Skip to content

Commit dce45af

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
Pull rdma updates from Jason Gunthorpe: "This has been a smaller cycle than normal. One new driver was accepted, which is unusual, and at least one more driver remains in review on the list. Summary: - Driver fixes for hns, hfi1, nes, rxe, i40iw, mlx5, cxgb4, vmw_pvrdma - Many patches from MatthewW converting radix tree and IDR users to use xarray - Introduction of tracepoints to the MAD layer - Build large SGLs at the start for DMA mapping and get the driver to split them - Generally clean SGL handling code throughout the subsystem - Support for restricting RDMA devices to net namespaces for containers - Progress to remove object allocation boilerplate code from drivers - Change in how the mlx5 driver shows representor ports linked to VFs - mlx5 uapi feature to access the on chip SW ICM memory - Add a new driver for 'EFA'. This is HW that supports user space packet processing through QPs in Amazon's cloud" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: (186 commits) RDMA/ipoib: Allow user space differentiate between valid dev_port IB/core, ipoib: Do not overreact to SM LID change event RDMA/device: Don't fire uevent before device is fully initialized lib/scatterlist: Remove leftover from sg_page_iter comment RDMA/efa: Add driver to Kconfig/Makefile RDMA/efa: Add the efa module RDMA/efa: Add EFA verbs implementation RDMA/efa: Add common command handlers RDMA/efa: Implement functions that submit and complete admin commands RDMA/efa: Add the ABI definitions RDMA/efa: Add the com service API definitions RDMA/efa: Add the efa_com.h file RDMA/efa: Add the efa.h header file RDMA/efa: Add EFA device definitions RDMA: Add EFA related definitions RDMA/umem: Remove hugetlb flag RDMA/bnxt_re: Use core helpers to get aligned DMA address RDMA/i40iw: Use core helpers to get aligned DMA address within a supported page size RDMA/verbs: Add a DMA iterator to return aligned contiguous memory blocks RDMA/umem: Add API to find best driver supported page size in an MR ...
2 parents 055128e + b79656e commit dce45af

251 files changed

Lines changed: 12535 additions & 4571 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎MAINTAINERS‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,15 @@ S: Supported
745745
F: Documentation/networking/device_drivers/amazon/ena.txt
746746
F: drivers/net/ethernet/amazon/
747747

748+
AMAZON RDMA EFA DRIVER
749+
M: Gal Pressman <galpress@amazon.com>
750+
R: Yossi Leybovich <sleybo@amazon.com>
751+
L: linux-rdma@vger.kernel.org
752+
Q: https://patchwork.kernel.org/project/linux-rdma/list/
753+
S: Supported
754+
F: drivers/infiniband/hw/efa/
755+
F: include/uapi/rdma/efa-abi.h
756+
748757
AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER
749758
M: Tom Lendacky <thomas.lendacky@amd.com>
750759
M: Gary Hook <gary.hook@amd.com>
@@ -4279,7 +4288,7 @@ S: Supported
42794288
F: drivers/scsi/cxgbi/cxgb3i
42804289

42814290
CXGB3 IWARP RNIC DRIVER (IW_CXGB3)
4282-
M: Steve Wise <swise@chelsio.com>
4291+
M: Potnuri Bharat Teja <bharat@chelsio.com>
42834292
L: linux-rdma@vger.kernel.org
42844293
W: http://www.openfabrics.org
42854294
S: Supported
@@ -4308,7 +4317,7 @@ S: Supported
43084317
F: drivers/scsi/cxgbi/cxgb4i
43094318

