Skip to content

Commit 24e83b7

Browse files
committed
RDMA/core: Pass port to counter bind/unbind operations
JIRA: https://issues.redhat.com/browse/RHEL-75591 commit 88ae02f Author: Patrisious Haddad <[email protected]> Date: Thu Mar 13 16:18:44 2025 +0200 RDMA/core: Pass port to counter bind/unbind operations This will be useful for the next patches in the series since port number is needed for optional counters binding and unbinding. Note that this change is needed since when the operation is done qp->port isn't necessarily initialized yet and can't be used. Signed-off-by: Patrisious Haddad <[email protected]> Reviewed-by: Mark Bloch <[email protected]> Link: https://patch.msgid.link/b6f6797844acbd517358e8d2a270ea9b3e6ecba1.1741875070.git.leon@kernel.org Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Kamal Heib <[email protected]>
1 parent 4efe160 commit 24e83b7

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

drivers/infiniband/core/counters.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static void auto_mode_init_counter(struct rdma_counter *counter,
9393
}
9494

9595
static int __rdma_counter_bind_qp(struct rdma_counter *counter,
96-
struct ib_qp *qp)
96+
struct ib_qp *qp, u32 port)
9797
{
9898
int ret;
9999

@@ -104,7 +104,7 @@ static int __rdma_counter_bind_qp(struct rdma_counter *counter,
104104
return -EOPNOTSUPP;
105105

106106
mutex_lock(&counter->lock);
107-
ret = qp->device->ops.counter_bind_qp(counter, qp);
107+
ret = qp->device->ops.counter_bind_qp(counter, qp, port);
108108
mutex_unlock(&counter->lock);
109109

110110
return ret;
@@ -196,7 +196,7 @@ static struct rdma_counter *alloc_and_bind(struct ib_device *dev, u32 port,
196196
kref_init(&counter->kref);
197197
mutex_init(&counter->lock);
198198

199-
ret = __rdma_counter_bind_qp(counter, qp);
199+
ret = __rdma_counter_bind_qp(counter, qp, port);
200200
if (ret)
201201
goto err_mode;
202202

@@ -247,7 +247,7 @@ static bool auto_mode_match(struct ib_qp *qp, struct rdma_counter *counter,
247247
return match;
248248
}
249249

250-
static int __rdma_counter_unbind_qp(struct ib_qp *qp)
250+
static int __rdma_counter_unbind_qp(struct ib_qp *qp, u32 port)
251251
{
252252
struct rdma_counter *counter = qp->counter;
253253
int ret;
@@ -256,7 +256,7 @@ static int __rdma_counter_unbind_qp(struct ib_qp *qp)
256256
return -EOPNOTSUPP;
257257

258258
mutex_lock(&counter->lock);
259-
ret = qp->device->ops.counter_unbind_qp(qp);
259+
ret = qp->device->ops.counter_unbind_qp(qp, port);
260260
mutex_unlock(&counter->lock);
261261

262262
return ret;
@@ -348,7 +348,7 @@ int rdma_counter_bind_qp_auto(struct ib_qp *qp, u32 port)
348348

349349
counter = rdma_get_counter_auto_mode(qp, port);
350350
if (counter) {
351-
ret = __rdma_counter_bind_qp(counter, qp);
351+
ret = __rdma_counter_bind_qp(counter, qp, port);
352352
if (ret) {
353353
kref_put(&counter->kref, counter_release);
354354
return ret;
@@ -368,15 +368,15 @@ int rdma_counter_bind_qp_auto(struct ib_qp *qp, u32 port)
368368
* @force:
369369
* true - Decrease the counter ref-count anyway (e.g., qp destroy)
370370
*/
371-
int rdma_counter_unbind_qp(struct ib_qp *qp, bool force)
371+
int rdma_counter_unbind_qp(struct ib_qp *qp, u32 port, bool force)
372372
{
373373
struct rdma_counter *counter = qp->counter;
374374
int ret;
375375

376376
if (!counter)
377377
return -EINVAL;
378378

379-
ret = __rdma_counter_unbind_qp(qp);
379+
ret = __rdma_counter_unbind_qp(qp, port);
380380
if (ret && !force)
381381
return ret;
382382

@@ -523,7 +523,7 @@ int rdma_counter_bind_qpn(struct ib_device *dev, u32 port,
523523
goto err_task;
524524
}
525525

526-
ret = __rdma_counter_bind_qp(counter, qp);
526+
ret = __rdma_counter_bind_qp(counter, qp, port);
527527
if (ret)
528528
goto err_task;
529529

@@ -614,7 +614,7 @@ int rdma_counter_unbind_qpn(struct ib_device *dev, u32 port,
614614
goto out;
615615
}
616616

617-
ret = rdma_counter_unbind_qp(qp, false);
617+
ret = rdma_counter_unbind_qp(qp, port, false);
618618

619619
out:
620620
rdma_restrack_put(&qp->res);

drivers/infiniband/core/verbs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,7 @@ int ib_destroy_qp_user(struct ib_qp *qp, struct ib_udata *udata)
21052105
if (!qp->uobject)
21062106
rdma_rw_cleanup_mrs(qp);
21072107

2108-
rdma_counter_unbind_qp(qp, true);
2108+
rdma_counter_unbind_qp(qp, qp->port, true);
21092109
ret = qp->device->ops.destroy_qp(qp, udata);
21102110
if (ret) {
21112111
if (sec)

drivers/infiniband/hw/mlx5/counters.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ static int mlx5_ib_counter_dealloc(struct rdma_counter *counter)
543543
}
544544

545545
static int mlx5_ib_counter_bind_qp(struct rdma_counter *counter,
546-
struct ib_qp *qp)
546+
struct ib_qp *qp, u32 port)
547547
{
548548
struct mlx5_ib_dev *dev = to_mdev(qp->device);
549549
int err;
@@ -575,7 +575,7 @@ static int mlx5_ib_counter_bind_qp(struct rdma_counter *counter,
575575
return err;
576576
}
577577

578-
static int mlx5_ib_counter_unbind_qp(struct ib_qp *qp)
578+
static int mlx5_ib_counter_unbind_qp(struct ib_qp *qp, u32 port)
579579
{
580580
return mlx5_ib_qp_set_counter(qp, NULL);
581581
}

include/rdma/ib_verbs.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2642,12 +2642,13 @@ struct ib_device_ops {
26422642
* @counter - The counter to be bound. If counter->id is zero then
26432643
* the driver needs to allocate a new counter and set counter->id
26442644
*/
2645-
int (*counter_bind_qp)(struct rdma_counter *counter, struct ib_qp *qp);
2645+
int (*counter_bind_qp)(struct rdma_counter *counter, struct ib_qp *qp,
2646+
u32 port);
26462647
/**
26472648
* counter_unbind_qp - Unbind the qp from the dynamically-allocated
26482649
* counter and bind it onto the default one
26492650
*/
2650-
int (*counter_unbind_qp)(struct ib_qp *qp);
2651+
int (*counter_unbind_qp)(struct ib_qp *qp, u32 port);
26512652
/**
26522653
* counter_dealloc -De-allocate the hw counter
26532654
*/

include/rdma/rdma_counter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ int rdma_counter_set_auto_mode(struct ib_device *dev, u32 port,
5151
bool bind_opcnt,
5252
struct netlink_ext_ack *extack);
5353
int rdma_counter_bind_qp_auto(struct ib_qp *qp, u32 port);
54-
int rdma_counter_unbind_qp(struct ib_qp *qp, bool force);
54+
int rdma_counter_unbind_qp(struct ib_qp *qp, u32 port, bool force);
5555

5656
int rdma_counter_query_stats(struct rdma_counter *counter);
5757
u64 rdma_counter_get_hwstat_value(struct ib_device *dev, u32 port, u32 index);

0 commit comments

Comments
 (0)