Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

IB/rxe: Revise the ib_wr_opcode enum

This enum has become part of the uABI, as both RXE and the
ib_uverbs_post_send() command expect userspace to supply values from this
enum. So it should be properly placed in include/uapi/rdma.

In userspace this enum is called 'enum ibv_wr_opcode' as part of
libibverbs.h. That enum defines different values for IB_WR_LOCAL_INV,
IB_WR_SEND_WITH_INV, and IB_WR_LSO. These were introduced (incorrectly, it
turns out) into libiberbs in 2015.

The kernel has changed its mind on the numbering for several of the IB_WC
values over the years, but has remained stable on IB_WR_LOCAL_INV and
below.

Based on this we can conclude that there is no real user space user of the
values beyond IB_WR_ATOMIC_FETCH_AND_ADD, as they have never worked via
rdma-core. This is confirmed by inspection, only rxe uses the kernel enum
and implements the latter operations. rxe has clearly never worked with
these attributes from userspace. Other drivers that support these opcodes
implement the functionality without calling out to the kernel.

To make IB_WR_SEND_WITH_INV and related work for RXE in userspace we
choose to renumber the IB_WR enum in the kernel to match the uABI that
userspace has bee using since before Soft RoCE was merged. This is an
overall simpler configuration for the whole software stack, and obviously
can't break anything existing.

Reported-by: Seth Howell <seth.howell@intel.com>
Tested-by: Seth Howell <seth.howell@intel.com>
Fixes: 8700e3e7c485 ("Soft RoCE driver")
Cc: <stable@vger.kernel.org>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

+39 -15
+20 -14
include/rdma/ib_verbs.h
··· 1281 1281 }; 1282 1282 1283 1283 enum ib_wr_opcode { 1284 - IB_WR_RDMA_WRITE, 1285 - IB_WR_RDMA_WRITE_WITH_IMM, 1286 - IB_WR_SEND, 1287 - IB_WR_SEND_WITH_IMM, 1288 - IB_WR_RDMA_READ, 1289 - IB_WR_ATOMIC_CMP_AND_SWP, 1290 - IB_WR_ATOMIC_FETCH_AND_ADD, 1291 - IB_WR_LSO, 1292 - IB_WR_SEND_WITH_INV, 1293 - IB_WR_RDMA_READ_WITH_INV, 1294 - IB_WR_LOCAL_INV, 1295 - IB_WR_REG_MR, 1296 - IB_WR_MASKED_ATOMIC_CMP_AND_SWP, 1297 - IB_WR_MASKED_ATOMIC_FETCH_AND_ADD, 1284 + /* These are shared with userspace */ 1285 + IB_WR_RDMA_WRITE = IB_UVERBS_WR_RDMA_WRITE, 1286 + IB_WR_RDMA_WRITE_WITH_IMM = IB_UVERBS_WR_RDMA_WRITE_WITH_IMM, 1287 + IB_WR_SEND = IB_UVERBS_WR_SEND, 1288 + IB_WR_SEND_WITH_IMM = IB_UVERBS_WR_SEND_WITH_IMM, 1289 + IB_WR_RDMA_READ = IB_UVERBS_WR_RDMA_READ, 1290 + IB_WR_ATOMIC_CMP_AND_SWP = IB_UVERBS_WR_ATOMIC_CMP_AND_SWP, 1291 + IB_WR_ATOMIC_FETCH_AND_ADD = IB_UVERBS_WR_ATOMIC_FETCH_AND_ADD, 1292 + IB_WR_LSO = IB_UVERBS_WR_TSO, 1293 + IB_WR_SEND_WITH_INV = IB_UVERBS_WR_SEND_WITH_INV, 1294 + IB_WR_RDMA_READ_WITH_INV = IB_UVERBS_WR_RDMA_READ_WITH_INV, 1295 + IB_WR_LOCAL_INV = IB_UVERBS_WR_LOCAL_INV, 1296 + IB_WR_MASKED_ATOMIC_CMP_AND_SWP = 1297 + IB_UVERBS_WR_MASKED_ATOMIC_CMP_AND_SWP, 1298 + IB_WR_MASKED_ATOMIC_FETCH_AND_ADD = 1299 + IB_UVERBS_WR_MASKED_ATOMIC_FETCH_AND_ADD, 1300 + 1301 + /* These are kernel only and can not be issued by userspace */ 1302 + IB_WR_REG_MR = 0x20, 1298 1303 IB_WR_REG_SIG_MR, 1304 + 1299 1305 /* reserve values for low level drivers' internal use. 1300 1306 * These values will not be used at all in the ib core layer. 1301 1307 */
+19 -1
include/uapi/rdma/ib_user_verbs.h
··· 763 763 __u32 lkey; 764 764 }; 765 765 766 + enum ib_uverbs_wr_opcode { 767 + IB_UVERBS_WR_RDMA_WRITE = 0, 768 + IB_UVERBS_WR_RDMA_WRITE_WITH_IMM = 1, 769 + IB_UVERBS_WR_SEND = 2, 770 + IB_UVERBS_WR_SEND_WITH_IMM = 3, 771 + IB_UVERBS_WR_RDMA_READ = 4, 772 + IB_UVERBS_WR_ATOMIC_CMP_AND_SWP = 5, 773 + IB_UVERBS_WR_ATOMIC_FETCH_AND_ADD = 6, 774 + IB_UVERBS_WR_LOCAL_INV = 7, 775 + IB_UVERBS_WR_BIND_MW = 8, 776 + IB_UVERBS_WR_SEND_WITH_INV = 9, 777 + IB_UVERBS_WR_TSO = 10, 778 + IB_UVERBS_WR_RDMA_READ_WITH_INV = 11, 779 + IB_UVERBS_WR_MASKED_ATOMIC_CMP_AND_SWP = 12, 780 + IB_UVERBS_WR_MASKED_ATOMIC_FETCH_AND_ADD = 13, 781 + /* Review enum ib_wr_opcode before modifying this */ 782 + }; 783 + 766 784 struct ib_uverbs_send_wr { 767 785 __aligned_u64 wr_id; 768 786 __u32 num_sge; 769 - __u32 opcode; 787 + __u32 opcode; /* see enum ib_uverbs_wr_opcode */ 770 788 __u32 send_flags; 771 789 union { 772 790 __be32 imm_data;