aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core/cm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband/core/cm.c')
-rw-r--r--drivers/infiniband/core/cm.c62
1 files changed, 35 insertions, 27 deletions
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 39e306a09f96..ca742e84e68b 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -1203,8 +1203,8 @@ static void cm_format_req(struct cm_req_msg *req_msg,
1203 } 1203 }
1204 1204
1205 if (pri_path->hop_limit <= 1) { 1205 if (pri_path->hop_limit <= 1) {
1206 req_msg->primary_local_lid = pri_path->slid; 1206 req_msg->primary_local_lid = sa_path_get_slid(pri_path);
1207 req_msg->primary_remote_lid = pri_path->dlid; 1207 req_msg->primary_remote_lid = sa_path_get_dlid(pri_path);
1208 } else { 1208 } else {
1209 /* Work-around until there's a way to obtain remote LID info */ 1209 /* Work-around until there's a way to obtain remote LID info */
1210 req_msg->primary_local_lid = IB_LID_PERMISSIVE; 1210 req_msg->primary_local_lid = IB_LID_PERMISSIVE;
@@ -1224,8 +1224,8 @@ static void cm_format_req(struct cm_req_msg *req_msg,
1224 1224
1225 if (alt_path) { 1225 if (alt_path) {
1226 if (alt_path->hop_limit <= 1) { 1226 if (alt_path->hop_limit <= 1) {
1227 req_msg->alt_local_lid = alt_path->slid; 1227 req_msg->alt_local_lid = sa_path_get_slid(alt_path);
1228 req_msg->alt_remote_lid = alt_path->dlid; 1228 req_msg->alt_remote_lid = sa_path_get_dlid(alt_path);
1229 } else { 1229 } else {
1230 req_msg->alt_local_lid = IB_LID_PERMISSIVE; 1230 req_msg->alt_local_lid = IB_LID_PERMISSIVE;
1231 req_msg->alt_remote_lid = IB_LID_PERMISSIVE; 1231 req_msg->alt_remote_lid = IB_LID_PERMISSIVE;
@@ -1405,11 +1405,10 @@ static void cm_format_paths_from_req(struct cm_req_msg *req_msg,
1405 struct sa_path_rec *primary_path, 1405 struct sa_path_rec *primary_path,
1406 struct sa_path_rec *alt_path) 1406 struct sa_path_rec *alt_path)
1407{ 1407{
1408 memset(primary_path, 0, sizeof(*primary_path));
1409 primary_path->dgid = req_msg->primary_local_gid; 1408 primary_path->dgid = req_msg->primary_local_gid;
1410 primary_path->sgid = req_msg->primary_remote_gid; 1409 primary_path->sgid = req_msg->primary_remote_gid;
1411 primary_path->dlid = req_msg->primary_local_lid; 1410 sa_path_set_dlid(primary_path, req_msg->primary_local_lid);
1412 primary_path->slid = req_msg->primary_remote_lid; 1411 sa_path_set_slid(primary_path, req_msg->primary_remote_lid);
1413 primary_path->flow_label = cm_req_get_primary_flow_label(req_msg); 1412 primary_path->flow_label = cm_req_get_primary_flow_label(req_msg);
1414 primary_path->hop_limit = req_msg->primary_hop_limit; 1413 primary_path->hop_limit = req_msg->primary_hop_limit;
1415 primary_path->traffic_class = req_msg->primary_traffic_class; 1414 primary_path->traffic_class = req_msg->primary_traffic_class;
@@ -1424,14 +1423,13 @@ static void cm_format_paths_from_req(struct cm_req_msg *req_msg,
1424 primary_path->packet_life_time = 1423 primary_path->packet_life_time =
1425 cm_req_get_primary_local_ack_timeout(req_msg); 1424 cm_req_get_primary_local_ack_timeout(req_msg);
1426 primary_path->packet_life_time -= (primary_path->packet_life_time > 0); 1425 primary_path->packet_life_time -= (primary_path->packet_life_time > 0);
1427 primary_path->service_id = req_msg->service_id; 1426 sa_path_set_service_id(primary_path, req_msg->service_id);
1428 1427
1429 if (req_msg->alt_local_lid) { 1428 if (req_msg->alt_local_lid) {
1430 memset(alt_path, 0, sizeof(*alt_path));
1431 alt_path->dgid = req_msg->alt_local_gid; 1429 alt_path->dgid = req_msg->alt_local_gid;
1432 alt_path->sgid = req_msg->alt_remote_gid; 1430 alt_path->sgid = req_msg->alt_remote_gid;
1433 alt_path->dlid = req_msg->alt_local_lid; 1431 sa_path_set_dlid(alt_path, req_msg->alt_local_lid);
1434 alt_path->slid = req_msg->alt_remote_lid; 1432 sa_path_set_slid(alt_path, req_msg->alt_remote_lid);
1435 alt_path->flow_label = cm_req_get_alt_flow_label(req_msg); 1433 alt_path->flow_label = cm_req_get_alt_flow_label(req_msg);
1436 alt_path->hop_limit = req_msg->alt_hop_limit; 1434 alt_path->hop_limit = req_msg->alt_hop_limit;
1437 alt_path->traffic_class = req_msg->alt_traffic_class; 1435 alt_path->traffic_class = req_msg->alt_traffic_class;
@@ -1446,7 +1444,7 @@ static void cm_format_paths_from_req(struct cm_req_msg *req_msg,
1446 alt_path->packet_life_time = 1444 alt_path->packet_life_time =
1447 cm_req_get_alt_local_ack_timeout(req_msg); 1445 cm_req_get_alt_local_ack_timeout(req_msg);
1448 alt_path->packet_life_time -= (alt_path->packet_life_time > 0); 1446 alt_path->packet_life_time -= (alt_path->packet_life_time > 0);
1449 alt_path->service_id = req_msg->service_id; 1447 sa_path_set_service_id(alt_path, req_msg->service_id);
1450 } 1448 }
1451} 1449}
1452 1450
@@ -1760,27 +1758,34 @@ static int cm_req_handler(struct cm_work *work)
1760 cm_id_priv->id.service_mask = ~cpu_to_be64(0); 1758 cm_id_priv->id.service_mask = ~cpu_to_be64(0);
1761 1759
1762 cm_process_routed_req(req_msg, work->mad_recv_wc->wc); 1760 cm_process_routed_req(req_msg, work->mad_recv_wc->wc);
1763 cm_format_paths_from_req(req_msg, &work->path[0], &work->path[1]);
1764 1761
1765 if (cm_id_priv->av.ah_attr.type == RDMA_AH_ATTR_TYPE_ROCE) 1762 memset(&work->path[0], 0, sizeof(work->path[0]));
1766 memcpy(work->path[0].dmac, cm_id_priv->av.ah_attr.roce.dmac, 1763 memset(&work->path[1], 0, sizeof(work->path[1]));
1767 ETH_ALEN);
1768 grh = rdma_ah_read_grh(&cm_id_priv->av.ah_attr); 1764 grh = rdma_ah_read_grh(&cm_id_priv->av.ah_attr);
1769 work->path[0].hop_limit = grh->hop_limit;
1770 ret = ib_get_cached_gid(work->port->cm_dev->ib_device, 1765 ret = ib_get_cached_gid(work->port->cm_dev->ib_device,
1771 work->port->port_num, 1766 work->port->port_num,
1772 grh->sgid_index, 1767 grh->sgid_index,
1773 &gid, &gid_attr); 1768 &gid, &gid_attr);
1774 if (!ret) { 1769 if (!ret) {
1775 if (gid_attr.ndev) { 1770 if (gid_attr.ndev) {
1776 work->path[0].ifindex = gid_attr.ndev->ifindex;
1777 work->path[0].net = dev_net(gid_attr.ndev);
1778 dev_put(gid_attr.ndev);
1779 work->path[0].rec_type = 1771 work->path[0].rec_type =
1780 sa_conv_gid_to_pathrec_type(gid_attr.gid_type); 1772 sa_conv_gid_to_pathrec_type(gid_attr.gid_type);
1773 sa_path_set_ifindex(&work->path[0],
1774 gid_attr.ndev->ifindex);
1775 sa_path_set_ndev(&work->path[0],
1776 dev_net(gid_attr.ndev));
1777 dev_put(gid_attr.ndev);
1781 } else { 1778 } else {
1782 work->path[0].rec_type = SA_PATH_REC_TYPE_IB; 1779 work->path[0].rec_type = SA_PATH_REC_TYPE_IB;
1783 } 1780 }
1781 if (req_msg->alt_local_lid)
1782 work->path[1].rec_type = work->path[0].rec_type;
1783 cm_format_paths_from_req(req_msg, &work->path[0],
1784 &work->path[1]);
1785 if (cm_id_priv->av.ah_attr.type == RDMA_AH_ATTR_TYPE_ROCE)
1786 sa_path_set_dmac(&work->path[0],
1787 cm_id_priv->av.ah_attr.roce.dmac);
1788 work->path[0].hop_limit = grh->hop_limit;
1784 ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av, 1789 ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av,
1785 cm_id_priv); 1790 cm_id_priv);
1786 } 1791 }
@@ -1790,11 +1795,13 @@ static int cm_req_handler(struct cm_work *work)
1790 &work->path[0].sgid, 1795 &work->path[0].sgid,
1791 &gid_attr); 1796 &gid_attr);
1792 if (!err && gid_attr.ndev) { 1797 if (!err && gid_attr.ndev) {
1793 work->path[0].ifindex = gid_attr.ndev->ifindex;
1794 work->path[0].net = dev_net(gid_attr.ndev);
1795 dev_put(gid_attr.ndev);
1796 work->path[0].rec_type = 1798 work->path[0].rec_type =
1797 sa_conv_gid_to_pathrec_type(gid_attr.gid_type); 1799 sa_conv_gid_to_pathrec_type(gid_attr.gid_type);
1800 sa_path_set_ifindex(&work->path[0],
1801 gid_attr.ndev->ifindex);
1802 sa_path_set_ndev(&work->path[0],
1803 dev_net(gid_attr.ndev));
1804 dev_put(gid_attr.ndev);
1798 } else { 1805 } else {
1799 work->path[0].rec_type = SA_PATH_REC_TYPE_IB; 1806 work->path[0].rec_type = SA_PATH_REC_TYPE_IB;
1800 } 1807 }
@@ -2835,8 +2842,8 @@ static void cm_format_lap(struct cm_lap_msg *lap_msg,
2835 cm_lap_set_remote_qpn(lap_msg, cm_id_priv->remote_qpn); 2842 cm_lap_set_remote_qpn(lap_msg, cm_id_priv->remote_qpn);
2836 /* todo: need remote CM response timeout */ 2843 /* todo: need remote CM response timeout */
2837 cm_lap_set_remote_resp_timeout(lap_msg, 0x1F); 2844 cm_lap_set_remote_resp_timeout(lap_msg, 0x1F);
2838 lap_msg->alt_local_lid = alternate_path->slid; 2845 lap_msg->alt_local_lid = sa_path_get_slid(alternate_path);
2839 lap_msg->alt_remote_lid = alternate_path->dlid; 2846 lap_msg->alt_remote_lid = sa_path_get_dlid(alternate_path);
2840 lap_msg->alt_local_gid = alternate_path->sgid; 2847 lap_msg->alt_local_gid = alternate_path->sgid;
2841 lap_msg->alt_remote_gid = alternate_path->dgid; 2848 lap_msg->alt_remote_gid = alternate_path->dgid;
2842 cm_lap_set_flow_label(lap_msg, alternate_path->flow_label); 2849 cm_lap_set_flow_label(lap_msg, alternate_path->flow_label);
@@ -2912,10 +2919,11 @@ static void cm_format_path_from_lap(struct cm_id_private *cm_id_priv,
2912 struct cm_lap_msg *lap_msg) 2919 struct cm_lap_msg *lap_msg)
2913{ 2920{
2914 memset(path, 0, sizeof *path); 2921 memset(path, 0, sizeof *path);
2922 path->rec_type = SA_PATH_REC_TYPE_IB;
2915 path->dgid = lap_msg->alt_local_gid; 2923 path->dgid = lap_msg->alt_local_gid;
2916 path->sgid = lap_msg->alt_remote_gid; 2924 path->sgid = lap_msg->alt_remote_gid;
2917 path->dlid = lap_msg->alt_local_lid; 2925 sa_path_set_dlid(path, lap_msg->alt_local_lid);
2918 path->slid = lap_msg->alt_remote_lid; 2926 sa_path_set_slid(path, lap_msg->alt_remote_lid);
2919 path->flow_label = cm_lap_get_flow_label(lap_msg); 2927 path->flow_label = cm_lap_get_flow_label(lap_msg);
2920 path->hop_limit = lap_msg->alt_hop_limit; 2928 path->hop_limit = lap_msg->alt_hop_limit;
2921 path->traffic_class = cm_lap_get_traffic_class(lap_msg); 2929 path->traffic_class = cm_lap_get_traffic_class(lap_msg);