RDMA/cm: Use DLID from inbound/outbound PathRecords as the datapath DLID
authorMark Zhang <markzhang@nvidia.com>
Thu, 8 Sep 2022 10:09:03 +0000 (13:09 +0300)
committerLeon Romanovsky <leon@kernel.org>
Thu, 22 Sep 2022 09:35:31 +0000 (12:35 +0300)
In inter-subnet cases, when inbound/outbound PRs are available,
outbound_PR.dlid is used as the requestor's datapath DLID and
inbound_PR.dlid is used as the responder's DLID. The inbound_PR.dlid
is passed to responder side with the "ConnectReq.Primary_Local_Port_LID"
field. With this solution the PERMISSIVE_LID is no longer used in
Primary Local LID field.

Signed-off-by: Mark Zhang <markzhang@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Link: https://lore.kernel.org/r/b3f6cac685bce9dde37c610be82e2c19d9e51d9e.1662631201.git.leonro@nvidia.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/core/cm.c
drivers/infiniband/core/cma.c
include/rdma/ib_cm.h

index ade82752f9f716ffc479e57e1c72f18e4a2b443d..1f9938a2c47522b8255239243edd26c7dacf402a 100644 (file)
@@ -175,6 +175,7 @@ struct cm_device {
 struct cm_av {
        struct cm_port *port;
        struct rdma_ah_attr ah_attr;
+       u16 dlid_datapath;
        u16 pkey_index;
        u8 timeout;
 };
@@ -1304,6 +1305,7 @@ static void cm_format_req(struct cm_req_msg *req_msg,
        struct sa_path_rec *pri_path = param->primary_path;
        struct sa_path_rec *alt_path = param->alternate_path;
        bool pri_ext = false;
+       __be16 lid;
 
        if (pri_path->rec_type == SA_PATH_REC_TYPE_OPA)
                pri_ext = opa_is_extended_lid(pri_path->opa.dlid,
@@ -1363,9 +1365,16 @@ static void cm_format_req(struct cm_req_msg *req_msg,
                                              htons(ntohl(sa_path_get_dlid(
                                                      pri_path)))));
        } else {
+
+               if (param->primary_path_inbound) {
+                       lid = param->primary_path_inbound->ib.dlid;
+                       IBA_SET(CM_REQ_PRIMARY_LOCAL_PORT_LID, req_msg,
+                               be16_to_cpu(lid));
+               } else
+                       IBA_SET(CM_REQ_PRIMARY_LOCAL_PORT_LID, req_msg,
+                               be16_to_cpu(IB_LID_PERMISSIVE));
+
                /* Work-around until there's a way to obtain remote LID info */
-               IBA_SET(CM_REQ_PRIMARY_LOCAL_PORT_LID, req_msg,
-                       be16_to_cpu(IB_LID_PERMISSIVE));
                IBA_SET(CM_REQ_PRIMARY_REMOTE_PORT_LID, req_msg,
                        be16_to_cpu(IB_LID_PERMISSIVE));
        }
@@ -1520,6 +1529,10 @@ int ib_send_cm_req(struct ib_cm_id *cm_id,
        spin_lock_irqsave(&cm_id_priv->lock, flags);
 
        cm_move_av_from_path(&cm_id_priv->av, &av);
+       if (param->primary_path_outbound)
+               cm_id_priv->av.dlid_datapath =
+                       be16_to_cpu(param->primary_path_outbound->ib.dlid);
+
        if (param->alternate_path)
                cm_move_av_from_path(&cm_id_priv->alt_av, &alt_av);
 
@@ -2154,6 +2167,10 @@ static int cm_req_handler(struct cm_work *work)
                                       NULL, 0);
                goto rejected;
        }
+       if (cm_id_priv->av.ah_attr.type == RDMA_AH_ATTR_TYPE_IB)
+               cm_id_priv->av.dlid_datapath =
+                       IBA_GET(CM_REQ_PRIMARY_LOCAL_PORT_LID, req_msg);
+
        if (cm_req_has_alt_path(req_msg)) {
                ret = cm_init_av_by_path(&work->path[1], NULL,
                                         &cm_id_priv->alt_av);
@@ -4113,6 +4130,10 @@ static int cm_init_qp_rtr_attr(struct cm_id_private *cm_id_priv,
                *qp_attr_mask = IB_QP_STATE | IB_QP_AV | IB_QP_PATH_MTU |
                                IB_QP_DEST_QPN | IB_QP_RQ_PSN;
                qp_attr->ah_attr = cm_id_priv->av.ah_attr;
+               if ((qp_attr->ah_attr.type == RDMA_AH_ATTR_TYPE_IB) &&
+                   cm_id_priv->av.dlid_datapath &&
+                   (cm_id_priv->av.dlid_datapath != 0xffff))
+                       qp_attr->ah_attr.ib.dlid = cm_id_priv->av.dlid_datapath;
                qp_attr->path_mtu = cm_id_priv->path_mtu;
                qp_attr->dest_qp_num = be32_to_cpu(cm_id_priv->remote_qpn);
                qp_attr->rq_psn = be32_to_cpu(cm_id_priv->rq_psn);
index a3efc462305d595c70435d21b49b51b16081df7e..7eacb23165fc591396a26b5fae39a935813ccd0a 100644 (file)
@@ -4313,6 +4313,8 @@ static int cma_connect_ib(struct rdma_id_private *id_priv,
        }
 
        req.primary_path = &route->path_rec[0];
+       req.primary_path_inbound = route->path_rec_inbound;
+       req.primary_path_outbound = route->path_rec_outbound;
        if (route->num_pri_alt_paths == 2)
                req.alternate_path = &route->path_rec[1];
 
index 8dae5847020ae4241672879167b31bae29a4038c..a2ac62b4a6cf1d79c87392c46e8ad5a1476c1e31 100644 (file)
@@ -348,6 +348,8 @@ struct ib_cm_id *ib_cm_insert_listen(struct ib_device *device,
 
 struct ib_cm_req_param {
        struct sa_path_rec      *primary_path;
+       struct sa_path_rec      *primary_path_inbound;
+       struct sa_path_rec      *primary_path_outbound;
        struct sa_path_rec      *alternate_path;
        const struct ib_gid_attr *ppath_sgid_attr;
        __be64                  service_id;