Skip to content

Commit aa9d464

Browse files
committed
Merge tag 'for-linus-ioctl' of git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma
Pull rdma updates from Doug Ledford: "This is a big pull request. Of note is that I'm sending you the new ioctl API for the rdma subsystem. We put it up on linux-api@, but didn't get much response. The API is complex, but it solves two different problems in one go: 1) The bi-directional nature of the RDMA file write calls, which created the security hole we had to handle (and for which the fix is now causing problems for systems in production, we were a bit over zealous in the fix and the ability to open a device, then fork, then create new queue pairs on the device and use them is broken). 2) The bloat caused by different vendors implementing extensions to the base verbs API. Each vendor's hardware is slightly different, and the hardware might be suitable for one extension but not another. By the time we add generic extensions for all the different ways that the different hardware can offload things, the API becomes bloated. Things like our completion structs have started to exceed a cache line in size because of all the elements needed to support this. That in turn shows up heavily in the performance graphs with a noticable drop in performance on 100Gigabit links as our completion structs go from occupying one cache line to 1+. This API makes things like the completion structs modular in a very similar way to netlink so that your structs can only include the items needed for the offloads/features you are actually using on a given queue pair. In that way we support everything, but only use what we need, and our structs stay smaller. The ioctl API is better explained by the posting on linux-api@ than I can explain it here, so I'll just leave it at that. The rest of the pull request is typical stuff. Updates for 4.14 kernel merge window - Lots of hfi1 driver updates (mixed with a few qib and core updates as well) - rxe updates - various mlx updates - Set default roce type to RoCEv2 - Several larger fixes for bnxt_re that were too big for -rc - Several larger fixes for qedr that, likewise, were too big for -rc - Misc core changes - Make the hns_roce driver compilable on arches other than aarch64 so we can more easily debug build issues related to it - Add rdma-netlink infrastructure updates - Add automatic IRQ affinity infrastructure - Add 32bit lid support - Lots of misc fixes across the subsystem from random people - Autoloading of RDMA netlink modules - PCI pool cleanups from Romain Perier - mlx5 driver feature additions and fixes - Hardware tag matchine feature - Fix sleeping in atomic when resolving roce ah - Add experimental ioctl interface as posted to linux-api@" * tag 'for-linus-ioctl' of git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma: (328 commits) IB/core: Expose ioctl interface through experimental Kconfig IB/core: Assign root to all drivers IB/core: Add completion queue (cq) object actions IB/core: Add legacy driver's user-data IB/core: Export ioctl enum types to user-space IB/core: Explicitly destroy an object while keeping uobject IB/core: Add macros for declaring methods and attributes IB/core: Add uverbs merge trees functionality IB/core: Add DEVICE object and root tree structure IB/core: Declare an object instead of declaring only type attributes IB/core: Add new ioctl interface RDMA/vmw_pvrdma: Fix a signedness RDMA/vmw_pvrdma: Report network header type in WC IB/core: Add might_sleep() annotation to ib_init_ah_from_wc() IB/cm: Fix sleeping in atomic when RoCE is used IB/core: Add support to finalize objects in one transaction IB/core: Add a generic way to execute an operation on a uobject Documentation: Hardware tag matching IB/mlx5: Support IB_SRQT_TM net/mlx5: Add XRQ support ...
2 parents 906dde0 + 8eb19e8 commit aa9d464

275 files changed

Lines changed: 14866 additions & 5221 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.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
Tag matching logic
2+
3+
The MPI standard defines a set of rules, known as tag-matching, for matching
4+
source send operations to destination receives. The following parameters must
5+
match the following source and destination parameters:
6+
* Communicator
7+
* User tag - wild card may be specified by the receiver
8+
* Source rank – wild car may be specified by the receiver
9+
* Destination rank – wild
10+
The ordering rules require that when more than one pair of send and receive
11+
message envelopes may match, the pair that includes the earliest posted-send
12+
and the earliest posted-receive is the pair that must be used to satisfy the
13+
matching operation. However, this doesn’t imply that tags are consumed in
14+
the order they are created, e.g., a later generated tag may be consumed, if
15+
earlier tags can’t be used to satisfy the matching rules.
16+
17+
When a message is sent from the sender to the receiver, the communication
18+
library may attempt to process the operation either after or before the
19+
corresponding matching receive is posted. If a matching receive is posted,
20+
this is an expected message, otherwise it is called an unexpected message.
21+
Implementations frequently use different matching schemes for these two
22+
different matching instances.
23+
24+
To keep MPI library memory footprint down, MPI implementations typically use
25+
two different protocols for this purpose:
26+
27+
1. The Eager protocol- the complete message is sent when the send is
28+
processed by the sender. A completion send is received in the send_cq
29+
notifying that the buffer can be reused.
30+
31+
2. The Rendezvous Protocol - the sender sends the tag-matching header,
32+
and perhaps a portion of data when first notifying the receiver. When the
33+
corresponding buffer is posted, the responder will use the information from
34+
the header to initiate an RDMA READ operation directly to the matching buffer.
35+
A fin message needs to be received in order for the buffer to be reused.
36+
37+
Tag matching implementation
38+
39+
There are two types of matching objects used, the posted receive list and the
40+
unexpected message list. The application posts receive buffers through calls
41+
to the MPI receive routines in the posted receive list and posts send messages
42+
using the MPI send routines. The head of the posted receive list may be
43+
maintained by the hardware, with the software expected to shadow this list.
44+
45+
When send is initiated and arrives at the receive side, if there is no
46+
pre-posted receive for this arriving message, it is passed to the software and
47+
placed in the unexpected message list. Otherwise the match is processed,
48+
including rendezvous processing, if appropriate, delivering the data to the
49+
specified receive buffer. This allows overlapping receive-side MPI tag
50+
matching with computation.
51+
52+
When a receive-message is posted, the communication library will first check
53+
the software unexpected message list for a matching receive. If a match is
54+
found, data is delivered to the user buffer, using a software controlled
55+
protocol. The UCX implementation uses either an eager or rendezvous protocol,
56+
depending on data size. If no match is found, the entire pre-posted receive
57+
list is maintained by the hardware, and there is space to add one more
58+
pre-posted receive to this list, this receive is passed to the hardware.
59+
Software is expected to shadow this list, to help with processing MPI cancel
60+
operations. In addition, because hardware and software are not expected to be
61+
tightly synchronized with respect to the tag-matching operation, this shadow
62+
list is used to detect the case that a pre-posted receive is passed to the
63+
hardware, as the matching unexpected message is being passed from the hardware
64+
to the software.

