Skip to content

Commit 8504597

Browse files
committed
verbs: Introduce ibv_query_port_speed() verb
Add a new API, ibv_query_port_speed(), which enables applications to query the effective bandwidth of a port. This is useful for VF LAG and multiport LAG configurations, since ibv_query_port does not report the combined bandwidth of all aggregated ports. In any case, the API can be used on non-aggregated devices as well. Signed-off-by: Or Har-Toov <ohartoov@nvidia.com> Reviewed-by: Patrisious Haddad <phaddad@nvidia.com> Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
1 parent d026300 commit 8504597

9 files changed

Lines changed: 87 additions & 1 deletion

File tree

debian/libibverbs1.symbols

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ libibverbs.so.1 libibverbs1 #MINVER#
1313
IBVERBS_1.13@IBVERBS_1.13 35
1414
IBVERBS_1.14@IBVERBS_1.14 36
1515
IBVERBS_1.15@IBVERBS_1.15 59
16+
IBVERBS_1.16@IBVERBS_1.16 62
1617
(symver)IBVERBS_PRIVATE_59 59
1718
_ibv_query_gid_ex@IBVERBS_1.11 32
1819
_ibv_query_gid_table@IBVERBS_1.11 32
@@ -100,6 +101,7 @@ libibverbs.so.1 libibverbs1 #MINVER#
100101
ibv_query_pkey@IBVERBS_1.1 1.1.6
101102
ibv_query_port@IBVERBS_1.0 1.1.6
102103
ibv_query_port@IBVERBS_1.1 1.1.6
104+
ibv_query_port_speed@IBVERBS_1.16 62
103105
ibv_query_qp@IBVERBS_1.0 1.1.6
104106
ibv_query_qp@IBVERBS_1.1 1.1.6
105107
ibv_query_qp_data_in_order@IBVERBS_1.14 36

