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_ext.h
35 
36  @Description   FM Application Programming Interface.
37 *//***************************************************************************/
38 #ifndef __FM_EXT
39 #define __FM_EXT
40 
41 #include "error_ext.h"
42 #include "std_ext.h"
43 #include "dpaa_ext.h"
44 
45 
46 /**************************************************************************//**
47  @Group         FM_grp Frame Manager API
48 
49  @Description   FM API functions, definitions and enums.
50 
51  @{
52 *//***************************************************************************/
53 
54 /**************************************************************************//**
55  @Group         FM_lib_grp FM library
56 
57  @Description   FM API functions, definitions and enums
58                 The FM module is the main driver module and is a mandatory module
59                 for FM driver users. Before any further module initialization,
60                 this module must be initialized.
61                 The FM is a "singletone" module. It is responsible of the common
62                 HW modules: FPM, DMA, common QMI, common BMI initializations and
63                 run-time control routines. This module must be initialized always
64                 when working with any of the FM modules.
65                 NOTE - We assumes that the FML will be initialize only by core No. 0!
66 
67  @{
68 *//***************************************************************************/
69 
70 /**************************************************************************//**
71  @Description   enum for defining port types
72 *//***************************************************************************/
73 typedef enum e_FmPortType {
74     e_FM_PORT_TYPE_OH_OFFLINE_PARSING = 0,  /**< Offline parsing port (id's: 0-6, share id's with
75                                                  host command, so must have exclusive id) */
76     e_FM_PORT_TYPE_OH_HOST_COMMAND,         /**< Host command port (id's: 0-6, share id's with
77                                                  offline parsing ports, so must have exclusive id) */
78     e_FM_PORT_TYPE_RX,                      /**< 1G Rx port (id's: 0-3) */
79     e_FM_PORT_TYPE_RX_10G,                  /**< 10G Rx port (id's: 0) */
80     e_FM_PORT_TYPE_TX,                      /**< 1G Tx port (id's: 0-3) */
81     e_FM_PORT_TYPE_TX_10G,                  /**< 10G Tx port (id's: 0) */
82     e_FM_PORT_TYPE_DUMMY
83 } e_FmPortType;
84 
85 /**************************************************************************//**
86  @Collection    General FM defines
87 *//***************************************************************************/
88 #define FM_MAX_NUM_OF_PARTITIONS    64      /**< Maximum number of partitions */
89 #define FM_PHYS_ADDRESS_SIZE        6       /**< FM Physical address size */
90 /* @} */
91 
92 
93 #if defined(__MWERKS__) && !defined(__GNUC__)
94 #pragma pack(push,1)
95 #endif /* defined(__MWERKS__) && ... */
96 #define MEM_MAP_START
97 
98 /**************************************************************************//**
99  @Description   FM physical Address
100 *//***************************************************************************/
101 typedef _Packed struct t_FmPhysAddr {
102     volatile uint8_t    high;         /**< High part of the physical address */
103     volatile uint32_t   low;          /**< Low part of the physical address */
104 } _PackedType t_FmPhysAddr;
105 
106 /**************************************************************************//**
107  @Description   Parse results memory layout
108 *//***************************************************************************/
109 typedef _Packed struct t_FmPrsResult {
110     volatile uint8_t     lpid;               /**< Logical port id */
111     volatile uint8_t     shimr;              /**< Shim header result  */
112     volatile uint16_t    l2r;                /**< Layer 2 result */
113     volatile uint16_t    l3r;                /**< Layer 3 result */
114     volatile uint8_t     l4r;                /**< Layer 4 result */
115     volatile uint8_t     cplan;              /**< Classification plan id */
116     volatile uint16_t    nxthdr;             /**< Next Header  */
117     volatile uint16_t    cksum;              /**< Checksum */
118     volatile uint32_t    lcv;                /**< LCV */
119     volatile uint8_t     shim_off[3];        /**< Shim offset */
120     volatile uint8_t     eth_off;            /**< ETH offset */
121     volatile uint8_t     llc_snap_off;       /**< LLC_SNAP offset */
122     volatile uint8_t     vlan_off[2];        /**< VLAN offset */
123     volatile uint8_t     etype_off;          /**< ETYPE offset */
124     volatile uint8_t     pppoe_off;          /**< PPP offset */
125     volatile uint8_t     mpls_off[2];        /**< MPLS offset */
126     volatile uint8_t     ip_off[2];          /**< IP offset */
127     volatile uint8_t     gre_off;            /**< GRE offset */
128     volatile uint8_t     l4_off;             /**< Layer 4 offset */
129     volatile uint8_t     nxthdr_off;         /**< Parser end point */
130 } _PackedType t_FmPrsResult;
131 
132 /**************************************************************************//**
133  @Collection   FM Parser results
134 *//***************************************************************************/
135 #define FM_PR_L2_VLAN_STACK         0x00000100  /**< Parse Result: VLAN stack */
136 #define FM_PR_L2_ETHERNET           0x00008000  /**< Parse Result: Ethernet*/
137 #define FM_PR_L2_VLAN               0x00004000  /**< Parse Result: VLAN */
138 #define FM_PR_L2_LLC_SNAP           0x00002000  /**< Parse Result: LLC_SNAP */
139 #define FM_PR_L2_MPLS               0x00001000  /**< Parse Result: MPLS */
140 #define FM_PR_L2_PPPoE              0x00000800  /**< Parse Result: PPPoE */
141 /* @} */
142 
143 /**************************************************************************//**
144  @Collection   FM Frame descriptor macros
145 *//***************************************************************************/
146 #define FM_FD_CMD_FCO               0x80000000  /**< Frame queue Context Override */
147 #define FM_FD_CMD_RPD               0x40000000  /**< Read Prepended Data */
148 #define FM_FD_CMD_UPD               0x20000000  /**< Update Prepended Data */
149 #define FM_FD_CMD_DTC               0x10000000  /**< Do L4 Checksum */
150 #define FM_FD_CMD_DCL4C             0x10000000  /**< Didn't calculate L4 Checksum */
151 #define FM_FD_CMD_CFQ               0x00ffffff  /**< Confirmation Frame Queue */
152 
153 #define FM_FD_TX_STATUS_ERR_MASK    0x07000000  /**< TX Error FD bits */
154 #define FM_FD_RX_STATUS_ERR_MASK    0x070ee3f8  /**< RX Error FD bits */
155 /* @} */
156 
157 /**************************************************************************//**
158  @Description   Context A
159 *//***************************************************************************/
160 typedef _Packed struct t_FmContextA {
161     volatile uint32_t    command;   /**< ContextA Command */
162     volatile uint8_t     res0[4];   /**< ContextA Reserved bits */
163 } _PackedType t_FmContextA;
164 
165 /**************************************************************************//**
166  @Description   Context B
167 *//***************************************************************************/
168 typedef uint32_t t_FmContextB;
169 
170 /**************************************************************************//**
171  @Collection   Context A macros
172 *//***************************************************************************/
173 #define FM_CONTEXTA_OVERRIDE_MASK       0x80000000
174 #define FM_CONTEXTA_ICMD_MASK           0x40000000
175 #define FM_CONTEXTA_A1_VALID_MASK       0x20000000
176 #define FM_CONTEXTA_MACCMD_MASK         0x00ff0000
177 #define FM_CONTEXTA_MACCMD_VALID_MASK   0x00800000
178 #define FM_CONTEXTA_MACCMD_SECURED_MASK 0x00100000
179 #define FM_CONTEXTA_MACCMD_SC_MASK      0x000f0000
180 #define FM_CONTEXTA_A1_MASK             0x0000ffff
181 
182 #define FM_CONTEXTA_GET_OVERRIDE(contextA)                 ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_OVERRIDE_MASK) >> (31-0))
183 #define FM_CONTEXTA_GET_ICMD(contextA)                     ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_ICMD_MASK) >> (31-1))
184 #define FM_CONTEXTA_GET_A1_VALID(contextA)                 ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_A1_VALID_MASK) >> (31-2))
185 #define FM_CONTEXTA_GET_A1(contextA)                       ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_A1_MASK) >> (31-31))
186 #define FM_CONTEXTA_GET_MACCMD(contextA)                   ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_MACCMD_MASK) >> (31-15))
187 #define FM_CONTEXTA_GET_MACCMD_VALID(contextA)             ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_MACCMD_VALID_MASK) >> (31-8))
188 #define FM_CONTEXTA_GET_MACCMD_SECURED(contextA)           ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_MACCMD_SECURED_MASK) >> (31-11))
189 #define FM_CONTEXTA_GET_MACCMD_SECURE_CHANNEL(contextA)    ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_MACCMD_SC_MASK) >> (31-15))
190 
191 #define FM_CONTEXTA_SET_OVERRIDE(contextA,val)              (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_OVERRIDE_MASK) | (((uint32_t)(val) << (31-0)) & FM_CONTEXTA_OVERRIDE_MASK) ))
192 #define FM_CONTEXTA_SET_ICMD(contextA,val)                  (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_ICMD_MASK) | (((val) << (31-1)) & FM_CONTEXTA_ICMD_MASK) ))
193 #define FM_CONTEXTA_SET_A1_VALID(contextA,val)              (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_A1_VALID_MASK) | (((val) << (31-2)) & FM_CONTEXTA_A1_VALID_MASK) ))
194 #define FM_CONTEXTA_SET_A1(contextA,val)                    (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_A1_MASK) | (((val) << (31-31)) & FM_CONTEXTA_A1_MASK) ))
195 #define FM_CONTEXTA_SET_MACCMD(contextA,val)                (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_MACCMD_MASK) | (((val) << (31-15)) & FM_CONTEXTA_MACCMD_MASK) ))
196 #define FM_CONTEXTA_SET_MACCMD_VALID(contextA,val)          (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_MACCMD_VALID_MASK) | (((val) << (31-8)) & FM_CONTEXTA_MACCMD_VALID_MASK) ))
197 #define FM_CONTEXTA_SET_MACCMD_SECURED(contextA,val)        (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_MACCMD_SECURED_MASK) | (((val) << (31-11)) & FM_CONTEXTA_MACCMD_SECURED_MASK) ))
198 #define FM_CONTEXTA_SET_MACCMD_SECURE_CHANNEL(contextA,val) (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_MACCMD_SC_MASK) | (((val) << (31-15)) & FM_CONTEXTA_MACCMD_SC_MASK) ))
199 /* @} */
200 
201 /**************************************************************************//**
202  @Collection   Context B macros
203 *//***************************************************************************/
204 #define FM_CONTEXTB_FQID_MASK               0x00ffffff
205 
206 #define FM_CONTEXTB_GET_FQID(contextB)      (*((t_FmContextB *)contextB) & FM_CONTEXTB_FQID_MASK)
207 #define FM_CONTEXTB_SET_FQID(contextB,val)  (*((t_FmContextB *)contextB) = ((*((t_FmContextB *)contextB) & ~FM_CONTEXTB_FQID_MASK) | ((val) & FM_CONTEXTB_FQID_MASK)))
208 /* @} */
209 
210 #define MEM_MAP_END
211 #if defined(__MWERKS__) && !defined(__GNUC__)
212 #pragma pack(pop)
213 #endif /* defined(__MWERKS__) && ... */
214 
215 
216 /**************************************************************************//**
217  @Description   FM Exceptions
218 *//***************************************************************************/
219 typedef enum e_FmExceptions {
220     e_FM_EX_DMA_BUS_ERROR,              /**< DMA bus error. */
221     e_FM_EX_DMA_READ_ECC,               /**< Read Buffer ECC error */
222     e_FM_EX_DMA_SYSTEM_WRITE_ECC,       /**< Write Buffer ECC error on system side */
223     e_FM_EX_DMA_FM_WRITE_ECC,           /**< Write Buffer ECC error on FM side */
224     e_FM_EX_FPM_STALL_ON_TASKS,         /**< Stall of tasks on FPM */
225     e_FM_EX_FPM_SINGLE_ECC,             /**< Single ECC on FPM. */
226     e_FM_EX_FPM_DOUBLE_ECC,             /**< Double ECC error on FPM ram access */
227     e_FM_EX_QMI_SINGLE_ECC,             /**< Single ECC on QMI. */
228     e_FM_EX_QMI_DOUBLE_ECC,             /**< Double bit ECC occurred on QMI */
229     e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID,/**< Dequeu from unknown port id */
230     e_FM_EX_BMI_LIST_RAM_ECC,           /**< Linked List RAM ECC error */
231     e_FM_EX_BMI_PIPELINE_ECC,           /**< Pipeline Table ECC Error */
232     e_FM_EX_BMI_STATISTICS_RAM_ECC,     /**< Statistics Count RAM ECC Error Enable */
233     e_FM_EX_BMI_DISPATCH_RAM_ECC,       /**< Dispatch RAM ECC Error Enable */
234     e_FM_EX_IRAM_ECC,                   /**< Double bit ECC occurred on IRAM*/
235     e_FM_EX_MURAM_ECC                   /**< Double bit ECC occurred on MURAM*/
236 } e_FmExceptions;
237 
238 /**************************************************************************//**
239  @Group         FM_init_grp FM Initialization Unit
240 
241  @Description   FM Initialization Unit
242 
243                 Initialization Flow
244                 Initialization of the FM Module will be carried out by the application
245                 according to the following sequence:
246                 a.  Calling the configuration routine with basic parameters.
247                 b.  Calling the advance initialization routines to change driver's defaults.
248                 c.  Calling the initialization routine.
249 
250  @{
251 *//***************************************************************************/
252 
253 /**************************************************************************//**
254  @Function      t_FmExceptionsCallback
255 
256  @Description   Exceptions user callback routine, will be called upon an
257                 exception passing the exception identification.
258 
259  @Param[in]     h_App      - User's application descriptor.
260  @Param[in]     exception  - The exception.
261 *//***************************************************************************/
262 typedef void (t_FmExceptionsCallback) (t_Handle              h_App,
263                                        e_FmExceptions        exception);
264 
265 /**************************************************************************//**
266  @Function      t_FmBusErrorCallback
267 
268  @Description   Bus error user callback routine, will be called upon a
269                 bus error, passing parameters describing the errors and the owner.
270 
271  @Param[in]     h_App       - User's application descriptor.
272  @Param[in]     portType    - Port type (e_FmPortType)
273  @Param[in]     portId      - Port id - relative to type.
274  @Param[in]     addr        - Address that caused the error
275  @Param[in]     tnum        - Owner of error
276  @Param[in]     liodn       - Logical IO device number
277 *//***************************************************************************/
278 typedef void (t_FmBusErrorCallback) (t_Handle        h_App,
279                                      e_FmPortType    portType,
280                                      uint8_t         portId,
281                                      uint64_t        addr,
282                                      uint8_t         tnum,
283                                      uint16_t        liodn);
284 
285 /**************************************************************************//**
286  @Description   structure for defining Ucode patch for loading.
287 *//***************************************************************************/
288 typedef struct t_FmPcdFirmwareParams {
289     uint32_t                size;                   /**< Size of uCode */
290     uint32_t                *p_Code;                /**< A pointer to the uCode */
291 } t_FmPcdFirmwareParams;
292 
293 /**************************************************************************//**
294  @Description   structure representing FM initialization parameters
295 *//***************************************************************************/
296 #define FM_SIZE_OF_LIODN_TABLE  64
297 typedef struct t_FmParams {
298     uint8_t                 fmId;                   /**< Index of the FM */
299 
300     uint8_t                 guestId;                /**< FM Partition Id */
301 
302     uintptr_t               baseAddr;               /**< Relevant when guestId = NCSW_MASSTER_ID only.
303                                                          A pointer to base of memory mapped FM registers (virtual);
304                                                          NOTE that this should include ALL common regs of the FM including
305                                                          the PCD regs area. */
306     t_Handle                h_FmMuram;              /**< Relevant when guestId = NCSW_MASSTER_ID only.
307                                                          A handle of an initialized MURAM object,
308                                                          to be used by the FM */
309     uint16_t                fmClkFreq;              /**< Relevant when guestId = NCSW_MASSTER_ID only.
310                                                          In Mhz */
311 #ifdef FM_PARTITION_ARRAY
312     uint16_t                liodnBasePerPort[FM_SIZE_OF_LIODN_TABLE];
313                                                     /**< Relevant when guestId = NCSW_MASSTER_ID only.
314                                                          For each partition, LIODN should be configured here. */
315 #endif /* FM_PARTITION_ARRAY */
316     t_FmExceptionsCallback  *f_Exception;           /**< Relevant when guestId = NCSW_MASSTER_ID only.
317                                                          An application callback routine to
318                                                          handle exceptions.*/
319     t_FmBusErrorCallback    *f_BusError;            /**< Relevant when guestId = NCSW_MASSTER_ID only.
320                                                          An application callback routine to
321                                                          handle exceptions.*/
322     t_Handle                h_App;                  /**< Relevant when guestId = NCSW_MASSTER_ID only.
323                                                          A handle to an application layer object; This handle will
324                                                          be passed by the driver upon calling the above callbacks */
325     uintptr_t               irq;                    /**< Relevant when guestId = NCSW_MASSTER_ID only.
326                                                          FM interrupt source for normal events */
327     uintptr_t               errIrq;                 /**< Relevant when guestId = NCSW_MASSTER_ID only.
328                                                          FM interrupt source for errors */
329     t_FmPcdFirmwareParams   firmware;               /**< Relevant when guestId = NCSW_MASSTER_ID only.
330                                                          Ucode */
331 } t_FmParams;
332 
333 
334 /**************************************************************************//**
335  @Function      FM_Config
336 
337  @Description   Creates descriptor for the FM module.
338 
339                 The routine returns a handle (descriptor) to the FM object.
340                 This descriptor must be passed as first parameter to all other
341                 FM function calls.
342 
343                 No actual initialization or configuration of FM hardware is
344                 done by this routine.
345 
346  @Param[in]     p_FmParams  - A pointer to data structure of parameters
347 
348  @Return        Handle to FM object, or NULL for Failure.
349 *//***************************************************************************/
350 t_Handle FM_Config(t_FmParams *p_FmParams);
351 
352 /**************************************************************************//**
353  @Function      FM_Init
354 
355  @Description   Initializes the FM module
356 
357  @Param[in]     h_Fm - FM module descriptor
358 
359  @Return        E_OK on success; Error code otherwise.
360 *//***************************************************************************/
361 t_Error FM_Init(t_Handle h_Fm);
362 
363 /**************************************************************************//**
364  @Function      FM_Free
365 
366  @Description   Frees all resources that were assigned to FM module.
367 
368                 Calling this routine invalidates the descriptor.
369 
370  @Param[in]     h_Fm - FM module descriptor
371 
372  @Return        E_OK on success; Error code otherwise.
373 *//***************************************************************************/
374 t_Error FM_Free(t_Handle h_Fm);
375 
376 
377 /**************************************************************************//**
378  @Group         FM_advanced_init_grp    FM Advanced Configuration Unit
379 
380  @Description   Configuration functions used to change default values;
381                 Note: Advanced init routines are not available for guest partition.
382  @{
383 *//***************************************************************************/
384 
385 /**************************************************************************//**
386  @Description   DMA debug mode
387 *//***************************************************************************/
388 typedef enum e_FmDmaDbgCntMode {
389     e_FM_DMA_DBG_NO_CNT             = 0,    /**< No counting */
390     e_FM_DMA_DBG_CNT_DONE,                  /**< Count DONE commands */
391     e_FM_DMA_DBG_CNT_COMM_Q_EM,             /**< count command queue emergency signals */
392     e_FM_DMA_DBG_CNT_INT_READ_EM,           /**< Count Internal Read buffer emergency signal */
393     e_FM_DMA_DBG_CNT_INT_WRITE_EM,          /**< Count Internal Write buffer emergency signal */
394     e_FM_DMA_DBG_CNT_FPM_WAIT,              /**< Count FPM WAIT signal */
395     e_FM_DMA_DBG_CNT_SIGLE_BIT_ECC,         /**< Single bit ECC errors. */
396     e_FM_DMA_DBG_CNT_RAW_WAR_PROT           /**< Number of times there was a need for RAW & WAR protection. */
397 } e_FmDmaDbgCntMode;
398 
399 /**************************************************************************//**
400  @Description   DMA Cache Override
401 *//***************************************************************************/
402 typedef enum e_FmDmaCacheOverride {
403     e_FM_DMA_NO_CACHE_OR = 0,               /**< No override of the Cache field */
404     e_FM_DMA_NO_STASH_DATA,                 /**< Data should not be stashed in system level cache */
405     e_FM_DMA_MAY_STASH_DATA,                /**< Data may be stashed in system level cache */
406     e_FM_DMA_STASH_DATA                     /**< Data should be stashed in system level cache */
407 } e_FmDmaCacheOverride;
408 
409 /**************************************************************************//**
410  @Description   DMA External Bus Priority
411 *//***************************************************************************/
412 typedef enum e_FmDmaExtBusPri {
413     e_FM_DMA_EXT_BUS_NORMAL = 0,            /**< Normal priority */
414     e_FM_DMA_EXT_BUS_EBS,                   /**< AXI extended bus service priority */
415     e_FM_DMA_EXT_BUS_SOS,                   /**< AXI sos priority */
416     e_FM_DMA_EXT_BUS_EBS_AND_SOS            /**< AXI ebs + sos priority */
417 } e_FmDmaExtBusPri;
418 
419 /**************************************************************************//**
420  @Description   enum for choosing the field that will be output on AID
421 *//***************************************************************************/
422 typedef enum e_FmDmaAidMode {
423     e_FM_DMA_AID_OUT_PORT_ID = 0,           /**< 4 LSB of PORT_ID */
424     e_FM_DMA_AID_OUT_TNUM                   /**< 4 LSB of TNUM */
425 } e_FmDmaAidMode;
426 
427 /**************************************************************************//**
428  @Description   FPM Catasrophic error behaviour
429 *//***************************************************************************/
430 typedef enum e_FmCatastrophicErr {
431     e_FM_CATASTROPHIC_ERR_STALL_PORT = 0,   /**< Port_ID is stalled (only reset can release it) */
432     e_FM_CATASTROPHIC_ERR_STALL_TASK        /**< Only errornous task is stalled */
433 } e_FmCatastrophicErr;
434 
435 /**************************************************************************//**
436  @Description   FPM DMA error behaviour
437 *//***************************************************************************/
438 typedef enum e_FmDmaErr {
439     e_FM_DMA_ERR_CATASTROPHIC = 0,          /**< Dma error is treated as a catastrophic error */
440     e_FM_DMA_ERR_REPORT                     /**< Dma error is just reported */
441 } e_FmDmaErr;
442 
443 /**************************************************************************//**
444  @Description   DMA Emergency level by BMI emergency signal
445 *//***************************************************************************/
446 typedef enum e_FmDmaEmergencyLevel {
447     e_FM_DMA_EM_EBS = 0,                    /**< EBS emergency */
448     e_FM_DMA_EM_SOS                         /**< SOS emergency */
449 } e_FmDmaEmergencyLevel;
450 
451 /**************************************************************************//**
452  @Collection   DMA emergency options
453 *//***************************************************************************/
454 typedef uint32_t fmEmergencyBus_t;          /**< DMA emergency options */
455 
456 #define  FM_DMA_MURAM_READ_EMERGENCY        0x00800000    /**< Enable emergency for MURAM1 */
457 #define  FM_DMA_MURAM_WRITE_EMERGENCY       0x00400000    /**< Enable emergency for MURAM2 */
458 #define  FM_DMA_EXT_BUS_EMERGENCY           0x00100000    /**< Enable emergency for external bus */
459 /* @} */
460 
461 /**************************************************************************//**
462  @Description   A structure for defining DMA emergency level
463 *//***************************************************************************/
464 typedef struct t_FmDmaEmergency {
465     fmEmergencyBus_t        emergencyBusSelect;             /**< An OR of the busses where emergency
466                                                                  should be enabled */
467     e_FmDmaEmergencyLevel   emergencyLevel;                 /**< EBS/SOS */
468 } t_FmDmaEmergency;
469 
470 /**************************************************************************//**
471  @Description   structure for defining FM threshold
472 *//***************************************************************************/
473 typedef struct t_FmThresholds {
474     uint8_t                 dispLimit;                      /**< The number of times a frames may
475                                                                  be passed in the FM before assumed to
476                                                                  be looping. */
477     uint8_t                 prsDispTh;                      /**< This is the number pf packets that may be
478                                                                  queued in the parser dispatch queue*/
479     uint8_t                 plcrDispTh;                     /**< This is the number pf packets that may be
480                                                                  queued in the policer dispatch queue*/
481     uint8_t                 kgDispTh;                       /**< This is the number pf packets that may be
482                                                                  queued in the keygen dispatch queue*/
483     uint8_t                 bmiDispTh;                      /**< This is the number pf packets that may be
484                                                                  queued in the BMI dispatch queue*/
485     uint8_t                 qmiEnqDispTh;                   /**< This is the number pf packets that may be
486                                                                  queued in the QMI enqueue dispatch queue*/
487     uint8_t                 qmiDeqDispTh;                   /**< This is the number pf packets that may be
488                                                                  queued in the QMI dequeue dispatch queue*/
489     uint8_t                 fmCtl1DispTh;                   /**< This is the number pf packets that may be
490                                                                  queued in fmCtl1 dispatch queue*/
491     uint8_t                 fmCtl2DispTh;                   /**< This is the number pf packets that may be
492                                                                  queued in fmCtl2 dispatch queue*/
493 } t_FmThresholds;
494 
495 
496 /**************************************************************************//**
497  @Description   structure for defining DMA thresholds
498 *//***************************************************************************/
499 typedef struct t_FmDmaThresholds {
500     uint8_t                     assertEmergency;            /**< When this value is reached,
501                                                                  assert emergency (Threshold)*/
502     uint8_t                     clearEmergency;             /**< After emergency is asserted, it is held
503                                                                  until this value is reached (Hystheresis) */
504 } t_FmDmaThresholds;
505 
506 
507 /**************************************************************************//**
508  @Function      FM_ConfigResetOnInit
509 
510  @Description   Tell the driver whether to reset the FM before initialization or
511                 not. It changes the default configuration [FALSE].
512 
513  @Param[in]     h_Fm                A handle to an FM Module.
514  @Param[in]     enable              When TRUE, FM will be reset before any initialization.
515 
516  @Return        E_OK on success; Error code otherwise.
517 
518  @Cautions      Allowed only following FM_Config() and before FM_Init().
519 *//***************************************************************************/
520 t_Error FM_ConfigResetOnInit(t_Handle h_Fm, bool enable);
521 
522 /**************************************************************************//**
523  @Function      FM_ConfigTotalNumOfTasks
524 
525  @Description   Change the total number of tasks from its default
526                 configuration [BMI_MAX_NUM_OF_TASKS]
527 
528  @Param[in]     h_Fm                A handle to an FM Module.
529  @Param[in]     totalNumOfTasks     The selected new value.
530 
531  @Return        E_OK on success; Error code otherwise.
532 
533  @Cautions      Allowed only following FM_Config() and before FM_Init().
534 *//***************************************************************************/
535 t_Error FM_ConfigTotalNumOfTasks(t_Handle h_Fm, uint8_t totalNumOfTasks);
536 
537 /**************************************************************************//**
538  @Function      FM_ConfigTotalFifoSize
539 
540  @Description   Change the total Fifo size from its default
541                 configuration [BMI_MAX_FIFO_SIZE]
542 
543  @Param[in]     h_Fm                A handle to an FM Module.
544  @Param[in]     totalFifoSize       The selected new value.
545 
546  @Return        E_OK on success; Error code otherwise.
547 
548  @Cautions      Allowed only following FM_Config() and before FM_Init().
549 *//***************************************************************************/
550 t_Error FM_ConfigTotalFifoSize(t_Handle h_Fm, uint32_t totalFifoSize);
551 
552 /**************************************************************************//**
553  @Function      FM_ConfigMaxNumOfOpenDmas
554 
555  @Description   Change the maximum allowed open DMA's for this FM from its default
556                 configuration [BMI_MAX_NUM_OF_DMAS]
557 
558  @Param[in]     h_Fm                A handle to an FM Module.
559  @Param[in]     maxNumOfOpenDmas    The selected new value.
560 
561  @Return        E_OK on success; Error code otherwise.
562 
563  @Cautions      Allowed only following FM_Config() and before FM_Init().
564 *//***************************************************************************/
565 t_Error FM_ConfigMaxNumOfOpenDmas(t_Handle h_Fm, uint8_t maxNumOfOpenDmas);
566 
567 /**************************************************************************//**
568  @Function      FM_ConfigThresholds
569 
570  @Description   Calling this routine changes the internal driver data base
571                 from its default FM threshold configuration:
572                                           dispLimit:    [0]
573                                           prsDispTh:    [16]
574                                           plcrDispTh:   [16]
575                                           kgDispTh:     [16]
576                                           bmiDispTh:    [16]
577                                           qmiEnqDispTh: [16]
578                                           qmiDeqDispTh: [16]
579                                           fmCtl1DispTh:  [16]
580                                           fmCtl2DispTh:  [16]
581 
582  @Param[in]     h_Fm            A handle to an FM Module.
583  @Param[in]     p_FmThresholds  A structure of threshold parameters.
584 
585  @Return        E_OK on success; Error code otherwise.
586 
587  @Cautions      Allowed only following FM_Config() and before FM_Init().
588 *//***************************************************************************/
589 t_Error FM_ConfigThresholds(t_Handle h_Fm, t_FmThresholds *p_FmThresholds);
590 
591  /**************************************************************************//**
592  @Function      FM_ConfigDmaCacheOverride
593 
594  @Description   Calling this routine changes the internal driver data base
595                 from its default configuration of cache override mode [e_FM_DMA_NO_CACHE_OR]
596 
597  @Param[in]     h_Fm            A handle to an FM Module.
598  @Param[in]     cacheOverride   The selected new value.
599 
600  @Return        E_OK on success; Error code otherwise.
601 
602  @Cautions      Allowed only following FM_Config() and before FM_Init().
603 *//***************************************************************************/
604 t_Error FM_ConfigDmaCacheOverride(t_Handle h_Fm, e_FmDmaCacheOverride cacheOverride);
605 
606 /**************************************************************************//**
607  @Function      FM_ConfigDmaAidOverride
608 
609  @Description   Calling this routine changes the internal driver data base
610                 from its default configuration of aid override mode [TRUE]
611 
612  @Param[in]     h_Fm            A handle to an FM Module.
613  @Param[in]     aidOverride     The selected new value.
614 
615  @Return        E_OK on success; Error code otherwise.
616 
617  @Cautions      Allowed only following FM_Config() and before FM_Init().
618 *//***************************************************************************/
619 t_Error FM_ConfigDmaAidOverride(t_Handle h_Fm, bool aidOverride);
620 
621 /**************************************************************************//**
622  @Function      FM_ConfigDmaAidMode
623 
624  @Description   Calling this routine changes the internal driver data base
625                 from its default configuration of aid mode [e_FM_DMA_AID_OUT_TNUM]
626 
627  @Param[in]     h_Fm            A handle to an FM Module.
628  @Param[in]     aidMode         The selected new value.
629 
630  @Return        E_OK on success; Error code otherwise.
631 
632  @Cautions      Allowed only following FM_Config() and before FM_Init().
633 *//***************************************************************************/
634 t_Error FM_ConfigDmaAidMode(t_Handle h_Fm, e_FmDmaAidMode aidMode);
635 
636 /**************************************************************************//**
637  @Function      FM_ConfigDmaAxiDbgNumOfBeats
638 
639  @Description   Calling this routine changes the internal driver data base
640                 from its default configuration of axi debug [1]
641 
642  @Param[in]     h_Fm                A handle to an FM Module.
643  @Param[in]     axiDbgNumOfBeats    The selected new value.
644 
645  @Return        E_OK on success; Error code otherwise.
646 
647  @Cautions      Allowed only following FM_Config() and before FM_Init().
648 *//***************************************************************************/
649 t_Error FM_ConfigDmaAxiDbgNumOfBeats(t_Handle h_Fm, uint8_t axiDbgNumOfBeats);
650 
651 /**************************************************************************//**
652  @Function      FM_ConfigDmaCamNumOfEntries
653 
654  @Description   Calling this routine changes the internal driver data base
655                 from its default configuration of number of CAM entries [32]
656 
657  @Param[in]     h_Fm            A handle to an FM Module.
658  @Param[in]     numOfEntries    The selected new value.
659 
660  @Return        E_OK on success; Error code otherwise.
661 
662  @Cautions      Allowed only following FM_Config() and before FM_Init().
663 *//***************************************************************************/
664 t_Error FM_ConfigDmaCamNumOfEntries(t_Handle h_Fm, uint8_t numOfEntries);
665 
666 /**************************************************************************//**
667  @Function      FM_ConfigDmaWatchdog
668 
669  @Description   Calling this routine changes the internal driver data base
670                 from its default watchdog configuration, which is disabled
671                 [0].
672 
673  @Param[in]     h_Fm            A handle to an FM Module.
674  @Param[in]     watchDogValue   The selected new value - in microseconds.
675 
676  @Return        E_OK on success; Error code otherwise.
677 
678  @Cautions      Allowed only following FM_Config() and before FM_Init().
679 *//***************************************************************************/
680 t_Error FM_ConfigDmaWatchdog(t_Handle h_Fm, uint32_t watchDogValue);
681 
682 /**************************************************************************//**
683  @Function      FM_ConfigDmaWriteBufThresholds
684 
685  @Description   Calling this routine changes the internal driver data base
686                 from its default configuration of DMA write buffer threshold
687                 assertEmergency: [DMA_THRESH_MAX_BUF]
688                 clearEmergency:  [DMA_THRESH_MAX_BUF]
689 
690  @Param[in]     h_Fm                A handle to an FM Module.
691  @Param[in]     p_FmDmaThresholds   A structure of thresholds to define emergency behavior -
692                                     When 'assertEmergency' value is reached, emergency is asserted,
693                                     then it is held until 'clearEmergency' value is reached.
694 
695  @Return        E_OK on success; Error code otherwise.
696 
697  @Cautions      Allowed only following FM_Config() and before FM_Init().
698 *//***************************************************************************/
699 t_Error FM_ConfigDmaWriteBufThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds);
700 
701  /**************************************************************************//**
702  @Function      FM_ConfigDmaCommQThresholds
703 
704  @Description   Calling this routine changes the internal driver data base
705                 from its default configuration of DMA command queue threshold
706                 assertEmergency: [DMA_THRESH_MAX_COMMQ]
707                 clearEmergency:  [DMA_THRESH_MAX_COMMQ]
708 
709  @Param[in]     h_Fm                A handle to an FM Module.
710  @Param[in]     p_FmDmaThresholds   A structure of thresholds to define emergency behavior -
711                                     When 'assertEmergency' value is reached, emergency is asserted,
712                                     then it is held until 'clearEmergency' value is reached..
713 
714  @Return        E_OK on success; Error code otherwise.
715 
716  @Cautions      Allowed only following FM_Config() and before FM_Init().
717 *//***************************************************************************/
718 t_Error FM_ConfigDmaCommQThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds);
719 
720 /**************************************************************************//**
721  @Function      FM_ConfigDmaReadBufThresholds
722 
723  @Description   Calling this routine changes the internal driver data base
724                 from its default configuration of DMA read buffer threshold
725                 assertEmergency: [DMA_THRESH_MAX_BUF]
726                 clearEmergency:  [DMA_THRESH_MAX_BUF]
727 
728  @Param[in]     h_Fm                A handle to an FM Module.
729  @Param[in]     p_FmDmaThresholds   A structure of thresholds to define emergency behavior -
730                                     When 'assertEmergency' value is reached, emergency is asserted,
731                                     then it is held until 'clearEmergency' value is reached..
732 
733  @Return        E_OK on success; Error code otherwise.
734 
735  @Cautions      Allowed only following FM_Config() and before FM_Init().
736 *//***************************************************************************/
737 t_Error FM_ConfigDmaReadBufThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds);
738 
739 /**************************************************************************//**
740  @Function      FM_ConfigDmaSosEmergencyThreshold
741 
742  @Description   Calling this routine changes the internal driver data base
743                 from its default dma SOS emergency configuration [0]
744 
745  @Param[in]     h_Fm                A handle to an FM Module.
746  @Param[in]     dmaSosEmergency     The selected new value.
747 
748  @Return        E_OK on success; Error code otherwise.
749 
750  @Cautions      Allowed only following FM_Config() and before FM_Init().
751 *//***************************************************************************/
752 t_Error FM_ConfigDmaSosEmergencyThreshold(t_Handle h_Fm, uint32_t dmaSosEmergency);
753 
754 /**************************************************************************//**
755  @Function      FM_ConfigEnableCounters
756 
757  @Description   Calling this routine changes the internal driver data base
758                 from its default counters configuration where counters are disabled.
759 
760  @Param[in]     h_Fm    A handle to an FM Module.
761 
762  @Return        E_OK on success; Error code otherwise.
763 
764  @Cautions      Allowed only following FM_Config() and before FM_Init().
765 *//***************************************************************************/
766 t_Error FM_ConfigEnableCounters(t_Handle h_Fm);
767 
768 /**************************************************************************//**
769  @Function      FM_ConfigDmaDbgCounter
770 
771  @Description   Calling this routine changes the internal driver data base
772                 from its default DMA debug counters configuration [e_FM_DMA_DBG_NO_CNT]
773 
774  @Param[in]     h_Fm                A handle to an FM Module.
775  @Param[in]     fmDmaDbgCntMode     An enum selecting the debug counter mode.
776 
777  @Return        E_OK on success; Error code otherwise.
778 
779  @Cautions      Allowed only following FM_Config() and before FM_Init().
780 *//***************************************************************************/
781 t_Error FM_ConfigDmaDbgCounter(t_Handle h_Fm, e_FmDmaDbgCntMode fmDmaDbgCntMode);
782 
783 /**************************************************************************//**
784  @Function      FM_ConfigDmaStopOnBusErr
785 
786  @Description   Calling this routine changes the internal driver data base
787                 from its default selection of bus error behavior [FALSE]
788 
789 
790  @Param[in]     h_Fm    A handle to an FM Module.
791  @Param[in]     stop    TRUE to stop on bus error, FALSE to continue.
792 
793  @Return        E_OK on success; Error code otherwise.
794 
795  @Cautions      Allowed only following FM_Config() and before FM_Init().
796                 Only if bus error is enabled.
797 *//***************************************************************************/
798 t_Error FM_ConfigDmaStopOnBusErr(t_Handle h_Fm, bool stop);
799 
800 /**************************************************************************//**
801  @Function      FM_ConfigDmaEmergency
802 
803  @Description   Calling this routine changes the internal driver data base
804                 from its default selection of DMA emergency where's it's disabled.
805 
806  @Param[in]     h_Fm        A handle to an FM Module.
807  @Param[in]     p_Emergency An OR mask of all required options.
808 
809  @Return        E_OK on success; Error code otherwise.
810 
811  @Cautions      Allowed only following FM_Config() and before FM_Init().
812 *//***************************************************************************/
813 t_Error FM_ConfigDmaEmergency(t_Handle h_Fm, t_FmDmaEmergency *p_Emergency);
814 
815 /**************************************************************************//**
816  @Function      FM_ConfigDmaEmergencySmoother
817 
818  @Description   sets the minimum amount of DATA beats transferred on the AXI
819                 READ and WRITE ports before lowering the emergency level.
820                 By default smother is disabled.
821 
822  @Param[in]     h_Fm            A handle to an FM Module.
823  @Param[in]     emergencyCnt    emergency switching counter.
824 
825  @Return        E_OK on success; Error code otherwise.
826 
827  @Cautions      Allowed only following FM_Config() and before FM_Init().
828 *//***************************************************************************/
829 t_Error FM_ConfigDmaEmergencySmoother(t_Handle h_Fm, uint32_t emergencyCnt);
830 
831 /**************************************************************************//**
832  @Function      FM_ConfigDmaErr
833 
834  @Description   Calling this routine changes the internal driver data base
835                 from its default DMA error treatment [e_FM_DMA_ERR_CATASTROPHIC]
836 
837  @Param[in]     h_Fm    A handle to an FM Module.
838  @Param[in]     dmaErr  The selected new choice.
839 
840  @Return        E_OK on success; Error code otherwise.
841 
842  @Cautions      Allowed only following FM_Config() and before FM_Init().
843 *//***************************************************************************/
844 t_Error FM_ConfigDmaErr(t_Handle h_Fm, e_FmDmaErr dmaErr);
845 
846 /**************************************************************************//**
847  @Function      FM_ConfigCatastrophicErr
848 
849  @Description   Calling this routine changes the internal driver data base
850                 from its default behavior on catastrophic error [e_FM_CATASTROPHIC_ERR_STALL_PORT]
851 
852  @Param[in]     h_Fm                A handle to an FM Module.
853  @Param[in]     catastrophicErr     The selected new choice.
854 
855  @Return        E_OK on success; Error code otherwise.
856 
857  @Cautions      Allowed only following FM_Config() and before FM_Init().
858 *//***************************************************************************/
859 t_Error FM_ConfigCatastrophicErr(t_Handle h_Fm, e_FmCatastrophicErr catastrophicErr);
860 
861 /**************************************************************************//**
862  @Function      FM_ConfigEnableMuramTestMode
863 
864  @Description   Calling this routine changes the internal driver data base
865                 from its default selection of test mode where it's disabled.
866 
867  @Param[in]     h_Fm    A handle to an FM Module.
868 
869  @Return        E_OK on success; Error code otherwise.
870 
871  @Cautions      Allowed only following FM_Config() and before FM_Init().
872 *//***************************************************************************/
873 t_Error FM_ConfigEnableMuramTestMode(t_Handle h_Fm);
874 
875 /**************************************************************************//**
876  @Function      FM_ConfigEnableIramTestMode
877 
878  @Description   Calling this routine changes the internal driver data base
879                 from its default selection of test mode where it's disabled.
880 
881  @Param[in]     h_Fm    A handle to an FM Module.
882 
883  @Return        E_OK on success; Error code otherwise.
884 
885  @Cautions      Allowed only following FM_Config() and before FM_Init().
886 *//***************************************************************************/
887 t_Error FM_ConfigEnableIramTestMode(t_Handle h_Fm);
888 
889 /**************************************************************************//**
890  @Function      FM_ConfigHaltOnExternalActivation
891 
892  @Description   Calling this routine changes the internal driver data base
893                 from its default selection of FM behaviour on external halt
894                 activation [FALSE].
895 
896  @Param[in]     h_Fm            A handle to an FM Module.
897  @Param[in]     enable          TRUE to enable halt on external halt
898                                 activation.
899 
900  @Return        E_OK on success; Error code otherwise.
901 
902  @Cautions      Allowed only following FM_Config() and before FM_Init().
903 *//***************************************************************************/
904 t_Error FM_ConfigHaltOnExternalActivation(t_Handle h_Fm, bool enable);
905 
906 /**************************************************************************//**
907  @Function      FM_ConfigHaltOnUnrecoverableEccError
908 
909  @Description   Calling this routine changes the internal driver data base
910                 from its default selection of FM behaviour on unrecoverable
911                 Ecc error [FALSE].
912 
913  @Param[in]     h_Fm            A handle to an FM Module.
914  @Param[in]     enable          TRUE to enable halt on unrecoverable Ecc error
915 
916  @Return        E_OK on success; Error code otherwise.
917 
918  @Cautions      Allowed only following FM_Config() and before FM_Init().
919 *//***************************************************************************/
920 t_Error FM_ConfigHaltOnUnrecoverableEccError(t_Handle h_Fm, bool enable);
921 
922 /**************************************************************************//**
923  @Function      FM_ConfigException
924 
925  @Description   Calling this routine changes the internal driver data base
926                 from its default selection of exceptions enablement.
927                 By default all exceptions are enabled.
928 
929  @Param[in]     h_Fm            A handle to an FM Module.
930  @Param[in]     exception       The exception to be selected.
931  @Param[in]     enable          TRUE to enable interrupt, FALSE to mask it.
932 
933  @Return        E_OK on success; Error code otherwise.
934 
935  @Cautions      Allowed only following FM_Config() and before FM_Init().
936 *//***************************************************************************/
937 t_Error FM_ConfigException(t_Handle h_Fm, e_FmExceptions exception, bool enable);
938 
939 /**************************************************************************//**
940  @Function      FM_ConfigExternalEccRamsEnable
941 
942  @Description   Calling this routine changes the internal driver data base
943                 from its default [FALSE].
944                 When this option is enabled Rams ECC enable is not effected
945                 by the FPM RCR bit, but by a JTAG.
946 
947  @Param[in]     h_Fm            A handle to an FM Module.
948  @Param[in]     enable          TRUE to enable this option.
949 
950  @Return        E_OK on success; Error code otherwise.
951 
952  @Cautions      Allowed only following FM_Config() and before FM_Init().
953 *//***************************************************************************/
954 t_Error FM_ConfigExternalEccRamsEnable(t_Handle h_Fm, bool enable);
955 
956 /**************************************************************************//**
957  @Function      FM_ConfigTnumAgingPeriod
958 
959  @Description   Calling this routine changes the internal driver data base
960                 from its default configuration for aging of dequeue TNUM's
961                 in the QMI.[0]
962                 Note that this functionality is not available in all chips.
963 
964  @Param[in]     h_Fm                A handle to an FM Module.
965  @Param[in]     tnumAgingPeriod     Tnum Aging Period in microseconds.
966                                     Note that period is recalculated in units of
967                                     64 FM clocks. Driver will pick the closest
968                                     possible period.
969 
970  @Return        E_OK on success; Error code otherwise.
971 
972  @Cautions      Allowed only following FM_Config() and before FM_Init().
973 *//***************************************************************************/
974 t_Error FM_ConfigTnumAgingPeriod(t_Handle h_Fm, uint16_t tnumAgingPeriod);
975 
976 /** @} */ /* end of FM_advanced_init_grp group */
977 /** @} */ /* end of FM_init_grp group */
978 
979 
980 /**************************************************************************//**
981  @Group         FM_runtime_control_grp FM Runtime Control Unit
982 
983  @Description   FM Runtime control unit API functions, definitions and enums.
984                 The FM driver provides a set of control routines for each module.
985                 These routines may only be called after the module was fully
986                 initialized (both configuration and initialization routines were
987                 called). They are typically used to get information from hardware
988                 (status, counters/statistics, revision etc.), to modify a current
989                 state or to force/enable a required action. Run-time control may
990                 be called whenever necessary and as many times as needed.
991  @{
992 *//***************************************************************************/
993 
994 /**************************************************************************//**
995  @Collection   General FM defines.
996 *//***************************************************************************/
997 #define FM_MAX_NUM_OF_VALID_PORTS   (FM_MAX_NUM_OF_OH_PORTS +       \
998                                      FM_MAX_NUM_OF_1G_RX_PORTS +    \
999                                      FM_MAX_NUM_OF_10G_RX_PORTS +   \
1000                                      FM_MAX_NUM_OF_1G_TX_PORTS +    \
1001                                      FM_MAX_NUM_OF_10G_TX_PORTS)
1002 /* @} */
1003 
1004 /**************************************************************************//**
1005  @Description   Structure for Port bandwidth requirement. Port is identified
1006                 by type and relative id.
1007 *//***************************************************************************/
1008 typedef struct t_FmPortBandwidth {
1009     e_FmPortType        type;           /**< FM port type */
1010     uint8_t             relativePortId; /**< Type relative port id */
1011     uint8_t             bandwidth;      /**< bandwidth - (in term of percents) */
1012 } t_FmPortBandwidth;
1013 
1014 /**************************************************************************//**
1015  @Description   A Structure containing an array of Port bandwidth requirements.
1016                 The user should state the ports requiring bandwidth in terms of
1017                 percentage - i.e. all port's bandwidths in the array must add
1018                 up to 100.
1019 *//***************************************************************************/
1020 typedef struct t_FmPortsBandwidthParams {
1021     uint8_t             numOfPorts;         /**< num of ports listed in the array below */
1022     t_FmPortBandwidth   portsBandwidths[FM_MAX_NUM_OF_VALID_PORTS];
1023                                             /**< for each port, it's bandwidth (all port's
1024                                                  bandwidths must add up to 100.*/
1025 } t_FmPortsBandwidthParams;
1026 
1027 /**************************************************************************//**
1028  @Description   DMA Emergency control on MURAM
1029 *//***************************************************************************/
1030 typedef enum e_FmDmaMuramPort {
1031     e_FM_DMA_MURAM_PORT_WRITE,              /**< MURAM write port */
1032     e_FM_DMA_MURAM_PORT_READ                /**< MURAM read port */
1033 } e_FmDmaMuramPort;
1034 
1035 /**************************************************************************//**
1036  @Description   enum for defining FM counters
1037 *//***************************************************************************/
1038 typedef enum e_FmCounters {
1039     e_FM_COUNTERS_ENQ_TOTAL_FRAME = 0,              /**< QMI total enqueued frames counter */
1040     e_FM_COUNTERS_DEQ_TOTAL_FRAME,                  /**< QMI total dequeued frames counter */
1041     e_FM_COUNTERS_DEQ_0,                            /**< QMI 0 frames from QMan counter */
1042     e_FM_COUNTERS_DEQ_1,                            /**< QMI 1 frames from QMan counter */
1043     e_FM_COUNTERS_DEQ_2,                            /**< QMI 2 frames from QMan counter */
1044     e_FM_COUNTERS_DEQ_3,                            /**< QMI 3 frames from QMan counter */
1045     e_FM_COUNTERS_DEQ_FROM_DEFAULT,                 /**< QMI dequeue from default queue counter */
1046     e_FM_COUNTERS_DEQ_FROM_CONTEXT,                 /**< QMI dequeue from FQ context counter */
1047     e_FM_COUNTERS_DEQ_FROM_FD,                      /**< QMI dequeue from FD command field counter */
1048     e_FM_COUNTERS_DEQ_CONFIRM,                      /**< QMI dequeue confirm counter */
1049     e_FM_COUNTERS_SEMAPHOR_ENTRY_FULL_REJECT,       /**< DMA semaphor reject due to full entry counter */
1050     e_FM_COUNTERS_SEMAPHOR_QUEUE_FULL_REJECT,       /**< DMA semaphor reject due to full CAM queue counter */
1051     e_FM_COUNTERS_SEMAPHOR_SYNC_REJECT              /**< DMA semaphor reject due to sync counter */
1052 } e_FmCounters;
1053 
1054 /**************************************************************************//**
1055  @Description   structure for returning revision information
1056 *//***************************************************************************/
1057 typedef struct t_FmRevisionInfo {
1058     uint8_t         majorRev;               /**< Major revision */
1059     uint8_t         minorRev;               /**< Minor revision */
1060 } t_FmRevisionInfo;
1061 
1062 /**************************************************************************//**
1063  @Description   struct for defining DMA status
1064 *//***************************************************************************/
1065 typedef struct t_FmDmaStatus {
1066     bool    cmqNotEmpty;            /**< Command queue is not empty */
1067     bool    busError;               /**< Bus error occurred */
1068     bool    readBufEccError;        /**< Double ECC error on buffer Read */
1069     bool    writeBufEccSysError;    /**< Double ECC error on buffer write from system side */
1070     bool    writeBufEccFmError;     /**< Double ECC error on buffer write from FM side */
1071 } t_FmDmaStatus;
1072 
1073 
1074 #if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
1075 /**************************************************************************//**
1076  @Function      FM_DumpRegs
1077 
1078  @Description   Dumps all FM registers
1079 
1080  @Param[in]     h_Fm      A handle to an FM Module.
1081 
1082  @Return        E_OK on success;
1083 
1084  @Cautions      Allowed only FM_Init().
1085 *//***************************************************************************/
1086 t_Error FM_DumpRegs(t_Handle h_Fm);
1087 #endif /* (defined(DEBUG_ERRORS) && ... */
1088 
1089 /**************************************************************************//**
1090  @Function      FM_SetException
1091 
1092  @Description   Calling this routine enables/disables the specified exception.
1093                 Note: Not available for guest partition.
1094 
1095  @Param[in]     h_Fm            A handle to an FM Module.
1096  @Param[in]     exception       The exception to be selected.
1097  @Param[in]     enable          TRUE to enable interrupt, FALSE to mask it.
1098 
1099  @Return        E_OK on success; Error code otherwise.
1100 
1101  @Cautions      Allowed only following FM_Init().
1102 *//***************************************************************************/
1103 t_Error FM_SetException(t_Handle h_Fm, e_FmExceptions exception, bool enable);
1104 
1105 /**************************************************************************//**
1106  @Function      FM_SetPortsBandwidth
1107 
1108  @Description   Sets relative weights between ports when accessing common resources.
1109                 Note: Not available for guest partition.
1110 
1111  @Param[in]     h_Fm                A handle to an FM Module.
1112  @Param[in]     p_PortsBandwidth    A structure of ports bandwidths in percentage, i.e.
1113                                     total must equal 100.
1114 
1115  @Return        E_OK on success; Error code otherwise.
1116 
1117  @Cautions      Allowed only following FM_Init().
1118 *//***************************************************************************/
1119 t_Error FM_SetPortsBandwidth(t_Handle h_Fm, t_FmPortsBandwidthParams *p_PortsBandwidth);
1120 
1121 /**************************************************************************//**
1122  @Function      FM_EnableRamsEcc
1123 
1124  @Description   Enables ECC mechanism for all the different FM RAM's; E.g. IRAM,
1125                 MURAM, Parser, Keygen, Policer, etc.
1126                 Note:
1127                 If FM_ConfigExternalEccRamsEnable was called to enable external
1128                 setting of ECC, this routine effects IRAM ECC only.
1129                 This routine is also called by the driver if an ECC exception is
1130                 enabled.
1131                 Note: Not available for guest partition.
1132 
1133  @Param[in]     h_Fm            A handle to an FM Module.
1134 
1135  @Return        E_OK on success; Error code otherwise.
1136 
1137  @Cautions      Allowed only following FM_Config() and before FM_Init().
1138 *//***************************************************************************/
1139 t_Error FM_EnableRamsEcc(t_Handle h_Fm);
1140 
1141 /**************************************************************************//**
1142  @Function      FM_DisableRamsEcc
1143 
1144  @Description   Disables ECC mechanism for all the different FM RAM's; E.g. IRAM,
1145                 MURAM, Parser, Keygen, Policer, etc.
1146                 Note:
1147                 If FM_ConfigExternalEccRamsEnable was called to enable external
1148                 setting of ECC, this routine effects IRAM ECC only.
1149                 In opposed to FM_EnableRamsEcc, this routine must be called
1150                 explicitly to disable all Rams ECC.
1151                 Note: Not available for guest partition.
1152 
1153 
1154  @Param[in]     h_Fm            A handle to an FM Module.
1155 
1156  @Return        E_OK on success; Error code otherwise.
1157 
1158  @Cautions      Allowed only following FM_Config() and before FM_Init().
1159 *//***************************************************************************/
1160 t_Error FM_DisableRamsEcc(t_Handle h_Fm);
1161 
1162 /**************************************************************************//**
1163  @Function      FM_GetRevision
1164 
1165  @Description   Returns the FM revision
1166 
1167  @Param[in]     h_Fm                A handle to an FM Module.
1168  @Param[out]    p_FmRevisionInfo    A structure of revision information parameters.
1169 
1170  @Return        E_OK on success; Error code otherwise.
1171 
1172  @Cautions      Allowed only following FM_Init().
1173 *//***************************************************************************/
1174 t_Error  FM_GetRevision(t_Handle h_Fm, t_FmRevisionInfo *p_FmRevisionInfo);
1175 
1176 /**************************************************************************//**
1177  @Function      FM_GetCounter
1178 
1179  @Description   Reads one of the FM counters.
1180 
1181  @Param[in]     h_Fm        A handle to an FM Module.
1182  @Param[in]     counter     The requested counter.
1183 
1184  @Return        Counter's current value.
1185 
1186  @Cautions      Allowed only following FM_Init().
1187                 Note that it is user's responsibility to call this routine only
1188                 for enabled counters, and there will be no indication if a
1189                 disabled counter is accessed.
1190 *//***************************************************************************/
1191 uint32_t  FM_GetCounter(t_Handle h_Fm, e_FmCounters counter);
1192 
1193 /**************************************************************************//**
1194  @Function      FM_ModifyCounter
1195 
1196  @Description   Sets a value to an enabled counter. Use "0" to reset the counter.
1197                 Note: Not available for guest partition.
1198 
1199  @Param[in]     h_Fm        A handle to an FM Module.
1200  @Param[in]     counter     The requested counter.
1201  @Param[in]     val         The requested value to be written into the counter.
1202 
1203  @Return        E_OK on success; Error code otherwise.
1204 
1205  @Cautions      Allowed only following FM_Init().
1206 *//***************************************************************************/
1207 t_Error  FM_ModifyCounter(t_Handle h_Fm, e_FmCounters counter, uint32_t val);
1208 
1209 /**************************************************************************//**
1210  @Function      FM_Resume
1211 
1212  @Description   Release FM after halt FM command or after unrecoverable ECC error.
1213                 Note: Not available for guest partition.
1214 
1215  @Param[in]     h_Fm        A handle to an FM Module.
1216 
1217  @Return        E_OK on success; Error code otherwise.
1218 *//***************************************************************************/
1219 void FM_Resume(t_Handle h_Fm);
1220 
1221 /**************************************************************************//**
1222  @Function      FM_SetDmaEmergency
1223 
1224  @Description   Manual emergency set
1225                 Note: Not available for guest partition.
1226 
1227  @Param[in]     h_Fm        A handle to an FM Module.
1228  @Param[in]     muramPort   MURAM direction select.
1229  @Param[in]     enable      TRUE to manually enable emergency, FALSE to disable.
1230 
1231  @Return        None.
1232 
1233  @Cautions      Allowed only following FM_Init().
1234 *//***************************************************************************/
1235 void FM_SetDmaEmergency(t_Handle h_Fm, e_FmDmaMuramPort muramPort, bool enable);
1236 
1237 /**************************************************************************//**
1238  @Function      FM_SetDmaExtBusPri
1239 
1240  @Description   Manual emergency set
1241                 Note: Not available for guest partition.
1242 
1243  @Param[in]     h_Fm    A handle to an FM Module.
1244  @Param[in]     pri     External bus priority select
1245 
1246  @Return        None.
1247 
1248  @Cautions      Allowed only following FM_Init().
1249 *//***************************************************************************/
1250 void FM_SetDmaExtBusPri(t_Handle h_Fm, e_FmDmaExtBusPri pri);
1251 
1252 /**************************************************************************//**
1253  @Function      FM_ForceIntr
1254 
1255  @Description   Causes an interrupt event on the requested source.
1256                 Note: Not available for guest partition.
1257 
1258  @Param[in]     h_Fm            A handle to an FM Module.
1259  @Param[in]     exception       An exception to be forced.
1260 
1261  @Return        E_OK on success; Error code if the exception is not enabled,
1262                 or is not able to create interrupt.
1263 
1264  @Cautions      Allowed only following FM_Init().
1265 *//***************************************************************************/
1266 t_Error FM_ForceIntr (t_Handle h_Fm, e_FmExceptions exception);
1267 
1268 /**************************************************************************//**
1269  @Function      FM_GetDmaStatus
1270 
1271  @Description   Reads the DMA current status
1272 
1273  @Param[in]     h_Fm                A handle to an FM Module.
1274  @Param[out]    p_FmDmaStatus      A structure of DMA status parameters.
1275 
1276  @Return        None
1277 
1278  @Cautions      Allowed only following FM_Init().
1279 *//***************************************************************************/
1280 void FM_GetDmaStatus(t_Handle h_Fm, t_FmDmaStatus *p_FmDmaStatus);
1281 
1282 /**************************************************************************//**
1283  @Function      FM_GetPcdHandle
1284 
1285  @Description   Used by FMC in order to get PCD handle
1286 
1287  @Param[in]     h_Fm     A handle to an FM Module.
1288 
1289  @Return        A handle to the PCD module, NULL if uninitialized.
1290 
1291  @Cautions      Allowed only following FM_Init().
1292 *//***************************************************************************/
1293 t_Handle FM_GetPcdHandle(t_Handle h_Fm);
1294 
1295 /**************************************************************************//**
1296  @Function      FM_ErrorIsr
1297                 Note: Not available for guest partition.
1298 
1299  @Description   FM interrupt-service-routine for errors.
1300 
1301  @Param[in]     h_Fm            A handle to an FM Module.
1302 
1303  @Return        E_OK on success; E_EMPTY if no errors found in register, other
1304                 error code otherwise.
1305 
1306  @Cautions      Allowed only following FM_Init().
1307                 This routine should NOT be called from guest-partition
1308                 (i.e. guestId != NCSW_MASTER_ID)
1309 *//***************************************************************************/
1310 t_Error FM_ErrorIsr(t_Handle h_Fm);
1311 
1312 /**************************************************************************//**
1313  @Function      FM_EventIsr
1314                 Note: Not available for guest partition.
1315 
1316  @Description   FM interrupt-service-routine for normal events.
1317 
1318  @Param[in]     h_Fm            A handle to an FM Module.
1319 
1320  @Cautions      Allowed only following FM_Init().
1321                 This routine should NOT be called from guest-partition
1322                 (i.e. guestId != NCSW_MASTER_ID)
1323 *//***************************************************************************/
1324 void FM_EventIsr(t_Handle h_Fm);
1325 
1326 #if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
1327 /**************************************************************************//**
1328  @Function      FmDumpPortRegs
1329 
1330  @Description   Dumps FM port registers which are part of FM common registers
1331 
1332  @Param[in]     h_Fm            A handle to an FM Module.
1333  @Param[in]     hardwarePortId    HW port id.
1334 
1335  @Return        E_OK on success; Error code otherwise.
1336 
1337  @Cautions      Allowed only FM_Init().
1338 *//***************************************************************************/
1339 t_Error FmDumpPortRegs(t_Handle h_Fm,uint8_t hardwarePortId);
1340 #endif /* (defined(DEBUG_ERRORS) && ... */
1341 
1342 
1343 /** @} */ /* end of FM_runtime_control_grp group */
1344 /** @} */ /* end of FM_lib_grp group */
1345 /** @} */ /* end of FM_grp group */
1346 
1347 #endif /* __FM_EXT */
1348