summaryrefslogtreecommitdiff
path: root/net/dsa/trace.c
blob: 1b107165d331cf3398160cd21aba99e9da61ee54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// SPDX-License-Identifier: GPL-2.0-or-later
/* Copyright 2022-2023 NXP
 */

#define CREATE_TRACE_POINTS
#include "trace.h"

void dsa_db_print(const struct dsa_db *db, char buf[DSA_DB_BUFSIZ])
{
	switch (db->type) {
	case DSA_DB_PORT:
		sprintf(buf, "port %s", db->dp->name);
		break;
	case DSA_DB_LAG:
		sprintf(buf, "lag %s id %d", db->lag.dev->name, db->lag.id);
		break;
	case DSA_DB_BRIDGE:
		sprintf(buf, "bridge %s num %d", db->bridge.dev->name,
			db->bridge.num);
		break;
	default:
		sprintf(buf, "unknown");
		break;
	}
}

const char *dsa_port_kind(const struct dsa_port *dp)
{
	switch (dp->type) {
	case DSA_PORT_TYPE_USER:
		return "user";
	case DSA_PORT_TYPE_CPU:
		return "cpu";
	case DSA_PORT_TYPE_DSA:
		return "dsa";
	default:
		return "unused";
	}
}