diff options
author | Parav Pandit <parav@mellanox.com> | 2018-06-05 01:40:19 -0400 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2018-06-18 13:09:05 -0400 |
commit | ddb457c6993babbcdd41fca638b870d2a2fc3941 (patch) | |
tree | 94dc8b6561d9e5089de2eb2c393bd5d81da05b26 /net/smc | |
parent | 77e786fcbe2ecdac57ced610260ffb1f7cfeed00 (diff) |
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>
Diffstat (limited to 'net/smc')
-rw-r--r-- | net/smc/smc_core.c | 20 | ||||
-rw-r--r-- | net/smc/smc_ib.c | 25 |
2 files changed, 25 insertions, 20 deletions
diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index add82b0266f3..d99a75f75e42 100644 --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <net/tcp.h> | 16 | #include <net/tcp.h> |
17 | #include <net/sock.h> | 17 | #include <net/sock.h> |
18 | #include <rdma/ib_verbs.h> | 18 | #include <rdma/ib_verbs.h> |
19 | #include <rdma/ib_cache.h> | ||
19 | 20 | ||
20 | #include "smc.h" | 21 | #include "smc.h" |
21 | #include "smc_clc.h" | 22 | #include "smc_clc.h" |
@@ -450,8 +451,7 @@ out: | |||
450 | static int smc_link_determine_gid(struct smc_link_group *lgr) | 451 | static int smc_link_determine_gid(struct smc_link_group *lgr) |
451 | { | 452 | { |
452 | struct smc_link *lnk = &lgr->lnk[SMC_SINGLE_LINK]; | 453 | struct smc_link *lnk = &lgr->lnk[SMC_SINGLE_LINK]; |
453 | struct ib_gid_attr gattr; | 454 | const struct ib_gid_attr *gattr; |
454 | union ib_gid gid; | ||
455 | int i; | 455 | int i; |
456 | 456 | ||
457 | if (!lgr->vlan_id) { | 457 | if (!lgr->vlan_id) { |
@@ -461,18 +461,18 @@ static int smc_link_determine_gid(struct smc_link_group *lgr) | |||
461 | 461 | ||
462 | for (i = 0; i < lnk->smcibdev->pattr[lnk->ibport - 1].gid_tbl_len; | 462 | for (i = 0; i < lnk->smcibdev->pattr[lnk->ibport - 1].gid_tbl_len; |
463 | i++) { | 463 | i++) { |
464 | if (ib_query_gid(lnk->smcibdev->ibdev, lnk->ibport, i, &gid, | 464 | gattr = rdma_get_gid_attr(lnk->smcibdev->ibdev, lnk->ibport, i); |
465 | &gattr)) | 465 | if (IS_ERR(gattr)) |
466 | continue; | 466 | continue; |
467 | if (gattr.ndev) { | 467 | if (gattr->ndev) { |
468 | if (is_vlan_dev(gattr.ndev) && | 468 | if (is_vlan_dev(gattr->ndev) && |
469 | vlan_dev_vlan_id(gattr.ndev) == lgr->vlan_id) { | 469 | vlan_dev_vlan_id(gattr->ndev) == lgr->vlan_id) { |
470 | lnk->gid = gid; | 470 | lnk->gid = gattr->gid; |
471 | dev_put(gattr.ndev); | 471 | rdma_put_gid_attr(gattr); |
472 | return 0; | 472 | return 0; |
473 | } | 473 | } |
474 | dev_put(gattr.ndev); | ||
475 | } | 474 | } |
475 | rdma_put_gid_attr(gattr); | ||
476 | } | 476 | } |
477 | return -ENODEV; | 477 | return -ENODEV; |
478 | } | 478 | } |
diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c index 0eed7ab9f28b..74f29f814ec1 100644 --- a/net/smc/smc_ib.c +++ b/net/smc/smc_ib.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/workqueue.h> | 16 | #include <linux/workqueue.h> |
17 | #include <linux/scatterlist.h> | 17 | #include <linux/scatterlist.h> |
18 | #include <rdma/ib_verbs.h> | 18 | #include <rdma/ib_verbs.h> |
19 | #include <rdma/ib_cache.h> | ||
19 | 20 | ||
20 | #include "smc_pnet.h" | 21 | #include "smc_pnet.h" |
21 | #include "smc_ib.h" | 22 | #include "smc_ib.h" |
@@ -372,17 +373,21 @@ void smc_ib_buf_unmap_sg(struct smc_ib_device *smcibdev, | |||
372 | 373 | ||
373 | static int smc_ib_fill_gid_and_mac(struct smc_ib_device *smcibdev, u8 ibport) | 374 | static int smc_ib_fill_gid_and_mac(struct smc_ib_device *smcibdev, u8 ibport) |
374 | { | 375 | { |
375 | struct ib_gid_attr gattr; | 376 | const struct ib_gid_attr *gattr; |
376 | int rc; | 377 | int rc = 0; |
377 | |||
378 | rc = ib_query_gid(smcibdev->ibdev, ibport, 0, | ||
379 | &smcibdev->gid[ibport - 1], &gattr); | ||
380 | if (rc || !gattr.ndev) | ||
381 | return -ENODEV; | ||
382 | 378 | ||
383 | memcpy(smcibdev->mac[ibport - 1], gattr.ndev->dev_addr, ETH_ALEN); | 379 | gattr = rdma_get_gid_attr(smcibdev->ibdev, ibport, 0); |
384 | dev_put(gattr.ndev); | 380 | if (IS_ERR(gattr)) |
385 | return 0; | 381 | return PTR_ERR(gattr); |
382 | if (!gattr->ndev) { | ||
383 | rc = -ENODEV; | ||
384 | goto done; | ||
385 | } | ||
386 | smcibdev->gid[ibport - 1] = gattr->gid; | ||
387 | memcpy(smcibdev->mac[ibport - 1], gattr->ndev->dev_addr, ETH_ALEN); | ||
388 | done: | ||
389 | rdma_put_gid_attr(gattr); | ||
390 | return rc; | ||
386 | } | 391 | } |
387 | 392 | ||
388 | /* Create an identifier unique for this instance of SMC-R. | 393 | /* Create an identifier unique for this instance of SMC-R. |