net/mlx5: Bridge, add tracepoints for multicast
authorVlad Buslov <vladbu@nvidia.com>
Tue, 14 Feb 2023 21:00:41 +0000 (22:00 +0100)
committerSaeed Mahameed <saeedm@nvidia.com>
Wed, 12 Apr 2023 03:57:37 +0000 (20:57 -0700)
Pass target struct net_device to mdb attach/detach handler in order to
expose the port name to the new tracepoints. Implemented following
tracepoints:

- Attach mdb to port.
- Detach mdb from port.

Usage example:

># cd /sys/kernel/debug/tracing
># echo mlx5:mlx5_esw_bridge_port_mdb_attach >> set_event
># cat trace
...
     kworker/0:0-19071   [000] ..... 259004.253848: mlx5_esw_bridge_port_mdb_attach: net_device=enp8s0f0_0 addr=33:33:ff:00:00:01 vid=0 num_ports=1 offloaded=1

Signed-off-by: Vlad Buslov <vladbu@nvidia.com>
Reviewed-by: Maor Dickman <maord@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c
drivers/net/ethernet/mellanox/mlx5/core/esw/bridge.c
drivers/net/ethernet/mellanox/mlx5/core/esw/bridge.h
drivers/net/ethernet/mellanox/mlx5/core/esw/bridge_mcast.c
drivers/net/ethernet/mellanox/mlx5/core/esw/bridge_priv.h
drivers/net/ethernet/mellanox/mlx5/core/esw/diag/bridge_tracepoint.h

