1 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
2 /* Copyright (c) 2019 Mellanox Technologies. */
3 
4 #define CREATE_TRACE_POINTS
5 #include "en_tc_tracepoint.h"
6 
7 void put_ids_to_array(int *ids,
8 		      const struct flow_action_entry *entries,
9 		      unsigned int num)
10 {
11 	unsigned int i;
12 
13 	for (i = 0; i < num; i++)
14 		ids[i] = entries[i].id;
15 }
16 
17 #define NAME_SIZE 16
18 
19 static const char FLOWACT2STR[NUM_FLOW_ACTIONS][NAME_SIZE] = {
20 	[FLOW_ACTION_ACCEPT]	= "ACCEPT",
21 	[FLOW_ACTION_DROP]	= "DROP",
22 	[FLOW_ACTION_TRAP]	= "TRAP",
23 	[FLOW_ACTION_GOTO]	= "GOTO",
24 	[FLOW_ACTION_REDIRECT]	= "REDIRECT",
25 	[FLOW_ACTION_MIRRED]	= "MIRRED",
26 	[FLOW_ACTION_VLAN_PUSH]	= "VLAN_PUSH",
27 	[FLOW_ACTION_VLAN_POP]	= "VLAN_POP",
28 	[FLOW_ACTION_VLAN_MANGLE]	= "VLAN_MANGLE",
29 	[FLOW_ACTION_TUNNEL_ENCAP]	= "TUNNEL_ENCAP",
30 	[FLOW_ACTION_TUNNEL_DECAP]	= "TUNNEL_DECAP",
31 	[FLOW_ACTION_MANGLE]	= "MANGLE",
32 	[FLOW_ACTION_ADD]	= "ADD",
33 	[FLOW_ACTION_CSUM]	= "CSUM",
34 	[FLOW_ACTION_MARK]	= "MARK",
35 	[FLOW_ACTION_WAKE]	= "WAKE",
36 	[FLOW_ACTION_QUEUE]	= "QUEUE",
37 	[FLOW_ACTION_SAMPLE]	= "SAMPLE",
38 	[FLOW_ACTION_POLICE]	= "POLICE",
39 	[FLOW_ACTION_CT]	= "CT",
40 };
41 
42 const char *parse_action(struct trace_seq *p,
43 			 int *ids,
44 			 unsigned int num)
45 {
46 	const char *ret = trace_seq_buffer_ptr(p);
47 	unsigned int i;
48 
49 	for (i = 0; i < num; i++) {
50 		if (ids[i] < NUM_FLOW_ACTIONS)
51 			trace_seq_printf(p, "%s ", FLOWACT2STR[ids[i]]);
52 		else
53 			trace_seq_printf(p, "UNKNOWN ");
54 	}
55 
56 	trace_seq_putc(p, 0);
57 	return ret;
58 }
59