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