xref: /freebsd/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_manip.h (revision 63d1fd5970ec814904aa0f4580b10a0d302d08b2)
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_manip.h
35 
36  @Description   FM PCD manip...
37 *//***************************************************************************/
38 #ifndef __FM_MANIP_H
39 #define __FM_MANIP_H
40 
41 #include "std_ext.h"
42 #include "error_ext.h"
43 #include "list_ext.h"
44 
45 #include "fm_cc.h"
46 
47 
48 /***********************************************************************/
49 /*          Header manipulations defines                              */
50 /***********************************************************************/
51 
52 #define HMAN_OC_RMV_N_OR_INSRT_INT_FRM_HDR                      0x2e
53 #define HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER              0x31
54 #define HMAN_OC_CAPWAP_FRAGMENTATION                            0x33
55 #define HMAN_OC_IPSEC                                           0x34
56 #define HMAN_OC_IP_FRAGMENTATION                                0x74
57 #define HMAN_OC_IP_REASSEMBLY                                   0xB4
58 #define HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX     0x2f
59 #define HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST                        0x30
60 #define HMAN_OC_CAPWAP_REASSEMBLY                               0x11 /* dummy */
61 #define HMAN_OC_CAPWAP_INDEXED_STATS                            0x32 /* dummy */
62 
63 #define HMAN_RMV_HDR                               0x80000000
64 #define HMAN_INSRT_INT_FRM_HDR                     0x40000000
65 
66 #define UDP_UDPHECKSUM_FIELD_OFFSET_FROM_UDP        6
67 #define UDP_UDPCHECKSUM_FIELD_SIZE                  2
68 
69 #define IP_DSCECN_FIELD_OFFSET_FROM_IP              1
70 #define IP_TOTALLENGTH_FIELD_OFFSET_FROM_IP         2
71 #define IP_HDRCHECKSUM_FIELD_OFFSET_FROM_IP         10
72 #define VLAN_TAG_FIELD_OFFSET_FROM_ETH              12
73 #define IP_ID_FIELD_OFFSET_FROM_IP                  4
74 
75 #define FM_PCD_MANIP_CAPWAP_REASM_TABLE_SIZE               80
76 #define FM_PCD_MANIP_CAPWAP_REASM_TABLE_ALIGN              8
77 #define FM_PCD_MANIP_CAPWAP_REASM_RFD_SIZE                 32
78 #define FM_PCD_MANIP_CAPWAP_REASM_AUTO_LEARNING_HASH_ENTRY_SIZE 4
79 #define FM_PCD_MANIP_CAPWAP_REASM_TIME_OUT_ENTRY_SIZE      8
80 
81 
82 #define FM_PCD_MANIP_CAPWAP_REASM_TIME_OUT_BETWEEN_FRAMES          0x40000000
83 #define FM_PCD_MANIP_CAPWAP_REASM_HALT_ON_DUPLICATE_FRAG           0x10000000
84 #define FM_PCD_MANIP_CAPWAP_REASM_AUTOMATIC_LEARNIN_HASH_8_WAYS    0x08000000
85 #define FM_PCD_MANIP_CAPWAP_REASM_PR_COPY                          0x00800000
86 
87 #define FM_PCD_MANIP_CAPWAP_FRAG_COMPR_OPTION_FIELD_EN             0x80000000
88 
89 #define FM_PCD_MANIP_INDEXED_STATS_ENTRY_SIZE               4
90 #define FM_PCD_MANIP_INDEXED_STATS_CNIA                     0x20000000
91 #define FM_PCD_MANIP_INDEXED_STATS_DPD                      0x10000000
92 
93 #define FM_PCD_MANIP_IPSEC_CALC_UDP_LENGTH                  0x01000000
94 #define FM_PCD_MANIP_IPSEC_CNIA                             0x20000000
95 
96 #define e_FM_MANIP_CAPWAP_INDX                              0
97 
98 #ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
99 #define FM_PCD_MANIP_IP_REASM_TABLE_SIZE                    0x40
100 #define FM_PCD_MANIP_IP_REASM_TABLE_ALIGN                   8
101 
102 #define FM_PCD_MANIP_IP_REASM_COMMON_PARAM_TABLE_SIZE       64
103 #define FM_PCD_MANIP_IP_REASM_COMMON_PARAM_TABLE_ALIGN      8
104 #define FM_PCD_MANIP_IP_REASM_TIME_OUT_BETWEEN_FRAMES              0x80000000
105 #define e_FM_MANIP_IP_INDX                                  1
106 #define FM_PCD_MANIP_IP_REASM_LIODN_MASK                    0x000003F0
107 #define FM_PCD_MANIP_IP_REASM_LIODN_SHIFT                   56
108 #define FM_PCD_MANIP_IP_REASM_ELIODN_MASK                   0x0000000F
109 #define FM_PCD_MANIP_IP_REASM_ELIODN_SHIFT                  44
110 
111 #endif /* UNDER_CONSTRUCTION_FRAG_REASSEMBLY */
112 
113 
114 /***********************************************************************/
115 /*          Memory map                                                 */
116 /***********************************************************************/
117 #if defined(__MWERKS__) && !defined(__GNUC__)
118 #pragma pack(push,1)
119 #endif /* defined(__MWERKS__) && ... */
120 
121 typedef _Packed struct {
122     volatile uint32_t mode;
123     volatile uint32_t autoLearnHashTblPtr;
124     volatile uint32_t intStatsTblPtr;
125     volatile uint32_t reasmFrmDescPoolTblPtr;
126     volatile uint32_t reasmFrmDescIndexPoolTblPtr;
127     volatile uint32_t timeOutTblPtr;
128     volatile uint32_t bufferPoolIdAndRisc1SetIndexes;
129     volatile uint32_t risc23SetIndexes;
130     volatile uint32_t risc4SetIndexesAndExtendedStatsTblPtr;
131     volatile uint32_t extendedStatsTblPtr;
132     volatile uint32_t expirationDelay;
133     volatile uint32_t totalProcessedFragCounter;
134     volatile uint32_t totalUnsuccessfulReasmFramesCounter;
135     volatile uint32_t totalDuplicatedFragCounter;
136     volatile uint32_t totalMalformdFragCounter;
137     volatile uint32_t totalTimeOutCounter;
138     volatile uint32_t totalSetBusyCounter;
139     volatile uint32_t totalRfdPoolBusyCounter;
140     volatile uint32_t totalDiscardedFragsCounter;
141     volatile uint32_t totalMoreThan16FramesCounter;
142     volatile uint32_t internalBufferBusy;
143     volatile uint32_t externalBufferBusy;
144     volatile uint8_t res[16];
145 } _PackedType t_CapwapReasmPram;
146 
147 #ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
148 typedef _Packed struct t_IpReasmPram{
149     volatile uint16_t waysNumAndSetSize;
150     volatile uint16_t autoLearnHashKeyMask;
151     volatile uint32_t ipReassCommonPrmTblPtr;
152     volatile uint32_t liodnAlAndAutoLearnHashTblPtrHi;
153     volatile uint32_t autoLearnHashTblPtrLow;
154     volatile uint32_t liodnSlAndAutoLearnSetLockTblPtrHi;
155     volatile uint32_t autoLearnSetLockTblPtrLow;
156     volatile uint16_t minFragSize;
157     volatile uint16_t reserved1;
158     volatile uint32_t totalSuccessfullyReasmFramesCounter;
159     volatile uint32_t totalValidFragmentCounter;
160     volatile uint32_t totalProcessedFragCounter;
161     volatile uint32_t totalMalformdFragCounter;
162     volatile uint32_t totalSetBusyCounter;
163     volatile uint32_t totalDiscardedFragsCounter;
164     volatile uint32_t totalMoreThan16FramesCounter;
165     volatile uint32_t reserved2[2];
166 } _PackedType t_IpReasmPram;
167 
168 typedef _Packed struct t_IpReasmCommonTbl{
169     volatile uint32_t timeoutModeAndFqid;
170     volatile uint32_t reassFrmDescIndexPoolTblPtr;
171     volatile uint32_t liodnAndReassFrmDescPoolPtrHi;
172     volatile uint32_t reassFrmDescPoolPtrLow;
173     volatile uint32_t timeOutTblPtr;
174     volatile uint32_t expirationDelay;
175     volatile uint32_t reseervd1;
176     volatile uint32_t reseervd2;
177     volatile uint32_t totalTimeOutCounter;
178     volatile uint32_t totalRfdPoolBusyCounter;
179     volatile uint32_t totalInternalBufferBusy;
180     volatile uint32_t totalExternalBufferBusy;
181     volatile uint32_t reserved3[4];
182 } _PackedType t_IpReasmCommonTbl;
183 
184 #endif /*UNDER_CONSTRUCTION_FRAG_REASSEMBLY*/
185 
186 #define MEM_MAP_END
187 #if defined(__MWERKS__) && !defined(__GNUC__)
188 #pragma pack(pop)
189 #endif /* defined(__MWERKS__) && ... */
190 
191 
192 /***********************************************************************/
193 /*  Driver's internal structures                                       */
194 /***********************************************************************/
195 
196 typedef struct
197 {
198     t_Handle p_AutoLearnHashTbl;
199     t_Handle p_ReassmFrmDescrPoolTbl;
200     t_Handle p_ReassmFrmDescrIndxPoolTbl;
201     t_Handle p_TimeOutTbl;
202     uint8_t  maxNumFramesInProcess;
203     uint8_t  numOfTasks;
204     uint8_t  poolId;
205     uint8_t  prOffset;
206     uint16_t dataOffset;
207     uint8_t  poolIndx;
208     uint8_t  hwPortId;
209     uint32_t fqidForTimeOutFrames;
210     uint32_t timeoutRoutineRequestTime;
211     uint32_t bitFor1Micro;
212 } t_FragParams;
213 
214 #ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
215 typedef struct
216 {
217     t_Handle h_Frag;
218     t_Handle h_FragId;
219     uint8_t  poolId;
220     uint16_t dataOffset;
221     uint8_t  poolIndx;
222 }t_IpFragParams;
223 
224 typedef struct t_IpReassmParams
225 {
226     t_Handle            h_Ipv4Ad;
227     t_Handle            h_Ipv6Ad;
228     e_NetHeaderType     hdr;                /**< Header selection */
229     uint32_t            fqidForTimeOutFrames;
230     uint16_t            dataOffset;
231     t_Handle            h_IpReassCommonParamsTbl;
232     t_Handle            h_Ipv4ReassParamsTblPtr;
233     t_Handle            h_Ipv6ReassParamsTblPtr;
234     t_Handle            h_Ipv4AutoLearnHashTbl;
235     t_Handle            h_Ipv6AutoLearnHashTbl;
236     t_Handle            h_Ipv4AutoLearnSetLockTblPtr;
237     t_Handle            h_Ipv6AutoLearnSetLockTblPtr;
238     t_Handle            h_ReassmFrmDescrIndxPoolTbl;
239     t_Handle            h_ReassmFrmDescrPoolTbl;
240     t_Handle            h_TimeOutTbl;
241     uint32_t            maxNumFramesInProcess;
242     uint32_t            liodnOffset;
243     uint32_t            minFragSize;
244     uint8_t             dataMemId;              /**< Memory partition ID for data buffers */
245     uint32_t            bpid;
246     e_FmPcdManipReassemTimeOutMode  timeOutMode;
247     e_FmPcdManipReassemWaysNumber   numOfFramesPerHashEntry;
248     uint32_t                        timeoutThresholdForReassmProcess;
249 
250 }t_IpReassmParams;
251 
252 typedef struct t_IpCommonReassmParams
253 {
254     uint8_t             numOfTasks;
255     uint32_t            bitFor1Micro;
256     t_Handle            h_ReassmFrmDescrPoolTbl;
257     t_Handle            h_ReassmFrmDescrIndxPoolTbl;
258     t_Handle            h_TimeOutTbl;
259 }t_IpCommonReassmParams;
260 
261 #endif /*UNDER_CONSTRUCTION_FRAG_REASSEMBLY*/
262 
263 typedef struct{
264     bool                muramAllocate;
265     t_Handle            h_Ad;
266     uint32_t            type;
267     bool                rmv;
268     bool                insrt;
269     uint8_t             *p_Template;
270     t_Handle            h_Frag;
271     bool                frag;
272     bool                reassm;
273     uint16_t            sizeForFragmentation;
274     uint8_t             owner;
275     uint32_t            updateParams;
276     uint32_t            shadowUpdateParams;
277     t_FragParams        fragParams;
278 #ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
279     t_IpReassmParams    ipReassmParams;
280     t_IpFragParams      ipFragParams;
281 #endif /* UNDER_CONSTRUCTION_FRAG_REASSEMBLY */
282     uint8_t             icOffset;
283     uint16_t            ownerTmp;
284     bool                cnia;
285     t_Handle            p_StatsTbl;
286     t_Handle            h_FmPcd;
287 } t_FmPcdManip;
288 
289 typedef struct t_FmPcdCcSavedManipParams
290 {
291     union
292     {
293         struct
294         {
295             uint16_t    dataOffset;
296             uint8_t     poolId;
297         }capwapParams;
298 #ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
299         struct
300         {
301             uint16_t    dataOffset;
302             uint8_t     poolId;
303         }ipParams;
304 #endif /*UNDER_CONSTRUCTION_FRAG_REASSEMBLY*/
305     };
306 
307 } t_FmPcdCcSavedManipParams;
308 
309 
310 #endif /* __FM_MANIP_H */
311