‎block/Kconfig‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,9 @@ config BLK_MQ_VIRTIO
206206
depends on BLOCK && VIRTIO
207207
default y
208208

209+
config BLK_MQ_RDMA
210+
bool
211+
depends on BLOCK && INFINIBAND
212+
default y
213+
209214
source block/Kconfig.iosched

‎block/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ obj-$(CONFIG_BLK_CMDLINE_PARSER) += cmdline-parser.o
2929
obj-$(CONFIG_BLK_DEV_INTEGRITY) += bio-integrity.o blk-integrity.o t10-pi.o
3030
obj-$(CONFIG_BLK_MQ_PCI) += blk-mq-pci.o
3131
obj-$(CONFIG_BLK_MQ_VIRTIO) += blk-mq-virtio.o
32+
obj-$(CONFIG_BLK_MQ_RDMA) += blk-mq-rdma.o
3233
obj-$(CONFIG_BLK_DEV_ZONED) += blk-zoned.o
3334
obj-$(CONFIG_BLK_WBT) += blk-wbt.o
3435
obj-$(CONFIG_BLK_DEBUG_FS) += blk-mq-debugfs.o

‎block/blk-mq-rdma.c‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2017 Sagi Grimberg.
3+
*
4+
* This program is free software; you can redistribute it and/or modify it
5+
* under the terms and conditions of the GNU General Public License,
6+
* version 2, as published by the Free Software Foundation.
7+
*
8+
* This program is distributed in the hope it will be useful, but WITHOUT
9+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11+
* more details.
12+
*/
13+
#include <linux/blk-mq.h>
14+
#include <linux/blk-mq-rdma.h>
15+
#include <rdma/ib_verbs.h>
16+
17+
/**
18+
* blk_mq_rdma_map_queues - provide a default queue mapping for rdma device
19+
* @set: tagset to provide the mapping for
20+
* @dev: rdma device associated with @set.
21+
* @first_vec: first interrupt vectors to use for queues (usually 0)
22+
*
23+
* This function assumes the rdma device @dev has at least as many available
24+
* interrupt vetors as @set has queues. It will then query it's affinity mask
25+
* and built queue mapping that maps a queue to the CPUs that have irq affinity
26+
* for the corresponding vector.
27+
*
28+
* In case either the driver passed a @dev with less vectors than
29+
* @set->nr_hw_queues, or @dev does not provide an affinity mask for a
30+
* vector, we fallback to the naive mapping.
31+
*/
32+
int blk_mq_rdma_map_queues(struct blk_mq_tag_set *set,
33+
struct ib_device *dev, int first_vec)
34+
{
35+
const struct cpumask *mask;
36+
unsigned int queue, cpu;
37+
38+
for (queue = 0; queue < set->nr_hw_queues; queue++) {
39+
mask = ib_get_vector_affinity(dev, first_vec + queue);
40+
if (!mask)
41+
goto fallback;
42+
43+
for_each_cpu(cpu, mask)
44+
set->mq_map[cpu] = queue;
45+
}
46+
47+
return 0;
48+
49+
fallback:
50+
return blk_mq_map_queues(set);
51+
}
52+
EXPORT_SYMBOL_GPL(blk_mq_rdma_map_queues);

‎drivers/infiniband/Kconfig‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ config INFINIBAND_USER_ACCESS
3434
libibverbs, libibcm and a hardware driver library from
3535
<http://www.openfabrics.org/git/>.
3636

