mlx5 updates 2022-03-10
Subsystems (7)
PATCH 1/15 net/mlx4: Delete useless moduleparam include
In reply to Saeed MahameedFrom: Leon Romanovsky <[email protected]>
Remove inclusion of not used moduleparam.h.
--- drivers/net/ethernet/mellanox/mlx4/en_tx.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/mellanox/mlx4/en_tx.c +0 -1
@@ -42,7 +42,6 @@#include <linux/tcp.h> #include <linux/ip.h> #include <linux/ipv6.h> -#include <linux/moduleparam.h> #include <linux/indirect_call_wrapper.h> #include "mlx4_en.h"
Signature · 1 line
2.35.1
PATCH 2/15 net/mlx5: Delete useless module.h include
In reply to Saeed MahameedFrom: Leon Romanovsky <[email protected]>
There is no need in include of module.h in the following files.
--- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/cq.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/debugfs.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/eq.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/fw.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/health.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/lib/port_tun.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/mcg.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/mr.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/pd.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/rl.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/uar.c | 1 - 18 files changed, 18 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +0 -1
@@ -31,7 +31,6 @@*/ #include <linux/highmem.h> -#include <linux/module.h> #include <linux/errno.h> #include <linux/pci.h> #include <linux/dma-mapping.h>
drivers/net/ethernet/mellanox/mlx5/core/cq.c +0 -1
@@ -31,7 +31,6 @@*/ #include <linux/kernel.h> -#include <linux/module.h> #include <linux/hardirq.h> #include <linux/mlx5/driver.h> #include <rdma/ib_verbs.h>
drivers/net/ethernet/mellanox/mlx5/core/debugfs.c +0 -1
@@ -30,7 +30,6 @@* SOFTWARE. */ -#include <linux/module.h> #include <linux/debugfs.h> #include <linux/mlx5/qp.h> #include <linux/mlx5/cq.h>
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +0 -1
@@ -35,7 +35,6 @@#include <crypto/aead.h> #include <linux/inetdevice.h> #include <linux/netdevice.h> -#include <linux/module.h> #include "en.h" #include "en_accel/ipsec.h"
drivers/net/ethernet/mellanox/mlx5/core/eq.c +0 -1
@@ -5,7 +5,6 @@#include <linux/interrupt.h> #include <linux/notifier.h> -#include <linux/module.h> #include <linux/mlx5/driver.h> #include <linux/mlx5/vport.h> #include <linux/mlx5/eq.h>
drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c +0 -1
@@ -30,7 +30,6 @@* SOFTWARE. */ -#include <linux/module.h> #include <linux/etherdevice.h> #include <linux/mlx5/driver.h>
drivers/net/ethernet/mellanox/mlx5/core/fw.c +0 -1
@@ -32,7 +32,6 @@#include <linux/mlx5/driver.h> #include <linux/mlx5/eswitch.h> -#include <linux/module.h> #include "mlx5_core.h" #include "../../mlxfw/mlxfw.h" #include "lib/tout.h"
drivers/net/ethernet/mellanox/mlx5/core/health.c +0 -1
@@ -31,7 +31,6 @@*/ #include <linux/kernel.h> -#include <linux/module.h> #include <linux/random.h> #include <linux/vmalloc.h> #include <linux/hardirq.h>
drivers/net/ethernet/mellanox/mlx5/core/lib/port_tun.c +0 -1
@@ -1,7 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ /* Copyright (c) 2019 Mellanox Technologies. */ -#include <linux/module.h> #include <linux/mlx5/driver.h> #include <linux/mlx5/port.h> #include "mlx5_core.h"
drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c +0 -1
@@ -31,7 +31,6 @@*/ #include <linux/kernel.h> -#include <linux/module.h> #include <linux/refcount.h> #include <linux/mlx5/driver.h> #include <net/vxlan.h>
drivers/net/ethernet/mellanox/mlx5/core/mcg.c +0 -1
@@ -31,7 +31,6 @@*/ #include <linux/kernel.h> -#include <linux/module.h> #include <linux/mlx5/driver.h> #include <rdma/ib_verbs.h> #include "mlx5_core.h"
drivers/net/ethernet/mellanox/mlx5/core/mr.c +0 -1
@@ -31,7 +31,6 @@*/ #include <linux/kernel.h> -#include <linux/module.h> #include <linux/mlx5/driver.h> #include "mlx5_core.h"
drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +0 -1
@@ -32,7 +32,6 @@#include <linux/highmem.h> #include <linux/kernel.h> -#include <linux/module.h> #include <linux/delay.h> #include <linux/mlx5/driver.h> #include <linux/xarray.h>
drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c +0 -1
@@ -3,7 +3,6 @@#include <linux/interrupt.h> #include <linux/notifier.h> -#include <linux/module.h> #include <linux/mlx5/driver.h> #include "mlx5_core.h" #include "mlx5_irq.h"
drivers/net/ethernet/mellanox/mlx5/core/pd.c +0 -1
@@ -31,7 +31,6 @@*/ #include <linux/kernel.h> -#include <linux/module.h> #include <linux/mlx5/driver.h> #include "mlx5_core.h"
drivers/net/ethernet/mellanox/mlx5/core/rl.c +0 -1
@@ -31,7 +31,6 @@*/ #include <linux/kernel.h> -#include <linux/module.h> #include <linux/mlx5/driver.h> #include "mlx5_core.h"
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c +0 -1
@@ -3,7 +3,6 @@#include <linux/debugfs.h> #include <linux/kernel.h> -#include <linux/module.h> #include <linux/seq_file.h> #include "dr_types.h"
drivers/net/ethernet/mellanox/mlx5/core/uar.c +0 -1
@@ -31,7 +31,6 @@*/ #include <linux/kernel.h> -#include <linux/module.h> #include <linux/io-mapping.h> #include <linux/mlx5/driver.h> #include "mlx5_core.h"
Signature · 1 line
2.35.1
PATCH 3/15 net/mlx5: Node-aware allocation for the IRQ table
In reply to Saeed MahameedFrom: Tariq Toukan <[email protected]>
Prefer the aware allocation, use the device NUMA node.
--- drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c +2 -1
@@ -600,7 +600,8 @@ int mlx5_irq_table_init(struct mlx5_core_dev *dev)if (mlx5_core_is_sf (dev))return 0 ; - irq_table =kvzalloc (sizeof (*irq_table),GFP_KERNEL ); + irq_table =kvzalloc_node (sizeof (*irq_table),GFP_KERNEL , + dev->priv.numa_node);if (!irq_table)return -ENOMEM ;
Signature · 1 line
2.35.1
From: Saeed Mahameed <[email protected]>
Hi Dave, Hi Jakub,
This series provides misc updates to mlx5 driver.
For more information please see tag log below.
Please pull and let me know if there is any problem.
Thanks,
Saeed.
The following changes since commit 63f13b2e879679014f42b65fb50dabde02c85726:
Merge branch 'net-ipa-use-bulk-interconnect-interfaces' (2022-03-10 21:20:08 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2022-03-10
for you to fetch changes up to 970adfb76095fa719778d70a6b86030d2feb88dd:
net/mlx5e: Remove overzealous validations in netlink EEPROM query (2022-03-10 23:38:25 -0800)
----------------------------------------------------------------
mlx5-updates-2022-03-10
1) Leon removes useless includes from both mlx5 and mlx4
2) Tariq adds node awareness to some object allocations
3) Gal Cleanups and improvements to EEPROM query
4) Paul adds Software steering to Connection Tracking, to speed up CT Rules insertion.
Paul Blakey Says:
=================
To improve insertion rate, this series allows for using software steering API directly instead of going through the fs_core layer. This can be done for CT because it doesn't need fs_core layer extra facilities, such as autogroups, FTE IDs and modifications (which require a copy of the flow key/mask). Skipping fs_core layer also allows to create the software steering objects (dr_* objects) ahead of time and re-use them for multiple rules, whereas software steering under fs_core creates them on the fly and discards them. This in turn increased insertion rate.
The series first introduces a lightweight CT flow steering provider with the first implementations using fs_core layer, and moves CT to use it. The next patches implement a provider using software steering directly, bypassing fs_core, and uses it if software steering is available.
=================
----------------------------------------------------------------
Gal Pressman (3):
net/mlx5: Query the maximum MCIA register read size from firmware net/mlx5: Parse module mapping using mlx5_ifc net/mlx5e: Remove overzealous validations in netlink EEPROM query
Leon Romanovsky (2):
net/mlx4: Delete useless moduleparam include net/mlx5: Delete useless module.h include
Paul Blakey (5):
net/mlx5: CT: Introduce a platform for multiple flow steering providers net/mlx5: DR, Add helper to get backing dr table from a mlx5 flow table net/mlx5: Add smfs lib to export direct steering API to CT net/mlx5: CT: Add software steering ct flow steering provider net/mlx5: CT: Create smfs dr matchers dynamically
Tariq Toukan (5):
net/mlx5: Node-aware allocation for the IRQ table net/mlx5: Node-aware allocation for the EQ table net/mlx5: Node-aware allocation for the EQs net/mlx5: Node-aware allocation for UAR net/mlx5: Node-aware allocation for the doorbell pgdir
drivers/net/ethernet/mellanox/mlx4/en_tx.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/Makefile | 8 +- drivers/net/ethernet/mellanox/mlx5/core/alloc.c | 4 +- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/cq.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/debugfs.c | 1 - .../net/ethernet/mellanox/mlx5/core/en/tc/ct_fs.h | 49 +++ .../ethernet/mellanox/mlx5/core/en/tc/ct_fs_dmfs.c | 79 +++++ .../ethernet/mellanox/mlx5/core/en/tc/ct_fs_smfs.c | 372 +++++++++++++++++++++ drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 53 ++- drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h | 2 + .../ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/eq.c | 10 +- .../net/ethernet/mellanox/mlx5/core/fpga/core.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/fw.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/health.c | 1 - .../net/ethernet/mellanox/mlx5/core/lib/port_tun.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/lib/smfs.c | 68 ++++ drivers/net/ethernet/mellanox/mlx5/core/lib/smfs.h | 36 ++ .../net/ethernet/mellanox/mlx5/core/lib/vxlan.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/mcg.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/mr.c | 1 - .../net/ethernet/mellanox/mlx5/core/pagealloc.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c | 4 +- drivers/net/ethernet/mellanox/mlx5/core/pd.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/port.c | 37 +- drivers/net/ethernet/mellanox/mlx5/core/rl.c | 1 - .../ethernet/mellanox/mlx5/core/steering/dr_dbg.c | 1 - .../mellanox/mlx5/core/steering/dr_table.c | 5 + .../ethernet/mellanox/mlx5/core/steering/mlx5dr.h | 3 + drivers/net/ethernet/mellanox/mlx5/core/uar.c | 9 +- include/linux/mlx5/mlx5_ifc.h | 12 +- include/linux/mlx5/port.h | 2 - 33 files changed, 700 insertions(+), 69 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/ct_fs.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/ct_fs_dmfs.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/ct_fs_smfs.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/lib/smfs.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/lib/smfs.h
PATCH 4/15 net/mlx5: Node-aware allocation for the EQ table
From: Tariq Toukan <[email protected]>
Prefer the aware allocation, use the device NUMA node.
--- drivers/net/ethernet/mellanox/mlx5/core/eq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/eq.c +2 -1
@@ -438,7 +438,8 @@ int mlx5_eq_table_init(struct mlx5_core_dev *dev)struct mlx5_eq_table *eq_table;int i; - eq_table =kvzalloc (sizeof (*eq_table),GFP_KERNEL ); + eq_table =kvzalloc_node (sizeof (*eq_table),GFP_KERNEL , + dev->priv.numa_node);if (!eq_table)return -ENOMEM ;
Signature · 1 line
2.35.1
PATCH 6/15 net/mlx5: Node-aware allocation for UAR
In reply to Saeed MahameedFrom: Tariq Toukan <[email protected]>
Prefer the aware allocation, use the device NUMA node.
--- drivers/net/ethernet/mellanox/mlx5/core/uar.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/uar.c +5 -3
@@ -99,19 +99,21 @@ static struct mlx5_uars_page *alloc_uars_page(struct mlx5_core_dev *mdev,int err = -ENOMEM ;phys_addr_t pfn;int bfregs; +int node;int i; bfregs =uars_per_sys_page (mdev) *MLX5_BFREGS_PER_UAR ; - up =kzalloc (sizeof (*up),GFP_KERNEL ); + node = mdev->priv.numa_node; + up =kzalloc_node (sizeof (*up),GFP_KERNEL , node);if (!up)return ERR_PTR (err); up->mdev = mdev; - up->reg_bitmap =bitmap_zalloc (bfregs,GFP_KERNEL ); + up->reg_bitmap =bitmap_zalloc_node (bfregs,GFP_KERNEL , node);if (!up->reg_bitmap) goto error1; - up->fp_bitmap =bitmap_zalloc (bfregs,GFP_KERNEL ); + up->fp_bitmap =bitmap_zalloc_node (bfregs,GFP_KERNEL , node);if (!up->fp_bitmap) goto error1;
Signature · 1 line
2.35.1
PATCH 7/15 net/mlx5: Node-aware allocation for the doorbell pgdir
In reply to Saeed MahameedFrom: Tariq Toukan <[email protected]>
The function is node-aware and gets the node as an argument. Use a node-aware allocation for the doorbell pgdir structure.
--- drivers/net/ethernet/mellanox/mlx5/core/alloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/alloc.c +2 -2
@@ -183,11 +183,11 @@ static struct mlx5_db_pgdir *mlx5_alloc_db_pgdir(struct mlx5_core_dev *dev,u32 db_per_page =PAGE_SIZE /cache_line_size ();struct mlx5_db_pgdir *pgdir; - pgdir =kzalloc (sizeof (*pgdir),GFP_KERNEL ); + pgdir =kzalloc_node (sizeof (*pgdir),GFP_KERNEL , node);if (!pgdir)return NULL ; - pgdir->bitmap =bitmap_zalloc (db_per_page,GFP_KERNEL ); + pgdir->bitmap =bitmap_zalloc_node (db_per_page,GFP_KERNEL , node);if (!pgdir->bitmap) {kfree (pgdir);return NULL ;
Signature · 1 line
2.35.1
PATCH 5/15 net/mlx5: Node-aware allocation for the EQs
In reply to Saeed MahameedFrom: Tariq Toukan <[email protected]>
Prefer the aware allocation, use the device NUMA node.
--- drivers/net/ethernet/mellanox/mlx5/core/eq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eq.c +4 -2
@@ -728,7 +728,8 @@ struct mlx5_eq * mlx5_eq_create_generic(struct mlx5_core_dev *dev, struct mlx5_eq_param *param) { - struct mlx5_eq *eq = kvzalloc(sizeof(*eq), GFP_KERNEL); + struct mlx5_eq *eq = kvzalloc_node(sizeof(*eq), GFP_KERNEL, + dev->priv.numa_node);int err;if (!eq)
@@ -888,10 +889,11 @@ static int create_comp_eqs(struct mlx5_core_dev *dev)return ncomp_eqs;INIT_LIST_HEAD (&table->comp_eqs_list); nent =comp_eq_depth_devlink_param_get (dev); +for (i =0 ; i < ncomp_eqs; i++) {struct mlx5_eq_param param = {}; - eq =kzalloc (sizeof (*eq),GFP_KERNEL ); + eq =kzalloc_node (sizeof (*eq),GFP_KERNEL , dev->priv.numa_node);if (!eq) { err = -ENOMEM ; goto clean;
Signature · 1 line
2.35.1
PATCH 8/15 net/mlx5: CT: Introduce a platform for multiple flow steering providers
In reply to Saeed MahameedFrom: Paul Blakey <[email protected]>
Currently, fs_core layer provides flow steering services to the driver
including: autogroups, allocating FTEs (flow table entries) and FTE ids, and support of fte action modification. If then software steering is configured, rule insertion will go through a translation layer from firmware buffers to software steering objects (see fs_dr.c).
The connection tracking table is a system table that is not directly controlled by the user and is a very high scale table. These fs_core services introduces an overhead that may be optimized by using software steering API directly.
Introduce ct flow steering interface to allow multiple flow steering providers. Use the new interface to implement the current dmfs (device managed flow steering) provider which uses fs_core insertion.
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../ethernet/mellanox/mlx5/core/en/tc/ct_fs.h | 24 +++++++ .../mellanox/mlx5/core/en/tc/ct_fs_dmfs.c | 64 +++++++++++++++++++ .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 33 +++++++++- 4 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/ct_fs.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/ct_fs_dmfs.c
drivers/net/ethernet/mellanox/mlx5/core/Makefile +1 -1
@@ -55,7 +55,7 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en/tc/act/act.o en/tc/act/drop.o en/tc/a en/tc/act/ct.o en/tc/act/sample.o en/tc/act/ptype.o \ en/tc/act/redirect_ingress.o -mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o +mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o en/tc/ct_fs_dmfs.o mlx5_core-$(CONFIG_MLX5_TC_SAMPLE) += en/tc/sample.o #
drivers/net/ethernet/mellanox/mlx5/core/en/tc/ct_fs.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. */ + +#ifndef __MLX5_EN_TC_CT_FS_H__ +#define __MLX5_EN_TC_CT_FS_H__ + +struct mlx5_ct_fs { +const struct net_device *netdev; +struct mlx5_core_dev *dev; +}; + +struct mlx5_ct_fs_rule { +}; + +struct mlx5_ct_fs_ops { +struct mlx5_ct_fs_rule * (*ct_rule_add)(struct mlx5_ct_fs *fs, +struct mlx5_flow_spec *spec, +struct mlx5_flow_attr *attr); +void (*ct_rule_del)(struct mlx5_ct_fs *fs,struct mlx5_ct_fs_rule *fs_rule); +}; + +struct mlx5_ct_fs_ops *mlx5_ct_fs_dmfs_ops_get (void ); + +#endif /* __MLX5_EN_TC_CT_FS_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en/tc/ct_fs_dmfs.c new file +64 -0
64 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +30 -3
@@ -18,6 +18,7 @@#include "lib/fs_chains.h" #include "en/tc_ct.h" +#include "en/tc/ct_fs.h" #include "en/tc_priv.h" #include "en/mod_hdr.h" #include "en/mapping.h"
@@ -63,6 +64,8 @@ struct mlx5_tc_ct_priv {struct mapping_ctx *labels_mapping;enum mlx5_flow_namespace_type ns_type;struct mlx5_fs_chains *chains; +struct mlx5_ct_fs *fs; +struct mlx5_ct_fs_ops *fs_ops;spinlock_t ht_lock;/* protects ft entries */ };
@@ -74,7 +77,7 @@ struct mlx5_ct_flow { };struct mlx5_ct_zone_rule { -struct mlx5_flow_handle *rule; +struct mlx5_ct_fs_rule *rule;struct mlx5e_mod_hdr_handle *mh;struct mlx5_flow_attr *attr;bool nat;
@@ -505,7 +508,7 @@ mlx5_tc_ct_entry_del_rule(struct mlx5_tc_ct_priv *ct_priv,ct_dbg ("Deleting ct entry rule in zone %d" , entry->tuple.zone); -mlx5_tc_rule_delete (netdev_priv (ct_priv->netdev), zone_rule->rule, attr); + ct_priv->fs_ops->ct_rule_del (ct_priv->fs, zone_rule->rule);mlx5_tc_ct_entry_destroy_mod_hdr (ct_priv, zone_rule->attr, zone_rule->mh);mlx5_put_label_mapping (ct_priv, attr->ct_attr.ct_labels_id);kfree (attr);
@@ -816,7 +819,7 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,mlx5_tc_ct_set_tuple_match (ct_priv, spec, flow_rule);mlx5e_tc_match_to_reg_match (spec,ZONE_TO_REG , entry->tuple.zone,MLX5_CT_ZONE_MASK ); - zone_rule->rule =mlx5_tc_rule_insert (priv, spec, attr); + zone_rule->rule = ct_priv->fs_ops->ct_rule_add (ct_priv->fs, spec, attr);if (IS_ERR (zone_rule->rule)) { err =PTR_ERR (zone_rule->rule);ct_dbg ("Failed to add ct entry rule, nat: %d" , nat);
@@ -1960,6 +1963,22 @@ mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *priv,mutex_unlock (&priv->control_lock); } +static int +mlx5_tc_ct_fs_init (struct mlx5_tc_ct_priv *ct_priv) +{ +struct mlx5_ct_fs_ops *fs_ops =mlx5_ct_fs_dmfs_ops_get (); + + ct_priv->fs =kzalloc (sizeof (*ct_priv->fs),GFP_KERNEL ); +if (!ct_priv->fs) +return -ENOMEM ; + + ct_priv->fs->netdev = ct_priv->netdev; + ct_priv->fs->dev = ct_priv->dev; + ct_priv->fs_ops = fs_ops; + +return 0 ; +} +static int mlx5_tc_ct_init_check_esw_support (struct mlx5_eswitch *esw,const char **err_msg)
@@ -2098,8 +2117,14 @@ mlx5_tc_ct_init(struct mlx5e_priv *priv, struct mlx5_fs_chains *chains,if (rhashtable_init (&ct_priv->ct_tuples_nat_ht, &tuples_nat_ht_params)) goto err_ct_tuples_nat_ht; + err =mlx5_tc_ct_fs_init (ct_priv); +if (err) + goto err_init_fs; +return ct_priv; +err_init_fs: +rhashtable_destroy (&ct_priv->ct_tuples_nat_ht); err_ct_tuples_nat_ht:rhashtable_destroy (&ct_priv->ct_tuples_ht); err_ct_tuples_ht:
@@ -2130,6 +2155,8 @@ mlx5_tc_ct_clean(struct mlx5_tc_ct_priv *ct_priv) chains = ct_priv->chains; +kfree (ct_priv->fs); +mlx5_chains_destroy_global_table (chains, ct_priv->ct_nat);mlx5_chains_destroy_global_table (chains, ct_priv->ct);mapping_destroy (ct_priv->zone_mapping);
Signature · 1 line
2.35.1
PATCH 9/15 net/mlx5: DR, Add helper to get backing dr table from a mlx5 flow table
In reply to Saeed MahameedFrom: Paul Blakey <[email protected]>
If sw steering was used to create the table, dr steeering fs creates a backing dr table for the mlx5 flow table.
Add helper to return this table so it can be used to create matchers and add rules on it directly instead of passing via eswitch_offloads/fs_core insertion.
--- drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c | 5 +++++ drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h | 3 +++ 2 files changed, 8 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c +5 -0
@@ -305,3 +305,8 @@ u32 mlx5dr_table_get_id(struct mlx5dr_table *tbl) {return tbl->table_id; } + +struct mlx5dr_table *mlx5dr_table_get_from_fs_ft (struct mlx5_flow_table *ft) +{ +return ft->fs_dr_table.dr_table; +}
drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h +3 -0
@@ -53,6 +53,9 @@ void mlx5dr_domain_set_peer(struct mlx5dr_domain *dmn,struct mlx5dr_table *mlx5dr_table_create (struct mlx5dr_domain *domain,u32 level,u32 flags); +struct mlx5dr_table * +mlx5dr_table_get_from_fs_ft (struct mlx5_flow_table *ft); +int mlx5dr_table_destroy (struct mlx5dr_table *table);u32 mlx5dr_table_get_id (struct mlx5dr_table *table);
Signature · 1 line
2.35.1
PATCH 10/15 net/mlx5: Add smfs lib to export direct steering API to CT
In reply to Saeed MahameedFrom: Paul Blakey <[email protected]>
Add a thin layer that exports selected direct steering (dr) API which will be used by a ct fs implementation in a following patch.
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../ethernet/mellanox/mlx5/core/lib/smfs.c | 68 +++++++++++++++++++ .../ethernet/mellanox/mlx5/core/lib/smfs.h | 36 ++++++++++ 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/lib/smfs.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/lib/smfs.h
drivers/net/ethernet/mellanox/mlx5/core/Makefile +1 -1
@@ -106,7 +106,7 @@ mlx5_core-$(CONFIG_MLX5_SW_STEERING) += steering/dr_domain.o steering/dr_table.o steering/dr_ste_v2.o \ steering/dr_cmd.o steering/dr_fw.o \ steering/dr_action.o steering/fs_dr.o \ - steering/dr_dbg.o + steering/dr_dbg.o lib/smfs.o # # SF device #
drivers/net/ethernet/mellanox/mlx5/core/lib/smfs.c new file +68 -0
68 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/lib/smfs.h new file +36 -0
@@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. */ + +#ifndef __MLX5_LIB_SMFS_H__ +#define __MLX5_LIB_SMFS_H__ + +#include "steering/mlx5dr.h" +#include "steering/dr_types.h" + +struct mlx5dr_matcher * +mlx5_smfs_matcher_create (struct mlx5dr_table *table,u32 priority,struct mlx5_flow_spec *spec); + +void +mlx5_smfs_matcher_destroy (struct mlx5dr_matcher *matcher); + +struct mlx5dr_table * +mlx5_smfs_table_get_from_fs_ft (struct mlx5_flow_table *ft); + +struct mlx5dr_action * +mlx5_smfs_action_create_dest_table (struct mlx5dr_table *table); + +struct mlx5dr_action * +mlx5_smfs_action_create_flow_counter (u32 counter_id); + +void +mlx5_smfs_action_destroy (struct mlx5dr_action *action); + +struct mlx5dr_rule * +mlx5_smfs_rule_create (struct mlx5dr_matcher *matcher,struct mlx5_flow_spec *spec, +size_t num_actions,struct mlx5dr_action *actions[], +u32 flow_source); + +void +mlx5_smfs_rule_destroy (struct mlx5dr_rule *rule); + +#endif /* __MLX5_LIB_SMFS_H__ */
Signature · 1 line
2.35.1
PATCH 12/15 net/mlx5: CT: Create smfs dr matchers dynamically
In reply to Saeed MahameedFrom: Paul Blakey <[email protected]>
SMFS dr matchers are processed sequentially in hardware according to their priorities, and not skipped if empty.
Currently, smfs ct fs creates four predefined dr matchers per ct table (ct/ct nat) with hardcoded priority. Compared to dmfs ct fs using autogroups, this might cause additional hops in fastpath for traffic patterns that match later priorties, even if previous priorites are empty, e.g user only using ipv6 UDP traffic will have additional 3 hops.
Create the matchers dynamically, using the highest priority available, on first rule usage, and remove them on last usage.
--- .../mellanox/mlx5/core/en/tc/ct_fs_smfs.c | 182 +++++++++--------- 1 file changed, 94 insertions(+), 88 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/ct_fs_smfs.c +94 -88
@@ -1,6 +1,8 @@// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. */ +#include <linux/refcount.h> +#include "en_tc.h" #include "en/tc_priv.h" #include "en/tc_ct.h"
@@ -13,24 +15,32 @@ netdev_dbg(fs->netdev, "ct_fs_smfs debug: " fmt "\n", ##args) #define MLX5_CT_TCP_FLAGS_MASK cpu_to_be16(be32_to_cpu(TCP_FLAG_RST | TCP_FLAG_FIN) >> 16) +struct mlx5_ct_fs_smfs_matcher { +struct mlx5dr_matcher *dr_matcher; +struct list_head list; +int prio; +refcount_t ref; +}; +struct mlx5_ct_fs_smfs_matchers { -struct mlx5dr_matcher *ipv4_tcp; -struct mlx5dr_matcher *ipv4_udp; -struct mlx5dr_matcher *ipv6_tcp; -struct mlx5dr_matcher *ipv6_udp; +struct mlx5_ct_fs_smfs_matcher smfs_matchers[4 ]; +struct list_head used; };struct mlx5_ct_fs_smfs { -struct mlx5_ct_fs_smfs_matchers ct_matchers; -struct mlx5_ct_fs_smfs_matchers ct_matchers_nat; +struct mlx5dr_table *ct_tbl, *ct_nat_tbl; +struct mlx5_ct_fs_smfs_matchers matchers; +struct mlx5_ct_fs_smfs_matchers matchers_nat;struct mlx5dr_action *fwd_action;struct mlx5_flow_table *ct_nat; +struct mutex lock;/* Guards matchers */ };struct mlx5_ct_fs_smfs_rule {struct mlx5_ct_fs_rule fs_rule;struct mlx5dr_rule *rule;struct mlx5dr_action *count_action; +struct mlx5_ct_fs_smfs_matcher *smfs_matcher; }; static inline void
@@ -97,71 +107,75 @@ mlx5_ct_fs_smfs_matcher_create(struct mlx5_ct_fs *fs, struct mlx5dr_table *tbl,return dr_matcher; } -static int -mlx5_ct_fs_smfs_matchers_create (struct mlx5_ct_fs *fs,struct mlx5dr_table *tbl, -struct mlx5_ct_fs_smfs_matchers *ct_matchers) +static struct mlx5_ct_fs_smfs_matcher * +mlx5_ct_fs_smfs_matcher_get (struct mlx5_ct_fs *fs,bool nat,bool ipv4,bool tcp) { -const struct net_device *netdev = fs->netdev; -u32 prio =0 ; -int err; - - ct_matchers->ipv4_tcp =mlx5_ct_fs_smfs_matcher_create (fs, tbl, true, true, prio); -if (IS_ERR (ct_matchers->ipv4_tcp)) { - err =PTR_ERR (ct_matchers->ipv4_tcp); -netdev_warn (netdev, -"%s, failed to create ipv4 tcp matcher, err: %d\n" , -INIT_ERR_PREFIX , err); -return err; - } - - ++prio; - ct_matchers->ipv4_udp =mlx5_ct_fs_smfs_matcher_create (fs, tbl, true, false, prio); -if (IS_ERR (ct_matchers->ipv4_udp)) { - err =PTR_ERR (ct_matchers->ipv4_udp); -netdev_warn (netdev, -"%s, failed to create ipv4 udp matcher, err: %d\n" , -INIT_ERR_PREFIX , err); - goto err_matcher_ipv4_udp; +struct mlx5_ct_fs_smfs *fs_smfs =mlx5_ct_fs_priv (fs); +struct mlx5_ct_fs_smfs_matcher *m, *smfs_matcher; +struct mlx5_ct_fs_smfs_matchers *matchers; +struct mlx5dr_matcher *dr_matcher; +struct mlx5dr_table *tbl; +struct list_head *prev; +int prio; + + matchers = nat ? &fs_smfs->matchers_nat : &fs_smfs->matchers; + smfs_matcher = &matchers->smfs_matchers[ipv4 *2 + tcp]; + +if (refcount_inc_not_zero (&smfs_matcher->ref)) +return smfs_matcher; + +mutex_lock (&fs_smfs->lock); + +/* Retry with lock, as another thread might have already created the relevant matcher +* till we acquired the lock +*/ +if (refcount_inc_not_zero (&smfs_matcher->ref)) + goto out_unlock; + +// Find next available priority in sorted used list + prio =0 ; + prev = &matchers->used; +list_for_each_entry (m, &matchers->used, list) { + prev = &m->list; + +if (m->prio == prio) + prio = m->prio +1 ; +else +break ; } - ++prio; - ct_matchers->ipv6_tcp =mlx5_ct_fs_smfs_matcher_create (fs, tbl, false, true, prio); -if (IS_ERR (ct_matchers->ipv6_tcp)) { - err =PTR_ERR (ct_matchers->ipv6_tcp); -netdev_warn (netdev, -"%s, failed to create ipv6 tcp matcher, err: %d\n" , -INIT_ERR_PREFIX , err); - goto err_matcher_ipv6_tcp; - } + tbl = nat ? fs_smfs->ct_nat_tbl : fs_smfs->ct_tbl; + dr_matcher =mlx5_ct_fs_smfs_matcher_create (fs, tbl, ipv4, tcp, prio); +if (IS_ERR (dr_matcher)) { +netdev_warn (fs->netdev, +"ct_fs_smfs: failed to create matcher (nat %d, ipv4 %d, tcp %d), err: %ld\n" , + nat, ipv4, tcp,PTR_ERR (dr_matcher)); - ++prio; - ct_matchers->ipv6_udp =mlx5_ct_fs_smfs_matcher_create (fs, tbl, false, false, prio); -if (IS_ERR (ct_matchers->ipv6_udp)) { - err =PTR_ERR (ct_matchers->ipv6_udp); -netdev_warn (netdev, -"%s, failed to create ipv6 tcp matcher, err: %d\n" , -INIT_ERR_PREFIX , err); - goto err_matcher_ipv6_udp; + smfs_matcher =ERR_CAST (dr_matcher); + goto out_unlock; } -return 0 ; + smfs_matcher->dr_matcher = dr_matcher; + smfs_matcher->prio = prio; +list_add (&smfs_matcher->list, prev); +refcount_set (&smfs_matcher->ref,1 ); -err_matcher_ipv6_udp: -mlx5_smfs_matcher_destroy (ct_matchers->ipv6_tcp); -err_matcher_ipv6_tcp: -mlx5_smfs_matcher_destroy (ct_matchers->ipv4_udp); -err_matcher_ipv4_udp: -mlx5_smfs_matcher_destroy (ct_matchers->ipv4_tcp); -return 0 ; +out_unlock: +mutex_unlock (&fs_smfs->lock); +return smfs_matcher; }static void -mlx5_ct_fs_smfs_matchers_destroy (struct mlx5_ct_fs_smfs_matchers *ct_matchers) +mlx5_ct_fs_smfs_matcher_put (struct mlx5_ct_fs *fs,struct mlx5_ct_fs_smfs_matcher *smfs_matcher) { -mlx5_smfs_matcher_destroy (ct_matchers->ipv6_udp); -mlx5_smfs_matcher_destroy (ct_matchers->ipv6_tcp); -mlx5_smfs_matcher_destroy (ct_matchers->ipv4_udp); -mlx5_smfs_matcher_destroy (ct_matchers->ipv4_tcp); +struct mlx5_ct_fs_smfs *fs_smfs =mlx5_ct_fs_priv (fs); + +if (!refcount_dec_and_mutex_lock (&smfs_matcher->ref, &fs_smfs->lock)) +return ; + +mlx5_smfs_matcher_destroy (smfs_matcher->dr_matcher); +list_del (&smfs_matcher->list); +mutex_unlock (&fs_smfs->lock); } static int
@@ -170,7 +184,6 @@ mlx5_ct_fs_smfs_init(struct mlx5_ct_fs *fs, struct mlx5_flow_table *ct, {struct mlx5dr_table *ct_tbl, *ct_nat_tbl, *post_ct_tbl;struct mlx5_ct_fs_smfs *fs_smfs =mlx5_ct_fs_priv (fs); -int err; post_ct_tbl =mlx5_smfs_table_get_from_fs_ft (post_ct); ct_nat_tbl =mlx5_smfs_table_get_from_fs_ft (ct_nat);
@@ -184,28 +197,18 @@ mlx5_ct_fs_smfs_init(struct mlx5_ct_fs *fs, struct mlx5_flow_table *ct,ct_dbg ("using smfs steering" ); - err =mlx5_ct_fs_smfs_matchers_create (fs, ct_tbl, &fs_smfs->ct_matchers); -if (err) - goto err_init; - - err =mlx5_ct_fs_smfs_matchers_create (fs, ct_nat_tbl, &fs_smfs->ct_matchers_nat); -if (err) - goto err_matchers_nat; - fs_smfs->fwd_action =mlx5_smfs_action_create_dest_table (post_ct_tbl);if (!fs_smfs->fwd_action) { - err = -EINVAL ; - goto err_action_create; +return -EINVAL ; } -return 0 ; + fs_smfs->ct_tbl = ct_tbl; + fs_smfs->ct_nat_tbl = ct_nat_tbl; +mutex_init (&fs_smfs->lock); +INIT_LIST_HEAD (&fs_smfs->matchers.used); +INIT_LIST_HEAD (&fs_smfs->matchers_nat.used); -err_action_create: -mlx5_ct_fs_smfs_matchers_destroy (&fs_smfs->ct_matchers_nat); -err_matchers_nat: -mlx5_ct_fs_smfs_matchers_destroy (&fs_smfs->ct_matchers); -err_init: -return err; +return 0 ; } static void
@@ -214,8 +217,6 @@ mlx5_ct_fs_smfs_destroy(struct mlx5_ct_fs *fs)struct mlx5_ct_fs_smfs *fs_smfs =mlx5_ct_fs_priv (fs);mlx5_smfs_action_destroy (fs_smfs->fwd_action); -mlx5_ct_fs_smfs_matchers_destroy (&fs_smfs->ct_matchers_nat); -mlx5_ct_fs_smfs_matchers_destroy (&fs_smfs->ct_matchers); } static inline bool
@@ -285,10 +286,9 @@ mlx5_ct_fs_smfs_ct_rule_add(struct mlx5_ct_fs *fs, struct mlx5_flow_spec *spec, struct mlx5_flow_attr *attr, struct flow_rule *flow_rule) { struct mlx5_ct_fs_smfs *fs_smfs = mlx5_ct_fs_priv(fs); -struct mlx5_ct_fs_smfs_matchers *matchers; +struct mlx5_ct_fs_smfs_matcher *smfs_matcher;struct mlx5_ct_fs_smfs_rule *smfs_rule;struct mlx5dr_action *actions[5 ]; -struct mlx5dr_matcher *matcher;struct mlx5dr_rule *rule;int num_actions =0 , err;bool nat, tcp, ipv4;
@@ -315,22 +315,27 @@ mlx5_ct_fs_smfs_ct_rule_add(struct mlx5_ct_fs *fs, struct mlx5_flow_spec *spec, tcp =MLX5_GET (fte_match_param, spec->match_value, outer_headers.ip_protocol) ==IPPROTO_TCP ; - matchers = nat ? &fs_smfs->ct_matchers_nat : &fs_smfs->ct_matchers; - matcher = ipv4 ? (tcp ? matchers->ipv4_tcp : matchers->ipv4_udp) : - (tcp ? matchers->ipv6_tcp : matchers->ipv6_udp); + smfs_matcher =mlx5_ct_fs_smfs_matcher_get (fs, nat, ipv4, tcp); +if (IS_ERR (smfs_matcher)) { + err =PTR_ERR (smfs_matcher); + goto err_matcher; + } - rule =mlx5_smfs_rule_create (matcher, spec, num_actions, actions, + rule =mlx5_smfs_rule_create (smfs_matcher->dr_matcher, spec, num_actions, actions,MLX5_FLOW_CONTEXT_FLOW_SOURCE_ANY_VPORT );if (!rule) { err = -EINVAL ; - goto err_rule; + goto err_create; } smfs_rule->rule = rule; + smfs_rule->smfs_matcher = smfs_matcher;return &smfs_rule->fs_rule; -err_rule: +err_create: +mlx5_ct_fs_smfs_matcher_put (fs, smfs_matcher); +err_matcher:mlx5_smfs_action_destroy (smfs_rule->count_action); err_count:kfree (smfs_rule);
@@ -345,6 +350,7 @@ mlx5_ct_fs_smfs_ct_rule_del(struct mlx5_ct_fs *fs, struct mlx5_ct_fs_rule *fs_ru fs_rule);mlx5_smfs_rule_destroy (smfs_rule->rule); +mlx5_ct_fs_smfs_matcher_put (fs, smfs_rule->smfs_matcher);mlx5_smfs_action_destroy (smfs_rule->count_action);kfree (smfs_rule); }
Signature · 1 line
2.35.1
PATCH 11/15 net/mlx5: CT: Add software steering ct flow steering provider
In reply to Saeed MahameedFrom: Paul Blakey <[email protected]>
fs_core layer adds extra book keeping that is either unneeded for CT, or unused by the underlying software steering, such as allocating FTEs and FTE ids, saving the match key and mask, and autogroups management. On top of that, direct steering has a translation layer (fs_dr) from PRM commands to direct steering objects, for example, creating temporary dr_action objects. This has a performance impact when dealing with CT high insertion rate.
To use direct steering (smfs) directly for ct, add a tc ct fs smfs implementation. Instead of dmfs autogroups, smfs ct fs uses one of 4 predefined dr matchers in CT and CT-NAT tables, for each combination of tuple ethertype (ipv4/ipv6), and tuple ip_proto (udp/tcp) that is currently used by nf flow table flow offload.
At rule insertions, validate the flow rule fits one of the predfined matcher, and insert to it.
To fill the dr_actions of the rule efficiently, create the fwd to post_ct tbl dr_action at fs init, the count dr_action at counter creation, and re-use the already pre-allocated modify header dr_action.
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 6 +- .../ethernet/mellanox/mlx5/core/en/tc/ct_fs.h | 27 +- .../mellanox/mlx5/core/en/tc/ct_fs_dmfs.c | 17 +- .../mellanox/mlx5/core/en/tc/ct_fs_smfs.c | 366 ++++++++++++++++++ .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 24 +- .../ethernet/mellanox/mlx5/core/en/tc_ct.h | 2 + 6 files changed, 435 insertions(+), 7 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/ct_fs_smfs.c
drivers/net/ethernet/mellanox/mlx5/core/Makefile +5 -1
@@ -55,7 +55,11 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en/tc/act/act.o en/tc/act/drop.o en/tc/a en/tc/act/ct.o en/tc/act/sample.o en/tc/act/ptype.o \ en/tc/act/redirect_ingress.o -mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o en/tc/ct_fs_dmfs.o +ifneq ($(CONFIG_MLX5_TC_CT),) + mlx5_core-y += en/tc_ct.o en/tc/ct_fs_dmfs.o + mlx5_core-$(CONFIG_MLX5_SW_STEERING) += en/tc/ct_fs_smfs.o +endif + mlx5_core-$(CONFIG_MLX5_TC_SAMPLE) += en/tc/sample.o #
drivers/net/ethernet/mellanox/mlx5/core/en/tc/ct_fs.h +26 -1
@@ -7,18 +7,43 @@struct mlx5_ct_fs {const struct net_device *netdev;struct mlx5_core_dev *dev; + +/* private data */ +void *priv_data[]; };struct mlx5_ct_fs_rule { };struct mlx5_ct_fs_ops { +int (*init)(struct mlx5_ct_fs *fs,struct mlx5_flow_table *ct, +struct mlx5_flow_table *ct_nat,struct mlx5_flow_table *post_ct); +void (*destroy)(struct mlx5_ct_fs *fs); +struct mlx5_ct_fs_rule * (*ct_rule_add)(struct mlx5_ct_fs *fs,struct mlx5_flow_spec *spec, -struct mlx5_flow_attr *attr); +struct mlx5_flow_attr *attr, +struct flow_rule *flow_rule);void (*ct_rule_del)(struct mlx5_ct_fs *fs,struct mlx5_ct_fs_rule *fs_rule); + +size_t priv_size; }; +static inline void *mlx5_ct_fs_priv (struct mlx5_ct_fs *fs) +{ +return &fs->priv_data; +} +struct mlx5_ct_fs_ops *mlx5_ct_fs_dmfs_ops_get (void ); +#if IS_ENABLED (CONFIG_MLX5_SW_STEERING ) +struct mlx5_ct_fs_ops *mlx5_ct_fs_smfs_ops_get (void ); +#else +static inline struct mlx5_ct_fs_ops * +mlx5_ct_fs_smfs_ops_get (void ) +{ +return NULL ; +} +#endif /* IS_ENABLED(CONFIG_MLX5_SW_STEERING) */ +#endif /* __MLX5_EN_TC_CT_FS_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en/tc/ct_fs_dmfs.c +16 -1
@@ -14,9 +14,21 @@ struct mlx5_ct_fs_dmfs_rule {struct mlx5_flow_attr *attr; }; +static int +mlx5_ct_fs_dmfs_init (struct mlx5_ct_fs *fs,struct mlx5_flow_table *ct, +struct mlx5_flow_table *ct_nat,struct mlx5_flow_table *post_ct) +{ +return 0 ; +} + +static void +mlx5_ct_fs_dmfs_destroy (struct mlx5_ct_fs *fs) +{ +} +static struct mlx5_ct_fs_rule *mlx5_ct_fs_dmfs_ct_rule_add (struct mlx5_ct_fs *fs,struct mlx5_flow_spec *spec, -struct mlx5_flow_attr *attr) +struct mlx5_flow_attr *attr,struct flow_rule *flow_rule) {struct mlx5e_priv *priv =netdev_priv (fs->netdev);struct mlx5_ct_fs_dmfs_rule *dmfs_rule;
@@ -56,6 +68,9 @@ mlx5_ct_fs_dmfs_ct_rule_del(struct mlx5_ct_fs *fs, struct mlx5_ct_fs_rule *fs_rustatic struct mlx5_ct_fs_ops dmfs_ops = { .ct_rule_add = mlx5_ct_fs_dmfs_ct_rule_add, .ct_rule_del = mlx5_ct_fs_dmfs_ct_rule_del, + + .init = mlx5_ct_fs_dmfs_init, + .destroy = mlx5_ct_fs_dmfs_destroy, };struct mlx5_ct_fs_ops *mlx5_ct_fs_dmfs_ops_get (void )
drivers/net/ethernet/mellanox/mlx5/core/en/tc/ct_fs_smfs.c new file +366 -0
366 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +20 -4
@@ -26,9 +26,8 @@#include "en.h" #include "en_tc.h" #include "en_rep.h" +#include "fs_core.h" -#define MLX5_CT_ZONE_BITS (mlx5e_tc_attr_to_reg_mappings[ZONE_TO_REG].mlen) -#define MLX5_CT_ZONE_MASK GENMASK(MLX5_CT_ZONE_BITS - 1, 0)#define MLX5_CT_STATE_ESTABLISHED_BIT BIT(1)#define MLX5_CT_STATE_TRK_BIT BIT(2)#define MLX5_CT_STATE_NAT_BIT BIT(3)
@@ -819,7 +818,7 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,mlx5_tc_ct_set_tuple_match (ct_priv, spec, flow_rule);mlx5e_tc_match_to_reg_match (spec,ZONE_TO_REG , entry->tuple.zone,MLX5_CT_ZONE_MASK ); - zone_rule->rule = ct_priv->fs_ops->ct_rule_add (ct_priv->fs, spec, attr); + zone_rule->rule = ct_priv->fs_ops->ct_rule_add (ct_priv->fs, spec, attr, flow_rule);if (IS_ERR (zone_rule->rule)) { err =PTR_ERR (zone_rule->rule);ct_dbg ("Failed to add ct entry rule, nat: %d" , nat);
@@ -1966,9 +1965,17 @@ mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *priv,static int mlx5_tc_ct_fs_init (struct mlx5_tc_ct_priv *ct_priv) { +struct mlx5_flow_table *post_ct =mlx5e_tc_post_act_get_ft (ct_priv->post_act);struct mlx5_ct_fs_ops *fs_ops =mlx5_ct_fs_dmfs_ops_get (); +int err; + +if (ct_priv->ns_type ==MLX5_FLOW_NAMESPACE_FDB && + ct_priv->dev->priv.steering->mode ==MLX5_FLOW_STEERING_MODE_SMFS ) { +ct_dbg ("Using SMFS ct flow steering provider" ); + fs_ops =mlx5_ct_fs_smfs_ops_get (); + } - ct_priv->fs =kzalloc (sizeof (*ct_priv->fs),GFP_KERNEL ); + ct_priv->fs =kzalloc (sizeof (*ct_priv->fs) + fs_ops->priv_size,GFP_KERNEL );if (!ct_priv->fs)return -ENOMEM ;
@@ -1976,7 +1983,15 @@ mlx5_tc_ct_fs_init(struct mlx5_tc_ct_priv *ct_priv) ct_priv->fs->dev = ct_priv->dev; ct_priv->fs_ops = fs_ops; + err = ct_priv->fs_ops->init (ct_priv->fs, ct_priv->ct, ct_priv->ct_nat, post_ct); +if (err) + goto err_init; +return 0 ; + +err_init: +kfree (ct_priv->fs); +return err; } static int
@@ -2155,6 +2170,7 @@ mlx5_tc_ct_clean(struct mlx5_tc_ct_priv *ct_priv) chains = ct_priv->chains; + ct_priv->fs_ops->destroy (ct_priv->fs);kfree (ct_priv->fs);mlx5_chains_destroy_global_table (chains, ct_priv->ct_nat);
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h +2 -0
@@ -86,6 +86,8 @@ struct mlx5_ct_attr {#define REG_MAPPING_MLEN (reg) (mlx5e_tc_attr_to_reg_mappings[reg].mlen)#define REG_MAPPING_MOFFSET (reg) (mlx5e_tc_attr_to_reg_mappings[reg].moffset) +#define MLX5_CT_ZONE_BITS (mlx5e_tc_attr_to_reg_mappings[ZONE_TO_REG].mlen) +#define MLX5_CT_ZONE_MASK GENMASK(MLX5_CT_ZONE_BITS - 1, 0)#if IS_ENABLED (CONFIG_MLX5_TC_CT )
Signature · 1 line
2.35.1
PATCH 13/15 net/mlx5: Query the maximum MCIA register read size from firmware
In reply to Saeed MahameedFrom: Gal Pressman <[email protected]>
The MCIA register supports either 12 or 32 dwords, use the correct value by querying the capability from the MCAM register.
--- drivers/net/ethernet/mellanox/mlx5/core/port.c | 8 +++++++- include/linux/mlx5/mlx5_ifc.h | 4 +++- include/linux/mlx5/port.h | 1 - 3 files changed, 10 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/port.c +7 -1
@@ -365,6 +365,12 @@ static void mlx5_sfp_eeprom_params_set(u16 *i2c_addr, int *page_num, u16 *offset *offset -=MLX5_EEPROM_PAGE_LENGTH ; } +static int mlx5_mcia_max_bytes (struct mlx5_core_dev *dev) +{ +/* mcia supports either 12 dwords or 32 dwords */ +return (MLX5_CAP_MCAM_FEATURE (dev, mcia_32dwords) ?32 :12 ) *sizeof (u32); +} +static int mlx5_query_mcia (struct mlx5_core_dev *dev,struct mlx5_module_eeprom_query_params *params,u8 *data) {
@@ -374,7 +380,7 @@ static int mlx5_query_mcia(struct mlx5_core_dev *dev,void *ptr;u16 size; - size =min_t (int, params->size,MLX5_EEPROM_MAX_BYTES ); + size =min_t (int, params->size,mlx5_mcia_max_bytes (dev));MLX5_SET (mcia_reg, in, l,0 );MLX5_SET (mcia_reg, in, size, size);
include/linux/mlx5/mlx5_ifc.h +3 -1
@@ -9691,7 +9691,9 @@ struct mlx5_ifc_pcam_reg_bits { };struct mlx5_ifc_mcam_enhanced_features_bits { -u8 reserved_at_0[0x6a ]; +u8 reserved_at_0[0x5d ]; +u8 mcia_32dwords[0x1 ]; +u8 reserved_at_5e[0xc ];u8 reset_state[0x1 ];u8 ptpcyc2realtime_modify[0x1 ];u8 reserved_at_6c[0x2 ];
include/linux/mlx5/port.h +0 -1
@@ -56,7 +56,6 @@ enum mlx5_an_status { MLX5_AN_LINK_DOWN = 4, }; -#define MLX5_EEPROM_MAX_BYTES 32#define MLX5_EEPROM_IDENTIFIER_BYTE_MASK 0x000000ff#define MLX5_I2C_ADDR_LOW 0x50#define MLX5_I2C_ADDR_HIGH 0x51
Signature · 1 line
2.35.1
PATCH 14/15 net/mlx5: Parse module mapping using mlx5_ifc
In reply to Saeed MahameedFrom: Gal Pressman <[email protected]>
The assumption that the first byte in the module mapping dword is the module number shouldn't be hard-coded in the driver, but come from mlx5_ifc structs.
While at it, fix the incorrect width for the 'rx_lane' and 'tx_lane' fields.
--- drivers/net/ethernet/mellanox/mlx5/core/port.c | 6 +++--- include/linux/mlx5/mlx5_ifc.h | 8 ++++---- include/linux/mlx5/port.h | 1 - 3 files changed, 7 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/port.c +3 -3
@@ -275,7 +275,6 @@ static int mlx5_query_module_num(struct mlx5_core_dev *dev, int *module_num) {u32 in[MLX5_ST_SZ_DW (pmlp_reg)] = {0 };u32 out[MLX5_ST_SZ_DW (pmlp_reg)]; -int module_mapping;int err;MLX5_SET (pmlp_reg, in, local_port,1 );
@@ -284,8 +283,9 @@ static int mlx5_query_module_num(struct mlx5_core_dev *dev, int *module_num)if (err)return err; - module_mapping =MLX5_GET (pmlp_reg, out, lane0_module_mapping); - *module_num = module_mapping &MLX5_EEPROM_IDENTIFIER_BYTE_MASK ; + *module_num =MLX5_GET (lane_2_module_mapping, +MLX5_ADDR_OF (pmlp_reg, out, lane0_module_mapping), + module);return 0 ; }
include/linux/mlx5/mlx5_ifc.h +4 -4
@@ -9888,10 +9888,10 @@ struct mlx5_ifc_pcmr_reg_bits { };struct mlx5_ifc_lane_2_module_mapping_bits { -u8 reserved_at_0[0x6 ]; -u8 rx_lane[0x2 ]; -u8 reserved_at_8[0x6 ]; -u8 tx_lane[0x2 ]; +u8 reserved_at_0[0x4 ]; +u8 rx_lane[0x4 ]; +u8 reserved_at_8[0x4 ]; +u8 tx_lane[0x4 ];u8 reserved_at_10[0x8 ];u8 module[0x8 ]; };
include/linux/mlx5/port.h +0 -1
@@ -56,7 +56,6 @@ enum mlx5_an_status { MLX5_AN_LINK_DOWN = 4, }; -#define MLX5_EEPROM_IDENTIFIER_BYTE_MASK 0x000000ff#define MLX5_I2C_ADDR_LOW 0x50#define MLX5_I2C_ADDR_HIGH 0x51#define MLX5_EEPROM_PAGE_LENGTH 256
Signature · 1 line
2.35.1
PATCH 15/15 net/mlx5e: Remove overzealous validations in netlink EEPROM query
In reply to Saeed MahameedFrom: Gal Pressman <[email protected]>
Unlike the legacy EEPROM callbacks, when using the netlink EEPROM query (get_module_eeprom_by_page) the driver should not try to validate the query parameters, but just perform the read requested by the userspace.
Recent discussion in the mailing list:
https://lore.kernel.org/netdev/20220120093051.70845141@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net/
--- .../net/ethernet/mellanox/mlx5/core/port.c | 23 ------------------- 1 file changed, 23 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/port.c +0 -23
@@ -451,35 +451,12 @@ int mlx5_query_module_eeprom_by_page(struct mlx5_core_dev *dev,struct mlx5_module_eeprom_query_params *params, u8 *data) { - u8 module_id; int err; err =mlx5_query_module_num (dev, ¶ms->module_number);if (err)return err; - err =mlx5_query_module_id (dev, params->module_number, &module_id); -if (err) -return err; - -switch (module_id) { -case MLX5_MODULE_ID_SFP : -if (params->page >0 ) -return -EINVAL ; -break ; -case MLX5_MODULE_ID_QSFP : -case MLX5_MODULE_ID_QSFP28 : -case MLX5_MODULE_ID_QSFP_PLUS : -if (params->page >3 ) -return -EINVAL ; -break ; -case MLX5_MODULE_ID_DSFP : -break ; -default : -mlx5_core_err (dev,"Module ID not recognized: 0x%x\n" , module_id); -return -EINVAL ; - } -if (params->i2c_address !=MLX5_I2C_ADDR_HIGH && params->i2c_address !=MLX5_I2C_ADDR_LOW ) {mlx5_core_err (dev,"I2C address not recognized: 0x%x\n" , params->i2c_address);
Signature · 1 line
2.35.1
Re: [net-next 01/15] net/mlx4: Delete useless moduleparam include
In reply to Saeed MahameedThis 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 8 lines · On Thu, 10 Mar 2022 23:40:17 -0800 you wrote:
From: Leon Romanovsky <[email protected]>
Remove inclusion of not used
moduleparam.h.Signed-off-by Leon Romanovsky <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>[...]
Here is the summary with links:
- [net-next,01/15] net/mlx4: Delete useless moduleparam include
https://git.kernel.org/netdev/net-next/c/042637019ea3 - [net-next,02/15] net/mlx5: Delete useless module.h include https://git.kernel.org/netdev/net-next/c/71ab580705c1 - [net-next,03/15] net/mlx5: Node-aware allocation for the IRQ table https://git.kernel.org/netdev/net-next/c/196df17ac53a - [net-next,04/15] net/mlx5: Node-aware allocation for the EQ table https://git.kernel.org/netdev/net-next/c/e894246df513 - [net-next,05/15] net/mlx5: Node-aware allocation for the EQs https://git.kernel.org/netdev/net-next/c/7f880719b953 - [net-next,06/15] net/mlx5: Node-aware allocation for UAR https://git.kernel.org/netdev/net-next/c/b5e4c3079490 - [net-next,07/15] net/mlx5: Node-aware allocation for the doorbell pgdir https://git.kernel.org/netdev/net-next/c/a3540effb766 - [net-next,08/15] net/mlx5: CT: Introduce a platform for multiple flow steering providers https://git.kernel.org/netdev/net-next/c/769090005230 - [net-next,09/15] net/mlx5: DR, Add helper to get backing dr table from a mlx5 flow table https://git.kernel.org/netdev/net-next/c/34ea969d1645 - [net-next,10/15] net/mlx5: Add smfs lib to export direct steering API to CT https://git.kernel.org/netdev/net-next/c/c6fef514adaa - [net-next,11/15] net/mlx5: CT: Add software steering ct flow steering provider https://git.kernel.org/netdev/net-next/c/3ee61ebb0df1 - [net-next,12/15] net/mlx5: CT: Create smfs dr matchers dynamically https://git.kernel.org/netdev/net-next/c/fbf6836db42d - [net-next,13/15] net/mlx5: Query the maximum MCIA register read size from firmware https://git.kernel.org/netdev/net-next/c/271907ee2f29 - [net-next,14/15] net/mlx5: Parse module mapping using mlx5_ifc https://git.kernel.org/netdev/net-next/c/fcb610a86c53 - [net-next,15/15] net/mlx5e: Remove overzealous validations in netlink EEPROM query https://git.kernel.org/netdev/net-next/c/970adfb76095
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html