net/smc: Replace ib_query_gid with rdma_get_gid_attr
Push the copy of the gid_attr into the SMC code. This probably doesn't push it far enough, as it looks like the conn->lgr should potentially hold the reference for its lifetime. Signed-off-by: Parav Pandit <parav@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>hifive-unleashed-5.1
parent
77e786fcbe
commit
ddb457c699
|
@ -16,6 +16,7 @@
|
||||||
#include <net/tcp.h>
|
#include <net/tcp.h>
|
||||||
#include <net/sock.h>
|
#include <net/sock.h>
|
||||||
#include <rdma/ib_verbs.h>
|
#include <rdma/ib_verbs.h>
|
||||||
|
#include <rdma/ib_cache.h>
|
||||||
|
|
||||||
#include "smc.h"
|
#include "smc.h"
|
||||||
#include "smc_clc.h"
|
#include "smc_clc.h"
|
||||||
|
@ -450,8 +451,7 @@ out:
|
||||||
static int smc_link_determine_gid(struct smc_link_group *lgr)
|
static int smc_link_determine_gid(struct smc_link_group *lgr)
|
||||||
{
|
{
|
||||||
struct smc_link *lnk = &lgr->lnk[SMC_SINGLE_LINK];
|
struct smc_link *lnk = &lgr->lnk[SMC_SINGLE_LINK];
|
||||||
struct ib_gid_attr gattr;
|
const struct ib_gid_attr *gattr;
|
||||||
union ib_gid gid;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!lgr->vlan_id) {
|
if (!lgr->vlan_id) {
|
||||||
|
@ -461,18 +461,18 @@ static int smc_link_determine_gid(struct smc_link_group *lgr)
|
||||||
|
|
||||||
for (i = 0; i < lnk->smcibdev->pattr[lnk->ibport - 1].gid_tbl_len;
|
for (i = 0; i < lnk->smcibdev->pattr[lnk->ibport - 1].gid_tbl_len;
|
||||||
i++) {
|
i++) {
|
||||||
if (ib_query_gid(lnk->smcibdev->ibdev, lnk->ibport, i, &gid,
|
gattr = rdma_get_gid_attr(lnk->smcibdev->ibdev, lnk->ibport, i);
|
||||||
&gattr))
|
if (IS_ERR(gattr))
|
||||||
continue;
|
continue;
|
||||||
if (gattr.ndev) {
|
if (gattr->ndev) {
|
||||||
if (is_vlan_dev(gattr.ndev) &&
|
if (is_vlan_dev(gattr->ndev) &&
|
||||||
vlan_dev_vlan_id(gattr.ndev) == lgr->vlan_id) {
|
vlan_dev_vlan_id(gattr->ndev) == lgr->vlan_id) {
|
||||||
lnk->gid = gid;
|
lnk->gid = gattr->gid;
|
||||||
dev_put(gattr.ndev);
|
rdma_put_gid_attr(gattr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
dev_put(gattr.ndev);
|
|
||||||
}
|
}
|
||||||
|
rdma_put_gid_attr(gattr);
|
||||||
}
|
}
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <linux/workqueue.h>
|
#include <linux/workqueue.h>
|
||||||
#include <linux/scatterlist.h>
|
#include <linux/scatterlist.h>
|
||||||
#include <rdma/ib_verbs.h>
|
#include <rdma/ib_verbs.h>
|
||||||
|
#include <rdma/ib_cache.h>
|
||||||
|
|
||||||
#include "smc_pnet.h"
|
#include "smc_pnet.h"
|
||||||
#include "smc_ib.h"
|
#include "smc_ib.h"
|
||||||
|
@ -372,17 +373,21 @@ void smc_ib_buf_unmap_sg(struct smc_ib_device *smcibdev,
|
||||||
|
|
||||||
static int smc_ib_fill_gid_and_mac(struct smc_ib_device *smcibdev, u8 ibport)
|
static int smc_ib_fill_gid_and_mac(struct smc_ib_device *smcibdev, u8 ibport)
|
||||||
{
|
{
|
||||||
struct ib_gid_attr gattr;
|
const struct ib_gid_attr *gattr;
|
||||||
int rc;
|
int rc = 0;
|
||||||
|
|
||||||
rc = ib_query_gid(smcibdev->ibdev, ibport, 0,
|
gattr = rdma_get_gid_attr(smcibdev->ibdev, ibport, 0);
|
||||||
&smcibdev->gid[ibport - 1], &gattr);
|
if (IS_ERR(gattr))
|
||||||
if (rc || !gattr.ndev)
|
return PTR_ERR(gattr);
|
||||||
return -ENODEV;
|
if (!gattr->ndev) {
|
||||||
|
rc = -ENODEV;
|
||||||
memcpy(smcibdev->mac[ibport - 1], gattr.ndev->dev_addr, ETH_ALEN);
|
goto done;
|
||||||
dev_put(gattr.ndev);
|
}
|
||||||
return 0;
|
smcibdev->gid[ibport - 1] = gattr->gid;
|
||||||
|
memcpy(smcibdev->mac[ibport - 1], gattr->ndev->dev_addr, ETH_ALEN);
|
||||||
|
done:
|
||||||
|
rdma_put_gid_attr(gattr);
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create an identifier unique for this instance of SMC-R.
|
/* Create an identifier unique for this instance of SMC-R.
|
||||||
|
|
Loading…
Reference in New Issue