aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core
diff options
context:
space:
mode:
authorArtemy Kovalyov <artemyko@mellanox.com>2018-07-04 15:57:50 +0300
committerJason Gunthorpe <jgg@mellanox.com>2018-07-10 11:13:04 -0600
commitb02289b3d60f79ba0831051a7743d8fdb4110355 (patch)
treeab40813ac166eb65344774f68d18d8bf313a076d /drivers/infiniband/core
parentRDMA/hfi1: Move grh_required into update_sm_ah (diff)
downloadlinux-dev-b02289b3d60f79ba0831051a7743d8fdb4110355.tar.xz
linux-dev-b02289b3d60f79ba0831051a7743d8fdb4110355.zip
RDMA: Validate grh_required when handling AVs
Extend the existing grh_required flag to check when AV's are handled that a GRH is present. Since we don't want to do query_port during the AV checks for performance reasons move the flag into the immutable_data. Signed-off-by: Artemy Kovalyov <artemyko@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband/core')
-rw-r--r--drivers/infiniband/core/sa_query.c8
-rw-r--r--drivers/infiniband/core/verbs.c3
2 files changed, 8 insertions, 3 deletions
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index fdfdbb2bea7a..7b794a14d6e8 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -2276,6 +2276,7 @@ static void update_sm_ah(struct work_struct *work)
struct ib_sa_sm_ah *new_ah;
struct ib_port_attr port_attr;
struct rdma_ah_attr ah_attr;
+ bool grh_required;
if (ib_query_port(port->agent->device, port->port_num, &port_attr)) {
pr_warn("Couldn't query port\n");
@@ -2301,6 +2302,9 @@ static void update_sm_ah(struct work_struct *work)
rdma_ah_set_sl(&ah_attr, port_attr.sm_sl);
rdma_ah_set_port_num(&ah_attr, port->port_num);
+ grh_required = rdma_is_grh_required(port->agent->device,
+ port->port_num);
+
/*
* The OPA sm_lid of 0xFFFF needs special handling so that it can be
* differentiated from a permissive LID of 0xFFFF. We set the
@@ -2308,11 +2312,11 @@ static void update_sm_ah(struct work_struct *work)
* address handle appropriately
*/
if (ah_attr.type == RDMA_AH_ATTR_TYPE_OPA &&
- (port_attr.grh_required ||
+ (grh_required ||
port_attr.sm_lid == be16_to_cpu(IB_LID_PERMISSIVE)))
rdma_ah_set_make_grd(&ah_attr, true);
- if (ah_attr.type == RDMA_AH_ATTR_TYPE_IB && port_attr.grh_required) {
+ if (ah_attr.type == RDMA_AH_ATTR_TYPE_IB && grh_required) {
rdma_ah_set_ah_flags(&ah_attr, IB_AH_GRH);
rdma_ah_set_subnet_prefix(&ah_attr,
cpu_to_be64(port_attr.subnet_prefix));
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 1bb6b6ff3341..b6ceb6fd6a67 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -390,7 +390,8 @@ static int rdma_check_ah_attr(struct ib_device *device,
if (!rdma_is_port_valid(device, ah_attr->port_num))
return -EINVAL;
- if (ah_attr->type == RDMA_AH_ATTR_TYPE_ROCE &&
+ if ((rdma_is_grh_required(device, ah_attr->port_num) ||
+ ah_attr->type == RDMA_AH_ATTR_TYPE_ROCE) &&
!(ah_attr->ah_flags & IB_AH_GRH))
return -EINVAL;