Commit 663912a6 authored by Mark Zhang's avatar Mark Zhang Committed by Jason Gunthorpe

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: 1bd8e0a9 ("RDMA/counter: Allow manual mode configuration support")
Link: https://lore.kernel.org/r/20190916071154.20383-3-leon@kernel.orgSigned-off-by: default avatarMark Zhang <markz@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 54ecb8f7
...@@ -463,10 +463,15 @@ static struct rdma_counter *rdma_get_counter_by_id(struct ib_device *dev, ...@@ -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, int rdma_counter_bind_qpn(struct ib_device *dev, u8 port,
u32 qp_num, u32 counter_id) u32 qp_num, u32 counter_id)
{ {
struct rdma_port_counter *port_counter;
struct rdma_counter *counter; struct rdma_counter *counter;
struct ib_qp *qp; struct ib_qp *qp;
int ret; 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); qp = rdma_counter_get_qp(dev, qp_num);
if (!qp) if (!qp)
return -ENOENT; return -ENOENT;
...@@ -503,6 +508,7 @@ int rdma_counter_bind_qpn(struct ib_device *dev, u8 port, ...@@ -503,6 +508,7 @@ int rdma_counter_bind_qpn(struct ib_device *dev, u8 port,
int rdma_counter_bind_qpn_alloc(struct ib_device *dev, u8 port, int rdma_counter_bind_qpn_alloc(struct ib_device *dev, u8 port,
u32 qp_num, u32 *counter_id) u32 qp_num, u32 *counter_id)
{ {
struct rdma_port_counter *port_counter;
struct rdma_counter *counter; struct rdma_counter *counter;
struct ib_qp *qp; struct ib_qp *qp;
int ret; int ret;
...@@ -510,9 +516,13 @@ int rdma_counter_bind_qpn_alloc(struct ib_device *dev, u8 port, ...@@ -510,9 +516,13 @@ 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) port_counter = &dev->port_data[port].port_counter;
if (!port_counter->hstats)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (port_counter->mode.mode == RDMA_COUNTER_MODE_AUTO)
return -EINVAL;
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