RDMA/rxe: Fix mismatched max_msg_sz
authorzhenwei pi <pizhenwei@bytedance.com>
Mon, 16 Dec 2024 12:19:53 +0000 (20:19 +0800)
committerLeon Romanovsky <leon@kernel.org>
Tue, 17 Dec 2024 14:35:33 +0000 (09:35 -0500)
User mode queries max_msg_sz as 0x800000 by command 'ibv_devinfo -v',
however ibv_post_send/ibv_post_recv has a limit of 2^31. Fix this
mismatched information.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Fixes: f605f26ea196 ("RDMA/rxe: Protect QP state with qp->state_lock")
Fixes: 5bf944f24129 ("RDMA/rxe: Add error messages")
Link: https://patch.msgid.link/20241216121953.765331-1-pizhenwei@bytedance.com
Review-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/sw/rxe/rxe_param.h
drivers/infiniband/sw/rxe/rxe_verbs.c

index d2f57ead78ad12d9328520c38289a21b7fe9906e..003f681e5dc022c62e3da9c6325e612afbefb1ff 100644 (file)
@@ -129,7 +129,7 @@ enum rxe_device_param {
 enum rxe_port_param {
        RXE_PORT_GID_TBL_LEN            = 1024,
        RXE_PORT_PORT_CAP_FLAGS         = IB_PORT_CM_SUP,
-       RXE_PORT_MAX_MSG_SZ             = 0x800000,
+       RXE_PORT_MAX_MSG_SZ             = (1UL << 31),
        RXE_PORT_BAD_PKEY_CNTR          = 0,
        RXE_PORT_QKEY_VIOL_CNTR         = 0,
        RXE_PORT_LID                    = 0,
index 5c18f7e342f29400369758a43c0d09a92e9e01ae..ffd5b07ad3e6ce4c1a78c1fe95b8076eb0ac2bc6 100644 (file)
@@ -688,7 +688,7 @@ static int validate_send_wr(struct rxe_qp *qp, const struct ib_send_wr *ibwr,
                for (i = 0; i < ibwr->num_sge; i++)
                        length += ibwr->sg_list[i].length;
 
-               if (length > (1UL << 31)) {
+               if (length > RXE_PORT_MAX_MSG_SZ) {
                        rxe_err_qp(qp, "message length too long\n");
                        break;
                }
@@ -972,8 +972,7 @@ static int post_one_recv(struct rxe_rq *rq, const struct ib_recv_wr *ibwr)
        for (i = 0; i < num_sge; i++)
                length += ibwr->sg_list[i].length;
 
-       /* IBA max message size is 2^31 */
-       if (length >= (1UL<<31)) {
+       if (length > RXE_PORT_MAX_MSG_SZ) {
                err = -EINVAL;
                rxe_dbg("message length too long\n");
                goto err_out;