net/bnxt: modify resource management scheme
[dpdk.git] / drivers / net / bnxt / tf_core / tf_util.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2014-2019 Broadcom
3  * All rights reserved.
4  */
5
6 #include <string.h>
7
8 #include "tf_util.h"
9
10 const char *
11 tf_dir_2_str(enum tf_dir dir)
12 {
13         switch (dir) {
14         case TF_DIR_RX:
15                 return "RX";
16         case TF_DIR_TX:
17                 return "TX";
18         default:
19                 return "Invalid direction";
20         }
21 }
22
23 const char *
24 tf_ident_2_str(enum tf_identifier_type id_type)
25 {
26         switch (id_type) {
27         case TF_IDENT_TYPE_L2_CTXT_HIGH:
28                 return "l2_ctxt_remap_high";
29         case TF_IDENT_TYPE_L2_CTXT_LOW:
30                 return "l2_ctxt_remap_low";
31         case TF_IDENT_TYPE_PROF_FUNC:
32                 return "prof_func";
33         case TF_IDENT_TYPE_WC_PROF:
34                 return "wc_prof";
35         case TF_IDENT_TYPE_EM_PROF:
36                 return "em_prof";
37         case TF_IDENT_TYPE_L2_FUNC:
38                 return "l2_func";
39         default:
40                 return "Invalid identifier";
41         }
42 }
43
44 const char *
45 tf_tcam_tbl_2_str(enum tf_tcam_tbl_type tcam_type)
46 {
47         switch (tcam_type) {
48         case TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH:
49                 return "l2_ctxt_tcam_high";
50         case TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW:
51                 return "l2_ctxt_tcam_low";
52         case TF_TCAM_TBL_TYPE_PROF_TCAM:
53                 return "prof_tcam";
54         case TF_TCAM_TBL_TYPE_WC_TCAM:
55                 return "wc_tcam";
56         case TF_TCAM_TBL_TYPE_VEB_TCAM:
57                 return "veb_tcam";
58         case TF_TCAM_TBL_TYPE_SP_TCAM:
59                 return "sp_tcam";
60         case TF_TCAM_TBL_TYPE_CT_RULE_TCAM:
61                 return "ct_rule_tcam";
62         default:
63                 return "Invalid tcam table type";
64         }
65 }
66
67 const char *
68 tf_tbl_type_2_str(enum tf_tbl_type tbl_type)
69 {
70         switch (tbl_type) {
71         case TF_TBL_TYPE_FULL_ACT_RECORD:
72                 return "Full Action record";
73         case TF_TBL_TYPE_MCAST_GROUPS:
74                 return "Multicast Groups";
75         case TF_TBL_TYPE_ACT_ENCAP_8B:
76                 return "Encap 8B";
77         case TF_TBL_TYPE_ACT_ENCAP_16B:
78                 return "Encap 16B";
79         case TF_TBL_TYPE_ACT_ENCAP_32B:
80                 return "Encap 32B";
81         case TF_TBL_TYPE_ACT_ENCAP_64B:
82                 return "Encap 64B";
83         case TF_TBL_TYPE_ACT_SP_SMAC:
84                 return "Source Properties SMAC";
85         case TF_TBL_TYPE_ACT_SP_SMAC_IPV4:
86                 return "Source Properties SMAC IPv4";
87         case TF_TBL_TYPE_ACT_SP_SMAC_IPV6:
88                 return "Source Properties SMAC IPv6";
89         case TF_TBL_TYPE_ACT_STATS_64:
90                 return "Stats 64B";
91         case TF_TBL_TYPE_ACT_MODIFY_SPORT:
92                 return "NAT Source Port";
93         case TF_TBL_TYPE_ACT_MODIFY_DPORT:
94                 return "NAT Destination Port";
95         case TF_TBL_TYPE_ACT_MODIFY_IPV4_SRC:
96                 return "NAT IPv4 Source";
97         case TF_TBL_TYPE_ACT_MODIFY_IPV4_DEST:
98                 return "NAT IPv4 Destination";
99         case TF_TBL_TYPE_METER_PROF:
100                 return "Meter Profile";
101         case TF_TBL_TYPE_METER_INST:
102                 return "Meter";
103         case TF_TBL_TYPE_MIRROR_CONFIG:
104                 return "Mirror";
105         case TF_TBL_TYPE_UPAR:
106                 return "UPAR";
107         case TF_TBL_TYPE_EPOCH0:
108                 return "EPOCH0";
109         case TF_TBL_TYPE_EPOCH1:
110                 return "EPOCH1";
111         case TF_TBL_TYPE_METADATA:
112                 return "Metadata";
113         case TF_TBL_TYPE_CT_STATE:
114                 return "Connection State";
115         case TF_TBL_TYPE_RANGE_PROF:
116                 return "Range Profile";
117         case TF_TBL_TYPE_RANGE_ENTRY:
118                 return "Range";
119         case TF_TBL_TYPE_LAG:
120                 return "Link Aggregation";
121         case TF_TBL_TYPE_VNIC_SVIF:
122                 return "VNIC SVIF";
123         case TF_TBL_TYPE_EM_FKB:
124                 return "EM Flexible Key Builder";
125         case TF_TBL_TYPE_WC_FKB:
126                 return "WC Flexible Key Builder";
127         case TF_TBL_TYPE_EXT:
128                 return "External";
129         default:
130                 return "Invalid tbl type";
131         }
132 }
133
134 const char *
135 tf_em_tbl_type_2_str(enum tf_em_tbl_type em_type)
136 {
137         switch (em_type) {
138         case TF_EM_TBL_TYPE_EM_RECORD:
139                 return "EM Record";
140         case TF_EM_TBL_TYPE_TBL_SCOPE:
141                 return "Table Scope";
142         default:
143                 return "Invalid EM type";
144         }
145 }
146
147 const char *
148 tf_device_module_type_subtype_2_str(enum tf_device_module_type dm_type,
149                                     uint16_t mod_type)
150 {
151         switch (dm_type) {
152         case TF_DEVICE_MODULE_TYPE_IDENTIFIER:
153                 return tf_ident_2_str(mod_type);
154         case TF_DEVICE_MODULE_TYPE_TABLE:
155                 return tf_tbl_type_2_str(mod_type);
156         case TF_DEVICE_MODULE_TYPE_TCAM:
157                 return tf_tcam_tbl_2_str(mod_type);
158         case TF_DEVICE_MODULE_TYPE_EM:
159                 return tf_em_tbl_type_2_str(mod_type);
160         default:
161                 return "Invalid Device Module type";
162         }
163 }
164
165 const char *
166 tf_device_module_type_2_str(enum tf_device_module_type dm_type)
167 {
168         switch (dm_type) {
169         case TF_DEVICE_MODULE_TYPE_IDENTIFIER:
170                 return "Identifier";
171         case TF_DEVICE_MODULE_TYPE_TABLE:
172                 return "Table";
173         case TF_DEVICE_MODULE_TYPE_TCAM:
174                 return "TCAM";
175         case TF_DEVICE_MODULE_TYPE_EM:
176                 return "EM";
177         default:
178                 return "Invalid Device Module type";
179         }
180 }