mlx5 updates 2021-11-01
From: Saeed Mahameed <[email protected]>
Hi Dave, Jakub,
v1->v2:
- Fix build error
This small pull request includes few updates to mlx5 driver, Mainly:
1) Support ethtool cq mode
2) Static allocation of mod header object for the common case
Please pull and let me know if there is any problem.
Thanks,
Saeed.
The following changes since commit cc0356d6a02e064387c16a83cb96fe43ef33181e:
Merge tag 'x86_core_for_v5.16_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip (2021-11-02 07:56:47 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2021-11-01
for you to fetch changes up to 5eb1f9a57b31fd543e871ac1e743ed4a01d158ec:
net/mlx5e: TC, Remove redundant action stack var (2021-11-02 08:56:35 -0700)
----------------------------------------------------------------
mlx5-updates-2021-11-01
Small updates for mlx5 driver:
1) Support ethtool cq mode
2) Static allocation of mod header object for the common case
3) minor code improvements
----------------------------------------------------------------
Paul Blakey (2):
net/mlx5e: Refactor mod header management API net/mlx5: CT: Allow static allocation of mod headers
Roi Dayan (3):
net/mlx5e: TC, Destroy nic flow counter if exists net/mlx5e: TC, Move kfree() calls after destroying all resources net/mlx5e: TC, Remove redundant action stack var
Saeed Mahameed (2):
net/mlx5e: Support ethtool cq mode net/mlx5: Print more info on pci error handlers
drivers/net/ethernet/mellanox/mlx5/core/en.h | 7 +- .../net/ethernet/mellanox/mlx5/core/en/mod_hdr.c | 58 +++++++ .../net/ethernet/mellanox/mlx5/core/en/mod_hdr.h | 26 +++ .../net/ethernet/mellanox/mlx5/core/en/tc/sample.c | 5 +- drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 34 ++-- .../ethernet/mellanox/mlx5/core/en/tc_tun_encap.c | 2 +- .../net/ethernet/mellanox/mlx5/core/en_ethtool.c | 49 +++++- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 4 +- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 191 +++++++-------------- drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 6 - .../ethernet/mellanox/mlx5/core/esw/indir_table.c | 5 +- .../ethernet/mellanox/mlx5/core/ipoib/ethtool.c | 4 +- drivers/net/ethernet/mellanox/mlx5/core/main.c | 51 ++++-- 13 files changed, 259 insertions(+), 183 deletions(-)
PATCH v2 1/7 net/mlx5e: Support ethtool cq mode
From: Saeed Mahameed <[email protected]>
Add support for ethtool coalesce cq mode set and get.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 7 ++- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 49 ++++++++++++++++--- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 4 +- .../mellanox/mlx5/core/ipoib/ethtool.c | 4 +- 4 files changed, 52 insertions(+), 12 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +5 -2
@@ -1148,9 +1148,12 @@ void mlx5e_ethtool_get_channels(struct mlx5e_priv *priv,int mlx5e_ethtool_set_channels (struct mlx5e_priv *priv,struct ethtool_channels *ch);int mlx5e_ethtool_get_coalesce (struct mlx5e_priv *priv, -struct ethtool_coalesce *coal); +struct ethtool_coalesce *coal, +struct kernel_ethtool_coalesce *kernel_coal);int mlx5e_ethtool_set_coalesce (struct mlx5e_priv *priv, -struct ethtool_coalesce *coal); +struct ethtool_coalesce *coal, +struct kernel_ethtool_coalesce *kernel_coal, +struct netlink_ext_ack *extack);int mlx5e_ethtool_get_link_ksettings (struct mlx5e_priv *priv,struct ethtool_link_ksettings *link_ksettings); int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv,
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +43 -6
105 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +2 -2
@@ -258,7 +258,7 @@ static int mlx5e_rep_get_coalesce(struct net_device *netdev, {struct mlx5e_priv *priv =netdev_priv (netdev); -return mlx5e_ethtool_get_coalesce (priv, coal); +return mlx5e_ethtool_get_coalesce (priv, coal, kernel_coal); } static int mlx5e_rep_set_coalesce(struct net_device *netdev,
@@ -268,7 +268,7 @@ static int mlx5e_rep_set_coalesce(struct net_device *netdev, {struct mlx5e_priv *priv =netdev_priv (netdev); -return mlx5e_ethtool_set_coalesce (priv, coal); +return mlx5e_ethtool_set_coalesce (priv, coal, kernel_coal, extack); }static u32 mlx5e_rep_get_rxfh_key_size (struct net_device *netdev)
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c +2 -2
@@ -105,7 +105,7 @@ static int mlx5i_set_coalesce(struct net_device *netdev, {struct mlx5e_priv *priv =mlx5i_epriv (netdev); -return mlx5e_ethtool_set_coalesce (priv, coal); +return mlx5e_ethtool_set_coalesce (priv, coal, kernel_coal, extack); } static int mlx5i_get_coalesce(struct net_device *netdev,
@@ -115,7 +115,7 @@ static int mlx5i_get_coalesce(struct net_device *netdev, {struct mlx5e_priv *priv =mlx5i_epriv (netdev); -return mlx5e_ethtool_get_coalesce (priv, coal); +return mlx5e_ethtool_get_coalesce (priv, coal, kernel_coal); } static int mlx5i_get_ts_info(struct net_device *netdev,
Signature · 1 line
2.31.1
PATCH v2 2/7 net/mlx5: Print more info on pci error handlers
In reply to Saeed MahameedFrom: Saeed Mahameed <[email protected]>
In case mlx5_pci_err_detected was called with state equals to pci_channel_io_perm_failure, the driver will never come back up.
It is nice to know why the driver went to zombie land, so print some useful information on pci err handlers.
--- .../net/ethernet/mellanox/mlx5/core/main.c | 51 ++++++++++++++----- 1 file changed, 37 insertions(+), 14 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +37 -14
@@ -1604,12 +1604,28 @@ static void remove_one(struct pci_dev *pdev)mlx5_devlink_free (devlink); } +#define mlx5_pci_trace (dev, fmt, ...) ({ \ + struct mlx5_core_dev *__dev = (dev); \ + mlx5_core_info(__dev, "%s Device state = %d health sensors: %d pci_status: %d. " fmt, \ + __func__, __dev->state, mlx5_health_check_fatal_sensors(__dev), \ + __dev->pci_status, ##__VA_ARGS__); \ +}) + +static const char *result2str (enum pci_ers_result result) +{ +return result ==PCI_ERS_RESULT_NEED_RESET ?"need reset" : + result ==PCI_ERS_RESULT_DISCONNECT ?"disconnect" : + result ==PCI_ERS_RESULT_RECOVERED ?"recovered" : +"unknown" ; +} +static pci_ers_result_t mlx5_pci_err_detected (struct pci_dev *pdev,pci_channel_state_t state) {struct mlx5_core_dev *dev =pci_get_drvdata (pdev); +enum pci_ers_result res; -mlx5_core_info (dev,"%s was called\n" , __func__); +mlx5_pci_trace (dev,"Enter, pci channel state = %d\n" , state);mlx5_enter_error_state (dev, false);mlx5_error_sw_reset (dev);
@@ -1617,8 +1633,11 @@ static pci_ers_result_t mlx5_pci_err_detected(struct pci_dev *pdev,mlx5_drain_health_wq (dev);mlx5_pci_disable_device (dev); -return state == pci_channel_io_perm_failure ? + res = state == pci_channel_io_perm_failure ?PCI_ERS_RESULT_DISCONNECT :PCI_ERS_RESULT_NEED_RESET ; + +mlx5_pci_trace (dev,"Exit, result = %d, %s\n" , res,result2str (res)); +return res; }/* wait for the device to show vital signs by waiting
@@ -1652,28 +1671,34 @@ static int wait_vital(struct pci_dev *pdev)static pci_ers_result_t mlx5_pci_slot_reset (struct pci_dev *pdev) { +enum pci_ers_result res =PCI_ERS_RESULT_DISCONNECT ;struct mlx5_core_dev *dev =pci_get_drvdata (pdev);int err; -mlx5_core_info (dev,"%s was called\n" , __func__); +mlx5_pci_trace (dev,"Enter\n" ); err =mlx5_pci_enable_device (dev);if (err) {mlx5_core_err (dev,"%s: mlx5_pci_enable_device failed with error code: %d\n" , __func__, err); -return PCI_ERS_RESULT_DISCONNECT ; + goto out; }pci_set_master (pdev);pci_restore_state (pdev);pci_save_state (pdev); -if (wait_vital (pdev)) { -mlx5_core_err (dev,"%s: wait_vital timed out\n" , __func__); -return PCI_ERS_RESULT_DISCONNECT ; + err =wait_vital (pdev); +if (err) { +mlx5_core_err (dev,"%s: wait vital failed with error code: %d\n" , + __func__, err); + goto out; } -return PCI_ERS_RESULT_RECOVERED ; + res =PCI_ERS_RESULT_RECOVERED ; +out: +mlx5_pci_trace (dev,"Exit, err = %d, result = %d, %s\n" , err, res,result2str (res)); +return res; }static void mlx5_pci_resume (struct pci_dev *pdev)
@@ -1681,14 +1706,12 @@ static void mlx5_pci_resume(struct pci_dev *pdev)struct mlx5_core_dev *dev =pci_get_drvdata (pdev);int err; -mlx5_core_info (dev,"%s was called\n" , __func__); +mlx5_pci_trace (dev,"Enter, loading driver..\n" ); err =mlx5_load_one (dev); -if (err) -mlx5_core_err (dev,"%s: mlx5_load_one failed with error code: %d\n" , - __func__, err); -else -mlx5_core_info (dev,"%s: device recovered\n" , __func__); + +mlx5_pci_trace (dev,"Done, err = %d, device %s\n" , err, + !err ?"recovered" :"Failed" ); }static const struct pci_error_handlers mlx5_err_handler = {
Signature · 1 line
2.31.1
PATCH v2 3/7 net/mlx5e: TC, Destroy nic flow counter if exists
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Counter is only added if counter flag exists.
So check the counter fag exists for deleting the counter. This is the same as in add/del fdb flow.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +2 -1
@@ -1137,7 +1137,8 @@ static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv,if (attr->action &MLX5_FLOW_CONTEXT_ACTION_MOD_HDR )mlx5e_detach_mod_hdr (priv, flow); -mlx5_fc_destroy (priv->mdev, attr->counter); +if (attr->action &MLX5_FLOW_CONTEXT_ACTION_COUNT ) +mlx5_fc_destroy (priv->mdev, attr->counter);if (flow_flag_test (flow,HAIRPIN ))mlx5e_hairpin_flow_del (priv, flow);
Signature · 1 line
2.31.1
PATCH v2 4/7 net/mlx5e: TC, Move kfree() calls after destroying all resources
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
When deleting fdb/nic flow rules first release all resources and then call the kfree() calls instead of sparse them around the function.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +4 -5
@@ -1132,8 +1132,6 @@ static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv, }mutex_unlock (&priv->fs.tc.t_lock); -kvfree (attr->parse_attr); -if (attr->action &MLX5_FLOW_CONTEXT_ACTION_MOD_HDR )mlx5e_detach_mod_hdr (priv, flow);
@@ -1143,6 +1141,7 @@ static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv,if (flow_flag_test (flow,HAIRPIN ))mlx5e_hairpin_flow_del (priv, flow); +kvfree (attr->parse_attr);kfree (flow->attr); }
@@ -1630,9 +1629,6 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,else mlx5e_detach_mod_hdr (priv, flow); } -kfree (attr->sample_attr); -kvfree (attr->parse_attr); -kvfree (attr->esw_attr->rx_tun_attr);if (attr->action &MLX5_FLOW_CONTEXT_ACTION_COUNT )mlx5_fc_destroy (esw_attr->counter_dev, attr->counter);
@@ -1646,6 +1642,9 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,if (flow_flag_test (flow,L3_TO_L2_DECAP ))mlx5e_detach_decap (priv, flow); +kfree (attr->sample_attr); +kvfree (attr->esw_attr->rx_tun_attr); +kvfree (attr->parse_attr);kfree (flow->attr); }
Signature · 1 line
2.31.1
PATCH v2 5/7 net/mlx5e: Refactor mod header management API
In reply to Saeed MahameedFrom: Paul Blakey <[email protected]>
For all mod hdr related functions to reside in a single self contained component (mod_hdr.c), refactor alloc() and add get_id() so that user won't rely on internal implementation, and move both to mod_hdr component.
Rename the prefix to mlx5e_mod_hdr_* as other mod hdr functions.
--- .../ethernet/mellanox/mlx5/core/en/mod_hdr.c | 47 ++++++++++ .../ethernet/mellanox/mlx5/core/en/mod_hdr.h | 13 +++ .../mellanox/mlx5/core/en/tc/sample.c | 5 +- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 25 ++---- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 90 ++++--------------- .../net/ethernet/mellanox/mlx5/core/en_tc.h | 5 -- .../mellanox/mlx5/core/esw/indir_table.c | 5 +- 7 files changed, 90 insertions(+), 100 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/mod_hdr.c +47 -0
@@ -155,3 +155,50 @@ struct mlx5_modify_hdr *mlx5e_mod_hdr_get(struct mlx5e_mod_hdr_handle *mh)return mh->modify_hdr; } +char * +mlx5e_mod_hdr_alloc (struct mlx5_core_dev *mdev,int namespace, +struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts) +{ +int new_num_actions, max_hw_actions; +size_t new_sz, old_sz; +void *ret; + +if (mod_hdr_acts->num_actions < mod_hdr_acts->max_actions) + goto out; + + max_hw_actions =mlx5e_mod_hdr_max_actions (mdev, namespace); + new_num_actions =min (max_hw_actions, + mod_hdr_acts->actions ? + mod_hdr_acts->max_actions *2 :1 ); +if (mod_hdr_acts->max_actions == new_num_actions) +return ERR_PTR (-ENOSPC ); + + new_sz =MLX5_MH_ACT_SZ * new_num_actions; + old_sz = mod_hdr_acts->max_actions *MLX5_MH_ACT_SZ ; + + ret =krealloc (mod_hdr_acts->actions, new_sz,GFP_KERNEL ); +if (!ret) +return ERR_PTR (-ENOMEM ); + +memset (ret + old_sz,0 , new_sz - old_sz); + mod_hdr_acts->actions = ret; + mod_hdr_acts->max_actions = new_num_actions; + +out: +return mod_hdr_acts->actions + (mod_hdr_acts->num_actions *MLX5_MH_ACT_SZ ); +} + +void +mlx5e_mod_hdr_dealloc (struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts) +{ +kfree (mod_hdr_acts->actions); + mod_hdr_acts->actions =NULL ; + mod_hdr_acts->num_actions =0 ; + mod_hdr_acts->max_actions =0 ; +} + +char * +mlx5e_mod_hdr_get_item (struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts,int pos) +{ +return mod_hdr_acts->actions + (pos *MLX5_MH_ACT_SZ ); +}
drivers/net/ethernet/mellanox/mlx5/core/en/mod_hdr.h +13 -0
@@ -15,6 +15,11 @@ struct mlx5e_tc_mod_hdr_acts {void *actions; }; +char *mlx5e_mod_hdr_alloc (struct mlx5_core_dev *mdev,int namespace, +struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts); +void mlx5e_mod_hdr_dealloc (struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts); +char *mlx5e_mod_hdr_get_item (struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts,int pos); +struct mlx5e_mod_hdr_handle * mlx5e_mod_hdr_attach(struct mlx5_core_dev *mdev, struct mod_hdr_tbl *tbl,
@@ -28,4 +33,12 @@ struct mlx5_modify_hdr *mlx5e_mod_hdr_get(struct mlx5e_mod_hdr_handle *mh);void mlx5e_mod_hdr_tbl_init (struct mod_hdr_tbl *tbl);void mlx5e_mod_hdr_tbl_destroy (struct mod_hdr_tbl *tbl); +static inline int mlx5e_mod_hdr_max_actions (struct mlx5_core_dev *mdev,int namespace) +{ +if (namespace ==MLX5_FLOW_NAMESPACE_FDB )/* FDB offloading */ +return MLX5_CAP_ESW_FLOWTABLE_FDB (mdev, max_modify_header_actions); +else /* namespace is MLX5_FLOW_NAMESPACE_KERNEL - NIC offloading */ +return MLX5_CAP_FLOWTABLE_NIC_RX (mdev, max_modify_header_actions); +} +#endif /* __MLX5E_EN_MOD_HDR_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c +3 -2
@@ -5,6 +5,7 @@#include <net/psample.h> #include "en/mapping.h" #include "en/tc/post_act.h" +#include "en/mod_hdr.h" #include "sample.h" #include "eswitch.h" #include "en_tc.h"
@@ -255,12 +256,12 @@ sample_modify_hdr_get(struct mlx5_core_dev *mdev, u32 obj_id, goto err_modify_hdr; } -dealloc_mod_hdr_actions (&mod_acts); +mlx5e_mod_hdr_dealloc (&mod_acts);return modify_hdr; err_modify_hdr: err_post_act: -dealloc_mod_hdr_actions (&mod_acts); +mlx5e_mod_hdr_dealloc (&mod_acts); err_set_regc0:return ERR_PTR (err); }
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +9 -16
@@ -609,22 +609,15 @@ mlx5_tc_ct_entry_create_nat(struct mlx5_tc_ct_priv *ct_priv,struct flow_action *flow_action = &flow_rule->action;struct mlx5_core_dev *mdev = ct_priv->dev;struct flow_action_entry *act; -size_t action_size;char *modact;int err, i; - action_size =MLX5_UN_SZ_BYTES (set_add_copy_action_in_auto); -flow_action_for_each (i, act, flow_action) {switch (act->id) {case FLOW_ACTION_MANGLE : { - err =alloc_mod_hdr_actions (mdev, ct_priv->ns_type, - mod_acts); -if (err) -return err; - - modact = mod_acts->actions + - mod_acts->num_actions * action_size; + modact =mlx5e_mod_hdr_alloc (mdev, ct_priv->ns_type, mod_acts); +if (IS_ERR (modact)) +return PTR_ERR (modact); err =mlx5_tc_ct_parse_mangle_to_mod_act (act, modact);if (err)
@@ -706,11 +699,11 @@ mlx5_tc_ct_entry_create_mod_hdr(struct mlx5_tc_ct_priv *ct_priv, attr->modify_hdr =mlx5e_mod_hdr_get (*mh); } -dealloc_mod_hdr_actions (&mod_acts); +mlx5e_mod_hdr_dealloc (&mod_acts);return 0 ; err_mapping: -dealloc_mod_hdr_actions (&mod_acts); +mlx5e_mod_hdr_dealloc (&mod_acts);mlx5_put_label_mapping (ct_priv, attr->ct_attr.ct_labels_id);return err; }
@@ -1445,7 +1438,7 @@ static int tc_ct_pre_ct_add_rules(struct mlx5_ct_ft *ct_ft, } pre_ct->miss_rule = rule; -dealloc_mod_hdr_actions (&pre_mod_acts); +mlx5e_mod_hdr_dealloc (&pre_mod_acts);kvfree (spec);return 0 ;
@@ -1454,7 +1447,7 @@ static int tc_ct_pre_ct_add_rules(struct mlx5_ct_ft *ct_ft, err_flow_rule:mlx5_modify_header_dealloc (dev, pre_ct->modify_hdr); err_mapping: -dealloc_mod_hdr_actions (&pre_mod_acts); +mlx5e_mod_hdr_dealloc (&pre_mod_acts);kvfree (spec);return err; }
@@ -1850,14 +1843,14 @@ __mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *ct_priv, } attr->ct_attr.ct_flow = ct_flow; -dealloc_mod_hdr_actions (&pre_mod_acts); +mlx5e_mod_hdr_dealloc (&pre_mod_acts);return ct_flow->pre_ct_rule; err_insert_orig:mlx5_modify_header_dealloc (priv->mdev, pre_ct_attr->modify_hdr); err_mapping: -dealloc_mod_hdr_actions (&pre_mod_acts); +mlx5e_mod_hdr_dealloc (&pre_mod_acts);mlx5_chains_put_chain_mapping (ct_priv->chains, ct_flow->chain_mapping); err_get_chain:kfree (ct_flow->pre_ct_attr);
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +15 -75
179 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +0 -5
@@ -247,11 +247,6 @@ int mlx5e_tc_add_flow_mod_hdr(struct mlx5e_priv *priv,struct mlx5e_tc_flow_parse_attr *parse_attr, struct mlx5e_tc_flow *flow); -int alloc_mod_hdr_actions (struct mlx5_core_dev *mdev, -int namespace, -struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts); -void dealloc_mod_hdr_actions (struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts); -struct mlx5e_tc_flow ;u32 mlx5e_tc_get_flow_tun_id (struct mlx5e_tc_flow *flow);
drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c +3 -2
@@ -14,6 +14,7 @@#include "fs_core.h" #include "esw/indir_table.h" #include "lib/fs_chains.h" +#include "en/mod_hdr.h" #define MLX5_ESW_INDIR_TABLE_SIZE 128#define MLX5_ESW_INDIR_TABLE_RECIRC_IDX_MAX (MLX5_ESW_INDIR_TABLE_SIZE - 2)
@@ -226,7 +227,7 @@ static int mlx5_esw_indir_table_rule_get(struct mlx5_eswitch *esw, goto err_handle; } -dealloc_mod_hdr_actions (&mod_acts); +mlx5e_mod_hdr_dealloc (&mod_acts); rule->handle = handle; rule->vni = esw_attr->rx_tun_attr->vni; rule->mh = flow_act.modify_hdr;
@@ -243,7 +244,7 @@ static int mlx5_esw_indir_table_rule_get(struct mlx5_eswitch *esw,mlx5_modify_header_dealloc (esw->dev, flow_act.modify_hdr); err_mod_hdr_alloc: err_mod_hdr_regc1: -dealloc_mod_hdr_actions (&mod_acts); +mlx5e_mod_hdr_dealloc (&mod_acts); err_mod_hdr_regc0: err_ethertype:kfree (rule);
Signature · 1 line
2.31.1
PATCH v2 6/7 net/mlx5: CT: Allow static allocation of mod headers
In reply to Saeed MahameedFrom: Paul Blakey <[email protected]>
As each CT rule uses at least 4 modify header actions, each rule causes at least 3 reallocations by the mod header actions api.
Allow initial static allocation of the mod acts array, and use it for CT rules. If the static allocation is exceeded go back to dynamic allocation.
--- .../ethernet/mellanox/mlx5/core/en/mod_hdr.c | 17 ++++++++++++++--- .../ethernet/mellanox/mlx5/core/en/mod_hdr.h | 13 +++++++++++++ .../net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 9 ++++++++- 3 files changed, 35 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/mod_hdr.c +14 -3
@@ -176,11 +176,20 @@ mlx5e_mod_hdr_alloc(struct mlx5_core_dev *mdev, int namespace, new_sz =MLX5_MH_ACT_SZ * new_num_actions; old_sz = mod_hdr_acts->max_actions *MLX5_MH_ACT_SZ ; - ret =krealloc (mod_hdr_acts->actions, new_sz,GFP_KERNEL ); +if (mod_hdr_acts->is_static) { + ret =kzalloc (new_sz,GFP_KERNEL ); +if (ret) { +memcpy (ret, mod_hdr_acts->actions, old_sz); + mod_hdr_acts->is_static = false; + } + }else { + ret =krealloc (mod_hdr_acts->actions, new_sz,GFP_KERNEL ); +if (ret) +memset (ret + old_sz,0 , new_sz - old_sz); + }if (!ret)return ERR_PTR (-ENOMEM ); -memset (ret + old_sz,0 , new_sz - old_sz); mod_hdr_acts->actions = ret; mod_hdr_acts->max_actions = new_num_actions;
@@ -191,7 +200,9 @@ mlx5e_mod_hdr_alloc(struct mlx5_core_dev *mdev, int namespace,void mlx5e_mod_hdr_dealloc (struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts) { -kfree (mod_hdr_acts->actions); +if (!mod_hdr_acts->is_static) +kfree (mod_hdr_acts->actions); + mod_hdr_acts->actions =NULL ; mod_hdr_acts->num_actions =0 ; mod_hdr_acts->max_actions =0 ;
drivers/net/ethernet/mellanox/mlx5/core/en/mod_hdr.h +13 -0
@@ -7,14 +7,27 @@#include <linux/hashtable.h> #include <linux/mlx5/fs.h> +#define MLX5_MH_ACT_SZ MLX5_UN_SZ_BYTES(set_add_copy_action_in_auto) +struct mlx5e_mod_hdr_handle ;struct mlx5e_tc_mod_hdr_acts {int num_actions;int max_actions; +bool is_static;void *actions; }; +#define DECLARE_MOD_HDR_ACTS_ACTIONS (name, len) \ + u8 name[len][MLX5_MH_ACT_SZ] = {} + +#define DECLARE_MOD_HDR_ACTS (name, acts_arr) \ + struct mlx5e_tc_mod_hdr_acts name = { \ + .max_actions = ARRAY_SIZE(acts_arr), \ + .is_static = true, \ + .actions = acts_arr, \ + } +char *mlx5e_mod_hdr_alloc (struct mlx5_core_dev *mdev,int namespace,struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts);void mlx5e_mod_hdr_dealloc (struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts);
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +8 -1
@@ -36,6 +36,12 @@#define MLX5_CT_LABELS_BITS (mlx5e_tc_attr_to_reg_mappings[LABELS_TO_REG].mlen)#define MLX5_CT_LABELS_MASK GENMASK(MLX5_CT_LABELS_BITS - 1, 0) +/* Statically allocate modify actions for +* ipv6 and port nat (5) + tuple fields (4) + nic mode zone restore (1) = 10. +* This will be increased dynamically if needed (for the ipv6 snat + dnat). +*/ +#define MLX5_CT_MIN_MOD_ACTS 10 + #define ct_dbg(fmt, args...)\ netdev_dbg(ct_priv->netdev, "ct_debug: " fmt "\n", ##args)
@@ -645,7 +651,8 @@ mlx5_tc_ct_entry_create_mod_hdr(struct mlx5_tc_ct_priv *ct_priv,struct mlx5e_mod_hdr_handle **mh, u8 zone_restore_id, bool nat) { - struct mlx5e_tc_mod_hdr_acts mod_acts = {}; +DECLARE_MOD_HDR_ACTS_ACTIONS (actions_arr ,MLX5_CT_MIN_MOD_ACTS ); +DECLARE_MOD_HDR_ACTS (mod_acts, actions_arr);struct flow_action_entry *meta;u16 ct_state =0 ;int err;
Signature · 1 line
2.31.1
PATCH v2 7/7 net/mlx5e: TC, Remove redundant action stack var
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Remove the action stack var from parse tc fdb actions and prase tc nic actions, use the flow attr action var directly.
--- .../mellanox/mlx5/core/en/tc_tun_encap.c | 2 +- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 89 +++++++++---------- .../net/ethernet/mellanox/mlx5/core/en_tc.h | 1 - 3 files changed, 42 insertions(+), 50 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c +1 -1
@@ -28,7 +28,7 @@ static int mlx5e_set_int_port_tunnel(struct mlx5e_priv *priv, err =mlx5e_set_fwd_to_int_port_actions (priv, attr, e->route_dev_ifindex,MLX5E_TC_INT_PORT_EGRESS , - &attr->action, out_index); + out_index); out:if (route_dev)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +41 -48
271 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +0 -1
@@ -285,7 +285,6 @@ int mlx5e_set_fwd_to_int_port_actions(struct mlx5e_priv *priv,struct mlx5_flow_attr *attr, int ifindex, enum mlx5e_tc_int_port_type type, - u32 *action, int out_index);#else /* CONFIG_MLX5_CLS_ACT */ static inline int mlx5e_tc_nic_init (struct mlx5e_priv *priv) {return 0 ; }
Signature · 1 line
2.31.1