vdpa:/mlx5: Add debugfs subtree
Subsystems (2)
cover vdpa:/mlx5: Add debugfs subtree
First patch fixes a copy paste error causing VLAN tagged packets to no be filtered.
Following three patches add debugfs subtree.
First one just moves definitions to a new header file. These definitions are needed for following patches.
Second patch adds entries to read flow table number and TIR number. Third patch adds multicast and unicast packets and bytes counters for for each untagged or VLAN tagged incoming traffic. This is depends on MLX5_VDPA_STEERING_DEBUG config option and is off by default.
Eli Cohen (4):
vdpa/mlx5: Fix rule forwarding VLAN to TIR vdpa/mlx5: Move some definitions to a new header file vdpa/mlx5: Add debugfs subtree
vdpa/mlx5: Add RX counters to debugfs
drivers/vdpa/Kconfig | 12 +++ drivers/vdpa/mlx5/Makefile | 2 +- drivers/vdpa/mlx5/net/debug.c | 148 +++++++++++++++++++++++++++++ drivers/vdpa/mlx5/net/mlx5_vnet.c | 152 +++++++++++++++++------------- drivers/vdpa/mlx5/net/mlx5_vnet.h | 94 ++++++++++++++++++ 5 files changed, 339 insertions(+), 69 deletions(-) create mode 100644 drivers/vdpa/mlx5/net/debug.c create mode 100644 drivers/vdpa/mlx5/net/mlx5_vnet.h
Signature · 1 line
2.35.1
PATCH 1/4 vdpa/mlx5: Fix rule forwarding VLAN to TIR
Set the VLAN id to the header values field instead of overwriting the headers criteria field.
Before this fix, VLAN filtering would not really work and tagged packets would be forwarded unfiltered to the TIR.
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +1 -1
@@ -1472,7 +1472,7 @@ static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac,if (tagged) {MLX5_SET (fte_match_set_lyr_2_4, headers_v, cvlan_tag,1 );MLX5_SET_TO_ONES (fte_match_set_lyr_2_4, headers_c, first_vid); -MLX5_SET (fte_match_set_lyr_2_4, headers_c, first_vid, vid); +MLX5_SET (fte_match_set_lyr_2_4, headers_v, first_vid, vid); } flow_act.action =MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ; dest.type =MLX5_FLOW_DESTINATION_TYPE_TIR ;
Signature · 1 line
2.35.1
PATCH 2/4 vdpa/mlx5: Move some definitions to a new header file
In reply to Eli CohenMove some definitions from mlx5_vnet.c to newly added header file mlx5_vnet.h. We need these definitions for the following patches that add debugfs tree to expose information vital for debug.
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 45 +------------------------ drivers/vdpa/mlx5/net/mlx5_vnet.h | 55 +++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 44 deletions(-) create mode 100644 drivers/vdpa/mlx5/net/mlx5_vnet.h
drivers/vdpa/mlx5/net/mlx5_vnet.c +1 -44
@@ -18,15 +18,12 @@#include <linux/mlx5/mlx5_ifc_vdpa.h> #include <linux/mlx5/mpfs.h> #include "mlx5_vdpa.h" +#include "mlx5_vnet.h" MODULE_AUTHOR ("Eli Cohen <[email protected]>" );MODULE_DESCRIPTION ("Mellanox VDPA driver" );MODULE_LICENSE ("Dual BSD/GPL" ); -#define to_mlx5_vdpa_ndev (__mvdev) \ - container_of(__mvdev, struct mlx5_vdpa_net, mvdev) -#define to_mvdev (__vdev) container_of((__vdev), struct mlx5_vdpa_dev, vdev) -#define VALID_FEATURES_MASK \ (BIT_ULL(VIRTIO_NET_F_CSUM) | BIT_ULL(VIRTIO_NET_F_GUEST_CSUM) | \ BIT_ULL(VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) | BIT_ULL(VIRTIO_NET_F_MTU) | BIT_ULL(VIRTIO_NET_F_MAC) | \
@@ -50,14 +47,6 @@ MODULE_LICENSE("Dual BSD/GPL");#define MLX5V_UNTAGGED 0x1000 -struct mlx5_vdpa_net_resources { -u32 tisn; -u32 tdn; -u32 tirn; -u32 rqtn; -bool valid; -}; -struct mlx5_vdpa_cq_buf {struct mlx5_frag_buf_ctrl fbc;struct mlx5_frag_buf frag_buf;
@@ -146,38 +135,6 @@ static bool is_index_valid(struct mlx5_vdpa_dev *mvdev, u16 idx)return idx <= mvdev->max_idx; } -#define MLX5V_MACVLAN_SIZE 256 - -struct mlx5_vdpa_net { -struct mlx5_vdpa_dev mvdev; -struct mlx5_vdpa_net_resources res; -struct virtio_net_config config; -struct mlx5_vdpa_virtqueue *vqs; -struct vdpa_callback *event_cbs; - -/* Serialize vq resources creation and destruction. This is required -* since memory map might change and we need to destroy and create -* resources while driver in operational. -*/ -struct rw_semaphore reslock; -struct mlx5_flow_table *rxft; -bool setup; -u32 cur_num_vqs; -u32 rqt_size; -bool nb_registered; -struct notifier_block nb; -struct vdpa_callback config_cb; -struct mlx5_vdpa_wq_ent cvq_ent; -struct hlist_head macvlan_hash[MLX5V_MACVLAN_SIZE ]; -}; - -struct macvlan_node { -struct hlist_node hlist; -struct mlx5_flow_handle *ucast_rule; -struct mlx5_flow_handle *mcast_rule; -u64 macvlan; -}; -static void free_resources (struct mlx5_vdpa_net *ndev);static void init_mvqs (struct mlx5_vdpa_net *ndev);static int setup_driver (struct mlx5_vdpa_dev *mvdev);
drivers/vdpa/mlx5/net/mlx5_vnet.h new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
2.35.1
PATCH 4/4 vdpa/mlx5: Add RX counters to debugfs
In reply to Eli CohenFor each interface, either VLAN tagged or untagged, add two hardware
counters: one for unicast and another for multicast. The counters count RX packets and bytes and can be read through debugfs:
$ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/untagged/mcast/packets $ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/untagged/ucast/bytes
This feature is controlled via the config option MLX5_VDPA_STEERING_DEBUG. It is off by default as it may have some impact on performance.
--- drivers/vdpa/Kconfig | 12 ++++ drivers/vdpa/mlx5/net/debug.c | 82 +++++++++++++++++++++++++++ drivers/vdpa/mlx5/net/mlx5_vnet.c | 94 +++++++++++++++++++++++-------- drivers/vdpa/mlx5/net/mlx5_vnet.h | 30 ++++++++++ 4 files changed, 195 insertions(+), 23 deletions(-)
drivers/vdpa/Kconfig +12 -0
@@ -71,6 +71,18 @@ config MLX5_VDPA_NET be executed by the hardware. It also supports a variety of stateless offloads depending on the actual device used and firmware version. +config MLX5_VDPA_STEERING_DEBUG + bool "expose steering counters on debugfs" + select MLX5_VDPA + help + Expose RX steering counters in debugfs to aid in debugging. For each VLAN + or non VLAN interface, two hardware counters are added to the RX flow + table: one for unicast and one for multicast. + The counters counts the number of packets and bytes and exposes them in + debugfs. Once can read the counters using, e.g.: + cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/untagged/ucast/packets + cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/untagged/mcast/bytes + config VP_VDPA tristate "Virtio PCI bridge vDPA driver" select VIRTIO_PCI_LIB
drivers/vdpa/mlx5/net/debug.c +82 -0
88 lines not on this page · raw message
drivers/vdpa/mlx5/net/mlx5_vnet.c +71 -23
179 lines not on this page · raw message
drivers/vdpa/mlx5/net/mlx5_vnet.h +30 -0
@@ -21,6 +21,11 @@ struct mlx5_vdpa_net_resources {#define MLX5V_MACVLAN_SIZE 256 +static inline u16 key2vid (u64 key) +{ +return (u16)(key >>48 ); +} +struct mlx5_vdpa_net {struct mlx5_vdpa_dev mvdev;struct mlx5_vdpa_net_resources res;
@@ -47,11 +52,24 @@ struct mlx5_vdpa_net {struct dentry *debugfs; }; +struct mlx5_vdpa_counter { +struct mlx5_fc *counter; +struct dentry *dent; +struct mlx5_core_dev *mdev; +}; +struct macvlan_node {struct hlist_node hlist;struct mlx5_flow_handle *ucast_rule;struct mlx5_flow_handle *mcast_rule;u64 macvlan; +struct mlx5_vdpa_net *ndev; +bool tagged; +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG ) +struct dentry *dent; +struct mlx5_vdpa_counter ucast_counter; +struct mlx5_vdpa_counter mcast_counter; +#endif };void mlx5_vdpa_add_debugfs (struct mlx5_vdpa_net *ndev);
@@ -60,5 +78,17 @@ void mlx5_vdpa_add_rx_flow_table(struct mlx5_vdpa_net *ndev);void mlx5_vdpa_remove_rx_flow_table (struct mlx5_vdpa_net *ndev);void mlx5_vdpa_add_tirn (struct mlx5_vdpa_net *ndev);void mlx5_vdpa_remove_tirn (struct mlx5_vdpa_net *ndev); +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG ) +void mlx5_vdpa_add_rx_counters (struct mlx5_vdpa_net *ndev, +struct macvlan_node *node); +void mlx5_vdpa_remove_rx_counters (struct mlx5_vdpa_net *ndev, +struct macvlan_node *node); +#else +static inline void mlx5_vdpa_add_rx_counters (struct mlx5_vdpa_net *ndev, +struct macvlan_node *node) {} +static inline void mlx5_vdpa_remove_rx_counters (struct mlx5_vdpa_net *ndev, +struct macvlan_node *node) {} +#endif +#endif /* __MLX5_VNET_H__ */
Signature · 1 line
2.35.1
PATCH 3/4 vdpa/mlx5: Add debugfs subtree
In reply to Eli CohenAdd debugfs subtree and expose flow table ID and TIR number. This information can be used by external tools to do extended troubleshooting.
The information can be retrieved like so:
$ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/table_id $ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/tirn
--- drivers/vdpa/mlx5/Makefile | 2 +- drivers/vdpa/mlx5/net/debug.c | 66 +++++++++++++++++++++++++++++++ drivers/vdpa/mlx5/net/mlx5_vnet.c | 11 ++++++ drivers/vdpa/mlx5/net/mlx5_vnet.h | 9 +++++ 4 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 drivers/vdpa/mlx5/net/debug.c
drivers/vdpa/mlx5/Makefile +1 -1
@@ -1,4 +1,4 @@ subdir-ccflags-y += -I$(srctree)/drivers/vdpa/mlx5/core obj-$(CONFIG_MLX5_VDPA_NET) += mlx5_vdpa.o -mlx5_vdpa-$(CONFIG_MLX5_VDPA_NET) += net/mlx5_vnet.o core/resources.o core/mr.o +mlx5_vdpa-$(CONFIG_MLX5_VDPA_NET) += net/mlx5_vnet.o core/resources.o core/mr.o net/debug.o
drivers/vdpa/mlx5/net/debug.c new file +66 -0
66 lines not on this page · raw message
drivers/vdpa/mlx5/net/mlx5_vnet.c +11 -0
@@ -1388,11 +1388,16 @@ static int create_tir(struct mlx5_vdpa_net *ndev) err =mlx5_vdpa_create_tir (&ndev->mvdev, in, &ndev->res.tirn);kfree (in); +if (err) +return err; + +mlx5_vdpa_add_tirn (ndev);return err; }static void destroy_tir (struct mlx5_vdpa_net *ndev) { +mlx5_vdpa_remove_tirn (ndev);mlx5_vdpa_destroy_tir (&ndev->mvdev, ndev->res.tirn); }
@@ -1576,6 +1581,7 @@ static int setup_steering(struct mlx5_vdpa_net *ndev)mlx5_vdpa_warn (&ndev->mvdev,"failed to create flow table\n" );return PTR_ERR (ndev->rxft); } +mlx5_vdpa_add_rx_flow_table (ndev); err =mac_vlan_add (ndev, ndev->config.mac,0 , false);if (err)
@@ -1584,6 +1590,7 @@ static int setup_steering(struct mlx5_vdpa_net *ndev)return 0 ; err_add: +mlx5_vdpa_remove_rx_flow_table (ndev);mlx5_destroy_flow_table (ndev->rxft);return err; }
@@ -1591,6 +1598,7 @@ static int setup_steering(struct mlx5_vdpa_net *ndev)static void teardown_steering (struct mlx5_vdpa_net *ndev) {clear_mac_vlan_table (ndev); +mlx5_vdpa_remove_rx_flow_table (ndev);mlx5_destroy_flow_table (ndev->rxft); }
@@ -3167,6 +3175,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,if (err) goto err_reg; +mlx5_vdpa_add_debugfs (ndev); mgtdev->ndev = ndev;return 0 ;
@@ -3193,6 +3202,8 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev);struct workqueue_struct *wq; +mlx5_vdpa_remove_debugfs (ndev->debugfs); + ndev->debugfs =NULL ;if (ndev->nb_registered) {mlx5_notifier_unregister (mvdev->mdev, &ndev->nb); ndev->nb_registered = false;
drivers/vdpa/mlx5/net/mlx5_vnet.h +9 -0
@@ -16,6 +16,7 @@ struct mlx5_vdpa_net_resources {u32 tirn;u32 rqtn;bool valid; +struct dentry *tirn_dent; };#define MLX5V_MACVLAN_SIZE 256
@@ -43,6 +44,7 @@ struct mlx5_vdpa_net {struct vdpa_callback config_cb;struct mlx5_vdpa_wq_ent cvq_ent;struct hlist_head macvlan_hash[MLX5V_MACVLAN_SIZE ]; +struct dentry *debugfs; };struct macvlan_node {
@@ -52,4 +54,11 @@ struct macvlan_node { u64 macvlan; }; +void mlx5_vdpa_add_debugfs (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_remove_debugfs (struct dentry *dbg); +void mlx5_vdpa_add_rx_flow_table (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_remove_rx_flow_table (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_add_tirn (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_remove_tirn (struct mlx5_vdpa_net *ndev); +#endif /* __MLX5_VNET_H__ */
Signature · 1 line
2.35.1
Re: [PATCH 1/4] vdpa/mlx5: Fix rule forwarding VLAN to TIR
In reply to Eli CohenHi Eli,
It's not for this patch but something related, so just a friendly heads-up. I haven't validated the VLAN tagging behavior yet for mlx5 vdpa, but from my quick read of the code it doesn't seem it differentiates the case with and without VIRTIO_NET_F_CTRL_VLAN, to be compatible/compliant with what's been implemented in QEMU software (a spec addendum was filed as requested by Michael):
https://github.com/oasis-tcs/virtio-spec/issues/147
- when VIRTIO_NET_F_CTRL_VLAN is negotiated, the device starts with all VLANs filtered (meaning only untagged traffic can be received, and traffic with VLAN tag will be dropped).
- when VIRTIO_NET_F_CTRL_VLAN is not negotiated, all traffic including untagged and tagged can be received.
Can you please help check if we need further fix in terms of VLAN tagging?
Thanks,
-Siwei
Quoted 9 lines · Eli Cohen
Set the VLAN id to the header values field instead of overwriting the headers criteria field.
Before this fix, VLAN filtering would not really work and tagged packets would be forwarded unfiltered to the TIR.
Fixes baf2ad3f6a98 ("vdpa/mlx5: Add RX MAC VLAN filter support")Signed-off-by Eli Cohen <[email protected]>
Quoted 9 lines
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-0
drivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac, · line 1478
Quoted 8 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-1@@ -1472,7 +1472,7 @@ static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac,if (tagged) {MLX5_SET (fte_match_set_lyr_2_4, headers_v, cvlan_tag,1 );MLX5_SET_TO_ONES (fte_match_set_lyr_2_4, headers_c, first_vid); -MLX5_SET (fte_match_set_lyr_2_4, headers_c, first_vid, vid); +MLX5_SET (fte_match_set_lyr_2_4, headers_v, first_vid, vid); } flow_act.action =MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ; dest.type =MLX5_FLOW_DESTINATION_TYPE_TIR ;
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 2/4] vdpa/mlx5: Move some definitions to a new header file
In reply to Eli CohenQuoted 5 lines · Eli Cohen
Move some definitions from
mlx5_vnet.cto newly added header filemlx5_vnet.h. We need these definitions for the following patches that add debugfs tree to expose information vital for debug.Signed-off-by Eli Cohen<[email protected]>
Quoted 132 lines
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 45 +------------------------ drivers/vdpa/mlx5/net/mlx5_vnet.h | 55 +++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 44 deletions(-)create mode 100644
drivers/vdpa/mlx5/net/mlx5_vnet.hdrivers/vdpa/mlx5/net/mlx5_vnet.c +1
-44@@ -18,15 +18,12 @@#include <linux/mlx5/mlx5_ifc_vdpa.h> #include <linux/mlx5/mpfs.h> #include "mlx5_vdpa.h" +#include "mlx5_vnet.h" MODULE_AUTHOR ("Eli Cohen<[email protected]>" );MODULE_DESCRIPTION ("Mellanox VDPA driver" );MODULE_LICENSE ("Dual BSD/GPL" ); -#define to_mlx5_vdpa_ndev (__mvdev) \ - container_of(__mvdev, struct mlx5_vdpa_net, mvdev) -#define to_mvdev (__vdev) container_of((__vdev), struct mlx5_vdpa_dev, vdev) -#define VALID_FEATURES_MASK \ (BIT_ULL(VIRTIO_NET_F_CSUM) | BIT_ULL(VIRTIO_NET_F_GUEST_CSUM) | \ BIT_ULL(VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) | BIT_ULL(VIRTIO_NET_F_MTU) | BIT_ULL(VIRTIO_NET_F_MAC) | \@@ -50,14 +47,6 @@ MODULE_LICENSE("Dual BSD/GPL");#define MLX5V_UNTAGGED 0x1000 -struct mlx5_vdpa_net_resources { -u32 tisn; -u32 tdn; -u32 tirn; -u32 rqtn; -bool valid; -}; -struct mlx5_vdpa_cq_buf {struct mlx5_frag_buf_ctrl fbc;struct mlx5_frag_buf frag_buf;@@ -146,38 +135,6 @@ static bool is_index_valid(struct mlx5_vdpa_dev *mvdev, u16 idx)return idx <= mvdev->max_idx; } -#define MLX5V_MACVLAN_SIZE 256 - -struct mlx5_vdpa_net { -struct mlx5_vdpa_dev mvdev; -struct mlx5_vdpa_net_resources res; -struct virtio_net_config config; -struct mlx5_vdpa_virtqueue *vqs; -struct vdpa_callback *event_cbs; - -/* Serialize vq resources creation and destruction. This is required -* since memory map might change and we need to destroy and create -* resources while driver in operational. -*/ -struct rw_semaphore reslock; -struct mlx5_flow_table *rxft; -bool setup; -u32 cur_num_vqs; -u32 rqt_size; -bool nb_registered; -struct notifier_block nb; -struct vdpa_callback config_cb; -struct mlx5_vdpa_wq_ent cvq_ent; -struct hlist_head macvlan_hash[MLX5V_MACVLAN_SIZE ]; -}; - -struct macvlan_node { -struct hlist_node hlist; -struct mlx5_flow_handle *ucast_rule; -struct mlx5_flow_handle *mcast_rule; -u64 macvlan; -}; -static void free_resources (struct mlx5_vdpa_net *ndev);static void init_mvqs (struct mlx5_vdpa_net *ndev);static int setup_driver (struct mlx5_vdpa_dev *mvdev);drivers/vdpa/mlx5/net/mlx5_vnet.h new file +45
-0@@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ + +#ifndef __MLX5_VNET_H__ +#define __MLX5_VNET_H__ + +#include "mlx5_vdpa.h" + +#define to_mlx5_vdpa_ndev(__mvdev) \ + container_of(__mvdev, struct mlx5_vdpa_net, mvdev) +#define to_mvdev(__vdev) container_of((__vdev), struct mlx5_vdpa_dev, vdev) + +struct mlx5_vdpa_net_resources { + u32 tisn; + u32 tdn; + u32 tirn; + u32 rqtn; + bool valid; +}; + +#define MLX5V_MACVLAN_SIZE 256 + +struct mlx5_vdpa_net { + struct mlx5_vdpa_dev mvdev; + struct mlx5_vdpa_net_resources res; + struct virtio_net_config config; + struct mlx5_vdpa_virtqueue *vqs; + struct vdpa_callback *event_cbs; + + /* Serialize vq resources creation and destruction. This is required + * since memory map might change and we need to destroy and create + * resources while driver in operational. + */ + struct rw_semaphore reslock; + struct mlx5_flow_table *rxft; + struct dentry *rx_dent; + struct dentry *rx_table_dent; + bool setup; + u32 cur_num_vqs; + u32 rqt_size; + bool nb_registered; + struct notifier_block nb; + struct vdpa_callback config_cb; + struct mlx5_vdpa_wq_ent cvq_ent; + struct hlist_head macvlan_hash[MLX5V_MACVLAN_SIZE];
drivers/vdpa/mlx5/net/mlx5_vnet.h line 55
Quoted 10 lines
drivers/vdpa/mlx5/net/mlx5_vnet.h new file +10
-0+}; + +struct macvlan_node { +struct hlist_node hlist; +struct mlx5_flow_handle *ucast_rule; +struct mlx5_flow_handle *mcast_rule; +u64 macvlan; +}; + +#endif /* __MLX5_VNET_H__ */
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 3/4] vdpa/mlx5: Add debugfs subtree
In reply to Eli CohenQuoted 9 lines · Eli Cohen
Add debugfs subtree and expose flow table ID and TIR number. This information can be used by external tools to do extended troubleshooting.
The information can be retrieved like so:
$ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/table_id $ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/tirnSigned-off-by Eli Cohen <[email protected]>
LGTM
Quoted 174 lines
--- drivers/vdpa/mlx5/Makefile | 2 +- drivers/vdpa/mlx5/net/debug.c | 66 +++++++++++++++++++++++++++++++ drivers/vdpa/mlx5/net/mlx5_vnet.c | 11 ++++++ drivers/vdpa/mlx5/net/mlx5_vnet.h | 9 +++++ 4 files changed, 87 insertions(+), 1 deletion(-)create mode 100644
drivers/vdpa/mlx5/net/debug.cdrivers/vdpa/mlx5/Makefile +1
-1@@ -1,4 +1,4 @@ subdir-ccflags-y += -I$(srctree)/drivers/vdpa/mlx5/core obj-$(CONFIG_MLX5_VDPA_NET) += mlx5_vdpa.o -mlx5_vdpa-$(CONFIG_MLX5_VDPA_NET) += net/mlx5_vnet.o core/resources.o core/mr.o +mlx5_vdpa-$(CONFIG_MLX5_VDPA_NET) += net/mlx5_vnet.o core/resources.o core/mr.o net/debug.odrivers/vdpa/mlx5/net/debug.c new file +66
-0@@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +/* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ + +#include <linux/debugfs.h> +#include <linux/mlx5/fs.h> +#include "mlx5_vnet.h" + +static int tirn_show (struct seq_file *file,void *priv) +{ +struct mlx5_vdpa_net *ndev = file->private; + +seq_printf (file,"0x%x\n" , ndev->res.tirn); +return 0 ; +} + +DEFINE_SHOW_ATTRIBUTE (tirn); + +void mlx5_vdpa_remove_tirn (struct mlx5_vdpa_net *ndev) +{ +if (ndev->debugfs) +debugfs_remove (ndev->res.tirn_dent); +} + +void mlx5_vdpa_add_tirn (struct mlx5_vdpa_net *ndev) +{ + ndev->res.tirn_dent =debugfs_create_file ("tirn" ,0444 , ndev->rx_dent, + ndev, &tirn_fops); +} + +static int rx_flow_table_show (struct seq_file *file,void *priv) +{ +struct mlx5_vdpa_net *ndev = file->private; + +seq_printf (file,"0x%x\n" ,mlx5_flow_table_id (ndev->rxft)); +return 0 ; +} + +DEFINE_SHOW_ATTRIBUTE (rx_flow_table); + +void mlx5_vdpa_remove_rx_flow_table (struct mlx5_vdpa_net *ndev) +{ +if (ndev->debugfs) +debugfs_remove (ndev->rx_table_dent); +} + +void mlx5_vdpa_add_rx_flow_table (struct mlx5_vdpa_net *ndev) +{ + ndev->rx_table_dent =debugfs_create_file ("table_id" ,0444 , ndev->rx_dent, + ndev, &rx_flow_table_fops); +} + +void mlx5_vdpa_add_debugfs (struct mlx5_vdpa_net *ndev) +{ +struct mlx5_core_dev *mdev; + + mdev = ndev->mvdev.mdev; + ndev->debugfs =debugfs_create_dir (dev_name (&ndev->mvdev.vdev.dev), +mlx5_debugfs_get_dev_root (mdev)); +if (!IS_ERR (ndev->debugfs)) + ndev->rx_dent =debugfs_create_dir ("rx" , ndev->debugfs); +} + +void mlx5_vdpa_remove_debugfs (struct dentry *dbg) +{ +debugfs_remove_recursive (dbg); +}drivers/vdpa/mlx5/net/mlx5_vnet.c +11
-0@@ -1388,11 +1388,16 @@ static int create_tir(struct mlx5_vdpa_net *ndev) err =mlx5_vdpa_create_tir (&ndev->mvdev, in, &ndev->res.tirn);kfree (in); +if (err) +return err; + +mlx5_vdpa_add_tirn (ndev);return err; }static void destroy_tir (struct mlx5_vdpa_net *ndev) { +mlx5_vdpa_remove_tirn (ndev);mlx5_vdpa_destroy_tir (&ndev->mvdev, ndev->res.tirn); }@@ -1576,6 +1581,7 @@ static int setup_steering(struct mlx5_vdpa_net *ndev)mlx5_vdpa_warn (&ndev->mvdev,"failed to create flow table\n" );return PTR_ERR (ndev->rxft); } +mlx5_vdpa_add_rx_flow_table (ndev); err =mac_vlan_add (ndev, ndev->config.mac,0 , false);if (err)@@ -1584,6 +1590,7 @@ static int setup_steering(struct mlx5_vdpa_net *ndev)return 0 ; err_add: +mlx5_vdpa_remove_rx_flow_table (ndev);mlx5_destroy_flow_table (ndev->rxft);return err; }@@ -1591,6 +1598,7 @@ static int setup_steering(struct mlx5_vdpa_net *ndev)static void teardown_steering (struct mlx5_vdpa_net *ndev) {clear_mac_vlan_table (ndev); +mlx5_vdpa_remove_rx_flow_table (ndev);mlx5_destroy_flow_table (ndev->rxft); }@@ -3167,6 +3175,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,if (err) goto err_reg; +mlx5_vdpa_add_debugfs (ndev); mgtdev->ndev = ndev;return 0 ;@@ -3193,6 +3202,8 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev);struct workqueue_struct *wq; +mlx5_vdpa_remove_debugfs (ndev->debugfs); + ndev->debugfs =NULL ;if (ndev->nb_registered) {mlx5_notifier_unregister (mvdev->mdev, &ndev->nb); ndev->nb_registered = false;drivers/vdpa/mlx5/net/mlx5_vnet.h +2
-0@@ -16,6 +16,7 @@ struct mlx5_vdpa_net_resources {u32 tirn;u32 rqtn;bool valid; +struct dentry *tirn_dent; };#define MLX5V_MACVLAN_SIZE 256@@ -43,6 +44,7 @@ struct mlx5_vdpa_net {struct vdpa_callback config_cb;struct mlx5_vdpa_wq_ent cvq_ent;struct hlist_head macvlan_hash[MLX5V_MACVLAN_SIZE ]; +struct dentry *debugfs; };struct macvlan_node {@@ -52,4 +54,11 @@ struct macvlan_node {u64 macvlan;
drivers/vdpa/mlx5/net/mlx5_vnet.h struct macvlan_node { · line 64
Quoted 10 lines
drivers/vdpa/mlx5/net/mlx5_vnet.h +7
-0}; +void mlx5_vdpa_add_debugfs (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_remove_debugfs (struct dentry *dbg); +void mlx5_vdpa_add_rx_flow_table (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_remove_rx_flow_table (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_add_tirn (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_remove_tirn (struct mlx5_vdpa_net *ndev); +#endif /* __MLX5_VNET_H__ */
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 4/4] vdpa/mlx5: Add RX counters to debugfs
In reply to Eli CohenQuoted 199 lines · Eli Cohen
For each interface, either VLAN tagged or untagged, add two hardware
counters: one for unicast and another for multicast. The counters count RX packets and bytes and can be read through debugfs:$ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/untagged/mcast/packets $ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/untagged/ucast/bytesThis feature is controlled via the config option
MLX5_VDPA_STEERING_DEBUG. It is off by default as it may have some impact on performance.Signed-off-by Eli Cohen<[email protected]>--- drivers/vdpa/Kconfig | 12 ++++ drivers/vdpa/mlx5/net/debug.c | 82 +++++++++++++++++++++++++++ drivers/vdpa/mlx5/net/mlx5_vnet.c | 94 +++++++++++++++++++++++-------- drivers/vdpa/mlx5/net/mlx5_vnet.h | 30 ++++++++++ 4 files changed, 195 insertions(+), 23 deletions(-)drivers/vdpa/Kconfig +12
-0@@ -71,6 +71,18 @@ config MLX5_VDPA_NET be executed by the hardware. It also supports a variety of stateless offloads depending on the actual device used and firmware version. +config MLX5_VDPA_STEERING_DEBUG + bool "expose steering counters on debugfs" + select MLX5_VDPA + help + Expose RX steering counters in debugfs to aid in debugging. For each VLAN + or non VLAN interface, two hardware counters are added to the RX flow + table: one for unicast and one for multicast. + The counters counts the number of packets and bytes and exposes them in + debugfs. Once can read the counters using, e.g.: + cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/untagged/ucast/packets + cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/untagged/mcast/bytes + config VP_VDPA tristate "Virtio PCI bridge vDPA driver" select VIRTIO_PCI_LIBdrivers/vdpa/mlx5/net/debug.c +82
-0@@ -49,6 +49,88 @@ void mlx5_vdpa_add_rx_flow_table(struct mlx5_vdpa_net *ndev) ndev, &rx_flow_table_fops); } +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG ) +static int packets_show (struct seq_file *file,void *priv) +{ +struct mlx5_vdpa_counter *counter = file->private; +u64 packets; +u64 bytes; +int err; + + err =mlx5_fc_query (counter->mdev, counter->counter, &packets, &bytes); +if (err) +return err; + +seq_printf (file,"0x%llx\n" , packets); +return 0 ; +} + +static int bytes_show (struct seq_file *file,void *priv) +{ +struct mlx5_vdpa_counter *counter = file->private; +u64 packets; +u64 bytes; +int err; + + err =mlx5_fc_query (counter->mdev, counter->counter, &packets, &bytes); +if (err) +return err; + +seq_printf (file,"0x%llx\n" , bytes); +return 0 ; +} + +DEFINE_SHOW_ATTRIBUTE (packets); +DEFINE_SHOW_ATTRIBUTE (bytes); + +static void add_counter_node (struct mlx5_vdpa_counter *counter, +struct dentry *parent) +{ +debugfs_create_file ("packets" ,0444 , parent, counter, + &packets_fops); +debugfs_create_file ("bytes" ,0444 , parent, counter, + &bytes_fops); +} + +void mlx5_vdpa_add_rx_counters (struct mlx5_vdpa_net *ndev, +struct macvlan_node *node) +{ +static const char *ut ="untagged" ; +char vidstr[9 ]; +u16 vid; + +if (node->tagged) { + vid =key2vid (node->macvlan); +snprintf (vidstr,sizeof (vidstr),"0x%x" , vid); + }else { +strcpy (vidstr, ut); + } + + node->dent =debugfs_create_dir (vidstr, ndev->rx_dent); +if (IS_ERR (node->dent)) +return ; + + node->ucast_counter.dent =debugfs_create_dir ("ucast" , node->dent); +if (IS_ERR (node->ucast_counter.dent)) +return ; + +add_counter_node (&node->ucast_counter, node->ucast_counter.dent); + + node->mcast_counter.dent =debugfs_create_dir ("mcast" , node->dent); +if (IS_ERR (node->mcast_counter.dent)) +return ; + +add_counter_node (&node->mcast_counter, node->mcast_counter.dent); +} + +void mlx5_vdpa_remove_rx_counters (struct mlx5_vdpa_net *ndev, +struct macvlan_node *node) +{ +if (ndev->debugfs) +debugfs_remove_recursive (node->dent); +} +#endif +void mlx5_vdpa_add_debugfs (struct mlx5_vdpa_net *ndev) {struct mlx5_core_dev *mdev;drivers/vdpa/mlx5/net/mlx5_vnet.c +22
-8@@ -1404,12 +1404,16 @@ static void destroy_tir(struct mlx5_vdpa_net *ndev)#define MAX_STEERING_ENT 0x8000#define MAX_STEERING_GROUPS 2 +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG ) +#define NUM_DESTS 2 +#else +#define NUM_DESTS 1 +#endif +static int mlx5_vdpa_add_mac_vlan_rules (struct mlx5_vdpa_net *ndev,u8 *mac, -u16 vid,bool tagged, -struct mlx5_flow_handle **ucast, -struct mlx5_flow_handle **mcast) +struct macvlan_node *node) { -struct mlx5_flow_destination dest = {}; +struct mlx5_flow_destination dests[NUM_DESTS ] = {};struct mlx5_flow_act flow_act = {};struct mlx5_flow_handle *rule;struct mlx5_flow_spec *spec;@@ -1418,11 +1422,13 @@ static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac,u8 *dmac_c;u8 *dmac_v;int err; +u16 vid; spec =kvzalloc (sizeof (*spec),GFP_KERNEL );if (!spec)return -ENOMEM ; + vid =key2vid (node->macvlan); spec->match_criteria_enable =MLX5_MATCH_OUTER_HEADERS ; headers_c =MLX5_ADDR_OF (fte_match_param, spec->match_criteria, outer_headers); headers_v =MLX5_ADDR_OF (fte_match_param, spec->match_value, outer_headers);@@ -1431,45 +1437,78 @@ static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac,eth_broadcast_addr (dmac_c);ether_addr_copy (dmac_v, mac);MLX5_SET (fte_match_set_lyr_2_4, headers_c, cvlan_tag,1 ); -if (tagged) { +if (node->tagged) {MLX5_SET (fte_match_set_lyr_2_4, headers_v, cvlan_tag,1 );MLX5_SET_TO_ONES (fte_match_set_lyr_2_4, headers_c, first_vid);MLX5_SET (fte_match_set_lyr_2_4, headers_v, first_vid, vid); } flow_act.action =MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ; - dest.type =MLX5_FLOW_DESTINATION_TYPE_TIR ; - dest.tir_num = ndev->res.tirn; - rule =mlx5_add_flow_rules (ndev->rxft, spec, &flow_act, &dest,1 ); + dests[0 ].type =MLX5_FLOW_DESTINATION_TYPE_TIR ; + dests[0 ].tir_num = ndev->res.tirn; +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG ) + node->ucast_counter.counter =mlx5_fc_create (ndev->mvdev.mdev, false); +if (IS_ERR (node->ucast_counter.counter)) { + err =PTR_ERR (node->ucast_counter.counter); + goto err_ucast_counter; + } + node->mcast_counter.counter =mlx5_fc_create (ndev->mvdev.mdev, false); +if (IS_ERR (node->mcast_counter.counter)) { + err =PTR_ERR (node->mcast_counter.counter);
drivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac, · line 1466
Quoted 10 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +8
-0+ goto err_mcast_counter; + } + + dests[1 ].type =MLX5_FLOW_DESTINATION_TYPE_COUNTER ; + dests[1 ].counter_id =mlx5_fc_id (node->ucast_counter.counter); + flow_act.action |=MLX5_FLOW_CONTEXT_ACTION_COUNT ; +#endif + node->ucast_rule =mlx5_add_flow_rules (ndev->rxft, spec, &flow_act, dests,NUM_DESTS );if (IS_ERR (rule))return PTR_ERR (rule);
There'll be leakage on counters and flow spec if using direct return.
drivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac, · line 1477
Quoted 13 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +4
-2- *ucast = rule; +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG ) + dests[1 ].counter_id =mlx5_fc_id (node->mcast_counter.counter); +#endif memset (dmac_c,0 ,ETH_ALEN );memset (dmac_v,0 ,ETH_ALEN ); dmac_c[0 ] =1 ; dmac_v[0 ] =1 ; - rule =mlx5_add_flow_rules (ndev->rxft, spec, &flow_act, &dest,1 ); + node->mcast_rule =mlx5_add_flow_rules (ndev->rxft, spec, &flow_act, dests,NUM_DESTS );kvfree (spec);
Move kvfree a couple of lines under (after the IS_ERR check).
Quoted 8 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +2
-1if (IS_ERR (rule)) { err =PTR_ERR (rule); goto err_mcast; } - *mcast = rule; +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG ) + node->ucast_counter.mdev = ndev->mvdev.mdev;
drivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac, · line 1493
Quoted 10 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +6
-1+ node->mcast_counter.mdev = ndev->mvdev.mdev; +#endif +mlx5_vdpa_add_rx_counters (ndev, node); +return 0 ; err_mcast: -mlx5_del_flow_rules (*ucast); +mlx5_del_flow_rules (node->ucast_rule); +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG )
No corresponding mlx5_fc_destroy() for mcast_counter.
drivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac, · line 1497
Quoted 4 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +4
-0+err_mcast_counter: +mlx5_fc_destroy (ndev->mvdev.mdev, node->ucast_counter.counter); +err_ucast_counter: +kfree (spec);
kvfree?
Regards,
-Siwei
Quoted 130 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +25
-11+#endif return err; }static void mlx5_vdpa_del_mac_vlan_rules (struct mlx5_vdpa_net *ndev, -struct mlx5_flow_handle *ucast, -struct mlx5_flow_handle *mcast) +struct macvlan_node *node) { -mlx5_del_flow_rules (ucast); -mlx5_del_flow_rules (mcast); +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG ) +if (node->dent && !IS_ERR (node->dent)) +mlx5_vdpa_remove_rx_counters (ndev, node); +#endif + +mlx5_del_flow_rules (node->ucast_rule); +mlx5_del_flow_rules (node->mcast_rule); }static u64 search_val (u8 *mac,u16 vlan,bool tagged)@@ -1503,14 +1542,14 @@ static struct macvlan_node *mac_vlan_lookup(struct mlx5_vdpa_net *ndev, u64 valureturn NULL ; } -static int mac_vlan_add (struct mlx5_vdpa_net *ndev,u8 *mac,u16 vlan,bool tagged)// vlan -> vid +static int mac_vlan_add (struct mlx5_vdpa_net *ndev,u8 *mac,u16 vid,bool tagged) {struct macvlan_node *ptr;u64 val;u32 idx;int err; - val =search_val (mac, vlan, tagged); + val =search_val (mac, vid, tagged);if (mac_vlan_lookup (ndev, val))return -EEXIST ;@@ -1518,12 +1557,13 @@ static int mac_vlan_add(struct mlx5_vdpa_net *ndev, u8 *mac, u16 vlan, bool taggif (!ptr)return -ENOMEM ; - err =mlx5_vdpa_add_mac_vlan_rules (ndev, ndev->config.mac, vlan, tagged, - &ptr->ucast_rule, &ptr->mcast_rule); + ptr->tagged = tagged; + ptr->macvlan = val; + ptr->ndev = ndev; + err =mlx5_vdpa_add_mac_vlan_rules (ndev, ndev->config.mac, ptr);if (err) goto err_add; - ptr->macvlan = val; idx =hash_64 (val,8 );hlist_add_head (&ptr->hlist, &ndev->macvlan_hash[idx]);return 0 ;@@ -1542,7 +1582,11 @@ static void mac_vlan_del(struct mlx5_vdpa_net *ndev, u8 *mac, u16 vlan, bool tagreturn ;hlist_del (&ptr->hlist); -mlx5_vdpa_del_mac_vlan_rules (ndev, ptr->ucast_rule, ptr->mcast_rule); +mlx5_vdpa_del_mac_vlan_rules (ndev, ptr); +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG ) +mlx5_fc_destroy (ndev->mvdev.mdev, ptr->mcast_counter.counter); +mlx5_fc_destroy (ndev->mvdev.mdev, ptr->ucast_counter.counter); +#endif kfree (ptr); }@@ -1555,7 +1599,11 @@ static void clear_mac_vlan_table(struct mlx5_vdpa_net *ndev)for (i =0 ; i <MLX5V_MACVLAN_SIZE ; i++) {hlist_for_each_entry_safe (pos, n, &ndev->macvlan_hash[i], hlist) {hlist_del (&pos->hlist); -mlx5_vdpa_del_mac_vlan_rules (ndev, pos->ucast_rule, pos->mcast_rule); +mlx5_vdpa_del_mac_vlan_rules (ndev, pos); +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG ) +mlx5_fc_destroy (ndev->mvdev.mdev, pos->mcast_counter.counter); +mlx5_fc_destroy (ndev->mvdev.mdev, pos->ucast_counter.counter); +#endif kfree (pos); } }drivers/vdpa/mlx5/net/mlx5_vnet.h +22
-0@@ -21,6 +21,11 @@ struct mlx5_vdpa_net_resources {#define MLX5V_MACVLAN_SIZE 256 +static inline u16 key2vid (u64 key) +{ +return (u16)(key >>48 ); +} +struct mlx5_vdpa_net {struct mlx5_vdpa_dev mvdev;struct mlx5_vdpa_net_resources res;@@ -47,11 +52,24 @@ struct mlx5_vdpa_net {struct dentry *debugfs; }; +struct mlx5_vdpa_counter { +struct mlx5_fc *counter; +struct dentry *dent; +struct mlx5_core_dev *mdev; +}; +struct macvlan_node {struct hlist_node hlist;struct mlx5_flow_handle *ucast_rule;struct mlx5_flow_handle *mcast_rule;u64 macvlan; +struct mlx5_vdpa_net *ndev; +bool tagged; +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG ) +struct dentry *dent; +struct mlx5_vdpa_counter ucast_counter; +struct mlx5_vdpa_counter mcast_counter; +#endif };void mlx5_vdpa_add_debugfs (struct mlx5_vdpa_net *ndev);@@ -60,5 +78,17 @@ void mlx5_vdpa_add_rx_flow_table(struct mlx5_vdpa_net *ndev);void mlx5_vdpa_remove_rx_flow_table (struct mlx5_vdpa_net *ndev);void mlx5_vdpa_add_tirn (struct mlx5_vdpa_net *ndev);void mlx5_vdpa_remove_tirn (struct mlx5_vdpa_net *ndev); +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG ) +void mlx5_vdpa_add_rx_counters (struct mlx5_vdpa_net *ndev, +struct macvlan_node *node); +void mlx5_vdpa_remove_rx_counters(struct mlx5_vdpa_net *ndev,
drivers/vdpa/mlx5/net/mlx5_vnet.h void mlx5_vdpa_add_rx_flow_table(struct mlx5_vdpa_net *ndev); · line 94
Quoted 10 lines
drivers/vdpa/mlx5/net/mlx5_vnet.h +8
-0+ struct macvlan_node *node); +#else +static inline void mlx5_vdpa_add_rx_counters (struct mlx5_vdpa_net *ndev, +struct macvlan_node *node) {} +static inline void mlx5_vdpa_remove_rx_counters (struct mlx5_vdpa_net *ndev, +struct macvlan_node *node) {} +#endif +#endif /* __MLX5_VNET_H__ */
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 3/4] vdpa/mlx5: Add debugfs subtree
In reply to Eli CohenQuoted 7 lines · Eli Cohen
Add debugfs subtree and expose flow table ID and TIR number. This information can be used by external tools to do extended troubleshooting.
The information can be retrieved like so:
$ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/table_id $ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/tirn
I wonder if we need a config option for this.
And if it's better to use vendor stats.
Thanks
Quoted 186 lines
Signed-off-by Eli Cohen <[email protected]>--- drivers/vdpa/mlx5/Makefile | 2 +- drivers/vdpa/mlx5/net/debug.c | 66 +++++++++++++++++++++++++++++++ drivers/vdpa/mlx5/net/mlx5_vnet.c | 11 ++++++ drivers/vdpa/mlx5/net/mlx5_vnet.h | 9 +++++ 4 files changed, 87 insertions(+), 1 deletion(-)create mode 100644
drivers/vdpa/mlx5/net/debug.cdrivers/vdpa/mlx5/Makefile +1
-1@@ -1,4 +1,4 @@ subdir-ccflags-y += -I$(srctree)/drivers/vdpa/mlx5/core obj-$(CONFIG_MLX5_VDPA_NET) += mlx5_vdpa.o -mlx5_vdpa-$(CONFIG_MLX5_VDPA_NET) += net/mlx5_vnet.o core/resources.o core/mr.o +mlx5_vdpa-$(CONFIG_MLX5_VDPA_NET) += net/mlx5_vnet.o core/resources.o core/mr.o net/debug.odrivers/vdpa/mlx5/net/debug.c new file +66
-0@@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +/* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ + +#include <linux/debugfs.h> +#include <linux/mlx5/fs.h> +#include "mlx5_vnet.h" + +static int tirn_show (struct seq_file *file,void *priv) +{ +struct mlx5_vdpa_net *ndev = file->private; + +seq_printf (file,"0x%x\n" , ndev->res.tirn); +return 0 ; +} + +DEFINE_SHOW_ATTRIBUTE (tirn); + +void mlx5_vdpa_remove_tirn (struct mlx5_vdpa_net *ndev) +{ +if (ndev->debugfs) +debugfs_remove (ndev->res.tirn_dent); +} + +void mlx5_vdpa_add_tirn (struct mlx5_vdpa_net *ndev) +{ + ndev->res.tirn_dent =debugfs_create_file ("tirn" ,0444 , ndev->rx_dent, + ndev, &tirn_fops); +} + +static int rx_flow_table_show (struct seq_file *file,void *priv) +{ +struct mlx5_vdpa_net *ndev = file->private; + +seq_printf (file,"0x%x\n" ,mlx5_flow_table_id (ndev->rxft)); +return 0 ; +} + +DEFINE_SHOW_ATTRIBUTE (rx_flow_table); + +void mlx5_vdpa_remove_rx_flow_table (struct mlx5_vdpa_net *ndev) +{ +if (ndev->debugfs) +debugfs_remove (ndev->rx_table_dent); +} + +void mlx5_vdpa_add_rx_flow_table (struct mlx5_vdpa_net *ndev) +{ + ndev->rx_table_dent =debugfs_create_file ("table_id" ,0444 , ndev->rx_dent, + ndev, &rx_flow_table_fops); +} + +void mlx5_vdpa_add_debugfs (struct mlx5_vdpa_net *ndev) +{ +struct mlx5_core_dev *mdev; + + mdev = ndev->mvdev.mdev; + ndev->debugfs =debugfs_create_dir (dev_name (&ndev->mvdev.vdev.dev), +mlx5_debugfs_get_dev_root (mdev)); +if (!IS_ERR (ndev->debugfs)) + ndev->rx_dent =debugfs_create_dir ("rx" , ndev->debugfs); +} + +void mlx5_vdpa_remove_debugfs (struct dentry *dbg) +{ +debugfs_remove_recursive (dbg); +}drivers/vdpa/mlx5/net/mlx5_vnet.c +11
-0@@ -1388,11 +1388,16 @@ static int create_tir(struct mlx5_vdpa_net *ndev) err =mlx5_vdpa_create_tir (&ndev->mvdev, in, &ndev->res.tirn);kfree (in); +if (err) +return err; + +mlx5_vdpa_add_tirn (ndev);return err; }static void destroy_tir (struct mlx5_vdpa_net *ndev) { +mlx5_vdpa_remove_tirn (ndev);mlx5_vdpa_destroy_tir (&ndev->mvdev, ndev->res.tirn); }@@ -1576,6 +1581,7 @@ static int setup_steering(struct mlx5_vdpa_net *ndev)mlx5_vdpa_warn (&ndev->mvdev,"failed to create flow table\n" );return PTR_ERR (ndev->rxft); } +mlx5_vdpa_add_rx_flow_table (ndev); err =mac_vlan_add (ndev, ndev->config.mac,0 , false);if (err)@@ -1584,6 +1590,7 @@ static int setup_steering(struct mlx5_vdpa_net *ndev)return 0 ; err_add: +mlx5_vdpa_remove_rx_flow_table (ndev);mlx5_destroy_flow_table (ndev->rxft);return err; }@@ -1591,6 +1598,7 @@ static int setup_steering(struct mlx5_vdpa_net *ndev)static void teardown_steering (struct mlx5_vdpa_net *ndev) {clear_mac_vlan_table (ndev); +mlx5_vdpa_remove_rx_flow_table (ndev);mlx5_destroy_flow_table (ndev->rxft); }@@ -3167,6 +3175,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,if (err) goto err_reg; +mlx5_vdpa_add_debugfs (ndev); mgtdev->ndev = ndev;return 0 ;@@ -3193,6 +3202,8 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev);struct workqueue_struct *wq; +mlx5_vdpa_remove_debugfs (ndev->debugfs); + ndev->debugfs =NULL ;if (ndev->nb_registered) {mlx5_notifier_unregister (mvdev->mdev, &ndev->nb); ndev->nb_registered = false;drivers/vdpa/mlx5/net/mlx5_vnet.h +9
-0@@ -16,6 +16,7 @@ struct mlx5_vdpa_net_resources {u32 tirn;u32 rqtn;bool valid; +struct dentry *tirn_dent; };#define MLX5V_MACVLAN_SIZE 256@@ -43,6 +44,7 @@ struct mlx5_vdpa_net {struct vdpa_callback config_cb;struct mlx5_vdpa_wq_ent cvq_ent;struct hlist_head macvlan_hash[MLX5V_MACVLAN_SIZE ]; +struct dentry *debugfs; };struct macvlan_node {@@ -52,4 +54,11 @@ struct macvlan_node { u64 macvlan; }; +void mlx5_vdpa_add_debugfs (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_remove_debugfs (struct dentry *dbg); +void mlx5_vdpa_add_rx_flow_table (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_remove_rx_flow_table (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_add_tirn (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_remove_tirn (struct mlx5_vdpa_net *ndev); +#endif /* __MLX5_VNET_H__ */
RE: [PATCH 1/4] vdpa/mlx5: Fix rule forwarding VLAN to TIR
In reply to Si-Wei LiuQuoted 18 lines
From: Si-Wei Liu <[email protected]>
Sent: Tuesday, 18 October 2022 22:21
To: Eli Cohen <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH 1/4] vdpa/mlx5: Fix rule forwarding VLAN to TIRHi Eli,
It's not for this patch but something related, so just a friendly heads-up. I haven't validated the VLAN tagging behavior yet for mlx5 vdpa, but from my quick read of the code it doesn't seem it differentiates the case with and without
VIRTIO_NET_F_CTRL_VLAN, to be compatible/compliant with what's been implemented in QEMU software (a spec addendum was filed as requested by Michael):
Quoted 9 lines
- when
VIRTIO_NET_F_CTRL_VLANis negotiated, the device starts with all VLANs filtered (meaning only untagged traffic can be received, and traffic with VLAN tag will be dropped).- when
VIRTIO_NET_F_CTRL_VLANis not negotiated, all traffic including untagged and tagged can be received.Can you please help check if we need further fix in terms of VLAN tagging?
Sure. It's broken today. I will fix this to conform to the above requirements and send V1.
Quoted 36 lines
Thanks,
-SiweiQuoted 9 lines · Eli Cohen
Set the VLAN id to the header values field instead of overwriting the headers criteria field.
Before this fix, VLAN filtering would not really work and tagged packets would be forwarded unfiltered to the TIR.
Fixes baf2ad3f6a98 ("vdpa/mlx5: Add RX MAC VLAN filter support")Signed-off-by Eli Cohen <[email protected]>Reviewed-by Si-Wei Liu <[email protected]>Review
Quoted 5 lines
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/vdpa/mlx5/net/mlx5_vnet.cdrivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5_vdpa_add_mac_vlan_rules(struct
Quoted 4 lines
index
90913365def4..dd29fdfc24ed100644drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-0@@ -1472,7 +1472,7 @@ static int mlx5_vdpa_add_mac_vlan_rules(struct
mlx5_vdpa_net*ndev, u8 *mac,drivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac,
Quoted 3 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-0if (tagged) {MLX5_SET (fte_match_set_lyr_2_4, headers_v, cvlan_tag,1 ); MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c,
first_vid);Quoted 5 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-1-MLX5_SET (fte_match_set_lyr_2_4, headers_c, first_vid, vid); +MLX5_SET (fte_match_set_lyr_2_4, headers_v, first_vid, vid); } flow_act.action =MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ; dest.type =MLX5_FLOW_DESTINATION_TYPE_TIR ;
Michael S. Tsirkin
maintainerRe: [PATCH 1/4] vdpa/mlx5: Fix rule forwarding VLAN to TIR
Quoted 22 lines · Eli Cohen
Quoted 22 lines
From: Si-Wei Liu <[email protected]>
Sent: Tuesday, 18 October 2022 22:21
To: Eli Cohen <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH 1/4] vdpa/mlx5: Fix rule forwarding VLAN to TIRHi Eli,
It's not for this patch but something related, so just a friendly heads-up. I haven't validated the VLAN tagging behavior yet for mlx5 vdpa, but from my quick read of the code it doesn't seem it differentiates the case with and without
VIRTIO_NET_F_CTRL_VLAN, to be compatible/compliant with what's been implemented in QEMU software (a spec addendum was filed as requested by Michael):https://github.com/oasis-tcs/virtio-spec/issues/147
- when
VIRTIO_NET_F_CTRL_VLANis negotiated, the device starts with all VLANs filtered (meaning only untagged traffic can be received, and traffic with VLAN tag will be dropped).
Quoted 7 lines
Quoted 5 lines
- when
VIRTIO_NET_F_CTRL_VLANis not negotiated, all traffic including untagged and tagged can be received.Can you please help check if we need further fix in terms of VLAN tagging?
Sure. It's broken today. I will fix this to conform to the above requirements and send V1.
Did you mean v2?
Quoted 30 lines
Quoted 30 lines
Thanks,
-SiweiQuoted 9 lines · Eli Cohen
Set the VLAN id to the header values field instead of overwriting the headers criteria field.
Before this fix, VLAN filtering would not really work and tagged packets would be forwarded unfiltered to the TIR.
Fixes baf2ad3f6a98 ("vdpa/mlx5: Add RX MAC VLAN filter support")Signed-off-by Eli Cohen <[email protected]>Reviewed-by Si-Wei Liu <[email protected]>Review
Quoted 5 lines
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/vdpa/mlx5/net/mlx5_vnet.cdrivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5_vdpa_add_mac_vlan_rules(struct
Quoted 4 lines
index
90913365def4..dd29fdfc24ed100644drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-0@@ -1472,7 +1472,7 @@ static int mlx5_vdpa_add_mac_vlan_rules(struct
mlx5_vdpa_net*ndev, u8 *mac,Quoted 3 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-0if (tagged) {MLX5_SET (fte_match_set_lyr_2_4, headers_v, cvlan_tag,1 ); MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c,
Quoted 7 lines
Quoted 6 lines
first_vid);drivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac, · line 1478
Quoted 5 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-1-MLX5_SET (fte_match_set_lyr_2_4, headers_c, first_vid, vid); +MLX5_SET (fte_match_set_lyr_2_4, headers_v, first_vid, vid); } flow_act.action =MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ; dest.type =MLX5_FLOW_DESTINATION_TYPE_TIR ;
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
RE: [PATCH 1/4] vdpa/mlx5: Fix rule forwarding VLAN to TIR
Quoted 34 lines
From: Michael S. Tsirkin <[email protected]>
Sent: Wednesday, 19 October 2022 8:34
To: Eli Cohen <[email protected]>
Cc: Si-Wei Liu <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/4] vdpa/mlx5: Fix rule forwarding VLAN to TIRQuoted 25 lines · Eli Cohen
Quoted 25 lines
From: Si-Wei Liu <[email protected]>
Sent: Tuesday, 18 October 2022 22:21
To: Eli Cohen <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH 1/4] vdpa/mlx5: Fix rule forwarding VLAN to TIRHi Eli,
It's not for this patch but something related, so just a friendly heads-up. I haven't validated the VLAN tagging behavior yet for mlx5 vdpa, but from my quick read of the code it doesn't seem it differentiates the case with and without
VIRTIO_NET_F_CTRL_VLAN, to be compatible/compliant with what's been implemented in QEMU software (a spec addendum was filed as requested by Michael):https://github.com/oasis-tcs/virtio-spec/issues/147
- when
VIRTIO_NET_F_CTRL_VLANis negotiated, the device starts with all VLANs filtered (meaning only untagged traffic can be received, and traffic with VLAN tag will be dropped).- when
VIRTIO_NET_F_CTRL_VLANis not negotiated, all traffic including untagged and tagged can be received.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Can you please help check if we need further fix in terms of VLAN tagging?
Sure. It's broken today. I will fix this to conform to the above requirements
and send V1.
Did you mean v2?
I count from 0 and have been following this scheme but I can make it v2 if that's the norm.
Quoted 38 lines
Quoted 20 lines
Quoted 20 lines
Thanks,
-SiweiQuoted 9 lines · Eli Cohen
Set the VLAN id to the header values field instead of overwriting the headers criteria field.
Before this fix, VLAN filtering would not really work and tagged packets would be forwarded unfiltered to the TIR.
Fixes baf2ad3f6a98 ("vdpa/mlx5: Add RX MAC VLAN filter support")Signed-off-by Eli Cohen <[email protected]>Reviewed-by Si-Wei Liu <[email protected]>Quoted 4 lines
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 6 lines
Quoted 6 lines
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/vdpa/mlx5/net/mlx5_vnet.cdrivers/vdpa/mlx5/net/mlx5_vnet.c static int
Quoted 4 lines
index
90913365def4..dd29fdfc24ed100644drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-0@@ -1472,7 +1472,7 @@ static intmlx5_vdpa_add_mac_vlan_rules(struct
Quoted 11 lines
Quoted 10 lines
mlx5_vdpa_net*ndev, u8 *mac,drivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac,
Quoted 3 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-0if (tagged) {MLX5_SET (fte_match_set_lyr_2_4, headers_v, cvlan_tag,1 ); MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c,
first_vid);Quoted 5 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-1-MLX5_SET (fte_match_set_lyr_2_4, headers_c, first_vid, vid); +MLX5_SET (fte_match_set_lyr_2_4, headers_v, first_vid, vid); } flow_act.action =MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ; dest.type =MLX5_FLOW_DESTINATION_TYPE_TIR ;
RE: [PATCH 3/4] vdpa/mlx5: Add debugfs subtree
In reply to Jason WangQuoted 13 lines
From: Jason Wang <[email protected]>
Sent: Wednesday, 19 October 2022 8:14
To: Eli Cohen <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 3/4] vdpa/mlx5: Add debugfs subtreeQuoted 4 lines · Eli Cohen
Add debugfs subtree and expose flow table ID and TIR number. This information can be used by external tools to do extended troubleshooting.
Quoted 9 lines
Quoted 3 lines
The information can be retrieved like so:
$ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/table_id $ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/tirnI wonder if we need a config option for this.
And if it's better to use vendor stats.
I am not sure. TIRs and flow tables has loose association VDPA. I would keep it in debugfs which for mlx5 there's lots of other information there.
Quoted 206 lines
Thanks
Quoted 5 lines
Signed-off-by Eli Cohen <[email protected]>--- drivers/vdpa/mlx5/Makefile | 2 +- drivers/vdpa/mlx5/net/debug.c | 66+++++++++++++++++++++++++++++++
Quoted 10 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c | 11 ++++++ drivers/vdpa/mlx5/net/mlx5_vnet.h | 9 +++++ 4 files changed, 87 insertions(+), 1 deletion(-)create mode 100644
drivers/vdpa/mlx5/net/debug.cdrivers/vdpa/mlx5/Makefile +0
-0drivers/vdpa/mlx5/Makefile line 4
Quoted 4 lines
drivers/vdpa/mlx5/Makefile +0
-1@@ -1,4 +1,4 @@ subdir-ccflags-y += -I$(srctree)/drivers/vdpa/mlx5/core obj-$(CONFIG_MLX5_VDPA_NET) += mlx5_vdpa.o -mlx5_vdpa-$(CONFIG_MLX5_VDPA_NET) += net/mlx5_vnet.o
core/resources.ocore/mr.odrivers/vdpa/mlx5/Makefile line 4
Quoted 1 line
drivers/vdpa/mlx5/Makefile +1
-0+mlx5_vdpa-$(CONFIG_MLX5_VDPA_NET) += net/mlx5_vnet.o
core/resources.ocore/mr.onet/debug.odrivers/vdpa/mlx5/net/debug.c line 2
Quoted 8 lines
drivers/vdpa/mlx5/net/debug.c new file +2
-0@@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +/* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
Quoted 57 lines
drivers/vdpa/mlx5/net/debug.c new file +24
-0+ +#include <linux/debugfs.h> +#include <linux/mlx5/fs.h> +#include "mlx5_vnet.h" + +static int tirn_show (struct seq_file *file,void *priv) +{ +struct mlx5_vdpa_net *ndev = file->private; + +seq_printf (file,"0x%x\n" , ndev->res.tirn); +return 0 ; +} + +DEFINE_SHOW_ATTRIBUTE (tirn); + +void mlx5_vdpa_remove_tirn (struct mlx5_vdpa_net *ndev) +{ +if (ndev->debugfs) +debugfs_remove (ndev->res.tirn_dent); +} + +void mlx5_vdpa_add_tirn (struct mlx5_vdpa_net *ndev) +{ + ndev->res.tirn_dent = debugfs_create_file("tirn", 0444, ndev-
rx_dent,drivers/vdpa/mlx5/net/debug.c new file +22
-0+ ndev, &tirn_fops); +} + +static int rx_flow_table_show (struct seq_file *file,void *priv) +{ +struct mlx5_vdpa_net *ndev = file->private; + +seq_printf (file,"0x%x\n" ,mlx5_flow_table_id (ndev->rxft)); +return 0 ; +} + +DEFINE_SHOW_ATTRIBUTE (rx_flow_table); + +void mlx5_vdpa_remove_rx_flow_table (struct mlx5_vdpa_net *ndev) +{ +if (ndev->debugfs) +debugfs_remove (ndev->rx_table_dent); +} + +void mlx5_vdpa_add_rx_flow_table (struct mlx5_vdpa_net *ndev) +{ + ndev->rx_table_dent = debugfs_create_file("table_id", 0444, ndev-
rx_dent,drivers/vdpa/mlx5/net/debug.c new file +9
-0+ ndev, &rx_flow_table_fops); +} + +void mlx5_vdpa_add_debugfs (struct mlx5_vdpa_net *ndev) +{ +struct mlx5_core_dev *mdev; + + mdev = ndev->mvdev.mdev; + ndev->debugfs = debugfs_create_dir(dev_name(&ndev-Quoted 2 lines
mvdev.vdev.dev),
+
mlx5_debugfs_get_dev_root(mdev));Review
Quoted 9 lines
drivers/vdpa/mlx5/net/debug.c new file +8
-0+if (!IS_ERR (ndev->debugfs)) + ndev->rx_dent =debugfs_create_dir ("rx" , ndev->debugfs); +} + +void mlx5_vdpa_remove_debugfs (struct dentry *dbg) +{ +debugfs_remove_recursive (dbg); +}(quoted diff) +0
-0
b/drivers/vdpa/mlx5/net/mlx5_vnet.cdrivers/vdpa/mlx5/net/mlx5_vnet.c static int create_tir(struct mlx5_vdpa_net
Quoted 4 lines
index
64fdb940380f..ee50da33e25b100644drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-0@@ -1388,11 +1388,16 @@ static int create_tir(struct mlx5_vdpa_net*ndev)
drivers/vdpa/mlx5/net/mlx5_vnet.c static int setup_steering(struct mlx5_vdpa_net
Quoted 17 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +5
-0err =mlx5_vdpa_create_tir (&ndev->mvdev, in, &ndev->res.tirn);kfree (in); +if (err) +return err; + +mlx5_vdpa_add_tirn (ndev);return err; }static void destroy_tir (struct mlx5_vdpa_net *ndev) { +mlx5_vdpa_remove_tirn (ndev);mlx5_vdpa_destroy_tir (&ndev->mvdev, ndev->res.tirn); }@@ -1576,6 +1581,7 @@ static int setup_steering(struct mlx5_vdpa_net*ndev)
drivers/vdpa/mlx5/net/mlx5_vnet.c static int setup_steering(struct mlx5_vdpa_net · line 1581
Quoted 1 line
drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-0mlx5_vdpa_warn(&ndev->mvdev, "failed to create flowtable\n");
drivers/vdpa/mlx5/net/mlx5_vnet.c static int setup_steering(struct mlx5_vdpa_net
Quoted 7 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-0return PTR_ERR (ndev->rxft); } +mlx5_vdpa_add_rx_flow_table (ndev); err =mac_vlan_add (ndev, ndev->config.mac,0 , false);if (err)@@ -1584,6 +1590,7 @@ static int setup_steering(struct mlx5_vdpa_net*ndev)
drivers/vdpa/mlx5/net/mlx5_vnet.c static int setup_steering(struct mlx5_vdpa_net
Quoted 8 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-0return 0 ; err_add: +mlx5_vdpa_remove_rx_flow_table (ndev);mlx5_destroy_flow_table (ndev->rxft);return err; }@@ -1591,6 +1598,7 @@ static int setup_steering(struct mlx5_vdpa_net*ndev)
drivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5_vdpa_dev_add(struct
Quoted 8 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-0static void teardown_steering (struct mlx5_vdpa_net *ndev) {clear_mac_vlan_table (ndev); +mlx5_vdpa_remove_rx_flow_table (ndev);mlx5_destroy_flow_table (ndev->rxft); }@@ -3167,6 +3175,7 @@ static int mlx5_vdpa_dev_add(struct
vdpa_mgmt_dev*v_mdev, const char *name,drivers/vdpa/mlx5/net/mlx5_vnet.c static void mlx5_vdpa_dev_del(struct
Quoted 8 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-0if (err) goto err_reg; +mlx5_vdpa_add_debugfs (ndev); mgtdev->ndev = ndev;return 0 ;@@ -3193,6 +3202,8 @@ static void mlx5_vdpa_dev_del(struct
vdpa_mgmt_dev*v_mdev, structvdpa_device*Review
Quoted 9 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +2
-0struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev);struct workqueue_struct *wq; +mlx5_vdpa_remove_debugfs (ndev->debugfs); + ndev->debugfs =NULL ;if (ndev->nb_registered) {mlx5_notifier_unregister (mvdev->mdev, &ndev->nb); ndev->nb_registered = false;(quoted diff) +0
-0
b/drivers/vdpa/mlx5/net/mlx5_vnet.hQuoted 31 lines
index
6691c879a6ca..f2cef3925e5b100644drivers/vdpa/mlx5/net/mlx5_vnet.h +9
-0@@ -16,6 +16,7 @@ struct mlx5_vdpa_net_resources {u32 tirn;u32 rqtn;bool valid; +struct dentry *tirn_dent; };#define MLX5V_MACVLAN_SIZE 256@@ -43,6 +44,7 @@ struct mlx5_vdpa_net {struct vdpa_callback config_cb;struct mlx5_vdpa_wq_ent cvq_ent;struct hlist_head macvlan_hash[MLX5V_MACVLAN_SIZE ]; +struct dentry *debugfs; };struct macvlan_node {@@ -52,4 +54,11 @@ struct macvlan_node { u64 macvlan; }; +void mlx5_vdpa_add_debugfs (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_remove_debugfs (struct dentry *dbg); +void mlx5_vdpa_add_rx_flow_table (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_remove_rx_flow_table (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_add_tirn (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_remove_tirn (struct mlx5_vdpa_net *ndev); +#endif /* __MLX5_VNET_H__ */
Michael S. Tsirkin
maintainerRe: [PATCH 1/4] vdpa/mlx5: Fix rule forwarding VLAN to TIR
In reply to Eli CohenQuoted 37 lines · Eli Cohen
Quoted 37 lines
From: Michael S. Tsirkin <[email protected]>
Sent: Wednesday, 19 October 2022 8:34
To: Eli Cohen <[email protected]>
Cc: Si-Wei Liu <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/4] vdpa/mlx5: Fix rule forwarding VLAN to TIRQuoted 28 lines · Eli Cohen
Quoted 27 lines
From: Si-Wei Liu <[email protected]>
Sent: Tuesday, 18 October 2022 22:21
To: Eli Cohen <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH 1/4] vdpa/mlx5: Fix rule forwarding VLAN to TIRHi Eli,
It's not for this patch but something related, so just a friendly heads-up. I haven't validated the VLAN tagging behavior yet for mlx5 vdpa, but from my quick read of the code it doesn't seem it differentiates the case with and without
VIRTIO_NET_F_CTRL_VLAN, to be compatible/compliant with what's been implemented in QEMU software (a spec addendum was filed as requested by Michael):https://github.com/oasis-tcs/virtio-spec/issues/147
- when
VIRTIO_NET_F_CTRL_VLANis negotiated, the device starts with all VLANs filtered (meaning only untagged traffic can be received, and traffic with VLAN tag will be dropped).- when
VIRTIO_NET_F_CTRL_VLANis not negotiated, all traffic including untagged and tagged can be received.Can you please help check if we need further fix in terms of VLAN tagging?
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Sure. It's broken today. I will fix this to conform to the above requirements
and send V1.
Did you mean v2?
I count from 0 and have been following this scheme but I can make it v2 if that's the norm.
Yes, most people seem to count patches from 1 so [PATCH] is followed by [PATCH v2]. I don't know why. But it doesn't matter much - I just wanted to understand whether you will be sending a new version of this patchset. I know now.
Quoted 31 lines
Quoted 31 lines
Quoted 20 lines
Quoted 20 lines
Thanks,
-SiweiQuoted 9 lines · Eli Cohen
Set the VLAN id to the header values field instead of overwriting the headers criteria field.
Before this fix, VLAN filtering would not really work and tagged packets would be forwarded unfiltered to the TIR.
Fixes baf2ad3f6a98 ("vdpa/mlx5: Add RX MAC VLAN filter support")Signed-off-by Eli Cohen <[email protected]>Reviewed-by Si-Wei Liu <[email protected]>Quoted 4 lines
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 6 lines
Quoted 6 lines
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/vdpa/mlx5/net/mlx5_vnet.cdrivers/vdpa/mlx5/net/mlx5_vnet.c static int
Quoted 4 lines
index
90913365def4..dd29fdfc24ed100644drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-0@@ -1472,7 +1472,7 @@ static intmlx5_vdpa_add_mac_vlan_rules(struct
Quoted 4 lines
Quoted 4 lines
mlx5_vdpa_net*ndev, u8 *mac,Quoted 3 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-0if (tagged) {MLX5_SET (fte_match_set_lyr_2_4, headers_v, cvlan_tag,1 ); MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c,
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
first_vid);drivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac, · line 1478
Quoted 5 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-1-MLX5_SET (fte_match_set_lyr_2_4, headers_c, first_vid, vid); +MLX5_SET (fte_match_set_lyr_2_4, headers_v, first_vid, vid); } flow_act.action =MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ; dest.type =MLX5_FLOW_DESTINATION_TYPE_TIR ;
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 3/4] vdpa/mlx5: Add debugfs subtree
In reply to Eli CohenQuoted 19 lines · Eli Cohen
Quoted 19 lines
From: Jason Wang <[email protected]>
Sent: Wednesday, 19 October 2022 8:14
To: Eli Cohen <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 3/4] vdpa/mlx5: Add debugfs subtreeQuoted 7 lines · Eli Cohen
Add debugfs subtree and expose flow table ID and TIR number. This information can be used by external tools to do extended troubleshooting.
The information can be retrieved like so:
$ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/table_id $ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/tirn
Quoted 7 lines
Quoted 4 lines
I wonder if we need a config option for this.
And if it's better to use vendor stats.
I am not sure. TIRs and flow tables has loose association VDPA. I would keep it in debugfs which for mlx5 there's lots of other information there.
That's fine.
Thanks
Quoted 208 lines
Quoted 207 lines
Thanks
Quoted 5 lines
Signed-off-by Eli Cohen <[email protected]>--- drivers/vdpa/mlx5/Makefile | 2 +- drivers/vdpa/mlx5/net/debug.c | 66+++++++++++++++++++++++++++++++
Quoted 10 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c | 11 ++++++ drivers/vdpa/mlx5/net/mlx5_vnet.h | 9 +++++ 4 files changed, 87 insertions(+), 1 deletion(-)create mode 100644
drivers/vdpa/mlx5/net/debug.cdrivers/vdpa/mlx5/Makefile +0
-0drivers/vdpa/mlx5/Makefile line 4
Quoted 4 lines
drivers/vdpa/mlx5/Makefile +0
-1@@ -1,4 +1,4 @@ subdir-ccflags-y += -I$(srctree)/drivers/vdpa/mlx5/core obj-$(CONFIG_MLX5_VDPA_NET) += mlx5_vdpa.o -mlx5_vdpa-$(CONFIG_MLX5_VDPA_NET) += net/mlx5_vnet.o
core/resources.ocore/mr.odrivers/vdpa/mlx5/Makefile line 4
Quoted 1 line
drivers/vdpa/mlx5/Makefile +1
-0+mlx5_vdpa-$(CONFIG_MLX5_VDPA_NET) += net/mlx5_vnet.o
core/resources.ocore/mr.onet/debug.odrivers/vdpa/mlx5/net/debug.c line 2
Quoted 8 lines
drivers/vdpa/mlx5/net/debug.c new file +2
-0@@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +/* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
Quoted 57 lines
drivers/vdpa/mlx5/net/debug.c new file +24
-0+ +#include <linux/debugfs.h> +#include <linux/mlx5/fs.h> +#include "mlx5_vnet.h" + +static int tirn_show (struct seq_file *file,void *priv) +{ +struct mlx5_vdpa_net *ndev = file->private; + +seq_printf (file,"0x%x\n" , ndev->res.tirn); +return 0 ; +} + +DEFINE_SHOW_ATTRIBUTE (tirn); + +void mlx5_vdpa_remove_tirn (struct mlx5_vdpa_net *ndev) +{ +if (ndev->debugfs) +debugfs_remove (ndev->res.tirn_dent); +} + +void mlx5_vdpa_add_tirn (struct mlx5_vdpa_net *ndev) +{ + ndev->res.tirn_dent = debugfs_create_file("tirn", 0444, ndev-
rx_dent,drivers/vdpa/mlx5/net/debug.c new file +22
-0+ ndev, &tirn_fops); +} + +static int rx_flow_table_show (struct seq_file *file,void *priv) +{ +struct mlx5_vdpa_net *ndev = file->private; + +seq_printf (file,"0x%x\n" ,mlx5_flow_table_id (ndev->rxft)); +return 0 ; +} + +DEFINE_SHOW_ATTRIBUTE (rx_flow_table); + +void mlx5_vdpa_remove_rx_flow_table (struct mlx5_vdpa_net *ndev) +{ +if (ndev->debugfs) +debugfs_remove (ndev->rx_table_dent); +} + +void mlx5_vdpa_add_rx_flow_table (struct mlx5_vdpa_net *ndev) +{ + ndev->rx_table_dent = debugfs_create_file("table_id", 0444, ndev-
rx_dent,drivers/vdpa/mlx5/net/debug.c new file +9
-0+ ndev, &rx_flow_table_fops); +} + +void mlx5_vdpa_add_debugfs (struct mlx5_vdpa_net *ndev) +{ +struct mlx5_core_dev *mdev; + + mdev = ndev->mvdev.mdev; + ndev->debugfs = debugfs_create_dir(dev_name(&ndev-Quoted 2 lines
mvdev.vdev.dev),
+
mlx5_debugfs_get_dev_root(mdev));Review
Quoted 9 lines
drivers/vdpa/mlx5/net/debug.c new file +8
-0+if (!IS_ERR (ndev->debugfs)) + ndev->rx_dent =debugfs_create_dir ("rx" , ndev->debugfs); +} + +void mlx5_vdpa_remove_debugfs (struct dentry *dbg) +{ +debugfs_remove_recursive (dbg); +}(quoted diff) +0
-0
b/drivers/vdpa/mlx5/net/mlx5_vnet.cdrivers/vdpa/mlx5/net/mlx5_vnet.c static int create_tir(struct mlx5_vdpa_net
Quoted 4 lines
index
64fdb940380f..ee50da33e25b100644drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-0@@ -1388,11 +1388,16 @@ static int create_tir(struct mlx5_vdpa_net*ndev)
drivers/vdpa/mlx5/net/mlx5_vnet.c static int setup_steering(struct mlx5_vdpa_net
Quoted 17 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +5
-0err =mlx5_vdpa_create_tir (&ndev->mvdev, in, &ndev->res.tirn);kfree (in); +if (err) +return err; + +mlx5_vdpa_add_tirn (ndev);return err; }static void destroy_tir (struct mlx5_vdpa_net *ndev) { +mlx5_vdpa_remove_tirn (ndev);mlx5_vdpa_destroy_tir (&ndev->mvdev, ndev->res.tirn); }@@ -1576,6 +1581,7 @@ static int setup_steering(struct mlx5_vdpa_net*ndev)
drivers/vdpa/mlx5/net/mlx5_vnet.c static int setup_steering(struct mlx5_vdpa_net · line 1581
Quoted 1 line
drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-0mlx5_vdpa_warn(&ndev->mvdev, "failed to create flowtable\n");
drivers/vdpa/mlx5/net/mlx5_vnet.c static int setup_steering(struct mlx5_vdpa_net
Quoted 7 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-0return PTR_ERR (ndev->rxft); } +mlx5_vdpa_add_rx_flow_table (ndev); err =mac_vlan_add (ndev, ndev->config.mac,0 , false);if (err)@@ -1584,6 +1590,7 @@ static int setup_steering(struct mlx5_vdpa_net*ndev)
drivers/vdpa/mlx5/net/mlx5_vnet.c static int setup_steering(struct mlx5_vdpa_net
Quoted 8 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-0return 0 ; err_add: +mlx5_vdpa_remove_rx_flow_table (ndev);mlx5_destroy_flow_table (ndev->rxft);return err; }@@ -1591,6 +1598,7 @@ static int setup_steering(struct mlx5_vdpa_net*ndev)
drivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5_vdpa_dev_add(struct
Quoted 8 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-0static void teardown_steering (struct mlx5_vdpa_net *ndev) {clear_mac_vlan_table (ndev); +mlx5_vdpa_remove_rx_flow_table (ndev);mlx5_destroy_flow_table (ndev->rxft); }@@ -3167,6 +3175,7 @@ static int mlx5_vdpa_dev_add(struct
vdpa_mgmt_dev*v_mdev, const char *name,drivers/vdpa/mlx5/net/mlx5_vnet.c static void mlx5_vdpa_dev_del(struct
Quoted 8 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-0if (err) goto err_reg; +mlx5_vdpa_add_debugfs (ndev); mgtdev->ndev = ndev;return 0 ;@@ -3193,6 +3202,8 @@ static void mlx5_vdpa_dev_del(struct
vdpa_mgmt_dev*v_mdev, structvdpa_device*Review
Quoted 9 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +2
-0struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev);struct workqueue_struct *wq; +mlx5_vdpa_remove_debugfs (ndev->debugfs); + ndev->debugfs =NULL ;if (ndev->nb_registered) {mlx5_notifier_unregister (mvdev->mdev, &ndev->nb); ndev->nb_registered = false;(quoted diff) +0
-0
b/drivers/vdpa/mlx5/net/mlx5_vnet.hQuoted 31 lines
index
6691c879a6ca..f2cef3925e5b100644drivers/vdpa/mlx5/net/mlx5_vnet.h +9
-0@@ -16,6 +16,7 @@ struct mlx5_vdpa_net_resources {u32 tirn;u32 rqtn;bool valid; +struct dentry *tirn_dent; };#define MLX5V_MACVLAN_SIZE 256@@ -43,6 +44,7 @@ struct mlx5_vdpa_net {struct vdpa_callback config_cb;struct mlx5_vdpa_wq_ent cvq_ent;struct hlist_head macvlan_hash[MLX5V_MACVLAN_SIZE ]; +struct dentry *debugfs; };struct macvlan_node {@@ -52,4 +54,11 @@ struct macvlan_node { u64 macvlan; }; +void mlx5_vdpa_add_debugfs (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_remove_debugfs (struct dentry *dbg); +void mlx5_vdpa_add_rx_flow_table (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_remove_rx_flow_table (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_add_tirn (struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_remove_tirn (struct mlx5_vdpa_net *ndev); +#endif /* __MLX5_VNET_H__ */