Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1487505

[PATCH V2 for-next 14/19] IB/hns: Validate mtu when modified qp

From Salil Mehta <salil.mehta@huawei.com>
Newsgroups linux.kernel
Subject [PATCH V2 for-next 14/19] IB/hns: Validate mtu when modified qp
Date 2016-09-20 18:20 +0200
Message-ID <sjvW2-5lT-45@gated-at.bofh.it> (permalink)
References <sjvMm-5fH-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Lijun Ou <oulijun@huawei.com>

The mtu should be validated when modify qp,so we check it.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Peter Chen <luck.chen@huawei.com>
Reviewed-by:  Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
PATCH V2: Addressed Leon Romanovsky's comments
          Link: https://lkml.org/lkml/2016/9/13/39
PATCH V1: Initial Submit
---
 drivers/infiniband/hw/hns/hns_roce_qp.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c
index dd1b214..6a38909 100644
--- a/drivers/infiniband/hw/hns/hns_roce_qp.c
+++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
@@ -32,6 +32,7 @@
  */
 
 #include <linux/platform_device.h>
+#include <rdma/ib_addr.h>
 #include <rdma/ib_umem.h>
 #include "hns_roce_common.h"
 #include "hns_roce_device.h"
@@ -657,6 +658,7 @@ int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 	struct device *dev = &hr_dev->pdev->dev;
 	int ret = -EINVAL;
 	int p;
+	enum ib_mtu active_mtu;
 
 	mutex_lock(&hr_qp->mutex);
 
@@ -687,6 +689,19 @@ int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 		}
 	}
 
+	if (attr_mask & IB_QP_PATH_MTU) {
+		p = attr_mask & IB_QP_PORT ? (attr->port_num - 1) : hr_qp->port;
+		active_mtu = iboe_get_mtu(hr_dev->iboe.netdevs[p]->mtu);
+
+		if (attr->path_mtu > IB_MTU_2048 ||
+		    attr->path_mtu < IB_MTU_256 ||
+		    attr->path_mtu > active_mtu) {
+			dev_err(dev, "attr path_mtu(%d)invalid while modify qp",
+				attr->path_mtu);
+			goto out;
+		}
+	}
+
 	if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC &&
 	    attr->max_rd_atomic > hr_dev->caps.max_qp_init_rdma) {
 		dev_err(dev, "attr max_rd_atomic invalid.attr->max_rd_atomic=%d\n",
-- 
1.9.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH V2 for-next 00/19] IB/hns: Fixes for various misc. bugs Salil Mehta <salil.mehta@huawei.com> - 2016-09-20 18:10 +0200
  [PATCH V2 for-next 05/19] IB/hns: Remove unused parameter named qp_type Salil Mehta <salil.mehta@huawei.com> - 2016-09-20 18:10 +0200
  [PATCH V2 for-next 03/19] IB/hns: Fix bug of using uninit refcount and free Salil Mehta <salil.mehta@huawei.com> - 2016-09-20 18:10 +0200
  [PATCH V2 for-next 06/19] IB/hns: Fix bug of clear hem Salil Mehta <salil.mehta@huawei.com> - 2016-09-20 18:10 +0200
  [PATCH V2 for-next 11/19] IB/hns: Return bad wr while post send failed Salil Mehta <salil.mehta@huawei.com> - 2016-09-20 18:20 +0200
  [PATCH V2 for-next 13/19] IB/hns: Some items of qpc need to take user param Salil Mehta <salil.mehta@huawei.com> - 2016-09-20 18:20 +0200
  [PATCH V2 for-next 17/19] IB/hns: Fix the bug when platform_get_resource() exec fail Salil Mehta <salil.mehta@huawei.com> - 2016-09-20 18:20 +0200
  [PATCH V2 for-next 18/19] IB/hns: Delete the redundant lines in hns_roce_v1_m_qp() Salil Mehta <salil.mehta@huawei.com> - 2016-09-20 18:20 +0200
  [PATCH V2 for-next 12/19] IB/hns: The Ack timeout need a lower limit value Salil Mehta <salil.mehta@huawei.com> - 2016-09-20 18:20 +0200
  [PATCH V2 for-next 16/19] IB/hns: Update the rq head when modify qp state Salil Mehta <salil.mehta@huawei.com> - 2016-09-20 18:20 +0200
  [PATCH V2 for-next 10/19] IB/hns: Fix bug of memory leakage for registering user mr Salil Mehta <salil.mehta@huawei.com> - 2016-09-20 18:20 +0200
  [PATCH V2 for-next 02/19] IB/hns: Remove parameters of resize cq Salil Mehta <salil.mehta@huawei.com> - 2016-09-20 18:20 +0200
  [PATCH V2 for-next 01/19] IB/hns: Remove unused parameters in some functions Salil Mehta <salil.mehta@huawei.com> - 2016-09-20 18:20 +0200
  [PATCH V2 for-next 19/19] IB/hns: Fix for removal of redundant code Salil Mehta <salil.mehta@huawei.com> - 2016-09-20 18:20 +0200
  [PATCH V2 for-next 15/19] IB/hns: Cq has not been freed Salil Mehta <salil.mehta@huawei.com> - 2016-09-20 18:20 +0200
  [PATCH V2 for-next 14/19] IB/hns: Validate mtu when modified qp Salil Mehta <salil.mehta@huawei.com> - 2016-09-20 18:20 +0200
  Re: [PATCH V2 for-next 00/19] IB/hns: Fixes for various misc. bugs Leon Romanovsky <leon@kernel.org> - 2016-09-22 15:40 +0200

csiph-web