Skip to content

Commit f8fc8cd

Browse files
yaminfjgunthorpe
authored andcommitted
RDMA/nldev: Added configuration of RDMA dynamic interrupt moderation to netlink
Added parameter in ib_device for enabling dynamic interrupt moderation so that it can be configured in userspace using rdma tool. In order to set adaptive-moderation for an ib device the command is: rdma dev set [DEV] adaptive-moderation [on|off] Please set on/off. rdma dev show 0: mlx5_0: node_type ca fw 16.26.0055 node_guid 248a:0703:00a5:29d0 sys_image_guid 248a:0703:00a5:29d0 adaptive-moderation on rdma resource show cq dev mlx5_0 cqn 0 cqe 1023 users 4 poll-ctx UNBOUND_WORKQUEUE adaptive-moderation off comm [ib_core] Signed-off-by: Yamin Friedman <yaminf@mellanox.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent da66297 commit f8fc8cd

5 files changed

Lines changed: 30 additions & 0 deletions

File tree

‎drivers/infiniband/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ menuconfig INFINIBAND
77
depends on m || IPV6 != m
88
depends on !ALPHA
99
select IRQ_POLL
10+
select DIMLIB
1011
---help---
1112
Core support for InfiniBand (IB). Make sure to also select
1213
any protocols you wish to use as well as drivers for your

‎drivers/infiniband/core/core_priv.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ extern bool ib_devices_shared_netns;
6060
int ib_device_register_sysfs(struct ib_device *device);
6161
void ib_device_unregister_sysfs(struct ib_device *device);
6262
int ib_device_rename(struct ib_device *ibdev, const char *name);
63+
int ib_device_set_dim(struct ib_device *ibdev, u8 use_dim);
6364

6465
typedef void (*roce_netdev_callback)(struct ib_device *device, u8 port,
6566
struct net_device *idev, void *cookie);

‎drivers/infiniband/core/device.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,15 @@ int ib_device_rename(struct ib_device *ibdev, const char *name)
448448
return 0;
449449
}
450450

451+
int ib_device_set_dim(struct ib_device *ibdev, u8 use_dim)
452+
{
453+
if (use_dim > 1)
454+
return -EINVAL;
455+
ibdev->use_cq_dim = use_dim;
456+
457+
return 0;
458+
}
459+
451460
static int alloc_name(struct ib_device *ibdev, const char *name)
452461
{
453462
struct ib_device *device;

‎drivers/infiniband/core/nldev.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
5252
.len = RDMA_NLDEV_ATTR_EMPTY_STRING },
5353
[RDMA_NLDEV_ATTR_CHARDEV_TYPE] = { .type = NLA_NUL_STRING,
5454
.len = RDMA_NLDEV_ATTR_CHARDEV_TYPE_SIZE },
55+
[RDMA_NLDEV_ATTR_DEV_DIM] = { .type = NLA_U8 },
5556
[RDMA_NLDEV_ATTR_DEV_INDEX] = { .type = NLA_U32 },
5657
[RDMA_NLDEV_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING,
5758
.len = IB_DEVICE_NAME_MAX },
@@ -252,6 +253,8 @@ static int fill_dev_info(struct sk_buff *msg, struct ib_device *device)
252253
return -EMSGSIZE;
253254
if (nla_put_u8(msg, RDMA_NLDEV_ATTR_DEV_NODE_TYPE, device->node_type))
254255
return -EMSGSIZE;
256+
if (nla_put_u8(msg, RDMA_NLDEV_ATTR_DEV_DIM, device->use_cq_dim))
257+
return -EMSGSIZE;
255258

256259
/*
257260
* Link type is determined on first port and mlx4 device
@@ -552,6 +555,9 @@ static int fill_res_cq_entry(struct sk_buff *msg, bool has_cap_net_admin,
552555
nla_put_u8(msg, RDMA_NLDEV_ATTR_RES_POLL_CTX, cq->poll_ctx))
553556
goto err;
554557

558+
if (nla_put_u8(msg, RDMA_NLDEV_ATTR_DEV_DIM, (cq->dim != NULL)))
559+
goto err;
560+
555561
if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_CQN, res->id))
556562
goto err;
557563
if (!rdma_is_kernel_res(res) &&
@@ -870,6 +876,14 @@ static int nldev_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
870876
goto put_done;
871877
}
872878

879+
if (tb[RDMA_NLDEV_ATTR_DEV_DIM]) {
880+
u8 use_dim;
881+
882+
use_dim = nla_get_u8(tb[RDMA_NLDEV_ATTR_DEV_DIM]);
883+
err = ib_device_set_dim(device, use_dim);
884+
goto done;
885+
}
886+
873887
done:
874888
ib_device_put(device);
875889
put_done:

‎include/uapi/rdma/rdma_netlink.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,11 @@ enum rdma_nldev_attr {
520520
RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_NAME, /* string */
521521
RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_VALUE, /* u64 */
522522

523+
/*
524+
* CQ adaptive moderatio (DIM)
525+
*/
526+
RDMA_NLDEV_ATTR_DEV_DIM, /* u8 */
527+
523528
/*
524529
* Always the end
525530
*/

0 commit comments

Comments
 (0)