diff options
| author | Mark Zhang <[email protected]> | 2019-09-16 07:11:52 +0000 |
|---|---|---|
| committer | Jason Gunthorpe <[email protected]> | 2019-10-01 13:30:16 +0000 |
| commit | 663912a6378a34fd4f43b8d873f0c6c6322d9d0e (patch) | |
| tree | aeb8ad7857d41adcbf4ae494384198616fd199e1 /drivers/infiniband/core/counters.c | |
| parent | Linux 5.4-rc1 (diff) | |
| download | kernel-663912a6378a34fd4f43b8d873f0c6c6322d9d0e.tar.gz kernel-663912a6378a34fd4f43b8d873f0c6c6322d9d0e.zip | |
RDMA/counter: Prevent QP counter manual binding in auto mode
If auto mode is configured, manual counter allocation and QP bind is not
allowed.
Fixes: 1bd8e0a9d0fd ("RDMA/counter: Allow manual mode configuration support")
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Zhang <[email protected]>
Signed-off-by: Leon Romanovsky <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
Diffstat (limited to 'drivers/infiniband/core/counters.c')
| -rw-r--r-- | drivers/infiniband/core/counters.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/infiniband/core/counters.c b/drivers/infiniband/core/counters.c index 680ad27f497d..736ab760025d 100644 --- a/drivers/infiniband/core/counters.c +++ b/drivers/infiniband/core/counters.c @@ -463,10 +463,15 @@ static struct rdma_counter *rdma_get_counter_by_id(struct ib_device *dev, int rdma_counter_bind_qpn(struct ib_device *dev, u8 port, u32 qp_num, u32 counter_id) { + struct rdma_port_counter *port_counter; struct rdma_counter *counter; struct ib_qp *qp; int ret; + port_counter = &dev->port_data[port].port_counter; + if (port_counter->mode.mode == RDMA_COUNTER_MODE_AUTO) + return -EINVAL; + qp = rdma_counter_get_qp(dev, qp_num); if (!qp) return -ENOENT; @@ -503,6 +508,7 @@ err: int rdma_counter_bind_qpn_alloc(struct ib_device *dev, u8 port, u32 qp_num, u32 *counter_id) { + struct rdma_port_counter *port_counter; struct rdma_counter *counter; struct ib_qp *qp; int ret; @@ -510,9 +516,13 @@ int rdma_counter_bind_qpn_alloc(struct ib_device *dev, u8 port, if (!rdma_is_port_valid(dev, port)) return -EINVAL; - if (!dev->port_data[port].port_counter.hstats) + port_counter = &dev->port_data[port].port_counter; + if (!port_counter->hstats) return -EOPNOTSUPP; + if (port_counter->mode.mode == RDMA_COUNTER_MODE_AUTO) + return -EINVAL; + qp = rdma_counter_get_qp(dev, qp_num); if (!qp) return -ENOENT; |
