vdpa:/mlx5: Add debugfs subtree
Subsystems (2)
v2 cover vdpa:/mlx5: Add debugfs subtree
First patch fixes a copy paste error causing VLAN tagged packets to no be filtered.In addition it modifies the logic so VLAN filtering is enforced only if VIRTIO_NET_F_CTRL_VLAN is negotiated.
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.
v1->v2:
1. Enforce VLAN filtering onl if VIRTIO_NET_F_CTRL_VLAN is negotiated.
2. Error flow cleanups.
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 | 152 +++++++++++++++++++++++++ drivers/vdpa/mlx5/net/mlx5_vnet.c | 181 ++++++++++++++++++------------ drivers/vdpa/mlx5/net/mlx5_vnet.h | 94 ++++++++++++++++ 5 files changed, 366 insertions(+), 75 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 v2 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.
In addition modify the logic so that VLAN filtering is enforced only when VIRTIO_NET_F_CTRL_VLAN is negotiated. When not negotiated, all incoming traffic is accepted as long as it is targeting the net device's MAC address.
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +8 -3
@@ -1468,11 +1468,13 @@ static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac, dmac_v =MLX5_ADDR_OF (fte_match_param, headers_v, outer_headers.dmac_47_16);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 (ndev->mvdev.actual_features &VIRTIO_NET_F_CTRL_VLAN ) { +MLX5_SET (fte_match_set_lyr_2_4, headers_c, cvlan_tag,1 ); +MLX5_SET_TO_ONES (fte_match_set_lyr_2_4, headers_c, first_vid); + }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 ;
@@ -1821,6 +1823,9 @@ static virtio_net_ctrl_ack handle_ctrl_vlan(struct mlx5_vdpa_dev *mvdev, u8 cmd)size_t read;u16 id; +if (!(ndev->mvdev.actual_features &VIRTIO_NET_F_CTRL_VLAN )) +return status; +switch (cmd) {case VIRTIO_NET_CTRL_VLAN_ADD : read =vringh_iov_pull_iotlb (&cvq->vring, &cvq->riov, &vlan,sizeof (vlan));
Signature · 1 line
2.35.1
PATCH v2 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.
Issue: 3214718
--- 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 v2 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
Issue: 3214718
--- 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); }
@@ -1578,6 +1583,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)
@@ -1586,6 +1592,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; }
@@ -1593,6 +1600,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); }
@@ -3172,6 +3180,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 ;
@@ -3198,6 +3207,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
PATCH v2 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.
Issue: 3214718
--- drivers/vdpa/Kconfig | 12 ++++ drivers/vdpa/mlx5/net/debug.c | 86 ++++++++++++++++++++++ drivers/vdpa/mlx5/net/mlx5_vnet.c | 114 +++++++++++++++++++++++------- drivers/vdpa/mlx5/net/mlx5_vnet.h | 30 ++++++++ 4 files changed, 215 insertions(+), 27 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 +86 -0
92 lines not on this page · raw message
drivers/vdpa/mlx5/net/mlx5_vnet.c +87 -27
194 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