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

Configure Feed

Select the types of activity you want to include in your feed.

IB/core: Add query_port_speed verb

Add new ibv_query_port_speed() verb to enable applications to query
the effective bandwidth of a port.

This verb is particularly useful when the speed is not a multiplication
of IB speed and width where width is 2^n.

Signed-off-by: Or Har-Toov <ohartoov@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Edward Srouji <edwards@nvidia.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>

authored by

Or Har-Toov and committed by
Leon Romanovsky
51a07ce2 d4adeff2

+51
+1
drivers/infiniband/core/device.c
··· 2816 2816 SET_DEVICE_OP(dev_ops, query_gid); 2817 2817 SET_DEVICE_OP(dev_ops, query_pkey); 2818 2818 SET_DEVICE_OP(dev_ops, query_port); 2819 + SET_DEVICE_OP(dev_ops, query_port_speed); 2819 2820 SET_DEVICE_OP(dev_ops, query_qp); 2820 2821 SET_DEVICE_OP(dev_ops, query_srq); 2821 2822 SET_DEVICE_OP(dev_ops, query_ucontext);
+42
drivers/infiniband/core/uverbs_std_types_device.c
··· 209 209 &resp, sizeof(resp)); 210 210 } 211 211 212 + static int UVERBS_HANDLER(UVERBS_METHOD_QUERY_PORT_SPEED)( 213 + struct uverbs_attr_bundle *attrs) 214 + { 215 + struct ib_ucontext *ucontext; 216 + struct ib_device *ib_dev; 217 + u32 port_num; 218 + u64 speed; 219 + int ret; 220 + 221 + ucontext = ib_uverbs_get_ucontext(attrs); 222 + if (IS_ERR(ucontext)) 223 + return PTR_ERR(ucontext); 224 + ib_dev = ucontext->device; 225 + 226 + if (!ib_dev->ops.query_port_speed) 227 + return -EOPNOTSUPP; 228 + 229 + ret = uverbs_get_const(&port_num, attrs, 230 + UVERBS_ATTR_QUERY_PORT_SPEED_PORT_NUM); 231 + if (ret) 232 + return ret; 233 + 234 + if (!rdma_is_port_valid(ib_dev, port_num)) 235 + return -EINVAL; 236 + 237 + ret = ib_dev->ops.query_port_speed(ib_dev, port_num, &speed); 238 + if (ret) 239 + return ret; 240 + 241 + return uverbs_copy_to(attrs, UVERBS_ATTR_QUERY_PORT_SPEED_RESP, 242 + &speed, sizeof(speed)); 243 + } 244 + 212 245 static int UVERBS_HANDLER(UVERBS_METHOD_GET_CONTEXT)( 213 246 struct uverbs_attr_bundle *attrs) 214 247 { ··· 503 470 UA_MANDATORY)); 504 471 505 472 DECLARE_UVERBS_NAMED_METHOD( 473 + UVERBS_METHOD_QUERY_PORT_SPEED, 474 + UVERBS_ATTR_CONST_IN(UVERBS_ATTR_QUERY_PORT_SPEED_PORT_NUM, u32, 475 + UA_MANDATORY), 476 + UVERBS_ATTR_PTR_OUT(UVERBS_ATTR_QUERY_PORT_SPEED_RESP, 477 + UVERBS_ATTR_TYPE(u64), 478 + UA_MANDATORY)); 479 + 480 + DECLARE_UVERBS_NAMED_METHOD( 506 481 UVERBS_METHOD_QUERY_GID_TABLE, 507 482 UVERBS_ATTR_CONST_IN(UVERBS_ATTR_QUERY_GID_TABLE_ENTRY_SIZE, u64, 508 483 UA_MANDATORY), ··· 539 498 &UVERBS_METHOD(UVERBS_METHOD_INVOKE_WRITE), 540 499 &UVERBS_METHOD(UVERBS_METHOD_INFO_HANDLES), 541 500 &UVERBS_METHOD(UVERBS_METHOD_QUERY_PORT), 501 + &UVERBS_METHOD(UVERBS_METHOD_QUERY_PORT_SPEED), 542 502 &UVERBS_METHOD(UVERBS_METHOD_QUERY_CONTEXT), 543 503 &UVERBS_METHOD(UVERBS_METHOD_QUERY_GID_TABLE), 544 504 &UVERBS_METHOD(UVERBS_METHOD_QUERY_GID_ENTRY));
+2
include/rdma/ib_verbs.h
··· 2418 2418 int comp_vector); 2419 2419 int (*query_port)(struct ib_device *device, u32 port_num, 2420 2420 struct ib_port_attr *port_attr); 2421 + int (*query_port_speed)(struct ib_device *device, u32 port_num, 2422 + u64 *speed); 2421 2423 int (*modify_port)(struct ib_device *device, u32 port_num, 2422 2424 int port_modify_mask, 2423 2425 struct ib_port_modify *port_modify);
+6
include/uapi/rdma/ib_user_ioctl_cmds.h
··· 73 73 UVERBS_METHOD_QUERY_CONTEXT, 74 74 UVERBS_METHOD_QUERY_GID_TABLE, 75 75 UVERBS_METHOD_QUERY_GID_ENTRY, 76 + UVERBS_METHOD_QUERY_PORT_SPEED, 76 77 }; 77 78 78 79 enum uverbs_attrs_invoke_write_cmd_attr_ids { ··· 85 84 enum uverbs_attrs_query_port_cmd_attr_ids { 86 85 UVERBS_ATTR_QUERY_PORT_PORT_NUM, 87 86 UVERBS_ATTR_QUERY_PORT_RESP, 87 + }; 88 + 89 + enum uverbs_attrs_query_port_speed_cmd_attr_ids { 90 + UVERBS_ATTR_QUERY_PORT_SPEED_PORT_NUM, 91 + UVERBS_ATTR_QUERY_PORT_SPEED_RESP, 88 92 }; 89 93 90 94 enum uverbs_attrs_get_context_attr_ids {