43104319
CXGB4 IWARP RNIC DRIVER (IW_CXGB4)
4311-
M: Steve Wise <swise@chelsio.com>
4320+
M: Potnuri Bharat Teja <bharat@chelsio.com>
43124321
L: linux-rdma@vger.kernel.org
43134322
W: http://www.openfabrics.org
43144323
S: Supported
@@ -7727,6 +7736,10 @@ F: drivers/infiniband/
77277736
F: include/uapi/linux/if_infiniband.h
77287737
F: include/uapi/rdma/
77297738
F: include/rdma/
7739+
F: include/trace/events/ib_mad.h
7740+
F: include/trace/events/ib_umad.h
7741+
F: samples/bpf/ibumad_kern.c
7742+
F: samples/bpf/ibumad_user.c
77307743

77317744
INGENIC JZ4780 DMA Driver
77327745
M: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>

‎drivers/infiniband/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ source "drivers/infiniband/hw/mthca/Kconfig"
9393
source "drivers/infiniband/hw/qib/Kconfig"
9494
source "drivers/infiniband/hw/cxgb3/Kconfig"
9595
source "drivers/infiniband/hw/cxgb4/Kconfig"
96+
source "drivers/infiniband/hw/efa/Kconfig"
9697
source "drivers/infiniband/hw/i40iw/Kconfig"
9798
source "drivers/infiniband/hw/mlx4/Kconfig"
9899
source "drivers/infiniband/hw/mlx5/Kconfig"

‎drivers/infiniband/core/addr.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include <net/ipv6_stubs.h>
4646
#include <net/ip6_route.h>
4747
#include <rdma/ib_addr.h>
48+
#include <rdma/ib_cache.h>
4849
#include <rdma/ib_sa.h>
4950
#include <rdma/ib.h>
5051
#include <rdma/rdma_netlink.h>

‎drivers/infiniband/core/cache.c‎

Lines changed: 115 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,22 @@ enum gid_table_entry_state {
7878
GID_TABLE_ENTRY_PENDING_DEL = 3,
7979
};
8080

81+
struct roce_gid_ndev_storage {
82+
struct rcu_head rcu_head;
83+
struct net_device *ndev;
84+
};
85+
8186
struct ib_gid_table_entry {
8287
struct kref kref;
8388
struct work_struct del_work;
8489
struct ib_gid_attr attr;
8590
void *context;
91+
/* Store the ndev pointer to release reference later on in
92+
* call_rcu context because by that time gid_table_entry
93+
* and attr might be already freed. So keep a copy of it.
94+
* ndev_storage is freed by rcu callback.
95+
*/
96+
struct roce_gid_ndev_storage *ndev_storage;
8697
enum gid_table_entry_state state;
8798
};
8899

@@ -206,6 +217,20 @@ static void schedule_free_gid(struct kref *kref)
206217
queue_work(ib_wq, &entry->del_work);
207218
}
208219

220+
static void put_gid_ndev(struct rcu_head *head)
221+
{
222+
struct roce_gid_ndev_storage *storage =
223+
container_of(head, struct roce_gid_ndev_storage, rcu_head);
224+
225+
WARN_ON(!storage->ndev);
226+
/* At this point its safe to release netdev reference,
227+
* as all callers working on gid_attr->ndev are done
228+
* using this netdev.
229+
*/
230+
dev_put(storage->ndev);
231+
kfree(storage);
232+
}
233+
209234
static void free_gid_entry_locked(struct ib_gid_table_entry *entry)
210235
{
211236
struct ib_device *device = entry->attr.device;
@@ -228,8 +253,8 @@ static void free_gid_entry_locked(struct ib_gid_table_entry *entry)
228253
/* Now this index is ready to be allocated */
229254
write_unlock_irq(&table->rwlock);
230255

231-
if (entry->attr.ndev)
232-
dev_put(entry->attr.ndev);
256+
if (entry->ndev_storage)
257+
call_rcu(&entry->ndev_storage->rcu_head, put_gid_ndev);
233258
kfree(entry);
234259
}
235260

