xref: /freebsd/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_cc.h (revision d9f0ce31900a48d1a2bfc1c8c86f79d1e831451a)
1 /* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *     * Redistributions of source code must retain the above copyright
7  *       notice, this list of conditions and the following disclaimer.
8  *     * Redistributions in binary form must reproduce the above copyright
9  *       notice, this list of conditions and the following disclaimer in the
10  *       documentation and/or other materials provided with the distribution.
11  *     * Neither the name of Freescale Semiconductor nor the
12  *       names of its contributors may be used to endorse or promote products
13  *       derived from this software without specific prior written permission.
14  *
15  *
16  * ALTERNATIVELY, this software may be distributed under the terms of the
17  * GNU General Public License ("GPL") as published by the Free Software
18  * Foundation, either version 2 of that License or (at your option) any
19  * later version.
20  *
21  * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
22  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
25  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 /******************************************************************************
34  @File          fm_cc.h
35 
36  @Description   FM PCD CC ...
37 *//***************************************************************************/
38 #ifndef __FM_CC_H
39 #define __FM_CC_H
40 
41 #include "std_ext.h"
42 #include "error_ext.h"
43 #include "list_ext.h"
44 
45 #include "fm_pcd.h"
46 
47 
48 /***********************************************************************/
49 /*          Coarse classification defines                              */
50 /***********************************************************************/
51 
52 #define CC_PC_FF_MACDST                     0x00
53 #define CC_PC_FF_MACSRC                     0x01
54 #define CC_PC_FF_ETYPE                      0x02
55 
56 #define CC_PC_FF_TCI1                       0x03
57 #define CC_PC_FF_TCI2                       0x04
58 
59 #define CC_PC_FF_MPLS1                      0x06
60 #define CC_PC_FF_MPLS_LAST                  0x07
61 
62 #define CC_PC_FF_IPV4DST1                   0x08
63 #define CC_PC_FF_IPV4DST2                   0x16
64 #define CC_PC_FF_IPV4IPTOS_TC1              0x09
65 #define CC_PC_FF_IPV4IPTOS_TC2              0x17
66 #define CC_PC_FF_IPV4PTYPE1                 0x0A
67 #define CC_PC_FF_IPV4PTYPE2                 0x18
68 #define CC_PC_FF_IPV4SRC1                   0x0b
69 #define CC_PC_FF_IPV4SRC2                   0x19
70 #define CC_PC_FF_IPV4SRC1_IPV4DST1          0x0c
71 #define CC_PC_FF_IPV4SRC2_IPV4DST2          0x1a
72 #define CC_PC_FF_IPV4TTL                    0x29
73 
74 
75 #define CC_PC_FF_IPTOS_IPV6TC1_IPV6FLOW1    0x0d /*TODO - CLASS - what is it? TOS*/
76 #define CC_PC_FF_IPTOS_IPV6TC2_IPV6FLOW2    0x1b
77 #define CC_PC_FF_IPV6PTYPE1                 0x0e
78 #define CC_PC_FF_IPV6PTYPE2                 0x1c
79 #define CC_PC_FF_IPV6DST1                   0x0f
80 #define CC_PC_FF_IPV6DST2                   0x1d
81 #define CC_PC_FF_IPV6SRC1                   0x10
82 #define CC_PC_FF_IPV6SRC2                   0x1e
83 #define CC_PC_FF_IPV6HOP_LIMIT              0x2a
84 #define CC_PC_FF_GREPTYPE                   0x11
85 
86 #define CC_PC_FF_MINENCAP_PTYPE             0x12
87 #define CC_PC_FF_MINENCAP_IPDST             0x13
88 #define CC_PC_FF_MINENCAP_IPSRC             0x14
89 #define CC_PC_FF_MINENCAP_IPSRC_IPDST       0x15
90 
91 #define CC_PC_FF_L4PSRC                     0x1f
92 #define CC_PC_FF_L4PDST                     0x20
93 #define CC_PC_FF_L4PSRC_L4PDST              0x21
94 
95 #define CC_PC_FF_PPPPID                     0x05
96 
97 #define CC_PC_PR_SHIM1                      0x22
98 #define CC_PC_PR_SHIM2                      0x23
99 
100 #define CC_PC_GENERIC_WITHOUT_MASK          0x27
101 #define CC_PC_GENERIC_WITH_MASK             0x28
102 #define CC_PC_GENERIC_IC_GMASK              0x2B
103 #define CC_PC_GENERIC_IC_HASH_INDEXED       0x2C
104 
105 #define CC_PR_OFFSET                        0x25
106 #define CC_PR_WITHOUT_OFFSET                0x26
107 
108 #define CC_PC_PR_ETH_OFFSET                 19
109 #define CC_PC_PR_USER_DEFINED_SHIM1_OFFSET  16
110 #define CC_PC_PR_USER_DEFINED_SHIM2_OFFSET  17
111 #define CC_PC_PR_USER_LLC_SNAP_OFFSET       20
112 #define CC_PC_PR_VLAN1_OFFSET               21
113 #define CC_PC_PR_VLAN2_OFFSET               22
114 #define CC_PC_PR_PPPOE_OFFSET               24
115 #define CC_PC_PR_MPLS1_OFFSET               25
116 #define CC_PC_PR_MPLS_LAST_OFFSET           26
117 #define CC_PC_PR_IP1_OFFSET                 27
118 #define CC_PC_PR_IP_LAST_OFFSET             28
119 #define CC_PC_PR_MINENC_OFFSET              28
120 #define CC_PC_PR_L4_OFFSET                  30
121 #define CC_PC_PR_GRE_OFFSET                 29
122 #define CC_PC_PR_ETYPE_LAST_OFFSET          23
123 #define CC_PC_PR_NEXT_HEADER_OFFSET         31
124 
125 #define CC_PC_ILLEGAL                       0xff
126 #define CC_SIZE_ILLEGAL                     0
127 
128 #define FM_PCD_CC_KEYS_MATCH_TABLE_ALIGN    16
129 #define FM_PCD_CC_AD_TABLE_ALIGN            256
130 #define FM_PCD_CC_AD_ENTRY_SIZE             16
131 #define FM_PCD_CC_NUM_OF_KEYS               255
132 
133 #define FM_PCD_AD_RESULT_CONTRL_FLOW_TYPE   0x00000000
134 #define FM_PCD_AD_RESULT_DATA_FLOW_TYPE     0x80000000
135 #define FM_PCD_AD_RESULT_PLCR_DIS           0x20000000
136 #define FM_PCD_AD_RESULT_EXTENDED_MODE      0x80000000
137 #define FM_PCD_AD_RESULT_NADEN              0x20000000
138 #define FM_PCD_AD_RESULT_STATISTICS_EN      0x40000000
139 
140 
141 #define FM_PCD_AD_CONT_LOOKUP_TYPE          0x40000000
142 #define FM_PCD_AD_CONT_LOOKUP_LCL_MASK      0x00800000
143 
144 #define FM_PCD_AD_TYPE_MASK                 0xc0000000
145 #define FM_PCD_AD_OPCODE_MASK               0x0000000f
146 
147 #define FM_PCD_AD_PROFILEID_FOR_CNTRL_SHIFT 16
148 
149 #define GLBL_MASK_FOR_HASH_INDEXED          0xfff00000
150 #define CC_GLBL_MASK_SIZE                   4
151 
152 typedef uint32_t ccPrivateInfo_t; /**< private info of CC: */
153 
154 #define CC_PRIVATE_INFO_NONE                       0
155 #define CC_PRIVATE_INFO_IC_HASH_INDEX_LOOKUP       0x80000000
156 #define CC_PRIVATE_INFO_IC_HASH_EXACT_MATCH        0x40000000
157 #define CC_PRIVATE_INFO_IC_KEY_EXACT_MATCH         0x20000000
158 #define CC_PRIVATE_INFO_IC_DEQ_FQID_INDEX_LOOKUP   0x10000000
159 
160 /***********************************************************************/
161 /*          Memory map                                                 */
162 /***********************************************************************/
163 #if defined(__MWERKS__) && !defined(__GNUC__)
164 #pragma pack(push,1)
165 #endif /* defined(__MWERKS__) && ... */
166 #define MEM_MAP_START
167 
168 typedef _Packed struct {
169     volatile uint32_t fqid;
170     volatile uint32_t plcrProfile;
171     volatile uint32_t nia;
172     volatile uint32_t  res;
173 } _PackedType t_AdOfTypeResult;
174 
175 typedef _Packed struct {
176     volatile uint32_t ccAdBase;
177     volatile uint32_t matchTblPtr;
178     volatile uint32_t pcAndOffsets;
179     volatile uint32_t gmask;
180 } _PackedType t_AdOfTypeContLookup;
181 
182 typedef _Packed union {
183     volatile t_AdOfTypeResult        adResult;
184     volatile t_AdOfTypeContLookup    adContLookup;
185 } _PackedType t_Ad;
186 
187 #define MEM_MAP_END
188 #if defined(__MWERKS__) && !defined(__GNUC__)
189 #pragma pack(pop)
190 #endif /* defined(__MWERKS__) && ... */
191 
192 
193 /***********************************************************************/
194 /*  Driver's internal structures                                        */
195 /***********************************************************************/
196 
197 typedef enum e_ModifyState {
198     e_MODIFY_STATE_ADD = 0,
199     e_MODIFY_STATE_REMOVE,
200     e_MODIFY_STATE_CHANGE
201 } e_ModifyState;
202 
203 typedef struct {
204     t_FmPcdCcNextEngineParams   nextEngineParams;
205     uint32_t                    requiredAction;
206     uint32_t                    shadowAction;
207 } t_FmPcdCcNextEngineAndRequiredActionParams;
208 
209 typedef struct {
210     t_Handle         p_Ad;
211     e_FmPcdEngine    fmPcdEngine;
212     bool             adAllocated;
213     bool             isTree;
214 
215     uint32_t    myInfo;
216     t_List      *h_CcNextNodesLst;
217     t_Handle    h_AdditionalInfo;
218     t_Handle    h_Node;
219 } t_FmPcdModifyCcAdditionalParams;
220 
221 typedef struct {
222     t_Handle p_AdTableNew;
223     t_Handle p_KeysMatchTableNew;
224     t_Handle p_AdTableOld;
225     t_Handle p_KeysMatchTableOld;
226     uint16_t numOfKeys;
227     t_Handle h_CurrentNode;
228     uint16_t keyIndex;
229     t_Handle h_NodeForAdd;
230     t_Handle h_NodeForRmv;
231     t_Handle h_ManipForRmv;
232     bool     tree;
233 
234     t_FmPcdCcNextEngineAndRequiredActionParams nextEngineAndRequiredAction[256];
235 } t_FmPcdModifyCcKeyAdditionalParams;
236 
237 typedef struct {
238     t_Handle h_Manip;
239     t_Handle h_CcNode;
240 } t_CcNextEngineInfo;
241 
242 typedef struct {
243     uint16_t    numOfKeys;
244     bool        glblMaskUpdated;
245     t_Handle    p_GlblMask;
246     bool        lclMask;
247     uint8_t     parseCode;
248     uint8_t     offset;
249     uint8_t     prsArrayOffset;
250     bool        ctrlFlow;
251     uint8_t     owners;
252 
253     uint8_t     ccKeySizeAccExtraction;
254     uint8_t     sizeOfExtraction;
255     uint8_t     glblMaskSize;
256 
257     t_Handle    h_KeysMatchTable;
258     t_Handle    h_AdTable;
259 
260     t_List      ccPrevNodesLst;
261 
262     t_List      ccTreeIdLst;
263     t_List      ccTreesLst;
264 
265     t_Handle    h_FmPcd;
266     uint32_t    shadowAction;
267     bool        modifiedState;
268     uint8_t     userSizeOfExtraction;
269 
270     t_FmPcdCcNextEngineAndRequiredActionParams nextEngineAndRequiredAction[256];
271 } t_FmPcdCcNode;
272 
273 typedef struct {
274     t_FmPcdCcNode       *p_FmPcdCcNode;
275     bool                occupied;
276     uint8_t             owners;
277     volatile bool       lock;
278 } t_FmPcdCcNodeArray;
279 
280 typedef struct {
281     uint8_t             numOfEntriesInGroup;
282     uint32_t            totalBitsMask;
283     uint8_t             baseGroupEntry;
284 } t_FmPcdCcGroupParam;
285 
286 typedef struct {
287     uint8_t             netEnvId;
288     uintptr_t           ccTreeBaseAddr;
289     uint8_t             numOfGrps;
290     t_FmPcdCcGroupParam fmPcdGroupParam[FM_PCD_MAX_NUM_OF_CC_GROUPS];
291     t_List              fmPortsLst;
292     volatile bool       lock;
293     uint8_t             numOfEntries;
294     uint8_t             owners;
295     t_Handle            *fmPcdCcSavedManipParams[256];
296     bool                modifiedState;
297     uint32_t            requiredAction;
298     t_FmPcdCcNextEngineAndRequiredActionParams nextEngineAndRequiredAction[FM_PCD_MAX_NUM_OF_KEYS];
299 } t_FmPcdCcTree;
300 
301 typedef struct {
302     t_FmPcdCcTree       *p_FmPcdCcTree;
303     bool                occupied;
304     uint8_t             owners;
305     volatile bool       lock;
306 } t_FmPcdCcTreeArray;
307 
308 
309 bool FmPcdManipIsManipNode(t_Handle h_Ad);
310 
311 
312 #endif /* __FM_CC_H */
313