From mboxrd@z Thu Jan 1 00:00:00 1970 From: Leon Romanovsky Subject: [PATCH rdma-next 09/31] IB/core: Make sure that PSN does not overflow Date: Tue, 14 Nov 2017 14:51:56 +0200 Message-ID: <20171114125218.20477-10-leon@kernel.org> References: <20171114125218.20477-1-leon@kernel.org> Return-path: In-Reply-To: <20171114125218.20477-1-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> Sender: linux-rdma-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Doug Ledford Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Leon Romanovsky , Majd Dibbiny , Daniel Jurgens List-Id: linux-rdma@vger.kernel.org From: Majd Dibbiny The rq/sq->psn is 24 bits as defined in the IB spec,therefore we mask out the 8 most significant bits to avoid overflow in modify qp. Signed-off-by: Majd Dibbiny Signed-off-by: Daniel Jurgens Reviewed-by: Parav Pandit Signed-off-by: Leon Romanovsky --- drivers/infiniband/core/verbs.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index 75ebd74f8bbd..584b6029cb44 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -1321,6 +1321,7 @@ static int ib_resolve_eth_dmac(struct ib_device *device, int ib_modify_qp_with_udata(struct ib_qp *qp, struct ib_qp_attr *attr, int attr_mask, struct ib_udata *udata) { + u8 port = attr_mask & IB_QP_PORT ? attr->port_num : qp->port; int ret; if (attr_mask & IB_QP_AV) { @@ -1328,6 +1329,21 @@ int ib_modify_qp_with_udata(struct ib_qp *qp, struct ib_qp_attr *attr, if (ret) return ret; } + + if (rdma_ib_or_roce(qp->device, port)) { + if (attr_mask & IB_QP_RQ_PSN && attr->rq_psn & ~0xffffff) { + pr_warn("%s: %s rq_psn overflow, masking to 24 bits\n", + __func__, qp->device->name); + attr->rq_psn &= 0xffffff; + } + + if (attr_mask & IB_QP_SQ_PSN && attr->sq_psn & ~0xffffff) { + pr_warn("%s: %s sq_psn overflow, masking to 24 bits\n", + __func__, qp->device->name); + attr->sq_psn &= 0xffffff; + } + } + ret = ib_security_modify_qp(qp, attr, attr_mask, udata); if (!ret && (attr_mask & IB_QP_PORT)) qp->port = attr->port_num; -- 2.15.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html