Open Ethernet Networking (OpEN) API Guide and Reference Manual  3.6.0.3
openapi_tcam.h
Go to the documentation of this file.
1 
9 /*********************************************************************
10 *
11 * Copyright 2016-2019 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 
284 {
285  /* Policy attributes*/
286  tcam_api_policyHeader_t policyHeader;
290  uint32_t policyPrio;
293  /* Classification attributes */
294  uint64_t ruleNum;
295  uint32_t rulePrio;
296  unsigned char matchDstMac[TCAM_MAC_ADDR_LEN];
297  unsigned char matchSrcMac[TCAM_MAC_ADDR_LEN];
298  uint16_t matchVlanVal;
299  unsigned char matchVlanPrio;
300  uint16_t matchEthType;
301  uint32_t matchDstIp;
302  uint32_t matchDstIpMask;
303  uint32_t matchSrcIp;
304  uint32_t matchSrcIpMask;
305  uint32_t matchIpProto;
306  uint32_t matchIpProtoMask;
307  uint32_t matchL4Sport;
308  uint32_t matchL4SportMask;
309  uint32_t matchL4Dport;
310  uint32_t matchL4DportMask;
311  uint32_t matchIpDscp;
312  unsigned char matchIpDscpMask;
313  uint16_t matchSrcPortIcmpType;
314  uint16_t matchSrcPortIcmpTypeMask;
315  uint16_t matchDstPortIcmpCode;
316  uint16_t matchDstPortIcmpCodeMask;
317  open_in6_addr_t matchSrcIpv6Addr;
318  open_in6_addr_t matchSrcIpv6Mask;
319  open_in6_addr_t matchDstIpv6Addr;
320  open_in6_addr_t matchDstIpv6Mask;
321  unsigned char matchCpuVisibility;
322  unsigned char matchCpuVisibilityMask;
323 
324  /* Actions*/
330  /* Policy Metering information */
331  OPEN_METER_ENTRY_t meterInfo;
332  uint8_t meterPresent; /* 1 meterInfo is valid, 0 not valid */
333 } open_tcamApiPolicy_v2_t;
334 
338 {
339  uint32_t in_use_rules;
340  uint32_t total_rules;
342  uint32_t in_use_counters;
343  uint32_t total_counters;
345  uint32_t in_use_meters;
346  uint32_t total_meters;
350  uint32_t natural_depth;
352 
355 #define OPEN_TCAM_POLICY_NAME_SIZE 64
356 
357 #define OPEN_TCAM_STAGE_LOOKUP 1
358 #define OPEN_TCAM_STAGE_INGRESS 2
359 #define OPEN_TCAM_STAGE_EGRESS 3
363 typedef struct open_tcamHardwarePolicyUsage_s
364 {
365  uint8_t policy_name [OPEN_TCAM_POLICY_NAME_SIZE];
366  uint32_t num_policy_rules;
367  uint32_t hardware_stage;
368  uint32_t hardware_group;
369  uint32_t in_use_rules;
370  uint32_t total_rules;
372 
373 /**********************************************************************/
387 
388 /**********************************************************************/
402 
403 /**********************************************************************/
429  open_tcamApiPolicy_t policyInfo,
430  OPEN_TCAM_API_POLICYID_t *handle);
431 
432 /**********************************************************************/
453  OPEN_TCAM_API_POLICYID_t *policyHandle);
454 
455 /**********************************************************************/
474  OPEN_TCAM_API_POLICYID_t *policyHandle,
475  uint32_t intf);
476 
477 /**********************************************************************/
495  OPEN_TCAM_API_POLICYID_t *policyHandle,
496  uint32_t intf);
497 
498 /**********************************************************************/
517  OPEN_TCAM_API_POLICYID_t *policyHandle,
518  open_tcamApiPolicy_t *policyInfo);
519 
520 /**********************************************************************/
542  open_tcamApiPolicy_t *policyInfo,
543  OPEN_TCAM_API_POLICYID_t *nextPolicyHandle);
544 
545 /**********************************************************************/
568  OPEN_TCAM_API_POLICYID_t *policyHandle,
569  open_tcamApiPolicy_t *policyInfo,
570  OPEN_TCAM_API_POLICYID_t *nextPolicyHandle);
571 
572 /**********************************************************************/
586 
587 /**********************************************************************/
603  open_tcam_version_t *version);
604 
605 /**********************************************************************/
627 open_error_t openapiExtAgentPktRegister( uint32_t agentId,
628  open_buffdesc *agentName,
629  uint32_t flags);
630 
631 /**********************************************************************/
642 open_error_t openapiExtAgentPktUnregister( uint32_t agentId);
643 
644 /*****************************************************************/
667  uint32_t *unit,
668  uint32_t *asic_id,
669  uint32_t *policy_id,
670  open_tcamHardwarePolicyUsage_t *tcam_usage);
671 
672 /**********************************************************************/
697  uint32_t *unit,
698  uint32_t *asic_id,
699  uint32_t *stage,
700  uint32_t *group_id,
701  open_tcamHardwareGroupUsage_t *group_usage);
702 
703 /**********************************************************************/
719  OPEN_TCAM_API_POLICYID_t *policyHandle);
720 
721 /**********************************************************************/
737  OPEN_TCAM_API_POLICYID_t *policyHandle,
738  uint64_t *inProf, uint64_t *outProf);
739 
740 /**********************************************************************/
754  OPEN_TCAM_API_POLICYID_t *policyHandle);
755 
756 /**********************************************************************/
778  open_tcamApiPolicy_v2_t policyInfo,
779  OPEN_TCAM_API_POLICYID_t *handle);
780 
781 /**********************************************************************/
797  OPEN_TCAM_API_POLICYID_t *policyHandle,
798  open_tcamApiPolicy_v2_t *policyInfo);
799 
800 /**********************************************************************/
819  open_tcamApiPolicy_v2_t *policyInfo,
820  OPEN_TCAM_API_POLICYID_t *nextPolicyHandle);
821 
822 /**********************************************************************/
842  OPEN_TCAM_API_POLICYID_t *policyHandle,
843  open_tcamApiPolicy_v2_t *policyInfo,
844  OPEN_TCAM_API_POLICYID_t *nextPolicyHandle);
845 
846 #endif /* OPENAPI_TCAM_H_INCLUDED*/
847 
open_error_t openapiTcamPolicyDeleteAll(openapiClientHandle_t *clientHandle)
Delete all the policies created by TCAM API.
Hardware TCAM Policy Usage Information.
Definition: openapi_tcam.h:363
open_error_t openapiTcamPolicyCreate(openapiClientHandle_t *clientHandle, open_tcamApiPolicy_t policyInfo, OPEN_TCAM_API_POLICYID_t *handle)
Create a policy in the hardware directly.
uint32_t policyPrio
Definition: openapi_tcam.h:237
OPEN_TCAM_POLICY_TYPE_t
Enumeration to describe where the policy should apply.
Definition: openapi_tcam.h:163
open_error_t openapiTcamApiInit(openapiClientHandle_t *clientHandle)
Initialize the TCAM API.
OPEN_TCAM_ACTION_t actionVal
Definition: openapi_tcam.h:272
open_error_t openapiTcamPolicyGetV2(openapiClientHandle_t *clientHandle, OPEN_TCAM_API_POLICYID_t *policyHandle, open_tcamApiPolicy_v2_t *policyInfo)
Get TCAM policy information from the policy handle provided.
open_error_t openapiTcamApiFini(openapiClientHandle_t *clientHandle)
Uninitialize the TCAM API and return its resources.
uint32_t in_use_rules
Number of rules currently used in the hardware group.
Definition: openapi_tcam.h:339
open_error_t openapiTcamPolicyGetFirstV2(openapiClientHandle_t *clientHandle, open_tcamApiPolicy_v2_t *policyInfo, OPEN_TCAM_API_POLICYID_t *nextPolicyHandle)
Get the first TCAM policy information.
uint32_t total_counters
Total counters available for the hardware group.
Definition: openapi_tcam.h:343
open_error_t openapiTcamPolicyDestroy(openapiClientHandle_t *clientHandle, OPEN_TCAM_API_POLICYID_t *policyHandle)
Delete the policy created.
uint32_t total_rules
Total number of rules that can be added to the hardware group.
Definition: openapi_tcam.h:340
open_error_t
OPEN uses these enumerators to indicate the error codes.
#define OPEN_TCAM_POLICY_NAME_SIZE
Maximum number of characters in the policy name.
Definition: openapi_tcam.h:355
open_error_t openapiExtAgentPktUnregister(uint32_t agentId)
Unregister an External Packet Transmit/Receive Agent.
open_error_t openapiTcamApiVersionGet(openapiClientHandle_t *clientHandle, open_tcam_version_t *version)
Get the version supported by the current API.
uint32_t total_rules
Total number of rules that can be added to the hardware group.
Definition: openapi_tcam.h:370
open_error_t openapiTcamPolicyIntfAdd(openapiClientHandle_t *clientHandle, OPEN_TCAM_API_POLICYID_t *policyHandle, uint32_t intf)
Add the TCAM policy to the list of interfaces provided.
open_error_t openapiTcamHardwareGroupUsageGetNext(openapiClientHandle_t *client_handle, uint32_t *unit, uint32_t *asic_id, uint32_t *stage, uint32_t *group_id, open_tcamHardwareGroupUsage_t *group_usage)
Get the hardware usage statistics for the next hardware group after the specified hardware group...
open_error_t openapiTcamPolicyCreateV2(openapiClientHandle_t *clientHandle, open_tcamApiPolicy_v2_t policyInfo, OPEN_TCAM_API_POLICYID_t *handle)
Create a policy in the hardware directly.
struct tcam_api_policyHeader_s tcam_api_policyHeader_t
Header that goes on the front of each policy.
uint32_t OPEN_TCAM_POLICY_ACTION_t
Type for Policy actions.
Definition: openapi_tcam.h:158
open_error_t openapiExtAgentPktRegister(uint32_t agentId, open_buffdesc *agentName, uint32_t flags)
Register an External Packet Transmit/Receive Agent.
Header that goes on the front of each policy.
Definition: openapi_tcam.h:184
uint32_t natural_depth
Number of rules when slice depth is one.
Definition: openapi_tcam.h:350
uint32_t in_use_meters
Number of meters currently used in the hardware group.
Definition: openapi_tcam.h:345
#define TCAM_MAC_ADDR_LEN
The typical sequence is: openapiTcamApiInit() to initialize the TCAM API repeat openapiTcamPolicyCr...
Definition: openapi_tcam.h:59
open_error_t openapiTcamPolicyGetNext(openapiClientHandle_t *clientHandle, OPEN_TCAM_API_POLICYID_t *policyHandle, open_tcamApiPolicy_t *policyInfo, OPEN_TCAM_API_POLICYID_t *nextPolicyHandle)
Get the next TCAM policy information from the policy handle provided.
TCAM_API_DEBUG_FLAG_t
Enumeration of debug flags.
Definition: openapi_tcam.h:74
Version information for the TCAM API.
Definition: openapi_tcam.h:174
OPEN_PACKED_STRUCT tcamApiPolicy_v2_s
Structure that contains the full TCAM API policy: headers, match values and action.
Definition: openapi_tcam.h:284
open_error_t openapiTcamPolicyMeteringStatsGet(openapiClientHandle_t *clientHandle, OPEN_TCAM_API_POLICYID_t *policyHandle, uint64_t *inProf, uint64_t *outProf)
Get TCAM policy statistics for the policy handle provided.
uint32_t hardware_group
The group in the TCAM to which this policy belongs.
Definition: openapi_tcam.h:368
OPEN_PACKED_STRUCT tcamApiPolicy_s
Structure that contains the full TCAM API policy: headers, match values and action.
Definition: openapi_tcam.h:231
open_error_t openapiTcamPolicyGetFirst(openapiClientHandle_t *clientHandle, open_tcamApiPolicy_t *policyInfo, OPEN_TCAM_API_POLICYID_t *nextPolicyHandle)
Get the first TCAM policy information.
struct open_tcamHardwareGroupUsage_s open_tcamHardwareGroupUsage_t
Hardware TCAM group usage information.
open_error_t openapiTcamHardwarePolicyUsageGetNext(openapiClientHandle_t *client_handle, uint32_t *unit, uint32_t *asic_id, uint32_t *policy_id, open_tcamHardwarePolicyUsage_t *tcam_usage)
Get the policy hardware usage statistics for the next policy after the specified policy.
OPEN_TCAM_POLICY_TYPE_t policyType
Definition: openapi_tcam.h:235
struct open_tcamHardwarePolicyUsage_s open_tcamHardwarePolicyUsage_t
Hardware TCAM Policy Usage Information.
uint32_t total_meters
Total meters available for the hardware group.
Definition: openapi_tcam.h:346
uint32_t OPEN_TCAM_API_POLICYID_t
Type for Policy IDs.
Definition: openapi_tcam.h:160
OPEN_TCAM_POLICY_ACTION_t actionType
Definition: openapi_tcam.h:270
OPEN_PACKED_STRUCT
MPLS LFDB entry information.
Definition: openapi_mpls.h:103
open_error_t openapiTcamPolicyGetNextV2(openapiClientHandle_t *clientHandle, OPEN_TCAM_API_POLICYID_t *policyHandle, open_tcamApiPolicy_v2_t *policyInfo, OPEN_TCAM_API_POLICYID_t *nextPolicyHandle)
Get the next TCAM policy information from the policy handle provided.
uint32_t slice_width_physical
Slice width of group based on physical slices.
Definition: openapi_tcam.h:348
uint32_t in_use_rules
Number of rules currently used in the hardware group.
Definition: openapi_tcam.h:369
Definition: openapi_tcam.h:210
uint32_t intraslice_mode_enable
Indicates if intraslice mode is enabled.
Definition: openapi_tcam.h:349
uint32_t rxUntagged
Parameter to specify whether the packet ingressing on physical port is having VLAN tag or not...
Definition: openapi_tcam.h:114
open_error_t openapiTcamPolicyGet(openapiClientHandle_t *clientHandle, OPEN_TCAM_API_POLICYID_t *policyHandle, open_tcamApiPolicy_t *policyInfo)
Get TCAM policy information from the policy handle provided.
open_error_t openapiTcamPolicyIntfRem(openapiClientHandle_t *clientHandle, OPEN_TCAM_API_POLICYID_t *policyHandle, uint32_t intf)
Remove TCAM policy from the list of interfaces provided.
uint32_t num_policy_rules
Number of rules in this policy.
Definition: openapi_tcam.h:366
uint32_t hardware_stage
In which TCAM the policy is installed.
Definition: openapi_tcam.h:367
Structure to define the action that should be taken.
Definition: openapi_tcam.h:119
open_error_t openapiTcamPolicyIntfAllAdd(openapiClientHandle_t *clientHandle, OPEN_TCAM_API_POLICYID_t *policyHandle)
Add the TCAM policy to all interfaces.
Hash Mode names.
uint32_t in_use_counters
Number of counters currently used in the hardware group.
Definition: openapi_tcam.h:342
Hardware TCAM group usage information.
Definition: openapi_tcam.h:337
open_error_t openapiTcamPolicyStatsClear(openapiClientHandle_t *clientHandle, OPEN_TCAM_API_POLICYID_t *policyHandle)
Clear TCAM policy statistics for the policy handle provided.