Open Ethernet Networking (OpEN) API Guide and Reference Manual  3.4.4.5
openapi_tcam.h
Go to the documentation of this file.
1 
9 /*********************************************************************
10 *
11 * Copyright 2016-2018 Broadcom.
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 * http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 *
25 **********************************************************************
26 *
27 * @filename openapi_tcam.h
28 *
29 * @purpose TCAM API: Provide an interface for managing policy in hardware.
30 *
31 * @component Policy Manager (TCAM API)
32 *
33 * @create 09/01/2012
34 *
35 * @author
36 * @end
37 *
38 **********************************************************************/
39 #ifndef OPENAPI_TCAM_H_INCLUDED
40 #define OPENAPI_TCAM_H_INCLUDED
41 
56 #include "openapi_common.h"
57 
59 #define TCAM_MAC_ADDR_LEN 6
60 
62 #define OPEN_TCAM_API_CURR_VER_MAJOR 0
63 
64 #define OPEN_TCAM_API_CURR_VER_MINOR 1
65 
67 #define OPEN_TCAM_API_POLICYID_INVALID 0
68 
70 #define OPEN_TCAM_POLICY_RULE_PRIORITY_LOWEST 0
71 #define OPEN_TCAM_POLICY_RULE_PRIORITY_DEFAULT 1
72 
74 typedef enum
75 {
82 
84 #define TCAM_API_DEBUG(dbgLvl, args...) {\
85  if (tcamApiDebugFlag >= dbgLvl) \
86  {\
87  SYSAPI_PRINTF(SYSAPI_LOGGING_ALWAYS,args);\
88  }\
89 }
90 
92 #define OPEN_TXRX_MAX_FRAME_SIZE 9216
93 
94 #define OPEN_TCAM_EXT_AGENT_PKT_TRANSMIT (0x1)
95 
96 #define OPEN_TCAM_EXT_AGENT_PKT_RECEIVE (0x2)
97 
98 
99 typedef struct
100 {
101  uint32_t version; /* Desc struct version number */
102  uint32_t pktLength; /* Length of the packet */
103  uint32_t descLen; /* Length of the packet meta-data */
104 
105  uint32_t rxIfNum; /* Interface number on which packet was received */
106 
107  /* Add new meta-data at the end */
108  uint32_t destIntIfNum; /* Destination intIfNum */
109 
114  uint32_t rxUntagged;
119 typedef struct
120 {
121  uint32_t redirIntfNum;
122  unsigned char srcAddr[TCAM_MAC_ADDR_LEN];
123  unsigned char dstMac[TCAM_MAC_ADDR_LEN];
124  uint32_t etherType;
125  uint16_t vlanId;
126  unsigned char vlanPrio;
127  unsigned char dscp;
128 
130 
131 
133 #define OPEN_TCAM_ACTION_NONE 0
134 
135 #define OPEN_TCAM_ACTION_DROP 1 /* ((uint32_t)(1 << 0)) */
136 
137 #define OPEN_TCAM_ACTION_REDIRECT 2 /* ((uint32_t)(1 << 1)) */
138 
139 #define OPEN_TCAM_ACTION_OUTERVLAN 4 /* ((uint32_t)(1 << 2)) */
140 
141 #define OPEN_TCAM_ACTION_SRCMAC_NEW 8 /* ((uint32_t)(1 << 3)) */
142 
143 #define OPEN_TCAM_ACTION_DSTMAC_NEW 16 /* ((uint32_t)(1 << 4)) */
144 
145 #define OPEN_TCAM_ACTION_USERPRIO 32 /* ((uint32_t)(1 << 5)) */
146 
147 #define OPEN_TCAM_ACTION_OUTERTPID_NEW 64 /* ((uint32_t)(1 << 6)) */
148 
149 #define OPEN_TCAM_ACTION_REDIRECT_CPU 128 /* ((uint32_t)(1 << 7)) */
150 
152 #define OPEN_PT_MATCH_RULE_NUM 61
153 
154 #define OPEN_CPU_RATE_LIMIT 5
155 #define OPEN_CPU_RATE_LIMIT_BURST 5
156 
158 typedef uint32_t OPEN_TCAM_POLICY_ACTION_t;
160 typedef uint32_t OPEN_TCAM_API_POLICYID_t;
161 
163 typedef enum
164 {
172 
174 typedef struct
175 {
176  uint32_t versionMajor;
177  uint32_t versionMinor;
179 
180 
182 /* User needs to populate the header witht the version of the API
183  it expects to interact with*/
185 {
186  open_tcam_version_t versionInfo;
187 
188  uint32_t headerLen;
190 
191 /* Metering Definitions */
192 typedef enum
193 {
194  OPEN_METER_COLOR_BLIND,
195  OPEN_METER_COLOR_AWARE
196 } OPEN_METER_COLOR_MODE_t;
197 
198 typedef enum
199 {
200  OPEN_METER_BYTES,
201  OPEN_METER_PACKETS
202 } OPEN_METER_MODE_t;
203 
204 typedef struct
205 {
206  uint64_t in_prof; /* green/yellow */
207  uint64_t out_prof; /* red */
209 
210 typedef struct
211 {
212  uint32_t cir, cbs;
213  uint32_t pir, pbs;
214  OPEN_METER_COLOR_MODE_t colorMode;
215  OPEN_METER_MODE_t meterMode;
217 
218 #define OPEN_COUNT_PACKETS 0x1 /* matching packet counter */
219 #define OPEN_COUNT_BYTES 0x2 /* matching byte counter */
220 
221 typedef struct
222 {
223  uint64_t byteCount;
224  uint64_t pktCount;
226 
231 {
232  /* Policy attributes*/
233  tcam_api_policyHeader_t policyHeader;
237  uint32_t policyPrio;
240  /* Classification attributes */
241  uint64_t ruleNum;
242  uint32_t rulePrio;
243  unsigned char matchDstMac[TCAM_MAC_ADDR_LEN];
244  unsigned char matchSrcMac[TCAM_MAC_ADDR_LEN];
245  uint16_t matchVlanVal;
246  unsigned char matchVlanPrio;
247  uint16_t matchEthType;
248  uint32_t matchDstIp;
249  uint32_t matchDstIpMask;
250  uint32_t matchSrcIp;
251  uint32_t matchSrcIpMask;
252  uint32_t matchIpProto;
253  uint32_t matchIpProtoMask;
254  uint32_t matchL4Sport;
255  uint32_t matchL4SportMask;
256  uint32_t matchL4Dport;
257  uint32_t matchL4DportMask;
258  uint32_t matchIpDscp;
259  unsigned char matchIpDscpMask;
260  uint16_t matchSrcPortIcmpType;
261  uint16_t matchSrcPortIcmpTypeMask;
262  uint16_t matchDstPortIcmpCode;
263  uint16_t matchDstPortIcmpCodeMask;
264  open_in6_addr_t matchSrcIpv6Addr;
265  open_in6_addr_t matchSrcIpv6Mask;
266  open_in6_addr_t matchDstIpv6Addr;
267  open_in6_addr_t matchDstIpv6Mask;
268 
269  /* Actions*/
275  /* Policy Metering information */
276  OPEN_METER_ENTRY_t meterInfo;
277  uint8_t meterPresent; /* 1 meterInfo is valid, 0 not valid */
278 } open_tcamApiPolicy_t;
279 
283 {
284  uint32_t in_use_rules;
285  uint32_t total_rules;
287  uint32_t in_use_counters;
288  uint32_t total_counters;
290  uint32_t in_use_meters;
291  uint32_t total_meters;
295  uint32_t natural_depth;
297 
300 #define OPEN_TCAM_POLICY_NAME_SIZE 64
301 
302 #define OPEN_TCAM_STAGE_LOOKUP 1
303 #define OPEN_TCAM_STAGE_INGRESS 2
304 #define OPEN_TCAM_STAGE_EGRESS 3
308 typedef struct open_tcamHardwarePolicyUsage_s
309 {
310  uint8_t policy_name [OPEN_TCAM_POLICY_NAME_SIZE];
311  uint32_t num_policy_rules;
312  uint32_t hardware_stage;
313  uint32_t hardware_group;
314  uint32_t in_use_rules;
315  uint32_t total_rules;
317 
318 /**********************************************************************/
332 
333 /**********************************************************************/
347 
348 /**********************************************************************/
370  open_tcamApiPolicy_t policyInfo,
371  OPEN_TCAM_API_POLICYID_t *handle);
372 
373 /**********************************************************************/
394  OPEN_TCAM_API_POLICYID_t *policyHandle);
395 
396 /**********************************************************************/
415  OPEN_TCAM_API_POLICYID_t *policyHandle,
416  uint32_t intf);
417 
418 /**********************************************************************/
436  OPEN_TCAM_API_POLICYID_t *policyHandle,
437  uint32_t intf);
438 
439 /**********************************************************************/
455  OPEN_TCAM_API_POLICYID_t *policyHandle,
456  open_tcamApiPolicy_t *policyInfo);
457 
458 /**********************************************************************/
477  open_tcamApiPolicy_t *policyInfo,
478  OPEN_TCAM_API_POLICYID_t *nextPolicyHandle);
479 
480 /**********************************************************************/
500  OPEN_TCAM_API_POLICYID_t *policyHandle,
501  open_tcamApiPolicy_t *policyInfo,
502  OPEN_TCAM_API_POLICYID_t *nextPolicyHandle);
503 
504 /**********************************************************************/
518 
519 /**********************************************************************/
535  open_tcam_version_t *version);
536 
537 /**********************************************************************/
559 open_error_t openapiExtAgentPktRegister( uint32_t agentId,
560  open_buffdesc *agentName,
561  uint32_t flags);
562 
563 /**********************************************************************/
574 open_error_t openapiExtAgentPktUnregister( uint32_t agentId);
575 
576 /*****************************************************************/
599  uint32_t *unit,
600  uint32_t *asic_id,
601  uint32_t *policy_id,
602  open_tcamHardwarePolicyUsage_t *tcam_usage);
603 
604 /**********************************************************************/
629  uint32_t *unit,
630  uint32_t *asic_id,
631  uint32_t *stage,
632  uint32_t *group_id,
633  open_tcamHardwareGroupUsage_t *group_usage);
634 
635 /**********************************************************************/
651  OPEN_TCAM_API_POLICYID_t *policyHandle);
652 
653 /**********************************************************************/
669  OPEN_TCAM_API_POLICYID_t *policyHandle,
670  uint64_t *inProf, uint64_t *outProf);
671 
672 /**********************************************************************/
686  OPEN_TCAM_API_POLICYID_t *policyHandle);
687 
688 #endif /* OPENAPI_TCAM_H_INCLUDED*/
689