Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Yamin Friedman and committed by
Jason Gunthorpe
f8fc8cd9 da662979

+30
+1
drivers/infiniband/Kconfig
··· 7 7 depends on m || IPV6 != m 8 8 depends on !ALPHA 9 9 select IRQ_POLL 10 + select DIMLIB 10 11 ---help--- 11 12 Core support for InfiniBand (IB). Make sure to also select 12 13 any protocols you wish to use as well as drivers for your
+1
drivers/infiniband/core/core_priv.h
··· 60 60 int ib_device_register_sysfs(struct ib_device *device); 61 61 void ib_device_unregister_sysfs(struct ib_device *device); 62 62 int ib_device_rename(struct ib_device *ibdev, const char *name); 63 + int ib_device_set_dim(struct ib_device *ibdev, u8 use_dim); 63 64 64 65 typedef void (*roce_netdev_callback)(struct ib_device *device, u8 port, 65 66 struct net_device *idev, void *cookie);
+9
drivers/infiniband/core/device.c
··· 448 448 return 0; 449 449 } 450 450 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 + 451 460 static int alloc_name(struct ib_device *ibdev, const char *name) 452 461 { 453 462 struct ib_device *device;
+14
drivers/infiniband/core/nldev.c
··· 52 52 .len = RDMA_NLDEV_ATTR_EMPTY_STRING }, 53 53 [RDMA_NLDEV_ATTR_CHARDEV_TYPE] = { .type = NLA_NUL_STRING, 54 54 .len = RDMA_NLDEV_ATTR_CHARDEV_TYPE_SIZE }, 55 + [RDMA_NLDEV_ATTR_DEV_DIM] = { .type = NLA_U8 }, 55 56 [RDMA_NLDEV_ATTR_DEV_INDEX] = { .type = NLA_U32 }, 56 57 [RDMA_NLDEV_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, 57 58 .len = IB_DEVICE_NAME_MAX }, ··· 252 251 RDMA_NLDEV_ATTR_PAD)) 253 252 return -EMSGSIZE; 254 253 if (nla_put_u8(msg, RDMA_NLDEV_ATTR_DEV_NODE_TYPE, device->node_type)) 254 + return -EMSGSIZE; 255 + if (nla_put_u8(msg, RDMA_NLDEV_ATTR_DEV_DIM, device->use_cq_dim)) 255 256 return -EMSGSIZE; 256 257 257 258 /* ··· 553 550 /* Poll context is only valid for kernel CQs */ 554 551 if (rdma_is_kernel_res(res) && 555 552 nla_put_u8(msg, RDMA_NLDEV_ATTR_RES_POLL_CTX, cq->poll_ctx)) 553 + goto err; 554 + 555 + if (nla_put_u8(msg, RDMA_NLDEV_ATTR_DEV_DIM, (cq->dim != NULL))) 556 556 goto err; 557 557 558 558 if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_CQN, res->id)) ··· 874 868 ns_fd = nla_get_u32(tb[RDMA_NLDEV_NET_NS_FD]); 875 869 err = ib_device_set_netns_put(skb, device, ns_fd); 876 870 goto put_done; 871 + } 872 + 873 + if (tb[RDMA_NLDEV_ATTR_DEV_DIM]) { 874 + u8 use_dim; 875 + 876 + use_dim = nla_get_u8(tb[RDMA_NLDEV_ATTR_DEV_DIM]); 877 + err = ib_device_set_dim(device, use_dim); 878 + goto done; 877 879 } 878 880 879 881 done:
+5
include/uapi/rdma/rdma_netlink.h
··· 521 521 RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_VALUE, /* u64 */ 522 522 523 523 /* 524 + * CQ adaptive moderatio (DIM) 525 + */ 526 + RDMA_NLDEV_ATTR_DEV_DIM, /* u8 */ 527 + 528 + /* 524 529 * Always the end 525 530 */ 526 531 RDMA_NLDEV_ATTR_MAX