mlx5 updates 2022-08-22
Subsystems (5)
From: Saeed Mahameed <[email protected]>
This series adds two updates to mlx5 driver:
Roi Dayan adds the support for tunnel offloads for SFs. Lama continues to decouple mlx5 auxiliary sub-modules from the main mlx5_priv (the netdev private data).
For more information please see tag log below.
Please pull and let me know if there is any problem.
Merge conflict:
When merged with latest mlx5 net PR [1], the following conflict will pop-up:
++<<<<<<< HEAD
+err_free_tc:
+ mlx5e_fs_tc_free(fs);
+err_free_fs:
+ kvfree(fs);
++||||||| 4c2d0b039c5c
++err_free_fs:
++ kvfree(fs);
++=======
+
++>>>>>>> submit/net-mlx5
err_free_vlan:
mlx5e_fs_vlan_free(fs);
+ err_free_fs:
+ kvfree(fs);
To resolve simply use this hunk:
err_free_tc:
mlx5e_fs_tc_free(fs);
err_free_vlan:
mlx5e_fs_vlan_free(fs);
err_free_fs:
kvfree(fs); [1] https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/
Thanks,
Saeed.
The following changes since commit 97d29b9231c73d8c2c1c5b6add6d1f679bb579f9:
Merge branch '10GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue (2022-08-22 20:24:45 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2022-08-22
for you to fetch changes up to 72e0bcd1563602168391ea52157bdd82e6d7875a:
net/mlx5: TC, Add support for SF tunnel offload (2022-08-22 22:44:26 -0700)
----------------------------------------------------------------
mlx5-updates-2022-08-22
Roi Dayan Says:
===============
Add support for SF tunnel offload
Mlx5 driver only supports VF tunnel offload.
To add support for SF tunnel offload the driver needs to:
1. Add send-to-vport metadata matching rules like done for VFs.
2. Set an indirect table for SF vport, same as VF vport.
info smaller sub functions for better maintainability.
rules from esw init phase to representor load phase.
SFs could be created after esw initialized and thus the send-to-vport meta rules would not be created for those SFs.
By moving the creation of the rules to representor load phase we ensure creating the rules also for SFs created later.
===============
Lama Kayal Says:
================
Make flow steering API loosely coupled from mlx5e_priv, in a manner to introduce more readable and maintainable modules.
Make TC's private, let mlx5e_flow_steering struct be dynamically allocated, and introduce its API to maintain the code via setters and getters instead of publicly exposing it.
Introduce flow steering debug macros to provide an elegant finish to the decoupled flow steering API, where errors related to flow steering shall be reported via them.
All flow steering related files will drop any coupling to mlx5e_priv, instead they will get the relevant members as input. Among these, fs_tt_redirect, fs_tc, and arfs.
================
----------------------------------------------------------------
Jianbo Liu (1):
net/mlx5: E-Switch, Add default drop rule for unmatched packets
Lama Kayal (11):
net/mlx5e: Introduce flow steering API
net/mlx5e: Decouple fs_tt_redirect from en.h
net/mlx5e: Decouple fs_tcp from en.h
net/mlx5e: Drop priv argument of ptp function in en_fs
net/mlx5e: Convert ethtool_steering member of flow_steering struct to pointer net/mlx5e: Directly get flow_steering struct as input when init/cleanup ethtool steering net/mlx5e: Separate ethtool_steering from fs.h and make private net/mlx5e: Introduce flow steering debug macros
net/mlx5e: Make flow steering arfs independent of priv
net/mlx5e: Make all ttc functions of en_fs get fs struct as argument net/mlx5e: Completely eliminate priv from fs.h
Roi Dayan (3):
net/mlx5: E-Switch, Split creating fdb tables into smaller chunks net/mlx5: E-Switch, Move send to vport meta rule creation net/mlx5: TC, Add support for SF tunnel offload
drivers/net/ethernet/mellanox/mlx5/core/en.h | 5 - drivers/net/ethernet/mellanox/mlx5/core/en/fs.h | 158 +++---- .../ethernet/mellanox/mlx5/core/en/fs_ethtool.h | 29 ++ .../mellanox/mlx5/core/en/fs_tt_redirect.c | 188 ++++---- .../mellanox/mlx5/core/en/fs_tt_redirect.h | 13 +- drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c | 44 +- drivers/net/ethernet/mellanox/mlx5/core/en/ptp.h | 6 +- .../ethernet/mellanox/mlx5/core/en/tc/act/goto.c | 3 +- drivers/net/ethernet/mellanox/mlx5/core/en/trap.c | 8 +- .../ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c | 111 ++--- .../ethernet/mellanox/mlx5/core/en_accel/fs_tcp.h | 14 +- .../mellanox/mlx5/core/en_accel/ipsec_fs.c | 15 +- .../ethernet/mellanox/mlx5/core/en_accel/ktls.c | 8 +- .../ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c | 141 +++--- .../net/ethernet/mellanox/mlx5/core/en_ethtool.c | 5 +- drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 436 ++++++++++++------ .../ethernet/mellanox/mlx5/core/en_fs_ethtool.c | 76 +++- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 42 +- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 77 +++- drivers/net/ethernet/mellanox/mlx5/core/en_rep.h | 9 +- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 85 ++-- drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 1 + .../ethernet/mellanox/mlx5/core/esw/indir_table.c | 6 +- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 7 +- .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 495 +++++++++++++-------- .../ethernet/mellanox/mlx5/core/ipoib/ethtool.c | 1 + .../net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 25 +- 29 files changed, 1246 insertions(+), 765 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/fs_ethtool.h
PATCH 1/15 net/mlx5e: Introduce flow steering API
From: Lama Kayal <[email protected]>
Move mlx5e_flow_steering struct to fs_en.c to make it private. Introduce flow_steering API and let other files go through it.
--- .../net/ethernet/mellanox/mlx5/core/en/fs.h | 55 ++++--- .../mellanox/mlx5/core/en/fs_tt_redirect.c | 93 ++++++----- .../net/ethernet/mellanox/mlx5/core/en/ptp.c | 8 +- .../mellanox/mlx5/core/en/tc/act/goto.c | 3 +- .../mellanox/mlx5/core/en_accel/fs_tcp.c | 46 +++--- .../mellanox/mlx5/core/en_accel/ipsec_fs.c | 15 +- .../net/ethernet/mellanox/mlx5/core/en_arfs.c | 78 +++++---- .../net/ethernet/mellanox/mlx5/core/en_fs.c | 154 +++++++++++++++++- .../mellanox/mlx5/core/en_fs_ethtool.c | 33 ++-- .../net/ethernet/mellanox/mlx5/core/en_main.c | 19 ++- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 17 +- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 78 +++++---- .../net/ethernet/mellanox/mlx5/core/en_tc.h | 1 + .../ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 8 +- 14 files changed, 415 insertions(+), 193 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/fs.h +30 -25
@@ -8,6 +8,7 @@#include "lib/fs_ttc.h" struct mlx5e_post_act ; +struct mlx5e_tc_table ;enum {MLX5E_TC_FT_LEVEL =0 ,
@@ -83,6 +84,7 @@ enum {#endif }; +struct mlx5e_flow_steering ;struct mlx5e_priv ;#ifdef CONFIG_MLX5_EN_RXNFC
@@ -142,31 +144,6 @@ struct mlx5e_fs_udp;struct mlx5e_fs_any ;struct mlx5e_ptp_fs ; -struct mlx5e_flow_steering { -bool state_destroy; -bool vlan_strip_disable; -struct mlx5_core_dev *mdev; -struct mlx5_flow_namespace *ns; -#ifdef CONFIG_MLX5_EN_RXNFC -struct mlx5e_ethtool_steering ethtool; -#endif -struct mlx5e_tc_table *tc; -struct mlx5e_promisc_table promisc; -struct mlx5e_vlan_table *vlan; -struct mlx5e_l2_table l2; -struct mlx5_ttc_table *ttc; -struct mlx5_ttc_table *inner_ttc; -#ifdef CONFIG_MLX5_EN_ARFS -struct mlx5e_arfs_tables *arfs; -#endif -#ifdef CONFIG_MLX5_EN_TLS -struct mlx5e_accel_fs_tcp *accel_tcp; -#endif -struct mlx5e_fs_udp *udp; -struct mlx5e_fs_any *any; -struct mlx5e_ptp_fs *ptp_fs; -}; -void mlx5e_set_ttc_params (struct mlx5e_priv *priv,struct ttc_params *ttc_params,bool tunnel);
@@ -185,7 +162,35 @@ struct mlx5e_flow_steering *mlx5e_fs_init(const struct mlx5e_profile *profile,struct mlx5_core_dev *mdev, bool state_destroy);void mlx5e_fs_cleanup (struct mlx5e_flow_steering *fs); +struct mlx5e_vlan_table *mlx5e_fs_get_vlan (struct mlx5e_flow_steering *fs); +void mlx5e_fs_set_tc (struct mlx5e_flow_steering *fs,struct mlx5e_tc_table *tc); +struct mlx5e_tc_table *mlx5e_fs_get_tc (struct mlx5e_flow_steering *fs); +struct mlx5e_l2_table *mlx5e_fs_get_l2 (struct mlx5e_flow_steering *fs); +struct mlx5_flow_namespace *mlx5e_fs_get_ns (struct mlx5e_flow_steering *fs,bool egress); +void mlx5e_fs_set_ns (struct mlx5e_flow_steering *fs,struct mlx5_flow_namespace *ns,bool egress); +#ifdef CONFIG_MLX5_EN_RXNFC +struct mlx5e_ethtool_steering *mlx5e_fs_get_ethtool (struct mlx5e_flow_steering *fs); +#endif +struct mlx5_ttc_table *mlx5e_fs_get_ttc (struct mlx5e_flow_steering *fs,bool inner); +void mlx5e_fs_set_ttc (struct mlx5e_flow_steering *fs,struct mlx5_ttc_table *ttc,bool inner); +#ifdef CONFIG_MLX5_EN_ARFS +struct mlx5e_arfs_tables *mlx5e_fs_get_arfs (struct mlx5e_flow_steering *fs); +void mlx5e_fs_set_arfs (struct mlx5e_flow_steering *fs,struct mlx5e_arfs_tables *arfs); +#endif +struct mlx5e_ptp_fs *mlx5e_fs_get_ptp (struct mlx5e_flow_steering *fs); +void mlx5e_fs_set_ptp (struct mlx5e_flow_steering *fs,struct mlx5e_ptp_fs *ptp_fs); +struct mlx5e_fs_any *mlx5e_fs_get_any (struct mlx5e_flow_steering *fs); +void mlx5e_fs_set_any (struct mlx5e_flow_steering *fs,struct mlx5e_fs_any *any); +struct mlx5e_fs_udp *mlx5e_fs_get_udp (struct mlx5e_flow_steering *fs); +void mlx5e_fs_set_udp (struct mlx5e_flow_steering *fs,struct mlx5e_fs_udp *udp); +#ifdef CONFIG_MLX5_EN_TLS +struct mlx5e_accel_fs_tcp *mlx5e_fs_get_accel_tcp (struct mlx5e_flow_steering *fs); +void mlx5e_fs_set_accel_tcp (struct mlx5e_flow_steering *fs,struct mlx5e_accel_fs_tcp *accel_tcp); +#endif +void mlx5e_fs_set_state_destroy (struct mlx5e_flow_steering *fs,bool state_destroy); +void mlx5e_fs_set_vlan_strip_disable (struct mlx5e_flow_steering *fs,bool vlan_strip_disable); +struct mlx5_core_dev *mlx5e_fs_get_mdev (struct mlx5e_flow_steering *fs);int mlx5e_add_vlan_trap (struct mlx5e_priv *priv,int trap_id,int tir_num);void mlx5e_remove_vlan_trap (struct mlx5e_priv *priv);int mlx5e_add_mac_trap (struct mlx5e_priv *priv,int trap_id,int tir_num);
drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c +52 -41
289 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c +4 -4
@@ -624,7 +624,7 @@ static int mlx5e_ptp_set_state(struct mlx5e_ptp *c, struct mlx5e_params *params)static void mlx5e_ptp_rx_unset_fs (struct mlx5e_priv *priv) { -struct mlx5e_ptp_fs *ptp_fs = priv->fs->ptp_fs; +struct mlx5e_ptp_fs *ptp_fs =mlx5e_fs_get_ptp (priv->fs);if (!ptp_fs->valid)return ;
@@ -640,8 +640,8 @@ static void mlx5e_ptp_rx_unset_fs(struct mlx5e_priv *priv)static int mlx5e_ptp_rx_set_fs (struct mlx5e_priv *priv) { +struct mlx5e_ptp_fs *ptp_fs =mlx5e_fs_get_ptp (priv->fs);u32 tirn =mlx5e_rx_res_get_tirn_ptp (priv->rx_res); -struct mlx5e_ptp_fs *ptp_fs = priv->fs->ptp_fs;struct mlx5_flow_handle *rule;int err;
@@ -807,14 +807,14 @@ int mlx5e_ptp_alloc_rx_fs(struct mlx5e_priv *priv) ptp_fs =kzalloc (sizeof (*ptp_fs),GFP_KERNEL );if (!ptp_fs)return -ENOMEM ; +mlx5e_fs_set_ptp (priv->fs, ptp_fs); - priv->fs->ptp_fs = ptp_fs;return 0 ; }void mlx5e_ptp_free_rx_fs (struct mlx5e_priv *priv) { -struct mlx5e_ptp_fs *ptp_fs = priv->fs->ptp_fs; +struct mlx5e_ptp_fs *ptp_fs =mlx5e_fs_get_ptp (priv->fs);if (!mlx5e_profile_feature_cap (priv->profile,PTP_RX ))return ;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/goto.c +2 -1
@@ -12,6 +12,7 @@ validate_goto_chain(struct mlx5e_priv *priv,const struct flow_action_entry *act, struct netlink_ext_ack *extack) { + struct mlx5e_tc_table *tc = mlx5e_fs_get_tc(priv->fs);bool is_esw =mlx5e_is_eswitch_flow (flow);bool ft_flow =mlx5e_is_ft_flow (flow);u32 dest_chain = act->chain_index;
@@ -21,7 +22,7 @@ validate_goto_chain(struct mlx5e_priv *priv,u32 max_chain; esw = priv->mdev->priv.eswitch; - chains = is_esw ?esw_chains (esw) :mlx5e_nic_chains (priv->fs->tc); + chains = is_esw ?esw_chains (esw) :mlx5e_nic_chains (tc); max_chain =mlx5_chains_get_chain_range (chains); reformat_and_fwd = is_esw ? MLX5_CAP_ESW_FLOWTABLE_FDB(priv->mdev, reformat_and_fwd_to_table) :
drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c +25 -21
145 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c +9 -6
@@ -174,6 +174,8 @@ static void rx_destroy(struct mlx5e_priv *priv, enum accel_fs_esp_type type)static int rx_create (struct mlx5e_priv *priv,enum accel_fs_esp_type type) { +struct mlx5_flow_namespace *ns =mlx5e_fs_get_ns (priv->fs, false); +struct mlx5_ttc_table *ttc =mlx5e_fs_get_ttc (priv->fs, false);struct mlx5_flow_table_attr ft_attr = {};struct mlx5e_accel_fs_esp_prot *fs_prot;struct mlx5e_accel_fs_esp *accel_esp;
@@ -182,15 +184,14 @@ static int rx_create(struct mlx5e_priv *priv, enum accel_fs_esp_type type) accel_esp = priv->ipsec->rx_fs; fs_prot = &accel_esp->fs_prot[type]; - fs_prot->default_dest = -mlx5_ttc_get_default_dest (priv->fs->ttc,fs_esp2tt (type)); +mlx5_ttc_get_default_dest (ttc,fs_esp2tt (type)); ft_attr.max_fte =1 ; ft_attr.autogroup.max_num_groups =1 ; ft_attr.level =MLX5E_ACCEL_FS_ESP_FT_ERR_LEVEL ; ft_attr.prio =MLX5E_NIC_PRIO ; - ft =mlx5_create_auto_grouped_flow_table (priv->fs->ns, &ft_attr); + ft =mlx5_create_auto_grouped_flow_table (ns, &ft_attr);if (IS_ERR (ft))return PTR_ERR (ft);
@@ -205,7 +206,7 @@ static int rx_create(struct mlx5e_priv *priv, enum accel_fs_esp_type type) ft_attr.prio =MLX5E_NIC_PRIO ; ft_attr.autogroup.num_reserved_entries =1 ; ft_attr.autogroup.max_num_groups =1 ; - ft =mlx5_create_auto_grouped_flow_table (priv->fs->ns, &ft_attr); + ft =mlx5_create_auto_grouped_flow_table (ns, &ft_attr);if (IS_ERR (ft)) { err =PTR_ERR (ft); goto err_fs_ft;
@@ -230,6 +231,7 @@ static int rx_create(struct mlx5e_priv *priv, enum accel_fs_esp_type type)static int rx_ft_get (struct mlx5e_priv *priv,enum accel_fs_esp_type type) { +struct mlx5_ttc_table *ttc =mlx5e_fs_get_ttc (priv->fs, false);struct mlx5e_accel_fs_esp_prot *fs_prot;struct mlx5_flow_destination dest = {};struct mlx5e_accel_fs_esp *accel_esp;
@@ -249,7 +251,7 @@ static int rx_ft_get(struct mlx5e_priv *priv, enum accel_fs_esp_type type)/* connect */ dest.type =MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE ; dest.ft = fs_prot->ft; -mlx5_ttc_fwd_dest (priv->fs->ttc,fs_esp2tt (type), &dest); +mlx5_ttc_fwd_dest (ttc,fs_esp2tt (type), &dest); skip: fs_prot->refcnt++;
@@ -260,6 +262,7 @@ static int rx_ft_get(struct mlx5e_priv *priv, enum accel_fs_esp_type type)static void rx_ft_put (struct mlx5e_priv *priv,enum accel_fs_esp_type type) { +struct mlx5_ttc_table *ttc =mlx5e_fs_get_ttc (priv->fs, false);struct mlx5e_accel_fs_esp_prot *fs_prot;struct mlx5e_accel_fs_esp *accel_esp;
@@ -271,7 +274,7 @@ static void rx_ft_put(struct mlx5e_priv *priv, enum accel_fs_esp_type type) goto out;/* disconnect */ -mlx5_ttc_fwd_default_dest (priv->fs->ttc,fs_esp2tt (type)); +mlx5_ttc_fwd_default_dest (ttc,fs_esp2tt (type));/* remove FT */ rx_destroy (priv, type);
drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c +48 -30
235 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +150 -4
185 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c +21 -12
@@ -66,6 +66,7 @@ static struct mlx5e_ethtool_table *get_flow_table(struct mlx5e_priv *priv, struct ethtool_rx_flow_spec *fs, int num_tuples) { +struct mlx5e_ethtool_steering *ethtool =mlx5e_fs_get_ethtool (priv->fs);struct mlx5_flow_table_attr ft_attr = {};struct mlx5e_ethtool_table *eth_ft;struct mlx5_flow_namespace *ns;
@@ -81,18 +82,18 @@ static struct mlx5e_ethtool_table *get_flow_table(struct mlx5e_priv *priv,case UDP_V6_FLOW : max_tuples =ETHTOOL_NUM_L3_L4_FTS ; prio =MLX5E_ETHTOOL_L3_L4_PRIO + (max_tuples - num_tuples); - eth_ft = &priv->fs->ethtool.l3_l4_ft[prio]; + eth_ft = ðtool->l3_l4_ft[prio];break ;case IP_USER_FLOW :case IPV6_USER_FLOW : max_tuples =ETHTOOL_NUM_L3_L4_FTS ; prio =MLX5E_ETHTOOL_L3_L4_PRIO + (max_tuples - num_tuples); - eth_ft = &priv->fs->ethtool.l3_l4_ft[prio]; + eth_ft = ðtool->l3_l4_ft[prio];break ;case ETHER_FLOW : max_tuples =ETHTOOL_NUM_L2_FTS ; prio = max_tuples - num_tuples; - eth_ft = &priv->fs->ethtool.l2_ft[prio]; + eth_ft = ðtool->l2_ft[prio]; prio +=MLX5E_ETHTOOL_L2_PRIO ;break ;default :
@@ -382,15 +383,16 @@ static int set_flow_attrs(u32 *match_c, u32 *match_v,static void add_rule_to_list (struct mlx5e_priv *priv,struct mlx5e_ethtool_rule *rule) { +struct mlx5e_ethtool_steering *ethtool =mlx5e_fs_get_ethtool (priv->fs); +struct list_head *head = ðtool->rules;struct mlx5e_ethtool_rule *iter; -struct list_head *head = &priv->fs->ethtool.rules; -list_for_each_entry (iter, &priv->fs->ethtool.rules, list) { +list_for_each_entry (iter, ðtool->rules, list) {if (iter->flow_spec.location > rule->flow_spec.location)break ; head = &iter->list; } - priv->fs->ethtool.tot_num_rules++; + ethtool->tot_num_rules++;list_add (&rule->list, head); }
@@ -502,12 +504,13 @@ add_ethtool_flow_rule(struct mlx5e_priv *priv,static void del_ethtool_rule (struct mlx5e_priv *priv,struct mlx5e_ethtool_rule *eth_rule) { +struct mlx5e_ethtool_steering *ethtool =mlx5e_fs_get_ethtool (priv->fs);if (eth_rule->rule)mlx5_del_flow_rules (eth_rule->rule);if (eth_rule->rss)mlx5e_rss_refcnt_dec (eth_rule->rss);list_del (ð_rule->list); - priv->fs->ethtool.tot_num_rules--; + ethtool->tot_num_rules--;put_flow_table (eth_rule->eth_ft);kfree (eth_rule); }
@@ -515,9 +518,10 @@ static void del_ethtool_rule(struct mlx5e_priv *priv,static struct mlx5e_ethtool_rule *find_ethtool_rule (struct mlx5e_priv *priv,int location) { +struct mlx5e_ethtool_steering *ethtool =mlx5e_fs_get_ethtool (priv->fs);struct mlx5e_ethtool_rule *iter; -list_for_each_entry (iter, &priv->fs->ethtool.rules, list) { +list_for_each_entry (iter, ðtool->rules, list) {if (iter->flow_spec.location == location)return iter; }
@@ -783,12 +787,13 @@ static int mlx5e_ethtool_get_flow(struct mlx5e_priv *priv, struct ethtool_rxnfc *info, int location) { + struct mlx5e_ethtool_steering *ethtool = mlx5e_fs_get_ethtool(priv->fs);struct mlx5e_ethtool_rule *eth_rule;if (location <0 || location >=MAX_NUM_OF_ETHTOOL_RULES )return -EINVAL ; -list_for_each_entry (eth_rule, &priv->fs->ethtool.rules, list) { +list_for_each_entry (eth_rule, ðtool->rules, list) {int index;if (eth_rule->flow_spec.location != location)
@@ -828,16 +833,19 @@ mlx5e_ethtool_get_all_flows(struct mlx5e_priv *priv,void mlx5e_ethtool_cleanup_steering (struct mlx5e_priv *priv) { +struct mlx5e_ethtool_steering *ethtool =mlx5e_fs_get_ethtool (priv->fs);struct mlx5e_ethtool_rule *iter;struct mlx5e_ethtool_rule *temp; -list_for_each_entry_safe (iter, temp, &priv->fs->ethtool.rules, list) +list_for_each_entry_safe (iter, temp, ðtool->rules, list)del_ethtool_rule (priv, iter); }void mlx5e_ethtool_init_steering (struct mlx5e_priv *priv) { -INIT_LIST_HEAD (&priv->fs->ethtool.rules); +struct mlx5e_ethtool_steering *ethtool =mlx5e_fs_get_ethtool (priv->fs); + +INIT_LIST_HEAD (ðtool->rules); }static int flow_type_to_traffic_type (u32 flow_type)
@@ -959,11 +967,12 @@ int mlx5e_ethtool_set_rxnfc(struct mlx5e_priv *priv, struct ethtool_rxnfc *cmd)int mlx5e_ethtool_get_rxnfc (struct mlx5e_priv *priv,struct ethtool_rxnfc *info,u32 *rule_locs) { +struct mlx5e_ethtool_steering *ethtool =mlx5e_fs_get_ethtool (priv->fs);int err =0 ;switch (info->cmd) {case ETHTOOL_GRXCLSRLCNT : - info->rule_cnt = priv->fs->ethtool.tot_num_rules; + info->rule_cnt = ethtool->tot_num_rules;break ;case ETHTOOL_GRXCLSRULE : err =mlx5e_ethtool_get_flow (priv, info, info->fs.location);
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +12 -7
@@ -3778,7 +3778,7 @@ static int set_feature_rx_vlan(struct net_device *netdev, bool enable)mutex_lock (&priv->state_lock); - priv->fs->vlan_strip_disable = !enable; +mlx5e_fs_set_vlan_strip_disable (priv->fs, !enable); priv->channels.params.vlan_strip_disable = !enable;if (!test_bit (MLX5E_STATE_OPENED , &priv->state))
@@ -3786,7 +3786,7 @@ static int set_feature_rx_vlan(struct net_device *netdev, bool enable) err =mlx5e_modify_channels_vsd (&priv->channels, !enable);if (err) { - priv->fs->vlan_strip_disable = enable; +mlx5e_fs_set_vlan_strip_disable (priv->fs, enable); priv->channels.params.vlan_strip_disable = enable; } unlock:
@@ -3910,12 +3910,14 @@ static netdev_features_t mlx5e_fix_features(struct net_device *netdev, netdev_features_t features) {struct mlx5e_priv *priv =netdev_priv (netdev); +struct mlx5e_vlan_table *vlan;struct mlx5e_params *params; + vlan =mlx5e_fs_get_vlan (priv->fs);mutex_lock (&priv->state_lock); params = &priv->channels.params; -if (!priv->fs->vlan || - !bitmap_empty (mlx5e_vlan_get_active_svlans (priv->fs->vlan),VLAN_N_VID )) { +if (!vlan || + !bitmap_empty (mlx5e_vlan_get_active_svlans (vlan),VLAN_N_VID )) {/* HW strips the outer C-tag header, this is a problem * for S-tag traffic. */
@@ -5518,7 +5520,8 @@ int mlx5e_attach_netdev(struct mlx5e_priv *priv)clear_bit (MLX5E_STATE_DESTROYING , &priv->state);if (priv->fs) - priv->fs->state_destroy = !test_bit (MLX5E_STATE_DESTROYING , &priv->state); +mlx5e_fs_set_state_destroy (priv->fs, + !test_bit (MLX5E_STATE_DESTROYING , &priv->state));/* max number of channels may have changed */ max_nch =mlx5e_calc_max_nch (priv->mdev, priv->netdev, profile);
@@ -5579,7 +5582,8 @@ int mlx5e_attach_netdev(struct mlx5e_priv *priv)mlx5e_reset_channels (priv->netdev);set_bit (MLX5E_STATE_DESTROYING , &priv->state);if (priv->fs) - priv->fs->state_destroy = !test_bit (MLX5E_STATE_DESTROYING , &priv->state); +mlx5e_fs_set_state_destroy (priv->fs, + !test_bit (MLX5E_STATE_DESTROYING , &priv->state));cancel_work_sync (&priv->update_stats_work);return err; }
@@ -5590,7 +5594,8 @@ void mlx5e_detach_netdev(struct mlx5e_priv *priv)set_bit (MLX5E_STATE_DESTROYING , &priv->state);if (priv->fs) - priv->fs->state_destroy = !test_bit (MLX5E_STATE_DESTROYING , &priv->state); +mlx5e_fs_set_state_destroy (priv->fs, + !test_bit (MLX5E_STATE_DESTROYING , &priv->state));if (profile->disable) profile->disable (priv);
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +9 -8
@@ -745,8 +745,9 @@ static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv)struct ttc_params ttc_params = {};int err; - priv->fs->ns =mlx5_get_flow_namespace (priv->mdev, -MLX5_FLOW_NAMESPACE_KERNEL ); +mlx5e_fs_set_ns (priv->fs, +mlx5_get_flow_namespace (priv->mdev, +MLX5_FLOW_NAMESPACE_KERNEL ), false);/* The inner_ttc in the ttc params is intentionally not set */ mlx5e_set_ttc_params (priv, &ttc_params, false);
@@ -755,9 +756,9 @@ static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv)/* To give uplik rep TTC a lower level for chaining from root ft */ ttc_params.ft_attr.level =MLX5E_TTC_FT_LEVEL +1 ; - priv->fs->ttc =mlx5_create_ttc_table (priv->mdev, &ttc_params); -if (IS_ERR (priv->fs->ttc)) { - err =PTR_ERR (priv->fs->ttc); +mlx5e_fs_set_ttc (priv->fs,mlx5_create_ttc_table (priv->mdev, &ttc_params), false); +if (IS_ERR (mlx5e_fs_get_ttc (priv->fs, false))) { + err =PTR_ERR (mlx5e_fs_get_ttc (priv->fs, false));netdev_err (priv->netdev,"Failed to create rep ttc table, err=%d\n" , err);return err;
@@ -777,7 +778,7 @@ static int mlx5e_create_rep_root_ft(struct mlx5e_priv *priv)/* non uplik reps will skip any bypass tables and go directly to * their own ttc */ - rpriv->root_ft =mlx5_get_ttc_flow_table (priv->fs->ttc); + rpriv->root_ft =mlx5_get_ttc_flow_table (mlx5e_fs_get_ttc (priv->fs, false));return 0 ; }
@@ -892,7 +893,7 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv) err_destroy_root_ft:mlx5e_destroy_rep_root_ft (priv); err_destroy_ttc_table: -mlx5_destroy_ttc_table (priv->fs->ttc); +mlx5_destroy_ttc_table (mlx5e_fs_get_ttc (priv->fs, false)); err_destroy_rx_res:mlx5e_rx_res_destroy (priv->rx_res); err_close_drop_rq:
@@ -909,7 +910,7 @@ static void mlx5e_cleanup_rep_rx(struct mlx5e_priv *priv)mlx5e_ethtool_cleanup_steering (priv);rep_vport_rx_rule_destroy (priv);mlx5e_destroy_rep_root_ft (priv); -mlx5_destroy_ttc_table (priv->fs->ttc); +mlx5_destroy_ttc_table (mlx5e_fs_get_ttc (priv->fs, false));mlx5e_rx_res_destroy (priv->rx_res);mlx5e_close_drop_rq (&priv->drop_rq);mlx5e_rx_res_free (priv->rx_res);
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +47 -31
279 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +1 -0
@@ -54,6 +54,7 @@ ESW_FLOW_ATTR_SZ :\ NIC_FLOW_ATTR_SZ) +struct mlx5_fs_chains *mlx5e_nic_chains (struct mlx5e_tc_table *tc);int mlx5e_tc_num_filters (struct mlx5e_priv *priv,unsigned long flags);struct mlx5e_tc_update_priv {
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +5 -3
@@ -320,14 +320,16 @@ static void mlx5i_cleanup_tx(struct mlx5e_priv *priv)static int mlx5i_create_flow_steering (struct mlx5e_priv *priv) { +struct mlx5_flow_namespace *ns = +mlx5_get_flow_namespace (priv->mdev,MLX5_FLOW_NAMESPACE_KERNEL );int err; - priv->fs->ns =mlx5_get_flow_namespace (priv->mdev, -MLX5_FLOW_NAMESPACE_KERNEL ); -if (!priv->fs->ns) +if (!ns)return -EINVAL ; +mlx5e_fs_set_ns (priv->fs, ns, false); + err =mlx5e_arfs_create_tables (priv);if (err) { netdev_err(priv->netdev, "Failed to create arfs tables, err=%d\n",
Signature · 1 line
2.37.1
Re: [net-next 01/15] net/mlx5e: Introduce flow steering API
This series was applied to netdev/net-next.git (master) by Saeed Mahameed <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by Saeed Mahameed <[email protected]>:
Quoted 10 lines · On Mon, 22 Aug 2022 22:55:19 -0700 you wrote:
From: Lama Kayal <[email protected]>
Move
mlx5e_flow_steeringstruct tofs_en.cto make it private. Introduceflow_steeringAPI and let other files go through it.Signed-off-by Lama Kayal <[email protected]>Reviewed-by Tariq Toukan <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>[...]
Here is the summary with links:
- [net-next,01/15] net/mlx5e: Introduce flow steering API
https://git.kernel.org/netdev/net-next/c/f52f2faee581 - [net-next,02/15] net/mlx5e: Decouple fs_tt_redirect from en.h https://git.kernel.org/netdev/net-next/c/4e0ecc17a74e - [net-next,03/15] net/mlx5e: Decouple fs_tcp from en.h https://git.kernel.org/netdev/net-next/c/1be44b42b25c - [net-next,04/15] net/mlx5e: Drop priv argument of ptp function in en_fs https://git.kernel.org/netdev/net-next/c/81a0b241affe - [net-next,05/15] net/mlx5e: Convert ethtool_steering member of flow_steering struct to pointer https://git.kernel.org/netdev/net-next/c/c7eafc5ed068 - [net-next,06/15] net/mlx5e: Directly get flow_steering struct as input when init/cleanup ethtool steering https://git.kernel.org/netdev/net-next/c/e8b5c4bcb554 - [net-next,07/15] net/mlx5e: Separate ethtool_steering from fs.h and make private https://git.kernel.org/netdev/net-next/c/9c2c1c5e7fde - [net-next,08/15] net/mlx5e: Introduce flow steering debug macros https://git.kernel.org/netdev/net-next/c/93a07599ee0a - [net-next,09/15] net/mlx5e: Make flow steering arfs independent of priv https://git.kernel.org/netdev/net-next/c/45b83c6c6831 - [net-next,10/15] net/mlx5e: Make all ttc functions of en_fs get fs struct as argument https://git.kernel.org/netdev/net-next/c/ca959d97d6bb - [net-next,11/15] net/mlx5e: Completely eliminate priv from fs.h https://git.kernel.org/netdev/net-next/c/d494dd2bb70c - [net-next,12/15] net/mlx5: E-Switch, Add default drop rule for unmatched packets https://git.kernel.org/netdev/net-next/c/8ea7bcf63218 - [net-next,13/15] net/mlx5: E-Switch, Split creating fdb tables into smaller chunks https://git.kernel.org/netdev/net-next/c/4a561817064f - [net-next,14/15] net/mlx5: E-Switch, Move send to vport meta rule creation https://git.kernel.org/netdev/net-next/c/430e2d5e2a98 - [net-next,15/15] net/mlx5: TC, Add support for SF tunnel offload https://git.kernel.org/netdev/net-next/c/72e0bcd15636
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
PATCH 2/15 net/mlx5e: Decouple fs_tt_redirect from en.h
In reply to Saeed MahameedFrom: Lama Kayal <[email protected]>
Make flow steering files fs_tt_redirect.c/h independent of en.h such that it goes through the flow steering API only.
Make error reports be via mlx5_core API instead of netdev_err API, this to ensure a safe decoupling from en.h, and prevent redundant argument passing.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 5 - .../net/ethernet/mellanox/mlx5/core/en/fs.h | 5 + .../mellanox/mlx5/core/en/fs_tt_redirect.c | 153 +++++++++--------- .../mellanox/mlx5/core/en/fs_tt_redirect.h | 13 +- .../net/ethernet/mellanox/mlx5/core/en/ptp.c | 26 +-- 5 files changed, 103 insertions(+), 99 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +0 -5
@@ -856,11 +856,6 @@ enum { MLX5E_STATE_XDP_ACTIVE, }; -enum { -MLX5E_TC_PRIO =0 , -MLX5E_NIC_PRIO -}; -struct mlx5e_modify_sq_param {int curr_state;int next_state;
drivers/net/ethernet/mellanox/mlx5/core/en/fs.h +5 -0
@@ -16,6 +16,11 @@ enum { MLX5E_TC_MISS_LEVEL, }; +enum { +MLX5E_TC_PRIO =0 , +MLX5E_NIC_PRIO +}; +struct mlx5e_flow_table {int num_groups;struct mlx5_flow_table *t;
drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c +77 -76
375 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.h +6 -7
@@ -4,23 +4,22 @@#ifndef __MLX5E_FS_TT_REDIRECT_H__#define __MLX5E_FS_TT_REDIRECT_H__ -#include "en.h" #include "en/fs.h" void mlx5e_fs_tt_redirect_del_rule (struct mlx5_flow_handle *rule);/* UDP traffic type redirect */ struct mlx5_flow_handle * -mlx5e_fs_tt_redirect_udp_add_rule (struct mlx5e_priv *priv, +mlx5e_fs_tt_redirect_udp_add_rule (struct mlx5e_flow_steering *fs,enum mlx5_traffic_types ttc_type,u32 tir_num,u16 d_port); -void mlx5e_fs_tt_redirect_udp_destroy (struct mlx5e_priv *priv); -int mlx5e_fs_tt_redirect_udp_create (struct mlx5e_priv *priv); +void mlx5e_fs_tt_redirect_udp_destroy (struct mlx5e_flow_steering *fs); +int mlx5e_fs_tt_redirect_udp_create (struct mlx5e_flow_steering *fs);/* ANY traffic type redirect*/ struct mlx5_flow_handle * -mlx5e_fs_tt_redirect_any_add_rule (struct mlx5e_priv *priv, +mlx5e_fs_tt_redirect_any_add_rule (struct mlx5e_flow_steering *fs,u32 tir_num,u16 ether_type); -void mlx5e_fs_tt_redirect_any_destroy (struct mlx5e_priv *priv); -int mlx5e_fs_tt_redirect_any_create (struct mlx5e_priv *priv); +void mlx5e_fs_tt_redirect_any_destroy (struct mlx5e_flow_steering *fs); +int mlx5e_fs_tt_redirect_any_create (struct mlx5e_flow_steering *fs);#endif
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c +15 -11
@@ -624,35 +624,39 @@ static int mlx5e_ptp_set_state(struct mlx5e_ptp *c, struct mlx5e_params *params)static void mlx5e_ptp_rx_unset_fs (struct mlx5e_priv *priv) { -struct mlx5e_ptp_fs *ptp_fs =mlx5e_fs_get_ptp (priv->fs); +struct mlx5e_flow_steering *fs = priv->fs; +struct mlx5e_ptp_fs *ptp_fs; + ptp_fs =mlx5e_fs_get_ptp (fs);if (!ptp_fs->valid)return ;mlx5e_fs_tt_redirect_del_rule (ptp_fs->l2_rule); -mlx5e_fs_tt_redirect_any_destroy (priv); +mlx5e_fs_tt_redirect_any_destroy (fs);mlx5e_fs_tt_redirect_del_rule (ptp_fs->udp_v6_rule);mlx5e_fs_tt_redirect_del_rule (ptp_fs->udp_v4_rule); -mlx5e_fs_tt_redirect_udp_destroy (priv); +mlx5e_fs_tt_redirect_udp_destroy (fs); ptp_fs->valid = false; }static int mlx5e_ptp_rx_set_fs (struct mlx5e_priv *priv) { -struct mlx5e_ptp_fs *ptp_fs =mlx5e_fs_get_ptp (priv->fs);u32 tirn =mlx5e_rx_res_get_tirn_ptp (priv->rx_res); +struct mlx5e_flow_steering *fs = priv->fs;struct mlx5_flow_handle *rule; +struct mlx5e_ptp_fs *ptp_fs;int err; + ptp_fs =mlx5e_fs_get_ptp (fs);if (ptp_fs->valid)return 0 ; - err =mlx5e_fs_tt_redirect_udp_create (priv); + err =mlx5e_fs_tt_redirect_udp_create (fs);if (err) goto out_free; - rule =mlx5e_fs_tt_redirect_udp_add_rule (priv,MLX5_TT_IPV4_UDP , + rule =mlx5e_fs_tt_redirect_udp_add_rule (fs,MLX5_TT_IPV4_UDP , tirn,PTP_EV_PORT );if (IS_ERR (rule)) { err =PTR_ERR (rule);
@@ -660,7 +664,7 @@ static int mlx5e_ptp_rx_set_fs(struct mlx5e_priv *priv) } ptp_fs->udp_v4_rule = rule; - rule =mlx5e_fs_tt_redirect_udp_add_rule (priv,MLX5_TT_IPV6_UDP , + rule =mlx5e_fs_tt_redirect_udp_add_rule (fs,MLX5_TT_IPV6_UDP , tirn,PTP_EV_PORT );if (IS_ERR (rule)) { err =PTR_ERR (rule);
@@ -668,11 +672,11 @@ static int mlx5e_ptp_rx_set_fs(struct mlx5e_priv *priv) } ptp_fs->udp_v6_rule = rule; - err =mlx5e_fs_tt_redirect_any_create (priv); + err =mlx5e_fs_tt_redirect_any_create (fs);if (err) goto out_destroy_udp_v6_rule; - rule =mlx5e_fs_tt_redirect_any_add_rule (priv, tirn,ETH_P_1588 ); + rule =mlx5e_fs_tt_redirect_any_add_rule (fs, tirn,ETH_P_1588 );if (IS_ERR (rule)) { err =PTR_ERR (rule); goto out_destroy_fs_any;
@@ -683,13 +687,13 @@ static int mlx5e_ptp_rx_set_fs(struct mlx5e_priv *priv)return 0 ; out_destroy_fs_any: -mlx5e_fs_tt_redirect_any_destroy (priv); +mlx5e_fs_tt_redirect_any_destroy (fs); out_destroy_udp_v6_rule:mlx5e_fs_tt_redirect_del_rule (ptp_fs->udp_v6_rule); out_destroy_udp_v4_rule:mlx5e_fs_tt_redirect_del_rule (ptp_fs->udp_v4_rule); out_destroy_fs_udp: -mlx5e_fs_tt_redirect_udp_destroy (priv); +mlx5e_fs_tt_redirect_udp_destroy (fs); out_free:return err; }
Signature · 1 line
2.37.1
PATCH 3/15 net/mlx5e: Decouple fs_tcp from en.h
In reply to Saeed MahameedFrom: Lama Kayal <[email protected]>
Make flow steering files fs_tcp.c/h independent of en.h such that they go through the flow steering API only.
Make error reports be via mlx5_core API instead of netdev_err API, this to ensure a safe decoupling from en.h, and prevent redundant argument passing.
--- .../mellanox/mlx5/core/en_accel/fs_tcp.c | 94 +++++++++---------- .../mellanox/mlx5/core/en_accel/fs_tcp.h | 14 +-- .../mellanox/mlx5/core/en_accel/ktls.c | 8 +- .../mellanox/mlx5/core/en_accel/ktls_rx.c | 2 +- 4 files changed, 59 insertions(+), 59 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c +47 -47
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* Copyright (c) 2020, Mellanox Technologies inc. All rights reserved. */ -#include <linux/netdevice.h> +#include <mlx5_core.h> #include "en_accel/fs_tcp.h" #include "fs_core.h"
@@ -71,11 +71,11 @@ void mlx5e_accel_fs_del_sk(struct mlx5_flow_handle *rule)mlx5_del_flow_rules (rule); } -struct mlx5_flow_handle *mlx5e_accel_fs_add_sk (struct mlx5e_priv *priv, +struct mlx5_flow_handle *mlx5e_accel_fs_add_sk (struct mlx5e_flow_steering *fs,struct sock *sk,u32 tirn,uint32_t flow_tag) { -struct mlx5e_accel_fs_tcp *fs_tcp =mlx5e_fs_get_accel_tcp (priv->fs); +struct mlx5e_accel_fs_tcp *fs_tcp =mlx5e_fs_get_accel_tcp (fs);struct mlx5_flow_destination dest = {};struct mlx5e_flow_table *ft =NULL ;MLX5_DECLARE_FLOW_ACT (flow_act);
@@ -92,11 +92,11 @@ struct mlx5_flow_handle *mlx5e_accel_fs_add_sk(struct mlx5e_priv *priv,case AF_INET :accel_fs_tcp_set_ipv4_flow (spec, sk); ft = &fs_tcp->tables[ACCEL_FS_IPV4_TCP ]; -mlx5e_dbg (HW , priv,"%s flow is %pI4:%d -> %pI4:%d\n" , __func__, - &inet_sk (sk)->inet_rcv_saddr, -inet_sk (sk)->inet_sport, - &inet_sk (sk)->inet_daddr, -inet_sk (sk)->inet_dport); +mlx5_core_dbg (mlx5e_fs_get_mdev (fs),"%s flow is %pI4:%d -> %pI4:%d\n" , __func__, + &inet_sk (sk)->inet_rcv_saddr, +inet_sk (sk)->inet_sport, + &inet_sk (sk)->inet_daddr, +inet_sk (sk)->inet_dport);break ;#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 :
@@ -138,19 +138,19 @@ struct mlx5_flow_handle *mlx5e_accel_fs_add_sk(struct mlx5e_priv *priv, flow =mlx5_add_flow_rules (ft->t, spec, &flow_act, &dest,1 );if (IS_ERR (flow)) -netdev_err (priv->netdev,"mlx5_add_flow_rules() failed, flow is %ld\n" , -PTR_ERR (flow)); +mlx5_core_err (mlx5e_fs_get_mdev (fs),"mlx5_add_flow_rules() failed, flow is %ld\n" , +PTR_ERR (flow)); out:kvfree (spec);return flow; } -static int accel_fs_tcp_add_default_rule (struct mlx5e_priv *priv, +static int accel_fs_tcp_add_default_rule (struct mlx5e_flow_steering *fs,enum accel_fs_tcp_type type) { -struct mlx5e_accel_fs_tcp *fs_tcp =mlx5e_fs_get_accel_tcp (priv->fs); -struct mlx5_ttc_table *ttc =mlx5e_fs_get_ttc (priv->fs, false); +struct mlx5e_accel_fs_tcp *fs_tcp =mlx5e_fs_get_accel_tcp (fs); +struct mlx5_ttc_table *ttc =mlx5e_fs_get_ttc (fs, false);struct mlx5e_flow_table *accel_fs_t;struct mlx5_flow_destination dest;MLX5_DECLARE_FLOW_ACT (flow_act);
@@ -163,9 +163,9 @@ static int accel_fs_tcp_add_default_rule(struct mlx5e_priv *priv, rule =mlx5_add_flow_rules (accel_fs_t->t,NULL , &flow_act, &dest,1 );if (IS_ERR (rule)) { err =PTR_ERR (rule); -netdev_err (priv->netdev, -"%s: add default rule failed, accel_fs type=%d, err %d\n" , - __func__, type, err); +mlx5_core_err (mlx5e_fs_get_mdev (fs), +"%s: add default rule failed, accel_fs type=%d, err %d\n" , + __func__, type, err);return err; }
@@ -263,10 +263,10 @@ static int accel_fs_tcp_create_groups(struct mlx5e_flow_table *ft,return err; } -static int accel_fs_tcp_create_table (struct mlx5e_priv *priv,enum accel_fs_tcp_type type) +static int accel_fs_tcp_create_table (struct mlx5e_flow_steering *fs,enum accel_fs_tcp_type type) { -struct mlx5e_accel_fs_tcp *accel_tcp =mlx5e_fs_get_accel_tcp (priv->fs); -struct mlx5_flow_namespace *ns =mlx5e_fs_get_ns (priv->fs, false); +struct mlx5e_accel_fs_tcp *accel_tcp =mlx5e_fs_get_accel_tcp (fs); +struct mlx5_flow_namespace *ns =mlx5e_fs_get_ns (fs, false);struct mlx5e_flow_table *ft = &accel_tcp->tables[type];struct mlx5_flow_table_attr ft_attr = {};int err;
@@ -284,14 +284,14 @@ static int accel_fs_tcp_create_table(struct mlx5e_priv *priv, enum accel_fs_tcp_return err; } -netdev_dbg (priv->netdev,"Created fs accel table id %u level %u\n" , - ft->t->id, ft->t->level); +mlx5_core_dbg (mlx5e_fs_get_mdev (fs),"Created fs accel table id %u level %u\n" , + ft->t->id, ft->t->level); err =accel_fs_tcp_create_groups (ft, type);if (err) goto err; - err =accel_fs_tcp_add_default_rule (priv, type); + err =accel_fs_tcp_add_default_rule (fs, type);if (err) goto err;
@@ -301,18 +301,18 @@ static int accel_fs_tcp_create_table(struct mlx5e_priv *priv, enum accel_fs_tcp_return err; } -static int accel_fs_tcp_disable (struct mlx5e_priv *priv) +static int accel_fs_tcp_disable (struct mlx5e_flow_steering *fs) { -struct mlx5_ttc_table *ttc =mlx5e_fs_get_ttc (priv->fs, false); +struct mlx5_ttc_table *ttc =mlx5e_fs_get_ttc (fs, false);int err, i;for (i =0 ; i <ACCEL_FS_TCP_NUM_TYPES ; i++) {/* Modify ttc rules destination to point back to the indir TIRs */ err =mlx5_ttc_fwd_default_dest (ttc,fs_accel2tt (i));if (err) { -netdev_err (priv->netdev, -"%s: modify ttc[%d] default destination failed, err(%d)\n" , - __func__,fs_accel2tt (i), err); +mlx5_core_err (mlx5e_fs_get_mdev (fs), +"%s: modify ttc[%d] default destination failed, err(%d)\n" , + __func__,fs_accel2tt (i), err);return err; } }
@@ -320,10 +320,10 @@ static int accel_fs_tcp_disable(struct mlx5e_priv *priv)return 0 ; } -static int accel_fs_tcp_enable (struct mlx5e_priv *priv) +static int accel_fs_tcp_enable (struct mlx5e_flow_steering *fs) { -struct mlx5e_accel_fs_tcp *accel_tcp =mlx5e_fs_get_accel_tcp (priv->fs); -struct mlx5_ttc_table *ttc =mlx5e_fs_get_ttc (priv->fs, false); +struct mlx5e_accel_fs_tcp *accel_tcp =mlx5e_fs_get_accel_tcp (fs); +struct mlx5_ttc_table *ttc =mlx5e_fs_get_ttc (fs, false);struct mlx5_flow_destination dest = {};int err, i;
@@ -334,18 +334,18 @@ static int accel_fs_tcp_enable(struct mlx5e_priv *priv)/* Modify ttc rules destination to point on the accel_fs FTs */ err =mlx5_ttc_fwd_dest (ttc,fs_accel2tt (i), &dest);if (err) { -netdev_err (priv->netdev, -"%s: modify ttc[%d] destination to accel failed, err(%d)\n" , - __func__,fs_accel2tt (i), err); +mlx5_core_err (mlx5e_fs_get_mdev (fs), +"%s: modify ttc[%d] destination to accel failed, err(%d)\n" , + __func__,fs_accel2tt (i), err);return err; } }return 0 ; } -static void accel_fs_tcp_destroy_table (struct mlx5e_priv *priv,int i) +static void accel_fs_tcp_destroy_table (struct mlx5e_flow_steering *fs,int i) { -struct mlx5e_accel_fs_tcp *fs_tcp =mlx5e_fs_get_accel_tcp (priv->fs); +struct mlx5e_accel_fs_tcp *fs_tcp =mlx5e_fs_get_accel_tcp (fs);if (IS_ERR_OR_NULL (fs_tcp->tables[i].t))return ;
@@ -355,43 +355,43 @@ static void accel_fs_tcp_destroy_table(struct mlx5e_priv *priv, int i) fs_tcp->tables[i].t =NULL ; } -void mlx5e_accel_fs_tcp_destroy (struct mlx5e_priv *priv) +void mlx5e_accel_fs_tcp_destroy (struct mlx5e_flow_steering *fs) { -struct mlx5e_accel_fs_tcp *accel_tcp =mlx5e_fs_get_accel_tcp (priv->fs); +struct mlx5e_accel_fs_tcp *accel_tcp =mlx5e_fs_get_accel_tcp (fs);int i;if (!accel_tcp)return ; -accel_fs_tcp_disable (priv); +accel_fs_tcp_disable (fs);for (i =0 ; i <ACCEL_FS_TCP_NUM_TYPES ; i++) -accel_fs_tcp_destroy_table (priv, i); +accel_fs_tcp_destroy_table (fs, i);kfree (accel_tcp); -mlx5e_fs_set_accel_tcp (priv->fs,NULL ); +mlx5e_fs_set_accel_tcp (fs,NULL ); } -int mlx5e_accel_fs_tcp_create (struct mlx5e_priv *priv) +int mlx5e_accel_fs_tcp_create (struct mlx5e_flow_steering *fs) {struct mlx5e_accel_fs_tcp *accel_tcp;int i, err; -if (!MLX5_CAP_FLOWTABLE_NIC_RX (priv->mdev, ft_field_support.outer_ip_version)) +if (!MLX5_CAP_FLOWTABLE_NIC_RX (mlx5e_fs_get_mdev (fs), ft_field_support.outer_ip_version))return -EOPNOTSUPP ; accel_tcp =kvzalloc (sizeof (*accel_tcp),GFP_KERNEL );if (!accel_tcp)return -ENOMEM ; -mlx5e_fs_set_accel_tcp (priv->fs, accel_tcp); +mlx5e_fs_set_accel_tcp (fs, accel_tcp);for (i =0 ; i <ACCEL_FS_TCP_NUM_TYPES ; i++) { - err =accel_fs_tcp_create_table (priv, i); + err =accel_fs_tcp_create_table (fs, i);if (err) goto err_destroy_tables; } - err =accel_fs_tcp_enable (priv); + err =accel_fs_tcp_enable (fs);if (err) goto err_destroy_tables;
@@ -399,8 +399,8 @@ int mlx5e_accel_fs_tcp_create(struct mlx5e_priv *priv) err_destroy_tables:while (--i >=0 ) -accel_fs_tcp_destroy_table (priv, i); +accel_fs_tcp_destroy_table (fs, i);kfree (accel_tcp); -mlx5e_fs_set_accel_tcp (priv->fs,NULL ); +mlx5e_fs_set_accel_tcp (fs,NULL );return err; }
drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.h +7 -7
@@ -4,19 +4,19 @@#ifndef __MLX5E_ACCEL_FS_TCP_H__#define __MLX5E_ACCEL_FS_TCP_H__ -#include "en.h" +#include "en/fs.h" #ifdef CONFIG_MLX5_EN_TLS -int mlx5e_accel_fs_tcp_create (struct mlx5e_priv *priv); -void mlx5e_accel_fs_tcp_destroy (struct mlx5e_priv *priv); -struct mlx5_flow_handle *mlx5e_accel_fs_add_sk (struct mlx5e_priv *priv, +int mlx5e_accel_fs_tcp_create (struct mlx5e_flow_steering *fs); +void mlx5e_accel_fs_tcp_destroy (struct mlx5e_flow_steering *fs); +struct mlx5_flow_handle *mlx5e_accel_fs_add_sk (struct mlx5e_flow_steering *fs,struct sock *sk,u32 tirn,uint32_t flow_tag);void mlx5e_accel_fs_del_sk (struct mlx5_flow_handle *rule);#else -static inline int mlx5e_accel_fs_tcp_create (struct mlx5e_priv *priv) {return 0 ; } -static inline void mlx5e_accel_fs_tcp_destroy (struct mlx5e_priv *priv) {} -static inline struct mlx5_flow_handle *mlx5e_accel_fs_add_sk (struct mlx5e_priv *priv, +static inline int mlx5e_accel_fs_tcp_create (struct mlx5e_flow_steering *fs) {return 0 ; } +static inline void mlx5e_accel_fs_tcp_destroy (struct mlx5e_flow_steering *fs) {} +static inline struct mlx5_flow_handle *mlx5e_accel_fs_add_sk (struct mlx5e_flow_steering *fs,struct sock *sk,u32 tirn,uint32_t flow_tag) {return ERR_PTR (-EOPNOTSUPP ); }
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c +4 -4
@@ -118,9 +118,9 @@ int mlx5e_ktls_set_feature_rx(struct net_device *netdev, bool enable)mutex_lock (&priv->state_lock);if (enable) - err =mlx5e_accel_fs_tcp_create (priv); + err =mlx5e_accel_fs_tcp_create (priv->fs);else -mlx5e_accel_fs_tcp_destroy (priv); +mlx5e_accel_fs_tcp_destroy (priv->fs);mutex_unlock (&priv->state_lock);return err;
@@ -138,7 +138,7 @@ int mlx5e_ktls_init_rx(struct mlx5e_priv *priv)return -ENOMEM ;if (priv->netdev->features &NETIF_F_HW_TLS_RX ) { - err =mlx5e_accel_fs_tcp_create (priv); + err =mlx5e_accel_fs_tcp_create (priv->fs);if (err) {destroy_workqueue (priv->tls->rx_wq);return err;
@@ -154,7 +154,7 @@ void mlx5e_ktls_cleanup_rx(struct mlx5e_priv *priv)return ;if (priv->netdev->features &NETIF_F_HW_TLS_RX ) -mlx5e_accel_fs_tcp_destroy (priv); +mlx5e_accel_fs_tcp_destroy (priv->fs);destroy_workqueue (priv->tls->rx_wq); }
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +1 -1
@@ -111,7 +111,7 @@ static void accel_rule_handle_work(struct work_struct *work)if (unlikely (test_bit (MLX5E_PRIV_RX_FLAG_DELETING , priv_rx->flags))) goto out; - rule =mlx5e_accel_fs_add_sk (accel_rule->priv, priv_rx->sk, + rule =mlx5e_accel_fs_add_sk (accel_rule->priv->fs, priv_rx->sk,mlx5e_tir_get_tirn (&priv_rx->tir),MLX5_FS_DEFAULT_FLOW_TAG );if (!IS_ERR_OR_NULL (rule))
Signature · 1 line
2.37.1
PATCH 4/15 net/mlx5e: Drop priv argument of ptp function in en_fs
In reply to Saeed MahameedFrom: Lama Kayal <[email protected]>
Both mlx5e_ptp_alloc_rx_fs and mlx5e_ptp_free_rx_fs only make use of two priv member, pass them directly instead. This will help dropping priv from all en_fs file.
--- .../net/ethernet/mellanox/mlx5/core/en/ptp.c | 24 +++++++++---------- .../net/ethernet/mellanox/mlx5/core/en/ptp.h | 6 +++-- .../net/ethernet/mellanox/mlx5/core/en_fs.c | 4 ++-- 3 files changed, 18 insertions(+), 16 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c +12 -12
@@ -622,12 +622,10 @@ static int mlx5e_ptp_set_state(struct mlx5e_ptp *c, struct mlx5e_params *params)return bitmap_empty (c->state,MLX5E_PTP_STATE_NUM_STATES ) ? -EINVAL :0 ; } -static void mlx5e_ptp_rx_unset_fs (struct mlx5e_priv *priv) +static void mlx5e_ptp_rx_unset_fs (struct mlx5e_flow_steering *fs) { -struct mlx5e_flow_steering *fs = priv->fs; -struct mlx5e_ptp_fs *ptp_fs; +struct mlx5e_ptp_fs *ptp_fs =mlx5e_fs_get_ptp (fs); - ptp_fs =mlx5e_fs_get_ptp (fs);if (!ptp_fs->valid)return ;
@@ -801,29 +799,31 @@ int mlx5e_ptp_get_rqn(struct mlx5e_ptp *c, u32 *rqn)return 0 ; } -int mlx5e_ptp_alloc_rx_fs (struct mlx5e_priv *priv) +int mlx5e_ptp_alloc_rx_fs (struct mlx5e_flow_steering *fs, +const struct mlx5e_profile *profile) {struct mlx5e_ptp_fs *ptp_fs; -if (!mlx5e_profile_feature_cap (priv->profile,PTP_RX )) +if (!mlx5e_profile_feature_cap (profile,PTP_RX ))return 0 ; ptp_fs =kzalloc (sizeof (*ptp_fs),GFP_KERNEL );if (!ptp_fs)return -ENOMEM ; -mlx5e_fs_set_ptp (priv->fs, ptp_fs); +mlx5e_fs_set_ptp (fs, ptp_fs);return 0 ; } -void mlx5e_ptp_free_rx_fs (struct mlx5e_priv *priv) +void mlx5e_ptp_free_rx_fs (struct mlx5e_flow_steering *fs, +const struct mlx5e_profile *profile) { -struct mlx5e_ptp_fs *ptp_fs =mlx5e_fs_get_ptp (priv->fs); +struct mlx5e_ptp_fs *ptp_fs =mlx5e_fs_get_ptp (fs); -if (!mlx5e_profile_feature_cap (priv->profile,PTP_RX )) +if (!mlx5e_profile_feature_cap (profile,PTP_RX ))return ; -mlx5e_ptp_rx_unset_fs (priv); +mlx5e_ptp_rx_unset_fs (fs);kfree (ptp_fs); }
@@ -849,6 +849,6 @@ int mlx5e_ptp_rx_manage_fs(struct mlx5e_priv *priv, bool set)netdev_WARN_ONCE (priv->netdev,"Don't try to remove PTP RX-FS rules" );return -EINVAL ; } -mlx5e_ptp_rx_unset_fs (priv); +mlx5e_ptp_rx_unset_fs (priv->fs);return 0 ; }
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.h +4 -2
@@ -74,8 +74,10 @@ void mlx5e_ptp_close(struct mlx5e_ptp *c);void mlx5e_ptp_activate_channel (struct mlx5e_ptp *c);void mlx5e_ptp_deactivate_channel (struct mlx5e_ptp *c);int mlx5e_ptp_get_rqn (struct mlx5e_ptp *c,u32 *rqn); -int mlx5e_ptp_alloc_rx_fs (struct mlx5e_priv *priv); -void mlx5e_ptp_free_rx_fs (struct mlx5e_priv *priv); +int mlx5e_ptp_alloc_rx_fs (struct mlx5e_flow_steering *fs, +const struct mlx5e_profile *profile); +void mlx5e_ptp_free_rx_fs (struct mlx5e_flow_steering *fs, +const struct mlx5e_profile *profile);int mlx5e_ptp_rx_manage_fs (struct mlx5e_priv *priv,bool set);enum {
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +2 -2
@@ -1338,7 +1338,7 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv) goto err_destroy_l2_table; } - err =mlx5e_ptp_alloc_rx_fs (priv); + err =mlx5e_ptp_alloc_rx_fs (priv->fs, priv->profile);if (err) goto err_destory_vlan_table;
@@ -1362,7 +1362,7 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv)void mlx5e_destroy_flow_steering (struct mlx5e_priv *priv) { -mlx5e_ptp_free_rx_fs (priv); +mlx5e_ptp_free_rx_fs (priv->fs, priv->profile);mlx5e_destroy_vlan_table (priv);mlx5e_destroy_l2_table (priv);mlx5e_destroy_ttc_table (priv);
Signature · 1 line
2.37.1
PATCH 5/15 net/mlx5e: Convert ethtool_steering member of flow_steering struct to pointer
In reply to Saeed MahameedFrom: Lama Kayal <[email protected]>
Convert mlx5e_ethtool_steering member of mlx5e_flow_steering to a pointer, and allocate dynamically for each profile at flow_steering init.
--- .../net/ethernet/mellanox/mlx5/core/en_fs.c | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +33 -8
@@ -50,7 +50,7 @@ struct mlx5e_flow_steering {struct mlx5_flow_namespace *ns;struct mlx5_flow_namespace *egress_ns;#ifdef CONFIG_MLX5_EN_RXNFC -struct mlx5e_ethtool_steering ethtool; +struct mlx5e_ethtool_steering *ethtool;#endif struct mlx5e_tc_table *tc;struct mlx5e_promisc_table promisc;
@@ -1407,6 +1407,31 @@ struct mlx5e_tc_table *mlx5e_fs_get_tc(struct mlx5e_flow_steering *fs)return fs->tc; } +#ifdef CONFIG_MLX5_EN_RXNFC +static int mlx5e_fs_ethtool_alloc (struct mlx5e_flow_steering *fs) +{ + fs->ethtool =kvzalloc (sizeof (*fs->ethtool),GFP_KERNEL ); + +if (!fs->ethtool) +return -ENOMEM ; +return 0 ; +} + +static void mlx5e_fs_ethtool_free (struct mlx5e_flow_steering *fs) +{ +kvfree (fs->ethtool); +} + +struct mlx5e_ethtool_steering *mlx5e_fs_get_ethtool (struct mlx5e_flow_steering *fs) +{ +return fs->ethtool; +} +#else +static int mlx5e_fs_ethtool_alloc (struct mlx5e_flow_steering *fs) +{return 0 ; } +static void mlx5e_fs_ethtool_free (struct mlx5e_flow_steering *fs) { } +#endif +struct mlx5e_flow_steering *mlx5e_fs_init (const struct mlx5e_profile *profile,struct mlx5_core_dev *mdev,bool state_destroy)
@@ -1432,7 +1457,13 @@ struct mlx5e_flow_steering *mlx5e_fs_init(const struct mlx5e_profile *profile, goto err_free_vlan; } + err =mlx5e_fs_ethtool_alloc (fs); +if (err) + goto err_free_tc; +return fs; +err_free_tc: +mlx5e_fs_tc_free (fs); err_free_fs:kvfree (fs); err_free_vlan:
@@ -1443,6 +1474,7 @@ struct mlx5e_flow_steering *mlx5e_fs_init(const struct mlx5e_profile *profile,void mlx5e_fs_cleanup (struct mlx5e_flow_steering *fs) { +mlx5e_fs_ethtool_free (fs);mlx5e_fs_tc_free (fs);mlx5e_fs_vlan_free (fs);kvfree (fs);
@@ -1466,13 +1498,6 @@ void mlx5e_fs_set_ns(struct mlx5e_flow_steering *fs, struct mlx5_flow_namespace fs->egress_ns = ns; } -#ifdef CONFIG_MLX5_EN_RXNFC -struct mlx5e_ethtool_steering *mlx5e_fs_get_ethtool (struct mlx5e_flow_steering *fs) -{ -return &fs->ethtool; -} -#endif -struct mlx5_ttc_table *mlx5e_fs_get_ttc (struct mlx5e_flow_steering *fs,bool inner) {return inner ? fs->inner_ttc : fs->ttc;
Signature · 1 line
2.37.1
PATCH 6/15 net/mlx5e: Directly get flow_steering struct as input when init/cleanup ethtool steering
In reply to Saeed MahameedFrom: Lama Kayal <[email protected]>
Let both mlx5e_ethtool_init_steering and mlx5e_ethtool_cleanup_steering get ethtool steering struct as input instead of priv, as passing priv is obsolete.
Also modify other function through the flow similarly.
--- .../net/ethernet/mellanox/mlx5/core/en/fs.h | 8 ++++---- .../net/ethernet/mellanox/mlx5/core/en_fs.c | 4 ++-- .../mellanox/mlx5/core/en_fs_ethtool.c | 20 +++++++++---------- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 4 ++-- .../ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/fs.h +4 -4
@@ -109,14 +109,14 @@ struct mlx5e_ethtool_steering {int tot_num_rules; }; -void mlx5e_ethtool_init_steering (struct mlx5e_priv *priv); -void mlx5e_ethtool_cleanup_steering (struct mlx5e_priv *priv); +void mlx5e_ethtool_init_steering (struct mlx5e_flow_steering *fs); +void mlx5e_ethtool_cleanup_steering (struct mlx5e_flow_steering *fs);int mlx5e_ethtool_set_rxnfc (struct mlx5e_priv *priv,struct ethtool_rxnfc *cmd);int mlx5e_ethtool_get_rxnfc (struct mlx5e_priv *priv,struct ethtool_rxnfc *info,u32 *rule_locs);#else -static inline void mlx5e_ethtool_init_steering (struct mlx5e_priv *priv) { } -static inline void mlx5e_ethtool_cleanup_steering (struct mlx5e_priv *priv) { } +static inline void mlx5e_ethtool_init_steering (struct mlx5e_flow_steering *fs) { } +static inline void mlx5e_ethtool_cleanup_steering (struct mlx5e_flow_steering *fs) { }static inline int mlx5e_ethtool_set_rxnfc (struct mlx5e_priv *priv,struct ethtool_rxnfc *cmd) {return -EOPNOTSUPP ; } static inline int mlx5e_ethtool_get_rxnfc(struct mlx5e_priv *priv,
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +2 -2
@@ -1342,7 +1342,7 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv)if (err) goto err_destory_vlan_table; -mlx5e_ethtool_init_steering (priv); +mlx5e_ethtool_init_steering (priv->fs);return 0 ;
@@ -1368,7 +1368,7 @@ void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv)mlx5e_destroy_ttc_table (priv);mlx5e_destroy_inner_ttc_table (priv);mlx5e_arfs_destroy_tables (priv); -mlx5e_ethtool_cleanup_steering (priv); +mlx5e_ethtool_cleanup_steering (priv->fs); }static int mlx5e_fs_vlan_alloc (struct mlx5e_flow_steering *fs)
drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c +10 -10
@@ -501,10 +501,10 @@ add_ethtool_flow_rule(struct mlx5e_priv *priv,return err ?ERR_PTR (err) : rule; } -static void del_ethtool_rule (struct mlx5e_priv *priv, +static void del_ethtool_rule (struct mlx5e_flow_steering *fs,struct mlx5e_ethtool_rule *eth_rule) { -struct mlx5e_ethtool_steering *ethtool =mlx5e_fs_get_ethtool (priv->fs); +struct mlx5e_ethtool_steering *ethtool =mlx5e_fs_get_ethtool (fs);if (eth_rule->rule)mlx5_del_flow_rules (eth_rule->rule);if (eth_rule->rss)
@@ -535,7 +535,7 @@ static struct mlx5e_ethtool_rule *get_ethtool_rule(struct mlx5e_priv *priv, eth_rule =find_ethtool_rule (priv, location);if (eth_rule) -del_ethtool_rule (priv, eth_rule); +del_ethtool_rule (priv->fs, eth_rule); eth_rule =kzalloc (sizeof (*eth_rule),GFP_KERNEL );if (!eth_rule)
@@ -758,7 +758,7 @@ mlx5e_ethtool_flow_replace(struct mlx5e_priv *priv,return 0 ; del_ethtool_rule: -del_ethtool_rule (priv, eth_rule); +del_ethtool_rule (priv->fs, eth_rule);return err; }
@@ -778,7 +778,7 @@ mlx5e_ethtool_flow_remove(struct mlx5e_priv *priv, int location) goto out; } -del_ethtool_rule (priv, eth_rule); +del_ethtool_rule (priv->fs, eth_rule); out:return err; }
@@ -831,19 +831,19 @@ mlx5e_ethtool_get_all_flows(struct mlx5e_priv *priv,return err; } -void mlx5e_ethtool_cleanup_steering (struct mlx5e_priv *priv) +void mlx5e_ethtool_cleanup_steering (struct mlx5e_flow_steering *fs) { -struct mlx5e_ethtool_steering *ethtool =mlx5e_fs_get_ethtool (priv->fs); +struct mlx5e_ethtool_steering *ethtool =mlx5e_fs_get_ethtool (fs);struct mlx5e_ethtool_rule *iter;struct mlx5e_ethtool_rule *temp;list_for_each_entry_safe (iter, temp, ðtool->rules, list) -del_ethtool_rule (priv, iter); +del_ethtool_rule (fs, iter); } -void mlx5e_ethtool_init_steering (struct mlx5e_priv *priv) +void mlx5e_ethtool_init_steering (struct mlx5e_flow_steering *fs) { -struct mlx5e_ethtool_steering *ethtool =mlx5e_fs_get_ethtool (priv->fs); +struct mlx5e_ethtool_steering *ethtool =mlx5e_fs_get_ethtool (fs);INIT_LIST_HEAD (ðtool->rules); }
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +2 -2
@@ -886,7 +886,7 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv)if (err) goto err_destroy_root_ft; -mlx5e_ethtool_init_steering (priv); +mlx5e_ethtool_init_steering (priv->fs);return 0 ;
@@ -907,7 +907,7 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv)static void mlx5e_cleanup_rep_rx (struct mlx5e_priv *priv) { -mlx5e_ethtool_cleanup_steering (priv); +mlx5e_ethtool_cleanup_steering (priv->fs);rep_vport_rx_rule_destroy (priv);mlx5e_destroy_rep_root_ft (priv);mlx5_destroy_ttc_table (mlx5e_fs_get_ttc (priv->fs, false));
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +2 -2
@@ -344,7 +344,7 @@ static int mlx5i_create_flow_steering(struct mlx5e_priv *priv) goto err_destroy_arfs_tables; } -mlx5e_ethtool_init_steering (priv); +mlx5e_ethtool_init_steering (priv->fs);return 0 ;
@@ -358,7 +358,7 @@ static void mlx5i_destroy_flow_steering(struct mlx5e_priv *priv) {mlx5e_destroy_ttc_table (priv);mlx5e_arfs_destroy_tables (priv); -mlx5e_ethtool_cleanup_steering (priv); +mlx5e_ethtool_cleanup_steering (priv->fs); }static int mlx5i_init_rx (struct mlx5e_priv *priv)
Signature · 1 line
2.37.1
PATCH 7/15 net/mlx5e: Separate ethtool_steering from fs.h and make private
In reply to Saeed MahameedFrom: Lama Kayal <[email protected]>
Create a new fs_ethtool.h header file, where ethtool steering init and cleanup functions are declared in it.
Make mlx5e_ethtool_steering struct private and declare at en_fs_ethtool.c.
--- .../net/ethernet/mellanox/mlx5/core/en/fs.h | 32 ------------------- .../mellanox/mlx5/core/en/fs_ethtool.h | 29 +++++++++++++++++ .../ethernet/mellanox/mlx5/core/en_ethtool.c | 1 + .../net/ethernet/mellanox/mlx5/core/en_fs.c | 9 ++---- .../mellanox/mlx5/core/en_fs_ethtool.c | 29 +++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en_rep.c | 1 + .../mellanox/mlx5/core/ipoib/ethtool.c | 1 + .../ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 1 + 8 files changed, 65 insertions(+), 38 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/fs_ethtool.h
drivers/net/ethernet/mellanox/mlx5/core/en/fs.h +0 -32
@@ -92,38 +92,6 @@ enum {struct mlx5e_flow_steering ;struct mlx5e_priv ; -#ifdef CONFIG_MLX5_EN_RXNFC - -struct mlx5e_ethtool_table { -struct mlx5_flow_table *ft; -int num_rules; -}; - -#define ETHTOOL_NUM_L3_L4_FTS 7 -#define ETHTOOL_NUM_L2_FTS 4 - -struct mlx5e_ethtool_steering { -struct mlx5e_ethtool_table l3_l4_ft[ETHTOOL_NUM_L3_L4_FTS ]; -struct mlx5e_ethtool_table l2_ft[ETHTOOL_NUM_L2_FTS ]; -struct list_head rules; -int tot_num_rules; -}; - -void mlx5e_ethtool_init_steering (struct mlx5e_flow_steering *fs); -void mlx5e_ethtool_cleanup_steering (struct mlx5e_flow_steering *fs); -int mlx5e_ethtool_set_rxnfc (struct mlx5e_priv *priv,struct ethtool_rxnfc *cmd); -int mlx5e_ethtool_get_rxnfc (struct mlx5e_priv *priv, -struct ethtool_rxnfc *info,u32 *rule_locs); -#else -static inline void mlx5e_ethtool_init_steering (struct mlx5e_flow_steering *fs) { } -static inline void mlx5e_ethtool_cleanup_steering (struct mlx5e_flow_steering *fs) { } -static inline int mlx5e_ethtool_set_rxnfc (struct mlx5e_priv *priv,struct ethtool_rxnfc *cmd) -{return -EOPNOTSUPP ; } -static inline int mlx5e_ethtool_get_rxnfc (struct mlx5e_priv *priv, -struct ethtool_rxnfc *info,u32 *rule_locs) -{return -EOPNOTSUPP ; } -#endif /* CONFIG_MLX5_EN_RXNFC */ -#ifdef CONFIG_MLX5_EN_ARFS struct mlx5e_arfs_tables ;
drivers/net/ethernet/mellanox/mlx5/core/en/fs_ethtool.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. */ + +#ifndef __MLX5E_FS_ETHTOOL_H__ +#define __MLX5E_FS_ETHTOOL_H__ + +struct mlx5e_priv ; +struct mlx5e_ethtool_steering ; +#ifdef CONFIG_MLX5_EN_RXNFC +int mlx5e_ethtool_alloc (struct mlx5e_ethtool_steering **ethtool); +void mlx5e_ethtool_free (struct mlx5e_ethtool_steering *ethtool); +void mlx5e_ethtool_init_steering (struct mlx5e_flow_steering *fs); +void mlx5e_ethtool_cleanup_steering (struct mlx5e_flow_steering *fs); +int mlx5e_ethtool_set_rxnfc (struct mlx5e_priv *priv,struct ethtool_rxnfc *cmd); +int mlx5e_ethtool_get_rxnfc (struct mlx5e_priv *priv, +struct ethtool_rxnfc *info,u32 *rule_locs); +#else +static inline int mlx5e_ethtool_alloc (struct mlx5e_ethtool_steering **ethtool) +{return 0 ; } +static inline void mlx5e_ethtool_free (struct mlx5e_ethtool_steering *ethtool) { } +static inline void mlx5e_ethtool_init_steering (struct mlx5e_flow_steering *fs) { } +static inline void mlx5e_ethtool_cleanup_steering (struct mlx5e_flow_steering *fs) { } +static inline int mlx5e_ethtool_set_rxnfc (struct mlx5e_priv *priv,struct ethtool_rxnfc *cmd) +{return -EOPNOTSUPP ; } +static inline int mlx5e_ethtool_get_rxnfc (struct mlx5e_priv *priv, +struct ethtool_rxnfc *info,u32 *rule_locs) +{return -EOPNOTSUPP ; } +#endif +#endif
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +1 -0
@@ -38,6 +38,7 @@#include "en/xsk/pool.h" #include "en/ptp.h" #include "lib/clock.h" +#include "en/fs_ethtool.h" void mlx5e_ethtool_get_drvinfo (struct mlx5e_priv *priv,struct ethtool_drvinfo *drvinfo)
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +3 -6
@@ -40,6 +40,7 @@#include "en_tc.h" #include "lib/mpfs.h" #include "en/ptp.h" +#include "en/fs_ethtool.h" struct mlx5e_flow_steering {struct work_struct set_rx_mode_work;
@@ -1410,16 +1411,12 @@ struct mlx5e_tc_table *mlx5e_fs_get_tc(struct mlx5e_flow_steering *fs)#ifdef CONFIG_MLX5_EN_RXNFC static int mlx5e_fs_ethtool_alloc (struct mlx5e_flow_steering *fs) { - fs->ethtool =kvzalloc (sizeof (*fs->ethtool),GFP_KERNEL ); - -if (!fs->ethtool) -return -ENOMEM ; -return 0 ; +return mlx5e_ethtool_alloc (&fs->ethtool); }static void mlx5e_fs_ethtool_free (struct mlx5e_flow_steering *fs) { -kvfree (fs->ethtool); +mlx5e_ethtool_free (fs->ethtool); }struct mlx5e_ethtool_steering *mlx5e_fs_get_ethtool (struct mlx5e_flow_steering *fs)
drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c +29 -0
@@ -34,6 +34,22 @@#include "en.h" #include "en/params.h" #include "en/xsk/pool.h" +#include "en/fs_ethtool.h" + +struct mlx5e_ethtool_table { +struct mlx5_flow_table *ft; +int num_rules; +}; + +#define ETHTOOL_NUM_L3_L4_FTS 7 +#define ETHTOOL_NUM_L2_FTS 4 + +struct mlx5e_ethtool_steering { +struct mlx5e_ethtool_table l3_l4_ft[ETHTOOL_NUM_L3_L4_FTS ]; +struct mlx5e_ethtool_table l2_ft[ETHTOOL_NUM_L2_FTS ]; +struct list_head rules; +int tot_num_rules; +};static int flow_type_to_traffic_type (u32 flow_type);
@@ -831,6 +847,19 @@ mlx5e_ethtool_get_all_flows(struct mlx5e_priv *priv,return err; } +int mlx5e_ethtool_alloc (struct mlx5e_ethtool_steering **ethtool) +{ + *ethtool =kvzalloc (sizeof (**ethtool),GFP_KERNEL ); +if (!*ethtool) +return -ENOMEM ; +return 0 ; +} + +void mlx5e_ethtool_free (struct mlx5e_ethtool_steering *ethtool) +{ +kvfree (ethtool); +} +void mlx5e_ethtool_cleanup_steering (struct mlx5e_flow_steering *fs) {struct mlx5e_ethtool_steering *ethtool =mlx5e_fs_get_ethtool (fs);
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +1 -0
@@ -56,6 +56,7 @@#include "en_accel/ipsec.h" #include "en/tc/int_port.h" #include "en/ptp.h" +#include "en/fs_ethtool.h" #define MLX5E_REP_PARAMS_DEF_LOG_SQ_SIZE \ max(0x7, MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE)
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c +1 -0
@@ -32,6 +32,7 @@#include "en.h" #include "ipoib.h" +#include "en/fs_ethtool.h" static void mlx5i_get_drvinfo (struct net_device *dev,struct ethtool_drvinfo *drvinfo)
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +1 -0
@@ -35,6 +35,7 @@#include "en.h" #include "en/params.h" #include "ipoib.h" +#include "en/fs_ethtool.h" #define IB_DEFAULT_Q_KEY 0xb1b#define MLX5I_PARAMS_DEFAULT_LOG_RQ_SIZE 9
Signature · 1 line
2.37.1
PATCH 8/15 net/mlx5e: Introduce flow steering debug macros
In reply to Saeed MahameedFrom: Lama Kayal <[email protected]>
Introduce flow steering debug macros family, fs_*. These macros bring clean finish to the decoupling of flow steering process such that all flow steering flows can report warnings and provide debug information via these exclusive macros.
--- .../net/ethernet/mellanox/mlx5/core/en/fs.h | 13 ++++ .../mellanox/mlx5/core/en/fs_tt_redirect.c | 40 +++++------ .../mellanox/mlx5/core/en_accel/fs_tcp.c | 33 +++++----- .../net/ethernet/mellanox/mlx5/core/en_fs.c | 66 +++++++++---------- 4 files changed, 76 insertions(+), 76 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/fs.h +13 -0
@@ -176,5 +176,18 @@ int mlx5e_fs_vlan_rx_kill_vid(struct mlx5e_flow_steering *fs,struct net_device *netdev, __be16 proto, u16 vid);void mlx5e_fs_init_l2_addr (struct mlx5e_flow_steering *fs,struct net_device *netdev); + +#define fs_err (fs, fmt, ...) \ + mlx5_core_err(mlx5e_fs_get_mdev(fs), fmt, ##__VA_ARGS__) + +#define fs_dbg (fs, fmt, ...) \ + mlx5_core_dbg(mlx5e_fs_get_mdev(fs), fmt, ##__VA_ARGS__) + +#define fs_warn (fs, fmt, ...) \ + mlx5_core_warn(mlx5e_fs_get_mdev(fs), fmt, ##__VA_ARGS__) + +#define fs_warn_once (fs, fmt, ...) \ + mlx5_core_warn_once(mlx5e_fs_get_mdev(fs), fmt, ##__VA_ARGS__) +#endif /* __MLX5E_FLOW_STEER_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c +18 -22
@@ -105,8 +105,8 @@ mlx5e_fs_tt_redirect_udp_add_rule(struct mlx5e_flow_steering *fs,if (IS_ERR (rule)) { err =PTR_ERR (rule); -mlx5_core_err (mlx5e_fs_get_mdev (fs),"%s: add %s rule failed, err %d\n" , - __func__,fs_udp_type2str (type), err); +fs_err (fs,"%s: add %s rule failed, err %d\n" , + __func__,fs_udp_type2str (type), err); }return rule; }
@@ -127,9 +127,8 @@ static int fs_udp_add_default_rule(struct mlx5e_flow_steering *fs, enum fs_udp_t rule =mlx5_add_flow_rules (fs_udp_t->t,NULL , &flow_act, &dest,1 );if (IS_ERR (rule)) { err =PTR_ERR (rule); -mlx5_core_err (mlx5e_fs_get_mdev (fs), -"%s: add default rule failed, fs type=%d, err %d\n" , - __func__, type, err); +fs_err (fs,"%s: add default rule failed, fs type=%d, err %d\n" , + __func__, type, err);return err; }
@@ -264,9 +263,8 @@ static int fs_udp_disable(struct mlx5e_flow_steering *fs)/* Modify ttc rules destination to point back to the indir TIRs */ err =mlx5_ttc_fwd_default_dest (ttc,fs_udp2tt (i));if (err) { -mlx5_core_err (mlx5e_fs_get_mdev (fs), -"%s: modify ttc[%d] default destination failed, err(%d)\n" , - __func__,fs_udp2tt (i), err); +fs_err (fs,"%s: modify ttc[%d] default destination failed, err(%d)\n" , + __func__,fs_udp2tt (i), err);return err; } }
@@ -288,9 +286,8 @@ static int fs_udp_enable(struct mlx5e_flow_steering *fs)/* Modify ttc rules destination to point on the accel_fs FTs */ err =mlx5_ttc_fwd_dest (ttc,fs_udp2tt (i), &dest);if (err) { -mlx5_core_err (mlx5e_fs_get_mdev (fs), -"%s: modify ttc[%d] destination to accel failed, err(%d)\n" , - __func__,fs_udp2tt (i), err); +fs_err (fs,"%s: modify ttc[%d] destination to accel failed, err(%d)\n" , + __func__,fs_udp2tt (i), err);return err; } }
@@ -389,8 +386,8 @@ mlx5e_fs_tt_redirect_any_add_rule(struct mlx5e_flow_steering *fs,if (IS_ERR (rule)) { err =PTR_ERR (rule); -mlx5_core_err (mlx5e_fs_get_mdev (fs),"%s: add ANY rule failed, err %d\n" , - __func__, err); +fs_err (fs,"%s: add ANY rule failed, err %d\n" , + __func__, err); }return rule; }
@@ -410,9 +407,8 @@ static int fs_any_add_default_rule(struct mlx5e_flow_steering *fs) rule =mlx5_add_flow_rules (fs_any_t->t,NULL , &flow_act, &dest,1 );if (IS_ERR (rule)) { err =PTR_ERR (rule); -mlx5_core_err (mlx5e_fs_get_mdev (fs), -"%s: add default rule failed, fs type=ANY, err %d\n" , - __func__, err); +fs_err (fs,"%s: add default rule failed, fs type=ANY, err %d\n" , + __func__, err);return err; }
@@ -524,9 +520,9 @@ static int fs_any_disable(struct mlx5e_flow_steering *fs)/* Modify ttc rules destination to point back to the indir TIRs */ err =mlx5_ttc_fwd_default_dest (ttc,MLX5_TT_ANY );if (err) { -mlx5_core_err (mlx5e_fs_get_mdev (fs), -"%s: modify ttc[%d] default destination failed, err(%d)\n" , - __func__,MLX5_TT_ANY , err); +fs_err (fs, +"%s: modify ttc[%d] default destination failed, err(%d)\n" , + __func__,MLX5_TT_ANY , err);return err; }return 0 ;
@@ -545,9 +541,9 @@ static int fs_any_enable(struct mlx5e_flow_steering *fs)/* Modify ttc rules destination to point on the accel_fs FTs */ err =mlx5_ttc_fwd_dest (ttc,MLX5_TT_ANY , &dest);if (err) { -mlx5_core_err (mlx5e_fs_get_mdev (fs), -"%s: modify ttc[%d] destination to accel failed, err(%d)\n" , - __func__,MLX5_TT_ANY , err); +fs_err (fs, +"%s: modify ttc[%d] destination to accel failed, err(%d)\n" , + __func__,MLX5_TT_ANY , err);return err; }return 0 ;
drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c +15 -18
@@ -92,11 +92,11 @@ struct mlx5_flow_handle *mlx5e_accel_fs_add_sk(struct mlx5e_flow_steering *fs,case AF_INET :accel_fs_tcp_set_ipv4_flow (spec, sk); ft = &fs_tcp->tables[ACCEL_FS_IPV4_TCP ]; -mlx5_core_dbg (mlx5e_fs_get_mdev (fs),"%s flow is %pI4:%d -> %pI4:%d\n" , __func__, - &inet_sk (sk)->inet_rcv_saddr, -inet_sk (sk)->inet_sport, - &inet_sk (sk)->inet_daddr, -inet_sk (sk)->inet_dport); +fs_dbg (fs,"%s flow is %pI4:%d -> %pI4:%d\n" , __func__, + &inet_sk (sk)->inet_rcv_saddr, +inet_sk (sk)->inet_sport, + &inet_sk (sk)->inet_daddr, +inet_sk (sk)->inet_dport);break ;#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 :
@@ -138,8 +138,7 @@ struct mlx5_flow_handle *mlx5e_accel_fs_add_sk(struct mlx5e_flow_steering *fs, flow =mlx5_add_flow_rules (ft->t, spec, &flow_act, &dest,1 );if (IS_ERR (flow)) -mlx5_core_err (mlx5e_fs_get_mdev (fs),"mlx5_add_flow_rules() failed, flow is %ld\n" , -PTR_ERR (flow)); +fs_err (fs,"mlx5_add_flow_rules() failed, flow is %ld\n" ,PTR_ERR (flow)); out:kvfree (spec);
@@ -163,9 +162,8 @@ static int accel_fs_tcp_add_default_rule(struct mlx5e_flow_steering *fs, rule =mlx5_add_flow_rules (accel_fs_t->t,NULL , &flow_act, &dest,1 );if (IS_ERR (rule)) { err =PTR_ERR (rule); -mlx5_core_err (mlx5e_fs_get_mdev (fs), -"%s: add default rule failed, accel_fs type=%d, err %d\n" , - __func__, type, err); +fs_err (fs,"%s: add default rule failed, accel_fs type=%d, err %d\n" , + __func__, type, err);return err; }
@@ -284,8 +282,8 @@ static int accel_fs_tcp_create_table(struct mlx5e_flow_steering *fs, enum accel_return err; } -mlx5_core_dbg (mlx5e_fs_get_mdev (fs),"Created fs accel table id %u level %u\n" , - ft->t->id, ft->t->level); +fs_dbg (fs,"Created fs accel table id %u level %u\n" , + ft->t->id, ft->t->level); err =accel_fs_tcp_create_groups (ft, type);if (err)
@@ -310,9 +308,9 @@ static int accel_fs_tcp_disable(struct mlx5e_flow_steering *fs)/* Modify ttc rules destination to point back to the indir TIRs */ err =mlx5_ttc_fwd_default_dest (ttc,fs_accel2tt (i));if (err) { -mlx5_core_err (mlx5e_fs_get_mdev (fs), -"%s: modify ttc[%d] default destination failed, err(%d)\n" , - __func__,fs_accel2tt (i), err); +fs_err (fs, +"%s: modify ttc[%d] default destination failed, err(%d)\n" , + __func__,fs_accel2tt (i), err);return err; } }
@@ -334,9 +332,8 @@ static int accel_fs_tcp_enable(struct mlx5e_flow_steering *fs)/* Modify ttc rules destination to point on the accel_fs FTs */ err =mlx5_ttc_fwd_dest (ttc,fs_accel2tt (i), &dest);if (err) { -mlx5_core_err (mlx5e_fs_get_mdev (fs), -"%s: modify ttc[%d] destination to accel failed, err(%d)\n" , - __func__,fs_accel2tt (i), err); +fs_err (fs,"%s: modify ttc[%d] destination to accel failed, err(%d)\n" , + __func__,fs_accel2tt (i), err);return err; } }
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +30 -36
182 lines not on this page · raw message
Signature · 1 line
2.37.1
PATCH 9/15 net/mlx5e: Make flow steering arfs independent of priv
In reply to Saeed MahameedFrom: Lama Kayal <[email protected]>
Decouple arfs flow steering functionality from priv.
Make all arfs functions defined under fs.h get flow_steering struct as an argument, thus helping with the process of decoupling the whole flow steering API from en.h.
--- .../net/ethernet/mellanox/mlx5/core/en/fs.h | 22 +++-- .../net/ethernet/mellanox/mlx5/core/en_arfs.c | 87 ++++++++++--------- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 4 +- .../net/ethernet/mellanox/mlx5/core/en_fs.c | 9 +- .../net/ethernet/mellanox/mlx5/core/en_main.c | 4 +- .../ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 10 ++- 6 files changed, 74 insertions(+), 62 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/fs.h +14 -8
@@ -90,22 +90,28 @@ enum { };struct mlx5e_flow_steering ; +struct mlx5e_rx_res ;struct mlx5e_priv ;#ifdef CONFIG_MLX5_EN_ARFS struct mlx5e_arfs_tables ; -int mlx5e_arfs_create_tables (struct mlx5e_priv *priv); -void mlx5e_arfs_destroy_tables (struct mlx5e_priv *priv); -int mlx5e_arfs_enable (struct mlx5e_priv *priv); -int mlx5e_arfs_disable (struct mlx5e_priv *priv); +int mlx5e_arfs_create_tables (struct mlx5e_flow_steering *fs, +struct mlx5e_rx_res *rx_res,bool ntuple); +void mlx5e_arfs_destroy_tables (struct mlx5e_flow_steering *fs,bool ntuple); +int mlx5e_arfs_enable (struct mlx5e_flow_steering *fs); +int mlx5e_arfs_disable (struct mlx5e_flow_steering *fs);int mlx5e_rx_flow_steer (struct net_device *dev,const struct sk_buff *skb,u16 rxq_index,u32 flow_id);#else -static inline int mlx5e_arfs_create_tables (struct mlx5e_priv *priv) {return 0 ; } -static inline void mlx5e_arfs_destroy_tables (struct mlx5e_priv *priv) {} -static inline int mlx5e_arfs_enable (struct mlx5e_priv *priv) {return -EOPNOTSUPP ; } -static inline int mlx5e_arfs_disable (struct mlx5e_priv *priv) {return -EOPNOTSUPP ; } +static inline int mlx5e_arfs_create_tables (struct mlx5e_flow_steering *fs, +struct mlx5e_rx_res *rx_res,bool ntuple) +{return 0 ; } +static inline void mlx5e_arfs_destroy_tables (struct mlx5e_flow_steering *fs,bool ntuple) {} +static inline int mlx5e_arfs_enable (struct mlx5e_flow_steering *fs) +{return -EOPNOTSUPP ; } +static inline int mlx5e_arfs_disable (struct mlx5e_flow_steering *fs) +{return -EOPNOTSUPP ; }#endif #ifdef CONFIG_MLX5_EN_TLS
drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c +44 -43
206 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +2 -2
@@ -495,14 +495,14 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv, arfs_enabled = opened && (priv->netdev->features &NETIF_F_NTUPLE );if (arfs_enabled) -mlx5e_arfs_disable (priv); +mlx5e_arfs_disable (priv->fs);/* Switch to new channels, set new parameters and close old ones */ err =mlx5e_safe_switch_params (priv, &new_params, mlx5e_num_channels_changed_ctx,NULL , true);if (arfs_enabled) { -int err2 =mlx5e_arfs_enable (priv); +int err2 =mlx5e_arfs_enable (priv->fs);if (err2) netdev_err(priv->netdev, "%s: mlx5e_arfs_enable failed: %d\n",
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +6 -3
@@ -1303,7 +1303,8 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv)return -EOPNOTSUPP ;mlx5e_fs_set_ns (priv->fs, ns, false); - err =mlx5e_arfs_create_tables (priv); + err =mlx5e_arfs_create_tables (priv->fs, priv->rx_res, + !!(priv->netdev->hw_features &NETIF_F_NTUPLE ));if (err) {fs_err (fs,"Failed to create arfs tables, err=%d\n" , err); priv->netdev->hw_features &= ~NETIF_F_NTUPLE ;
@@ -1350,7 +1351,8 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv) err_destroy_inner_ttc_table:mlx5e_destroy_inner_ttc_table (priv); err_destroy_arfs_tables: -mlx5e_arfs_destroy_tables (priv); +mlx5e_arfs_destroy_tables (priv->fs, + !!(priv->netdev->hw_features &NETIF_F_NTUPLE ));return err; }
@@ -1362,7 +1364,8 @@ void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv)mlx5e_destroy_l2_table (priv);mlx5e_destroy_ttc_table (priv);mlx5e_destroy_inner_ttc_table (priv); -mlx5e_arfs_destroy_tables (priv); +mlx5e_arfs_destroy_tables (priv->fs, + !!(priv->netdev->hw_features &NETIF_F_NTUPLE ));mlx5e_ethtool_cleanup_steering (priv->fs); }
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +2 -2
@@ -3824,9 +3824,9 @@ static int set_feature_arfs(struct net_device *netdev, bool enable)int err;if (enable) - err =mlx5e_arfs_enable (priv); + err =mlx5e_arfs_enable (priv->fs);else - err =mlx5e_arfs_disable (priv); + err =mlx5e_arfs_disable (priv->fs);return err; }
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +6 -4
@@ -330,8 +330,8 @@ static int mlx5i_create_flow_steering(struct mlx5e_priv *priv)return -EINVAL ;mlx5e_fs_set_ns (priv->fs, ns, false); - - err =mlx5e_arfs_create_tables (priv); + err =mlx5e_arfs_create_tables (priv->fs, priv->rx_res, + !!(priv->netdev->hw_features &NETIF_F_NTUPLE ));if (err) {netdev_err (priv->netdev,"Failed to create arfs tables, err=%d\n" , err);
@@ -350,7 +350,8 @@ static int mlx5i_create_flow_steering(struct mlx5e_priv *priv)return 0 ; err_destroy_arfs_tables: -mlx5e_arfs_destroy_tables (priv); +mlx5e_arfs_destroy_tables (priv->fs, + !!(priv->netdev->hw_features &NETIF_F_NTUPLE ));return err; }
@@ -358,7 +359,8 @@ static int mlx5i_create_flow_steering(struct mlx5e_priv *priv)static void mlx5i_destroy_flow_steering (struct mlx5e_priv *priv) {mlx5e_destroy_ttc_table (priv); -mlx5e_arfs_destroy_tables (priv); +mlx5e_arfs_destroy_tables (priv->fs, + !!(priv->netdev->hw_features &NETIF_F_NTUPLE ));mlx5e_ethtool_cleanup_steering (priv->fs); }
Signature · 1 line
2.37.1
PATCH 10/15 net/mlx5e: Make all ttc functions of en_fs get fs struct as argument
In reply to Saeed MahameedFrom: Lama Kayal <[email protected]>
Let all ttc creation be independent of priv, and pass relevant members of priv only.
--- .../net/ethernet/mellanox/mlx5/core/en/fs.h | 8 ++- .../net/ethernet/mellanox/mlx5/core/en_fs.c | 65 ++++++++++--------- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 2 +- .../ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 4 +- 4 files changed, 43 insertions(+), 36 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/fs.h +5 -3
@@ -123,11 +123,13 @@ struct mlx5e_fs_udp;struct mlx5e_fs_any ;struct mlx5e_ptp_fs ; -void mlx5e_set_ttc_params (struct mlx5e_priv *priv, +void mlx5e_set_ttc_params (struct mlx5e_flow_steering *fs, +struct mlx5e_rx_res *rx_res,struct ttc_params *ttc_params,bool tunnel); -void mlx5e_destroy_ttc_table (struct mlx5e_priv *priv); -int mlx5e_create_ttc_table (struct mlx5e_priv *priv); +void mlx5e_destroy_ttc_table (struct mlx5e_flow_steering *fs); +int mlx5e_create_ttc_table (struct mlx5e_flow_steering *fs, +struct mlx5e_rx_res *rx_res);void mlx5e_destroy_flow_table (struct mlx5e_flow_table *ft);
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +35 -30
163 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +1 -1
@@ -751,7 +751,7 @@ static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv) MLX5_FLOW_NAMESPACE_KERNEL), false);/* The inner_ttc in the ttc params is intentionally not set */ -mlx5e_set_ttc_params (priv, &ttc_params, false); +mlx5e_set_ttc_params (priv->fs, priv->rx_res, &ttc_params, false);if (rep->vport !=MLX5_VPORT_UPLINK )/* To give uplik rep TTC a lower level for chaining from root ft */
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +2 -2
@@ -338,7 +338,7 @@ static int mlx5i_create_flow_steering(struct mlx5e_priv *priv) priv->netdev->hw_features &= ~NETIF_F_NTUPLE ; } - err =mlx5e_create_ttc_table (priv); + err =mlx5e_create_ttc_table (priv->fs, priv->rx_res);if (err) {netdev_err (priv->netdev,"Failed to create ttc table, err=%d\n" , err);
@@ -358,7 +358,7 @@ static int mlx5i_create_flow_steering(struct mlx5e_priv *priv)static void mlx5i_destroy_flow_steering (struct mlx5e_priv *priv) { -mlx5e_destroy_ttc_table (priv); +mlx5e_destroy_ttc_table (priv->fs);mlx5e_arfs_destroy_tables (priv->fs, !!(priv->netdev->hw_features &NETIF_F_NTUPLE ));mlx5e_ethtool_cleanup_steering (priv->fs);
Signature · 1 line
2.37.1
PATCH 11/15 net/mlx5e: Completely eliminate priv from fs.h
In reply to Saeed MahameedFrom: Lama Kayal <[email protected]>
Complete the decoupling process of flow steering from en.h.
--- .../net/ethernet/mellanox/mlx5/core/en/fs.h | 21 +-- .../net/ethernet/mellanox/mlx5/core/en/trap.c | 8 +- .../net/ethernet/mellanox/mlx5/core/en_fs.c | 150 +++++++++--------- .../net/ethernet/mellanox/mlx5/core/en_main.c | 15 +- 4 files changed, 100 insertions(+), 94 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/fs.h +12 -9
@@ -91,7 +91,6 @@ enum {struct mlx5e_flow_steering ;struct mlx5e_rx_res ; -struct mlx5e_priv ;#ifdef CONFIG_MLX5_EN_ARFS struct mlx5e_arfs_tables ;
@@ -133,11 +132,15 @@ int mlx5e_create_ttc_table(struct mlx5e_flow_steering *fs,void mlx5e_destroy_flow_table (struct mlx5e_flow_table *ft); -void mlx5e_enable_cvlan_filter (struct mlx5e_priv *priv); -void mlx5e_disable_cvlan_filter (struct mlx5e_priv *priv); +void mlx5e_enable_cvlan_filter (struct mlx5e_flow_steering *fs,bool promisc); +void mlx5e_disable_cvlan_filter (struct mlx5e_flow_steering *fs,bool promisc); -int mlx5e_create_flow_steering (struct mlx5e_priv *priv); -void mlx5e_destroy_flow_steering (struct mlx5e_priv *priv); +int mlx5e_create_flow_steering (struct mlx5e_flow_steering *fs, +struct mlx5e_rx_res *rx_res, +const struct mlx5e_profile *profile, +struct net_device *netdev); +void mlx5e_destroy_flow_steering (struct mlx5e_flow_steering *fs,bool ntuple, +const struct mlx5e_profile *profile); struct mlx5e_flow_steering *mlx5e_fs_init(const struct mlx5e_profile *profile, struct mlx5_core_dev *mdev,
@@ -172,10 +175,10 @@ void mlx5e_fs_set_state_destroy(struct mlx5e_flow_steering *fs, bool state_destrvoid mlx5e_fs_set_vlan_strip_disable (struct mlx5e_flow_steering *fs,bool vlan_strip_disable);struct mlx5_core_dev *mlx5e_fs_get_mdev (struct mlx5e_flow_steering *fs); -int mlx5e_add_vlan_trap (struct mlx5e_priv *priv,int trap_id,int tir_num); -void mlx5e_remove_vlan_trap (struct mlx5e_priv *priv); -int mlx5e_add_mac_trap (struct mlx5e_priv *priv,int trap_id,int tir_num); -void mlx5e_remove_mac_trap (struct mlx5e_priv *priv); +int mlx5e_add_vlan_trap (struct mlx5e_flow_steering *fs,int trap_id,int tir_num); +void mlx5e_remove_vlan_trap (struct mlx5e_flow_steering *fs); +int mlx5e_add_mac_trap (struct mlx5e_flow_steering *fs,int trap_id,int tir_num); +void mlx5e_remove_mac_trap (struct mlx5e_flow_steering *fs);void mlx5e_fs_set_rx_mode_work (struct mlx5e_flow_steering *fs,struct net_device *netdev); int mlx5e_fs_vlan_rx_add_vid(struct mlx5e_flow_steering *fs, struct net_device *netdev,
drivers/net/ethernet/mellanox/mlx5/core/en/trap.c +4 -4
@@ -230,12 +230,12 @@ static int mlx5e_handle_action_trap(struct mlx5e_priv *priv, int trap_id)switch (trap_id) {case DEVLINK_TRAP_GENERIC_ID_INGRESS_VLAN_FILTER : - err =mlx5e_add_vlan_trap (priv, trap_id,mlx5e_trap_get_tirn (priv->en_trap)); + err =mlx5e_add_vlan_trap (priv->fs, trap_id,mlx5e_trap_get_tirn (priv->en_trap));if (err) goto err_out;break ;case DEVLINK_TRAP_GENERIC_ID_DMAC_FILTER : - err =mlx5e_add_mac_trap (priv, trap_id,mlx5e_trap_get_tirn (priv->en_trap)); + err =mlx5e_add_mac_trap (priv->fs, trap_id,mlx5e_trap_get_tirn (priv->en_trap));if (err) goto err_out;break ;
@@ -256,10 +256,10 @@ static int mlx5e_handle_action_drop(struct mlx5e_priv *priv, int trap_id) {switch (trap_id) {case DEVLINK_TRAP_GENERIC_ID_INGRESS_VLAN_FILTER : -mlx5e_remove_vlan_trap (priv); +mlx5e_remove_vlan_trap (priv->fs);break ;case DEVLINK_TRAP_GENERIC_ID_DMAC_FILTER : -mlx5e_remove_mac_trap (priv); +mlx5e_remove_mac_trap (priv->fs);break ;default :netdev_warn (priv->netdev,"%s: Unknown trap id %d\n" , __func__, trap_id);
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +74 -76
299 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +10 -5
@@ -3669,9 +3669,11 @@ static int set_feature_cvlan_filter(struct net_device *netdev, bool enable)struct mlx5e_priv *priv =netdev_priv (netdev);if (enable) -mlx5e_enable_cvlan_filter (priv); +mlx5e_enable_cvlan_filter (priv->fs, + !!(priv->netdev->flags &IFF_PROMISC ));else -mlx5e_disable_cvlan_filter (priv); +mlx5e_disable_cvlan_filter (priv->fs, + !!(priv->netdev->flags &IFF_PROMISC ));return 0 ; }
@@ -5105,7 +5107,8 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)if (err) goto err_close_drop_rq; - err =mlx5e_create_flow_steering (priv); + err =mlx5e_create_flow_steering (priv->fs, priv->rx_res, priv->profile, + priv->netdev);if (err) {mlx5_core_warn (mdev,"create flow steering failed, %d\n" , err); goto err_destroy_rx_res;
@@ -5128,7 +5131,8 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv) err_tc_nic_cleanup:mlx5e_tc_nic_cleanup (priv); err_destroy_flow_steering: -mlx5e_destroy_flow_steering (priv); +mlx5e_destroy_flow_steering (priv->fs, !!(priv->netdev->hw_features &NETIF_F_NTUPLE ), + priv->profile); err_destroy_rx_res:mlx5e_rx_res_destroy (priv->rx_res); err_close_drop_rq:
@@ -5144,7 +5148,8 @@ static void mlx5e_cleanup_nic_rx(struct mlx5e_priv *priv) {mlx5e_accel_cleanup_rx (priv);mlx5e_tc_nic_cleanup (priv); -mlx5e_destroy_flow_steering (priv); +mlx5e_destroy_flow_steering (priv->fs, !!(priv->netdev->hw_features &NETIF_F_NTUPLE ), + priv->profile);mlx5e_rx_res_destroy (priv->rx_res);mlx5e_close_drop_rq (&priv->drop_rq);mlx5e_destroy_q_counters (priv);
Signature · 1 line
2.37.1
PATCH 12/15 net/mlx5: E-Switch, Add default drop rule for unmatched packets
In reply to Saeed MahameedFrom: Jianbo Liu <[email protected]>
The ft_offloads table serves to steer packets, which are from the eswitch, to the representor associated with the packets' source vport.
Previously, if a packet's source vport or metadata was not associated with any representor, it was forwarded to the uplink representor. The representor got packets it shouldn't have as they weren't coming from the uplink vport.
One such effect of this breakage can be observed if the uplink representor is attached to a bridge, where such illegal packets will be broadcast to the remaining ports, flooding the switch with illegal packets. In the case where IB loopback (e.g, SNAP) is enabled, all transmitted packets would be looped back, and received by the uplink representor, and result in an infinite feedback loop.
Therefore, block this hole by adding a default drop rule to the ft_offloads table, so that all unmatched packets with no associated representor are dropped.
--- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 2 + .../mellanox/mlx5/core/eswitch_offloads.c | 95 ++++++++++++++++++- 2 files changed, 94 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +2 -0
@@ -244,6 +244,8 @@ struct mlx5_esw_offload {struct mlx5_flow_table *ft_offloads;struct mlx5_flow_group *vport_rx_group; +struct mlx5_flow_group *vport_rx_drop_group; +struct mlx5_flow_handle *vport_rx_drop_rule;struct xarray vport_reps;struct list_head peer_flows;struct mutex peer_mutex;
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +92 -3
145 lines not on this page · raw message
Signature · 1 line
2.37.1
PATCH 13/15 net/mlx5: E-Switch, Split creating fdb tables into smaller chunks
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Split esw_create_offloads_fdb_tables() into smaller functions. This will help maintenance.
--- .../mellanox/mlx5/core/eswitch_offloads.c | 330 +++++++++++------- 1 file changed, 206 insertions(+), 124 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +206 -124
@@ -1669,18 +1669,209 @@ esw_chains_destroy(struct mlx5_eswitch *esw, struct mlx5_fs_chains *chains)#endif +static int +esw_create_send_to_vport_group (struct mlx5_eswitch *esw, +struct mlx5_flow_table *fdb, +u32 *flow_group_in, +int *ix) +{ +int inlen =MLX5_ST_SZ_BYTES (create_flow_group_in); +struct mlx5_flow_group *g; +void *match_criteria; +int count, err =0 ; + +memset (flow_group_in,0 , inlen); + +MLX5_SET (create_flow_group_in, flow_group_in, match_criteria_enable, +MLX5_MATCH_MISC_PARAMETERS ); + + match_criteria =MLX5_ADDR_OF (create_flow_group_in, flow_group_in, match_criteria); + +MLX5_SET_TO_ONES (fte_match_param, match_criteria, misc_parameters.source_sqn); +MLX5_SET_TO_ONES (fte_match_param, match_criteria, misc_parameters.source_port); +if (MLX5_CAP_ESW (esw->dev, merged_eswitch)) { +MLX5_SET_TO_ONES (fte_match_param, match_criteria, + misc_parameters.source_eswitch_owner_vhca_id); +MLX5_SET (create_flow_group_in, flow_group_in, + source_eswitch_owner_vhca_id_valid,1 ); + } + +/* See comment at table_size calculation */ + count =MLX5_MAX_PORTS * (esw->total_vports *MAX_SQ_NVPORTS +MAX_PF_SQ ); +MLX5_SET (create_flow_group_in, flow_group_in, start_flow_index,0 ); +MLX5_SET (create_flow_group_in, flow_group_in, end_flow_index, *ix + count -1 ); + *ix += count; + + g =mlx5_create_flow_group (fdb, flow_group_in); +if (IS_ERR (g)) { + err =PTR_ERR (g); +esw_warn (esw->dev,"Failed to create send-to-vport flow group err(%d)\n" , err); + goto out; + } + esw->fdb_table.offloads.send_to_vport_grp = g; + +out: +return err; +} + +static int +esw_create_meta_send_to_vport_group (struct mlx5_eswitch *esw, +struct mlx5_flow_table *fdb, +u32 *flow_group_in, +int *ix) +{ +int inlen =MLX5_ST_SZ_BYTES (create_flow_group_in); +int num_vfs = esw->esw_funcs.num_vfs; +struct mlx5_flow_group *g; +void *match_criteria; +int err =0 ; + +if (!esw_src_port_rewrite_supported (esw)) +return 0 ; + +memset (flow_group_in,0 , inlen); + +MLX5_SET (create_flow_group_in, flow_group_in, match_criteria_enable, +MLX5_MATCH_MISC_PARAMETERS_2 ); + + match_criteria =MLX5_ADDR_OF (create_flow_group_in, flow_group_in, match_criteria); + +MLX5_SET (fte_match_param, match_criteria, + misc_parameters_2.metadata_reg_c_0, +mlx5_eswitch_get_vport_metadata_mask ()); +MLX5_SET (fte_match_param, match_criteria, + misc_parameters_2.metadata_reg_c_1,ESW_TUN_MASK ); + +if (num_vfs) { +MLX5_SET (create_flow_group_in, flow_group_in, start_flow_index, *ix); +MLX5_SET (create_flow_group_in, flow_group_in, + end_flow_index, *ix + num_vfs -1 ); + *ix += num_vfs; + + g =mlx5_create_flow_group (fdb, flow_group_in); +if (IS_ERR (g)) { + err =PTR_ERR (g); +esw_warn (esw->dev, +"Failed to create send-to-vport meta flow group err(%d)\n" , err); + goto send_vport_meta_err; + } + esw->fdb_table.offloads.send_to_vport_meta_grp = g; + + err =mlx5_eswitch_add_send_to_vport_meta_rules (esw); +if (err) + goto meta_rule_err; + } + +return 0 ; + +meta_rule_err: +mlx5_destroy_flow_group (esw->fdb_table.offloads.send_to_vport_meta_grp); +send_vport_meta_err: +return err; +} + +static int +esw_create_peer_esw_miss_group (struct mlx5_eswitch *esw, +struct mlx5_flow_table *fdb, +u32 *flow_group_in, +int *ix) +{ +int inlen =MLX5_ST_SZ_BYTES (create_flow_group_in); +struct mlx5_flow_group *g; +void *match_criteria; +int err =0 ; + +if (!MLX5_CAP_ESW (esw->dev, merged_eswitch)) +return 0 ; + +memset (flow_group_in,0 , inlen); + +esw_set_flow_group_source_port (esw, flow_group_in); + +if (!mlx5_eswitch_vport_match_metadata_enabled (esw)) { + match_criteria =MLX5_ADDR_OF (create_flow_group_in, + flow_group_in, + match_criteria); + +MLX5_SET_TO_ONES (fte_match_param, match_criteria, + misc_parameters.source_eswitch_owner_vhca_id); + +MLX5_SET (create_flow_group_in, flow_group_in, + source_eswitch_owner_vhca_id_valid,1 ); + } + +MLX5_SET (create_flow_group_in, flow_group_in, start_flow_index, *ix); +MLX5_SET (create_flow_group_in, flow_group_in, end_flow_index, + *ix + esw->total_vports -1 ); + *ix += esw->total_vports; + + g =mlx5_create_flow_group (fdb, flow_group_in); +if (IS_ERR (g)) { + err =PTR_ERR (g); +esw_warn (esw->dev,"Failed to create peer miss flow group err(%d)\n" , err); + goto out; + } + esw->fdb_table.offloads.peer_miss_grp = g; + +out: +return err; +} + +static int +esw_create_miss_group (struct mlx5_eswitch *esw, +struct mlx5_flow_table *fdb, +u32 *flow_group_in, +int *ix) +{ +int inlen =MLX5_ST_SZ_BYTES (create_flow_group_in); +struct mlx5_flow_group *g; +void *match_criteria; +int err =0 ; +u8 *dmac; + +memset (flow_group_in,0 , inlen); + +MLX5_SET (create_flow_group_in, flow_group_in, match_criteria_enable, +MLX5_MATCH_OUTER_HEADERS ); + match_criteria =MLX5_ADDR_OF (create_flow_group_in, flow_group_in, + match_criteria); + dmac =MLX5_ADDR_OF (fte_match_param, match_criteria, + outer_headers.dmac_47_16); + dmac[0 ] =0x01 ; + +MLX5_SET (create_flow_group_in, flow_group_in, start_flow_index, *ix); +MLX5_SET (create_flow_group_in, flow_group_in, end_flow_index, + *ix +MLX5_ESW_MISS_FLOWS ); + + g =mlx5_create_flow_group (fdb, flow_group_in); +if (IS_ERR (g)) { + err =PTR_ERR (g); +esw_warn (esw->dev,"Failed to create miss flow group err(%d)\n" , err); + goto miss_err; + } + esw->fdb_table.offloads.miss_grp = g; + + err =esw_add_fdb_miss_rule (esw); +if (err) + goto miss_rule_err; + +return 0 ; + +miss_rule_err: +mlx5_destroy_flow_group (esw->fdb_table.offloads.miss_grp); +miss_err: +return err; +} +static int esw_create_offloads_fdb_tables (struct mlx5_eswitch *esw) {int inlen =MLX5_ST_SZ_BYTES (create_flow_group_in);struct mlx5_flow_table_attr ft_attr = {}; -int num_vfs, table_size, ix, err =0 ;struct mlx5_core_dev *dev = esw->dev;struct mlx5_flow_namespace *root_ns;struct mlx5_flow_table *fdb =NULL ; +int table_size, ix =0 , err =0 ;u32 flags =0 , *flow_group_in; -struct mlx5_flow_group *g; -void *match_criteria; -u8 *dmac;esw_debug (esw->dev,"Create offloads FDB Tables\n" );
@@ -1714,7 +1905,7 @@ static int esw_create_offloads_fdb_tables(struct mlx5_eswitch *esw)* total vports of the peer (currently is also uses esw->total_vports). */ table_size =MLX5_MAX_PORTS * (esw->total_vports *MAX_SQ_NVPORTS +MAX_PF_SQ ) + -MLX5_ESW_MISS_FLOWS + esw->total_vports + esw->esw_funcs.num_vfs; +MLX5_ESW_MISS_FLOWS + esw->total_vports + esw->esw_funcs.num_vfs;/* create the slow path fdb with encap set, so further table instances * can be created at run time while VFs are probed if the FW allows that.
@@ -1755,139 +1946,30 @@ static int esw_create_offloads_fdb_tables(struct mlx5_eswitch *esw) goto fdb_chains_err; } -/* create send-to-vport group */ -MLX5_SET (create_flow_group_in, flow_group_in, match_criteria_enable, -MLX5_MATCH_MISC_PARAMETERS ); - - match_criteria =MLX5_ADDR_OF (create_flow_group_in, flow_group_in, match_criteria); - -MLX5_SET_TO_ONES (fte_match_param, match_criteria, misc_parameters.source_sqn); -MLX5_SET_TO_ONES (fte_match_param, match_criteria, misc_parameters.source_port); -if (MLX5_CAP_ESW (esw->dev, merged_eswitch)) { -MLX5_SET_TO_ONES (fte_match_param, match_criteria, - misc_parameters.source_eswitch_owner_vhca_id); -MLX5_SET (create_flow_group_in, flow_group_in, - source_eswitch_owner_vhca_id_valid,1 ); - } - -/* See comment above table_size calculation */ - ix =MLX5_MAX_PORTS * (esw->total_vports *MAX_SQ_NVPORTS +MAX_PF_SQ ); -MLX5_SET (create_flow_group_in, flow_group_in, start_flow_index,0 ); -MLX5_SET (create_flow_group_in, flow_group_in, end_flow_index, ix -1 ); - - g =mlx5_create_flow_group (fdb, flow_group_in); -if (IS_ERR (g)) { - err =PTR_ERR (g); -esw_warn (dev,"Failed to create send-to-vport flow group err(%d)\n" , err); + err =esw_create_send_to_vport_group (esw, fdb, flow_group_in, &ix); +if (err) goto send_vport_err; - } - esw->fdb_table.offloads.send_to_vport_grp = g; - -if (esw_src_port_rewrite_supported (esw)) { -/* meta send to vport */ -memset (flow_group_in,0 , inlen); -MLX5_SET (create_flow_group_in, flow_group_in, match_criteria_enable, -MLX5_MATCH_MISC_PARAMETERS_2 ); - - match_criteria =MLX5_ADDR_OF (create_flow_group_in, flow_group_in, match_criteria); - -MLX5_SET (fte_match_param, match_criteria, - misc_parameters_2.metadata_reg_c_0, -mlx5_eswitch_get_vport_metadata_mask ()); -MLX5_SET (fte_match_param, match_criteria, - misc_parameters_2.metadata_reg_c_1,ESW_TUN_MASK ); - - num_vfs = esw->esw_funcs.num_vfs; -if (num_vfs) { -MLX5_SET (create_flow_group_in, flow_group_in, start_flow_index, ix); -MLX5_SET (create_flow_group_in, flow_group_in, - end_flow_index, ix + num_vfs -1 ); - ix += num_vfs; - - g =mlx5_create_flow_group (fdb, flow_group_in); -if (IS_ERR (g)) { - err =PTR_ERR (g); -esw_warn (dev,"Failed to create send-to-vport meta flow group err(%d)\n" , - err); - goto send_vport_meta_err; - } - esw->fdb_table.offloads.send_to_vport_meta_grp = g; - - err =mlx5_eswitch_add_send_to_vport_meta_rules (esw); -if (err) - goto meta_rule_err; - } - } - -if (MLX5_CAP_ESW (esw->dev, merged_eswitch)) { -/* create peer esw miss group */ -memset (flow_group_in,0 , inlen); - -esw_set_flow_group_source_port (esw, flow_group_in); - -if (!mlx5_eswitch_vport_match_metadata_enabled (esw)) { - match_criteria =MLX5_ADDR_OF (create_flow_group_in, - flow_group_in, - match_criteria); - -MLX5_SET_TO_ONES (fte_match_param, match_criteria, - misc_parameters.source_eswitch_owner_vhca_id); - -MLX5_SET (create_flow_group_in, flow_group_in, - source_eswitch_owner_vhca_id_valid,1 ); - } - -MLX5_SET (create_flow_group_in, flow_group_in, start_flow_index, ix); -MLX5_SET (create_flow_group_in, flow_group_in, end_flow_index, - ix + esw->total_vports -1 ); - ix += esw->total_vports; - - g =mlx5_create_flow_group (fdb, flow_group_in); -if (IS_ERR (g)) { - err =PTR_ERR (g); -esw_warn (dev,"Failed to create peer miss flow group err(%d)\n" , err); - goto peer_miss_err; - } - esw->fdb_table.offloads.peer_miss_grp = g; - } - -/* create miss group */ -memset (flow_group_in,0 , inlen); -MLX5_SET (create_flow_group_in, flow_group_in, match_criteria_enable, -MLX5_MATCH_OUTER_HEADERS ); - match_criteria =MLX5_ADDR_OF (create_flow_group_in, flow_group_in, - match_criteria); - dmac =MLX5_ADDR_OF (fte_match_param, match_criteria, - outer_headers.dmac_47_16); - dmac[0 ] =0x01 ; -MLX5_SET (create_flow_group_in, flow_group_in, start_flow_index, ix); -MLX5_SET (create_flow_group_in, flow_group_in, end_flow_index, - ix +MLX5_ESW_MISS_FLOWS ); + err =esw_create_meta_send_to_vport_group (esw, fdb, flow_group_in, &ix); +if (err) + goto send_vport_meta_err; - g =mlx5_create_flow_group (fdb, flow_group_in); -if (IS_ERR (g)) { - err =PTR_ERR (g); -esw_warn (dev,"Failed to create miss flow group err(%d)\n" , err); - goto miss_err; - } - esw->fdb_table.offloads.miss_grp = g; + err =esw_create_peer_esw_miss_group (esw, fdb, flow_group_in, &ix); +if (err) + goto peer_miss_err; - err =esw_add_fdb_miss_rule (esw); + err =esw_create_miss_group (esw, fdb, flow_group_in, &ix);if (err) - goto miss_rule_err; + goto miss_err;kvfree (flow_group_in);return 0 ; -miss_rule_err: -mlx5_destroy_flow_group (esw->fdb_table.offloads.miss_grp); miss_err:if (MLX5_CAP_ESW (esw->dev, merged_eswitch))mlx5_destroy_flow_group (esw->fdb_table.offloads.peer_miss_grp); peer_miss_err:mlx5_eswitch_del_send_to_vport_meta_rules (esw); -meta_rule_err:if (esw->fdb_table.offloads.send_to_vport_meta_grp)mlx5_destroy_flow_group (esw->fdb_table.offloads.send_to_vport_meta_grp); send_vport_meta_err:
Signature · 1 line
2.37.1
PATCH 14/15 net/mlx5: E-Switch, Move send to vport meta rule creation
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Move the creation of the rules from offloads fdb table init to per rep vport init.
This way the driver will creating the send to vport meta rule on any representor, e.g. SF representors.
--- .../net/ethernet/mellanox/mlx5/core/en_main.c | 4 +- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 53 ++++++++- .../net/ethernet/mellanox/mlx5/core/en_rep.h | 9 +- .../net/ethernet/mellanox/mlx5/core/eswitch.c | 1 - .../net/ethernet/mellanox/mlx5/core/eswitch.h | 5 +- .../mellanox/mlx5/core/eswitch_offloads.c | 112 +++++------------- 6 files changed, 90 insertions(+), 94 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +2 -2
@@ -2738,7 +2738,7 @@ void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)netif_tx_start_all_queues (priv->netdev);if (mlx5e_is_vport_rep (priv)) -mlx5e_add_sqs_fwd_rules (priv); +mlx5e_rep_activate_channels (priv);mlx5e_wait_channels_min_rx_wqes (&priv->channels);
@@ -2752,7 +2752,7 @@ void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv)mlx5e_rx_res_channels_deactivate (priv->rx_res);if (mlx5e_is_vport_rep (priv)) -mlx5e_remove_sqs_fwd_rules (priv); +mlx5e_rep_deactivate_channels (priv);/* The results of ndo_select_queue are unreliable, while netdev config * is being changed (real_num_tx_queues, num_tc). Stop all queues to
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +51 -2
71 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_rep.h +5 -4
@@ -111,6 +111,7 @@ struct mlx5e_rep_priv {struct list_head vport_sqs_list;struct mlx5_rep_uplink_priv uplink_priv;/* valid for uplink rep */ struct rtnl_link_stats64 prev_vf_vport_stats; +struct mlx5_flow_handle *send_to_vport_meta_rule;struct rhashtable tc_ht; };
@@ -241,8 +242,8 @@ int mlx5e_rep_get_offload_stats(int attr_id, const struct net_device *dev, void *sp);bool mlx5e_is_uplink_rep (struct mlx5e_priv *priv); -int mlx5e_add_sqs_fwd_rules (struct mlx5e_priv *priv); -void mlx5e_remove_sqs_fwd_rules (struct mlx5e_priv *priv); +void mlx5e_rep_activate_channels (struct mlx5e_priv *priv); +void mlx5e_rep_deactivate_channels (struct mlx5e_priv *priv);void mlx5e_rep_queue_neigh_stats_work (struct mlx5e_priv *priv);
@@ -256,8 +257,8 @@ static inline bool mlx5e_eswitch_rep(const struct net_device *netdev)#else /* CONFIG_MLX5_ESWITCH */ static inline bool mlx5e_is_uplink_rep (struct mlx5e_priv *priv) {return false; } -static inline int mlx5e_add_sqs_fwd_rules (struct mlx5e_priv *priv) {return 0 ; } -static inline void mlx5e_remove_sqs_fwd_rules (struct mlx5e_priv *priv) {} +static inline void mlx5e_rep_activate_channels (struct mlx5e_priv *priv) {} +static inline void mlx5e_rep_deactivate_channels (struct mlx5e_priv *priv) {}static inline int mlx5e_rep_init (void ) {return 0 ; };static inline void mlx5e_rep_cleanup (void ) {}; static inline bool mlx5e_rep_has_offload_stats(const struct net_device *dev,
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +0 -1
@@ -1360,7 +1360,6 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw, bool clear_vf)if (esw->mode ==MLX5_ESWITCH_OFFLOADS ) {struct devlink *devlink =priv_to_devlink (esw->dev); -esw_offloads_del_send_to_vport_meta_rules (esw);devl_rate_nodes_destroy (devlink); }
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +4 -1
@@ -346,7 +346,10 @@ void esw_offloads_disable(struct mlx5_eswitch *esw);int esw_offloads_enable (struct mlx5_eswitch *esw);void esw_offloads_cleanup_reps (struct mlx5_eswitch *esw);int esw_offloads_init_reps (struct mlx5_eswitch *esw); -void esw_offloads_del_send_to_vport_meta_rules (struct mlx5_eswitch *esw); + +struct mlx5_flow_handle * +mlx5_eswitch_add_send_to_vport_meta_rule (struct mlx5_eswitch *esw,u16 vport_num); +void mlx5_eswitch_del_send_to_vport_meta_rule (struct mlx5_flow_handle *rule);bool mlx5_esw_vport_match_metadata_supported (const struct mlx5_eswitch *esw);int mlx5_esw_offloads_vport_metadata_set (struct mlx5_eswitch *esw,bool enable);
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +28 -84
172 lines not on this page · raw message
Signature · 1 line
2.37.1
Re: [net-next 14/15] net/mlx5: E-Switch, Move send to vport meta rule creation
From: Saeed Mahameed <[email protected]>
Date: Mon, 22 Aug 2022 22:55:32 -0700
Quoted 19 lines
From: Roi Dayan <[email protected]>
Move the creation of the rules from offloads fdb table init to per rep vport init.
This way the driver will creating the send to vport meta rule on any representor, e.g. SF representors.Signed-off-by Roi Dayan <[email protected]>Reviewed-by Mark Bloch <[email protected]>Reviewed-by Maor Dickman <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>--- .../net/ethernet/mellanox/mlx5/core/en_main.c | 4 +- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 53 ++++++++- .../net/ethernet/mellanox/mlx5/core/en_rep.h | 9 +- .../net/ethernet/mellanox/mlx5/core/eswitch.c | 1 - .../net/ethernet/mellanox/mlx5/core/eswitch.h | 5 +- .../mellanox/mlx5/core/eswitch_offloads.c | 112 +++++------------- 6 files changed, 90 insertions(+), 94 deletions(-)
[...]
Quoted 15 lines
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +15
-0+static int +mlx5e_rep_add_meta_tunnel_rule (struct mlx5e_priv *priv) +{ +struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; +struct mlx5e_rep_priv *rpriv = priv->ppriv; +struct mlx5_eswitch_rep *rep = rpriv->rep; +struct mlx5_flow_handle *flow_rule; +struct mlx5_flow_group *g; +int err; + + g = esw->fdb_table.offloads.send_to_vport_meta_grp; +if (!g) +return 0 ; + + flow_rule =mlx5_eswitch_add_send_to_vport_meta_rule (esw, rep->vport);
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv) · line 490
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +10
-0+if (IS_ERR (flow_rule)) { + err =PTR_ERR (flow_rule); + goto out; + } + + rpriv->send_to_vport_meta_rule = flow_rule; + +out: +return err; +}
On my system (LLVM, CONFIG_WERROR=y):
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:481:6: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
if (IS_ERR(flow_rule)) {
^~~~~~~~~~~~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:489:9: note: uninitialized use occurs here
return err;
^~~I believe you can just
if (IS_ERR(flow_rule)) return PTR_ERR(flow_rule); rpriv->send_to_vport_meta_rule = flow_rule; return 0; }
?
Quoted 9 lines
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +9
-0+ +static void +mlx5e_rep_del_meta_tunnel_rule (struct mlx5e_priv *priv) +{ +struct mlx5e_rep_priv *rpriv = priv->ppriv; + +if (rpriv->send_to_vport_meta_rule) +mlx5_eswitch_del_send_to_vport_meta_rule (rpriv->send_to_vport_meta_rule); +}
[...]
Quoted 2 lines
Signature · 1 line
2.37.1
Thanks,
Olek
Re: [net-next 14/15] net/mlx5: E-Switch, Move send to vport meta rule creation
Quoted 70 lines · Alexander Lobakin
From: Saeed Mahameed <[email protected]>
Date: Mon, 22 Aug 2022 22:55:32 -0700Quoted 19 lines
From: Roi Dayan <[email protected]>
Move the creation of the rules from offloads fdb table init to per rep vport init.
This way the driver will creating the send to vport meta rule on any representor, e.g. SF representors.Signed-off-by Roi Dayan <[email protected]>Reviewed-by Mark Bloch <[email protected]>Reviewed-by Maor Dickman <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>--- .../net/ethernet/mellanox/mlx5/core/en_main.c | 4 +- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 53 ++++++++- .../net/ethernet/mellanox/mlx5/core/en_rep.h | 9 +- .../net/ethernet/mellanox/mlx5/core/eswitch.c | 1 - .../net/ethernet/mellanox/mlx5/core/eswitch.h | 5 +- .../mellanox/mlx5/core/eswitch_offloads.c | 112 +++++------------- 6 files changed, 90 insertions(+), 94 deletions(-)[...]
Quoted 15 lines
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +15
-0+static int +mlx5e_rep_add_meta_tunnel_rule (struct mlx5e_priv *priv) +{ +struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; +struct mlx5e_rep_priv *rpriv = priv->ppriv; +struct mlx5_eswitch_rep *rep = rpriv->rep; +struct mlx5_flow_handle *flow_rule; +struct mlx5_flow_group *g; +int err; + + g = esw->fdb_table.offloads.send_to_vport_meta_grp; +if (!g) +return 0 ; + + flow_rule =mlx5_eswitch_add_send_to_vport_meta_rule (esw, rep->vport);drivers/net/ethernet/mellanox/mlx5/core/en_rep.c void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv) · line 490
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +10
-0+if (IS_ERR (flow_rule)) { + err =PTR_ERR (flow_rule); + goto out; + } + + rpriv->send_to_vport_meta_rule = flow_rule; + +out: +return err; +}On my system (LLVM,
CONFIG_WERROR=y):
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:481:6: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]if (IS_ERR(flow_rule)) { ^~~~~~~~~~~~~~~~~ drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:489:9: note: uninitialized use occurs here return err; ^~~I believe you can just
if (IS_ERR(flow_rule)) return PTR_ERR(flow_rule); rpriv->send_to_vport_meta_rule = flow_rule; return 0; }
Quoted 1 line
?
thanks. missed that. i see the series got merged so i'll send a fix.
Quoted 18 lines
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +9
-0+ +static void +mlx5e_rep_del_meta_tunnel_rule (struct mlx5e_priv *priv) +{ +struct mlx5e_rep_priv *rpriv = priv->ppriv; + +if (rpriv->send_to_vport_meta_rule) +mlx5_eswitch_del_send_to_vport_meta_rule (rpriv->send_to_vport_meta_rule); +}[...]
Quoted 2 lines
Signature · 1 line
2.37.1Thanks,
Olek
PATCH 15/15 net/mlx5: TC, Add support for SF tunnel offload
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
VF tunnel flow already exists and SF tunnel is the same flow. Support offloading of tunneling over SF device by allow to attach an encap route over SF and set to use indirect flow table on SF.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 7 +++++-- drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +5 -2
@@ -1505,8 +1505,11 @@ bool mlx5e_tc_is_vf_tunnel(struct net_device *out_dev, struct net_device *route_ route_priv =netdev_priv (route_dev); route_mdev = route_priv->mdev; -if (out_mdev->coredev_type !=MLX5_COREDEV_PF || - route_mdev->coredev_type !=MLX5_COREDEV_VF ) +if (out_mdev->coredev_type !=MLX5_COREDEV_PF ) +return false; + +if (route_mdev->coredev_type !=MLX5_COREDEV_VF && + route_mdev->coredev_type !=MLX5_COREDEV_SF )return false;return mlx5e_same_hw_devs (out_priv, route_priv);
drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c +5 -1
@@ -78,12 +78,16 @@ mlx5_esw_indir_table_needed(struct mlx5_eswitch *esw, struct mlx5_core_dev *dest_mdev) {struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr; +bool vf_sf_vport; + + vf_sf_vport =mlx5_eswitch_is_vf_vport (esw, vport_num) || +mlx5_esw_is_sf_vport (esw, vport_num);/* Use indirect table for all IP traffic from UL to VF with vport * destination when source rewrite flag is set. */ return esw_attr->in_rep->vport ==MLX5_VPORT_UPLINK && -mlx5_eswitch_is_vf_vport (esw, vport_num) && + vf_sf_vport && esw->dev == dest_mdev && attr->ip_version && attr->flags &MLX5_ATTR_FLAG_SRC_REWRITE ;
Signature · 1 line
2.37.1