net/ice/base: add inner VLAN protocol type for QinQ filter
[dpdk.git] / drivers / net / octeontx2 / otx2_flow_dump.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2019 Marvell International Ltd.
3  */
4
5 #include "otx2_ethdev.h"
6 #include "otx2_ethdev_sec.h"
7 #include "otx2_flow.h"
8
9 #define NPC_MAX_FIELD_NAME_SIZE 80
10 #define NPC_RX_ACTIONOP_MASK            GENMASK(3, 0)
11 #define NPC_RX_ACTION_PFFUNC_MASK       GENMASK(19, 4)
12 #define NPC_RX_ACTION_INDEX_MASK        GENMASK(39, 20)
13 #define NPC_RX_ACTION_MATCH_MASK        GENMASK(55, 40)
14 #define NPC_RX_ACTION_FLOWKEY_MASK      GENMASK(60, 56)
15
16 #define NPC_TX_ACTION_INDEX_MASK        GENMASK(31, 12)
17 #define NPC_TX_ACTION_MATCH_MASK        GENMASK(47, 32)
18
19 #define NIX_RX_VTAGACT_VTAG0_RELPTR_MASK        GENMASK(7, 0)
20 #define NIX_RX_VTAGACT_VTAG0_LID_MASK           GENMASK(10, 8)
21 #define NIX_RX_VTAGACT_VTAG0_TYPE_MASK          GENMASK(14, 12)
22 #define NIX_RX_VTAGACT_VTAG0_VALID_MASK         BIT_ULL(15)
23
24 #define NIX_RX_VTAGACT_VTAG1_RELPTR_MASK        GENMASK(39, 32)
25 #define NIX_RX_VTAGACT_VTAG1_LID_MASK           GENMASK(42, 40)
26 #define NIX_RX_VTAGACT_VTAG1_TYPE_MASK          GENMASK(46, 44)
27 #define NIX_RX_VTAGACT_VTAG1_VALID_MASK         BIT_ULL(47)
28
29 #define NIX_TX_VTAGACT_VTAG0_RELPTR_MASK        GENMASK(7, 0)
30 #define NIX_TX_VTAGACT_VTAG0_LID_MASK           GENMASK(10, 8)
31 #define NIX_TX_VTAGACT_VTAG0_OP_MASK            GENMASK(13, 12)
32 #define NIX_TX_VTAGACT_VTAG0_DEF_MASK           GENMASK(25, 16)
33
34 #define NIX_TX_VTAGACT_VTAG1_RELPTR_MASK        GENMASK(39, 32)
35 #define NIX_TX_VTAGACT_VTAG1_LID_MASK           GENMASK(42, 40)
36 #define NIX_TX_VTAGACT_VTAG1_OP_MASK            GENMASK(45, 44)
37 #define NIX_TX_VTAGACT_VTAG1_DEF_MASK           GENMASK(57, 48)
38
39 struct npc_rx_parse_nibble_s {
40         uint16_t chan         : 3;
41         uint16_t errlev       : 1;
42         uint16_t errcode      : 2;
43         uint16_t l2l3bm       : 1;
44         uint16_t laflags      : 2;
45         uint16_t latype       : 1;
46         uint16_t lbflags      : 2;
47         uint16_t lbtype       : 1;
48         uint16_t lcflags      : 2;
49         uint16_t lctype       : 1;
50         uint16_t ldflags      : 2;
51         uint16_t ldtype       : 1;
52         uint16_t leflags      : 2;
53         uint16_t letype       : 1;
54         uint16_t lfflags      : 2;
55         uint16_t lftype       : 1;
56         uint16_t lgflags      : 2;
57         uint16_t lgtype       : 1;
58         uint16_t lhflags      : 2;
59         uint16_t lhtype       : 1;
60 } __rte_packed;
61
62 const char *intf_str[] = {
63         "NIX-RX",
64         "NIX-TX",
65 };
66
67 const char *ltype_str[NPC_MAX_LID][NPC_MAX_LT] = {
68         [NPC_LID_LA][0] = "NONE",
69         [NPC_LID_LA][NPC_LT_LA_ETHER] = "LA_ETHER",
70         [NPC_LID_LA][NPC_LT_LA_IH_NIX_ETHER] = "LA_IH_NIX_ETHER",
71         [NPC_LID_LA][NPC_LT_LA_HIGIG2_ETHER] = "LA_HIGIG2_ETHER",
72         [NPC_LID_LA][NPC_LT_LA_IH_NIX_HIGIG2_ETHER] = "LA_IH_NIX_HIGIG2_ETHER",
73         [NPC_LID_LB][0] = "NONE",
74         [NPC_LID_LB][NPC_LT_LB_CTAG] = "LB_CTAG",
75         [NPC_LID_LB][NPC_LT_LB_STAG_QINQ] = "LB_STAG_QINQ",
76         [NPC_LID_LB][NPC_LT_LB_ETAG] = "LB_ETAG",
77         [NPC_LID_LB][NPC_LT_LB_EXDSA] = "LB_EXDSA",
78         [NPC_LID_LB][NPC_LT_LB_VLAN_EXDSA] = "LB_VLAN_EXDSA",
79         [NPC_LID_LC][0] = "NONE",
80         [NPC_LID_LC][NPC_LT_LC_IP] = "LC_IP",
81         [NPC_LID_LC][NPC_LT_LC_IP6] = "LC_IP6",
82         [NPC_LID_LC][NPC_LT_LC_ARP] = "LC_ARP",
83         [NPC_LID_LC][NPC_LT_LC_IP6_EXT] = "LC_IP6_EXT",
84         [NPC_LID_LC][NPC_LT_LC_NGIO] = "LC_NGIO",
85         [NPC_LID_LD][0] = "NONE",
86         [NPC_LID_LD][NPC_LT_LD_ICMP] = "LD_ICMP",
87         [NPC_LID_LD][NPC_LT_LD_ICMP6] = "LD_ICMP6",
88         [NPC_LID_LD][NPC_LT_LD_UDP] = "LD_UDP",
89         [NPC_LID_LD][NPC_LT_LD_TCP] = "LD_TCP",
90         [NPC_LID_LD][NPC_LT_LD_SCTP] = "LD_SCTP",
91         [NPC_LID_LD][NPC_LT_LD_GRE] = "LD_GRE",
92         [NPC_LID_LD][NPC_LT_LD_NVGRE] = "LD_NVGRE",
93         [NPC_LID_LE][0] = "NONE",
94         [NPC_LID_LE][NPC_LT_LE_VXLAN] = "LE_VXLAN",
95         [NPC_LID_LE][NPC_LT_LE_ESP] = "LE_ESP",
96         [NPC_LID_LE][NPC_LT_LE_GTPC] = "LE_GTPC",
97         [NPC_LID_LE][NPC_LT_LE_GTPU] = "LE_GTPU",
98         [NPC_LID_LE][NPC_LT_LE_GENEVE] = "LE_GENEVE",
99         [NPC_LID_LE][NPC_LT_LE_VXLANGPE] = "LE_VXLANGPE",
100         [NPC_LID_LF][0] = "NONE",
101         [NPC_LID_LF][NPC_LT_LF_TU_ETHER] = "LF_TU_ETHER",
102         [NPC_LID_LG][0] = "NONE",
103         [NPC_LID_LG][NPC_LT_LG_TU_IP] = "LG_TU_IP",
104         [NPC_LID_LG][NPC_LT_LG_TU_IP6] = "LG_TU_IP6",
105         [NPC_LID_LH][0] = "NONE",
106         [NPC_LID_LH][NPC_LT_LH_TU_UDP] = "LH_TU_UDP",
107         [NPC_LID_LH][NPC_LT_LH_TU_TCP] = "LH_TU_TCP",
108         [NPC_LID_LH][NPC_LT_LH_TU_SCTP] = "LH_TU_SCTP",
109         [NPC_LID_LH][NPC_LT_LH_TU_ESP] = "LH_TU_ESP",
110 };
111
112 static uint16_t
113 otx2_get_nibbles(struct rte_flow *flow, uint16_t size, uint32_t bit_offset)
114 {
115         uint32_t byte_index, noffset;
116         uint16_t data, mask;
117         uint8_t *bytes;
118
119         bytes = (uint8_t *)flow->mcam_data;
120         mask = (1ULL << (size * 4)) - 1;
121         byte_index = bit_offset / 8;
122         noffset = bit_offset % 8;
123         data = *(uint16_t *)&bytes[byte_index];
124         data >>= noffset;
125         data &= mask;
126
127         return data;
128 }
129
130 static void
131 otx2_flow_print_parse_nibbles(FILE *file, struct rte_flow *flow,
132                               uint64_t parse_nibbles)
133 {
134         struct npc_rx_parse_nibble_s *rx_parse;
135         uint32_t data, offset = 0;
136
137         rx_parse = (struct npc_rx_parse_nibble_s *)&parse_nibbles;
138
139         if (rx_parse->chan) {
140                 data = otx2_get_nibbles(flow, 3, offset);
141                 fprintf(file, "\tNPC_PARSE_NIBBLE_CHAN:%#03X\n", data);
142                 offset += 12;
143         }
144
145         if (rx_parse->errlev) {
146                 data = otx2_get_nibbles(flow, 1, offset);
147                 fprintf(file, "\tNPC_PARSE_NIBBLE_ERRLEV:%#X\n", data);
148                 offset += 4;
149         }
150
151         if (rx_parse->errcode) {
152                 data = otx2_get_nibbles(flow, 2, offset);
153                 fprintf(file, "\tNPC_PARSE_NIBBLE_ERRCODE:%#02X\n", data);
154                 offset += 8;
155         }
156
157         if (rx_parse->l2l3bm) {
158                 data = otx2_get_nibbles(flow, 1, offset);
159                 fprintf(file, "\tNPC_PARSE_NIBBLE_L2L3_BCAST:%#X\n", data);
160                 offset += 4;
161         }
162
163         if (rx_parse->latype) {
164                 data = otx2_get_nibbles(flow, 1, offset);
165                 fprintf(file, "\tNPC_PARSE_NIBBLE_LA_LTYPE:%s\n",
166                         ltype_str[NPC_LID_LA][data]);
167                 offset += 4;
168         }
169
170         if (rx_parse->laflags) {
171                 data = otx2_get_nibbles(flow, 2, offset);
172                 fprintf(file, "\tNPC_PARSE_NIBBLE_LA_FLAGS:%#02X\n", data);
173                 offset += 8;
174         }
175
176         if (rx_parse->lbtype) {
177                 data = otx2_get_nibbles(flow, 1, offset);
178                 fprintf(file, "\tNPC_PARSE_NIBBLE_LB_LTYPE:%s\n",
179                         ltype_str[NPC_LID_LB][data]);
180                 offset += 4;
181         }
182
183         if (rx_parse->lbflags) {
184                 data = otx2_get_nibbles(flow, 2, offset);
185                 fprintf(file, "\tNPC_PARSE_NIBBLE_LB_FLAGS:%#02X\n", data);
186                 offset += 8;
187         }
188
189         if (rx_parse->lctype) {
190                 data = otx2_get_nibbles(flow, 1, offset);
191                 fprintf(file, "\tNPC_PARSE_NIBBLE_LC_LTYPE:%s\n",
192                         ltype_str[NPC_LID_LC][data]);
193                 offset += 4;
194         }
195
196         if (rx_parse->lcflags) {
197                 data = otx2_get_nibbles(flow, 2, offset);
198                 fprintf(file, "\tNPC_PARSE_NIBBLE_LC_FLAGS:%#02X\n", data);
199                 offset += 8;
200         }
201
202         if (rx_parse->ldtype) {
203                 data = otx2_get_nibbles(flow, 1, offset);
204                 fprintf(file, "\tNPC_PARSE_NIBBLE_LD_LTYPE:%s\n",
205                         ltype_str[NPC_LID_LD][data]);
206                 offset += 4;
207         }
208
209         if (rx_parse->ldflags) {
210                 data = otx2_get_nibbles(flow, 2, offset);
211                 fprintf(file, "\tNPC_PARSE_NIBBLE_LD_FLAGS:%#02X\n", data);
212                 offset += 8;
213         }
214
215         if (rx_parse->letype) {
216                 data = otx2_get_nibbles(flow, 1, offset);
217                 fprintf(file, "\tNPC_PARSE_NIBBLE_LE_LTYPE:%s\n",
218                         ltype_str[NPC_LID_LE][data]);
219                 offset += 4;
220         }
221
222         if (rx_parse->leflags) {
223                 data = otx2_get_nibbles(flow, 2, offset);
224                 fprintf(file, "\tNPC_PARSE_NIBBLE_LE_FLAGS:%#02X\n", data);
225                 offset += 8;
226         }
227
228         if (rx_parse->lftype) {
229                 data = otx2_get_nibbles(flow, 1, offset);
230                 fprintf(file, "\tNPC_PARSE_NIBBLE_LF_LTYPE:%s\n",
231                         ltype_str[NPC_LID_LF][data]);
232                 offset += 4;
233         }
234
235         if (rx_parse->lfflags) {
236                 data = otx2_get_nibbles(flow, 2, offset);
237                 fprintf(file, "\tNPC_PARSE_NIBBLE_LF_FLAGS:%#02X\n", data);
238                 offset += 8;
239         }
240
241         if (rx_parse->lgtype) {
242                 data = otx2_get_nibbles(flow, 1, offset);
243                 fprintf(file, "\tNPC_PARSE_NIBBLE_LG_LTYPE:%s\n",
244                         ltype_str[NPC_LID_LG][data]);
245                 offset += 4;
246         }
247
248         if (rx_parse->lgflags) {
249                 data = otx2_get_nibbles(flow, 2, offset);
250                 fprintf(file, "\tNPC_PARSE_NIBBLE_LG_FLAGS:%#02X\n", data);
251                 offset += 8;
252         }
253
254         if (rx_parse->lhtype) {
255                 data = otx2_get_nibbles(flow, 1, offset);
256                 fprintf(file, "\tNPC_PARSE_NIBBLE_LH_LTYPE:%s\n",
257                         ltype_str[NPC_LID_LH][data]);
258                 offset += 4;
259         }
260
261         if (rx_parse->lhflags) {
262                 data = otx2_get_nibbles(flow, 2, offset);
263                 fprintf(file, "\tNPC_PARSE_NIBBLE_LH_FLAGS:%#02X\n", data);
264         }
265 }
266
267 static void
268 otx2_flow_print_xtractinfo(FILE *file, struct npc_xtract_info *lfinfo,
269                            struct rte_flow *flow, int lid, int lt)
270 {
271         uint8_t *datastart, *maskstart;
272         int i;
273
274         datastart = (uint8_t *)&flow->mcam_data + lfinfo->key_off;
275         maskstart = (uint8_t *)&flow->mcam_mask + lfinfo->key_off;
276
277         fprintf(file, "\t%s, hdr offset:%#X, len:%#X, key offset:%#X, ",
278                 ltype_str[lid][lt], lfinfo->hdr_off,
279                 lfinfo->len, lfinfo->key_off);
280
281         fprintf(file, "Data:0X");
282         for (i = lfinfo->len - 1; i >= 0; i--)
283                 fprintf(file, "%02X", datastart[i]);
284
285         fprintf(file, ", ");
286
287         fprintf(file, "Mask:0X");
288
289         for (i = lfinfo->len - 1; i >= 0; i--)
290                 fprintf(file, "%02X", maskstart[i]);
291
292         fprintf(file, "\n");
293 }
294
295 static void
296 otx2_flow_print_item(FILE *file, struct otx2_eth_dev *hw,
297                      struct npc_xtract_info *xinfo, struct rte_flow *flow,
298                      int intf, int lid, int lt, int ld)
299 {
300         struct otx2_npc_flow_info *npc_flow = &hw->npc_flow;
301         struct npc_xtract_info *lflags_info;
302         int i, lf_cfg;
303
304         otx2_flow_print_xtractinfo(file, xinfo, flow, lid, lt);
305
306         if (xinfo->flags_enable) {
307                 lf_cfg = npc_flow->prx_lfcfg[ld].i;
308
309                 if (lf_cfg == lid) {
310                         for (i = 0; i < NPC_MAX_LFL; i++) {
311                                 lflags_info = npc_flow->prx_fxcfg[intf]
312                                                         [ld][i].xtract;
313
314                                 otx2_flow_print_xtractinfo(file, lflags_info,
315                                                            flow, lid, lt);
316                         }
317                 }
318         }
319 }
320
321 static void
322 otx2_flow_dump_patterns(FILE *file, struct otx2_eth_dev *hw,
323                         struct rte_flow *flow)
324 {
325         struct otx2_npc_flow_info *npc_flow = &hw->npc_flow;
326         struct npc_lid_lt_xtract_info *lt_xinfo;
327         struct npc_xtract_info *xinfo;
328         uint32_t intf, lid, ld, i;
329         uint64_t parse_nibbles;
330         uint16_t ltype;
331
332         intf = flow->nix_intf;
333         parse_nibbles = npc_flow->keyx_supp_nmask[intf];
334         otx2_flow_print_parse_nibbles(file, flow, parse_nibbles);
335
336         for (i = 0; i < flow->num_patterns; i++) {
337                 lid = flow->dump_data[i].lid;
338                 ltype = flow->dump_data[i].ltype;
339                 lt_xinfo = &npc_flow->prx_dxcfg[intf][lid][ltype];
340
341                 for (ld = 0; ld < NPC_MAX_LD; ld++) {
342                         xinfo = &lt_xinfo->xtract[ld];
343                         if (!xinfo->enable)
344                                 continue;
345                         otx2_flow_print_item(file, hw, xinfo, flow, intf, lid,
346                                              ltype, ld);
347                 }
348         }
349 }
350
351 static void
352 otx2_flow_dump_tx_action(FILE *file, uint64_t npc_action)
353 {
354         char index_name[NPC_MAX_FIELD_NAME_SIZE] = "Index:";
355         uint32_t tx_op, index, match_id;
356
357         tx_op = npc_action & NPC_RX_ACTIONOP_MASK;
358
359         fprintf(file, "\tActionOp:");
360
361         switch (tx_op) {
362         case NIX_TX_ACTIONOP_DROP:
363                 fprintf(file, "NIX_TX_ACTIONOP_DROP (%lu)\n",
364                         (uint64_t)NIX_RX_ACTIONOP_DROP);
365                 break;
366         case NIX_TX_ACTIONOP_UCAST_DEFAULT:
367                 fprintf(file, "NIX_TX_ACTIONOP_UCAST_DEFAULT (%lu)\n",
368                         (uint64_t)NIX_TX_ACTIONOP_UCAST_DEFAULT);
369                 break;
370         case NIX_TX_ACTIONOP_UCAST_CHAN:
371                 fprintf(file, "NIX_TX_ACTIONOP_UCAST_DEFAULT (%lu)\n",
372                         (uint64_t)NIX_TX_ACTIONOP_UCAST_CHAN);
373                 strncpy(index_name, "Transmit Channel:",
374                         NPC_MAX_FIELD_NAME_SIZE);
375                 break;
376         case NIX_TX_ACTIONOP_MCAST:
377                 fprintf(file, "NIX_TX_ACTIONOP_MCAST (%lu)\n",
378                         (uint64_t)NIX_TX_ACTIONOP_MCAST);
379                 strncpy(index_name, "Multicast Table Index:",
380                         NPC_MAX_FIELD_NAME_SIZE);
381                 break;
382         case NIX_TX_ACTIONOP_DROP_VIOL:
383                 fprintf(file, "NIX_TX_ACTIONOP_DROP_VIOL (%lu)\n",
384                         (uint64_t)NIX_TX_ACTIONOP_DROP_VIOL);
385                 break;
386         }
387
388         index = ((npc_action & NPC_TX_ACTION_INDEX_MASK) >> 12) & 0xFFFFF;
389
390         fprintf(file, "\t%s:%#05X\n", index_name, index);
391
392         match_id = ((npc_action & NPC_TX_ACTION_MATCH_MASK) >> 32) & 0xFFFF;
393
394         fprintf(file, "\tMatch Id:%#04X\n", match_id);
395 }
396
397 static void
398 otx2_flow_dump_rx_action(FILE *file, uint64_t npc_action)
399 {
400         uint32_t rx_op, pf_func, index, match_id, flowkey_alg;
401         char index_name[NPC_MAX_FIELD_NAME_SIZE] = "Index:";
402
403         rx_op = npc_action & NPC_RX_ACTIONOP_MASK;
404
405         fprintf(file, "\tActionOp:");
406
407         switch (rx_op) {
408         case NIX_RX_ACTIONOP_DROP:
409                 fprintf(file, "NIX_RX_ACTIONOP_DROP (%lu)\n",
410                         (uint64_t)NIX_RX_ACTIONOP_DROP);
411                 break;
412         case NIX_RX_ACTIONOP_UCAST:
413                 fprintf(file, "NIX_RX_ACTIONOP_UCAST (%lu)\n",
414                         (uint64_t)NIX_RX_ACTIONOP_UCAST);
415                 strncpy(index_name, "RQ Index", NPC_MAX_FIELD_NAME_SIZE);
416                 break;
417         case NIX_RX_ACTIONOP_UCAST_IPSEC:
418                 fprintf(file, "NIX_RX_ACTIONOP_UCAST_IPSEC (%lu)\n",
419                         (uint64_t)NIX_RX_ACTIONOP_UCAST_IPSEC);
420                 strncpy(index_name, "RQ Index:", NPC_MAX_FIELD_NAME_SIZE);
421                 break;
422         case NIX_RX_ACTIONOP_MCAST:
423                 fprintf(file, "NIX_RX_ACTIONOP_MCAST (%lu)\n",
424                         (uint64_t)NIX_RX_ACTIONOP_MCAST);
425                 strncpy(index_name, "Multicast/mirror table index",
426                         NPC_MAX_FIELD_NAME_SIZE);
427                 break;
428         case NIX_RX_ACTIONOP_RSS:
429                 fprintf(file, "NIX_RX_ACTIONOP_RSS (%lu)\n",
430                         (uint64_t)NIX_RX_ACTIONOP_RSS);
431                 strncpy(index_name, "RSS Group Index",
432                         NPC_MAX_FIELD_NAME_SIZE);
433                 break;
434         case NIX_RX_ACTIONOP_PF_FUNC_DROP:
435                 fprintf(file, "NIX_RX_ACTIONOP_PF_FUNC_DROP (%lu)\n",
436                         (uint64_t)NIX_RX_ACTIONOP_PF_FUNC_DROP);
437                 break;
438         case NIX_RX_ACTIONOP_MIRROR:
439                 fprintf(file, "NIX_RX_ACTIONOP_MIRROR (%lu)\n",
440                         (uint64_t)NIX_RX_ACTIONOP_MIRROR);
441                 strncpy(index_name, "Multicast/mirror table index",
442                         NPC_MAX_FIELD_NAME_SIZE);
443                 break;
444         }
445
446         pf_func = ((npc_action & NPC_RX_ACTION_PFFUNC_MASK) >> 4) & 0xFFFF;
447
448         fprintf(file, "\tPF_FUNC: %#04X\n", pf_func);
449
450         index = ((npc_action & NPC_RX_ACTION_INDEX_MASK) >> 20) & 0xFFFFF;
451
452         fprintf(file, "\t%s:%#05X\n", index_name, index);
453
454         match_id = ((npc_action & NPC_RX_ACTION_MATCH_MASK) >> 40) & 0xFFFF;
455
456         fprintf(file, "\tMatch Id:%#04X\n", match_id);
457
458         flowkey_alg = ((npc_action & NPC_RX_ACTION_FLOWKEY_MASK) >> 56) & 0x1F;
459
460         fprintf(file, "\tFlow Key Alg:%#X\n", flowkey_alg);
461 }
462
463 static void
464 otx2_flow_dump_parsed_action(FILE *file, uint64_t npc_action, bool is_rx)
465 {
466         if (is_rx) {
467                 fprintf(file, "NPC RX Action:%#016lX\n", npc_action);
468                 otx2_flow_dump_rx_action(file, npc_action);
469         } else {
470                 fprintf(file, "NPC TX Action:%#016lX\n", npc_action);
471                 otx2_flow_dump_tx_action(file, npc_action);
472         }
473 }
474
475 static void
476 otx2_flow_dump_rx_vtag_action(FILE *file, uint64_t vtag_action)
477 {
478         uint32_t type, lid, relptr;
479
480         if (vtag_action & NIX_RX_VTAGACT_VTAG0_VALID_MASK) {
481                 relptr = vtag_action & NIX_RX_VTAGACT_VTAG0_RELPTR_MASK;
482                 lid = ((vtag_action & NIX_RX_VTAGACT_VTAG0_LID_MASK) >> 8)
483                         & 0x7;
484                 type = ((vtag_action & NIX_RX_VTAGACT_VTAG0_TYPE_MASK) >> 12)
485                         & 0x7;
486
487                 fprintf(file, "\tVTAG0:relptr:%#X\n", relptr);
488                 fprintf(file, "\tlid:%#X\n", lid);
489                 fprintf(file, "\ttype:%#X\n", type);
490         }
491
492         if (vtag_action & NIX_RX_VTAGACT_VTAG1_VALID_MASK) {
493                 relptr = ((vtag_action & NIX_RX_VTAGACT_VTAG1_RELPTR_MASK)
494                            >> 32) & 0xFF;
495                 lid = ((vtag_action & NIX_RX_VTAGACT_VTAG1_LID_MASK) >> 40)
496                         & 0x7;
497                 type = ((vtag_action & NIX_RX_VTAGACT_VTAG1_TYPE_MASK) >> 44)
498                         & 0x7;
499
500                 fprintf(file, "\tVTAG1:relptr:%#X\n", relptr);
501                 fprintf(file, "\tlid:%#X\n", lid);
502                 fprintf(file, "\ttype:%#X\n", type);
503         }
504 }
505
506 static void
507 otx2_get_vtag_opname(uint32_t op, char *opname, int len)
508 {
509         switch (op) {
510         case 0x0:
511                 strncpy(opname, "NOP", len - 1);
512                 break;
513         case 0x1:
514                 strncpy(opname, "INSERT", len - 1);
515                 break;
516         case 0x2:
517                 strncpy(opname, "REPLACE", len - 1);
518                 break;
519         }
520 }
521
522 static void
523 otx2_flow_dump_tx_vtag_action(FILE *file, uint64_t vtag_action)
524 {
525         uint32_t relptr, lid, op, vtag_def;
526         char opname[10];
527
528         relptr = vtag_action & NIX_TX_VTAGACT_VTAG0_RELPTR_MASK;
529         lid = ((vtag_action & NIX_TX_VTAGACT_VTAG0_LID_MASK) >> 8) & 0x7;
530         op = ((vtag_action & NIX_TX_VTAGACT_VTAG0_OP_MASK) >> 12) & 0x3;
531         vtag_def = ((vtag_action & NIX_TX_VTAGACT_VTAG0_DEF_MASK) >> 16)
532                    & 0x3FF;
533
534         otx2_get_vtag_opname(op, opname, sizeof(opname));
535
536         fprintf(file, "\tVTAG0 relptr:%#X\n", relptr);
537         fprintf(file, "\tlid:%#X\n", lid);
538         fprintf(file, "\top:%s\n", opname);
539         fprintf(file, "\tvtag_def:%#X\n", vtag_def);
540
541         relptr = ((vtag_action & NIX_TX_VTAGACT_VTAG1_RELPTR_MASK) >> 32)
542                  & 0xFF;
543         lid = ((vtag_action & NIX_TX_VTAGACT_VTAG1_LID_MASK) >> 40) & 0x7;
544         op = ((vtag_action & NIX_TX_VTAGACT_VTAG1_OP_MASK) >> 44) & 0x3;
545         vtag_def = ((vtag_action & NIX_TX_VTAGACT_VTAG1_DEF_MASK) >> 48)
546                    & 0x3FF;
547
548         otx2_get_vtag_opname(op, opname, sizeof(opname));
549
550         fprintf(file, "\tVTAG1:relptr:%#X\n", relptr);
551         fprintf(file, "\tlid:%#X\n", lid);
552         fprintf(file, "\top:%s\n", opname);
553         fprintf(file, "\tvtag_def:%#X\n", vtag_def);
554 }
555
556 static void
557 otx2_flow_dump_vtag_action(FILE *file, uint64_t vtag_action, bool is_rx)
558 {
559         if (is_rx) {
560                 fprintf(file, "NPC RX VTAG Action:%#016lX\n", vtag_action);
561                 otx2_flow_dump_rx_vtag_action(file, vtag_action);
562         } else {
563                 fprintf(file, "NPC TX VTAG Action:%#016lX\n", vtag_action);
564                 otx2_flow_dump_tx_vtag_action(file, vtag_action);
565         }
566 }
567
568 void
569 otx2_flow_dump(FILE *file, struct otx2_eth_dev *hw, struct rte_flow *flow)
570 {
571         bool is_rx = 0;
572         int i;
573
574         fprintf(file, "MCAM Index:%d\n", flow->mcam_id);
575         fprintf(file, "Interface :%s (%d)\n", intf_str[flow->nix_intf],
576                 flow->nix_intf);
577         fprintf(file, "Priority  :%d\n", flow->priority);
578
579         if (flow->nix_intf == NIX_INTF_RX)
580                 is_rx = 1;
581
582         otx2_flow_dump_parsed_action(file, flow->npc_action, is_rx);
583         otx2_flow_dump_vtag_action(file, flow->vtag_action, is_rx);
584         fprintf(file, "Patterns:\n");
585         otx2_flow_dump_patterns(file, hw, flow);
586
587         fprintf(file, "MCAM Raw Data :\n");
588
589         for (i = 0; i < OTX2_MAX_MCAM_WIDTH_DWORDS; i++)  {
590                 fprintf(file, "\tDW%d     :%016lX\n", i, flow->mcam_data[i]);
591                 fprintf(file, "\tDW%d_Mask:%016lX\n", i, flow->mcam_mask[i]);
592         }
593
594         fprintf(file, "\n");
595 }