aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatan Barak <matanb@mellanox.com>2015-10-15 11:38:47 -0400
committerDoug Ledford <dledford@redhat.com>2015-10-21 23:48:17 -0400
commitba36e37fd3ca3dc8f215b14bcfdccf9f41b65767 (patch)
tree82da7f56ca3c414f27913a26c816449e8be9be7b
parentd300ec528b799ca87935b3667f5563f397f00f85 (diff)
IB/core: Add netdev to path record
In order to find the sgid_index, one could just query the IB cache with the correct GID and netdevice. Therefore, instead of storing the L2 attributes directly in the path, we only store the ifindex and net and use them later to get the sgid_index. The vlan_id and smac L2 attributes are removed in a later patch. Signed-off-by: Matan Barak <matanb@mellanox.com> Reviewed-By: Devesh Sharma <devesh.sharma@avagotech.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r--drivers/infiniband/core/sa_query.c13
-rw-r--r--drivers/infiniband/core/uverbs_marshall.c2
-rw-r--r--include/rdma/ib_sa.h10
3 files changed, 23 insertions, 2 deletions
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index 9a4e7891ada2..c9d9d7afcdb4 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -1007,18 +1007,25 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
1007 force_grh = rdma_cap_eth_ah(device, port_num); 1007 force_grh = rdma_cap_eth_ah(device, port_num);
1008 1008
1009 if (rec->hop_limit > 1 || force_grh) { 1009 if (rec->hop_limit > 1 || force_grh) {
1010 struct net_device *ndev = ib_get_ndev_from_path(rec);
1011
1010 ah_attr->ah_flags = IB_AH_GRH; 1012 ah_attr->ah_flags = IB_AH_GRH;
1011 ah_attr->grh.dgid = rec->dgid; 1013 ah_attr->grh.dgid = rec->dgid;
1012 1014
1013 ret = ib_find_cached_gid(device, &rec->sgid, NULL, &port_num, 1015 ret = ib_find_cached_gid(device, &rec->sgid, ndev, &port_num,
1014 &gid_index); 1016 &gid_index);
1015 if (ret) 1017 if (ret) {
1018 if (ndev)
1019 dev_put(ndev);
1016 return ret; 1020 return ret;
1021 }
1017 1022
1018 ah_attr->grh.sgid_index = gid_index; 1023 ah_attr->grh.sgid_index = gid_index;
1019 ah_attr->grh.flow_label = be32_to_cpu(rec->flow_label); 1024 ah_attr->grh.flow_label = be32_to_cpu(rec->flow_label);
1020 ah_attr->grh.hop_limit = rec->hop_limit; 1025 ah_attr->grh.hop_limit = rec->hop_limit;
1021 ah_attr->grh.traffic_class = rec->traffic_class; 1026 ah_attr->grh.traffic_class = rec->traffic_class;
1027 if (ndev)
1028 dev_put(ndev);
1022 } 1029 }
1023 if (force_grh) { 1030 if (force_grh) {
1024 memcpy(ah_attr->dmac, rec->dmac, ETH_ALEN); 1031 memcpy(ah_attr->dmac, rec->dmac, ETH_ALEN);
@@ -1151,6 +1158,8 @@ static void ib_sa_path_rec_callback(struct ib_sa_query *sa_query,
1151 ib_unpack(path_rec_table, ARRAY_SIZE(path_rec_table), 1158 ib_unpack(path_rec_table, ARRAY_SIZE(path_rec_table),
1152 mad->data, &rec); 1159 mad->data, &rec);
1153 rec.vlan_id = 0xffff; 1160 rec.vlan_id = 0xffff;
1161 rec.net = NULL;
1162 rec.ifindex = 0;
1154 memset(rec.dmac, 0, ETH_ALEN); 1163 memset(rec.dmac, 0, ETH_ALEN);
1155 memset(rec.smac, 0, ETH_ALEN); 1164 memset(rec.smac, 0, ETH_ALEN);
1156 query->callback(status, &rec, query->context); 1165 query->callback(status, &rec, query->context);
diff --git a/drivers/infiniband/core/uverbs_marshall.c b/drivers/infiniband/core/uverbs_marshall.c
index abd97247443e..484698c94d7f 100644
--- a/drivers/infiniband/core/uverbs_marshall.c
+++ b/drivers/infiniband/core/uverbs_marshall.c
@@ -144,5 +144,7 @@ void ib_copy_path_rec_from_user(struct ib_sa_path_rec *dst,
144 memset(dst->smac, 0, sizeof(dst->smac)); 144 memset(dst->smac, 0, sizeof(dst->smac));
145 memset(dst->dmac, 0, sizeof(dst->dmac)); 145 memset(dst->dmac, 0, sizeof(dst->dmac));
146 dst->vlan_id = 0xffff; 146 dst->vlan_id = 0xffff;
147 dst->net = NULL;
148 dst->ifindex = 0;
147} 149}
148EXPORT_SYMBOL(ib_copy_path_rec_from_user); 150EXPORT_SYMBOL(ib_copy_path_rec_from_user);
diff --git a/include/rdma/ib_sa.h b/include/rdma/ib_sa.h
index 7e071a6abb34..406ecf177f21 100644
--- a/include/rdma/ib_sa.h
+++ b/include/rdma/ib_sa.h
@@ -39,6 +39,7 @@
39#include <linux/compiler.h> 39#include <linux/compiler.h>
40 40
41#include <linux/atomic.h> 41#include <linux/atomic.h>
42#include <linux/netdevice.h>
42 43
43#include <rdma/ib_verbs.h> 44#include <rdma/ib_verbs.h>
44#include <rdma/ib_mad.h> 45#include <rdma/ib_mad.h>
@@ -157,8 +158,17 @@ struct ib_sa_path_rec {
157 u8 smac[ETH_ALEN]; 158 u8 smac[ETH_ALEN];
158 u8 dmac[ETH_ALEN]; 159 u8 dmac[ETH_ALEN];
159 u16 vlan_id; 160 u16 vlan_id;
161 /* ignored in IB */
162 int ifindex;
163 /* ignored in IB */
164 struct net *net;
160}; 165};
161 166
167static inline struct net_device *ib_get_ndev_from_path(struct ib_sa_path_rec *rec)
168{
169 return rec->net ? dev_get_by_index(rec->net, rec->ifindex) : NULL;
170}
171
162#define IB_SA_MCMEMBER_REC_MGID IB_SA_COMP_MASK( 0) 172#define IB_SA_MCMEMBER_REC_MGID IB_SA_COMP_MASK( 0)
163#define IB_SA_MCMEMBER_REC_PORT_GID IB_SA_COMP_MASK( 1) 173#define IB_SA_MCMEMBER_REC_PORT_GID IB_SA_COMP_MASK( 1)
164#define IB_SA_MCMEMBER_REC_QKEY IB_SA_COMP_MASK( 2) 174#define IB_SA_MCMEMBER_REC_QKEY IB_SA_COMP_MASK( 2)