37+
config INFINIBAND_EXP_USER_ACCESS
38+
bool "Allow experimental support for Infiniband ABI"
39+
depends on INFINIBAND_USER_ACCESS
40+
---help---
41+
IOCTL based ABI support for Infiniband. This allows userspace
42+
to invoke the experimental IOCTL based ABI.
43+
These commands are parsed via per-device parsing tree and
44+
enables per-device features.
45+
3746
config INFINIBAND_USER_MEM
3847
bool
3948
depends on INFINIBAND_USER_ACCESS != n

‎drivers/infiniband/core/Makefile‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ ib_core-y := packer.o ud_header.o verbs.o cq.o rw.o sysfs.o \
1111
device.o fmr_pool.o cache.o netlink.o \
1212
roce_gid_mgmt.o mr_pool.o addr.o sa_query.o \
1313
multicast.o mad.o smi.o agent.o mad_rmpp.o \
14-
security.o
14+
security.o nldev.o
15+
1516
ib_core-$(CONFIG_INFINIBAND_USER_MEM) += umem.o
1617
ib_core-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += umem_odp.o umem_rbtree.o
1718
ib_core-$(CONFIG_CGROUP_RDMA) += cgroup.o
@@ -31,4 +32,5 @@ ib_umad-y := user_mad.o
3132
ib_ucm-y := ucm.o
3233

3334
ib_uverbs-y := uverbs_main.o uverbs_cmd.o uverbs_marshall.o \
34-
rdma_core.o uverbs_std_types.o
35+
rdma_core.o uverbs_std_types.o uverbs_ioctl.o \
36+
uverbs_ioctl_merge.o

‎drivers/infiniband/core/addr.c‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,11 @@ static void ib_nl_process_good_ip_rsep(const struct nlmsghdr *nlh)
130130
}
131131

132132
int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
133-
struct netlink_callback *cb)
133+
struct nlmsghdr *nlh,
134+
struct netlink_ext_ack *extack)
134135
{
135-
const struct nlmsghdr *nlh = (struct nlmsghdr *)cb->nlh;
136-
137136
if ((nlh->nlmsg_flags & NLM_F_REQUEST) ||
138-
!(NETLINK_CB(skb).sk) ||
139-
!netlink_capable(skb, CAP_NET_ADMIN))
137+
!(NETLINK_CB(skb).sk))
140138
return -EPERM;
141139

142140
if (ib_nl_is_good_ip_resp(nlh))
@@ -186,7 +184,7 @@ static int ib_nl_ip_send_msg(struct rdma_dev_addr *dev_addr,
186184

187185
/* Repair the nlmsg header length */
188186
nlmsg_end(skb, nlh);
189-
ibnl_multicast(skb, nlh, RDMA_NL_GROUP_LS, GFP_KERNEL);
187+
rdma_nl_multicast(skb, RDMA_NL_GROUP_LS, GFP_KERNEL);
190188

191189
/* Make the request retry, so when we get the response from userspace
192190
* we will have something.
@@ -326,7 +324,7 @@ static void queue_req(struct addr_req *req)
326324
static int ib_nl_fetch_ha(struct dst_entry *dst, struct rdma_dev_addr *dev_addr,
327325
const void *daddr, u32 seq, u16 family)
328326
{
329-
if (ibnl_chk_listeners(RDMA_NL_GROUP_LS))
327+
if (rdma_nl_chk_listeners(RDMA_NL_GROUP_LS))
330328
return -EADDRNOTAVAIL;
331329

332330
/* We fill in what we can, the response will fill the rest */

‎drivers/infiniband/core/cache.c‎

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,30 +1199,23 @@ int ib_cache_setup_one(struct ib_device *device)
11991199
device->cache.ports =
12001200
kzalloc(sizeof(*device->cache.ports) *
12011201
(rdma_end_port(device) - rdma_start_port(device) + 1), GFP_KERNEL);
1202-
if (!device->cache.ports) {
1203-
err = -ENOMEM;
1204-
goto out;
1205-
}
1202+
if (!device->cache.ports)
1203+
return -ENOMEM;
12061204

12071205
err = gid_table_setup_one(device);
1208-
if (err)
1209-
goto out;
1206+
if (err) {
1207+
kfree(device->cache.ports);
1208+
device->cache.ports = NULL;
1209+
return err;
1210+
}
12101211

12111212
for (p = 0; p <= rdma_end_port(device) - rdma_start_port(device); ++p)
12121213
ib_cache_update(device, p + rdma_start_port(device), true);
12131214

12141215
INIT_IB_EVENT_HANDLER(&device->cache.event_handler,
12151216
device, ib_cache_event);
1216-
err = ib_register_event_handler(&device->cache.event_handler);
1217-
if (err)
1218-
goto err;
1219-
1217+
ib_register_event_handler(&device->cache.event_handler);
12201218
return 0;
1221-
1222-
err:
1223-
gid_table_cleanup_one(device);
1224-
out:
1225-
return err;
12261219
}
12271220

12281221
void ib_cache_release_one(struct ib_device *device)

0 commit comments

Comments
 (0)