Skip to content

Commit 10b1c04

Browse files
Jack Morgensteindavem330
authored andcommitted
net/mlx4_core: Fix raw qp flow steering rules under SRIOV
Demoting simple flow steering rule priority (for DPDK) was achieved by wrapping FW commands MLX4_QP_FLOW_STEERING_ATTACH/DETACH for the PF as well, and forcing the priority to MLX4_DOMAIN_NIC in the wrapper function for the PF and all VFs. In function mlx4_ib_create_flow(), this change caused the main rule creation for the PF to be wrapped, while it left the associated tunnel steering rule creation unwrapped for the PF. This mismatch caused rule deletion failures in mlx4_ib_destroy_flow() for the PF when the detach wrapper function did not find the associated tunnel-steering rule (since creation of that rule for the PF did not go through the wrapper function). Fix this by setting MLX4_QP_FLOW_STEERING_ATTACH/DETACH to be "native" (so that the PF invocation does not go through the wrapper), and perform the required priority demotion for the PF in the mlx4_ib_create_flow() code path. Fixes: 4856413 ("net/mlx4_core: Demote simple multicast and broadcast flow steering rules") Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il> Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 61b6034 commit 10b1c04

File tree

4 files changed

+33
-23
lines changed

4 files changed

+33
-23
lines changed

drivers/infiniband/hw/mlx4/main.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,9 +1682,19 @@ static int __mlx4_ib_create_flow(struct ib_qp *qp, struct ib_flow_attr *flow_att
16821682
size += ret;
16831683
}
16841684

1685+
if (mlx4_is_master(mdev->dev) && flow_type == MLX4_FS_REGULAR &&
1686+
flow_attr->num_of_specs == 1) {
1687+
struct _rule_hw *rule_header = (struct _rule_hw *)(ctrl + 1);
1688+
enum ib_flow_spec_type header_spec =
1689+
((union ib_flow_spec *)(flow_attr + 1))->type;
1690+
1691+
if (header_spec == IB_FLOW_SPEC_ETH)
1692+
mlx4_handle_eth_header_mcast_prio(ctrl, rule_header);
1693+
}
1694+
16851695
ret = mlx4_cmd_imm(mdev->dev, mailbox->dma, reg_id, size >> 2, 0,
16861696
MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A,
1687-
MLX4_CMD_WRAPPED);
1697+
MLX4_CMD_NATIVE);
16881698
if (ret == -ENOMEM)
16891699
pr_err("mcg table is full. Fail to register network rule.\n");
16901700
else if (ret == -ENXIO)
@@ -1701,7 +1711,7 @@ static int __mlx4_ib_destroy_flow(struct mlx4_dev *dev, u64 reg_id)
17011711
int err;
17021712
err = mlx4_cmd(dev, reg_id, 0, 0,
17031713
MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A,
1704-
MLX4_CMD_WRAPPED);
1714+
MLX4_CMD_NATIVE);
17051715
if (err)
17061716
pr_err("Fail to detach network rule. registration id = 0x%llx\n",
17071717
reg_id);

drivers/net/ethernet/mellanox/mlx4/main.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <linux/io-mapping.h>
4343
#include <linux/delay.h>
4444
#include <linux/kmod.h>
45+
#include <linux/etherdevice.h>
4546
#include <net/devlink.h>
4647

4748
#include <linux/mlx4/device.h>
@@ -782,6 +783,23 @@ int mlx4_is_slave_active(struct mlx4_dev *dev, int slave)
782783
}
783784
EXPORT_SYMBOL(mlx4_is_slave_active);
784785

786+
void mlx4_handle_eth_header_mcast_prio(struct mlx4_net_trans_rule_hw_ctrl *ctrl,
787+
struct _rule_hw *eth_header)
788+
{
789+
if (is_multicast_ether_addr(eth_header->eth.dst_mac) ||
790+
is_broadcast_ether_addr(eth_header->eth.dst_mac)) {
791+
struct mlx4_net_trans_rule_hw_eth *eth =
792+
(struct mlx4_net_trans_rule_hw_eth *)eth_header;
793+
struct _rule_hw *next_rule = (struct _rule_hw *)(eth + 1);
794+
bool last_rule = next_rule->size == 0 && next_rule->id == 0 &&
795+
next_rule->rsvd == 0;
796+
797+
if (last_rule)
798+
ctrl->prio = cpu_to_be16(MLX4_DOMAIN_NIC);
799+
}
800+
}
801+
EXPORT_SYMBOL(mlx4_handle_eth_header_mcast_prio);
802+
785803
static void slave_adjust_steering_mode(struct mlx4_dev *dev,
786804
struct mlx4_dev_cap *dev_cap,
787805
struct mlx4_init_hca_param *hca_param)

drivers/net/ethernet/mellanox/mlx4/resource_tracker.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4164,22 +4164,6 @@ static int validate_eth_header_mac(int slave, struct _rule_hw *eth_header,
41644164
return 0;
41654165
}
41664166

4167-
static void handle_eth_header_mcast_prio(struct mlx4_net_trans_rule_hw_ctrl *ctrl,
4168-
struct _rule_hw *eth_header)
4169-
{
4170-
if (is_multicast_ether_addr(eth_header->eth.dst_mac) ||
4171-
is_broadcast_ether_addr(eth_header->eth.dst_mac)) {
4172-
struct mlx4_net_trans_rule_hw_eth *eth =
4173-
(struct mlx4_net_trans_rule_hw_eth *)eth_header;
4174-
struct _rule_hw *next_rule = (struct _rule_hw *)(eth + 1);
4175-
bool last_rule = next_rule->size == 0 && next_rule->id == 0 &&
4176-
next_rule->rsvd == 0;
4177-
4178-
if (last_rule)
4179-
ctrl->prio = cpu_to_be16(MLX4_DOMAIN_NIC);
4180-
}
4181-
}
4182-
41834167
/*
41844168
* In case of missing eth header, append eth header with a MAC address
41854169
* assigned to the VF.
@@ -4363,10 +4347,7 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
43634347
header_id = map_hw_to_sw_id(be16_to_cpu(rule_header->id));
43644348

43654349
if (header_id == MLX4_NET_TRANS_RULE_ID_ETH)
4366-
handle_eth_header_mcast_prio(ctrl, rule_header);
4367-
4368-
if (slave == dev->caps.function)
4369-
goto execute;
4350+
mlx4_handle_eth_header_mcast_prio(ctrl, rule_header);
43704351

43714352
switch (header_id) {
43724353
case MLX4_NET_TRANS_RULE_ID_ETH:
@@ -4394,7 +4375,6 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
43944375
goto err_put_qp;
43954376
}
43964377

4397-
execute:
43984378
err = mlx4_cmd_imm(dev, inbox->dma, &vhcr->out_param,
43994379
vhcr->in_modifier, 0,
44004380
MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A,

include/linux/mlx4/device.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,8 @@ int set_phv_bit(struct mlx4_dev *dev, u8 port, int new_val);
13841384
int get_phv_bit(struct mlx4_dev *dev, u8 port, int *phv);
13851385
int mlx4_get_is_vlan_offload_disabled(struct mlx4_dev *dev, u8 port,
13861386
bool *vlan_offload_disabled);
1387+
void mlx4_handle_eth_header_mcast_prio(struct mlx4_net_trans_rule_hw_ctrl *ctrl,
1388+
struct _rule_hw *eth_header);
13871389
int mlx4_find_cached_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *idx);
13881390
int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx);
13891391
int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index);

0 commit comments

Comments
 (0)