xref: /openbmc/linux/net/dsa/trace.c (revision 9538ebce)
1*9538ebceSVladimir Oltean // SPDX-License-Identifier: GPL-2.0-or-later
2*9538ebceSVladimir Oltean /* Copyright 2022-2023 NXP
3*9538ebceSVladimir Oltean  */
4*9538ebceSVladimir Oltean 
5*9538ebceSVladimir Oltean #define CREATE_TRACE_POINTS
6*9538ebceSVladimir Oltean #include "trace.h"
7*9538ebceSVladimir Oltean 
dsa_db_print(const struct dsa_db * db,char buf[DSA_DB_BUFSIZ])8*9538ebceSVladimir Oltean void dsa_db_print(const struct dsa_db *db, char buf[DSA_DB_BUFSIZ])
9*9538ebceSVladimir Oltean {
10*9538ebceSVladimir Oltean 	switch (db->type) {
11*9538ebceSVladimir Oltean 	case DSA_DB_PORT:
12*9538ebceSVladimir Oltean 		sprintf(buf, "port %s", db->dp->name);
13*9538ebceSVladimir Oltean 		break;
14*9538ebceSVladimir Oltean 	case DSA_DB_LAG:
15*9538ebceSVladimir Oltean 		sprintf(buf, "lag %s id %d", db->lag.dev->name, db->lag.id);
16*9538ebceSVladimir Oltean 		break;
17*9538ebceSVladimir Oltean 	case DSA_DB_BRIDGE:
18*9538ebceSVladimir Oltean 		sprintf(buf, "bridge %s num %d", db->bridge.dev->name,
19*9538ebceSVladimir Oltean 			db->bridge.num);
20*9538ebceSVladimir Oltean 		break;
21*9538ebceSVladimir Oltean 	default:
22*9538ebceSVladimir Oltean 		sprintf(buf, "unknown");
23*9538ebceSVladimir Oltean 		break;
24*9538ebceSVladimir Oltean 	}
25*9538ebceSVladimir Oltean }
26*9538ebceSVladimir Oltean 
dsa_port_kind(const struct dsa_port * dp)27*9538ebceSVladimir Oltean const char *dsa_port_kind(const struct dsa_port *dp)
28*9538ebceSVladimir Oltean {
29*9538ebceSVladimir Oltean 	switch (dp->type) {
30*9538ebceSVladimir Oltean 	case DSA_PORT_TYPE_USER:
31*9538ebceSVladimir Oltean 		return "user";
32*9538ebceSVladimir Oltean 	case DSA_PORT_TYPE_CPU:
33*9538ebceSVladimir Oltean 		return "cpu";
34*9538ebceSVladimir Oltean 	case DSA_PORT_TYPE_DSA:
35*9538ebceSVladimir Oltean 		return "dsa";
36*9538ebceSVladimir Oltean 	default:
37*9538ebceSVladimir Oltean 		return "unused";
38*9538ebceSVladimir Oltean 	}
39*9538ebceSVladimir Oltean }
40