Commit d97de888 authored by Mark Zhang's avatar Mark Zhang Committed by Doug Ledford

RDMA/counter: Prevent QP counter binding if counters unsupported

In case of rdma_counter_init() fails, counter allocation and QP bind
should not be allowed.

Fixes: 413d3347 ("RDMA/counter: Add set/clear per-port auto mode support")
Fixes: 1bd8e0a9 ("RDMA/counter: Allow manual mode configuration support")
Signed-off-by: default avatarMark Zhang <markz@mellanox.com>
Reviewed-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Link: https://lore.kernel.org/r/20190807101819.7581-1-leon@kernel.orgSigned-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent f591822c
...@@ -38,6 +38,9 @@ int rdma_counter_set_auto_mode(struct ib_device *dev, u8 port, ...@@ -38,6 +38,9 @@ int rdma_counter_set_auto_mode(struct ib_device *dev, u8 port,
int ret; int ret;
port_counter = &dev->port_data[port].port_counter; port_counter = &dev->port_data[port].port_counter;
if (!port_counter->hstats)
return -EOPNOTSUPP;
mutex_lock(&port_counter->lock); mutex_lock(&port_counter->lock);
if (on) { if (on) {
ret = __counter_set_mode(&port_counter->mode, ret = __counter_set_mode(&port_counter->mode,
...@@ -509,6 +512,9 @@ int rdma_counter_bind_qpn_alloc(struct ib_device *dev, u8 port, ...@@ -509,6 +512,9 @@ int rdma_counter_bind_qpn_alloc(struct ib_device *dev, u8 port,
if (!rdma_is_port_valid(dev, port)) if (!rdma_is_port_valid(dev, port))
return -EINVAL; return -EINVAL;
if (!dev->port_data[port].port_counter.hstats)
return -EOPNOTSUPP;
qp = rdma_counter_get_qp(dev, qp_num); qp = rdma_counter_get_qp(dev, qp_num);
if (!qp) if (!qp)
return -ENOENT; return -ENOENT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment