mlx5 devlink trap support
Subsystems (7)
Saeed Mahameed
maintainerHi Jakub, Dave,
This series adds devlink trap support 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 02c26940908fd31bb112e9742adedfb06eca19e1:
nfc: fix typo (2021-01-25 19:35:26 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2021-01-26
for you to fetch changes up to 243898b5d77445555e8de350269fd879f2283208:
net/mlx5e: Enable traps according to link state (2021-01-26 14:22:09 -0800)
----------------------------------------------------------------
mlx5-updates-2021-01-26
mlx5 devlink traps support:
Add support for devlink traps [1] reporting in mlx5,
mlx5 will also report/trap packets filtered due to dest mac steering miss
The first patch in the series defines the new DMAC trap type in devlink for this purpose.
Other patches in the series are mlx5 only and they gradually traps support. Supported traps:
DMAC: Drops due to destination MAC not configured in the MAC table
VLAN: Drops due to vlan not configured in the vlan table
Design note:
devlink instance is managed by the low level mlx5 core layer, mlx5 core will serve as an abstraction layer for trap reporting, since we might have multiple mlx5 interfaces who might want to report traps on the same device.
----------------------------------------------------------------
Aya Levin (14):
devlink: Add DMAC filter generic packet trap net/mlx5: Add support for devlink traps in mlx5 core driver net/mlx5: Register to devlink ingress VLAN filter trap net/mlx5: Register to devlink DMAC filter trap net/mlx5: Rename events notifier header
net/mlx5: Notify on trap action by blocking event net/mlx5e: Optimize promiscuous mode
net/mlx5e: Add flow steering VLAN trap rule net/mlx5e: Add flow steering DMAC trap rule net/mlx5e: Expose RX dma info helpers
net/mlx5e: Add trap entity to ETH driver net/mlx5e: Add listener to trap event
net/mlx5e: Add listener to DMAC filter trap event net/mlx5e: Enable traps according to link state
Documentation/networking/devlink/devlink-trap.rst | 5 + drivers/net/ethernet/mellanox/mlx5/core/Makefile | 2 +- drivers/net/ethernet/mellanox/mlx5/core/devlink.c | 188 +++++++++ drivers/net/ethernet/mellanox/mlx5/core/devlink.h | 18 + drivers/net/ethernet/mellanox/mlx5/core/en.h | 10 + drivers/net/ethernet/mellanox/mlx5/core/en/fs.h | 16 +- drivers/net/ethernet/mellanox/mlx5/core/en/trap.c | 457 ++++++++++++++++++++++ drivers/net/ethernet/mellanox/mlx5/core/en/trap.h | 37 ++ drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 212 ++++++++-- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 52 ++- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 46 +++ drivers/net/ethernet/mellanox/mlx5/core/events.c | 47 ++- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 4 +- drivers/net/ethernet/mellanox/mlx5/core/main.c | 2 + include/linux/mlx5/device.h | 9 + include/linux/mlx5/driver.h | 16 + include/net/devlink.h | 3 + net/core/devlink.c | 1 + 18 files changed, 1076 insertions(+), 49 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/trap.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/trap.h
Saeed Mahameed
maintainerPATCH 1/14 devlink: Add DMAC filter generic packet trap
From: Aya Levin <[email protected]>
Add packet trap that can report packets that were dropped due to destination MAC filtering.
--- Documentation/networking/devlink/devlink-trap.rst | 5 +++++ include/net/devlink.h | 3 +++ net/core/devlink.c | 1 + 3 files changed, 9 insertions(+)
Documentation/networking/devlink/devlink-trap.rst +5 -0
@@ -480,6 +480,11 @@ be added to the following table: - ``drop`` - Traps packets that the device decided to drop in case they hit a blackhole nexthop + * - ``dmac_filter`` + - ``drop`` + - Traps incoming packets that the device decided to drop in case + the destination MAC is not configured in the MAC table + Driver-specific Packet Traps ============================
include/net/devlink.h +3 -0
@@ -838,6 +838,7 @@ enum devlink_trap_generic_id {DEVLINK_TRAP_GENERIC_ID_GTP_PARSING ,DEVLINK_TRAP_GENERIC_ID_ESP_PARSING ,DEVLINK_TRAP_GENERIC_ID_BLACKHOLE_NEXTHOP , +DEVLINK_TRAP_GENERIC_ID_DMAC_FILTER ,/* Add new generic trap IDs above */ __DEVLINK_TRAP_GENERIC_ID_MAX,
@@ -1063,6 +1064,8 @@ enum devlink_trap_group_generic_id { "esp_parsing"#define DEVLINK_TRAP_GENERIC_NAME_BLACKHOLE_NEXTHOP \ "blackhole_nexthop" +#define DEVLINK_TRAP_GENERIC_NAME_DMAC_FILTER \ + "dest_mac_filter"#define DEVLINK_TRAP_GROUP_GENERIC_NAME_L2_DROPS \ "l2_drops"
net/core/devlink.c +1 -0
@@ -9512,6 +9512,7 @@ static const struct devlink_trap devlink_trap_generic[] = {DEVLINK_TRAP (GTP_PARSING ,DROP ),DEVLINK_TRAP (ESP_PARSING ,DROP ),DEVLINK_TRAP (BLACKHOLE_NEXTHOP ,DROP ), + DEVLINK_TRAP(DMAC_FILTER, DROP), };#define DEVLINK_TRAP_GROUP (_id) \
Signature · 1 line
2.29.2
Jakub Kicinski
maintainerRe: [net-next 01/14] devlink: Add DMAC filter generic packet trap
Quoted 22 lines · On Tue, 26 Jan 2021 15:24:06 -0800 Saeed Mahameed wrote:
From: Aya Levin <[email protected]>
Add packet trap that can report packets that were dropped due to destination MAC filtering.
Signed-off-by Aya Levin <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Reviewed-by Moshe Shemesh <[email protected]>Reviewed-by Tariq Toukan <[email protected]>Signed-off-by Tariq Toukan <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>--- Documentation/networking/devlink/devlink-trap.rst | 5 +++++ include/net/devlink.h | 3 +++ net/core/devlink.c | 1 + 3 files changed, 9 insertions(+)Documentation/networking/devlink/devlink-trap.rst +0
-0
Documentation/networking/devlink/devlink-trap.rst be added to the following table: · line 485
Quoted 6 lines
Documentation/networking/devlink/devlink-trap.rst +3
-0@@ -480,6 +480,11 @@ be added to the following table: - ``drop`` - Traps packets that the device decided to drop in case they hit a blackhole nexthop + * - ``dmac_filter`` + - ``drop`` + - Traps incoming packets that the device decided to drop in case
s/in case/because/
Documentation/networking/devlink/devlink-trap.rst be added to the following table: · line 486
Quoted 1 line
Documentation/networking/devlink/devlink-trap.rst +1
-0+ the destination MAC is not configured in the MAC table
... and the interface is not in promiscuous mode
Documentation/networking/devlink/devlink-trap.rst be added to the following table: · line 487
Quoted 1 line
Documentation/networking/devlink/devlink-trap.rst +1
-0+
Double new line
Documentation/networking/devlink/devlink-trap.rst be added to the following table: · line 490
Quoted 2 lines
Documentation/networking/devlink/devlink-trap.rst +0
-0Driver-specific Packet Traps ============================
Fix that up and applied from the list.
Re: [net-next 01/14] devlink: Add DMAC filter generic packet trap
Quoted 35 lines · Jakub Kicinski
Quoted 23 lines · On Tue, 26 Jan 2021 15:24:06 -0800 Saeed Mahameed wrote:
From: Aya Levin <[email protected]>
Add packet trap that can report packets that were dropped due to destination MAC filtering.
Signed-off-by Aya Levin <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Reviewed-by Moshe Shemesh <[email protected]>Reviewed-by Tariq Toukan <[email protected]>Signed-off-by Tariq Toukan <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>---
Documentation/networking/devlink/devlink-trap.rst | 5 +++++ include/net/devlink.h | 3 +++ net/core/devlink.c | 1 +3 files changed, 9 insertions(+)Documentation/networking/devlink/devlink-trap.rst +0
-0@@ -480,6 +480,11 @@ be added to the following table:Quoted 8 lines
- ``drop``
- Traps packets that the device decided to drop in case they hit a
blackhole nexthop
+ * - ``dmac_filter``
+ - ``drop``
+ - Traps incoming packets that the device decided to drop in cases/in case/because/
Quoted 4 lines
Quoted 1 line
+ the destination MAC is not configured in the MAC table
... and the interface is not in promiscuous mode
Makes sense !
Quoted 8 lines
Quoted 1 line
+
Double new line
Quoted 2 lines
Driver-specific Packet Traps
============================Fix that up and applied from the list.
Thanks,
I can stop sending pull requests and siwtch to normal patchsets if this will be more convenient to you/
to me is just converting the cover letter :)..
Jakub Kicinski
maintainerRe: [net-next 01/14] devlink: Add DMAC filter generic packet trap
Quoted 30 lines · On Thu, 28 Jan 2021 00:19:48 -0800 Saeed Mahameed wrote:
Quoted 13 lines · Jakub Kicinski
Quoted 11 lines · On Tue, 26 Jan 2021 15:24:06 -0800 Saeed Mahameed wrote:
From: Aya Levin <[email protected]>
Add packet trap that can report packets that were dropped due to destination MAC filtering.
Signed-off-by Aya Levin <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Reviewed-by Moshe Shemesh <[email protected]>Reviewed-by Tariq Toukan <[email protected]>Signed-off-by Tariq Toukan <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>Quoted 6 lines
s/in case/because/
Quoted 1 line
+ the destination MAC is not configured in the MAC table
... and the interface is not in promiscuous mode
Makes sense !
Quoted 7 lines
Quoted 1 line
+
Double new line
Quoted 2 lines
Driver-specific Packet Traps
============================
Quoted 7 lines
Quoted 1 line
Fix that up and applied from the list.
Thanks,
I can stop sending pull requests and siwtch to normal patchsets if this will be more convenient to you/to me is just converting the cover letter :)..
No preference on my side, as long as the patches are on the ML it's just the matter of remembering which parameters to pass to my scripts :)
Saeed Mahameed
maintainerPATCH 2/14 net/mlx5: Add support for devlink traps in mlx5 core driver
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Add devlink traps infra-structure to mlx5 core driver. Add traps list to mlx5_priv and corresponding API:
- mlx5_devlink_trap_report() to wrap trap reports to devlink
- mlx5_devlink_trap_get_num_active() to decide whether to open/close trap resources.
--- .../net/ethernet/mellanox/mlx5/core/devlink.c | 84 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/devlink.h | 16 ++++ .../net/ethernet/mellanox/mlx5/core/main.c | 2 + include/linux/mlx5/driver.h | 1 + 4 files changed, 103 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +84 -0
@@ -168,6 +168,56 @@ static int mlx5_devlink_reload_up(struct devlink *devlink, enum devlink_reload_areturn 0 ; } +static struct mlx5_devlink_trap *mlx5_find_trap_by_id (struct mlx5_core_dev *dev,int trap_id) +{ +struct mlx5_devlink_trap *dl_trap; + +list_for_each_entry (dl_trap, &dev->priv.traps, list) +if (dl_trap->trap.id == trap_id) +return dl_trap; + +return NULL ; +} + +static int mlx5_devlink_trap_init (struct devlink *devlink,const struct devlink_trap *trap, +void *trap_ctx) +{ +struct mlx5_core_dev *dev =devlink_priv (devlink); +struct mlx5_devlink_trap *dl_trap; + + dl_trap =kzalloc (sizeof (*dl_trap),GFP_KERNEL ); +if (!dl_trap) +return -ENOMEM ; + + dl_trap->trap.id = trap->id; + dl_trap->trap.action =DEVLINK_TRAP_ACTION_DROP ; + dl_trap->item = trap_ctx; + +if (mlx5_find_trap_by_id (dev, trap->id)) { +kfree (dl_trap); +mlx5_core_err (dev,"Devlink trap: Trap 0x%x already found" , trap->id); +return -EEXIST ; + } + +list_add_tail (&dl_trap->list, &dev->priv.traps); +return 0 ; +} + +static void mlx5_devlink_trap_fini (struct devlink *devlink,const struct devlink_trap *trap, +void *trap_ctx) +{ +struct mlx5_core_dev *dev =devlink_priv (devlink); +struct mlx5_devlink_trap *dl_trap; + + dl_trap =mlx5_find_trap_by_id (dev, trap->id); +if (!dl_trap) { +mlx5_core_err (dev,"Devlink trap: Missing trap id 0x%x" , trap->id); +return ; + } +list_del (&dl_trap->list); +kfree (dl_trap); +} +static const struct devlink_ops mlx5_devlink_ops = { #ifdef CONFIG_MLX5_ESWITCH .eswitch_mode_set = mlx5_devlink_eswitch_mode_set,
@@ -186,8 +236,42 @@ static const struct devlink_ops mlx5_devlink_ops = { .reload_limits = BIT(DEVLINK_RELOAD_LIMIT_NO_RESET), .reload_down = mlx5_devlink_reload_down, .reload_up = mlx5_devlink_reload_up, + .trap_init = mlx5_devlink_trap_init, + .trap_fini = mlx5_devlink_trap_fini, }; +void mlx5_devlink_trap_report (struct mlx5_core_dev *dev,int trap_id,struct sk_buff *skb, +struct devlink_port *dl_port) +{ +struct devlink *devlink =priv_to_devlink (dev); +struct mlx5_devlink_trap *dl_trap; + + dl_trap =mlx5_find_trap_by_id (dev, trap_id); +if (!dl_trap) { +mlx5_core_err (dev,"Devlink trap: Report on invalid trap id 0x%x" , trap_id); +return ; + } + +if (dl_trap->trap.action !=DEVLINK_TRAP_ACTION_TRAP ) { +mlx5_core_dbg (dev,"Devlink trap: Trap id %d has action %d" , trap_id, + dl_trap->trap.action); +return ; + } +devlink_trap_report (devlink, skb, dl_trap->item, dl_port,NULL ); +} + +int mlx5_devlink_trap_get_num_active (struct mlx5_core_dev *dev) +{ +struct mlx5_devlink_trap *dl_trap; +int count =0 ; + +list_for_each_entry (dl_trap, &dev->priv.traps, list) +if (dl_trap->trap.action ==DEVLINK_TRAP_ACTION_TRAP ) + count++; + +return count; +} +struct devlink *mlx5_devlink_alloc (void ) {return devlink_alloc (&mlx5_devlink_ops,sizeof (struct mlx5_core_dev ));
drivers/net/ethernet/mellanox/mlx5/core/devlink.h +16 -0
@@ -12,6 +12,22 @@ enum mlx5_devlink_param_id { MLX5_DEVLINK_PARAM_ID_ESW_LARGE_GROUP_NUM, }; +struct mlx5_trap_ctx { +int id; +int action; +}; + +struct mlx5_devlink_trap { +struct mlx5_trap_ctx trap; +void *item; +struct list_head list; +}; + +struct mlx5_core_dev ; +void mlx5_devlink_trap_report (struct mlx5_core_dev *dev,int trap_id,struct sk_buff *skb, +struct devlink_port *dl_port); +int mlx5_devlink_trap_get_num_active (struct mlx5_core_dev *dev); +struct devlink *mlx5_devlink_alloc (void );void mlx5_devlink_free (struct devlink *devlink);int mlx5_devlink_register (struct devlink *devlink,struct device *dev);
drivers/net/ethernet/mellanox/mlx5/core/main.c +2 -0
@@ -1305,6 +1305,8 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx) priv->dbg_root =debugfs_create_dir (dev_name (dev->device), mlx5_debugfs_root); +INIT_LIST_HEAD (&priv->traps); + err =mlx5_health_init (dev);if (err) goto err_health_init;
include/linux/mlx5/driver.h +1 -0
@@ -564,6 +564,7 @@ struct mlx5_priv {int host_pf_pages;struct mlx5_core_health health; +struct list_head traps;/* start: qp staff */ struct dentry *qp_debugfs;
Signature · 1 line
2.29.2
Saeed Mahameed
maintainerPATCH 3/14 net/mlx5: Register to devlink ingress VLAN filter trap
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Add traps registration to mlx5_core devlink register/unregister flow. This patch registers INGRESS_VLAN_FILTER trap.
--- .../net/ethernet/mellanox/mlx5/core/devlink.c | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +51 -0
@@ -442,6 +442,48 @@ static void mlx5_devlink_set_params_init_values(struct devlink *devlink)#endif } +#define MLX5_TRAP_DROP (_id, _group_id) \ + DEVLINK_TRAP_GENERIC(DROP, DROP, _id, \ + DEVLINK_TRAP_GROUP_GENERIC_ID_##_group_id, \ + DEVLINK_TRAP_METADATA_TYPE_F_IN_PORT) + +static const struct devlink_trap mlx5_traps_arr[] = { +MLX5_TRAP_DROP (INGRESS_VLAN_FILTER ,L2_DROPS ), +}; + +static const struct devlink_trap_group mlx5_trap_groups_arr[] = { +DEVLINK_TRAP_GROUP_GENERIC (L2_DROPS ,0 ), +}; + +static int mlx5_devlink_traps_register (struct devlink *devlink) +{ +struct mlx5_core_dev *core_dev =devlink_priv (devlink); +int err; + + err =devlink_trap_groups_register (devlink, mlx5_trap_groups_arr, +ARRAY_SIZE (mlx5_trap_groups_arr)); +if (err) +return err; + + err =devlink_traps_register (devlink, mlx5_traps_arr,ARRAY_SIZE (mlx5_traps_arr), + &core_dev->priv); +if (err) + goto err_trap_group; +return 0 ; + +err_trap_group: +devlink_trap_groups_unregister (devlink, mlx5_trap_groups_arr, +ARRAY_SIZE (mlx5_trap_groups_arr)); +return err; +} + +static void mlx5_devlink_traps_unregister (struct devlink *devlink) +{ +devlink_traps_unregister (devlink, mlx5_traps_arr,ARRAY_SIZE (mlx5_traps_arr)); +devlink_trap_groups_unregister (devlink, mlx5_trap_groups_arr, +ARRAY_SIZE (mlx5_trap_groups_arr)); +} +int mlx5_devlink_register (struct devlink *devlink,struct device *dev) {int err;
@@ -456,8 +498,16 @@ int mlx5_devlink_register(struct devlink *devlink, struct device *dev) goto params_reg_err;mlx5_devlink_set_params_init_values (devlink);devlink_params_publish (devlink); + + err =mlx5_devlink_traps_register (devlink); +if (err) + goto traps_reg_err; +return 0 ; +traps_reg_err: +devlink_params_unregister (devlink, mlx5_devlink_params, +ARRAY_SIZE (mlx5_devlink_params)); params_reg_err:devlink_unregister (devlink);return err;
@@ -465,6 +515,7 @@ int mlx5_devlink_register(struct devlink *devlink, struct device *dev)void mlx5_devlink_unregister (struct devlink *devlink) { +mlx5_devlink_traps_unregister (devlink);devlink_params_unregister (devlink, mlx5_devlink_params,ARRAY_SIZE (mlx5_devlink_params));devlink_unregister (devlink);
Signature · 1 line
2.29.2
Saeed Mahameed
maintainerPATCH 4/14 net/mlx5: Register to devlink DMAC filter trap
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Core driver is registered to the devlink traps service, which enables the admin to redeem packets that were destined to be dropped due to a particular reason. Register to DMAC filter, allow visibility of packets that were filtered out by the MAC table.
--- drivers/net/ethernet/mellanox/mlx5/core/devlink.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +1 -0
@@ -449,6 +449,7 @@ static void mlx5_devlink_set_params_init_values(struct devlink *devlink)static const struct devlink_trap mlx5_traps_arr[] = {MLX5_TRAP_DROP (INGRESS_VLAN_FILTER ,L2_DROPS ), +MLX5_TRAP_DROP (DMAC_FILTER ,L2_DROPS ), };static const struct devlink_trap_group mlx5_trap_groups_arr[] = {
Signature · 1 line
2.29.2
Saeed Mahameed
maintainerPATCH 5/14 net/mlx5: Rename events notifier header
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Change the naming of events notifier head to clarify that it handles only firmware events. Coming patches in the set, add event notifier for software events.
--- .../net/ethernet/mellanox/mlx5/core/events.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/events.c +11 -8
@@ -23,7 +23,7 @@ static int temp_warn(struct notifier_block *, unsigned long, void *);static int port_module (struct notifier_block *,unsigned long ,void *);static int pcie_core (struct notifier_block *,unsigned long ,void *); -/* handler which forwards the event to events->nh, driver notifiers */ +/* handler which forwards the event to events->fw_nh, driver notifiers */ static int forward_event (struct notifier_block *,unsigned long ,void *);static struct mlx5_nb events_nbs_ref[] = {
@@ -55,8 +55,8 @@ struct mlx5_events {struct mlx5_core_dev *dev;struct workqueue_struct *wq;struct mlx5_event_nb notifiers[ARRAY_SIZE (events_nbs_ref)]; -/* driver notifier chain */ -struct atomic_notifier_head nh; +/* driver notifier chain for fw events */ +struct atomic_notifier_head fw_nh;/* port module events stats */ struct mlx5_pme_stats pme_stats;/*pcie_core*/
@@ -331,7 +331,7 @@ static int forward_event(struct notifier_block *nb, unsigned long event, void *dmlx5_core_dbg (events->dev,"Async eqe type %s, subtype (%d) forward to interfaces\n" ,eqe_type_str (eqe->type), eqe->sub_type); -atomic_notifier_call_chain (&events->nh, event, data); +atomic_notifier_call_chain (&events->fw_nh, event, data);return NOTIFY_OK ; }
@@ -342,7 +342,7 @@ int mlx5_events_init(struct mlx5_core_dev *dev)if (!events)return -ENOMEM ; -ATOMIC_INIT_NOTIFIER_HEAD (&events->nh); +ATOMIC_INIT_NOTIFIER_HEAD (&events->fw_nh); events->dev = dev; dev->priv.events = events; events->wq =create_singlethread_workqueue ("mlx5_events" );
@@ -383,11 +383,14 @@ void mlx5_events_stop(struct mlx5_core_dev *dev)flush_workqueue (events->wq); } +/* This API is used only for processing and forwarding firmware +* events to mlx5 consumer. +*/ int mlx5_notifier_register (struct mlx5_core_dev *dev,struct notifier_block *nb) {struct mlx5_events *events = dev->priv.events; -return atomic_notifier_chain_register (&events->nh, nb); +return atomic_notifier_chain_register (&events->fw_nh, nb); }EXPORT_SYMBOL (mlx5_notifier_register);
@@ -395,11 +398,11 @@ int mlx5_notifier_unregister(struct mlx5_core_dev *dev, struct notifier_block *n {struct mlx5_events *events = dev->priv.events; -return atomic_notifier_chain_unregister (&events->nh, nb); +return atomic_notifier_chain_unregister (&events->fw_nh, nb); }EXPORT_SYMBOL (mlx5_notifier_unregister);int mlx5_notifier_call_chain (struct mlx5_events *events,unsigned int event,void *data) { -return atomic_notifier_call_chain (&events->nh, event, data); +return atomic_notifier_call_chain (&events->fw_nh, event, data); }
Signature · 1 line
2.29.2
Saeed Mahameed
maintainerPATCH 6/14 net/mlx5: Notify on trap action by blocking event
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
In order to allow mlx5 core driver to trigger synchronous operations to its consumers, add a blocking events handler. Add wrappers to blocking_notifier_[call_chain/chain_register/chain_unregister]. Add trap callback for action set and notify about this change. Following patches in the set add a listener for this event.
--- .../net/ethernet/mellanox/mlx5/core/devlink.c | 36 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/events.c | 28 +++++++++++++++ include/linux/mlx5/device.h | 4 +++ include/linux/mlx5/driver.h | 15 ++++++++ 4 files changed, 83 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +36 -0
@@ -218,6 +218,41 @@ static void mlx5_devlink_trap_fini(struct devlink *devlink, const struct devlinkkfree (dl_trap); } +static int mlx5_devlink_trap_action_set (struct devlink *devlink, +const struct devlink_trap *trap, +enum devlink_trap_action action, +struct netlink_ext_ack *extack) +{ +struct mlx5_core_dev *dev =devlink_priv (devlink); +enum devlink_trap_action action_orig; +struct mlx5_devlink_trap *dl_trap; +int err =0 ; + + dl_trap =mlx5_find_trap_by_id (dev, trap->id); +if (!dl_trap) { +mlx5_core_err (dev,"Devlink trap: Set action on invalid trap id 0x%x" , trap->id); + err = -EINVAL ; + goto out; + } + +if (action !=DEVLINK_TRAP_ACTION_DROP && action !=DEVLINK_TRAP_ACTION_TRAP ) { + err = -EOPNOTSUPP ; + goto out; + } + +if (action == dl_trap->trap.action) + goto out; + + action_orig = dl_trap->trap.action; + dl_trap->trap.action = action; + err =mlx5_blocking_notifier_call_chain (dev,MLX5_DRIVER_EVENT_TYPE_TRAP , + &dl_trap->trap); +if (err) + dl_trap->trap.action = action_orig; +out: +return err; +} +static const struct devlink_ops mlx5_devlink_ops = { #ifdef CONFIG_MLX5_ESWITCH .eswitch_mode_set = mlx5_devlink_eswitch_mode_set,
@@ -238,6 +273,7 @@ static const struct devlink_ops mlx5_devlink_ops = { .reload_up = mlx5_devlink_reload_up, .trap_init = mlx5_devlink_trap_init, .trap_fini = mlx5_devlink_trap_fini, + .trap_action_set = mlx5_devlink_trap_action_set, }; void mlx5_devlink_trap_report(struct mlx5_core_dev *dev, int trap_id, struct sk_buff *skb,
drivers/net/ethernet/mellanox/mlx5/core/events.c +28 -0
@@ -61,6 +61,8 @@ struct mlx5_events {struct mlx5_pme_stats pme_stats;/*pcie_core*/ struct work_struct pcie_core_work; +/* driver notifier chain for sw events */ +struct blocking_notifier_head sw_nh; };static const char *eqe_type_str (u8 type)
@@ -351,6 +353,7 @@ int mlx5_events_init(struct mlx5_core_dev *dev)return -ENOMEM ; }INIT_WORK (&events->pcie_core_work, mlx5_pcie_event); +BLOCKING_INIT_NOTIFIER_HEAD (&events->sw_nh);return 0 ; }
@@ -406,3 +409,28 @@ int mlx5_notifier_call_chain(struct mlx5_events *events, unsigned int event, voi {return atomic_notifier_call_chain (&events->fw_nh, event, data); } + +/* This API is used only for processing and forwarding driver-specific +* events to mlx5 consumers. +*/ +int mlx5_blocking_notifier_register (struct mlx5_core_dev *dev,struct notifier_block *nb) +{ +struct mlx5_events *events = dev->priv.events; + +return blocking_notifier_chain_register (&events->sw_nh, nb); +} + +int mlx5_blocking_notifier_unregister (struct mlx5_core_dev *dev,struct notifier_block *nb) +{ +struct mlx5_events *events = dev->priv.events; + +return blocking_notifier_chain_unregister (&events->sw_nh, nb); +} + +int mlx5_blocking_notifier_call_chain (struct mlx5_core_dev *dev,unsigned int event, +void *data) +{ +struct mlx5_events *events = dev->priv.events; + +return blocking_notifier_call_chain (&events->sw_nh, event, data); +}
include/linux/mlx5/device.h +4 -0
@@ -359,6 +359,10 @@ enum mlx5_event { MLX5_EVENT_TYPE_MAX = 0x100, }; +enum mlx5_driver_event { +MLX5_DRIVER_EVENT_TYPE_TRAP =0 , +}; +enum {MLX5_TRACER_SUBTYPE_OWNERSHIP_CHANGE =0x0 ,MLX5_TRACER_SUBTYPE_TRACES_AVAILABLE =0x1 ,
include/linux/mlx5/driver.h +15 -0
@@ -1073,11 +1073,26 @@ enum {MAX_MR_CACHE_ENTRIES }; +/* Async-atomic event notifier used by mlx5 core to forward FW +* evetns recived from event queue to mlx5 consumers. +* Optimise event queue dipatching. +*/ int mlx5_notifier_register (struct mlx5_core_dev *dev,struct notifier_block *nb);int mlx5_notifier_unregister (struct mlx5_core_dev *dev,struct notifier_block *nb); + +/* Async-atomic event notifier used for forwarding +* evetns from the event queue into the to mlx5 events dispatcher, +* eswitch, clock and others. +*/ int mlx5_eq_notifier_register (struct mlx5_core_dev *dev,struct mlx5_nb *nb);int mlx5_eq_notifier_unregister (struct mlx5_core_dev *dev,struct mlx5_nb *nb); +/* Blocking event notifier used to forward SW events, used for slow path */ +int mlx5_blocking_notifier_register (struct mlx5_core_dev *dev,struct notifier_block *nb); +int mlx5_blocking_notifier_unregister (struct mlx5_core_dev *dev,struct notifier_block *nb); +int mlx5_blocking_notifier_call_chain (struct mlx5_core_dev *dev,unsigned int event, +void *data); +int mlx5_core_query_vendor_id (struct mlx5_core_dev *mdev,u32 *vendor_id);int mlx5_cmd_create_vport_lag (struct mlx5_core_dev *dev);
Signature · 1 line
2.29.2
Saeed Mahameed
maintainerPATCH 7/14 net/mlx5e: Optimize promiscuous mode
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Change steering flow to optimize traffic in promiscuous mode. On demand, add a high priority table containing a catch-all rule. All incoming packets are caught by this rule and steered directly to the TTC table. Prior to this change, packets in promiscuous mode may suffer from up to 4 steering hops before reaching TTC table.
In addition, this patch will allow us adding a catch-all rule at the end of MAC table to serve MAC trap, with no impact on promiscuous mode performance.
--- .../net/ethernet/mellanox/mlx5/core/en/fs.h | 10 +- .../net/ethernet/mellanox/mlx5/core/en_fs.c | 120 +++++++++++++----- .../net/ethernet/mellanox/mlx5/core/fs_core.c | 4 +- 3 files changed, 100 insertions(+), 34 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/fs.h +8 -2
@@ -44,6 +44,11 @@ struct mlx5e_l2_rule {#define MLX5E_L2_ADDR_HASH_SIZE BIT(BITS_PER_BYTE) +struct mlx5e_promisc_table { +struct mlx5e_flow_table ft; +struct mlx5_flow_handle *rule; +}; +struct mlx5e_vlan_table {struct mlx5e_flow_table ft; DECLARE_BITMAP(active_cvlans, VLAN_N_VID);
@@ -62,7 +67,6 @@ struct mlx5e_l2_table {struct hlist_head netdev_mc[MLX5E_L2_ADDR_HASH_SIZE ];struct mlx5e_l2_rule broadcast;struct mlx5e_l2_rule allmulti; -struct mlx5e_l2_rule promisc;bool broadcast_enabled;bool allmulti_enabled;bool promisc_enabled;
@@ -126,7 +130,8 @@ struct mlx5e_ttc_table {/* NIC prio FTS */ enum { -MLX5E_VLAN_FT_LEVEL =0 , +MLX5E_PROMISC_FT_LEVEL , +MLX5E_VLAN_FT_LEVEL ,MLX5E_L2_FT_LEVEL ,MLX5E_TTC_FT_LEVEL ,MLX5E_INNER_TTC_FT_LEVEL ,
@@ -241,6 +246,7 @@ struct mlx5e_flow_steering {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 mlx5e_ttc_table ttc;
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +90 -30
177 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +2 -2
@@ -105,8 +105,8 @@#define ETHTOOL_PRIO_NUM_LEVELS 1#define ETHTOOL_NUM_PRIOS 11#define ETHTOOL_MIN_LEVEL (KERNEL_MIN_LEVEL + ETHTOOL_NUM_PRIOS) -/* Vlan, mac, ttc, inner ttc, {aRFS/accel and esp/esp_err} */ -#define KERNEL_NIC_PRIO_NUM_LEVELS 6 +/* Promiscuous, Vlan, mac, ttc, inner ttc, {aRFS/accel and esp/esp_err} */ +#define KERNEL_NIC_PRIO_NUM_LEVELS 7#define KERNEL_NIC_NUM_PRIOS 1/* One more level for tc */ #define KERNEL_MIN_LEVEL (KERNEL_NIC_PRIO_NUM_LEVELS + 1)
Signature · 1 line
2.29.2
Saeed Mahameed
maintainerPATCH 8/14 net/mlx5e: Add flow steering VLAN trap rule
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Add flow group to the VLAN table to hold the catch-all VLAN rule. Add API which adds/removes VLAN trap rule. This rule catches packets that were destined to be dropped due to no-match with previous VLAN rules. The trap rule steer these packets to the trap tir related to the trap-RQ.
--- .../net/ethernet/mellanox/mlx5/core/en/fs.h | 3 + .../net/ethernet/mellanox/mlx5/core/en_fs.c | 64 ++++++++++++++++++- 2 files changed, 65 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/fs.h +3 -0
@@ -58,6 +58,7 @@ struct mlx5e_vlan_table {struct mlx5_flow_handle *untagged_rule;struct mlx5_flow_handle *any_cvlan_rule;struct mlx5_flow_handle *any_svlan_rule; +struct mlx5_flow_handle *trap_rule;bool cvlan_filter_disabled; };
@@ -294,6 +295,8 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv);void mlx5e_destroy_flow_steering (struct mlx5e_priv *priv);u8 mlx5e_get_proto_by_tunnel_type (enum mlx5e_tunnel_types tt); +int mlx5e_add_vlan_trap (struct mlx5e_priv *priv,int trap_id,int tir_num); +void mlx5e_remove_vlan_trap (struct mlx5e_priv *priv);#endif /* __MLX5E_FLOW_STEER_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +62 -2
95 lines not on this page · raw message
Signature · 1 line
2.29.2
Saeed Mahameed
maintainerPATCH 9/14 net/mlx5e: Add flow steering DMAC trap rule
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Add flow group to the L2 table to hold the catch-all DMAC rule. Add API which adds/removes DMAC trap rule. This rule catches packets that were destined to be dropped due to no-match with previous DMAC rules. The trap rule steer these packets to the trap tir related to the trap-RQ.
--- .../net/ethernet/mellanox/mlx5/core/en/fs.h | 3 ++ .../net/ethernet/mellanox/mlx5/core/en_fs.c | 42 ++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/fs.h +3 -0
@@ -68,6 +68,7 @@ struct mlx5e_l2_table {struct hlist_head netdev_mc[MLX5E_L2_ADDR_HASH_SIZE ];struct mlx5e_l2_rule broadcast;struct mlx5e_l2_rule allmulti; +struct mlx5_flow_handle *trap_rule;bool broadcast_enabled;bool allmulti_enabled;bool promisc_enabled;
@@ -297,6 +298,8 @@ void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv);u8 mlx5e_get_proto_by_tunnel_type (enum mlx5e_tunnel_types tt);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);#endif /* __MLX5E_FLOW_STEER_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +40 -2
63 lines not on this page · raw message
Signature · 1 line
2.29.2
Saeed Mahameed
maintainerPATCH 10/14 net/mlx5e: Expose RX dma info helpers
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
In order to support RQs outside of channel context, change mlx5e_init_di_list() signature to accept NUMA node instead of cpu. In addition, expose dma info helpers as API. This API will be used for RQ's creation in other files in downstream patches.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 ++ drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +2 -0
@@ -1072,6 +1072,8 @@ void mlx5e_destroy_q_counters(struct mlx5e_priv *priv);int mlx5e_open_drop_rq (struct mlx5e_priv *priv,struct mlx5e_rq *drop_rq);void mlx5e_close_drop_rq (struct mlx5e_rq *drop_rq); +int mlx5e_init_di_list (struct mlx5e_rq *rq,int wq_sz,int node); +void mlx5e_free_di_list (struct mlx5e_rq *rq);int mlx5e_create_indirect_rqt (struct mlx5e_priv *priv);
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +4 -6
@@ -343,13 +343,11 @@ static void mlx5e_init_frags_partition(struct mlx5e_rq *rq) prev->last_in_page = true; } -static int mlx5e_init_di_list (struct mlx5e_rq *rq, -int wq_sz,int cpu) +int mlx5e_init_di_list (struct mlx5e_rq *rq,int wq_sz,int node) {int len = wq_sz << rq->wqe.info.log_num_frags; - rq->wqe.di =kvzalloc_node (array_size (len,sizeof (*rq->wqe.di)), -GFP_KERNEL ,cpu_to_node (cpu)); + rq->wqe.di =kvzalloc_node (array_size (len,sizeof (*rq->wqe.di)),GFP_KERNEL , node);if (!rq->wqe.di)return -ENOMEM ;
@@ -358,7 +356,7 @@ static int mlx5e_init_di_list(struct mlx5e_rq *rq,return 0 ; } -static void mlx5e_free_di_list (struct mlx5e_rq *rq) +void mlx5e_free_di_list (struct mlx5e_rq *rq) {kvfree (rq->wqe.di); }
@@ -500,7 +498,7 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c, goto err_rq_wq_destroy; } - err =mlx5e_init_di_list (rq, wq_sz, c->cpu); + err =mlx5e_init_di_list (rq, wq_sz,cpu_to_node (c->cpu));if (err) goto err_rq_frags;
Signature · 1 line
2.29.2
Saeed Mahameed
maintainerPATCH 11/14 net/mlx5e: Add trap entity to ETH driver
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Introduce mlx5e_trap which includes a dedicated RQ and NAPI for trapped packets. Trap-RQ processes packets that were destined to be dropped, but for debug and visibility sake these packets are trapped and reported to devlink.
Trap-RQ connects between the HW and the driver and is not a part of a channel. Open mlx5e_create_rq() and mlx5_core_destroy_rq() as API and add dedicate RQ handlers which report to devlink of trapped packets.
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en.h | 7 + .../net/ethernet/mellanox/mlx5/core/en/trap.c | 409 ++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en/trap.h | 35 ++ .../net/ethernet/mellanox/mlx5/core/en_main.c | 5 +- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 46 ++ include/linux/mlx5/device.h | 5 + 7 files changed, 505 insertions(+), 4 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/trap.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/trap.h
drivers/net/ethernet/mellanox/mlx5/core/Makefile +1 -1
@@ -27,7 +27,7 @@ mlx5_core-$(CONFIG_MLX5_CORE_EN) += en_main.o en_common.o en_fs.o en_ethtool.o \ en_selftest.o en/port.o en/monitor_stats.o en/health.o \ en/reporter_tx.o en/reporter_rx.o en/params.o en/xsk/pool.o \ en/xsk/setup.o en/xsk/rx.o en/xsk/tx.o en/devlink.o en/ptp.o \ - en/qos.o + en/qos.o en/trap.o # # Netdev extra
drivers/net/ethernet/mellanox/mlx5/core/en.h +7 -0
@@ -564,6 +564,7 @@ typedef bool (*mlx5e_fp_post_rx_wqes)(struct mlx5e_rq *rq);typedef void (*mlx5e_fp_dealloc_wqe )(struct mlx5e_rq *,u16 );int mlx5e_rq_set_handlers (struct mlx5e_rq *rq,struct mlx5e_params *params,bool xsk); +void mlx5e_rq_set_trap_handlers (struct mlx5e_rq *rq,struct mlx5e_params *params);enum mlx5e_rq_flag {MLX5E_RQ_FLAG_XDP_XMIT ,
@@ -805,6 +806,8 @@ struct mlx5e_htb {u16 defcls; }; +struct mlx5e_trap ; +struct mlx5e_priv {/* priv data path fields - start */ /* +1 for port ptp ts */
@@ -844,8 +847,10 @@ struct mlx5e_priv {struct mlx5_core_dev *mdev;struct net_device *netdev; +struct mlx5e_trap *en_trap;struct mlx5e_stats stats;struct mlx5e_channel_stats channel_stats[MLX5E_MAX_NUM_CHANNELS ]; +struct mlx5e_channel_stats trap_stats;struct mlx5e_port_ptp_stats port_ptp_stats;u16 max_nch;u8 max_opened_tc;
@@ -961,6 +966,8 @@ int mlx5e_open_rq(struct mlx5e_channel *c, struct mlx5e_params *params,int mlx5e_wait_for_min_rx_wqes (struct mlx5e_rq *rq,int wait_time);void mlx5e_deactivate_rq (struct mlx5e_rq *rq);void mlx5e_close_rq (struct mlx5e_rq *rq); +int mlx5e_create_rq (struct mlx5e_rq *rq,struct mlx5e_rq_param *param); +void mlx5e_destroy_rq (struct mlx5e_rq *rq);struct mlx5e_sq_param ; int mlx5e_open_icosq(struct mlx5e_channel *c, struct mlx5e_params *params,
drivers/net/ethernet/mellanox/mlx5/core/en/trap.c new file +409 -0
409 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/trap.h new file +35 -0
@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2020, Mellanox Technologies */ + +#ifndef __MLX5E_TRAP_H__ +#define __MLX5E_TRAP_H__ + +#include "../en.h" +#include "../devlink.h" + +struct mlx5e_trap { +/* data path */ +struct mlx5e_rq rq; +struct mlx5e_tir tir; +struct napi_struct napi; +struct device *pdev; +struct net_device *netdev; +__be32 mkey_be; + +/* data path - accessed per napi poll */ +struct mlx5e_ch_stats *stats; + +/* control */ +struct mlx5e_priv *priv; +struct mlx5_core_dev *mdev; +struct hwtstamp_config *tstamp; + DECLARE_BITMAP(state, MLX5E_CHANNEL_NUM_STATES); + +struct mlx5e_params params; +struct mlx5e_rq_param rq_param; +}; + +void mlx5e_close_trap (struct mlx5e_trap *trap); +void mlx5e_deactivate_trap (struct mlx5e_priv *priv); +int mlx5e_handle_trap_event (struct mlx5e_priv *priv,struct mlx5_trap_ctx *trap_ctx); +#endif
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +2 -3
@@ -649,8 +649,7 @@ static void mlx5e_free_rq(struct mlx5e_rq *rq)mlx5_wq_destroy (&rq->wq_ctrl); } -static int mlx5e_create_rq (struct mlx5e_rq *rq, -struct mlx5e_rq_param *param) +int mlx5e_create_rq (struct mlx5e_rq *rq,struct mlx5e_rq_param *param) {struct mlx5_core_dev *mdev = rq->mdev;
@@ -773,7 +772,7 @@ static int mlx5e_modify_rq_vsd(struct mlx5e_rq *rq, bool vsd)return err; } -static void mlx5e_destroy_rq (struct mlx5e_rq *rq) +void mlx5e_destroy_rq (struct mlx5e_rq *rq) {mlx5_core_destroy_rq (rq->mdev, rq->rqn); }
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +46 -0
55 lines not on this page · raw message
include/linux/mlx5/device.h +5 -0
@@ -903,6 +903,11 @@ static inline u64 get_cqe_ts(struct mlx5_cqe64 *cqe)return (u64 )lo | ((u64 )hi <<32 ); } +static inline u16 get_cqe_flow_tag (struct mlx5_cqe64 *cqe) +{ +return be32_to_cpu (cqe->sop_drop_qpn) &0xFFF ; +} +#define MLX5_MPWQE_LOG_NUM_STRIDES_BASE (9)#define MLX5_MPWQE_LOG_STRIDE_SZ_BASE (6)
Signature · 1 line
2.29.2
Saeed Mahameed
maintainerPATCH 12/14 net/mlx5e: Add listener to trap event
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Add support for listening to blocking events in the ETH driver. Listen on trap event. If received, call mlx5e_handle_trap_event() which:
1) Verifies if driver needs open/close trap-RQ with respect to the active traps count.
2) Inspects trap id and its action (trap/drop) and add/remove the flow steering rule accordingly.
Otherwise, return an error.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + .../net/ethernet/mellanox/mlx5/core/en_main.c | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -0
@@ -859,6 +859,7 @@ struct mlx5e_priv {u16 q_counter;u16 drop_rq_q_counter;struct notifier_block events_nb; +struct notifier_block blocking_events_nb;int num_tc_x_num_ch;struct udp_tunnel_nic_info nic_info;
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +35 -0
@@ -66,6 +66,7 @@#include "lib/mlx5.h" #include "en/ptp.h" #include "qos.h" +#include "en/trap.h" bool mlx5e_check_fragmented_striding_rq_cap (struct mlx5_core_dev *mdev) {
@@ -212,6 +213,33 @@ static void mlx5e_disable_async_events(struct mlx5e_priv *priv)mlx5_notifier_unregister (priv->mdev, &priv->events_nb); } +static int blocking_event (struct notifier_block *nb,unsigned long event,void *data) +{ + struct mlx5e_priv *priv = container_of(nb, struct mlx5e_priv, blocking_events_nb); +int err; + +switch (event) { +case MLX5_DRIVER_EVENT_TYPE_TRAP : + err =mlx5e_handle_trap_event (priv, data); +break ; +default : +netdev_warn (priv->netdev,"Sync event: Unknouwn event %ld\n" , event); + err = -EINVAL ; + } +return err; +} + +static void mlx5e_enable_blocking_events (struct mlx5e_priv *priv) +{ + priv->blocking_events_nb.notifier_call = blocking_event; +mlx5_blocking_notifier_register (priv->mdev, &priv->blocking_events_nb); +} + +static void mlx5e_disable_blocking_events (struct mlx5e_priv *priv) +{ +mlx5_blocking_notifier_unregister (priv->mdev, &priv->blocking_events_nb); +} +static inline void mlx5e_build_umr_wqe (struct mlx5e_rq *rq,struct mlx5e_icosq *sq,struct mlx5e_umr_wqe *wqe)
@@ -5341,6 +5369,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)mlx5_lag_add (mdev, netdev);mlx5e_enable_async_events (priv); +mlx5e_enable_blocking_events (priv);if (mlx5e_monitor_counter_supported (priv))mlx5e_monitor_counter_init (priv);
@@ -5378,6 +5407,12 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv)if (mlx5e_monitor_counter_supported (priv))mlx5e_monitor_counter_cleanup (priv); +mlx5e_disable_blocking_events (priv); +if (priv->en_trap) { +mlx5e_deactivate_trap (priv); +mlx5e_close_trap (priv->en_trap); + priv->en_trap =NULL ; + }mlx5e_disable_async_events (priv);mlx5_lag_remove (mdev);mlx5_vxlan_reset_to_default (mdev->vxlan);
Signature · 1 line
2.29.2
Saeed Mahameed
maintainerPATCH 13/14 net/mlx5e: Add listener to DMAC filter trap event
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Add support for trapping packets which didn't match any DMAC in the MAC table. Add a listener which adds/removes MAC trap rule in the flow steering according to the trap's action trap/drop.
--- drivers/net/ethernet/mellanox/mlx5/core/en/trap.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en/trap.c +8 -0
@@ -360,6 +360,11 @@ static int mlx5e_handle_action_trap(struct mlx5e_priv *priv, int trap_id)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)); +if (err) + goto err_out; +break ;default :netdev_warn (priv->netdev,"%s: Unknown trap id %d\n" , __func__, trap_id); err = -EINVAL ;
@@ -379,6 +384,9 @@ static int mlx5e_handle_action_drop(struct mlx5e_priv *priv, int trap_id)case DEVLINK_TRAP_GENERIC_ID_INGRESS_VLAN_FILTER :mlx5e_remove_vlan_trap (priv);break ; +case DEVLINK_TRAP_GENERIC_ID_DMAC_FILTER : +mlx5e_remove_mac_trap (priv); +break ;default :netdev_warn (priv->netdev,"%s: Unknown trap id %d\n" , __func__, trap_id);return -EINVAL ;
Signature · 1 line
2.29.2
Saeed Mahameed
maintainerPATCH 14/14 net/mlx5e: Enable traps according to link state
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Avoid trapping packets when the interface is down, and revive them when interface is back up. Add API to mlx5 core retrieving the action by trap id. Use it to apply traps when interface is up, and disable then when interface is down.
--- .../net/ethernet/mellanox/mlx5/core/devlink.c | 16 ++++++++ .../net/ethernet/mellanox/mlx5/core/devlink.h | 2 + .../net/ethernet/mellanox/mlx5/core/en/trap.c | 40 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en/trap.h | 2 + .../net/ethernet/mellanox/mlx5/core/en_main.c | 2 + 5 files changed, 62 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +16 -0
@@ -308,6 +308,22 @@ int mlx5_devlink_trap_get_num_active(struct mlx5_core_dev *dev)return count; } +int mlx5_devlink_traps_get_action (struct mlx5_core_dev *dev,int trap_id, +enum devlink_trap_action *action) +{ +struct mlx5_devlink_trap *dl_trap; + + dl_trap =mlx5_find_trap_by_id (dev, trap_id); +if (!dl_trap) { +mlx5_core_err (dev,"Devlink trap: Get action on invalid trap id 0x%x" , + trap_id); +return -EINVAL ; + } + + *action = dl_trap->trap.action; +return 0 ; +} +struct devlink *mlx5_devlink_alloc (void ) {return devlink_alloc (&mlx5_devlink_ops,sizeof (struct mlx5_core_dev ));
drivers/net/ethernet/mellanox/mlx5/core/devlink.h +2 -0
@@ -27,6 +27,8 @@ struct mlx5_core_dev;void mlx5_devlink_trap_report (struct mlx5_core_dev *dev,int trap_id,struct sk_buff *skb,struct devlink_port *dl_port);int mlx5_devlink_trap_get_num_active (struct mlx5_core_dev *dev); +int mlx5_devlink_traps_get_action (struct mlx5_core_dev *dev,int trap_id, +enum devlink_trap_action *action);struct devlink *mlx5_devlink_alloc (void );void mlx5_devlink_free (struct devlink *devlink);
drivers/net/ethernet/mellanox/mlx5/core/en/trap.c +40 -0
@@ -401,6 +401,14 @@ int mlx5e_handle_trap_event(struct mlx5e_priv *priv, struct mlx5_trap_ctx *trap_ {int err =0 ; +/* Traps are unarmed when interface is down, no need to update +* them. The configuration is saved in the core driver, +* queried and applied upon interface up operation in +* mlx5e_open_locked(). +*/ +if (!test_bit (MLX5E_STATE_OPENED , &priv->state)) +return 0 ; +switch (trap_ctx->action) {case DEVLINK_TRAP_ACTION_TRAP : err =mlx5e_handle_action_trap (priv, trap_ctx->id);
@@ -415,3 +423,35 @@ int mlx5e_handle_trap_event(struct mlx5e_priv *priv, struct mlx5_trap_ctx *trap_ }return err; } + +static int mlx5e_apply_trap (struct mlx5e_priv *priv,int trap_id,bool enable) +{ +enum devlink_trap_action action; +int err; + + err =mlx5_devlink_traps_get_action (priv->mdev, trap_id, &action); +if (err) +return err; +if (action ==DEVLINK_TRAP_ACTION_TRAP ) + err = enable ?mlx5e_handle_action_trap (priv, trap_id) : +mlx5e_handle_action_drop (priv, trap_id); +return err; +} + +static const int mlx5e_traps_arr[] = { +DEVLINK_TRAP_GENERIC_ID_INGRESS_VLAN_FILTER , +DEVLINK_TRAP_GENERIC_ID_DMAC_FILTER , +}; + +int mlx5e_apply_traps (struct mlx5e_priv *priv,bool enable) +{ +int err; +int i; + +for (i =0 ; i <ARRAY_SIZE (mlx5e_traps_arr); i++) { + err =mlx5e_apply_trap (priv, mlx5e_traps_arr[i], enable); +if (err) +return err; + } +return 0 ; +}
drivers/net/ethernet/mellanox/mlx5/core/en/trap.h +2 -0
@@ -32,4 +32,6 @@ struct mlx5e_trap {void mlx5e_close_trap (struct mlx5e_trap *trap);void mlx5e_deactivate_trap (struct mlx5e_priv *priv);int mlx5e_handle_trap_event (struct mlx5e_priv *priv,struct mlx5_trap_ctx *trap_ctx); +int mlx5e_apply_traps (struct mlx5e_priv *priv,bool enable); +#endif
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +2 -0
@@ -3247,6 +3247,7 @@ int mlx5e_open_locked(struct net_device *netdev) priv->profile->update_rx (priv);mlx5e_activate_priv_channels (priv); +mlx5e_apply_traps (priv, true);if (priv->profile->update_carrier) priv->profile->update_carrier (priv);
@@ -3282,6 +3283,7 @@ int mlx5e_close_locked(struct net_device *netdev)if (!test_bit (MLX5E_STATE_OPENED , &priv->state))return 0 ; +mlx5e_apply_traps (priv, false);clear_bit (MLX5E_STATE_OPENED , &priv->state);netif_carrier_off (priv->netdev);
Signature · 1 line
2.29.2