mirror of
https://github.com/torvalds/linux.git
synced 2024-12-23 03:11:46 +00:00
RDMA/cma: Use RDMA device port iterator
Use RDMA device port iterator to avoid open coding. Link: https://lore.kernel.org/r/20200126142652.104803-4-leon@kernel.org Signed-off-by: Parav Pandit <parav@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
parent
081ea5195a
commit
cc055dd3a7
@ -728,8 +728,8 @@ static int cma_iw_acquire_dev(struct rdma_id_private *id_priv,
|
|||||||
struct cma_device *cma_dev;
|
struct cma_device *cma_dev;
|
||||||
enum ib_gid_type gid_type;
|
enum ib_gid_type gid_type;
|
||||||
int ret = -ENODEV;
|
int ret = -ENODEV;
|
||||||
|
unsigned int port;
|
||||||
union ib_gid gid;
|
union ib_gid gid;
|
||||||
u8 port;
|
|
||||||
|
|
||||||
if (dev_addr->dev_type != ARPHRD_INFINIBAND &&
|
if (dev_addr->dev_type != ARPHRD_INFINIBAND &&
|
||||||
id_priv->id.ps == RDMA_PS_IPOIB)
|
id_priv->id.ps == RDMA_PS_IPOIB)
|
||||||
@ -753,7 +753,8 @@ static int cma_iw_acquire_dev(struct rdma_id_private *id_priv,
|
|||||||
}
|
}
|
||||||
|
|
||||||
list_for_each_entry(cma_dev, &dev_list, list) {
|
list_for_each_entry(cma_dev, &dev_list, list) {
|
||||||
for (port = 1; port <= cma_dev->device->phys_port_cnt; ++port) {
|
rdma_for_each_port (cma_dev->device, port) {
|
||||||
|
|
||||||
if (listen_id_priv->cma_dev == cma_dev &&
|
if (listen_id_priv->cma_dev == cma_dev &&
|
||||||
listen_id_priv->id.port_num == port)
|
listen_id_priv->id.port_num == port)
|
||||||
continue;
|
continue;
|
||||||
@ -786,8 +787,8 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
|
|||||||
struct cma_device *cma_dev, *cur_dev;
|
struct cma_device *cma_dev, *cur_dev;
|
||||||
struct sockaddr_ib *addr;
|
struct sockaddr_ib *addr;
|
||||||
union ib_gid gid, sgid, *dgid;
|
union ib_gid gid, sgid, *dgid;
|
||||||
|
unsigned int p;
|
||||||
u16 pkey, index;
|
u16 pkey, index;
|
||||||
u8 p;
|
|
||||||
enum ib_port_state port_state;
|
enum ib_port_state port_state;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -798,7 +799,7 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
|
|||||||
|
|
||||||
mutex_lock(&lock);
|
mutex_lock(&lock);
|
||||||
list_for_each_entry(cur_dev, &dev_list, list) {
|
list_for_each_entry(cur_dev, &dev_list, list) {
|
||||||
for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) {
|
rdma_for_each_port (cur_dev->device, p) {
|
||||||
if (!rdma_cap_af_ib(cur_dev->device, p))
|
if (!rdma_cap_af_ib(cur_dev->device, p))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -3029,9 +3030,9 @@ static int cma_bind_loopback(struct rdma_id_private *id_priv)
|
|||||||
struct cma_device *cma_dev, *cur_dev;
|
struct cma_device *cma_dev, *cur_dev;
|
||||||
union ib_gid gid;
|
union ib_gid gid;
|
||||||
enum ib_port_state port_state;
|
enum ib_port_state port_state;
|
||||||
|
unsigned int p;
|
||||||
u16 pkey;
|
u16 pkey;
|
||||||
int ret;
|
int ret;
|
||||||
u8 p;
|
|
||||||
|
|
||||||
cma_dev = NULL;
|
cma_dev = NULL;
|
||||||
mutex_lock(&lock);
|
mutex_lock(&lock);
|
||||||
@ -3043,7 +3044,7 @@ static int cma_bind_loopback(struct rdma_id_private *id_priv)
|
|||||||
if (!cma_dev)
|
if (!cma_dev)
|
||||||
cma_dev = cur_dev;
|
cma_dev = cur_dev;
|
||||||
|
|
||||||
for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) {
|
rdma_for_each_port (cur_dev->device, p) {
|
||||||
if (!ib_get_cached_port_state(cur_dev->device, p, &port_state) &&
|
if (!ib_get_cached_port_state(cur_dev->device, p, &port_state) &&
|
||||||
port_state == IB_PORT_ACTIVE) {
|
port_state == IB_PORT_ACTIVE) {
|
||||||
cma_dev = cur_dev;
|
cma_dev = cur_dev;
|
||||||
|
Loading…
Reference in New Issue
Block a user