Commit 16c72e40 authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

IB/cm: Refactor to avoid setting path record software only fields

When path ah_attr initialization from path record
fails, ib_cm_send_rej() uses av.ah_attr fields to send out reject
message. In such cases initialization of path record software fields
is not needed. Code is simplified for same.

Additionally in current code in cm_req_handler, when ib_get_cached_gid
fails for a given sgid_index of the GID of the GRH of the incoming CM MAD,
error code 12 is sent. This error code refers to primary GID in incoming
CM REQ and not for the GID in in MAD packet.
Therefore code is refactored to send code 5 (unsupported request) for such
error.
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Reviewed-by: default avatarHal Rosenstock <hal@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent f6bdb142
...@@ -1902,56 +1902,52 @@ static int cm_req_handler(struct cm_work *work) ...@@ -1902,56 +1902,52 @@ static int cm_req_handler(struct cm_work *work)
work->port->port_num, work->port->port_num,
grh->sgid_index, grh->sgid_index,
&gid, &gid_attr); &gid, &gid_attr);
if (!ret) { if (ret) {
if (gid_attr.ndev) { if (gid_attr.ndev)
work->path[0].rec_type =
sa_conv_gid_to_pathrec_type(gid_attr.gid_type);
sa_path_set_ifindex(&work->path[0],
gid_attr.ndev->ifindex);
sa_path_set_ndev(&work->path[0],
dev_net(gid_attr.ndev));
dev_put(gid_attr.ndev); dev_put(gid_attr.ndev);
} else { ib_send_cm_rej(cm_id, IB_CM_REJ_UNSUPPORTED, NULL, 0, NULL, 0);
cm_path_set_rec_type(work->port->cm_dev->ib_device, goto rejected;
work->port->port_num,
&work->path[0],
&req_msg->primary_local_gid);
}
if (cm_req_has_alt_path(req_msg))
work->path[1].rec_type = work->path[0].rec_type;
cm_format_paths_from_req(req_msg, &work->path[0],
&work->path[1]);
if (cm_id_priv->av.ah_attr.type == RDMA_AH_ATTR_TYPE_ROCE)
sa_path_set_dmac(&work->path[0],
cm_id_priv->av.ah_attr.roce.dmac);
work->path[0].hop_limit = grh->hop_limit;
ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av,
cm_id_priv);
} }
if (gid_attr.ndev) {
work->path[0].rec_type =
sa_conv_gid_to_pathrec_type(gid_attr.gid_type);
sa_path_set_ifindex(&work->path[0],
gid_attr.ndev->ifindex);
sa_path_set_ndev(&work->path[0],
dev_net(gid_attr.ndev));
dev_put(gid_attr.ndev);
} else {
cm_path_set_rec_type(work->port->cm_dev->ib_device,
work->port->port_num,
&work->path[0],
&req_msg->primary_local_gid);
}
if (cm_req_has_alt_path(req_msg))
work->path[1].rec_type = work->path[0].rec_type;
cm_format_paths_from_req(req_msg, &work->path[0],
&work->path[1]);
if (cm_id_priv->av.ah_attr.type == RDMA_AH_ATTR_TYPE_ROCE)
sa_path_set_dmac(&work->path[0],
cm_id_priv->av.ah_attr.roce.dmac);
work->path[0].hop_limit = grh->hop_limit;
ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av,
cm_id_priv);
if (ret) { if (ret) {
int err = ib_get_cached_gid(work->port->cm_dev->ib_device, int err;
work->port->port_num, 0,
&work->path[0].sgid, err = ib_get_cached_gid(work->port->cm_dev->ib_device,
&gid_attr); work->port->port_num, 0,
if (!err && gid_attr.ndev) { &work->path[0].sgid,
work->path[0].rec_type = NULL);
sa_conv_gid_to_pathrec_type(gid_attr.gid_type); if (err)
sa_path_set_ifindex(&work->path[0], ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_GID,
gid_attr.ndev->ifindex); NULL, 0, NULL, 0);
sa_path_set_ndev(&work->path[0], else
dev_net(gid_attr.ndev)); ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_GID,
dev_put(gid_attr.ndev); &work->path[0].sgid,
} else { sizeof(work->path[0].sgid),
cm_path_set_rec_type(work->port->cm_dev->ib_device, NULL, 0);
work->port->port_num,
&work->path[0],
&req_msg->primary_local_gid);
}
if (cm_req_has_alt_path(req_msg))
work->path[1].rec_type = work->path[0].rec_type;
ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_GID,
&work->path[0].sgid, sizeof work->path[0].sgid,
NULL, 0);
goto rejected; goto rejected;
} }
if (cm_req_has_alt_path(req_msg)) { if (cm_req_has_alt_path(req_msg)) {
...@@ -1960,7 +1956,7 @@ static int cm_req_handler(struct cm_work *work) ...@@ -1960,7 +1956,7 @@ static int cm_req_handler(struct cm_work *work)
if (ret) { if (ret) {
ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_ALT_GID, ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_ALT_GID,
&work->path[0].sgid, &work->path[0].sgid,
sizeof work->path[0].sgid, NULL, 0); sizeof(work->path[0].sgid), NULL, 0);
goto rejected; goto rejected;
} }
} }
......
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