index dd0dd3f..fd19192 100644 (file)
@@ -238,7 +238,7 @@ mlx5_esw_bridge_port_obj_add(struct net_device *dev,
                break;
        case SWITCHDEV_OBJ_ID_PORT_MDB:
                mdb = SWITCHDEV_OBJ_PORT_MDB(obj);
-               err = mlx5_esw_bridge_port_mdb_add(vport_num, esw_owner_vhca_id, mdb->addr,
+               err = mlx5_esw_bridge_port_mdb_add(dev, vport_num, esw_owner_vhca_id, mdb->addr,
                                                   mdb->vid, br_offloads, extack);
                break;
        default:
@@ -270,7 +270,7 @@ mlx5_esw_bridge_port_obj_del(struct net_device *dev,
                break;
        case SWITCHDEV_OBJ_ID_PORT_MDB:
                mdb = SWITCHDEV_OBJ_PORT_MDB(obj);
-               mlx5_esw_bridge_port_mdb_del(vport_num, esw_owner_vhca_id, mdb->addr, mdb->vid,
+               mlx5_esw_bridge_port_mdb_del(dev, vport_num, esw_owner_vhca_id, mdb->addr, mdb->vid,
                                             br_offloads);
                break;
        default:
index be47875..1ba03e2 100644 (file)
@@ -1803,8 +1803,9 @@ void mlx5_esw_bridge_update(struct mlx5_esw_bridge_offloads *br_offloads)
        }
 }
 
-int mlx5_esw_bridge_port_mdb_add(u16 vport_num, u16 esw_owner_vhca_id, const unsigned char *addr,
-                                u16 vid, struct mlx5_esw_bridge_offloads *br_offloads,
+int mlx5_esw_bridge_port_mdb_add(struct net_device *dev, u16 vport_num, u16 esw_owner_vhca_id,
+                                const unsigned char *addr, u16 vid,
+                                struct mlx5_esw_bridge_offloads *br_offloads,
                                 struct netlink_ext_ack *extack)
 {
        struct mlx5_esw_bridge_vlan *vlan;
@@ -1837,7 +1838,7 @@ int mlx5_esw_bridge_port_mdb_add(u16 vport_num, u16 esw_owner_vhca_id, const uns
                }
        }
 
-       err = mlx5_esw_bridge_port_mdb_attach(port, addr, vid);
+       err = mlx5_esw_bridge_port_mdb_attach(dev, port, addr, vid);
        if (err) {
                NL_SET_ERR_MSG_FMT_MOD(extack, "Failed to add MDB (MAC=%pM,vid=%u,vport=%u)\n",
                                       addr, vid, vport_num);
@@ -1847,8 +1848,9 @@ int mlx5_esw_bridge_port_mdb_add(u16 vport_num, u16 esw_owner_vhca_id, const uns
        return 0;
 }
 
-void mlx5_esw_bridge_port_mdb_del(u16 vport_num, u16 esw_owner_vhca_id, const unsigned char *addr,
-                                 u16 vid, struct mlx5_esw_bridge_offloads *br_offloads)
+void mlx5_esw_bridge_port_mdb_del(struct net_device *dev, u16 vport_num, u16 esw_owner_vhca_id,
+                                 const unsigned char *addr, u16 vid,
+                                 struct mlx5_esw_bridge_offloads *br_offloads)
 {
        struct mlx5_esw_bridge_port *port;
 
@@ -1856,7 +1858,7 @@ void mlx5_esw_bridge_port_mdb_del(u16 vport_num, u16 esw_owner_vhca_id, const un
        if (!port)
                return;
 
-       mlx5_esw_bridge_port_mdb_detach(port, addr, vid);
+       mlx5_esw_bridge_port_mdb_detach(dev, port, addr, vid);
 }
 
 static void mlx5_esw_bridge_flush(struct mlx5_esw_bridge_offloads *br_offloads)
index 9cab664..a9dd18c 100644 (file)
@@ -79,10 +79,12 @@ int mlx5_esw_bridge_port_vlan_add(u16 vport_num, u16 esw_owner_vhca_id, u16 vid,
 void mlx5_esw_bridge_port_vlan_del(u16 vport_num, u16 esw_owner_vhca_id, u16 vid,
                                   struct mlx5_esw_bridge_offloads *br_offloads);
 
-int mlx5_esw_bridge_port_mdb_add(u16 vport_num, u16 esw_owner_vhca_id, const unsigned char *addr,
-                                u16 vid, struct mlx5_esw_bridge_offloads *br_offloads,
+int mlx5_esw_bridge_port_mdb_add(struct net_device *dev, u16 vport_num, u16 esw_owner_vhca_id,
+                                const unsigned char *addr, u16 vid,
+                                struct mlx5_esw_bridge_offloads *br_offloads,
                                 struct netlink_ext_ack *extack);
-void mlx5_esw_bridge_port_mdb_del(u16 vport_num, u16 esw_owner_vhca_id, const unsigned char *addr,
-                                 u16 vid, struct mlx5_esw_bridge_offloads *br_offloads);
+void mlx5_esw_bridge_port_mdb_del(struct net_device *dev, u16 vport_num, u16 esw_owner_vhca_id,
+                                 const unsigned char *addr, u16 vid,
+                                 struct mlx5_esw_bridge_offloads *br_offloads);
 
 #endif /* __MLX5_ESW_BRIDGE_H__ */
index d17fe6d..2eae594 100644 (file)
@@ -5,6 +5,7 @@
 #include "bridge.h"
 #include "eswitch.h"
 #include "bridge_priv.h"
+#include "diag/bridge_tracepoint.h"
 
 static const struct rhashtable_params mdb_ht_params = {
        .key_offset = offsetof(struct mlx5_esw_bridge_mdb_entry, key),
@@ -180,8 +181,8 @@ static void mlx5_esw_bridge_port_mdb_entry_cleanup(struct mlx5_esw_bridge *bridg
        kvfree(entry);
 }
 
-int mlx5_esw_bridge_port_mdb_attach(struct mlx5_esw_bridge_port *port, const unsigned char *addr,
-                                   u16 vid)
+int mlx5_esw_bridge_port_mdb_attach(struct net_device *dev, struct mlx5_esw_bridge_port *port,
+                                   const unsigned char *addr, u16 vid)
 {
        struct mlx5_esw_bridge *bridge = port->bridge;
        struct mlx5_esw_bridge_mdb_entry *entry;
@@ -224,6 +225,8 @@ int mlx5_esw_bridge_port_mdb_attach(struct mlx5_esw_bridge_port *port, const uns
                 */
                esw_warn(bridge->br_offloads->esw->dev, "MDB attach failed to offload (MAC=%pM,vid=%u,vport=%u,err=%d)\n",
                         addr, vid, port->vport_num, err);
+
+       trace_mlx5_esw_bridge_port_mdb_attach(dev, entry);
        return 0;
 }
 
@@ -248,8 +251,8 @@ static void mlx5_esw_bridge_port_mdb_entry_detach(struct mlx5_esw_bridge_port *p
                         entry->key.addr, entry->key.vid, port->vport_num);
 }
 
-void mlx5_esw_bridge_port_mdb_detach(struct mlx5_esw_bridge_port *port, const unsigned char *addr,
-                                    u16 vid)
+void mlx5_esw_bridge_port_mdb_detach(struct net_device *dev, struct mlx5_esw_bridge_port *port,
+                                    const unsigned char *addr, u16 vid)
 {
        struct mlx5_esw_bridge *bridge = port->bridge;
        struct mlx5_esw_bridge_mdb_entry *entry;
@@ -269,6 +272,7 @@ void mlx5_esw_bridge_port_mdb_detach(struct mlx5_esw_bridge_port *port, const un
                return;
        }
 
+       trace_mlx5_esw_bridge_port_mdb_detach(dev, entry);
        mlx5_esw_bridge_port_mdb_entry_detach(port, entry);
 }
 
index 849028f..c959580 100644 (file)
@@ -233,10 +233,10 @@ void mlx5_esw_bridge_mcast_disable(struct mlx5_esw_bridge *bridge);
 
 int mlx5_esw_bridge_mdb_init(struct mlx5_esw_bridge *bridge);
 void mlx5_esw_bridge_mdb_cleanup(struct mlx5_esw_bridge *bridge);
-int mlx5_esw_bridge_port_mdb_attach(struct mlx5_esw_bridge_port *port, const unsigned char *addr,
-                                   u16 vid);
-void mlx5_esw_bridge_port_mdb_detach(struct mlx5_esw_bridge_port *port, const unsigned char *addr,
-                                    u16 vid);
+int mlx5_esw_bridge_port_mdb_attach(struct net_device *dev, struct mlx5_esw_bridge_port *port,
+                                   const unsigned char *addr, u16 vid);
+void mlx5_esw_bridge_port_mdb_detach(struct net_device *dev, struct mlx5_esw_bridge_port *port,
+                                    const unsigned char *addr, u16 vid);
 void mlx5_esw_bridge_port_mdb_vlan_flush(struct mlx5_esw_bridge_port *port,
                                         struct mlx5_esw_bridge_vlan *vlan);
 void mlx5_esw_bridge_mdb_flush(struct mlx5_esw_bridge *bridge);
index 51ac24e..1808da2 100644 (file)
@@ -110,6 +110,41 @@ DEFINE_EVENT(mlx5_esw_bridge_port_template,
             TP_ARGS(port)
        );
 
+DECLARE_EVENT_CLASS(mlx5_esw_bridge_mdb_port_change_template,
+                   TP_PROTO(const struct net_device *dev,
+                            const struct mlx5_esw_bridge_mdb_entry *mdb),
+                   TP_ARGS(dev, mdb),
+                   TP_STRUCT__entry(
+                           __array(char, dev_name, IFNAMSIZ)
+                           __array(unsigned char, addr, ETH_ALEN)
+                           __field(u16, vid)
+                           __field(int, num_ports)
+                           __field(bool, offloaded)),
+                   TP_fast_assign(
+                           strscpy(__entry->dev_name, netdev_name(dev), IFNAMSIZ);
+                           memcpy(__entry->addr, mdb->key.addr, ETH_ALEN);
+                           __entry->vid = mdb->key.vid;
+                           __entry->num_ports = mdb->num_ports;
+                           __entry->offloaded = mdb->egress_handle;),
+                   TP_printk("net_device=%s addr=%pM vid=%u num_ports=%d offloaded=%d",
+                             __entry->dev_name,
+                             __entry->addr,
+                             __entry->vid,
+                             __entry->num_ports,
+                             __entry->offloaded));
+
+DEFINE_EVENT(mlx5_esw_bridge_mdb_port_change_template,
+            mlx5_esw_bridge_port_mdb_attach,
+            TP_PROTO(const struct net_device *dev,
+                     const struct mlx5_esw_bridge_mdb_entry *mdb),
+            TP_ARGS(dev, mdb));
+
+DEFINE_EVENT(mlx5_esw_bridge_mdb_port_change_template,
+            mlx5_esw_bridge_port_mdb_detach,
+            TP_PROTO(const struct net_device *dev,
+                     const struct mlx5_esw_bridge_mdb_entry *mdb),
+            TP_ARGS(dev, mdb));
+
 #endif
 
 /* This part must be outside protection */