mlx5 Connection Tracking in NIC mode
Subsystems (5)
From: Saeed Mahameed <[email protected]>
Hi Dave, Jakub,
This series adds the support for connection tracking in NIC mode, and attached to this series some trivial cleanup patches. v1->v2:
- Remove "fixup!" comment from commit message (Jakub)
- More information and use case description in the tag message (Cover-letter) (Jakub)
For more information please see tag log below.
Please pull and let me know if there is any problem.
Thanks,
Saeed.
---
The following changes since commit 748d1c8a425ec529d541f082ee7a81f6a51fa120:
Merge branch 'devlink-Use-nla_policy-to-validate-range' (2020-09-22 17:38:42 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2020-09-22
for you to fetch changes up to 987cd5f049a2b5ed46901f6a874040a08d21d31f:
net/mlx5: remove unreachable return (2020-09-23 15:44:39 -0700)
----------------------------------------------------------------
mlx5-updates-2020-09-22
This series includes mlx5 updates
1) Add support for Connection Tracking offload in NIC mode. Supporting CT offload in NIC mode on Mellanox cards is useful for scenarios where the dual port NIC serves as a gateway between 2 networks and forwards traffic between these networks.
Since the traffic is not terminated on the host in this case, no use of SRIOV VFs and/or switchdev mode is required.
Today Mellanox NIC cards already support offloading of packet forwarding between physical ports without going to the host so combining it with CT offloading allows users to create a gateway with forwarding and CT (Including NAT) offloading capabilities in non-switchdev mode.
To support connection tracking in non-Switchdev mode (Single NIC mode), we need to make use of the current Connection tracking infrastructure implemented on top of E-Switch and the mlx5 generic flow table chains APIs, to make it work on non-Eswitch steering domain e.g. NIC RX domain, the following was performed:
1.1) Refactor current flow steering chains infrastructure and
updates TC nic mode implementation to use flow table chains.
1.2) Refactor current Connection Tracking (CT) infrastructure to not
assume E-switch backend, and make the CT layer agnostic to underlying steering mode (E-Switch/NIC)
1.3) Plumbing to support CT offload in NIC mode.
2) Trivial code cleanups.
----------------------------------------------------------------
Ariel Levkovich (9):
net/mlx5: Refactor multi chains and prios support net/mlx5: Allow ft level ignore for nic rx tables net/mlx5e: Tc nic flows to use mlx5_chains flow tables net/mlx5e: Split nic tc flow allocation and creation net/mlx5: Refactor tc flow attributes structure net/mlx5e: Add tc chains offload support for nic flows net/mlx5e: rework ct offload init messages net/mlx5e: Support CT offload for tc nic flows net/mlx5e: Keep direct reference to mlx5_core_dev in tc ct
Denis Efremov (2):
net/mlx5e: IPsec: Use kvfree() for memory allocated with kvzalloc() net/mlx5e: Use kfree() to free fd->g in accel_fs_tcp_create_groups()
Oz Shlomo (1):
net/mlx5e: CT: Use the same counter for both directions
Pavel Machek (CIP) (1):
net/mlx5: remove unreachable return
Qinglang Miao (1):
net/mlx5: simplify the return expression of mlx5_ec_init()
Saeed Mahameed (1):
net/mlx5e: TC: Remove unused parameter from mlx5_tc_ct_add_no_trk_match()
drivers/net/ethernet/mellanox/mlx5/core/Makefile | 2 +- drivers/net/ethernet/mellanox/mlx5/core/ecpf.c | 8 +- drivers/net/ethernet/mellanox/mlx5/core/en/fs.h | 7 +- .../net/ethernet/mellanox/mlx5/core/en/rep/tc.c | 22 +- drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 525 +++++++----- drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h | 75 +- .../ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c | 2 +- .../mellanox/mlx5/core/en_accel/ipsec_fs.c | 4 +- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 10 + drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 865 +++++++++++++------ drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 97 +++ .../net/ethernet/mellanox/mlx5/core/esw/chains.c | 944 --------------------- .../net/ethernet/mellanox/mlx5/core/esw/chains.h | 68 -- drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 39 +- .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 309 +++++-- .../mellanox/mlx5/core/eswitch_offloads_termtbl.c | 8 +- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 5 +- .../net/ethernet/mellanox/mlx5/core/lib/clock.c | 2 - .../ethernet/mellanox/mlx5/core/lib/fs_chains.c | 911 ++++++++++++++++++++ .../ethernet/mellanox/mlx5/core/lib/fs_chains.h | 93 ++ 21 files changed, 2339 insertions(+), 1658 deletions(-) delete mode 100644 drivers/net/ethernet/mellanox/mlx5/core/esw/chains.c delete mode 100644 drivers/net/ethernet/mellanox/mlx5/core/esw/chains.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.h
PATCH v2 1/15 net/mlx5: Refactor multi chains and prios support
From: Ariel Levkovich <[email protected]>
Decouple the chains infrastructure from eswitch and make it generic to support other steering namespaces.
The change defines an agnostic data structure to keep all the relevant information for maintaining flow table chaining in any steering namespace. Each namespace that requires table chaining will be required to allocate such data structure.
The chains creation code will receive the steering namespace and flow table parameters from the caller so it will operate agnosticly when creating the required resources to maintain the table chaining function while Parts of the code that are relevant to eswitch specific functionality are moved to eswitch files.
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../ethernet/mellanox/mlx5/core/en/rep/tc.c | 16 +- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 31 +- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 1 - .../net/ethernet/mellanox/mlx5/core/en_tc.c | 12 +- .../ethernet/mellanox/mlx5/core/esw/chains.c | 944 ------------------ .../ethernet/mellanox/mlx5/core/esw/chains.h | 68 -- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 12 +- .../mellanox/mlx5/core/eswitch_offloads.c | 159 ++- .../mellanox/mlx5/core/lib/fs_chains.c | 902 +++++++++++++++++ .../mellanox/mlx5/core/lib/fs_chains.h | 93 ++ 11 files changed, 1174 insertions(+), 1066 deletions(-) delete mode 100644 drivers/net/ethernet/mellanox/mlx5/core/esw/chains.c delete mode 100644 drivers/net/ethernet/mellanox/mlx5/core/esw/chains.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.h
drivers/net/ethernet/mellanox/mlx5/core/Makefile +1 -1
@@ -37,7 +37,7 @@ mlx5_core-$(CONFIG_PCI_HYPERV_INTERFACE) += en/hv_vhca_stats.o mlx5_core-$(CONFIG_MLX5_ESWITCH) += lag_mp.o lib/geneve.o lib/port_tun.o \ en_rep.o en/rep/bond.o en/mod_hdr.o mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en_tc.o en/rep/tc.o en/rep/neigh.o \ - en/mapping.o esw/chains.o en/tc_tun.o \ + en/mapping.o lib/fs_chains.o en/tc_tun.o \ en/tc_tun_vxlan.o en/tc_tun_gre.o en/tc_tun_geneve.o \ en/tc_tun_mplsoudp.o diag/en_tc_tracepoint.o mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o
drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c +8 -8
@@ -12,7 +12,7 @@#include "neigh.h" #include "en_rep.h" #include "eswitch.h" -#include "esw/chains.h" +#include "lib/fs_chains.h" #include "en/tc_ct.h" #include "en/mapping.h" #include "en/tc_tun.h"
@@ -191,7 +191,7 @@ static int mlx5e_rep_setup_ft_cb(enum tc_setup_type type, void *type_data,case TC_SETUP_CLSFLOWER :memcpy (&tmp, f,sizeof (*f)); -if (!mlx5_esw_chains_prios_supported (esw)) +if (!mlx5_chains_prios_supported (esw_chains (esw)))return -EOPNOTSUPP ;/* Re-use tc offload path by moving the ft flow to the
@@ -203,12 +203,12 @@ static int mlx5e_rep_setup_ft_cb(enum tc_setup_type type, void *type_data,* * We only support chain 0 of FT offload. */ -if (tmp.common.prio >=mlx5_esw_chains_get_prio_range (esw)) +if (tmp.common.prio >=mlx5_chains_get_prio_range (esw_chains (esw)))return -EOPNOTSUPP ;if (tmp.common.chain_index !=0 )return -EOPNOTSUPP ; - tmp.common.chain_index =mlx5_esw_chains_get_ft_chain (esw); + tmp.common.chain_index =mlx5_chains_get_nf_ft_chain (esw_chains (esw)); tmp.common.prio++; err =mlx5e_rep_setup_tc_cls_flower (priv, &tmp, flags);memcpy (&f->stats, &tmp.stats,sizeof (f->stats));
@@ -378,12 +378,12 @@ static int mlx5e_rep_indr_setup_ft_cb(enum tc_setup_type type,* * We only support chain 0 of FT offload. */ -if (!mlx5_esw_chains_prios_supported (esw) || - tmp.common.prio >=mlx5_esw_chains_get_prio_range (esw) || +if (!mlx5_chains_prios_supported (esw_chains (esw)) || + tmp.common.prio >=mlx5_chains_get_prio_range (esw_chains (esw)) || tmp.common.chain_index)return -EOPNOTSUPP ; - tmp.common.chain_index =mlx5_esw_chains_get_ft_chain (esw); + tmp.common.chain_index =mlx5_chains_get_nf_ft_chain (esw_chains (esw)); tmp.common.prio++; err =mlx5e_rep_indr_offload (priv->netdev, &tmp, priv, flags);memcpy (&f->stats, &tmp.stats,sizeof (f->stats));
@@ -626,7 +626,7 @@ bool mlx5e_rep_tc_update_skb(struct mlx5_cqe64 *cqe, priv =netdev_priv (skb->dev); esw = priv->mdev->priv.eswitch; - err =mlx5_eswitch_get_chain_for_tag (esw, reg_c0, &chain); + err =mlx5_get_chain_for_tag (esw_chains (esw), reg_c0, &chain);if (err) { netdev_dbg(priv->netdev, "Couldn't find chain for chain tag: %d, err: %d\n",
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +18 -13
@@ -14,7 +14,7 @@#include <linux/workqueue.h> #include <linux/xarray.h> -#include "esw/chains.h" +#include "lib/fs_chains.h" #include "en/tc_ct.h" #include "en/mod_hdr.h" #include "en/mapping.h"
@@ -1485,8 +1485,8 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,* don't go though all prios of this chain as normal tc rules * miss. */ - err =mlx5_esw_chains_get_chain_mapping (esw, attr->chain, - &chain_mapping); + err =mlx5_chains_get_chain_mapping (esw_chains (esw), attr->chain, + &chain_mapping);if (err) {ct_dbg ("Failed to get chain register mapping for chain" ); goto err_get_chain;
@@ -1582,7 +1582,7 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,mlx5_modify_header_dealloc (priv->mdev, pre_ct_attr->modify_hdr); err_mapping:dealloc_mod_hdr_actions (&pre_mod_acts); -mlx5_esw_chains_put_chain_mapping (esw, ct_flow->chain_mapping); +mlx5_chains_put_chain_mapping (esw_chains (esw), ct_flow->chain_mapping); err_get_chain:idr_remove (&ct_priv->fte_ids, fte_id); err_idr:
@@ -1694,7 +1694,7 @@ __mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *ct_priv,if (ct_flow->post_ct_rule) {mlx5_eswitch_del_offloaded_rule (esw, ct_flow->post_ct_rule, &ct_flow->post_ct_attr); -mlx5_esw_chains_put_chain_mapping (esw, ct_flow->chain_mapping); +mlx5_chains_put_chain_mapping (esw_chains (esw), ct_flow->chain_mapping);idr_remove (&ct_priv->fte_ids, ct_flow->fte_id);mlx5_tc_ct_del_ft_cb (ct_priv, ct_flow->ft); }
@@ -1817,14 +1817,14 @@ mlx5_tc_ct_init(struct mlx5_rep_uplink_priv *uplink_priv) ct_priv->esw = esw; ct_priv->netdev = rpriv->netdev; - ct_priv->ct =mlx5_esw_chains_create_global_table (esw); + ct_priv->ct =mlx5_chains_create_global_table (esw_chains (esw));if (IS_ERR (ct_priv->ct)) { err =PTR_ERR (ct_priv->ct);mlx5_tc_ct_init_err (rpriv,"failed to create ct table" , err); goto err_ct_tbl; } - ct_priv->ct_nat =mlx5_esw_chains_create_global_table (esw); + ct_priv->ct_nat =mlx5_chains_create_global_table (esw_chains (esw));if (IS_ERR (ct_priv->ct_nat)) { err =PTR_ERR (ct_priv->ct_nat); mlx5_tc_ct_init_err(rpriv, "failed to create ct nat table",
@@ -1832,7 +1832,7 @@ mlx5_tc_ct_init(struct mlx5_rep_uplink_priv *uplink_priv) goto err_ct_nat_tbl; } - ct_priv->post_ct =mlx5_esw_chains_create_global_table (esw); + ct_priv->post_ct =mlx5_chains_create_global_table (esw_chains (esw));if (IS_ERR (ct_priv->post_ct)) { err =PTR_ERR (ct_priv->post_ct); mlx5_tc_ct_init_err(rpriv, "failed to create post ct table",
@@ -1852,9 +1852,9 @@ mlx5_tc_ct_init(struct mlx5_rep_uplink_priv *uplink_priv)return 0 ; err_post_ct_tbl: -mlx5_esw_chains_destroy_global_table (esw, ct_priv->ct_nat); +mlx5_chains_destroy_global_table (esw_chains (esw), ct_priv->ct_nat); err_ct_nat_tbl: -mlx5_esw_chains_destroy_global_table (esw, ct_priv->ct); +mlx5_chains_destroy_global_table (esw_chains (esw), ct_priv->ct); err_ct_tbl:mapping_destroy (ct_priv->labels_mapping); err_mapping_labels:
@@ -1871,13 +1871,18 @@ void mlx5_tc_ct_clean(struct mlx5_rep_uplink_priv *uplink_priv) {struct mlx5_tc_ct_priv *ct_priv = uplink_priv->ct_priv; +struct mlx5_fs_chains *chains; +struct mlx5_eswitch *esw;if (!ct_priv)return ; -mlx5_esw_chains_destroy_global_table (ct_priv->esw, ct_priv->post_ct); -mlx5_esw_chains_destroy_global_table (ct_priv->esw, ct_priv->ct_nat); -mlx5_esw_chains_destroy_global_table (ct_priv->esw, ct_priv->ct); + esw = ct_priv->esw; + chains =esw_chains (esw); + +mlx5_chains_destroy_global_table (chains, ct_priv->post_ct); +mlx5_chains_destroy_global_table (chains, ct_priv->ct_nat); +mlx5_chains_destroy_global_table (chains, ct_priv->ct);mapping_destroy (ct_priv->zone_mapping);mapping_destroy (ct_priv->labels_mapping);
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +0 -1
@@ -39,7 +39,6 @@#include <net/ipv6_stubs.h> #include "eswitch.h" -#include "esw/chains.h" #include "en.h" #include "en_rep.h" #include "en/txrx.h"
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +6 -6
@@ -57,7 +57,6 @@#include "en/rep/neigh.h" #include "en_tc.h" #include "eswitch.h" -#include "esw/chains.h" #include "fs_core.h" #include "en/port.h" #include "en/tc_tun.h"
@@ -66,6 +65,7 @@#include "en/mod_hdr.h" #include "lib/devcom.h" #include "lib/geneve.h" +#include "lib/fs_chains.h" #include "diag/en_tc_tracepoint.h" #define MLX5_MH_ACT_SZ MLX5_UN_SZ_BYTES(set_add_copy_action_in_auto)
@@ -1180,7 +1180,7 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,int err =0 ;int out_index; -if (!mlx5_esw_chains_prios_supported (esw) && attr->prio !=1 ) { +if (!mlx5_chains_prios_supported (esw_chains (esw)) && attr->prio !=1 ) {NL_SET_ERR_MSG_MOD (extack,"E-switch priorities unsupported, upgrade FW" );return -EOPNOTSUPP ;
@@ -1191,14 +1191,14 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,* FDB_FT_CHAIN which is outside tc range. * See mlx5e_rep_setup_ft_cb(). */ - max_chain =mlx5_esw_chains_get_chain_range (esw); + max_chain =mlx5_chains_get_chain_range (esw_chains (esw));if (!mlx5e_is_ft_flow (flow) && attr->chain > max_chain) {NL_SET_ERR_MSG_MOD (extack,"Requested chain is out of supported range" );return -EOPNOTSUPP ; } - max_prio =mlx5_esw_chains_get_prio_range (esw); + max_prio =mlx5_chains_get_prio_range (esw_chains (esw));if (attr->prio > max_prio) {NL_SET_ERR_MSG_MOD (extack,"Requested priority is out of supported range" );
@@ -3845,7 +3845,7 @@ static int mlx5_validate_goto_chain(struct mlx5_eswitch *esw,u32 actions, struct netlink_ext_ack *extack) { - u32 max_chain = mlx5_esw_chains_get_chain_range(esw); + u32 max_chain = mlx5_chains_get_chain_range(esw_chains(esw));struct mlx5_esw_flow_attr *attr = flow->esw_attr;bool ft_flow =mlx5e_is_ft_flow (flow);u32 dest_chain = act->chain_index;
@@ -3855,7 +3855,7 @@ static int mlx5_validate_goto_chain(struct mlx5_eswitch *esw,return -EOPNOTSUPP ; } -if (!mlx5_esw_chains_backwards_supported (esw) && +if (!mlx5_chains_backwards_supported (esw_chains (esw)) && dest_chain <= attr->chain) {NL_SET_ERR_MSG_MOD (extack,"Goto lower numbered chain isn't supported" );
drivers/net/ethernet/mellanox/mlx5/core/esw/chains.c deleted +0 -944
944 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/esw/chains.h deleted +0 -68
68 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +5 -7
@@ -42,6 +42,7 @@#include <linux/mlx5/vport.h> #include <linux/mlx5/fs.h> #include "lib/mpfs.h" +#include "lib/fs_chains.h" #include "en/tc_ct.h" #ifdef CONFIG_MLX5_ESWITCH
@@ -62,6 +63,9 @@#define mlx5_esw_has_fwd_fdb (dev) \ MLX5_CAP_ESW_FLOWTABLE(dev, fdb_multi_path_to_table) +#define esw_chains (esw) \ + ((esw)->fdb_table.offloads.esw_chains_priv) +struct vport_ingress {struct mlx5_flow_table *acl;struct mlx5_flow_handle *allow_rule;
@@ -154,12 +158,6 @@ struct mlx5_vport {enum mlx5_eswitch_vport_event enabled_events; }; -enum offloads_fdb_flags { -ESW_FDB_CHAINS_AND_PRIOS_SUPPORTED =BIT (0 ), -}; - -struct mlx5_esw_chains_priv ; - struct mlx5_eswitch_fdb { union { struct legacy_fdb {
@@ -183,7 +181,7 @@ struct mlx5_eswitch_fdb {struct mlx5_flow_handle *miss_rule_multi;int vlan_push_pop_refcount; -struct mlx5_esw_chains_priv *esw_chains_priv; +struct mlx5_fs_chains *esw_chains_priv;struct { DECLARE_HASHTABLE(table, 8);/* Protects vports.table */
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +141 -18
258 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c new file +902 -0
902 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.h new file +93 -0
93 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH v2 2/15 net/mlx5: Allow ft level ignore for nic rx tables
In reply to [email protected]From: Ariel Levkovich <[email protected]>
Allow setting a flow table with a lower level as a rule destination in nic rx tables. This is required in order to support table chaining of tc nic flows.
--- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +3 -2
@@ -1595,11 +1595,12 @@ static bool dest_is_valid(struct mlx5_flow_destination *dest,return true;if (ignore_level) { -if (ft->type !=FS_FT_FDB ) +if (ft->type !=FS_FT_FDB && + ft->type !=FS_FT_NIC_RX )return false;if (dest->type ==MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE && - dest->ft->type !=FS_FT_FDB ) + ft->type != dest->ft->type)return false; }
Signature · 1 line
2.26.2
PATCH v2 3/15 net/mlx5e: Tc nic flows to use mlx5_chains flow tables
In reply to [email protected]From: Ariel Levkovich <[email protected]>
Change nic tc flows offload path to use the chains and prios infrastructure for the flow table creation as a preparation to support tc multi chains and priorities for nic flows.
Adding an instance of the table chaining database to the nic tc struct and perform the root table creation and desctuction via the chains api while keeping the limit of a single chain (0) in nic tc mode. This will be extendable to supporting multiple chains in the following patches.
The flow table sizes and default miss table parameters that are provided to the chains creation api are kept the same.
--- .../net/ethernet/mellanox/mlx5/core/en/fs.h | 5 +- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 86 ++++++++++++------- 2 files changed, 60 insertions(+), 31 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/fs.h +4 -1
@@ -12,9 +12,12 @@ enum { };struct mlx5e_tc_table { -/* protects flow table */ +/* Protects the dynamic assignment of the t parameter +* which is the nic tc root table. +*/ struct mutex t_lock;struct mlx5_flow_table *t; +struct mlx5_fs_chains *chains;struct rhashtable ht;
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +56 -30
160 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH v2 4/15 net/mlx5e: Split nic tc flow allocation and creation
In reply to [email protected]From: Ariel Levkovich <[email protected]>
For future support of CT offload with nic tc flows, where the flow rule is not created immediately but rather following a future event, the patch is splitting the nic rule creation and deletion into 2 parts:
1. Creating/Deleting and setting the rule attributes.
2. Creating/Deleting the flow table and flow rule itself.
This way the attributes can be prepared and stored in the flow handle when the tc flow is created but the rule can actually be created at any point in the future, using these pre allocated attributes.
--- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 116 +++++++++++------- .../net/ethernet/mellanox/mlx5/core/en_tc.h | 7 ++ 2 files changed, 77 insertions(+), 46 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +70 -46
@@ -891,39 +891,31 @@ static void mlx5e_hairpin_flow_del(struct mlx5e_priv *priv, flow->hpe =NULL ; } -static int -mlx5e_tc_add_nic_flow (struct mlx5e_priv *priv, -struct mlx5e_tc_flow_parse_attr *parse_attr, -struct mlx5e_tc_flow *flow, -struct netlink_ext_ack *extack) +struct mlx5_flow_handle * +mlx5e_add_offloaded_nic_rule (struct mlx5e_priv *priv, +struct mlx5_flow_spec *spec, +struct mlx5_nic_flow_attr *attr) { -struct mlx5_flow_context *flow_context = &parse_attr->spec.flow_context; -struct mlx5_nic_flow_attr *attr = flow->nic_attr; +struct mlx5_flow_context *flow_context = &spec->flow_context;struct mlx5e_tc_table *tc = &priv->fs.tc; -struct mlx5_core_dev *dev = priv->mdev;struct mlx5_flow_destination dest[2 ] = {};struct mlx5_flow_act flow_act = { .action = attr->action, .flags =FLOW_ACT_NO_APPEND , }; -struct mlx5_fc *counter =NULL ; -int err, dest_ix =0 ; +struct mlx5_flow_handle *rule; +int dest_ix =0 ; flow_context->flags |=FLOW_CONTEXT_HAS_TAG ; flow_context->flow_tag = attr->flow_tag; -if (flow_flag_test (flow,HAIRPIN )) { - err =mlx5e_hairpin_flow_add (priv, flow, parse_attr, extack); -if (err) -return err; - -if (flow_flag_test (flow,HAIRPIN_RSS )) { - dest[dest_ix].type =MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE ; - dest[dest_ix].ft = attr->hairpin_ft; - }else { - dest[dest_ix].type =MLX5_FLOW_DESTINATION_TYPE_TIR ; - dest[dest_ix].tir_num = attr->hairpin_tirn; - } +if (attr->hairpin_ft) { + dest[dest_ix].type =MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE ; + dest[dest_ix].ft = attr->hairpin_ft; + dest_ix++; + }else if (attr->hairpin_tirn) { + dest[dest_ix].type =MLX5_FLOW_DESTINATION_TYPE_TIR ; + dest[dest_ix].tir_num = attr->hairpin_tirn; dest_ix++; }else if (attr->action &MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ) { dest[dest_ix].type =MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE ;
@@ -931,24 +923,14 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv, dest_ix++; } -if (attr->action &MLX5_FLOW_CONTEXT_ACTION_COUNT ) { - counter =mlx5_fc_create (dev, true); -if (IS_ERR (counter)) -return PTR_ERR (counter); - +if (flow_act.action &MLX5_FLOW_CONTEXT_ACTION_COUNT ) { dest[dest_ix].type =MLX5_FLOW_DESTINATION_TYPE_COUNTER ; - dest[dest_ix].counter_id =mlx5_fc_id (counter); + dest[dest_ix].counter_id =mlx5_fc_id (attr->counter); dest_ix++; - attr->counter = counter; } -if (attr->action &MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ) { - err =mlx5e_attach_mod_hdr (priv, flow, parse_attr); +if (attr->action &MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ) flow_act.modify_hdr = attr->modify_hdr; -dealloc_mod_hdr_actions (&parse_attr->mod_hdr_acts); -if (err) -return err; - }mutex_lock (&tc->t_lock);if (IS_ERR_OR_NULL (tc->t)) {
@@ -958,35 +940,77 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv,if (IS_ERR (tc->t)) {mutex_unlock (&tc->t_lock); -NL_SET_ERR_MSG_MOD (extack, -"Failed to create tc offload table" );netdev_err (priv->netdev,"Failed to create tc offload table\n" ); -return PTR_ERR (tc->t); +return ERR_CAST (tc->t); } } +mutex_unlock (&tc->t_lock);if (attr->match_level !=MLX5_MATCH_NONE ) - parse_attr->spec.match_criteria_enable |=MLX5_MATCH_OUTER_HEADERS ; + spec->match_criteria_enable |=MLX5_MATCH_OUTER_HEADERS ; - flow->rule[0 ] =mlx5_add_flow_rules (priv->fs.tc.t, &parse_attr->spec, - &flow_act, dest, dest_ix); -mutex_unlock (&priv->fs.tc.t_lock); + rule =mlx5_add_flow_rules (tc->t, spec, + &flow_act, dest, dest_ix); +if (IS_ERR (rule)) +return ERR_CAST (rule); + +return rule; +} + +static int +mlx5e_tc_add_nic_flow (struct mlx5e_priv *priv, +struct mlx5e_tc_flow_parse_attr *parse_attr, +struct mlx5e_tc_flow *flow, +struct netlink_ext_ack *extack) +{ +struct mlx5_nic_flow_attr *attr = flow->nic_attr; +struct mlx5_core_dev *dev = priv->mdev; +struct mlx5_fc *counter =NULL ; +int err; + +if (flow_flag_test (flow,HAIRPIN )) { + err =mlx5e_hairpin_flow_add (priv, flow, parse_attr, extack); +if (err) +return err; + } + +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; + } + +if (attr->action &MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ) { + err =mlx5e_attach_mod_hdr (priv, flow, parse_attr); +dealloc_mod_hdr_actions (&parse_attr->mod_hdr_acts); +if (err) +return err; + } + + flow->rule[0 ] =mlx5e_add_offloaded_nic_rule (priv, &parse_attr->spec, + attr);return PTR_ERR_OR_ZERO (flow->rule[0 ]); } +void mlx5e_del_offloaded_nic_rule (struct mlx5e_priv *priv, +struct mlx5_flow_handle *rule) +{ +mlx5_del_flow_rules (rule); +} +static void mlx5e_tc_del_nic_flow (struct mlx5e_priv *priv,struct mlx5e_tc_flow *flow) {struct mlx5_nic_flow_attr *attr = flow->nic_attr;struct mlx5e_tc_table *tc = &priv->fs.tc; -struct mlx5_fc *counter =NULL ; - counter = attr->counter;if (!IS_ERR_OR_NULL (flow->rule[0 ])) -mlx5_del_flow_rules (flow->rule[0 ]); -mlx5_fc_destroy (priv->mdev, counter); +mlx5e_del_offloaded_nic_rule (priv, flow->rule[0 ]); +mlx5_fc_destroy (priv->mdev, attr->counter);mutex_lock (&priv->fs.tc.t_lock); if (!mlx5e_tc_num_filters(priv, MLX5_TC_FLAG(NIC_OFFLOAD)) &&
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +7 -0
@@ -181,6 +181,13 @@ void mlx5e_tc_nic_cleanup(struct mlx5e_priv *priv);int mlx5e_setup_tc_block_cb (enum tc_setup_type type,void *type_data,void *cb_priv); +struct mlx5_nic_flow_attr ; +struct mlx5_flow_handle * +mlx5e_add_offloaded_nic_rule (struct mlx5e_priv *priv, +struct mlx5_flow_spec *spec, +struct mlx5_nic_flow_attr *attr); +void mlx5e_del_offloaded_nic_rule (struct mlx5e_priv *priv, +struct mlx5_flow_handle *rule);#else /* CONFIG_MLX5_CLS_ACT */ static inline int mlx5e_tc_nic_init (struct mlx5e_priv *priv) {return 0 ; }static inline void mlx5e_tc_nic_cleanup (struct mlx5e_priv *priv) {}
Signature · 1 line
2.26.2
PATCH v2 5/15 net/mlx5: Refactor tc flow attributes structure
In reply to [email protected]From: Ariel Levkovich <[email protected]>
In order to support chains and connection tracking offload for nic flows, there's a need to introduce a common flow attributes struct so that these features can be agnostic and have access to a single attributes struct, regardless of the flow type.
Therefore, a new tc flow attributes format is introduced to allow access to attributes that are common to eswitch and nic flows.
The common attributes will always get allocated for the new flows, regardless of their type, while the type specific attributes are separated into different structs and will be allocated based on the flow type to avoid memory waste.
When allocating the flow attributes the caller provides the flow steering namespace and according the namespace type the additional space for the extra, type specific, attributes is determined and added to the total attribute allocation size.
In addition, the attributes that are going to be common to both flow types are moved to the common attributes struct.
--- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 99 ++++-- .../ethernet/mellanox/mlx5/core/en/tc_ct.h | 14 +- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 304 ++++++++++-------- .../net/ethernet/mellanox/mlx5/core/en_tc.h | 36 ++- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 27 +- .../mellanox/mlx5/core/eswitch_offloads.c | 150 +++++---- .../mlx5/core/eswitch_offloads_termtbl.c | 8 +- 7 files changed, 376 insertions(+), 262 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +69 -30
@@ -55,8 +55,8 @@ struct mlx5_tc_ct_priv { };struct mlx5_ct_flow { -struct mlx5_esw_flow_attr pre_ct_attr; -struct mlx5_esw_flow_attr post_ct_attr; +struct mlx5_flow_attr *pre_ct_attr; +struct mlx5_flow_attr *post_ct_attr;struct mlx5_flow_handle *pre_ct_rule;struct mlx5_flow_handle *post_ct_rule;struct mlx5_ct_ft *ft;
@@ -67,7 +67,7 @@ struct mlx5_ct_flow {struct mlx5_ct_zone_rule {struct mlx5_flow_handle *rule;struct mlx5e_mod_hdr_handle *mh; -struct mlx5_esw_flow_attr attr; +struct mlx5_flow_attr *attr;bool nat; };
@@ -400,7 +400,7 @@ mlx5_tc_ct_entry_del_rule(struct mlx5_tc_ct_priv *ct_priv, bool nat) {struct mlx5_ct_zone_rule *zone_rule = &entry->zone_rules[nat]; -struct mlx5_esw_flow_attr *attr = &zone_rule->attr; +struct mlx5_flow_attr *attr = zone_rule->attr;struct mlx5_eswitch *esw = ct_priv->esw;ct_dbg ("Deleting ct entry rule in zone %d" , entry->tuple.zone);
@@ -409,6 +409,7 @@ mlx5_tc_ct_entry_del_rule(struct mlx5_tc_ct_priv *ct_priv,mlx5e_mod_hdr_detach (ct_priv->esw->dev, &esw->offloads.mod_hdr, zone_rule->mh);mapping_remove (ct_priv->labels_mapping, attr->ct_attr.ct_labels_id); +kfree (attr); } static void
@@ -588,7 +589,7 @@ mlx5_tc_ct_entry_create_nat(struct mlx5_tc_ct_priv *ct_priv,static int mlx5_tc_ct_entry_create_mod_hdr (struct mlx5_tc_ct_priv *ct_priv, -struct mlx5_esw_flow_attr *attr, +struct mlx5_flow_attr *attr,struct flow_rule *flow_rule,struct mlx5e_mod_hdr_handle **mh,u8 zone_restore_id,bool nat)
@@ -650,9 +651,9 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, bool nat, u8 zone_restore_id) {struct mlx5_ct_zone_rule *zone_rule = &entry->zone_rules[nat]; -struct mlx5_esw_flow_attr *attr = &zone_rule->attr;struct mlx5_eswitch *esw = ct_priv->esw;struct mlx5_flow_spec *spec =NULL ; +struct mlx5_flow_attr *attr;int err; zone_rule->nat = nat;
@@ -661,6 +662,12 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,if (!spec)return -ENOMEM ; + attr =mlx5_alloc_flow_attr (MLX5_FLOW_NAMESPACE_FDB ); +if (!attr) { + err = -ENOMEM ; + goto err_attr; + } + err =mlx5_tc_ct_entry_create_mod_hdr (ct_priv, attr, flow_rule, &zone_rule->mh, zone_restore_id, nat);
@@ -674,7 +681,7 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,MLX5_FLOW_CONTEXT_ACTION_COUNT ; attr->dest_chain =0 ; attr->dest_ft = ct_priv->post_ct; - attr->fdb = nat ? ct_priv->ct_nat : ct_priv->ct; + attr->ft = nat ? ct_priv->ct_nat : ct_priv->ct; attr->outer_match_level =MLX5_MATCH_L4 ; attr->counter = entry->counter; attr->flags |=MLX5_ESW_ATTR_FLAG_NO_IN_PORT ;
@@ -691,6 +698,8 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, goto err_rule; } + zone_rule->attr = attr; +kfree (spec);ct_dbg ("Offloaded ct entry rule in zone %d" , entry->tuple.zone);
@@ -701,6 +710,8 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, &esw->offloads.mod_hdr, zone_rule->mh);mapping_remove (ct_priv->labels_mapping, attr->ct_attr.ct_labels_id); err_mod_hdr: +kfree (attr); +err_attr:kfree (spec);return err; }
@@ -1056,7 +1067,7 @@ mlx5_tc_ct_match_add(struct mlx5e_priv *priv,int mlx5_tc_ct_parse_action (struct mlx5e_priv *priv, -struct mlx5_esw_flow_attr *attr, +struct mlx5_flow_attr *attr,const struct flow_action_entry *act,struct netlink_ext_ack *extack) {
@@ -1429,14 +1440,14 @@ static struct mlx5_flow_handle * __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv, struct mlx5e_tc_flow *flow, struct mlx5_flow_spec *orig_spec, - struct mlx5_esw_flow_attr *attr) + struct mlx5_flow_attr *attr) { struct mlx5_tc_ct_priv *ct_priv = mlx5_tc_ct_get_ct_priv(priv);bool nat = attr->ct_attr.ct_action &TCA_CT_ACT_NAT ;struct mlx5e_tc_mod_hdr_acts pre_mod_acts = {};struct mlx5_flow_spec *post_ct_spec =NULL ;struct mlx5_eswitch *esw = ct_priv->esw; -struct mlx5_esw_flow_attr *pre_ct_attr; +struct mlx5_flow_attr *pre_ct_attr;struct mlx5_modify_hdr *mod_hdr;struct mlx5_flow_handle *rule;struct mlx5_ct_flow *ct_flow;
@@ -1471,10 +1482,22 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv, } ct_flow->fte_id = fte_id; -/* Base esw attributes of both rules on original rule attribute */ - pre_ct_attr = &ct_flow->pre_ct_attr; -memcpy (pre_ct_attr, attr,sizeof (*attr)); -memcpy (&ct_flow->post_ct_attr, attr,sizeof (*attr)); +/* Base flow attributes of both rules on original rule attribute */ + ct_flow->pre_ct_attr =mlx5_alloc_flow_attr (MLX5_FLOW_NAMESPACE_FDB ); +if (!ct_flow->pre_ct_attr) { + err = -ENOMEM ; + goto err_alloc_pre; + } + + ct_flow->post_ct_attr =mlx5_alloc_flow_attr (MLX5_FLOW_NAMESPACE_FDB ); +if (!ct_flow->post_ct_attr) { + err = -ENOMEM ; + goto err_alloc_post; + } + + pre_ct_attr = ct_flow->pre_ct_attr; +memcpy (pre_ct_attr, attr,ESW_FLOW_ATTR_SZ ); +memcpy (ct_flow->post_ct_attr, attr,ESW_FLOW_ATTR_SZ );/* Modify the original rule's action to fwd and modify, leave decap */ pre_ct_attr->action = attr->action &MLX5_FLOW_CONTEXT_ACTION_DECAP ;
@@ -1541,15 +1564,15 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv, fte_id, MLX5_FTE_ID_MASK);/* Put post_ct rule on post_ct fdb */ - ct_flow->post_ct_attr.chain =0 ; - ct_flow->post_ct_attr.prio =0 ; - ct_flow->post_ct_attr.fdb = ct_priv->post_ct; + ct_flow->post_ct_attr->chain =0 ; + ct_flow->post_ct_attr->prio =0 ; + ct_flow->post_ct_attr->ft = ct_priv->post_ct; - ct_flow->post_ct_attr.inner_match_level =MLX5_MATCH_NONE ; - ct_flow->post_ct_attr.outer_match_level =MLX5_MATCH_NONE ; - ct_flow->post_ct_attr.action &= ~(MLX5_FLOW_CONTEXT_ACTION_DECAP ); + ct_flow->post_ct_attr->inner_match_level =MLX5_MATCH_NONE ; + ct_flow->post_ct_attr->outer_match_level =MLX5_MATCH_NONE ; + ct_flow->post_ct_attr->action &= ~(MLX5_FLOW_CONTEXT_ACTION_DECAP ); rule =mlx5_eswitch_add_offloaded_rule (esw, post_ct_spec, - &ct_flow->post_ct_attr); + ct_flow->post_ct_attr); ct_flow->post_ct_rule = rule;if (IS_ERR (ct_flow->post_ct_rule)) { err =PTR_ERR (ct_flow->post_ct_rule);
@@ -1577,13 +1600,17 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv, err_insert_orig:mlx5_eswitch_del_offloaded_rule (ct_priv->esw, ct_flow->post_ct_rule, - &ct_flow->post_ct_attr); + ct_flow->post_ct_attr); err_insert_post_ct:mlx5_modify_header_dealloc (priv->mdev, pre_ct_attr->modify_hdr); err_mapping:dealloc_mod_hdr_actions (&pre_mod_acts);mlx5_chains_put_chain_mapping (esw_chains (esw), ct_flow->chain_mapping); err_get_chain: +kfree (ct_flow->post_ct_attr); +err_alloc_post: +kfree (ct_flow->pre_ct_attr); +err_alloc_pre:idr_remove (&ct_priv->fte_ids, fte_id); err_idr:mlx5_tc_ct_del_ft_cb (ct_priv, ft);
@@ -1597,12 +1624,12 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,static struct mlx5_flow_handle *__mlx5_tc_ct_flow_offload_clear (struct mlx5e_priv *priv,struct mlx5_flow_spec *orig_spec, -struct mlx5_esw_flow_attr *attr, +struct mlx5_flow_attr *attr,struct mlx5e_tc_mod_hdr_acts *mod_acts) {struct mlx5_tc_ct_priv *ct_priv =mlx5_tc_ct_get_ct_priv (priv);struct mlx5_eswitch *esw = ct_priv->esw; -struct mlx5_esw_flow_attr *pre_ct_attr; +struct mlx5_flow_attr *pre_ct_attr;struct mlx5_modify_hdr *mod_hdr;struct mlx5_flow_handle *rule;struct mlx5_ct_flow *ct_flow;
@@ -1613,8 +1640,13 @@ __mlx5_tc_ct_flow_offload_clear(struct mlx5e_priv *priv,return ERR_PTR (-ENOMEM );/* Base esw attributes on original rule attribute */ - pre_ct_attr = &ct_flow->pre_ct_attr; -memcpy (pre_ct_attr, attr,sizeof (*attr)); + pre_ct_attr =mlx5_alloc_flow_attr (MLX5_FLOW_NAMESPACE_FDB ); +if (!pre_ct_attr) { + err = -ENOMEM ; + goto err_attr; + } + +memcpy (pre_ct_attr, attr,ESW_FLOW_ATTR_SZ ); err =mlx5_tc_ct_entry_set_registers (ct_priv, mod_acts,0 ,0 ,0 ,0 );if (err) {
@@ -1644,6 +1676,7 @@ __mlx5_tc_ct_flow_offload_clear(struct mlx5e_priv *priv, } attr->ct_attr.ct_flow = ct_flow; + ct_flow->pre_ct_attr = pre_ct_attr; ct_flow->pre_ct_rule = rule;return rule;
@@ -1652,6 +1685,10 @@ __mlx5_tc_ct_flow_offload_clear(struct mlx5e_priv *priv, err_set_registers:netdev_warn (priv->netdev,"Failed to offload ct clear flow, err %d\n" , err); +kfree (pre_ct_attr); +err_attr: +kfree (ct_flow); +return ERR_PTR (err); }
@@ -1659,7 +1696,7 @@ struct mlx5_flow_handle * mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv, struct mlx5e_tc_flow *flow, struct mlx5_flow_spec *spec, - struct mlx5_esw_flow_attr *attr, + struct mlx5_flow_attr *attr, struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts) { bool clear_action = attr->ct_attr.ct_action & TCA_CT_ACT_CLEAR;
@@ -1684,7 +1721,7 @@ static void __mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *ct_priv, struct mlx5_ct_flow *ct_flow) { - struct mlx5_esw_flow_attr *pre_ct_attr = &ct_flow->pre_ct_attr; + struct mlx5_flow_attr *pre_ct_attr = ct_flow->pre_ct_attr;struct mlx5_eswitch *esw = ct_priv->esw; mlx5_eswitch_del_offloaded_rule(esw, ct_flow->pre_ct_rule,
@@ -1693,18 +1730,20 @@ __mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *ct_priv,if (ct_flow->post_ct_rule) {mlx5_eswitch_del_offloaded_rule (esw, ct_flow->post_ct_rule, - &ct_flow->post_ct_attr); + ct_flow->post_ct_attr);mlx5_chains_put_chain_mapping (esw_chains (esw), ct_flow->chain_mapping);idr_remove (&ct_priv->fte_ids, ct_flow->fte_id);mlx5_tc_ct_del_ft_cb (ct_priv, ct_flow->ft); } +kfree (ct_flow->pre_ct_attr); +kfree (ct_flow->post_ct_attr);kfree (ct_flow); }void mlx5_tc_ct_delete_flow (struct mlx5e_priv *priv,struct mlx5e_tc_flow *flow, -struct mlx5_esw_flow_attr *attr) +struct mlx5_flow_attr *attr) {struct mlx5_tc_ct_priv *ct_priv =mlx5_tc_ct_get_ct_priv (priv);struct mlx5_ct_flow *ct_flow = attr->ct_attr.ct_flow;
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h +7 -7
@@ -10,7 +10,7 @@#include "en.h" -struct mlx5_esw_flow_attr ; +struct mlx5_flow_attr ;struct mlx5e_tc_mod_hdr_acts ;struct mlx5_rep_uplink_priv ;struct mlx5e_tc_flow ;
@@ -101,7 +101,7 @@ mlx5_tc_ct_add_no_trk_match(struct mlx5e_priv *priv, struct mlx5_flow_spec *spec);int mlx5_tc_ct_parse_action (struct mlx5e_priv *priv, -struct mlx5_esw_flow_attr *attr, +struct mlx5_flow_attr *attr,const struct flow_action_entry *act,struct netlink_ext_ack *extack);
@@ -109,12 +109,12 @@ struct mlx5_flow_handle * mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv, struct mlx5e_tc_flow *flow, struct mlx5_flow_spec *spec, - struct mlx5_esw_flow_attr *attr, + struct mlx5_flow_attr *attr, struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts);void mlx5_tc_ct_delete_flow (struct mlx5e_priv *priv,struct mlx5e_tc_flow *flow, -struct mlx5_esw_flow_attr *attr); +struct mlx5_flow_attr *attr); bool mlx5e_tc_ct_restore_flow(struct mlx5_rep_uplink_priv *uplink_priv,
@@ -162,7 +162,7 @@ mlx5_tc_ct_add_no_trk_match(struct mlx5e_priv *priv,static inline int mlx5_tc_ct_parse_action (struct mlx5e_priv *priv, -struct mlx5_esw_flow_attr *attr, +struct mlx5_flow_attr *attr,const struct flow_action_entry *act,struct netlink_ext_ack *extack) {
@@ -175,7 +175,7 @@ static inline struct mlx5_flow_handle * mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv, struct mlx5e_tc_flow *flow, struct mlx5_flow_spec *spec, - struct mlx5_esw_flow_attr *attr, + struct mlx5_flow_attr *attr, struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts) { return ERR_PTR(-EOPNOTSUPP);
@@ -184,7 +184,7 @@ mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,static inline void mlx5_tc_ct_delete_flow (struct mlx5e_priv *priv,struct mlx5e_tc_flow *flow, -struct mlx5_esw_flow_attr *attr) +struct mlx5_flow_attr *attr) { }
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +166 -138
814 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +34 -2
@@ -35,17 +35,48 @@#include <net/pkt_cls.h> #include "en.h" +#include "eswitch.h" +#include "en/tc_ct.h" #define MLX5E_TC_FLOW_ID_MASK 0x0000ffff#ifdef CONFIG_MLX5_ESWITCH +#define ESW_FLOW_ATTR_SZ (sizeof(struct mlx5_flow_attr) +\ + sizeof(struct mlx5_esw_flow_attr)) +int mlx5e_tc_num_filters (struct mlx5e_priv *priv,unsigned long flags);struct mlx5e_tc_update_priv {struct net_device *tun_dev; }; +struct mlx5_nic_flow_attr { +u32 flow_tag; +u32 hairpin_tirn; +struct mlx5_flow_table *hairpin_ft; +}; + +struct mlx5_flow_attr { +u32 action; +struct mlx5_fc *counter; +struct mlx5_modify_hdr *modify_hdr; +struct mlx5_ct_attr ct_attr; +struct mlx5e_tc_flow_parse_attr *parse_attr; +u32 chain; +u16 prio; +u32 dest_chain; +struct mlx5_flow_table *ft; +struct mlx5_flow_table *dest_ft; +u8 inner_match_level; +u8 outer_match_level; +u32 flags; +union { +struct mlx5_esw_flow_attr esw_attr[0 ]; +struct mlx5_nic_flow_attr nic_attr[0 ]; + }; +}; +#if IS_ENABLED (CONFIG_MLX5_CLS_ACT ) struct tunnel_match_key {
@@ -181,11 +212,10 @@ void mlx5e_tc_nic_cleanup(struct mlx5e_priv *priv);int mlx5e_setup_tc_block_cb (enum tc_setup_type type,void *type_data,void *cb_priv); -struct mlx5_nic_flow_attr ;struct mlx5_flow_handle *mlx5e_add_offloaded_nic_rule (struct mlx5e_priv *priv,struct mlx5_flow_spec *spec, -struct mlx5_nic_flow_attr *attr); +struct mlx5_flow_attr *attr);void mlx5e_del_offloaded_nic_rule (struct mlx5e_priv *priv,struct mlx5_flow_handle *rule);#else /* CONFIG_MLX5_CLS_ACT */
@@ -196,6 +226,8 @@ mlx5e_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv) {return -EOPNOTSUPP ; }#endif /* CONFIG_MLX5_CLS_ACT */ +struct mlx5_flow_attr *mlx5_alloc_flow_attr (enum mlx5_flow_namespace_type type); +#else /* CONFIG_MLX5_ESWITCH */ static inline int mlx5e_tc_nic_init (struct mlx5e_priv *priv) {return 0 ; }static inline void mlx5e_tc_nic_cleanup (struct mlx5e_priv *priv) {}
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +7 -20
@@ -328,7 +328,7 @@ struct mlx5_termtbl_handle;bool mlx5_eswitch_termtbl_required (struct mlx5_eswitch *esw, -struct mlx5_esw_flow_attr *attr, +struct mlx5_flow_attr *attr,struct mlx5_flow_act *flow_act,struct mlx5_flow_spec *spec);
@@ -348,19 +348,19 @@ mlx5_eswitch_termtbl_put(struct mlx5_eswitch *esw,struct mlx5_flow_handle *mlx5_eswitch_add_offloaded_rule (struct mlx5_eswitch *esw,struct mlx5_flow_spec *spec, -struct mlx5_esw_flow_attr *attr); +struct mlx5_flow_attr *attr);struct mlx5_flow_handle *mlx5_eswitch_add_fwd_rule (struct mlx5_eswitch *esw,struct mlx5_flow_spec *spec, -struct mlx5_esw_flow_attr *attr); +struct mlx5_flow_attr *attr);void mlx5_eswitch_del_offloaded_rule (struct mlx5_eswitch *esw,struct mlx5_flow_handle *rule, -struct mlx5_esw_flow_attr *attr); +struct mlx5_flow_attr *attr);void mlx5_eswitch_del_fwd_rule (struct mlx5_eswitch *esw,struct mlx5_flow_handle *rule, -struct mlx5_esw_flow_attr *attr); +struct mlx5_flow_attr *attr);struct mlx5_flow_handle * mlx5_eswitch_create_vport_rx_rule(struct mlx5_eswitch *esw, u16 vport,
@@ -400,7 +400,6 @@ struct mlx5_esw_flow_attr {int split_count;int out_count; -int action;__be16 vlan_proto[MLX5_FS_VLAN_DEPTH ];u16 vlan_vid[MLX5_FS_VLAN_DEPTH ];u8 vlan_prio[MLX5_FS_VLAN_DEPTH ];
@@ -412,19 +411,7 @@ struct mlx5_esw_flow_attr {struct mlx5_core_dev *mdev;struct mlx5_termtbl_handle *termtbl; } dests[MLX5_MAX_FLOW_FWD_VPORTS ]; -struct mlx5_modify_hdr *modify_hdr; -u8 inner_match_level; -u8 outer_match_level; -struct mlx5_fc *counter; -u32 chain; -u16 prio; -u32 dest_chain; -u32 flags; -struct mlx5_flow_table *fdb; -struct mlx5_flow_table *dest_ft; -struct mlx5_ct_attr ct_attr;struct mlx5_pkt_reformat *decap_pkt_reformat; -struct mlx5e_tc_flow_parse_attr *parse_attr; }; int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
@@ -450,9 +437,9 @@ int mlx5_devlink_port_function_hw_addr_set(struct devlink *devlink,void *mlx5_eswitch_get_uplink_priv (struct mlx5_eswitch *esw,u8 rep_type);int mlx5_eswitch_add_vlan_action (struct mlx5_eswitch *esw, -struct mlx5_esw_flow_attr *attr); +struct mlx5_flow_attr *attr);int mlx5_eswitch_del_vlan_action (struct mlx5_eswitch *esw, -struct mlx5_esw_flow_attr *attr); +struct mlx5_flow_attr *attr);int __mlx5_eswitch_set_vport_vlan (struct mlx5_eswitch *esw,u16 vport,u16 vlan,u8 qos,u8 set_flags);
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +88 -62
391 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c +5 -3
@@ -3,6 +3,7 @@#include <linux/mlx5/fs.h> #include "eswitch.h" +#include "en_tc.h" #include "fs_core.h" struct mlx5_termtbl_handle {
@@ -228,10 +229,11 @@ static bool mlx5_eswitch_offload_is_uplink_port(const struct mlx5_eswitch *esw,bool mlx5_eswitch_termtbl_required (struct mlx5_eswitch *esw, -struct mlx5_esw_flow_attr *attr, +struct mlx5_flow_attr *attr,struct mlx5_flow_act *flow_act,struct mlx5_flow_spec *spec) { +struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr;int i; if (!MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, termination_table) ||
@@ -244,8 +246,8 @@ mlx5_eswitch_termtbl_required(struct mlx5_eswitch *esw,return true;/* hairpin */ -for (i = attr->split_count; i < attr->out_count; i++) -if (attr->dests[i].rep->vport ==MLX5_VPORT_UPLINK ) +for (i = esw_attr->split_count; i < esw_attr->out_count; i++) +if (esw_attr->dests[i].rep->vport ==MLX5_VPORT_UPLINK )return true;return false;
Signature · 1 line
2.26.2
PATCH v2 6/15 net/mlx5e: Add tc chains offload support for nic flows
In reply to [email protected]From: Ariel Levkovich <[email protected]>
Allow adding nic tc flow rules with goto chain action.
Connecting the nic flows to the mlx5 chains infrastructure in previous patches allows us to support the creation of chained flow tables and rules that direct to another chain for further packet processing. This is a required preparation to support CT offloads for nic tc flows.
We allow the creation of 256 different chains for nic flows since we have 8 bits available for the chain restore tag in case of a miss.
--- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 10 + .../net/ethernet/mellanox/mlx5/core/en_tc.c | 252 ++++++++++++++---- .../net/ethernet/mellanox/mlx5/core/en_tc.h | 34 ++- .../mellanox/mlx5/core/lib/fs_chains.c | 11 +- 4 files changed, 250 insertions(+), 57 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +10 -0
@@ -1260,6 +1260,11 @@ static void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe) }mlx5e_complete_rx_cqe (rq, cqe, cqe_bcnt, skb); + +if (mlx5e_cqe_regb_chain (cqe)) +if (!mlx5e_tc_update_skb (cqe, skb)) + goto free_wqe; +napi_gro_receive (rq->cq.napi, skb); free_wqe:
@@ -1521,6 +1526,11 @@ static void mlx5e_handle_rx_cqe_mpwrq(struct mlx5e_rq *rq, struct mlx5_cqe64 *cq goto mpwrq_cqe_out;mlx5e_complete_rx_cqe (rq, cqe, cqe_bcnt, skb); + +if (mlx5e_cqe_regb_chain (cqe)) +if (!mlx5e_tc_update_skb (cqe, skb)) + goto mpwrq_cqe_out; +napi_gro_receive (rq->cq.napi, skb); mpwrq_cqe_out:
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +197 -55
387 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +33 -1
@@ -77,6 +77,9 @@ struct mlx5_flow_attr { }; }; +#define MLX5E_TC_TABLE_CHAIN_TAG_BITS 16 +#define MLX5E_TC_TABLE_CHAIN_TAG_MASK GENMASK(MLX5E_TC_TABLE_CHAIN_TAG_BITS - 1, 0) +#if IS_ENABLED (CONFIG_MLX5_CLS_ACT ) struct tunnel_match_key {
@@ -164,6 +167,7 @@ enum mlx5e_tc_attr_to_reg {MARK_TO_REG ,LABELS_TO_REG ,FTEID_TO_REG , + NIC_CHAIN_TO_REG, }; struct mlx5e_tc_attr_to_reg_mapping {
@@ -217,13 +221,16 @@ mlx5e_add_offloaded_nic_rule(struct mlx5e_priv *priv,struct mlx5_flow_spec *spec, struct mlx5_flow_attr *attr);void mlx5e_del_offloaded_nic_rule (struct mlx5e_priv *priv, -struct mlx5_flow_handle *rule); +struct mlx5_flow_handle *rule, +struct mlx5_flow_attr *attr); +#else /* CONFIG_MLX5_CLS_ACT */ static inline int mlx5e_tc_nic_init (struct mlx5e_priv *priv) {return 0 ; }static inline void mlx5e_tc_nic_cleanup (struct mlx5e_priv *priv) {}static inline int mlx5e_setup_tc_block_cb (enum tc_setup_type type,void *type_data,void *cb_priv) {return -EOPNOTSUPP ; } +#endif /* CONFIG_MLX5_CLS_ACT */ struct mlx5_flow_attr *mlx5_alloc_flow_attr (enum mlx5_flow_namespace_type type);
@@ -242,4 +249,29 @@ mlx5e_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv) {return -EOPNOTSUPP ; }#endif +#if IS_ENABLED (CONFIG_MLX5_CLS_ACT ) +static inline bool mlx5e_cqe_regb_chain (struct mlx5_cqe64 *cqe) +{ +#if IS_ENABLED (CONFIG_NET_TC_SKB_EXT ) +u32 chain, reg_b; + + reg_b =be32_to_cpu (cqe->ft_metadata); + + chain = reg_b &MLX5E_TC_TABLE_CHAIN_TAG_MASK ; +if (chain) +return true; +#endif + +return false; +} + +bool mlx5e_tc_update_skb (struct mlx5_cqe64 *cqe,struct sk_buff *skb); +#else /* CONFIG_MLX5_CLS_ACT */ +static inline bool mlx5e_cqe_regb_chain (struct mlx5_cqe64 *cqe) +{return false; } +static inline bool +mlx5e_tc_update_skb (struct mlx5_cqe64 *cqe,struct sk_buff *skb) +{return true; } +#endif +#endif /* __MLX5_EN_TC_H__ */
drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c +10 -1
@@ -330,6 +330,12 @@ create_chain_restore(struct fs_chain *chain) err =PTR_ERR (chain->restore_rule); goto err_rule; } + }else if (chains->ns ==MLX5_FLOW_NAMESPACE_KERNEL ) { +/* For NIC RX we don't need a restore rule +* since we write the metadata to reg_b +* that is passed to SW directly. +*/ + chain_to_reg =NIC_CHAIN_TO_REG ; }else { err = -EINVAL ; goto err_rule;
@@ -447,7 +453,10 @@ mlx5_chains_add_miss_rule(struct fs_chain *chain,struct mlx5_flow_destination dest = {};struct mlx5_flow_act act = {}; - act.flags =FLOW_ACT_IGNORE_FLOW_LEVEL |FLOW_ACT_NO_APPEND ; + act.flags =FLOW_ACT_NO_APPEND ; +if (mlx5_chains_ignore_flow_level_supported (chain->chains)) + act.flags |=FLOW_ACT_IGNORE_FLOW_LEVEL ; + act.action =MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ; dest.type =MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE ; dest.ft = next_ft;
Signature · 1 line
2.26.2
PATCH v2 7/15 net/mlx5e: rework ct offload init messages
In reply to [email protected]From: Ariel Levkovich <[email protected]>
The changes are:
- Use mlx5_core print macros instead of netdev_warn since netdev is not always initialized at that stage.
- Print a warning message in case the issue is with lack of support for CT offload without indicating an error.
--- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +17 -22
@@ -1803,24 +1803,14 @@ mlx5_tc_ct_init_check_support(struct mlx5_eswitch *esw,return 0 ; } -static void -mlx5_tc_ct_init_err (struct mlx5e_rep_priv *rpriv,const char *msg,int err) -{ -if (msg) -netdev_warn (rpriv->netdev, -"tc ct offload not supported, %s, err: %d\n" , - msg, err); -else -netdev_warn (rpriv->netdev, -"tc ct offload not supported, err: %d\n" , - err); -} +#define INIT_ERR_PREFIX "tc ct offload init failed"int mlx5_tc_ct_init (struct mlx5_rep_uplink_priv *uplink_priv) {struct mlx5_tc_ct_priv *ct_priv;struct mlx5e_rep_priv *rpriv; +struct mlx5_core_dev *dev;struct mlx5_eswitch *esw;struct mlx5e_priv *priv;const char *msg;
@@ -1828,19 +1818,20 @@ mlx5_tc_ct_init(struct mlx5_rep_uplink_priv *uplink_priv) rpriv = container_of(uplink_priv, struct mlx5e_rep_priv, uplink_priv); priv =netdev_priv (rpriv->netdev); - esw = priv->mdev->priv.eswitch; + dev = priv->mdev; + esw = dev->priv.eswitch; err =mlx5_tc_ct_init_check_support (esw, &msg);if (err) { -mlx5_tc_ct_init_err (rpriv, msg, err); +mlx5_core_warn (dev, +"tc ct offload not supported, %s\n" , + msg); goto err_support; } ct_priv =kzalloc (sizeof (*ct_priv),GFP_KERNEL ); -if (!ct_priv) { -mlx5_tc_ct_init_err (rpriv,NULL , -ENOMEM ); +if (!ct_priv) goto err_alloc; - } ct_priv->zone_mapping =mapping_create (sizeof (u16),0 , true);if (IS_ERR (ct_priv->zone_mapping)) {
@@ -1859,23 +1850,27 @@ mlx5_tc_ct_init(struct mlx5_rep_uplink_priv *uplink_priv) ct_priv->ct =mlx5_chains_create_global_table (esw_chains (esw));if (IS_ERR (ct_priv->ct)) { err =PTR_ERR (ct_priv->ct); -mlx5_tc_ct_init_err (rpriv,"failed to create ct table" , err); +mlx5_core_warn (dev, +"%s, failed to create ct table err: %d\n" , +INIT_ERR_PREFIX , err); goto err_ct_tbl; } ct_priv->ct_nat =mlx5_chains_create_global_table (esw_chains (esw));if (IS_ERR (ct_priv->ct_nat)) { err =PTR_ERR (ct_priv->ct_nat); -mlx5_tc_ct_init_err (rpriv,"failed to create ct nat table" , - err); +mlx5_core_warn (dev, +"%s, failed to create ct nat table err: %d\n" , +INIT_ERR_PREFIX , err); goto err_ct_nat_tbl; } ct_priv->post_ct =mlx5_chains_create_global_table (esw_chains (esw));if (IS_ERR (ct_priv->post_ct)) { err =PTR_ERR (ct_priv->post_ct); -mlx5_tc_ct_init_err (rpriv,"failed to create post ct table" , - err); +mlx5_core_warn (dev, +"%s, failed to create post ct table err: %d\n" , +INIT_ERR_PREFIX , err); goto err_post_ct_tbl; }
Signature · 1 line
2.26.2
PATCH v2 8/15 net/mlx5e: Support CT offload for tc nic flows
In reply to [email protected]From: Ariel Levkovich <[email protected]>
Adding support to perform CT related tc actions and matching on CT states for nic flows.
The ct flows management and handling will be done using a new instance of the ct database that is declared in this patch to keep it separate from the eswitch ct flows database. Offloading and unoffloading ct flows will be done using the existing ct offload api by providing it the relevant ct database reference in each mode.
In addition, refactoring the tc ct api is introduced to make it agnostic to the flow type and perform the resource allocations and rule insertion to the proper steering domain in the device.
In the initialization call, the api requests and stores in the ct database instance all the relevant information that distinguishes between nic flows and esw flows, such as chains database, steering namespace and mod hdr table.
This way the operations of adding and removing ct flows to the device can later performed agnostically to the flow type.
--- .../net/ethernet/mellanox/mlx5/core/en/fs.h | 2 + .../ethernet/mellanox/mlx5/core/en/rep/tc.c | 6 +- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 289 +++++++++--------- .../ethernet/mellanox/mlx5/core/en/tc_ct.h | 54 ++-- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 171 ++++++++--- .../net/ethernet/mellanox/mlx5/core/en_tc.h | 26 ++ 6 files changed, 348 insertions(+), 200 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/fs.h +2 -0
@@ -27,6 +27,8 @@ struct mlx5e_tc_table {struct notifier_block netdevice_nb;struct netdev_net_notifier netdevice_nn; + +struct mlx5_tc_ct_priv *ct; };struct mlx5e_flow_table {
drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c +2 -4
@@ -612,7 +612,6 @@ bool mlx5e_rep_tc_update_skb(struct mlx5_cqe64 *cqe,struct tc_skb_ext *tc_skb_ext;struct mlx5_eswitch *esw;struct mlx5e_priv *priv; -int tunnel_moffset;int err; reg_c0 = (be32_to_cpu (cqe->sop_drop_qpn) &MLX5E_TC_FLOW_ID_MASK );
@@ -647,13 +646,12 @@ bool mlx5e_rep_tc_update_skb(struct mlx5_cqe64 *cqe, uplink_rpriv =mlx5_eswitch_get_uplink_priv (esw,REP_ETH ); uplink_priv = &uplink_rpriv->uplink_priv; -if (!mlx5e_tc_ct_restore_flow (uplink_priv, skb, +if (!mlx5e_tc_ct_restore_flow (uplink_priv->ct_priv, skb, zone_restore_id)) return false; } - tunnel_moffset = mlx5e_tc_attr_to_reg_mappings[TUNNEL_TO_REG ].moffset; - tunnel_id = reg_c1 >> (8 * tunnel_moffset); + tunnel_id = reg_c1 >>REG_MAPPING_SHIFT (TUNNEL_TO_REG );return mlx5e_restore_tunnel (priv, skb, tc_priv, tunnel_id);#endif /* CONFIG_NET_TC_SKB_EXT */
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +148 -141
724 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h +33 -21
144 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +137 -34
364 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +26 -0
@@ -42,8 +42,14 @@#ifdef CONFIG_MLX5_ESWITCH +#define NIC_FLOW_ATTR_SZ (sizeof(struct mlx5_flow_attr) +\ + sizeof(struct mlx5_nic_flow_attr))#define ESW_FLOW_ATTR_SZ (sizeof(struct mlx5_flow_attr) +\ sizeof(struct mlx5_esw_flow_attr)) +#define ns_to_attr_sz (ns) (((ns) == MLX5_FLOW_NAMESPACE_FDB) ?\ + ESW_FLOW_ATTR_SZ :\ + NIC_FLOW_ATTR_SZ) +int mlx5e_tc_num_filters (struct mlx5e_priv *priv,unsigned long flags);
@@ -124,6 +130,7 @@ enum {int mlx5e_tc_esw_init (struct rhashtable *tc_ht);void mlx5e_tc_esw_cleanup (struct rhashtable *tc_ht); +bool mlx5e_is_eswitch_flow (struct mlx5e_tc_flow *flow);int mlx5e_configure_flower (struct net_device *dev,struct mlx5e_priv *priv,struct flow_cls_offload *f,unsigned long flags);
@@ -168,6 +175,7 @@ enum mlx5e_tc_attr_to_reg {LABELS_TO_REG ,FTEID_TO_REG ,NIC_CHAIN_TO_REG , + NIC_ZONE_RESTORE_TO_REG, }; struct mlx5e_tc_attr_to_reg_mapping {
@@ -185,6 +193,7 @@ bool mlx5e_is_valid_eswitch_fwd_dev(struct mlx5e_priv *priv,int mlx5e_tc_match_to_reg_set (struct mlx5_core_dev *mdev,struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts, +enum mlx5_flow_namespace_type ns,enum mlx5e_tc_attr_to_reg type,u32 data);
@@ -224,6 +233,15 @@ void mlx5e_del_offloaded_nic_rule(struct mlx5e_priv *priv,struct mlx5_flow_handle *rule, struct mlx5_flow_attr *attr); +struct mlx5_flow_handle * +mlx5_tc_rule_insert (struct mlx5e_priv *priv, +struct mlx5_flow_spec *spec, +struct mlx5_flow_attr *attr); +void +mlx5_tc_rule_delete (struct mlx5e_priv *priv, +struct mlx5_flow_handle *rule, +struct mlx5_flow_attr *attr); +#else /* CONFIG_MLX5_CLS_ACT */ static inline int mlx5e_tc_nic_init (struct mlx5e_priv *priv) {return 0 ; }static inline void mlx5e_tc_nic_cleanup (struct mlx5e_priv *priv) {}
@@ -235,6 +253,14 @@ mlx5e_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv)struct mlx5_flow_attr *mlx5_alloc_flow_attr (enum mlx5_flow_namespace_type type); +struct mlx5_flow_handle * +mlx5e_add_offloaded_nic_rule (struct mlx5e_priv *priv, +struct mlx5_flow_spec *spec, +struct mlx5_flow_attr *attr); +void mlx5e_del_offloaded_nic_rule (struct mlx5e_priv *priv, +struct mlx5_flow_handle *rule, +struct mlx5_flow_attr *attr); +#else /* CONFIG_MLX5_ESWITCH */ static inline int mlx5e_tc_nic_init (struct mlx5e_priv *priv) {return 0 ; }static inline void mlx5e_tc_nic_cleanup (struct mlx5e_priv *priv) {}
Signature · 1 line
2.26.2
PATCH v2 9/15 net/mlx5e: CT: Use the same counter for both directions
In reply to [email protected]From: Oz Shlomo <[email protected]>
A connection is represented by two 5-tuple entries, one for each direction. Currently, each direction allocates its own hw counter, which is inefficient as ct aging is managed per connection.
Share the counter that was allocated for the original direction with the reverse direction.
--- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 94 +++++++++++++++++-- 1 file changed, 85 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +85 -9
@@ -51,6 +51,7 @@ struct mlx5_tc_ct_priv {struct mlx5_flow_table *ct_nat;struct mlx5_flow_table *post_ct;struct mutex control_lock;/* guards parallel adds/dels */ +struct mutex shared_counter_lock;struct mapping_ctx *zone_mapping;struct mapping_ctx *labels_mapping;enum mlx5_flow_namespace_type ns_type;
@@ -117,11 +118,16 @@ struct mlx5_ct_tuple {u16 zone; }; +struct mlx5_ct_shared_counter { +struct mlx5_fc *counter; +refcount_t refcount; +}; +struct mlx5_ct_entry {struct rhash_head node;struct rhash_head tuple_node;struct rhash_head tuple_nat_node; -struct mlx5_fc *counter; +struct mlx5_ct_shared_counter *shared_counter;unsigned long cookie;unsigned long restore_cookie;struct mlx5_ct_tuple tuple;
@@ -385,6 +391,16 @@ mlx5_tc_ct_set_tuple_match(struct mlx5e_priv *priv, struct mlx5_flow_spec *spec,return 0 ; } +static void +mlx5_tc_ct_shared_counter_put (struct mlx5_tc_ct_priv *ct_priv,struct mlx5_ct_entry *entry) +{ +if (!refcount_dec_and_test (&entry->shared_counter->refcount)) +return ; + +mlx5_fc_destroy (ct_priv->esw->dev, entry->shared_counter->counter); +kfree (entry->shared_counter); +} + static void mlx5_tc_ct_entry_del_rule(struct mlx5_tc_ct_priv *ct_priv, struct mlx5_ct_entry *entry,
@@ -409,7 +425,6 @@ mlx5_tc_ct_entry_del_rules(struct mlx5_tc_ct_priv *ct_priv,mlx5_tc_ct_entry_del_rule (ct_priv, entry, true);mlx5_tc_ct_entry_del_rule (ct_priv, entry, false); -mlx5_fc_destroy (ct_priv->esw->dev, entry->counter); } static struct flow_action_entry *
@@ -683,7 +698,7 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, attr->dest_ft = ct_priv->post_ct; attr->ft = nat ? ct_priv->ct_nat : ct_priv->ct; attr->outer_match_level =MLX5_MATCH_L4 ; - attr->counter = entry->counter; + attr->counter = entry->shared_counter->counter; attr->flags |=MLX5_ESW_ATTR_FLAG_NO_IN_PORT ;mlx5_tc_ct_set_tuple_match (netdev_priv (ct_priv->netdev), spec, flow_rule);
@@ -716,18 +731,73 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,return err; } +static struct mlx5_ct_shared_counter * +mlx5_tc_ct_shared_counter_get (struct mlx5_tc_ct_priv *ct_priv, +struct mlx5_ct_entry *entry) +{ +struct mlx5_ct_tuple rev_tuple = entry->tuple; +struct mlx5_ct_shared_counter *shared_counter; +struct mlx5_eswitch *esw = ct_priv->esw; +struct mlx5_ct_entry *rev_entry; +__be16 tmp_port; + +/* get the reversed tuple */ + tmp_port = rev_tuple.port.src; + rev_tuple.port.src = rev_tuple.port.dst; + rev_tuple.port.dst = tmp_port; + +if (rev_tuple.addr_type ==FLOW_DISSECTOR_KEY_IPV4_ADDRS ) { +__be32 tmp_addr = rev_tuple.ip.src_v4; + + rev_tuple.ip.src_v4 = rev_tuple.ip.dst_v4; + rev_tuple.ip.dst_v4 = tmp_addr; + }else if (rev_tuple.addr_type ==FLOW_DISSECTOR_KEY_IPV6_ADDRS ) { +struct in6_addr tmp_addr = rev_tuple.ip.src_v6; + + rev_tuple.ip.src_v6 = rev_tuple.ip.dst_v6; + rev_tuple.ip.dst_v6 = tmp_addr; + }else { +return ERR_PTR (-EOPNOTSUPP ); + } + +/* Use the same counter as the reverse direction */ +mutex_lock (&ct_priv->shared_counter_lock); + rev_entry =rhashtable_lookup_fast (&ct_priv->ct_tuples_ht, &rev_tuple, + tuples_ht_params); +if (rev_entry) { +if (refcount_inc_not_zero (&rev_entry->shared_counter->refcount)) { +mutex_unlock (&ct_priv->shared_counter_lock); +return rev_entry->shared_counter; + } + } +mutex_unlock (&ct_priv->shared_counter_lock); + + shared_counter =kzalloc (sizeof (*shared_counter),GFP_KERNEL ); +if (!shared_counter) +return ERR_PTR (-ENOMEM ); + + shared_counter->counter =mlx5_fc_create (esw->dev, true); +if (IS_ERR (shared_counter->counter)) { +ct_dbg ("Failed to create counter for ct entry" ); +kfree (shared_counter); +return ERR_PTR (PTR_ERR (shared_counter->counter)); + } + +refcount_set (&shared_counter->refcount,1 ); +return shared_counter; +} +static int mlx5_tc_ct_entry_add_rules (struct mlx5_tc_ct_priv *ct_priv,struct flow_rule *flow_rule,struct mlx5_ct_entry *entry,u8 zone_restore_id) { -struct mlx5_eswitch *esw = ct_priv->esw;int err; - entry->counter =mlx5_fc_create (esw->dev, true); -if (IS_ERR (entry->counter)) { - err =PTR_ERR (entry->counter); + entry->shared_counter =mlx5_tc_ct_shared_counter_get (ct_priv, entry); +if (IS_ERR (entry->shared_counter)) { + err =PTR_ERR (entry->shared_counter);ct_dbg ("Failed to create counter for ct entry" );return err; }
@@ -747,7 +817,7 @@ mlx5_tc_ct_entry_add_rules(struct mlx5_tc_ct_priv *ct_priv, err_nat:mlx5_tc_ct_entry_del_rule (ct_priv, entry, false); err_orig: -mlx5_fc_destroy (esw->dev, entry->counter); +mlx5_tc_ct_shared_counter_put (ct_priv, entry);return err; }
@@ -837,12 +907,16 @@ mlx5_tc_ct_del_ft_entry(struct mlx5_tc_ct_priv *ct_priv, struct mlx5_ct_entry *entry) {mlx5_tc_ct_entry_del_rules (ct_priv, entry); +mutex_lock (&ct_priv->shared_counter_lock);if (entry->tuple_node.next)rhashtable_remove_fast (&ct_priv->ct_tuples_nat_ht, &entry->tuple_nat_node, tuples_nat_ht_params);rhashtable_remove_fast (&ct_priv->ct_tuples_ht, &entry->tuple_node, tuples_ht_params); +mutex_unlock (&ct_priv->shared_counter_lock); +mlx5_tc_ct_shared_counter_put (ct_priv, entry); + } static int
@@ -879,7 +953,7 @@ mlx5_tc_ct_block_flow_offload_stats(struct mlx5_ct_ft *ft,if (!entry)return -ENOENT ; -mlx5_fc_query_cached (entry->counter, &bytes, &packets, &lastuse); +mlx5_fc_query_cached (entry->shared_counter->counter, &bytes, &packets, &lastuse);flow_stats_update (&f->stats, bytes, packets,0 , lastuse,FLOW_ACTION_HW_STATS_DELAYED );
@@ -1892,6 +1966,7 @@ mlx5_tc_ct_init(struct mlx5e_priv *priv, struct mlx5_fs_chains *chains,idr_init (&ct_priv->fte_ids);mutex_init (&ct_priv->control_lock); +mutex_init (&ct_priv->shared_counter_lock);rhashtable_init (&ct_priv->zone_ht, &zone_params);rhashtable_init (&ct_priv->ct_tuples_ht, &tuples_ht_params);rhashtable_init (&ct_priv->ct_tuples_nat_ht, &tuples_nat_ht_params);
@@ -1934,6 +2009,7 @@ mlx5_tc_ct_clean(struct mlx5_tc_ct_priv *ct_priv)rhashtable_destroy (&ct_priv->ct_tuples_nat_ht);rhashtable_destroy (&ct_priv->zone_ht);mutex_destroy (&ct_priv->control_lock); +mutex_destroy (&ct_priv->shared_counter_lock);idr_destroy (&ct_priv->fte_ids);kfree (ct_priv); }
Signature · 1 line
2.26.2
Re: [net-next V2 09/15] net/mlx5e: CT: Use the same counter for both directions
Quoted 1 line · On Wed, Sep 23, 2020 at 03:48:18PM -0700, [email protected] wrote:
From: Oz Shlomo <[email protected]>
Sorry for reviving this one, but seemed better for the context.
Quoted 7 lines
A connection is represented by two 5-tuple entries, one for each direction. Currently, each direction allocates its own hw counter, which is inefficient as ct aging is managed per connection.
Share the counter that was allocated for the original direction with the reverse direction.
Yes, aging is done per connection, but the stats are not. With this patch, with netperf TCP_RR test, I get this: (mangled for readability)
# grep 172.0.0.4 /proc/net/nf_conntrack ipv4 2 tcp 6 src=172.0.0.3 dst=172.0.0.4 sport=34018 dport=33396 packets=3941992 bytes=264113427 src=172.0.0.4 dst=172.0.0.3 sport=33396 dport=34018 packets=4 bytes=218 [HW_OFFLOAD] mark=0 secctx=system_u:object_r:unlabeled_t:s0 zone=0 use=3
while without it (594e31bceb + act_ct patch to enable it posted yesterday + revert), I get:
# grep 172.0.0.4 /proc/net/nf_conntrack ipv4 2 tcp 6 src=172.0.0.3 dst=172.0.0.4 sport=41856 dport=32776 packets=1876763 bytes=125743084 src=172.0.0.4 dst=172.0.0.3 sport=32776 dport=41856 packets=1876761 bytes=125742951 [HW_OFFLOAD] mark=0 secctx=system_u:object_r:unlabeled_t:s0 zone=0 use=3
The same is visible on 'ovs-appctl dpctl/dump-conntrack -s' then. Summing both directions in one like this is at least very misleading. Seems this change was motivated only by hw resources constrains. That said, I'm wondering, can this change be reverted somehow?
Marcelo
Re: [net-next V2 09/15] net/mlx5e: CT: Use the same counter for both directions
Quoted 37 lines · Marcelo Ricardo Leitner
Quoted 1 line · On Wed, Sep 23, 2020 at 03:48:18PM -0700, [email protected] wrote:
From: Oz Shlomo <[email protected]>
Sorry for reviving this one, but seemed better for the context.
Quoted 8 lines
A connection is represented by two 5-tuple entries, one for each direction.
Currently, each direction allocates its own hw counter, which is inefficient as ct aging is managed per connection.Share the counter that was allocated for the original direction with the
reverse direction.Yes, aging is done per connection, but the stats are not. With this patch, with netperf
TCP_RRtest, I get this: (mangled for readability)# grep 172.0.0.4 /proc/net/nf_conntrack ipv4 2 tcp 6 src=172.0.0.3 dst=172.0.0.4 sport=34018 dport=33396 packets=3941992 bytes=264113427 src=172.0.0.4 dst=172.0.0.3 sport=33396 dport=34018 packets=4 bytes=218 [HW_OFFLOAD] mark=0 secctx=system_u:object_r:unlabeled_t:s0 zone=0 use=3while without it (
594e31bceb+act_ctpatch to enable it posted yesterday + revert), I get:# grep 172.0.0.4 /proc/net/nf_conntrack ipv4 2 tcp 6 src=172.0.0.3 dst=172.0.0.4 sport=41856 dport=32776 packets=1876763 bytes=125743084 src=172.0.0.4 dst=172.0.0.3 sport=32776 dport=41856 packets=1876761 bytes=125742951 [HW_OFFLOAD] mark=0 secctx=system_u:object_r:unlabeled_t:s0 zone=0 use=3
Quoted 6 lines
The same is visible on 'ovs-appctl dpctl/dump-conntrack -s' then. Summing both directions in one like this is at least very misleading. Seems this change was motivated only by hw resources constrains. That said, I'm wondering, can this change be reverted somehow?
Marcelo
Hi Marcelo, thanks for the report,
Sorry i am not familiar with this /procfs
Oz, Ariel, Roi, what is your take on this, it seems that we changed the behavior of stats incorrectly.
Thanks,
Saeed.
Re: [net-next V2 09/15] net/mlx5e: CT: Use the same counter for both directions
Hi Marcelo,
Quoted 43 lines · Saeed Mahameed
Quoted 42 lines · Marcelo Ricardo Leitner
Quoted 1 line · On Wed, Sep 23, 2020 at 03:48:18PM -0700, [email protected] wrote:
From: Oz Shlomo <[email protected]>
Sorry for reviving this one, but seemed better for the context.
Quoted 8 lines
A connection is represented by two 5-tuple entries, one for each direction.
Currently, each direction allocates its own hw counter, which is inefficient as ct aging is managed per connection.Share the counter that was allocated for the original direction with the
reverse direction.Yes, aging is done per connection, but the stats are not. With this patch, with netperf
TCP_RRtest, I get this: (mangled for readability)# grep 172.0.0.4 /proc/net/nf_conntrack ipv4 2 tcp 6 src=172.0.0.3 dst=172.0.0.4 sport=34018 dport=33396 packets=3941992 bytes=264113427 src=172.0.0.4 dst=172.0.0.3 sport=33396 dport=34018 packets=4 bytes=218 [HW_OFFLOAD] mark=0 secctx=system_u:object_r:unlabeled_t:s0 zone=0 use=3while without it (
594e31bceb+act_ctpatch to enable it posted yesterday + revert), I get:# grep 172.0.0.4 /proc/net/nf_conntrack ipv4 2 tcp 6 src=172.0.0.3 dst=172.0.0.4 sport=41856 dport=32776 packets=1876763 bytes=125743084 src=172.0.0.4 dst=172.0.0.3 sport=32776 dport=41856 packets=1876761 bytes=125742951 [HW_OFFLOAD] mark=0 secctx=system_u:object_r:unlabeled_t:s0 zone=0 use=3The same is visible on 'ovs-appctl dpctl/dump-conntrack -s' then. Summing both directions in one like this is at least very misleading. Seems this change was motivated only by hw resources constrains. That said, I'm wondering, can this change be reverted somehow?
Quoted 6 lines
Quoted 1 line
Marcelo
Hi Marcelo, thanks for the report,
Sorry i am not familiar with this /procfs
Oz, Ariel, Roi, what is your take on this, it seems that we changed the behavior of stats incorrectly.
Indeed we overlooked the CT accounting extension.
We will submit a driver fix.
Quoted 5 lines
Thanks,
Saeed.
Re: [net-next V2 09/15] net/mlx5e: CT: Use the same counter for both directions
Quoted 2 lines · Oz Shlomo
Quoted 1 line · Saeed Mahameed
On Fri, 2020-11-27 at 11:01 -0300, Marcelo Ricardo Leitner wrote:
...
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
The same is visible on 'ovs-appctl dpctl/dump-conntrack -s' then. Summing both directions in one like this is at least very misleading. Seems this change was motivated only by hw resources constrains. That said, I'm wondering, can this change be reverted somehow?
Marcelo
Quoted 7 lines
Quoted 4 lines
Hi Marcelo, thanks for the report,
Sorry i am not familiar with this /procfs
Oz, Ariel, Roi, what is your take on this, it seems that we changed the behavior of stats incorrectly.Indeed we overlooked the CT accounting extension.
We will submit a driver fix.
Cool. Thanks for confirming it, Oz.
Marcelo
PATCH v2 10/15 net/mlx5e: TC: Remove unused parameter from mlx5_tc_ct_add_no_trk_match()
In reply to [email protected]From: Saeed Mahameed <[email protected]>
priv is never used in this function
--- drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 4 +--- drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h | 7 ++----- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +1 -3
@@ -1026,9 +1026,7 @@ mlx5_tc_ct_skb_to_tuple(struct sk_buff *skb, struct mlx5_ct_tuple *tuple,return false; } -int -mlx5_tc_ct_add_no_trk_match (struct mlx5e_priv *priv, -struct mlx5_flow_spec *spec) +int mlx5_tc_ct_add_no_trk_match (struct mlx5_flow_spec *spec) {u32 ctstate =0 , ctstate_mask =0 ;
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h +2 -5
@@ -108,9 +108,7 @@ mlx5_tc_ct_match_add(struct mlx5_tc_ct_priv *priv,struct flow_cls_offload *f, struct mlx5_ct_attr *ct_attr, struct netlink_ext_ack *extack); -int -mlx5_tc_ct_add_no_trk_match (struct mlx5e_priv *priv, -struct mlx5_flow_spec *spec); +int mlx5_tc_ct_add_no_trk_match (struct mlx5_flow_spec *spec); int mlx5_tc_ct_parse_action(struct mlx5_tc_ct_priv *priv, struct mlx5_flow_attr *attr,
@@ -167,8 +165,7 @@ mlx5_tc_ct_match_add(struct mlx5_tc_ct_priv *priv, }static inline int -mlx5_tc_ct_add_no_trk_match (struct mlx5e_priv *priv, -struct mlx5_flow_spec *spec) +mlx5_tc_ct_add_no_trk_match (struct mlx5_flow_spec *spec) {return 0 ; }
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1 -1
@@ -3233,7 +3233,7 @@ static bool modify_header_match_supported(struct mlx5e_priv *priv,* we can't restore ct state */ if (!ct_clear && modify_tuple && -mlx5_tc_ct_add_no_trk_match (priv, spec)) { +mlx5_tc_ct_add_no_trk_match (spec)) {NL_SET_ERR_MSG_MOD (extack,"can't offload tuple modify header with ct matches" ); netdev_info(priv->netdev,
Signature · 1 line
2.26.2
PATCH v2 11/15 net/mlx5e: Keep direct reference to mlx5_core_dev in tc ct
In reply to [email protected]From: Ariel Levkovich <[email protected]>
Keep and use a direct reference to the mlx5 core device in all of tc_ct code instead of accessing it via a pointer to mlx5 eswitch in order to support nic mode ct offload for VF devices that don't have a valid eswitch pointer set.
--- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +18 -19
@@ -39,7 +39,7 @@ netdev_dbg(ct_priv->netdev, "ct_debug: " fmt "\n", ##args) struct mlx5_tc_ct_priv { - struct mlx5_eswitch *esw; + struct mlx5_core_dev *dev; const struct net_device *netdev; struct mod_hdr_tbl *mod_hdr_tbl; struct idr fte_ids;
@@ -397,7 +397,7 @@ mlx5_tc_ct_shared_counter_put(struct mlx5_tc_ct_priv *ct_priv, struct mlx5_ct_enif (!refcount_dec_and_test (&entry->shared_counter->refcount))return ; -mlx5_fc_destroy (ct_priv->esw->dev, entry->shared_counter->counter); +mlx5_fc_destroy (ct_priv->dev, entry->shared_counter->counter);kfree (entry->shared_counter); }
@@ -412,7 +412,7 @@ mlx5_tc_ct_entry_del_rule(struct mlx5_tc_ct_priv *ct_priv,ct_dbg ("Deleting ct entry rule in zone %d" , entry->tuple.zone);mlx5_tc_rule_delete (netdev_priv (ct_priv->netdev), zone_rule->rule, attr); -mlx5e_mod_hdr_detach (ct_priv->esw->dev, +mlx5e_mod_hdr_detach (ct_priv->dev, ct_priv->mod_hdr_tbl, zone_rule->mh);mapping_remove (ct_priv->labels_mapping, attr->ct_attr.ct_labels_id);kfree (attr);
@@ -424,7 +424,6 @@ mlx5_tc_ct_entry_del_rules(struct mlx5_tc_ct_priv *ct_priv, {mlx5_tc_ct_entry_del_rule (ct_priv, entry, true);mlx5_tc_ct_entry_del_rule (ct_priv, entry, false); - } static struct flow_action_entry *
@@ -451,25 +450,25 @@ mlx5_tc_ct_entry_set_registers(struct mlx5_tc_ct_priv *ct_priv, u8 zone_restore_id) {enum mlx5_flow_namespace_type ns = ct_priv->ns_type; -struct mlx5_eswitch *esw = ct_priv->esw; +struct mlx5_core_dev *dev = ct_priv->dev;int err; - err =mlx5e_tc_match_to_reg_set (esw->dev, mod_acts, ns, + err =mlx5e_tc_match_to_reg_set (dev, mod_acts, ns,CTSTATE_TO_REG , ct_state);if (err)return err; - err =mlx5e_tc_match_to_reg_set (esw->dev, mod_acts, ns, + err =mlx5e_tc_match_to_reg_set (dev, mod_acts, ns,MARK_TO_REG , mark);if (err)return err; - err =mlx5e_tc_match_to_reg_set (esw->dev, mod_acts, ns, + err =mlx5e_tc_match_to_reg_set (dev, mod_acts, ns,LABELS_TO_REG , labels_id);if (err)return err; - err =mlx5e_tc_match_to_reg_set (esw->dev, mod_acts, ns, + err =mlx5e_tc_match_to_reg_set (dev, mod_acts, ns,ZONE_RESTORE_TO_REG , zone_restore_id);if (err)return err;
@@ -479,7 +478,7 @@ mlx5_tc_ct_entry_set_registers(struct mlx5_tc_ct_priv *ct_priv,* reg_b upon miss. */ if (ns !=MLX5_FLOW_NAMESPACE_FDB ) { - err =mlx5e_tc_match_to_reg_set (esw->dev, mod_acts, ns, + err =mlx5e_tc_match_to_reg_set (dev, mod_acts, ns,NIC_ZONE_RESTORE_TO_REG , zone_restore_id);if (err)return err;
@@ -564,7 +563,7 @@ mlx5_tc_ct_entry_create_nat(struct mlx5_tc_ct_priv *ct_priv, struct mlx5e_tc_mod_hdr_acts *mod_acts) {struct flow_action *flow_action = &flow_rule->action; -struct mlx5_core_dev *mdev = ct_priv->esw->dev; +struct mlx5_core_dev *mdev = ct_priv->dev;struct flow_action_entry *act;size_t action_size;char *modact;
@@ -640,7 +639,7 @@ mlx5_tc_ct_entry_create_mod_hdr(struct mlx5_tc_ct_priv *ct_priv,if (err) goto err_mapping; - *mh =mlx5e_mod_hdr_attach (ct_priv->esw->dev, + *mh =mlx5e_mod_hdr_attach (ct_priv->dev, ct_priv->mod_hdr_tbl, ct_priv->ns_type, &mod_acts);
@@ -721,7 +720,7 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,return 0 ; err_rule: -mlx5e_mod_hdr_detach (ct_priv->esw->dev, +mlx5e_mod_hdr_detach (ct_priv->dev, ct_priv->mod_hdr_tbl, zone_rule->mh);mapping_remove (ct_priv->labels_mapping, attr->ct_attr.ct_labels_id); err_mod_hdr:
@@ -737,7 +736,7 @@ mlx5_tc_ct_shared_counter_get(struct mlx5_tc_ct_priv *ct_priv, {struct mlx5_ct_tuple rev_tuple = entry->tuple;struct mlx5_ct_shared_counter *shared_counter; -struct mlx5_eswitch *esw = ct_priv->esw; +struct mlx5_core_dev *dev = ct_priv->dev;struct mlx5_ct_entry *rev_entry;__be16 tmp_port;
@@ -776,7 +775,7 @@ mlx5_tc_ct_shared_counter_get(struct mlx5_tc_ct_priv *ct_priv,if (!shared_counter)return ERR_PTR (-ENOMEM ); - shared_counter->counter =mlx5_fc_create (esw->dev, true); + shared_counter->counter =mlx5_fc_create (dev, true);if (IS_ERR (shared_counter->counter)) {ct_dbg ("Failed to create counter for ct entry" );kfree (shared_counter);
@@ -1159,7 +1158,7 @@ static int tc_ct_pre_ct_add_rules(struct mlx5_ct_ft *ct_ft, {struct mlx5_tc_ct_priv *ct_priv = ct_ft->ct_priv;struct mlx5e_tc_mod_hdr_acts pre_mod_acts = {}; -struct mlx5_core_dev *dev = ct_priv->esw->dev; +struct mlx5_core_dev *dev = ct_priv->dev;struct mlx5_flow_table *ft = pre_ct->ft;struct mlx5_flow_destination dest = {};struct mlx5_flow_act flow_act = {};
@@ -1246,7 +1245,7 @@ tc_ct_pre_ct_del_rules(struct mlx5_ct_ft *ct_ft, struct mlx5_tc_ct_pre *pre_ct) {struct mlx5_tc_ct_priv *ct_priv = ct_ft->ct_priv; -struct mlx5_core_dev *dev = ct_priv->esw->dev; +struct mlx5_core_dev *dev = ct_priv->dev;mlx5_del_flow_rules (pre_ct->flow_rule);mlx5_del_flow_rules (pre_ct->miss_rule);
@@ -1260,7 +1259,7 @@ mlx5_tc_ct_alloc_pre_ct(struct mlx5_ct_ft *ct_ft, {int inlen =MLX5_ST_SZ_BYTES (create_flow_group_in);struct mlx5_tc_ct_priv *ct_priv = ct_ft->ct_priv; -struct mlx5_core_dev *dev = ct_priv->esw->dev; +struct mlx5_core_dev *dev = ct_priv->dev;struct mlx5_flow_table_attr ft_attr = {};struct mlx5_flow_namespace *ns;struct mlx5_flow_table *ft;
@@ -1932,8 +1931,8 @@ mlx5_tc_ct_init(struct mlx5e_priv *priv, struct mlx5_fs_chains *chains, ct_priv->ns_type = ns_type; ct_priv->chains = chains; - ct_priv->esw = priv->mdev->priv.eswitch; ct_priv->netdev = priv->netdev; + ct_priv->dev = priv->mdev; ct_priv->mod_hdr_tbl = mod_hdr; ct_priv->ct =mlx5_chains_create_global_table (chains);if (IS_ERR (ct_priv->ct)) {
Signature · 1 line
2.26.2
PATCH v2 12/15 net/mlx5e: IPsec: Use kvfree() for memory allocated with kvzalloc()
In reply to [email protected]From: Denis Efremov <[email protected]>
Variables flow_group_in, spec in rx_fs_create() are allocated with kvzalloc(). It's incorrect to free them with kfree(). Use kvfree() instead.
--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c +2 -2
@@ -228,8 +228,8 @@ static int rx_fs_create(struct mlx5e_priv *priv, fs_prot->miss_rule = miss_rule; out: -kfree (flow_group_in); -kfree (spec); +kvfree (flow_group_in); +kvfree (spec);return err; }
Signature · 1 line
2.26.2
PATCH v2 13/15 net/mlx5e: Use kfree() to free fd->g in accel_fs_tcp_create_groups()
In reply to [email protected]From: Denis Efremov <[email protected]>
Memory ft->g in accel_fs_tcp_create_groups() is allocaed with kcalloc(). It's excessive to free ft->g with kvfree(). Use kfree() instead.
--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c +1 -1
@@ -191,7 +191,7 @@ static int accel_fs_tcp_create_groups(struct mlx5e_flow_table *ft, ft->g =kcalloc (MLX5E_ACCEL_FS_TCP_NUM_GROUPS ,sizeof (*ft->g),GFP_KERNEL ); in =kvzalloc (inlen,GFP_KERNEL );if (!in || !ft->g) { -kvfree (ft->g); +kfree (ft->g);kvfree (in);return -ENOMEM ; }
Signature · 1 line
2.26.2
PATCH v2 14/15 net/mlx5: simplify the return expression of mlx5_ec_init()
In reply to [email protected]From: Qinglang Miao <[email protected]>
Simplify the return expression.
--- drivers/net/ethernet/mellanox/mlx5/core/ecpf.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/ecpf.c +1 -7
@@ -43,19 +43,13 @@ static void mlx5_peer_pf_cleanup(struct mlx5_core_dev *dev)int mlx5_ec_init (struct mlx5_core_dev *dev) { -int err =0 ; -if (!mlx5_core_is_ecpf (dev))return 0 ;/* ECPF shall enable HCA for peer PF in the same way a PF * does this for its VFs. */ - err =mlx5_peer_pf_init (dev); -if (err) -return err; - -return 0 ; +return mlx5_peer_pf_init (dev); }void mlx5_ec_cleanup (struct mlx5_core_dev *dev)
Signature · 1 line
2.26.2
PATCH v2 15/15 net/mlx5: remove unreachable return
In reply to [email protected]From: "Pavel Machek (CIP)" <[email protected]>
The last return statement is unreachable code. I'm not sure if it will provoke any warnings, but it looks ugly.
--- drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +0 -2
@@ -435,8 +435,6 @@ static int mlx5_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin,default :return -EOPNOTSUPP ; } - -return -EOPNOTSUPP ; }static const struct ptp_clock_info mlx5_ptp_clock_info = {
Signature · 1 line
2.26.2
David Miller
maintainerFrom: [email protected]
Date: Wed, 23 Sep 2020 15:48:09 -0700
Quoted 10 lines
This series adds the support for connection tracking in NIC mode, and attached to this series some trivial cleanup patches.
v1->v2:
- Remove "fixup!" comment from commit message (Jakub)
- More information and use case description in the tag message (Cover-letter) (Jakub)For more information please see tag log below.
Please pull and let me know if there is any problem.
Pulled, thanks Saeed.