Commit 79d684f0 authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

RDMA/core: Simplify gid type check in cma_acquire_dev()

cma_add_one() initializes the default GID regardless of device type.
listen_id is bound to a device and an IP address, its GID type is
initialized by cma_acquire_dev().

Therefore a valid default GID type is always available, it is not needed
to check port type during cma_acquire_dev().

Initialize gid type of a cm id when the cm_id is created instead of
doing conditional checks during cma_acquire_dev() and trying to
initialize to 0 during _cma_attach_to_dev().
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Reviewed-by: default avatarDaniel Jurgens <danielj@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 7582df82
...@@ -490,7 +490,6 @@ static void _cma_attach_to_dev(struct rdma_id_private *id_priv, ...@@ -490,7 +490,6 @@ static void _cma_attach_to_dev(struct rdma_id_private *id_priv,
{ {
cma_ref_dev(cma_dev); cma_ref_dev(cma_dev);
id_priv->cma_dev = cma_dev; id_priv->cma_dev = cma_dev;
id_priv->gid_type = 0;
id_priv->id.device = cma_dev->device; id_priv->id.device = cma_dev->device;
id_priv->id.route.addr.dev_addr.transport = id_priv->id.route.addr.dev_addr.transport =
rdma_node_get_transport(cma_dev->device->node_type); rdma_node_get_transport(cma_dev->device->node_type);
...@@ -648,7 +647,6 @@ static int cma_acquire_dev(struct rdma_id_private *id_priv, ...@@ -648,7 +647,6 @@ static int cma_acquire_dev(struct rdma_id_private *id_priv,
struct cma_device *cma_dev; struct cma_device *cma_dev;
union ib_gid gid, iboe_gid, *gidp; union ib_gid gid, iboe_gid, *gidp;
enum ib_gid_type gid_type; enum ib_gid_type gid_type;
enum ib_gid_type default_type;
int ret = -ENODEV; int ret = -ENODEV;
u8 port; u8 port;
...@@ -668,9 +666,7 @@ static int cma_acquire_dev(struct rdma_id_private *id_priv, ...@@ -668,9 +666,7 @@ static int cma_acquire_dev(struct rdma_id_private *id_priv,
port = listen_id_priv->id.port_num; port = listen_id_priv->id.port_num;
gidp = rdma_protocol_roce(cma_dev->device, port) ? gidp = rdma_protocol_roce(cma_dev->device, port) ?
&iboe_gid : &gid; &iboe_gid : &gid;
gid_type = rdma_protocol_ib(cma_dev->device, port) ? gid_type = listen_id_priv->gid_type;
IB_GID_TYPE_IB :
listen_id_priv->gid_type;
sgid_attr = cma_validate_port(cma_dev->device, port, sgid_attr = cma_validate_port(cma_dev->device, port,
gid_type, gidp, id_priv); gid_type, gidp, id_priv);
if (!IS_ERR(sgid_attr)) { if (!IS_ERR(sgid_attr)) {
...@@ -690,10 +686,7 @@ static int cma_acquire_dev(struct rdma_id_private *id_priv, ...@@ -690,10 +686,7 @@ static int cma_acquire_dev(struct rdma_id_private *id_priv,
gidp = rdma_protocol_roce(cma_dev->device, port) ? gidp = rdma_protocol_roce(cma_dev->device, port) ?
&iboe_gid : &gid; &iboe_gid : &gid;
default_type = cma_dev->default_gid_type[port - 1]; gid_type = cma_dev->default_gid_type[port - 1];
gid_type =
rdma_protocol_ib(cma_dev->device, port) ?
IB_GID_TYPE_IB : default_type;
sgid_attr = cma_validate_port(cma_dev->device, port, sgid_attr = cma_validate_port(cma_dev->device, port,
gid_type, gidp, id_priv); gid_type, gidp, id_priv);
if (!IS_ERR(sgid_attr)) { if (!IS_ERR(sgid_attr)) {
...@@ -801,6 +794,7 @@ struct rdma_cm_id *__rdma_create_id(struct net *net, ...@@ -801,6 +794,7 @@ struct rdma_cm_id *__rdma_create_id(struct net *net,
id_priv->id.ps = ps; id_priv->id.ps = ps;
id_priv->id.qp_type = qp_type; id_priv->id.qp_type = qp_type;
id_priv->tos_set = false; id_priv->tos_set = false;
id_priv->gid_type = IB_GID_TYPE_IB;
spin_lock_init(&id_priv->lock); spin_lock_init(&id_priv->lock);
mutex_init(&id_priv->qp_mutex); mutex_init(&id_priv->qp_mutex);
init_completion(&id_priv->comp); init_completion(&id_priv->comp);
......
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