diff options
author | Parav Pandit <parav@mellanox.com> | 2019-05-02 03:48:04 -0400 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2019-05-03 10:10:03 -0400 |
commit | adb4a57a7a1d0bf4bebc96266f30f04330e741de (patch) | |
tree | 2ce512da297cec0e96fa4c4124adb0154a88212a | |
parent | a70c07397fd80dfeeaead15751ab71449b548826 (diff) |
RDMA/cma: Use rdma_read_gid_attr_ndev_rcu to access netdev
To access the netdevice of the GID attribute, use an existing API
rdma_read_gid_attr_ndev_rcu().
This further reduces dependency on open access to netdevice of GID
attribute.
Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
-rw-r--r-- | drivers/infiniband/core/addr.c | 1 | ||||
-rw-r--r-- | drivers/infiniband/core/cache.c | 1 | ||||
-rw-r--r-- | drivers/infiniband/core/cma.c | 12 | ||||
-rw-r--r-- | include/rdma/ib_cache.h | 1 |
4 files changed, 13 insertions, 2 deletions
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c index 0dce94e3c495..2b791ce7597f 100644 --- a/drivers/infiniband/core/addr.c +++ b/drivers/infiniband/core/addr.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <net/addrconf.h> | 45 | #include <net/addrconf.h> |
46 | #include <net/ip6_route.h> | 46 | #include <net/ip6_route.h> |
47 | #include <rdma/ib_addr.h> | 47 | #include <rdma/ib_addr.h> |
48 | #include <rdma/ib_cache.h> | ||
48 | #include <rdma/ib_sa.h> | 49 | #include <rdma/ib_sa.h> |
49 | #include <rdma/ib.h> | 50 | #include <rdma/ib.h> |
50 | #include <rdma/rdma_netlink.h> | 51 | #include <rdma/rdma_netlink.h> |
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index c164e377e563..a53c7713d77a 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c | |||
@@ -1249,6 +1249,7 @@ struct net_device *rdma_read_gid_attr_ndev_rcu(const struct ib_gid_attr *attr) | |||
1249 | read_unlock_irqrestore(&table->rwlock, flags); | 1249 | read_unlock_irqrestore(&table->rwlock, flags); |
1250 | return ndev; | 1250 | return ndev; |
1251 | } | 1251 | } |
1252 | EXPORT_SYMBOL(rdma_read_gid_attr_ndev_rcu); | ||
1252 | 1253 | ||
1253 | static int get_lower_dev_vlan(struct net_device *lower_dev, void *data) | 1254 | static int get_lower_dev_vlan(struct net_device *lower_dev, void *data) |
1254 | { | 1255 | { |
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 088b5495e199..19f1730a4f24 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c | |||
@@ -1486,6 +1486,7 @@ static struct net_device * | |||
1486 | roce_get_net_dev_by_cm_event(const struct ib_cm_event *ib_event) | 1486 | roce_get_net_dev_by_cm_event(const struct ib_cm_event *ib_event) |
1487 | { | 1487 | { |
1488 | const struct ib_gid_attr *sgid_attr = NULL; | 1488 | const struct ib_gid_attr *sgid_attr = NULL; |
1489 | struct net_device *ndev; | ||
1489 | 1490 | ||
1490 | if (ib_event->event == IB_CM_REQ_RECEIVED) | 1491 | if (ib_event->event == IB_CM_REQ_RECEIVED) |
1491 | sgid_attr = ib_event->param.req_rcvd.ppath_sgid_attr; | 1492 | sgid_attr = ib_event->param.req_rcvd.ppath_sgid_attr; |
@@ -1494,8 +1495,15 @@ roce_get_net_dev_by_cm_event(const struct ib_cm_event *ib_event) | |||
1494 | 1495 | ||
1495 | if (!sgid_attr) | 1496 | if (!sgid_attr) |
1496 | return NULL; | 1497 | return NULL; |
1497 | dev_hold(sgid_attr->ndev); | 1498 | |
1498 | return sgid_attr->ndev; | 1499 | rcu_read_lock(); |
1500 | ndev = rdma_read_gid_attr_ndev_rcu(sgid_attr); | ||
1501 | if (IS_ERR(ndev)) | ||
1502 | ndev = NULL; | ||
1503 | else | ||
1504 | dev_hold(ndev); | ||
1505 | rcu_read_unlock(); | ||
1506 | return ndev; | ||
1499 | } | 1507 | } |
1500 | 1508 | ||
1501 | static struct net_device *cma_get_net_dev(const struct ib_cm_event *ib_event, | 1509 | static struct net_device *cma_get_net_dev(const struct ib_cm_event *ib_event, |
diff --git a/include/rdma/ib_cache.h b/include/rdma/ib_cache.h index 730a65ad8c74..870b5e6c06db 100644 --- a/include/rdma/ib_cache.h +++ b/include/rdma/ib_cache.h | |||
@@ -56,6 +56,7 @@ const struct ib_gid_attr *rdma_find_gid_by_filter( | |||
56 | 56 | ||
57 | int rdma_read_gid_l2_fields(const struct ib_gid_attr *attr, | 57 | int rdma_read_gid_l2_fields(const struct ib_gid_attr *attr, |
58 | u16 *vlan_id, u8 *smac); | 58 | u16 *vlan_id, u8 *smac); |
59 | struct net_device *rdma_read_gid_attr_ndev_rcu(const struct ib_gid_attr *attr); | ||
59 | 60 | ||
60 | /** | 61 | /** |
61 | * ib_get_cached_pkey - Returns a cached PKey table entry | 62 | * ib_get_cached_pkey - Returns a cached PKey table entry |