1 /*
2 * Copyright 2008-2012 Freescale Semiconductor Inc.
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 /******************************************************************************
35 @File fm_common.h
36
37 @Description FM internal structures and definitions.
38 *//***************************************************************************/
39 #ifndef __FM_COMMON_H
40 #define __FM_COMMON_H
41
42 #include "error_ext.h"
43 #include "std_ext.h"
44 #include "fm_pcd_ext.h"
45 #include "fm_ext.h"
46 #include "fm_port_ext.h"
47
48
49 #define e_FM_PORT_TYPE_OH_HOST_COMMAND e_FM_PORT_TYPE_DUMMY
50
51 #define CLS_PLAN_NUM_PER_GRP 8
52
53 #define IP_OFFLOAD_PACKAGE_NUMBER 106
54 #define CAPWAP_OFFLOAD_PACKAGE_NUMBER 108
55 #define IS_OFFLOAD_PACKAGE(num) ((num == IP_OFFLOAD_PACKAGE_NUMBER) || (num == CAPWAP_OFFLOAD_PACKAGE_NUMBER))
56
57
58
59 /**************************************************************************//**
60 @Description Modules registers offsets
61 *//***************************************************************************/
62 #define FM_MM_MURAM 0x00000000
63 #define FM_MM_BMI 0x00080000
64 #define FM_MM_QMI 0x00080400
65 #define FM_MM_PRS 0x000c7000
66 #define FM_MM_KG 0x000C1000
67 #define FM_MM_DMA 0x000C2000
68 #define FM_MM_FPM 0x000C3000
69 #define FM_MM_PLCR 0x000C0000
70 #define FM_MM_IMEM 0x000C4000
71 #define FM_MM_CGP 0x000DB000
72 #define FM_MM_TRB(i) (0x000D0200 + 0x400 * (i))
73 #if (DPAA_VERSION >= 11)
74 #define FM_MM_SP 0x000dc000
75 #endif /* (DPAA_VERSION >= 11) */
76
77
78 /**************************************************************************//**
79 @Description Enum for inter-module interrupts registration
80 *//***************************************************************************/
81 typedef enum e_FmEventModules{
82 e_FM_MOD_PRS, /**< Parser event */
83 e_FM_MOD_KG, /**< Keygen event */
84 e_FM_MOD_PLCR, /**< Policer event */
85 e_FM_MOD_10G_MAC, /**< 10G MAC event */
86 e_FM_MOD_1G_MAC, /**< 1G MAC event */
87 e_FM_MOD_TMR, /**< Timer event */
88 e_FM_MOD_FMAN_CTRL, /**< FMAN Controller Timer event */
89 e_FM_MOD_MACSEC,
90 e_FM_MOD_DUMMY_LAST
91 } e_FmEventModules;
92
93 /**************************************************************************//**
94 @Description Enum for interrupts types
95 *//***************************************************************************/
96 typedef enum e_FmIntrType {
97 e_FM_INTR_TYPE_ERR,
98 e_FM_INTR_TYPE_NORMAL
99 } e_FmIntrType;
100
101 /**************************************************************************//**
102 @Description Enum for inter-module interrupts registration
103 *//***************************************************************************/
104 typedef enum e_FmInterModuleEvent
105 {
106 e_FM_EV_PRS = 0, /**< Parser event */
107 e_FM_EV_ERR_PRS, /**< Parser error event */
108 e_FM_EV_KG, /**< Keygen event */
109 e_FM_EV_ERR_KG, /**< Keygen error event */
110 e_FM_EV_PLCR, /**< Policer event */
111 e_FM_EV_ERR_PLCR, /**< Policer error event */
112 e_FM_EV_ERR_10G_MAC0, /**< 10G MAC 0 error event */
113 e_FM_EV_ERR_10G_MAC1, /**< 10G MAC 1 error event */
114 e_FM_EV_ERR_1G_MAC0, /**< 1G MAC 0 error event */
115 e_FM_EV_ERR_1G_MAC1, /**< 1G MAC 1 error event */
116 e_FM_EV_ERR_1G_MAC2, /**< 1G MAC 2 error event */
117 e_FM_EV_ERR_1G_MAC3, /**< 1G MAC 3 error event */
118 e_FM_EV_ERR_1G_MAC4, /**< 1G MAC 4 error event */
119 e_FM_EV_ERR_1G_MAC5, /**< 1G MAC 5 error event */
120 e_FM_EV_ERR_1G_MAC6, /**< 1G MAC 6 error event */
121 e_FM_EV_ERR_1G_MAC7, /**< 1G MAC 7 error event */
122 e_FM_EV_ERR_MACSEC_MAC0,
123 e_FM_EV_TMR, /**< Timer event */
124 e_FM_EV_10G_MAC0, /**< 10G MAC 0 event (Magic packet detection)*/
125 e_FM_EV_10G_MAC1, /**< 10G MAC 1 event (Magic packet detection)*/
126 e_FM_EV_1G_MAC0, /**< 1G MAC 0 event (Magic packet detection)*/
127 e_FM_EV_1G_MAC1, /**< 1G MAC 1 event (Magic packet detection)*/
128 e_FM_EV_1G_MAC2, /**< 1G MAC 2 (Magic packet detection)*/
129 e_FM_EV_1G_MAC3, /**< 1G MAC 3 (Magic packet detection)*/
130 e_FM_EV_1G_MAC4, /**< 1G MAC 4 (Magic packet detection)*/
131 e_FM_EV_1G_MAC5, /**< 1G MAC 5 (Magic packet detection)*/
132 e_FM_EV_1G_MAC6, /**< 1G MAC 6 (Magic packet detection)*/
133 e_FM_EV_1G_MAC7, /**< 1G MAC 7 (Magic packet detection)*/
134 e_FM_EV_MACSEC_MAC0, /**< MACSEC MAC 0 event */
135 e_FM_EV_FMAN_CTRL_0, /**< Fman controller event 0 */
136 e_FM_EV_FMAN_CTRL_1, /**< Fman controller event 1 */
137 e_FM_EV_FMAN_CTRL_2, /**< Fman controller event 2 */
138 e_FM_EV_FMAN_CTRL_3, /**< Fman controller event 3 */
139 e_FM_EV_DUMMY_LAST
140 } e_FmInterModuleEvent;
141
142
143 #if defined(__MWERKS__) && !defined(__GNUC__)
144 #pragma pack(push,1)
145 #endif /* defined(__MWERKS__) && ... */
146
147 /**************************************************************************//**
148 @Description PCD KG scheme registers
149 *//***************************************************************************/
150 typedef _Packed struct t_FmPcdPlcrProfileRegs {
151 volatile uint32_t fmpl_pemode; /* 0x090 FMPL_PEMODE - FM Policer Profile Entry Mode*/
152 volatile uint32_t fmpl_pegnia; /* 0x094 FMPL_PEGNIA - FM Policer Profile Entry GREEN Next Invoked Action*/
153 volatile uint32_t fmpl_peynia; /* 0x098 FMPL_PEYNIA - FM Policer Profile Entry YELLOW Next Invoked Action*/
154 volatile uint32_t fmpl_pernia; /* 0x09C FMPL_PERNIA - FM Policer Profile Entry RED Next Invoked Action*/
155 volatile uint32_t fmpl_pecir; /* 0x0A0 FMPL_PECIR - FM Policer Profile Entry Committed Information Rate*/
156 volatile uint32_t fmpl_pecbs; /* 0x0A4 FMPL_PECBS - FM Policer Profile Entry Committed Burst Size*/
157 volatile uint32_t fmpl_pepepir_eir; /* 0x0A8 FMPL_PEPIR_EIR - FM Policer Profile Entry Peak/Excess Information Rate*/
158 volatile uint32_t fmpl_pepbs_ebs; /* 0x0AC FMPL_PEPBS_EBS - FM Policer Profile Entry Peak/Excess Information Rate*/
159 volatile uint32_t fmpl_pelts; /* 0x0B0 FMPL_PELTS - FM Policer Profile Entry Last TimeStamp*/
160 volatile uint32_t fmpl_pects; /* 0x0B4 FMPL_PECTS - FM Policer Profile Entry Committed Token Status*/
161 volatile uint32_t fmpl_pepts_ets; /* 0x0B8 FMPL_PEPTS_ETS - FM Policer Profile Entry Peak/Excess Token Status*/
162 volatile uint32_t fmpl_pegpc; /* 0x0BC FMPL_PEGPC - FM Policer Profile Entry GREEN Packet Counter*/
163 volatile uint32_t fmpl_peypc; /* 0x0C0 FMPL_PEYPC - FM Policer Profile Entry YELLOW Packet Counter*/
164 volatile uint32_t fmpl_perpc; /* 0x0C4 FMPL_PERPC - FM Policer Profile Entry RED Packet Counter */
165 volatile uint32_t fmpl_perypc; /* 0x0C8 FMPL_PERYPC - FM Policer Profile Entry Recolored YELLOW Packet Counter*/
166 volatile uint32_t fmpl_perrpc; /* 0x0CC FMPL_PERRPC - FM Policer Profile Entry Recolored RED Packet Counter*/
167 volatile uint32_t fmpl_res1[12]; /* 0x0D0-0x0FF Reserved */
168 } _PackedType t_FmPcdPlcrProfileRegs;
169
170
171 typedef _Packed struct t_FmPcdCcCapwapReassmTimeoutParams {
172 volatile uint32_t portIdAndCapwapReassmTbl;
173 volatile uint32_t fqidForTimeOutFrames;
174 volatile uint32_t timeoutRequestTime;
175 }_PackedType t_FmPcdCcCapwapReassmTimeoutParams;
176
177 /**************************************************************************//**
178 @Description PCD CTRL Parameters Page
179 *//***************************************************************************/
180 typedef _Packed struct t_FmPcdCtrlParamsPage {
181 volatile uint8_t reserved0[16];
182 volatile uint32_t iprIpv4Nia;
183 volatile uint32_t iprIpv6Nia;
184 volatile uint8_t reserved1[24];
185 volatile uint32_t ipfOptionsCounter;
186 volatile uint8_t reserved2[12];
187 volatile uint32_t misc;
188 volatile uint32_t errorsDiscardMask;
189 volatile uint32_t discardMask;
190 volatile uint8_t reserved3[4];
191 volatile uint32_t postBmiFetchNia;
192 volatile uint8_t reserved4[172];
193 } _PackedType t_FmPcdCtrlParamsPage;
194
195
196
197 #if defined(__MWERKS__) && !defined(__GNUC__)
198 #pragma pack(pop)
199 #endif /* defined(__MWERKS__) && ... */
200
201
202 /*for UNDER_CONSTRUCTION_FM_RMU_USE_SEC its defined in fm_ext.h*/
203 typedef uint32_t t_FmFmanCtrl;
204
205 #define FPM_PORT_FM_CTL1 0x00000001
206 #define FPM_PORT_FM_CTL2 0x00000002
207
208
209
210 typedef struct t_FmPcdCcFragScratchPoolCmdParams {
211 uint32_t numOfBuffers;
212 uint8_t bufferPoolId;
213 } t_FmPcdCcFragScratchPoolCmdParams;
214
215 typedef struct t_FmPcdCcReassmTimeoutParams {
216 bool activate;
217 uint8_t tsbs;
218 uint32_t iprcpt;
219 } t_FmPcdCcReassmTimeoutParams;
220
221 typedef struct {
222 uint8_t baseEntry;
223 uint16_t numOfClsPlanEntries;
224 uint32_t vectors[FM_PCD_MAX_NUM_OF_CLS_PLANS];
225 } t_FmPcdKgInterModuleClsPlanSet;
226
227 /**************************************************************************//**
228 @Description Structure for binding a port to keygen schemes.
229 *//***************************************************************************/
230 typedef struct t_FmPcdKgInterModuleBindPortToSchemes {
231 uint8_t hardwarePortId;
232 uint8_t netEnvId;
233 bool useClsPlan; /**< TRUE if this port uses the clsPlan mechanism */
234 uint8_t numOfSchemes;
235 uint8_t schemesIds[FM_PCD_KG_NUM_OF_SCHEMES];
236 } t_FmPcdKgInterModuleBindPortToSchemes;
237
238 typedef struct {
239 uint32_t nextCcNodeInfo;
240 t_List node;
241 } t_CcNodeInfo;
242
243 typedef struct
244 {
245 t_Handle h_CcNode;
246 uint16_t index;
247 t_List node;
248 }t_CcNodeInformation;
249 #define CC_NODE_F_OBJECT(ptr) NCSW_LIST_OBJECT(ptr, t_CcNodeInformation, node)
250
251 typedef enum e_ModifyState
252 {
253 e_MODIFY_STATE_ADD = 0,
254 e_MODIFY_STATE_REMOVE,
255 e_MODIFY_STATE_CHANGE
256 } e_ModifyState;
257
258 typedef struct
259 {
260 t_Handle h_Manip;
261 t_List node;
262 }t_ManipInfo;
263 #define CC_NEXT_NODE_F_OBJECT(ptr) NCSW_LIST_OBJECT(ptr, t_CcNodeInfo, node)
264
265 typedef struct {
266 uint32_t type;
267 uint8_t prOffset;
268 uint16_t dataOffset;
269 uint8_t internalBufferOffset;
270 uint8_t numOfTasks;
271 uint8_t numOfExtraTasks;
272 uint8_t hardwarePortId;
273 t_FmRevisionInfo revInfo;
274 uint32_t nia;
275 uint32_t discardMask;
276 } t_GetCcParams;
277
278 typedef struct {
279 uint32_t type;
280 int psoSize;
281 uint32_t nia;
282 t_FmFmanCtrl orFmanCtrl;
283 bool overwrite;
284 uint8_t ofpDpde;
285 } t_SetCcParams;
286
287 typedef struct {
288 t_GetCcParams getCcParams;
289 t_SetCcParams setCcParams;
290 } t_FmPortGetSetCcParams;
291
292 typedef struct {
293 uint32_t type;
294 bool sleep;
295 } t_FmSetParams;
296
297 typedef struct {
298 uint32_t type;
299 uint32_t fmqm_gs;
300 uint32_t fm_npi;
301 uint32_t fm_cld;
302 uint32_t fmfp_extc;
303 } t_FmGetParams;
304
305 typedef struct {
306 t_FmSetParams setParams;
307 t_FmGetParams getParams;
308 } t_FmGetSetParams;
309
310 t_Error FmGetSetParams(t_Handle h_Fm, t_FmGetSetParams *p_Params);
311
TRY_LOCK(t_Handle h_Spinlock,volatile bool * p_Flag)312 static __inline__ bool TRY_LOCK(t_Handle h_Spinlock, volatile bool *p_Flag)
313 {
314 uint32_t intFlags;
315 if (h_Spinlock)
316 intFlags = XX_LockIntrSpinlock(h_Spinlock);
317 else
318 intFlags = XX_DisableAllIntr();
319
320 if (*p_Flag)
321 {
322 if (h_Spinlock)
323 XX_UnlockIntrSpinlock(h_Spinlock, intFlags);
324 else
325 XX_RestoreAllIntr(intFlags);
326 return FALSE;
327 }
328 *p_Flag = TRUE;
329
330 if (h_Spinlock)
331 XX_UnlockIntrSpinlock(h_Spinlock, intFlags);
332 else
333 XX_RestoreAllIntr(intFlags);
334
335 return TRUE;
336 }
337
338 #define RELEASE_LOCK(_flag) _flag = FALSE;
339
340 /**************************************************************************//**
341 @Collection Defines used for manipulation CC and BMI
342 @{
343 *//***************************************************************************/
344 #define INTERNAL_CONTEXT_OFFSET 0x80000000
345 #define OFFSET_OF_PR 0x40000000
346 #define MANIP_EXTRA_SPACE 0x20000000
347 #define NUM_OF_TASKS 0x10000000
348 #define OFFSET_OF_DATA 0x08000000
349 #define HW_PORT_ID 0x04000000
350 #define FM_REV 0x02000000
351 #define GET_NIA_FPNE 0x01000000
352 #define GET_NIA_PNDN 0x00800000
353 #define NUM_OF_EXTRA_TASKS 0x00400000
354 #define DISCARD_MASK 0x00200000
355
356 #define UPDATE_NIA_PNEN 0x80000000
357 #define UPDATE_PSO 0x40000000
358 #define UPDATE_NIA_PNDN 0x20000000
359 #define UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY 0x10000000
360 #define UPDATE_OFP_DPTE 0x08000000
361 #define UPDATE_NIA_FENE 0x04000000
362 #define UPDATE_NIA_CMNE 0x02000000
363 #define UPDATE_NIA_FPNE 0x01000000
364 /* @} */
365
366 /**************************************************************************//**
367 @Collection Defines used for manipulation CC and CC
368 @{
369 *//***************************************************************************/
370 #define UPDATE_NIA_ENQ_WITHOUT_DMA 0x80000000
371 #define UPDATE_CC_WITH_TREE 0x40000000
372 #define UPDATE_CC_WITH_DELETE_TREE 0x20000000
373 #define UPDATE_KG_NIA_CC_WA 0x10000000
374 #define UPDATE_KG_OPT_MODE 0x08000000
375 #define UPDATE_KG_NIA 0x04000000
376 #define UPDATE_CC_SHADOW_CLEAR 0x02000000
377 /* @} */
378
379 #define UPDATE_FPM_BRKC_SLP 0x80000000
380 #define UPDATE_FPM_EXTC 0x40000000
381 #define UPDATE_FPM_EXTC_CLEAR 0x20000000
382 #define GET_FMQM_GS 0x10000000
383 #define GET_FM_NPI 0x08000000
384 #define GET_FMFP_EXTC 0x04000000
385 #define CLEAR_IRAM_READY 0x02000000
386 #define UPDATE_FM_CLD 0x01000000
387 #define GET_FM_CLD 0x00800000
388 #define FM_MAX_NUM_OF_PORTS (FM_MAX_NUM_OF_OH_PORTS + \
389 FM_MAX_NUM_OF_1G_RX_PORTS + \
390 FM_MAX_NUM_OF_10G_RX_PORTS + \
391 FM_MAX_NUM_OF_1G_TX_PORTS + \
392 FM_MAX_NUM_OF_10G_TX_PORTS)
393
394 #define MODULE_NAME_SIZE 30
395 #define DUMMY_PORT_ID 0
396
397 #define FM_LIODN_OFFSET_MASK 0x3FF
398
399 /**************************************************************************//**
400 @Description NIA Description
401 *//***************************************************************************/
402 #define NIA_ENG_MASK 0x007C0000
403 #define NIA_AC_MASK 0x0003ffff
404
405 #define NIA_ORDER_RESTOR 0x00800000
406 #define NIA_ENG_FM_CTL 0x00000000
407 #define NIA_ENG_PRS 0x00440000
408 #define NIA_ENG_KG 0x00480000
409 #define NIA_ENG_PLCR 0x004C0000
410 #define NIA_ENG_BMI 0x00500000
411 #define NIA_ENG_QMI_ENQ 0x00540000
412 #define NIA_ENG_QMI_DEQ 0x00580000
413
414 #define NIA_FM_CTL_AC_CC 0x00000006
415 #define NIA_FM_CTL_AC_HC 0x0000000C
416 #define NIA_FM_CTL_AC_IND_MODE_TX 0x00000008
417 #define NIA_FM_CTL_AC_IND_MODE_RX 0x0000000A
418 #define NIA_FM_CTL_AC_POP_TO_N_STEP 0x0000000e
419 #define NIA_FM_CTL_AC_PRE_BMI_FETCH_HEADER 0x00000010
420 #define NIA_FM_CTL_AC_PRE_BMI_FETCH_FULL_FRAME 0x00000018
421 #define NIA_FM_CTL_AC_POST_BMI_FETCH 0x00000012
422 #define NIA_FM_CTL_AC_PRE_BMI_ENQ_FRAME 0x0000001A
423 #define NIA_FM_CTL_AC_PRE_BMI_DISCARD_FRAME 0x0000001E
424 #define NIA_FM_CTL_AC_POST_BMI_ENQ_ORR 0x00000014
425 #define NIA_FM_CTL_AC_POST_BMI_ENQ 0x00000022
426 #define NIA_FM_CTL_AC_PRE_CC 0x00000020
427 #define NIA_FM_CTL_AC_POST_TX 0x00000024
428 /* V3 only */
429 #define NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_ENQ_FRAME 0x00000028
430 #define NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_DISCARD_FRAME 0x0000002A
431 #define NIA_FM_CTL_AC_NO_IPACC_POP_TO_N_STEP 0x0000002C
432
433 #define NIA_BMI_AC_ENQ_FRAME 0x00000002
434 #define NIA_BMI_AC_TX_RELEASE 0x000002C0
435 #define NIA_BMI_AC_RELEASE 0x000000C0
436 #define NIA_BMI_AC_DISCARD 0x000000C1
437 #define NIA_BMI_AC_TX 0x00000274
438 #define NIA_BMI_AC_FETCH 0x00000208
439 #define NIA_BMI_AC_MASK 0x000003FF
440
441 #define NIA_KG_DIRECT 0x00000100
442 #define NIA_KG_CC_EN 0x00000200
443 #define NIA_PLCR_ABSOLUTE 0x00008000
444
445 #define NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA 0x00000202
446
447 #if defined(FM_OP_NO_VSP_NO_RELEASE_ERRATA_FMAN_A006675) || defined(FM_ERROR_VSP_NO_MATCH_SW006)
448 #define GET_NIA_BMI_AC_ENQ_FRAME(h_FmPcd) \
449 (uint32_t)((FmPcdIsAdvancedOffloadSupported(h_FmPcd)) ? \
450 (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_PRE_BMI_ENQ_FRAME) : \
451 (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_ENQ_FRAME))
452 #define GET_NIA_BMI_AC_DISCARD_FRAME(h_FmPcd) \
453 (uint32_t)((FmPcdIsAdvancedOffloadSupported(h_FmPcd)) ? \
454 (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_PRE_BMI_DISCARD_FRAME) : \
455 (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_DISCARD_FRAME))
456 #define GET_NO_PCD_NIA_BMI_AC_ENQ_FRAME() \
457 (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_ENQ_FRAME)
458 #else
459 #define GET_NIA_BMI_AC_ENQ_FRAME(h_FmPcd) \
460 (uint32_t)((FmPcdIsAdvancedOffloadSupported(h_FmPcd)) ? \
461 (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_PRE_BMI_ENQ_FRAME) : \
462 (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME))
463 #define GET_NIA_BMI_AC_DISCARD_FRAME(h_FmPcd) \
464 (uint32_t)((FmPcdIsAdvancedOffloadSupported(h_FmPcd)) ? \
465 (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_PRE_BMI_DISCARD_FRAME) : \
466 (NIA_ENG_BMI | NIA_BMI_AC_DISCARD))
467 #define GET_NO_PCD_NIA_BMI_AC_ENQ_FRAME() \
468 (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)
469 #endif /* defined(FM_OP_NO_VSP_NO_RELEASE_ERRATA_FMAN_A006675) || ... */
470
471 /**************************************************************************//**
472 @Description CTRL Parameters Page defines
473 *//***************************************************************************/
474 #define FM_CTL_PARAMS_PAGE_OP_FIX_EN 0x80000000
475 #define FM_CTL_PARAMS_PAGE_OFFLOAD_SUPPORT_EN 0x40000000
476 #define FM_CTL_PARAMS_PAGE_ALWAYS_ON 0x00000100
477
478 #define FM_CTL_PARAMS_PAGE_ERROR_VSP_MASK 0x0000003f
479
480 /**************************************************************************//**
481 @Description Port Id defines
482 *//***************************************************************************/
483 #if (DPAA_VERSION == 10)
484 #define BASE_OH_PORTID 1
485 #else
486 #define BASE_OH_PORTID 2
487 #endif /* (DPAA_VERSION == 10) */
488 #define BASE_1G_RX_PORTID 8
489 #define BASE_10G_RX_PORTID 0x10
490 #define BASE_1G_TX_PORTID 0x28
491 #define BASE_10G_TX_PORTID 0x30
492
493 #define FM_PCD_PORT_OH_BASE_INDX 0
494 #define FM_PCD_PORT_1G_RX_BASE_INDX (FM_PCD_PORT_OH_BASE_INDX+FM_MAX_NUM_OF_OH_PORTS)
495 #define FM_PCD_PORT_10G_RX_BASE_INDX (FM_PCD_PORT_1G_RX_BASE_INDX+FM_MAX_NUM_OF_1G_RX_PORTS)
496 #define FM_PCD_PORT_1G_TX_BASE_INDX (FM_PCD_PORT_10G_RX_BASE_INDX+FM_MAX_NUM_OF_10G_RX_PORTS)
497 #define FM_PCD_PORT_10G_TX_BASE_INDX (FM_PCD_PORT_1G_TX_BASE_INDX+FM_MAX_NUM_OF_1G_TX_PORTS)
498
499 #if (FM_MAX_NUM_OF_OH_PORTS > 0)
500 #define CHECK_PORT_ID_OH_PORTS(_relativePortId) \
501 if ((_relativePortId) >= FM_MAX_NUM_OF_OH_PORTS) \
502 REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal OH_PORT port id"))
503 #else
504 #define CHECK_PORT_ID_OH_PORTS(_relativePortId) \
505 REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal OH_PORT port id"))
506 #endif
507 #if (FM_MAX_NUM_OF_1G_RX_PORTS > 0)
508 #define CHECK_PORT_ID_1G_RX_PORTS(_relativePortId) \
509 if ((_relativePortId) >= FM_MAX_NUM_OF_1G_RX_PORTS) \
510 REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 1G_RX_PORT port id"))
511 #else
512 #define CHECK_PORT_ID_1G_RX_PORTS(_relativePortId) \
513 REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 1G_RX_PORT port id"))
514 #endif
515 #if (FM_MAX_NUM_OF_10G_RX_PORTS > 0)
516 #define CHECK_PORT_ID_10G_RX_PORTS(_relativePortId) \
517 if ((_relativePortId) >= FM_MAX_NUM_OF_10G_RX_PORTS) \
518 REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 10G_RX_PORT port id"))
519 #else
520 #define CHECK_PORT_ID_10G_RX_PORTS(_relativePortId) \
521 REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 10G_RX_PORT port id"))
522 #endif
523 #if (FM_MAX_NUM_OF_1G_TX_PORTS > 0)
524 #define CHECK_PORT_ID_1G_TX_PORTS(_relativePortId) \
525 if ((_relativePortId) >= FM_MAX_NUM_OF_1G_TX_PORTS) \
526 REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 1G_TX_PORT port id"))
527 #else
528 #define CHECK_PORT_ID_1G_TX_PORTS(_relativePortId) \
529 REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 1G_TX_PORT port id"))
530 #endif
531 #if (FM_MAX_NUM_OF_10G_TX_PORTS > 0)
532 #define CHECK_PORT_ID_10G_TX_PORTS(_relativePortId) \
533 if ((_relativePortId) >= FM_MAX_NUM_OF_10G_TX_PORTS) \
534 REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 10G_TX_PORT port id"))
535 #else
536 #define CHECK_PORT_ID_10G_TX_PORTS(_relativePortId) \
537 REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 10G_TX_PORT port id"))
538 #endif
539
540 uint8_t SwPortIdToHwPortId(e_FmPortType type, uint8_t relativePortId, uint8_t majorRev, uint8_t minorRev);
541
542 #define HW_PORT_ID_TO_SW_PORT_ID(_relativePortId, hardwarePortId) \
543 { if (((hardwarePortId) >= BASE_OH_PORTID) && \
544 ((hardwarePortId) < BASE_OH_PORTID+FM_MAX_NUM_OF_OH_PORTS)) \
545 _relativePortId = (uint8_t)((hardwarePortId)-BASE_OH_PORTID); \
546 else if (((hardwarePortId) >= BASE_10G_TX_PORTID) && \
547 ((hardwarePortId) < BASE_10G_TX_PORTID+FM_MAX_NUM_OF_10G_TX_PORTS)) \
548 _relativePortId = (uint8_t)((hardwarePortId)-BASE_10G_TX_PORTID); \
549 else if (((hardwarePortId) >= BASE_1G_TX_PORTID) && \
550 ((hardwarePortId) < BASE_1G_TX_PORTID+FM_MAX_NUM_OF_1G_TX_PORTS)) \
551 _relativePortId = (uint8_t)((hardwarePortId)-BASE_1G_TX_PORTID); \
552 else if (((hardwarePortId) >= BASE_10G_RX_PORTID) && \
553 ((hardwarePortId) < BASE_10G_RX_PORTID+FM_MAX_NUM_OF_10G_RX_PORTS)) \
554 _relativePortId = (uint8_t)((hardwarePortId)-BASE_10G_RX_PORTID); \
555 else if (((hardwarePortId) >= BASE_1G_RX_PORTID) && \
556 ((hardwarePortId) < BASE_1G_RX_PORTID+FM_MAX_NUM_OF_1G_RX_PORTS)) \
557 _relativePortId = (uint8_t)((hardwarePortId)-BASE_1G_RX_PORTID); \
558 else { \
559 _relativePortId = (uint8_t)DUMMY_PORT_ID; \
560 ASSERT_COND(TRUE); \
561 } \
562 }
563
564 #define HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId) \
565 do { \
566 if (((hardwarePortId) >= BASE_OH_PORTID) && ((hardwarePortId) < BASE_OH_PORTID+FM_MAX_NUM_OF_OH_PORTS)) \
567 swPortIndex = (uint8_t)((hardwarePortId)-BASE_OH_PORTID+FM_PCD_PORT_OH_BASE_INDX); \
568 else if (((hardwarePortId) >= BASE_1G_RX_PORTID) && \
569 ((hardwarePortId) < BASE_1G_RX_PORTID+FM_MAX_NUM_OF_1G_RX_PORTS)) \
570 swPortIndex = (uint8_t)((hardwarePortId)-BASE_1G_RX_PORTID+FM_PCD_PORT_1G_RX_BASE_INDX); \
571 else if (((hardwarePortId) >= BASE_10G_RX_PORTID) && \
572 ((hardwarePortId) < BASE_10G_RX_PORTID+FM_MAX_NUM_OF_10G_RX_PORTS)) \
573 swPortIndex = (uint8_t)((hardwarePortId)-BASE_10G_RX_PORTID+FM_PCD_PORT_10G_RX_BASE_INDX); \
574 else if (((hardwarePortId) >= BASE_1G_TX_PORTID) && \
575 ((hardwarePortId) < BASE_1G_TX_PORTID+FM_MAX_NUM_OF_1G_TX_PORTS)) \
576 swPortIndex = (uint8_t)((hardwarePortId)-BASE_1G_TX_PORTID+FM_PCD_PORT_1G_TX_BASE_INDX); \
577 else if (((hardwarePortId) >= BASE_10G_TX_PORTID) && \
578 ((hardwarePortId) < BASE_10G_TX_PORTID+FM_MAX_NUM_OF_10G_TX_PORTS)) \
579 swPortIndex = (uint8_t)((hardwarePortId)-BASE_10G_TX_PORTID+FM_PCD_PORT_10G_TX_BASE_INDX); \
580 else ASSERT_COND(FALSE); \
581 } while (0)
582
583 #define SW_PORT_INDX_TO_HW_PORT_ID(hardwarePortId, swPortIndex) \
584 do { \
585 if (((swPortIndex) >= FM_PCD_PORT_OH_BASE_INDX) && ((swPortIndex) < FM_PCD_PORT_1G_RX_BASE_INDX)) \
586 hardwarePortId = (uint8_t)((swPortIndex)-FM_PCD_PORT_OH_BASE_INDX+BASE_OH_PORTID); \
587 else if (((swPortIndex) >= FM_PCD_PORT_1G_RX_BASE_INDX) && ((swPortIndex) < FM_PCD_PORT_10G_RX_BASE_INDX)) \
588 hardwarePortId = (uint8_t)((swPortIndex)-FM_PCD_PORT_1G_RX_BASE_INDX+BASE_1G_RX_PORTID); \
589 else if (((swPortIndex) >= FM_PCD_PORT_10G_RX_BASE_INDX) && ((swPortIndex) < FM_MAX_NUM_OF_PORTS)) \
590 hardwarePortId = (uint8_t)((swPortIndex)-FM_PCD_PORT_10G_RX_BASE_INDX+BASE_10G_RX_PORTID); \
591 else if (((swPortIndex) >= FM_PCD_PORT_1G_TX_BASE_INDX) && ((swPortIndex) < FM_PCD_PORT_10G_TX_BASE_INDX)) \
592 hardwarePortId = (uint8_t)((swPortIndex)-FM_PCD_PORT_1G_TX_BASE_INDX+BASE_1G_TX_PORTID); \
593 else if (((swPortIndex) >= FM_PCD_PORT_10G_TX_BASE_INDX) && ((swPortIndex) < FM_MAX_NUM_OF_PORTS)) \
594 hardwarePortId = (uint8_t)((swPortIndex)-FM_PCD_PORT_10G_TX_BASE_INDX+BASE_10G_TX_PORTID); \
595 else ASSERT_COND(FALSE); \
596 } while (0)
597
598 #define BMI_MAX_FIFO_SIZE (FM_MURAM_SIZE)
599 #define BMI_FIFO_UNITS 0x100
600
601 typedef struct {
602 void (*f_Isr) (t_Handle h_Arg);
603 t_Handle h_SrcHandle;
604 uint8_t guestId;
605 } t_FmIntrSrc;
606
607 #define ILLEGAL_HDR_NUM 0xFF
608 #define NO_HDR_NUM FM_PCD_PRS_NUM_OF_HDRS
609
610 #define IS_PRIVATE_HEADER(hdr) (((hdr) == HEADER_TYPE_USER_DEFINED_SHIM1) || \
611 ((hdr) == HEADER_TYPE_USER_DEFINED_SHIM2))
612 #define IS_SPECIAL_HEADER(hdr) ((hdr) == HEADER_TYPE_MACSEC)
613
GetPrsHdrNum(e_NetHeaderType hdr)614 static __inline__ uint8_t GetPrsHdrNum(e_NetHeaderType hdr)
615 {
616 switch (hdr)
617 { case (HEADER_TYPE_ETH): return 0;
618 case (HEADER_TYPE_LLC_SNAP): return 1;
619 case (HEADER_TYPE_VLAN): return 2;
620 case (HEADER_TYPE_PPPoE): return 3;
621 case (HEADER_TYPE_PPP): return 3;
622 case (HEADER_TYPE_MPLS): return 4;
623 case (HEADER_TYPE_IPv4): return 5;
624 case (HEADER_TYPE_IPv6): return 6;
625 case (HEADER_TYPE_GRE): return 7;
626 case (HEADER_TYPE_MINENCAP): return 8;
627 case (HEADER_TYPE_USER_DEFINED_L3): return 9;
628 case (HEADER_TYPE_TCP): return 10;
629 case (HEADER_TYPE_UDP): return 11;
630 case (HEADER_TYPE_IPSEC_AH):
631 case (HEADER_TYPE_IPSEC_ESP): return 12;
632 case (HEADER_TYPE_SCTP): return 13;
633 case (HEADER_TYPE_DCCP): return 14;
634 case (HEADER_TYPE_USER_DEFINED_L4): return 15;
635 case (HEADER_TYPE_USER_DEFINED_SHIM1):
636 case (HEADER_TYPE_USER_DEFINED_SHIM2):
637 case (HEADER_TYPE_MACSEC): return NO_HDR_NUM;
638 default:
639 return ILLEGAL_HDR_NUM;
640 }
641 }
642
643 #define FM_PCD_MAX_NUM_OF_OPTIONS(clsPlanEntries) ((clsPlanEntries==256)? 8:((clsPlanEntries==128)? 7: ((clsPlanEntries==64)? 6: ((clsPlanEntries==32)? 5:0))))
644
645
646 /**************************************************************************//**
647 @Description A structure for initializing a keygen classification plan group
648 *//***************************************************************************/
649 typedef struct t_FmPcdKgInterModuleClsPlanGrpParams {
650 uint8_t netEnvId; /* IN */
651 bool grpExists; /* OUT (unused in FmPcdKgBuildClsPlanGrp)*/
652 uint8_t clsPlanGrpId; /* OUT */
653 bool emptyClsPlanGrp; /* OUT */
654 uint8_t numOfOptions; /* OUT in FmPcdGetSetClsPlanGrpParams IN in FmPcdKgBuildClsPlanGrp*/
655 protocolOpt_t options[FM_PCD_MAX_NUM_OF_OPTIONS(FM_PCD_MAX_NUM_OF_CLS_PLANS)];
656 /* OUT in FmPcdGetSetClsPlanGrpParams IN in FmPcdKgBuildClsPlanGrp*/
657 uint32_t optVectors[FM_PCD_MAX_NUM_OF_OPTIONS(FM_PCD_MAX_NUM_OF_CLS_PLANS)];
658 /* OUT in FmPcdGetSetClsPlanGrpParams IN in FmPcdKgBuildClsPlanGrp*/
659 } t_FmPcdKgInterModuleClsPlanGrpParams;
660
661 typedef struct t_FmPcdLock {
662 t_Handle h_Spinlock;
663 volatile bool flag;
664 t_List node;
665 } t_FmPcdLock;
666 #define FM_PCD_LOCK_OBJ(ptr) NCSW_LIST_OBJECT(ptr, t_FmPcdLock, node)
667
668
669 typedef t_Error (t_FmPortGetSetCcParamsCallback) (t_Handle h_FmPort,
670 t_FmPortGetSetCcParams *p_FmPortGetSetCcParams);
671
672
673 /***********************************************************************/
674 /* Common API for FM-PCD module */
675 /***********************************************************************/
676 t_Handle FmPcdGetHcHandle(t_Handle h_FmPcd);
677 uint32_t FmPcdGetSwPrsOffset(t_Handle h_FmPcd, e_NetHeaderType hdr, uint8_t indexPerHdr);
678 uint32_t FmPcdGetLcv(t_Handle h_FmPcd, uint32_t netEnvId, uint8_t hdrNum);
679 uint32_t FmPcdGetMacsecLcv(t_Handle h_FmPcd, uint32_t netEnvId);
680 void FmPcdIncNetEnvOwners(t_Handle h_FmPcd, uint8_t netEnvId);
681 void FmPcdDecNetEnvOwners(t_Handle h_FmPcd, uint8_t netEnvId);
682 uint8_t FmPcdGetNetEnvId(t_Handle h_NetEnv);
683 void FmPcdPortRegister(t_Handle h_FmPcd, t_Handle h_FmPort, uint8_t hardwarePortId);
684 uint32_t FmPcdLock(t_Handle h_FmPcd);
685 void FmPcdUnlock(t_Handle h_FmPcd, uint32_t intFlags);
686 bool FmPcdNetEnvIsHdrExist(t_Handle h_FmPcd, uint8_t netEnvId, e_NetHeaderType hdr);
687 t_Error FmPcdFragHcScratchPoolInit(t_Handle h_FmPcd, uint8_t scratchBpid);
688 t_Error FmPcdRegisterReassmPort(t_Handle h_FmPcd, t_Handle h_IpReasmCommonPramTbl);
689 t_Error FmPcdUnregisterReassmPort(t_Handle h_FmPcd, t_Handle h_IpReasmCommonPramTbl);
690 bool FmPcdIsAdvancedOffloadSupported(t_Handle h_FmPcd);
691 bool FmPcdLockTryLockAll(t_Handle h_FmPcd);
692 void FmPcdLockUnlockAll(t_Handle h_FmPcd);
693 t_Error FmPcdHcSync(t_Handle h_FmPcd);
694 t_Handle FmGetPcd(t_Handle h_Fm);
695 /***********************************************************************/
696 /* Common API for FM-PCD KG module */
697 /***********************************************************************/
698 uint8_t FmPcdKgGetClsPlanGrpBase(t_Handle h_FmPcd, uint8_t clsPlanGrp);
699 uint16_t FmPcdKgGetClsPlanGrpSize(t_Handle h_FmPcd, uint8_t clsPlanGrp);
700 t_Error FmPcdKgBuildClsPlanGrp(t_Handle h_FmPcd, t_FmPcdKgInterModuleClsPlanGrpParams *p_Grp, t_FmPcdKgInterModuleClsPlanSet *p_ClsPlanSet);
701
702 uint8_t FmPcdKgGetSchemeId(t_Handle h_Scheme);
703 #if (DPAA_VERSION >= 11)
704 bool FmPcdKgGetVspe(t_Handle h_Scheme);
705 #endif /* (DPAA_VERSION >= 11) */
706 uint8_t FmPcdKgGetRelativeSchemeId(t_Handle h_FmPcd, uint8_t schemeId);
707 void FmPcdKgDestroyClsPlanGrp(t_Handle h_FmPcd, uint8_t grpId);
708 t_Error FmPcdKgCheckInvalidateSchemeSw(t_Handle h_Scheme);
709 t_Error FmPcdKgBuildBindPortToSchemes(t_Handle h_FmPcd , t_FmPcdKgInterModuleBindPortToSchemes *p_BindPortToSchemes, uint32_t *p_SpReg, bool add);
710 bool FmPcdKgHwSchemeIsValid(uint32_t schemeModeReg);
711 uint32_t FmPcdKgBuildWriteSchemeActionReg(uint8_t schemeId, bool updateCounter);
712 uint32_t FmPcdKgBuildReadSchemeActionReg(uint8_t schemeId);
713 uint32_t FmPcdKgBuildWriteClsPlanBlockActionReg(uint8_t grpId);
714 uint32_t FmPcdKgBuildWritePortSchemeBindActionReg(uint8_t hardwarePortId);
715 uint32_t FmPcdKgBuildReadPortSchemeBindActionReg(uint8_t hardwarePortId);
716 uint32_t FmPcdKgBuildWritePortClsPlanBindActionReg(uint8_t hardwarePortId);
717 bool FmPcdKgIsSchemeValidSw(t_Handle h_Scheme);
718
719 t_Error FmPcdKgBindPortToSchemes(t_Handle h_FmPcd , t_FmPcdKgInterModuleBindPortToSchemes *p_SchemeBind);
720 t_Error FmPcdKgUnbindPortToSchemes(t_Handle h_FmPcd , t_FmPcdKgInterModuleBindPortToSchemes *p_SchemeBind);
721 uint32_t FmPcdKgGetRequiredAction(t_Handle h_FmPcd, uint8_t schemeId);
722 uint32_t FmPcdKgGetRequiredActionFlag(t_Handle h_FmPcd, uint8_t schemeId);
723 e_FmPcdDoneAction FmPcdKgGetDoneAction(t_Handle h_FmPcd, uint8_t schemeId);
724 e_FmPcdEngine FmPcdKgGetNextEngine(t_Handle h_FmPcd, uint8_t schemeId);
725 void FmPcdKgUpdateRequiredAction(t_Handle h_Scheme, uint32_t requiredAction);
726 bool FmPcdKgIsDirectPlcr(t_Handle h_FmPcd, uint8_t schemeId);
727 bool FmPcdKgIsDistrOnPlcrProfile(t_Handle h_FmPcd, uint8_t schemeId);
728 uint16_t FmPcdKgGetRelativeProfileId(t_Handle h_FmPcd, uint8_t schemeId);
729 t_Handle FmPcdKgGetSchemeHandle(t_Handle h_FmPcd, uint8_t relativeSchemeId);
730 bool FmPcdKgIsSchemeHasOwners(t_Handle h_Scheme);
731 t_Error FmPcdKgCcGetSetParams(t_Handle h_FmPcd, t_Handle h_Scheme, uint32_t requiredAction, uint32_t value);
732 t_Error FmPcdKgSetOrBindToClsPlanGrp(t_Handle h_FmPcd, uint8_t hardwarePortId, uint8_t netEnvId, protocolOpt_t *p_OptArray, uint8_t *p_ClsPlanGrpId, bool *p_IsEmptyClsPlanGrp);
733 t_Error FmPcdKgDeleteOrUnbindPortToClsPlanGrp(t_Handle h_FmPcd, uint8_t hardwarePortId, uint8_t clsPlanGrpId);
734
735 /***********************************************************************/
736 /* Common API for FM-PCD parser module */
737 /***********************************************************************/
738 t_Error FmPcdPrsIncludePortInStatistics(t_Handle p_FmPcd, uint8_t hardwarePortId, bool include);
739
740 /***********************************************************************/
741 /* Common API for FM-PCD policer module */
742 /***********************************************************************/
743 t_Error FmPcdPlcrAllocProfiles(t_Handle h_FmPcd, uint8_t hardwarePortId, uint16_t numOfProfiles);
744 t_Error FmPcdPlcrFreeProfiles(t_Handle h_FmPcd, uint8_t hardwarePortId);
745 bool FmPcdPlcrIsProfileValid(t_Handle h_FmPcd, uint16_t absoluteProfileId);
746 uint16_t FmPcdPlcrGetPortProfilesBase(t_Handle h_FmPcd, uint8_t hardwarePortId);
747 uint16_t FmPcdPlcrGetPortNumOfProfiles(t_Handle h_FmPcd, uint8_t hardwarePortId);
748 uint32_t FmPcdPlcrBuildWritePlcrActionRegs(uint16_t absoluteProfileId);
749 uint32_t FmPcdPlcrBuildCounterProfileReg(e_FmPcdPlcrProfileCounters counter);
750 uint32_t FmPcdPlcrBuildWritePlcrActionReg(uint16_t absoluteProfileId);
751 uint32_t FmPcdPlcrBuildReadPlcrActionReg(uint16_t absoluteProfileId);
752 uint16_t FmPcdPlcrProfileGetAbsoluteId(t_Handle h_Profile);
753 t_Error FmPcdPlcrGetAbsoluteIdByProfileParams(t_Handle h_FmPcd,
754 e_FmPcdProfileTypeSelection profileType,
755 t_Handle h_FmPort,
756 uint16_t relativeProfile,
757 uint16_t *p_AbsoluteId);
758 void FmPcdPlcrInvalidateProfileSw(t_Handle h_FmPcd, uint16_t absoluteProfileId);
759 void FmPcdPlcrValidateProfileSw(t_Handle h_FmPcd, uint16_t absoluteProfileId);
760 bool FmPcdPlcrHwProfileIsValid(uint32_t profileModeReg);
761 uint32_t FmPcdPlcrGetRequiredAction(t_Handle h_FmPcd, uint16_t absoluteProfileId);
762 uint32_t FmPcdPlcrGetRequiredActionFlag(t_Handle h_FmPcd, uint16_t absoluteProfileId);
763 uint32_t FmPcdPlcrBuildNiaProfileReg(bool green, bool yellow, bool red);
764 void FmPcdPlcrUpdateRequiredAction(t_Handle h_FmPcd, uint16_t absoluteProfileId, uint32_t requiredAction);
765 t_Error FmPcdPlcrCcGetSetParams(t_Handle h_FmPcd, uint16_t profileIndx,uint32_t requiredAction);
766
767 /***********************************************************************/
768 /* Common API for FM-PCD CC module */
769 /***********************************************************************/
770 uint8_t FmPcdCcGetParseCode(t_Handle h_CcNode);
771 uint8_t FmPcdCcGetOffset(t_Handle h_CcNode);
772 t_Error FmPcdCcRemoveKey(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode, uint16_t keyIndex);
773 t_Error FmPcdCcAddKey(t_Handle h_FmPcd, t_Handle h_CcNode, uint16_t keyIndex, uint8_t keySize, t_FmPcdCcKeyParams *p_FmPCdCcKeyParams);
774 t_Error FmPcdCcModifyKey(t_Handle h_FmPcd, t_Handle h_CcNode, uint16_t keyIndex, uint8_t keySize, uint8_t *p_Key, uint8_t *p_Mask);
775 t_Error FmPcdCcModifyKeyAndNextEngine(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode, uint16_t keyIndex, uint8_t keySize, t_FmPcdCcKeyParams *p_FmPcdCcKeyParams);
776 t_Error FmPcdCcModifyMissNextEngineParamNode(t_Handle h_FmPcd,t_Handle h_FmPcdCcNode, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
777 t_Error FmPcdCcModifyNextEngineParamTree(t_Handle h_FmPcd, t_Handle h_FmPcdCcTree, uint8_t grpId, uint8_t index, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
778 uint32_t FmPcdCcGetNodeAddrOffsetFromNodeInfo(t_Handle h_FmPcd, t_Handle h_Pointer);
779 t_Handle FmPcdCcTreeGetSavedManipParams(t_Handle h_FmTree);
780 void FmPcdCcTreeSetSavedManipParams(t_Handle h_FmTree, t_Handle h_SavedManipParams);
781 t_Error FmPcdCcTreeAddIPR(t_Handle h_FmPcd, t_Handle h_FmTree, t_Handle h_NetEnv, t_Handle h_ReassemblyManip, bool schemes);
782 t_Error FmPcdCcTreeAddCPR(t_Handle h_FmPcd, t_Handle h_FmTree, t_Handle h_NetEnv, t_Handle h_ReassemblyManip, bool schemes);
783 t_Error FmPcdCcBindTree(t_Handle h_FmPcd, t_Handle h_PcdParams, t_Handle h_CcTree, uint32_t *p_Offset,t_Handle h_FmPort);
784 t_Error FmPcdCcUnbindTree(t_Handle h_FmPcd, t_Handle h_CcTree);
785
786 /***********************************************************************/
787 /* Common API for FM-PCD Manip module */
788 /***********************************************************************/
789 t_Error FmPcdManipUpdate(t_Handle h_FmPcd, t_Handle h_PcdParams, t_Handle h_FmPort, t_Handle h_Manip, t_Handle h_Ad, bool validate, int level, t_Handle h_FmTree, bool modify);
790
791 /***********************************************************************/
792 /* Common API for FM-Port module */
793 /***********************************************************************/
794 #if (DPAA_VERSION >= 11)
795 typedef enum e_FmPortGprFuncType
796 {
797 e_FM_PORT_GPR_EMPTY = 0,
798 e_FM_PORT_GPR_MURAM_PAGE
799 } e_FmPortGprFuncType;
800
801 t_Error FmPortSetGprFunc(t_Handle h_FmPort, e_FmPortGprFuncType gprFunc, void **p_Value);
802 #endif /* DPAA_VERSION >= 11) */
803 t_Error FmGetSetParams(t_Handle h_Fm, t_FmGetSetParams *p_FmGetSetParams);
804 t_Error FmPortGetSetCcParams(t_Handle h_FmPort, t_FmPortGetSetCcParams *p_FmPortGetSetCcParams);
805 uint8_t FmPortGetNetEnvId(t_Handle h_FmPort);
806 uint8_t FmPortGetHardwarePortId(t_Handle h_FmPort);
807 uint32_t FmPortGetPcdEngines(t_Handle h_FmPort);
808 void FmPortPcdKgSwUnbindClsPlanGrp (t_Handle h_FmPort);
809
810
811 #if (DPAA_VERSION >= 11)
812 t_Error FmPcdFrmReplicUpdate(t_Handle h_FmPcd, t_Handle h_FmPort, t_Handle h_FrmReplic);
813 #endif /* (DPAA_VERSION >= 11) */
814
815 /**************************************************************************//**
816 @Function FmRegisterIntr
817
818 @Description Used to register an inter-module event handler to be processed by FM
819
820 @Param[in] h_Fm A handle to an FM Module.
821 @Param[in] mod The module that causes the event
822 @Param[in] modId Module id - if more than 1 instansiation of this
823 mode exists,0 otherwise.
824 @Param[in] intrType Interrupt type (error/normal) selection.
825 @Param[in] f_Isr The interrupt service routine.
826 @Param[in] h_Arg Argument to be passed to f_Isr.
827
828 @Return None.
829 *//***************************************************************************/
830 void FmRegisterIntr(t_Handle h_Fm,
831 e_FmEventModules mod,
832 uint8_t modId,
833 e_FmIntrType intrType,
834 void (*f_Isr) (t_Handle h_Arg),
835 t_Handle h_Arg);
836
837 /**************************************************************************//**
838 @Function FmUnregisterIntr
839
840 @Description Used to un-register an inter-module event handler that was processed by FM
841
842 @Param[in] h_Fm A handle to an FM Module.
843 @Param[in] mod The module that causes the event
844 @Param[in] modId Module id - if more than 1 instansiation of this
845 mode exists,0 otherwise.
846 @Param[in] intrType Interrupt type (error/normal) selection.
847
848 @Return None.
849 *//***************************************************************************/
850 void FmUnregisterIntr(t_Handle h_Fm,
851 e_FmEventModules mod,
852 uint8_t modId,
853 e_FmIntrType intrType);
854
855 /**************************************************************************//**
856 @Function FmRegisterFmCtlIntr
857
858 @Description Used to register to one of the fmCtl events in the FM module
859
860 @Param[in] h_Fm A handle to an FM Module.
861 @Param[in] eventRegId FmCtl event id (0-7).
862 @Param[in] f_Isr The interrupt service routine.
863
864 @Return E_OK on success; Error code otherwise.
865
866 @Cautions Allowed only following FM_Init().
867 *//***************************************************************************/
868 void FmRegisterFmCtlIntr(t_Handle h_Fm, uint8_t eventRegId, void (*f_Isr) (t_Handle h_Fm, uint32_t event));
869
870
871 /**************************************************************************//**
872 @Description enum for defining MAC types
873 *//***************************************************************************/
874 typedef enum e_FmMacType {
875 e_FM_MAC_10G = 0, /**< 10G MAC */
876 e_FM_MAC_1G /**< 1G MAC */
877 } e_FmMacType;
878
879 /**************************************************************************//**
880 @Description Structure for port-FM communication during FM_PORT_Init.
881 Fields commented 'IN' are passed by the port module to be used
882 by the FM module.
883 Fields commented 'OUT' will be filled by FM before returning to port.
884 Some fields are optional (depending on configuration) and
885 will be analized by the port and FM modules accordingly.
886 *//***************************************************************************/
887 typedef struct t_FmInterModulePortInitParams {
888 uint8_t hardwarePortId; /**< IN. port Id */
889 e_FmPortType portType; /**< IN. Port type */
890 bool independentMode; /**< IN. TRUE if FM Port operates in independent mode */
891 uint16_t liodnOffset; /**< IN. Port's requested resource */
892 uint8_t numOfTasks; /**< IN. Port's requested resource */
893 uint8_t numOfExtraTasks; /**< IN. Port's requested resource */
894 uint8_t numOfOpenDmas; /**< IN. Port's requested resource */
895 uint8_t numOfExtraOpenDmas; /**< IN. Port's requested resource */
896 uint32_t sizeOfFifo; /**< IN. Port's requested resource */
897 uint32_t extraSizeOfFifo; /**< IN. Port's requested resource */
898 uint8_t deqPipelineDepth; /**< IN. Port's requested resource */
899 uint16_t maxFrameLength; /**< IN. Port's max frame length. */
900 uint16_t liodnBase; /**< IN. Irrelevant for P4080 rev 1.
901 LIODN base for this port, to be
902 used together with LIODN offset. */
903 t_FmPhysAddr fmMuramPhysBaseAddr;/**< OUT. FM-MURAM physical address*/
904 } t_FmInterModulePortInitParams;
905
906 /**************************************************************************//**
907 @Description Structure for port-FM communication during FM_PORT_Free.
908 *//***************************************************************************/
909 typedef struct t_FmInterModulePortFreeParams {
910 uint8_t hardwarePortId; /**< IN. port Id */
911 e_FmPortType portType; /**< IN. Port type */
912 uint8_t deqPipelineDepth; /**< IN. Port's requested resource */
913 } t_FmInterModulePortFreeParams;
914
915 /**************************************************************************//**
916 @Function FmGetPcdPrsBaseAddr
917
918 @Description Get the base address of the Parser from the FM module
919
920 @Param[in] h_Fm A handle to an FM Module.
921
922 @Return Base address.
923 *//***************************************************************************/
924 uintptr_t FmGetPcdPrsBaseAddr(t_Handle h_Fm);
925
926 /**************************************************************************//**
927 @Function FmGetPcdKgBaseAddr
928
929 @Description Get the base address of the Keygen from the FM module
930
931 @Param[in] h_Fm A handle to an FM Module.
932
933 @Return Base address.
934 *//***************************************************************************/
935 uintptr_t FmGetPcdKgBaseAddr(t_Handle h_Fm);
936
937 /**************************************************************************//**
938 @Function FmGetPcdPlcrBaseAddr
939
940 @Description Get the base address of the Policer from the FM module
941
942 @Param[in] h_Fm A handle to an FM Module.
943
944 @Return Base address.
945 *//***************************************************************************/
946 uintptr_t FmGetPcdPlcrBaseAddr(t_Handle h_Fm);
947
948 /**************************************************************************//**
949 @Function FmGetMuramHandle
950
951 @Description Get the handle of the MURAM from the FM module
952
953 @Param[in] h_Fm A handle to an FM Module.
954
955 @Return MURAM module handle.
956 *//***************************************************************************/
957 t_Handle FmGetMuramHandle(t_Handle h_Fm);
958
959 /**************************************************************************//**
960 @Function FmGetPhysicalMuramBase
961
962 @Description Get the physical base address of the MURAM from the FM module
963
964 @Param[in] h_Fm A handle to an FM Module.
965 @Param[in] fmPhysAddr Physical MURAM base
966
967 @Return Physical base address.
968 *//***************************************************************************/
969 void FmGetPhysicalMuramBase(t_Handle h_Fm, t_FmPhysAddr *fmPhysAddr);
970
971 /**************************************************************************//**
972 @Function FmGetTimeStampScale
973
974 @Description Used internally by other modules in order to get the timeStamp
975 period as requested by the application.
976
977 This function returns bit number that is incremented every 1 usec.
978 To calculate timestamp period in nsec, use
979 1000 / (1 << FmGetTimeStampScale()).
980
981 @Param[in] h_Fm A handle to an FM Module.
982
983 @Return Bit that counts 1 usec.
984
985 @Cautions Allowed only following FM_Init().
986 *//***************************************************************************/
987 uint32_t FmGetTimeStampScale(t_Handle h_Fm);
988
989 /**************************************************************************//**
990 @Function FmResumeStalledPort
991
992 @Description Used internally by FM port to release a stalled port.
993
994 @Param[in] h_Fm A handle to an FM Module.
995 @Param[in] hardwarePortId HW port id.
996
997 @Return E_OK on success; Error code otherwise.
998
999 @Cautions Allowed only following FM_Init().
1000 *//***************************************************************************/
1001 t_Error FmResumeStalledPort(t_Handle h_Fm, uint8_t hardwarePortId);
1002
1003 /**************************************************************************//**
1004 @Function FmIsPortStalled
1005
1006 @Description Used internally by FM port to read the port's status.
1007
1008 @Param[in] h_Fm A handle to an FM Module.
1009 @Param[in] hardwarePortId HW port id.
1010 @Param[in] p_IsStalled A pointer to the boolean port stalled state
1011
1012 @Return E_OK on success; Error code otherwise.
1013
1014 @Cautions Allowed only following FM_Init().
1015 *//***************************************************************************/
1016 t_Error FmIsPortStalled(t_Handle h_Fm, uint8_t hardwarePortId, bool *p_IsStalled);
1017
1018 /**************************************************************************//**
1019 @Function FmResetMac
1020
1021 @Description Used by MAC driver to reset the MAC registers
1022
1023 @Param[in] h_Fm A handle to an FM Module.
1024 @Param[in] type MAC type.
1025 @Param[in] macId MAC id - according to type.
1026
1027 @Return E_OK on success; Error code otherwise.
1028
1029 @Cautions Allowed only following FM_Init().
1030 *//***************************************************************************/
1031 t_Error FmResetMac(t_Handle h_Fm, e_FmMacType type, uint8_t macId);
1032
1033 /**************************************************************************//**
1034 @Function FmGetClockFreq
1035
1036 @Description Used by MAC driver to get the FM clock frequency
1037
1038 @Param[in] h_Fm A handle to an FM Module.
1039
1040 @Return clock-freq on success; 0 otherwise.
1041
1042 @Cautions Allowed only following FM_Init().
1043 *//***************************************************************************/
1044 uint16_t FmGetClockFreq(t_Handle h_Fm);
1045
1046 /**************************************************************************//**
1047 @Function FmGetMacClockFreq
1048
1049 @Description Used by MAC driver to get the MAC clock frequency
1050
1051 @Param[in] h_Fm A handle to an FM Module.
1052
1053 @Return clock-freq on success; 0 otherwise.
1054
1055 @Cautions Allowed only following FM_Init().
1056 *//***************************************************************************/
1057 uint16_t FmGetMacClockFreq(t_Handle h_Fm);
1058
1059 /**************************************************************************//**
1060 @Function FmGetId
1061
1062 @Description Used by PCD driver to read rhe FM id
1063
1064 @Param[in] h_Fm A handle to an FM Module.
1065
1066 @Return E_OK on success; Error code otherwise.
1067
1068 @Cautions Allowed only following FM_Init().
1069 *//***************************************************************************/
1070 uint8_t FmGetId(t_Handle h_Fm);
1071
1072 /**************************************************************************//**
1073 @Function FmReset
1074
1075 @Description Used to reset the FM
1076
1077 @Param[in] h_Fm A handle to an FM Module.
1078
1079 @Return E_OK on success; Error code otherwise.
1080 *//***************************************************************************/
1081 t_Error FmReset(t_Handle h_Fm);
1082
1083 /**************************************************************************//**
1084 @Function FmGetSetPortParams
1085
1086 @Description Used by FM-PORT driver to pass and receive parameters between
1087 PORT and FM modules.
1088
1089 @Param[in] h_Fm A handle to an FM Module.
1090 @Param[in,out] p_PortParams A structure of FM Port parameters.
1091
1092 @Return E_OK on success; Error code otherwise.
1093
1094 @Cautions Allowed only following FM_Init().
1095 *//***************************************************************************/
1096 t_Error FmGetSetPortParams(t_Handle h_Fm,t_FmInterModulePortInitParams *p_PortParams);
1097
1098 /**************************************************************************//**
1099 @Function FmFreePortParams
1100
1101 @Description Used by FM-PORT driver to free port's resources within the FM.
1102
1103 @Param[in] h_Fm A handle to an FM Module.
1104 @Param[in,out] p_PortParams A structure of FM Port parameters.
1105
1106 @Return None.
1107
1108 @Cautions Allowed only following FM_Init().
1109 *//***************************************************************************/
1110 void FmFreePortParams(t_Handle h_Fm,t_FmInterModulePortFreeParams *p_PortParams);
1111
1112 /**************************************************************************//**
1113 @Function FmSetNumOfRiscsPerPort
1114
1115 @Description Used by FM-PORT driver to pass parameter between
1116 PORT and FM modules for working with number of RISC..
1117
1118 @Param[in] h_Fm A handle to an FM Module.
1119 @Param[in] hardwarePortId hardware port Id.
1120 @Param[in] numOfFmanCtrls number of Fman Controllers.
1121 @Param[in] orFmanCtrl Fman Controller for order restoration.
1122
1123 @Return None.
1124
1125 @Cautions Allowed only following FM_Init().
1126 *//***************************************************************************/
1127 t_Error FmSetNumOfRiscsPerPort(t_Handle h_Fm, uint8_t hardwarePortId, uint8_t numOfFmanCtrls, t_FmFmanCtrl orFmanCtrl);
1128
1129 #if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
1130 /**************************************************************************//*
1131 @Function FmDumpPortRegs
1132
1133 @Description Dumps FM port registers which are part of FM common registers
1134
1135 @Param[in] h_Fm A handle to an FM Module.
1136 @Param[in] hardwarePortId HW port id.
1137
1138 @Return E_OK on success; Error code otherwise.
1139
1140 @Cautions Allowed only FM_Init().
1141 *//***************************************************************************/
1142 t_Error FmDumpPortRegs(t_Handle h_Fm,uint8_t hardwarePortId);
1143 #endif /* (defined(DEBUG_ERRORS) && ... */
1144
1145 void FmRegisterPcd(t_Handle h_Fm, t_Handle h_FmPcd);
1146 void FmUnregisterPcd(t_Handle h_Fm);
1147 t_Handle FmGetPcdHandle(t_Handle h_Fm);
1148 t_Error FmEnableRamsEcc(t_Handle h_Fm);
1149 t_Error FmDisableRamsEcc(t_Handle h_Fm);
1150 void FmGetRevision(t_Handle h_Fm, t_FmRevisionInfo *p_FmRevisionInfo);
1151 t_Error FmAllocFmanCtrlEventReg(t_Handle h_Fm, uint8_t *p_EventId);
1152 void FmFreeFmanCtrlEventReg(t_Handle h_Fm, uint8_t eventId);
1153 void FmSetFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId, uint32_t enableEvents);
1154 uint32_t FmGetFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId);
1155 void FmRegisterFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId, void (*f_Isr) (t_Handle h_Fm, uint32_t event), t_Handle h_Arg);
1156 void FmUnregisterFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId);
1157 t_Error FmSetMacMaxFrame(t_Handle h_Fm, e_FmMacType type, uint8_t macId, uint16_t mtu);
1158 bool FmIsMaster(t_Handle h_Fm);
1159 uint8_t FmGetGuestId(t_Handle h_Fm);
1160 uint16_t FmGetTnumAgingPeriod(t_Handle h_Fm);
1161 t_Error FmSetPortPreFetchConfiguration(t_Handle h_Fm, uint8_t portNum, bool preFetchConfigured);
1162 t_Error FmGetPortPreFetchConfiguration(t_Handle h_Fm, uint8_t portNum, bool *p_PortConfigured, bool *p_PreFetchConfigured);
1163
1164
1165 #ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
1166 t_Error Fm10GTxEccWorkaround(t_Handle h_Fm, uint8_t macId);
1167 #endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
1168
1169 void FmMuramClear(t_Handle h_FmMuram);
1170 t_Error FmSetNumOfOpenDmas(t_Handle h_Fm,
1171 uint8_t hardwarePortId,
1172 uint8_t *p_NumOfOpenDmas,
1173 uint8_t *p_NumOfExtraOpenDmas,
1174 bool initialConfig);
1175 t_Error FmSetNumOfTasks(t_Handle h_Fm,
1176 uint8_t hardwarePortId,
1177 uint8_t *p_NumOfTasks,
1178 uint8_t *p_NumOfExtraTasks,
1179 bool initialConfig);
1180 t_Error FmSetSizeOfFifo(t_Handle h_Fm,
1181 uint8_t hardwarePortId,
1182 uint32_t *p_SizeOfFifo,
1183 uint32_t *p_ExtraSizeOfFifo,
1184 bool initialConfig);
1185
1186 t_Error FmSetCongestionGroupPFCpriority(t_Handle h_Fm,
1187 uint32_t congestionGroupId,
1188 uint8_t priorityBitMap);
1189
1190 #if (DPAA_VERSION >= 11)
1191 t_Error FmVSPAllocForPort(t_Handle h_Fm,
1192 e_FmPortType portType,
1193 uint8_t portId,
1194 uint8_t numOfStorageProfiles);
1195
1196 t_Error FmVSPFreeForPort(t_Handle h_Fm,
1197 e_FmPortType portType,
1198 uint8_t portId);
1199
1200 t_Error FmVSPGetAbsoluteProfileId(t_Handle h_Fm,
1201 e_FmPortType portType,
1202 uint8_t portId,
1203 uint16_t relativeProfile,
1204 uint16_t *p_AbsoluteId);
1205 t_Error FmVSPCheckRelativeProfile(t_Handle h_Fm,
1206 e_FmPortType portType,
1207 uint8_t portId,
1208 uint16_t relativeProfile);
1209
1210 uintptr_t FmGetVSPBaseAddr(t_Handle h_Fm);
1211 #endif /* (DPAA_VERSION >= 11) */
1212
1213
1214 #endif /* __FM_COMMON_H */
1215