Skip to content

Commit d2fce8a

Browse files
ogerlitzdavem330
authored andcommitted
mlx4: Set user-space raw Ethernet QPs to properly handle VXLAN traffic
Raw Ethernet QPs opened from user-space lack the proper setup to recieve/handle VXLAN traffic when VXLAN offloads are enabled. Fix that by adding a tunnel steering rule on top of the normal unicast steering rule and set the tunnel_type field in the QP context. Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b95089d commit d2fce8a

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

drivers/infiniband/hw/mlx4/main.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,30 @@ static int __mlx4_ib_destroy_flow(struct mlx4_dev *dev, u64 reg_id)
10891089
return err;
10901090
}
10911091

1092+
static int mlx4_ib_tunnel_steer_add(struct ib_qp *qp, struct ib_flow_attr *flow_attr,
1093+
u64 *reg_id)
1094+
{
1095+
void *ib_flow;
1096+
union ib_flow_spec *ib_spec;
1097+
struct mlx4_dev *dev = to_mdev(qp->device)->dev;
1098+
int err = 0;
1099+
1100+
if (dev->caps.tunnel_offload_mode != MLX4_TUNNEL_OFFLOAD_MODE_VXLAN)
1101+
return 0; /* do nothing */
1102+
1103+
ib_flow = flow_attr + 1;
1104+
ib_spec = (union ib_flow_spec *)ib_flow;
1105+
1106+
if (ib_spec->type != IB_FLOW_SPEC_ETH || flow_attr->num_of_specs != 1)
1107+
return 0; /* do nothing */
1108+
1109+
err = mlx4_tunnel_steer_add(to_mdev(qp->device)->dev, ib_spec->eth.val.dst_mac,
1110+
flow_attr->port, qp->qp_num,
1111+
MLX4_DOMAIN_UVERBS | (flow_attr->priority & 0xff),
1112+
reg_id);
1113+
return err;
1114+
}
1115+
10921116
static struct ib_flow *mlx4_ib_create_flow(struct ib_qp *qp,
10931117
struct ib_flow_attr *flow_attr,
10941118
int domain)
@@ -1136,6 +1160,12 @@ static struct ib_flow *mlx4_ib_create_flow(struct ib_qp *qp,
11361160
i++;
11371161
}
11381162

1163+
if (i < ARRAY_SIZE(type) && flow_attr->type == IB_FLOW_ATTR_NORMAL) {
1164+
err = mlx4_ib_tunnel_steer_add(qp, flow_attr, &mflow->reg_id[i]);
1165+
if (err)
1166+
goto err_free;
1167+
}
1168+
11391169
return &mflow->ibflow;
11401170

11411171
err_free:

drivers/infiniband/hw/mlx4/qp.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1677,9 +1677,15 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
16771677
}
16781678
}
16791679

1680-
if (qp->ibqp.qp_type == IB_QPT_RAW_PACKET)
1680+
if (qp->ibqp.qp_type == IB_QPT_RAW_PACKET) {
16811681
context->pri_path.ackto = (context->pri_path.ackto & 0xf8) |
16821682
MLX4_IB_LINK_TYPE_ETH;
1683+
if (dev->dev->caps.tunnel_offload_mode == MLX4_TUNNEL_OFFLOAD_MODE_VXLAN) {
1684+
/* set QP to receive both tunneled & non-tunneled packets */
1685+
if (!(context->flags & (1 << MLX4_RSS_QPC_FLAG_OFFSET)))
1686+
context->srqn = cpu_to_be32(7 << 28);
1687+
}
1688+
}
16831689

16841690
if (ibqp->qp_type == IB_QPT_UD && (new_state == IB_QPS_RTR)) {
16851691
int is_eth = rdma_port_get_link_layer(

0 commit comments

Comments
 (0)