libibverbs/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ configure_file("libibverbs.map.in"
2121

2222
rdma_library(ibverbs "${CMAKE_CURRENT_BINARY_DIR}/libibverbs.map"
2323
# See Documentation/versioning.md
24-
1 1.15.${PACKAGE_VERSION}
24+
1 1.16.${PACKAGE_VERSION}
2525
all_providers.c
2626
cmd.c
2727
cmd_ah.c

libibverbs/driver.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ struct verbs_context_ops {
447447
int (*query_ece)(struct ibv_qp *qp, struct ibv_ece *ece);
448448
int (*query_port)(struct ibv_context *context, uint8_t port_num,
449449
struct ibv_port_attr *port_attr);
450+
int (*query_port_speed)(struct ibv_context *context, uint32_t port_num,
451+
uint64_t *speed);
450452
int (*query_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr,
451453
int attr_mask, struct ibv_qp_init_attr *init_attr);
452454
int (*query_qp_data_in_order)(struct ibv_qp *qp, enum ibv_wr_opcode op,

libibverbs/dummy_ops.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,12 @@ static int query_port(struct ibv_context *context, uint8_t port_num,
421421
return EOPNOTSUPP;
422422
}
423423

424+
static int query_port_speed(struct ibv_context *context, uint32_t port_num,
425+
uint64_t *speed)
426+
{
427+
return EOPNOTSUPP;
428+
}
429+
424430
static int query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask,
425431
struct ibv_qp_init_attr *init_attr)
426432
{
@@ -585,6 +591,7 @@ const struct verbs_context_ops verbs_dummy_ops = {
585591
query_device_ex,
586592
query_ece,
587593
query_port,
594+
query_port_speed,
588595
query_qp,
589596
query_qp_data_in_order,
590597
query_rt_values,
@@ -713,6 +720,7 @@ void verbs_set_ops(struct verbs_context *vctx,
713720
SET_OP(vctx, query_device_ex);
714721
SET_PRIV_OP_IC(vctx, query_ece);
715722
SET_PRIV_OP_IC(ctx, query_port);
723+
SET_PRIV_OP_IC(ctx, query_port_speed);
716724
SET_PRIV_OP(ctx, query_qp);
717725
SET_PRIV_OP_IC(ctx, query_qp_data_in_order);
718726
SET_OP(vctx, query_rt_values);

libibverbs/libibverbs.map.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ IBVERBS_1.15 {
171171
ibv_reg_mr_ex;
172172
} IBVERBS_1.14;
173173

174+
IBVERBS_1.16 {
175+
global:
176+
ibv_query_port_speed;
177+
} IBVERBS_1.15;
178+
174179
/* If any symbols in this stanza change ABI then the entire staza gets a new symbol
175180
version. See the top level CMakeLists.txt for this setting. */
176181

libibverbs/man/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ rdma_man_pages(
6464
ibv_query_gid_table.3.md
6565
ibv_query_pkey.3.md
6666
ibv_query_port.3
67+
ibv_query_port_speed.3.md
6768
ibv_query_qp.3
6869
ibv_query_qp_data_in_order.3.md
6970
ibv_query_rt_values_ex.3
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
date: 2025-10-19
3+
footer: libibverbs
4+
header: "Libibverbs Programmer's Manual"
5+
layout: page
6+
license: 'Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md'
7+
section: 3
8+
title: ibv_query_port_speed
9+
---
10+
11+
# NAME
12+
13+
ibv_query_port_speed - query an RDMA port's effective bandwidth in 100Mb/s granularity
14+
15+
# SYNOPSIS
16+
17+
```c
18+
#include <infiniband/verbs.h>
19+
20+
int ibv_query_port_speed(struct ibv_context *context, uint32_t port_num, uint64_t *port_speed);
21+
22+
```
23+
24+
25+
# DESCRIPTION
26+
27+
**ibv_query_port_speed()** Queries the device of the context at the given port number
28+
for the effective bandwidth of the port in 100Mb/s granularity.
29+
30+
# ARGUMENTS
31+
*context*
32+
: The device context.
33+
34+
*port_num*
35+
: The device port number which needs to be queried.
36+
37+
*port_speed*
38+
: The effective bandwidth of port for device context in a granularity of 100 Mb/s
39+
40+
# RETURN VALUE
41+
42+
**ibv_query_port_speed()** Returns 0 on success, or the value of errno on failure (which indicates the failure reason)
43+
44+
# NOTES
45+
46+
port_speed pointer value is valid only when the function returns 0.
47+
48+
# SEE ALSO
49+
50+
**ibv_query_port**(3)
51+
52+
# AUTHOR
53+
54+
Patrisious Haddad <phaddad@nvidia.com>
55+
Or Har-Toov <ohartoov@nvidia.com>

libibverbs/verbs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,3 +1186,10 @@ int ibv_query_ece(struct ibv_qp *qp, struct ibv_ece *ece)
11861186
{
11871187
return get_ops(qp->context)->query_ece(qp, ece);
11881188
}
1189+
1190+
int ibv_query_port_speed(struct ibv_context *context, uint32_t port_num,
1191+
uint64_t *port_speed)
1192+
{
1193+
return get_ops(context)->query_port_speed(context, port_num,
1194+
port_speed);
1195+
}

libibverbs/verbs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2455,6 +2455,12 @@ int ibv_query_device(struct ibv_context *context,
24552455
int ibv_query_port(struct ibv_context *context, uint8_t port_num,
24562456
struct _compat_ibv_port_attr *port_attr);
24572457

2458+
/**
2459+
* ibv_query_port_speed - Get port effective speed in 100 Mb/s granularity.
2460+
*/
2461+
int ibv_query_port_speed(struct ibv_context *context, uint32_t port_num,
2462+
uint64_t *port_speed);
2463+
24582464
static inline int ___ibv_query_port(struct ibv_context *context,
24592465
uint8_t port_num,
24602466
struct ibv_port_attr *port_attr)

0 commit comments

Comments
 (0)