Commit 1dfce294 authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

IB: Replace ib_query_gid/ib_get_cached_gid with rdma_query_gid

If the gid_attr argument is NULL then the functions behave identically to
rdma_query_gid. ib_query_gid just calls ib_get_cached_gid, so everything
can be consolidated to one function.

Now that all callers either use rdma_query_gid() or ib_get_cached_gid(),
ib_query_gid() API is removed.
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 83f6f8d2
...@@ -1646,7 +1646,7 @@ static void cm_opa_to_ib_sgid(struct cm_work *work, ...@@ -1646,7 +1646,7 @@ static void cm_opa_to_ib_sgid(struct cm_work *work,
(ib_is_opa_gid(&path->sgid))) { (ib_is_opa_gid(&path->sgid))) {
union ib_gid sgid; union ib_gid sgid;
if (ib_get_cached_gid(dev, port_num, 0, &sgid, NULL)) { if (rdma_query_gid(dev, port_num, 0, &sgid)) {
dev_warn(&dev->dev, dev_warn(&dev->dev,
"Error updating sgid in CM request\n"); "Error updating sgid in CM request\n");
return; return;
...@@ -1997,10 +1997,9 @@ static int cm_req_handler(struct cm_work *work) ...@@ -1997,10 +1997,9 @@ static int cm_req_handler(struct cm_work *work)
if (ret) { if (ret) {
int err; int err;
err = ib_get_cached_gid(work->port->cm_dev->ib_device, err = rdma_query_gid(work->port->cm_dev->ib_device,
work->port->port_num, 0, work->port->port_num, 0,
&work->path[0].sgid, &work->path[0].sgid);
NULL);
if (err) if (err)
ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_GID, ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_GID,
NULL, 0, NULL, 0); NULL, 0, NULL, 0);
......
...@@ -732,8 +732,8 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv) ...@@ -732,8 +732,8 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
if (ib_get_cached_port_state(cur_dev->device, p, &port_state)) if (ib_get_cached_port_state(cur_dev->device, p, &port_state))
continue; continue;
for (i = 0; !ib_get_cached_gid(cur_dev->device, p, i, for (i = 0; !rdma_query_gid(cur_dev->device,
&gid, NULL); p, i, &gid);
i++) { i++) {
if (!memcmp(&gid, dgid, sizeof(gid))) { if (!memcmp(&gid, dgid, sizeof(gid))) {
cma_dev = cur_dev; cma_dev = cur_dev;
...@@ -2791,7 +2791,7 @@ static int cma_bind_loopback(struct rdma_id_private *id_priv) ...@@ -2791,7 +2791,7 @@ static int cma_bind_loopback(struct rdma_id_private *id_priv)
p = 1; p = 1;
port_found: port_found:
ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid, NULL); ret = rdma_query_gid(cma_dev->device, p, 0, &gid);
if (ret) if (ret)
goto out; goto out;
......
...@@ -861,25 +861,6 @@ int ib_query_port(struct ib_device *device, ...@@ -861,25 +861,6 @@ int ib_query_port(struct ib_device *device,
} }
EXPORT_SYMBOL(ib_query_port); EXPORT_SYMBOL(ib_query_port);
/**
* ib_query_gid - Get GID table entry
* @device:Device to query
* @port_num:Port number to query
* @index:GID table index to query
* @gid:Returned GID
* @attr: Returned GID attributes related to this GID index (only in RoCE).
* NULL means ignore.
*
* ib_query_gid() fetches the specified GID table entry from the cache.
*/
int ib_query_gid(struct ib_device *device,
u8 port_num, int index, union ib_gid *gid,
struct ib_gid_attr *attr)
{
return ib_get_cached_gid(device, port_num, index, gid, attr);
}
EXPORT_SYMBOL(ib_query_gid);
/** /**
* ib_enum_roce_netdev - enumerate all RoCE ports * ib_enum_roce_netdev - enumerate all RoCE ports
* @ib_dev : IB device we want to query * @ib_dev : IB device we want to query
...@@ -1057,7 +1038,7 @@ int ib_find_gid(struct ib_device *device, union ib_gid *gid, ...@@ -1057,7 +1038,7 @@ int ib_find_gid(struct ib_device *device, union ib_gid *gid,
continue; continue;
for (i = 0; i < device->port_immutable[port].gid_tbl_len; ++i) { for (i = 0; i < device->port_immutable[port].gid_tbl_len; ++i) {
ret = ib_query_gid(device, port, i, &tmp_gid, NULL); ret = rdma_query_gid(device, port, i, &tmp_gid);
if (ret) if (ret)
return ret; return ret;
if (!memcmp(&tmp_gid, gid, sizeof *gid)) { if (!memcmp(&tmp_gid, gid, sizeof *gid)) {
......
...@@ -1896,8 +1896,8 @@ static inline int rcv_has_same_gid(const struct ib_mad_agent_private *mad_agent_ ...@@ -1896,8 +1896,8 @@ static inline int rcv_has_same_gid(const struct ib_mad_agent_private *mad_agent_
const struct ib_global_route *grh = const struct ib_global_route *grh =
rdma_ah_read_grh(&attr); rdma_ah_read_grh(&attr);
if (ib_get_cached_gid(device, port_num, if (rdma_query_gid(device, port_num,
grh->sgid_index, &sgid, NULL)) grh->sgid_index, &sgid))
return 0; return 0;
return !memcmp(sgid.raw, rwc->recv_buf.grh->dgid.raw, return !memcmp(sgid.raw, rwc->recv_buf.grh->dgid.raw,
16); 16);
......
...@@ -516,10 +516,8 @@ static int ib_resolve_unicast_gid_dmac(struct ib_device *device, ...@@ -516,10 +516,8 @@ static int ib_resolve_unicast_gid_dmac(struct ib_device *device,
grh = rdma_ah_retrieve_grh(ah_attr); grh = rdma_ah_retrieve_grh(ah_attr);
ret = ib_query_gid(device, ret = ib_get_cached_gid(device, rdma_ah_get_port_num(ah_attr),
rdma_ah_get_port_num(ah_attr), grh->sgid_index, &sgid, &sgid_attr);
grh->sgid_index,
&sgid, &sgid_attr);
if (ret || !sgid_attr.ndev) { if (ret || !sgid_attr.ndev) {
if (!ret) if (!ret)
ret = -ENXIO; ret = -ENXIO;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <linux/ip.h> #include <linux/ip.h>
#include <linux/tcp.h> #include <linux/tcp.h>
#include <rdma/ib_cache.h>
#include "ipoib.h" #include "ipoib.h"
...@@ -1069,7 +1070,7 @@ static bool ipoib_dev_addr_changed_valid(struct ipoib_dev_priv *priv) ...@@ -1069,7 +1070,7 @@ static bool ipoib_dev_addr_changed_valid(struct ipoib_dev_priv *priv)
bool ret = false; bool ret = false;
netdev_gid = (union ib_gid *)(priv->dev->dev_addr + 4); netdev_gid = (union ib_gid *)(priv->dev->dev_addr + 4);
if (ib_query_gid(priv->ca, priv->port, 0, &gid0, NULL)) if (rdma_query_gid(priv->ca, priv->port, 0, &gid0))
return false; return false;
netif_addr_lock_bh(priv->dev); netif_addr_lock_bh(priv->dev);
......
...@@ -2287,9 +2287,9 @@ static struct net_device *ipoib_add_port(const char *format, ...@@ -2287,9 +2287,9 @@ static struct net_device *ipoib_add_port(const char *format,
priv->dev->broadcast[8] = priv->pkey >> 8; priv->dev->broadcast[8] = priv->pkey >> 8;
priv->dev->broadcast[9] = priv->pkey & 0xff; priv->dev->broadcast[9] = priv->pkey & 0xff;
result = ib_query_gid(hca, port, 0, &priv->local_gid, NULL); result = rdma_query_gid(hca, port, 0, &priv->local_gid);
if (result) { if (result) {
pr_warn("%s: ib_query_gid port %d failed (ret = %d)\n", pr_warn("%s: rdma_query_gid port %d failed (ret = %d)\n",
hca->name, port, result); hca->name, port, result);
goto device_init_failed; goto device_init_failed;
} }
......
...@@ -3843,7 +3843,7 @@ static ssize_t srp_create_target(struct device *dev, ...@@ -3843,7 +3843,7 @@ static ssize_t srp_create_target(struct device *dev,
INIT_WORK(&target->tl_err_work, srp_tl_err_work); INIT_WORK(&target->tl_err_work, srp_tl_err_work);
INIT_WORK(&target->remove_work, srp_remove_work); INIT_WORK(&target->remove_work, srp_remove_work);
spin_lock_init(&target->lock); spin_lock_init(&target->lock);
ret = ib_query_gid(ibdev, host->port, 0, &target->sgid, NULL); ret = rdma_query_gid(ibdev, host->port, 0, &target->sgid);
if (ret) if (ret)
goto out; goto out;
......
...@@ -575,8 +575,7 @@ static int srpt_refresh_port(struct srpt_port *sport) ...@@ -575,8 +575,7 @@ static int srpt_refresh_port(struct srpt_port *sport)
sport->sm_lid = port_attr.sm_lid; sport->sm_lid = port_attr.sm_lid;
sport->lid = port_attr.lid; sport->lid = port_attr.lid;
ret = ib_query_gid(sport->sdev->device, sport->port, 0, &sport->gid, ret = rdma_query_gid(sport->sdev->device, sport->port, 0, &sport->gid);
NULL);
if (ret) if (ret)
goto err_query_port; goto err_query_port;
......
...@@ -3046,10 +3046,6 @@ static inline bool rdma_cap_read_inv(struct ib_device *dev, u32 port_num) ...@@ -3046,10 +3046,6 @@ static inline bool rdma_cap_read_inv(struct ib_device *dev, u32 port_num)
return rdma_protocol_iwarp(dev, port_num); return rdma_protocol_iwarp(dev, port_num);
} }
int ib_query_gid(struct ib_device *device,
u8 port_num, int index, union ib_gid *gid,
struct ib_gid_attr *attr);
int ib_set_vf_link_state(struct ib_device *device, int vf, u8 port, int ib_set_vf_link_state(struct ib_device *device, int vf, u8 port,
int state); int state);
int ib_get_vf_config(struct ib_device *device, int vf, u8 port, int ib_get_vf_config(struct ib_device *device, int vf, u8 port,
......
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