aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorParav Pandit <parav@mellanox.com>2018-04-01 08:08:20 -0400
committerJason Gunthorpe <jgg@mellanox.com>2018-04-03 23:33:50 -0400
commitf35faa4ba9568138eea1c58abb92e8ef415dce41 (patch)
tree83c62300a1cb46181b6a05eac13f9051bd135eae /drivers
parent0e1f9b924471c132dcf314476916e3c4bd4956b2 (diff)
IB/core: Simplify ib_query_gid to always refer to cache
Currently following inconsistencies exist. 1. ib_query_gid() returns GID from the software cache for a RoCE port and returns GID from the HCA for an IB port. This is incorrect because software GID cache is maintained regardless of HCA port type. 2. GID is queries from the HCA via ib_query_gid and updated in the software cache for IB link layer. Both of them might not be in sync. ULPs such as SRP initiator, SRP target, IPoIB driver have historically used ib_query_gid() API to query the GID. However CM used cached version during CM processing, When software cache was introduced, this inconsitency remained. In order to simplify, improve readability and avoid link layer specific above inconsistencies, this patch brings following changes. 1. ib_query_gid() always refers to the cache layer regardless of link layer. 2. cache module who reads the GID entry from HCA and builds the cache, directly invokes the HCA provider verb's query_gid() callback function. 3. ib_query_port() is being called in early stage where GID cache is not yet build while reading port immutable property. Therefore it needs to read the default GID from the HCA for IB link layer to publish the subnet prefix. Signed-off-by: Parav Pandit <parav@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/infiniband/core/cache.c4
-rw-r--r--drivers/infiniband/core/device.c15
2 files changed, 5 insertions, 14 deletions
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index 552f3c8dc246..e03eaf0c7527 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -1116,8 +1116,8 @@ static void ib_cache_update(struct ib_device *device,
1116 1116
1117 if (!use_roce_gid_table) { 1117 if (!use_roce_gid_table) {
1118 for (i = 0; i < gid_cache->table_len; ++i) { 1118 for (i = 0; i < gid_cache->table_len; ++i) {
1119 ret = ib_query_gid(device, port, i, 1119 ret = device->query_gid(device, port, i,
1120 gid_cache->table + i, NULL); 1120 gid_cache->table + i);
1121 if (ret) { 1121 if (ret) {
1122 pr_warn("ib_query_gid failed (%d) for %s (index %d)\n", 1122 pr_warn("ib_query_gid failed (%d) for %s (index %d)\n",
1123 ret, device->name, i); 1123 ret, device->name, i);
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 5d79e8de31f5..601ff782e5f3 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -853,7 +853,7 @@ int ib_query_port(struct ib_device *device,
853 if (rdma_port_get_link_layer(device, port_num) != IB_LINK_LAYER_INFINIBAND) 853 if (rdma_port_get_link_layer(device, port_num) != IB_LINK_LAYER_INFINIBAND)
854 return 0; 854 return 0;
855 855
856 err = ib_query_gid(device, port_num, 0, &gid, NULL); 856 err = device->query_gid(device, port_num, 0, &gid);
857 if (err) 857 if (err)
858 return err; 858 return err;
859 859
@@ -871,22 +871,13 @@ EXPORT_SYMBOL(ib_query_port);
871 * @attr: Returned GID attributes related to this GID index (only in RoCE). 871 * @attr: Returned GID attributes related to this GID index (only in RoCE).
872 * NULL means ignore. 872 * NULL means ignore.
873 * 873 *
874 * ib_query_gid() fetches the specified GID table entry. 874 * ib_query_gid() fetches the specified GID table entry from the cache.
875 */ 875 */
876int ib_query_gid(struct ib_device *device, 876int ib_query_gid(struct ib_device *device,
877 u8 port_num, int index, union ib_gid *gid, 877 u8 port_num, int index, union ib_gid *gid,
878 struct ib_gid_attr *attr) 878 struct ib_gid_attr *attr)
879{ 879{
880 if (rdma_protocol_roce(device, port_num)) 880 return ib_get_cached_gid(device, port_num, index, gid, attr);
881 return ib_get_cached_gid(device, port_num, index, gid, attr);
882
883 if (attr)
884 return -EINVAL;
885
886 if (!device->query_gid)
887 return -EOPNOTSUPP;
888
889 return device->query_gid(device, port_num, index, gid);
890} 881}
891EXPORT_SYMBOL(ib_query_gid); 882EXPORT_SYMBOL(ib_query_gid);
892 883