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

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 <phaddad@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Link: https://patch.msgid.link/b6f6797844acbd517358e8d2a270ea9b3e6ecba1.1741875070.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>

authored by

Patrisious Haddad and committed by
Leon Romanovsky
88ae02fe da371107

+17 -16
+10 -10
drivers/infiniband/core/counters.c
··· 93 93 } 94 94 95 95 static int __rdma_counter_bind_qp(struct rdma_counter *counter, 96 - struct ib_qp *qp) 96 + struct ib_qp *qp, u32 port) 97 97 { 98 98 int ret; 99 99 ··· 104 104 return -EOPNOTSUPP; 105 105 106 106 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); 108 108 mutex_unlock(&counter->lock); 109 109 110 110 return ret; ··· 196 196 kref_init(&counter->kref); 197 197 mutex_init(&counter->lock); 198 198 199 - ret = __rdma_counter_bind_qp(counter, qp); 199 + ret = __rdma_counter_bind_qp(counter, qp, port); 200 200 if (ret) 201 201 goto err_mode; 202 202 ··· 247 247 return match; 248 248 } 249 249 250 - static int __rdma_counter_unbind_qp(struct ib_qp *qp) 250 + static int __rdma_counter_unbind_qp(struct ib_qp *qp, u32 port) 251 251 { 252 252 struct rdma_counter *counter = qp->counter; 253 253 int ret; ··· 256 256 return -EOPNOTSUPP; 257 257 258 258 mutex_lock(&counter->lock); 259 - ret = qp->device->ops.counter_unbind_qp(qp); 259 + ret = qp->device->ops.counter_unbind_qp(qp, port); 260 260 mutex_unlock(&counter->lock); 261 261 262 262 return ret; ··· 348 348 349 349 counter = rdma_get_counter_auto_mode(qp, port); 350 350 if (counter) { 351 - ret = __rdma_counter_bind_qp(counter, qp); 351 + ret = __rdma_counter_bind_qp(counter, qp, port); 352 352 if (ret) { 353 353 kref_put(&counter->kref, counter_release); 354 354 return ret; ··· 368 368 * @force: 369 369 * true - Decrease the counter ref-count anyway (e.g., qp destroy) 370 370 */ 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) 372 372 { 373 373 struct rdma_counter *counter = qp->counter; 374 374 int ret; ··· 376 376 if (!counter) 377 377 return -EINVAL; 378 378 379 - ret = __rdma_counter_unbind_qp(qp); 379 + ret = __rdma_counter_unbind_qp(qp, port); 380 380 if (ret && !force) 381 381 return ret; 382 382 ··· 523 523 goto err_task; 524 524 } 525 525 526 - ret = __rdma_counter_bind_qp(counter, qp); 526 + ret = __rdma_counter_bind_qp(counter, qp, port); 527 527 if (ret) 528 528 goto err_task; 529 529 ··· 614 614 goto out; 615 615 } 616 616 617 - ret = rdma_counter_unbind_qp(qp, false); 617 + ret = rdma_counter_unbind_qp(qp, port, false); 618 618 619 619 out: 620 620 rdma_restrack_put(&qp->res);
+1 -1
drivers/infiniband/core/verbs.c
··· 2105 2105 if (!qp->uobject) 2106 2106 rdma_rw_cleanup_mrs(qp); 2107 2107 2108 - rdma_counter_unbind_qp(qp, true); 2108 + rdma_counter_unbind_qp(qp, qp->port, true); 2109 2109 ret = qp->device->ops.destroy_qp(qp, udata); 2110 2110 if (ret) { 2111 2111 if (sec)
+2 -2
drivers/infiniband/hw/mlx5/counters.c
··· 562 562 } 563 563 564 564 static int mlx5_ib_counter_bind_qp(struct rdma_counter *counter, 565 - struct ib_qp *qp) 565 + struct ib_qp *qp, u32 port) 566 566 { 567 567 struct mlx5_ib_dev *dev = to_mdev(qp->device); 568 568 int err; ··· 594 594 return err; 595 595 } 596 596 597 - static int mlx5_ib_counter_unbind_qp(struct ib_qp *qp) 597 + static int mlx5_ib_counter_unbind_qp(struct ib_qp *qp, u32 port) 598 598 { 599 599 return mlx5_ib_qp_set_counter(qp, NULL); 600 600 }
+3 -2
include/rdma/ib_verbs.h
··· 2644 2644 * @counter - The counter to be bound. If counter->id is zero then 2645 2645 * the driver needs to allocate a new counter and set counter->id 2646 2646 */ 2647 - int (*counter_bind_qp)(struct rdma_counter *counter, struct ib_qp *qp); 2647 + int (*counter_bind_qp)(struct rdma_counter *counter, struct ib_qp *qp, 2648 + u32 port); 2648 2649 /** 2649 2650 * counter_unbind_qp - Unbind the qp from the dynamically-allocated 2650 2651 * counter and bind it onto the default one 2651 2652 */ 2652 - int (*counter_unbind_qp)(struct ib_qp *qp); 2653 + int (*counter_unbind_qp)(struct ib_qp *qp, u32 port); 2653 2654 /** 2654 2655 * counter_dealloc -De-allocate the hw counter 2655 2656 */
+1 -1
include/rdma/rdma_counter.h
··· 51 51 bool bind_opcnt, 52 52 struct netlink_ext_ack *extack); 53 53 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); 55 55 56 56 int rdma_counter_query_stats(struct rdma_counter *counter); 57 57 u64 rdma_counter_get_hwstat_value(struct ib_device *dev, u32 port, u32 index);