IB/rxe: Revise the ib_wr_opcode enum
authorJason Gunthorpe <jgg@mellanox.com>
Tue, 14 Aug 2018 22:33:02 +0000 (15:33 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 May 2019 17:42:25 +0000 (19:42 +0200)
[ Upstream commit 9a59739bd01f77db6fbe2955a4fce165f0f43568 ]

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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
include/rdma/ib_verbs.h
include/uapi/rdma/ib_user_verbs.h

index 5a24b4c700e5974464d3280f80c9c44fead89737..9e76b2410d03f30ed520091859d8629bd01991a5 100644 (file)
@@ -1251,21 +1251,27 @@ struct ib_qp_attr {
 };
 
 enum ib_wr_opcode {
-       IB_WR_RDMA_WRITE,
-       IB_WR_RDMA_WRITE_WITH_IMM,
-       IB_WR_SEND,
-       IB_WR_SEND_WITH_IMM,
-       IB_WR_RDMA_READ,
-       IB_WR_ATOMIC_CMP_AND_SWP,
-       IB_WR_ATOMIC_FETCH_AND_ADD,
-       IB_WR_LSO,
-       IB_WR_SEND_WITH_INV,
-       IB_WR_RDMA_READ_WITH_INV,
-       IB_WR_LOCAL_INV,
-       IB_WR_REG_MR,
-       IB_WR_MASKED_ATOMIC_CMP_AND_SWP,
-       IB_WR_MASKED_ATOMIC_FETCH_AND_ADD,
+       /* These are shared with userspace */
+       IB_WR_RDMA_WRITE = IB_UVERBS_WR_RDMA_WRITE,
+       IB_WR_RDMA_WRITE_WITH_IMM = IB_UVERBS_WR_RDMA_WRITE_WITH_IMM,
+       IB_WR_SEND = IB_UVERBS_WR_SEND,
+       IB_WR_SEND_WITH_IMM = IB_UVERBS_WR_SEND_WITH_IMM,
+       IB_WR_RDMA_READ = IB_UVERBS_WR_RDMA_READ,
+       IB_WR_ATOMIC_CMP_AND_SWP = IB_UVERBS_WR_ATOMIC_CMP_AND_SWP,
+       IB_WR_ATOMIC_FETCH_AND_ADD = IB_UVERBS_WR_ATOMIC_FETCH_AND_ADD,
+       IB_WR_LSO = IB_UVERBS_WR_TSO,
+       IB_WR_SEND_WITH_INV = IB_UVERBS_WR_SEND_WITH_INV,
+       IB_WR_RDMA_READ_WITH_INV = IB_UVERBS_WR_RDMA_READ_WITH_INV,
+       IB_WR_LOCAL_INV = IB_UVERBS_WR_LOCAL_INV,
+       IB_WR_MASKED_ATOMIC_CMP_AND_SWP =
+               IB_UVERBS_WR_MASKED_ATOMIC_CMP_AND_SWP,
+       IB_WR_MASKED_ATOMIC_FETCH_AND_ADD =
+               IB_UVERBS_WR_MASKED_ATOMIC_FETCH_AND_ADD,
+
+       /* These are kernel only and can not be issued by userspace */
+       IB_WR_REG_MR = 0x20,
        IB_WR_REG_SIG_MR,
+
        /* reserve values for low level drivers' internal use.
         * These values will not be used at all in the ib core layer.
         */
index e0e83a105953ae1ef3df080cf54ae1619884c11c..e11b4def8630fc36fea507c86bcf211334bd5888 100644 (file)
@@ -751,10 +751,28 @@ struct ib_uverbs_sge {
        __u32 lkey;
 };
 
+enum ib_uverbs_wr_opcode {
+       IB_UVERBS_WR_RDMA_WRITE = 0,
+       IB_UVERBS_WR_RDMA_WRITE_WITH_IMM = 1,
+       IB_UVERBS_WR_SEND = 2,
+       IB_UVERBS_WR_SEND_WITH_IMM = 3,
+       IB_UVERBS_WR_RDMA_READ = 4,
+       IB_UVERBS_WR_ATOMIC_CMP_AND_SWP = 5,
+       IB_UVERBS_WR_ATOMIC_FETCH_AND_ADD = 6,
+       IB_UVERBS_WR_LOCAL_INV = 7,
+       IB_UVERBS_WR_BIND_MW = 8,
+       IB_UVERBS_WR_SEND_WITH_INV = 9,
+       IB_UVERBS_WR_TSO = 10,
+       IB_UVERBS_WR_RDMA_READ_WITH_INV = 11,
+       IB_UVERBS_WR_MASKED_ATOMIC_CMP_AND_SWP = 12,
+       IB_UVERBS_WR_MASKED_ATOMIC_FETCH_AND_ADD = 13,
+       /* Review enum ib_wr_opcode before modifying this */
+};
+
 struct ib_uverbs_send_wr {
        __u64 wr_id;
        __u32 num_sge;
-       __u32 opcode;
+       __u32 opcode;           /* see enum ib_uverbs_wr_opcode */
        __u32 send_flags;
        union {
                __u32 imm_data;