@@ -266,14 +291,25 @@ static struct ib_gid_table_entry *
266291
alloc_gid_entry(const struct ib_gid_attr *attr)
267292
{
268293
struct ib_gid_table_entry *entry;
294+
struct net_device *ndev;
269295

270296
entry = kzalloc(sizeof(*entry), GFP_KERNEL);
271297
if (!entry)
272298
return NULL;
299+
300+
ndev = rcu_dereference_protected(attr->ndev, 1);
301+
if (ndev) {
302+
entry->ndev_storage = kzalloc(sizeof(*entry->ndev_storage),
303+
GFP_KERNEL);
304+
if (!entry->ndev_storage) {
305+
kfree(entry);
306+
return NULL;
307+
}
308+
dev_hold(ndev);
309+
entry->ndev_storage->ndev = ndev;
310+
}
273311
kref_init(&entry->kref);
274312
memcpy(&entry->attr, attr, sizeof(*attr));
275-
if (entry->attr.ndev)
276-
dev_hold(entry->attr.ndev);
277313
INIT_WORK(&entry->del_work, free_gid_work);
278314
entry->state = GID_TABLE_ENTRY_INVALID;
279315
return entry;
@@ -343,6 +379,7 @@ static int add_roce_gid(struct ib_gid_table_entry *entry)
343379
static void del_gid(struct ib_device *ib_dev, u8 port,
344380
struct ib_gid_table *table, int ix)
345381
{
382+
struct roce_gid_ndev_storage *ndev_storage;
346383
struct ib_gid_table_entry *entry;
347384

348385
lockdep_assert_held(&table->lock);
@@ -360,6 +397,13 @@ static void del_gid(struct ib_device *ib_dev, u8 port,
360397
table->data_vec[ix] = NULL;
361398
write_unlock_irq(&table->rwlock);
362399

400+
ndev_storage = entry->ndev_storage;
401+
if (ndev_storage) {
402+
entry->ndev_storage = NULL;
403+
rcu_assign_pointer(entry->attr.ndev, NULL);
404+
call_rcu(&ndev_storage->rcu_head, put_gid_ndev);
405+
}
406+
363407
if (rdma_cap_roce_gid_table(ib_dev, port))
364408
ib_dev->ops.del_gid(&entry->attr, &entry->context);
365409

@@ -543,30 +587,11 @@ static int __ib_cache_gid_add(struct ib_device *ib_dev, u8 port,
543587
int ib_cache_gid_add(struct ib_device *ib_dev, u8 port,
544588
union ib_gid *gid, struct ib_gid_attr *attr)
545589
{
546-
struct net_device *idev;
547-
unsigned long mask;
548-
int ret;
549-
550-
idev = ib_device_get_netdev(ib_dev, port);
551-
if (idev && attr->ndev != idev) {
552-
union ib_gid default_gid;
553-
554-
/* Adding default GIDs is not permitted */
555-
make_default_gid(idev, &default_gid);
556-
if (!memcmp(gid, &default_gid, sizeof(*gid))) {
557-
dev_put(idev);
558-
return -EPERM;
559-
}
560-
}
561-
if (idev)
562-
dev_put(idev);
563-
564-
mask = GID_ATTR_FIND_MASK_GID |
565-
GID_ATTR_FIND_MASK_GID_TYPE |
566-
GID_ATTR_FIND_MASK_NETDEV;
590+
unsigned long mask = GID_ATTR_FIND_MASK_GID |
591+
GID_ATTR_FIND_MASK_GID_TYPE |
592+
GID_ATTR_FIND_MASK_NETDEV;
567593

568-
ret = __ib_cache_gid_add(ib_dev, port, gid, attr, mask, false);
569-
return ret;
594+
return __ib_cache_gid_add(ib_dev, port, gid, attr, mask, false);
570595
}
571596

572597
static int
@@ -1263,11 +1288,72 @@ struct net_device *rdma_read_gid_attr_ndev_rcu(const struct ib_gid_attr *attr)
12631288

12641289
read_lock_irqsave(&table->rwlock, flags);
12651290
valid = is_gid_entry_valid(table->data_vec[attr->index]);
1266-
if (valid && attr->ndev && (READ_ONCE(attr->ndev->flags) & IFF_UP))
1267-
ndev = attr->ndev;
1291+
if (valid) {
1292+
ndev = rcu_dereference(attr->ndev);
1293+
if (!ndev ||
1294+
(ndev && ((READ_ONCE(ndev->flags) & IFF_UP) == 0)))
1295+
ndev = ERR_PTR(-ENODEV);
1296+
}
12681297
read_unlock_irqrestore(&table->rwlock, flags);
12691298
return ndev;
12701299
}
1300+
EXPORT_SYMBOL(rdma_read_gid_attr_ndev_rcu);
1301+
1302+
static int get_lower_dev_vlan(struct net_device *lower_dev, void *data)
1303+
{
1304+
u16 *vlan_id = data;
1305+
1306+
if (is_vlan_dev(lower_dev))
1307+
*vlan_id = vlan_dev_vlan_id(lower_dev);
1308+
1309+
/* We are interested only in first level vlan device, so
1310+
* always return 1 to stop iterating over next level devices.
1311+
*/
1312+
return 1;
1313+
}
1314+
1315+
/**
1316+
* rdma_read_gid_l2_fields - Read the vlan ID and source MAC address
1317+
* of a GID entry.
1318+
*
1319+
* @attr: GID attribute pointer whose L2 fields to be read
1320+
* @vlan_id: Pointer to vlan id to fill up if the GID entry has
1321+
* vlan id. It is optional.
1322+
* @smac: Pointer to smac to fill up for a GID entry. It is optional.
1323+
*
1324+
* rdma_read_gid_l2_fields() returns 0 on success and returns vlan id
1325+
* (if gid entry has vlan) and source MAC, or returns error.
1326+
*/
1327+
int rdma_read_gid_l2_fields(const struct ib_gid_attr *attr,
1328+
u16 *vlan_id, u8 *smac)
1329+
{
1330+
struct net_device *ndev;
1331+
1332+
rcu_read_lock();
1333+
ndev = rcu_dereference(attr->ndev);
1334+
if (!ndev) {
1335+
rcu_read_unlock();
1336+
return -ENODEV;
1337+
}
1338+
if (smac)
1339+
ether_addr_copy(smac, ndev->dev_addr);
1340+
if (vlan_id) {
1341+
*vlan_id = 0xffff;
1342+
if (is_vlan_dev(ndev)) {
1343+
*vlan_id = vlan_dev_vlan_id(ndev);
1344+
} else {
1345+
/* If the netdev is upper device and if it's lower
1346+
* device is vlan device, consider vlan id of the
1347+
* the lower vlan device for this gid entry.
1348+
*/
1349+
netdev_walk_all_lower_dev_rcu(attr->ndev,
1350+
get_lower_dev_vlan, vlan_id);
1351+
}
1352+
}
1353+
rcu_read_unlock();
1354+
return 0;
1355+
}
1356+
EXPORT_SYMBOL(rdma_read_gid_l2_fields);
12711357

12721358
static int config_non_roce_gid_cache(struct ib_device *device,
12731359
u8 port, int gid_tbl_len)
@@ -1392,7 +1478,6 @@ static void ib_cache_event(struct ib_event_handler *handler,
13921478
event->event == IB_EVENT_PORT_ACTIVE ||
13931479
event->event == IB_EVENT_LID_CHANGE ||
13941480
event->event == IB_EVENT_PKEY_CHANGE ||
1395-
event->event == IB_EVENT_SM_CHANGE ||
13961481
event->event == IB_EVENT_CLIENT_REREGISTER ||
13971482
event->event == IB_EVENT_GID_CHANGE) {
13981483
work = kmalloc(sizeof *work, GFP_ATOMIC);

0 commit comments

Comments
 (0)