mlx5 updates 2022-01-10
Subsystems (5)
From: Saeed Mahameed <[email protected]>
Hi Dave, Hi Jakub,
This series is mostly refactoring and code improvements in mlx5. For more information please see tag log below.
Please pull and let me know if there is any problem.
Thanks,
Saeed.
PATCH 1/17 net/mlx5: Remove unused TIR modify bitmask enums
From: Tariq Toukan <[email protected]>
struct mlx5_ifc_modify_tir_bitmask_bits is used for the bitmask of MODIFY_TIR operations.
Remove the unused bitmask enums.
--- include/linux/mlx5/mlx5_ifc.h | 7 ------- 1 file changed, 7 deletions(-)
include/linux/mlx5/mlx5_ifc.h +0 -7
@@ -63,13 +63,6 @@ enum {MLX5_EVENT_TYPE_CODING_FPGA_QP_ERROR =0x21 }; -enum { -MLX5_MODIFY_TIR_BITMASK_LRO =0x0 , -MLX5_MODIFY_TIR_BITMASK_INDIRECT_TABLE =0x1 , -MLX5_MODIFY_TIR_BITMASK_HASH =0x2 , -MLX5_MODIFY_TIR_BITMASK_TUNNELED_OFFLOAD_EN =0x3 -}; -enum {MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE =0x0 ,MLX5_SET_HCA_CAP_OP_MOD_ODP =0x2 ,
Signature · 1 line
2.34.1
PATCH 2/17 net/mlx5e: Move code chunk setting encap dests into its own function
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Split setting encap dests code chunk out of mlx5e_tc_add_fdb_flow() to make the function smaller for maintainability and reuse. For symmetry do the same for mlx5e_tc_del_fdb_flow(). While at it refactor cleanup to first check for encap flag like done when setting encap dests.
--- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 144 +++++++++++------- 1 file changed, 93 insertions(+), 51 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +93 -51
@@ -1367,6 +1367,94 @@ int mlx5e_tc_add_flow_mod_hdr(struct mlx5e_priv *priv,return 0 ; } +static int +set_encap_dests (struct mlx5e_priv *priv, +struct mlx5e_tc_flow *flow, +struct netlink_ext_ack *extack, +bool *encap_valid, +bool *vf_tun) +{ +struct mlx5e_tc_flow_parse_attr *parse_attr; +struct mlx5_flow_attr *attr = flow->attr; +struct mlx5_esw_flow_attr *esw_attr; +struct net_device *encap_dev =NULL ; +struct mlx5e_rep_priv *rpriv; +struct mlx5e_priv *out_priv; +int out_index; +int err =0 ; + + parse_attr = attr->parse_attr; + esw_attr = attr->esw_attr; + *vf_tun = false; + *encap_valid = true; + +for (out_index =0 ; out_index <MLX5_MAX_FLOW_FWD_VPORTS ; out_index++) { +struct net_device *out_dev; +int mirred_ifindex; + +if (!(esw_attr->dests[out_index].flags &MLX5_ESW_DEST_ENCAP )) +continue ; + + mirred_ifindex = parse_attr->mirred_ifindex[out_index]; + out_dev =dev_get_by_index (dev_net (priv->netdev), mirred_ifindex); +if (!out_dev) { +NL_SET_ERR_MSG_MOD (extack,"Requested mirred device not found" ); + err = -ENODEV ; + goto out; + } + err =mlx5e_attach_encap (priv, flow, out_dev, out_index, + extack, &encap_dev, encap_valid); +dev_put (out_dev); +if (err) + goto out; + +if (esw_attr->dests[out_index].flags & +MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE && + !esw_attr->dest_int_port) + *vf_tun = true; + + out_priv =netdev_priv (encap_dev); + rpriv = out_priv->ppriv; + esw_attr->dests[out_index].rep = rpriv->rep; + esw_attr->dests[out_index].mdev = out_priv->mdev; + } + +if (*vf_tun && esw_attr->out_count >1 ) { +NL_SET_ERR_MSG_MOD (extack,"VF tunnel encap with mirroring is not supported" ); + err = -EOPNOTSUPP ; + goto out; + } + +out: +return err; +} + +static void +clean_encap_dests (struct mlx5e_priv *priv, +struct mlx5e_tc_flow *flow, +bool *vf_tun) +{ +struct mlx5_flow_attr *attr = flow->attr; +struct mlx5_esw_flow_attr *esw_attr; +int out_index; + + esw_attr = attr->esw_attr; + *vf_tun = false; + +for (out_index =0 ; out_index <MLX5_MAX_FLOW_FWD_VPORTS ; out_index++) { +if (!(esw_attr->dests[out_index].flags &MLX5_ESW_DEST_ENCAP )) +continue ; + +if (esw_attr->dests[out_index].flags & +MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE && + !esw_attr->dest_int_port) + *vf_tun = true; + +mlx5e_detach_encap (priv, flow, out_index); +kfree (attr->parse_attr->tun_info[out_index]); + } +} + static int mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv, struct mlx5e_tc_flow *flow,
@@ -1375,15 +1463,11 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;struct mlx5e_tc_flow_parse_attr *parse_attr;struct mlx5_flow_attr *attr = flow->attr; -bool vf_tun = false, encap_valid = true; -struct net_device *encap_dev =NULL ;struct mlx5_esw_flow_attr *esw_attr; -struct mlx5e_rep_priv *rpriv; -struct mlx5e_priv *out_priv; +bool vf_tun, encap_valid;struct mlx5_fc *counter;u32 max_prio, max_chain;int err =0 ; -int out_index; parse_attr = attr->parse_attr; esw_attr = attr->esw_attr;
@@ -1471,41 +1555,9 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv, esw_attr->int_port = int_port; } -for (out_index =0 ; out_index <MLX5_MAX_FLOW_FWD_VPORTS ; out_index++) { -struct net_device *out_dev; -int mirred_ifindex; - -if (!(esw_attr->dests[out_index].flags &MLX5_ESW_DEST_ENCAP )) -continue ; - - mirred_ifindex = parse_attr->mirred_ifindex[out_index]; - out_dev =dev_get_by_index (dev_net (priv->netdev), mirred_ifindex); -if (!out_dev) { -NL_SET_ERR_MSG_MOD (extack,"Requested mirred device not found" ); - err = -ENODEV ; - goto err_out; - } - err =mlx5e_attach_encap (priv, flow, out_dev, out_index, - extack, &encap_dev, &encap_valid); -dev_put (out_dev); -if (err) - goto err_out; - -if (esw_attr->dests[out_index].flags & -MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE && - !esw_attr->dest_int_port) - vf_tun = true; - out_priv =netdev_priv (encap_dev); - rpriv = out_priv->ppriv; - esw_attr->dests[out_index].rep = rpriv->rep; - esw_attr->dests[out_index].mdev = out_priv->mdev; - } - -if (vf_tun && esw_attr->out_count >1 ) { -NL_SET_ERR_MSG_MOD (extack,"VF tunnel encap with mirroring is not supported" ); - err = -EOPNOTSUPP ; + err =set_encap_dests (priv, flow, extack, &encap_valid, &vf_tun); +if (err) goto err_out; - } err =mlx5_eswitch_add_vlan_action (esw, attr);if (err)
@@ -1575,8 +1627,7 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;struct mlx5_flow_attr *attr = flow->attr;struct mlx5_esw_flow_attr *esw_attr; -bool vf_tun = false; -int out_index; +bool vf_tun; esw_attr = attr->esw_attr;mlx5e_put_flow_tunnel_id (flow);
@@ -1600,16 +1651,7 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,if (flow->decap_route)mlx5e_detach_decap_route (priv, flow); -for (out_index =0 ; out_index <MLX5_MAX_FLOW_FWD_VPORTS ; out_index++) { -if (esw_attr->dests[out_index].flags & -MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE && - !esw_attr->dest_int_port) - vf_tun = true; -if (esw_attr->dests[out_index].flags &MLX5_ESW_DEST_ENCAP ) { -mlx5e_detach_encap (priv, flow, out_index); -kfree (attr->parse_attr->tun_info[out_index]); - } - } +clean_encap_dests (priv, flow, &vf_tun);mlx5_tc_ct_match_del (get_ct_priv (priv), &flow->attr->ct_attr);
Signature · 1 line
2.34.1
PATCH 3/17 net/mlx5e: Pass attr arg for attaching/detaching encaps
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
In later commit that we will have multiple attr instances per flow we would like to pass a specific attr instance to set encaps.
Currently the mlx5_flow object contains a single mlx5_attr instance. However, multi table actions (e.g. CT) instantiate multiple attr instances.
Currently mlx5e_attach/detach_encap() reads the first attr instance from the flow instance. Modify the functions to receive the attr instance as a parameter which is set by the calling function.
--- .../ethernet/mellanox/mlx5/core/en/tc_tun_encap.c | 15 +++++++++------ .../ethernet/mellanox/mlx5/core/en/tc_tun_encap.h | 6 +++++- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 12 ++++++------ 3 files changed, 20 insertions(+), 13 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c +9 -6
@@ -488,12 +488,14 @@ static void mlx5e_detach_encap_route(struct mlx5e_priv *priv, int out_index);void mlx5e_detach_encap (struct mlx5e_priv *priv, -struct mlx5e_tc_flow *flow,int out_index) +struct mlx5e_tc_flow *flow, +struct mlx5_flow_attr *attr, +int out_index) {struct mlx5e_encap_entry *e = flow->encaps[out_index].e;struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; -if (flow->attr->esw_attr->dests[out_index].flags & +if (attr->esw_attr->dests[out_index].flags &MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE )mlx5e_detach_encap_route (priv, flow, out_index);
@@ -733,6 +735,7 @@ static unsigned int mlx5e_route_tbl_get_last_update(struct mlx5e_priv *priv) static int mlx5e_attach_encap_route(struct mlx5e_priv *priv, struct mlx5e_tc_flow *flow, + struct mlx5_flow_attr *attr, struct mlx5e_encap_entry *e, bool new_encap_entry, unsigned long tbl_time_before,
@@ -740,6 +743,7 @@ static int mlx5e_attach_encap_route(struct mlx5e_priv *priv, int mlx5e_attach_encap(struct mlx5e_priv *priv, struct mlx5e_tc_flow *flow, + struct mlx5_flow_attr *attr, struct net_device *mirred_dev, int out_index, struct netlink_ext_ack *extack,
@@ -748,7 +752,6 @@ int mlx5e_attach_encap(struct mlx5e_priv *priv, {struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;struct mlx5e_tc_flow_parse_attr *parse_attr; -struct mlx5_flow_attr *attr = flow->attr;const struct ip_tunnel_info *tun_info;unsigned long tbl_time_before =0 ;struct mlx5e_encap_entry *e;
@@ -834,8 +837,8 @@ int mlx5e_attach_encap(struct mlx5e_priv *priv, e->compl_result =1 ; attach_flow: - err =mlx5e_attach_encap_route (priv, flow, e, entry_created, tbl_time_before, - out_index); + err =mlx5e_attach_encap_route (priv, flow, attr, e, entry_created, + tbl_time_before, out_index);if (err) goto out_err;
@@ -1198,6 +1201,7 @@ int mlx5e_attach_decap_route(struct mlx5e_priv *priv, static int mlx5e_attach_encap_route(struct mlx5e_priv *priv, struct mlx5e_tc_flow *flow, + struct mlx5_flow_attr *attr, struct mlx5e_encap_entry *e, bool new_encap_entry, unsigned long tbl_time_before,
@@ -1206,7 +1210,6 @@ static int mlx5e_attach_encap_route(struct mlx5e_priv *priv,struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;unsigned long tbl_time_after = tbl_time_before;struct mlx5e_tc_flow_parse_attr *parse_attr; -struct mlx5_flow_attr *attr = flow->attr;const struct ip_tunnel_info *tun_info;struct mlx5_esw_flow_attr *esw_attr;struct mlx5e_route_entry *r;
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.h +5 -1
@@ -7,15 +7,19 @@#include "tc_priv.h" void mlx5e_detach_encap (struct mlx5e_priv *priv, -struct mlx5e_tc_flow *flow,int out_index); +struct mlx5e_tc_flow *flow, +struct mlx5_flow_attr *attr, +int out_index);int mlx5e_attach_encap (struct mlx5e_priv *priv,struct mlx5e_tc_flow *flow, +struct mlx5_flow_attr *attr,struct net_device *mirred_dev,int out_index,struct netlink_ext_ack *extack,struct net_device **encap_dev,bool *encap_valid); +int mlx5e_attach_decap (struct mlx5e_priv *priv,struct mlx5e_tc_flow *flow,struct netlink_ext_ack *extack);
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +6 -6
@@ -1370,12 +1370,12 @@ int mlx5e_tc_add_flow_mod_hdr(struct mlx5e_priv *priv,static int set_encap_dests (struct mlx5e_priv *priv,struct mlx5e_tc_flow *flow, +struct mlx5_flow_attr *attr,struct netlink_ext_ack *extack,bool *encap_valid,bool *vf_tun) {struct mlx5e_tc_flow_parse_attr *parse_attr; -struct mlx5_flow_attr *attr = flow->attr;struct mlx5_esw_flow_attr *esw_attr;struct net_device *encap_dev =NULL ;struct mlx5e_rep_priv *rpriv;
@@ -1402,7 +1402,7 @@ set_encap_dests(struct mlx5e_priv *priv, err = -ENODEV ; goto out; } - err =mlx5e_attach_encap (priv, flow, out_dev, out_index, + err =mlx5e_attach_encap (priv, flow, attr, out_dev, out_index, extack, &encap_dev, encap_valid);dev_put (out_dev);if (err)
@@ -1432,9 +1432,9 @@ set_encap_dests(struct mlx5e_priv *priv,static void clean_encap_dests (struct mlx5e_priv *priv,struct mlx5e_tc_flow *flow, +struct mlx5_flow_attr *attr,bool *vf_tun) { -struct mlx5_flow_attr *attr = flow->attr;struct mlx5_esw_flow_attr *esw_attr;int out_index;
@@ -1450,7 +1450,7 @@ clean_encap_dests(struct mlx5e_priv *priv, !esw_attr->dest_int_port) *vf_tun = true; -mlx5e_detach_encap (priv, flow, out_index); +mlx5e_detach_encap (priv, flow, attr, out_index);kfree (attr->parse_attr->tun_info[out_index]); } }
@@ -1555,7 +1555,7 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv, esw_attr->int_port = int_port; } - err =set_encap_dests (priv, flow, extack, &encap_valid, &vf_tun); + err =set_encap_dests (priv, flow, attr, extack, &encap_valid, &vf_tun);if (err) goto err_out;
@@ -1651,7 +1651,7 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,if (flow->decap_route)mlx5e_detach_decap_route (priv, flow); -clean_encap_dests (priv, flow, &vf_tun); +clean_encap_dests (priv, flow, attr, &vf_tun);mlx5_tc_ct_match_del (get_ct_priv (priv), &flow->attr->ct_attr);
Signature · 1 line
2.34.1
PATCH 4/17 net/mlx5e: Move counter creation call to alloc_flow_attr_counter()
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Move shared code to alloc_flow_attr_counter() for reuse by the next patches.
--- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +20 -13
@@ -1038,6 +1038,21 @@ mlx5e_add_offloaded_nic_rule(struct mlx5e_priv *priv,return ERR_CAST (rule); } +static int +alloc_flow_attr_counter (struct mlx5_core_dev *counter_dev, +struct mlx5_flow_attr *attr) + +{ +struct mlx5_fc *counter; + + counter =mlx5_fc_create (counter_dev, true); +if (IS_ERR (counter)) +return PTR_ERR (counter); + + attr->counter = counter; +return 0 ; +} + static int mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv, struct mlx5e_tc_flow *flow,
@@ -1046,7 +1061,6 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv,struct mlx5e_tc_flow_parse_attr *parse_attr;struct mlx5_flow_attr *attr = flow->attr;struct mlx5_core_dev *dev = priv->mdev; -struct mlx5_fc *counter;int err; parse_attr = attr->parse_attr;
@@ -1058,11 +1072,9 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv, }if (attr->action &MLX5_FLOW_CONTEXT_ACTION_COUNT ) { - counter =mlx5_fc_create (dev, true); -if (IS_ERR (counter)) -return PTR_ERR (counter); - - attr->counter = counter; + err =alloc_flow_attr_counter (dev, attr); +if (err) +return err; }if (attr->action &MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ) {
@@ -1465,7 +1477,6 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,struct mlx5_flow_attr *attr = flow->attr;struct mlx5_esw_flow_attr *esw_attr;bool vf_tun, encap_valid; -struct mlx5_fc *counter;u32 max_prio, max_chain;int err =0 ;
@@ -1577,13 +1588,9 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv, }if (attr->action &MLX5_FLOW_CONTEXT_ACTION_COUNT ) { - counter =mlx5_fc_create (esw_attr->counter_dev, true); -if (IS_ERR (counter)) { - err =PTR_ERR (counter); + err =alloc_flow_attr_counter (esw_attr->counter_dev, attr); +if (err) goto err_out; - } - - attr->counter = counter; }/* we get here if one of the following takes place:
Signature · 1 line
2.34.1
PATCH 5/17 net/mlx5e: TC, Move pedit_headers_action to parse_attr
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Move pedit_headers_action from flow parse_state to flow parse_attr. In a follow up commit we are going to have multiple attr per flow and pedit_headers_action are unique per attr.
--- .../mellanox/mlx5/core/en/tc/act/act.h | 1 - .../mellanox/mlx5/core/en/tc/act/pedit.c | 8 +++--- .../mellanox/mlx5/core/en/tc/act/pedit.h | 1 - .../mellanox/mlx5/core/en/tc/act/vlan.c | 10 +++----- .../mellanox/mlx5/core/en/tc/act/vlan.h | 1 - .../mlx5/core/en/tc/act/vlan_mangle.c | 6 ++--- .../ethernet/mellanox/mlx5/core/en/tc_priv.h | 1 + .../net/ethernet/mellanox/mlx5/core/en_tc.c | 25 +++++++------------ 8 files changed, 19 insertions(+), 34 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +0 -1
@@ -21,7 +21,6 @@ struct mlx5e_tc_act_parse_state {bool mpls_push;bool ptype_host;const struct ip_tunnel_info *tun_info; -struct pedit_headers_action hdrs[__PEDIT_CMD_MAX];int ifindexes[MLX5_MAX_FLOW_FWD_VPORTS ];int if_count;struct mlx5_tc_ct_priv *ct_priv;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.c +3 -5
@@ -46,9 +46,9 @@ static int parse_pedit_to_modify_hdr(struct mlx5e_priv *priv, const struct flow_action_entry *act, int namespace, struct mlx5e_tc_flow_parse_attr *parse_attr, - struct pedit_headers_action *hdrs, struct netlink_ext_ack *extack) { + struct pedit_headers_action *hdrs = parse_attr->hdrs;u8 cmd = (act->id ==FLOW_ACTION_MANGLE ) ?0 :1 ;u8 htype = act->mangle.htype;int err = -EOPNOTSUPP ;
@@ -110,14 +110,13 @@ int mlx5e_tc_act_pedit_parse_action(struct mlx5e_priv *priv, const struct flow_action_entry *act, int namespace, struct mlx5e_tc_flow_parse_attr *parse_attr, - struct pedit_headers_action *hdrs, struct mlx5e_tc_flow *flow, struct netlink_ext_ack *extack) { if (flow && flow_flag_test(flow, L3_TO_L2_DECAP)) return parse_pedit_to_reformat(act, parse_attr, extack); - return parse_pedit_to_modify_hdr(priv, act, namespace, parse_attr, hdrs, extack); + return parse_pedit_to_modify_hdr(priv, act, namespace, parse_attr, extack); } static bool
@@ -141,8 +140,7 @@ tc_act_parse_pedit(struct mlx5e_tc_act_parse_state *parse_state, ns_type =mlx5e_get_flow_namespace (flow); - err =mlx5e_tc_act_pedit_parse_action (flow->priv, act, ns_type, - attr->parse_attr, parse_state->hdrs, + err =mlx5e_tc_act_pedit_parse_action (flow->priv, act, ns_type, attr->parse_attr, flow, parse_state->extack);if (err)return err;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.h +0 -1
@@ -25,7 +25,6 @@ int mlx5e_tc_act_pedit_parse_action(struct mlx5e_priv *priv, const struct flow_action_entry *act, int namespace, struct mlx5e_tc_flow_parse_attr *parse_attr, - struct pedit_headers_action *hdrs, struct mlx5e_tc_flow *flow, struct netlink_ext_ack *extack);
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c +4 -6
@@ -9,7 +9,6 @@static int add_vlan_prio_tag_rewrite_action (struct mlx5e_priv *priv,struct mlx5e_tc_flow_parse_attr *parse_attr, -struct pedit_headers_action *hdrs,u32 *action,struct netlink_ext_ack *extack) {const struct flow_action_entry prio_tag_act = {
@@ -26,7 +25,7 @@ add_vlan_prio_tag_rewrite_action(struct mlx5e_priv *priv, };return mlx5e_tc_act_vlan_add_rewrite_action (priv,MLX5_FLOW_NAMESPACE_FDB , - &prio_tag_act, parse_attr, hdrs, action, + &prio_tag_act, parse_attr, action, extack); }
@@ -170,8 +169,8 @@ tc_act_parse_vlan(struct mlx5e_tc_act_parse_state *parse_state,/* Replace vlan pop+push with vlan modify */ attr->action &= ~MLX5_FLOW_CONTEXT_ACTION_VLAN_POP ; err =mlx5e_tc_act_vlan_add_rewrite_action (priv,MLX5_FLOW_NAMESPACE_FDB , act, - attr->parse_attr, parse_state->hdrs, - &attr->action, parse_state->extack); + attr->parse_attr, &attr->action, + parse_state->extack); }else { err =parse_tc_vlan_action (priv, act, esw_attr, &attr->action, parse_state->extack);
@@ -191,7 +190,6 @@ tc_act_post_parse_vlan(struct mlx5e_tc_act_parse_state *parse_state, struct mlx5_flow_attr *attr) {struct mlx5e_tc_flow_parse_attr *parse_attr = attr->parse_attr; -struct pedit_headers_action *hdrs = parse_state->hdrs;struct netlink_ext_ack *extack = parse_state->extack;struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;int err;
@@ -202,7 +200,7 @@ tc_act_post_parse_vlan(struct mlx5e_tc_act_parse_state *parse_state,* tag rewrite. */ attr->action &= ~MLX5_FLOW_CONTEXT_ACTION_VLAN_POP ; - err =add_vlan_prio_tag_rewrite_action (priv, parse_attr, hdrs, + err =add_vlan_prio_tag_rewrite_action (priv, parse_attr, &attr->action, extack);if (err)return err;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.h +0 -1
@@ -24,7 +24,6 @@ int mlx5e_tc_act_vlan_add_rewrite_action(struct mlx5e_priv *priv, int namespace, const struct flow_action_entry *act, struct mlx5e_tc_flow_parse_attr *parse_attr, - struct pedit_headers_action *hdrs, u32 *action, struct netlink_ext_ack *extack);#endif /* __MLX5_EN_TC_ACT_VLAN_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan_mangle.c +2 -4
@@ -12,7 +12,6 @@ int mlx5e_tc_act_vlan_add_rewrite_action(struct mlx5e_priv *priv, int namespace, const struct flow_action_entry *act, struct mlx5e_tc_flow_parse_attr *parse_attr, - struct pedit_headers_action *hdrs, u32 *action, struct netlink_ext_ack *extack) { u16 mask16 = VLAN_VID_MASK;
@@ -44,7 +43,7 @@ mlx5e_tc_act_vlan_add_rewrite_action(struct mlx5e_priv *priv, int namespace,return -EOPNOTSUPP ; } - err =mlx5e_tc_act_pedit_parse_action (priv, &pedit_act, namespace, parse_attr, hdrs, + err =mlx5e_tc_act_pedit_parse_action (priv, &pedit_act, namespace, parse_attr,NULL , extack); *action |=MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ;
@@ -69,8 +68,7 @@ tc_act_parse_vlan_mangle(struct mlx5e_tc_act_parse_state *parse_state,int err; ns_type =mlx5e_get_flow_namespace (parse_state->flow); - err =mlx5e_tc_act_vlan_add_rewrite_action (priv, ns_type, act, - attr->parse_attr, parse_state->hdrs, + err =mlx5e_tc_act_vlan_add_rewrite_action (priv, ns_type, act, attr->parse_attr, &attr->action, parse_state->extack);if (err)return err;
drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h +1 -0
@@ -37,6 +37,7 @@ struct mlx5e_tc_flow_parse_attr {const struct ip_tunnel_info *tun_info[MLX5_MAX_FLOW_FWD_VPORTS ];struct net_device *filter_dev;struct mlx5_flow_spec spec; +struct pedit_headers_action hdrs[__PEDIT_CMD_MAX];struct mlx5e_tc_mod_hdr_acts mod_hdr_acts;int mirred_ifindex[MLX5_MAX_FLOW_FWD_VPORTS ];struct ethhdr eth;
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +9 -16
@@ -2859,14 +2859,15 @@ static unsigned long mask_to_le(unsigned long mask, int size)return mask; } +static int offload_pedit_fields (struct mlx5e_priv *priv,int namespace, -struct pedit_headers_action *hdrs,struct mlx5e_tc_flow_parse_attr *parse_attr,u32 *action_flags,struct netlink_ext_ack *extack) {struct pedit_headers *set_masks, *add_masks, *set_vals, *add_vals; +struct pedit_headers_action *hdrs = parse_attr->hdrs;void *headers_c, *headers_v, *action, *vals_p;u32 *s_masks_p, *a_masks_p, s_mask, a_mask;struct mlx5e_tc_mod_hdr_acts *mod_acts;
@@ -2994,7 +2995,6 @@ static const struct pedit_headers zero_masks = {};static int alloc_tc_pedit_action (struct mlx5e_priv *priv,int namespace,struct mlx5e_tc_flow_parse_attr *parse_attr, -struct pedit_headers_action *hdrs,u32 *action_flags,struct netlink_ext_ack *extack) {
@@ -3002,16 +3002,14 @@ static int alloc_tc_pedit_action(struct mlx5e_priv *priv, int namespace,int err;u8 cmd; - err =offload_pedit_fields (priv, namespace, hdrs, parse_attr, - action_flags, extack); + err =offload_pedit_fields (priv, namespace, parse_attr, action_flags, extack);if (err <0 ) goto out_dealloc_parsed_actions;for (cmd =0 ; cmd < __PEDIT_CMD_MAX; cmd++) { - cmd_masks = &hdrs[cmd].masks; + cmd_masks = &parse_attr->hdrs[cmd].masks;if (memcmp (cmd_masks, &zero_masks,sizeof (zero_masks))) { -NL_SET_ERR_MSG_MOD (extack, -"attempt to offload an unsupported field" ); +NL_SET_ERR_MSG_MOD (extack,"attempt to offload an unsupported field" );netdev_warn (priv->netdev,"attempt to offload an unsupported field (cmd %d)\n" , cmd);print_hex_dump (KERN_WARNING ,"mask: " ,DUMP_PREFIX_ADDRESS ,16 ,1 , cmd_masks,sizeof (zero_masks), true);
@@ -3319,10 +3317,10 @@ static int actions_prepare_mod_hdr_actions(struct mlx5e_priv *priv, struct mlx5e_tc_flow *flow, struct mlx5_flow_attr *attr, - struct pedit_headers_action *hdrs, struct netlink_ext_ack *extack) { struct mlx5e_tc_flow_parse_attr *parse_attr = attr->parse_attr; +struct pedit_headers_action *hdrs = parse_attr->hdrs;enum mlx5_flow_namespace_type ns_type;int err;
@@ -3332,8 +3330,7 @@ actions_prepare_mod_hdr_actions(struct mlx5e_priv *priv, ns_type =mlx5e_get_flow_namespace (flow); - err =alloc_tc_pedit_action (priv, ns_type, parse_attr, hdrs, - &attr->action, extack); + err =alloc_tc_pedit_action (priv, ns_type, parse_attr, &attr->action, extack);if (err)return err;
@@ -3381,7 +3378,6 @@ parse_tc_nic_actions(struct mlx5e_priv *priv,struct mlx5e_tc_act_parse_state *parse_state;struct mlx5e_tc_flow_parse_attr *parse_attr;struct mlx5_flow_attr *attr = flow->attr; -struct pedit_headers_action *hdrs;int err; err =flow_action_supported (flow_action, extack);
@@ -3393,13 +3389,12 @@ parse_tc_nic_actions(struct mlx5e_priv *priv, parse_state = &parse_attr->parse_state;mlx5e_tc_act_init_parse_state (parse_state, flow, flow_action, extack); parse_state->ct_priv =get_ct_priv (priv); - hdrs = parse_state->hdrs; err =parse_tc_actions (parse_state, flow_action);if (err)return err; - err =actions_prepare_mod_hdr_actions (priv, flow, attr, hdrs, extack); + err =actions_prepare_mod_hdr_actions (priv, flow, attr, extack);if (err)return err;
@@ -3504,7 +3499,6 @@ parse_tc_fdb_actions(struct mlx5e_priv *priv,struct mlx5e_tc_flow_parse_attr *parse_attr;struct mlx5_flow_attr *attr = flow->attr;struct mlx5_esw_flow_attr *esw_attr; -struct pedit_headers_action *hdrs;int err; err =flow_action_supported (flow_action, extack);
@@ -3516,7 +3510,6 @@ parse_tc_fdb_actions(struct mlx5e_priv *priv, parse_state = &parse_attr->parse_state;mlx5e_tc_act_init_parse_state (parse_state, flow, flow_action, extack); parse_state->ct_priv =get_ct_priv (priv); - hdrs = parse_state->hdrs; err =parse_tc_actions (parse_state, flow_action);if (err)
@@ -3530,7 +3523,7 @@ parse_tc_fdb_actions(struct mlx5e_priv *priv,return -EOPNOTSUPP ; } - err =actions_prepare_mod_hdr_actions (priv, flow, attr, hdrs, extack); + err =actions_prepare_mod_hdr_actions (priv, flow, attr, extack);if (err)return err;
Signature · 1 line
2.34.1
PATCH 6/17 net/mlx5e: TC, Split pedit offloads verify from alloc_tc_pedit_action()
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Split pedit verify part into a new subfunction for better maintainability.
--- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +22 -11
@@ -2993,19 +2993,13 @@ static int offload_pedit_fields(struct mlx5e_priv *priv,static const struct pedit_headers zero_masks = {}; -static int alloc_tc_pedit_action (struct mlx5e_priv *priv,int namespace, -struct mlx5e_tc_flow_parse_attr *parse_attr, -u32 *action_flags, -struct netlink_ext_ack *extack) +static int verify_offload_pedit_fields (struct mlx5e_priv *priv, +struct mlx5e_tc_flow_parse_attr *parse_attr, +struct netlink_ext_ack *extack) {struct pedit_headers *cmd_masks; -int err;u8 cmd; - err =offload_pedit_fields (priv, namespace, parse_attr, action_flags, extack); -if (err <0 ) - goto out_dealloc_parsed_actions; -for (cmd =0 ; cmd < __PEDIT_CMD_MAX; cmd++) { cmd_masks = &parse_attr->hdrs[cmd].masks;if (memcmp (cmd_masks, &zero_masks,sizeof (zero_masks))) {
@@ -3013,12 +3007,29 @@ static int alloc_tc_pedit_action(struct mlx5e_priv *priv, int namespace,netdev_warn (priv->netdev,"attempt to offload an unsupported field (cmd %d)\n" , cmd);print_hex_dump (KERN_WARNING ,"mask: " ,DUMP_PREFIX_ADDRESS ,16 ,1 , cmd_masks,sizeof (zero_masks), true); - err = -EOPNOTSUPP ; - goto out_dealloc_parsed_actions; +return -EOPNOTSUPP ; } }return 0 ; +} + +static int alloc_tc_pedit_action (struct mlx5e_priv *priv,int namespace, +struct mlx5e_tc_flow_parse_attr *parse_attr, +u32 *action_flags, +struct netlink_ext_ack *extack) +{ +int err; + + err =offload_pedit_fields (priv, namespace, parse_attr, action_flags, extack); +if (err) + goto out_dealloc_parsed_actions; + + err =verify_offload_pedit_fields (priv, parse_attr, extack); +if (err) + goto out_dealloc_parsed_actions; + +return 0 ; out_dealloc_parsed_actions:mlx5e_mod_hdr_dealloc (&parse_attr->mod_hdr_acts);
Signature · 1 line
2.34.1
PATCH 7/17 net/mlx5e: TC, Pass attr to tc_act can_offload()
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
In later commit we are going to instantiate multiple attr instances for flow instead of single attr.
Make sure the parsing using correct attr and not flow->attr.
--- .../ethernet/mellanox/mlx5/core/en/tc/act/accept.c | 3 ++- .../net/ethernet/mellanox/mlx5/core/en/tc/act/act.h | 3 ++- .../net/ethernet/mellanox/mlx5/core/en/tc/act/csum.c | 5 +++-- .../net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c | 3 ++- .../net/ethernet/mellanox/mlx5/core/en/tc/act/drop.c | 3 ++- .../net/ethernet/mellanox/mlx5/core/en/tc/act/goto.c | 12 +++++++----- .../net/ethernet/mellanox/mlx5/core/en/tc/act/mark.c | 3 ++- .../ethernet/mellanox/mlx5/core/en/tc/act/mirred.c | 7 ++++--- .../mellanox/mlx5/core/en/tc/act/mirred_nic.c | 3 ++- .../net/ethernet/mellanox/mlx5/core/en/tc/act/mpls.c | 9 +++++---- .../ethernet/mellanox/mlx5/core/en/tc/act/pedit.c | 3 ++- .../ethernet/mellanox/mlx5/core/en/tc/act/ptype.c | 3 ++- .../mellanox/mlx5/core/en/tc/act/redirect_ingress.c | 8 ++++---- .../ethernet/mellanox/mlx5/core/en/tc/act/sample.c | 3 ++- .../net/ethernet/mellanox/mlx5/core/en/tc/act/trap.c | 3 ++- .../net/ethernet/mellanox/mlx5/core/en/tc/act/tun.c | 6 ++++-- .../net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c | 3 ++- .../mellanox/mlx5/core/en/tc/act/vlan_mangle.c | 3 ++- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 4 ++-- 19 files changed, 53 insertions(+), 34 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/accept.c +2 -1
@@ -7,7 +7,8 @@static bool tc_act_can_offload_accept (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {return true; }
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +2 -1
@@ -29,7 +29,8 @@ struct mlx5e_tc_act_parse_state {struct mlx5e_tc_act {bool (*can_offload)(struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index); +int act_index, +struct mlx5_flow_attr *attr); int (*parse_action)(struct mlx5e_tc_act_parse_state *parse_state, const struct flow_action_entry *act,
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/csum.c +3 -2
@@ -38,11 +38,12 @@ csum_offload_supported(struct mlx5e_priv *priv,static bool tc_act_can_offload_csum (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {struct mlx5e_tc_flow *flow = parse_state->flow; -return csum_offload_supported (flow->priv, flow->attr->action, +return csum_offload_supported (flow->priv, attr->action, act->csum_flags, parse_state->extack); }
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c +2 -1
@@ -8,7 +8,8 @@static bool tc_act_can_offload_ct (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {struct netlink_ext_ack *extack = parse_state->extack;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/drop.c +2 -1
@@ -7,7 +7,8 @@static bool tc_act_can_offload_drop (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {return true; }
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/goto.c +7 -5
@@ -8,6 +8,7 @@static int validate_goto_chain (struct mlx5e_priv *priv,struct mlx5e_tc_flow *flow, +struct mlx5_flow_attr *attr,const struct flow_action_entry *act,struct netlink_ext_ack *extack) {
@@ -32,7 +33,7 @@ validate_goto_chain(struct mlx5e_priv *priv, }if (!mlx5_chains_backwards_supported (chains) && - dest_chain <= flow->attr->chain) { + dest_chain <= attr->chain) {NL_SET_ERR_MSG_MOD (extack,"Goto lower numbered chain isn't supported" );return -EOPNOTSUPP ; }
@@ -43,8 +44,8 @@ validate_goto_chain(struct mlx5e_priv *priv,return -EOPNOTSUPP ; } -if (flow->attr->action & (MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT | -MLX5_FLOW_CONTEXT_ACTION_DECAP ) && +if (attr->action & (MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT | +MLX5_FLOW_CONTEXT_ACTION_DECAP ) && !reformat_and_fwd) {NL_SET_ERR_MSG_MOD (extack,"Goto chain is not allowed if action has reformat or decap" );
@@ -57,12 +58,13 @@ validate_goto_chain(struct mlx5e_priv *priv,static bool tc_act_can_offload_goto (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {struct netlink_ext_ack *extack = parse_state->extack;struct mlx5e_tc_flow *flow = parse_state->flow; -if (validate_goto_chain (flow->priv, flow, act, extack)) +if (validate_goto_chain (flow->priv, flow, attr, act, extack))return false;return true;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mark.c +2 -1
@@ -7,7 +7,8 @@static bool tc_act_can_offload_mark (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {if (act->mark & ~MLX5E_TC_FLOW_ID_MASK ) {NL_SET_ERR_MSG_MOD (parse_state->extack,"Bad flow mark, only 16 bit supported" );
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mirred.c +4 -3
@@ -99,7 +99,8 @@ get_fdb_out_dev(struct net_device *uplink_dev, struct net_device *out_dev)static bool tc_act_can_offload_mirred (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {struct netlink_ext_ack *extack = parse_state->extack;struct mlx5e_tc_flow *flow = parse_state->flow;
@@ -108,8 +109,8 @@ tc_act_can_offload_mirred(struct mlx5e_tc_act_parse_state *parse_state,struct mlx5e_priv *priv = flow->priv;struct mlx5_esw_flow_attr *esw_attr; - parse_attr = flow->attr->parse_attr; - esw_attr = flow->attr->esw_attr; + parse_attr = attr->parse_attr; + esw_attr = attr->esw_attr;if (!out_dev) {/* out_dev is NULL when filters with
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mirred_nic.c +2 -1
@@ -7,7 +7,8 @@static bool tc_act_can_offload_mirred_nic (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {struct netlink_ext_ack *extack = parse_state->extack;struct mlx5e_tc_flow *flow = parse_state->flow;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mpls.c +5 -4
@@ -8,7 +8,8 @@static bool tc_act_can_offload_mpls_push (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {struct netlink_ext_ack *extack = parse_state->extack;struct mlx5e_priv *priv = parse_state->flow->priv;
@@ -36,13 +37,13 @@ tc_act_parse_mpls_push(struct mlx5e_tc_act_parse_state *parse_state,static bool tc_act_can_offload_mpls_pop (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {struct netlink_ext_ack *extack = parse_state->extack; -struct mlx5e_tc_flow *flow = parse_state->flow;struct net_device *filter_dev; - filter_dev = flow->attr->parse_attr->filter_dev; + filter_dev = attr->parse_attr->filter_dev;/* we only support mpls pop if it is the first action * and the filter net device is bareudp. Subsequent
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.c +2 -1
@@ -122,7 +122,8 @@ mlx5e_tc_act_pedit_parse_action(struct mlx5e_priv *priv,static bool tc_act_can_offload_pedit (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {return true; }
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ptype.c +2 -1
@@ -7,7 +7,8 @@static bool tc_act_can_offload_ptype (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {return true; }
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/redirect_ingress.c +4 -4
@@ -7,16 +7,16 @@static bool tc_act_can_offload_redirect_ingress (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {struct netlink_ext_ack *extack = parse_state->extack; -struct mlx5e_tc_flow *flow = parse_state->flow;struct mlx5e_tc_flow_parse_attr *parse_attr;struct net_device *out_dev = act->dev;struct mlx5_esw_flow_attr *esw_attr; - parse_attr = flow->attr->parse_attr; - esw_attr = flow->attr->esw_attr; + parse_attr = attr->parse_attr; + esw_attr = attr->esw_attr;if (!out_dev)return false;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c +2 -1
@@ -8,7 +8,8 @@static bool tc_act_can_offload_sample (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {struct netlink_ext_ack *extack = parse_state->extack;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/trap.c +2 -1
@@ -7,7 +7,8 @@static bool tc_act_can_offload_trap (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {struct netlink_ext_ack *extack = parse_state->extack;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/tun.c +4 -2
@@ -8,7 +8,8 @@static bool tc_act_can_offload_tun_encap (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {if (!act->tunnel) { NL_SET_ERR_MSG_MOD(parse_state->extack,
@@ -34,7 +35,8 @@ tc_act_parse_tun_encap(struct mlx5e_tc_act_parse_state *parse_state,static bool tc_act_can_offload_tun_decap (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {return true; }
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c +2 -1
@@ -150,7 +150,8 @@ mlx5e_tc_act_vlan_add_pop_action(struct mlx5e_priv *priv,static bool tc_act_can_offload_vlan (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {return true; }
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan_mangle.c +2 -1
@@ -53,7 +53,8 @@ mlx5e_tc_act_vlan_add_rewrite_action(struct mlx5e_priv *priv, int namespace,static bool tc_act_can_offload_vlan_mangle (struct mlx5e_tc_act_parse_state *parse_state,const struct flow_action_entry *act, -int act_index) +int act_index, +struct mlx5_flow_attr *attr) {return true; }
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +2 -2
@@ -3302,7 +3302,7 @@ parse_tc_actions(struct mlx5e_tc_act_parse_state *parse_state,return -EOPNOTSUPP ; } -if (!tc_act->can_offload (parse_state, act, i)) +if (!tc_act->can_offload (parse_state, act, i, attr))return -EOPNOTSUPP ; err = tc_act->parse_action (parse_state, act, priv, attr);
@@ -3313,7 +3313,7 @@ parse_tc_actions(struct mlx5e_tc_act_parse_state *parse_state,flow_action_for_each (i, act, flow_action) { tc_act =mlx5e_tc_act_get (act->id, ns_type);if (!tc_act || !tc_act->post_parse || - !tc_act->can_offload (parse_state, act, i)) + !tc_act->can_offload (parse_state, act, i, attr))continue ; err = tc_act->post_parse (parse_state, priv, attr);
Signature · 1 line
2.34.1
PATCH 8/17 net/mlx5e: TC, Refactor mlx5e_tc_add_flow_mod_hdr() to get flow attr
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
In later commit we are going to instantiate multiple attr instances for flow instead of single attr.
Make sure mlx5e_tc_add_flow_mod_hdr() use the correct attr and not flow->attr.
--- .../ethernet/mellanox/mlx5/core/en/tc_tun_encap.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 12 ++++++------ drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c +1 -1
@@ -1380,7 +1380,7 @@ static void mlx5e_reoffload_encap(struct mlx5e_priv *priv,continue ; } - err =mlx5e_tc_add_flow_mod_hdr (priv, parse_attr, flow); + err =mlx5e_tc_add_flow_mod_hdr (priv, flow, attr);if (err) {mlx5_core_warn (priv->mdev,"Failed to update flow mod_hdr err=%d" , err);
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +6 -6
@@ -1360,10 +1360,10 @@ int mlx5e_tc_query_route_vport(struct net_device *out_dev, struct net_device *ro }int mlx5e_tc_add_flow_mod_hdr (struct mlx5e_priv *priv, -struct mlx5e_tc_flow_parse_attr *parse_attr, -struct mlx5e_tc_flow *flow) +struct mlx5e_tc_flow *flow, +struct mlx5_flow_attr *attr) { -struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts = &parse_attr->mod_hdr_acts; +struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts = &attr->parse_attr->mod_hdr_acts;struct mlx5_modify_hdr *mod_hdr; mod_hdr = mlx5_modify_header_alloc(priv->mdev,
@@ -1373,8 +1373,8 @@ int mlx5e_tc_add_flow_mod_hdr(struct mlx5e_priv *priv,if (IS_ERR (mod_hdr))return PTR_ERR (mod_hdr); -WARN_ON (flow->attr->modify_hdr); - flow->attr->modify_hdr = mod_hdr; +WARN_ON (attr->modify_hdr); + attr->modify_hdr = mod_hdr;return 0 ; }
@@ -1577,7 +1577,7 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,if (attr->action &MLX5_FLOW_CONTEXT_ACTION_MOD_HDR && !(attr->ct_attr.ct_action &TCA_CT_ACT_CLEAR )) {if (vf_tun) { - err =mlx5e_tc_add_flow_mod_hdr (priv, parse_attr, flow); + err =mlx5e_tc_add_flow_mod_hdr (priv, flow, attr);if (err) goto err_out; }else {
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +2 -2
@@ -243,8 +243,8 @@ int mlx5e_tc_match_to_reg_set_and_get_id(struct mlx5_core_dev *mdev, u32 data);int mlx5e_tc_add_flow_mod_hdr (struct mlx5e_priv *priv, -struct mlx5e_tc_flow_parse_attr *parse_attr, -struct mlx5e_tc_flow *flow); +struct mlx5e_tc_flow *flow, +struct mlx5_flow_attr *attr);struct mlx5e_tc_flow ;u32 mlx5e_tc_get_flow_tun_id (struct mlx5e_tc_flow *flow);
Signature · 1 line
2.34.1
PATCH 9/17 net/mlx5e: TC, Reject rules with multiple CT actions
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
The driver doesn't support multiple CT actions. Multiple CT clear actions are ok as they are redundant also with another CT actions.
--- .../net/ethernet/mellanox/mlx5/core/en/tc/act/act.h | 1 + drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c | 10 ++++++++++ 2 files changed, 11 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +1 -0
@@ -16,6 +16,7 @@ struct mlx5e_tc_act_parse_state {unsigned int num_actions;struct mlx5e_tc_flow *flow;struct netlink_ext_ack *extack; +bool ct;bool encap;bool decap;bool mpls_push;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c +10 -0
@@ -11,6 +11,7 @@ tc_act_can_offload_ct(struct mlx5e_tc_act_parse_state *parse_state,int act_index, struct mlx5_flow_attr *attr) { + bool clear_action = act->ct.action & TCA_CT_ACT_CLEAR;struct netlink_ext_ack *extack = parse_state->extack;if (flow_flag_test (parse_state->flow,SAMPLE )) {
@@ -19,6 +20,11 @@ tc_act_can_offload_ct(struct mlx5e_tc_act_parse_state *parse_state,return false; } +if (parse_state->ct && !clear_action) { +NL_SET_ERR_MSG_MOD (extack,"Multiple CT actions are not supoported" ); +return false; + } +return true; }
@@ -28,6 +34,7 @@ tc_act_parse_ct(struct mlx5e_tc_act_parse_state *parse_state,struct mlx5e_priv *priv, struct mlx5_flow_attr *attr) { + bool clear_action = act->ct.action & TCA_CT_ACT_CLEAR;int err; err = mlx5_tc_ct_parse_action(parse_state->ct_priv, attr,
@@ -41,6 +48,9 @@ tc_act_parse_ct(struct mlx5e_tc_act_parse_state *parse_state,if (mlx5e_is_eswitch_flow (parse_state->flow)) attr->esw_attr->split_count = attr->esw_attr->out_count; +if (!clear_action) + parse_state->ct = true; +return 0 ; }
Signature · 1 line
2.34.1
PATCH 10/17 net/mlx5e: TC, Hold sample_attr on stack instead of pointer
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
In later commit we are going to instantiate multiple attr instances for flow instead of single attr.
Parsing TC sample allocates a new memory but there is no symmetric cleanup in the infrastructure.
To avoid asymmetric alloc/free use sample_attr as part of the flow attr and not allocated and held as a pointer.
This will avoid a cleanup leak when sample action is not on the first attr.
--- .../net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c | 7 +------ drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c | 10 +++++----- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 2 +- .../net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 6 +++--- 5 files changed, 10 insertions(+), 16 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c +1 -6
@@ -28,11 +28,7 @@ tc_act_parse_sample(struct mlx5e_tc_act_parse_state *parse_state,struct mlx5e_priv *priv, struct mlx5_flow_attr *attr) { - struct mlx5e_sample_attr *sample_attr; - - sample_attr =kzalloc (sizeof (*attr->sample_attr),GFP_KERNEL ); -if (!sample_attr) -return -ENOMEM ; + struct mlx5e_sample_attr *sample_attr = &attr->sample_attr; sample_attr->rate = act->sample.rate; sample_attr->group_num = act->sample.psample_group->group_num;
@@ -40,7 +36,6 @@ tc_act_parse_sample(struct mlx5e_tc_act_parse_state *parse_state,if (act->sample.truncate) sample_attr->trunc_size = act->sample.trunc_size; - attr->sample_attr = sample_attr;flow_flag_set (parse_state->flow,SAMPLE );return 0 ;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c +5 -5
@@ -513,7 +513,7 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample, sample_flow =kzalloc (sizeof (*sample_flow),GFP_KERNEL );if (!sample_flow)return ERR_PTR (-ENOMEM ); - sample_attr = attr->sample_attr; + sample_attr = &attr->sample_attr; sample_attr->sample_flow = sample_flow;/* For NICs with reg_c_preserve support or decap action, use
@@ -546,6 +546,7 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample, err =PTR_ERR (sample_flow->sampler); goto err_sampler; } + sample_attr->sampler_id = sample_flow->sampler->sampler_id;/* Create an id mapping reg_c0 value to sample object. */ restore_obj.type =MLX5_MAPPED_OBJ_SAMPLE ;
@@ -585,8 +586,7 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample, pre_attr->outer_match_level = attr->outer_match_level; pre_attr->chain = attr->chain; pre_attr->prio = attr->prio; - pre_attr->sample_attr = attr->sample_attr; - sample_attr->sampler_id = sample_flow->sampler->sampler_id; + pre_attr->sample_attr = *sample_attr; pre_esw_attr = pre_attr->esw_attr; pre_esw_attr->in_mdev = esw_attr->in_mdev; pre_esw_attr->in_rep = esw_attr->in_rep;
@@ -633,11 +633,11 @@ mlx5e_tc_sample_unoffload(struct mlx5e_tc_psample *tc_psample,* will hit fw syndromes. */ esw = tc_psample->esw; - sample_flow = attr->sample_attr->sample_flow; + sample_flow = attr->sample_attr.sample_flow;mlx5_eswitch_del_offloaded_rule (esw, sample_flow->pre_rule, sample_flow->pre_attr);sample_restore_put (tc_psample, sample_flow->restore); -mapping_remove (esw->offloads.reg_c0_obj_pool, attr->sample_attr->restore_obj_id); +mapping_remove (esw->offloads.reg_c0_obj_pool, attr->sample_attr.restore_obj_id);sampler_put (tc_psample, sample_flow->sampler);if (sample_flow->post_act_handle)mlx5e_tc_post_act_del (tc_psample->post_act, sample_flow->post_act_handle);
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +0 -1
@@ -1682,7 +1682,6 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,if (flow_flag_test (flow,L3_TO_L2_DECAP ))mlx5e_detach_decap (priv, flow); -kfree (attr->sample_attr);kvfree (attr->esw_attr->rx_tun_attr);kvfree (attr->parse_attr);kfree (flow->attr);
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +1 -1
@@ -71,7 +71,7 @@ struct mlx5_flow_attr {struct mlx5_fc *counter;struct mlx5_modify_hdr *modify_hdr;struct mlx5_ct_attr ct_attr; -struct mlx5e_sample_attr *sample_attr; +struct mlx5e_sample_attr sample_attr;struct mlx5e_tc_flow_parse_attr *parse_attr;u32 chain;u16 prio;
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +3 -3
@@ -201,12 +201,12 @@ esw_cleanup_decap_indir(struct mlx5_eswitch *esw,static int esw_setup_sampler_dest (struct mlx5_flow_destination *dest,struct mlx5_flow_act *flow_act, -struct mlx5_flow_attr *attr, +u32 sampler_id,int i) { flow_act->flags |=FLOW_ACT_IGNORE_FLOW_LEVEL ; dest[i].type =MLX5_FLOW_DESTINATION_TYPE_FLOW_SAMPLER ; - dest[i].sampler_id = attr->sample_attr->sampler_id; + dest[i].sampler_id = sampler_id;return 0 ; }
@@ -466,7 +466,7 @@ esw_setup_dests(struct mlx5_flow_destination *dest, attr->flags |=MLX5_ESW_ATTR_FLAG_SRC_REWRITE ;if (attr->flags &MLX5_ESW_ATTR_FLAG_SAMPLE ) { -esw_setup_sampler_dest (dest, flow_act, attr, *i); +esw_setup_sampler_dest (dest, flow_act, attr->sample_attr.sampler_id, *i); (*i)++; }else if (attr->dest_ft) {esw_setup_ft_dest (dest, flow_act, esw, attr, spec, *i);
Signature · 1 line
2.34.1
PATCH 11/17 net/mlx5e: CT, Don't set flow flag CT for ct clear flow
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
ct clear action is a normal flow with a modify header for registers to
0. there is no need for any special handling in tc_ct.c. Parsing of ct clear action still allocates mod acts to set 0 on the registers and the driver continue to add a normal rule with modify hdr context.
--- .../mellanox/mlx5/core/en/tc/act/ct.c | 5 +- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 72 +------------------ .../net/ethernet/mellanox/mlx5/core/en_tc.c | 3 +- 3 files changed, 6 insertions(+), 74 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c +3 -2
@@ -43,13 +43,14 @@ tc_act_parse_ct(struct mlx5e_tc_act_parse_state *parse_state,if (err)return err; -flow_flag_set (parse_state->flow,CT );if (mlx5e_is_eswitch_flow (parse_state->flow)) attr->esw_attr->split_count = attr->esw_attr->out_count; -if (!clear_action) +if (!clear_action) { +flow_flag_set (parse_state->flow,CT ); parse_state->ct = true; + }return 0 ; }
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +2 -70
96 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1 -2
@@ -1574,8 +1574,7 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,if (err) goto err_out; -if (attr->action &MLX5_FLOW_CONTEXT_ACTION_MOD_HDR && - !(attr->ct_attr.ct_action &TCA_CT_ACT_CLEAR )) { +if (attr->action &MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ) {if (vf_tun) { err =mlx5e_tc_add_flow_mod_hdr (priv, flow, attr);if (err)
Signature · 1 line
2.34.1
PATCH 12/17 net/mlx5e: Refactor eswitch attr flags to just attr flags
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
The flags are flow attrs and not esw specific attr flags. Refactor to remove the esw prefix and move from eswitch.h to en_tc.h where struct mlx5_flow_attr exists.
--- .../mellanox/mlx5/core/en/tc/act/accept.c | 2 +- .../mellanox/mlx5/core/en/tc/act/trap.c | 2 +- .../mellanox/mlx5/core/en/tc/sample.c | 4 +-- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 2 +- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 8 +++--- .../net/ethernet/mellanox/mlx5/core/en_tc.h | 16 ++++++++++++ .../mellanox/mlx5/core/esw/indir_table.c | 2 +- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 16 ------------ .../mellanox/mlx5/core/eswitch_offloads.c | 26 +++++++++---------- .../mlx5/core/eswitch_offloads_termtbl.c | 2 +- 10 files changed, 40 insertions(+), 40 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/accept.c +1 -1
@@ -21,7 +21,7 @@ tc_act_parse_accept(struct mlx5e_tc_act_parse_state *parse_state, { attr->action |=MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |MLX5_FLOW_CONTEXT_ACTION_COUNT ; - attr->flags |=MLX5_ESW_ATTR_FLAG_ACCEPT ; + attr->flags |=MLX5_ATTR_FLAG_ACCEPT ;return 0 ; }
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/trap.c +1 -1
@@ -28,7 +28,7 @@ tc_act_parse_trap(struct mlx5e_tc_act_parse_state *parse_state, { attr->action |=MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |MLX5_FLOW_CONTEXT_ACTION_COUNT ; - attr->flags |=MLX5_ESW_ATTR_FLAG_SLOW_PATH ; + attr->flags |=MLX5_ATTR_FLAG_SLOW_PATH ;return 0 ; }
drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c +2 -2
@@ -403,7 +403,7 @@ add_post_rule(struct mlx5_eswitch *esw, struct mlx5e_sample_flow *sample_flow, post_attr->chain =0 ; post_attr->prio =0 ; post_attr->ft = default_tbl; - post_attr->flags =MLX5_ESW_ATTR_FLAG_NO_IN_PORT ; + post_attr->flags =MLX5_ATTR_FLAG_NO_IN_PORT ;/* When offloading sample and encap action, if there is no valid * neigh data struct, a slow path rule is offloaded first. Source
@@ -581,7 +581,7 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample,if (tunnel_id) pre_attr->action |=MLX5_FLOW_CONTEXT_ACTION_DECAP ; pre_attr->modify_hdr = sample_flow->restore->modify_hdr; - pre_attr->flags =MLX5_ESW_ATTR_FLAG_SAMPLE ; + pre_attr->flags =MLX5_ATTR_FLAG_SAMPLE ; pre_attr->inner_match_level = attr->inner_match_level; pre_attr->outer_match_level = attr->outer_match_level; pre_attr->chain = attr->chain;
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +1 -1
@@ -809,7 +809,7 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, attr->ft = nat ? ct_priv->ct_nat : ct_priv->ct; attr->outer_match_level =MLX5_MATCH_L4 ; attr->counter = entry->counter->counter; - attr->flags |=MLX5_ESW_ATTR_FLAG_NO_IN_PORT ; + attr->flags |=MLX5_ATTR_FLAG_NO_IN_PORT ;if (ct_priv->ns_type ==MLX5_FLOW_NAMESPACE_FDB ) attr->esw_attr->in_mdev = priv->mdev;
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +4 -4
@@ -1157,7 +1157,7 @@ mlx5e_tc_offload_fdb_rules(struct mlx5_eswitch *esw,struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts;struct mlx5_flow_handle *rule; -if (attr->flags &MLX5_ESW_ATTR_FLAG_SLOW_PATH ) +if (attr->flags &MLX5_ATTR_FLAG_SLOW_PATH )return mlx5_eswitch_add_offloaded_rule (esw, spec, attr);if (flow_flag_test (flow,CT )) {
@@ -1196,7 +1196,7 @@ void mlx5e_tc_unoffload_fdb_rules(struct mlx5_eswitch *esw, {flow_flag_clear (flow,OFFLOADED ); -if (attr->flags &MLX5_ESW_ATTR_FLAG_SLOW_PATH ) +if (attr->flags &MLX5_ATTR_FLAG_SLOW_PATH ) goto offload_rule_0;if (attr->esw_attr->split_count)
@@ -1226,7 +1226,7 @@ mlx5e_tc_offload_to_slow_path(struct mlx5_eswitch *esw,memcpy (slow_attr, flow->attr,ESW_FLOW_ATTR_SZ ); slow_attr->action =MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ; slow_attr->esw_attr->split_count =0 ; - slow_attr->flags |=MLX5_ESW_ATTR_FLAG_SLOW_PATH ; + slow_attr->flags |=MLX5_ATTR_FLAG_SLOW_PATH ; rule =mlx5e_tc_offload_fdb_rules (esw, flow, spec, slow_attr);if (!IS_ERR (rule))
@@ -1251,7 +1251,7 @@ void mlx5e_tc_unoffload_from_slow_path(struct mlx5_eswitch *esw,memcpy (slow_attr, flow->attr,ESW_FLOW_ATTR_SZ ); slow_attr->action =MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ; slow_attr->esw_attr->split_count =0 ; - slow_attr->flags |=MLX5_ESW_ATTR_FLAG_SLOW_PATH ; + slow_attr->flags |=MLX5_ATTR_FLAG_SLOW_PATH ;mlx5e_tc_unoffload_fdb_rules (esw, flow, slow_attr);flow_flag_clear (flow,SLOW );kfree (slow_attr);
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +16 -0
@@ -89,6 +89,22 @@ struct mlx5_flow_attr { }; }; +enum { +MLX5_ATTR_FLAG_VLAN_HANDLED =BIT (0 ), +MLX5_ATTR_FLAG_SLOW_PATH =BIT (1 ), +MLX5_ATTR_FLAG_NO_IN_PORT =BIT (2 ), +MLX5_ATTR_FLAG_SRC_REWRITE =BIT (3 ), +MLX5_ATTR_FLAG_SAMPLE =BIT (4 ), +MLX5_ATTR_FLAG_ACCEPT =BIT (5 ), +}; + +/* Returns true if any of the flags that require skipping further TC/NF processing are set. */ +static inline bool +mlx5e_tc_attr_flags_skip (u32 attr_flags) +{ +return attr_flags & (MLX5_ATTR_FLAG_SLOW_PATH |MLX5_ATTR_FLAG_ACCEPT ); +} +struct mlx5_rx_tun_attr {u16 decap_vport;union {
drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c +1 -1
@@ -86,7 +86,7 @@ mlx5_esw_indir_table_needed(struct mlx5_eswitch *esw,mlx5_eswitch_is_vf_vport (esw, vport_num) && esw->dev == dest_mdev && attr->ip_version && - attr->flags &MLX5_ESW_ATTR_FLAG_SRC_REWRITE ; + attr->flags &MLX5_ATTR_FLAG_SRC_REWRITE ; } u16
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +0 -16
@@ -448,22 +448,6 @@ enum { MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE = BIT(2), }; -enum { -MLX5_ESW_ATTR_FLAG_VLAN_HANDLED =BIT (0 ), -MLX5_ESW_ATTR_FLAG_SLOW_PATH =BIT (1 ), -MLX5_ESW_ATTR_FLAG_NO_IN_PORT =BIT (2 ), -MLX5_ESW_ATTR_FLAG_SRC_REWRITE =BIT (3 ), -MLX5_ESW_ATTR_FLAG_SAMPLE =BIT (4 ), -MLX5_ESW_ATTR_FLAG_ACCEPT =BIT (5 ), -}; - -/* Returns true if any of the flags that require skipping further TC/NF processing are set. */ -static inline bool -mlx5_esw_attr_flags_skip (u32 attr_flags) -{ -return attr_flags & (MLX5_ESW_ATTR_FLAG_SLOW_PATH |MLX5_ESW_ATTR_FLAG_ACCEPT ); -} -struct mlx5_esw_flow_attr {struct mlx5_eswitch_rep *in_rep;struct mlx5_core_dev *in_mdev;
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +13 -13
@@ -180,7 +180,7 @@ esw_setup_decap_indir(struct mlx5_eswitch *esw, {struct mlx5_flow_table *ft; -if (!(attr->flags &MLX5_ESW_ATTR_FLAG_SRC_REWRITE )) +if (!(attr->flags &MLX5_ATTR_FLAG_SRC_REWRITE ))return -EOPNOTSUPP ; ft = mlx5_esw_indir_table_get(esw, attr, spec,
@@ -297,7 +297,7 @@ esw_setup_chain_src_port_rewrite(struct mlx5_flow_destination *dest,struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr;int err; -if (!(attr->flags &MLX5_ESW_ATTR_FLAG_SRC_REWRITE )) +if (!(attr->flags &MLX5_ATTR_FLAG_SRC_REWRITE ))return -EOPNOTSUPP ;/* flow steering cannot handle more than one dest with the same ft
@@ -364,7 +364,7 @@ esw_setup_indir_table(struct mlx5_flow_destination *dest,struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr;int j, err; -if (!(attr->flags &MLX5_ESW_ATTR_FLAG_SRC_REWRITE )) +if (!(attr->flags &MLX5_ATTR_FLAG_SRC_REWRITE ))return -EOPNOTSUPP ;for (j = esw_attr->split_count; j < esw_attr->out_count; j++, (*i)++) {
@@ -463,15 +463,15 @@ esw_setup_dests(struct mlx5_flow_destination *dest,if (!mlx5_eswitch_termtbl_required (esw, attr, flow_act, spec) &&esw_src_port_rewrite_supported (esw)) - attr->flags |=MLX5_ESW_ATTR_FLAG_SRC_REWRITE ; + attr->flags |=MLX5_ATTR_FLAG_SRC_REWRITE ; -if (attr->flags &MLX5_ESW_ATTR_FLAG_SAMPLE ) { +if (attr->flags &MLX5_ATTR_FLAG_SAMPLE ) {esw_setup_sampler_dest (dest, flow_act, attr->sample_attr.sampler_id, *i); (*i)++; }else if (attr->dest_ft) {esw_setup_ft_dest (dest, flow_act, esw, attr, spec, *i); (*i)++; - }else if (mlx5_esw_attr_flags_skip (attr->flags)) { + }else if (mlx5e_tc_attr_flags_skip (attr->flags)) {esw_setup_slow_path_dest (dest, flow_act, chains, *i); (*i)++; }else if (attr->dest_chain) {
@@ -498,7 +498,7 @@ esw_cleanup_dests(struct mlx5_eswitch *esw,if (attr->dest_ft) {esw_cleanup_decap_indir (esw, attr); - }else if (!mlx5_esw_attr_flags_skip (attr->flags)) { + }else if (!mlx5e_tc_attr_flags_skip (attr->flags)) {if (attr->dest_chain)esw_cleanup_chain_dest (chains, attr->dest_chain,1 ,0 );else if (esw_is_indir_table (esw, attr))
@@ -589,7 +589,7 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,else fdb = attr->ft; -if (!(attr->flags &MLX5_ESW_ATTR_FLAG_NO_IN_PORT )) +if (!(attr->flags &MLX5_ATTR_FLAG_NO_IN_PORT ))mlx5_eswitch_set_rule_source_port (esw, spec, attr, esw_attr->in_mdev->priv.eswitch, esw_attr->in_rep->vport);
@@ -721,7 +721,7 @@ __mlx5_eswitch_del_rule(struct mlx5_eswitch *esw,mlx5_del_flow_rules (rule); -if (!mlx5_esw_attr_flags_skip (attr->flags)) { +if (!mlx5e_tc_attr_flags_skip (attr->flags)) {/* unref the term table */ for (i =0 ; i <MLX5_MAX_FLOW_FWD_VPORTS ; i++) {if (esw_attr->dests[i].termtbl)
@@ -863,7 +863,7 @@ int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw,if (err) goto unlock; - attr->flags &= ~MLX5_ESW_ATTR_FLAG_VLAN_HANDLED ; + attr->flags &= ~MLX5_ATTR_FLAG_VLAN_HANDLED ; vport =esw_vlan_action_get_vport (esw_attr, push, pop);
@@ -871,7 +871,7 @@ int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw,/* tracks VF --> wire rules without vlan push action */ if (esw_attr->dests[0 ].rep->vport ==MLX5_VPORT_UPLINK ) { vport->vlan_refcount++; - attr->flags |=MLX5_ESW_ATTR_FLAG_VLAN_HANDLED ; + attr->flags |=MLX5_ATTR_FLAG_VLAN_HANDLED ; } goto unlock;
@@ -902,7 +902,7 @@ int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw, } out:if (!err) - attr->flags |=MLX5_ESW_ATTR_FLAG_VLAN_HANDLED ; + attr->flags |=MLX5_ATTR_FLAG_VLAN_HANDLED ; unlock:mutex_unlock (&esw->state_lock);return err;
@@ -921,7 +921,7 @@ int mlx5_eswitch_del_vlan_action(struct mlx5_eswitch *esw,if (mlx5_eswitch_vlan_actions_supported (esw->dev,1 ))return 0 ; -if (!(attr->flags &MLX5_ESW_ATTR_FLAG_VLAN_HANDLED )) +if (!(attr->flags &MLX5_ATTR_FLAG_VLAN_HANDLED ))return 0 ; push = !!(attr->action &MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH );
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c +1 -1
@@ -219,7 +219,7 @@ mlx5_eswitch_termtbl_required(struct mlx5_eswitch *esw,if (!MLX5_CAP_ESW_FLOWTABLE_FDB (esw->dev, termination_table) || !MLX5_CAP_ESW_FLOWTABLE_FDB (esw->dev, ignore_flow_level) || -mlx5_esw_attr_flags_skip (attr->flags) || +mlx5e_tc_attr_flags_skip (attr->flags) || (!mlx5_eswitch_offload_is_uplink_port (esw, spec) && !esw_attr->int_port))return false;
Signature · 1 line
2.34.1
PATCH 13/17 net/mlx5e: Test CT and SAMPLE on flow attr
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Currently the mlx5_flow object contains a single mlx5_attr instance. However, multi table actions (e.g. CT) instantiate multiple attr instances. Prepare for multiple attr instances by testing for CT or SAMPLE flag on attr flags instead of flow flag.
--- .../mellanox/mlx5/core/en/tc/act/ct.c | 1 + .../mellanox/mlx5/core/en/tc/act/sample.c | 1 + .../ethernet/mellanox/mlx5/core/en/tc_priv.h | 12 +++ .../net/ethernet/mellanox/mlx5/core/en_tc.c | 95 +++++++++++++------ .../net/ethernet/mellanox/mlx5/core/en_tc.h | 1 + 5 files changed, 79 insertions(+), 31 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c +1 -0
@@ -48,6 +48,7 @@ tc_act_parse_ct(struct mlx5e_tc_act_parse_state *parse_state, attr->esw_attr->split_count = attr->esw_attr->out_count;if (!clear_action) { + attr->flags |=MLX5_ATTR_FLAG_CT ;flow_flag_set (parse_state->flow,CT ); parse_state->ct = true; }
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c +1 -0
@@ -36,6 +36,7 @@ tc_act_parse_sample(struct mlx5e_tc_act_parse_state *parse_state,if (act->sample.truncate) sample_attr->trunc_size = act->sample.trunc_size; + attr->flags |=MLX5_ATTR_FLAG_SAMPLE ;flow_flag_set (parse_state->flow,SAMPLE );return 0 ;
drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h +12 -0
@@ -112,6 +112,17 @@ struct mlx5e_tc_flow {struct mlx5_flow_attr *attr; }; +struct mlx5_flow_handle * +mlx5e_tc_rule_offload (struct mlx5e_priv *priv, +struct mlx5e_tc_flow *flow, +struct mlx5_flow_spec *spec, +struct mlx5_flow_attr *attr); + +void +mlx5e_tc_rule_unoffload (struct mlx5e_priv *priv, +struct mlx5e_tc_flow *flow, +struct mlx5_flow_attr *attr); +u8 mlx5e_tc_get_ip_version (struct mlx5_flow_spec *spec,bool outer); struct mlx5_flow_handle *
@@ -174,6 +185,7 @@ struct mlx5_flow_handle * mlx5e_tc_offload_to_slow_path(struct mlx5_eswitch *esw, struct mlx5e_tc_flow *flow, struct mlx5_flow_spec *spec); +void mlx5e_tc_unoffload_fdb_rules (struct mlx5_eswitch *esw,struct mlx5e_tc_flow *flow,struct mlx5_flow_attr *attr);
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +64 -31
149 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +1 -0
@@ -96,6 +96,7 @@ enum {MLX5_ATTR_FLAG_SRC_REWRITE =BIT (3 ),MLX5_ATTR_FLAG_SAMPLE =BIT (4 ),MLX5_ATTR_FLAG_ACCEPT =BIT (5 ), + MLX5_ATTR_FLAG_CT = BIT(6), };/* Returns true if any of the flags that require skipping further TC/NF processing are set. */
Signature · 1 line
2.34.1
PATCH 14/17 net/mlx5e: TC, Store mapped tunnel id on flow attr
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
In preparation for multiple attr instances the tunnel_id should be attr specific and not flow specific.
--- .../net/ethernet/mellanox/mlx5/core/en/tc/sample.c | 4 ++-- .../net/ethernet/mellanox/mlx5/core/en/tc/sample.h | 6 ++---- drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 4 +--- .../net/ethernet/mellanox/mlx5/core/en/tc_priv.h | 1 - drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 14 ++++---------- drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 4 +--- 6 files changed, 10 insertions(+), 23 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c +2 -2
@@ -492,8 +492,7 @@ del_post_rule(struct mlx5_eswitch *esw, struct mlx5e_sample_flow *sample_flow,struct mlx5_flow_handle *mlx5e_tc_sample_offload (struct mlx5e_tc_psample *tc_psample,struct mlx5_flow_spec *spec, -struct mlx5_flow_attr *attr, -u32 tunnel_id) +struct mlx5_flow_attr *attr) {struct mlx5e_post_act_handle *post_act_handle =NULL ;struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr;
@@ -502,6 +501,7 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample,struct mlx5e_sample_flow *sample_flow;struct mlx5e_sample_attr *sample_attr;struct mlx5_flow_attr *pre_attr; +u32 tunnel_id = attr->tunnel_id;struct mlx5_eswitch *esw;u32 default_tbl_id;u32 obj_id;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.h +2 -4
@@ -26,8 +26,7 @@ void mlx5e_tc_sample_skb(struct sk_buff *skb, struct mlx5_mapped_obj *mapped_objstruct mlx5_flow_handle *mlx5e_tc_sample_offload (struct mlx5e_tc_psample *sample_priv,struct mlx5_flow_spec *spec, -struct mlx5_flow_attr *attr, -u32 tunnel_id); +struct mlx5_flow_attr *attr); void mlx5e_tc_sample_unoffload(struct mlx5e_tc_psample *sample_priv,
@@ -45,8 +44,7 @@ mlx5e_tc_sample_cleanup(struct mlx5e_tc_psample *tc_psample);static inline struct mlx5_flow_handle *mlx5e_tc_sample_offload (struct mlx5e_tc_psample *tc_psample,struct mlx5_flow_spec *spec, -struct mlx5_flow_attr *attr, -u32 tunnel_id) +struct mlx5_flow_attr *attr) {return ERR_PTR (-EOPNOTSUPP ); } static inline void
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +1 -3
@@ -1871,12 +1871,10 @@ __mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *ct_priv,*/ if ((pre_ct_attr->action &MLX5_FLOW_CONTEXT_ACTION_DECAP ) && attr->chain ==0 ) { -u32 tun_id =mlx5e_tc_get_flow_tun_id (flow); - err =mlx5e_tc_match_to_reg_set (priv->mdev, &pre_mod_acts, ct_priv->ns_type,TUNNEL_TO_REG , - tun_id); + attr->tunnel_id);if (err) {ct_dbg ("Failed to set tunnel register mapping" ); goto err_mapping;
drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h +0 -1
@@ -108,7 +108,6 @@ struct mlx5e_tc_flow {struct rcu_head rcu_head;struct completion init_done;struct completion del_hw_done; -int tunnel_id;/* the mapped tunnel id of this flow */ struct mlx5_flow_attr *attr; };
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +4 -10
@@ -308,7 +308,6 @@ mlx5e_tc_rule_offload(struct mlx5e_priv *priv, struct mlx5_flow_attr *attr) {struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; -u32 tun_id =mlx5e_tc_get_flow_tun_id (flow);if (attr->flags &MLX5_ATTR_FLAG_CT ) { struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts =
@@ -323,7 +322,7 @@ mlx5e_tc_rule_offload(struct mlx5e_priv *priv,return mlx5e_add_offloaded_nic_rule (priv, spec, attr);if (attr->flags &MLX5_ATTR_FLAG_SAMPLE ) -return mlx5e_tc_sample_offload (get_sample_priv (priv), spec, attr, tun_id); +return mlx5e_tc_sample_offload (get_sample_priv (priv), spec, attr);return mlx5_eswitch_add_offloaded_rule (esw, spec, attr); }
@@ -1933,7 +1932,7 @@ static int mlx5e_get_flow_tunnel_id(struct mlx5e_priv *priv, attr->action |=MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ; } - flow->tunnel_id = value; + flow->attr->tunnel_id = value;return 0 ; err_set:
@@ -1947,8 +1946,8 @@ static int mlx5e_get_flow_tunnel_id(struct mlx5e_priv *priv,static void mlx5e_put_flow_tunnel_id (struct mlx5e_tc_flow *flow) { -u32 enc_opts_id = flow->tunnel_id &ENC_OPTS_BITS_MASK ; -u32 tun_id = flow->tunnel_id >>ENC_OPTS_BITS ; +u32 enc_opts_id = flow->attr->tunnel_id &ENC_OPTS_BITS_MASK ; +u32 tun_id = flow->attr->tunnel_id >>ENC_OPTS_BITS ;struct mlx5_rep_uplink_priv *uplink_priv;struct mlx5e_rep_priv *uplink_rpriv;struct mlx5_eswitch *esw;
@@ -1964,11 +1963,6 @@ static void mlx5e_put_flow_tunnel_id(struct mlx5e_tc_flow *flow) enc_opts_id); } -u32 mlx5e_tc_get_flow_tun_id (struct mlx5e_tc_flow *flow) -{ -return flow->tunnel_id; -} -void mlx5e_tc_set_ethertype (struct mlx5_core_dev *mdev,struct flow_match_basic *match,bool outer,void *headers_c,void *headers_v)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +1 -3
@@ -82,6 +82,7 @@ struct mlx5_flow_attr {u8 outer_match_level;u8 ip_version;u8 tun_ip_version; +int tunnel_id;/* mapped tunnel id */ u32 flags;union {struct mlx5_esw_flow_attr esw_attr[0 ];
@@ -263,9 +264,6 @@ int mlx5e_tc_add_flow_mod_hdr(struct mlx5e_priv *priv,struct mlx5e_tc_flow *flow, struct mlx5_flow_attr *attr); -struct mlx5e_tc_flow ; -u32 mlx5e_tc_get_flow_tun_id (struct mlx5e_tc_flow *flow); -void mlx5e_tc_set_ethertype (struct mlx5_core_dev *mdev,struct flow_match_basic *match,bool outer,void *headers_c,void *headers_v);
Signature · 1 line
2.34.1
PATCH 15/17 net/mlx5e: CT, Remove redundant flow args from tc ct calls
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
The flow arg is not being used so remove it.
--- .../net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 11 ++++------- .../net/ethernet/mellanox/mlx5/core/en/tc_ct.h | 4 ---- .../ethernet/mellanox/mlx5/core/en/tc_priv.h | 3 +-- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 18 ++++++++---------- 4 files changed, 13 insertions(+), 23 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +4 -7
@@ -1787,7 +1787,6 @@ mlx5_tc_ct_del_ft_cb(struct mlx5_tc_ct_priv *ct_priv, struct mlx5_ct_ft *ft)*/ static struct mlx5_flow_handle *__mlx5_tc_ct_flow_offload (struct mlx5_tc_ct_priv *ct_priv, -struct mlx5e_tc_flow *flow,struct mlx5_flow_spec *orig_spec,struct mlx5_flow_attr *attr) {
@@ -1926,7 +1925,6 @@ __mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *ct_priv,struct mlx5_flow_handle *mlx5_tc_ct_flow_offload (struct mlx5_tc_ct_priv *priv, -struct mlx5e_tc_flow *flow,struct mlx5_flow_spec *spec,struct mlx5_flow_attr *attr,struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts)
@@ -1937,7 +1935,7 @@ mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *priv,return ERR_PTR (-EOPNOTSUPP );mutex_lock (&priv->control_lock); - rule =__mlx5_tc_ct_flow_offload (priv, flow, spec, attr); + rule =__mlx5_tc_ct_flow_offload (priv, spec, attr);mutex_unlock (&priv->control_lock);return rule;
@@ -1945,8 +1943,8 @@ mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *priv,static void __mlx5_tc_ct_delete_flow (struct mlx5_tc_ct_priv *ct_priv, -struct mlx5e_tc_flow *flow, -struct mlx5_ct_flow *ct_flow) +struct mlx5_ct_flow *ct_flow, +struct mlx5_flow_attr *attr) {struct mlx5_flow_attr *pre_ct_attr = ct_flow->pre_ct_attr;struct mlx5e_priv *priv =netdev_priv (ct_priv->netdev);
@@ -1966,7 +1964,6 @@ __mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *ct_priv,void mlx5_tc_ct_delete_flow (struct mlx5_tc_ct_priv *priv, -struct mlx5e_tc_flow *flow,struct mlx5_flow_attr *attr) {struct mlx5_ct_flow *ct_flow = attr->ct_attr.ct_flow;
@@ -1978,7 +1975,7 @@ mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *priv,return ;mutex_lock (&priv->control_lock); -__mlx5_tc_ct_delete_flow (priv, flow, ct_flow); +__mlx5_tc_ct_delete_flow (priv, ct_flow, attr);mutex_unlock (&priv->control_lock); }
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h +0 -4
@@ -116,13 +116,11 @@ mlx5_tc_ct_parse_action(struct mlx5_tc_ct_priv *priv,struct mlx5_flow_handle *mlx5_tc_ct_flow_offload (struct mlx5_tc_ct_priv *priv, -struct mlx5e_tc_flow *flow,struct mlx5_flow_spec *spec,struct mlx5_flow_attr *attr,struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts);void mlx5_tc_ct_delete_flow (struct mlx5_tc_ct_priv *priv, -struct mlx5e_tc_flow *flow,struct mlx5_flow_attr *attr);bool
@@ -183,7 +181,6 @@ mlx5_tc_ct_parse_action(struct mlx5_tc_ct_priv *priv,static inline struct mlx5_flow_handle *mlx5_tc_ct_flow_offload (struct mlx5_tc_ct_priv *priv, -struct mlx5e_tc_flow *flow,struct mlx5_flow_spec *spec,struct mlx5_flow_attr *attr,struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts)
@@ -193,7 +190,6 @@ mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *priv,static inline void mlx5_tc_ct_delete_flow (struct mlx5_tc_ct_priv *priv, -struct mlx5e_tc_flow *flow,struct mlx5_flow_attr *attr) { }
drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h +1 -2
@@ -113,13 +113,12 @@ struct mlx5e_tc_flow {struct mlx5_flow_handle *mlx5e_tc_rule_offload (struct mlx5e_priv *priv, -struct mlx5e_tc_flow *flow,struct mlx5_flow_spec *spec,struct mlx5_flow_attr *attr);void mlx5e_tc_rule_unoffload (struct mlx5e_priv *priv, -struct mlx5e_tc_flow *flow, +struct mlx5_flow_handle *rule,struct mlx5_flow_attr *attr);u8 mlx5e_tc_get_ip_version (struct mlx5_flow_spec *spec,bool outer);
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +8 -10
@@ -303,7 +303,6 @@ mlx5_tc_rule_delete(struct mlx5e_priv *priv,struct mlx5_flow_handle *mlx5e_tc_rule_offload (struct mlx5e_priv *priv, -struct mlx5e_tc_flow *flow,struct mlx5_flow_spec *spec,struct mlx5_flow_attr *attr) {
@@ -313,7 +312,7 @@ mlx5e_tc_rule_offload(struct mlx5e_priv *priv,struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts = &attr->parse_attr->mod_hdr_acts; -return mlx5_tc_ct_flow_offload (get_ct_priv (priv), flow, +return mlx5_tc_ct_flow_offload (get_ct_priv (priv), spec, attr, mod_hdr_acts); }
@@ -329,14 +328,13 @@ mlx5e_tc_rule_offload(struct mlx5e_priv *priv,void mlx5e_tc_rule_unoffload (struct mlx5e_priv *priv, -struct mlx5e_tc_flow *flow, +struct mlx5_flow_handle *rule,struct mlx5_flow_attr *attr) {struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; -struct mlx5_flow_handle *rule = flow->rule[0 ];if (attr->flags &MLX5_ATTR_FLAG_CT ) { -mlx5_tc_ct_delete_flow (get_ct_priv (priv), flow, attr); +mlx5_tc_ct_delete_flow (get_ct_priv (priv), attr);return ; }
@@ -1136,7 +1134,7 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv, }if (attr->flags &MLX5_ATTR_FLAG_CT ) - flow->rule[0 ] =mlx5_tc_ct_flow_offload (get_ct_priv (priv), flow, &parse_attr->spec, + flow->rule[0 ] =mlx5_tc_ct_flow_offload (get_ct_priv (priv), &parse_attr->spec, attr, &parse_attr->mod_hdr_acts);else flow->rule[0] = mlx5e_add_offloaded_nic_rule(priv, &parse_attr->spec,
@@ -1171,7 +1169,7 @@ static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv,flow_flag_clear (flow,OFFLOADED );if (attr->flags &MLX5_ATTR_FLAG_CT ) -mlx5_tc_ct_delete_flow (get_ct_priv (flow->priv), flow, attr); +mlx5_tc_ct_delete_flow (get_ct_priv (flow->priv), attr);else if (!IS_ERR_OR_NULL (flow->rule[0 ]))mlx5e_del_offloaded_nic_rule (priv, flow->rule[0 ], attr);
@@ -1210,7 +1208,7 @@ mlx5e_tc_offload_fdb_rules(struct mlx5_eswitch *esw,if (attr->flags &MLX5_ATTR_FLAG_SLOW_PATH )return mlx5_eswitch_add_offloaded_rule (esw, spec, attr); - rule =mlx5e_tc_rule_offload (flow->priv, flow, spec, attr); + rule =mlx5e_tc_rule_offload (flow->priv, spec, attr);if (IS_ERR (rule))return rule;
@@ -1224,7 +1222,7 @@ mlx5e_tc_offload_fdb_rules(struct mlx5_eswitch *esw,return rule; err_rule1: -mlx5e_tc_rule_unoffload (flow->priv, flow, attr); +mlx5e_tc_rule_unoffload (flow->priv, rule, attr);return flow->rule[1 ]; }
@@ -1240,7 +1238,7 @@ void mlx5e_tc_unoffload_fdb_rules(struct mlx5_eswitch *esw,if (attr->esw_attr->split_count)mlx5_eswitch_del_fwd_rule (esw, flow->rule[1 ], attr); -mlx5e_tc_rule_unoffload (flow->priv, flow, attr); +mlx5e_tc_rule_unoffload (flow->priv, flow->rule[0 ], attr); } struct mlx5_flow_handle *
Signature · 1 line
2.34.1
PATCH 16/17 net/mlx5: Introduce software defined steering capabilities
In reply to Saeed MahameedFrom: Dima Chumak <[email protected]>
There are two different internal steering modes, abstracted from the rest of the driver. In order to keep upper layer of the driver agnostic to the differences in capabilities of the steering modes, this patch introduces mlx5_fs_get_capabilities() API to check if a certain software defined capability is supported. It differs from the capabilities exposed by the hardware, as it takes into account the flow steering mode (SMFS/DMFS) currently enabled.
This implementation supports only two capability flags:
MLX5_FLOW_STEERING_CAP_VLAN_PUSH_ON_RX
MLX5_FLOW_STEERING_CAP_VLAN_POP_ON_TX
They map to DR_ACTION_STATE_PUSH_VLAN and DR_ACTION_STATE_POP_VLAN actions, implemented in SW steering earlier in commit f5e22be534e0 ("net/mlx5: DR, Split modify VLAN state to separate pop/push states"). Which enables using of pop/push vlan without restrictions, e.g. doing vlan pop on TX and RX, compared to FW steering that supports only vlan pop on RX and push on TX.
Other capabilities can be added in the future.
--- drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 14 ++++++++++++++ drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h | 3 +++ .../net/ethernet/mellanox/mlx5/core/fs_core.c | 16 ++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/fs_core.h | 7 +++++++ .../ethernet/mellanox/mlx5/core/steering/fs_dr.c | 11 +++++++++++ 5 files changed, 51 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +14 -0
@@ -152,6 +152,12 @@ static int mlx5_cmd_stub_destroy_ns(struct mlx5_flow_root_namespace *ns)return 0 ; } +static u32 mlx5_cmd_stub_get_capabilities (struct mlx5_flow_root_namespace *ns, +enum fs_flow_table_type ft_type) +{ +return 0 ; +} + static int mlx5_cmd_set_slave_root_fdb(struct mlx5_core_dev *master, struct mlx5_core_dev *slave, bool ft_id_valid,
@@ -971,6 +977,12 @@ static int mlx5_cmd_create_match_definer(struct mlx5_flow_root_namespace *ns,return err ? err :MLX5_GET (general_obj_out_cmd_hdr, out, obj_id); } +static u32 mlx5_cmd_get_capabilities (struct mlx5_flow_root_namespace *ns, +enum fs_flow_table_type ft_type) +{ +return 0 ; +} +static const struct mlx5_flow_cmds mlx5_flow_cmds = { .create_flow_table = mlx5_cmd_create_flow_table, .destroy_flow_table = mlx5_cmd_destroy_flow_table,
@@ -990,6 +1002,7 @@ static const struct mlx5_flow_cmds mlx5_flow_cmds = { .set_peer = mlx5_cmd_stub_set_peer, .create_ns = mlx5_cmd_stub_create_ns, .destroy_ns = mlx5_cmd_stub_destroy_ns, + .get_capabilities = mlx5_cmd_get_capabilities, };static const struct mlx5_flow_cmds mlx5_flow_cmd_stubs = {
@@ -1011,6 +1024,7 @@ static const struct mlx5_flow_cmds mlx5_flow_cmd_stubs = { .set_peer = mlx5_cmd_stub_set_peer, .create_ns = mlx5_cmd_stub_create_ns, .destroy_ns = mlx5_cmd_stub_destroy_ns, + .get_capabilities = mlx5_cmd_stub_get_capabilities, };const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds (void )
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h +3 -0
@@ -101,6 +101,9 @@ struct mlx5_flow_cmds { u16 format_id, u32 *match_mask);int (*destroy_match_definer)(struct mlx5_flow_root_namespace *ns,int definer_id); + +u32 (*get_capabilities)(struct mlx5_flow_root_namespace *ns, +enum fs_flow_table_type ft_type); };int mlx5_cmd_fc_alloc (struct mlx5_core_dev *dev,u32 *id);
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +16 -0
@@ -3040,6 +3040,22 @@ void mlx5_fs_ingress_acls_cleanup(struct mlx5_core_dev *dev) steering->esw_ingress_root_ns =NULL ; } +u32 mlx5_fs_get_capabilities (struct mlx5_core_dev *dev,enum mlx5_flow_namespace_type type) +{ +struct mlx5_flow_root_namespace *root; +struct mlx5_flow_namespace *ns; + + ns =mlx5_get_flow_namespace (dev, type); +if (!ns) +return 0 ; + + root =find_root (&ns->node); +if (!root) +return 0 ; + +return root->cmds->get_capabilities (root, root->table_type); +} +static int init_egress_root_ns (struct mlx5_flow_steering *steering) {int err;
drivers/net/ethernet/mellanox/mlx5/core/fs_core.h +7 -0
@@ -120,6 +120,11 @@ enum mlx5_flow_steering_mode {MLX5_FLOW_STEERING_MODE_SMFS }; +enum mlx5_flow_steering_capabilty { +MLX5_FLOW_STEERING_CAP_VLAN_PUSH_ON_RX =1UL <<0 , +MLX5_FLOW_STEERING_CAP_VLAN_POP_ON_TX =1UL <<1 , +}; +struct mlx5_flow_steering {struct mlx5_core_dev *dev;enum mlx5_flow_steering_mode mode;
@@ -301,6 +306,8 @@ void mlx5_fs_egress_acls_cleanup(struct mlx5_core_dev *dev);int mlx5_fs_ingress_acls_init (struct mlx5_core_dev *dev,int total_vports);void mlx5_fs_ingress_acls_cleanup (struct mlx5_core_dev *dev); +u32 mlx5_fs_get_capabilities (struct mlx5_core_dev *dev,enum mlx5_flow_namespace_type type); +struct mlx5_flow_root_namespace *find_root (struct fs_node *node);#define fs_get_obj (v, _node) {v = container_of((_node), typeof(*v), node); }
drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c +11 -0
@@ -735,6 +735,16 @@ static int mlx5_cmd_dr_destroy_ns(struct mlx5_flow_root_namespace *ns)return mlx5dr_domain_destroy (ns->fs_dr_domain.dr_domain); } +static u32 mlx5_cmd_dr_get_capabilities (struct mlx5_flow_root_namespace *ns, +enum fs_flow_table_type ft_type) +{ +if (ft_type !=FS_FT_FDB || +MLX5_CAP_GEN (ns->dev, steering_format_version) !=MLX5_STEERING_FORMAT_CONNECTX_6DX ) +return 0 ; + +return MLX5_FLOW_STEERING_CAP_VLAN_PUSH_ON_RX |MLX5_FLOW_STEERING_CAP_VLAN_POP_ON_TX ; +} +bool mlx5_fs_dr_is_supported (struct mlx5_core_dev *dev) {return mlx5dr_is_supported (dev);
@@ -759,6 +769,7 @@ static const struct mlx5_flow_cmds mlx5_flow_cmds_dr = { .set_peer = mlx5_cmd_dr_set_peer, .create_ns = mlx5_cmd_dr_create_ns, .destroy_ns = mlx5_cmd_dr_destroy_ns, + .get_capabilities = mlx5_cmd_dr_get_capabilities, };const struct mlx5_flow_cmds *mlx5_fs_cmd_get_dr_cmds (void )
Signature · 1 line
2.34.1
PATCH 17/17 net/mlx5: VLAN push on RX, pop on TX
In reply to Saeed MahameedFrom: Dima Chumak <[email protected]>
Some older NIC hardware isn't capable of doing VLAN push on RX and pop on TX.
A workaround has been added in software to support it, but it has a performance penalty since it requires a hairpin + loopback.
There's no such limitation with the newer NICs, so no need to pay the price of the w/a. With this change the software w/a is disabled for certain HW versions and steering modes that support it.
--- .../ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c +3 -1
@@ -224,7 +224,9 @@ mlx5_eswitch_termtbl_required(struct mlx5_eswitch *esw,return false;/* push vlan on RX */ -if (flow_act->action &MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH ) +if (flow_act->action &MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH && + !(mlx5_fs_get_capabilities (esw->dev,MLX5_FLOW_NAMESPACE_FDB ) & +MLX5_FLOW_STEERING_CAP_VLAN_PUSH_ON_RX ))return true;/* hairpin */
Signature · 1 line
2.34.1
Jakub Kicinski
maintainerQuoted 4 lines · On Mon, 10 Jan 2022 17:43:18 -0800 Saeed Mahameed wrote:
This series is mostly refactoring and code improvements in mlx5. For more information please see tag log below.
Please pull and let me know if there is any problem.
We posted the net-next PR yesterday already -
https://lore.kernel.org/all/[email protected]/