aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/ncsw
diff options
context:
space:
mode:
authorJustin Hibbits <jhibbits@FreeBSD.org>2017-10-30 03:41:04 +0000
committerJustin Hibbits <jhibbits@FreeBSD.org>2017-10-30 03:41:04 +0000
commit852ba100814e41898dc6e673fe0af017084e411d (patch)
tree76d70be40184900be656feb0f50605ed56589b45 /sys/contrib/ncsw
parent50ee2e2aabaab2ba54ef1c091b015a1bd2e2b927 (diff)
downloadsrc-852ba100814e41898dc6e673fe0af017084e411d.tar.gz
src-852ba100814e41898dc6e673fe0af017084e411d.zip
Update DPAA SDK to SDK 2.0
This adds some support for ARM as well as 64-bit. 64-bit on PowerPC is currently not working, and ARM support has not been completed or tested on the FreeBSD side. As this was imported from a Linux tree, it includes some Linux-isms (ioread/iowrite), so compile with the LinuxKPI for now. This may change in the future.
Notes
Notes: svn path=/head/; revision=325118
Diffstat (limited to 'sys/contrib/ncsw')
-rw-r--r--sys/contrib/ncsw/Peripherals/BM/bm.h10
-rw-r--r--sys/contrib/ncsw/Peripherals/BM/bm_pool.c20
-rw-r--r--sys/contrib/ncsw/Peripherals/BM/bman_low.c12
-rw-r--r--sys/contrib/ncsw/Peripherals/BM/bman_private.h85
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/HC/hc.c1451
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/dtsec.c1677
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/dtsec.h520
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/dtsec_mii_acc.c67
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/dtsec_mii_acc.h44
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/fm_mac.c188
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/fm_mac.h76
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/fman_crc32.c119
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/fman_crc32.h43
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/fman_dtsec.c845
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/fman_dtsec_mii_acc.c163
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/fman_memac.c511
-rwxr-xr-xsys/contrib/ncsw/Peripherals/FM/MAC/fman_memac_mii_acc.c213
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/fman_tgec.c367
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/memac.c1096
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/memac.h110
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/memac_mii_acc.c78
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/memac_mii_acc.h73
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/tgec.c891
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/tgec.h449
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/tgec_mii_acc.c32
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MAC/tgec_mii_acc.h7
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec.c237
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec.h203
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_guest.c (renamed from sys/contrib/ncsw/etc/sprint.c)66
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_master.c1031
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_master.h479
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_secy.c883
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_secy.h144
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Pcd/crc64.h360
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Pcd/fm_cc.c8114
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Pcd/fm_cc.h275
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Pcd/fm_kg.c3617
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Pcd/fm_kg.h206
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Pcd/fm_manip.c6414
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Pcd/fm_manip.h489
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Pcd/fm_pcd.c1676
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Pcd/fm_pcd.h580
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Pcd/fm_pcd_ipc.h148
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Pcd/fm_plcr.c2073
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Pcd/fm_plcr.h165
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Pcd/fm_prs.c446
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Pcd/fm_prs.h316
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Pcd/fm_replic.c984
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Pcd/fm_replic.h101
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Pcd/fman_kg.c888
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Pcd/fman_prs.c129
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Port/fm_port.c7746
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Port/fm_port.h513
-rwxr-xr-xsys/contrib/ncsw/Peripherals/FM/Port/fm_port_dsar.h494
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Port/fm_port_im.c88
-rwxr-xr-xsys/contrib/ncsw/Peripherals/FM/Port/fman_port.c1568
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Rtc/fm_rtc.c467
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/Rtc/fm_rtc.h137
-rwxr-xr-xsys/contrib/ncsw/Peripherals/FM/Rtc/fman_rtc.c334
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/SP/fm_sp.c757
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/SP/fm_sp.h85
-rwxr-xr-xsys/contrib/ncsw/Peripherals/FM/SP/fman_sp.c197
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/fm.c5394
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/fm.h875
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/fm_ipc.h106
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/fm_muram.c18
-rwxr-xr-xsys/contrib/ncsw/Peripherals/FM/fman_ncsw.c1398
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/inc/fm_common.h917
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/inc/fm_hc.h33
-rw-r--r--sys/contrib/ncsw/Peripherals/FM/inc/fm_sp_common.h117
-rw-r--r--sys/contrib/ncsw/Peripherals/QM/fsl_qman.h2
-rw-r--r--sys/contrib/ncsw/Peripherals/QM/qm.c11
-rw-r--r--sys/contrib/ncsw/Peripherals/QM/qm.h2
-rw-r--r--sys/contrib/ncsw/Peripherals/QM/qm_portal_fqr.c74
-rw-r--r--sys/contrib/ncsw/Peripherals/QM/qman_low.h10
-rw-r--r--sys/contrib/ncsw/Peripherals/QM/qman_private.h81
-rw-r--r--sys/contrib/ncsw/etc/error.c111
-rw-r--r--sys/contrib/ncsw/etc/list.c12
-rw-r--r--sys/contrib/ncsw/etc/memcpy.c99
-rw-r--r--sys/contrib/ncsw/etc/mm.c78
-rw-r--r--sys/contrib/ncsw/etc/mm.h16
-rw-r--r--sys/contrib/ncsw/etc/ncsw_mem.c2
-rw-r--r--sys/contrib/ncsw/inc/Peripherals/bm_ext.h26
-rw-r--r--sys/contrib/ncsw/inc/Peripherals/crc_mac_addr_ext.h5
-rw-r--r--sys/contrib/ncsw/inc/Peripherals/dpaa_ext.h55
-rw-r--r--sys/contrib/ncsw/inc/Peripherals/fm_ext.h1138
-rw-r--r--sys/contrib/ncsw/inc/Peripherals/fm_mac_ext.h356
-rw-r--r--sys/contrib/ncsw/inc/Peripherals/fm_macsec_ext.h1271
-rw-r--r--sys/contrib/ncsw/inc/Peripherals/fm_muram_ext.h20
-rw-r--r--sys/contrib/ncsw/inc/Peripherals/fm_pcd_ext.h3206
-rw-r--r--sys/contrib/ncsw/inc/Peripherals/fm_port_ext.h1306
-rw-r--r--sys/contrib/ncsw/inc/Peripherals/fm_rtc_ext.h71
-rw-r--r--sys/contrib/ncsw/inc/Peripherals/fm_vsp_ext.h411
-rw-r--r--sys/contrib/ncsw/inc/Peripherals/mii_acc_ext.h76
-rw-r--r--sys/contrib/ncsw/inc/Peripherals/qm_ext.h2
-rw-r--r--sys/contrib/ncsw/inc/core_ext.h19
-rw-r--r--sys/contrib/ncsw/inc/cores/arm_ext.h55
-rw-r--r--sys/contrib/ncsw/inc/cores/e500v2_ext.h73
-rw-r--r--sys/contrib/ncsw/inc/cores/ppc_ext.h21
-rw-r--r--sys/contrib/ncsw/inc/ddr_std_ext.h67
-rw-r--r--sys/contrib/ncsw/inc/debug_ext.h86
-rw-r--r--sys/contrib/ncsw/inc/endian_ext.h5
-rw-r--r--sys/contrib/ncsw/inc/enet_ext.h125
-rw-r--r--sys/contrib/ncsw/inc/error_ext.h139
-rw-r--r--sys/contrib/ncsw/inc/etc/list_ext.h101
-rw-r--r--sys/contrib/ncsw/inc/etc/mem_ext.h5
-rw-r--r--sys/contrib/ncsw/inc/etc/memcpy_ext.h37
-rw-r--r--sys/contrib/ncsw/inc/etc/mm_ext.h20
-rw-r--r--sys/contrib/ncsw/inc/etc/sprint_ext.h11
-rw-r--r--sys/contrib/ncsw/inc/flib/common/arch/ppc_access.h (renamed from sys/contrib/ncsw/Peripherals/FM/fm_guest.c)8
-rw-r--r--sys/contrib/ncsw/inc/flib/common/general.h52
-rwxr-xr-xsys/contrib/ncsw/inc/flib/fman_common.h78
-rw-r--r--sys/contrib/ncsw/inc/flib/fsl_enet.h273
-rwxr-xr-xsys/contrib/ncsw/inc/flib/fsl_fman.h825
-rw-r--r--sys/contrib/ncsw/inc/flib/fsl_fman_dtsec.h1096
-rw-r--r--sys/contrib/ncsw/inc/flib/fsl_fman_dtsec_mii_acc.h107
-rw-r--r--sys/contrib/ncsw/inc/flib/fsl_fman_kg.h514
-rw-r--r--sys/contrib/ncsw/inc/flib/fsl_fman_memac.h427
-rwxr-xr-xsys/contrib/ncsw/inc/flib/fsl_fman_memac_mii_acc.h78
-rwxr-xr-xsys/contrib/ncsw/inc/flib/fsl_fman_port.h593
-rw-r--r--sys/contrib/ncsw/inc/flib/fsl_fman_prs.h102
-rwxr-xr-xsys/contrib/ncsw/inc/flib/fsl_fman_rtc.h449
-rwxr-xr-xsys/contrib/ncsw/inc/flib/fsl_fman_sp.h138
-rw-r--r--sys/contrib/ncsw/inc/flib/fsl_fman_tgec.h479
-rw-r--r--sys/contrib/ncsw/inc/integrations/dpaa_integration_ext.h113
-rw-r--r--sys/contrib/ncsw/inc/integrations/part_ext.h17
-rw-r--r--sys/contrib/ncsw/inc/math_ext.h98
-rw-r--r--sys/contrib/ncsw/inc/ncsw_ext.h31
-rw-r--r--sys/contrib/ncsw/inc/net_ext.h46
-rw-r--r--sys/contrib/ncsw/inc/std_ext.h4
-rw-r--r--sys/contrib/ncsw/inc/stdarg_ext.h4
-rw-r--r--sys/contrib/ncsw/inc/stdlib_ext.h4
-rw-r--r--sys/contrib/ncsw/inc/string_ext.h4
-rw-r--r--sys/contrib/ncsw/inc/types_ext.h65
-rw-r--r--sys/contrib/ncsw/inc/xx_common.h58
-rw-r--r--sys/contrib/ncsw/inc/xx_ext.h163
-rw-r--r--sys/contrib/ncsw/user/env/xx.c77
137 files changed, 53614 insertions, 21909 deletions
diff --git a/sys/contrib/ncsw/Peripherals/BM/bm.h b/sys/contrib/ncsw/Peripherals/BM/bm.h
index 157315629e86..e9708666e244 100644
--- a/sys/contrib/ncsw/Peripherals/BM/bm.h
+++ b/sys/contrib/ncsw/Peripherals/BM/bm.h
@@ -41,6 +41,7 @@
#ifndef __BM_H
#define __BM_H
+#include "xx_common.h"
#include "bm_ext.h"
#include "mm_ext.h"
@@ -261,7 +262,7 @@ typedef struct {
t_Handle h_Bm;
struct bm_portal *p_BmPortalLow;
t_BmPortalCallbacks cbs[BM_NUM_OF_RINGS];
- int irq;
+ uintptr_t irq;
int cpu; /* This is used for any "core-affine" portals, ie. default portals
* associated to the corresponding cpu. -1 implies that there is no core
* affinity configured. */
@@ -303,7 +304,7 @@ typedef struct {
uint32_t exceptions;
t_BmExceptionsCallback *f_Exception;
t_Handle h_App;
- int errIrq; /**< error interrupt line; NO_IRQ if interrupts not used */
+ uintptr_t errIrq; /**< error interrupt line; NO_IRQ if interrupts not used */
t_BmDriverParams *p_BmDriverParams;
} t_Bm;
@@ -339,7 +340,7 @@ static __inline__ void BmCommit(t_BmPortal *p_BmPortal, bmRingType_t type, uint8
static __inline__ uint32_t BmBpidGet(t_Bm *p_Bm, bool force, uint32_t base)
{
uint64_t ans, size = 1;
- uint32_t alignment = 1;
+ uint64_t alignment = 1;
if (force)
{
@@ -347,7 +348,7 @@ static __inline__ uint32_t BmBpidGet(t_Bm *p_Bm, bool force, uint32_t base)
{
ans = MM_GetForce(p_Bm->h_BpidMm,
base,
- (int)size,
+ size,
"BM BPID MEM");
ans = base;
}
@@ -394,6 +395,7 @@ static __inline__ uint32_t BmBpidGet(t_Bm *p_Bm, bool force, uint32_t base)
size,
alignment,
"BM BPID MEM");
+ KASSERT(ans < UINT32_MAX, ("Oops, %lx > UINT32_MAX!\n", ans));
return (uint32_t)ans;
}
diff --git a/sys/contrib/ncsw/Peripherals/BM/bm_pool.c b/sys/contrib/ncsw/Peripherals/BM/bm_pool.c
index d7a38c26b714..c908846760ad 100644
--- a/sys/contrib/ncsw/Peripherals/BM/bm_pool.c
+++ b/sys/contrib/ncsw/Peripherals/BM/bm_pool.c
@@ -545,26 +545,6 @@ t_Handle BM_POOL_GetBufferContext(t_Handle h_BmPool, void *p_Buff)
return *(t_Handle *)PTR_MOVE(p_Buff, -(sizeof(t_Handle)));
}
-void * BM_POOL_PhysToVirt(t_Handle h_BmPool, physAddress_t addr)
-{
- t_BmPool *p_BmPool = (t_BmPool *)h_BmPool;
-
- SANITY_CHECK_RETURN_VALUE(p_BmPool, E_INVALID_HANDLE, NULL);
- SANITY_CHECK_RETURN_VALUE(!p_BmPool->p_BmPoolDriverParams, E_INVALID_HANDLE, NULL);
-
- return p_BmPool->bufferPoolInfo.f_PhysToVirt(addr);
-}
-
-physAddress_t BM_POOL_VirtToPhys(t_Handle h_BmPool, void *p_Buff)
-{
- t_BmPool *p_BmPool = (t_BmPool *)h_BmPool;
-
- SANITY_CHECK_RETURN_VALUE(p_BmPool, E_INVALID_HANDLE, (physAddress_t)0);
- SANITY_CHECK_RETURN_VALUE(!p_BmPool->p_BmPoolDriverParams, E_INVALID_HANDLE, (physAddress_t)0);
-
- return p_BmPool->bufferPoolInfo.f_VirtToPhys(p_Buff);
-}
-
uint32_t BM_POOL_GetCounter(t_Handle h_BmPool, e_BmPoolCounters counter)
{
t_BmPool *p_BmPool = (t_BmPool *)h_BmPool;
diff --git a/sys/contrib/ncsw/Peripherals/BM/bman_low.c b/sys/contrib/ncsw/Peripherals/BM/bman_low.c
index e3a83c83f2b3..818e62df31c0 100644
--- a/sys/contrib/ncsw/Peripherals/BM/bman_low.c
+++ b/sys/contrib/ncsw/Peripherals/BM/bman_low.c
@@ -38,6 +38,10 @@
@Description BM low-level implementation
*//***************************************************************************/
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <machine/atomic.h>
+
#include "std_ext.h"
#include "core_ext.h"
#include "xx_ext.h"
@@ -259,7 +263,7 @@ void bm_rcr_pci_commit(struct bm_portal *portal, uint8_t myverb)
rcr->cursor->__dont_write_directly__verb = (uint8_t)(myverb | rcr->vbit);
RCR_INC(rcr);
rcr->available--;
- hwsync();
+ mb();
bm_out(RCR_PI_CINH, RCR_PTR2IDX(rcr->cursor));
#ifdef BM_CHECKING
rcr->busy = 0;
@@ -281,7 +285,7 @@ void bm_rcr_pce_commit(struct bm_portal *portal, uint8_t myverb)
rcr->cursor->__dont_write_directly__verb = (uint8_t)(myverb | rcr->vbit);
RCR_INC(rcr);
rcr->available--;
- lwsync();
+ wmb();
bm_cl_out(RCR_PI, RCR_PTR2IDX(rcr->cursor));
#ifdef BM_CHECKING
rcr->busy = 0;
@@ -294,7 +298,7 @@ void bm_rcr_pvb_commit(struct bm_portal *portal, uint8_t myverb)
struct bm_rcr_entry *rcursor;
ASSERT_COND(rcr->busy);
ASSERT_COND(rcr->pmode == e_BmPortalPVB);
- lwsync();
+ rmb();
rcursor = rcr->cursor;
rcursor->__dont_write_directly__verb = (uint8_t)(myverb | rcr->vbit);
dcbf_64(rcursor);
@@ -432,7 +436,7 @@ void bm_mc_commit(struct bm_portal *portal, uint8_t myverb)
{
register struct bm_mc *mc = &portal->mc;
ASSERT_COND(mc->state == mc_user);
- lwsync();
+ rmb();
mc->cr->__dont_write_directly__verb = (uint8_t)(myverb | mc->vbit);
dcbf_64(mc->cr);
dcbit_ro(mc->rr + mc->rridx);
diff --git a/sys/contrib/ncsw/Peripherals/BM/bman_private.h b/sys/contrib/ncsw/Peripherals/BM/bman_private.h
index 2d70428f3778..972c57cecb0a 100644
--- a/sys/contrib/ncsw/Peripherals/BM/bman_private.h
+++ b/sys/contrib/ncsw/Peripherals/BM/bman_private.h
@@ -54,76 +54,13 @@
* and that dcbzl(), dcbfl(), and dcbi() won't fall victim to compiler or
* execution reordering with respect to other code/instructions that manipulate
* the same cacheline. */
-#ifdef CORE_E500MC
-
-#if defined(_DIAB_TOOL)
-#define hwsync() \
-do { \
-__asm__ __volatile__ ("sync"); \
-} while(0)
-
-#define lwsync() \
-do { \
-__asm__ __volatile__ ("lwsync"); \
-} while(0)
-
-__asm__ __volatile__ void dcbf (volatile void * addr)
-{
-%reg addr
- dcbf r0, addr
-}
-
-__asm__ __volatile__ void dcbt_ro (volatile void * addr)
-{
-%reg addr
- dcbt r0, addr
-}
-
-__asm__ __volatile__ void dcbt_rw (volatile void * addr)
-{
-%reg addr
- dcbtst r0, addr
-}
-
-__asm__ __volatile__ void dcbzl (volatile void * addr)
-{
-%reg addr
- dcbzl r0, addr
-}
-
-#define dcbz_64(p) \
- do { \
- dcbzl(p); \
- } while (0)
-
-#define dcbf_64(p) \
- do { \
- dcbf(p); \
- } while (0)
-
-/* Commonly used combo */
-#define dcbit_ro(p) \
- do { \
- dcbi(p); \
- dcbt_ro(p); \
- } while (0)
-
-#else /* GNU C */
-#define hwsync() \
- do { \
- __asm__ __volatile__ ("sync" : : : "memory"); \
- } while(0)
-
-#define lwsync() \
- do { \
- __asm__ __volatile__ ("lwsync" : : : "memory"); \
- } while(0)
#define dcbf(addr) \
do { \
__asm__ __volatile__ ("dcbf 0, %0" : : "r" (addr)); \
} while(0)
+#ifdef CORE_E500MC
#define dcbt_ro(addr) \
do { \
__asm__ __volatile__ ("dcbt 0, %0" : : "r" (addr)); \
@@ -156,46 +93,34 @@ __asm__ __volatile__ void dcbzl (volatile void * addr)
dcbt_ro(p); \
} while (0)
-#endif /* _DIAB_TOOL */
-
#else
-#define hwsync CORE_MemoryBarrier
-#define lwsync hwsync
-#define dcbf(p) \
- do { \
- __asm__ __volatile__ ("dcbf 0,%0" : : "r" (p)); \
- } while(0)
#define dcbt_ro(p) \
do { \
__asm__ __volatile__ ("dcbt 0,%0" : : "r" (p)); \
lwsync(); \
} while(0)
-#define dcbt_rw(p) \
- do { \
- __asm__ __volatile__ ("dcbtst 0,%0" : : "r" (p)); \
- } while(0)
#define dcbz(p) \
do { \
__asm__ __volatile__ ("dcbz 0,%0" : : "r" (p)); \
} while (0)
#define dcbz_64(p) \
do { \
- dcbz((uint32_t)p + 32); \
+ dcbz((char *)p + 32); \
dcbz(p); \
} while (0)
#define dcbf_64(p) \
do { \
- dcbf((uint32_t)p + 32); \
+ dcbf((char *)p + 32); \
dcbf(p); \
} while (0)
/* Commonly used combo */
#define dcbit_ro(p) \
do { \
dcbi(p); \
- dcbi((uint32_t)p + 32); \
+ dcbi((char *)p + 32); \
dcbt_ro(p); \
- dcbt_ro((uint32_t)p + 32); \
+ dcbt_ro((char *)p + 32); \
} while (0)
#endif /* CORE_E500MC */
diff --git a/sys/contrib/ncsw/Peripherals/FM/HC/hc.c b/sys/contrib/ncsw/Peripherals/FM/HC/hc.c
index 134d13b10e3d..278e7c7ae6ed 100644
--- a/sys/contrib/ncsw/Peripherals/FM/HC/hc.c
+++ b/sys/contrib/ncsw/Peripherals/FM/HC/hc.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#include "std_ext.h"
#include "error_ext.h"
#include "sprint_ext.h"
@@ -39,24 +40,54 @@
#include "fm_hc.h"
+/**************************************************************************//**
+ @Description defaults
+*//***************************************************************************/
+#define DEFAULT_dataMemId 0
+
#define HC_HCOR_OPCODE_PLCR_PRFL 0x0
#define HC_HCOR_OPCODE_KG_SCM 0x1
#define HC_HCOR_OPCODE_SYNC 0x2
#define HC_HCOR_OPCODE_CC 0x3
+#define HC_HCOR_OPCODE_CC_AGE_MASK 0x4
#define HC_HCOR_OPCODE_CC_CAPWAP_REASSM_TIMEOUT 0x5
+#define HC_HCOR_OPCODE_CC_REASSM_TIMEOUT 0x10
+#define HC_HCOR_OPCODE_CC_IP_FRAG_INITIALIZATION 0x11
+#define HC_HCOR_OPCODE_CC_UPDATE_WITH_AGING 0x13
+#define HC_HCOR_ACTION_REG_REASSM_TIMEOUT_ACTIVE_SHIFT 24
+#define HC_HCOR_EXTRA_REG_REASSM_TIMEOUT_TSBS_SHIFT 24
+#define HC_HCOR_EXTRA_REG_CC_AGING_ADD 0x80000000
+#define HC_HCOR_EXTRA_REG_CC_AGING_REMOVE 0x40000000
+#define HC_HCOR_EXTRA_REG_CC_AGING_CHANGE_MASK 0xC0000000
+#define HC_HCOR_EXTRA_REG_CC_REMOVE_INDX_SHIFT 24
+#define HC_HCOR_EXTRA_REG_CC_REMOVE_INDX_MASK 0x1F000000
+#define HC_HCOR_ACTION_REG_REASSM_TIMEOUT_RES_SHIFT 16
+#define HC_HCOR_ACTION_REG_REASSM_TIMEOUT_RES_MASK 0xF
+#define HC_HCOR_ACTION_REG_IP_FRAG_SCRATCH_POOL_CMD_SHIFT 24
+#define HC_HCOR_ACTION_REG_IP_FRAG_SCRATCH_POOL_BPID 16
#define HC_HCOR_GBL 0x20000000
-#define SIZE_OF_HC_FRAME_PORT_REGS (sizeof(t_HcFrame)-sizeof(t_FmPcdKgInterModuleSchemeRegs)+sizeof(t_FmPcdKgPortRegs))
+#define HC_HCOR_KG_SCHEME_COUNTER 0x00000400
+
+#if (DPAA_VERSION == 10)
+#define HC_HCOR_KG_SCHEME_REGS_MASK 0xFFFFF800
+#else
+#define HC_HCOR_KG_SCHEME_REGS_MASK 0xFFFFFE00
+#endif /* (DPAA_VERSION == 10) */
+
+#define SIZE_OF_HC_FRAME_PORT_REGS (sizeof(t_HcFrame)-sizeof(struct fman_kg_scheme_regs)+sizeof(t_FmPcdKgPortRegs))
#define SIZE_OF_HC_FRAME_SCHEME_REGS sizeof(t_HcFrame)
-#define SIZE_OF_HC_FRAME_PROFILES_REGS (sizeof(t_HcFrame)-sizeof(t_FmPcdKgInterModuleSchemeRegs)+sizeof(t_FmPcdPlcrInterModuleProfileRegs))
-#define SIZE_OF_HC_FRAME_PROFILE_CNT (sizeof(t_HcFrame)-sizeof(t_FmPcdPlcrInterModuleProfileRegs)+sizeof(uint32_t))
+#define SIZE_OF_HC_FRAME_PROFILES_REGS (sizeof(t_HcFrame)-sizeof(struct fman_kg_scheme_regs)+sizeof(t_FmPcdPlcrProfileRegs))
+#define SIZE_OF_HC_FRAME_PROFILE_CNT (sizeof(t_HcFrame)-sizeof(t_FmPcdPlcrProfileRegs)+sizeof(uint32_t))
#define SIZE_OF_HC_FRAME_READ_OR_CC_DYNAMIC 16
+#define HC_CMD_POOL_SIZE (INTG_MAX_NUM_OF_CORES)
+
#define BUILD_FD(len) \
do { \
memset(&fmFd, 0, sizeof(t_DpaaFD)); \
- DPAA_FD_SET_ADDR(&fmFd, p_HcFrame); \
+ DPAA_FD_SET_ADDR(&fmFd, p_HcFrame); \
DPAA_FD_SET_OFFSET(&fmFd, 0); \
DPAA_FD_SET_LENGTH(&fmFd, len); \
} while (0)
@@ -65,50 +96,29 @@ do { \
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(push,1)
#endif /* defined(__MWERKS__) && ... */
-#define MEM_MAP_START
-/**************************************************************************//**
- @Description PCD KG scheme registers
-*//***************************************************************************/
-typedef _Packed struct t_FmPcdKgSchemeRegsWithoutCounter {
- volatile uint32_t kgse_mode; /**< MODE */
- volatile uint32_t kgse_ekfc; /**< Extract Known Fields Command */
- volatile uint32_t kgse_ekdv; /**< Extract Known Default Value */
- volatile uint32_t kgse_bmch; /**< Bit Mask Command High */
- volatile uint32_t kgse_bmcl; /**< Bit Mask Command Low */
- volatile uint32_t kgse_fqb; /**< Frame Queue Base */
- volatile uint32_t kgse_hc; /**< Hash Command */
- volatile uint32_t kgse_ppc; /**< Policer Profile Command */
- volatile uint32_t kgse_gec[FM_PCD_KG_NUM_OF_GENERIC_REGS];
- /**< Generic Extract Command */
- volatile uint32_t kgse_dv0; /**< KeyGen Scheme Entry Default Value 0 */
- volatile uint32_t kgse_dv1; /**< KeyGen Scheme Entry Default Value 1 */
- volatile uint32_t kgse_ccbs; /**< KeyGen Scheme Entry Coarse Classification Bit*/
- volatile uint32_t kgse_mv; /**< KeyGen Scheme Entry Match vector */
-} _PackedType t_FmPcdKgSchemeRegsWithoutCounter;
-
-typedef _Packed struct t_FmPcdKgPortRegs {
+typedef struct t_FmPcdKgPortRegs {
volatile uint32_t spReg;
volatile uint32_t cppReg;
-} _PackedType t_FmPcdKgPortRegs;
+} t_FmPcdKgPortRegs;
-typedef _Packed struct t_HcFrame {
+typedef struct t_HcFrame {
volatile uint32_t opcode;
volatile uint32_t actionReg;
volatile uint32_t extraReg;
volatile uint32_t commandSequence;
union {
- t_FmPcdKgInterModuleSchemeRegs schemeRegs;
- t_FmPcdKgInterModuleSchemeRegs schemeRegsWithoutCounter;
- t_FmPcdPlcrInterModuleProfileRegs profileRegs;
+ struct fman_kg_scheme_regs schemeRegs;
+ struct fman_kg_scheme_regs schemeRegsWithoutCounter;
+ t_FmPcdPlcrProfileRegs profileRegs;
volatile uint32_t singleRegForWrite; /* for writing SP, CPP, profile counter */
t_FmPcdKgPortRegs portRegsForRead;
volatile uint32_t clsPlanEntries[CLS_PLAN_NUM_PER_GRP];
t_FmPcdCcCapwapReassmTimeoutParams ccCapwapReassmTimeout;
+ t_FmPcdCcReassmTimeoutParams ccReassmTimeout;
} hcSpecificData;
-} _PackedType t_HcFrame;
+} t_HcFrame;
-#define MEM_MAP_END
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(pop)
#endif /* defined(__MWERKS__) && ... */
@@ -119,114 +129,108 @@ typedef struct t_FmHc {
t_Handle h_HcPortDev;
t_FmPcdQmEnqueueCallback *f_QmEnqueue; /**< A callback for enqueuing frames to the QM */
t_Handle h_QmArg; /**< A handle to the QM module */
- uint8_t padTill16;
-
- uint32_t seqNum;
- volatile bool wait[32];
+ uint8_t dataMemId; /**< Memory partition ID for data buffers */
+
+ uint32_t seqNum[HC_CMD_POOL_SIZE]; /* FIFO of seqNum to use when
+ taking buffer */
+ uint32_t nextSeqNumLocation; /* seqNum location in seqNum[] for next buffer */
+ volatile bool enqueued[HC_CMD_POOL_SIZE]; /* HC is active - frame is enqueued
+ and not confirmed yet */
+ t_HcFrame *p_Frm[HC_CMD_POOL_SIZE];
} t_FmHc;
-static __inline__ t_Error EnQFrm(t_FmHc *p_FmHc, t_DpaaFD *p_FmFd, volatile uint32_t *p_SeqNum)
+static t_Error FillBufPool(t_FmHc *p_FmHc)
{
- t_Error err = E_OK;
- uint32_t savedSeqNum;
- uint32_t intFlags;
- uint32_t timeout=100;
+ uint32_t i;
- intFlags = FmPcdLock(p_FmHc->h_FmPcd);
- *p_SeqNum = p_FmHc->seqNum;
- savedSeqNum = p_FmHc->seqNum;
- p_FmHc->seqNum = (uint32_t)((p_FmHc->seqNum+1)%32);
- ASSERT_COND(!p_FmHc->wait[savedSeqNum]);
- p_FmHc->wait[savedSeqNum] = TRUE;
- FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
- DBG(TRACE, ("Send Hc, SeqNum %d, FD@0x%x, fd offset 0x%x",
- savedSeqNum,DPAA_FD_GET_ADDR(p_FmFd),DPAA_FD_GET_OFFSET(p_FmFd)));
- err = p_FmHc->f_QmEnqueue(p_FmHc->h_QmArg, (void *)p_FmFd);
- if(err)
- RETURN_ERROR(MINOR, err, ("HC enqueue failed"));
+ ASSERT_COND(p_FmHc);
- while (p_FmHc->wait[savedSeqNum] && --timeout)
- XX_UDelay(100);
+ for (i = 0; i < HC_CMD_POOL_SIZE; i++)
+ {
+#ifdef FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004
+ p_FmHc->p_Frm[i] = (t_HcFrame *)XX_MallocSmart((sizeof(t_HcFrame) + (16 - (sizeof(t_FmHc) % 16))),
+ p_FmHc->dataMemId,
+ 16);
+#else
+ p_FmHc->p_Frm[i] = (t_HcFrame *)XX_MallocSmart(sizeof(t_HcFrame),
+ p_FmHc->dataMemId,
+ 16);
+#endif /* FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004 */
+ if (!p_FmHc->p_Frm[i])
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("FM HC frames!"));
+ }
- if (!timeout)
- RETURN_ERROR(MINOR, E_TIMEOUT, ("HC Callback, timeout exceeded"));
+ /* Initialize FIFO of seqNum to use during GetBuf */
+ for (i = 0; i < HC_CMD_POOL_SIZE; i++)
+ {
+ p_FmHc->seqNum[i] = i;
+ }
+ p_FmHc->nextSeqNumLocation = 0;
- return err;
+ return E_OK;
}
-static t_Error CcHcDoDynamicChange(t_FmHc *p_FmHc, t_Handle p_OldPointer, t_Handle p_NewPointer)
+static __inline__ t_HcFrame * GetBuf(t_FmHc *p_FmHc, uint32_t *p_SeqNum)
{
- t_HcFrame *p_HcFrame;
- t_DpaaFD fmFd;
- t_Error err = E_OK;
+ uint32_t intFlags;
ASSERT_COND(p_FmHc);
- p_HcFrame = (t_HcFrame *)XX_MallocSmart((sizeof(t_HcFrame) + p_FmHc->padTill16), 0, 16);
- if (!p_HcFrame)
- RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame obj"));
+ intFlags = FmPcdLock(p_FmHc->h_FmPcd);
- memset(p_HcFrame, 0, sizeof(t_HcFrame));
- p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_CC);
- p_HcFrame->actionReg = FmPcdCcGetNodeAddrOffsetFromNodeInfo(p_FmHc->h_FmPcd, p_NewPointer);
- if(p_HcFrame->actionReg == (uint32_t)ILLEGAL_BASE)
+ if (p_FmHc->nextSeqNumLocation == HC_CMD_POOL_SIZE)
{
- XX_FreeSmart(p_HcFrame);
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Something wrong with base address"));
+ /* No more buffers */
+ FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
+ return NULL;
}
- p_HcFrame->actionReg |= 0xc0000000;
- p_HcFrame->extraReg = FmPcdCcGetNodeAddrOffsetFromNodeInfo(p_FmHc->h_FmPcd, p_OldPointer);
- if(p_HcFrame->extraReg == (uint32_t)ILLEGAL_BASE)
- {
- XX_FreeSmart(p_HcFrame);
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Something wrong with base address"));
- }
+ *p_SeqNum = p_FmHc->seqNum[p_FmHc->nextSeqNumLocation];
+ p_FmHc->nextSeqNumLocation++;
- BUILD_FD(SIZE_OF_HC_FRAME_READ_OR_CC_DYNAMIC);
+ FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
+ return p_FmHc->p_Frm[*p_SeqNum];
+}
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
- {
- XX_FreeSmart(p_HcFrame);
- RETURN_ERROR(MINOR, err, NO_MSG);
- }
+static __inline__ void PutBuf(t_FmHc *p_FmHc, t_HcFrame *p_Buf, uint32_t seqNum)
+{
+ uint32_t intFlags;
- XX_FreeSmart(p_HcFrame);
+ UNUSED(p_Buf);
- return E_OK;
+ intFlags = FmPcdLock(p_FmHc->h_FmPcd);
+ ASSERT_COND(p_FmHc->nextSeqNumLocation);
+ p_FmHc->nextSeqNumLocation--;
+ p_FmHc->seqNum[p_FmHc->nextSeqNumLocation] = seqNum;
+ FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
}
-static t_Error HcDynamicChange(t_FmHc *p_FmHc,t_List *h_OldPointersLst, t_List *h_NewPointersLst, t_Handle *h_Params)
+static __inline__ t_Error EnQFrm(t_FmHc *p_FmHc, t_DpaaFD *p_FmFd, uint32_t seqNum)
{
-
- t_List *p_PosOld, *p_PosNew;
- uint16_t i = 0;
t_Error err = E_OK;
- uint8_t numOfModifiedPtr;
+ uint32_t intFlags;
+ uint32_t timeout=100;
- SANITY_CHECK_RETURN_ERROR((LIST_NumOfObjs(h_NewPointersLst) == LIST_NumOfObjs(h_OldPointersLst)),E_INVALID_STATE);
+ intFlags = FmPcdLock(p_FmHc->h_FmPcd);
+ ASSERT_COND(!p_FmHc->enqueued[seqNum]);
+ p_FmHc->enqueued[seqNum] = TRUE;
+ FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
+ DBG(TRACE, ("Send Hc, SeqNum %d, buff@0x%x, fd offset 0x%x",
+ seqNum,
+ DPAA_FD_GET_ADDR(p_FmFd),
+ DPAA_FD_GET_OFFSET(p_FmFd)));
+ err = p_FmHc->f_QmEnqueue(p_FmHc->h_QmArg, (void *)p_FmFd);
+ if (err)
+ RETURN_ERROR(MINOR, err, ("HC enqueue failed"));
- numOfModifiedPtr = (uint8_t)LIST_NumOfObjs(h_NewPointersLst);
- p_PosNew = NCSW_LIST_FIRST(h_NewPointersLst);
- p_PosOld = NCSW_LIST_FIRST(h_OldPointersLst);
- for(i = 0; i < numOfModifiedPtr; i++)
- {
- err = CcHcDoDynamicChange(p_FmHc, p_PosOld, p_PosNew);
- if(err)
- {
- FmPcdCcReleaseModifiedDataStructure(p_FmHc->h_FmPcd, h_OldPointersLst, h_NewPointersLst, i, h_Params);
- RETURN_ERROR(MAJOR, err, ("For part of nodes changes are done - situation is danger"));
- }
- p_PosNew = NCSW_LIST_NEXT(p_PosNew);
- p_PosOld = NCSW_LIST_NEXT(p_PosOld);
- }
+ while (p_FmHc->enqueued[seqNum] && --timeout)
+ XX_UDelay(100);
- err = FmPcdCcReleaseModifiedDataStructure(p_FmHc->h_FmPcd, h_OldPointersLst, h_NewPointersLst, i, h_Params);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
+ if (!timeout)
+ RETURN_ERROR(MINOR, E_TIMEOUT, ("HC Callback, timeout exceeded"));
- return E_OK;
+ return err;
}
@@ -234,7 +238,7 @@ t_Handle FmHcConfigAndInit(t_FmHcParams *p_FmHcParams)
{
t_FmHc *p_FmHc;
t_FmPortParams fmPortParam;
- t_Error err = E_OK;
+ t_Error err;
p_FmHc = (t_FmHc *)XX_Malloc(sizeof(t_FmHc));
if (!p_FmHc)
@@ -247,17 +251,19 @@ t_Handle FmHcConfigAndInit(t_FmHcParams *p_FmHcParams)
p_FmHc->h_FmPcd = p_FmHcParams->h_FmPcd;
p_FmHc->f_QmEnqueue = p_FmHcParams->params.f_QmEnqueue;
p_FmHc->h_QmArg = p_FmHcParams->params.h_QmArg;
+ p_FmHc->dataMemId = DEFAULT_dataMemId;
+
+ err = FillBufPool(p_FmHc);
+ if (err != E_OK)
+ {
+ REPORT_ERROR(MAJOR, err, NO_MSG);
+ FmHcFree(p_FmHc);
+ return NULL;
+ }
if (!FmIsMaster(p_FmHcParams->h_Fm))
return (t_Handle)p_FmHc;
-/*
-TKT056919 - axi12axi0 can hang if read request follows the single byte write on the very next cycle
-TKT038900 - FM dma lockup occur due to AXI slave protocol violation
-*/
-#ifdef FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004
- p_FmHc->padTill16 = 16 - (sizeof(t_FmHc) % 16);
-#endif /* FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004 */
memset(&fmPortParam, 0, sizeof(fmPortParam));
fmPortParam.baseAddr = p_FmHcParams->params.portBaseAddr;
fmPortParam.portType = e_FM_PORT_TYPE_OH_HOST_COMMAND;
@@ -270,24 +276,36 @@ TKT038900 - FM dma lockup occur due to AXI slave protocol violation
fmPortParam.specificParams.nonRxParams.qmChannel = p_FmHcParams->params.qmChannel;
p_FmHc->h_HcPortDev = FM_PORT_Config(&fmPortParam);
- if(!p_FmHc->h_HcPortDev)
+ if (!p_FmHc->h_HcPortDev)
{
REPORT_ERROR(MAJOR, E_INVALID_HANDLE, ("FM HC port!"));
XX_Free(p_FmHc);
return NULL;
}
+ err = FM_PORT_ConfigMaxFrameLength(p_FmHc->h_HcPortDev,
+ (uint16_t)sizeof(t_HcFrame));
+
+ if (err != E_OK)
+ {
+ REPORT_ERROR(MAJOR, err, ("FM HC port init!"));
+ FmHcFree(p_FmHc);
+ return NULL;
+ }
+
/* final init */
- if ((err = FM_PORT_Init(p_FmHc->h_HcPortDev)) != E_OK)
+ err = FM_PORT_Init(p_FmHc->h_HcPortDev);
+ if (err != E_OK)
{
- REPORT_ERROR(MAJOR, err, ("FM HC port!"));
+ REPORT_ERROR(MAJOR, err, ("FM HC port init!"));
FmHcFree(p_FmHc);
return NULL;
}
- if ((err = FM_PORT_Enable(p_FmHc->h_HcPortDev)) != E_OK)
+ err = FM_PORT_Enable(p_FmHc->h_HcPortDev);
+ if (err != E_OK)
{
- REPORT_ERROR(MAJOR, err, ("FM HC port!"));
+ REPORT_ERROR(MAJOR, err, ("FM HC port enable!"));
FmHcFree(p_FmHc);
return NULL;
}
@@ -298,28 +316,40 @@ TKT038900 - FM dma lockup occur due to AXI slave protocol violation
void FmHcFree(t_Handle h_FmHc)
{
t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
+ int i;
if (!p_FmHc)
return;
+ for (i=0; i<HC_CMD_POOL_SIZE; i++)
+ if (p_FmHc->p_Frm[i])
+ XX_FreeSmart(p_FmHc->p_Frm[i]);
+ else
+ break;
+
if (p_FmHc->h_HcPortDev)
FM_PORT_Free(p_FmHc->h_HcPortDev);
XX_Free(p_FmHc);
}
-#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
-t_Error FmHcDumpRegs(t_Handle h_FmHc)
+/*****************************************************************************/
+t_Error FmHcSetFramesDataMemory(t_Handle h_FmHc,
+ uint8_t memId)
{
t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
+ int i;
SANITY_CHECK_RETURN_ERROR(p_FmHc, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmHc->h_HcPortDev, E_INVALID_HANDLE);
- return FM_PORT_DumpRegs(p_FmHc->h_HcPortDev);
+ p_FmHc->dataMemId = memId;
+
+ for (i=0; i<HC_CMD_POOL_SIZE; i++)
+ if (p_FmHc->p_Frm[i])
+ XX_FreeSmart(p_FmHc->p_Frm[i]);
+ return FillBufPool(p_FmHc);
}
-#endif /* (defined(DEBUG_ERRORS) && ... */
void FmHcTxConf(t_Handle h_FmHc, t_DpaaFD *p_Fd)
{
@@ -335,134 +365,55 @@ void FmHcTxConf(t_Handle h_FmHc, t_DpaaFD *p_Fd)
DBG(TRACE, ("Hc Conf, SeqNum %d, FD@0x%x, fd offset 0x%x",
p_HcFrame->commandSequence, DPAA_FD_GET_ADDR(p_Fd), DPAA_FD_GET_OFFSET(p_Fd)));
- if (!(p_FmHc->wait[p_HcFrame->commandSequence]))
+ if (!(p_FmHc->enqueued[p_HcFrame->commandSequence]))
REPORT_ERROR(MINOR, E_INVALID_FRAME, ("Not an Host-Command frame received!"));
else
- p_FmHc->wait[p_HcFrame->commandSequence] = FALSE;
+ p_FmHc->enqueued[p_HcFrame->commandSequence] = FALSE;
FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
}
-t_Handle FmHcPcdKgSetScheme(t_Handle h_FmHc, t_FmPcdKgSchemeParams *p_Scheme)
+t_Error FmHcPcdKgSetScheme(t_Handle h_FmHc,
+ t_Handle h_Scheme,
+ struct fman_kg_scheme_regs *p_SchemeRegs,
+ bool updateCounter)
{
t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
t_Error err = E_OK;
- t_FmPcdKgInterModuleSchemeRegs schemeRegs;
t_HcFrame *p_HcFrame;
t_DpaaFD fmFd;
- uint32_t intFlags;
- uint8_t physicalSchemeId, relativeSchemeId;
+ uint8_t physicalSchemeId;
+ uint32_t seqNum;
- p_HcFrame = (t_HcFrame *)XX_MallocSmart((sizeof(t_HcFrame) + p_FmHc->padTill16), 0, 16);
+ p_HcFrame = GetBuf(p_FmHc, &seqNum);
if (!p_HcFrame)
- {
- REPORT_ERROR(MINOR, E_NO_MEMORY, ("HC Frame obj"));
- return NULL;
- }
-
- if(!p_Scheme->modify)
- {
- /* check that schemeId is in range */
- if(p_Scheme->id.relativeSchemeId >= FmPcdKgGetNumOfPartitionSchemes(p_FmHc->h_FmPcd))
- {
- REPORT_ERROR(MAJOR, E_NOT_IN_RANGE, ("Scheme is out of range"));
- XX_FreeSmart(p_HcFrame);
- return NULL;
- }
-
- relativeSchemeId = p_Scheme->id.relativeSchemeId;
-
- if (FmPcdKgSchemeTryLock(p_FmHc->h_FmPcd, relativeSchemeId, FALSE))
- {
- XX_FreeSmart(p_HcFrame);
- return NULL;
- }
-
- physicalSchemeId = FmPcdKgGetPhysicalSchemeId(p_FmHc->h_FmPcd, relativeSchemeId);
-
- memset(p_HcFrame, 0, sizeof(t_HcFrame));
- p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
- p_HcFrame->actionReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
- p_HcFrame->extraReg = 0xFFFFF800;
-
- BUILD_FD(SIZE_OF_HC_FRAME_READ_OR_CC_DYNAMIC);
-
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
- {
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
- REPORT_ERROR(MINOR, err, NO_MSG);
- XX_FreeSmart(p_HcFrame);
- return NULL;
- }
-
- /* check if this scheme is already used */
- if (FmPcdKgHwSchemeIsValid(p_HcFrame->hcSpecificData.schemeRegs.kgse_mode))
- {
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
- REPORT_ERROR(MAJOR, E_ALREADY_EXISTS, ("Scheme is already used"));
- XX_FreeSmart(p_HcFrame);
- return NULL;
- }
- }
- else
- {
- intFlags = FmPcdLock(p_FmHc->h_FmPcd);
- physicalSchemeId = (uint8_t)(PTR_TO_UINT(p_Scheme->id.h_Scheme)-1);
- relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmHc->h_FmPcd, physicalSchemeId);
- if( relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)
- {
- FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
- REPORT_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
- XX_FreeSmart(p_HcFrame);
- return NULL;
- }
- err = FmPcdKgSchemeTryLock(p_FmHc->h_FmPcd, relativeSchemeId, TRUE);
- FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
- if (err)
- {
- XX_FreeSmart(p_HcFrame);
- return NULL;
- }
- }
+ RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
- err = FmPcdKgBuildScheme(p_FmHc->h_FmPcd, p_Scheme, &schemeRegs);
- if(err)
- {
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
- REPORT_ERROR(MAJOR, err, NO_MSG);
- XX_FreeSmart(p_HcFrame);
- return NULL;
- }
+ physicalSchemeId = FmPcdKgGetSchemeId(h_Scheme);
memset(p_HcFrame, 0, sizeof(t_HcFrame));
p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
- p_HcFrame->actionReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, p_Scheme->schemeCounter.update);
- p_HcFrame->extraReg = 0xFFFFF800;
- memcpy(&p_HcFrame->hcSpecificData.schemeRegs, &schemeRegs, sizeof(t_FmPcdKgInterModuleSchemeRegs));
- if(!p_Scheme->schemeCounter.update)
+ p_HcFrame->actionReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, updateCounter);
+ p_HcFrame->extraReg = HC_HCOR_KG_SCHEME_REGS_MASK;
+ memcpy(&p_HcFrame->hcSpecificData.schemeRegs, p_SchemeRegs, sizeof(struct fman_kg_scheme_regs));
+ if (!updateCounter)
{
- p_HcFrame->hcSpecificData.schemeRegs.kgse_dv0 = schemeRegs.kgse_dv0;
- p_HcFrame->hcSpecificData.schemeRegs.kgse_dv1 = schemeRegs.kgse_dv1;
- p_HcFrame->hcSpecificData.schemeRegs.kgse_ccbs = schemeRegs.kgse_ccbs;
- p_HcFrame->hcSpecificData.schemeRegs.kgse_mv = schemeRegs.kgse_mv;
+ p_HcFrame->hcSpecificData.schemeRegs.kgse_dv0 = p_SchemeRegs->kgse_dv0;
+ p_HcFrame->hcSpecificData.schemeRegs.kgse_dv1 = p_SchemeRegs->kgse_dv1;
+ p_HcFrame->hcSpecificData.schemeRegs.kgse_ccbs = p_SchemeRegs->kgse_ccbs;
+ p_HcFrame->hcSpecificData.schemeRegs.kgse_mv = p_SchemeRegs->kgse_mv;
}
+ p_HcFrame->commandSequence = seqNum;
BUILD_FD(sizeof(t_HcFrame));
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
- {
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
- REPORT_ERROR(MINOR, err, NO_MSG);
- XX_FreeSmart(p_HcFrame);
- return NULL;
- }
-
- FmPcdKgValidateSchemeSw(p_FmHc->h_FmPcd, relativeSchemeId);
+ err = EnQFrm(p_FmHc, &fmFd, seqNum);
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
- XX_FreeSmart(p_HcFrame);
+ if (err != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
- return (t_Handle)(UINT_TO_PTR(physicalSchemeId + 1));
+ return E_OK;
}
t_Error FmHcPcdKgDeleteScheme(t_Handle h_FmHc, t_Handle h_Scheme)
@@ -471,212 +422,181 @@ t_Error FmHcPcdKgDeleteScheme(t_Handle h_FmHc, t_Handle h_Scheme)
t_Error err = E_OK;
t_HcFrame *p_HcFrame;
t_DpaaFD fmFd;
- uint8_t relativeSchemeId;
- uint8_t physicalSchemeId = (uint8_t)(PTR_TO_UINT(h_Scheme)-1);
+ uint8_t physicalSchemeId = FmPcdKgGetSchemeId(h_Scheme);
+ uint32_t seqNum;
- relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmHc->h_FmPcd, physicalSchemeId);
-
- if ((err = FmPcdKgSchemeTryLock(p_FmHc->h_FmPcd, relativeSchemeId, FALSE)) != E_OK)
- RETURN_ERROR(MAJOR, err, NO_MSG);
-
- if(relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)
- {
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
- RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
- }
-
- err = FmPcdKgCheckInvalidateSchemeSw(p_FmHc->h_FmPcd, relativeSchemeId);
- if (err)
- {
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
- RETURN_ERROR(MAJOR, err, NO_MSG);
- }
-
- p_HcFrame = (t_HcFrame *)XX_MallocSmart((sizeof(t_HcFrame) + p_FmHc->padTill16), 0, 16);
+ p_HcFrame = GetBuf(p_FmHc, &seqNum);
if (!p_HcFrame)
- {
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
- RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame obj"));
- }
+ RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
+
memset(p_HcFrame, 0, sizeof(t_HcFrame));
p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
p_HcFrame->actionReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, TRUE);
- p_HcFrame->extraReg = 0xFFFFF800;
- memset(&p_HcFrame->hcSpecificData.schemeRegs, 0, sizeof(t_FmPcdKgInterModuleSchemeRegs));
+ p_HcFrame->extraReg = HC_HCOR_KG_SCHEME_REGS_MASK;
+ memset(&p_HcFrame->hcSpecificData.schemeRegs, 0, sizeof(struct fman_kg_scheme_regs));
+ p_HcFrame->commandSequence = seqNum;
BUILD_FD(sizeof(t_HcFrame));
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
- {
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
- XX_FreeSmart(p_HcFrame);
- RETURN_ERROR(MINOR, err, NO_MSG);
- }
-
- FmPcdKgInvalidateSchemeSw(p_FmHc->h_FmPcd, relativeSchemeId);
+ err = EnQFrm(p_FmHc, &fmFd, seqNum);
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
- XX_FreeSmart(p_HcFrame);
+ if (err != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
return E_OK;
}
-t_Error FmHcPcdKgCcGetSetParams(t_Handle h_FmHc, t_Handle h_Scheme, uint32_t requiredAction)
+t_Error FmHcPcdKgCcGetSetParams(t_Handle h_FmHc, t_Handle h_Scheme, uint32_t requiredAction, uint32_t value)
{
t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
t_Error err = E_OK;
t_HcFrame *p_HcFrame;
t_DpaaFD fmFd;
uint8_t relativeSchemeId;
- uint8_t physicalSchemeId = (uint8_t)(PTR_TO_UINT(h_Scheme)-1);
+ uint8_t physicalSchemeId = FmPcdKgGetSchemeId(h_Scheme);
uint32_t tmpReg32 = 0;
+ uint32_t seqNum;
+
+ /* Scheme is locked by calling routine */
+ /* WARNING - this lock will not be efficient if other HC routine will attempt to change
+ * "kgse_mode" or "kgse_om" without locking scheme !
+ */
relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmHc->h_FmPcd, physicalSchemeId);
- if( relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)
+ if ( relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)
RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
- if (FmPcdKgSchemeTryLock(p_FmHc->h_FmPcd, relativeSchemeId, FALSE))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Lock of the scheme FAILED"));
-
- if(!FmPcdKgGetPointedOwners(p_FmHc->h_FmPcd, relativeSchemeId) ||
+ if (!FmPcdKgGetRequiredActionFlag(p_FmHc->h_FmPcd, relativeSchemeId) ||
!(FmPcdKgGetRequiredAction(p_FmHc->h_FmPcd, relativeSchemeId) & requiredAction))
{
-
- if(requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)
+ if ((requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA) &&
+ (FmPcdKgGetNextEngine(p_FmHc->h_FmPcd, relativeSchemeId) == e_FM_PCD_PLCR))
+ {
+ if ((FmPcdKgIsDirectPlcr(p_FmHc->h_FmPcd, relativeSchemeId) == FALSE) ||
+ (FmPcdKgIsDistrOnPlcrProfile(p_FmHc->h_FmPcd, relativeSchemeId) == TRUE))
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("In this situation PP can not be with distribution and has to be shared"));
+ err = FmPcdPlcrCcGetSetParams(p_FmHc->h_FmPcd, FmPcdKgGetRelativeProfileId(p_FmHc->h_FmPcd, relativeSchemeId), requiredAction);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+ else /* From here we deal with KG-Schemes only */
{
- if((FmPcdKgGetNextEngine(p_FmHc->h_FmPcd, relativeSchemeId) == e_FM_PCD_DONE) && (FmPcdKgGetDoneAction(p_FmHc->h_FmPcd, relativeSchemeId) == e_FM_PCD_ENQ_FRAME))
+ /* Pre change general code */
+ p_HcFrame = GetBuf(p_FmHc, &seqNum);
+ if (!p_HcFrame)
+ RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
+ memset(p_HcFrame, 0, sizeof(t_HcFrame));
+ p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
+ p_HcFrame->actionReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
+ p_HcFrame->extraReg = HC_HCOR_KG_SCHEME_REGS_MASK;
+ p_HcFrame->commandSequence = seqNum;
+ BUILD_FD(SIZE_OF_HC_FRAME_READ_OR_CC_DYNAMIC);
+ if ((err = EnQFrm(p_FmHc, &fmFd, seqNum)) != E_OK)
+ {
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
+ RETURN_ERROR(MINOR, err, NO_MSG);
+ }
+ /* specific change */
+ if ((requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA) &&
+ ((FmPcdKgGetNextEngine(p_FmHc->h_FmPcd, relativeSchemeId) == e_FM_PCD_DONE) &&
+ (FmPcdKgGetDoneAction(p_FmHc->h_FmPcd, relativeSchemeId) == e_FM_PCD_ENQ_FRAME)))
{
- p_HcFrame = (t_HcFrame *)XX_MallocSmart((sizeof(t_HcFrame) + p_FmHc->padTill16), 0, 16);
- if (!p_HcFrame)
- {
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
- RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame obj"));
- }
- memset(p_HcFrame, 0, sizeof(t_HcFrame));
- p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
- p_HcFrame->actionReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
- p_HcFrame->extraReg = 0xFFFFF800;
- BUILD_FD(SIZE_OF_HC_FRAME_READ_OR_CC_DYNAMIC);
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
- {
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
- XX_FreeSmart(p_HcFrame);
- RETURN_ERROR(MINOR, err, NO_MSG);
- }
-
- /* check if this scheme is already used */
- if (!FmPcdKgHwSchemeIsValid(p_HcFrame->hcSpecificData.schemeRegs.kgse_mode))
- {
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
- XX_FreeSmart(p_HcFrame);
- RETURN_ERROR(MAJOR, E_ALREADY_EXISTS, ("Scheme is already used"));
- }
tmpReg32 = p_HcFrame->hcSpecificData.schemeRegs.kgse_mode;
-
ASSERT_COND(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME));
-
p_HcFrame->hcSpecificData.schemeRegs.kgse_mode = tmpReg32 | NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
+ }
- p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
- p_HcFrame->actionReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, FALSE);
- p_HcFrame->extraReg = 0x80000000;
-
- BUILD_FD(sizeof(t_HcFrame));
+ if ((requiredAction & UPDATE_KG_NIA_CC_WA) &&
+ (FmPcdKgGetNextEngine(p_FmHc->h_FmPcd, relativeSchemeId) == e_FM_PCD_CC))
+ {
+ tmpReg32 = p_HcFrame->hcSpecificData.schemeRegs.kgse_mode;
+ ASSERT_COND(tmpReg32 & (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_CC));
+ tmpReg32 &= ~NIA_FM_CTL_AC_CC;
+ p_HcFrame->hcSpecificData.schemeRegs.kgse_mode = tmpReg32 | NIA_FM_CTL_AC_PRE_CC;
+ }
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
- {
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
- XX_FreeSmart(p_HcFrame);
- RETURN_ERROR(MINOR, err, NO_MSG);
- }
+ if (requiredAction & UPDATE_KG_OPT_MODE)
+ p_HcFrame->hcSpecificData.schemeRegs.kgse_om = value;
- XX_FreeSmart(p_HcFrame);
- }
- else if (FmPcdKgGetNextEngine(p_FmHc->h_FmPcd, relativeSchemeId) == e_FM_PCD_PLCR)
+ if (requiredAction & UPDATE_KG_NIA)
{
+ tmpReg32 = p_HcFrame->hcSpecificData.schemeRegs.kgse_mode;
+ tmpReg32 &= ~(NIA_ENG_MASK | NIA_AC_MASK);
+ tmpReg32 |= value;
+ p_HcFrame->hcSpecificData.schemeRegs.kgse_mode = tmpReg32;
+ }
- if((FmPcdKgIsDirectPlcr(p_FmHc->h_FmPcd, relativeSchemeId) == FALSE) ||
- (FmPcdKgIsDistrOnPlcrProfile(p_FmHc->h_FmPcd, relativeSchemeId) == TRUE))
- {
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("In this situation PP can not be with distribution and has to be shared"));
- }
- err = FmPcdPlcrCcGetSetParams(p_FmHc->h_FmPcd, FmPcdKgGetRelativeProfileId(p_FmHc->h_FmPcd, relativeSchemeId), requiredAction);
- if(err)
- {
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
- RETURN_ERROR(MAJOR, err, NO_MSG);
- }
+ /* Post change general code */
+ p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
+ p_HcFrame->actionReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, FALSE);
+ p_HcFrame->extraReg = HC_HCOR_KG_SCHEME_REGS_MASK;
+
+ BUILD_FD(sizeof(t_HcFrame));
+ err = EnQFrm(p_FmHc, &fmFd, seqNum);
+
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
+
+ if (err != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
}
- }
}
- FmPcdKgUpatePointedOwner(p_FmHc->h_FmPcd, relativeSchemeId,TRUE);
- FmPcdKgUpdateRequiredAction(p_FmHc->h_FmPcd, relativeSchemeId,requiredAction);
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
-
return E_OK;
}
uint32_t FmHcPcdKgGetSchemeCounter(t_Handle h_FmHc, t_Handle h_Scheme)
{
t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
- t_Error err = E_OK;
+ t_Error err;
t_HcFrame *p_HcFrame;
t_DpaaFD fmFd;
uint32_t retVal;
uint8_t relativeSchemeId;
- uint8_t physicalSchemeId = (uint8_t)(PTR_TO_UINT(h_Scheme)-1);
+ uint8_t physicalSchemeId = FmPcdKgGetSchemeId(h_Scheme);
+ uint32_t seqNum;
relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmHc->h_FmPcd, physicalSchemeId);
- if( relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)
+ if ( relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)
{
REPORT_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
return 0;
}
- if ((err = FmPcdKgSchemeTryLock(p_FmHc->h_FmPcd, relativeSchemeId, FALSE)) != E_OK)
- {
- REPORT_ERROR(MAJOR, err, ("Scheme lock"));
- return 0;
- }
-
/* first read scheme and check that it is valid */
- p_HcFrame = (t_HcFrame *)XX_MallocSmart((sizeof(t_HcFrame) + p_FmHc->padTill16), 0, 16);
+ p_HcFrame = GetBuf(p_FmHc, &seqNum);
if (!p_HcFrame)
{
- REPORT_ERROR(MINOR, E_NO_MEMORY, ("HC Frame obj"));
+ REPORT_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
return 0;
}
memset(p_HcFrame, 0, sizeof(t_HcFrame));
p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
p_HcFrame->actionReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
- p_HcFrame->extraReg = 0xFFFFF800;
+ p_HcFrame->extraReg = HC_HCOR_KG_SCHEME_REGS_MASK;
+ p_HcFrame->commandSequence = seqNum;
BUILD_FD(SIZE_OF_HC_FRAME_READ_OR_CC_DYNAMIC);
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
+ err = EnQFrm(p_FmHc, &fmFd, seqNum);
+ if (err != E_OK)
{
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
REPORT_ERROR(MINOR, err, NO_MSG);
- XX_FreeSmart(p_HcFrame);
return 0;
}
if (!FmPcdKgHwSchemeIsValid(p_HcFrame->hcSpecificData.schemeRegs.kgse_mode))
{
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
REPORT_ERROR(MAJOR, E_ALREADY_EXISTS, ("Scheme is invalid"));
- XX_FreeSmart(p_HcFrame);
return 0;
}
retVal = p_HcFrame->hcSpecificData.schemeRegs.kgse_spc;
-
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
-
- XX_FreeSmart(p_HcFrame);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
return retVal;
}
@@ -687,55 +607,31 @@ t_Error FmHcPcdKgSetSchemeCounter(t_Handle h_FmHc, t_Handle h_Scheme, uint32_t
t_Error err = E_OK;
t_HcFrame *p_HcFrame;
t_DpaaFD fmFd;
- uint8_t relativeSchemeId, physicalSchemeId = (uint8_t)(PTR_TO_UINT(h_Scheme)-1);
+ uint8_t relativeSchemeId, physicalSchemeId;
+ uint32_t seqNum;
+ physicalSchemeId = FmPcdKgGetSchemeId(h_Scheme);
relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmHc->h_FmPcd, physicalSchemeId);
- if( relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)
+ if ( relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)
RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
- if ((err = FmPcdKgSchemeTryLock(p_FmHc->h_FmPcd, relativeSchemeId, FALSE)) != E_OK)
- RETURN_ERROR(MAJOR, err, NO_MSG);
-
/* first read scheme and check that it is valid */
- p_HcFrame = (t_HcFrame *)XX_MallocSmart((sizeof(t_HcFrame) + p_FmHc->padTill16), 0, 16);
+ p_HcFrame = GetBuf(p_FmHc, &seqNum);
if (!p_HcFrame)
- RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame obj"));
+ RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
memset(p_HcFrame, 0, sizeof(t_HcFrame));
p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
- p_HcFrame->actionReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
- p_HcFrame->extraReg = 0xFFFFF800;
-
- BUILD_FD(SIZE_OF_HC_FRAME_READ_OR_CC_DYNAMIC);
-
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
- {
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
- XX_FreeSmart(p_HcFrame);
- RETURN_ERROR(MINOR, err, NO_MSG);
- }
-
- /* check that scheme is valid */
- if (!FmPcdKgHwSchemeIsValid(p_HcFrame->hcSpecificData.schemeRegs.kgse_mode))
- {
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
- XX_FreeSmart(p_HcFrame);
- RETURN_ERROR(MAJOR, E_ALREADY_EXISTS, ("Scheme is invalid"));
- }
-
- /* Write scheme back, with modified counter */
- p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
p_HcFrame->actionReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, TRUE);
- p_HcFrame->extraReg = 0xFFFFF800;
+ p_HcFrame->extraReg = HC_HCOR_KG_SCHEME_COUNTER;
/* write counter */
- p_HcFrame->hcSpecificData.schemeRegs.kgse_spc = value;
+ p_HcFrame->hcSpecificData.singleRegForWrite = value;
+ p_HcFrame->commandSequence = seqNum;
BUILD_FD(sizeof(t_HcFrame));
- err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence);
-
- FmPcdKgReleaseSchemeLock(p_FmHc->h_FmPcd, relativeSchemeId);
- XX_FreeSmart(p_HcFrame);
+ err = EnQFrm(p_FmHc, &fmFd, seqNum);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
return err;
}
@@ -744,33 +640,37 @@ t_Error FmHcPcdKgSetClsPlan(t_Handle h_FmHc, t_FmPcdKgInterModuleClsPlanSet *p_S
t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
t_HcFrame *p_HcFrame;
t_DpaaFD fmFd;
- uint32_t i;
+ uint8_t i, idx;
+ uint32_t seqNum;
t_Error err = E_OK;
ASSERT_COND(p_FmHc);
- p_HcFrame = (t_HcFrame *)XX_MallocSmart((sizeof(t_HcFrame) + p_FmHc->padTill16), 0, 16);
+ p_HcFrame = GetBuf(p_FmHc, &seqNum);
if (!p_HcFrame)
- RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame obj"));
+ RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
- for(i=p_Set->baseEntry;i<p_Set->baseEntry+p_Set->numOfClsPlanEntries;i+=8)
+ for (i = p_Set->baseEntry; i < (p_Set->baseEntry+p_Set->numOfClsPlanEntries); i+=8)
{
memset(p_HcFrame, 0, sizeof(t_HcFrame));
p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
p_HcFrame->actionReg = FmPcdKgBuildWriteClsPlanBlockActionReg((uint8_t)(i / CLS_PLAN_NUM_PER_GRP));
- p_HcFrame->extraReg = 0xFFFFF800;
- memcpy((void*)&p_HcFrame->hcSpecificData.clsPlanEntries, (void *)&p_Set->vectors[i-p_Set->baseEntry], CLS_PLAN_NUM_PER_GRP*sizeof(uint32_t));
+ p_HcFrame->extraReg = HC_HCOR_KG_SCHEME_REGS_MASK;
+
+ idx = (uint8_t)(i - p_Set->baseEntry);
+ memcpy(&p_HcFrame->hcSpecificData.clsPlanEntries, &p_Set->vectors[idx], CLS_PLAN_NUM_PER_GRP*sizeof(uint32_t));
+ p_HcFrame->commandSequence = seqNum;
BUILD_FD(sizeof(t_HcFrame));
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
+ if ((err = EnQFrm(p_FmHc, &fmFd, seqNum)) != E_OK)
{
- XX_FreeSmart(p_HcFrame);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
RETURN_ERROR(MINOR, err, NO_MSG);
}
}
- XX_FreeSmart(p_HcFrame);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
return err;
}
@@ -779,10 +679,10 @@ t_Error FmHcPcdKgDeleteClsPlan(t_Handle h_FmHc, uint8_t grpId)
t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
t_FmPcdKgInterModuleClsPlanSet *p_ClsPlanSet;
- /* clear clsPlan entries in memory */
p_ClsPlanSet = (t_FmPcdKgInterModuleClsPlanSet *)XX_Malloc(sizeof(t_FmPcdKgInterModuleClsPlanSet));
if (!p_ClsPlanSet)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("memory allocation failed for p_ClsPlanSetd"));
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Classification plan set"));
+
memset(p_ClsPlanSet, 0, sizeof(t_FmPcdKgInterModuleClsPlanSet));
p_ClsPlanSet->baseEntry = FmPcdKgGetClsPlanGrpBase(p_FmHc->h_FmPcd, grpId);
@@ -790,9 +690,12 @@ t_Error FmHcPcdKgDeleteClsPlan(t_Handle h_FmHc, uint8_t grpId)
ASSERT_COND(p_ClsPlanSet->numOfClsPlanEntries <= FM_PCD_MAX_NUM_OF_CLS_PLANS);
if (FmHcPcdKgSetClsPlan(p_FmHc, p_ClsPlanSet) != E_OK)
+ {
+ XX_Free(p_ClsPlanSet);
RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
- XX_Free(p_ClsPlanSet);
+ }
+ XX_Free(p_ClsPlanSet);
FmPcdKgDestroyClsPlanGrp(p_FmHc->h_FmPcd, grpId);
return E_OK;
@@ -802,28 +705,99 @@ t_Error FmHcPcdCcCapwapTimeoutReassm(t_Handle h_FmHc, t_FmPcdCcCapwapReassmTimeo
{
t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
t_HcFrame *p_HcFrame;
- uint32_t intFlags;
t_DpaaFD fmFd;
t_Error err;
+ uint32_t seqNum;
SANITY_CHECK_RETURN_VALUE(h_FmHc, E_INVALID_HANDLE,0);
- intFlags = FmPcdLock(p_FmHc->h_FmPcd);
- p_HcFrame = (t_HcFrame *)XX_MallocSmart((sizeof(t_HcFrame) + p_FmHc->padTill16), 0, 16);
+ p_HcFrame = GetBuf(p_FmHc, &seqNum);
if (!p_HcFrame)
- RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame obj"));
+ RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
+
memset(p_HcFrame, 0, sizeof(t_HcFrame));
p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_CC_CAPWAP_REASSM_TIMEOUT);
memcpy(&p_HcFrame->hcSpecificData.ccCapwapReassmTimeout, p_CcCapwapReassmTimeoutParams, sizeof(t_FmPcdCcCapwapReassmTimeoutParams));
+ p_HcFrame->commandSequence = seqNum;
BUILD_FD(sizeof(t_HcFrame));
- err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence);
+ err = EnQFrm(p_FmHc, &fmFd, seqNum);
- XX_FreeSmart(p_HcFrame);
- FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
return err;
}
+t_Error FmHcPcdCcIpFragScratchPollCmd(t_Handle h_FmHc, bool fill, t_FmPcdCcFragScratchPoolCmdParams *p_FmPcdCcFragScratchPoolCmdParams)
+{
+ t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
+ t_HcFrame *p_HcFrame;
+ t_DpaaFD fmFd;
+ t_Error err;
+ uint32_t seqNum;
+
+ SANITY_CHECK_RETURN_VALUE(h_FmHc, E_INVALID_HANDLE,0);
+
+ p_HcFrame = GetBuf(p_FmHc, &seqNum);
+ if (!p_HcFrame)
+ RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
+
+ memset(p_HcFrame, 0, sizeof(t_HcFrame));
+
+ p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_CC_IP_FRAG_INITIALIZATION);
+ p_HcFrame->actionReg = (uint32_t)(((fill == TRUE) ? 0 : 1) << HC_HCOR_ACTION_REG_IP_FRAG_SCRATCH_POOL_CMD_SHIFT);
+ p_HcFrame->actionReg |= p_FmPcdCcFragScratchPoolCmdParams->bufferPoolId << HC_HCOR_ACTION_REG_IP_FRAG_SCRATCH_POOL_BPID;
+ if (fill == TRUE)
+ {
+ p_HcFrame->extraReg = p_FmPcdCcFragScratchPoolCmdParams->numOfBuffers;
+ }
+ p_HcFrame->commandSequence = seqNum;
+
+ BUILD_FD(sizeof(t_HcFrame));
+ if ((err = EnQFrm(p_FmHc, &fmFd, seqNum)) != E_OK)
+ {
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
+ RETURN_ERROR(MINOR, err, NO_MSG);
+ }
+
+ p_FmPcdCcFragScratchPoolCmdParams->numOfBuffers = p_HcFrame->extraReg;
+
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
+ return E_OK;
+}
+
+t_Error FmHcPcdCcTimeoutReassm(t_Handle h_FmHc, t_FmPcdCcReassmTimeoutParams *p_CcReassmTimeoutParams, uint8_t *p_Result)
+{
+ t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
+ t_HcFrame *p_HcFrame;
+ t_DpaaFD fmFd;
+ t_Error err;
+ uint32_t seqNum;
+
+ SANITY_CHECK_RETURN_VALUE(h_FmHc, E_INVALID_HANDLE,0);
+
+ p_HcFrame = GetBuf(p_FmHc, &seqNum);
+ if (!p_HcFrame)
+ RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
+
+ memset(p_HcFrame, 0, sizeof(t_HcFrame));
+ p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_CC_REASSM_TIMEOUT);
+ p_HcFrame->actionReg = (uint32_t)((p_CcReassmTimeoutParams->activate ? 0 : 1) << HC_HCOR_ACTION_REG_REASSM_TIMEOUT_ACTIVE_SHIFT);
+ p_HcFrame->extraReg = (p_CcReassmTimeoutParams->tsbs << HC_HCOR_EXTRA_REG_REASSM_TIMEOUT_TSBS_SHIFT) | p_CcReassmTimeoutParams->iprcpt;
+ p_HcFrame->commandSequence = seqNum;
+
+ BUILD_FD(sizeof(t_HcFrame));
+ if ((err = EnQFrm(p_FmHc, &fmFd, seqNum)) != E_OK)
+ {
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
+ RETURN_ERROR(MINOR, err, NO_MSG);
+ }
+
+ *p_Result = (uint8_t)
+ ((p_HcFrame->actionReg >> HC_HCOR_ACTION_REG_REASSM_TIMEOUT_RES_SHIFT) & HC_HCOR_ACTION_REG_REASSM_TIMEOUT_RES_MASK);
+
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
+ return E_OK;
+}
t_Error FmHcPcdPlcrCcGetSetParams(t_Handle h_FmHc,uint16_t absoluteProfileId, uint32_t requiredAction)
{
@@ -832,58 +806,49 @@ t_Error FmHcPcdPlcrCcGetSetParams(t_Handle h_FmHc,uint16_t absoluteProfileId, ui
t_DpaaFD fmFd;
t_Error err;
uint32_t tmpReg32 = 0;
- uint32_t requiredActionTmp, pointedOwnersTmp;
+ uint32_t requiredActionTmp, requiredActionFlag;
+ uint32_t seqNum;
SANITY_CHECK_RETURN_VALUE(h_FmHc, E_INVALID_HANDLE,0);
- if (absoluteProfileId >= FM_PCD_PLCR_NUM_ENTRIES)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE,("Policer profile out of range"));
-
- if (FmPcdPlcrProfileTryLock(p_FmHc->h_FmPcd, absoluteProfileId, FALSE))
- return ERROR_CODE(E_BUSY);
-
+ /* Profile is locked by calling routine */
+ /* WARNING - this lock will not be efficient if other HC routine will attempt to change
+ * "fmpl_pegnia" "fmpl_peynia" or "fmpl_pernia" without locking Profile !
+ */
requiredActionTmp = FmPcdPlcrGetRequiredAction(p_FmHc->h_FmPcd, absoluteProfileId);
- pointedOwnersTmp = FmPcdPlcrGetPointedOwners(p_FmHc->h_FmPcd, absoluteProfileId);
+ requiredActionFlag = FmPcdPlcrGetRequiredActionFlag(p_FmHc->h_FmPcd, absoluteProfileId);
- if(!pointedOwnersTmp || !(requiredActionTmp & requiredAction))
+ if (!requiredActionFlag || !(requiredActionTmp & requiredAction))
{
-
- if(requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)
+ if (requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)
{
-
- p_HcFrame = (t_HcFrame *)XX_MallocSmart((sizeof(t_HcFrame) + p_FmHc->padTill16), 0, 16);
+ p_HcFrame = GetBuf(p_FmHc, &seqNum);
if (!p_HcFrame)
- RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame obj"));
+ RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
/* first read scheme and check that it is valid */
memset(p_HcFrame, 0, sizeof(t_HcFrame));
p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_PLCR_PRFL);
p_HcFrame->actionReg = FmPcdPlcrBuildReadPlcrActionReg(absoluteProfileId);
p_HcFrame->extraReg = 0x00008000;
+ p_HcFrame->commandSequence = seqNum;
BUILD_FD(SIZE_OF_HC_FRAME_READ_OR_CC_DYNAMIC);
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
+ if ((err = EnQFrm(p_FmHc, &fmFd, seqNum)) != E_OK)
{
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, absoluteProfileId);
- XX_FreeSmart(p_HcFrame);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
RETURN_ERROR(MINOR, err, NO_MSG);
}
- /* check that profile is valid */
- if (!FmPcdPlcrHwProfileIsValid(p_HcFrame->hcSpecificData.profileRegs.fmpl_pemode))
- {
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, absoluteProfileId);
- XX_FreeSmart(p_HcFrame);
- RETURN_ERROR(MAJOR, E_ALREADY_EXISTS, ("Policer is already used"));
- }
-
tmpReg32 = p_HcFrame->hcSpecificData.profileRegs.fmpl_pegnia;
- if(!(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)))
+ if (!(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)))
{
- XX_FreeSmart(p_HcFrame);
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next engine of this policer profile has to be assigned to FM_PCD_DONE"));
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("Next engine of this policer profile has to be assigned to FM_PCD_DONE"));
}
+
tmpReg32 |= NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_PLCR_PRFL);
@@ -894,19 +859,19 @@ t_Error FmHcPcdPlcrCcGetSetParams(t_Handle h_FmHc,uint16_t absoluteProfileId, ui
BUILD_FD(SIZE_OF_HC_FRAME_PROFILE_CNT);
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
+ if ((err = EnQFrm(p_FmHc, &fmFd, seqNum)) != E_OK)
{
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, absoluteProfileId);
- XX_FreeSmart(p_HcFrame);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
RETURN_ERROR(MINOR, err, NO_MSG);
}
tmpReg32 = p_HcFrame->hcSpecificData.profileRegs.fmpl_peynia;
- if(!(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)))
+ if (!(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)))
{
- XX_FreeSmart(p_HcFrame);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next engine of this policer profile has to be assigned to FM_PCD_DONE"));
}
+
tmpReg32 |= NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_PLCR_PRFL);
@@ -917,19 +882,19 @@ t_Error FmHcPcdPlcrCcGetSetParams(t_Handle h_FmHc,uint16_t absoluteProfileId, ui
BUILD_FD(SIZE_OF_HC_FRAME_PROFILE_CNT);
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
+ if ((err = EnQFrm(p_FmHc, &fmFd, seqNum)) != E_OK)
{
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, absoluteProfileId);
- XX_FreeSmart(p_HcFrame);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
RETURN_ERROR(MINOR, err, NO_MSG);
}
tmpReg32 = p_HcFrame->hcSpecificData.profileRegs.fmpl_pernia;
- if(!(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)))
+ if (!(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)))
{
- XX_FreeSmart(p_HcFrame);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next engine of this policer profile has to be assigned to FM_PCD_DONE"));
}
+
tmpReg32 |= NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_PLCR_PRFL);
@@ -940,163 +905,81 @@ t_Error FmHcPcdPlcrCcGetSetParams(t_Handle h_FmHc,uint16_t absoluteProfileId, ui
BUILD_FD(SIZE_OF_HC_FRAME_PROFILE_CNT);
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
+ if ((err = EnQFrm(p_FmHc, &fmFd, seqNum)) != E_OK)
{
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, absoluteProfileId);
- XX_FreeSmart(p_HcFrame);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
RETURN_ERROR(MINOR, err, NO_MSG);
}
- XX_FreeSmart(p_HcFrame);
+
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
}
}
- FmPcdPlcrUpatePointedOwner(p_FmHc->h_FmPcd, absoluteProfileId, TRUE);
- FmPcdPlcrUpdateRequiredAction(p_FmHc->h_FmPcd, absoluteProfileId, requiredAction);
-
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, absoluteProfileId);
-
return E_OK;
}
-t_Handle FmHcPcdPlcrSetProfile(t_Handle h_FmHc,t_FmPcdPlcrProfileParams *p_Profile)
+t_Error FmHcPcdPlcrSetProfile(t_Handle h_FmHc, t_Handle h_Profile, t_FmPcdPlcrProfileRegs *p_PlcrRegs)
{
t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
- t_FmPcdPlcrInterModuleProfileRegs profileRegs;
t_Error err = E_OK;
- uint32_t intFlags;
uint16_t profileIndx;
t_HcFrame *p_HcFrame;
t_DpaaFD fmFd;
+ uint32_t seqNum;
- if (p_Profile->modify)
- {
- profileIndx = (uint16_t)(PTR_TO_UINT(p_Profile->id.h_Profile)-1);
- if (FmPcdPlcrProfileTryLock(p_FmHc->h_FmPcd, profileIndx, FALSE))
- return NULL;
- }
- else
- {
- intFlags = FmPcdLock(p_FmHc->h_FmPcd);
- err = FmPcdPlcrGetAbsoluteProfileId(p_FmHc->h_FmPcd,
- p_Profile->id.newParams.profileType,
- p_Profile->id.newParams.h_FmPort,
- p_Profile->id.newParams.relativeProfileId,
- &profileIndx);
- if (err)
- {
- REPORT_ERROR(MAJOR, err, NO_MSG);
- return NULL;
- }
- err = FmPcdPlcrProfileTryLock(p_FmHc->h_FmPcd, profileIndx, TRUE);
- FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
- if (err)
- return NULL;
- }
-
- p_HcFrame = (t_HcFrame *)XX_MallocSmart((sizeof(t_HcFrame) + p_FmHc->padTill16), 0, 16);
+ p_HcFrame = GetBuf(p_FmHc, &seqNum);
if (!p_HcFrame)
- {
- REPORT_ERROR(MINOR, E_NO_MEMORY, ("HC Frame obj"));
- return NULL;
- }
+ RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
- if(!p_Profile->modify)
- {
- memset(p_HcFrame, 0, sizeof(t_HcFrame));
- p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_PLCR_PRFL);
- p_HcFrame->actionReg = FmPcdPlcrBuildReadPlcrActionReg(profileIndx);
- p_HcFrame->extraReg = 0x00008000;
-
- BUILD_FD(SIZE_OF_HC_FRAME_READ_OR_CC_DYNAMIC);
-
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
- {
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, profileIndx);
- REPORT_ERROR(MINOR, err, NO_MSG);
- XX_FreeSmart(p_HcFrame);
- return NULL;
- }
-
- /* check if this scheme is already used */
- if (FmPcdPlcrHwProfileIsValid(p_HcFrame->hcSpecificData.profileRegs.fmpl_pemode))
- {
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, profileIndx);
- REPORT_ERROR(MAJOR, E_ALREADY_EXISTS, ("Policer is already used"));
- XX_FreeSmart(p_HcFrame);
- return NULL;
- }
- }
-
- memset(&profileRegs, 0, sizeof(t_FmPcdPlcrInterModuleProfileRegs));
- err = FmPcdPlcrBuildProfile(p_FmHc->h_FmPcd, p_Profile, &profileRegs);
- if(err)
- {
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, profileIndx);
- REPORT_ERROR(MAJOR, err, NO_MSG);
- XX_FreeSmart(p_HcFrame);
- return NULL;
- }
+ profileIndx = FmPcdPlcrProfileGetAbsoluteId(h_Profile);
memset(p_HcFrame, 0, sizeof(t_HcFrame));
p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_PLCR_PRFL);
p_HcFrame->actionReg = FmPcdPlcrBuildWritePlcrActionRegs(profileIndx);
p_HcFrame->extraReg = 0x00008000;
- memcpy(&p_HcFrame->hcSpecificData.profileRegs, &profileRegs, sizeof(t_FmPcdPlcrInterModuleProfileRegs));
+ memcpy(&p_HcFrame->hcSpecificData.profileRegs, p_PlcrRegs, sizeof(t_FmPcdPlcrProfileRegs));
+ p_HcFrame->commandSequence = seqNum;
BUILD_FD(sizeof(t_HcFrame));
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
- {
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, profileIndx);
- REPORT_ERROR(MINOR, err, NO_MSG);
- XX_FreeSmart(p_HcFrame);
- return NULL;
- }
+ err = EnQFrm(p_FmHc, &fmFd, seqNum);
- FmPcdPlcrValidateProfileSw(p_FmHc->h_FmPcd, profileIndx);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, profileIndx);
-
- XX_FreeSmart(p_HcFrame);
+ if (err != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
- return UINT_TO_PTR((uint64_t)profileIndx+1);
+ return E_OK;
}
t_Error FmHcPcdPlcrDeleteProfile(t_Handle h_FmHc, t_Handle h_Profile)
{
t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
- uint16_t absoluteProfileId = (uint16_t)(PTR_TO_UINT(h_Profile)-1);
+ uint16_t absoluteProfileId = FmPcdPlcrProfileGetAbsoluteId(h_Profile);
t_Error err = E_OK;
t_HcFrame *p_HcFrame;
t_DpaaFD fmFd;
+ uint32_t seqNum;
- if (FmPcdPlcrProfileTryLock(p_FmHc->h_FmPcd, absoluteProfileId, FALSE))
- return ERROR_CODE(E_BUSY);
-
- FmPcdPlcrInvalidateProfileSw(p_FmHc->h_FmPcd, absoluteProfileId);
-
- p_HcFrame = (t_HcFrame *)XX_MallocSmart((sizeof(t_HcFrame) + p_FmHc->padTill16), 0, 16);
+ p_HcFrame = GetBuf(p_FmHc, &seqNum);
if (!p_HcFrame)
- RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame obj"));
+ RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
memset(p_HcFrame, 0, sizeof(t_HcFrame));
p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_PLCR_PRFL);
p_HcFrame->actionReg = FmPcdPlcrBuildWritePlcrActionReg(absoluteProfileId);
p_HcFrame->actionReg |= 0x00008000;
p_HcFrame->extraReg = 0x00008000;
- memset(&p_HcFrame->hcSpecificData.profileRegs, 0, sizeof(t_FmPcdPlcrInterModuleProfileRegs));
+ memset(&p_HcFrame->hcSpecificData.profileRegs, 0, sizeof(t_FmPcdPlcrProfileRegs));
+ p_HcFrame->commandSequence = seqNum;
BUILD_FD(sizeof(t_HcFrame));
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
- {
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, absoluteProfileId);
- XX_FreeSmart(p_HcFrame);
- RETURN_ERROR(MINOR, err, NO_MSG);
- }
+ err = EnQFrm(p_FmHc, &fmFd, seqNum);
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, absoluteProfileId);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
- XX_FreeSmart(p_HcFrame);
+ if (err != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
return E_OK;
}
@@ -1105,58 +988,32 @@ t_Error FmHcPcdPlcrSetProfileCounter(t_Handle h_FmHc, t_Handle h_Profile, e_FmP
{
t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
- uint16_t absoluteProfileId = (uint16_t)(PTR_TO_UINT(h_Profile)-1);
+ uint16_t absoluteProfileId = FmPcdPlcrProfileGetAbsoluteId(h_Profile);
t_Error err = E_OK;
t_HcFrame *p_HcFrame;
t_DpaaFD fmFd;
-
- if (FmPcdPlcrProfileTryLock(p_FmHc->h_FmPcd, absoluteProfileId, FALSE))
- return ERROR_CODE(E_BUSY);
+ uint32_t seqNum;
/* first read scheme and check that it is valid */
- p_HcFrame = (t_HcFrame *)XX_MallocSmart((sizeof(t_HcFrame) + p_FmHc->padTill16), 0, 16);
+ p_HcFrame = GetBuf(p_FmHc, &seqNum);
if (!p_HcFrame)
- RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame obj"));
+ RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
memset(p_HcFrame, 0, sizeof(t_HcFrame));
p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_PLCR_PRFL);
- p_HcFrame->actionReg = FmPcdPlcrBuildReadPlcrActionReg(absoluteProfileId);
- p_HcFrame->extraReg = 0x00008000;
-
- BUILD_FD(SIZE_OF_HC_FRAME_READ_OR_CC_DYNAMIC);
-
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
- {
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, absoluteProfileId);
- XX_FreeSmart(p_HcFrame);
- RETURN_ERROR(MINOR, err, NO_MSG);
- }
-
- /* check that profile is valid */
- if (!FmPcdPlcrHwProfileIsValid(p_HcFrame->hcSpecificData.profileRegs.fmpl_pemode))
- {
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, absoluteProfileId);
- XX_FreeSmart(p_HcFrame);
- RETURN_ERROR(MAJOR, E_ALREADY_EXISTS, ("Policer is already used"));
- }
-
- p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_PLCR_PRFL);
p_HcFrame->actionReg = FmPcdPlcrBuildWritePlcrActionReg(absoluteProfileId);
p_HcFrame->actionReg |= FmPcdPlcrBuildCounterProfileReg(counter);
p_HcFrame->extraReg = 0x00008000;
p_HcFrame->hcSpecificData.singleRegForWrite = value;
+ p_HcFrame->commandSequence = seqNum;
BUILD_FD(SIZE_OF_HC_FRAME_PROFILE_CNT);
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
- {
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, absoluteProfileId);
- XX_FreeSmart(p_HcFrame);
- RETURN_ERROR(MINOR, err, NO_MSG);
- }
+ err = EnQFrm(p_FmHc, &fmFd, seqNum);
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, absoluteProfileId);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
- XX_FreeSmart(p_HcFrame);
+ if (err != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
return E_OK;
}
@@ -1164,45 +1021,35 @@ t_Error FmHcPcdPlcrSetProfileCounter(t_Handle h_FmHc, t_Handle h_Profile, e_FmP
uint32_t FmHcPcdPlcrGetProfileCounter(t_Handle h_FmHc, t_Handle h_Profile, e_FmPcdPlcrProfileCounters counter)
{
t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
- uint16_t absoluteProfileId = (uint16_t)(PTR_TO_UINT(h_Profile)-1);
- t_Error err = E_OK;
+ uint16_t absoluteProfileId = FmPcdPlcrProfileGetAbsoluteId(h_Profile);
+ t_Error err;
t_HcFrame *p_HcFrame;
t_DpaaFD fmFd;
uint32_t retVal = 0;
+ uint32_t seqNum;
SANITY_CHECK_RETURN_VALUE(h_FmHc, E_INVALID_HANDLE,0);
- if (FmPcdPlcrProfileTryLock(p_FmHc->h_FmPcd, absoluteProfileId, FALSE))
- return 0;
-
/* first read scheme and check that it is valid */
- p_HcFrame = (t_HcFrame *)XX_MallocSmart((sizeof(t_HcFrame) + p_FmHc->padTill16), 0, 16);
+ p_HcFrame = GetBuf(p_FmHc, &seqNum);
if (!p_HcFrame)
{
- REPORT_ERROR(MINOR, E_NO_MEMORY, ("HC Frame obj"));
+ REPORT_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
return 0;
}
memset(p_HcFrame, 0, sizeof(t_HcFrame));
p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_PLCR_PRFL);
p_HcFrame->actionReg = FmPcdPlcrBuildReadPlcrActionReg(absoluteProfileId);
p_HcFrame->extraReg = 0x00008000;
+ p_HcFrame->commandSequence = seqNum;
BUILD_FD(SIZE_OF_HC_FRAME_READ_OR_CC_DYNAMIC);
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
+ err = EnQFrm(p_FmHc, &fmFd, seqNum);
+ if (err != E_OK)
{
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, absoluteProfileId);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
REPORT_ERROR(MINOR, err, NO_MSG);
- XX_FreeSmart(p_HcFrame);
- return 0;
- }
-
- /* check that profile is valid */
- if (!FmPcdPlcrHwProfileIsValid(p_HcFrame->hcSpecificData.profileRegs.fmpl_pemode))
- {
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, absoluteProfileId);
- XX_FreeSmart(p_HcFrame);
- REPORT_ERROR(MAJOR, E_ALREADY_EXISTS, ("invalid Policer profile"));
return 0;
}
@@ -1227,358 +1074,158 @@ uint32_t FmHcPcdPlcrGetProfileCounter(t_Handle h_FmHc, t_Handle h_Profile, e_FmP
REPORT_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
}
- FmPcdPlcrReleaseProfileLock(p_FmHc->h_FmPcd, absoluteProfileId);
-
- XX_FreeSmart(p_HcFrame);
-
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
return retVal;
}
-t_Error FmHcPcdCcModifyTreeNextEngine(t_Handle h_FmHc, t_Handle h_CcTree, uint8_t grpId, uint8_t index, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
+t_Error FmHcKgWriteSp(t_Handle h_FmHc, uint8_t hardwarePortId, uint32_t spReg, bool add)
{
- t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
- t_Error err = E_OK;
- uint32_t intFlags;
- t_List h_OldPointersLst, h_NewPointersLst;
- t_Handle h_Params;
-
- intFlags = FmPcdLock(p_FmHc->h_FmPcd);
- err = FmPcdCcTreeTryLock(h_CcTree);
- FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
- if (err)
- return err;
-
- INIT_LIST(&h_OldPointersLst);
- INIT_LIST(&h_NewPointersLst);
-
- err = FmPcdCcModifyNextEngineParamTree(p_FmHc->h_FmPcd, h_CcTree, grpId, index, p_FmPcdCcNextEngineParams,
- &h_OldPointersLst, &h_NewPointersLst, &h_Params);
- if(err)
- {
- FmPcdCcTreeReleaseLock(h_CcTree);
- RETURN_ERROR(MAJOR, err, NO_MSG);
- }
-
- err = HcDynamicChange(p_FmHc, &h_OldPointersLst, &h_NewPointersLst, &h_Params);
-
- FmPcdCcTreeReleaseLock(h_CcTree);
-
- return err;
-}
-
+ t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
+ t_HcFrame *p_HcFrame;
+ t_DpaaFD fmFd;
+ t_Error err = E_OK;
+ uint32_t seqNum;
-t_Error FmHcPcdCcModifyNodeMissNextEngine(t_Handle h_FmHc, t_Handle h_CcNode, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
-{
- t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
- t_Handle h_Params;
- t_List h_OldPointersLst, h_NewPointersLst;
- t_Error err = E_OK;
- t_List h_List;
- uint32_t intFlags;
+ ASSERT_COND(p_FmHc);
- INIT_LIST(&h_List);
+ p_HcFrame = GetBuf(p_FmHc, &seqNum);
+ if (!p_HcFrame)
+ RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
+ memset(p_HcFrame, 0, sizeof(t_HcFrame));
+ /* first read SP register */
+ p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
+ p_HcFrame->actionReg = FmPcdKgBuildReadPortSchemeBindActionReg(hardwarePortId);
+ p_HcFrame->extraReg = HC_HCOR_KG_SCHEME_REGS_MASK;
+ p_HcFrame->commandSequence = seqNum;
- intFlags = FmPcdLock(p_FmHc->h_FmPcd);
+ BUILD_FD(SIZE_OF_HC_FRAME_PORT_REGS);
- if ((err = FmPcdCcNodeTreeTryLock(p_FmHc->h_FmPcd, h_CcNode, &h_List)) != E_OK)
+ if ((err = EnQFrm(p_FmHc, &fmFd, seqNum)) != E_OK)
{
- FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
- return err;
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
+ RETURN_ERROR(MINOR, err, NO_MSG);
}
- FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
+ /* spReg is the first reg, so we can use it both for read and for write */
+ if (add)
+ p_HcFrame->hcSpecificData.portRegsForRead.spReg |= spReg;
+ else
+ p_HcFrame->hcSpecificData.portRegsForRead.spReg &= ~spReg;
- INIT_LIST(&h_OldPointersLst);
- INIT_LIST(&h_NewPointersLst);
+ p_HcFrame->actionReg = FmPcdKgBuildWritePortSchemeBindActionReg(hardwarePortId);
- err = FmPcdCcModifyMissNextEngineParamNode(p_FmHc->h_FmPcd, h_CcNode, p_FmPcdCcNextEngineParams, &h_OldPointersLst, &h_NewPointersLst, &h_Params);
- if(err)
- {
- FmPcdCcNodeTreeReleaseLock(&h_List);
- RETURN_ERROR(MAJOR, err, NO_MSG);
- }
+ BUILD_FD(sizeof(t_HcFrame));
- err = HcDynamicChange(p_FmHc, &h_OldPointersLst, &h_NewPointersLst, &h_Params);
+ err = EnQFrm(p_FmHc, &fmFd, seqNum);
- FmPcdCcNodeTreeReleaseLock(&h_List);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
+ if (err != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
return E_OK;
}
-t_Error FmHcPcdCcRemoveKey(t_Handle h_FmHc, t_Handle h_CcNode, uint8_t keyIndex)
-{
- t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
- t_Handle h_Params;
- t_List h_OldPointersLst, h_NewPointersLst;
- t_Error err = E_OK;
- t_List h_List;
- uint32_t intFlags;
-
- INIT_LIST(&h_List);
-
- intFlags = FmPcdLock(p_FmHc->h_FmPcd);
-
- if ((err = FmPcdCcNodeTreeTryLock(p_FmHc->h_FmPcd, h_CcNode, &h_List)) != E_OK)
- {
- FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
- return err;
- }
-
- FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
-
- INIT_LIST(&h_OldPointersLst);
- INIT_LIST(&h_NewPointersLst);
-
-
- err = FmPcdCcRemoveKey(p_FmHc->h_FmPcd,h_CcNode,keyIndex, &h_OldPointersLst, &h_NewPointersLst, &h_Params);
- if(err)
- {
- FmPcdCcNodeTreeReleaseLock(&h_List);
- RETURN_ERROR(MAJOR, err, NO_MSG);
- }
-
- err = HcDynamicChange(p_FmHc, &h_OldPointersLst, &h_NewPointersLst, &h_Params);
-
- FmPcdCcNodeTreeReleaseLock(&h_List);
-
- return err;
-
-}
-
-t_Error FmHcPcdCcAddKey(t_Handle h_FmHc, t_Handle h_CcNode, uint8_t keyIndex, uint8_t keySize, t_FmPcdCcKeyParams *p_KeyParams)
-{
- t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
- t_Handle h_Params;
- t_List h_OldPointersLst, h_NewPointersLst;
- t_Error err = E_OK;
- t_List h_List;
- uint32_t intFlags;
-
- INIT_LIST(&h_List);
-
- intFlags = FmPcdLock(p_FmHc->h_FmPcd);
-
- if ((err = FmPcdCcNodeTreeTryLock(p_FmHc->h_FmPcd, h_CcNode, &h_List)) != E_OK)
- {
- FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
- return err;
- }
-
- FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
-
- INIT_LIST(&h_OldPointersLst);
- INIT_LIST(&h_NewPointersLst);
-
-
- err = FmPcdCcAddKey(p_FmHc->h_FmPcd,h_CcNode,keyIndex,keySize, p_KeyParams, &h_OldPointersLst,&h_NewPointersLst, &h_Params);
- if(err)
- {
- FmPcdCcNodeTreeReleaseLock(&h_List);
- RETURN_ERROR(MAJOR, err, NO_MSG);
- }
-
- err = HcDynamicChange(p_FmHc, &h_OldPointersLst, &h_NewPointersLst, &h_Params);
-
- FmPcdCcNodeTreeReleaseLock(&h_List);
-
- return err;
-}
-
-
-t_Error FmHcPcdCcModifyKey(t_Handle h_FmHc, t_Handle h_CcNode, uint8_t keyIndex, uint8_t keySize, uint8_t *p_Key, uint8_t *p_Mask)
-{
- t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
- t_List h_OldPointersLst, h_NewPointersLst;
- t_Error err = E_OK;
- t_List h_List;
- uint32_t intFlags;
- t_Handle h_Params;
-
- UNUSED(keySize);
-
- INIT_LIST(&h_List);
-
- intFlags = FmPcdLock(p_FmHc->h_FmPcd);
-
- if ((err = FmPcdCcNodeTreeTryLock(p_FmHc->h_FmPcd, h_CcNode, &h_List)) != E_OK)
- {
- FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
- return err;
- }
-
- FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
-
- INIT_LIST(&h_OldPointersLst);
- INIT_LIST(&h_NewPointersLst);
-
- err = FmPcdCcModifyKey(p_FmHc->h_FmPcd, h_CcNode, keyIndex, keySize, p_Key, p_Mask, &h_OldPointersLst,&h_NewPointersLst, &h_Params);
- if(err)
- {
- FmPcdCcNodeTreeReleaseLock(&h_List);
- RETURN_ERROR(MAJOR, err, NO_MSG);
- }
-
- err = HcDynamicChange(p_FmHc, &h_OldPointersLst, &h_NewPointersLst, &h_Params);
-
- FmPcdCcNodeTreeReleaseLock(&h_List);
-
- return err;
-}
-
-t_Error FmHcPcdCcModifyNodeNextEngine(t_Handle h_FmHc, t_Handle h_CcNode, uint8_t keyIndex, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
-{
- t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
- t_Error err = E_OK;
- t_List h_OldPointersLst, h_NewPointersLst;
- t_List h_List;
- uint32_t intFlags;
- t_Handle h_Params;
-
- INIT_LIST(&h_List);
-
- intFlags = FmPcdLock(p_FmHc->h_FmPcd);
-
- if ((err = FmPcdCcNodeTreeTryLock(p_FmHc->h_FmPcd, h_CcNode, &h_List)) != E_OK)
- {
- FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
- return err;
- }
-
- FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
-
- INIT_LIST(&h_OldPointersLst);
- INIT_LIST(&h_NewPointersLst);
-
- err = FmPcdCcModiyNextEngineParamNode(p_FmHc->h_FmPcd, h_CcNode, keyIndex, p_FmPcdCcNextEngineParams, &h_OldPointersLst, &h_NewPointersLst, &h_Params);
- if(err)
- {
- FmPcdCcNodeTreeReleaseLock(&h_List);
- RETURN_ERROR(MAJOR, err, NO_MSG);
- }
-
- err = HcDynamicChange(p_FmHc, &h_OldPointersLst, &h_NewPointersLst, &h_Params);
- FmPcdCcNodeTreeReleaseLock(&h_List);
- return err;
-}
-
-
-t_Error FmHcPcdCcModifyKeyAndNextEngine(t_Handle h_FmHc, t_Handle h_CcNode, uint8_t keyIndex, uint8_t keySize, t_FmPcdCcKeyParams *p_KeyParams)
+t_Error FmHcKgWriteCpp(t_Handle h_FmHc, uint8_t hardwarePortId, uint32_t cppReg)
{
- t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
- t_List h_OldPointersLst, h_NewPointersLst;
- t_Error err = E_OK;
- t_List h_List;
- uint32_t intFlags;
- t_Handle h_Params;
-
- INIT_LIST(&h_OldPointersLst);
- INIT_LIST(&h_NewPointersLst);
- INIT_LIST(&h_List);
-
- intFlags = FmPcdLock(p_FmHc->h_FmPcd);
-
- if ((err = FmPcdCcNodeTreeTryLock(p_FmHc->h_FmPcd, h_CcNode, &h_List)) != E_OK)
- {
- FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
- return err;
- }
+ t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
+ t_HcFrame *p_HcFrame;
+ t_DpaaFD fmFd;
+ t_Error err = E_OK;
+ uint32_t seqNum;
- FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
+ ASSERT_COND(p_FmHc);
+ p_HcFrame = GetBuf(p_FmHc, &seqNum);
+ if (!p_HcFrame)
+ RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
+ memset(p_HcFrame, 0, sizeof(t_HcFrame));
+ /* first read SP register */
+ p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
+ p_HcFrame->actionReg = FmPcdKgBuildWritePortClsPlanBindActionReg(hardwarePortId);
+ p_HcFrame->extraReg = HC_HCOR_KG_SCHEME_REGS_MASK;
+ p_HcFrame->hcSpecificData.singleRegForWrite = cppReg;
+ p_HcFrame->commandSequence = seqNum;
- err = FmPcdCcModifyKeyAndNextEngine(p_FmHc->h_FmPcd,h_CcNode,keyIndex,keySize, p_KeyParams, &h_OldPointersLst,&h_NewPointersLst, &h_Params);
- if(err)
- {
- FmPcdCcNodeTreeReleaseLock(&h_List);
- RETURN_ERROR(MAJOR, err, NO_MSG);
- }
+ BUILD_FD(sizeof(t_HcFrame));
- err = HcDynamicChange(p_FmHc, &h_OldPointersLst, &h_NewPointersLst, &h_Params);
+ err = EnQFrm(p_FmHc, &fmFd, seqNum);
- FmPcdCcNodeTreeReleaseLock(&h_List);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
+ if (err != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
- return err;
+ return E_OK;
}
-
-t_Error FmHcKgWriteSp(t_Handle h_FmHc, uint8_t hardwarePortId, uint32_t spReg, bool add)
+t_Error FmHcPcdCcDoDynamicChange(t_Handle h_FmHc, uint32_t oldAdAddrOffset, uint32_t newAdAddrOffset)
{
t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
t_HcFrame *p_HcFrame;
t_DpaaFD fmFd;
t_Error err = E_OK;
+ uint32_t seqNum;
- ASSERT_COND(p_FmHc);
+ SANITY_CHECK_RETURN_ERROR(p_FmHc, E_INVALID_HANDLE);
- p_HcFrame = (t_HcFrame *)XX_MallocSmart((sizeof(t_HcFrame) + p_FmHc->padTill16), 0, 16);
+ p_HcFrame = GetBuf(p_FmHc, &seqNum);
if (!p_HcFrame)
- RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame obj"));
+ RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
memset(p_HcFrame, 0, sizeof(t_HcFrame));
- /* first read SP register */
- p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
- p_HcFrame->actionReg = FmPcdKgBuildReadPortSchemeBindActionReg(hardwarePortId);
- p_HcFrame->extraReg = 0xFFFFF800;
- BUILD_FD(SIZE_OF_HC_FRAME_PORT_REGS);
+ p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_CC);
+ p_HcFrame->actionReg = newAdAddrOffset;
+ p_HcFrame->actionReg |= 0xc0000000;
+ p_HcFrame->extraReg = oldAdAddrOffset;
+ p_HcFrame->commandSequence = seqNum;
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
- {
- XX_FreeSmart(p_HcFrame);
- RETURN_ERROR(MINOR, err, NO_MSG);
- }
-
- /* spReg is the first reg, so we can use it both for read and for write */
- if(add)
- p_HcFrame->hcSpecificData.portRegsForRead.spReg |= spReg;
- else
- p_HcFrame->hcSpecificData.portRegsForRead.spReg &= ~spReg;
-
- p_HcFrame->actionReg = FmPcdKgBuildWritePortSchemeBindActionReg(hardwarePortId);
+ BUILD_FD(SIZE_OF_HC_FRAME_READ_OR_CC_DYNAMIC);
- BUILD_FD(sizeof(t_HcFrame));
+ err = EnQFrm(p_FmHc, &fmFd, seqNum);
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
- {
- XX_FreeSmart(p_HcFrame);
- RETURN_ERROR(MINOR, err, NO_MSG);
- }
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
- XX_FreeSmart(p_HcFrame);
+ if (err != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
return E_OK;
}
-t_Error FmHcKgWriteCpp(t_Handle h_FmHc, uint8_t hardwarePortId, uint32_t cppReg)
+t_Error FmHcPcdSync(t_Handle h_FmHc)
{
t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
t_HcFrame *p_HcFrame;
t_DpaaFD fmFd;
t_Error err = E_OK;
+ uint32_t seqNum;
ASSERT_COND(p_FmHc);
- p_HcFrame = (t_HcFrame *)XX_MallocSmart((sizeof(t_HcFrame) + p_FmHc->padTill16), 0, 16);
+ p_HcFrame = GetBuf(p_FmHc, &seqNum);
if (!p_HcFrame)
- RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame obj"));
+ RETURN_ERROR(MINOR, E_NO_MEMORY, ("HC Frame object"));
memset(p_HcFrame, 0, sizeof(t_HcFrame));
/* first read SP register */
- p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_KG_SCM);
- p_HcFrame->actionReg = FmPcdKgBuildWritePortClsPlanBindActionReg(hardwarePortId);
- p_HcFrame->extraReg = 0xFFFFF800;
- p_HcFrame->hcSpecificData.singleRegForWrite = cppReg;
+ p_HcFrame->opcode = (uint32_t)(HC_HCOR_GBL | HC_HCOR_OPCODE_SYNC);
+ p_HcFrame->actionReg = 0;
+ p_HcFrame->extraReg = 0;
+ p_HcFrame->commandSequence = seqNum;
BUILD_FD(sizeof(t_HcFrame));
- if ((err = EnQFrm(p_FmHc, &fmFd, &p_HcFrame->commandSequence)) != E_OK)
- {
- XX_FreeSmart(p_HcFrame);
- RETURN_ERROR(MINOR, err, NO_MSG);
- }
+ err = EnQFrm(p_FmHc, &fmFd, seqNum);
- XX_FreeSmart(p_HcFrame);
+ PutBuf(p_FmHc, p_HcFrame, seqNum);
+
+ if (err != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
return E_OK;
}
+t_Handle FmHcGetPort(t_Handle h_FmHc)
+{
+ t_FmHc *p_FmHc = (t_FmHc*)h_FmHc;
+ return p_FmHc->h_HcPortDev;
+}
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/dtsec.c b/sys/contrib/ncsw/Peripherals/FM/MAC/dtsec.c
index d543132b0f02..b6a18340efe9 100644
--- a/sys/contrib/ncsw/Peripherals/FM/MAC/dtsec.c
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/dtsec.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2013 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -33,7 +33,7 @@
/******************************************************************************
@File dtsec.c
- @Description FM dTSEC ...
+ @Description FMan dTSEC driver
*//***************************************************************************/
#include "std_ext.h"
@@ -41,12 +41,13 @@
#include "string_ext.h"
#include "xx_ext.h"
#include "endian_ext.h"
-#include "crc_mac_addr_ext.h"
#include "debug_ext.h"
+#include "crc_mac_addr_ext.h"
#include "fm_common.h"
#include "dtsec.h"
-
+#include "fsl_fman_dtsec.h"
+#include "fsl_fman_dtsec_mii_acc.h"
/*****************************************************************************/
/* Internal routines */
@@ -54,255 +55,141 @@
static t_Error CheckInitParameters(t_Dtsec *p_Dtsec)
{
- if(ENET_SPEED_FROM_MODE(p_Dtsec->enetMode) >= e_ENET_SPEED_10000)
+ if (ENET_SPEED_FROM_MODE(p_Dtsec->enetMode) >= e_ENET_SPEED_10000)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Ethernet 1G MAC driver only supports 1G or lower speeds"));
- if(p_Dtsec->macId >= FM_MAX_NUM_OF_1G_MACS)
+ if (p_Dtsec->macId >= FM_MAX_NUM_OF_1G_MACS)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("macId can not be greater than the number of 1G MACs"));
- if(p_Dtsec->addr == 0)
+ if (p_Dtsec->addr == 0)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Ethernet MAC Must have a valid MAC Address"));
- if(((p_Dtsec->enetMode == e_ENET_MODE_SGMII_1000) ||
- (p_Dtsec->enetMode == e_ENET_MODE_RGMII_1000) ||
- (p_Dtsec->enetMode == e_ENET_MODE_QSGMII_1000)) &&
- p_Dtsec->p_DtsecDriverParam->halfDuplex)
+ if ((ENET_SPEED_FROM_MODE(p_Dtsec->enetMode) >= e_ENET_SPEED_1000) &&
+ p_Dtsec->p_DtsecDriverParam->halfdup_on)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Ethernet MAC 1G can't work in half duplex"));
- if(p_Dtsec->p_DtsecDriverParam->halfDuplex && (p_Dtsec->p_DtsecDriverParam)->loopback)
+ if (p_Dtsec->p_DtsecDriverParam->halfdup_on && (p_Dtsec->p_DtsecDriverParam)->loopback)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("LoopBack is not supported in halfDuplex mode"));
-#ifdef FM_NO_RX_PREAM_ERRATA_DTSECx1
- if(p_Dtsec->p_DtsecDriverParam->preambleRxEn)
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("preambleRxEn"));
-#endif /* FM_NO_RX_PREAM_ERRATA_DTSECx1 */
- if(((p_Dtsec->p_DtsecDriverParam)->preambleTxEn || (p_Dtsec->p_DtsecDriverParam)->preambleRxEn) &&( (p_Dtsec->p_DtsecDriverParam)->preambleLength != 0x7))
+#ifdef FM_RX_PREAM_4_ERRATA_DTSEC_A001
+ if (p_Dtsec->fmMacControllerDriver.fmRevInfo.majorRev <= 6) /* fixed for rev3 */
+ if (p_Dtsec->p_DtsecDriverParam->rx_preamble)
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("preambleRxEn"));
+#endif /* FM_RX_PREAM_4_ERRATA_DTSEC_A001 */
+ if (((p_Dtsec->p_DtsecDriverParam)->tx_preamble || (p_Dtsec->p_DtsecDriverParam)->rx_preamble) &&( (p_Dtsec->p_DtsecDriverParam)->preamble_len != 0x7))
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Preamble length should be 0x7 bytes"));
- if((p_Dtsec->p_DtsecDriverParam)->fifoTxWatermarkH<((p_Dtsec->p_DtsecDriverParam)->fifoTxThr+8))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fifoTxWatermarkH has to be at least 8 larger than fifoTxThr"));
- if((p_Dtsec->p_DtsecDriverParam)->halfDuplex &&
- (p_Dtsec->p_DtsecDriverParam->txTimeStampEn || p_Dtsec->p_DtsecDriverParam->rxTimeStampEn))
+ if ((p_Dtsec->p_DtsecDriverParam)->halfdup_on &&
+ (p_Dtsec->p_DtsecDriverParam->tx_time_stamp_en || p_Dtsec->p_DtsecDriverParam->rx_time_stamp_en))
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dTSEC in half duplex mode has to be with 1588 timeStamping diable"));
- if((p_Dtsec->p_DtsecDriverParam)->actOnRxPauseFrame && (p_Dtsec->p_DtsecDriverParam)->controlFrameAccept )
+ if ((p_Dtsec->p_DtsecDriverParam)->rx_flow && (p_Dtsec->p_DtsecDriverParam)->rx_ctrl_acc )
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Receive control frame are not passed to the system memory so it can not be accept "));
- if((p_Dtsec->p_DtsecDriverParam)->packetAlignmentPadding > MAX_PACKET_ALIGNMENT)
+ if ((p_Dtsec->p_DtsecDriverParam)->rx_prepend > MAX_PACKET_ALIGNMENT)
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("packetAlignmentPadding can't be greater than %d ",MAX_PACKET_ALIGNMENT ));
- if(((p_Dtsec->p_DtsecDriverParam)->nonBackToBackIpg1 > MAX_INTER_PACKET_GAP) ||
- ((p_Dtsec->p_DtsecDriverParam)->nonBackToBackIpg2 > MAX_INTER_PACKET_GAP) ||
- ((p_Dtsec->p_DtsecDriverParam)->backToBackIpg > MAX_INTER_PACKET_GAP))
+ if (((p_Dtsec->p_DtsecDriverParam)->non_back_to_back_ipg1 > MAX_INTER_PACKET_GAP) ||
+ ((p_Dtsec->p_DtsecDriverParam)->non_back_to_back_ipg2 > MAX_INTER_PACKET_GAP) ||
+ ((p_Dtsec->p_DtsecDriverParam)->back_to_back_ipg > MAX_INTER_PACKET_GAP))
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inter packet gap can't be greater than %d ",MAX_INTER_PACKET_GAP ));
- if((p_Dtsec->p_DtsecDriverParam)->alternateBackoffVal > MAX_INTER_PALTERNATE_BEB)
+ if ((p_Dtsec->p_DtsecDriverParam)->halfdup_alt_backoff_val > MAX_INTER_PALTERNATE_BEB)
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("alternateBackoffVal can't be greater than %d ",MAX_INTER_PALTERNATE_BEB ));
- if((p_Dtsec->p_DtsecDriverParam)->maxRetransmission > MAX_RETRANSMISSION)
+ if ((p_Dtsec->p_DtsecDriverParam)->halfdup_retransmit > MAX_RETRANSMISSION)
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("maxRetransmission can't be greater than %d ",MAX_RETRANSMISSION ));
- if((p_Dtsec->p_DtsecDriverParam)->collisionWindow > MAX_COLLISION_WINDOW)
+ if ((p_Dtsec->p_DtsecDriverParam)->halfdup_coll_window > MAX_COLLISION_WINDOW)
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("collisionWindow can't be greater than %d ",MAX_COLLISION_WINDOW ));
/* If Auto negotiation process is disabled, need to */
/* Set up the PHY using the MII Management Interface */
- if (p_Dtsec->p_DtsecDriverParam->tbiPhyAddr > MAX_PHYS)
+ if (p_Dtsec->p_DtsecDriverParam->tbipa > MAX_PHYS)
RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, ("PHY address (should be 0-%d)", MAX_PHYS));
- if(!p_Dtsec->f_Exception)
+ if (!p_Dtsec->f_Exception)
RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("uninitialized f_Exception"));
- if(!p_Dtsec->f_Event)
+ if (!p_Dtsec->f_Event)
RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("uninitialized f_Event"));
- return E_OK;
-}
-static uint8_t GetMiiDiv(int32_t refClk)
-{
- uint32_t div,tmpClk;
- int minRange;
-
- div = 1;
- minRange = (int)(refClk/40 - 1);
-
- tmpClk = (uint32_t)ABS(refClk/60 - 1);
- if (tmpClk < minRange)
- {
- div = 2;
- minRange = (int)tmpClk;
- }
- tmpClk = (uint32_t)ABS(refClk/60 - 1);
- if (tmpClk < minRange)
- {
- div = 3;
- minRange = (int)tmpClk;
- }
- tmpClk = (uint32_t)ABS(refClk/80 - 1);
- if (tmpClk < minRange)
- {
- div = 4;
- minRange = (int)tmpClk;
- }
- tmpClk = (uint32_t)ABS(refClk/100 - 1);
- if (tmpClk < minRange)
- {
- div = 5;
- minRange = (int)tmpClk;
- }
- tmpClk = (uint32_t)ABS(refClk/140 - 1);
- if (tmpClk < minRange)
- {
- div = 6;
- minRange = (int)tmpClk;
- }
- tmpClk = (uint32_t)ABS(refClk/280 - 1);
- if (tmpClk < minRange)
- {
- div = 7;
- minRange = (int)tmpClk;
- }
+#ifdef FM_LEN_CHECK_ERRATA_FMAN_SW002
+ if (p_Dtsec->p_DtsecDriverParam->rx_len_check)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("LengthCheck!"));
+#endif /* FM_LEN_CHECK_ERRATA_FMAN_SW002 */
- return (uint8_t)div;
+ return E_OK;
}
-/* ........................................................................... */
-
-static void SetDefaultParam(t_DtsecDriverParam *p_DtsecDriverParam)
-{
- p_DtsecDriverParam->errorDisabled = DEFAULT_errorDisabled;
-
- p_DtsecDriverParam->promiscuousEnable = DEFAULT_promiscuousEnable;
-
- p_DtsecDriverParam->pauseExtended = DEFAULT_pauseExtended;
- p_DtsecDriverParam->pauseTime = DEFAULT_pauseTime;
-
- p_DtsecDriverParam->halfDuplex = DEFAULT_halfDuplex;
- p_DtsecDriverParam->halfDulexFlowControlEn = DEFAULT_halfDulexFlowControlEn;
- p_DtsecDriverParam->txTimeStampEn = DEFAULT_txTimeStampEn;
- p_DtsecDriverParam->rxTimeStampEn = DEFAULT_rxTimeStampEn;
-
- p_DtsecDriverParam->packetAlignmentPadding = DEFAULT_packetAlignment;
- p_DtsecDriverParam->controlFrameAccept = DEFAULT_controlFrameAccept;
- p_DtsecDriverParam->groupHashExtend = DEFAULT_groupHashExtend;
- p_DtsecDriverParam->broadcReject = DEFAULT_broadcReject;
- p_DtsecDriverParam->rxShortFrame = DEFAULT_rxShortFrame;
- p_DtsecDriverParam->exactMatch = DEFAULT_exactMatch;
- p_DtsecDriverParam->debugMode = DEFAULT_debugMode;
-
- p_DtsecDriverParam->loopback = DEFAULT_loopback;
- p_DtsecDriverParam->tbiPhyAddr = DEFAULT_tbiPhyAddr;
- p_DtsecDriverParam->actOnRxPauseFrame = DEFAULT_actOnRxPauseFrame;
- p_DtsecDriverParam->actOnTxPauseFrame = DEFAULT_actOnTxPauseFrame;
-
- p_DtsecDriverParam->preambleLength = DEFAULT_PreAmLength;
- p_DtsecDriverParam->preambleRxEn = DEFAULT_PreAmRxEn;
- p_DtsecDriverParam->preambleTxEn = DEFAULT_PreAmTxEn;
- p_DtsecDriverParam->lengthCheckEnable = DEFAULT_lengthCheckEnable;
- p_DtsecDriverParam->padAndCrcEnable = DEFAULT_padAndCrcEnable;
- p_DtsecDriverParam->crcEnable = DEFAULT_crcEnable;
-
- p_DtsecDriverParam->nonBackToBackIpg1 = DEFAULT_nonBackToBackIpg1;
- p_DtsecDriverParam->nonBackToBackIpg2 = DEFAULT_nonBackToBackIpg2;
- p_DtsecDriverParam->minIfgEnforcement = DEFAULT_minIfgEnforcement;
- p_DtsecDriverParam->backToBackIpg = DEFAULT_backToBackIpg;
-
- p_DtsecDriverParam->alternateBackoffVal = DEFAULT_altBackoffVal;
- p_DtsecDriverParam->alternateBackoffEnable = DEFAULT_altBackoffEnable;
- p_DtsecDriverParam->backPressureNoBackoff = DEFAULT_backPressureNoBackoff;
- p_DtsecDriverParam->noBackoff = DEFAULT_noBackoff;
- p_DtsecDriverParam->excessDefer = DEFAULT_excessDefer;
- p_DtsecDriverParam->maxRetransmission = DEFAULT_maxRetransmission;
- p_DtsecDriverParam->collisionWindow = DEFAULT_collisionWindow;
-
- p_DtsecDriverParam->maxFrameLength = DEFAULT_maxFrameLength;
-
- p_DtsecDriverParam->fifoTxThr = DEFAULT_fifoTxThr;
- p_DtsecDriverParam->fifoTxWatermarkH = DEFAULT_fifoTxWatermarkH;
-
- p_DtsecDriverParam->fifoRxWatermarkL = DEFAULT_fifoRxWatermarkL;
-}
+/* ......................................................................... */
-static void DtsecException(t_Handle h_Dtsec)
+static uint32_t GetMacAddrHashCode(uint64_t ethAddr)
{
- t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
- uint32_t event;
- t_DtsecMemMap *p_DtsecMemMap;
-
- ASSERT_COND(p_Dtsec);
- p_DtsecMemMap = p_Dtsec->p_MemMap;
- ASSERT_COND(p_DtsecMemMap);
+ uint32_t crc;
- event = GET_UINT32(p_DtsecMemMap->ievent);
- /* handle only MDIO events */
- event &= (IMASK_MMRDEN | IMASK_MMWREN);
- if(event)
- {
- event &= GET_UINT32(p_DtsecMemMap->imask);
+ /* CRC calculation */
+ GET_MAC_ADDR_CRC(ethAddr, crc);
- WRITE_UINT32(p_DtsecMemMap->ievent, event);
+ crc = GetMirror32(crc);
- if(event & IMASK_MMRDEN)
- p_Dtsec->f_Event(p_Dtsec->h_App, e_FM_MAC_EX_1G_MII_MNG_RD_COMPLET);
- if(event & IMASK_MMWREN)
- p_Dtsec->f_Event(p_Dtsec->h_App, e_FM_MAC_EX_1G_MII_MNG_WR_COMPLET);
- }
+ return crc;
}
+/* ......................................................................... */
+
static void UpdateStatistics(t_Dtsec *p_Dtsec)
{
- t_DtsecMemMap *p_DtsecMemMap = p_Dtsec->p_MemMap;
- uint32_t car1 = GET_UINT32(p_DtsecMemMap->car1);
- uint32_t car2 = GET_UINT32(p_DtsecMemMap->car2);
+ uint32_t car1, car2;
- if(car1)
+ fman_dtsec_get_clear_carry_regs(p_Dtsec->p_MemMap, &car1, &car2);
+
+ if (car1)
{
- WRITE_UINT32(p_DtsecMemMap->car1, car1);
- if(car1 & CAR1_TR64)
+ if (car1 & CAR1_TR64)
p_Dtsec->internalStatistics.tr64 += VAL22BIT;
- if(car1 & CAR1_TR127)
+ if (car1 & CAR1_TR127)
p_Dtsec->internalStatistics.tr127 += VAL22BIT;
- if(car1 & CAR1_TR255)
+ if (car1 & CAR1_TR255)
p_Dtsec->internalStatistics.tr255 += VAL22BIT;
- if(car1 & CAR1_TR511)
+ if (car1 & CAR1_TR511)
p_Dtsec->internalStatistics.tr511 += VAL22BIT;
- if(car1 & CAR1_TRK1)
+ if (car1 & CAR1_TRK1)
p_Dtsec->internalStatistics.tr1k += VAL22BIT;
- if(car1 & CAR1_TRMAX)
+ if (car1 & CAR1_TRMAX)
p_Dtsec->internalStatistics.trmax += VAL22BIT;
- if(car1 & CAR1_TRMGV)
+ if (car1 & CAR1_TRMGV)
p_Dtsec->internalStatistics.trmgv += VAL22BIT;
- if(car1 & CAR1_RBYT)
+ if (car1 & CAR1_RBYT)
p_Dtsec->internalStatistics.rbyt += (uint64_t)VAL32BIT;
- if(car1 & CAR1_RPKT)
+ if (car1 & CAR1_RPKT)
p_Dtsec->internalStatistics.rpkt += VAL22BIT;
- if(car1 & CAR1_RMCA)
+ if (car1 & CAR1_RMCA)
p_Dtsec->internalStatistics.rmca += VAL22BIT;
- if(car1 & CAR1_RBCA)
+ if (car1 & CAR1_RBCA)
p_Dtsec->internalStatistics.rbca += VAL22BIT;
- if(car1 & CAR1_RXPF)
+ if (car1 & CAR1_RXPF)
p_Dtsec->internalStatistics.rxpf += VAL16BIT;
- if(car1 & CAR1_RALN)
+ if (car1 & CAR1_RALN)
p_Dtsec->internalStatistics.raln += VAL16BIT;
- if(car1 & CAR1_RFLR)
+ if (car1 & CAR1_RFLR)
p_Dtsec->internalStatistics.rflr += VAL16BIT;
- if(car1 & CAR1_RCDE)
+ if (car1 & CAR1_RCDE)
p_Dtsec->internalStatistics.rcde += VAL16BIT;
- if(car1 & CAR1_RCSE)
+ if (car1 & CAR1_RCSE)
p_Dtsec->internalStatistics.rcse += VAL16BIT;
- if(car1 & CAR1_RUND)
+ if (car1 & CAR1_RUND)
p_Dtsec->internalStatistics.rund += VAL16BIT;
- if(car1 & CAR1_ROVR)
+ if (car1 & CAR1_ROVR)
p_Dtsec->internalStatistics.rovr += VAL16BIT;
- if(car1 & CAR1_RFRG)
+ if (car1 & CAR1_RFRG)
p_Dtsec->internalStatistics.rfrg += VAL16BIT;
- if(car1 & CAR1_RJBR)
+ if (car1 & CAR1_RJBR)
p_Dtsec->internalStatistics.rjbr += VAL16BIT;
- if(car1 & CAR1_RDRP)
+ if (car1 & CAR1_RDRP)
p_Dtsec->internalStatistics.rdrp += VAL16BIT;
}
- if(car2)
+ if (car2)
{
- WRITE_UINT32(p_DtsecMemMap->car2, car2);
- if(car2 & CAR2_TFCS)
+ if (car2 & CAR2_TFCS)
p_Dtsec->internalStatistics.tfcs += VAL12BIT;
- if(car2 & CAR2_TBYT)
+ if (car2 & CAR2_TBYT)
p_Dtsec->internalStatistics.tbyt += (uint64_t)VAL32BIT;
- if(car2 & CAR2_TPKT)
+ if (car2 & CAR2_TPKT)
p_Dtsec->internalStatistics.tpkt += VAL22BIT;
- if(car2 & CAR2_TMCA)
+ if (car2 & CAR2_TMCA)
p_Dtsec->internalStatistics.tmca += VAL22BIT;
- if(car2 & CAR2_TBCA)
+ if (car2 & CAR2_TBCA)
p_Dtsec->internalStatistics.tbca += VAL22BIT;
- if(car2 & CAR2_TXPF)
+ if (car2 & CAR2_TXPF)
p_Dtsec->internalStatistics.txpf += VAL16BIT;
- if(car2 & CAR2_TDRP)
+ if (car2 & CAR2_TDRP)
p_Dtsec->internalStatistics.tdrp += VAL16BIT;
}
}
@@ -311,145 +198,163 @@ static void UpdateStatistics(t_Dtsec *p_Dtsec)
static uint16_t DtsecGetMaxFrameLength(t_Handle h_Dtsec)
{
- t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
SANITY_CHECK_RETURN_VALUE(p_Dtsec, E_INVALID_HANDLE, 0);
+ SANITY_CHECK_RETURN_VALUE(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE, 0);
- return (uint16_t)GET_UINT32(p_Dtsec->p_MemMap->maxfrm);
+ return fman_dtsec_get_max_frame_len(p_Dtsec->p_MemMap);
}
-static void DtsecErrException(t_Handle h_Dtsec)
+/* .............................................................................. */
+
+static void DtsecIsr(t_Handle h_Dtsec)
{
t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
uint32_t event;
- t_DtsecMemMap *p_DtsecMemMap = p_Dtsec->p_MemMap;
+ struct dtsec_regs *p_DtsecMemMap = p_Dtsec->p_MemMap;
- event = GET_UINT32(p_DtsecMemMap->ievent);
/* do not handle MDIO events */
- event &= ~(IMASK_MMRDEN | IMASK_MMWREN);
+ event = fman_dtsec_get_event(p_DtsecMemMap, (uint32_t)(~(DTSEC_IMASK_MMRDEN | DTSEC_IMASK_MMWREN)));
- event &= GET_UINT32(p_DtsecMemMap->imask);
+ event &= fman_dtsec_get_interrupt_mask(p_DtsecMemMap);
- WRITE_UINT32(p_DtsecMemMap->ievent, event);
+ fman_dtsec_ack_event(p_DtsecMemMap, event);
- if(event & IMASK_BREN)
+ if (event & DTSEC_IMASK_BREN)
p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_BAB_RX);
- if(event & IMASK_RXCEN)
+ if (event & DTSEC_IMASK_RXCEN)
p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_RX_CTL);
- if(event & IMASK_MSROEN)
+ if (event & DTSEC_IMASK_MSROEN)
UpdateStatistics(p_Dtsec);
- if(event & IMASK_GTSCEN)
+ if (event & DTSEC_IMASK_GTSCEN)
p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_GRATEFUL_TX_STP_COMPLET);
- if(event & IMASK_BTEN)
+ if (event & DTSEC_IMASK_BTEN)
p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_BAB_TX);
- if(event & IMASK_TXCEN)
+ if (event & DTSEC_IMASK_TXCEN)
p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_TX_CTL);
- if(event & IMASK_TXEEN)
+ if (event & DTSEC_IMASK_TXEEN)
p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_TX_ERR);
- if(event & IMASK_LCEN)
+ if (event & DTSEC_IMASK_LCEN)
p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_LATE_COL);
- if(event & IMASK_CRLEN)
+ if (event & DTSEC_IMASK_CRLEN)
p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_COL_RET_LMT);
- if(event & IMASK_XFUNEN)
+ if (event & DTSEC_IMASK_XFUNEN)
{
#ifdef FM_TX_LOCKUP_ERRATA_DTSEC6
- uint32_t tpkt1, tmpReg1, tpkt2, tmpReg2, i;
- /* a. Write 0x00E0_0C00 to DTSEC_ID */
- /* This is a read only regidter */
-
- /* b. Read and save the value of TPKT */
- tpkt1 = GET_UINT32(p_DtsecMemMap->tpkt);
-
- /* c. Read the register at dTSEC address offset 0x32C */
- tmpReg1 = GET_UINT32(*(uint32_t*)((uint8_t*)p_DtsecMemMap + 0x32c));
-
- /* d. Compare bits [9:15] to bits [25:31] of the register at address offset 0x32C. */
- if((tmpReg1 & 0x007F0000) != (tmpReg1 & 0x0000007F))
+ if (p_Dtsec->fmMacControllerDriver.fmRevInfo.majorRev == 2)
{
- /* If they are not equal, save the value of this register and wait for at least
- * MAXFRM*16 ns */
- XX_UDelay((uint32_t)(NCSW_MIN(DtsecGetMaxFrameLength(p_Dtsec)*16/1000, 1)));
- }
-
- /* e. Read and save TPKT again and read the register at dTSEC address offset
- 0x32C again*/
- tpkt2 = GET_UINT32(p_DtsecMemMap->tpkt);
- tmpReg2 = GET_UINT32(*(uint32_t*)((uint8_t*)p_DtsecMemMap + 0x32c));
-
- /* f. Compare the value of TPKT saved in step b to value read in step e. Also
- compare bits [9:15] of the register at offset 0x32C saved in step d to the value
- of bits [9:15] saved in step e. If the two registers values are unchanged, then
- the transmit portion of the dTSEC controller is locked up and the user should
- proceed to the recover sequence. */
- if((tpkt1 == tpkt2) && ((tmpReg1 & 0x007F0000) == (tmpReg2 & 0x007F0000)))
- {
- /* recover sequence */
+ uint32_t tpkt1, tmpReg1, tpkt2, tmpReg2, i;
+ /* a. Write 0x00E0_0C00 to DTSEC_ID */
+ /* This is a read only regidter */
- /* a.Write a 1 to RCTRL[GRS]*/
+ /* b. Read and save the value of TPKT */
+ tpkt1 = GET_UINT32(p_DtsecMemMap->tpkt);
- WRITE_UINT32(p_DtsecMemMap->rctrl, GET_UINT32(p_DtsecMemMap->rctrl) | RCTRL_GRS);
+ /* c. Read the register at dTSEC address offset 0x32C */
+ tmpReg1 = GET_UINT32(*(uint32_t*)((uint8_t*)p_DtsecMemMap + 0x32c));
- /* b.Wait until IEVENT[GRSC]=1, or at least 100 us has elapsed. */
- for(i = 0 ; i < 100 ; i++ )
+ /* d. Compare bits [9:15] to bits [25:31] of the register at address offset 0x32C. */
+ if ((tmpReg1 & 0x007F0000) != (tmpReg1 & 0x0000007F))
{
- if(GET_UINT32(p_DtsecMemMap->ievent) & IMASK_GRSCEN)
- break;
- XX_UDelay(1);
+ /* If they are not equal, save the value of this register and wait for at least
+ * MAXFRM*16 ns */
+ XX_UDelay((uint32_t)(MIN(DtsecGetMaxFrameLength(p_Dtsec)*16/1000, 1)));
}
- if(GET_UINT32(p_DtsecMemMap->ievent) & IMASK_GRSCEN)
- WRITE_UINT32(p_DtsecMemMap->ievent, IMASK_GRSCEN);
- else
- DBG(INFO,("Rx lockup due to dTSEC Tx lockup"));
+ /* e. Read and save TPKT again and read the register at dTSEC address offset
+ 0x32C again*/
+ tpkt2 = GET_UINT32(p_DtsecMemMap->tpkt);
+ tmpReg2 = GET_UINT32(*(uint32_t*)((uint8_t*)p_DtsecMemMap + 0x32c));
+
+ /* f. Compare the value of TPKT saved in step b to value read in step e. Also
+ compare bits [9:15] of the register at offset 0x32C saved in step d to the value
+ of bits [9:15] saved in step e. If the two registers values are unchanged, then
+ the transmit portion of the dTSEC controller is locked up and the user should
+ proceed to the recover sequence. */
+ if ((tpkt1 == tpkt2) && ((tmpReg1 & 0x007F0000) == (tmpReg2 & 0x007F0000)))
+ {
+ /* recover sequence */
- /* c.Write a 1 to bit n of FM_RSTC (offset 0x0CC of FPM)*/
- FmResetMac(p_Dtsec->fmMacControllerDriver.h_Fm, e_FM_MAC_1G, p_Dtsec->fmMacControllerDriver.macId);
+ /* a.Write a 1 to RCTRL[GRS]*/
- /* d.Wait 4 Tx clocks (32 ns) */
- XX_UDelay(1);
+ WRITE_UINT32(p_DtsecMemMap->rctrl, GET_UINT32(p_DtsecMemMap->rctrl) | RCTRL_GRS);
- /* e.Write a 0 to bit n of FM_RSTC. */
- /* cleared by FMAN */
- }
- else
- {
- /* If either value has changed, the dTSEC controller is not locked up and the
- controller should be allowed to proceed normally by writing the reset value
- of 0x0824_0101 to DTSEC_ID. */
- /* Register is read only */
+ /* b.Wait until IEVENT[GRSC]=1, or at least 100 us has elapsed. */
+ for (i = 0 ; i < 100 ; i++ )
+ {
+ if (GET_UINT32(p_DtsecMemMap->ievent) & DTSEC_IMASK_GRSCEN)
+ break;
+ XX_UDelay(1);
+ }
+ if (GET_UINT32(p_DtsecMemMap->ievent) & DTSEC_IMASK_GRSCEN)
+ WRITE_UINT32(p_DtsecMemMap->ievent, DTSEC_IMASK_GRSCEN);
+ else
+ DBG(INFO,("Rx lockup due to dTSEC Tx lockup"));
+
+ /* c.Write a 1 to bit n of FM_RSTC (offset 0x0CC of FPM)*/
+ FmResetMac(p_Dtsec->fmMacControllerDriver.h_Fm, e_FM_MAC_1G, p_Dtsec->fmMacControllerDriver.macId);
+
+ /* d.Wait 4 Tx clocks (32 ns) */
+ XX_UDelay(1);
+
+ /* e.Write a 0 to bit n of FM_RSTC. */
+ /* cleared by FMAN */
+ }
}
#endif /* FM_TX_LOCKUP_ERRATA_DTSEC6 */
p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_TX_FIFO_UNDRN);
}
- if(event & IMASK_MAGEN)
+ if (event & DTSEC_IMASK_MAGEN)
p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_MAG_PCKT);
- if(event & IMASK_GRSCEN)
+ if (event & DTSEC_IMASK_GRSCEN)
p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_GRATEFUL_RX_STP_COMPLET);
- if(event & IMASK_TDPEEN)
+ if (event & DTSEC_IMASK_TDPEEN)
p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_TX_DATA_ERR);
- if(event & IMASK_RDPEEN)
+ if (event & DTSEC_IMASK_RDPEEN)
p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_RX_DATA_ERR);
/* - masked interrupts */
- ASSERT_COND(!(event & IMASK_ABRTEN));
- ASSERT_COND(!(event & IMASK_IFERREN));
+ ASSERT_COND(!(event & DTSEC_IMASK_ABRTEN));
+ ASSERT_COND(!(event & DTSEC_IMASK_IFERREN));
+}
+
+static void DtsecMdioIsr(t_Handle h_Dtsec)
+{
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
+ uint32_t event;
+ struct dtsec_regs *p_DtsecMemMap = p_Dtsec->p_MemMap;
+
+ event = GET_UINT32(p_DtsecMemMap->ievent);
+ /* handle only MDIO events */
+ event &= (DTSEC_IMASK_MMRDEN | DTSEC_IMASK_MMWREN);
+ if (event)
+ {
+ event &= GET_UINT32(p_DtsecMemMap->imask);
+
+ WRITE_UINT32(p_DtsecMemMap->ievent, event);
+
+ if (event & DTSEC_IMASK_MMRDEN)
+ p_Dtsec->f_Event(p_Dtsec->h_App, e_FM_MAC_EX_1G_MII_MNG_RD_COMPLET);
+ if (event & DTSEC_IMASK_MMWREN)
+ p_Dtsec->f_Event(p_Dtsec->h_App, e_FM_MAC_EX_1G_MII_MNG_WR_COMPLET);
+ }
}
-static void Dtsec1588Exception(t_Handle h_Dtsec)
+static void Dtsec1588Isr(t_Handle h_Dtsec)
{
t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
uint32_t event;
- t_DtsecMemMap *p_DtsecMemMap = p_Dtsec->p_MemMap;
+ struct dtsec_regs *p_DtsecMemMap = p_Dtsec->p_MemMap;
if (p_Dtsec->ptpTsuEnabled)
{
- event = GET_UINT32(p_DtsecMemMap->tmr_pevent);
- event &= GET_UINT32(p_DtsecMemMap->tmr_pemask);
- if(event)
+ event = fman_dtsec_check_and_clear_tmr_event(p_DtsecMemMap);
+
+ if (event)
{
- WRITE_UINT32(p_DtsecMemMap->tmr_pevent, event);
- ASSERT_COND(event & PEMASK_TSRE);
+ ASSERT_COND(event & TMR_PEVENT_TSRE);
p_Dtsec->f_Exception(p_Dtsec->h_App, e_FM_MAC_EX_1G_1588_TS_RX_ERR);
}
}
@@ -459,16 +364,13 @@ static void Dtsec1588Exception(t_Handle h_Dtsec)
static void FreeInitResources(t_Dtsec *p_Dtsec)
{
- /*TODO - need to ask why with mdioIrq != 0*/
- if ((p_Dtsec->mdioIrq != 0) && (p_Dtsec->mdioIrq != NO_IRQ))
+ if (p_Dtsec->mdioIrq != NO_IRQ)
{
XX_DisableIntr(p_Dtsec->mdioIrq);
XX_FreeIntr(p_Dtsec->mdioIrq);
}
- else if (p_Dtsec->mdioIrq == 0)
- FmUnregisterIntr(p_Dtsec->fmMacControllerDriver.h_Fm, e_FM_MOD_1G_MAC, p_Dtsec->macId, e_FM_INTR_TYPE_NORMAL);
FmUnregisterIntr(p_Dtsec->fmMacControllerDriver.h_Fm, e_FM_MOD_1G_MAC, p_Dtsec->macId, e_FM_INTR_TYPE_ERR);
- FmUnregisterIntr(p_Dtsec->fmMacControllerDriver.h_Fm, e_FM_MOD_1G_MAC_TMR, p_Dtsec->macId, e_FM_INTR_TYPE_NORMAL);
+ FmUnregisterIntr(p_Dtsec->fmMacControllerDriver.h_Fm, e_FM_MOD_1G_MAC, p_Dtsec->macId, e_FM_INTR_TYPE_NORMAL);
/* release the driver's group hash table */
FreeHashTable(p_Dtsec->p_MulticastAddrHash);
@@ -481,56 +383,41 @@ static void FreeInitResources(t_Dtsec *p_Dtsec)
/* ........................................................................... */
-static void HardwareClearAddrInPaddr(t_Dtsec *p_Dtsec, uint8_t paddrNum)
-{
- WRITE_UINT32(((t_DtsecMemMap*)p_Dtsec->p_MemMap)->macaddr[paddrNum].exact_match1, 0x0);
- WRITE_UINT32(((t_DtsecMemMap*)p_Dtsec->p_MemMap)->macaddr[paddrNum].exact_match2, 0x0);
-}
-
-/* ........................................................................... */
-
-static void HardwareAddAddrInPaddr(t_Dtsec *p_Dtsec, uint64_t *p_Addr, uint8_t paddrNum)
-{
- uint32_t tmpReg32 = 0;
- uint64_t addr = *p_Addr;
- t_DtsecMemMap *p_DtsecMemMap = (t_DtsecMemMap*)p_Dtsec->p_MemMap;
-
- tmpReg32 = (uint32_t)(addr);
- SwapUint32P(&tmpReg32);
- WRITE_UINT32(p_DtsecMemMap->macaddr[paddrNum].exact_match1, tmpReg32);
-
- tmpReg32 = (uint32_t)(addr>>32);
- SwapUint32P(&tmpReg32);
- WRITE_UINT32(p_DtsecMemMap->macaddr[paddrNum].exact_match2, tmpReg32);
-}
-
-/* ........................................................................... */
-
static t_Error GracefulStop(t_Dtsec *p_Dtsec, e_CommMode mode)
{
- t_DtsecMemMap *p_MemMap;
+ struct dtsec_regs *p_MemMap;
ASSERT_COND(p_Dtsec);
- p_MemMap= (t_DtsecMemMap*)(p_Dtsec->p_MemMap);
+ p_MemMap = p_Dtsec->p_MemMap;
ASSERT_COND(p_MemMap);
/* Assert the graceful transmit stop bit */
if (mode & e_COMM_MODE_RX)
- WRITE_UINT32(p_MemMap->rctrl,
- GET_UINT32(p_MemMap->rctrl) | RCTRL_GRS);
+ {
+ fman_dtsec_stop_rx(p_MemMap);
#ifdef FM_GRS_ERRATA_DTSEC_A002
- XX_UDelay(100);
+ if (p_Dtsec->fmMacControllerDriver.fmRevInfo.majorRev == 2)
+ XX_UDelay(100);
+#else /* FM_GRS_ERRATA_DTSEC_A002 */
+#ifdef FM_GTS_AFTER_DROPPED_FRAME_ERRATA_DTSEC_A004839
+ XX_UDelay(10);
+#endif /* FM_GTS_AFTER_DROPPED_FRAME_ERRATA_DTSEC_A004839 */
#endif /* FM_GRS_ERRATA_DTSEC_A002 */
+ }
-#ifdef FM_GTS_ERRATA_DTSEC_A004
- DBG(INFO, ("GTS not supported due to DTSEC_A004 errata."));
-#else /* not FM_GTS_ERRATA_DTSEC_A004 */
if (mode & e_COMM_MODE_TX)
- WRITE_UINT32(p_MemMap->tctrl,
- GET_UINT32(p_MemMap->tctrl) | TCTRL_GTS);
-#endif /* not FM_GTS_ERRATA_DTSEC_A004 */
+#if defined(FM_GTS_ERRATA_DTSEC_A004) || defined(FM_GTS_AFTER_MAC_ABORTED_FRAME_ERRATA_DTSEC_A0012)
+ if (p_Dtsec->fmMacControllerDriver.fmRevInfo.majorRev == 2)
+ DBG(INFO, ("GTS not supported due to DTSEC_A004 errata."));
+#else /* not defined(FM_GTS_ERRATA_DTSEC_A004) ||... */
+#ifdef FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014
+ DBG(INFO, ("GTS not supported due to DTSEC_A0014 errata."));
+#else /* FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014 */
+ fman_dtsec_stop_tx(p_MemMap);
+#endif /* FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014 */
+#endif /* defined(FM_GTS_ERRATA_DTSEC_A004) ||... */
return E_OK;
}
@@ -539,21 +426,18 @@ static t_Error GracefulStop(t_Dtsec *p_Dtsec, e_CommMode mode)
static t_Error GracefulRestart(t_Dtsec *p_Dtsec, e_CommMode mode)
{
- t_DtsecMemMap *p_MemMap;
+ struct dtsec_regs *p_MemMap;
ASSERT_COND(p_Dtsec);
-
- p_MemMap= (t_DtsecMemMap*)(p_Dtsec->p_MemMap);
+ p_MemMap = p_Dtsec->p_MemMap;
ASSERT_COND(p_MemMap);
/* clear the graceful receive stop bit */
- if(mode & e_COMM_MODE_TX)
- WRITE_UINT32(p_MemMap->tctrl,
- GET_UINT32(p_MemMap->tctrl) & ~TCTRL_GTS);
+ if (mode & e_COMM_MODE_TX)
+ fman_dtsec_start_tx(p_MemMap);
- if(mode & e_COMM_MODE_RX)
- WRITE_UINT32(p_MemMap->rctrl,
- GET_UINT32(p_MemMap->rctrl) & ~RCTRL_GRS);
+ if (mode & e_COMM_MODE_RX)
+ fman_dtsec_start_rx(p_MemMap);
return E_OK;
}
@@ -563,7 +447,6 @@ static t_Error GracefulRestart(t_Dtsec *p_Dtsec, e_CommMode mode)
/* dTSEC Configs modification functions */
/*****************************************************************************/
-
/* .............................................................................. */
static t_Error DtsecConfigLoopback(t_Handle h_Dtsec, bool newVal)
@@ -588,7 +471,7 @@ static t_Error DtsecConfigMaxFrameLength(t_Handle h_Dtsec, uint16_t newVal)
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
- p_Dtsec->p_DtsecDriverParam->maxFrameLength = newVal;
+ p_Dtsec->p_DtsecDriverParam->maximum_frame = newVal;
return E_OK;
}
@@ -602,7 +485,7 @@ static t_Error DtsecConfigPadAndCrc(t_Handle h_Dtsec, bool newVal)
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
- p_Dtsec->p_DtsecDriverParam->padAndCrcEnable = newVal;
+ p_Dtsec->p_DtsecDriverParam->tx_pad_crc = newVal;
return E_OK;
}
@@ -616,31 +499,41 @@ static t_Error DtsecConfigHalfDuplex(t_Handle h_Dtsec, bool newVal)
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
- p_Dtsec->p_DtsecDriverParam->halfDuplex = newVal;
+ p_Dtsec->p_DtsecDriverParam->halfdup_on = newVal;
return E_OK;
}
/* .............................................................................. */
-static t_Error DtsecConfigLengthCheck(t_Handle h_Dtsec, bool newVal)
+static t_Error DtsecConfigTbiPhyAddr(t_Handle h_Dtsec, uint8_t newVal)
{
-#ifdef FM_LEN_CHECK_ERRATA_FMAN_SW002
-UNUSED(h_Dtsec);
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("LengthCheck!"));
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
+
+ p_Dtsec->p_DtsecDriverParam->tbi_phy_addr = newVal;
+
+ return E_OK;
+}
-#else
+/* .............................................................................. */
+
+static t_Error DtsecConfigLengthCheck(t_Handle h_Dtsec, bool newVal)
+{
t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
- p_Dtsec->p_DtsecDriverParam->lengthCheckEnable = newVal;
+ p_Dtsec->p_DtsecDriverParam->rx_len_check = newVal;
return E_OK;
-#endif /* FM_LEN_CHECK_ERRATA_FMAN_SW002 */
}
+/* .............................................................................. */
+
static t_Error DtsecConfigException(t_Handle h_Dtsec, e_FmMacExceptions exception, bool enable)
{
t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
@@ -649,10 +542,10 @@ static t_Error DtsecConfigException(t_Handle h_Dtsec, e_FmMacExceptions exceptio
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
- if(exception != e_FM_MAC_EX_1G_1588_TS_RX_ERR)
+ if (exception != e_FM_MAC_EX_1G_1588_TS_RX_ERR)
{
GET_EXCEPTION_FLAG(bitMask, exception);
- if(bitMask)
+ if (bitMask)
{
if (enable)
p_Dtsec->exceptions |= bitMask;
@@ -664,21 +557,19 @@ static t_Error DtsecConfigException(t_Handle h_Dtsec, e_FmMacExceptions exceptio
}
else
{
- if(!p_Dtsec->ptpTsuEnabled)
+ if (!p_Dtsec->ptpTsuEnabled)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Exception valid for 1588 only"));
- switch(exception){
- case(e_FM_MAC_EX_1G_1588_TS_RX_ERR):
- if(enable)
- p_Dtsec->enTsuErrExeption = TRUE;
- else
- p_Dtsec->enTsuErrExeption = FALSE;
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
- }
+
+ if (enable)
+ p_Dtsec->enTsuErrExeption = TRUE;
+ else
+ p_Dtsec->enTsuErrExeption = FALSE;
}
+
return E_OK;
}
+
+
/*****************************************************************************/
/* dTSEC Run Time API functions */
/*****************************************************************************/
@@ -687,21 +578,14 @@ static t_Error DtsecConfigException(t_Handle h_Dtsec, e_FmMacExceptions exceptio
static t_Error DtsecEnable(t_Handle h_Dtsec, e_CommMode mode)
{
- t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
- t_DtsecMemMap *p_MemMap ;
- uint32_t tmpReg32 = 0;
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_MemMap, E_INVALID_HANDLE);
-
- p_MemMap= (t_DtsecMemMap*)(p_Dtsec->p_MemMap);
+ SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
- tmpReg32 = GET_UINT32(p_MemMap->maccfg1);
- if (mode & e_COMM_MODE_RX)
- tmpReg32 |= MACCFG1_RX_EN;
- if (mode & e_COMM_MODE_TX)
- tmpReg32 |= MACCFG1_TX_EN;
- WRITE_UINT32(p_MemMap->maccfg1, tmpReg32);
+ fman_dtsec_enable(p_Dtsec->p_MemMap,
+ (bool)!!(mode & e_COMM_MODE_RX),
+ (bool)!!(mode & e_COMM_MODE_TX));
GracefulRestart(p_Dtsec, mode);
@@ -712,132 +596,94 @@ static t_Error DtsecEnable(t_Handle h_Dtsec, e_CommMode mode)
static t_Error DtsecDisable (t_Handle h_Dtsec, e_CommMode mode)
{
- t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
- t_DtsecMemMap *p_MemMap ;
- uint32_t tmpReg32 = 0;
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_MemMap, E_INVALID_HANDLE);
-
- p_MemMap = (t_DtsecMemMap*)(p_Dtsec->p_MemMap);
+ SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
GracefulStop(p_Dtsec, mode);
- tmpReg32 = GET_UINT32(p_MemMap->maccfg1);
- if (mode & e_COMM_MODE_RX)
- tmpReg32 &= ~MACCFG1_RX_EN;
- if (mode & e_COMM_MODE_TX)
- tmpReg32 &= ~MACCFG1_TX_EN;
- WRITE_UINT32(p_MemMap->maccfg1, tmpReg32);
+ fman_dtsec_disable(p_Dtsec->p_MemMap,
+ (bool)!!(mode & e_COMM_MODE_RX),
+ (bool)!!(mode & e_COMM_MODE_TX));
return E_OK;
}
/* .............................................................................. */
-static t_Error DtsecTxMacPause(t_Handle h_Dtsec, uint16_t pauseTime)
+static t_Error DtsecSetTxPauseFrames(t_Handle h_Dtsec,
+ uint8_t priority,
+ uint16_t pauseTime,
+ uint16_t threshTime)
{
- t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
- uint32_t ptv = 0;
- t_DtsecMemMap *p_MemMap;
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
+
+ UNUSED(priority);UNUSED(threshTime);
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_STATE);
SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
- SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_MemMap, E_INVALID_STATE);
- p_MemMap = (t_DtsecMemMap*)(p_Dtsec->p_MemMap);
-
- if (pauseTime)
- {
#ifdef FM_BAD_TX_TS_IN_B_2_B_ERRATA_DTSEC_A003
- {
- if (pauseTime <= 320)
- RETURN_ERROR(MINOR, E_INVALID_VALUE,
- ("This pause-time value of %d is illegal due to errata dTSEC-A003!"
- " value should be greater than 320."));
- }
+ if (p_Dtsec->fmMacControllerDriver.fmRevInfo.majorRev == 2)
+ if (0 < pauseTime && pauseTime <= 320)
+ RETURN_ERROR(MINOR, E_INVALID_VALUE,
+ ("This pause-time value of %d is illegal due to errata dTSEC-A003!"
+ " value should be greater than 320."));
#endif /* FM_BAD_TX_TS_IN_B_2_B_ERRATA_DTSEC_A003 */
-#ifdef FM_SHORT_PAUSE_TIME_ERRATA_DTSEC1
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_Dtsec->fmMacControllerDriver.h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- pauseTime += 2;
- }
-#endif /* FM_SHORT_PAUSE_TIME_ERRATA_DTSEC1 */
-
- ptv = GET_UINT32(p_MemMap->ptv);
- ptv |= pauseTime;
- WRITE_UINT32(p_MemMap->ptv, ptv);
-
- /* trigger the transmission of a flow-control pause frame */
- WRITE_UINT32(p_MemMap->maccfg1,
- GET_UINT32(p_MemMap->maccfg1) | MACCFG1_TX_FLOW);
- }
- else
- {
- WRITE_UINT32(p_MemMap->maccfg1,
- GET_UINT32(p_MemMap->maccfg1) & ~MACCFG1_TX_FLOW);
- }
-
+ fman_dtsec_set_tx_pause_frames(p_Dtsec->p_MemMap, pauseTime);
return E_OK;
}
/* .............................................................................. */
+/* backward compatibility. will be removed in the future. */
+static t_Error DtsecTxMacPause(t_Handle h_Dtsec, uint16_t pauseTime)
+{
+ return DtsecSetTxPauseFrames(h_Dtsec, 0, pauseTime, 0);
+}
+
+/* .............................................................................. */
static t_Error DtsecRxIgnoreMacPause(t_Handle h_Dtsec, bool en)
{
t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
- t_DtsecMemMap *p_MemMap;
- uint32_t tmpReg32;
+ bool accept_pause = !en;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_STATE);
SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
- SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_MemMap, E_INVALID_STATE);
-
- p_MemMap = (t_DtsecMemMap*)(p_Dtsec->p_MemMap);
- tmpReg32 = GET_UINT32(p_MemMap->maccfg1);
- if (en)
- tmpReg32 &= ~MACCFG1_RX_FLOW;
- else
- tmpReg32 |= MACCFG1_RX_FLOW;
- WRITE_UINT32(p_MemMap->maccfg1, tmpReg32);
+ fman_dtsec_handle_rx_pause(p_Dtsec->p_MemMap, accept_pause);
return E_OK;
}
-
/* .............................................................................. */
static t_Error DtsecEnable1588TimeStamp(t_Handle h_Dtsec)
{
- t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
-#ifdef FM_10_100_SGMII_NO_TS_ERRATA_DTSEC3
- if((p_Dtsec->enetMode == e_ENET_MODE_SGMII_10) || (p_Dtsec->enetMode == e_ENET_MODE_SGMII_100))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("1588TimeStamp in 10/100 SGMII"));
-#endif /* FM_10_100_SGMII_NO_TS_ERRATA_DTSEC3 */
+
p_Dtsec->ptpTsuEnabled = TRUE;
- WRITE_UINT32(p_Dtsec->p_MemMap->rctrl, GET_UINT32(p_Dtsec->p_MemMap->rctrl) | RCTRL_RTSE);
- WRITE_UINT32(p_Dtsec->p_MemMap->tctrl, GET_UINT32(p_Dtsec->p_MemMap->tctrl) | TCTRL_TTSE);
+ fman_dtsec_set_ts(p_Dtsec->p_MemMap, TRUE);
return E_OK;
}
+/* .............................................................................. */
+
static t_Error DtsecDisable1588TimeStamp(t_Handle h_Dtsec)
{
- t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
p_Dtsec->ptpTsuEnabled = FALSE;
- WRITE_UINT32(p_Dtsec->p_MemMap->rctrl, GET_UINT32(p_Dtsec->p_MemMap->rctrl) & ~RCTRL_RTSE);
- WRITE_UINT32(p_Dtsec->p_MemMap->tctrl, GET_UINT32(p_Dtsec->p_MemMap->tctrl) & ~TCTRL_TTSE);
+ fman_dtsec_set_ts(p_Dtsec->p_MemMap, FALSE);
return E_OK;
}
@@ -847,89 +693,84 @@ static t_Error DtsecDisable1588TimeStamp(t_Handle h_Dtsec)
static t_Error DtsecGetStatistics(t_Handle h_Dtsec, t_FmMacStatistics *p_Statistics)
{
t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
- t_DtsecMemMap *p_DtsecMemMap;
+ struct dtsec_regs *p_DtsecMemMap;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_MemMap, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
SANITY_CHECK_RETURN_ERROR(p_Statistics, E_NULL_POINTER);
+ p_DtsecMemMap = p_Dtsec->p_MemMap;
+
if (p_Dtsec->statisticsLevel == e_FM_MAC_NONE_STATISTICS)
RETURN_ERROR(MINOR, E_INVALID_STATE, ("Statistics disabled"));
- p_DtsecMemMap = p_Dtsec->p_MemMap;
memset(p_Statistics, 0xff, sizeof(t_FmMacStatistics));
if (p_Dtsec->statisticsLevel == e_FM_MAC_FULL_STATISTICS)
{
- p_Statistics->eStatPkts64 = (MASK22BIT & GET_UINT32(p_DtsecMemMap->tr64))
- + p_Dtsec->internalStatistics.tr64; /**< r-10G tr-DT 64 byte frame counter */
- p_Statistics->eStatPkts65to127 = (MASK22BIT & GET_UINT32(p_DtsecMemMap->tr127))
- + p_Dtsec->internalStatistics.tr127; /**< r-10G 65 to 127 byte frame counter */
- p_Statistics->eStatPkts128to255 = (MASK22BIT & GET_UINT32(p_DtsecMemMap->tr255))
- + p_Dtsec->internalStatistics.tr255; /**< r-10G 128 to 255 byte frame counter */
- p_Statistics->eStatPkts256to511 = (MASK22BIT & GET_UINT32(p_DtsecMemMap->tr511))
- + p_Dtsec->internalStatistics.tr511; /**< r-10G 256 to 511 byte frame counter */
- p_Statistics->eStatPkts512to1023 = (MASK22BIT & GET_UINT32(p_DtsecMemMap->tr1k))
- + p_Dtsec->internalStatistics.tr1k; /**< r-10G 512 to 1023 byte frame counter */
- p_Statistics->eStatPkts1024to1518 = (MASK22BIT & GET_UINT32(p_DtsecMemMap->trmax))
- + p_Dtsec->internalStatistics.trmax; /**< r-10G 1024 to 1518 byte frame counter */
- p_Statistics->eStatPkts1519to1522 = (MASK22BIT & GET_UINT32(p_DtsecMemMap->trmgv))
- + p_Dtsec->internalStatistics.trmgv; /**< r-10G 1519 to 1522 byte good frame count */
+ p_Statistics->eStatPkts64 = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TR64)
+ + p_Dtsec->internalStatistics.tr64;
+ p_Statistics->eStatPkts65to127 = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TR127)
+ + p_Dtsec->internalStatistics.tr127;
+ p_Statistics->eStatPkts128to255 = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TR255)
+ + p_Dtsec->internalStatistics.tr255;
+ p_Statistics->eStatPkts256to511 = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TR511)
+ + p_Dtsec->internalStatistics.tr511;
+ p_Statistics->eStatPkts512to1023 = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TR1K)
+ + p_Dtsec->internalStatistics.tr1k;
+ p_Statistics->eStatPkts1024to1518 = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TRMAX)
+ + p_Dtsec->internalStatistics.trmax;
+ p_Statistics->eStatPkts1519to1522 = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TRMGV)
+ + p_Dtsec->internalStatistics.trmgv;
+
/* MIB II */
- p_Statistics->ifInOctets = GET_UINT32(p_DtsecMemMap->rbyt)
- + p_Dtsec->internalStatistics.rbyt; /**< Total number of byte received. */
- p_Statistics->ifInPkts = (MASK22BIT & GET_UINT32(p_DtsecMemMap->rpkt))
- + p_Dtsec->internalStatistics.rpkt; /**< Total number of packets received.*/
- p_Statistics->ifInMcastPkts = (MASK22BIT & GET_UINT32(p_DtsecMemMap->rmca))
- + p_Dtsec->internalStatistics.rmca; /**< Total number of multicast frame received*/
- p_Statistics->ifInBcastPkts = (MASK22BIT & GET_UINT32(p_DtsecMemMap->rbca))
- + p_Dtsec->internalStatistics.rbca; /**< Total number of broadcast frame received */
- p_Statistics->ifOutOctets = GET_UINT32(p_DtsecMemMap->tbyt)
- + p_Dtsec->internalStatistics.tbyt; /**< Total number of byte sent. */
- p_Statistics->ifOutPkts = (MASK22BIT & GET_UINT32(p_DtsecMemMap->tpkt))
- + p_Dtsec->internalStatistics.tpkt; /**< Total number of packets sent .*/
- p_Statistics->ifOutMcastPkts = (MASK22BIT & GET_UINT32(p_DtsecMemMap->tmca))
- + p_Dtsec->internalStatistics.tmca; /**< Total number of multicast frame sent */
- p_Statistics->ifOutBcastPkts = (MASK22BIT & GET_UINT32(p_DtsecMemMap->tbca))
- + p_Dtsec->internalStatistics.tbca; /**< Total number of multicast frame sent */
+ p_Statistics->ifInOctets = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RBYT)
+ + p_Dtsec->internalStatistics.rbyt;
+ p_Statistics->ifInPkts = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RPKT)
+ + p_Dtsec->internalStatistics.rpkt;
+ p_Statistics->ifInUcastPkts = 0;
+ p_Statistics->ifInMcastPkts = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RMCA)
+ + p_Dtsec->internalStatistics.rmca;
+ p_Statistics->ifInBcastPkts = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RBCA)
+ + p_Dtsec->internalStatistics.rbca;
+ p_Statistics->ifOutOctets = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TBYT)
+ + p_Dtsec->internalStatistics.tbyt;
+ p_Statistics->ifOutPkts = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TPKT)
+ + p_Dtsec->internalStatistics.tpkt;
+ p_Statistics->ifOutUcastPkts = 0;
+ p_Statistics->ifOutMcastPkts = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TMCA)
+ + p_Dtsec->internalStatistics.tmca;
+ p_Statistics->ifOutBcastPkts = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TBCA)
+ + p_Dtsec->internalStatistics.tbca;
}
-/* */
- p_Statistics->eStatFragments = (MASK16BIT & GET_UINT32(p_DtsecMemMap->rfrg))
- + p_Dtsec->internalStatistics.rfrg; /**< Total number of packets that were less than 64 octets long with a wrong CRC.*/
- p_Statistics->eStatJabbers = (MASK16BIT & GET_UINT32(p_DtsecMemMap->rjbr))
- + p_Dtsec->internalStatistics.rjbr; /**< Total number of packets longer than valid maximum length octets */
-
- p_Statistics->eStatsDropEvents = (MASK16BIT & GET_UINT32(p_DtsecMemMap->rdrp))
- + p_Dtsec->internalStatistics.rdrp; /**< number of dropped packets due to internal errors of the MAC Client. */
- p_Statistics->eStatCRCAlignErrors = (MASK16BIT & GET_UINT32(p_DtsecMemMap->raln))
- + p_Dtsec->internalStatistics.raln; /**< Incremented when frames of correct length but with CRC error are received.*/
-
- p_Statistics->eStatUndersizePkts = (MASK16BIT & GET_UINT32(p_DtsecMemMap->rund))
- + p_Dtsec->internalStatistics.rund; /**< Total number of packets that were less than 64 octets long with a good CRC.*/
- p_Statistics->eStatOversizePkts = (MASK16BIT & GET_UINT32(p_DtsecMemMap->rovr))
- + p_Dtsec->internalStatistics.rovr; /**< T,B.D*/
-/* Pause */
- p_Statistics->reStatPause = (MASK16BIT & GET_UINT32(p_DtsecMemMap->rxpf))
- + p_Dtsec->internalStatistics.rxpf; /**< Pause MAC Control received */
- p_Statistics->teStatPause = (MASK16BIT & GET_UINT32(p_DtsecMemMap->txpf))
- + p_Dtsec->internalStatistics.txpf; /**< Pause MAC Control sent */
-
- p_Statistics->ifInDiscards = p_Statistics->eStatsDropEvents; /**< Frames received, but discarded due to problems within the MAC RX. */
-
- p_Statistics->ifInErrors = p_Statistics->eStatsDropEvents
- + p_Statistics->eStatCRCAlignErrors
- + (MASK16BIT & GET_UINT32(p_DtsecMemMap->rflr))
- + p_Dtsec->internalStatistics.rflr
- + (MASK16BIT & GET_UINT32(p_DtsecMemMap->rcde))
- + p_Dtsec->internalStatistics.rcde
- + (MASK16BIT & GET_UINT32(p_DtsecMemMap->rcse))
- + p_Dtsec->internalStatistics.rcse;
-
- p_Statistics->ifOutDiscards = (MASK16BIT & GET_UINT32(p_DtsecMemMap->tdrp))
- + p_Dtsec->internalStatistics.tdrp; /**< Frames received, but discarded due to problems within the MAC TX N/A!.*/
- p_Statistics->ifOutErrors = p_Statistics->ifOutDiscards /**< Number of frames transmitted with error: */
- + (MASK12BIT & GET_UINT32(p_DtsecMemMap->tfcs))
- + p_Dtsec->internalStatistics.tfcs;
+
+ p_Statistics->eStatFragments = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RFRG)
+ + p_Dtsec->internalStatistics.rfrg;
+ p_Statistics->eStatJabbers = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RJBR)
+ + p_Dtsec->internalStatistics.rjbr;
+ p_Statistics->eStatsDropEvents = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RDRP)
+ + p_Dtsec->internalStatistics.rdrp;
+ p_Statistics->eStatCRCAlignErrors = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RALN)
+ + p_Dtsec->internalStatistics.raln;
+ p_Statistics->eStatUndersizePkts = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RUND)
+ + p_Dtsec->internalStatistics.rund;
+ p_Statistics->eStatOversizePkts = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_ROVR)
+ + p_Dtsec->internalStatistics.rovr;
+ p_Statistics->reStatPause = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_RXPF)
+ + p_Dtsec->internalStatistics.rxpf;
+ p_Statistics->teStatPause = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TXPF)
+ + p_Dtsec->internalStatistics.txpf;
+ p_Statistics->ifInDiscards = p_Statistics->eStatsDropEvents;
+ p_Statistics->ifInErrors = p_Statistics->eStatsDropEvents + p_Statistics->eStatCRCAlignErrors
+ + fman_dtsec_get_stat_counter(p_DtsecMemMap,E_DTSEC_STAT_RFLR) + p_Dtsec->internalStatistics.rflr
+ + fman_dtsec_get_stat_counter(p_DtsecMemMap,E_DTSEC_STAT_RCDE) + p_Dtsec->internalStatistics.rcde
+ + fman_dtsec_get_stat_counter(p_DtsecMemMap,E_DTSEC_STAT_RCSE) + p_Dtsec->internalStatistics.rcse;
+
+ p_Statistics->ifOutDiscards = fman_dtsec_get_stat_counter(p_DtsecMemMap, E_DTSEC_STAT_TDRP)
+ + p_Dtsec->internalStatistics.tdrp;
+ p_Statistics->ifOutErrors = p_Statistics->ifOutDiscards /**< Number of frames transmitted with error: */
+ + fman_dtsec_get_stat_counter(p_DtsecMemMap,E_DTSEC_STAT_TFCS)
+ + p_Dtsec->internalStatistics.tfcs;
return E_OK;
}
@@ -938,27 +779,15 @@ static t_Error DtsecGetStatistics(t_Handle h_Dtsec, t_FmMacStatistics *p_Statist
static t_Error DtsecModifyMacAddress (t_Handle h_Dtsec, t_EnetAddr *p_EnetAddr)
{
- t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
- t_DtsecMemMap *p_DtsecMemMap;
- uint32_t tmpReg32 = 0;
- uint64_t addr;
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_MemMap, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
- p_DtsecMemMap = p_Dtsec->p_MemMap;
/* Initialize MAC Station Address registers (1 & 2) */
/* Station address have to be swapped (big endian to little endian */
- addr = ((*(uint64_t *)p_EnetAddr) >> 16);
- p_Dtsec->addr = addr;
-
- tmpReg32 = (uint32_t)(addr);
- SwapUint32P(&tmpReg32);
- WRITE_UINT32(p_DtsecMemMap->macstnaddr1, tmpReg32);
-
- tmpReg32 = (uint32_t)(addr>>32);
- SwapUint32P(&tmpReg32);
- WRITE_UINT32(p_DtsecMemMap->macstnaddr2, tmpReg32);
+ p_Dtsec->addr = ENET_ADDR_TO_UINT64(*p_EnetAddr);
+ fman_dtsec_set_mac_address(p_Dtsec->p_MemMap, (uint8_t *)(*p_EnetAddr));
return E_OK;
}
@@ -967,15 +796,16 @@ static t_Error DtsecModifyMacAddress (t_Handle h_Dtsec, t_EnetAddr *p_EnetAddr)
static t_Error DtsecResetCounters (t_Handle h_Dtsec)
{
- t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
/* clear HW counters */
- WRITE_UINT32(p_Dtsec->p_MemMap->ecntrl, GET_UINT32(p_Dtsec->p_MemMap->ecntrl) | ECNTRL_CLRCNT);
+ fman_dtsec_reset_stat(p_Dtsec->p_MemMap);
/* clear SW counters holding carries */
- memset((char *)&p_Dtsec->internalStatistics, (char)0x0, sizeof(t_InternalStatistics));
+ memset(&p_Dtsec->internalStatistics, 0, sizeof(t_InternalStatistics));
return E_OK;
}
@@ -989,8 +819,9 @@ static t_Error DtsecAddExactMatchMacAddress(t_Handle h_Dtsec, t_EnetAddr *p_EthA
uint8_t paddrNum;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
- ethAddr = ((*(uint64_t *)p_EthAddr) >> 16);
+ ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
if (ethAddr & GROUP_ADDRESS)
/* Multicast address has no effect in PADDR */
@@ -1012,7 +843,7 @@ static t_Error DtsecAddExactMatchMacAddress(t_Handle h_Dtsec, t_EnetAddr *p_EthA
p_Dtsec->paddr[paddrNum] = ethAddr;
/* put in hardware */
- HardwareAddAddrInPaddr(p_Dtsec, &ethAddr, paddrNum);
+ fman_dtsec_add_addr_in_paddr(p_Dtsec->p_MemMap, (uint64_t)PTR_TO_UINT(&ethAddr), paddrNum);
p_Dtsec->numOfIndAddrInRegs++;
return E_OK;
@@ -1031,8 +862,9 @@ static t_Error DtsecDelExactMatchMacAddress(t_Handle h_Dtsec, t_EnetAddr *p_EthA
uint8_t paddrNum;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
- ethAddr = ((*(uint64_t *)p_EthAddr) >> 16);
+ ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
/* Find used PADDR containing this address */
for (paddrNum = 0; paddrNum < DTSEC_NUM_OF_PADDRS; paddrNum++)
@@ -1043,7 +875,7 @@ static t_Error DtsecDelExactMatchMacAddress(t_Handle h_Dtsec, t_EnetAddr *p_EthA
/* mark this PADDR as not used */
p_Dtsec->indAddrRegUsed[paddrNum] = FALSE;
/* clear in hardware */
- HardwareClearAddrInPaddr(p_Dtsec, paddrNum);
+ fman_dtsec_clear_addr_in_paddr(p_Dtsec->p_MemMap, paddrNum);
p_Dtsec->numOfIndAddrInRegs--;
return E_OK;
@@ -1058,51 +890,56 @@ static t_Error DtsecDelExactMatchMacAddress(t_Handle h_Dtsec, t_EnetAddr *p_EthA
static t_Error DtsecAddHashMacAddress(t_Handle h_Dtsec, t_EnetAddr *p_EthAddr)
{
t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
- t_DtsecMemMap *p_DtsecMemMap;
- uint32_t crc;
- uint8_t crcMirror, reg;
- uint32_t bitMask;
t_EthHashEntry *p_HashEntry;
uint64_t ethAddr;
+ int32_t bucket;
+ uint32_t crc;
+ bool mcast, ghtx;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_MemMap, E_NULL_POINTER);
-
- p_DtsecMemMap = p_Dtsec->p_MemMap;
-
- ethAddr = ((*(uint64_t *)p_EthAddr) >> 16);
-
- /* CRC calculation */
- GET_MAC_ADDR_CRC(ethAddr, crc);
+ SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
- /* calculate the "crc mirror" */
- crcMirror = MIRROR((uint8_t)crc);
+ ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
+
+ ghtx = (bool)((fman_dtsec_get_rctrl(p_Dtsec->p_MemMap) & RCTRL_GHTX) ? TRUE : FALSE);
+ mcast = (bool)((ethAddr & MAC_GROUP_ADDRESS) ? TRUE : FALSE);
+
+ if (ghtx && !mcast) /* Cannot handle unicast mac addr when GHTX is on */
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Could not compute hash bucket"));
+
+ crc = GetMacAddrHashCode(ethAddr);
+
+ /* considering the 9 highest order bits in crc H[8:0]:
+ * if ghtx = 0 H[8:6] (highest order 3 bits) identify the hash register
+ * and H[5:1] (next 5 bits) identify the hash bit
+ * if ghts = 1 H[8:5] (highest order 4 bits) identify the hash register
+ * and H[4:0] (next 5 bits) identify the hash bit.
+ *
+ * In bucket index output the low 5 bits identify the hash register bit,
+ * while the higher 4 bits identify the hash register
+ */
+
+ if (ghtx)
+ bucket = (int32_t)((crc >> 23) & 0x1ff);
+ else {
+ bucket = (int32_t)((crc >> 24) & 0xff);
+ /* if !ghtx and mcast the bit must be set in gaddr instead of igaddr. */
+ if (mcast)
+ bucket += 0x100;
+ }
- /* 3 MSB bits define the register */
- reg = (uint8_t)(crcMirror >> 5);
- /* 5 LSB bits define the bit within the register */
- bitMask = 0x80000000 >> (crcMirror & 0x1f);
+ fman_dtsec_set_bucket(p_Dtsec->p_MemMap, bucket, TRUE);
/* Create element to be added to the driver hash table */
p_HashEntry = (t_EthHashEntry *)XX_Malloc(sizeof(t_EthHashEntry));
p_HashEntry->addr = ethAddr;
INIT_LIST(&p_HashEntry->node);
- if (ethAddr & GROUP_ADDRESS)
- {
+ if (ethAddr & MAC_GROUP_ADDRESS)
/* Group Address */
- LIST_AddToTail(&(p_HashEntry->node), &(p_Dtsec->p_MulticastAddrHash->p_Lsts[crcMirror]));
- /* Set the appropriate bit in GADDR0-7 */
- WRITE_UINT32(p_DtsecMemMap->gaddr[reg],
- GET_UINT32(p_DtsecMemMap->gaddr[reg]) | bitMask);
- }
+ NCSW_LIST_AddToTail(&(p_HashEntry->node), &(p_Dtsec->p_MulticastAddrHash->p_Lsts[bucket]));
else
- {
- LIST_AddToTail(&(p_HashEntry->node), &(p_Dtsec->p_UnicastAddrHash->p_Lsts[crcMirror]));
- /* Set the appropriate bit in IADDR0-7 */
- WRITE_UINT32(p_DtsecMemMap->igaddr[reg],
- GET_UINT32(p_DtsecMemMap->igaddr[reg]) | bitMask);
- }
+ NCSW_LIST_AddToTail(&(p_HashEntry->node), &(p_Dtsec->p_UnicastAddrHash->p_Lsts[bucket]));
return E_OK;
}
@@ -1112,65 +949,66 @@ static t_Error DtsecAddHashMacAddress(t_Handle h_Dtsec, t_EnetAddr *p_EthAddr)
static t_Error DtsecDelHashMacAddress(t_Handle h_Dtsec, t_EnetAddr *p_EthAddr)
{
t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
- t_DtsecMemMap *p_DtsecMemMap;
t_List *p_Pos;
- uint32_t crc;
- uint8_t crcMirror, reg;
- uint32_t bitMask;
t_EthHashEntry *p_HashEntry = NULL;
uint64_t ethAddr;
+ int32_t bucket;
+ uint32_t crc;
+ bool mcast, ghtx;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_MemMap, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
- p_DtsecMemMap = p_Dtsec->p_MemMap;
+ ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
- ethAddr = ((*(uint64_t *)p_EthAddr) >> 16);
+ ghtx = (bool)((fman_dtsec_get_rctrl(p_Dtsec->p_MemMap) & RCTRL_GHTX) ? TRUE : FALSE);
+ mcast = (bool)((ethAddr & MAC_GROUP_ADDRESS) ? TRUE : FALSE);
- /* CRC calculation */
- GET_MAC_ADDR_CRC(ethAddr, crc);
+ if (ghtx && !mcast) /* Cannot handle unicast mac addr when GHTX is on */
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Could not compute hash bucket"));
- /* calculate the "crc mirror" */
- crcMirror = MIRROR((uint8_t)crc);
+ crc = GetMacAddrHashCode(ethAddr);
- /* 3 MSB bits define the register */
- reg =(uint8_t)( crcMirror >> 5);
- /* 5 LSB bits define the bit within the register */
- bitMask = 0x80000000 >> (crcMirror & 0x1f);
+ if (ghtx)
+ bucket = (int32_t)((crc >> 23) & 0x1ff);
+ else {
+ bucket = (int32_t)((crc >> 24) & 0xff);
+ /* if !ghtx and mcast the bit must be set in gaddr instead of igaddr. */
+ if (mcast)
+ bucket += 0x100;
+ }
- if (ethAddr & GROUP_ADDRESS)
+ if (ethAddr & MAC_GROUP_ADDRESS)
{
/* Group Address */
- LIST_FOR_EACH(p_Pos, &(p_Dtsec->p_MulticastAddrHash->p_Lsts[crcMirror]))
+ NCSW_LIST_FOR_EACH(p_Pos, &(p_Dtsec->p_MulticastAddrHash->p_Lsts[bucket]))
{
p_HashEntry = ETH_HASH_ENTRY_OBJ(p_Pos);
- if(p_HashEntry->addr == ethAddr)
+ if (p_HashEntry->addr == ethAddr)
{
- LIST_DelAndInit(&p_HashEntry->node);
+ NCSW_LIST_DelAndInit(&p_HashEntry->node);
XX_Free(p_HashEntry);
break;
}
}
- if(LIST_IsEmpty(&p_Dtsec->p_MulticastAddrHash->p_Lsts[crcMirror]))
- WRITE_UINT32(p_DtsecMemMap->gaddr[reg],
- GET_UINT32(p_DtsecMemMap->gaddr[reg]) & ~bitMask);
+ if (NCSW_LIST_IsEmpty(&p_Dtsec->p_MulticastAddrHash->p_Lsts[bucket]))
+ fman_dtsec_set_bucket(p_Dtsec->p_MemMap, bucket, FALSE);
}
else
{
/* Individual Address */
- LIST_FOR_EACH(p_Pos, &(p_Dtsec->p_UnicastAddrHash->p_Lsts[crcMirror]))
+ NCSW_LIST_FOR_EACH(p_Pos, &(p_Dtsec->p_UnicastAddrHash->p_Lsts[bucket]))
{
p_HashEntry = ETH_HASH_ENTRY_OBJ(p_Pos);
- if(p_HashEntry->addr == ethAddr)
+ if (p_HashEntry->addr == ethAddr)
{
- LIST_DelAndInit(&p_HashEntry->node);
+ NCSW_LIST_DelAndInit(&p_HashEntry->node);
XX_Free(p_HashEntry);
break;
}
}
- if(LIST_IsEmpty(&p_Dtsec->p_UnicastAddrHash->p_Lsts[crcMirror]))
- WRITE_UINT32(p_DtsecMemMap->igaddr[reg],
- GET_UINT32(p_DtsecMemMap->igaddr[reg]) & ~bitMask);
+ if (NCSW_LIST_IsEmpty(&p_Dtsec->p_UnicastAddrHash->p_Lsts[bucket]))
+ fman_dtsec_set_bucket(p_Dtsec->p_MemMap, bucket, FALSE);
}
/* address does not exist */
@@ -1179,29 +1017,17 @@ static t_Error DtsecDelHashMacAddress(t_Handle h_Dtsec, t_EnetAddr *p_EthAddr)
return E_OK;
}
-
/* .............................................................................. */
static t_Error DtsecSetPromiscuous(t_Handle h_Dtsec, bool newVal)
{
- t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
- t_DtsecMemMap *p_DtsecMemMap;
- uint32_t tmpReg32;
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_MemMap, E_NULL_POINTER);
-
- p_DtsecMemMap = p_Dtsec->p_MemMap;
-
- tmpReg32 = GET_UINT32(p_DtsecMemMap->rctrl);
-
- if (newVal)
- tmpReg32 |= RCTRL_PROM;
- else
- tmpReg32 &= ~RCTRL_PROM;
+ SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
- WRITE_UINT32(p_DtsecMemMap->rctrl, tmpReg32);
+ fman_dtsec_set_uc_promisc(p_Dtsec->p_MemMap, newVal);
+ fman_dtsec_set_mc_promisc(p_Dtsec->p_MemMap, newVal);
return E_OK;
}
@@ -1210,38 +1036,29 @@ static t_Error DtsecSetPromiscuous(t_Handle h_Dtsec, bool newVal)
static t_Error DtsecSetStatistics(t_Handle h_Dtsec, e_FmMacStatisticsLevel statisticsLevel)
{
- t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
- t_DtsecMemMap *p_DtsecMemMap;
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
+ t_Error err;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_MemMap, E_NULL_POINTER);
-
- p_DtsecMemMap = p_Dtsec->p_MemMap;
+ SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
p_Dtsec->statisticsLevel = statisticsLevel;
- switch (p_Dtsec->statisticsLevel)
+ err = (t_Error)fman_dtsec_set_stat_level(p_Dtsec->p_MemMap,
+ (enum dtsec_stat_level)statisticsLevel);
+ if (err != E_OK)
+ return err;
+
+ switch (statisticsLevel)
{
- case(e_FM_MAC_NONE_STATISTICS):
- WRITE_UINT32(p_DtsecMemMap->cam1,0xffffffff);
- WRITE_UINT32(p_DtsecMemMap->cam2,0xffffffff);
- WRITE_UINT32(p_DtsecMemMap->ecntrl, GET_UINT32(p_DtsecMemMap->ecntrl) & ~ECNTRL_STEN);
- WRITE_UINT32(p_DtsecMemMap->imask, GET_UINT32(p_DtsecMemMap->imask) & ~IMASK_MSROEN);
- p_Dtsec->exceptions &= ~IMASK_MSROEN;
+ case (e_FM_MAC_NONE_STATISTICS):
+ p_Dtsec->exceptions &= ~DTSEC_IMASK_MSROEN;
break;
- case(e_FM_MAC_PARTIAL_STATISTICS):
- WRITE_UINT32(p_DtsecMemMap->cam1, CAM1_ERRORS_ONLY);
- WRITE_UINT32(p_DtsecMemMap->cam2, CAM2_ERRORS_ONLY);
- WRITE_UINT32(p_DtsecMemMap->ecntrl, GET_UINT32(p_DtsecMemMap->ecntrl) | ECNTRL_STEN);
- WRITE_UINT32(p_DtsecMemMap->imask, GET_UINT32(p_DtsecMemMap->imask) | IMASK_MSROEN);
- p_Dtsec->exceptions |= IMASK_MSROEN;
+ case (e_FM_MAC_PARTIAL_STATISTICS):
+ p_Dtsec->exceptions |= DTSEC_IMASK_MSROEN;
break;
- case(e_FM_MAC_FULL_STATISTICS):
- WRITE_UINT32(p_DtsecMemMap->cam1,0);
- WRITE_UINT32(p_DtsecMemMap->cam2,0);
- WRITE_UINT32(p_DtsecMemMap->ecntrl, GET_UINT32(p_DtsecMemMap->ecntrl) | ECNTRL_STEN);
- WRITE_UINT32(p_DtsecMemMap->imask, GET_UINT32(p_DtsecMemMap->imask) | IMASK_MSROEN);
- p_Dtsec->exceptions |= IMASK_MSROEN;
+ case (e_FM_MAC_FULL_STATISTICS):
+ p_Dtsec->exceptions |= DTSEC_IMASK_MSROEN;
break;
default:
RETURN_ERROR(MINOR, E_INVALID_SELECTION, NO_MSG);
@@ -1252,51 +1069,59 @@ static t_Error DtsecSetStatistics(t_Handle h_Dtsec, e_FmMacStatisticsLevel stati
/* .............................................................................. */
-static t_Error DtsecAdjustLink(t_Handle h_Dtsec, e_EnetSpeed speed, bool fullDuplex)
+static t_Error DtsecSetWakeOnLan(t_Handle h_Dtsec, bool en)
{
t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
- t_DtsecMemMap *p_DtsecMemMap;
- uint32_t tmpReg32;
- SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_HANDLE);
- p_DtsecMemMap = p_Dtsec->p_MemMap;
- SANITY_CHECK_RETURN_ERROR(p_DtsecMemMap, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
- if ((!fullDuplex) && (speed >= e_ENET_SPEED_1000))
- RETURN_ERROR(MAJOR, E_CONFLICT, ("Ethernet interface does not support Half Duplex mode"));
+ fman_dtsec_set_wol(p_Dtsec->p_MemMap, en);
+
+ return E_OK;
+}
+
+/* .............................................................................. */
+
+static t_Error DtsecAdjustLink(t_Handle h_Dtsec, e_EnetSpeed speed, bool fullDuplex)
+{
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
+ int err;
+ enum enet_interface enet_interface;
+ enum enet_speed enet_speed;
+
+ SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
p_Dtsec->enetMode = MAKE_ENET_MODE(ENET_INTERFACE_FROM_MODE(p_Dtsec->enetMode), speed);
+ enet_interface = (enum enet_interface) ENET_INTERFACE_FROM_MODE(p_Dtsec->enetMode);
+ enet_speed = (enum enet_speed) ENET_SPEED_FROM_MODE(p_Dtsec->enetMode);
p_Dtsec->halfDuplex = !fullDuplex;
- tmpReg32 = GET_UINT32(p_DtsecMemMap->maccfg2);
- if(p_Dtsec->halfDuplex)
- tmpReg32 &= ~MACCFG2_FULL_DUPLEX;
- else
- tmpReg32 |= MACCFG2_FULL_DUPLEX;
-
- tmpReg32 &= ~(MACCFG2_NIBBLE_MODE | MACCFG2_BYTE_MODE);
- if((p_Dtsec->enetMode == e_ENET_MODE_RGMII_10) ||
- (p_Dtsec->enetMode == e_ENET_MODE_RGMII_100)||
- (p_Dtsec->enetMode == e_ENET_MODE_SGMII_10) ||
- (p_Dtsec->enetMode == e_ENET_MODE_SGMII_100))
- tmpReg32 |= MACCFG2_NIBBLE_MODE;
- else if((p_Dtsec->enetMode == e_ENET_MODE_RGMII_1000) ||
- (p_Dtsec->enetMode == e_ENET_MODE_SGMII_1000)||
- (p_Dtsec->enetMode == e_ENET_MODE_GMII_1000))
- tmpReg32 |= MACCFG2_BYTE_MODE;
- WRITE_UINT32(p_DtsecMemMap->maccfg2, tmpReg32);
-
- tmpReg32 = GET_UINT32(p_DtsecMemMap->ecntrl);
- if (!(tmpReg32 & ECNTRL_CFG_RO))
- {
- if ((p_Dtsec->enetMode == e_ENET_MODE_RGMII_100) ||
- (p_Dtsec->enetMode == e_ENET_MODE_SGMII_100))
- tmpReg32 |= ECNTRL_R100M;
- else
- tmpReg32 &= ~ECNTRL_R100M;
- WRITE_UINT32(p_DtsecMemMap->ecntrl, tmpReg32);
- }
+ err = fman_dtsec_adjust_link(p_Dtsec->p_MemMap, enet_interface, enet_speed, fullDuplex);
+
+ if (err == -EINVAL)
+ RETURN_ERROR(MAJOR, E_CONFLICT, ("Ethernet interface does not support Half Duplex mode"));
+
+ return (t_Error)err;
+}
+
+/* .............................................................................. */
+
+static t_Error DtsecRestartAutoneg(t_Handle h_Dtsec)
+{
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
+ uint16_t tmpReg16;
+
+ SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
+
+ DTSEC_MII_ReadPhyReg(p_Dtsec, p_Dtsec->tbi_phy_addr, 0, &tmpReg16);
+
+ tmpReg16 &= ~( PHY_CR_SPEED0 | PHY_CR_SPEED1 );
+ tmpReg16 |= (PHY_CR_ANE | PHY_CR_RESET_AN | PHY_CR_FULLDUPLEX | PHY_CR_SPEED1);
+
+ DTSEC_MII_WritePhyReg(p_Dtsec, p_Dtsec->tbi_phy_addr, 0, tmpReg16);
return E_OK;
}
@@ -1305,10 +1130,10 @@ static t_Error DtsecAdjustLink(t_Handle h_Dtsec, e_EnetSpeed speed, bool fullDup
static t_Error DtsecGetId(t_Handle h_Dtsec, uint32_t *macId)
{
- t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
*macId = p_Dtsec->macId;
@@ -1319,15 +1144,12 @@ static t_Error DtsecGetId(t_Handle h_Dtsec, uint32_t *macId)
static t_Error DtsecGetVersion(t_Handle h_Dtsec, uint32_t *macVersion)
{
- t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
- t_DtsecMemMap *p_DtsecMemMap;
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_MemMap, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
- p_DtsecMemMap = p_Dtsec->p_MemMap;
- *macVersion = GET_UINT32(p_DtsecMemMap->tsec_id1);
+ *macVersion = fman_dtsec_get_revision(p_Dtsec->p_MemMap);
return E_OK;
}
@@ -1336,118 +1158,53 @@ static t_Error DtsecGetVersion(t_Handle h_Dtsec, uint32_t *macVersion)
static t_Error DtsecSetException(t_Handle h_Dtsec, e_FmMacExceptions exception, bool enable)
{
- t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
- uint32_t tmpReg, bitMask = 0;
- t_DtsecMemMap *p_DtsecMemMap;
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
+ uint32_t bitMask = 0;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_MemMap, E_NULL_POINTER);
-
- p_DtsecMemMap = p_Dtsec->p_MemMap;
+ SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
- if(exception != e_FM_MAC_EX_1G_1588_TS_RX_ERR)
+ if (exception != e_FM_MAC_EX_1G_1588_TS_RX_ERR)
{
GET_EXCEPTION_FLAG(bitMask, exception);
- if(bitMask)
+ if (bitMask)
{
if (enable)
p_Dtsec->exceptions |= bitMask;
else
p_Dtsec->exceptions &= ~bitMask;
- }
+ }
else
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
- tmpReg = GET_UINT32(p_DtsecMemMap->imask);
- if(enable)
- tmpReg |= bitMask;
+ if (enable)
+ fman_dtsec_enable_interrupt(p_Dtsec->p_MemMap, bitMask);
else
- tmpReg &= ~bitMask;
- WRITE_UINT32(p_DtsecMemMap->imask, tmpReg);
-
- /* warn if MIB OVFL is disabled and statistic gathering is enabled */
- if((exception == e_FM_MAC_EX_1G_RX_MIB_CNT_OVFL) &&
- !enable &&
- (p_Dtsec->statisticsLevel != e_FM_MAC_NONE_STATISTICS))
- DBG(WARNING, ("Disabled MIB counters overflow exceptions. Counters value may be inaccurate due to unregistered overflow"));
-
+ fman_dtsec_disable_interrupt(p_Dtsec->p_MemMap, bitMask);
}
else
{
- if(!p_Dtsec->ptpTsuEnabled)
+ if (!p_Dtsec->ptpTsuEnabled)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Exception valid for 1588 only"));
- tmpReg = GET_UINT32(p_DtsecMemMap->tmr_pemask);
- switch(exception){
- case(e_FM_MAC_EX_1G_1588_TS_RX_ERR):
- if(enable)
- {
- p_Dtsec->enTsuErrExeption = TRUE;
- WRITE_UINT32(p_DtsecMemMap->tmr_pemask, tmpReg | PEMASK_TSRE);
- }
- else
- {
- p_Dtsec->enTsuErrExeption = FALSE;
- WRITE_UINT32(p_DtsecMemMap->tmr_pemask, tmpReg & ~PEMASK_TSRE);
- }
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
- }
- }
-
- return E_OK;
-}
-
-/* ........................................................................... */
-
-#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
-static t_Error DtsecDumpRegs(t_Handle h_Dtsec)
-{
- t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
- int i = 0;
- DECLARE_DUMP;
-
- if (p_Dtsec->p_MemMap)
- {
-
- DUMP_TITLE(p_Dtsec->p_MemMap, ("MAC %d: ", p_Dtsec->macId));
- DUMP_VAR(p_Dtsec->p_MemMap, tsec_id1);
- DUMP_VAR(p_Dtsec->p_MemMap, tsec_id2);
- DUMP_VAR(p_Dtsec->p_MemMap, ievent);
- DUMP_VAR(p_Dtsec->p_MemMap, imask);
- DUMP_VAR(p_Dtsec->p_MemMap, edis);
- DUMP_VAR(p_Dtsec->p_MemMap, ecntrl);
- DUMP_VAR(p_Dtsec->p_MemMap, ptv);
- DUMP_VAR(p_Dtsec->p_MemMap, tmr_ctrl);
- DUMP_VAR(p_Dtsec->p_MemMap, tmr_pevent);
- DUMP_VAR(p_Dtsec->p_MemMap, tmr_pemask);
- DUMP_VAR(p_Dtsec->p_MemMap, tctrl);
- DUMP_VAR(p_Dtsec->p_MemMap, rctrl);
- DUMP_VAR(p_Dtsec->p_MemMap, maccfg1);
- DUMP_VAR(p_Dtsec->p_MemMap, maccfg2);
- DUMP_VAR(p_Dtsec->p_MemMap, ipgifg);
- DUMP_VAR(p_Dtsec->p_MemMap, hafdup);
- DUMP_VAR(p_Dtsec->p_MemMap, maxfrm);
-
- DUMP_VAR(p_Dtsec->p_MemMap, macstnaddr1);
- DUMP_VAR(p_Dtsec->p_MemMap, macstnaddr2);
-
- DUMP_SUBSTRUCT_ARRAY(i, 8)
+ if (enable)
+ {
+ p_Dtsec->enTsuErrExeption = TRUE;
+ fman_dtsec_enable_tmr_interrupt(p_Dtsec->p_MemMap);
+ }
+ else
{
- DUMP_VAR(p_Dtsec->p_MemMap, macaddr[i].exact_match1);
- DUMP_VAR(p_Dtsec->p_MemMap, macaddr[i].exact_match2);
+ p_Dtsec->enTsuErrExeption = FALSE;
+ fman_dtsec_disable_tmr_interrupt(p_Dtsec->p_MemMap);
}
}
return E_OK;
}
-#endif /* (defined(DEBUG_ERRORS) && ... */
/*****************************************************************************/
-/* FM Init & Free API */
+/* dTSEC Init & Free API */
/*****************************************************************************/
/* .............................................................................. */
@@ -1455,354 +1212,115 @@ static t_Error DtsecDumpRegs(t_Handle h_Dtsec)
static t_Error DtsecInit(t_Handle h_Dtsec)
{
t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
- t_DtsecDriverParam *p_DtsecDriverParam;
- t_DtsecMemMap *p_DtsecMemMap;
- int i;
- uint32_t tmpReg32;
- uint64_t addr;
+ struct dtsec_cfg *p_DtsecDriverParam;
t_Error err;
+ uint16_t maxFrmLn;
+ enum enet_interface enet_interface;
+ enum enet_speed enet_speed;
+ t_EnetAddr ethAddr;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
- SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_MemMap, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_Dtsec->fmMacControllerDriver.h_Fm, E_INVALID_HANDLE);
+ FM_GetRevision(p_Dtsec->fmMacControllerDriver.h_Fm, &p_Dtsec->fmMacControllerDriver.fmRevInfo);
CHECK_INIT_PARAMETERS(p_Dtsec, CheckInitParameters);
p_DtsecDriverParam = p_Dtsec->p_DtsecDriverParam;
- p_Dtsec->halfDuplex = p_DtsecDriverParam->halfDuplex;
- p_Dtsec->debugMode = p_DtsecDriverParam->debugMode;
- p_DtsecMemMap = p_Dtsec->p_MemMap;
-
- /*************dtsec_id2******************/
- tmpReg32 = GET_UINT32(p_DtsecMemMap->tsec_id2);
-
- if ((p_Dtsec->enetMode == e_ENET_MODE_RGMII_10) ||
- (p_Dtsec->enetMode == e_ENET_MODE_RGMII_100) ||
- (p_Dtsec->enetMode == e_ENET_MODE_RGMII_1000) ||
- (p_Dtsec->enetMode == e_ENET_MODE_RMII_10) ||
- (p_Dtsec->enetMode == e_ENET_MODE_RMII_100))
- if(tmpReg32 & ID2_INT_REDUCED_OFF)
- {
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("no support for reduced interface in current DTSEC version"));
- }
-
- if ((p_Dtsec->enetMode == e_ENET_MODE_SGMII_10) ||
- (p_Dtsec->enetMode == e_ENET_MODE_SGMII_100) ||
- (p_Dtsec->enetMode == e_ENET_MODE_SGMII_1000)||
- (p_Dtsec->enetMode == e_ENET_MODE_MII_10) ||
- (p_Dtsec->enetMode == e_ENET_MODE_MII_100))
- if(tmpReg32 & ID2_INT_NORMAL_OFF)
- {
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("no support for normal interface in current DTSEC version"));
- }
- /*************dtsec_id2******************/
-
- /***************EDIS************************/
- WRITE_UINT32(p_DtsecMemMap->edis, p_DtsecDriverParam->errorDisabled);
- /***************EDIS************************/
-
- /***************ECNTRL************************/
- tmpReg32 = 0;
- if ((p_Dtsec->enetMode == e_ENET_MODE_RGMII_10) ||
- (p_Dtsec->enetMode == e_ENET_MODE_RGMII_100) ||
- (p_Dtsec->enetMode == e_ENET_MODE_RGMII_1000) ||
- (p_Dtsec->enetMode == e_ENET_MODE_GMII_1000))
- tmpReg32 |= ECNTRL_GMIIM;
- if ((p_Dtsec->enetMode == e_ENET_MODE_SGMII_10) ||
- (p_Dtsec->enetMode == e_ENET_MODE_SGMII_100) ||
- (p_Dtsec->enetMode == e_ENET_MODE_SGMII_1000))
- tmpReg32 |= (ECNTRL_SGMIIM | ECNTRL_TBIM);
- if (p_Dtsec->enetMode == e_ENET_MODE_QSGMII_1000)
- tmpReg32 |= (ECNTRL_SGMIIM | ECNTRL_TBIM | ECNTRL_QSGMIIM);
- if ((p_Dtsec->enetMode == e_ENET_MODE_RGMII_1000) ||
- (p_Dtsec->enetMode == e_ENET_MODE_RGMII_10)||
- (p_Dtsec->enetMode == e_ENET_MODE_RGMII_100))
- tmpReg32 |= ECNTRL_RPM;
- if ((p_Dtsec->enetMode == e_ENET_MODE_RGMII_100) ||
- (p_Dtsec->enetMode == e_ENET_MODE_SGMII_100) ||
- (p_Dtsec->enetMode == e_ENET_MODE_RMII_100))
- tmpReg32 |= ECNTRL_R100M;
- if ((p_Dtsec->enetMode == e_ENET_MODE_RMII_10) || (p_Dtsec->enetMode == e_ENET_MODE_RMII_100))
- tmpReg32 |= ECNTRL_RMM;
- WRITE_UINT32(p_DtsecMemMap->ecntrl, tmpReg32);
- /***************ECNTRL************************/
-
- /***************PTV************************/
- tmpReg32 = 0;
-#ifdef FM_SHORT_PAUSE_TIME_ERRATA_DTSEC1
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_Dtsec->fmMacControllerDriver.h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- p_DtsecDriverParam->pauseTime += 2;
- }
-#endif /* FM_SHORT_PAUSE_TIME_ERRATA_DTSEC1 */
- if (p_DtsecDriverParam->pauseTime)
- tmpReg32 |= (uint32_t)p_DtsecDriverParam->pauseTime;
-
- if (p_DtsecDriverParam->pauseExtended)
- tmpReg32 |= ((uint32_t)p_DtsecDriverParam->pauseExtended) << PTV_PTE_OFST;
- WRITE_UINT32(p_DtsecMemMap->ptv, tmpReg32);
- /***************PTV************************/
-
- /***************TCTRL************************/
- tmpReg32 = 0;
- if(p_DtsecDriverParam->halfDuplex)
- {
- if(p_DtsecDriverParam->halfDulexFlowControlEn)
- tmpReg32 |= TCTRL_THDF;
- }
- else
+ p_Dtsec->halfDuplex = p_DtsecDriverParam->halfdup_on;
+
+ enet_interface = (enum enet_interface)ENET_INTERFACE_FROM_MODE(p_Dtsec->enetMode);
+ enet_speed = (enum enet_speed)ENET_SPEED_FROM_MODE(p_Dtsec->enetMode);
+ MAKE_ENET_ADDR_FROM_UINT64(p_Dtsec->addr, ethAddr);
+
+ err = (t_Error)fman_dtsec_init(p_Dtsec->p_MemMap,
+ p_DtsecDriverParam,
+ enet_interface,
+ enet_speed,
+ (uint8_t*)ethAddr,
+ p_Dtsec->fmMacControllerDriver.fmRevInfo.majorRev,
+ p_Dtsec->fmMacControllerDriver.fmRevInfo.minorRev,
+ p_Dtsec->exceptions);
+ if (err)
{
- if(p_DtsecDriverParam->txTimeStampEn)
- tmpReg32 |= TCTRL_TTSE;
+ FreeInitResources(p_Dtsec);
+ RETURN_ERROR(MAJOR, err, ("This DTSEC version does not support the required i/f mode"));
}
- WRITE_UINT32(p_DtsecMemMap->tctrl, tmpReg32);
- /***************TCTRL************************/
-
- /***************RCTRL************************/
- tmpReg32 = 0;
- if (p_DtsecDriverParam->packetAlignmentPadding)
- tmpReg32 |= ((uint32_t)(0x0000001f & p_DtsecDriverParam->packetAlignmentPadding)) << 16;
- if (p_DtsecDriverParam->controlFrameAccept)
- tmpReg32 |= RCTRL_CFA;
- if (p_DtsecDriverParam->groupHashExtend)
- tmpReg32 |= RCTRL_GHTX;
- if(p_DtsecDriverParam->rxTimeStampEn)
- tmpReg32 |= RCTRL_RTSE;
- if (p_DtsecDriverParam->broadcReject)
- tmpReg32 |= RCTRL_BC_REJ;
- if (p_DtsecDriverParam->rxShortFrame)
- tmpReg32 |= RCTRL_RSF;
- if (p_DtsecDriverParam->promiscuousEnable)
- tmpReg32 |= RCTRL_PROM;
- if (p_DtsecDriverParam->exactMatch)
- tmpReg32 |= RCTRL_EMEN;
-
- WRITE_UINT32(p_DtsecMemMap->rctrl, tmpReg32);
- /***************RCTRL************************/
-
- /* Assign a Phy Address to the TBI (TBIPA). */
- /* Done also in case that TBI is not selected to avoid */
- /* conflict with the external PHY’s Physical address */
- WRITE_UINT32(p_DtsecMemMap->tbipa, p_DtsecDriverParam->tbiPhyAddr);
-
- /* Reset the management interface */
- WRITE_UINT32(p_Dtsec->p_MiiMemMap->miimcfg, MIIMCFG_RESET_MGMT);
- WRITE_UINT32(p_Dtsec->p_MiiMemMap->miimcfg, ~MIIMCFG_RESET_MGMT);
- /* Setup the MII Mgmt clock speed */
- WRITE_UINT32(p_Dtsec->p_MiiMemMap->miimcfg,
- (uint32_t)GetMiiDiv((int32_t)(((p_Dtsec->fmMacControllerDriver.clkFreq*10)/2)/8)));
-
- if(p_Dtsec->enetMode == e_ENET_MODE_SGMII_1000)
+
+ if (ENET_INTERFACE_FROM_MODE(p_Dtsec->enetMode) == e_ENET_IF_SGMII)
{
uint16_t tmpReg16;
/* Configure the TBI PHY Control Register */
- tmpReg16 = PHY_TBICON_SPEED2 | PHY_TBICON_SRESET;
-
- DTSEC_MII_WritePhyReg(p_Dtsec, p_DtsecDriverParam->tbiPhyAddr, 17, tmpReg16);
+ tmpReg16 = PHY_TBICON_CLK_SEL | PHY_TBICON_SRESET;
+ DTSEC_MII_WritePhyReg(p_Dtsec, (uint8_t)p_DtsecDriverParam->tbipa, 17, tmpReg16);
- tmpReg16 = PHY_TBICON_SPEED2;
+ tmpReg16 = PHY_TBICON_CLK_SEL;
+ DTSEC_MII_WritePhyReg(p_Dtsec, (uint8_t)p_DtsecDriverParam->tbipa, 17, tmpReg16);
- DTSEC_MII_WritePhyReg(p_Dtsec, p_DtsecDriverParam->tbiPhyAddr, 17, tmpReg16);
+ tmpReg16 = (PHY_CR_PHY_RESET | PHY_CR_ANE | PHY_CR_FULLDUPLEX | PHY_CR_SPEED1);
+ DTSEC_MII_WritePhyReg(p_Dtsec, (uint8_t)p_DtsecDriverParam->tbipa, 0, tmpReg16);
- if(!p_DtsecDriverParam->halfDuplex)
- tmpReg16 |= PHY_CR_FULLDUPLEX | 0x8000 | PHY_CR_ANE;
-
- DTSEC_MII_WritePhyReg(p_Dtsec, p_DtsecDriverParam->tbiPhyAddr, 0, tmpReg16);
-
- tmpReg16 = 0x01a0;
- DTSEC_MII_WritePhyReg(p_Dtsec, p_DtsecDriverParam->tbiPhyAddr, 4, tmpReg16);
-
- tmpReg16 = 0x1340;
- DTSEC_MII_WritePhyReg(p_Dtsec, p_DtsecDriverParam->tbiPhyAddr, 0, tmpReg16);
- }
-
- /***************TMR_CTL************************/
- WRITE_UINT32(p_DtsecMemMap->tmr_ctrl, 0);
+ if (p_Dtsec->enetMode & ENET_IF_SGMII_BASEX)
+ tmpReg16 = PHY_TBIANA_1000X;
+ else
+ tmpReg16 = PHY_TBIANA_SGMII;
+ DTSEC_MII_WritePhyReg(p_Dtsec, (uint8_t)p_DtsecDriverParam->tbipa, 4, tmpReg16);
- if(p_Dtsec->ptpTsuEnabled)
- {
- tmpReg32 = 0;
- if (p_Dtsec->enTsuErrExeption)
- tmpReg32 |= PEMASK_TSRE;
- WRITE_UINT32(p_DtsecMemMap->tmr_pemask, tmpReg32);
- WRITE_UINT32(p_DtsecMemMap->tmr_pevent, tmpReg32);
- }
+ tmpReg16 = (PHY_CR_ANE | PHY_CR_RESET_AN | PHY_CR_FULLDUPLEX | PHY_CR_SPEED1);
- /***************DEBUG************************/
- tmpReg32 = 0;
- if(p_DtsecDriverParam->debugMode)
- WRITE_UINT32(p_DtsecMemMap->tsec_id1, TSEC_ID1_DEBUG);
- /***************DEBUG************************/
-
- /***************MACCFG1***********************/
- WRITE_UINT32(p_DtsecMemMap->maccfg1, MACCFG1_SOFT_RESET);
- WRITE_UINT32(p_DtsecMemMap->maccfg1, 0);
- tmpReg32 = 0;
- if(p_DtsecDriverParam->loopback)
- tmpReg32 |= MACCFG1_LOOPBACK;
- if(p_DtsecDriverParam->actOnRxPauseFrame)
- tmpReg32 |= MACCFG1_RX_FLOW;
- if(p_DtsecDriverParam->actOnTxPauseFrame)
- tmpReg32 |= MACCFG1_TX_FLOW;
- WRITE_UINT32(p_DtsecMemMap->maccfg1, tmpReg32);
- /***************MACCFG1***********************/
-
- /***************MACCFG2***********************/
- tmpReg32 = 0;
- if( (p_Dtsec->enetMode == e_ENET_MODE_RMII_10) ||
- (p_Dtsec->enetMode == e_ENET_MODE_RMII_100) ||
- (p_Dtsec->enetMode == e_ENET_MODE_MII_10) ||
- (p_Dtsec->enetMode == e_ENET_MODE_MII_100) ||
- (p_Dtsec->enetMode == e_ENET_MODE_RGMII_10) ||
- (p_Dtsec->enetMode == e_ENET_MODE_RGMII_100)||
- (p_Dtsec->enetMode == e_ENET_MODE_SGMII_10) ||
- (p_Dtsec->enetMode == e_ENET_MODE_SGMII_100))
- tmpReg32 |= MACCFG2_NIBBLE_MODE;
- else if((p_Dtsec->enetMode == e_ENET_MODE_RGMII_1000) ||
- (p_Dtsec->enetMode == e_ENET_MODE_SGMII_1000)||
- (p_Dtsec->enetMode == e_ENET_MODE_GMII_1000)||
- (p_Dtsec->enetMode == e_ENET_MODE_QSGMII_1000))
- tmpReg32 |= MACCFG2_BYTE_MODE;
-
- tmpReg32 |= (((uint32_t)p_DtsecDriverParam->preambleLength) & 0x0000000f)<< PREAMBLE_LENGTH_SHIFT;
-
- if(p_DtsecDriverParam->preambleRxEn)
- tmpReg32 |= MACCFG2_PRE_AM_Rx_EN;
- if(p_DtsecDriverParam->preambleTxEn)
- tmpReg32 |= MACCFG2_PRE_AM_Tx_EN;
- if(p_DtsecDriverParam->lengthCheckEnable)
- tmpReg32 |= MACCFG2_LENGTH_CHECK;
- if(p_DtsecDriverParam->padAndCrcEnable)
- tmpReg32 |= MACCFG2_PAD_CRC_EN;
- if(p_DtsecDriverParam->crcEnable)
- tmpReg32 |= MACCFG2_CRC_EN;
- if(!p_DtsecDriverParam->halfDuplex)
- tmpReg32 |= MACCFG2_FULL_DUPLEX;
- WRITE_UINT32(p_DtsecMemMap->maccfg2, tmpReg32);
- /***************MACCFG2***********************/
-
- /***************IPGIFG************************/
- tmpReg32 = 0;
- ASSERT_COND(p_DtsecDriverParam->nonBackToBackIpg1 <= p_DtsecDriverParam->nonBackToBackIpg2);
- tmpReg32 = (uint32_t)((((uint32_t)p_DtsecDriverParam->nonBackToBackIpg1 <<
- IPGIFG_NON_BACK_TO_BACK_IPG_1_SHIFT) & IPGIFG_NON_BACK_TO_BACK_IPG_1) |
- (((uint32_t)p_DtsecDriverParam->nonBackToBackIpg2 <<
- IPGIFG_NON_BACK_TO_BACK_IPG_2_SHIFT) & IPGIFG_NON_BACK_TO_BACK_IPG_2) |
- (((uint32_t)p_DtsecDriverParam->minIfgEnforcement <<
- IPGIFG_MIN_IFG_ENFORCEMENT_SHIFT) & IPGIFG_MIN_IFG_ENFORCEMENT) |
- ((uint32_t)p_DtsecDriverParam->backToBackIpg & IPGIFG_BACK_TO_BACK_IPG));
- WRITE_UINT32(p_DtsecMemMap->ipgifg, tmpReg32);
- /***************IPGIFG************************/
-
- /***************HAFDUP************************/
- tmpReg32 = 0;
- if(p_DtsecDriverParam->alternateBackoffEnable)
- {
- tmpReg32 = (uint32_t) (HAFDUP_ALT_BEB | (((uint32_t)p_DtsecDriverParam->alternateBackoffVal & 0x0000000f) <<
- HAFDUP_ALTERNATE_BEB_TRUNCATION_SHIFT));
+ DTSEC_MII_WritePhyReg(p_Dtsec, (uint8_t)p_DtsecDriverParam->tbipa, 0, tmpReg16);
}
- if(p_DtsecDriverParam->backPressureNoBackoff)
- tmpReg32 |= HAFDUP_BP_NO_BACKOFF;
- if(p_DtsecDriverParam->noBackoff)
- tmpReg32 |= HAFDUP_NO_BACKOFF;
- if(p_DtsecDriverParam->excessDefer)
- tmpReg32 |= HAFDUP_EXCESS_DEFER;
- tmpReg32 |= (((uint32_t)p_DtsecDriverParam->maxRetransmission <<
- HAFDUP_RETRANSMISSION_MAX_SHIFT )& HAFDUP_RETRANSMISSION_MAX);
- tmpReg32|= ((uint32_t)p_DtsecDriverParam->collisionWindow & HAFDUP_COLLISION_WINDOW);
-
- WRITE_UINT32(p_DtsecMemMap->hafdup, tmpReg32);
- /***************HAFDUP************************/
-
- /***************MAXFRM************************/
- /* Initialize MAXFRM */
- WRITE_UINT32(p_DtsecMemMap->maxfrm,
- p_DtsecDriverParam->maxFrameLength);
- err = FmSetMacMaxFrame(p_Dtsec->fmMacControllerDriver.h_Fm,
- e_FM_MAC_1G,
- p_Dtsec->fmMacControllerDriver.macId,
- p_DtsecDriverParam->maxFrameLength);
+ /* Max Frame Length */
+ maxFrmLn = fman_dtsec_get_max_frame_len(p_Dtsec->p_MemMap);
+ err = FmSetMacMaxFrame(p_Dtsec->fmMacControllerDriver.h_Fm, e_FM_MAC_1G,
+ p_Dtsec->fmMacControllerDriver.macId, maxFrmLn);
if (err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
- /***************MAXFRM************************/
-
- /***************CAM1************************/
- WRITE_UINT32(p_DtsecMemMap->cam1,0xffffffff);
- WRITE_UINT32(p_DtsecMemMap->cam2,0xffffffff);
-
- /***************IMASK************************/
- WRITE_UINT32(p_DtsecMemMap->imask, p_Dtsec->exceptions);
- /***************IMASK************************/
-
- /***************IEVENT************************/
- WRITE_UINT32(p_DtsecMemMap->ievent, EVENTS_MASK);
-
- /***************MACSTNADDR1/2*****************/
- /* Initialize MAC Station Address registers (1 & 2) */
- /* Station address have to be swapped (big endian to little endian */
- addr = p_Dtsec->addr;
-
- tmpReg32 = (uint32_t)(addr);
- SwapUint32P(&tmpReg32);
- WRITE_UINT32(p_DtsecMemMap->macstnaddr1, tmpReg32);
-
- tmpReg32 = (uint32_t)(addr>>32);
- SwapUint32P(&tmpReg32);
- WRITE_UINT32(p_DtsecMemMap->macstnaddr2, tmpReg32);
- /***************MACSTNADDR1/2*****************/
-
- /***************DEBUG*****************/
- WRITE_UINT32(p_DtsecMemMap->tx_threshold, (uint32_t)(p_DtsecDriverParam->fifoTxThr & 0x7f));
- WRITE_UINT32(p_DtsecMemMap->tx_watermark_high, (uint32_t)(p_DtsecDriverParam->fifoTxWatermarkH & 0x7f));
- WRITE_UINT32(p_DtsecMemMap->rx_watermark_low, (uint32_t)(p_DtsecDriverParam->fifoRxWatermarkL & 0x7f));
- /***************DEBUG*****************/
-
- /*****************HASH************************/
- for(i=0 ; i<NUM_OF_HASH_REGS ; i++)
- {
- /* Initialize IADDRx */
- WRITE_UINT32(p_DtsecMemMap->igaddr[i], 0);
- /* Initialize GADDRx */
- WRITE_UINT32(p_DtsecMemMap->gaddr[i], 0);
- }
+ RETURN_ERROR(MINOR,err, NO_MSG);
- p_Dtsec->p_MulticastAddrHash = AllocHashTable(HASH_TABLE_SIZE);
- if(!p_Dtsec->p_MulticastAddrHash)
- {
+ p_Dtsec->p_MulticastAddrHash = AllocHashTable(EXTENDED_HASH_TABLE_SIZE);
+ if (!p_Dtsec->p_MulticastAddrHash) {
FreeInitResources(p_Dtsec);
RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MC hash table is FAILED"));
}
p_Dtsec->p_UnicastAddrHash = AllocHashTable(HASH_TABLE_SIZE);
- if(!p_Dtsec->p_UnicastAddrHash)
+ if (!p_Dtsec->p_UnicastAddrHash)
{
FreeInitResources(p_Dtsec);
RETURN_ERROR(MAJOR, E_NO_MEMORY, ("UC hash table is FAILED"));
}
/* register err intr handler for dtsec to FPM (err)*/
- FmRegisterIntr(p_Dtsec->fmMacControllerDriver.h_Fm, e_FM_MOD_1G_MAC, p_Dtsec->macId, e_FM_INTR_TYPE_ERR, DtsecErrException , p_Dtsec);
+ FmRegisterIntr(p_Dtsec->fmMacControllerDriver.h_Fm,
+ e_FM_MOD_1G_MAC,
+ p_Dtsec->macId,
+ e_FM_INTR_TYPE_ERR,
+ DtsecIsr,
+ p_Dtsec);
/* register 1588 intr handler for TMR to FPM (normal)*/
- FmRegisterIntr(p_Dtsec->fmMacControllerDriver.h_Fm, e_FM_MOD_1G_MAC_TMR, p_Dtsec->macId, e_FM_INTR_TYPE_NORMAL, Dtsec1588Exception , p_Dtsec);
+ FmRegisterIntr(p_Dtsec->fmMacControllerDriver.h_Fm,
+ e_FM_MOD_1G_MAC,
+ p_Dtsec->macId,
+ e_FM_INTR_TYPE_NORMAL,
+ Dtsec1588Isr,
+ p_Dtsec);
/* register normal intr handler for dtsec to main interrupt controller. */
if (p_Dtsec->mdioIrq != NO_IRQ)
{
- XX_SetIntr(p_Dtsec->mdioIrq, DtsecException, p_Dtsec);
+ XX_SetIntr(p_Dtsec->mdioIrq, DtsecMdioIsr, p_Dtsec);
XX_EnableIntr(p_Dtsec->mdioIrq);
}
XX_Free(p_DtsecDriverParam);
p_Dtsec->p_DtsecDriverParam = NULL;
- err = DtsecSetStatistics(p_Dtsec, e_FM_MAC_FULL_STATISTICS);
- if(err)
+ err = DtsecSetStatistics(h_Dtsec, e_FM_MAC_FULL_STATISTICS);
+ if (err)
{
FreeInitResources(p_Dtsec);
- RETURN_ERROR(MAJOR, err, NO_MSG);
+ RETURN_ERROR(MAJOR, err, ("Undefined statistics level"));
}
return E_OK;
@@ -1816,14 +1334,17 @@ static t_Error DtsecFree(t_Handle h_Dtsec)
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
- FreeInitResources(p_Dtsec);
-
if (p_Dtsec->p_DtsecDriverParam)
{
+ /* Called after config */
XX_Free(p_Dtsec->p_DtsecDriverParam);
p_Dtsec->p_DtsecDriverParam = NULL;
}
- XX_Free (h_Dtsec);
+ else
+ /* Called after init */
+ FreeInitResources(p_Dtsec);
+
+ XX_Free(p_Dtsec);
return E_OK;
}
@@ -1844,20 +1365,26 @@ static void InitFmMacControllerDriver(t_FmMacControllerDriver *p_FmMacController
p_FmMacControllerDriver->f_FM_MAC_ConfigPadAndCrc = DtsecConfigPadAndCrc;
p_FmMacControllerDriver->f_FM_MAC_ConfigHalfDuplex = DtsecConfigHalfDuplex;
p_FmMacControllerDriver->f_FM_MAC_ConfigLengthCheck = DtsecConfigLengthCheck;
+ p_FmMacControllerDriver->f_FM_MAC_ConfigTbiPhyAddr = DtsecConfigTbiPhyAddr;
p_FmMacControllerDriver->f_FM_MAC_ConfigException = DtsecConfigException;
+ p_FmMacControllerDriver->f_FM_MAC_ConfigResetOnInit = NULL;
p_FmMacControllerDriver->f_FM_MAC_Enable = DtsecEnable;
p_FmMacControllerDriver->f_FM_MAC_Disable = DtsecDisable;
+ p_FmMacControllerDriver->f_FM_MAC_Resume = NULL;
p_FmMacControllerDriver->f_FM_MAC_SetException = DtsecSetException;
p_FmMacControllerDriver->f_FM_MAC_SetPromiscuous = DtsecSetPromiscuous;
p_FmMacControllerDriver->f_FM_MAC_AdjustLink = DtsecAdjustLink;
+ p_FmMacControllerDriver->f_FM_MAC_SetWakeOnLan = DtsecSetWakeOnLan;
+ p_FmMacControllerDriver->f_FM_MAC_RestartAutoneg = DtsecRestartAutoneg;
p_FmMacControllerDriver->f_FM_MAC_Enable1588TimeStamp = DtsecEnable1588TimeStamp;
p_FmMacControllerDriver->f_FM_MAC_Disable1588TimeStamp = DtsecDisable1588TimeStamp;
p_FmMacControllerDriver->f_FM_MAC_SetTxAutoPauseFrames = DtsecTxMacPause;
+ p_FmMacControllerDriver->f_FM_MAC_SetTxPauseFrames = DtsecSetTxPauseFrames;
p_FmMacControllerDriver->f_FM_MAC_SetRxIgnorePauseFrames = DtsecRxIgnoreMacPause;
p_FmMacControllerDriver->f_FM_MAC_ResetCounters = DtsecResetCounters;
@@ -1875,14 +1402,11 @@ static void InitFmMacControllerDriver(t_FmMacControllerDriver *p_FmMacController
p_FmMacControllerDriver->f_FM_MAC_MII_WritePhyReg = DTSEC_MII_WritePhyReg;
p_FmMacControllerDriver->f_FM_MAC_MII_ReadPhyReg = DTSEC_MII_ReadPhyReg;
-#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
- p_FmMacControllerDriver->f_FM_MAC_DumpRegs = DtsecDumpRegs;
-#endif /* (defined(DEBUG_ERRORS) && ... */
}
/*****************************************************************************/
-/* dTSEC Config Main Entry */
+/* dTSEC Config Main Entry */
/*****************************************************************************/
/* .............................................................................. */
@@ -1890,45 +1414,41 @@ static void InitFmMacControllerDriver(t_FmMacControllerDriver *p_FmMacController
t_Handle DTSEC_Config(t_FmMacParams *p_FmMacParam)
{
t_Dtsec *p_Dtsec;
- t_DtsecDriverParam *p_DtsecDriverParam;
+ struct dtsec_cfg *p_DtsecDriverParam;
uintptr_t baseAddr;
- uint8_t i;
SANITY_CHECK_RETURN_VALUE(p_FmMacParam, E_NULL_POINTER, NULL);
baseAddr = p_FmMacParam->baseAddr;
+
/* allocate memory for the UCC GETH data structure. */
- p_Dtsec = (t_Dtsec *) XX_Malloc(sizeof(t_Dtsec));
+ p_Dtsec = (t_Dtsec *)XX_Malloc(sizeof(t_Dtsec));
if (!p_Dtsec)
{
REPORT_ERROR(MAJOR, E_NO_MEMORY, ("dTSEC driver structure"));
return NULL;
}
- /* Zero out * p_Dtsec */
memset(p_Dtsec, 0, sizeof(t_Dtsec));
InitFmMacControllerDriver(&p_Dtsec->fmMacControllerDriver);
/* allocate memory for the dTSEC driver parameters data structure. */
- p_DtsecDriverParam = (t_DtsecDriverParam *) XX_Malloc(sizeof(t_DtsecDriverParam));
+ p_DtsecDriverParam = (struct dtsec_cfg *) XX_Malloc(sizeof(struct dtsec_cfg));
if (!p_DtsecDriverParam)
{
XX_Free(p_Dtsec);
REPORT_ERROR(MAJOR, E_NO_MEMORY, ("dTSEC driver parameters"));
return NULL;
}
- /* Zero out */
- memset(p_DtsecDriverParam, 0, sizeof(t_DtsecDriverParam));
+ memset(p_DtsecDriverParam, 0, sizeof(struct dtsec_cfg));
/* Plant parameter structure pointer */
p_Dtsec->p_DtsecDriverParam = p_DtsecDriverParam;
- SetDefaultParam(p_DtsecDriverParam);
-
- for (i=0; i < sizeof(p_FmMacParam->addr); i++)
- p_Dtsec->addr |= ((uint64_t)p_FmMacParam->addr[i] << ((5-i) * 8));
+ fman_dtsec_defconfig(p_DtsecDriverParam);
- p_Dtsec->p_MemMap = (t_DtsecMemMap *)UINT_TO_PTR(baseAddr);
- p_Dtsec->p_MiiMemMap = (t_MiiAccessMemMap *)UINT_TO_PTR(baseAddr + DTSEC_TO_MII_OFFSET);
+ p_Dtsec->p_MemMap = (struct dtsec_regs *)UINT_TO_PTR(baseAddr);
+ p_Dtsec->p_MiiMemMap = (struct dtsec_mii_reg *)UINT_TO_PTR(baseAddr + DTSEC_TO_MII_OFFSET);
+ p_Dtsec->addr = ENET_ADDR_TO_UINT64(p_FmMacParam->addr);
p_Dtsec->enetMode = p_FmMacParam->enetMode;
p_Dtsec->macId = p_FmMacParam->macId;
p_Dtsec->exceptions = DEFAULT_exceptions;
@@ -1936,6 +1456,9 @@ t_Handle DTSEC_Config(t_FmMacParams *p_FmMacParam)
p_Dtsec->f_Exception = p_FmMacParam->f_Exception;
p_Dtsec->f_Event = p_FmMacParam->f_Event;
p_Dtsec->h_App = p_FmMacParam->h_App;
+ p_Dtsec->ptpTsuEnabled = p_Dtsec->p_DtsecDriverParam->ptp_tsu_en;
+ p_Dtsec->enTsuErrExeption = p_Dtsec->p_DtsecDriverParam->ptp_exception_en;
+ p_Dtsec->tbi_phy_addr = p_Dtsec->p_DtsecDriverParam->tbi_phy_addr;
return p_Dtsec;
}
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/dtsec.h b/sys/contrib/ncsw/Peripherals/FM/MAC/dtsec.h
index 4bb7a8617972..c26f40cc9664 100644
--- a/sys/contrib/ncsw/Peripherals/FM/MAC/dtsec.h
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/dtsec.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2013 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -41,81 +41,58 @@
#include "std_ext.h"
#include "error_ext.h"
#include "list_ext.h"
+#include "enet_ext.h"
+
#include "dtsec_mii_acc.h"
#include "fm_mac.h"
-#define PEMASK_TSRE 0x00010000
-
-#define IMASK_BREN 0x80000000
-#define IMASK_RXCEN 0x40000000
-#define IMASK_MSROEN 0x04000000
-#define IMASK_GTSCEN 0x02000000
-#define IMASK_BTEN 0x01000000
-#define IMASK_TXCEN 0x00800000
-#define IMASK_TXEEN 0x00400000
-#define IMASK_LCEN 0x00040000
-#define IMASK_CRLEN 0x00020000
-#define IMASK_XFUNEN 0x00010000
-#define IMASK_ABRTEN 0x00008000
-#define IMASK_IFERREN 0x00004000
-#define IMASK_MAGEN 0x00000800
-#define IMASK_MMRDEN 0x00000400
-#define IMASK_MMWREN 0x00000200
-#define IMASK_GRSCEN 0x00000100
-#define IMASK_TDPEEN 0x00000002
-#define IMASK_RDPEEN 0x00000001
-
-#define EVENTS_MASK ((uint32_t)(IMASK_BREN | \
- IMASK_RXCEN | \
- IMASK_MSROEN | \
- IMASK_GTSCEN | \
- IMASK_BTEN | \
- IMASK_TXCEN | \
- IMASK_TXEEN | \
- IMASK_ABRTEN | \
- IMASK_LCEN | \
- IMASK_CRLEN | \
- IMASK_XFUNEN | \
- IMASK_IFERREN | \
- IMASK_MAGEN | \
- IMASK_MMRDEN | \
- IMASK_MMWREN | \
- IMASK_GRSCEN | \
- IMASK_TDPEEN | \
- IMASK_RDPEEN))
-
-#define GET_EXCEPTION_FLAG(bitMask, exception) switch(exception){ \
- case e_FM_MAC_EX_1G_BAB_RX: \
- bitMask = IMASK_BREN; break; \
- case e_FM_MAC_EX_1G_RX_CTL: \
- bitMask = IMASK_RXCEN; break; \
- case e_FM_MAC_EX_1G_GRATEFUL_TX_STP_COMPLET: \
- bitMask = IMASK_GTSCEN ; break; \
- case e_FM_MAC_EX_1G_BAB_TX: \
- bitMask = IMASK_BTEN ; break; \
- case e_FM_MAC_EX_1G_TX_CTL: \
- bitMask = IMASK_TXCEN ; break; \
- case e_FM_MAC_EX_1G_TX_ERR: \
- bitMask = IMASK_TXEEN ; break; \
- case e_FM_MAC_EX_1G_LATE_COL: \
- bitMask = IMASK_LCEN ; break; \
- case e_FM_MAC_EX_1G_COL_RET_LMT: \
- bitMask = IMASK_CRLEN ; break; \
- case e_FM_MAC_EX_1G_TX_FIFO_UNDRN: \
- bitMask = IMASK_XFUNEN ; break; \
- case e_FM_MAC_EX_1G_MAG_PCKT: \
- bitMask = IMASK_MAGEN ; break; \
- case e_FM_MAC_EX_1G_MII_MNG_RD_COMPLET: \
- bitMask = IMASK_MMRDEN; break; \
- case e_FM_MAC_EX_1G_MII_MNG_WR_COMPLET: \
- bitMask = IMASK_MMWREN ; break; \
- case e_FM_MAC_EX_1G_GRATEFUL_RX_STP_COMPLET: \
- bitMask = IMASK_GRSCEN; break; \
- case e_FM_MAC_EX_1G_TX_DATA_ERR: \
- bitMask = IMASK_TDPEEN; break; \
- case e_FM_MAC_EX_1G_RX_MIB_CNT_OVFL: \
- bitMask = IMASK_MSROEN ; break; \
+#define DEFAULT_exceptions \
+ ((uint32_t)(DTSEC_IMASK_BREN | \
+ DTSEC_IMASK_RXCEN | \
+ DTSEC_IMASK_BTEN | \
+ DTSEC_IMASK_TXCEN | \
+ DTSEC_IMASK_TXEEN | \
+ DTSEC_IMASK_ABRTEN | \
+ DTSEC_IMASK_LCEN | \
+ DTSEC_IMASK_CRLEN | \
+ DTSEC_IMASK_XFUNEN | \
+ DTSEC_IMASK_IFERREN | \
+ DTSEC_IMASK_MAGEN | \
+ DTSEC_IMASK_TDPEEN | \
+ DTSEC_IMASK_RDPEEN))
+
+#define GET_EXCEPTION_FLAG(bitMask, exception) switch (exception){ \
+ case e_FM_MAC_EX_1G_BAB_RX: \
+ bitMask = DTSEC_IMASK_BREN; break; \
+ case e_FM_MAC_EX_1G_RX_CTL: \
+ bitMask = DTSEC_IMASK_RXCEN; break; \
+ case e_FM_MAC_EX_1G_GRATEFUL_TX_STP_COMPLET: \
+ bitMask = DTSEC_IMASK_GTSCEN ; break; \
+ case e_FM_MAC_EX_1G_BAB_TX: \
+ bitMask = DTSEC_IMASK_BTEN ; break; \
+ case e_FM_MAC_EX_1G_TX_CTL: \
+ bitMask = DTSEC_IMASK_TXCEN ; break; \
+ case e_FM_MAC_EX_1G_TX_ERR: \
+ bitMask = DTSEC_IMASK_TXEEN ; break; \
+ case e_FM_MAC_EX_1G_LATE_COL: \
+ bitMask = DTSEC_IMASK_LCEN ; break; \
+ case e_FM_MAC_EX_1G_COL_RET_LMT: \
+ bitMask = DTSEC_IMASK_CRLEN ; break; \
+ case e_FM_MAC_EX_1G_TX_FIFO_UNDRN: \
+ bitMask = DTSEC_IMASK_XFUNEN ; break; \
+ case e_FM_MAC_EX_1G_MAG_PCKT: \
+ bitMask = DTSEC_IMASK_MAGEN ; break; \
+ case e_FM_MAC_EX_1G_MII_MNG_RD_COMPLET: \
+ bitMask = DTSEC_IMASK_MMRDEN; break; \
+ case e_FM_MAC_EX_1G_MII_MNG_WR_COMPLET: \
+ bitMask = DTSEC_IMASK_MMWREN ; break; \
+ case e_FM_MAC_EX_1G_GRATEFUL_RX_STP_COMPLET: \
+ bitMask = DTSEC_IMASK_GRSCEN; break; \
+ case e_FM_MAC_EX_1G_TX_DATA_ERR: \
+ bitMask = DTSEC_IMASK_TDPEEN; break; \
+ case e_FM_MAC_EX_1G_RX_MIB_CNT_OVFL: \
+ bitMask = DTSEC_IMASK_MSROEN ; break; \
default: bitMask = 0;break;}
@@ -145,192 +122,18 @@ typedef uint32_t t_ErrorDisable;
#define HASH_TABLE_SIZE 256 /* Hash table size (= 32 bits * 8 regs) */
-#define DTSEC_TO_MII_OFFSET 0x1120 /* number of pattern match registers (entries) */
-
-#define DEFAULT_errorDisabled 0
-#define DEFAULT_promiscuousEnable FALSE
-#define DEFAULT_pauseExtended 0x0
-#define DEFAULT_pauseTime 0xf000
-#define DEFAULT_halfDuplex FALSE
-#define DEFAULT_halfDulexFlowControlEn FALSE
-#define DEFAULT_txTimeStampEn FALSE
-#define DEFAULT_rxTimeStampEn FALSE
-#define DEFAULT_packetAlignment 0
-#define DEFAULT_controlFrameAccept FALSE
-#define DEFAULT_groupHashExtend FALSE
-#define DEFAULT_broadcReject FALSE
-#define DEFAULT_rxShortFrame TRUE
-#define DEFAULT_exactMatch FALSE
-#define DEFAULT_debugMode FALSE
-#define DEFAULT_loopback FALSE
-#define DEFAULT_actOnRxPauseFrame TRUE
-#define DEFAULT_actOnTxPauseFrame TRUE
-
-#define DEFAULT_PreAmLength 0x7
-#define DEFAULT_PreAmRxEn FALSE
-#define DEFAULT_PreAmTxEn FALSE
-#define DEFAULT_lengthCheckEnable FALSE
-#define DEFAULT_padAndCrcEnable TRUE
-#define DEFAULT_crcEnable FALSE
-
-#define DEFAULT_nonBackToBackIpg1 0x40
-#define DEFAULT_nonBackToBackIpg2 0x60
-#define DEFAULT_minIfgEnforcement 0x50
-#define DEFAULT_backToBackIpg 0x60
-
-#define DEFAULT_altBackoffVal 0x0A
-#define DEFAULT_altBackoffEnable FALSE
-#define DEFAULT_backPressureNoBackoff FALSE
-#define DEFAULT_noBackoff FALSE
-#define DEFAULT_excessDefer TRUE
-#define DEFAULT_maxRetransmission 0x0F
-#define DEFAULT_collisionWindow 0x37
-
-#define DEFAULT_maxFrameLength 0x600
-
-#define DEFAULT_collisionWindow 0x37
-
-#define DEFAULT_fifoTxThr 0x10
-#define DEFAULT_fifoTxWatermarkH 0x7e
-#define DEFAULT_fifoRxWatermarkL 0x08
-#define DEFAULT_tbiPhyAddr 5
-
-#define DEFAULT_exceptions ((uint32_t)(IMASK_BREN | \
- IMASK_RXCEN | \
- IMASK_BTEN | \
- IMASK_TXCEN | \
- IMASK_TXEEN | \
- IMASK_ABRTEN | \
- IMASK_LCEN | \
- IMASK_CRLEN | \
- IMASK_XFUNEN | \
- IMASK_IFERREN | \
- IMASK_MAGEN | \
- IMASK_TDPEEN | \
- IMASK_RDPEEN))
+#define HASH_TABLE_SIZE 256 /* Hash table size (32 bits * 8 regs) */
+#define EXTENDED_HASH_TABLE_SIZE 512 /* Extended Hash table size (32 bits * 16 regs) */
+#define DTSEC_TO_MII_OFFSET 0x1000 /* number of pattern match registers (entries) */
#define MAX_PHYS 32 /* maximum number of phys */
-#define DTSEC_ID1_ID 0xffff0000
-#define DTSEC_ID1_REV_MJ 0x0000FF00
-#define DTSEC_ID1_REV_MN 0x000000ff
-
-#define ID2_INT_REDUCED_OFF 0x00010000
-#define ID2_INT_NORMAL_OFF 0x00020000
-
-#define ECNTRL_CLRCNT 0x00004000
-#define ECNTRL_AUTOZ 0x00002000
-#define ECNTRL_STEN 0x00001000
-#define ECNTRL_CFG_RO 0x80000000
-#define ECNTRL_GMIIM 0x00000040
-#define ECNTRL_TBIM 0x00000020
-#define ECNTRL_SGMIIM 0x00000002
-#define ECNTRL_RPM 0x00000010
-#define ECNTRL_R100M 0x00000008
-#define ECNTRL_RMM 0x00000004
-#define ECNTRL_QSGMIIM 0x00000001
-
-#define TCTRL_THDF 0x00000800
-#define TCTRL_TTSE 0x00000040
-#define TCTRL_GTS 0x00000020
-#define TCTRL_TFC_PAUSE 0x00000010
-
-/* PTV offsets */
-#define PTV_PTE_OFST 16
-
-#define RCTRL_CFA 0x00008000
-#define RCTRL_GHTX 0x00000400
-#define RCTRL_RTSE 0x00000040
-#define RCTRL_GRS 0x00000020
-#define RCTRL_BC_REJ 0x00000010
-#define RCTRL_MPROM 0x00000008
-#define RCTRL_RSF 0x00000004
-#define RCTRL_EMEN 0x00000002
-#define RCTRL_UPROM 0x00000001
-#define RCTRL_PROM (RCTRL_UPROM | RCTRL_MPROM)
-
-#define TMR_CTL_ESFDP 0x00000800
-#define TMR_CTL_ESFDE 0x00000400
-
-#define TSEC_ID1_DEBUG 0x00e00c00
-#define DEBUG_ENABLE 0x80000000
-#define DPERROR_Tx_ERROR_ON_SEC 0x00400000
-#define DPERROR_Tx_ERROR_ON_WRITE 0x10000000
-#define DPERROR_Rx_ERROR_ON_SEC 0x00000040
-#define DPERROR_Rx_ERROR_ON_WRITE 0x00001000
-#define DPERROR_STT 0x80000000
-#define DPERROR_STR 0x00008000
-
-#define MACCFG1_SOFT_RESET 0x80000000
-#define MACCFG1_LOOPBACK 0x00000100
-#define MACCFG1_RX_FLOW 0x00000020
-#define MACCFG1_TX_FLOW 0x00000010
-#define MACCFG1_TX_EN 0x00000001
-#define MACCFG1_RX_EN 0x00000004
-#define MACCFG1_RESET_RxMC 0x00080000
-#define MACCFG1_RESET_TxMC 0x00040000
-#define MACCFG1_RESET_RxFUN 0x00020000
-#define MACCFG1_RESET_TxFUN 0x00010000
-
-#define MACCFG2_NIBBLE_MODE 0x00000100
-#define MACCFG2_BYTE_MODE 0x00000200
-#define MACCFG2_PRE_AM_Rx_EN 0x00000080
-#define MACCFG2_PRE_AM_Tx_EN 0x00000040
-#define MACCFG2_LENGTH_CHECK 0x00000010
-#define MACCFG2_MAGIC_PACKET_EN 0x00000008
-#define MACCFG2_PAD_CRC_EN 0x00000004
-#define MACCFG2_CRC_EN 0x00000002
-#define MACCFG2_FULL_DUPLEX 0x00000001
-
-#define PREAMBLE_LENGTH_SHIFT 12
-
-#define IPGIFG_NON_BACK_TO_BACK_IPG_1_SHIFT 24
-#define IPGIFG_NON_BACK_TO_BACK_IPG_2_SHIFT 16
-#define IPGIFG_MIN_IFG_ENFORCEMENT_SHIFT 8
-
-#define IPGIFG_NON_BACK_TO_BACK_IPG_1 0x7F000000
-#define IPGIFG_NON_BACK_TO_BACK_IPG_2 0x007F0000
-#define IPGIFG_MIN_IFG_ENFORCEMENT 0x0000FF00
-#define IPGIFG_BACK_TO_BACK_IPG 0x0000007F
-
-#define HAFDUP_ALT_BEB 0x00080000
-#define HAFDUP_BP_NO_BACKOFF 0x00040000
-#define HAFDUP_NO_BACKOFF 0x00020000
-#define HAFDUP_EXCESS_DEFER 0x00010000
-#define HAFDUP_COLLISION_WINDOW 0x000003ff
-
-#define HAFDUP_ALTERNATE_BEB_TRUNCATION_SHIFT 20
-#define HAFDUP_RETRANSMISSION_MAX_SHIFT 12
-#define HAFDUP_RETRANSMISSION_MAX 0x0000f000
-
-#define NUM_OF_HASH_REGS 8 /* Number of hash table registers */
-
-#define DEBUG_GET_FIFO_READ_INDEX 0x007f0000
-#define DEBUG_GET_FIFO_WRITE_INDEX 0x0000007f
-/* Pause Time Value Register */
-#define PTV_PTE_SHIFT 16
-
-#define MASK22BIT 0x003FFFFF
-#define MASK16BIT 0x0000FFFF
-#define MASK12BIT 0x00000FFF
-#define MASK8BIT 0x000000FF
-
#define VAL32BIT 0x100000000LL
#define VAL22BIT 0x00400000
#define VAL16BIT 0x00010000
#define VAL12BIT 0x00001000
-/* PHY Control Register */
-#define PHY_CR_LOOPBACK 0x4000
-#define PHY_CR_SPEED0 0x2000
-#define PHY_CR_ANE 0x1000
-#define PHY_CR_FULLDUPLEX 0x0100
-#define PHY_CR_SPEED1 0x0040
-
-#define PHY_TBICON_SRESET 0x8000
-#define PHY_TBICON_SPEED2 0x0020
-
/* CAR1/2 bits */
#define CAR1_TR64 0x80000000
#define CAR1_TR127 0x40000000
@@ -363,19 +166,6 @@ typedef uint32_t t_ErrorDisable;
#define CAR2_TXPF 0x00000200
#define CAR2_TDRP 0x00000001
-#define CAM1_ERRORS_ONLY (CAR1_RXPF | \
- CAR1_RALN | \
- CAR1_RFLR | \
- CAR1_RCDE | \
- CAR1_RCSE | \
- CAR1_RUND | \
- CAR1_ROVR | \
- CAR1_RFRG | \
- CAR1_RJBR | \
- CAR1_RDRP)
-
-#define CAM2_ERRORS_ONLY (CAR2_TFCS | CAR2_TXPF | CAR2_TDRP)
-
typedef struct t_InternalStatistics
{
uint64_t tr64;
@@ -408,202 +198,11 @@ typedef struct t_InternalStatistics
uint64_t tfcs;
} t_InternalStatistics;
-#if defined(__MWERKS__) && !defined(__GNUC__)
-#pragma pack(push,1)
-#endif /* defined(__MWERKS__) && ... */
-#define MEM_MAP_START
-
-typedef _Packed struct
-{
- uint32_t exact_match1; /* octets 1-4 */
- uint32_t exact_match2; /* octets 5-6 */
-} _PackedType macRegs;
-
-typedef _Packed struct
-{
- volatile uint32_t tsec_id1; /* 0x000 ETSEC_ID register */
- volatile uint32_t tsec_id2; /* 0x004 ETSEC_ID2 register */
- volatile uint32_t ievent; /* 0x008 Interrupt event register */
- volatile uint32_t imask; /* 0x00C Interrupt mask register */
- volatile uint32_t edis; /* 0x010 Error disabled register */
- volatile uint32_t ecntrl; /* 0x014 E control register */
- volatile uint32_t ptv; /* 0x018 Pause time value register */
- volatile uint32_t tbipa; /* 0x01C TBI PHY address register */
- volatile uint32_t tmr_ctrl; /* 0x020 Time-stamp Control register */
- volatile uint32_t tmr_pevent; /* 0x024 Time-stamp event register */
- volatile uint32_t tmr_pemask; /* 0x028 Timer event mask register */
- volatile uint32_t DTSEC_RESERVED2; /* 0x02C */
- volatile uint32_t iobistctl; /* 0x030 IO BIST Control register */
- volatile uint32_t DTSEC_RESERVED3[3]; /* 0x034 */
-
- volatile uint32_t tctrl; /* 0x040 Transmit control register */
- volatile uint32_t DTSEC_RESERVED4[3]; /* 0x044-0x04C */
- volatile uint32_t rctrl; /* 0x050 Receive control register */
- volatile uint32_t DTSEC_RESERVED5[11]; /* 0x054- 0x07C */
-
- volatile uint32_t igaddr[8]; /* 0x080-0x09C Individual/group address registers 0-7 */
- volatile uint32_t gaddr[8]; /* 0x0A0-0x0BC Group address registers 0-7 */
- volatile uint32_t ETSEC_RESERVED6[16]; /* 0x0C0-0x0FC */
-
- volatile uint32_t maccfg1; /* 0x100 MAC configuration #1 */
- volatile uint32_t maccfg2; /* 0x104 MAC configuration #2 */
- volatile uint32_t ipgifg; /* 0x108 IPG/IFG */
- volatile uint32_t hafdup; /* 0x10C Half-duplex */
- volatile uint32_t maxfrm; /* 0x110 Maximum frame */
- volatile uint32_t DTSEC_RESERVED7[3]; /* 0x114-0x11C register */
- t_MiiAccessMemMap miiMemMap;
- volatile uint32_t ifctrl; /* 0x138 MII Mgmt:interface control */
- volatile uint32_t ifstat; /* 0x13C Interface status */
- volatile uint32_t macstnaddr1; /* 0x140 Station Address,part 1 */
- volatile uint32_t macstnaddr2; /* 0x144 Station Address,part 2 */
- volatile macRegs macaddr[DTSEC_NUM_OF_PADDRS]; /* 0x148-0x1BC mac exact match addresses 1-15, parts 1-2 */
- volatile uint32_t DTSEC_RESERVED8[16]; /* 0x1C0-0x1FC register */
-
- /* RMON MIB REGISTERS */
- /* TRANSMIT and RECEIVE COUNTERS */
-
- volatile uint32_t tr64; /* 0x200 transmit and receive 64 byte frame counter */
- volatile uint32_t tr127; /* 0x204 transmit and receive 65 to 127 byte frame counter */
- volatile uint32_t tr255; /* 0x208 transmit and receive 128 to 255 byte frame counter */
- volatile uint32_t tr511; /* 0x20C transmit and receive 256 to 511 byte frame counter */
- volatile uint32_t tr1k; /* 0x210 transmit and receive 512 to 1023 byte frame counter */
- volatile uint32_t trmax; /* 0x214 transmit and receive 1024 to 1518 byte frame counter */
- volatile uint32_t trmgv; /* 0x218 transmit and receive 1519 to 1522 byte good VLAN frame count */
-
- /* RECEIVE COUNTERS */
- volatile uint32_t rbyt; /* 0x21C receive byte counter */
- volatile uint32_t rpkt; /* 0x220 receive packet counter */
- volatile uint32_t rfcs; /* 0x224 receive FCS error counter */
- volatile uint32_t rmca; /* 0x228 RMCA receive multicast packet counter */
- volatile uint32_t rbca; /* 0x22C receive broadcast packet counter */
- volatile uint32_t rxcf; /* 0x230 receive control frame packet counter */
- volatile uint32_t rxpf; /* 0x234 receive PAUSE frame packet counter */
- volatile uint32_t rxuo; /* 0x238 receive unknown OP code counter */
- volatile uint32_t raln; /* 0x23C receive alignment error counter */
- volatile uint32_t rflr; /* 0x240 receive frame length error counter */
- volatile uint32_t rcde; /* 0x244 receive code error counter */
- volatile uint32_t rcse; /* 0x248 receive carrier sense error counter */
- volatile uint32_t rund; /* 0x24C receive undersize packet counter */
- volatile uint32_t rovr; /* 0x250 receive oversize packet counter */
- volatile uint32_t rfrg; /* 0x254 receive fragments counter */
- volatile uint32_t rjbr; /* 0x258 receive jabber counter */
- volatile uint32_t rdrp; /* 0x25C receive drop */
-
- /* TRANSMIT COUNTERS */
- volatile uint32_t tbyt; /* 0x260 transmit byte counter */
- volatile uint32_t tpkt; /* 0x264 transmit packet counter */
- volatile uint32_t tmca; /* 0x268 transmit multicast packet counter */
- volatile uint32_t tbca; /* 0x26C transmit broadcast packet counter */
- volatile uint32_t txpf; /* 0x270 transmit PAUSE control frame counter */
- volatile uint32_t tdfr; /* 0x274 transmit deferral packet counter */
- volatile uint32_t tedf; /* 0x278 transmit excessive deferral packet counter */
- volatile uint32_t tscl; /* 0x27C transmit single collision packet counter */
- volatile uint32_t tmcl; /* 0x280 transmit multiple collision packet counter */
- volatile uint32_t tlcl; /* 0x284 transmit late collision packet counter */
- volatile uint32_t txcl; /* 0x288 transmit excessive collision packet counter */
- volatile uint32_t tncl; /* 0x28C transmit total collision counter */
- volatile uint32_t DTSEC_RESERVED9; /* 0x290 */
- volatile uint32_t tdrp; /* 0x294 transmit drop frame counter */
- volatile uint32_t tjbr; /* 0x298 transmit jabber frame counter */
- volatile uint32_t tfcs; /* 0x29C transmit FCS error counter */
- volatile uint32_t txcf; /* 0x2A0 transmit control frame counter */
- volatile uint32_t tovr; /* 0x2A4 transmit oversize frame counter */
- volatile uint32_t tund; /* 0x2A8 transmit undersize frame counter */
- volatile uint32_t tfrg; /* 0x2AC transmit fragments frame counter */
-
- /* GENERAL REGISTERS */
- volatile uint32_t car1; /* 0x2B0 carry register one register* */
- volatile uint32_t car2; /* 0x2B4 carry register two register* */
- volatile uint32_t cam1; /* 0x2B8 carry register one mask register */
- volatile uint32_t cam2; /* 0x2BC carry register two mask register */
- volatile uint32_t DTSEC_RESERVED10[16]; /* 0x2C0-0x2FC */
-
- /* Debug and Factory Test Registers */
- volatile uint32_t debug; /* 0x300 DEBUG - Debug Register */
- volatile uint32_t dperror; /* 0x304 DPERROR - Parity Error Register */
- volatile uint32_t hwassert; /* 0x308 HWASSERT */
- volatile uint32_t RESERVED11; /* 0x30C Reserved */
- volatile uint32_t rx_fifo_ptr; /* 0x310 RXFIFOPTR - Rx FIFO R/W Pointer Register */
- volatile uint32_t rx_fifo_dath; /* 0x314 RXFIFODATH - Rx FIFO Data Register */
- volatile uint32_t rx_fifo_datl; /* 0x318 RXFIFODATL - Rx FIFO Data Register */
- volatile uint32_t rx_fifo_stat; /* 0x31C RXFIFOSTAT - Rx FIFO Status Register */
- volatile uint32_t tx_fifo_ptr; /* 0x320 TXFIFOPTR - Tx FIFO R/W Pointer Register */
- volatile uint32_t tx_fifo_dath; /* 0x324 TXFIFODATH - Rx FIFO Data Register */
- volatile uint32_t tx_fifo_datl; /* 0x328 TXFIFODATL - Rx FIFO Data Register */
- volatile uint32_t tx_fifo_stat; /* 0x32C TXFIFOSTAT - Tx FIFO Status Register */
- volatile uint32_t pkt_rcv_cnt; /* 0x330 PKTRCVCNT - Number of packets accepted and written to Rx FIFO */
- volatile uint32_t RESERVED12[3]; /* 0x334-0x33C Reserved */
- volatile uint32_t tx_threshold; /* 0x340 Transmit threshold; Number of entries (4 bytes units) before starting to transmit to the MAC */
- volatile uint32_t tx_watermark_high;/* 0x344 Transmit watermark high; Number of entries (4 byte units) before de-asserting Ready to packet Interface */
- volatile uint32_t rx_watermark_low; /* 0x348 Receive watermark low; Number of entries (4 byte units) before unloading to packet Interface */
-} _PackedType t_DtsecMemMap;
-
-#define MEM_MAP_END
-#if defined(__MWERKS__) && !defined(__GNUC__)
-#pragma pack(pop)
-#endif /* defined(__MWERKS__) && ... */
-
-
-typedef struct {
- uint32_t errorDisabled;
- bool halfDuplex;
- uint16_t pauseTime;
- uint16_t pauseExtended;
- uint8_t tbiPhyAddr; /**< TBI Physical address (1-31) [DEFAULT_tbiPhyAddr] */
-
- bool autoZeroCounters;
- bool promiscuousEnable;
-
- bool halfDulexFlowControlEn;
- bool txTimeStampEn;
- bool rxTimeStampEn;
-
- uint8_t packetAlignmentPadding;
- bool controlFrameAccept;
- bool groupHashExtend;
- bool broadcReject;
- bool rxShortFrame;
- bool exactMatch;
-
- bool debugMode;
-
- bool loopback;
- bool actOnRxPauseFrame;
- bool actOnTxPauseFrame;
-
- uint8_t nonBackToBackIpg1;
- uint8_t nonBackToBackIpg2;
- uint8_t minIfgEnforcement;
- uint8_t backToBackIpg;
-
- uint8_t preambleLength;
- bool preambleRxEn;
- bool preambleTxEn;
- bool lengthCheckEnable;
- bool magicPacketEnable;
- bool padAndCrcEnable;
- bool crcEnable;
-
- bool alternateBackoffEnable;
- uint8_t alternateBackoffVal;
- bool backPressureNoBackoff;
- bool noBackoff;
- bool excessDefer;
- uint8_t maxRetransmission;
- uint16_t collisionWindow;
-
- uint16_t maxFrameLength;
-
- uint8_t fifoTxThr;
- uint8_t fifoTxWatermarkH;
- uint8_t fifoRxWatermarkL;
-} t_DtsecDriverParam;
-
typedef struct {
t_FmMacControllerDriver fmMacControllerDriver;
t_Handle h_App; /**< Handle to the upper layer application */
- t_DtsecMemMap *p_MemMap; /**< pointer to dTSEC memory mapped registers. */
- t_MiiAccessMemMap *p_MiiMemMap; /**< pointer to dTSEC MII memory mapped registers. */
+ struct dtsec_regs *p_MemMap; /**< pointer to dTSEC memory mapped registers. */
+ struct dtsec_mii_reg *p_MiiMemMap; /**< pointer to dTSEC MII memory mapped registers. */
uint64_t addr; /**< MAC address of device; */
e_EnetMode enetMode; /**< Ethernet physical interface */
t_FmMacExceptionCallback *f_Exception;
@@ -612,23 +211,18 @@ typedef struct {
bool indAddrRegUsed[DTSEC_NUM_OF_PADDRS]; /**< Whether a particular individual address recognition register is being used */
uint64_t paddr[DTSEC_NUM_OF_PADDRS]; /**< MAC address for particular individual address recognition register */
uint8_t numOfIndAddrInRegs; /**< Number of individual addresses in registers for this station. */
- bool debugMode;
bool halfDuplex;
t_InternalStatistics internalStatistics;
t_EthHash *p_MulticastAddrHash; /* pointer to driver's global address hash table */
t_EthHash *p_UnicastAddrHash; /* pointer to driver's individual address hash table */
uint8_t macId;
+ uint8_t tbi_phy_addr;
uint32_t exceptions;
bool ptpTsuEnabled;
bool enTsuErrExeption;
e_FmMacStatisticsLevel statisticsLevel;
-
- t_DtsecDriverParam *p_DtsecDriverParam;
+ struct dtsec_cfg *p_DtsecDriverParam;
} t_Dtsec;
-t_Error DTSEC_MII_WritePhyReg(t_Handle h_Dtsec, uint8_t phyAddr, uint8_t reg, uint16_t data);
-t_Error DTSEC_MII_ReadPhyReg(t_Handle h_Dtsec, uint8_t phyAddr, uint8_t reg, uint16_t *p_Data);
-
-
#endif /* __DTSEC_H */
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/dtsec_mii_acc.c b/sys/contrib/ncsw/Peripherals/FM/MAC/dtsec_mii_acc.c
index be85fa21b206..87da25ff9e35 100644
--- a/sys/contrib/ncsw/Peripherals/FM/MAC/dtsec_mii_acc.c
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/dtsec_mii_acc.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2013 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File dtsec_mii_acc.c
@@ -40,6 +41,7 @@
#include "std_ext.h"
#include "fm_mac.h"
#include "dtsec.h"
+#include "fsl_fman_dtsec_mii_acc.h"
/*****************************************************************************/
@@ -48,33 +50,20 @@ t_Error DTSEC_MII_WritePhyReg(t_Handle h_Dtsec,
uint8_t reg,
uint16_t data)
{
- t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
- t_MiiAccessMemMap *p_MiiAccess;
- uint32_t tmpReg;
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
+ struct dtsec_mii_reg *miiregs;
+ uint16_t dtsec_freq;
+ t_Error err;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_MiiMemMap, E_INVALID_HANDLE);
- p_MiiAccess = p_Dtsec->p_MiiMemMap;
-
- /* Stop the MII management read cycle */
- WRITE_UINT32(p_MiiAccess->miimcom, 0);
- /* Dummy read to make sure MIIMCOM is written */
- tmpReg = GET_UINT32(p_MiiAccess->miimcom);
-
- /* Setting up MII Management Address Register */
- tmpReg = (uint32_t)((phyAddr << MIIMADD_PHY_ADDR_SHIFT) | reg);
- WRITE_UINT32(p_MiiAccess->miimadd, tmpReg);
+ dtsec_freq = (uint16_t)(p_Dtsec->fmMacControllerDriver.clkFreq >> 1);
+ miiregs = p_Dtsec->p_MiiMemMap;
- /* Setting up MII Management Control Register with data */
- WRITE_UINT32(p_MiiAccess->miimcon, (uint32_t)data);
- /* Dummy read to make sure MIIMCON is written */
- tmpReg = GET_UINT32(p_MiiAccess->miimcon);
+ err = (t_Error)fman_dtsec_mii_write_reg(miiregs, phyAddr, reg, data, dtsec_freq);
- /* Wait till MII management write is complete */
- while ((GET_UINT32(p_MiiAccess->miimind)) & MIIMIND_BUSY) ;
-
- return E_OK;
+ return err;
}
/*****************************************************************************/
@@ -83,38 +72,26 @@ t_Error DTSEC_MII_ReadPhyReg(t_Handle h_Dtsec,
uint8_t reg,
uint16_t *p_Data)
{
- t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
- t_MiiAccessMemMap *p_MiiAccess;
- uint32_t tmpReg;
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
+ struct dtsec_mii_reg *miiregs;
+ uint16_t dtsec_freq;
+ t_Error err;
SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Dtsec->p_MiiMemMap, E_INVALID_HANDLE);
- p_MiiAccess = p_Dtsec->p_MiiMemMap;
+ dtsec_freq = (uint16_t)(p_Dtsec->fmMacControllerDriver.clkFreq >> 1);
+ miiregs = p_Dtsec->p_MiiMemMap;
- /* Setting up the MII Management Address Register */
- tmpReg = (uint32_t)((phyAddr << MIIMADD_PHY_ADDR_SHIFT) | reg);
- WRITE_UINT32(p_MiiAccess->miimadd, tmpReg);
-
- /* Perform an MII management read cycle */
- WRITE_UINT32(p_MiiAccess->miimcom, MIIMCOM_READ_CYCLE);
- /* Dummy read to make sure MIIMCOM is written */
- tmpReg = GET_UINT32(p_MiiAccess->miimcom);
-
- /* Wait till MII management read is complete */
- while ((GET_UINT32(p_MiiAccess->miimind)) & MIIMIND_BUSY) ;
-
- /* Read MII management status */
- *p_Data = (uint16_t)GET_UINT32(p_MiiAccess->miimstat);
-
- WRITE_UINT32(p_MiiAccess->miimcom, 0);
- /* Dummy read to make sure MIIMCOM is written */
- tmpReg = GET_UINT32(p_MiiAccess->miimcom);
+ err = fman_dtsec_mii_read_reg(miiregs, phyAddr, reg, p_Data, dtsec_freq);
if (*p_Data == 0xffff)
RETURN_ERROR(MINOR, E_NO_DEVICE,
("Read wrong data (0xffff): phyAddr 0x%x, reg 0x%x",
phyAddr, reg));
+ if (err)
+ RETURN_ERROR(MINOR, (t_Error)err, NO_MSG);
return E_OK;
}
+
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/dtsec_mii_acc.h b/sys/contrib/ncsw/Peripherals/FM/MAC/dtsec_mii_acc.h
index 7c529c2bd02d..75cc658a5c50 100644
--- a/sys/contrib/ncsw/Peripherals/FM/MAC/dtsec_mii_acc.h
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/dtsec_mii_acc.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2013 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -36,43 +36,7 @@
#include "std_ext.h"
-/* MII Management Configuration Register */
-#define MIIMCFG_RESET_MGMT 0x80000000
-#define MIIMCFG_MGMT_CLOCK_SELECT 0x00000007
-
-/* MII Management Command Register */
-#define MIIMCOM_READ_CYCLE 0x00000001
-#define MIIMCOM_SCAN_CYCLE 0x00000002
-
-/* MII Management Address Register */
-#define MIIMADD_PHY_ADDR_SHIFT 8
-
-/* MII Management Indicator Register */
-#define MIIMIND_BUSY 0x00000001
-
-
-#if defined(__MWERKS__) && !defined(__GNUC__)
-#pragma pack(push,1)
-#endif /* defined(__MWERKS__) && ... */
-#define MEM_MAP_START
-
-/*----------------------------------------------------*/
-/* MII Configuration Control Memory Map Registers */
-/*----------------------------------------------------*/
-typedef _Packed struct t_MiiAccessMemMap
-{
- volatile uint32_t miimcfg; /* MII Mgmt:configuration */
- volatile uint32_t miimcom; /* MII Mgmt:command */
- volatile uint32_t miimadd; /* MII Mgmt:address */
- volatile uint32_t miimcon; /* MII Mgmt:control 3 */
- volatile uint32_t miimstat; /* MII Mgmt:status */
- volatile uint32_t miimind; /* MII Mgmt:indicators */
-} _PackedType t_MiiAccessMemMap ;
-
-#define MEM_MAP_END
-#if defined(__MWERKS__) && !defined(__GNUC__)
-#pragma pack(pop)
-#endif /* defined(__MWERKS__) && ... */
-
+t_Error DTSEC_MII_WritePhyReg(t_Handle h_Dtsec, uint8_t phyAddr, uint8_t reg, uint16_t data);
+t_Error DTSEC_MII_ReadPhyReg(t_Handle h_Dtsec, uint8_t phyAddr, uint8_t reg, uint16_t *p_Data);
#endif /* __DTSEC_MII_ACC_H */
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/fm_mac.c b/sys/contrib/ncsw/Peripherals/FM/MAC/fm_mac.c
index 4eb39540ee9b..20bf150a36ff 100644
--- a/sys/contrib/ncsw/Peripherals/FM/MAC/fm_mac.c
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/fm_mac.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm_mac.c
@@ -45,18 +46,34 @@
#include "fm_mac.h"
-/* ........................................................................... */
+/* ......................................................................... */
t_Handle FM_MAC_Config (t_FmMacParams *p_FmMacParam)
{
t_FmMacControllerDriver *p_FmMacControllerDriver;
+ uint16_t fmClkFreq;
SANITY_CHECK_RETURN_VALUE(p_FmMacParam, E_INVALID_HANDLE, NULL);
- if(ENET_SPEED_FROM_MODE(p_FmMacParam->enetMode) < e_ENET_SPEED_10000)
+ fmClkFreq = FmGetClockFreq(p_FmMacParam->h_Fm);
+ if (fmClkFreq == 0)
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Can't get clock for MAC!"));
+ return NULL;
+ }
+
+#if (DPAA_VERSION == 10)
+ if (ENET_SPEED_FROM_MODE(p_FmMacParam->enetMode) < e_ENET_SPEED_10000)
p_FmMacControllerDriver = (t_FmMacControllerDriver *)DTSEC_Config(p_FmMacParam);
else
- p_FmMacControllerDriver = (t_FmMacControllerDriver *)TGEC_Config(p_FmMacParam);
+#if FM_MAX_NUM_OF_10G_MACS > 0
+ p_FmMacControllerDriver = (t_FmMacControllerDriver *)TGEC_Config(p_FmMacParam);
+#else
+ p_FmMacControllerDriver = NULL;
+#endif /* FM_MAX_NUM_OF_10G_MACS > 0 */
+#else
+ p_FmMacControllerDriver = (t_FmMacControllerDriver *)MEMAC_Config(p_FmMacParam);
+#endif /* (DPAA_VERSION == 10) */
if (!p_FmMacControllerDriver)
return NULL;
@@ -66,10 +83,12 @@ t_Handle FM_MAC_Config (t_FmMacParams *p_FmMacParam)
p_FmMacControllerDriver->macId = p_FmMacParam->macId;
p_FmMacControllerDriver->resetOnInit = DEFAULT_resetOnInit;
+ p_FmMacControllerDriver->clkFreq = fmClkFreq;
+
return (t_Handle)p_FmMacControllerDriver;
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_Init (t_Handle h_FmMac)
{
@@ -78,20 +97,19 @@ t_Error FM_MAC_Init (t_Handle h_FmMac)
SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
if (p_FmMacControllerDriver->resetOnInit &&
+ !p_FmMacControllerDriver->f_FM_MAC_ConfigResetOnInit &&
(FmResetMac(p_FmMacControllerDriver->h_Fm,
- ((ENET_INTERFACE_FROM_MODE(p_FmMacControllerDriver->enetMode) == e_ENET_IF_XGMII) ? e_FM_MAC_10G : e_FM_MAC_1G),
- p_FmMacControllerDriver->macId) != E_OK))
+ ((ENET_INTERFACE_FROM_MODE(p_FmMacControllerDriver->enetMode) == e_ENET_IF_XGMII) ?
+ e_FM_MAC_10G : e_FM_MAC_1G),
+ p_FmMacControllerDriver->macId) != E_OK))
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Can't reset MAC!"));
- if ((p_FmMacControllerDriver->clkFreq = FmGetClockFreq(p_FmMacControllerDriver->h_Fm)) == 0)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Can't get clock for MAC!"));
-
if (p_FmMacControllerDriver->f_FM_MAC_Init)
return p_FmMacControllerDriver->f_FM_MAC_Init(h_FmMac);
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_Free (t_Handle h_FmMac)
{
@@ -105,7 +123,7 @@ t_Error FM_MAC_Free (t_Handle h_FmMac)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_ConfigResetOnInit (t_Handle h_FmMac, bool enable)
{
@@ -113,12 +131,15 @@ t_Error FM_MAC_ConfigResetOnInit (t_Handle h_FmMac, bool enable)
SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
+ if (p_FmMacControllerDriver->f_FM_MAC_ConfigResetOnInit)
+ return p_FmMacControllerDriver->f_FM_MAC_ConfigResetOnInit(h_FmMac, enable);
+
p_FmMacControllerDriver->resetOnInit = enable;
return E_OK;
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_ConfigLoopback (t_Handle h_FmMac, bool newVal)
{
@@ -132,7 +153,7 @@ t_Error FM_MAC_ConfigLoopback (t_Handle h_FmMac, bool newVal)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_ConfigMaxFrameLength (t_Handle h_FmMac, uint16_t newVal)
{
@@ -145,7 +166,7 @@ t_Error FM_MAC_ConfigMaxFrameLength (t_Handle h_FmMac, uint16_t newVal)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_ConfigWan (t_Handle h_FmMac, bool flag)
{
@@ -159,7 +180,7 @@ t_Error FM_MAC_ConfigWan (t_Handle h_FmMac, bool flag)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_ConfigPadAndCrc (t_Handle h_FmMac, bool newVal)
{
@@ -173,7 +194,7 @@ t_Error FM_MAC_ConfigPadAndCrc (t_Handle h_FmMac, bool newVal)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_ConfigHalfDuplex (t_Handle h_FmMac, bool newVal)
{
@@ -187,7 +208,21 @@ t_Error FM_MAC_ConfigHalfDuplex (t_Handle h_FmMac, bool newVal)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
+
+t_Error FM_MAC_ConfigTbiPhyAddr (t_Handle h_FmMac, uint8_t newVal)
+{
+ t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacControllerDriver->f_FM_MAC_ConfigTbiPhyAddr)
+ return p_FmMacControllerDriver->f_FM_MAC_ConfigTbiPhyAddr(h_FmMac,newVal);
+
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+/* ......................................................................... */
t_Error FM_MAC_ConfigLengthCheck (t_Handle h_FmMac, bool newVal)
{
@@ -201,7 +236,7 @@ t_Error FM_MAC_ConfigLengthCheck (t_Handle h_FmMac, bool newVal)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_ConfigException (t_Handle h_FmMac, e_FmMacExceptions ex, bool enable)
{
@@ -216,7 +251,7 @@ t_Error FM_MAC_ConfigException (t_Handle h_FmMac, e_FmMacExceptions ex, bool ena
}
#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_ConfigSkipFman11Workaround (t_Handle h_FmMac)
{
@@ -236,7 +271,7 @@ t_Error FM_MAC_ConfigSkipFman11Workaround (t_Handle h_FmMac)
/* Run Time Control */
/*****************************************************************************/
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_Enable (t_Handle h_FmMac, e_CommMode mode)
{
@@ -250,7 +285,7 @@ t_Error FM_MAC_Enable (t_Handle h_FmMac, e_CommMode mode)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_Disable (t_Handle h_FmMac, e_CommMode mode)
{
@@ -264,7 +299,19 @@ t_Error FM_MAC_Disable (t_Handle h_FmMac, e_CommMode mode)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+t_Error FM_MAC_Resume (t_Handle h_FmMac)
+{
+ t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacControllerDriver->f_FM_MAC_Resume)
+ return p_FmMacControllerDriver->f_FM_MAC_Resume(h_FmMac);
+
+ return E_OK;
+}
+
+/* ......................................................................... */
t_Error FM_MAC_Enable1588TimeStamp (t_Handle h_FmMac)
{
@@ -278,7 +325,7 @@ t_Error FM_MAC_Enable1588TimeStamp (t_Handle h_FmMac)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_Disable1588TimeStamp (t_Handle h_FmMac)
{
@@ -292,21 +339,43 @@ t_Error FM_MAC_Disable1588TimeStamp (t_Handle h_FmMac)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
-t_Error FM_MAC_SetTxAutoPauseFrames (t_Handle h_FmMac, uint16_t pauseTime)
+t_Error FM_MAC_SetTxAutoPauseFrames(t_Handle h_FmMac,
+ uint16_t pauseTime)
{
t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
if (p_FmMacControllerDriver->f_FM_MAC_SetTxAutoPauseFrames)
- return p_FmMacControllerDriver->f_FM_MAC_SetTxAutoPauseFrames(h_FmMac, pauseTime);
+ return p_FmMacControllerDriver->f_FM_MAC_SetTxAutoPauseFrames(h_FmMac,
+ pauseTime);
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
+
+t_Error FM_MAC_SetTxPauseFrames(t_Handle h_FmMac,
+ uint8_t priority,
+ uint16_t pauseTime,
+ uint16_t threshTime)
+{
+ t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacControllerDriver->f_FM_MAC_SetTxPauseFrames)
+ return p_FmMacControllerDriver->f_FM_MAC_SetTxPauseFrames(h_FmMac,
+ priority,
+ pauseTime,
+ threshTime);
+
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+/* ......................................................................... */
t_Error FM_MAC_SetRxIgnorePauseFrames (t_Handle h_FmMac, bool en)
{
@@ -320,7 +389,21 @@ t_Error FM_MAC_SetRxIgnorePauseFrames (t_Handle h_FmMac, bool en)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
+
+t_Error FM_MAC_SetWakeOnLan (t_Handle h_FmMac, bool en)
+{
+ t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacControllerDriver->f_FM_MAC_SetWakeOnLan)
+ return p_FmMacControllerDriver->f_FM_MAC_SetWakeOnLan(h_FmMac, en);
+
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+/* ......................................................................... */
t_Error FM_MAC_ResetCounters (t_Handle h_FmMac)
{
@@ -334,7 +417,7 @@ t_Error FM_MAC_ResetCounters (t_Handle h_FmMac)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_SetException(t_Handle h_FmMac, e_FmMacExceptions ex, bool enable)
{
@@ -348,7 +431,7 @@ t_Error FM_MAC_SetException(t_Handle h_FmMac, e_FmMacExceptions ex, bool enable)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_SetStatistics (t_Handle h_FmMac, e_FmMacStatisticsLevel statisticsLevel)
{
@@ -358,10 +441,11 @@ t_Error FM_MAC_SetStatistics (t_Handle h_FmMac, e_FmMacStatisticsLevel statistic
if (p_FmMacControllerDriver->f_FM_MAC_SetStatistics)
return p_FmMacControllerDriver->f_FM_MAC_SetStatistics(h_FmMac, statisticsLevel);
+
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_GetStatistics (t_Handle h_FmMac, t_FmMacStatistics *p_Statistics)
{
@@ -375,7 +459,7 @@ t_Error FM_MAC_GetStatistics (t_Handle h_FmMac, t_FmMacStatistics *p_Statistics)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_ModifyMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
{
@@ -389,7 +473,7 @@ t_Error FM_MAC_ModifyMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_AddHashMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
{
@@ -403,7 +487,7 @@ t_Error FM_MAC_AddHashMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_RemoveHashMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
{
@@ -417,7 +501,7 @@ t_Error FM_MAC_RemoveHashMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_AddExactMatchMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
{
@@ -431,7 +515,7 @@ t_Error FM_MAC_AddExactMatchMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_RemovelExactMatchMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
{
@@ -445,7 +529,7 @@ t_Error FM_MAC_RemovelExactMatchMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAdd
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_GetVesrion (t_Handle h_FmMac, uint32_t *macVresion)
{
@@ -460,7 +544,7 @@ t_Error FM_MAC_GetVesrion (t_Handle h_FmMac, uint32_t *macVresion)
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_GetId (t_Handle h_FmMac, uint32_t *macId)
{
@@ -474,7 +558,7 @@ t_Error FM_MAC_GetId (t_Handle h_FmMac, uint32_t *macId)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_SetPromiscuous (t_Handle h_FmMac, bool newVal)
{
@@ -488,7 +572,7 @@ t_Error FM_MAC_SetPromiscuous (t_Handle h_FmMac, bool newVal)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_AdjustLink(t_Handle h_FmMac, e_EnetSpeed speed, bool fullDuplex)
{
@@ -502,7 +586,21 @@ t_Error FM_MAC_AdjustLink(t_Handle h_FmMac, e_EnetSpeed speed, bool fullDuplex)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
+
+t_Error FM_MAC_RestartAutoneg(t_Handle h_FmMac)
+{
+ t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacControllerDriver->f_FM_MAC_RestartAutoneg)
+ return p_FmMacControllerDriver->f_FM_MAC_RestartAutoneg(h_FmMac);
+
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+/* ......................................................................... */
t_Error FM_MAC_MII_WritePhyReg (t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, uint16_t data)
{
@@ -516,7 +614,7 @@ t_Error FM_MAC_MII_WritePhyReg (t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg,
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
t_Error FM_MAC_MII_ReadPhyReg(t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, uint16_t *p_Data)
{
@@ -530,7 +628,7 @@ t_Error FM_MAC_MII_ReadPhyReg(t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, u
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
}
-/* ........................................................................... */
+/* ......................................................................... */
uint16_t FM_MAC_GetMaxFrameLength(t_Handle h_FmMac)
{
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/fm_mac.h b/sys/contrib/ncsw/Peripherals/FM/MAC/fm_mac.h
index 9a64f14bfc92..a73e198405ee 100644
--- a/sys/contrib/ncsw/Peripherals/FM/MAC/fm_mac.h
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/fm_mac.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm_mac.h
@@ -42,11 +43,18 @@
#include "error_ext.h"
#include "list_ext.h"
#include "fm_mac_ext.h"
+#include "fm_common.h"
#define __ERR_MODULE__ MODULE_FM_MAC
+/**************************************************************************//**
+ @Description defaults
+*//***************************************************************************/
+
+#define DEFAULT_halfDuplex FALSE
+#define DEFAULT_padAndCrcEnable TRUE
#define DEFAULT_resetOnInit FALSE
@@ -54,7 +62,7 @@ typedef struct {
uint64_t addr; /* Ethernet Address */
t_List node;
} t_EthHashEntry;
-#define ETH_HASH_ENTRY_OBJ(ptr) LIST_OBJECT(ptr, t_EthHashEntry, node)
+#define ETH_HASH_ENTRY_OBJ(ptr) NCSW_LIST_OBJECT(ptr, t_EthHashEntry, node)
typedef struct {
uint16_t size;
@@ -72,7 +80,9 @@ typedef struct {
t_Error (*f_FM_MAC_ConfigPadAndCrc) (t_Handle h_FmMac, bool newVal);
t_Error (*f_FM_MAC_ConfigHalfDuplex) (t_Handle h_FmMac, bool newVal);
t_Error (*f_FM_MAC_ConfigLengthCheck) (t_Handle h_FmMac, bool newVal);
+ t_Error (*f_FM_MAC_ConfigTbiPhyAddr) (t_Handle h_FmMac, uint8_t newVal);
t_Error (*f_FM_MAC_ConfigException) (t_Handle h_FmMac, e_FmMacExceptions, bool enable);
+ t_Error (*f_FM_MAC_ConfigResetOnInit) (t_Handle h_FmMac, bool enable);
#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
t_Error (*f_FM_MAC_ConfigSkipFman11Workaround) (t_Handle h_FmMac);
#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
@@ -81,11 +91,17 @@ typedef struct {
t_Error (*f_FM_MAC_Enable) (t_Handle h_FmMac, e_CommMode mode);
t_Error (*f_FM_MAC_Disable) (t_Handle h_FmMac, e_CommMode mode);
+ t_Error (*f_FM_MAC_Resume) (t_Handle h_FmMac);
t_Error (*f_FM_MAC_Enable1588TimeStamp) (t_Handle h_FmMac);
t_Error (*f_FM_MAC_Disable1588TimeStamp) (t_Handle h_FmMac);
t_Error (*f_FM_MAC_Reset) (t_Handle h_FmMac, bool wait);
- t_Error (*f_FM_MAC_SetTxAutoPauseFrames) (t_Handle h_FmMac, uint16_t pauseTime);
+ t_Error (*f_FM_MAC_SetTxAutoPauseFrames) (t_Handle h_FmMac,
+ uint16_t pauseTime);
+ t_Error (*f_FM_MAC_SetTxPauseFrames) (t_Handle h_FmMac,
+ uint8_t priority,
+ uint16_t pauseTime,
+ uint16_t threshTime);
t_Error (*f_FM_MAC_SetRxIgnorePauseFrames) (t_Handle h_FmMac, bool en);
t_Error (*f_FM_MAC_ResetCounters) (t_Handle h_FmMac);
@@ -99,6 +115,9 @@ typedef struct {
t_Error (*f_FM_MAC_SetPromiscuous) (t_Handle h_FmMac, bool newVal);
t_Error (*f_FM_MAC_AdjustLink) (t_Handle h_FmMac, e_EnetSpeed speed, bool fullDuplex);
+ t_Error (*f_FM_MAC_RestartAutoneg) (t_Handle h_FmMac);
+
+ t_Error (*f_FM_MAC_SetWakeOnLan) (t_Handle h_FmMac, bool en);
t_Error (*f_FM_MAC_GetId) (t_Handle h_FmMac, uint32_t *macId);
@@ -113,16 +132,21 @@ typedef struct {
t_Error (*f_FM_MAC_DumpRegs) (t_Handle h_FmMac);
#endif /* (defined(DEBUG_ERRORS) && ... */
- t_Handle h_Fm;
- e_EnetMode enetMode;
- uint8_t macId;
- bool resetOnInit;
- uint16_t clkFreq;
+ t_Handle h_Fm;
+ t_FmRevisionInfo fmRevInfo;
+ e_EnetMode enetMode;
+ uint8_t macId;
+ bool resetOnInit;
+ uint16_t clkFreq;
} t_FmMacControllerDriver;
+#if (DPAA_VERSION == 10)
t_Handle DTSEC_Config(t_FmMacParams *p_FmMacParam);
t_Handle TGEC_Config(t_FmMacParams *p_FmMacParams);
+#else
+t_Handle MEMAC_Config(t_FmMacParams *p_FmMacParam);
+#endif /* (DPAA_VERSION == 10) */
uint16_t FM_MAC_GetMaxFrameLength(t_Handle FmMac);
@@ -131,10 +155,10 @@ uint16_t FM_MAC_GetMaxFrameLength(t_Handle FmMac);
static __inline__ t_EthHashEntry *DequeueAddrFromHashEntry(t_List *p_AddrLst)
{
t_EthHashEntry *p_HashEntry = NULL;
- if (!LIST_IsEmpty(p_AddrLst))
+ if (!NCSW_LIST_IsEmpty(p_AddrLst))
{
p_HashEntry = ETH_HASH_ENTRY_OBJ(p_AddrLst->p_Next);
- LIST_DelAndInit(&p_HashEntry->node);
+ NCSW_LIST_DelAndInit(&p_HashEntry->node);
}
return p_HashEntry;
}
@@ -146,21 +170,25 @@ static __inline__ void FreeHashTable(t_EthHash *p_Hash)
t_EthHashEntry *p_HashEntry;
int i = 0;
- if (!p_Hash || !p_Hash->p_Lsts)
- return;
-
- for(i=0; i<p_Hash->size; i++)
+ if (p_Hash)
{
- p_HashEntry = DequeueAddrFromHashEntry(&p_Hash->p_Lsts[i]);
- while (p_HashEntry)
+ if (p_Hash->p_Lsts)
{
- XX_Free(p_HashEntry);
- p_HashEntry = DequeueAddrFromHashEntry(&p_Hash->p_Lsts[i]);
+ for (i=0; i<p_Hash->size; i++)
+ {
+ p_HashEntry = DequeueAddrFromHashEntry(&p_Hash->p_Lsts[i]);
+ while (p_HashEntry)
+ {
+ XX_Free(p_HashEntry);
+ p_HashEntry = DequeueAddrFromHashEntry(&p_Hash->p_Lsts[i]);
+ }
+ }
+
+ XX_Free(p_Hash->p_Lsts);
}
- }
- XX_Free(p_Hash->p_Lsts);
- XX_Free(p_Hash);
+ XX_Free(p_Hash);
+ }
}
/* ........................................................................... */
@@ -171,7 +199,7 @@ static __inline__ t_EthHash * AllocHashTable(uint16_t size)
t_EthHash *p_Hash;
/* Allocate address hash table */
- p_Hash = (t_EthHash *)XX_Malloc(size*sizeof(t_EthHash *));
+ p_Hash = (t_EthHash *)XX_Malloc(sizeof(t_EthHash));
if (!p_Hash)
{
REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Address hash table"));
@@ -187,7 +215,7 @@ static __inline__ t_EthHash * AllocHashTable(uint16_t size)
return NULL;
}
- for(i=0 ; i<p_Hash->size; i++)
+ for (i=0 ; i<p_Hash->size; i++)
INIT_LIST(&p_Hash->p_Lsts[i]);
return p_Hash;
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/fman_crc32.c b/sys/contrib/ncsw/Peripherals/FM/MAC/fman_crc32.c
new file mode 100644
index 000000000000..b6a4ca25f80c
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/fman_crc32.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "fman_crc32.h"
+#include "common/general.h"
+
+
+/* precomputed CRC values for address hashing */
+static const uint32_t crc_tbl[256] = {
+ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
+ 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
+ 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
+ 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
+ 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
+ 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
+ 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
+ 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
+ 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
+ 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
+ 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
+ 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
+ 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
+ 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
+ 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
+ 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
+ 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
+ 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
+ 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
+ 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
+ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
+ 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
+ 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
+ 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
+ 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
+ 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
+ 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
+ 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
+ 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
+ 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
+ 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
+ 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
+ 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
+ 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
+ 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
+ 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
+ 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
+ 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
+ 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
+ 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
+ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
+ 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
+ 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
+};
+
+/* Get the mirrored value of a byte size number. (0x11010011 --> 0x11001011) */
+static inline uint8_t get_mirror8(uint8_t n)
+{
+ uint8_t mirror[16] = {
+ 0x00, 0x08, 0x04, 0x0c, 0x02, 0x0a, 0x06, 0x0e,
+ 0x01, 0x09, 0x05, 0x0d, 0x03, 0x0b, 0x07, 0x0f
+ };
+ return (uint8_t)(((mirror[n & 0x0f] << 4) | (mirror[n >> 4])));
+}
+
+static inline uint32_t get_mirror32(uint32_t n)
+{
+ return ((uint32_t)get_mirror8((uint8_t)(n))<<24) |
+ ((uint32_t)get_mirror8((uint8_t)(n>>8))<<16) |
+ ((uint32_t)get_mirror8((uint8_t)(n>>16))<<8) |
+ ((uint32_t)get_mirror8((uint8_t)(n>>24)));
+}
+
+uint32_t get_mac_addr_crc(uint64_t _addr)
+{
+ uint32_t i;
+ uint8_t data;
+ uint32_t crc;
+
+ /* CRC calculation */
+ crc = 0xffffffff;
+ for (i = 0; i < 6; i++) {
+ data = (uint8_t)(_addr >> ((5-i)*8));
+ crc = crc ^ data;
+ crc = crc_tbl[crc&0xff] ^ (crc>>8);
+ }
+
+ crc = get_mirror32(crc);
+ return crc;
+}
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/fman_crc32.h b/sys/contrib/ncsw/Peripherals/FM/MAC/fman_crc32.h
new file mode 100644
index 000000000000..6e32fdc6c5f6
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/fman_crc32.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef __FMAN_CRC32_H
+#define __FMAN_CRC32_H
+
+#include "common/general.h"
+
+
+uint32_t get_mac_addr_crc(uint64_t _addr);
+
+
+#endif /* __FMAN_CRC32_H */
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/fman_dtsec.c b/sys/contrib/ncsw/Peripherals/FM/MAC/fman_dtsec.c
new file mode 100644
index 000000000000..5b092865632f
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/fman_dtsec.c
@@ -0,0 +1,845 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "fsl_fman_dtsec.h"
+
+
+void fman_dtsec_stop_rx(struct dtsec_regs *regs)
+{
+ /* Assert the graceful stop bit */
+ iowrite32be(ioread32be(&regs->rctrl) | RCTRL_GRS, &regs->rctrl);
+}
+
+void fman_dtsec_stop_tx(struct dtsec_regs *regs)
+{
+ /* Assert the graceful stop bit */
+ iowrite32be(ioread32be(&regs->tctrl) | DTSEC_TCTRL_GTS, &regs->tctrl);
+}
+
+void fman_dtsec_start_tx(struct dtsec_regs *regs)
+{
+ /* clear the graceful stop bit */
+ iowrite32be(ioread32be(&regs->tctrl) & ~DTSEC_TCTRL_GTS, &regs->tctrl);
+}
+
+void fman_dtsec_start_rx(struct dtsec_regs *regs)
+{
+ /* clear the graceful stop bit */
+ iowrite32be(ioread32be(&regs->rctrl) & ~RCTRL_GRS, &regs->rctrl);
+}
+
+void fman_dtsec_defconfig(struct dtsec_cfg *cfg)
+{
+ cfg->halfdup_on = DEFAULT_HALFDUP_ON;
+ cfg->halfdup_retransmit = DEFAULT_HALFDUP_RETRANSMIT;
+ cfg->halfdup_coll_window = DEFAULT_HALFDUP_COLL_WINDOW;
+ cfg->halfdup_excess_defer = DEFAULT_HALFDUP_EXCESS_DEFER;
+ cfg->halfdup_no_backoff = DEFAULT_HALFDUP_NO_BACKOFF;
+ cfg->halfdup_bp_no_backoff = DEFAULT_HALFDUP_BP_NO_BACKOFF;
+ cfg->halfdup_alt_backoff_val = DEFAULT_HALFDUP_ALT_BACKOFF_VAL;
+ cfg->halfdup_alt_backoff_en = DEFAULT_HALFDUP_ALT_BACKOFF_EN;
+ cfg->rx_drop_bcast = DEFAULT_RX_DROP_BCAST;
+ cfg->rx_short_frm = DEFAULT_RX_SHORT_FRM;
+ cfg->rx_len_check = DEFAULT_RX_LEN_CHECK;
+ cfg->tx_pad_crc = DEFAULT_TX_PAD_CRC;
+ cfg->tx_crc = DEFAULT_TX_CRC;
+ cfg->rx_ctrl_acc = DEFAULT_RX_CTRL_ACC;
+ cfg->tx_pause_time = DEFAULT_TX_PAUSE_TIME;
+ cfg->tbipa = DEFAULT_TBIPA; /* PHY address 0 is reserved (DPAA RM)*/
+ cfg->rx_prepend = DEFAULT_RX_PREPEND;
+ cfg->ptp_tsu_en = DEFAULT_PTP_TSU_EN;
+ cfg->ptp_exception_en = DEFAULT_PTP_EXCEPTION_EN;
+ cfg->preamble_len = DEFAULT_PREAMBLE_LEN;
+ cfg->rx_preamble = DEFAULT_RX_PREAMBLE;
+ cfg->tx_preamble = DEFAULT_TX_PREAMBLE;
+ cfg->loopback = DEFAULT_LOOPBACK;
+ cfg->rx_time_stamp_en = DEFAULT_RX_TIME_STAMP_EN;
+ cfg->tx_time_stamp_en = DEFAULT_TX_TIME_STAMP_EN;
+ cfg->rx_flow = DEFAULT_RX_FLOW;
+ cfg->tx_flow = DEFAULT_TX_FLOW;
+ cfg->rx_group_hash_exd = DEFAULT_RX_GROUP_HASH_EXD;
+ cfg->tx_pause_time_extd = DEFAULT_TX_PAUSE_TIME_EXTD;
+ cfg->rx_promisc = DEFAULT_RX_PROMISC;
+ cfg->non_back_to_back_ipg1 = DEFAULT_NON_BACK_TO_BACK_IPG1;
+ cfg->non_back_to_back_ipg2 = DEFAULT_NON_BACK_TO_BACK_IPG2;
+ cfg->min_ifg_enforcement = DEFAULT_MIN_IFG_ENFORCEMENT;
+ cfg->back_to_back_ipg = DEFAULT_BACK_TO_BACK_IPG;
+ cfg->maximum_frame = DEFAULT_MAXIMUM_FRAME;
+ cfg->tbi_phy_addr = DEFAULT_TBI_PHY_ADDR;
+ cfg->wake_on_lan = DEFAULT_WAKE_ON_LAN;
+}
+
+int fman_dtsec_init(struct dtsec_regs *regs, struct dtsec_cfg *cfg,
+ enum enet_interface iface_mode,
+ enum enet_speed iface_speed,
+ uint8_t *macaddr,
+ uint8_t fm_rev_maj,
+ uint8_t fm_rev_min,
+ uint32_t exception_mask)
+{
+ bool is_rgmii = FALSE;
+ bool is_sgmii = FALSE;
+ bool is_qsgmii = FALSE;
+ int i;
+ uint32_t tmp;
+
+UNUSED(fm_rev_maj);UNUSED(fm_rev_min);
+
+ /* let's start with a soft reset */
+ iowrite32be(MACCFG1_SOFT_RESET, &regs->maccfg1);
+ iowrite32be(0, &regs->maccfg1);
+
+ /*************dtsec_id2******************/
+ tmp = ioread32be(&regs->tsec_id2);
+
+ /* check RGMII support */
+ if (iface_mode == E_ENET_IF_RGMII ||
+ iface_mode == E_ENET_IF_RMII)
+ if (tmp & DTSEC_ID2_INT_REDUCED_OFF)
+ return -EINVAL;
+
+ if (iface_mode == E_ENET_IF_SGMII ||
+ iface_mode == E_ENET_IF_MII)
+ if (tmp & DTSEC_ID2_INT_REDUCED_OFF)
+ return -EINVAL;
+
+ /***************ECNTRL************************/
+
+ is_rgmii = (bool)((iface_mode == E_ENET_IF_RGMII) ? TRUE : FALSE);
+ is_sgmii = (bool)((iface_mode == E_ENET_IF_SGMII) ? TRUE : FALSE);
+ is_qsgmii = (bool)((iface_mode == E_ENET_IF_QSGMII) ? TRUE : FALSE);
+
+ tmp = 0;
+ if (is_rgmii || iface_mode == E_ENET_IF_GMII)
+ tmp |= DTSEC_ECNTRL_GMIIM;
+ if (is_sgmii)
+ tmp |= (DTSEC_ECNTRL_SGMIIM | DTSEC_ECNTRL_TBIM);
+ if (is_qsgmii)
+ tmp |= (DTSEC_ECNTRL_SGMIIM | DTSEC_ECNTRL_TBIM |
+ DTSEC_ECNTRL_QSGMIIM);
+ if (is_rgmii)
+ tmp |= DTSEC_ECNTRL_RPM;
+ if (iface_speed == E_ENET_SPEED_100)
+ tmp |= DTSEC_ECNTRL_R100M;
+
+ iowrite32be(tmp, &regs->ecntrl);
+ /***************ECNTRL************************/
+
+ /***************TCTRL************************/
+ tmp = 0;
+ if (cfg->halfdup_on)
+ tmp |= DTSEC_TCTRL_THDF;
+ if (cfg->tx_time_stamp_en)
+ tmp |= DTSEC_TCTRL_TTSE;
+
+ iowrite32be(tmp, &regs->tctrl);
+
+ /***************TCTRL************************/
+
+ /***************PTV************************/
+ tmp = 0;
+
+#ifdef FM_SHORT_PAUSE_TIME_ERRATA_DTSEC1
+ if ((fm_rev_maj == 1) && (fm_rev_min == 0))
+ cfg->tx_pause_time += 2;
+#endif /* FM_SHORT_PAUSE_TIME_ERRATA_DTSEC1 */
+
+ if (cfg->tx_pause_time)
+ tmp |= cfg->tx_pause_time;
+ if (cfg->tx_pause_time_extd)
+ tmp |= cfg->tx_pause_time_extd << PTV_PTE_OFST;
+ iowrite32be(tmp, &regs->ptv);
+
+ /***************RCTRL************************/
+ tmp = 0;
+ tmp |= ((uint32_t)(cfg->rx_prepend & 0x0000001f)) << 16;
+ if (cfg->rx_ctrl_acc)
+ tmp |= RCTRL_CFA;
+ if (cfg->rx_group_hash_exd)
+ tmp |= RCTRL_GHTX;
+ if (cfg->rx_time_stamp_en)
+ tmp |= RCTRL_RTSE;
+ if (cfg->rx_drop_bcast)
+ tmp |= RCTRL_BC_REJ;
+ if (cfg->rx_short_frm)
+ tmp |= RCTRL_RSF;
+ if (cfg->rx_promisc)
+ tmp |= RCTRL_PROM;
+
+ iowrite32be(tmp, &regs->rctrl);
+ /***************RCTRL************************/
+
+ /*
+ * Assign a Phy Address to the TBI (TBIPA).
+ * Done also in cases where TBI is not selected to avoid conflict with
+ * the external PHY's Physical address
+ */
+ iowrite32be(cfg->tbipa, &regs->tbipa);
+
+ /***************TMR_CTL************************/
+ iowrite32be(0, &regs->tmr_ctrl);
+
+ if (cfg->ptp_tsu_en) {
+ tmp = 0;
+ tmp |= TMR_PEVENT_TSRE;
+ iowrite32be(tmp, &regs->tmr_pevent);
+
+ if (cfg->ptp_exception_en) {
+ tmp = 0;
+ tmp |= TMR_PEMASK_TSREEN;
+ iowrite32be(tmp, &regs->tmr_pemask);
+ }
+ }
+
+ /***************MACCFG1***********************/
+ tmp = 0;
+ if (cfg->loopback)
+ tmp |= MACCFG1_LOOPBACK;
+ if (cfg->rx_flow)
+ tmp |= MACCFG1_RX_FLOW;
+ if (cfg->tx_flow)
+ tmp |= MACCFG1_TX_FLOW;
+ iowrite32be(tmp, &regs->maccfg1);
+
+ /***************MACCFG1***********************/
+
+ /***************MACCFG2***********************/
+ tmp = 0;
+
+ if (iface_speed < E_ENET_SPEED_1000)
+ tmp |= MACCFG2_NIBBLE_MODE;
+ else if (iface_speed == E_ENET_SPEED_1000)
+ tmp |= MACCFG2_BYTE_MODE;
+
+ tmp |= ((uint32_t) cfg->preamble_len & 0x0000000f)
+ << PREAMBLE_LENGTH_SHIFT;
+
+ if (cfg->rx_preamble)
+ tmp |= MACCFG2_PRE_AM_Rx_EN;
+ if (cfg->tx_preamble)
+ tmp |= MACCFG2_PRE_AM_Tx_EN;
+ if (cfg->rx_len_check)
+ tmp |= MACCFG2_LENGTH_CHECK;
+ if (cfg->tx_pad_crc)
+ tmp |= MACCFG2_PAD_CRC_EN;
+ if (cfg->tx_crc)
+ tmp |= MACCFG2_CRC_EN;
+ if (!cfg->halfdup_on)
+ tmp |= MACCFG2_FULL_DUPLEX;
+ iowrite32be(tmp, &regs->maccfg2);
+
+ /***************MACCFG2***********************/
+
+ /***************IPGIFG************************/
+ tmp = (((cfg->non_back_to_back_ipg1 <<
+ IPGIFG_NON_BACK_TO_BACK_IPG_1_SHIFT)
+ & IPGIFG_NON_BACK_TO_BACK_IPG_1)
+ | ((cfg->non_back_to_back_ipg2 <<
+ IPGIFG_NON_BACK_TO_BACK_IPG_2_SHIFT)
+ & IPGIFG_NON_BACK_TO_BACK_IPG_2)
+ | ((cfg->min_ifg_enforcement <<
+ IPGIFG_MIN_IFG_ENFORCEMENT_SHIFT)
+ & IPGIFG_MIN_IFG_ENFORCEMENT)
+ | (cfg->back_to_back_ipg & IPGIFG_BACK_TO_BACK_IPG));
+ iowrite32be(tmp, &regs->ipgifg);
+
+ /***************IPGIFG************************/
+
+ /***************HAFDUP************************/
+ tmp = 0;
+
+ if (cfg->halfdup_alt_backoff_en)
+ tmp = (uint32_t)(HAFDUP_ALT_BEB |
+ ((cfg->halfdup_alt_backoff_val & 0x0000000f)
+ << HAFDUP_ALTERNATE_BEB_TRUNCATION_SHIFT));
+ if (cfg->halfdup_bp_no_backoff)
+ tmp |= HAFDUP_BP_NO_BACKOFF;
+ if (cfg->halfdup_no_backoff)
+ tmp |= HAFDUP_NO_BACKOFF;
+ if (cfg->halfdup_excess_defer)
+ tmp |= HAFDUP_EXCESS_DEFER;
+ tmp |= ((cfg->halfdup_retransmit << HAFDUP_RETRANSMISSION_MAX_SHIFT)
+ & HAFDUP_RETRANSMISSION_MAX);
+ tmp |= (cfg->halfdup_coll_window & HAFDUP_COLLISION_WINDOW);
+
+ iowrite32be(tmp, &regs->hafdup);
+ /***************HAFDUP************************/
+
+ /***************MAXFRM************************/
+ /* Initialize MAXFRM */
+ iowrite32be(cfg->maximum_frame, &regs->maxfrm);
+
+ /***************MAXFRM************************/
+
+ /***************CAM1************************/
+ iowrite32be(0xffffffff, &regs->cam1);
+ iowrite32be(0xffffffff, &regs->cam2);
+
+ /***************IMASK************************/
+ iowrite32be(exception_mask, &regs->imask);
+ /***************IMASK************************/
+
+ /***************IEVENT************************/
+ iowrite32be(0xffffffff, &regs->ievent);
+
+ /***************MACSTNADDR1/2*****************/
+
+ tmp = (uint32_t)((macaddr[5] << 24) |
+ (macaddr[4] << 16) |
+ (macaddr[3] << 8) |
+ macaddr[2]);
+ iowrite32be(tmp, &regs->macstnaddr1);
+
+ tmp = (uint32_t)((macaddr[1] << 24) |
+ (macaddr[0] << 16));
+ iowrite32be(tmp, &regs->macstnaddr2);
+
+ /***************MACSTNADDR1/2*****************/
+
+ /*****************HASH************************/
+ for (i = 0; i < NUM_OF_HASH_REGS ; i++) {
+ /* Initialize IADDRx */
+ iowrite32be(0, &regs->igaddr[i]);
+ /* Initialize GADDRx */
+ iowrite32be(0, &regs->gaddr[i]);
+ }
+
+ fman_dtsec_reset_stat(regs);
+
+ return 0;
+}
+
+uint16_t fman_dtsec_get_max_frame_len(struct dtsec_regs *regs)
+{
+ return (uint16_t)ioread32be(&regs->maxfrm);
+}
+
+void fman_dtsec_set_max_frame_len(struct dtsec_regs *regs, uint16_t length)
+{
+ iowrite32be(length, &regs->maxfrm);
+}
+
+void fman_dtsec_set_mac_address(struct dtsec_regs *regs, uint8_t *adr)
+{
+ uint32_t tmp;
+
+ tmp = (uint32_t)((adr[5] << 24) |
+ (adr[4] << 16) |
+ (adr[3] << 8) |
+ adr[2]);
+ iowrite32be(tmp, &regs->macstnaddr1);
+
+ tmp = (uint32_t)((adr[1] << 24) |
+ (adr[0] << 16));
+ iowrite32be(tmp, &regs->macstnaddr2);
+}
+
+void fman_dtsec_get_mac_address(struct dtsec_regs *regs, uint8_t *macaddr)
+{
+ uint32_t tmp1, tmp2;
+
+ tmp1 = ioread32be(&regs->macstnaddr1);
+ tmp2 = ioread32be(&regs->macstnaddr2);
+
+ macaddr[0] = (uint8_t)((tmp2 & 0x00ff0000) >> 16);
+ macaddr[1] = (uint8_t)((tmp2 & 0xff000000) >> 24);
+ macaddr[2] = (uint8_t)(tmp1 & 0x000000ff);
+ macaddr[3] = (uint8_t)((tmp1 & 0x0000ff00) >> 8);
+ macaddr[4] = (uint8_t)((tmp1 & 0x00ff0000) >> 16);
+ macaddr[5] = (uint8_t)((tmp1 & 0xff000000) >> 24);
+}
+
+void fman_dtsec_set_hash_table(struct dtsec_regs *regs, uint32_t crc, bool mcast, bool ghtx)
+{
+ int32_t bucket;
+ if (ghtx)
+ bucket = (int32_t)((crc >> 23) & 0x1ff);
+ else {
+ bucket = (int32_t)((crc >> 24) & 0xff);
+ /* if !ghtx and mcast the bit must be set in gaddr instead of igaddr. */
+ if (mcast)
+ bucket += 0x100;
+ }
+ fman_dtsec_set_bucket(regs, bucket, TRUE);
+}
+
+void fman_dtsec_set_bucket(struct dtsec_regs *regs, int bucket, bool enable)
+{
+ int reg_idx = (bucket >> 5) & 0xf;
+ int bit_idx = bucket & 0x1f;
+ uint32_t bit_mask = 0x80000000 >> bit_idx;
+ uint32_t *reg;
+
+ if (reg_idx > 7)
+ reg = &regs->gaddr[reg_idx-8];
+ else
+ reg = &regs->igaddr[reg_idx];
+
+ if (enable)
+ iowrite32be(ioread32be(reg) | bit_mask, reg);
+ else
+ iowrite32be(ioread32be(reg) & (~bit_mask), reg);
+}
+
+void fman_dtsec_reset_filter_table(struct dtsec_regs *regs, bool mcast, bool ucast)
+{
+ int i;
+ bool ghtx;
+
+ ghtx = (bool)((ioread32be(&regs->rctrl) & RCTRL_GHTX) ? TRUE : FALSE);
+
+ if (ucast || (ghtx && mcast)) {
+ for (i = 0; i < NUM_OF_HASH_REGS; i++)
+ iowrite32be(0, &regs->igaddr[i]);
+ }
+ if (mcast) {
+ for (i = 0; i < NUM_OF_HASH_REGS; i++)
+ iowrite32be(0, &regs->gaddr[i]);
+ }
+}
+
+int fman_dtsec_set_tbi_phy_addr(struct dtsec_regs *regs,
+ uint8_t addr)
+{
+ if (addr > 0 && addr < 32)
+ iowrite32be(addr, &regs->tbipa);
+ else
+ return -EINVAL;
+
+ return 0;
+}
+
+void fman_dtsec_set_wol(struct dtsec_regs *regs, bool en)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->maccfg2);
+ if (en)
+ tmp |= MACCFG2_MAGIC_PACKET_EN;
+ else
+ tmp &= ~MACCFG2_MAGIC_PACKET_EN;
+ iowrite32be(tmp, &regs->maccfg2);
+}
+
+int fman_dtsec_adjust_link(struct dtsec_regs *regs,
+ enum enet_interface iface_mode,
+ enum enet_speed speed, bool full_dx)
+{
+ uint32_t tmp;
+
+ UNUSED(iface_mode);
+
+ if ((speed == E_ENET_SPEED_1000) && !full_dx)
+ return -EINVAL;
+
+ tmp = ioread32be(&regs->maccfg2);
+ if (!full_dx)
+ tmp &= ~MACCFG2_FULL_DUPLEX;
+ else
+ tmp |= MACCFG2_FULL_DUPLEX;
+
+ tmp &= ~(MACCFG2_NIBBLE_MODE | MACCFG2_BYTE_MODE);
+ if (speed < E_ENET_SPEED_1000)
+ tmp |= MACCFG2_NIBBLE_MODE;
+ else if (speed == E_ENET_SPEED_1000)
+ tmp |= MACCFG2_BYTE_MODE;
+ iowrite32be(tmp, &regs->maccfg2);
+
+ tmp = ioread32be(&regs->ecntrl);
+ if (speed == E_ENET_SPEED_100)
+ tmp |= DTSEC_ECNTRL_R100M;
+ else
+ tmp &= ~DTSEC_ECNTRL_R100M;
+ iowrite32be(tmp, &regs->ecntrl);
+
+ return 0;
+}
+
+void fman_dtsec_set_uc_promisc(struct dtsec_regs *regs, bool enable)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->rctrl);
+
+ if (enable)
+ tmp |= RCTRL_UPROM;
+ else
+ tmp &= ~RCTRL_UPROM;
+
+ iowrite32be(tmp, &regs->rctrl);
+}
+
+void fman_dtsec_set_mc_promisc(struct dtsec_regs *regs, bool enable)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->rctrl);
+
+ if (enable)
+ tmp |= RCTRL_MPROM;
+ else
+ tmp &= ~RCTRL_MPROM;
+
+ iowrite32be(tmp, &regs->rctrl);
+}
+
+bool fman_dtsec_get_clear_carry_regs(struct dtsec_regs *regs,
+ uint32_t *car1, uint32_t *car2)
+{
+ /* read carry registers */
+ *car1 = ioread32be(&regs->car1);
+ *car2 = ioread32be(&regs->car2);
+ /* clear carry registers */
+ if (*car1)
+ iowrite32be(*car1, &regs->car1);
+ if (*car2)
+ iowrite32be(*car2, &regs->car2);
+
+ return (bool)((*car1 | *car2) ? TRUE : FALSE);
+}
+
+void fman_dtsec_reset_stat(struct dtsec_regs *regs)
+{
+ /* clear HW counters */
+ iowrite32be(ioread32be(&regs->ecntrl) |
+ DTSEC_ECNTRL_CLRCNT, &regs->ecntrl);
+}
+
+int fman_dtsec_set_stat_level(struct dtsec_regs *regs, enum dtsec_stat_level level)
+{
+ switch (level) {
+ case E_MAC_STAT_NONE:
+ iowrite32be(0xffffffff, &regs->cam1);
+ iowrite32be(0xffffffff, &regs->cam2);
+ iowrite32be(ioread32be(&regs->ecntrl) & ~DTSEC_ECNTRL_STEN,
+ &regs->ecntrl);
+ iowrite32be(ioread32be(&regs->imask) & ~DTSEC_IMASK_MSROEN,
+ &regs->imask);
+ break;
+ case E_MAC_STAT_PARTIAL:
+ iowrite32be(CAM1_ERRORS_ONLY, &regs->cam1);
+ iowrite32be(CAM2_ERRORS_ONLY, &regs->cam2);
+ iowrite32be(ioread32be(&regs->ecntrl) | DTSEC_ECNTRL_STEN,
+ &regs->ecntrl);
+ iowrite32be(ioread32be(&regs->imask) | DTSEC_IMASK_MSROEN,
+ &regs->imask);
+ break;
+ case E_MAC_STAT_MIB_GRP1:
+ iowrite32be((uint32_t)~CAM1_MIB_GRP_1, &regs->cam1);
+ iowrite32be((uint32_t)~CAM2_MIB_GRP_1, &regs->cam2);
+ iowrite32be(ioread32be(&regs->ecntrl) | DTSEC_ECNTRL_STEN,
+ &regs->ecntrl);
+ iowrite32be(ioread32be(&regs->imask) | DTSEC_IMASK_MSROEN,
+ &regs->imask);
+ break;
+ case E_MAC_STAT_FULL:
+ iowrite32be(0, &regs->cam1);
+ iowrite32be(0, &regs->cam2);
+ iowrite32be(ioread32be(&regs->ecntrl) | DTSEC_ECNTRL_STEN,
+ &regs->ecntrl);
+ iowrite32be(ioread32be(&regs->imask) | DTSEC_IMASK_MSROEN,
+ &regs->imask);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+void fman_dtsec_set_ts(struct dtsec_regs *regs, bool en)
+{
+ if (en) {
+ iowrite32be(ioread32be(&regs->rctrl) | RCTRL_RTSE,
+ &regs->rctrl);
+ iowrite32be(ioread32be(&regs->tctrl) | DTSEC_TCTRL_TTSE,
+ &regs->tctrl);
+ } else {
+ iowrite32be(ioread32be(&regs->rctrl) & ~RCTRL_RTSE,
+ &regs->rctrl);
+ iowrite32be(ioread32be(&regs->tctrl) & ~DTSEC_TCTRL_TTSE,
+ &regs->tctrl);
+ }
+}
+
+void fman_dtsec_enable(struct dtsec_regs *regs, bool apply_rx, bool apply_tx)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->maccfg1);
+
+ if (apply_rx)
+ tmp |= MACCFG1_RX_EN ;
+
+ if (apply_tx)
+ tmp |= MACCFG1_TX_EN ;
+
+ iowrite32be(tmp, &regs->maccfg1);
+}
+
+void fman_dtsec_clear_addr_in_paddr(struct dtsec_regs *regs, uint8_t paddr_num)
+{
+ iowrite32be(0, &regs->macaddr[paddr_num].exact_match1);
+ iowrite32be(0, &regs->macaddr[paddr_num].exact_match2);
+}
+
+void fman_dtsec_add_addr_in_paddr(struct dtsec_regs *regs,
+ uint64_t addr,
+ uint8_t paddr_num)
+{
+ uint32_t tmp;
+
+ tmp = (uint32_t)(addr);
+ /* swap */
+ tmp = (((tmp & 0x000000FF) << 24) |
+ ((tmp & 0x0000FF00) << 8) |
+ ((tmp & 0x00FF0000) >> 8) |
+ ((tmp & 0xFF000000) >> 24));
+ iowrite32be(tmp, &regs->macaddr[paddr_num].exact_match1);
+
+ tmp = (uint32_t)(addr>>32);
+ /* swap */
+ tmp = (((tmp & 0x000000FF) << 24) |
+ ((tmp & 0x0000FF00) << 8) |
+ ((tmp & 0x00FF0000) >> 8) |
+ ((tmp & 0xFF000000) >> 24));
+ iowrite32be(tmp, &regs->macaddr[paddr_num].exact_match2);
+}
+
+void fman_dtsec_disable(struct dtsec_regs *regs, bool apply_rx, bool apply_tx)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->maccfg1);
+
+ if (apply_rx)
+ tmp &= ~MACCFG1_RX_EN;
+
+ if (apply_tx)
+ tmp &= ~MACCFG1_TX_EN;
+
+ iowrite32be(tmp, &regs->maccfg1);
+}
+
+void fman_dtsec_set_tx_pause_frames(struct dtsec_regs *regs, uint16_t time)
+{
+ uint32_t ptv = 0;
+
+ /* fixme: don't enable tx pause for half-duplex */
+
+ if (time) {
+ ptv = ioread32be(&regs->ptv);
+ ptv &= 0xffff0000;
+ ptv |= time & 0x0000ffff;
+ iowrite32be(ptv, &regs->ptv);
+
+ /* trigger the transmission of a flow-control pause frame */
+ iowrite32be(ioread32be(&regs->maccfg1) | MACCFG1_TX_FLOW,
+ &regs->maccfg1);
+ } else
+ iowrite32be(ioread32be(&regs->maccfg1) & ~MACCFG1_TX_FLOW,
+ &regs->maccfg1);
+}
+
+void fman_dtsec_handle_rx_pause(struct dtsec_regs *regs, bool en)
+{
+ uint32_t tmp;
+
+ /* todo: check if mac is set to full-duplex */
+
+ tmp = ioread32be(&regs->maccfg1);
+ if (en)
+ tmp |= MACCFG1_RX_FLOW;
+ else
+ tmp &= ~MACCFG1_RX_FLOW;
+ iowrite32be(tmp, &regs->maccfg1);
+}
+
+uint32_t fman_dtsec_get_rctrl(struct dtsec_regs *regs)
+{
+ return ioread32be(&regs->rctrl);
+}
+
+uint32_t fman_dtsec_get_revision(struct dtsec_regs *regs)
+{
+ return ioread32be(&regs->tsec_id);
+}
+
+uint32_t fman_dtsec_get_event(struct dtsec_regs *regs, uint32_t ev_mask)
+{
+ return ioread32be(&regs->ievent) & ev_mask;
+}
+
+void fman_dtsec_ack_event(struct dtsec_regs *regs, uint32_t ev_mask)
+{
+ iowrite32be(ev_mask, &regs->ievent);
+}
+
+uint32_t fman_dtsec_get_interrupt_mask(struct dtsec_regs *regs)
+{
+ return ioread32be(&regs->imask);
+}
+
+uint32_t fman_dtsec_check_and_clear_tmr_event(struct dtsec_regs *regs)
+{
+ uint32_t event;
+
+ event = ioread32be(&regs->tmr_pevent);
+ event &= ioread32be(&regs->tmr_pemask);
+
+ if (event)
+ iowrite32be(event, &regs->tmr_pevent);
+ return event;
+}
+
+void fman_dtsec_enable_tmr_interrupt(struct dtsec_regs *regs)
+{
+ iowrite32be(ioread32be(&regs->tmr_pemask) | TMR_PEMASK_TSREEN,
+ &regs->tmr_pemask);
+}
+
+void fman_dtsec_disable_tmr_interrupt(struct dtsec_regs *regs)
+{
+ iowrite32be(ioread32be(&regs->tmr_pemask) & ~TMR_PEMASK_TSREEN,
+ &regs->tmr_pemask);
+}
+
+void fman_dtsec_enable_interrupt(struct dtsec_regs *regs, uint32_t ev_mask)
+{
+ iowrite32be(ioread32be(&regs->imask) | ev_mask, &regs->imask);
+}
+
+void fman_dtsec_disable_interrupt(struct dtsec_regs *regs, uint32_t ev_mask)
+{
+ iowrite32be(ioread32be(&regs->imask) & ~ev_mask, &regs->imask);
+}
+
+uint32_t fman_dtsec_get_stat_counter(struct dtsec_regs *regs,
+ enum dtsec_stat_counters reg_name)
+{
+ uint32_t ret_val;
+
+ switch (reg_name) {
+ case E_DTSEC_STAT_TR64:
+ ret_val = ioread32be(&regs->tr64);
+ break;
+ case E_DTSEC_STAT_TR127:
+ ret_val = ioread32be(&regs->tr127);
+ break;
+ case E_DTSEC_STAT_TR255:
+ ret_val = ioread32be(&regs->tr255);
+ break;
+ case E_DTSEC_STAT_TR511:
+ ret_val = ioread32be(&regs->tr511);
+ break;
+ case E_DTSEC_STAT_TR1K:
+ ret_val = ioread32be(&regs->tr1k);
+ break;
+ case E_DTSEC_STAT_TRMAX:
+ ret_val = ioread32be(&regs->trmax);
+ break;
+ case E_DTSEC_STAT_TRMGV:
+ ret_val = ioread32be(&regs->trmgv);
+ break;
+ case E_DTSEC_STAT_RBYT:
+ ret_val = ioread32be(&regs->rbyt);
+ break;
+ case E_DTSEC_STAT_RPKT:
+ ret_val = ioread32be(&regs->rpkt);
+ break;
+ case E_DTSEC_STAT_RMCA:
+ ret_val = ioread32be(&regs->rmca);
+ break;
+ case E_DTSEC_STAT_RBCA:
+ ret_val = ioread32be(&regs->rbca);
+ break;
+ case E_DTSEC_STAT_RXPF:
+ ret_val = ioread32be(&regs->rxpf);
+ break;
+ case E_DTSEC_STAT_RALN:
+ ret_val = ioread32be(&regs->raln);
+ break;
+ case E_DTSEC_STAT_RFLR:
+ ret_val = ioread32be(&regs->rflr);
+ break;
+ case E_DTSEC_STAT_RCDE:
+ ret_val = ioread32be(&regs->rcde);
+ break;
+ case E_DTSEC_STAT_RCSE:
+ ret_val = ioread32be(&regs->rcse);
+ break;
+ case E_DTSEC_STAT_RUND:
+ ret_val = ioread32be(&regs->rund);
+ break;
+ case E_DTSEC_STAT_ROVR:
+ ret_val = ioread32be(&regs->rovr);
+ break;
+ case E_DTSEC_STAT_RFRG:
+ ret_val = ioread32be(&regs->rfrg);
+ break;
+ case E_DTSEC_STAT_RJBR:
+ ret_val = ioread32be(&regs->rjbr);
+ break;
+ case E_DTSEC_STAT_RDRP:
+ ret_val = ioread32be(&regs->rdrp);
+ break;
+ case E_DTSEC_STAT_TFCS:
+ ret_val = ioread32be(&regs->tfcs);
+ break;
+ case E_DTSEC_STAT_TBYT:
+ ret_val = ioread32be(&regs->tbyt);
+ break;
+ case E_DTSEC_STAT_TPKT:
+ ret_val = ioread32be(&regs->tpkt);
+ break;
+ case E_DTSEC_STAT_TMCA:
+ ret_val = ioread32be(&regs->tmca);
+ break;
+ case E_DTSEC_STAT_TBCA:
+ ret_val = ioread32be(&regs->tbca);
+ break;
+ case E_DTSEC_STAT_TXPF:
+ ret_val = ioread32be(&regs->txpf);
+ break;
+ case E_DTSEC_STAT_TNCL:
+ ret_val = ioread32be(&regs->tncl);
+ break;
+ case E_DTSEC_STAT_TDRP:
+ ret_val = ioread32be(&regs->tdrp);
+ break;
+ default:
+ ret_val = 0;
+ }
+
+ return ret_val;
+}
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/fman_dtsec_mii_acc.c b/sys/contrib/ncsw/Peripherals/FM/MAC/fman_dtsec_mii_acc.c
new file mode 100644
index 000000000000..8819f8fcafbd
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/fman_dtsec_mii_acc.c
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2008-2013 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "common/general.h"
+#include "fsl_fman_dtsec_mii_acc.h"
+
+
+/**
+ * dtsec_mii_get_div() - calculates the value of the dtsec mii divider
+ * @dtsec_freq: dtsec clock frequency (in Mhz)
+ *
+ * This function calculates the dtsec mii clock divider that determines
+ * the MII MDC clock. MII MDC clock will be set to work in the range
+ * of 1.5 to 2.5Mhz
+ * The output of this function is the value of MIIMCFG[MgmtClk] which
+ * implicitly determines the divider value.
+ * Note: the dTSEC system clock is equal to 1/2 of the FMan clock.
+ *
+ * The table below which reflects dtsec_mii_get_div() functionality
+ * shows the relations among dtsec_freq, MgmtClk, actual divider
+ * and the MII frequency:
+ *
+ * dtsec freq MgmtClk div MII freq Mhz
+ * [0.....80] 1 (1/4)(1/8) [0 to 2.5]
+ * [81...120] 2 (1/6)(1/8) [1.6 to 2.5]
+ * [121..160] 3 (1/8)(1/8) [1.8 to 2.5]
+ * [161..200] 4 (1/10)(1/8) [2.0 to 2.5]
+ * [201..280] 5 (1/14)(1/8) [1.8 to 2.5]
+ * [281..400] 6 (1/20)(1/8) [1.1 to 2.5]
+ * [401..560] 7 (1/28)(1/8) [1.8 to 2.5]
+ * [560..frq] 7 (1/28)(1/8) [frq/224]
+ *
+ * Returns: the MIIMCFG[MgmtClk] appropriate value
+ */
+
+static uint8_t dtsec_mii_get_div(uint16_t dtsec_freq)
+{
+ uint16_t mgmt_clk;
+
+ if (dtsec_freq < 80) mgmt_clk = 1;
+ else if (dtsec_freq < 120) mgmt_clk = 2;
+ else if (dtsec_freq < 160) mgmt_clk = 3;
+ else if (dtsec_freq < 200) mgmt_clk = 4;
+ else if (dtsec_freq < 280) mgmt_clk = 5;
+ else if (dtsec_freq < 400) mgmt_clk = 6;
+ else mgmt_clk = 7;
+
+ return (uint8_t)mgmt_clk;
+}
+
+void fman_dtsec_mii_reset(struct dtsec_mii_reg *regs)
+{
+ /* Reset the management interface */
+ iowrite32be(ioread32be(&regs->miimcfg) | MIIMCFG_RESET_MGMT,
+ &regs->miimcfg);
+ iowrite32be(ioread32be(&regs->miimcfg) & ~MIIMCFG_RESET_MGMT,
+ &regs->miimcfg);
+}
+
+
+int fman_dtsec_mii_write_reg(struct dtsec_mii_reg *regs, uint8_t addr,
+ uint8_t reg, uint16_t data, uint16_t dtsec_freq)
+{
+ uint32_t tmp;
+
+ /* Setup the MII Mgmt clock speed */
+ iowrite32be((uint32_t)dtsec_mii_get_div(dtsec_freq), &regs->miimcfg);
+ wmb();
+
+ /* Stop the MII management read cycle */
+ iowrite32be(0, &regs->miimcom);
+ /* Dummy read to make sure MIIMCOM is written */
+ tmp = ioread32be(&regs->miimcom);
+ wmb();
+
+ /* Setting up MII Management Address Register */
+ tmp = (uint32_t)((addr << MIIMADD_PHY_ADDR_SHIFT) | reg);
+ iowrite32be(tmp, &regs->miimadd);
+ wmb();
+
+ /* Setting up MII Management Control Register with data */
+ iowrite32be((uint32_t)data, &regs->miimcon);
+ /* Dummy read to make sure MIIMCON is written */
+ tmp = ioread32be(&regs->miimcon);
+ wmb();
+
+ /* Wait until MII management write is complete */
+ /* todo: a timeout could be useful here */
+ while ((ioread32be(&regs->miimind)) & MIIMIND_BUSY)
+ /* busy wait */;
+
+ return 0;
+}
+
+int fman_dtsec_mii_read_reg(struct dtsec_mii_reg *regs, uint8_t addr,
+ uint8_t reg, uint16_t *data, uint16_t dtsec_freq)
+{
+ uint32_t tmp;
+
+ /* Setup the MII Mgmt clock speed */
+ iowrite32be((uint32_t)dtsec_mii_get_div(dtsec_freq), &regs->miimcfg);
+ wmb();
+
+ /* Setting up the MII Management Address Register */
+ tmp = (uint32_t)((addr << MIIMADD_PHY_ADDR_SHIFT) | reg);
+ iowrite32be(tmp, &regs->miimadd);
+ wmb();
+
+ /* Perform an MII management read cycle */
+ iowrite32be(MIIMCOM_READ_CYCLE, &regs->miimcom);
+ /* Dummy read to make sure MIIMCOM is written */
+ tmp = ioread32be(&regs->miimcom);
+ wmb();
+
+ /* Wait until MII management read is complete */
+ /* todo: a timeout could be useful here */
+ while ((ioread32be(&regs->miimind)) & MIIMIND_BUSY)
+ /* busy wait */;
+
+ /* Read MII management status */
+ *data = (uint16_t)ioread32be(&regs->miimstat);
+ wmb();
+
+ iowrite32be(0, &regs->miimcom);
+ /* Dummy read to make sure MIIMCOM is written */
+ tmp = ioread32be(&regs->miimcom);
+
+ if (*data == 0xffff)
+ return -ENXIO;
+
+ return 0;
+}
+
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/fman_memac.c b/sys/contrib/ncsw/Peripherals/FM/MAC/fman_memac.c
new file mode 100644
index 000000000000..00995a1066d0
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/fman_memac.c
@@ -0,0 +1,511 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "fsl_fman_memac.h"
+
+
+uint32_t fman_memac_get_event(struct memac_regs *regs, uint32_t ev_mask)
+{
+ return ioread32be(&regs->ievent) & ev_mask;
+}
+
+uint32_t fman_memac_get_interrupt_mask(struct memac_regs *regs)
+{
+ return ioread32be(&regs->imask);
+}
+
+void fman_memac_ack_event(struct memac_regs *regs, uint32_t ev_mask)
+{
+ iowrite32be(ev_mask, &regs->ievent);
+}
+
+void fman_memac_set_promiscuous(struct memac_regs *regs, bool val)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->command_config);
+
+ if (val)
+ tmp |= CMD_CFG_PROMIS_EN;
+ else
+ tmp &= ~CMD_CFG_PROMIS_EN;
+
+ iowrite32be(tmp, &regs->command_config);
+}
+
+void fman_memac_clear_addr_in_paddr(struct memac_regs *regs,
+ uint8_t paddr_num)
+{
+ if (paddr_num == 0) {
+ iowrite32be(0, &regs->mac_addr0.mac_addr_l);
+ iowrite32be(0, &regs->mac_addr0.mac_addr_u);
+ } else {
+ iowrite32be(0x0, &regs->mac_addr[paddr_num - 1].mac_addr_l);
+ iowrite32be(0x0, &regs->mac_addr[paddr_num - 1].mac_addr_u);
+ }
+}
+
+void fman_memac_add_addr_in_paddr(struct memac_regs *regs,
+ uint8_t *adr,
+ uint8_t paddr_num)
+{
+ uint32_t tmp0, tmp1;
+
+ tmp0 = (uint32_t)(adr[0] |
+ adr[1] << 8 |
+ adr[2] << 16 |
+ adr[3] << 24);
+ tmp1 = (uint32_t)(adr[4] | adr[5] << 8);
+
+ if (paddr_num == 0) {
+ iowrite32be(tmp0, &regs->mac_addr0.mac_addr_l);
+ iowrite32be(tmp1, &regs->mac_addr0.mac_addr_u);
+ } else {
+ iowrite32be(tmp0, &regs->mac_addr[paddr_num-1].mac_addr_l);
+ iowrite32be(tmp1, &regs->mac_addr[paddr_num-1].mac_addr_u);
+ }
+}
+
+void fman_memac_enable(struct memac_regs *regs, bool apply_rx, bool apply_tx)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->command_config);
+
+ if (apply_rx)
+ tmp |= CMD_CFG_RX_EN;
+
+ if (apply_tx)
+ tmp |= CMD_CFG_TX_EN;
+
+ iowrite32be(tmp, &regs->command_config);
+}
+
+void fman_memac_disable(struct memac_regs *regs, bool apply_rx, bool apply_tx)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->command_config);
+
+ if (apply_rx)
+ tmp &= ~CMD_CFG_RX_EN;
+
+ if (apply_tx)
+ tmp &= ~CMD_CFG_TX_EN;
+
+ iowrite32be(tmp, &regs->command_config);
+}
+
+void fman_memac_reset_stat(struct memac_regs *regs)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->statn_config);
+
+ tmp |= STATS_CFG_CLR;
+
+ iowrite32be(tmp, &regs->statn_config);
+
+ while (ioread32be(&regs->statn_config) & STATS_CFG_CLR);
+}
+
+void fman_memac_reset(struct memac_regs *regs)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->command_config);
+
+ tmp |= CMD_CFG_SW_RESET;
+
+ iowrite32be(tmp, &regs->command_config);
+
+ while (ioread32be(&regs->command_config) & CMD_CFG_SW_RESET);
+}
+
+int fman_memac_init(struct memac_regs *regs,
+ struct memac_cfg *cfg,
+ enum enet_interface enet_interface,
+ enum enet_speed enet_speed,
+ bool slow_10g_if,
+ uint32_t exceptions)
+{
+ uint32_t tmp;
+
+ /* Config */
+ tmp = 0;
+ if (cfg->wan_mode_enable)
+ tmp |= CMD_CFG_WAN_MODE;
+ if (cfg->promiscuous_mode_enable)
+ tmp |= CMD_CFG_PROMIS_EN;
+ if (cfg->pause_forward_enable)
+ tmp |= CMD_CFG_PAUSE_FWD;
+ if (cfg->pause_ignore)
+ tmp |= CMD_CFG_PAUSE_IGNORE;
+ if (cfg->tx_addr_ins_enable)
+ tmp |= CMD_CFG_TX_ADDR_INS;
+ if (cfg->loopback_enable)
+ tmp |= CMD_CFG_LOOPBACK_EN;
+ if (cfg->cmd_frame_enable)
+ tmp |= CMD_CFG_CNT_FRM_EN;
+ if (cfg->send_idle_enable)
+ tmp |= CMD_CFG_SEND_IDLE;
+ if (cfg->no_length_check_enable)
+ tmp |= CMD_CFG_NO_LEN_CHK;
+ if (cfg->rx_sfd_any)
+ tmp |= CMD_CFG_SFD_ANY;
+ if (cfg->pad_enable)
+ tmp |= CMD_CFG_TX_PAD_EN;
+ if (cfg->wake_on_lan)
+ tmp |= CMD_CFG_MG;
+
+ tmp |= CMD_CFG_CRC_FWD;
+
+ iowrite32be(tmp, &regs->command_config);
+
+ /* Max Frame Length */
+ iowrite32be((uint32_t)cfg->max_frame_length, &regs->maxfrm);
+
+ /* Pause Time */
+ iowrite32be((uint32_t)cfg->pause_quanta, &regs->pause_quanta[0]);
+ iowrite32be((uint32_t)0, &regs->pause_thresh[0]);
+
+ /* IF_MODE */
+ tmp = 0;
+ switch (enet_interface) {
+ case E_ENET_IF_XGMII:
+ case E_ENET_IF_XFI:
+ tmp |= IF_MODE_XGMII;
+ break;
+ default:
+ tmp |= IF_MODE_GMII;
+ if (enet_interface == E_ENET_IF_RGMII && !cfg->loopback_enable)
+ tmp |= IF_MODE_RGMII | IF_MODE_RGMII_AUTO;
+ }
+ iowrite32be(tmp, &regs->if_mode);
+
+ /* TX_FIFO_SECTIONS */
+ tmp = 0;
+ if (enet_interface == E_ENET_IF_XGMII ||
+ enet_interface == E_ENET_IF_XFI) {
+ if(slow_10g_if) {
+ tmp |= (TX_FIFO_SECTIONS_TX_AVAIL_SLOW_10G |
+ TX_FIFO_SECTIONS_TX_EMPTY_DEFAULT_10G);
+ } else {
+ tmp |= (TX_FIFO_SECTIONS_TX_AVAIL_10G |
+ TX_FIFO_SECTIONS_TX_EMPTY_DEFAULT_10G);
+ }
+ } else {
+ tmp |= (TX_FIFO_SECTIONS_TX_AVAIL_1G |
+ TX_FIFO_SECTIONS_TX_EMPTY_DEFAULT_1G);
+ }
+ iowrite32be(tmp, &regs->tx_fifo_sections);
+
+ /* clear all pending events and set-up interrupts */
+ fman_memac_ack_event(regs, 0xffffffff);
+ fman_memac_set_exception(regs, exceptions, TRUE);
+
+ return 0;
+}
+
+void fman_memac_set_exception(struct memac_regs *regs, uint32_t val, bool enable)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->imask);
+ if (enable)
+ tmp |= val;
+ else
+ tmp &= ~val;
+
+ iowrite32be(tmp, &regs->imask);
+}
+
+void fman_memac_reset_filter_table(struct memac_regs *regs)
+{
+ uint32_t i;
+ for (i = 0; i < 64; i++)
+ iowrite32be(i & ~HASH_CTRL_MCAST_EN, &regs->hashtable_ctrl);
+}
+
+void fman_memac_set_hash_table_entry(struct memac_regs *regs, uint32_t crc)
+{
+ iowrite32be(crc | HASH_CTRL_MCAST_EN, &regs->hashtable_ctrl);
+}
+
+void fman_memac_set_hash_table(struct memac_regs *regs, uint32_t val)
+{
+ iowrite32be(val, &regs->hashtable_ctrl);
+}
+
+uint16_t fman_memac_get_max_frame_len(struct memac_regs *regs)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->maxfrm);
+
+ return(uint16_t)tmp;
+}
+
+
+void fman_memac_set_tx_pause_frames(struct memac_regs *regs,
+ uint8_t priority,
+ uint16_t pause_time,
+ uint16_t thresh_time)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->tx_fifo_sections);
+
+ if (priority == 0xff) {
+ GET_TX_EMPTY_DEFAULT_VALUE(tmp);
+ iowrite32be(tmp, &regs->tx_fifo_sections);
+
+ tmp = ioread32be(&regs->command_config);
+ tmp &= ~CMD_CFG_PFC_MODE;
+ priority = 0;
+ } else {
+ GET_TX_EMPTY_PFC_VALUE(tmp);
+ iowrite32be(tmp, &regs->tx_fifo_sections);
+
+ tmp = ioread32be(&regs->command_config);
+ tmp |= CMD_CFG_PFC_MODE;
+ }
+
+ iowrite32be(tmp, &regs->command_config);
+
+ tmp = ioread32be(&regs->pause_quanta[priority / 2]);
+ if (priority % 2)
+ tmp &= 0x0000FFFF;
+ else
+ tmp &= 0xFFFF0000;
+ tmp |= ((uint32_t)pause_time << (16 * (priority % 2)));
+ iowrite32be(tmp, &regs->pause_quanta[priority / 2]);
+
+ tmp = ioread32be(&regs->pause_thresh[priority / 2]);
+ if (priority % 2)
+ tmp &= 0x0000FFFF;
+ else
+ tmp &= 0xFFFF0000;
+ tmp |= ((uint32_t)thresh_time<<(16 * (priority % 2)));
+ iowrite32be(tmp, &regs->pause_thresh[priority / 2]);
+}
+
+void fman_memac_set_rx_ignore_pause_frames(struct memac_regs *regs,bool enable)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->command_config);
+ if (enable)
+ tmp |= CMD_CFG_PAUSE_IGNORE;
+ else
+ tmp &= ~CMD_CFG_PAUSE_IGNORE;
+
+ iowrite32be(tmp, &regs->command_config);
+}
+
+void fman_memac_set_wol(struct memac_regs *regs, bool enable)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->command_config);
+
+ if (enable)
+ tmp |= CMD_CFG_MG;
+ else
+ tmp &= ~CMD_CFG_MG;
+
+ iowrite32be(tmp, &regs->command_config);
+}
+
+#define GET_MEMAC_CNTR_64(bn) \
+ (ioread32be(&regs->bn ## _l) | \
+ ((uint64_t)ioread32be(&regs->bn ## _u) << 32))
+
+uint64_t fman_memac_get_counter(struct memac_regs *regs,
+ enum memac_counters reg_name)
+{
+ uint64_t ret_val;
+
+ switch (reg_name) {
+ case E_MEMAC_COUNTER_R64:
+ ret_val = GET_MEMAC_CNTR_64(r64);
+ break;
+ case E_MEMAC_COUNTER_R127:
+ ret_val = GET_MEMAC_CNTR_64(r127);
+ break;
+ case E_MEMAC_COUNTER_R255:
+ ret_val = GET_MEMAC_CNTR_64(r255);
+ break;
+ case E_MEMAC_COUNTER_R511:
+ ret_val = GET_MEMAC_CNTR_64(r511);
+ break;
+ case E_MEMAC_COUNTER_R1023:
+ ret_val = GET_MEMAC_CNTR_64(r1023);
+ break;
+ case E_MEMAC_COUNTER_R1518:
+ ret_val = GET_MEMAC_CNTR_64(r1518);
+ break;
+ case E_MEMAC_COUNTER_R1519X:
+ ret_val = GET_MEMAC_CNTR_64(r1519x);
+ break;
+ case E_MEMAC_COUNTER_RFRG:
+ ret_val = GET_MEMAC_CNTR_64(rfrg);
+ break;
+ case E_MEMAC_COUNTER_RJBR:
+ ret_val = GET_MEMAC_CNTR_64(rjbr);
+ break;
+ case E_MEMAC_COUNTER_RDRP:
+ ret_val = GET_MEMAC_CNTR_64(rdrp);
+ break;
+ case E_MEMAC_COUNTER_RALN:
+ ret_val = GET_MEMAC_CNTR_64(raln);
+ break;
+ case E_MEMAC_COUNTER_TUND:
+ ret_val = GET_MEMAC_CNTR_64(tund);
+ break;
+ case E_MEMAC_COUNTER_ROVR:
+ ret_val = GET_MEMAC_CNTR_64(rovr);
+ break;
+ case E_MEMAC_COUNTER_RXPF:
+ ret_val = GET_MEMAC_CNTR_64(rxpf);
+ break;
+ case E_MEMAC_COUNTER_TXPF:
+ ret_val = GET_MEMAC_CNTR_64(txpf);
+ break;
+ case E_MEMAC_COUNTER_ROCT:
+ ret_val = GET_MEMAC_CNTR_64(roct);
+ break;
+ case E_MEMAC_COUNTER_RMCA:
+ ret_val = GET_MEMAC_CNTR_64(rmca);
+ break;
+ case E_MEMAC_COUNTER_RBCA:
+ ret_val = GET_MEMAC_CNTR_64(rbca);
+ break;
+ case E_MEMAC_COUNTER_RPKT:
+ ret_val = GET_MEMAC_CNTR_64(rpkt);
+ break;
+ case E_MEMAC_COUNTER_RUCA:
+ ret_val = GET_MEMAC_CNTR_64(ruca);
+ break;
+ case E_MEMAC_COUNTER_RERR:
+ ret_val = GET_MEMAC_CNTR_64(rerr);
+ break;
+ case E_MEMAC_COUNTER_TOCT:
+ ret_val = GET_MEMAC_CNTR_64(toct);
+ break;
+ case E_MEMAC_COUNTER_TMCA:
+ ret_val = GET_MEMAC_CNTR_64(tmca);
+ break;
+ case E_MEMAC_COUNTER_TBCA:
+ ret_val = GET_MEMAC_CNTR_64(tbca);
+ break;
+ case E_MEMAC_COUNTER_TUCA:
+ ret_val = GET_MEMAC_CNTR_64(tuca);
+ break;
+ case E_MEMAC_COUNTER_TERR:
+ ret_val = GET_MEMAC_CNTR_64(terr);
+ break;
+ default:
+ ret_val = 0;
+ }
+
+ return ret_val;
+}
+
+void fman_memac_adjust_link(struct memac_regs *regs,
+ enum enet_interface iface_mode,
+ enum enet_speed speed, bool full_dx)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->if_mode);
+
+ if (full_dx)
+ tmp &= ~IF_MODE_HD;
+ else
+ tmp |= IF_MODE_HD;
+
+ if (iface_mode == E_ENET_IF_RGMII) {
+ /* Configure RGMII in manual mode */
+ tmp &= ~IF_MODE_RGMII_AUTO;
+ tmp &= ~IF_MODE_RGMII_SP_MASK;
+
+ if (full_dx)
+ tmp |= IF_MODE_RGMII_FD;
+ else
+ tmp &= ~IF_MODE_RGMII_FD;
+
+ switch (speed) {
+ case E_ENET_SPEED_1000:
+ tmp |= IF_MODE_RGMII_1000;
+ break;
+ case E_ENET_SPEED_100:
+ tmp |= IF_MODE_RGMII_100;
+ break;
+ case E_ENET_SPEED_10:
+ tmp |= IF_MODE_RGMII_10;
+ break;
+ default:
+ break;
+ }
+ }
+
+ iowrite32be(tmp, &regs->if_mode);
+}
+
+void fman_memac_defconfig(struct memac_cfg *cfg)
+{
+ cfg->reset_on_init = FALSE;
+ cfg->wan_mode_enable = FALSE;
+ cfg->promiscuous_mode_enable = FALSE;
+ cfg->pause_forward_enable = FALSE;
+ cfg->pause_ignore = FALSE;
+ cfg->tx_addr_ins_enable = FALSE;
+ cfg->loopback_enable = FALSE;
+ cfg->cmd_frame_enable = FALSE;
+ cfg->rx_error_discard = FALSE;
+ cfg->send_idle_enable = FALSE;
+ cfg->no_length_check_enable = TRUE;
+ cfg->lgth_check_nostdr = FALSE;
+ cfg->time_stamp_enable = FALSE;
+ cfg->tx_ipg_length = DEFAULT_TX_IPG_LENGTH;
+ cfg->max_frame_length = DEFAULT_FRAME_LENGTH;
+ cfg->pause_quanta = DEFAULT_PAUSE_QUANTA;
+ cfg->pad_enable = TRUE;
+ cfg->phy_tx_ena_on = FALSE;
+ cfg->rx_sfd_any = FALSE;
+ cfg->rx_pbl_fwd = FALSE;
+ cfg->tx_pbl_fwd = FALSE;
+ cfg->debug_mode = FALSE;
+ cfg->wake_on_lan = FALSE;
+}
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/fman_memac_mii_acc.c b/sys/contrib/ncsw/Peripherals/FM/MAC/fman_memac_mii_acc.c
new file mode 100755
index 000000000000..ccda11ec25e1
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/fman_memac_mii_acc.c
@@ -0,0 +1,213 @@
+/*
+ * Copyright 2008-2013 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "fsl_fman_memac_mii_acc.h"
+
+static void write_phy_reg_10g(struct memac_mii_access_mem_map *mii_regs,
+ uint8_t phy_addr, uint8_t reg, uint16_t data)
+{
+ uint32_t tmp_reg;
+
+ tmp_reg = ioread32be(&mii_regs->mdio_cfg);
+ /* Leave only MDIO_CLK_DIV bits set on */
+ tmp_reg &= MDIO_CFG_CLK_DIV_MASK;
+ /* Set maximum MDIO_HOLD value to allow phy to see
+ change of data signal */
+ tmp_reg |= MDIO_CFG_HOLD_MASK;
+ /* Add 10G interface mode */
+ tmp_reg |= MDIO_CFG_ENC45;
+ iowrite32be(tmp_reg, &mii_regs->mdio_cfg);
+
+ /* Wait for command completion */
+ while ((ioread32be(&mii_regs->mdio_cfg)) & MDIO_CFG_BSY)
+ udelay(1);
+
+ /* Specify phy and register to be accessed */
+ iowrite32be(phy_addr, &mii_regs->mdio_ctrl);
+ iowrite32be(reg, &mii_regs->mdio_addr);
+ wmb();
+
+ while ((ioread32be(&mii_regs->mdio_cfg)) & MDIO_CFG_BSY)
+ udelay(1);
+
+ /* Write data */
+ iowrite32be(data, &mii_regs->mdio_data);
+ wmb();
+
+ /* Wait for write transaction end */
+ while ((ioread32be(&mii_regs->mdio_data)) & MDIO_DATA_BSY)
+ udelay(1);
+}
+
+static uint32_t read_phy_reg_10g(struct memac_mii_access_mem_map *mii_regs,
+ uint8_t phy_addr, uint8_t reg, uint16_t *data)
+{
+ uint32_t tmp_reg;
+
+ tmp_reg = ioread32be(&mii_regs->mdio_cfg);
+ /* Leave only MDIO_CLK_DIV bits set on */
+ tmp_reg &= MDIO_CFG_CLK_DIV_MASK;
+ /* Set maximum MDIO_HOLD value to allow phy to see
+ change of data signal */
+ tmp_reg |= MDIO_CFG_HOLD_MASK;
+ /* Add 10G interface mode */
+ tmp_reg |= MDIO_CFG_ENC45;
+ iowrite32be(tmp_reg, &mii_regs->mdio_cfg);
+
+ /* Wait for command completion */
+ while ((ioread32be(&mii_regs->mdio_cfg)) & MDIO_CFG_BSY)
+ udelay(1);
+
+ /* Specify phy and register to be accessed */
+ iowrite32be(phy_addr, &mii_regs->mdio_ctrl);
+ iowrite32be(reg, &mii_regs->mdio_addr);
+ wmb();
+
+ while ((ioread32be(&mii_regs->mdio_cfg)) & MDIO_CFG_BSY)
+ udelay(1);
+
+ /* Read cycle */
+ tmp_reg = phy_addr;
+ tmp_reg |= MDIO_CTL_READ;
+ iowrite32be(tmp_reg, &mii_regs->mdio_ctrl);
+ wmb();
+
+ /* Wait for data to be available */
+ while ((ioread32be(&mii_regs->mdio_data)) & MDIO_DATA_BSY)
+ udelay(1);
+
+ *data = (uint16_t)ioread32be(&mii_regs->mdio_data);
+
+ /* Check if there was an error */
+ return ioread32be(&mii_regs->mdio_cfg);
+}
+
+static void write_phy_reg_1g(struct memac_mii_access_mem_map *mii_regs,
+ uint8_t phy_addr, uint8_t reg, uint16_t data)
+{
+ uint32_t tmp_reg;
+
+ /* Leave only MDIO_CLK_DIV and MDIO_HOLD bits set on */
+ tmp_reg = ioread32be(&mii_regs->mdio_cfg);
+ tmp_reg &= (MDIO_CFG_CLK_DIV_MASK | MDIO_CFG_HOLD_MASK);
+ iowrite32be(tmp_reg, &mii_regs->mdio_cfg);
+
+ /* Wait for command completion */
+ while ((ioread32be(&mii_regs->mdio_cfg)) & MDIO_CFG_BSY)
+ udelay(1);
+
+ /* Write transaction */
+ tmp_reg = (phy_addr << MDIO_CTL_PHY_ADDR_SHIFT);
+ tmp_reg |= reg;
+ iowrite32be(tmp_reg, &mii_regs->mdio_ctrl);
+
+ while ((ioread32be(&mii_regs->mdio_cfg)) & MDIO_CFG_BSY)
+ udelay(1);
+
+ iowrite32be(data, &mii_regs->mdio_data);
+
+ wmb();
+
+ /* Wait for write transaction to end */
+ while ((ioread32be(&mii_regs->mdio_data)) & MDIO_DATA_BSY)
+ udelay(1);
+}
+
+static uint32_t read_phy_reg_1g(struct memac_mii_access_mem_map *mii_regs,
+ uint8_t phy_addr, uint8_t reg, uint16_t *data)
+{
+ uint32_t tmp_reg;
+
+ /* Leave only MDIO_CLK_DIV and MDIO_HOLD bits set on */
+ tmp_reg = ioread32be(&mii_regs->mdio_cfg);
+ tmp_reg &= (MDIO_CFG_CLK_DIV_MASK | MDIO_CFG_HOLD_MASK);
+ iowrite32be(tmp_reg, &mii_regs->mdio_cfg);
+
+ /* Wait for command completion */
+ while ((ioread32be(&mii_regs->mdio_cfg)) & MDIO_CFG_BSY)
+ udelay(1);
+
+ /* Read transaction */
+ tmp_reg = (phy_addr << MDIO_CTL_PHY_ADDR_SHIFT);
+ tmp_reg |= reg;
+ tmp_reg |= MDIO_CTL_READ;
+ iowrite32be(tmp_reg, &mii_regs->mdio_ctrl);
+
+ while ((ioread32be(&mii_regs->mdio_cfg)) & MDIO_CFG_BSY)
+ udelay(1);
+
+ /* Wait for data to be available */
+ while ((ioread32be(&mii_regs->mdio_data)) & MDIO_DATA_BSY)
+ udelay(1);
+
+ *data = (uint16_t)ioread32be(&mii_regs->mdio_data);
+
+ /* Check error */
+ return ioread32be(&mii_regs->mdio_cfg);
+}
+
+/*****************************************************************************/
+int fman_memac_mii_write_phy_reg(struct memac_mii_access_mem_map *mii_regs,
+ uint8_t phy_addr, uint8_t reg, uint16_t data,
+ enum enet_speed enet_speed)
+{
+ /* Figure out interface type - 10G vs 1G.
+ In 10G interface both phy_addr and devAddr present. */
+ if (enet_speed == E_ENET_SPEED_10000)
+ write_phy_reg_10g(mii_regs, phy_addr, reg, data);
+ else
+ write_phy_reg_1g(mii_regs, phy_addr, reg, data);
+
+ return 0;
+}
+
+/*****************************************************************************/
+int fman_memac_mii_read_phy_reg(struct memac_mii_access_mem_map *mii_regs,
+ uint8_t phy_addr, uint8_t reg, uint16_t *data,
+ enum enet_speed enet_speed)
+{
+ uint32_t ans;
+ /* Figure out interface type - 10G vs 1G.
+ In 10G interface both phy_addr and devAddr present. */
+ if (enet_speed == E_ENET_SPEED_10000)
+ ans = read_phy_reg_10g(mii_regs, phy_addr, reg, data);
+ else
+ ans = read_phy_reg_1g(mii_regs, phy_addr, reg, data);
+
+ if (ans & MDIO_CFG_READ_ERR)
+ return -EINVAL;
+ return 0;
+}
+
+/* ......................................................................... */
+
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/fman_tgec.c b/sys/contrib/ncsw/Peripherals/FM/MAC/fman_tgec.c
new file mode 100644
index 000000000000..fff9d5de80e3
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/fman_tgec.c
@@ -0,0 +1,367 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "fsl_fman_tgec.h"
+
+
+void fman_tgec_set_mac_address(struct tgec_regs *regs, uint8_t *adr)
+{
+ uint32_t tmp0, tmp1;
+
+ tmp0 = (uint32_t)(adr[0] |
+ adr[1] << 8 |
+ adr[2] << 16 |
+ adr[3] << 24);
+ tmp1 = (uint32_t)(adr[4] | adr[5] << 8);
+ iowrite32be(tmp0, &regs->mac_addr_0);
+ iowrite32be(tmp1, &regs->mac_addr_1);
+}
+
+void fman_tgec_reset_stat(struct tgec_regs *regs)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->command_config);
+
+ tmp |= CMD_CFG_STAT_CLR;
+
+ iowrite32be(tmp, &regs->command_config);
+
+ while (ioread32be(&regs->command_config) & CMD_CFG_STAT_CLR) ;
+}
+
+#define GET_TGEC_CNTR_64(bn) \
+ (((uint64_t)ioread32be(&regs->bn ## _u) << 32) | \
+ ioread32be(&regs->bn ## _l))
+
+uint64_t fman_tgec_get_counter(struct tgec_regs *regs, enum tgec_counters reg_name)
+{
+ uint64_t ret_val;
+
+ switch (reg_name) {
+ case E_TGEC_COUNTER_R64:
+ ret_val = GET_TGEC_CNTR_64(r64);
+ break;
+ case E_TGEC_COUNTER_R127:
+ ret_val = GET_TGEC_CNTR_64(r127);
+ break;
+ case E_TGEC_COUNTER_R255:
+ ret_val = GET_TGEC_CNTR_64(r255);
+ break;
+ case E_TGEC_COUNTER_R511:
+ ret_val = GET_TGEC_CNTR_64(r511);
+ break;
+ case E_TGEC_COUNTER_R1023:
+ ret_val = GET_TGEC_CNTR_64(r1023);
+ break;
+ case E_TGEC_COUNTER_R1518:
+ ret_val = GET_TGEC_CNTR_64(r1518);
+ break;
+ case E_TGEC_COUNTER_R1519X:
+ ret_val = GET_TGEC_CNTR_64(r1519x);
+ break;
+ case E_TGEC_COUNTER_TRFRG:
+ ret_val = GET_TGEC_CNTR_64(trfrg);
+ break;
+ case E_TGEC_COUNTER_TRJBR:
+ ret_val = GET_TGEC_CNTR_64(trjbr);
+ break;
+ case E_TGEC_COUNTER_RDRP:
+ ret_val = GET_TGEC_CNTR_64(rdrp);
+ break;
+ case E_TGEC_COUNTER_RALN:
+ ret_val = GET_TGEC_CNTR_64(raln);
+ break;
+ case E_TGEC_COUNTER_TRUND:
+ ret_val = GET_TGEC_CNTR_64(trund);
+ break;
+ case E_TGEC_COUNTER_TROVR:
+ ret_val = GET_TGEC_CNTR_64(trovr);
+ break;
+ case E_TGEC_COUNTER_RXPF:
+ ret_val = GET_TGEC_CNTR_64(rxpf);
+ break;
+ case E_TGEC_COUNTER_TXPF:
+ ret_val = GET_TGEC_CNTR_64(txpf);
+ break;
+ case E_TGEC_COUNTER_ROCT:
+ ret_val = GET_TGEC_CNTR_64(roct);
+ break;
+ case E_TGEC_COUNTER_RMCA:
+ ret_val = GET_TGEC_CNTR_64(rmca);
+ break;
+ case E_TGEC_COUNTER_RBCA:
+ ret_val = GET_TGEC_CNTR_64(rbca);
+ break;
+ case E_TGEC_COUNTER_RPKT:
+ ret_val = GET_TGEC_CNTR_64(rpkt);
+ break;
+ case E_TGEC_COUNTER_RUCA:
+ ret_val = GET_TGEC_CNTR_64(ruca);
+ break;
+ case E_TGEC_COUNTER_RERR:
+ ret_val = GET_TGEC_CNTR_64(rerr);
+ break;
+ case E_TGEC_COUNTER_TOCT:
+ ret_val = GET_TGEC_CNTR_64(toct);
+ break;
+ case E_TGEC_COUNTER_TMCA:
+ ret_val = GET_TGEC_CNTR_64(tmca);
+ break;
+ case E_TGEC_COUNTER_TBCA:
+ ret_val = GET_TGEC_CNTR_64(tbca);
+ break;
+ case E_TGEC_COUNTER_TUCA:
+ ret_val = GET_TGEC_CNTR_64(tuca);
+ break;
+ case E_TGEC_COUNTER_TERR:
+ ret_val = GET_TGEC_CNTR_64(terr);
+ break;
+ default:
+ ret_val = 0;
+ }
+
+ return ret_val;
+}
+
+void fman_tgec_enable(struct tgec_regs *regs, bool apply_rx, bool apply_tx)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->command_config);
+ if (apply_rx)
+ tmp |= CMD_CFG_RX_EN;
+ if (apply_tx)
+ tmp |= CMD_CFG_TX_EN;
+ iowrite32be(tmp, &regs->command_config);
+}
+
+void fman_tgec_disable(struct tgec_regs *regs, bool apply_rx, bool apply_tx)
+{
+ uint32_t tmp_reg_32;
+
+ tmp_reg_32 = ioread32be(&regs->command_config);
+ if (apply_rx)
+ tmp_reg_32 &= ~CMD_CFG_RX_EN;
+ if (apply_tx)
+ tmp_reg_32 &= ~CMD_CFG_TX_EN;
+ iowrite32be(tmp_reg_32, &regs->command_config);
+}
+
+void fman_tgec_set_promiscuous(struct tgec_regs *regs, bool val)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->command_config);
+ if (val)
+ tmp |= CMD_CFG_PROMIS_EN;
+ else
+ tmp &= ~CMD_CFG_PROMIS_EN;
+ iowrite32be(tmp, &regs->command_config);
+}
+
+void fman_tgec_reset_filter_table(struct tgec_regs *regs)
+{
+ uint32_t i;
+ for (i = 0; i < 512; i++)
+ iowrite32be(i & ~TGEC_HASH_MCAST_EN, &regs->hashtable_ctrl);
+}
+
+void fman_tgec_set_hash_table_entry(struct tgec_regs *regs, uint32_t crc)
+{
+ uint32_t hash = (crc >> TGEC_HASH_MCAST_SHIFT) & TGEC_HASH_ADR_MSK; /* Take 9 MSB bits */
+ iowrite32be(hash | TGEC_HASH_MCAST_EN, &regs->hashtable_ctrl);
+}
+
+void fman_tgec_set_hash_table(struct tgec_regs *regs, uint32_t value)
+{
+ iowrite32be(value, &regs->hashtable_ctrl);
+}
+
+void fman_tgec_set_tx_pause_frames(struct tgec_regs *regs, uint16_t pause_time)
+{
+ iowrite32be((uint32_t)pause_time, &regs->pause_quant);
+}
+
+void fman_tgec_set_rx_ignore_pause_frames(struct tgec_regs *regs, bool en)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->command_config);
+ if (en)
+ tmp |= CMD_CFG_PAUSE_IGNORE;
+ else
+ tmp &= ~CMD_CFG_PAUSE_IGNORE;
+ iowrite32be(tmp, &regs->command_config);
+}
+
+void fman_tgec_enable_1588_time_stamp(struct tgec_regs *regs, bool en)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->command_config);
+ if (en)
+ tmp |= CMD_CFG_EN_TIMESTAMP;
+ else
+ tmp &= ~CMD_CFG_EN_TIMESTAMP;
+ iowrite32be(tmp, &regs->command_config);
+}
+
+uint32_t fman_tgec_get_event(struct tgec_regs *regs, uint32_t ev_mask)
+{
+ return ioread32be(&regs->ievent) & ev_mask;
+}
+
+void fman_tgec_ack_event(struct tgec_regs *regs, uint32_t ev_mask)
+{
+ iowrite32be(ev_mask, &regs->ievent);
+}
+
+uint32_t fman_tgec_get_interrupt_mask(struct tgec_regs *regs)
+{
+ return ioread32be(&regs->imask);
+}
+
+void fman_tgec_add_addr_in_paddr(struct tgec_regs *regs, uint8_t *adr)
+{
+ uint32_t tmp0, tmp1;
+
+ tmp0 = (uint32_t)(adr[0] |
+ adr[1] << 8 |
+ adr[2] << 16 |
+ adr[3] << 24);
+ tmp1 = (uint32_t)(adr[4] | adr[5] << 8);
+ iowrite32be(tmp0, &regs->mac_addr_2);
+ iowrite32be(tmp1, &regs->mac_addr_3);
+}
+
+void fman_tgec_clear_addr_in_paddr(struct tgec_regs *regs)
+{
+ iowrite32be(0, &regs->mac_addr_2);
+ iowrite32be(0, &regs->mac_addr_3);
+}
+
+uint32_t fman_tgec_get_revision(struct tgec_regs *regs)
+{
+ return ioread32be(&regs->tgec_id);
+}
+
+void fman_tgec_enable_interrupt(struct tgec_regs *regs, uint32_t ev_mask)
+{
+ iowrite32be(ioread32be(&regs->imask) | ev_mask, &regs->imask);
+}
+
+void fman_tgec_disable_interrupt(struct tgec_regs *regs, uint32_t ev_mask)
+{
+ iowrite32be(ioread32be(&regs->imask) & ~ev_mask, &regs->imask);
+}
+
+uint16_t fman_tgec_get_max_frame_len(struct tgec_regs *regs)
+{
+ return (uint16_t) ioread32be(&regs->maxfrm);
+}
+
+void fman_tgec_defconfig(struct tgec_cfg *cfg)
+{
+ cfg->wan_mode_enable = DEFAULT_WAN_MODE_ENABLE;
+ cfg->promiscuous_mode_enable = DEFAULT_PROMISCUOUS_MODE_ENABLE;
+ cfg->pause_forward_enable = DEFAULT_PAUSE_FORWARD_ENABLE;
+ cfg->pause_ignore = DEFAULT_PAUSE_IGNORE;
+ cfg->tx_addr_ins_enable = DEFAULT_TX_ADDR_INS_ENABLE;
+ cfg->loopback_enable = DEFAULT_LOOPBACK_ENABLE;
+ cfg->cmd_frame_enable = DEFAULT_CMD_FRAME_ENABLE;
+ cfg->rx_error_discard = DEFAULT_RX_ERROR_DISCARD;
+ cfg->send_idle_enable = DEFAULT_SEND_IDLE_ENABLE;
+ cfg->no_length_check_enable = DEFAULT_NO_LENGTH_CHECK_ENABLE;
+ cfg->lgth_check_nostdr = DEFAULT_LGTH_CHECK_NOSTDR;
+ cfg->time_stamp_enable = DEFAULT_TIME_STAMP_ENABLE;
+ cfg->tx_ipg_length = DEFAULT_TX_IPG_LENGTH;
+ cfg->max_frame_length = DEFAULT_MAX_FRAME_LENGTH;
+ cfg->pause_quant = DEFAULT_PAUSE_QUANT;
+#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
+ cfg->skip_fman11_workaround = FALSE;
+#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
+}
+
+int fman_tgec_init(struct tgec_regs *regs, struct tgec_cfg *cfg,
+ uint32_t exception_mask)
+{
+ uint32_t tmp;
+
+ /* Config */
+ tmp = 0x40; /* CRC forward */
+ if (cfg->wan_mode_enable)
+ tmp |= CMD_CFG_WAN_MODE;
+ if (cfg->promiscuous_mode_enable)
+ tmp |= CMD_CFG_PROMIS_EN;
+ if (cfg->pause_forward_enable)
+ tmp |= CMD_CFG_PAUSE_FWD;
+ if (cfg->pause_ignore)
+ tmp |= CMD_CFG_PAUSE_IGNORE;
+ if (cfg->tx_addr_ins_enable)
+ tmp |= CMD_CFG_TX_ADDR_INS;
+ if (cfg->loopback_enable)
+ tmp |= CMD_CFG_LOOPBACK_EN;
+ if (cfg->cmd_frame_enable)
+ tmp |= CMD_CFG_CMD_FRM_EN;
+ if (cfg->rx_error_discard)
+ tmp |= CMD_CFG_RX_ER_DISC;
+ if (cfg->send_idle_enable)
+ tmp |= CMD_CFG_SEND_IDLE;
+ if (cfg->no_length_check_enable)
+ tmp |= CMD_CFG_NO_LEN_CHK;
+ if (cfg->time_stamp_enable)
+ tmp |= CMD_CFG_EN_TIMESTAMP;
+ iowrite32be(tmp, &regs->command_config);
+
+ /* Max Frame Length */
+ iowrite32be((uint32_t)cfg->max_frame_length, &regs->maxfrm);
+ /* Pause Time */
+ iowrite32be(cfg->pause_quant, &regs->pause_quant);
+
+ /* clear all pending events and set-up interrupts */
+ fman_tgec_ack_event(regs, 0xffffffff);
+ fman_tgec_enable_interrupt(regs, exception_mask);
+
+ return 0;
+}
+
+void fman_tgec_set_erratum_tx_fifo_corruption_10gmac_a007(struct tgec_regs *regs)
+{
+ uint32_t tmp;
+
+ /* restore the default tx ipg Length */
+ tmp = (ioread32be(&regs->tx_ipg_len) & ~TGEC_TX_IPG_LENGTH_MASK) | 12;
+
+ iowrite32be(tmp, &regs->tx_ipg_len);
+}
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/memac.c b/sys/contrib/ncsw/Peripherals/FM/MAC/memac.c
new file mode 100644
index 000000000000..85426c5feda9
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/memac.c
@@ -0,0 +1,1096 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/******************************************************************************
+ @File memac.c
+
+ @Description FM mEMAC driver
+*//***************************************************************************/
+
+#include "std_ext.h"
+#include "string_ext.h"
+#include "error_ext.h"
+#include "xx_ext.h"
+#include "endian_ext.h"
+#include "debug_ext.h"
+
+#include "fm_common.h"
+#include "memac.h"
+
+
+/*****************************************************************************/
+/* Internal routines */
+/*****************************************************************************/
+
+/* ......................................................................... */
+
+static uint32_t GetMacAddrHashCode(uint64_t ethAddr)
+{
+ uint64_t mask1, mask2;
+ uint32_t xorVal = 0;
+ uint8_t i, j;
+
+ for (i=0; i<6; i++)
+ {
+ mask1 = ethAddr & (uint64_t)0x01;
+ ethAddr >>= 1;
+
+ for (j=0; j<7; j++)
+ {
+ mask2 = ethAddr & (uint64_t)0x01;
+ mask1 ^= mask2;
+ ethAddr >>= 1;
+ }
+
+ xorVal |= (mask1 << (5-i));
+ }
+
+ return xorVal;
+}
+
+/* ......................................................................... */
+
+static void SetupSgmiiInternalPhy(t_Memac *p_Memac, uint8_t phyAddr)
+{
+ uint16_t tmpReg16;
+ e_EnetMode enetMode;
+
+ /* In case the higher MACs are used (i.e. the MACs that should support 10G),
+ speed=10000 is provided for SGMII ports. Temporary modify enet mode
+ to 1G one, so MII functions can work correctly. */
+ enetMode = p_Memac->enetMode;
+
+ /* SGMII mode + AN enable */
+ tmpReg16 = PHY_SGMII_IF_MODE_AN | PHY_SGMII_IF_MODE_SGMII;
+ if ((p_Memac->enetMode) == e_ENET_MODE_SGMII_2500)
+ tmpReg16 = PHY_SGMII_CR_PHY_RESET | PHY_SGMII_IF_SPEED_GIGABIT | PHY_SGMII_IF_MODE_SGMII;
+
+ p_Memac->enetMode = MAKE_ENET_MODE(ENET_INTERFACE_FROM_MODE(p_Memac->enetMode), e_ENET_SPEED_1000);
+ MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x14, tmpReg16);
+
+ /* Device ability according to SGMII specification */
+ tmpReg16 = PHY_SGMII_DEV_ABILITY_SGMII;
+ MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x4, tmpReg16);
+
+ /* Adjust link timer for SGMII -
+ According to Cisco SGMII specification the timer should be 1.6 ms.
+ The link_timer register is configured in units of the clock.
+ - When running as 1G SGMII, Serdes clock is 125 MHz, so
+ unit = 1 / (125*10^6 Hz) = 8 ns.
+ 1.6 ms in units of 8 ns = 1.6ms / 8ns = 2 * 10^5 = 0x30d40
+ - When running as 2.5G SGMII, Serdes clock is 312.5 MHz, so
+ unit = 1 / (312.5*10^6 Hz) = 3.2 ns.
+ 1.6 ms in units of 3.2 ns = 1.6ms / 3.2ns = 5 * 10^5 = 0x7a120.
+ Since link_timer value of 1G SGMII will be too short for 2.5 SGMII,
+ we always set up here a value of 2.5 SGMII. */
+ MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x13, 0x0007);
+ MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x12, 0xa120);
+
+ /* Restart AN */
+ tmpReg16 = PHY_SGMII_CR_DEF_VAL | PHY_SGMII_CR_RESET_AN;
+ MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x0, tmpReg16);
+
+ /* Restore original enet mode */
+ p_Memac->enetMode = enetMode;
+}
+
+/* ......................................................................... */
+
+static void SetupSgmiiInternalPhyBaseX(t_Memac *p_Memac, uint8_t phyAddr)
+{
+ uint16_t tmpReg16;
+ e_EnetMode enetMode;
+
+ /* In case the higher MACs are used (i.e. the MACs that should support 10G),
+ speed=10000 is provided for SGMII ports. Temporary modify enet mode
+ to 1G one, so MII functions can work correctly. */
+ enetMode = p_Memac->enetMode;
+ p_Memac->enetMode = MAKE_ENET_MODE(ENET_INTERFACE_FROM_MODE(p_Memac->enetMode), e_ENET_SPEED_1000);
+
+ /* 1000BaseX mode */
+ tmpReg16 = PHY_SGMII_IF_MODE_1000X;
+ MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x14, tmpReg16);
+
+ /* AN Device capability */
+ tmpReg16 = PHY_SGMII_DEV_ABILITY_1000X;
+ MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x4, tmpReg16);
+
+ /* Adjust link timer for SGMII -
+ For Serdes 1000BaseX auto-negotiation the timer should be 10 ms.
+ The link_timer register is configured in units of the clock.
+ - When running as 1G SGMII, Serdes clock is 125 MHz, so
+ unit = 1 / (125*10^6 Hz) = 8 ns.
+ 10 ms in units of 8 ns = 10ms / 8ns = 1250000 = 0x1312d0
+ - When running as 2.5G SGMII, Serdes clock is 312.5 MHz, so
+ unit = 1 / (312.5*10^6 Hz) = 3.2 ns.
+ 10 ms in units of 3.2 ns = 10ms / 3.2ns = 3125000 = 0x2faf08.
+ Since link_timer value of 1G SGMII will be too short for 2.5 SGMII,
+ we always set up here a value of 2.5 SGMII. */
+ MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x13, 0x002f);
+ MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x12, 0xaf08);
+
+ /* Restart AN */
+ tmpReg16 = PHY_SGMII_CR_DEF_VAL | PHY_SGMII_CR_RESET_AN;
+ MEMAC_MII_WritePhyReg(p_Memac, phyAddr, 0x0, tmpReg16);
+
+ /* Restore original enet mode */
+ p_Memac->enetMode = enetMode;
+}
+
+/* ......................................................................... */
+
+static t_Error CheckInitParameters(t_Memac *p_Memac)
+{
+ e_FmMacType portType;
+
+ portType = ((ENET_SPEED_FROM_MODE(p_Memac->enetMode) < e_ENET_SPEED_10000) ? e_FM_MAC_1G : e_FM_MAC_10G);
+
+#if (FM_MAX_NUM_OF_10G_MACS > 0)
+ if ((portType == e_FM_MAC_10G) && (p_Memac->macId >= FM_MAX_NUM_OF_10G_MACS))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("10G MAC ID must be less than %d", FM_MAX_NUM_OF_10G_MACS));
+#endif /* (FM_MAX_NUM_OF_10G_MACS > 0) */
+
+ if ((portType == e_FM_MAC_1G) && (p_Memac->macId >= FM_MAX_NUM_OF_1G_MACS))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("1G MAC ID must be less than %d", FM_MAX_NUM_OF_1G_MACS));
+ if (p_Memac->addr == 0)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Ethernet MAC must have a valid MAC address"));
+ if (!p_Memac->f_Exception)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Uninitialized f_Exception"));
+ if (!p_Memac->f_Event)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Uninitialized f_Event"));
+#ifdef FM_LEN_CHECK_ERRATA_FMAN_SW002
+ if (!p_Memac->p_MemacDriverParam->no_length_check_enable)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("LengthCheck!"));
+#endif /* FM_LEN_CHECK_ERRATA_FMAN_SW002 */
+
+ return E_OK;
+}
+
+/* ........................................................................... */
+
+static void MemacErrException(t_Handle h_Memac)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+ uint32_t event, imask;
+
+ event = fman_memac_get_event(p_Memac->p_MemMap, 0xffffffff);
+ imask = fman_memac_get_interrupt_mask(p_Memac->p_MemMap);
+
+ /* Imask include both error and notification/event bits.
+ Leaving only error bits enabled by imask.
+ The imask error bits are shifted by 16 bits offset from
+ their corresponding location in the ievent - hence the >> 16 */
+ event &= ((imask & MEMAC_ALL_ERRS_IMASK) >> 16);
+
+ fman_memac_ack_event(p_Memac->p_MemMap, event);
+
+ if (event & MEMAC_IEVNT_TS_ECC_ER)
+ p_Memac->f_Exception(p_Memac->h_App, e_FM_MAC_EX_TS_FIFO_ECC_ERR);
+ if (event & MEMAC_IEVNT_TX_ECC_ER)
+ p_Memac->f_Exception(p_Memac->h_App, e_FM_MAC_EX_10G_1TX_ECC_ER);
+ if (event & MEMAC_IEVNT_RX_ECC_ER)
+ p_Memac->f_Exception(p_Memac->h_App, e_FM_MAC_EX_10G_RX_ECC_ER);
+}
+
+static void MemacException(t_Handle h_Memac)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+ uint32_t event, imask;
+
+ event = fman_memac_get_event(p_Memac->p_MemMap, 0xffffffff);
+ imask = fman_memac_get_interrupt_mask(p_Memac->p_MemMap);
+
+ /* Imask include both error and notification/event bits.
+ Leaving only error bits enabled by imask.
+ The imask error bits are shifted by 16 bits offset from
+ their corresponding location in the ievent - hence the >> 16 */
+ event &= ((imask & MEMAC_ALL_ERRS_IMASK) >> 16);
+
+ fman_memac_ack_event(p_Memac->p_MemMap, event);
+
+ if (event & MEMAC_IEVNT_MGI)
+ p_Memac->f_Exception(p_Memac->h_App, e_FM_MAC_EX_MAGIC_PACKET_INDICATION);
+}
+
+/* ......................................................................... */
+
+static void FreeInitResources(t_Memac *p_Memac)
+{
+ e_FmMacType portType;
+
+ portType =
+ ((ENET_SPEED_FROM_MODE(p_Memac->enetMode) < e_ENET_SPEED_10000) ? e_FM_MAC_1G : e_FM_MAC_10G);
+
+ if (portType == e_FM_MAC_10G)
+ FmUnregisterIntr(p_Memac->fmMacControllerDriver.h_Fm, e_FM_MOD_10G_MAC, p_Memac->macId, e_FM_INTR_TYPE_ERR);
+ else
+ FmUnregisterIntr(p_Memac->fmMacControllerDriver.h_Fm, e_FM_MOD_1G_MAC, p_Memac->macId, e_FM_INTR_TYPE_ERR);
+
+ /* release the driver's group hash table */
+ FreeHashTable(p_Memac->p_MulticastAddrHash);
+ p_Memac->p_MulticastAddrHash = NULL;
+
+ /* release the driver's individual hash table */
+ FreeHashTable(p_Memac->p_UnicastAddrHash);
+ p_Memac->p_UnicastAddrHash = NULL;
+}
+
+
+/*****************************************************************************/
+/* mEMAC API routines */
+/*****************************************************************************/
+
+/* ......................................................................... */
+
+static t_Error MemacEnable(t_Handle h_Memac, e_CommMode mode)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ fman_memac_enable(p_Memac->p_MemMap, (mode & e_COMM_MODE_RX), (mode & e_COMM_MODE_TX));
+
+ return E_OK;
+}
+
+/* ......................................................................... */
+
+static t_Error MemacDisable (t_Handle h_Memac, e_CommMode mode)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ fman_memac_disable(p_Memac->p_MemMap, (mode & e_COMM_MODE_RX), (mode & e_COMM_MODE_TX));
+
+ return E_OK;
+}
+
+/* ......................................................................... */
+
+static t_Error MemacSetPromiscuous(t_Handle h_Memac, bool newVal)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ fman_memac_set_promiscuous(p_Memac->p_MemMap, newVal);
+
+ return E_OK;
+}
+
+/* .............................................................................. */
+
+static t_Error MemacAdjustLink(t_Handle h_Memac, e_EnetSpeed speed, bool fullDuplex)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ if ((speed >= e_ENET_SPEED_1000) && (!fullDuplex))
+ RETURN_ERROR(MAJOR, E_CONFLICT,
+ ("Ethernet MAC 1G or 10G does not support half-duplex"));
+
+ fman_memac_adjust_link(p_Memac->p_MemMap,
+ (enum enet_interface)ENET_INTERFACE_FROM_MODE(p_Memac->enetMode),
+ (enum enet_speed)speed,
+ fullDuplex);
+ return E_OK;
+}
+
+
+/*****************************************************************************/
+/* Memac Configs modification functions */
+/*****************************************************************************/
+
+/* ......................................................................... */
+
+static t_Error MemacConfigLoopback(t_Handle h_Memac, bool newVal)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ p_Memac->p_MemacDriverParam->loopback_enable = newVal;
+
+ return E_OK;
+}
+
+/* ......................................................................... */
+
+static t_Error MemacConfigWan(t_Handle h_Memac, bool newVal)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ p_Memac->p_MemacDriverParam->wan_mode_enable = newVal;
+
+ return E_OK;
+}
+
+/* ......................................................................... */
+
+static t_Error MemacConfigMaxFrameLength(t_Handle h_Memac, uint16_t newVal)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ p_Memac->p_MemacDriverParam->max_frame_length = newVal;
+
+ return E_OK;
+}
+
+/* ......................................................................... */
+
+static t_Error MemacConfigPad(t_Handle h_Memac, bool newVal)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ p_Memac->p_MemacDriverParam->pad_enable = newVal;
+
+ return E_OK;
+}
+
+/* ......................................................................... */
+
+static t_Error MemacConfigLengthCheck(t_Handle h_Memac, bool newVal)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ p_Memac->p_MemacDriverParam->no_length_check_enable = !newVal;
+
+ return E_OK;
+}
+
+/* ......................................................................... */
+
+static t_Error MemacConfigException(t_Handle h_Memac, e_FmMacExceptions exception, bool enable)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+ uint32_t bitMask = 0;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ GET_EXCEPTION_FLAG(bitMask, exception);
+ if (bitMask)
+ {
+ if (enable)
+ p_Memac->exceptions |= bitMask;
+ else
+ p_Memac->exceptions &= ~bitMask;
+ }
+ else
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
+
+ return E_OK;
+}
+
+/* ......................................................................... */
+
+static t_Error MemacConfigResetOnInit(t_Handle h_Memac, bool enable)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ p_Memac->p_MemacDriverParam->reset_on_init = enable;
+
+ return E_OK;
+}
+
+
+/*****************************************************************************/
+/* Memac Run Time API functions */
+/*****************************************************************************/
+
+/* ......................................................................... */
+
+static t_Error MemacSetTxPauseFrames(t_Handle h_Memac,
+ uint8_t priority,
+ uint16_t pauseTime,
+ uint16_t threshTime)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ if (priority != 0xFF)
+ {
+ bool PortConfigured, PreFetchEnabled;
+
+ if (FmGetTnumAgingPeriod(p_Memac->fmMacControllerDriver.h_Fm) == 0)
+ RETURN_ERROR(MAJOR, E_CONFLICT, ("For PFC operation, TNUM aging must be enabled"));
+
+ FmGetPortPreFetchConfiguration(p_Memac->fmMacControllerDriver.h_Fm,
+ p_Memac->fmMacControllerDriver.macId,
+ &PortConfigured,
+ &PreFetchEnabled);
+
+ if ((ENET_SPEED_FROM_MODE(p_Memac->fmMacControllerDriver.enetMode) == e_ENET_SPEED_1000) && !PortConfigured)
+ DBG(INFO, ("For PFC correct operation, prefetch must be configured on the FM Tx PORT"));
+
+ if ((ENET_SPEED_FROM_MODE(p_Memac->fmMacControllerDriver.enetMode) == e_ENET_SPEED_1000) && PortConfigured && !PreFetchEnabled)
+ DBG(WARNING, ("For PFC correct operation, prefetch must be configured on the FM Tx PORT"));
+ }
+
+ fman_memac_set_tx_pause_frames(p_Memac->p_MemMap, priority, pauseTime, threshTime);
+
+ return E_OK;
+}
+
+/* ......................................................................... */
+
+static t_Error MemacSetTxAutoPauseFrames(t_Handle h_Memac,
+ uint16_t pauseTime)
+{
+ return MemacSetTxPauseFrames(h_Memac, FM_MAC_NO_PFC, pauseTime, 0);
+}
+
+/* ......................................................................... */
+
+static t_Error MemacSetRxIgnorePauseFrames(t_Handle h_Memac, bool en)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ fman_memac_set_rx_ignore_pause_frames(p_Memac->p_MemMap, en);
+
+ return E_OK;
+}
+
+/* ......................................................................... */
+
+static t_Error MemacSetWakeOnLan(t_Handle h_Memac, bool en)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ fman_memac_set_wol(p_Memac->p_MemMap, en);
+
+ return E_OK;
+}
+
+/* .............................................................................. */
+
+static t_Error MemacEnable1588TimeStamp(t_Handle h_Memac)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+UNUSED(p_Memac);
+DBG(WARNING, ("mEMAC has 1588 always enabled!"));
+
+ return E_OK;
+}
+
+/* Counters handling */
+/* ......................................................................... */
+
+static t_Error MemacGetStatistics(t_Handle h_Memac, t_FmMacStatistics *p_Statistics)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_Statistics, E_NULL_POINTER);
+
+ p_Statistics->eStatPkts64 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R64);
+ p_Statistics->eStatPkts65to127 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R127);
+ p_Statistics->eStatPkts128to255 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R255);
+ p_Statistics->eStatPkts256to511 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R511);
+ p_Statistics->eStatPkts512to1023 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1023);
+ p_Statistics->eStatPkts1024to1518 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1518);
+ p_Statistics->eStatPkts1519to1522 = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_R1519X);
+/* */
+ p_Statistics->eStatFragments = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RFRG);
+ p_Statistics->eStatJabbers = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RJBR);
+
+ p_Statistics->eStatsDropEvents = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RDRP);
+ p_Statistics->eStatCRCAlignErrors = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RALN);
+
+ p_Statistics->eStatUndersizePkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TUND);
+ p_Statistics->eStatOversizePkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_ROVR);
+/* Pause */
+ p_Statistics->reStatPause = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RXPF);
+ p_Statistics->teStatPause = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TXPF);
+
+/* MIB II */
+ p_Statistics->ifInOctets = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_ROCT);
+ p_Statistics->ifInUcastPkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RUCA);
+ p_Statistics->ifInMcastPkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RMCA);
+ p_Statistics->ifInBcastPkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RBCA);
+ p_Statistics->ifInPkts = p_Statistics->ifInUcastPkts
+ + p_Statistics->ifInMcastPkts
+ + p_Statistics->ifInBcastPkts;
+ p_Statistics->ifInDiscards = 0;
+ p_Statistics->ifInErrors = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_RERR);
+
+ p_Statistics->ifOutOctets = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TOCT);
+ p_Statistics->ifOutUcastPkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TUCA);
+ p_Statistics->ifOutMcastPkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TMCA);
+ p_Statistics->ifOutBcastPkts = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TBCA);
+ p_Statistics->ifOutPkts = p_Statistics->ifOutUcastPkts
+ + p_Statistics->ifOutMcastPkts
+ + p_Statistics->ifOutBcastPkts;
+ p_Statistics->ifOutDiscards = 0;
+ p_Statistics->ifOutErrors = fman_memac_get_counter(p_Memac->p_MemMap, E_MEMAC_COUNTER_TERR);
+
+ return E_OK;
+}
+
+/* ......................................................................... */
+
+static t_Error MemacModifyMacAddress (t_Handle h_Memac, t_EnetAddr *p_EnetAddr)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ fman_memac_add_addr_in_paddr(p_Memac->p_MemMap, (uint8_t *)(*p_EnetAddr), 0);
+
+ return E_OK;
+}
+
+/* ......................................................................... */
+
+static t_Error MemacResetCounters (t_Handle h_Memac)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ fman_memac_reset_stat(p_Memac->p_MemMap);
+
+ return E_OK;
+}
+
+/* ......................................................................... */
+
+static t_Error MemacAddExactMatchMacAddress(t_Handle h_Memac, t_EnetAddr *p_EthAddr)
+{
+ t_Memac *p_Memac = (t_Memac *) h_Memac;
+ uint64_t ethAddr;
+ uint8_t paddrNum;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
+
+ if (ethAddr & GROUP_ADDRESS)
+ /* Multicast address has no effect in PADDR */
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Multicast address"));
+
+ /* Make sure no PADDR contains this address */
+ for (paddrNum = 0; paddrNum < MEMAC_NUM_OF_PADDRS; paddrNum++)
+ if (p_Memac->indAddrRegUsed[paddrNum])
+ if (p_Memac->paddr[paddrNum] == ethAddr)
+ RETURN_ERROR(MAJOR, E_ALREADY_EXISTS, NO_MSG);
+
+ /* Find first unused PADDR */
+ for (paddrNum = 0; paddrNum < MEMAC_NUM_OF_PADDRS; paddrNum++)
+ if (!(p_Memac->indAddrRegUsed[paddrNum]))
+ {
+ /* mark this PADDR as used */
+ p_Memac->indAddrRegUsed[paddrNum] = TRUE;
+ /* store address */
+ p_Memac->paddr[paddrNum] = ethAddr;
+
+ /* put in hardware */
+ fman_memac_add_addr_in_paddr(p_Memac->p_MemMap, (uint8_t*)(*p_EthAddr), paddrNum);
+ p_Memac->numOfIndAddrInRegs++;
+
+ return E_OK;
+ }
+
+ /* No free PADDR */
+ RETURN_ERROR(MAJOR, E_FULL, NO_MSG);
+}
+
+/* ......................................................................... */
+
+static t_Error MemacDelExactMatchMacAddress(t_Handle h_Memac, t_EnetAddr *p_EthAddr)
+{
+ t_Memac *p_Memac = (t_Memac *) h_Memac;
+ uint64_t ethAddr;
+ uint8_t paddrNum;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
+
+ /* Find used PADDR containing this address */
+ for (paddrNum = 0; paddrNum < MEMAC_NUM_OF_PADDRS; paddrNum++)
+ {
+ if ((p_Memac->indAddrRegUsed[paddrNum]) &&
+ (p_Memac->paddr[paddrNum] == ethAddr))
+ {
+ /* mark this PADDR as not used */
+ p_Memac->indAddrRegUsed[paddrNum] = FALSE;
+ /* clear in hardware */
+ fman_memac_clear_addr_in_paddr(p_Memac->p_MemMap, paddrNum);
+ p_Memac->numOfIndAddrInRegs--;
+
+ return E_OK;
+ }
+ }
+
+ RETURN_ERROR(MAJOR, E_NOT_FOUND, NO_MSG);
+}
+
+/* ......................................................................... */
+
+static t_Error MemacGetId(t_Handle h_Memac, uint32_t *macId)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ *macId = p_Memac->macId;
+
+ return E_OK;
+}
+
+/* ......................................................................... */
+
+
+static t_Error MemacAddHashMacAddress(t_Handle h_Memac, t_EnetAddr *p_EthAddr)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+ t_EthHashEntry *p_HashEntry;
+ uint32_t hash;
+ uint64_t ethAddr;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
+
+ if (!(ethAddr & GROUP_ADDRESS))
+ /* Unicast addresses not supported in hash */
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Unicast Address"));
+
+ hash = GetMacAddrHashCode(ethAddr) & HASH_CTRL_ADDR_MASK;
+
+ /* Create element to be added to the driver hash table */
+ p_HashEntry = (t_EthHashEntry *)XX_Malloc(sizeof(t_EthHashEntry));
+ p_HashEntry->addr = ethAddr;
+ INIT_LIST(&p_HashEntry->node);
+
+ LIST_AddToTail(&(p_HashEntry->node), &(p_Memac->p_MulticastAddrHash->p_Lsts[hash]));
+ fman_memac_set_hash_table(p_Memac->p_MemMap, (hash | HASH_CTRL_MCAST_EN));
+
+ return E_OK;
+}
+
+/* ......................................................................... */
+
+static t_Error MemacDelHashMacAddress(t_Handle h_Memac, t_EnetAddr *p_EthAddr)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+ t_EthHashEntry *p_HashEntry = NULL;
+ t_List *p_Pos;
+ uint32_t hash;
+ uint64_t ethAddr;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
+
+ hash = GetMacAddrHashCode(ethAddr) & HASH_CTRL_ADDR_MASK;
+
+ LIST_FOR_EACH(p_Pos, &(p_Memac->p_MulticastAddrHash->p_Lsts[hash]))
+ {
+ p_HashEntry = ETH_HASH_ENTRY_OBJ(p_Pos);
+ if (p_HashEntry->addr == ethAddr)
+ {
+ LIST_DelAndInit(&p_HashEntry->node);
+ XX_Free(p_HashEntry);
+ break;
+ }
+ }
+ if (LIST_IsEmpty(&p_Memac->p_MulticastAddrHash->p_Lsts[hash]))
+ fman_memac_set_hash_table(p_Memac->p_MemMap, (hash & ~HASH_CTRL_MCAST_EN));
+
+ return E_OK;
+}
+
+
+/* ......................................................................... */
+
+static t_Error MemacSetException(t_Handle h_Memac, e_FmMacExceptions exception, bool enable)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+ uint32_t bitMask = 0;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ GET_EXCEPTION_FLAG(bitMask, exception);
+ if (bitMask)
+ {
+ if (enable)
+ p_Memac->exceptions |= bitMask;
+ else
+ p_Memac->exceptions &= ~bitMask;
+ }
+ else
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
+
+ fman_memac_set_exception(p_Memac->p_MemMap, bitMask, enable);
+
+ return E_OK;
+}
+
+/* ......................................................................... */
+
+static uint16_t MemacGetMaxFrameLength(t_Handle h_Memac)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_VALUE(p_Memac, E_INVALID_HANDLE, 0);
+ SANITY_CHECK_RETURN_VALUE(!p_Memac->p_MemacDriverParam, E_INVALID_STATE, 0);
+
+ return fman_memac_get_max_frame_len(p_Memac->p_MemMap);
+}
+
+static t_Error MemacInitInternalPhy(t_Handle h_Memac)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+ uint8_t i, phyAddr;
+
+ if (ENET_INTERFACE_FROM_MODE(p_Memac->enetMode) == e_ENET_IF_SGMII)
+ {
+ /* Configure internal SGMII PHY */
+ if (p_Memac->enetMode & ENET_IF_SGMII_BASEX)
+ SetupSgmiiInternalPhyBaseX(p_Memac, PHY_MDIO_ADDR);
+ else
+ SetupSgmiiInternalPhy(p_Memac, PHY_MDIO_ADDR);
+ }
+ else if (ENET_INTERFACE_FROM_MODE(p_Memac->enetMode) == e_ENET_IF_QSGMII)
+ {
+ /* Configure 4 internal SGMII PHYs */
+ for (i = 0; i < 4; i++)
+ {
+ /* QSGMII PHY address occupies 3 upper bits of 5-bit
+ phyAddress; the lower 2 bits are used to extend
+ register address space and access each one of 4
+ ports inside QSGMII. */
+ phyAddr = (uint8_t)((PHY_MDIO_ADDR << 2) | i);
+ if (p_Memac->enetMode & ENET_IF_SGMII_BASEX)
+ SetupSgmiiInternalPhyBaseX(p_Memac, phyAddr);
+ else
+ SetupSgmiiInternalPhy(p_Memac, phyAddr);
+ }
+ }
+ return E_OK;
+}
+
+/*****************************************************************************/
+/* mEMAC Init & Free API */
+/*****************************************************************************/
+
+/* ......................................................................... */
+void *g_MemacRegs;
+static t_Error MemacInit(t_Handle h_Memac)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+ struct memac_cfg *p_MemacDriverParam;
+ enum enet_interface enet_interface;
+ enum enet_speed enet_speed;
+ t_EnetAddr ethAddr;
+ e_FmMacType portType;
+ t_Error err;
+ bool slow_10g_if = FALSE;
+ if (p_Memac->macId == 3) /* This is a quick WA */
+ g_MemacRegs = p_Memac->p_MemMap;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_Memac->fmMacControllerDriver.h_Fm, E_INVALID_HANDLE);
+
+ FM_GetRevision(p_Memac->fmMacControllerDriver.h_Fm, &p_Memac->fmMacControllerDriver.fmRevInfo);
+ if (p_Memac->fmMacControllerDriver.fmRevInfo.majorRev == 6 &&
+ p_Memac->fmMacControllerDriver.fmRevInfo.minorRev == 4)
+ slow_10g_if = TRUE;
+
+ CHECK_INIT_PARAMETERS(p_Memac, CheckInitParameters);
+
+ p_MemacDriverParam = p_Memac->p_MemacDriverParam;
+
+ portType =
+ ((ENET_SPEED_FROM_MODE(p_Memac->enetMode) < e_ENET_SPEED_10000) ? e_FM_MAC_1G : e_FM_MAC_10G);
+
+ /* First, reset the MAC if desired. */
+ if (p_MemacDriverParam->reset_on_init)
+ fman_memac_reset(p_Memac->p_MemMap);
+
+ /* MAC Address */
+ MAKE_ENET_ADDR_FROM_UINT64(p_Memac->addr, ethAddr);
+ fman_memac_add_addr_in_paddr(p_Memac->p_MemMap, (uint8_t*)ethAddr, 0);
+
+ enet_interface = (enum enet_interface) ENET_INTERFACE_FROM_MODE(p_Memac->enetMode);
+ enet_speed = (enum enet_speed) ENET_SPEED_FROM_MODE(p_Memac->enetMode);
+
+ fman_memac_init(p_Memac->p_MemMap,
+ p_Memac->p_MemacDriverParam,
+ enet_interface,
+ enet_speed,
+ slow_10g_if,
+ p_Memac->exceptions);
+
+#ifdef FM_RX_FIFO_CORRUPT_ERRATA_10GMAC_A006320
+ {
+ uint32_t tmpReg = 0;
+
+ FM_GetRevision(p_Memac->fmMacControllerDriver.h_Fm, &p_Memac->fmMacControllerDriver.fmRevInfo);
+ /* check the FMAN version - the bug exists only in rev1 */
+ if ((p_Memac->fmMacControllerDriver.fmRevInfo.majorRev == 6) &&
+ (p_Memac->fmMacControllerDriver.fmRevInfo.minorRev == 0))
+ {
+ /* MAC strips CRC from received frames - this workaround should
+ decrease the likelihood of bug appearance
+ */
+ tmpReg = GET_UINT32(p_Memac->p_MemMap->command_config);
+ tmpReg &= ~CMD_CFG_CRC_FWD;
+ WRITE_UINT32(p_Memac->p_MemMap->command_config, tmpReg);
+ /* DBG(WARNING, ("mEMAC strips CRC from received frames as part of A006320 errata workaround"));*/
+ }
+ }
+#endif /* FM_RX_FIFO_CORRUPT_ERRATA_10GMAC_A006320 */
+
+ MemacInitInternalPhy(h_Memac);
+
+ /* Max Frame Length */
+ err = FmSetMacMaxFrame(p_Memac->fmMacControllerDriver.h_Fm,
+ portType,
+ p_Memac->fmMacControllerDriver.macId,
+ p_MemacDriverParam->max_frame_length);
+ if (err)
+ RETURN_ERROR(MAJOR, err, ("settings Mac max frame length is FAILED"));
+
+ p_Memac->p_MulticastAddrHash = AllocHashTable(HASH_TABLE_SIZE);
+ if (!p_Memac->p_MulticastAddrHash)
+ {
+ FreeInitResources(p_Memac);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("allocation hash table is FAILED"));
+ }
+
+ p_Memac->p_UnicastAddrHash = AllocHashTable(HASH_TABLE_SIZE);
+ if (!p_Memac->p_UnicastAddrHash)
+ {
+ FreeInitResources(p_Memac);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("allocation hash table is FAILED"));
+ }
+
+ FmRegisterIntr(p_Memac->fmMacControllerDriver.h_Fm,
+ (portType == e_FM_MAC_10G) ? e_FM_MOD_10G_MAC : e_FM_MOD_1G_MAC,
+ p_Memac->macId,
+ e_FM_INTR_TYPE_ERR,
+ MemacErrException,
+ p_Memac);
+
+ FmRegisterIntr(p_Memac->fmMacControllerDriver.h_Fm,
+ (portType == e_FM_MAC_10G) ? e_FM_MOD_10G_MAC : e_FM_MOD_1G_MAC,
+ p_Memac->macId,
+ e_FM_INTR_TYPE_NORMAL,
+ MemacException,
+ p_Memac);
+
+ XX_Free(p_MemacDriverParam);
+ p_Memac->p_MemacDriverParam = NULL;
+
+ return E_OK;
+}
+
+/* ......................................................................... */
+
+static t_Error MemacFree(t_Handle h_Memac)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+
+ if (p_Memac->p_MemacDriverParam)
+ {
+ /* Called after config */
+ XX_Free(p_Memac->p_MemacDriverParam);
+ p_Memac->p_MemacDriverParam = NULL;
+ }
+ else
+ /* Called after init */
+ FreeInitResources(p_Memac);
+
+ XX_Free(p_Memac);
+
+ return E_OK;
+}
+
+/* ......................................................................... */
+
+static void InitFmMacControllerDriver(t_FmMacControllerDriver *p_FmMacControllerDriver)
+{
+ p_FmMacControllerDriver->f_FM_MAC_Init = MemacInit;
+ p_FmMacControllerDriver->f_FM_MAC_Free = MemacFree;
+
+ p_FmMacControllerDriver->f_FM_MAC_SetStatistics = NULL;
+ p_FmMacControllerDriver->f_FM_MAC_ConfigLoopback = MemacConfigLoopback;
+ p_FmMacControllerDriver->f_FM_MAC_ConfigMaxFrameLength = MemacConfigMaxFrameLength;
+
+ p_FmMacControllerDriver->f_FM_MAC_ConfigWan = MemacConfigWan;
+
+ p_FmMacControllerDriver->f_FM_MAC_ConfigPadAndCrc = MemacConfigPad;
+ p_FmMacControllerDriver->f_FM_MAC_ConfigHalfDuplex = NULL; /* half-duplex is detected automatically */
+ p_FmMacControllerDriver->f_FM_MAC_ConfigLengthCheck = MemacConfigLengthCheck;
+
+ p_FmMacControllerDriver->f_FM_MAC_ConfigException = MemacConfigException;
+ p_FmMacControllerDriver->f_FM_MAC_ConfigResetOnInit = MemacConfigResetOnInit;
+
+ p_FmMacControllerDriver->f_FM_MAC_SetException = MemacSetException;
+
+ p_FmMacControllerDriver->f_FM_MAC_Enable1588TimeStamp = MemacEnable1588TimeStamp; /* always enabled */
+ p_FmMacControllerDriver->f_FM_MAC_Disable1588TimeStamp = NULL;
+
+ p_FmMacControllerDriver->f_FM_MAC_SetPromiscuous = MemacSetPromiscuous;
+ p_FmMacControllerDriver->f_FM_MAC_AdjustLink = MemacAdjustLink;
+ p_FmMacControllerDriver->f_FM_MAC_RestartAutoneg = NULL;
+
+ p_FmMacControllerDriver->f_FM_MAC_Enable = MemacEnable;
+ p_FmMacControllerDriver->f_FM_MAC_Disable = MemacDisable;
+ p_FmMacControllerDriver->f_FM_MAC_Resume = MemacInitInternalPhy;
+
+ p_FmMacControllerDriver->f_FM_MAC_SetTxAutoPauseFrames = MemacSetTxAutoPauseFrames;
+ p_FmMacControllerDriver->f_FM_MAC_SetTxPauseFrames = MemacSetTxPauseFrames;
+ p_FmMacControllerDriver->f_FM_MAC_SetRxIgnorePauseFrames = MemacSetRxIgnorePauseFrames;
+
+ p_FmMacControllerDriver->f_FM_MAC_SetWakeOnLan = MemacSetWakeOnLan;
+
+ p_FmMacControllerDriver->f_FM_MAC_ResetCounters = MemacResetCounters;
+ p_FmMacControllerDriver->f_FM_MAC_GetStatistics = MemacGetStatistics;
+
+ p_FmMacControllerDriver->f_FM_MAC_ModifyMacAddr = MemacModifyMacAddress;
+ p_FmMacControllerDriver->f_FM_MAC_AddHashMacAddr = MemacAddHashMacAddress;
+ p_FmMacControllerDriver->f_FM_MAC_RemoveHashMacAddr = MemacDelHashMacAddress;
+ p_FmMacControllerDriver->f_FM_MAC_AddExactMatchMacAddr = MemacAddExactMatchMacAddress;
+ p_FmMacControllerDriver->f_FM_MAC_RemovelExactMatchMacAddr = MemacDelExactMatchMacAddress;
+ p_FmMacControllerDriver->f_FM_MAC_GetId = MemacGetId;
+ p_FmMacControllerDriver->f_FM_MAC_GetVersion = NULL;
+ p_FmMacControllerDriver->f_FM_MAC_GetMaxFrameLength = MemacGetMaxFrameLength;
+
+ p_FmMacControllerDriver->f_FM_MAC_MII_WritePhyReg = MEMAC_MII_WritePhyReg;
+ p_FmMacControllerDriver->f_FM_MAC_MII_ReadPhyReg = MEMAC_MII_ReadPhyReg;
+}
+
+
+/*****************************************************************************/
+/* mEMAC Config Main Entry */
+/*****************************************************************************/
+
+/* ......................................................................... */
+
+t_Handle MEMAC_Config(t_FmMacParams *p_FmMacParam)
+{
+ t_Memac *p_Memac;
+ struct memac_cfg *p_MemacDriverParam;
+ uintptr_t baseAddr;
+
+ SANITY_CHECK_RETURN_VALUE(p_FmMacParam, E_NULL_POINTER, NULL);
+
+ baseAddr = p_FmMacParam->baseAddr;
+ /* Allocate memory for the mEMAC data structure */
+ p_Memac = (t_Memac *)XX_Malloc(sizeof(t_Memac));
+ if (!p_Memac)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("mEMAC driver structure"));
+ return NULL;
+ }
+ memset(p_Memac, 0, sizeof(t_Memac));
+ InitFmMacControllerDriver(&p_Memac->fmMacControllerDriver);
+
+ /* Allocate memory for the mEMAC driver parameters data structure */
+ p_MemacDriverParam = (struct memac_cfg *)XX_Malloc(sizeof(struct memac_cfg));
+ if (!p_MemacDriverParam)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("mEMAC driver parameters"));
+ XX_Free(p_Memac);
+ return NULL;
+ }
+ memset(p_MemacDriverParam, 0, sizeof(struct memac_cfg));
+
+ /* Plant parameter structure pointer */
+ p_Memac->p_MemacDriverParam = p_MemacDriverParam;
+
+ fman_memac_defconfig(p_MemacDriverParam);
+
+ p_Memac->addr = ENET_ADDR_TO_UINT64(p_FmMacParam->addr);
+
+ p_Memac->p_MemMap = (struct memac_regs *)UINT_TO_PTR(baseAddr);
+ p_Memac->p_MiiMemMap = (struct memac_mii_access_mem_map*)UINT_TO_PTR(baseAddr + MEMAC_TO_MII_OFFSET);
+
+ p_Memac->enetMode = p_FmMacParam->enetMode;
+ p_Memac->macId = p_FmMacParam->macId;
+ p_Memac->exceptions = MEMAC_default_exceptions;
+ p_Memac->f_Exception = p_FmMacParam->f_Exception;
+ p_Memac->f_Event = p_FmMacParam->f_Event;
+ p_Memac->h_App = p_FmMacParam->h_App;
+
+ return p_Memac;
+}
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/memac.h b/sys/contrib/ncsw/Peripherals/FM/MAC/memac.h
new file mode 100644
index 000000000000..2fd89dae20d6
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/memac.h
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/******************************************************************************
+ @File memac.h
+
+ @Description FM Multirate Ethernet MAC (mEMAC)
+*//***************************************************************************/
+#ifndef __MEMAC_H
+#define __MEMAC_H
+
+#include "std_ext.h"
+#include "error_ext.h"
+#include "list_ext.h"
+
+#include "fsl_fman_memac_mii_acc.h"
+#include "fm_mac.h"
+#include "fsl_fman_memac.h"
+
+
+#define MEMAC_default_exceptions \
+ ((uint32_t)(MEMAC_IMASK_TSECC_ER | MEMAC_IMASK_TECC_ER | MEMAC_IMASK_RECC_ER | MEMAC_IMASK_MGI))
+
+#define GET_EXCEPTION_FLAG(bitMask, exception) switch (exception){ \
+ case e_FM_MAC_EX_10G_1TX_ECC_ER: \
+ bitMask = MEMAC_IMASK_TECC_ER; break; \
+ case e_FM_MAC_EX_10G_RX_ECC_ER: \
+ bitMask = MEMAC_IMASK_RECC_ER; break; \
+ case e_FM_MAC_EX_TS_FIFO_ECC_ERR: \
+ bitMask = MEMAC_IMASK_TSECC_ER; break; \
+ case e_FM_MAC_EX_MAGIC_PACKET_INDICATION: \
+ bitMask = MEMAC_IMASK_MGI; break; \
+ default: bitMask = 0;break;}
+
+
+typedef struct
+{
+ t_FmMacControllerDriver fmMacControllerDriver; /**< Upper Mac control block */
+ t_Handle h_App; /**< Handle to the upper layer application */
+ struct memac_regs *p_MemMap; /**< Pointer to MAC memory mapped registers */
+ struct memac_mii_access_mem_map *p_MiiMemMap; /**< Pointer to MII memory mapped registers */
+ uint64_t addr; /**< MAC address of device */
+ e_EnetMode enetMode; /**< Ethernet physical interface */
+ t_FmMacExceptionCallback *f_Exception;
+ int mdioIrq;
+ t_FmMacExceptionCallback *f_Event;
+ bool indAddrRegUsed[MEMAC_NUM_OF_PADDRS]; /**< Whether a particular individual address recognition register is being used */
+ uint64_t paddr[MEMAC_NUM_OF_PADDRS]; /**< MAC address for particular individual address recognition register */
+ uint8_t numOfIndAddrInRegs; /**< Number of individual addresses in registers for this station. */
+ t_EthHash *p_MulticastAddrHash; /**< Pointer to driver's global address hash table */
+ t_EthHash *p_UnicastAddrHash; /**< Pointer to driver's individual address hash table */
+ bool debugMode;
+ uint8_t macId;
+ uint32_t exceptions;
+ struct memac_cfg *p_MemacDriverParam;
+} t_Memac;
+
+
+/* Internal PHY access */
+#define PHY_MDIO_ADDR 0
+
+/* Internal PHY Registers - SGMII */
+#define PHY_SGMII_CR_PHY_RESET 0x8000
+#define PHY_SGMII_CR_RESET_AN 0x0200
+#define PHY_SGMII_CR_DEF_VAL 0x1140
+#define PHY_SGMII_DEV_ABILITY_SGMII 0x4001
+#define PHY_SGMII_DEV_ABILITY_1000X 0x01A0
+#define PHY_SGMII_IF_SPEED_GIGABIT 0x0008
+#define PHY_SGMII_IF_MODE_AN 0x0002
+#define PHY_SGMII_IF_MODE_SGMII 0x0001
+#define PHY_SGMII_IF_MODE_1000X 0x0000
+
+
+#define MEMAC_TO_MII_OFFSET 0x030 /* Offset from the MEM map to the MDIO mem map */
+
+t_Error MEMAC_MII_WritePhyReg(t_Handle h_Memac, uint8_t phyAddr, uint8_t reg, uint16_t data);
+t_Error MEMAC_MII_ReadPhyReg(t_Handle h_Memac, uint8_t phyAddr, uint8_t reg, uint16_t *p_Data);
+
+
+#endif /* __MEMAC_H */
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/memac_mii_acc.c b/sys/contrib/ncsw/Peripherals/FM/MAC/memac_mii_acc.c
new file mode 100644
index 000000000000..56eaffbcf66d
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/memac_mii_acc.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "error_ext.h"
+#include "std_ext.h"
+#include "fm_mac.h"
+#include "memac.h"
+#include "xx_ext.h"
+
+#include "fm_common.h"
+#include "memac_mii_acc.h"
+
+
+/*****************************************************************************/
+t_Error MEMAC_MII_WritePhyReg(t_Handle h_Memac,
+ uint8_t phyAddr,
+ uint8_t reg,
+ uint16_t data)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Memac->p_MiiMemMap, E_INVALID_HANDLE);
+
+ return (t_Error)fman_memac_mii_write_phy_reg(p_Memac->p_MiiMemMap,
+ phyAddr,
+ reg,
+ data,
+ (enum enet_speed)ENET_SPEED_FROM_MODE(p_Memac->enetMode));
+}
+
+/*****************************************************************************/
+t_Error MEMAC_MII_ReadPhyReg(t_Handle h_Memac,
+ uint8_t phyAddr,
+ uint8_t reg,
+ uint16_t *p_Data)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Memac->p_MiiMemMap, E_INVALID_HANDLE);
+
+ return fman_memac_mii_read_phy_reg(p_Memac->p_MiiMemMap,
+ phyAddr,
+ reg,
+ p_Data,
+ (enum enet_speed)ENET_SPEED_FROM_MODE(p_Memac->enetMode));
+}
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/memac_mii_acc.h b/sys/contrib/ncsw/Peripherals/FM/MAC/memac_mii_acc.h
new file mode 100644
index 000000000000..325ec082ffde
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/memac_mii_acc.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef __MEMAC_MII_ACC_H
+#define __MEMAC_MII_ACC_H
+
+#include "std_ext.h"
+
+
+/* MII Management Registers */
+#define MDIO_CFG_CLK_DIV_MASK 0x0080ff80
+#define MDIO_CFG_CLK_DIV_SHIFT 7
+#define MDIO_CFG_HOLD_MASK 0x0000001c
+#define MDIO_CFG_ENC45 0x00000040
+#define MDIO_CFG_READ_ERR 0x00000002
+#define MDIO_CFG_BSY 0x00000001
+
+#define MDIO_CTL_PHY_ADDR_SHIFT 5
+#define MDIO_CTL_READ 0x00008000
+
+#define MDIO_DATA_BSY 0x80000000
+
+#if defined(__MWERKS__) && !defined(__GNUC__)
+#pragma pack(push,1)
+#endif /* defined(__MWERKS__) && ... */
+
+/*----------------------------------------------------*/
+/* MII Configuration Control Memory Map Registers */
+/*----------------------------------------------------*/
+typedef struct t_MemacMiiAccessMemMap
+{
+ volatile uint32_t mdio_cfg; /* 0x030 */
+ volatile uint32_t mdio_ctrl; /* 0x034 */
+ volatile uint32_t mdio_data; /* 0x038 */
+ volatile uint32_t mdio_addr; /* 0x03c */
+} t_MemacMiiAccessMemMap ;
+
+#if defined(__MWERKS__) && !defined(__GNUC__)
+#pragma pack(pop)
+#endif /* defined(__MWERKS__) && ... */
+
+
+#endif /* __MEMAC_MII_ACC_H */
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/tgec.c b/sys/contrib/ncsw/Peripherals/FM/MAC/tgec.c
index cbe35351252a..452913d154ae 100644
--- a/sys/contrib/ncsw/Peripherals/FM/MAC/tgec.c
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/tgec.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File tgec.c
@@ -41,10 +42,11 @@
#include "error_ext.h"
#include "xx_ext.h"
#include "endian_ext.h"
-#include "crc_mac_addr_ext.h"
#include "debug_ext.h"
+#include "crc_mac_addr_ext.h"
#include "fm_common.h"
+#include "fsl_fman_tgec.h"
#include "tgec.h"
@@ -54,131 +56,116 @@
static t_Error CheckInitParameters(t_Tgec *p_Tgec)
{
- if(ENET_SPEED_FROM_MODE(p_Tgec->enetMode) < e_ENET_SPEED_10000)
+ if (ENET_SPEED_FROM_MODE(p_Tgec->enetMode) < e_ENET_SPEED_10000)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Ethernet 10G MAC driver only support 10G speed"));
#if (FM_MAX_NUM_OF_10G_MACS > 0)
- if(p_Tgec->macId >= FM_MAX_NUM_OF_10G_MACS)
+ if (p_Tgec->macId >= FM_MAX_NUM_OF_10G_MACS)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("macId of 10G can not be greater than 0"));
-#endif
- if(p_Tgec->addr == 0)
+#endif /* (FM_MAX_NUM_OF_10G_MACS > 0) */
+
+ if (p_Tgec->addr == 0)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Ethernet 10G MAC Must have a valid MAC Address"));
- if(!p_Tgec->f_Exception)
+ if (!p_Tgec->f_Exception)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("uninitialized f_Exception"));
- if(!p_Tgec->f_Event)
+ if (!p_Tgec->f_Event)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("uninitialized f_Event"));
+#ifdef FM_LEN_CHECK_ERRATA_FMAN_SW002
+ if (!p_Tgec->p_TgecDriverParam->no_length_check_enable)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("LengthCheck!"));
+#endif /* FM_LEN_CHECK_ERRATA_FMAN_SW002 */
return E_OK;
}
-/* .............................................................................. */
+/* ......................................................................... */
-static void SetDefaultParam(t_TgecDriverParam *p_TgecDriverParam)
+static uint32_t GetMacAddrHashCode(uint64_t ethAddr)
{
- p_TgecDriverParam->wanModeEnable = DEFAULT_wanModeEnable;
- p_TgecDriverParam->promiscuousModeEnable = DEFAULT_promiscuousModeEnable;
- p_TgecDriverParam->pauseForwardEnable = DEFAULT_pauseForwardEnable;
- p_TgecDriverParam->pauseIgnore = DEFAULT_pauseIgnore;
- p_TgecDriverParam->txAddrInsEnable = DEFAULT_txAddrInsEnable;
-
- p_TgecDriverParam->loopbackEnable = DEFAULT_loopbackEnable;
- p_TgecDriverParam->cmdFrameEnable = DEFAULT_cmdFrameEnable;
- p_TgecDriverParam->rxErrorDiscard = DEFAULT_rxErrorDiscard;
- p_TgecDriverParam->phyTxenaOn = DEFAULT_phyTxenaOn;
- p_TgecDriverParam->sendIdleEnable = DEFAULT_sendIdleEnable;
- p_TgecDriverParam->noLengthCheckEnable = DEFAULT_noLengthCheckEnable;
- p_TgecDriverParam->lgthCheckNostdr = DEFAULT_lgthCheckNostdr;
- p_TgecDriverParam->timeStampEnable = DEFAULT_timeStampEnable;
- p_TgecDriverParam->rxSfdAny = DEFAULT_rxSfdAny;
- p_TgecDriverParam->rxPblFwd = DEFAULT_rxPblFwd;
- p_TgecDriverParam->txPblFwd = DEFAULT_txPblFwd;
-
- p_TgecDriverParam->txIpgLength = DEFAULT_txIpgLength;
- p_TgecDriverParam->maxFrameLength = DEFAULT_maxFrameLength;
-
- p_TgecDriverParam->debugMode = DEFAULT_debugMode;
-
- p_TgecDriverParam->pauseTime = DEFAULT_pauseTime;
+ uint32_t crc;
-#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
- p_TgecDriverParam->skipFman11Workaround = DEFAULT_skipFman11Workaround;
-#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
+ /* CRC calculation */
+ GET_MAC_ADDR_CRC(ethAddr, crc);
+
+ crc = GetMirror32(crc);
+
+ return crc;
}
-/* ........................................................................... */
+/* ......................................................................... */
static void TgecErrException(t_Handle h_Tgec)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
uint32_t event;
- t_TgecMemMap *p_TgecMemMap = p_Tgec->p_MemMap;
+ struct tgec_regs *p_TgecMemMap = p_Tgec->p_MemMap;
- event = GET_UINT32(p_TgecMemMap->ievent);
/* do not handle MDIO events */
- event &= ~(IMASK_MDIO_SCAN_EVENTMDIO | IMASK_MDIO_CMD_CMPL);
-
- event &= GET_UINT32(p_TgecMemMap->imask);
+ event = fman_tgec_get_event(p_TgecMemMap, ~(TGEC_IMASK_MDIO_SCAN_EVENT | TGEC_IMASK_MDIO_CMD_CMPL));
+ event &= fman_tgec_get_interrupt_mask(p_TgecMemMap);
- WRITE_UINT32(p_TgecMemMap->ievent, event);
+ fman_tgec_ack_event(p_TgecMemMap, event);
- if (event & IMASK_REM_FAULT)
+ if (event & TGEC_IMASK_REM_FAULT)
p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_REM_FAULT);
- if (event & IMASK_LOC_FAULT)
+ if (event & TGEC_IMASK_LOC_FAULT)
p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_LOC_FAULT);
- if (event & IMASK_1TX_ECC_ER)
+ if (event & TGEC_IMASK_TX_ECC_ER)
p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_1TX_ECC_ER);
- if (event & IMASK_TX_FIFO_UNFL)
+ if (event & TGEC_IMASK_TX_FIFO_UNFL)
p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_TX_FIFO_UNFL);
- if (event & IMASK_TX_FIFO_OVFL)
+ if (event & TGEC_IMASK_TX_FIFO_OVFL)
p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_TX_FIFO_OVFL);
- if (event & IMASK_TX_ER)
+ if (event & TGEC_IMASK_TX_ER)
p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_TX_ER);
- if (event & IMASK_RX_FIFO_OVFL)
+ if (event & TGEC_IMASK_RX_FIFO_OVFL)
p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_RX_FIFO_OVFL);
- if (event & IMASK_RX_ECC_ER)
+ if (event & TGEC_IMASK_RX_ECC_ER)
p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_RX_ECC_ER);
- if (event & IMASK_RX_JAB_FRM)
+ if (event & TGEC_IMASK_RX_JAB_FRM)
p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_RX_JAB_FRM);
- if (event & IMASK_RX_OVRSZ_FRM)
+ if (event & TGEC_IMASK_RX_OVRSZ_FRM)
p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_RX_OVRSZ_FRM);
- if (event & IMASK_RX_RUNT_FRM)
+ if (event & TGEC_IMASK_RX_RUNT_FRM)
p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_RX_RUNT_FRM);
- if (event & IMASK_RX_FRAG_FRM)
+ if (event & TGEC_IMASK_RX_FRAG_FRM)
p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_RX_FRAG_FRM);
- if (event & IMASK_RX_LEN_ER)
+ if (event & TGEC_IMASK_RX_LEN_ER)
p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_RX_LEN_ER);
- if (event & IMASK_RX_CRC_ER)
+ if (event & TGEC_IMASK_RX_CRC_ER)
p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_RX_CRC_ER);
- if (event & IMASK_RX_ALIGN_ER)
+ if (event & TGEC_IMASK_RX_ALIGN_ER)
p_Tgec->f_Exception(p_Tgec->h_App, e_FM_MAC_EX_10G_RX_ALIGN_ER);
}
+/* ......................................................................... */
+
static void TgecException(t_Handle h_Tgec)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
- uint32_t event;
- t_TgecMemMap *p_TgecMemMap = p_Tgec->p_MemMap;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
+ uint32_t event;
+ struct tgec_regs *p_TgecMemMap = p_Tgec->p_MemMap;
- event = GET_UINT32(p_TgecMemMap->ievent);
/* handle only MDIO events */
- event &= (IMASK_MDIO_SCAN_EVENTMDIO | IMASK_MDIO_CMD_CMPL);
- event &= GET_UINT32(p_TgecMemMap->imask);
+ event = fman_tgec_get_event(p_TgecMemMap, (TGEC_IMASK_MDIO_SCAN_EVENT | TGEC_IMASK_MDIO_CMD_CMPL));
+ event &= fman_tgec_get_interrupt_mask(p_TgecMemMap);
- WRITE_UINT32(p_TgecMemMap->ievent, event);
+ fman_tgec_ack_event(p_TgecMemMap, event);
- if(event & IMASK_MDIO_SCAN_EVENTMDIO)
+ if (event & TGEC_IMASK_MDIO_SCAN_EVENT)
p_Tgec->f_Event(p_Tgec->h_App, e_FM_MAC_EX_10G_MDIO_SCAN_EVENTMDIO);
- if(event & IMASK_MDIO_CMD_CMPL)
+ if (event & TGEC_IMASK_MDIO_CMD_CMPL)
p_Tgec->f_Event(p_Tgec->h_App, e_FM_MAC_EX_10G_MDIO_CMD_CMPL);
}
+/* ......................................................................... */
+
static void FreeInitResources(t_Tgec *p_Tgec)
{
- if ((p_Tgec->mdioIrq != 0) && (p_Tgec->mdioIrq != NO_IRQ))
+ if (p_Tgec->mdioIrq != NO_IRQ)
{
XX_DisableIntr(p_Tgec->mdioIrq);
XX_FreeIntr(p_Tgec->mdioIrq);
}
- else if (p_Tgec->mdioIrq == 0)
- REPORT_ERROR(MINOR, E_NOT_SUPPORTED, (NO_MSG));
+
FmUnregisterIntr(p_Tgec->fmMacControllerDriver.h_Fm, e_FM_MOD_10G_MAC, p_Tgec->macId, e_FM_INTR_TYPE_ERR);
/* release the driver's group hash table */
@@ -190,133 +177,49 @@ static void FreeInitResources(t_Tgec *p_Tgec)
p_Tgec->p_UnicastAddrHash = NULL;
}
-/* .............................................................................. */
-
-static void HardwareClearAddrInPaddr(t_Tgec *p_Tgec, uint8_t paddrNum)
-{
- if (paddrNum != 0)
- return; /* At this time MAC has only one address */
-
- WRITE_UINT32(p_Tgec->p_MemMap->mac_addr_2, 0x0);
- WRITE_UINT32(p_Tgec->p_MemMap->mac_addr_3, 0x0);
-}
-
-/* ........................................................................... */
-
-static void HardwareAddAddrInPaddr(t_Tgec *p_Tgec, uint64_t *p_Addr, uint8_t paddrNum)
-{
- uint32_t tmpReg32 = 0;
- uint64_t addr = *p_Addr;
- t_TgecMemMap *p_TgecMemMap = p_Tgec->p_MemMap;
-
- if (paddrNum != 0)
- return; /* At this time MAC has only one address */
-
- tmpReg32 = (uint32_t)(addr>>16);
- SwapUint32P(&tmpReg32);
- WRITE_UINT32(p_TgecMemMap->mac_addr_2, tmpReg32);
-
- tmpReg32 = (uint32_t)(addr);
- SwapUint32P(&tmpReg32);
- tmpReg32 >>= 16;
- WRITE_UINT32(p_TgecMemMap->mac_addr_3, tmpReg32);
-}
/*****************************************************************************/
/* 10G MAC API routines */
/*****************************************************************************/
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecEnable(t_Handle h_Tgec, e_CommMode mode)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
- t_TgecMemMap *p_MemMap ;
- uint32_t tmpReg32 = 0;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Tgec->p_MemMap, E_INVALID_HANDLE);
-
- p_MemMap= (t_TgecMemMap*)(p_Tgec->p_MemMap);
-
- tmpReg32 = GET_UINT32(p_MemMap->cmd_conf_ctrl);
-
- switch (mode)
- {
- case e_COMM_MODE_NONE:
- tmpReg32 &= ~(CMD_CFG_TX_EN | CMD_CFG_RX_EN);
- break;
- case e_COMM_MODE_RX :
- tmpReg32 |= CMD_CFG_RX_EN ;
- break;
- case e_COMM_MODE_TX :
- tmpReg32 |= CMD_CFG_TX_EN ;
- break;
- case e_COMM_MODE_RX_AND_TX:
- tmpReg32 |= (CMD_CFG_TX_EN | CMD_CFG_RX_EN);
- break;
- }
+ SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- WRITE_UINT32(p_MemMap->cmd_conf_ctrl, tmpReg32);
+ fman_tgec_enable(p_Tgec->p_MemMap, (mode & e_COMM_MODE_RX), (mode & e_COMM_MODE_TX));
return E_OK;
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecDisable (t_Handle h_Tgec, e_CommMode mode)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
- t_TgecMemMap *p_MemMap ;
- uint32_t tmpReg32 = 0;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Tgec->p_MemMap, E_INVALID_HANDLE);
-
- p_MemMap= (t_TgecMemMap*)(p_Tgec->p_MemMap);
+ SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- tmpReg32 = GET_UINT32(p_MemMap->cmd_conf_ctrl);
- switch (mode)
- {
- case e_COMM_MODE_RX:
- tmpReg32 &= ~CMD_CFG_RX_EN;
- break;
- case e_COMM_MODE_TX:
- tmpReg32 &= ~CMD_CFG_TX_EN;
- break;
- case e_COMM_MODE_RX_AND_TX:
- tmpReg32 &= ~(CMD_CFG_TX_EN | CMD_CFG_RX_EN);
- break;
- default:
- RETURN_ERROR(MINOR, E_INVALID_SELECTION, NO_MSG);
- }
- WRITE_UINT32(p_MemMap->cmd_conf_ctrl, tmpReg32);
+ fman_tgec_disable(p_Tgec->p_MemMap, (mode & e_COMM_MODE_RX), (mode & e_COMM_MODE_TX));
return E_OK;
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecSetPromiscuous(t_Handle h_Tgec, bool newVal)
{
t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
- t_TgecMemMap *p_TgecMemMap;
- uint32_t tmpReg32;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_NULL_POINTER);
- SANITY_CHECK_RETURN_ERROR(p_Tgec->p_MemMap, E_NULL_POINTER);
-
- p_TgecMemMap = p_Tgec->p_MemMap;
-
- tmpReg32 = GET_UINT32(p_TgecMemMap->cmd_conf_ctrl);
-
- if (newVal)
- tmpReg32 |= CMD_CFG_PROMIS_EN;
- else
- tmpReg32 &= ~CMD_CFG_PROMIS_EN;
+ SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- WRITE_UINT32(p_TgecMemMap->cmd_conf_ctrl, tmpReg32);
+ fman_tgec_set_promiscuous(p_Tgec->p_MemMap, newVal);
return E_OK;
}
@@ -326,80 +229,65 @@ static t_Error TgecSetPromiscuous(t_Handle h_Tgec, bool newVal)
/* Tgec Configs modification functions */
/*****************************************************************************/
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecConfigLoopback(t_Handle h_Tgec, bool newVal)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
-#ifdef FM_NO_TGEC_LOOPBACK
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_Tgec->fmMacControllerDriver.h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("no loopback in this chip rev!"));
- }
-#endif /* FM_NO_TGEC_LOOPBACK */
-
- p_Tgec->p_TgecDriverParam->loopbackEnable = newVal;
+ p_Tgec->p_TgecDriverParam->loopback_enable = newVal;
return E_OK;
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecConfigWan(t_Handle h_Tgec, bool newVal)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- p_Tgec->p_TgecDriverParam->wanModeEnable = newVal;
+ p_Tgec->p_TgecDriverParam->wan_mode_enable = newVal;
return E_OK;
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecConfigMaxFrameLength(t_Handle h_Tgec, uint16_t newVal)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- p_Tgec->p_TgecDriverParam->maxFrameLength = newVal;
+ p_Tgec->p_TgecDriverParam->max_frame_length = newVal;
return E_OK;
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecConfigLengthCheck(t_Handle h_Tgec, bool newVal)
{
-#ifdef FM_LEN_CHECK_ERRATA_FMAN_SW002
-UNUSED(h_Tgec);
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("LengthCheck!"));
-
-#else
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
UNUSED(newVal);
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- p_Tgec->p_TgecDriverParam->noLengthCheckEnable = !newVal;
+ p_Tgec->p_TgecDriverParam->no_length_check_enable = !newVal;
return E_OK;
-#endif /* FM_LEN_CHECK_ERRATA_FMAN_SW002 */
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecConfigException(t_Handle h_Tgec, e_FmMacExceptions exception, bool enable)
{
@@ -408,19 +296,9 @@ static t_Error TgecConfigException(t_Handle h_Tgec, e_FmMacExceptions exception,
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
-#ifdef FM_10G_REM_N_LCL_FLT_EX_ERRATA_10GMAC001
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_Tgec->fmMacControllerDriver.h_Fm, &revInfo);
- if((revInfo.majorRev <=2) &&
- enable &&
- ((exception == e_FM_MAC_EX_10G_LOC_FAULT) || (exception == e_FM_MAC_EX_10G_REM_FAULT)))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("e_FM_MAC_EX_10G_LOC_FAULT and e_FM_MAC_EX_10G_REM_FAULT !"));
- }
-#endif /* FM_10G_REM_N_LCL_FLT_EX_ERRATA_10GMAC001 */
GET_EXCEPTION_FLAG(bitMask, exception);
- if(bitMask)
+ if (bitMask)
{
if (enable)
p_Tgec->exceptions |= bitMask;
@@ -434,7 +312,7 @@ static t_Error TgecConfigException(t_Handle h_Tgec, e_FmMacExceptions exception,
}
#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecConfigSkipFman11Workaround(t_Handle h_Tgec)
{
@@ -443,7 +321,7 @@ static t_Error TgecConfigSkipFman11Workaround(t_Handle h_Tgec)
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- p_Tgec->p_TgecDriverParam->skipFman11Workaround = TRUE;
+ p_Tgec->p_TgecDriverParam->skip_fman11_workaround = TRUE;
return E_OK;
}
@@ -454,217 +332,179 @@ static t_Error TgecConfigSkipFman11Workaround(t_Handle h_Tgec)
/* Tgec Run Time API functions */
/*****************************************************************************/
-/* .............................................................................. */
-
+/* ......................................................................... */
+/* backward compatibility. will be removed in the future. */
static t_Error TgecTxMacPause(t_Handle h_Tgec, uint16_t pauseTime)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
- uint32_t ptv = 0;
- t_TgecMemMap *p_MemMap;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_STATE);
SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- SANITY_CHECK_RETURN_ERROR(p_Tgec->p_MemMap, E_INVALID_STATE);
+ fman_tgec_set_tx_pause_frames(p_Tgec->p_MemMap, pauseTime);
+
+
+ return E_OK;
+}
+
+/* ......................................................................... */
- p_MemMap = (t_TgecMemMap*)(p_Tgec->p_MemMap);
+static t_Error TgecSetTxPauseFrames(t_Handle h_Tgec,
+ uint8_t priority,
+ uint16_t pauseTime,
+ uint16_t threshTime)
+{
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
+
+ SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- ptv = (uint32_t)pauseTime;
+ UNUSED(priority); UNUSED(threshTime);
- WRITE_UINT32(p_MemMap->pause_quant, ptv);
+ fman_tgec_set_tx_pause_frames(p_Tgec->p_MemMap, pauseTime);
return E_OK;
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecRxIgnoreMacPause(t_Handle h_Tgec, bool en)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
- t_TgecMemMap *p_MemMap;
- uint32_t tmpReg32;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_STATE);
SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- SANITY_CHECK_RETURN_ERROR(p_Tgec->p_MemMap, E_INVALID_STATE);
- p_MemMap = (t_TgecMemMap*)(p_Tgec->p_MemMap);
- tmpReg32 = GET_UINT32(p_MemMap->cmd_conf_ctrl);
- if (en)
- tmpReg32 |= CMD_CFG_PAUSE_IGNORE;
- else
- tmpReg32 &= ~CMD_CFG_PAUSE_IGNORE;
- WRITE_UINT32(p_MemMap->cmd_conf_ctrl, tmpReg32);
+ fman_tgec_set_rx_ignore_pause_frames(p_Tgec->p_MemMap, en);
return E_OK;
}
-/* Counters handling */
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecGetStatistics(t_Handle h_Tgec, t_FmMacStatistics *p_Statistics)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
- t_TgecMemMap *p_TgecMemMap;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
+ struct tgec_regs *p_TgecMemMap;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
SANITY_CHECK_RETURN_ERROR(p_Statistics, E_NULL_POINTER);
- SANITY_CHECK_RETURN_ERROR(p_Tgec->p_MemMap, E_NULL_POINTER);
p_TgecMemMap = p_Tgec->p_MemMap;
- p_Statistics->eStatPkts64 = GET_UINT64(p_TgecMemMap->R64);
- p_Statistics->eStatPkts65to127 = GET_UINT64(p_TgecMemMap->R127);
- p_Statistics->eStatPkts128to255 = GET_UINT64(p_TgecMemMap->R255);
- p_Statistics->eStatPkts256to511 = GET_UINT64(p_TgecMemMap->R511);
- p_Statistics->eStatPkts512to1023 = GET_UINT64(p_TgecMemMap->R1023);
- p_Statistics->eStatPkts1024to1518 = GET_UINT64(p_TgecMemMap->R1518);
- p_Statistics->eStatPkts1519to1522 = GET_UINT64(p_TgecMemMap->R1519X);
+ p_Statistics->eStatPkts64 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R64);
+ p_Statistics->eStatPkts65to127 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R127);
+ p_Statistics->eStatPkts128to255 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R255);
+ p_Statistics->eStatPkts256to511 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R511);
+ p_Statistics->eStatPkts512to1023 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R1023);
+ p_Statistics->eStatPkts1024to1518 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R1518);
+ p_Statistics->eStatPkts1519to1522 = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_R1519X);
/* */
- p_Statistics->eStatFragments = GET_UINT64(p_TgecMemMap->TRFRG);
- p_Statistics->eStatJabbers = GET_UINT64(p_TgecMemMap->TRJBR);
+ p_Statistics->eStatFragments = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TRFRG);
+ p_Statistics->eStatJabbers = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TRJBR);
- p_Statistics->eStatsDropEvents = GET_UINT64(p_TgecMemMap->RDRP);
- p_Statistics->eStatCRCAlignErrors = GET_UINT64(p_TgecMemMap->RALN);
+ p_Statistics->eStatsDropEvents = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_RDRP);
+ p_Statistics->eStatCRCAlignErrors = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_RALN);
- p_Statistics->eStatUndersizePkts = GET_UINT64(p_TgecMemMap->TRUND);
- p_Statistics->eStatOversizePkts = GET_UINT64(p_TgecMemMap->TROVR);
+ p_Statistics->eStatUndersizePkts = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TRUND);
+ p_Statistics->eStatOversizePkts = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TROVR);
/* Pause */
- p_Statistics->reStatPause = GET_UINT64(p_TgecMemMap->RXPF);
- p_Statistics->teStatPause = GET_UINT64(p_TgecMemMap->TXPF);
-
+ p_Statistics->reStatPause = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_RXPF);
+ p_Statistics->teStatPause = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TXPF);
/* MIB II */
- p_Statistics->ifInOctets = GET_UINT64(p_TgecMemMap->ROCT);
- p_Statistics->ifInMcastPkts = GET_UINT64(p_TgecMemMap->RMCA);
- p_Statistics->ifInBcastPkts = GET_UINT64(p_TgecMemMap->RBCA);
- p_Statistics->ifInPkts = GET_UINT64(p_TgecMemMap->RUCA)
+ p_Statistics->ifInOctets = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_ROCT);
+ p_Statistics->ifInUcastPkts = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_RUCA);
+ p_Statistics->ifInMcastPkts = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_RMCA);
+ p_Statistics->ifInBcastPkts = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_RBCA);
+ p_Statistics->ifInPkts = p_Statistics->ifInUcastPkts
+ p_Statistics->ifInMcastPkts
+ p_Statistics->ifInBcastPkts;
p_Statistics->ifInDiscards = 0;
- p_Statistics->ifInErrors = GET_UINT64(p_TgecMemMap->RERR);
-
- p_Statistics->ifOutOctets = GET_UINT64(p_TgecMemMap->TOCT);
- p_Statistics->ifOutMcastPkts = GET_UINT64(p_TgecMemMap->TMCA);
- p_Statistics->ifOutBcastPkts = GET_UINT64(p_TgecMemMap->TBCA);
- p_Statistics->ifOutPkts = GET_UINT64(p_TgecMemMap->TUCA);
+ p_Statistics->ifInErrors = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_RERR);
+
+ p_Statistics->ifOutOctets = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TOCT);
+ p_Statistics->ifOutUcastPkts = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TUCA);
+ p_Statistics->ifOutMcastPkts = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TMCA);
+ p_Statistics->ifOutBcastPkts = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TBCA);
+ p_Statistics->ifOutPkts = p_Statistics->ifOutUcastPkts
+ + p_Statistics->ifOutMcastPkts
+ + p_Statistics->ifOutBcastPkts;
p_Statistics->ifOutDiscards = 0;
- p_Statistics->ifOutErrors = GET_UINT64(p_TgecMemMap->TERR);
+ p_Statistics->ifOutErrors = fman_tgec_get_counter(p_TgecMemMap, E_TGEC_COUNTER_TERR);
return E_OK;
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecEnable1588TimeStamp(t_Handle h_Tgec)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
- t_TgecMemMap *p_TgecMemMap;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- p_TgecMemMap = p_Tgec->p_MemMap;
- SANITY_CHECK_RETURN_ERROR(p_TgecMemMap, E_INVALID_HANDLE);
-
- WRITE_UINT32(p_TgecMemMap->cmd_conf_ctrl, GET_UINT32(p_TgecMemMap->cmd_conf_ctrl) | CMD_CFG_EN_TIMESTAMP);
+ fman_tgec_enable_1588_time_stamp(p_Tgec->p_MemMap, 1);
return E_OK;
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecDisable1588TimeStamp(t_Handle h_Tgec)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
- t_TgecMemMap *p_TgecMemMap;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- p_TgecMemMap = p_Tgec->p_MemMap;
- SANITY_CHECK_RETURN_ERROR(p_TgecMemMap, E_INVALID_HANDLE);
-
- WRITE_UINT32(p_TgecMemMap->cmd_conf_ctrl, GET_UINT32(p_TgecMemMap->cmd_conf_ctrl) & ~CMD_CFG_EN_TIMESTAMP);
+ fman_tgec_enable_1588_time_stamp(p_Tgec->p_MemMap, 0);
return E_OK;
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecModifyMacAddress (t_Handle h_Tgec, t_EnetAddr *p_EnetAddr)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
- t_TgecMemMap *p_TgecMemMap;
- uint32_t tmpReg32 = 0;
- uint64_t addr;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_NULL_POINTER);
- SANITY_CHECK_RETURN_ERROR(p_Tgec->p_MemMap, E_NULL_POINTER);
-
- p_TgecMemMap = p_Tgec->p_MemMap;
-
- /* Initialize MAC Station Address registers (1 & 2) */
- /* Station address have to be swapped (big endian to little endian */
-
- addr = ((*(uint64_t *)p_EnetAddr) >> 16);
- p_Tgec->addr = addr;
-
- tmpReg32 = (uint32_t)(addr>>16);
- SwapUint32P(&tmpReg32);
- WRITE_UINT32(p_TgecMemMap->mac_addr_0, tmpReg32);
+ SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- tmpReg32 = (uint32_t)(addr);
- SwapUint32P(&tmpReg32);
- tmpReg32 >>= 16;
- WRITE_UINT32(p_TgecMemMap->mac_addr_1, tmpReg32);
+ p_Tgec->addr = ENET_ADDR_TO_UINT64(*p_EnetAddr);
+ fman_tgec_set_mac_address(p_Tgec->p_MemMap, (uint8_t *)(*p_EnetAddr));
return E_OK;
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecResetCounters (t_Handle h_Tgec)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
- t_TgecMemMap *p_MemMap ;
- uint32_t tmpReg32, cmdConfCtrl;
- int i;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Tgec->p_MemMap, E_INVALID_HANDLE);
-
- p_MemMap= (t_TgecMemMap*)(p_Tgec->p_MemMap);
-
- cmdConfCtrl = GET_UINT32(p_MemMap->cmd_conf_ctrl);
-
- cmdConfCtrl |= CMD_CFG_STAT_CLR;
-
- WRITE_UINT32(p_MemMap->cmd_conf_ctrl, cmdConfCtrl);
-
- for (i=0; i<1000; i++)
- {
- tmpReg32 = GET_UINT32(p_MemMap->cmd_conf_ctrl);
- if (!(tmpReg32 & CMD_CFG_STAT_CLR))
- break;
- }
+ SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- cmdConfCtrl &= ~CMD_CFG_STAT_CLR;
- WRITE_UINT32(p_MemMap->cmd_conf_ctrl, cmdConfCtrl);
+ fman_tgec_reset_stat(p_Tgec->p_MemMap);
return E_OK;
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecAddExactMatchMacAddress(t_Handle h_Tgec, t_EnetAddr *p_EthAddr)
{
- t_Tgec *p_Tgec = (t_Tgec *) h_Tgec;
- uint64_t ethAddr;
- uint8_t paddrNum;
+ t_Tgec *p_Tgec = (t_Tgec *) h_Tgec;
+ uint64_t ethAddr;
+ uint8_t paddrNum;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- ethAddr = ((*(uint64_t *)p_EthAddr) >> 16);
+ ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
if (ethAddr & GROUP_ADDRESS)
/* Multicast address has no effect in PADDR */
@@ -672,15 +512,9 @@ static t_Error TgecAddExactMatchMacAddress(t_Handle h_Tgec, t_EnetAddr *p_EthAdd
/* Make sure no PADDR contains this address */
for (paddrNum = 0; paddrNum < TGEC_NUM_OF_PADDRS; paddrNum++)
- {
if (p_Tgec->indAddrRegUsed[paddrNum])
- {
if (p_Tgec->paddr[paddrNum] == ethAddr)
- {
RETURN_ERROR(MAJOR, E_ALREADY_EXISTS, NO_MSG);
- }
- }
- }
/* Find first unused PADDR */
for (paddrNum = 0; paddrNum < TGEC_NUM_OF_PADDRS; paddrNum++)
@@ -693,7 +527,7 @@ static t_Error TgecAddExactMatchMacAddress(t_Handle h_Tgec, t_EnetAddr *p_EthAdd
p_Tgec->paddr[paddrNum] = ethAddr;
/* put in hardware */
- HardwareAddAddrInPaddr(p_Tgec, &ethAddr, paddrNum);
+ fman_tgec_add_addr_in_paddr(p_Tgec->p_MemMap, (uint8_t*)(*p_EthAddr)/* , paddrNum */);
p_Tgec->numOfIndAddrInRegs++;
return E_OK;
@@ -704,18 +538,18 @@ static t_Error TgecAddExactMatchMacAddress(t_Handle h_Tgec, t_EnetAddr *p_EthAdd
RETURN_ERROR(MAJOR, E_FULL, NO_MSG);
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecDelExactMatchMacAddress(t_Handle h_Tgec, t_EnetAddr *p_EthAddr)
{
- t_Tgec *p_Tgec = (t_Tgec *) h_Tgec;
- uint64_t ethAddr;
- uint8_t paddrNum;
+ t_Tgec *p_Tgec = (t_Tgec *) h_Tgec;
+ uint64_t ethAddr;
+ uint8_t paddrNum;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Tgec->p_MemMap, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- ethAddr = ((*(uint64_t *)p_EthAddr) >> 16);
+ ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
/* Find used PADDR containing this address */
for (paddrNum = 0; paddrNum < TGEC_NUM_OF_PADDRS; paddrNum++)
@@ -726,7 +560,7 @@ static t_Error TgecDelExactMatchMacAddress(t_Handle h_Tgec, t_EnetAddr *p_EthAdd
/* mark this PADDR as not used */
p_Tgec->indAddrRegUsed[paddrNum] = FALSE;
/* clear in hardware */
- HardwareClearAddrInPaddr(p_Tgec, paddrNum);
+ fman_tgec_clear_addr_in_paddr(p_Tgec->p_MemMap /*, paddrNum */);
p_Tgec->numOfIndAddrInRegs--;
return E_OK;
@@ -736,142 +570,118 @@ static t_Error TgecDelExactMatchMacAddress(t_Handle h_Tgec, t_EnetAddr *p_EthAdd
RETURN_ERROR(MAJOR, E_NOT_FOUND, NO_MSG);
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecAddHashMacAddress(t_Handle h_Tgec, t_EnetAddr *p_EthAddr)
{
t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
- t_TgecMemMap *p_TgecMemMap;
t_EthHashEntry *p_HashEntry;
uint32_t crc;
uint32_t hash;
uint64_t ethAddr;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_NULL_POINTER);
- SANITY_CHECK_RETURN_ERROR(p_Tgec->p_MemMap, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- p_TgecMemMap = p_Tgec->p_MemMap;
- ethAddr = ((*(uint64_t *)p_EthAddr) >> 16);
+ ethAddr = ENET_ADDR_TO_UINT64(*p_EthAddr);
if (!(ethAddr & GROUP_ADDRESS))
/* Unicast addresses not supported in hash */
RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Unicast Address"));
/* CRC calculation */
- GET_MAC_ADDR_CRC(ethAddr, crc);
- crc = MIRROR_32(crc);
+ crc = GetMacAddrHashCode(ethAddr);
- hash = (crc >> HASH_CTRL_MCAST_SHIFT) & HASH_ADDR_MASK; /* Take 9 MSB bits */
+ hash = (crc >> TGEC_HASH_MCAST_SHIFT) & TGEC_HASH_ADR_MSK; /* Take 9 MSB bits */
/* Create element to be added to the driver hash table */
p_HashEntry = (t_EthHashEntry *)XX_Malloc(sizeof(t_EthHashEntry));
p_HashEntry->addr = ethAddr;
INIT_LIST(&p_HashEntry->node);
- LIST_AddToTail(&(p_HashEntry->node), &(p_Tgec->p_MulticastAddrHash->p_Lsts[hash]));
- WRITE_UINT32(p_TgecMemMap->hashtable_ctrl, (hash | HASH_CTRL_MCAST_EN));
+ NCSW_LIST_AddToTail(&(p_HashEntry->node), &(p_Tgec->p_MulticastAddrHash->p_Lsts[hash]));
+ fman_tgec_set_hash_table(p_Tgec->p_MemMap, (hash | TGEC_HASH_MCAST_EN));
return E_OK;
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecDelHashMacAddress(t_Handle h_Tgec, t_EnetAddr *p_EthAddr)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
- t_TgecMemMap *p_TgecMemMap;
- t_EthHashEntry *p_HashEntry = NULL;
- t_List *p_Pos;
- uint32_t crc;
- uint32_t hash;
- uint64_t ethAddr;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
+ t_EthHashEntry *p_HashEntry = NULL;
+ t_List *p_Pos;
+ uint32_t crc;
+ uint32_t hash;
+ uint64_t ethAddr;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_NULL_POINTER);
- SANITY_CHECK_RETURN_ERROR(p_Tgec->p_MemMap, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- p_TgecMemMap = p_Tgec->p_MemMap;
ethAddr = ((*(uint64_t *)p_EthAddr) >> 16);
/* CRC calculation */
- GET_MAC_ADDR_CRC(ethAddr, crc);
- crc = MIRROR_32(crc);
+ crc = GetMacAddrHashCode(ethAddr);
- hash = (crc >> HASH_CTRL_MCAST_SHIFT) & HASH_ADDR_MASK; /* Take 9 MSB bits */
+ hash = (crc >> TGEC_HASH_MCAST_SHIFT) & TGEC_HASH_ADR_MSK; /* Take 9 MSB bits */
- LIST_FOR_EACH(p_Pos, &(p_Tgec->p_MulticastAddrHash->p_Lsts[hash]))
+ NCSW_LIST_FOR_EACH(p_Pos, &(p_Tgec->p_MulticastAddrHash->p_Lsts[hash]))
{
-
p_HashEntry = ETH_HASH_ENTRY_OBJ(p_Pos);
- if(p_HashEntry->addr == ethAddr)
+ if (p_HashEntry->addr == ethAddr)
{
- LIST_DelAndInit(&p_HashEntry->node);
+ NCSW_LIST_DelAndInit(&p_HashEntry->node);
XX_Free(p_HashEntry);
break;
}
}
- if(LIST_IsEmpty(&p_Tgec->p_MulticastAddrHash->p_Lsts[hash]))
- WRITE_UINT32(p_TgecMemMap->hashtable_ctrl, (hash & ~HASH_CTRL_MCAST_EN));
+ if (NCSW_LIST_IsEmpty(&p_Tgec->p_MulticastAddrHash->p_Lsts[hash]))
+ fman_tgec_set_hash_table(p_Tgec->p_MemMap, (hash & ~TGEC_HASH_MCAST_EN));
return E_OK;
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecGetId(t_Handle h_Tgec, uint32_t *macId)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
UNUSED(p_Tgec);
UNUSED(macId);
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("TgecGetId Not Supported"));
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecGetVersion(t_Handle h_Tgec, uint32_t *macVersion)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
- t_TgecMemMap *p_TgecMemMap;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_NULL_POINTER);
- SANITY_CHECK_RETURN_ERROR(p_Tgec->p_MemMap, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- p_TgecMemMap = p_Tgec->p_MemMap;
- *macVersion = GET_UINT32(p_TgecMemMap->tgec_id);
+ *macVersion = fman_tgec_get_revision(p_Tgec->p_MemMap);
return E_OK;
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecSetExcpetion(t_Handle h_Tgec, e_FmMacExceptions exception, bool enable)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
- uint32_t bitMask = 0, tmpReg;
- t_TgecMemMap *p_TgecMemMap;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
+ uint32_t bitMask = 0;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_NULL_POINTER);
- SANITY_CHECK_RETURN_ERROR(p_Tgec->p_MemMap, E_NULL_POINTER);
-
- p_TgecMemMap = p_Tgec->p_MemMap;
-#ifdef FM_10G_REM_N_LCL_FLT_EX_ERRATA_10GMAC001
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_Tgec->fmMacControllerDriver.h_Fm, &revInfo);
- if((revInfo.majorRev <=2) &&
- enable &&
- ((exception == e_FM_MAC_EX_10G_LOC_FAULT) || (exception == e_FM_MAC_EX_10G_REM_FAULT)))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("e_FM_MAC_EX_10G_LOC_FAULT and e_FM_MAC_EX_10G_REM_FAULT !"));
- }
-#endif /* FM_10G_REM_N_LCL_FLT_EX_ERRATA_10GMAC001 */
+ SANITY_CHECK_RETURN_ERROR(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
GET_EXCEPTION_FLAG(bitMask, exception);
- if(bitMask)
+ if (bitMask)
{
if (enable)
p_Tgec->exceptions |= bitMask;
@@ -881,250 +691,147 @@ static t_Error TgecSetExcpetion(t_Handle h_Tgec, e_FmMacExceptions exception, bo
else
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
- tmpReg = GET_UINT32(p_TgecMemMap->imask);
- if(enable)
- tmpReg |= bitMask;
+ if (enable)
+ fman_tgec_enable_interrupt(p_Tgec->p_MemMap, bitMask);
else
- tmpReg &= ~bitMask;
- WRITE_UINT32(p_TgecMemMap->imask, tmpReg);
+ fman_tgec_disable_interrupt(p_Tgec->p_MemMap, bitMask);
+
return E_OK;
}
-/* .............................................................................. */
+/* ......................................................................... */
static uint16_t TgecGetMaxFrameLength(t_Handle h_Tgec)
{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
+ t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
SANITY_CHECK_RETURN_VALUE(p_Tgec, E_INVALID_HANDLE, 0);
+ SANITY_CHECK_RETURN_VALUE(!p_Tgec->p_TgecDriverParam, E_INVALID_STATE, 0);
- return (uint16_t)GET_UINT32(p_Tgec->p_MemMap->maxfrm);
+ return fman_tgec_get_max_frame_len(p_Tgec->p_MemMap);
}
-/* .............................................................................. */
+/* ......................................................................... */
#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
static t_Error TgecTxEccWorkaround(t_Tgec *p_Tgec)
{
t_Error err;
- XX_Print("Applying 10G tx-ecc error workaround (10GMAC-A004) ...");
+#if defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0)
+ XX_Print("Applying 10G TX ECC workaround (10GMAC-A004) ... ");
+#endif /* (DEBUG_ERRORS > 0) */
/* enable and set promiscuous */
- WRITE_UINT32(p_Tgec->p_MemMap->cmd_conf_ctrl, CMD_CFG_PROMIS_EN | CMD_CFG_TX_EN | CMD_CFG_RX_EN);
+ fman_tgec_enable(p_Tgec->p_MemMap, TRUE, TRUE);
+ fman_tgec_set_promiscuous(p_Tgec->p_MemMap, TRUE);
err = Fm10GTxEccWorkaround(p_Tgec->fmMacControllerDriver.h_Fm, p_Tgec->macId);
/* disable */
- WRITE_UINT32(p_Tgec->p_MemMap->cmd_conf_ctrl, 0);
+ fman_tgec_set_promiscuous(p_Tgec->p_MemMap, FALSE);
+ fman_tgec_enable(p_Tgec->p_MemMap, FALSE, FALSE);
+ fman_tgec_reset_stat(p_Tgec->p_MemMap);
+ fman_tgec_ack_event(p_Tgec->p_MemMap, 0xffffffff);
+#if defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0)
if (err)
XX_Print("FAILED!\n");
else
XX_Print("done.\n");
- TgecResetCounters (p_Tgec);
+#endif /* (DEBUG_ERRORS > 0) */
return err;
}
#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
-/* .............................................................................. */
-
-#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
-static t_Error TgecDumpRegs(t_Handle h_Tgec)
-{
- t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
-
- DECLARE_DUMP;
-
- if (p_Tgec->p_MemMap)
- {
- DUMP_TITLE(p_Tgec->p_MemMap, ("10G MAC %d: ", p_Tgec->macId));
- DUMP_VAR(p_Tgec->p_MemMap, tgec_id);
- DUMP_VAR(p_Tgec->p_MemMap, scratch);
- DUMP_VAR(p_Tgec->p_MemMap, cmd_conf_ctrl);
- DUMP_VAR(p_Tgec->p_MemMap, mac_addr_0);
- DUMP_VAR(p_Tgec->p_MemMap, mac_addr_1);
- DUMP_VAR(p_Tgec->p_MemMap, maxfrm);
- DUMP_VAR(p_Tgec->p_MemMap, pause_quant);
- DUMP_VAR(p_Tgec->p_MemMap, rx_fifo_sections);
- DUMP_VAR(p_Tgec->p_MemMap, tx_fifo_sections);
- DUMP_VAR(p_Tgec->p_MemMap, rx_fifo_almost_f_e);
- DUMP_VAR(p_Tgec->p_MemMap, tx_fifo_almost_f_e);
- DUMP_VAR(p_Tgec->p_MemMap, hashtable_ctrl);
- DUMP_VAR(p_Tgec->p_MemMap, mdio_cfg_status);
- DUMP_VAR(p_Tgec->p_MemMap, mdio_command);
- DUMP_VAR(p_Tgec->p_MemMap, mdio_data);
- DUMP_VAR(p_Tgec->p_MemMap, mdio_regaddr);
- DUMP_VAR(p_Tgec->p_MemMap, status);
- DUMP_VAR(p_Tgec->p_MemMap, tx_ipg_len);
- DUMP_VAR(p_Tgec->p_MemMap, mac_addr_2);
- DUMP_VAR(p_Tgec->p_MemMap, mac_addr_3);
- DUMP_VAR(p_Tgec->p_MemMap, rx_fifo_ptr_rd);
- DUMP_VAR(p_Tgec->p_MemMap, rx_fifo_ptr_wr);
- DUMP_VAR(p_Tgec->p_MemMap, tx_fifo_ptr_rd);
- DUMP_VAR(p_Tgec->p_MemMap, tx_fifo_ptr_wr);
- DUMP_VAR(p_Tgec->p_MemMap, imask);
- DUMP_VAR(p_Tgec->p_MemMap, ievent);
- DUMP_VAR(p_Tgec->p_MemMap, udp_port);
- DUMP_VAR(p_Tgec->p_MemMap, type_1588v2);
- }
-
- return E_OK;
-}
-#endif /* (defined(DEBUG_ERRORS) && ... */
-
-
/*****************************************************************************/
/* FM Init & Free API */
/*****************************************************************************/
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecInit(t_Handle h_Tgec)
{
t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
- t_TgecDriverParam *p_TgecDriverParam;
- t_TgecMemMap *p_MemMap;
- uint64_t addr;
- uint32_t tmpReg32;
+ struct tgec_cfg *p_TgecDriverParam;
+ t_EnetAddr ethAddr;
t_Error err;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Tgec->p_TgecDriverParam, E_INVALID_STATE);
- SANITY_CHECK_RETURN_ERROR(p_Tgec->p_MemMap, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Tgec->fmMacControllerDriver.h_Fm, E_INVALID_HANDLE);
-#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
- if (!p_Tgec->p_TgecDriverParam->skipFman11Workaround &&
- ((err = TgecTxEccWorkaround(p_Tgec)) != E_OK))
-#ifdef NCSW_LINUX
+ FM_GetRevision(p_Tgec->fmMacControllerDriver.h_Fm, &p_Tgec->fmMacControllerDriver.fmRevInfo);
+ CHECK_INIT_PARAMETERS(p_Tgec, CheckInitParameters);
+
+ p_TgecDriverParam = p_Tgec->p_TgecDriverParam;
+
+ MAKE_ENET_ADDR_FROM_UINT64(p_Tgec->addr, ethAddr);
+ fman_tgec_set_mac_address(p_Tgec->p_MemMap, (uint8_t *)ethAddr);
+
+ /* interrupts */
+#ifdef FM_10G_REM_N_LCL_FLT_EX_10GMAC_ERRATA_SW005
{
- /* the workaround fails in simics, just report and continue initialization */
- REPORT_ERROR(MAJOR, err, ("TgecTxEccWorkaround FAILED, skipping workaround"));
+ if (p_Tgec->fmMacControllerDriver.fmRevInfo.majorRev <=2)
+ p_Tgec->exceptions &= ~(TGEC_IMASK_REM_FAULT | TGEC_IMASK_LOC_FAULT);
}
-#else
+#endif /* FM_10G_REM_N_LCL_FLT_EX_10GMAC_ERRATA_SW005 */
+
+#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
+ if (!p_Tgec->p_TgecDriverParam->skip_fman11_workaround &&
+ ((err = TgecTxEccWorkaround(p_Tgec)) != E_OK))
{
FreeInitResources(p_Tgec);
- RETURN_ERROR(MAJOR, err, ("TgecTxEccWorkaround FAILED"));
+ REPORT_ERROR(MINOR, err, ("TgecTxEccWorkaround FAILED"));
}
-#endif
#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
- CHECK_INIT_PARAMETERS(p_Tgec, CheckInitParameters);
-
- p_TgecDriverParam = p_Tgec->p_TgecDriverParam;
- p_MemMap = p_Tgec->p_MemMap;
-
- /* MAC Address */
- addr = p_Tgec->addr;
- tmpReg32 = (uint32_t)(addr>>16);
- SwapUint32P(&tmpReg32);
- WRITE_UINT32(p_MemMap->mac_addr_0, tmpReg32);
-
- tmpReg32 = (uint32_t)(addr);
- SwapUint32P(&tmpReg32);
- tmpReg32 >>= 16;
- WRITE_UINT32(p_MemMap->mac_addr_1, tmpReg32);
-
- /* Config */
- tmpReg32 = 0;
- if (p_TgecDriverParam->wanModeEnable)
- tmpReg32 |= CMD_CFG_WAN_MODE;
- if (p_TgecDriverParam->promiscuousModeEnable)
- tmpReg32 |= CMD_CFG_PROMIS_EN;
- if (p_TgecDriverParam->pauseForwardEnable)
- tmpReg32 |= CMD_CFG_PAUSE_FWD;
- if (p_TgecDriverParam->pauseIgnore)
- tmpReg32 |= CMD_CFG_PAUSE_IGNORE;
- if (p_TgecDriverParam->txAddrInsEnable)
- tmpReg32 |= CMD_CFG_TX_ADDR_INS;
- if (p_TgecDriverParam->loopbackEnable)
- tmpReg32 |= CMD_CFG_LOOPBACK_EN;
- if (p_TgecDriverParam->cmdFrameEnable)
- tmpReg32 |= CMD_CFG_CMD_FRM_EN;
- if (p_TgecDriverParam->rxErrorDiscard)
- tmpReg32 |= CMD_CFG_RX_ER_DISC;
- if (p_TgecDriverParam->phyTxenaOn)
- tmpReg32 |= CMD_CFG_PHY_TX_EN;
- if (p_TgecDriverParam->sendIdleEnable)
- tmpReg32 |= CMD_CFG_SEND_IDLE;
- if (p_TgecDriverParam->noLengthCheckEnable)
- tmpReg32 |= CMD_CFG_NO_LEN_CHK;
- if (p_TgecDriverParam->lgthCheckNostdr)
- tmpReg32 |= CMD_CFG_LEN_CHK_NOSTDR;
- if (p_TgecDriverParam->timeStampEnable)
- tmpReg32 |= CMD_CFG_EN_TIMESTAMP;
- if (p_TgecDriverParam->rxSfdAny)
- tmpReg32 |= RX_SFD_ANY;
- if (p_TgecDriverParam->rxPblFwd)
- tmpReg32 |= CMD_CFG_RX_PBL_FWD;
- if (p_TgecDriverParam->txPblFwd)
- tmpReg32 |= CMD_CFG_TX_PBL_FWD;
- tmpReg32 |= 0x40;
- WRITE_UINT32(p_MemMap->cmd_conf_ctrl, tmpReg32);
+ err = fman_tgec_init(p_Tgec->p_MemMap, p_TgecDriverParam, p_Tgec->exceptions);
+ if (err)
+ {
+ FreeInitResources(p_Tgec);
+ RETURN_ERROR(MAJOR, err, ("This TGEC version does not support the required i/f mode"));
+ }
/* Max Frame Length */
- WRITE_UINT32(p_MemMap->maxfrm, (uint32_t)p_TgecDriverParam->maxFrameLength);
- err = FmSetMacMaxFrame(p_Tgec->fmMacControllerDriver.h_Fm, e_FM_MAC_10G, p_Tgec->fmMacControllerDriver.macId, p_TgecDriverParam->maxFrameLength);
- if(err)
+ err = FmSetMacMaxFrame(p_Tgec->fmMacControllerDriver.h_Fm,
+ e_FM_MAC_10G,
+ p_Tgec->fmMacControllerDriver.macId,
+ p_TgecDriverParam->max_frame_length);
+ if (err != E_OK)
{
FreeInitResources(p_Tgec);
- RETURN_ERROR(MAJOR, err, NO_MSG);
+ RETURN_ERROR(MINOR, err, NO_MSG);
}
-
- /* Pause Time */
- WRITE_UINT32(p_MemMap->pause_quant, p_TgecDriverParam->pauseTime);
+/* we consider having no IPC a non crasher... */
#ifdef FM_TX_FIFO_CORRUPTION_ERRATA_10GMAC_A007
- WRITE_UINT32(p_Tgec->p_MemMap->tx_ipg_len,
- (GET_UINT32(p_Tgec->p_MemMap->tx_ipg_len) & ~TX_IPG_LENGTH_MASK) | DEFAULT_txIpgLength);
+ if (p_Tgec->fmMacControllerDriver.fmRevInfo.majorRev == 2)
+ fman_tgec_set_erratum_tx_fifo_corruption_10gmac_a007(p_Tgec->p_MemMap);
#endif /* FM_TX_FIFO_CORRUPTION_ERRATA_10GMAC_A007 */
- /* Configure MII */
- tmpReg32 = GET_UINT32(p_Tgec->p_MiiMemMap->mdio_cfg_status);
-#ifdef FM_10G_MDIO_HOLD_ERRATA_XAUI3
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_Tgec->fmMacControllerDriver.h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- tmpReg32 |= (MIIMCOM_MDIO_HOLD_4_REG_CLK << 2);
- }
-#endif /* FM_10G_MDIO_HOLD_ERRATA_XAUI3 */
- tmpReg32 &= ~MIIMCOM_DIV_MASK;
- /* (one half of fm clock => 2.5Mhz) */
- tmpReg32 |=((((p_Tgec->fmMacControllerDriver.clkFreq*10)/2)/25) << MIIMCOM_DIV_SHIFT);
- WRITE_UINT32(p_Tgec->p_MiiMemMap->mdio_cfg_status, tmpReg32);
-
p_Tgec->p_MulticastAddrHash = AllocHashTable(HASH_TABLE_SIZE);
- if(!p_Tgec->p_MulticastAddrHash)
+ if (!p_Tgec->p_MulticastAddrHash)
{
FreeInitResources(p_Tgec);
RETURN_ERROR(MAJOR, E_NO_MEMORY, ("allocation hash table is FAILED"));
}
p_Tgec->p_UnicastAddrHash = AllocHashTable(HASH_TABLE_SIZE);
- if(!p_Tgec->p_UnicastAddrHash)
+ if (!p_Tgec->p_UnicastAddrHash)
{
FreeInitResources(p_Tgec);
RETURN_ERROR(MAJOR, E_NO_MEMORY, ("allocation hash table is FAILED"));
}
- /* interrupts */
-#ifdef FM_10G_REM_N_LCL_FLT_EX_ERRATA_10GMAC001
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_Tgec->fmMacControllerDriver.h_Fm, &revInfo);
- if (revInfo.majorRev <=2)
- p_Tgec->exceptions &= ~(IMASK_REM_FAULT | IMASK_LOC_FAULT);
- }
-#endif /* FM_10G_REM_N_LCL_FLT_EX_ERRATA_10GMAC001 */
- WRITE_UINT32(p_MemMap->ievent, EVENTS_MASK);
- WRITE_UINT32(p_MemMap->imask, p_Tgec->exceptions);
-
- FmRegisterIntr(p_Tgec->fmMacControllerDriver.h_Fm, e_FM_MOD_10G_MAC, p_Tgec->macId, e_FM_INTR_TYPE_ERR, TgecErrException , p_Tgec);
- if ((p_Tgec->mdioIrq != 0) && (p_Tgec->mdioIrq != NO_IRQ))
+ FmRegisterIntr(p_Tgec->fmMacControllerDriver.h_Fm,
+ e_FM_MOD_10G_MAC,
+ p_Tgec->macId,
+ e_FM_INTR_TYPE_ERR,
+ TgecErrException,
+ p_Tgec);
+ if (p_Tgec->mdioIrq != NO_IRQ)
{
XX_SetIntr(p_Tgec->mdioIrq, TgecException, p_Tgec);
XX_EnableIntr(p_Tgec->mdioIrq);
}
- else if (p_Tgec->mdioIrq == 0)
- REPORT_ERROR(MINOR, E_NOT_SUPPORTED, (NO_MSG));
XX_Free(p_TgecDriverParam);
p_Tgec->p_TgecDriverParam = NULL;
@@ -1132,7 +839,7 @@ static t_Error TgecInit(t_Handle h_Tgec)
return E_OK;
}
-/* .............................................................................. */
+/* ......................................................................... */
static t_Error TgecFree(t_Handle h_Tgec)
{
@@ -1140,25 +847,29 @@ static t_Error TgecFree(t_Handle h_Tgec)
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
- FreeInitResources(p_Tgec);
-
if (p_Tgec->p_TgecDriverParam)
{
+ /* Called after config */
XX_Free(p_Tgec->p_TgecDriverParam);
p_Tgec->p_TgecDriverParam = NULL;
}
- XX_Free (p_Tgec);
+ else
+ /* Called after init */
+ FreeInitResources(p_Tgec);
+
+ XX_Free(p_Tgec);
return E_OK;
}
-/* .............................................................................. */
+/* ......................................................................... */
static void InitFmMacControllerDriver(t_FmMacControllerDriver *p_FmMacControllerDriver)
{
p_FmMacControllerDriver->f_FM_MAC_Init = TgecInit;
p_FmMacControllerDriver->f_FM_MAC_Free = TgecFree;
+ p_FmMacControllerDriver->f_FM_MAC_SetStatistics = NULL;
p_FmMacControllerDriver->f_FM_MAC_ConfigLoopback = TgecConfigLoopback;
p_FmMacControllerDriver->f_FM_MAC_ConfigMaxFrameLength = TgecConfigMaxFrameLength;
@@ -1168,6 +879,7 @@ static void InitFmMacControllerDriver(t_FmMacControllerDriver *p_FmMacController
p_FmMacControllerDriver->f_FM_MAC_ConfigHalfDuplex = NULL; /* half-duplex is not supported in xgec */
p_FmMacControllerDriver->f_FM_MAC_ConfigLengthCheck = TgecConfigLengthCheck;
p_FmMacControllerDriver->f_FM_MAC_ConfigException = TgecConfigException;
+ p_FmMacControllerDriver->f_FM_MAC_ConfigResetOnInit = NULL;
#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
p_FmMacControllerDriver->f_FM_MAC_ConfigSkipFman11Workaround= TgecConfigSkipFman11Workaround;
@@ -1180,11 +892,15 @@ static void InitFmMacControllerDriver(t_FmMacControllerDriver *p_FmMacController
p_FmMacControllerDriver->f_FM_MAC_SetPromiscuous = TgecSetPromiscuous;
p_FmMacControllerDriver->f_FM_MAC_AdjustLink = NULL;
+ p_FmMacControllerDriver->f_FM_MAC_SetWakeOnLan = NULL;
+ p_FmMacControllerDriver->f_FM_MAC_RestartAutoneg = NULL;
p_FmMacControllerDriver->f_FM_MAC_Enable = TgecEnable;
p_FmMacControllerDriver->f_FM_MAC_Disable = TgecDisable;
+ p_FmMacControllerDriver->f_FM_MAC_Resume = NULL;
p_FmMacControllerDriver->f_FM_MAC_SetTxAutoPauseFrames = TgecTxMacPause;
+ p_FmMacControllerDriver->f_FM_MAC_SetTxPauseFrames = TgecSetTxPauseFrames;
p_FmMacControllerDriver->f_FM_MAC_SetRxIgnorePauseFrames = TgecRxIgnoreMacPause;
p_FmMacControllerDriver->f_FM_MAC_ResetCounters = TgecResetCounters;
@@ -1201,10 +917,6 @@ static void InitFmMacControllerDriver(t_FmMacControllerDriver *p_FmMacController
p_FmMacControllerDriver->f_FM_MAC_MII_WritePhyReg = TGEC_MII_WritePhyReg;
p_FmMacControllerDriver->f_FM_MAC_MII_ReadPhyReg = TGEC_MII_ReadPhyReg;
-
-#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
- p_FmMacControllerDriver->f_FM_MAC_DumpRegs = TgecDumpRegs;
-#endif /* (defined(DEBUG_ERRORS) && ... */
}
@@ -1212,50 +924,45 @@ static void InitFmMacControllerDriver(t_FmMacControllerDriver *p_FmMacController
/* Tgec Config Main Entry */
/*****************************************************************************/
-/* .............................................................................. */
+/* ......................................................................... */
t_Handle TGEC_Config(t_FmMacParams *p_FmMacParam)
{
- t_Tgec *p_Tgec;
- t_TgecDriverParam *p_TgecDriverParam;
- uintptr_t baseAddr;
- uint8_t i;
+ t_Tgec *p_Tgec;
+ struct tgec_cfg *p_TgecDriverParam;
+ uintptr_t baseAddr;
SANITY_CHECK_RETURN_VALUE(p_FmMacParam, E_NULL_POINTER, NULL);
baseAddr = p_FmMacParam->baseAddr;
/* allocate memory for the UCC GETH data structure. */
- p_Tgec = (t_Tgec *) XX_Malloc(sizeof(t_Tgec));
+ p_Tgec = (t_Tgec *)XX_Malloc(sizeof(t_Tgec));
if (!p_Tgec)
{
REPORT_ERROR(MAJOR, E_NO_MEMORY, ("10G MAC driver structure"));
return NULL;
}
- /* Zero out * p_Tgec */
memset(p_Tgec, 0, sizeof(t_Tgec));
InitFmMacControllerDriver(&p_Tgec->fmMacControllerDriver);
/* allocate memory for the 10G MAC driver parameters data structure. */
- p_TgecDriverParam = (t_TgecDriverParam *) XX_Malloc(sizeof(t_TgecDriverParam));
+ p_TgecDriverParam = (struct tgec_cfg *) XX_Malloc(sizeof(struct tgec_cfg));
if (!p_TgecDriverParam)
{
REPORT_ERROR(MAJOR, E_NO_MEMORY, ("10G MAC driver parameters"));
- TgecFree(p_Tgec);
+ XX_Free(p_Tgec);
return NULL;
}
- /* Zero out */
- memset(p_TgecDriverParam, 0, sizeof(t_TgecDriverParam));
+ memset(p_TgecDriverParam, 0, sizeof(struct tgec_cfg));
/* Plant parameter structure pointer */
p_Tgec->p_TgecDriverParam = p_TgecDriverParam;
- SetDefaultParam(p_TgecDriverParam);
-
- for (i=0; i < sizeof(p_FmMacParam->addr); i++)
- p_Tgec->addr |= ((uint64_t)p_FmMacParam->addr[i] << ((5-i) * 8));
+ fman_tgec_defconfig(p_TgecDriverParam);
- p_Tgec->p_MemMap = (t_TgecMemMap *)UINT_TO_PTR(baseAddr);
+ p_Tgec->p_MemMap = (struct tgec_regs *)UINT_TO_PTR(baseAddr);
p_Tgec->p_MiiMemMap = (t_TgecMiiAccessMemMap *)UINT_TO_PTR(baseAddr + TGEC_TO_MII_OFFSET);
+ p_Tgec->addr = ENET_ADDR_TO_UINT64(p_FmMacParam->addr);
p_Tgec->enetMode = p_FmMacParam->enetMode;
p_Tgec->macId = p_FmMacParam->macId;
p_Tgec->exceptions = DEFAULT_exceptions;
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/tgec.h b/sys/contrib/ncsw/Peripherals/FM/MAC/tgec.h
index db22eadd669f..2aa392385588 100644
--- a/sys/contrib/ncsw/Peripherals/FM/MAC/tgec.h
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/tgec.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File tgec.h
@@ -41,190 +42,72 @@
#include "std_ext.h"
#include "error_ext.h"
#include "list_ext.h"
+#include "enet_ext.h"
+
#include "tgec_mii_acc.h"
#include "fm_mac.h"
-/* Interrupt Mask Register (IMASK) */
-#define IMASK_MDIO_SCAN_EVENTMDIO 0x00010000 /* MDIO_SCAN_EVENTMDIO scan event interrupt mask.
- * 0 masked
- * 1 enabled
- */
-#define IMASK_MDIO_CMD_CMPL 0x00008000 /* 16 MDIO_CMD_CMPL MDIO command completion interrupt mask.
- * 0 masked
- * 1 enabled
- */
-#define IMASK_REM_FAULT 0x00004000 /* 17 REM_FAULT Remote fault interrupt mask.
- * 0 masked
- * 1 enabled
- */
-#define IMASK_LOC_FAULT 0x00002000 /* 18 LOC_FAULT Local fault interrupt mask.
- * 0 masked
- * 1 enabled
- */
-#define IMASK_1TX_ECC_ER 0x00001000 /* 19 TX_ECC_ER Transmit frame ECC error interrupt mask.
- * 0 masked
- * 1 enabled
- */
-#define IMASK_TX_FIFO_UNFL 0x00000800 /* 20 TX_FIFO_UNFL Transmit FIFO underflow interrupt mask.
- * 0 masked
- * 1 enabled
- */
-#define IMASK_TX_FIFO_OVFL 0x00000400 /* 21 TX_FIFO_OVFL Transmit FIFO overflow interrupt mask.
- * 0 masked
- * 1 enabled
- */
-#define IMASK_TX_ER 0x00000200 /* 22 TX_ER Transmit frame error interrupt mask.
- * 0 masked
- * 1 enabled
- */
-#define IMASK_RX_FIFO_OVFL 0x00000100 /* 23 RX_FIFO_OVFL Receive FIFO overflow interrupt mask.
- * 0 masked
- * 1 enabled
- */
-#define IMASK_RX_ECC_ER 0x00000080 /* 24 RX_ECC_ER Receive frame ECC error interrupt mask.
- * 0 masked
- * 1 enabled
- */
-#define IMASK_RX_JAB_FRM 0x00000040 /* 25 RX_JAB_FRM Receive jabber frame interrupt mask.
- * 0 masked
- * 1 enabled
- */
-#define IMASK_RX_OVRSZ_FRM 0x00000020 /* 26 RX_OVRSZ_FRM Receive oversized frame interrupt mask.
- * 0 masked
- * 1 enabled
- */
-#define IMASK_RX_RUNT_FRM 0x00000010 /* 27 RX_RUNT_FRM Receive runt frame interrupt mask.
- * 0 masked
- * 1 enabled
- */
-#define IMASK_RX_FRAG_FRM 0x00000008 /* 28 RX_FRAG_FRM Receive fragment frame interrupt mask.
- * 0 masked
- * 1 enabled
- */
-#define IMASK_RX_LEN_ER 0x00000004 /* 29 RX_LEN_ER Receive payload length error interrupt mask.
- * 0 masked
- * 1 enabled
- */
-#define IMASK_RX_CRC_ER 0x00000002 /* 30 RX_CRC_ER Receive CRC error interrupt mask.
- * 0 masked
- * 1 enabled
- */
-#define IMASK_RX_ALIGN_ER 0x00000001 /* 31 RX_ALIGN_ER Receive alignment error interrupt mask.
- * 0 masked
- * 1 enabled
- */
-
-#define EVENTS_MASK ((uint32_t)(IMASK_MDIO_SCAN_EVENTMDIO | \
- IMASK_MDIO_CMD_CMPL | \
- IMASK_REM_FAULT | \
- IMASK_LOC_FAULT | \
- IMASK_1TX_ECC_ER | \
- IMASK_TX_FIFO_UNFL | \
- IMASK_TX_FIFO_OVFL | \
- IMASK_TX_ER | \
- IMASK_RX_FIFO_OVFL | \
- IMASK_RX_ECC_ER | \
- IMASK_RX_JAB_FRM | \
- IMASK_RX_OVRSZ_FRM | \
- IMASK_RX_RUNT_FRM | \
- IMASK_RX_FRAG_FRM | \
- IMASK_RX_LEN_ER | \
- IMASK_RX_CRC_ER | \
- IMASK_RX_ALIGN_ER))
-
-#define GET_EXCEPTION_FLAG(bitMask, exception) switch(exception){ \
- case e_FM_MAC_EX_10G_MDIO_SCAN_EVENTMDIO: \
- bitMask = IMASK_MDIO_SCAN_EVENTMDIO; break; \
- case e_FM_MAC_EX_10G_MDIO_CMD_CMPL: \
- bitMask = IMASK_MDIO_CMD_CMPL ; break; \
- case e_FM_MAC_EX_10G_REM_FAULT: \
- bitMask = IMASK_REM_FAULT ; break; \
- case e_FM_MAC_EX_10G_LOC_FAULT: \
- bitMask = IMASK_LOC_FAULT ; break; \
- case e_FM_MAC_EX_10G_1TX_ECC_ER: \
- bitMask = IMASK_1TX_ECC_ER ; break; \
- case e_FM_MAC_EX_10G_TX_FIFO_UNFL: \
- bitMask = IMASK_TX_FIFO_UNFL ; break; \
- case e_FM_MAC_EX_10G_TX_FIFO_OVFL: \
- bitMask = IMASK_TX_FIFO_OVFL ; break; \
- case e_FM_MAC_EX_10G_TX_ER: \
- bitMask = IMASK_TX_ER ; break; \
- case e_FM_MAC_EX_10G_RX_FIFO_OVFL: \
- bitMask = IMASK_RX_FIFO_OVFL ; break; \
- case e_FM_MAC_EX_10G_RX_ECC_ER: \
- bitMask = IMASK_RX_ECC_ER ; break; \
- case e_FM_MAC_EX_10G_RX_JAB_FRM: \
- bitMask = IMASK_RX_JAB_FRM ; break; \
- case e_FM_MAC_EX_10G_RX_OVRSZ_FRM: \
- bitMask = IMASK_RX_OVRSZ_FRM ; break; \
- case e_FM_MAC_EX_10G_RX_RUNT_FRM: \
- bitMask = IMASK_RX_RUNT_FRM ; break; \
- case e_FM_MAC_EX_10G_RX_FRAG_FRM: \
- bitMask = IMASK_RX_FRAG_FRM ; break; \
- case e_FM_MAC_EX_10G_RX_LEN_ER: \
- bitMask = IMASK_RX_LEN_ER ; break; \
- case e_FM_MAC_EX_10G_RX_CRC_ER: \
- bitMask = IMASK_RX_CRC_ER ; break; \
- case e_FM_MAC_EX_10G_RX_ALIGN_ER: \
- bitMask = IMASK_RX_ALIGN_ER ; break; \
+#define DEFAULT_exceptions \
+ ((uint32_t)(TGEC_IMASK_MDIO_SCAN_EVENT | \
+ TGEC_IMASK_REM_FAULT | \
+ TGEC_IMASK_LOC_FAULT | \
+ TGEC_IMASK_TX_ECC_ER | \
+ TGEC_IMASK_TX_FIFO_UNFL | \
+ TGEC_IMASK_TX_FIFO_OVFL | \
+ TGEC_IMASK_TX_ER | \
+ TGEC_IMASK_RX_FIFO_OVFL | \
+ TGEC_IMASK_RX_ECC_ER | \
+ TGEC_IMASK_RX_JAB_FRM | \
+ TGEC_IMASK_RX_OVRSZ_FRM | \
+ TGEC_IMASK_RX_RUNT_FRM | \
+ TGEC_IMASK_RX_FRAG_FRM | \
+ TGEC_IMASK_RX_CRC_ER | \
+ TGEC_IMASK_RX_ALIGN_ER))
+
+#define GET_EXCEPTION_FLAG(bitMask, exception) switch (exception){ \
+ case e_FM_MAC_EX_10G_MDIO_SCAN_EVENTMDIO: \
+ bitMask = TGEC_IMASK_MDIO_SCAN_EVENT ; break; \
+ case e_FM_MAC_EX_10G_MDIO_CMD_CMPL: \
+ bitMask = TGEC_IMASK_MDIO_CMD_CMPL ; break; \
+ case e_FM_MAC_EX_10G_REM_FAULT: \
+ bitMask = TGEC_IMASK_REM_FAULT ; break; \
+ case e_FM_MAC_EX_10G_LOC_FAULT: \
+ bitMask = TGEC_IMASK_LOC_FAULT ; break; \
+ case e_FM_MAC_EX_10G_1TX_ECC_ER: \
+ bitMask = TGEC_IMASK_TX_ECC_ER ; break; \
+ case e_FM_MAC_EX_10G_TX_FIFO_UNFL: \
+ bitMask = TGEC_IMASK_TX_FIFO_UNFL ; break; \
+ case e_FM_MAC_EX_10G_TX_FIFO_OVFL: \
+ bitMask = TGEC_IMASK_TX_FIFO_OVFL ; break; \
+ case e_FM_MAC_EX_10G_TX_ER: \
+ bitMask = TGEC_IMASK_TX_ER ; break; \
+ case e_FM_MAC_EX_10G_RX_FIFO_OVFL: \
+ bitMask = TGEC_IMASK_RX_FIFO_OVFL ; break; \
+ case e_FM_MAC_EX_10G_RX_ECC_ER: \
+ bitMask = TGEC_IMASK_RX_ECC_ER ; break; \
+ case e_FM_MAC_EX_10G_RX_JAB_FRM: \
+ bitMask = TGEC_IMASK_RX_JAB_FRM ; break; \
+ case e_FM_MAC_EX_10G_RX_OVRSZ_FRM: \
+ bitMask = TGEC_IMASK_RX_OVRSZ_FRM ; break; \
+ case e_FM_MAC_EX_10G_RX_RUNT_FRM: \
+ bitMask = TGEC_IMASK_RX_RUNT_FRM ; break; \
+ case e_FM_MAC_EX_10G_RX_FRAG_FRM: \
+ bitMask = TGEC_IMASK_RX_FRAG_FRM ; break; \
+ case e_FM_MAC_EX_10G_RX_LEN_ER: \
+ bitMask = TGEC_IMASK_RX_LEN_ER ; break; \
+ case e_FM_MAC_EX_10G_RX_CRC_ER: \
+ bitMask = TGEC_IMASK_RX_CRC_ER ; break; \
+ case e_FM_MAC_EX_10G_RX_ALIGN_ER: \
+ bitMask = TGEC_IMASK_RX_ALIGN_ER ; break; \
default: bitMask = 0;break;}
-
-/* Default Config Params */
-#define DEFAULT_wanModeEnable FALSE
-#define DEFAULT_promiscuousModeEnable FALSE
-
-
-#define DEFAULT_pauseForwardEnable FALSE
-#define DEFAULT_pauseIgnore FALSE
-#define DEFAULT_txAddrInsEnable FALSE
-
-#define DEFAULT_loopbackEnable FALSE
-#define DEFAULT_cmdFrameEnable FALSE
-#define DEFAULT_rxErrorDiscard FALSE
-#define DEFAULT_phyTxenaOn FALSE
-#define DEFAULT_sendIdleEnable FALSE
-#define DEFAULT_noLengthCheckEnable TRUE
-#define DEFAULT_lgthCheckNostdr FALSE
-#define DEFAULT_timeStampEnable FALSE
-#define DEFAULT_rxSfdAny FALSE
-#define DEFAULT_rxPblFwd FALSE
-#define DEFAULT_txPblFwd FALSE
-#define DEFAULT_txIpgLength 12
-
-#define DEFAULT_maxFrameLength 0x600
-
-#define DEFAULT_debugMode FALSE
-#define DEFAULT_pauseTime 0xf000
-#define DEFAULT_imask 0xf000
-#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
-#define DEFAULT_skipFman11Workaround FALSE
-#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
-
-#define DEFAULT_exceptions ((uint32_t)(IMASK_MDIO_SCAN_EVENTMDIO | \
- IMASK_REM_FAULT | \
- IMASK_LOC_FAULT | \
- IMASK_1TX_ECC_ER | \
- IMASK_TX_FIFO_UNFL | \
- IMASK_TX_FIFO_OVFL | \
- IMASK_TX_ER | \
- IMASK_RX_FIFO_OVFL | \
- IMASK_RX_ECC_ER | \
- IMASK_RX_JAB_FRM | \
- IMASK_RX_OVRSZ_FRM | \
- IMASK_RX_RUNT_FRM | \
- IMASK_RX_FRAG_FRM | \
- IMASK_RX_CRC_ER | \
- IMASK_RX_ALIGN_ER))
-
#define MAX_PACKET_ALIGNMENT 31
#define MAX_INTER_PACKET_GAP 0x7f
#define MAX_INTER_PALTERNATE_BEB 0x0f
#define MAX_RETRANSMISSION 0x0f
#define MAX_COLLISION_WINDOW 0x03ff
-
#define TGEC_NUM_OF_PADDRS 1 /* number of pattern match registers (entries) */
#define GROUP_ADDRESS 0x0000010000000000LL /* Group address bit indication */
@@ -238,225 +121,11 @@
#define TGEC_ID_MAC_VERSION 0x0000FF00
#define TGEC_ID_MAC_REV 0x000000ff
-/* Command and Configuration Register (COMMAND_CONFIG) */
-#define CMD_CFG_TX_PBL_FWD 0x00800000 /* 08 Transmit Preamble Forwarding (custom preamble).
- */
-#define CMD_CFG_RX_PBL_FWD 0x00400000 /* 09 Receive Preamble Forwarding (custom preamble).
- */
-#define RX_SFD_ANY 0x00200000 /* 10 Enables, when set, that any character is allowed at the SFD position of the preamble and the frame will be accepted.
- */
-#define CMD_CFG_EN_TIMESTAMP 0x00100000 /* 11 EN_TIMESTAMP IEEE 1588 timeStamp functionality control.
- * 0 disabled
- * 1 enabled
- */
-#define CMD_CFG_TX_ADDR_INS_SEL 0x00080000 /* 12 TX_ADDR_INS_SEL Transmit MAC address select
- * 0 insert using first MAC address
- * 1 insert using second MAC address
- */
-#define CMD_CFG_LEN_CHK_NOSTDR 0x00040000 /* 13 LEN_CHK_NOSTDR
- */
-#define CMD_CFG_NO_LEN_CHK 0x00020000 /* 14 NO_LEN_CHK Payload length check disable
- * 0 MAC compares the frame payload length with the frame length/type field.
- * 1 Payload length check is disabled.
- */
-#define CMD_CFG_SEND_IDLE 0x00010000 /* 15 SEND_IDLE Force idle generation
- * 0 Normal operation.
- * 1 MAC permanently sends XGMII idle sequences even when faults are received.
- */
-#define CMD_CFG_PHY_TX_EN 0x00008000 /* 16 PHY_TX_EN PHY transmit enable
- * 0 PHY transmit is disabled.
- * 1 PHY transmit is enabled.
- */
-#define CMD_CFG_RX_ER_DISC 0x00004000 /* 17 RX_ER_DISC Receive error frame discard enable
- * 0 Received error frames are processed.
- * 1 Any frame received with an error is discarded.
- */
-#define CMD_CFG_CMD_FRM_EN 0x00002000 /* 18 CMD_FRM_EN Command frame reception enable
- * 0 Only Pause frames are accepted (all other command frames are rejected).
- * 1 All command frames are accepted.
- */
-#define CMD_CFG_STAT_CLR 0x00001000 /* 19 STAT_CLR Clear statistics
- * 0 Normal operations.
- * 1 All statistics counters are cleared.
- */
-#define CMD_CFG_LOOPBACK_EN 0x00000400 /* 21 LOOPBAC_EN PHY interface loopback enable
- * 0 Configure PHY for normal operation.
- * 1 Configure PHY for loopback mode.
- */
-#define CMD_CFG_TX_ADDR_INS 0x00000200 /* 22 TX_ADDR_INS Transmit source MAC address insertion
- * 0 MAC transmits the source MAC address unmodified.
- * 1 MAC overwrites the source MAC address with address specified by COMMAND_CONFIG[TX_ADDR_INS_SEL].
- */
-#define CMD_CFG_PAUSE_IGNORE 0x00000100 /* 23 PAUSE_IGNORE Ignore Pause frame quanta
- * 0 MAC stops transmit process for the duration specified in the Pause frame quanta of a received Pause frame.
- * 1 MAC ignores received Pause frames.
- */
-#define CMD_CFG_PAUSE_FWD 0x00000080 /* 24 PAUSE_FWD Terminate/forward received Pause frames
- * 0 MAC terminates and discards received Pause frames.
- * 1 MAC forwards Pause frames to the user application.
- */
-#define CMD_CFG_PROMIS_EN 0x00000010 /* 27 PROMIS_EN Promiscuous operation enable
- * 0 Unicast frames with a destination address not matching the core MAC address (defined by registers, MAC_ADDR_0 and MAC_ADDR_1) are rejected.
- * 1 All frames are received without any MAC address filtering.
- */
-#define CMD_CFG_WAN_MODE 0x00000008 /* 28 WAN_MODE WAN mode enable
- * 0 Configure MAC for LAN mode.
- * 1 Configure MAC for WAN mode.
- */
-#define CMD_CFG_RX_EN 0x00000002 /* 30 RX_EN MAC receive path enable
- * 0 MAC receive path is disabled
- * 1 MAC receive path is enabled.
- */
-#define CMD_CFG_TX_EN 0x00000001 /* 31 TX_EN MAC transmit path enable
- * 0 MAC transmit path is disabled
- * 1 MAC transmit path is enabled.
- */
-
-/* Hashtable Control Register (HASHTABLE_CTRL) */
-#define HASH_CTRL_MCAST_SHIFT 23
-
-#define HASH_CTRL_MCAST_RD 0x00000400 /* 22 MCAST_READ Entry Multicast frame reception for the hash entry.
- * 0 disabled
- * 1 enabled
- */
-#define HASH_CTRL_MCAST_EN 0x00000200 /* 22 MCAST_EN Multicast frame reception for the hash entry.
- * 0 disabled
- * 1 enabled
- */
-#define HASH_ADDR_MASK 0x000001ff /* 23-31 HASH_ADDR Hash table address code.
- */
-
-/* Transmit Inter-Packet Gap Length Register (TX_IPG_LENGTH) */
-#define TX_IPG_LENGTH_MASK 0x000003ff
-
-
-
-#if defined(__MWERKS__) && !defined(__GNUC__)
-#pragma pack(push,1)
-#endif /* defined(__MWERKS__) && ... */
-#define MEM_MAP_START
-
-/*
- * 10G memory map
- */
-typedef _Packed struct {
-/* 10Ge General Control and Status */
- volatile uint32_t tgec_id; /* 0x000 10GEC_ID - Controller ID register */
- volatile uint32_t scratch; /* 0x004 */
- volatile uint32_t cmd_conf_ctrl; /* 0x008 COMMAND_CONFIG - Control and configuration register */
- volatile uint32_t mac_addr_0; /* 0x00C MAC_ADDR_0 - Lower 32 bits of the first 48-bit MAC address */
- volatile uint32_t mac_addr_1; /* 0x010 MAC_ADDR_1 - Upper 16 bits of the first 48-bit MAC address */
- volatile uint32_t maxfrm; /* 0x014 MAXFRM - Maximum frame length register */
- volatile uint32_t pause_quant; /* 0x018 PAUSE_QUANT - Pause quanta register */
- volatile uint32_t rx_fifo_sections; /* 0x01c */
- volatile uint32_t tx_fifo_sections; /* 0x020 */
- volatile uint32_t rx_fifo_almost_f_e; /* 0x024 */
- volatile uint32_t tx_fifo_almost_f_e; /* 0x028 */
- volatile uint32_t hashtable_ctrl; /* 0x02C HASHTABLE_CTRL - Hash table control register */
- volatile uint32_t mdio_cfg_status; /* 0x030 */
- volatile uint32_t mdio_command; /* 0x034 */
- volatile uint32_t mdio_data; /* 0x038 */
- volatile uint32_t mdio_regaddr; /* 0x03c */
- volatile uint32_t status; /* 0x040 */
- volatile uint32_t tx_ipg_len; /* 0x044 TX_IPG_LENGTH - Transmitter inter-packet-gap register */
- volatile uint32_t mac_addr_2; /* 0x048 MAC_ADDR_2 - Lower 32 bits of the second 48-bit MAC address */
- volatile uint32_t mac_addr_3; /* 0x04C MAC_ADDR_3 - Upper 16 bits of the second 48-bit MAC address */
- volatile uint32_t rx_fifo_ptr_rd; /* 0x050 */
- volatile uint32_t rx_fifo_ptr_wr; /* 0x054 */
- volatile uint32_t tx_fifo_ptr_rd; /* 0x058 */
- volatile uint32_t tx_fifo_ptr_wr; /* 0x05c */
- volatile uint32_t imask; /* 0x060 IMASK - Interrupt mask register */
- volatile uint32_t ievent; /* 0x064 IEVENT - Interrupt event register */
- volatile uint32_t udp_port; /* 0x068 Defines a UDP Port number. When an UDP/IP frame is received with a matching UDP destination port, the receive status indication pin ff_rx_ts_frm will be asserted.*/
- volatile uint32_t type_1588v2; /* 0x06c Type field for 1588v2 layer 2 frames. IEEE1588 defines the type 0x88f7 for 1588 frames. */
- volatile uint32_t TENGEC_RESERVED4[4];
-/*10Ge Statistics Counter */
- volatile uint64_t TFRM; /* 80 aFramesTransmittedOK */
- volatile uint64_t RFRM; /* 88 aFramesReceivedOK */
- volatile uint64_t RFCS; /* 90 aFrameCheckSequenceErrors */
- volatile uint64_t RALN; /* 98 aAlignmentErrors */
- volatile uint64_t TXPF; /* A0 aPAUSEMACCtrlFramesTransmitted */
- volatile uint64_t RXPF; /* A8 aPAUSEMACCtrlFramesReceived */
- volatile uint64_t RLONG; /* B0 aFrameTooLongErrors */
- volatile uint64_t RFLR; /* B8 aInRangeLengthErrors */
- volatile uint64_t TVLAN; /* C0 VLANTransmittedOK */
- volatile uint64_t RVLAN; /* C8 VLANReceivedOK */
- volatile uint64_t TOCT; /* D0 ifOutOctets */
- volatile uint64_t ROCT; /* D8 ifInOctets */
- volatile uint64_t RUCA; /* E0 ifInUcastPkts */
- volatile uint64_t RMCA; /* E8 ifInMulticastPkts */
- volatile uint64_t RBCA; /* F0 ifInBroadcastPkts */
- volatile uint64_t TERR; /* F8 ifOutErrors */
- volatile uint32_t TENGEC_RESERVED6[2];
- volatile uint64_t TUCA; /* 108 ifOutUcastPkts */
- volatile uint64_t TMCA; /* 110 ifOutMulticastPkts */
- volatile uint64_t TBCA; /* 118 ifOutBroadcastPkts */
- volatile uint64_t RDRP; /* 120 etherStatsDropEvents */
- volatile uint64_t REOCT; /* 128 etherStatsOctets */
- volatile uint64_t RPKT; /* 130 etherStatsPkts */
- volatile uint64_t TRUND; /* 138 etherStatsUndersizePkts */
- volatile uint64_t R64; /* 140 etherStatsPkts64Octets */
- volatile uint64_t R127; /* 148 etherStatsPkts65to127Octets */
- volatile uint64_t R255; /* 150 etherStatsPkts128to255Octets */
- volatile uint64_t R511; /* 158 etherStatsPkts256to511Octets */
- volatile uint64_t R1023; /* 160 etherStatsPkts512to1023Octets */
- volatile uint64_t R1518; /* 168 etherStatsPkts1024to1518Octets */
- volatile uint64_t R1519X; /* 170 etherStatsPkts1519toX */
- volatile uint64_t TROVR; /* 178 etherStatsOversizePkts */
- volatile uint64_t TRJBR; /* 180 etherStatsJabbers */
- volatile uint64_t TRFRG; /* 188 etherStatsFragments */
- volatile uint64_t RERR; /* 190 ifInErrors */
-} _PackedType t_TgecMemMap;
-
-#define MEM_MAP_END
-#if defined(__MWERKS__) && !defined(__GNUC__)
-#pragma pack(pop)
-#endif /* defined(__MWERKS__) && ... */
-
-
-typedef struct {
- bool wanModeEnable; /* WAN Mode Enable. Sets WAN mode (1) or LAN mode (0, default) of operation. */
- bool promiscuousModeEnable; /* Enables MAC promiscuous operation. When set to '1', all frames are received without any MAC address filtering, when set to '0' (Reset value) Unicast Frames with a destination address not matching the Core MAC Address (MAC Address programmed in Registers MAC_ADDR_0 and MAC_ADDR_1 or the MAC address programmed in Registers MAC_ADDR_2 and MAC_ADDR_3 ) are rejected. */
- bool pauseForwardEnable; /* Terminate / Forward Pause Frames. If set to '1' pause frames are forwarded to the user application. When set to '0' (Reset value) pause frames are terminated and discarded within the MAC. */
- bool pauseIgnore; /* Ignore Pause Frame Quanta. If set to '1' received pause frames are ignored by the MAC. When set to '0' (Reset value) the transmit process is stopped for the amount of time specified in the pause quanta received within a pause frame. */
- bool txAddrInsEnable; /* Set Source MAC Address on Transmit.
- If set to '1' the MAC overwrites the source MAC address received from the Client Interface with one of the MAC addresses (Refer to section 10.4)
- If set to '0' (Reset value), the source MAC address from the Client Interface is transmitted unmodified to the line. */
- bool loopbackEnable; /* PHY Interface Loopback. When set to '1', the signal loop_ena is set to '1', when set to '0' (Reset value) the signal loop_ena is set to '0'. */
- bool cmdFrameEnable; /* Enables reception of all command frames. When set to '1' all Command Frames are accepted, when set to '0' (Reset Value) only Pause Frames are accepted and all other Command Frames are rejected. */
- bool rxErrorDiscard; /* Receive Errored Frame Discard Enable. When set to ‘1’, any frame received with an error is discarded in the Core and not forwarded to the Client interface. When set to ‘0’ (Reset value), errored Frames are forwarded to the Client interface with ff_rx_err asserted. */
- bool phyTxenaOn; /* PHY Transmit Enable. When set to '1', the signal phy_txena is set to '1', when set to '0' (Reset value) the signal phy_txena is set to '0' */
- bool sendIdleEnable; /* Force Idle Generation. When set to '1', the MAC permanently sends XGMII Idle sequences even when faults are received. */
- bool noLengthCheckEnable; /* Payload Length Check Disable. When set to ‘0’ (Reset value), the Core checks the frame's payload length with the Frame Length/Type field, when set to ‘1’, the payload length check is disabled. */
- bool lgthCheckNostdr; /* The Core interprets the Length/Type field differently depending on the value of this Bit */
- bool timeStampEnable; /* This bit selects between enabling and disabling the IEEE 1588 functionality.
- 1: IEEE 1588 is enabled.
- 0: IEEE 1588 is disabled. */
- bool rxSfdAny; /* Enables, when set, that any character is allowed at the SFD position of the preamble and the frame will be accepted.
- If cleared (default) the frame is accepted only if the 8th byte of the preamble contains the SFD value 0xd5. If another value is received, the frame is discarded and the alignment error counter increments. */
- bool rxPblFwd; /* Receive Preamble Forwarding (custom preamble).
- If set, the first word (ff_rx_sop) of every received frame contains the preamble of the frame. The frame data starts with the 2nd word from the FIFO.
- If the bit is cleared (default) the preamble is removed from the frame before it is written into the receive FIFO. */
- bool txPblFwd; /* Transmit Preamble Forwarding (custom preamble).
- If set, the first word written into the TX FIFO is considered as frame preamble. The MAC will not add a preamble in front of the frame. Note that bits 7:0 of the preamble word will still be overwritten with the XGMII start character upon transmission.
- If cleared (default) the MAC */
- uint32_t txIpgLength; /*Transmit Inter-Packet-Gap (IPG) value.
- A 6-bit value: Depending on LAN or WAN mode of operation (see COMMAND_CONFIG, 19.2.1 page 91) the value has the following meaning:
- - LAN Mode: Number of octets in steps of 4. Valid values are 8, 12, 16, ... 100. DIC is fully supported (see 10.6.1 page 49) for any setting. A default of 12 (reset value) must be set to conform to IEEE802.3ae. Warning: When set to 8, PCS layers may not be able to perform clock rate compensation.
- - WAN Mode: Stretch factor. Valid values are 4..15. The stretch factor is calculated as (value+1)*8. A default of 12 (reset value) must be set to conform to IEEE 802.3ae (i.e. 13*8=104). A larger value shrinks the IPG (increasing bandwidth). */
-/*.. */
- uint16_t maxFrameLength;
- bool debugMode;
- uint16_t pauseTime;
-#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
- bool skipFman11Workaround;
-#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
-} t_TgecDriverParam;
typedef struct {
t_FmMacControllerDriver fmMacControllerDriver; /**< Upper Mac control block */
t_Handle h_App; /**< Handle to the upper layer application */
- t_TgecMemMap *p_MemMap; /**< pointer to 10G memory mapped registers. */
+ struct tgec_regs *p_MemMap; /**< pointer to 10G memory mapped registers. */
t_TgecMiiAccessMemMap *p_MiiMemMap; /**< pointer to MII memory mapped registers. */
uint64_t addr; /**< MAC address of device; */
e_EnetMode enetMode; /**< Ethernet physical interface */
@@ -471,7 +140,7 @@ typedef struct {
bool debugMode;
uint8_t macId;
uint32_t exceptions;
- t_TgecDriverParam *p_TgecDriverParam;
+ struct tgec_cfg *p_TgecDriverParam;
} t_Tgec;
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/tgec_mii_acc.c b/sys/contrib/ncsw/Peripherals/FM/MAC/tgec_mii_acc.c
index c9753be15069..e0fafd1d174d 100644
--- a/sys/contrib/ncsw/Peripherals/FM/MAC/tgec_mii_acc.c
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/tgec_mii_acc.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -31,12 +31,15 @@
*/
+
#include "error_ext.h"
#include "std_ext.h"
#include "fm_mac.h"
#include "tgec.h"
#include "xx_ext.h"
+#include "fm_common.h"
+
/*****************************************************************************/
t_Error TGEC_MII_WritePhyReg(t_Handle h_Tgec,
@@ -46,12 +49,20 @@ t_Error TGEC_MII_WritePhyReg(t_Handle h_Tgec,
{
t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
t_TgecMiiAccessMemMap *p_MiiAccess;
+ uint32_t cfgStatusReg;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Tgec->p_MiiMemMap, E_INVALID_HANDLE);
p_MiiAccess = p_Tgec->p_MiiMemMap;
+ /* Configure MII */
+ cfgStatusReg = GET_UINT32(p_MiiAccess->mdio_cfg_status);
+ cfgStatusReg &= ~MIIMCOM_DIV_MASK;
+ /* (one half of fm clock => 2.5Mhz) */
+ cfgStatusReg |=((((p_Tgec->fmMacControllerDriver.clkFreq*10)/2)/25) << MIIMCOM_DIV_SHIFT);
+ WRITE_UINT32(p_MiiAccess->mdio_cfg_status, cfgStatusReg);
+
while ((GET_UINT32(p_MiiAccess->mdio_cfg_status)) & MIIMIND_BUSY)
XX_UDelay (1);
@@ -82,13 +93,20 @@ t_Error TGEC_MII_ReadPhyReg(t_Handle h_Tgec,
{
t_Tgec *p_Tgec = (t_Tgec *)h_Tgec;
t_TgecMiiAccessMemMap *p_MiiAccess;
- uint32_t cfg_status;
+ uint32_t cfgStatusReg;
SANITY_CHECK_RETURN_ERROR(p_Tgec, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Tgec->p_MiiMemMap, E_INVALID_HANDLE);
p_MiiAccess = p_Tgec->p_MiiMemMap;
+ /* Configure MII */
+ cfgStatusReg = GET_UINT32(p_MiiAccess->mdio_cfg_status);
+ cfgStatusReg &= ~MIIMCOM_DIV_MASK;
+ /* (one half of fm clock => 2.5Mhz) */
+ cfgStatusReg |=((((p_Tgec->fmMacControllerDriver.clkFreq*10)/2)/25) << MIIMCOM_DIV_SHIFT);
+ WRITE_UINT32(p_MiiAccess->mdio_cfg_status, cfgStatusReg);
+
while ((GET_UINT32(p_MiiAccess->mdio_cfg_status)) & MIIMIND_BUSY)
XX_UDelay (1);
@@ -110,12 +128,12 @@ t_Error TGEC_MII_ReadPhyReg(t_Handle h_Tgec,
*p_Data = (uint16_t)GET_UINT32(p_MiiAccess->mdio_data);
- cfg_status = GET_UINT32(p_MiiAccess->mdio_cfg_status);
+ cfgStatusReg = GET_UINT32(p_MiiAccess->mdio_cfg_status);
- if (cfg_status & MIIMIND_READ_ERROR)
+ if (cfgStatusReg & MIIMIND_READ_ERROR)
RETURN_ERROR(MINOR, E_INVALID_VALUE,
- ("Read Error: phyAddr 0x%x, dev 0x%x, reg 0x%x, cfg_status 0x%x",
- ((phyAddr & 0xe0)>>5), (phyAddr & 0x1f), reg, cfg_status));
+ ("Read Error: phyAddr 0x%x, dev 0x%x, reg 0x%x, cfgStatusReg 0x%x",
+ ((phyAddr & 0xe0)>>5), (phyAddr & 0x1f), reg, cfgStatusReg));
return E_OK;
}
diff --git a/sys/contrib/ncsw/Peripherals/FM/MAC/tgec_mii_acc.h b/sys/contrib/ncsw/Peripherals/FM/MAC/tgec_mii_acc.h
index 81fd6efdf045..645cdde57973 100644
--- a/sys/contrib/ncsw/Peripherals/FM/MAC/tgec_mii_acc.h
+++ b/sys/contrib/ncsw/Peripherals/FM/MAC/tgec_mii_acc.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#ifndef __TGEC_MII_ACC_H
#define __TGEC_MII_ACC_H
@@ -59,7 +60,6 @@
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(push,1)
#endif /* defined(__MWERKS__) && ... */
-#define MEM_MAP_START
/*----------------------------------------------------*/
/* MII Configuration Control Memory Map Registers */
@@ -72,7 +72,6 @@ typedef _Packed struct t_TgecMiiAccessMemMap
volatile uint32_t mdio_regaddr; /* 0x03c */
} _PackedType t_TgecMiiAccessMemMap ;
-#define MEM_MAP_END
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(pop)
#endif /* defined(__MWERKS__) && ... */
diff --git a/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec.c b/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec.c
new file mode 100644
index 000000000000..0a1b31f11d5f
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec.c
@@ -0,0 +1,237 @@
+/*
+ * Copyright 2008-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/******************************************************************************
+
+ @File fm_macsec.c
+
+ @Description FM MACSEC driver routines implementation.
+*//***************************************************************************/
+
+#include "std_ext.h"
+#include "error_ext.h"
+#include "xx_ext.h"
+#include "string_ext.h"
+#include "sprint_ext.h"
+#include "debug_ext.h"
+
+#include "fm_macsec.h"
+
+
+/****************************************/
+/* API Init unit functions */
+/****************************************/
+t_Handle FM_MACSEC_Config(t_FmMacsecParams *p_FmMacsecParam)
+{
+ t_FmMacsecControllerDriver *p_FmMacsecControllerDriver;
+
+ SANITY_CHECK_RETURN_VALUE(p_FmMacsecParam, E_INVALID_HANDLE, NULL);
+
+ if (p_FmMacsecParam->guestMode)
+ p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)FM_MACSEC_GUEST_Config(p_FmMacsecParam);
+ else
+ p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)FM_MACSEC_MASTER_Config(p_FmMacsecParam);
+
+ if (!p_FmMacsecControllerDriver)
+ return NULL;
+
+ return (t_Handle)p_FmMacsecControllerDriver;
+}
+
+t_Error FM_MACSEC_Init(t_Handle h_FmMacsec)
+{
+ t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacsecControllerDriver->f_FM_MACSEC_Init)
+ return p_FmMacsecControllerDriver->f_FM_MACSEC_Init(h_FmMacsec);
+
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+t_Error FM_MACSEC_Free(t_Handle h_FmMacsec)
+{
+ t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacsecControllerDriver->f_FM_MACSEC_Free)
+ return p_FmMacsecControllerDriver->f_FM_MACSEC_Free(h_FmMacsec);
+
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+t_Error FM_MACSEC_ConfigUnknownSciFrameTreatment(t_Handle h_FmMacsec, e_FmMacsecUnknownSciFrameTreatment treatMode)
+{
+ t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigUnknownSciFrameTreatment)
+ return p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigUnknownSciFrameTreatment(h_FmMacsec, treatMode);
+
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+t_Error FM_MACSEC_ConfigInvalidTagsFrameTreatment(t_Handle h_FmMacsec, bool deliverUncontrolled)
+{
+ t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigInvalidTagsFrameTreatment)
+ return p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigInvalidTagsFrameTreatment(h_FmMacsec, deliverUncontrolled);
+
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+t_Error FM_MACSEC_ConfigEncryptWithNoChangedTextFrameTreatment(t_Handle h_FmMacsec, bool discardUncontrolled)
+{
+ t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigEncryptWithNoChangedTextFrameTreatment)
+ return p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigEncryptWithNoChangedTextFrameTreatment(h_FmMacsec, discardUncontrolled);
+
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+t_Error FM_MACSEC_ConfigUntagFrameTreatment(t_Handle h_FmMacsec, e_FmMacsecUntagFrameTreatment treatMode)
+{
+ t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigUntagFrameTreatment)
+ return p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigUntagFrameTreatment(h_FmMacsec, treatMode);
+
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+t_Error FM_MACSEC_ConfigPnExhaustionThreshold(t_Handle h_FmMacsec, uint32_t pnExhThr)
+{
+ t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigPnExhaustionThreshold)
+ return p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigPnExhaustionThreshold(h_FmMacsec, pnExhThr);
+
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+t_Error FM_MACSEC_ConfigKeysUnreadable(t_Handle h_FmMacsec)
+{
+ t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigKeysUnreadable)
+ return p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigKeysUnreadable(h_FmMacsec);
+
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+t_Error FM_MACSEC_ConfigSectagWithoutSCI(t_Handle h_FmMacsec)
+{
+ t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigSectagWithoutSCI)
+ return p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigSectagWithoutSCI(h_FmMacsec);
+
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+t_Error FM_MACSEC_ConfigException(t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable)
+{
+ t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigException)
+ return p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigException(h_FmMacsec, exception, enable);
+
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+t_Error FM_MACSEC_GetRevision(t_Handle h_FmMacsec, uint32_t *p_MacsecRevision)
+{
+ t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacsecControllerDriver->f_FM_MACSEC_GetRevision)
+ return p_FmMacsecControllerDriver->f_FM_MACSEC_GetRevision(h_FmMacsec, p_MacsecRevision);
+
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+
+t_Error FM_MACSEC_Enable(t_Handle h_FmMacsec)
+{
+ t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacsecControllerDriver->f_FM_MACSEC_Enable)
+ return p_FmMacsecControllerDriver->f_FM_MACSEC_Enable(h_FmMacsec);
+
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+t_Error FM_MACSEC_Disable(t_Handle h_FmMacsec)
+{
+ t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacsecControllerDriver->f_FM_MACSEC_Disable)
+ return p_FmMacsecControllerDriver->f_FM_MACSEC_Disable(h_FmMacsec);
+
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+t_Error FM_MACSEC_SetException(t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable)
+{
+ t_FmMacsecControllerDriver *p_FmMacsecControllerDriver = (t_FmMacsecControllerDriver *)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacsecControllerDriver->f_FM_MACSEC_SetException)
+ return p_FmMacsecControllerDriver->f_FM_MACSEC_SetException(h_FmMacsec, exception, enable);
+
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
diff --git a/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec.h b/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec.h
new file mode 100644
index 000000000000..fbe51875f92f
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec.h
@@ -0,0 +1,203 @@
+/*
+ * Copyright 2008-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/******************************************************************************
+ @File fm_macsec.h
+
+ @Description FM MACSEC internal structures and definitions.
+*//***************************************************************************/
+#ifndef __FM_MACSEC_H
+#define __FM_MACSEC_H
+
+#include "error_ext.h"
+#include "std_ext.h"
+#include "fm_macsec_ext.h"
+
+#include "fm_common.h"
+
+
+#define __ERR_MODULE__ MODULE_FM_MACSEC
+
+
+typedef struct
+{
+ t_Error (*f_FM_MACSEC_Init) (t_Handle h_FmMacsec);
+ t_Error (*f_FM_MACSEC_Free) (t_Handle h_FmMacsec);
+
+ t_Error (*f_FM_MACSEC_ConfigUnknownSciFrameTreatment) (t_Handle h_FmMacsec, e_FmMacsecUnknownSciFrameTreatment treatMode);
+ t_Error (*f_FM_MACSEC_ConfigInvalidTagsFrameTreatment) (t_Handle h_FmMacsec, bool deliverUncontrolled);
+ t_Error (*f_FM_MACSEC_ConfigEncryptWithNoChangedTextFrameTreatment) (t_Handle h_FmMacsec, bool discardUncontrolled);
+ t_Error (*f_FM_MACSEC_ConfigChangedTextWithNoEncryptFrameTreatment) (t_Handle h_FmMacsec, bool deliverUncontrolled);
+ t_Error (*f_FM_MACSEC_ConfigUntagFrameTreatment) (t_Handle h_FmMacsec, e_FmMacsecUntagFrameTreatment treatMode);
+ t_Error (*f_FM_MACSEC_ConfigOnlyScbIsSetFrameTreatment) (t_Handle h_FmMacsec, bool deliverUncontrolled);
+ t_Error (*f_FM_MACSEC_ConfigPnExhaustionThreshold) (t_Handle h_FmMacsec, uint32_t pnExhThr);
+ t_Error (*f_FM_MACSEC_ConfigKeysUnreadable) (t_Handle h_FmMacsec);
+ t_Error (*f_FM_MACSEC_ConfigSectagWithoutSCI) (t_Handle h_FmMacsec);
+ t_Error (*f_FM_MACSEC_ConfigException) (t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable);
+
+ t_Error (*f_FM_MACSEC_GetRevision) (t_Handle h_FmMacsec, uint32_t *p_MacsecRevision);
+ t_Error (*f_FM_MACSEC_Enable) (t_Handle h_FmMacsec);
+ t_Error (*f_FM_MACSEC_Disable) (t_Handle h_FmMacsec);
+ t_Error (*f_FM_MACSEC_SetException) (t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable);
+
+} t_FmMacsecControllerDriver;
+
+t_Handle FM_MACSEC_GUEST_Config(t_FmMacsecParams *p_FmMacsecParam);
+t_Handle FM_MACSEC_MASTER_Config(t_FmMacsecParams *p_FmMacsecParams);
+
+/***********************************************************************/
+/* MACSEC internal routines */
+/***********************************************************************/
+
+/**************************************************************************//**
+
+ @Group FM_MACSEC_InterModule_grp FM MACSEC Inter-Module Unit
+
+ @Description FM MACSEC Inter Module functions -
+ These are not User API routines but routines that may be called
+ from other modules. This will be the case in a single core environment,
+ where instead of using the XX messaging mechanism, the routines may be
+ called from other modules. In a multicore environment, the other modules may
+ be run by other cores and therefore these routines may not be called directly.
+
+ @{
+*//***************************************************************************/
+
+#define MAX_NUM_OF_SA_PER_SC 4
+
+typedef enum
+{
+ e_SC_RX = 0,
+ e_SC_TX
+} e_ScType;
+
+typedef enum
+{
+ e_SC_SA_A = 0,
+ e_SC_SA_B ,
+ e_SC_SA_C ,
+ e_SC_SA_D
+} e_ScSaId;
+
+typedef struct
+{
+ uint32_t scId;
+ macsecSCI_t sci;
+ bool replayProtect;
+ uint32_t replayWindow;
+ e_FmMacsecValidFrameBehavior validateFrames;
+ uint16_t confidentialityOffset;
+ e_FmMacsecSecYCipherSuite cipherSuite;
+} t_RxScParams;
+
+typedef struct
+{
+ uint32_t scId;
+ macsecSCI_t sci;
+ bool protectFrames;
+ e_FmMacsecSciInsertionMode sciInsertionMode;
+ bool confidentialityEnable;
+ uint16_t confidentialityOffset;
+ e_FmMacsecSecYCipherSuite cipherSuite;
+} t_TxScParams;
+
+typedef enum e_FmMacsecGlobalExceptions {
+ e_FM_MACSEC_EX_TX_SC, /**< Tx Sc 0 frame discarded error. */
+ e_FM_MACSEC_EX_ECC /**< MACSEC memory ECC multiple-bit error. */
+} e_FmMacsecGlobalExceptions;
+
+typedef enum e_FmMacsecGlobalEvents {
+ e_FM_MACSEC_EV_TX_SC_NEXT_PN /**< Tx Sc 0 Next Pn exhaustion threshold reached. */
+} e_FmMacsecGlobalEvents;
+
+/**************************************************************************//**
+ @Description Enum for inter-module interrupts registration
+*//***************************************************************************/
+typedef enum e_FmMacsecEventModules{
+ e_FM_MACSEC_MOD_SC_TX,
+ e_FM_MACSEC_MOD_DUMMY_LAST
+} e_FmMacsecEventModules;
+
+typedef enum e_FmMacsecInterModuleEvent {
+ e_FM_MACSEC_EV_SC_TX,
+ e_FM_MACSEC_EV_ERR_SC_TX,
+ e_FM_MACSEC_EV_DUMMY_LAST
+} e_FmMacsecInterModuleEvent;
+
+#define NUM_OF_INTER_MODULE_EVENTS (NUM_OF_TX_SC * 2)
+
+#define GET_MACSEC_MODULE_EVENT(mod, id, intrType, event) \
+ switch(mod){ \
+ case e_FM_MACSEC_MOD_SC_TX: \
+ event = (intrType == e_FM_INTR_TYPE_ERR) ? \
+ e_FM_MACSEC_EV_ERR_SC_TX: \
+ e_FM_MACSEC_EV_SC_TX; \
+ event += (uint8_t)(2 * id);break; \
+ break; \
+ default:event = e_FM_MACSEC_EV_DUMMY_LAST; \
+ break;}
+
+void FmMacsecRegisterIntr(t_Handle h_FmMacsec,
+ e_FmMacsecEventModules module,
+ uint8_t modId,
+ e_FmIntrType intrType,
+ void (*f_Isr) (t_Handle h_Arg, uint32_t id),
+ t_Handle h_Arg);
+
+void FmMacsecUnregisterIntr(t_Handle h_FmMacsec,
+ e_FmMacsecEventModules module,
+ uint8_t modId,
+ e_FmIntrType intrType);
+
+t_Error FmMacsecAllocScs(t_Handle h_FmMacsec, e_ScType type, bool isPtp, uint32_t numOfScs, uint32_t *p_ScIds);
+t_Error FmMacsecFreeScs(t_Handle h_FmMacsec, e_ScType type, uint32_t numOfScs, uint32_t *p_ScIds);
+t_Error FmMacsecCreateRxSc(t_Handle h_FmMacsec, t_RxScParams *p_RxScParams);
+t_Error FmMacsecDeleteRxSc(t_Handle h_FmMacsec, uint32_t scId);
+t_Error FmMacsecCreateTxSc(t_Handle h_FmMacsec, t_TxScParams *p_RxScParams);
+t_Error FmMacsecDeleteTxSc(t_Handle h_FmMacsec, uint32_t scId);
+t_Error FmMacsecCreateRxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, macsecAN_t an, uint32_t lowestPn, macsecSAKey_t key);
+t_Error FmMacsecCreateTxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, macsecSAKey_t key);
+t_Error FmMacsecDeleteRxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId);
+t_Error FmMacsecDeleteTxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId);
+t_Error FmMacsecRxSaSetReceive(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, bool enableReceive);
+t_Error FmMacsecRxSaUpdateNextPn(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, uint32_t updtNextPN);
+t_Error FmMacsecRxSaUpdateLowestPn(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, uint32_t updtLowestPN);
+t_Error FmMacsecTxSaSetActive(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, macsecAN_t an);
+t_Error FmMacsecTxSaGetActive(t_Handle h_FmMacsec, uint32_t scId, macsecAN_t *p_An);
+t_Error FmMacsecSetPTP(t_Handle h_FmMacsec, bool enable);
+
+t_Error FmMacsecSetException(t_Handle h_FmMacsec, e_FmMacsecGlobalExceptions exception, uint32_t scId, bool enable);
+t_Error FmMacsecSetEvent(t_Handle h_FmMacsec, e_FmMacsecGlobalEvents event, uint32_t scId, bool enable);
+
+
+
+#endif /* __FM_MACSEC_H */
diff --git a/sys/contrib/ncsw/etc/sprint.c b/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_guest.c
index 6f9bdf94ffe5..31d789d042a7 100644
--- a/sys/contrib/ncsw/etc/sprint.c
+++ b/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_guest.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2015 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,52 +30,30 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*------------------------------------------------------*/
-/* File: sprint.c */
-/* */
-/* Description: */
-/* Debug routines (externals) */
-/*------------------------------------------------------*/
-#include "string_ext.h"
-#include "stdlib_ext.h"
-#include "ctype_ext.h"
-#include "stdarg_ext.h"
-#include "sprint_ext.h"
-#include "std_ext.h"
-#include "xx_ext.h"
+/******************************************************************************
+ @File fm_macsec.c
+ @Description FM MACSEC driver routines implementation.
+*//***************************************************************************/
-int Sprint(char * buf, const char *fmt, ...)
-{
- va_list args;
- int i;
-
- va_start(args, fmt);
- i=vsprintf(buf,fmt,args);
- va_end(args);
- return i;
-}
+#include "std_ext.h"
+#include "error_ext.h"
+#include "xx_ext.h"
+#include "string_ext.h"
+#include "sprint_ext.h"
+#include "debug_ext.h"
+#include "fm_macsec.h"
-int Snprint(char * buf, uint32_t size, const char *fmt, ...)
-{
- va_list args;
- int i;
- va_start(args, fmt);
- i=vsnprintf(buf,size,fmt,args);
- va_end(args);
- return i;
-}
+/****************************************/
+/* static functions */
+/****************************************/
-#ifndef NCSW_VXWORKS
-int Sscan(const char * buf, const char * fmt, ...)
+/****************************************/
+/* API Init unit functions */
+/****************************************/
+t_Handle FM_MACSEC_GUEST_Config(t_FmMacsecParams *p_FmMacsecParam)
{
- va_list args;
- int i;
-
- va_start(args,fmt);
- i = vsscanf(buf,fmt,args);
- va_end(args);
- return i;
+ UNUSED(p_FmMacsecParam);
+ return NULL;
}
-#endif /* NCSW_VXWORKS */
diff --git a/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_master.c b/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_master.c
new file mode 100644
index 000000000000..623612aca2d0
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_master.c
@@ -0,0 +1,1031 @@
+/*
+ * Copyright 2008-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/******************************************************************************
+ @File fm_macsec.c
+
+ @Description FM MACSEC driver routines implementation.
+*//***************************************************************************/
+
+#include "std_ext.h"
+#include "error_ext.h"
+#include "xx_ext.h"
+#include "string_ext.h"
+#include "sprint_ext.h"
+#include "fm_mac_ext.h"
+
+#include "fm_macsec_master.h"
+
+
+extern uint16_t FM_MAC_GetMaxFrameLength(t_Handle FmMac);
+
+
+/****************************************/
+/* static functions */
+/****************************************/
+static t_Error CheckFmMacsecParameters(t_FmMacsec *p_FmMacsec)
+{
+ if (!p_FmMacsec->f_Exception)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Exceptions callback not provided"));
+
+ return E_OK;
+}
+
+static void UnimplementedIsr(t_Handle h_Arg, uint32_t id)
+{
+ UNUSED(h_Arg); UNUSED(id);
+
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Unimplemented Isr!"));
+}
+
+static void MacsecEventIsr(t_Handle h_FmMacsec)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ uint32_t events,event,i;
+
+ SANITY_CHECK_RETURN(p_FmMacsec, E_INVALID_HANDLE);
+
+ events = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->evr);
+ events |= GET_UINT32(p_FmMacsec->p_FmMacsecRegs->ever);
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->evr,events);
+
+ for (i=0; i<NUM_OF_TX_SC; i++)
+ if (events & FM_MACSEC_EV_TX_SC_NEXT_PN(i))
+ {
+ GET_MACSEC_MODULE_EVENT(e_FM_MACSEC_MOD_SC_TX, i, e_FM_INTR_TYPE_NORMAL, event);
+ p_FmMacsec->intrMng[event].f_Isr(p_FmMacsec->intrMng[event].h_SrcHandle, i);
+ }
+}
+
+static void MacsecErrorIsr(t_Handle h_FmMacsec)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ uint32_t errors,error,i;
+
+ SANITY_CHECK_RETURN(p_FmMacsec, E_INVALID_HANDLE);
+
+ errors = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->err);
+ errors |= GET_UINT32(p_FmMacsec->p_FmMacsecRegs->erer);
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->err,errors);
+
+ for (i=0; i<NUM_OF_TX_SC; i++)
+ if (errors & FM_MACSEC_EX_TX_SC(i))
+ {
+ GET_MACSEC_MODULE_EVENT(e_FM_MACSEC_MOD_SC_TX, i, e_FM_INTR_TYPE_ERR, error);
+ p_FmMacsec->intrMng[error].f_Isr(p_FmMacsec->intrMng[error].h_SrcHandle, i);
+ }
+
+ if (errors & FM_MACSEC_EX_ECC)
+ {
+ uint8_t eccType;
+ uint32_t tmpReg;
+
+ tmpReg = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->meec);
+ ASSERT_COND(tmpReg & MECC_CAP);
+ eccType = (uint8_t)((tmpReg & MECC_CET) >> MECC_CET_SHIFT);
+
+ if (!eccType && (p_FmMacsec->userExceptions & FM_MACSEC_USER_EX_SINGLE_BIT_ECC))
+ p_FmMacsec->f_Exception(p_FmMacsec->h_App,e_FM_MACSEC_EX_SINGLE_BIT_ECC);
+ else if (eccType && (p_FmMacsec->userExceptions & FM_MACSEC_USER_EX_MULTI_BIT_ECC))
+ p_FmMacsec->f_Exception(p_FmMacsec->h_App,e_FM_MACSEC_EX_MULTI_BIT_ECC);
+ else
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->meec,tmpReg);
+ }
+}
+
+static t_Error MacsecInit(t_Handle h_FmMacsec)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ t_FmMacsecDriverParam *p_FmMacsecDriverParam = NULL;
+ uint32_t tmpReg,i,macId;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
+
+ CHECK_INIT_PARAMETERS(p_FmMacsec, CheckFmMacsecParameters);
+
+ p_FmMacsecDriverParam = p_FmMacsec->p_FmMacsecDriverParam;
+
+ for (i=0;i<e_FM_MACSEC_EV_DUMMY_LAST;i++)
+ p_FmMacsec->intrMng[i].f_Isr = UnimplementedIsr;
+
+ tmpReg = 0;
+ tmpReg |= (p_FmMacsecDriverParam->changedTextWithNoEncryptDeliverUncontrolled << CFG_UECT_SHIFT)|
+ (p_FmMacsecDriverParam->onlyScbIsSetDeliverUncontrolled << CFG_ESCBT_SHIFT) |
+ (p_FmMacsecDriverParam->unknownSciTreatMode << CFG_USFT_SHIFT) |
+ (p_FmMacsecDriverParam->invalidTagsDeliverUncontrolled << CFG_ITT_SHIFT) |
+ (p_FmMacsecDriverParam->encryptWithNoChangedTextDiscardUncontrolled << CFG_KFT_SHIFT) |
+ (p_FmMacsecDriverParam->untagTreatMode << CFG_UFT_SHIFT) |
+ (p_FmMacsecDriverParam->keysUnreadable << CFG_KSS_SHIFT) |
+ (p_FmMacsecDriverParam->reservedSc0 << CFG_S0I_SHIFT) |
+ (p_FmMacsecDriverParam->byPassMode << CFG_BYPN_SHIFT);
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->cfg, tmpReg);
+
+ tmpReg = FM_MAC_GetMaxFrameLength(p_FmMacsec->h_FmMac);
+ /* At least Ethernet FCS (4 bytes) overhead must be subtracted from MFL.
+ * In addition, the SCI (8 bytes) overhead might be subtracted as well. */
+ tmpReg -= p_FmMacsecDriverParam->mflSubtract;
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->mfl, tmpReg);
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->tpnet, p_FmMacsecDriverParam->pnExhThr);
+
+ if (!p_FmMacsec->userExceptions)
+ p_FmMacsec->exceptions &= ~FM_MACSEC_EX_ECC;
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->erer, p_FmMacsec->exceptions);
+
+ p_FmMacsec->numRxScAvailable = NUM_OF_RX_SC;
+ if (p_FmMacsecDriverParam->reservedSc0)
+ p_FmMacsec->numRxScAvailable --;
+ p_FmMacsec->numTxScAvailable = NUM_OF_TX_SC;
+
+ XX_Free(p_FmMacsecDriverParam);
+ p_FmMacsec->p_FmMacsecDriverParam = NULL;
+
+ FM_MAC_GetId(p_FmMacsec->h_FmMac, &macId);
+ FmRegisterIntr(p_FmMacsec->h_Fm,
+ e_FM_MOD_MACSEC,
+ (uint8_t)macId,
+ e_FM_INTR_TYPE_NORMAL,
+ MacsecEventIsr,
+ p_FmMacsec);
+
+ FmRegisterIntr(p_FmMacsec->h_Fm,
+ e_FM_MOD_MACSEC,
+ 0,
+ e_FM_INTR_TYPE_ERR,
+ MacsecErrorIsr,
+ p_FmMacsec);
+
+ return E_OK;
+}
+
+static t_Error MacsecFree(t_Handle h_FmMacsec)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ uint32_t macId;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
+
+ FM_MAC_GetId(p_FmMacsec->h_FmMac, &macId);
+ FmUnregisterIntr(p_FmMacsec->h_Fm,
+ e_FM_MOD_MACSEC,
+ (uint8_t)macId,
+ e_FM_INTR_TYPE_NORMAL);
+
+ FmUnregisterIntr(p_FmMacsec->h_Fm,
+ e_FM_MOD_MACSEC,
+ 0,
+ e_FM_INTR_TYPE_ERR);
+
+ if (p_FmMacsec->rxScSpinLock)
+ XX_FreeSpinlock(p_FmMacsec->rxScSpinLock);
+ if (p_FmMacsec->txScSpinLock)
+ XX_FreeSpinlock(p_FmMacsec->txScSpinLock);
+
+ XX_Free(p_FmMacsec);
+
+ return E_OK;
+}
+
+static t_Error MacsecConfigUnknownSciFrameTreatment(t_Handle h_FmMacsec, e_FmMacsecUnknownSciFrameTreatment treatMode)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
+
+ p_FmMacsec->p_FmMacsecDriverParam->unknownSciTreatMode = treatMode;
+
+ return E_OK;
+}
+
+static t_Error MacsecConfigInvalidTagsFrameTreatment(t_Handle h_FmMacsec, bool deliverUncontrolled)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
+
+ p_FmMacsec->p_FmMacsecDriverParam->invalidTagsDeliverUncontrolled = deliverUncontrolled;
+
+ return E_OK;
+}
+
+static t_Error MacsecConfigChangedTextWithNoEncryptFrameTreatment(t_Handle h_FmMacsec, bool deliverUncontrolled)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
+
+ p_FmMacsec->p_FmMacsecDriverParam->changedTextWithNoEncryptDeliverUncontrolled = deliverUncontrolled;
+
+ return E_OK;
+}
+
+static t_Error MacsecConfigOnlyScbIsSetFrameTreatment(t_Handle h_FmMacsec, bool deliverUncontrolled)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
+
+ p_FmMacsec->p_FmMacsecDriverParam->onlyScbIsSetDeliverUncontrolled = deliverUncontrolled;
+
+ return E_OK;
+}
+
+static t_Error MacsecConfigEncryptWithNoChangedTextFrameTreatment(t_Handle h_FmMacsec, bool discardUncontrolled)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
+
+ p_FmMacsec->p_FmMacsecDriverParam->encryptWithNoChangedTextDiscardUncontrolled = discardUncontrolled;
+
+ return E_OK;
+}
+
+static t_Error MacsecConfigUntagFrameTreatment(t_Handle h_FmMacsec, e_FmMacsecUntagFrameTreatment treatMode)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
+
+ p_FmMacsec->p_FmMacsecDriverParam->untagTreatMode = treatMode;
+
+ return E_OK;
+}
+
+static t_Error MacsecConfigPnExhaustionThreshold(t_Handle h_FmMacsec, uint32_t pnExhThr)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
+
+ p_FmMacsec->p_FmMacsecDriverParam->pnExhThr = pnExhThr;
+
+ return E_OK;
+}
+
+static t_Error MacsecConfigKeysUnreadable(t_Handle h_FmMacsec)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
+
+ p_FmMacsec->p_FmMacsecDriverParam->keysUnreadable = TRUE;
+
+ return E_OK;
+}
+
+static t_Error MacsecConfigSectagWithoutSCI(t_Handle h_FmMacsec)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
+
+ p_FmMacsec->p_FmMacsecDriverParam->sectagOverhead -= MACSEC_SCI_SIZE;
+ p_FmMacsec->p_FmMacsecDriverParam->mflSubtract += MACSEC_SCI_SIZE;
+
+ return E_OK;
+}
+
+static t_Error MacsecConfigException(t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ uint32_t bitMask = 0;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
+
+ GET_USER_EXCEPTION_FLAG(bitMask, exception);
+ if (bitMask)
+ {
+ if (enable)
+ p_FmMacsec->userExceptions |= bitMask;
+ else
+ p_FmMacsec->userExceptions &= ~bitMask;
+ }
+ else
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
+
+ return E_OK;
+}
+
+static t_Error MacsecGetRevision(t_Handle h_FmMacsec, uint32_t *p_MacsecRevision)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
+
+ *p_MacsecRevision = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->ip_rev1);
+
+ return E_OK;
+}
+
+static t_Error MacsecEnable(t_Handle h_FmMacsec)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ uint32_t tmpReg;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
+
+ tmpReg = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->cfg);
+ tmpReg |= CFG_BYPN;
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->cfg,tmpReg);
+
+ return E_OK;
+}
+
+static t_Error MacsecDisable(t_Handle h_FmMacsec)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ uint32_t tmpReg;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
+
+ tmpReg = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->cfg);
+ tmpReg &= ~CFG_BYPN;
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->cfg,tmpReg);
+
+ return E_OK;
+}
+
+static t_Error MacsecSetException(t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ uint32_t bitMask;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
+
+ GET_USER_EXCEPTION_FLAG(bitMask, exception);
+ if (bitMask)
+ {
+ if (enable)
+ p_FmMacsec->userExceptions |= bitMask;
+ else
+ p_FmMacsec->userExceptions &= ~bitMask;
+ }
+ else
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
+
+ if (!p_FmMacsec->userExceptions)
+ p_FmMacsec->exceptions &= ~FM_MACSEC_EX_ECC;
+ else
+ p_FmMacsec->exceptions |= FM_MACSEC_EX_ECC;
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->erer, p_FmMacsec->exceptions);
+
+ return E_OK;
+}
+
+static void InitFmMacsecControllerDriver(t_FmMacsecControllerDriver *p_FmMacsecControllerDriver)
+{
+ p_FmMacsecControllerDriver->f_FM_MACSEC_Init = MacsecInit;
+ p_FmMacsecControllerDriver->f_FM_MACSEC_Free = MacsecFree;
+ p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigUnknownSciFrameTreatment = MacsecConfigUnknownSciFrameTreatment;
+ p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigInvalidTagsFrameTreatment = MacsecConfigInvalidTagsFrameTreatment;
+ p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigEncryptWithNoChangedTextFrameTreatment = MacsecConfigEncryptWithNoChangedTextFrameTreatment;
+ p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigUntagFrameTreatment = MacsecConfigUntagFrameTreatment;
+ p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigChangedTextWithNoEncryptFrameTreatment = MacsecConfigChangedTextWithNoEncryptFrameTreatment;
+ p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigOnlyScbIsSetFrameTreatment = MacsecConfigOnlyScbIsSetFrameTreatment;
+ p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigPnExhaustionThreshold = MacsecConfigPnExhaustionThreshold;
+ p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigKeysUnreadable = MacsecConfigKeysUnreadable;
+ p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigSectagWithoutSCI = MacsecConfigSectagWithoutSCI;
+ p_FmMacsecControllerDriver->f_FM_MACSEC_ConfigException = MacsecConfigException;
+ p_FmMacsecControllerDriver->f_FM_MACSEC_GetRevision = MacsecGetRevision;
+ p_FmMacsecControllerDriver->f_FM_MACSEC_Enable = MacsecEnable;
+ p_FmMacsecControllerDriver->f_FM_MACSEC_Disable = MacsecDisable;
+ p_FmMacsecControllerDriver->f_FM_MACSEC_SetException = MacsecSetException;
+}
+
+/****************************************/
+/* Inter-Module functions */
+/****************************************/
+
+void FmMacsecRegisterIntr(t_Handle h_FmMacsec,
+ e_FmMacsecEventModules module,
+ uint8_t modId,
+ e_FmIntrType intrType,
+ void (*f_Isr) (t_Handle h_Arg, uint32_t id),
+ t_Handle h_Arg)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ uint8_t event= 0;
+
+ SANITY_CHECK_RETURN(p_FmMacsec, E_INVALID_HANDLE);
+
+ GET_MACSEC_MODULE_EVENT(module, modId, intrType, event);
+
+ ASSERT_COND(event != e_FM_MACSEC_EV_DUMMY_LAST);
+ p_FmMacsec->intrMng[event].f_Isr = f_Isr;
+ p_FmMacsec->intrMng[event].h_SrcHandle = h_Arg;
+}
+
+void FmMacsecUnregisterIntr(t_Handle h_FmMacsec,
+ e_FmMacsecEventModules module,
+ uint8_t modId,
+ e_FmIntrType intrType)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ uint8_t event= 0;
+
+ SANITY_CHECK_RETURN(p_FmMacsec, E_INVALID_HANDLE);
+
+ GET_MACSEC_MODULE_EVENT(module, modId,intrType, event);
+
+ ASSERT_COND(event != e_FM_MACSEC_EV_DUMMY_LAST);
+ p_FmMacsec->intrMng[event].f_Isr = NULL;
+ p_FmMacsec->intrMng[event].h_SrcHandle = NULL;
+}
+
+t_Error FmMacsecAllocScs(t_Handle h_FmMacsec, e_ScType type, bool isPtp, uint32_t numOfScs, uint32_t *p_ScIds)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ t_Error err = E_OK;
+ bool *p_ScTable;
+ uint32_t *p_ScAvailable,i;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_ScIds, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(numOfScs, E_INVALID_HANDLE);
+
+ if (type == e_SC_RX)
+ {
+ p_ScTable = (bool *)p_FmMacsec->rxScTable;
+ p_ScAvailable = &p_FmMacsec->numRxScAvailable;
+ i = (NUM_OF_RX_SC - 1);
+ }
+ else
+ {
+ p_ScTable = (bool *)p_FmMacsec->txScTable;
+ p_ScAvailable = &p_FmMacsec->numTxScAvailable;
+ i = (NUM_OF_TX_SC - 1);
+
+ }
+ if (*p_ScAvailable < numOfScs)
+ RETURN_ERROR(MINOR, E_NOT_AVAILABLE, ("Not enough SCs available"));
+
+ if (isPtp)
+ {
+ i = 0;
+ if (p_ScTable[i])
+ RETURN_ERROR(MINOR, E_NOT_AVAILABLE, ("Sc 0 Not available"));
+ }
+
+ for (;numOfScs;i--)
+ {
+ if (p_ScTable[i])
+ continue;
+ numOfScs --;
+ (*p_ScAvailable)--;
+ p_ScIds[numOfScs] = i;
+ p_ScTable[i] = TRUE;
+ }
+
+ return err;
+}
+
+t_Error FmMacsecFreeScs(t_Handle h_FmMacsec, e_ScType type, uint32_t numOfScs, uint32_t *p_ScIds)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ t_Error err = E_OK;
+ bool *p_ScTable;
+ uint32_t *p_ScAvailable,maxNumOfSc,i;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_ScIds, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(numOfScs, E_INVALID_HANDLE);
+
+ if (type == e_SC_RX)
+ {
+ p_ScTable = (bool *)p_FmMacsec->rxScTable;
+ p_ScAvailable = &p_FmMacsec->numRxScAvailable;
+ maxNumOfSc = NUM_OF_RX_SC;
+ }
+ else
+ {
+ p_ScTable = (bool *)p_FmMacsec->txScTable;
+ p_ScAvailable = &p_FmMacsec->numTxScAvailable;
+ maxNumOfSc = NUM_OF_TX_SC;
+ }
+
+ if ((*p_ScAvailable + numOfScs) > maxNumOfSc)
+ RETURN_ERROR(MINOR, E_FULL, ("Too much SCs"));
+
+ for (i=0;i<numOfScs;i++)
+ {
+ p_ScTable[p_ScIds[i]] = FALSE;
+ (*p_ScAvailable)++;
+ }
+
+ return err;
+
+}
+
+t_Error FmMacsecSetPTP(t_Handle h_FmMacsec, bool enable)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ uint32_t tmpReg = 0;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+
+ tmpReg = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->cfg);
+ if (enable && (tmpReg & CFG_S0I))
+ RETURN_ERROR(MINOR, E_INVALID_STATE, ("MACSEC already in point-to-point mode"));
+
+ if (enable)
+ tmpReg |= CFG_S0I;
+ else
+ tmpReg &= ~CFG_S0I;
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->cfg, tmpReg);
+
+ return E_OK;
+}
+
+t_Error FmMacsecCreateRxSc(t_Handle h_FmMacsec, t_RxScParams *p_RxScParams)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ t_Error err = E_OK;
+ uint32_t tmpReg = 0, intFlags;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_RxScParams, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_RxScParams->scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
+
+ intFlags = XX_LockIntrSpinlock(p_FmMacsec->rxScSpinLock);
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsca, p_RxScParams->scId);
+ tmpReg = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsccfg);
+ if (tmpReg & RX_SCCFG_SCI_EN_MASK)
+ {
+ XX_UnlockIntrSpinlock(p_FmMacsec->rxScSpinLock, intFlags);
+ RETURN_ERROR(MINOR, E_INVALID_STATE, ("Rx Sc %d must be disable",p_RxScParams->scId));
+ }
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsci1h, GET_SCI_FIRST_HALF(p_RxScParams->sci));
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsci2h, GET_SCI_SECOND_HALF(p_RxScParams->sci));
+ tmpReg |= ((p_RxScParams->replayProtect << RX_SCCFG_RP_SHIFT) & RX_SCCFG_RP_MASK);
+ tmpReg |= ((p_RxScParams->validateFrames << RX_SCCFG_VF_SHIFT) & RX_SCCFG_VF_MASK);
+ tmpReg |= ((p_RxScParams->confidentialityOffset << RX_SCCFG_CO_SHIFT) & RX_SCCFG_CO_MASK);
+ tmpReg |= RX_SCCFG_SCI_EN_MASK;
+ tmpReg |= (p_RxScParams->cipherSuite << RX_SCCFG_CS_SHIFT);
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsccfg, tmpReg);
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rpw, p_RxScParams->replayWindow);
+
+ XX_UnlockIntrSpinlock(p_FmMacsec->rxScSpinLock, intFlags);
+
+ return err;
+}
+
+t_Error FmMacsecDeleteRxSc(t_Handle h_FmMacsec, uint32_t scId)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ t_Error err = E_OK;
+ uint32_t tmpReg = 0, intFlags;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
+
+ intFlags = XX_LockIntrSpinlock(p_FmMacsec->rxScSpinLock);
+
+ tmpReg &= ~RX_SCCFG_SCI_EN_MASK;
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsca, scId);
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsccfg, tmpReg);
+
+ XX_UnlockIntrSpinlock(p_FmMacsec->rxScSpinLock, intFlags);
+
+ return err;
+}
+
+t_Error FmMacsecCreateTxSc(t_Handle h_FmMacsec, t_TxScParams *p_TxScParams)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ t_Error err = E_OK;
+ uint32_t tmpReg = 0, intFlags;
+ bool alwaysIncludeSCI = FALSE, useES = FALSE, useSCB = FALSE;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_TxScParams, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_TxScParams->scId < NUM_OF_TX_SC, E_INVALID_HANDLE);
+
+ intFlags = XX_LockIntrSpinlock(p_FmMacsec->txScSpinLock);
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsca, p_TxScParams->scId);
+
+ tmpReg = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->txsccfg);
+ if (tmpReg & TX_SCCFG_SCE_MASK)
+ {
+ XX_UnlockIntrSpinlock(p_FmMacsec->txScSpinLock, intFlags);
+ RETURN_ERROR(MINOR, E_INVALID_STATE, ("Tx Sc %d must be disable",p_TxScParams->scId));
+ }
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsci1h, GET_SCI_FIRST_HALF(p_TxScParams->sci));
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsci2h, GET_SCI_SECOND_HALF(p_TxScParams->sci));
+ alwaysIncludeSCI = (p_TxScParams->sciInsertionMode == e_FM_MACSEC_SCI_INSERTION_MODE_EXPLICIT_SECTAG);
+ useES = (p_TxScParams->sciInsertionMode == e_FM_MACSEC_SCI_INSERTION_MODE_EXPLICIT_MAC_SA);
+
+ tmpReg |= ((p_TxScParams->protectFrames << TX_SCCFG_PF_SHIFT) & TX_SCCFG_PF_MASK);
+ tmpReg |= ((alwaysIncludeSCI << TX_SCCFG_AIS_SHIFT) & TX_SCCFG_AIS_MASK);
+ tmpReg |= ((useES << TX_SCCFG_UES_SHIFT) & TX_SCCFG_UES_MASK);
+ tmpReg |= ((useSCB << TX_SCCFG_USCB_SHIFT) & TX_SCCFG_USCB_MASK);
+ tmpReg |= ((p_TxScParams->confidentialityEnable << TX_SCCFG_CE_SHIFT) & TX_SCCFG_CE_MASK);
+ tmpReg |= ((p_TxScParams->confidentialityOffset << TX_SCCFG_CO_SHIFT) & TX_SCCFG_CO_MASK);
+ tmpReg |= TX_SCCFG_SCE_MASK;
+ tmpReg |= (p_TxScParams->cipherSuite << TX_SCCFG_CS_SHIFT);
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsccfg, tmpReg);
+
+ XX_UnlockIntrSpinlock(p_FmMacsec->txScSpinLock, intFlags);
+
+ return err;
+}
+
+t_Error FmMacsecDeleteTxSc(t_Handle h_FmMacsec, uint32_t scId)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ t_Error err = E_OK;
+ uint32_t tmpReg = 0, intFlags;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_TX_SC, E_INVALID_HANDLE);
+
+ intFlags = XX_LockIntrSpinlock(p_FmMacsec->txScSpinLock);
+
+ tmpReg &= ~TX_SCCFG_SCE_MASK;
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsca, scId);
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsccfg, tmpReg);
+
+ XX_UnlockIntrSpinlock(p_FmMacsec->txScSpinLock, intFlags);
+
+ return err;
+}
+
+t_Error FmMacsecCreateRxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, macsecAN_t an, uint32_t lowestPn, macsecSAKey_t key)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ t_Error err = E_OK;
+ uint32_t tmpReg = 0, intFlags;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(saId < NUM_OF_SA_PER_RX_SC, E_INVALID_HANDLE);
+
+ intFlags = XX_LockIntrSpinlock(p_FmMacsec->rxScSpinLock);
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsca, scId);
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsanpn, DEFAULT_initNextPn);
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsalpn, lowestPn);
+ MemCpy8((void*)p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsak, key, sizeof(macsecSAKey_t));
+
+ tmpReg |= RX_SACFG_ACTIVE;
+ tmpReg |= ((an << RX_SACFG_AN_SHIFT) & RX_SACFG_AN_MASK);
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsacs, tmpReg);
+
+ XX_UnlockIntrSpinlock(p_FmMacsec->rxScSpinLock, intFlags);
+
+ return err;
+}
+
+t_Error FmMacsecCreateTxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, macsecSAKey_t key)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ t_Error err = E_OK;
+ uint32_t tmpReg = 0, intFlags;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(saId < NUM_OF_SA_PER_TX_SC, E_INVALID_HANDLE);
+
+ intFlags = XX_LockIntrSpinlock(p_FmMacsec->txScSpinLock);
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsca, scId);
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecTxScSa[saId].txsanpn, DEFAULT_initNextPn);
+ MemCpy8((void*)p_FmMacsec->p_FmMacsecRegs->fmMacsecTxScSa[saId].txsak, key, sizeof(macsecSAKey_t));
+
+ tmpReg |= TX_SACFG_ACTIVE;
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecTxScSa[saId].txsacs, tmpReg);
+
+ XX_UnlockIntrSpinlock(p_FmMacsec->txScSpinLock, intFlags);
+
+ return err;
+}
+
+t_Error FmMacsecDeleteRxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ t_Error err = E_OK;
+ uint32_t tmpReg = 0, i, intFlags;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(saId < NUM_OF_SA_PER_RX_SC, E_INVALID_HANDLE);
+
+ intFlags = XX_LockIntrSpinlock(p_FmMacsec->rxScSpinLock);
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsca, scId);
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsanpn, 0x0);
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsalpn, 0x0);
+ for (i=0; i<4; i++)
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsak[i], 0x0);
+
+ tmpReg |= RX_SACFG_ACTIVE;
+ tmpReg &= ~RX_SACFG_EN_MASK;
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsacs, tmpReg);
+
+ XX_UnlockIntrSpinlock(p_FmMacsec->rxScSpinLock, intFlags);
+
+ return err;
+}
+
+t_Error FmMacsecDeleteTxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ t_Error err = E_OK;
+ uint32_t tmpReg = 0, i, intFlags;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(saId < NUM_OF_SA_PER_TX_SC, E_INVALID_HANDLE);
+
+ intFlags = XX_LockIntrSpinlock(p_FmMacsec->txScSpinLock);
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsca, scId);
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecTxScSa[saId].txsanpn, 0x0);
+ for (i=0; i<4; i++)
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecTxScSa[saId].txsak[i], 0x0);
+
+ tmpReg |= TX_SACFG_ACTIVE;
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecTxScSa[saId].txsacs, tmpReg);
+
+ XX_UnlockIntrSpinlock(p_FmMacsec->txScSpinLock, intFlags);
+
+ return err;
+}
+
+t_Error FmMacsecRxSaSetReceive(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, bool enableReceive)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ t_Error err = E_OK;
+ uint32_t tmpReg = 0, intFlags;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(saId < NUM_OF_SA_PER_RX_SC, E_INVALID_HANDLE);
+
+ intFlags = XX_LockIntrSpinlock(p_FmMacsec->rxScSpinLock);
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsca, scId);
+ tmpReg = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsacs);
+ if (enableReceive)
+ tmpReg |= RX_SACFG_EN_MASK;
+ else
+ tmpReg &= ~RX_SACFG_EN_MASK;
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsacs, tmpReg);
+
+ XX_UnlockIntrSpinlock(p_FmMacsec->rxScSpinLock, intFlags);
+
+ return err;
+}
+
+t_Error FmMacsecRxSaUpdateNextPn(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, uint32_t updtNextPN)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ t_Error err = E_OK;
+ uint32_t intFlags;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(saId < NUM_OF_SA_PER_RX_SC, E_INVALID_HANDLE);
+
+ intFlags = XX_LockIntrSpinlock(p_FmMacsec->rxScSpinLock);
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsca, scId);
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsanpn, updtNextPN);
+
+ XX_UnlockIntrSpinlock(p_FmMacsec->rxScSpinLock, intFlags);
+
+ return err;
+}
+
+t_Error FmMacsecRxSaUpdateLowestPn(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, uint32_t updtLowestPN)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ t_Error err = E_OK;
+ uint32_t intFlags;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(saId < NUM_OF_SA_PER_RX_SC, E_INVALID_HANDLE);
+
+ intFlags = XX_LockIntrSpinlock(p_FmMacsec->rxScSpinLock);
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->rxsca, scId);
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->fmMacsecRxScSa[saId].rxsalpn, updtLowestPN);
+
+ XX_UnlockIntrSpinlock(p_FmMacsec->rxScSpinLock, intFlags);
+
+ return err;
+}
+
+t_Error FmMacsecTxSaSetActive(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, macsecAN_t an)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ t_Error err = E_OK;
+ uint32_t tmpReg = 0, intFlags;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(saId < NUM_OF_SA_PER_TX_SC, E_INVALID_HANDLE);
+
+ intFlags = XX_LockIntrSpinlock(p_FmMacsec->txScSpinLock);
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsca, scId);
+
+ tmpReg = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->txsccfg);
+
+ tmpReg |= ((an << TX_SCCFG_AN_SHIFT) & TX_SCCFG_AN_MASK);
+ tmpReg |= ((saId << TX_SCCFG_ASA_SHIFT) & TX_SCCFG_ASA_MASK);
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsccfg, tmpReg);
+
+ XX_UnlockIntrSpinlock(p_FmMacsec->txScSpinLock, intFlags);
+
+ return err;
+}
+
+t_Error FmMacsecTxSaGetActive(t_Handle h_FmMacsec, uint32_t scId, macsecAN_t *p_An)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ t_Error err = E_OK;
+ uint32_t tmpReg = 0, intFlags;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(scId < NUM_OF_RX_SC, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_An, E_INVALID_HANDLE);
+
+ intFlags = XX_LockIntrSpinlock(p_FmMacsec->txScSpinLock);
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->txsca, scId);
+
+ tmpReg = GET_UINT32(p_FmMacsec->p_FmMacsecRegs->txsccfg);
+
+ XX_UnlockIntrSpinlock(p_FmMacsec->txScSpinLock, intFlags);
+
+ *p_An = (macsecAN_t)((tmpReg & TX_SCCFG_AN_MASK) >> TX_SCCFG_AN_SHIFT);
+
+ return err;
+}
+
+t_Error FmMacsecSetException(t_Handle h_FmMacsec, e_FmMacsecGlobalExceptions exception, uint32_t scId, bool enable)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ uint32_t bitMask;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
+
+ GET_EXCEPTION_FLAG(bitMask, exception, scId);
+ if (bitMask)
+ {
+ if (enable)
+ p_FmMacsec->exceptions |= bitMask;
+ else
+ p_FmMacsec->exceptions &= ~bitMask;
+ }
+ else
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->erer, p_FmMacsec->exceptions);
+
+ return E_OK;
+}
+
+t_Error FmMacsecSetEvent(t_Handle h_FmMacsec, e_FmMacsecGlobalEvents event, uint32_t scId, bool enable)
+{
+ t_FmMacsec *p_FmMacsec = (t_FmMacsec*)h_FmMacsec;
+ uint32_t bitMask;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsec->p_FmMacsecDriverParam, E_INVALID_HANDLE);
+
+ GET_EVENT_FLAG(bitMask, event, scId);
+ if (bitMask)
+ {
+ if (enable)
+ p_FmMacsec->events |= bitMask;
+ else
+ p_FmMacsec->events &= ~bitMask;
+ }
+ else
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined event"));
+
+ WRITE_UINT32(p_FmMacsec->p_FmMacsecRegs->ever, p_FmMacsec->events);
+
+ return E_OK;
+}
+
+/****************************************/
+/* API Init unit functions */
+/****************************************/
+t_Handle FM_MACSEC_MASTER_Config(t_FmMacsecParams *p_FmMacsecParam)
+{
+ t_FmMacsec *p_FmMacsec;
+ uint32_t macId;
+
+ /* Allocate FM MACSEC structure */
+ p_FmMacsec = (t_FmMacsec *) XX_Malloc(sizeof(t_FmMacsec));
+ if (!p_FmMacsec)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM MACSEC driver structure"));
+ return NULL;
+ }
+ memset(p_FmMacsec, 0, sizeof(t_FmMacsec));
+ InitFmMacsecControllerDriver(&p_FmMacsec->fmMacsecControllerDriver);
+
+ /* Allocate the FM MACSEC driver's parameters structure */
+ p_FmMacsec->p_FmMacsecDriverParam = (t_FmMacsecDriverParam *)XX_Malloc(sizeof(t_FmMacsecDriverParam));
+ if (!p_FmMacsec->p_FmMacsecDriverParam)
+ {
+ XX_Free(p_FmMacsec);
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM MACSEC driver parameters"));
+ return NULL;
+ }
+ memset(p_FmMacsec->p_FmMacsecDriverParam, 0, sizeof(t_FmMacsecDriverParam));
+
+ /* Initialize FM MACSEC parameters which will be kept by the driver */
+ p_FmMacsec->h_Fm = p_FmMacsecParam->h_Fm;
+ p_FmMacsec->h_FmMac = p_FmMacsecParam->nonGuestParams.h_FmMac;
+ p_FmMacsec->p_FmMacsecRegs = (t_FmMacsecRegs *)UINT_TO_PTR(p_FmMacsecParam->nonGuestParams.baseAddr);
+ p_FmMacsec->f_Exception = p_FmMacsecParam->nonGuestParams.f_Exception;
+ p_FmMacsec->h_App = p_FmMacsecParam->nonGuestParams.h_App;
+ p_FmMacsec->userExceptions = DEFAULT_userExceptions;
+ p_FmMacsec->exceptions = DEFAULT_exceptions;
+ p_FmMacsec->events = DEFAULT_events;
+ p_FmMacsec->rxScSpinLock = XX_InitSpinlock();
+ p_FmMacsec->txScSpinLock = XX_InitSpinlock();
+
+ /* Initialize FM MACSEC driver parameters parameters (for initialization phase only) */
+ p_FmMacsec->p_FmMacsecDriverParam->unknownSciTreatMode = DEFAULT_unknownSciFrameTreatment;
+ p_FmMacsec->p_FmMacsecDriverParam->invalidTagsDeliverUncontrolled = DEFAULT_invalidTagsFrameTreatment;
+ p_FmMacsec->p_FmMacsecDriverParam->encryptWithNoChangedTextDiscardUncontrolled = DEFAULT_encryptWithNoChangedTextFrameTreatment;
+ p_FmMacsec->p_FmMacsecDriverParam->untagTreatMode = DEFAULT_untagFrameTreatment;
+ p_FmMacsec->p_FmMacsecDriverParam->keysUnreadable = DEFAULT_keysUnreadable;
+ p_FmMacsec->p_FmMacsecDriverParam->reservedSc0 = DEFAULT_sc0ReservedForPTP;
+ p_FmMacsec->p_FmMacsecDriverParam->byPassMode = !DEFAULT_normalMode;
+ p_FmMacsec->p_FmMacsecDriverParam->pnExhThr = DEFAULT_pnExhThr;
+ p_FmMacsec->p_FmMacsecDriverParam->sectagOverhead = DEFAULT_sectagOverhead;
+ p_FmMacsec->p_FmMacsecDriverParam->mflSubtract = DEFAULT_mflSubtract;
+ /* build the FM MACSEC master IPC address */
+ memset(p_FmMacsec->fmMacsecModuleName, 0, (sizeof(char))*MODULE_NAME_SIZE);
+ FM_MAC_GetId(p_FmMacsec->h_FmMac,&macId);
+ if (Sprint (p_FmMacsec->fmMacsecModuleName, "FM-%d-MAC-%d-MACSEC-Master",
+ FmGetId(p_FmMacsec->h_Fm),macId) != 24)
+ {
+ XX_Free(p_FmMacsec->p_FmMacsecDriverParam);
+ XX_Free(p_FmMacsec);
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
+ return NULL;
+ }
+ return p_FmMacsec;
+}
diff --git a/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_master.h b/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_master.h
new file mode 100644
index 000000000000..2296a0f10d54
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_master.h
@@ -0,0 +1,479 @@
+/*
+ * Copyright 2008-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/******************************************************************************
+ @File fm_macsec_master.h
+
+ @Description FM MACSEC internal structures and definitions.
+*//***************************************************************************/
+#ifndef __FM_MACSEC_MASTER_H
+#define __FM_MACSEC_MASTER_H
+
+#include "error_ext.h"
+#include "std_ext.h"
+
+#include "fm_macsec.h"
+
+
+#define MACSEC_ICV_SIZE 16
+#define MACSEC_SECTAG_SIZE 16
+#define MACSEC_SCI_SIZE 8
+#define MACSEC_FCS_SIZE 4
+
+/**************************************************************************//**
+ @Description Exceptions
+*//***************************************************************************/
+
+#define FM_MACSEC_EX_TX_SC_0 0x80000000
+#define FM_MACSEC_EX_TX_SC(sc) (FM_MACSEC_EX_TX_SC_0 >> (sc))
+#define FM_MACSEC_EX_ECC 0x00000001
+
+#define GET_EXCEPTION_FLAG(bitMask, exception, id) switch (exception){ \
+ case e_FM_MACSEC_EX_TX_SC: \
+ bitMask = FM_MACSEC_EX_TX_SC(id); break; \
+ case e_FM_MACSEC_EX_ECC: \
+ bitMask = FM_MACSEC_EX_ECC; break; \
+ default: bitMask = 0;break;}
+
+#define FM_MACSEC_USER_EX_SINGLE_BIT_ECC 0x80000000
+#define FM_MACSEC_USER_EX_MULTI_BIT_ECC 0x40000000
+
+#define GET_USER_EXCEPTION_FLAG(bitMask, exception) switch (exception){ \
+ case e_FM_MACSEC_EX_SINGLE_BIT_ECC: \
+ bitMask = FM_MACSEC_USER_EX_SINGLE_BIT_ECC; break; \
+ case e_FM_MACSEC_EX_MULTI_BIT_ECC: \
+ bitMask = FM_MACSEC_USER_EX_MULTI_BIT_ECC; break; \
+ default: bitMask = 0;break;}
+
+/**************************************************************************//**
+ @Description Events
+*//***************************************************************************/
+
+#define FM_MACSEC_EV_TX_SC_0_NEXT_PN 0x80000000
+#define FM_MACSEC_EV_TX_SC_NEXT_PN(sc) (FM_MACSEC_EV_TX_SC_0_NEXT_PN >> (sc))
+
+#define GET_EVENT_FLAG(bitMask, event, id) switch (event){ \
+ case e_FM_MACSEC_EV_TX_SC_NEXT_PN: \
+ bitMask = FM_MACSEC_EV_TX_SC_NEXT_PN(id); break; \
+ default: bitMask = 0;break;}
+
+/**************************************************************************//**
+ @Description Defaults
+*//***************************************************************************/
+#define DEFAULT_userExceptions (FM_MACSEC_USER_EX_SINGLE_BIT_ECC |\
+ FM_MACSEC_USER_EX_MULTI_BIT_ECC)
+
+#define DEFAULT_exceptions (FM_MACSEC_EX_TX_SC(0) |\
+ FM_MACSEC_EX_TX_SC(1) |\
+ FM_MACSEC_EX_TX_SC(2) |\
+ FM_MACSEC_EX_TX_SC(3) |\
+ FM_MACSEC_EX_TX_SC(4) |\
+ FM_MACSEC_EX_TX_SC(5) |\
+ FM_MACSEC_EX_TX_SC(6) |\
+ FM_MACSEC_EX_TX_SC(7) |\
+ FM_MACSEC_EX_TX_SC(8) |\
+ FM_MACSEC_EX_TX_SC(9) |\
+ FM_MACSEC_EX_TX_SC(10) |\
+ FM_MACSEC_EX_TX_SC(11) |\
+ FM_MACSEC_EX_TX_SC(12) |\
+ FM_MACSEC_EX_TX_SC(13) |\
+ FM_MACSEC_EX_TX_SC(14) |\
+ FM_MACSEC_EX_TX_SC(15) |\
+ FM_MACSEC_EX_ECC )
+
+#define DEFAULT_events (FM_MACSEC_EV_TX_SC_NEXT_PN(0) |\
+ FM_MACSEC_EV_TX_SC_NEXT_PN(1) |\
+ FM_MACSEC_EV_TX_SC_NEXT_PN(2) |\
+ FM_MACSEC_EV_TX_SC_NEXT_PN(3) |\
+ FM_MACSEC_EV_TX_SC_NEXT_PN(4) |\
+ FM_MACSEC_EV_TX_SC_NEXT_PN(5) |\
+ FM_MACSEC_EV_TX_SC_NEXT_PN(6) |\
+ FM_MACSEC_EV_TX_SC_NEXT_PN(7) |\
+ FM_MACSEC_EV_TX_SC_NEXT_PN(8) |\
+ FM_MACSEC_EV_TX_SC_NEXT_PN(9) |\
+ FM_MACSEC_EV_TX_SC_NEXT_PN(10) |\
+ FM_MACSEC_EV_TX_SC_NEXT_PN(11) |\
+ FM_MACSEC_EV_TX_SC_NEXT_PN(12) |\
+ FM_MACSEC_EV_TX_SC_NEXT_PN(13) |\
+ FM_MACSEC_EV_TX_SC_NEXT_PN(14) |\
+ FM_MACSEC_EV_TX_SC_NEXT_PN(15) )
+
+#define DEFAULT_unknownSciFrameTreatment e_FM_MACSEC_UNKNOWN_SCI_FRAME_TREATMENT_DISCARD_BOTH
+#define DEFAULT_invalidTagsFrameTreatment FALSE
+#define DEFAULT_encryptWithNoChangedTextFrameTreatment FALSE
+#define DEFAULT_untagFrameTreatment e_FM_MACSEC_UNTAG_FRAME_TREATMENT_DELIVER_UNCONTROLLED_DISCARD_CONTROLLED
+#define DEFAULT_changedTextWithNoEncryptFrameTreatment FALSE
+#define DEFAULT_onlyScbIsSetFrameTreatment FALSE
+#define DEFAULT_keysUnreadable FALSE
+#define DEFAULT_normalMode TRUE
+#define DEFAULT_sc0ReservedForPTP FALSE
+#define DEFAULT_initNextPn 1
+#define DEFAULT_pnExhThr 0xffffffff
+#define DEFAULT_sectagOverhead (MACSEC_ICV_SIZE + MACSEC_SECTAG_SIZE)
+#define DEFAULT_mflSubtract MACSEC_FCS_SIZE
+
+
+/**************************************************************************//**
+ @Description Memory Mapped Registers
+*//***************************************************************************/
+
+#if defined(__MWERKS__) && !defined(__GNUC__)
+#pragma pack(push,1)
+#endif /* defined(__MWERKS__) && ... */
+
+typedef _Packed struct
+{
+ /* MACsec configuration */
+ volatile uint32_t cfg; /**< MACsec configuration */
+ volatile uint32_t et; /**< MACsec EtherType */
+ volatile uint8_t res1[56]; /**< reserved */
+ volatile uint32_t mfl; /**< Maximum Frame Length */
+ volatile uint32_t tpnet; /**< TX Packet Number exhaustion threshold */
+ volatile uint8_t res2[56]; /**< reserved */
+ volatile uint32_t rxsca; /**< RX SC access select */
+ volatile uint8_t res3[60]; /**< reserved */
+ volatile uint32_t txsca; /**< TX SC access select */
+ volatile uint8_t res4[60]; /**< reserved */
+
+ /* RX configuration, status and statistic */
+ volatile uint32_t rxsci1h; /**< RX Secure Channel Identifier first half */
+ volatile uint32_t rxsci2h; /**< RX Secure Channel Identifier second half */
+ volatile uint8_t res5[8]; /**< reserved */
+ volatile uint32_t ifio1hs; /**< ifInOctets first half Statistic */
+ volatile uint32_t ifio2hs; /**< ifInOctets second half Statistic */
+ volatile uint32_t ifiups; /**< ifInUcastPkts Statistic */
+ volatile uint8_t res6[4]; /**< reserved */
+ volatile uint32_t ifimps; /**< ifInMulticastPkts Statistic */
+ volatile uint32_t ifibps; /**< ifInBroadcastPkts Statistic */
+ volatile uint32_t rxsccfg; /**< RX Secure Channel configuration */
+ volatile uint32_t rpw; /**< replayWindow */
+ volatile uint8_t res7[16]; /**< reserved */
+ volatile uint32_t inov1hs; /**< InOctetsValidated first half Statistic */
+ volatile uint32_t inov2hs; /**< InOctetsValidated second half Statistic */
+ volatile uint32_t inod1hs; /**< InOctetsDecrypted first half Statistic */
+ volatile uint32_t inod2hs; /**< InOctetsDecrypted second half Statistic */
+ volatile uint32_t rxscipus; /**< RX Secure Channel InPktsUnchecked Statistic */
+ volatile uint32_t rxscipds; /**< RX Secure Channel InPktsDelayed Statistic */
+ volatile uint32_t rxscipls; /**< RX Secure Channel InPktsLate Statistic */
+ volatile uint8_t res8[4]; /**< reserved */
+ volatile uint32_t rxaninuss[MAX_NUM_OF_SA_PER_SC]; /**< RX AN 0-3 InNotUsingSA Statistic */
+ volatile uint32_t rxanipuss[MAX_NUM_OF_SA_PER_SC]; /**< RX AN 0-3 InPktsUnusedSA Statistic */
+ _Packed struct
+ {
+ volatile uint32_t rxsacs; /**< RX Security Association configuration and status */
+ volatile uint32_t rxsanpn; /**< RX Security Association nextPN */
+ volatile uint32_t rxsalpn; /**< RX Security Association lowestPN */
+ volatile uint32_t rxsaipos; /**< RX Security Association InPktsOK Statistic */
+ volatile uint32_t rxsak[4]; /**< RX Security Association key (128 bit) */
+ volatile uint32_t rxsah[4]; /**< RX Security Association hash (128 bit) */
+ volatile uint32_t rxsaipis; /**< RX Security Association InPktsInvalid Statistic */
+ volatile uint32_t rxsaipnvs; /**< RX Security Association InPktsNotValid Statistic */
+ volatile uint8_t res9[8]; /**< reserved */
+ } _PackedType fmMacsecRxScSa[NUM_OF_SA_PER_RX_SC];
+
+ /* TX configuration, status and statistic */
+ volatile uint32_t txsci1h; /**< TX Secure Channel Identifier first half */
+ volatile uint32_t txsci2h; /**< TX Secure Channel Identifier second half */
+ volatile uint8_t res10[8]; /**< reserved */
+ volatile uint32_t ifoo1hs; /**< ifOutOctets first half Statistic */
+ volatile uint32_t ifoo2hs; /**< ifOutOctets second half Statistic */
+ volatile uint32_t ifoups; /**< ifOutUcastPkts Statistic */
+ volatile uint32_t opus; /**< OutPktsUntagged Statistic */
+ volatile uint32_t ifomps; /**< ifOutMulticastPkts Statistic */
+ volatile uint32_t ifobps; /**< ifOutBroadcastPkts Statistic */
+ volatile uint32_t txsccfg; /**< TX Secure Channel configuration */
+ volatile uint32_t optls; /**< OutPktsTooLong Statistic */
+ volatile uint8_t res11[16]; /**< reserved */
+ volatile uint32_t oop1hs; /**< OutOctetsProtected first half Statistic */
+ volatile uint32_t oop2hs; /**< OutOctetsProtected second half Statistic */
+ volatile uint32_t ooe1hs; /**< OutOctetsEncrypted first half Statistic */
+ volatile uint32_t ooe2hs; /**< OutOctetsEncrypted second half Statistic */
+ volatile uint8_t res12[48]; /**< reserved */
+ _Packed struct
+ {
+ volatile uint32_t txsacs; /**< TX Security Association configuration and status */
+ volatile uint32_t txsanpn; /**< TX Security Association nextPN */
+ volatile uint32_t txsaopps; /**< TX Security Association OutPktsProtected Statistic */
+ volatile uint32_t txsaopes; /**< TX Security Association OutPktsEncrypted Statistic */
+ volatile uint32_t txsak[4]; /**< TX Security Association key (128 bit) */
+ volatile uint32_t txsah[4]; /**< TX Security Association hash (128 bit) */
+ volatile uint8_t res13[16]; /**< reserved */
+ } _PackedType fmMacsecTxScSa[NUM_OF_SA_PER_TX_SC];
+ volatile uint8_t res14[248]; /**< reserved */
+
+ /* Global configuration and status */
+ volatile uint32_t ip_rev1; /**< MACsec IP Block Revision 1 register */
+ volatile uint32_t ip_rev2; /**< MACsec IP Block Revision 2 register */
+ volatile uint32_t evr; /**< MACsec Event Register */
+ volatile uint32_t ever; /**< MACsec Event Enable Register */
+ volatile uint32_t evfr; /**< MACsec Event Force Register */
+ volatile uint32_t err; /**< MACsec Error Register */
+ volatile uint32_t erer; /**< MACsec Error Enable Register */
+ volatile uint32_t erfr; /**< MACsec Error Force Register */
+ volatile uint8_t res15[40]; /**< reserved */
+ volatile uint32_t meec; /**< MACsec Memory ECC Error Capture Register */
+ volatile uint32_t idle; /**< MACsec Idle status Register */
+ volatile uint8_t res16[184]; /**< reserved */
+ /* DEBUG */
+ volatile uint32_t rxec; /**< MACsec RX error capture Register */
+ volatile uint8_t res17[28]; /**< reserved */
+ volatile uint32_t txec; /**< MACsec TX error capture Register */
+ volatile uint8_t res18[220]; /**< reserved */
+
+ /* Macsec Rx global statistic */
+ volatile uint32_t ifiocp1hs; /**< ifInOctetsCp first half Statistic */
+ volatile uint32_t ifiocp2hs; /**< ifInOctetsCp second half Statistic */
+ volatile uint32_t ifiupcps; /**< ifInUcastPktsCp Statistic */
+ volatile uint8_t res19[4]; /**< reserved */
+ volatile uint32_t ifioup1hs; /**< ifInOctetsUp first half Statistic */
+ volatile uint32_t ifioup2hs; /**< ifInOctetsUp second half Statistic */
+ volatile uint32_t ifiupups; /**< ifInUcastPktsUp Statistic */
+ volatile uint8_t res20[4]; /**< reserved */
+ volatile uint32_t ifimpcps; /**< ifInMulticastPktsCp Statistic */
+ volatile uint32_t ifibpcps; /**< ifInBroadcastPktsCp Statistic */
+ volatile uint32_t ifimpups; /**< ifInMulticastPktsUp Statistic */
+ volatile uint32_t ifibpups; /**< ifInBroadcastPktsUp Statistic */
+ volatile uint32_t ipwts; /**< InPktsWithoutTag Statistic */
+ volatile uint32_t ipkays; /**< InPktsKaY Statistic */
+ volatile uint32_t ipbts; /**< InPktsBadTag Statistic */
+ volatile uint32_t ipsnfs; /**< InPktsSCINotFound Statistic */
+ volatile uint32_t ipuecs; /**< InPktsUnsupportedEC Statistic */
+ volatile uint32_t ipescbs; /**< InPktsEponSingleCopyBroadcast Statistic */
+ volatile uint32_t iptls; /**< InPktsTooLong Statistic */
+ volatile uint8_t res21[52]; /**< reserved */
+
+ /* Macsec Tx global statistic */
+ volatile uint32_t opds; /**< OutPktsDiscarded Statistic */
+#if (DPAA_VERSION >= 11)
+ volatile uint8_t res22[124]; /**< reserved */
+ _Packed struct
+ {
+ volatile uint32_t rxsak[8]; /**< RX Security Association key (128/256 bit) */
+ volatile uint8_t res23[32]; /**< reserved */
+ } _PackedType rxScSaKey[NUM_OF_SA_PER_RX_SC];
+ _Packed struct
+ {
+ volatile uint32_t txsak[8]; /**< TX Security Association key (128/256 bit) */
+ volatile uint8_t res24[32]; /**< reserved */
+ } _PackedType txScSaKey[NUM_OF_SA_PER_TX_SC];
+#endif /* (DPAA_VERSION >= 11) */
+} _PackedType t_FmMacsecRegs;
+
+#if defined(__MWERKS__) && !defined(__GNUC__)
+#pragma pack(pop)
+#endif /* defined(__MWERKS__) && ... */
+
+
+/**************************************************************************//**
+ @Description General defines
+*//***************************************************************************/
+
+#define SCI_HIGH_MASK 0xffffffff00000000LL
+#define SCI_LOW_MASK 0x00000000ffffffffLL
+
+#define LONG_SHIFT 32
+
+#define GET_SCI_FIRST_HALF(sci) (uint32_t)((macsecSCI_t)((macsecSCI_t)(sci) & SCI_HIGH_MASK) >> LONG_SHIFT)
+#define GET_SCI_SECOND_HALF(sci) (uint32_t)((macsecSCI_t)(sci) & SCI_LOW_MASK)
+
+/**************************************************************************//**
+ @Description Configuration defines
+*//***************************************************************************/
+
+/* masks */
+#define CFG_UECT 0x00000800
+#define CFG_ESCBT 0x00000400
+#define CFG_USFT 0x00000300
+#define CFG_ITT 0x00000080
+#define CFG_KFT 0x00000040
+#define CFG_UFT 0x00000030
+#define CFG_KSS 0x00000004
+#define CFG_BYPN 0x00000002
+#define CFG_S0I 0x00000001
+
+#define ET_TYPE 0x0000ffff
+
+#define MFL_MAX_LEN 0x0000ffff
+
+#define RXSCA_SC_SEL 0x0000000f
+
+#define TXSCA_SC_SEL 0x0000000f
+
+#define IP_REV_1_IP_ID 0xffff0000
+#define IP_REV_1_IP_MJ 0x0000ff00
+#define IP_REV_1_IP_MM 0x000000ff
+
+#define IP_REV_2_IP_INT 0x00ff0000
+#define IP_REV_2_IP_ERR 0x0000ff00
+#define IP_REV_2_IP_CFG 0x000000ff
+
+#define MECC_CAP 0x80000000
+#define MECC_CET 0x40000000
+#define MECC_SERCNT 0x00ff0000
+#define MECC_MEMADDR 0x000001ff
+
+/* shifts */
+#define CFG_UECT_SHIFT (31-20)
+#define CFG_ESCBT_SHIFT (31-21)
+#define CFG_USFT_SHIFT (31-23)
+#define CFG_ITT_SHIFT (31-24)
+#define CFG_KFT_SHIFT (31-25)
+#define CFG_UFT_SHIFT (31-27)
+#define CFG_KSS_SHIFT (31-29)
+#define CFG_BYPN_SHIFT (31-30)
+#define CFG_S0I_SHIFT (31-31)
+
+#define IP_REV_1_IP_ID_SHIFT (31-15)
+#define IP_REV_1_IP_MJ_SHIFT (31-23)
+#define IP_REV_1_IP_MM_SHIFT (31-31)
+
+#define IP_REV_2_IP_INT_SHIFT (31-15)
+#define IP_REV_2_IP_ERR_SHIFT (31-23)
+#define IP_REV_2_IP_CFG_SHIFT (31-31)
+
+#define MECC_CAP_SHIFT (31-0)
+#define MECC_CET_SHIFT (31-1)
+#define MECC_SERCNT_SHIFT (31-15)
+#define MECC_MEMADDR_SHIFT (31-31)
+
+/**************************************************************************//**
+ @Description RX SC defines
+*//***************************************************************************/
+
+/* masks */
+#define RX_SCCFG_SCI_EN_MASK 0x00000800
+#define RX_SCCFG_RP_MASK 0x00000400
+#define RX_SCCFG_VF_MASK 0x00000300
+#define RX_SCCFG_CO_MASK 0x0000003f
+
+/* shifts */
+#define RX_SCCFG_SCI_EN_SHIFT (31-20)
+#define RX_SCCFG_RP_SHIFT (31-21)
+#define RX_SCCFG_VF_SHIFT (31-23)
+#define RX_SCCFG_CO_SHIFT (31-31)
+#define RX_SCCFG_CS_SHIFT (31-7)
+
+/**************************************************************************//**
+ @Description RX SA defines
+*//***************************************************************************/
+
+/* masks */
+#define RX_SACFG_ACTIVE 0x80000000
+#define RX_SACFG_AN_MASK 0x00000006
+#define RX_SACFG_EN_MASK 0x00000001
+
+/* shifts */
+#define RX_SACFG_AN_SHIFT (31-30)
+#define RX_SACFG_EN_SHIFT (31-31)
+
+/**************************************************************************//**
+ @Description TX SC defines
+*//***************************************************************************/
+
+/* masks */
+#define TX_SCCFG_AN_MASK 0x000c0000
+#define TX_SCCFG_ASA_MASK 0x00020000
+#define TX_SCCFG_SCE_MASK 0x00010000
+#define TX_SCCFG_CO_MASK 0x00003f00
+#define TX_SCCFG_CE_MASK 0x00000010
+#define TX_SCCFG_PF_MASK 0x00000008
+#define TX_SCCFG_AIS_MASK 0x00000004
+#define TX_SCCFG_UES_MASK 0x00000002
+#define TX_SCCFG_USCB_MASK 0x00000001
+
+/* shifts */
+#define TX_SCCFG_AN_SHIFT (31-13)
+#define TX_SCCFG_ASA_SHIFT (31-14)
+#define TX_SCCFG_SCE_SHIFT (31-15)
+#define TX_SCCFG_CO_SHIFT (31-23)
+#define TX_SCCFG_CE_SHIFT (31-27)
+#define TX_SCCFG_PF_SHIFT (31-28)
+#define TX_SCCFG_AIS_SHIFT (31-29)
+#define TX_SCCFG_UES_SHIFT (31-30)
+#define TX_SCCFG_USCB_SHIFT (31-31)
+#define TX_SCCFG_CS_SHIFT (31-7)
+
+/**************************************************************************//**
+ @Description TX SA defines
+*//***************************************************************************/
+
+/* masks */
+#define TX_SACFG_ACTIVE 0x80000000
+
+
+typedef struct
+{
+ void (*f_Isr) (t_Handle h_Arg, uint32_t id);
+ t_Handle h_SrcHandle;
+} t_FmMacsecIntrSrc;
+
+typedef struct
+{
+ e_FmMacsecUnknownSciFrameTreatment unknownSciTreatMode;
+ bool invalidTagsDeliverUncontrolled;
+ bool changedTextWithNoEncryptDeliverUncontrolled;
+ bool onlyScbIsSetDeliverUncontrolled;
+ bool encryptWithNoChangedTextDiscardUncontrolled;
+ e_FmMacsecUntagFrameTreatment untagTreatMode;
+ uint32_t pnExhThr;
+ bool keysUnreadable;
+ bool byPassMode;
+ bool reservedSc0;
+ uint32_t sectagOverhead;
+ uint32_t mflSubtract;
+} t_FmMacsecDriverParam;
+
+typedef struct
+{
+ t_FmMacsecControllerDriver fmMacsecControllerDriver;
+ t_Handle h_Fm;
+ t_FmMacsecRegs *p_FmMacsecRegs;
+ t_Handle h_FmMac; /**< A handle to the FM MAC object related to */
+ char fmMacsecModuleName[MODULE_NAME_SIZE];
+ t_FmMacsecIntrSrc intrMng[NUM_OF_INTER_MODULE_EVENTS];
+ uint32_t events;
+ uint32_t exceptions;
+ uint32_t userExceptions;
+ t_FmMacsecExceptionsCallback *f_Exception; /**< Exception Callback Routine */
+ t_Handle h_App; /**< A handle to an application layer object; This handle will
+ be passed by the driver upon calling the above callbacks */
+ bool rxScTable[NUM_OF_RX_SC];
+ uint32_t numRxScAvailable;
+ bool txScTable[NUM_OF_TX_SC];
+ uint32_t numTxScAvailable;
+ t_Handle rxScSpinLock;
+ t_Handle txScSpinLock;
+ t_FmMacsecDriverParam *p_FmMacsecDriverParam;
+} t_FmMacsec;
+
+
+#endif /* __FM_MACSEC_MASTER_H */
diff --git a/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_secy.c b/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_secy.c
new file mode 100644
index 000000000000..7c72dc98e7f1
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_secy.c
@@ -0,0 +1,883 @@
+/*
+ * Copyright 2008-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/******************************************************************************
+ @File fm_macsec_secy.c
+
+ @Description FM MACSEC SECY driver routines implementation.
+*//***************************************************************************/
+
+#include "std_ext.h"
+#include "error_ext.h"
+#include "xx_ext.h"
+#include "string_ext.h"
+#include "sprint_ext.h"
+
+#include "fm_macsec_secy.h"
+
+
+/****************************************/
+/* static functions */
+/****************************************/
+static void FmMacsecSecYExceptionsIsr(t_Handle h_FmMacsecSecY, uint32_t id)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+
+ UNUSED(id);
+ SANITY_CHECK_RETURN(p_FmMacsecSecY, E_INVALID_HANDLE);
+
+ if (p_FmMacsecSecY->exceptions & FM_MACSEC_SECY_EX_FRAME_DISCARDED)
+ p_FmMacsecSecY->f_Exception(p_FmMacsecSecY->h_App, e_FM_MACSEC_SECY_EX_FRAME_DISCARDED);
+}
+
+static void FmMacsecSecYEventsIsr(t_Handle h_FmMacsecSecY, uint32_t id)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+
+ UNUSED(id);
+ SANITY_CHECK_RETURN(p_FmMacsecSecY, E_INVALID_HANDLE);
+
+ if (p_FmMacsecSecY->events & FM_MACSEC_SECY_EV_NEXT_PN)
+ p_FmMacsecSecY->f_Event(p_FmMacsecSecY->h_App, e_FM_MACSEC_SECY_EV_NEXT_PN);
+}
+
+static t_Error CheckFmMacsecSecYParameters(t_FmMacsecSecY *p_FmMacsecSecY)
+{
+ if (!p_FmMacsecSecY->f_Exception)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Exceptions callback not provided"));
+
+ if (!p_FmMacsecSecY->f_Event)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Events callback not provided"));
+
+ if (!p_FmMacsecSecY->numOfRxSc)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Num of Rx Scs must be greater than '0'"));
+
+
+ return E_OK;
+}
+
+static t_Handle FmMacsecSecYCreateSc(t_FmMacsecSecY *p_FmMacsecSecY,
+ macsecSCI_t sci,
+ e_FmMacsecSecYCipherSuite cipherSuite,
+ e_ScType type)
+{
+ t_SecYSc *p_ScTable;
+ void *p_Params;
+ uint32_t numOfSc,i;
+ t_Error err = E_OK;
+ t_RxScParams rxScParams;
+ t_TxScParams txScParams;
+
+ ASSERT_COND(p_FmMacsecSecY);
+ ASSERT_COND(p_FmMacsecSecY->h_FmMacsec);
+
+ if (type == e_SC_RX)
+ {
+ memset(&rxScParams, 0, sizeof(rxScParams));
+ i = (NUM_OF_RX_SC - 1);
+ p_ScTable = p_FmMacsecSecY->p_RxSc;
+ numOfSc = p_FmMacsecSecY->numOfRxSc;
+ rxScParams.confidentialityOffset = p_FmMacsecSecY->confidentialityOffset;
+ rxScParams.replayProtect = p_FmMacsecSecY->replayProtect;
+ rxScParams.replayWindow = p_FmMacsecSecY->replayWindow;
+ rxScParams.validateFrames = p_FmMacsecSecY->validateFrames;
+ rxScParams.cipherSuite = cipherSuite;
+ p_Params = &rxScParams;
+ }
+ else
+ {
+ memset(&txScParams, 0, sizeof(txScParams));
+ i = (NUM_OF_TX_SC - 1);
+ p_ScTable = p_FmMacsecSecY->p_TxSc;
+ numOfSc = p_FmMacsecSecY->numOfTxSc;
+ txScParams.sciInsertionMode = p_FmMacsecSecY->sciInsertionMode;
+ txScParams.protectFrames = p_FmMacsecSecY->protectFrames;
+ txScParams.confidentialityEnable = p_FmMacsecSecY->confidentialityEnable;
+ txScParams.confidentialityOffset = p_FmMacsecSecY->confidentialityOffset;
+ txScParams.cipherSuite = cipherSuite;
+ p_Params = &txScParams;
+ }
+
+ for (i=0;i<numOfSc;i++)
+ if (!p_ScTable[i].inUse)
+ break;
+ if (i == numOfSc)
+ {
+ REPORT_ERROR(MAJOR, E_FULL, ("FM MACSEC SECY SC"));
+ return NULL;
+ }
+
+ if (type == e_SC_RX)
+ {
+ ((t_RxScParams *)p_Params)->scId = p_ScTable[i].scId;
+ ((t_RxScParams *)p_Params)->sci = sci;
+ if ((err = FmMacsecCreateRxSc(p_FmMacsecSecY->h_FmMacsec, (t_RxScParams *)p_Params)) != E_OK)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM MACSEC SECY RX SC"));
+ return NULL;
+ }
+ }
+ else
+ {
+ ((t_TxScParams *)p_Params)->scId = p_ScTable[i].scId;
+ ((t_TxScParams *)p_Params)->sci = sci;
+ if ((err = FmMacsecCreateTxSc(p_FmMacsecSecY->h_FmMacsec, (t_TxScParams *)p_Params)) != E_OK)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM MACSEC SECY TX SC"));
+ return NULL;
+ }
+ }
+
+ p_ScTable[i].inUse = TRUE;
+ return &p_ScTable[i];
+}
+
+static t_Error FmMacsecSecYDeleteSc(t_FmMacsecSecY *p_FmMacsecSecY, t_SecYSc *p_FmSecYSc, e_ScType type)
+{
+ t_Error err = E_OK;
+
+ ASSERT_COND(p_FmMacsecSecY);
+ ASSERT_COND(p_FmMacsecSecY->h_FmMacsec);
+ ASSERT_COND(p_FmSecYSc);
+
+ if (type == e_SC_RX)
+ {
+ if ((err = FmMacsecDeleteRxSc(p_FmMacsecSecY->h_FmMacsec, p_FmSecYSc->scId)) != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+ }
+ else
+ if ((err = FmMacsecDeleteTxSc(p_FmMacsecSecY->h_FmMacsec, p_FmSecYSc->scId)) != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ p_FmSecYSc->inUse = FALSE;
+
+ return err;
+}
+
+/****************************************/
+/* API Init unit functions */
+/****************************************/
+t_Handle FM_MACSEC_SECY_Config(t_FmMacsecSecYParams *p_FmMacsecSecYParam)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY;
+
+ /* Allocate FM MACSEC structure */
+ p_FmMacsecSecY = (t_FmMacsecSecY *) XX_Malloc(sizeof(t_FmMacsecSecY));
+ if (!p_FmMacsecSecY)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM MACSEC SECY driver structure"));
+ return NULL;
+ }
+ memset(p_FmMacsecSecY, 0, sizeof(t_FmMacsecSecY));
+
+ /* Allocate the FM MACSEC driver's parameters structure */
+ p_FmMacsecSecY->p_FmMacsecSecYDriverParam = (t_FmMacsecSecYDriverParam *)XX_Malloc(sizeof(t_FmMacsecSecYDriverParam));
+ if (!p_FmMacsecSecY->p_FmMacsecSecYDriverParam)
+ {
+ XX_Free(p_FmMacsecSecY);
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM MACSEC SECY driver parameters"));
+ return NULL;
+ }
+ memset(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, 0, sizeof(t_FmMacsecSecYDriverParam));
+
+ /* Initialize FM MACSEC SECY parameters which will be kept by the driver */
+ p_FmMacsecSecY->h_FmMacsec = p_FmMacsecSecYParam->h_FmMacsec;
+ p_FmMacsecSecY->f_Event = p_FmMacsecSecYParam->f_Event;
+ p_FmMacsecSecY->f_Exception = p_FmMacsecSecYParam->f_Exception;
+ p_FmMacsecSecY->h_App = p_FmMacsecSecYParam->h_App;
+ p_FmMacsecSecY->confidentialityEnable = DEFAULT_confidentialityEnable;
+ p_FmMacsecSecY->confidentialityOffset = DEFAULT_confidentialityOffset;
+ p_FmMacsecSecY->validateFrames = DEFAULT_validateFrames;
+ p_FmMacsecSecY->replayProtect = DEFAULT_replayEnable;
+ p_FmMacsecSecY->replayWindow = DEFAULT_replayWindow;
+ p_FmMacsecSecY->protectFrames = DEFAULT_protectFrames;
+ p_FmMacsecSecY->sciInsertionMode = DEFAULT_sciInsertionMode;
+ p_FmMacsecSecY->isPointToPoint = DEFAULT_ptp;
+ p_FmMacsecSecY->numOfRxSc = p_FmMacsecSecYParam->numReceiveChannels;
+ p_FmMacsecSecY->numOfTxSc = DEFAULT_numOfTxSc;
+ p_FmMacsecSecY->exceptions = DEFAULT_exceptions;
+ p_FmMacsecSecY->events = DEFAULT_events;
+
+ memcpy(&p_FmMacsecSecY->p_FmMacsecSecYDriverParam->txScParams,
+ &p_FmMacsecSecYParam->txScParams,
+ sizeof(t_FmMacsecSecYSCParams));
+ return p_FmMacsecSecY;
+}
+
+t_Error FM_MACSEC_SECY_Init(t_Handle h_FmMacsecSecY)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+ t_FmMacsecSecYDriverParam *p_FmMacsecSecYDriverParam = NULL;
+ uint32_t rxScIds[NUM_OF_RX_SC], txScIds[NUM_OF_TX_SC], i, j;
+ t_Error err;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_HANDLE);
+
+ CHECK_INIT_PARAMETERS(p_FmMacsecSecY, CheckFmMacsecSecYParameters);
+
+ p_FmMacsecSecYDriverParam = p_FmMacsecSecY->p_FmMacsecSecYDriverParam;
+
+ if ((p_FmMacsecSecY->isPointToPoint) &&
+ ((err = FmMacsecSetPTP(p_FmMacsecSecY->h_FmMacsec, TRUE)) != E_OK))
+ RETURN_ERROR(MAJOR, err, ("Can't set Poin-to-Point"));
+
+ /* Rx Sc Allocation */
+ p_FmMacsecSecY->p_RxSc = (t_SecYSc *)XX_Malloc(sizeof(t_SecYSc) * p_FmMacsecSecY->numOfRxSc);
+ if (!p_FmMacsecSecY->p_RxSc)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("FM MACSEC SECY RX SC"));
+ memset(p_FmMacsecSecY->p_RxSc, 0, sizeof(t_SecYSc) * p_FmMacsecSecY->numOfRxSc);
+ if ((err = FmMacsecAllocScs(p_FmMacsecSecY->h_FmMacsec, e_SC_RX, p_FmMacsecSecY->isPointToPoint, p_FmMacsecSecY->numOfRxSc, rxScIds)) != E_OK)
+ {
+ if (p_FmMacsecSecY->p_TxSc)
+ XX_Free(p_FmMacsecSecY->p_TxSc);
+ if (p_FmMacsecSecY->p_RxSc)
+ XX_Free(p_FmMacsecSecY->p_RxSc);
+ return ERROR_CODE(err);
+ }
+ for (i=0; i<p_FmMacsecSecY->numOfRxSc; i++)
+ {
+ p_FmMacsecSecY->p_RxSc[i].scId = rxScIds[i];
+ p_FmMacsecSecY->p_RxSc[i].type = e_SC_RX;
+ for (j=0; j<MAX_NUM_OF_SA_PER_SC;j++)
+ p_FmMacsecSecY->p_RxSc[i].sa[j].saId = (e_ScSaId)SECY_AN_FREE_VALUE;
+ }
+
+ /* Tx Sc Allocation */
+ p_FmMacsecSecY->p_TxSc = (t_SecYSc *)XX_Malloc(sizeof(t_SecYSc) * p_FmMacsecSecY->numOfTxSc);
+ if (!p_FmMacsecSecY->p_TxSc)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("FM MACSEC SECY TX SC"));
+ memset(p_FmMacsecSecY->p_TxSc, 0, sizeof(t_SecYSc) * p_FmMacsecSecY->numOfTxSc);
+
+ if ((err = FmMacsecAllocScs(p_FmMacsecSecY->h_FmMacsec, e_SC_TX, p_FmMacsecSecY->isPointToPoint, p_FmMacsecSecY->numOfTxSc, txScIds)) != E_OK)
+ {
+ if (p_FmMacsecSecY->p_TxSc)
+ XX_Free(p_FmMacsecSecY->p_TxSc);
+ if (p_FmMacsecSecY->p_RxSc)
+ XX_Free(p_FmMacsecSecY->p_RxSc);
+ return ERROR_CODE(err);
+ }
+ for (i=0; i<p_FmMacsecSecY->numOfTxSc; i++)
+ {
+ p_FmMacsecSecY->p_TxSc[i].scId = txScIds[i];
+ p_FmMacsecSecY->p_TxSc[i].type = e_SC_TX;
+ for (j=0; j<MAX_NUM_OF_SA_PER_SC;j++)
+ p_FmMacsecSecY->p_TxSc[i].sa[j].saId = (e_ScSaId)SECY_AN_FREE_VALUE;
+ FmMacsecRegisterIntr(p_FmMacsecSecY->h_FmMacsec,
+ e_FM_MACSEC_MOD_SC_TX,
+ (uint8_t)txScIds[i],
+ e_FM_INTR_TYPE_ERR,
+ FmMacsecSecYExceptionsIsr,
+ p_FmMacsecSecY);
+ FmMacsecRegisterIntr(p_FmMacsecSecY->h_FmMacsec,
+ e_FM_MACSEC_MOD_SC_TX,
+ (uint8_t)txScIds[i],
+ e_FM_INTR_TYPE_NORMAL,
+ FmMacsecSecYEventsIsr,
+ p_FmMacsecSecY);
+
+ if (p_FmMacsecSecY->exceptions & FM_MACSEC_SECY_EX_FRAME_DISCARDED)
+ FmMacsecSetException(p_FmMacsecSecY->h_FmMacsec, e_FM_MACSEC_EX_TX_SC, txScIds[i], TRUE);
+ if (p_FmMacsecSecY->events & FM_MACSEC_SECY_EV_NEXT_PN)
+ FmMacsecSetEvent(p_FmMacsecSecY->h_FmMacsec, e_FM_MACSEC_EV_TX_SC_NEXT_PN, txScIds[i], TRUE);
+ }
+
+ FmMacsecSecYCreateSc(p_FmMacsecSecY,
+ p_FmMacsecSecYDriverParam->txScParams.sci,
+ p_FmMacsecSecYDriverParam->txScParams.cipherSuite,
+ e_SC_TX);
+ XX_Free(p_FmMacsecSecYDriverParam);
+ p_FmMacsecSecY->p_FmMacsecSecYDriverParam = NULL;
+
+ return E_OK;
+}
+
+t_Error FM_MACSEC_SECY_Free(t_Handle h_FmMacsecSecY)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+ t_Error err = E_OK;
+ uint32_t rxScIds[NUM_OF_RX_SC], txScIds[NUM_OF_TX_SC], i;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+
+ if (p_FmMacsecSecY->isPointToPoint)
+ FmMacsecSetPTP(p_FmMacsecSecY->h_FmMacsec, FALSE);
+ if (p_FmMacsecSecY->p_RxSc)
+ {
+ for (i=0; i<p_FmMacsecSecY->numOfRxSc; i++)
+ rxScIds[i] = p_FmMacsecSecY->p_RxSc[i].scId;
+ if ((err = FmMacsecFreeScs(p_FmMacsecSecY->h_FmMacsec, e_SC_RX, p_FmMacsecSecY->numOfRxSc, rxScIds)) != E_OK)
+ return ERROR_CODE(err);
+ XX_Free(p_FmMacsecSecY->p_RxSc);
+ }
+ if (p_FmMacsecSecY->p_TxSc)
+ {
+ FmMacsecSecYDeleteSc(p_FmMacsecSecY, &p_FmMacsecSecY->p_TxSc[0], e_SC_TX);
+
+ for (i=0; i<p_FmMacsecSecY->numOfTxSc; i++) {
+ txScIds[i] = p_FmMacsecSecY->p_TxSc[i].scId;
+ FmMacsecUnregisterIntr(p_FmMacsecSecY->h_FmMacsec,
+ e_FM_MACSEC_MOD_SC_TX,
+ (uint8_t)txScIds[i],
+ e_FM_INTR_TYPE_ERR);
+ FmMacsecUnregisterIntr(p_FmMacsecSecY->h_FmMacsec,
+ e_FM_MACSEC_MOD_SC_TX,
+ (uint8_t)txScIds[i],
+ e_FM_INTR_TYPE_NORMAL);
+
+ if (p_FmMacsecSecY->exceptions & FM_MACSEC_SECY_EX_FRAME_DISCARDED)
+ FmMacsecSetException(p_FmMacsecSecY->h_FmMacsec, e_FM_MACSEC_EX_TX_SC, txScIds[i], FALSE);
+ if (p_FmMacsecSecY->events & FM_MACSEC_SECY_EV_NEXT_PN)
+ FmMacsecSetEvent(p_FmMacsecSecY->h_FmMacsec, e_FM_MACSEC_EV_TX_SC_NEXT_PN, txScIds[i], FALSE);
+ }
+
+ if ((err = FmMacsecFreeScs(p_FmMacsecSecY->h_FmMacsec, e_SC_TX, p_FmMacsecSecY->numOfTxSc, txScIds)) != E_OK)
+ return ERROR_CODE(err);
+ XX_Free(p_FmMacsecSecY->p_TxSc);
+ }
+
+ XX_Free(p_FmMacsecSecY);
+
+ return err;
+}
+
+t_Error FM_MACSEC_SECY_ConfigSciInsertionMode(t_Handle h_FmMacsecSecY, e_FmMacsecSciInsertionMode sciInsertionMode)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+
+ p_FmMacsecSecY->sciInsertionMode = sciInsertionMode;
+
+ return E_OK;
+}
+
+t_Error FM_MACSEC_SECY_ConfigProtectFrames(t_Handle h_FmMacsecSecY, bool protectFrames)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+
+ p_FmMacsecSecY->protectFrames = protectFrames;
+
+ return E_OK;
+}
+
+t_Error FM_MACSEC_SECY_ConfigReplayWindow(t_Handle h_FmMacsecSecY, bool replayProtect, uint32_t replayWindow)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+
+ p_FmMacsecSecY->replayProtect = replayProtect;
+ p_FmMacsecSecY->replayWindow = replayWindow;
+
+ return E_OK;
+}
+
+t_Error FM_MACSEC_SECY_ConfigValidationMode(t_Handle h_FmMacsecSecY, e_FmMacsecValidFrameBehavior validateFrames)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+
+ p_FmMacsecSecY->validateFrames = validateFrames;
+
+ return E_OK;
+}
+
+t_Error FM_MACSEC_SECY_ConfigConfidentiality(t_Handle h_FmMacsecSecY, bool confidentialityEnable, uint16_t confidentialityOffset)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+
+ p_FmMacsecSecY->confidentialityEnable = confidentialityEnable;
+ p_FmMacsecSecY->confidentialityOffset = confidentialityOffset;
+
+ return E_OK;
+}
+
+t_Error FM_MACSEC_SECY_ConfigPointToPoint(t_Handle h_FmMacsecSecY)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+
+ p_FmMacsecSecY->numOfRxSc = 1;
+ p_FmMacsecSecY->isPointToPoint = TRUE;
+ p_FmMacsecSecY->sciInsertionMode = e_FM_MACSEC_SCI_INSERTION_MODE_IMPLICT_PTP;
+
+ return E_OK;
+}
+
+t_Error FM_MACSEC_SECY_ConfigException(t_Handle h_FmMacsecSecY, e_FmMacsecSecYExceptions exception, bool enable)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+ uint32_t bitMask = 0;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+
+ GET_EXCEPTION_FLAG(bitMask, exception);
+ if (bitMask)
+ {
+ if (enable)
+ p_FmMacsecSecY->exceptions |= bitMask;
+ else
+ p_FmMacsecSecY->exceptions &= ~bitMask;
+ }
+ else
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
+
+ return E_OK;
+}
+
+t_Error FM_MACSEC_SECY_ConfigEvent(t_Handle h_FmMacsecSecY, e_FmMacsecSecYEvents event, bool enable)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+ uint32_t bitMask = 0;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+
+ GET_EVENT_FLAG(bitMask, event);
+ if (bitMask)
+ {
+ if (enable)
+ p_FmMacsecSecY->events |= bitMask;
+ else
+ p_FmMacsecSecY->events &= ~bitMask;
+ }
+ else
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined event"));
+
+ return E_OK;
+}
+
+t_Handle FM_MACSEC_SECY_CreateRxSc(t_Handle h_FmMacsecSecY, t_FmMacsecSecYSCParams *p_ScParams)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+
+ SANITY_CHECK_RETURN_VALUE(p_FmMacsecSecY, E_INVALID_HANDLE, NULL);
+ SANITY_CHECK_RETURN_VALUE(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE, NULL);
+ SANITY_CHECK_RETURN_VALUE(p_ScParams, E_NULL_POINTER, NULL);
+ SANITY_CHECK_RETURN_VALUE(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE, NULL);
+
+ return FmMacsecSecYCreateSc(p_FmMacsecSecY, p_ScParams->sci, p_ScParams->cipherSuite, e_SC_RX);
+}
+
+t_Error FM_MACSEC_SECY_DeleteRxSc(t_Handle h_FmMacsecSecY, t_Handle h_Sc)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+ t_SecYSc *p_FmSecYSc = (t_SecYSc *)h_Sc;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
+
+ return FmMacsecSecYDeleteSc(p_FmMacsecSecY, p_FmSecYSc, e_SC_RX);
+}
+
+t_Error FM_MACSEC_SECY_CreateRxSa(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, uint32_t lowestPn, macsecSAKey_t key)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+ t_SecYSc *p_FmSecYSc = (t_SecYSc *)h_Sc;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
+
+ if (p_FmSecYSc->sa[an].saId != SECY_AN_FREE_VALUE)
+ RETURN_ERROR(MINOR, E_INVALID_STATE, ("An %d is already assigned",an));
+
+ if ((err = FmMacsecCreateRxSa(p_FmMacsecSecY->h_FmMacsec, p_FmSecYSc->scId, (e_ScSaId)p_FmSecYSc->numOfSa, an, lowestPn, key)) != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ p_FmSecYSc->sa[an].saId = (e_ScSaId)p_FmSecYSc->numOfSa++;
+ return err;
+}
+
+t_Error FM_MACSEC_SECY_DeleteRxSa(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+ t_SecYSc *p_FmSecYSc = (t_SecYSc *)h_Sc;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
+
+ if (p_FmSecYSc->sa[an].saId == SECY_AN_FREE_VALUE)
+ RETURN_ERROR(MINOR, E_INVALID_STATE, ("An %d is already deleted",an));
+
+ if ((err = FmMacsecDeleteRxSa(p_FmMacsecSecY->h_FmMacsec, p_FmSecYSc->scId, p_FmSecYSc->sa[an].saId)) != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ p_FmSecYSc->numOfSa--;
+ p_FmSecYSc->sa[an].saId = (e_ScSaId)SECY_AN_FREE_VALUE;
+ /* TODO - check if statistics need to be read*/
+ return err;
+}
+
+t_Error FM_MACSEC_SECY_RxSaEnableReceive(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+ t_SecYSc *p_FmSecYSc = (t_SecYSc *)h_Sc;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
+
+ if (p_FmSecYSc->sa[an].saId == SECY_AN_FREE_VALUE)
+ RETURN_ERROR(MINOR, E_INVALID_STATE, ("An %d is not configured",an));
+
+ if ((err = FmMacsecRxSaSetReceive(p_FmMacsecSecY->h_FmMacsec,p_FmSecYSc->scId, p_FmSecYSc->sa[an].saId, TRUE)) != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ p_FmSecYSc->sa[an].active = TRUE;
+ return err;
+}
+
+t_Error FM_MACSEC_SECY_RxSaDisableReceive(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+ t_SecYSc *p_FmSecYSc = (t_SecYSc *)h_Sc;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
+
+ if (p_FmSecYSc->sa[an].saId == SECY_AN_FREE_VALUE)
+ RETURN_ERROR(MINOR, E_INVALID_STATE, ("An %d is not configured",an));
+
+ if ((err = FmMacsecRxSaSetReceive(p_FmMacsecSecY->h_FmMacsec,p_FmSecYSc->scId, p_FmSecYSc->sa[an].saId, FALSE)) != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ p_FmSecYSc->sa[an].active = FALSE;
+ return err;
+}
+
+t_Error FM_MACSEC_SECY_RxSaUpdateNextPn(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, uint32_t updtNextPN)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+ t_SecYSc *p_FmSecYSc = (t_SecYSc *)h_Sc;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
+
+ if (p_FmSecYSc->sa[an].saId == SECY_AN_FREE_VALUE)
+ RETURN_ERROR(MINOR, E_INVALID_STATE, ("An %d is not configured",an));
+
+ if ((err = FmMacsecRxSaUpdateNextPn(p_FmMacsecSecY->h_FmMacsec,p_FmSecYSc->scId, p_FmSecYSc->sa[an].saId, updtNextPN)) != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ return err;
+}
+
+t_Error FM_MACSEC_SECY_RxSaUpdateLowestPn(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, uint32_t updtLowestPN)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+ t_SecYSc *p_FmSecYSc = (t_SecYSc *)h_Sc;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
+
+ if (p_FmSecYSc->sa[an].saId == SECY_AN_FREE_VALUE)
+ RETURN_ERROR(MINOR, E_INVALID_STATE, ("An %d is not configured",an));
+
+ if ((err = FmMacsecRxSaUpdateLowestPn(p_FmMacsecSecY->h_FmMacsec,p_FmSecYSc->scId, p_FmSecYSc->sa[an].saId, updtLowestPN)) != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ return err;
+}
+
+t_Error FM_MACSEC_SECY_RxSaModifyKey(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, macsecSAKey_t key)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+ t_SecYSc *p_FmSecYSc = (t_SecYSc *)h_Sc;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
+
+ if (p_FmSecYSc->sa[an].saId == SECY_AN_FREE_VALUE)
+ RETURN_ERROR(MINOR, E_INVALID_STATE, ("An %d is not configured",an));
+
+ if (p_FmSecYSc->sa[an].active)
+ if ((err = FmMacsecRxSaSetReceive(p_FmMacsecSecY->h_FmMacsec, p_FmSecYSc->scId, p_FmSecYSc->sa[an].saId, FALSE)) != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ /* TODO - statistics should be read */
+
+ if ((err = FmMacsecCreateRxSa(p_FmMacsecSecY->h_FmMacsec, p_FmSecYSc->scId, p_FmSecYSc->sa[an].saId, an, 1, key)) != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ if (p_FmSecYSc->sa[an].active)
+ if ((err = FmMacsecRxSaSetReceive(p_FmMacsecSecY->h_FmMacsec, p_FmSecYSc->scId, p_FmSecYSc->sa[an].saId, TRUE)) != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+ return err;
+}
+
+
+t_Error FM_MACSEC_SECY_CreateTxSa(t_Handle h_FmMacsecSecY, macsecAN_t an, macsecSAKey_t key)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+ t_SecYSc *p_FmSecYSc;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+ p_FmSecYSc = &p_FmMacsecSecY->p_TxSc[0];
+ SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
+
+ if (p_FmSecYSc->sa[an].saId != SECY_AN_FREE_VALUE)
+ RETURN_ERROR(MINOR, err, ("An %d is already assigned",an));
+
+ if ((err = FmMacsecCreateTxSa(p_FmMacsecSecY->h_FmMacsec,p_FmSecYSc->scId, (e_ScSaId)p_FmSecYSc->numOfSa, key)) != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ p_FmSecYSc->sa[an].saId = (e_ScSaId)p_FmSecYSc->numOfSa++;
+ return err;
+}
+
+t_Error FM_MACSEC_SECY_DeleteTxSa(t_Handle h_FmMacsecSecY, macsecAN_t an)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+ t_SecYSc *p_FmSecYSc;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+ p_FmSecYSc = &p_FmMacsecSecY->p_TxSc[0];
+ SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
+
+ if (p_FmSecYSc->sa[an].saId == SECY_AN_FREE_VALUE)
+ RETURN_ERROR(MINOR, E_INVALID_STATE, ("An %d is already deleted",an));
+
+ if ((err = FmMacsecDeleteTxSa(p_FmMacsecSecY->h_FmMacsec, p_FmSecYSc->scId, p_FmSecYSc->sa[an].saId)) != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ p_FmSecYSc->numOfSa--;
+ p_FmSecYSc->sa[an].saId = (e_ScSaId)SECY_AN_FREE_VALUE;
+ /* TODO - check if statistics need to be read*/
+ return err;
+}
+
+t_Error FM_MACSEC_SECY_TxSaModifyKey(t_Handle h_FmMacsecSecY, macsecAN_t nextActiveAn, macsecSAKey_t key)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+ t_SecYSc *p_FmSecYSc;
+ macsecAN_t currentAn;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+ p_FmSecYSc = &p_FmMacsecSecY->p_TxSc[0];
+ SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(nextActiveAn < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
+
+ if ((err = FmMacsecTxSaGetActive(p_FmMacsecSecY->h_FmMacsec,
+ p_FmSecYSc->scId,
+ &currentAn)) != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ if ((err = FmMacsecTxSaSetActive(p_FmMacsecSecY->h_FmMacsec,
+ p_FmSecYSc->scId,
+ p_FmSecYSc->sa[nextActiveAn].saId,
+ nextActiveAn)) != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ /* TODO - statistics should be read */
+
+ if ((err = FmMacsecCreateTxSa(p_FmMacsecSecY->h_FmMacsec, p_FmSecYSc->scId, p_FmSecYSc->sa[currentAn].saId, key)) != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ return err;
+}
+
+t_Error FM_MACSEC_SECY_TxSaSetActive(t_Handle h_FmMacsecSecY, macsecAN_t an)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+ t_SecYSc *p_FmSecYSc;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+ p_FmSecYSc = &p_FmMacsecSecY->p_TxSc[0];
+ SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(an < MAX_NUM_OF_SA_PER_SC, E_INVALID_STATE);
+
+ if (p_FmSecYSc->sa[an].saId == SECY_AN_FREE_VALUE)
+ RETURN_ERROR(MINOR, E_INVALID_STATE, ("An %d is not configured",an));
+
+ if ((err = FmMacsecTxSaSetActive(p_FmMacsecSecY->h_FmMacsec,
+ p_FmSecYSc->scId,
+ p_FmSecYSc->sa[an].saId,
+ an)) != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ return err;
+}
+
+t_Error FM_MACSEC_SECY_TxSaGetActive(t_Handle h_FmMacsecSecY, macsecAN_t *p_An)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+ t_SecYSc *p_FmSecYSc;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+ p_FmSecYSc = &p_FmMacsecSecY->p_TxSc[0];
+ SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_An, E_INVALID_HANDLE);
+
+ if ((err = FmMacsecTxSaGetActive(p_FmMacsecSecY->h_FmMacsec,
+ p_FmSecYSc->scId,
+ p_An)) != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ return err;
+}
+
+t_Error FM_MACSEC_SECY_GetRxScPhysId(t_Handle h_FmMacsecSecY, t_Handle h_Sc, uint32_t *p_ScPhysId)
+{
+ t_SecYSc *p_FmSecYSc = (t_SecYSc *)h_Sc;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(h_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(((t_FmMacsecSecY *)h_FmMacsecSecY)->h_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!((t_FmMacsecSecY *)h_FmMacsecSecY)->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
+#ifdef DISABLE_SANITY_CHECKS
+ UNUSED(h_FmMacsecSecY);
+#endif /* DISABLE_SANITY_CHECKS */
+
+ *p_ScPhysId = p_FmSecYSc->scId;
+ return err;
+}
+
+t_Error FM_MACSEC_SECY_GetTxScPhysId(t_Handle h_FmMacsecSecY, uint32_t *p_ScPhysId)
+{
+ t_FmMacsecSecY *p_FmMacsecSecY = (t_FmMacsecSecY *)h_FmMacsecSecY;
+ t_SecYSc *p_FmSecYSc;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmMacsecSecY->h_FmMacsec, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmMacsecSecY->p_FmMacsecSecYDriverParam, E_INVALID_STATE);
+ p_FmSecYSc = &p_FmMacsecSecY->p_TxSc[0];
+ SANITY_CHECK_RETURN_ERROR(p_FmSecYSc, E_INVALID_HANDLE);
+
+ *p_ScPhysId = p_FmSecYSc->scId;
+ return err;
+}
+
+t_Error FM_MACSEC_SECY_SetException(t_Handle h_FmMacsecSecY, e_FmMacsecExceptions exception, bool enable)
+{
+ UNUSED(h_FmMacsecSecY);UNUSED(exception);UNUSED(enable);
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+t_Error FM_MACSEC_SECY_SetEvent(t_Handle h_FmMacsecSecY, e_FmMacsecSecYEvents event, bool enable)
+{
+ UNUSED(h_FmMacsecSecY);UNUSED(event);UNUSED(enable);
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+t_Error FM_MACSEC_SECY_GetStatistics(t_Handle h_FmMacsecSecY, t_FmMacsecSecYStatistics *p_Statistics)
+{
+ UNUSED(h_FmMacsecSecY);UNUSED(p_Statistics);
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+t_Error FM_MACSEC_SECY_RxScGetStatistics(t_Handle h_FmMacsecSecY, t_Handle h_Sc, t_FmMacsecSecYRxScStatistics *p_Statistics)
+{
+ UNUSED(h_FmMacsecSecY);UNUSED(h_Sc);UNUSED(p_Statistics);
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+t_Error FM_MACSEC_SECY_RxSaGetStatistics(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, t_FmMacsecSecYRxSaStatistics *p_Statistics)
+{
+ UNUSED(h_FmMacsecSecY);UNUSED(h_Sc);UNUSED(an);UNUSED(p_Statistics);
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+t_Error FM_MACSEC_SECY_TxScGetStatistics(t_Handle h_FmMacsecSecY, t_FmMacsecSecYTxScStatistics *p_Statistics)
+{
+ UNUSED(h_FmMacsecSecY);UNUSED(p_Statistics);
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+t_Error FM_MACSEC_SECY_TxSaGetStatistics(t_Handle h_FmMacsecSecY, macsecAN_t an, t_FmMacsecSecYTxSaStatistics *p_Statistics)
+{
+ UNUSED(h_FmMacsecSecY);UNUSED(an);UNUSED(p_Statistics);
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
diff --git a/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_secy.h b/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_secy.h
new file mode 100644
index 000000000000..0cf624e68e2a
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec_secy.h
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2008-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/******************************************************************************
+ @File fm_macsec_secy.h
+
+ @Description FM MACSEC SecY internal structures and definitions.
+*//***************************************************************************/
+#ifndef __FM_MACSEC_SECY_H
+#define __FM_MACSEC_SECY_H
+
+#include "error_ext.h"
+#include "std_ext.h"
+
+#include "fm_macsec.h"
+
+
+/**************************************************************************//**
+ @Description Exceptions
+*//***************************************************************************/
+
+#define FM_MACSEC_SECY_EX_FRAME_DISCARDED 0x80000000
+
+#define GET_EXCEPTION_FLAG(bitMask, exception) switch (exception){ \
+ case e_FM_MACSEC_SECY_EX_FRAME_DISCARDED: \
+ bitMask = FM_MACSEC_SECY_EX_FRAME_DISCARDED; break; \
+ default: bitMask = 0;break;}
+
+/**************************************************************************//**
+ @Description Events
+*//***************************************************************************/
+
+#define FM_MACSEC_SECY_EV_NEXT_PN 0x80000000
+
+#define GET_EVENT_FLAG(bitMask, event) switch (event){ \
+ case e_FM_MACSEC_SECY_EV_NEXT_PN: \
+ bitMask = FM_MACSEC_SECY_EV_NEXT_PN; break; \
+ default: bitMask = 0;break;}
+
+/**************************************************************************//**
+ @Description Defaults
+*//***************************************************************************/
+
+#define DEFAULT_exceptions (FM_MACSEC_SECY_EX_FRAME_DISCARDED)
+#define DEFAULT_events (FM_MACSEC_SECY_EV_NEXT_PN)
+#define DEFAULT_numOfTxSc 1
+#define DEFAULT_confidentialityEnable FALSE
+#define DEFAULT_confidentialityOffset 0
+#define DEFAULT_sciInsertionMode e_FM_MACSEC_SCI_INSERTION_MODE_EXPLICIT_SECTAG
+#define DEFAULT_validateFrames e_FM_MACSEC_VALID_FRAME_BEHAVIOR_STRICT
+#define DEFAULT_replayEnable FALSE
+#define DEFAULT_replayWindow 0
+#define DEFAULT_protectFrames TRUE
+#define DEFAULT_ptp FALSE
+
+/**************************************************************************//**
+ @Description General defines
+*//***************************************************************************/
+
+#define SECY_AN_FREE_VALUE MAX_NUM_OF_SA_PER_SC
+
+
+typedef struct {
+ e_ScSaId saId;
+ bool active;
+ union {
+ t_FmMacsecSecYRxSaStatistics rxSaStatistics;
+ t_FmMacsecSecYTxSaStatistics txSaStatistics;
+ };
+} t_SecYSa;
+
+typedef struct {
+ bool inUse;
+ uint32_t scId;
+ e_ScType type;
+ uint8_t numOfSa;
+ t_SecYSa sa[MAX_NUM_OF_SA_PER_SC];
+ union {
+ t_FmMacsecSecYRxScStatistics rxScStatistics;
+ t_FmMacsecSecYTxScStatistics txScStatistics;
+ };
+} t_SecYSc;
+
+typedef struct {
+ t_FmMacsecSecYSCParams txScParams; /**< Tx SC Params */
+} t_FmMacsecSecYDriverParam;
+
+typedef struct {
+ t_Handle h_FmMacsec;
+ bool confidentialityEnable; /**< TRUE - confidentiality protection and integrity protection
+ FALSE - no confidentiality protection, only integrity protection*/
+ uint16_t confidentialityOffset; /**< The number of initial octets of each MSDU without confidentiality protection
+ common values are 0, 30, and 50 */
+ bool replayProtect; /**< replay protection function mode */
+ uint32_t replayWindow; /**< the size of the replay window */
+ e_FmMacsecValidFrameBehavior validateFrames; /**< validation function mode */
+ e_FmMacsecSciInsertionMode sciInsertionMode;
+ bool protectFrames;
+ bool isPointToPoint;
+ e_FmMacsecSecYCipherSuite cipherSuite; /**< Cipher suite to be used for this SecY */
+ uint32_t numOfRxSc; /**< Number of receive channels */
+ uint32_t numOfTxSc; /**< Number of transmit channels */
+ t_SecYSc *p_RxSc;
+ t_SecYSc *p_TxSc;
+ uint32_t events;
+ uint32_t exceptions;
+ t_FmMacsecSecYExceptionsCallback *f_Exception; /**< TODO */
+ t_FmMacsecSecYEventsCallback *f_Event; /**< TODO */
+ t_Handle h_App;
+ t_FmMacsecSecYStatistics statistics;
+ t_FmMacsecSecYDriverParam *p_FmMacsecSecYDriverParam;
+} t_FmMacsecSecY;
+
+
+#endif /* __FM_MACSEC_SECY_H */
diff --git a/sys/contrib/ncsw/Peripherals/FM/Pcd/crc64.h b/sys/contrib/ncsw/Peripherals/FM/Pcd/crc64.h
new file mode 100644
index 000000000000..335ee6819188
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/Pcd/crc64.h
@@ -0,0 +1,360 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+ /**************************************************************************//**
+ @File crc64.h
+
+ @Description brief This file contains the CRC64 Table, and __inline__
+ functions used for calculating crc.
+*//***************************************************************************/
+#ifndef __CRC64_H
+#define __CRC64_H
+
+#include "std_ext.h"
+
+
+#define BITS_PER_BYTE 8
+
+#define CRC64_EXPON_ECMA_182 0xC96C5795D7870F42ULL
+#define CRC64_DEFAULT_INITVAL 0xFFFFFFFFFFFFFFFFULL
+
+#define CRC64_BYTE_MASK 0xFF
+#define CRC64_TABLE_ENTRIES ( 1 << BITS_PER_BYTE )
+#define CRC64_ODD_MASK 1
+
+
+/**
+ \brief '64 bit crc' Table
+ */
+struct crc64_t {
+ uint64_t initial; /**< Initial seed */
+ uint64_t table[CRC64_TABLE_ENTRIES]; /**< CRC table entries */
+};
+
+
+static struct crc64_t CRC64_ECMA_182 = {
+ CRC64_DEFAULT_INITVAL,
+ {
+ 0x0000000000000000ULL,
+ 0xb32e4cbe03a75f6fULL,
+ 0xf4843657a840a05bULL,
+ 0x47aa7ae9abe7ff34ULL,
+ 0x7bd0c384ff8f5e33ULL,
+ 0xc8fe8f3afc28015cULL,
+ 0x8f54f5d357cffe68ULL,
+ 0x3c7ab96d5468a107ULL,
+ 0xf7a18709ff1ebc66ULL,
+ 0x448fcbb7fcb9e309ULL,
+ 0x0325b15e575e1c3dULL,
+ 0xb00bfde054f94352ULL,
+ 0x8c71448d0091e255ULL,
+ 0x3f5f08330336bd3aULL,
+ 0x78f572daa8d1420eULL,
+ 0xcbdb3e64ab761d61ULL,
+ 0x7d9ba13851336649ULL,
+ 0xceb5ed8652943926ULL,
+ 0x891f976ff973c612ULL,
+ 0x3a31dbd1fad4997dULL,
+ 0x064b62bcaebc387aULL,
+ 0xb5652e02ad1b6715ULL,
+ 0xf2cf54eb06fc9821ULL,
+ 0x41e11855055bc74eULL,
+ 0x8a3a2631ae2dda2fULL,
+ 0x39146a8fad8a8540ULL,
+ 0x7ebe1066066d7a74ULL,
+ 0xcd905cd805ca251bULL,
+ 0xf1eae5b551a2841cULL,
+ 0x42c4a90b5205db73ULL,
+ 0x056ed3e2f9e22447ULL,
+ 0xb6409f5cfa457b28ULL,
+ 0xfb374270a266cc92ULL,
+ 0x48190ecea1c193fdULL,
+ 0x0fb374270a266cc9ULL,
+ 0xbc9d3899098133a6ULL,
+ 0x80e781f45de992a1ULL,
+ 0x33c9cd4a5e4ecdceULL,
+ 0x7463b7a3f5a932faULL,
+ 0xc74dfb1df60e6d95ULL,
+ 0x0c96c5795d7870f4ULL,
+ 0xbfb889c75edf2f9bULL,
+ 0xf812f32ef538d0afULL,
+ 0x4b3cbf90f69f8fc0ULL,
+ 0x774606fda2f72ec7ULL,
+ 0xc4684a43a15071a8ULL,
+ 0x83c230aa0ab78e9cULL,
+ 0x30ec7c140910d1f3ULL,
+ 0x86ace348f355aadbULL,
+ 0x3582aff6f0f2f5b4ULL,
+ 0x7228d51f5b150a80ULL,
+ 0xc10699a158b255efULL,
+ 0xfd7c20cc0cdaf4e8ULL,
+ 0x4e526c720f7dab87ULL,
+ 0x09f8169ba49a54b3ULL,
+ 0xbad65a25a73d0bdcULL,
+ 0x710d64410c4b16bdULL,
+ 0xc22328ff0fec49d2ULL,
+ 0x85895216a40bb6e6ULL,
+ 0x36a71ea8a7ace989ULL,
+ 0x0adda7c5f3c4488eULL,
+ 0xb9f3eb7bf06317e1ULL,
+ 0xfe5991925b84e8d5ULL,
+ 0x4d77dd2c5823b7baULL,
+ 0x64b62bcaebc387a1ULL,
+ 0xd7986774e864d8ceULL,
+ 0x90321d9d438327faULL,
+ 0x231c512340247895ULL,
+ 0x1f66e84e144cd992ULL,
+ 0xac48a4f017eb86fdULL,
+ 0xebe2de19bc0c79c9ULL,
+ 0x58cc92a7bfab26a6ULL,
+ 0x9317acc314dd3bc7ULL,
+ 0x2039e07d177a64a8ULL,
+ 0x67939a94bc9d9b9cULL,
+ 0xd4bdd62abf3ac4f3ULL,
+ 0xe8c76f47eb5265f4ULL,
+ 0x5be923f9e8f53a9bULL,
+ 0x1c4359104312c5afULL,
+ 0xaf6d15ae40b59ac0ULL,
+ 0x192d8af2baf0e1e8ULL,
+ 0xaa03c64cb957be87ULL,
+ 0xeda9bca512b041b3ULL,
+ 0x5e87f01b11171edcULL,
+ 0x62fd4976457fbfdbULL,
+ 0xd1d305c846d8e0b4ULL,
+ 0x96797f21ed3f1f80ULL,
+ 0x2557339fee9840efULL,
+ 0xee8c0dfb45ee5d8eULL,
+ 0x5da24145464902e1ULL,
+ 0x1a083bacedaefdd5ULL,
+ 0xa9267712ee09a2baULL,
+ 0x955cce7fba6103bdULL,
+ 0x267282c1b9c65cd2ULL,
+ 0x61d8f8281221a3e6ULL,
+ 0xd2f6b4961186fc89ULL,
+ 0x9f8169ba49a54b33ULL,
+ 0x2caf25044a02145cULL,
+ 0x6b055fede1e5eb68ULL,
+ 0xd82b1353e242b407ULL,
+ 0xe451aa3eb62a1500ULL,
+ 0x577fe680b58d4a6fULL,
+ 0x10d59c691e6ab55bULL,
+ 0xa3fbd0d71dcdea34ULL,
+ 0x6820eeb3b6bbf755ULL,
+ 0xdb0ea20db51ca83aULL,
+ 0x9ca4d8e41efb570eULL,
+ 0x2f8a945a1d5c0861ULL,
+ 0x13f02d374934a966ULL,
+ 0xa0de61894a93f609ULL,
+ 0xe7741b60e174093dULL,
+ 0x545a57dee2d35652ULL,
+ 0xe21ac88218962d7aULL,
+ 0x5134843c1b317215ULL,
+ 0x169efed5b0d68d21ULL,
+ 0xa5b0b26bb371d24eULL,
+ 0x99ca0b06e7197349ULL,
+ 0x2ae447b8e4be2c26ULL,
+ 0x6d4e3d514f59d312ULL,
+ 0xde6071ef4cfe8c7dULL,
+ 0x15bb4f8be788911cULL,
+ 0xa6950335e42fce73ULL,
+ 0xe13f79dc4fc83147ULL,
+ 0x521135624c6f6e28ULL,
+ 0x6e6b8c0f1807cf2fULL,
+ 0xdd45c0b11ba09040ULL,
+ 0x9aefba58b0476f74ULL,
+ 0x29c1f6e6b3e0301bULL,
+ 0xc96c5795d7870f42ULL,
+ 0x7a421b2bd420502dULL,
+ 0x3de861c27fc7af19ULL,
+ 0x8ec62d7c7c60f076ULL,
+ 0xb2bc941128085171ULL,
+ 0x0192d8af2baf0e1eULL,
+ 0x4638a2468048f12aULL,
+ 0xf516eef883efae45ULL,
+ 0x3ecdd09c2899b324ULL,
+ 0x8de39c222b3eec4bULL,
+ 0xca49e6cb80d9137fULL,
+ 0x7967aa75837e4c10ULL,
+ 0x451d1318d716ed17ULL,
+ 0xf6335fa6d4b1b278ULL,
+ 0xb199254f7f564d4cULL,
+ 0x02b769f17cf11223ULL,
+ 0xb4f7f6ad86b4690bULL,
+ 0x07d9ba1385133664ULL,
+ 0x4073c0fa2ef4c950ULL,
+ 0xf35d8c442d53963fULL,
+ 0xcf273529793b3738ULL,
+ 0x7c0979977a9c6857ULL,
+ 0x3ba3037ed17b9763ULL,
+ 0x888d4fc0d2dcc80cULL,
+ 0x435671a479aad56dULL,
+ 0xf0783d1a7a0d8a02ULL,
+ 0xb7d247f3d1ea7536ULL,
+ 0x04fc0b4dd24d2a59ULL,
+ 0x3886b22086258b5eULL,
+ 0x8ba8fe9e8582d431ULL,
+ 0xcc0284772e652b05ULL,
+ 0x7f2cc8c92dc2746aULL,
+ 0x325b15e575e1c3d0ULL,
+ 0x8175595b76469cbfULL,
+ 0xc6df23b2dda1638bULL,
+ 0x75f16f0cde063ce4ULL,
+ 0x498bd6618a6e9de3ULL,
+ 0xfaa59adf89c9c28cULL,
+ 0xbd0fe036222e3db8ULL,
+ 0x0e21ac88218962d7ULL,
+ 0xc5fa92ec8aff7fb6ULL,
+ 0x76d4de52895820d9ULL,
+ 0x317ea4bb22bfdfedULL,
+ 0x8250e80521188082ULL,
+ 0xbe2a516875702185ULL,
+ 0x0d041dd676d77eeaULL,
+ 0x4aae673fdd3081deULL,
+ 0xf9802b81de97deb1ULL,
+ 0x4fc0b4dd24d2a599ULL,
+ 0xfceef8632775faf6ULL,
+ 0xbb44828a8c9205c2ULL,
+ 0x086ace348f355aadULL,
+ 0x34107759db5dfbaaULL,
+ 0x873e3be7d8faa4c5ULL,
+ 0xc094410e731d5bf1ULL,
+ 0x73ba0db070ba049eULL,
+ 0xb86133d4dbcc19ffULL,
+ 0x0b4f7f6ad86b4690ULL,
+ 0x4ce50583738cb9a4ULL,
+ 0xffcb493d702be6cbULL,
+ 0xc3b1f050244347ccULL,
+ 0x709fbcee27e418a3ULL,
+ 0x3735c6078c03e797ULL,
+ 0x841b8ab98fa4b8f8ULL,
+ 0xadda7c5f3c4488e3ULL,
+ 0x1ef430e13fe3d78cULL,
+ 0x595e4a08940428b8ULL,
+ 0xea7006b697a377d7ULL,
+ 0xd60abfdbc3cbd6d0ULL,
+ 0x6524f365c06c89bfULL,
+ 0x228e898c6b8b768bULL,
+ 0x91a0c532682c29e4ULL,
+ 0x5a7bfb56c35a3485ULL,
+ 0xe955b7e8c0fd6beaULL,
+ 0xaeffcd016b1a94deULL,
+ 0x1dd181bf68bdcbb1ULL,
+ 0x21ab38d23cd56ab6ULL,
+ 0x9285746c3f7235d9ULL,
+ 0xd52f0e859495caedULL,
+ 0x6601423b97329582ULL,
+ 0xd041dd676d77eeaaULL,
+ 0x636f91d96ed0b1c5ULL,
+ 0x24c5eb30c5374ef1ULL,
+ 0x97eba78ec690119eULL,
+ 0xab911ee392f8b099ULL,
+ 0x18bf525d915feff6ULL,
+ 0x5f1528b43ab810c2ULL,
+ 0xec3b640a391f4fadULL,
+ 0x27e05a6e926952ccULL,
+ 0x94ce16d091ce0da3ULL,
+ 0xd3646c393a29f297ULL,
+ 0x604a2087398eadf8ULL,
+ 0x5c3099ea6de60cffULL,
+ 0xef1ed5546e415390ULL,
+ 0xa8b4afbdc5a6aca4ULL,
+ 0x1b9ae303c601f3cbULL,
+ 0x56ed3e2f9e224471ULL,
+ 0xe5c372919d851b1eULL,
+ 0xa26908783662e42aULL,
+ 0x114744c635c5bb45ULL,
+ 0x2d3dfdab61ad1a42ULL,
+ 0x9e13b115620a452dULL,
+ 0xd9b9cbfcc9edba19ULL,
+ 0x6a978742ca4ae576ULL,
+ 0xa14cb926613cf817ULL,
+ 0x1262f598629ba778ULL,
+ 0x55c88f71c97c584cULL,
+ 0xe6e6c3cfcadb0723ULL,
+ 0xda9c7aa29eb3a624ULL,
+ 0x69b2361c9d14f94bULL,
+ 0x2e184cf536f3067fULL,
+ 0x9d36004b35545910ULL,
+ 0x2b769f17cf112238ULL,
+ 0x9858d3a9ccb67d57ULL,
+ 0xdff2a94067518263ULL,
+ 0x6cdce5fe64f6dd0cULL,
+ 0x50a65c93309e7c0bULL,
+ 0xe388102d33392364ULL,
+ 0xa4226ac498dedc50ULL,
+ 0x170c267a9b79833fULL,
+ 0xdcd7181e300f9e5eULL,
+ 0x6ff954a033a8c131ULL,
+ 0x28532e49984f3e05ULL,
+ 0x9b7d62f79be8616aULL,
+ 0xa707db9acf80c06dULL,
+ 0x14299724cc279f02ULL,
+ 0x5383edcd67c06036ULL,
+ 0xe0ada17364673f59ULL
+ }
+};
+
+
+/**
+ \brief Initializes the crc seed
+ */
+static __inline__ uint64_t crc64_init(void)
+{
+ return CRC64_ECMA_182.initial;
+}
+
+/**
+ \brief Computes 64 bit the crc
+ \param[in] data Pointer to the Data in the frame
+ \param[in] len Length of the Data
+ \param[in] crc seed
+ \return calculated crc
+ */
+static __inline__ uint64_t crc64_compute(void const *data,
+ uint32_t len,
+ uint64_t seed)
+{
+ uint32_t i;
+ uint64_t crc = seed;
+ uint8_t *bdata = (uint8_t *) data;
+
+ for (i = 0; i < len; i++)
+ crc =
+ CRC64_ECMA_182.
+ table[(crc ^ *bdata++) & CRC64_BYTE_MASK] ^ (crc >> 8);
+
+ return crc;
+}
+
+
+#endif /* __CRC64_H */
diff --git a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_cc.c b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_cc.c
index fe765a475614..c633fce847ee 100644
--- a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_cc.c
+++ b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_cc.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,11 +30,14 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm_cc.c
- @Description FM CC ...
-*//***************************************************************************/
+ @Description FM Coarse Classifier implementation
+ *//***************************************************************************/
+#include <sys/cdefs.h>
+#include <sys/endian.h>
#include "std_ext.h"
#include "error_ext.h"
#include "string_ext.h"
@@ -43,376 +46,1178 @@
#include "fm_muram_ext.h"
#include "fm_common.h"
+#include "fm_pcd.h"
#include "fm_hc.h"
#include "fm_cc.h"
+#include "crc64.h"
+
+/****************************************/
+/* static functions */
+/****************************************/
-#if defined(FM_CAPWAP_SUPPORT)
-#define FM_PCD_CC_MANIP
-#endif /* defined(FM_CAPWAP_SUPPORT) || ... */
+static t_Error CcRootTryLock(t_Handle h_FmPcdCcTree)
+{
+ t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;
+ ASSERT_COND(h_FmPcdCcTree);
+
+ if (FmPcdLockTryLock(p_FmPcdCcTree->p_Lock))
+ return E_OK;
-t_Handle FmPcdCcTreeGetSavedManipParams(t_Handle h_FmTree, uint8_t manipIndx)
+ return ERROR_CODE(E_BUSY);
+}
+
+static void CcRootReleaseLock(t_Handle h_FmPcdCcTree)
{
- t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmTree;
+ t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;
- ASSERT_COND(p_FmPcdCcTree);
+ ASSERT_COND(h_FmPcdCcTree);
- return p_FmPcdCcTree->fmPcdCcSavedManipParams[manipIndx];
+ FmPcdLockUnlock(p_FmPcdCcTree->p_Lock);
}
-void FmPcdCcTreeSetSavedManipParams(t_Handle h_FmTree, t_Handle h_SavedManipParams, uint8_t manipIndx)
+static void UpdateNodeOwner(t_FmPcdCcNode *p_CcNode, bool add)
{
- t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmTree;
+ uint32_t intFlags;
- ASSERT_COND(p_FmPcdCcTree);
+ ASSERT_COND(p_CcNode);
- p_FmPcdCcTree->fmPcdCcSavedManipParams[manipIndx] = h_SavedManipParams;
+ intFlags = XX_LockIntrSpinlock(p_CcNode->h_Spinlock);
+
+ if (add)
+ p_CcNode->owners++;
+ else
+ {
+ ASSERT_COND(p_CcNode->owners);
+ p_CcNode->owners--;
+ }
+
+ XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
}
-uint8_t FmPcdCcGetParseCode(t_Handle h_CcNode)
+static __inline__ t_FmPcdStatsObj* DequeueStatsObj(t_List *p_List)
{
- t_FmPcdCcNode *p_FmPcdCcNode = (t_FmPcdCcNode *)h_CcNode;
+ t_FmPcdStatsObj *p_StatsObj = NULL;
+ t_List *p_Next;
+
+ if (!NCSW_LIST_IsEmpty(p_List))
+ {
+ p_Next = NCSW_LIST_FIRST(p_List);
+ p_StatsObj = NCSW_LIST_OBJECT(p_Next, t_FmPcdStatsObj, node);
+ ASSERT_COND(p_StatsObj);
+ NCSW_LIST_DelAndInit(p_Next);
+ }
- ASSERT_COND(p_FmPcdCcNode);
- return p_FmPcdCcNode->parseCode;
+ return p_StatsObj;
}
-uint8_t FmPcdCcGetOffset(t_Handle h_CcNode)
+static __inline__ void EnqueueStatsObj(t_List *p_List,
+ t_FmPcdStatsObj *p_StatsObj)
+{
+ NCSW_LIST_AddToTail(&p_StatsObj->node, p_List);
+}
+
+static void FreeStatObjects(t_List *p_List, t_Handle h_FmMuram)
{
- t_FmPcdCcNode *p_FmPcdCcNode = (t_FmPcdCcNode *)h_CcNode;
+ t_FmPcdStatsObj *p_StatsObj;
+
+ while (!NCSW_LIST_IsEmpty(p_List))
+ {
+ p_StatsObj = DequeueStatsObj(p_List);
+ ASSERT_COND(p_StatsObj);
+
+ FM_MURAM_FreeMem(h_FmMuram, p_StatsObj->h_StatsAd);
+ FM_MURAM_FreeMem(h_FmMuram, p_StatsObj->h_StatsCounters);
- ASSERT_COND(p_FmPcdCcNode);
- return p_FmPcdCcNode->offset;
+ XX_Free(p_StatsObj);
+ }
}
-uint16_t FmPcdCcGetNumOfKeys(t_Handle h_CcNode)
+static t_FmPcdStatsObj* GetStatsObj(t_FmPcdCcNode *p_CcNode)
{
- t_FmPcdCcNode *p_FmPcdCcNode = (t_FmPcdCcNode *)h_CcNode;
+ t_FmPcdStatsObj* p_StatsObj;
+ t_Handle h_FmMuram;
+
+ ASSERT_COND(p_CcNode);
- ASSERT_COND(p_FmPcdCcNode);
- return p_FmPcdCcNode->numOfKeys;
+ /* If 'maxNumOfKeys' was passed, all statistics object were preallocated
+ upon node initialization */
+ if (p_CcNode->maxNumOfKeys)
+ {
+ p_StatsObj = DequeueStatsObj(&p_CcNode->availableStatsLst);
+ }
+ else
+ {
+ h_FmMuram = ((t_FmPcd *)(p_CcNode->h_FmPcd))->h_FmMuram;
+ ASSERT_COND(h_FmMuram);
+
+ p_StatsObj = XX_Malloc(sizeof(t_FmPcdStatsObj));
+ if (!p_StatsObj)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("statistics object"));
+ return NULL;
+ }
+
+ p_StatsObj->h_StatsAd = (t_Handle)FM_MURAM_AllocMem(
+ h_FmMuram, FM_PCD_CC_AD_ENTRY_SIZE, FM_PCD_CC_AD_TABLE_ALIGN);
+ if (!p_StatsObj->h_StatsAd)
+ {
+ XX_Free(p_StatsObj);
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for statistics ADs"));
+ return NULL;
+ }
+ MemSet8(p_StatsObj->h_StatsAd, 0, FM_PCD_CC_AD_ENTRY_SIZE);
+
+ p_StatsObj->h_StatsCounters = (t_Handle)FM_MURAM_AllocMem(
+ h_FmMuram, p_CcNode->countersArraySize,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if (!p_StatsObj->h_StatsCounters)
+ {
+ FM_MURAM_FreeMem(h_FmMuram, p_StatsObj->h_StatsAd);
+ XX_Free(p_StatsObj);
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for statistics counters"));
+ return NULL;
+ }
+ MemSet8(p_StatsObj->h_StatsCounters, 0, p_CcNode->countersArraySize);
+ }
+
+ return p_StatsObj;
}
-static void EnqueueNodeInfoToRelevantLst(t_List *p_List, t_CcNodeInformation *p_CcInfo)
+
+static void PutStatsObj(t_FmPcdCcNode *p_CcNode, t_FmPcdStatsObj *p_StatsObj)
{
- t_CcNodeInformation *p_CcInformation;
- uint32_t intFlags;
+ t_Handle h_FmMuram;
- p_CcInformation = (t_CcNodeInformation *)XX_Malloc(sizeof(t_CcNodeInformation));
- if (p_CcInformation)
+ ASSERT_COND(p_CcNode);
+ ASSERT_COND(p_StatsObj);
+
+ /* If 'maxNumOfKeys' was passed, all statistics object were preallocated
+ upon node initialization and now will be enqueued back to the list */
+ if (p_CcNode->maxNumOfKeys)
{
- memset(p_CcInformation, 0, sizeof(t_CcNodeInformation));
- memcpy(p_CcInformation, p_CcInfo, sizeof(t_CcNodeInformation));
- INIT_LIST(&p_CcInformation->node);
+ /* Nullify counters */
+ MemSet8(p_StatsObj->h_StatsCounters, 0, p_CcNode->countersArraySize);
- intFlags = XX_DisableAllIntr();
- LIST_AddToTail(&p_CcInformation->node, p_List);
- XX_RestoreAllIntr(intFlags);
+ EnqueueStatsObj(&p_CcNode->availableStatsLst, p_StatsObj);
}
else
- REPORT_ERROR(MAJOR, E_NO_MEMORY, ("CC Node Information"));
+ {
+ h_FmMuram = ((t_FmPcd *)(p_CcNode->h_FmPcd))->h_FmMuram;
+ ASSERT_COND(h_FmMuram);
+
+ FM_MURAM_FreeMem(h_FmMuram, p_StatsObj->h_StatsAd);
+ FM_MURAM_FreeMem(h_FmMuram, p_StatsObj->h_StatsCounters);
+
+ XX_Free(p_StatsObj);
+ }
+}
+
+static void SetStatsCounters(t_AdOfTypeStats *p_StatsAd,
+ uint32_t statsCountersAddr)
+{
+ uint32_t tmp = (statsCountersAddr & FM_PCD_AD_STATS_COUNTERS_ADDR_MASK);
+
+ WRITE_UINT32(p_StatsAd->statsTableAddr, tmp);
}
-static t_CcNodeInformation* FindNodeInfoInReleventLst(t_List *p_List, t_Handle h_Info)
+static void UpdateStatsAd(t_FmPcdCcStatsParams *p_FmPcdCcStatsParams,
+ t_Handle h_Ad, uint64_t physicalMuramBase)
{
- t_CcNodeInformation *p_CcInformation;
- t_List *p_Pos;
- uint32_t intFlags;
+ t_AdOfTypeStats *p_StatsAd;
+ uint32_t statsCountersAddr, nextActionAddr, tmp;
+#if (DPAA_VERSION >= 11)
+ uint32_t frameLengthRangesAddr;
+#endif /* (DPAA_VERSION >= 11) */
+
+ p_StatsAd = (t_AdOfTypeStats *)p_FmPcdCcStatsParams->h_StatsAd;
+
+ tmp = FM_PCD_AD_STATS_TYPE;
- intFlags = XX_DisableAllIntr();
- for (p_Pos = NCSW_LIST_FIRST(p_List); p_Pos != (p_List); p_Pos = NCSW_LIST_NEXT(p_Pos))
+#if (DPAA_VERSION >= 11)
+ if (p_FmPcdCcStatsParams->h_StatsFLRs)
{
- p_CcInformation = CC_NODE_F_OBJECT(p_Pos);
- ASSERT_COND(p_CcInformation->h_CcNode);
- if(p_CcInformation->h_CcNode == h_Info)
- {
- XX_RestoreAllIntr(intFlags);
- return p_CcInformation;
- }
+ frameLengthRangesAddr = (uint32_t)((XX_VirtToPhys(
+ p_FmPcdCcStatsParams->h_StatsFLRs) - physicalMuramBase));
+ tmp |= (frameLengthRangesAddr & FM_PCD_AD_STATS_FLR_ADDR_MASK);
}
- XX_RestoreAllIntr(intFlags);
- return NULL;
+#endif /* (DPAA_VERSION >= 11) */
+ WRITE_UINT32(p_StatsAd->profileTableAddr, tmp);
+
+ nextActionAddr = (uint32_t)((XX_VirtToPhys(h_Ad) - physicalMuramBase));
+ tmp = 0;
+ tmp |= (uint32_t)((nextActionAddr << FM_PCD_AD_STATS_NEXT_ACTION_SHIFT)
+ & FM_PCD_AD_STATS_NEXT_ACTION_MASK);
+ tmp |= (FM_PCD_AD_STATS_NAD_EN | FM_PCD_AD_STATS_OP_CODE);
+
+#if (DPAA_VERSION >= 11)
+ if (p_FmPcdCcStatsParams->h_StatsFLRs)
+ tmp |= FM_PCD_AD_STATS_FLR_EN;
+#endif /* (DPAA_VERSION >= 11) */
+
+ WRITE_UINT32(p_StatsAd->nextActionIndx, tmp);
+
+ statsCountersAddr = (uint32_t)((XX_VirtToPhys(
+ p_FmPcdCcStatsParams->h_StatsCounters) - physicalMuramBase));
+ SetStatsCounters(p_StatsAd, statsCountersAddr);
}
-static void DequeueNodeInfoFromRelevantLst(t_List *p_List, t_Handle h_Info)
+static void FillAdOfTypeContLookup(t_Handle h_Ad,
+ t_FmPcdCcStatsParams *p_FmPcdCcStatsParams,
+ t_Handle h_FmPcd, t_Handle p_CcNode,
+ t_Handle h_Manip, t_Handle h_FrmReplic)
{
- t_CcNodeInformation *p_CcInformation = NULL;
- uint32_t intFlags;
- t_List *p_Pos;
+ t_FmPcdCcNode *p_Node = (t_FmPcdCcNode *)p_CcNode;
+ t_AdOfTypeContLookup *p_AdContLookup = (t_AdOfTypeContLookup *)h_Ad;
+ t_Handle h_TmpAd;
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ uint32_t tmpReg32;
+ t_Handle p_AdNewPtr = NULL;
+
+ UNUSED(h_Manip);
+ UNUSED(h_FrmReplic);
+
+ /* there are 3 cases handled in this routine of building a "Continue lookup" type AD.
+ * Case 1: No Manip. The action descriptor is built within the match table.
+ * p_AdResult = p_AdNewPtr;
+ * Case 2: Manip exists. A new AD is created - p_AdNewPtr. It is initialized
+ * either in the FmPcdManipUpdateAdResultForCc routine or it was already
+ * initialized and returned here.
+ * p_AdResult (within the match table) will be initialized after
+ * this routine returns and point to the existing AD.
+ * Case 3: Manip exists. The action descriptor is built within the match table.
+ * FmPcdManipUpdateAdContLookupForCc returns a NULL p_AdNewPtr.
+ */
+
+ /* As default, the "new" ptr is the current one. i.e. the content of the result
+ * AD will be written into the match table itself (case (1))*/
+ p_AdNewPtr = p_AdContLookup;
- intFlags = XX_DisableAllIntr();
- if (LIST_IsEmpty(p_List))
+ /* Initialize an action descriptor, if current statistics mode requires an Ad */
+ if (p_FmPcdCcStatsParams)
{
- XX_RestoreAllIntr(intFlags);
- return;
+ ASSERT_COND(p_FmPcdCcStatsParams->h_StatsAd);
+ ASSERT_COND(p_FmPcdCcStatsParams->h_StatsCounters);
+
+ /* Swapping addresses between statistics Ad and the current lookup AD */
+ h_TmpAd = p_FmPcdCcStatsParams->h_StatsAd;
+ p_FmPcdCcStatsParams->h_StatsAd = h_Ad;
+ h_Ad = h_TmpAd;
+
+ p_AdNewPtr = h_Ad;
+ p_AdContLookup = h_Ad;
+
+ /* Init statistics Ad and connect current lookup AD as 'next action' from statistics Ad */
+ UpdateStatsAd(p_FmPcdCcStatsParams, h_Ad, p_FmPcd->physicalMuramBase);
}
- for (p_Pos = NCSW_LIST_FIRST(p_List); p_Pos != (p_List); p_Pos = NCSW_LIST_NEXT(p_Pos))
+#if DPAA_VERSION >= 11
+ if (h_Manip && h_FrmReplic)
+ FmPcdManipUpdateAdContLookupForCc(
+ h_Manip,
+ h_Ad,
+ &p_AdNewPtr,
+ (uint32_t)((XX_VirtToPhys(
+ FrmReplicGroupGetSourceTableDescriptor(h_FrmReplic))
+ - p_FmPcd->physicalMuramBase)));
+ else
+ if (h_FrmReplic)
+ FrmReplicGroupUpdateAd(h_FrmReplic, h_Ad, &p_AdNewPtr);
+ else
+#endif /* (DPAA_VERSION >= 11) */
+ if (h_Manip)
+ FmPcdManipUpdateAdContLookupForCc(
+ h_Manip,
+ h_Ad,
+ &p_AdNewPtr,
+
+#ifdef FM_CAPWAP_SUPPORT
+ /*no check for opcode of manip - this step can be reached only with capwap_applic_specific*/
+ (uint32_t)((XX_VirtToPhys(p_Node->h_AdTable) - p_FmPcd->physicalMuramBase))
+#else /* not FM_CAPWAP_SUPPORT */
+ (uint32_t)((XX_VirtToPhys(p_Node->h_Ad)
+ - p_FmPcd->physicalMuramBase))
+#endif /* not FM_CAPWAP_SUPPORT */
+ );
+
+ /* if (p_AdNewPtr = NULL) --> Done. (case (3)) */
+ if (p_AdNewPtr)
{
- p_CcInformation = CC_NODE_F_OBJECT(p_Pos);
- ASSERT_COND(p_CcInformation->h_CcNode);
- if (p_CcInformation->h_CcNode == h_Info)
- break;
+ /* cases (1) & (2) */
+ tmpReg32 = 0;
+ tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
+ tmpReg32 |=
+ p_Node->sizeOfExtraction ? ((p_Node->sizeOfExtraction - 1) << 24) :
+ 0;
+ tmpReg32 |= (uint32_t)(XX_VirtToPhys(p_Node->h_AdTable)
+ - p_FmPcd->physicalMuramBase);
+ WRITE_UINT32(p_AdContLookup->ccAdBase, tmpReg32);
+
+ tmpReg32 = 0;
+ tmpReg32 |= p_Node->numOfKeys << 24;
+ tmpReg32 |= (p_Node->lclMask ? FM_PCD_AD_CONT_LOOKUP_LCL_MASK : 0);
+ tmpReg32 |=
+ p_Node->h_KeysMatchTable ? (uint32_t)(XX_VirtToPhys(
+ p_Node->h_KeysMatchTable) - p_FmPcd->physicalMuramBase) :
+ 0;
+ WRITE_UINT32(p_AdContLookup->matchTblPtr, tmpReg32);
+
+ tmpReg32 = 0;
+ tmpReg32 |= p_Node->prsArrayOffset << 24;
+ tmpReg32 |= p_Node->offset << 16;
+ tmpReg32 |= p_Node->parseCode;
+ WRITE_UINT32(p_AdContLookup->pcAndOffsets, tmpReg32);
+
+ MemCpy8((void*)&p_AdContLookup->gmask, p_Node->p_GlblMask,
+ CC_GLBL_MASK_SIZE);
}
- if (p_CcInformation)
- LIST_DelAndInit(&p_CcInformation->node);
- XX_RestoreAllIntr(intFlags);
}
-static t_Error FmPcdCcSetRequiredAction(t_Handle h_FmPcd, uint32_t requiredAction, t_FmPcdCcNextEngineAndRequiredActionParams *p_CcNextEngineParamsTmp,
- t_Handle h_AdTmp, uint16_t numOfEntries, t_Handle h_Tree)
+static t_Error AllocAndFillAdForContLookupManip(t_Handle h_CcNode)
{
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+ uint32_t intFlags;
+
+ ASSERT_COND(p_CcNode);
+
+ intFlags = XX_LockIntrSpinlock(p_CcNode->h_Spinlock);
+
+ if (!p_CcNode->h_Ad)
+ {
+ if (p_CcNode->maxNumOfKeys)
+ p_CcNode->h_Ad = p_CcNode->h_TmpAd;
+ else
+ p_CcNode->h_Ad = (t_Handle)FM_MURAM_AllocMem(
+ ((t_FmPcd *)(p_CcNode->h_FmPcd))->h_FmMuram,
+ FM_PCD_CC_AD_ENTRY_SIZE, FM_PCD_CC_AD_TABLE_ALIGN);
- t_AdOfTypeResult *p_AdTmp = (t_AdOfTypeResult *)h_AdTmp;
- uint32_t tmpReg32;
- t_Error err;
- t_FmPcdCcNode *p_FmPcdCcNode;
- int i = 0;
- uint16_t tmp = 0;
- uint16_t profileId;
- uint8_t relativeSchemeId, physicalSchemeId;
+ XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
+
+ if (!p_CcNode->h_Ad)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("MURAM allocation for CC action descriptor"));
+
+ MemSet8(p_CcNode->h_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
+
+ FillAdOfTypeContLookup(p_CcNode->h_Ad, NULL, p_CcNode->h_FmPcd,
+ p_CcNode, NULL, NULL);
+ }
+ else
+ XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
+
+ return E_OK;
+}
+
+static t_Error SetRequiredAction1(
+ t_Handle h_FmPcd, uint32_t requiredAction,
+ t_FmPcdCcKeyAndNextEngineParams *p_CcKeyAndNextEngineParamsTmp,
+ t_Handle h_AdTmp, uint16_t numOfEntries, t_Handle h_Tree)
+{
+ t_AdOfTypeResult *p_AdTmp = (t_AdOfTypeResult *)h_AdTmp;
+ uint32_t tmpReg32;
+ t_Error err;
+ t_FmPcdCcNode *p_CcNode;
+ int i = 0;
+ uint16_t tmp = 0;
+ uint16_t profileId;
+ uint8_t relativeSchemeId, physicalSchemeId;
t_CcNodeInformation ccNodeInfo;
- for(i = 0; i < numOfEntries; i++)
- {
- if(i == 0)
+ for (i = 0; i < numOfEntries; i++)
+ {
+ if (i == 0)
h_AdTmp = PTR_MOVE(h_AdTmp, i*FM_PCD_CC_AD_ENTRY_SIZE);
else
h_AdTmp = PTR_MOVE(h_AdTmp, FM_PCD_CC_AD_ENTRY_SIZE);
- if(p_CcNextEngineParamsTmp[i].shadowAction & requiredAction)
- continue;
- switch(p_CcNextEngineParamsTmp[i].nextEngineParams.nextEngine)
+ switch (p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.nextEngine)
{
- case(e_FM_PCD_CC):
- if(requiredAction)
+ case (e_FM_PCD_CC):
+ if (requiredAction)
{
- p_FmPcdCcNode = p_CcNextEngineParamsTmp[i].nextEngineParams.params.ccParams.h_CcNode;
- ASSERT_COND(p_FmPcdCcNode);
- if(p_FmPcdCcNode->shadowAction == requiredAction)
+ p_CcNode =
+ p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.ccParams.h_CcNode;
+ ASSERT_COND(p_CcNode);
+ if (p_CcNode->shadowAction == requiredAction)
break;
- if((requiredAction & UPDATE_CC_WITH_TREE) && !(p_FmPcdCcNode->shadowAction & UPDATE_CC_WITH_TREE))
+ if ((requiredAction & UPDATE_CC_WITH_TREE)
+ && !(p_CcNode->shadowAction & UPDATE_CC_WITH_TREE))
{
- ASSERT_COND(LIST_NumOfObjs(&p_FmPcdCcNode->ccTreesLst) == 0);
- if(p_FmPcdCcNode->shadowAction & UPDATE_CC_WITH_DELETE_TREE)
- p_FmPcdCcNode->shadowAction &= ~UPDATE_CC_WITH_DELETE_TREE;
memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
ccNodeInfo.h_CcNode = h_Tree;
- EnqueueNodeInfoToRelevantLst(&p_FmPcdCcNode->ccTreesLst, &ccNodeInfo);
- p_CcNextEngineParamsTmp[i].shadowAction |= UPDATE_CC_WITH_TREE;
+ EnqueueNodeInfoToRelevantLst(&p_CcNode->ccTreesLst,
+ &ccNodeInfo, NULL);
+ p_CcKeyAndNextEngineParamsTmp[i].shadowAction |=
+ UPDATE_CC_WITH_TREE;
}
- if((requiredAction & UPDATE_CC_WITH_DELETE_TREE) && !(p_FmPcdCcNode->shadowAction & UPDATE_CC_WITH_DELETE_TREE))
+ if ((requiredAction & UPDATE_CC_SHADOW_CLEAR)
+ && !(p_CcNode->shadowAction & UPDATE_CC_SHADOW_CLEAR))
+ {
+
+ p_CcNode->shadowAction = 0;
+ }
+
+ if ((requiredAction & UPDATE_CC_WITH_DELETE_TREE)
+ && !(p_CcNode->shadowAction
+ & UPDATE_CC_WITH_DELETE_TREE))
{
- ASSERT_COND(LIST_NumOfObjs(&p_FmPcdCcNode->ccTreesLst) == 1);
- if(p_FmPcdCcNode->shadowAction & UPDATE_CC_WITH_TREE)
- p_FmPcdCcNode->shadowAction &= ~UPDATE_CC_WITH_TREE;
- DequeueNodeInfoFromRelevantLst(&p_FmPcdCcNode->ccTreesLst, h_Tree);
- p_CcNextEngineParamsTmp[i].shadowAction |= UPDATE_CC_WITH_DELETE_TREE;
+ DequeueNodeInfoFromRelevantLst(&p_CcNode->ccTreesLst,
+ h_Tree, NULL);
+ p_CcKeyAndNextEngineParamsTmp[i].shadowAction |=
+ UPDATE_CC_WITH_DELETE_TREE;
}
- if(p_FmPcdCcNode->nextEngineAndRequiredAction[p_FmPcdCcNode->numOfKeys].nextEngineParams.nextEngine != e_FM_PCD_INVALID)
- tmp = (uint8_t)(p_FmPcdCcNode->numOfKeys + 1);
+ if (p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.nextEngine
+ != e_FM_PCD_INVALID)
+ tmp = (uint8_t)(p_CcNode->numOfKeys + 1);
else
- tmp = p_FmPcdCcNode->numOfKeys;
- err = FmPcdCcSetRequiredAction(h_FmPcd, requiredAction, p_FmPcdCcNode->nextEngineAndRequiredAction, p_FmPcdCcNode->h_AdTable, tmp, h_Tree);
- if(err != E_OK)
+ tmp = p_CcNode->numOfKeys;
+ err = SetRequiredAction1(h_FmPcd, requiredAction,
+ p_CcNode->keyAndNextEngineParams,
+ p_CcNode->h_AdTable, tmp, h_Tree);
+ if (err != E_OK)
return err;
- p_FmPcdCcNode->shadowAction |= requiredAction;
+ if (requiredAction != UPDATE_CC_SHADOW_CLEAR)
+ p_CcNode->shadowAction |= requiredAction;
}
break;
- case(e_FM_PCD_KG):
- if((requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA) && !(p_CcNextEngineParamsTmp[i].shadowAction & UPDATE_NIA_ENQ_WITHOUT_DMA))
+ case (e_FM_PCD_KG):
+ if ((requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)
+ && !(p_CcKeyAndNextEngineParamsTmp[i].shadowAction
+ & UPDATE_NIA_ENQ_WITHOUT_DMA))
{
- physicalSchemeId = (uint8_t)(PTR_TO_UINT(p_CcNextEngineParamsTmp[i].nextEngineParams.params.kgParams.h_DirectScheme)-1);
- relativeSchemeId = FmPcdKgGetRelativeSchemeId(h_FmPcd, physicalSchemeId);
- if(relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)
+ physicalSchemeId =
+ FmPcdKgGetSchemeId(
+ p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.kgParams.h_DirectScheme);
+ relativeSchemeId = FmPcdKgGetRelativeSchemeId(
+ h_FmPcd, physicalSchemeId);
+ if (relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)
RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
- if (!FmPcdKgIsSchemeValidSw(h_FmPcd, relativeSchemeId))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid direct scheme."));
- if(!KgIsSchemeAlwaysDirect(h_FmPcd, relativeSchemeId))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("For this action scheme has to be direct."));
- err = FmPcdKgCcGetSetParams(h_FmPcd, p_CcNextEngineParamsTmp[i].nextEngineParams.params.kgParams.h_DirectScheme, requiredAction);
- if(err != E_OK)
+ if (!FmPcdKgIsSchemeValidSw(
+ p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.kgParams.h_DirectScheme))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("Invalid direct scheme."));
+ if (!KgIsSchemeAlwaysDirect(h_FmPcd, relativeSchemeId))
+ RETURN_ERROR(
+ MAJOR, E_INVALID_STATE,
+ ("For this action scheme has to be direct."));
+ err =
+ FmPcdKgCcGetSetParams(
+ h_FmPcd,
+ p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.kgParams.h_DirectScheme,
+ requiredAction, 0);
+ if (err != E_OK)
RETURN_ERROR(MAJOR, err, NO_MSG);
- p_CcNextEngineParamsTmp[i].shadowAction |= requiredAction;
+ p_CcKeyAndNextEngineParamsTmp[i].shadowAction |=
+ requiredAction;
}
break;
- case(e_FM_PCD_PLCR):
- if((requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA) && !(p_CcNextEngineParamsTmp[i].shadowAction & UPDATE_NIA_ENQ_WITHOUT_DMA))
+ case (e_FM_PCD_PLCR):
+ if ((requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)
+ && !(p_CcKeyAndNextEngineParamsTmp[i].shadowAction
+ & UPDATE_NIA_ENQ_WITHOUT_DMA))
{
- if(!p_CcNextEngineParamsTmp[i].nextEngineParams.params.plcrParams.overrideParams)
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("In this intialization only overrideFqid can be intiizliaes"));
- if(!p_CcNextEngineParamsTmp[i].nextEngineParams.params.plcrParams.sharedProfile)
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("In this intialization only overrideFqid can be intiizliaes"));
- err = FmPcdPlcrGetAbsoluteProfileId(h_FmPcd, e_FM_PCD_PLCR_SHARED, NULL, p_CcNextEngineParamsTmp[i].nextEngineParams.params.plcrParams.newRelativeProfileId, &profileId);
- if(err!= E_OK)
+ if (!p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.plcrParams.overrideParams)
+ RETURN_ERROR(
+ MAJOR,
+ E_NOT_SUPPORTED,
+ ("In this initialization only overrideFqid can be initialized"));
+ if (!p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.plcrParams.sharedProfile)
+ RETURN_ERROR(
+ MAJOR,
+ E_NOT_SUPPORTED,
+ ("In this initialization only overrideFqid can be initialized"));
+ err =
+ FmPcdPlcrGetAbsoluteIdByProfileParams(
+ h_FmPcd,
+ e_FM_PCD_PLCR_SHARED,
+ NULL,
+ p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.plcrParams.newRelativeProfileId,
+ &profileId);
+ if (err != E_OK)
RETURN_ERROR(MAJOR, err, NO_MSG);
- err = FmPcdPlcrCcGetSetParams(h_FmPcd, profileId, requiredAction);
- if(err != E_OK)
+ err = FmPcdPlcrCcGetSetParams(h_FmPcd, profileId,
+ requiredAction);
+ if (err != E_OK)
RETURN_ERROR(MAJOR, err, NO_MSG);
- p_CcNextEngineParamsTmp[i].shadowAction |= requiredAction;
+ p_CcKeyAndNextEngineParamsTmp[i].shadowAction |=
+ requiredAction;
}
break;
- case(e_FM_PCD_DONE):
- if((requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA) && !(p_CcNextEngineParamsTmp[i].shadowAction & UPDATE_NIA_ENQ_WITHOUT_DMA))
+ case (e_FM_PCD_DONE):
+ if ((requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)
+ && !(p_CcKeyAndNextEngineParamsTmp[i].shadowAction
+ & UPDATE_NIA_ENQ_WITHOUT_DMA))
{
tmpReg32 = GET_UINT32(p_AdTmp->nia);
- if((tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)) != (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next engine was previosely assigned not as PCD_DONE"));
+ if ((tmpReg32 & GET_NIA_BMI_AC_ENQ_FRAME(h_FmPcd))
+ != GET_NIA_BMI_AC_ENQ_FRAME(h_FmPcd))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("Next engine was previously assigned not as PCD_DONE"));
tmpReg32 |= NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
WRITE_UINT32(p_AdTmp->nia, tmpReg32);
- p_CcNextEngineParamsTmp[i].shadowAction |= requiredAction;
+ p_CcKeyAndNextEngineParamsTmp[i].shadowAction |=
+ requiredAction;
}
break;
default:
break;
}
- }
+ }
+
+ return E_OK;
+}
+
+static t_Error SetRequiredAction(
+ t_Handle h_FmPcd, uint32_t requiredAction,
+ t_FmPcdCcKeyAndNextEngineParams *p_CcKeyAndNextEngineParamsTmp,
+ t_Handle h_AdTmp, uint16_t numOfEntries, t_Handle h_Tree)
+{
+ t_Error err = SetRequiredAction1(h_FmPcd, requiredAction,
+ p_CcKeyAndNextEngineParamsTmp, h_AdTmp,
+ numOfEntries, h_Tree);
+ if (err != E_OK)
+ return err;
+ return SetRequiredAction1(h_FmPcd, UPDATE_CC_SHADOW_CLEAR,
+ p_CcKeyAndNextEngineParamsTmp, h_AdTmp,
+ numOfEntries, h_Tree);
+}
+
+static t_Error ReleaseModifiedDataStructure(
+ t_Handle h_FmPcd, t_List *h_FmPcdOldPointersLst,
+ t_List *h_FmPcdNewPointersLst,
+ t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalParams,
+ bool useShadowStructs)
+{
+ t_List *p_Pos;
+ t_Error err = E_OK;
+ t_CcNodeInformation ccNodeInfo, *p_CcNodeInformation;
+ t_Handle h_Muram;
+ t_FmPcdCcNode *p_FmPcdCcNextNode, *p_FmPcdCcWorkingOnNode;
+ t_List *p_UpdateLst;
+ uint32_t intFlags;
+
+ SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_AdditionalParams->h_CurrentNode,
+ E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(h_FmPcdOldPointersLst, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(h_FmPcdNewPointersLst, E_INVALID_HANDLE);
+
+ /* We don't update subtree of the new node with new tree because it was done in the previous stage */
+ if (p_AdditionalParams->h_NodeForAdd)
+ {
+ p_FmPcdCcNextNode = (t_FmPcdCcNode*)p_AdditionalParams->h_NodeForAdd;
+
+ if (!p_AdditionalParams->tree)
+ p_UpdateLst = &p_FmPcdCcNextNode->ccPrevNodesLst;
+ else
+ p_UpdateLst = &p_FmPcdCcNextNode->ccTreeIdLst;
+
+ p_CcNodeInformation = FindNodeInfoInReleventLst(
+ p_UpdateLst, p_AdditionalParams->h_CurrentNode,
+ p_FmPcdCcNextNode->h_Spinlock);
+
+ if (p_CcNodeInformation)
+ p_CcNodeInformation->index++;
+ else
+ {
+ memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
+ ccNodeInfo.h_CcNode = (t_Handle)p_AdditionalParams->h_CurrentNode;
+ ccNodeInfo.index = 1;
+ EnqueueNodeInfoToRelevantLst(p_UpdateLst, &ccNodeInfo,
+ p_FmPcdCcNextNode->h_Spinlock);
+ }
+ if (p_AdditionalParams->h_ManipForAdd)
+ {
+ p_CcNodeInformation = FindNodeInfoInReleventLst(
+ FmPcdManipGetNodeLstPointedOnThisManip(
+ p_AdditionalParams->h_ManipForAdd),
+ p_AdditionalParams->h_CurrentNode,
+ FmPcdManipGetSpinlock(p_AdditionalParams->h_ManipForAdd));
+
+ if (p_CcNodeInformation)
+ p_CcNodeInformation->index++;
+ else
+ {
+ memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
+ ccNodeInfo.h_CcNode =
+ (t_Handle)p_AdditionalParams->h_CurrentNode;
+ ccNodeInfo.index = 1;
+ EnqueueNodeInfoToRelevantLst(
+ FmPcdManipGetNodeLstPointedOnThisManip(
+ p_AdditionalParams->h_ManipForAdd),
+ &ccNodeInfo,
+ FmPcdManipGetSpinlock(
+ p_AdditionalParams->h_ManipForAdd));
+ }
+ }
+ }
+
+ if (p_AdditionalParams->h_NodeForRmv)
+ {
+ p_FmPcdCcNextNode = (t_FmPcdCcNode*)p_AdditionalParams->h_NodeForRmv;
+
+ if (!p_AdditionalParams->tree)
+ {
+ p_UpdateLst = &p_FmPcdCcNextNode->ccPrevNodesLst;
+ p_FmPcdCcWorkingOnNode =
+ (t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode);
+
+ for (p_Pos = NCSW_LIST_FIRST(&p_FmPcdCcWorkingOnNode->ccTreesLst);
+ p_Pos != (&p_FmPcdCcWorkingOnNode->ccTreesLst); p_Pos =
+ NCSW_LIST_NEXT(p_Pos))
+ {
+ p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);
+
+ ASSERT_COND(p_CcNodeInformation->h_CcNode);
+
+ err =
+ SetRequiredAction(
+ h_FmPcd,
+ UPDATE_CC_WITH_DELETE_TREE,
+ &((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->keyAndNextEngineParams[p_AdditionalParams->savedKeyIndex],
+ PTR_MOVE(((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->h_AdTable, p_AdditionalParams->savedKeyIndex*FM_PCD_CC_AD_ENTRY_SIZE),
+ 1, p_CcNodeInformation->h_CcNode);
+ }
+ }
+ else
+ {
+ p_UpdateLst = &p_FmPcdCcNextNode->ccTreeIdLst;
+
+ err =
+ SetRequiredAction(
+ h_FmPcd,
+ UPDATE_CC_WITH_DELETE_TREE,
+ &((t_FmPcdCcTree *)(p_AdditionalParams->h_CurrentNode))->keyAndNextEngineParams[p_AdditionalParams->savedKeyIndex],
+ UINT_TO_PTR(((t_FmPcdCcTree *)(p_AdditionalParams->h_CurrentNode))->ccTreeBaseAddr + p_AdditionalParams->savedKeyIndex*FM_PCD_CC_AD_ENTRY_SIZE),
+ 1, p_AdditionalParams->h_CurrentNode);
+ }
+ if (err)
+ return err;
+
+ /* We remove from the subtree of the removed node tree because it wasn't done in the previous stage
+ Update ccPrevNodesLst or ccTreeIdLst of the removed node
+ Update of the node owner */
+ p_CcNodeInformation = FindNodeInfoInReleventLst(
+ p_UpdateLst, p_AdditionalParams->h_CurrentNode,
+ p_FmPcdCcNextNode->h_Spinlock);
+
+ ASSERT_COND(p_CcNodeInformation);
+ ASSERT_COND(p_CcNodeInformation->index);
+
+ p_CcNodeInformation->index--;
+
+ if (p_CcNodeInformation->index == 0)
+ DequeueNodeInfoFromRelevantLst(p_UpdateLst,
+ p_AdditionalParams->h_CurrentNode,
+ p_FmPcdCcNextNode->h_Spinlock);
+
+ UpdateNodeOwner(p_FmPcdCcNextNode, FALSE);
+
+ if (p_AdditionalParams->h_ManipForRmv)
+ {
+ p_CcNodeInformation = FindNodeInfoInReleventLst(
+ FmPcdManipGetNodeLstPointedOnThisManip(
+ p_AdditionalParams->h_ManipForRmv),
+ p_AdditionalParams->h_CurrentNode,
+ FmPcdManipGetSpinlock(p_AdditionalParams->h_ManipForRmv));
+
+ ASSERT_COND(p_CcNodeInformation);
+ ASSERT_COND(p_CcNodeInformation->index);
+
+ p_CcNodeInformation->index--;
+
+ if (p_CcNodeInformation->index == 0)
+ DequeueNodeInfoFromRelevantLst(
+ FmPcdManipGetNodeLstPointedOnThisManip(
+ p_AdditionalParams->h_ManipForRmv),
+ p_AdditionalParams->h_CurrentNode,
+ FmPcdManipGetSpinlock(
+ p_AdditionalParams->h_ManipForRmv));
+ }
+ }
+
+ if (p_AdditionalParams->h_ManipForRmv)
+ FmPcdManipUpdateOwner(p_AdditionalParams->h_ManipForRmv, FALSE);
+
+ if (p_AdditionalParams->p_StatsObjForRmv)
+ PutStatsObj((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode),
+ p_AdditionalParams->p_StatsObjForRmv);
+
+#if (DPAA_VERSION >= 11)
+ if (p_AdditionalParams->h_FrmReplicForRmv)
+ FrmReplicGroupUpdateOwner(p_AdditionalParams->h_FrmReplicForRmv,
+ FALSE/* remove */);
+#endif /* (DPAA_VERSION >= 11) */
+
+ if (!useShadowStructs)
+ {
+ h_Muram = FmPcdGetMuramHandle(h_FmPcd);
+ ASSERT_COND(h_Muram);
+
+ if ((p_AdditionalParams->tree && !((t_FmPcd *)h_FmPcd)->p_CcShadow)
+ || (!p_AdditionalParams->tree
+ && !((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->maxNumOfKeys))
+ {
+ /* We release new AD which was allocated and updated for copy from to actual AD */
+ for (p_Pos = NCSW_LIST_FIRST(h_FmPcdNewPointersLst);
+ p_Pos != (h_FmPcdNewPointersLst); p_Pos = NCSW_LIST_NEXT(p_Pos))
+ {
+
+ p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);
+ ASSERT_COND(p_CcNodeInformation->h_CcNode);
+ FM_MURAM_FreeMem(h_Muram, p_CcNodeInformation->h_CcNode);
+ }
+ }
+
+ /* Free Old data structure if it has to be freed - new data structure was allocated*/
+ if (p_AdditionalParams->p_AdTableOld)
+ FM_MURAM_FreeMem(h_Muram, p_AdditionalParams->p_AdTableOld);
+
+ if (p_AdditionalParams->p_KeysMatchTableOld)
+ FM_MURAM_FreeMem(h_Muram, p_AdditionalParams->p_KeysMatchTableOld);
+ }
+
+ /* Update current modified node with changed fields if it's required*/
+ if (!p_AdditionalParams->tree)
+ {
+ if (p_AdditionalParams->p_AdTableNew)
+ ((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->h_AdTable =
+ p_AdditionalParams->p_AdTableNew;
+
+ if (p_AdditionalParams->p_KeysMatchTableNew)
+ ((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->h_KeysMatchTable =
+ p_AdditionalParams->p_KeysMatchTableNew;
+
+ /* Locking node's spinlock before updating 'keys and next engine' structure,
+ as it maybe used to retrieve keys statistics */
+ intFlags =
+ XX_LockIntrSpinlock(
+ ((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->h_Spinlock);
+
+ ((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->numOfKeys =
+ p_AdditionalParams->numOfKeys;
+
+ memcpy(((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->keyAndNextEngineParams,
+ &p_AdditionalParams->keyAndNextEngineParams,
+ sizeof(t_FmPcdCcKeyAndNextEngineParams) * (CC_MAX_NUM_OF_KEYS));
+
+ XX_UnlockIntrSpinlock(
+ ((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->h_Spinlock,
+ intFlags);
+ }
+ else
+ {
+ uint8_t numEntries =
+ ((t_FmPcdCcTree *)(p_AdditionalParams->h_CurrentNode))->numOfEntries;
+ ASSERT_COND(numEntries < FM_PCD_MAX_NUM_OF_CC_GROUPS);
+ memcpy(&((t_FmPcdCcTree *)(p_AdditionalParams->h_CurrentNode))->keyAndNextEngineParams,
+ &p_AdditionalParams->keyAndNextEngineParams,
+ sizeof(t_FmPcdCcKeyAndNextEngineParams) * numEntries);
+ }
+
+ ReleaseLst(h_FmPcdOldPointersLst);
+ ReleaseLst(h_FmPcdNewPointersLst);
- return E_OK;
+ XX_Free(p_AdditionalParams);
+
+ return E_OK;
}
-static t_Error CcUpdateParam(t_Handle h_FmPcd,
- t_Handle h_FmPort,
- t_FmPcdCcNextEngineAndRequiredActionParams *p_CcNextEngineParams,
- uint16_t numOfEntries,
- t_Handle h_Ad,
- bool validate,
- uint16_t level,
- t_Handle h_FmTree,
- bool modify)
+static t_Handle BuildNewAd(
+ t_Handle h_Ad,
+ t_FmPcdModifyCcKeyAdditionalParams *p_FmPcdModifyCcKeyAdditionalParams,
+ t_FmPcdCcNode *p_CcNode,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
{
+ t_FmPcdCcNode *p_FmPcdCcNodeTmp;
+ t_Handle h_OrigAd = NULL;
+
+ p_FmPcdCcNodeTmp = (t_FmPcdCcNode*)XX_Malloc(sizeof(t_FmPcdCcNode));
+ if (!p_FmPcdCcNodeTmp)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("p_FmPcdCcNodeTmp"));
+ return NULL;
+ }
+ memset(p_FmPcdCcNodeTmp, 0, sizeof(t_FmPcdCcNode));
+
+ p_FmPcdCcNodeTmp->numOfKeys = p_FmPcdModifyCcKeyAdditionalParams->numOfKeys;
+ p_FmPcdCcNodeTmp->h_KeysMatchTable =
+ p_FmPcdModifyCcKeyAdditionalParams->p_KeysMatchTableNew;
+ p_FmPcdCcNodeTmp->h_AdTable =
+ p_FmPcdModifyCcKeyAdditionalParams->p_AdTableNew;
+
+ p_FmPcdCcNodeTmp->lclMask = p_CcNode->lclMask;
+ p_FmPcdCcNodeTmp->parseCode = p_CcNode->parseCode;
+ p_FmPcdCcNodeTmp->offset = p_CcNode->offset;
+ p_FmPcdCcNodeTmp->prsArrayOffset = p_CcNode->prsArrayOffset;
+ p_FmPcdCcNodeTmp->ctrlFlow = p_CcNode->ctrlFlow;
+ p_FmPcdCcNodeTmp->ccKeySizeAccExtraction = p_CcNode->ccKeySizeAccExtraction;
+ p_FmPcdCcNodeTmp->sizeOfExtraction = p_CcNode->sizeOfExtraction;
+ p_FmPcdCcNodeTmp->glblMaskSize = p_CcNode->glblMaskSize;
+ p_FmPcdCcNodeTmp->p_GlblMask = p_CcNode->p_GlblMask;
+
+ if (p_FmPcdCcNextEngineParams->nextEngine == e_FM_PCD_CC)
+ {
+ if (p_FmPcdCcNextEngineParams->h_Manip)
+ {
+ h_OrigAd = p_CcNode->h_Ad;
+ if (AllocAndFillAdForContLookupManip(
+ p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode)
+ != E_OK)
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
+ XX_Free(p_FmPcdCcNodeTmp);
+ return NULL;
+ }
+ }
+ FillAdOfTypeContLookup(h_Ad, NULL, p_CcNode->h_FmPcd, p_FmPcdCcNodeTmp,
+ h_OrigAd ? NULL : p_FmPcdCcNextEngineParams->h_Manip, NULL);
+ }
+
+#if (DPAA_VERSION >= 11)
+ if ((p_FmPcdCcNextEngineParams->nextEngine == e_FM_PCD_FR)
+ && (p_FmPcdCcNextEngineParams->params.frParams.h_FrmReplic))
+ {
+ FillAdOfTypeContLookup(
+ h_Ad, NULL, p_CcNode->h_FmPcd, p_FmPcdCcNodeTmp,
+ p_FmPcdCcNextEngineParams->h_Manip,
+ p_FmPcdCcNextEngineParams->params.frParams.h_FrmReplic);
+ }
+#endif /* (DPAA_VERSION >= 11) */
+
+ XX_Free(p_FmPcdCcNodeTmp);
+
+ return E_OK;
+}
+
+static t_Error DynamicChangeHc(
+ t_Handle h_FmPcd, t_List *h_OldPointersLst, t_List *h_NewPointersLst,
+ t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalParams,
+ bool useShadowStructs)
+{
+ t_List *p_PosOld, *p_PosNew;
+ uint32_t oldAdAddrOffset, newAdAddrOffset;
+ uint16_t i = 0;
+ t_Error err = E_OK;
+ uint8_t numOfModifiedPtr;
+
+ ASSERT_COND(h_FmPcd);
+ ASSERT_COND(h_OldPointersLst);
+ ASSERT_COND(h_NewPointersLst);
+
+ numOfModifiedPtr = (uint8_t)NCSW_LIST_NumOfObjs(h_OldPointersLst);
+
+ if (numOfModifiedPtr)
+ {
+ p_PosNew = NCSW_LIST_FIRST(h_NewPointersLst);
+ p_PosOld = NCSW_LIST_FIRST(h_OldPointersLst);
+
+ /* Retrieve address of new AD */
+ newAdAddrOffset = FmPcdCcGetNodeAddrOffsetFromNodeInfo(h_FmPcd,
+ p_PosNew);
+ if (newAdAddrOffset == (uint32_t)ILLEGAL_BASE)
+ {
+ ReleaseModifiedDataStructure(h_FmPcd, h_OldPointersLst,
+ h_NewPointersLst,
+ p_AdditionalParams, useShadowStructs);
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("New AD address"));
+ }
+
+ for (i = 0; i < numOfModifiedPtr; i++)
+ {
+ /* Retrieve address of current AD */
+ oldAdAddrOffset = FmPcdCcGetNodeAddrOffsetFromNodeInfo(h_FmPcd,
+ p_PosOld);
+ if (oldAdAddrOffset == (uint32_t)ILLEGAL_BASE)
+ {
+ ReleaseModifiedDataStructure(h_FmPcd, h_OldPointersLst,
+ h_NewPointersLst,
+ p_AdditionalParams,
+ useShadowStructs);
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Old AD address"));
+ }
+
+ /* Invoke host command to copy from new AD to old AD */
+ err = FmHcPcdCcDoDynamicChange(((t_FmPcd *)h_FmPcd)->h_Hc,
+ oldAdAddrOffset, newAdAddrOffset);
+ if (err)
+ {
+ ReleaseModifiedDataStructure(h_FmPcd, h_OldPointersLst,
+ h_NewPointersLst,
+ p_AdditionalParams,
+ useShadowStructs);
+ RETURN_ERROR(
+ MAJOR,
+ err,
+ ("For part of nodes changes are done - situation is danger"));
+ }
+
+ p_PosOld = NCSW_LIST_NEXT(p_PosOld);
+ }
+ }
+ return E_OK;
+}
+
+static t_Error DoDynamicChange(
+ t_Handle h_FmPcd, t_List *h_OldPointersLst, t_List *h_NewPointersLst,
+ t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalParams,
+ bool useShadowStructs)
+{
+ t_FmPcdCcNode *p_CcNode =
+ (t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode);
+ t_List *p_PosNew;
t_CcNodeInformation *p_CcNodeInfo;
- t_FmPcdCcNode *p_FmPcdCcNode;
- t_Error err;
- uint16_t tmp = 0;
- int i = 0;
+ t_FmPcdCcNextEngineParams nextEngineParams;
+ t_Handle h_Ad;
+ uint32_t keySize;
+ t_Error err = E_OK;
+ uint8_t numOfModifiedPtr;
+
+ ASSERT_COND(h_FmPcd);
+
+ memset(&nextEngineParams, 0, sizeof(t_FmPcdCcNextEngineParams));
+
+ numOfModifiedPtr = (uint8_t)NCSW_LIST_NumOfObjs(h_OldPointersLst);
+
+ if (numOfModifiedPtr)
+ {
+
+ p_PosNew = NCSW_LIST_FIRST(h_NewPointersLst);
+
+ /* Invoke host-command to copy from the new Ad to existing Ads */
+ err = DynamicChangeHc(h_FmPcd, h_OldPointersLst, h_NewPointersLst,
+ p_AdditionalParams, useShadowStructs);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ if (useShadowStructs)
+ {
+ /* When the host-command above has ended, the old structures are 'free'and we can update
+ them by copying from the new shadow structures. */
+ if (p_CcNode->lclMask)
+ keySize = (uint32_t)(2 * p_CcNode->ccKeySizeAccExtraction);
+ else
+ keySize = p_CcNode->ccKeySizeAccExtraction;
+
+ MemCpy8(p_AdditionalParams->p_KeysMatchTableOld,
+ p_AdditionalParams->p_KeysMatchTableNew,
+ p_CcNode->maxNumOfKeys * keySize * sizeof(uint8_t));
+
+ MemCpy8(
+ p_AdditionalParams->p_AdTableOld,
+ p_AdditionalParams->p_AdTableNew,
+ (uint32_t)((p_CcNode->maxNumOfKeys + 1)
+ * FM_PCD_CC_AD_ENTRY_SIZE));
+
+ /* Retrieve the address of the allocated Ad */
+ p_CcNodeInfo = CC_NODE_F_OBJECT(p_PosNew);
+ h_Ad = p_CcNodeInfo->h_CcNode;
+
+ /* Build a new Ad that holds the old (now updated) structures */
+ p_AdditionalParams->p_KeysMatchTableNew =
+ p_AdditionalParams->p_KeysMatchTableOld;
+ p_AdditionalParams->p_AdTableNew = p_AdditionalParams->p_AdTableOld;
+
+ nextEngineParams.nextEngine = e_FM_PCD_CC;
+ nextEngineParams.params.ccParams.h_CcNode = (t_Handle)p_CcNode;
+
+ BuildNewAd(h_Ad, p_AdditionalParams, p_CcNode, &nextEngineParams);
+
+ /* HC to copy from the new Ad (old updated structures) to current Ad (uses shadow structures) */
+ err = DynamicChangeHc(h_FmPcd, h_OldPointersLst, h_NewPointersLst,
+ p_AdditionalParams, useShadowStructs);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+ }
+
+ err = ReleaseModifiedDataStructure(h_FmPcd, h_OldPointersLst,
+ h_NewPointersLst,
+ p_AdditionalParams, useShadowStructs);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ return E_OK;
+}
+
+#ifdef FM_CAPWAP_SUPPORT
+static bool IsCapwapApplSpecific(t_Handle h_Node)
+{
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_Node;
+ bool isManipForCapwapApplSpecificBuild = FALSE;
+ int i = 0;
+
+ ASSERT_COND(h_Node);
+ /* assumption that this function called only for INDEXED_FLOW_ID - so no miss*/
+ for (i = 0; i < p_CcNode->numOfKeys; i++)
+ {
+ if ( p_CcNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip &&
+ FmPcdManipIsCapwapApplSpecific(p_CcNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip))
+ {
+ isManipForCapwapApplSpecificBuild = TRUE;
+ break;
+ }
+ }
+ return isManipForCapwapApplSpecificBuild;
+
+}
+#endif /* FM_CAPWAP_SUPPORT */
+
+static t_Error CcUpdateParam(
+ t_Handle h_FmPcd, t_Handle h_PcdParams, t_Handle h_FmPort,
+ t_FmPcdCcKeyAndNextEngineParams *p_CcKeyAndNextEngineParams,
+ uint16_t numOfEntries, t_Handle h_Ad, bool validate, uint16_t level,
+ t_Handle h_FmTree, bool modify)
+{
+ t_FmPcdCcNode *p_CcNode;
+ t_Error err;
+ uint16_t tmp = 0;
+ int i = 0;
+ t_FmPcdCcTree *p_CcTree = (t_FmPcdCcTree *)h_FmTree;
level++;
- if(numOfEntries)
+ if (p_CcTree->h_IpReassemblyManip)
+ {
+ err = FmPcdManipUpdate(h_FmPcd, h_PcdParams, h_FmPort,
+ p_CcTree->h_IpReassemblyManip, NULL, validate,
+ level, h_FmTree, modify);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+
+ if (p_CcTree->h_CapwapReassemblyManip)
{
- for(i = 0; i < numOfEntries; i++)
+ err = FmPcdManipUpdate(h_FmPcd, h_PcdParams, h_FmPort,
+ p_CcTree->h_CapwapReassemblyManip, NULL, validate,
+ level, h_FmTree, modify);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+
+ if (numOfEntries)
+ {
+ for (i = 0; i < numOfEntries; i++)
{
- if(i == 0)
+ if (i == 0)
h_Ad = PTR_MOVE(h_Ad, i*FM_PCD_CC_AD_ENTRY_SIZE);
else
h_Ad = PTR_MOVE(h_Ad, FM_PCD_CC_AD_ENTRY_SIZE);
- if(p_CcNextEngineParams[i].nextEngineParams.nextEngine == e_FM_PCD_CC)
+ if (p_CcKeyAndNextEngineParams[i].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
{
- p_FmPcdCcNode = p_CcNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode;
- ASSERT_COND(p_FmPcdCcNode);
- p_CcNodeInfo = FindNodeInfoInReleventLst(&p_FmPcdCcNode->ccTreesLst,h_FmTree);
- ASSERT_COND(p_CcNodeInfo);
- p_CcNodeInfo->index = level;
-#ifdef FM_PCD_CC_MANIP
- if(p_CcNextEngineParams[i].nextEngineParams.h_Manip)
+ p_CcNode =
+ p_CcKeyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode;
+ ASSERT_COND(p_CcNode);
+
+ if (p_CcKeyAndNextEngineParams[i].nextEngineParams.h_Manip)
{
- err = FmPcdManipUpdate(h_FmPcd, h_FmPort, p_CcNextEngineParams[i].nextEngineParams.h_Manip, h_Ad, validate, p_CcNodeInfo->index, h_FmTree, modify);
- if(err)
+ err =
+ FmPcdManipUpdate(
+ h_FmPcd,
+ NULL,
+ h_FmPort,
+ p_CcKeyAndNextEngineParams[i].nextEngineParams.h_Manip,
+ h_Ad, validate, level, h_FmTree, modify);
+ if (err)
RETURN_ERROR(MAJOR, err, NO_MSG);
}
-#endif /* FM_PCD_CC_MANIP */
- if(p_FmPcdCcNode->nextEngineAndRequiredAction[p_FmPcdCcNode->numOfKeys].nextEngineParams.nextEngine != e_FM_PCD_INVALID)
- tmp = (uint8_t)(p_FmPcdCcNode->numOfKeys + 1);
+ if (p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.nextEngine
+ != e_FM_PCD_INVALID)
+ tmp = (uint8_t)(p_CcNode->numOfKeys + 1);
else
- tmp = p_FmPcdCcNode->numOfKeys;
+ tmp = p_CcNode->numOfKeys;
- err = CcUpdateParam(h_FmPcd, h_FmPort, p_FmPcdCcNode->nextEngineAndRequiredAction, tmp, p_FmPcdCcNode->h_AdTable, validate,level, h_FmTree, modify);
- if(err)
+ err = CcUpdateParam(h_FmPcd, h_PcdParams, h_FmPort,
+ p_CcNode->keyAndNextEngineParams, tmp,
+ p_CcNode->h_AdTable, validate, level,
+ h_FmTree, modify);
+ if (err)
RETURN_ERROR(MAJOR, err, NO_MSG);
}
-#ifdef FM_PCD_CC_MANIP
else
{
- if(p_CcNextEngineParams[i].nextEngineParams.h_Manip)
+ if (p_CcKeyAndNextEngineParams[i].nextEngineParams.h_Manip)
{
- err = FmPcdManipUpdate(h_FmPcd, h_FmPort, p_CcNextEngineParams[i].nextEngineParams.h_Manip, h_Ad, validate, level,h_FmTree, modify);
- if(err)
+ err =
+ FmPcdManipUpdate(
+ h_FmPcd,
+ NULL,
+ h_FmPort,
+ p_CcKeyAndNextEngineParams[i].nextEngineParams.h_Manip,
+ h_Ad, validate, level, h_FmTree, modify);
+ if (err)
RETURN_ERROR(MAJOR, err, NO_MSG);
}
}
-#endif /* FM_PCD_CC_MANIP */
- }
+ }
}
return E_OK;
}
-static bool IsNodeInModifiedState(t_Handle h_CcNode)
-{
- t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
-
- ASSERT_COND(p_CcNode);
-
- return p_CcNode->modifiedState;
-}
-
-static void UpdateNodeWithModifiedState(t_Handle h_CcNode, bool modifiedState)
-{
- t_FmPcdCcNode *p_FmPcdCcNode = (t_FmPcdCcNode *)h_CcNode;
-
- ASSERT_COND(p_FmPcdCcNode);
-
- p_FmPcdCcNode->modifiedState = modifiedState;
-}
static ccPrivateInfo_t IcDefineCode(t_FmPcdCcNodeParams *p_CcNodeParam)
{
switch (p_CcNodeParam->extractCcParams.extractNonHdr.action)
{
- case(e_FM_PCD_ACTION_EXACT_MATCH):
- switch(p_CcNodeParam->extractCcParams.extractNonHdr.src)
+ case (e_FM_PCD_ACTION_EXACT_MATCH):
+ switch (p_CcNodeParam->extractCcParams.extractNonHdr.src)
{
- case(e_FM_PCD_EXTRACT_FROM_KEY):
+ case (e_FM_PCD_EXTRACT_FROM_KEY):
return CC_PRIVATE_INFO_IC_KEY_EXACT_MATCH;
- case(e_FM_PCD_EXTRACT_FROM_HASH):
+ case (e_FM_PCD_EXTRACT_FROM_HASH):
return CC_PRIVATE_INFO_IC_HASH_EXACT_MATCH;
default:
return CC_PRIVATE_INFO_NONE;
}
- case(e_FM_PCD_ACTION_INDEXED_LOOKUP):
- switch(p_CcNodeParam->extractCcParams.extractNonHdr.src)
+
+ case (e_FM_PCD_ACTION_INDEXED_LOOKUP):
+ switch (p_CcNodeParam->extractCcParams.extractNonHdr.src)
{
- case(e_FM_PCD_EXTRACT_FROM_HASH):
+ case (e_FM_PCD_EXTRACT_FROM_HASH):
return CC_PRIVATE_INFO_IC_HASH_INDEX_LOOKUP;
- case(e_FM_PCD_EXTRACT_FROM_FLOW_ID):
+ case (e_FM_PCD_EXTRACT_FROM_FLOW_ID):
return CC_PRIVATE_INFO_IC_DEQ_FQID_INDEX_LOOKUP;
default:
- return CC_PRIVATE_INFO_NONE;
+ return CC_PRIVATE_INFO_NONE;
}
- default:
- break;
+
+ default:
+ break;
}
+
return CC_PRIVATE_INFO_NONE;
}
-static t_CcNodeInformation * DequeueAdditionalInfoFromRelevantLst(t_List *p_List)
+static t_CcNodeInformation * DequeueAdditionalInfoFromRelevantLst(
+ t_List *p_List)
{
- t_CcNodeInformation *p_CcNodeInfo = NULL;
- uint32_t intFlags;
+ t_CcNodeInformation *p_CcNodeInfo = NULL;
- intFlags = XX_DisableAllIntr();
- if (!LIST_IsEmpty(p_List))
+ if (!NCSW_LIST_IsEmpty(p_List))
{
p_CcNodeInfo = CC_NODE_F_OBJECT(p_List->p_Next);
- LIST_DelAndInit(&p_CcNodeInfo->node);
+ NCSW_LIST_DelAndInit(&p_CcNodeInfo->node);
}
- XX_RestoreAllIntr(intFlags);
+
return p_CcNodeInfo;
}
-static void ReleaseLst(t_List *p_List)
+void ReleaseLst(t_List *p_List)
{
- t_CcNodeInformation *p_CcNodeInfo = NULL;
+ t_CcNodeInformation *p_CcNodeInfo = NULL;
- if(!LIST_IsEmpty(p_List))
+ if (!NCSW_LIST_IsEmpty(p_List))
{
p_CcNodeInfo = DequeueAdditionalInfoFromRelevantLst(p_List);
while (p_CcNodeInfo)
@@ -421,64 +1226,95 @@ static void ReleaseLst(t_List *p_List)
p_CcNodeInfo = DequeueAdditionalInfoFromRelevantLst(p_List);
}
}
- LIST_DelAndInit(p_List);
-}
-void FmPcdCcTreeReleaseLock(t_Handle h_FmPcdCcTree)
-{
- RELEASE_LOCK(((t_FmPcdCcTree *)h_FmPcdCcTree)->lock);
+ NCSW_LIST_Del(p_List);
}
-void FmPcdCcNodeTreeReleaseLock(t_List *p_List)
+static void DeleteNode(t_FmPcdCcNode *p_CcNode)
{
- t_List *p_Pos;
- t_CcNodeInformation *p_CcNodeInfo;
- t_Handle h_FmPcdCcTree;
+ uint32_t i;
+
+ if (!p_CcNode)
+ return;
- LIST_FOR_EACH(p_Pos, p_List)
+ if (p_CcNode->p_GlblMask)
{
- p_CcNodeInfo = CC_NODE_F_OBJECT(p_Pos);
- h_FmPcdCcTree = p_CcNodeInfo->h_CcNode;
- FmPcdCcTreeReleaseLock(h_FmPcdCcTree);
+ XX_Free(p_CcNode->p_GlblMask);
+ p_CcNode->p_GlblMask = NULL;
}
- ReleaseLst(p_List);
-}
-static void DeleteNode(t_FmPcdCcNode *p_FmPcdCcNode)
-{
- if(p_FmPcdCcNode)
+ if (p_CcNode->h_KeysMatchTable)
{
- if(p_FmPcdCcNode->p_GlblMask)
- {
- XX_Free(p_FmPcdCcNode->p_GlblMask);
- p_FmPcdCcNode->p_GlblMask = NULL;
- }
- if(p_FmPcdCcNode->h_KeysMatchTable)
- {
- FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_FmPcdCcNode->h_FmPcd), p_FmPcdCcNode->h_KeysMatchTable);
- p_FmPcdCcNode->h_KeysMatchTable = NULL;
- }
- if(p_FmPcdCcNode->h_AdTable)
- {
- FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_FmPcdCcNode->h_FmPcd), p_FmPcdCcNode->h_AdTable);
- p_FmPcdCcNode->h_AdTable = NULL;
- }
+ FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_CcNode->h_FmPcd),
+ p_CcNode->h_KeysMatchTable);
+ p_CcNode->h_KeysMatchTable = NULL;
+ }
+
+ if (p_CcNode->h_AdTable)
+ {
+ FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_CcNode->h_FmPcd),
+ p_CcNode->h_AdTable);
+ p_CcNode->h_AdTable = NULL;
+ }
+
+ if (p_CcNode->h_Ad)
+ {
+ FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_CcNode->h_FmPcd),
+ p_CcNode->h_Ad);
+ p_CcNode->h_Ad = NULL;
+ p_CcNode->h_TmpAd = NULL;
+ }
+
+ if (p_CcNode->h_StatsFLRs)
+ {
+ FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_CcNode->h_FmPcd),
+ p_CcNode->h_StatsFLRs);
+ p_CcNode->h_StatsFLRs = NULL;
+ }
+
+ if (p_CcNode->h_Spinlock)
+ {
+ XX_FreeSpinlock(p_CcNode->h_Spinlock);
+ p_CcNode->h_Spinlock = NULL;
+ }
+
+ /* Restore the original counters pointer instead of the mutual pointer (mutual to all hash buckets) */
+ if (p_CcNode->isHashBucket
+ && (p_CcNode->statisticsMode != e_FM_PCD_CC_STATS_MODE_NONE))
+ p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].p_StatsObj->h_StatsCounters =
+ p_CcNode->h_PrivMissStatsCounters;
- ReleaseLst(&p_FmPcdCcNode->ccPrevNodesLst);
- ReleaseLst(&p_FmPcdCcNode->ccTreeIdLst);
- ReleaseLst(&p_FmPcdCcNode->ccTreesLst);
+ /* Releasing all currently used statistics objects, including 'miss' entry */
+ for (i = 0; i < p_CcNode->numOfKeys + 1; i++)
+ if (p_CcNode->keyAndNextEngineParams[i].p_StatsObj)
+ PutStatsObj(p_CcNode,
+ p_CcNode->keyAndNextEngineParams[i].p_StatsObj);
- XX_Free(p_FmPcdCcNode);
+ if (!NCSW_LIST_IsEmpty(&p_CcNode->availableStatsLst))
+ {
+ t_Handle h_FmMuram = FmPcdGetMuramHandle(p_CcNode->h_FmPcd);
+ ASSERT_COND(h_FmMuram);
+
+ FreeStatObjects(&p_CcNode->availableStatsLst, h_FmMuram);
}
+
+ NCSW_LIST_Del(&p_CcNode->availableStatsLst);
+
+ ReleaseLst(&p_CcNode->ccPrevNodesLst);
+ ReleaseLst(&p_CcNode->ccTreeIdLst);
+ ReleaseLst(&p_CcNode->ccTreesLst);
+
+ XX_Free(p_CcNode);
}
static void DeleteTree(t_FmPcdCcTree *p_FmPcdTree, t_FmPcd *p_FmPcd)
{
- if(p_FmPcdTree)
+ if (p_FmPcdTree)
{
- if(p_FmPcdTree->ccTreeBaseAddr)
+ if (p_FmPcdTree->ccTreeBaseAddr)
{
- FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_FmPcd), UINT_TO_PTR(p_FmPcdTree->ccTreeBaseAddr));
+ FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_FmPcd),
+ UINT_TO_PTR(p_FmPcdTree->ccTreeBaseAddr));
p_FmPcdTree->ccTreeBaseAddr = 0;
}
@@ -488,296 +1324,398 @@ static void DeleteTree(t_FmPcdCcTree *p_FmPcdTree, t_FmPcd *p_FmPcd)
}
}
-static void UpdateNodeOwner(t_FmPcdCcNode *p_FmPcdCcNode, bool add)
-{
- ASSERT_COND(p_FmPcdCcNode);
-
- if(add)
- p_FmPcdCcNode->owners++;
- else
- {
- ASSERT_COND(p_FmPcdCcNode->owners);
- p_FmPcdCcNode->owners--;
- }
-}
-
-static void GetCcExtractKeySize(uint8_t parseCodeRealSize, uint8_t *parseCodeCcSize)
+static void GetCcExtractKeySize(uint8_t parseCodeRealSize,
+ uint8_t *parseCodeCcSize)
{
- if((parseCodeRealSize > 0) && (parseCodeRealSize < 2))
+ if ((parseCodeRealSize > 0) && (parseCodeRealSize < 2))
*parseCodeCcSize = 1;
- else if(parseCodeRealSize == 2)
- *parseCodeCcSize = 2;
- else if((parseCodeRealSize > 2) && (parseCodeRealSize <= 4))
- *parseCodeCcSize = 4;
- else if((parseCodeRealSize > 4) && (parseCodeRealSize <= 8))
- *parseCodeCcSize = 8;
- else if((parseCodeRealSize > 8) && (parseCodeRealSize <= 16))
- *parseCodeCcSize = 16;
- else if((parseCodeRealSize > 16) && (parseCodeRealSize <= 24))
- *parseCodeCcSize = 24;
- else if((parseCodeRealSize > 24) && (parseCodeRealSize <= 32))
- *parseCodeCcSize = 32;
- else if((parseCodeRealSize > 32) && (parseCodeRealSize <= 40))
- *parseCodeCcSize = 40;
- else if((parseCodeRealSize > 40) && (parseCodeRealSize <= 48))
- *parseCodeCcSize = 48;
- else if((parseCodeRealSize > 48) && (parseCodeRealSize <= 56))
- *parseCodeCcSize = 56;
else
- *parseCodeCcSize = 0;
+ if (parseCodeRealSize == 2)
+ *parseCodeCcSize = 2;
+ else
+ if ((parseCodeRealSize > 2) && (parseCodeRealSize <= 4))
+ *parseCodeCcSize = 4;
+ else
+ if ((parseCodeRealSize > 4) && (parseCodeRealSize <= 8))
+ *parseCodeCcSize = 8;
+ else
+ if ((parseCodeRealSize > 8) && (parseCodeRealSize <= 16))
+ *parseCodeCcSize = 16;
+ else
+ if ((parseCodeRealSize > 16)
+ && (parseCodeRealSize <= 24))
+ *parseCodeCcSize = 24;
+ else
+ if ((parseCodeRealSize > 24)
+ && (parseCodeRealSize <= 32))
+ *parseCodeCcSize = 32;
+ else
+ if ((parseCodeRealSize > 32)
+ && (parseCodeRealSize <= 40))
+ *parseCodeCcSize = 40;
+ else
+ if ((parseCodeRealSize > 40)
+ && (parseCodeRealSize <= 48))
+ *parseCodeCcSize = 48;
+ else
+ if ((parseCodeRealSize > 48)
+ && (parseCodeRealSize <= 56))
+ *parseCodeCcSize = 56;
+ else
+ *parseCodeCcSize = 0;
}
-static void GetSizeHeaderField(e_NetHeaderType hdr,t_FmPcdFields field,uint8_t *parseCodeRealSize)
+static void GetSizeHeaderField(e_NetHeaderType hdr, t_FmPcdFields field,
+ uint8_t *parseCodeRealSize)
{
- switch(hdr)
+ switch (hdr)
{
case (HEADER_TYPE_ETH):
- switch(field.eth)
+ switch (field.eth)
{
- case(NET_HEADER_FIELD_ETH_DA):
+ case (NET_HEADER_FIELD_ETH_DA):
*parseCodeRealSize = 6;
break;
- case(NET_HEADER_FIELD_ETH_SA):
+
+ case (NET_HEADER_FIELD_ETH_SA):
*parseCodeRealSize = 6;
break;
- case(NET_HEADER_FIELD_ETH_TYPE):
+
+ case (NET_HEADER_FIELD_ETH_TYPE):
*parseCodeRealSize = 2;
break;
+
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported1"));
*parseCodeRealSize = CC_SIZE_ILLEGAL;
break;
}
break;
- case(HEADER_TYPE_PPPoE):
- switch(field.pppoe)
+
+ case (HEADER_TYPE_PPPoE):
+ switch (field.pppoe)
{
- case(NET_HEADER_FIELD_PPPoE_PID):
+ case (NET_HEADER_FIELD_PPPoE_PID):
*parseCodeRealSize = 2;
break;
+
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported1"));
*parseCodeRealSize = CC_SIZE_ILLEGAL;
break;
}
break;
+
case (HEADER_TYPE_VLAN):
- switch(field.vlan)
+ switch (field.vlan)
{
- case(NET_HEADER_FIELD_VLAN_TCI):
+ case (NET_HEADER_FIELD_VLAN_TCI):
*parseCodeRealSize = 2;
break;
+
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported2"));
*parseCodeRealSize = CC_SIZE_ILLEGAL;
break;
}
break;
+
case (HEADER_TYPE_MPLS):
- switch(field.mpls)
+ switch (field.mpls)
{
- case(NET_HEADER_FIELD_MPLS_LABEL_STACK):
+ case (NET_HEADER_FIELD_MPLS_LABEL_STACK):
*parseCodeRealSize = 4;
break;
+
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported3"));
*parseCodeRealSize = CC_SIZE_ILLEGAL;
break;
}
break;
+
case (HEADER_TYPE_IPv4):
- switch(field.ipv4)
+ switch (field.ipv4)
{
- case(NET_HEADER_FIELD_IPv4_DST_IP):
- case(NET_HEADER_FIELD_IPv4_SRC_IP):
+ case (NET_HEADER_FIELD_IPv4_DST_IP):
+ case (NET_HEADER_FIELD_IPv4_SRC_IP):
*parseCodeRealSize = 4;
break;
- case(NET_HEADER_FIELD_IPv4_TOS):
- case(NET_HEADER_FIELD_IPv4_PROTO):
+
+ case (NET_HEADER_FIELD_IPv4_TOS):
+ case (NET_HEADER_FIELD_IPv4_PROTO):
*parseCodeRealSize = 1;
break;
- case(NET_HEADER_FIELD_IPv4_DST_IP | NET_HEADER_FIELD_IPv4_SRC_IP):
+
+ case (NET_HEADER_FIELD_IPv4_DST_IP
+ | NET_HEADER_FIELD_IPv4_SRC_IP):
*parseCodeRealSize = 8;
break;
- case(NET_HEADER_FIELD_IPv4_TTL):
+
+ case (NET_HEADER_FIELD_IPv4_TTL):
*parseCodeRealSize = 1;
break;
+
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported4"));
*parseCodeRealSize = CC_SIZE_ILLEGAL;
break;
}
break;
+
case (HEADER_TYPE_IPv6):
- switch(field.ipv6)
+ switch (field.ipv6)
{
- case(NET_HEADER_FIELD_IPv6_VER | NET_HEADER_FIELD_IPv6_FL | NET_HEADER_FIELD_IPv6_TC):
- *parseCodeRealSize = 4;
+ case (NET_HEADER_FIELD_IPv6_VER | NET_HEADER_FIELD_IPv6_FL
+ | NET_HEADER_FIELD_IPv6_TC):
+ *parseCodeRealSize = 4;
break;
- case(NET_HEADER_FIELD_IPv6_NEXT_HDR):
- case(NET_HEADER_FIELD_IPv6_HOP_LIMIT):
- *parseCodeRealSize = 1;
+
+ case (NET_HEADER_FIELD_IPv6_NEXT_HDR):
+ case (NET_HEADER_FIELD_IPv6_HOP_LIMIT):
+ *parseCodeRealSize = 1;
+ break;
+
+ case (NET_HEADER_FIELD_IPv6_DST_IP):
+ case (NET_HEADER_FIELD_IPv6_SRC_IP):
+ *parseCodeRealSize = 16;
+ break;
+
+ default:
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported5"));
+ *parseCodeRealSize = CC_SIZE_ILLEGAL;
break;
- case(NET_HEADER_FIELD_IPv6_DST_IP):
- case(NET_HEADER_FIELD_IPv6_SRC_IP):
- *parseCodeRealSize = 16;
+ }
+ break;
+
+ case (HEADER_TYPE_IP):
+ switch (field.ip)
+ {
+ case (NET_HEADER_FIELD_IP_DSCP):
+ case (NET_HEADER_FIELD_IP_PROTO):
+ *parseCodeRealSize = 1;
break;
+
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported5"));
*parseCodeRealSize = CC_SIZE_ILLEGAL;
break;
}
break;
+
case (HEADER_TYPE_GRE):
- switch(field.gre)
+ switch (field.gre)
{
- case(NET_HEADER_FIELD_GRE_TYPE):
- *parseCodeRealSize = 2;
+ case (NET_HEADER_FIELD_GRE_TYPE):
+ *parseCodeRealSize = 2;
break;
+
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported6"));
*parseCodeRealSize = CC_SIZE_ILLEGAL;
break;
}
break;
+
case (HEADER_TYPE_MINENCAP):
- switch(field.minencap)
+ switch (field.minencap)
{
- case(NET_HEADER_FIELD_MINENCAP_TYPE):
- *parseCodeRealSize = 1;
+ case (NET_HEADER_FIELD_MINENCAP_TYPE):
+ *parseCodeRealSize = 1;
break;
- case(NET_HEADER_FIELD_MINENCAP_DST_IP):
- case(NET_HEADER_FIELD_MINENCAP_SRC_IP):
- *parseCodeRealSize = 4;
+
+ case (NET_HEADER_FIELD_MINENCAP_DST_IP):
+ case (NET_HEADER_FIELD_MINENCAP_SRC_IP):
+ *parseCodeRealSize = 4;
break;
- case(NET_HEADER_FIELD_MINENCAP_SRC_IP | NET_HEADER_FIELD_MINENCAP_DST_IP):
- *parseCodeRealSize = 8;
+
+ case (NET_HEADER_FIELD_MINENCAP_SRC_IP
+ | NET_HEADER_FIELD_MINENCAP_DST_IP):
+ *parseCodeRealSize = 8;
break;
+
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported7"));
*parseCodeRealSize = CC_SIZE_ILLEGAL;
break;
}
break;
+
case (HEADER_TYPE_TCP):
- switch(field.tcp)
+ switch (field.tcp)
{
- case(NET_HEADER_FIELD_TCP_PORT_SRC):
- case(NET_HEADER_FIELD_TCP_PORT_DST):
- *parseCodeRealSize = 2;
+ case (NET_HEADER_FIELD_TCP_PORT_SRC):
+ case (NET_HEADER_FIELD_TCP_PORT_DST):
+ *parseCodeRealSize = 2;
break;
- case(NET_HEADER_FIELD_TCP_PORT_SRC | NET_HEADER_FIELD_TCP_PORT_DST):
- *parseCodeRealSize = 4;
+
+ case (NET_HEADER_FIELD_TCP_PORT_SRC
+ | NET_HEADER_FIELD_TCP_PORT_DST):
+ *parseCodeRealSize = 4;
break;
+
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported8"));
*parseCodeRealSize = CC_SIZE_ILLEGAL;
break;
}
break;
+
case (HEADER_TYPE_UDP):
- switch(field.udp)
+ switch (field.udp)
{
- case(NET_HEADER_FIELD_UDP_PORT_SRC):
- case(NET_HEADER_FIELD_UDP_PORT_DST):
- *parseCodeRealSize = 2;
+ case (NET_HEADER_FIELD_UDP_PORT_SRC):
+ case (NET_HEADER_FIELD_UDP_PORT_DST):
+ *parseCodeRealSize = 2;
break;
- case(NET_HEADER_FIELD_UDP_PORT_SRC | NET_HEADER_FIELD_UDP_PORT_DST):
- *parseCodeRealSize = 4;
+
+ case (NET_HEADER_FIELD_UDP_PORT_SRC
+ | NET_HEADER_FIELD_UDP_PORT_DST):
+ *parseCodeRealSize = 4;
break;
+
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported9"));
*parseCodeRealSize = CC_SIZE_ILLEGAL;
break;
}
break;
- default:
+
+ default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported10"));
*parseCodeRealSize = CC_SIZE_ILLEGAL;
break;
}
}
-static t_Error ValidateNextEngineParams(t_Handle h_FmPcd, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
+t_Error ValidateNextEngineParams(
+ t_Handle h_FmPcd, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams,
+ e_FmPcdCcStatsMode statsMode)
{
- uint16_t absoluteProfileId;
- t_Error err = E_OK;
- uint8_t relativeSchemeId;
+ uint16_t absoluteProfileId;
+ t_Error err = E_OK;
+ uint8_t relativeSchemeId;
- switch(p_FmPcdCcNextEngineParams->nextEngine)
+ if ((statsMode == e_FM_PCD_CC_STATS_MODE_NONE)
+ && (p_FmPcdCcNextEngineParams->statisticsEn))
+ RETURN_ERROR(
+ MAJOR,
+ E_CONFLICT,
+ ("Statistics are requested for a key, but statistics mode was set"
+ "to 'NONE' upon initialization"));
+
+ switch (p_FmPcdCcNextEngineParams->nextEngine)
{
- case(e_FM_PCD_INVALID):
- err = E_NOT_SUPPORTED;
- break;
- case(e_FM_PCD_DONE):
- if(p_FmPcdCcNextEngineParams->params.enqueueParams.action == e_FM_PCD_ENQ_FRAME)
- {
- if(p_FmPcdCcNextEngineParams->params.enqueueParams.overrideFqid &&
- !p_FmPcdCcNextEngineParams->params.enqueueParams.newFqid)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("not defined fqid for control flow for BMI next engine "));
- if(p_FmPcdCcNextEngineParams->params.enqueueParams.newFqid & ~0x00FFFFFF)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fqidForCtrlFlow must be between 1 and 2^24-1"));
- }
+ case (e_FM_PCD_INVALID):
+ err = E_NOT_SUPPORTED;
break;
- case(e_FM_PCD_KG):
- relativeSchemeId = FmPcdKgGetRelativeSchemeId(h_FmPcd, (uint8_t)(PTR_TO_UINT(p_FmPcdCcNextEngineParams->params.kgParams.h_DirectScheme)-1));
- if(relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)
- RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
- if(!FmPcdKgIsSchemeValidSw(h_FmPcd, relativeSchemeId))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("not valid schemeIndex in KG next engine param"));
- if(!KgIsSchemeAlwaysDirect(h_FmPcd, relativeSchemeId))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("CC Node may point only to a scheme that is always direct."));
+ case (e_FM_PCD_DONE):
+ if ((p_FmPcdCcNextEngineParams->params.enqueueParams.action
+ == e_FM_PCD_ENQ_FRAME)
+ && p_FmPcdCcNextEngineParams->params.enqueueParams.overrideFqid)
+ {
+ if (!p_FmPcdCcNextEngineParams->params.enqueueParams.newFqid)
+ RETURN_ERROR(
+ MAJOR,
+ E_CONFLICT,
+ ("When overrideFqid is set, newFqid must not be zero"));
+ if (p_FmPcdCcNextEngineParams->params.enqueueParams.newFqid
+ & ~0x00FFFFFF)
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("fqidForCtrlFlow must be between 1 and 2^24-1"));
+ }
+ break;
+
+ case (e_FM_PCD_KG):
+ relativeSchemeId =
+ FmPcdKgGetRelativeSchemeId(
+ h_FmPcd,
+ FmPcdKgGetSchemeId(
+ p_FmPcdCcNextEngineParams->params.kgParams.h_DirectScheme));
+ if (relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)
+ RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
+ if (!FmPcdKgIsSchemeValidSw(
+ p_FmPcdCcNextEngineParams->params.kgParams.h_DirectScheme))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("not valid schemeIndex in KG next engine param"));
+ if (!KgIsSchemeAlwaysDirect(h_FmPcd, relativeSchemeId))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("CC Node may point only to a scheme that is always direct."));
break;
- case(e_FM_PCD_PLCR):
- if(p_FmPcdCcNextEngineParams->params.plcrParams.overrideParams)
+
+ case (e_FM_PCD_PLCR):
+ if (p_FmPcdCcNextEngineParams->params.plcrParams.overrideParams)
{
- /* if private policer profile, it may be uninitialized yet, therefor no checks are done at this stage */
- if(p_FmPcdCcNextEngineParams->params.plcrParams.sharedProfile)
- {
- err = FmPcdPlcrGetAbsoluteProfileId(h_FmPcd,e_FM_PCD_PLCR_SHARED,NULL,p_FmPcdCcNextEngineParams->params.plcrParams.newRelativeProfileId, &absoluteProfileId);
- if(err)
- RETURN_ERROR(MAJOR, err, ("Shared profile offset is out of range"));
- if(!FmPcdPlcrIsProfileValid(h_FmPcd, absoluteProfileId))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid profile"));
- }
- else
+ /* if private policer profile, it may be uninitialized yet, therefore no checks are done at this stage */
+ if (p_FmPcdCcNextEngineParams->params.plcrParams.sharedProfile)
{
+ err =
+ FmPcdPlcrGetAbsoluteIdByProfileParams(
+ h_FmPcd,
+ e_FM_PCD_PLCR_SHARED,
+ NULL,
+ p_FmPcdCcNextEngineParams->params.plcrParams.newRelativeProfileId,
+ &absoluteProfileId);
+ if (err)
+ RETURN_ERROR(MAJOR, err,
+ ("Shared profile offset is out of range"));
+ if (!FmPcdPlcrIsProfileValid(h_FmPcd, absoluteProfileId))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("Invalid profile"));
}
- /* TODO - add check according to the revision of the chip.
- if(!p_FmPcdCcNextEngineParams->params.plcrParams.newFqid ||
- (p_FmPcdCcNextEngineParams->params.plcrParams.newFqid & ~0x00FFFFFF))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("newFqid must be between 1 and 2^24-1"));
- */
}
break;
- case(e_FM_PCD_CC):
- if(!p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode)
- RETURN_ERROR(MAJOR, E_NULL_POINTER, ("handler to next Node is NULL"));
+
+ case (e_FM_PCD_HASH):
+ p_FmPcdCcNextEngineParams->nextEngine = e_FM_PCD_CC;
+ case (e_FM_PCD_CC):
+ if (!p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode)
+ RETURN_ERROR(MAJOR, E_NULL_POINTER,
+ ("handler to next Node is NULL"));
+ break;
+
+#if (DPAA_VERSION >= 11)
+ case (e_FM_PCD_FR):
+ if (!p_FmPcdCcNextEngineParams->params.frParams.h_FrmReplic)
+ err = E_NOT_SUPPORTED;
break;
+#endif /* (DPAA_VERSION >= 11) */
+
default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next engine is not correct"));
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("Next engine is not correct"));
}
+
+
return err;
}
-static uint8_t GetGenParseCode(e_FmPcdExtractFrom src, uint32_t offset, bool glblMask, uint8_t *parseArrayOffset, bool fromIc, ccPrivateInfo_t icCode)
+static uint8_t GetGenParseCode(e_FmPcdExtractFrom src,
+ uint32_t offset, bool glblMask,
+ uint8_t *parseArrayOffset, bool fromIc,
+ ccPrivateInfo_t icCode)
{
- if(!fromIc)
+ if (!fromIc)
{
- switch(src)
+ switch (src)
{
- case(e_FM_PCD_EXTRACT_FROM_FRAME_START):
- if(glblMask)
- return CC_PC_GENERIC_WITH_MASK ;
+ case (e_FM_PCD_EXTRACT_FROM_FRAME_START):
+ if (glblMask)
+ return CC_PC_GENERIC_WITH_MASK;
else
- return CC_PC_GENERIC_WITHOUT_MASK;
- case(e_FM_PCD_EXTRACT_FROM_CURR_END_OF_PARSE):
+ return CC_PC_GENERIC_WITHOUT_MASK;
+
+ case (e_FM_PCD_EXTRACT_FROM_CURR_END_OF_PARSE):
*parseArrayOffset = CC_PC_PR_NEXT_HEADER_OFFSET;
- if(offset)
+ if (offset)
return CC_PR_OFFSET;
else
return CC_PR_WITHOUT_OFFSET;
+
default:
REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 'extract from' src"));
return CC_PC_ILLEGAL;
@@ -787,403 +1725,548 @@ static uint8_t GetGenParseCode(e_FmPcdExtractFrom src, uint32_t offset, bool glb
{
switch (icCode)
{
- case(CC_PRIVATE_INFO_IC_KEY_EXACT_MATCH):
- *parseArrayOffset = 0x50;
- return CC_PC_GENERIC_IC_GMASK;
- case(CC_PRIVATE_INFO_IC_HASH_EXACT_MATCH):
- *parseArrayOffset = 0x48;
- return CC_PC_GENERIC_IC_GMASK;
- case(CC_PRIVATE_INFO_IC_HASH_INDEX_LOOKUP):
+ case (CC_PRIVATE_INFO_IC_KEY_EXACT_MATCH):
+ *parseArrayOffset = 0x50;
+ return CC_PC_GENERIC_IC_GMASK;
+
+ case (CC_PRIVATE_INFO_IC_HASH_EXACT_MATCH):
+ *parseArrayOffset = 0x48;
+ return CC_PC_GENERIC_IC_GMASK;
+
+ case (CC_PRIVATE_INFO_IC_HASH_INDEX_LOOKUP):
*parseArrayOffset = 0x48;
- return CC_PC_GENERIC_IC_HASH_INDEXED;
- case(CC_PRIVATE_INFO_IC_DEQ_FQID_INDEX_LOOKUP):
+ return CC_PC_GENERIC_IC_HASH_INDEXED;
+
+ case (CC_PRIVATE_INFO_IC_DEQ_FQID_INDEX_LOOKUP):
*parseArrayOffset = 0x16;
- return CC_PC_GENERIC_IC_HASH_INDEXED;
+ return CC_PC_GENERIC_IC_HASH_INDEXED;
+
default:
REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 'extract from' src"));
break;
}
}
+
return CC_PC_ILLEGAL;
}
-static uint8_t GetFullFieldParseCode(e_NetHeaderType hdr, e_FmPcdHdrIndex index, t_FmPcdFields field)
+static uint8_t GetFullFieldParseCode(e_NetHeaderType hdr, e_FmPcdHdrIndex index,
+ t_FmPcdFields field)
{
+ switch (hdr)
+ {
+ case (HEADER_TYPE_NONE):
+ ASSERT_COND(FALSE);
+ return CC_PC_ILLEGAL;
- switch(hdr)
- {
- case(HEADER_TYPE_NONE):
- ASSERT_COND(FALSE);
- return CC_PC_ILLEGAL;
-
- case(HEADER_TYPE_ETH):
- switch(field.eth)
- {
- case(NET_HEADER_FIELD_ETH_DA):
- return CC_PC_FF_MACDST;
- case(NET_HEADER_FIELD_ETH_SA):
- return CC_PC_FF_MACSRC;
- case(NET_HEADER_FIELD_ETH_TYPE):
- return CC_PC_FF_ETYPE;
- default:
- REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
- return CC_PC_ILLEGAL;
- }
+ case (HEADER_TYPE_ETH):
+ switch (field.eth)
+ {
+ case (NET_HEADER_FIELD_ETH_DA):
+ return CC_PC_FF_MACDST;
+ case (NET_HEADER_FIELD_ETH_SA):
+ return CC_PC_FF_MACSRC;
+ case (NET_HEADER_FIELD_ETH_TYPE):
+ return CC_PC_FF_ETYPE;
+ default:
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
+ return CC_PC_ILLEGAL;
+ }
- case(HEADER_TYPE_VLAN):
- switch(field.vlan)
+ case (HEADER_TYPE_VLAN):
+ switch (field.vlan)
{
- case(NET_HEADER_FIELD_VLAN_TCI):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_VLAN_TCI):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE)
+ || (index == e_FM_PCD_HDR_INDEX_1))
return CC_PC_FF_TCI1;
- if(index == e_FM_PCD_HDR_INDEX_LAST)
+ if (index == e_FM_PCD_HDR_INDEX_LAST)
return CC_PC_FF_TCI2;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return CC_PC_ILLEGAL;
default:
- REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
- return CC_PC_ILLEGAL;
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
+ return CC_PC_ILLEGAL;
}
- case(HEADER_TYPE_MPLS):
- switch(field.mpls)
+ case (HEADER_TYPE_MPLS):
+ switch (field.mpls)
{
- case(NET_HEADER_FIELD_MPLS_LABEL_STACK):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_MPLS_LABEL_STACK):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE)
+ || (index == e_FM_PCD_HDR_INDEX_1))
return CC_PC_FF_MPLS1;
- if(index == e_FM_PCD_HDR_INDEX_LAST)
+ if (index == e_FM_PCD_HDR_INDEX_LAST)
return CC_PC_FF_MPLS_LAST;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal MPLS index"));
return CC_PC_ILLEGAL;
- default:
+ default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return CC_PC_ILLEGAL;
- }
+ }
- case(HEADER_TYPE_IPv4):
- switch(field.ipv4)
+ case (HEADER_TYPE_IPv4):
+ switch (field.ipv4)
{
- case(NET_HEADER_FIELD_IPv4_DST_IP):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_IPv4_DST_IP):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE)
+ || (index == e_FM_PCD_HDR_INDEX_1))
return CC_PC_FF_IPV4DST1;
- if(index == e_FM_PCD_HDR_INDEX_2)
+ if (index == e_FM_PCD_HDR_INDEX_2)
return CC_PC_FF_IPV4DST2;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));
return CC_PC_ILLEGAL;
- case(NET_HEADER_FIELD_IPv4_TOS):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_IPv4_TOS):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE)
+ || (index == e_FM_PCD_HDR_INDEX_1))
return CC_PC_FF_IPV4IPTOS_TC1;
- if(index == e_FM_PCD_HDR_INDEX_2)
+ if (index == e_FM_PCD_HDR_INDEX_2)
return CC_PC_FF_IPV4IPTOS_TC2;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));
return CC_PC_ILLEGAL;
- case(NET_HEADER_FIELD_IPv4_PROTO):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_IPv4_PROTO):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE)
+ || (index == e_FM_PCD_HDR_INDEX_1))
return CC_PC_FF_IPV4PTYPE1;
- if(index == e_FM_PCD_HDR_INDEX_2)
+ if (index == e_FM_PCD_HDR_INDEX_2)
return CC_PC_FF_IPV4PTYPE2;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));
return CC_PC_ILLEGAL;
- case(NET_HEADER_FIELD_IPv4_SRC_IP):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_IPv4_SRC_IP):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE)
+ || (index == e_FM_PCD_HDR_INDEX_1))
return CC_PC_FF_IPV4SRC1;
- if(index == e_FM_PCD_HDR_INDEX_2)
+ if (index == e_FM_PCD_HDR_INDEX_2)
return CC_PC_FF_IPV4SRC2;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));
return CC_PC_ILLEGAL;
- case(NET_HEADER_FIELD_IPv4_SRC_IP | NET_HEADER_FIELD_IPv4_DST_IP):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_IPv4_SRC_IP
+ | NET_HEADER_FIELD_IPv4_DST_IP):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE)
+ || (index == e_FM_PCD_HDR_INDEX_1))
return CC_PC_FF_IPV4SRC1_IPV4DST1;
- if(index == e_FM_PCD_HDR_INDEX_2)
+ if (index == e_FM_PCD_HDR_INDEX_2)
return CC_PC_FF_IPV4SRC2_IPV4DST2;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));
return CC_PC_ILLEGAL;
- case(NET_HEADER_FIELD_IPv4_TTL):
+ case (NET_HEADER_FIELD_IPv4_TTL):
return CC_PC_FF_IPV4TTL;
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return CC_PC_ILLEGAL;
}
- case(HEADER_TYPE_IPv6):
- switch(field.ipv6)
+ case (HEADER_TYPE_IPv6):
+ switch (field.ipv6)
{
- case(NET_HEADER_FIELD_IPv6_VER | NET_HEADER_FIELD_IPv6_FL | NET_HEADER_FIELD_IPv6_TC):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_IPv6_VER | NET_HEADER_FIELD_IPv6_FL
+ | NET_HEADER_FIELD_IPv6_TC):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE)
+ || (index == e_FM_PCD_HDR_INDEX_1))
return CC_PC_FF_IPTOS_IPV6TC1_IPV6FLOW1;
- if(index == e_FM_PCD_HDR_INDEX_2)
+ if (index == e_FM_PCD_HDR_INDEX_2)
return CC_PC_FF_IPTOS_IPV6TC2_IPV6FLOW2;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
return CC_PC_ILLEGAL;
- case(NET_HEADER_FIELD_IPv6_NEXT_HDR):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+
+ case (NET_HEADER_FIELD_IPv6_NEXT_HDR):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE)
+ || (index == e_FM_PCD_HDR_INDEX_1))
return CC_PC_FF_IPV6PTYPE1;
- if(index == e_FM_PCD_HDR_INDEX_2)
+ if (index == e_FM_PCD_HDR_INDEX_2)
return CC_PC_FF_IPV6PTYPE2;
+ if (index == e_FM_PCD_HDR_INDEX_LAST)
+ return CC_PC_FF_IPPID;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
return CC_PC_ILLEGAL;
- case(NET_HEADER_FIELD_IPv6_DST_IP):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+
+ case (NET_HEADER_FIELD_IPv6_DST_IP):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE)
+ || (index == e_FM_PCD_HDR_INDEX_1))
return CC_PC_FF_IPV6DST1;
- if(index == e_FM_PCD_HDR_INDEX_2)
+ if (index == e_FM_PCD_HDR_INDEX_2)
return CC_PC_FF_IPV6DST2;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
return CC_PC_ILLEGAL;
- case(NET_HEADER_FIELD_IPv6_SRC_IP):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+
+ case (NET_HEADER_FIELD_IPv6_SRC_IP):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE)
+ || (index == e_FM_PCD_HDR_INDEX_1))
return CC_PC_FF_IPV6SRC1;
- if(index == e_FM_PCD_HDR_INDEX_2)
+ if (index == e_FM_PCD_HDR_INDEX_2)
return CC_PC_FF_IPV6SRC2;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
return CC_PC_ILLEGAL;
- case(NET_HEADER_FIELD_IPv6_HOP_LIMIT):
+
+ case (NET_HEADER_FIELD_IPv6_HOP_LIMIT):
return CC_PC_FF_IPV6HOP_LIMIT;
- default:
+
+ default:
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
+ return CC_PC_ILLEGAL;
+ }
+
+ case (HEADER_TYPE_IP):
+ switch (field.ip)
+ {
+ case (NET_HEADER_FIELD_IP_DSCP):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE)
+ || (index == e_FM_PCD_HDR_INDEX_1))
+ return CC_PC_FF_IPDSCP;
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IP index"));
+ return CC_PC_ILLEGAL;
+
+ case (NET_HEADER_FIELD_IP_PROTO):
+ if (index == e_FM_PCD_HDR_INDEX_LAST)
+ return CC_PC_FF_IPPID;
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IP index"));
+ return CC_PC_ILLEGAL;
+
+ default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return CC_PC_ILLEGAL;
}
- case(HEADER_TYPE_GRE):
- switch(field.gre)
+ case (HEADER_TYPE_GRE):
+ switch (field.gre)
{
- case(NET_HEADER_FIELD_GRE_TYPE):
+ case (NET_HEADER_FIELD_GRE_TYPE):
return CC_PC_FF_GREPTYPE;
+
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return CC_PC_ILLEGAL;
- }
- case(HEADER_TYPE_MINENCAP):
- switch(field.minencap)
+ }
+
+ case (HEADER_TYPE_MINENCAP):
+ switch (field.minencap)
{
- case(NET_HEADER_FIELD_MINENCAP_TYPE):
+ case (NET_HEADER_FIELD_MINENCAP_TYPE):
return CC_PC_FF_MINENCAP_PTYPE;
- case(NET_HEADER_FIELD_MINENCAP_DST_IP):
+
+ case (NET_HEADER_FIELD_MINENCAP_DST_IP):
return CC_PC_FF_MINENCAP_IPDST;
- case(NET_HEADER_FIELD_MINENCAP_SRC_IP):
+
+ case (NET_HEADER_FIELD_MINENCAP_SRC_IP):
return CC_PC_FF_MINENCAP_IPSRC;
- case(NET_HEADER_FIELD_MINENCAP_SRC_IP | NET_HEADER_FIELD_MINENCAP_DST_IP):
+
+ case (NET_HEADER_FIELD_MINENCAP_SRC_IP
+ | NET_HEADER_FIELD_MINENCAP_DST_IP):
return CC_PC_FF_MINENCAP_IPSRC_IPDST;
+
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return CC_PC_ILLEGAL;
- }
+ }
- case(HEADER_TYPE_TCP):
- switch(field.tcp)
+ case (HEADER_TYPE_TCP):
+ switch (field.tcp)
{
- case(NET_HEADER_FIELD_TCP_PORT_SRC):
+ case (NET_HEADER_FIELD_TCP_PORT_SRC):
return CC_PC_FF_L4PSRC;
- case(NET_HEADER_FIELD_TCP_PORT_DST):
+
+ case (NET_HEADER_FIELD_TCP_PORT_DST):
return CC_PC_FF_L4PDST;
- case(NET_HEADER_FIELD_TCP_PORT_DST | NET_HEADER_FIELD_TCP_PORT_SRC):
+
+ case (NET_HEADER_FIELD_TCP_PORT_DST
+ | NET_HEADER_FIELD_TCP_PORT_SRC):
return CC_PC_FF_L4PSRC_L4PDST;
+
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return CC_PC_ILLEGAL;
}
- case(HEADER_TYPE_PPPoE):
- switch(field.pppoe)
+ case (HEADER_TYPE_PPPoE):
+ switch (field.pppoe)
{
- case(NET_HEADER_FIELD_PPPoE_PID):
+ case (NET_HEADER_FIELD_PPPoE_PID):
return CC_PC_FF_PPPPID;
+
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return CC_PC_ILLEGAL;
}
- case(HEADER_TYPE_UDP):
- switch(field.udp)
+ case (HEADER_TYPE_UDP):
+ switch (field.udp)
{
- case(NET_HEADER_FIELD_UDP_PORT_SRC):
+ case (NET_HEADER_FIELD_UDP_PORT_SRC):
return CC_PC_FF_L4PSRC;
- case(NET_HEADER_FIELD_UDP_PORT_DST):
+
+ case (NET_HEADER_FIELD_UDP_PORT_DST):
return CC_PC_FF_L4PDST;
- case(NET_HEADER_FIELD_UDP_PORT_DST | NET_HEADER_FIELD_UDP_PORT_SRC):
+
+ case (NET_HEADER_FIELD_UDP_PORT_DST
+ | NET_HEADER_FIELD_UDP_PORT_SRC):
return CC_PC_FF_L4PSRC_L4PDST;
+
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return CC_PC_ILLEGAL;
}
- default:
+ default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return CC_PC_ILLEGAL;
}
}
-static uint8_t GetPrParseCode(e_NetHeaderType hdr, e_FmPcdHdrIndex hdrIndex, uint32_t offset, bool glblMask, uint8_t *parseArrayOffset)
+static uint8_t GetPrParseCode(e_NetHeaderType hdr, e_FmPcdHdrIndex hdrIndex,
+ uint32_t offset, bool glblMask,
+ uint8_t *parseArrayOffset)
{
bool offsetRelevant = FALSE;
- if(offset)
+ if (offset)
offsetRelevant = TRUE;
- switch(hdr){
- case(HEADER_TYPE_NONE):
+ switch (hdr)
+ {
+ case (HEADER_TYPE_NONE):
ASSERT_COND(FALSE);
return CC_PC_ILLEGAL;
- case(HEADER_TYPE_ETH):
+
+ case (HEADER_TYPE_ETH):
*parseArrayOffset = (uint8_t)CC_PC_PR_ETH_OFFSET;
break;
- case(HEADER_TYPE_USER_DEFINED_SHIM1):
- if(offset || glblMask)
+
+ case (HEADER_TYPE_USER_DEFINED_SHIM1):
+ if (offset || glblMask)
*parseArrayOffset = (uint8_t)CC_PC_PR_USER_DEFINED_SHIM1_OFFSET;
else
return CC_PC_PR_SHIM1;
break;
- case(HEADER_TYPE_USER_DEFINED_SHIM2):
- if(offset || glblMask)
+
+ case (HEADER_TYPE_USER_DEFINED_SHIM2):
+ if (offset || glblMask)
*parseArrayOffset = (uint8_t)CC_PC_PR_USER_DEFINED_SHIM2_OFFSET;
else
return CC_PC_PR_SHIM2;
break;
- case(HEADER_TYPE_LLC_SNAP):
+
+ case (HEADER_TYPE_LLC_SNAP):
*parseArrayOffset = CC_PC_PR_USER_LLC_SNAP_OFFSET;
break;
- case(HEADER_TYPE_PPPoE):
+
+ case (HEADER_TYPE_PPPoE):
*parseArrayOffset = CC_PC_PR_PPPOE_OFFSET;
break;
- case(HEADER_TYPE_MPLS):
- if((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
- *parseArrayOffset = CC_PC_PR_MPLS1_OFFSET;
- else if(hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
- *parseArrayOffset = CC_PC_PR_MPLS_LAST_OFFSET;
+
+ case (HEADER_TYPE_MPLS):
+ if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE)
+ || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
+ *parseArrayOffset = CC_PC_PR_MPLS1_OFFSET;
+ else
+ if (hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
+ *parseArrayOffset = CC_PC_PR_MPLS_LAST_OFFSET;
else
{
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal MPLS header index"));
return CC_PC_ILLEGAL;
}
- break;
- case(HEADER_TYPE_IPv4):
- case(HEADER_TYPE_IPv6):
- if((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
- *parseArrayOffset = CC_PC_PR_IP1_OFFSET;
- else if(hdrIndex == e_FM_PCD_HDR_INDEX_2)
+ break;
+
+ case (HEADER_TYPE_IPv4):
+ case (HEADER_TYPE_IPv6):
+ if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE)
+ || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
+ *parseArrayOffset = CC_PC_PR_IP1_OFFSET;
+ else
+ if (hdrIndex == e_FM_PCD_HDR_INDEX_2)
*parseArrayOffset = CC_PC_PR_IP_LAST_OFFSET;
- else
- {
- REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IP header index"));
- return CC_PC_ILLEGAL;
+ else
+ {
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IP header index"));
+ return CC_PC_ILLEGAL;
+ }
+ break;
- }
- break;
- case(HEADER_TYPE_MINENCAP):
- *parseArrayOffset = CC_PC_PR_MINENC_OFFSET;
- break;
- case(HEADER_TYPE_GRE):
- *parseArrayOffset = CC_PC_PR_GRE_OFFSET;
- break;
- case(HEADER_TYPE_TCP):
- case(HEADER_TYPE_UDP):
- case(HEADER_TYPE_IPSEC_AH):
- case(HEADER_TYPE_IPSEC_ESP):
- case(HEADER_TYPE_DCCP):
- case(HEADER_TYPE_SCTP):
- *parseArrayOffset = CC_PC_PR_L4_OFFSET;
- break;
+ case (HEADER_TYPE_MINENCAP):
+ *parseArrayOffset = CC_PC_PR_MINENC_OFFSET;
+ break;
- default:
- REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IP header for this type of operation"));
- return CC_PC_ILLEGAL;
- }
+ case (HEADER_TYPE_GRE):
+ *parseArrayOffset = CC_PC_PR_GRE_OFFSET;
+ break;
- if(offsetRelevant)
- return CC_PR_OFFSET;
- else
- return CC_PR_WITHOUT_OFFSET;
+ case (HEADER_TYPE_TCP):
+ case (HEADER_TYPE_UDP):
+ case (HEADER_TYPE_IPSEC_AH):
+ case (HEADER_TYPE_IPSEC_ESP):
+ case (HEADER_TYPE_DCCP):
+ case (HEADER_TYPE_SCTP):
+ *parseArrayOffset = CC_PC_PR_L4_OFFSET;
+ break;
+
+ default:
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IP header for this type of operation"));
+ return CC_PC_ILLEGAL;
+ }
+
+ if (offsetRelevant)
+ return CC_PR_OFFSET;
+ else
+ return CC_PR_WITHOUT_OFFSET;
}
-static uint8_t GetFieldParseCode(e_NetHeaderType hdr, t_FmPcdFields field, uint32_t offset, uint8_t *parseArrayOffset, e_FmPcdHdrIndex hdrIndex)
+static uint8_t GetFieldParseCode(e_NetHeaderType hdr, t_FmPcdFields field,
+ uint32_t offset, uint8_t *parseArrayOffset,
+ e_FmPcdHdrIndex hdrIndex)
{
bool offsetRelevant = FALSE;
- if(offset)
+ if (offset)
offsetRelevant = TRUE;
- switch(hdr)
+ switch (hdr)
{
- case(HEADER_TYPE_NONE):
- ASSERT_COND(FALSE);
- case(HEADER_TYPE_ETH):
- switch(field.eth)
+ case (HEADER_TYPE_NONE):
+ ASSERT_COND(FALSE);
+ break;
+ case (HEADER_TYPE_ETH):
+ switch (field.eth)
{
- case(NET_HEADER_FIELD_ETH_TYPE):
+ case (NET_HEADER_FIELD_ETH_TYPE):
*parseArrayOffset = CC_PC_PR_ETYPE_LAST_OFFSET;
break;
+
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return CC_PC_ILLEGAL;
}
break;
- case(HEADER_TYPE_VLAN):
- switch(field.vlan)
+
+ case (HEADER_TYPE_VLAN):
+ switch (field.vlan)
{
- case(NET_HEADER_FIELD_VLAN_TCI):
- if((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_VLAN_TCI):
+ if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE)
+ || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
*parseArrayOffset = CC_PC_PR_VLAN1_OFFSET;
- else if(hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
- *parseArrayOffset = CC_PC_PR_VLAN2_OFFSET;
+ else
+ if (hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
+ *parseArrayOffset = CC_PC_PR_VLAN2_OFFSET;
break;
+
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return CC_PC_ILLEGAL;
}
- break;
+ break;
+
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal header "));
return CC_PC_ILLEGAL;
}
- if(offsetRelevant)
+
+ if (offsetRelevant)
return CC_PR_OFFSET;
else
return CC_PR_WITHOUT_OFFSET;
}
-static void FillAdOfTypeResult(t_Handle p_Ad, t_FmPcd *p_FmPcd, t_FmPcdCcNextEngineParams *p_CcNextEngineParams)
+static void FillAdOfTypeResult(t_Handle h_Ad,
+ t_FmPcdCcStatsParams *p_FmPcdCcStatsParams,
+ t_FmPcd *p_FmPcd,
+ t_FmPcdCcNextEngineParams *p_CcNextEngineParams)
{
- t_AdOfTypeResult *p_AdResult = (t_AdOfTypeResult*)p_Ad;
- uint32_t tmp = 0, tmpNia = 0;
- uint16_t profileId;
- t_Handle p_AdNewPtr = NULL;
+ t_AdOfTypeResult *p_AdResult = (t_AdOfTypeResult *)h_Ad;
+ t_Handle h_TmpAd;
+ uint32_t tmp = 0, tmpNia = 0;
+ uint16_t profileId;
+ t_Handle p_AdNewPtr = NULL;
+ t_Error err = E_OK;
+ /* There are 3 cases handled in this routine of building a "result" type AD.
+ * Case 1: No Manip. The action descriptor is built within the match table.
+ * Case 2: Manip exists. A new AD is created - p_AdNewPtr. It is initialized
+ * either in the FmPcdManipUpdateAdResultForCc routine or it was already
+ * initialized and returned here.
+ * p_AdResult (within the match table) will be initialized after
+ * this routine returns and point to the existing AD.
+ * Case 3: Manip exists. The action descriptor is built within the match table.
+ * FmPcdManipUpdateAdResultForCc returns a NULL p_AdNewPtr.
+ *
+ * If statistics were enabled and the statistics mode of this node requires
+ * a statistics Ad, it will be placed after the result Ad and before the
+ * manip Ad, if manip Ad exists here.
+ */
+
+ /* As default, the "new" ptr is the current one. i.e. the content of the result
+ * AD will be written into the match table itself (case (1))*/
p_AdNewPtr = p_AdResult;
-#ifdef FM_PCD_CC_MANIP
+ /* Initialize an action descriptor, if current statistics mode requires an Ad */
+ if (p_FmPcdCcStatsParams)
+ {
+ ASSERT_COND(p_FmPcdCcStatsParams->h_StatsAd);
+ ASSERT_COND(p_FmPcdCcStatsParams->h_StatsCounters);
+
+ /* Swapping addresses between statistics Ad and the current lookup AD addresses */
+ h_TmpAd = p_FmPcdCcStatsParams->h_StatsAd;
+ p_FmPcdCcStatsParams->h_StatsAd = h_Ad;
+ h_Ad = h_TmpAd;
+
+ p_AdNewPtr = h_Ad;
+ p_AdResult = h_Ad;
+
+ /* Init statistics Ad and connect current lookup AD as 'next action' from statistics Ad */
+ UpdateStatsAd(p_FmPcdCcStatsParams, h_Ad, p_FmPcd->physicalMuramBase);
+ }
+
+ /* Create manip and return p_AdNewPtr to either a new descriptor or NULL */
if (p_CcNextEngineParams->h_Manip)
- FmPcdManipUpdateAdResultForCc(p_CcNextEngineParams->h_Manip, p_Ad, &p_AdNewPtr);
-#endif /* FM_PCD_CC_MANIP */
+ FmPcdManipUpdateAdResultForCc(p_CcNextEngineParams->h_Manip,
+ p_CcNextEngineParams, h_Ad, &p_AdNewPtr);
- if(p_AdNewPtr)
+ /* if (p_AdNewPtr = NULL) --> Done. (case (3)) */
+ if (p_AdNewPtr)
{
- switch(p_CcNextEngineParams->nextEngine)
+ /* case (1) and (2) */
+ switch (p_CcNextEngineParams->nextEngine)
{
- case(e_FM_PCD_DONE):
- if(p_CcNextEngineParams->params.enqueueParams.action == e_FM_PCD_ENQ_FRAME)
+ case (e_FM_PCD_DONE):
+ if (p_CcNextEngineParams->params.enqueueParams.action
+ == e_FM_PCD_ENQ_FRAME)
{
- if(p_CcNextEngineParams->params.enqueueParams.overrideFqid)
+ if (p_CcNextEngineParams->params.enqueueParams.overrideFqid)
{
- tmp = FM_PCD_AD_RESULT_CONTRL_FLOW_TYPE;
- tmp |= p_CcNextEngineParams->params.enqueueParams.newFqid;
+ tmp = FM_PCD_AD_RESULT_CONTRL_FLOW_TYPE;
+ tmp |=
+ p_CcNextEngineParams->params.enqueueParams.newFqid;
+#if (DPAA_VERSION >= 11)
+ tmp |=
+ (p_CcNextEngineParams->params.enqueueParams.newRelativeStorageProfileId
+ & FM_PCD_AD_RESULT_VSP_MASK)
+ << FM_PCD_AD_RESULT_VSP_SHIFT;
+#endif /* (DPAA_VERSION >= 11) */
}
else
{
- tmp = FM_PCD_AD_RESULT_DATA_FLOW_TYPE;
- tmp |= FM_PCD_AD_RESULT_PLCR_DIS;
+ tmp = FM_PCD_AD_RESULT_DATA_FLOW_TYPE;
+ tmp |= FM_PCD_AD_RESULT_PLCR_DIS;
}
}
- if(p_CcNextEngineParams->params.enqueueParams.action == e_FM_PCD_DROP_FRAME)
- tmpNia |= (NIA_ENG_BMI |NIA_BMI_AC_DISCARD);
- else
- tmpNia |= (NIA_ENG_BMI |NIA_BMI_AC_ENQ_FRAME);
- if(p_CcNextEngineParams->params.enqueueParams.statisticsEn)
- tmpNia |= FM_PCD_AD_RESULT_EXTENDED_MODE | FM_PCD_AD_RESULT_STATISTICS_EN;
+
+ if (p_CcNextEngineParams->params.enqueueParams.action
+ == e_FM_PCD_DROP_FRAME)
+ tmpNia |= GET_NIA_BMI_AC_DISCARD_FRAME(p_FmPcd);
+ else
+ tmpNia |= GET_NIA_BMI_AC_ENQ_FRAME(p_FmPcd);
break;
- case(e_FM_PCD_KG):
- if(p_CcNextEngineParams->params.kgParams.overrideFqid)
+
+ case (e_FM_PCD_KG):
+ if (p_CcNextEngineParams->params.kgParams.overrideFqid)
{
tmp = FM_PCD_AD_RESULT_CONTRL_FLOW_TYPE;
tmp |= p_CcNextEngineParams->params.kgParams.newFqid;
+#if (DPAA_VERSION >= 11)
+ tmp |=
+ (p_CcNextEngineParams->params.kgParams.newRelativeStorageProfileId
+ & FM_PCD_AD_RESULT_VSP_MASK)
+ << FM_PCD_AD_RESULT_VSP_SHIFT;
+#endif /* (DPAA_VERSION >= 11) */
}
else
{
@@ -1192,790 +2275,1206 @@ static void FillAdOfTypeResult(t_Handle p_Ad, t_FmPcd *p_FmPcd, t_FmPcdCcNextEng
}
tmpNia = NIA_KG_DIRECT;
tmpNia |= NIA_ENG_KG;
- tmpNia |= (uint8_t)(PTR_TO_UINT(p_CcNextEngineParams->params.kgParams.h_DirectScheme)-1);
- if(p_CcNextEngineParams->params.kgParams.statisticsEn)
- tmpNia |= FM_PCD_AD_RESULT_EXTENDED_MODE | FM_PCD_AD_RESULT_STATISTICS_EN;
- break;
- case(e_FM_PCD_PLCR):
- tmp = 0;
- if(p_CcNextEngineParams->params.plcrParams.overrideParams)
+ tmpNia |= NIA_KG_CC_EN;
+ tmpNia |= FmPcdKgGetSchemeId(
+ p_CcNextEngineParams->params.kgParams.h_DirectScheme);
+ break;
+
+ case (e_FM_PCD_PLCR):
+ if (p_CcNextEngineParams->params.plcrParams.overrideParams)
{
tmp = FM_PCD_AD_RESULT_CONTRL_FLOW_TYPE;
- /* if private policer profile, it may be uninitialized yet, therefor no checks are done at this stage */
- if(p_CcNextEngineParams->params.plcrParams.sharedProfile)
+ /* if private policer profile, it may be uninitialized yet, therefore no checks are done at this stage */
+ if (p_CcNextEngineParams->params.plcrParams.sharedProfile)
{
tmpNia |= NIA_PLCR_ABSOLUTE;
- FmPcdPlcrGetAbsoluteProfileId((t_Handle)p_FmPcd,e_FM_PCD_PLCR_SHARED,NULL,p_CcNextEngineParams->params.plcrParams.newRelativeProfileId, &profileId);
+ err = FmPcdPlcrGetAbsoluteIdByProfileParams(
+ (t_Handle)p_FmPcd,
+ e_FM_PCD_PLCR_SHARED,
+ NULL,
+ p_CcNextEngineParams->params.plcrParams.newRelativeProfileId,
+ &profileId);
+ if (err != E_OK)
+ return;
+
}
else
- profileId = p_CcNextEngineParams->params.plcrParams.newRelativeProfileId;
+ profileId =
+ p_CcNextEngineParams->params.plcrParams.newRelativeProfileId;
tmp |= p_CcNextEngineParams->params.plcrParams.newFqid;
- WRITE_UINT32(p_AdResult->plcrProfile,(uint32_t)((uint32_t)profileId << FM_PCD_AD_PROFILEID_FOR_CNTRL_SHIFT));
+#if (DPAA_VERSION >= 11)
+ tmp |=
+ (p_CcNextEngineParams->params.plcrParams.newRelativeStorageProfileId
+ & FM_PCD_AD_RESULT_VSP_MASK)
+ << FM_PCD_AD_RESULT_VSP_SHIFT;
+#endif /* (DPAA_VERSION >= 11) */
+ WRITE_UINT32(
+ p_AdResult->plcrProfile,
+ (uint32_t)((uint32_t)profileId << FM_PCD_AD_PROFILEID_FOR_CNTRL_SHIFT));
}
else
- tmp = FM_PCD_AD_RESULT_DATA_FLOW_TYPE;
- tmpNia |= NIA_ENG_PLCR | p_CcNextEngineParams->params.plcrParams.newRelativeProfileId;
- if(p_CcNextEngineParams->params.kgParams.statisticsEn)
- tmpNia |= FM_PCD_AD_RESULT_EXTENDED_MODE | FM_PCD_AD_RESULT_STATISTICS_EN;
- break;
+ tmp = FM_PCD_AD_RESULT_DATA_FLOW_TYPE;
+
+ tmpNia |=
+ NIA_ENG_PLCR
+ | p_CcNextEngineParams->params.plcrParams.newRelativeProfileId;
+ break;
+
default:
return;
- }
- WRITE_UINT32(p_AdResult->fqid, tmp);
+ }WRITE_UINT32(p_AdResult->fqid, tmp);
-#ifdef FM_PCD_CC_MANIP
- if(p_CcNextEngineParams->h_Manip)
+ if (p_CcNextEngineParams->h_Manip)
{
tmp = GET_UINT32(p_AdResult->plcrProfile);
- tmp |= (uint32_t)(XX_VirtToPhys(p_AdNewPtr) - (p_FmPcd->physicalMuramBase)) >> 4;
+ tmp |= (uint32_t)(XX_VirtToPhys(p_AdNewPtr)
+ - (p_FmPcd->physicalMuramBase)) >> 4;
WRITE_UINT32(p_AdResult->plcrProfile, tmp);
tmpNia |= FM_PCD_AD_RESULT_EXTENDED_MODE;
tmpNia |= FM_PCD_AD_RESULT_NADEN;
}
-#endif /* FM_PCD_CC_MANIP */
+#if (DPAA_VERSION >= 11)
+ tmpNia |= FM_PCD_AD_RESULT_NO_OM_VSPE;
+#endif /* (DPAA_VERSION >= 11) */
WRITE_UINT32(p_AdResult->nia, tmpNia);
}
}
-static void FillAdOfTypeContLookup(t_Handle p_Ad, t_Handle h_FmPcd, t_Handle p_FmPcdCcNode, t_Handle h_Manip)
+static t_Error CcUpdateParams(t_Handle h_FmPcd, t_Handle h_PcdParams,
+ t_Handle h_FmPort, t_Handle h_FmTree,
+ bool validate)
{
- t_FmPcdCcNode *p_Node = (t_FmPcdCcNode *)p_FmPcdCcNode;
- t_AdOfTypeContLookup *p_AdContLookup = (t_AdOfTypeContLookup *)p_Ad;
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint32_t tmpReg32;
- t_Handle p_AdNewPtr = NULL;
-
- p_AdNewPtr = p_AdContLookup;
-
-#ifdef FM_PCD_CC_MANIP
- if (h_Manip)
- FmPcdManipUpdateAdContLookupForCc(h_Manip, p_Ad, &p_AdNewPtr, (uint32_t)((XX_VirtToPhys(p_Node->h_AdTable) - p_FmPcd->physicalMuramBase)));
-#else
- UNUSED(h_Manip);
-#endif /* FM_PCD_CC_MANIP */
-
- if(p_AdNewPtr)
- {
- tmpReg32 = 0;
- tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
- tmpReg32 |= p_Node->sizeOfExtraction ? ((p_Node->sizeOfExtraction - 1) << 24) : 0;
- tmpReg32 |= (uint32_t)(XX_VirtToPhys(p_Node->h_AdTable) - p_FmPcd->physicalMuramBase);
- WRITE_UINT32(p_AdContLookup->ccAdBase, tmpReg32);
+ t_FmPcdCcTree *p_CcTree = (t_FmPcdCcTree *)h_FmTree;
- tmpReg32 = 0;
- tmpReg32 |= p_Node->numOfKeys << 24;
- tmpReg32 |= (p_Node->lclMask ? FM_PCD_AD_CONT_LOOKUP_LCL_MASK : 0);
- tmpReg32 |= p_Node->h_KeysMatchTable ?
- (uint32_t)(XX_VirtToPhys(p_Node->h_KeysMatchTable) - p_FmPcd->physicalMuramBase) : 0;
- WRITE_UINT32(p_AdContLookup->matchTblPtr, tmpReg32);
+ return CcUpdateParam(h_FmPcd, h_PcdParams, h_FmPort,
+ p_CcTree->keyAndNextEngineParams,
+ p_CcTree->numOfEntries,
+ UINT_TO_PTR(p_CcTree->ccTreeBaseAddr), validate, 0,
+ h_FmTree, FALSE);
+}
- tmpReg32 = 0;
- tmpReg32 |= p_Node->prsArrayOffset << 24;
- tmpReg32 |= p_Node->offset << 16;
- tmpReg32 |= p_Node->parseCode;
- WRITE_UINT32(p_AdContLookup->pcAndOffsets, tmpReg32);
- Mem2IOCpy32((void*)&p_AdContLookup->gmask, p_Node->p_GlblMask, CC_GLBL_MASK_SIZE);
- }
+static void ReleaseNewNodeCommonPart(
+ t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)
+{
+ if (p_AdditionalInfo->p_AdTableNew)
+ FM_MURAM_FreeMem(
+ FmPcdGetMuramHandle(
+ ((t_FmPcdCcNode *)(p_AdditionalInfo->h_CurrentNode))->h_FmPcd),
+ p_AdditionalInfo->p_AdTableNew);
+
+ if (p_AdditionalInfo->p_KeysMatchTableNew)
+ FM_MURAM_FreeMem(
+ FmPcdGetMuramHandle(
+ ((t_FmPcdCcNode *)(p_AdditionalInfo->h_CurrentNode))->h_FmPcd),
+ p_AdditionalInfo->p_KeysMatchTableNew);
}
-static void NextStepAd(t_Handle p_Ad, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams, t_FmPcd *p_FmPcd)
+static t_Error UpdateGblMask(t_FmPcdCcNode *p_CcNode, uint8_t keySize,
+ uint8_t *p_Mask)
{
- switch(p_FmPcdCcNextEngineParams->nextEngine)
+ uint8_t prvGlblMaskSize = p_CcNode->glblMaskSize;
+
+ if (p_Mask && !p_CcNode->glblMaskUpdated && (keySize <= 4)
+ && !p_CcNode->lclMask)
{
- case(e_FM_PCD_KG):
- case(e_FM_PCD_PLCR):
- case(e_FM_PCD_DONE):
- FillAdOfTypeResult(p_Ad, p_FmPcd, p_FmPcdCcNextEngineParams);
- break;
- case(e_FM_PCD_CC):
- FillAdOfTypeContLookup(p_Ad,
- p_FmPcd,
- p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode,
-#ifdef FM_PCD_CC_MANIP
- p_FmPcdCcNextEngineParams->h_Manip
-#else
- NULL
-#endif /* FM_PCD_CC_MANIP */
- );
- UpdateNodeOwner (p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode,
- TRUE);
- break;
- default:
- return;
+ if (p_CcNode->parseCode && (p_CcNode->parseCode != CC_PC_FF_TCI1)
+ && (p_CcNode->parseCode != CC_PC_FF_TCI2)
+ && (p_CcNode->parseCode != CC_PC_FF_MPLS1)
+ && (p_CcNode->parseCode != CC_PC_FF_MPLS_LAST)
+ && (p_CcNode->parseCode != CC_PC_FF_IPV4IPTOS_TC1)
+ && (p_CcNode->parseCode != CC_PC_FF_IPV4IPTOS_TC2)
+ && (p_CcNode->parseCode != CC_PC_FF_IPTOS_IPV6TC1_IPV6FLOW1)
+ && (p_CcNode->parseCode != CC_PC_FF_IPDSCP)
+ && (p_CcNode->parseCode != CC_PC_FF_IPTOS_IPV6TC2_IPV6FLOW2))
+ {
+ p_CcNode->glblMaskSize = 0;
+ p_CcNode->lclMask = TRUE;
+ }
+ else
+ {
+ memcpy(p_CcNode->p_GlblMask, p_Mask, (sizeof(uint8_t)) * keySize);
+ p_CcNode->glblMaskUpdated = TRUE;
+ p_CcNode->glblMaskSize = 4;
+ }
}
-}
+ else
+ if (p_Mask && (keySize <= 4) && !p_CcNode->lclMask)
+ {
+ if (memcmp(p_CcNode->p_GlblMask, p_Mask, keySize) != 0)
+ {
+ p_CcNode->lclMask = TRUE;
+ p_CcNode->glblMaskSize = 0;
+ }
+ }
+ else
+ if (!p_Mask && p_CcNode->glblMaskUpdated && (keySize <= 4))
+ {
+ uint32_t tmpMask = 0xffffffff;
+ if (memcmp(p_CcNode->p_GlblMask, &tmpMask, 4) != 0)
+ {
+ p_CcNode->lclMask = TRUE;
+ p_CcNode->glblMaskSize = 0;
+ }
+ }
+ else
+ if (p_Mask)
+ {
+ p_CcNode->lclMask = TRUE;
+ p_CcNode->glblMaskSize = 0;
+ }
+ /* In static mode (maxNumOfKeys > 0), local mask is supported
+ only is mask support was enabled at initialization */
+ if (p_CcNode->maxNumOfKeys && (!p_CcNode->maskSupport) && p_CcNode->lclMask)
+ {
+ p_CcNode->lclMask = FALSE;
+ p_CcNode->glblMaskSize = prvGlblMaskSize;
+ return ERROR_CODE(E_NOT_SUPPORTED);
+ }
-static void ReleaseNewNodeCommonPart(t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)
-{
- if(p_AdditionalInfo->p_AdTableNew)
- FM_MURAM_FreeMem(FmPcdGetMuramHandle(((t_FmPcdCcNode *)(p_AdditionalInfo->h_CurrentNode))->h_FmPcd), p_AdditionalInfo->p_AdTableNew);
- if(p_AdditionalInfo->p_KeysMatchTableNew)
- FM_MURAM_FreeMem(FmPcdGetMuramHandle(((t_FmPcdCcNode *)(p_AdditionalInfo->h_CurrentNode))->h_FmPcd), p_AdditionalInfo->p_KeysMatchTableNew);
+ return E_OK;
}
-static t_Error UpdateGblMask(t_FmPcdCcNode *p_FmPcdCcNode, uint8_t keySize, uint8_t *p_Mask)
+static __inline__ t_Handle GetNewAd(t_Handle h_FmPcdCcNodeOrTree, bool isTree)
{
- if (p_Mask &&
- !p_FmPcdCcNode->glblMaskUpdated &&
- (keySize <= 4) &&
- !p_FmPcdCcNode->lclMask )
- {
- memcpy(p_FmPcdCcNode->p_GlblMask, p_Mask, (sizeof(uint8_t))*keySize);
- p_FmPcdCcNode->glblMaskUpdated = TRUE;
- p_FmPcdCcNode->glblMaskSize = 4;
- }
- else if (p_Mask &&
- (keySize <= 4) &&
- !p_FmPcdCcNode->lclMask)
+ t_FmPcd *p_FmPcd;
+ t_Handle h_Ad;
+
+ if (isTree)
+ p_FmPcd = (t_FmPcd *)(((t_FmPcdCcTree *)h_FmPcdCcNodeOrTree)->h_FmPcd);
+ else
+ p_FmPcd = (t_FmPcd *)(((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->h_FmPcd);
+
+ if ((isTree && p_FmPcd->p_CcShadow)
+ || (!isTree && ((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->maxNumOfKeys))
{
- if (memcmp(p_FmPcdCcNode->p_GlblMask, p_Mask, keySize) != 0)
+ /* The allocated shadow is divided as follows:
+ 0 . . . 16 . . .
+ ---------------------------------------------------
+ | Shadow | Shadow Keys | Shadow Next |
+ | Ad | Match Table | Engine Table |
+ | (16 bytes) | (maximal size) | (maximal size) |
+ ---------------------------------------------------
+ */
+ if (!p_FmPcd->p_CcShadow)
{
- p_FmPcdCcNode->lclMask = TRUE;
- p_FmPcdCcNode->glblMaskSize = 0;
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("CC Shadow not allocated"));
+ return NULL;
}
+
+ h_Ad = p_FmPcd->p_CcShadow;
}
- else if (!p_Mask && (p_FmPcdCcNode->glblMaskUpdated) && (keySize <= 4))
+ else
{
- uint32_t tmpMask = 0xffffffff;
- if (memcmp(p_FmPcdCcNode->p_GlblMask, &tmpMask, 4) != 0)
+ h_Ad = (t_Handle)FM_MURAM_AllocMem(FmPcdGetMuramHandle(p_FmPcd),
+ FM_PCD_CC_AD_ENTRY_SIZE,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if (!h_Ad)
{
- p_FmPcdCcNode->lclMask = TRUE;
- p_FmPcdCcNode->glblMaskSize = 0;
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for CC node action descriptor"));
+ return NULL;
}
}
- else if (p_Mask)
- {
- p_FmPcdCcNode->lclMask = TRUE;
- p_FmPcdCcNode->glblMaskSize = 0;
- }
- return E_OK;
+ return h_Ad;
}
-static t_Error BuildNewNodeCommonPart(t_FmPcdCcNode *p_FmPcdCcNode,
- int *size,
- t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)
+static t_Error BuildNewNodeCommonPart(
+ t_FmPcdCcNode *p_CcNode, int *size,
+ t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)
{
+ t_FmPcd *p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
- p_AdditionalInfo->p_AdTableNew = (t_Handle)FM_MURAM_AllocMem(FmPcdGetMuramHandle(p_FmPcdCcNode->h_FmPcd),
- (uint32_t)( (p_AdditionalInfo->numOfKeys+1) * FM_PCD_CC_AD_ENTRY_SIZE),
- FM_PCD_CC_AD_TABLE_ALIGN);
- if(!p_AdditionalInfo->p_AdTableNew)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("No memory in MURAM for AD table "));
+ if (p_CcNode->lclMask)
+ *size = 2 * p_CcNode->ccKeySizeAccExtraction;
+ else
+ *size = p_CcNode->ccKeySizeAccExtraction;
- IOMemSet32((uint8_t*)p_AdditionalInfo->p_AdTableNew, 0, (uint32_t)((p_AdditionalInfo->numOfKeys+1) * FM_PCD_CC_AD_ENTRY_SIZE));
+ if (p_CcNode->maxNumOfKeys == 0)
+ {
+ p_AdditionalInfo->p_AdTableNew = (t_Handle)FM_MURAM_AllocMem(
+ FmPcdGetMuramHandle(p_FmPcd),
+ (uint32_t)((p_AdditionalInfo->numOfKeys + 1)
+ * FM_PCD_CC_AD_ENTRY_SIZE),
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if (!p_AdditionalInfo->p_AdTableNew)
+ RETURN_ERROR(
+ MAJOR, E_NO_MEMORY,
+ ("MURAM allocation for CC node action descriptors table"));
+
+ p_AdditionalInfo->p_KeysMatchTableNew = (t_Handle)FM_MURAM_AllocMem(
+ FmPcdGetMuramHandle(p_FmPcd),
+ (uint32_t)(*size * sizeof(uint8_t)
+ * (p_AdditionalInfo->numOfKeys + 1)),
+ FM_PCD_CC_KEYS_MATCH_TABLE_ALIGN);
+ if (!p_AdditionalInfo->p_KeysMatchTableNew)
+ {
+ FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_CcNode->h_FmPcd),
+ p_AdditionalInfo->p_AdTableNew);
+ p_AdditionalInfo->p_AdTableNew = NULL;
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("MURAM allocation for CC node key match table"));
+ }
- if(p_FmPcdCcNode->lclMask)
- *size = 2 * p_FmPcdCcNode->ccKeySizeAccExtraction;
+ MemSet8(
+ (uint8_t*)p_AdditionalInfo->p_AdTableNew,
+ 0,
+ (uint32_t)((p_AdditionalInfo->numOfKeys + 1)
+ * FM_PCD_CC_AD_ENTRY_SIZE));
+ MemSet8((uint8_t*)p_AdditionalInfo->p_KeysMatchTableNew, 0,
+ *size * sizeof(uint8_t) * (p_AdditionalInfo->numOfKeys + 1));
+ }
else
- *size = p_FmPcdCcNode->ccKeySizeAccExtraction;
-
- p_AdditionalInfo->p_KeysMatchTableNew =
- (t_Handle)FM_MURAM_AllocMem(FmPcdGetMuramHandle(p_FmPcdCcNode->h_FmPcd),
- (uint32_t)(*size * sizeof(uint8_t) * (p_AdditionalInfo->numOfKeys + 1)),
- FM_PCD_CC_KEYS_MATCH_TABLE_ALIGN);
- if(!p_AdditionalInfo->p_KeysMatchTableNew)
{
- FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_FmPcdCcNode->h_FmPcd), p_AdditionalInfo->p_AdTableNew);
- p_AdditionalInfo->p_AdTableNew = NULL;
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("No memory in MURAM for KEY MATCH table"));
+ /* The allocated shadow is divided as follows:
+ 0 . . . 16 . . .
+ ---------------------------------------------------
+ | Shadow | Shadow Keys | Shadow Next |
+ | Ad | Match Table | Engine Table |
+ | (16 bytes) | (maximal size) | (maximal size) |
+ ---------------------------------------------------
+ */
+
+ if (!p_FmPcd->p_CcShadow)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("CC Shadow not allocated"));
+
+ p_AdditionalInfo->p_KeysMatchTableNew =
+ PTR_MOVE(p_FmPcd->p_CcShadow, FM_PCD_CC_AD_ENTRY_SIZE);
+ p_AdditionalInfo->p_AdTableNew =
+ PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, p_CcNode->keysMatchTableMaxSize);
+
+ MemSet8(
+ (uint8_t*)p_AdditionalInfo->p_AdTableNew,
+ 0,
+ (uint32_t)((p_CcNode->maxNumOfKeys + 1)
+ * FM_PCD_CC_AD_ENTRY_SIZE));
+ MemSet8((uint8_t*)p_AdditionalInfo->p_KeysMatchTableNew, 0,
+ (*size) * sizeof(uint8_t) * (p_CcNode->maxNumOfKeys));
}
- IOMemSet32((uint8_t*)p_AdditionalInfo->p_KeysMatchTableNew, 0, *size * sizeof(uint8_t) * (p_AdditionalInfo->numOfKeys + 1));
- p_AdditionalInfo->p_AdTableOld = p_FmPcdCcNode->h_AdTable;
- p_AdditionalInfo->p_KeysMatchTableOld = p_FmPcdCcNode->h_KeysMatchTable;
+ p_AdditionalInfo->p_AdTableOld = p_CcNode->h_AdTable;
+ p_AdditionalInfo->p_KeysMatchTableOld = p_CcNode->h_KeysMatchTable;
return E_OK;
}
-static t_Error BuildNewNodeAddOrMdfyKeyAndNextEngine(t_Handle h_FmPcd ,t_FmPcdCcNode *p_FmPcdCcNode, uint8_t keyIndex, t_FmPcdCcKeyParams *p_KeyParams,t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo, bool add)
+static t_Error BuildNewNodeAddOrMdfyKeyAndNextEngine(
+ t_Handle h_FmPcd, t_FmPcdCcNode *p_CcNode, uint16_t keyIndex,
+ t_FmPcdCcKeyParams *p_KeyParams,
+ t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo, bool add)
{
- t_Error err = E_OK;
- t_Handle p_AdTableNewTmp, p_KeysMatchTableNewTmp;
- t_Handle p_KeysMatchTableOldTmp, p_AdTableOldTmp;
- int size;
- int i = 0, j = 0;
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint32_t requiredAction = 0;
- bool prvLclMask;
- t_CcNodeInformation *p_CcNodeInformation;
- t_List *p_Pos;
+ t_Error err = E_OK;
+ t_Handle p_AdTableNewTmp, p_KeysMatchTableNewTmp;
+ t_Handle p_KeysMatchTableOldTmp, p_AdTableOldTmp;
+ int size;
+ int i = 0, j = 0;
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ uint32_t requiredAction = 0;
+ bool prvLclMask;
+ t_CcNodeInformation *p_CcNodeInformation;
+ t_FmPcdCcStatsParams statsParams = { 0 };
+ t_List *p_Pos;
+ t_FmPcdStatsObj *p_StatsObj;
- /*check that new NIA is legal*/
- err = ValidateNextEngineParams(h_FmPcd, &p_KeyParams->ccNextEngineParams);
- if(err)
+ /* Check that new NIA is legal */
+ err = ValidateNextEngineParams(h_FmPcd, &p_KeyParams->ccNextEngineParams,
+ p_CcNode->statisticsMode);
+ if (err)
RETURN_ERROR(MAJOR, err, NO_MSG);
- prvLclMask = p_FmPcdCcNode->lclMask;
+ prvLclMask = p_CcNode->lclMask;
- /*check that new key is not require update of localMask*/
- err = UpdateGblMask(p_FmPcdCcNode,
- p_FmPcdCcNode->ccKeySizeAccExtraction,
+ /* Check that new key is not require update of localMask */
+ err = UpdateGblMask(p_CcNode, p_CcNode->ccKeySizeAccExtraction,
p_KeyParams->p_Mask);
- if (err != E_OK)
- RETURN_ERROR(MAJOR, err, NO_MSG);
+ if (err)
+ RETURN_ERROR(MAJOR, err, (NO_MSG));
+
+ /* Update internal data structure with new next engine for the given index */
+ memcpy(&p_AdditionalInfo->keyAndNextEngineParams[keyIndex].nextEngineParams,
+ &p_KeyParams->ccNextEngineParams, sizeof(t_FmPcdCcNextEngineParams));
+
+ memcpy(p_AdditionalInfo->keyAndNextEngineParams[keyIndex].key,
+ p_KeyParams->p_Key, p_CcNode->userSizeOfExtraction);
+
+ if ((p_AdditionalInfo->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
+ && p_AdditionalInfo->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip)
+ {
+ err =
+ AllocAndFillAdForContLookupManip(
+ p_AdditionalInfo->keyAndNextEngineParams[keyIndex].nextEngineParams.params.ccParams.h_CcNode);
+ if (err)
+ RETURN_ERROR(MAJOR, err, (NO_MSG));
+ }
- /*update internal data structure for next engine per index (index - key)*/
- memcpy(&p_AdditionalInfo->nextEngineAndRequiredAction[keyIndex].nextEngineParams,&p_KeyParams->ccNextEngineParams, sizeof(t_FmPcdCcNextEngineParams));
+ if (p_KeyParams->p_Mask)
+ memcpy(p_AdditionalInfo->keyAndNextEngineParams[keyIndex].mask,
+ p_KeyParams->p_Mask, p_CcNode->userSizeOfExtraction);
+ else
+ memset(p_AdditionalInfo->keyAndNextEngineParams[keyIndex].mask, 0xFF,
+ p_CcNode->userSizeOfExtraction);
- /*update numOfKeys*/
- if(add)
- p_AdditionalInfo->numOfKeys = (uint8_t)(p_FmPcdCcNode->numOfKeys + 1);
+ /* Update numOfKeys */
+ if (add)
+ p_AdditionalInfo->numOfKeys = (uint8_t)(p_CcNode->numOfKeys + 1);
else
- p_AdditionalInfo->numOfKeys = (uint8_t)p_FmPcdCcNode->numOfKeys;
- /*function which build in the memory new KeyTbl, AdTbl*/
- err = BuildNewNodeCommonPart(p_FmPcdCcNode, &size, p_AdditionalInfo);
- if(err)
+ p_AdditionalInfo->numOfKeys = (uint8_t)p_CcNode->numOfKeys;
+
+ /* Allocate new tables in MURAM: keys match table and action descriptors table */
+ err = BuildNewNodeCommonPart(p_CcNode, &size, p_AdditionalInfo);
+ if (err)
RETURN_ERROR(MAJOR, err, NO_MSG);
-#ifdef FM_PCD_CC_MANIP
- /*check that manip is legal and what requiredAction is necessary for this manip*/
- if(p_KeyParams->ccNextEngineParams.h_Manip)
+ /* Check that manip is legal and what requiredAction is necessary for this manip */
+ if (p_KeyParams->ccNextEngineParams.h_Manip)
{
- err = FmPcdManipCheckParamsForCcNextEgine(&p_KeyParams->ccNextEngineParams,&requiredAction);
- if(err)
+ err = FmPcdManipCheckParamsForCcNextEngine(
+ &p_KeyParams->ccNextEngineParams, &requiredAction);
+ if (err)
RETURN_ERROR(MAJOR, err, (NO_MSG));
-
}
-#endif /* FM_PCD_CC_MANIP */
- p_AdditionalInfo->nextEngineAndRequiredAction[keyIndex].requiredAction = requiredAction;
+ p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction =
+ requiredAction;
+ p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction |=
+ UPDATE_CC_WITH_TREE;
- p_AdditionalInfo->nextEngineAndRequiredAction[keyIndex].requiredAction |= UPDATE_CC_WITH_TREE;
+ /* Update new Ad and new Key Table according to new requirement */
+ i = 0;
+ for (j = 0; j < p_AdditionalInfo->numOfKeys; j++)
+ {
+ p_AdTableNewTmp =
+ PTR_MOVE(p_AdditionalInfo->p_AdTableNew, j*FM_PCD_CC_AD_ENTRY_SIZE);
+ if (j == keyIndex)
+ {
+ if (p_KeyParams->ccNextEngineParams.statisticsEn)
+ {
+ /* Allocate a statistics object that holds statistics AD and counters.
+ - For added key - New statistics AD and counters pointer need to be allocated
+ new statistics object. If statistics were enabled, we need to replace the
+ existing descriptor with a new descriptor with nullified counters.
+ */
+ p_StatsObj = GetStatsObj(p_CcNode);
+ ASSERT_COND(p_StatsObj);
+
+ /* Store allocated statistics object */
+ ASSERT_COND(keyIndex < CC_MAX_NUM_OF_KEYS);
+ p_AdditionalInfo->keyAndNextEngineParams[keyIndex].p_StatsObj =
+ p_StatsObj;
+
+ statsParams.h_StatsAd = p_StatsObj->h_StatsAd;
+ statsParams.h_StatsCounters = p_StatsObj->h_StatsCounters;
+#if (DPAA_VERSION >= 11)
+ statsParams.h_StatsFLRs = p_CcNode->h_StatsFLRs;
+
+#endif /* (DPAA_VERSION >= 11) */
+
+ /* Building action descriptor for the received new key */
+ NextStepAd(p_AdTableNewTmp, &statsParams,
+ &p_KeyParams->ccNextEngineParams, p_FmPcd);
+ }
+ else
+ {
+ /* Building action descriptor for the received new key */
+ NextStepAd(p_AdTableNewTmp, NULL,
+ &p_KeyParams->ccNextEngineParams, p_FmPcd);
+ }
- /*update new Ad and new Key Table according to new requirement*/
- i = 0;
- for(j = 0; j < p_AdditionalInfo->numOfKeys; j++)
- {
- p_AdTableNewTmp = PTR_MOVE(p_AdditionalInfo->p_AdTableNew, j*FM_PCD_CC_AD_ENTRY_SIZE);
- if(j == keyIndex)
- {
- NextStepAd(p_AdTableNewTmp,&p_KeyParams->ccNextEngineParams, p_FmPcd);
- p_KeysMatchTableNewTmp = PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, j*size * sizeof(uint8_t));
- Mem2IOCpy32((void*)p_KeysMatchTableNewTmp, p_KeyParams->p_Key, p_FmPcdCcNode->userSizeOfExtraction);
- if(p_FmPcdCcNode->lclMask)
- {
- if(p_KeyParams->p_Mask)
- Mem2IOCpy32(PTR_MOVE(p_KeysMatchTableNewTmp, p_FmPcdCcNode->ccKeySizeAccExtraction), p_KeyParams->p_Mask, p_FmPcdCcNode->userSizeOfExtraction);
- else if (p_FmPcdCcNode->ccKeySizeAccExtraction > 4)
- IOMemSet32(PTR_MOVE(p_KeysMatchTableNewTmp, p_FmPcdCcNode->ccKeySizeAccExtraction), 0xff, p_FmPcdCcNode->userSizeOfExtraction);
+ /* Copy the received new key into keys match table */
+ p_KeysMatchTableNewTmp =
+ PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, j*size*sizeof(uint8_t));
+
+ MemCpy8((void*)p_KeysMatchTableNewTmp, p_KeyParams->p_Key,
+ p_CcNode->userSizeOfExtraction);
+
+ /* Update mask for the received new key */
+ if (p_CcNode->lclMask)
+ {
+ if (p_KeyParams->p_Mask)
+ {
+ MemCpy8(PTR_MOVE(p_KeysMatchTableNewTmp,
+ p_CcNode->ccKeySizeAccExtraction),
+ p_KeyParams->p_Mask,
+ p_CcNode->userSizeOfExtraction);
+ }
else
- Mem2IOCpy32(PTR_MOVE(p_KeysMatchTableNewTmp, p_FmPcdCcNode->ccKeySizeAccExtraction),p_FmPcdCcNode->p_GlblMask, p_FmPcdCcNode->userSizeOfExtraction);
+ if (p_CcNode->ccKeySizeAccExtraction > 4)
+ {
+ MemSet8(PTR_MOVE(p_KeysMatchTableNewTmp,
+ p_CcNode->ccKeySizeAccExtraction),
+ 0xff, p_CcNode->userSizeOfExtraction);
+ }
+ else
+ {
+ MemCpy8(PTR_MOVE(p_KeysMatchTableNewTmp,
+ p_CcNode->ccKeySizeAccExtraction),
+ p_CcNode->p_GlblMask,
+ p_CcNode->userSizeOfExtraction);
+ }
}
- if(!add)
+
+ /* If key modification requested, the old entry is omitted and replaced by the new parameters */
+ if (!add)
i++;
- }
- else
- {
- p_AdTableOldTmp = PTR_MOVE(p_AdditionalInfo->p_AdTableOld, i*FM_PCD_CC_AD_ENTRY_SIZE);
- IO2IOCpy32(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);
- p_KeysMatchTableNewTmp = PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, j*size * sizeof(uint8_t));
- p_KeysMatchTableOldTmp = PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableOld, i*size * sizeof(uint8_t));
-
- if(p_FmPcdCcNode->lclMask)
- {
- if(prvLclMask)
- IO2IOCpy32(PTR_MOVE(p_KeysMatchTableNewTmp, p_FmPcdCcNode->ccKeySizeAccExtraction),
- PTR_MOVE(p_KeysMatchTableOldTmp, p_FmPcdCcNode->ccKeySizeAccExtraction),
- p_FmPcdCcNode->ccKeySizeAccExtraction);
+ }
+ else
+ {
+ /* Copy existing action descriptors to the newly allocated Ad table */
+ p_AdTableOldTmp =
+ PTR_MOVE(p_AdditionalInfo->p_AdTableOld, i*FM_PCD_CC_AD_ENTRY_SIZE);
+ MemCpy8(p_AdTableNewTmp, p_AdTableOldTmp,
+ FM_PCD_CC_AD_ENTRY_SIZE);
+
+ /* Copy existing keys and their masks to the newly allocated keys match table */
+ p_KeysMatchTableNewTmp =
+ PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, j * size * sizeof(uint8_t));
+ p_KeysMatchTableOldTmp =
+ PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableOld, i * size * sizeof(uint8_t));
+
+ if (p_CcNode->lclMask)
+ {
+ if (prvLclMask)
+ {
+ MemCpy8(
+ PTR_MOVE(p_KeysMatchTableNewTmp, p_CcNode->ccKeySizeAccExtraction),
+ PTR_MOVE(p_KeysMatchTableOldTmp, p_CcNode->ccKeySizeAccExtraction),
+ p_CcNode->ccKeySizeAccExtraction);
+ }
else
{
- p_KeysMatchTableOldTmp = PTR_MOVE(p_FmPcdCcNode->h_KeysMatchTable, i*p_FmPcdCcNode->ccKeySizeAccExtraction*sizeof(uint8_t));
+ p_KeysMatchTableOldTmp =
+ PTR_MOVE(p_CcNode->h_KeysMatchTable,
+ i * (int)p_CcNode->ccKeySizeAccExtraction * sizeof(uint8_t));
- if (p_FmPcdCcNode->ccKeySizeAccExtraction > 4)
- IOMemSet32(PTR_MOVE(p_KeysMatchTableNewTmp, p_FmPcdCcNode->ccKeySizeAccExtraction), 0xff, p_FmPcdCcNode->userSizeOfExtraction);
+ if (p_CcNode->ccKeySizeAccExtraction > 4)
+ {
+ MemSet8(PTR_MOVE(p_KeysMatchTableNewTmp,
+ p_CcNode->ccKeySizeAccExtraction),
+ 0xff, p_CcNode->userSizeOfExtraction);
+ }
else
- IO2IOCpy32(PTR_MOVE(p_KeysMatchTableNewTmp, p_FmPcdCcNode->ccKeySizeAccExtraction), p_FmPcdCcNode->p_GlblMask, p_FmPcdCcNode->userSizeOfExtraction);
+ {
+ MemCpy8(PTR_MOVE(p_KeysMatchTableNewTmp,
+ p_CcNode->ccKeySizeAccExtraction),
+ p_CcNode->p_GlblMask,
+ p_CcNode->userSizeOfExtraction);
+ }
}
}
- IO2IOCpy32(p_KeysMatchTableNewTmp, p_KeysMatchTableOldTmp, p_FmPcdCcNode->ccKeySizeAccExtraction);
- i++;
- }
- }
- p_AdTableNewTmp = PTR_MOVE(p_AdditionalInfo->p_AdTableNew, j*FM_PCD_CC_AD_ENTRY_SIZE);
- p_AdTableOldTmp = PTR_MOVE(p_AdditionalInfo->p_AdTableOld, i*FM_PCD_CC_AD_ENTRY_SIZE);
- IO2IOCpy32(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);
+ MemCpy8(p_KeysMatchTableNewTmp, p_KeysMatchTableOldTmp,
+ p_CcNode->ccKeySizeAccExtraction);
+
+ i++;
+ }
+ }
+ /* Miss action descriptor */
+ p_AdTableNewTmp =
+ PTR_MOVE(p_AdditionalInfo->p_AdTableNew, j * FM_PCD_CC_AD_ENTRY_SIZE);
+ p_AdTableOldTmp =
+ PTR_MOVE(p_AdditionalInfo->p_AdTableOld, i * FM_PCD_CC_AD_ENTRY_SIZE);
+ MemCpy8(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);
- if(!LIST_IsEmpty(&p_FmPcdCcNode->ccTreesLst))
+ if (!NCSW_LIST_IsEmpty(&p_CcNode->ccTreesLst))
{
- LIST_FOR_EACH(p_Pos, &p_FmPcdCcNode->ccTreesLst)
+ NCSW_LIST_FOR_EACH(p_Pos, &p_CcNode->ccTreesLst)
{
p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);
ASSERT_COND(p_CcNodeInformation->h_CcNode);
- /*update the manipulation which has to be updated from parameters of the port*/
- /*it's has to be updated with restrictions defined in the function*/
- err = FmPcdCcSetRequiredAction(p_FmPcdCcNode->h_FmPcd,
- p_FmPcdCcNode->shadowAction | p_AdditionalInfo->nextEngineAndRequiredAction[keyIndex].requiredAction,
- &p_AdditionalInfo->nextEngineAndRequiredAction[keyIndex],
- PTR_MOVE(p_AdditionalInfo->p_AdTableNew, keyIndex*FM_PCD_CC_AD_ENTRY_SIZE),
- 1,
- p_CcNodeInformation->h_CcNode);
- if (err)
- RETURN_ERROR(MAJOR, err, (NO_MSG));
+ /* Update the manipulation which has to be updated from parameters of the port */
+ /* It's has to be updated with restrictions defined in the function */
+ err =
+ SetRequiredAction(
+ p_CcNode->h_FmPcd,
+ p_CcNode->shadowAction
+ | p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction,
+ &p_AdditionalInfo->keyAndNextEngineParams[keyIndex],
+ PTR_MOVE(p_AdditionalInfo->p_AdTableNew, keyIndex*FM_PCD_CC_AD_ENTRY_SIZE),
+ 1, p_CcNodeInformation->h_CcNode);
+ if (err)
+ RETURN_ERROR(MAJOR, err, (NO_MSG));
- err = CcUpdateParam(p_FmPcdCcNode->h_FmPcd,
- NULL,
- &p_AdditionalInfo->nextEngineAndRequiredAction[keyIndex],
- 1,
- PTR_MOVE(p_AdditionalInfo->p_AdTableNew, keyIndex*FM_PCD_CC_AD_ENTRY_SIZE),
- TRUE,
- p_CcNodeInformation->index,
- p_CcNodeInformation->h_CcNode,
- TRUE);
- if (err)
- RETURN_ERROR(MAJOR, err, (NO_MSG));
+ err =
+ CcUpdateParam(
+ p_CcNode->h_FmPcd,
+ NULL,
+ NULL,
+ &p_AdditionalInfo->keyAndNextEngineParams[keyIndex],
+ 1,
+ PTR_MOVE(p_AdditionalInfo->p_AdTableNew, keyIndex*FM_PCD_CC_AD_ENTRY_SIZE),
+ TRUE, p_CcNodeInformation->index,
+ p_CcNodeInformation->h_CcNode, TRUE);
+ if (err)
+ RETURN_ERROR(MAJOR, err, (NO_MSG));
}
- }
+ }
- if(p_FmPcdCcNode->lclMask)
- memset(p_FmPcdCcNode->p_GlblMask, 0xff, CC_GLBL_MASK_SIZE * sizeof(uint8_t));
+ if (p_CcNode->lclMask)
+ memset(p_CcNode->p_GlblMask, 0xff, CC_GLBL_MASK_SIZE * sizeof(uint8_t));
+ if (p_KeyParams->ccNextEngineParams.nextEngine == e_FM_PCD_CC)
+ p_AdditionalInfo->h_NodeForAdd =
+ p_KeyParams->ccNextEngineParams.params.ccParams.h_CcNode;
+ if (p_KeyParams->ccNextEngineParams.h_Manip)
+ p_AdditionalInfo->h_ManipForAdd =
+ p_KeyParams->ccNextEngineParams.h_Manip;
- if(p_KeyParams->ccNextEngineParams.nextEngine == e_FM_PCD_CC)
- p_AdditionalInfo->h_NodeForAdd = p_KeyParams->ccNextEngineParams.params.ccParams.h_CcNode;
+#if (DPAA_VERSION >= 11)
+ if ((p_KeyParams->ccNextEngineParams.nextEngine == e_FM_PCD_FR)
+ && (p_KeyParams->ccNextEngineParams.params.frParams.h_FrmReplic))
+ p_AdditionalInfo->h_FrmReplicForAdd =
+ p_KeyParams->ccNextEngineParams.params.frParams.h_FrmReplic;
+#endif /* (DPAA_VERSION >= 11) */
- if(!add)
+ if (!add)
{
- if(p_FmPcdCcNode->nextEngineAndRequiredAction[keyIndex].nextEngineParams.nextEngine == e_FM_PCD_CC)
- p_AdditionalInfo->h_NodeForRmv = p_FmPcdCcNode->nextEngineAndRequiredAction[keyIndex].nextEngineParams.params.ccParams.h_CcNode;
-#ifdef FM_PCD_CC_MANIP
- if(p_FmPcdCcNode->nextEngineAndRequiredAction[keyIndex].nextEngineParams.h_Manip)
- p_AdditionalInfo->h_ManipForRmv = p_FmPcdCcNode->nextEngineAndRequiredAction[keyIndex].nextEngineParams.h_Manip;
-#endif /* FM_PCD_CC_MANIP */
+ if (p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
+ p_AdditionalInfo->h_NodeForRmv =
+ p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.params.ccParams.h_CcNode;
+
+ if (p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip)
+ p_AdditionalInfo->h_ManipForRmv =
+ p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip;
+
+ /* If statistics were previously enabled, store the old statistics object to be released */
+ if (p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj)
+ {
+ p_AdditionalInfo->p_StatsObjForRmv =
+ p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj;
+ }
+
+#if (DPAA_VERSION >= 11)
+ if ((p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine
+ == e_FM_PCD_FR)
+ && (p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic))
+ p_AdditionalInfo->h_FrmReplicForRmv =
+ p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic;
+#endif /* (DPAA_VERSION >= 11) */
}
return E_OK;
}
-static t_Error BuildNewNodeRemoveKey(t_FmPcdCcNode *p_FmPcdCcNode, uint8_t keyIndex, t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)
+static t_Error BuildNewNodeRemoveKey(
+ t_FmPcdCcNode *p_CcNode, uint16_t keyIndex,
+ t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)
{
- int i = 0, j = 0;
- t_Handle p_AdTableNewTmp,p_KeysMatchTableNewTmp;
- t_Handle p_KeysMatchTableOldTmp, p_AdTableOldTmp;
- int size;
- t_Error err = E_OK;
+ int i = 0, j = 0;
+ t_Handle p_AdTableNewTmp, p_KeysMatchTableNewTmp;
+ t_Handle p_KeysMatchTableOldTmp, p_AdTableOldTmp;
+ int size;
+ t_Error err = E_OK;
/*save new numOfKeys*/
- p_AdditionalInfo->numOfKeys = (uint16_t)(p_FmPcdCcNode->numOfKeys - 1);
+ p_AdditionalInfo->numOfKeys = (uint16_t)(p_CcNode->numOfKeys - 1);
/*function which allocates in the memory new KeyTbl, AdTbl*/
- err = BuildNewNodeCommonPart(p_FmPcdCcNode, &size, p_AdditionalInfo);
- if(err)
+ err = BuildNewNodeCommonPart(p_CcNode, &size, p_AdditionalInfo);
+ if (err)
RETURN_ERROR(MAJOR, err, NO_MSG);
/*update new Ad and new Key Table according to new requirement*/
- for(i = 0, j = 0; j < p_FmPcdCcNode->numOfKeys; i++, j++)
+ for (i = 0, j = 0; j < p_CcNode->numOfKeys; i++, j++)
{
- if(j == keyIndex)
- {
- p_AdTableOldTmp = PTR_MOVE(p_AdditionalInfo->p_AdTableOld, j*FM_PCD_CC_AD_ENTRY_SIZE);
+ if (j == keyIndex)
j++;
- }
- if(j == p_FmPcdCcNode->numOfKeys)
+
+ if (j == p_CcNode->numOfKeys)
break;
- p_AdTableNewTmp = PTR_MOVE(p_AdditionalInfo->p_AdTableNew, i*FM_PCD_CC_AD_ENTRY_SIZE);
- p_AdTableOldTmp = PTR_MOVE(p_AdditionalInfo->p_AdTableOld, j*FM_PCD_CC_AD_ENTRY_SIZE);
- IO2IOCpy32(p_AdTableNewTmp,p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);
- p_KeysMatchTableOldTmp = PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableOld, j*size * sizeof(uint8_t));
- p_KeysMatchTableNewTmp = PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, i*size * sizeof(uint8_t));
- IO2IOCpy32(p_KeysMatchTableNewTmp,p_KeysMatchTableOldTmp, size * sizeof(uint8_t));
+ p_AdTableNewTmp =
+ PTR_MOVE(p_AdditionalInfo->p_AdTableNew, i * FM_PCD_CC_AD_ENTRY_SIZE);
+ p_AdTableOldTmp =
+ PTR_MOVE(p_AdditionalInfo->p_AdTableOld, j * FM_PCD_CC_AD_ENTRY_SIZE);
+ MemCpy8(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);
+
+ p_KeysMatchTableOldTmp =
+ PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableOld, j * size * sizeof(uint8_t));
+ p_KeysMatchTableNewTmp =
+ PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, i * size * sizeof(uint8_t));
+ MemCpy8(p_KeysMatchTableNewTmp, p_KeysMatchTableOldTmp,
+ size * sizeof(uint8_t));
}
- p_AdTableNewTmp = PTR_MOVE(p_AdditionalInfo->p_AdTableNew, i*FM_PCD_CC_AD_ENTRY_SIZE);
- p_AdTableOldTmp = PTR_MOVE(p_AdditionalInfo->p_AdTableOld, j*FM_PCD_CC_AD_ENTRY_SIZE);
- IO2IOCpy32(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);
+ p_AdTableNewTmp =
+ PTR_MOVE(p_AdditionalInfo->p_AdTableNew, i * FM_PCD_CC_AD_ENTRY_SIZE);
+ p_AdTableOldTmp =
+ PTR_MOVE(p_AdditionalInfo->p_AdTableOld, j * FM_PCD_CC_AD_ENTRY_SIZE);
+ MemCpy8(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);
- if(p_FmPcdCcNode->nextEngineAndRequiredAction[keyIndex].nextEngineParams.nextEngine == e_FM_PCD_CC)
- p_AdditionalInfo->h_NodeForRmv = p_FmPcdCcNode->nextEngineAndRequiredAction[keyIndex].nextEngineParams.params.ccParams.h_CcNode;
-#ifdef FM_PCD_CC_MANIP
- if(p_FmPcdCcNode->nextEngineAndRequiredAction[keyIndex].nextEngineParams.h_Manip)
- p_AdditionalInfo->h_ManipForRmv = p_FmPcdCcNode->nextEngineAndRequiredAction[keyIndex].nextEngineParams.h_Manip;
-#endif /* FM_PCD_CC_MANIP */
+ if (p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
+ p_AdditionalInfo->h_NodeForRmv =
+ p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.params.ccParams.h_CcNode;
- return E_OK;
-}
+ if (p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip)
+ p_AdditionalInfo->h_ManipForRmv =
+ p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip;
-static t_Error BuildNewNodeModifyKey(t_FmPcdCcNode *p_FmPcdCcNode, uint8_t keyIndex, uint8_t *p_Key, uint8_t *p_Mask,t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)
-{
- t_Error err = E_OK;
- t_Handle p_AdTableNewTmp, p_KeysMatchTableNewTmp;
- t_Handle p_KeysMatchTableOldTmp, p_AdTableOldTmp;
- int size;
- int i = 0, j = 0;
- bool prvLclMask;
+ /* If statistics were previously enabled, store the old statistics object to be released */
+ if (p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj)
+ {
+ p_AdditionalInfo->p_StatsObjForRmv =
+ p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj;
+ }
- p_AdditionalInfo->numOfKeys = p_FmPcdCcNode->numOfKeys;
+#if (DPAA_VERSION >= 11)
+ if ((p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine
+ == e_FM_PCD_FR)
+ && (p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic))
+ p_AdditionalInfo->h_FrmReplicForRmv =
+ p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic;
+#endif /* (DPAA_VERSION >= 11) */
- prvLclMask = p_FmPcdCcNode->lclMask;
+ return E_OK;
+}
- /*check that new key is not require update of localMask*/
- err = UpdateGblMask(p_FmPcdCcNode,
- p_FmPcdCcNode->sizeOfExtraction,
- p_Mask);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
+static t_Error BuildNewNodeModifyKey(
+ t_FmPcdCcNode *p_CcNode, uint16_t keyIndex, uint8_t *p_Key,
+ uint8_t *p_Mask, t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
+ t_Error err = E_OK;
+ t_Handle p_AdTableNewTmp, p_KeysMatchTableNewTmp;
+ t_Handle p_KeysMatchTableOldTmp, p_AdTableOldTmp;
+ int size;
+ int i = 0, j = 0;
+ bool prvLclMask;
+ t_FmPcdStatsObj *p_StatsObj, tmpStatsObj;
+ p_AdditionalInfo->numOfKeys = p_CcNode->numOfKeys;
+
+ prvLclMask = p_CcNode->lclMask;
+
+ /* Check that new key is not require update of localMask */
+ err = UpdateGblMask(p_CcNode, p_CcNode->ccKeySizeAccExtraction, p_Mask);
+ if (err)
+ RETURN_ERROR(MAJOR, err, (NO_MSG));
+
+ /* Update internal data structure with new next engine for the given index */
+ memcpy(p_AdditionalInfo->keyAndNextEngineParams[keyIndex].key, p_Key,
+ p_CcNode->userSizeOfExtraction);
+
+ if (p_Mask)
+ memcpy(p_AdditionalInfo->keyAndNextEngineParams[keyIndex].mask, p_Mask,
+ p_CcNode->userSizeOfExtraction);
+ else
+ memset(p_AdditionalInfo->keyAndNextEngineParams[keyIndex].mask, 0xFF,
+ p_CcNode->userSizeOfExtraction);
/*function which build in the memory new KeyTbl, AdTbl*/
- err = BuildNewNodeCommonPart(p_FmPcdCcNode, &size, p_AdditionalInfo);
- if(err)
+ err = BuildNewNodeCommonPart(p_CcNode, &size, p_AdditionalInfo);
+ if (err)
RETURN_ERROR(MAJOR, err, NO_MSG);
/*fill the New AdTable and New KeyTable*/
- for(j = 0, i = 0; j < p_AdditionalInfo->numOfKeys; j++, i++)
+ for (j = 0, i = 0; j < p_AdditionalInfo->numOfKeys; j++, i++)
{
- p_AdTableNewTmp = PTR_MOVE(p_AdditionalInfo->p_AdTableNew, j*FM_PCD_CC_AD_ENTRY_SIZE);
- p_AdTableOldTmp = PTR_MOVE(p_AdditionalInfo->p_AdTableOld, i*FM_PCD_CC_AD_ENTRY_SIZE);
- IO2IOCpy32(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);
- if(j == keyIndex)
+ p_AdTableNewTmp =
+ PTR_MOVE(p_AdditionalInfo->p_AdTableNew, j*FM_PCD_CC_AD_ENTRY_SIZE);
+ p_AdTableOldTmp =
+ PTR_MOVE(p_AdditionalInfo->p_AdTableOld, i*FM_PCD_CC_AD_ENTRY_SIZE);
+
+ MemCpy8(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);
+
+ if (j == keyIndex)
{
- p_KeysMatchTableNewTmp = PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, j*size * sizeof(uint8_t));
- Mem2IOCpy32(p_KeysMatchTableNewTmp, p_Key, p_FmPcdCcNode->userSizeOfExtraction);
- if(p_FmPcdCcNode->lclMask)
+ ASSERT_COND(keyIndex < CC_MAX_NUM_OF_KEYS);
+ if (p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj)
+ {
+ /* As statistics were enabled, we need to update the existing
+ statistics descriptor with a new nullified counters. */
+ p_StatsObj = GetStatsObj(p_CcNode);
+ ASSERT_COND(p_StatsObj);
+
+ SetStatsCounters(
+ p_AdTableNewTmp,
+ (uint32_t)((XX_VirtToPhys(p_StatsObj->h_StatsCounters)
+ - p_FmPcd->physicalMuramBase)));
+
+ tmpStatsObj.h_StatsAd = p_StatsObj->h_StatsAd;
+ tmpStatsObj.h_StatsCounters = p_StatsObj->h_StatsCounters;
+
+ /* As we need to replace only the counters, we build a new statistics
+ object that holds the old AD and the new counters - this will be the
+ currently used statistics object.
+ The newly allocated AD is not required and may be released back to
+ the available objects with the previous counters pointer. */
+ p_StatsObj->h_StatsAd =
+ p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj->h_StatsAd;
+
+ p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj->h_StatsAd =
+ tmpStatsObj.h_StatsAd;
+
+ /* Store allocated statistics object */
+ p_AdditionalInfo->keyAndNextEngineParams[keyIndex].p_StatsObj =
+ p_StatsObj;
+
+ /* As statistics were previously enabled, store the old statistics object to be released */
+ p_AdditionalInfo->p_StatsObjForRmv =
+ p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj;
+ }
+
+ p_KeysMatchTableNewTmp =
+ PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, j * size * sizeof(uint8_t));
+
+ MemCpy8(p_KeysMatchTableNewTmp, p_Key,
+ p_CcNode->userSizeOfExtraction);
+
+ if (p_CcNode->lclMask)
{
- if(p_Mask)
- Mem2IOCpy32(PTR_MOVE(p_KeysMatchTableNewTmp, p_FmPcdCcNode->ccKeySizeAccExtraction), p_Mask, p_FmPcdCcNode->userSizeOfExtraction);
- else if (p_FmPcdCcNode->ccKeySizeAccExtraction > 4)
- IOMemSet32(PTR_MOVE(p_KeysMatchTableNewTmp, p_FmPcdCcNode->ccKeySizeAccExtraction), 0xff, p_FmPcdCcNode->userSizeOfExtraction);
+ if (p_Mask)
+ MemCpy8(PTR_MOVE(p_KeysMatchTableNewTmp,
+ p_CcNode->ccKeySizeAccExtraction),
+ p_Mask, p_CcNode->userSizeOfExtraction);
else
- Mem2IOCpy32(PTR_MOVE(p_KeysMatchTableNewTmp, p_FmPcdCcNode->ccKeySizeAccExtraction),p_FmPcdCcNode->p_GlblMask, p_FmPcdCcNode->userSizeOfExtraction);
+ if (p_CcNode->ccKeySizeAccExtraction > 4)
+ MemSet8(PTR_MOVE(p_KeysMatchTableNewTmp,
+ p_CcNode->ccKeySizeAccExtraction),
+ 0xff, p_CcNode->userSizeOfExtraction);
+ else
+ MemCpy8(PTR_MOVE(p_KeysMatchTableNewTmp,
+ p_CcNode->ccKeySizeAccExtraction),
+ p_CcNode->p_GlblMask,
+ p_CcNode->userSizeOfExtraction);
}
}
else
{
- p_KeysMatchTableNewTmp = PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, j*size * sizeof(uint8_t));
- p_KeysMatchTableOldTmp = PTR_MOVE(p_FmPcdCcNode->h_KeysMatchTable, i*size * sizeof(uint8_t));
- if (p_FmPcdCcNode->lclMask)
+ p_KeysMatchTableNewTmp =
+ PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, j * size * sizeof(uint8_t));
+ p_KeysMatchTableOldTmp =
+ PTR_MOVE(p_CcNode->h_KeysMatchTable, i * size * sizeof(uint8_t));
+
+ if (p_CcNode->lclMask)
{
- if(prvLclMask)
- IO2IOCpy32(PTR_MOVE(p_KeysMatchTableNewTmp, p_FmPcdCcNode->ccKeySizeAccExtraction),
- PTR_MOVE(p_KeysMatchTableOldTmp, p_FmPcdCcNode->ccKeySizeAccExtraction),
- p_FmPcdCcNode->userSizeOfExtraction);
+ if (prvLclMask)
+ MemCpy8(
+ PTR_MOVE(p_KeysMatchTableNewTmp, p_CcNode->ccKeySizeAccExtraction),
+ PTR_MOVE(p_KeysMatchTableOldTmp, p_CcNode->ccKeySizeAccExtraction),
+ p_CcNode->userSizeOfExtraction);
else
{
- p_KeysMatchTableOldTmp = PTR_MOVE(p_FmPcdCcNode->h_KeysMatchTable, i*p_FmPcdCcNode->ccKeySizeAccExtraction * sizeof(uint8_t));
-
- if (p_FmPcdCcNode->ccKeySizeAccExtraction > 4)
- IOMemSet32(PTR_MOVE(p_KeysMatchTableNewTmp, p_FmPcdCcNode->ccKeySizeAccExtraction), 0xff, p_FmPcdCcNode->userSizeOfExtraction);
+ p_KeysMatchTableOldTmp =
+ PTR_MOVE(p_CcNode->h_KeysMatchTable,
+ i * (int)p_CcNode->ccKeySizeAccExtraction * sizeof(uint8_t));
+
+ if (p_CcNode->ccKeySizeAccExtraction > 4)
+ MemSet8(PTR_MOVE(p_KeysMatchTableNewTmp,
+ p_CcNode->ccKeySizeAccExtraction),
+ 0xff, p_CcNode->userSizeOfExtraction);
else
- IO2IOCpy32(PTR_MOVE(p_KeysMatchTableNewTmp, p_FmPcdCcNode->ccKeySizeAccExtraction), p_FmPcdCcNode->p_GlblMask, p_FmPcdCcNode->userSizeOfExtraction);
+ MemCpy8(
+ PTR_MOVE(p_KeysMatchTableNewTmp, p_CcNode->ccKeySizeAccExtraction),
+ p_CcNode->p_GlblMask,
+ p_CcNode->userSizeOfExtraction);
}
}
- IO2IOCpy32((void*)p_KeysMatchTableNewTmp, p_KeysMatchTableOldTmp, p_FmPcdCcNode->ccKeySizeAccExtraction);
+ MemCpy8((void*)p_KeysMatchTableNewTmp, p_KeysMatchTableOldTmp,
+ p_CcNode->ccKeySizeAccExtraction);
}
}
- p_AdTableNewTmp = PTR_MOVE(p_AdditionalInfo->p_AdTableNew, j*FM_PCD_CC_AD_ENTRY_SIZE);
- p_AdTableOldTmp = PTR_MOVE(p_FmPcdCcNode->h_AdTable, i*FM_PCD_CC_AD_ENTRY_SIZE);
- IO2IOCpy32(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);
+ p_AdTableNewTmp =
+ PTR_MOVE(p_AdditionalInfo->p_AdTableNew, j * FM_PCD_CC_AD_ENTRY_SIZE);
+ p_AdTableOldTmp = PTR_MOVE(p_CcNode->h_AdTable, i * FM_PCD_CC_AD_ENTRY_SIZE);
+
+ MemCpy8(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);
return E_OK;
}
-static t_Error BuildNewNodeModifyNextEngine(t_Handle h_FmPcd ,t_Handle h_FmPcdCcNodeOrTree, uint16_t keyIndex,t_FmPcdCcNextEngineParams *p_CcNextEngineParams, t_List *h_OldLst, t_List *h_NewLst,t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)
+static t_Error BuildNewNodeModifyNextEngine(
+ t_Handle h_FmPcd, t_Handle h_FmPcdCcNodeOrTree, uint16_t keyIndex,
+ t_FmPcdCcNextEngineParams *p_CcNextEngineParams, t_List *h_OldLst,
+ t_List *h_NewLst, t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)
{
-
- t_Error err = E_OK;
- uint32_t requiredAction = 0;
- t_List *p_Pos;
+ t_Error err = E_OK;
+ uint32_t requiredAction = 0;
+ t_List *p_Pos;
t_CcNodeInformation *p_CcNodeInformation, ccNodeInfo;
- t_Handle p_Ad;
+ t_Handle p_Ad;
t_FmPcdCcNode *p_FmPcdCcNode1 = NULL;
t_FmPcdCcTree *p_FmPcdCcTree = NULL;
+ t_FmPcdStatsObj *p_StatsObj;
+ t_FmPcdCcStatsParams statsParams = { 0 };
ASSERT_COND(p_CcNextEngineParams);
- /*check that new NIA is legal*/
- err = ValidateNextEngineParams(h_FmPcd, p_CcNextEngineParams);
- if(err)
+
+ /* check that new NIA is legal */
+ if (!p_AdditionalInfo->tree)
+ err = ValidateNextEngineParams(
+ h_FmPcd, p_CcNextEngineParams,
+ ((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->statisticsMode);
+ else
+ /* Statistics are not supported for CC root */
+ err = ValidateNextEngineParams(h_FmPcd, p_CcNextEngineParams,
+ e_FM_PCD_CC_STATS_MODE_NONE);
+ if (err)
RETURN_ERROR(MAJOR, err, NO_MSG);
- /*update internal data structure for next engine per index (index - key)*/
- memcpy(&p_AdditionalInfo->nextEngineAndRequiredAction[keyIndex].nextEngineParams,p_CcNextEngineParams, sizeof(t_FmPcdCcNextEngineParams));
+ /* Update internal data structure for next engine per index (index - key) */
+ memcpy(&p_AdditionalInfo->keyAndNextEngineParams[keyIndex].nextEngineParams,
+ p_CcNextEngineParams, sizeof(t_FmPcdCcNextEngineParams));
-#ifdef FM_PCD_CC_MANIP
- /*check that manip is legal and what requiredAction is necessary for this manip*/
- if(p_CcNextEngineParams->h_Manip)
+ /* Check that manip is legal and what requiredAction is necessary for this manip */
+ if (p_CcNextEngineParams->h_Manip)
{
- err = FmPcdManipCheckParamsForCcNextEgine(p_CcNextEngineParams,&requiredAction);
- if(err)
+ err = FmPcdManipCheckParamsForCcNextEngine(p_CcNextEngineParams,
+ &requiredAction);
+ if (err)
RETURN_ERROR(MAJOR, err, (NO_MSG));
-
}
-#endif /* FM_PCD_CC_MANIP */
- if(!p_AdditionalInfo->tree)
+ if (!p_AdditionalInfo->tree)
{
p_FmPcdCcNode1 = (t_FmPcdCcNode *)h_FmPcdCcNodeOrTree;
+ p_AdditionalInfo->numOfKeys = p_FmPcdCcNode1->numOfKeys;
p_Ad = p_FmPcdCcNode1->h_AdTable;
- if(p_FmPcdCcNode1->nextEngineAndRequiredAction[keyIndex].nextEngineParams.nextEngine == e_FM_PCD_CC)
- p_AdditionalInfo->h_NodeForRmv = p_FmPcdCcNode1->nextEngineAndRequiredAction[keyIndex].nextEngineParams.params.ccParams.h_CcNode;
-#ifdef FM_PCD_CC_MANIP
- if(p_FmPcdCcNode1->nextEngineAndRequiredAction[keyIndex].nextEngineParams.h_Manip)
- p_AdditionalInfo->h_ManipForRmv = p_FmPcdCcNode1->nextEngineAndRequiredAction[keyIndex].nextEngineParams.h_Manip;
-#endif /* FM_PCD_CC_MANIP */
+
+ if (p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
+ p_AdditionalInfo->h_NodeForRmv =
+ p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.params.ccParams.h_CcNode;
+
+ if (p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip)
+ p_AdditionalInfo->h_ManipForRmv =
+ p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip;
+
+#if (DPAA_VERSION >= 11)
+ if ((p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine
+ == e_FM_PCD_FR)
+ && (p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic))
+ p_AdditionalInfo->h_FrmReplicForRmv =
+ p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic;
+#endif /* (DPAA_VERSION >= 11) */
}
else
{
p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcNodeOrTree;
p_Ad = UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr);
- if(p_FmPcdCcTree->nextEngineAndRequiredAction[keyIndex].nextEngineParams.nextEngine == e_FM_PCD_CC)
- p_AdditionalInfo->h_NodeForRmv = p_FmPcdCcTree->nextEngineAndRequiredAction[keyIndex].nextEngineParams.params.ccParams.h_CcNode;
-#ifdef FM_PCD_CC_MANIP
- if(p_FmPcdCcTree->nextEngineAndRequiredAction[keyIndex].nextEngineParams.h_Manip)
- p_AdditionalInfo->h_ManipForRmv = p_FmPcdCcTree->nextEngineAndRequiredAction[keyIndex].nextEngineParams.h_Manip;
-#endif /* FM_PCD_CC_MANIP */
+
+ if (p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
+ p_AdditionalInfo->h_NodeForRmv =
+ p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.params.ccParams.h_CcNode;
+
+ if (p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip)
+ p_AdditionalInfo->h_ManipForRmv =
+ p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip;
+
+#if (DPAA_VERSION >= 11)
+ if ((p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine
+ == e_FM_PCD_FR)
+ && (p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic))
+ p_AdditionalInfo->h_FrmReplicForRmv =
+ p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic;
+#endif /* (DPAA_VERSION >= 11) */
+ }
+
+ if ((p_CcNextEngineParams->nextEngine == e_FM_PCD_CC)
+ && p_CcNextEngineParams->h_Manip)
+ {
+ err = AllocAndFillAdForContLookupManip(
+ p_CcNextEngineParams->params.ccParams.h_CcNode);
+ if (err)
+ RETURN_ERROR(MAJOR, err, (NO_MSG));
}
+
ASSERT_COND(p_Ad);
+
memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
ccNodeInfo.h_CcNode = PTR_MOVE(p_Ad, keyIndex * FM_PCD_CC_AD_ENTRY_SIZE);
- EnqueueNodeInfoToRelevantLst(h_OldLst, &ccNodeInfo);
+
+ /* If statistics were enabled, this Ad is the statistics Ad. Need to follow its
+ nextAction to retrieve the actual Nia-Ad. If statistics should remain enabled,
+ only the actual Nia-Ad should be modified. */
+ if ((!p_AdditionalInfo->tree)
+ && (((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->keyAndNextEngineParams[keyIndex].p_StatsObj)
+ && (p_CcNextEngineParams->statisticsEn))
+ ccNodeInfo.h_CcNode =
+ ((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->keyAndNextEngineParams[keyIndex].p_StatsObj->h_StatsAd;
+
+ EnqueueNodeInfoToRelevantLst(h_OldLst, &ccNodeInfo, NULL);
memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
- p_Ad = (t_Handle)FM_MURAM_AllocMem(FmPcdGetMuramHandle(h_FmPcd),
- FM_PCD_CC_AD_ENTRY_SIZE,
- FM_PCD_CC_AD_TABLE_ALIGN);
+ p_Ad = GetNewAd(h_FmPcdCcNodeOrTree, p_AdditionalInfo->tree);
+ if (!p_Ad)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("MURAM allocation for CC node action descriptor"));
+ MemSet8((uint8_t *)p_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
+
+ /* If statistics were not enabled before, but requested now - Allocate a statistics
+ object that holds statistics AD and counters. */
+ if ((!p_AdditionalInfo->tree)
+ && (!((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->keyAndNextEngineParams[keyIndex].p_StatsObj)
+ && (p_CcNextEngineParams->statisticsEn))
+ {
+ p_StatsObj = GetStatsObj((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree);
+ ASSERT_COND(p_StatsObj);
- if(!p_Ad)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
+ /* Store allocated statistics object */
+ p_AdditionalInfo->keyAndNextEngineParams[keyIndex].p_StatsObj =
+ p_StatsObj;
- IOMemSet32((uint8_t *)p_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
- if(p_CcNextEngineParams)
- NextStepAd(p_Ad,p_CcNextEngineParams, h_FmPcd);
- ccNodeInfo.h_CcNode = p_Ad;
- EnqueueNodeInfoToRelevantLst(h_NewLst, &ccNodeInfo);
+ statsParams.h_StatsAd = p_StatsObj->h_StatsAd;
+ statsParams.h_StatsCounters = p_StatsObj->h_StatsCounters;
+
+#if (DPAA_VERSION >= 11)
+ statsParams.h_StatsFLRs =
+ ((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->h_StatsFLRs;
+
+#endif /* (DPAA_VERSION >= 11) */
+
+ NextStepAd(p_Ad, &statsParams, p_CcNextEngineParams, h_FmPcd);
+ }
+ else
+ NextStepAd(p_Ad, NULL, p_CcNextEngineParams, h_FmPcd);
- p_AdditionalInfo->nextEngineAndRequiredAction[keyIndex].requiredAction = requiredAction;
+ ccNodeInfo.h_CcNode = p_Ad;
+ EnqueueNodeInfoToRelevantLst(h_NewLst, &ccNodeInfo, NULL);
- p_AdditionalInfo->nextEngineAndRequiredAction[keyIndex].requiredAction |= UPDATE_CC_WITH_TREE;
+ p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction =
+ requiredAction;
+ p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction |=
+ UPDATE_CC_WITH_TREE;
- if(!p_AdditionalInfo->tree)
+ if (!p_AdditionalInfo->tree)
{
ASSERT_COND(p_FmPcdCcNode1);
- if(!LIST_IsEmpty(&p_FmPcdCcNode1->ccTreesLst))
+ if (!NCSW_LIST_IsEmpty(&p_FmPcdCcNode1->ccTreesLst))
{
- LIST_FOR_EACH(p_Pos, &p_FmPcdCcNode1->ccTreesLst)
+ NCSW_LIST_FOR_EACH(p_Pos, &p_FmPcdCcNode1->ccTreesLst)
{
p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);
+
ASSERT_COND(p_CcNodeInformation->h_CcNode);
- /*update the manipulation which has to be updated from parameters of the port*/
- /*it's has to be updated with restrictions defined in the function*/
- err = FmPcdCcSetRequiredAction(p_FmPcdCcNode1->h_FmPcd, p_FmPcdCcNode1->shadowAction | p_AdditionalInfo->nextEngineAndRequiredAction[keyIndex].requiredAction, &p_AdditionalInfo->nextEngineAndRequiredAction[keyIndex],
- p_Ad, 1, p_CcNodeInformation->h_CcNode);
- if(err)
- RETURN_ERROR(MAJOR, err, (NO_MSG));
- err = CcUpdateParam(p_FmPcdCcNode1->h_FmPcd, NULL, &p_AdditionalInfo->nextEngineAndRequiredAction[keyIndex],1, p_Ad, TRUE, p_CcNodeInformation->index, p_CcNodeInformation->h_CcNode, TRUE);
- if(err)
- RETURN_ERROR(MAJOR, err, (NO_MSG));
+ /* Update the manipulation which has to be updated from parameters of the port
+ it's has to be updated with restrictions defined in the function */
+
+ err =
+ SetRequiredAction(
+ p_FmPcdCcNode1->h_FmPcd,
+ p_FmPcdCcNode1->shadowAction
+ | p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction,
+ &p_AdditionalInfo->keyAndNextEngineParams[keyIndex],
+ p_Ad, 1, p_CcNodeInformation->h_CcNode);
+ if (err)
+ RETURN_ERROR(MAJOR, err, (NO_MSG));
+
+ err = CcUpdateParam(
+ p_FmPcdCcNode1->h_FmPcd, NULL, NULL,
+ &p_AdditionalInfo->keyAndNextEngineParams[keyIndex], 1,
+ p_Ad, TRUE, p_CcNodeInformation->index,
+ p_CcNodeInformation->h_CcNode, TRUE);
+ if (err)
+ RETURN_ERROR(MAJOR, err, (NO_MSG));
}
}
}
else
{
- ASSERT_COND(p_FmPcdCcTree);
- err = FmPcdCcSetRequiredAction(h_FmPcd, p_FmPcdCcTree->requiredAction | p_AdditionalInfo->nextEngineAndRequiredAction[keyIndex].requiredAction, &p_AdditionalInfo->nextEngineAndRequiredAction[keyIndex],
- p_Ad, 1, (t_Handle)p_FmPcdCcTree);
- if(err)
+ ASSERT_COND(p_FmPcdCcTree);
+
+ err =
+ SetRequiredAction(
+ h_FmPcd,
+ p_FmPcdCcTree->requiredAction
+ | p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction,
+ &p_AdditionalInfo->keyAndNextEngineParams[keyIndex],
+ p_Ad, 1, (t_Handle)p_FmPcdCcTree);
+ if (err)
RETURN_ERROR(MAJOR, err, (NO_MSG));
- err = CcUpdateParam(h_FmPcd, NULL, &p_AdditionalInfo->nextEngineAndRequiredAction[keyIndex],1, p_Ad, TRUE, 0, (t_Handle)p_FmPcdCcTree, TRUE);
- if(err)
+
+ err = CcUpdateParam(h_FmPcd, NULL, NULL,
+ &p_AdditionalInfo->keyAndNextEngineParams[keyIndex],
+ 1, p_Ad, TRUE, 0, (t_Handle)p_FmPcdCcTree, TRUE);
+ if (err)
RETURN_ERROR(MAJOR, err, (NO_MSG));
}
- if(p_CcNextEngineParams->nextEngine == e_FM_PCD_CC)
- p_AdditionalInfo->h_NodeForAdd = p_CcNextEngineParams->params.ccParams.h_CcNode;
- return E_OK;
-}
-
-static t_Handle BuildNewAd(t_FmPcdModifyCcKeyAdditionalParams *p_FmPcdModifyCcKeyAdditionalParams,
- t_FmPcdCcNode *p_FmPcdCcNode,
- t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
-{
-
- t_Handle p_Ad;
- t_FmPcdCcNode *p_FmPcdCcNodeTmp;
-
- p_Ad = (t_Handle)FM_MURAM_AllocMem(((t_FmPcd *)(p_FmPcdCcNode->h_FmPcd))->h_FmMuram,
- FM_PCD_CC_AD_ENTRY_SIZE,
- FM_PCD_CC_AD_TABLE_ALIGN);
- if(!p_Ad)
- {
- REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM for AD"));
- return NULL;
- }
- IOMemSet32(p_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
+ if (p_CcNextEngineParams->nextEngine == e_FM_PCD_CC)
+ p_AdditionalInfo->h_NodeForAdd =
+ p_CcNextEngineParams->params.ccParams.h_CcNode;
+ if (p_CcNextEngineParams->h_Manip)
+ p_AdditionalInfo->h_ManipForAdd = p_CcNextEngineParams->h_Manip;
- p_FmPcdCcNodeTmp = (t_FmPcdCcNode*)XX_Malloc(sizeof(t_FmPcdCcNode));
- if(!p_FmPcdCcNodeTmp)
+ /* If statistics were previously enabled, but now are disabled,
+ store the old statistics object to be released */
+ if ((!p_AdditionalInfo->tree)
+ && (((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->keyAndNextEngineParams[keyIndex].p_StatsObj)
+ && (!p_CcNextEngineParams->statisticsEn))
{
- REPORT_ERROR(MAJOR, E_NO_MEMORY, ("p_FmPcdCcNodeTmp"));
- return NULL;
- }
- memset(p_FmPcdCcNodeTmp, 0, sizeof(t_FmPcdCcNode));
-
- p_FmPcdCcNodeTmp->numOfKeys = p_FmPcdModifyCcKeyAdditionalParams->numOfKeys;
- p_FmPcdCcNodeTmp->h_KeysMatchTable = p_FmPcdModifyCcKeyAdditionalParams->p_KeysMatchTableNew;
- p_FmPcdCcNodeTmp->h_AdTable = p_FmPcdModifyCcKeyAdditionalParams->p_AdTableNew;
-
- p_FmPcdCcNodeTmp->lclMask = p_FmPcdCcNode->lclMask;
- p_FmPcdCcNodeTmp->parseCode = p_FmPcdCcNode->parseCode;
- p_FmPcdCcNodeTmp->offset = p_FmPcdCcNode->offset;
- p_FmPcdCcNodeTmp->prsArrayOffset = p_FmPcdCcNode->prsArrayOffset;
- p_FmPcdCcNodeTmp->ctrlFlow = p_FmPcdCcNode->ctrlFlow;
- p_FmPcdCcNodeTmp->ccKeySizeAccExtraction = p_FmPcdCcNode->ccKeySizeAccExtraction;
- p_FmPcdCcNodeTmp->sizeOfExtraction = p_FmPcdCcNode->sizeOfExtraction;
- p_FmPcdCcNodeTmp->glblMaskSize = p_FmPcdCcNode->glblMaskSize;
- p_FmPcdCcNodeTmp->p_GlblMask = p_FmPcdCcNode->p_GlblMask;
+ p_AdditionalInfo->p_StatsObjForRmv =
+ ((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->keyAndNextEngineParams[keyIndex].p_StatsObj;
- if (p_FmPcdCcNextEngineParams->nextEngine == e_FM_PCD_CC)
- FillAdOfTypeContLookup(p_Ad,
- p_FmPcdCcNode->h_FmPcd,
- p_FmPcdCcNodeTmp,
-#ifdef FM_PCD_CC_MANIP
- p_FmPcdCcNextEngineParams->h_Manip
-#else
- NULL
-#endif /* FM_PCD_CC_MANIP */
- );
- XX_Free(p_FmPcdCcNodeTmp);
+ p_AdditionalInfo->keyAndNextEngineParams[keyIndex].p_StatsObj = NULL;
+ }
+#if (DPAA_VERSION >= 11)
+ if ((p_CcNextEngineParams->nextEngine == e_FM_PCD_FR)
+ && (p_CcNextEngineParams->params.frParams.h_FrmReplic))
+ p_AdditionalInfo->h_FrmReplicForAdd =
+ p_CcNextEngineParams->params.frParams.h_FrmReplic;
+#endif /* (DPAA_VERSION >= 11) */
- return p_Ad;
+ return E_OK;
}
-static void UpdateAdPtrOfNodesWhichPointsOnCrntMdfNode(t_FmPcdCcNode *p_CrntMdfNode ,t_FmPcdModifyCcKeyAdditionalParams *p_FmPcdModifyCcKeyAdditionalParams, t_List *h_OldLst, t_List *h_NewLst)
+static void UpdateAdPtrOfNodesWhichPointsOnCrntMdfNode(
+ t_FmPcdCcNode *p_CrntMdfNode, t_List *h_OldLst,
+ t_FmPcdCcNextEngineParams **p_NextEngineParams)
{
- t_CcNodeInformation *p_CcNodeInformation;
- t_FmPcdCcNode *p_NodePtrOnCurrentMdfNode = NULL;
- t_List *p_Pos;
- int i = 0;
- t_Handle p_AdTablePtOnCrntCurrentMdfNode, p_AdTableNewModified;
- t_CcNodeInformation ccNodeInfo;
+ t_CcNodeInformation *p_CcNodeInformation;
+ t_FmPcdCcNode *p_NodePtrOnCurrentMdfNode = NULL;
+ t_List *p_Pos;
+ int i = 0;
+ t_Handle p_AdTablePtOnCrntCurrentMdfNode/*, p_AdTableNewModified*/;
+ t_CcNodeInformation ccNodeInfo;
- LIST_FOR_EACH(p_Pos, &p_CrntMdfNode->ccPrevNodesLst)
+ NCSW_LIST_FOR_EACH(p_Pos, &p_CrntMdfNode->ccPrevNodesLst)
{
p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);
- p_NodePtrOnCurrentMdfNode = (t_FmPcdCcNode *)p_CcNodeInformation->h_CcNode;
+ p_NodePtrOnCurrentMdfNode =
+ (t_FmPcdCcNode *)p_CcNodeInformation->h_CcNode;
+
ASSERT_COND(p_NodePtrOnCurrentMdfNode);
- /*search in the prev node which exact index points on this current modified node for getting AD */
- for(i = 0; i < p_NodePtrOnCurrentMdfNode->numOfKeys + 1; i++)
+
+ /* Search in the previous node which exact index points on this current modified node for getting AD */
+ for (i = 0; i < p_NodePtrOnCurrentMdfNode->numOfKeys + 1; i++)
{
- if(p_NodePtrOnCurrentMdfNode->nextEngineAndRequiredAction[i].nextEngineParams.nextEngine == e_FM_PCD_CC)
+ if (p_NodePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
{
- if(p_NodePtrOnCurrentMdfNode->nextEngineAndRequiredAction[i].nextEngineParams.params.ccParams.h_CcNode == (t_Handle)p_CrntMdfNode)
+ if (p_NodePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode
+ == (t_Handle)p_CrntMdfNode)
{
- p_AdTablePtOnCrntCurrentMdfNode = PTR_MOVE(p_NodePtrOnCurrentMdfNode->h_AdTable, i*FM_PCD_CC_AD_ENTRY_SIZE);
+ if (p_NodePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip)
+ p_AdTablePtOnCrntCurrentMdfNode = p_CrntMdfNode->h_Ad;
+ else
+ if (p_NodePtrOnCurrentMdfNode->keyAndNextEngineParams[i].p_StatsObj)
+ p_AdTablePtOnCrntCurrentMdfNode =
+ p_NodePtrOnCurrentMdfNode->keyAndNextEngineParams[i].p_StatsObj->h_StatsAd;
+ else
+ p_AdTablePtOnCrntCurrentMdfNode =
+ PTR_MOVE(p_NodePtrOnCurrentMdfNode->h_AdTable, i*FM_PCD_CC_AD_ENTRY_SIZE);
+
memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
ccNodeInfo.h_CcNode = p_AdTablePtOnCrntCurrentMdfNode;
- EnqueueNodeInfoToRelevantLst(h_OldLst, &ccNodeInfo);
+ EnqueueNodeInfoToRelevantLst(h_OldLst, &ccNodeInfo, NULL);
- p_AdTableNewModified = BuildNewAd(p_FmPcdModifyCcKeyAdditionalParams, p_CrntMdfNode, &p_NodePtrOnCurrentMdfNode->nextEngineAndRequiredAction[i].nextEngineParams);
- memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
- ccNodeInfo.h_CcNode = p_AdTableNewModified;
- EnqueueNodeInfoToRelevantLst(h_NewLst, &ccNodeInfo);
+ if (!(*p_NextEngineParams))
+ *p_NextEngineParams =
+ &p_NodePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams;
}
}
}
+
ASSERT_COND(i != p_NodePtrOnCurrentMdfNode->numOfKeys);
}
}
-static void UpdateAdPtrOfTreesWhichPointsOnCrntMdfNode(t_FmPcdCcNode *p_CrntMdfNode ,t_FmPcdModifyCcKeyAdditionalParams *p_FmPcdModifyCcKeyAdditionalParams, t_List *h_OldLst, t_List *h_NewLst)
+static void UpdateAdPtrOfTreesWhichPointsOnCrntMdfNode(
+ t_FmPcdCcNode *p_CrntMdfNode, t_List *h_OldLst,
+ t_FmPcdCcNextEngineParams **p_NextEngineParams)
{
- t_CcNodeInformation *p_CcNodeInformation;
- t_FmPcdCcTree *p_TreePtrOnCurrentMdfNode = NULL;
- t_List *p_Pos;
- int i = 0;
- t_Handle p_AdTableTmp, p_AdTableTmp1;
- t_CcNodeInformation ccNodeInfo;
+ t_CcNodeInformation *p_CcNodeInformation;
+ t_FmPcdCcTree *p_TreePtrOnCurrentMdfNode = NULL;
+ t_List *p_Pos;
+ int i = 0;
+ t_Handle p_AdTableTmp;
+ t_CcNodeInformation ccNodeInfo;
- LIST_FOR_EACH(p_Pos, &p_CrntMdfNode->ccTreeIdLst)
+ NCSW_LIST_FOR_EACH(p_Pos, &p_CrntMdfNode->ccTreeIdLst)
{
p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);
- p_TreePtrOnCurrentMdfNode = (t_FmPcdCcTree *)p_CcNodeInformation->h_CcNode;
+ p_TreePtrOnCurrentMdfNode =
+ (t_FmPcdCcTree *)p_CcNodeInformation->h_CcNode;
ASSERT_COND(p_TreePtrOnCurrentMdfNode);
- /*search in the trees which exact index points on this current modified node for getting AD
- */
- for(i = 0; i < p_TreePtrOnCurrentMdfNode->numOfEntries; i++)
+
+ /*search in the trees which exact index points on this current modified node for getting AD */
+ for (i = 0; i < p_TreePtrOnCurrentMdfNode->numOfEntries; i++)
{
- if(p_TreePtrOnCurrentMdfNode->nextEngineAndRequiredAction[i].nextEngineParams.nextEngine == e_FM_PCD_CC)
+ if (p_TreePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
{
- if(p_TreePtrOnCurrentMdfNode->nextEngineAndRequiredAction[i].nextEngineParams.params.ccParams.h_CcNode == (t_Handle)p_CrntMdfNode)
+ if (p_TreePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode
+ == (t_Handle)p_CrntMdfNode)
{
- p_AdTableTmp = UINT_TO_PTR(p_TreePtrOnCurrentMdfNode->ccTreeBaseAddr + i*FM_PCD_CC_AD_ENTRY_SIZE);
+ p_AdTableTmp =
+ UINT_TO_PTR(p_TreePtrOnCurrentMdfNode->ccTreeBaseAddr + i*FM_PCD_CC_AD_ENTRY_SIZE);
memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
ccNodeInfo.h_CcNode = p_AdTableTmp;
- EnqueueNodeInfoToRelevantLst(h_OldLst, &ccNodeInfo);
+ EnqueueNodeInfoToRelevantLst(h_OldLst, &ccNodeInfo, NULL);
- p_AdTableTmp1 = BuildNewAd(p_FmPcdModifyCcKeyAdditionalParams, p_CrntMdfNode, &p_TreePtrOnCurrentMdfNode->nextEngineAndRequiredAction[i].nextEngineParams);
- memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
- ccNodeInfo.h_CcNode = p_AdTableTmp1;
- EnqueueNodeInfoToRelevantLst(h_NewLst, &ccNodeInfo);
+ if (!(*p_NextEngineParams))
+ *p_NextEngineParams =
+ &p_TreePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams;
}
+ }
}
- }
+
ASSERT_COND(i == p_TreePtrOnCurrentMdfNode->numOfEntries);
- }
+ }
}
-static t_Error ModifyKeyCommonPart1(t_Handle h_FmPcdCcNodeOrTree, uint16_t keyIndex, t_Handle *h_Params, e_ModifyState modifyState, bool check, bool tree)
+static t_FmPcdModifyCcKeyAdditionalParams * ModifyNodeCommonPart(
+ t_Handle h_FmPcdCcNodeOrTree, uint16_t keyIndex,
+ e_ModifyState modifyState, bool ttlCheck, bool hashCheck, bool tree)
{
- t_FmPcdModifyCcKeyAdditionalParams *p_FmPcdModifyCcKeyAdditionalParams;
- int i = 0, j = 0;
- bool wasUpdate = FALSE;
- t_FmPcdCcNode *p_FmPcdCcNode = NULL;
- t_FmPcdCcTree *p_FmPcdCcTree;
- uint16_t numOfKeys;
- t_FmPcdCcNextEngineAndRequiredActionParams *p_nextEngineAndRequiredAction = NULL;
-
- SANITY_CHECK_RETURN_ERROR(h_FmPcdCcNodeOrTree,E_INVALID_HANDLE);
+ t_FmPcdModifyCcKeyAdditionalParams *p_FmPcdModifyCcKeyAdditionalParams;
+ int i = 0, j = 0;
+ bool wasUpdate = FALSE;
+ t_FmPcdCcNode *p_CcNode = NULL;
+ t_FmPcdCcTree *p_FmPcdCcTree;
+ uint16_t numOfKeys;
+ t_FmPcdCcKeyAndNextEngineParams *p_KeyAndNextEngineParams;
- p_nextEngineAndRequiredAction = XX_Malloc(FM_PCD_MAX_NUM_OF_KEYS * sizeof(*p_nextEngineAndRequiredAction));
- if(!p_nextEngineAndRequiredAction)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("failed to allocate memory for p_nextEngineAndRequiredAction"));
+ SANITY_CHECK_RETURN_VALUE(h_FmPcdCcNodeOrTree, E_INVALID_HANDLE, NULL);
- memset(p_nextEngineAndRequiredAction, 0, FM_PCD_MAX_NUM_OF_KEYS * sizeof(*p_nextEngineAndRequiredAction));
-
- if(!tree)
+ if (!tree)
{
- p_FmPcdCcNode = (t_FmPcdCcNode *)h_FmPcdCcNodeOrTree;
- numOfKeys = p_FmPcdCcNode->numOfKeys;
+ p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNodeOrTree;
+ numOfKeys = p_CcNode->numOfKeys;
+
+ /* node has to be pointed by another node or tree */
- /*node has to be pointed by another node or tree*/
- if (!LIST_NumOfObjs(&p_FmPcdCcNode->ccPrevNodesLst) &&
- !LIST_NumOfObjs(&p_FmPcdCcNode->ccTreeIdLst))
+ p_KeyAndNextEngineParams = (t_FmPcdCcKeyAndNextEngineParams *)XX_Malloc(
+ sizeof(t_FmPcdCcKeyAndNextEngineParams) * (numOfKeys + 1));
+ if (!p_KeyAndNextEngineParams)
{
- XX_Free(p_nextEngineAndRequiredAction);
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("node has to be pointed by node or tree"));
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Next engine and required action structure"));
+ return NULL;
}
+ memcpy(p_KeyAndNextEngineParams, p_CcNode->keyAndNextEngineParams,
+ (numOfKeys + 1) * sizeof(t_FmPcdCcKeyAndNextEngineParams));
- if(!LIST_NumOfObjs(&p_FmPcdCcNode->ccTreesLst) ||
- (LIST_NumOfObjs(&p_FmPcdCcNode->ccTreesLst) != 1))
+ if (ttlCheck)
{
- XX_Free(p_nextEngineAndRequiredAction);
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("node has to be belonging to some tree and only to one tree"));
+ if ((p_CcNode->parseCode == CC_PC_FF_IPV4TTL)
+ || (p_CcNode->parseCode == CC_PC_FF_IPV6HOP_LIMIT))
+ {
+ XX_Free(p_KeyAndNextEngineParams);
+ REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("nodeId of CC_PC_FF_IPV4TTL or CC_PC_FF_IPV6HOP_LIMIT can not be used for this operation"));
+ return NULL;
+ }
}
- memcpy(p_nextEngineAndRequiredAction,
- p_FmPcdCcNode->nextEngineAndRequiredAction,
- FM_PCD_MAX_NUM_OF_KEYS * sizeof(t_FmPcdCcNextEngineAndRequiredActionParams));
-
- if(check)
+ if (hashCheck)
{
- if((p_FmPcdCcNode->parseCode == CC_PC_FF_IPV4TTL) ||
- (p_FmPcdCcNode->parseCode == CC_PC_FF_IPV6HOP_LIMIT) ||
- (p_FmPcdCcNode->parseCode == CC_PC_GENERIC_IC_HASH_INDEXED))
+ if (p_CcNode->parseCode == CC_PC_GENERIC_IC_HASH_INDEXED)
{
- XX_Free(p_nextEngineAndRequiredAction);
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("nodeId of CC_PC_FF_IPV4TTL or CC_PC_FF_IPV6HOP_LIMIT can not be used for addKey, removeKey, modifyKey"));
+ XX_Free(p_KeyAndNextEngineParams);
+ REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("nodeId of CC_PC_GENERIC_IC_HASH_INDEXED can not be used for this operation"));
+ return NULL;
}
}
}
@@ -1983,36 +3482,52 @@ static t_Error ModifyKeyCommonPart1(t_Handle h_FmPcdCcNodeOrTree, uint16_t keyI
{
p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcNodeOrTree;
numOfKeys = p_FmPcdCcTree->numOfEntries;
- memcpy(p_nextEngineAndRequiredAction,
- p_FmPcdCcTree->nextEngineAndRequiredAction,
- FM_PCD_MAX_NUM_OF_KEYS * sizeof(t_FmPcdCcNextEngineAndRequiredActionParams));
+
+ p_KeyAndNextEngineParams = (t_FmPcdCcKeyAndNextEngineParams *)XX_Malloc(
+ sizeof(t_FmPcdCcKeyAndNextEngineParams)
+ * FM_PCD_MAX_NUM_OF_CC_GROUPS);
+ if (!p_KeyAndNextEngineParams)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Next engine and required action structure"));
+ return NULL;
+ }
+ memcpy(p_KeyAndNextEngineParams,
+ p_FmPcdCcTree->keyAndNextEngineParams,
+ FM_PCD_MAX_NUM_OF_CC_GROUPS
+ * sizeof(t_FmPcdCcKeyAndNextEngineParams));
}
p_FmPcdModifyCcKeyAdditionalParams =
- (t_FmPcdModifyCcKeyAdditionalParams *)XX_Malloc(sizeof(t_FmPcdModifyCcKeyAdditionalParams));
- if(!p_FmPcdModifyCcKeyAdditionalParams)
+ (t_FmPcdModifyCcKeyAdditionalParams *)XX_Malloc(
+ sizeof(t_FmPcdModifyCcKeyAdditionalParams));
+ if (!p_FmPcdModifyCcKeyAdditionalParams)
{
- XX_Free(p_nextEngineAndRequiredAction);
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Allocation of internal data structure FAILED"));
+ XX_Free(p_KeyAndNextEngineParams);
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Allocation of internal data structure FAILED"));
+ return NULL;
}
- memset(p_FmPcdModifyCcKeyAdditionalParams, 0, sizeof(t_FmPcdModifyCcKeyAdditionalParams));
+ memset(p_FmPcdModifyCcKeyAdditionalParams, 0,
+ sizeof(t_FmPcdModifyCcKeyAdditionalParams));
p_FmPcdModifyCcKeyAdditionalParams->h_CurrentNode = h_FmPcdCcNodeOrTree;
- p_FmPcdModifyCcKeyAdditionalParams->keyIndex = keyIndex;
+ p_FmPcdModifyCcKeyAdditionalParams->savedKeyIndex = keyIndex;
- while(i < numOfKeys)
+ while (i < numOfKeys)
{
- if((j == keyIndex) && !wasUpdate)
+ if ((j == keyIndex) && !wasUpdate)
{
- if(modifyState == e_MODIFY_STATE_ADD)
+ if (modifyState == e_MODIFY_STATE_ADD)
j++;
- else if(modifyState == e_MODIFY_STATE_REMOVE)
- i++;
+ else
+ if (modifyState == e_MODIFY_STATE_REMOVE)
+ i++;
wasUpdate = TRUE;
}
else
{
- memcpy(&p_FmPcdModifyCcKeyAdditionalParams->nextEngineAndRequiredAction[j], &p_nextEngineAndRequiredAction[i], sizeof(t_FmPcdCcNextEngineAndRequiredActionParams));
+ memcpy(&p_FmPcdModifyCcKeyAdditionalParams->keyAndNextEngineParams[j],
+ p_KeyAndNextEngineParams + i,
+ sizeof(t_FmPcdCcKeyAndNextEngineParams));
i++;
j++;
}
@@ -2022,34 +3537,65 @@ static t_Error ModifyKeyCommonPart1(t_Handle h_FmPcdCcNodeOrTree, uint16_t keyI
{
if (modifyState == e_MODIFY_STATE_ADD)
j++;
- else if(modifyState == e_MODIFY_STATE_REMOVE)
- i++;
}
- memcpy(&p_FmPcdModifyCcKeyAdditionalParams->nextEngineAndRequiredAction[j], &p_nextEngineAndRequiredAction[numOfKeys], sizeof(t_FmPcdCcNextEngineAndRequiredActionParams));
+ memcpy(&p_FmPcdModifyCcKeyAdditionalParams->keyAndNextEngineParams[j],
+ p_KeyAndNextEngineParams + numOfKeys,
+ sizeof(t_FmPcdCcKeyAndNextEngineParams));
- XX_Free(p_nextEngineAndRequiredAction);
- *h_Params = p_FmPcdModifyCcKeyAdditionalParams;
+ XX_Free(p_KeyAndNextEngineParams);
- return E_OK;
+ return p_FmPcdModifyCcKeyAdditionalParams;
}
-static t_Error UpdatePtrWhichPointOnCrntMdfNode(t_FmPcdCcNode *p_FmPcdCcNode, t_FmPcdModifyCcKeyAdditionalParams *p_FmPcdModifyCcKeyAdditionalParams ,t_List *h_OldLst, t_List *h_NewLst)
+static t_Error UpdatePtrWhichPointOnCrntMdfNode(
+ t_FmPcdCcNode *p_CcNode,
+ t_FmPcdModifyCcKeyAdditionalParams *p_FmPcdModifyCcKeyAdditionalParams,
+ t_List *h_OldLst, t_List *h_NewLst)
{
- if(!LIST_IsEmpty(&p_FmPcdCcNode->ccPrevNodesLst))
- UpdateAdPtrOfNodesWhichPointsOnCrntMdfNode(p_FmPcdCcNode, p_FmPcdModifyCcKeyAdditionalParams, h_OldLst, h_NewLst);
+ t_FmPcdCcNextEngineParams *p_NextEngineParams = NULL;
+ t_CcNodeInformation ccNodeInfo = { 0 };
+ t_Handle h_NewAd;
+ t_Handle h_OrigAd = NULL;
+
+ /* Building a list of all action descriptors that point to the previous node */
+ if (!NCSW_LIST_IsEmpty(&p_CcNode->ccPrevNodesLst))
+ UpdateAdPtrOfNodesWhichPointsOnCrntMdfNode(p_CcNode, h_OldLst,
+ &p_NextEngineParams);
+
+ if (!NCSW_LIST_IsEmpty(&p_CcNode->ccTreeIdLst))
+ UpdateAdPtrOfTreesWhichPointsOnCrntMdfNode(p_CcNode, h_OldLst,
+ &p_NextEngineParams);
+
+ /* This node must be found as next engine of one of its previous nodes or trees*/
+ if (p_NextEngineParams)
+ {
+ /* Building a new action descriptor that points to the modified node */
+ h_NewAd = GetNewAd(p_CcNode, FALSE);
+ if (!h_NewAd)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
+ MemSet8(h_NewAd, 0, FM_PCD_CC_AD_ENTRY_SIZE);
- if(!LIST_IsEmpty(&p_FmPcdCcNode->ccTreeIdLst))
- UpdateAdPtrOfTreesWhichPointsOnCrntMdfNode(p_FmPcdCcNode, p_FmPcdModifyCcKeyAdditionalParams, h_OldLst, h_NewLst);
+ h_OrigAd = p_CcNode->h_Ad;
+ BuildNewAd(h_NewAd, p_FmPcdModifyCcKeyAdditionalParams, p_CcNode,
+ p_NextEngineParams);
+ ccNodeInfo.h_CcNode = h_NewAd;
+ EnqueueNodeInfoToRelevantLst(h_NewLst, &ccNodeInfo, NULL);
+
+ if (p_NextEngineParams->h_Manip && !h_OrigAd)
+ FmPcdManipUpdateOwner(p_NextEngineParams->h_Manip, FALSE);
+ }
return E_OK;
}
-static void FmPcdCcUpdateTreeOwner(t_FmPcdCcTree *p_FmPcdCcTree, bool add)
+static void UpdateCcRootOwner(t_FmPcdCcTree *p_FmPcdCcTree, bool add)
{
ASSERT_COND(p_FmPcdCcTree);
- if(add)
+ /* this routine must be protected by the calling routine! */
+
+ if (add)
p_FmPcdCcTree->owners++;
else
{
@@ -2058,728 +3604,2412 @@ static void FmPcdCcUpdateTreeOwner(t_FmPcdCcTree *p_FmPcdCcTree, bool add)
}
}
-#ifdef FM_PCD_CC_MANIP
-static t_Error CheckAndSetManipParamsWithCcNodeParams(t_FmPcdCcNode *p_FmPcdCcNode)
+static t_Error CheckAndSetManipParamsWithCcNodeParams(t_FmPcdCcNode *p_CcNode)
{
t_Error err = E_OK;
- int i = 0;
+ int i = 0;
- for(i = 0; i < p_FmPcdCcNode->numOfKeys; i++)
+ for (i = 0; i < p_CcNode->numOfKeys; i++)
{
- if(p_FmPcdCcNode->nextEngineAndRequiredAction[i].nextEngineParams.h_Manip)
+ if (p_CcNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip)
{
- err = FmPcdManipCheckParamsWithCcNodeParams(p_FmPcdCcNode->nextEngineAndRequiredAction[i].nextEngineParams.h_Manip, (t_Handle)p_FmPcdCcNode);
- if(err)
+ err =
+ FmPcdManipCheckParamsWithCcNodeParams(
+ p_CcNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip,
+ (t_Handle)p_CcNode);
+ if (err)
return err;
}
}
return err;
}
-#endif /* FM_PCD_CC_MANIP */
-
-static t_Error CcUpdateParams(t_Handle h_FmPcd,
- t_Handle h_FmPort,
- t_Handle h_FmTree,
- bool validate)
+static t_Error ValidateAndCalcStatsParams(t_FmPcdCcNode *p_CcNode,
+ t_FmPcdCcNodeParams *p_CcNodeParam,
+ uint32_t *p_NumOfRanges,
+ uint32_t *p_CountersArraySize)
{
- t_FmPcdCcTree *p_CcTree = (t_FmPcdCcTree *) h_FmTree;
+ e_FmPcdCcStatsMode statisticsMode = p_CcNode->statisticsMode;
+ uint32_t i;
- return CcUpdateParam(h_FmPcd,
- h_FmPort,
- p_CcTree->nextEngineAndRequiredAction,
- p_CcTree->numOfEntries,
- UINT_TO_PTR(p_CcTree->ccTreeBaseAddr),
- validate,
- 0,
- h_FmTree,
- FALSE);
+ UNUSED(p_CcNodeParam);
+
+ switch (statisticsMode)
+ {
+ case e_FM_PCD_CC_STATS_MODE_NONE:
+ for (i = 0; i < p_CcNode->numOfKeys; i++)
+ if (p_CcNodeParam->keysParams.keyParams[i].ccNextEngineParams.statisticsEn)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("Statistics cannot be enabled for key %d when statistics mode was set to 'NONE'", i));
+ return E_OK;
+
+ case e_FM_PCD_CC_STATS_MODE_FRAME:
+ case e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME:
+ *p_NumOfRanges = 1;
+ *p_CountersArraySize = 2 * FM_PCD_CC_STATS_COUNTER_SIZE;
+ return E_OK;
+
+#if (DPAA_VERSION >= 11)
+ case e_FM_PCD_CC_STATS_MODE_RMON:
+ {
+ uint16_t *p_FrameLengthRanges =
+ p_CcNodeParam->keysParams.frameLengthRanges;
+ uint32_t i;
+
+ if (p_FrameLengthRanges[0] <= 0)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Statistics mode"));
+
+ if (p_FrameLengthRanges[0] == 0xFFFF)
+ {
+ *p_NumOfRanges = 1;
+ *p_CountersArraySize = 2 * FM_PCD_CC_STATS_COUNTER_SIZE;
+ return E_OK;
+ }
+
+ for (i = 1; i < FM_PCD_CC_STATS_MAX_NUM_OF_FLR; i++)
+ {
+ if (p_FrameLengthRanges[i - 1] >= p_FrameLengthRanges[i])
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("Frame length range must be larger at least by 1 from preceding range"));
+
+ /* Stop when last range is reached */
+ if (p_FrameLengthRanges[i] == 0xFFFF)
+ break;
+ }
+
+ if ((i >= FM_PCD_CC_STATS_MAX_NUM_OF_FLR)
+ || (p_FrameLengthRanges[i] != 0xFFFF))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("Last Frame length range must be 0xFFFF"));
+
+ *p_NumOfRanges = i + 1;
+
+ /* Allocate an extra counter for byte count, as counters
+ array always begins with byte count */
+ *p_CountersArraySize = (*p_NumOfRanges + 1)
+ * FM_PCD_CC_STATS_COUNTER_SIZE;
+
+ }
+ return E_OK;
+#endif /* (DPAA_VERSION >= 11) */
+
+ default:
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Statistics mode"));
+ }
}
-static t_Error CheckParams(t_Handle h_FmPcd,
- t_FmPcdCcNodeParams *p_CcNodeParam,
- t_FmPcdCcNode *p_FmPcdCcNode,
- bool *isKeyTblAlloc)
+static t_Error CheckParams(t_Handle h_FmPcd, t_FmPcdCcNodeParams *p_CcNodeParam,
+ t_FmPcdCcNode *p_CcNode, bool *isKeyTblAlloc)
{
- int tmp = 0;
- t_FmPcdCcKeyParams *p_KeyParams;
- t_Error err;
- uint32_t requiredAction = 0;
+ int tmp = 0;
+ t_FmPcdCcKeyParams *p_KeyParams;
+ t_Error err;
+ uint32_t requiredAction = 0;
+
+ /* Validate statistics parameters */
+ err = ValidateAndCalcStatsParams(p_CcNode, p_CcNodeParam,
+ &(p_CcNode->numOfStatsFLRs),
+ &(p_CcNode->countersArraySize));
+ if (err)
+ RETURN_ERROR(MAJOR, err, ("Invalid statistics parameters"));
+
+ /* Validate next engine parameters on Miss */
+ err = ValidateNextEngineParams(
+ h_FmPcd, &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,
+ p_CcNode->statisticsMode);
+ if (err)
+ RETURN_ERROR(MAJOR, err,
+ ("For this node MissNextEngineParams are not valid"));
+
+ if (p_CcNodeParam->keysParams.ccNextEngineParamsForMiss.h_Manip)
+ {
+ err = FmPcdManipCheckParamsForCcNextEngine(
+ &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,
+ &requiredAction);
+ if (err)
+ RETURN_ERROR(MAJOR, err, (NO_MSG));
+ }
- err = ValidateNextEngineParams(h_FmPcd, &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss);
- if(err)
- RETURN_ERROR(MAJOR, err, ("For this node MissNextEngineParams are not valid"));
+ memcpy(&p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams,
+ &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,
+ sizeof(t_FmPcdCcNextEngineParams));
-#ifdef FM_PCD_CC_MANIP
- if(p_CcNodeParam->keysParams.ccNextEngineParamsForMiss.h_Manip)
+ p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].requiredAction =
+ requiredAction;
+
+ if ((p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
+ && p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.h_Manip)
{
- err = FmPcdManipCheckParamsForCcNextEgine(&p_CcNodeParam->keysParams.ccNextEngineParamsForMiss, &requiredAction);
- if(err)
+ err =
+ AllocAndFillAdForContLookupManip(
+ p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.params.ccParams.h_CcNode);
+ if (err)
RETURN_ERROR(MAJOR, err, (NO_MSG));
}
-#endif /* FM_PCD_CC_MANIP */
-
- memcpy(&p_FmPcdCcNode->nextEngineAndRequiredAction[p_FmPcdCcNode->numOfKeys].nextEngineParams,&p_CcNodeParam->keysParams.ccNextEngineParamsForMiss, sizeof(t_FmPcdCcNextEngineParams));
- p_FmPcdCcNode->nextEngineAndRequiredAction[p_FmPcdCcNode->numOfKeys].requiredAction = requiredAction;
- for(tmp = 0 ; tmp < p_FmPcdCcNode->numOfKeys; tmp++)
+ for (tmp = 0; tmp < p_CcNode->numOfKeys; tmp++)
{
p_KeyParams = &p_CcNodeParam->keysParams.keyParams[tmp];
- if(!p_KeyParams->p_Key)
+ if (!p_KeyParams->p_Key)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("p_Key is not initialized"));
-
- err = ValidateNextEngineParams(h_FmPcd, &p_KeyParams->ccNextEngineParams);
- if(err)
+ err = ValidateNextEngineParams(h_FmPcd,
+ &p_KeyParams->ccNextEngineParams,
+ p_CcNode->statisticsMode);
+ if (err)
RETURN_ERROR(MAJOR, err, (NO_MSG));
- err = UpdateGblMask(p_FmPcdCcNode,
- p_CcNodeParam->keysParams.keySize,
+ err = UpdateGblMask(p_CcNode, p_CcNodeParam->keysParams.keySize,
p_KeyParams->p_Mask);
+ if (err)
+ RETURN_ERROR(MAJOR, err, (NO_MSG));
+
+ if (p_KeyParams->ccNextEngineParams.h_Manip)
+ {
+ err = FmPcdManipCheckParamsForCcNextEngine(
+ &p_KeyParams->ccNextEngineParams, &requiredAction);
+ if (err)
+ RETURN_ERROR(MAJOR, err, (NO_MSG));
+ }
+
+ /* Store 'key' parameters - key, mask (if passed by the user) */
+ memcpy(p_CcNode->keyAndNextEngineParams[tmp].key, p_KeyParams->p_Key,
+ p_CcNodeParam->keysParams.keySize);
+
+ if (p_KeyParams->p_Mask)
+ memcpy(p_CcNode->keyAndNextEngineParams[tmp].mask,
+ p_KeyParams->p_Mask, p_CcNodeParam->keysParams.keySize);
+ else
+ memset((void *)(p_CcNode->keyAndNextEngineParams[tmp].mask), 0xFF,
+ p_CcNodeParam->keysParams.keySize);
+
+ /* Store next engine parameters */
+ memcpy(&p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams,
+ &p_KeyParams->ccNextEngineParams,
+ sizeof(t_FmPcdCcNextEngineParams));
-#ifdef FM_PCD_CC_MANIP
- if(p_KeyParams->ccNextEngineParams.h_Manip)
+ p_CcNode->keyAndNextEngineParams[tmp].requiredAction = requiredAction;
+
+ if ((p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
+ && p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.h_Manip)
{
- err = FmPcdManipCheckParamsForCcNextEgine(&p_KeyParams->ccNextEngineParams, &requiredAction);
- if(err)
+ err =
+ AllocAndFillAdForContLookupManip(
+ p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.params.ccParams.h_CcNode);
+ if (err)
RETURN_ERROR(MAJOR, err, (NO_MSG));
}
-#endif /* FM_PCD_CC_MANIP */
+ }
- memcpy(&p_FmPcdCcNode->nextEngineAndRequiredAction[tmp],&p_KeyParams->ccNextEngineParams, sizeof(t_FmPcdCcNextEngineParams));
- p_FmPcdCcNode->nextEngineAndRequiredAction[tmp].requiredAction = requiredAction;
+ if (p_CcNode->maxNumOfKeys)
+ {
+ if (p_CcNode->maxNumOfKeys < p_CcNode->numOfKeys)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("Number of keys exceed the provided maximal number of keys"));
}
*isKeyTblAlloc = TRUE;
+
return E_OK;
}
-static t_Error Ipv4TtlOrIpv6HopLimiCheckParams( t_Handle h_FmPcd,
- t_FmPcdCcNodeParams *p_CcNodeParam, t_FmPcdCcNode *p_FmPcdCcNode,
- bool *isKeyTblAlloc)
+static t_Error Ipv4TtlOrIpv6HopLimitCheckParams(
+ t_Handle h_FmPcd, t_FmPcdCcNodeParams *p_CcNodeParam,
+ t_FmPcdCcNode *p_CcNode, bool *isKeyTblAlloc)
{
- int tmp = 0;
- t_FmPcdCcKeyParams *p_KeyParams;
- t_Error err;
- uint8_t key = 0x01;
- uint32_t requiredAction = 0;
+ int tmp = 0;
+ t_FmPcdCcKeyParams *p_KeyParams;
+ t_Error err;
+ uint8_t key = 0x01;
+ uint32_t requiredAction = 0;
+
+ if (p_CcNode->numOfKeys != 1)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("For node of the type IPV4_TTL or IPV6_HOP_LIMIT the maximal supported 'numOfKeys' is 1"));
+
+ if ((p_CcNodeParam->keysParams.maxNumOfKeys)
+ && (p_CcNodeParam->keysParams.maxNumOfKeys != 1))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("For node of the type IPV4_TTL or IPV6_HOP_LIMIT the maximal supported 'maxNumOfKeys' is 1"));
+
+ /* Validate statistics parameters */
+ err = ValidateAndCalcStatsParams(p_CcNode, p_CcNodeParam,
+ &(p_CcNode->numOfStatsFLRs),
+ &(p_CcNode->countersArraySize));
+ if (err)
+ RETURN_ERROR(MAJOR, err, ("Invalid statistics parameters"));
+
+ err = ValidateNextEngineParams(
+ h_FmPcd, &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,
+ p_CcNodeParam->keysParams.statisticsMode);
+ if (err)
+ RETURN_ERROR(MAJOR, err,
+ ("For this node MissNextEngineParams are not valid"));
+
+ if (p_CcNodeParam->keysParams.ccNextEngineParamsForMiss.h_Manip)
+ {
+ err = FmPcdManipCheckParamsForCcNextEngine(
+ &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,
+ &requiredAction);
+ if (err)
+ RETURN_ERROR(MAJOR, err, (NO_MSG));
+ }
- if(p_FmPcdCcNode->numOfKeys != 1 )
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("for IPV4TTL and IPV6_HOP_LIMIT has to be only 1 key - TTL = 1, otherwise it's Miss"));
+ memcpy(&p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams,
+ &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,
+ sizeof(t_FmPcdCcNextEngineParams));
- err = ValidateNextEngineParams(h_FmPcd, &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss);
- if(err)
- RETURN_ERROR(MAJOR, err, ("For this node MissNextEngineParams are not valid"));
+ p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].requiredAction =
+ requiredAction;
-#ifdef FM_PCD_CC_MANIP
- if(p_CcNodeParam->keysParams.ccNextEngineParamsForMiss.h_Manip)
+ if ((p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
+ && p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.h_Manip)
{
- err = FmPcdManipCheckParamsForCcNextEgine(&p_CcNodeParam->keysParams.ccNextEngineParamsForMiss, &requiredAction);
- if(err)
+ err =
+ AllocAndFillAdForContLookupManip(
+ p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.params.ccParams.h_CcNode);
+ if (err)
RETURN_ERROR(MAJOR, err, (NO_MSG));
}
-#endif /* FM_PCD_CC_MANIP */
-
- memcpy(&p_FmPcdCcNode->nextEngineAndRequiredAction[p_FmPcdCcNode->numOfKeys].nextEngineParams, &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss, sizeof(t_FmPcdCcNextEngineParams));
- p_FmPcdCcNode->nextEngineAndRequiredAction[p_FmPcdCcNode->numOfKeys].requiredAction = requiredAction;
- for(tmp = 0 ; tmp < p_FmPcdCcNode->numOfKeys; tmp++)
+ for (tmp = 0; tmp < p_CcNode->numOfKeys; tmp++)
{
p_KeyParams = &p_CcNodeParam->keysParams.keyParams[tmp];
- if(p_KeyParams->p_Mask)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("If node of the type IPV4_TTL or IPV6_HOP_LIMIT p_Mask can not be initialized"));
- if(memcmp(p_KeyParams->p_Key, &key, 1) != 0)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("If node of the type IPV4_TTL or IPV6_HOP_LIMIT p_Key has to be 1"));
- err = ValidateNextEngineParams(h_FmPcd, &p_KeyParams->ccNextEngineParams);
- if(err)
- RETURN_ERROR(MAJOR, err, (NO_MSG));
-#ifdef FM_PCD_CC_MANIP
- if(p_KeyParams->ccNextEngineParams.h_Manip)
- {
- err = FmPcdManipCheckParamsForCcNextEgine(&p_KeyParams->ccNextEngineParams, &requiredAction);
- if(err)
+ if (p_KeyParams->p_Mask)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("For node of the type IPV4_TTL or IPV6_HOP_LIMIT p_Mask can not be initialized"));
+
+ if (memcmp(p_KeyParams->p_Key, &key, 1) != 0)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("For node of the type IPV4_TTL or IPV6_HOP_LIMIT p_Key has to be 1"));
+
+ err = ValidateNextEngineParams(h_FmPcd,
+ &p_KeyParams->ccNextEngineParams,
+ p_CcNode->statisticsMode);
+ if (err)
RETURN_ERROR(MAJOR, err, (NO_MSG));
- }
-#endif /* FM_PCD_CC_MANIP */
- memcpy(&p_FmPcdCcNode->nextEngineAndRequiredAction[tmp].nextEngineParams, &p_KeyParams->ccNextEngineParams, sizeof(t_FmPcdCcNextEngineParams));
- p_FmPcdCcNode->nextEngineAndRequiredAction[tmp].requiredAction = requiredAction;
+ if (p_KeyParams->ccNextEngineParams.h_Manip)
+ {
+ err = FmPcdManipCheckParamsForCcNextEngine(
+ &p_KeyParams->ccNextEngineParams, &requiredAction);
+ if (err)
+ RETURN_ERROR(MAJOR, err, (NO_MSG));
+ }
+
+ /* Store 'key' parameters - key (fixed to 0x01), key size of 1 byte and full mask */
+ p_CcNode->keyAndNextEngineParams[tmp].key[0] = key;
+ p_CcNode->keyAndNextEngineParams[tmp].mask[0] = 0xFF;
+
+ /* Store NextEngine parameters */
+ memcpy(&p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams,
+ &p_KeyParams->ccNextEngineParams,
+ sizeof(t_FmPcdCcNextEngineParams));
+
+ if ((p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
+ && p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.h_Manip)
+ {
+ err =
+ AllocAndFillAdForContLookupManip(
+ p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.params.ccParams.h_CcNode);
+ if (err)
+ RETURN_ERROR(MAJOR, err, (NO_MSG));
+ }
+ p_CcNode->keyAndNextEngineParams[tmp].requiredAction = requiredAction;
}
*isKeyTblAlloc = FALSE;
+
return E_OK;
}
static t_Error IcHashIndexedCheckParams(t_Handle h_FmPcd,
- t_FmPcdCcNodeParams *p_CcNodeParam,
- t_FmPcdCcNode *p_FmPcdCcNode,
- /*uint16_t *ccInfo,*/
- /*t_List *ccNextDifferentNodesLst,*/
- bool *isKeyTblAlloc)
-{
- int tmp = 0, countOnes = 0;
- t_FmPcdCcKeyParams *p_KeyParams;
- t_Error err;
- uint16_t glblMask = p_CcNodeParam->extractCcParams.extractNonHdr.icIndxMask;
- uint16_t countMask = (uint16_t)(glblMask >> 4);
-#ifdef FM_PCD_CC_MANIP
- uint32_t requiredAction;
-#endif /* FM_PCD_CC_MANIP */
+ t_FmPcdCcNodeParams *p_CcNodeParam,
+ t_FmPcdCcNode *p_CcNode,
+ bool *isKeyTblAlloc)
+{
+ int tmp = 0, countOnes = 0;
+ t_FmPcdCcKeyParams *p_KeyParams;
+ t_Error err;
+ uint16_t glblMask = p_CcNodeParam->extractCcParams.extractNonHdr.icIndxMask;
+ uint16_t countMask = (uint16_t)(glblMask >> 4);
+ uint32_t requiredAction = 0;
if (glblMask & 0x000f)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("icIndxMask has to be with last nibble 0"));
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("icIndxMask has to be with last nibble 0"));
while (countMask)
{
countOnes++;
- countMask=(uint16_t)(countMask>>1);
+ countMask = (uint16_t)(countMask >> 1);
}
- if (!POWER_OF_2(p_FmPcdCcNode->numOfKeys))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("For Node of the type INDEXED numOfKeys has to be powerOfTwo"));
- if (p_FmPcdCcNode->numOfKeys != ((uint32_t)1<<countOnes ))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("For Node of the type IC_HASH_INDEXED numOfKeys has to be powerOfTwo"));
-
- err = ValidateNextEngineParams(h_FmPcd, &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss);
- if(GET_ERROR_TYPE(err)!= E_NOT_SUPPORTED)
- RETURN_ERROR(MAJOR, err, ("MissNextEngineParams for the node of the type IC_INDEX_HASH has to be UnInitialized"));
-
- for(tmp = 0 ; tmp < p_FmPcdCcNode->numOfKeys; tmp++)
+ if (!POWER_OF_2(p_CcNode->numOfKeys))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("For Node of the type INDEXED numOfKeys has to be powerOfTwo"));
+
+ if (p_CcNode->numOfKeys != ((uint32_t)1 << countOnes))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("For Node of the type IC_HASH_INDEXED numOfKeys has to be powerOfTwo"));
+
+ if (p_CcNodeParam->keysParams.maxNumOfKeys
+ && (p_CcNodeParam->keysParams.maxNumOfKeys != p_CcNode->numOfKeys))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("For Node of the type INDEXED 'maxNumOfKeys' should be 0 or equal 'numOfKeys'"));
+
+ /* Validate statistics parameters */
+ err = ValidateAndCalcStatsParams(p_CcNode, p_CcNodeParam,
+ &(p_CcNode->numOfStatsFLRs),
+ &(p_CcNode->countersArraySize));
+ if (err)
+ RETURN_ERROR(MAJOR, err, ("Invalid statistics parameters"));
+
+ err = ValidateNextEngineParams(
+ h_FmPcd, &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,
+ p_CcNode->statisticsMode);
+ if (GET_ERROR_TYPE(err) != E_NOT_SUPPORTED)
+ RETURN_ERROR(
+ MAJOR,
+ err,
+ ("MissNextEngineParams for the node of the type IC_INDEX_HASH has to be UnInitialized"));
+
+ for (tmp = 0; tmp < p_CcNode->numOfKeys; tmp++)
{
p_KeyParams = &p_CcNodeParam->keysParams.keyParams[tmp];
- if(p_KeyParams->p_Mask || p_KeyParams->p_Key)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("For Node of the type IC_HASH_INDEXED p_Key or p_Mask has to be NULL"));
- if((glblMask & (tmp * 16)) == (tmp * 16))
- {
- err = ValidateNextEngineParams(h_FmPcd, &p_KeyParams->ccNextEngineParams);
- if(err)
- RETURN_ERROR(MAJOR, err, ("This index has to be initialized for the node of the type IC_INDEX_HASH according to settings of GlobalMask "));
+ if (p_KeyParams->p_Mask || p_KeyParams->p_Key)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("For Node of the type IC_HASH_INDEXED p_Key or p_Mask has to be NULL"));
-#ifdef FM_PCD_CC_MANIP
- if(p_KeyParams->ccNextEngineParams.h_Manip)
+ if ((glblMask & (tmp * 16)) == (tmp * 16))
+ {
+ err = ValidateNextEngineParams(h_FmPcd,
+ &p_KeyParams->ccNextEngineParams,
+ p_CcNode->statisticsMode);
+ if (err)
+ RETURN_ERROR(
+ MAJOR,
+ err,
+ ("This index has to be initialized for the node of the type IC_INDEX_HASH according to settings of GlobalMask "));
+
+ if (p_KeyParams->ccNextEngineParams.h_Manip)
{
- err = FmPcdManipCheckParamsForCcNextEgine(&p_KeyParams->ccNextEngineParams, &requiredAction);
- if(err)
+ err = FmPcdManipCheckParamsForCcNextEngine(
+ &p_KeyParams->ccNextEngineParams, &requiredAction);
+ if (err)
RETURN_ERROR(MAJOR, err, (NO_MSG));
+ p_CcNode->keyAndNextEngineParams[tmp].requiredAction =
+ requiredAction;
}
- p_FmPcdCcNode->nextEngineAndRequiredAction[tmp].requiredAction = requiredAction;
-#endif /* FM_PCD_CC_MANIP */
- memcpy(&p_FmPcdCcNode->nextEngineAndRequiredAction[tmp].nextEngineParams,&p_KeyParams->ccNextEngineParams, sizeof(t_FmPcdCcNextEngineParams));
+ memcpy(&p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams,
+ &p_KeyParams->ccNextEngineParams,
+ sizeof(t_FmPcdCcNextEngineParams));
+
+ if ((p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
+ && p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.h_Manip)
+ {
+ err =
+ AllocAndFillAdForContLookupManip(
+ p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.params.ccParams.h_CcNode);
+ if (err)
+ RETURN_ERROR(MAJOR, err, (NO_MSG));
+ }
}
else
{
- err = ValidateNextEngineParams(h_FmPcd, &p_KeyParams->ccNextEngineParams);
- if(GET_ERROR_TYPE(err)!= E_NOT_SUPPORTED)
- RETURN_ERROR(MAJOR, err, ("This index has to be UnInitialized for the node of the type IC_INDEX_HASH according to settings of GlobalMask"));
+ err = ValidateNextEngineParams(h_FmPcd,
+ &p_KeyParams->ccNextEngineParams,
+ p_CcNode->statisticsMode);
+ if (GET_ERROR_TYPE(err) != E_NOT_SUPPORTED)
+ RETURN_ERROR(
+ MAJOR,
+ err,
+ ("This index has to be UnInitialized for the node of the type IC_INDEX_HASH according to settings of GlobalMask"));
}
}
+
*isKeyTblAlloc = FALSE;
- memcpy(PTR_MOVE(p_FmPcdCcNode->p_GlblMask, 2), &glblMask, 2);
+ glblMask = htobe16(glblMask);
+ memcpy(PTR_MOVE(p_CcNode->p_GlblMask, 2), &glblMask, 2);
return E_OK;
}
-t_Error FmPcdCcModifyNextEngineParamTree(t_Handle h_FmPcd, t_Handle h_FmPcdCcTree, uint8_t grpId, uint8_t index, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams, t_List *h_OldLst, t_List *h_NewLst, t_Handle *h_AdditionalParams)
+static t_Error ModifyNextEngineParamNode(
+ t_Handle h_FmPcd, t_Handle h_FmPcdCcNode, uint16_t keyIndex,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
{
- t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;
- t_Error err = E_OK;
- uint16_t keyIndex;
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
+ t_FmPcd *p_FmPcd;
+ t_List h_OldPointersLst, h_NewPointersLst;
t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;
+ t_Error err = E_OK;
- SANITY_CHECK_RETURN_ERROR((grpId <= 7),E_INVALID_VALUE);
- SANITY_CHECK_RETURN_ERROR(h_FmPcdCcTree,E_INVALID_VALUE);
+ SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_VALUE);
+ SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
- if(grpId >= p_FmPcdCcTree->numOfGrps)
- RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("grpId you asked > numOfGroup of relevant tree"));
+ if (keyIndex >= p_CcNode->numOfKeys)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("keyIndex > previously cleared last index + 1"));
- if(index >= p_FmPcdCcTree->fmPcdGroupParam[grpId].numOfEntriesInGroup)
- RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("index > numOfEntriesInGroup"));
+ p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
- keyIndex = (uint16_t)(p_FmPcdCcTree->fmPcdGroupParam[grpId].baseGroupEntry + index);
+ INIT_LIST(&h_OldPointersLst);
+ INIT_LIST(&h_NewPointersLst);
- err = ModifyKeyCommonPart1(h_FmPcdCcTree, keyIndex, h_AdditionalParams, e_MODIFY_STATE_CHANGE, TRUE, TRUE);
- if(err)
+ p_ModifyKeyParams = ModifyNodeCommonPart(p_CcNode, keyIndex,
+ e_MODIFY_STATE_CHANGE, FALSE,
+ FALSE, FALSE);
+ if (!p_ModifyKeyParams)
RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
- p_ModifyKeyParams = (t_FmPcdModifyCcKeyAdditionalParams *)*h_AdditionalParams;
- p_ModifyKeyParams->tree = TRUE;
+ if (p_CcNode->maxNumOfKeys
+ && !TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))
+ {
+ XX_Free(p_ModifyKeyParams);
+ return ERROR_CODE(E_BUSY);
+ }
- err = BuildNewNodeModifyNextEngine (h_FmPcd, h_FmPcdCcTree, keyIndex,p_FmPcdCcNextEngineParams, h_OldLst, h_NewLst, p_ModifyKeyParams);
- if(err)
+ err = BuildNewNodeModifyNextEngine(h_FmPcd, p_CcNode, keyIndex,
+ p_FmPcdCcNextEngineParams,
+ &h_OldPointersLst, &h_NewPointersLst,
+ p_ModifyKeyParams);
+ if (err)
{
XX_Free(p_ModifyKeyParams);
+ if (p_CcNode->maxNumOfKeys)
+ RELEASE_LOCK(p_FmPcd->shadowLock);
RETURN_ERROR(MAJOR, err, NO_MSG);
}
+
+ err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,
+ p_ModifyKeyParams, FALSE);
+
+ if (p_CcNode->maxNumOfKeys)
+ RELEASE_LOCK(p_FmPcd->shadowLock);
+
+ return err;
+}
+
+static t_Error FindKeyIndex(t_Handle h_CcNode, uint8_t keySize, uint8_t *p_Key,
+ uint8_t *p_Mask, uint16_t *p_KeyIndex)
+{
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+ uint8_t tmpMask[FM_PCD_MAX_SIZE_OF_KEY];
+ uint16_t i;
+
+ ASSERT_COND(p_Key);
+ ASSERT_COND(p_KeyIndex);
+ ASSERT_COND(keySize < FM_PCD_MAX_SIZE_OF_KEY);
+
+ if (keySize != p_CcNode->userSizeOfExtraction)
+ RETURN_ERROR(
+ MINOR, E_INVALID_VALUE,
+ ("Key size doesn't match the extraction size of the node"));
+
+ /* If user didn't pass a mask for this key, we'll look for full extraction mask */
+ if (!p_Mask)
+ memset(tmpMask, 0xFF, keySize);
+
+ for (i = 0; i < p_CcNode->numOfKeys; i++)
+ {
+ /* Comparing received key */
+ if (memcmp(p_Key, p_CcNode->keyAndNextEngineParams[i].key, keySize)
+ == 0)
+ {
+ if (p_Mask)
+ {
+ /* If a user passed a mask for this key, it must match to the existing key's mask for a correct match */
+ if (memcmp(p_Mask, p_CcNode->keyAndNextEngineParams[i].mask,
+ keySize) == 0)
+ {
+ *p_KeyIndex = i;
+ return E_OK;
+ }
+ }
+ else
+ {
+ /* If user didn't pass a mask for this key, check if the existing key mask is full extraction */
+ if (memcmp(tmpMask, p_CcNode->keyAndNextEngineParams[i].mask,
+ keySize) == 0)
+ {
+ *p_KeyIndex = i;
+ return E_OK;
+ }
+ }
+ }
+ }
+
+ return ERROR_CODE(E_NOT_FOUND);
+}
+
+static t_Error CalcAndUpdateCcShadow(t_FmPcdCcNode *p_CcNode,
+ bool isKeyTblAlloc,
+ uint32_t *p_MatchTableSize,
+ uint32_t *p_AdTableSize)
+{
+ uint32_t shadowSize;
+ t_Error err;
+
+ /* Calculate keys table maximal size - each entry consists of a key and a mask,
+ (if local mask support is requested) */
+ *p_MatchTableSize = p_CcNode->ccKeySizeAccExtraction * sizeof(uint8_t)
+ * p_CcNode->maxNumOfKeys;
+
+ if (p_CcNode->maskSupport)
+ *p_MatchTableSize *= 2;
+
+ /* Calculate next action descriptors table, including one more entry for miss */
+ *p_AdTableSize = (uint32_t)((p_CcNode->maxNumOfKeys + 1)
+ * FM_PCD_CC_AD_ENTRY_SIZE);
+
+ /* Calculate maximal shadow size of this node.
+ All shadow structures will be used for runtime modifications host command. If
+ keys table was allocated for this node, the keys table and next engines table may
+ be modified in run time (entries added or removed), so shadow tables are requires.
+ Otherwise, the only supported runtime modification is a specific next engine update
+ and this requires shadow memory of a single AD */
+
+ /* Shadow size should be enough to hold the following 3 structures:
+ * 1 - an action descriptor */
+ shadowSize = FM_PCD_CC_AD_ENTRY_SIZE;
+
+ /* 2 - keys match table, if was allocated for the current node */
+ if (isKeyTblAlloc)
+ shadowSize += *p_MatchTableSize;
+
+ /* 3 - next action descriptors table */
+ shadowSize += *p_AdTableSize;
+
+ /* Update shadow to the calculated size */
+ err = FmPcdUpdateCcShadow(p_CcNode->h_FmPcd, (uint32_t)shadowSize,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if (err != E_OK)
+ {
+ DeleteNode(p_CcNode);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for CC node shadow"));
+ }
+
return E_OK;
+}
+
+static t_Error AllocStatsObjs(t_FmPcdCcNode *p_CcNode)
+{
+ t_FmPcdStatsObj *p_StatsObj;
+ t_Handle h_FmMuram, h_StatsAd, h_StatsCounters;
+ uint32_t i;
+
+ h_FmMuram = FmPcdGetMuramHandle(p_CcNode->h_FmPcd);
+ if (!h_FmMuram)
+ RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("FM MURAM"));
+
+ /* Allocate statistics ADs and statistics counter. An extra pair (AD + counters)
+ will be allocated to support runtime modifications */
+ for (i = 0; i < p_CcNode->maxNumOfKeys + 2; i++)
+ {
+ /* Allocate list object structure */
+ p_StatsObj = XX_Malloc(sizeof(t_FmPcdStatsObj));
+ if (!p_StatsObj)
+ {
+ FreeStatObjects(&p_CcNode->availableStatsLst, h_FmMuram);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Statistics object"));
+ }
+ memset(p_StatsObj, 0, sizeof(t_FmPcdStatsObj));
+
+ /* Allocate statistics AD from MURAM */
+ h_StatsAd = (t_Handle)FM_MURAM_AllocMem(h_FmMuram,
+ FM_PCD_CC_AD_ENTRY_SIZE,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if (!h_StatsAd)
+ {
+ FreeStatObjects(&p_CcNode->availableStatsLst, h_FmMuram);
+ XX_Free(p_StatsObj);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("MURAM allocation for statistics ADs"));
+ }
+ MemSet8(h_StatsAd, 0, FM_PCD_CC_AD_ENTRY_SIZE);
+
+ /* Allocate statistics counters from MURAM */
+ h_StatsCounters = (t_Handle)FM_MURAM_AllocMem(
+ h_FmMuram, p_CcNode->countersArraySize,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if (!h_StatsCounters)
+ {
+ FreeStatObjects(&p_CcNode->availableStatsLst, h_FmMuram);
+ FM_MURAM_FreeMem(h_FmMuram, h_StatsAd);
+ XX_Free(p_StatsObj);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("MURAM allocation for statistics counters"));
+ }
+ MemSet8(h_StatsCounters, 0, p_CcNode->countersArraySize);
+ p_StatsObj->h_StatsAd = h_StatsAd;
+ p_StatsObj->h_StatsCounters = h_StatsCounters;
+
+ EnqueueStatsObj(&p_CcNode->availableStatsLst, p_StatsObj);
+ }
+
+ return E_OK;
}
-t_Error FmPcdCcRemoveKey(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode, uint8_t keyIndex, t_List *h_OldLst, t_List *h_NewLst, t_Handle *h_AdditionalParams)
+static t_Error MatchTableGetKeyStatistics(
+ t_FmPcdCcNode *p_CcNode, uint16_t keyIndex,
+ t_FmPcdCcKeyStatistics *p_KeyStatistics)
{
+ uint32_t *p_StatsCounters, i;
- t_FmPcdCcNode *p_FmPcdCcNode = (t_FmPcdCcNode *) h_FmPcdCcNode;
- t_Error err = E_OK;
- t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;
+ if (p_CcNode->statisticsMode == e_FM_PCD_CC_STATS_MODE_NONE)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("Statistics were not enabled for this match table"));
- if(keyIndex >= p_FmPcdCcNode->numOfKeys)
- RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("impossible to remove key when numOfKeys <= keyIndex"));
+ if (!p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("Statistics were not enabled for this key"));
- if(!p_FmPcdCcNode->numOfKeys)
- RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("keyIndex you asked > numOfKeys of relevant node that was initialized"));
+ memset(p_KeyStatistics, 0, sizeof(t_FmPcdCcKeyStatistics));
- if(p_FmPcdCcNode->h_FmPcd != h_FmPcd)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("handler to FmPcd is diferent from one which was assigned to the node in the Init time"));
+ p_StatsCounters =
+ p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj->h_StatsCounters;
+ ASSERT_COND(p_StatsCounters);
- err = ModifyKeyCommonPart1(p_FmPcdCcNode, keyIndex, h_AdditionalParams, e_MODIFY_STATE_REMOVE, TRUE, FALSE);
- if(err)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
+ p_KeyStatistics->byteCount = GET_UINT32(*p_StatsCounters);
- p_ModifyKeyParams = (t_FmPcdModifyCcKeyAdditionalParams *)*h_AdditionalParams;
- err = BuildNewNodeRemoveKey (p_FmPcdCcNode, keyIndex, p_ModifyKeyParams);
- if(err)
+ for (i = 1; i <= p_CcNode->numOfStatsFLRs; i++)
{
- XX_Free(p_ModifyKeyParams);
- RETURN_ERROR(MAJOR, err, NO_MSG);
+ p_StatsCounters =
+ PTR_MOVE(p_StatsCounters, FM_PCD_CC_STATS_COUNTER_SIZE);
+
+ p_KeyStatistics->frameCount += GET_UINT32(*p_StatsCounters);
+
+#if (DPAA_VERSION >= 11)
+ p_KeyStatistics->frameLengthRangeCount[i - 1] =
+ GET_UINT32(*p_StatsCounters);
+#endif /* (DPAA_VERSION >= 11) */
+ }
+
+ return E_OK;
+}
+
+static t_Error MatchTableSet(t_Handle h_FmPcd, t_FmPcdCcNode *p_CcNode,
+ t_FmPcdCcNodeParams *p_CcNodeParam)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ t_FmPcdCcNode *p_FmPcdCcNextNode;
+ t_Error err = E_OK;
+ uint32_t tmp, keySize;
+ bool glblMask = FALSE;
+ t_FmPcdCcKeyParams *p_KeyParams;
+ t_Handle h_FmMuram, p_KeysMatchTblTmp, p_AdTableTmp;
+#if (DPAA_VERSION >= 11)
+ t_Handle h_StatsFLRs;
+#endif /* (DPAA_VERSION >= 11) */
+ bool fullField = FALSE;
+ ccPrivateInfo_t icCode = CC_PRIVATE_INFO_NONE;
+ bool isKeyTblAlloc, fromIc = FALSE;
+ uint32_t matchTableSize, adTableSize;
+ t_CcNodeInformation ccNodeInfo, *p_CcInformation;
+ t_FmPcdStatsObj *p_StatsObj;
+ t_FmPcdCcStatsParams statsParams = { 0 };
+ t_Handle h_Manip;
+
+ ASSERT_COND(h_FmPcd);
+ ASSERT_COND(p_CcNode);
+ ASSERT_COND(p_CcNodeParam);
+
+ p_CcNode->p_GlblMask = (t_Handle)XX_Malloc(
+ CC_GLBL_MASK_SIZE * sizeof(uint8_t));
+ memset(p_CcNode->p_GlblMask, 0, CC_GLBL_MASK_SIZE * sizeof(uint8_t));
+
+ p_CcNode->h_FmPcd = h_FmPcd;
+ p_CcNode->numOfKeys = p_CcNodeParam->keysParams.numOfKeys;
+ p_CcNode->maxNumOfKeys = p_CcNodeParam->keysParams.maxNumOfKeys;
+ p_CcNode->maskSupport = p_CcNodeParam->keysParams.maskSupport;
+ p_CcNode->statisticsMode = p_CcNodeParam->keysParams.statisticsMode;
+
+ /* For backward compatibility - even if statistics mode is nullified,
+ we'll fix it to frame mode so we can support per-key request for
+ statistics using 'statisticsEn' in next engine parameters */
+ if (!p_CcNode->maxNumOfKeys
+ && (p_CcNode->statisticsMode == e_FM_PCD_CC_STATS_MODE_NONE))
+ p_CcNode->statisticsMode = e_FM_PCD_CC_STATS_MODE_FRAME;
+
+ h_FmMuram = FmPcdGetMuramHandle(h_FmPcd);
+ if (!h_FmMuram)
+ RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("FM MURAM"));
+
+ INIT_LIST(&p_CcNode->ccPrevNodesLst);
+ INIT_LIST(&p_CcNode->ccTreeIdLst);
+ INIT_LIST(&p_CcNode->ccTreesLst);
+ INIT_LIST(&p_CcNode->availableStatsLst);
+
+ p_CcNode->h_Spinlock = XX_InitSpinlock();
+ if (!p_CcNode->h_Spinlock)
+ {
+ DeleteNode(p_CcNode);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("CC node spinlock"));
}
- err = UpdatePtrWhichPointOnCrntMdfNode(p_FmPcdCcNode, p_ModifyKeyParams, h_OldLst, h_NewLst);
- if(err)
+ if ((p_CcNodeParam->extractCcParams.type == e_FM_PCD_EXTRACT_BY_HDR)
+ && ((p_CcNodeParam->extractCcParams.extractByHdr.hdr
+ == HEADER_TYPE_IPv4)
+ || (p_CcNodeParam->extractCcParams.extractByHdr.hdr
+ == HEADER_TYPE_IPv6))
+ && (p_CcNodeParam->extractCcParams.extractByHdr.type
+ == e_FM_PCD_EXTRACT_FULL_FIELD)
+ && ((p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fullField.ipv6
+ == NET_HEADER_FIELD_IPv6_HOP_LIMIT)
+ || (p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fullField.ipv4
+ == NET_HEADER_FIELD_IPv4_TTL)))
{
- ReleaseNewNodeCommonPart(p_ModifyKeyParams);
- XX_Free(p_ModifyKeyParams);
+ err = Ipv4TtlOrIpv6HopLimitCheckParams(h_FmPcd, p_CcNodeParam, p_CcNode,
+ &isKeyTblAlloc);
+ glblMask = FALSE;
+ }
+ else
+ if ((p_CcNodeParam->extractCcParams.type == e_FM_PCD_EXTRACT_NON_HDR)
+ && ((p_CcNodeParam->extractCcParams.extractNonHdr.src
+ == e_FM_PCD_EXTRACT_FROM_KEY)
+ || (p_CcNodeParam->extractCcParams.extractNonHdr.src
+ == e_FM_PCD_EXTRACT_FROM_HASH)
+ || (p_CcNodeParam->extractCcParams.extractNonHdr.src
+ == e_FM_PCD_EXTRACT_FROM_FLOW_ID)))
+ {
+ if ((p_CcNodeParam->extractCcParams.extractNonHdr.src
+ == e_FM_PCD_EXTRACT_FROM_FLOW_ID)
+ && (p_CcNodeParam->extractCcParams.extractNonHdr.offset != 0))
+ {
+ DeleteNode(p_CcNode);
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("In the case of the extraction from e_FM_PCD_EXTRACT_FROM_FLOW_ID offset has to be 0"));
+ }
+
+ icCode = IcDefineCode(p_CcNodeParam);
+ fromIc = TRUE;
+ if (icCode == CC_PRIVATE_INFO_NONE)
+ {
+ DeleteNode(p_CcNode);
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("user asked extraction from IC and field in internal context or action wasn't initialized in the right way"));
+ }
+
+ if ((icCode == CC_PRIVATE_INFO_IC_DEQ_FQID_INDEX_LOOKUP)
+ || (icCode == CC_PRIVATE_INFO_IC_HASH_INDEX_LOOKUP))
+ {
+ err = IcHashIndexedCheckParams(h_FmPcd, p_CcNodeParam, p_CcNode,
+ &isKeyTblAlloc);
+ glblMask = TRUE;
+ }
+ else
+ {
+ err = CheckParams(h_FmPcd, p_CcNodeParam, p_CcNode,
+ &isKeyTblAlloc);
+ if (p_CcNode->glblMaskSize)
+ glblMask = TRUE;
+ }
+ }
+ else
+ {
+ err = CheckParams(h_FmPcd, p_CcNodeParam, p_CcNode, &isKeyTblAlloc);
+ if (p_CcNode->glblMaskSize)
+ glblMask = TRUE;
+ }
+
+ if (err)
+ {
+ DeleteNode(p_CcNode);
RETURN_ERROR(MAJOR, err, NO_MSG);
}
+ switch (p_CcNodeParam->extractCcParams.type)
+ {
+ case (e_FM_PCD_EXTRACT_BY_HDR):
+ switch (p_CcNodeParam->extractCcParams.extractByHdr.type)
+ {
+ case (e_FM_PCD_EXTRACT_FULL_FIELD):
+ p_CcNode->parseCode =
+ GetFullFieldParseCode(
+ p_CcNodeParam->extractCcParams.extractByHdr.hdr,
+ p_CcNodeParam->extractCcParams.extractByHdr.hdrIndex,
+ p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fullField);
+ GetSizeHeaderField(
+ p_CcNodeParam->extractCcParams.extractByHdr.hdr,
+ p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fullField,
+ &p_CcNode->sizeOfExtraction);
+ fullField = TRUE;
+ if ((p_CcNode->parseCode != CC_PC_FF_TCI1)
+ && (p_CcNode->parseCode != CC_PC_FF_TCI2)
+ && (p_CcNode->parseCode != CC_PC_FF_MPLS1)
+ && (p_CcNode->parseCode != CC_PC_FF_MPLS_LAST)
+ && (p_CcNode->parseCode != CC_PC_FF_IPV4IPTOS_TC1)
+ && (p_CcNode->parseCode != CC_PC_FF_IPV4IPTOS_TC2)
+ && (p_CcNode->parseCode
+ != CC_PC_FF_IPTOS_IPV6TC1_IPV6FLOW1)
+ && (p_CcNode->parseCode != CC_PC_FF_IPDSCP)
+ && (p_CcNode->parseCode
+ != CC_PC_FF_IPTOS_IPV6TC2_IPV6FLOW2)
+ && glblMask)
+ {
+ glblMask = FALSE;
+ p_CcNode->glblMaskSize = 4;
+ p_CcNode->lclMask = TRUE;
+ }
+ break;
+
+ case (e_FM_PCD_EXTRACT_FROM_HDR):
+ p_CcNode->sizeOfExtraction =
+ p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromHdr.size;
+ p_CcNode->offset =
+ p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromHdr.offset;
+ p_CcNode->userOffset =
+ p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromHdr.offset;
+ p_CcNode->parseCode =
+ GetPrParseCode(
+ p_CcNodeParam->extractCcParams.extractByHdr.hdr,
+ p_CcNodeParam->extractCcParams.extractByHdr.hdrIndex,
+ p_CcNode->offset, glblMask,
+ &p_CcNode->prsArrayOffset);
+ break;
+
+ case (e_FM_PCD_EXTRACT_FROM_FIELD):
+ p_CcNode->offset =
+ p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromField.offset;
+ p_CcNode->userOffset =
+ p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromField.offset;
+ p_CcNode->sizeOfExtraction =
+ p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromField.size;
+ p_CcNode->parseCode =
+ GetFieldParseCode(
+ p_CcNodeParam->extractCcParams.extractByHdr.hdr,
+ p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromField.field,
+ p_CcNode->offset,
+ &p_CcNode->prsArrayOffset,
+ p_CcNodeParam->extractCcParams.extractByHdr.hdrIndex);
+ break;
+
+ default:
+ DeleteNode(p_CcNode);
+ RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
+ }
+ break;
+
+ case (e_FM_PCD_EXTRACT_NON_HDR):
+ /* get the field code for the generic extract */
+ p_CcNode->sizeOfExtraction =
+ p_CcNodeParam->extractCcParams.extractNonHdr.size;
+ p_CcNode->offset =
+ p_CcNodeParam->extractCcParams.extractNonHdr.offset;
+ p_CcNode->userOffset =
+ p_CcNodeParam->extractCcParams.extractNonHdr.offset;
+ p_CcNode->parseCode = GetGenParseCode(
+ p_CcNodeParam->extractCcParams.extractNonHdr.src,
+ p_CcNode->offset, glblMask, &p_CcNode->prsArrayOffset,
+ fromIc, icCode);
+
+ if (p_CcNode->parseCode == CC_PC_GENERIC_IC_HASH_INDEXED)
+ {
+ if ((p_CcNode->offset + p_CcNode->sizeOfExtraction) > 8)
+ {
+ DeleteNode(p_CcNode);
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_SELECTION,
+ ("when node of the type CC_PC_GENERIC_IC_HASH_INDEXED offset + size can not be bigger then size of HASH 64 bits (8 bytes)"));
+ }
+ }
+ if ((p_CcNode->parseCode == CC_PC_GENERIC_IC_GMASK)
+ || (p_CcNode->parseCode == CC_PC_GENERIC_IC_HASH_INDEXED))
+ {
+ p_CcNode->offset += p_CcNode->prsArrayOffset;
+ p_CcNode->prsArrayOffset = 0;
+ }
+ break;
+
+ default:
+ DeleteNode(p_CcNode);
+ RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
+ }
+
+ if (p_CcNode->parseCode == CC_PC_ILLEGAL)
+ {
+ DeleteNode(p_CcNode);
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("illegal extraction type"));
+ }
+
+ if ((p_CcNode->sizeOfExtraction > FM_PCD_MAX_SIZE_OF_KEY)
+ || !p_CcNode->sizeOfExtraction)
+ {
+ DeleteNode(p_CcNode);
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("sizeOfExatrction can not be greater than 56 and not 0"));
+ }
+
+ if (p_CcNodeParam->keysParams.keySize != p_CcNode->sizeOfExtraction)
+ {
+ DeleteNode(p_CcNode);
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("keySize has to be equal to sizeOfExtraction"));
+ }
+
+ p_CcNode->userSizeOfExtraction = p_CcNode->sizeOfExtraction;
+
+ if (!glblMask)
+ memset(p_CcNode->p_GlblMask, 0xff, CC_GLBL_MASK_SIZE * sizeof(uint8_t));
+
+ err = CheckAndSetManipParamsWithCcNodeParams(p_CcNode);
+ if (err != E_OK)
+ {
+ DeleteNode(p_CcNode);
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("keySize has to be equal to sizeOfExtraction"));
+ }
+
+ /* Calculating matching table entry size by rounding up the user-defined size of extraction to valid entry size */
+ GetCcExtractKeySize(p_CcNode->sizeOfExtraction,
+ &p_CcNode->ccKeySizeAccExtraction);
+
+ /* If local mask is used, it is stored next to each key in the keys match table */
+ if (p_CcNode->lclMask)
+ keySize = (uint32_t)(2 * p_CcNode->ccKeySizeAccExtraction);
+ else
+ keySize = p_CcNode->ccKeySizeAccExtraction;
+
+ /* Update CC shadow with maximal size required by this node */
+ if (p_CcNode->maxNumOfKeys)
+ {
+ err = CalcAndUpdateCcShadow(p_CcNode, isKeyTblAlloc, &matchTableSize,
+ &adTableSize);
+ if (err != E_OK)
+ {
+ DeleteNode(p_CcNode);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+
+ p_CcNode->keysMatchTableMaxSize = matchTableSize;
+
+ if (p_CcNode->statisticsMode != e_FM_PCD_CC_STATS_MODE_NONE)
+ {
+ err = AllocStatsObjs(p_CcNode);
+ if (err != E_OK)
+ {
+ DeleteNode(p_CcNode);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+ }
+
+ /* If manipulation will be initialized before this node, it will use the table
+ descriptor in the AD table of previous node and this node will need an extra
+ AD as his table descriptor. */
+ p_CcNode->h_TmpAd = (t_Handle)FM_MURAM_AllocMem(
+ h_FmMuram, FM_PCD_CC_AD_ENTRY_SIZE, FM_PCD_CC_AD_TABLE_ALIGN);
+ if (!p_CcNode->h_TmpAd)
+ {
+ DeleteNode(p_CcNode);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("MURAM allocation for CC action descriptor"));
+ }
+ }
+ else
+ {
+ matchTableSize = (uint32_t)(keySize * sizeof(uint8_t)
+ * (p_CcNode->numOfKeys + 1));
+ adTableSize = (uint32_t)(FM_PCD_CC_AD_ENTRY_SIZE
+ * (p_CcNode->numOfKeys + 1));
+ }
+
+#if (DPAA_VERSION >= 11)
+ switch (p_CcNode->statisticsMode)
+ {
+
+ case e_FM_PCD_CC_STATS_MODE_RMON:
+ /* If RMON statistics or RMON conditional statistics modes are requested,
+ allocate frame length ranges array */
+ p_CcNode->h_StatsFLRs = FM_MURAM_AllocMem(
+ h_FmMuram,
+ (uint32_t)(p_CcNode->numOfStatsFLRs)
+ * FM_PCD_CC_STATS_FLR_SIZE,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+
+ if (!p_CcNode->h_StatsFLRs)
+ {
+ DeleteNode(p_CcNode);
+ RETURN_ERROR(
+ MAJOR, E_NO_MEMORY,
+ ("MURAM allocation for CC frame length ranges array"));
+ }
+
+ /* Initialize using value received from the user */
+ for (tmp = 0; tmp < p_CcNode->numOfStatsFLRs; tmp++)
+ {
+ uint16_t flr =
+ cpu_to_be16(p_CcNodeParam->keysParams.frameLengthRanges[tmp]);
+
+ h_StatsFLRs =
+ PTR_MOVE(p_CcNode->h_StatsFLRs, tmp * FM_PCD_CC_STATS_FLR_SIZE);
+
+ MemCpy8(h_StatsFLRs,
+ &flr,
+ FM_PCD_CC_STATS_FLR_SIZE);
+ }
+ break;
+
+ default:
+ break;
+ }
+#endif /* (DPAA_VERSION >= 11) */
+
+ /* Allocate keys match table. Not required for some CC nodes, for example for IPv4 TTL
+ identification, IPv6 hop count identification, etc. */
+ if (isKeyTblAlloc)
+ {
+ p_CcNode->h_KeysMatchTable = (t_Handle)FM_MURAM_AllocMem(
+ h_FmMuram, matchTableSize, FM_PCD_CC_KEYS_MATCH_TABLE_ALIGN);
+ if (!p_CcNode->h_KeysMatchTable)
+ {
+ DeleteNode(p_CcNode);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("MURAM allocation for CC node key match table"));
+ }
+ MemSet8((uint8_t *)p_CcNode->h_KeysMatchTable, 0, matchTableSize);
+ }
+
+ /* Allocate action descriptors table */
+ p_CcNode->h_AdTable = (t_Handle)FM_MURAM_AllocMem(h_FmMuram, adTableSize,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if (!p_CcNode->h_AdTable)
+ {
+ DeleteNode(p_CcNode);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("MURAM allocation for CC node action descriptors table"));
+ }
+ MemSet8((uint8_t *)p_CcNode->h_AdTable, 0, adTableSize);
+
+ p_KeysMatchTblTmp = p_CcNode->h_KeysMatchTable;
+ p_AdTableTmp = p_CcNode->h_AdTable;
+
+ /* For each key, create the key and the next step AD */
+ for (tmp = 0; tmp < p_CcNode->numOfKeys; tmp++)
+ {
+ p_KeyParams = &p_CcNodeParam->keysParams.keyParams[tmp];
+
+ if (p_KeysMatchTblTmp)
+ {
+ /* Copy the key */
+ MemCpy8((void*)p_KeysMatchTblTmp, p_KeyParams->p_Key,
+ p_CcNode->sizeOfExtraction);
+
+ /* Copy the key mask or initialize it to 0xFF..F */
+ if (p_CcNode->lclMask && p_KeyParams->p_Mask)
+ {
+ MemCpy8(PTR_MOVE(p_KeysMatchTblTmp,
+ p_CcNode->ccKeySizeAccExtraction), /* User's size of extraction rounded up to a valid matching table entry size */
+ p_KeyParams->p_Mask, p_CcNode->sizeOfExtraction); /* Exact size of extraction as received from the user */
+ }
+ else
+ if (p_CcNode->lclMask)
+ {
+ MemSet8(PTR_MOVE(p_KeysMatchTblTmp,
+ p_CcNode->ccKeySizeAccExtraction), /* User's size of extraction rounded up to a valid matching table entry size */
+ 0xff, p_CcNode->sizeOfExtraction); /* Exact size of extraction as received from the user */
+ }
+
+ p_KeysMatchTblTmp =
+ PTR_MOVE(p_KeysMatchTblTmp, keySize * sizeof(uint8_t));
+ }
+
+ /* Create the next action descriptor in the match table */
+ if (p_KeyParams->ccNextEngineParams.statisticsEn)
+ {
+ p_StatsObj = GetStatsObj(p_CcNode);
+ ASSERT_COND(p_StatsObj);
+
+ statsParams.h_StatsAd = p_StatsObj->h_StatsAd;
+ statsParams.h_StatsCounters = p_StatsObj->h_StatsCounters;
+#if (DPAA_VERSION >= 11)
+ statsParams.h_StatsFLRs = p_CcNode->h_StatsFLRs;
+
+#endif /* (DPAA_VERSION >= 11) */
+ NextStepAd(p_AdTableTmp, &statsParams,
+ &p_KeyParams->ccNextEngineParams, p_FmPcd);
+
+ p_CcNode->keyAndNextEngineParams[tmp].p_StatsObj = p_StatsObj;
+ }
+ else
+ {
+ NextStepAd(p_AdTableTmp, NULL, &p_KeyParams->ccNextEngineParams,
+ p_FmPcd);
+
+ p_CcNode->keyAndNextEngineParams[tmp].p_StatsObj = NULL;
+ }
+
+ p_AdTableTmp = PTR_MOVE(p_AdTableTmp, FM_PCD_CC_AD_ENTRY_SIZE);
+ }
+
+ /* Update next engine for the 'miss' entry */
+ if (p_CcNodeParam->keysParams.ccNextEngineParamsForMiss.statisticsEn)
+ {
+ p_StatsObj = GetStatsObj(p_CcNode);
+ ASSERT_COND(p_StatsObj);
+
+ /* All 'bucket' nodes of a hash table should share the same statistics counters,
+ allocated by the hash table. So, if this node is a bucket of a hash table,
+ we'll replace the locally allocated counters with the shared counters. */
+ if (p_CcNode->isHashBucket)
+ {
+ ASSERT_COND(p_CcNode->h_MissStatsCounters);
+
+ /* Store original counters pointer and replace it with mutual preallocated pointer */
+ p_CcNode->h_PrivMissStatsCounters = p_StatsObj->h_StatsCounters;
+ p_StatsObj->h_StatsCounters = p_CcNode->h_MissStatsCounters;
+ }
+
+ statsParams.h_StatsAd = p_StatsObj->h_StatsAd;
+ statsParams.h_StatsCounters = p_StatsObj->h_StatsCounters;
+#if (DPAA_VERSION >= 11)
+ statsParams.h_StatsFLRs = p_CcNode->h_StatsFLRs;
+
+#endif /* (DPAA_VERSION >= 11) */
+
+ NextStepAd(p_AdTableTmp, &statsParams,
+ &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,
+ p_FmPcd);
+
+ p_CcNode->keyAndNextEngineParams[tmp].p_StatsObj = p_StatsObj;
+ }
+ else
+ {
+ NextStepAd(p_AdTableTmp, NULL,
+ &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,
+ p_FmPcd);
+
+ p_CcNode->keyAndNextEngineParams[tmp].p_StatsObj = NULL;
+ }
+
+ /* This parameter will be used to initialize the "key length" field in the action descriptor
+ that points to this node and it should be 0 for full field extraction */
+ if (fullField == TRUE)
+ p_CcNode->sizeOfExtraction = 0;
+
+ for (tmp = 0; tmp < MIN(p_CcNode->numOfKeys + 1, CC_MAX_NUM_OF_KEYS); tmp++)
+ {
+ if (p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
+ {
+ p_FmPcdCcNextNode =
+ (t_FmPcdCcNode*)p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.params.ccParams.h_CcNode;
+ p_CcInformation = FindNodeInfoInReleventLst(
+ &p_FmPcdCcNextNode->ccPrevNodesLst, (t_Handle)p_CcNode,
+ p_FmPcdCcNextNode->h_Spinlock);
+ if (!p_CcInformation)
+ {
+ memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
+ ccNodeInfo.h_CcNode = (t_Handle)p_CcNode;
+ ccNodeInfo.index = 1;
+ EnqueueNodeInfoToRelevantLst(&p_FmPcdCcNextNode->ccPrevNodesLst,
+ &ccNodeInfo,
+ p_FmPcdCcNextNode->h_Spinlock);
+ }
+ else
+ p_CcInformation->index++;
+
+ if (p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.h_Manip)
+ {
+ h_Manip =
+ p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.h_Manip;
+ p_CcInformation = FindNodeInfoInReleventLst(
+ FmPcdManipGetNodeLstPointedOnThisManip(h_Manip),
+ (t_Handle)p_CcNode, FmPcdManipGetSpinlock(h_Manip));
+ if (!p_CcInformation)
+ {
+ memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
+ ccNodeInfo.h_CcNode = (t_Handle)p_CcNode;
+ ccNodeInfo.index = 1;
+ EnqueueNodeInfoToRelevantLst(
+ FmPcdManipGetNodeLstPointedOnThisManip(h_Manip),
+ &ccNodeInfo, FmPcdManipGetSpinlock(h_Manip));
+ }
+ else
+ p_CcInformation->index++;
+ }
+ }
+ }
+
+ p_AdTableTmp = p_CcNode->h_AdTable;
+
+ if (!FmPcdLockTryLockAll(h_FmPcd))
+ {
+ FM_PCD_MatchTableDelete((t_Handle)p_CcNode);
+ DBG(TRACE, ("FmPcdLockTryLockAll failed"));
+ return ERROR_CODE(E_BUSY);
+ }
+
+ /* Required action for each next engine */
+ for (tmp = 0; tmp < MIN(p_CcNode->numOfKeys + 1, CC_MAX_NUM_OF_KEYS); tmp++)
+ {
+ if (p_CcNode->keyAndNextEngineParams[tmp].requiredAction)
+ {
+ err = SetRequiredAction(
+ h_FmPcd,
+ p_CcNode->keyAndNextEngineParams[tmp].requiredAction,
+ &p_CcNode->keyAndNextEngineParams[tmp], p_AdTableTmp, 1,
+ NULL);
+ if (err)
+ {
+ FmPcdLockUnlockAll(h_FmPcd);
+ FM_PCD_MatchTableDelete((t_Handle)p_CcNode);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+ p_AdTableTmp = PTR_MOVE(p_AdTableTmp, FM_PCD_CC_AD_ENTRY_SIZE);
+ }
+ }
+
+ FmPcdLockUnlockAll(h_FmPcd);
+
return E_OK;
+}
+/************************** End of static functions **************************/
+
+/*****************************************************************************/
+/* Inter-module API routines */
+/*****************************************************************************/
+
+t_CcNodeInformation* FindNodeInfoInReleventLst(t_List *p_List, t_Handle h_Info,
+ t_Handle h_Spinlock)
+{
+ t_CcNodeInformation *p_CcInformation;
+ t_List *p_Pos;
+ uint32_t intFlags;
+
+ intFlags = XX_LockIntrSpinlock(h_Spinlock);
+
+ for (p_Pos = NCSW_LIST_FIRST(p_List); p_Pos != (p_List);
+ p_Pos = NCSW_LIST_NEXT(p_Pos))
+ {
+ p_CcInformation = CC_NODE_F_OBJECT(p_Pos);
+
+ ASSERT_COND(p_CcInformation->h_CcNode);
+ if (p_CcInformation->h_CcNode == h_Info)
+ {
+ XX_UnlockIntrSpinlock(h_Spinlock, intFlags);
+ return p_CcInformation;
+ }
+ }
+
+ XX_UnlockIntrSpinlock(h_Spinlock, intFlags);
+
+ return NULL;
}
-t_Error FmPcdCcModifyKey(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode, uint8_t keyIndex, uint8_t keySize, uint8_t *p_Key, uint8_t *p_Mask, t_List *h_OldLst, t_List *h_NewLst,t_Handle *h_AdditionalParams)
+void EnqueueNodeInfoToRelevantLst(t_List *p_List, t_CcNodeInformation *p_CcInfo,
+ t_Handle h_Spinlock)
{
- t_FmPcdCcNode *p_FmPcdCcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
- t_Error err = E_OK;
- t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;
+ t_CcNodeInformation *p_CcInformation;
+ uint32_t intFlags = 0;
- if(keyIndex >= p_FmPcdCcNode->numOfKeys)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("keyIndex > previousely cleared last index + 1"));
+ p_CcInformation = (t_CcNodeInformation *)XX_Malloc(
+ sizeof(t_CcNodeInformation));
- if((p_FmPcdCcNode->numOfKeys + 1) > FM_PCD_MAX_NUM_OF_CC_NODES)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfKeys with new key can not be larger than 255"));
+ if (p_CcInformation)
+ {
+ memset(p_CcInformation, 0, sizeof(t_CcNodeInformation));
+ memcpy(p_CcInformation, p_CcInfo, sizeof(t_CcNodeInformation));
+ INIT_LIST(&p_CcInformation->node);
- if(keySize != p_FmPcdCcNode->userSizeOfExtraction)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("size for ModifyKey has to be the same as defined in SetNode"));
+ if (h_Spinlock)
+ intFlags = XX_LockIntrSpinlock(h_Spinlock);
- if(p_FmPcdCcNode->h_FmPcd != h_FmPcd)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("handler to FmPcd is diferent from one which was assigned to the node in the Init time"));
+ NCSW_LIST_AddToTail(&p_CcInformation->node, p_List);
- err = ModifyKeyCommonPart1(p_FmPcdCcNode, keyIndex, h_AdditionalParams, e_MODIFY_STATE_CHANGE, TRUE, FALSE);
- if(err)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
+ if (h_Spinlock)
+ XX_UnlockIntrSpinlock(h_Spinlock, intFlags);
+ }
+ else
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("CC Node Information"));
+}
+
+void DequeueNodeInfoFromRelevantLst(t_List *p_List, t_Handle h_Info,
+ t_Handle h_Spinlock)
+{
+ t_CcNodeInformation *p_CcInformation = NULL;
+ uint32_t intFlags = 0;
+ t_List *p_Pos;
- p_ModifyKeyParams = (t_FmPcdModifyCcKeyAdditionalParams *)*h_AdditionalParams;
+ if (h_Spinlock)
+ intFlags = XX_LockIntrSpinlock(h_Spinlock);
- err = BuildNewNodeModifyKey (p_FmPcdCcNode, keyIndex, p_Key, p_Mask, p_ModifyKeyParams);
- if(err)
+ if (NCSW_LIST_IsEmpty(p_List))
{
- XX_Free(p_ModifyKeyParams);
- RETURN_ERROR(MAJOR, err, NO_MSG);
+ XX_RestoreAllIntr(intFlags);
+ return;
}
- err = UpdatePtrWhichPointOnCrntMdfNode(p_FmPcdCcNode, p_ModifyKeyParams, h_OldLst, h_NewLst);
- if(err)
+ for (p_Pos = NCSW_LIST_FIRST(p_List); p_Pos != (p_List);
+ p_Pos = NCSW_LIST_NEXT(p_Pos))
{
- ReleaseNewNodeCommonPart(p_ModifyKeyParams);
- XX_Free(p_ModifyKeyParams);
- RETURN_ERROR(MAJOR, err, NO_MSG);
+ p_CcInformation = CC_NODE_F_OBJECT(p_Pos);
+ ASSERT_COND(p_CcInformation);
+ ASSERT_COND(p_CcInformation->h_CcNode);
+ if (p_CcInformation->h_CcNode == h_Info)
+ break;
+ }
+
+ if (p_CcInformation)
+ {
+ NCSW_LIST_DelAndInit(&p_CcInformation->node);
+ XX_Free(p_CcInformation);
+ }
+
+ if (h_Spinlock)
+ XX_UnlockIntrSpinlock(h_Spinlock, intFlags);
+}
+
+void NextStepAd(t_Handle h_Ad, t_FmPcdCcStatsParams *p_FmPcdCcStatsParams,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams,
+ t_FmPcd *p_FmPcd)
+{
+ switch (p_FmPcdCcNextEngineParams->nextEngine)
+ {
+ case (e_FM_PCD_KG):
+ case (e_FM_PCD_PLCR):
+ case (e_FM_PCD_DONE):
+ /* if NIA is not CC, create a "result" type AD */
+ FillAdOfTypeResult(h_Ad, p_FmPcdCcStatsParams, p_FmPcd,
+ p_FmPcdCcNextEngineParams);
+ break;
+#if (DPAA_VERSION >= 11)
+ case (e_FM_PCD_FR):
+ if (p_FmPcdCcNextEngineParams->params.frParams.h_FrmReplic)
+ {
+ FillAdOfTypeContLookup(
+ h_Ad, p_FmPcdCcStatsParams, p_FmPcd,
+ p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode,
+ p_FmPcdCcNextEngineParams->h_Manip,
+ p_FmPcdCcNextEngineParams->params.frParams.h_FrmReplic);
+ FrmReplicGroupUpdateOwner(
+ p_FmPcdCcNextEngineParams->params.frParams.h_FrmReplic,
+ TRUE/* add */);
+ }
+ break;
+#endif /* (DPAA_VERSION >= 11) */
+
+ case (e_FM_PCD_CC):
+ /* if NIA is not CC, create a TD to continue the CC lookup */
+ FillAdOfTypeContLookup(
+ h_Ad, p_FmPcdCcStatsParams, p_FmPcd,
+ p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode,
+ p_FmPcdCcNextEngineParams->h_Manip, NULL);
+
+ UpdateNodeOwner(p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode,
+ TRUE);
+ break;
+
+ default:
+ return;
+ }
+}
+
+t_Error FmPcdCcTreeAddIPR(t_Handle h_FmPcd, t_Handle h_FmTree,
+ t_Handle h_NetEnv, t_Handle h_IpReassemblyManip,
+ bool createSchemes)
+{
+ t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmTree;
+ t_FmPcdCcNextEngineParams nextEngineParams;
+ t_NetEnvParams netEnvParams;
+ t_Handle h_Ad;
+ bool isIpv6Present;
+ uint8_t ipv4GroupId, ipv6GroupId;
+ t_Error err;
+
+ ASSERT_COND(p_FmPcdCcTree);
+
+ /* this routine must be protected by the calling routine! */
+
+ memset(&nextEngineParams, 0, sizeof(t_FmPcdCcNextEngineParams));
+ memset(&netEnvParams, 0, sizeof(t_NetEnvParams));
+
+ h_Ad = UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr);
+
+ isIpv6Present = FmPcdManipIpReassmIsIpv6Hdr(h_IpReassemblyManip);
+
+ if (isIpv6Present
+ && (p_FmPcdCcTree->numOfEntries > (FM_PCD_MAX_NUM_OF_CC_GROUPS - 2)))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("need two free entries for IPR"));
+
+ if (p_FmPcdCcTree->numOfEntries > (FM_PCD_MAX_NUM_OF_CC_GROUPS - 1))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("need two free entries for IPR"));
+
+ nextEngineParams.nextEngine = e_FM_PCD_DONE;
+ nextEngineParams.h_Manip = h_IpReassemblyManip;
+
+ /* Lock tree */
+ err = CcRootTryLock(p_FmPcdCcTree);
+ if (err)
+ return ERROR_CODE(E_BUSY);
+
+ if (p_FmPcdCcTree->h_IpReassemblyManip == h_IpReassemblyManip)
+ {
+ CcRootReleaseLock(p_FmPcdCcTree);
+ return E_OK;
+ }
+
+ if ((p_FmPcdCcTree->h_IpReassemblyManip)
+ && (p_FmPcdCcTree->h_IpReassemblyManip != h_IpReassemblyManip))
+ {
+ CcRootReleaseLock(p_FmPcdCcTree);
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("This tree was previously updated with different IPR"));
+ }
+
+ /* Initialize IPR for the first time for this tree */
+ if (isIpv6Present)
+ {
+ ipv6GroupId = p_FmPcdCcTree->numOfGrps++;
+ p_FmPcdCcTree->fmPcdGroupParam[ipv6GroupId].baseGroupEntry =
+ (FM_PCD_MAX_NUM_OF_CC_GROUPS - 2);
+
+ if (createSchemes)
+ {
+ err = FmPcdManipBuildIpReassmScheme(h_FmPcd, h_NetEnv,
+ p_FmPcdCcTree,
+ h_IpReassemblyManip, FALSE,
+ ipv6GroupId);
+ if (err)
+ {
+ p_FmPcdCcTree->numOfGrps--;
+ CcRootReleaseLock(p_FmPcdCcTree);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+ }
+
+ NextStepAd(
+ PTR_MOVE(h_Ad, (FM_PCD_MAX_NUM_OF_CC_GROUPS-2) * FM_PCD_CC_AD_ENTRY_SIZE),
+ NULL, &nextEngineParams, h_FmPcd);
+ }
+
+ ipv4GroupId = p_FmPcdCcTree->numOfGrps++;
+ p_FmPcdCcTree->fmPcdGroupParam[ipv4GroupId].totalBitsMask = 0;
+ p_FmPcdCcTree->fmPcdGroupParam[ipv4GroupId].baseGroupEntry =
+ (FM_PCD_MAX_NUM_OF_CC_GROUPS - 1);
+
+ if (createSchemes)
+ {
+ err = FmPcdManipBuildIpReassmScheme(h_FmPcd, h_NetEnv, p_FmPcdCcTree,
+ h_IpReassemblyManip, TRUE,
+ ipv4GroupId);
+ if (err)
+ {
+ p_FmPcdCcTree->numOfGrps--;
+ if (isIpv6Present)
+ {
+ p_FmPcdCcTree->numOfGrps--;
+ FmPcdManipDeleteIpReassmSchemes(h_IpReassemblyManip);
+ }
+ CcRootReleaseLock(p_FmPcdCcTree);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
}
+
+ NextStepAd(
+ PTR_MOVE(h_Ad, (FM_PCD_MAX_NUM_OF_CC_GROUPS-1) * FM_PCD_CC_AD_ENTRY_SIZE),
+ NULL, &nextEngineParams, h_FmPcd);
+
+ p_FmPcdCcTree->h_IpReassemblyManip = h_IpReassemblyManip;
+
+ CcRootReleaseLock(p_FmPcdCcTree);
+
return E_OK;
}
+t_Error FmPcdCcTreeAddCPR(t_Handle h_FmPcd, t_Handle h_FmTree,
+ t_Handle h_NetEnv, t_Handle h_ReassemblyManip,
+ bool createSchemes)
+{
+ t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmTree;
+ t_FmPcdCcNextEngineParams nextEngineParams;
+ t_NetEnvParams netEnvParams;
+ t_Handle h_Ad;
+ uint8_t groupId;
+ t_Error err;
+
+ ASSERT_COND(p_FmPcdCcTree);
+
+ /* this routine must be protected by the calling routine! */
+ memset(&nextEngineParams, 0, sizeof(t_FmPcdCcNextEngineParams));
+ memset(&netEnvParams, 0, sizeof(t_NetEnvParams));
+
+ h_Ad = UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr);
+
+ if (p_FmPcdCcTree->numOfEntries > (FM_PCD_MAX_NUM_OF_CC_GROUPS - 1))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("need one free entries for CPR"));
+
+ nextEngineParams.nextEngine = e_FM_PCD_DONE;
+ nextEngineParams.h_Manip = h_ReassemblyManip;
+
+ /* Lock tree */
+ err = CcRootTryLock(p_FmPcdCcTree);
+ if (err)
+ return ERROR_CODE(E_BUSY);
+
+ if (p_FmPcdCcTree->h_CapwapReassemblyManip == h_ReassemblyManip)
+ {
+ CcRootReleaseLock(p_FmPcdCcTree);
+ return E_OK;
+ }
+
+ if ((p_FmPcdCcTree->h_CapwapReassemblyManip)
+ && (p_FmPcdCcTree->h_CapwapReassemblyManip != h_ReassemblyManip))
+ {
+ CcRootReleaseLock(p_FmPcdCcTree);
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("This tree was previously updated with different CPR"));
+ }
+
+ groupId = p_FmPcdCcTree->numOfGrps++;
+ p_FmPcdCcTree->fmPcdGroupParam[groupId].baseGroupEntry =
+ (FM_PCD_MAX_NUM_OF_CC_GROUPS - 1);
+
+ if (createSchemes)
+ {
+ err = FmPcdManipBuildCapwapReassmScheme(h_FmPcd, h_NetEnv,
+ p_FmPcdCcTree,
+ h_ReassemblyManip, groupId);
+ if (err)
+ {
+ p_FmPcdCcTree->numOfGrps--;
+ CcRootReleaseLock(p_FmPcdCcTree);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+ }
+
+ NextStepAd(
+ PTR_MOVE(h_Ad, (FM_PCD_MAX_NUM_OF_CC_GROUPS-1) * FM_PCD_CC_AD_ENTRY_SIZE),
+ NULL, &nextEngineParams, h_FmPcd);
+
+ p_FmPcdCcTree->h_CapwapReassemblyManip = h_ReassemblyManip;
+
+ CcRootReleaseLock(p_FmPcdCcTree);
+
+ return E_OK;
+}
+
+t_Handle FmPcdCcTreeGetSavedManipParams(t_Handle h_FmTree)
+{
+ t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmTree;
+
+ ASSERT_COND(p_FmPcdCcTree);
+
+ return p_FmPcdCcTree->h_FmPcdCcSavedManipParams;
+}
+
+void FmPcdCcTreeSetSavedManipParams(t_Handle h_FmTree,
+ t_Handle h_SavedManipParams)
+{
+ t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmTree;
+
+ ASSERT_COND(p_FmPcdCcTree);
+
+ p_FmPcdCcTree->h_FmPcdCcSavedManipParams = h_SavedManipParams;
+}
+
+uint8_t FmPcdCcGetParseCode(t_Handle h_CcNode)
+{
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+
+ ASSERT_COND(p_CcNode);
+
+ return p_CcNode->parseCode;
+}
+
+uint8_t FmPcdCcGetOffset(t_Handle h_CcNode)
+{
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+
+ ASSERT_COND(p_CcNode);
+
+ return p_CcNode->offset;
+}
+
+uint16_t FmPcdCcGetNumOfKeys(t_Handle h_CcNode)
+{
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+
+ ASSERT_COND(p_CcNode);
-t_Error FmPcdCcModiyNextEngineParamNode(t_Handle h_FmPcd,t_Handle h_FmPcdCcNode, uint8_t keyIndex,t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams,t_List *h_OldPointer, t_List *h_NewPointer,t_Handle *h_AdditionalParams)
+ return p_CcNode->numOfKeys;
+}
+
+t_Error FmPcdCcModifyNextEngineParamTree(
+ t_Handle h_FmPcd, t_Handle h_FmPcdCcTree, uint8_t grpId, uint8_t index,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
{
- t_FmPcdCcNode *p_FmPcdCcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
- t_Error err = E_OK;
+ t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;
+ t_FmPcd *p_FmPcd;
+ t_List h_OldPointersLst, h_NewPointersLst;
+ uint16_t keyIndex;
t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(h_FmPcdCcTree, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((grpId <= 7), E_INVALID_VALUE);
+
+ if (grpId >= p_FmPcdCcTree->numOfGrps)
+ RETURN_ERROR(MAJOR, E_INVALID_HANDLE,
+ ("grpId you asked > numOfGroup of relevant tree"));
+
+ if (index >= p_FmPcdCcTree->fmPcdGroupParam[grpId].numOfEntriesInGroup)
+ RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("index > numOfEntriesInGroup"));
- SANITY_CHECK_RETURN_ERROR(h_FmPcd,E_INVALID_VALUE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNode,E_INVALID_HANDLE);
+ p_FmPcd = (t_FmPcd *)h_FmPcd;
- if(keyIndex >= p_FmPcdCcNode->numOfKeys)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("keyIndex > previousely cleared last index + 1"));
+ INIT_LIST(&h_OldPointersLst);
+ INIT_LIST(&h_NewPointersLst);
- if((p_FmPcdCcNode->numOfKeys + 1) > FM_PCD_MAX_NUM_OF_CC_NODES)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfKeys with new key can not be larger than 255"));
+ keyIndex = (uint16_t)(p_FmPcdCcTree->fmPcdGroupParam[grpId].baseGroupEntry
+ + index);
- err = ModifyKeyCommonPart1(p_FmPcdCcNode, keyIndex, h_AdditionalParams, e_MODIFY_STATE_CHANGE, FALSE, FALSE);
- if(err)
+ p_ModifyKeyParams = ModifyNodeCommonPart(p_FmPcdCcTree, keyIndex,
+ e_MODIFY_STATE_CHANGE, FALSE,
+ FALSE, TRUE);
+ if (!p_ModifyKeyParams)
RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
- p_ModifyKeyParams = (t_FmPcdModifyCcKeyAdditionalParams *)*h_AdditionalParams;
+ p_ModifyKeyParams->tree = TRUE;
+
+ if (p_FmPcd->p_CcShadow
+ && !TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))
+ {
+ XX_Free(p_ModifyKeyParams);
+ return ERROR_CODE(E_BUSY);
+ }
- err = BuildNewNodeModifyNextEngine (h_FmPcd, p_FmPcdCcNode, keyIndex,p_FmPcdCcNextEngineParams, h_OldPointer, h_NewPointer, p_ModifyKeyParams);
- if(err)
+ err = BuildNewNodeModifyNextEngine(p_FmPcd, p_FmPcdCcTree, keyIndex,
+ p_FmPcdCcNextEngineParams,
+ &h_OldPointersLst, &h_NewPointersLst,
+ p_ModifyKeyParams);
+ if (err)
{
XX_Free(p_ModifyKeyParams);
RETURN_ERROR(MAJOR, err, NO_MSG);
}
- return E_OK;
+
+ err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,
+ p_ModifyKeyParams, FALSE);
+
+ if (p_FmPcd->p_CcShadow)
+ RELEASE_LOCK(p_FmPcd->shadowLock);
+
+ return err;
+
}
-t_Error FmPcdCcModifyMissNextEngineParamNode(t_Handle h_FmPcd,t_Handle h_FmPcdCcNode, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams,t_List *h_OldPointer, t_List *h_NewPointer,t_Handle *h_AdditionalParams)
+t_Error FmPcdCcRemoveKey(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode,
+ uint16_t keyIndex)
{
- t_FmPcdCcNode *p_FmPcdCcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
- t_Error err = E_OK;
- uint16_t keyIndex;
+
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
+ t_FmPcd *p_FmPcd;
t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;
+ t_List h_OldPointersLst, h_NewPointersLst;
+ bool useShadowStructs = FALSE;
+ t_Error err = E_OK;
+
+ if (keyIndex >= p_CcNode->numOfKeys)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("impossible to remove key when numOfKeys <= keyIndex"));
+
+ if (p_CcNode->h_FmPcd != h_FmPcd)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("handler to FmPcd is different from the handle provided at node initialization time"));
- SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNode,E_INVALID_VALUE);
+ p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
- keyIndex = p_FmPcdCcNode->numOfKeys;
+ INIT_LIST(&h_OldPointersLst);
+ INIT_LIST(&h_NewPointersLst);
- err = ModifyKeyCommonPart1(p_FmPcdCcNode, keyIndex, h_AdditionalParams, e_MODIFY_STATE_CHANGE, TRUE, FALSE);
- if(err)
+ p_ModifyKeyParams = ModifyNodeCommonPart(p_CcNode, keyIndex,
+ e_MODIFY_STATE_REMOVE, TRUE, TRUE,
+ FALSE);
+ if (!p_ModifyKeyParams)
RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
- p_ModifyKeyParams = (t_FmPcdModifyCcKeyAdditionalParams *)*h_AdditionalParams;
+ if (p_CcNode->maxNumOfKeys)
+ {
+ if (!TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))
+ {
+ XX_Free(p_ModifyKeyParams);
+ return ERROR_CODE(E_BUSY);
+ }
+
+ useShadowStructs = TRUE;
+ }
- err = BuildNewNodeModifyNextEngine (h_FmPcd, p_FmPcdCcNode, keyIndex,p_FmPcdCcNextEngineParams, h_OldPointer, h_NewPointer, p_ModifyKeyParams);
- if(err)
+ err = BuildNewNodeRemoveKey(p_CcNode, keyIndex, p_ModifyKeyParams);
+ if (err)
{
XX_Free(p_ModifyKeyParams);
+ if (p_CcNode->maxNumOfKeys)
+ RELEASE_LOCK(p_FmPcd->shadowLock);
RETURN_ERROR(MAJOR, err, NO_MSG);
}
- return E_OK;
-}
-
-t_Error FmPcdCcAddKey(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode, uint8_t keyIndex, uint8_t keySize, t_FmPcdCcKeyParams *p_FmPcdCcKeyParams, t_List *h_OldLst, t_List *h_NewLst, t_Handle *h_AdditionalParams)
-{
- t_FmPcdCcNode *p_FmPcdCcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
- t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;
- t_Error err = E_OK;
+ err = UpdatePtrWhichPointOnCrntMdfNode(p_CcNode, p_ModifyKeyParams,
+ &h_OldPointersLst,
+ &h_NewPointersLst);
+ if (err)
+ {
+ ReleaseNewNodeCommonPart(p_ModifyKeyParams);
+ XX_Free(p_ModifyKeyParams);
+ if (p_CcNode->maxNumOfKeys)
+ RELEASE_LOCK(p_FmPcd->shadowLock);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
- if(keyIndex > p_FmPcdCcNode->numOfKeys)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("keyIndex > previousely cleared last index + 1"));
+ err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,
+ p_ModifyKeyParams, useShadowStructs);
- if((p_FmPcdCcNode->numOfKeys + 1) > FM_PCD_MAX_NUM_OF_CC_NODES)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfKeys with new key can not be larger than 255"));
+ if (p_CcNode->maxNumOfKeys)
+ RELEASE_LOCK(p_FmPcd->shadowLock);
- if(keySize != p_FmPcdCcNode->userSizeOfExtraction)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("keySize has to be defined as it was defined in initialization step."));
+ return err;
+}
- if(p_FmPcdCcNode->h_FmPcd != h_FmPcd)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("handler to FmPcd is diferent from one which was assigned to the node in the Init time"));
+t_Error FmPcdCcModifyKey(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode,
+ uint16_t keyIndex, uint8_t keySize, uint8_t *p_Key,
+ uint8_t *p_Mask)
+{
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
+ t_FmPcd *p_FmPcd;
+ t_List h_OldPointersLst, h_NewPointersLst;
+ t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;
+ uint16_t tmpKeyIndex;
+ bool useShadowStructs = FALSE;
+ t_Error err = E_OK;
- err = ModifyKeyCommonPart1(p_FmPcdCcNode, keyIndex, h_AdditionalParams, e_MODIFY_STATE_ADD, TRUE, FALSE);
- if(err)
+ if (keyIndex >= p_CcNode->numOfKeys)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("keyIndex > previously cleared last index + 1"));
+
+ if (keySize != p_CcNode->userSizeOfExtraction)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("size for ModifyKey has to be the same as defined in SetNode"));
+
+ if (p_CcNode->h_FmPcd != h_FmPcd)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("handler to FmPcd is different from the handle provided at node initialization time"));
+
+ err = FindKeyIndex(h_FmPcdCcNode, keySize, p_Key, p_Mask, &tmpKeyIndex);
+ if (GET_ERROR_TYPE(err) != E_NOT_FOUND)
+ RETURN_ERROR(
+ MINOR,
+ E_ALREADY_EXISTS,
+ ("The received key and mask pair was already found in the match table of the provided node"));
+
+ p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
+
+ INIT_LIST(&h_OldPointersLst);
+ INIT_LIST(&h_NewPointersLst);
+
+ p_ModifyKeyParams = ModifyNodeCommonPart(p_CcNode, keyIndex,
+ e_MODIFY_STATE_CHANGE, TRUE, TRUE,
+ FALSE);
+ if (!p_ModifyKeyParams)
RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
- p_ModifyKeyParams = (t_FmPcdModifyCcKeyAdditionalParams *)*h_AdditionalParams;
- err = BuildNewNodeAddOrMdfyKeyAndNextEngine (h_FmPcd, p_FmPcdCcNode, keyIndex, p_FmPcdCcKeyParams, p_ModifyKeyParams, TRUE);
- if(err)
+ if (p_CcNode->maxNumOfKeys)
+ {
+ if (!TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))
+ {
+ XX_Free(p_ModifyKeyParams);
+ return ERROR_CODE(E_BUSY);
+ }
+
+ useShadowStructs = TRUE;
+ }
+
+ err = BuildNewNodeModifyKey(p_CcNode, keyIndex, p_Key, p_Mask,
+ p_ModifyKeyParams);
+ if (err)
{
XX_Free(p_ModifyKeyParams);
+ if (p_CcNode->maxNumOfKeys)
+ RELEASE_LOCK(p_FmPcd->shadowLock);
RETURN_ERROR(MAJOR, err, NO_MSG);
}
- err = UpdatePtrWhichPointOnCrntMdfNode(p_FmPcdCcNode, p_ModifyKeyParams, h_OldLst, h_NewLst);
- if(err)
+ err = UpdatePtrWhichPointOnCrntMdfNode(p_CcNode, p_ModifyKeyParams,
+ &h_OldPointersLst,
+ &h_NewPointersLst);
+ if (err)
{
ReleaseNewNodeCommonPart(p_ModifyKeyParams);
XX_Free(p_ModifyKeyParams);
- RETURN_ERROR(MAJOR, err, NO_MSG);
+ if (p_CcNode->maxNumOfKeys)
+ RELEASE_LOCK(p_FmPcd->shadowLock);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
- return E_OK;
+ err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,
+ p_ModifyKeyParams, useShadowStructs);
+
+ if (p_CcNode->maxNumOfKeys)
+ RELEASE_LOCK(p_FmPcd->shadowLock);
+
+ return err;
}
-t_Error FmPcdCcModifyKeyAndNextEngine(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode, uint8_t keyIndex, uint8_t keySize, t_FmPcdCcKeyParams *p_FmPcdCcKeyParams, t_List *h_OldLst, t_List *h_NewLst, t_Handle *h_AdditionalParams)
+t_Error FmPcdCcModifyMissNextEngineParamNode(
+ t_Handle h_FmPcd, t_Handle h_FmPcdCcNode,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
{
- t_FmPcdCcNode *p_FmPcdCcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
- t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;
- t_Error err = E_OK;
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
+ t_FmPcd *p_FmPcd;
+ t_List h_OldPointersLst, h_NewPointersLst;
+ uint16_t keyIndex;
+ t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;
+ t_Error err = E_OK;
- if(keyIndex > p_FmPcdCcNode->numOfKeys)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("keyIndex > previousely cleared last index + 1"));
+ SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_VALUE);
- if((p_FmPcdCcNode->numOfKeys + 1) > FM_PCD_MAX_NUM_OF_CC_NODES)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfKeys with new key can not be larger than 255"));
+ keyIndex = p_CcNode->numOfKeys;
- if(keySize != p_FmPcdCcNode->userSizeOfExtraction)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("keySize has to be defined as it was defined in initialization step"));
+ p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
- if(p_FmPcdCcNode->h_FmPcd != h_FmPcd)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("handler to FmPcd is diferent from one which was assigned to the node in the Init time"));
+ INIT_LIST(&h_OldPointersLst);
+ INIT_LIST(&h_NewPointersLst);
- err = ModifyKeyCommonPart1(p_FmPcdCcNode, keyIndex, h_AdditionalParams, e_MODIFY_STATE_CHANGE, TRUE, FALSE);
- if(err)
+ p_ModifyKeyParams = ModifyNodeCommonPart(p_CcNode, keyIndex,
+ e_MODIFY_STATE_CHANGE, FALSE, TRUE,
+ FALSE);
+ if (!p_ModifyKeyParams)
RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
- p_ModifyKeyParams = (t_FmPcdModifyCcKeyAdditionalParams *)*h_AdditionalParams;
-
- err = BuildNewNodeAddOrMdfyKeyAndNextEngine (h_FmPcd, p_FmPcdCcNode, keyIndex, p_FmPcdCcKeyParams, p_ModifyKeyParams, FALSE);
- if(err)
+ if (p_CcNode->maxNumOfKeys
+ && !TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))
{
- ReleaseNewNodeCommonPart(p_ModifyKeyParams);
XX_Free(p_ModifyKeyParams);
- RETURN_ERROR(MAJOR, err, NO_MSG);
+ return ERROR_CODE(E_BUSY);
}
- err = UpdatePtrWhichPointOnCrntMdfNode(p_FmPcdCcNode, p_ModifyKeyParams, h_OldLst, h_NewLst);
- if(err)
+ err = BuildNewNodeModifyNextEngine(h_FmPcd, p_CcNode, keyIndex,
+ p_FmPcdCcNextEngineParams,
+ &h_OldPointersLst, &h_NewPointersLst,
+ p_ModifyKeyParams);
+ if (err)
{
- ReleaseNewNodeCommonPart(p_ModifyKeyParams);
XX_Free(p_ModifyKeyParams);
- RETURN_ERROR(MAJOR, err, NO_MSG);
+ if (p_CcNode->maxNumOfKeys)
+ RELEASE_LOCK(p_FmPcd->shadowLock);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
- return E_OK;
+ err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,
+ p_ModifyKeyParams, FALSE);
+
+ if (p_CcNode->maxNumOfKeys)
+ RELEASE_LOCK(p_FmPcd->shadowLock);
+
+ return err;
}
-t_Error FmPcdCcReleaseModifiedDataStructure(t_Handle h_FmPcd, t_List *h_FmPcdOldPointersLst, t_List *h_FmPcdNewPointersLst, uint16_t numOfGoodChanges, t_Handle *h_Params)
+t_Error FmPcdCcAddKey(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode,
+ uint16_t keyIndex, uint8_t keySize,
+ t_FmPcdCcKeyParams *p_FmPcdCcKeyParams)
{
- t_FmPcdModifyCcKeyAdditionalParams *p_CcNewModifyAdditionalParams = (t_FmPcdModifyCcKeyAdditionalParams *)*h_Params;
- t_List *p_Pos;
- t_Error err = E_OK;
- t_CcNodeInformation ccNodeInfo, *p_CcNodeInformation;
- t_Handle h_Muram;
- t_FmPcdCcNode *p_FmPcdCcNextNode;
- t_List *p_UpdateLst;
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
+ t_FmPcd *p_FmPcd;
+ t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;
+ t_List h_OldPointersLst, h_NewPointersLst;
+ bool useShadowStructs = FALSE;
+ uint16_t tmpKeyIndex;
+ t_Error err = E_OK;
+
+ if (keyIndex > p_CcNode->numOfKeys)
+ RETURN_ERROR(MAJOR, E_NOT_IN_RANGE,
+ ("keyIndex > previously cleared last index + 1"));
- UNUSED(numOfGoodChanges);
+ if (keySize != p_CcNode->userSizeOfExtraction)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("keySize has to be defined as it was defined in initialization step"));
- SANITY_CHECK_RETURN_ERROR(h_FmPcd,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_CcNewModifyAdditionalParams->h_CurrentNode,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(h_FmPcdOldPointersLst,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(h_FmPcdNewPointersLst,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR((numOfGoodChanges == LIST_NumOfObjs(h_FmPcdOldPointersLst)),E_INVALID_STATE);
- SANITY_CHECK_RETURN_ERROR((numOfGoodChanges == LIST_NumOfObjs(h_FmPcdNewPointersLst)),E_INVALID_STATE);
- SANITY_CHECK_RETURN_ERROR((LIST_NumOfObjs(h_FmPcdOldPointersLst) == LIST_NumOfObjs(h_FmPcdNewPointersLst)),E_INVALID_STATE);
+ if (p_CcNode->h_FmPcd != h_FmPcd)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("handler to FmPcd is different from the handle provided at node initialization time"));
- /*we don't update subtree of the new node with new tree because it was done in the previose stage*/
- if(p_CcNewModifyAdditionalParams->h_NodeForAdd)
+ if (p_CcNode->maxNumOfKeys)
{
- p_FmPcdCcNextNode = (t_FmPcdCcNode*)p_CcNewModifyAdditionalParams->h_NodeForAdd;
- if(!p_CcNewModifyAdditionalParams->tree)
- p_UpdateLst = &p_FmPcdCcNextNode->ccPrevNodesLst;
- else
- p_UpdateLst = &p_FmPcdCcNextNode->ccTreeIdLst;
- p_CcNodeInformation = FindNodeInfoInReleventLst(p_UpdateLst, p_CcNewModifyAdditionalParams->h_CurrentNode);
- if(p_CcNodeInformation)
- p_CcNodeInformation->index++;
- else
- {
- memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
- ccNodeInfo.h_CcNode = (t_Handle)p_CcNewModifyAdditionalParams->h_CurrentNode;
- ccNodeInfo.index = 1;
- EnqueueNodeInfoToRelevantLst(p_UpdateLst, &ccNodeInfo);
- }
+ if (p_CcNode->numOfKeys == p_CcNode->maxNumOfKeys)
+ RETURN_ERROR(
+ MAJOR,
+ E_FULL,
+ ("number of keys exceeds the maximal number of keys provided at node initialization time"));
}
+ else
+ if (p_CcNode->numOfKeys == FM_PCD_MAX_NUM_OF_KEYS)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("number of keys can not be larger than %d", FM_PCD_MAX_NUM_OF_KEYS));
+
+ err = FindKeyIndex(h_FmPcdCcNode, keySize, p_FmPcdCcKeyParams->p_Key,
+ p_FmPcdCcKeyParams->p_Mask, &tmpKeyIndex);
+ if (GET_ERROR_TYPE(err) != E_NOT_FOUND)
+ RETURN_ERROR(
+ MAJOR,
+ E_ALREADY_EXISTS,
+ ("The received key and mask pair was already found in the match table of the provided node"));
+
+ p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
+
+ INIT_LIST(&h_OldPointersLst);
+ INIT_LIST(&h_NewPointersLst);
+
+ p_ModifyKeyParams = ModifyNodeCommonPart(p_CcNode, keyIndex,
+ e_MODIFY_STATE_ADD, TRUE, TRUE,
+ FALSE);
+ if (!p_ModifyKeyParams)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
- if(p_CcNewModifyAdditionalParams->h_NodeForRmv)
+ if (p_CcNode->maxNumOfKeys)
{
-
- p_FmPcdCcNextNode = (t_FmPcdCcNode*)p_CcNewModifyAdditionalParams->h_NodeForRmv;
- if(!p_CcNewModifyAdditionalParams->tree)
+ if (!TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))
{
- p_UpdateLst = &p_FmPcdCcNextNode->ccPrevNodesLst;
- LIST_FOR_EACH(p_Pos, &p_FmPcdCcNextNode->ccTreesLst)
- {
- p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);
- ASSERT_COND(p_CcNodeInformation->h_CcNode);
- err = FmPcdCcSetRequiredAction(h_FmPcd,
- UPDATE_CC_WITH_DELETE_TREE,
- &((t_FmPcdCcNode *)(p_CcNewModifyAdditionalParams->h_CurrentNode))->nextEngineAndRequiredAction[p_CcNewModifyAdditionalParams->keyIndex],
- PTR_MOVE(((t_FmPcdCcNode *)(p_CcNewModifyAdditionalParams->h_CurrentNode))->h_AdTable, p_CcNewModifyAdditionalParams->keyIndex*FM_PCD_CC_AD_ENTRY_SIZE),
- 1,
- p_CcNodeInformation->h_CcNode);
- }
+ XX_Free(p_ModifyKeyParams);
+ return ERROR_CODE(E_BUSY);
}
- else
- {
- p_UpdateLst = &p_FmPcdCcNextNode->ccTreeIdLst;
- err = FmPcdCcSetRequiredAction(h_FmPcd,
- UPDATE_CC_WITH_DELETE_TREE,
- &((t_FmPcdCcTree *)(p_CcNewModifyAdditionalParams->h_CurrentNode))->nextEngineAndRequiredAction[p_CcNewModifyAdditionalParams->keyIndex],
- UINT_TO_PTR(((t_FmPcdCcTree *)(p_CcNewModifyAdditionalParams->h_CurrentNode))->ccTreeBaseAddr + p_CcNewModifyAdditionalParams->keyIndex*FM_PCD_CC_AD_ENTRY_SIZE),
- 1,
- p_CcNewModifyAdditionalParams->h_CurrentNode);
- }
- if(err)
- return err;
- /*we remove from the subtree of the removed node tree because it wasn't done in the previose stage*/
- /*update ccPrevNodesLst or ccTreeIdLst of the removed node*/
- /*update of the nodeOwner*/
- p_CcNodeInformation = FindNodeInfoInReleventLst(p_UpdateLst, p_CcNewModifyAdditionalParams->h_CurrentNode);
- ASSERT_COND(p_CcNodeInformation);
- ASSERT_COND(p_CcNodeInformation->index);
- p_CcNodeInformation->index--;
- if(p_CcNodeInformation->index == 0)
- DequeueNodeInfoFromRelevantLst(p_UpdateLst,p_CcNewModifyAdditionalParams->h_CurrentNode);
- ASSERT_COND(LIST_NumOfObjs(&p_FmPcdCcNextNode->ccTreesLst) == 1);
- UpdateNodeOwner(p_FmPcdCcNextNode, FALSE);
+ useShadowStructs = TRUE;
+ }
+
+ err = BuildNewNodeAddOrMdfyKeyAndNextEngine(h_FmPcd, p_CcNode, keyIndex,
+ p_FmPcdCcKeyParams,
+ p_ModifyKeyParams, TRUE);
+ if (err)
+ {
+ ReleaseNewNodeCommonPart(p_ModifyKeyParams);
+ XX_Free(p_ModifyKeyParams);
+ if (p_CcNode->maxNumOfKeys)
+ RELEASE_LOCK(p_FmPcd->shadowLock);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+
+ err = UpdatePtrWhichPointOnCrntMdfNode(p_CcNode, p_ModifyKeyParams,
+ &h_OldPointersLst,
+ &h_NewPointersLst);
+ if (err)
+ {
+ ReleaseNewNodeCommonPart(p_ModifyKeyParams);
+ XX_Free(p_ModifyKeyParams);
+ if (p_CcNode->maxNumOfKeys)
+ RELEASE_LOCK(p_FmPcd->shadowLock);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
-#ifdef FM_PCD_CC_MANIP
- if(p_CcNewModifyAdditionalParams->h_ManipForRmv)
- FmPcdManipUpdateOwner(p_CcNewModifyAdditionalParams->h_ManipForRmv, FALSE);
-#endif /* FM_PCD_CC_MANIP */
+ err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,
+ p_ModifyKeyParams, useShadowStructs);
+ if (p_CcNode->maxNumOfKeys)
+ RELEASE_LOCK(p_FmPcd->shadowLock);
+
+ return err;
+}
+
+t_Error FmPcdCcModifyKeyAndNextEngine(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode,
+ uint16_t keyIndex, uint8_t keySize,
+ t_FmPcdCcKeyParams *p_FmPcdCcKeyParams)
+{
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
+ t_FmPcd *p_FmPcd;
+ t_List h_OldPointersLst, h_NewPointersLst;
+ t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;
+ uint16_t tmpKeyIndex;
+ bool useShadowStructs = FALSE;
+ t_Error err = E_OK;
- h_Muram = FmPcdGetMuramHandle(h_FmPcd);
- ASSERT_COND(h_Muram);
+ if (keyIndex > p_CcNode->numOfKeys)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("keyIndex > previously cleared last index + 1"));
+
+ if (keySize != p_CcNode->userSizeOfExtraction)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("keySize has to be defined as it was defined in initialization step"));
+
+ if (p_CcNode->h_FmPcd != h_FmPcd)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("handler to FmPcd is different from the handle provided at node initialization time"));
+
+ err = FindKeyIndex(h_FmPcdCcNode, keySize, p_FmPcdCcKeyParams->p_Key,
+ p_FmPcdCcKeyParams->p_Mask, &tmpKeyIndex);
+ if (GET_ERROR_TYPE(err) != E_NOT_FOUND)
+ RETURN_ERROR(
+ MINOR,
+ E_ALREADY_EXISTS,
+ ("The received key and mask pair was already found in the match table of the provided node"));
+
+ p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
+
+ INIT_LIST(&h_OldPointersLst);
+ INIT_LIST(&h_NewPointersLst);
+
+ p_ModifyKeyParams = ModifyNodeCommonPart(p_CcNode, keyIndex,
+ e_MODIFY_STATE_CHANGE, TRUE, TRUE,
+ FALSE);
+ if (!p_ModifyKeyParams)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
- /*we release new AD which was allocated and updated for copy from to actual AD*/
- LIST_FOR_EACH(p_Pos, h_FmPcdNewPointersLst)
+ if (p_CcNode->maxNumOfKeys)
{
- p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);
- ASSERT_COND(p_CcNodeInformation->h_CcNode);
- FM_MURAM_FreeMem(h_Muram, p_CcNodeInformation->h_CcNode);
+ if (!TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))
+ {
+ XX_Free(p_ModifyKeyParams);
+ return ERROR_CODE(E_BUSY);
+ }
- }
+ useShadowStructs = TRUE;
+ }
- /*free Old data structure if it has to be freed - new data structure was allocated*/
- if(p_CcNewModifyAdditionalParams->p_AdTableOld)
- FM_MURAM_FreeMem(h_Muram,p_CcNewModifyAdditionalParams->p_AdTableOld);
- if(p_CcNewModifyAdditionalParams->p_KeysMatchTableOld)
- FM_MURAM_FreeMem(h_Muram,p_CcNewModifyAdditionalParams->p_KeysMatchTableOld);
+ err = BuildNewNodeAddOrMdfyKeyAndNextEngine(h_FmPcd, p_CcNode, keyIndex,
+ p_FmPcdCcKeyParams,
+ p_ModifyKeyParams, FALSE);
+ if (err)
+ {
+ ReleaseNewNodeCommonPart(p_ModifyKeyParams);
+ XX_Free(p_ModifyKeyParams);
+ if (p_CcNode->maxNumOfKeys)
+ RELEASE_LOCK(p_FmPcd->shadowLock);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
- /*update current modified node with changed fields if it's required*/
- if(!p_CcNewModifyAdditionalParams->tree)
+ err = UpdatePtrWhichPointOnCrntMdfNode(p_CcNode, p_ModifyKeyParams,
+ &h_OldPointersLst,
+ &h_NewPointersLst);
+ if (err)
{
- if(p_CcNewModifyAdditionalParams->p_AdTableNew)
- ((t_FmPcdCcNode *)(p_CcNewModifyAdditionalParams->h_CurrentNode))->h_AdTable = p_CcNewModifyAdditionalParams->p_AdTableNew;
- if(p_CcNewModifyAdditionalParams->numOfKeys)
- ((t_FmPcdCcNode *)(p_CcNewModifyAdditionalParams->h_CurrentNode))->numOfKeys = p_CcNewModifyAdditionalParams->numOfKeys;
- if(p_CcNewModifyAdditionalParams->p_KeysMatchTableNew)
- ((t_FmPcdCcNode *)(p_CcNewModifyAdditionalParams->h_CurrentNode))->h_KeysMatchTable = p_CcNewModifyAdditionalParams->p_KeysMatchTableNew;
- memcpy(((t_FmPcdCcNode *)(p_CcNewModifyAdditionalParams->h_CurrentNode))->nextEngineAndRequiredAction, &p_CcNewModifyAdditionalParams->nextEngineAndRequiredAction, sizeof(t_FmPcdCcNextEngineAndRequiredActionParams) * (FM_PCD_MAX_NUM_OF_KEYS));
+ ReleaseNewNodeCommonPart(p_ModifyKeyParams);
+ XX_Free(p_ModifyKeyParams);
+ if (p_CcNode->maxNumOfKeys)
+ RELEASE_LOCK(p_FmPcd->shadowLock);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
- else
- memcpy(&((t_FmPcdCcTree *)(p_CcNewModifyAdditionalParams->h_CurrentNode))->nextEngineAndRequiredAction, &p_CcNewModifyAdditionalParams->nextEngineAndRequiredAction, sizeof(t_FmPcdCcNextEngineAndRequiredActionParams) * (((t_FmPcdCcTree *)(p_CcNewModifyAdditionalParams->h_CurrentNode))->numOfEntries));
- ReleaseLst(h_FmPcdOldPointersLst);
- ReleaseLst(h_FmPcdNewPointersLst);
- XX_Free(p_CcNewModifyAdditionalParams);
+ err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,
+ p_ModifyKeyParams, useShadowStructs);
- return E_OK;
+ if (p_CcNode->maxNumOfKeys)
+ RELEASE_LOCK(p_FmPcd->shadowLock);
+
+ return err;
}
-uint32_t FmPcdCcGetNodeAddrOffsetFromNodeInfo(t_Handle h_FmPcd, t_Handle h_Pointer)
+uint32_t FmPcdCcGetNodeAddrOffsetFromNodeInfo(t_Handle h_FmPcd,
+ t_Handle h_Pointer)
{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- t_CcNodeInformation *p_CcNodeInfo;
+ t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ t_CcNodeInformation *p_CcNodeInfo;
- SANITY_CHECK_RETURN_VALUE(h_FmPcd,E_INVALID_HANDLE, (uint32_t)ILLEGAL_BASE);
+ SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE,
+ (uint32_t)ILLEGAL_BASE);
p_CcNodeInfo = CC_NODE_F_OBJECT(h_Pointer);
- return (uint32_t)(XX_VirtToPhys(p_CcNodeInfo->h_CcNode) - p_FmPcd->physicalMuramBase);
+
+ return (uint32_t)(XX_VirtToPhys(p_CcNodeInfo->h_CcNode)
+ - p_FmPcd->physicalMuramBase);
}
-t_Error FmPcdCcGetGrpParams(t_Handle h_FmPcdCcTree, uint8_t grpId, uint32_t *p_GrpBits, uint8_t *p_GrpBase)
+t_Error FmPcdCcGetGrpParams(t_Handle h_FmPcdCcTree, uint8_t grpId,
+ uint32_t *p_GrpBits, uint8_t *p_GrpBase)
{
- t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *) h_FmPcdCcTree;
+ t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;
SANITY_CHECK_RETURN_ERROR(h_FmPcdCcTree, E_INVALID_HANDLE);
- if(grpId >= p_FmPcdCcTree->numOfGrps)
- RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("grpId you asked > numOfGroup of relevant tree"));
+ if (grpId >= p_FmPcdCcTree->numOfGrps)
+ RETURN_ERROR(MAJOR, E_INVALID_HANDLE,
+ ("grpId you asked > numOfGroup of relevant tree"));
+
*p_GrpBits = p_FmPcdCcTree->fmPcdGroupParam[grpId].totalBitsMask;
*p_GrpBase = p_FmPcdCcTree->fmPcdGroupParam[grpId].baseGroupEntry;
+
return E_OK;
}
-t_Error FmPcdCcBindTree(t_Handle h_FmPcd, t_Handle h_FmPcdCcTree, uint32_t *p_Offset, t_Handle h_FmPort)
+t_Error FmPcdCcBindTree(t_Handle h_FmPcd, t_Handle h_PcdParams,
+ t_Handle h_FmPcdCcTree, uint32_t *p_Offset,
+ t_Handle h_FmPort)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;
- t_Error err = E_OK;
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(h_FmPcdCcTree, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcdCcTree,E_INVALID_STATE);
+ /* this routine must be protected by the calling routine by locking all PCD modules! */
- FmPcdCcUpdateTreeOwner(p_FmPcdCcTree, TRUE);
+ err = CcUpdateParams(h_FmPcd, h_PcdParams, h_FmPort, h_FmPcdCcTree, TRUE);
- *p_Offset = (uint32_t)(XX_VirtToPhys(UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr)) -
- p_FmPcd->physicalMuramBase);
+ if (err == E_OK)
+ UpdateCcRootOwner(p_FmPcdCcTree, TRUE);
- err = CcUpdateParams(h_FmPcd, h_FmPort, h_FmPcdCcTree, TRUE);
+ *p_Offset = (uint32_t)(XX_VirtToPhys(
+ UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr))
+ - p_FmPcd->physicalMuramBase);
return err;
}
-t_Error FmPcdCcUnbindTree(t_Handle h_FmPcd, t_Handle h_FmPcdCcTree)
+t_Error FmPcdCcUnbindTree(t_Handle h_FmPcd, t_Handle h_FmPcdCcTree)
{
- t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;
+ t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;
+
+ /* this routine must be protected by the calling routine by locking all PCD modules! */
UNUSED(h_FmPcd);
- SANITY_CHECK_RETURN_ERROR(p_FmPcdCcTree,E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(h_FmPcdCcTree, E_INVALID_HANDLE);
- FmPcdCcUpdateTreeOwner(p_FmPcdCcTree, FALSE);
+ UpdateCcRootOwner(p_FmPcdCcTree, FALSE);
return E_OK;
}
-t_Error FmPcdCcTreeTryLock(t_Handle h_FmPcdCcTree)
+t_Error FmPcdCcNodeTreeTryLock(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode,
+ t_List *p_List)
{
- if (TRY_LOCK(NULL, &((t_FmPcdCcTree *)h_FmPcdCcTree)->lock))
- return E_OK;
- return ERROR_CODE(E_BUSY);
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
+ t_List *p_Pos, *p_Tmp;
+ t_CcNodeInformation *p_CcNodeInfo, nodeInfo;
+ uint32_t intFlags;
+ t_Error err = E_OK;
+
+ intFlags = FmPcdLock(h_FmPcd);
+
+ NCSW_LIST_FOR_EACH(p_Pos, &p_CcNode->ccTreesLst)
+ {
+ p_CcNodeInfo = CC_NODE_F_OBJECT(p_Pos);
+ ASSERT_COND(p_CcNodeInfo->h_CcNode);
+
+ err = CcRootTryLock(p_CcNodeInfo->h_CcNode);
+
+ if (err)
+ {
+ NCSW_LIST_FOR_EACH(p_Tmp, &p_CcNode->ccTreesLst)
+ {
+ if (p_Tmp == p_Pos)
+ break;
+
+ CcRootReleaseLock(p_CcNodeInfo->h_CcNode);
+ }
+ break;
+ }
+
+ memset(&nodeInfo, 0, sizeof(t_CcNodeInformation));
+ nodeInfo.h_CcNode = p_CcNodeInfo->h_CcNode;
+ EnqueueNodeInfoToRelevantLst(p_List, &nodeInfo, NULL);
+ }
+
+ FmPcdUnlock(h_FmPcd, intFlags);
+ CORE_MemoryBarrier();
+
+ return err;
}
-t_Error FmPcdCcNodeTreeTryLock(t_Handle h_FmPcd,t_Handle h_FmPcdCcNode, t_List *p_List)
+void FmPcdCcNodeTreeReleaseLock(t_Handle h_FmPcd, t_List *p_List)
{
- t_FmPcdCcNode *p_FmPcdCcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;
- t_List *p_Pos;
- t_CcNodeInformation *p_CcNodeInfo, nodeInfo;
- t_Error err = E_OK;
+ t_List *p_Pos;
+ t_CcNodeInformation *p_CcNodeInfo;
+ t_Handle h_FmPcdCcTree;
+ uint32_t intFlags;
- UNUSED(h_FmPcd);
+ intFlags = FmPcdLock(h_FmPcd);
- if(LIST_IsEmpty(&p_FmPcdCcNode->ccTreesLst))
- RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("asked for more nodes in CC than MAX")) ;
- LIST_FOR_EACH(p_Pos, &p_FmPcdCcNode->ccTreesLst)
+ NCSW_LIST_FOR_EACH(p_Pos, p_List)
{
p_CcNodeInfo = CC_NODE_F_OBJECT(p_Pos);
- ASSERT_COND(p_CcNodeInfo->h_CcNode);
- err = FmPcdCcTreeTryLock(p_CcNodeInfo->h_CcNode);
- if(err == E_OK)
+ h_FmPcdCcTree = p_CcNodeInfo->h_CcNode;
+ CcRootReleaseLock(h_FmPcdCcTree);
+ }
+
+ ReleaseLst(p_List);
+
+ FmPcdUnlock(h_FmPcd, intFlags);
+ CORE_MemoryBarrier();
+}
+
+t_Error FmPcdUpdateCcShadow(t_FmPcd *p_FmPcd, uint32_t size, uint32_t align)
+{
+ uint32_t intFlags;
+ uint32_t newSize = 0, newAlign = 0;
+ bool allocFail = FALSE;
+
+ ASSERT_COND(p_FmPcd);
+
+ if (!size)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("size must be larger then 0"));
+
+ if (!POWER_OF_2(align))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("alignment must be power of 2"));
+
+ newSize = p_FmPcd->ccShadowSize;
+ newAlign = p_FmPcd->ccShadowAlign;
+
+ /* Check if current shadow is large enough to hold the requested size */
+ if (size > p_FmPcd->ccShadowSize)
+ newSize = size;
+
+ /* Check if current shadow matches the requested alignment */
+ if (align > p_FmPcd->ccShadowAlign)
+ newAlign = align;
+
+ /* If a bigger shadow size or bigger shadow alignment are required,
+ a new shadow will be allocated */
+ if ((newSize != p_FmPcd->ccShadowSize)
+ || (newAlign != p_FmPcd->ccShadowAlign))
+ {
+ intFlags = FmPcdLock(p_FmPcd);
+
+ if (p_FmPcd->p_CcShadow)
{
- memset(&nodeInfo, 0, sizeof(t_CcNodeInformation));
- nodeInfo.h_CcNode = p_CcNodeInfo->h_CcNode;
- EnqueueNodeInfoToRelevantLst(p_List, &nodeInfo);
+ FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_FmPcd), p_FmPcd->p_CcShadow);
+ p_FmPcd->ccShadowSize = 0;
+ p_FmPcd->ccShadowAlign = 0;
}
- else
- FmPcdCcNodeTreeReleaseLock(p_List);
+
+ p_FmPcd->p_CcShadow = FM_MURAM_AllocMem(FmPcdGetMuramHandle(p_FmPcd),
+ newSize, newAlign);
+ if (!p_FmPcd->p_CcShadow)
+ {
+ allocFail = TRUE;
+
+ /* If new shadow size allocation failed,
+ re-allocate with previous parameters */
+ p_FmPcd->p_CcShadow = FM_MURAM_AllocMem(
+ FmPcdGetMuramHandle(p_FmPcd), p_FmPcd->ccShadowSize,
+ p_FmPcd->ccShadowAlign);
+ }
+
+ FmPcdUnlock(p_FmPcd, intFlags);
+
+ if (allocFail)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("MURAM allocation for CC Shadow memory"));
+
+ p_FmPcd->ccShadowSize = newSize;
+ p_FmPcd->ccShadowAlign = newAlign;
}
- return err;
+ return E_OK;
+}
+
+#if (DPAA_VERSION >= 11)
+void FmPcdCcGetAdTablesThatPointOnReplicGroup(t_Handle h_Node,
+ t_Handle h_ReplicGroup,
+ t_List *p_AdTables,
+ uint32_t *p_NumOfAdTables)
+{
+ t_FmPcdCcNode *p_CurrentNode = (t_FmPcdCcNode *)h_Node;
+ int i = 0;
+ void * p_AdTable;
+ t_CcNodeInformation ccNodeInfo;
+
+ ASSERT_COND(h_Node);
+ *p_NumOfAdTables = 0;
+
+ /* search in the current node which exact index points on this current replicator group for getting AD */
+ for (i = 0; i < p_CurrentNode->numOfKeys + 1; i++)
+ {
+ if ((p_CurrentNode->keyAndNextEngineParams[i].nextEngineParams.nextEngine
+ == e_FM_PCD_FR)
+ && ((p_CurrentNode->keyAndNextEngineParams[i].nextEngineParams.params.frParams.h_FrmReplic
+ == (t_Handle)h_ReplicGroup)))
+ {
+ /* save the current ad table in the list */
+ /* this entry uses the input replicator group */
+ p_AdTable =
+ PTR_MOVE(p_CurrentNode->h_AdTable, i*FM_PCD_CC_AD_ENTRY_SIZE);
+ memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
+ ccNodeInfo.h_CcNode = p_AdTable;
+ EnqueueNodeInfoToRelevantLst(p_AdTables, &ccNodeInfo, NULL);
+ (*p_NumOfAdTables)++;
+ }
+ }
+
+ ASSERT_COND(i != p_CurrentNode->numOfKeys);
}
+#endif /* (DPAA_VERSION >= 11) */
+/*********************** End of inter-module routines ************************/
+
+/****************************************/
+/* API Init unit functions */
+/****************************************/
-t_Handle FM_PCD_CcBuildTree(t_Handle h_FmPcd, t_FmPcdCcTreeParams *p_PcdGroupsParam)
+t_Handle FM_PCD_CcRootBuild(t_Handle h_FmPcd,
+ t_FmPcdCcTreeParams *p_PcdGroupsParam)
{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- t_Error err = E_OK;
- int i = 0, j = 0, k = 0;
- t_FmPcdCcTree *p_FmPcdCcTree;
- uint8_t numOfEntries;
- t_Handle p_CcTreeTmp;
- t_FmPcdCcGrpParams *p_FmPcdCcGroupParams;
- t_FmPcdCcNextEngineAndRequiredActionParams params[16];
- t_NetEnvParams netEnvParams;
- uint8_t lastOne = 0;
- uint32_t requiredAction = 0;
- t_FmPcdCcNode *p_FmPcdCcNextNode;
- t_CcNodeInformation ccNodeInfo, *p_CcInformation;
+ t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ t_Error err = E_OK;
+ int i = 0, j = 0, k = 0;
+ t_FmPcdCcTree *p_FmPcdCcTree;
+ uint8_t numOfEntries;
+ t_Handle p_CcTreeTmp;
+ t_FmPcdCcGrpParams *p_FmPcdCcGroupParams;
+ t_FmPcdCcKeyAndNextEngineParams *p_Params, *p_KeyAndNextEngineParams;
+ t_NetEnvParams netEnvParams;
+ uint8_t lastOne = 0;
+ uint32_t requiredAction = 0;
+ t_FmPcdCcNode *p_FmPcdCcNextNode;
+ t_CcNodeInformation ccNodeInfo, *p_CcInformation;
- SANITY_CHECK_RETURN_VALUE(h_FmPcd,E_INVALID_HANDLE, NULL);
- SANITY_CHECK_RETURN_VALUE(p_PcdGroupsParam,E_INVALID_HANDLE, NULL);
+ SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, NULL);
+ SANITY_CHECK_RETURN_VALUE(p_PcdGroupsParam, E_INVALID_HANDLE, NULL);
if (p_PcdGroupsParam->numOfGrps > FM_PCD_MAX_NUM_OF_CC_GROUPS)
{
@@ -2788,44 +6018,77 @@ t_Handle FM_PCD_CcBuildTree(t_Handle h_FmPcd, t_FmPcdCcTreeParams *p_PcdGroupsPa
}
p_FmPcdCcTree = (t_FmPcdCcTree*)XX_Malloc(sizeof(t_FmPcdCcTree));
- if(!p_FmPcdCcTree)
+ if (!p_FmPcdCcTree)
{
REPORT_ERROR(MAJOR, E_NO_MEMORY, ("PCD tree structure"));
return NULL;
}
- memset(p_FmPcdCcTree, 0, sizeof(t_FmPcdCcTree)) ;
- memset(params, 0, 16 * sizeof(t_FmPcdCcNextEngineParams));
+ memset(p_FmPcdCcTree, 0, sizeof(t_FmPcdCcTree));
+ p_FmPcdCcTree->h_FmPcd = h_FmPcd;
+
+ p_Params = (t_FmPcdCcKeyAndNextEngineParams*)XX_Malloc(
+ FM_PCD_MAX_NUM_OF_CC_GROUPS
+ * sizeof(t_FmPcdCcKeyAndNextEngineParams));
+ memset(p_Params,
+ 0,
+ FM_PCD_MAX_NUM_OF_CC_GROUPS
+ * sizeof(t_FmPcdCcKeyAndNextEngineParams));
INIT_LIST(&p_FmPcdCcTree->fmPortsLst);
+#ifdef FM_CAPWAP_SUPPORT
+ if ((p_PcdGroupsParam->numOfGrps == 1) &&
+ (p_PcdGroupsParam->ccGrpParams[0].numOfDistinctionUnits == 0) &&
+ (p_PcdGroupsParam->ccGrpParams[0].nextEnginePerEntriesInGrp[0].nextEngine == e_FM_PCD_CC) &&
+ p_PcdGroupsParam->ccGrpParams[0].nextEnginePerEntriesInGrp[0].params.ccParams.h_CcNode &&
+ IsCapwapApplSpecific(p_PcdGroupsParam->ccGrpParams[0].nextEnginePerEntriesInGrp[0].params.ccParams.h_CcNode))
+ {
+ p_PcdGroupsParam->ccGrpParams[0].nextEnginePerEntriesInGrp[0].h_Manip = FmPcdManipApplSpecificBuild();
+ if (!p_PcdGroupsParam->ccGrpParams[0].nextEnginePerEntriesInGrp[0].h_Manip)
+ {
+ DeleteTree(p_FmPcdCcTree,p_FmPcd);
+ XX_Free(p_Params);
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
+ return NULL;
+ }
+ }
+#endif /* FM_CAPWAP_SUPPORT */
+
numOfEntries = 0;
- p_FmPcdCcTree->netEnvId = (uint8_t)(PTR_TO_UINT(p_PcdGroupsParam->h_NetEnv)-1);
- for(i = 0; i < p_PcdGroupsParam->numOfGrps; i++)
+ p_FmPcdCcTree->netEnvId = FmPcdGetNetEnvId(p_PcdGroupsParam->h_NetEnv);
+
+ for (i = 0; i < p_PcdGroupsParam->numOfGrps; i++)
{
p_FmPcdCcGroupParams = &p_PcdGroupsParam->ccGrpParams[i];
- if (p_FmPcdCcGroupParams->numOfDistinctionUnits > FM_PCD_MAX_NUM_OF_CC_UNITS)
+ if (p_FmPcdCcGroupParams->numOfDistinctionUnits
+ > FM_PCD_MAX_NUM_OF_CC_UNITS)
{
- DeleteTree(p_FmPcdCcTree,p_FmPcd);
+ DeleteTree(p_FmPcdCcTree, p_FmPcd);
+ XX_Free(p_Params);
REPORT_ERROR(MAJOR, E_INVALID_VALUE,
- ("numOfDistinctionUnits (group %d) should not exceed %d", i, FM_PCD_MAX_NUM_OF_CC_UNITS));
+ ("numOfDistinctionUnits (group %d) should not exceed %d", i, FM_PCD_MAX_NUM_OF_CC_UNITS));
return NULL;
}
p_FmPcdCcTree->fmPcdGroupParam[i].baseGroupEntry = numOfEntries;
- p_FmPcdCcTree->fmPcdGroupParam[i].numOfEntriesInGroup =(uint8_t)( 0x01 << p_FmPcdCcGroupParams->numOfDistinctionUnits);
+ p_FmPcdCcTree->fmPcdGroupParam[i].numOfEntriesInGroup = (uint8_t)(0x01
+ << p_FmPcdCcGroupParams->numOfDistinctionUnits);
numOfEntries += p_FmPcdCcTree->fmPcdGroupParam[i].numOfEntriesInGroup;
- if(numOfEntries > 16)
+ if (numOfEntries > FM_PCD_MAX_NUM_OF_CC_GROUPS)
{
- DeleteTree(p_FmPcdCcTree,p_FmPcd);
- REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("numOfEntries can not be larger than 16"));
+ DeleteTree(p_FmPcdCcTree, p_FmPcd);
+ XX_Free(p_Params);
+ REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("numOfEntries can not be larger than %d", FM_PCD_MAX_NUM_OF_CC_GROUPS));
return NULL;
}
- if(lastOne)
+
+ if (lastOne)
{
- if(p_FmPcdCcTree->fmPcdGroupParam[i].numOfEntriesInGroup > lastOne)
+ if (p_FmPcdCcTree->fmPcdGroupParam[i].numOfEntriesInGroup > lastOne)
{
- DeleteTree(p_FmPcdCcTree,p_FmPcd);
+ DeleteTree(p_FmPcdCcTree, p_FmPcd);
+ XX_Free(p_Params);
REPORT_ERROR(MAJOR, E_CONFLICT, ("numOfEntries per group must be set in descending order"));
return NULL;
}
@@ -2834,112 +6097,160 @@ t_Handle FM_PCD_CcBuildTree(t_Handle h_FmPcd, t_FmPcdCcTreeParams *p_PcdGroupsPa
lastOne = p_FmPcdCcTree->fmPcdGroupParam[i].numOfEntriesInGroup;
netEnvParams.netEnvId = p_FmPcdCcTree->netEnvId;
- netEnvParams.numOfDistinctionUnits = p_FmPcdCcGroupParams->numOfDistinctionUnits;
- memcpy(netEnvParams.unitIds, &p_FmPcdCcGroupParams->unitIds, (sizeof(uint8_t)) * p_FmPcdCcGroupParams->numOfDistinctionUnits);
+ netEnvParams.numOfDistinctionUnits =
+ p_FmPcdCcGroupParams->numOfDistinctionUnits;
+
+ memcpy(netEnvParams.unitIds, &p_FmPcdCcGroupParams->unitIds,
+ (sizeof(uint8_t)) * p_FmPcdCcGroupParams->numOfDistinctionUnits);
+
err = PcdGetUnitsVector(p_FmPcd, &netEnvParams);
- if(err)
+ if (err)
{
- DeleteTree(p_FmPcdCcTree,p_FmPcd);
+ DeleteTree(p_FmPcdCcTree, p_FmPcd);
+ XX_Free(p_Params);
REPORT_ERROR(MAJOR, err, NO_MSG);
return NULL;
}
p_FmPcdCcTree->fmPcdGroupParam[i].totalBitsMask = netEnvParams.vector;
- for(j = 0; j < p_FmPcdCcTree->fmPcdGroupParam[i].numOfEntriesInGroup; j++)
+ for (j = 0; j < p_FmPcdCcTree->fmPcdGroupParam[i].numOfEntriesInGroup;
+ j++)
{
- err = ValidateNextEngineParams(h_FmPcd,&p_FmPcdCcGroupParams->nextEnginePerEntriesInGrp[j]);
- if(err)
+ err = ValidateNextEngineParams(
+ h_FmPcd,
+ &p_FmPcdCcGroupParams->nextEnginePerEntriesInGrp[j],
+ e_FM_PCD_CC_STATS_MODE_NONE);
+ if (err)
{
- DeleteTree(p_FmPcdCcTree,p_FmPcd);
+ DeleteTree(p_FmPcdCcTree, p_FmPcd);
+ XX_Free(p_Params);
REPORT_ERROR(MAJOR, err, (NO_MSG));
return NULL;
}
-#ifdef FM_PCD_CC_MANIP
- if(p_FmPcdCcGroupParams->nextEnginePerEntriesInGrp[j].h_Manip)
+ if (p_FmPcdCcGroupParams->nextEnginePerEntriesInGrp[j].h_Manip)
{
- err = FmPcdManipCheckParamsForCcNextEgine(&p_FmPcdCcGroupParams->nextEnginePerEntriesInGrp[j], &requiredAction);
- if(err)
+ err = FmPcdManipCheckParamsForCcNextEngine(
+ &p_FmPcdCcGroupParams->nextEnginePerEntriesInGrp[j],
+ &requiredAction);
+ if (err)
{
- DeleteTree(p_FmPcdCcTree,p_FmPcd);
+ DeleteTree(p_FmPcdCcTree, p_FmPcd);
+ XX_Free(p_Params);
REPORT_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
return NULL;
}
- }
-#endif /* FM_PCD_CC_MANIP */
+ }
+ p_KeyAndNextEngineParams = p_Params + k;
+
+ memcpy(&p_KeyAndNextEngineParams->nextEngineParams,
+ &p_FmPcdCcGroupParams->nextEnginePerEntriesInGrp[j],
+ sizeof(t_FmPcdCcNextEngineParams));
+
+ if ((p_KeyAndNextEngineParams->nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
+ && p_KeyAndNextEngineParams->nextEngineParams.h_Manip)
+ {
+ err =
+ AllocAndFillAdForContLookupManip(
+ p_KeyAndNextEngineParams->nextEngineParams.params.ccParams.h_CcNode);
+ if (err)
+ {
+ DeleteTree(p_FmPcdCcTree, p_FmPcd);
+ XX_Free(p_Params);
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for CC Tree"));
+ return NULL;
+ }
+ }
+
+ requiredAction |= UPDATE_CC_WITH_TREE;
+ p_KeyAndNextEngineParams->requiredAction = requiredAction;
- memcpy(&params[k].nextEngineParams, &p_FmPcdCcGroupParams->nextEnginePerEntriesInGrp[j], sizeof(t_FmPcdCcNextEngineParams));
- requiredAction |= UPDATE_CC_WITH_TREE;
- params[k].requiredAction = requiredAction;
- k++;
+ k++;
}
}
p_FmPcdCcTree->numOfEntries = (uint8_t)k;
p_FmPcdCcTree->numOfGrps = p_PcdGroupsParam->numOfGrps;
- p_FmPcdCcTree->ccTreeBaseAddr =
- PTR_TO_UINT(FM_MURAM_AllocMem(FmPcdGetMuramHandle(h_FmPcd),
- (uint32_t)( k * FM_PCD_CC_AD_ENTRY_SIZE),
- FM_PCD_CC_AD_TABLE_ALIGN));
- if(!p_FmPcdCcTree->ccTreeBaseAddr)
+ p_FmPcdCcTree->ccTreeBaseAddr =
+ PTR_TO_UINT(FM_MURAM_AllocMem(FmPcdGetMuramHandle(h_FmPcd),
+ (uint32_t)( FM_PCD_MAX_NUM_OF_CC_GROUPS * FM_PCD_CC_AD_ENTRY_SIZE),
+ FM_PCD_CC_TREE_ADDR_ALIGN));
+ if (!p_FmPcdCcTree->ccTreeBaseAddr)
{
- DeleteTree(p_FmPcdCcTree,p_FmPcd);
- REPORT_ERROR(MAJOR, E_NO_MEMORY, ("No memory"));
+ DeleteTree(p_FmPcdCcTree, p_FmPcd);
+ XX_Free(p_Params);
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for CC Tree"));
return NULL;
}
- IOMemSet32(UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr), 0, (uint32_t)(k * FM_PCD_CC_AD_ENTRY_SIZE));
+ MemSet8(
+ UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr), 0,
+ (uint32_t)(FM_PCD_MAX_NUM_OF_CC_GROUPS * FM_PCD_CC_AD_ENTRY_SIZE));
p_CcTreeTmp = UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr);
- j = 0;
- for(i = 0; i < numOfEntries; i++)
+ for (i = 0; i < numOfEntries; i++)
{
- NextStepAd(p_CcTreeTmp,&params[i].nextEngineParams,p_FmPcd);
+ p_KeyAndNextEngineParams = p_Params + i;
+
+ NextStepAd(p_CcTreeTmp, NULL,
+ &p_KeyAndNextEngineParams->nextEngineParams, p_FmPcd);
+
p_CcTreeTmp = PTR_MOVE(p_CcTreeTmp, FM_PCD_CC_AD_ENTRY_SIZE);
- memcpy(&p_FmPcdCcTree->nextEngineAndRequiredAction[i], &params[i], sizeof(t_FmPcdCcNextEngineAndRequiredActionParams));
- if(p_FmPcdCcTree->nextEngineAndRequiredAction[i].nextEngineParams.nextEngine== e_FM_PCD_CC)
+
+ memcpy(&p_FmPcdCcTree->keyAndNextEngineParams[i],
+ p_KeyAndNextEngineParams,
+ sizeof(t_FmPcdCcKeyAndNextEngineParams));
+
+ if (p_FmPcdCcTree->keyAndNextEngineParams[i].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
{
- p_FmPcdCcNextNode = (t_FmPcdCcNode*)p_FmPcdCcTree->nextEngineAndRequiredAction[i].nextEngineParams.params.ccParams.h_CcNode;
- if(!IsNodeInModifiedState((t_Handle)p_FmPcdCcNextNode))
+ p_FmPcdCcNextNode =
+ (t_FmPcdCcNode*)p_FmPcdCcTree->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode;
+ p_CcInformation = FindNodeInfoInReleventLst(
+ &p_FmPcdCcNextNode->ccTreeIdLst, (t_Handle)p_FmPcdCcTree,
+ p_FmPcdCcNextNode->h_Spinlock);
+
+ if (!p_CcInformation)
{
memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
ccNodeInfo.h_CcNode = (t_Handle)p_FmPcdCcTree;
ccNodeInfo.index = 1;
- EnqueueNodeInfoToRelevantLst(&p_FmPcdCcNextNode->ccTreeIdLst, &ccNodeInfo);
- UpdateNodeWithModifiedState((t_Handle)p_FmPcdCcNextNode, TRUE);
+ EnqueueNodeInfoToRelevantLst(&p_FmPcdCcNextNode->ccTreeIdLst,
+ &ccNodeInfo,
+ p_FmPcdCcNextNode->h_Spinlock);
}
else
- {
- p_CcInformation = FindNodeInfoInReleventLst(&p_FmPcdCcNextNode->ccTreeIdLst,(t_Handle)p_FmPcdCcTree);
- ASSERT_COND(p_CcInformation);
p_CcInformation->index++;
- }
}
}
FmPcdIncNetEnvOwners(h_FmPcd, p_FmPcdCcTree->netEnvId);
p_CcTreeTmp = UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr);
- for(i = 0; i < p_FmPcdCcTree->numOfEntries ; i++)
+ if (!FmPcdLockTryLockAll(p_FmPcd))
{
- if(p_FmPcdCcTree->nextEngineAndRequiredAction[i].nextEngineParams.nextEngine == e_FM_PCD_CC)
- {
- p_FmPcdCcNextNode = (t_FmPcdCcNode*)p_FmPcdCcTree->nextEngineAndRequiredAction[i].nextEngineParams.params.ccParams.h_CcNode;
-
- if(IsNodeInModifiedState((t_Handle)p_FmPcdCcNextNode))
- UpdateNodeWithModifiedState((t_Handle)p_FmPcdCcNextNode, FALSE);
- }
+ FM_PCD_CcRootDelete(p_FmPcdCcTree);
+ XX_Free(p_Params);
+ DBG(TRACE, ("FmPcdLockTryLockAll failed"));
+ return NULL;
}
- for(i = 0; i < numOfEntries; i++)
+ for (i = 0; i < numOfEntries; i++)
{
- if(p_FmPcdCcTree->nextEngineAndRequiredAction[i].requiredAction)
+ if (p_FmPcdCcTree->keyAndNextEngineParams[i].requiredAction)
{
- err = FmPcdCcSetRequiredAction(h_FmPcd, p_FmPcdCcTree->nextEngineAndRequiredAction[i].requiredAction, &p_FmPcdCcTree->nextEngineAndRequiredAction[i], p_CcTreeTmp,1, p_FmPcdCcTree);
- if(err)
+ err = SetRequiredAction(
+ h_FmPcd,
+ p_FmPcdCcTree->keyAndNextEngineParams[i].requiredAction,
+ &p_FmPcdCcTree->keyAndNextEngineParams[i], p_CcTreeTmp, 1,
+ p_FmPcdCcTree);
+ if (err)
{
- DeleteTree(p_FmPcdCcTree,p_FmPcd);
+ FmPcdLockUnlockAll(p_FmPcd);
+ FM_PCD_CcRootDelete(p_FmPcdCcTree);
+ XX_Free(p_Params);
REPORT_ERROR(MAJOR, E_NO_MEMORY, ("No memory"));
return NULL;
}
@@ -2947,521 +6258,1294 @@ t_Handle FM_PCD_CcBuildTree(t_Handle h_FmPcd, t_FmPcdCcTreeParams *p_PcdGroupsPa
}
}
+ FmPcdLockUnlockAll(p_FmPcd);
+ p_FmPcdCcTree->p_Lock = FmPcdAcquireLock(p_FmPcd);
+ if (!p_FmPcdCcTree->p_Lock)
+ {
+ FM_PCD_CcRootDelete(p_FmPcdCcTree);
+ XX_Free(p_Params);
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM CC lock"));
+ return NULL;
+ }
+
+ XX_Free(p_Params);
+
return p_FmPcdCcTree;
}
-t_Error FM_PCD_CcDeleteTree(t_Handle h_FmPcd, t_Handle h_CcTree)
+t_Error FM_PCD_CcRootDelete(t_Handle h_CcTree)
{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- t_FmPcdCcTree *p_CcTree = (t_FmPcdCcTree *)h_CcTree;
- int i= 0;
+ t_FmPcd *p_FmPcd;
+ t_FmPcdCcTree *p_CcTree = (t_FmPcdCcTree *)h_CcTree;
+ int i = 0;
+ SANITY_CHECK_RETURN_ERROR(p_CcTree, E_INVALID_STATE);
+ p_FmPcd = (t_FmPcd *)p_CcTree->h_FmPcd;
SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_CcTree,E_INVALID_STATE);
- FmPcdDecNetEnvOwners(h_FmPcd, p_CcTree->netEnvId);
+ FmPcdDecNetEnvOwners(p_FmPcd, p_CcTree->netEnvId);
- if(p_CcTree->owners)
- RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("the tree with this ID can not be removed because this tree is occupied, first - unbind this tree"));
+ if (p_CcTree->owners)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_SELECTION,
+ ("the tree with this ID can not be removed because this tree is occupied, first - unbind this tree"));
+
+ /* Delete ip-reassembly schemes if exist */
+ if (p_CcTree->h_IpReassemblyManip)
+ {
+ FmPcdManipDeleteIpReassmSchemes(p_CcTree->h_IpReassemblyManip);
+ FmPcdManipUpdateOwner(p_CcTree->h_IpReassemblyManip, FALSE);
+ }
- for(i = 0; i <p_CcTree->numOfEntries; i++)
+ /* Delete capwap-reassembly schemes if exist */
+ if (p_CcTree->h_CapwapReassemblyManip)
{
- if(p_CcTree->nextEngineAndRequiredAction[i].nextEngineParams.nextEngine == e_FM_PCD_CC)
- UpdateNodeOwner(p_CcTree->nextEngineAndRequiredAction[i].nextEngineParams.params.ccParams.h_CcNode, FALSE);
+ FmPcdManipDeleteCapwapReassmSchemes(p_CcTree->h_CapwapReassemblyManip);
+ FmPcdManipUpdateOwner(p_CcTree->h_CapwapReassemblyManip, FALSE);
}
-#ifdef FM_PCD_CC_MANIP
- for(i = 0; i < p_CcTree->numOfEntries; i++)
+ for (i = 0; i < p_CcTree->numOfEntries; i++)
{
- if(p_CcTree->nextEngineAndRequiredAction[i].nextEngineParams.h_Manip)
- FmPcdManipUpdateOwner(p_CcTree->nextEngineAndRequiredAction[i].nextEngineParams.h_Manip, FALSE);
+ if (p_CcTree->keyAndNextEngineParams[i].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
+ UpdateNodeOwner(
+ p_CcTree->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode,
+ FALSE);
+
+ if (p_CcTree->keyAndNextEngineParams[i].nextEngineParams.h_Manip)
+ FmPcdManipUpdateOwner(
+ p_CcTree->keyAndNextEngineParams[i].nextEngineParams.h_Manip,
+ FALSE);
+
+#ifdef FM_CAPWAP_SUPPORT
+ if ((p_CcTree->numOfGrps == 1) &&
+ (p_CcTree->fmPcdGroupParam[0].numOfEntriesInGroup == 1) &&
+ (p_CcTree->keyAndNextEngineParams[0].nextEngineParams.nextEngine == e_FM_PCD_CC) &&
+ p_CcTree->keyAndNextEngineParams[0].nextEngineParams.params.ccParams.h_CcNode &&
+ IsCapwapApplSpecific(p_CcTree->keyAndNextEngineParams[0].nextEngineParams.params.ccParams.h_CcNode))
+ {
+ if (FM_PCD_ManipNodeDelete(p_CcTree->keyAndNextEngineParams[0].nextEngineParams.h_Manip) != E_OK)
+ return E_INVALID_STATE;
+ }
+#endif /* FM_CAPWAP_SUPPORT */
+
+#if (DPAA_VERSION >= 11)
+ if ((p_CcTree->keyAndNextEngineParams[i].nextEngineParams.nextEngine
+ == e_FM_PCD_FR)
+ && (p_CcTree->keyAndNextEngineParams[i].nextEngineParams.params.frParams.h_FrmReplic))
+ FrmReplicGroupUpdateOwner(
+ p_CcTree->keyAndNextEngineParams[i].nextEngineParams.params.frParams.h_FrmReplic,
+ FALSE);
+#endif /* (DPAA_VERSION >= 11) */
}
-#endif /* FM_PCD_CC_MANIP */
+
+ if (p_CcTree->p_Lock)
+ FmPcdReleaseLock(p_CcTree->h_FmPcd, p_CcTree->p_Lock);
DeleteTree(p_CcTree, p_FmPcd);
+
return E_OK;
}
-t_Handle FM_PCD_CcSetNode(t_Handle h_FmPcd, t_FmPcdCcNodeParams *p_CcNodeParam)
+t_Error FM_PCD_CcRootModifyNextEngine(
+ t_Handle h_CcTree, uint8_t grpId, uint8_t index,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
{
- t_FmPcd *p_FmPcd = (t_FmPcd *) h_FmPcd;
- t_FmPcdCcNode *p_FmPcdCcNode, *p_FmPcdCcNextNode;
- t_Error err = E_OK;
- int tmp, size;
- bool glblMask = FALSE;
- t_FmPcdCcKeyParams *p_KeyParams;
- t_Handle p_KeysMatchTblTmp;
- t_Handle p_AdTableTmp;
- bool fullField = FALSE;
- ccPrivateInfo_t icCode = CC_PRIVATE_INFO_NONE;
- bool isKeyTblAlloc, fromIc = FALSE;
- t_CcNodeInformation ccNodeInfo, *p_CcInformation;
+ t_FmPcd *p_FmPcd;
+ t_FmPcdCcTree *p_CcTree = (t_FmPcdCcTree *)h_CcTree;
+ t_Error err = E_OK;
- SANITY_CHECK_RETURN_VALUE(h_FmPcd,E_INVALID_HANDLE,NULL);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_CcTree, E_INVALID_STATE);
+ p_FmPcd = (t_FmPcd *)p_CcTree->h_FmPcd;
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- /*
- if (!p_CcNodeParam->keysParams.keySize ||
- !p_CcNodeParam->keysParams.numOfKeys)
+ if (!FmPcdLockTryLockAll(p_FmPcd))
{
- REPORT_ERROR(MAJOR, E_INVALID_STATE, ("At least one key of keySize > 0 must be defined."));
- return NULL;
+ DBG(TRACE, ("FmPcdLockTryLockAll failed"));
+ return ERROR_CODE(E_BUSY);
+ }
+
+ err = FmPcdCcModifyNextEngineParamTree(p_FmPcd, p_CcTree, grpId, index,
+ p_FmPcdCcNextEngineParams);
+ FmPcdLockUnlockAll(p_FmPcd);
+
+ if (err)
+ {
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
- */
- p_FmPcdCcNode = (t_FmPcdCcNode*)XX_Malloc(sizeof(t_FmPcdCcNode));
- if(!p_FmPcdCcNode)
+
+ return E_OK;
+}
+
+t_Handle FM_PCD_MatchTableSet(t_Handle h_FmPcd,
+ t_FmPcdCcNodeParams *p_CcNodeParam)
+{
+ t_FmPcdCcNode *p_CcNode;
+ t_Error err;
+
+ SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, NULL);
+ SANITY_CHECK_RETURN_VALUE(p_CcNodeParam, E_NULL_POINTER, NULL);
+
+ p_CcNode = (t_FmPcdCcNode*)XX_Malloc(sizeof(t_FmPcdCcNode));
+ if (!p_CcNode)
{
REPORT_ERROR(MAJOR, E_NO_MEMORY, ("No memory"));
return NULL;
}
- memset(p_FmPcdCcNode, 0, sizeof(t_FmPcdCcNode));
+ memset(p_CcNode, 0, sizeof(t_FmPcdCcNode));
- p_FmPcdCcNode->p_GlblMask = (t_Handle)XX_Malloc(CC_GLBL_MASK_SIZE * sizeof(uint8_t));
- memset(p_FmPcdCcNode->p_GlblMask, 0, CC_GLBL_MASK_SIZE * sizeof(uint8_t));
+ err = MatchTableSet(h_FmPcd, p_CcNode, p_CcNodeParam);
- p_FmPcdCcNode->numOfKeys = p_CcNodeParam->keysParams.numOfKeys;
+ switch(GET_ERROR_TYPE(err)
+) {
+ case E_OK:
+ break;
- p_FmPcdCcNode->h_FmPcd = h_FmPcd;
+ case E_BUSY:
+ DBG(TRACE, ("E_BUSY error"));
+ return NULL;
- INIT_LIST(&p_FmPcdCcNode->ccPrevNodesLst);
- INIT_LIST(&p_FmPcdCcNode->ccTreeIdLst);
- INIT_LIST(&p_FmPcdCcNode->ccTreesLst);
+ default:
+ REPORT_ERROR(MAJOR, err, NO_MSG);
+ return NULL;
+ }
- if((p_CcNodeParam->extractCcParams.type == e_FM_PCD_EXTRACT_BY_HDR) &&
- ((p_CcNodeParam->extractCcParams.extractByHdr.hdr == HEADER_TYPE_IPv4) ||
- (p_CcNodeParam->extractCcParams.extractByHdr.hdr == HEADER_TYPE_IPv6)) &&
- (p_CcNodeParam->extractCcParams.extractByHdr.type == e_FM_PCD_EXTRACT_FULL_FIELD) &&
- ((p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fullField.ipv6 == NET_HEADER_FIELD_IPv6_HOP_LIMIT) ||
- (p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fullField.ipv4 == NET_HEADER_FIELD_IPv4_TTL)))
- {
- err = Ipv4TtlOrIpv6HopLimiCheckParams(h_FmPcd, p_CcNodeParam, p_FmPcdCcNode, &isKeyTblAlloc);
- glblMask = FALSE;
+ return p_CcNode;
+}
- }
- else if((p_CcNodeParam->extractCcParams.type == e_FM_PCD_EXTRACT_NON_HDR) &&
- ((p_CcNodeParam->extractCcParams.extractNonHdr.src == e_FM_PCD_EXTRACT_FROM_KEY) ||
- (p_CcNodeParam->extractCcParams.extractNonHdr.src == e_FM_PCD_EXTRACT_FROM_HASH) ||
- (p_CcNodeParam->extractCcParams.extractNonHdr.src == e_FM_PCD_EXTRACT_FROM_FLOW_ID)))
+t_Error FM_PCD_MatchTableDelete(t_Handle h_CcNode)
+{
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+ int i = 0;
+
+ SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_CcNode->h_FmPcd, E_INVALID_HANDLE);
+
+ if (p_CcNode->owners)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("This node cannot be removed because it is occupied; first unbind this node"));
+
+ for (i = 0; i < p_CcNode->numOfKeys; i++)
+ if (p_CcNode->keyAndNextEngineParams[i].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
+ UpdateNodeOwner(
+ p_CcNode->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode,
+ FALSE);
+
+ if (p_CcNode->keyAndNextEngineParams[i].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
+ UpdateNodeOwner(
+ p_CcNode->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode,
+ FALSE);
+
+ /* Handle also Miss entry */
+ for (i = 0; i < p_CcNode->numOfKeys + 1; i++)
{
- if((p_CcNodeParam->extractCcParams.extractNonHdr.src == e_FM_PCD_EXTRACT_FROM_FLOW_ID) &&
- (p_CcNodeParam->extractCcParams.extractNonHdr.offset != 0))
+ if (p_CcNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip)
+ FmPcdManipUpdateOwner(
+ p_CcNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip,
+ FALSE);
+
+#if (DPAA_VERSION >= 11)
+ if ((p_CcNode->keyAndNextEngineParams[i].nextEngineParams.nextEngine
+ == e_FM_PCD_FR)
+ && (p_CcNode->keyAndNextEngineParams[i].nextEngineParams.params.frParams.h_FrmReplic))
{
- REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("In the case of the extraction from e_FM_PCD_EXTRACT_FROM_FLOW_ID offset has to be 0"));
- return NULL;
+ FrmReplicGroupUpdateOwner(
+ p_CcNode->keyAndNextEngineParams[i].nextEngineParams.params.frParams.h_FrmReplic,
+ FALSE);
}
+#endif /* (DPAA_VERSION >= 11) */
+ }
- icCode = IcDefineCode(p_CcNodeParam);
- fromIc = TRUE;
- if(icCode == CC_PRIVATE_INFO_NONE)
- {
- REPORT_ERROR(MAJOR, E_INVALID_STATE, ("user asked extraction from IC and field in internal context or action wasn't initialized in the right way"));
- return NULL;
- }
+ DeleteNode(p_CcNode);
- if((icCode == CC_PRIVATE_INFO_IC_DEQ_FQID_INDEX_LOOKUP) || (icCode == CC_PRIVATE_INFO_IC_HASH_INDEX_LOOKUP))
- {
- err = IcHashIndexedCheckParams(h_FmPcd, p_CcNodeParam, p_FmPcdCcNode, &isKeyTblAlloc);
+ return E_OK;
+}
- glblMask = TRUE;
- }
- else
- {
- err = CheckParams(h_FmPcd, p_CcNodeParam,p_FmPcdCcNode, &isKeyTblAlloc);
- if(p_FmPcdCcNode->glblMaskSize)
- glblMask = TRUE;
- }
- }
- else
+t_Error FM_PCD_MatchTableAddKey(t_Handle h_CcNode, uint16_t keyIndex,
+ uint8_t keySize,
+ t_FmPcdCcKeyParams *p_KeyParams)
+{
+ t_FmPcd *p_FmPcd;
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_KeyParams, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
+ p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
+
+ if (keyIndex == FM_PCD_LAST_KEY_INDEX)
+ keyIndex = p_CcNode->numOfKeys;
+
+ if (!FmPcdLockTryLockAll(p_FmPcd))
{
- err = CheckParams(h_FmPcd, p_CcNodeParam,p_FmPcdCcNode, &isKeyTblAlloc);
- if(p_FmPcdCcNode->glblMaskSize)
- glblMask = TRUE;
+ DBG(TRACE, ("FmPcdLockTryLockAll failed"));
+ return ERROR_CODE(E_BUSY);
}
- if(err)
- {
- DeleteNode(p_FmPcdCcNode);
- REPORT_ERROR(MAJOR, err, NO_MSG);
- return NULL;
+ err = FmPcdCcAddKey(p_FmPcd, p_CcNode, keyIndex, keySize, p_KeyParams);
+
+ FmPcdLockUnlockAll(p_FmPcd);
+
+ switch(GET_ERROR_TYPE(err)
+) {
+ case E_OK:
+ return E_OK;
+
+ case E_BUSY:
+ DBG(TRACE, ("E_BUSY error"));
+ return ERROR_CODE(E_BUSY);
+
+ default:
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
+}
- switch(p_CcNodeParam->extractCcParams.type)
+t_Error FM_PCD_MatchTableRemoveKey(t_Handle h_CcNode, uint16_t keyIndex)
+{
+ t_FmPcd *p_FmPcd;
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
+ p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
+
+ if (!FmPcdLockTryLockAll(p_FmPcd))
{
- case(e_FM_PCD_EXTRACT_BY_HDR):
- switch(p_CcNodeParam->extractCcParams.extractByHdr.type)
- {
- case(e_FM_PCD_EXTRACT_FULL_FIELD):
- p_FmPcdCcNode->parseCode = GetFullFieldParseCode(p_CcNodeParam->extractCcParams.extractByHdr.hdr, p_CcNodeParam->extractCcParams.extractByHdr.hdrIndex,
- p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fullField);
- GetSizeHeaderField(p_CcNodeParam->extractCcParams.extractByHdr.hdr, p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fullField, &p_FmPcdCcNode->sizeOfExtraction);
- fullField = TRUE;
- if((p_FmPcdCcNode->parseCode != CC_PC_FF_TCI1) && (p_FmPcdCcNode->parseCode != CC_PC_FF_TCI2) &&
- (p_FmPcdCcNode->parseCode != CC_PC_FF_MPLS1) && (p_FmPcdCcNode->parseCode != CC_PC_FF_MPLS1) &&
- (p_FmPcdCcNode->parseCode != CC_PC_FF_IPV4IPTOS_TC1) && (p_FmPcdCcNode->parseCode != CC_PC_FF_IPV4IPTOS_TC2) &&
- (p_FmPcdCcNode->parseCode != CC_PC_FF_IPTOS_IPV6TC1_IPV6FLOW1) && (p_FmPcdCcNode->parseCode != CC_PC_FF_IPTOS_IPV6TC2_IPV6FLOW2) &&
- glblMask)
- {
- glblMask = FALSE;
- p_FmPcdCcNode->glblMaskSize = 4;
- p_FmPcdCcNode->lclMask = TRUE;
- }
- break;
- case(e_FM_PCD_EXTRACT_FROM_HDR):
- p_FmPcdCcNode->sizeOfExtraction = p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromHdr.size;
- p_FmPcdCcNode->offset = p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromHdr.offset;
- p_FmPcdCcNode->parseCode = GetPrParseCode(p_CcNodeParam->extractCcParams.extractByHdr.hdr, p_CcNodeParam->extractCcParams.extractByHdr.hdrIndex,
- p_FmPcdCcNode->offset,glblMask, &p_FmPcdCcNode->prsArrayOffset);
- break;
- case(e_FM_PCD_EXTRACT_FROM_FIELD):
- p_FmPcdCcNode->offset = p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromField.offset;
- p_FmPcdCcNode->sizeOfExtraction = p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromField.size;
- p_FmPcdCcNode->parseCode = GetFieldParseCode(p_CcNodeParam->extractCcParams.extractByHdr.hdr, p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromField.field,
- p_FmPcdCcNode->offset,&p_FmPcdCcNode->prsArrayOffset,
- p_CcNodeParam->extractCcParams.extractByHdr.hdrIndex);
- break;
- default:
- DeleteNode(p_FmPcdCcNode);
- REPORT_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
- return NULL;
- }
- break;
- case(e_FM_PCD_EXTRACT_NON_HDR):
- /* get the field code for the generic extract */
- p_FmPcdCcNode->sizeOfExtraction = p_CcNodeParam->extractCcParams.extractNonHdr.size;
- p_FmPcdCcNode->offset = p_CcNodeParam->extractCcParams.extractNonHdr.offset;
- p_FmPcdCcNode->parseCode = GetGenParseCode(p_CcNodeParam->extractCcParams.extractNonHdr.src, p_FmPcdCcNode->offset, glblMask, &p_FmPcdCcNode->prsArrayOffset, fromIc,icCode);
+ DBG(TRACE, ("FmPcdLockTryLockAll failed"));
+ return ERROR_CODE(E_BUSY);
+ }
- if(p_FmPcdCcNode->parseCode == CC_PC_GENERIC_IC_HASH_INDEXED)
- {
- if((p_FmPcdCcNode->offset + p_FmPcdCcNode->sizeOfExtraction) > 64)
- {
- DeleteNode(p_FmPcdCcNode);
- REPORT_ERROR(MAJOR, E_INVALID_SELECTION,("when node of the type CC_PC_GENERIC_IC_HASH_INDEXED offset + size can not be bigger then size of HASH 64 bits (8 bytes)"));
- return NULL;
- }
- }
- if((p_FmPcdCcNode->parseCode == CC_PC_GENERIC_IC_GMASK) || (p_FmPcdCcNode->parseCode == CC_PC_GENERIC_IC_HASH_INDEXED))
- {
- p_FmPcdCcNode->offset += p_FmPcdCcNode->prsArrayOffset;
- p_FmPcdCcNode->prsArrayOffset = 0;
- }
- break;
+ err = FmPcdCcRemoveKey(p_FmPcd, p_CcNode, keyIndex);
- default:
- DeleteNode(p_FmPcdCcNode);
- REPORT_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
- return NULL;
+ FmPcdLockUnlockAll(p_FmPcd);
+
+ switch(GET_ERROR_TYPE(err)
+) {
+ case E_OK:
+ return E_OK;
+
+ case E_BUSY:
+ DBG(TRACE, ("E_BUSY error"));
+ return ERROR_CODE(E_BUSY);
+
+ default:
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
- if(p_FmPcdCcNode->parseCode == CC_PC_ILLEGAL)
+ return E_OK;
+}
+
+t_Error FM_PCD_MatchTableModifyKey(t_Handle h_CcNode, uint16_t keyIndex,
+ uint8_t keySize, uint8_t *p_Key,
+ uint8_t *p_Mask)
+{
+ t_FmPcd *p_FmPcd;
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
+ p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
+
+
+ if (!FmPcdLockTryLockAll(p_FmPcd))
{
- DeleteNode(p_FmPcdCcNode);
- REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("illeagl extraction type"));
- return NULL;
+ DBG(TRACE, ("FmPcdLockTryLockAll failed"));
+ return ERROR_CODE(E_BUSY);
}
- if((p_FmPcdCcNode->sizeOfExtraction > FM_PCD_MAX_SIZE_OF_KEY) || !p_FmPcdCcNode->sizeOfExtraction)
- {
- DeleteNode(p_FmPcdCcNode);
- REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("sizeOfExatrction can not be greater than 56 and not 0"));
- return NULL;
+ err = FmPcdCcModifyKey(p_FmPcd, p_CcNode, keyIndex, keySize, p_Key, p_Mask);
+
+ FmPcdLockUnlockAll(p_FmPcd);
+
+ switch(GET_ERROR_TYPE(err)
+) {
+ case E_OK:
+ return E_OK;
+
+ case E_BUSY:
+ DBG(TRACE, ("E_BUSY error"));
+ return ERROR_CODE(E_BUSY);
+
+ default:
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
+}
+
+t_Error FM_PCD_MatchTableModifyNextEngine(
+ t_Handle h_CcNode, uint16_t keyIndex,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
+{
+ t_FmPcd *p_FmPcd;
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
+ p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
- if(p_CcNodeParam->keysParams.keySize != p_FmPcdCcNode->sizeOfExtraction)
+ if (!FmPcdLockTryLockAll(p_FmPcd))
{
- DeleteNode(p_FmPcdCcNode);
- REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("keySize has to be equal to sizeOfExtraction"));
- return NULL;
+ DBG(TRACE, ("FmPcdLockTryLockAll failed"));
+ return ERROR_CODE(E_BUSY);
}
+ err = ModifyNextEngineParamNode(p_FmPcd, p_CcNode, keyIndex,
+ p_FmPcdCcNextEngineParams);
+
+ FmPcdLockUnlockAll(p_FmPcd);
+
+ switch(GET_ERROR_TYPE(err)
+) {
+ case E_OK:
+ return E_OK;
+
+ case E_BUSY:
+ DBG(TRACE, ("E_BUSY error"));
+ return ERROR_CODE(E_BUSY);
+
+ default:
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+}
- p_FmPcdCcNode->userSizeOfExtraction = p_FmPcdCcNode->sizeOfExtraction;
+t_Error FM_PCD_MatchTableModifyMissNextEngine(
+ t_Handle h_CcNode, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
+{
+ t_FmPcd *p_FmPcd;
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+ t_Error err = E_OK;
- if(!glblMask)
- memset(p_FmPcdCcNode->p_GlblMask, 0xff, CC_GLBL_MASK_SIZE * sizeof(uint8_t));
+ SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
+ p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
-#ifdef FM_PCD_CC_MANIP
- err = CheckAndSetManipParamsWithCcNodeParams(p_FmPcdCcNode);
- if(err != E_OK)
+ if (!FmPcdLockTryLockAll(p_FmPcd))
{
- DeleteNode(p_FmPcdCcNode);
- REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("keySize has to be equal to sizeOfExtraction"));
- return NULL;
+ DBG(TRACE, ("FmPcdLockTryLockAll failed"));
+ return ERROR_CODE(E_BUSY);
}
-#endif /* FM_PCD_CC_MANIP */
- GetCcExtractKeySize(p_FmPcdCcNode->sizeOfExtraction, &p_FmPcdCcNode->ccKeySizeAccExtraction);
+ err = FmPcdCcModifyMissNextEngineParamNode(p_FmPcd, p_CcNode,
+ p_FmPcdCcNextEngineParams);
- if(p_FmPcdCcNode->lclMask)
- size = 2 * p_FmPcdCcNode->ccKeySizeAccExtraction;
- else
- size = p_FmPcdCcNode->ccKeySizeAccExtraction;
+ FmPcdLockUnlockAll(p_FmPcd);
+
+ switch(GET_ERROR_TYPE(err)
+) {
+ case E_OK:
+ return E_OK;
+
+ case E_BUSY:
+ DBG(TRACE, ("E_BUSY error"));
+ return ERROR_CODE(E_BUSY);
+
+ default:
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+}
+
+t_Error FM_PCD_MatchTableModifyKeyAndNextEngine(t_Handle h_CcNode,
+ uint16_t keyIndex,
+ uint8_t keySize,
+ t_FmPcdCcKeyParams *p_KeyParams)
+{
+ t_FmPcd *p_FmPcd;
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_KeyParams, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
+ p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
- if(isKeyTblAlloc)
+ if (!FmPcdLockTryLockAll(p_FmPcd))
{
- p_FmPcdCcNode->h_KeysMatchTable =(t_Handle)FM_MURAM_AllocMem(FmPcdGetMuramHandle(p_FmPcdCcNode->h_FmPcd),
- (uint32_t)(size * sizeof(uint8_t) * (p_FmPcdCcNode->numOfKeys + 1)),
- FM_PCD_CC_KEYS_MATCH_TABLE_ALIGN);
- if(!p_FmPcdCcNode->h_KeysMatchTable)
- {
- DeleteNode(p_FmPcdCcNode);
- REPORT_ERROR(MAJOR, E_NO_MEMORY, ("No memory in MURAM for KEY MATCH table"));
- return NULL;
- }
- IOMemSet32((uint8_t *)p_FmPcdCcNode->h_KeysMatchTable, 0, size * sizeof(uint8_t) * (p_FmPcdCcNode->numOfKeys + 1));
+ DBG(TRACE, ("FmPcdLockTryLockAll failed"));
+ return ERROR_CODE(E_BUSY);
+ }
+
+ err = FmPcdCcModifyKeyAndNextEngine(p_FmPcd, p_CcNode, keyIndex, keySize,
+ p_KeyParams);
+
+ FmPcdLockUnlockAll(p_FmPcd);
+
+ switch(GET_ERROR_TYPE(err)
+) {
+ case E_OK:
+ return E_OK;
+
+ case E_BUSY:
+ DBG(TRACE, ("E_BUSY error"));
+ return ERROR_CODE(E_BUSY);
+
+ default:
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
+}
+
+t_Error FM_PCD_MatchTableFindNRemoveKey(t_Handle h_CcNode, uint8_t keySize,
+ uint8_t *p_Key, uint8_t *p_Mask)
+{
+ t_FmPcd *p_FmPcd;
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+ uint16_t keyIndex;
+ t_Error err;
- p_FmPcdCcNode->h_AdTable = (t_Handle)FM_MURAM_AllocMem(FmPcdGetMuramHandle(p_FmPcdCcNode->h_FmPcd),
- (uint32_t)( (p_FmPcdCcNode->numOfKeys+1) * FM_PCD_CC_AD_ENTRY_SIZE),
- FM_PCD_CC_AD_TABLE_ALIGN);
- if(!p_FmPcdCcNode->h_AdTable)
+ SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
+ p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
+
+ if (!FmPcdLockTryLockAll(p_FmPcd))
{
- DeleteNode(p_FmPcdCcNode);
- REPORT_ERROR(MAJOR, E_NO_MEMORY, ("No memory in MURAM for AD table "));
- return NULL;
+ DBG(TRACE, ("FmPcdLockTryLockAll failed"));
+ return ERROR_CODE(E_BUSY);
}
- IOMemSet32((uint8_t *)p_FmPcdCcNode->h_AdTable, 0, (uint32_t)((p_FmPcdCcNode->numOfKeys+1) * FM_PCD_CC_AD_ENTRY_SIZE));
- p_KeysMatchTblTmp = p_FmPcdCcNode->h_KeysMatchTable;
- p_AdTableTmp = p_FmPcdCcNode->h_AdTable;
- for(tmp = 0 ; tmp < p_FmPcdCcNode->numOfKeys; tmp++)
+ err = FindKeyIndex(p_CcNode, keySize, p_Key, p_Mask, &keyIndex);
+ if (GET_ERROR_TYPE(err) != E_OK)
{
- p_KeyParams = &p_CcNodeParam->keysParams.keyParams[tmp];
+ FmPcdLockUnlockAll(p_FmPcd);
+ RETURN_ERROR(
+ MAJOR,
+ err,
+ ("The received key and mask pair was not found in the match table of the provided node"));
+ }
- if(p_KeysMatchTblTmp)
- {
- Mem2IOCpy32((void*)p_KeysMatchTblTmp, p_KeyParams->p_Key, p_FmPcdCcNode->sizeOfExtraction);
+ err = FmPcdCcRemoveKey(p_FmPcd, p_CcNode, keyIndex);
- if(p_FmPcdCcNode->lclMask && p_KeyParams->p_Mask)
- Mem2IOCpy32(PTR_MOVE(p_KeysMatchTblTmp, p_FmPcdCcNode->ccKeySizeAccExtraction), p_KeyParams->p_Mask, p_FmPcdCcNode->sizeOfExtraction);
- else if(p_FmPcdCcNode->lclMask)
- IOMemSet32(PTR_MOVE(p_KeysMatchTblTmp, p_FmPcdCcNode->ccKeySizeAccExtraction), 0xff, p_FmPcdCcNode->sizeOfExtraction);
- p_KeysMatchTblTmp = PTR_MOVE(p_KeysMatchTblTmp, size * sizeof(uint8_t));
- }
- NextStepAd(p_AdTableTmp,&p_KeyParams->ccNextEngineParams, p_FmPcd);
+ FmPcdLockUnlockAll(p_FmPcd);
- p_AdTableTmp = PTR_MOVE(p_AdTableTmp, FM_PCD_CC_AD_ENTRY_SIZE);
+ switch(GET_ERROR_TYPE(err)
+) {
+ case E_OK:
+ return E_OK;
+ case E_BUSY:
+ DBG(TRACE, ("E_BUSY error"));
+ return ERROR_CODE(E_BUSY);
+
+ default:
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
- NextStepAd(p_AdTableTmp,&p_CcNodeParam->keysParams.ccNextEngineParamsForMiss, p_FmPcd);
+}
- if(fullField == TRUE)
- p_FmPcdCcNode->sizeOfExtraction = 0;
+t_Error FM_PCD_MatchTableFindNModifyNextEngine(
+ t_Handle h_CcNode, uint8_t keySize, uint8_t *p_Key, uint8_t *p_Mask,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
+{
+ t_FmPcd *p_FmPcd;
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+ uint16_t keyIndex;
+ t_Error err;
+ SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
+ p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
- for(tmp = 0; tmp < p_FmPcdCcNode->numOfKeys + 1; tmp++)
+ if (!FmPcdLockTryLockAll(p_FmPcd))
{
- if(p_FmPcdCcNode->nextEngineAndRequiredAction[tmp].nextEngineParams.nextEngine == e_FM_PCD_CC)
- {
- p_FmPcdCcNextNode = (t_FmPcdCcNode*)p_FmPcdCcNode->nextEngineAndRequiredAction[tmp].nextEngineParams.params.ccParams.h_CcNode;
+ DBG(TRACE, ("FmPcdLockTryLockAll failed"));
+ return ERROR_CODE(E_BUSY);
+ }
- if(!IsNodeInModifiedState((t_Handle)p_FmPcdCcNextNode))
- {
- memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
- ccNodeInfo.h_CcNode = (t_Handle)p_FmPcdCcNode;
- ccNodeInfo.index = 1;
- EnqueueNodeInfoToRelevantLst(&p_FmPcdCcNextNode->ccPrevNodesLst, &ccNodeInfo);
- UpdateNodeWithModifiedState((t_Handle)p_FmPcdCcNextNode, TRUE);
- }
- else
- {
- p_CcInformation = FindNodeInfoInReleventLst(&p_FmPcdCcNextNode->ccPrevNodesLst,(t_Handle)p_FmPcdCcNode);
- ASSERT_COND(p_CcInformation);
- p_CcInformation->index++;
- }
- }
+ err = FindKeyIndex(p_CcNode, keySize, p_Key, p_Mask, &keyIndex);
+ if (GET_ERROR_TYPE(err) != E_OK)
+ {
+ FmPcdLockUnlockAll(p_FmPcd);
+ RETURN_ERROR(
+ MAJOR,
+ err,
+ ("The received key and mask pair was not found in the match table of the provided node"));
+ }
+
+ err = ModifyNextEngineParamNode(p_FmPcd, p_CcNode, keyIndex,
+ p_FmPcdCcNextEngineParams);
+ FmPcdLockUnlockAll(p_FmPcd);
+
+ switch(GET_ERROR_TYPE(err)
+) {
+ case E_OK:
+ return E_OK;
+
+ case E_BUSY:
+ DBG(TRACE, ("E_BUSY error"));
+ return ERROR_CODE(E_BUSY);
+
+ default:
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
+}
- for(tmp = 0; tmp < p_FmPcdCcNode->numOfKeys + 1; tmp++)
- {
- if(p_FmPcdCcNode->nextEngineAndRequiredAction[tmp].nextEngineParams.nextEngine == e_FM_PCD_CC)
- {
- p_FmPcdCcNextNode = (t_FmPcdCcNode*)p_FmPcdCcNode->nextEngineAndRequiredAction[tmp].nextEngineParams.params.ccParams.h_CcNode;
+t_Error FM_PCD_MatchTableFindNModifyKeyAndNextEngine(
+ t_Handle h_CcNode, uint8_t keySize, uint8_t *p_Key, uint8_t *p_Mask,
+ t_FmPcdCcKeyParams *p_KeyParams)
+{
+ t_FmPcd *p_FmPcd;
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+ uint16_t keyIndex;
+ t_Error err;
- if(IsNodeInModifiedState((t_Handle)p_FmPcdCcNextNode))
- UpdateNodeWithModifiedState((t_Handle)p_FmPcdCcNextNode, FALSE);
- }
+ SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_KeyParams, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
+ p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
+
+ if (!FmPcdLockTryLockAll(p_FmPcd))
+ {
+ DBG(TRACE, ("FmPcdLockTryLockAll failed"));
+ return ERROR_CODE(E_BUSY);
}
- p_AdTableTmp = p_FmPcdCcNode->h_AdTable;
- for(tmp = 0; tmp < p_FmPcdCcNode->numOfKeys; tmp++)
+ err = FindKeyIndex(p_CcNode, keySize, p_Key, p_Mask, &keyIndex);
+ if (GET_ERROR_TYPE(err) != E_OK)
{
- if(p_FmPcdCcNode->nextEngineAndRequiredAction[tmp].requiredAction)
- {
+ FmPcdLockUnlockAll(p_FmPcd);
+ RETURN_ERROR(
+ MAJOR,
+ err,
+ ("The received key and mask pair was not found in the match table of the provided node"));
+ }
- err = FmPcdCcSetRequiredAction(h_FmPcd, p_FmPcdCcNode->nextEngineAndRequiredAction[tmp].requiredAction, &p_FmPcdCcNode->nextEngineAndRequiredAction[tmp], p_AdTableTmp,1, NULL);
- if(err)
- {
- FM_PCD_CcDeleteNode(h_FmPcd, (t_Handle)p_FmPcdCcNode);
- REPORT_ERROR(MAJOR, err, NO_MSG);
- return NULL;
- }
- p_AdTableTmp = PTR_MOVE(p_AdTableTmp, FM_PCD_CC_AD_ENTRY_SIZE);
- }
+ err = FmPcdCcModifyKeyAndNextEngine(p_FmPcd, h_CcNode, keyIndex, keySize,
+ p_KeyParams);
+
+ FmPcdLockUnlockAll(p_FmPcd);
+
+ switch(GET_ERROR_TYPE(err)
+) {
+ case E_OK:
+ return E_OK;
+
+ case E_BUSY:
+ DBG(TRACE, ("E_BUSY error"));
+ return ERROR_CODE(E_BUSY);
+
+ default:
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
- if(p_FmPcdCcNode->nextEngineAndRequiredAction[tmp].requiredAction)
+}
+
+t_Error FM_PCD_MatchTableFindNModifyKey(t_Handle h_CcNode, uint8_t keySize,
+ uint8_t *p_Key, uint8_t *p_Mask,
+ uint8_t *p_NewKey, uint8_t *p_NewMask)
+{
+ t_FmPcd *p_FmPcd;
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+ t_List h_List;
+ uint16_t keyIndex;
+ t_Error err;
+
+ SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_NewKey, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
+ p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
+
+ INIT_LIST(&h_List);
+
+ err = FmPcdCcNodeTreeTryLock(p_FmPcd, p_CcNode, &h_List);
+ if (err)
{
- err = FmPcdCcSetRequiredAction(h_FmPcd, p_FmPcdCcNode->nextEngineAndRequiredAction[tmp].requiredAction, &p_FmPcdCcNode->nextEngineAndRequiredAction[tmp], p_AdTableTmp,1, NULL);
- if(err)
- {
- FM_PCD_CcDeleteNode(h_FmPcd, (t_Handle)p_FmPcdCcNode);
- REPORT_ERROR(MAJOR, err, NO_MSG);
- return NULL;
- }
+ DBG(TRACE, ("Node's trees lock failed"));
+ return ERROR_CODE(E_BUSY);
+ }
+ err = FindKeyIndex(p_CcNode, keySize, p_Key, p_Mask, &keyIndex);
+ if (GET_ERROR_TYPE(err) != E_OK)
+ {
+ FmPcdCcNodeTreeReleaseLock(p_FmPcd, &h_List);
+ RETURN_ERROR(MAJOR, err,
+ ("The received key and mask pair was not found in the "
+ "match table of the provided node"));
}
+ err = FmPcdCcModifyKey(p_FmPcd, p_CcNode, keyIndex, keySize, p_NewKey,
+ p_NewMask);
+
+ FmPcdCcNodeTreeReleaseLock(p_FmPcd, &h_List);
+
+ switch(GET_ERROR_TYPE(err)
+) {
+ case E_OK:
+ return E_OK;
+
+ case E_BUSY:
+ DBG(TRACE, ("E_BUSY error"));
+ return ERROR_CODE(E_BUSY);
- return p_FmPcdCcNode;
+ default:
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
}
-t_Error FM_PCD_CcDeleteNode(t_Handle h_FmPcd, t_Handle h_CcNode)
+t_Error FM_PCD_MatchTableGetNextEngine(
+ t_Handle h_CcNode, uint16_t keyIndex,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
{
- t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
- int i = 0;
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
- SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);
- UNUSED(h_FmPcd);
- if(!p_CcNode)
- RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("the node with this ID is not initialized"));
+ if (keyIndex >= p_CcNode->numOfKeys)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("keyIndex exceeds current number of keys"));
+
+ if (keyIndex > (FM_PCD_MAX_NUM_OF_KEYS - 1))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("keyIndex can not be larger than %d", (FM_PCD_MAX_NUM_OF_KEYS - 1)));
- if(p_CcNode->owners)
- RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("the node with this ID can not be removed because this node is occupied, first - unbind this node"));
+ memcpy(p_FmPcdCcNextEngineParams,
+ &p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams,
+ sizeof(t_FmPcdCcNextEngineParams));
- for(i = 0; i < p_CcNode->numOfKeys; i++)
- {
- if(p_CcNode->nextEngineAndRequiredAction[i].nextEngineParams.nextEngine == e_FM_PCD_CC)
- UpdateNodeOwner(p_CcNode->nextEngineAndRequiredAction[i].nextEngineParams.params.ccParams.h_CcNode, FALSE);
+ return E_OK;
+}
+
+
+uint32_t FM_PCD_MatchTableGetKeyCounter(t_Handle h_CcNode, uint16_t keyIndex)
+{
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+ uint32_t *p_StatsCounters, frameCount;
+ uint32_t intFlags;
+ SANITY_CHECK_RETURN_VALUE(p_CcNode, E_INVALID_HANDLE, 0);
+
+ if (p_CcNode->statisticsMode == e_FM_PCD_CC_STATS_MODE_NONE)
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Statistics were not enabled for this match table"));
+ return 0;
}
- if(p_CcNode->nextEngineAndRequiredAction[i].nextEngineParams.nextEngine == e_FM_PCD_CC)
- UpdateNodeOwner(p_CcNode->nextEngineAndRequiredAction[i].nextEngineParams.params.ccParams.h_CcNode, FALSE);
-#ifdef FM_PCD_CC_MANIP
- for(i = 0; i < p_CcNode->numOfKeys; i++)
+ if ((p_CcNode->statisticsMode != e_FM_PCD_CC_STATS_MODE_FRAME)
+ && (p_CcNode->statisticsMode
+ != e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME))
{
- if(p_CcNode->nextEngineAndRequiredAction[i].nextEngineParams.h_Manip)
- FmPcdManipUpdateOwner(p_CcNode->nextEngineAndRequiredAction[i].nextEngineParams.h_Manip, FALSE);
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Frame count is not supported in the statistics mode of this match table"));
+ return 0;
}
- if(p_CcNode->nextEngineAndRequiredAction[i].nextEngineParams.h_Manip)
- FmPcdManipUpdateOwner(p_CcNode->nextEngineAndRequiredAction[i].nextEngineParams.h_Manip, FALSE);
-#endif /* FM_PCD_CC_MANIP */
- DeleteNode(p_CcNode);
+ intFlags = XX_LockIntrSpinlock(p_CcNode->h_Spinlock);
- return E_OK;
+ if (keyIndex >= p_CcNode->numOfKeys)
+ {
+ XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("The provided keyIndex exceeds the number of keys in this match table"));
+ return 0;
+ }
+
+ if (!p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj)
+ {
+ XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Statistics were not enabled for this key"));
+ return 0;
+ }
+
+ p_StatsCounters =
+ p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj->h_StatsCounters;
+ ASSERT_COND(p_StatsCounters);
+
+ /* The first counter is byte counter, so we need to advance to the next counter */
+ frameCount = GET_UINT32(*(uint32_t *)(PTR_MOVE(p_StatsCounters,
+ FM_PCD_CC_STATS_COUNTER_SIZE)));
+
+ XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
+
+ return frameCount;
}
-t_Error FM_PCD_CcNodeAddKey(t_Handle h_FmPcd, t_Handle h_CcNode, uint8_t keyIndex, uint8_t keySize, t_FmPcdCcKeyParams *p_KeyParams)
+t_Error FM_PCD_MatchTableGetKeyStatistics(
+ t_Handle h_CcNode, uint16_t keyIndex,
+ t_FmPcdCcKeyStatistics *p_KeyStatistics)
{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+ uint32_t intFlags;
+ t_Error err;
- SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(h_CcNode, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_KeyStatistics, E_NULL_POINTER);
+
+ intFlags = XX_LockIntrSpinlock(p_CcNode->h_Spinlock);
+
+ if (keyIndex >= p_CcNode->numOfKeys)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("The provided keyIndex exceeds the number of keys in this match table"));
+
+ err = MatchTableGetKeyStatistics(p_CcNode, keyIndex, p_KeyStatistics);
+
+ XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
+
+ if (err != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
- return FmHcPcdCcAddKey(p_FmPcd->h_Hc, h_CcNode, keyIndex, keySize, p_KeyParams);
+ return E_OK;
}
-t_Error FM_PCD_CcNodeRemoveKey(t_Handle h_FmPcd, t_Handle h_CcNode, uint8_t keyIndex)
+t_Error FM_PCD_MatchTableGetMissStatistics(
+ t_Handle h_CcNode, t_FmPcdCcKeyStatistics *p_MissStatistics)
{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+ uint32_t intFlags;
+ t_Error err;
- SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(h_CcNode, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_MissStatistics, E_NULL_POINTER);
+
+ intFlags = XX_LockIntrSpinlock(p_CcNode->h_Spinlock);
+
+ err = MatchTableGetKeyStatistics(p_CcNode, p_CcNode->numOfKeys,
+ p_MissStatistics);
+
+ XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
+
+ if (err != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
- return FmHcPcdCcRemoveKey(p_FmPcd->h_Hc, h_CcNode, keyIndex);
+ return E_OK;
}
-t_Error FM_PCD_CcNodeModifyKey(t_Handle h_FmPcd, t_Handle h_CcNode, uint8_t keyIndex, uint8_t keySize, uint8_t *p_Key, uint8_t *p_Mask)
+t_Error FM_PCD_MatchTableFindNGetKeyStatistics(
+ t_Handle h_CcNode, uint8_t keySize, uint8_t *p_Key, uint8_t *p_Mask,
+ t_FmPcdCcKeyStatistics *p_KeyStatistics)
{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+ uint16_t keyIndex;
+ uint32_t intFlags;
+ t_Error err;
- SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_KeyStatistics, E_NULL_POINTER);
+
+ intFlags = XX_LockIntrSpinlock(p_CcNode->h_Spinlock);
+
+ err = FindKeyIndex(p_CcNode, keySize, p_Key, p_Mask, &keyIndex);
+ if (GET_ERROR_TYPE(err) != E_OK)
+ {
+ XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
+ RETURN_ERROR(MAJOR, err,
+ ("The received key and mask pair was not found in the "
+ "match table of the provided node"));
+ }
+
+ ASSERT_COND(keyIndex < p_CcNode->numOfKeys);
+
+ err = MatchTableGetKeyStatistics(p_CcNode, keyIndex, p_KeyStatistics);
+
+ XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);
+
+ if (err != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
- return FmHcPcdCcModifyKey(p_FmPcd->h_Hc, h_CcNode, keyIndex, keySize, p_Key, p_Mask);
+ return E_OK;
}
-t_Error FM_PCD_CcNodeModifyNextEngine(t_Handle h_FmPcd, t_Handle h_CcNode, uint8_t keyIndex, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
+t_Error FM_PCD_MatchTableGetIndexedHashBucket(t_Handle h_CcNode,
+ uint8_t keySize, uint8_t *p_Key,
+ uint8_t hashShift,
+ t_Handle *p_CcNodeBucketHandle,
+ uint8_t *p_BucketIndex,
+ uint16_t *p_LastIndex)
{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;
+ uint16_t glblMask;
+ uint64_t crc64 = 0;
- SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(h_CcNode, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(
+ p_CcNode->parseCode == CC_PC_GENERIC_IC_HASH_INDEXED,
+ E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_CcNodeBucketHandle, E_NULL_POINTER);
+
+ memcpy(&glblMask, PTR_MOVE(p_CcNode->p_GlblMask, 2), 2);
+ glblMask = be16toh(glblMask);
+
+ crc64 = crc64_init();
+ crc64 = crc64_compute(p_Key, keySize, crc64);
+ crc64 >>= hashShift;
+
+ *p_BucketIndex = (uint8_t)(((crc64 >> (8 * (6 - p_CcNode->userOffset)))
+ & glblMask) >> 4);
+ if (*p_BucketIndex >= p_CcNode->numOfKeys)
+ RETURN_ERROR(MINOR, E_NOT_IN_RANGE, ("bucket index!"));
+
+ *p_CcNodeBucketHandle =
+ p_CcNode->keyAndNextEngineParams[*p_BucketIndex].nextEngineParams.params.ccParams.h_CcNode;
+ if (!*p_CcNodeBucketHandle)
+ RETURN_ERROR(MINOR, E_NOT_FOUND, ("bucket!"));
- return FmHcPcdCcModifyNodeNextEngine(p_FmPcd->h_Hc, h_CcNode, keyIndex, p_FmPcdCcNextEngineParams);
+ *p_LastIndex = ((t_FmPcdCcNode *)*p_CcNodeBucketHandle)->numOfKeys;
+
+ return E_OK;
}
-t_Error FM_PCD_CcNodeModifyMissNextEngine(t_Handle h_FmPcd, t_Handle h_CcNode, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
+t_Handle FM_PCD_HashTableSet(t_Handle h_FmPcd, t_FmPcdHashTableParams *p_Param)
{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ t_FmPcdCcNode *p_CcNodeHashTbl;
+ t_FmPcdCcNodeParams *p_IndxHashCcNodeParam, *p_ExactMatchCcNodeParam;
+ t_FmPcdCcNode *p_CcNode;
+ t_Handle h_MissStatsCounters = NULL;
+ t_FmPcdCcKeyParams *p_HashKeyParams;
+ int i;
+ uint16_t numOfSets, numOfWays, countMask, onesCount = 0;
+ bool statsEnForMiss = FALSE;
+ t_Error err;
+
+ SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, NULL);
+ SANITY_CHECK_RETURN_VALUE(p_Param, E_NULL_POINTER, NULL);
+
+ if (p_Param->maxNumOfKeys == 0)
+ {
+ REPORT_ERROR(MINOR, E_INVALID_VALUE, ("Max number of keys must be higher then 0"));
+ return NULL;
+ }
- SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
+ if (p_Param->hashResMask == 0)
+ {
+ REPORT_ERROR(MINOR, E_INVALID_VALUE, ("Hash result mask must differ from 0"));
+ return NULL;
+ }
+
+ /*Fix: QorIQ SDK / QSDK-2131*/
+ if (p_Param->ccNextEngineParamsForMiss.nextEngine == e_FM_PCD_INVALID)
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Next PCD Engine for on-miss entry is invalid. On-miss entry is always required. You can use e_FM_PCD_DONE."));
+ return NULL;
+ }
+
+#if (DPAA_VERSION >= 11)
+ if (p_Param->statisticsMode == e_FM_PCD_CC_STATS_MODE_RMON)
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_VALUE,
+ ("RMON statistics mode is not supported for hash table"));
+ return NULL;
+ }
+#endif /* (DPAA_VERSION >= 11) */
+
+ p_ExactMatchCcNodeParam = (t_FmPcdCcNodeParams*)XX_Malloc(
+ sizeof(t_FmPcdCcNodeParams));
+ if (!p_ExactMatchCcNodeParam)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("p_ExactMatchCcNodeParam"));
+ return NULL;
+ }
+ memset(p_ExactMatchCcNodeParam, 0, sizeof(t_FmPcdCcNodeParams));
+
+ p_IndxHashCcNodeParam = (t_FmPcdCcNodeParams*)XX_Malloc(
+ sizeof(t_FmPcdCcNodeParams));
+ if (!p_IndxHashCcNodeParam)
+ {
+ XX_Free(p_ExactMatchCcNodeParam);
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("p_IndxHashCcNodeParam"));
+ return NULL;
+ }
+ memset(p_IndxHashCcNodeParam, 0, sizeof(t_FmPcdCcNodeParams));
+
+ /* Calculate number of sets and number of ways of the hash table */
+ countMask = (uint16_t)(p_Param->hashResMask >> 4);
+ while (countMask)
+ {
+ onesCount++;
+ countMask = (uint16_t)(countMask >> 1);
+ }
+
+ numOfSets = (uint16_t)(1 << onesCount);
+ numOfWays = (uint16_t)DIV_CEIL(p_Param->maxNumOfKeys, numOfSets);
+
+ if (p_Param->maxNumOfKeys % numOfSets)
+ DBG(INFO, ("'maxNumOfKeys' is not a multiple of hash number of ways, so number of ways will be rounded up"));
+
+ if ((p_Param->statisticsMode == e_FM_PCD_CC_STATS_MODE_FRAME)
+ || (p_Param->statisticsMode == e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME))
+ {
+ /* Allocating a statistics counters table that will be used by all
+ 'miss' entries of the hash table */
+ h_MissStatsCounters = (t_Handle)FM_MURAM_AllocMem(
+ FmPcdGetMuramHandle(h_FmPcd), 2 * FM_PCD_CC_STATS_COUNTER_SIZE,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if (!h_MissStatsCounters)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for statistics table for hash miss"));
+ XX_Free(p_IndxHashCcNodeParam);
+ XX_Free(p_ExactMatchCcNodeParam);
+ return NULL;
+ }
+ memset(h_MissStatsCounters, 0, (2 * FM_PCD_CC_STATS_COUNTER_SIZE));
+
+ /* Always enable statistics for 'miss', so that a statistics AD will be
+ initialized from the start. We'll store the requested 'statistics enable'
+ value and it will be used when statistics are read by the user. */
+ statsEnForMiss = p_Param->ccNextEngineParamsForMiss.statisticsEn;
+ p_Param->ccNextEngineParamsForMiss.statisticsEn = TRUE;
+ }
+
+ /* Building exact-match node params, will be used to create the hash buckets */
+ p_ExactMatchCcNodeParam->extractCcParams.type = e_FM_PCD_EXTRACT_NON_HDR;
+
+ p_ExactMatchCcNodeParam->extractCcParams.extractNonHdr.src =
+ e_FM_PCD_EXTRACT_FROM_KEY;
+ p_ExactMatchCcNodeParam->extractCcParams.extractNonHdr.action =
+ e_FM_PCD_ACTION_EXACT_MATCH;
+ p_ExactMatchCcNodeParam->extractCcParams.extractNonHdr.offset = 0;
+ p_ExactMatchCcNodeParam->extractCcParams.extractNonHdr.size =
+ p_Param->matchKeySize;
+
+ p_ExactMatchCcNodeParam->keysParams.maxNumOfKeys = numOfWays;
+ p_ExactMatchCcNodeParam->keysParams.maskSupport = FALSE;
+ p_ExactMatchCcNodeParam->keysParams.statisticsMode =
+ p_Param->statisticsMode;
+ p_ExactMatchCcNodeParam->keysParams.numOfKeys = 0;
+ p_ExactMatchCcNodeParam->keysParams.keySize = p_Param->matchKeySize;
+ p_ExactMatchCcNodeParam->keysParams.ccNextEngineParamsForMiss =
+ p_Param->ccNextEngineParamsForMiss;
+
+ p_HashKeyParams = p_IndxHashCcNodeParam->keysParams.keyParams;
+
+ for (i = 0; i < numOfSets; i++)
+ {
+ /* Each exact-match node will be marked as a 'bucket' and provided with
+ a pointer to statistics counters, to be used for 'miss' entry
+ statistics */
+ p_CcNode = (t_FmPcdCcNode *)XX_Malloc(sizeof(t_FmPcdCcNode));
+ if (!p_CcNode)
+ break;
+ memset(p_CcNode, 0, sizeof(t_FmPcdCcNode));
+
+ p_CcNode->isHashBucket = TRUE;
+ p_CcNode->h_MissStatsCounters = h_MissStatsCounters;
+
+ err = MatchTableSet(h_FmPcd, p_CcNode, p_ExactMatchCcNodeParam);
+ if (err)
+ break;
+
+ p_HashKeyParams[i].ccNextEngineParams.nextEngine = e_FM_PCD_CC;
+ p_HashKeyParams[i].ccNextEngineParams.statisticsEn = FALSE;
+ p_HashKeyParams[i].ccNextEngineParams.params.ccParams.h_CcNode =
+ p_CcNode;
+ }
+
+ if (i < numOfSets)
+ {
+ for (i = i - 1; i >= 0; i--)
+ FM_PCD_MatchTableDelete(
+ p_HashKeyParams[i].ccNextEngineParams.params.ccParams.h_CcNode);
+
+ FM_MURAM_FreeMem(FmPcdGetMuramHandle(h_FmPcd), h_MissStatsCounters);
+
+ REPORT_ERROR(MAJOR, E_NULL_POINTER, NO_MSG);
+ XX_Free(p_IndxHashCcNodeParam);
+ XX_Free(p_ExactMatchCcNodeParam);
+ return NULL;
+ }
+
+ /* Creating indexed-hash CC node */
+ p_IndxHashCcNodeParam->extractCcParams.type = e_FM_PCD_EXTRACT_NON_HDR;
+ p_IndxHashCcNodeParam->extractCcParams.extractNonHdr.src =
+ e_FM_PCD_EXTRACT_FROM_HASH;
+ p_IndxHashCcNodeParam->extractCcParams.extractNonHdr.action =
+ e_FM_PCD_ACTION_INDEXED_LOOKUP;
+ p_IndxHashCcNodeParam->extractCcParams.extractNonHdr.icIndxMask =
+ p_Param->hashResMask;
+ p_IndxHashCcNodeParam->extractCcParams.extractNonHdr.offset =
+ p_Param->hashShift;
+ p_IndxHashCcNodeParam->extractCcParams.extractNonHdr.size = 2;
+
+ p_IndxHashCcNodeParam->keysParams.maxNumOfKeys = numOfSets;
+ p_IndxHashCcNodeParam->keysParams.maskSupport = FALSE;
+ p_IndxHashCcNodeParam->keysParams.statisticsMode =
+ e_FM_PCD_CC_STATS_MODE_NONE;
+ /* Number of keys of this node is number of sets of the hash */
+ p_IndxHashCcNodeParam->keysParams.numOfKeys = numOfSets;
+ p_IndxHashCcNodeParam->keysParams.keySize = 2;
+
+ p_CcNodeHashTbl = FM_PCD_MatchTableSet(h_FmPcd, p_IndxHashCcNodeParam);
+
+ if (p_CcNodeHashTbl)
+ {
+ p_CcNodeHashTbl->kgHashShift = p_Param->kgHashShift;
+
+ /* Storing the allocated counters for buckets 'miss' in the hash table
+ and if statistics for miss were enabled. */
+ p_CcNodeHashTbl->h_MissStatsCounters = h_MissStatsCounters;
+ p_CcNodeHashTbl->statsEnForMiss = statsEnForMiss;
+ }
+
+ XX_Free(p_IndxHashCcNodeParam);
+ XX_Free(p_ExactMatchCcNodeParam);
- return FmHcPcdCcModifyNodeMissNextEngine(p_FmPcd->h_Hc, h_CcNode, p_FmPcdCcNextEngineParams);
+ return p_CcNodeHashTbl;
}
-t_Error FM_PCD_CcTreeModifyNextEngine(t_Handle h_FmPcd, t_Handle h_CcTree, uint8_t grpId, uint8_t index, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
+t_Error FM_PCD_HashTableDelete(t_Handle h_HashTbl)
{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
+ t_Handle h_FmPcd;
+ t_Handle *p_HashBuckets, h_MissStatsCounters;
+ uint16_t i, numOfBuckets;
+ t_Error err;
- SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);
+
+ /* Store all hash buckets before the hash is freed */
+ numOfBuckets = p_HashTbl->numOfKeys;
+
+ p_HashBuckets = (t_Handle *)XX_Malloc(numOfBuckets * sizeof(t_Handle));
+ if (!p_HashBuckets)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
+
+ for (i = 0; i < numOfBuckets; i++)
+ p_HashBuckets[i] =
+ p_HashTbl->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode;
+
+ h_FmPcd = p_HashTbl->h_FmPcd;
+ h_MissStatsCounters = p_HashTbl->h_MissStatsCounters;
- return FmHcPcdCcModifyTreeNextEngine(p_FmPcd->h_Hc, h_CcTree, grpId, index, p_FmPcdCcNextEngineParams);
+ /* Free the hash */
+ err = FM_PCD_MatchTableDelete(p_HashTbl);
+
+ /* Free each hash bucket */
+ for (i = 0; i < numOfBuckets; i++)
+ err |= FM_PCD_MatchTableDelete(p_HashBuckets[i]);
+
+ XX_Free(p_HashBuckets);
+
+ /* Free statistics counters for 'miss', if these were allocated */
+ if (h_MissStatsCounters)
+ FM_MURAM_FreeMem(FmPcdGetMuramHandle(h_FmPcd), h_MissStatsCounters);
+
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ return E_OK;
}
-t_Error FM_PCD_CcNodeModifyKeyAndNextEngine(t_Handle h_FmPcd, t_Handle h_CcNode, uint8_t keyIndex, uint8_t keySize, t_FmPcdCcKeyParams *p_KeyParams)
+t_Error FM_PCD_HashTableAddKey(t_Handle h_HashTbl, uint8_t keySize,
+ t_FmPcdCcKeyParams *p_KeyParams)
{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
+ t_Handle h_HashBucket;
+ uint8_t bucketIndex;
+ uint16_t lastIndex;
+ t_Error err;
+
+ SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_KeyParams, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_KeyParams->p_Key, E_NULL_POINTER);
+
+ if (p_KeyParams->p_Mask)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("Keys masks not supported for hash table"));
+
+ err = FM_PCD_MatchTableGetIndexedHashBucket(p_HashTbl, keySize,
+ p_KeyParams->p_Key,
+ p_HashTbl->kgHashShift,
+ &h_HashBucket, &bucketIndex,
+ &lastIndex);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
- SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
+ return FM_PCD_MatchTableAddKey(h_HashBucket, FM_PCD_LAST_KEY_INDEX, keySize,
+ p_KeyParams);
+}
+
+t_Error FM_PCD_HashTableRemoveKey(t_Handle h_HashTbl, uint8_t keySize,
+ uint8_t *p_Key)
+{
+ t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
+ t_Handle h_HashBucket;
+ uint8_t bucketIndex;
+ uint16_t lastIndex;
+ t_Error err;
+
+ SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
+
+ err = FM_PCD_MatchTableGetIndexedHashBucket(p_HashTbl, keySize, p_Key,
+ p_HashTbl->kgHashShift,
+ &h_HashBucket, &bucketIndex,
+ &lastIndex);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
- return FmHcPcdCcModifyKeyAndNextEngine(p_FmPcd->h_Hc, h_CcNode, keyIndex, keySize, p_KeyParams);
+ return FM_PCD_MatchTableFindNRemoveKey(h_HashBucket, keySize, p_Key, NULL);
}
-uint32_t FM_PCD_CcNodeGetKeyCounter(t_Handle h_FmPcd, t_Handle h_CcNode, uint8_t keyIndex)
+t_Error FM_PCD_HashTableModifyNextEngine(
+ t_Handle h_HashTbl, uint8_t keySize, uint8_t *p_Key,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
{
- t_FmPcdCcNode *p_FmPcdCcNode = (t_FmPcdCcNode *)h_CcNode;
- t_AdOfTypeResult *p_AdResult = NULL;
+ t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
+ t_Handle h_HashBucket;
+ uint8_t bucketIndex;
+ uint16_t lastIndex;
+ t_Error err;
+
+ SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);
+
+ err = FM_PCD_MatchTableGetIndexedHashBucket(p_HashTbl, keySize, p_Key,
+ p_HashTbl->kgHashShift,
+ &h_HashBucket, &bucketIndex,
+ &lastIndex);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
- SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_VALUE(h_CcNode, E_INVALID_HANDLE, 0);
-#ifdef DISABLE_SANITY_CHECKS
-UNUSED(h_FmPcd);
-#endif /* DISABLE_SANITY_CHECKS */
+ return FM_PCD_MatchTableFindNModifyNextEngine(h_HashBucket, keySize, p_Key,
+ NULL,
+ p_FmPcdCcNextEngineParams);
+}
- if (keyIndex >= p_FmPcdCcNode->numOfKeys)
+t_Error FM_PCD_HashTableModifyMissNextEngine(
+ t_Handle h_HashTbl,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
+{
+ t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
+ t_Handle h_HashBucket;
+ uint8_t i;
+ bool nullifyMissStats = FALSE;
+ t_Error err;
+
+ SANITY_CHECK_RETURN_ERROR(h_HashTbl, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);
+
+ if ((!p_HashTbl->h_MissStatsCounters)
+ && (p_FmPcdCcNextEngineParams->statisticsEn))
+ RETURN_ERROR(
+ MAJOR,
+ E_CONFLICT,
+ ("Statistics are requested for a key, but statistics mode was set"
+ "to 'NONE' upon initialization"));
+
+ if (p_HashTbl->h_MissStatsCounters)
{
- REPORT_ERROR(MINOR, E_INVALID_STATE,
- ("keyIndex > numOfKeys defined for this node"));
- return 0;
- }
+ if ((!p_HashTbl->statsEnForMiss)
+ && (p_FmPcdCcNextEngineParams->statisticsEn))
+ nullifyMissStats = TRUE;
- p_AdResult = PTR_MOVE(p_FmPcdCcNode->h_AdTable, keyIndex*FM_PCD_CC_AD_ENTRY_SIZE);
- ASSERT_COND(p_AdResult);
+ if ((p_HashTbl->statsEnForMiss)
+ && (!p_FmPcdCcNextEngineParams->statisticsEn))
+ {
+ p_HashTbl->statsEnForMiss = FALSE;
+ p_FmPcdCcNextEngineParams->statisticsEn = TRUE;
+ }
+ }
- if (p_FmPcdCcNode->nextEngineAndRequiredAction[keyIndex].nextEngineParams.nextEngine == e_FM_PCD_CC)
+ for (i = 0; i < p_HashTbl->numOfKeys; i++)
{
- REPORT_ERROR(MINOR, E_INVALID_STATE,
- ("statistics updated only for entries where next engine not CC"));
- return 0;
+ h_HashBucket =
+ p_HashTbl->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode;
+
+ err = FM_PCD_MatchTableModifyMissNextEngine(h_HashBucket,
+ p_FmPcdCcNextEngineParams);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
- if(((p_FmPcdCcNode->nextEngineAndRequiredAction[keyIndex].nextEngineParams.nextEngine == e_FM_PCD_DONE) &&
- !p_FmPcdCcNode->nextEngineAndRequiredAction[keyIndex].nextEngineParams.params.enqueueParams.statisticsEn) ||
- ((p_FmPcdCcNode->nextEngineAndRequiredAction[keyIndex].nextEngineParams.nextEngine == e_FM_PCD_KG) &&
- !p_FmPcdCcNode->nextEngineAndRequiredAction[keyIndex].nextEngineParams.params.kgParams.statisticsEn) ||
- ((p_FmPcdCcNode->nextEngineAndRequiredAction[keyIndex].nextEngineParams.nextEngine == e_FM_PCD_PLCR) &&
- !p_FmPcdCcNode->nextEngineAndRequiredAction[keyIndex].nextEngineParams.params.plcrParams.statisticsEn))
+ if (nullifyMissStats)
{
- REPORT_ERROR(MINOR, E_INVALID_STATE,
- ("statistics wasn't enable"));
- return 0;
+ memset(p_HashTbl->h_MissStatsCounters, 0,
+ (2 * FM_PCD_CC_STATS_COUNTER_SIZE));
+ memset(p_HashTbl->h_MissStatsCounters, 0,
+ (2 * FM_PCD_CC_STATS_COUNTER_SIZE));
+ p_HashTbl->statsEnForMiss = TRUE;
}
- return GET_UINT32(p_AdResult->res);
+ return E_OK;
+}
+
+
+t_Error FM_PCD_HashTableGetMissNextEngine(
+ t_Handle h_HashTbl,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
+{
+ t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
+ t_FmPcdCcNode *p_HashBucket;
+
+ SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);
+
+ /* Miss next engine of each bucket was initialized with the next engine of the hash table */
+ p_HashBucket =
+ p_HashTbl->keyAndNextEngineParams[0].nextEngineParams.params.ccParams.h_CcNode;
+
+ memcpy(p_FmPcdCcNextEngineParams,
+ &p_HashBucket->keyAndNextEngineParams[p_HashBucket->numOfKeys].nextEngineParams,
+ sizeof(t_FmPcdCcNextEngineParams));
+
+ return E_OK;
+}
+
+t_Error FM_PCD_HashTableFindNGetKeyStatistics(
+ t_Handle h_HashTbl, uint8_t keySize, uint8_t *p_Key,
+ t_FmPcdCcKeyStatistics *p_KeyStatistics)
+{
+ t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
+ t_Handle h_HashBucket;
+ uint8_t bucketIndex;
+ uint16_t lastIndex;
+ t_Error err;
+
+ SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_KeyStatistics, E_NULL_POINTER);
+
+ err = FM_PCD_MatchTableGetIndexedHashBucket(p_HashTbl, keySize, p_Key,
+ p_HashTbl->kgHashShift,
+ &h_HashBucket, &bucketIndex,
+ &lastIndex);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ return FM_PCD_MatchTableFindNGetKeyStatistics(h_HashBucket, keySize, p_Key,
+ NULL, p_KeyStatistics);
+}
+
+t_Error FM_PCD_HashTableGetMissStatistics(
+ t_Handle h_HashTbl, t_FmPcdCcKeyStatistics *p_MissStatistics)
+{
+ t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
+ t_Handle h_HashBucket;
+
+ SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_MissStatistics, E_NULL_POINTER);
+
+ if (!p_HashTbl->statsEnForMiss)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("Statistics were not enabled for miss"));
+
+ h_HashBucket =
+ p_HashTbl->keyAndNextEngineParams[0].nextEngineParams.params.ccParams.h_CcNode;
+
+ return FM_PCD_MatchTableGetMissStatistics(h_HashBucket, p_MissStatistics);
}
diff --git a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_cc.h b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_cc.h
index a96142bf2b30..3456bb565fd7 100644
--- a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_cc.h
+++ b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_cc.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm_cc.h
@@ -49,6 +50,8 @@
/* Coarse classification defines */
/***********************************************************************/
+#define CC_MAX_NUM_OF_KEYS (FM_PCD_MAX_NUM_OF_KEYS + 1)
+
#define CC_PC_FF_MACDST 0x00
#define CC_PC_FF_MACSRC 0x01
#define CC_PC_FF_ETYPE 0x02
@@ -81,6 +84,9 @@
#define CC_PC_FF_IPV6SRC1 0x10
#define CC_PC_FF_IPV6SRC2 0x1e
#define CC_PC_FF_IPV6HOP_LIMIT 0x2a
+#define CC_PC_FF_IPPID 0x24
+#define CC_PC_FF_IPDSCP 0x76
+
#define CC_PC_FF_GREPTYPE 0x11
#define CC_PC_FF_MINENCAP_PTYPE 0x12
@@ -101,6 +107,7 @@
#define CC_PC_GENERIC_WITH_MASK 0x28
#define CC_PC_GENERIC_IC_GMASK 0x2B
#define CC_PC_GENERIC_IC_HASH_INDEXED 0x2C
+#define CC_PC_GENERIC_IC_AGING_MASK 0x2D
#define CC_PR_OFFSET 0x25
#define CC_PR_WITHOUT_OFFSET 0x26
@@ -126,9 +133,10 @@
#define CC_SIZE_ILLEGAL 0
#define FM_PCD_CC_KEYS_MATCH_TABLE_ALIGN 16
-#define FM_PCD_CC_AD_TABLE_ALIGN 256
+#define FM_PCD_CC_AD_TABLE_ALIGN 16
#define FM_PCD_CC_AD_ENTRY_SIZE 16
#define FM_PCD_CC_NUM_OF_KEYS 255
+#define FM_PCD_CC_TREE_ADDR_ALIGN 256
#define FM_PCD_AD_RESULT_CONTRL_FLOW_TYPE 0x00000000
#define FM_PCD_AD_RESULT_DATA_FLOW_TYPE 0x80000000
@@ -137,17 +145,37 @@
#define FM_PCD_AD_RESULT_NADEN 0x20000000
#define FM_PCD_AD_RESULT_STATISTICS_EN 0x40000000
-
#define FM_PCD_AD_CONT_LOOKUP_TYPE 0x40000000
#define FM_PCD_AD_CONT_LOOKUP_LCL_MASK 0x00800000
+#define FM_PCD_AD_STATS_TYPE 0x40000000
+#define FM_PCD_AD_STATS_FLR_ADDR_MASK 0x00FFFFFF
+#define FM_PCD_AD_STATS_COUNTERS_ADDR_MASK 0x00FFFFFF
+#define FM_PCD_AD_STATS_NEXT_ACTION_MASK 0xFFFF0000
+#define FM_PCD_AD_STATS_NEXT_ACTION_SHIFT 12
+#define FM_PCD_AD_STATS_NAD_EN 0x00008000
+#define FM_PCD_AD_STATS_OP_CODE 0x00000036
+#define FM_PCD_AD_STATS_FLR_EN 0x00004000
+#define FM_PCD_AD_STATS_COND_EN 0x00002000
+
+
+
+#define FM_PCD_AD_BYPASS_TYPE 0xc0000000
+
#define FM_PCD_AD_TYPE_MASK 0xc0000000
#define FM_PCD_AD_OPCODE_MASK 0x0000000f
#define FM_PCD_AD_PROFILEID_FOR_CNTRL_SHIFT 16
+#if (DPAA_VERSION >= 11)
+#define FM_PCD_AD_RESULT_VSP_SHIFT 24
+#define FM_PCD_AD_RESULT_NO_OM_VSPE 0x02000000
+#define FM_PCD_AD_RESULT_VSP_MASK 0x3f
+#define FM_PCD_AD_NCSPFQIDM_MASK 0x80000000
+#endif /* (DPAA_VERSION >= 11) */
#define GLBL_MASK_FOR_HASH_INDEXED 0xfff00000
#define CC_GLBL_MASK_SIZE 4
+#define CC_AGING_MASK_SIZE 4
typedef uint32_t ccPrivateInfo_t; /**< private info of CC: */
@@ -157,156 +185,215 @@ typedef uint32_t ccPrivateInfo_t; /**< private info of CC: */
#define CC_PRIVATE_INFO_IC_KEY_EXACT_MATCH 0x20000000
#define CC_PRIVATE_INFO_IC_DEQ_FQID_INDEX_LOOKUP 0x10000000
+#define CC_BUILD_AGING_MASK(numOfKeys) ((((1LL << ((numOfKeys) + 1)) - 1)) << (31 - (numOfKeys)))
/***********************************************************************/
/* Memory map */
/***********************************************************************/
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(push,1)
#endif /* defined(__MWERKS__) && ... */
-#define MEM_MAP_START
-typedef _Packed struct {
+typedef struct
+{
volatile uint32_t fqid;
volatile uint32_t plcrProfile;
volatile uint32_t nia;
- volatile uint32_t res;
-} _PackedType t_AdOfTypeResult;
+ volatile uint32_t res;
+} t_AdOfTypeResult;
-typedef _Packed struct {
+typedef struct
+{
volatile uint32_t ccAdBase;
volatile uint32_t matchTblPtr;
volatile uint32_t pcAndOffsets;
volatile uint32_t gmask;
-} _PackedType t_AdOfTypeContLookup;
-
-typedef _Packed union {
+} t_AdOfTypeContLookup;
+
+typedef struct
+{
+ volatile uint32_t profileTableAddr;
+ volatile uint32_t reserved;
+ volatile uint32_t nextActionIndx;
+ volatile uint32_t statsTableAddr;
+} t_AdOfTypeStats;
+
+typedef union
+{
volatile t_AdOfTypeResult adResult;
volatile t_AdOfTypeContLookup adContLookup;
-} _PackedType t_Ad;
+} t_Ad;
-#define MEM_MAP_END
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(pop)
#endif /* defined(__MWERKS__) && ... */
/***********************************************************************/
-/* Driver's internal structures */
+/* Driver's internal structures */
/***********************************************************************/
-typedef enum e_ModifyState {
- e_MODIFY_STATE_ADD = 0,
- e_MODIFY_STATE_REMOVE,
- e_MODIFY_STATE_CHANGE
-} e_ModifyState;
+typedef struct t_FmPcdStatsObj
+{
+ t_Handle h_StatsAd;
+ t_Handle h_StatsCounters;
+ t_List node;
+} t_FmPcdStatsObj;
+
+typedef struct
+{
+ uint8_t key[FM_PCD_MAX_SIZE_OF_KEY];
+ uint8_t mask[FM_PCD_MAX_SIZE_OF_KEY];
-typedef struct {
t_FmPcdCcNextEngineParams nextEngineParams;
uint32_t requiredAction;
uint32_t shadowAction;
-} t_FmPcdCcNextEngineAndRequiredActionParams;
-
-typedef struct {
- t_Handle p_Ad;
- e_FmPcdEngine fmPcdEngine;
- bool adAllocated;
- bool isTree;
-
- uint32_t myInfo;
- t_List *h_CcNextNodesLst;
- t_Handle h_AdditionalInfo;
- t_Handle h_Node;
-} t_FmPcdModifyCcAdditionalParams;
-typedef struct {
- t_Handle p_AdTableNew;
- t_Handle p_KeysMatchTableNew;
- t_Handle p_AdTableOld;
- t_Handle p_KeysMatchTableOld;
- uint16_t numOfKeys;
- t_Handle h_CurrentNode;
- uint16_t keyIndex;
- t_Handle h_NodeForAdd;
- t_Handle h_NodeForRmv;
- t_Handle h_ManipForRmv;
- bool tree;
-
- t_FmPcdCcNextEngineAndRequiredActionParams nextEngineAndRequiredAction[256];
-} t_FmPcdModifyCcKeyAdditionalParams;
+ t_FmPcdStatsObj *p_StatsObj;
-typedef struct {
- t_Handle h_Manip;
- t_Handle h_CcNode;
-} t_CcNextEngineInfo;
-
-typedef struct {
- uint16_t numOfKeys;
- bool glblMaskUpdated;
- t_Handle p_GlblMask;
- bool lclMask;
- uint8_t parseCode;
- uint8_t offset;
- uint8_t prsArrayOffset;
- bool ctrlFlow;
- uint8_t owners;
-
- uint8_t ccKeySizeAccExtraction;
- uint8_t sizeOfExtraction;
- uint8_t glblMaskSize;
+} t_FmPcdCcKeyAndNextEngineParams;
- t_Handle h_KeysMatchTable;
- t_Handle h_AdTable;
+typedef struct
+{
+ t_Handle p_Ad;
+ e_FmPcdEngine fmPcdEngine;
+ bool adAllocated;
+ bool isTree;
- t_List ccPrevNodesLst;
+ uint32_t myInfo;
+ t_List *h_CcNextNodesLst;
+ t_Handle h_AdditionalInfo;
+ t_Handle h_Node;
+} t_FmPcdModifyCcAdditionalParams;
- t_List ccTreeIdLst;
- t_List ccTreesLst;
+typedef struct
+{
+ t_Handle p_AdTableNew;
+ t_Handle p_KeysMatchTableNew;
+ t_Handle p_AdTableOld;
+ t_Handle p_KeysMatchTableOld;
+ uint16_t numOfKeys;
+ t_Handle h_CurrentNode;
+ uint16_t savedKeyIndex;
+ t_Handle h_NodeForAdd;
+ t_Handle h_NodeForRmv;
+ t_Handle h_ManipForRmv;
+ t_Handle h_ManipForAdd;
+ t_FmPcdStatsObj *p_StatsObjForRmv;
+#if (DPAA_VERSION >= 11)
+ t_Handle h_FrmReplicForAdd;
+ t_Handle h_FrmReplicForRmv;
+#endif /* (DPAA_VERSION >= 11) */
+ bool tree;
+
+ t_FmPcdCcKeyAndNextEngineParams keyAndNextEngineParams[CC_MAX_NUM_OF_KEYS];
+} t_FmPcdModifyCcKeyAdditionalParams;
- t_Handle h_FmPcd;
- uint32_t shadowAction;
- bool modifiedState;
- uint8_t userSizeOfExtraction;
+typedef struct
+{
+ t_Handle h_Manip;
+ t_Handle h_CcNode;
+} t_CcNextEngineInfo;
- t_FmPcdCcNextEngineAndRequiredActionParams nextEngineAndRequiredAction[256];
+typedef struct
+{
+ uint16_t numOfKeys;
+ uint16_t maxNumOfKeys;
+
+ bool maskSupport;
+ uint32_t keysMatchTableMaxSize;
+
+ e_FmPcdCcStatsMode statisticsMode;
+ uint32_t numOfStatsFLRs;
+ uint32_t countersArraySize;
+
+ bool isHashBucket; /**< Valid for match table node that is a bucket of a hash table only */
+ t_Handle h_MissStatsCounters; /**< Valid for hash table node and match table that is a bucket;
+ Holds the statistics counters allocated by the hash table and
+ are shared by all hash table buckets; */
+ t_Handle h_PrivMissStatsCounters; /**< Valid for match table node that is a bucket of a hash table only;
+ Holds the statistics counters that were allocated for this node
+ and replaced by the shared counters (allocated by the hash table); */
+ bool statsEnForMiss; /**< Valid for hash table node only; TRUE is statistics are currently
+ enabled for hash 'miss', FALSE otherwise; This parameter effects the
+ returned statistics count to user, statistics AD always present for 'miss'
+ for all hash buckets; */
+ bool glblMaskUpdated;
+ t_Handle p_GlblMask;
+ bool lclMask;
+ uint8_t parseCode;
+ uint8_t offset;
+ uint8_t prsArrayOffset;
+ bool ctrlFlow;
+ uint16_t owners;
+
+ uint8_t ccKeySizeAccExtraction;
+ uint8_t sizeOfExtraction;
+ uint8_t glblMaskSize;
+
+ t_Handle h_KeysMatchTable;
+ t_Handle h_AdTable;
+ t_Handle h_StatsAds;
+ t_Handle h_TmpAd;
+ t_Handle h_Ad;
+ t_Handle h_StatsFLRs;
+
+ t_List availableStatsLst;
+
+ t_List ccPrevNodesLst;
+
+ t_List ccTreeIdLst;
+ t_List ccTreesLst;
+
+ t_Handle h_FmPcd;
+ uint32_t shadowAction;
+ uint8_t userSizeOfExtraction;
+ uint8_t userOffset;
+ uint8_t kgHashShift; /* used in hash-table */
+
+ t_Handle h_Spinlock;
+
+ t_FmPcdCcKeyAndNextEngineParams keyAndNextEngineParams[CC_MAX_NUM_OF_KEYS];
} t_FmPcdCcNode;
-typedef struct {
+typedef struct
+{
t_FmPcdCcNode *p_FmPcdCcNode;
bool occupied;
- uint8_t owners;
+ uint16_t owners;
volatile bool lock;
} t_FmPcdCcNodeArray;
-typedef struct {
+typedef struct
+{
uint8_t numOfEntriesInGroup;
uint32_t totalBitsMask;
uint8_t baseGroupEntry;
} t_FmPcdCcGroupParam;
-typedef struct {
+typedef struct
+{
+ t_Handle h_FmPcd;
uint8_t netEnvId;
uintptr_t ccTreeBaseAddr;
uint8_t numOfGrps;
t_FmPcdCcGroupParam fmPcdGroupParam[FM_PCD_MAX_NUM_OF_CC_GROUPS];
t_List fmPortsLst;
- volatile bool lock;
+ t_FmPcdLock *p_Lock;
uint8_t numOfEntries;
- uint8_t owners;
- t_Handle *fmPcdCcSavedManipParams[256];
+ uint16_t owners;
+ t_Handle h_FmPcdCcSavedManipParams;
bool modifiedState;
uint32_t requiredAction;
- t_FmPcdCcNextEngineAndRequiredActionParams nextEngineAndRequiredAction[FM_PCD_MAX_NUM_OF_KEYS];
-} t_FmPcdCcTree;
+ t_Handle h_IpReassemblyManip;
+ t_Handle h_CapwapReassemblyManip;
-typedef struct {
- t_FmPcdCcTree *p_FmPcdCcTree;
- bool occupied;
- uint8_t owners;
- volatile bool lock;
-} t_FmPcdCcTreeArray;
+ t_FmPcdCcKeyAndNextEngineParams keyAndNextEngineParams[FM_PCD_MAX_NUM_OF_CC_GROUPS];
+} t_FmPcdCcTree;
-bool FmPcdManipIsManipNode(t_Handle h_Ad);
+t_Error FmPcdCcNodeTreeTryLock(t_Handle h_FmPcd,t_Handle h_FmPcdCcNode, t_List *p_List);
+void FmPcdCcNodeTreeReleaseLock(t_Handle h_FmPcd, t_List *p_List);
+t_Error FmPcdUpdateCcShadow (t_FmPcd *p_FmPcd, uint32_t size, uint32_t align);
#endif /* __FM_CC_H */
diff --git a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_kg.c b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_kg.c
index ca93ec513cab..f183d2f9ee05 100644
--- a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_kg.c
+++ b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_kg.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm_kg.c
@@ -45,17 +46,59 @@
#include "fm_common.h"
#include "fm_pcd.h"
#include "fm_hc.h"
-
#include "fm_pcd_ipc.h"
+#include "fm_kg.h"
+#include "fsl_fman_kg.h"
+
+
+/****************************************/
+/* static functions */
+/****************************************/
+
+static uint32_t KgHwLock(t_Handle h_FmPcdKg)
+{
+ ASSERT_COND(h_FmPcdKg);
+ return XX_LockIntrSpinlock(((t_FmPcdKg *)h_FmPcdKg)->h_HwSpinlock);
+}
+
+static void KgHwUnlock(t_Handle h_FmPcdKg, uint32_t intFlags)
+{
+ ASSERT_COND(h_FmPcdKg);
+ XX_UnlockIntrSpinlock(((t_FmPcdKg *)h_FmPcdKg)->h_HwSpinlock, intFlags);
+}
+
+static uint32_t KgSchemeLock(t_Handle h_Scheme)
+{
+ ASSERT_COND(h_Scheme);
+ return FmPcdLockSpinlock(((t_FmPcdKgScheme *)h_Scheme)->p_Lock);
+}
+static void KgSchemeUnlock(t_Handle h_Scheme, uint32_t intFlags)
+{
+ ASSERT_COND(h_Scheme);
+ FmPcdUnlockSpinlock(((t_FmPcdKgScheme *)h_Scheme)->p_Lock, intFlags);
+}
+
+static bool KgSchemeFlagTryLock(t_Handle h_Scheme)
+{
+ ASSERT_COND(h_Scheme);
+ return FmPcdLockTryLock(((t_FmPcdKgScheme *)h_Scheme)->p_Lock);
+}
-static t_Error WriteKgarWait(t_FmPcd *p_FmPcd, uint32_t kgar)
+static void KgSchemeFlagUnlock(t_Handle h_Scheme)
{
- WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->kgar, kgar);
- /* Wait for GO to be idle and read error */
- while ((kgar = GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->kgar)) & FM_PCD_KG_KGAR_GO) ;
- if (kgar & FM_PCD_KG_KGAR_ERR)
+ ASSERT_COND(h_Scheme);
+ FmPcdLockUnlock(((t_FmPcdKgScheme *)h_Scheme)->p_Lock);
+}
+
+static t_Error WriteKgarWait(t_FmPcd *p_FmPcd, uint32_t fmkg_ar)
+{
+
+ struct fman_kg_regs *regs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
+
+ if (fman_kg_write_ar_wait(regs, fmkg_ar))
RETURN_ERROR(MINOR, E_INVALID_STATE, ("Keygen scheme access violation"));
+
return E_OK;
}
@@ -63,81 +106,84 @@ static e_FmPcdKgExtractDfltSelect GetGenericSwDefault(t_FmPcdKgExtractDflt swDef
{
int i;
- switch(code)
+ switch (code)
{
- case( KG_SCH_GEN_PARSE_RESULT_N_FQID):
- case( KG_SCH_GEN_DEFAULT):
- case( KG_SCH_GEN_NEXTHDR):
- for(i=0 ; i<numOfSwDefaults ; i++)
- if(swDefaults[i].type == e_FM_PCD_KG_GENERIC_NOT_FROM_DATA)
+ case (KG_SCH_GEN_PARSE_RESULT_N_FQID):
+ case (KG_SCH_GEN_DEFAULT):
+ case (KG_SCH_GEN_NEXTHDR):
+ for (i=0 ; i<numOfSwDefaults ; i++)
+ if (swDefaults[i].type == e_FM_PCD_KG_GENERIC_NOT_FROM_DATA)
return swDefaults[i].dfltSelect;
- ASSERT_COND(FALSE);
- case( KG_SCH_GEN_SHIM1):
- case( KG_SCH_GEN_SHIM2):
- case( KG_SCH_GEN_IP_PID_NO_V):
- case( KG_SCH_GEN_ETH_NO_V):
- case( KG_SCH_GEN_SNAP_NO_V):
- case( KG_SCH_GEN_VLAN1_NO_V):
- case( KG_SCH_GEN_VLAN2_NO_V):
- case( KG_SCH_GEN_ETH_TYPE_NO_V):
- case( KG_SCH_GEN_PPP_NO_V):
- case( KG_SCH_GEN_MPLS1_NO_V):
- case( KG_SCH_GEN_MPLS_LAST_NO_V):
- case( KG_SCH_GEN_L3_NO_V):
- case( KG_SCH_GEN_IP2_NO_V):
- case( KG_SCH_GEN_GRE_NO_V):
- case( KG_SCH_GEN_L4_NO_V):
- for(i=0 ; i<numOfSwDefaults ; i++)
- if(swDefaults[i].type == e_FM_PCD_KG_GENERIC_FROM_DATA_NO_V)
+ break;
+ case (KG_SCH_GEN_SHIM1):
+ case (KG_SCH_GEN_SHIM2):
+ case (KG_SCH_GEN_IP_PID_NO_V):
+ case (KG_SCH_GEN_ETH_NO_V):
+ case (KG_SCH_GEN_SNAP_NO_V):
+ case (KG_SCH_GEN_VLAN1_NO_V):
+ case (KG_SCH_GEN_VLAN2_NO_V):
+ case (KG_SCH_GEN_ETH_TYPE_NO_V):
+ case (KG_SCH_GEN_PPP_NO_V):
+ case (KG_SCH_GEN_MPLS1_NO_V):
+ case (KG_SCH_GEN_MPLS_LAST_NO_V):
+ case (KG_SCH_GEN_L3_NO_V):
+ case (KG_SCH_GEN_IP2_NO_V):
+ case (KG_SCH_GEN_GRE_NO_V):
+ case (KG_SCH_GEN_L4_NO_V):
+ for (i=0 ; i<numOfSwDefaults ; i++)
+ if (swDefaults[i].type == e_FM_PCD_KG_GENERIC_FROM_DATA_NO_V)
return swDefaults[i].dfltSelect;
-
- case( KG_SCH_GEN_START_OF_FRM):
- case( KG_SCH_GEN_ETH):
- case( KG_SCH_GEN_SNAP):
- case( KG_SCH_GEN_VLAN1):
- case( KG_SCH_GEN_VLAN2):
- case( KG_SCH_GEN_ETH_TYPE):
- case( KG_SCH_GEN_PPP):
- case( KG_SCH_GEN_MPLS1):
- case( KG_SCH_GEN_MPLS2):
- case( KG_SCH_GEN_MPLS3):
- case( KG_SCH_GEN_MPLS_LAST):
- case( KG_SCH_GEN_IPV4):
- case( KG_SCH_GEN_IPV6):
- case( KG_SCH_GEN_IPV4_TUNNELED):
- case( KG_SCH_GEN_IPV6_TUNNELED):
- case( KG_SCH_GEN_MIN_ENCAP):
- case( KG_SCH_GEN_GRE):
- case( KG_SCH_GEN_TCP):
- case( KG_SCH_GEN_UDP):
- case( KG_SCH_GEN_IPSEC_AH):
- case( KG_SCH_GEN_SCTP):
- case( KG_SCH_GEN_DCCP):
- case( KG_SCH_GEN_IPSEC_ESP):
- for(i=0 ; i<numOfSwDefaults ; i++)
- if(swDefaults[i].type == e_FM_PCD_KG_GENERIC_FROM_DATA)
+ break;
+ case (KG_SCH_GEN_START_OF_FRM):
+ case (KG_SCH_GEN_ETH):
+ case (KG_SCH_GEN_SNAP):
+ case (KG_SCH_GEN_VLAN1):
+ case (KG_SCH_GEN_VLAN2):
+ case (KG_SCH_GEN_ETH_TYPE):
+ case (KG_SCH_GEN_PPP):
+ case (KG_SCH_GEN_MPLS1):
+ case (KG_SCH_GEN_MPLS2):
+ case (KG_SCH_GEN_MPLS3):
+ case (KG_SCH_GEN_MPLS_LAST):
+ case (KG_SCH_GEN_IPV4):
+ case (KG_SCH_GEN_IPV6):
+ case (KG_SCH_GEN_IPV4_TUNNELED):
+ case (KG_SCH_GEN_IPV6_TUNNELED):
+ case (KG_SCH_GEN_MIN_ENCAP):
+ case (KG_SCH_GEN_GRE):
+ case (KG_SCH_GEN_TCP):
+ case (KG_SCH_GEN_UDP):
+ case (KG_SCH_GEN_IPSEC_AH):
+ case (KG_SCH_GEN_SCTP):
+ case (KG_SCH_GEN_DCCP):
+ case (KG_SCH_GEN_IPSEC_ESP):
+ for (i=0 ; i<numOfSwDefaults ; i++)
+ if (swDefaults[i].type == e_FM_PCD_KG_GENERIC_FROM_DATA)
return swDefaults[i].dfltSelect;
+ break;
default:
- return e_FM_PCD_KG_DFLT_ILLEGAL;
+ break;
}
+
+ return e_FM_PCD_KG_DFLT_ILLEGAL;
}
static uint8_t GetGenCode(e_FmPcdExtractFrom src, uint8_t *p_Offset)
{
*p_Offset = 0;
- switch(src)
+ switch (src)
{
- case(e_FM_PCD_EXTRACT_FROM_FRAME_START):
+ case (e_FM_PCD_EXTRACT_FROM_FRAME_START):
return KG_SCH_GEN_START_OF_FRM;
- case(e_FM_PCD_EXTRACT_FROM_DFLT_VALUE):
+ case (e_FM_PCD_EXTRACT_FROM_DFLT_VALUE):
return KG_SCH_GEN_DEFAULT;
- case(e_FM_PCD_EXTRACT_FROM_PARSE_RESULT):
+ case (e_FM_PCD_EXTRACT_FROM_PARSE_RESULT):
return KG_SCH_GEN_PARSE_RESULT_N_FQID;
- case(e_FM_PCD_EXTRACT_FROM_ENQ_FQID):
+ case (e_FM_PCD_EXTRACT_FROM_ENQ_FQID):
*p_Offset = 32;
return KG_SCH_GEN_PARSE_RESULT_N_FQID;
- case(e_FM_PCD_EXTRACT_FROM_CURR_END_OF_PARSE):
+ case (e_FM_PCD_EXTRACT_FROM_CURR_END_OF_PARSE):
return KG_SCH_GEN_NEXTHDR;
default:
REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 'extract from' src"));
@@ -147,104 +193,104 @@ static uint8_t GetGenCode(e_FmPcdExtractFrom src, uint8_t *p_Offset)
static uint8_t GetGenHdrCode(e_NetHeaderType hdr, e_FmPcdHdrIndex hdrIndex, bool ignoreProtocolValidation)
{
- if(!ignoreProtocolValidation)
- switch(hdr)
+ if (!ignoreProtocolValidation)
+ switch (hdr)
{
- case(HEADER_TYPE_NONE):
+ case (HEADER_TYPE_NONE):
ASSERT_COND(FALSE);
- case(HEADER_TYPE_ETH):
+ case (HEADER_TYPE_ETH):
return KG_SCH_GEN_ETH;
- case(HEADER_TYPE_LLC_SNAP):
+ case (HEADER_TYPE_LLC_SNAP):
return KG_SCH_GEN_SNAP;
- case(HEADER_TYPE_PPPoE):
+ case (HEADER_TYPE_PPPoE):
return KG_SCH_GEN_PPP;
- case(HEADER_TYPE_MPLS):
- if((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
+ case (HEADER_TYPE_MPLS):
+ if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
return KG_SCH_GEN_MPLS1;
- if(hdrIndex == e_FM_PCD_HDR_INDEX_2)
+ if (hdrIndex == e_FM_PCD_HDR_INDEX_2)
return KG_SCH_GEN_MPLS2;
- if(hdrIndex == e_FM_PCD_HDR_INDEX_3)
+ if (hdrIndex == e_FM_PCD_HDR_INDEX_3)
return KG_SCH_GEN_MPLS3;
- if(hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
+ if (hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
return KG_SCH_GEN_MPLS_LAST;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal MPLS header index"));
return 0;
- case(HEADER_TYPE_IPv4):
- if((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
+ case (HEADER_TYPE_IPv4):
+ if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
return KG_SCH_GEN_IPV4;
- if(hdrIndex == e_FM_PCD_HDR_INDEX_2)
+ if ((hdrIndex == e_FM_PCD_HDR_INDEX_2) || (hdrIndex == e_FM_PCD_HDR_INDEX_LAST))
return KG_SCH_GEN_IPV4_TUNNELED;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 header index"));
return 0;
- case(HEADER_TYPE_IPv6):
- if((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
+ case (HEADER_TYPE_IPv6):
+ if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
return KG_SCH_GEN_IPV6;
- if(hdrIndex == e_FM_PCD_HDR_INDEX_2)
+ if ((hdrIndex == e_FM_PCD_HDR_INDEX_2) || (hdrIndex == e_FM_PCD_HDR_INDEX_LAST))
return KG_SCH_GEN_IPV6_TUNNELED;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 header index"));
return 0;
- case(HEADER_TYPE_GRE):
+ case (HEADER_TYPE_GRE):
return KG_SCH_GEN_GRE;
- case(HEADER_TYPE_TCP):
+ case (HEADER_TYPE_TCP):
return KG_SCH_GEN_TCP;
- case(HEADER_TYPE_UDP):
+ case (HEADER_TYPE_UDP):
return KG_SCH_GEN_UDP;
- case(HEADER_TYPE_IPSEC_AH):
+ case (HEADER_TYPE_IPSEC_AH):
return KG_SCH_GEN_IPSEC_AH;
- case(HEADER_TYPE_IPSEC_ESP):
+ case (HEADER_TYPE_IPSEC_ESP):
return KG_SCH_GEN_IPSEC_ESP;
- case(HEADER_TYPE_SCTP):
+ case (HEADER_TYPE_SCTP):
return KG_SCH_GEN_SCTP;
- case(HEADER_TYPE_DCCP):
+ case (HEADER_TYPE_DCCP):
return KG_SCH_GEN_DCCP;
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
}
else
- switch(hdr)
+ switch (hdr)
{
- case(HEADER_TYPE_NONE):
+ case (HEADER_TYPE_NONE):
ASSERT_COND(FALSE);
- case(HEADER_TYPE_ETH):
+ case (HEADER_TYPE_ETH):
return KG_SCH_GEN_ETH_NO_V;
- case(HEADER_TYPE_LLC_SNAP):
+ case (HEADER_TYPE_LLC_SNAP):
return KG_SCH_GEN_SNAP_NO_V;
- case(HEADER_TYPE_PPPoE):
+ case (HEADER_TYPE_PPPoE):
return KG_SCH_GEN_PPP_NO_V;
- case(HEADER_TYPE_MPLS):
- if((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
+ case (HEADER_TYPE_MPLS):
+ if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
return KG_SCH_GEN_MPLS1_NO_V;
- if(hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
+ if (hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
return KG_SCH_GEN_MPLS_LAST_NO_V;
- if((hdrIndex == e_FM_PCD_HDR_INDEX_2) || (hdrIndex == e_FM_PCD_HDR_INDEX_3) )
+ if ((hdrIndex == e_FM_PCD_HDR_INDEX_2) || (hdrIndex == e_FM_PCD_HDR_INDEX_3) )
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Indexed MPLS Extraction not supported"));
else
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal MPLS header index"));
return 0;
- case(HEADER_TYPE_IPv4):
- case(HEADER_TYPE_IPv6):
- if((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
+ case (HEADER_TYPE_IPv4):
+ case (HEADER_TYPE_IPv6):
+ if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
return KG_SCH_GEN_L3_NO_V;
- if(hdrIndex == e_FM_PCD_HDR_INDEX_2)
+ if ((hdrIndex == e_FM_PCD_HDR_INDEX_2) || (hdrIndex == e_FM_PCD_HDR_INDEX_LAST))
return KG_SCH_GEN_IP2_NO_V;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IP header index"));
- case(HEADER_TYPE_MINENCAP):
+ case (HEADER_TYPE_MINENCAP):
return KG_SCH_GEN_IP2_NO_V;
- case(HEADER_TYPE_USER_DEFINED_L3):
+ case (HEADER_TYPE_USER_DEFINED_L3):
return KG_SCH_GEN_L3_NO_V;
- case(HEADER_TYPE_GRE):
+ case (HEADER_TYPE_GRE):
return KG_SCH_GEN_GRE_NO_V;
- case(HEADER_TYPE_TCP):
- case(HEADER_TYPE_UDP):
- case(HEADER_TYPE_IPSEC_AH):
- case(HEADER_TYPE_IPSEC_ESP):
- case(HEADER_TYPE_SCTP):
- case(HEADER_TYPE_DCCP):
+ case (HEADER_TYPE_TCP):
+ case (HEADER_TYPE_UDP):
+ case (HEADER_TYPE_IPSEC_AH):
+ case (HEADER_TYPE_IPSEC_ESP):
+ case (HEADER_TYPE_SCTP):
+ case (HEADER_TYPE_DCCP):
return KG_SCH_GEN_L4_NO_V;
- case(HEADER_TYPE_USER_DEFINED_SHIM1):
+ case (HEADER_TYPE_USER_DEFINED_SHIM1):
return KG_SCH_GEN_SHIM1;
- case(HEADER_TYPE_USER_DEFINED_SHIM2):
+ case (HEADER_TYPE_USER_DEFINED_SHIM2):
return KG_SCH_GEN_SHIM2;
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
@@ -254,149 +300,162 @@ static uint8_t GetGenHdrCode(e_NetHeaderType hdr, e_FmPcdHdrIndex hdrIndex, bool
static t_GenericCodes GetGenFieldCode(e_NetHeaderType hdr, t_FmPcdFields field, bool ignoreProtocolValidation, e_FmPcdHdrIndex hdrIndex)
{
if (!ignoreProtocolValidation)
- switch(hdr)
+ switch (hdr)
{
- case(HEADER_TYPE_NONE):
+ case (HEADER_TYPE_NONE):
ASSERT_COND(FALSE);
- case(HEADER_TYPE_ETH):
- switch(field.eth)
+ break;
+ case (HEADER_TYPE_ETH):
+ switch (field.eth)
{
- case(NET_HEADER_FIELD_ETH_TYPE):
+ case (NET_HEADER_FIELD_ETH_TYPE):
return KG_SCH_GEN_ETH_TYPE;
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
}
- case(HEADER_TYPE_VLAN):
- switch(field.vlan)
+ break;
+ case (HEADER_TYPE_VLAN):
+ switch (field.vlan)
{
- case(NET_HEADER_FIELD_VLAN_TCI):
- if((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_VLAN_TCI):
+ if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
return KG_SCH_GEN_VLAN1;
- if(hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
+ if (hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
return KG_SCH_GEN_VLAN2;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal VLAN header index"));
return 0;
}
- case(HEADER_TYPE_MPLS):
- case(HEADER_TYPE_IPSEC_AH):
- case(HEADER_TYPE_IPSEC_ESP):
- case(HEADER_TYPE_LLC_SNAP):
- case(HEADER_TYPE_PPPoE):
- case(HEADER_TYPE_IPv4):
- case(HEADER_TYPE_IPv6):
- case(HEADER_TYPE_GRE):
- case(HEADER_TYPE_MINENCAP):
- case(HEADER_TYPE_USER_DEFINED_L3):
- case(HEADER_TYPE_TCP):
- case(HEADER_TYPE_UDP):
- case(HEADER_TYPE_SCTP):
- case(HEADER_TYPE_DCCP):
- case(HEADER_TYPE_USER_DEFINED_L4):
+ break;
+ case (HEADER_TYPE_MPLS):
+ case (HEADER_TYPE_IPSEC_AH):
+ case (HEADER_TYPE_IPSEC_ESP):
+ case (HEADER_TYPE_LLC_SNAP):
+ case (HEADER_TYPE_PPPoE):
+ case (HEADER_TYPE_IPv4):
+ case (HEADER_TYPE_IPv6):
+ case (HEADER_TYPE_GRE):
+ case (HEADER_TYPE_MINENCAP):
+ case (HEADER_TYPE_USER_DEFINED_L3):
+ case (HEADER_TYPE_TCP):
+ case (HEADER_TYPE_UDP):
+ case (HEADER_TYPE_SCTP):
+ case (HEADER_TYPE_DCCP):
+ case (HEADER_TYPE_USER_DEFINED_L4):
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
- default:
- REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Header not supported"));
return 0;
+ default:
+ break;
+
}
else
- switch(hdr)
+ switch (hdr)
{
- case(HEADER_TYPE_NONE):
+ case (HEADER_TYPE_NONE):
ASSERT_COND(FALSE);
- case(HEADER_TYPE_ETH):
- switch(field.eth)
- {
- case(NET_HEADER_FIELD_ETH_TYPE):
- return KG_SCH_GEN_ETH_TYPE_NO_V;
- default:
- REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
- return 0;
- }
- case(HEADER_TYPE_VLAN):
- switch(field.vlan)
+ break;
+ case (HEADER_TYPE_ETH):
+ switch (field.eth)
{
- case(NET_HEADER_FIELD_VLAN_TCI) :
- if((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_ETH_TYPE):
+ return KG_SCH_GEN_ETH_TYPE_NO_V;
+ default:
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
+ return 0;
+ }
+ break;
+ case (HEADER_TYPE_VLAN):
+ switch (field.vlan)
+ {
+ case (NET_HEADER_FIELD_VLAN_TCI) :
+ if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
return KG_SCH_GEN_VLAN1_NO_V;
- if(hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
+ if (hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
return KG_SCH_GEN_VLAN2_NO_V;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal VLAN header index"));
return 0;
}
- case(HEADER_TYPE_IPv4):
- switch(field.ipv4)
+ break;
+ case (HEADER_TYPE_IPv4):
+ switch (field.ipv4)
{
- case(NET_HEADER_FIELD_IPv4_PROTO):
+ case (NET_HEADER_FIELD_IPv4_PROTO):
return KG_SCH_GEN_IP_PID_NO_V;
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
}
- case(HEADER_TYPE_IPv6):
- switch(field.ipv6)
+ break;
+ case (HEADER_TYPE_IPv6):
+ switch (field.ipv6)
{
- case(NET_HEADER_FIELD_IPv6_NEXT_HDR):
+ case (NET_HEADER_FIELD_IPv6_NEXT_HDR):
return KG_SCH_GEN_IP_PID_NO_V;
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
}
- case(HEADER_TYPE_MPLS):
- case(HEADER_TYPE_LLC_SNAP):
- case(HEADER_TYPE_PPPoE):
- case(HEADER_TYPE_GRE):
- case(HEADER_TYPE_MINENCAP):
- case(HEADER_TYPE_USER_DEFINED_L3):
- case(HEADER_TYPE_TCP):
- case(HEADER_TYPE_UDP):
- case(HEADER_TYPE_IPSEC_AH):
- case(HEADER_TYPE_IPSEC_ESP):
- case(HEADER_TYPE_SCTP):
- case(HEADER_TYPE_DCCP):
- case(HEADER_TYPE_USER_DEFINED_L4):
+ break;
+ case (HEADER_TYPE_MPLS):
+ case (HEADER_TYPE_LLC_SNAP):
+ case (HEADER_TYPE_PPPoE):
+ case (HEADER_TYPE_GRE):
+ case (HEADER_TYPE_MINENCAP):
+ case (HEADER_TYPE_USER_DEFINED_L3):
+ case (HEADER_TYPE_TCP):
+ case (HEADER_TYPE_UDP):
+ case (HEADER_TYPE_IPSEC_AH):
+ case (HEADER_TYPE_IPSEC_ESP):
+ case (HEADER_TYPE_SCTP):
+ case (HEADER_TYPE_DCCP):
+ case (HEADER_TYPE_USER_DEFINED_L4):
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
default:
- REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Header not supported"));
- return 0;
+ break;
}
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Header not supported"));
+ return 0;
}
-static t_KnownFieldsMasks GetKnownProtMask(e_NetHeaderType hdr, e_FmPcdHdrIndex index, t_FmPcdFields field)
+static t_KnownFieldsMasks GetKnownProtMask(t_FmPcd *p_FmPcd, e_NetHeaderType hdr, e_FmPcdHdrIndex index, t_FmPcdFields field)
{
- switch(hdr)
+ UNUSED(p_FmPcd);
+
+ switch (hdr)
{
- case(HEADER_TYPE_NONE):
+ case (HEADER_TYPE_NONE):
ASSERT_COND(FALSE);
- case(HEADER_TYPE_ETH):
- switch(field.eth)
+ break;
+ case (HEADER_TYPE_ETH):
+ switch (field.eth)
{
- case(NET_HEADER_FIELD_ETH_DA):
+ case (NET_HEADER_FIELD_ETH_DA):
return KG_SCH_KN_MACDST;
- case(NET_HEADER_FIELD_ETH_SA):
+ case (NET_HEADER_FIELD_ETH_SA):
return KG_SCH_KN_MACSRC;
- case(NET_HEADER_FIELD_ETH_TYPE):
+ case (NET_HEADER_FIELD_ETH_TYPE):
return KG_SCH_KN_ETYPE;
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
- }
- case(HEADER_TYPE_LLC_SNAP):
- switch(field.llcSnap)
+ }
+ case (HEADER_TYPE_LLC_SNAP):
+ switch (field.llcSnap)
{
- case(NET_HEADER_FIELD_LLC_SNAP_TYPE):
+ case (NET_HEADER_FIELD_LLC_SNAP_TYPE):
return KG_SCH_KN_ETYPE;
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
- }
- case(HEADER_TYPE_VLAN):
- switch(field.vlan)
+ }
+ case (HEADER_TYPE_VLAN):
+ switch (field.vlan)
{
- case(NET_HEADER_FIELD_VLAN_TCI):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_VLAN_TCI):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
return KG_SCH_KN_TCI1;
- if(index == e_FM_PCD_HDR_INDEX_LAST)
+ if (index == e_FM_PCD_HDR_INDEX_LAST)
return KG_SCH_KN_TCI2;
else
{
@@ -407,15 +466,15 @@ static t_KnownFieldsMasks GetKnownProtMask(e_NetHeaderType hdr, e_FmPcdHdrIndex
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
}
- case(HEADER_TYPE_MPLS):
- switch(field.mpls)
+ case (HEADER_TYPE_MPLS):
+ switch (field.mpls)
{
- case(NET_HEADER_FIELD_MPLS_LABEL_STACK):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_MPLS_LABEL_STACK):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
return KG_SCH_KN_MPLS1;
- if(index == e_FM_PCD_HDR_INDEX_2)
+ if (index == e_FM_PCD_HDR_INDEX_2)
return KG_SCH_KN_MPLS2;
- if(index == e_FM_PCD_HDR_INDEX_LAST)
+ if (index == e_FM_PCD_HDR_INDEX_LAST)
return KG_SCH_KN_MPLS_LAST;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal MPLS index"));
return 0;
@@ -423,34 +482,34 @@ static t_KnownFieldsMasks GetKnownProtMask(e_NetHeaderType hdr, e_FmPcdHdrIndex
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
}
- case(HEADER_TYPE_IPv4):
- switch(field.ipv4)
+ case (HEADER_TYPE_IPv4):
+ switch (field.ipv4)
{
- case(NET_HEADER_FIELD_IPv4_SRC_IP):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_IPv4_SRC_IP):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
return KG_SCH_KN_IPSRC1;
- if(index == e_FM_PCD_HDR_INDEX_2)
+ if ((index == e_FM_PCD_HDR_INDEX_2) || (index == e_FM_PCD_HDR_INDEX_LAST))
return KG_SCH_KN_IPSRC2;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));
return 0;
- case(NET_HEADER_FIELD_IPv4_DST_IP):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_IPv4_DST_IP):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
return KG_SCH_KN_IPDST1;
- if(index == e_FM_PCD_HDR_INDEX_2)
+ if ((index == e_FM_PCD_HDR_INDEX_2) || (index == e_FM_PCD_HDR_INDEX_LAST))
return KG_SCH_KN_IPDST2;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));
return 0;
- case(NET_HEADER_FIELD_IPv4_PROTO):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_IPv4_PROTO):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
return KG_SCH_KN_PTYPE1;
- if(index == e_FM_PCD_HDR_INDEX_2)
+ if ((index == e_FM_PCD_HDR_INDEX_2) || (index == e_FM_PCD_HDR_INDEX_LAST))
return KG_SCH_KN_PTYPE2;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));
return 0;
- case(NET_HEADER_FIELD_IPv4_TOS):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_IPv4_TOS):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
return KG_SCH_KN_IPTOS_TC1;
- if(index == e_FM_PCD_HDR_INDEX_2)
+ if ((index == e_FM_PCD_HDR_INDEX_2) || (index == e_FM_PCD_HDR_INDEX_LAST))
return KG_SCH_KN_IPTOS_TC2;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));
return 0;
@@ -458,144 +517,167 @@ static t_KnownFieldsMasks GetKnownProtMask(e_NetHeaderType hdr, e_FmPcdHdrIndex
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
}
- case(HEADER_TYPE_IPv6):
- switch(field.ipv6)
+ case (HEADER_TYPE_IPv6):
+ switch (field.ipv6)
{
- case(NET_HEADER_FIELD_IPv6_SRC_IP):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_IPv6_SRC_IP):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
return KG_SCH_KN_IPSRC1;
- if(index == e_FM_PCD_HDR_INDEX_2)
+ if ((index == e_FM_PCD_HDR_INDEX_2) || (index == e_FM_PCD_HDR_INDEX_LAST))
return KG_SCH_KN_IPSRC2;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
return 0;
- case(NET_HEADER_FIELD_IPv6_DST_IP):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_IPv6_DST_IP):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
return KG_SCH_KN_IPDST1;
- if(index == e_FM_PCD_HDR_INDEX_2)
+ if ((index == e_FM_PCD_HDR_INDEX_2) || (index == e_FM_PCD_HDR_INDEX_LAST))
return KG_SCH_KN_IPDST2;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
return 0;
- case(NET_HEADER_FIELD_IPv6_NEXT_HDR):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_IPv6_NEXT_HDR):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
return KG_SCH_KN_PTYPE1;
- if(index == e_FM_PCD_HDR_INDEX_2)
+ if (index == e_FM_PCD_HDR_INDEX_2)
return KG_SCH_KN_PTYPE2;
+ if (index == e_FM_PCD_HDR_INDEX_LAST)
+#ifdef FM_KG_NO_IPPID_SUPPORT
+ if (p_FmPcd->fmRevInfo.majorRev < 6)
+ return KG_SCH_KN_PTYPE2;
+#endif /* FM_KG_NO_IPPID_SUPPORT */
+ return KG_SCH_KN_IPPID;
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
return 0;
- case(NET_HEADER_FIELD_IPv6_VER | NET_HEADER_FIELD_IPv6_FL | NET_HEADER_FIELD_IPv6_TC):
- if((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ case (NET_HEADER_FIELD_IPv6_VER | NET_HEADER_FIELD_IPv6_FL | NET_HEADER_FIELD_IPv6_TC):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
return (KG_SCH_KN_IPV6FL1 | KG_SCH_KN_IPTOS_TC1);
- if(index == e_FM_PCD_HDR_INDEX_2)
+ if ((index == e_FM_PCD_HDR_INDEX_2) || (index == e_FM_PCD_HDR_INDEX_LAST))
return (KG_SCH_KN_IPV6FL2 | KG_SCH_KN_IPTOS_TC2);
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
return 0;
+ case (NET_HEADER_FIELD_IPv6_VER | NET_HEADER_FIELD_IPv6_TC):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ return KG_SCH_KN_IPTOS_TC1;
+ if ((index == e_FM_PCD_HDR_INDEX_2) || (index == e_FM_PCD_HDR_INDEX_LAST))
+ return KG_SCH_KN_IPTOS_TC2;
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
+ return 0;
+ case (NET_HEADER_FIELD_IPv6_FL):
+ if ((index == e_FM_PCD_HDR_INDEX_NONE) || (index == e_FM_PCD_HDR_INDEX_1))
+ return KG_SCH_KN_IPV6FL1;
+ if ((index == e_FM_PCD_HDR_INDEX_2) || (index == e_FM_PCD_HDR_INDEX_LAST))
+ return KG_SCH_KN_IPV6FL2;
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));
+ return 0;
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
}
- case(HEADER_TYPE_GRE):
- switch(field.gre)
+ case (HEADER_TYPE_GRE):
+ switch (field.gre)
{
- case(NET_HEADER_FIELD_GRE_TYPE):
+ case (NET_HEADER_FIELD_GRE_TYPE):
return KG_SCH_KN_GREPTYPE;
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
- }
- case(HEADER_TYPE_MINENCAP):
- switch(field.minencap)
+ }
+ case (HEADER_TYPE_MINENCAP):
+ switch (field.minencap)
{
- case(NET_HEADER_FIELD_MINENCAP_SRC_IP):
+ case (NET_HEADER_FIELD_MINENCAP_SRC_IP):
return KG_SCH_KN_IPSRC2;
- case(NET_HEADER_FIELD_MINENCAP_DST_IP):
+ case (NET_HEADER_FIELD_MINENCAP_DST_IP):
return KG_SCH_KN_IPDST2;
- case(NET_HEADER_FIELD_MINENCAP_TYPE):
+ case (NET_HEADER_FIELD_MINENCAP_TYPE):
return KG_SCH_KN_PTYPE2;
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
- }
- case(HEADER_TYPE_TCP):
- switch(field.tcp)
+ }
+ case (HEADER_TYPE_TCP):
+ switch (field.tcp)
{
- case(NET_HEADER_FIELD_TCP_PORT_SRC):
+ case (NET_HEADER_FIELD_TCP_PORT_SRC):
return KG_SCH_KN_L4PSRC;
- case(NET_HEADER_FIELD_TCP_PORT_DST):
+ case (NET_HEADER_FIELD_TCP_PORT_DST):
return KG_SCH_KN_L4PDST;
- case(NET_HEADER_FIELD_TCP_FLAGS):
+ case (NET_HEADER_FIELD_TCP_FLAGS):
return KG_SCH_KN_TFLG;
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
}
- case(HEADER_TYPE_UDP):
- switch(field.udp)
+ case (HEADER_TYPE_UDP):
+ switch (field.udp)
{
- case(NET_HEADER_FIELD_UDP_PORT_SRC):
+ case (NET_HEADER_FIELD_UDP_PORT_SRC):
return KG_SCH_KN_L4PSRC;
- case(NET_HEADER_FIELD_UDP_PORT_DST):
+ case (NET_HEADER_FIELD_UDP_PORT_DST):
return KG_SCH_KN_L4PDST;
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
}
- case(HEADER_TYPE_IPSEC_AH):
- switch(field.ipsecAh)
+ case (HEADER_TYPE_IPSEC_AH):
+ switch (field.ipsecAh)
{
- case(NET_HEADER_FIELD_IPSEC_AH_SPI):
+ case (NET_HEADER_FIELD_IPSEC_AH_SPI):
return KG_SCH_KN_IPSEC_SPI;
- case(NET_HEADER_FIELD_IPSEC_AH_NH):
+ case (NET_HEADER_FIELD_IPSEC_AH_NH):
return KG_SCH_KN_IPSEC_NH;
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
}
- case(HEADER_TYPE_IPSEC_ESP):
- switch(field.ipsecEsp)
+ case (HEADER_TYPE_IPSEC_ESP):
+ switch (field.ipsecEsp)
{
- case(NET_HEADER_FIELD_IPSEC_ESP_SPI):
+ case (NET_HEADER_FIELD_IPSEC_ESP_SPI):
return KG_SCH_KN_IPSEC_SPI;
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
}
- case(HEADER_TYPE_SCTP):
- switch(field.sctp)
+ case (HEADER_TYPE_SCTP):
+ switch (field.sctp)
{
- case(NET_HEADER_FIELD_SCTP_PORT_SRC):
+ case (NET_HEADER_FIELD_SCTP_PORT_SRC):
return KG_SCH_KN_L4PSRC;
- case(NET_HEADER_FIELD_SCTP_PORT_DST):
+ case (NET_HEADER_FIELD_SCTP_PORT_DST):
return KG_SCH_KN_L4PDST;
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
}
- case(HEADER_TYPE_DCCP):
- switch(field.dccp)
+ case (HEADER_TYPE_DCCP):
+ switch (field.dccp)
{
- case(NET_HEADER_FIELD_DCCP_PORT_SRC):
+ case (NET_HEADER_FIELD_DCCP_PORT_SRC):
return KG_SCH_KN_L4PSRC;
- case(NET_HEADER_FIELD_DCCP_PORT_DST):
+ case (NET_HEADER_FIELD_DCCP_PORT_DST):
return KG_SCH_KN_L4PDST;
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
}
- case(HEADER_TYPE_PPPoE):
- switch(field.pppoe)
+ case (HEADER_TYPE_PPPoE):
+ switch (field.pppoe)
{
- case(NET_HEADER_FIELD_PPPoE_PID):
+ case (NET_HEADER_FIELD_PPPoE_PID):
return KG_SCH_KN_PPPID;
- case(NET_HEADER_FIELD_PPPoE_SID):
+ case (NET_HEADER_FIELD_PPPoE_SID):
return KG_SCH_KN_PPPSID;
default:
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
return 0;
}
default:
- REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
- return 0;
+ break;
+
}
+
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));
+ return 0;
}
@@ -604,7 +686,7 @@ static uint8_t GetKnownFieldId(uint32_t bitMask)
uint8_t cnt = 0;
while (bitMask)
- if(bitMask & 0x80000000)
+ if (bitMask & 0x80000000)
break;
else
{
@@ -620,716 +702,211 @@ static uint8_t GetExtractedOrMask(uint8_t bitOffset, bool fqid)
uint8_t i, mask, numOfOnesToClear, walking1Mask = 1;
/* bitOffset 1-7 --> mask 0x1-0x7F */
- if(bitOffset<8)
+ if (bitOffset<8)
{
mask = 0;
- for(i = 0 ; i < bitOffset ; i++, walking1Mask <<= 1)
+ for (i = 0 ; i < bitOffset ; i++, walking1Mask <<= 1)
mask |= walking1Mask;
}
else
{
mask = 0xFF;
numOfOnesToClear = 0;
- if(fqid && bitOffset>24)
+ if (fqid && bitOffset>24)
/* bitOffset 25-31 --> mask 0xFE-0x80 */
numOfOnesToClear = (uint8_t)(bitOffset-24);
else
/* bitOffset 9-15 --> mask 0xFE-0x80 */
- if(!fqid && bitOffset>8)
+ if (!fqid && bitOffset>8)
numOfOnesToClear = (uint8_t)(bitOffset-8);
- for(i = 0 ; i < numOfOnesToClear ; i++, walking1Mask <<= 1)
+ for (i = 0 ; i < numOfOnesToClear ; i++, walking1Mask <<= 1)
mask &= ~walking1Mask;
/* bitOffset 8-24 for FQID, 8 for PP --> no mask (0xFF)*/
}
return mask;
}
-
-t_Error FmPcdKgBuildClsPlanGrp(t_Handle h_FmPcd, t_FmPcdKgInterModuleClsPlanGrpParams *p_Grp, t_FmPcdKgInterModuleClsPlanSet *p_ClsPlanSet)
+static void IncSchemeOwners(t_FmPcd *p_FmPcd, t_FmPcdKgInterModuleBindPortToSchemes *p_BindPort)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- t_FmPcdKgClsPlanGrp *p_ClsPlanGrp;
- t_FmPcdIpcKgClsPlanParams kgAlloc;
- t_Error err = E_OK;
- uint32_t oredVectors = 0;
- uint32_t intFlags;
- int i, j;
-
- if (p_Grp->numOfOptions >= FM_PCD_MAX_NUM_OF_OPTIONS(FM_PCD_MAX_NUM_OF_CLS_PLANS))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE,("Too many classification plan basic options selected."));
-
- intFlags = FmPcdLock(p_FmPcd);
-
- /* find a new clsPlan group */
- for(i = 0;i<FM_MAX_NUM_OF_PORTS;i++)
- if(!p_FmPcd->p_FmPcdKg->clsPlanGrps[i].used)
- break;
- if(i== FM_MAX_NUM_OF_PORTS)
- {
- FmPcdUnlock(p_FmPcd, intFlags);
- RETURN_ERROR(MAJOR, E_FULL,("No classification plan groups available."));
- }
- p_FmPcd->p_FmPcdKg->clsPlanGrps[i].used = TRUE;
- p_Grp->clsPlanGrpId = (uint8_t)i;
-
- if(p_Grp->numOfOptions == 0)
- p_FmPcd->p_FmPcdKg->emptyClsPlanGrpId = (uint8_t)i;
-
- if (!TRY_LOCK(NULL, &p_FmPcd->p_FmPcdKg->clsPlanGrps[p_Grp->clsPlanGrpId].lock))
- {
- FmPcdUnlock(p_FmPcd, intFlags);
- return ERROR_CODE(E_BUSY);
- }
- FmPcdUnlock(p_FmPcd, intFlags);
-
- p_ClsPlanGrp = &p_FmPcd->p_FmPcdKg->clsPlanGrps[i];
- p_ClsPlanGrp->netEnvId = p_Grp->netEnvId;
- p_ClsPlanGrp->owners = 0;
- FmPcdSetClsPlanGrpId(p_FmPcd, p_Grp->netEnvId, p_Grp->clsPlanGrpId);
- FmPcdIncNetEnvOwners(p_FmPcd, p_Grp->netEnvId);
-
- p_ClsPlanGrp->sizeOfGrp = (uint16_t)(1<<p_Grp->numOfOptions);
- /* a minimal group of 8 is required */
- if(p_ClsPlanGrp->sizeOfGrp < CLS_PLAN_NUM_PER_GRP)
- p_ClsPlanGrp->sizeOfGrp = CLS_PLAN_NUM_PER_GRP;
- if(p_FmPcd->guestId == NCSW_MASTER_ID)
- {
- err = KgAllocClsPlanEntries(h_FmPcd, p_ClsPlanGrp->sizeOfGrp, p_FmPcd->guestId, &p_ClsPlanGrp->baseEntry);
-
- if(err)
- {
- RELEASE_LOCK(p_FmPcd->p_FmPcdKg->clsPlanGrps[p_Grp->clsPlanGrpId].lock);
- RETURN_ERROR(MINOR, E_INVALID_STATE, NO_MSG);
- }
-
- }
- else
- {
- t_FmPcdIpcMsg msg;
- uint32_t replyLength;
- t_FmPcdIpcReply reply;
-
- /* in GUEST_PARTITION, we use the IPC, to also set a private driver group if required */
- memset(&reply, 0, sizeof(reply));
- memset(&msg, 0, sizeof(msg));
- memset(&kgAlloc, 0, sizeof(kgAlloc));
- kgAlloc.guestId = p_FmPcd->guestId;
- kgAlloc.numOfClsPlanEntries = p_ClsPlanGrp->sizeOfGrp;
- msg.msgId = FM_PCD_ALLOC_KG_CLSPLAN;
- memcpy(msg.msgBody, &kgAlloc, sizeof(kgAlloc));
- replyLength = (sizeof(uint32_t) + sizeof(p_ClsPlanGrp->baseEntry));
- if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
- (uint8_t*)&msg,
- sizeof(msg.msgId) + sizeof(kgAlloc),
- (uint8_t*)&reply,
- &replyLength,
- NULL,
- NULL)) != E_OK)
- {
- RELEASE_LOCK(p_FmPcd->p_FmPcdKg->clsPlanGrps[p_Grp->clsPlanGrpId].lock);
- RETURN_ERROR(MAJOR, err, NO_MSG);
- }
-
- if (replyLength != (sizeof(uint32_t) + sizeof(p_ClsPlanGrp->baseEntry)))
- {
- RELEASE_LOCK(p_FmPcd->p_FmPcdKg->clsPlanGrps[p_Grp->clsPlanGrpId].lock);
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
- }
- if ((t_Error)reply.error != E_OK)
- {
- RELEASE_LOCK(p_FmPcd->p_FmPcdKg->clsPlanGrps[p_Grp->clsPlanGrpId].lock);
- RETURN_ERROR(MINOR, (t_Error)reply.error, NO_MSG);
- }
-
- p_ClsPlanGrp->baseEntry = *(uint8_t*)(reply.replyBody);
- }
-
- /* build classification plan entries parameters */
- p_ClsPlanSet->baseEntry = p_ClsPlanGrp->baseEntry;
- p_ClsPlanSet->numOfClsPlanEntries = p_ClsPlanGrp->sizeOfGrp;
-
- oredVectors = 0;
- for(i = 0; i<p_Grp->numOfOptions; i++)
- {
- oredVectors |= p_Grp->optVectors[i];
- /* save an array of used options - the indexes represent the power of 2 index */
- p_ClsPlanGrp->optArray[i] = p_Grp->options[i];
- }
- /* set the classification plan relevant entries so that all bits
- * relevant to the list of options is cleared
- */
- for(j = 0; j<p_ClsPlanGrp->sizeOfGrp; j++)
- p_ClsPlanSet->vectors[j] = ~oredVectors;
-
- for(i = 0; i<p_Grp->numOfOptions; i++)
- {
- /* option i got the place 2^i in the clsPlan array. all entries that
- * have bit i set, should have the vector bit cleared. So each option
- * has one location that it is exclusive (1,2,4,8...) and represent the
- * presence of that option only, and other locations that represent a
- * combination of options.
- * e.g:
- * If ethernet-BC is option 1 it gets entry 2 in the table. Entry 2
- * now represents a frame with ethernet-BC header - so the bit
- * representing ethernet-BC should be set and all other option bits
- * should be cleared.
- * Entries 2,3,6,7,10... also have ethernet-BC and therefore have bit
- * vector[1] set, but they also have other bits set:
- * 3=1+2, options 0 and 1
- * 6=2+4, options 1 and 2
- * 7=1+2+4, options 0,1,and 2
- * 10=2+8, options 1 and 3
- * etc.
- * */
-
- /* now for each option (i), we set their bits in all entries (j)
- * that contain bit 2^i.
- */
- for(j = 0; j<p_ClsPlanGrp->sizeOfGrp; j++)
- {
- if(j & (1<<i))
- p_ClsPlanSet->vectors[j] |= p_Grp->optVectors[i];
- }
- }
-
- RELEASE_LOCK(p_FmPcd->p_FmPcdKg->clsPlanGrps[p_Grp->clsPlanGrpId].lock);
-
- return E_OK;
-}
+ t_FmPcdKg *p_FmPcdKg;
+ t_FmPcdKgScheme *p_Scheme;
+ uint32_t intFlags;
+ uint8_t relativeSchemeId;
+ int i;
-void FmPcdKgDestroyClsPlanGrp(t_Handle h_FmPcd, uint8_t grpId)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- t_FmPcdIpcKgClsPlanParams kgAlloc;
- t_Error err;
- t_FmPcdIpcMsg msg;
- uint32_t replyLength;
- t_FmPcdIpcReply reply;
+ p_FmPcdKg = p_FmPcd->p_FmPcdKg;
- /* check that no port is bound to this clsPlan */
- if(p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].owners)
+ /* for each scheme - update owners counters */
+ for (i = 0; i < p_BindPort->numOfSchemes; i++)
{
- REPORT_ERROR(MINOR, E_INVALID_STATE, ("Trying to delete a clsPlan grp that has ports bound to"));
- return;
- }
+ relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmPcd, p_BindPort->schemesIds[i]);
+ ASSERT_COND(relativeSchemeId < FM_PCD_KG_NUM_OF_SCHEMES);
- FmPcdDecNetEnvOwners(p_FmPcd, p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].netEnvId);
+ p_Scheme = &p_FmPcdKg->schemes[relativeSchemeId];
- /* free blocks */
- if(p_FmPcd->guestId == NCSW_MASTER_ID)
- {
- KgFreeClsPlanEntries(h_FmPcd,
- p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].sizeOfGrp,
- p_FmPcd->guestId,
- p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].baseEntry);
- }
- else /* in GUEST_PARTITION, we use the IPC, to also set a private driver group if required */
- {
- memset(&reply, 0, sizeof(reply));
- memset(&msg, 0, sizeof(msg));
- kgAlloc.guestId = p_FmPcd->guestId;
- kgAlloc.numOfClsPlanEntries = p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].sizeOfGrp;
- kgAlloc.clsPlanBase = p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].baseEntry;
- msg.msgId = FM_PCD_FREE_KG_CLSPLAN;
- memcpy(msg.msgBody, &kgAlloc, sizeof(kgAlloc));
- replyLength = sizeof(uint32_t);
- if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
- (uint8_t*)&msg,
- sizeof(msg.msgId) + sizeof(kgAlloc),
- (uint8_t*)&reply,
- &replyLength,
- NULL,
- NULL)) != E_OK)
- {
- REPORT_ERROR(MINOR, err, NO_MSG);
- return;
- }
- if (replyLength != sizeof(uint32_t))
- {
- REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
- return;
- }
- if((t_Error)reply.error != E_OK)
- {
- REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Free KG clsPlan failed"));
- return;
- }
+ /* increment owners number */
+ intFlags = KgSchemeLock(p_Scheme);
+ p_Scheme->owners++;
+ KgSchemeUnlock(p_Scheme, intFlags);
}
-
- if(grpId == p_FmPcd->p_FmPcdKg->emptyClsPlanGrpId)
- p_FmPcd->p_FmPcdKg->emptyClsPlanGrpId = ILLEGAL_CLS_PLAN;
- /* clear clsPlan driver structure */
- memset(&p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId], 0, sizeof(t_FmPcdKgClsPlanGrp));
}
-t_Error FmPcdKgBuildBindPortToSchemes(t_Handle h_FmPcd , t_FmPcdKgInterModuleBindPortToSchemes *p_BindPort, uint32_t *p_SpReg, bool add)
+static void DecSchemeOwners(t_FmPcd *p_FmPcd, t_FmPcdKgInterModuleBindPortToSchemes *p_BindPort)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint32_t j, schemesPerPortVector = 0;
- t_FmPcdKgScheme *p_Scheme;
- uint8_t i, relativeSchemeId;
- uint32_t tmp, walking1Mask;
- uint8_t swPortIndex = 0;
+ t_FmPcdKg *p_FmPcdKg;
+ t_FmPcdKgScheme *p_Scheme;
+ uint32_t intFlags;
+ uint8_t relativeSchemeId;
+ int i;
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
+ p_FmPcdKg = p_FmPcd->p_FmPcdKg;
- /* for each scheme */
- for(i = 0; i<p_BindPort->numOfSchemes; i++)
+ /* for each scheme - update owners counters */
+ for (i = 0; i < p_BindPort->numOfSchemes; i++)
{
relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmPcd, p_BindPort->schemesIds[i]);
- if(relativeSchemeId >= FM_PCD_KG_NUM_OF_SCHEMES)
- RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
+ ASSERT_COND(relativeSchemeId < FM_PCD_KG_NUM_OF_SCHEMES);
- if(add)
- {
- if (!FmPcdKgIsSchemeValidSw(h_FmPcd, relativeSchemeId))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Requested scheme is invalid."));
-
- p_Scheme = &p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId];
- /* check netEnvId of the port against the scheme netEnvId */
- if((p_Scheme->netEnvId != p_BindPort->netEnvId) && (p_Scheme->netEnvId != ILLEGAL_NETENV))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Port may not be bound to requested scheme - differ in netEnvId"));
-
- /* if next engine is private port policer profile, we need to check that it is valid */
- HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, p_BindPort->hardwarePortId);
- if(p_Scheme->nextRelativePlcrProfile)
- {
- for(j = 0;j<p_Scheme->numOfProfiles;j++)
- {
- ASSERT_COND(p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].h_FmPort);
- if(p_Scheme->relativeProfileId+j >= p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].numOfProfiles)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Relative profile not in range"));
- if(!FmPcdPlcrIsProfileValid(p_FmPcd, (uint16_t)(p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].profilesBase + p_Scheme->relativeProfileId + j)))
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Relative profile not valid."));
- }
- }
- if(!p_BindPort->useClsPlan)
- {
- /* if this port does not use clsPlan, it may not be bound to schemes with units that contain
- cls plan options. Schemes that are used only directly, should not be checked.
- it also may not be bound to schemes that go to CC with units that are options - so we OR
- the match vector and the grpBits (= ccUnits) */
- if ((p_Scheme->matchVector != SCHEME_ALWAYS_DIRECT) || p_Scheme->ccUnits)
- {
- walking1Mask = 0x80000000;
- tmp = (p_Scheme->matchVector == SCHEME_ALWAYS_DIRECT)? 0:p_Scheme->matchVector;
- tmp |= p_Scheme->ccUnits;
- while (tmp)
- {
- if(tmp & walking1Mask)
- {
- tmp &= ~walking1Mask;
- if(!PcdNetEnvIsUnitWithoutOpts(p_FmPcd, p_Scheme->netEnvId, walking1Mask))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Port (without clsPlan) may not be bound to requested scheme - uses clsPlan options"));
- }
- walking1Mask >>= 1;
- }
- }
- }
- }
- /* build vector */
- schemesPerPortVector |= 1 << (31 - p_BindPort->schemesIds[i]);
- }
-
- *p_SpReg = schemesPerPortVector;
-
- return E_OK;
-}
-
-void FmPcdKgIncSchemeOwners(t_Handle h_FmPcd , t_FmPcdKgInterModuleBindPortToSchemes *p_BindPort)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- int i;
- t_FmPcdKgScheme *p_Scheme;
-
- /* for each scheme - update owners counters */
- for(i = 0; i<p_BindPort->numOfSchemes; i++)
- {
- p_Scheme = &p_FmPcd->p_FmPcdKg->schemes[p_BindPort->schemesIds[i]];
+ p_Scheme = &p_FmPcdKg->schemes[relativeSchemeId];
/* increment owners number */
- p_Scheme->owners++;
+ ASSERT_COND(p_Scheme->owners);
+ intFlags = KgSchemeLock(p_Scheme);
+ p_Scheme->owners--;
+ KgSchemeUnlock(p_Scheme, intFlags);
}
}
-void FmPcdKgDecSchemeOwners(t_Handle h_FmPcd , t_FmPcdKgInterModuleBindPortToSchemes *p_BindPort)
+static void UpdateRequiredActionFlag(t_FmPcdKgScheme *p_Scheme, bool set)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- int i;
- t_FmPcdKgScheme *p_Scheme;
+ /* this routine is locked by the calling routine */
+ ASSERT_COND(p_Scheme);
+ ASSERT_COND(p_Scheme->valid);
- /* for each scheme - update owners counters */
- for(i = 0; i<p_BindPort->numOfSchemes; i++)
+ if (set)
+ p_Scheme->requiredActionFlag = TRUE;
+ else
{
- p_Scheme = &p_FmPcd->p_FmPcdKg->schemes[p_BindPort->schemesIds[i]];
-
- /* increment owners number */
- ASSERT_COND(p_Scheme->owners);
- p_Scheme->owners--;
+ p_Scheme->requiredAction = 0;
+ p_Scheme->requiredActionFlag = FALSE;
}
}
static t_Error KgWriteSp(t_FmPcd *p_FmPcd, uint8_t hardwarePortId, uint32_t spReg, bool add)
{
- t_FmPcdKgPortConfigRegs *p_FmPcdKgPortRegs;
- uint32_t tmpKgarReg = 0, tmpKgpeSp, intFlags;
+ struct fman_kg_regs *p_KgRegs;
+
+ uint32_t tmpKgarReg = 0, intFlags;
t_Error err = E_OK;
+ /* The calling routine had locked the port, so for each port only one core can access
+ * (so we don't need a lock here) */
+
if (p_FmPcd->h_Hc)
return FmHcKgWriteSp(p_FmPcd->h_Hc, hardwarePortId, spReg, add);
- p_FmPcdKgPortRegs = &p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.portRegs;
+ p_KgRegs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
tmpKgarReg = FmPcdKgBuildReadPortSchemeBindActionReg(hardwarePortId);
- intFlags = FmPcdLock(p_FmPcd);
+ /* lock a common KG reg */
+ intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
err = WriteKgarWait(p_FmPcd, tmpKgarReg);
- if(err)
+ if (err)
{
- FmPcdUnlock(p_FmPcd, intFlags);
+ KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
RETURN_ERROR(MINOR, err, NO_MSG);
}
- tmpKgpeSp = GET_UINT32(p_FmPcdKgPortRegs->kgoe_sp);
-
- if(add)
- tmpKgpeSp |= spReg;
- else /* clear */
- tmpKgpeSp &= ~spReg;
-
- WRITE_UINT32(p_FmPcdKgPortRegs->kgoe_sp, tmpKgpeSp);
+ fman_kg_write_sp(p_KgRegs, spReg, add);
tmpKgarReg = FmPcdKgBuildWritePortSchemeBindActionReg(hardwarePortId);
err = WriteKgarWait(p_FmPcd, tmpKgarReg);
- FmPcdUnlock(p_FmPcd, intFlags);
+ KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
return err;
}
static t_Error KgWriteCpp(t_FmPcd *p_FmPcd, uint8_t hardwarePortId, uint32_t cppReg)
{
- t_FmPcdKgPortConfigRegs *p_FmPcdKgPortRegs;
+ struct fman_kg_regs *p_KgRegs;
uint32_t tmpKgarReg, intFlags;
t_Error err;
- if (p_FmPcd->h_Hc)
- return FmHcKgWriteCpp(p_FmPcd->h_Hc, hardwarePortId, cppReg);
+ p_KgRegs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
- p_FmPcdKgPortRegs = &p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.portRegs;
- intFlags = FmPcdLock(p_FmPcd);
- WRITE_UINT32(p_FmPcdKgPortRegs->kgoe_cpp, cppReg);
+ if (p_FmPcd->h_Hc)
+ {
+ err = FmHcKgWriteCpp(p_FmPcd->h_Hc, hardwarePortId, cppReg);
+ return err;
+ }
+ intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
+ fman_kg_write_cpp(p_KgRegs, cppReg);
tmpKgarReg = FmPcdKgBuildWritePortClsPlanBindActionReg(hardwarePortId);
err = WriteKgarWait(p_FmPcd, tmpKgarReg);
- FmPcdUnlock(p_FmPcd, intFlags);
+ KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
return err;
}
-static void FmPcdKgUnbindPortToClsPlanGrp(t_FmPcd *p_FmPcd, uint8_t hardwarePortId)
-{
- KgWriteCpp(p_FmPcd, hardwarePortId, 0);
-}
-
-static t_Error KgBindPortToClsPlanGrp(t_FmPcd *p_FmPcd, uint8_t hardwarePortId, uint8_t clsPlanGrpId)
-{
- uint32_t tmpKgpeCpp = 0;
-
- tmpKgpeCpp = FmPcdKgBuildCppReg(p_FmPcd, clsPlanGrpId);
- return KgWriteCpp(p_FmPcd, hardwarePortId, tmpKgpeCpp);
-}
-
-t_Error FmPcdKgBindPortToSchemes(t_Handle h_FmPcd , t_FmPcdKgInterModuleBindPortToSchemes *p_SchemeBind)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint32_t spReg;
- t_Error err = E_OK;
-
- err = FmPcdKgBuildBindPortToSchemes(h_FmPcd, p_SchemeBind, &spReg, TRUE);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
-
- err = KgWriteSp(p_FmPcd, p_SchemeBind->hardwarePortId, spReg, TRUE);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
-
- FmPcdKgIncSchemeOwners(h_FmPcd, p_SchemeBind);
-
- return E_OK;
-}
-
-t_Error FmPcdKgUnbindPortToSchemes(t_Handle h_FmPcd , t_FmPcdKgInterModuleBindPortToSchemes *p_SchemeBind)
+static uint32_t BuildCppReg(t_FmPcd *p_FmPcd, uint8_t clsPlanGrpId)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint32_t spReg;
- t_Error err = E_OK;
-
- err = FmPcdKgBuildBindPortToSchemes(h_FmPcd, p_SchemeBind, &spReg, FALSE);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
-
- err = KgWriteSp(p_FmPcd, p_SchemeBind->hardwarePortId, spReg, FALSE);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
-
- FmPcdKgDecSchemeOwners(h_FmPcd, p_SchemeBind);
-
- return E_OK;
-}
-
-bool FmPcdKgIsSchemeValidSw(t_Handle h_FmPcd, uint8_t schemeId)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
-
- return p_FmPcd->p_FmPcdKg->schemes[schemeId].valid;
-}
-
-bool KgIsSchemeAlwaysDirect(t_Handle h_FmPcd, uint8_t schemeId)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
-
- if(p_FmPcd->p_FmPcdKg->schemes[schemeId].matchVector == SCHEME_ALWAYS_DIRECT)
- return TRUE;
- else
- return FALSE;
-}
-
-t_Error FmPcdKgAllocSchemes(t_Handle h_FmPcd, uint8_t numOfSchemes, uint8_t guestId, uint8_t *p_SchemesIds)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint32_t intFlags;
- uint8_t i,j;
-
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE);
-
- intFlags = FmPcdLock(p_FmPcd);
- for(j=0,i=0;i<FM_PCD_KG_NUM_OF_SCHEMES && j<numOfSchemes;i++)
- {
- if(!p_FmPcd->p_FmPcdKg->schemesMng[i].allocated)
- {
- p_FmPcd->p_FmPcdKg->schemesMng[i].allocated = TRUE;
- p_FmPcd->p_FmPcdKg->schemesMng[i].ownerId = guestId;
- p_SchemesIds[j] = i;
- j++;
- }
- }
-
- if (j != numOfSchemes)
- {
- /* roll back */
- for(j--; j; j--)
- {
- p_FmPcd->p_FmPcdKg->schemesMng[p_SchemesIds[j]].allocated = FALSE;
- p_FmPcd->p_FmPcdKg->schemesMng[p_SchemesIds[j]].ownerId = 0;
- p_SchemesIds[j] = 0;
- }
- FmPcdUnlock(p_FmPcd, intFlags);
- RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("No schemes found"));
- }
- FmPcdUnlock(p_FmPcd, intFlags);
-
- return E_OK;
-}
-
-t_Error FmPcdKgFreeSchemes(t_Handle h_FmPcd, uint8_t numOfSchemes, uint8_t guestId, uint8_t *p_SchemesIds)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint32_t intFlags;
- uint8_t i;
-
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE);
-
- intFlags = FmPcdLock(p_FmPcd);
-
- for(i=0;i<numOfSchemes;i++)
- {
- if(!p_FmPcd->p_FmPcdKg->schemesMng[p_SchemesIds[i]].allocated)
- {
- FmPcdUnlock(p_FmPcd, intFlags);
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Scheme was not previously allocated"));
- }
- if(p_FmPcd->p_FmPcdKg->schemesMng[p_SchemesIds[i]].ownerId != guestId)
- {
- FmPcdUnlock(p_FmPcd, intFlags);
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Scheme is not owned by caller. "));
- }
- p_FmPcd->p_FmPcdKg->schemesMng[p_SchemesIds[i]].allocated = FALSE;
- p_FmPcd->p_FmPcdKg->schemesMng[p_SchemesIds[i]].ownerId = 0;
- }
-
- FmPcdUnlock(p_FmPcd, intFlags);
- return E_OK;
-}
-
-t_Error KgAllocClsPlanEntries(t_Handle h_FmPcd, uint16_t numOfClsPlanEntries, uint8_t guestId, uint8_t *p_First)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint32_t intFlags;
- uint8_t numOfBlocks, blocksFound=0, first=0;
- uint8_t i, j;
-
- intFlags = FmPcdLock(p_FmPcd);
-
- if(!numOfClsPlanEntries)
- {
- FmPcdUnlock(p_FmPcd, intFlags);
- return E_OK;
- }
-
- if ((numOfClsPlanEntries % CLS_PLAN_NUM_PER_GRP) || (!POWER_OF_2(numOfClsPlanEntries)))
- {
- FmPcdUnlock(p_FmPcd, intFlags);
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfClsPlanEntries must be a power of 2 and divisible by 8"));
- }
-
- numOfBlocks = (uint8_t)(numOfClsPlanEntries/CLS_PLAN_NUM_PER_GRP);
-
- /* try to find consequent blocks */
- first = 0;
- for(i=0;i<FM_PCD_MAX_NUM_OF_CLS_PLANS/CLS_PLAN_NUM_PER_GRP;)
- {
- if(!p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[i].allocated)
- {
- blocksFound++;
- i++;
- if(blocksFound == numOfBlocks)
- break;
- }
- else
- {
- blocksFound = 0;
- /* advance i to the next aligned address */
- first = i = (uint8_t)(first + numOfBlocks);
- }
- }
-
- if(blocksFound == numOfBlocks)
- {
- *p_First = (uint8_t)(first*CLS_PLAN_NUM_PER_GRP);
- for(j = first; j<first + numOfBlocks; j++)
- {
- p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[j].allocated = TRUE;
- p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[j].ownerId = guestId;
- }
- FmPcdUnlock(p_FmPcd, intFlags);
-
- return E_OK;
- }
- else
- {
- FmPcdUnlock(p_FmPcd, intFlags);
- RETURN_ERROR(MINOR, E_FULL, ("No recources for clsPlan"));
- }
-}
-
-void KgFreeClsPlanEntries(t_Handle h_FmPcd, uint16_t numOfClsPlanEntries, uint8_t guestId, uint8_t base)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint32_t intFlags;
- uint8_t numOfBlocks;
- uint8_t i, baseBlock;
-
- UNUSED( guestId);
-
- intFlags = FmPcdLock(p_FmPcd);
+ uint32_t tmpKgpeCpp;
- numOfBlocks = (uint8_t)(numOfClsPlanEntries/CLS_PLAN_NUM_PER_GRP);
- ASSERT_COND(!(base%CLS_PLAN_NUM_PER_GRP));
+ tmpKgpeCpp = (uint32_t)(p_FmPcd->p_FmPcdKg->clsPlanGrps[clsPlanGrpId].baseEntry / 8);
+ tmpKgpeCpp |= (uint32_t)(((p_FmPcd->p_FmPcdKg->clsPlanGrps[clsPlanGrpId].sizeOfGrp / 8) - 1) << FM_KG_PE_CPP_MASK_SHIFT);
- baseBlock = (uint8_t)(base/CLS_PLAN_NUM_PER_GRP);
- for(i=baseBlock;i<baseBlock+numOfBlocks;i++)
- {
- ASSERT_COND(p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[i].allocated);
- ASSERT_COND(guestId == p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[i].ownerId);
- p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[i].allocated = FALSE;
- p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[i].ownerId = 0;
- }
- FmPcdUnlock(p_FmPcd, intFlags);
+ return tmpKgpeCpp;
}
-void KgEnable(t_FmPcd *p_FmPcd)
+static t_Error BindPortToClsPlanGrp(t_FmPcd *p_FmPcd, uint8_t hardwarePortId, uint8_t clsPlanGrpId)
{
- t_FmPcdKgRegs *p_Regs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
+ uint32_t tmpKgpeCpp = 0;
- ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
- WRITE_UINT32(p_Regs->kggcr,GET_UINT32(p_Regs->kggcr) | FM_PCD_KG_KGGCR_EN);
+ tmpKgpeCpp = BuildCppReg(p_FmPcd, clsPlanGrpId);
+ return KgWriteCpp(p_FmPcd, hardwarePortId, tmpKgpeCpp);
}
-void KgDisable(t_FmPcd *p_FmPcd)
+static void UnbindPortToClsPlanGrp(t_FmPcd *p_FmPcd, uint8_t hardwarePortId)
{
- t_FmPcdKgRegs *p_Regs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
-
- ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
- WRITE_UINT32(p_Regs->kggcr,GET_UINT32(p_Regs->kggcr) & ~FM_PCD_KG_KGGCR_EN);
+ KgWriteCpp(p_FmPcd, hardwarePortId, 0);
}
-void KgSetClsPlan(t_Handle h_FmPcd, t_FmPcdKgInterModuleClsPlanSet *p_Set)
+#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
+static uint32_t __attribute__((unused)) ReadClsPlanBlockActionReg(uint8_t grpId)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- t_FmPcdKgClsPlanRegs *p_FmPcdKgPortRegs;
- uint32_t tmpKgarReg=0, intFlags;
- uint16_t i, j;
-
- SANITY_CHECK_RETURN(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE);
+ return (uint32_t)(FM_KG_KGAR_GO |
+ FM_KG_KGAR_READ |
+ FM_PCD_KG_KGAR_SEL_CLS_PLAN_ENTRY |
+ DUMMY_PORT_ID |
+ ((uint32_t)grpId << FM_PCD_KG_KGAR_NUM_SHIFT) |
+ FM_PCD_KG_KGAR_WSEL_MASK);
- ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
- p_FmPcdKgPortRegs = &p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.clsPlanRegs;
-
- intFlags = FmPcdLock(p_FmPcd);
- for(i=p_Set->baseEntry;i<p_Set->baseEntry+p_Set->numOfClsPlanEntries;i+=8)
- {
- tmpKgarReg = FmPcdKgBuildWriteClsPlanBlockActionReg((uint8_t)(i / CLS_PLAN_NUM_PER_GRP));
-
- for (j = i; j < i+8; j++)
- {
- ASSERT_COND(IN_RANGE(0, (j - p_Set->baseEntry), FM_PCD_MAX_NUM_OF_CLS_PLANS-1));
- WRITE_UINT32(p_FmPcdKgPortRegs->kgcpe[j % CLS_PLAN_NUM_PER_GRP],p_Set->vectors[j - p_Set->baseEntry]);
- }
-
- if(WriteKgarWait(p_FmPcd, tmpKgarReg) != E_OK)
- {
- REPORT_ERROR(MAJOR, E_INVALID_STATE, ("WriteKgarWait FAILED"));
- return;
- }
- }
- FmPcdUnlock(p_FmPcd, intFlags);
+ /* if we ever want to write 1 by 1, use:
+ sel = (uint8_t)(0x01 << (7- (entryId % CLS_PLAN_NUM_PER_GRP)));
+ */
}
+#endif /* (defined(DEBUG_ERRORS) && ... */
static void PcdKgErrorException(t_Handle h_FmPcd)
{
t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- uint32_t event, force, schemeIndexes = 0,index = 0, mask = 0;
+ uint32_t event,schemeIndexes = 0, index = 0;
+ struct fman_kg_regs *p_KgRegs;
ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
- event = GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->kgeer);
- mask = GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->kgeeer);
-
- schemeIndexes = GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->kgseer);
- schemeIndexes &= GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->kgseeer);
-
- event &= mask;
-
- /* clear the forced events */
- force = GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->kgfeer);
- if(force & event)
- WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->kgfeer, force & ~event);
-
- WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->kgeer, event);
- WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->kgseer, schemeIndexes);
+ p_KgRegs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
+ fman_kg_get_event(p_KgRegs, &event, &schemeIndexes);
- if(event & FM_PCD_KG_DOUBLE_ECC)
+ if (event & FM_EX_KG_DOUBLE_ECC)
p_FmPcd->f_Exception(p_FmPcd->h_App,e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC);
- if(event & FM_PCD_KG_KEYSIZE_OVERFLOW)
+ if (event & FM_EX_KG_KEYSIZE_OVERFLOW)
{
- if(schemeIndexes)
+ if (schemeIndexes)
{
- while(schemeIndexes)
+ while (schemeIndexes)
{
- if(schemeIndexes & 0x1)
+ if (schemeIndexes & 0x1)
p_FmPcd->f_FmPcdIndexedException(p_FmPcd->h_App,e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW, (uint16_t)(31 - index));
schemeIndexes >>= 1;
index+=1;
@@ -1367,7 +944,7 @@ static t_Error KgInitGuest(t_FmPcd *p_FmPcd)
NULL,
NULL)) != E_OK)
RETURN_ERROR(MAJOR, err, NO_MSG);
- if(replyLength != (sizeof(uint32_t) + p_FmPcd->p_FmPcdKg->numOfSchemes*sizeof(uint8_t)))
+ if (replyLength != (sizeof(uint32_t) + p_FmPcd->p_FmPcdKg->numOfSchemes*sizeof(uint8_t)))
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
memcpy(p_FmPcd->p_FmPcdKg->schemesIds, (uint8_t*)(reply.replyBody),p_FmPcd->p_FmPcdKg->numOfSchemes*sizeof(uint8_t));
@@ -1377,438 +954,63 @@ static t_Error KgInitGuest(t_FmPcd *p_FmPcd)
static t_Error KgInitMaster(t_FmPcd *p_FmPcd)
{
t_Error err = E_OK;
- t_FmPcdKgRegs *p_Regs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
- int i;
- uint8_t hardwarePortId = 0;
- uint32_t tmpReg;
+ struct fman_kg_regs *p_Regs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
ASSERT_COND(p_FmPcd->guestId == NCSW_MASTER_ID);
- /**********************KGEER******************/
- WRITE_UINT32(p_Regs->kgeer, (FM_PCD_KG_DOUBLE_ECC | FM_PCD_KG_KEYSIZE_OVERFLOW));
- /**********************KGEER******************/
-
- /**********************KGEEER******************/
- tmpReg = 0;
- if(p_FmPcd->exceptions & FM_PCD_EX_KG_DOUBLE_ECC)
- {
+ if (p_FmPcd->exceptions & FM_EX_KG_DOUBLE_ECC)
FmEnableRamsEcc(p_FmPcd->h_Fm);
- tmpReg |= FM_PCD_KG_DOUBLE_ECC;
- }
- if(p_FmPcd->exceptions & FM_PCD_EX_KG_KEYSIZE_OVERFLOW)
- tmpReg |= FM_PCD_KG_KEYSIZE_OVERFLOW;
- WRITE_UINT32(p_Regs->kgeeer,tmpReg);
- /**********************KGEEER******************/
-
- /**********************KGFDOR******************/
- WRITE_UINT32(p_Regs->kgfdor,0);
- /**********************KGFDOR******************/
-
- /**********************KGGDV0R******************/
- WRITE_UINT32(p_Regs->kggdv0r,0);
- /**********************KGGDV0R******************/
-
- /**********************KGGDV1R******************/
- WRITE_UINT32(p_Regs->kggdv1r,0);
- /**********************KGGDV1R******************/
- /**********************KGGCR******************/
- WRITE_UINT32(p_Regs->kggcr, NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME);
- /**********************KGGCR******************/
+ fman_kg_init(p_Regs, p_FmPcd->exceptions, GET_NIA_BMI_AC_ENQ_FRAME(p_FmPcd));
/* register even if no interrupts enabled, to allow future enablement */
- FmRegisterIntr(p_FmPcd->h_Fm, e_FM_MOD_KG, 0, e_FM_INTR_TYPE_ERR, PcdKgErrorException, p_FmPcd);
-
- /* clear binding between ports to schemes so that all ports are not bound to any schemes */
- for (i=0;i<FM_MAX_NUM_OF_PORTS;i++)
- {
- SW_PORT_INDX_TO_HW_PORT_ID(hardwarePortId, i);
-
- err = KgWriteSp(p_FmPcd, hardwarePortId, 0xffffffff, FALSE);
- if(err)
- RETURN_ERROR(MINOR, err, NO_MSG);
-
- err = KgWriteCpp(p_FmPcd, hardwarePortId, 0);
- if(err)
- RETURN_ERROR(MINOR, err, NO_MSG);
- }
+ FmRegisterIntr(p_FmPcd->h_Fm,
+ e_FM_MOD_KG,
+ 0,
+ e_FM_INTR_TYPE_ERR,
+ PcdKgErrorException,
+ p_FmPcd);
- /* enable and enable all scheme interrupts */
- WRITE_UINT32(p_Regs->kgseer, 0xFFFFFFFF);
- WRITE_UINT32(p_Regs->kgseeer, 0xFFFFFFFF);
+ fman_kg_enable_scheme_interrupts(p_Regs);
- if(p_FmPcd->p_FmPcdKg->numOfSchemes)
+ if (p_FmPcd->p_FmPcdKg->numOfSchemes)
{
err = FmPcdKgAllocSchemes(p_FmPcd,
p_FmPcd->p_FmPcdKg->numOfSchemes,
p_FmPcd->guestId,
p_FmPcd->p_FmPcdKg->schemesIds);
- if(err)
- RETURN_ERROR(MINOR, err, NO_MSG);
- }
-
- return E_OK;
-}
-
-
-/****************************************/
-/* API routines */
-/****************************************/
-t_Error FM_PCD_KgSetAdditionalDataAfterParsing(t_Handle h_FmPcd, uint8_t payloadOffset)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- t_FmPcdKgRegs *p_Regs;
-
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_NULL_POINTER);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg, E_NULL_POINTER);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs, E_NULL_POINTER);
-
- p_Regs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
- if(!FmIsMaster(p_FmPcd->h_Fm))
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_KgSetAdditionalDataAfterParsing - guest mode!"));
-
-/* not needed
- if(payloadOffset > 256)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("data exatraction offset from parseing end can not be more than 256"));
-*/
-
- WRITE_UINT32(p_Regs->kgfdor,payloadOffset);
-
- return E_OK;
-}
-
-t_Error FM_PCD_KgSetDfltValue(t_Handle h_FmPcd, uint8_t valueId, uint32_t value)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- t_FmPcdKgRegs *p_Regs;
-
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(((valueId == 0) || (valueId == 1)), E_INVALID_VALUE);
- SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_NULL_POINTER);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg, E_NULL_POINTER);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs, E_NULL_POINTER);
-
- p_Regs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
-
- if(!FmIsMaster(p_FmPcd->h_Fm))
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_KgSetDfltValue - guest mode!"));
-
- if(valueId == 0)
- WRITE_UINT32(p_Regs->kggdv0r,value);
- else
- WRITE_UINT32(p_Regs->kggdv1r,value);
- return E_OK;
-}
-
-#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
-t_Error FM_PCD_KgDumpRegs(t_Handle h_FmPcd)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- int i = 0, j = 0;
- uint8_t hardwarePortId = 0;
- uint32_t tmpKgarReg, intFlags;
- t_Error err = E_OK;
- t_FmPcdIpcMsg msg;
-
- DECLARE_DUMP;
-
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
-
- if(p_FmPcd->guestId != NCSW_MASTER_ID)
- {
- memset(&msg, 0, sizeof(msg));
- msg.msgId = FM_PCD_KG_DUMP_REGS;
- return XX_IpcSendMessage(p_FmPcd->h_IpcSession,
- (uint8_t*)&msg,
- sizeof(msg.msgId),
- NULL,
- NULL,
- NULL,
- NULL);
- }
- DUMP_SUBTITLE(("\n"));
- DUMP_TITLE(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs, ("FmPcdKgRegs Regs"));
-
- DUMP_VAR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs,kggcr);
- DUMP_VAR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs,kgeer);
- DUMP_VAR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs,kgeeer);
- DUMP_VAR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs,kgseer);
- DUMP_VAR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs,kgseeer);
- DUMP_VAR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs,kggsr);
- DUMP_VAR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs,kgtpc);
- DUMP_VAR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs,kgserc);
- DUMP_VAR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs,kgfdor);
- DUMP_VAR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs,kggdv0r);
- DUMP_VAR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs,kggdv1r);
- DUMP_VAR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs,kgfer);
- DUMP_VAR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs,kgfeer);
- DUMP_VAR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs,kgar);
-
- DUMP_SUBTITLE(("\n"));
- intFlags = FmPcdLock(p_FmPcd);
- for(j = 0;j<FM_PCD_KG_NUM_OF_SCHEMES;j++)
- {
- tmpKgarReg = FmPcdKgBuildReadSchemeActionReg((uint8_t)j);
- if(WriteKgarWait(p_FmPcd, tmpKgarReg) != E_OK)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
-
- DUMP_TITLE(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs, ("FmPcdKgIndirectAccessSchemeRegs Scheme %d Regs", j));
-
- DUMP_VAR(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs,kgse_mode);
- DUMP_VAR(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs,kgse_ekfc);
- DUMP_VAR(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs,kgse_ekdv);
- DUMP_VAR(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs,kgse_bmch);
- DUMP_VAR(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs,kgse_bmcl);
- DUMP_VAR(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs,kgse_fqb);
- DUMP_VAR(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs,kgse_hc);
- DUMP_VAR(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs,kgse_ppc);
-
- DUMP_TITLE(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs.kgse_gec, ("kgse_gec"));
- DUMP_SUBSTRUCT_ARRAY(i, FM_PCD_KG_NUM_OF_GENERIC_REGS)
- {
- DUMP_MEMORY(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs.kgse_gec[i], sizeof(uint32_t));
- }
-
- DUMP_VAR(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs,kgse_spc);
- DUMP_VAR(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs,kgse_dv0);
- DUMP_VAR(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs,kgse_dv1);
- DUMP_VAR(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs,kgse_ccbs);
- DUMP_VAR(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs,kgse_mv);
- }
- DUMP_SUBTITLE(("\n"));
-
- for (i=0;i<FM_MAX_NUM_OF_PORTS;i++)
- {
- SW_PORT_INDX_TO_HW_PORT_ID(hardwarePortId, i);
-
- tmpKgarReg = FmPcdKgBuildReadPortSchemeBindActionReg(hardwarePortId);
-
- err = WriteKgarWait(p_FmPcd, tmpKgarReg);
- if(err)
- RETURN_ERROR(MINOR, err, NO_MSG);
-
- DUMP_TITLE(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.portRegs, ("FmPcdKgIndirectAccessPortRegs PCD Port %d regs", hardwarePortId));
-
- DUMP_VAR(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.portRegs, kgoe_sp);
- DUMP_VAR(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.portRegs, kgoe_cpp);
- }
-
- DUMP_SUBTITLE(("\n"));
- for(j=0;j<FM_PCD_MAX_NUM_OF_CLS_PLANS/CLS_PLAN_NUM_PER_GRP;j++)
- {
- DUMP_TITLE(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.clsPlanRegs, ("FmPcdKgIndirectAccessClsPlanRegs Regs group %d", j));
- DUMP_TITLE(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.clsPlanRegs.kgcpe, ("kgcpe"));
-
- tmpKgarReg = FmPcdKgBuildReadClsPlanBlockActionReg((uint8_t)j);
- err = WriteKgarWait(p_FmPcd, tmpKgarReg);
- if(err)
+ if (err)
RETURN_ERROR(MINOR, err, NO_MSG);
- DUMP_SUBSTRUCT_ARRAY(i, 8)
- DUMP_MEMORY(&p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.clsPlanRegs.kgcpe[i], sizeof(uint32_t));
}
- FmPcdUnlock(p_FmPcd, intFlags);
return E_OK;
}
-#endif /* (defined(DEBUG_ERRORS) && ... */
-t_Handle KgConfig( t_FmPcd *p_FmPcd, t_FmPcdParams *p_FmPcdParams)
+static void ValidateSchemeSw(t_FmPcdKgScheme *p_Scheme)
{
- t_FmPcdKg *p_FmPcdKg;
-
- UNUSED(p_FmPcd);
-
- if (p_FmPcdParams->numOfSchemes > FM_PCD_KG_NUM_OF_SCHEMES)
- {
- REPORT_ERROR(MAJOR, E_INVALID_VALUE,
- ("numOfSchemes should not exceed %d", FM_PCD_KG_NUM_OF_SCHEMES));
- return NULL;
- }
-
- p_FmPcdKg = (t_FmPcdKg *)XX_Malloc(sizeof(t_FmPcdKg));
- if (!p_FmPcdKg)
- {
- REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Keygen allocation FAILED"));
- return NULL;
- }
- memset(p_FmPcdKg, 0, sizeof(t_FmPcdKg));
-
- if(FmIsMaster(p_FmPcd->h_Fm))
- {
- p_FmPcdKg->p_FmPcdKgRegs = (t_FmPcdKgRegs *)UINT_TO_PTR(FmGetPcdKgBaseAddr(p_FmPcdParams->h_Fm));
- p_FmPcd->exceptions |= DEFAULT_fmPcdKgErrorExceptions;
- }
-
- p_FmPcdKg->numOfSchemes = p_FmPcdParams->numOfSchemes;
- if((p_FmPcd->guestId == NCSW_MASTER_ID) && !p_FmPcdKg->numOfSchemes)
- {
- p_FmPcdKg->numOfSchemes = FM_PCD_KG_NUM_OF_SCHEMES;
- DBG(WARNING, ("numOfSchemes was defined 0 by user, re-defined by driver to FM_PCD_KG_NUM_OF_SCHEMES"));
- }
-
- p_FmPcdKg->emptyClsPlanGrpId = ILLEGAL_CLS_PLAN;
-
- return p_FmPcdKg;
+ ASSERT_COND(!p_Scheme->valid);
+ if (p_Scheme->netEnvId != ILLEGAL_NETENV)
+ FmPcdIncNetEnvOwners(p_Scheme->h_FmPcd, p_Scheme->netEnvId);
+ p_Scheme->valid = TRUE;
}
-t_Error KgInit(t_FmPcd *p_FmPcd)
+static t_Error InvalidateSchemeSw(t_FmPcdKgScheme *p_Scheme)
{
- if (p_FmPcd->guestId == NCSW_MASTER_ID)
- return KgInitMaster(p_FmPcd);
- else
- return KgInitGuest(p_FmPcd);
-}
-
-t_Error KgFree(t_FmPcd *p_FmPcd)
-{
- t_FmPcdIpcKgSchemesParams kgAlloc;
- t_Error err = E_OK;
- t_FmPcdIpcMsg msg;
- uint32_t replyLength;
- t_FmPcdIpcReply reply;
-
- FmUnregisterIntr(p_FmPcd->h_Fm, e_FM_MOD_KG, 0, e_FM_INTR_TYPE_ERR);
-
- if(p_FmPcd->guestId == NCSW_MASTER_ID)
- return FmPcdKgFreeSchemes(p_FmPcd,
- p_FmPcd->p_FmPcdKg->numOfSchemes,
- p_FmPcd->guestId,
- p_FmPcd->p_FmPcdKg->schemesIds);
-
- /* guest */
- memset(&reply, 0, sizeof(reply));
- memset(&msg, 0, sizeof(msg));
- kgAlloc.numOfSchemes = p_FmPcd->p_FmPcdKg->numOfSchemes;
- kgAlloc.guestId = p_FmPcd->guestId;
- ASSERT_COND(kgAlloc.numOfSchemes < FM_PCD_KG_NUM_OF_SCHEMES);
- memcpy(kgAlloc.schemesIds, p_FmPcd->p_FmPcdKg->schemesIds , (sizeof(uint8_t))*kgAlloc.numOfSchemes);
- msg.msgId = FM_PCD_FREE_KG_SCHEMES;
- memcpy(msg.msgBody, &kgAlloc, sizeof(kgAlloc));
- replyLength = sizeof(uint32_t);
- if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
- (uint8_t*)&msg,
- sizeof(msg.msgId) + sizeof(kgAlloc),
- (uint8_t*)&reply,
- &replyLength,
- NULL,
- NULL)) != E_OK)
- RETURN_ERROR(MAJOR, err, NO_MSG);
- if (replyLength != sizeof(uint32_t))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
-
- return (t_Error)reply.error;
-}
-
-t_Error FmPcdKgSetOrBindToClsPlanGrp(t_Handle h_FmPcd, uint8_t hardwarePortId, uint8_t netEnvId, protocolOpt_t *p_OptArray, uint8_t *p_ClsPlanGrpId, bool *p_IsEmptyClsPlanGrp)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- t_FmPcdKgInterModuleClsPlanGrpParams grpParams, *p_GrpParams;
- t_FmPcdKgClsPlanGrp *p_ClsPlanGrp;
- t_FmPcdKgInterModuleClsPlanSet *p_ClsPlanSet;
- t_Error err;
-
- memset(&grpParams, 0, sizeof(grpParams));
- grpParams.clsPlanGrpId = ILLEGAL_CLS_PLAN;
- p_GrpParams = &grpParams;
-
- p_GrpParams->netEnvId = netEnvId;
- err = PcdGetClsPlanGrpParams(h_FmPcd, p_GrpParams);
- if(err)
- RETURN_ERROR(MINOR,err,NO_MSG);
- if(p_GrpParams->grpExists)
- *p_ClsPlanGrpId = p_GrpParams->clsPlanGrpId;
- else
- {
- p_ClsPlanSet = (t_FmPcdKgInterModuleClsPlanSet *)XX_Malloc(sizeof(t_FmPcdKgInterModuleClsPlanSet));
- if (!p_ClsPlanSet)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("memory allocation failed for p_ClsPlanSet"));
- memset(p_ClsPlanSet, 0, sizeof(t_FmPcdKgInterModuleClsPlanSet));
- err = FmPcdKgBuildClsPlanGrp(h_FmPcd, p_GrpParams, p_ClsPlanSet);
- if (err)
- {
- XX_Free(p_ClsPlanSet);
- RETURN_ERROR(MINOR,err,NO_MSG);
- }
- *p_ClsPlanGrpId = p_GrpParams->clsPlanGrpId;
-
- if (p_FmPcd->h_Hc)
- {
- /* write clsPlan entries to memory */
- err = FmHcPcdKgSetClsPlan(p_FmPcd->h_Hc, p_ClsPlanSet);
- if (err)
- {
- XX_Free(p_ClsPlanSet);
- RETURN_ERROR(MAJOR, err, NO_MSG);
- }
- }
- else
- /* write clsPlan entries to memory */
- KgSetClsPlan(p_FmPcd, p_ClsPlanSet);
-
- XX_Free(p_ClsPlanSet);
- }
-
- /* mark if this is an empty classification group */
- if(*p_ClsPlanGrpId == p_FmPcd->p_FmPcdKg->emptyClsPlanGrpId)
- *p_IsEmptyClsPlanGrp = TRUE;
- else
- *p_IsEmptyClsPlanGrp = FALSE;
-
- p_ClsPlanGrp = &p_FmPcd->p_FmPcdKg->clsPlanGrps[*p_ClsPlanGrpId];
-
- /* increment owners number */
- p_ClsPlanGrp->owners++;
-
- /* copy options array for port */
- memcpy(p_OptArray, &p_FmPcd->p_FmPcdKg->clsPlanGrps[*p_ClsPlanGrpId].optArray, FM_PCD_MAX_NUM_OF_OPTIONS(FM_PCD_MAX_NUM_OF_CLS_PLANS)*sizeof(protocolOpt_t));
+ if (p_Scheme->owners)
+ RETURN_ERROR(MINOR, E_INVALID_STATE, ("Trying to delete a scheme that has ports bound to"));
- /* bind port to the new or existing group */
- err = KgBindPortToClsPlanGrp(p_FmPcd, hardwarePortId, p_GrpParams->clsPlanGrpId);
- if(err)
- RETURN_ERROR(MINOR, err, NO_MSG);
+ if (p_Scheme->netEnvId != ILLEGAL_NETENV)
+ FmPcdDecNetEnvOwners(p_Scheme->h_FmPcd, p_Scheme->netEnvId);
+ p_Scheme->valid = FALSE;
return E_OK;
}
-t_Error FmPcdKgDeleteOrUnbindPortToClsPlanGrp(t_Handle h_FmPcd, uint8_t hardwarePortId, uint8_t clsPlanGrpId)
+static t_Error BuildSchemeRegs(t_FmPcdKgScheme *p_Scheme,
+ t_FmPcdKgSchemeParams *p_SchemeParams,
+ struct fman_kg_scheme_regs *p_SchemeRegs)
{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- t_FmPcdKgClsPlanGrp *p_ClsPlanGrp = &p_FmPcd->p_FmPcdKg->clsPlanGrps[clsPlanGrpId];
- t_FmPcdKgInterModuleClsPlanSet *p_ClsPlanSet;
-
- FmPcdKgUnbindPortToClsPlanGrp(p_FmPcd, hardwarePortId);
-
- /* decrement owners number */
- ASSERT_COND(p_ClsPlanGrp->owners);
- p_ClsPlanGrp->owners--;
-
- if(!p_ClsPlanGrp->owners)
- {
- if (p_FmPcd->h_Hc)
- return FmHcPcdKgDeleteClsPlan(p_FmPcd->h_Hc, clsPlanGrpId);
- else
- {
- /* clear clsPlan entries in memory */
- p_ClsPlanSet = (t_FmPcdKgInterModuleClsPlanSet *)XX_Malloc(sizeof(t_FmPcdKgInterModuleClsPlanSet));
- if (!p_ClsPlanSet)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("memory allocation failed for p_ClsPlanSet"));
- memset(p_ClsPlanSet, 0, sizeof(t_FmPcdKgInterModuleClsPlanSet));
- p_ClsPlanSet->baseEntry = p_FmPcd->p_FmPcdKg->clsPlanGrps[clsPlanGrpId].baseEntry;
- p_ClsPlanSet->numOfClsPlanEntries = p_FmPcd->p_FmPcdKg->clsPlanGrps[clsPlanGrpId].sizeOfGrp;
- KgSetClsPlan(p_FmPcd, p_ClsPlanSet);
- XX_Free(p_ClsPlanSet);
- FmPcdKgDestroyClsPlanGrp(h_FmPcd, clsPlanGrpId);
- }
- }
- return E_OK;
-}
-
-t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t_FmPcdKgInterModuleSchemeRegs *p_SchemeRegs)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ t_FmPcd *p_FmPcd = (t_FmPcd *)(p_Scheme->h_FmPcd);
uint32_t grpBits = 0;
uint8_t grpBase;
bool direct=TRUE, absolute=FALSE;
@@ -1828,184 +1030,169 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
t_FmPcdKgSchemesExtracts *p_LocalExtractsArray;
uint8_t numOfSwDefaults = 0;
t_FmPcdKgExtractDflt swDefaults[NUM_OF_SW_DEFAULTS];
- uint8_t currGenId = 0, relativeSchemeId;
-
- if(!p_Scheme->modify)
- relativeSchemeId = p_Scheme->id.relativeSchemeId;
- else
- relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmPcd, (uint8_t)(PTR_TO_UINT(p_Scheme->id.h_Scheme)-1));
+ uint8_t currGenId = 0;
- memset(&p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId], 0, sizeof(t_FmPcdKgScheme));
memset(swDefaults, 0, NUM_OF_SW_DEFAULTS*sizeof(t_FmPcdKgExtractDflt));
- memset(p_SchemeRegs, 0, sizeof(t_FmPcdKgInterModuleSchemeRegs));
+ memset(p_SchemeRegs, 0, sizeof(struct fman_kg_scheme_regs));
- if (p_Scheme->netEnvParams.numOfDistinctionUnits > FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
+ if (p_SchemeParams->netEnvParams.numOfDistinctionUnits > FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
RETURN_ERROR(MAJOR, E_INVALID_VALUE,
("numOfDistinctionUnits should not exceed %d", FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS));
/* by netEnv parameters, get match vector */
- if(!p_Scheme->alwaysDirect)
+ if (!p_SchemeParams->alwaysDirect)
{
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].netEnvId =
- (uint8_t)(PTR_TO_UINT(p_Scheme->netEnvParams.h_NetEnv)-1);
- netEnvParams.netEnvId = p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].netEnvId;
- netEnvParams.numOfDistinctionUnits = p_Scheme->netEnvParams.numOfDistinctionUnits;
- memcpy(netEnvParams.unitIds, p_Scheme->netEnvParams.unitIds, (sizeof(uint8_t))*p_Scheme->netEnvParams.numOfDistinctionUnits);
+ p_Scheme->netEnvId = FmPcdGetNetEnvId(p_SchemeParams->netEnvParams.h_NetEnv);
+ netEnvParams.netEnvId = p_Scheme->netEnvId;
+ netEnvParams.numOfDistinctionUnits = p_SchemeParams->netEnvParams.numOfDistinctionUnits;
+ memcpy(netEnvParams.unitIds, p_SchemeParams->netEnvParams.unitIds, (sizeof(uint8_t))*p_SchemeParams->netEnvParams.numOfDistinctionUnits);
err = PcdGetUnitsVector(p_FmPcd, &netEnvParams);
- if(err)
+ if (err)
RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].matchVector = netEnvParams.vector;
+ p_Scheme->matchVector = netEnvParams.vector;
}
else
{
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].matchVector = SCHEME_ALWAYS_DIRECT;
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].netEnvId = ILLEGAL_NETENV;
+ p_Scheme->matchVector = SCHEME_ALWAYS_DIRECT;
+ p_Scheme->netEnvId = ILLEGAL_NETENV;
}
- if(p_Scheme->nextEngine == e_FM_PCD_INVALID)
+ if (p_SchemeParams->nextEngine == e_FM_PCD_INVALID)
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next Engine of the scheme is not Valid"));
- if(p_Scheme->bypassFqidGeneration)
+ if (p_SchemeParams->bypassFqidGeneration)
{
#ifdef FM_KG_NO_BYPASS_FQID_GEN
- {
- t_FmRevisionInfo revInfo;
-
- FM_GetRevision(p_FmPcd->h_Fm, &revInfo);
- if (revInfo.majorRev != 4)
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("bypassFqidGeneration."));
- }
+ if ((p_FmPcd->fmRevInfo.majorRev != 4) && (p_FmPcd->fmRevInfo.majorRev < 6))
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("bypassFqidGeneration."));
#endif /* FM_KG_NO_BYPASS_FQID_GEN */
- if(p_Scheme->baseFqid)
+ if (p_SchemeParams->baseFqid)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("baseFqid set for a scheme that does not generate an FQID"));
}
else
- if(!p_Scheme->baseFqid)
+ if (!p_SchemeParams->baseFqid)
DBG(WARNING, ("baseFqid is 0."));
- if(p_Scheme->nextEngine == e_FM_PCD_PLCR)
+ if (p_SchemeParams->nextEngine == e_FM_PCD_PLCR)
{
- direct = p_Scheme->kgNextEngineParams.plcrProfile.direct;
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].directPlcr = direct;
- absolute = (bool)(p_Scheme->kgNextEngineParams.plcrProfile.sharedProfile ? TRUE : FALSE);
- if(!direct && absolute)
+ direct = p_SchemeParams->kgNextEngineParams.plcrProfile.direct;
+ p_Scheme->directPlcr = direct;
+ absolute = (bool)(p_SchemeParams->kgNextEngineParams.plcrProfile.sharedProfile ? TRUE : FALSE);
+ if (!direct && absolute)
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Indirect policing is not available when profile is shared."));
- if(direct)
+ if (direct)
{
- profileId = p_Scheme->kgNextEngineParams.plcrProfile.profileSelect.directRelativeProfileId;
+ profileId = p_SchemeParams->kgNextEngineParams.plcrProfile.profileSelect.directRelativeProfileId;
numOfProfiles = 1;
}
else
{
- profileId = p_Scheme->kgNextEngineParams.plcrProfile.profileSelect.indirectProfile.fqidOffsetRelativeProfileIdBase;
- shift = p_Scheme->kgNextEngineParams.plcrProfile.profileSelect.indirectProfile.fqidOffsetShift;
- numOfProfiles = p_Scheme->kgNextEngineParams.plcrProfile.profileSelect.indirectProfile.numOfProfiles;
+ profileId = p_SchemeParams->kgNextEngineParams.plcrProfile.profileSelect.indirectProfile.fqidOffsetRelativeProfileIdBase;
+ shift = p_SchemeParams->kgNextEngineParams.plcrProfile.profileSelect.indirectProfile.fqidOffsetShift;
+ numOfProfiles = p_SchemeParams->kgNextEngineParams.plcrProfile.profileSelect.indirectProfile.numOfProfiles;
}
}
- if(p_Scheme->nextEngine == e_FM_PCD_CC)
+ if (p_SchemeParams->nextEngine == e_FM_PCD_CC)
{
#ifdef FM_KG_NO_BYPASS_PLCR_PROFILE_GEN
- if((p_Scheme->kgNextEngineParams.cc.plcrNext) && (p_Scheme->kgNextEngineParams.cc.bypassPlcrProfileGeneration))
+ if ((p_SchemeParams->kgNextEngineParams.cc.plcrNext) && (p_SchemeParams->kgNextEngineParams.cc.bypassPlcrProfileGeneration))
{
- t_FmRevisionInfo revInfo;
-
- FM_GetRevision(p_FmPcd->h_Fm, &revInfo);
- if (revInfo.majorRev != 4)
+ if ((p_FmPcd->fmRevInfo.majorRev != 4) && (p_FmPcd->fmRevInfo.majorRev < 6))
RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("bypassPlcrProfileGeneration."));
}
#endif /* FM_KG_NO_BYPASS_PLCR_PROFILE_GEN */
- err = FmPcdCcGetGrpParams(p_Scheme->kgNextEngineParams.cc.h_CcTree,
- p_Scheme->kgNextEngineParams.cc.grpId,
+ err = FmPcdCcGetGrpParams(p_SchemeParams->kgNextEngineParams.cc.h_CcTree,
+ p_SchemeParams->kgNextEngineParams.cc.grpId,
&grpBits,
&grpBase);
- if(err)
+ if (err)
RETURN_ERROR(MAJOR, err, NO_MSG);
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].ccUnits = grpBits;
+ p_Scheme->ccUnits = grpBits;
- if((p_Scheme->kgNextEngineParams.cc.plcrNext) &&
- (!p_Scheme->kgNextEngineParams.cc.bypassPlcrProfileGeneration))
+ if ((p_SchemeParams->kgNextEngineParams.cc.plcrNext) &&
+ (!p_SchemeParams->kgNextEngineParams.cc.bypassPlcrProfileGeneration))
{
- if(p_Scheme->kgNextEngineParams.cc.plcrProfile.sharedProfile)
+ if (p_SchemeParams->kgNextEngineParams.cc.plcrProfile.sharedProfile)
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Shared profile may not be used after Coarse classification."));
absolute = FALSE;
- direct = p_Scheme->kgNextEngineParams.cc.plcrProfile.direct;
- if(direct)
+ direct = p_SchemeParams->kgNextEngineParams.cc.plcrProfile.direct;
+ if (direct)
{
- profileId = p_Scheme->kgNextEngineParams.cc.plcrProfile.profileSelect.directRelativeProfileId;
+ profileId = p_SchemeParams->kgNextEngineParams.cc.plcrProfile.profileSelect.directRelativeProfileId;
numOfProfiles = 1;
}
else
{
- profileId = p_Scheme->kgNextEngineParams.cc.plcrProfile.profileSelect.indirectProfile.fqidOffsetRelativeProfileIdBase;
- shift = p_Scheme->kgNextEngineParams.cc.plcrProfile.profileSelect.indirectProfile.fqidOffsetShift;
- numOfProfiles = p_Scheme->kgNextEngineParams.cc.plcrProfile.profileSelect.indirectProfile.numOfProfiles;
+ profileId = p_SchemeParams->kgNextEngineParams.cc.plcrProfile.profileSelect.indirectProfile.fqidOffsetRelativeProfileIdBase;
+ shift = p_SchemeParams->kgNextEngineParams.cc.plcrProfile.profileSelect.indirectProfile.fqidOffsetShift;
+ numOfProfiles = p_SchemeParams->kgNextEngineParams.cc.plcrProfile.profileSelect.indirectProfile.numOfProfiles;
}
}
}
/* if policer is used directly after KG, or after CC */
- if((p_Scheme->nextEngine == e_FM_PCD_PLCR) ||
- ((p_Scheme->nextEngine == e_FM_PCD_CC) &&
- (p_Scheme->kgNextEngineParams.cc.plcrNext) &&
- (!p_Scheme->kgNextEngineParams.cc.bypassPlcrProfileGeneration)))
+ if ((p_SchemeParams->nextEngine == e_FM_PCD_PLCR) ||
+ ((p_SchemeParams->nextEngine == e_FM_PCD_CC) &&
+ (p_SchemeParams->kgNextEngineParams.cc.plcrNext) &&
+ (!p_SchemeParams->kgNextEngineParams.cc.bypassPlcrProfileGeneration)))
{
/* if private policer profile, it may be uninitialized yet, therefore no checks are done at this stage */
- if(absolute)
+ if (absolute)
{
/* for absolute direct policy only, */
relativeProfileId = profileId;
- err = FmPcdPlcrGetAbsoluteProfileId(h_FmPcd,e_FM_PCD_PLCR_SHARED,NULL, relativeProfileId, &profileId);
- if(err)
+ err = FmPcdPlcrGetAbsoluteIdByProfileParams((t_Handle)p_FmPcd,e_FM_PCD_PLCR_SHARED,NULL, relativeProfileId, &profileId);
+ if (err)
RETURN_ERROR(MAJOR, err, ("Shared profile not valid offset"));
- if(!FmPcdPlcrIsProfileValid(p_FmPcd, profileId))
+ if (!FmPcdPlcrIsProfileValid(p_FmPcd, profileId))
RETURN_ERROR(MINOR, E_INVALID_STATE, ("Shared profile not valid."));
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].relativeProfileId = profileId;
+ p_Scheme->relativeProfileId = profileId;
}
else
{
/* save relative profile id's for later check */
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].nextRelativePlcrProfile = TRUE;
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].relativeProfileId = profileId;
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].numOfProfiles = numOfProfiles;
+ p_Scheme->nextRelativePlcrProfile = TRUE;
+ p_Scheme->relativeProfileId = profileId;
+ p_Scheme->numOfProfiles = numOfProfiles;
}
}
else
{
/* if policer is NOT going to be used after KG at all than if bypassFqidGeneration
is set, we do not need numOfUsedExtractedOrs and hashDistributionNumOfFqids */
- if(p_Scheme->bypassFqidGeneration && p_Scheme->numOfUsedExtractedOrs)
+ if (p_SchemeParams->bypassFqidGeneration && p_SchemeParams->numOfUsedExtractedOrs)
RETURN_ERROR(MAJOR, E_INVALID_STATE,
("numOfUsedExtractedOrs is set in a scheme that does not generate FQID or policer profile ID"));
- if(p_Scheme->bypassFqidGeneration &&
- p_Scheme->useHash &&
- p_Scheme->keyExtractAndHashParams.hashDistributionNumOfFqids)
+ if (p_SchemeParams->bypassFqidGeneration &&
+ p_SchemeParams->useHash &&
+ p_SchemeParams->keyExtractAndHashParams.hashDistributionNumOfFqids)
RETURN_ERROR(MAJOR, E_INVALID_STATE,
("hashDistributionNumOfFqids is set in a scheme that does not generate FQID or policer profile ID"));
}
/* configure all 21 scheme registers */
tmpReg = KG_SCH_MODE_EN;
- switch(p_Scheme->nextEngine)
+ switch (p_SchemeParams->nextEngine)
{
- case(e_FM_PCD_PLCR):
+ case (e_FM_PCD_PLCR):
/* add to mode register - NIA */
tmpReg |= KG_SCH_MODE_NIA_PLCR;
tmpReg |= NIA_ENG_PLCR;
- tmpReg |= (uint32_t)(p_Scheme->kgNextEngineParams.plcrProfile.sharedProfile ? NIA_PLCR_ABSOLUTE:0);
+ tmpReg |= (uint32_t)(p_SchemeParams->kgNextEngineParams.plcrProfile.sharedProfile ? NIA_PLCR_ABSOLUTE:0);
/* initialize policer profile command - */
/* configure kgse_ppc */
- if(direct)
+ if (direct)
/* use profileId as base, other fields are 0 */
p_SchemeRegs->kgse_ppc = (uint32_t)profileId;
else
{
- if(shift > MAX_PP_SHIFT)
+ if (shift > MAX_PP_SHIFT)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fqidOffsetShift may not be larger than %d", MAX_PP_SHIFT));
- if(!numOfProfiles || !POWER_OF_2(numOfProfiles))
+ if (!numOfProfiles || !POWER_OF_2(numOfProfiles))
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfProfiles must not be 0 and must be a power of 2"));
ppcTmp = ((uint32_t)shift << KG_SCH_PP_SHIFT_HIGH_SHIFT) & KG_SCH_PP_SHIFT_HIGH;
@@ -2016,30 +1203,30 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
p_SchemeRegs->kgse_ppc = ppcTmp;
}
break;
- case(e_FM_PCD_CC):
+ case (e_FM_PCD_CC):
/* mode reg - define NIA */
tmpReg |= (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_CC);
p_SchemeRegs->kgse_ccbs = grpBits;
tmpReg |= (uint32_t)(grpBase << KG_SCH_MODE_CCOBASE_SHIFT);
- if(p_Scheme->kgNextEngineParams.cc.plcrNext)
+ if (p_SchemeParams->kgNextEngineParams.cc.plcrNext)
{
- if(!p_Scheme->kgNextEngineParams.cc.bypassPlcrProfileGeneration)
+ if (!p_SchemeParams->kgNextEngineParams.cc.bypassPlcrProfileGeneration)
{
/* find out if absolute or relative */
- if(absolute)
+ if (absolute)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("It is illegal to request a shared profile in a scheme that is in a KG->CC->PLCR flow"));
- if(direct)
+ if (direct)
{
/* mask = 0, base = directProfileId */
p_SchemeRegs->kgse_ppc = (uint32_t)profileId;
}
else
{
- if(shift > MAX_PP_SHIFT)
+ if (shift > MAX_PP_SHIFT)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fqidOffsetShift may not be larger than %d", MAX_PP_SHIFT));
- if(!numOfProfiles || !POWER_OF_2(numOfProfiles))
+ if (!numOfProfiles || !POWER_OF_2(numOfProfiles))
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfProfiles must not be 0 and must be a power of 2"));
ppcTmp = ((uint32_t)shift << KG_SCH_PP_SHIFT_HIGH_SHIFT) & KG_SCH_PP_SHIFT_HIGH;
@@ -2050,26 +1237,61 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
p_SchemeRegs->kgse_ppc = ppcTmp;
}
}
- else
- ppcTmp = KG_SCH_PP_NO_GEN;
}
break;
- case(e_FM_PCD_DONE):
- if(p_Scheme->kgNextEngineParams.doneAction == e_FM_PCD_DROP_FRAME)
- tmpReg |= (NIA_ENG_BMI | NIA_BMI_AC_DISCARD);
+ case (e_FM_PCD_DONE):
+ if (p_SchemeParams->kgNextEngineParams.doneAction == e_FM_PCD_DROP_FRAME)
+ tmpReg |= GET_NIA_BMI_AC_DISCARD_FRAME(p_FmPcd);
else
- tmpReg |= (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME);
+ tmpReg |= GET_NIA_BMI_AC_ENQ_FRAME(p_FmPcd);
break;
default:
RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Next engine not supported"));
}
p_SchemeRegs->kgse_mode = tmpReg;
- p_SchemeRegs->kgse_mv = p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].matchVector;
+ p_SchemeRegs->kgse_mv = p_Scheme->matchVector;
+
+#if (DPAA_VERSION >= 11)
+ if (p_SchemeParams->overrideStorageProfile)
+ {
+ p_SchemeRegs->kgse_om |= KG_SCH_OM_VSPE;
+
+ if (p_SchemeParams->storageProfile.direct)
+ {
+ profileId = p_SchemeParams->storageProfile.profileSelect.directRelativeProfileId;
+ shift = 0;
+ numOfProfiles = 1;
+ }
+ else
+ {
+ profileId = p_SchemeParams->storageProfile.profileSelect.indirectProfile.fqidOffsetRelativeProfileIdBase;
+ shift = p_SchemeParams->storageProfile.profileSelect.indirectProfile.fqidOffsetShift;
+ numOfProfiles = p_SchemeParams->storageProfile.profileSelect.indirectProfile.numOfProfiles;
+ }
+ if (shift > MAX_SP_SHIFT)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fqidOffsetShift may not be larger than %d", MAX_SP_SHIFT));
+
+ if (!numOfProfiles || !POWER_OF_2(numOfProfiles))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfProfiles must not be 0 and must be a power of 2"));
- if(p_Scheme->useHash)
+ tmpReg = (uint32_t)shift << KG_SCH_VSP_SHIFT;
+ tmpReg |= ((uint32_t)(numOfProfiles-1) << KG_SCH_VSP_MASK_SHIFT);
+ tmpReg |= (uint32_t)profileId;
+
+
+ p_SchemeRegs->kgse_vsp = tmpReg;
+
+ p_Scheme->vspe = TRUE;
+
+ }
+ else
+ p_SchemeRegs->kgse_vsp = KG_SCH_VSP_NO_KSP_EN;
+#endif /* (DPAA_VERSION >= 11) */
+
+ if (p_SchemeParams->useHash)
{
- p_KeyAndHash = &p_Scheme->keyExtractAndHashParams;
+ p_KeyAndHash = &p_SchemeParams->keyExtractAndHashParams;
if (p_KeyAndHash->numOfUsedExtracts >= FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfUsedExtracts out of range"));
@@ -2080,70 +1302,70 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
/* configure kgse_dv1 */
p_SchemeRegs->kgse_dv1 = p_KeyAndHash->privateDflt1;
- if(!p_Scheme->bypassFqidGeneration)
+ if (!p_SchemeParams->bypassFqidGeneration)
{
- if(!p_KeyAndHash->hashDistributionNumOfFqids || !POWER_OF_2(p_KeyAndHash->hashDistributionNumOfFqids))
+ if (!p_KeyAndHash->hashDistributionNumOfFqids || !POWER_OF_2(p_KeyAndHash->hashDistributionNumOfFqids))
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("hashDistributionNumOfFqids must not be 0 and must be a power of 2"));
- if((p_KeyAndHash->hashDistributionNumOfFqids-1) & p_Scheme->baseFqid)
+ if ((p_KeyAndHash->hashDistributionNumOfFqids-1) & p_SchemeParams->baseFqid)
DBG(WARNING, ("baseFqid unaligned. Distribution may result in less than hashDistributionNumOfFqids queues."));
}
/* configure kgse_ekdv */
tmpReg = 0;
- for( i=0 ;i<p_KeyAndHash->numOfUsedDflts ; i++)
+ for ( i=0 ;i<p_KeyAndHash->numOfUsedDflts ; i++)
{
- switch(p_KeyAndHash->dflts[i].type)
+ switch (p_KeyAndHash->dflts[i].type)
{
- case(e_FM_PCD_KG_MAC_ADDR):
+ case (e_FM_PCD_KG_MAC_ADDR):
tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_MAC_ADDR_SHIFT);
break;
- case(e_FM_PCD_KG_TCI):
+ case (e_FM_PCD_KG_TCI):
tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_TCI_SHIFT);
break;
- case(e_FM_PCD_KG_ENET_TYPE):
+ case (e_FM_PCD_KG_ENET_TYPE):
tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_ENET_TYPE_SHIFT);
break;
- case(e_FM_PCD_KG_PPP_SESSION_ID):
+ case (e_FM_PCD_KG_PPP_SESSION_ID):
tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_PPP_SESSION_ID_SHIFT);
break;
- case(e_FM_PCD_KG_PPP_PROTOCOL_ID):
+ case (e_FM_PCD_KG_PPP_PROTOCOL_ID):
tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_PPP_PROTOCOL_ID_SHIFT);
break;
- case(e_FM_PCD_KG_MPLS_LABEL):
+ case (e_FM_PCD_KG_MPLS_LABEL):
tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_MPLS_LABEL_SHIFT);
break;
- case(e_FM_PCD_KG_IP_ADDR):
+ case (e_FM_PCD_KG_IP_ADDR):
tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_IP_ADDR_SHIFT);
break;
- case(e_FM_PCD_KG_PROTOCOL_TYPE):
+ case (e_FM_PCD_KG_PROTOCOL_TYPE):
tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_PROTOCOL_TYPE_SHIFT);
break;
- case(e_FM_PCD_KG_IP_TOS_TC):
+ case (e_FM_PCD_KG_IP_TOS_TC):
tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_IP_TOS_TC_SHIFT);
break;
- case(e_FM_PCD_KG_IPV6_FLOW_LABEL):
+ case (e_FM_PCD_KG_IPV6_FLOW_LABEL):
tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_L4_PORT_SHIFT);
break;
- case(e_FM_PCD_KG_IPSEC_SPI):
+ case (e_FM_PCD_KG_IPSEC_SPI):
tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_IPSEC_SPI_SHIFT);
break;
- case(e_FM_PCD_KG_L4_PORT):
+ case (e_FM_PCD_KG_L4_PORT):
tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_L4_PORT_SHIFT);
break;
- case(e_FM_PCD_KG_TCP_FLAG):
+ case (e_FM_PCD_KG_TCP_FLAG):
tmpReg |= (p_KeyAndHash->dflts[i].dfltSelect << KG_SCH_DEF_TCP_FLAG_SHIFT);
break;
- case(e_FM_PCD_KG_GENERIC_FROM_DATA):
+ case (e_FM_PCD_KG_GENERIC_FROM_DATA):
swDefaults[numOfSwDefaults].type = e_FM_PCD_KG_GENERIC_FROM_DATA;
swDefaults[numOfSwDefaults].dfltSelect = p_KeyAndHash->dflts[i].dfltSelect;
numOfSwDefaults ++;
break;
- case(e_FM_PCD_KG_GENERIC_FROM_DATA_NO_V):
+ case (e_FM_PCD_KG_GENERIC_FROM_DATA_NO_V):
swDefaults[numOfSwDefaults].type = e_FM_PCD_KG_GENERIC_FROM_DATA_NO_V;
swDefaults[numOfSwDefaults].dfltSelect = p_KeyAndHash->dflts[i].dfltSelect;
numOfSwDefaults ++;
break;
- case(e_FM_PCD_KG_GENERIC_NOT_FROM_DATA):
+ case (e_FM_PCD_KG_GENERIC_NOT_FROM_DATA):
swDefaults[numOfSwDefaults].type = e_FM_PCD_KG_GENERIC_NOT_FROM_DATA;
swDefaults[numOfSwDefaults].dfltSelect = p_KeyAndHash->dflts[i].dfltSelect;
numOfSwDefaults ++;
@@ -2155,33 +1377,38 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
p_SchemeRegs->kgse_ekdv = tmpReg;
p_LocalExtractsArray = (t_FmPcdKgSchemesExtracts *)XX_Malloc(sizeof(t_FmPcdKgSchemesExtracts));
- if(!p_LocalExtractsArray)
+ if (!p_LocalExtractsArray)
RETURN_ERROR(MAJOR, E_NO_MEMORY, ("No memory"));
/* configure kgse_ekfc and kgse_gec */
knownTmp = 0;
- for( i=0 ;i<p_KeyAndHash->numOfUsedExtracts ; i++)
+ for ( i=0 ;i<p_KeyAndHash->numOfUsedExtracts ; i++)
{
p_Extract = &p_KeyAndHash->extractArray[i];
- switch(p_Extract->type)
+ switch (p_Extract->type)
{
- case(e_FM_PCD_KG_EXTRACT_PORT_PRIVATE_INFO):
+ case (e_FM_PCD_KG_EXTRACT_PORT_PRIVATE_INFO):
knownTmp |= KG_SCH_KN_PORT_ID;
/* save in driver structure */
p_LocalExtractsArray->extractsArray[i].id = GetKnownFieldId(KG_SCH_KN_PORT_ID);
p_LocalExtractsArray->extractsArray[i].known = TRUE;
break;
- case(e_FM_PCD_EXTRACT_BY_HDR):
- switch(p_Extract->extractByHdr.hdr)
+ case (e_FM_PCD_EXTRACT_BY_HDR):
+ switch (p_Extract->extractByHdr.hdr)
{
- case(HEADER_TYPE_UDP_ENCAP_ESP):
- switch(p_Extract->extractByHdr.type)
+#if (DPAA_VERSION >= 11) || ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
+ case (HEADER_TYPE_UDP_LITE):
+ p_Extract->extractByHdr.hdr = HEADER_TYPE_UDP;
+ break;
+#endif /* (DPAA_VERSION >= 11) || ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
+ case (HEADER_TYPE_UDP_ENCAP_ESP):
+ switch (p_Extract->extractByHdr.type)
{
- case(e_FM_PCD_EXTRACT_FROM_HDR):
+ case (e_FM_PCD_EXTRACT_FROM_HDR):
/* case where extraction from ESP only */
if (p_Extract->extractByHdr.extractByHdrType.fromHdr.offset >= UDP_HEADER_SIZE)
{
- p_Extract->extractByHdr.hdr = FmPcdGetAliasHdr(p_FmPcd, p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].netEnvId, HEADER_TYPE_UDP_ENCAP_ESP);
+ p_Extract->extractByHdr.hdr = FmPcdGetAliasHdr(p_FmPcd, p_Scheme->netEnvId, HEADER_TYPE_UDP_ENCAP_ESP);
p_Extract->extractByHdr.extractByHdrType.fromHdr.offset -= UDP_HEADER_SIZE;
p_Extract->extractByHdr.ignoreProtocolValidation = TRUE;
}
@@ -2191,50 +1418,48 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
p_Extract->extractByHdr.ignoreProtocolValidation = FALSE;
}
break;
- case(e_FM_PCD_EXTRACT_FROM_FIELD):
- switch(p_Extract->extractByHdr.extractByHdrType.fromField.field.udpEncapEsp)
+ case (e_FM_PCD_EXTRACT_FROM_FIELD):
+ switch (p_Extract->extractByHdr.extractByHdrType.fromField.field.udpEncapEsp)
{
- case(NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC):
- case(NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_DST):
- case(NET_HEADER_FIELD_UDP_ENCAP_ESP_LEN):
- case(NET_HEADER_FIELD_UDP_ENCAP_ESP_CKSUM):
+ case (NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC):
+ case (NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_DST):
+ case (NET_HEADER_FIELD_UDP_ENCAP_ESP_LEN):
+ case (NET_HEADER_FIELD_UDP_ENCAP_ESP_CKSUM):
p_Extract->extractByHdr.hdr = HEADER_TYPE_UDP;
break;
- case(NET_HEADER_FIELD_UDP_ENCAP_ESP_SPI):
+ case (NET_HEADER_FIELD_UDP_ENCAP_ESP_SPI):
p_Extract->extractByHdr.type = e_FM_PCD_EXTRACT_FROM_HDR;
- p_Extract->extractByHdr.hdr = FmPcdGetAliasHdr(p_FmPcd, p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].netEnvId, HEADER_TYPE_UDP_ENCAP_ESP);
- p_Extract->extractByHdr.extractByHdrType.fromField.size = p_Extract->extractByHdr.extractByHdrType.fromField.size;
+ p_Extract->extractByHdr.hdr = FmPcdGetAliasHdr(p_FmPcd, p_Scheme->netEnvId, HEADER_TYPE_UDP_ENCAP_ESP);
/*p_Extract->extractByHdr.extractByHdrType.fromField.offset += ESP_SPI_OFFSET;*/
p_Extract->extractByHdr.ignoreProtocolValidation = TRUE;
break;
- case(NET_HEADER_FIELD_UDP_ENCAP_ESP_SEQUENCE_NUM):
+ case (NET_HEADER_FIELD_UDP_ENCAP_ESP_SEQUENCE_NUM):
p_Extract->extractByHdr.type = e_FM_PCD_EXTRACT_FROM_HDR;
- p_Extract->extractByHdr.hdr = FmPcdGetAliasHdr(p_FmPcd, p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].netEnvId, HEADER_TYPE_UDP_ENCAP_ESP);
- p_Extract->extractByHdr.extractByHdrType.fromField.size = p_Extract->extractByHdr.extractByHdrType.fromField.size;
+ p_Extract->extractByHdr.hdr = FmPcdGetAliasHdr(p_FmPcd, p_Scheme->netEnvId, HEADER_TYPE_UDP_ENCAP_ESP);
p_Extract->extractByHdr.extractByHdrType.fromField.offset += ESP_SEQ_NUM_OFFSET;
p_Extract->extractByHdr.ignoreProtocolValidation = TRUE;
break;
}
break;
- case(e_FM_PCD_EXTRACT_FULL_FIELD):
- switch(p_Extract->extractByHdr.extractByHdrType.fullField.udpEncapEsp)
+ case (e_FM_PCD_EXTRACT_FULL_FIELD):
+ switch (p_Extract->extractByHdr.extractByHdrType.fullField.udpEncapEsp)
{
- case(NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC):
- case(NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_DST):
- case(NET_HEADER_FIELD_UDP_ENCAP_ESP_LEN):
- case(NET_HEADER_FIELD_UDP_ENCAP_ESP_CKSUM):
+ case (NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC):
+ case (NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_DST):
+ case (NET_HEADER_FIELD_UDP_ENCAP_ESP_LEN):
+ case (NET_HEADER_FIELD_UDP_ENCAP_ESP_CKSUM):
p_Extract->extractByHdr.hdr = HEADER_TYPE_UDP;
break;
- case(NET_HEADER_FIELD_UDP_ENCAP_ESP_SPI):
+ case (NET_HEADER_FIELD_UDP_ENCAP_ESP_SPI):
p_Extract->extractByHdr.type = e_FM_PCD_EXTRACT_FROM_HDR;
- p_Extract->extractByHdr.hdr = FmPcdGetAliasHdr(p_FmPcd, p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].netEnvId, HEADER_TYPE_UDP_ENCAP_ESP);
+ p_Extract->extractByHdr.hdr = FmPcdGetAliasHdr(p_FmPcd, p_Scheme->netEnvId, HEADER_TYPE_UDP_ENCAP_ESP);
p_Extract->extractByHdr.extractByHdrType.fromHdr.size = ESP_SPI_SIZE;
p_Extract->extractByHdr.extractByHdrType.fromHdr.offset = ESP_SPI_OFFSET;
p_Extract->extractByHdr.ignoreProtocolValidation = TRUE;
break;
- case(NET_HEADER_FIELD_UDP_ENCAP_ESP_SEQUENCE_NUM):
+ case (NET_HEADER_FIELD_UDP_ENCAP_ESP_SEQUENCE_NUM):
p_Extract->extractByHdr.type = e_FM_PCD_EXTRACT_FROM_HDR;
- p_Extract->extractByHdr.hdr = FmPcdGetAliasHdr(p_FmPcd, p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].netEnvId, HEADER_TYPE_UDP_ENCAP_ESP);
+ p_Extract->extractByHdr.hdr = FmPcdGetAliasHdr(p_FmPcd, p_Scheme->netEnvId, HEADER_TYPE_UDP_ENCAP_ESP);
p_Extract->extractByHdr.extractByHdrType.fromHdr.size = ESP_SEQ_NUM_SIZE;
p_Extract->extractByHdr.extractByHdrType.fromHdr.offset = ESP_SEQ_NUM_OFFSET;
p_Extract->extractByHdr.ignoreProtocolValidation = TRUE;
@@ -2246,9 +1471,9 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
default:
break;
}
- switch(p_Extract->extractByHdr.type)
+ switch (p_Extract->extractByHdr.type)
{
- case(e_FM_PCD_EXTRACT_FROM_HDR):
+ case (e_FM_PCD_EXTRACT_FROM_HDR):
generic = TRUE;
/* get the header code for the generic extract */
code = GetGenHdrCode(p_Extract->extractByHdr.hdr, p_Extract->extractByHdr.hdrIndex, p_Extract->extractByHdr.ignoreProtocolValidation);
@@ -2256,7 +1481,7 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
offset = p_Extract->extractByHdr.extractByHdrType.fromHdr.offset;
size = p_Extract->extractByHdr.extractByHdrType.fromHdr.size;
break;
- case(e_FM_PCD_EXTRACT_FROM_FIELD):
+ case (e_FM_PCD_EXTRACT_FROM_FIELD):
generic = TRUE;
/* get the field code for the generic extract */
code = GetGenFieldCode(p_Extract->extractByHdr.hdr,
@@ -2264,13 +1489,13 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
offset = p_Extract->extractByHdr.extractByHdrType.fromField.offset;
size = p_Extract->extractByHdr.extractByHdrType.fromField.size;
break;
- case(e_FM_PCD_EXTRACT_FULL_FIELD):
- if(!p_Extract->extractByHdr.ignoreProtocolValidation)
+ case (e_FM_PCD_EXTRACT_FULL_FIELD):
+ if (!p_Extract->extractByHdr.ignoreProtocolValidation)
{
/* if we have a known field for it - use it, otherwise use generic */
- bitMask = GetKnownProtMask(p_Extract->extractByHdr.hdr, p_Extract->extractByHdr.hdrIndex,
+ bitMask = GetKnownProtMask(p_FmPcd, p_Extract->extractByHdr.hdr, p_Extract->extractByHdr.hdrIndex,
p_Extract->extractByHdr.extractByHdrType.fullField);
- if(bitMask)
+ if (bitMask)
{
knownTmp |= bitMask;
/* save in driver structure */
@@ -2279,21 +1504,22 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
}
else
generic = TRUE;
-
}
else
generic = TRUE;
- if(generic)
+ if (generic)
{
/* tmp - till we cover more headers under generic */
+ XX_Free(p_LocalExtractsArray);
RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Full header selection not supported"));
}
break;
default:
+ XX_Free(p_LocalExtractsArray);
RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
}
break;
- case(e_FM_PCD_EXTRACT_NON_HDR):
+ case (e_FM_PCD_EXTRACT_NON_HDR):
/* use generic */
generic = TRUE;
offset = 0;
@@ -2306,25 +1532,35 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
}
- if(generic)
+ if (generic)
{
/* set generic register fields */
- if(currGenId >= FM_PCD_KG_NUM_OF_GENERIC_REGS)
+ if (currGenId >= FM_KG_NUM_OF_GENERIC_REGS)
+ {
+ XX_Free(p_LocalExtractsArray);
RETURN_ERROR(MAJOR, E_FULL, ("Generic registers are fully used"));
- if(!code)
+ }
+ if (!code)
+ {
+ XX_Free(p_LocalExtractsArray);
RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, NO_MSG);
+ }
genTmp = KG_SCH_GEN_VALID;
genTmp |= (uint32_t)(code << KG_SCH_GEN_HT_SHIFT);
genTmp |= offset;
- if((size > MAX_KG_SCH_SIZE) || (size < 1))
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal extraction (size out of range)"));
+ if ((size > MAX_KG_SCH_SIZE) || (size < 1))
+ {
+ XX_Free(p_LocalExtractsArray);
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal extraction (size out of range)"));
+ }
genTmp |= (uint32_t)((size - 1) << KG_SCH_GEN_SIZE_SHIFT);
swDefault = GetGenericSwDefault(swDefaults, numOfSwDefaults, code);
- if(swDefault == e_FM_PCD_KG_DFLT_ILLEGAL)
+ if (swDefault == e_FM_PCD_KG_DFLT_ILLEGAL)
DBG(WARNING, ("No sw default configured"));
+ else
+ genTmp |= swDefault << KG_SCH_GEN_DEF_SHIFT;
- genTmp |= swDefault << KG_SCH_GEN_DEF_SHIFT;
genTmp |= KG_SCH_GEN_MASK;
p_SchemeRegs->kgse_gec[currGenId] = genTmp;
/* save in driver structure */
@@ -2339,9 +1575,12 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
maskTmp = 0xFFFFFFFF;
/* configure kgse_bmch, kgse_bmcl and kgse_fqb */
- if(p_KeyAndHash->numOfUsedMasks >= FM_PCD_KG_NUM_OF_EXTRACT_MASKS)
+ if (p_KeyAndHash->numOfUsedMasks > FM_PCD_KG_NUM_OF_EXTRACT_MASKS)
+ {
+ XX_Free(p_LocalExtractsArray);
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Only %d masks supported", FM_PCD_KG_NUM_OF_EXTRACT_MASKS));
- for( i=0 ;i<p_KeyAndHash->numOfUsedMasks ; i++)
+ }
+ for ( i=0 ;i<p_KeyAndHash->numOfUsedMasks ; i++)
{
/* Get the relative id of the extract (for known 0-0x1f, for generic 0-7) */
id = p_LocalExtractsArray->extractsArray[p_KeyAndHash->masks[i].extractArrayIndex].id;
@@ -2374,23 +1613,32 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
/* kgse_fqb will be written t the end of the routine */
/* configure kgse_hc */
- if(p_KeyAndHash->hashShift > MAX_HASH_SHIFT)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("hashShift must not be larger than %d", MAX_HASH_SHIFT));
- if(p_KeyAndHash->hashDistributionFqidsShift > MAX_DIST_FQID_SHIFT)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("hashDistributionFqidsShift must not be larger than %d", MAX_DIST_FQID_SHIFT));
+ if (p_KeyAndHash->hashShift > MAX_HASH_SHIFT)
+ {
+ XX_Free(p_LocalExtractsArray);
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("hashShift must not be larger than %d", MAX_HASH_SHIFT));
+ }
+ if (p_KeyAndHash->hashDistributionFqidsShift > MAX_DIST_FQID_SHIFT)
+ {
+ XX_Free(p_LocalExtractsArray);
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("hashDistributionFqidsShift must not be larger than %d", MAX_DIST_FQID_SHIFT));
+ }
tmpReg = 0;
tmpReg |= ((p_KeyAndHash->hashDistributionNumOfFqids - 1) << p_KeyAndHash->hashDistributionFqidsShift);
tmpReg |= p_KeyAndHash->hashShift << KG_SCH_HASH_CONFIG_SHIFT_SHIFT;
- if(p_KeyAndHash->symmetricHash)
+ if (p_KeyAndHash->symmetricHash)
{
- if((!!(p_SchemeRegs->kgse_ekfc & KG_SCH_KN_MACSRC) != !!(p_SchemeRegs->kgse_ekfc & KG_SCH_KN_MACDST)) ||
+ if ((!!(p_SchemeRegs->kgse_ekfc & KG_SCH_KN_MACSRC) != !!(p_SchemeRegs->kgse_ekfc & KG_SCH_KN_MACDST)) ||
(!!(p_SchemeRegs->kgse_ekfc & KG_SCH_KN_IPSRC1) != !!(p_SchemeRegs->kgse_ekfc & KG_SCH_KN_IPDST1)) ||
(!!(p_SchemeRegs->kgse_ekfc & KG_SCH_KN_IPSRC2) != !!(p_SchemeRegs->kgse_ekfc & KG_SCH_KN_IPDST2)) ||
(!!(p_SchemeRegs->kgse_ekfc & KG_SCH_KN_L4PSRC) != !!(p_SchemeRegs->kgse_ekfc & KG_SCH_KN_L4PDST)))
+ {
+ XX_Free(p_LocalExtractsArray);
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("symmetricHash set but src/dest extractions missing"));
+ }
tmpReg |= KG_SCH_HASH_CONFIG_SYM;
}
p_SchemeRegs->kgse_hc = tmpReg;
@@ -2409,7 +1657,7 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
curr = 0;
for (i=0;i<p_KeyAndHash->numOfUsedExtracts ; i++)
{
- if(p_LocalExtractsArray->extractsArray[i].known)
+ if (p_LocalExtractsArray->extractsArray[i].known)
{
ASSERT_COND(curr<(p_KeyAndHash->numOfUsedExtracts - currGenId));
j = curr;
@@ -2417,14 +1665,14 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
index in the user's extractions array */
/* we compare the id of the current extract with the id of the extract in the orderedArray[j-1]
location */
- while((j > 0) && (p_LocalExtractsArray->extractsArray[i].id <
- p_LocalExtractsArray->extractsArray[p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].orderedArray[j-1]].id))
+ while ((j > 0) && (p_LocalExtractsArray->extractsArray[i].id <
+ p_LocalExtractsArray->extractsArray[p_Scheme->orderedArray[j-1]].id))
{
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].orderedArray[j] =
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].orderedArray[j-1];
+ p_Scheme->orderedArray[j] =
+ p_Scheme->orderedArray[j-1];
j--;
}
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].orderedArray[j] = (uint8_t)i;
+ p_Scheme->orderedArray[j] = (uint8_t)i;
curr++;
}
else
@@ -2432,12 +1680,10 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
/* index is first_generic_index + generic index (id) */
idx = (uint8_t)(p_KeyAndHash->numOfUsedExtracts - currGenId + p_LocalExtractsArray->extractsArray[i].id);
ASSERT_COND(idx < FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY);
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].orderedArray[idx]= (uint8_t)i;
+ p_Scheme->orderedArray[idx]= (uint8_t)i;
}
}
XX_Free(p_LocalExtractsArray);
- p_LocalExtractsArray = NULL;
-
}
else
{
@@ -2451,38 +1697,38 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
p_SchemeRegs->kgse_dv1 = 0;
}
- if(p_Scheme->bypassFqidGeneration)
+ if (p_SchemeParams->bypassFqidGeneration)
p_SchemeRegs->kgse_hc |= KG_SCH_HASH_CONFIG_NO_FQID;
/* configure kgse_spc */
- if( p_Scheme->schemeCounter.update)
- p_SchemeRegs->kgse_spc = p_Scheme->schemeCounter.value;
+ if ( p_SchemeParams->schemeCounter.update)
+ p_SchemeRegs->kgse_spc = p_SchemeParams->schemeCounter.value;
/* check that are enough generic registers */
- if(p_Scheme->numOfUsedExtractedOrs + currGenId > FM_PCD_KG_NUM_OF_GENERIC_REGS)
+ if (p_SchemeParams->numOfUsedExtractedOrs + currGenId > FM_KG_NUM_OF_GENERIC_REGS)
RETURN_ERROR(MAJOR, E_FULL, ("Generic registers are fully used"));
/* extracted OR mask on Qid */
- for( i=0 ;i<p_Scheme->numOfUsedExtractedOrs ; i++)
+ for ( i=0 ;i<p_SchemeParams->numOfUsedExtractedOrs ; i++)
{
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].extractedOrs = TRUE;
+ p_Scheme->extractedOrs = TRUE;
/* configure kgse_gec[i] */
- p_ExtractOr = &p_Scheme->extractedOrs[i];
- switch(p_ExtractOr->type)
+ p_ExtractOr = &p_SchemeParams->extractedOrs[i];
+ switch (p_ExtractOr->type)
{
- case(e_FM_PCD_KG_EXTRACT_PORT_PRIVATE_INFO):
+ case (e_FM_PCD_KG_EXTRACT_PORT_PRIVATE_INFO):
code = KG_SCH_GEN_PARSE_RESULT_N_FQID;
offset = 0;
break;
- case(e_FM_PCD_EXTRACT_BY_HDR):
+ case (e_FM_PCD_EXTRACT_BY_HDR):
/* get the header code for the generic extract */
code = GetGenHdrCode(p_ExtractOr->extractByHdr.hdr, p_ExtractOr->extractByHdr.hdrIndex, p_ExtractOr->extractByHdr.ignoreProtocolValidation);
/* set generic register fields */
offset = p_ExtractOr->extractionOffset;
break;
- case(e_FM_PCD_EXTRACT_NON_HDR):
+ case (e_FM_PCD_EXTRACT_NON_HDR):
/* get the field code for the generic extract */
offset = 0;
code = GetGenCode(p_ExtractOr->src, &offset);
@@ -2493,12 +1739,12 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
}
/* set generic register fields */
- if(!code)
+ if (!code)
RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, NO_MSG);
genTmp = KG_SCH_GEN_EXTRACT_TYPE | KG_SCH_GEN_VALID;
genTmp |= (uint32_t)(code << KG_SCH_GEN_HT_SHIFT);
genTmp |= offset;
- if(!!p_ExtractOr->bitOffsetInFqid == !!p_ExtractOr->bitOffsetInPlcrProfile)
+ if (!!p_ExtractOr->bitOffsetInFqid == !!p_ExtractOr->bitOffsetInPlcrProfile)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, (" extracted byte must effect either FQID or Policer profile"));
/************************************************************************************
@@ -2542,11 +1788,11 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
************************************************************************************/
- if(p_ExtractOr->bitOffsetInFqid)
+ if (p_ExtractOr->bitOffsetInFqid)
{
- if(p_ExtractOr->bitOffsetInFqid > MAX_KG_SCH_FQID_BIT_OFFSET )
+ if (p_ExtractOr->bitOffsetInFqid > MAX_KG_SCH_FQID_BIT_OFFSET )
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal extraction (bitOffsetInFqid out of range)"));
- if(p_ExtractOr->bitOffsetInFqid<8)
+ if (p_ExtractOr->bitOffsetInFqid<8)
genTmp |= (uint32_t)((p_ExtractOr->bitOffsetInFqid+24) << KG_SCH_GEN_SIZE_SHIFT);
else
genTmp |= (uint32_t)((p_ExtractOr->bitOffsetInFqid-8) << KG_SCH_GEN_SIZE_SHIFT);
@@ -2554,9 +1800,9 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
}
else /* effect policer profile */
{
- if(p_ExtractOr->bitOffsetInPlcrProfile > MAX_KG_SCH_PP_BIT_OFFSET )
+ if (p_ExtractOr->bitOffsetInPlcrProfile > MAX_KG_SCH_PP_BIT_OFFSET )
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal extraction (bitOffsetInPlcrProfile out of range)"));
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].bitOffsetInPlcrProfile = p_ExtractOr->bitOffsetInPlcrProfile;
+ p_Scheme->bitOffsetInPlcrProfile = p_ExtractOr->bitOffsetInPlcrProfile;
genTmp |= (uint32_t)((p_ExtractOr->bitOffsetInPlcrProfile+16) << KG_SCH_GEN_SIZE_SHIFT);
p_ExtractOr->mask &= GetExtractedOrMask(p_ExtractOr->bitOffsetInPlcrProfile, FALSE);
}
@@ -2570,245 +1816,938 @@ t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t
}
/* clear all unused GEC registers */
- for( i=currGenId ;i<FM_PCD_KG_NUM_OF_GENERIC_REGS ; i++)
+ for ( i=currGenId ;i<FM_KG_NUM_OF_GENERIC_REGS ; i++)
p_SchemeRegs->kgse_gec[i] = 0;
/* add base Qid for this scheme */
/* add configuration for kgse_fqb */
- if(p_Scheme->baseFqid & ~0x00FFFFFF)
+ if (p_SchemeParams->baseFqid & ~0x00FFFFFF)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("baseFqid must be between 1 and 2^24-1"));
- fqbTmp |= p_Scheme->baseFqid;
+ fqbTmp |= p_SchemeParams->baseFqid;
p_SchemeRegs->kgse_fqb = fqbTmp;
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].nextEngine = p_Scheme->nextEngine;
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].doneAction = p_Scheme->kgNextEngineParams.doneAction;
+ p_Scheme->nextEngine = p_SchemeParams->nextEngine;
+ p_Scheme->doneAction = p_SchemeParams->kgNextEngineParams.doneAction;
+
return E_OK;
}
-void FmPcdKgValidateSchemeSw(t_Handle h_FmPcd, uint8_t schemeId)
+
+/*****************************************************************************/
+/* Inter-module API routines */
+/*****************************************************************************/
+
+t_Error FmPcdKgBuildClsPlanGrp(t_Handle h_FmPcd, t_FmPcdKgInterModuleClsPlanGrpParams *p_Grp, t_FmPcdKgInterModuleClsPlanSet *p_ClsPlanSet)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_FmPcdKgClsPlanGrp *p_ClsPlanGrp;
+ t_FmPcdIpcKgClsPlanParams kgAlloc;
+ t_Error err = E_OK;
+ uint32_t oredVectors = 0;
+ int i, j;
+
+ /* this routine is protected by the calling routine ! */
+ if (p_Grp->numOfOptions >= FM_PCD_MAX_NUM_OF_OPTIONS(FM_PCD_MAX_NUM_OF_CLS_PLANS))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,("Too many classification plan basic options selected."));
+
+ /* find a new clsPlan group */
+ for (i = 0; i < FM_MAX_NUM_OF_PORTS; i++)
+ if (!p_FmPcd->p_FmPcdKg->clsPlanGrps[i].used)
+ break;
+ if (i == FM_MAX_NUM_OF_PORTS)
+ RETURN_ERROR(MAJOR, E_FULL,("No classification plan groups available."));
+
+ p_FmPcd->p_FmPcdKg->clsPlanGrps[i].used = TRUE;
+
+ p_Grp->clsPlanGrpId = (uint8_t)i;
+
+ if (p_Grp->numOfOptions == 0)
+ p_FmPcd->p_FmPcdKg->emptyClsPlanGrpId = (uint8_t)i;
+
+ p_ClsPlanGrp = &p_FmPcd->p_FmPcdKg->clsPlanGrps[i];
+ p_ClsPlanGrp->netEnvId = p_Grp->netEnvId;
+ p_ClsPlanGrp->owners = 0;
+ FmPcdSetClsPlanGrpId(p_FmPcd, p_Grp->netEnvId, p_Grp->clsPlanGrpId);
+ if (p_Grp->numOfOptions != 0)
+ FmPcdIncNetEnvOwners(p_FmPcd, p_Grp->netEnvId);
+
+ p_ClsPlanGrp->sizeOfGrp = (uint16_t)(1 << p_Grp->numOfOptions);
+ /* a minimal group of 8 is required */
+ if (p_ClsPlanGrp->sizeOfGrp < CLS_PLAN_NUM_PER_GRP)
+ p_ClsPlanGrp->sizeOfGrp = CLS_PLAN_NUM_PER_GRP;
+ if (p_FmPcd->guestId == NCSW_MASTER_ID)
+ {
+ err = KgAllocClsPlanEntries(h_FmPcd, p_ClsPlanGrp->sizeOfGrp, p_FmPcd->guestId, &p_ClsPlanGrp->baseEntry);
+
+ if (err)
+ RETURN_ERROR(MINOR, E_INVALID_STATE, NO_MSG);
+ }
+ else
+ {
+ t_FmPcdIpcMsg msg;
+ uint32_t replyLength;
+ t_FmPcdIpcReply reply;
+
+ /* in GUEST_PARTITION, we use the IPC, to also set a private driver group if required */
+ memset(&reply, 0, sizeof(reply));
+ memset(&msg, 0, sizeof(msg));
+ memset(&kgAlloc, 0, sizeof(kgAlloc));
+ kgAlloc.guestId = p_FmPcd->guestId;
+ kgAlloc.numOfClsPlanEntries = p_ClsPlanGrp->sizeOfGrp;
+ msg.msgId = FM_PCD_ALLOC_KG_CLSPLAN;
+ memcpy(msg.msgBody, &kgAlloc, sizeof(kgAlloc));
+ replyLength = (sizeof(uint32_t) + sizeof(p_ClsPlanGrp->baseEntry));
+ if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
+ (uint8_t*)&msg,
+ sizeof(msg.msgId) + sizeof(kgAlloc),
+ (uint8_t*)&reply,
+ &replyLength,
+ NULL,
+ NULL)) != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ if (replyLength != (sizeof(uint32_t) + sizeof(p_ClsPlanGrp->baseEntry)))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
+ if ((t_Error)reply.error != E_OK)
+ RETURN_ERROR(MINOR, (t_Error)reply.error, NO_MSG);
+
+ p_ClsPlanGrp->baseEntry = *(uint8_t*)(reply.replyBody);
+ }
+
+ /* build classification plan entries parameters */
+ p_ClsPlanSet->baseEntry = p_ClsPlanGrp->baseEntry;
+ p_ClsPlanSet->numOfClsPlanEntries = p_ClsPlanGrp->sizeOfGrp;
+
+ oredVectors = 0;
+ for (i = 0; i<p_Grp->numOfOptions; i++)
+ {
+ oredVectors |= p_Grp->optVectors[i];
+ /* save an array of used options - the indexes represent the power of 2 index */
+ p_ClsPlanGrp->optArray[i] = p_Grp->options[i];
+ }
+ /* set the classification plan relevant entries so that all bits
+ * relevant to the list of options is cleared
+ */
+ for (j = 0; j<p_ClsPlanGrp->sizeOfGrp; j++)
+ p_ClsPlanSet->vectors[j] = ~oredVectors;
+
+ for (i = 0; i<p_Grp->numOfOptions; i++)
+ {
+ /* option i got the place 2^i in the clsPlan array. all entries that
+ * have bit i set, should have the vector bit cleared. So each option
+ * has one location that it is exclusive (1,2,4,8...) and represent the
+ * presence of that option only, and other locations that represent a
+ * combination of options.
+ * e.g:
+ * If ethernet-BC is option 1 it gets entry 2 in the table. Entry 2
+ * now represents a frame with ethernet-BC header - so the bit
+ * representing ethernet-BC should be set and all other option bits
+ * should be cleared.
+ * Entries 2,3,6,7,10... also have ethernet-BC and therefore have bit
+ * vector[1] set, but they also have other bits set:
+ * 3=1+2, options 0 and 1
+ * 6=2+4, options 1 and 2
+ * 7=1+2+4, options 0,1,and 2
+ * 10=2+8, options 1 and 3
+ * etc.
+ * */
- ASSERT_COND(!p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
+ /* now for each option (i), we set their bits in all entries (j)
+ * that contain bit 2^i.
+ */
+ for (j = 0; j<p_ClsPlanGrp->sizeOfGrp; j++)
+ {
+ if (j & (1<<i))
+ p_ClsPlanSet->vectors[j] |= p_Grp->optVectors[i];
+ }
+ }
- if(p_FmPcd->p_FmPcdKg->schemes[schemeId].netEnvId != ILLEGAL_NETENV)
- FmPcdIncNetEnvOwners(p_FmPcd, p_FmPcd->p_FmPcdKg->schemes[schemeId].netEnvId);
- p_FmPcd->p_FmPcdKg->schemes[schemeId].valid = TRUE;
+ return E_OK;
}
-void FmPcdKgInvalidateSchemeSw(t_Handle h_FmPcd, uint8_t schemeId)
+void FmPcdKgDestroyClsPlanGrp(t_Handle h_FmPcd, uint8_t grpId)
{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_FmPcdIpcKgClsPlanParams kgAlloc;
+ t_Error err;
+ t_FmPcdIpcMsg msg;
+ uint32_t replyLength;
+ t_FmPcdIpcReply reply;
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ /* check that no port is bound to this clsPlan */
+ if (p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].owners)
+ {
+ REPORT_ERROR(MINOR, E_INVALID_STATE, ("Trying to delete a clsPlan grp that has ports bound to"));
+ return;
+ }
+
+ FmPcdSetClsPlanGrpId(p_FmPcd, p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].netEnvId, ILLEGAL_CLS_PLAN);
+
+ if (grpId == p_FmPcd->p_FmPcdKg->emptyClsPlanGrpId)
+ p_FmPcd->p_FmPcdKg->emptyClsPlanGrpId = ILLEGAL_CLS_PLAN;
+ else
+ FmPcdDecNetEnvOwners(p_FmPcd, p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].netEnvId);
- if(p_FmPcd->p_FmPcdKg->schemes[schemeId].netEnvId != ILLEGAL_NETENV)
- FmPcdDecNetEnvOwners(h_FmPcd, p_FmPcd->p_FmPcdKg->schemes[schemeId].netEnvId);
- p_FmPcd->p_FmPcdKg->schemes[schemeId].valid = FALSE;
+ /* free blocks */
+ if (p_FmPcd->guestId == NCSW_MASTER_ID)
+ KgFreeClsPlanEntries(h_FmPcd,
+ p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].sizeOfGrp,
+ p_FmPcd->guestId,
+ p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].baseEntry);
+ else /* in GUEST_PARTITION, we use the IPC, to also set a private driver group if required */
+ {
+ memset(&reply, 0, sizeof(reply));
+ memset(&msg, 0, sizeof(msg));
+ kgAlloc.guestId = p_FmPcd->guestId;
+ kgAlloc.numOfClsPlanEntries = p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].sizeOfGrp;
+ kgAlloc.clsPlanBase = p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId].baseEntry;
+ msg.msgId = FM_PCD_FREE_KG_CLSPLAN;
+ memcpy(msg.msgBody, &kgAlloc, sizeof(kgAlloc));
+ replyLength = sizeof(uint32_t);
+ err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
+ (uint8_t*)&msg,
+ sizeof(msg.msgId) + sizeof(kgAlloc),
+ (uint8_t*)&reply,
+ &replyLength,
+ NULL,
+ NULL);
+ if (err != E_OK)
+ {
+ REPORT_ERROR(MINOR, err, NO_MSG);
+ return;
+ }
+ if (replyLength != sizeof(uint32_t))
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
+ return;
+ }
+ if ((t_Error)reply.error != E_OK)
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Free KG clsPlan failed"));
+ return;
+ }
+ }
+
+ /* clear clsPlan driver structure */
+ memset(&p_FmPcd->p_FmPcdKg->clsPlanGrps[grpId], 0, sizeof(t_FmPcdKgClsPlanGrp));
}
-uint32_t FmPcdKgGetRequiredAction(t_Handle h_FmPcd, uint8_t schemeId)
+t_Error FmPcdKgBuildBindPortToSchemes(t_Handle h_FmPcd, t_FmPcdKgInterModuleBindPortToSchemes *p_BindPort, uint32_t *p_SpReg, bool add)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ uint32_t j, schemesPerPortVector = 0;
+ t_FmPcdKgScheme *p_Scheme;
+ uint8_t i, relativeSchemeId;
+ uint32_t tmp, walking1Mask;
+ uint8_t swPortIndex = 0;
- return p_FmPcd->p_FmPcdKg->schemes[schemeId].requiredAction;
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
+
+ /* for each scheme */
+ for (i = 0; i<p_BindPort->numOfSchemes; i++)
+ {
+ relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmPcd, p_BindPort->schemesIds[i]);
+ if (relativeSchemeId >= FM_PCD_KG_NUM_OF_SCHEMES)
+ RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
+
+ if (add)
+ {
+ p_Scheme = &p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId];
+ if (!FmPcdKgIsSchemeValidSw(p_Scheme))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Requested scheme is invalid."));
+ /* check netEnvId of the port against the scheme netEnvId */
+ if ((p_Scheme->netEnvId != p_BindPort->netEnvId) && (p_Scheme->netEnvId != ILLEGAL_NETENV))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Port may not be bound to requested scheme - differ in netEnvId"));
+
+ /* if next engine is private port policer profile, we need to check that it is valid */
+ HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, p_BindPort->hardwarePortId);
+ if (p_Scheme->nextRelativePlcrProfile)
+ {
+ for (j = 0;j<p_Scheme->numOfProfiles;j++)
+ {
+ ASSERT_COND(p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].h_FmPort);
+ if (p_Scheme->relativeProfileId+j >= p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].numOfProfiles)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Relative profile not in range"));
+ if (!FmPcdPlcrIsProfileValid(p_FmPcd, (uint16_t)(p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].profilesBase + p_Scheme->relativeProfileId + j)))
+ RETURN_ERROR(MINOR, E_INVALID_STATE, ("Relative profile not valid."));
+ }
+ }
+ if (!p_BindPort->useClsPlan)
+ {
+ /* This check may be redundant as port is a assigned to the whole NetEnv */
+
+ /* if this port does not use clsPlan, it may not be bound to schemes with units that contain
+ cls plan options. Schemes that are used only directly, should not be checked.
+ it also may not be bound to schemes that go to CC with units that are options - so we OR
+ the match vector and the grpBits (= ccUnits) */
+ if ((p_Scheme->matchVector != SCHEME_ALWAYS_DIRECT) || p_Scheme->ccUnits)
+ {
+ uint8_t netEnvId;
+ walking1Mask = 0x80000000;
+ netEnvId = (p_Scheme->netEnvId == ILLEGAL_NETENV)? p_BindPort->netEnvId:p_Scheme->netEnvId;
+ tmp = (p_Scheme->matchVector == SCHEME_ALWAYS_DIRECT)? 0:p_Scheme->matchVector;
+ tmp |= p_Scheme->ccUnits;
+ while (tmp)
+ {
+ if (tmp & walking1Mask)
+ {
+ tmp &= ~walking1Mask;
+ if (!PcdNetEnvIsUnitWithoutOpts(p_FmPcd, netEnvId, walking1Mask))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Port (without clsPlan) may not be bound to requested scheme - uses clsPlan options"));
+ }
+ walking1Mask >>= 1;
+ }
+ }
+ }
+ }
+ /* build vector */
+ schemesPerPortVector |= 1 << (31 - p_BindPort->schemesIds[i]);
+ }
+
+ *p_SpReg = schemesPerPortVector;
+
+ return E_OK;
}
-uint32_t FmPcdKgGetPointedOwners(t_Handle h_FmPcd, uint8_t schemeId)
+t_Error FmPcdKgBindPortToSchemes(t_Handle h_FmPcd , t_FmPcdKgInterModuleBindPortToSchemes *p_SchemeBind)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ uint32_t spReg;
+ t_Error err = E_OK;
- ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
+ err = FmPcdKgBuildBindPortToSchemes(h_FmPcd, p_SchemeBind, &spReg, TRUE);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
- return p_FmPcd->p_FmPcdKg->schemes[schemeId].pointedOwners;
+ err = KgWriteSp(p_FmPcd, p_SchemeBind->hardwarePortId, spReg, TRUE);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ IncSchemeOwners(p_FmPcd, p_SchemeBind);
+
+ return E_OK;
}
-bool FmPcdKgIsDirectPlcr(t_Handle h_FmPcd, uint8_t schemeId)
+t_Error FmPcdKgUnbindPortToSchemes(t_Handle h_FmPcd, t_FmPcdKgInterModuleBindPortToSchemes *p_SchemeBind)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ uint32_t spReg;
+ t_Error err = E_OK;
- ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
+ err = FmPcdKgBuildBindPortToSchemes(p_FmPcd, p_SchemeBind, &spReg, FALSE);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
- return p_FmPcd->p_FmPcdKg->schemes[schemeId].directPlcr;
+ err = KgWriteSp(p_FmPcd, p_SchemeBind->hardwarePortId, spReg, FALSE);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ DecSchemeOwners(p_FmPcd, p_SchemeBind);
+
+ return E_OK;
}
+bool FmPcdKgIsSchemeValidSw(t_Handle h_Scheme)
+{
+ t_FmPcdKgScheme *p_Scheme = (t_FmPcdKgScheme*)h_Scheme;
-uint16_t FmPcdKgGetRelativeProfileId(t_Handle h_FmPcd, uint8_t schemeId)
+ return p_Scheme->valid;
+}
+
+bool KgIsSchemeAlwaysDirect(t_Handle h_FmPcd, uint8_t schemeId)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
+ if (p_FmPcd->p_FmPcdKg->schemes[schemeId].matchVector == SCHEME_ALWAYS_DIRECT)
+ return TRUE;
+ else
+ return FALSE;
+}
- return p_FmPcd->p_FmPcdKg->schemes[schemeId].relativeProfileId;
+t_Error FmPcdKgAllocSchemes(t_Handle h_FmPcd, uint8_t numOfSchemes, uint8_t guestId, uint8_t *p_SchemesIds)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ uint8_t i, j;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE);
+
+ /* This routine is issued only on master core of master partition -
+ either directly or through IPC, so no need for lock */
+
+ for (j = 0, i = 0; i < FM_PCD_KG_NUM_OF_SCHEMES && j < numOfSchemes; i++)
+ {
+ if (!p_FmPcd->p_FmPcdKg->schemesMng[i].allocated)
+ {
+ p_FmPcd->p_FmPcdKg->schemesMng[i].allocated = TRUE;
+ p_FmPcd->p_FmPcdKg->schemesMng[i].ownerId = guestId;
+ p_SchemesIds[j] = i;
+ j++;
+ }
+ }
+
+ if (j != numOfSchemes)
+ {
+ /* roll back */
+ for (j--; j; j--)
+ {
+ p_FmPcd->p_FmPcdKg->schemesMng[p_SchemesIds[j]].allocated = FALSE;
+ p_FmPcd->p_FmPcdKg->schemesMng[p_SchemesIds[j]].ownerId = 0;
+ p_SchemesIds[j] = 0;
+ }
+
+ RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("No schemes found"));
+ }
+
+ return E_OK;
}
+t_Error FmPcdKgFreeSchemes(t_Handle h_FmPcd, uint8_t numOfSchemes, uint8_t guestId, uint8_t *p_SchemesIds)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ uint8_t i;
-bool FmPcdKgIsDistrOnPlcrProfile(t_Handle h_FmPcd, uint8_t schemeId)
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE);
+
+ /* This routine is issued only on master core of master partition -
+ either directly or through IPC */
+
+ for (i = 0; i < numOfSchemes; i++)
+ {
+ if (!p_FmPcd->p_FmPcdKg->schemesMng[p_SchemesIds[i]].allocated)
+ {
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Scheme was not previously allocated"));
+ }
+ if (p_FmPcd->p_FmPcdKg->schemesMng[p_SchemesIds[i]].ownerId != guestId)
+ {
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Scheme is not owned by caller. "));
+ }
+ p_FmPcd->p_FmPcdKg->schemesMng[p_SchemesIds[i]].allocated = FALSE;
+ p_FmPcd->p_FmPcdKg->schemesMng[p_SchemesIds[i]].ownerId = 0;
+ }
+
+ return E_OK;
+}
+
+t_Error KgAllocClsPlanEntries(t_Handle h_FmPcd, uint16_t numOfClsPlanEntries, uint8_t guestId, uint8_t *p_First)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ uint8_t numOfBlocks, blocksFound=0, first=0;
+ uint8_t i, j;
+
+ /* This routine is issued only on master core of master partition -
+ either directly or through IPC, so no need for lock */
+
+ if (!numOfClsPlanEntries)
+ return E_OK;
+
+ if ((numOfClsPlanEntries % CLS_PLAN_NUM_PER_GRP) || (!POWER_OF_2(numOfClsPlanEntries)))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfClsPlanEntries must be a power of 2 and divisible by 8"));
+
+ numOfBlocks = (uint8_t)(numOfClsPlanEntries/CLS_PLAN_NUM_PER_GRP);
+
+ /* try to find consequent blocks */
+ first = 0;
+ for (i = 0; i < FM_PCD_MAX_NUM_OF_CLS_PLANS/CLS_PLAN_NUM_PER_GRP;)
+ {
+ if (!p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[i].allocated)
+ {
+ blocksFound++;
+ i++;
+ if (blocksFound == numOfBlocks)
+ break;
+ }
+ else
+ {
+ blocksFound = 0;
+ /* advance i to the next aligned address */
+ first = i = (uint8_t)(first + numOfBlocks);
+ }
+ }
+
+ if (blocksFound == numOfBlocks)
+ {
+ *p_First = (uint8_t)(first * CLS_PLAN_NUM_PER_GRP);
+ for (j = first; j < (first + numOfBlocks); j++)
+ {
+ p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[j].allocated = TRUE;
+ p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[j].ownerId = guestId;
+ }
+ return E_OK;
+ }
+ else
+ RETURN_ERROR(MINOR, E_FULL, ("No resources for clsPlan"));
+}
+
+void KgFreeClsPlanEntries(t_Handle h_FmPcd, uint16_t numOfClsPlanEntries, uint8_t guestId, uint8_t base)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ uint8_t numOfBlocks;
+ uint8_t i, baseBlock;
- ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
+#ifdef DISABLE_ASSERTIONS
+UNUSED(guestId);
+#endif /* DISABLE_ASSERTIONS */
- if((p_FmPcd->p_FmPcdKg->schemes[schemeId].extractedOrs &&
- p_FmPcd->p_FmPcdKg->schemes[schemeId].bitOffsetInPlcrProfile) ||
- p_FmPcd->p_FmPcdKg->schemes[schemeId].nextRelativePlcrProfile)
- return TRUE;
+ /* This routine is issued only on master core of master partition -
+ either directly or through IPC, so no need for lock */
+
+ numOfBlocks = (uint8_t)(numOfClsPlanEntries/CLS_PLAN_NUM_PER_GRP);
+ ASSERT_COND(!(base%CLS_PLAN_NUM_PER_GRP));
+
+ baseBlock = (uint8_t)(base/CLS_PLAN_NUM_PER_GRP);
+ for (i=baseBlock;i<baseBlock+numOfBlocks;i++)
+ {
+ ASSERT_COND(p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[i].allocated);
+ ASSERT_COND(guestId == p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[i].ownerId);
+ p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[i].allocated = FALSE;
+ p_FmPcd->p_FmPcdKg->clsPlanBlocksMng[i].ownerId = 0;
+ }
+}
+
+void KgEnable(t_FmPcd *p_FmPcd)
+{
+ struct fman_kg_regs *p_Regs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
+
+ ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
+ fman_kg_enable(p_Regs);
+}
+
+void KgDisable(t_FmPcd *p_FmPcd)
+{
+ struct fman_kg_regs *p_Regs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
+
+ ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
+ fman_kg_disable(p_Regs);
+}
+
+void KgSetClsPlan(t_Handle h_FmPcd, t_FmPcdKgInterModuleClsPlanSet *p_Set)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ struct fman_kg_cp_regs *p_FmPcdKgPortRegs;
+ uint32_t tmpKgarReg = 0, intFlags;
+ uint16_t i, j;
+
+ /* This routine is protected by the calling routine ! */
+ ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
+ p_FmPcdKgPortRegs = &p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->clsPlanRegs;
+
+ intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
+ for (i=p_Set->baseEntry;i<p_Set->baseEntry+p_Set->numOfClsPlanEntries;i+=8)
+ {
+ tmpKgarReg = FmPcdKgBuildWriteClsPlanBlockActionReg((uint8_t)(i / CLS_PLAN_NUM_PER_GRP));
+
+ for (j = i; j < i+8; j++)
+ {
+ ASSERT_COND(IN_RANGE(0, (j - p_Set->baseEntry), FM_PCD_MAX_NUM_OF_CLS_PLANS-1));
+ WRITE_UINT32(p_FmPcdKgPortRegs->kgcpe[j % CLS_PLAN_NUM_PER_GRP],p_Set->vectors[j - p_Set->baseEntry]);
+ }
+
+ if (WriteKgarWait(p_FmPcd, tmpKgarReg) != E_OK)
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("WriteKgarWait FAILED"));
+ KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
+ return;
+ }
+ }
+ KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
+}
+
+t_Handle KgConfig( t_FmPcd *p_FmPcd, t_FmPcdParams *p_FmPcdParams)
+{
+ t_FmPcdKg *p_FmPcdKg;
+
+ UNUSED(p_FmPcd);
+
+ if (p_FmPcdParams->numOfSchemes > FM_PCD_KG_NUM_OF_SCHEMES)
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_VALUE,
+ ("numOfSchemes should not exceed %d", FM_PCD_KG_NUM_OF_SCHEMES));
+ return NULL;
+ }
+
+ p_FmPcdKg = (t_FmPcdKg *)XX_Malloc(sizeof(t_FmPcdKg));
+ if (!p_FmPcdKg)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Keygen allocation FAILED"));
+ return NULL;
+ }
+ memset(p_FmPcdKg, 0, sizeof(t_FmPcdKg));
+
+
+ if (FmIsMaster(p_FmPcd->h_Fm))
+ {
+ p_FmPcdKg->p_FmPcdKgRegs = (struct fman_kg_regs *)UINT_TO_PTR(FmGetPcdKgBaseAddr(p_FmPcdParams->h_Fm));
+ p_FmPcd->exceptions |= DEFAULT_fmPcdKgErrorExceptions;
+ p_FmPcdKg->p_IndirectAccessRegs = (u_FmPcdKgIndirectAccessRegs *)&p_FmPcdKg->p_FmPcdKgRegs->fmkg_indirect[0];
+ }
+
+ p_FmPcdKg->numOfSchemes = p_FmPcdParams->numOfSchemes;
+ if ((p_FmPcd->guestId == NCSW_MASTER_ID) && !p_FmPcdKg->numOfSchemes)
+ {
+ p_FmPcdKg->numOfSchemes = FM_PCD_KG_NUM_OF_SCHEMES;
+ DBG(WARNING, ("numOfSchemes was defined 0 by user, re-defined by driver to FM_PCD_KG_NUM_OF_SCHEMES"));
+ }
+
+ p_FmPcdKg->emptyClsPlanGrpId = ILLEGAL_CLS_PLAN;
+
+ return p_FmPcdKg;
+}
+
+t_Error KgInit(t_FmPcd *p_FmPcd)
+{
+ t_Error err = E_OK;
+
+ p_FmPcd->p_FmPcdKg->h_HwSpinlock = XX_InitSpinlock();
+ if (!p_FmPcd->p_FmPcdKg->h_HwSpinlock)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("FM KG HW spinlock"));
+
+ if (p_FmPcd->guestId == NCSW_MASTER_ID)
+ err = KgInitMaster(p_FmPcd);
else
- return FALSE;
+ err = KgInitGuest(p_FmPcd);
+ if (err != E_OK)
+ {
+ if (p_FmPcd->p_FmPcdKg->h_HwSpinlock)
+ XX_FreeSpinlock(p_FmPcd->p_FmPcdKg->h_HwSpinlock);
+ }
+
+ return err;
}
-void FmPcdKgUpatePointedOwner(t_Handle h_FmPcd, uint8_t schemeId, bool add)
+
+t_Error KgFree(t_FmPcd *p_FmPcd)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_FmPcdIpcKgSchemesParams kgAlloc;
+ t_Error err = E_OK;
+ t_FmPcdIpcMsg msg;
+ uint32_t replyLength;
+ t_FmPcdIpcReply reply;
- ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
+ FmUnregisterIntr(p_FmPcd->h_Fm, e_FM_MOD_KG, 0, e_FM_INTR_TYPE_ERR);
- if(add)
- p_FmPcd->p_FmPcdKg->schemes[schemeId].pointedOwners++;
+ if (p_FmPcd->guestId == NCSW_MASTER_ID)
+ {
+ err = FmPcdKgFreeSchemes(p_FmPcd,
+ p_FmPcd->p_FmPcdKg->numOfSchemes,
+ p_FmPcd->guestId,
+ p_FmPcd->p_FmPcdKg->schemesIds);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ if (p_FmPcd->p_FmPcdKg->h_HwSpinlock)
+ XX_FreeSpinlock(p_FmPcd->p_FmPcdKg->h_HwSpinlock);
+
+ return E_OK;
+ }
+
+ /* guest */
+ memset(&reply, 0, sizeof(reply));
+ memset(&msg, 0, sizeof(msg));
+ kgAlloc.numOfSchemes = p_FmPcd->p_FmPcdKg->numOfSchemes;
+ kgAlloc.guestId = p_FmPcd->guestId;
+ ASSERT_COND(kgAlloc.numOfSchemes < FM_PCD_KG_NUM_OF_SCHEMES);
+ memcpy(kgAlloc.schemesIds, p_FmPcd->p_FmPcdKg->schemesIds, (sizeof(uint8_t))*kgAlloc.numOfSchemes);
+ msg.msgId = FM_PCD_FREE_KG_SCHEMES;
+ memcpy(msg.msgBody, &kgAlloc, sizeof(kgAlloc));
+ replyLength = sizeof(uint32_t);
+ if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
+ (uint8_t*)&msg,
+ sizeof(msg.msgId) + sizeof(kgAlloc),
+ (uint8_t*)&reply,
+ &replyLength,
+ NULL,
+ NULL)) != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ if (replyLength != sizeof(uint32_t))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
+
+ if (p_FmPcd->p_FmPcdKg->h_HwSpinlock)
+ XX_FreeSpinlock(p_FmPcd->p_FmPcdKg->h_HwSpinlock);
+
+ return (t_Error)reply.error;
+}
+
+t_Error FmPcdKgSetOrBindToClsPlanGrp(t_Handle h_FmPcd, uint8_t hardwarePortId, uint8_t netEnvId, protocolOpt_t *p_OptArray, uint8_t *p_ClsPlanGrpId, bool *p_IsEmptyClsPlanGrp)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ t_FmPcdKgInterModuleClsPlanGrpParams grpParams, *p_GrpParams;
+ t_FmPcdKgClsPlanGrp *p_ClsPlanGrp;
+ t_FmPcdKgInterModuleClsPlanSet *p_ClsPlanSet;
+ t_Error err;
+
+ /* This function is issued only from FM_PORT_SetPcd which locked all PCD modules,
+ so no need for lock here */
+
+ memset(&grpParams, 0, sizeof(grpParams));
+ grpParams.clsPlanGrpId = ILLEGAL_CLS_PLAN;
+ p_GrpParams = &grpParams;
+
+ p_GrpParams->netEnvId = netEnvId;
+
+ /* Get from the NetEnv the information of the clsPlan (can be already created,
+ * or needs to build) */
+ err = PcdGetClsPlanGrpParams(h_FmPcd, p_GrpParams);
+ if (err)
+ RETURN_ERROR(MINOR,err,NO_MSG);
+
+ if (p_GrpParams->grpExists)
+ {
+ /* this group was already updated (at least) in SW */
+ *p_ClsPlanGrpId = p_GrpParams->clsPlanGrpId;
+ }
+ else
+ {
+ p_ClsPlanSet = (t_FmPcdKgInterModuleClsPlanSet *)XX_Malloc(sizeof(t_FmPcdKgInterModuleClsPlanSet));
+ if (!p_ClsPlanSet)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Classification plan set"));
+ memset(p_ClsPlanSet, 0, sizeof(t_FmPcdKgInterModuleClsPlanSet));
+ /* Build (in SW) the clsPlan parameters, including the vectors to be written to HW */
+ err = FmPcdKgBuildClsPlanGrp(h_FmPcd, p_GrpParams, p_ClsPlanSet);
+ if (err)
+ {
+ XX_Free(p_ClsPlanSet);
+ RETURN_ERROR(MINOR, err, NO_MSG);
+ }
+ *p_ClsPlanGrpId = p_GrpParams->clsPlanGrpId;
+
+ if (p_FmPcd->h_Hc)
+ {
+ /* write clsPlan entries to memory */
+ err = FmHcPcdKgSetClsPlan(p_FmPcd->h_Hc, p_ClsPlanSet);
+ if (err)
+ {
+ XX_Free(p_ClsPlanSet);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+ }
+ else
+ /* write clsPlan entries to memory */
+ KgSetClsPlan(p_FmPcd, p_ClsPlanSet);
+
+ XX_Free(p_ClsPlanSet);
+ }
+
+ /* Set caller parameters */
+
+ /* mark if this is an empty classification group */
+ if (*p_ClsPlanGrpId == p_FmPcd->p_FmPcdKg->emptyClsPlanGrpId)
+ *p_IsEmptyClsPlanGrp = TRUE;
else
- p_FmPcd->p_FmPcdKg->schemes[schemeId].pointedOwners--;
+ *p_IsEmptyClsPlanGrp = FALSE;
+
+ p_ClsPlanGrp = &p_FmPcd->p_FmPcdKg->clsPlanGrps[*p_ClsPlanGrpId];
+
+ /* increment owners number */
+ p_ClsPlanGrp->owners++;
+
+ /* copy options array for port */
+ memcpy(p_OptArray, &p_FmPcd->p_FmPcdKg->clsPlanGrps[*p_ClsPlanGrpId].optArray, FM_PCD_MAX_NUM_OF_OPTIONS(FM_PCD_MAX_NUM_OF_CLS_PLANS)*sizeof(protocolOpt_t));
+
+ /* bind port to the new or existing group */
+ err = BindPortToClsPlanGrp(p_FmPcd, hardwarePortId, p_GrpParams->clsPlanGrpId);
+ if (err)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ return E_OK;
}
-e_FmPcdEngine FmPcdKgGetNextEngine(t_Handle h_FmPcd, uint8_t schemeId)
+t_Error FmPcdKgDeleteOrUnbindPortToClsPlanGrp(t_Handle h_FmPcd, uint8_t hardwarePortId, uint8_t clsPlanGrpId)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ t_FmPcdKgClsPlanGrp *p_ClsPlanGrp = &p_FmPcd->p_FmPcdKg->clsPlanGrps[clsPlanGrpId];
+ t_FmPcdKgInterModuleClsPlanSet *p_ClsPlanSet;
+ t_Error err;
- ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
+ /* This function is issued only from FM_PORT_DeletePcd which locked all PCD modules,
+ so no need for lock here */
+
+ UnbindPortToClsPlanGrp(p_FmPcd, hardwarePortId);
+
+ /* decrement owners number */
+ ASSERT_COND(p_ClsPlanGrp->owners);
+ p_ClsPlanGrp->owners--;
- return p_FmPcd->p_FmPcdKg->schemes[schemeId].nextEngine;
+ if (!p_ClsPlanGrp->owners)
+ {
+ if (p_FmPcd->h_Hc)
+ {
+ err = FmHcPcdKgDeleteClsPlan(p_FmPcd->h_Hc, clsPlanGrpId);
+ return err;
+ }
+ else
+ {
+ /* clear clsPlan entries in memory */
+ p_ClsPlanSet = (t_FmPcdKgInterModuleClsPlanSet *)XX_Malloc(sizeof(t_FmPcdKgInterModuleClsPlanSet));
+ if (!p_ClsPlanSet)
+ {
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Classification plan set"));
+ }
+ memset(p_ClsPlanSet, 0, sizeof(t_FmPcdKgInterModuleClsPlanSet));
+
+ p_ClsPlanSet->baseEntry = p_FmPcd->p_FmPcdKg->clsPlanGrps[clsPlanGrpId].baseEntry;
+ p_ClsPlanSet->numOfClsPlanEntries = p_FmPcd->p_FmPcdKg->clsPlanGrps[clsPlanGrpId].sizeOfGrp;
+ KgSetClsPlan(p_FmPcd, p_ClsPlanSet);
+ XX_Free(p_ClsPlanSet);
+
+ FmPcdKgDestroyClsPlanGrp(h_FmPcd, clsPlanGrpId);
+ }
+ }
+ return E_OK;
}
-e_FmPcdDoneAction FmPcdKgGetDoneAction(t_Handle h_FmPcd, uint8_t schemeId)
+uint32_t FmPcdKgGetRequiredAction(t_Handle h_FmPcd, uint8_t schemeId)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
-
ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
- return p_FmPcd->p_FmPcdKg->schemes[schemeId].doneAction;
+ return p_FmPcd->p_FmPcdKg->schemes[schemeId].requiredAction;
}
-void FmPcdKgUpdateRequiredAction(t_Handle h_FmPcd, uint8_t schemeId, uint32_t requiredAction)
+uint32_t FmPcdKgGetRequiredActionFlag(t_Handle h_FmPcd, uint8_t schemeId)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
+ ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
- p_FmPcd->p_FmPcdKg->schemes[schemeId].requiredAction = requiredAction;
+ return p_FmPcd->p_FmPcdKg->schemes[schemeId].requiredActionFlag;
}
-t_Error FmPcdKgCheckInvalidateSchemeSw(t_Handle h_FmPcd, uint8_t schemeId)
+bool FmPcdKgIsDirectPlcr(t_Handle h_FmPcd, uint8_t schemeId)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- if(schemeId >= FM_PCD_KG_NUM_OF_SCHEMES)
- REPORT_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
+ ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
- /* check that no port is bound to this scheme */
- if(p_FmPcd->p_FmPcdKg->schemes[schemeId].owners)
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Trying to delete a scheme that has ports bound to"));
- if(!p_FmPcd->p_FmPcdKg->schemes[schemeId].valid)
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Trying to delete an invalid scheme"));
- return E_OK;
+ return p_FmPcd->p_FmPcdKg->schemes[schemeId].directPlcr;
}
-uint32_t FmPcdKgBuildCppReg(t_Handle h_FmPcd, uint8_t clsPlanGrpId)
+
+uint16_t FmPcdKgGetRelativeProfileId(t_Handle h_FmPcd, uint8_t schemeId)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint32_t tmpKgpeCpp;
- tmpKgpeCpp = (uint32_t)(p_FmPcd->p_FmPcdKg->clsPlanGrps[clsPlanGrpId].baseEntry / 8);
- tmpKgpeCpp |= (uint32_t)(((p_FmPcd->p_FmPcdKg->clsPlanGrps[clsPlanGrpId].sizeOfGrp / 8) - 1) << FM_PCD_KG_PE_CPP_MASK_SHIFT);
- return tmpKgpeCpp;
+ ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
+
+ return p_FmPcd->p_FmPcdKg->schemes[schemeId].relativeProfileId;
}
-bool FmPcdKgHwSchemeIsValid(uint32_t schemeModeReg)
+bool FmPcdKgIsDistrOnPlcrProfile(t_Handle h_FmPcd, uint8_t schemeId)
{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+
+ ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
- if(schemeModeReg & KG_SCH_MODE_EN)
+ if ((p_FmPcd->p_FmPcdKg->schemes[schemeId].extractedOrs &&
+ p_FmPcd->p_FmPcdKg->schemes[schemeId].bitOffsetInPlcrProfile) ||
+ p_FmPcd->p_FmPcdKg->schemes[schemeId].nextRelativePlcrProfile)
return TRUE;
else
return FALSE;
+
}
-uint32_t FmPcdKgBuildWriteSchemeActionReg(uint8_t schemeId, bool updateCounter)
+e_FmPcdEngine FmPcdKgGetNextEngine(t_Handle h_FmPcd, uint8_t relativeSchemeId)
{
- return (uint32_t)(((uint32_t)schemeId << FM_PCD_KG_KGAR_NUM_SHIFT)|
- FM_PCD_KG_KGAR_GO |
- FM_PCD_KG_KGAR_WRITE |
- FM_PCD_KG_KGAR_SEL_SCHEME_ENTRY |
- DUMMY_PORT_ID |
- (updateCounter ? FM_PCD_KG_KGAR_SCHEME_WSEL_UPDATE_CNT:0));
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+
+ ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].valid);
+ return p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].nextEngine;
}
-uint32_t FmPcdKgBuildReadSchemeActionReg(uint8_t schemeId)
+e_FmPcdDoneAction FmPcdKgGetDoneAction(t_Handle h_FmPcd, uint8_t schemeId)
{
- return (uint32_t)(((uint32_t)schemeId << FM_PCD_KG_KGAR_NUM_SHIFT)|
- FM_PCD_KG_KGAR_GO |
- FM_PCD_KG_KGAR_READ |
- FM_PCD_KG_KGAR_SEL_SCHEME_ENTRY |
- DUMMY_PORT_ID |
- FM_PCD_KG_KGAR_SCHEME_WSEL_UPDATE_CNT);
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
-}
+ ASSERT_COND(p_FmPcd->p_FmPcdKg->schemes[schemeId].valid);
+ return p_FmPcd->p_FmPcdKg->schemes[schemeId].doneAction;
+}
-uint32_t FmPcdKgBuildWriteClsPlanBlockActionReg(uint8_t grpId)
+void FmPcdKgUpdateRequiredAction(t_Handle h_Scheme, uint32_t requiredAction)
{
- return (uint32_t)(FM_PCD_KG_KGAR_GO |
- FM_PCD_KG_KGAR_WRITE |
- FM_PCD_KG_KGAR_SEL_CLS_PLAN_ENTRY |
- DUMMY_PORT_ID |
- ((uint32_t)grpId << FM_PCD_KG_KGAR_NUM_SHIFT) |
- FM_PCD_KG_KGAR_WSEL_MASK);
+ t_FmPcdKgScheme *p_Scheme = (t_FmPcdKgScheme *)h_Scheme;
+
+ /* this routine is protected by calling routine */
+ ASSERT_COND(p_Scheme->valid);
- /* if we ever want to write 1 by 1, use:
- sel = (uint8_t)(0x01 << (7- (entryId % CLS_PLAN_NUM_PER_GRP)));*/
+ p_Scheme->requiredAction |= requiredAction;
}
-uint32_t FmPcdKgBuildReadClsPlanBlockActionReg(uint8_t grpId)
+bool FmPcdKgHwSchemeIsValid(uint32_t schemeModeReg)
{
- return (uint32_t)(FM_PCD_KG_KGAR_GO |
- FM_PCD_KG_KGAR_READ |
- FM_PCD_KG_KGAR_SEL_CLS_PLAN_ENTRY |
- DUMMY_PORT_ID |
- ((uint32_t)grpId << FM_PCD_KG_KGAR_NUM_SHIFT) |
- FM_PCD_KG_KGAR_WSEL_MASK);
+ return (bool)!!(schemeModeReg & KG_SCH_MODE_EN);
+}
+
+uint32_t FmPcdKgBuildWriteSchemeActionReg(uint8_t schemeId, bool updateCounter)
+{
+ return (uint32_t)(((uint32_t)schemeId << FM_PCD_KG_KGAR_NUM_SHIFT) |
+ FM_KG_KGAR_GO |
+ FM_KG_KGAR_WRITE |
+ FM_KG_KGAR_SEL_SCHEME_ENTRY |
+ DUMMY_PORT_ID |
+ (updateCounter ? FM_KG_KGAR_SCM_WSEL_UPDATE_CNT:0));
+}
+
+uint32_t FmPcdKgBuildReadSchemeActionReg(uint8_t schemeId)
+{
+ return (uint32_t)(((uint32_t)schemeId << FM_PCD_KG_KGAR_NUM_SHIFT) |
+ FM_KG_KGAR_GO |
+ FM_KG_KGAR_READ |
+ FM_KG_KGAR_SEL_SCHEME_ENTRY |
+ DUMMY_PORT_ID |
+ FM_KG_KGAR_SCM_WSEL_UPDATE_CNT);
+
+}
+uint32_t FmPcdKgBuildWriteClsPlanBlockActionReg(uint8_t grpId)
+{
+ return (uint32_t)(FM_KG_KGAR_GO |
+ FM_KG_KGAR_WRITE |
+ FM_PCD_KG_KGAR_SEL_CLS_PLAN_ENTRY |
+ DUMMY_PORT_ID |
+ ((uint32_t)grpId << FM_PCD_KG_KGAR_NUM_SHIFT) |
+ FM_PCD_KG_KGAR_WSEL_MASK);
- /* if we ever want to write 1 by 1, use:
- sel = (uint8_t)(0x01 << (7- (entryId % CLS_PLAN_NUM_PER_GRP)));*/
+ /* if we ever want to write 1 by 1, use:
+ sel = (uint8_t)(0x01 << (7- (entryId % CLS_PLAN_NUM_PER_GRP)));
+ */
}
-uint32_t FmPcdKgBuildWritePortSchemeBindActionReg(uint8_t hardwarePortId)
+uint32_t FmPcdKgBuildWritePortSchemeBindActionReg(uint8_t hardwarePortId)
{
- return (uint32_t)(FM_PCD_KG_KGAR_GO |
- FM_PCD_KG_KGAR_WRITE |
- FM_PCD_KG_KGAR_SEL_PORT_ENTRY |
- hardwarePortId |
- FM_PCD_KG_KGAR_SEL_PORT_WSEL_SP);
+ return (uint32_t)(FM_KG_KGAR_GO |
+ FM_KG_KGAR_WRITE |
+ FM_PCD_KG_KGAR_SEL_PORT_ENTRY |
+ hardwarePortId |
+ FM_PCD_KG_KGAR_SEL_PORT_WSEL_SP);
}
-uint32_t FmPcdKgBuildReadPortSchemeBindActionReg(uint8_t hardwarePortId)
+uint32_t FmPcdKgBuildReadPortSchemeBindActionReg(uint8_t hardwarePortId)
{
- return (uint32_t)(FM_PCD_KG_KGAR_GO |
- FM_PCD_KG_KGAR_READ |
- FM_PCD_KG_KGAR_SEL_PORT_ENTRY |
- hardwarePortId |
- FM_PCD_KG_KGAR_SEL_PORT_WSEL_SP);
+ return (uint32_t)(FM_KG_KGAR_GO |
+ FM_KG_KGAR_READ |
+ FM_PCD_KG_KGAR_SEL_PORT_ENTRY |
+ hardwarePortId |
+ FM_PCD_KG_KGAR_SEL_PORT_WSEL_SP);
}
-uint32_t FmPcdKgBuildWritePortClsPlanBindActionReg(uint8_t hardwarePortId)
+
+uint32_t FmPcdKgBuildWritePortClsPlanBindActionReg(uint8_t hardwarePortId)
{
- return (uint32_t)(FM_PCD_KG_KGAR_GO |
- FM_PCD_KG_KGAR_WRITE |
- FM_PCD_KG_KGAR_SEL_PORT_ENTRY |
- hardwarePortId |
- FM_PCD_KG_KGAR_SEL_PORT_WSEL_CPP);
+ return (uint32_t)(FM_KG_KGAR_GO |
+ FM_KG_KGAR_WRITE |
+ FM_PCD_KG_KGAR_SEL_PORT_ENTRY |
+ hardwarePortId |
+ FM_PCD_KG_KGAR_SEL_PORT_WSEL_CPP);
}
uint8_t FmPcdKgGetClsPlanGrpBase(t_Handle h_FmPcd, uint8_t clsPlanGrp)
@@ -2825,106 +2764,125 @@ uint16_t FmPcdKgGetClsPlanGrpSize(t_Handle h_FmPcd, uint8_t clsPlanGrp)
return p_FmPcd->p_FmPcdKg->clsPlanGrps[clsPlanGrp].sizeOfGrp;
}
-uint8_t FmPcdKgGetSchemeSwId(t_Handle h_FmPcd, uint8_t schemeHwId)
+
+uint8_t FmPcdKgGetSchemeId(t_Handle h_Scheme)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint8_t i;
+ return ((t_FmPcdKgScheme*)h_Scheme)->schemeId;
- for(i=0;i<p_FmPcd->p_FmPcdKg->numOfSchemes;i++)
- if(p_FmPcd->p_FmPcdKg->schemesIds[i] == schemeHwId)
- return i;
- ASSERT_COND(i!=p_FmPcd->p_FmPcdKg->numOfSchemes);
- return FM_PCD_KG_NUM_OF_SCHEMES;
}
-uint8_t FmPcdKgGetNumOfPartitionSchemes(t_Handle h_FmPcd)
+#if (DPAA_VERSION >= 11)
+bool FmPcdKgGetVspe(t_Handle h_Scheme)
{
- return ((t_FmPcd*)h_FmPcd)->p_FmPcdKg->numOfSchemes;
-}
+ return ((t_FmPcdKgScheme*)h_Scheme)->vspe;
-uint8_t FmPcdKgGetPhysicalSchemeId(t_Handle h_FmPcd, uint8_t relativeSchemeId)
-{
- return ((t_FmPcd*)h_FmPcd)->p_FmPcdKg->schemesIds[relativeSchemeId];
}
+#endif /* (DPAA_VERSION >= 11) */
uint8_t FmPcdKgGetRelativeSchemeId(t_Handle h_FmPcd, uint8_t schemeId)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
uint8_t i;
- for(i = 0;i<p_FmPcd->p_FmPcdKg->numOfSchemes;i++)
- if(p_FmPcd->p_FmPcdKg->schemesIds[i] == schemeId)
+ for (i = 0;i<p_FmPcd->p_FmPcdKg->numOfSchemes;i++)
+ if (p_FmPcd->p_FmPcdKg->schemesIds[i] == schemeId)
return i;
- if(i == p_FmPcd->p_FmPcdKg->numOfSchemes)
+ if (i == p_FmPcd->p_FmPcdKg->numOfSchemes)
REPORT_ERROR(MAJOR, E_NOT_IN_RANGE, ("Scheme is out of partition range"));
return FM_PCD_KG_NUM_OF_SCHEMES;
}
-t_Error FmPcdKgCcGetSetParams(t_Handle h_FmPcd, t_Handle h_Scheme, uint32_t requiredAction)
+t_Handle FmPcdKgGetSchemeHandle(t_Handle h_FmPcd, uint8_t relativeSchemeId)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+
+ ASSERT_COND(p_FmPcd);
+
+ /* check that schemeId is in range */
+ if (relativeSchemeId >= p_FmPcd->p_FmPcdKg->numOfSchemes)
+ {
+ REPORT_ERROR(MAJOR, E_NOT_IN_RANGE, ("relative-scheme-id %d!", relativeSchemeId));
+ return NULL;
+ }
+
+ if (!FmPcdKgIsSchemeValidSw(&p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId]))
+ return NULL;
+
+ return &p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId];
+}
+
+bool FmPcdKgIsSchemeHasOwners(t_Handle h_Scheme)
+{
+ return (((t_FmPcdKgScheme*)h_Scheme)->owners == 0)?FALSE:TRUE;
+}
+
+t_Error FmPcdKgCcGetSetParams(t_Handle h_FmPcd, t_Handle h_Scheme, uint32_t requiredAction, uint32_t value)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
uint8_t relativeSchemeId, physicalSchemeId;
uint32_t tmpKgarReg, tmpReg32 = 0, intFlags;
t_Error err;
+ t_FmPcdKgScheme *p_Scheme = (t_FmPcdKgScheme*)h_Scheme;
SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, 0);
SANITY_CHECK_RETURN_VALUE(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE, 0);
SANITY_CHECK_RETURN_VALUE(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE, 0);
+ /* Calling function locked all PCD modules, so no need to lock here */
+
+ if (!FmPcdKgIsSchemeValidSw(h_Scheme))
+ RETURN_ERROR(MAJOR, E_ALREADY_EXISTS, ("Scheme is Invalid"));
+
if (p_FmPcd->h_Hc)
- return FmHcPcdKgCcGetSetParams(p_FmPcd->h_Hc, h_Scheme, requiredAction);
+ {
+ err = FmHcPcdKgCcGetSetParams(p_FmPcd->h_Hc, h_Scheme, requiredAction, value);
+
+ UpdateRequiredActionFlag(h_Scheme,TRUE);
+ FmPcdKgUpdateRequiredAction(h_Scheme,requiredAction);
+ return err;
+ }
- physicalSchemeId = (uint8_t)(PTR_TO_UINT(h_Scheme)-1);
+ physicalSchemeId = p_Scheme->schemeId;
relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmPcd, physicalSchemeId);
- if(relativeSchemeId >= FM_PCD_KG_NUM_OF_SCHEMES)
+ if (relativeSchemeId >= FM_PCD_KG_NUM_OF_SCHEMES)
RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
- if (FmPcdKgSchemeTryLock(p_FmPcd, relativeSchemeId, FALSE))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Lock of the scheme FAILED"));
-
- if(!p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].pointedOwners ||
- !(p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].requiredAction & requiredAction))
+ if (!p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].requiredActionFlag ||
+ !(p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].requiredAction & requiredAction))
{
- if(requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)
+ if (requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)
{
- switch(p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].nextEngine)
+ switch (p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].nextEngine)
{
- case(e_FM_PCD_DONE):
- if(p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].doneAction == e_FM_PCD_ENQ_FRAME)
+ case (e_FM_PCD_DONE):
+ if (p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].doneAction == e_FM_PCD_ENQ_FRAME)
{
tmpKgarReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
- intFlags = FmPcdLock(p_FmPcd);
+ intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
WriteKgarWait(p_FmPcd, tmpKgarReg);
- if (!(GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs.kgse_mode) & KG_SCH_MODE_EN))
- {
- RELEASE_LOCK(p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].lock);
- RETURN_ERROR(MAJOR, E_ALREADY_EXISTS, ("Scheme is Invalid"));
- }
- tmpReg32 = GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs.kgse_mode);
+ tmpReg32 = GET_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_mode);
ASSERT_COND(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME));
- WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs.kgse_mode, tmpReg32 | NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA);
+ WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_mode, tmpReg32 | NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA);
/* call indirect command for scheme write */
tmpKgarReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, FALSE);
WriteKgarWait(p_FmPcd, tmpKgarReg);
- FmPcdUnlock(p_FmPcd, intFlags);
+ KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
}
break;
- case(e_FM_PCD_PLCR):
- if(!p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].directPlcr ||
+ case (e_FM_PCD_PLCR):
+ if (!p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].directPlcr ||
(p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].extractedOrs &&
p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].bitOffsetInPlcrProfile) ||
p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].nextRelativePlcrProfile)
{
- RELEASE_LOCK(p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].lock);
RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("In this situation PP can not be with distribution and has to be shared"));
}
err = FmPcdPlcrCcGetSetParams(h_FmPcd, p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].relativeProfileId, requiredAction);
- if(err)
+ if (err)
{
- RELEASE_LOCK(p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].lock);
RETURN_ERROR(MAJOR, err, NO_MSG);
}
break;
@@ -2932,258 +2890,353 @@ t_Error FmPcdKgCcGetSetParams(t_Handle h_FmPcd, t_Handle h_Scheme, uint32_t req
RETURN_ERROR(MAJOR, E_INVALID_VALUE,("in this situation the next engine after scheme can be or PLCR or ENQ_FRAME"));
}
}
+ if (requiredAction & UPDATE_KG_NIA_CC_WA)
+ {
+ if (p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].nextEngine == e_FM_PCD_CC)
+ {
+ tmpKgarReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
+ intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
+ WriteKgarWait(p_FmPcd, tmpKgarReg);
+ tmpReg32 = GET_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_mode);
+ ASSERT_COND(tmpReg32 & (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_CC));
+ tmpReg32 &= ~NIA_FM_CTL_AC_CC;
+ WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_mode, tmpReg32 | NIA_FM_CTL_AC_PRE_CC);
+ /* call indirect command for scheme write */
+ tmpKgarReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, FALSE);
+ WriteKgarWait(p_FmPcd, tmpKgarReg);
+ KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
+ }
+ }
+ if (requiredAction & UPDATE_KG_OPT_MODE)
+ {
+ tmpKgarReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
+ intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
+ WriteKgarWait(p_FmPcd, tmpKgarReg);
+ WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_om, value);
+ /* call indirect command for scheme write */
+ tmpKgarReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, FALSE);
+ WriteKgarWait(p_FmPcd, tmpKgarReg);
+ KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
+ }
+ if (requiredAction & UPDATE_KG_NIA)
+ {
+ tmpKgarReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
+ intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
+ WriteKgarWait(p_FmPcd, tmpKgarReg);
+ tmpReg32 = GET_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_mode);
+ tmpReg32 &= ~(NIA_ENG_MASK | NIA_AC_MASK);
+ tmpReg32 |= value;
+ WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_mode, tmpReg32);
+ /* call indirect command for scheme write */
+ tmpKgarReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, FALSE);
+ WriteKgarWait(p_FmPcd, tmpKgarReg);
+ KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
+ }
}
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].pointedOwners += 1;
- p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].requiredAction |= requiredAction;
- RELEASE_LOCK(p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].lock);
+ UpdateRequiredActionFlag(h_Scheme, TRUE);
+ FmPcdKgUpdateRequiredAction(h_Scheme, requiredAction);
+
return E_OK;
}
+/*********************** End of inter-module routines ************************/
-t_Error FmPcdKgSchemeTryLock(t_Handle h_FmPcd, uint8_t schemeId, bool intr)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- bool ans;
-
- if (intr)
- ans = TRY_LOCK(NULL, &p_FmPcd->p_FmPcdKg->schemes[schemeId].lock);
- else
- ans = TRY_LOCK(p_FmPcd->h_Spinlock, &p_FmPcd->p_FmPcdKg->schemes[schemeId].lock);
- if (ans)
- return E_OK;
- return ERROR_CODE(E_BUSY);
-}
-void FmPcdKgReleaseSchemeLock(t_Handle h_FmPcd, uint8_t schemeId)
-{
- RELEASE_LOCK(((t_FmPcd*)h_FmPcd)->p_FmPcdKg->schemes[schemeId].lock);
-}
+/****************************************/
+/* API routines */
+/****************************************/
-t_Handle FM_PCD_KgSetScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme)
+t_Handle FM_PCD_KgSchemeSet(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_SchemeParams)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint32_t tmpReg;
- t_FmPcdKgInterModuleSchemeRegs schemeRegs;
- t_FmPcdKgInterModuleSchemeRegs *p_MemRegs;
+ t_FmPcd *p_FmPcd;
+ struct fman_kg_scheme_regs schemeRegs;
+ struct fman_kg_scheme_regs *p_MemRegs;
uint8_t i;
t_Error err = E_OK;
uint32_t tmpKgarReg;
uint32_t intFlags;
- uint8_t physicalSchemeId, relativeSchemeId;
+ uint8_t physicalSchemeId, relativeSchemeId = 0;
+ t_FmPcdKgScheme *p_Scheme;
- SANITY_CHECK_RETURN_VALUE(p_FmPcd, E_INVALID_HANDLE, NULL);
- SANITY_CHECK_RETURN_VALUE(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE, NULL);
- SANITY_CHECK_RETURN_VALUE(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE, NULL);
+ if (p_SchemeParams->modify)
+ {
+ p_Scheme = (t_FmPcdKgScheme *)p_SchemeParams->id.h_Scheme;
+ p_FmPcd = p_Scheme->h_FmPcd;
- if (p_FmPcd->h_Hc)
- return FmHcPcdKgSetScheme(p_FmPcd->h_Hc, p_Scheme);
+ SANITY_CHECK_RETURN_VALUE(p_FmPcd, E_INVALID_HANDLE, NULL);
+ SANITY_CHECK_RETURN_VALUE(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE, NULL);
- /* if not called for modification, check first that this scheme is unused */
- if(!p_Scheme->modify)
- {
- /* check that schemeId is in range */
- if(p_Scheme->id.relativeSchemeId >= p_FmPcd->p_FmPcdKg->numOfSchemes)
+ if (!FmPcdKgIsSchemeValidSw(p_Scheme))
{
- REPORT_ERROR(MAJOR, E_NOT_IN_RANGE, ("Scheme is out of range"));
+ REPORT_ERROR(MAJOR, E_ALREADY_EXISTS,
+ ("Scheme is invalid"));
return NULL;
}
- relativeSchemeId = p_Scheme->id.relativeSchemeId;
-
- if (FmPcdKgSchemeTryLock(p_FmPcd, relativeSchemeId, FALSE))
- return NULL;
-
- physicalSchemeId = p_FmPcd->p_FmPcdKg->schemesIds[relativeSchemeId];
-
- /* read specified scheme into scheme registers */
- tmpKgarReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
- intFlags = FmPcdLock(p_FmPcd);
- WriteKgarWait(p_FmPcd, tmpKgarReg);
- tmpReg = GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs.kgse_mode);
- FmPcdUnlock(p_FmPcd, intFlags);
- if (tmpReg & KG_SCH_MODE_EN)
+ if (!KgSchemeFlagTryLock(p_Scheme))
{
- REPORT_ERROR(MAJOR, E_ALREADY_EXISTS,
- ("Scheme %d(phys %d) is already used", relativeSchemeId, physicalSchemeId));
- RELEASE_LOCK(p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].lock);
+ DBG(TRACE, ("Scheme Try Lock - BUSY"));
+ /* Signal to caller BUSY condition */
+ p_SchemeParams->id.h_Scheme = NULL;
return NULL;
}
}
else
{
- SANITY_CHECK_RETURN_VALUE(p_Scheme->id.h_Scheme, E_INVALID_HANDLE, NULL);
+ p_FmPcd = (t_FmPcd*)h_FmPcd;
- intFlags = FmPcdLock(p_FmPcd);
- physicalSchemeId = (uint8_t)(PTR_TO_UINT(p_Scheme->id.h_Scheme)-1);
- relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmPcd, physicalSchemeId);
+ SANITY_CHECK_RETURN_VALUE(p_FmPcd, E_INVALID_HANDLE, NULL);
+ SANITY_CHECK_RETURN_VALUE(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE, NULL);
+ relativeSchemeId = p_SchemeParams->id.relativeSchemeId;
/* check that schemeId is in range */
- if(relativeSchemeId >= FM_PCD_KG_NUM_OF_SCHEMES)
+ if (relativeSchemeId >= p_FmPcd->p_FmPcdKg->numOfSchemes)
{
- REPORT_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
- FmPcdUnlock(p_FmPcd, intFlags);
+ REPORT_ERROR(MAJOR, E_NOT_IN_RANGE, ("relative-scheme-id %d!", relativeSchemeId));
return NULL;
}
- err = FmPcdKgSchemeTryLock(p_FmPcd, relativeSchemeId, TRUE);
- FmPcdUnlock(p_FmPcd, intFlags);
- if (err)
+ p_Scheme = &p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId];
+ if (FmPcdKgIsSchemeValidSw(p_Scheme))
+ {
+ REPORT_ERROR(MAJOR, E_ALREADY_EXISTS,
+ ("Scheme id (%d)!", relativeSchemeId));
return NULL;
+ }
+ /* Clear all fields, scheme may have beed previously used */
+ memset(p_Scheme, 0, sizeof(t_FmPcdKgScheme));
+
+ p_Scheme->schemeId = p_FmPcd->p_FmPcdKg->schemesIds[relativeSchemeId];
+ p_Scheme->h_FmPcd = p_FmPcd;
+
+ p_Scheme->p_Lock = FmPcdAcquireLock(p_FmPcd);
+ if (!p_Scheme->p_Lock)
+ REPORT_ERROR(MAJOR, E_NOT_AVAILABLE, ("FM KG Scheme lock obj!"));
}
- err = FmPcdKgBuildScheme(h_FmPcd, p_Scheme, &schemeRegs);
- if(err)
+ err = BuildSchemeRegs((t_Handle)p_Scheme, p_SchemeParams, &schemeRegs);
+ if (err)
{
REPORT_ERROR(MAJOR, err, NO_MSG);
- FmPcdKgInvalidateSchemeSw(h_FmPcd, relativeSchemeId);
- RELEASE_LOCK(p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].lock);
+ if (p_SchemeParams->modify)
+ KgSchemeFlagUnlock(p_Scheme);
+ if (!p_SchemeParams->modify &&
+ p_Scheme->p_Lock)
+ FmPcdReleaseLock(p_FmPcd, p_Scheme->p_Lock);
return NULL;
}
+ if (p_FmPcd->h_Hc)
+ {
+ err = FmHcPcdKgSetScheme(p_FmPcd->h_Hc,
+ (t_Handle)p_Scheme,
+ &schemeRegs,
+ p_SchemeParams->schemeCounter.update);
+ if (p_SchemeParams->modify)
+ KgSchemeFlagUnlock(p_Scheme);
+ if (err)
+ {
+ if (!p_SchemeParams->modify &&
+ p_Scheme->p_Lock)
+ FmPcdReleaseLock(p_FmPcd, p_Scheme->p_Lock);
+ return NULL;
+ }
+ if (!p_SchemeParams->modify)
+ ValidateSchemeSw(p_Scheme);
+ return (t_Handle)p_Scheme;
+ }
+
+ physicalSchemeId = p_Scheme->schemeId;
+
/* configure all 21 scheme registers */
- p_MemRegs = &p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs;
- intFlags = FmPcdLock(p_FmPcd);
- WRITE_UINT32(p_MemRegs->kgse_ppc, schemeRegs.kgse_ppc);
- WRITE_UINT32(p_MemRegs->kgse_ccbs, schemeRegs.kgse_ccbs);
- WRITE_UINT32(p_MemRegs->kgse_mode, schemeRegs.kgse_mode);
- WRITE_UINT32(p_MemRegs->kgse_mv, schemeRegs.kgse_mv);
- WRITE_UINT32(p_MemRegs->kgse_dv0, schemeRegs.kgse_dv0);
- WRITE_UINT32(p_MemRegs->kgse_dv1, schemeRegs.kgse_dv1);
- WRITE_UINT32(p_MemRegs->kgse_ekdv, schemeRegs.kgse_ekdv);
- WRITE_UINT32(p_MemRegs->kgse_ekfc, schemeRegs.kgse_ekfc);
- WRITE_UINT32(p_MemRegs->kgse_bmch, schemeRegs.kgse_bmch);
- WRITE_UINT32(p_MemRegs->kgse_bmcl, schemeRegs.kgse_bmcl);
- WRITE_UINT32(p_MemRegs->kgse_hc, schemeRegs.kgse_hc);
- WRITE_UINT32(p_MemRegs->kgse_spc, schemeRegs.kgse_spc);
- WRITE_UINT32(p_MemRegs->kgse_fqb, schemeRegs.kgse_fqb);
- for(i=0 ; i<FM_PCD_KG_NUM_OF_GENERIC_REGS ; i++)
+ p_MemRegs = &p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs;
+ intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
+ WRITE_UINT32(p_MemRegs->kgse_ppc, schemeRegs.kgse_ppc);
+ WRITE_UINT32(p_MemRegs->kgse_ccbs, schemeRegs.kgse_ccbs);
+ WRITE_UINT32(p_MemRegs->kgse_mode, schemeRegs.kgse_mode);
+ WRITE_UINT32(p_MemRegs->kgse_mv, schemeRegs.kgse_mv);
+ WRITE_UINT32(p_MemRegs->kgse_dv0, schemeRegs.kgse_dv0);
+ WRITE_UINT32(p_MemRegs->kgse_dv1, schemeRegs.kgse_dv1);
+ WRITE_UINT32(p_MemRegs->kgse_ekdv, schemeRegs.kgse_ekdv);
+ WRITE_UINT32(p_MemRegs->kgse_ekfc, schemeRegs.kgse_ekfc);
+ WRITE_UINT32(p_MemRegs->kgse_bmch, schemeRegs.kgse_bmch);
+ WRITE_UINT32(p_MemRegs->kgse_bmcl, schemeRegs.kgse_bmcl);
+ WRITE_UINT32(p_MemRegs->kgse_hc, schemeRegs.kgse_hc);
+ WRITE_UINT32(p_MemRegs->kgse_spc, schemeRegs.kgse_spc);
+ WRITE_UINT32(p_MemRegs->kgse_fqb, schemeRegs.kgse_fqb);
+ WRITE_UINT32(p_MemRegs->kgse_om, schemeRegs.kgse_om);
+ WRITE_UINT32(p_MemRegs->kgse_vsp, schemeRegs.kgse_vsp);
+ for (i=0 ; i<FM_KG_NUM_OF_GENERIC_REGS ; i++)
WRITE_UINT32(p_MemRegs->kgse_gec[i], schemeRegs.kgse_gec[i]);
/* call indirect command for scheme write */
- tmpKgarReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, p_Scheme->schemeCounter.update);
+ tmpKgarReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, p_SchemeParams->schemeCounter.update);
WriteKgarWait(p_FmPcd, tmpKgarReg);
- FmPcdUnlock(p_FmPcd, intFlags);
+ KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
- FmPcdKgValidateSchemeSw(h_FmPcd, relativeSchemeId);
-
- RELEASE_LOCK(p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].lock);
+ if (!p_SchemeParams->modify)
+ ValidateSchemeSw(p_Scheme);
+ else
+ KgSchemeFlagUnlock(p_Scheme);
- return UINT_TO_PTR((uint64_t)physicalSchemeId+1);
+ return (t_Handle)p_Scheme;
}
-t_Error FM_PCD_KgDeleteScheme(t_Handle h_FmPcd, t_Handle h_Scheme)
+t_Error FM_PCD_KgSchemeDelete(t_Handle h_Scheme)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_FmPcd *p_FmPcd;
uint8_t physicalSchemeId;
uint32_t tmpKgarReg, intFlags;
t_Error err = E_OK;
- uint8_t relativeSchemeId;
+ t_FmPcdKgScheme *p_Scheme = (t_FmPcdKgScheme *)h_Scheme;
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(h_Scheme, E_INVALID_HANDLE);
- if (p_FmPcd->h_Hc)
- return FmHcPcdKgDeleteScheme(p_FmPcd->h_Hc, h_Scheme);
+ p_FmPcd = (t_FmPcd*)(p_Scheme->h_FmPcd);
- physicalSchemeId = (uint8_t)(PTR_TO_UINT(h_Scheme)-1);
- relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmPcd, physicalSchemeId);
+ UpdateRequiredActionFlag(h_Scheme, FALSE);
- if(relativeSchemeId >= FM_PCD_KG_NUM_OF_SCHEMES)
- RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
+ /* check that no port is bound to this scheme */
+ err = InvalidateSchemeSw(h_Scheme);
+ if (err)
+ RETURN_ERROR(MINOR, err, NO_MSG);
- if ((err = FmPcdKgSchemeTryLock(p_FmPcd, relativeSchemeId, FALSE)) != E_OK)
- RETURN_ERROR(MINOR, err, NO_MSG);
+ if (p_FmPcd->h_Hc)
+ {
+ err = FmHcPcdKgDeleteScheme(p_FmPcd->h_Hc, h_Scheme);
+ if (p_Scheme->p_Lock)
+ FmPcdReleaseLock(p_FmPcd, p_Scheme->p_Lock);
+ return err;
+ }
- /* check that no port is bound to this scheme */
- err = FmPcdKgCheckInvalidateSchemeSw(h_FmPcd, relativeSchemeId);
- if(err)
- RETURN_ERROR(MINOR, err, NO_MSG);
+ physicalSchemeId = ((t_FmPcdKgScheme *)h_Scheme)->schemeId;
- intFlags = FmPcdLock(p_FmPcd);
+ intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
/* clear mode register, including enable bit */
- WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs.kgse_mode, 0);
+ WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_mode, 0);
/* call indirect command for scheme write */
tmpKgarReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, FALSE);
WriteKgarWait(p_FmPcd, tmpKgarReg);
- FmPcdUnlock(p_FmPcd, intFlags);
+ KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
- FmPcdKgInvalidateSchemeSw(h_FmPcd, relativeSchemeId);
-
- RELEASE_LOCK(p_FmPcd->p_FmPcdKg->schemes[relativeSchemeId].lock);
+ if (p_Scheme->p_Lock)
+ FmPcdReleaseLock(p_FmPcd, p_Scheme->p_Lock);
return E_OK;
}
-uint32_t FM_PCD_KgGetSchemeCounter(t_Handle h_FmPcd, t_Handle h_Scheme)
+uint32_t FM_PCD_KgSchemeGetCounter(t_Handle h_Scheme)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_FmPcd *p_FmPcd;
uint32_t tmpKgarReg, spc, intFlags;
uint8_t physicalSchemeId;
- SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, 0);
- SANITY_CHECK_RETURN_VALUE(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE, 0);
- SANITY_CHECK_RETURN_VALUE(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE, 0);
+ SANITY_CHECK_RETURN_VALUE(h_Scheme, E_INVALID_HANDLE, 0);
+ p_FmPcd = (t_FmPcd*)(((t_FmPcdKgScheme *)h_Scheme)->h_FmPcd);
if (p_FmPcd->h_Hc)
return FmHcPcdKgGetSchemeCounter(p_FmPcd->h_Hc, h_Scheme);
- physicalSchemeId = (uint8_t)(PTR_TO_UINT(h_Scheme)-1);
+ physicalSchemeId = ((t_FmPcdKgScheme *)h_Scheme)->schemeId;
- if(FmPcdKgGetRelativeSchemeId(p_FmPcd, physicalSchemeId) == FM_PCD_KG_NUM_OF_SCHEMES)
+ if (FmPcdKgGetRelativeSchemeId(p_FmPcd, physicalSchemeId) == FM_PCD_KG_NUM_OF_SCHEMES)
REPORT_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
tmpKgarReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
- intFlags = FmPcdLock(p_FmPcd);
+ intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
WriteKgarWait(p_FmPcd, tmpKgarReg);
- if (!(GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs.kgse_mode) & KG_SCH_MODE_EN))
+ if (!(GET_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_mode) & KG_SCH_MODE_EN))
REPORT_ERROR(MAJOR, E_ALREADY_EXISTS, ("Scheme is Invalid"));
- spc = GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs.kgse_spc);
- FmPcdUnlock(p_FmPcd, intFlags);
+ spc = GET_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_spc);
+ KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
return spc;
}
-t_Error FM_PCD_KgSetSchemeCounter(t_Handle h_FmPcd, t_Handle h_Scheme, uint32_t value)
+t_Error FM_PCD_KgSchemeSetCounter(t_Handle h_Scheme, uint32_t value)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_FmPcd *p_FmPcd;
uint32_t tmpKgarReg, intFlags;
uint8_t physicalSchemeId;
- SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, 0);
- SANITY_CHECK_RETURN_VALUE(p_FmPcd->p_FmPcdKg, E_INVALID_HANDLE, 0);
- SANITY_CHECK_RETURN_VALUE(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE, 0);
+ SANITY_CHECK_RETURN_VALUE(h_Scheme, E_INVALID_HANDLE, 0);
+
+ p_FmPcd = (t_FmPcd*)(((t_FmPcdKgScheme *)h_Scheme)->h_FmPcd);
+
+ if (!FmPcdKgIsSchemeValidSw(h_Scheme))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Requested scheme is invalid."));
if (p_FmPcd->h_Hc)
return FmHcPcdKgSetSchemeCounter(p_FmPcd->h_Hc, h_Scheme, value);
- physicalSchemeId = (uint8_t)(PTR_TO_UINT(h_Scheme)-1);
+ physicalSchemeId = ((t_FmPcdKgScheme *)h_Scheme)->schemeId;
/* check that schemeId is in range */
- if(FmPcdKgGetRelativeSchemeId(p_FmPcd, physicalSchemeId) == FM_PCD_KG_NUM_OF_SCHEMES)
+ if (FmPcdKgGetRelativeSchemeId(p_FmPcd, physicalSchemeId) == FM_PCD_KG_NUM_OF_SCHEMES)
REPORT_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
/* read specified scheme into scheme registers */
tmpKgarReg = FmPcdKgBuildReadSchemeActionReg(physicalSchemeId);
- intFlags = FmPcdLock(p_FmPcd);
+ intFlags = KgHwLock(p_FmPcd->p_FmPcdKg);
WriteKgarWait(p_FmPcd, tmpKgarReg);
- if (!(GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs.kgse_mode) & KG_SCH_MODE_EN))
+ if (!(GET_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_mode) & KG_SCH_MODE_EN))
{
- FmPcdUnlock(p_FmPcd, intFlags);
+ KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
RETURN_ERROR(MAJOR, E_ALREADY_EXISTS, ("Scheme is Invalid"));
}
/* change counter value */
- WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->indirectAccessRegs.schemeRegs.kgse_spc, value);
+ WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_IndirectAccessRegs->schemeRegs.kgse_spc, value);
/* call indirect command for scheme write */
tmpKgarReg = FmPcdKgBuildWriteSchemeActionReg(physicalSchemeId, TRUE);
WriteKgarWait(p_FmPcd, tmpKgarReg);
- FmPcdUnlock(p_FmPcd, intFlags);
+ KgHwUnlock(p_FmPcd->p_FmPcdKg, intFlags);
return E_OK;
}
+t_Error FM_PCD_KgSetAdditionalDataAfterParsing(t_Handle h_FmPcd, uint8_t payloadOffset)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ struct fman_kg_regs *p_Regs;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs, E_NULL_POINTER);
+
+ p_Regs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
+ if (!FmIsMaster(p_FmPcd->h_Fm))
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_KgSetAdditionalDataAfterParsing - guest mode!"));
+
+ WRITE_UINT32(p_Regs->fmkg_fdor,payloadOffset);
+
+ return E_OK;
+}
+
+t_Error FM_PCD_KgSetDfltValue(t_Handle h_FmPcd, uint8_t valueId, uint32_t value)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ struct fman_kg_regs *p_Regs;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(((valueId == 0) || (valueId == 1)), E_INVALID_VALUE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs, E_NULL_POINTER);
+
+ p_Regs = p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs;
+
+ if (!FmIsMaster(p_FmPcd->h_Fm))
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_KgSetDfltValue - guest mode!"));
+
+ if (valueId == 0)
+ WRITE_UINT32(p_Regs->fmkg_gdv0r,value);
+ else
+ WRITE_UINT32(p_Regs->fmkg_gdv1r,value);
+ return E_OK;
+}
diff --git a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_kg.h b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_kg.h
new file mode 100644
index 000000000000..cb7521a11397
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_kg.h
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/******************************************************************************
+ @File fm_kg.h
+
+ @Description FM KG private header
+*//***************************************************************************/
+#ifndef __FM_KG_H
+#define __FM_KG_H
+
+#include "std_ext.h"
+
+/***********************************************************************/
+/* Keygen defines */
+/***********************************************************************/
+/* maskes */
+#if (DPAA_VERSION >= 11)
+#define KG_SCH_VSP_SHIFT_MASK 0x0003f000
+#define KG_SCH_OM_VSPE 0x00000001
+#define KG_SCH_VSP_NO_KSP_EN 0x80000000
+
+#define MAX_SP_SHIFT 23
+#define KG_SCH_VSP_MASK_SHIFT 12
+#define KG_SCH_VSP_SHIFT 24
+#endif /* (DPAA_VERSION >= 11) */
+
+typedef uint32_t t_KnownFieldsMasks;
+#define KG_SCH_KN_PORT_ID 0x80000000
+#define KG_SCH_KN_MACDST 0x40000000
+#define KG_SCH_KN_MACSRC 0x20000000
+#define KG_SCH_KN_TCI1 0x10000000
+#define KG_SCH_KN_TCI2 0x08000000
+#define KG_SCH_KN_ETYPE 0x04000000
+#define KG_SCH_KN_PPPSID 0x02000000
+#define KG_SCH_KN_PPPID 0x01000000
+#define KG_SCH_KN_MPLS1 0x00800000
+#define KG_SCH_KN_MPLS2 0x00400000
+#define KG_SCH_KN_MPLS_LAST 0x00200000
+#define KG_SCH_KN_IPSRC1 0x00100000
+#define KG_SCH_KN_IPDST1 0x00080000
+#define KG_SCH_KN_PTYPE1 0x00040000
+#define KG_SCH_KN_IPTOS_TC1 0x00020000
+#define KG_SCH_KN_IPV6FL1 0x00010000
+#define KG_SCH_KN_IPSRC2 0x00008000
+#define KG_SCH_KN_IPDST2 0x00004000
+#define KG_SCH_KN_PTYPE2 0x00002000
+#define KG_SCH_KN_IPTOS_TC2 0x00001000
+#define KG_SCH_KN_IPV6FL2 0x00000800
+#define KG_SCH_KN_GREPTYPE 0x00000400
+#define KG_SCH_KN_IPSEC_SPI 0x00000200
+#define KG_SCH_KN_IPSEC_NH 0x00000100
+#define KG_SCH_KN_IPPID 0x00000080
+#define KG_SCH_KN_L4PSRC 0x00000004
+#define KG_SCH_KN_L4PDST 0x00000002
+#define KG_SCH_KN_TFLG 0x00000001
+
+typedef uint8_t t_GenericCodes;
+#define KG_SCH_GEN_SHIM1 0x70
+#define KG_SCH_GEN_DEFAULT 0x10
+#define KG_SCH_GEN_PARSE_RESULT_N_FQID 0x20
+#define KG_SCH_GEN_START_OF_FRM 0x40
+#define KG_SCH_GEN_SHIM2 0x71
+#define KG_SCH_GEN_IP_PID_NO_V 0x72
+#define KG_SCH_GEN_ETH 0x03
+#define KG_SCH_GEN_ETH_NO_V 0x73
+#define KG_SCH_GEN_SNAP 0x04
+#define KG_SCH_GEN_SNAP_NO_V 0x74
+#define KG_SCH_GEN_VLAN1 0x05
+#define KG_SCH_GEN_VLAN1_NO_V 0x75
+#define KG_SCH_GEN_VLAN2 0x06
+#define KG_SCH_GEN_VLAN2_NO_V 0x76
+#define KG_SCH_GEN_ETH_TYPE 0x07
+#define KG_SCH_GEN_ETH_TYPE_NO_V 0x77
+#define KG_SCH_GEN_PPP 0x08
+#define KG_SCH_GEN_PPP_NO_V 0x78
+#define KG_SCH_GEN_MPLS1 0x09
+#define KG_SCH_GEN_MPLS2 0x19
+#define KG_SCH_GEN_MPLS3 0x29
+#define KG_SCH_GEN_MPLS1_NO_V 0x79
+#define KG_SCH_GEN_MPLS_LAST 0x0a
+#define KG_SCH_GEN_MPLS_LAST_NO_V 0x7a
+#define KG_SCH_GEN_IPV4 0x0b
+#define KG_SCH_GEN_IPV6 0x1b
+#define KG_SCH_GEN_L3_NO_V 0x7b
+#define KG_SCH_GEN_IPV4_TUNNELED 0x0c
+#define KG_SCH_GEN_IPV6_TUNNELED 0x1c
+#define KG_SCH_GEN_MIN_ENCAP 0x2c
+#define KG_SCH_GEN_IP2_NO_V 0x7c
+#define KG_SCH_GEN_GRE 0x0d
+#define KG_SCH_GEN_GRE_NO_V 0x7d
+#define KG_SCH_GEN_TCP 0x0e
+#define KG_SCH_GEN_UDP 0x1e
+#define KG_SCH_GEN_IPSEC_AH 0x2e
+#define KG_SCH_GEN_SCTP 0x3e
+#define KG_SCH_GEN_DCCP 0x4e
+#define KG_SCH_GEN_IPSEC_ESP 0x6e
+#define KG_SCH_GEN_L4_NO_V 0x7e
+#define KG_SCH_GEN_NEXTHDR 0x7f
+/* shifts */
+#define KG_SCH_PP_SHIFT_HIGH_SHIFT 27
+#define KG_SCH_PP_SHIFT_LOW_SHIFT 12
+#define KG_SCH_PP_MASK_SHIFT 16
+#define KG_SCH_MODE_CCOBASE_SHIFT 24
+#define KG_SCH_DEF_MAC_ADDR_SHIFT 30
+#define KG_SCH_DEF_TCI_SHIFT 28
+#define KG_SCH_DEF_ENET_TYPE_SHIFT 26
+#define KG_SCH_DEF_PPP_SESSION_ID_SHIFT 24
+#define KG_SCH_DEF_PPP_PROTOCOL_ID_SHIFT 22
+#define KG_SCH_DEF_MPLS_LABEL_SHIFT 20
+#define KG_SCH_DEF_IP_ADDR_SHIFT 18
+#define KG_SCH_DEF_PROTOCOL_TYPE_SHIFT 16
+#define KG_SCH_DEF_IP_TOS_TC_SHIFT 14
+#define KG_SCH_DEF_IPV6_FLOW_LABEL_SHIFT 12
+#define KG_SCH_DEF_IPSEC_SPI_SHIFT 10
+#define KG_SCH_DEF_L4_PORT_SHIFT 8
+#define KG_SCH_DEF_TCP_FLAG_SHIFT 6
+#define KG_SCH_HASH_CONFIG_SHIFT_SHIFT 24
+#define KG_SCH_GEN_MASK_SHIFT 16
+#define KG_SCH_GEN_HT_SHIFT 8
+#define KG_SCH_GEN_SIZE_SHIFT 24
+#define KG_SCH_GEN_DEF_SHIFT 29
+#define FM_PCD_KG_KGAR_NUM_SHIFT 16
+
+/* others */
+#define NUM_OF_SW_DEFAULTS 3
+#define MAX_PP_SHIFT 23
+#define MAX_KG_SCH_SIZE 16
+#define MASK_FOR_GENERIC_BASE_ID 0x20
+#define MAX_HASH_SHIFT 40
+#define MAX_KG_SCH_FQID_BIT_OFFSET 31
+#define MAX_KG_SCH_PP_BIT_OFFSET 15
+#define MAX_DIST_FQID_SHIFT 23
+
+#define GET_MASK_SEL_SHIFT(shift,i) \
+switch (i) { \
+ case (0):shift = 26;break; \
+ case (1):shift = 20;break; \
+ case (2):shift = 10;break; \
+ case (3):shift = 4;break; \
+ default: \
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG); \
+}
+
+#define GET_MASK_OFFSET_SHIFT(shift,i) \
+switch (i) { \
+ case (0):shift = 16;break; \
+ case (1):shift = 0;break; \
+ case (2):shift = 28;break; \
+ case (3):shift = 24;break; \
+ default: \
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG); \
+}
+
+#define GET_MASK_SHIFT(shift,i) \
+switch (i) { \
+ case (0):shift = 24;break; \
+ case (1):shift = 16;break; \
+ case (2):shift = 8;break; \
+ case (3):shift = 0;break; \
+ default: \
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG); \
+}
+
+/***********************************************************************/
+/* Keygen defines */
+/***********************************************************************/
+
+#define KG_DOUBLE_MEANING_REGS_OFFSET 0x100
+#define NO_VALIDATION 0x70
+#define KG_ACTION_REG_TO 1024
+#define KG_MAX_PROFILE 255
+#define SCHEME_ALWAYS_DIRECT 0xFFFFFFFF
+
+
+#endif /* __FM_KG_H */
diff --git a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_manip.c b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_manip.c
index 0d176e88b48b..33e7ae807347 100644
--- a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_manip.c
+++ b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_manip.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,18 +30,18 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm_manip.c
@Description FM PCD manip ...
-*//***************************************************************************/
-#ifdef CONFIG_FMAN_P1023
-#ifdef FM_CAPWAP_SUPPORT
+ *//***************************************************************************/
#include "std_ext.h"
#include "error_ext.h"
#include "string_ext.h"
#include "debug_ext.h"
#include "fm_pcd_ext.h"
+#include "fm_port_ext.h"
#include "fm_muram_ext.h"
#include "memcpy_ext.h"
@@ -49,1472 +49,2971 @@
#include "fm_hc.h"
#include "fm_manip.h"
+/****************************************/
+/* static functions */
+/****************************************/
+static t_Handle GetManipInfo(t_FmPcdManip *p_Manip, e_ManipInfo manipInfo)
+{
+ t_FmPcdManip *p_CurManip = p_Manip;
-#ifdef CORE_8BIT_ACCESS_ERRATA
-#undef WRITE_UINT16
-#undef GET_UINT16
-#undef WRITE_UINT8
-#undef GET_UINT8
-
-#define WRITE_UINT16(addr, val) \
- do{ \
- if((int)&(addr) % 4) \
- WRITE_UINT32(*(uint32_t*)(uint32_t)((uint32_t)&addr & ~0x3L), \
- ((GET_UINT32(*(uint32_t*)(uint32_t)((uint32_t)&addr & ~0x3L)) & 0xffff0000) | (uint32_t)val)); \
- else \
- WRITE_UINT32(*(uint32_t*)&addr, \
- ((GET_UINT32(*(uint32_t*)&addr) & 0x0000ffff) | (uint32_t)val<<16)); \
- }while(0);
-#define GET_UINT16(addr) (((uint32_t)&addr%4) ? \
- ((uint16_t)GET_UINT32(*(uint32_t*)(uint32_t)((uint32_t)&addr & ~0x3L))): \
- ((uint16_t)(GET_UINT32(*(uint32_t*)(uint32_t)&addr) >> 16)))
-
-#define WRITE_UINT8(addr,val) WRITE_UINT8_ERRATA(&addr,val)
-#define GET_UINT8(addr) GET_UINT8_ERRATA(&addr)
-#endif /* CORE_8BIT_ACCESS_ERRATA */
-
-
-static void WRITE_UINT8_ERRATA(uint8_t *addr, uint8_t val)
-{
- uint32_t newAddr, newVal;
- newAddr = (uint32_t)addr & ~0x3L;
- switch ((uint32_t)addr%4)
- {
- case (0):
- newVal = GET_UINT32(*(uint32_t*)newAddr);
- newVal = (newVal & 0x00ffffff) | (((uint32_t)val)<<24);
- WRITE_UINT32(*(uint32_t*)newAddr, newVal);
- break;
- case (1):
- newVal = GET_UINT32(*(uint32_t*)newAddr);
- newVal = (newVal & 0xff00ffff) | (((uint32_t)val)<<16);
- WRITE_UINT32(*(uint32_t*)newAddr, newVal);
- break;
- case (2):
- newVal = GET_UINT32(*(uint32_t*)newAddr);
- newVal = (newVal & 0xffff00ff) | (((uint32_t)val)<<8);
- WRITE_UINT32(*(uint32_t*)newAddr, newVal);
- break;
- case (3):
- newVal = GET_UINT32(*(uint32_t*)newAddr);
- newVal = (newVal & 0xffffff00) | val;
- WRITE_UINT32(*(uint32_t*)newAddr, newVal);
- break;
+ if (!MANIP_IS_UNIFIED(p_Manip))
+ p_CurManip = p_Manip;
+ else
+ {
+ /* go to first unified */
+ while (MANIP_IS_UNIFIED_NON_FIRST(p_CurManip))
+ p_CurManip = p_CurManip->h_PrevManip;
+ }
+
+ switch (manipInfo)
+ {
+ case (e_MANIP_HMCT):
+ return p_CurManip->p_Hmct;
+ case (e_MANIP_HMTD):
+ return p_CurManip->h_Ad;
+ case (e_MANIP_HANDLER_TABLE_OWNER):
+ return (t_Handle)p_CurManip;
+ default:
+ return NULL;
}
}
-static uint8_t GET_UINT8_ERRATA(uint8_t *addr)
+static uint16_t GetHmctSize(t_FmPcdManip *p_Manip)
{
- uint32_t newAddr, newVal=0;
- newAddr = (uint32_t)addr & ~0x3L;
- switch ((uint32_t)addr%4)
+ uint16_t size = 0;
+ t_FmPcdManip *p_CurManip = p_Manip;
+
+ if (!MANIP_IS_UNIFIED(p_Manip))
+ return p_Manip->tableSize;
+
+ /* accumulate sizes, starting with the first node */
+ while (MANIP_IS_UNIFIED_NON_FIRST(p_CurManip))
+ p_CurManip = p_CurManip->h_PrevManip;
+
+ while (MANIP_IS_UNIFIED_NON_LAST(p_CurManip))
{
- case (0):
- newVal = GET_UINT32(*(uint32_t*)newAddr);
- newVal = (newVal & 0xff000000)>>24;
- break;
- case (1):
- newVal = GET_UINT32(*(uint32_t*)newAddr);
- newVal = (newVal & 0x00ff0000)>>16;
- break;
- case (2):
- newVal = GET_UINT32(*(uint32_t*)newAddr);
- newVal = (newVal & 0x0000ff00)>>8;
- break;
- case (3):
- newVal = GET_UINT32(*(uint32_t*)newAddr);
- newVal = (newVal & 0x000000ff);
- break;
+ size += p_CurManip->tableSize;
+ p_CurManip = (t_FmPcdManip *)p_CurManip->h_NextManip;
}
+ size += p_CurManip->tableSize; /* add last size */
- return (uint8_t)newVal;
+ return (size);
}
-static t_Error GetPrOffsetByNonHeader(uint8_t *parseArrayOffset)
+static uint16_t GetDataSize(t_FmPcdManip *p_Manip)
{
- /*For now - the only field in the Parse Array from the NON_BY_TYPE can be e_FM_PCD_KG_EXTRACT_FROM_CURR_END_OF_PARSE*/
- /*Maybe extended in the future*/
+ uint16_t size = 0;
+ t_FmPcdManip *p_CurManip = p_Manip;
+
+ if (!MANIP_IS_UNIFIED(p_Manip))
+ return p_Manip->dataSize;
+
+ /* accumulate sizes, starting with the first node */
+ while (MANIP_IS_UNIFIED_NON_FIRST(p_CurManip))
+ p_CurManip = p_CurManip->h_PrevManip;
+
+ while (MANIP_IS_UNIFIED_NON_LAST(p_CurManip))
+ {
+ size += p_CurManip->dataSize;
+ p_CurManip = (t_FmPcdManip *)p_CurManip->h_NextManip;
+ }
+ size += p_CurManip->dataSize; /* add last size */
+
+ return (size);
+}
+
+static t_Error CalculateTableSize(t_FmPcdManipParams *p_FmPcdManipParams,
+ uint16_t *p_TableSize, uint8_t *p_DataSize)
+{
+ uint8_t localDataSize, remain, tableSize = 0, dataSize = 0;
+
+ if (p_FmPcdManipParams->u.hdr.rmv)
+ {
+ switch (p_FmPcdManipParams->u.hdr.rmvParams.type)
+ {
+ case (e_FM_PCD_MANIP_RMV_GENERIC):
+ tableSize += HMCD_BASIC_SIZE;
+ break;
+ case (e_FM_PCD_MANIP_RMV_BY_HDR):
+ switch (p_FmPcdManipParams->u.hdr.rmvParams.u.byHdr.type)
+ {
+ case (e_FM_PCD_MANIP_RMV_BY_HDR_SPECIFIC_L2):
+#if (DPAA_VERSION >= 11)
+ case (e_FM_PCD_MANIP_RMV_BY_HDR_CAPWAP):
+ case (e_FM_PCD_MANIP_RMV_BY_HDR_FROM_START):
+#endif /* (DPAA_VERSION >= 11) */
+ tableSize += HMCD_BASIC_SIZE;
+ break;
+ default:
+ RETURN_ERROR(MINOR, E_INVALID_SELECTION,
+ ("Unknown byHdr.type"));
+ }
+ break;
+ default:
+ RETURN_ERROR(MINOR, E_INVALID_SELECTION,
+ ("Unknown rmvParams.type"));
+ }
+ }
+
+ if (p_FmPcdManipParams->u.hdr.insrt)
+ {
+ switch (p_FmPcdManipParams->u.hdr.insrtParams.type)
+ {
+ case (e_FM_PCD_MANIP_INSRT_GENERIC):
+ remain =
+ (uint8_t)(p_FmPcdManipParams->u.hdr.insrtParams.u.generic.size
+ % 4);
+ if (remain)
+ localDataSize =
+ (uint8_t)(p_FmPcdManipParams->u.hdr.insrtParams.u.generic.size
+ + 4 - remain);
+ else
+ localDataSize =
+ p_FmPcdManipParams->u.hdr.insrtParams.u.generic.size;
+ tableSize += (uint8_t)(HMCD_BASIC_SIZE + localDataSize);
+ break;
+ case (e_FM_PCD_MANIP_INSRT_BY_HDR):
+ {
+ switch (p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.type)
+ {
+
+ case (e_FM_PCD_MANIP_INSRT_BY_HDR_SPECIFIC_L2):
+ tableSize += HMCD_BASIC_SIZE + HMCD_PTR_SIZE;
+ switch (p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.specificL2Params.specificL2)
+ {
+ case (e_FM_PCD_MANIP_HDR_INSRT_MPLS):
+ case (e_FM_PCD_MANIP_HDR_INSRT_PPPOE):
+ dataSize +=
+ p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.specificL2Params.size;
+ break;
+ default:
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+ }
+ break;
+#if (DPAA_VERSION >= 11)
+ case (e_FM_PCD_MANIP_INSRT_BY_HDR_IP):
+ tableSize +=
+ (HMCD_BASIC_SIZE + HMCD_PTR_SIZE
+ + HMCD_PARAM_SIZE
+ + p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.insrt.size);
+ dataSize += 2;
+ break;
+
+ case (e_FM_PCD_MANIP_INSRT_BY_HDR_UDP):
+ case (e_FM_PCD_MANIP_INSRT_BY_HDR_UDP_LITE):
+ tableSize += (HMCD_BASIC_SIZE + HMCD_L4_HDR_SIZE);
+
+ break;
- *parseArrayOffset = CC_PC_PR_NEXT_HEADER_OFFSET;
+ case (e_FM_PCD_MANIP_INSRT_BY_HDR_CAPWAP):
+ tableSize +=
+ (HMCD_BASIC_SIZE
+ + p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.insrt.size);
+ break;
+#endif /* (DPAA_VERSION >= 11) */
+ default:
+ RETURN_ERROR(MINOR, E_INVALID_SELECTION,
+ ("Unknown byHdr.type"));
+ }
+ }
+ break;
+ default:
+ RETURN_ERROR(MINOR, E_INVALID_SELECTION,
+ ("Unknown insrtParams.type"));
+ }
+ }
+
+ if (p_FmPcdManipParams->u.hdr.fieldUpdate)
+ {
+ switch (p_FmPcdManipParams->u.hdr.fieldUpdateParams.type)
+ {
+ case (e_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN):
+ tableSize += HMCD_BASIC_SIZE;
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.vlan.updateType
+ == e_FM_PCD_MANIP_HDR_FIELD_UPDATE_DSCP_TO_VLAN)
+ {
+ tableSize += HMCD_PTR_SIZE;
+ dataSize += DSCP_TO_VLAN_TABLE_SIZE;
+ }
+ break;
+ case (e_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV4):
+ tableSize += HMCD_BASIC_SIZE;
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
+ & HDR_MANIP_IPV4_ID)
+ {
+ tableSize += HMCD_PARAM_SIZE;
+ dataSize += 2;
+ }
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
+ & HDR_MANIP_IPV4_SRC)
+ tableSize += HMCD_IPV4_ADDR_SIZE;
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
+ & HDR_MANIP_IPV4_DST)
+ tableSize += HMCD_IPV4_ADDR_SIZE;
+ break;
+ case (e_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV6):
+ tableSize += HMCD_BASIC_SIZE;
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
+ & HDR_MANIP_IPV6_SRC)
+ tableSize += HMCD_IPV6_ADDR_SIZE;
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
+ & HDR_MANIP_IPV6_DST)
+ tableSize += HMCD_IPV6_ADDR_SIZE;
+ break;
+ case (e_FM_PCD_MANIP_HDR_FIELD_UPDATE_TCP_UDP):
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.tcpUdp.validUpdates
+ == HDR_MANIP_TCP_UDP_CHECKSUM)
+ /* we implement this case with the update-checksum descriptor */
+ tableSize += HMCD_BASIC_SIZE;
+ else
+ /* we implement this case with the TCP/UDP-update descriptor */
+ tableSize += HMCD_BASIC_SIZE + HMCD_PARAM_SIZE;
+ break;
+ default:
+ RETURN_ERROR(MINOR, E_INVALID_SELECTION,
+ ("Unknown fieldUpdateParams.type"));
+ }
+ }
+
+ if (p_FmPcdManipParams->u.hdr.custom)
+ {
+ switch (p_FmPcdManipParams->u.hdr.customParams.type)
+ {
+ case (e_FM_PCD_MANIP_HDR_CUSTOM_IP_REPLACE):
+ {
+ tableSize += HMCD_BASIC_SIZE + HMCD_PARAM_SIZE + HMCD_PARAM_SIZE;
+ dataSize +=
+ p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.hdrSize;
+ if ((p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.replaceType
+ == e_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV6_BY_IPV4)
+ && (p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.updateIpv4Id))
+ dataSize += 2;
+ }
+ break;
+ case (e_FM_PCD_MANIP_HDR_CUSTOM_GEN_FIELD_REPLACE):
+ tableSize += HMCD_BASIC_SIZE + HMCD_PARAM_SIZE;
+ break;
+ default:
+ RETURN_ERROR(MINOR, E_INVALID_SELECTION,
+ ("Unknown customParams.type"));
+ }
+ }
+
+ *p_TableSize = tableSize;
+ *p_DataSize = dataSize;
return E_OK;
}
-static t_Error UpdateManipIc(t_Handle h_Manip, uint8_t icOffset)
+static t_Error GetPrOffsetByHeaderOrField(t_FmManipHdrInfo *p_HdrInfo,
+ uint8_t *parseArrayOffset)
{
- t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
- t_Handle p_Ad;
- uint32_t tmpReg32 = 0;
- SANITY_CHECK_RETURN_ERROR(h_Manip,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad, E_INVALID_HANDLE);
+ e_NetHeaderType hdr = p_HdrInfo->hdr;
+ e_FmPcdHdrIndex hdrIndex = p_HdrInfo->hdrIndex;
+ bool byField = p_HdrInfo->byField;
+ t_FmPcdFields field;
+
+ if (byField)
+ field = p_HdrInfo->fullField;
- switch(p_Manip->type)
+ if (byField)
+ {
+ switch (hdr)
+ {
+ case (HEADER_TYPE_ETH):
+ switch (field.eth)
+ {
+ case (NET_HEADER_FIELD_ETH_TYPE):
+ *parseArrayOffset = CC_PC_PR_ETYPE_LAST_OFFSET;
+ break;
+ default:
+ RETURN_ERROR(
+ MAJOR,
+ E_NOT_SUPPORTED,
+ ("Header manipulation of the type Ethernet with this field not supported"));
+ }
+ break;
+ case (HEADER_TYPE_VLAN):
+ switch (field.vlan)
+ {
+ case (NET_HEADER_FIELD_VLAN_TCI):
+ if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE)
+ || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
+ *parseArrayOffset = CC_PC_PR_VLAN1_OFFSET;
+ else
+ if (hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
+ *parseArrayOffset = CC_PC_PR_VLAN2_OFFSET;
+ break;
+ default:
+ RETURN_ERROR(
+ MAJOR,
+ E_NOT_SUPPORTED,
+ ("Header manipulation of the type VLAN with this field not supported"));
+ }
+ break;
+ default:
+ RETURN_ERROR(
+ MAJOR,
+ E_NOT_SUPPORTED,
+ ("Header manipulation of this header by field not supported"));
+ }
+ }
+ else
{
- case(HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
- p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
- if(p_Manip->updateParams & INTERNAL_CONTEXT_OFFSET)
+ switch (hdr)
+ {
+ case (HEADER_TYPE_ETH):
+ *parseArrayOffset = (uint8_t)CC_PC_PR_ETH_OFFSET;
+ break;
+ case (HEADER_TYPE_USER_DEFINED_SHIM1):
+ *parseArrayOffset = (uint8_t)CC_PC_PR_USER_DEFINED_SHIM1_OFFSET;
+ break;
+ case (HEADER_TYPE_USER_DEFINED_SHIM2):
+ *parseArrayOffset = (uint8_t)CC_PC_PR_USER_DEFINED_SHIM2_OFFSET;
+ break;
+ case (HEADER_TYPE_LLC_SNAP):
+ *parseArrayOffset = CC_PC_PR_USER_LLC_SNAP_OFFSET;
+ break;
+ case (HEADER_TYPE_PPPoE):
+ *parseArrayOffset = CC_PC_PR_PPPOE_OFFSET;
+ break;
+ case (HEADER_TYPE_MPLS):
+ if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE)
+ || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
+ *parseArrayOffset = CC_PC_PR_MPLS1_OFFSET;
+ else
+ if (hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
+ *parseArrayOffset = CC_PC_PR_MPLS_LAST_OFFSET;
+ break;
+ case (HEADER_TYPE_IPv4):
+ case (HEADER_TYPE_IPv6):
+ if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE)
+ || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
+ *parseArrayOffset = CC_PC_PR_IP1_OFFSET;
+ else
+ if (hdrIndex == e_FM_PCD_HDR_INDEX_2)
+ *parseArrayOffset = CC_PC_PR_IP_LAST_OFFSET;
+ break;
+ case (HEADER_TYPE_MINENCAP):
+ *parseArrayOffset = CC_PC_PR_MINENC_OFFSET;
+ break;
+ case (HEADER_TYPE_GRE):
+ *parseArrayOffset = CC_PC_PR_GRE_OFFSET;
+ break;
+ case (HEADER_TYPE_TCP):
+ case (HEADER_TYPE_UDP):
+ case (HEADER_TYPE_IPSEC_AH):
+ case (HEADER_TYPE_IPSEC_ESP):
+ case (HEADER_TYPE_DCCP):
+ case (HEADER_TYPE_SCTP):
+ *parseArrayOffset = CC_PC_PR_L4_OFFSET;
+ break;
+ case (HEADER_TYPE_CAPWAP):
+ case (HEADER_TYPE_CAPWAP_DTLS):
+ *parseArrayOffset = CC_PC_PR_NEXT_HEADER_OFFSET;
+ break;
+ default:
+ RETURN_ERROR(
+ MAJOR,
+ E_NOT_SUPPORTED,
+ ("Header manipulation of this header is not supported"));
+ }
+ }
+ return E_OK;
+}
+
+static t_Error BuildHmct(t_FmPcdManip *p_Manip,
+ t_FmPcdManipParams *p_FmPcdManipParams,
+ uint8_t *p_DestHmct, uint8_t *p_DestData, bool new)
+{
+ uint32_t *p_TmpHmct = (uint32_t*)p_DestHmct, *p_LocalData;
+ uint32_t tmpReg = 0, *p_Last = NULL, tmp_ipv6_addr;
+ uint8_t remain, i, size = 0, origSize, *p_UsrData = NULL, *p_TmpData =
+ p_DestData;
+ t_Handle h_FmPcd = p_Manip->h_FmPcd;
+ uint8_t j = 0;
+
+ if (p_FmPcdManipParams->u.hdr.rmv)
+ {
+ if (p_FmPcdManipParams->u.hdr.rmvParams.type
+ == e_FM_PCD_MANIP_RMV_GENERIC)
+ {
+ /* initialize HMCD */
+ tmpReg = (uint32_t)(HMCD_OPCODE_GENERIC_RMV) << HMCD_OC_SHIFT;
+ /* tmp, should be conditional */
+ tmpReg |= p_FmPcdManipParams->u.hdr.rmvParams.u.generic.offset
+ << HMCD_RMV_OFFSET_SHIFT;
+ tmpReg |= p_FmPcdManipParams->u.hdr.rmvParams.u.generic.size
+ << HMCD_RMV_SIZE_SHIFT;
+ }
+ else
+ if (p_FmPcdManipParams->u.hdr.rmvParams.type
+ == e_FM_PCD_MANIP_RMV_BY_HDR)
{
- tmpReg32 = *(uint32_t *)&((t_AdOfTypeContLookup *)p_Ad)->pcAndOffsets;
- tmpReg32 |= (uint32_t)((uint32_t)icOffset << 16);
- *(uint32_t *)&((t_AdOfTypeContLookup *)p_Ad)->pcAndOffsets = tmpReg32;
- p_Manip->updateParams &= ~INTERNAL_CONTEXT_OFFSET;
- p_Manip->icOffset = icOffset;
+ switch (p_FmPcdManipParams->u.hdr.rmvParams.u.byHdr.type)
+ {
+ case (e_FM_PCD_MANIP_RMV_BY_HDR_SPECIFIC_L2):
+ {
+ uint8_t hmcdOpt;
+
+ /* initialize HMCD */
+ tmpReg = (uint32_t)(HMCD_OPCODE_L2_RMV) << HMCD_OC_SHIFT;
+
+ switch (p_FmPcdManipParams->u.hdr.rmvParams.u.byHdr.u.specificL2)
+ {
+ case (e_FM_PCD_MANIP_HDR_RMV_ETHERNET):
+ hmcdOpt = HMCD_RMV_L2_ETHERNET;
+ break;
+ case (e_FM_PCD_MANIP_HDR_RMV_STACKED_QTAGS):
+ hmcdOpt = HMCD_RMV_L2_STACKED_QTAGS;
+ break;
+ case (e_FM_PCD_MANIP_HDR_RMV_ETHERNET_AND_MPLS):
+ hmcdOpt = HMCD_RMV_L2_ETHERNET_AND_MPLS;
+ break;
+ case (e_FM_PCD_MANIP_HDR_RMV_MPLS):
+ hmcdOpt = HMCD_RMV_L2_MPLS;
+ break;
+ case (e_FM_PCD_MANIP_HDR_RMV_PPPOE):
+ hmcdOpt = HMCD_RMV_L2_PPPOE;
+ break;
+ default:
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+ }
+ tmpReg |= hmcdOpt << HMCD_L2_MODE_SHIFT;
+ break;
+ }
+#if (DPAA_VERSION >= 11)
+ case (e_FM_PCD_MANIP_RMV_BY_HDR_CAPWAP):
+ tmpReg = (uint32_t)(HMCD_OPCODE_CAPWAP_RMV)
+ << HMCD_OC_SHIFT;
+ break;
+ case (e_FM_PCD_MANIP_RMV_BY_HDR_FROM_START):
+ {
+ uint8_t prsArrayOffset;
+ t_Error err = E_OK;
+
+ tmpReg = (uint32_t)(HMCD_OPCODE_RMV_TILL)
+ << HMCD_OC_SHIFT;
+
+ err =
+ GetPrOffsetByHeaderOrField(
+ &p_FmPcdManipParams->u.hdr.rmvParams.u.byHdr.u.hdrInfo,
+ &prsArrayOffset);
+ ASSERT_COND(!err);
+ /* was previously checked */
+
+ tmpReg |= ((uint32_t)prsArrayOffset << 16);
+ }
+ break;
+#endif /* (DPAA_VERSION >= 11) */
+ default:
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("manip header remove by hdr type!"));
+ }
}
+
+ WRITE_UINT32(*p_TmpHmct, tmpReg);
+ /* save a pointer to the "last" indication word */
+ p_Last = p_TmpHmct;
+ /* advance to next command */
+ p_TmpHmct += HMCD_BASIC_SIZE / 4;
+ }
+
+ if (p_FmPcdManipParams->u.hdr.insrt)
+ {
+ if (p_FmPcdManipParams->u.hdr.insrtParams.type
+ == e_FM_PCD_MANIP_INSRT_GENERIC)
+ {
+ /* initialize HMCD */
+ if (p_FmPcdManipParams->u.hdr.insrtParams.u.generic.replace)
+ tmpReg = (uint32_t)(HMCD_OPCODE_GENERIC_REPLACE)
+ << HMCD_OC_SHIFT;
else
+ tmpReg = (uint32_t)(HMCD_OPCODE_GENERIC_INSRT) << HMCD_OC_SHIFT;
+
+ tmpReg |= p_FmPcdManipParams->u.hdr.insrtParams.u.generic.offset
+ << HMCD_INSRT_OFFSET_SHIFT;
+ tmpReg |= p_FmPcdManipParams->u.hdr.insrtParams.u.generic.size
+ << HMCD_INSRT_SIZE_SHIFT;
+
+ size = p_FmPcdManipParams->u.hdr.insrtParams.u.generic.size;
+ p_UsrData = p_FmPcdManipParams->u.hdr.insrtParams.u.generic.p_Data;
+
+ WRITE_UINT32(*p_TmpHmct, tmpReg);
+ /* save a pointer to the "last" indication word */
+ p_Last = p_TmpHmct;
+
+ p_TmpHmct += HMCD_BASIC_SIZE / 4;
+
+ /* initialize data to be inserted */
+ /* if size is not a multiple of 4, padd with 0's */
+ origSize = size;
+ remain = (uint8_t)(size % 4);
+ if (remain)
{
- if(p_Manip->icOffset != icOffset)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("this manipulation was updated previousely by different value"););
+ size += (uint8_t)(4 - remain);
+ p_LocalData = (uint32_t *)XX_Malloc(size);
+ memset((uint8_t *)p_LocalData, 0, size);
+ memcpy((uint8_t *)p_LocalData, p_UsrData, origSize);
}
- break;
-#ifdef FM_CAPWAP_SUPPORT
- case(HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
- if(p_Manip->h_Frag)
+ else
+ p_LocalData = (uint32_t*)p_UsrData;
+
+ /* initialize data and advance pointer to next command */
+ MemCpy8(p_TmpHmct, p_LocalData, size);
+ p_TmpHmct += size / sizeof(uint32_t);
+
+ if (remain)
+ XX_Free(p_LocalData);
+ }
+
+ else
+ if (p_FmPcdManipParams->u.hdr.insrtParams.type
+ == e_FM_PCD_MANIP_INSRT_BY_HDR)
{
- if(p_Manip->updateParams & INTERNAL_CONTEXT_OFFSET)
+ switch (p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.type)
+ {
+ case (e_FM_PCD_MANIP_INSRT_BY_HDR_SPECIFIC_L2):
+ {
+ uint8_t hmcdOpt;
+
+ /* initialize HMCD */
+ tmpReg = (uint32_t)(HMCD_OPCODE_L2_INSRT)
+ << HMCD_OC_SHIFT;
+
+ switch (p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.specificL2Params.specificL2)
+ {
+ case (e_FM_PCD_MANIP_HDR_INSRT_MPLS):
+ if (p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.specificL2Params.update)
+ hmcdOpt = HMCD_INSRT_N_UPDATE_L2_MPLS;
+ else
+ hmcdOpt = HMCD_INSRT_L2_MPLS;
+ break;
+ case (e_FM_PCD_MANIP_HDR_INSRT_PPPOE):
+ hmcdOpt = HMCD_INSRT_L2_PPPOE;
+ break;
+ default:
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+ }
+ tmpReg |= hmcdOpt << HMCD_L2_MODE_SHIFT;
+
+ WRITE_UINT32(*p_TmpHmct, tmpReg);
+ /* save a pointer to the "last" indication word */
+ p_Last = p_TmpHmct;
+
+ p_TmpHmct += HMCD_BASIC_SIZE / 4;
+
+ /* set size and pointer of user's data */
+ size =
+ (uint8_t)p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.specificL2Params.size;
+
+ ASSERT_COND(p_TmpData);
+ MemCpy8(
+ p_TmpData,
+ p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.specificL2Params.p_Data,
+ size);
+ tmpReg =
+ (size << HMCD_INSRT_L2_SIZE_SHIFT)
+ | (uint32_t)(XX_VirtToPhys(p_TmpData)
+ - (((t_FmPcd*)h_FmPcd)->physicalMuramBase));
+ WRITE_UINT32(*p_TmpHmct, tmpReg);
+ p_TmpHmct += HMCD_PTR_SIZE / 4;
+ p_TmpData += size;
+ }
+ break;
+#if (DPAA_VERSION >= 11)
+ case (e_FM_PCD_MANIP_INSRT_BY_HDR_IP):
+ tmpReg = (uint32_t)(HMCD_OPCODE_IP_INSRT)
+ << HMCD_OC_SHIFT;
+ if (p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.calcL4Checksum)
+ tmpReg |= HMCD_IP_L4_CS_CALC;
+ if (p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.mappingMode
+ == e_FM_PCD_MANIP_HDR_QOS_MAPPING_AS_IS)
+ tmpReg |= HMCD_IP_OR_QOS;
+ tmpReg |=
+ p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.lastPidOffset
+ & HMCD_IP_LAST_PID_MASK;
+ tmpReg |=
+ ((p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.insrt.size
+ << HMCD_IP_SIZE_SHIFT)
+ & HMCD_IP_SIZE_MASK);
+ if (p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.dontFragOverwrite)
+ tmpReg |= HMCD_IP_DF_MODE;
+
+ WRITE_UINT32(*p_TmpHmct, tmpReg);
+
+ /* save a pointer to the "last" indication word */
+ p_Last = p_TmpHmct;
+
+ p_TmpHmct += HMCD_BASIC_SIZE / 4;
+
+ /* set IP id */
+ ASSERT_COND(p_TmpData);
+ WRITE_UINT16(
+ *(uint16_t*)p_TmpData,
+ p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.id);
+ WRITE_UINT32(
+ *p_TmpHmct,
+ (uint32_t)(XX_VirtToPhys(p_TmpData) - (((t_FmPcd*)p_Manip->h_FmPcd)->physicalMuramBase)));
+ p_TmpData += 2;
+ p_TmpHmct += HMCD_PTR_SIZE / 4;
+
+ WRITE_UINT8(*p_TmpHmct, p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.lastDstOffset);
+ p_TmpHmct += HMCD_PARAM_SIZE / 4;
+
+ MemCpy8(
+ p_TmpHmct,
+ p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.insrt.p_Data,
+ p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.insrt.size);
+ p_TmpHmct +=
+ p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.insrt.size
+ / 4;
+ break;
+ case (e_FM_PCD_MANIP_INSRT_BY_HDR_UDP_LITE):
+ tmpReg = HMCD_INSRT_UDP_LITE;
+ case (e_FM_PCD_MANIP_INSRT_BY_HDR_UDP):
+ tmpReg |= (uint32_t)(HMCD_OPCODE_UDP_INSRT)
+ << HMCD_OC_SHIFT;
+
+ WRITE_UINT32(*p_TmpHmct, tmpReg);
+
+ /* save a pointer to the "last" indication word */
+ p_Last = p_TmpHmct;
+
+ p_TmpHmct += HMCD_BASIC_SIZE / 4;
+
+ MemCpy8(
+ p_TmpHmct,
+ p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.insrt.p_Data,
+ p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.insrt.size);
+ p_TmpHmct +=
+ p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.insrt.size
+ / 4;
+ break;
+ case (e_FM_PCD_MANIP_INSRT_BY_HDR_CAPWAP):
+ tmpReg = (uint32_t)(HMCD_OPCODE_CAPWAP_INSRT)
+ << HMCD_OC_SHIFT;
+ tmpReg |= HMCD_CAPWAP_INSRT;
+
+ WRITE_UINT32(*p_TmpHmct, tmpReg);
+
+ /* save a pointer to the "last" indication word */
+ p_Last = p_TmpHmct;
+
+ p_TmpHmct += HMCD_BASIC_SIZE / 4;
+
+ MemCpy8(
+ p_TmpHmct,
+ p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.insrt.p_Data,
+ p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.insrt.size);
+ p_TmpHmct +=
+ p_FmPcdManipParams->u.hdr.insrtParams.u.byHdr.u.insrt.size
+ / 4;
+ break;
+#endif /* (DPAA_VERSION >= 11) */
+ default:
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("manip header insert by header type!"));
+
+ }
+ }
+ }
+
+ if (p_FmPcdManipParams->u.hdr.fieldUpdate)
+ {
+ switch (p_FmPcdManipParams->u.hdr.fieldUpdateParams.type)
+ {
+ case (e_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN):
+ /* set opcode */
+ tmpReg = (uint32_t)(HMCD_OPCODE_VLAN_PRI_UPDATE)
+ << HMCD_OC_SHIFT;
+
+ /* set mode & table pointer */
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.vlan.updateType
+ == e_FM_PCD_MANIP_HDR_FIELD_UPDATE_DSCP_TO_VLAN)
+ {
+ /* set Mode */
+ tmpReg |= (uint32_t)(HMCD_VLAN_PRI_UPDATE_DSCP_TO_VPRI)
+ << HMCD_VLAN_PRI_REP_MODE_SHIFT;
+ /* set VPRI default */
+ tmpReg |=
+ p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.vlan.u.dscpToVpri.vpriDefVal;
+ WRITE_UINT32(*p_TmpHmct, tmpReg);
+ /* save a pointer to the "last" indication word */
+ p_Last = p_TmpHmct;
+ /* write the table pointer into the Manip descriptor */
+ p_TmpHmct += HMCD_BASIC_SIZE / 4;
+
+ tmpReg = 0;
+ ASSERT_COND(p_TmpData);
+ for (i = 0; i < HMCD_DSCP_VALUES; i++)
+ {
+ /* first we build from each 8 values a 32bit register */
+ tmpReg |=
+ (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.vlan.u.dscpToVpri.dscpToVpriTable[i])
+ << (32 - 4 * (j + 1));
+ j++;
+ /* Than we write this register to the next table word
+ * (i=7-->word 0, i=15-->word 1,... i=63-->word 7) */
+ if ((i % 8) == 7)
+ {
+ WRITE_UINT32(*((uint32_t*)p_TmpData + (i+1)/8-1),
+ tmpReg);
+ tmpReg = 0;
+ j = 0;
+ }
+ }
+
+ WRITE_UINT32(
+ *p_TmpHmct,
+ (uint32_t)(XX_VirtToPhys(p_TmpData) - (((t_FmPcd*)h_FmPcd)->physicalMuramBase)));
+ p_TmpHmct += HMCD_PTR_SIZE / 4;
+
+ p_TmpData += DSCP_TO_VLAN_TABLE_SIZE;
+ }
+ else
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.vlan.updateType
+ == e_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN_VPRI)
+ {
+ /* set Mode */
+ /* line commented out as it has no-side-effect ('0' value). */
+ /*tmpReg |= HMCD_VLAN_PRI_UPDATE << HMCD_VLAN_PRI_REP_MODE_SHIFT*/;
+ /* set VPRI parameter */
+ tmpReg |=
+ p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.vlan.u.vpri;
+ WRITE_UINT32(*p_TmpHmct, tmpReg);
+ /* save a pointer to the "last" indication word */
+ p_Last = p_TmpHmct;
+ p_TmpHmct += HMCD_BASIC_SIZE / 4;
+ }
+ break;
+
+ case (e_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV4):
+ /* set opcode */
+ tmpReg = (uint32_t)(HMCD_OPCODE_IPV4_UPDATE) << HMCD_OC_SHIFT;
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
+ & HDR_MANIP_IPV4_TTL)
+ tmpReg |= HMCD_IPV4_UPDATE_TTL;
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
+ & HDR_MANIP_IPV4_TOS)
+ {
+ tmpReg |= HMCD_IPV4_UPDATE_TOS;
+ tmpReg |=
+ p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.tos
+ << HMCD_IPV4_UPDATE_TOS_SHIFT;
+ }
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
+ & HDR_MANIP_IPV4_ID)
+ tmpReg |= HMCD_IPV4_UPDATE_ID;
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
+ & HDR_MANIP_IPV4_SRC)
+ tmpReg |= HMCD_IPV4_UPDATE_SRC;
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
+ & HDR_MANIP_IPV4_DST)
+ tmpReg |= HMCD_IPV4_UPDATE_DST;
+ /* write the first 4 bytes of the descriptor */
+ WRITE_UINT32(*p_TmpHmct, tmpReg);
+ /* save a pointer to the "last" indication word */
+ p_Last = p_TmpHmct;
+
+ p_TmpHmct += HMCD_BASIC_SIZE / 4;
+
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
+ & HDR_MANIP_IPV4_ID)
+ {
+ ASSERT_COND(p_TmpData);
+ WRITE_UINT16(
+ *(uint16_t*)p_TmpData,
+ p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.id);
+ WRITE_UINT32(
+ *p_TmpHmct,
+ (uint32_t)(XX_VirtToPhys(p_TmpData) - (((t_FmPcd*)p_Manip->h_FmPcd)->physicalMuramBase)));
+ p_TmpData += 2;
+ p_TmpHmct += HMCD_PTR_SIZE / 4;
+ }
+
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
+ & HDR_MANIP_IPV4_SRC)
+ {
+ WRITE_UINT32(
+ *p_TmpHmct,
+ p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.src);
+ p_TmpHmct += HMCD_IPV4_ADDR_SIZE / 4;
+ }
+
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.validUpdates
+ & HDR_MANIP_IPV4_DST)
+ {
+ WRITE_UINT32(
+ *p_TmpHmct,
+ p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv4.dst);
+ p_TmpHmct += HMCD_IPV4_ADDR_SIZE / 4;
+ }
+ break;
+
+ case (e_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV6):
+ /* set opcode */
+ tmpReg = (uint32_t)(HMCD_OPCODE_IPV6_UPDATE) << HMCD_OC_SHIFT;
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv6.validUpdates
+ & HDR_MANIP_IPV6_HL)
+ tmpReg |= HMCD_IPV6_UPDATE_HL;
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv6.validUpdates
+ & HDR_MANIP_IPV6_TC)
+ {
+ tmpReg |= HMCD_IPV6_UPDATE_TC;
+ tmpReg |=
+ p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv6.trafficClass
+ << HMCD_IPV6_UPDATE_TC_SHIFT;
+ }
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv6.validUpdates
+ & HDR_MANIP_IPV6_SRC)
+ tmpReg |= HMCD_IPV6_UPDATE_SRC;
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv6.validUpdates
+ & HDR_MANIP_IPV6_DST)
+ tmpReg |= HMCD_IPV6_UPDATE_DST;
+ /* write the first 4 bytes of the descriptor */
+ WRITE_UINT32(*p_TmpHmct, tmpReg);
+ /* save a pointer to the "last" indication word */
+ p_Last = p_TmpHmct;
+
+ p_TmpHmct += HMCD_BASIC_SIZE / 4;
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv6.validUpdates
+ & HDR_MANIP_IPV6_SRC)
+ {
+ for (i = 0; i < NET_HEADER_FIELD_IPv6_ADDR_SIZE; i += 4)
+ {
+ memcpy(&tmp_ipv6_addr,
+ &p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv6.src[i],
+ sizeof(uint32_t));
+ WRITE_UINT32(*p_TmpHmct, tmp_ipv6_addr);
+ p_TmpHmct += HMCD_PTR_SIZE / 4;
+ }
+ }
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv6.validUpdates
+ & HDR_MANIP_IPV6_DST)
+ {
+ for (i = 0; i < NET_HEADER_FIELD_IPv6_ADDR_SIZE; i += 4)
+ {
+ memcpy(&tmp_ipv6_addr,
+ &p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.ipv6.dst[i],
+ sizeof(uint32_t));
+ WRITE_UINT32(*p_TmpHmct, tmp_ipv6_addr);
+ p_TmpHmct += HMCD_PTR_SIZE / 4;
+ }
+ }
+ break;
+
+ case (e_FM_PCD_MANIP_HDR_FIELD_UPDATE_TCP_UDP):
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.tcpUdp.validUpdates
+ == HDR_MANIP_TCP_UDP_CHECKSUM)
{
- p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
- tmpReg32 |= GET_UINT32(((t_AdOfTypeContLookup *)p_Ad)->pcAndOffsets);
- tmpReg32 |= (uint32_t)((uint32_t)icOffset << 16);
- WRITE_UINT32(((t_AdOfTypeContLookup *)p_Ad)->pcAndOffsets, tmpReg32);
- p_Manip->updateParams &= ~INTERNAL_CONTEXT_OFFSET;
- p_Manip->icOffset = icOffset;
+ /* we implement this case with the update-checksum descriptor */
+ /* set opcode */
+ tmpReg = (uint32_t)(HMCD_OPCODE_TCP_UDP_CHECKSUM)
+ << HMCD_OC_SHIFT;
+ /* write the first 4 bytes of the descriptor */
+ WRITE_UINT32(*p_TmpHmct, tmpReg);
+ /* save a pointer to the "last" indication word */
+ p_Last = p_TmpHmct;
+
+ p_TmpHmct += HMCD_BASIC_SIZE / 4;
}
else
{
- if(p_Manip->icOffset != icOffset)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("this manipulation was updated previousely by different value"););
+ /* we implement this case with the TCP/UDP update descriptor */
+ /* set opcode */
+ tmpReg = (uint32_t)(HMCD_OPCODE_TCP_UDP_UPDATE)
+ << HMCD_OC_SHIFT;
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.tcpUdp.validUpdates
+ & HDR_MANIP_TCP_UDP_DST)
+ tmpReg |= HMCD_TCP_UDP_UPDATE_DST;
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.tcpUdp.validUpdates
+ & HDR_MANIP_TCP_UDP_SRC)
+ tmpReg |= HMCD_TCP_UDP_UPDATE_SRC;
+ /* write the first 4 bytes of the descriptor */
+ WRITE_UINT32(*p_TmpHmct, tmpReg);
+ /* save a pointer to the "last" indication word */
+ p_Last = p_TmpHmct;
+
+ p_TmpHmct += HMCD_BASIC_SIZE / 4;
+
+ tmpReg = 0;
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.tcpUdp.validUpdates
+ & HDR_MANIP_TCP_UDP_SRC)
+ tmpReg |=
+ ((uint32_t)p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.tcpUdp.src)
+ << HMCD_TCP_UDP_UPDATE_SRC_SHIFT;
+ if (p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.tcpUdp.validUpdates
+ & HDR_MANIP_TCP_UDP_DST)
+ tmpReg |=
+ ((uint32_t)p_FmPcdManipParams->u.hdr.fieldUpdateParams.u.tcpUdp.dst);
+ WRITE_UINT32(*p_TmpHmct, tmpReg);
+ p_TmpHmct += HMCD_PTR_SIZE / 4;
}
+ break;
+
+ default:
+ RETURN_ERROR(MINOR, E_INVALID_SELECTION,
+ ("Unknown fieldUpdateParams.type"));
+ }
+ }
+
+ if (p_FmPcdManipParams->u.hdr.custom)
+ {
+ switch (p_FmPcdManipParams->u.hdr.customParams.type)
+ {
+ case (e_FM_PCD_MANIP_HDR_CUSTOM_IP_REPLACE):
+ /* set opcode */
+ tmpReg = (uint32_t)(HMCD_OPCODE_REPLACE_IP) << HMCD_OC_SHIFT;
+
+ if (p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.decTtlHl)
+ tmpReg |= HMCD_IP_REPLACE_TTL_HL;
+ if (p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.replaceType
+ == e_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV4_BY_IPV6)
+ /* line commented out as it has no-side-effect ('0' value). */
+ /*tmpReg |= HMCD_IP_REPLACE_REPLACE_IPV4*/;
+ else
+ if (p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.replaceType
+ == e_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV6_BY_IPV4)
+ {
+ tmpReg |= HMCD_IP_REPLACE_REPLACE_IPV6;
+ if (p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.updateIpv4Id)
+ tmpReg |= HMCD_IP_REPLACE_ID;
+ }
+ else
+ RETURN_ERROR(
+ MINOR,
+ E_NOT_SUPPORTED,
+ ("One flag out of HDR_MANIP_IP_REPLACE_IPV4, HDR_MANIP_IP_REPLACE_IPV6 - must be set."));
+
+ /* write the first 4 bytes of the descriptor */
+ WRITE_UINT32(*p_TmpHmct, tmpReg);
+ /* save a pointer to the "last" indication word */
+ p_Last = p_TmpHmct;
+
+ p_TmpHmct += HMCD_BASIC_SIZE / 4;
+
+ size =
+ p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.hdrSize;
+ ASSERT_COND(p_TmpData);
+ MemCpy8(
+ p_TmpData,
+ p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.hdr,
+ size);
+ tmpReg = (uint32_t)(size << HMCD_IP_REPLACE_L3HDRSIZE_SHIFT);
+ tmpReg |= (uint32_t)(XX_VirtToPhys(p_TmpData)
+ - (((t_FmPcd*)h_FmPcd)->physicalMuramBase));
+ WRITE_UINT32(*p_TmpHmct, tmpReg);
+ p_TmpHmct += HMCD_PTR_SIZE / 4;
+ p_TmpData += size;
+
+ if ((p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.replaceType
+ == e_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV6_BY_IPV4)
+ && (p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.updateIpv4Id))
+ {
+ WRITE_UINT16(
+ *(uint16_t*)p_TmpData,
+ p_FmPcdManipParams->u.hdr.customParams.u.ipHdrReplace.id);
+ WRITE_UINT32(
+ *p_TmpHmct,
+ (uint32_t)(XX_VirtToPhys(p_TmpData) - (((t_FmPcd*)h_FmPcd)->physicalMuramBase)));
+ p_TmpData += 2;
+ }
+ p_TmpHmct += HMCD_PTR_SIZE / 4;
+ break;
+ case (e_FM_PCD_MANIP_HDR_CUSTOM_GEN_FIELD_REPLACE):
+ /* set opcode */
+ tmpReg = (uint32_t)(HMCD_OPCODE_GEN_FIELD_REPLACE) << HMCD_OC_SHIFT;
+ tmpReg |= p_FmPcdManipParams->u.hdr.customParams.u.genFieldReplace.size << HMCD_GEN_FIELD_SIZE_SHIFT;
+ tmpReg |= p_FmPcdManipParams->u.hdr.customParams.u.genFieldReplace.srcOffset << HMCD_GEN_FIELD_SRC_OFF_SHIFT;
+ tmpReg |= p_FmPcdManipParams->u.hdr.customParams.u.genFieldReplace.dstOffset << HMCD_GEN_FIELD_DST_OFF_SHIFT;
+ if (p_FmPcdManipParams->u.hdr.customParams.u.genFieldReplace.mask)
+ tmpReg |= HMCD_GEN_FIELD_MASK_EN;
+
+ /* write the first 4 bytes of the descriptor */
+ WRITE_UINT32(*p_TmpHmct, tmpReg);
+ /* save a pointer to the "last" indication word */
+ p_Last = p_TmpHmct;
+
+ p_TmpHmct += HMCD_BASIC_SIZE/4;
+
+ if (p_FmPcdManipParams->u.hdr.customParams.u.genFieldReplace.mask)
+ {
+ tmpReg = p_FmPcdManipParams->u.hdr.customParams.u.genFieldReplace.mask << HMCD_GEN_FIELD_MASK_SHIFT;
+ tmpReg |= p_FmPcdManipParams->u.hdr.customParams.u.genFieldReplace.maskOffset << HMCD_GEN_FIELD_MASK_OFF_SHIFT;
+ /* write the next 4 bytes of the descriptor */
+ WRITE_UINT32(*p_TmpHmct, tmpReg);
+ }
+ p_TmpHmct += HMCD_PARAM_SIZE/4;
+ break;
+ default:
+ RETURN_ERROR(MINOR, E_INVALID_SELECTION,
+ ("Unknown customParams.type"));
+ }
+ }
+
+ /* If this node has a nextManip, and no parsing is required, the old table must be copied to the new table
+ the old table and should be freed */
+ if (p_FmPcdManipParams->h_NextManip
+ && (p_Manip->nextManipType == e_FM_PCD_MANIP_HDR)
+ && (MANIP_DONT_REPARSE(p_Manip)))
+ {
+ if (new)
+ {
+ /* If this is the first time this manip is created we need to free unused memory. If it
+ * is a dynamic changes case, the memory used is either the CC shadow or the existing
+ * table - no allocation, no free */
+ MANIP_UPDATE_UNIFIED_POSITION(p_FmPcdManipParams->h_NextManip);
+
+ p_Manip->unifiedPosition = e_MANIP_UNIFIED_FIRST;
+ }
+ }
+ else
+ {
+ ASSERT_COND(p_Last);
+ /* set the "last" indication on the last command of the current table */
+ WRITE_UINT32(*p_Last, GET_UINT32(*p_Last) | HMCD_LAST);
+ }
+
+ return E_OK;
+}
+
+static t_Error CreateManipActionNew(t_FmPcdManip *p_Manip,
+ t_FmPcdManipParams *p_FmPcdManipParams)
+{
+ t_FmPcdManip *p_CurManip;
+ t_Error err;
+ uint32_t nextSize = 0, totalSize;
+ uint16_t tmpReg;
+ uint8_t *p_OldHmct, *p_TmpHmctPtr, *p_TmpDataPtr;
+
+ /* set Manip structure */
+
+ p_Manip->dontParseAfterManip =
+ p_FmPcdManipParams->u.hdr.dontParseAfterManip;
+
+ if (p_FmPcdManipParams->h_NextManip)
+ { /* Next Header manipulation exists */
+ p_Manip->nextManipType = MANIP_GET_TYPE(p_FmPcdManipParams->h_NextManip);
+
+ if ((p_Manip->nextManipType == e_FM_PCD_MANIP_HDR) && p_Manip->dontParseAfterManip)
+ nextSize = (uint32_t)(GetHmctSize(p_FmPcdManipParams->h_NextManip)
+ + GetDataSize(p_FmPcdManipParams->h_NextManip));
+ else /* either parsing is required or next manip is Frag; no table merging. */
+ p_Manip->cascaded = TRUE;
+ /* pass up the "cascaded" attribute. The whole chain is cascaded
+ * if something is cascaded along the way. */
+ if (MANIP_IS_CASCADED(p_FmPcdManipParams->h_NextManip))
+ p_Manip->cascaded = TRUE;
+ }
+
+ /* Allocate new table */
+ /* calculate table size according to manip parameters */
+ err = CalculateTableSize(p_FmPcdManipParams, &p_Manip->tableSize,
+ &p_Manip->dataSize);
+ if (err)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ totalSize = (uint16_t)(p_Manip->tableSize + p_Manip->dataSize + nextSize);
+
+ p_Manip->p_Hmct = (uint8_t*)FM_MURAM_AllocMem(
+ ((t_FmPcd *)p_Manip->h_FmPcd)->h_FmMuram, totalSize, 4);
+ if (!p_Manip->p_Hmct)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc failed"));
+
+ if (p_Manip->dataSize)
+ p_Manip->p_Data =
+ (uint8_t*)PTR_MOVE(p_Manip->p_Hmct, (p_Manip->tableSize + nextSize));
+
+ /* update shadow size to allow runtime replacement of Header manipulation */
+ /* The allocated shadow is divided as follows:
+ 0 . . . 16 . . .
+ --------------------------------
+ | Shadow | Shadow HMTD |
+ | HMTD | Match Table |
+ | (16 bytes) | (maximal size) |
+ --------------------------------
+ */
+
+ err = FmPcdUpdateCcShadow(p_Manip->h_FmPcd, (uint32_t)(totalSize + 16),
+ (uint16_t)FM_PCD_CC_AD_TABLE_ALIGN);
+ if (err != E_OK)
+ {
+ FM_MURAM_FreeMem(p_Manip->h_FmPcd, p_Manip->p_Hmct);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("MURAM allocation for HdrManip node shadow"));
+ }
+
+ if (p_FmPcdManipParams->h_NextManip
+ && (p_Manip->nextManipType == e_FM_PCD_MANIP_HDR)
+ && (MANIP_DONT_REPARSE(p_Manip)))
+ {
+ p_OldHmct = (uint8_t *)GetManipInfo(p_FmPcdManipParams->h_NextManip,
+ e_MANIP_HMCT);
+ p_CurManip = p_FmPcdManipParams->h_NextManip;
+ /* Run till the last Manip (which is the first to configure) */
+ while (MANIP_IS_UNIFIED_NON_LAST(p_CurManip))
+ p_CurManip = p_CurManip->h_NextManip;
+
+ while (p_CurManip)
+ {
+ /* If this is a unified table, point to the part of the table
+ * which is the relative offset in HMCT.
+ */
+ p_TmpHmctPtr = (uint8_t*)PTR_MOVE(p_Manip->p_Hmct,
+ (p_Manip->tableSize +
+ (PTR_TO_UINT(p_CurManip->p_Hmct) -
+ PTR_TO_UINT(p_OldHmct))));
+ if (p_CurManip->p_Data)
+ p_TmpDataPtr = (uint8_t*)PTR_MOVE(p_Manip->p_Hmct,
+ (p_Manip->tableSize +
+ (PTR_TO_UINT(p_CurManip->p_Data) -
+ PTR_TO_UINT(p_OldHmct))));
+ else
+ p_TmpDataPtr = NULL;
+
+ BuildHmct(p_CurManip, &p_CurManip->manipParams, p_TmpHmctPtr,
+ p_TmpDataPtr, FALSE);
+ /* update old manip table pointer */
+ MANIP_SET_HMCT_PTR(p_CurManip, p_TmpHmctPtr);
+ MANIP_SET_DATA_PTR(p_CurManip, p_TmpDataPtr);
+
+ p_CurManip = p_CurManip->h_PrevManip;
+ }
+ /* We copied the HMCT to create a new large HMCT so we can free the old one */
+ FM_MURAM_FreeMem(MANIP_GET_MURAM(p_FmPcdManipParams->h_NextManip),
+ p_OldHmct);
+ }
+
+ /* Fill table */
+ err = BuildHmct(p_Manip, p_FmPcdManipParams, p_Manip->p_Hmct,
+ p_Manip->p_Data, TRUE);
+ if (err)
+ {
+ FM_MURAM_FreeMem(p_Manip->h_FmPcd, p_Manip->p_Hmct);
+ RETURN_ERROR(MINOR, err, NO_MSG);
+ }
+
+ /* Build HMTD (table descriptor) */
+ tmpReg = HMTD_CFG_TYPE; /* NADEN = 0 */
+
+ /* add parseAfterManip */
+ if (!p_Manip->dontParseAfterManip)
+ tmpReg |= HMTD_CFG_PRS_AFTER_HM;
+
+ /* create cascade */
+ /*if (p_FmPcdManipParams->h_NextManip
+ && (!MANIP_DONT_REPARSE(p_Manip) || (p_Manip->nextManipType != e_FM_PCD_MANIP_HDR)))*/
+ if (p_Manip->cascaded)
+ {
+ uint16_t nextAd;
+ /* indicate that there's another HM table descriptor */
+ tmpReg |= HMTD_CFG_NEXT_AD_EN;
+ /* get address of next HMTD (table descriptor; h_Ad).
+ * If the next HMTD was removed due to table unifing, get the address
+ * of the "next next" as written in the h_Ad of the next h_Manip node.
+ */
+ if (p_Manip->unifiedPosition != e_MANIP_UNIFIED_FIRST)
+ nextAd = (uint16_t)((uint32_t)(XX_VirtToPhys(MANIP_GET_HMTD_PTR(p_FmPcdManipParams->h_NextManip)) - (((t_FmPcd*)p_Manip->h_FmPcd)->physicalMuramBase)) >> 4);
+ else
+ nextAd = ((t_Hmtd *)((t_FmPcdManip *)p_FmPcdManipParams->h_NextManip)->h_Ad)->nextAdIdx;
+
+ WRITE_UINT16(((t_Hmtd *)p_Manip->h_Ad)->nextAdIdx, nextAd);
+ }
+
+ WRITE_UINT16(((t_Hmtd *)p_Manip->h_Ad)->cfg, tmpReg);
+ WRITE_UINT32(
+ ((t_Hmtd *)p_Manip->h_Ad)->hmcdBasePtr,
+ (uint32_t)(XX_VirtToPhys(p_Manip->p_Hmct) - (((t_FmPcd*)p_Manip->h_FmPcd)->physicalMuramBase)));
+
+ WRITE_UINT8(((t_Hmtd *)p_Manip->h_Ad)->opCode, HMAN_OC);
+
+ if (p_Manip->unifiedPosition == e_MANIP_UNIFIED_FIRST)
+ {
+ /* The HMTD of the next Manip is never going to be used */
+ if (((t_FmPcdManip *)p_FmPcdManipParams->h_NextManip)->muramAllocate)
+ FM_MURAM_FreeMem(
+ ((t_FmPcd *)((t_FmPcdManip *)p_FmPcdManipParams->h_NextManip)->h_FmPcd)->h_FmMuram,
+ ((t_FmPcdManip *)p_FmPcdManipParams->h_NextManip)->h_Ad);
+ else
+ XX_Free(((t_FmPcdManip *)p_FmPcdManipParams->h_NextManip)->h_Ad);
+ ((t_FmPcdManip *)p_FmPcdManipParams->h_NextManip)->h_Ad = NULL;
+ }
+
+ return E_OK;
+}
+
+static t_Error CreateManipActionShadow(t_FmPcdManip *p_Manip,
+ t_FmPcdManipParams *p_FmPcdManipParams)
+{
+ uint8_t *p_WholeHmct, *p_TmpHmctPtr, newDataSize, *p_TmpDataPtr = NULL;
+ uint16_t newSize;
+ t_FmPcd *p_FmPcd = (t_FmPcd *)p_Manip->h_FmPcd;
+ t_Error err;
+ t_FmPcdManip *p_CurManip = p_Manip;
+
+ err = CalculateTableSize(p_FmPcdManipParams, &newSize, &newDataSize);
+ if (err)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ /* check coherency of new table parameters */
+ if (newSize > p_Manip->tableSize)
+ RETURN_ERROR(
+ MINOR,
+ E_INVALID_VALUE,
+ ("New Hdr Manip configuration requires larger size than current one (command table)."));
+ if (newDataSize > p_Manip->dataSize)
+ RETURN_ERROR(
+ MINOR,
+ E_INVALID_VALUE,
+ ("New Hdr Manip configuration requires larger size than current one (data)."));
+ if (p_FmPcdManipParams->h_NextManip)
+ RETURN_ERROR(
+ MINOR, E_INVALID_VALUE,
+ ("New Hdr Manip configuration can not contain h_NextManip."));
+ if (MANIP_IS_UNIFIED(p_Manip) && (newSize != p_Manip->tableSize))
+ RETURN_ERROR(
+ MINOR,
+ E_INVALID_VALUE,
+ ("New Hdr Manip configuration in a chained manipulation requires different size than current one."));
+ if (p_Manip->dontParseAfterManip
+ != p_FmPcdManipParams->u.hdr.dontParseAfterManip)
+ RETURN_ERROR(
+ MINOR,
+ E_INVALID_VALUE,
+ ("New Hdr Manip configuration differs in dontParseAfterManip value."));
+
+ p_Manip->tableSize = newSize;
+ p_Manip->dataSize = newDataSize;
+
+ /* Build the new table in the shadow */
+ if (!MANIP_IS_UNIFIED(p_Manip))
+ {
+ p_TmpHmctPtr = (uint8_t*)PTR_MOVE(p_FmPcd->p_CcShadow, 16);
+ if (p_Manip->p_Data)
+ p_TmpDataPtr =
+ (uint8_t*)PTR_MOVE(p_TmpHmctPtr,
+ (PTR_TO_UINT(p_Manip->p_Data) - PTR_TO_UINT(p_Manip->p_Hmct)));
+
+ BuildHmct(p_Manip, p_FmPcdManipParams, p_TmpHmctPtr, p_Manip->p_Data,
+ FALSE);
+ }
+ else
+ {
+ p_WholeHmct = (uint8_t *)GetManipInfo(p_Manip, e_MANIP_HMCT);
+ ASSERT_COND(p_WholeHmct);
+
+ /* Run till the last Manip (which is the first to configure) */
+ while (MANIP_IS_UNIFIED_NON_LAST(p_CurManip))
+ p_CurManip = p_CurManip->h_NextManip;
+
+ while (p_CurManip)
+ {
+ /* If this is a non-head node in a unified table, point to the part of the shadow
+ * which is the relative offset in HMCT.
+ * else, point to the beginning of the
+ * shadow table (we save 16 for the HMTD.
+ */
+ p_TmpHmctPtr =
+ (uint8_t*)PTR_MOVE(p_FmPcd->p_CcShadow,
+ (16 + PTR_TO_UINT(p_CurManip->p_Hmct) - PTR_TO_UINT(p_WholeHmct)));
+ if (p_CurManip->p_Data)
+ p_TmpDataPtr =
+ (uint8_t*)PTR_MOVE(p_FmPcd->p_CcShadow,
+ (16 + PTR_TO_UINT(p_CurManip->p_Data) - PTR_TO_UINT(p_WholeHmct)));
+
+ BuildHmct(p_CurManip, &p_CurManip->manipParams, p_TmpHmctPtr,
+ p_TmpDataPtr, FALSE);
+ p_CurManip = p_CurManip->h_PrevManip;
+ }
+ }
+
+ return E_OK;
+}
+
+static t_Error CreateManipActionBackToOrig(
+ t_FmPcdManip *p_Manip, t_FmPcdManipParams *p_FmPcdManipParams)
+{
+ uint8_t *p_WholeHmct = NULL, *p_TmpHmctPtr, *p_TmpDataPtr;
+ t_FmPcdManip *p_CurManip = p_Manip;
+
+ /* Build the new table in the shadow */
+ if (!MANIP_IS_UNIFIED(p_Manip))
+ BuildHmct(p_Manip, p_FmPcdManipParams, p_Manip->p_Hmct, p_Manip->p_Data,
+ FALSE);
+ else
+ {
+ p_WholeHmct = (uint8_t *)GetManipInfo(p_Manip, e_MANIP_HMCT);
+ ASSERT_COND(p_WholeHmct);
+
+ /* Run till the last Manip (which is the first to configure) */
+ while (MANIP_IS_UNIFIED_NON_LAST(p_CurManip))
+ p_CurManip = p_CurManip->h_NextManip;
+
+ while (p_CurManip)
+ {
+ /* If this is a unified table, point to the part of the table
+ * which is the relative offset in HMCT.
+ */
+ p_TmpHmctPtr = p_CurManip->p_Hmct; /*- (uint32_t)p_WholeHmct*/
+ p_TmpDataPtr = p_CurManip->p_Data; /*- (uint32_t)p_WholeHmct*/
+
+ BuildHmct(p_CurManip, &p_CurManip->manipParams, p_TmpHmctPtr,
+ p_TmpDataPtr, FALSE);
+
+ p_CurManip = p_CurManip->h_PrevManip;
+ }
+ }
+
+ return E_OK;
+}
+
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
+static t_Error UpdateManipIc(t_Handle h_Manip, uint8_t icOffset)
+{
+ t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
+ t_Handle p_Ad;
+ uint32_t tmpReg32 = 0;
+ SANITY_CHECK_RETURN_ERROR(h_Manip, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad, E_INVALID_HANDLE);
+
+ switch (p_Manip->opcode)
+ {
+ case (HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
+ p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
+ if (p_Manip->updateParams & INTERNAL_CONTEXT_OFFSET)
+ {
+ tmpReg32 =
+ *(uint32_t *)&((t_AdOfTypeContLookup *)p_Ad)->pcAndOffsets;
+ tmpReg32 |= (uint32_t)((uint32_t)icOffset << 16);
+ *(uint32_t *)&((t_AdOfTypeContLookup *)p_Ad)->pcAndOffsets =
+ tmpReg32;
+ p_Manip->updateParams &= ~INTERNAL_CONTEXT_OFFSET;
+ p_Manip->icOffset = icOffset;
+ }
+ else
+ {
+ if (p_Manip->icOffset != icOffset)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("this manipulation was updated previously by different value"););
+ }
+ break;
+ case (HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
+ if (p_Manip->h_Frag)
+ {
+ if (p_Manip->updateParams & INTERNAL_CONTEXT_OFFSET)
+ {
+ p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
+ tmpReg32 |= GET_UINT32(((t_AdOfTypeContLookup *)p_Ad)->pcAndOffsets);
+ tmpReg32 |= (uint32_t)((uint32_t)icOffset << 16);
+ WRITE_UINT32(((t_AdOfTypeContLookup *)p_Ad)->pcAndOffsets, tmpReg32);
+ p_Manip->updateParams &= ~INTERNAL_CONTEXT_OFFSET;
+ p_Manip->icOffset = icOffset;
}
- break;
-#endif /* FM_CAPWAP_SUPPORT */
+ else
+ {
+ if (p_Manip->icOffset != icOffset)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("this manipulation was updated previousely by different value"););
+ }
+ }
+ break;
}
return E_OK;
}
-static t_Error UpdateInitMvIntFrameHeaderFromFrameToBufferPrefix(t_Handle h_FmPort, t_FmPcdManip *p_Manip, t_Handle h_Ad, bool validate)
+static t_Error UpdateInitMvIntFrameHeaderFromFrameToBufferPrefix(
+ t_Handle h_FmPort, t_FmPcdManip *p_Manip, t_Handle h_Ad, bool validate)
{
- t_AdOfTypeContLookup *p_Ad = (t_AdOfTypeContLookup *)h_Ad;
- t_FmPortGetSetCcParams fmPortGetSetCcParams;
- t_Error err;
- uint32_t tmpReg32;
+ t_AdOfTypeContLookup *p_Ad = (t_AdOfTypeContLookup *)h_Ad;
+ t_FmPortGetSetCcParams fmPortGetSetCcParams;
+ t_Error err;
+ uint32_t tmpReg32;
memset(&fmPortGetSetCcParams, 0, sizeof(t_FmPortGetSetCcParams));
- SANITY_CHECK_RETURN_ERROR(p_Manip,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR((p_Manip->type & HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX), E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_Manip, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(
+ (p_Manip->opcode & HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX),
+ E_INVALID_STATE);
SANITY_CHECK_RETURN_ERROR(!p_Manip->muramAllocate, E_INVALID_STATE);
- if(p_Manip->updateParams)
+ if (p_Manip->updateParams)
{
- if((!(p_Manip->updateParams & OFFSET_OF_PR)) ||
- (p_Manip->shadowUpdateParams & OFFSET_OF_PR))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has not be updated"));
+ if ((!(p_Manip->updateParams & OFFSET_OF_PR))
+ || (p_Manip->shadowUpdateParams & OFFSET_OF_PR))
+ RETURN_ERROR(
+ MAJOR, E_INVALID_STATE,
+ ("in this stage parameters from Port has not be updated"));
fmPortGetSetCcParams.getCcParams.type = p_Manip->updateParams;
fmPortGetSetCcParams.setCcParams.type = UPDATE_PSO;
fmPortGetSetCcParams.setCcParams.psoSize = 16;
err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
- if(fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_PR)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Parser result offset wasn't configured previousely"));
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ if (fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_PR)
+ RETURN_ERROR(
+ MAJOR, E_INVALID_STATE,
+ ("Parser result offset wasn't configured previousely"));
#ifdef FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004
ASSERT_COND(!(fmPortGetSetCcParams.getCcParams.prOffset % 16));
#endif
}
- else if (validate)
+ else
+ if (validate)
{
- if((!(p_Manip->shadowUpdateParams & OFFSET_OF_PR)) ||
- (p_Manip->updateParams & OFFSET_OF_PR))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has be updated"));
+ if ((!(p_Manip->shadowUpdateParams & OFFSET_OF_PR))
+ || (p_Manip->updateParams & OFFSET_OF_PR))
+ RETURN_ERROR(
+ MAJOR, E_INVALID_STATE,
+ ("in this stage parameters from Port has be updated"));
fmPortGetSetCcParams.getCcParams.type = p_Manip->shadowUpdateParams;
fmPortGetSetCcParams.setCcParams.type = UPDATE_PSO;
fmPortGetSetCcParams.setCcParams.psoSize = 16;
err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
- if(fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_PR)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Parser result offset wasn't configured previousely"));
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ if (fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_PR)
+ RETURN_ERROR(
+ MAJOR, E_INVALID_STATE,
+ ("Parser result offset wasn't configured previousely"));
}
- if(p_Manip->updateParams & OFFSET_OF_PR)
- {
+ ASSERT_COND(p_Ad);
+
+ if (p_Manip->updateParams & OFFSET_OF_PR)
+ {
tmpReg32 = 0;
tmpReg32 |= fmPortGetSetCcParams.getCcParams.prOffset;
- WRITE_UINT32(p_Ad->matchTblPtr, (GET_UINT32(p_Ad->matchTblPtr) | tmpReg32));
+ WRITE_UINT32(p_Ad->matchTblPtr,
+ (GET_UINT32(p_Ad->matchTblPtr) | tmpReg32));
p_Manip->updateParams &= ~OFFSET_OF_PR;
p_Manip->shadowUpdateParams |= OFFSET_OF_PR;
- }
- else if (validate)
- {
+ }
+ else
+ if (validate)
+ {
tmpReg32 = GET_UINT32(p_Ad->matchTblPtr);
- if((uint8_t)tmpReg32 != fmPortGetSetCcParams.getCcParams.prOffset)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("this manipulation was updated previousely by different value"););
- }
+ if ((uint8_t)tmpReg32 != fmPortGetSetCcParams.getCcParams.prOffset)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("this manipulation was updated previousely by different value"););
+ }
return E_OK;
}
-#ifdef FM_CAPWAP_SUPPORT
static t_Error UpdateModifyCapwapFragmenation(t_FmPcdManip *p_Manip, t_Handle h_Ad, bool validate,t_Handle h_FmTree)
{
- t_AdOfTypeContLookup *p_Ad = (t_AdOfTypeContLookup *)h_Ad;
- t_FmPcdCcSavedManipParams *p_SavedManipParams = NULL;
- uint32_t tmpReg32 = 0;
+ t_AdOfTypeContLookup *p_Ad = (t_AdOfTypeContLookup *)h_Ad;
+ t_FmPcdCcSavedManipParams *p_SavedManipParams = NULL;
+ uint32_t tmpReg32 = 0;
SANITY_CHECK_RETURN_ERROR(p_Manip,E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Manip->h_Frag,E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Manip->frag,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(((p_Manip->type == HMAN_OC_CAPWAP_FRAGMENTATION) || (p_Manip->type == HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER)), E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(((p_Manip->opcode == HMAN_OC_CAPWAP_FRAGMENTATION) || (p_Manip->opcode == HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER)), E_INVALID_STATE);
- p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Frag;
+ p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Frag;
- if(p_Manip->updateParams)
+ if (p_Manip->updateParams)
{
- if((!(p_Manip->updateParams & OFFSET_OF_DATA) &&
- !(p_Manip->updateParams & BUFFER_POOL_ID_FOR_MANIP)) ||
- ((p_Manip->shadowUpdateParams & OFFSET_OF_DATA) || (p_Manip->shadowUpdateParams & BUFFER_POOL_ID_FOR_MANIP)))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has not be updated"));
- p_SavedManipParams = FmPcdCcTreeGetSavedManipParams(h_FmTree, e_FM_MANIP_CAPWAP_INDX);
- if(!p_SavedManipParams)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("for this manipulation tree has to be configured previosely with this type"));
- p_Manip->fragParams.poolId = p_SavedManipParams->capwapParams.poolId;
- p_Manip->fragParams.dataOffset = p_SavedManipParams->capwapParams.dataOffset;
+ if ((!(p_Manip->updateParams & OFFSET_OF_DATA)) ||
+ ((p_Manip->shadowUpdateParams & OFFSET_OF_DATA)))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has not be updated"));
+ p_SavedManipParams = FmPcdCcTreeGetSavedManipParams(h_FmTree);
+ if (!p_SavedManipParams)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("for this manipulation tree has to be configured previosely with this type"));
+ p_Manip->capwapFragParams.dataOffset = p_SavedManipParams->capwapParams.dataOffset;
tmpReg32 = GET_UINT32(p_Ad->pcAndOffsets);
- tmpReg32 |= ((uint32_t)p_Manip->fragParams.poolId << 8);
- tmpReg32 |= ((uint32_t)p_Manip->fragParams.dataOffset<< 16);
+ tmpReg32 |= ((uint32_t)p_Manip->capwapFragParams.dataOffset<< 16);
WRITE_UINT32(p_Ad->pcAndOffsets,tmpReg32);
p_Manip->updateParams &= ~OFFSET_OF_DATA;
- p_Manip->updateParams &= ~BUFFER_POOL_ID_FOR_MANIP;
- p_Manip->shadowUpdateParams |= (OFFSET_OF_DATA | BUFFER_POOL_ID_FOR_MANIP);
+ p_Manip->shadowUpdateParams |= OFFSET_OF_DATA;
}
- else if (validate)
- {
+ else if (validate)
+ {
- p_SavedManipParams = FmPcdCcTreeGetSavedManipParams(h_FmTree, e_FM_MANIP_CAPWAP_INDX);
- if(!p_SavedManipParams)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("for this manipulation tree has to be configured previosely with this type"));
- if((p_Manip->fragParams.poolId != p_SavedManipParams->capwapParams.poolId) ||
- (p_Manip->fragParams.dataOffset != p_SavedManipParams->capwapParams.dataOffset))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("this manipulation was updated previousely by different value"));
- }
+ p_SavedManipParams = FmPcdCcTreeGetSavedManipParams(h_FmTree);
+ if (!p_SavedManipParams)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("for this manipulation tree has to be configured previosely with this type"));
+ if (p_Manip->capwapFragParams.dataOffset != p_SavedManipParams->capwapParams.dataOffset)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("this manipulation was updated previousely by different value"));
+ }
return E_OK;
}
-static t_Error UpdateInitCapwapFragmentation(t_Handle h_FmPort, t_FmPcdManip *p_Manip, t_Handle h_Ad, bool validate, t_Handle h_FmTree)
+static t_Error UpdateInitCapwapFragmentation(t_Handle h_FmPort,
+ t_FmPcdManip *p_Manip,
+ t_Handle h_Ad,
+ bool validate,
+ t_Handle h_FmTree)
{
- t_AdOfTypeContLookup *p_Ad;
- t_FmPortGetSetCcParams fmPortGetSetCcParams;
- t_Error err;
- uint32_t tmpReg32 = 0;
- t_FmPcdCcSavedManipParams *p_SavedManipParams;
+ t_AdOfTypeContLookup *p_Ad;
+ t_FmPortGetSetCcParams fmPortGetSetCcParams;
+ t_Error err;
+ uint32_t tmpReg32 = 0;
+ t_FmPcdCcSavedManipParams *p_SavedManipParams;
UNUSED(h_Ad);
SANITY_CHECK_RETURN_ERROR(p_Manip,E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Manip->h_Frag,E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Manip->frag,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(((p_Manip->type == HMAN_OC_CAPWAP_FRAGMENTATION) || (p_Manip->type == HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER)), E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(((p_Manip->opcode == HMAN_OC_CAPWAP_FRAGMENTATION) ||
+ (p_Manip->opcode == HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER)), E_INVALID_STATE);
- p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Frag;
+ p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Frag;
- if(p_Manip->updateParams)
+ if (p_Manip->updateParams)
{
- if((!(p_Manip->updateParams & OFFSET_OF_DATA) &&
- !(p_Manip->updateParams & BUFFER_POOL_ID_FOR_MANIP)) ||
- ((p_Manip->shadowUpdateParams & OFFSET_OF_DATA) || (p_Manip->shadowUpdateParams & BUFFER_POOL_ID_FOR_MANIP)))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has not be updated"));
+ if ((!(p_Manip->updateParams & OFFSET_OF_DATA)) ||
+ ((p_Manip->shadowUpdateParams & OFFSET_OF_DATA)))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has not be updated"));
fmPortGetSetCcParams.getCcParams.type = p_Manip->updateParams;
fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNEN | UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY;
- fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_FRAG | NIA_ENG_FM_CTL;
- fmPortGetSetCcParams.getCcParams.poolIndex = p_Manip->fragParams.poolIndx;
+ fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_POP_TO_N_STEP | NIA_ENG_FM_CTL;
+ /* For CAPWAP Rassembly used FMAN_CTRL2 hardcoded - so for fragmentation its better to use FMAN_CTRL1 */
+ fmPortGetSetCcParams.setCcParams.orFmanCtrl = FPM_PORT_FM_CTL1;
+
err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
- if(fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_DATA)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Data offset wasn't configured previousely"));
- if(fmPortGetSetCcParams.getCcParams.type & BUFFER_POOL_ID_FOR_MANIP)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Buffer pool doe header manipulation wasn't configured previousely"));
+ if (fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_DATA)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Data offset wasn't configured previousely"));
p_SavedManipParams = (t_FmPcdCcSavedManipParams *)XX_Malloc(sizeof(t_FmPcdCcSavedManipParams));
p_SavedManipParams->capwapParams.dataOffset = fmPortGetSetCcParams.getCcParams.dataOffset;
- p_SavedManipParams->capwapParams.poolId = fmPortGetSetCcParams.getCcParams.poolIdForManip;
#ifdef FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004
ASSERT_COND(!(p_SavedManipParams->capwapParams.dataOffset % 16));
-#endif
+#endif /* FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004 */
- FmPcdCcTreeSetSavedManipParams(h_FmTree, (t_Handle)p_SavedManipParams, e_FM_MANIP_CAPWAP_INDX);
+ FmPcdCcTreeSetSavedManipParams(h_FmTree, (t_Handle)p_SavedManipParams);
}
else if (validate)
{
- if ((!(p_Manip->shadowUpdateParams & OFFSET_OF_DATA) &&
- !(p_Manip->shadowUpdateParams & BUFFER_POOL_ID_FOR_MANIP)) ||
- ((p_Manip->updateParams & OFFSET_OF_DATA) ||
- (p_Manip->updateParams & BUFFER_POOL_ID_FOR_MANIP)))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has be updated"));
+ if ((!(p_Manip->shadowUpdateParams & OFFSET_OF_DATA)) ||
+ ((p_Manip->updateParams & OFFSET_OF_DATA)))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has be updated"));
fmPortGetSetCcParams.getCcParams.type = p_Manip->shadowUpdateParams;
- fmPortGetSetCcParams.getCcParams.poolIndex = p_Manip->fragParams.poolIndx;
fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNEN | UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY;
- fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_FRAG | NIA_ENG_FM_CTL;
+ fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_POP_TO_N_STEP | NIA_ENG_FM_CTL;
err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
- if(fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_DATA)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Data offset wasn't configured previousely"));
- if(fmPortGetSetCcParams.getCcParams.type & BUFFER_POOL_ID_FOR_MANIP)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Buffer pool doe header manipulation wasn't configured previousely"));
+ if (fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_DATA)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Data offset wasn't configured previousely"));
}
- if(p_Manip->updateParams)
+ if (p_Manip->updateParams)
{
tmpReg32 = GET_UINT32(p_Ad->pcAndOffsets);
- tmpReg32 |= ((uint32_t)fmPortGetSetCcParams.getCcParams.poolIdForManip << 8);
tmpReg32 |= ((uint32_t)fmPortGetSetCcParams.getCcParams.dataOffset<< 16);
WRITE_UINT32(p_Ad->pcAndOffsets,tmpReg32);
p_Manip->updateParams &= ~OFFSET_OF_DATA;
- p_Manip->updateParams &= ~BUFFER_POOL_ID_FOR_MANIP;
- p_Manip->shadowUpdateParams |= (OFFSET_OF_DATA | BUFFER_POOL_ID_FOR_MANIP);
- p_Manip->fragParams.poolId = fmPortGetSetCcParams.getCcParams.poolIdForManip;
- p_Manip->fragParams.dataOffset = fmPortGetSetCcParams.getCcParams.dataOffset;
+ p_Manip->shadowUpdateParams |= OFFSET_OF_DATA;
+ p_Manip->capwapFragParams.dataOffset = fmPortGetSetCcParams.getCcParams.dataOffset;
}
else if (validate)
{
- if((p_Manip->fragParams.poolId != fmPortGetSetCcParams.getCcParams.poolIdForManip) ||
- (p_Manip->fragParams.dataOffset != fmPortGetSetCcParams.getCcParams.dataOffset))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("this manipulation was updated previousely by different value"));
+ if (p_Manip->capwapFragParams.dataOffset != fmPortGetSetCcParams.getCcParams.dataOffset)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("this manipulation was updated previousely by different value"));
}
return E_OK;
}
-static t_Error UpdateInitCapwapReasm(t_Handle h_FmPcd,
- t_Handle h_FmPort,
- t_FmPcdManip *p_Manip,
- t_Handle h_Ad,
- bool validate)
+static t_Error UpdateInitCapwapReasm(t_Handle h_FmPcd,
+ t_Handle h_FmPort,
+ t_FmPcdManip *p_Manip,
+ t_Handle h_Ad,
+ bool validate)
{
- t_CapwapReasmPram *p_ReassmTbl;
- t_Error err;
- t_FmPortGetSetCcParams fmPortGetSetCcParams;
- uint8_t i = 0;
- uint16_t size;
- uint32_t tmpReg32;
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ t_CapwapReasmPram *p_ReassmTbl;
+ t_Error err;
+ t_FmPortGetSetCcParams fmPortGetSetCcParams;
+ uint8_t i = 0;
+ uint16_t size;
+ uint32_t tmpReg32;
+ t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
t_FmPcdCcCapwapReassmTimeoutParams ccCapwapReassmTimeoutParams;
SANITY_CHECK_RETURN_ERROR(p_Manip,E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Manip->h_Frag,E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Manip->frag,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR((p_Manip->type == HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST), E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR((p_Manip->opcode == HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST), E_INVALID_STATE);
SANITY_CHECK_RETURN_ERROR(h_FmPcd,E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc,E_INVALID_HANDLE);
- if(p_Manip->h_FmPcd != h_FmPcd)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("handler of PCD previously was initiated by different value"));
+ if (p_Manip->h_FmPcd != h_FmPcd)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("handler of PCD previously was initiated by different value"));
UNUSED(h_Ad);
memset(&fmPortGetSetCcParams, 0, sizeof(t_FmPortGetSetCcParams));
- p_ReassmTbl = (t_CapwapReasmPram *)p_Manip->h_Frag;
+ p_ReassmTbl = (t_CapwapReasmPram *)p_Manip->h_Frag;
- if(p_Manip->updateParams)
+ if (p_Manip->updateParams)
{
- if((!(p_Manip->updateParams & NUM_OF_TASKS) && !(p_Manip->updateParams & BUFFER_POOL_ID_FOR_MANIP) &&
- !(p_Manip->updateParams & OFFSET_OF_DATA) && !(p_Manip->updateParams & OFFSET_OF_PR) &&
- !(p_Manip->updateParams & HW_PORT_ID)) ||
- ((p_Manip->shadowUpdateParams & NUM_OF_TASKS) || (p_Manip->shadowUpdateParams & BUFFER_POOL_ID_FOR_MANIP) ||
- (p_Manip->shadowUpdateParams & OFFSET_OF_DATA) || (p_Manip->shadowUpdateParams & OFFSET_OF_PR)
- ||(p_Manip->shadowUpdateParams & HW_PORT_ID)))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has not be updated"));
+ if ((!(p_Manip->updateParams & NUM_OF_TASKS) &&
+ !(p_Manip->updateParams & OFFSET_OF_DATA) &&
+ !(p_Manip->updateParams & OFFSET_OF_PR) &&
+ !(p_Manip->updateParams & HW_PORT_ID)) ||
+ ((p_Manip->shadowUpdateParams & NUM_OF_TASKS) ||
+ (p_Manip->shadowUpdateParams & OFFSET_OF_DATA) || (p_Manip->shadowUpdateParams & OFFSET_OF_PR) ||
+ (p_Manip->shadowUpdateParams & HW_PORT_ID)))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has not be updated"));
fmPortGetSetCcParams.getCcParams.type = p_Manip->updateParams;
- fmPortGetSetCcParams.getCcParams.poolIndex = p_Manip->fragParams.poolIndx;
fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNEN;
- fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_FRAG | NIA_ENG_FM_CTL;
+ fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_POP_TO_N_STEP | NIA_ENG_FM_CTL;
+
err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
- if(fmPortGetSetCcParams.getCcParams.type & NUM_OF_TASKS)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Num of tasks wasn't configured previousely"));
- if(fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_DATA)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("offset of the data wasn't configured previousely"));
- if(fmPortGetSetCcParams.getCcParams.type & BUFFER_POOL_ID_FOR_MANIP)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("buffser pool id wasn't configured previousely"));
- if(fmPortGetSetCcParams.getCcParams.type & HW_PORT_ID)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("hwPortId wasn't updated"));
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ if (fmPortGetSetCcParams.getCcParams.type & NUM_OF_TASKS)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Num of tasks wasn't configured previousely"));
+ if (fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_DATA)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("offset of the data wasn't configured previousely"));
+ if (fmPortGetSetCcParams.getCcParams.type & HW_PORT_ID)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("hwPortId wasn't updated"));
#ifdef FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004
ASSERT_COND((fmPortGetSetCcParams.getCcParams.dataOffset % 16) == 0);
-#endif
+#endif /* FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004 */
}
else if (validate)
{
- if((!(p_Manip->shadowUpdateParams & NUM_OF_TASKS) && (!(p_Manip->shadowUpdateParams & BUFFER_POOL_ID_FOR_MANIP)) &&
- (!(p_Manip->shadowUpdateParams & OFFSET_OF_DATA)) && (!(p_Manip->shadowUpdateParams & OFFSET_OF_PR)) &&
- (!(p_Manip->shadowUpdateParams & HW_PORT_ID))) &&
- ((p_Manip->updateParams & NUM_OF_TASKS) ||
- (p_Manip->updateParams & BUFFER_POOL_ID_FOR_MANIP) ||
- (p_Manip->updateParams & OFFSET_OF_DATA) || (p_Manip->updateParams & OFFSET_OF_PR)||
- (p_Manip->updateParams & HW_PORT_ID)))
+ if ((!(p_Manip->shadowUpdateParams & NUM_OF_TASKS) &&
+ !(p_Manip->shadowUpdateParams & OFFSET_OF_DATA) &&
+ !(p_Manip->shadowUpdateParams & OFFSET_OF_PR) &&
+ !(p_Manip->shadowUpdateParams & HW_PORT_ID)) &&
+ ((p_Manip->updateParams & NUM_OF_TASKS) ||
+ (p_Manip->updateParams & OFFSET_OF_DATA) || (p_Manip->updateParams & OFFSET_OF_PR) ||
+ (p_Manip->updateParams & HW_PORT_ID)))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has be updated"));
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has be updated"));
fmPortGetSetCcParams.getCcParams.type = p_Manip->shadowUpdateParams;
- fmPortGetSetCcParams.getCcParams.poolIndex = p_Manip->fragParams.poolIndx;
fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNEN;
- fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_FRAG | NIA_ENG_FM_CTL;
+ fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_POP_TO_N_STEP | NIA_ENG_FM_CTL;
+
err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
- if(fmPortGetSetCcParams.getCcParams.type & NUM_OF_TASKS)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("NumOfTasks wasn't configured previousely"));
- if(fmPortGetSetCcParams.getCcParams.type & BUFFER_POOL_ID_FOR_MANIP)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Buffer pool for header manipulation wasn't configured previousely"));
- if(fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_DATA)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("offset of the data wasn't configured previousely"));
- if(fmPortGetSetCcParams.getCcParams.type & HW_PORT_ID)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("hwPortId wasn't updated"));
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ if (fmPortGetSetCcParams.getCcParams.type & NUM_OF_TASKS)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("NumOfTasks wasn't configured previously"));
+ if (fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_DATA)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("offset of the data wasn't configured previously"));
+ if (fmPortGetSetCcParams.getCcParams.type & HW_PORT_ID)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("hwPortId wasn't updated"));
}
- if(p_Manip->updateParams)
+ if (p_Manip->updateParams)
{
- if(p_Manip->updateParams & NUM_OF_TASKS)
+ if (p_Manip->updateParams & NUM_OF_TASKS)
{
- size = (uint16_t)(p_Manip->fragParams.maxNumFramesInProcess + fmPortGetSetCcParams.getCcParams.numOfTasks);
- if(size > 255)
- RETURN_ERROR(MAJOR,E_INVALID_VALUE, ("numOfOpenReassmEntries + numOfTasks per port can not be greater than 256"));
+ /*recommendation of Microcode team - (maxNumFramesInProcess * 2) */
+ size = (uint16_t)(p_Manip->capwapFragParams.maxNumFramesInProcess*2 + fmPortGetSetCcParams.getCcParams.numOfTasks);
+ if (size > 255)
+ RETURN_ERROR(MAJOR,E_INVALID_VALUE, ("numOfOpenReassmEntries + numOfTasks per port can not be greater than 256"));
- p_Manip->fragParams.numOfTasks = fmPortGetSetCcParams.getCcParams.numOfTasks;
+ p_Manip->capwapFragParams.numOfTasks = fmPortGetSetCcParams.getCcParams.numOfTasks;
/*p_ReassmFrmDescrIndxPoolTbl*/
- p_Manip->fragParams.p_ReassmFrmDescrIndxPoolTbl = (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
- (uint32_t)(size + 1),
- 4);
- if(!p_Manip->fragParams.p_ReassmFrmDescrIndxPoolTbl)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
+ p_Manip->capwapFragParams.p_ReassmFrmDescrIndxPoolTbl =
+ (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
+ (uint32_t)(size + 1),
+ 4);
+ if (!p_Manip->capwapFragParams.p_ReassmFrmDescrIndxPoolTbl)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for CAPWAP Reassembly frame buffer index pool table"));
- IOMemSet32(p_Manip->fragParams.p_ReassmFrmDescrIndxPoolTbl, 0, (uint32_t)(size + 1));
+ MemSet8(p_Manip->capwapFragParams.p_ReassmFrmDescrIndxPoolTbl, 0, (uint32_t)(size + 1));
- for( i = 0; i < size; i++)
- WRITE_UINT8(*(uint8_t *)PTR_MOVE(p_Manip->fragParams.p_ReassmFrmDescrIndxPoolTbl, i), (uint8_t)(i+1));
+ for ( i = 0; i < size; i++)
+ WRITE_UINT8(*(uint8_t *)PTR_MOVE(p_Manip->capwapFragParams.p_ReassmFrmDescrIndxPoolTbl, i), (uint8_t)(i+1));
- tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->fragParams.p_ReassmFrmDescrIndxPoolTbl) - p_FmPcd->physicalMuramBase);
+ tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->capwapFragParams.p_ReassmFrmDescrIndxPoolTbl) - p_FmPcd->physicalMuramBase);
WRITE_UINT32(p_ReassmTbl->reasmFrmDescIndexPoolTblPtr, tmpReg32);
/*p_ReassmFrmDescrPoolTbl*/
- p_Manip->fragParams.p_ReassmFrmDescrPoolTbl = (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
- (uint32_t)((size + 1) * FM_PCD_MANIP_CAPWAP_REASM_RFD_SIZE),
- 4);
+ p_Manip->capwapFragParams.p_ReassmFrmDescrPoolTbl =
+ (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
+ (uint32_t)((size + 1) * FM_PCD_MANIP_CAPWAP_REASM_RFD_SIZE),
+ 4);
- if(!p_Manip->fragParams.p_ReassmFrmDescrPoolTbl)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
+ if (!p_Manip->capwapFragParams.p_ReassmFrmDescrPoolTbl)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for CAPWAP Reassembly frame buffer pool table"));
- IOMemSet32(p_Manip->fragParams.p_ReassmFrmDescrPoolTbl, 0, (uint32_t)((size +1)* FM_PCD_MANIP_CAPWAP_REASM_RFD_SIZE));
+ MemSet8(p_Manip->capwapFragParams.p_ReassmFrmDescrPoolTbl, 0, (uint32_t)((size +1)* FM_PCD_MANIP_CAPWAP_REASM_RFD_SIZE));
- tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->fragParams.p_ReassmFrmDescrPoolTbl) - p_FmPcd->physicalMuramBase);
+ tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->capwapFragParams.p_ReassmFrmDescrPoolTbl) - p_FmPcd->physicalMuramBase);
WRITE_UINT32(p_ReassmTbl->reasmFrmDescPoolTblPtr, tmpReg32);
/*p_TimeOutTbl*/
- p_Manip->fragParams.p_TimeOutTbl = (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
- (uint32_t)((size + 1)* FM_PCD_MANIP_CAPWAP_REASM_TIME_OUT_ENTRY_SIZE),
- 4);
+ p_Manip->capwapFragParams.p_TimeOutTbl =
+ (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
+ (uint32_t)((size + 1)* FM_PCD_MANIP_CAPWAP_REASM_TIME_OUT_ENTRY_SIZE),
+ 4);
- if(!p_Manip->fragParams.p_TimeOutTbl)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
+ if (!p_Manip->capwapFragParams.p_TimeOutTbl)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for CAPWAP Reassembly timeout table"));
- IOMemSet32(p_Manip->fragParams.p_TimeOutTbl, 0, (uint16_t)((size + 1)*FM_PCD_MANIP_CAPWAP_REASM_TIME_OUT_ENTRY_SIZE));
+ MemSet8(p_Manip->capwapFragParams.p_TimeOutTbl, 0, (uint16_t)((size + 1)*FM_PCD_MANIP_CAPWAP_REASM_TIME_OUT_ENTRY_SIZE));
- tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->fragParams.p_TimeOutTbl) - p_FmPcd->physicalMuramBase);
+ tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->capwapFragParams.p_TimeOutTbl) - p_FmPcd->physicalMuramBase);
WRITE_UINT32(p_ReassmTbl->timeOutTblPtr, tmpReg32);
-
p_Manip->updateParams &= ~NUM_OF_TASKS;
p_Manip->shadowUpdateParams |= NUM_OF_TASKS;
- }
-
- if(p_Manip->updateParams & BUFFER_POOL_ID_FOR_MANIP)
- {
-
- p_Manip->fragParams.poolId = fmPortGetSetCcParams.getCcParams.poolIdForManip;
-
- tmpReg32 = GET_UINT32(p_ReassmTbl->bufferPoolIdAndRisc1SetIndexes);
- tmpReg32 |= (uint32_t)p_Manip->fragParams.poolId << 16;
- WRITE_UINT32(p_ReassmTbl->bufferPoolIdAndRisc1SetIndexes, tmpReg32);
-
- p_Manip->updateParams &= ~BUFFER_POOL_ID_FOR_MANIP;
- p_Manip->shadowUpdateParams |= BUFFER_POOL_ID_FOR_MANIP;
- }
+ }
- if(p_Manip->updateParams & OFFSET_OF_DATA)
+ if (p_Manip->updateParams & OFFSET_OF_DATA)
{
- p_Manip->fragParams.dataOffset = fmPortGetSetCcParams.getCcParams.dataOffset;
+ p_Manip->capwapFragParams.dataOffset = fmPortGetSetCcParams.getCcParams.dataOffset;
tmpReg32 = GET_UINT32(p_ReassmTbl->mode);
- tmpReg32|= p_Manip->fragParams.dataOffset;
+ tmpReg32|= p_Manip->capwapFragParams.dataOffset;
WRITE_UINT32(p_ReassmTbl->mode, tmpReg32);
p_Manip->updateParams &= ~OFFSET_OF_DATA;
p_Manip->shadowUpdateParams |= OFFSET_OF_DATA;
}
- if(!(fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_PR))
+
+ if (!(fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_PR))
{
- p_Manip->fragParams.prOffset = fmPortGetSetCcParams.getCcParams.prOffset;
+ p_Manip->capwapFragParams.prOffset = fmPortGetSetCcParams.getCcParams.prOffset;
tmpReg32 = GET_UINT32(p_ReassmTbl->mode);
tmpReg32|= FM_PCD_MANIP_CAPWAP_REASM_PR_COPY;
WRITE_UINT32(p_ReassmTbl->mode, tmpReg32);
tmpReg32 = GET_UINT32(p_ReassmTbl->intStatsTblPtr);
- tmpReg32 |= (uint32_t)p_Manip->fragParams.prOffset << 24;
+ tmpReg32 |= (uint32_t)p_Manip->capwapFragParams.prOffset << 24;
WRITE_UINT32(p_ReassmTbl->intStatsTblPtr, tmpReg32);
- p_Manip->updateParams &= ~OFFSET_OF_PR;
- p_Manip->shadowUpdateParams |= OFFSET_OF_PR;
- }
- else
- {
- p_Manip->fragParams.prOffset = 0xff;
- p_Manip->updateParams &= ~OFFSET_OF_PR;
- p_Manip->shadowUpdateParams |= OFFSET_OF_PR;
-
- }
-
- p_Manip->fragParams.hwPortId = fmPortGetSetCcParams.getCcParams.hardwarePortId;
+ p_Manip->updateParams &= ~OFFSET_OF_PR;
+ p_Manip->shadowUpdateParams |= OFFSET_OF_PR;
+ }
+ else
+ {
+ p_Manip->capwapFragParams.prOffset = 0xff;
+ p_Manip->updateParams &= ~OFFSET_OF_PR;
+ p_Manip->shadowUpdateParams |= OFFSET_OF_PR;
+ }
+
+ p_Manip->capwapFragParams.hwPortId = fmPortGetSetCcParams.getCcParams.hardwarePortId;
p_Manip->updateParams &= ~HW_PORT_ID;
p_Manip->shadowUpdateParams |= HW_PORT_ID;
/*timeout hc */
- ccCapwapReassmTimeoutParams.fqidForTimeOutFrames = p_Manip->fragParams.fqidForTimeOutFrames;
- ccCapwapReassmTimeoutParams.portIdAndCapwapReassmTbl = (uint32_t)p_Manip->fragParams.hwPortId << 24;
- ccCapwapReassmTimeoutParams.portIdAndCapwapReassmTbl |= (uint32_t)((XX_VirtToPhys(p_ReassmTbl) - p_FmPcd->physicalMuramBase));
- ccCapwapReassmTimeoutParams.timeoutRequestTime = (((uint32_t)1<<p_Manip->fragParams.bitFor1Micro) * p_Manip->fragParams.timeoutRoutineRequestTime)/2;
- return FmHcPcdCcCapwapTimeoutReassm(p_FmPcd->h_Hc,&ccCapwapReassmTimeoutParams);
-
+ ccCapwapReassmTimeoutParams.fqidForTimeOutFrames = p_Manip->capwapFragParams.fqidForTimeOutFrames;
+ ccCapwapReassmTimeoutParams.portIdAndCapwapReassmTbl = (uint32_t)p_Manip->capwapFragParams.hwPortId << 24;
+ ccCapwapReassmTimeoutParams.portIdAndCapwapReassmTbl |= (uint32_t)((XX_VirtToPhys(p_ReassmTbl) - p_FmPcd->physicalMuramBase));
+ ccCapwapReassmTimeoutParams.timeoutRequestTime = (((uint32_t)1<<p_Manip->capwapFragParams.bitFor1Micro) * p_Manip->capwapFragParams.timeoutRoutineRequestTime)/2;
+ return FmHcPcdCcCapwapTimeoutReassm(p_FmPcd->h_Hc,&ccCapwapReassmTimeoutParams);
}
- else if(validate)
- {
- if(fmPortGetSetCcParams.getCcParams.hardwarePortId != p_Manip->fragParams.hwPortId)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Reassembly manipulation previously was assigned to another port"));
- if(fmPortGetSetCcParams.getCcParams.numOfTasks != p_Manip->fragParams.numOfTasks)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfTasks for this manipulation previously was defined by another value "));
- if(fmPortGetSetCcParams.getCcParams.poolIdForManip != p_Manip->fragParams.poolId)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("poolId for this manipulation previously was defined by another value "));
+ else if (validate)
+ {
+ if (fmPortGetSetCcParams.getCcParams.hardwarePortId != p_Manip->capwapFragParams.hwPortId)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Reassembly manipulation previously was assigned to another port"));
+ if (fmPortGetSetCcParams.getCcParams.numOfTasks != p_Manip->capwapFragParams.numOfTasks)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfTasks for this manipulation previously was defined by another value "));
- if(!(fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_PR))
+ if (!(fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_PR))
{
- if(p_Manip->fragParams.prOffset != fmPortGetSetCcParams.getCcParams.prOffset)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Parse result offset previously was defined by another value "));
+ if (p_Manip->capwapFragParams.prOffset != fmPortGetSetCcParams.getCcParams.prOffset)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Parse result offset previously was defined by another value "));
}
else
{
- if(p_Manip->fragParams.prOffset != 0xff)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Parse result offset previously was defined by another value "));
+ if (p_Manip->capwapFragParams.prOffset != 0xff)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Parse result offset previously was defined by another value "));
}
- if(fmPortGetSetCcParams.getCcParams.dataOffset != p_Manip->fragParams.dataOffset)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Data offset previously was defined by another value "));
+ if (fmPortGetSetCcParams.getCcParams.dataOffset != p_Manip->capwapFragParams.dataOffset)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Data offset previously was defined by another value "));
}
return E_OK;
}
-#endif /* FM_CAPWAP_SUPPORT */
+#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
-#if (defined(UNDER_CONSTRUCTION_FRAG_REASSEMBLY) || defined(UNDER_CONSTRUCTION_IPSEC))
-static t_Error UpdateInitIPSec(t_Handle h_FmPort, t_FmPcdManip *p_Manip)
+t_Error FmPcdRegisterReassmPort(t_Handle h_FmPcd, t_Handle h_ReasmCommonPramTbl)
{
- SANITY_CHECK_RETURN_ERROR(h_FmPort,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Manip,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Manip->type == HMAN_OC_IPSEC, E_INVALID_STATE);
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_FmPcdCcReassmTimeoutParams ccReassmTimeoutParams = { 0 };
+ t_Error err = E_OK;
+ uint8_t result;
+ uint32_t bitFor1Micro, tsbs, log2num;
+
+ ASSERT_COND(p_FmPcd);
+ ASSERT_COND(h_ReasmCommonPramTbl);
+
+ bitFor1Micro = FmGetTimeStampScale(p_FmPcd->h_Fm);
+ if (bitFor1Micro == 0)
+ RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("Timestamp scale"));
+
+ bitFor1Micro = 32 - bitFor1Micro;
+ LOG2(FM_PCD_MANIP_REASM_TIMEOUT_THREAD_THRESH, log2num);
+ tsbs = bitFor1Micro - log2num;
+
+ ccReassmTimeoutParams.iprcpt = (uint32_t)(XX_VirtToPhys(
+ h_ReasmCommonPramTbl) - p_FmPcd->physicalMuramBase);
+ ccReassmTimeoutParams.tsbs = (uint8_t)tsbs;
+ ccReassmTimeoutParams.activate = TRUE;
+ if ((err = FmHcPcdCcTimeoutReassm(p_FmPcd->h_Hc, &ccReassmTimeoutParams,
+ &result)) != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
- /*
- if(p_Manip->cnia)
+ switch (result)
{
- p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
-
- WRITE_UINT32(p_Ad->ccAdBase, GET_UINT32(p_Ad->ccAdBase) | FM_PCD_MANIP_IPSEC_CNIA);
+ case (0):
+ return E_OK;
+ case (1):
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("failed to allocate TNUM"));
+ case (2):
+ RETURN_ERROR(
+ MAJOR, E_NO_MEMORY,
+ ("failed to allocate internal buffer from the HC-Port"));
+ case (3):
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("'Disable Timeout Task' with invalid IPRCPT"));
+ case (4):
+ RETURN_ERROR(MAJOR, E_FULL, ("too many timeout tasks"));
+ case (5):
+ RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("invalid sub command"));
+ default:
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
}
-*/
- return E_OK;
-}
-#endif /* (defined(UNDER_CONSTRUCTION_FRAG_REASSEMBLY) || defined(UNDER_CONSTRUCTION_IPSEC))*/
-
-#ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
-static t_Error UpdateInitIpFragmentation(t_Handle h_FmPort, t_FmPcdManip *p_Manip)
-{
- t_FmPortGetSetCcParams fmPortGetSetCcParams;
- t_Error err;
- uint32_t tmpReg32 = 0;
-
- SANITY_CHECK_RETURN_ERROR(p_Manip,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Manip->h_Frag,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Manip->frag,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Manip->type == HMAN_OC_IP_FRAGMENTATION, E_INVALID_STATE);
-
- fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNEN | UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY;
- fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_FRAG | NIA_ENG_FM_CTL;
- err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
-
return E_OK;
}
-static t_Error CreateIpReassCommonParamTable(t_FmPcdManip *p_Manip,
- t_FmPcd *p_FmPcd ,
- t_IpReasmCommonTbl *p_IpReasmCommonPramTbl)
+static t_Error CreateReassCommonTable(t_FmPcdManip *p_Manip)
{
- uint32_t tmpReg32 = 0, i;
- uint64_t tmpReg64, size;
+ uint32_t tmpReg32 = 0, i, bitFor1Micro;
+ uint64_t tmpReg64, size;
+ t_FmPcd *p_FmPcd = (t_FmPcd *)p_Manip->h_FmPcd;
+ t_Error err = E_OK;
- p_Manip->ipReassmParams.h_IpReassCommonParamsTbl = (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
- FM_PCD_MANIP_IP_REASM_COMMON_PARAM_TABLE_SIZE,
- FM_PCD_MANIP_IP_REASM_COMMON_PARAM_TABLE_ALIGN);
+ bitFor1Micro = FmGetTimeStampScale(p_FmPcd->h_Fm);
+ if (bitFor1Micro == 0)
+ RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("Timestamp scale"));
- if(!p_Manip->ipReassmParams.h_IpReassCommonParamsTbl)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
+ /* Allocation of the Reassembly Common Parameters table. This table is located in the
+ MURAM. Its size is 64 bytes and its base address should be 8-byte aligned. */
+ p_Manip->reassmParams.p_ReassCommonTbl =
+ (t_ReassCommonTbl *)FM_MURAM_AllocMem(
+ p_FmPcd->h_FmMuram,
+ FM_PCD_MANIP_REASM_COMMON_PARAM_TABLE_SIZE,
+ FM_PCD_MANIP_REASM_COMMON_PARAM_TABLE_ALIGN);
- p_IpReasmCommonPramTbl = (t_IpReasmCommonTbl *)(p_Manip->ipReassmParams.h_IpReassCommonParamsTbl);
+ if (!p_Manip->reassmParams.p_ReassCommonTbl)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("MURAM alloc for Reassembly common parameters table"));
- IOMemSet32(p_IpReasmCommonPramTbl, 0, FM_PCD_MANIP_IP_REASM_COMMON_PARAM_TABLE_SIZE);
+ MemSet8(p_Manip->reassmParams.p_ReassCommonTbl, 0,
+ FM_PCD_MANIP_REASM_COMMON_PARAM_TABLE_SIZE);
+ /* Setting the TimeOut Mode.*/
tmpReg32 = 0;
- if(p_Manip->ipReassmParams.timeOutMode == e_FM_PCD_MANIP_TIME_OUT_BETWEEN_FRAMES)
- tmpReg32 |= FM_PCD_MANIP_IP_REASM_TIME_OUT_BETWEEN_FRAMES;
-
- tmpReg32 |= p_Manip->ipReassmParams.fqidForTimeOutFrames;
- WRITE_UINT32(p_IpReasmCommonPramTbl->timeoutModeAndFqid, tmpReg32);
-
-
- size = p_Manip->ipReassmParams.maxNumFramesInProcess + 129;
-
- /*p_ReassmFrmDescrIndxPoolTbl */
- p_Manip->ipReassmParams.h_ReassmFrmDescrIndxPoolTbl = (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
- (uint32_t)(size * 2),
- 256);
- if(!p_Manip->ipReassmParams.h_ReassmFrmDescrIndxPoolTbl)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
-
- IOMemSet32(p_Manip->ipReassmParams.h_ReassmFrmDescrIndxPoolTbl, 0, (uint32_t)(size * 2));
-
- for( i = 0; i < size - 1; i++)
- WRITE_UINT8(*(uint8_t *)PTR_MOVE(p_Manip->ipReassmParams.h_ReassmFrmDescrIndxPoolTbl, i), (uint8_t)(i+1));
-
- tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->ipReassmParams.h_ReassmFrmDescrIndxPoolTbl) - p_FmPcd->physicalMuramBase);
-
- WRITE_UINT32(p_IpReasmCommonPramTbl->reassFrmDescIndexPoolTblPtr, tmpReg32);
-
- /*p_ReassmFrmDescrPoolTbl*/
- p_Manip->ipReassmParams.h_ReassmFrmDescrPoolTbl = (t_Handle)XX_MallocSmart((uint32_t)(size * 32), p_Manip->ipReassmParams.dataMemId, 32);
-
- if(!p_Manip->ipReassmParams.h_ReassmFrmDescrPoolTbl)
+ if (p_Manip->reassmParams.timeOutMode
+ == e_FM_PCD_MANIP_TIME_OUT_BETWEEN_FRAMES)
+ tmpReg32 |= FM_PCD_MANIP_REASM_TIME_OUT_BETWEEN_FRAMES;
+
+ /* Setting TimeOut FQID - Frames that time out are enqueued to this FQID.
+ In order to cause TimeOut frames to be discarded, this queue should be configured accordingly*/
+ tmpReg32 |= p_Manip->reassmParams.fqidForTimeOutFrames;
+ WRITE_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->timeoutModeAndFqid,
+ tmpReg32);
+
+ /* Calculation the size of IP Reassembly Frame Descriptor - number of frames that are allowed to be reassembled simultaneously + 129.*/
+ size = p_Manip->reassmParams.maxNumFramesInProcess + 129;
+
+ /*Allocation of IP Reassembly Frame Descriptor Indexes Pool - This pool resides in the MURAM */
+ p_Manip->reassmParams.reassFrmDescrIndxPoolTblAddr =
+ PTR_TO_UINT(FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
+ (uint32_t)(size * 2),
+ 256));
+ if (!p_Manip->reassmParams.reassFrmDescrIndxPoolTblAddr)
+ RETURN_ERROR(
+ MAJOR, E_NO_MEMORY,
+ ("MURAM alloc for Reassembly frame descriptor indexes pool"));
+
+ MemSet8(UINT_TO_PTR(p_Manip->reassmParams.reassFrmDescrIndxPoolTblAddr),
+ 0, (uint32_t)(size * 2));
+
+ /* The entries in IP Reassembly Frame Descriptor Indexes Pool contains indexes starting with 1 up to
+ the maximum number of frames that are allowed to be reassembled simultaneously + 128.
+ The last entry in this pool must contain the index zero*/
+ for (i = 0; i < (size - 1); i++)
+ WRITE_UINT16(
+ *(uint16_t *)PTR_MOVE(UINT_TO_PTR(p_Manip->reassmParams.reassFrmDescrIndxPoolTblAddr), (i<<1)),
+ (uint16_t)(i+1));
+
+ /* Sets the IP Reassembly Frame Descriptor Indexes Pool offset from MURAM */
+ tmpReg32 = (uint32_t)(XX_VirtToPhys(
+ UINT_TO_PTR(p_Manip->reassmParams.reassFrmDescrIndxPoolTblAddr))
+ - p_FmPcd->physicalMuramBase);
+ WRITE_UINT32(
+ p_Manip->reassmParams.p_ReassCommonTbl->reassFrmDescIndexPoolTblPtr,
+ tmpReg32);
+
+ /* Allocation of the Reassembly Frame Descriptors Pool - This pool resides in external memory.
+ The number of entries in this pool should be equal to the number of entries in IP Reassembly Frame Descriptor Indexes Pool.*/
+ p_Manip->reassmParams.reassFrmDescrPoolTblAddr =
+ PTR_TO_UINT(XX_MallocSmart((uint32_t)(size * 64), p_Manip->reassmParams.dataMemId, 64));
+
+ if (!p_Manip->reassmParams.reassFrmDescrPoolTblAddr)
RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation FAILED"));
- IOMemSet32(p_Manip->ipReassmParams.h_ReassmFrmDescrPoolTbl, 0, (uint32_t)(size * 32));
-
- tmpReg64 = (uint64_t)(XX_VirtToPhys(p_Manip->ipReassmParams.h_ReassmFrmDescrPoolTbl));
- tmpReg64 |= ((uint64_t)(p_Manip->ipReassmParams.liodnOffset & FM_PCD_MANIP_IP_REASM_LIODN_MASK) << (uint64_t)FM_PCD_MANIP_IP_REASM_LIODN_SHIFT);
- tmpReg64 |= ((uint64_t)(p_Manip->ipReassmParams.liodnOffset & FM_PCD_MANIP_IP_REASM_ELIODN_MASK) << (uint64_t)FM_PCD_MANIP_IP_REASM_ELIODN_SHIFT);
- WRITE_UINT32(p_IpReasmCommonPramTbl->liodnAndReassFrmDescPoolPtrHi, (uint32_t)(tmpReg64 >> 32));
- WRITE_UINT32(p_IpReasmCommonPramTbl->reassFrmDescPoolPtrLow, (uint32_t)tmpReg64);
-
- /*p_TimeOutTbl*/
- p_Manip->ipReassmParams.h_TimeOutTbl = (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
- (uint32_t)(size * 8),8);
-
- if(!p_Manip->ipReassmParams.h_TimeOutTbl)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
-
- IOMemSet32(p_Manip->ipReassmParams.h_TimeOutTbl, 0, (uint16_t)(size * 8));
-
- tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->ipReassmParams.h_TimeOutTbl) - p_FmPcd->physicalMuramBase);
- WRITE_UINT32(p_IpReasmCommonPramTbl->timeOutTblPtr, tmpReg32);
-
- /* Expiration Delay */
+ MemSet8(UINT_TO_PTR(p_Manip->reassmParams.reassFrmDescrPoolTblAddr), 0,
+ (uint32_t)(size * 64));
+
+ /* Sets the Reassembly Frame Descriptors Pool and liodn offset*/
+ tmpReg64 = (uint64_t)(XX_VirtToPhys(
+ UINT_TO_PTR(p_Manip->reassmParams.reassFrmDescrPoolTblAddr)));
+ tmpReg64 |= ((uint64_t)(p_Manip->reassmParams.dataLiodnOffset
+ & FM_PCD_MANIP_REASM_LIODN_MASK)
+ << (uint64_t)FM_PCD_MANIP_REASM_LIODN_SHIFT);
+ tmpReg64 |= ((uint64_t)(p_Manip->reassmParams.dataLiodnOffset
+ & FM_PCD_MANIP_REASM_ELIODN_MASK)
+ << (uint64_t)FM_PCD_MANIP_REASM_ELIODN_SHIFT);
+ WRITE_UINT32(
+ p_Manip->reassmParams.p_ReassCommonTbl->liodnAndReassFrmDescPoolPtrHi,
+ (uint32_t)(tmpReg64 >> 32));
+ WRITE_UINT32(
+ p_Manip->reassmParams.p_ReassCommonTbl->reassFrmDescPoolPtrLow,
+ (uint32_t)tmpReg64);
+
+ /*Allocation of the TimeOut table - This table resides in the MURAM.
+ The number of entries in this table is identical to the number of entries in the Reassembly Frame Descriptors Pool*/
+ p_Manip->reassmParams.timeOutTblAddr =
+ PTR_TO_UINT(FM_MURAM_AllocMem(p_FmPcd->h_FmMuram, (uint32_t)(size * 8),8));
+
+ if (!p_Manip->reassmParams.timeOutTblAddr)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("MURAM alloc for Reassembly timeout table"));
+
+ MemSet8(UINT_TO_PTR(p_Manip->reassmParams.timeOutTblAddr), 0,
+ (uint16_t)(size * 8));
+
+ /* Sets the TimeOut table offset from MURAM */
+ tmpReg32 = (uint32_t)(XX_VirtToPhys(
+ UINT_TO_PTR(p_Manip->reassmParams.timeOutTblAddr))
+ - p_FmPcd->physicalMuramBase);
+ WRITE_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->timeOutTblPtr,
+ tmpReg32);
+
+ /* Sets the Expiration Delay */
tmpReg32 = 0;
- tmpReg32 |= p_Manip->ipReassmParams.timeoutThresholdForReassmProcess;
- WRITE_UINT32(p_IpReasmCommonPramTbl->expirationDelay, tmpReg32);
-
- /* Counts the number of TimeOut occurrences - Must be initialized to zero.*/
- WRITE_UINT32(p_IpReasmCommonPramTbl->totalTimeOutCounter, 0);
- /* Counts the number of failed attempts to allocate a Reassembly Frame Descriptor - Must be initialized to zero.*/
- WRITE_UINT32(p_IpReasmCommonPramTbl->totalRfdPoolBusyCounter, 0);
- /* Counts the number of times an internal buffer busy occured.*/
- WRITE_UINT32(p_IpReasmCommonPramTbl->totalInternalBufferBusy, 0);
- /* Counts the number of times external buffer busy occured. */
- WRITE_UINT32(p_IpReasmCommonPramTbl->totalExternalBufferBusy, 0);
+ tmpReg32 |= (((uint32_t)(1 << bitFor1Micro))
+ * p_Manip->reassmParams.timeoutThresholdForReassmProcess);
+ WRITE_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->expirationDelay,
+ tmpReg32);
- return E_OK;
+ err = FmPcdRegisterReassmPort(p_FmPcd,
+ p_Manip->reassmParams.p_ReassCommonTbl);
+ if (err != E_OK)
+ {
+ FM_MURAM_FreeMem(p_FmPcd->h_FmMuram,
+ p_Manip->reassmParams.p_ReassCommonTbl);
+ RETURN_ERROR(MAJOR, err, ("port registration"));
+ }
+
+ return err;
}
-static t_Error CreateIpReassParamTable(t_FmPcdManip *p_Manip, t_Handle h_IpReassParamsTblPtr, bool ipv4)
+static t_Error CreateReassTable(t_FmPcdManip *p_Manip, e_NetHeaderType hdr)
{
- t_IpReasmPram *p_Table;
- t_AdOfTypeContLookup *p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
- t_FmPcd *p_FmPcd = p_Manip->h_FmPcd;
- uint32_t tmpReg32, autoLearnHashTblSize;
- uint32_t numOfWays, setSize, setSizeCode, tmpSetSize;
- uint32_t waySize, numOfSets, tmpNumOfSets, numOfEntries;
- uint64_t tmpReg64;
- t_Handle h_AutoLearnHashTbl, h_AutoLearnSetLockTblPtr;
-
- /*Pointer to fragment ID*/
- h_IpReassParamsTblPtr = (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
- FM_PCD_MANIP_IP_REASM_TABLE_SIZE,
- FM_PCD_MANIP_IP_REASM_TABLE_ALIGN);
-
- if(!h_IpReassParamsTblPtr)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
-
- IOMemSet32(h_IpReassParamsTblPtr, 0, FM_PCD_MANIP_IP_REASM_TABLE_SIZE);
-
- p_Table = (t_IpReasmPram *)h_IpReassParamsTblPtr;
-
- tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->ipReassmParams.h_IpReassCommonParamsTbl) - p_FmPcd->physicalMuramBase);
- WRITE_UINT32(((t_IpReasmPram *)h_IpReassParamsTblPtr)->ipReassCommonPrmTblPtr, tmpReg32);
-
- /* waysNumAndSetSize calculation */
- numOfWays = p_Manip->ipReassmParams.numOfFramesPerHashEntry;
-
- /*It is recommended that the total number of entries in this table
- (number of sets * number of ways) will be twice the number of frames that
- are expected to be reassembled simultaneously.*/
- numOfEntries = (uint32_t)(p_Manip->ipReassmParams.maxNumFramesInProcess * 2);
-
- /* sets number calculation - number of entries = number of sets * number of ways */
- numOfSets = numOfEntries / numOfWays;
-
- /*TODO - Handle way size*/
- switch(p_Manip->ipReassmParams.hdr)
+ t_FmPcd *p_FmPcd = p_Manip->h_FmPcd;
+ uint32_t tmpReg32, autoLearnHashTblSize;
+ uint32_t numOfWays, setSize, setSizeCode, keySize;
+ uint32_t waySize, numOfSets, numOfEntries;
+ uint64_t tmpReg64;
+ uint16_t minFragSize;
+ uint16_t maxReassemSize;
+ uintptr_t *p_AutoLearnHashTblAddr, *p_AutoLearnSetLockTblAddr;
+ t_ReassTbl **p_ReassTbl;
+
+ switch (hdr)
{
- case(HEADER_TYPE_IPv6):
- /* WaySize is rounded-up to next multiple of 8 */
- waySize = ROUND_UP(((16 + 16 + 4 + 2) /* * numOfWays*/),8);
+ case HEADER_TYPE_IPv4:
+ p_ReassTbl = &p_Manip->reassmParams.ip.p_Ipv4ReassTbl;
+ p_AutoLearnHashTblAddr =
+ &p_Manip->reassmParams.ip.ipv4AutoLearnHashTblAddr;
+ p_AutoLearnSetLockTblAddr =
+ &p_Manip->reassmParams.ip.ipv4AutoLearnSetLockTblAddr;
+ minFragSize = p_Manip->reassmParams.ip.minFragSize[0];
+ maxReassemSize = 0;
+ numOfWays = p_Manip->reassmParams.ip.numOfFramesPerHashEntry[0];
+ keySize = 4 + 4 + 1 + 2; /* 3-tuple + IP-Id */
+ break;
+ case HEADER_TYPE_IPv6:
+ p_ReassTbl = &p_Manip->reassmParams.ip.p_Ipv6ReassTbl;
+ p_AutoLearnHashTblAddr =
+ &p_Manip->reassmParams.ip.ipv6AutoLearnHashTblAddr;
+ p_AutoLearnSetLockTblAddr =
+ &p_Manip->reassmParams.ip.ipv6AutoLearnSetLockTblAddr;
+ minFragSize = p_Manip->reassmParams.ip.minFragSize[1];
+ maxReassemSize = 0;
+ numOfWays = p_Manip->reassmParams.ip.numOfFramesPerHashEntry[1];
+ keySize = 16 + 16 + 4; /* 2-tuple + IP-Id */
+ if (numOfWays > e_FM_PCD_MANIP_SIX_WAYS_HASH)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("num of ways"));
break;
- case(HEADER_TYPE_IPv4):
+ case HEADER_TYPE_CAPWAP:
+ p_ReassTbl = &p_Manip->reassmParams.capwap.p_ReassTbl;
+ p_AutoLearnHashTblAddr =
+ &p_Manip->reassmParams.capwap.autoLearnHashTblAddr;
+ p_AutoLearnSetLockTblAddr =
+ &p_Manip->reassmParams.capwap.autoLearnSetLockTblAddr;
+ minFragSize = 0;
+ maxReassemSize = p_Manip->reassmParams.capwap.maxRessembledsSize;
+ numOfWays = p_Manip->reassmParams.capwap.numOfFramesPerHashEntry;
+ keySize = 4;
break;
default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Unsupported header for reassembly"));
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("header type"));
}
- /* Set size is rounded-up to next power of 2 */
- LOG2(numOfWays * waySize, tmpSetSize);
- setSize = (uint32_t)(1 << (tmpSetSize + (POWER_OF_2(numOfWays * waySize) ? 0 : 1)));
-
+ keySize += 2; /* 2 bytes reserved for RFDIndex */
+#if (DPAA_VERSION >= 11)
+ keySize += 2; /* 2 bytes reserved */
+#endif /* (DPAA_VERSION >= 11) */
+ waySize = ROUND_UP(keySize, 8);
+
+ /* Allocates the Reassembly Parameters Table - This table is located in the MURAM.*/
+ *p_ReassTbl = (t_ReassTbl *)FM_MURAM_AllocMem(
+ p_FmPcd->h_FmMuram, FM_PCD_MANIP_REASM_TABLE_SIZE,
+ FM_PCD_MANIP_REASM_TABLE_ALIGN);
+ if (!*p_ReassTbl)
+ RETURN_ERROR( MAJOR, E_NO_MEMORY,
+ ("MURAM alloc for Reassembly specific parameters table"));
+ memset(*p_ReassTbl, 0, sizeof(t_ReassTbl));
+
+ /* Sets the Reassembly common Parameters table offset from MURAM in the Reassembly Table descriptor*/
+ tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->reassmParams.p_ReassCommonTbl)
+ - p_FmPcd->physicalMuramBase);
+ WRITE_UINT32((*p_ReassTbl)->reassCommonPrmTblPtr, tmpReg32);
+
+ /* Calculate set size (set size is rounded-up to next power of 2) */
+ NEXT_POWER_OF_2(numOfWays * waySize, setSize);
+
+ /* Get set size code */
LOG2(setSize, setSizeCode);
- WRITE_UINT16(((t_IpReasmPram *)p_Table)->waysNumAndSetSize, (uint16_t)((numOfWays << 8) | setSizeCode));
-
- LOG2(numOfSets, tmpNumOfSets);
- numOfSets = (uint32_t)(1 << (tmpNumOfSets + (POWER_OF_2(numOfSets) ? 0 : 1)));
-
- WRITE_UINT16(((t_IpReasmPram *)p_Table)->autoLearnHashKeyMask, (uint16_t)(numOfSets - 1));
-
- /*autoLearnHashTbl allocation
- Table size = set size * number of sets
- This table’s base address should be aligned to SetSize.*/
- autoLearnHashTblSize = numOfSets * setSize;
-
- if (ipv4)
- h_AutoLearnHashTbl = p_Manip->ipReassmParams.h_Ipv4AutoLearnHashTbl;
- else
- h_AutoLearnHashTbl = p_Manip->ipReassmParams.h_Ipv6AutoLearnHashTbl;
- h_AutoLearnHashTbl = (t_Handle)XX_MallocSmart(autoLearnHashTblSize, p_Manip->ipReassmParams.dataMemId, setSizeCode);
+ /* Sets ways number and set size code */
+ WRITE_UINT16((*p_ReassTbl)->waysNumAndSetSize,
+ (uint16_t)((numOfWays << 8) | setSizeCode));
- if(!h_AutoLearnHashTbl)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation FAILED"));
+ /* It is recommended that the total number of entries in this table
+ (number of sets * number of ways) will be twice the number of frames that
+ are expected to be reassembled simultaneously.*/
+ numOfEntries = (uint32_t)(p_Manip->reassmParams.maxNumFramesInProcess * 2);
- IOMemSet32(h_AutoLearnHashTbl, 0, autoLearnHashTblSize);
+ /* sets number calculation - number of entries = number of sets * number of ways */
+ numOfSets = numOfEntries / numOfWays;
- tmpReg64 = ((uint64_t)(p_Manip->ipReassmParams.liodnOffset & FM_PCD_MANIP_IP_REASM_LIODN_MASK) << (uint64_t)FM_PCD_MANIP_IP_REASM_LIODN_SHIFT);
- tmpReg64 |= ((uint64_t)(p_Manip->ipReassmParams.liodnOffset & FM_PCD_MANIP_IP_REASM_ELIODN_MASK) << (uint64_t)FM_PCD_MANIP_IP_REASM_ELIODN_SHIFT);
- tmpReg64 |= XX_VirtToPhys(h_AutoLearnHashTbl);
- WRITE_UINT32(((t_IpReasmPram *)p_Table)->liodnAlAndAutoLearnHashTblPtrHi, (uint32_t)(tmpReg64 >> 32));
- WRITE_UINT32(((t_IpReasmPram *)p_Table)->autoLearnHashTblPtrLow, (uint32_t)tmpReg64);
+ /* Sets AutoLearnHashKeyMask*/
+ NEXT_POWER_OF_2(numOfSets, numOfSets);
- /* AutoLearnSetLockTbl allocation - The size of this table is (number of sets in the IP
- Reassembly Automatic Learning Hash table)*4 bytes. This table resides in external memory
- and its base address should be 4-byte aligned */
- if (ipv4)
- h_AutoLearnSetLockTblPtr = p_Manip->ipReassmParams.h_Ipv4AutoLearnSetLockTblPtr;
- else
- h_AutoLearnSetLockTblPtr = p_Manip->ipReassmParams.h_Ipv6AutoLearnSetLockTblPtr;
+ WRITE_UINT16((*p_ReassTbl)->autoLearnHashKeyMask,
+ (uint16_t)(numOfSets - 1));
- h_AutoLearnSetLockTblPtr = (t_Handle)XX_MallocSmart((uint32_t)(numOfSets * 4), p_Manip->ipReassmParams.dataMemId, 4);
+ /* Allocation of Reassembly Automatic Learning Hash Table - This table resides in external memory.
+ The size of this table is determined by the number of sets and the set size.
+ Table size = set size * number of sets
+ This table base address should be aligned to SetSize.*/
+ autoLearnHashTblSize = numOfSets * setSize;
- if(!h_AutoLearnSetLockTblPtr)
+ *p_AutoLearnHashTblAddr =
+ PTR_TO_UINT(XX_MallocSmart(autoLearnHashTblSize, p_Manip->reassmParams.dataMemId, setSize));
+ if (!*p_AutoLearnHashTblAddr)
+ {
+ FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, *p_ReassTbl);
+ *p_ReassTbl = NULL;
RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation FAILED"));
+ }
+ MemSet8(UINT_TO_PTR(*p_AutoLearnHashTblAddr), 0, autoLearnHashTblSize);
+
+ /* Sets the Reassembly Automatic Learning Hash Table and liodn offset */
+ tmpReg64 = ((uint64_t)(p_Manip->reassmParams.dataLiodnOffset
+ & FM_PCD_MANIP_REASM_LIODN_MASK)
+ << (uint64_t)FM_PCD_MANIP_REASM_LIODN_SHIFT);
+ tmpReg64 |= ((uint64_t)(p_Manip->reassmParams.dataLiodnOffset
+ & FM_PCD_MANIP_REASM_ELIODN_MASK)
+ << (uint64_t)FM_PCD_MANIP_REASM_ELIODN_SHIFT);
+ tmpReg64 |= XX_VirtToPhys(UINT_TO_PTR(*p_AutoLearnHashTblAddr));
+ WRITE_UINT32( (*p_ReassTbl)->liodnAlAndAutoLearnHashTblPtrHi,
+ (uint32_t)(tmpReg64 >> 32));
+ WRITE_UINT32((*p_ReassTbl)->autoLearnHashTblPtrLow, (uint32_t)tmpReg64);
+
+ /* Allocation of the Set Lock table - This table resides in external memory
+ The size of this table is (number of sets in the Reassembly Automatic Learning Hash table)*4 bytes.
+ This table resides in external memory and its base address should be 4-byte aligned */
+ *p_AutoLearnSetLockTblAddr =
+ PTR_TO_UINT(XX_MallocSmart((uint32_t)(numOfSets * 4), p_Manip->reassmParams.dataMemId, 4));
+ if (!*p_AutoLearnSetLockTblAddr)
+ {
+ FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, *p_ReassTbl);
+ *p_ReassTbl = NULL;
+ XX_FreeSmart(UINT_TO_PTR(*p_AutoLearnHashTblAddr));
+ *p_AutoLearnHashTblAddr = 0;
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation FAILED"));
+ }
+ MemSet8(UINT_TO_PTR(*p_AutoLearnSetLockTblAddr), 0, (numOfSets * 4));
- IOMemSet32(h_AutoLearnSetLockTblPtr, 0, (numOfSets * 4));
-
- tmpReg64 = ((uint64_t)(p_Manip->ipReassmParams.liodnOffset & FM_PCD_MANIP_IP_REASM_LIODN_MASK) << (uint64_t)FM_PCD_MANIP_IP_REASM_LIODN_SHIFT);
- tmpReg64 |= ((uint64_t)(p_Manip->ipReassmParams.liodnOffset & FM_PCD_MANIP_IP_REASM_ELIODN_MASK) << (uint64_t)FM_PCD_MANIP_IP_REASM_ELIODN_SHIFT);
- tmpReg64 |= XX_VirtToPhys(h_AutoLearnSetLockTblPtr);
- WRITE_UINT32(((t_IpReasmPram *)p_Table)->liodnSlAndAutoLearnSetLockTblPtrHi, (uint32_t)(tmpReg64 >> 32));
- WRITE_UINT32(((t_IpReasmPram *)p_Table)->autoLearnSetLockTblPtrLow, (uint32_t)tmpReg64);
+ /* sets Set Lock table pointer and liodn offset*/
+ tmpReg64 = ((uint64_t)(p_Manip->reassmParams.dataLiodnOffset
+ & FM_PCD_MANIP_REASM_LIODN_MASK)
+ << (uint64_t)FM_PCD_MANIP_REASM_LIODN_SHIFT);
+ tmpReg64 |= ((uint64_t)(p_Manip->reassmParams.dataLiodnOffset
+ & FM_PCD_MANIP_REASM_ELIODN_MASK)
+ << (uint64_t)FM_PCD_MANIP_REASM_ELIODN_SHIFT);
+ tmpReg64 |= XX_VirtToPhys(UINT_TO_PTR(*p_AutoLearnSetLockTblAddr));
+ WRITE_UINT32( (*p_ReassTbl)->liodnSlAndAutoLearnSetLockTblPtrHi,
+ (uint32_t)(tmpReg64 >> 32));
+ WRITE_UINT32((*p_ReassTbl)->autoLearnSetLockTblPtrLow, (uint32_t)tmpReg64);
- /* Setting the First/Middle fragment minimum size in Bytes */
- WRITE_UINT32(((t_IpReasmPram *)p_Table)->minFragSize, p_Manip->ipReassmParams.minFragSize);
+ /* Sets user's requested minimum fragment size (in Bytes) for First/Middle fragment */
+ WRITE_UINT16((*p_ReassTbl)->minFragSize, minFragSize);
- /* Zeroes all counters */
- WRITE_UINT32(((t_IpReasmPram *)p_Table)->totalSuccessfullyReasmFramesCounter, 0);
- WRITE_UINT32(((t_IpReasmPram *)p_Table)->totalValidFragmentCounter, 0);
- WRITE_UINT32(((t_IpReasmPram *)p_Table)->totalProcessedFragCounter, 0);
- WRITE_UINT32(((t_IpReasmPram *)p_Table)->totalMalformdFragCounter, 0);
- WRITE_UINT32(((t_IpReasmPram *)p_Table)->totalSetBusyCounter, 0);
- WRITE_UINT32(((t_IpReasmPram *)p_Table)->totalDiscardedFragsCounter, 0);
- WRITE_UINT32(((t_IpReasmPram *)p_Table)->totalMoreThan16FramesCounter, 0);
+ WRITE_UINT16((*p_ReassTbl)->maxReassemblySize, maxReassemSize);
return E_OK;
}
-static t_Error UpdateInitIpReasm(t_Handle h_FmPcd,
- t_Handle h_FmPort,
- t_FmPcdManip *p_Manip,
- t_Handle h_Ad,
- bool validate)
+static t_Error UpdateInitReasm(t_Handle h_FmPcd, t_Handle h_PcdParams,
+ t_Handle h_FmPort, t_FmPcdManip *p_Manip,
+ t_Handle h_Ad, bool validate)
{
- t_AdOfTypeContLookup *p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
- t_IpReasmCommonTbl *p_ReassmCommonTbl = NULL;
- t_FmPortGetSetCcParams fmPortGetSetCcParams;
- uint8_t i = 0;
- uint32_t tmpReg32;
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- t_Error err;
-
- SANITY_CHECK_RETURN_ERROR(p_Manip,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_Manip->frag,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR((p_Manip->type == HMAN_OC_IP_REASSEMBLY), E_INVALID_STATE);
- SANITY_CHECK_RETURN_ERROR(h_FmPcd,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc,E_INVALID_HANDLE);
+ t_FmPortGetSetCcParams fmPortGetSetCcParams;
+ uint32_t tmpReg32;
+ t_Error err;
+ t_FmPortPcdParams *p_PcdParams = (t_FmPortPcdParams *)h_PcdParams;
+#if (DPAA_VERSION >= 11)
+ t_FmPcdCtrlParamsPage *p_ParamsPage;
+#endif /* (DPAA_VERSION >= 11) */
+
+ SANITY_CHECK_RETURN_ERROR(p_Manip, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Manip->frag, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(
+ (p_Manip->opcode == HMAN_OC_IP_REASSEMBLY) || (p_Manip->opcode == HMAN_OC_CAPWAP_REASSEMBLY),
+ E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Manip->updateParams || h_PcdParams,
+ E_INVALID_HANDLE);
UNUSED(h_Ad);
- if(p_Manip->h_FmPcd != h_FmPcd)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("handler of PCD previously was initiated by different value"));
+ if (!p_Manip->updateParams)
+ return E_OK;
- memset(&fmPortGetSetCcParams, 0, sizeof(t_FmPortGetSetCcParams));
+ if (p_Manip->h_FmPcd != h_FmPcd)
+ RETURN_ERROR(
+ MAJOR, E_INVALID_STATE,
+ ("handler of PCD previously was initiated by different value"));
-
- if(p_Manip->updateParams)
+ if (p_Manip->updateParams)
{
- if((!(p_Manip->updateParams & OFFSET_OF_DATA) && !(p_Manip->updateParams & OFFSET_OF_PR) &&
- !(p_Manip->updateParams & HW_PORT_ID)) ||
- ((p_Manip->shadowUpdateParams & NUM_OF_TASKS) || (p_Manip->shadowUpdateParams & BUFFER_POOL_ID_FOR_MANIP) ||
- (p_Manip->shadowUpdateParams & OFFSET_OF_DATA) || (p_Manip->shadowUpdateParams & OFFSET_OF_PR)
- ||(p_Manip->shadowUpdateParams & HW_PORT_ID)))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has not be updated"));
-
- fmPortGetSetCcParams.getCcParams.type = p_Manip->updateParams;
- fmPortGetSetCcParams.getCcParams.poolIndex = p_Manip->fragParams.poolIndx;
- fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNEN;
- fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_FRAG | NIA_ENG_FM_CTL;
- fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_RFENE;
- fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_CLOSING_FRAG_CHECK;
- err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
- if(fmPortGetSetCcParams.getCcParams.type & NUM_OF_TASKS)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Num of tasks wasn't configured previousely"));
- if(fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_DATA)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("offset of the data wasn't configured previousely"));
- if(fmPortGetSetCcParams.getCcParams.type & HW_PORT_ID)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("hwPortId wasn't updated"));
-
- }
- else if (validate)
- {
- if((!(p_Manip->shadowUpdateParams & BUFFER_POOL_ID_FOR_MANIP) &&
- (!(p_Manip->shadowUpdateParams & OFFSET_OF_DATA)) && (!(p_Manip->shadowUpdateParams & OFFSET_OF_PR)) &&
- (!(p_Manip->shadowUpdateParams & HW_PORT_ID))) &&
- ((p_Manip->updateParams & NUM_OF_TASKS) ||
- (p_Manip->updateParams & OFFSET_OF_DATA) || (p_Manip->updateParams & OFFSET_OF_PR)||
- (p_Manip->updateParams & HW_PORT_ID)))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("in this stage parameters from Port has be updated"));
-
- fmPortGetSetCcParams.getCcParams.type = p_Manip->shadowUpdateParams;
- fmPortGetSetCcParams.getCcParams.poolIndex = p_Manip->fragParams.poolIndx;
- fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNEN;
- fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_FRAG | NIA_ENG_FM_CTL;
- fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_RFENE;
- fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_CLOSING_FRAG_CHECK;
- err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
- if(err)
+ if ((!(p_Manip->updateParams
+ & (NUM_OF_TASKS | NUM_OF_EXTRA_TASKS | DISCARD_MASK)))
+ || ((p_Manip->shadowUpdateParams
+ & (NUM_OF_TASKS | NUM_OF_EXTRA_TASKS | DISCARD_MASK))))
+ RETURN_ERROR(
+ MAJOR, E_INVALID_STATE,
+ ("in this stage parameters from Port has not be updated"));
+
+ fmPortGetSetCcParams.setCcParams.type = 0;
+ if (p_Manip->opcode == HMAN_OC_CAPWAP_REASSEMBLY)
+ {
+ fmPortGetSetCcParams.setCcParams.type |= UPDATE_OFP_DPTE;
+ fmPortGetSetCcParams.setCcParams.ofpDpde = 0xF;
+ }
+ fmPortGetSetCcParams.getCcParams.type = p_Manip->updateParams | FM_REV;
+ if ((err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams))
+ != E_OK)
RETURN_ERROR(MAJOR, err, NO_MSG);
- if(fmPortGetSetCcParams.getCcParams.type & NUM_OF_TASKS)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("NumOfTasks wasn't configured previousely"));
- if(fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_DATA)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("offset of the data wasn't configured previousely"));
- if(fmPortGetSetCcParams.getCcParams.type & HW_PORT_ID)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("hwPortId wasn't updated"));
+ if (fmPortGetSetCcParams.getCcParams.type
+ & (NUM_OF_TASKS | NUM_OF_EXTRA_TASKS | DISCARD_MASK | FM_REV))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("offset of the data wasn't configured previously"));
+ if (p_Manip->updateParams
+ & (NUM_OF_TASKS | NUM_OF_EXTRA_TASKS | DISCARD_MASK))
+ {
+ t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ uint8_t *p_Ptr, i, totalNumOfTnums;
+
+ totalNumOfTnums =
+ (uint8_t)(fmPortGetSetCcParams.getCcParams.numOfTasks
+ + fmPortGetSetCcParams.getCcParams.numOfExtraTasks);
+
+ p_Manip->reassmParams.internalBufferPoolAddr =
+ PTR_TO_UINT(FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
+ (uint32_t)(totalNumOfTnums * BMI_FIFO_UNITS),
+ BMI_FIFO_UNITS));
+ if (!p_Manip->reassmParams.internalBufferPoolAddr)
+ RETURN_ERROR(
+ MAJOR, E_NO_MEMORY,
+ ("MURAM alloc for Reassembly internal buffers pool"));
+ MemSet8(
+ UINT_TO_PTR(p_Manip->reassmParams.internalBufferPoolAddr),
+ 0, (uint32_t)(totalNumOfTnums * BMI_FIFO_UNITS));
+
+ p_Manip->reassmParams.internalBufferPoolManagementIndexAddr =
+ PTR_TO_UINT(FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
+ (uint32_t)(5 + totalNumOfTnums),
+ 4));
+ if (!p_Manip->reassmParams.internalBufferPoolManagementIndexAddr)
+ RETURN_ERROR(
+ MAJOR,
+ E_NO_MEMORY,
+ ("MURAM alloc for Reassembly internal buffers management"));
+
+ p_Ptr =
+ (uint8_t*)UINT_TO_PTR(p_Manip->reassmParams.internalBufferPoolManagementIndexAddr);
+ WRITE_UINT32(
+ *(uint32_t*)p_Ptr,
+ (uint32_t)(XX_VirtToPhys(UINT_TO_PTR(p_Manip->reassmParams.internalBufferPoolAddr)) - p_FmPcd->physicalMuramBase));
+ for (i = 0, p_Ptr += 4; i < totalNumOfTnums; i++, p_Ptr++)
+ WRITE_UINT8(*p_Ptr, i);
+ WRITE_UINT8(*p_Ptr, 0xFF);
+
+ tmpReg32 =
+ (4 << FM_PCD_MANIP_REASM_COMMON_INT_BUFFER_IDX_SHIFT)
+ | ((uint32_t)(XX_VirtToPhys(
+ UINT_TO_PTR(p_Manip->reassmParams.internalBufferPoolManagementIndexAddr))
+ - p_FmPcd->physicalMuramBase));
+ WRITE_UINT32(
+ p_Manip->reassmParams.p_ReassCommonTbl->internalBufferManagement,
+ tmpReg32);
+
+ p_Manip->updateParams &= ~(NUM_OF_TASKS | NUM_OF_EXTRA_TASKS
+ | DISCARD_MASK);
+ p_Manip->shadowUpdateParams |= (NUM_OF_TASKS | NUM_OF_EXTRA_TASKS
+ | DISCARD_MASK);
+ }
}
- if(p_Manip->updateParams)
+ if (p_Manip->opcode == HMAN_OC_CAPWAP_REASSEMBLY)
{
- if(p_Manip->updateParams & OFFSET_OF_DATA)
+ if (p_Manip->reassmParams.capwap.h_Scheme)
{
- p_Manip->ipReassmParams.dataOffset = fmPortGetSetCcParams.getCcParams.dataOffset;
- tmpReg32 = GET_UINT32(p_Ad->matchTblPtr);
- tmpReg32 |= p_Manip->ipReassmParams.dataOffset;
- WRITE_UINT32(p_Ad->matchTblPtr, tmpReg32);
-
- p_Manip->updateParams &= ~OFFSET_OF_DATA;
- p_Manip->shadowUpdateParams |= OFFSET_OF_DATA;
+ p_PcdParams->p_KgParams->h_Schemes[p_PcdParams->p_KgParams->numOfSchemes] =
+ p_Manip->reassmParams.capwap.h_Scheme;
+ p_PcdParams->p_KgParams->numOfSchemes++;
}
- p_Manip->updateParams &= ~HW_PORT_ID;
- p_Manip->shadowUpdateParams |= HW_PORT_ID;
}
else
{
- if(validate)
+ if (p_Manip->reassmParams.ip.h_Ipv4Scheme)
{
- /* TODO - Handle validate..*/
- /*if(fmPortGetSetCcParams.getCcParams.hardwarePortId != p_Manip->fragParams.hwPortId)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Reassembly manipulation previously was assigned to another port"));
- if(fmPortGetSetCcParams.getCcParams.numOfTasks != p_Manip->fragParams.numOfTasks)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfTasks for this manipulation previously was defined by another value "));
-
- if(fmPortGetSetCcParams.getCcParams.poolIdForManip != p_Manip->fragParams.poolId)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("poolId for this manipulation previously was defined by another value "));
+ p_PcdParams->p_KgParams->h_Schemes[p_PcdParams->p_KgParams->numOfSchemes] =
+ p_Manip->reassmParams.ip.h_Ipv4Scheme;
+ p_PcdParams->p_KgParams->numOfSchemes++;
+ }
+ if (p_Manip->reassmParams.ip.h_Ipv6Scheme)
+ {
+ p_PcdParams->p_KgParams->h_Schemes[p_PcdParams->p_KgParams->numOfSchemes] =
+ p_Manip->reassmParams.ip.h_Ipv6Scheme;
+ p_PcdParams->p_KgParams->numOfSchemes++;
+ }
+#if (DPAA_VERSION >= 11)
+ if (fmPortGetSetCcParams.getCcParams.revInfo.majorRev >= 6)
+ {
+ if ((err = FmPortSetGprFunc(h_FmPort, e_FM_PORT_GPR_MURAM_PAGE,
+ (void**)&p_ParamsPage)) != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
- if(!(fmPortGetSetCcParams.getCcParams.type & OFFSET_OF_PR))
+ tmpReg32 = NIA_ENG_KG;
+ if (p_Manip->reassmParams.ip.h_Ipv4Scheme)
{
- if(p_Manip->fragParams.prOffset != fmPortGetSetCcParams.getCcParams.prOffset)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Parse result offset previously was defined by another value "));
+ tmpReg32 |= NIA_KG_DIRECT;
+ tmpReg32 |= NIA_KG_CC_EN;
+ tmpReg32 |= FmPcdKgGetSchemeId(
+ p_Manip->reassmParams.ip.h_Ipv4Scheme);
+ WRITE_UINT32(p_ParamsPage->iprIpv4Nia, tmpReg32);
}
- else
+ if (p_Manip->reassmParams.ip.h_Ipv6Scheme)
{
- if(p_Manip->fragParams.prOffset != 0xff)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Parse result offset previously was defined by another value "));
+ tmpReg32 &= ~NIA_AC_MASK;
+ tmpReg32 |= NIA_KG_DIRECT;
+ tmpReg32 |= NIA_KG_CC_EN;
+ tmpReg32 |= FmPcdKgGetSchemeId(
+ p_Manip->reassmParams.ip.h_Ipv6Scheme);
+ WRITE_UINT32(p_ParamsPage->iprIpv6Nia, tmpReg32);
}
- if(fmPortGetSetCcParams.getCcParams.dataOffset != p_Manip->fragParams.dataOffset)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Data offset previously was defined by another value "));*/
-
}
+#else
+ if (fmPortGetSetCcParams.getCcParams.revInfo.majorRev < 6)
+ {
+ WRITE_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->discardMask,
+ fmPortGetSetCcParams.getCcParams.discardMask);
+ }
+#endif /* (DPAA_VERSION >= 11) */
}
+ return E_OK;
+}
+
+#if (DPAA_VERSION == 10)
+static t_Error FmPcdFragHcScratchPoolFill(t_Handle h_FmPcd, uint8_t scratchBpid)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_FmPcdCcFragScratchPoolCmdParams fmPcdCcFragScratchPoolCmdParams;
+ t_Error err;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+
+ memset(&fmPcdCcFragScratchPoolCmdParams, 0, sizeof(t_FmPcdCcFragScratchPoolCmdParams));
+
+ fmPcdCcFragScratchPoolCmdParams.numOfBuffers = NUM_OF_SCRATCH_POOL_BUFFERS;
+ fmPcdCcFragScratchPoolCmdParams.bufferPoolId = scratchBpid;
+ if ((err = FmHcPcdCcIpFragScratchPollCmd(p_FmPcd->h_Hc, TRUE, &fmPcdCcFragScratchPoolCmdParams)) != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ if (fmPcdCcFragScratchPoolCmdParams.numOfBuffers != 0)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Fill scratch pool failed,"
+ "Failed to release %d buffers to the BM (missing FBPRs)",
+ fmPcdCcFragScratchPoolCmdParams.numOfBuffers));
+
+ return E_OK;
+}
+
+static t_Error FmPcdFragHcScratchPoolEmpty(t_Handle h_FmPcd, uint8_t scratchBpid)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_FmPcdCcFragScratchPoolCmdParams fmPcdCcFragScratchPoolCmdParams;
+ t_Error err;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+
+ memset(&fmPcdCcFragScratchPoolCmdParams, 0, sizeof(t_FmPcdCcFragScratchPoolCmdParams));
+
+ fmPcdCcFragScratchPoolCmdParams.bufferPoolId = scratchBpid;
+ if ((err = FmHcPcdCcIpFragScratchPollCmd(p_FmPcd->h_Hc, FALSE, &fmPcdCcFragScratchPoolCmdParams)) != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
return E_OK;
}
-#endif /*UNDER_CONSTRUCTION_FRAG_REASSEMBLY*/
+#endif /* (DPAA_VERSION == 10) */
static void ReleaseManipHandler(t_FmPcdManip *p_Manip, t_FmPcd *p_FmPcd)
{
- if(p_Manip->h_Ad)
+ if (p_Manip->h_Ad)
{
- if(p_Manip->muramAllocate)
+ if (p_Manip->muramAllocate)
FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->h_Ad);
else
XX_Free(p_Manip->h_Ad);
p_Manip->h_Ad = NULL;
}
- if(p_Manip->p_Template)
+ if (p_Manip->p_Template)
{
FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->p_Template);
p_Manip->p_Template = NULL;
}
- if(p_Manip->h_Frag)
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
+ if (p_Manip->h_Frag)
{
- if(p_Manip->fragParams.p_AutoLearnHashTbl)
- FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->fragParams.p_AutoLearnHashTbl);
- if(p_Manip->fragParams.p_ReassmFrmDescrPoolTbl)
- FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->fragParams.p_ReassmFrmDescrPoolTbl);
- if(p_Manip->fragParams.p_ReassmFrmDescrIndxPoolTbl)
- FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->fragParams.p_ReassmFrmDescrIndxPoolTbl);
- if(p_Manip->fragParams.p_TimeOutTbl)
- FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->fragParams.p_TimeOutTbl);
+ if (p_Manip->capwapFragParams.p_AutoLearnHashTbl)
+ FM_MURAM_FreeMem(p_FmPcd->h_FmMuram,
+ p_Manip->capwapFragParams.p_AutoLearnHashTbl);
+ if (p_Manip->capwapFragParams.p_ReassmFrmDescrPoolTbl)
+ FM_MURAM_FreeMem(p_FmPcd->h_FmMuram,
+ p_Manip->capwapFragParams.p_ReassmFrmDescrPoolTbl);
+ if (p_Manip->capwapFragParams.p_ReassmFrmDescrIndxPoolTbl)
+ FM_MURAM_FreeMem(p_FmPcd->h_FmMuram,
+ p_Manip->capwapFragParams.p_ReassmFrmDescrIndxPoolTbl);
+ if (p_Manip->capwapFragParams.p_TimeOutTbl)
+ FM_MURAM_FreeMem(p_FmPcd->h_FmMuram,
+ p_Manip->capwapFragParams.p_TimeOutTbl);
FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->h_Frag);
}
-#ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
- if (p_Manip->ipFragParams.h_Frag)
- {
- if(p_Manip->ipFragParams.h_FragId)
- FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->ipFragParams.h_FragId);
- FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->ipFragParams.h_Frag);
- }
- if (p_Manip->reassm)
- {
- if(p_Manip->ipReassmParams.h_Ipv4AutoLearnHashTbl)
- XX_Free(p_Manip->ipReassmParams.h_Ipv4AutoLearnHashTbl);
- if(p_Manip->ipReassmParams.h_Ipv6AutoLearnHashTbl)
- XX_Free(p_Manip->ipReassmParams.h_Ipv6AutoLearnHashTbl);
- if(p_Manip->ipReassmParams.h_Ipv4AutoLearnSetLockTblPtr)
- XX_Free(p_Manip->ipReassmParams.h_Ipv4AutoLearnSetLockTblPtr);
- if(p_Manip->ipReassmParams.h_Ipv6AutoLearnSetLockTblPtr)
- XX_Free(p_Manip->ipReassmParams.h_Ipv6AutoLearnSetLockTblPtr);
- if(p_Manip->ipReassmParams.h_Ipv4ReassParamsTblPtr)
- FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->ipReassmParams.h_Ipv4ReassParamsTblPtr);
- if(p_Manip->ipReassmParams.h_Ipv6ReassParamsTblPtr)
- FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->ipReassmParams.h_Ipv6ReassParamsTblPtr);
- if(p_Manip->ipReassmParams.h_IpReassCommonParamsTbl)
- FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->ipReassmParams.h_IpReassCommonParamsTbl);
- if(p_Manip->ipReassmParams.h_ReassmFrmDescrIndxPoolTbl)
- FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->ipReassmParams.h_ReassmFrmDescrIndxPoolTbl);
- if(p_Manip->ipReassmParams.h_ReassmFrmDescrPoolTbl)
- XX_Free(p_Manip->ipReassmParams.h_ReassmFrmDescrPoolTbl);
- }
-#endif /* UNDER_CONSTRUCTION_FRAG_REASSEMBLY */
- if(p_Manip->p_StatsTbl)
+#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
+ if (p_Manip->frag)
+ {
+ if (p_Manip->fragParams.p_Frag)
+ {
+#if (DPAA_VERSION == 10)
+ FmPcdFragHcScratchPoolEmpty((t_Handle)p_FmPcd, p_Manip->fragParams.scratchBpid);
+#endif /* (DPAA_VERSION == 10) */
+
+ FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->fragParams.p_Frag);
+ }
+ }
+ else
+ if (p_Manip->reassm)
+ {
+ FmPcdUnregisterReassmPort(p_FmPcd,
+ p_Manip->reassmParams.p_ReassCommonTbl);
+
+ if (p_Manip->reassmParams.timeOutTblAddr)
+ FM_MURAM_FreeMem(
+ p_FmPcd->h_FmMuram,
+ UINT_TO_PTR(p_Manip->reassmParams.timeOutTblAddr));
+ if (p_Manip->reassmParams.reassFrmDescrPoolTblAddr)
+ XX_FreeSmart(
+ UINT_TO_PTR(p_Manip->reassmParams.reassFrmDescrPoolTblAddr));
+ if (p_Manip->reassmParams.p_ReassCommonTbl)
+ FM_MURAM_FreeMem(p_FmPcd->h_FmMuram,
+ p_Manip->reassmParams.p_ReassCommonTbl);
+ if (p_Manip->reassmParams.reassFrmDescrIndxPoolTblAddr)
+ FM_MURAM_FreeMem(
+ p_FmPcd->h_FmMuram,
+ UINT_TO_PTR(p_Manip->reassmParams.reassFrmDescrIndxPoolTblAddr));
+ if (p_Manip->reassmParams.internalBufferPoolManagementIndexAddr)
+ FM_MURAM_FreeMem(
+ p_FmPcd->h_FmMuram,
+ UINT_TO_PTR(p_Manip->reassmParams.internalBufferPoolManagementIndexAddr));
+ if (p_Manip->reassmParams.internalBufferPoolAddr)
+ FM_MURAM_FreeMem(
+ p_FmPcd->h_FmMuram,
+ UINT_TO_PTR(p_Manip->reassmParams.internalBufferPoolAddr));
+ if (p_Manip->reassmParams.hdr == HEADER_TYPE_CAPWAP)
+ {
+
+ }
+ else
+ {
+ if (p_Manip->reassmParams.ip.ipv4AutoLearnHashTblAddr)
+ XX_FreeSmart(
+ UINT_TO_PTR(p_Manip->reassmParams.ip.ipv4AutoLearnHashTblAddr));
+ if (p_Manip->reassmParams.ip.ipv6AutoLearnHashTblAddr)
+ XX_FreeSmart(
+ UINT_TO_PTR(p_Manip->reassmParams.ip.ipv6AutoLearnHashTblAddr));
+ if (p_Manip->reassmParams.ip.ipv4AutoLearnSetLockTblAddr)
+ XX_FreeSmart(
+ UINT_TO_PTR(p_Manip->reassmParams.ip.ipv4AutoLearnSetLockTblAddr));
+ if (p_Manip->reassmParams.ip.ipv6AutoLearnSetLockTblAddr)
+ XX_FreeSmart(
+ UINT_TO_PTR(p_Manip->reassmParams.ip.ipv6AutoLearnSetLockTblAddr));
+ if (p_Manip->reassmParams.ip.p_Ipv4ReassTbl)
+ FM_MURAM_FreeMem(p_FmPcd->h_FmMuram,
+ p_Manip->reassmParams.ip.p_Ipv4ReassTbl);
+ if (p_Manip->reassmParams.ip.p_Ipv6ReassTbl)
+ FM_MURAM_FreeMem(p_FmPcd->h_FmMuram,
+ p_Manip->reassmParams.ip.p_Ipv6ReassTbl);
+ if (p_Manip->reassmParams.ip.h_Ipv6Ad)
+ XX_FreeSmart(p_Manip->reassmParams.ip.h_Ipv6Ad);
+ if (p_Manip->reassmParams.ip.h_Ipv4Ad)
+ XX_FreeSmart(p_Manip->reassmParams.ip.h_Ipv4Ad);
+ }
+ }
+
+ if (p_Manip->p_StatsTbl)
FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->p_StatsTbl);
}
-static t_Error CheckManipParamsAndSetType(t_FmPcdManip *p_Manip, t_FmPcdManipParams *p_ManipParams)
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
+static t_Error CheckManipParamsAndSetType(t_FmPcdManip *p_Manip, t_FmPcdManipParams *p_ManipParams)
{
-
- if(p_ManipParams->rmv)
+ if (p_ManipParams->u.hdr.rmv)
{
- switch(p_ManipParams->rmvParams.type)
+ switch (p_ManipParams->u.hdr.rmvParams.type)
{
- case(e_FM_PCD_MANIP_RMV_FROM_START_OF_FRAME_INCLUDE_SPECIFIC_LOCATION):
- switch(p_ManipParams->rmvParams.rmvSpecificLocationParams.type)
+ case (e_FM_PCD_MANIP_RMV_BY_HDR):
+ switch (p_ManipParams->u.hdr.rmvParams.u.byHdr.type)
+ {
+ case (e_FM_PCD_MANIP_RMV_BY_HDR_FROM_START) :
+ if (p_ManipParams->u.hdr.rmvParams.u.byHdr.u.fromStartByHdr.include)
{
- case(e_FM_PCD_MANIP_LOC_BY_HDR) :
- switch(p_ManipParams->rmvParams.rmvSpecificLocationParams.manipByHdr.hdr)
+ switch (p_ManipParams->u.hdr.rmvParams.u.byHdr.u.fromStartByHdr.hdrInfo.hdr)
+ {
+ case (HEADER_TYPE_CAPWAP_DTLS) :
+ p_Manip->opcode = HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST;
+ p_Manip->muramAllocate = TRUE;
+ if (p_ManipParams->u.hdr.insrt)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("for CAPWAP_DTLS_HDR remove can not be insrt manipualtion after"));
+ if (p_ManipParams->fragOrReasm)
{
- case(HEADER_TYPE_CAPWAP_DTLS) :
-
- p_Manip->type = HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST;
- p_Manip->muramAllocate = TRUE;
-
- if(p_ManipParams->insrt)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("for CAPWAP_DTLS_HDR remove can not be insrt manipualtion after"));
-
- if(p_ManipParams->fragOrReasm)
+ if (!p_ManipParams->fragOrReasmParams.frag)
+ {
+ switch (p_ManipParams->fragOrReasmParams.hdr)
{
- if(!p_ManipParams->fragOrReasmParams.frag)
- {
- switch(p_ManipParams->fragOrReasmParams.hdr)
- {
- case(HEADER_TYPE_CAPWAP):
- p_Manip->type = HMAN_OC_CAPWAP_REASSEMBLY;
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("unsupported header for Reassembly"));
- }
- }
- else
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("for this type of manipulation frag can not be TRUE"));
+ case (HEADER_TYPE_CAPWAP):
+ p_Manip->opcode = HMAN_OC_CAPWAP_REASSEMBLY;
+ break;
+ default:
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("unsupported header for Reassembly"));
}
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("non valid net header of remove location"));
-
+ }
+ else
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("for this type of manipulation frag can not be TRUE"));
}
break;
default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("non valid type of remove location"));
-
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("non valid net header of remove location"));
+ }
}
- break;
- case(e_FM_PCD_MANIP_RMV_INT_FRAME_HDR) :
- if(p_ManipParams->insrt || p_ManipParams->fragOrReasm)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("For the type of remove e_FM_PCD_MANIP_RMV_INT_FRAME_HDR the only valid option rmv = TRUE, insrt = FALSE, fragOrReasm = FALSE"));
- p_Manip->type = HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX;
- p_Manip->muramAllocate = FALSE;
- break;
- case(e_FM_PCD_MANIP_RMV_FROM_START_OF_FRAME_TILL_SPECIFIC_LOCATION) :
- if (p_ManipParams->fragOrReasm ||
- ((p_ManipParams->insrt) && p_ManipParams->insrtParams.type != e_FM_PCD_MANIP_INSRT_TO_START_OF_FRAME_INT_FRAME_HDR))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("for the type of remove e_FM_PCD_MANIP_RMV_FROM_START_OF_FRAME_TILL_SPECIFIC_LOCATION the only allowed insertion type is e_FM_PCD_MANIP_INSRT_TO_START_OF_FRAME_INT_FRAME_HDR"));
- p_Manip->type = HMAN_OC_RMV_N_OR_INSRT_INT_FRM_HDR;
- p_Manip->muramAllocate = TRUE;
- break;
- default:
+ else
+ {
+ switch (p_ManipParams->u.hdr.rmvParams.u.byHdr.u.fromStartByHdr.hdrInfo.hdr)
+ {
+ case (HEADER_TYPE_CAPWAP_DTLS) :
+ case (HEADER_TYPE_CAPWAP) :
+ if (p_ManipParams->fragOrReasm || p_ManipParams->u.hdr.insrt)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("for the type of remove e_FM_PCD_MANIP_RMV_FROM_START_OF_FRAME_TILL_CAPWAP can not be insert or fragOrReasm TRUE"));
+ p_Manip->opcode = HMAN_OC_RMV_N_OR_INSRT_INT_FRM_HDR;
+ p_Manip->muramAllocate = TRUE;
+ p_ManipParams->u.hdr.insrt = TRUE; //internal frame header
+ break;
+ default :
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("invalid type of remove manipulation"));
+ }
+ }
+ break;
+ default :
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("invalid type of remove manipulation"));
+ }
+ break;
+ default:
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("invalid type of remove manipulation"));
}
}
- else if(p_ManipParams->insrt)
+ else if (p_ManipParams->u.hdr.insrt)
{
- switch(p_ManipParams->insrtParams.type)
+ switch (p_ManipParams->u.hdr.insrtParams.type)
{
- case(e_FM_PCD_MANIP_INSRT_TO_START_OF_FRAME_TEMPLATE) :
-
- p_Manip->type = HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER;
- p_Manip->muramAllocate = FALSE;
+ case (e_FM_PCD_MANIP_INSRT_BY_TEMPLATE) :
- if(p_ManipParams->fragOrReasm)
+ p_Manip->opcode = HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER;
+ p_Manip->muramAllocate = FALSE;
+ if (p_ManipParams->fragOrReasm)
+ {
+ if (p_ManipParams->fragOrReasmParams.frag)
{
- if(p_ManipParams->fragOrReasmParams.frag)
+ switch (p_ManipParams->fragOrReasmParams.hdr)
{
- switch(p_ManipParams->fragOrReasmParams.hdr)
- {
- case(HEADER_TYPE_CAPWAP):
- p_Manip->type = HMAN_OC_CAPWAP_FRAGMENTATION;
- break;
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid header for fragmentation"));
- }
+ case (HEADER_TYPE_CAPWAP):
+ p_Manip->opcode = HMAN_OC_CAPWAP_FRAGMENTATION;
+ break;
+ default:
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid header for fragmentation"));
}
- else
- RETURN_ERROR(MAJOR, E_INVALID_STATE,("can not reach this point"));
}
+ else
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,("can not reach this point"));
+ }
break;
- case(e_FM_PCD_MANIP_INSRT_TO_START_OF_FRAME_INT_FRAME_HDR) :
- if(p_ManipParams->fragOrReasm)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("For this type of insert can not be fragOrReasm = TRUE"));
- p_Manip->type = HMAN_OC_RMV_N_OR_INSRT_INT_FRM_HDR;
- p_Manip->muramAllocate = TRUE;
- break;
+
default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("for only isert manipulation unsupported type"));
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("for only isert manipulation unsupported type"));
}
}
- else if(p_ManipParams->fragOrReasm)
+ else if (p_ManipParams->fragOrReasm)
{
- if(p_ManipParams->fragOrReasmParams.frag)
+ if (p_ManipParams->fragOrReasmParams.frag)
{
- switch(p_ManipParams->fragOrReasmParams.hdr)
- {
- case(HEADER_TYPE_CAPWAP):
- p_Manip->type = HMAN_OC_CAPWAP_FRAGMENTATION;
- p_Manip->muramAllocate = FALSE;
- break;
-#ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
- case(HEADER_TYPE_IPv4):
- p_Manip->type = HMAN_OC_IP_FRAGMENTATION;
- p_Manip->muramAllocate = TRUE;
- break;
-#endif /* UNDER_CONSTRUCTION_FRAG_REASSEMBLY */
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Unsupported header for fragmentation"));
- }
+ switch (p_ManipParams->fragOrReasmParams.hdr)
+ {
+ case (HEADER_TYPE_CAPWAP):
+ p_Manip->opcode = HMAN_OC_CAPWAP_FRAGMENTATION;
+ p_Manip->muramAllocate = FALSE;
+ break;
+ default:
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Unsupported header for fragmentation"));
+ }
}
else
{
switch (p_ManipParams->fragOrReasmParams.hdr)
{
- case(HEADER_TYPE_CAPWAP):
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Reassembly has to be with additional operation - rmv = TRUE, type of remove - e_FM_PCD_MANIP_RMV_FROM_START_OF_FRAME_INCLUDE_SPECIFIC_LOCATION,type = e_FM_PCD_MANIP_LOC_BY_HDR, hdr = HEADER_TYPE_CAPWAP_DTLS"));
-#ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
- case(HEADER_TYPE_IPv4):
- p_Manip->type = HMAN_OC_IP_REASSEMBLY;
- p_Manip->muramAllocate = TRUE;
- p_Manip->ipReassmParams.hdr = HEADER_TYPE_IPv4;
- break;
- case(HEADER_TYPE_IPv6):
- p_Manip->type = HMAN_OC_IP_REASSEMBLY;
- p_Manip->muramAllocate = TRUE;
- p_Manip->ipReassmParams.hdr = HEADER_TYPE_IPv6;
- break;
-#endif /* UNDER_CONSTRUCTION_FRAG_REASSEMBLY */
+ case (HEADER_TYPE_CAPWAP):
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Reassembly has to be with additional operation - rmv = TRUE, type of remove - e_FM_PCD_MANIP_RMV_FROM_START_OF_FRAME_INCLUDE_SPECIFIC_LOCATION,type = e_FM_PCD_MANIP_LOC_BY_HDR, hdr = HEADER_TYPE_CAPWAP_DTLS"));
default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Unsupported header for reassembly"));
-
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Unsupported header for reassembly"));
}
}
}
else
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("User didn't ask for any manipulation"));
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("User didn't ask for any manipulation"));
- p_Manip->insrt = p_ManipParams->insrt;
- p_Manip->rmv = p_ManipParams->rmv;
+ p_Manip->insrt = p_ManipParams->u.hdr.insrt;
+ p_Manip->rmv = p_ManipParams->u.hdr.rmv;
return E_OK;
}
-static t_Error UpdateIndxStats( t_Handle h_FmPcd,
- t_Handle h_FmPort,
- t_FmPcdManip *p_Manip)
+
+#else /* not (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
+static t_Error CheckManipParamsAndSetType(t_FmPcdManip *p_Manip,
+ t_FmPcdManipParams *p_ManipParams)
{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- uint32_t tmpReg32 = 0;
- t_AdOfTypeContLookup *p_Ad;
- t_FmPortGetSetCcParams fmPortGetSetCcParams;
- t_Error err;
+ switch (p_ManipParams->type)
+ {
+ case e_FM_PCD_MANIP_HDR:
+ /* Check that next-manip is not already used */
+ if (p_ManipParams->h_NextManip)
+ {
+ if (!MANIP_IS_FIRST(p_ManipParams->h_NextManip))
+ RETURN_ERROR(
+ MAJOR, E_INVALID_STATE,
+ ("h_NextManip is already a part of another chain"));
+ if ((MANIP_GET_TYPE(p_ManipParams->h_NextManip)
+ != e_FM_PCD_MANIP_HDR) &&
+ (MANIP_GET_TYPE(p_ManipParams->h_NextManip)
+ != e_FM_PCD_MANIP_FRAG))
+ RETURN_ERROR(
+ MAJOR,
+ E_NOT_SUPPORTED,
+ ("For a Header Manipulation node - no support of h_NextManip of type other than Header Manipulation or Fragmentation."));
+ }
+
+ if (p_ManipParams->u.hdr.rmv)
+ {
+ switch (p_ManipParams->u.hdr.rmvParams.type)
+ {
+ case (e_FM_PCD_MANIP_RMV_BY_HDR):
+ switch (p_ManipParams->u.hdr.rmvParams.u.byHdr.type)
+ {
+ case (e_FM_PCD_MANIP_RMV_BY_HDR_SPECIFIC_L2):
+ break;
+#if (DPAA_VERSION >= 11)
+ case (e_FM_PCD_MANIP_RMV_BY_HDR_CAPWAP):
+ break;
+ case (e_FM_PCD_MANIP_RMV_BY_HDR_FROM_START):
+ {
+ t_Error err;
+ uint8_t prsArrayOffset;
+
+ err =
+ GetPrOffsetByHeaderOrField(
+ &p_ManipParams->u.hdr.rmvParams.u.byHdr.u.hdrInfo,
+ &prsArrayOffset);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ break;
+ }
+#endif /* (DPAA_VERSION >= 11) */
+ default:
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("invalid type of remove manipulation"));
+ }
+ break;
+ case (e_FM_PCD_MANIP_RMV_GENERIC):
+ break;
+ default:
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("invalid type of remove manipulation"));
+ }
+ p_Manip->opcode = HMAN_OC;
+ p_Manip->muramAllocate = TRUE;
+ p_Manip->rmv = TRUE;
+ }
+ else
+ if (p_ManipParams->u.hdr.insrt)
+ {
+ switch (p_ManipParams->u.hdr.insrtParams.type)
+ {
+ case (e_FM_PCD_MANIP_INSRT_BY_HDR):
+ {
+ switch (p_ManipParams->u.hdr.insrtParams.u.byHdr.type)
+ {
+ case (e_FM_PCD_MANIP_INSRT_BY_HDR_SPECIFIC_L2):
+ /* nothing to check */
+ break;
+#if (DPAA_VERSION >= 11)
+ case (e_FM_PCD_MANIP_INSRT_BY_HDR_IP):
+ if (p_ManipParams->u.hdr.insrtParams.u.byHdr.u.ipParams.insrt.size
+ % 4)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("IP inserted header must be of size which is a multiple of four bytes"));
+ break;
+ case (e_FM_PCD_MANIP_INSRT_BY_HDR_CAPWAP):
+ if (p_ManipParams->u.hdr.insrtParams.u.byHdr.u.insrt.size
+ % 4)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("CAPWAP inserted header must be of size which is a multiple of four bytes"));
+ break;
+ case (e_FM_PCD_MANIP_INSRT_BY_HDR_UDP):
+ case (e_FM_PCD_MANIP_INSRT_BY_HDR_UDP_LITE):
+ if (p_ManipParams->u.hdr.insrtParams.u.byHdr.u.insrt.size
+ != 8)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("Inserted header must be of size 8"));
+ break;
+#endif /* (DPAA_VERSION >= 11) */
+ default:
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("unsupported insert by header type"));
+ }
+ }
+ case (e_FM_PCD_MANIP_INSRT_GENERIC):
+ break;
+ default:
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("for only insert manipulation unsupported type"));
+ }
+ p_Manip->opcode = HMAN_OC;
+ p_Manip->muramAllocate = TRUE;
+ p_Manip->insrt = TRUE;
+ }
+ else
+ if (p_ManipParams->u.hdr.fieldUpdate)
+ {
+ /* Check parameters */
+ if (p_ManipParams->u.hdr.fieldUpdateParams.type
+ == e_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN)
+ {
+ if ((p_ManipParams->u.hdr.fieldUpdateParams.u.vlan.updateType
+ == e_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN_VPRI)
+ && (p_ManipParams->u.hdr.fieldUpdateParams.u.vlan.u.vpri
+ > 7))
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("vpri should get values of 0-7 "));
+ if (p_ManipParams->u.hdr.fieldUpdateParams.u.vlan.updateType
+ == e_FM_PCD_MANIP_HDR_FIELD_UPDATE_DSCP_TO_VLAN)
+ {
+ int i;
+
+ if (p_ManipParams->u.hdr.fieldUpdateParams.u.vlan.u.dscpToVpri.vpriDefVal
+ > 7)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("vpriDefVal should get values of 0-7 "));
+ for (i = 0; i < FM_PCD_MANIP_DSCP_TO_VLAN_TRANS;
+ i++)
+ if (p_ManipParams->u.hdr.fieldUpdateParams.u.vlan.u.dscpToVpri.dscpToVpriTable[i]
+ & 0xf0)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("dscpToVpriTabl value out of range (0-15)"));
+ }
+
+ }
+
+ p_Manip->opcode = HMAN_OC;
+ p_Manip->muramAllocate = TRUE;
+ p_Manip->fieldUpdate = TRUE;
+ }
+ else
+ if (p_ManipParams->u.hdr.custom)
+ {
+ if (p_ManipParams->u.hdr.customParams.type == e_FM_PCD_MANIP_HDR_CUSTOM_GEN_FIELD_REPLACE)
+ {
+
+ if ((p_ManipParams->u.hdr.customParams.u.genFieldReplace.size == 0) ||
+ (p_ManipParams->u.hdr.customParams.u.genFieldReplace.size > 8))
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("size should get values of 1-8 "));
+
+ if (p_ManipParams->u.hdr.customParams.u.genFieldReplace.srcOffset > 7)
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("srcOffset should be <= 7"));
+
+ if ((p_ManipParams->u.hdr.customParams.u.genFieldReplace.srcOffset +
+ p_ManipParams->u.hdr.customParams.u.genFieldReplace.size) > 8)
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("(srcOffset + size) should be <= 8"));
+
+ if ((p_ManipParams->u.hdr.customParams.u.genFieldReplace.dstOffset +
+ p_ManipParams->u.hdr.customParams.u.genFieldReplace.size) > 256)
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("(dstOffset + size) should be <= 256"));
+
+ }
+
+ p_Manip->opcode = HMAN_OC;
+ p_Manip->muramAllocate = TRUE;
+ p_Manip->custom = TRUE;
+ }
+ break;
+ case e_FM_PCD_MANIP_REASSEM:
+ if (p_ManipParams->h_NextManip)
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
+ ("next manip with reassembly"));
+ switch (p_ManipParams->u.reassem.hdr)
+ {
+ case (HEADER_TYPE_IPv4):
+ p_Manip->reassmParams.hdr = HEADER_TYPE_IPv4;
+ p_Manip->opcode = HMAN_OC_IP_REASSEMBLY;
+ break;
+ case (HEADER_TYPE_IPv6):
+ p_Manip->reassmParams.hdr = HEADER_TYPE_IPv6;
+ p_Manip->opcode = HMAN_OC_IP_REASSEMBLY;
+ break;
+#if (DPAA_VERSION >= 11)
+ case (HEADER_TYPE_CAPWAP):
+ p_Manip->reassmParams.hdr = HEADER_TYPE_CAPWAP;
+ p_Manip->opcode = HMAN_OC_CAPWAP_REASSEMBLY;
+ break;
+#endif /* (DPAA_VERSION >= 11) */
+ default:
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
+ ("header for reassembly"));
+ }
+ break;
+ case e_FM_PCD_MANIP_FRAG:
+ if (p_ManipParams->h_NextManip)
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
+ ("next manip with fragmentation"));
+ switch (p_ManipParams->u.frag.hdr)
+ {
+ case (HEADER_TYPE_IPv4):
+ case (HEADER_TYPE_IPv6):
+ p_Manip->opcode = HMAN_OC_IP_FRAGMENTATION;
+ break;
+#if (DPAA_VERSION >= 11)
+ case (HEADER_TYPE_CAPWAP):
+ p_Manip->opcode = HMAN_OC_CAPWAP_FRAGMENTATION;
+ break;
+#endif /* (DPAA_VERSION >= 11) */
+ default:
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
+ ("header for fragmentation"));
+ }
+ p_Manip->muramAllocate = TRUE;
+ break;
+ case e_FM_PCD_MANIP_SPECIAL_OFFLOAD:
+ switch (p_ManipParams->u.specialOffload.type)
+ {
+ case (e_FM_PCD_MANIP_SPECIAL_OFFLOAD_IPSEC):
+ p_Manip->opcode = HMAN_OC_IPSEC_MANIP;
+ p_Manip->muramAllocate = TRUE;
+ break;
+#if (DPAA_VERSION >= 11)
+ case (e_FM_PCD_MANIP_SPECIAL_OFFLOAD_CAPWAP):
+ p_Manip->opcode = HMAN_OC_CAPWAP_MANIP;
+ p_Manip->muramAllocate = TRUE;
+ break;
+#endif /* (DPAA_VERSION >= 11) */
+ default:
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
+ ("special offload type"));
+ }
+ break;
+ default:
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("manip type"));
+ }
+
+ return E_OK;
+}
+#endif /* not (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
+
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
+
+static t_Error UpdateIndxStats(t_Handle h_FmPcd,
+ t_Handle h_FmPort,
+ t_FmPcdManip *p_Manip)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ uint32_t tmpReg32 = 0;
+ t_AdOfTypeContLookup *p_Ad;
+ t_FmPortGetSetCcParams fmPortGetSetCcParams;
+ t_Error err;
SANITY_CHECK_RETURN_ERROR(p_Manip,E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad,E_INVALID_HANDLE);
- p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
- if(p_Manip->h_FmPcd != h_FmPcd)
- RETURN_ERROR(MAJOR, E_INVALID_STATE,
- ("handler of PCD previously was initiated by different value"));
+ p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
+ if (p_Manip->h_FmPcd != h_FmPcd)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("handler of PCD previously was initiated by different value"));
memset(&fmPortGetSetCcParams, 0, sizeof(t_FmPortGetSetCcParams));
- if(!p_Manip->p_StatsTbl)
+ if (!p_Manip->p_StatsTbl)
{
fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNDN;
fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_CC;
err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
tmpReg32 = GET_UINT32(p_Ad->ccAdBase);
- p_Manip->p_StatsTbl = (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
- (uint32_t)p_Manip->owner * FM_PCD_MANIP_INDEXED_STATS_ENTRY_SIZE,
- 4);
- if(!p_Manip->p_StatsTbl)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
+ p_Manip->p_StatsTbl =
+ (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
+ (uint32_t)p_Manip->owner * FM_PCD_MANIP_INDEXED_STATS_ENTRY_SIZE,
+ 4);
+ if (!p_Manip->p_StatsTbl)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for Manipulation indexed statistics table"));
- IOMemSet32(p_Manip->p_StatsTbl, 0, (uint32_t)(p_Manip->owner * 4));
+ MemSet8(p_Manip->p_StatsTbl, 0, (uint32_t)(p_Manip->owner * 4));
tmpReg32 |= (uint32_t)(XX_VirtToPhys(p_Manip->p_StatsTbl) - p_FmPcd->physicalMuramBase);
- if(p_Manip->cnia)
- tmpReg32 |= FM_PCD_MANIP_INDEXED_STATS_CNIA;
+ if (p_Manip->cnia)
+ tmpReg32 |= FM_PCD_MANIP_INDEXED_STATS_CNIA;
- tmpReg32 |= FM_PCD_MANIP_INDEXED_STATS_DPD;
+ tmpReg32 |= FM_PCD_MANIP_INDEXED_STATS_DPD;
WRITE_UINT32(p_Ad->ccAdBase, tmpReg32);
-
}
else
{
fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNDN;
fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_CC;
err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
- }
- return E_OK;
-}
-
-static t_Error FmPcdManipInitUpdate(t_Handle h_FmPcd, t_Handle h_FmPort, t_Handle h_Manip, t_Handle h_Ad, bool validate, int level, t_Handle h_FmTree)
-{
- t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
- t_Error err = E_OK;
-
- SANITY_CHECK_RETURN_ERROR(h_Manip,E_INVALID_HANDLE);
- UNUSED(h_FmPcd);
- UNUSED(h_FmTree);
-
- switch(p_Manip->type)
- {
- case(HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
- if(level != 1)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("For CAPWAP reassembly the manipulation has to be in the first level of the tree"));
- err = UpdateInitMvIntFrameHeaderFromFrameToBufferPrefix(h_FmPort, p_Manip, h_Ad, validate);
- break;
-#ifdef FM_CAPWAP_SUPPORT
- case(HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER):
- if(!p_Manip->h_Frag)
- break;
- case(HMAN_OC_CAPWAP_FRAGMENTATION):
- if(level != 2)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("For CAPWAP fragmentation the manipulation has to be in the first level of the tree"));
- err = UpdateInitCapwapFragmentation(h_FmPort, p_Manip, h_Ad, validate, h_FmTree);
- break;
- case(HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
- if(p_Manip->h_Frag)
- {
- if(level != 2)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("For CAPWAP reassembly the manipulation has to be in the first level of the tree"));
- err = UpdateInitCapwapReasm(h_FmPcd, h_FmPort, p_Manip, h_Ad, validate);
- }
- break;
-#endif /* FM_CAPWAP_SUPPORT */
-#if (defined(UNDER_CONSTRUCTION_FRAG_REASSEMBLY) || defined(UNDER_CONSTRUCTION_IPSEC))
- case(HMAN_OC_IPSEC):
- err = UpdateInitIPSec(h_FmPort, p_Manip);
- if (err != E_OK)
- RETURN_ERROR(MAJOR, err, ("UpdateInitIPSec failed"));
- if(!p_Manip->h_Frag)
- break;
-#ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
- case(HMAN_OC_IP_FRAGMENTATION):
- err = UpdateInitIpFragmentation(h_FmPort, p_Manip);
- break;
- case(HMAN_OC_IP_REASSEMBLY):
- err = UpdateInitIpReasm(h_FmPcd, h_FmPort, p_Manip, h_Ad, validate);
- break;
-#endif /* UNDER_CONSTRUCTION_FRAG_REASSEMBLY */
-#endif /* (defined(UNDER_CONSTRUCTION_FRAG_REASSEMBLY) || defined(UNDER_CONSTRUCTION_IPSEC))*/
- case(HMAN_OC_CAPWAP_INDEXED_STATS):
- if(level != 2)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("For index statistics the manipulation has to be in the first level of the tree"));
- err = UpdateIndxStats(h_FmPcd, h_FmPort, p_Manip);
- break;
- default:
- return E_OK;
- }
- return err;
-}
-
-static t_Error FmPcdManipModifyUpdate(t_Handle h_Manip, t_Handle h_Ad, bool validate, int level, t_Handle h_FmTree)
-{
-
- t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
- t_Error err = E_OK;
-
- switch(p_Manip->type)
- {
- case(HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("modify node with this type of manipulation is not suppported"));
- case(HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
-
- if(p_Manip->h_Frag)
- {
- if(!(p_Manip->shadowUpdateParams & NUM_OF_TASKS) && !(p_Manip->shadowUpdateParams & BUFFER_POOL_ID_FOR_MANIP) &&
- !(p_Manip->shadowUpdateParams & OFFSET_OF_DATA) && !(p_Manip->shadowUpdateParams & OFFSET_OF_PR))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("modify node with this type of manipulation requires manipulation be updated previousely in SetPcd function"));
- if(level != 2)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("For CAPWAP reassembly the manipulation has to be in the first level of the tree"));
- }
- break;
-#ifdef FM_CAPWAP_SUPPORT
- case(HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER):
- if(p_Manip->h_Frag)
- {
- if(level != 2)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("For CAPWAP fragmentation the manipulation has to be in the first level of the tree"));
- err = UpdateModifyCapwapFragmenation(p_Manip, h_Ad, validate, h_FmTree);
- }
- break;
-#endif /* FM_CAPWAP_SUPPORT */
- default:
- return E_OK;
-
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
- return err;
-
-}
-
-static t_Error GetPrOffsetByHeaderOrField(t_FmPcdManipLocationParams *p_ManipParams, uint8_t *parseArrayOffset)
-{
- e_NetHeaderType hdr = p_ManipParams->manipByHdr.hdr;
- e_FmPcdHdrIndex hdrIndex = p_ManipParams->manipByHdr.hdrIndex;
- bool byField = p_ManipParams->manipByHdr.byField;
- t_FmPcdFields field;
-
- if(byField)
- field = p_ManipParams->manipByHdr.fullField;
- if(byField)
- {
- switch(hdr)
- {
- case(HEADER_TYPE_ETH):
- switch(field.eth)
- {
- case(NET_HEADER_FIELD_ETH_TYPE):
- *parseArrayOffset = CC_PC_PR_ETYPE_LAST_OFFSET;
- break;
- default:
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Header manipulation of the type Ethernet with this field not supported"));
- }
- break;
- case(HEADER_TYPE_VLAN):
- switch(field.vlan)
- {
- case(NET_HEADER_FIELD_VLAN_TCI) :
- if((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
- *parseArrayOffset = CC_PC_PR_VLAN1_OFFSET;
- else if(hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
- *parseArrayOffset = CC_PC_PR_VLAN2_OFFSET;
- break;
- default:
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Header manipulation of the type VLAN with this field not supported"));
- }
- break;
- default:
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Header manipulation of this header by field not supported"));
- }
- }
- else
- {
- switch(hdr){
- case(HEADER_TYPE_ETH):
- *parseArrayOffset = (uint8_t)CC_PC_PR_ETH_OFFSET;
- break;
- case(HEADER_TYPE_USER_DEFINED_SHIM1):
- *parseArrayOffset = (uint8_t)CC_PC_PR_USER_DEFINED_SHIM1_OFFSET;
- break;
- case(HEADER_TYPE_USER_DEFINED_SHIM2):
- *parseArrayOffset = (uint8_t)CC_PC_PR_USER_DEFINED_SHIM2_OFFSET;
- break;
- /* TODO - to take care about SHIM3
- case(HEADER_TYPE_USER_DEFINED_SHIM3):
- *parseArrayOffset = (uint8_t)CC_PC_PR_USER_DEFINED_SHIM3_OFFSET;
- break;
- */
- case(HEADER_TYPE_LLC_SNAP):
- *parseArrayOffset = CC_PC_PR_USER_LLC_SNAP_OFFSET;
- break;
- case(HEADER_TYPE_PPPoE):
- *parseArrayOffset = CC_PC_PR_PPPOE_OFFSET;
- break;
- case(HEADER_TYPE_MPLS):
- if((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
- *parseArrayOffset = CC_PC_PR_MPLS1_OFFSET;
- else if(hdrIndex == e_FM_PCD_HDR_INDEX_LAST)
- *parseArrayOffset = CC_PC_PR_MPLS_LAST_OFFSET;
- break;
- case(HEADER_TYPE_IPv4):
- case(HEADER_TYPE_IPv6):
- if((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
- *parseArrayOffset = CC_PC_PR_IP1_OFFSET;
- else if(hdrIndex == e_FM_PCD_HDR_INDEX_2)
- *parseArrayOffset = CC_PC_PR_IP_LAST_OFFSET;
- break;
- case(HEADER_TYPE_MINENCAP):
- *parseArrayOffset = CC_PC_PR_MINENC_OFFSET;
- break;
- case(HEADER_TYPE_GRE):
- *parseArrayOffset = CC_PC_PR_GRE_OFFSET;
- break;
- case(HEADER_TYPE_TCP):
- case(HEADER_TYPE_UDP):
- case(HEADER_TYPE_IPSEC_AH):
- case(HEADER_TYPE_IPSEC_ESP):
- case(HEADER_TYPE_DCCP):
- case(HEADER_TYPE_SCTP):
- *parseArrayOffset = CC_PC_PR_L4_OFFSET;
- break;
- default:
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Header manipulation of this header is not supported"));
- }
- }
return E_OK;
}
-static t_Error RmvHdrTillSpecLocNOrInsrtIntFrmHdr(t_FmPcdManipRmvParams *p_ManipParams, t_FmPcdManip *p_Manip)
+static t_Error RmvHdrTillSpecLocNOrInsrtIntFrmHdr(t_FmPcdManipHdrRmvParams *p_ManipParams, t_FmPcdManip *p_Manip)
{
- t_AdOfTypeContLookup *p_Ad;
- uint32_t tmpReg32 = 0;
- uint8_t prsArrayOffset = 0;
- t_Error err;
+ t_AdOfTypeContLookup *p_Ad;
+ uint32_t tmpReg32 = 0;
+ uint8_t prsArrayOffset = 0;
+ t_Error err;
SANITY_CHECK_RETURN_ERROR(p_Manip,E_NULL_POINTER);
SANITY_CHECK_RETURN_ERROR(p_ManipParams,E_NULL_POINTER);
SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad,E_INVALID_HANDLE);
p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
- if(p_Manip->rmv)
+ if (p_Manip->rmv)
{
- switch(p_ManipParams->rmvSpecificLocationParams.type)
- {
- case(e_FM_PCD_MANIP_LOC_BY_HDR) :
- err = GetPrOffsetByHeaderOrField(&p_ManipParams->rmvSpecificLocationParams, &prsArrayOffset);
- break;
- case(e_FM_PCD_MANIP_LOC_NON_HDR) :
- err = GetPrOffsetByNonHeader(&prsArrayOffset);
- break;
- default :
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid type of location header manipulation of type Remove"));
- }
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
+ err = GetPrOffsetByHeaderOrField(&p_ManipParams->u.byHdr.u.fromStartByHdr.hdrInfo, &prsArrayOffset);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
tmpReg32 |= (uint32_t)prsArrayOffset << 24;
tmpReg32 |= HMAN_RMV_HDR;
}
- if(p_Manip->insrt)
- tmpReg32 |= HMAN_INSRT_INT_FRM_HDR;
+ if (p_Manip->insrt)
+ tmpReg32 |= HMAN_INSRT_INT_FRM_HDR;
tmpReg32 |= (uint32_t)HMAN_OC_RMV_N_OR_INSRT_INT_FRM_HDR;
@@ -1527,12 +3026,13 @@ static t_Error RmvHdrTillSpecLocNOrInsrtIntFrmHdr(t_FmPcdManipRmvParams *p_Mani
return E_OK;
}
-static t_Error MvIntFrameHeaderFromFrameToBufferPrefix(t_FmPcdManip *p_Manip, bool caamUsed)
+static t_Error MvIntFrameHeaderFromFrameToBufferPrefix(t_FmPcdManip *p_Manip,
+ bool caamUsed)
{
- t_AdOfTypeContLookup *p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
- uint32_t tmpReg32 = 0;
+ t_AdOfTypeContLookup *p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
+ uint32_t tmpReg32 = 0;
- SANITY_CHECK_RETURN_ERROR(p_Ad,E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Ad, E_INVALID_HANDLE);
p_Manip->updateParams |= OFFSET_OF_PR | INTERNAL_CONTEXT_OFFSET;
@@ -1540,32 +3040,26 @@ static t_Error MvIntFrameHeaderFromFrameToBufferPrefix(t_FmPcdManip *p_Manip, bo
tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
*(uint32_t *)&p_Ad->ccAdBase = tmpReg32;
- /*TODO - update offsetInBufferPrefixForIntFrameHdr when port connected to tree
- tmpReg32 = 0;
- tmpReg32 |= offsetInBufferPrefixForIntFrameHdr;
- *(uint32_t *)&p_Ad->matchTblPtr = tmpReg32;*/
-
tmpReg32 = 0;
tmpReg32 |= HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX;
tmpReg32 |= (uint32_t)0x16 << 16;
*(uint32_t *)&p_Ad->pcAndOffsets = tmpReg32;
if (caamUsed)
- *(uint32_t *)&p_Ad->gmask = 0xf0000000;
+ *(uint32_t *)&p_Ad->gmask = 0xf0000000;
return E_OK;
}
-#ifdef FM_CAPWAP_SUPPORT
static t_Error CapwapRmvDtlsHdr(t_FmPcd *p_FmPcd, t_FmPcdManip *p_Manip)
{
- t_AdOfTypeContLookup *p_Ad;
- uint32_t tmpReg32 = 0;
- t_Error err = E_OK;
+ t_AdOfTypeContLookup *p_Ad;
+ uint32_t tmpReg32 = 0;
+ t_Error err = E_OK;
SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad,E_INVALID_HANDLE);
- p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
+ p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
tmpReg32 = 0;
tmpReg32 |= (uint32_t)HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST;
@@ -1575,7 +3069,7 @@ static t_Error CapwapRmvDtlsHdr(t_FmPcd *p_FmPcd, t_FmPcdManip *p_Manip)
tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
- if(p_Manip->h_Frag)
+ if (p_Manip->h_Frag)
{
p_Manip->updateParams |= INTERNAL_CONTEXT_OFFSET;
tmpReg32 |= (uint32_t)(XX_VirtToPhys(p_Manip->h_Frag) - (p_FmPcd->physicalMuramBase));
@@ -1586,74 +3080,85 @@ static t_Error CapwapRmvDtlsHdr(t_FmPcd *p_FmPcd, t_FmPcdManip *p_Manip)
return err;
}
-static t_Error CapwapReassembly(t_CapwapReassemblyParams *p_ManipParams,t_FmPcdManip *p_Manip,t_FmPcd *p_FmPcd, uint8_t poolIndex)
+static t_Error CapwapReassembly(t_CapwapReassemblyParams *p_ManipParams,
+ t_FmPcdManip *p_Manip,
+ t_FmPcd *p_FmPcd,
+ uint8_t poolId)
{
- t_Handle p_Table;
- uint32_t tmpReg32 = 0;
- int i = 0;
- uint8_t log2Num;
- uint8_t numOfSets;
- uint32_t j = 0;
+ t_Handle p_Table;
+ uint32_t tmpReg32 = 0;
+ int i = 0;
+ uint8_t log2Num;
+ uint8_t numOfSets;
+ uint32_t j = 0;
+ uint32_t bitFor1Micro;
- SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc,E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
- if(!p_FmPcd->h_Hc)
+ if (!p_FmPcd->h_Hc)
RETURN_ERROR(MAJOR, E_INVALID_VALUE,("hc port has to be initialized in this mode"));
if (!POWER_OF_2(p_ManipParams->timeoutRoutineRequestTime))
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("timeoutRoutineRequestTime has to be power of 2"));
- if(!POWER_OF_2(p_ManipParams->maxNumFramesInProcess))
+ if (!POWER_OF_2(p_ManipParams->maxNumFramesInProcess))
RETURN_ERROR(MAJOR, E_INVALID_VALUE,("maxNumFramesInProcess has to be power of 2"));
- if(!p_ManipParams->timeoutRoutineRequestTime && p_ManipParams->timeoutThresholdForReassmProcess)
+ if (!p_ManipParams->timeoutRoutineRequestTime && p_ManipParams->timeoutThresholdForReassmProcess)
DBG(WARNING, ("if timeoutRoutineRequestTime 0, timeoutThresholdForReassmProcess is uselessly"));
- if(p_ManipParams->numOfFramesPerHashEntry == e_FM_PCD_MANIP_FOUR_WAYS_HASH)
+ if (p_ManipParams->numOfFramesPerHashEntry == e_FM_PCD_MANIP_FOUR_WAYS_HASH)
{
- if((p_ManipParams->maxNumFramesInProcess < 4) ||
- (p_ManipParams->maxNumFramesInProcess > 512))
- RETURN_ERROR(MAJOR,E_INVALID_VALUE, ("In the case of numOfFramesPerHashEntry = e_FM_PCD_MANIP_EIGHT_WAYS_HASH maxNumFramesInProcess has to be in the range 4-512"));
+ if ((p_ManipParams->maxNumFramesInProcess < 4) ||
+ (p_ManipParams->maxNumFramesInProcess > 512))
+ RETURN_ERROR(MAJOR,E_INVALID_VALUE, ("In the case of numOfFramesPerHashEntry = e_FM_PCD_MANIP_EIGHT_WAYS_HASH maxNumFramesInProcess has to be in the range 4-512"));
}
else
{
- if((p_ManipParams->maxNumFramesInProcess < 8) ||
- (p_ManipParams->maxNumFramesInProcess > 2048))
- RETURN_ERROR(MAJOR,E_INVALID_VALUE, ("In the case of numOfFramesPerHashEntry = e_FM_PCD_MANIP_FOUR_WAYS_HASH maxNumFramesInProcess has to be in the range 8-2048"));
+ if ((p_ManipParams->maxNumFramesInProcess < 8) ||
+ (p_ManipParams->maxNumFramesInProcess > 2048))
+ RETURN_ERROR(MAJOR,E_INVALID_VALUE, ("In the case of numOfFramesPerHashEntry = e_FM_PCD_MANIP_FOUR_WAYS_HASH maxNumFramesInProcess has to be in the range 8-2048"));
}
- p_Manip->updateParams |= (NUM_OF_TASKS | BUFFER_POOL_ID_FOR_MANIP | OFFSET_OF_PR | OFFSET_OF_DATA | HW_PORT_ID);
+ bitFor1Micro = FmGetTimeStampScale(p_FmPcd->h_Fm);
+ if (bitFor1Micro == 0)
+ RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("Timestamp scale"));
+
+ p_Manip->updateParams |= (NUM_OF_TASKS | OFFSET_OF_PR | OFFSET_OF_DATA | HW_PORT_ID);
p_Manip->h_Frag = (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
- FM_PCD_MANIP_CAPWAP_REASM_TABLE_SIZE,
- FM_PCD_MANIP_CAPWAP_REASM_TABLE_ALIGN);
- if(!p_Manip->h_Frag)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
+ FM_PCD_MANIP_CAPWAP_REASM_TABLE_SIZE,
+ FM_PCD_MANIP_CAPWAP_REASM_TABLE_ALIGN);
+ if (!p_Manip->h_Frag)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc CAPWAP reassembly parameters table"));
- IOMemSet32(p_Manip->h_Frag, 0, FM_PCD_MANIP_CAPWAP_REASM_TABLE_SIZE);
+ MemSet8(p_Manip->h_Frag, 0, FM_PCD_MANIP_CAPWAP_REASM_TABLE_SIZE);
- p_Table = (t_CapwapReasmPram *)p_Manip->h_Frag;
+ p_Table = (t_CapwapReasmPram *)p_Manip->h_Frag;
- p_Manip->fragParams.p_AutoLearnHashTbl = (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
- (uint32_t)(p_ManipParams->maxNumFramesInProcess * 2 * FM_PCD_MANIP_CAPWAP_REASM_AUTO_LEARNING_HASH_ENTRY_SIZE),
- FM_PCD_MANIP_CAPWAP_REASM_TABLE_ALIGN);
+ p_Manip->capwapFragParams.p_AutoLearnHashTbl =
+ (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
+ (uint32_t)(p_ManipParams->maxNumFramesInProcess * 2 * FM_PCD_MANIP_CAPWAP_REASM_AUTO_LEARNING_HASH_ENTRY_SIZE),
+ FM_PCD_MANIP_CAPWAP_REASM_TABLE_ALIGN);
- IOMemSet32(p_Manip->fragParams.p_AutoLearnHashTbl, 0, (uint32_t)(p_ManipParams->maxNumFramesInProcess * 2 * FM_PCD_MANIP_CAPWAP_REASM_AUTO_LEARNING_HASH_ENTRY_SIZE));
+ if (!p_Manip->capwapFragParams.p_AutoLearnHashTbl)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,("MURAM alloc for CAPWAP automatic learning hash table"));
+ MemSet8(p_Manip->capwapFragParams.p_AutoLearnHashTbl, 0, (uint32_t)(p_ManipParams->maxNumFramesInProcess * 2 * FM_PCD_MANIP_CAPWAP_REASM_AUTO_LEARNING_HASH_ENTRY_SIZE));
- tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->fragParams.p_AutoLearnHashTbl) - p_FmPcd->physicalMuramBase);
+ tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->capwapFragParams.p_AutoLearnHashTbl) - p_FmPcd->physicalMuramBase);
WRITE_UINT32(((t_CapwapReasmPram *)p_Table)->autoLearnHashTblPtr, tmpReg32);
tmpReg32 = 0;
- if(p_ManipParams->timeOutMode == e_FM_PCD_MANIP_TIME_OUT_BETWEEN_FRAMES)
+ if (p_ManipParams->timeOutMode == e_FM_PCD_MANIP_TIME_OUT_BETWEEN_FRAMES)
tmpReg32 |= FM_PCD_MANIP_CAPWAP_REASM_TIME_OUT_BETWEEN_FRAMES;
- if(p_ManipParams->haltOnDuplicationFrag)
- tmpReg32 |= FM_PCD_MANIP_CAPWAP_REASM_HALT_ON_DUPLICATE_FRAG;
- if(p_ManipParams->numOfFramesPerHashEntry == e_FM_PCD_MANIP_EIGHT_WAYS_HASH)
+ if (p_ManipParams->haltOnDuplicationFrag)
+ tmpReg32 |= FM_PCD_MANIP_CAPWAP_REASM_HALT_ON_DUPLICATE_FRAG;
+ if (p_ManipParams->numOfFramesPerHashEntry == e_FM_PCD_MANIP_EIGHT_WAYS_HASH)
{
i = 8;
- tmpReg32 |= FM_PCD_MANIP_CAPWAP_REASM_AUTOMATIC_LEARNIN_HASH_8_WAYS;
+ tmpReg32 |= FM_PCD_MANIP_CAPWAP_REASM_AUTOMATIC_LEARNIN_HASH_8_WAYS;
}
else
- i = 4;
+ i = 4;
numOfSets = (uint8_t)((p_ManipParams->maxNumFramesInProcess * 2) / i);
LOG2(numOfSets, log2Num);
@@ -1661,977 +3166,2406 @@ static t_Error CapwapReassembly(t_CapwapReassemblyParams *p_ManipParams,t_FmPcdM
WRITE_UINT32(((t_CapwapReasmPram *)p_Table)->mode, tmpReg32);
- for(j = 0; j < p_ManipParams->maxNumFramesInProcess * 2; j++)
- {
- if(((j / i) % 2)== 0)
- {
- WRITE_UINT32(*(uint32_t *)PTR_MOVE(p_Manip->fragParams.p_AutoLearnHashTbl, j * FM_PCD_MANIP_CAPWAP_REASM_AUTO_LEARNING_HASH_ENTRY_SIZE), 0x80000000);
- }
- }
+ for (j=0; j<p_ManipParams->maxNumFramesInProcess*2; j++)
+ if (((j / i) % 2)== 0)
+ WRITE_UINT32(*(uint32_t *)PTR_MOVE(p_Manip->capwapFragParams.p_AutoLearnHashTbl, j * FM_PCD_MANIP_CAPWAP_REASM_AUTO_LEARNING_HASH_ENTRY_SIZE), 0x80000000);
- WRITE_UINT32(((t_CapwapReasmPram *)p_Table)->bufferPoolIdAndRisc1SetIndexes, 0x00008000);
+ tmpReg32 = 0x00008000;
+ tmpReg32 |= (uint32_t)poolId << 16;
+ WRITE_UINT32(((t_CapwapReasmPram *)p_Table)->bufferPoolIdAndRisc1SetIndexes, tmpReg32);
WRITE_UINT32(((t_CapwapReasmPram *)p_Table)->risc23SetIndexes, 0x80008000);
WRITE_UINT32(((t_CapwapReasmPram *)p_Table)->risc4SetIndexesAndExtendedStatsTblPtr, 0x80000000);
- p_Manip->fragParams.maxNumFramesInProcess = p_ManipParams->maxNumFramesInProcess;
+ p_Manip->capwapFragParams.maxNumFramesInProcess = p_ManipParams->maxNumFramesInProcess;
- p_Manip->fragParams.poolIndx = poolIndex;
+ p_Manip->capwapFragParams.sgBpid = poolId;
- p_Manip->fragParams.fqidForTimeOutFrames = p_ManipParams->fqidForTimeOutFrames;
- p_Manip->fragParams.timeoutRoutineRequestTime = p_ManipParams->timeoutRoutineRequestTime;
- /*TODO - to take care about this function FmGetTimeStampScale - it return t_Error
- now we have problems with all calls to this fucntion*/
- p_Manip->fragParams.bitFor1Micro = FmGetTimeStampScale(p_FmPcd->h_Fm);
+ p_Manip->capwapFragParams.fqidForTimeOutFrames = p_ManipParams->fqidForTimeOutFrames;
+ p_Manip->capwapFragParams.timeoutRoutineRequestTime = p_ManipParams->timeoutRoutineRequestTime;
+ p_Manip->capwapFragParams.bitFor1Micro = bitFor1Micro;
tmpReg32 = 0;
- tmpReg32 |= (((uint32_t)1<<p_Manip->fragParams.bitFor1Micro) * p_ManipParams->timeoutThresholdForReassmProcess);
+ tmpReg32 |= (((uint32_t)1<<p_Manip->capwapFragParams.bitFor1Micro) * p_ManipParams->timeoutThresholdForReassmProcess);
WRITE_UINT32(((t_CapwapReasmPram *)p_Table)->expirationDelay, tmpReg32);
return E_OK;
-
}
-static t_Error CapwapFragmentation(t_CapwapFragmentationParams *p_ManipParams,t_FmPcdManip *p_Manip,t_FmPcd *p_FmPcd, uint8_t poolIndex)
+static t_Error CapwapFragmentation(t_CapwapFragmentationParams *p_ManipParams,
+ t_FmPcdManip *p_Manip,
+ t_FmPcd *p_FmPcd,
+ uint8_t poolId)
{
- t_AdOfTypeContLookup *p_Ad;
- uint32_t tmpReg32 = 0;
+ t_AdOfTypeContLookup *p_Ad;
+ uint32_t tmpReg32 = 0;
SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad,E_INVALID_HANDLE);
- p_Manip->updateParams |= OFFSET_OF_DATA | BUFFER_POOL_ID_FOR_MANIP;
+ p_Manip->updateParams |= OFFSET_OF_DATA;
p_Manip->frag = TRUE;
p_Manip->h_Frag = (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
- FM_PCD_CC_AD_ENTRY_SIZE,
- FM_PCD_CC_AD_TABLE_ALIGN);
- if(!p_Manip->h_Frag)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
+ FM_PCD_CC_AD_ENTRY_SIZE,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if (!p_Manip->h_Frag)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for CAPWAP fragmentation table descriptor"));
- IOMemSet32(p_Manip->h_Frag, 0, FM_PCD_CC_AD_ENTRY_SIZE);
+ MemSet8(p_Manip->h_Frag, 0, FM_PCD_CC_AD_ENTRY_SIZE);
- p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Frag;
+ p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Frag;
tmpReg32 = 0;
tmpReg32 |= (uint32_t)HMAN_OC_CAPWAP_FRAGMENTATION;
- if(p_ManipParams->headerOptionsCompr)
- tmpReg32 = FM_PCD_MANIP_CAPWAP_FRAG_COMPR_OPTION_FIELD_EN;
+ if (p_ManipParams->headerOptionsCompr)
+ tmpReg32 |= FM_PCD_MANIP_CAPWAP_FRAG_COMPR_OPTION_FIELD_EN;
+ tmpReg32 |= ((uint32_t)poolId << 8);
WRITE_UINT32(p_Ad->pcAndOffsets, tmpReg32);
tmpReg32 = 0;
tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
WRITE_UINT32(p_Ad->ccAdBase, tmpReg32);
-
p_Manip->sizeForFragmentation = p_ManipParams->sizeForFragmentation;
- p_Manip->fragParams.poolIndx = poolIndex;
+ p_Manip->capwapFragParams.sgBpid = poolId;
return E_OK;
}
-#endif /* FM_CAPWAP_SUPPORT */
-#ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
-static t_Error IpFragmentation(t_IpFragmentationParams *p_ManipParams,t_FmPcdManip *p_Manip, t_FmPcd *p_FmPcd, uint8_t poolIndex)
+static t_Error IndxStats(t_FmPcdStatsParams *p_StatsParams,t_FmPcdManip *p_Manip,t_FmPcd *p_FmPcd)
{
- t_AdOfTypeContLookup *p_Ad;
- uint32_t tmpReg32 = 0;
+ t_AdOfTypeContLookup *p_Ad;
+ uint32_t tmpReg32 = 0;
SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad,E_INVALID_HANDLE);
- p_Manip->ipFragParams.h_Frag = (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
- FM_PCD_CC_AD_ENTRY_SIZE,
- FM_PCD_CC_AD_TABLE_ALIGN);
-
- if( !p_Manip->ipFragParams.h_Frag)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
-
- IOMemSet32( p_Manip->ipFragParams.h_Frag, 0, FM_PCD_CC_AD_ENTRY_SIZE);
+ UNUSED(p_FmPcd);
- p_Ad = (t_AdOfTypeContLookup *)p_Manip->ipFragParams.h_Frag;
+ p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
tmpReg32 = 0;
- tmpReg32 |= (uint32_t)HMAN_OC_IP_FRAGMENTATION;
+ tmpReg32 |= (uint32_t)HMAN_OC_CAPWAP_INDEXED_STATS;
+ if (p_StatsParams->type == e_FM_PCD_STATS_PER_FLOWID)
+ tmpReg32 |= (uint32_t)0x16 << 16;
WRITE_UINT32(p_Ad->pcAndOffsets, tmpReg32);
tmpReg32 = 0;
tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
- tmpReg32 |= (p_ManipParams->dontFragAction << 30);
WRITE_UINT32(p_Ad->ccAdBase, tmpReg32);
- p_Manip->frag = TRUE;
+ return E_OK;
+}
- p_Manip->sizeForFragmentation = p_ManipParams->sizeForFragmentation;
- p_Manip->ipFragParams.poolIndx = poolIndex;
+static t_Error InsrtHdrByTempl(t_FmPcdManipHdrInsrtParams *p_ManipParams, t_FmPcdManip *p_Manip, t_FmPcd *p_FmPcd)
+{
+ t_FmPcdManipHdrInsrtByTemplateParams *p_InsrtByTemplate = &p_ManipParams->u.byTemplate;
+ uint8_t tmpReg8 = 0xff;
+ t_AdOfTypeContLookup *p_Ad;
+ bool ipModify = FALSE;
+ uint32_t tmpReg32 = 0, tmpRegNia = 0;
+ uint16_t tmpReg16 = 0;
+ t_Error err = E_OK;
+ uint8_t extraAddedBytes = 0, blockSize = 0, extraAddedBytesAlignedToBlockSize = 0, log2Num = 0;
+ uint8_t *p_Template = NULL;
- /*Pointer to fragment ID*/
- p_Manip->ipFragParams.h_FragId= (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,4, 4);
+ SANITY_CHECK_RETURN_ERROR(p_ManipParams,E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_Manip,E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad,E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd,E_NULL_POINTER);
- if(!p_Manip->ipFragParams.h_FragId)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
+ p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
+ if (p_Manip->insrt)
+ {
+ if ((!p_InsrtByTemplate->size && p_InsrtByTemplate->modifyOuterIp) ||
+ (!p_InsrtByTemplate->size && p_InsrtByTemplate->modifyOuterVlan))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inconsistent parameters : asking for header template modifications with no template for insertion (template size)"));
- IOMemSet32(p_Manip->ipFragParams.h_FragId, 0, 4);
+ if (p_InsrtByTemplate->size && p_InsrtByTemplate->modifyOuterIp && (p_InsrtByTemplate->size <= p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inconsistent parameters : size of template < ipOuterOffset"));
- tmpReg32 = 0;
- tmpReg32 |= (uint32_t)(XX_VirtToPhys(p_Manip->ipFragParams.h_FragId) - (p_FmPcd->physicalMuramBase));
- tmpReg32 |= p_ManipParams->scratchBpid << 24;
- WRITE_UINT32(p_Ad->gmask, tmpReg32);
+ if (p_InsrtByTemplate->size > 128)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Size of header template for insertion can not be more than 128"));
- return E_OK;
-}
+ if (p_InsrtByTemplate->size)
+ {
+ p_Manip->p_Template = (uint8_t *)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
+ p_InsrtByTemplate->size,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if(!p_Manip->p_Template)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
-static t_Error FillReassmManipParams(t_FmPcdManip *p_Manip, t_Handle h_Ad, bool ipv4)
-{
- t_AdOfTypeContLookup *p_Ad = (t_AdOfTypeContLookup *)h_Ad;
- t_FmPcd *p_FmPcd = (t_FmPcd *)p_Manip->h_FmPcd;
- uint32_t tmpReg32;
- t_Error err;
- t_Handle h_IpReassParamsTblPtr;
+ tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->p_Template) - (p_FmPcd->physicalMuramBase));
+ tmpReg32 |= (uint32_t)p_InsrtByTemplate->size << 24;
+ *(uint32_t *)&p_Ad->matchTblPtr = tmpReg32;
+ }
- /* First Ad register */
- tmpReg32 = 0;
- tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
+ tmpReg32 = 0;
- if (ipv4)
- h_IpReassParamsTblPtr = p_Manip->ipReassmParams.h_Ipv4ReassParamsTblPtr;
- else
- h_IpReassParamsTblPtr = p_Manip->ipReassmParams.h_Ipv6ReassParamsTblPtr;
+ p_Template = (uint8_t *)XX_Malloc(p_InsrtByTemplate->size * sizeof(uint8_t));
- err = CreateIpReassParamTable(p_Manip, h_IpReassParamsTblPtr, ipv4);
+ if (!p_Template)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("XX_Malloc allocation FAILED"));
- if (err == E_OK)
- tmpReg32 |= (uint32_t)(XX_VirtToPhys(h_IpReassParamsTblPtr) - (p_FmPcd->physicalMuramBase));
- else
- return err;
+ memcpy(p_Template, p_InsrtByTemplate->hdrTemplate, p_InsrtByTemplate->size * sizeof(uint8_t));
- WRITE_UINT32(p_Ad->ccAdBase, tmpReg32);
+ if (p_InsrtByTemplate->modifyOuterIp)
+ {
+ ipModify = TRUE;
- /* Second Ad register */
- tmpReg32 = (uint32_t)(p_Manip->ipReassmParams.bpid << 8);
- WRITE_UINT32(p_Ad->matchTblPtr, tmpReg32);
+ tmpReg8 = (uint8_t)p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset];
- p_Manip->updateParams = OFFSET_OF_DATA;
+ if((tmpReg8 & 0xf0) == 0x40)
+ tmpReg8 = 4;
+ else if((tmpReg8 & 0xf0) == 0x60)
+ tmpReg8 = 6;
+ else
+ tmpReg8 = 0xff;
- /* Third Ad register */
- tmpReg32 = 0;
- tmpReg32 |= (uint32_t)HMAN_OC_IP_REASSEMBLY;
- tmpReg32 |= (uint64_t)(p_Manip->ipReassmParams.liodnOffset & FM_PCD_MANIP_IP_REASM_LIODN_MASK) << (uint64_t)FM_PCD_MANIP_IP_REASM_LIODN_SHIFT;
- tmpReg32 |= (uint64_t)(p_Manip->ipReassmParams.liodnOffset & FM_PCD_MANIP_IP_REASM_ELIODN_MASK) << (uint64_t)FM_PCD_MANIP_IP_REASM_ELIODN_SHIFT;
- WRITE_UINT32(p_Ad->pcAndOffsets, tmpReg32);
+ if (tmpReg8 != 0xff)
+ {
+ if(p_InsrtByTemplate->modifyOuterIpParams.dscpEcn & 0xff00)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inconsistent parameters : IPV4 present in header template, dscpEcn has to be only 1 byte"));
+ if(p_InsrtByTemplate->modifyOuterIpParams.recalculateLength)
+ {
- p_Manip->reassm = TRUE;
+ if((p_InsrtByTemplate->modifyOuterIpParams.recalculateLengthParams.extraBytesAddedAlignedToBlockSize + p_InsrtByTemplate->modifyOuterIpParams.recalculateLengthParams.extraBytesAddedNotAlignedToBlockSize) > 255)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("extra Byte added can not be more than 256 bytes"));
+ extraAddedBytes = (uint8_t) (p_InsrtByTemplate->modifyOuterIpParams.recalculateLengthParams.extraBytesAddedAlignedToBlockSize + p_InsrtByTemplate->modifyOuterIpParams.recalculateLengthParams.extraBytesAddedNotAlignedToBlockSize);
+ blockSize = p_InsrtByTemplate->modifyOuterIpParams.recalculateLengthParams.blockSize;
+ extraAddedBytesAlignedToBlockSize = p_InsrtByTemplate->modifyOuterIpParams.recalculateLengthParams.extraBytesAddedAlignedToBlockSize;
+ /*IP header template - IP totalLength -
+ (1 byte) extraByteForIp = headerTemplateSize - ipOffset + insertedBytesAfterThisStage ,
+ in the case of SEC insertedBytesAfterThisStage - SEC trailer (21/31) + header(13)
+ second byte - extraByteForIp = headerTemplate - ipOffset + insertedBytesAfterThisStage*/
+ }
+ if (blockSize)
+ {
+ if (!POWER_OF_2(blockSize))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("inputFrmPaddingUpToBlockSize has to be power of 2"));
+ }
- return E_OK;
-}
+ }
+ if (tmpReg8 == 4)
+ {
+ if ((IPv4_HDRCHECKSUM_FIELD_OFFSET_FROM_IP + p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset) > p_InsrtByTemplate->size)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inconsistent parameters : IP present in header template, user asked for IP modifications but ipOffset + ipTotalLengthFieldOffset in header template bigger than template size"));
-static t_Error SetIpv4ReassmManip(t_FmPcdManip *p_Manip)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd *)p_Manip->h_FmPcd;
+ p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv4_DSCECN_FIELD_OFFSET_FROM_IP] = (uint8_t)p_InsrtByTemplate->modifyOuterIpParams.dscpEcn;
- if(p_Manip->muramAllocate)
- {
- p_Manip->ipReassmParams.h_Ipv4Ad = (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
- FM_PCD_CC_AD_ENTRY_SIZE,
- FM_PCD_CC_AD_TABLE_ALIGN);
- if(!p_Manip->ipReassmParams.h_Ipv4Ad)
+ if (blockSize)
+ blockSize -= 1;
+
+ if ((p_InsrtByTemplate->size - p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + extraAddedBytes) > 255)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("p_InsrtByTemplate->size - p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + extraAddedBytes has to be less than 255"));
+
+ p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv4_TOTALLENGTH_FIELD_OFFSET_FROM_IP + 1] = blockSize; // IPV6 - in AD instead of SEQ IND
+ p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv4_TOTALLENGTH_FIELD_OFFSET_FROM_IP] = (uint8_t)(p_InsrtByTemplate->size - p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + extraAddedBytes);// for IPV6 decrement additional 40 bytes of IPV6 heade size
+
+ p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv4_ID_FIELD_OFFSET_FROM_IP] = 0x00;
+ p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv4_ID_FIELD_OFFSET_FROM_IP + 1] = extraAddedBytesAlignedToBlockSize;
+
+ /*IP header template - relevant only for ipv4 CheckSum = 0*/
+ p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv4_HDRCHECKSUM_FIELD_OFFSET_FROM_IP] = 0x00;
+ p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv4_HDRCHECKSUM_FIELD_OFFSET_FROM_IP + 1] = 0x00;
+
+ /*UDP checksum has to be 0*/
+ if (p_InsrtByTemplate->modifyOuterIpParams.udpPresent)
+ {
+ if ((p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_CHECKSUM_FIELD_OFFSET_FROM_UDP + UDP_CHECKSUM_FIELD_SIZE) > p_InsrtByTemplate->size)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inconsistent parameters : UDP present according to user but (UDP offset + UDP header size) < size of header template"));
+
+ p_Template[p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_CHECKSUM_FIELD_OFFSET_FROM_UDP ] = 0x00;
+ p_Template[p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_CHECKSUM_FIELD_OFFSET_FROM_UDP + 1] = 0x00;
+
+ }
+
+ if (p_InsrtByTemplate->modifyOuterIpParams.ipIdentGenId > 7)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("ipIdentGenId has to be one out of 8 sequence number generators (0 - 7) for IP identification field"));
+
+ tmpRegNia |= (uint32_t)p_InsrtByTemplate->modifyOuterIpParams.ipIdentGenId<<24;
+ }
+ else if (tmpReg8 == 6)
+ {
+ /*TODO - add check for maximum value of blockSize;*/
+ if (blockSize)
+ LOG2(blockSize, log2Num);
+ tmpRegNia |= (uint32_t)log2Num << 24;
+
+ // for IPV6 decrement additional 40 bytes of IPV6 heade size - because IPV6 header size is not included in payloadLength
+ p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv6_PAYLOAD_LENGTH_OFFSET_FROM_IP] = (uint8_t)(p_InsrtByTemplate->size - p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + extraAddedBytes - 40);
+ p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv6_PAYLOAD_LENGTH_OFFSET_FROM_IP + 1] = extraAddedBytesAlignedToBlockSize;
+ if (p_InsrtByTemplate->modifyOuterIpParams.udpPresent)
+ {
+ if ((p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_CHECKSUM_FIELD_OFFSET_FROM_UDP + UDP_CHECKSUM_FIELD_SIZE) > p_InsrtByTemplate->size)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inconsistent parameters : UDP present according to user but (UDP offset + UDP header size) < size of header template"));
+ if (p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IPv6_NEXT_HEADER_OFFSET_FROM_IP] != 0x88)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("OUr suppport is only IPv6/UDPLite"));
+ p_Template[p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_LENGTH_FIELD_OFFSET_FROM_UDP] = 0x00;
+ p_Template[p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_LENGTH_FIELD_OFFSET_FROM_UDP + 1] = 0x08;
+ p_Template[p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_CHECKSUM_FIELD_OFFSET_FROM_UDP] = 0x00;
+ p_Template[p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_CHECKSUM_FIELD_OFFSET_FROM_UDP + 1] = 0x00;
+ }
+ }
+ else
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("IP version supported only IPV4"));
+ }
+
+ tmpReg32 = tmpReg16 = tmpReg8 = 0;
+ /*TODO - check it*/
+ if (p_InsrtByTemplate->modifyOuterVlan)
{
- ReleaseManipHandler(p_Manip, p_FmPcd);
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
+ if (p_InsrtByTemplate->modifyOuterVlanParams.vpri & ~0x07)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,("Inconsistent parameters : user asked for VLAN modifications but VPRI more than 3 bits"));
+
+ memcpy(&tmpReg16, &p_Template[VLAN_TAG_FIELD_OFFSET_FROM_ETH], 2*(sizeof(uint8_t)));
+ if ((tmpReg16 != 0x9100) && (tmpReg16!= 0x9200) && (tmpReg16 != 0x8100))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,("Inconsistent parameters : user asked for VLAN modifications but Tag Protocol identifier is not VLAN "));
+
+ memcpy(&tmpReg8, &p_Template[14],1*(sizeof(uint8_t)));
+ tmpReg8 &= 0x1f;
+ tmpReg8 |= (uint8_t)(p_InsrtByTemplate->modifyOuterVlanParams.vpri << 5);
+
+ p_Template[14] = tmpReg8;
}
- IOMemSet32(p_Manip->ipReassmParams.h_Ipv4Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
+ MemCpy8(p_Manip->p_Template, p_Template, p_InsrtByTemplate->size);
+
+ XX_Free(p_Template);
}
- else
- {
- p_Manip->ipReassmParams.h_Ipv4Ad = (t_Handle)XX_MallocSmart(FM_PCD_CC_AD_ENTRY_SIZE * sizeof(uint8_t), p_Manip->ipReassmParams.dataMemId, 0);
- if(!p_Manip->ipReassmParams.h_Ipv4Ad)
- {
- ReleaseManipHandler(p_Manip, p_FmPcd);
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
- }
- memset(p_Manip->ipReassmParams.h_Ipv4Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE * sizeof(uint8_t));
+ tmpReg32 = 0;
+ if (p_Manip->h_Frag)
+ {
+ tmpRegNia |= (uint32_t)(XX_VirtToPhys(p_Manip->h_Frag) - (p_FmPcd->physicalMuramBase));
+ tmpReg32 |= (uint32_t)p_Manip->sizeForFragmentation << 16;
}
+ else
+ tmpReg32 = 0xffff0000;
+
+ if (ipModify)
+ tmpReg32 |= (uint32_t)p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset << 8;
+ else
+ tmpReg32 |= (uint32_t)0x0000ff00;
+
+ tmpReg32 |= (uint32_t)HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER;
+ *(uint32_t *)&p_Ad->pcAndOffsets = tmpReg32;
+
+ tmpRegNia |= FM_PCD_AD_CONT_LOOKUP_TYPE;
+ *(uint32_t *)&p_Ad->ccAdBase = tmpRegNia;
+
+ return err;
+}
+
+static t_Error CheckStatsParamsAndSetType(t_FmPcdManip *p_Manip, t_FmPcdStatsParams *p_StatsParams)
+{
- FillReassmManipParams(p_Manip, p_Manip->ipReassmParams.h_Ipv6Ad, TRUE);
+ switch (p_StatsParams->type)
+ {
+ case (e_FM_PCD_STATS_PER_FLOWID):
+ p_Manip->opcode = HMAN_OC_CAPWAP_INDEXED_STATS;
+ p_Manip->muramAllocate = TRUE;
+ break;
+ default:
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Unsupported statistics type"));
+ }
return E_OK;
}
+#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
-static t_Error SetIpv6ReassmManip(t_FmPcdManip *p_Manip)
+static t_Error FillReassmManipParams(t_FmPcdManip *p_Manip, e_NetHeaderType hdr)
{
+ t_AdOfTypeContLookup *p_Ad;
t_FmPcd *p_FmPcd = (t_FmPcd *)p_Manip->h_FmPcd;
+ uint32_t tmpReg32;
+ t_Error err = E_OK;
+
+ /* Creates the Reassembly Parameters table. It contains parameters that are specific to either the IPv4 reassembly
+ function or to the IPv6 reassembly function. If both IPv4 reassembly and IPv6 reassembly are required, then
+ two separate IP Reassembly Parameter tables are required.*/
+ if ((err = CreateReassTable(p_Manip, hdr)) != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ /* Sets the first Ad register (ccAdBase) - Action Descriptor Type and Pointer to the Reassembly Parameters Table offset from MURAM*/
+ tmpReg32 = 0;
+ tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
+
+ /* Gets the required Action descriptor table pointer */
+ switch (hdr)
+ {
+ case HEADER_TYPE_IPv4:
+ p_Ad = (t_AdOfTypeContLookup *)p_Manip->reassmParams.ip.h_Ipv4Ad;
+ tmpReg32 |= (uint32_t)(XX_VirtToPhys(
+ p_Manip->reassmParams.ip.p_Ipv4ReassTbl)
+ - (p_FmPcd->physicalMuramBase));
+ break;
+ case HEADER_TYPE_IPv6:
+ p_Ad = (t_AdOfTypeContLookup *)p_Manip->reassmParams.ip.h_Ipv6Ad;
+ tmpReg32 |= (uint32_t)(XX_VirtToPhys(
+ p_Manip->reassmParams.ip.p_Ipv6ReassTbl)
+ - (p_FmPcd->physicalMuramBase));
+ break;
+ case HEADER_TYPE_CAPWAP:
+ p_Ad = (t_AdOfTypeContLookup *)p_Manip->reassmParams.capwap.h_Ad;
+ tmpReg32 |= (uint32_t)(XX_VirtToPhys(
+ p_Manip->reassmParams.capwap.p_ReassTbl)
+ - (p_FmPcd->physicalMuramBase));
+ break;
+ default:
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("header type"));
+ }
- if(p_Manip->muramAllocate)
+ WRITE_UINT32(p_Ad->ccAdBase, tmpReg32);
+
+ /* Sets the second Ad register (matchTblPtr) - Buffer pool ID (BPID for V2) and Scatter/Gather table offset*/
+ /* mark the Scatter/Gather table offset to be set later on when the port will be known */
+ p_Manip->updateParams = (NUM_OF_TASKS | NUM_OF_EXTRA_TASKS | DISCARD_MASK);
+
+ if ((hdr == HEADER_TYPE_IPv6) || (hdr == HEADER_TYPE_IPv4))
{
- p_Manip->ipReassmParams.h_Ipv6Ad = (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
- FM_PCD_CC_AD_ENTRY_SIZE,
- FM_PCD_CC_AD_TABLE_ALIGN);
- if(!p_Manip->ipReassmParams.h_Ipv6Ad)
+#if (DPAA_VERSION == 10)
+ tmpReg32 = (uint32_t)(p_Manip->reassmParams.sgBpid << 8);
+ WRITE_UINT32(p_Ad->matchTblPtr, tmpReg32);
+#endif /* (DPAA_VERSION == 10) */
+#if (DPAA_VERSION >= 11)
+ if (p_Manip->reassmParams.ip.nonConsistentSpFqid != 0)
{
- ReleaseManipHandler(p_Manip, p_FmPcd);
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
+ tmpReg32 = FM_PCD_AD_NCSPFQIDM_MASK
+ | (uint32_t)(p_Manip->reassmParams.ip.nonConsistentSpFqid);
+ WRITE_UINT32(p_Ad->gmask, tmpReg32);
}
-
- IOMemSet32(p_Manip->ipReassmParams.h_Ipv6Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
+#endif /* (DPAA_VERSION >= 11) */
+ /* Sets the third Ad register (pcAndOffsets)- IP Reassemble Operation Code*/
+ tmpReg32 = 0;
+ tmpReg32 |= (uint32_t)HMAN_OC_IP_REASSEMBLY;
}
+#if (DPAA_VERSION >= 11)
else
- {
- p_Manip->ipReassmParams.h_Ipv6Ad = (t_Handle)XX_MallocSmart(FM_PCD_CC_AD_ENTRY_SIZE * sizeof(uint8_t), p_Manip->ipReassmParams.dataMemId, 0);
- if(!p_Manip->ipReassmParams.h_Ipv6Ad)
- {
- ReleaseManipHandler(p_Manip, p_FmPcd);
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
- }
+ if (hdr == HEADER_TYPE_CAPWAP)
+ {
+ tmpReg32 = 0;
+ tmpReg32 |= (uint32_t)HMAN_OC_CAPWAP_REASSEMBLY;
+ }
+#endif /* (DPAA_VERSION >= 11) */
- memset(p_Manip->ipReassmParams.h_Ipv6Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE * sizeof(uint8_t));
- }
+ WRITE_UINT32(p_Ad->pcAndOffsets, tmpReg32);
- FillReassmManipParams(p_Manip, p_Manip->ipReassmParams.h_Ipv6Ad, FALSE);
+ p_Manip->reassm = TRUE;
return E_OK;
}
-
-static t_Error IpReassembly(t_FmPcdManipFragOrReasmParams *p_ManipParams,t_FmPcdManip *p_Manip, t_FmPcd *p_FmPcd)
+static t_Error SetIpv4ReassmManip(t_FmPcdManip *p_Manip)
{
- uint32_t tmpReg32 = 0, maxSetNumber = 10000;
- t_IpReasmCommonTbl *p_IpReasmCommonPramTbl = NULL;
- t_IpReassemblyParams reassmManipParams = p_ManipParams->ipReasmParams;
- t_Error err;
+ t_FmPcd *p_FmPcd = (t_FmPcd *)p_Manip->h_FmPcd;
- SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc,E_INVALID_HANDLE);
+ /* Allocation if IPv4 Action descriptor */
+ p_Manip->reassmParams.ip.h_Ipv4Ad = (t_Handle)XX_MallocSmart(
+ FM_PCD_CC_AD_ENTRY_SIZE, p_Manip->reassmParams.dataMemId,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if (!p_Manip->reassmParams.ip.h_Ipv4Ad)
+ {
+ ReleaseManipHandler(p_Manip, p_FmPcd);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("Allocation of IPv4 table descriptor"));
+ }
- if (!p_FmPcd->h_Hc)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE,("hc port has to be initialized in this mode"));
- if (!POWER_OF_2(reassmManipParams.maxNumFramesInProcess))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE,("maxNumFramesInProcess has to be power of 2"));
+ memset(p_Manip->reassmParams.ip.h_Ipv4Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
- if ((reassmManipParams.timeoutThresholdForReassmProcess < 1000) && (reassmManipParams.timeoutThresholdForReassmProcess > 8000000))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE,("timeoutThresholdForReassmProcess should be 1msec - 8sec"));
+ /* Fill reassembly manipulation parameter in the IP Reassembly Action Descriptor */
+ return FillReassmManipParams(p_Manip, HEADER_TYPE_IPv4);
+}
- /*It is recommended that the total number of entries in this table (number of sets * number of ways)
- will be twice the number of frames that are expected to be reassembled simultaneously.*/
- if (reassmManipParams.maxNumFramesInProcess > (reassmManipParams.maxNumFramesInProcess * maxSetNumber / 2))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("maxNumFramesInProcess has to be less than (maximun set number * number of ways / 2)"));
+static t_Error SetIpv6ReassmManip(t_FmPcdManip *p_Manip)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd *)p_Manip->h_FmPcd;
- p_Manip->ipReassmParams.maxNumFramesInProcess = reassmManipParams.maxNumFramesInProcess;
- p_Manip->ipReassmParams.timeOutMode = reassmManipParams.timeOutMode;
- p_Manip->ipReassmParams.fqidForTimeOutFrames = reassmManipParams.fqidForTimeOutFrames;
- p_Manip->ipReassmParams.numOfFramesPerHashEntry = reassmManipParams.numOfFramesPerHashEntry;
- p_Manip->ipReassmParams.timeoutThresholdForReassmProcess = reassmManipParams.timeoutThresholdForReassmProcess;
- p_Manip->ipReassmParams.liodnOffset = reassmManipParams.liodnOffset;
- p_Manip->ipReassmParams.minFragSize = reassmManipParams.minFragSize;
- p_Manip->ipReassmParams.dataMemId = reassmManipParams.dataMemId;
- p_Manip->ipReassmParams.bpid = p_ManipParams->extBufPoolIndx;
+ /* Allocation if IPv6 Action descriptor */
+ p_Manip->reassmParams.ip.h_Ipv6Ad = (t_Handle)XX_MallocSmart(
+ FM_PCD_CC_AD_ENTRY_SIZE, p_Manip->reassmParams.dataMemId,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if (!p_Manip->reassmParams.ip.h_Ipv6Ad)
+ {
+ ReleaseManipHandler(p_Manip, p_FmPcd);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("Allocation of IPv6 table descriptor"));
+ }
- CreateIpReassCommonParamTable(p_Manip, p_FmPcd, p_IpReasmCommonPramTbl);
+ memset(p_Manip->reassmParams.ip.h_Ipv6Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
- if ((p_Manip->ipReassmParams.hdr == HEADER_TYPE_IPv4_AND_IPv6) || (p_Manip->ipReassmParams.hdr == HEADER_TYPE_IPv4))
- return SetIpv4ReassmManip(p_Manip);
+ /* Fill reassembly manipulation parameter in the IP Reassembly Action Descriptor */
+ return FillReassmManipParams(p_Manip, HEADER_TYPE_IPv6);
+}
- if ((p_Manip->ipReassmParams.hdr == HEADER_TYPE_IPv4_AND_IPv6) || (p_Manip->ipReassmParams.hdr == HEADER_TYPE_IPv6))
- return SetIpv6ReassmManip(p_Manip);
+static t_Error IpReassembly(t_FmPcdManipReassemParams *p_ManipReassmParams,
+ t_FmPcdManip *p_Manip)
+{
+ uint32_t maxSetNumber = 10000;
+ t_FmPcdManipReassemIpParams reassmManipParams =
+ p_ManipReassmParams->u.ipReassem;
+ t_Error res;
+
+ SANITY_CHECK_RETURN_ERROR(p_Manip->h_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(((t_FmPcd *)p_Manip->h_FmPcd)->h_Hc,
+ E_INVALID_HANDLE);
+
+ /* Check validation of user's parameter.*/
+ if ((reassmManipParams.timeoutThresholdForReassmProcess < 1000)
+ || (reassmManipParams.timeoutThresholdForReassmProcess > 8000000))
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("timeoutThresholdForReassmProcess should be 1msec - 8sec"));
+ /* It is recommended that the total number of entries in this table (number of sets * number of ways)
+ will be twice the number of frames that are expected to be reassembled simultaneously.*/
+ if (reassmManipParams.maxNumFramesInProcess
+ > (reassmManipParams.maxNumFramesInProcess * maxSetNumber / 2))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("maxNumFramesInProcess has to be less than (maximun set number * number of ways / 2)"));
+
+ if ((p_ManipReassmParams->hdr == HEADER_TYPE_IPv6)
+ && (reassmManipParams.minFragSize[1] < 256))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("minFragSize[1] must be >= 256"));
+
+ /* Saves user's reassembly manipulation parameters */
+ p_Manip->reassmParams.ip.relativeSchemeId[0] =
+ reassmManipParams.relativeSchemeId[0];
+ p_Manip->reassmParams.ip.relativeSchemeId[1] =
+ reassmManipParams.relativeSchemeId[1];
+ p_Manip->reassmParams.ip.numOfFramesPerHashEntry[0] =
+ reassmManipParams.numOfFramesPerHashEntry[0];
+ p_Manip->reassmParams.ip.numOfFramesPerHashEntry[1] =
+ reassmManipParams.numOfFramesPerHashEntry[1];
+ p_Manip->reassmParams.ip.minFragSize[0] = reassmManipParams.minFragSize[0];
+ p_Manip->reassmParams.ip.minFragSize[1] = reassmManipParams.minFragSize[1];
+ p_Manip->reassmParams.maxNumFramesInProcess =
+ reassmManipParams.maxNumFramesInProcess;
+ p_Manip->reassmParams.timeOutMode = reassmManipParams.timeOutMode;
+ p_Manip->reassmParams.fqidForTimeOutFrames =
+ reassmManipParams.fqidForTimeOutFrames;
+ p_Manip->reassmParams.timeoutThresholdForReassmProcess =
+ reassmManipParams.timeoutThresholdForReassmProcess;
+ p_Manip->reassmParams.dataMemId = reassmManipParams.dataMemId;
+ p_Manip->reassmParams.dataLiodnOffset = reassmManipParams.dataLiodnOffset;
+#if (DPAA_VERSION == 10)
+ p_Manip->reassmParams.sgBpid = reassmManipParams.sgBpid;
+#endif /* (DPAA_VERSION == 10) */
+#if (DPAA_VERSION >= 11)
+ if (reassmManipParams.nonConsistentSpFqid != 0)
+ {
+ p_Manip->reassmParams.ip.nonConsistentSpFqid =
+ reassmManipParams.nonConsistentSpFqid;
+ }
+#endif /* (DPAA_VERSION >= 11) */
- err = FM_PCD_RegisterReassmPort(p_FmPcd, p_IpReasmCommonPramTbl);
- if (err != E_OK)
+ /* Creates and initializes the IP Reassembly common parameter table */
+ CreateReassCommonTable(p_Manip);
+
+ /* Creation of IPv4 reassembly manipulation */
+ if ((p_Manip->reassmParams.hdr == HEADER_TYPE_IPv6)
+ || (p_Manip->reassmParams.hdr == HEADER_TYPE_IPv4))
{
- FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_IpReasmCommonPramTbl);
- RETURN_ERROR(MAJOR, err, ("port registration"));
+ res = SetIpv4ReassmManip(p_Manip);
+ if (res != E_OK)
+ return res;
+ }
+
+ /* Creation of IPv6 reassembly manipulation */
+ if (p_Manip->reassmParams.hdr == HEADER_TYPE_IPv6)
+ {
+ res = SetIpv6ReassmManip(p_Manip);
+ if (res != E_OK)
+ return res;
}
return E_OK;
}
-#endif /*UNDER_CONSTRUCTION_FRAG_REASSEMBLY*/
-static t_Error IndxStats(t_FmPcdStatsParams *p_StatsParams,t_FmPcdManip *p_Manip,t_FmPcd *p_FmPcd)
+static void setIpReassmSchemeParams(t_FmPcd* p_FmPcd,
+ t_FmPcdKgSchemeParams *p_Scheme,
+ t_Handle h_CcTree, bool ipv4,
+ uint8_t groupId)
{
- t_AdOfTypeContLookup *p_Ad;
- uint32_t tmpReg32 = 0;
+ uint32_t j;
+ uint8_t res;
- SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad,E_INVALID_HANDLE);
+ /* Configures scheme's network environment parameters */
+ p_Scheme->netEnvParams.numOfDistinctionUnits = 2;
+ if (ipv4)
+ res = FmPcdNetEnvGetUnitId(
+ p_FmPcd, FmPcdGetNetEnvId(p_Scheme->netEnvParams.h_NetEnv),
+ HEADER_TYPE_IPv4, FALSE, 0);
+ else
+ res = FmPcdNetEnvGetUnitId(
+ p_FmPcd, FmPcdGetNetEnvId(p_Scheme->netEnvParams.h_NetEnv),
+ HEADER_TYPE_IPv6, FALSE, 0);
+ ASSERT_COND(res != FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS);
+ p_Scheme->netEnvParams.unitIds[0] = res;
+
+ res = FmPcdNetEnvGetUnitId(
+ p_FmPcd, FmPcdGetNetEnvId(p_Scheme->netEnvParams.h_NetEnv),
+ HEADER_TYPE_USER_DEFINED_SHIM2, FALSE, 0);
+ ASSERT_COND(res != FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS);
+ p_Scheme->netEnvParams.unitIds[1] = res;
+
+ /* Configures scheme's next engine parameters*/
+ p_Scheme->nextEngine = e_FM_PCD_CC;
+ p_Scheme->kgNextEngineParams.cc.h_CcTree = h_CcTree;
+ p_Scheme->kgNextEngineParams.cc.grpId = groupId;
+ p_Scheme->useHash = TRUE;
+
+ /* Configures scheme's key*/
+ if (ipv4 == TRUE)
+ {
+ p_Scheme->keyExtractAndHashParams.numOfUsedExtracts = 4;
+ p_Scheme->keyExtractAndHashParams.extractArray[0].type =
+ e_FM_PCD_EXTRACT_BY_HDR;
+ p_Scheme->keyExtractAndHashParams.extractArray[0].extractByHdr.type =
+ e_FM_PCD_EXTRACT_FULL_FIELD;
+ p_Scheme->keyExtractAndHashParams.extractArray[0].extractByHdr.hdr =
+ HEADER_TYPE_IPv4;
+ p_Scheme->keyExtractAndHashParams.extractArray[0].extractByHdr.extractByHdrType.fullField.ipv4 =
+ NET_HEADER_FIELD_IPv4_DST_IP;
+ p_Scheme->keyExtractAndHashParams.extractArray[1].type =
+ e_FM_PCD_EXTRACT_BY_HDR;
+ p_Scheme->keyExtractAndHashParams.extractArray[1].extractByHdr.type =
+ e_FM_PCD_EXTRACT_FULL_FIELD;
+ p_Scheme->keyExtractAndHashParams.extractArray[1].extractByHdr.hdr =
+ HEADER_TYPE_IPv4;
+ p_Scheme->keyExtractAndHashParams.extractArray[1].extractByHdr.extractByHdrType.fullField.ipv4 =
+ NET_HEADER_FIELD_IPv4_SRC_IP;
+ p_Scheme->keyExtractAndHashParams.extractArray[2].type =
+ e_FM_PCD_EXTRACT_BY_HDR;
+ p_Scheme->keyExtractAndHashParams.extractArray[2].extractByHdr.type =
+ e_FM_PCD_EXTRACT_FULL_FIELD;
+ p_Scheme->keyExtractAndHashParams.extractArray[2].extractByHdr.hdr =
+ HEADER_TYPE_IPv4;
+ p_Scheme->keyExtractAndHashParams.extractArray[2].extractByHdr.extractByHdrType.fullField.ipv4 =
+ NET_HEADER_FIELD_IPv4_PROTO;
+ p_Scheme->keyExtractAndHashParams.extractArray[3].type =
+ e_FM_PCD_EXTRACT_BY_HDR;
+ p_Scheme->keyExtractAndHashParams.extractArray[3].extractByHdr.hdr =
+ HEADER_TYPE_IPv4;
+ p_Scheme->keyExtractAndHashParams.extractArray[3].extractByHdr.type =
+ e_FM_PCD_EXTRACT_FROM_HDR;
+ p_Scheme->keyExtractAndHashParams.extractArray[3].extractByHdr.ignoreProtocolValidation =
+ FALSE;
+ p_Scheme->keyExtractAndHashParams.extractArray[3].extractByHdr.extractByHdrType.fromHdr.size =
+ 2;
+ p_Scheme->keyExtractAndHashParams.extractArray[3].extractByHdr.extractByHdrType.fromHdr.offset =
+ 4;
+ }
+ else /* IPv6 */
+ {
+ p_Scheme->keyExtractAndHashParams.numOfUsedExtracts = 3;
+ p_Scheme->keyExtractAndHashParams.extractArray[0].type =
+ e_FM_PCD_EXTRACT_BY_HDR;
+ p_Scheme->keyExtractAndHashParams.extractArray[0].extractByHdr.type =
+ e_FM_PCD_EXTRACT_FULL_FIELD;
+ p_Scheme->keyExtractAndHashParams.extractArray[0].extractByHdr.hdr =
+ HEADER_TYPE_IPv6;
+ p_Scheme->keyExtractAndHashParams.extractArray[0].extractByHdr.extractByHdrType.fullField.ipv6 =
+ NET_HEADER_FIELD_IPv6_DST_IP;
+ p_Scheme->keyExtractAndHashParams.extractArray[1].type =
+ e_FM_PCD_EXTRACT_BY_HDR;
+ p_Scheme->keyExtractAndHashParams.extractArray[1].extractByHdr.type =
+ e_FM_PCD_EXTRACT_FULL_FIELD;
+ p_Scheme->keyExtractAndHashParams.extractArray[1].extractByHdr.hdr =
+ HEADER_TYPE_IPv6;
+ p_Scheme->keyExtractAndHashParams.extractArray[1].extractByHdr.extractByHdrType.fullField.ipv6 =
+ NET_HEADER_FIELD_IPv6_SRC_IP;
+ p_Scheme->keyExtractAndHashParams.extractArray[2].type =
+ e_FM_PCD_EXTRACT_BY_HDR;
+ p_Scheme->keyExtractAndHashParams.extractArray[2].extractByHdr.hdr =
+ HEADER_TYPE_USER_DEFINED_SHIM2;
+ p_Scheme->keyExtractAndHashParams.extractArray[2].extractByHdr.type =
+ e_FM_PCD_EXTRACT_FROM_HDR;
+ p_Scheme->keyExtractAndHashParams.extractArray[2].extractByHdr.extractByHdrType.fromHdr.size =
+ 4;
+ p_Scheme->keyExtractAndHashParams.extractArray[2].extractByHdr.extractByHdrType.fromHdr.offset =
+ 4;
+ p_Scheme->keyExtractAndHashParams.extractArray[2].extractByHdr.ignoreProtocolValidation =
+ TRUE;
+ }
- UNUSED(p_FmPcd);
+ p_Scheme->keyExtractAndHashParams.privateDflt0 = 0x01020304;
+ p_Scheme->keyExtractAndHashParams.privateDflt1 = 0x11121314;
+ p_Scheme->keyExtractAndHashParams.numOfUsedDflts =
+ FM_PCD_KG_NUM_OF_DEFAULT_GROUPS;
+ for (j = 0; j < FM_PCD_KG_NUM_OF_DEFAULT_GROUPS; j++)
+ {
+ p_Scheme->keyExtractAndHashParams.dflts[j].type =
+ (e_FmPcdKgKnownFieldsDfltTypes)j; /* all types */
+ p_Scheme->keyExtractAndHashParams.dflts[j].dfltSelect =
+ e_FM_PCD_KG_DFLT_GBL_0;
+ }
+}
+
+static t_Error IpReassemblyStats(t_FmPcdManip *p_Manip,
+ t_FmPcdManipReassemIpStats *p_Stats)
+{
+ ASSERT_COND(p_Manip);
+ ASSERT_COND(p_Stats);
+ ASSERT_COND(p_Manip->reassmParams.p_ReassCommonTbl);
+
+ p_Stats->timeout =
+ GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalTimeOutCounter);
+ p_Stats->rfdPoolBusy =
+ GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalRfdPoolBusyCounter);
+ p_Stats->internalBufferBusy =
+ GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalInternalBufferBusy);
+ p_Stats->externalBufferBusy =
+ GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalExternalBufferBusy);
+ p_Stats->sgFragments =
+ GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalSgFragmentCounter);
+ p_Stats->dmaSemaphoreDepletion =
+ GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalDmaSemaphoreDepletionCounter);
+#if (DPAA_VERSION >= 11)
+ p_Stats->nonConsistentSp =
+ GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalNCSPCounter);
+#endif /* (DPAA_VERSION >= 11) */
+
+ if (p_Manip->reassmParams.ip.p_Ipv4ReassTbl)
+ {
+ p_Stats->specificHdrStatistics[0].successfullyReassembled =
+ GET_UINT32(p_Manip->reassmParams.ip.p_Ipv4ReassTbl->totalSuccessfullyReasmFramesCounter);
+ p_Stats->specificHdrStatistics[0].validFragments =
+ GET_UINT32(p_Manip->reassmParams.ip.p_Ipv4ReassTbl->totalValidFragmentCounter);
+ p_Stats->specificHdrStatistics[0].processedFragments =
+ GET_UINT32(p_Manip->reassmParams.ip.p_Ipv4ReassTbl->totalProcessedFragCounter);
+ p_Stats->specificHdrStatistics[0].malformedFragments =
+ GET_UINT32(p_Manip->reassmParams.ip.p_Ipv4ReassTbl->totalMalformdFragCounter);
+ p_Stats->specificHdrStatistics[0].autoLearnBusy =
+ GET_UINT32(p_Manip->reassmParams.ip.p_Ipv4ReassTbl->totalSetBusyCounter);
+ p_Stats->specificHdrStatistics[0].discardedFragments =
+ GET_UINT32(p_Manip->reassmParams.ip.p_Ipv4ReassTbl->totalDiscardedFragsCounter);
+ p_Stats->specificHdrStatistics[0].moreThan16Fragments =
+ GET_UINT32(p_Manip->reassmParams.ip.p_Ipv4ReassTbl->totalMoreThan16FramesCounter);
+ }
+ if (p_Manip->reassmParams.ip.p_Ipv6ReassTbl)
+ {
+ p_Stats->specificHdrStatistics[1].successfullyReassembled =
+ GET_UINT32(p_Manip->reassmParams.ip.p_Ipv6ReassTbl->totalSuccessfullyReasmFramesCounter);
+ p_Stats->specificHdrStatistics[1].validFragments =
+ GET_UINT32(p_Manip->reassmParams.ip.p_Ipv6ReassTbl->totalValidFragmentCounter);
+ p_Stats->specificHdrStatistics[1].processedFragments =
+ GET_UINT32(p_Manip->reassmParams.ip.p_Ipv6ReassTbl->totalProcessedFragCounter);
+ p_Stats->specificHdrStatistics[1].malformedFragments =
+ GET_UINT32(p_Manip->reassmParams.ip.p_Ipv6ReassTbl->totalMalformdFragCounter);
+ p_Stats->specificHdrStatistics[1].autoLearnBusy =
+ GET_UINT32(p_Manip->reassmParams.ip.p_Ipv6ReassTbl->totalSetBusyCounter);
+ p_Stats->specificHdrStatistics[1].discardedFragments =
+ GET_UINT32(p_Manip->reassmParams.ip.p_Ipv6ReassTbl->totalDiscardedFragsCounter);
+ p_Stats->specificHdrStatistics[1].moreThan16Fragments =
+ GET_UINT32(p_Manip->reassmParams.ip.p_Ipv6ReassTbl->totalMoreThan16FramesCounter);
+ }
+ return E_OK;
+}
- p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
+static t_Error IpFragmentationStats(t_FmPcdManip *p_Manip,
+ t_FmPcdManipFragIpStats *p_Stats)
+{
+ t_AdOfTypeContLookup *p_Ad;
- tmpReg32 = 0;
- tmpReg32 |= (uint32_t)HMAN_OC_CAPWAP_INDEXED_STATS;
- if(p_StatsParams->type == e_FM_PCD_STATS_PER_FLOWID)
- tmpReg32 |= (uint32_t)0x16 << 16;
- WRITE_UINT32(p_Ad->pcAndOffsets, tmpReg32);
+ ASSERT_COND(p_Manip);
+ ASSERT_COND(p_Stats);
+ ASSERT_COND(p_Manip->h_Ad);
+ ASSERT_COND(p_Manip->fragParams.p_Frag);
- tmpReg32 = 0;
- tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
- WRITE_UINT32(p_Ad->ccAdBase, tmpReg32);
+ p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
+
+ p_Stats->totalFrames = GET_UINT32(p_Ad->gmask);
+ p_Stats->fragmentedFrames = GET_UINT32(p_Manip->fragParams.p_Frag->ccAdBase)
+ & 0x00ffffff;
+ p_Stats->generatedFragments =
+ GET_UINT32(p_Manip->fragParams.p_Frag->matchTblPtr);
return E_OK;
}
-static t_Error InsrtHdrByTempl(t_FmPcdManipInsrtParams *p_ManipParams, t_FmPcdManip *p_Manip, t_FmPcd *p_FmPcd)
+static t_Error IpFragmentation(t_FmPcdManipFragIpParams *p_ManipParams,
+ t_FmPcdManip *p_Manip)
{
- t_FmPcdManipInsrtByTemplateParams *p_InsrtByTemplate = &p_ManipParams->insrtByTemplateParams;
- uint8_t tmpReg8 = 0xff;
- t_AdOfTypeContLookup *p_Ad;
- bool ipModify = FALSE;
- uint32_t tmpReg32 = 0, tmpRegNia = 0;
- uint16_t tmpReg16 = 0;
- t_Error err = E_OK;
- uint8_t extraAddedBytes = 0, blockSize = 0, extraAddedBytesAlignedToBlockSize = 0;
- uint8_t *p_Template = NULL;
-
- SANITY_CHECK_RETURN_ERROR(p_ManipParams,E_NULL_POINTER);
- SANITY_CHECK_RETURN_ERROR(p_Manip,E_NULL_POINTER);
- SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd,E_NULL_POINTER);
+ uint32_t pcAndOffsetsReg = 0, ccAdBaseReg = 0, gmaskReg = 0;
+ t_FmPcd *p_FmPcd;
+#if (DPAA_VERSION == 10)
+ t_Error err = E_OK;
+#endif /* (DPAA_VERSION == 10) */
- p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
- if(p_Manip->insrt)
+ SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_ManipParams->sizeForFragmentation != 0xFFFF,
+ E_INVALID_VALUE);
+
+ p_FmPcd = p_Manip->h_FmPcd;
+ /* Allocation of fragmentation Action Descriptor */
+ p_Manip->fragParams.p_Frag = (t_AdOfTypeContLookup *)FM_MURAM_AllocMem(
+ p_FmPcd->h_FmMuram, FM_PCD_CC_AD_ENTRY_SIZE,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if (!p_Manip->fragParams.p_Frag)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("MURAM alloc for Fragmentation table descriptor"));
+ MemSet8(p_Manip->fragParams.p_Frag, 0, FM_PCD_CC_AD_ENTRY_SIZE);
+
+ /* Prepare the third Ad register (pcAndOffsets)- OperationCode */
+ pcAndOffsetsReg = (uint32_t)HMAN_OC_IP_FRAGMENTATION;
+
+ /* Prepare the first Ad register (ccAdBase) - Don't frag action and Action descriptor type*/
+ ccAdBaseReg = FM_PCD_AD_CONT_LOOKUP_TYPE;
+ ccAdBaseReg |= (p_ManipParams->dontFragAction
+ << FM_PCD_MANIP_IP_FRAG_DF_SHIFT);
+
+
+ /* Set Scatter/Gather BPid */
+ if (p_ManipParams->sgBpidEn)
{
- if((!p_InsrtByTemplate->size && p_InsrtByTemplate->modifyOuterIp) ||
- (!p_InsrtByTemplate->size && p_InsrtByTemplate->modifyOuterVlan))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inconsistent parameters : asking for header template modifications with no template for insertion (template size)"));
+ ccAdBaseReg |= FM_PCD_MANIP_IP_FRAG_SG_BDID_EN;
+ pcAndOffsetsReg |= ((p_ManipParams->sgBpid
+ << FM_PCD_MANIP_IP_FRAG_SG_BDID_SHIFT)
+ & FM_PCD_MANIP_IP_FRAG_SG_BDID_MASK);
+ }
- if (p_InsrtByTemplate->size && p_InsrtByTemplate->modifyOuterIp && (p_InsrtByTemplate->size <= p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inconsistent parameters : size of template < ipOuterOffset"));
+ /* Prepare the first Ad register (gmask) - scratch buffer pool id and Pointer to fragment ID */
+ gmaskReg = (uint32_t)(XX_VirtToPhys(UINT_TO_PTR(p_FmPcd->ipv6FrameIdAddr))
+ - p_FmPcd->physicalMuramBase);
+#if (DPAA_VERSION == 10)
+ gmaskReg |= p_ManipParams->scratchBpid << FM_PCD_MANIP_IP_FRAG_SCRATCH_BPID;
+#else
+ gmaskReg |= (0xFF) << FM_PCD_MANIP_IP_FRAG_SCRATCH_BPID;
+#endif /* (DPAA_VERSION == 10) */
+
+ /* Set all Ad registers */
+ WRITE_UINT32(p_Manip->fragParams.p_Frag->pcAndOffsets, pcAndOffsetsReg);
+ WRITE_UINT32(p_Manip->fragParams.p_Frag->ccAdBase, ccAdBaseReg);
+ WRITE_UINT32(p_Manip->fragParams.p_Frag->gmask, gmaskReg);
+
+ /* Saves user's fragmentation manipulation parameters */
+ p_Manip->frag = TRUE;
+ p_Manip->sizeForFragmentation = p_ManipParams->sizeForFragmentation;
- if(p_InsrtByTemplate->size > 128)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Size of header template for insertion can not be more than 128"));
+#if (DPAA_VERSION == 10)
+ p_Manip->fragParams.scratchBpid = p_ManipParams->scratchBpid;
- if(p_InsrtByTemplate->size)
- {
- p_Manip->p_Template = (uint8_t *)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
- p_InsrtByTemplate->size,
- FM_PCD_CC_AD_TABLE_ALIGN);
- if(!p_Manip->p_Template)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
+ /* scratch buffer pool initialization */
+ if ((err = FmPcdFragHcScratchPoolFill((t_Handle)p_FmPcd, p_ManipParams->scratchBpid)) != E_OK)
+ {
+ FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, p_Manip->fragParams.p_Frag);
+ p_Manip->fragParams.p_Frag = NULL;
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+#endif /* (DPAA_VERSION == 10) */
- tmpReg32 = (uint32_t)(XX_VirtToPhys(p_Manip->p_Template) - (p_FmPcd->physicalMuramBase));
- tmpReg32 |= (uint32_t)p_InsrtByTemplate->size << 24;
- *(uint32_t *)&p_Ad->matchTblPtr = tmpReg32;
- }
+ return E_OK;
+}
- tmpReg32 = 0;
+static t_Error IPManip(t_FmPcdManip *p_Manip)
+{
+ t_Error err = E_OK;
+ t_FmPcd *p_FmPcd;
+ t_AdOfTypeContLookup *p_Ad;
+ uint32_t tmpReg32 = 0, tmpRegNia = 0;
- p_Template = (uint8_t *)XX_Malloc(p_InsrtByTemplate->size * sizeof(uint8_t));
+ SANITY_CHECK_RETURN_ERROR(p_Manip, E_INVALID_HANDLE);
+ p_FmPcd = p_Manip->h_FmPcd;
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- if(!p_Template)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("XX_Malloc allocation FAILED"));
+ p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
- memcpy(p_Template, p_InsrtByTemplate->hdrTemplate, p_InsrtByTemplate->size * sizeof(uint8_t));
+ tmpReg32 = FM_PCD_MANIP_IP_NO_FRAGMENTATION;
+ if (p_Manip->frag == TRUE)
+ {
+ tmpRegNia = (uint32_t)(XX_VirtToPhys(p_Manip->fragParams.p_Frag)
+ - (p_FmPcd->physicalMuramBase));
+ tmpReg32 = (uint32_t)p_Manip->sizeForFragmentation
+ << FM_PCD_MANIP_IP_MTU_SHIFT;
+ }
+ tmpRegNia |= FM_PCD_AD_CONT_LOOKUP_TYPE;
+ tmpReg32 |= HMAN_OC_IP_MANIP;
- if(p_InsrtByTemplate->modifyOuterIp)
- {
- ipModify = TRUE;
+#if (DPAA_VERSION >= 11)
+ tmpRegNia |= FM_PCD_MANIP_IP_CNIA;
+#endif /* (DPAA_VERSION >= 11) */
- tmpReg8 = (uint8_t)p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset];
+ WRITE_UINT32(p_Ad->pcAndOffsets, tmpReg32);
+ WRITE_UINT32(p_Ad->ccAdBase, tmpRegNia);
+ WRITE_UINT32(p_Ad->gmask, 0);
+ /* Total frame counter - MUST be initialized to zero.*/
- if((tmpReg8 & 0xf0) == 0x40)
- tmpReg8 = 4;
- else if((tmpReg8 & 0xf0) == 0x60)
- tmpReg8 = 6;
- else
- tmpReg8 = 0xff;
+ return err;
+}
- if(tmpReg8 == 4)
- {
- if((IP_HDRCHECKSUM_FIELD_OFFSET_FROM_IP + p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset) > p_InsrtByTemplate->size)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inconsistent parameters : IP present in header template, user asked for IP modifications but ipOffset + ipTotalLengthFieldOffset in header template bigger than template size"));
+static t_Error UpdateInitIpFrag(t_Handle h_FmPcd, t_Handle h_PcdParams,
+ t_Handle h_FmPort, t_FmPcdManip *p_Manip,
+ t_Handle h_Ad, bool validate)
+{
+ t_FmPortGetSetCcParams fmPortGetSetCcParams;
+ t_Error err;
- if(p_InsrtByTemplate->modifyOuterIpParams.dscpEcn & 0xff00)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inconsistent parameters : IPV4 present in header template, dscpEcn has to be only 1 byte"));
+ SANITY_CHECK_RETURN_ERROR(p_Manip, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Manip->opcode == HMAN_OC_IP_FRAGMENTATION),
+ E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
- p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IP_DSCECN_FIELD_OFFSET_FROM_IP] = (uint8_t)p_InsrtByTemplate->modifyOuterIpParams.dscpEcn;
+ UNUSED(h_FmPcd);
+ UNUSED(h_Ad);
+ UNUSED(h_PcdParams);
+ UNUSED(validate);
+ UNUSED(p_Manip);
- if(p_InsrtByTemplate->modifyOuterIpParams.recalculateLength)
- {
+ fmPortGetSetCcParams.setCcParams.type = 0;
+ fmPortGetSetCcParams.getCcParams.type = MANIP_EXTRA_SPACE;
+ if ((err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams)) != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
- if((p_InsrtByTemplate->modifyOuterIpParams.recalculateLengthParams.extraBytesAddedAlignedToBlockSize + p_InsrtByTemplate->modifyOuterIpParams.recalculateLengthParams.extraBytesAddedNotAlignedToBlockSize) > 255)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("extra Byte added can not be more than 256 bytes"));
- extraAddedBytes = (uint8_t) (p_InsrtByTemplate->modifyOuterIpParams.recalculateLengthParams.extraBytesAddedAlignedToBlockSize + p_InsrtByTemplate->modifyOuterIpParams.recalculateLengthParams.extraBytesAddedNotAlignedToBlockSize);
- blockSize = p_InsrtByTemplate->modifyOuterIpParams.recalculateLengthParams.blockSize;
- extraAddedBytesAlignedToBlockSize = p_InsrtByTemplate->modifyOuterIpParams.recalculateLengthParams.extraBytesAddedAlignedToBlockSize;
- /*IP header template - IP totalLength -
- (1 byte) extraByteForIp = headerTemplateSize - ipOffset + insertedBytesAfterThisStage ,
- in the case of SEC insertedBytesAfterThisStage - SEC trailer (21/31) + header(13)
- second byte - extraByteForIp = headerTemplate - ipOffset + insertedBytesAfterThisStage*/
- }
- if(blockSize)
- {
- if (!POWER_OF_2(blockSize))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("inputFrmPaddingUpToBlockSize has to be power of 2"));
- blockSize -= 1;
- }
+ if (!fmPortGetSetCcParams.getCcParams.internalBufferOffset)
+ DBG(WARNING, ("manipExtraSpace must be larger than '0'"));
- if((p_InsrtByTemplate->size - p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + extraAddedBytes) > 255)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("p_InsrtByTemplate->size - p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + extraAddedBytes has to be less than 255"));
+ return E_OK;
+}
- p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IP_TOTALLENGTH_FIELD_OFFSET_FROM_IP + 1] = blockSize;
- p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IP_TOTALLENGTH_FIELD_OFFSET_FROM_IP] = (uint8_t)(p_InsrtByTemplate->size - p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + extraAddedBytes);
+static t_Error IPSecManip(t_FmPcdManipParams *p_ManipParams,
+ t_FmPcdManip *p_Manip)
+{
+ t_AdOfTypeContLookup *p_Ad;
+ t_FmPcdManipSpecialOffloadIPSecParams *p_IPSecParams;
+ t_Error err = E_OK;
+ uint32_t tmpReg32 = 0;
+ uint32_t power;
+
+ SANITY_CHECK_RETURN_ERROR(p_Manip, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_ManipParams, E_INVALID_HANDLE);
+
+ p_IPSecParams = &p_ManipParams->u.specialOffload.u.ipsec;
+
+ SANITY_CHECK_RETURN_ERROR(
+ !p_IPSecParams->variableIpHdrLen || p_IPSecParams->decryption,
+ E_INVALID_VALUE);
+ SANITY_CHECK_RETURN_ERROR(
+ !p_IPSecParams->variableIpVersion || !p_IPSecParams->decryption,
+ E_INVALID_VALUE);
+ SANITY_CHECK_RETURN_ERROR(
+ !p_IPSecParams->variableIpVersion || p_IPSecParams->outerIPHdrLen,
+ E_INVALID_VALUE);
+ SANITY_CHECK_RETURN_ERROR(
+ !p_IPSecParams->arwSize || p_IPSecParams->arwAddr,
+ E_INVALID_VALUE);
+ SANITY_CHECK_RETURN_ERROR(
+ !p_IPSecParams->arwSize || p_IPSecParams->decryption,
+ E_INVALID_VALUE);
+ SANITY_CHECK_RETURN_ERROR((p_IPSecParams->arwSize % 16) == 0, E_INVALID_VALUE);
- p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IP_ID_FIELD_OFFSET_FROM_IP] = 0x00;
- p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IP_ID_FIELD_OFFSET_FROM_IP + 1] = extraAddedBytesAlignedToBlockSize;
+ p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
+ tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
+ tmpReg32 |= (p_IPSecParams->decryption) ? FM_PCD_MANIP_IPSEC_DEC : 0;
+ tmpReg32 |= (p_IPSecParams->ecnCopy) ? FM_PCD_MANIP_IPSEC_ECN_EN : 0;
+ tmpReg32 |= (p_IPSecParams->dscpCopy) ? FM_PCD_MANIP_IPSEC_DSCP_EN : 0;
+ tmpReg32 |=
+ (p_IPSecParams->variableIpHdrLen) ? FM_PCD_MANIP_IPSEC_VIPL_EN : 0;
+ tmpReg32 |=
+ (p_IPSecParams->variableIpVersion) ? FM_PCD_MANIP_IPSEC_VIPV_EN : 0;
+ if (p_IPSecParams->arwSize)
+ tmpReg32 |= (uint32_t)((XX_VirtToPhys(UINT_TO_PTR(p_IPSecParams->arwAddr))-FM_MM_MURAM)
+ & (FM_MURAM_SIZE-1));
+ WRITE_UINT32(p_Ad->ccAdBase, tmpReg32);
- /*IP header template - relevant only for ipv4 CheckSum = 0*/
- p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IP_HDRCHECKSUM_FIELD_OFFSET_FROM_IP] = 0x00;
- p_Template[p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset + IP_HDRCHECKSUM_FIELD_OFFSET_FROM_IP + 1] = 0x00;
+ tmpReg32 = 0;
+ if (p_IPSecParams->arwSize) {
+ NEXT_POWER_OF_2((p_IPSecParams->arwSize + 32), power);
+ LOG2(power, power);
+ tmpReg32 = (p_IPSecParams->arwSize | (power - 5)) << FM_PCD_MANIP_IPSEC_ARW_SIZE_SHIFT;
+ }
+ if (p_ManipParams->h_NextManip)
+ tmpReg32 |=
+ (uint32_t)(XX_VirtToPhys(((t_FmPcdManip *)p_ManipParams->h_NextManip)->h_Ad)-
+ (((t_FmPcd *)p_Manip->h_FmPcd)->physicalMuramBase)) >> 4;
+ WRITE_UINT32(p_Ad->matchTblPtr, tmpReg32);
- /*UDP checksum has to be 0*/
- if(p_InsrtByTemplate->modifyOuterIpParams.udpPresent)
- {
- if((p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_UDPHECKSUM_FIELD_OFFSET_FROM_UDP + UDP_UDPCHECKSUM_FIELD_SIZE) > p_InsrtByTemplate->size)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Inconsistent parameters : UDP present according to user but (UDP offset + UDP header size) < size of header template"));
+ tmpReg32 = HMAN_OC_IPSEC_MANIP;
+ tmpReg32 |= p_IPSecParams->outerIPHdrLen
+ << FM_PCD_MANIP_IPSEC_IP_HDR_LEN_SHIFT;
+ if (p_ManipParams->h_NextManip)
+ tmpReg32 |= FM_PCD_MANIP_IPSEC_NADEN;
+ WRITE_UINT32(p_Ad->pcAndOffsets, tmpReg32);
- p_Template[p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_UDPHECKSUM_FIELD_OFFSET_FROM_UDP ] = 0x00;
- p_Template[p_InsrtByTemplate->modifyOuterIpParams.udpOffset + UDP_UDPHECKSUM_FIELD_OFFSET_FROM_UDP + 1] = 0x00;
+ return err;
+}
- }
+static t_Error SetCapwapReassmManip(t_FmPcdManip *p_Manip)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd *)p_Manip->h_FmPcd;
- if(p_InsrtByTemplate->modifyOuterIpParams.ipIdentGenId > 7)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("ipIdentGenId has to be one out of 8 sequence number generators (0 - 7) for IP identification field"));
+ /* Allocation if CAPWAP Action descriptor */
+ p_Manip->reassmParams.capwap.h_Ad = (t_Handle)XX_MallocSmart(
+ FM_PCD_CC_AD_ENTRY_SIZE, p_Manip->reassmParams.dataMemId,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if (!p_Manip->reassmParams.capwap.h_Ad)
+ {
+ ReleaseManipHandler(p_Manip, p_FmPcd);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("Allocation of CAPWAP table descriptor"));
+ }
- tmpRegNia |= (uint32_t)p_InsrtByTemplate->modifyOuterIpParams.ipIdentGenId<<24;
- }
- else
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("IP version supported only IPV4"));
- }
+ memset(p_Manip->reassmParams.capwap.h_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
- tmpReg32 = tmpReg16 = tmpReg8 = 0;
- /*TODO - check it*/
- if(p_InsrtByTemplate->modifyOuterVlan)
- {
- if(p_InsrtByTemplate->modifyOuterVlanParams.vpri & ~0x07)
- RETURN_ERROR(MAJOR, E_INVALID_STATE,("Inconsistent parameters : user asked for VLAN modifications but VPRI more than 3 bits"));
+ /* Fill reassembly manipulation parameter in the Reassembly Action Descriptor */
+ return FillReassmManipParams(p_Manip, HEADER_TYPE_CAPWAP);
+}
- memcpy(&tmpReg16, &p_Template[VLAN_TAG_FIELD_OFFSET_FROM_ETH], 2*(sizeof(uint8_t)));
- if((tmpReg16 != 0x9100) && (tmpReg16!= 0x9200) && (tmpReg16 != 0x8100))
- RETURN_ERROR(MAJOR, E_INVALID_STATE,("Inconsistent parameters : user asked for VLAN modifications but Tag Protocol identifier is not VLAN "));
+static void setCapwapReassmSchemeParams(t_FmPcd* p_FmPcd,
+ t_FmPcdKgSchemeParams *p_Scheme,
+ t_Handle h_CcTree, uint8_t groupId)
+{
+ uint8_t res;
+
+ /* Configures scheme's network environment parameters */
+ p_Scheme->netEnvParams.numOfDistinctionUnits = 1;
+ res = FmPcdNetEnvGetUnitId(
+ p_FmPcd, FmPcdGetNetEnvId(p_Scheme->netEnvParams.h_NetEnv),
+ HEADER_TYPE_USER_DEFINED_SHIM2, FALSE, 0);
+ ASSERT_COND(res != FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS);
+ p_Scheme->netEnvParams.unitIds[0] = res;
+
+ /* Configures scheme's next engine parameters*/
+ p_Scheme->nextEngine = e_FM_PCD_CC;
+ p_Scheme->kgNextEngineParams.cc.h_CcTree = h_CcTree;
+ p_Scheme->kgNextEngineParams.cc.grpId = groupId;
+ p_Scheme->useHash = TRUE;
+
+ /* Configures scheme's key*/
+ p_Scheme->keyExtractAndHashParams.numOfUsedExtracts = 2;
+ p_Scheme->keyExtractAndHashParams.extractArray[0].type =
+ e_FM_PCD_EXTRACT_NON_HDR;
+ p_Scheme->keyExtractAndHashParams.extractArray[0].extractNonHdr.src =
+ e_FM_PCD_EXTRACT_FROM_PARSE_RESULT;
+ p_Scheme->keyExtractAndHashParams.extractArray[0].extractNonHdr.action =
+ e_FM_PCD_ACTION_NONE;
+ p_Scheme->keyExtractAndHashParams.extractArray[0].extractNonHdr.offset = 20;
+ p_Scheme->keyExtractAndHashParams.extractArray[0].extractNonHdr.size = 4;
+ p_Scheme->keyExtractAndHashParams.extractArray[1].type =
+ e_FM_PCD_EXTRACT_NON_HDR;
+ p_Scheme->keyExtractAndHashParams.extractArray[1].extractNonHdr.src =
+ e_FM_PCD_EXTRACT_FROM_DFLT_VALUE;
+ p_Scheme->keyExtractAndHashParams.extractArray[1].extractNonHdr.action =
+ e_FM_PCD_ACTION_NONE;
+ p_Scheme->keyExtractAndHashParams.extractArray[1].extractNonHdr.offset = 0;
+ p_Scheme->keyExtractAndHashParams.extractArray[1].extractNonHdr.size = 1;
+
+ p_Scheme->keyExtractAndHashParams.privateDflt0 = 0x0;
+ p_Scheme->keyExtractAndHashParams.privateDflt1 = 0x0;
+ p_Scheme->keyExtractAndHashParams.numOfUsedDflts = 1;
+ p_Scheme->keyExtractAndHashParams.dflts[0].type = e_FM_PCD_KG_GENERIC_NOT_FROM_DATA;
+ p_Scheme->keyExtractAndHashParams.dflts[0].dfltSelect = e_FM_PCD_KG_DFLT_PRIVATE_0;
+}
- memcpy(&tmpReg8, &p_Template[14],1*(sizeof(uint8_t)));
- tmpReg8 &= 0x1f;
- tmpReg8 |= (uint8_t)(p_InsrtByTemplate->modifyOuterVlanParams.vpri << 5);
+#if (DPAA_VERSION >= 11)
+static t_Error CapwapReassemblyStats(t_FmPcdManip *p_Manip,
+ t_FmPcdManipReassemCapwapStats *p_Stats)
+{
+ ASSERT_COND(p_Manip);
+ ASSERT_COND(p_Stats);
+ ASSERT_COND(p_Manip->reassmParams.p_ReassCommonTbl);
+
+ p_Stats->timeout =
+ GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalTimeOutCounter);
+ p_Stats->rfdPoolBusy =
+ GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalRfdPoolBusyCounter);
+ p_Stats->internalBufferBusy =
+ GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalInternalBufferBusy);
+ p_Stats->externalBufferBusy =
+ GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalExternalBufferBusy);
+ p_Stats->sgFragments =
+ GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalSgFragmentCounter);
+ p_Stats->dmaSemaphoreDepletion =
+ GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalDmaSemaphoreDepletionCounter);
+ p_Stats->exceedMaxReassemblyFrameLen =
+ GET_UINT32(p_Manip->reassmParams.p_ReassCommonTbl->totalNCSPCounter);
+
+ p_Stats->successfullyReassembled =
+ GET_UINT32(p_Manip->reassmParams.capwap.p_ReassTbl->totalSuccessfullyReasmFramesCounter);
+ p_Stats->validFragments =
+ GET_UINT32(p_Manip->reassmParams.capwap.p_ReassTbl->totalValidFragmentCounter);
+ p_Stats->processedFragments =
+ GET_UINT32(p_Manip->reassmParams.capwap.p_ReassTbl->totalProcessedFragCounter);
+ p_Stats->malformedFragments =
+ GET_UINT32(p_Manip->reassmParams.capwap.p_ReassTbl->totalMalformdFragCounter);
+ p_Stats->autoLearnBusy =
+ GET_UINT32(p_Manip->reassmParams.capwap.p_ReassTbl->totalSetBusyCounter);
+ p_Stats->discardedFragments =
+ GET_UINT32(p_Manip->reassmParams.capwap.p_ReassTbl->totalDiscardedFragsCounter);
+ p_Stats->moreThan16Fragments =
+ GET_UINT32(p_Manip->reassmParams.capwap.p_ReassTbl->totalMoreThan16FramesCounter);
- p_Template[14] = tmpReg8;
- }
+ return E_OK;
+}
- Mem2IOCpy32(p_Manip->p_Template, p_Template, p_InsrtByTemplate->size);
+static t_Error CapwapFragmentationStats(t_FmPcdManip *p_Manip,
+ t_FmPcdManipFragCapwapStats *p_Stats)
+{
+ t_AdOfTypeContLookup *p_Ad;
- XX_Free(p_Template);
- }
+ ASSERT_COND(p_Manip);
+ ASSERT_COND(p_Stats);
+ ASSERT_COND(p_Manip->h_Ad);
+ ASSERT_COND(p_Manip->fragParams.p_Frag);
- tmpReg32 = 0;
- if(p_Manip->h_Frag)
- {
- tmpRegNia |= (uint32_t)(XX_VirtToPhys(p_Manip->h_Frag) - (p_FmPcd->physicalMuramBase));
- tmpReg32 |= (uint32_t)p_Manip->sizeForFragmentation << 16;
- }
- else
- tmpReg32 = 0xffff0000;
+ p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
- if(ipModify)
- tmpReg32 |= (uint32_t)p_InsrtByTemplate->modifyOuterIpParams.ipOuterOffset << 8;
- else
- tmpReg32 |= (uint32_t)0x0000ff00;
+ p_Stats->totalFrames = GET_UINT32(p_Ad->gmask);
- tmpReg32 |= (uint32_t)HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER;
- *(uint32_t *)&p_Ad->pcAndOffsets = tmpReg32;
+ return E_OK;
+}
- tmpRegNia |= FM_PCD_AD_CONT_LOOKUP_TYPE;
- *(uint32_t *)&p_Ad->ccAdBase = tmpRegNia;
+static t_Error CapwapReassembly(t_FmPcdManipReassemParams *p_ManipReassmParams,
+ t_FmPcdManip *p_Manip)
+{
+ uint32_t maxSetNumber = 10000;
+ t_FmPcdManipReassemCapwapParams reassmManipParams =
+ p_ManipReassmParams->u.capwapReassem;
+ t_Error res;
+
+ SANITY_CHECK_RETURN_ERROR(p_Manip->h_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(((t_FmPcd *)p_Manip->h_FmPcd)->h_Hc,
+ E_INVALID_HANDLE);
+
+ /* Check validation of user's parameter.*/
+ if ((reassmManipParams.timeoutThresholdForReassmProcess < 1000)
+ || (reassmManipParams.timeoutThresholdForReassmProcess > 8000000))
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("timeoutThresholdForReassmProcess should be 1msec - 8sec"));
+ /* It is recommended that the total number of entries in this table (number of sets * number of ways)
+ will be twice the number of frames that are expected to be reassembled simultaneously.*/
+ if (reassmManipParams.maxNumFramesInProcess
+ > (reassmManipParams.maxNumFramesInProcess * maxSetNumber / 2))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("maxNumFramesInProcess has to be less than (maximun set number * number of ways / 2)"));
+
+ /* Saves user's reassembly manipulation parameters */
+ p_Manip->reassmParams.capwap.relativeSchemeId =
+ reassmManipParams.relativeSchemeId;
+ p_Manip->reassmParams.capwap.numOfFramesPerHashEntry =
+ reassmManipParams.numOfFramesPerHashEntry;
+ p_Manip->reassmParams.capwap.maxRessembledsSize =
+ reassmManipParams.maxReassembledFrameLength;
+ p_Manip->reassmParams.maxNumFramesInProcess =
+ reassmManipParams.maxNumFramesInProcess;
+ p_Manip->reassmParams.timeOutMode = reassmManipParams.timeOutMode;
+ p_Manip->reassmParams.fqidForTimeOutFrames =
+ reassmManipParams.fqidForTimeOutFrames;
+ p_Manip->reassmParams.timeoutThresholdForReassmProcess =
+ reassmManipParams.timeoutThresholdForReassmProcess;
+ p_Manip->reassmParams.dataMemId = reassmManipParams.dataMemId;
+ p_Manip->reassmParams.dataLiodnOffset = reassmManipParams.dataLiodnOffset;
+
+ /* Creates and initializes the Reassembly common parameter table */
+ CreateReassCommonTable(p_Manip);
+
+ res = SetCapwapReassmManip(p_Manip);
+ if (res != E_OK)
+ return res;
- return err;
+ return E_OK;
}
-#if defined(UNDER_CONSTRUCTION_FRAG_REASSEMBLY) || defined(UNDER_CONSTRUCTION_IPSEC)
-static t_Error IPSecManip(t_FmPcdManipParams *p_ManipParams, t_FmPcdManip *p_Manip, t_FmPcd *p_FmPcd)
+static t_Error CapwapFragmentation(t_FmPcdManipFragCapwapParams *p_ManipParams,
+ t_FmPcdManip *p_Manip)
{
+ t_FmPcd *p_FmPcd;
+ t_AdOfTypeContLookup *p_Ad;
+ uint32_t pcAndOffsetsReg = 0, ccAdBaseReg = 0, gmaskReg = 0;
+ uint32_t tmpReg32 = 0, tmpRegNia = 0;
- t_Error err = E_OK;
- t_AdOfTypeContLookup *p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
- uint32_t tmpReg32 = 0, tmpRegNia = 0;
-
- SANITY_CHECK_RETURN_ERROR(p_Manip,E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd,E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Manip->h_Ad, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_ManipParams->sizeForFragmentation != 0xFFFF,
+ E_INVALID_VALUE);
+ p_FmPcd = p_Manip->h_FmPcd;
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- if(p_Manip->frag == TRUE)
+ /* Allocation of fragmentation Action Descriptor */
+ p_Manip->fragParams.p_Frag = (t_AdOfTypeContLookup *)FM_MURAM_AllocMem(
+ p_FmPcd->h_FmMuram, FM_PCD_CC_AD_ENTRY_SIZE,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if (!p_Manip->fragParams.p_Frag)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("MURAM alloc for Fragmentation table descriptor"));
+ MemSet8(p_Manip->fragParams.p_Frag, 0, FM_PCD_CC_AD_ENTRY_SIZE);
+
+ /* Prepare the third Ad register (pcAndOffsets)- OperationCode */
+ pcAndOffsetsReg = (uint32_t)HMAN_OC_CAPWAP_FRAGMENTATION;
+
+ /* Prepare the first Ad register (ccAdBase) - Don't frag action and Action descriptor type*/
+ ccAdBaseReg = FM_PCD_AD_CONT_LOOKUP_TYPE;
+ ccAdBaseReg |=
+ (p_ManipParams->compressModeEn) ? FM_PCD_MANIP_CAPWAP_FRAG_COMPRESS_EN :
+ 0;
+
+ /* Set Scatter/Gather BPid */
+ if (p_ManipParams->sgBpidEn)
{
- tmpRegNia |= (uint32_t)(XX_VirtToPhys(p_Manip->h_Frag) - (p_FmPcd->physicalMuramBase));
- tmpReg32 |= (uint32_t)p_Manip->sizeForFragmentation << 16;
+ ccAdBaseReg |= FM_PCD_MANIP_CAPWAP_FRAG_SG_BDID_EN;
+ pcAndOffsetsReg |= ((p_ManipParams->sgBpid
+ << FM_PCD_MANIP_CAPWAP_FRAG_SG_BDID_SHIFT)
+ & FM_PCD_MANIP_CAPWAP_FRAG_SG_BDID_MASK);
}
- else
- tmpReg32 = 0xffff0000;
+
+ /* Prepare the first Ad register (gmask) - scratch buffer pool id and Pointer to fragment ID */
+ gmaskReg = (uint32_t)(XX_VirtToPhys(UINT_TO_PTR(p_FmPcd->capwapFrameIdAddr))
+ - p_FmPcd->physicalMuramBase);
+ gmaskReg |= (0xFF) << FM_PCD_MANIP_IP_FRAG_SCRATCH_BPID;
+
+ /* Set all Ad registers */
+ WRITE_UINT32(p_Manip->fragParams.p_Frag->pcAndOffsets, pcAndOffsetsReg);
+ WRITE_UINT32(p_Manip->fragParams.p_Frag->ccAdBase, ccAdBaseReg);
+ WRITE_UINT32(p_Manip->fragParams.p_Frag->gmask, gmaskReg);
+
+ /* Saves user's fragmentation manipulation parameters */
+ p_Manip->frag = TRUE;
+ p_Manip->sizeForFragmentation = p_ManipParams->sizeForFragmentation;
+
+ p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
+
+ tmpRegNia = (uint32_t)(XX_VirtToPhys(p_Manip->fragParams.p_Frag)
+ - (p_FmPcd->physicalMuramBase));
+ tmpReg32 = (uint32_t)p_Manip->sizeForFragmentation
+ << FM_PCD_MANIP_CAPWAP_FRAG_CHECK_MTU_SHIFT;
tmpRegNia |= FM_PCD_AD_CONT_LOOKUP_TYPE;
- tmpReg32 |= HMAN_OC_IPSEC;
+ tmpReg32 |= HMAN_OC_CAPWAP_FRAG_CHECK;
+
+ tmpRegNia |= FM_PCD_MANIP_CAPWAP_FRAG_CHECK_CNIA;
WRITE_UINT32(p_Ad->pcAndOffsets, tmpReg32);
WRITE_UINT32(p_Ad->ccAdBase, tmpRegNia);
- WRITE_UINT32(p_Ad->gmask, 0); /* Total frame counter - MUST be initialized to zero.*/
+ WRITE_UINT32(p_Ad->gmask, 0);
+ /* Total frame counter - MUST be initialized to zero.*/
-/*
- TODO - Fill the following:
- - Over write OuterTos
- - SaveInnerTos
- - support in CNIA
-*/
+ return E_OK;
+}
- return err;
+static t_Error UpdateInitCapwapFrag(t_Handle h_FmPcd, t_Handle h_PcdParams,
+ t_Handle h_FmPort, t_FmPcdManip *p_Manip,
+ t_Handle h_Ad, bool validate)
+{
+ t_FmPortGetSetCcParams fmPortGetSetCcParams;
+ t_Error err;
+
+ SANITY_CHECK_RETURN_ERROR(p_Manip, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Manip->opcode == HMAN_OC_CAPWAP_FRAGMENTATION),
+ E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
+
+ UNUSED(h_FmPcd);
+ UNUSED(h_Ad);
+ UNUSED(h_PcdParams);
+ UNUSED(validate);
+ UNUSED(p_Manip);
+
+ fmPortGetSetCcParams.setCcParams.type = 0;
+ fmPortGetSetCcParams.getCcParams.type = MANIP_EXTRA_SPACE;
+ if ((err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams)) != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ if (!fmPortGetSetCcParams.getCcParams.internalBufferOffset)
+ DBG(WARNING, ("manipExtraSpace must be larger than '0'"));
+
+ return E_OK;
}
-#endif /* (defined(UNDER_CONSTRUCTION_FRAG_REASSEMBLY) || ... */
-static t_Error CheckStatsParamsAndSetType(t_FmPcdManip *p_Manip, t_FmPcdStatsParams *p_StatsParams)
+static t_Error CapwapManip(t_FmPcdManipParams *p_ManipParams,
+ t_FmPcdManip *p_Manip)
{
+ t_AdOfTypeContLookup *p_Ad;
+ t_FmPcdManipSpecialOffloadCapwapParams *p_Params;
+ t_Error err = E_OK;
+ uint32_t tmpReg32 = 0;
- switch(p_StatsParams->type)
+ SANITY_CHECK_RETURN_ERROR(p_Manip, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_ManipParams, E_INVALID_HANDLE);
+
+ p_Params = &p_ManipParams->u.specialOffload.u.capwap;
+
+ p_Ad = (t_AdOfTypeContLookup *)p_Manip->h_Ad;
+ tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
+ tmpReg32 |= (p_Params->dtls) ? FM_PCD_MANIP_CAPWAP_DTLS : 0;
+ /* TODO - add 'qosSrc' */
+ WRITE_UINT32(p_Ad->ccAdBase, tmpReg32);
+
+ tmpReg32 = HMAN_OC_CAPWAP_MANIP;
+ if (p_ManipParams->h_NextManip)
{
- case(e_FM_PCD_STATS_PER_FLOWID):
- p_Manip->type = HMAN_OC_CAPWAP_INDEXED_STATS;
- p_Manip->muramAllocate = TRUE;
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Unsupported statistics type"));
+ WRITE_UINT32(
+ p_Ad->matchTblPtr,
+ (uint32_t)(XX_VirtToPhys(((t_FmPcdManip *)p_ManipParams->h_NextManip)->h_Ad)- (((t_FmPcd *)p_Manip->h_FmPcd)->physicalMuramBase)) >> 4);
+
+ tmpReg32 |= FM_PCD_MANIP_CAPWAP_NADEN;
}
- return E_OK;
+ WRITE_UINT32(p_Ad->pcAndOffsets, tmpReg32);
+
+ return err;
}
+#endif /* (DPAA_VERSION >= 11) */
-static t_Handle ManipOrStatsSetNode(t_Handle h_FmPcd, t_Handle *p_Params, bool stats)
+static t_Handle ManipOrStatsSetNode(t_Handle h_FmPcd, t_Handle *p_Params,
+ bool stats)
{
- t_FmPcdManip *p_Manip;
- t_Error err;
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ t_FmPcdManip *p_Manip;
+ t_Error err;
+ t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
p_Manip = (t_FmPcdManip*)XX_Malloc(sizeof(t_FmPcdManip));
- if(!p_Manip)
+ if (!p_Manip)
{
REPORT_ERROR(MAJOR, E_NO_MEMORY, ("No memory"));
return NULL;
}
memset(p_Manip, 0, sizeof(t_FmPcdManip));
- if(!stats)
- {
- err = CheckManipParamsAndSetType(p_Manip, (t_FmPcdManipParams *)p_Params);
- }
+ p_Manip->type = ((t_FmPcdManipParams *)p_Params)->type;
+ memcpy((uint8_t*)&p_Manip->manipParams, p_Params,
+ sizeof(p_Manip->manipParams));
+
+ if (!stats)
+ err = CheckManipParamsAndSetType(p_Manip,
+ (t_FmPcdManipParams *)p_Params);
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
else
- {
err = CheckStatsParamsAndSetType(p_Manip, (t_FmPcdStatsParams *)p_Params);
+#else /* not (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
+ else
+ {
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Statistics node!"));
+ XX_Free(p_Manip);
+ return NULL;
}
-
- if(err)
+#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
+ if (err)
{
- REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("INVALID HEADER MANIPULATION TYPE"));
- ReleaseManipHandler(p_Manip, p_FmPcd);
+ REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Invalid header manipulation type"));
XX_Free(p_Manip);
return NULL;
}
-#ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
- if(p_Manip->type != HMAN_OC_IP_REASSEMBLY)
- {
-#endif /* UNDER_CONSTRUCTION_FRAG_REASSEMBLY */
- if(p_Manip->muramAllocate)
+ if ((p_Manip->opcode != HMAN_OC_IP_REASSEMBLY) && (p_Manip->opcode != HMAN_OC_CAPWAP_REASSEMBLY))
{
- p_Manip->h_Ad = (t_Handle)FM_MURAM_AllocMem(p_FmPcd->h_FmMuram,
- FM_PCD_CC_AD_ENTRY_SIZE,
- FM_PCD_CC_AD_TABLE_ALIGN);
- if(!p_Manip->h_Ad)
- {
- REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
- ReleaseManipHandler(p_Manip, p_FmPcd);
- XX_Free(p_Manip);
- return NULL;
- }
+ /* In Case of reassembly manipulation the reassembly action descriptor will
+ be defines later on */
+ if (p_Manip->muramAllocate)
+ {
+ p_Manip->h_Ad = (t_Handle)FM_MURAM_AllocMem(
+ p_FmPcd->h_FmMuram, FM_PCD_CC_AD_ENTRY_SIZE,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if (!p_Manip->h_Ad)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for Manipulation action descriptor"));
+ ReleaseManipHandler(p_Manip, p_FmPcd);
+ XX_Free(p_Manip);
+ return NULL;
+ }
- IOMemSet32(p_Manip->h_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
- }
- else
- {
- p_Manip->h_Ad = (t_Handle)XX_Malloc(FM_PCD_CC_AD_ENTRY_SIZE * sizeof(uint8_t));
- if(!p_Manip->h_Ad)
- {
- REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Memory allocation in MURAM FAILED"));
- ReleaseManipHandler(p_Manip, p_FmPcd);
- XX_Free(p_Manip);
- return NULL;
- }
+ MemSet8(p_Manip->h_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
+ }
+ else
+ {
+ p_Manip->h_Ad = (t_Handle)XX_Malloc(
+ FM_PCD_CC_AD_ENTRY_SIZE * sizeof(uint8_t));
+ if (!p_Manip->h_Ad)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Allocation of Manipulation action descriptor"));
+ ReleaseManipHandler(p_Manip, p_FmPcd);
+ XX_Free(p_Manip);
+ return NULL;
+ }
- memset(p_Manip->h_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE * sizeof(uint8_t));
- }
-#ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
+ memset(p_Manip->h_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE * sizeof(uint8_t));
+ }
}
-#endif /* UNDER_CONSTRUCTION_FRAG_REASSEMBLY */
+
p_Manip->h_FmPcd = h_FmPcd;
return p_Manip;
}
+static void UpdateAdPtrOfNodesWhichPointsOnCrntMdfManip(
+ t_FmPcdManip *p_CrntMdfManip, t_List *h_NodesLst)
+{
+ t_CcNodeInformation *p_CcNodeInformation;
+ t_FmPcdCcNode *p_NodePtrOnCurrentMdfManip = NULL;
+ t_List *p_Pos;
+ int i = 0;
+ t_Handle p_AdTablePtOnCrntCurrentMdfNode/*, p_AdTableNewModified*/;
+ t_CcNodeInformation ccNodeInfo;
+
+ NCSW_LIST_FOR_EACH(p_Pos, &p_CrntMdfManip->nodesLst)
+ {
+ p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);
+ p_NodePtrOnCurrentMdfManip =
+ (t_FmPcdCcNode *)p_CcNodeInformation->h_CcNode;
+
+ ASSERT_COND(p_NodePtrOnCurrentMdfManip);
-t_Error FmPcdManipUpdate(t_Handle h_FmPcd, t_Handle h_FmPort, t_Handle h_Manip, t_Handle h_Ad, bool validate, int level, t_Handle h_FmTree, bool modify)
+ /* Search in the previous node which exact index points on this current modified node for getting AD */
+ for (i = 0; i < p_NodePtrOnCurrentMdfManip->numOfKeys + 1; i++)
+ {
+ if (p_NodePtrOnCurrentMdfManip->keyAndNextEngineParams[i].nextEngineParams.nextEngine
+ == e_FM_PCD_CC)
+ {
+ if (p_NodePtrOnCurrentMdfManip->keyAndNextEngineParams[i].nextEngineParams.h_Manip
+ == (t_Handle)p_CrntMdfManip)
+ {
+ if (p_NodePtrOnCurrentMdfManip->keyAndNextEngineParams[i].p_StatsObj)
+ p_AdTablePtOnCrntCurrentMdfNode =
+ p_NodePtrOnCurrentMdfManip->keyAndNextEngineParams[i].p_StatsObj->h_StatsAd;
+ else
+ p_AdTablePtOnCrntCurrentMdfNode =
+ PTR_MOVE(p_NodePtrOnCurrentMdfManip->h_AdTable, i*FM_PCD_CC_AD_ENTRY_SIZE);
+
+ memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));
+ ccNodeInfo.h_CcNode = p_AdTablePtOnCrntCurrentMdfNode;
+ EnqueueNodeInfoToRelevantLst(h_NodesLst, &ccNodeInfo, NULL);
+ }
+ }
+ }
+
+ ASSERT_COND(i != p_NodePtrOnCurrentMdfManip->numOfKeys);
+ }
+}
+
+static void BuildHmtd(uint8_t *p_Dest, uint8_t *p_Src, uint8_t *p_Hmcd,
+ t_FmPcd *p_FmPcd)
{
t_Error err;
- if(!modify)
- {
- err = FmPcdManipInitUpdate(h_FmPcd, h_FmPort, h_Manip, h_Ad, validate, level, h_FmTree);
- }
- else
+ /* Copy the HMTD */
+ MemCpy8(p_Dest, (uint8_t*)p_Src, 16);
+ /* Replace the HMCT table pointer */
+ WRITE_UINT32(
+ ((t_Hmtd *)p_Dest)->hmcdBasePtr,
+ (uint32_t)(XX_VirtToPhys(p_Hmcd) - ((t_FmPcd*)p_FmPcd)->physicalMuramBase));
+ /* Call Host Command to replace HMTD by a new HMTD */
+ err = FmHcPcdCcDoDynamicChange(
+ p_FmPcd->h_Hc,
+ (uint32_t)(XX_VirtToPhys(p_Src) - p_FmPcd->physicalMuramBase),
+ (uint32_t)(XX_VirtToPhys(p_Dest) - p_FmPcd->physicalMuramBase));
+ if (err)
+ REPORT_ERROR(MINOR, err, ("Failed in dynamic manip change, continued to the rest of the owners."));
+}
+
+static t_Error FmPcdManipInitUpdate(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)
+{
+ t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(h_Manip, E_INVALID_HANDLE);
+
+ UNUSED(level);
+ UNUSED(h_FmTree);
+
+ switch (p_Manip->opcode)
{
- err = FmPcdManipModifyUpdate(h_Manip, h_Ad, validate, level, h_FmTree);
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
+ case (HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
+ err = UpdateInitMvIntFrameHeaderFromFrameToBufferPrefix(h_FmPort,
+ p_Manip,
+ h_Ad,
+ validate);
+ break;
+ case (HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER):
+ if (!p_Manip->h_Frag)
+ break;
+ case (HMAN_OC_CAPWAP_FRAGMENTATION):
+ err = UpdateInitCapwapFragmentation(h_FmPort, p_Manip, h_Ad, validate, h_FmTree);
+ break;
+ case (HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
+ if (p_Manip->h_Frag)
+ err = UpdateInitCapwapReasm(h_FmPcd, h_FmPort, p_Manip, h_Ad, validate);
+ break;
+ case (HMAN_OC_CAPWAP_INDEXED_STATS):
+ err = UpdateIndxStats(h_FmPcd, h_FmPort, p_Manip);
+ break;
+#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
+ case (HMAN_OC_IP_REASSEMBLY):
+ err = UpdateInitReasm(h_FmPcd, h_PcdParams, h_FmPort, p_Manip, h_Ad,
+ validate);
+ break;
+ case (HMAN_OC_IP_FRAGMENTATION):
+ err = UpdateInitIpFrag(h_FmPcd, h_PcdParams, h_FmPort, p_Manip,
+ h_Ad, validate);
+ break;
+#if (DPAA_VERSION >= 11)
+ case (HMAN_OC_CAPWAP_FRAGMENTATION):
+ err = UpdateInitCapwapFrag(h_FmPcd, h_PcdParams, h_FmPort, p_Manip,
+ h_Ad, validate);
+ break;
+ case (HMAN_OC_CAPWAP_REASSEMBLY):
+ err = UpdateInitReasm(h_FmPcd, h_PcdParams, h_FmPort, p_Manip, h_Ad,
+ validate);
+ break;
+#endif /* (DPAA_VERSION >= 11) */
+ default:
+ return E_OK;
}
+
return err;
}
-uint32_t FmPcdManipGetRequiredAction (t_Handle h_Manip)
+static t_Error FmPcdManipModifyUpdate(t_Handle h_Manip, t_Handle h_Ad,
+ bool validate, int level,
+ t_Handle h_FmTree)
{
+
t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
+ t_Error err = E_OK;
- ASSERT_COND(h_Manip);
+ UNUSED(level);
- switch(p_Manip->type)
+ switch (p_Manip->opcode)
{
- case(HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
- case(HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
- return UPDATE_NIA_ENQ_WITHOUT_DMA;
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
+ case (HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("modify node with this type of manipulation is not suppported"));
+ case (HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
+
+ if (p_Manip->h_Frag)
+ {
+ if (!(p_Manip->shadowUpdateParams & NUM_OF_TASKS)
+ && !(p_Manip->shadowUpdateParams & OFFSET_OF_DATA)
+ && !(p_Manip->shadowUpdateParams & OFFSET_OF_PR))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("modify node with this type of manipulation requires manipulation be updated previously in SetPcd function"));
+ }
+ break;
+ case (HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER):
+ if (p_Manip->h_Frag)
+ err = UpdateModifyCapwapFragmenation(p_Manip, h_Ad, validate, h_FmTree);
+ break;
+#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
default:
- return 0;
+ return E_OK;
}
+
+ return err;
+}
+
+/*****************************************************************************/
+/* Inter-module API routines */
+/*****************************************************************************/
+
+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)
+{
+ t_Error err;
+
+ if (!modify)
+ err = FmPcdManipInitUpdate(h_FmPcd, h_PcdParams, h_FmPort, h_Manip,
+ h_Ad, validate, level, h_FmTree);
+ else
+ err = FmPcdManipModifyUpdate(h_Manip, h_Ad, validate, level, h_FmTree);
+
+ return err;
}
void FmPcdManipUpdateOwner(t_Handle h_Manip, bool add)
{
- if(add)
+ uint32_t intFlags;
+
+ intFlags = XX_LockIntrSpinlock(((t_FmPcdManip *)h_Manip)->h_Spinlock);
+ if (add)
((t_FmPcdManip *)h_Manip)->owner++;
else
{
ASSERT_COND(((t_FmPcdManip *)h_Manip)->owner);
((t_FmPcdManip *)h_Manip)->owner--;
}
+ XX_UnlockIntrSpinlock(((t_FmPcdManip *)h_Manip)->h_Spinlock, intFlags);
+}
+
+t_List *FmPcdManipGetNodeLstPointedOnThisManip(t_Handle h_Manip)
+{
+ ASSERT_COND(h_Manip);
+ return &((t_FmPcdManip *)h_Manip)->nodesLst;
}
-t_Error FmPcdManipCheckParamsForCcNextEgine(t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams, uint32_t *requiredAction)
+t_List *FmPcdManipGetSpinlock(t_Handle h_Manip)
{
- t_FmPcdManip *p_Manip;
- t_Error err;
+ ASSERT_COND(h_Manip);
+ return ((t_FmPcdManip *)h_Manip)->h_Spinlock;
+}
+t_Error FmPcdManipCheckParamsForCcNextEngine(
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams,
+ uint32_t *requiredAction)
+{
+ t_FmPcdManip *p_Manip;
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
+ t_Error err = E_OK;
+#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))*/
+ bool pointFromCc = TRUE;
SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);
- SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams->h_Manip, E_NULL_POINTER);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams->h_Manip,
+ E_NULL_POINTER);
p_Manip = (t_FmPcdManip *)(p_FmPcdCcNextEngineParams->h_Manip);
*requiredAction = 0;
- switch(p_Manip->type)
- {
- case(HMAN_OC_CAPWAP_INDEXED_STATS):
- if(p_FmPcdCcNextEngineParams->nextEngine != e_FM_PCD_DONE)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("For this type of header manipulation has to be nextEngine e_FM_PCD_DONE"));
- if(p_FmPcdCcNextEngineParams->params.enqueueParams.overrideFqid)
- p_Manip->cnia = TRUE;
- case(HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
- *requiredAction = UPDATE_NIA_ENQ_WITHOUT_DMA;
- case(HMAN_OC_RMV_N_OR_INSRT_INT_FRM_HDR):
- p_Manip->ownerTmp++;
- break;
- case(HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER):
- if((p_FmPcdCcNextEngineParams->nextEngine != e_FM_PCD_DONE) && !p_FmPcdCcNextEngineParams->params.enqueueParams.overrideFqid)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("For this type of header manipulation has to be nextEngine e_FM_PCD_DONE with fqidForCtrlFlow FALSE"));
- p_Manip->ownerTmp++;
- break;
- case(HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
- if((p_FmPcdCcNextEngineParams->nextEngine != e_FM_PCD_CC) &&
- (FmPcdCcGetParseCode(p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode) != CC_PC_GENERIC_IC_HASH_INDEXED))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("For this type of header manipulation next engine has to be CC and action = e_FM_PCD_ACTION_INDEXED_LOOKUP"));
- err = UpdateManipIc(p_FmPcdCcNextEngineParams->h_Manip, FmPcdCcGetOffset(p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode));
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
- *requiredAction = UPDATE_NIA_ENQ_WITHOUT_DMA;
- break;
-#if (defined(UNDER_CONSTRUCTION_FRAG_REASSEMBLY) || defined(UNDER_CONSTRUCTION_IPSEC))
- case(HMAN_OC_IPSEC):
- if((p_FmPcdCcNextEngineParams->nextEngine == e_FM_PCD_DONE) &&
- !p_FmPcdCcNextEngineParams->params.enqueueParams.overrideFqid)
- p_Manip->cnia = FALSE;
- else
- p_Manip->cnia = TRUE;
- if(!p_Manip->h_Frag)
- {
+ while (p_Manip)
+ {
+ switch (p_Manip->opcode)
+ {
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
+ case (HMAN_OC_CAPWAP_INDEXED_STATS):
+ if (p_FmPcdCcNextEngineParams->nextEngine != e_FM_PCD_DONE)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("For this type of header manipulation has to be nextEngine e_FM_PCD_DONE"));
+ if (p_FmPcdCcNextEngineParams->params.enqueueParams.overrideFqid)
+ p_Manip->cnia = TRUE;
+ case (HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
+ *requiredAction = UPDATE_NIA_ENQ_WITHOUT_DMA;
+ case (HMAN_OC_RMV_N_OR_INSRT_INT_FRM_HDR):
p_Manip->ownerTmp++;
break;
- }
-#ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
- case(HMAN_OC_IP_FRAGMENTATION):
- if(p_FmPcdCcNextEngineParams->nextEngine != e_FM_PCD_DONE)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("For this type of header manipulation has to be nextEngine e_FM_PCD_DONE"));
- p_Manip->ownerTmp++;
- break;
-#endif /*UNDER_CONSTRUCTION_FRAG_REASSEMBLY*/
- break;
-#endif /* (defined(UNDER_CONSTRUCTION_FRAG_REASSEMBLY) || ... */
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE,("invalid type of header manipulation for this state"));
+ case (HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER):
+ if ((p_FmPcdCcNextEngineParams->nextEngine != e_FM_PCD_DONE)
+ && !p_FmPcdCcNextEngineParams->params.enqueueParams.overrideFqid)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("For this type of header manipulation has to be nextEngine e_FM_PCD_DONE with fqidForCtrlFlow FALSE"));
+ p_Manip->ownerTmp++;
+ break;
+ case (HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
+ if ((p_FmPcdCcNextEngineParams->nextEngine != e_FM_PCD_CC)
+ && (FmPcdCcGetParseCode(p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode)
+ != CC_PC_GENERIC_IC_HASH_INDEXED))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("For this type of header manipulation next engine has to be CC and action = e_FM_PCD_ACTION_INDEXED_LOOKUP"));
+ err = UpdateManipIc(p_FmPcdCcNextEngineParams->h_Manip,
+ FmPcdCcGetOffset(p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode));
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ *requiredAction = UPDATE_NIA_ENQ_WITHOUT_DMA;
+ break;
+ #endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
+ case (HMAN_OC_IP_FRAGMENTATION):
+ case (HMAN_OC_IP_REASSEMBLY):
+#if (DPAA_VERSION >= 11)
+ case (HMAN_OC_CAPWAP_REASSEMBLY):
+ case (HMAN_OC_CAPWAP_FRAGMENTATION):
+#endif /* (DPAA_VERSION >= 11) */
+ if (p_FmPcdCcNextEngineParams->nextEngine != e_FM_PCD_DONE)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("For this type of header manipulation has to be nextEngine e_FM_PCD_DONE"));
+ p_Manip->ownerTmp++;
+ break;
+ case (HMAN_OC_IPSEC_MANIP):
+#if (DPAA_VERSION >= 11)
+ case (HMAN_OC_CAPWAP_MANIP):
+#endif /* (DPAA_VERSION >= 11) */
+ p_Manip->ownerTmp++;
+ break;
+ case (HMAN_OC):
+ if ((p_FmPcdCcNextEngineParams->nextEngine == e_FM_PCD_CC)
+ && MANIP_IS_CASCADED(p_Manip))
+ RETURN_ERROR(
+ MINOR,
+ E_INVALID_STATE,
+ ("Can't have a cascaded manipulation when and Next Engine is CC"));
+ if (!MANIP_IS_FIRST(p_Manip) && pointFromCc)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("h_Manip is already used and may not be shared (no sharing of non-head manip nodes)"));
+ break;
+ default:
+ RETURN_ERROR(
+ MAJOR, E_INVALID_STATE,
+ ("invalid type of header manipulation for this state"));
+ }
+ p_Manip = p_Manip->h_NextManip;
+ pointFromCc = FALSE;
}
-
return E_OK;
}
-t_Error FmPcdManipCheckParamsWithCcNodeParams(t_Handle h_Manip, t_Handle h_FmPcdCcNode)
+
+t_Error FmPcdManipCheckParamsWithCcNodeParams(t_Handle h_Manip,
+ t_Handle h_FmPcdCcNode)
{
t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
- t_Error err = E_OK;
+ t_Error err = E_OK;
SANITY_CHECK_RETURN_ERROR(h_Manip, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(h_FmPcdCcNode, E_INVALID_HANDLE);
- switch(p_Manip->type)
+ switch (p_Manip->opcode)
{
- case(HMAN_OC_CAPWAP_INDEXED_STATS):
- if(p_Manip->ownerTmp != FmPcdCcGetNumOfKeys(h_FmPcdCcNode))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("The manipulation of the type statistics flowId if exist has to be pointed by all numOfKeys"));
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
+ case (HMAN_OC_CAPWAP_INDEXED_STATS):
+ if (p_Manip->ownerTmp != FmPcdCcGetNumOfKeys(h_FmPcdCcNode))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("The manipulation of the type statistics flowId if exist has to be pointed by all numOfKeys"));
break;
- case(HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
- if(p_Manip->h_Frag)
- {
- if(p_Manip->ownerTmp != FmPcdCcGetNumOfKeys(h_FmPcdCcNode))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("The manipulation of the type remove DTLS if exist has to be pointed by all numOfKeys"));
- err = UpdateManipIc(h_Manip, FmPcdCcGetOffset(h_FmPcdCcNode));
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
- }
- break;
+ case (HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
+ if (p_Manip->h_Frag)
+ {
+ if (p_Manip->ownerTmp != FmPcdCcGetNumOfKeys(h_FmPcdCcNode))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("The manipulation of the type remove DTLS if exist has to be pointed by all numOfKeys"));
+ err = UpdateManipIc(h_Manip, FmPcdCcGetOffset(h_FmPcdCcNode));
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+ break;
+#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
default:
break;
}
+
return err;
}
-void FmPcdManipUpdateAdResultForCc(t_Handle h_Manip, t_Handle p_Ad, t_Handle *p_AdNew)
+void FmPcdManipUpdateAdResultForCc(
+ t_Handle h_Manip, t_FmPcdCcNextEngineParams *p_CcNextEngineParams,
+ t_Handle p_Ad, t_Handle *p_AdNewPtr)
{
- t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
+ t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
+
+ /* This routine creates a Manip AD and can return in "p_AdNewPtr"
+ * either the new descriptor or NULL if it writes the Manip AD into p_AD (into the match table) */
ASSERT_COND(p_Manip);
+ ASSERT_COND(p_CcNextEngineParams);
+ ASSERT_COND(p_Ad);
+ ASSERT_COND(p_AdNewPtr);
FmPcdManipUpdateOwner(h_Manip, TRUE);
- switch(p_Manip->type)
+ /* According to "type", either build & initialize a new AD (p_AdNew) or initialize
+ * p_Ad ( the AD in the match table) and set p_AdNew = NULL. */
+ switch (p_Manip->opcode)
{
- case(HMAN_OC_RMV_N_OR_INSRT_INT_FRM_HDR):
- case(HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
- case(HMAN_OC_CAPWAP_INDEXED_STATS):
-#if (defined(UNDER_CONSTRUCTION_FRAG_REASSEMBLY) || defined(UNDER_CONSTRUCTION_IPSEC))
- case(HMAN_OC_IP_FRAGMENTATION):
- case(HMAN_OC_IP_REASSEMBLY):
-#endif /* (defined(UNDER_CONSTRUCTION_FRAG_REASSEMBLY) || ... */
- *p_AdNew = p_Manip->h_Ad;
- break;
- case(HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER):
- case(HMAN_OC_CAPWAP_FRAGMENTATION):
- WRITE_UINT32(((t_AdOfTypeResult *)p_Ad)->fqid, ((t_AdOfTypeResult *)(p_Manip->h_Ad))->fqid);
- WRITE_UINT32(((t_AdOfTypeResult *)p_Ad)->plcrProfile, ((t_AdOfTypeResult *)(p_Manip->h_Ad))->plcrProfile);
- WRITE_UINT32(((t_AdOfTypeResult *)p_Ad)->nia, ((t_AdOfTypeResult *)(p_Manip->h_Ad))->nia);
- *p_AdNew = NULL;
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
+ case (HMAN_OC_RMV_N_OR_INSRT_INT_FRM_HDR):
+ case (HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
+ case (HMAN_OC_CAPWAP_INDEXED_STATS):
+ *p_AdNewPtr = p_Manip->h_Ad;
+ break;
+ case (HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER):
+ case (HMAN_OC_CAPWAP_FRAGMENTATION):
+ WRITE_UINT32(((t_AdOfTypeResult *)p_Ad)->fqid,
+ ((t_AdOfTypeResult *)(p_Manip->h_Ad))->fqid);
+ WRITE_UINT32(((t_AdOfTypeResult *)p_Ad)->plcrProfile,
+ ((t_AdOfTypeResult *)(p_Manip->h_Ad))->plcrProfile);
+ WRITE_UINT32(((t_AdOfTypeResult *)p_Ad)->nia,
+ ((t_AdOfTypeResult *)(p_Manip->h_Ad))->nia);
+ *p_AdNewPtr = NULL;
+ break;
+#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
+ case (HMAN_OC_IPSEC_MANIP):
+#if (DPAA_VERSION >= 11)
+ case (HMAN_OC_CAPWAP_MANIP):
+#endif /* (DPAA_VERSION >= 11) */
+ *p_AdNewPtr = p_Manip->h_Ad;
break;
-#if (defined(UNDER_CONSTRUCTION_FRAG_REASSEMBLY) || defined(UNDER_CONSTRUCTION_IPSEC))
- case(HMAN_OC_IPSEC):
- if (p_Manip->cnia)
- *p_AdNew = p_Manip->h_Ad;
+ case (HMAN_OC_IP_FRAGMENTATION):
+#if (DPAA_VERSION >= 11)
+ case (HMAN_OC_CAPWAP_FRAGMENTATION):
+#endif /* (DPAA_VERSION >= 11) */
+ if ((p_CcNextEngineParams->nextEngine == e_FM_PCD_DONE)
+ && (!p_CcNextEngineParams->params.enqueueParams.overrideFqid))
+ {
+ memcpy((uint8_t *)p_Ad, (uint8_t *)p_Manip->h_Ad,
+ sizeof(t_AdOfTypeContLookup));
+#if (DPAA_VERSION >= 11)
+ WRITE_UINT32(
+ ((t_AdOfTypeContLookup *)p_Ad)->ccAdBase,
+ GET_UINT32(((t_AdOfTypeContLookup *)p_Ad)->ccAdBase) & ~FM_PCD_MANIP_IP_CNIA);
+#endif /* (DPAA_VERSION >= 11) */
+ *p_AdNewPtr = NULL;
+ }
else
+ *p_AdNewPtr = p_Manip->h_Ad;
+ break;
+ case (HMAN_OC_IP_REASSEMBLY):
+ if (FmPcdManipIpReassmIsIpv6Hdr(p_Manip))
{
- WRITE_UINT32(((t_AdOfTypeResult *)p_Ad)->fqid, ((t_AdOfTypeResult *)(p_Manip->h_Ad))->fqid);
- WRITE_UINT32(((t_AdOfTypeResult *)p_Ad)->plcrProfile, ((t_AdOfTypeResult *)(p_Manip->h_Ad))->plcrProfile);
- WRITE_UINT32(((t_AdOfTypeResult *)p_Ad)->nia, ((t_AdOfTypeResult *)(p_Manip->h_Ad))->nia);
- *p_AdNew = NULL;
+ if (!p_Manip->reassmParams.ip.ipv6Assigned)
+ {
+ *p_AdNewPtr = p_Manip->reassmParams.ip.h_Ipv6Ad;
+ p_Manip->reassmParams.ip.ipv6Assigned = TRUE;
+ FmPcdManipUpdateOwner(h_Manip, FALSE);
+ }
+ else
+ {
+ *p_AdNewPtr = p_Manip->reassmParams.ip.h_Ipv4Ad;
+ p_Manip->reassmParams.ip.ipv6Assigned = FALSE;
+ }
}
+ else
+ *p_AdNewPtr = p_Manip->reassmParams.ip.h_Ipv4Ad;
+ memcpy((uint8_t *)p_Ad, (uint8_t *)*p_AdNewPtr,
+ sizeof(t_AdOfTypeContLookup));
+ *p_AdNewPtr = NULL;
+ break;
+#if (DPAA_VERSION >= 11)
+ case (HMAN_OC_CAPWAP_REASSEMBLY):
+ *p_AdNewPtr = p_Manip->reassmParams.capwap.h_Ad;
+ memcpy((uint8_t *)p_Ad, (uint8_t *)*p_AdNewPtr,
+ sizeof(t_AdOfTypeContLookup));
+ *p_AdNewPtr = NULL;
+ break;
+#endif /* (DPAA_VERSION >= 11) */
+ case (HMAN_OC):
+ /* Allocate and initialize HMTD */
+ *p_AdNewPtr = p_Manip->h_Ad;
break;
-#endif /* (defined(UNDER_CONSTRUCTION_FRAG_REASSEMBLY) || ... */
default:
break;
}
}
-void FmPcdManipUpdateAdContLookupForCc(t_Handle h_Manip, t_Handle p_Ad, t_Handle *p_AdNew, uint32_t adTableOffset)
+void FmPcdManipUpdateAdContLookupForCc(t_Handle h_Manip, t_Handle p_Ad,
+ t_Handle *p_AdNewPtr,
+ uint32_t adTableOffset)
{
- t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
+ t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
+ /* This routine creates a Manip AD and can return in "p_AdNewPtr"
+ * either the new descriptor or NULL if it writes the Manip AD into p_AD (into the match table) */
ASSERT_COND(p_Manip);
FmPcdManipUpdateOwner(h_Manip, TRUE);
- switch(p_Manip->type)
+ switch (p_Manip->opcode)
{
- case(HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
- WRITE_UINT32(((t_AdOfTypeContLookup *)p_Ad)->ccAdBase, ((t_AdOfTypeContLookup *)(p_Manip->h_Ad))->ccAdBase);
- WRITE_UINT32(((t_AdOfTypeContLookup *)p_Ad)->matchTblPtr, ((t_AdOfTypeContLookup *)(p_Manip->h_Ad))->matchTblPtr);
- WRITE_UINT32(((t_AdOfTypeContLookup *)p_Ad)->pcAndOffsets, ((t_AdOfTypeContLookup *)(p_Manip->h_Ad))->pcAndOffsets);
- WRITE_UINT32(((t_AdOfTypeContLookup *)p_Ad)->gmask, ((t_AdOfTypeContLookup *)(p_Manip->h_Ad))->gmask);
- WRITE_UINT32(((t_AdOfTypeContLookup *)p_Ad)->ccAdBase, (GET_UINT32(((t_AdOfTypeContLookup *)p_Ad)->ccAdBase) | adTableOffset));
- *p_AdNew = NULL;
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
+ case (HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
+ WRITE_UINT32(((t_AdOfTypeContLookup *)p_Ad)->ccAdBase,
+ ((t_AdOfTypeContLookup *)(p_Manip->h_Ad))->ccAdBase);
+ WRITE_UINT32(
+ ((t_AdOfTypeContLookup *)p_Ad)->matchTblPtr,
+ ((t_AdOfTypeContLookup *)(p_Manip->h_Ad))->matchTblPtr);
+ WRITE_UINT32(
+ ((t_AdOfTypeContLookup *)p_Ad)->pcAndOffsets,
+ ((t_AdOfTypeContLookup *)(p_Manip->h_Ad))->pcAndOffsets);
+ WRITE_UINT32(((t_AdOfTypeContLookup *)p_Ad)->gmask,
+ ((t_AdOfTypeContLookup *)(p_Manip->h_Ad))->gmask);
+ WRITE_UINT32(
+ ((t_AdOfTypeContLookup *)p_Ad)->ccAdBase,
+ (GET_UINT32(((t_AdOfTypeContLookup *)p_Ad)->ccAdBase) | adTableOffset));
+ *p_AdNewPtr = NULL;
+ break;
+#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
+ case (HMAN_OC):
+ /* Initialize HMTD within the match table*/
+ MemSet8(p_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
+ /* copy the existing HMTD *//* ask Alla - memcpy??? */
+ memcpy((uint8_t*)p_Ad, p_Manip->h_Ad, sizeof(t_Hmtd));
+ /* update NADEN to be "1"*/
+ WRITE_UINT16(
+ ((t_Hmtd *)p_Ad)->cfg,
+ (uint16_t)(GET_UINT16(((t_Hmtd *)p_Ad)->cfg) | HMTD_CFG_NEXT_AD_EN));
+ /* update next action descriptor */
+ WRITE_UINT16(((t_Hmtd *)p_Ad)->nextAdIdx,
+ (uint16_t)(adTableOffset >> 4));
+ /* mark that Manip's HMTD is not used */
+ *p_AdNewPtr = NULL;
break;
+
default:
break;
}
}
-t_Handle FM_PCD_ManipSetNode(t_Handle h_FmPcd, t_FmPcdManipParams *p_ManipParams)
+t_Error FmPcdManipBuildIpReassmScheme(t_FmPcd *p_FmPcd, t_Handle h_NetEnv,
+ t_Handle h_CcTree, t_Handle h_Manip,
+ bool isIpv4, uint8_t groupId)
{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- t_FmPcdManip *p_Manip;
- t_Error err;
+ t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
+ t_FmPcdKgSchemeParams *p_SchemeParams = NULL;
+ t_Handle h_Scheme;
- SANITY_CHECK_RETURN_VALUE(h_FmPcd,E_INVALID_HANDLE,NULL);
- SANITY_CHECK_RETURN_VALUE(p_ManipParams,E_INVALID_HANDLE,NULL);
+ ASSERT_COND(p_FmPcd);
+ ASSERT_COND(h_NetEnv);
+ ASSERT_COND(p_Manip);
+
+ /* scheme was already build, no need to check for IPv6 */
+ if (p_Manip->reassmParams.ip.h_Ipv4Scheme)
+ return E_OK;
+
+ if (isIpv4) {
+ h_Scheme = FmPcdKgGetSchemeHandle(p_FmPcd, p_Manip->reassmParams.ip.relativeSchemeId[0]);
+ if (h_Scheme) {
+ /* scheme was found */
+ p_Manip->reassmParams.ip.h_Ipv4Scheme = h_Scheme;
+ return E_OK;
+ }
+ } else {
+ h_Scheme = FmPcdKgGetSchemeHandle(p_FmPcd, p_Manip->reassmParams.ip.relativeSchemeId[1]);
+ if (h_Scheme) {
+ /* scheme was found */
+ p_Manip->reassmParams.ip.h_Ipv6Scheme = h_Scheme;
+ return E_OK;
+ }
+ }
+
+ p_SchemeParams = XX_Malloc(sizeof(t_FmPcdKgSchemeParams));
+ if (!p_SchemeParams)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("Memory allocation failed for scheme"));
+
+ /* Configures the IPv4 or IPv6 scheme*/
+ memset(p_SchemeParams, 0, sizeof(t_FmPcdKgSchemeParams));
+ p_SchemeParams->netEnvParams.h_NetEnv = h_NetEnv;
+ p_SchemeParams->id.relativeSchemeId = (uint8_t)(
+ (isIpv4 == TRUE) ? p_Manip->reassmParams.ip.relativeSchemeId[0] :
+ p_Manip->reassmParams.ip.relativeSchemeId[1]);
+ p_SchemeParams->schemeCounter.update = TRUE;
+#if (DPAA_VERSION >= 11)
+ p_SchemeParams->alwaysDirect = TRUE;
+ p_SchemeParams->bypassFqidGeneration = TRUE;
+#else
+ p_SchemeParams->keyExtractAndHashParams.hashDistributionNumOfFqids = 1;
+ p_SchemeParams->baseFqid = 0xFFFFFF; /*TODO- baseFqid*/
+#endif /* (DPAA_VERSION >= 11) */
+
+ setIpReassmSchemeParams(p_FmPcd, p_SchemeParams, h_CcTree, isIpv4, groupId);
+
+ /* Sets the new scheme */
+ if (isIpv4)
+ p_Manip->reassmParams.ip.h_Ipv4Scheme = FM_PCD_KgSchemeSet(
+ p_FmPcd, p_SchemeParams);
+ else
+ p_Manip->reassmParams.ip.h_Ipv6Scheme = FM_PCD_KgSchemeSet(
+ p_FmPcd, p_SchemeParams);
+
+ XX_Free(p_SchemeParams);
+
+ return E_OK;
+}
+
+t_Error FmPcdManipDeleteIpReassmSchemes(t_Handle h_Manip)
+{
+ t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
+
+ ASSERT_COND(p_Manip);
+
+ if ((p_Manip->reassmParams.ip.h_Ipv4Scheme) &&
+ !FmPcdKgIsSchemeHasOwners(p_Manip->reassmParams.ip.h_Ipv4Scheme))
+ FM_PCD_KgSchemeDelete(p_Manip->reassmParams.ip.h_Ipv4Scheme);
+
+ if ((p_Manip->reassmParams.ip.h_Ipv6Scheme) &&
+ !FmPcdKgIsSchemeHasOwners(p_Manip->reassmParams.ip.h_Ipv6Scheme))
+ FM_PCD_KgSchemeDelete(p_Manip->reassmParams.ip.h_Ipv6Scheme);
+ return E_OK;
+}
+
+bool FmPcdManipIpReassmIsIpv6Hdr(t_Handle h_Manip)
+{
+ t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
+
+ ASSERT_COND(p_Manip);
+
+ return (p_Manip->reassmParams.hdr == HEADER_TYPE_IPv6);
+}
+
+t_Error FmPcdManipBuildCapwapReassmScheme(t_FmPcd *p_FmPcd, t_Handle h_NetEnv,
+ t_Handle h_CcTree, t_Handle h_Manip,
+ uint8_t groupId)
+{
+ t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
+ t_FmPcdKgSchemeParams *p_SchemeParams = NULL;
- p_Manip = ManipOrStatsSetNode(h_FmPcd, (t_Handle)p_ManipParams, FALSE);
- if(!p_Manip)
+ ASSERT_COND(p_FmPcd);
+ ASSERT_COND(h_NetEnv);
+ ASSERT_COND(p_Manip);
+
+ /* scheme was already build, no need to check for IPv6 */
+ if (p_Manip->reassmParams.capwap.h_Scheme)
+ return E_OK;
+
+ p_SchemeParams = XX_Malloc(sizeof(t_FmPcdKgSchemeParams));
+ if (!p_SchemeParams)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY,
+ ("Memory allocation failed for scheme"));
+
+ memset(p_SchemeParams, 0, sizeof(t_FmPcdKgSchemeParams));
+ p_SchemeParams->netEnvParams.h_NetEnv = h_NetEnv;
+ p_SchemeParams->id.relativeSchemeId =
+ (uint8_t)p_Manip->reassmParams.capwap.relativeSchemeId;
+ p_SchemeParams->schemeCounter.update = TRUE;
+ p_SchemeParams->bypassFqidGeneration = TRUE;
+
+ setCapwapReassmSchemeParams(p_FmPcd, p_SchemeParams, h_CcTree, groupId);
+
+ p_Manip->reassmParams.capwap.h_Scheme = FM_PCD_KgSchemeSet(p_FmPcd,
+ p_SchemeParams);
+
+ XX_Free(p_SchemeParams);
+
+ return E_OK;
+}
+
+t_Error FmPcdManipDeleteCapwapReassmSchemes(t_Handle h_Manip)
+{
+ t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
+
+ ASSERT_COND(p_Manip);
+
+ if (p_Manip->reassmParams.capwap.h_Scheme)
+ FM_PCD_KgSchemeDelete(p_Manip->reassmParams.capwap.h_Scheme);
+
+ return E_OK;
+}
+
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
+t_Handle FmPcdManipApplSpecificBuild(void)
+{
+ t_FmPcdManip *p_Manip;
+
+ p_Manip = (t_FmPcdManip*)XX_Malloc(sizeof(t_FmPcdManip));
+ if (!p_Manip)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("No memory"));
return NULL;
+ }
+ memset(p_Manip, 0, sizeof(t_FmPcdManip));
- switch(p_Manip->type)
+ p_Manip->opcode = HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX;
+ p_Manip->muramAllocate = FALSE;
+
+ p_Manip->h_Ad = (t_Handle)XX_Malloc(FM_PCD_CC_AD_ENTRY_SIZE * sizeof(uint8_t));
+ if (!p_Manip->h_Ad)
{
- case(HMAN_OC_RMV_N_OR_INSRT_INT_FRM_HDR):
- /* HmanType1 */
- err = RmvHdrTillSpecLocNOrInsrtIntFrmHdr(&p_ManipParams->rmvParams, p_Manip);
- break;
-#ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
- case(HMAN_OC_IP_REASSEMBLY):
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Allocation of Manipulation action descriptor"));
+ XX_Free(p_Manip);
+ return NULL;
+ }
+
+ memset(p_Manip->h_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE * sizeof(uint8_t));
+
+ /*treatFdStatusFieldsAsErrors = TRUE hardcoded - assumption its always come after CAAM*/
+ /*Application specific = type of flowId index, move internal frame header from data to IC,
+ SEC errors check*/
+ if (MvIntFrameHeaderFromFrameToBufferPrefix(p_Manip, TRUE)!= E_OK)
+ {
+ XX_Free(p_Manip->h_Ad);
+ XX_Free(p_Manip);
+ return NULL;
+ }
+ return p_Manip;
+}
+
+bool FmPcdManipIsCapwapApplSpecific(t_Handle h_Manip)
+{
+ t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip;
+ ASSERT_COND(h_Manip);
+
+ return (bool)((p_Manip->opcode == HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST) ? TRUE : FALSE);
+}
+#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
+/*********************** End of inter-module routines ************************/
+
+/****************************************/
+/* API Init unit functions */
+/****************************************/
+
+t_Handle FM_PCD_ManipNodeSet(t_Handle h_FmPcd,
+ t_FmPcdManipParams *p_ManipParams)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ t_FmPcdManip *p_Manip;
+ t_Error err;
+
+ SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, NULL);
+ SANITY_CHECK_RETURN_VALUE(p_ManipParams, E_INVALID_HANDLE, NULL);
+
+ p_Manip = ManipOrStatsSetNode(h_FmPcd, (t_Handle)p_ManipParams, FALSE);
+ if (!p_Manip)
+ return NULL;
+
+ if (((p_Manip->opcode == HMAN_OC_IP_REASSEMBLY)
+ || (p_Manip->opcode == HMAN_OC_IP_FRAGMENTATION)
+ || (p_Manip->opcode == HMAN_OC)
+ || (p_Manip->opcode == HMAN_OC_IPSEC_MANIP)
+#if (DPAA_VERSION >= 11)
+ || (p_Manip->opcode == HMAN_OC_CAPWAP_MANIP)
+ || (p_Manip->opcode == HMAN_OC_CAPWAP_FRAGMENTATION)
+ || (p_Manip->opcode == HMAN_OC_CAPWAP_REASSEMBLY)
+#endif /* (DPAA_VERSION >= 11) */
+ ) && (!FmPcdIsAdvancedOffloadSupported(p_FmPcd)))
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Advanced-offload must be enabled"));
+ XX_Free(p_Manip);
+ return NULL;
+ }
+ p_Manip->h_Spinlock = XX_InitSpinlock();
+ if (!p_Manip->h_Spinlock)
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("UNSUPPORTED HEADER MANIPULATION TYPE"));
+ ReleaseManipHandler(p_Manip, p_FmPcd);
+ XX_Free(p_Manip);
+ return NULL;
+ }INIT_LIST(&p_Manip->nodesLst);
+
+ switch (p_Manip->opcode)
+ {
+ case (HMAN_OC_IP_REASSEMBLY):
/* IpReassembly */
- err = IpReassembly(&p_ManipParams->fragOrReasmParams, p_Manip, p_FmPcd);
- if(err)
- {
- REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("UNSUPPORTED HEADER MANIPULATION TYPE"));
- ReleaseManipHandler(p_Manip, p_FmPcd);
- XX_Free(p_Manip);
- return NULL;
- }
+ err = IpReassembly(&p_ManipParams->u.reassem, p_Manip);
break;
- case(HMAN_OC_IP_FRAGMENTATION):
+ case (HMAN_OC_IP_FRAGMENTATION):
/* IpFragmentation */
- err = IpFragmentation(&p_ManipParams->fragOrReasmParams.ipFragParams ,p_Manip, p_FmPcd, p_ManipParams->fragOrReasmParams.extBufPoolIndx);
- if(err)
- {
- REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("UNSUPPORTED HEADER MANIPULATION TYPE"));
- ReleaseManipHandler(p_Manip, p_FmPcd);
- XX_Free(p_Manip);
- return NULL;
- }
-#endif /* UNDER_CONSTRUCTION_FRAG_REASSEMBLY */
-#if (defined(UNDER_CONSTRUCTION_FRAG_REASSEMBLY) || defined(UNDER_CONSTRUCTION_IPSEC))
- case(HMAN_OC_IPSEC) :
- err = IPSecManip(p_ManipParams, p_Manip, p_FmPcd);
+ err = IpFragmentation(&p_ManipParams->u.frag.u.ipFrag, p_Manip);
+ if (err)
+ break;
+ err = IPManip(p_Manip);
+ break;
+ case (HMAN_OC_IPSEC_MANIP):
+ err = IPSecManip(p_ManipParams, p_Manip);
+ break;
+#if (DPAA_VERSION >= 11)
+ case (HMAN_OC_CAPWAP_REASSEMBLY):
+ /* CapwapReassembly */
+ err = CapwapReassembly(&p_ManipParams->u.reassem, p_Manip);
break;
-#endif /* (defined(UNDER_CONSTRUCTION_FRAG_REASSEMBLY) || ... */
-#ifdef FM_CAPWAP_SUPPORT
- case(HMAN_OC_CAPWAP_FRAGMENTATION):
+ case (HMAN_OC_CAPWAP_FRAGMENTATION):
/* CapwapFragmentation */
- err = CapwapFragmentation(&p_ManipParams->fragOrReasmParams.capwapFragParams ,p_Manip, p_FmPcd, p_ManipParams->fragOrReasmParams.extBufPoolIndx);
- if(err)
+ err = CapwapFragmentation(&p_ManipParams->u.frag.u.capwapFrag,
+ p_Manip);
+ break;
+ case (HMAN_OC_CAPWAP_MANIP):
+ err = CapwapManip(p_ManipParams, p_Manip);
+ break;
+#endif /* (DPAA_VERSION >= 11) */
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
+ case (HMAN_OC_RMV_N_OR_INSRT_INT_FRM_HDR):
+ /* HmanType1 */
+ err = RmvHdrTillSpecLocNOrInsrtIntFrmHdr(&p_ManipParams->u.hdr.rmvParams, p_Manip);
+ break;
+ case (HMAN_OC_CAPWAP_FRAGMENTATION):
+ err = CapwapFragmentation(&p_ManipParams->fragOrReasmParams.u.capwapFragParams,
+ p_Manip,
+ p_FmPcd,
+ p_ManipParams->fragOrReasmParams.sgBpid);
+ if (err)
{
REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("UNSUPPORTED HEADER MANIPULATION TYPE"));
ReleaseManipHandler(p_Manip, p_FmPcd);
XX_Free(p_Manip);
return NULL;
}
- if(p_Manip->insrt)
- p_Manip->type = HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER;
- case(HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER):
+ if (p_Manip->insrt)
+ p_Manip->opcode = HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER;
+ case (HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER):
/* HmanType2 + if user asked only for fragmentation still need to allocate HmanType2 */
- err = InsrtHdrByTempl(&p_ManipParams->insrtParams, p_Manip, p_FmPcd);
+ err = InsrtHdrByTempl(&p_ManipParams->u.hdr.insrtParams, p_Manip, p_FmPcd);
break;
- case(HMAN_OC_CAPWAP_REASSEMBLY) :
- /*CAPWAP Reassembly*/
- err = CapwapReassembly(&p_ManipParams->fragOrReasmParams.capwapReasmParams,p_Manip, p_FmPcd, p_ManipParams->fragOrReasmParams.extBufPoolIndx);
- if(err)
+ case (HMAN_OC_CAPWAP_REASSEMBLY):
+ err = CapwapReassembly(&p_ManipParams->fragOrReasmParams.u.capwapReasmParams,
+ p_Manip,
+ p_FmPcd,
+ p_ManipParams->fragOrReasmParams.sgBpid);
+ if (err)
{
REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("UNSUPPORTED HEADER MANIPULATION TYPE"));
ReleaseManipHandler(p_Manip, p_FmPcd);
XX_Free(p_Manip);
return NULL;
}
- if(p_Manip->rmv)
- p_Manip->type = HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST;
- case(HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
+ if (p_Manip->rmv)
+ p_Manip->opcode = HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST;
+ case (HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST):
/*CAPWAP decapsulation + if user asked only for reassembly still need to allocate CAPWAP decapsulation*/
err = CapwapRmvDtlsHdr(p_FmPcd, p_Manip);
break;
-#endif /* FM_CAPWAP_SUPPORT */
- case(HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
+ case (HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX):
/*Application Specific type 1*/
- err = MvIntFrameHeaderFromFrameToBufferPrefix(p_Manip, (bool)(p_ManipParams->treatFdStatusFieldsAsErrors ? TRUE : FALSE));
+ err = MvIntFrameHeaderFromFrameToBufferPrefix(p_Manip, TRUE);
break;
- default:
- REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("UNSUPPORTED HEADER MANIPULATION TYPE"));
- ReleaseManipHandler(p_Manip, p_FmPcd);
- XX_Free(p_Manip);
- return NULL;
+#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
+ case (HMAN_OC):
+ /* New Manip */
+ err = CreateManipActionNew(p_Manip, p_ManipParams);
+ break;
+ default:
+ REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("UNSUPPORTED HEADER MANIPULATION TYPE"));
+ ReleaseManipHandler(p_Manip, p_FmPcd);
+ XX_Free(p_Manip);
+ return NULL;
+ }
+
+ if (err)
+ {
+ REPORT_ERROR(MAJOR, err, NO_MSG);
+ ReleaseManipHandler(p_Manip, p_FmPcd);
+ XX_Free(p_Manip);
+ return NULL;
+ }
+
+ if (p_ManipParams->h_NextManip)
+ {
+ /* in the check routine we've verified that h_NextManip has no owners
+ * and that only supported types are allowed. */
+ p_Manip->h_NextManip = p_ManipParams->h_NextManip;
+ /* save a "prev" pointer in h_NextManip */
+ MANIP_SET_PREV(p_Manip->h_NextManip, p_Manip);
+ FmPcdManipUpdateOwner(p_Manip->h_NextManip, TRUE);
}
- if(err)
- {
- REPORT_ERROR(MAJOR, err, NO_MSG);
- ReleaseManipHandler(p_Manip, p_FmPcd);
- XX_Free(p_Manip);
- return NULL;
- }
- return p_Manip;
+
+ return p_Manip;
}
-t_Error FM_PCD_ManipDeleteNode(t_Handle h_FmPcd, t_Handle h_ManipNode)
+t_Error FM_PCD_ManipNodeReplace(t_Handle h_Manip,
+ t_FmPcdManipParams *p_ManipParams)
{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_ManipNode;
+ t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_Manip, *p_FirstManip;
+ t_FmPcd *p_FmPcd = (t_FmPcd *)(p_Manip->h_FmPcd);
+ t_Error err;
+ uint8_t *p_WholeHmct = NULL, *p_ShadowHmct = NULL, *p_Hmtd = NULL;
+ t_List lstOfNodeshichPointsOnCrntMdfManip, *p_Pos;
+ t_CcNodeInformation *p_CcNodeInfo;
+ SANITY_CHECK_RETURN_ERROR(h_Manip, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_ManipParams, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_Manip,E_INVALID_HANDLE);
+ INIT_LIST(&lstOfNodeshichPointsOnCrntMdfManip);
+
+ if ((p_ManipParams->type != e_FM_PCD_MANIP_HDR)
+ || (p_Manip->type != e_FM_PCD_MANIP_HDR))
+ RETURN_ERROR(
+ MINOR,
+ E_NOT_SUPPORTED,
+ ("FM_PCD_ManipNodeReplace Functionality supported only for Header Manipulation."));
+
+ ASSERT_COND(p_Manip->opcode == HMAN_OC);
+ ASSERT_COND(p_Manip->manipParams.h_NextManip == p_Manip->h_NextManip);
+ memcpy((uint8_t*)&p_Manip->manipParams, p_ManipParams,
+ sizeof(p_Manip->manipParams));
+ p_Manip->manipParams.h_NextManip = p_Manip->h_NextManip;
+
+ /* The replacement of the HdrManip depends on the node type.*/
+ /*
+ * (1) If this is an independent node, all its owners should be updated.
+ *
+ * (2) If it is the head of a cascaded chain (it does not have a "prev" but
+ * it has a "next" and it has a "cascaded" indication), the next
+ * node remains unchanged, and the behavior is as in (1).
+ *
+ * (3) If it is not the head, but a part of a cascaded chain, in can be
+ * also replaced as a regular node with just one owner.
+ *
+ * (4) If it is a part of a chain implemented as a unified table, the
+ * whole table is replaced and the owners of the head node must be updated.
+ *
+ */
+ /* lock shadow */
+ if (!p_FmPcd->p_CcShadow)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("CC Shadow not allocated"));
+
+ if (!TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))
+ return ERROR_CODE(E_BUSY);
+
+ /* this routine creates a new manip action in the CC Shadow. */
+ err = CreateManipActionShadow(p_Manip, p_ManipParams);
+ if (err)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+
+ /* If the owners list is empty (these are NOT the "owners" counter, but pointers from CC)
+ * replace only HMTD and no lcok is required. Otherwise
+ * lock the whole PCD
+ * In case 4 MANIP_IS_UNIFIED_NON_FIRST(p_Manip) - Use the head node instead. */
+ if (!FmPcdLockTryLockAll(p_FmPcd))
+ {
+ DBG(TRACE, ("FmPcdLockTryLockAll failed"));
+ return ERROR_CODE(E_BUSY);
+ }
+
+ p_ShadowHmct = (uint8_t*)PTR_MOVE(p_FmPcd->p_CcShadow, 16);
+
+ p_FirstManip = (t_FmPcdManip*)GetManipInfo(p_Manip,
+ e_MANIP_HANDLER_TABLE_OWNER);
+ ASSERT_COND(p_FirstManip);
+
+ if (!NCSW_LIST_IsEmpty(&p_FirstManip->nodesLst))
+ UpdateAdPtrOfNodesWhichPointsOnCrntMdfManip(
+ p_FirstManip, &lstOfNodeshichPointsOnCrntMdfManip);
+
+ p_Hmtd = (uint8_t *)GetManipInfo(p_Manip, e_MANIP_HMTD);
+ ASSERT_COND(p_Hmtd);
+ BuildHmtd(p_FmPcd->p_CcShadow, (uint8_t *)p_Hmtd, p_ShadowHmct,
+ ((t_FmPcd*)(p_Manip->h_FmPcd)));
+
+ NCSW_LIST_FOR_EACH(p_Pos, &lstOfNodeshichPointsOnCrntMdfManip)
+ {
+ p_CcNodeInfo = CC_NODE_F_OBJECT(p_Pos);
+ BuildHmtd(p_FmPcd->p_CcShadow, (uint8_t *)p_CcNodeInfo->h_CcNode,
+ p_ShadowHmct, ((t_FmPcd*)(p_Manip->h_FmPcd)));
+ }
+
+ p_WholeHmct = (uint8_t *)GetManipInfo(p_Manip, e_MANIP_HMCT);
+ ASSERT_COND(p_WholeHmct);
+
+ /* re-build the HMCT n the original location */
+ err = CreateManipActionBackToOrig(p_Manip, p_ManipParams);
+ if (err)
+ {
+ RELEASE_LOCK(p_FmPcd->shadowLock);
+ RETURN_ERROR(MINOR, err, NO_MSG);
+ }
+
+ p_Hmtd = (uint8_t *)GetManipInfo(p_Manip, e_MANIP_HMTD);
+ ASSERT_COND(p_Hmtd);
+ BuildHmtd(p_FmPcd->p_CcShadow, (uint8_t *)p_Hmtd, p_WholeHmct,
+ ((t_FmPcd*)p_Manip->h_FmPcd));
+
+ /* If NCSW_LIST > 0, create a list of p_Ad's that point to the HMCT. Join also t_HMTD to this list.
+ * For each p_Hmct (from list+fixed):
+ * call Host Command to replace HMTD by a new one */NCSW_LIST_FOR_EACH(p_Pos, &lstOfNodeshichPointsOnCrntMdfManip)
+ {
+ p_CcNodeInfo = CC_NODE_F_OBJECT(p_Pos);
+ BuildHmtd(p_FmPcd->p_CcShadow, (uint8_t *)p_CcNodeInfo->h_CcNode,
+ p_WholeHmct, ((t_FmPcd*)(p_Manip->h_FmPcd)));
+ }
- if(p_Manip->owner)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("This manipulation node not be removed because this node is occupied, first - unbind this node "));
- ReleaseManipHandler(p_Manip,p_FmPcd);
+ ReleaseLst(&lstOfNodeshichPointsOnCrntMdfManip);
+
+ FmPcdLockUnlockAll(p_FmPcd);
+
+ /* unlock shadow */
+ RELEASE_LOCK(p_FmPcd->shadowLock);
+
+ return E_OK;
+}
+
+t_Error FM_PCD_ManipNodeDelete(t_Handle h_ManipNode)
+{
+ t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_ManipNode;
+
+ SANITY_CHECK_RETURN_ERROR(p_Manip, E_INVALID_HANDLE);
+
+ if (p_Manip->owner)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("This manipulation node not be removed because this node is occupied, first - unbind this node "));
+
+ if (p_Manip->h_NextManip)
+ {
+ MANIP_SET_PREV(p_Manip->h_NextManip, NULL);
+ FmPcdManipUpdateOwner(p_Manip->h_NextManip, FALSE);
+ }
+
+ if (p_Manip->p_Hmct
+ && (MANIP_IS_UNIFIED_FIRST(p_Manip) || !MANIP_IS_UNIFIED(p_Manip)))
+ FM_MURAM_FreeMem(((t_FmPcd *)p_Manip->h_FmPcd)->h_FmMuram,
+ p_Manip->p_Hmct);
+
+ if (p_Manip->h_Spinlock)
+ {
+ XX_FreeSpinlock(p_Manip->h_Spinlock);
+ p_Manip->h_Spinlock = NULL;
+ }
+
+ ReleaseManipHandler(p_Manip, p_Manip->h_FmPcd);
XX_Free(h_ManipNode);
return E_OK;
}
+t_Error FM_PCD_ManipGetStatistics(t_Handle h_ManipNode,
+ t_FmPcdManipStats *p_FmPcdManipStats)
+{
+ t_FmPcdManip *p_Manip = (t_FmPcdManip *)h_ManipNode;
+
+ SANITY_CHECK_RETURN_ERROR(p_Manip, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcdManipStats, E_NULL_POINTER);
+
+ switch (p_Manip->opcode)
+ {
+ case (HMAN_OC_IP_REASSEMBLY):
+ return IpReassemblyStats(p_Manip,
+ &p_FmPcdManipStats->u.reassem.u.ipReassem);
+ case (HMAN_OC_IP_FRAGMENTATION):
+ return IpFragmentationStats(p_Manip,
+ &p_FmPcdManipStats->u.frag.u.ipFrag);
+#if (DPAA_VERSION >= 11)
+ case (HMAN_OC_CAPWAP_REASSEMBLY):
+ return CapwapReassemblyStats(
+ p_Manip, &p_FmPcdManipStats->u.reassem.u.capwapReassem);
+ case (HMAN_OC_CAPWAP_FRAGMENTATION):
+ return CapwapFragmentationStats(
+ p_Manip, &p_FmPcdManipStats->u.frag.u.capwapFrag);
+#endif /* (DPAA_VERSION >= 11) */
+ default:
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
+ ("no statistics to this type of manip"));
+ }
+
+ return E_OK;
+}
+
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
t_Handle FM_PCD_StatisticsSetNode(t_Handle h_FmPcd, t_FmPcdStatsParams *p_StatsParams)
{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- t_FmPcdManip *p_Manip;
- t_Error err;
+ t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ t_FmPcdManip *p_Manip;
+ t_Error err;
SANITY_CHECK_RETURN_VALUE(h_FmPcd,E_INVALID_HANDLE,NULL);
SANITY_CHECK_RETURN_VALUE(p_StatsParams,E_INVALID_HANDLE,NULL);
- p_Manip = ManipOrStatsSetNode(h_FmPcd, (t_Handle)p_StatsParams, TRUE);
- if(!p_Manip)
- return NULL;
+ p_Manip = ManipOrStatsSetNode(h_FmPcd, (t_Handle)p_StatsParams, TRUE);
+ if (!p_Manip)
+ return NULL;
- switch(p_Manip->type)
+ switch (p_Manip->opcode)
{
- case(HMAN_OC_CAPWAP_INDEXED_STATS):
- /* Indexed statistics */
- err = IndxStats(p_StatsParams, p_Manip, p_FmPcd);
- break;
- default:
- REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("UNSUPPORTED Statistics type"));
- ReleaseManipHandler(p_Manip, p_FmPcd);
- XX_Free(p_Manip);
- return NULL;
+ case (HMAN_OC_CAPWAP_INDEXED_STATS):
+ /* Indexed statistics */
+ err = IndxStats(p_StatsParams, p_Manip, p_FmPcd);
+ break;
+ default:
+ REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("UNSUPPORTED Statistics type"));
+ ReleaseManipHandler(p_Manip, p_FmPcd);
+ XX_Free(p_Manip);
+ return NULL;
+ }
+ if (err)
+ {
+ REPORT_ERROR(MAJOR, err, NO_MSG);
+ ReleaseManipHandler(p_Manip, p_FmPcd);
+ XX_Free(p_Manip);
+ return NULL;
}
- if(err)
- {
- REPORT_ERROR(MAJOR, err, NO_MSG);
- ReleaseManipHandler(p_Manip, p_FmPcd);
- XX_Free(p_Manip);
- return NULL;
- }
- return p_Manip;
-}
-#endif /* FM_CAPWAP_SUPPORT */
-#endif /* CONFIG_FMAN_P1023 */
+ return p_Manip;
+}
+#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
diff --git a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_manip.h b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_manip.h
index dbe9c1d4da0a..853bb834dedf 100644
--- a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_manip.h
+++ b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_manip.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm_manip.h
@@ -49,30 +50,46 @@
/* Header manipulations defines */
/***********************************************************************/
+#define NUM_OF_SCRATCH_POOL_BUFFERS 1000 /*TODO - Change it!!*/
+
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
#define HMAN_OC_RMV_N_OR_INSRT_INT_FRM_HDR 0x2e
#define HMAN_OC_INSRT_HDR_BY_TEMPL_N_OR_FRAG_AFTER 0x31
-#define HMAN_OC_CAPWAP_FRAGMENTATION 0x33
-#define HMAN_OC_IPSEC 0x34
-#define HMAN_OC_IP_FRAGMENTATION 0x74
-#define HMAN_OC_IP_REASSEMBLY 0xB4
#define HMAN_OC_MV_INT_FRAME_HDR_FROM_FRM_TO_BUFFER_PREFFIX 0x2f
#define HMAN_OC_CAPWAP_RMV_DTLS_IF_EXIST 0x30
#define HMAN_OC_CAPWAP_REASSEMBLY 0x11 /* dummy */
#define HMAN_OC_CAPWAP_INDEXED_STATS 0x32 /* dummy */
+#define HMAN_OC_CAPWAP_FRAGMENTATION 0x33
+#else
+#define HMAN_OC_CAPWAP_MANIP 0x2F
+#define HMAN_OC_CAPWAP_FRAG_CHECK 0x2E
+#define HMAN_OC_CAPWAP_FRAGMENTATION 0x33
+#define HMAN_OC_CAPWAP_REASSEMBLY 0x30
+#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
+#define HMAN_OC_IP_MANIP 0x34
+#define HMAN_OC_IP_FRAGMENTATION 0x74
+#define HMAN_OC_IP_REASSEMBLY 0xB4
+#define HMAN_OC_IPSEC_MANIP 0xF4
+#define HMAN_OC 0x35
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
#define HMAN_RMV_HDR 0x80000000
#define HMAN_INSRT_INT_FRM_HDR 0x40000000
-#define UDP_UDPHECKSUM_FIELD_OFFSET_FROM_UDP 6
-#define UDP_UDPCHECKSUM_FIELD_SIZE 2
+#define UDP_CHECKSUM_FIELD_OFFSET_FROM_UDP 6
+#define UDP_CHECKSUM_FIELD_SIZE 2
+#define UDP_LENGTH_FIELD_OFFSET_FROM_UDP 4
-#define IP_DSCECN_FIELD_OFFSET_FROM_IP 1
-#define IP_TOTALLENGTH_FIELD_OFFSET_FROM_IP 2
-#define IP_HDRCHECKSUM_FIELD_OFFSET_FROM_IP 10
+#define IPv4_DSCECN_FIELD_OFFSET_FROM_IP 1
+#define IPv4_TOTALLENGTH_FIELD_OFFSET_FROM_IP 2
+#define IPv4_HDRCHECKSUM_FIELD_OFFSET_FROM_IP 10
#define VLAN_TAG_FIELD_OFFSET_FROM_ETH 12
-#define IP_ID_FIELD_OFFSET_FROM_IP 4
+#define IPv4_ID_FIELD_OFFSET_FROM_IP 4
-#define FM_PCD_MANIP_CAPWAP_REASM_TABLE_SIZE 80
+#define IPv6_PAYLOAD_LENGTH_OFFSET_FROM_IP 4
+#define IPv6_NEXT_HEADER_OFFSET_FROM_IP 6
+
+#define FM_PCD_MANIP_CAPWAP_REASM_TABLE_SIZE 0x80
#define FM_PCD_MANIP_CAPWAP_REASM_TABLE_ALIGN 8
#define FM_PCD_MANIP_CAPWAP_REASM_RFD_SIZE 32
#define FM_PCD_MANIP_CAPWAP_REASM_AUTO_LEARNING_HASH_ENTRY_SIZE 4
@@ -89,28 +106,219 @@
#define FM_PCD_MANIP_INDEXED_STATS_ENTRY_SIZE 4
#define FM_PCD_MANIP_INDEXED_STATS_CNIA 0x20000000
#define FM_PCD_MANIP_INDEXED_STATS_DPD 0x10000000
+#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
+
+#if (DPAA_VERSION >= 11)
+#define FM_PCD_MANIP_CAPWAP_DTLS 0x00040000
+#define FM_PCD_MANIP_CAPWAP_NADEN 0x20000000
+
+#define FM_PCD_MANIP_CAPWAP_FRAG_CHECK_MTU_SHIFT 16
+#define FM_PCD_MANIP_CAPWAP_FRAG_CHECK_NO_FRAGMENTATION 0xFFFF0000
+#define FM_PCD_MANIP_CAPWAP_FRAG_CHECK_CNIA 0x20000000
+
+#define FM_PCD_MANIP_CAPWAP_FRAG_COMPRESS_EN 0x04000000
+#define FM_PCD_MANIP_CAPWAP_FRAG_SCRATCH_BPID 24
+#define FM_PCD_MANIP_CAPWAP_FRAG_SG_BDID_EN 0x08000000
+#define FM_PCD_MANIP_CAPWAP_FRAG_SG_BDID_MASK 0xFF000000
+#define FM_PCD_MANIP_CAPWAP_FRAG_SG_BDID_SHIFT 24
+#endif /* (DPAA_VERSION >= 11) */
+
+#define FM_PCD_MANIP_REASM_TABLE_SIZE 0x40
+#define FM_PCD_MANIP_REASM_TABLE_ALIGN 8
+
+#define FM_PCD_MANIP_REASM_COMMON_PARAM_TABLE_SIZE 64
+#define FM_PCD_MANIP_REASM_COMMON_PARAM_TABLE_ALIGN 8
+#define FM_PCD_MANIP_REASM_TIME_OUT_BETWEEN_FRAMES 0x80000000
+#define FM_PCD_MANIP_REASM_COUPLING_ENABLE 0x40000000
+#define FM_PCD_MANIP_REASM_COUPLING_MASK 0xFF000000
+#define FM_PCD_MANIP_REASM_COUPLING_SHIFT 24
+#define FM_PCD_MANIP_REASM_LIODN_MASK 0x0000003F
+#define FM_PCD_MANIP_REASM_LIODN_SHIFT 56
+#define FM_PCD_MANIP_REASM_ELIODN_MASK 0x000003c0
+#define FM_PCD_MANIP_REASM_ELIODN_SHIFT 38
+#define FM_PCD_MANIP_REASM_COMMON_INT_BUFFER_IDX_MASK 0x000000FF
+#define FM_PCD_MANIP_REASM_COMMON_INT_BUFFER_IDX_SHIFT 24
+#define FM_PCD_MANIP_REASM_TIMEOUT_THREAD_THRESH 1024
+
+#define FM_PCD_MANIP_IP_MTU_SHIFT 16
+#define FM_PCD_MANIP_IP_NO_FRAGMENTATION 0xFFFF0000
+#define FM_PCD_MANIP_IP_CNIA 0x20000000
+
+#define FM_PCD_MANIP_IP_FRAG_DF_SHIFT 28
+#define FM_PCD_MANIP_IP_FRAG_SCRATCH_BPID 24
+#define FM_PCD_MANIP_IP_FRAG_SG_BDID_EN 0x08000000
+#define FM_PCD_MANIP_IP_FRAG_SG_BDID_MASK 0xFF000000
+#define FM_PCD_MANIP_IP_FRAG_SG_BDID_SHIFT 24
+
+#define FM_PCD_MANIP_IPSEC_DEC 0x10000000
+#define FM_PCD_MANIP_IPSEC_VIPV_EN 0x08000000
+#define FM_PCD_MANIP_IPSEC_ECN_EN 0x04000000
+#define FM_PCD_MANIP_IPSEC_DSCP_EN 0x02000000
+#define FM_PCD_MANIP_IPSEC_VIPL_EN 0x01000000
+#define FM_PCD_MANIP_IPSEC_NADEN 0x20000000
+
+#define FM_PCD_MANIP_IPSEC_IP_HDR_LEN_MASK 0x00FF0000
+#define FM_PCD_MANIP_IPSEC_IP_HDR_LEN_SHIFT 16
+
+#define FM_PCD_MANIP_IPSEC_ARW_SIZE_MASK 0xFFFF0000
+#define FM_PCD_MANIP_IPSEC_ARW_SIZE_SHIFT 16
-#define FM_PCD_MANIP_IPSEC_CALC_UDP_LENGTH 0x01000000
-#define FM_PCD_MANIP_IPSEC_CNIA 0x20000000
-
-#define e_FM_MANIP_CAPWAP_INDX 0
-
-#ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
-#define FM_PCD_MANIP_IP_REASM_TABLE_SIZE 0x40
-#define FM_PCD_MANIP_IP_REASM_TABLE_ALIGN 8
-
-#define FM_PCD_MANIP_IP_REASM_COMMON_PARAM_TABLE_SIZE 64
-#define FM_PCD_MANIP_IP_REASM_COMMON_PARAM_TABLE_ALIGN 8
-#define FM_PCD_MANIP_IP_REASM_TIME_OUT_BETWEEN_FRAMES 0x80000000
#define e_FM_MANIP_IP_INDX 1
-#define FM_PCD_MANIP_IP_REASM_LIODN_MASK 0x000003F0
-#define FM_PCD_MANIP_IP_REASM_LIODN_SHIFT 56
-#define FM_PCD_MANIP_IP_REASM_ELIODN_MASK 0x0000000F
-#define FM_PCD_MANIP_IP_REASM_ELIODN_SHIFT 44
-
-#endif /* UNDER_CONSTRUCTION_FRAG_REASSEMBLY */
-
+#define HMCD_OPCODE_GENERIC_RMV 0x01
+#define HMCD_OPCODE_GENERIC_INSRT 0x02
+#define HMCD_OPCODE_GENERIC_REPLACE 0x05
+#define HMCD_OPCODE_L2_RMV 0x08
+#define HMCD_OPCODE_L2_INSRT 0x09
+#define HMCD_OPCODE_VLAN_PRI_UPDATE 0x0B
+#define HMCD_OPCODE_IPV4_UPDATE 0x0C
+#define HMCD_OPCODE_IPV6_UPDATE 0x10
+#define HMCD_OPCODE_TCP_UDP_UPDATE 0x0E
+#define HMCD_OPCODE_TCP_UDP_CHECKSUM 0x14
+#define HMCD_OPCODE_REPLACE_IP 0x12
+#define HMCD_OPCODE_RMV_TILL 0x15
+#define HMCD_OPCODE_UDP_INSRT 0x16
+#define HMCD_OPCODE_IP_INSRT 0x17
+#define HMCD_OPCODE_CAPWAP_RMV 0x18
+#define HMCD_OPCODE_CAPWAP_INSRT 0x18
+#define HMCD_OPCODE_GEN_FIELD_REPLACE 0x19
+
+#define HMCD_LAST 0x00800000
+
+#define HMCD_DSCP_VALUES 64
+
+#define HMCD_BASIC_SIZE 4
+#define HMCD_PTR_SIZE 4
+#define HMCD_PARAM_SIZE 4
+#define HMCD_IPV4_ADDR_SIZE 4
+#define HMCD_IPV6_ADDR_SIZE 0x10
+#define HMCD_L4_HDR_SIZE 8
+
+#define HMCD_CAPWAP_INSRT 0x00010000
+#define HMCD_INSRT_UDP_LITE 0x00010000
+#define HMCD_IP_ID_MASK 0x0000FFFF
+#define HMCD_IP_SIZE_MASK 0x0000FF00
+#define HMCD_IP_SIZE_SHIFT 8
+#define HMCD_IP_LAST_PID_MASK 0x000000FF
+#define HMCD_IP_OR_QOS 0x00010000
+#define HMCD_IP_L4_CS_CALC 0x00040000
+#define HMCD_IP_DF_MODE 0x00400000
+
+
+#define HMCD_OC_SHIFT 24
+
+#define HMCD_RMV_OFFSET_SHIFT 0
+#define HMCD_RMV_SIZE_SHIFT 8
+
+#define HMCD_INSRT_OFFSET_SHIFT 0
+#define HMCD_INSRT_SIZE_SHIFT 8
+
+#define HMTD_CFG_TYPE 0x4000
+#define HMTD_CFG_EXT_HMCT 0x0080
+#define HMTD_CFG_PRS_AFTER_HM 0x0040
+#define HMTD_CFG_NEXT_AD_EN 0x0020
+
+#define HMCD_RMV_L2_ETHERNET 0
+#define HMCD_RMV_L2_STACKED_QTAGS 1
+#define HMCD_RMV_L2_ETHERNET_AND_MPLS 2
+#define HMCD_RMV_L2_MPLS 3
+#define HMCD_RMV_L2_PPPOE 4
+
+#define HMCD_INSRT_L2_MPLS 0
+#define HMCD_INSRT_N_UPDATE_L2_MPLS 1
+#define HMCD_INSRT_L2_PPPOE 2
+#define HMCD_INSRT_L2_SIZE_SHIFT 24
+
+#define HMCD_L2_MODE_SHIFT 16
+
+#define HMCD_VLAN_PRI_REP_MODE_SHIFT 16
+#define HMCD_VLAN_PRI_UPDATE 0
+#define HMCD_VLAN_PRI_UPDATE_DSCP_TO_VPRI 1
+
+#define HMCD_IPV4_UPDATE_TTL 0x00000001
+#define HMCD_IPV4_UPDATE_TOS 0x00000002
+#define HMCD_IPV4_UPDATE_DST 0x00000020
+#define HMCD_IPV4_UPDATE_SRC 0x00000040
+#define HMCD_IPV4_UPDATE_ID 0x00000080
+#define HMCD_IPV4_UPDATE_TOS_SHIFT 8
+
+#define HMCD_IPV6_UPDATE_HL 0x00000001
+#define HMCD_IPV6_UPDATE_TC 0x00000002
+#define HMCD_IPV6_UPDATE_DST 0x00000040
+#define HMCD_IPV6_UPDATE_SRC 0x00000080
+#define HMCD_IPV6_UPDATE_TC_SHIFT 8
+
+#define HMCD_TCP_UDP_UPDATE_DST 0x00004000
+#define HMCD_TCP_UDP_UPDATE_SRC 0x00008000
+#define HMCD_TCP_UDP_UPDATE_SRC_SHIFT 16
+
+#define HMCD_IP_REPLACE_REPLACE_IPV4 0x00000000
+#define HMCD_IP_REPLACE_REPLACE_IPV6 0x00010000
+#define HMCD_IP_REPLACE_TTL_HL 0x00200000
+#define HMCD_IP_REPLACE_ID 0x00400000
+
+#define HMCD_IP_REPLACE_L3HDRSIZE_SHIFT 24
+
+#define HMCD_GEN_FIELD_SIZE_SHIFT 16
+#define HMCD_GEN_FIELD_SRC_OFF_SHIFT 8
+#define HMCD_GEN_FIELD_DST_OFF_SHIFT 0
+#define HMCD_GEN_FIELD_MASK_EN 0x00400000
+
+#define HMCD_GEN_FIELD_MASK_OFF_SHIFT 16
+#define HMCD_GEN_FIELD_MASK_SHIFT 24
+
+#define DSCP_TO_VLAN_TABLE_SIZE 32
+
+#define MANIP_GET_HMCT_SIZE(h_Manip) (((t_FmPcdManip *)h_Manip)->tableSize)
+#define MANIP_GET_DATA_SIZE(h_Manip) (((t_FmPcdManip *)h_Manip)->dataSize)
+
+#define MANIP_GET_HMCT_PTR(h_Manip) (((t_FmPcdManip *)h_Manip)->p_Hmct)
+#define MANIP_GET_DATA_PTR(h_Manip) (((t_FmPcdManip *)h_Manip)->p_Data)
+
+#define MANIP_SET_HMCT_PTR(h_Manip, h_NewPtr) (((t_FmPcdManip *)h_Manip)->p_Hmct = h_NewPtr)
+#define MANIP_SET_DATA_PTR(h_Manip, h_NewPtr) (((t_FmPcdManip *)h_Manip)->p_Data = h_NewPtr)
+
+#define MANIP_GET_HMTD_PTR(h_Manip) (((t_FmPcdManip *)h_Manip)->h_Ad)
+#define MANIP_DONT_REPARSE(h_Manip) (((t_FmPcdManip *)h_Manip)->dontParseAfterManip)
+#define MANIP_SET_PREV(h_Manip, h_Prev) (((t_FmPcdManip *)h_Manip)->h_PrevManip = h_Prev)
+#define MANIP_GET_OWNERS(h_Manip) (((t_FmPcdManip *)h_Manip)->owner)
+#define MANIP_GET_TYPE(h_Manip) (((t_FmPcdManip *)h_Manip)->type)
+#define MANIP_SET_UNIFIED_TBL_PTR_INDICATION(h_Manip) (((t_FmPcdManip *)h_Manip)->unifiedTablePtr = TRUE)
+#define MANIP_GET_MURAM(h_Manip) (((t_FmPcd *)((t_FmPcdManip *)h_Manip)->h_FmPcd)->h_FmMuram)
+#define MANIP_FREE_HMTD(h_Manip) \
+ {if (((t_FmPcdManip *)h_Manip)->muramAllocate) \
+ FM_MURAM_FreeMem(((t_FmPcd *)((t_FmPcdManip *)h_Manip)->h_FmPcd)->h_FmMuram, ((t_FmPcdManip *)h_Manip)->h_Ad);\
+ else \
+ XX_Free(((t_FmPcdManip *)h_Manip)->h_Ad); \
+ ((t_FmPcdManip *)h_Manip)->h_Ad = NULL; \
+ }
+/* position regarding Manip SW structure */
+#define MANIP_IS_FIRST(h_Manip) (!(((t_FmPcdManip *)h_Manip)->h_PrevManip))
+#define MANIP_IS_CASCADED(h_Manip) (((t_FmPcdManip *)h_Manip)->cascaded)
+#define MANIP_IS_UNIFIED(h_Manip) (!(((t_FmPcdManip *)h_Manip)->unifiedPosition == e_MANIP_UNIFIED_NONE))
+#define MANIP_IS_UNIFIED_NON_FIRST(h_Manip) ((((t_FmPcdManip *)h_Manip)->unifiedPosition == e_MANIP_UNIFIED_MID) || \
+ (((t_FmPcdManip *)h_Manip)->unifiedPosition == e_MANIP_UNIFIED_LAST))
+#define MANIP_IS_UNIFIED_NON_LAST(h_Manip) ((((t_FmPcdManip *)h_Manip)->unifiedPosition == e_MANIP_UNIFIED_FIRST) ||\
+ (((t_FmPcdManip *)h_Manip)->unifiedPosition == e_MANIP_UNIFIED_MID))
+#define MANIP_IS_UNIFIED_FIRST(h_Manip) (((t_FmPcdManip *)h_Manip)->unifiedPosition == e_MANIP_UNIFIED_FIRST)
+#define MANIP_IS_UNIFIED_LAST(h_Manip) (((t_FmPcdManip *)h_Manip)->unifiedPosition == e_MANIP_UNIFIED_LAST)
+
+#define MANIP_UPDATE_UNIFIED_POSITION(h_Manip) (((t_FmPcdManip *)h_Manip)->unifiedPosition = \
+ (((t_FmPcdManip *)h_Manip)->unifiedPosition == e_MANIP_UNIFIED_NONE)? \
+ e_MANIP_UNIFIED_LAST : e_MANIP_UNIFIED_MID)
+
+typedef enum e_ManipUnifiedPosition {
+ e_MANIP_UNIFIED_NONE = 0,
+ e_MANIP_UNIFIED_FIRST,
+ e_MANIP_UNIFIED_MID,
+ e_MANIP_UNIFIED_LAST
+} e_ManipUnifiedPosition;
+
+typedef enum e_ManipInfo {
+ e_MANIP_HMTD,
+ e_MANIP_HMCT,
+ e_MANIP_HANDLER_TABLE_OWNER
+}e_ManipInfo;
/***********************************************************************/
/* Memory map */
/***********************************************************************/
@@ -118,7 +326,8 @@
#pragma pack(push,1)
#endif /* defined(__MWERKS__) && ... */
-typedef _Packed struct {
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
+typedef struct t_CapwapReasmPram {
volatile uint32_t mode;
volatile uint32_t autoLearnHashTblPtr;
volatile uint32_t intStatsTblPtr;
@@ -141,20 +350,20 @@ typedef _Packed struct {
volatile uint32_t totalMoreThan16FramesCounter;
volatile uint32_t internalBufferBusy;
volatile uint32_t externalBufferBusy;
- volatile uint8_t res[16];
-} _PackedType t_CapwapReasmPram;
+ volatile uint32_t reserved1[4];
+} t_CapwapReasmPram;
+#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
-#ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
-typedef _Packed struct t_IpReasmPram{
+typedef _Packed struct t_ReassTbl {
volatile uint16_t waysNumAndSetSize;
volatile uint16_t autoLearnHashKeyMask;
- volatile uint32_t ipReassCommonPrmTblPtr;
+ volatile uint32_t reassCommonPrmTblPtr;
volatile uint32_t liodnAlAndAutoLearnHashTblPtrHi;
volatile uint32_t autoLearnHashTblPtrLow;
volatile uint32_t liodnSlAndAutoLearnSetLockTblPtrHi;
volatile uint32_t autoLearnSetLockTblPtrLow;
- volatile uint16_t minFragSize;
- volatile uint16_t reserved1;
+ volatile uint16_t minFragSize; /* Not relevant for CAPWAP*/
+ volatile uint16_t maxReassemblySize; /* Only relevant for CAPWAP*/
volatile uint32_t totalSuccessfullyReasmFramesCounter;
volatile uint32_t totalValidFragmentCounter;
volatile uint32_t totalProcessedFragCounter;
@@ -163,27 +372,38 @@ typedef _Packed struct t_IpReasmPram{
volatile uint32_t totalDiscardedFragsCounter;
volatile uint32_t totalMoreThan16FramesCounter;
volatile uint32_t reserved2[2];
-} _PackedType t_IpReasmPram;
+} _PackedType t_ReassTbl;
-typedef _Packed struct t_IpReasmCommonTbl{
+typedef struct t_ReassCommonTbl {
volatile uint32_t timeoutModeAndFqid;
volatile uint32_t reassFrmDescIndexPoolTblPtr;
volatile uint32_t liodnAndReassFrmDescPoolPtrHi;
volatile uint32_t reassFrmDescPoolPtrLow;
volatile uint32_t timeOutTblPtr;
volatile uint32_t expirationDelay;
- volatile uint32_t reseervd1;
- volatile uint32_t reseervd2;
+ volatile uint32_t internalBufferManagement;
+ volatile uint32_t reserved2;
volatile uint32_t totalTimeOutCounter;
volatile uint32_t totalRfdPoolBusyCounter;
volatile uint32_t totalInternalBufferBusy;
volatile uint32_t totalExternalBufferBusy;
- volatile uint32_t reserved3[4];
-} _PackedType t_IpReasmCommonTbl;
-
-#endif /*UNDER_CONSTRUCTION_FRAG_REASSEMBLY*/
+ volatile uint32_t totalSgFragmentCounter;
+ volatile uint32_t totalDmaSemaphoreDepletionCounter;
+ volatile uint32_t totalNCSPCounter;
+ volatile uint32_t discardMask;
+} t_ReassCommonTbl;
+
+typedef _Packed struct t_Hmtd {
+ volatile uint16_t cfg;
+ volatile uint8_t eliodnOffset;
+ volatile uint8_t extHmcdBasePtrHi;
+ volatile uint32_t hmcdBasePtr;
+ volatile uint16_t nextAdIdx;
+ volatile uint8_t res1;
+ volatile uint8_t opCode;
+ volatile uint32_t res2;
+} _PackedType t_Hmtd;
-#define MEM_MAP_END
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(pop)
#endif /* defined(__MWERKS__) && ... */
@@ -192,98 +412,125 @@ typedef _Packed struct t_IpReasmCommonTbl{
/***********************************************************************/
/* Driver's internal structures */
/***********************************************************************/
-
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
typedef struct
{
t_Handle p_AutoLearnHashTbl;
t_Handle p_ReassmFrmDescrPoolTbl;
t_Handle p_ReassmFrmDescrIndxPoolTbl;
t_Handle p_TimeOutTbl;
- uint8_t maxNumFramesInProcess;
+ uint16_t maxNumFramesInProcess;
uint8_t numOfTasks;
- uint8_t poolId;
+ //uint8_t poolId;
uint8_t prOffset;
uint16_t dataOffset;
- uint8_t poolIndx;
+ uint8_t sgBpid;
uint8_t hwPortId;
uint32_t fqidForTimeOutFrames;
uint32_t timeoutRoutineRequestTime;
uint32_t bitFor1Micro;
-} t_FragParams;
+} t_CapwapFragParams;
+#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
-#ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
typedef struct
{
- t_Handle h_Frag;
- t_Handle h_FragId;
- uint8_t poolId;
- uint16_t dataOffset;
- uint8_t poolIndx;
-}t_IpFragParams;
+ t_AdOfTypeContLookup *p_Frag;
+#if (DPAA_VERSION == 10)
+ uint8_t scratchBpid;
+#endif /* (DPAA_VERSION == 10) */
+} t_FragParams;
-typedef struct t_IpReassmParams
+typedef struct t_ReassmParams
{
- t_Handle h_Ipv4Ad;
- t_Handle h_Ipv6Ad;
- e_NetHeaderType hdr; /**< Header selection */
- uint32_t fqidForTimeOutFrames;
- uint16_t dataOffset;
- t_Handle h_IpReassCommonParamsTbl;
- t_Handle h_Ipv4ReassParamsTblPtr;
- t_Handle h_Ipv6ReassParamsTblPtr;
- t_Handle h_Ipv4AutoLearnHashTbl;
- t_Handle h_Ipv6AutoLearnHashTbl;
- t_Handle h_Ipv4AutoLearnSetLockTblPtr;
- t_Handle h_Ipv6AutoLearnSetLockTblPtr;
- t_Handle h_ReassmFrmDescrIndxPoolTbl;
- t_Handle h_ReassmFrmDescrPoolTbl;
- t_Handle h_TimeOutTbl;
- uint32_t maxNumFramesInProcess;
- uint32_t liodnOffset;
- uint32_t minFragSize;
- uint8_t dataMemId; /**< Memory partition ID for data buffers */
- uint32_t bpid;
+ e_NetHeaderType hdr; /* Header selection */
+ t_ReassCommonTbl *p_ReassCommonTbl;
+ uintptr_t reassFrmDescrIndxPoolTblAddr;
+ uintptr_t reassFrmDescrPoolTblAddr;
+ uintptr_t timeOutTblAddr;
+ uintptr_t internalBufferPoolManagementIndexAddr;
+ uintptr_t internalBufferPoolAddr;
+ uint32_t maxNumFramesInProcess;
+ uint8_t sgBpid;
+ uint8_t dataMemId;
+ uint16_t dataLiodnOffset;
+ uint32_t fqidForTimeOutFrames;
e_FmPcdManipReassemTimeOutMode timeOutMode;
- e_FmPcdManipReassemWaysNumber numOfFramesPerHashEntry;
uint32_t timeoutThresholdForReassmProcess;
-
-}t_IpReassmParams;
-
-typedef struct t_IpCommonReassmParams
-{
- uint8_t numOfTasks;
- uint32_t bitFor1Micro;
- t_Handle h_ReassmFrmDescrPoolTbl;
- t_Handle h_ReassmFrmDescrIndxPoolTbl;
- t_Handle h_TimeOutTbl;
-}t_IpCommonReassmParams;
-
-#endif /*UNDER_CONSTRUCTION_FRAG_REASSEMBLY*/
+ union {
+ struct {
+ t_Handle h_Ipv4Ad;
+ t_Handle h_Ipv6Ad;
+ bool ipv6Assigned;
+ t_ReassTbl *p_Ipv4ReassTbl;
+ t_ReassTbl *p_Ipv6ReassTbl;
+ uintptr_t ipv4AutoLearnHashTblAddr;
+ uintptr_t ipv6AutoLearnHashTblAddr;
+ uintptr_t ipv4AutoLearnSetLockTblAddr;
+ uintptr_t ipv6AutoLearnSetLockTblAddr;
+ uint16_t minFragSize[2];
+ e_FmPcdManipReassemWaysNumber numOfFramesPerHashEntry[2];
+ uint8_t relativeSchemeId[2];
+ t_Handle h_Ipv4Scheme;
+ t_Handle h_Ipv6Scheme;
+ uint32_t nonConsistentSpFqid;
+ } ip;
+ struct {
+ t_Handle h_Ad;
+ t_ReassTbl *p_ReassTbl;
+ uintptr_t autoLearnHashTblAddr;
+ uintptr_t autoLearnSetLockTblAddr;
+ uint16_t maxRessembledsSize;
+ e_FmPcdManipReassemWaysNumber numOfFramesPerHashEntry;
+ uint8_t relativeSchemeId;
+ t_Handle h_Scheme;
+ } capwap;
+ };
+} t_ReassmParams;
typedef struct{
- bool muramAllocate;
- t_Handle h_Ad;
- uint32_t type;
- bool rmv;
- bool insrt;
- uint8_t *p_Template;
- t_Handle h_Frag;
- bool frag;
- bool reassm;
- uint16_t sizeForFragmentation;
- uint8_t owner;
- uint32_t updateParams;
- uint32_t shadowUpdateParams;
- t_FragParams fragParams;
-#ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
- t_IpReassmParams ipReassmParams;
- t_IpFragParams ipFragParams;
-#endif /* UNDER_CONSTRUCTION_FRAG_REASSEMBLY */
- uint8_t icOffset;
- uint16_t ownerTmp;
- bool cnia;
- t_Handle p_StatsTbl;
- t_Handle h_FmPcd;
+ e_FmPcdManipType type;
+ t_FmPcdManipParams manipParams;
+ bool muramAllocate;
+ t_Handle h_Ad;
+ uint32_t opcode;
+ bool rmv;
+ bool insrt;
+ t_Handle h_NextManip;
+ t_Handle h_PrevManip;
+ e_FmPcdManipType nextManipType;
+ /* HdrManip parameters*/
+ uint8_t *p_Hmct;
+ uint8_t *p_Data;
+ bool dontParseAfterManip;
+ bool fieldUpdate;
+ bool custom;
+ uint16_t tableSize;
+ uint8_t dataSize;
+ bool cascaded;
+ e_ManipUnifiedPosition unifiedPosition;
+ /* end HdrManip */
+ uint8_t *p_Template;
+ uint16_t owner;
+ uint32_t updateParams;
+ uint32_t shadowUpdateParams;
+ bool frag;
+ bool reassm;
+ uint16_t sizeForFragmentation;
+#if (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10))
+ t_Handle h_Frag;
+ t_CapwapFragParams capwapFragParams;
+#endif /* (defined(FM_CAPWAP_SUPPORT) && (DPAA_VERSION == 10)) */
+ union {
+ t_ReassmParams reassmParams;
+ t_FragParams fragParams;
+ };
+ uint8_t icOffset;
+ uint16_t ownerTmp;
+ bool cnia;
+ t_Handle p_StatsTbl;
+ t_Handle h_FmPcd;
+ t_List nodesLst;
+ t_Handle h_Spinlock;
} t_FmPcdManip;
typedef struct t_FmPcdCcSavedManipParams
@@ -293,15 +540,13 @@ typedef struct t_FmPcdCcSavedManipParams
struct
{
uint16_t dataOffset;
- uint8_t poolId;
+ //uint8_t poolId;
}capwapParams;
-#ifdef UNDER_CONSTRUCTION_FRAG_REASSEMBLY
struct
{
uint16_t dataOffset;
uint8_t poolId;
}ipParams;
-#endif /*UNDER_CONSTRUCTION_FRAG_REASSEMBLY*/
};
} t_FmPcdCcSavedManipParams;
diff --git a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_pcd.c b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_pcd.c
index e3af876627c2..48d650d0607f 100644
--- a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_pcd.c
+++ b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_pcd.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm_pcd.c
@@ -49,28 +50,33 @@
#include "fm_pcd.h"
#include "fm_pcd_ipc.h"
#include "fm_hc.h"
+#include "fm_muram_ext.h"
+
+/****************************************/
+/* static functions */
+/****************************************/
static t_Error CheckFmPcdParameters(t_FmPcd *p_FmPcd)
{
- if(!p_FmPcd->h_Fm)
+ if (!p_FmPcd->h_Fm)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("h_Fm has to be initialized"));
- if(p_FmPcd->guestId == NCSW_MASTER_ID)
+ if (p_FmPcd->guestId == NCSW_MASTER_ID)
{
- if(p_FmPcd->p_FmPcdKg && !p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs)
+ if (p_FmPcd->p_FmPcdKg && !p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Something WRONG"));
- if(p_FmPcd->p_FmPcdPlcr && !p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs)
+ if (p_FmPcd->p_FmPcdPlcr && !p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Something WRONG"));
- if(!p_FmPcd->f_Exception)
+ if (!p_FmPcd->f_Exception)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("f_FmPcdExceptions has to be initialized"));
- if((!p_FmPcd->f_FmPcdIndexedException) && (p_FmPcd->p_FmPcdPlcr || p_FmPcd->p_FmPcdKg))
+ if ((!p_FmPcd->f_FmPcdIndexedException) && (p_FmPcd->p_FmPcdPlcr || p_FmPcd->p_FmPcdKg))
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("f_FmPcdIndexedException has to be initialized"));
- if(p_FmPcd->p_FmPcdDriverParam->prsMaxParseCycleLimit > PRS_MAX_CYCLE_LIMIT)
+ if (p_FmPcd->p_FmPcdDriverParam->prsMaxParseCycleLimit > PRS_MAX_CYCLE_LIMIT)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("prsMaxParseCycleLimit has to be less than 8191"));
}
@@ -78,21 +84,21 @@ static t_Error CheckFmPcdParameters(t_FmPcd *p_FmPcd)
}
static volatile bool blockingFlag = FALSE;
-static void FmPcdIpcMsgCompletionCB(t_Handle h_FmPcd,
- uint8_t *p_Msg,
- uint8_t *p_Reply,
- uint32_t replyLength,
- t_Error status)
+static void IpcMsgCompletionCB(t_Handle h_FmPcd,
+ uint8_t *p_Msg,
+ uint8_t *p_Reply,
+ uint32_t replyLength,
+ t_Error status)
{
UNUSED(h_FmPcd);UNUSED(p_Msg);UNUSED(p_Reply);UNUSED(replyLength);UNUSED(status);
blockingFlag = FALSE;
}
-static t_Error FmPcdHandleIpcMsgCB(t_Handle h_FmPcd,
- uint8_t *p_Msg,
- uint32_t msgLength,
- uint8_t *p_Reply,
- uint32_t *p_ReplyLength)
+static t_Error IpcMsgHandlerCB(t_Handle h_FmPcd,
+ uint8_t *p_Msg,
+ uint32_t msgLength,
+ uint8_t *p_Reply,
+ uint32_t *p_ReplyLength)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
t_Error err = E_OK;
@@ -111,7 +117,7 @@ static t_Error FmPcdHandleIpcMsgCB(t_Handle h_FmPcd,
memset(p_IpcReply, 0, (sizeof(uint8_t) * FM_PCD_MAX_REPLY_SIZE));
*p_ReplyLength = 0;
- switch(p_IpcMsg->msgId)
+ switch (p_IpcMsg->msgId)
{
case (FM_PCD_MASTER_IS_ALIVE):
*(uint8_t*)(p_IpcReply->replyBody) = 1;
@@ -120,14 +126,14 @@ static t_Error FmPcdHandleIpcMsgCB(t_Handle h_FmPcd,
break;
case (FM_PCD_MASTER_IS_ENABLED):
/* count partitions registrations */
- if(p_FmPcd->enabled)
+ if (p_FmPcd->enabled)
p_FmPcd->numOfEnabledGuestPartitionsPcds++;
*(uint8_t*)(p_IpcReply->replyBody) = (uint8_t)p_FmPcd->enabled;
p_IpcReply->error = E_OK;
*p_ReplyLength = sizeof(uint32_t) + sizeof(uint8_t);
break;
case (FM_PCD_GUEST_DISABLE):
- if(p_FmPcd->numOfEnabledGuestPartitionsPcds)
+ if (p_FmPcd->numOfEnabledGuestPartitionsPcds)
{
p_FmPcd->numOfEnabledGuestPartitionsPcds--;
p_IpcReply->error = E_OK;
@@ -139,7 +145,7 @@ static t_Error FmPcdHandleIpcMsgCB(t_Handle h_FmPcd,
}
*p_ReplyLength = sizeof(uint32_t);
break;
- case(FM_PCD_GET_COUNTER):
+ case (FM_PCD_GET_COUNTER):
{
e_FmPcdCounters inCounter;
uint32_t outCounter;
@@ -196,91 +202,54 @@ static t_Error FmPcdHandleIpcMsgCB(t_Handle h_FmPcd,
memcpy((uint8_t*)&ipcKgClsPlanParams, p_IpcMsg->msgBody, sizeof(t_FmPcdIpcKgClsPlanParams));
KgFreeClsPlanEntries(h_FmPcd,
- ipcKgClsPlanParams.numOfClsPlanEntries,
- ipcKgClsPlanParams.guestId,
- ipcKgClsPlanParams.clsPlanBase);
+ ipcKgClsPlanParams.numOfClsPlanEntries,
+ ipcKgClsPlanParams.guestId,
+ ipcKgClsPlanParams.clsPlanBase);
*p_ReplyLength = sizeof(uint32_t);
break;
}
case (FM_PCD_ALLOC_PROFILES):
{
- t_FmPcdIpcPlcrAllocParams ipcPlcrAllocParams;
- uint16_t profilesBase;
-
- memcpy((uint8_t*)&ipcPlcrAllocParams, p_IpcMsg->msgBody, sizeof(t_FmPcdIpcPlcrAllocParams));
- err = PlcrAllocProfiles(h_FmPcd,
- ipcPlcrAllocParams.hardwarePortId,
- ipcPlcrAllocParams.num,
- &profilesBase);
- memcpy(p_IpcReply->replyBody, (uint8_t*)&profilesBase, sizeof(uint16_t));
- p_IpcReply->error = err;
+ t_FmIpcResourceAllocParams ipcAllocParams;
+ uint16_t base;
+ memcpy(&ipcAllocParams, p_IpcMsg->msgBody, sizeof(t_FmIpcResourceAllocParams));
+ base = PlcrAllocProfilesForPartition(h_FmPcd,
+ ipcAllocParams.base,
+ ipcAllocParams.num,
+ ipcAllocParams.guestId);
+ memcpy(p_IpcReply->replyBody, (uint16_t*)&base, sizeof(uint16_t));
*p_ReplyLength = sizeof(uint32_t) + sizeof(uint16_t);
break;
}
case (FM_PCD_FREE_PROFILES):
{
- t_FmPcdIpcPlcrAllocParams ipcPlcrAllocParams;
-
- memcpy((uint8_t*)&ipcPlcrAllocParams, p_IpcMsg->msgBody, sizeof(t_FmPcdIpcPlcrAllocParams));
- err = PlcrFreeProfiles(h_FmPcd,
- ipcPlcrAllocParams.hardwarePortId,
- ipcPlcrAllocParams.num,
- ipcPlcrAllocParams.plcrProfilesBase);
- p_IpcReply->error = err;
- *p_ReplyLength = sizeof(uint32_t);
+ t_FmIpcResourceAllocParams ipcAllocParams;
+ memcpy(&ipcAllocParams, p_IpcMsg->msgBody, sizeof(t_FmIpcResourceAllocParams));
+ PlcrFreeProfilesForPartition(h_FmPcd,
+ ipcAllocParams.base,
+ ipcAllocParams.num,
+ ipcAllocParams.guestId);
break;
}
- case (FM_PCD_ALLOC_SHARED_PROFILES):
+ case (FM_PCD_SET_PORT_PROFILES):
{
- uint16_t numOfProfiles;
- uint16_t profilesIds[FM_PCD_PLCR_NUM_ENTRIES];
- uint32_t profilesMask[FM_PCD_PLCR_NUM_ENTRIES/32];
- int i;
-
- memset(profilesMask, 0, FM_PCD_PLCR_NUM_ENTRIES/32 * sizeof(uint32_t));
- memcpy((uint8_t*)&numOfProfiles, p_IpcMsg->msgBody, sizeof(uint16_t));
- err = PlcrAllocSharedProfiles(h_FmPcd,
- numOfProfiles,
- profilesIds);
- p_IpcReply->error = err;
-
- /* translate the allocated profile id's to a 32bit * 8regs mask */
- for(i = 0;i<numOfProfiles;i++)
- profilesMask[profilesIds[i]/32] |= (0x80000000 >> (profilesIds[i] % 32));
-
- memcpy(p_IpcReply->replyBody, (uint8_t*)&profilesMask, sizeof(profilesMask));
- *p_ReplyLength = sizeof(uint32_t) + sizeof(profilesMask); /* num-of-shared-profiles */
+ t_FmIpcResourceAllocParams ipcAllocParams;
+ memcpy(&ipcAllocParams, p_IpcMsg->msgBody, sizeof(t_FmIpcResourceAllocParams));
+ PlcrSetPortProfiles(h_FmPcd,
+ ipcAllocParams.guestId,
+ ipcAllocParams.num,
+ ipcAllocParams.base);
break;
}
- case (FM_PCD_FREE_SHARED_PROFILES):
+ case (FM_PCD_CLEAR_PORT_PROFILES):
{
- t_FmPcdIpcSharedPlcrAllocParams ipcSharedPlcrAllocParams;
- uint16_t profilesIds[FM_PCD_PLCR_NUM_ENTRIES];
- int i,j, index = 0;
- uint32_t walking1Mask = 0x80000000;
-
- memset(profilesIds, 0, FM_PCD_PLCR_NUM_ENTRIES*sizeof(uint16_t));
- memcpy((uint8_t*)&ipcSharedPlcrAllocParams, p_IpcMsg->msgBody, sizeof(t_FmPcdIpcSharedPlcrAllocParams));
- for(i = 0; i<FM_PCD_PLCR_NUM_ENTRIES/32 ; i++)
- {
- if(ipcSharedPlcrAllocParams.sharedProfilesMask[i])
- {
- for(j = 0 ; j<32 ; j++)
- {
- if(ipcSharedPlcrAllocParams.sharedProfilesMask[i] & walking1Mask)
- profilesIds[index++] = (uint16_t)(i*32+j);
- walking1Mask >>= 1;
- }
- walking1Mask = 0x80000000;
- }
- }
-
- PlcrFreeSharedProfiles(h_FmPcd,
- ipcSharedPlcrAllocParams.num,
- profilesIds);
+ t_FmIpcResourceAllocParams ipcAllocParams;
+ memcpy(&ipcAllocParams, p_IpcMsg->msgBody, sizeof(t_FmIpcResourceAllocParams));
+ PlcrClearPortProfiles(h_FmPcd,
+ ipcAllocParams.guestId);
break;
}
- case(FM_PCD_GET_SW_PRS_OFFSET):
+ case (FM_PCD_GET_SW_PRS_OFFSET):
{
t_FmPcdIpcSwPrsLable ipcSwPrsLable;
uint32_t swPrsOffset;
@@ -294,7 +263,7 @@ static t_Error FmPcdHandleIpcMsgCB(t_Handle h_FmPcd,
*p_ReplyLength = sizeof(uint32_t) + sizeof(uint32_t);
break;
}
- case(FM_PCD_PRS_INC_PORT_STATS):
+ case (FM_PCD_PRS_INC_PORT_STATS):
{
t_FmPcdIpcPrsIncludePort ipcPrsIncludePort;
@@ -304,33 +273,6 @@ static t_Error FmPcdHandleIpcMsgCB(t_Handle h_FmPcd,
ipcPrsIncludePort.include);
break;
}
-#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
- case(FM_PCD_DUMP_REGS):
- if((err = FM_PCD_DumpRegs(h_FmPcd)) != E_OK)
- REPORT_ERROR(MINOR, err, NO_MSG);
- break;
- case(FM_PCD_KG_DUMP_REGS):
- if((err = FM_PCD_KgDumpRegs(h_FmPcd)) != E_OK)
- REPORT_ERROR(MINOR, err, NO_MSG);
- break;
- case(FM_PCD_PLCR_DUMP_REGS):
- if((err = FM_PCD_PlcrDumpRegs(h_FmPcd)) != E_OK)
- REPORT_ERROR(MINOR, err, NO_MSG);
- break;
- case(FM_PCD_PLCR_PROFILE_DUMP_REGS):
- {
- t_Handle h_Profile;
- memcpy((uint8_t*)&h_Profile, p_IpcMsg->msgBody, sizeof(t_Handle));
- if((err = FM_PCD_PlcrProfileDumpRegs(h_FmPcd, h_Profile)) != E_OK)
- REPORT_ERROR(MINOR, err, NO_MSG);
- break;
-
- }
- case(FM_PCD_PRS_DUMP_REGS):
- if((err = FM_PCD_PrsDumpRegs(h_FmPcd)) != E_OK)
- REPORT_ERROR(MINOR, err, NO_MSG);
- break;
-#endif /* (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0)) */
default:
*p_ReplyLength = 0;
RETURN_ERROR(MINOR, E_INVALID_SELECTION, ("command not found!!!"));
@@ -338,8 +280,99 @@ static t_Error FmPcdHandleIpcMsgCB(t_Handle h_FmPcd,
return E_OK;
}
+static uint32_t NetEnvLock(t_Handle h_NetEnv)
+{
+ ASSERT_COND(h_NetEnv);
+ return XX_LockIntrSpinlock(((t_FmPcdNetEnv*)h_NetEnv)->h_Spinlock);
+}
+
+static void NetEnvUnlock(t_Handle h_NetEnv, uint32_t intFlags)
+{
+ ASSERT_COND(h_NetEnv);
+ XX_UnlockIntrSpinlock(((t_FmPcdNetEnv*)h_NetEnv)->h_Spinlock, intFlags);
+}
+
+static void EnqueueLockToFreeLst(t_FmPcd *p_FmPcd, t_FmPcdLock *p_Lock)
+{
+ uint32_t intFlags;
+
+ intFlags = XX_LockIntrSpinlock(p_FmPcd->h_Spinlock);
+ NCSW_LIST_AddToTail(&p_Lock->node, &p_FmPcd->freeLocksLst);
+ XX_UnlockIntrSpinlock(p_FmPcd->h_Spinlock, intFlags);
+}
+
+static t_FmPcdLock * DequeueLockFromFreeLst(t_FmPcd *p_FmPcd)
+{
+ t_FmPcdLock *p_Lock = NULL;
+ uint32_t intFlags;
+
+ intFlags = XX_LockIntrSpinlock(p_FmPcd->h_Spinlock);
+ if (!NCSW_LIST_IsEmpty(&p_FmPcd->freeLocksLst))
+ {
+ p_Lock = FM_PCD_LOCK_OBJ(p_FmPcd->freeLocksLst.p_Next);
+ NCSW_LIST_DelAndInit(&p_Lock->node);
+ }
+ if (p_FmPcd->h_Spinlock)
+ XX_UnlockIntrSpinlock(p_FmPcd->h_Spinlock, intFlags);
+
+ return p_Lock;
+}
+
+static void EnqueueLockToAcquiredLst(t_FmPcd *p_FmPcd, t_FmPcdLock *p_Lock)
+{
+ uint32_t intFlags;
+
+ intFlags = XX_LockIntrSpinlock(p_FmPcd->h_Spinlock);
+ NCSW_LIST_AddToTail(&p_Lock->node, &p_FmPcd->acquiredLocksLst);
+ XX_UnlockIntrSpinlock(p_FmPcd->h_Spinlock, intFlags);
+}
+
+static t_Error FillFreeLocksLst(t_FmPcd *p_FmPcd)
+{
+ t_FmPcdLock *p_Lock;
+ int i;
+
+ for (i=0; i<10; i++)
+ {
+ p_Lock = (t_FmPcdLock *)XX_Malloc(sizeof(t_FmPcdLock));
+ if (!p_Lock)
+ RETURN_ERROR(MINOR, E_NO_MEMORY, ("FM-PCD lock obj!"));
+ memset(p_Lock, 0, sizeof(t_FmPcdLock));
+ INIT_LIST(&p_Lock->node);
+ p_Lock->h_Spinlock = XX_InitSpinlock();
+ if (!p_Lock->h_Spinlock)
+ {
+ XX_Free(p_Lock);
+ RETURN_ERROR(MINOR, E_INVALID_STATE, ("FM-PCD spinlock obj!"));
+ }
+ EnqueueLockToFreeLst(p_FmPcd, p_Lock);
+ }
+
+ return E_OK;
+}
+
+static void ReleaseFreeLocksLst(t_FmPcd *p_FmPcd)
+{
+ t_FmPcdLock *p_Lock;
+
+ p_Lock = DequeueLockFromFreeLst(p_FmPcd);
+ while (p_Lock)
+ {
+ XX_FreeSpinlock(p_Lock->h_Spinlock);
+ XX_Free(p_Lock);
+ p_Lock = DequeueLockFromFreeLst(p_FmPcd);
+ }
+}
+
+
+
+/*****************************************************************************/
+/* Inter-module API routines */
+/*****************************************************************************/
+
void FmPcdSetClsPlanGrpId(t_FmPcd *p_FmPcd, uint8_t netEnvId, uint8_t clsPlanGrpId)
{
+ ASSERT_COND(p_FmPcd);
p_FmPcd->netEnvs[netEnvId].clsPlanGrpId = clsPlanGrpId;
}
@@ -348,7 +381,8 @@ t_Error PcdGetClsPlanGrpParams(t_FmPcd *p_FmPcd, t_FmPcdKgInterModuleClsPlanGrpP
uint8_t netEnvId = p_GrpParams->netEnvId;
int i, k, j;
- if(p_FmPcd->netEnvs[netEnvId].clsPlanGrpId != ILLEGAL_CLS_PLAN)
+ ASSERT_COND(p_FmPcd);
+ if (p_FmPcd->netEnvs[netEnvId].clsPlanGrpId != ILLEGAL_CLS_PLAN)
{
p_GrpParams->grpExists = TRUE;
p_GrpParams->clsPlanGrpId = p_FmPcd->netEnvs[netEnvId].clsPlanGrpId;
@@ -362,16 +396,16 @@ t_Error PcdGetClsPlanGrpParams(t_FmPcd *p_FmPcd, t_FmPcdKgInterModuleClsPlanGrpP
(p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].hdr != HEADER_TYPE_NONE)); k++)
{
/* if an option exists, add it to the opts list */
- if(p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].opt)
+ if (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].opt)
{
/* check if this option already exists, add if it doesn't */
- for(j = 0;j<p_GrpParams->numOfOptions;j++)
+ for (j = 0;j<p_GrpParams->numOfOptions;j++)
{
- if(p_GrpParams->options[j] == p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].opt)
+ if (p_GrpParams->options[j] == p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].opt)
break;
}
p_GrpParams->optVectors[j] |= p_FmPcd->netEnvs[netEnvId].unitsVectors[i];
- if(j == p_GrpParams->numOfOptions)
+ if (j == p_GrpParams->numOfOptions)
{
p_GrpParams->options[p_GrpParams->numOfOptions] = p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].opt;
p_GrpParams->numOfOptions++;
@@ -380,9 +414,9 @@ t_Error PcdGetClsPlanGrpParams(t_FmPcd *p_FmPcd, t_FmPcdKgInterModuleClsPlanGrpP
}
}
- if(p_GrpParams->numOfOptions == 0)
+ if (p_GrpParams->numOfOptions == 0)
{
- if(p_FmPcd->p_FmPcdKg->emptyClsPlanGrpId != ILLEGAL_CLS_PLAN)
+ if (p_FmPcd->p_FmPcdKg->emptyClsPlanGrpId != ILLEGAL_CLS_PLAN)
{
p_GrpParams->grpExists = TRUE;
p_GrpParams->clsPlanGrpId = p_FmPcd->p_FmPcdKg->emptyClsPlanGrpId;
@@ -399,6 +433,7 @@ t_Error PcdGetVectorForOpt(t_FmPcd *p_FmPcd, uint8_t netEnvId, protocolOpt_t opt
*p_Vector = 0;
+ ASSERT_COND(p_FmPcd);
for (j=0; ((j < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS) &&
(p_FmPcd->netEnvs[netEnvId].units[j].hdrs[0].hdr != HEADER_TYPE_NONE)); j++)
{
@@ -420,10 +455,13 @@ t_Error PcdGetUnitsVector(t_FmPcd *p_FmPcd, t_NetEnvParams *p_Params)
{
int i;
+ ASSERT_COND(p_FmPcd);
+ ASSERT_COND(p_Params->netEnvId < FM_MAX_NUM_OF_PORTS);
+
p_Params->vector = 0;
- for(i=0; i<p_Params->numOfDistinctionUnits ;i++)
+ for (i=0; i<p_Params->numOfDistinctionUnits ;i++)
{
- if(p_FmPcd->netEnvs[p_Params->netEnvId].units[p_Params->unitIds[i]].hdrs[0].hdr == HEADER_TYPE_NONE)
+ if (p_FmPcd->netEnvs[p_Params->netEnvId].units[p_Params->unitIds[i]].hdrs[0].hdr == HEADER_TYPE_NONE)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Requested unit was not defined for this Network Environment Characteristics module"));
ASSERT_COND(p_FmPcd->netEnvs[p_Params->netEnvId].unitsVectors[p_Params->unitIds[i]]);
p_Params->vector |= p_FmPcd->netEnvs[p_Params->netEnvId].unitsVectors[p_Params->unitIds[i]];
@@ -435,6 +473,8 @@ t_Error PcdGetUnitsVector(t_FmPcd *p_FmPcd, t_NetEnvParams *p_Params)
bool PcdNetEnvIsUnitWithoutOpts(t_FmPcd *p_FmPcd, uint8_t netEnvId, uint32_t unitVector)
{
int i=0, k;
+
+ ASSERT_COND(p_FmPcd);
/* check whether a given unit may be used by non-clsPlan users. */
/* first, recognize the unit by its vector */
while (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[0].hdr != HEADER_TYPE_NONE)
@@ -446,7 +486,7 @@ bool PcdNetEnvIsUnitWithoutOpts(t_FmPcd *p_FmPcd, uint8_t netEnvId, uint32_t uni
(p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].hdr != HEADER_TYPE_NONE));
k++)
/* check that no option exists */
- if((protocolOpt_t)p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].opt)
+ if ((protocolOpt_t)p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].opt)
return FALSE;
break;
}
@@ -472,7 +512,7 @@ bool FmPcdNetEnvIsHdrExist(t_Handle h_FmPcd, uint8_t netEnvId, e_NetHeaderType
if (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].hdr == hdr)
return TRUE;
}
- for (i=0; ((i < FM_PCD_MAX_NUM_OF_PRIVATE_HDRS) &&
+ for (i=0; ((i < FM_PCD_MAX_NUM_OF_ALIAS_HDRS) &&
(p_FmPcd->netEnvs[netEnvId].aliasHdrs[i].hdr != HEADER_TYPE_NONE)); i++)
{
if (p_FmPcd->netEnvs[netEnvId].aliasHdrs[i].hdr == hdr)
@@ -482,13 +522,87 @@ bool FmPcdNetEnvIsHdrExist(t_Handle h_FmPcd, uint8_t netEnvId, e_NetHeaderType
return FALSE;
}
+uint8_t FmPcdNetEnvGetUnitId(t_FmPcd *p_FmPcd, uint8_t netEnvId, e_NetHeaderType hdr, bool interchangeable, protocolOpt_t opt)
+{
+ uint8_t i, k;
+
+ ASSERT_COND(p_FmPcd);
+
+ if (interchangeable)
+ {
+ for (i=0; (i < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS) &&
+ (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[0].hdr != HEADER_TYPE_NONE); i++)
+ {
+ for (k=0; (k < FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS) &&
+ (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].hdr != HEADER_TYPE_NONE); k++)
+ {
+ if ((p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].hdr == hdr) &&
+ (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[k].opt == opt))
+
+ return i;
+ }
+ }
+ }
+ else
+ {
+ for (i=0; (i < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS) &&
+ (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[0].hdr != HEADER_TYPE_NONE); i++)
+ if ((p_FmPcd->netEnvs[netEnvId].units[i].hdrs[0].hdr == hdr) &&
+ (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[0].opt == opt) &&
+ (p_FmPcd->netEnvs[netEnvId].units[i].hdrs[1].hdr == HEADER_TYPE_NONE))
+ return i;
+
+ for (i=0; (i < FM_PCD_MAX_NUM_OF_ALIAS_HDRS) &&
+ (p_FmPcd->netEnvs[netEnvId].aliasHdrs[i].hdr != HEADER_TYPE_NONE); i++)
+ if ((p_FmPcd->netEnvs[netEnvId].aliasHdrs[i].hdr == hdr) &&
+ (p_FmPcd->netEnvs[netEnvId].aliasHdrs[i].opt == opt))
+ return p_FmPcd->netEnvs[netEnvId].aliasHdrs[i].aliasHdr;
+ }
+
+ return FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS;
+}
+
+t_Error FmPcdUnregisterReassmPort(t_Handle h_FmPcd, t_Handle h_ReasmCommonPramTbl)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_FmPcdCcReassmTimeoutParams ccReassmTimeoutParams = {0};
+ uint8_t result;
+ t_Error err = E_OK;
+
+ ASSERT_COND(p_FmPcd);
+ ASSERT_COND(h_ReasmCommonPramTbl);
+
+ ccReassmTimeoutParams.iprcpt = (uint32_t)(XX_VirtToPhys(h_ReasmCommonPramTbl) - p_FmPcd->physicalMuramBase);
+ ccReassmTimeoutParams.activate = FALSE; /*Disable Timeout Task*/
+
+ if ((err = FmHcPcdCcTimeoutReassm(p_FmPcd->h_Hc, &ccReassmTimeoutParams, &result)) != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ switch (result)
+ {
+ case (0):
+ return E_OK;
+ case (1):
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, (""));
+ case (2):
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, (""));
+ case (3):
+ RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("Disable Timeout Task with invalid IPRCPT"));
+ default:
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
+ }
+
+ return E_OK;
+}
+
e_NetHeaderType FmPcdGetAliasHdr(t_FmPcd *p_FmPcd, uint8_t netEnvId, e_NetHeaderType hdr)
{
int i;
ASSERT_COND(p_FmPcd);
+ ASSERT_COND(netEnvId < FM_MAX_NUM_OF_PORTS);
- for (i=0; (i < FM_PCD_MAX_NUM_OF_PRIVATE_HDRS)
+ for (i=0; (i < FM_PCD_MAX_NUM_OF_ALIAS_HDRS)
&& (p_FmPcd->netEnvs[netEnvId].aliasHdrs[i].hdr != HEADER_TYPE_NONE); i++)
{
if (p_FmPcd->netEnvs[netEnvId].aliasHdrs[i].hdr == hdr)
@@ -503,8 +617,8 @@ void FmPcdPortRegister(t_Handle h_FmPcd, t_Handle h_FmPort, uint8_t hardwarePo
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
uint16_t swPortIndex = 0;
+ ASSERT_COND(h_FmPcd);
HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId);
-
p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].h_FmPort = h_FmPort;
}
@@ -512,6 +626,7 @@ uint32_t FmPcdGetLcv(t_Handle h_FmPcd, uint32_t netEnvId, uint8_t hdrNum)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ ASSERT_COND(h_FmPcd);
return p_FmPcd->netEnvs[netEnvId].lcvs[hdrNum];
}
@@ -519,40 +634,154 @@ uint32_t FmPcdGetMacsecLcv(t_Handle h_FmPcd, uint32_t netEnvId)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ ASSERT_COND(h_FmPcd);
return p_FmPcd->netEnvs[netEnvId].macsecVector;
}
+uint8_t FmPcdGetNetEnvId(t_Handle h_NetEnv)
+{
+ return ((t_FmPcdNetEnv*)h_NetEnv)->netEnvId;
+}
+
void FmPcdIncNetEnvOwners(t_Handle h_FmPcd, uint8_t netEnvId)
{
+ uint32_t intFlags;
+
+ ASSERT_COND(h_FmPcd);
+
+ intFlags = NetEnvLock(&((t_FmPcd*)h_FmPcd)->netEnvs[netEnvId]);
((t_FmPcd*)h_FmPcd)->netEnvs[netEnvId].owners++;
+ NetEnvUnlock(&((t_FmPcd*)h_FmPcd)->netEnvs[netEnvId], intFlags);
}
void FmPcdDecNetEnvOwners(t_Handle h_FmPcd, uint8_t netEnvId)
{
+ uint32_t intFlags;
+
+ ASSERT_COND(h_FmPcd);
ASSERT_COND(((t_FmPcd*)h_FmPcd)->netEnvs[netEnvId].owners);
+
+ intFlags = NetEnvLock(&((t_FmPcd*)h_FmPcd)->netEnvs[netEnvId]);
((t_FmPcd*)h_FmPcd)->netEnvs[netEnvId].owners--;
+ NetEnvUnlock(&((t_FmPcd*)h_FmPcd)->netEnvs[netEnvId], intFlags);
}
uint32_t FmPcdLock(t_Handle h_FmPcd)
{
+ ASSERT_COND(h_FmPcd);
return XX_LockIntrSpinlock(((t_FmPcd*)h_FmPcd)->h_Spinlock);
}
void FmPcdUnlock(t_Handle h_FmPcd, uint32_t intFlags)
{
+ ASSERT_COND(h_FmPcd);
XX_UnlockIntrSpinlock(((t_FmPcd*)h_FmPcd)->h_Spinlock, intFlags);
}
+t_FmPcdLock * FmPcdAcquireLock(t_Handle h_FmPcd)
+{
+ t_FmPcdLock *p_Lock;
+ ASSERT_COND(h_FmPcd);
+ p_Lock = DequeueLockFromFreeLst((t_FmPcd*)h_FmPcd);
+ if (!p_Lock)
+ {
+ FillFreeLocksLst(h_FmPcd);
+ p_Lock = DequeueLockFromFreeLst((t_FmPcd*)h_FmPcd);
+ }
+
+ if (p_Lock)
+ EnqueueLockToAcquiredLst((t_FmPcd*)h_FmPcd, p_Lock);
+ return p_Lock;
+}
+
+void FmPcdReleaseLock(t_Handle h_FmPcd, t_FmPcdLock *p_Lock)
+{
+ uint32_t intFlags;
+ ASSERT_COND(h_FmPcd);
+ intFlags = FmPcdLock(h_FmPcd);
+ NCSW_LIST_DelAndInit(&p_Lock->node);
+ FmPcdUnlock(h_FmPcd, intFlags);
+ EnqueueLockToFreeLst((t_FmPcd*)h_FmPcd, p_Lock);
+}
+
+bool FmPcdLockTryLockAll(t_Handle h_FmPcd)
+{
+ uint32_t intFlags;
+ t_List *p_Pos, *p_SavedPos=NULL;
+
+ ASSERT_COND(h_FmPcd);
+ intFlags = FmPcdLock(h_FmPcd);
+ NCSW_LIST_FOR_EACH(p_Pos, &((t_FmPcd*)h_FmPcd)->acquiredLocksLst)
+ {
+ t_FmPcdLock *p_Lock = FM_PCD_LOCK_OBJ(p_Pos);
+ if (!FmPcdLockTryLock(p_Lock))
+ {
+ p_SavedPos = p_Pos;
+ break;
+ }
+ }
+ if (p_SavedPos)
+ {
+ NCSW_LIST_FOR_EACH(p_Pos, &((t_FmPcd*)h_FmPcd)->acquiredLocksLst)
+ {
+ t_FmPcdLock *p_Lock = FM_PCD_LOCK_OBJ(p_Pos);
+ if (p_Pos == p_SavedPos)
+ break;
+ FmPcdLockUnlock(p_Lock);
+ }
+ }
+ FmPcdUnlock(h_FmPcd, intFlags);
+
+ CORE_MemoryBarrier();
+
+ if (p_SavedPos)
+ return FALSE;
+
+ return TRUE;
+}
+
+void FmPcdLockUnlockAll(t_Handle h_FmPcd)
+{
+ uint32_t intFlags;
+ t_List *p_Pos;
+
+ ASSERT_COND(h_FmPcd);
+ intFlags = FmPcdLock(h_FmPcd);
+ NCSW_LIST_FOR_EACH(p_Pos, &((t_FmPcd*)h_FmPcd)->acquiredLocksLst)
+ {
+ t_FmPcdLock *p_Lock = FM_PCD_LOCK_OBJ(p_Pos);
+ p_Lock->flag = FALSE;
+ }
+ FmPcdUnlock(h_FmPcd, intFlags);
+
+ CORE_MemoryBarrier();
+}
+
+t_Error FmPcdHcSync(t_Handle h_FmPcd)
+{
+ ASSERT_COND(h_FmPcd);
+ ASSERT_COND(((t_FmPcd*)h_FmPcd)->h_Hc);
+
+ return FmHcPcdSync(((t_FmPcd*)h_FmPcd)->h_Hc);
+}
+
t_Handle FmPcdGetHcHandle(t_Handle h_FmPcd)
{
ASSERT_COND(h_FmPcd);
- SANITY_CHECK_RETURN_VALUE(((t_FmPcd*)h_FmPcd)->h_Hc, E_INVALID_HANDLE, NULL);
return ((t_FmPcd*)h_FmPcd)->h_Hc;
}
-/**********************************************************************************************************/
-/* API */
-/**********************************************************************************************************/
+bool FmPcdIsAdvancedOffloadSupported(t_Handle h_FmPcd)
+{
+ ASSERT_COND(h_FmPcd);
+ return ((t_FmPcd*)h_FmPcd)->advancedOffloadSupport;
+}
+/*********************** End of inter-module routines ************************/
+
+
+/****************************************/
+/* API Init unit functions */
+/****************************************/
t_Handle FM_PCD_Config(t_FmPcdParams *p_FmPcdParams)
{
@@ -565,7 +794,7 @@ t_Handle FM_PCD_Config(t_FmPcdParams *p_FmPcdParams)
p_FmPcd = (t_FmPcd *) XX_Malloc(sizeof(t_FmPcd));
if (!p_FmPcd)
{
- REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Pcd"));
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM PCD"));
return NULL;
}
memset(p_FmPcd, 0, sizeof(t_FmPcd));
@@ -574,7 +803,7 @@ t_Handle FM_PCD_Config(t_FmPcdParams *p_FmPcdParams)
if (!p_FmPcd->p_FmPcdDriverParam)
{
XX_Free(p_FmPcd);
- REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Pcd Driver Param"));
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM PCD Driver Param"));
return NULL;
}
memset(p_FmPcd->p_FmPcdDriverParam, 0, sizeof(t_FmPcdDriverParam));
@@ -582,10 +811,13 @@ t_Handle FM_PCD_Config(t_FmPcdParams *p_FmPcdParams)
p_FmPcd->h_Fm = p_FmPcdParams->h_Fm;
p_FmPcd->guestId = FmGetGuestId(p_FmPcd->h_Fm);
p_FmPcd->h_FmMuram = FmGetMuramHandle(p_FmPcd->h_Fm);
- FmGetPhysicalMuramBase(p_FmPcdParams->h_Fm, &physicalMuramBase);
- p_FmPcd->physicalMuramBase = (uint64_t)((uint64_t)(&physicalMuramBase)->low | ((uint64_t)(&physicalMuramBase)->high << 32));
+ if (p_FmPcd->h_FmMuram)
+ {
+ FmGetPhysicalMuramBase(p_FmPcdParams->h_Fm, &physicalMuramBase);
+ p_FmPcd->physicalMuramBase = (uint64_t)((uint64_t)(&physicalMuramBase)->low | ((uint64_t)(&physicalMuramBase)->high << 32));
+ }
- for(i = 0; i<FM_MAX_NUM_OF_PORTS; i++)
+ for (i = 0; i<FM_MAX_NUM_OF_PORTS; i++)
p_FmPcd->netEnvs[i].clsPlanGrpId = ILLEGAL_CLS_PLAN;
if (p_FmPcdParams->useHostCommand)
@@ -599,42 +831,42 @@ t_Handle FM_PCD_Config(t_FmPcdParams *p_FmPcdParams)
p_FmPcd->h_Hc = FmHcConfigAndInit(&hcParams);
if (!p_FmPcd->h_Hc)
{
- REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Pcd HC"));
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM PCD HC"));
FM_PCD_Free(p_FmPcd);
return NULL;
}
}
- else if(p_FmPcd->guestId != NCSW_MASTER_ID)
+ else if (p_FmPcd->guestId != NCSW_MASTER_ID)
REPORT_ERROR(MAJOR, E_INVALID_STATE, ("No Host Command defined for a guest partition."));
- if(p_FmPcdParams->kgSupport)
+ if (p_FmPcdParams->kgSupport)
{
p_FmPcd->p_FmPcdKg = (t_FmPcdKg *)KgConfig(p_FmPcd, p_FmPcdParams);
- if(!p_FmPcd->p_FmPcdKg)
+ if (!p_FmPcd->p_FmPcdKg)
{
- REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Pcd Keygen"));
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM PCD Keygen"));
FM_PCD_Free(p_FmPcd);
return NULL;
}
}
- if(p_FmPcdParams->plcrSupport)
+ if (p_FmPcdParams->plcrSupport)
{
p_FmPcd->p_FmPcdPlcr = (t_FmPcdPlcr *)PlcrConfig(p_FmPcd, p_FmPcdParams);
- if(!p_FmPcd->p_FmPcdPlcr)
+ if (!p_FmPcd->p_FmPcdPlcr)
{
- REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Pcd Policer"));
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM PCD Policer"));
FM_PCD_Free(p_FmPcd);
return NULL;
}
}
- if(p_FmPcdParams->prsSupport)
+ if (p_FmPcdParams->prsSupport)
{
p_FmPcd->p_FmPcdPrs = (t_FmPcdPrs *)PrsConfig(p_FmPcd, p_FmPcdParams);
- if(!p_FmPcd->p_FmPcdPrs)
+ if (!p_FmPcd->p_FmPcdPrs)
{
- REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Pcd Parser"));
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM PCD Parser"));
FM_PCD_Free(p_FmPcd);
return NULL;
}
@@ -643,10 +875,12 @@ t_Handle FM_PCD_Config(t_FmPcdParams *p_FmPcdParams)
p_FmPcd->h_Spinlock = XX_InitSpinlock();
if (!p_FmPcd->h_Spinlock)
{
- REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Pcd spinlock"));
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM PCD spinlock"));
FM_PCD_Free(p_FmPcd);
return NULL;
}
+ INIT_LIST(&p_FmPcd->freeLocksLst);
+ INIT_LIST(&p_FmPcd->acquiredLocksLst);
p_FmPcd->numOfEnabledGuestPartitionsPcds = 0;
@@ -654,6 +888,18 @@ t_Handle FM_PCD_Config(t_FmPcdParams *p_FmPcdParams)
p_FmPcd->f_FmPcdIndexedException = p_FmPcdParams->f_ExceptionId;
p_FmPcd->h_App = p_FmPcdParams->h_App;
+ p_FmPcd->p_CcShadow = NULL;
+ p_FmPcd->ccShadowSize = 0;
+ p_FmPcd->ccShadowAlign = 0;
+
+ p_FmPcd->h_ShadowSpinlock = XX_InitSpinlock();
+ if (!p_FmPcd->h_ShadowSpinlock)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM PCD shadow spinlock"));
+ FM_PCD_Free(p_FmPcd);
+ return NULL;
+ }
+
return p_FmPcd;
}
@@ -666,81 +912,101 @@ t_Error FM_PCD_Init(t_Handle h_FmPcd)
SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdDriverParam, E_INVALID_HANDLE);
- if(p_FmPcd->guestId != NCSW_MASTER_ID)
- {
- uint8_t isMasterAlive = 0;
- t_FmPcdIpcReply reply;
- uint32_t replyLength;
+ FM_GetRevision(p_FmPcd->h_Fm, &p_FmPcd->fmRevInfo);
+ if (p_FmPcd->guestId != NCSW_MASTER_ID)
+ {
memset(p_FmPcd->fmPcdIpcHandlerModuleName, 0, (sizeof(char)) * MODULE_NAME_SIZE);
- if(Sprint (p_FmPcd->fmPcdIpcHandlerModuleName, "FM_PCD_%d_%d", FmGetId(p_FmPcd->h_Fm), NCSW_MASTER_ID) != 10)
+ if (Sprint (p_FmPcd->fmPcdIpcHandlerModuleName, "FM_PCD_%d_%d", FmGetId(p_FmPcd->h_Fm), NCSW_MASTER_ID) != 10)
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
memset(p_FmPcd->fmPcdModuleName, 0, (sizeof(char)) * MODULE_NAME_SIZE);
- if(Sprint (p_FmPcd->fmPcdModuleName, "FM_PCD_%d_%d",FmGetId(p_FmPcd->h_Fm), p_FmPcd->guestId) != (p_FmPcd->guestId<10 ? 10:11))
+ if (Sprint (p_FmPcd->fmPcdModuleName, "FM_PCD_%d_%d",FmGetId(p_FmPcd->h_Fm), p_FmPcd->guestId) != (p_FmPcd->guestId<10 ? 10:11))
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
p_FmPcd->h_IpcSession = XX_IpcInitSession(p_FmPcd->fmPcdIpcHandlerModuleName, p_FmPcd->fmPcdModuleName);
- if (p_FmPcd->h_IpcSession == NULL)
- RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("FM PCD Guest %d IPC session", p_FmPcd->guestId));
+ if (p_FmPcd->h_IpcSession)
+ {
+ t_FmPcdIpcReply reply;
+ uint32_t replyLength;
+ uint8_t isMasterAlive = 0;
- memset(&msg, 0, sizeof(msg));
- memset(&reply, 0, sizeof(reply));
- msg.msgId = FM_PCD_MASTER_IS_ALIVE;
- msg.msgBody[0] = p_FmPcd->guestId;
- blockingFlag = TRUE;
+ memset(&msg, 0, sizeof(msg));
+ memset(&reply, 0, sizeof(reply));
+ msg.msgId = FM_PCD_MASTER_IS_ALIVE;
+ msg.msgBody[0] = p_FmPcd->guestId;
+ blockingFlag = TRUE;
- do
- {
- replyLength = sizeof(uint32_t) + sizeof(isMasterAlive);
- if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
- (uint8_t*)&msg,
- sizeof(msg.msgId)+sizeof(p_FmPcd->guestId),
- (uint8_t*)&reply,
- &replyLength,
- FmPcdIpcMsgCompletionCB,
- h_FmPcd)) != E_OK)
- REPORT_ERROR(MAJOR, err, NO_MSG);
- while(blockingFlag) ;
- if(replyLength != (sizeof(uint32_t) + sizeof(isMasterAlive)))
- REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
- isMasterAlive = *(uint8_t*)(reply.replyBody);
- } while (!isMasterAlive);
+ do
+ {
+ replyLength = sizeof(uint32_t) + sizeof(isMasterAlive);
+ if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
+ (uint8_t*)&msg,
+ sizeof(msg.msgId)+sizeof(p_FmPcd->guestId),
+ (uint8_t*)&reply,
+ &replyLength,
+ IpcMsgCompletionCB,
+ h_FmPcd)) != E_OK)
+ REPORT_ERROR(MAJOR, err, NO_MSG);
+ while (blockingFlag) ;
+ if (replyLength != (sizeof(uint32_t) + sizeof(isMasterAlive)))
+ REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
+ isMasterAlive = *(uint8_t*)(reply.replyBody);
+ } while (!isMasterAlive);
+ }
}
CHECK_INIT_PARAMETERS(p_FmPcd, CheckFmPcdParameters);
- if(p_FmPcd->p_FmPcdKg)
+ if (p_FmPcd->p_FmPcdKg)
{
err = KgInit(p_FmPcd);
- if(err)
+ if (err)
RETURN_ERROR(MAJOR, err, NO_MSG);
}
- if(p_FmPcd->p_FmPcdPlcr)
+ if (p_FmPcd->p_FmPcdPlcr)
{
err = PlcrInit(p_FmPcd);
- if(err)
+ if (err)
RETURN_ERROR(MAJOR, err, NO_MSG);
}
- if(p_FmPcd->p_FmPcdPrs)
+ if (p_FmPcd->p_FmPcdPrs)
{
err = PrsInit(p_FmPcd);
- if(err)
+ if (err)
RETURN_ERROR(MAJOR, err, NO_MSG);
}
- if(p_FmPcd->guestId == NCSW_MASTER_ID)
+ if (p_FmPcd->guestId == NCSW_MASTER_ID)
{
/* register to inter-core messaging mechanism */
memset(p_FmPcd->fmPcdModuleName, 0, (sizeof(char)) * MODULE_NAME_SIZE);
- if(Sprint (p_FmPcd->fmPcdModuleName, "FM_PCD_%d_%d",FmGetId(p_FmPcd->h_Fm),NCSW_MASTER_ID) != 10)
+ if (Sprint (p_FmPcd->fmPcdModuleName, "FM_PCD_%d_%d",FmGetId(p_FmPcd->h_Fm),NCSW_MASTER_ID) != 10)
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
- err = XX_IpcRegisterMsgHandler(p_FmPcd->fmPcdModuleName, FmPcdHandleIpcMsgCB, p_FmPcd, FM_PCD_MAX_REPLY_SIZE);
- if(err)
+ err = XX_IpcRegisterMsgHandler(p_FmPcd->fmPcdModuleName, IpcMsgHandlerCB, p_FmPcd, FM_PCD_MAX_REPLY_SIZE);
+ if (err)
RETURN_ERROR(MAJOR, err, NO_MSG);
}
+ /* IPv6 Frame-Id used for fragmentation */
+ p_FmPcd->ipv6FrameIdAddr = PTR_TO_UINT(FM_MURAM_AllocMem(p_FmPcd->h_FmMuram, 4, 4));
+ if (!p_FmPcd->ipv6FrameIdAddr)
+ {
+ FM_PCD_Free(p_FmPcd);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for IPv6 Frame-Id"));
+ }
+ IOMemSet32(UINT_TO_PTR(p_FmPcd->ipv6FrameIdAddr), 0, 4);
+
+ /* CAPWAP Frame-Id used for fragmentation */
+ p_FmPcd->capwapFrameIdAddr = PTR_TO_UINT(FM_MURAM_AllocMem(p_FmPcd->h_FmMuram, 2, 4));
+ if (!p_FmPcd->capwapFrameIdAddr)
+ {
+ FM_PCD_Free(p_FmPcd);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for CAPWAP Frame-Id"));
+ }
+ IOMemSet32(UINT_TO_PTR(p_FmPcd->capwapFrameIdAddr), 0, 2);
+
XX_Free(p_FmPcd->p_FmPcdDriverParam);
p_FmPcd->p_FmPcdDriverParam = NULL;
@@ -754,36 +1020,39 @@ t_Error FM_PCD_Free(t_Handle h_FmPcd)
t_FmPcd *p_FmPcd =(t_FmPcd *)h_FmPcd;
t_Error err = E_OK;
- if(p_FmPcd->enabled)
- FM_PCD_Disable(p_FmPcd);
+ if (p_FmPcd->ipv6FrameIdAddr)
+ FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, UINT_TO_PTR(p_FmPcd->ipv6FrameIdAddr));
- if (p_FmPcd->h_Spinlock)
- XX_FreeSpinlock(p_FmPcd->h_Spinlock);
+ if (p_FmPcd->capwapFrameIdAddr)
+ FM_MURAM_FreeMem(p_FmPcd->h_FmMuram, UINT_TO_PTR(p_FmPcd->capwapFrameIdAddr));
- if(p_FmPcd->p_FmPcdDriverParam)
+ if (p_FmPcd->enabled)
+ FM_PCD_Disable(p_FmPcd);
+
+ if (p_FmPcd->p_FmPcdDriverParam)
{
XX_Free(p_FmPcd->p_FmPcdDriverParam);
p_FmPcd->p_FmPcdDriverParam = NULL;
}
- if(p_FmPcd->p_FmPcdKg)
+
+ if (p_FmPcd->p_FmPcdKg)
{
- if((err = KgFree(p_FmPcd)) != E_OK)
+ if ((err = KgFree(p_FmPcd)) != E_OK)
RETURN_ERROR(MINOR, err, NO_MSG);
XX_Free(p_FmPcd->p_FmPcdKg);
p_FmPcd->p_FmPcdKg = NULL;
}
- if(p_FmPcd->p_FmPcdPlcr)
+ if (p_FmPcd->p_FmPcdPlcr)
{
- if((err = PlcrFree(p_FmPcd)) != E_OK)
- RETURN_ERROR(MINOR, err, NO_MSG);
+ PlcrFree(p_FmPcd);
XX_Free(p_FmPcd->p_FmPcdPlcr);
p_FmPcd->p_FmPcdPlcr = NULL;
}
- if(p_FmPcd->p_FmPcdPrs)
+ if (p_FmPcd->p_FmPcdPrs)
{
- if(p_FmPcd->guestId == NCSW_MASTER_ID)
+ if (p_FmPcd->guestId == NCSW_MASTER_ID)
PrsFree(p_FmPcd);
XX_Free(p_FmPcd->p_FmPcdPrs);
p_FmPcd->p_FmPcdPrs = NULL;
@@ -799,10 +1068,53 @@ t_Error FM_PCD_Free(t_Handle h_FmPcd)
FmUnregisterPcd(p_FmPcd->h_Fm);
+ ReleaseFreeLocksLst(p_FmPcd);
+
+ if (p_FmPcd->h_Spinlock)
+ XX_FreeSpinlock(p_FmPcd->h_Spinlock);
+
+ if (p_FmPcd->h_ShadowSpinlock)
+ XX_FreeSpinlock(p_FmPcd->h_ShadowSpinlock);
+
XX_Free(p_FmPcd);
+
+ return E_OK;
+}
+
+t_Error FM_PCD_ConfigException(t_Handle h_FmPcd, e_FmPcdExceptions exception, bool enable)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ uint32_t bitMask = 0;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+
+ if (p_FmPcd->guestId != NCSW_MASTER_ID)
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_ConfigException - guest mode!"));
+
+ GET_FM_PCD_EXCEPTION_FLAG(bitMask, exception);
+ if (bitMask)
+ {
+ if (enable)
+ p_FmPcd->exceptions |= bitMask;
+ else
+ p_FmPcd->exceptions &= ~bitMask;
+ }
+ else
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
+
return E_OK;
}
+t_Error FM_PCD_ConfigHcFramesDataMemory(t_Handle h_FmPcd, uint8_t memId)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);
+
+ return FmHcSetFramesDataMemory(p_FmPcd->h_Hc, memId);
+}
+
t_Error FM_PCD_Enable(t_Handle h_FmPcd)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
@@ -810,28 +1122,19 @@ t_Error FM_PCD_Enable(t_Handle h_FmPcd)
SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
- if(p_FmPcd->guestId == NCSW_MASTER_ID)
- {
- if(p_FmPcd->p_FmPcdKg)
- KgEnable(p_FmPcd);
-
- if(p_FmPcd->p_FmPcdPlcr)
- PlcrEnable(p_FmPcd);
-
- if(p_FmPcd->p_FmPcdPrs)
- PrsEnable(p_FmPcd);
+ if (p_FmPcd->enabled)
+ return E_OK;
- p_FmPcd->enabled = TRUE;
- }
- else
+ if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
+ p_FmPcd->h_IpcSession)
{
uint8_t enabled;
t_FmPcdIpcMsg msg;
t_FmPcdIpcReply reply;
uint32_t replyLength;
- memset(&msg, 0, sizeof(msg));
memset(&reply, 0, sizeof(reply));
+ memset(&msg, 0, sizeof(msg));
msg.msgId = FM_PCD_MASTER_IS_ENABLED;
replyLength = sizeof(uint32_t) + sizeof(enabled);
if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
@@ -847,7 +1150,23 @@ t_Error FM_PCD_Enable(t_Handle h_FmPcd)
p_FmPcd->enabled = (bool)!!(*(uint8_t*)(reply.replyBody));
if (!p_FmPcd->enabled)
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM-PCD master should be enabled first!"));
+
+ return E_OK;
}
+ else if (p_FmPcd->guestId != NCSW_MASTER_ID)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("running in guest-mode without IPC!"));
+
+ if (p_FmPcd->p_FmPcdKg)
+ KgEnable(p_FmPcd);
+
+ if (p_FmPcd->p_FmPcdPlcr)
+ PlcrEnable(p_FmPcd);
+
+ if (p_FmPcd->p_FmPcdPrs)
+ PrsEnable(p_FmPcd);
+
+ p_FmPcd->enabled = TRUE;
return E_OK;
}
@@ -856,50 +1175,62 @@ t_Error FM_PCD_Disable(t_Handle h_FmPcd)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
t_Error err = E_OK;
- t_FmPcdIpcMsg msg;
- t_FmPcdIpcReply reply;
- uint32_t replyLength;
SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
- if(p_FmPcd->guestId == NCSW_MASTER_ID)
+ if (!p_FmPcd->enabled)
+ return E_OK;
+
+ if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
+ p_FmPcd->h_IpcSession)
{
- if(p_FmPcd->numOfEnabledGuestPartitionsPcds != 0)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Trying to disable a master partition PCD while guest partitions are still enabled."));
+ t_FmPcdIpcMsg msg;
+ t_FmPcdIpcReply reply;
+ uint32_t replyLength;
+
+ memset(&reply, 0, sizeof(reply));
+ memset(&msg, 0, sizeof(msg));
+ msg.msgId = FM_PCD_GUEST_DISABLE;
+ replyLength = sizeof(uint32_t);
+ if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
+ (uint8_t*)&msg,
+ sizeof(msg.msgId),
+ (uint8_t*)&reply,
+ &replyLength,
+ NULL,
+ NULL)) != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ if (replyLength != sizeof(uint32_t))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
+ if (reply.error == E_OK)
+ p_FmPcd->enabled = FALSE;
- if(p_FmPcd->p_FmPcdKg)
- KgDisable(p_FmPcd);
+ return (t_Error)(reply.error);
+ }
+ else if (p_FmPcd->guestId != NCSW_MASTER_ID)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("running in guest-mode without IPC!"));
- if(p_FmPcd->p_FmPcdPlcr)
- PlcrDisable(p_FmPcd);
+ if (p_FmPcd->numOfEnabledGuestPartitionsPcds != 0)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("Trying to disable a master partition PCD while"
+ "guest partitions are still enabled!"));
- if(p_FmPcd->p_FmPcdPrs)
- PrsDisable(p_FmPcd);
+ if (p_FmPcd->p_FmPcdKg)
+ KgDisable(p_FmPcd);
- p_FmPcd->enabled = FALSE;
+ if (p_FmPcd->p_FmPcdPlcr)
+ PlcrDisable(p_FmPcd);
- return E_OK;
- }
+ if (p_FmPcd->p_FmPcdPrs)
+ PrsDisable(p_FmPcd);
- memset(&msg, 0, sizeof(msg));
- msg.msgId = FM_PCD_GUEST_DISABLE;
- memset(&reply, 0, sizeof(reply));
- replyLength = sizeof(uint32_t);
- if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
- (uint8_t*)&msg,
- sizeof(msg.msgId),
- (uint8_t*)&reply,
- &replyLength,
- NULL,
- NULL)) != E_OK)
- RETURN_ERROR(MAJOR, err, NO_MSG);
- if (replyLength != sizeof(uint32_t))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
+ p_FmPcd->enabled = FALSE;
- return (t_Error)(reply.error);
+ return E_OK;
}
-t_Handle FM_PCD_SetNetEnvCharacteristics(t_Handle h_FmPcd, t_FmPcdNetEnvParams *p_NetEnvParams)
+t_Handle FM_PCD_NetEnvCharacteristicsSet(t_Handle h_FmPcd, t_FmPcdNetEnvParams *p_NetEnvParams)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
uint32_t intFlags, specialUnits = 0;
@@ -909,18 +1240,20 @@ t_Handle FM_PCD_SetNetEnvCharacteristics(t_Handle h_FmPcd, t_FmPcdNetEnvParams
uint8_t ipsecAhUnit = 0,ipsecEspUnit = 0;
bool ipsecAhExists = FALSE, ipsecEspExists = FALSE, shim1Selected = FALSE;
uint8_t hdrNum;
+ t_FmPcdNetEnvParams *p_ModifiedNetEnvParams;
SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_STATE, NULL);
SANITY_CHECK_RETURN_VALUE(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE, NULL);
+ SANITY_CHECK_RETURN_VALUE(p_NetEnvParams, E_NULL_POINTER, NULL);
intFlags = FmPcdLock(p_FmPcd);
/* find a new netEnv */
- for(i = 0;i<FM_MAX_NUM_OF_PORTS;i++)
- if(!p_FmPcd->netEnvs[i].used)
+ for (i = 0; i < FM_MAX_NUM_OF_PORTS; i++)
+ if (!p_FmPcd->netEnvs[i].used)
break;
- if(i== FM_MAX_NUM_OF_PORTS)
+ if (i== FM_MAX_NUM_OF_PORTS)
{
REPORT_ERROR(MAJOR, E_FULL,("No more than %d netEnv's allowed.", FM_MAX_NUM_OF_PORTS));
FmPcdUnlock(p_FmPcd, intFlags);
@@ -928,63 +1261,78 @@ t_Handle FM_PCD_SetNetEnvCharacteristics(t_Handle h_FmPcd, t_FmPcdNetEnvParams
}
p_FmPcd->netEnvs[i].used = TRUE;
+ FmPcdUnlock(p_FmPcd, intFlags);
+
+ /* As anyone doesn't have handle of this netEnv yet, no need
+ to protect it with spinlocks */
- if (!TRY_LOCK(NULL, &p_FmPcd->netEnvs[i].lock))
+ p_ModifiedNetEnvParams = (t_FmPcdNetEnvParams *)XX_Malloc(sizeof(t_FmPcdNetEnvParams));
+ if (!p_ModifiedNetEnvParams)
{
- FmPcdUnlock(p_FmPcd, intFlags);
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FmPcdNetEnvParams"));
return NULL;
}
- FmPcdUnlock(p_FmPcd, intFlags);
+
+ memcpy(p_ModifiedNetEnvParams, p_NetEnvParams, sizeof(t_FmPcdNetEnvParams));
+ p_NetEnvParams = p_ModifiedNetEnvParams;
netEnvCurrId = (uint8_t)i;
/* clear from previous use */
memset(&p_FmPcd->netEnvs[netEnvCurrId].units, 0, FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS * sizeof(t_FmPcdIntDistinctionUnit));
- memset(&p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs, 0, FM_PCD_MAX_NUM_OF_PRIVATE_HDRS * sizeof(t_FmPcdNetEnvAliases));
+ memset(&p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs, 0, FM_PCD_MAX_NUM_OF_ALIAS_HDRS * sizeof(t_FmPcdNetEnvAliases));
memcpy(&p_FmPcd->netEnvs[netEnvCurrId].units, p_NetEnvParams->units, p_NetEnvParams->numOfDistinctionUnits*sizeof(t_FmPcdIntDistinctionUnit));
+
+ p_FmPcd->netEnvs[netEnvCurrId].netEnvId = netEnvCurrId;
+ p_FmPcd->netEnvs[netEnvCurrId].h_FmPcd = p_FmPcd;
+
p_FmPcd->netEnvs[netEnvCurrId].clsPlanGrpId = ILLEGAL_CLS_PLAN;
/* check that header with opt is not interchanged with the same header */
- for (i=0; (i < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
+ for (i = 0; (i < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
&& (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr != HEADER_TYPE_NONE); i++)
{
- for (k=0; (k < FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS)
+ for (k = 0; (k < FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS)
&& (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr != HEADER_TYPE_NONE); k++)
{
/* if an option exists, check that other headers are not the same header
without option */
- if(p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt)
+ if (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt)
{
- for (j=0; (j < FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS)
+ for (j = 0; (j < FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS)
&& (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[j].hdr != HEADER_TYPE_NONE); j++)
- if((p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[j].hdr == p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr) &&
+ {
+ if ((p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[j].hdr == p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr) &&
!p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[j].opt)
{
- REPORT_ERROR(MINOR, E_FULL, ("Illegal unit - header with opt may not be interchangeable with the same header without opt"));
- RELEASE_LOCK(p_FmPcd->netEnvs[netEnvCurrId].lock);
+ REPORT_ERROR(MINOR, E_FULL,
+ ("Illegal unit - header with opt may not be interchangeable with the same header without opt"));
+ XX_Free(p_ModifiedNetEnvParams);
return NULL;
}
+ }
}
}
}
- /* IPSEC_AH and IPSEC_SPI can't be 2 units, */
- /* check that header with opt is not interchanged with the same header */
- for(i=0; (i < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
+ /* Specific headers checking */
+ for (i = 0; (i < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
&& (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr != HEADER_TYPE_NONE); i++)
{
- for(k=0; (k < FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS)
+ for (k = 0; (k < FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS)
&& (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr != HEADER_TYPE_NONE); k++)
{
/* Some headers pairs may not be defined on different units as the parser
doesn't distinguish */
- if(p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr == HEADER_TYPE_IPSEC_AH)
+ /* IPSEC_AH and IPSEC_SPI can't be 2 units, */
+ /* check that header with opt is not interchanged with the same header */
+ if (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr == HEADER_TYPE_IPSEC_AH)
{
if (ipsecEspExists && (ipsecEspUnit != i))
{
REPORT_ERROR(MINOR, E_INVALID_STATE, ("HEADER_TYPE_IPSEC_AH and HEADER_TYPE_IPSEC_ESP may not be defined in separate units"));
- RELEASE_LOCK(p_FmPcd->netEnvs[netEnvCurrId].lock);
- return NULL;
+ XX_Free(p_ModifiedNetEnvParams);
+ return NULL;
}
else
{
@@ -992,12 +1340,12 @@ t_Handle FM_PCD_SetNetEnvCharacteristics(t_Handle h_FmPcd, t_FmPcdNetEnvParams
ipsecAhExists = TRUE;
}
}
- if(p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr == HEADER_TYPE_IPSEC_ESP)
+ if (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr == HEADER_TYPE_IPSEC_ESP)
{
if (ipsecAhExists && (ipsecAhUnit != i))
{
REPORT_ERROR(MINOR, E_INVALID_STATE, ("HEADER_TYPE_IPSEC_AH and HEADER_TYPE_IPSEC_ESP may not be defined in separate units"));
- RELEASE_LOCK(p_FmPcd->netEnvs[netEnvCurrId].lock);
+ XX_Free(p_ModifiedNetEnvParams);
return NULL;
}
else
@@ -1006,46 +1354,111 @@ t_Handle FM_PCD_SetNetEnvCharacteristics(t_Handle h_FmPcd, t_FmPcdNetEnvParams
ipsecEspExists = TRUE;
}
}
- if(p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr == HEADER_TYPE_UDP_ENCAP_ESP)
+ /* ENCAP_ESP */
+ if (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr == HEADER_TYPE_UDP_ENCAP_ESP)
{
- /* TODO - general coding. choose the free shim header */
+ /* IPSec UDP encapsulation is currently set to use SHIM1 */
p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits].hdr = HEADER_TYPE_UDP_ENCAP_ESP;
p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits++].aliasHdr = HEADER_TYPE_USER_DEFINED_SHIM1;
p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr = HEADER_TYPE_USER_DEFINED_SHIM1;
p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt = 0;
}
+#if (DPAA_VERSION >= 11) || ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
+ /* UDP_LITE */
+ if (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr == HEADER_TYPE_UDP_LITE)
+ {
+ p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits].hdr = HEADER_TYPE_UDP_LITE;
+ p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits++].aliasHdr = HEADER_TYPE_UDP;
+ p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr = HEADER_TYPE_UDP;
+ p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt = 0;
+ }
+#endif /* (DPAA_VERSION >= 11) || ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
+
+ /* IP FRAG */
+ if ((p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr == HEADER_TYPE_IPv4) &&
+ (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt == IPV4_FRAG_1))
+ {
+ /* If IPv4+Frag, we need to set 2 units - SHIM 2 and IPv4. We first set SHIM2, and than check if
+ * IPv4 exists. If so we don't need to set an extra unit
+ * We consider as "having IPv4" any IPv4 without interchangable headers
+ * but including any options. */
+ p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits].hdr = HEADER_TYPE_IPv4;
+ p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits].opt = IPV4_FRAG_1;
+ p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits++].aliasHdr = HEADER_TYPE_USER_DEFINED_SHIM2;
+ p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr = HEADER_TYPE_USER_DEFINED_SHIM2;
+ p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt = 0;
+
+ /* check if IPv4 header exists by itself */
+ if (FmPcdNetEnvGetUnitId(p_FmPcd, netEnvCurrId, HEADER_TYPE_IPv4, FALSE, 0) == FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
+ {
+ p_FmPcd->netEnvs[netEnvCurrId].units[p_NetEnvParams->numOfDistinctionUnits].hdrs[0].hdr = HEADER_TYPE_IPv4;
+ p_FmPcd->netEnvs[netEnvCurrId].units[p_NetEnvParams->numOfDistinctionUnits++].hdrs[0].opt = 0;
+ }
+ }
+ if ((p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr == HEADER_TYPE_IPv6) &&
+ (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt == IPV6_FRAG_1))
+ {
+ /* If IPv6+Frag, we need to set 2 units - SHIM 2 and IPv6. We first set SHIM2, and than check if
+ * IPv4 exists. If so we don't need to set an extra unit
+ * We consider as "having IPv6" any IPv6 without interchangable headers
+ * but including any options. */
+ p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits].hdr = HEADER_TYPE_IPv6;
+ p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits].opt = IPV6_FRAG_1;
+ p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits++].aliasHdr = HEADER_TYPE_USER_DEFINED_SHIM2;
+ p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr = HEADER_TYPE_USER_DEFINED_SHIM2;
+ p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt = 0;
+
+ /* check if IPv6 header exists by itself */
+ if (FmPcdNetEnvGetUnitId(p_FmPcd, netEnvCurrId, HEADER_TYPE_IPv6, FALSE, 0) == FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
+ {
+ p_FmPcd->netEnvs[netEnvCurrId].units[p_NetEnvParams->numOfDistinctionUnits].hdrs[0].hdr = HEADER_TYPE_IPv6;
+ p_FmPcd->netEnvs[netEnvCurrId].units[p_NetEnvParams->numOfDistinctionUnits++].hdrs[0].opt = 0;
+ }
+ }
+#if (DPAA_VERSION >= 11)
+ /* CAPWAP FRAG */
+ if ((p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr == HEADER_TYPE_CAPWAP) &&
+ (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt == CAPWAP_FRAG_1))
+ {
+ p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits].hdr = HEADER_TYPE_CAPWAP;
+ p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits].opt = CAPWAP_FRAG_1;
+ p_FmPcd->netEnvs[netEnvCurrId].aliasHdrs[specialUnits++].aliasHdr = HEADER_TYPE_USER_DEFINED_SHIM2;
+ p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr = HEADER_TYPE_USER_DEFINED_SHIM2;
+ p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].opt = 0;
+ }
+#endif /* (DPAA_VERSION >= 11) */
}
}
/* if private header (shim), check that no other headers specified */
- for (i=0; (i < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
+ for (i = 0; (i < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
&& (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr != HEADER_TYPE_NONE); i++)
{
- if(IS_PRIVATE_HEADER(p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr))
- if(p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[1].hdr != HEADER_TYPE_NONE)
+ if (IS_PRIVATE_HEADER(p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr))
+ if (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[1].hdr != HEADER_TYPE_NONE)
{
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("SHIM header may not be interchanged with other headers"));
- RELEASE_LOCK(p_FmPcd->netEnvs[netEnvCurrId].lock);
+ XX_Free(p_ModifiedNetEnvParams);
return NULL;
}
}
- for(i=0; i<p_NetEnvParams->numOfDistinctionUnits;i++)
+ for (i = 0; i < p_NetEnvParams->numOfDistinctionUnits; i++)
{
if (IS_PRIVATE_HEADER(p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr))
- switch(p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr)
+ switch (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr)
{
- case(HEADER_TYPE_USER_DEFINED_SHIM1):
+ case (HEADER_TYPE_USER_DEFINED_SHIM1):
if (shim1Selected)
{
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("SHIM header cannot be selected with UDP_IPSEC_ESP"));
- RELEASE_LOCK(p_FmPcd->netEnvs[netEnvCurrId].lock);
+ XX_Free(p_ModifiedNetEnvParams);
return NULL;
}
shim1Selected = TRUE;
p_FmPcd->netEnvs[netEnvCurrId].unitsVectors[i] = 0x00000001;
- break;
- case(HEADER_TYPE_USER_DEFINED_SHIM2):
+ break;
+ case (HEADER_TYPE_USER_DEFINED_SHIM2):
p_FmPcd->netEnvs[netEnvCurrId].unitsVectors[i] = 0x00000002;
break;
default:
@@ -1055,7 +1468,7 @@ t_Handle FM_PCD_SetNetEnvCharacteristics(t_Handle h_FmPcd, t_FmPcdNetEnvParams
{
p_FmPcd->netEnvs[netEnvCurrId].unitsVectors[i] = (uint32_t)(0x80000000 >> bitId++);
- if(IS_SPECIAL_HEADER(p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr))
+ if (IS_SPECIAL_HEADER(p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr))
p_FmPcd->netEnvs[netEnvCurrId].macsecVector = p_FmPcd->netEnvs[netEnvCurrId].unitsVectors[i];
}
}
@@ -1063,57 +1476,67 @@ t_Handle FM_PCD_SetNetEnvCharacteristics(t_Handle h_FmPcd, t_FmPcdNetEnvParams
/* define a set of hardware parser LCV's according to the defined netenv */
/* set an array of LCV's for each header in the netEnv */
- for (i=0; (i < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
+ for (i = 0; (i < FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS)
&& (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr != HEADER_TYPE_NONE); i++)
{
/* private headers have no LCV in the hard parser */
if (!IS_PRIVATE_HEADER(p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[0].hdr))
{
- for (k=0; (k < FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS)
+ for (k = 0; (k < FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS)
&& (p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr != HEADER_TYPE_NONE); k++)
{
- GET_PRS_HDR_NUM(hdrNum, p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr);
+ hdrNum = GetPrsHdrNum(p_FmPcd->netEnvs[netEnvCurrId].units[i].hdrs[k].hdr);
if ((hdrNum == ILLEGAL_HDR_NUM) || (hdrNum == NO_HDR_NUM))
{
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, NO_MSG);
- RELEASE_LOCK(p_FmPcd->netEnvs[netEnvCurrId].lock);
+ XX_Free(p_ModifiedNetEnvParams);
return NULL;
}
p_FmPcd->netEnvs[netEnvCurrId].lcvs[hdrNum] |= p_FmPcd->netEnvs[netEnvCurrId].unitsVectors[i];
}
}
}
+ XX_Free(p_ModifiedNetEnvParams);
- RELEASE_LOCK(p_FmPcd->netEnvs[netEnvCurrId].lock);
-
- return UINT_TO_PTR((uint64_t)netEnvCurrId+1);
+ p_FmPcd->netEnvs[netEnvCurrId].h_Spinlock = XX_InitSpinlock();
+ if (!p_FmPcd->netEnvs[netEnvCurrId].h_Spinlock)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Pcd NetEnv spinlock"));
+ return NULL;
+ }
+ return &p_FmPcd->netEnvs[netEnvCurrId];
}
-t_Error FM_PCD_DeleteNetEnvCharacteristics(t_Handle h_FmPcd, t_Handle h_NetEnv)
+t_Error FM_PCD_NetEnvCharacteristicsDelete(t_Handle h_NetEnv)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint8_t netEnvId = (uint8_t)(PTR_TO_UINT(h_NetEnv)-1);
+ t_FmPcdNetEnv *p_NetEnv = (t_FmPcdNetEnv*)h_NetEnv;
+ t_FmPcd *p_FmPcd = p_NetEnv->h_FmPcd;
+ uint32_t intFlags;
+ uint8_t netEnvId = p_NetEnv->netEnvId;
- SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_STATE);
SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
- if (!TRY_LOCK(p_FmPcd->h_Spinlock, &p_FmPcd->netEnvs[netEnvId].lock))
- return ERROR_CODE(E_BUSY);
/* check that no port is bound to this netEnv */
- if(p_FmPcd->netEnvs[netEnvId].owners)
+ if (p_FmPcd->netEnvs[netEnvId].owners)
{
- RELEASE_LOCK(p_FmPcd->netEnvs[netEnvId].lock);
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Trying to delete a netEnv that has ports/schemes/trees/clsPlanGrps bound to"));
+ RETURN_ERROR(MINOR, E_INVALID_STATE,
+ ("Trying to delete a netEnv that has ports/schemes/trees/clsPlanGrps bound to"));
}
- p_FmPcd->netEnvs[netEnvId].used= FALSE;
+
+ intFlags = FmPcdLock(p_FmPcd);
+
+ p_FmPcd->netEnvs[netEnvId].used = FALSE;
p_FmPcd->netEnvs[netEnvId].clsPlanGrpId = ILLEGAL_CLS_PLAN;
memset(p_FmPcd->netEnvs[netEnvId].units, 0, sizeof(t_FmPcdIntDistinctionUnit)*FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS);
memset(p_FmPcd->netEnvs[netEnvId].unitsVectors, 0, sizeof(uint32_t)*FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS);
memset(p_FmPcd->netEnvs[netEnvId].lcvs, 0, sizeof(uint32_t)*FM_PCD_PRS_NUM_OF_HDRS);
- RELEASE_LOCK(p_FmPcd->netEnvs[netEnvId].lock);
+ if (p_FmPcd->netEnvs[netEnvId].h_Spinlock)
+ XX_FreeSpinlock(p_FmPcd->netEnvs[netEnvId].h_Spinlock);
+ FmPcdUnlock(p_FmPcd, intFlags);
return E_OK;
}
@@ -1126,221 +1549,208 @@ void FM_PCD_HcTxConf(t_Handle h_FmPcd, t_DpaaFD *p_Fd)
FmHcTxConf(p_FmPcd->h_Hc, p_Fd);
}
+t_Error FM_PCD_SetAdvancedOffloadSupport(t_Handle h_FmPcd)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_FmCtrlCodeRevisionInfo revInfo;
+ t_Error err;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmPcd->enabled, E_INVALID_STATE);
+
+ if ((err = FM_GetFmanCtrlCodeRevision(p_FmPcd->h_Fm, &revInfo)) != E_OK)
+ {
+ DBG(WARNING, ("FM in guest-mode without IPC, can't validate firmware revision."));
+ revInfo.packageRev = IP_OFFLOAD_PACKAGE_NUMBER;
+ }
+ if (!IS_OFFLOAD_PACKAGE(revInfo.packageRev))
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Fman ctrl code package"));
+
+ if (!p_FmPcd->h_Hc)
+ RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("HC must be initialized in this mode"));
+
+ p_FmPcd->advancedOffloadSupport = TRUE;
+
+ return E_OK;
+}
+
uint32_t FM_PCD_GetCounter(t_Handle h_FmPcd, e_FmPcdCounters counter)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint32_t replyLength, outCounter = 0;
- t_FmPcdIpcMsg msg;
+ uint32_t outCounter = 0;
t_Error err;
- t_FmPcdIpcReply reply;
SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, 0);
SANITY_CHECK_RETURN_VALUE(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE, 0);
- if(p_FmPcd->guestId != NCSW_MASTER_ID)
- {
- memset(&msg, 0, sizeof(msg));
- memset(&reply, 0, sizeof(reply));
- msg.msgId = FM_PCD_GET_COUNTER;
- memcpy(msg.msgBody, (uint8_t *)&counter, sizeof(uint32_t));
- replyLength = sizeof(uint32_t) + sizeof(uint32_t);
- if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
- (uint8_t*)&msg,
- sizeof(msg.msgId) +sizeof(uint32_t),
- (uint8_t*)&reply,
- &replyLength,
- NULL,
- NULL)) != E_OK)
- RETURN_ERROR(MAJOR, err, NO_MSG);
- if (replyLength != sizeof(uint32_t) + sizeof(uint32_t))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
-
- memcpy((uint8_t*)&outCounter, reply.replyBody, sizeof(uint32_t));
- return outCounter;
- }
-
- switch(counter)
+ switch (counter)
{
- case(e_FM_PCD_KG_COUNTERS_TOTAL):
- if(!p_FmPcd->p_FmPcdKg)
+ case (e_FM_PCD_KG_COUNTERS_TOTAL):
+ if (!p_FmPcd->p_FmPcdKg)
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("KeyGen is not activated"));
+ return 0;
+ }
+ if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
+ !p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs &&
+ !p_FmPcd->h_IpcSession)
{
- REPORT_ERROR(MINOR, E_INVALID_STATE, ("Can't ask for this counters"));
+ REPORT_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("running in guest-mode without neither IPC nor mapped register!"));
return 0;
}
break;
- case(e_FM_PCD_PLCR_COUNTERS_YELLOW):
- case(e_FM_PCD_PLCR_COUNTERS_RED):
- case(e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_RED):
- case(e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_YELLOW):
- case(e_FM_PCD_PLCR_COUNTERS_TOTAL):
- case(e_FM_PCD_PLCR_COUNTERS_LENGTH_MISMATCH):
- if(!p_FmPcd->p_FmPcdPlcr)
+
+ case (e_FM_PCD_PLCR_COUNTERS_YELLOW):
+ case (e_FM_PCD_PLCR_COUNTERS_RED):
+ case (e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_RED):
+ case (e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_YELLOW):
+ case (e_FM_PCD_PLCR_COUNTERS_TOTAL):
+ case (e_FM_PCD_PLCR_COUNTERS_LENGTH_MISMATCH):
+ if (!p_FmPcd->p_FmPcdPlcr)
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Policer is not activated"));
+ return 0;
+ }
+ if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
+ !p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs &&
+ !p_FmPcd->h_IpcSession)
{
- REPORT_ERROR(MINOR, E_INVALID_STATE, ("Can't ask for this counters"));
+ REPORT_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("running in \"guest-mode\" without neither IPC nor mapped register!"));
return 0;
}
+
/* check that counters are enabled */
- if(!(GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_gcr) & FM_PCD_PLCR_GCR_STEN))
+ if (p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs &&
+ !(GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_gcr) & FM_PCD_PLCR_GCR_STEN))
{
REPORT_ERROR(MINOR, E_INVALID_STATE, ("Requested counter was not enabled"));
return 0;
}
+ ASSERT_COND(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs ||
+ ((p_FmPcd->guestId != NCSW_MASTER_ID) && p_FmPcd->h_IpcSession));
break;
- case(e_FM_PCD_PRS_COUNTERS_PARSE_DISPATCH):
- case(e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED):
- case(e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED):
- case(e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED):
- case(e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED):
- case(e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED_WITH_ERR):
- case(e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED_WITH_ERR):
- case(e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED_WITH_ERR):
- case(e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED_WITH_ERR):
- case(e_FM_PCD_PRS_COUNTERS_SOFT_PRS_CYCLES):
- case(e_FM_PCD_PRS_COUNTERS_SOFT_PRS_STALL_CYCLES):
- case(e_FM_PCD_PRS_COUNTERS_HARD_PRS_CYCLE_INCL_STALL_CYCLES):
- case(e_FM_PCD_PRS_COUNTERS_MURAM_READ_CYCLES):
- case(e_FM_PCD_PRS_COUNTERS_MURAM_READ_STALL_CYCLES):
- case(e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_CYCLES):
- case(e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_STALL_CYCLES):
- case(e_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES):
- if(!p_FmPcd->p_FmPcdPrs)
+
+ case (e_FM_PCD_PRS_COUNTERS_PARSE_DISPATCH):
+ case (e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED):
+ case (e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED):
+ case (e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED):
+ case (e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED):
+ case (e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED_WITH_ERR):
+ case (e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED_WITH_ERR):
+ case (e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED_WITH_ERR):
+ case (e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED_WITH_ERR):
+ case (e_FM_PCD_PRS_COUNTERS_SOFT_PRS_CYCLES):
+ case (e_FM_PCD_PRS_COUNTERS_SOFT_PRS_STALL_CYCLES):
+ case (e_FM_PCD_PRS_COUNTERS_HARD_PRS_CYCLE_INCL_STALL_CYCLES):
+ case (e_FM_PCD_PRS_COUNTERS_MURAM_READ_CYCLES):
+ case (e_FM_PCD_PRS_COUNTERS_MURAM_READ_STALL_CYCLES):
+ case (e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_CYCLES):
+ case (e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_STALL_CYCLES):
+ case (e_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES):
+ if (!p_FmPcd->p_FmPcdPrs)
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Parser is not activated"));
+ return 0;
+ }
+ if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
+ !p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs &&
+ !p_FmPcd->h_IpcSession)
{
- REPORT_ERROR(MINOR, E_INVALID_STATE, ("Can't ask for this counters"));
+ REPORT_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("running in guest-mode without neither IPC nor mapped register!"));
return 0;
}
break;
default:
- REPORT_ERROR(MINOR, E_INVALID_STATE, ("Unsupported type of counter"));
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Unsupported type of counter"));
return 0;
}
- switch(counter)
+
+ if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
+ p_FmPcd->h_IpcSession)
{
- case(e_FM_PCD_PRS_COUNTERS_PARSE_DISPATCH):
- return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->pds);
- case(e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED):
- return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->l2rrs);
- case(e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED):
- return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->l3rrs);
- case(e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED):
- return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->l4rrs);
- case(e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED):
- return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->srrs);
- case(e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED_WITH_ERR):
- return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->l2rres);
- case(e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED_WITH_ERR):
- return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->l3rres);
- case(e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED_WITH_ERR):
- return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->l4rres);
- case(e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED_WITH_ERR):
- return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->srres);
- case(e_FM_PCD_PRS_COUNTERS_SOFT_PRS_CYCLES):
- return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->spcs);
- case(e_FM_PCD_PRS_COUNTERS_SOFT_PRS_STALL_CYCLES):
- return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->spscs);
- case(e_FM_PCD_PRS_COUNTERS_HARD_PRS_CYCLE_INCL_STALL_CYCLES):
- return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->hxscs);
- case(e_FM_PCD_PRS_COUNTERS_MURAM_READ_CYCLES):
- return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->mrcs);
- case(e_FM_PCD_PRS_COUNTERS_MURAM_READ_STALL_CYCLES):
- return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->mrscs);
- case(e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_CYCLES):
- return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->mwcs);
- case(e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_STALL_CYCLES):
- return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->mwscs);
- case(e_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES):
- return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fcscs);
- case(e_FM_PCD_KG_COUNTERS_TOTAL):
- return GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->kgtpc);
-
- /*Policer statictics*/
- case(e_FM_PCD_PLCR_COUNTERS_YELLOW):
+ t_FmPcdIpcMsg msg;
+ t_FmPcdIpcReply reply;
+ uint32_t replyLength;
+
+ memset(&msg, 0, sizeof(msg));
+ memset(&reply, 0, sizeof(reply));
+ msg.msgId = FM_PCD_GET_COUNTER;
+ memcpy(msg.msgBody, (uint8_t *)&counter, sizeof(uint32_t));
+ replyLength = sizeof(uint32_t) + sizeof(uint32_t);
+ if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
+ (uint8_t*)&msg,
+ sizeof(msg.msgId) +sizeof(uint32_t),
+ (uint8_t*)&reply,
+ &replyLength,
+ NULL,
+ NULL)) != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ if (replyLength != sizeof(uint32_t) + sizeof(uint32_t))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
+
+ memcpy((uint8_t*)&outCounter, reply.replyBody, sizeof(uint32_t));
+ return outCounter;
+ }
+
+ switch (counter)
+ {
+ /* Parser statistics */
+ case (e_FM_PCD_PRS_COUNTERS_PARSE_DISPATCH):
+ return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_pds);
+ case (e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED):
+ return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l2rrs);
+ case (e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED):
+ return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l3rrs);
+ case (e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED):
+ return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l4rrs);
+ case (e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED):
+ return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_srrs);
+ case (e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED_WITH_ERR):
+ return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l2rres);
+ case (e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED_WITH_ERR):
+ return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l3rres);
+ case (e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED_WITH_ERR):
+ return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l4rres);
+ case (e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED_WITH_ERR):
+ return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_srres);
+ case (e_FM_PCD_PRS_COUNTERS_SOFT_PRS_CYCLES):
+ return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_spcs);
+ case (e_FM_PCD_PRS_COUNTERS_SOFT_PRS_STALL_CYCLES):
+ return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_spscs);
+ case (e_FM_PCD_PRS_COUNTERS_HARD_PRS_CYCLE_INCL_STALL_CYCLES):
+ return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_hxscs);
+ case (e_FM_PCD_PRS_COUNTERS_MURAM_READ_CYCLES):
+ return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_mrcs);
+ case (e_FM_PCD_PRS_COUNTERS_MURAM_READ_STALL_CYCLES):
+ return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_mrscs);
+ case (e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_CYCLES):
+ return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_mwcs);
+ case (e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_STALL_CYCLES):
+ return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_mwscs);
+ case (e_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES):
+ return GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_fcscs);
+ case (e_FM_PCD_KG_COUNTERS_TOTAL):
+ return GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->fmkg_tpc);
+
+ /* Policer statistics */
+ case (e_FM_PCD_PLCR_COUNTERS_YELLOW):
return GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ypcnt);
- case(e_FM_PCD_PLCR_COUNTERS_RED):
+ case (e_FM_PCD_PLCR_COUNTERS_RED):
return GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_rpcnt);
- case(e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_RED):
+ case (e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_RED):
return GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_rrpcnt);
- case(e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_YELLOW):
+ case (e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_YELLOW):
return GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_rypcnt);
- case(e_FM_PCD_PLCR_COUNTERS_TOTAL):
+ case (e_FM_PCD_PLCR_COUNTERS_TOTAL):
return GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_tpcnt);
- case(e_FM_PCD_PLCR_COUNTERS_LENGTH_MISMATCH):
+ case (e_FM_PCD_PLCR_COUNTERS_LENGTH_MISMATCH):
return GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_flmcnt);
-
- default:
- REPORT_ERROR(MINOR, E_INVALID_STATE, ("Unsupported type of counter"));
- return 0;
- }
-}
-
-#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
-t_Error FM_PCD_DumpRegs(t_Handle h_FmPcd)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- t_FmPcdIpcMsg msg;
-
- DECLARE_DUMP;
-
- SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
-
- if(p_FmPcd->guestId != NCSW_MASTER_ID)
- {
- memset(&msg, 0, sizeof(msg));
- msg.msgId = FM_PCD_DUMP_REGS;
- return XX_IpcSendMessage(p_FmPcd->h_IpcSession,
- (uint8_t*)&msg,
- sizeof(msg.msgId),
- NULL,
- NULL,
- NULL,
- NULL);
}
- if (p_FmPcd->p_FmPcdKg)
- return FM_PCD_KgDumpRegs(h_FmPcd);
- if (p_FmPcd->p_FmPcdPlcr)
- return FM_PCD_PlcrDumpRegs(h_FmPcd);
- if (p_FmPcd->p_FmPcdPrs)
- return FM_PCD_PrsDumpRegs(h_FmPcd);
- return E_OK;
-}
-
-t_Error FM_PCD_HcDumpRegs(t_Handle h_FmPcd)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
-
- DECLARE_DUMP;
-
- SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_STATE);
-
- return FmHcDumpRegs(p_FmPcd->h_Hc);
-}
-
-#endif /* (defined(DEBUG_ERRORS) && ... */
-
-t_Error FM_PCD_ConfigException(t_Handle h_FmPcd, e_FmPcdExceptions exception, bool enable)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint32_t bitMask = 0;
-
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
-
- if(p_FmPcd->guestId != NCSW_MASTER_ID)
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_ConfigException - guest mode!"));
-
- GET_FM_PCD_EXCEPTION_FLAG(bitMask, exception);
- if(bitMask)
- {
- if (enable)
- p_FmPcd->exceptions |= bitMask;
- else
- p_FmPcd->exceptions &= ~bitMask;
- }
- else
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
-
- return E_OK;
+ return 0;
}
t_Error FM_PCD_SetException(t_Handle h_FmPcd, e_FmPcdExceptions exception, bool enable)
@@ -1351,126 +1761,119 @@ t_Error FM_PCD_SetException(t_Handle h_FmPcd, e_FmPcdExceptions exception, bool
SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
- if(p_FmPcd->guestId != NCSW_MASTER_ID)
+ if (p_FmPcd->guestId != NCSW_MASTER_ID)
RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_SetException - guest mode!"));
GET_FM_PCD_EXCEPTION_FLAG(bitMask, exception);
- if(bitMask)
+ if (bitMask)
{
if (enable)
p_FmPcd->exceptions |= bitMask;
else
p_FmPcd->exceptions &= ~bitMask;
- switch(exception)
+ switch (exception)
{
- case(e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC):
- case(e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW):
- if(!p_FmPcd->p_FmPcdKg)
+ case (e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC):
+ case (e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW):
+ if (!p_FmPcd->p_FmPcdKg)
RETURN_ERROR(MINOR, E_INVALID_STATE, ("Can't ask for this interrupt - keygen is not working"));
break;
- case(e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC):
- case(e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR):
- case(e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE):
- case(e_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE):
- if(!p_FmPcd->p_FmPcdPlcr)
+ case (e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC):
+ case (e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR):
+ case (e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE):
+ case (e_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE):
+ if (!p_FmPcd->p_FmPcdPlcr)
RETURN_ERROR(MINOR, E_INVALID_STATE, ("Can't ask for this interrupt - policer is not working"));
- break;
- case(e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC):
- case(e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC):
- if(!p_FmPcd->p_FmPcdPrs)
+ break;
+ case (e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC):
+ case (e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC):
+ if (!p_FmPcd->p_FmPcdPrs)
RETURN_ERROR(MINOR, E_INVALID_STATE, ("Can't ask for this interrupt - parser is not working"));
- break;
- default:
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Unsupported exception"));
-
+ break;
}
- switch(exception)
+ switch (exception)
{
- case(e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC):
- tmpReg = GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->kgeeer);
- if(enable)
- tmpReg |= FM_PCD_KG_DOUBLE_ECC;
+ case (e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC):
+ tmpReg = GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->fmkg_eeer);
+ if (enable)
+ tmpReg |= FM_EX_KG_DOUBLE_ECC;
else
- tmpReg &= ~FM_PCD_KG_DOUBLE_ECC;
- WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->kgeeer, tmpReg);
+ tmpReg &= ~FM_EX_KG_DOUBLE_ECC;
+ WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->fmkg_eeer, tmpReg);
break;
- case(e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW):
- tmpReg = GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->kgeeer);
- if(enable)
- tmpReg |= FM_PCD_KG_KEYSIZE_OVERFLOW;
+ case (e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW):
+ tmpReg = GET_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->fmkg_eeer);
+ if (enable)
+ tmpReg |= FM_EX_KG_KEYSIZE_OVERFLOW;
else
- tmpReg &= ~FM_PCD_KG_KEYSIZE_OVERFLOW;
- WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->kgeeer, tmpReg);
+ tmpReg &= ~FM_EX_KG_KEYSIZE_OVERFLOW;
+ WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->fmkg_eeer, tmpReg);
break;
- case(e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC):
- tmpReg = GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->perer);
- if(enable)
+ case (e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC):
+ tmpReg = GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_perer);
+ if (enable)
tmpReg |= FM_PCD_PRS_DOUBLE_ECC;
else
tmpReg &= ~FM_PCD_PRS_DOUBLE_ECC;
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->perer, tmpReg);
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_perer, tmpReg);
break;
- case(e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC):
- tmpReg = GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->pever);
- if(enable)
+ case (e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC):
+ tmpReg = GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_pever);
+ if (enable)
tmpReg |= FM_PCD_PRS_SINGLE_ECC;
else
tmpReg &= ~FM_PCD_PRS_SINGLE_ECC;
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->pever, tmpReg);
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_pever, tmpReg);
break;
- case(e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC):
+ case (e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC):
tmpReg = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eier);
- if(enable)
+ if (enable)
tmpReg |= FM_PCD_PLCR_DOUBLE_ECC;
else
tmpReg &= ~FM_PCD_PLCR_DOUBLE_ECC;
WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eier, tmpReg);
break;
- case(e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR):
+ case (e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR):
tmpReg = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eier);
- if(enable)
+ if (enable)
tmpReg |= FM_PCD_PLCR_INIT_ENTRY_ERROR;
else
tmpReg &= ~FM_PCD_PLCR_INIT_ENTRY_ERROR;
WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eier, tmpReg);
break;
- case(e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE):
+ case (e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE):
tmpReg = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ier);
- if(enable)
+ if (enable)
tmpReg |= FM_PCD_PLCR_PRAM_SELF_INIT_COMPLETE;
else
tmpReg &= ~FM_PCD_PLCR_PRAM_SELF_INIT_COMPLETE;
WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ier, tmpReg);
break;
- case(e_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE):
+ case (e_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE):
tmpReg = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ier);
- if(enable)
+ if (enable)
tmpReg |= FM_PCD_PLCR_ATOMIC_ACTION_COMPLETE;
else
tmpReg &= ~FM_PCD_PLCR_ATOMIC_ACTION_COMPLETE;
WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ier, tmpReg);
break;
- default:
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Unsupported exception"));
}
/* for ECC exceptions driver automatically enables ECC mechanism, if disabled.
Driver may disable them automatically, depending on driver's status */
- if(enable && ( (exception == e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC) |
+ if (enable && ((exception == e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC) |
(exception == e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC) |
(exception == e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC) |
(exception == e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC)))
FmEnableRamsEcc(p_FmPcd->h_Fm);
- if(!enable && ( (exception == e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC) |
+ if (!enable && ((exception == e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC) |
(exception == e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC) |
(exception == e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC) |
(exception == e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC)))
FmDisableRamsEcc(p_FmPcd->h_Fm);
}
- else
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
return E_OK;
}
@@ -1482,53 +1885,50 @@ t_Error FM_PCD_ForceIntr (t_Handle h_FmPcd, e_FmPcdExceptions exception)
SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
- if(p_FmPcd->guestId != NCSW_MASTER_ID)
+ if (p_FmPcd->guestId != NCSW_MASTER_ID)
RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_ForceIntr - guest mode!"));
- switch(exception)
+ switch (exception)
{
- case(e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC):
- case(e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW):
- if(!p_FmPcd->p_FmPcdKg)
+ case (e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC):
+ case (e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW):
+ if (!p_FmPcd->p_FmPcdKg)
RETURN_ERROR(MINOR, E_INVALID_STATE, ("Can't ask for this interrupt - keygen is not working"));
break;
- case(e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC):
- case(e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR):
- case(e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE):
- case(e_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE):
- if(!p_FmPcd->p_FmPcdPlcr)
+ case (e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC):
+ case (e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR):
+ case (e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE):
+ case (e_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE):
+ if (!p_FmPcd->p_FmPcdPlcr)
RETURN_ERROR(MINOR, E_INVALID_STATE, ("Can't ask for this interrupt - policer is not working"));
break;
- case(e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC):
- case(e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC):
- if(!p_FmPcd->p_FmPcdPrs)
+ case (e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC):
+ case (e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC):
+ if (!p_FmPcd->p_FmPcdPrs)
RETURN_ERROR(MINOR, E_INVALID_STATE, ("Can't ask for this interrupt -parsrer is not working"));
break;
default:
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Invalid interrupt requested"));
-
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid interrupt requested"));
}
- switch(exception)
+ switch (exception)
{
case e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC:
if (!(p_FmPcd->exceptions & FM_PCD_EX_PRS_DOUBLE_ECC))
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->perfr, FM_PCD_PRS_DOUBLE_ECC);
break;
case e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC:
if (!(p_FmPcd->exceptions & FM_PCD_EX_PRS_SINGLE_ECC))
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->pevfr, FM_PCD_PRS_SINGLE_ECC);
break;
case e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC:
- if (!(p_FmPcd->exceptions & FM_PCD_EX_KG_DOUBLE_ECC))
+ if (!(p_FmPcd->exceptions & FM_EX_KG_DOUBLE_ECC))
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
- WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->kgfeer, FM_PCD_KG_DOUBLE_ECC);
+ WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->fmkg_feer, FM_EX_KG_DOUBLE_ECC);
break;
case e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW:
- if (!(p_FmPcd->exceptions & FM_PCD_EX_KG_KEYSIZE_OVERFLOW))
+ if (!(p_FmPcd->exceptions & FM_EX_KG_KEYSIZE_OVERFLOW))
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
- WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->kgfeer, FM_PCD_KG_KEYSIZE_OVERFLOW);
+ WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->fmkg_feer, FM_EX_KG_KEYSIZE_OVERFLOW);
break;
case e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC:
if (!(p_FmPcd->exceptions & FM_PCD_EX_PLCR_DOUBLE_ECC))
@@ -1550,8 +1950,6 @@ t_Error FM_PCD_ForceIntr (t_Handle h_FmPcd, e_FmPcdExceptions exception)
RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ifr, FM_PCD_PLCR_ATOMIC_ACTION_COMPLETE);
break;
- default:
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception may not be forced"));
}
return E_OK;
@@ -1565,129 +1963,133 @@ t_Error FM_PCD_ModifyCounter(t_Handle h_FmPcd, e_FmPcdCounters counter, uint32_t
SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
- if(p_FmPcd->guestId != NCSW_MASTER_ID)
+ if (p_FmPcd->guestId != NCSW_MASTER_ID)
RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_ModifyCounter - guest mode!"));
- switch(counter)
+ switch (counter)
{
- case(e_FM_PCD_KG_COUNTERS_TOTAL):
- if(!p_FmPcd->p_FmPcdKg)
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Can't ask for this counters - keygen is not working"));
+ case (e_FM_PCD_KG_COUNTERS_TOTAL):
+ if (!p_FmPcd->p_FmPcdKg)
+ RETURN_ERROR(MINOR, E_INVALID_STATE, ("Invalid counters - KeyGen is not working"));
break;
- case(e_FM_PCD_PLCR_COUNTERS_YELLOW):
- case(e_FM_PCD_PLCR_COUNTERS_RED):
- case(e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_RED):
- case(e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_YELLOW):
- case(e_FM_PCD_PLCR_COUNTERS_TOTAL):
- case(e_FM_PCD_PLCR_COUNTERS_LENGTH_MISMATCH):
- if(!p_FmPcd->p_FmPcdPlcr)
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Can't ask for this counters - Policer is not working"));
- if(!(GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_gcr) & FM_PCD_PLCR_GCR_STEN))
+ case (e_FM_PCD_PLCR_COUNTERS_YELLOW):
+ case (e_FM_PCD_PLCR_COUNTERS_RED):
+ case (e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_RED):
+ case (e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_YELLOW):
+ case (e_FM_PCD_PLCR_COUNTERS_TOTAL):
+ case (e_FM_PCD_PLCR_COUNTERS_LENGTH_MISMATCH):
+ if (!p_FmPcd->p_FmPcdPlcr)
+ RETURN_ERROR(MINOR, E_INVALID_STATE, ("Invalid counters - Policer is not working"));
+ if (!(GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_gcr) & FM_PCD_PLCR_GCR_STEN))
RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter was not enabled"));
break;
- case(e_FM_PCD_PRS_COUNTERS_PARSE_DISPATCH):
- case(e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED):
- case(e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED):
- case(e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED):
- case(e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED):
- case(e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED_WITH_ERR):
- case(e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED_WITH_ERR):
- case(e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED_WITH_ERR):
- case(e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED_WITH_ERR):
- case(e_FM_PCD_PRS_COUNTERS_SOFT_PRS_CYCLES):
- case(e_FM_PCD_PRS_COUNTERS_SOFT_PRS_STALL_CYCLES):
- case(e_FM_PCD_PRS_COUNTERS_HARD_PRS_CYCLE_INCL_STALL_CYCLES):
- case(e_FM_PCD_PRS_COUNTERS_MURAM_READ_CYCLES):
- case(e_FM_PCD_PRS_COUNTERS_MURAM_READ_STALL_CYCLES):
- case(e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_CYCLES):
- case(e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_STALL_CYCLES):
- case(e_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES):
- if(!p_FmPcd->p_FmPcdPrs)
+ case (e_FM_PCD_PRS_COUNTERS_PARSE_DISPATCH):
+ case (e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED):
+ case (e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED):
+ case (e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED):
+ case (e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED):
+ case (e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED_WITH_ERR):
+ case (e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED_WITH_ERR):
+ case (e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED_WITH_ERR):
+ case (e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED_WITH_ERR):
+ case (e_FM_PCD_PRS_COUNTERS_SOFT_PRS_CYCLES):
+ case (e_FM_PCD_PRS_COUNTERS_SOFT_PRS_STALL_CYCLES):
+ case (e_FM_PCD_PRS_COUNTERS_HARD_PRS_CYCLE_INCL_STALL_CYCLES):
+ case (e_FM_PCD_PRS_COUNTERS_MURAM_READ_CYCLES):
+ case (e_FM_PCD_PRS_COUNTERS_MURAM_READ_STALL_CYCLES):
+ case (e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_CYCLES):
+ case (e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_STALL_CYCLES):
+ case (e_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES):
+ if (!p_FmPcd->p_FmPcdPrs)
RETURN_ERROR(MINOR, E_INVALID_STATE, ("Unsupported type of counter"));
break;
default:
RETURN_ERROR(MINOR, E_INVALID_STATE, ("Unsupported type of counter"));
}
- switch(counter)
+ switch (counter)
{
- case(e_FM_PCD_PRS_COUNTERS_PARSE_DISPATCH):
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->pds, value);
+ case (e_FM_PCD_PRS_COUNTERS_PARSE_DISPATCH):
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_pds, value);
break;
- case(e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED):
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->l2rrs, value);
+ case (e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED):
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l2rrs, value);
break;
- case(e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED):
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->l3rrs, value);
+ case (e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED):
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l3rrs, value);
break;
- case(e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED):
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->l4rrs, value);
+ case (e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED):
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l4rrs, value);
break;
- case(e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED):
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->srrs, value);
+ case (e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED):
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_srrs, value);
break;
- case(e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED_WITH_ERR):
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->l2rres, value);
+ case (e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED_WITH_ERR):
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l2rres, value);
break;
- case(e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED_WITH_ERR):
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->l3rres, value);
+ case (e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED_WITH_ERR):
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l3rres, value);
break;
- case(e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED_WITH_ERR):
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->l4rres, value);
+ case (e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED_WITH_ERR):
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_l4rres, value);
break;
- case(e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED_WITH_ERR):
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->srres, value);
+ case (e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED_WITH_ERR):
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_srres, value);
break;
- case(e_FM_PCD_PRS_COUNTERS_SOFT_PRS_CYCLES):
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->spcs, value);
+ case (e_FM_PCD_PRS_COUNTERS_SOFT_PRS_CYCLES):
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_spcs, value);
break;
- case(e_FM_PCD_PRS_COUNTERS_SOFT_PRS_STALL_CYCLES):
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->spscs, value);
+ case (e_FM_PCD_PRS_COUNTERS_SOFT_PRS_STALL_CYCLES):
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_spscs, value);
break;
- case(e_FM_PCD_PRS_COUNTERS_HARD_PRS_CYCLE_INCL_STALL_CYCLES):
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->hxscs, value);
+ case (e_FM_PCD_PRS_COUNTERS_HARD_PRS_CYCLE_INCL_STALL_CYCLES):
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_hxscs, value);
break;
- case(e_FM_PCD_PRS_COUNTERS_MURAM_READ_CYCLES):
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->mrcs, value);
+ case (e_FM_PCD_PRS_COUNTERS_MURAM_READ_CYCLES):
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_mrcs, value);
break;
- case(e_FM_PCD_PRS_COUNTERS_MURAM_READ_STALL_CYCLES):
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->mrscs, value);
+ case (e_FM_PCD_PRS_COUNTERS_MURAM_READ_STALL_CYCLES):
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_mrscs, value);
break;
- case(e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_CYCLES):
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->mwcs, value);
+ case (e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_CYCLES):
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_mwcs, value);
break;
- case(e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_STALL_CYCLES):
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->mwscs, value);
+ case (e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_STALL_CYCLES):
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_mwscs, value);
break;
- case(e_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES):
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fcscs, value);
+ case (e_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES):
+ WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->fmpr_fcscs, value);
break;
- case(e_FM_PCD_KG_COUNTERS_TOTAL):
- WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->kgtpc,value);
+ case (e_FM_PCD_KG_COUNTERS_TOTAL):
+ WRITE_UINT32(p_FmPcd->p_FmPcdKg->p_FmPcdKgRegs->fmkg_tpc,value);
break;
/*Policer counters*/
- case(e_FM_PCD_PLCR_COUNTERS_YELLOW):
+ case (e_FM_PCD_PLCR_COUNTERS_YELLOW):
WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ypcnt, value);
break;
- case(e_FM_PCD_PLCR_COUNTERS_RED):
+ case (e_FM_PCD_PLCR_COUNTERS_RED):
WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_rpcnt, value);
break;
- case(e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_RED):
+ case (e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_RED):
WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_rrpcnt, value);
break;
- case(e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_YELLOW):
+ case (e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_YELLOW):
WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_rypcnt, value);
break;
- case(e_FM_PCD_PLCR_COUNTERS_TOTAL):
+ case (e_FM_PCD_PLCR_COUNTERS_TOTAL):
WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_tpcnt, value);
break;
- case(e_FM_PCD_PLCR_COUNTERS_LENGTH_MISMATCH):
+ case (e_FM_PCD_PLCR_COUNTERS_LENGTH_MISMATCH):
WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_flmcnt, value);
break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Unsupported type of counter"));
}
-return E_OK;
+ return E_OK;
+}
+
+t_Handle FM_PCD_GetHcPort(t_Handle h_FmPcd)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ return FmHcGetPort(p_FmPcd->h_Hc);
}
diff --git a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_pcd.h b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_pcd.h
index 55ae47ac3f88..27ec9c5bf672 100644
--- a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_pcd.h
+++ b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_pcd.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm_pcd.h
@@ -42,15 +43,25 @@
#include "error_ext.h"
#include "list_ext.h"
#include "fm_pcd_ext.h"
-
+#include "fm_common.h"
+#include "fsl_fman_prs.h"
+#include "fsl_fman_kg.h"
#define __ERR_MODULE__ MODULE_FM_PCD
-/**************************************************************************//**
- @Group FM_PCD_Runtime_grp FM PCD Runtime Unit
- @{
-*//***************************************************************************/
+/****************************/
+/* Defaults */
+/****************************/
+#define DEFAULT_plcrAutoRefresh FALSE
+#define DEFAULT_fmPcdKgErrorExceptions (FM_EX_KG_DOUBLE_ECC | FM_EX_KG_KEYSIZE_OVERFLOW)
+#define DEFAULT_fmPcdPlcrErrorExceptions (FM_PCD_EX_PLCR_DOUBLE_ECC | FM_PCD_EX_PLCR_INIT_ENTRY_ERROR)
+#define DEFAULT_fmPcdPlcrExceptions 0
+#define DEFAULT_fmPcdPrsErrorExceptions (FM_PCD_EX_PRS_DOUBLE_ECC)
+
+#define DEFAULT_fmPcdPrsExceptions FM_PCD_EX_PRS_SINGLE_ECC
+#define DEFAULT_numOfUsedProfilesPerWindow 16
+#define DEFAULT_numOfSharedPlcrProfiles 4
/****************************/
/* Network defines */
@@ -67,28 +78,26 @@
/****************************/
#define ILLEGAL_CLS_PLAN 0xff
#define ILLEGAL_NETENV 0xff
+
+#define FM_PCD_MAX_NUM_OF_ALIAS_HDRS 3
+
/****************************/
/* Error defines */
/****************************/
-#define FM_PCD_EX_KG_DOUBLE_ECC 0x80000000
-#define FM_PCD_EX_KG_KEYSIZE_OVERFLOW 0x40000000
#define FM_PCD_EX_PLCR_DOUBLE_ECC 0x20000000
#define FM_PCD_EX_PLCR_INIT_ENTRY_ERROR 0x10000000
#define FM_PCD_EX_PLCR_PRAM_SELF_INIT_COMPLETE 0x08000000
#define FM_PCD_EX_PLCR_ATOMIC_ACTION_COMPLETE 0x04000000
-#define FM_PCD_EX_PRS_DOUBLE_ECC 0x02000000
-#define FM_PCD_EX_PRS_SINGLE_ECC 0x01000000
-
#define GET_FM_PCD_EXCEPTION_FLAG(bitMask, exception) \
-switch(exception){ \
+switch (exception){ \
case e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC: \
- bitMask = FM_PCD_EX_KG_DOUBLE_ECC; break; \
+ bitMask = FM_EX_KG_DOUBLE_ECC; break; \
case e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC: \
bitMask = FM_PCD_EX_PLCR_DOUBLE_ECC; break; \
case e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW: \
- bitMask = FM_PCD_EX_KG_KEYSIZE_OVERFLOW; break; \
+ bitMask = FM_EX_KG_KEYSIZE_OVERFLOW; break; \
case e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR: \
bitMask = FM_PCD_EX_PLCR_INIT_ENTRY_ERROR; break; \
case e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE: \
@@ -102,289 +111,23 @@ switch(exception){ \
default: bitMask = 0;break;}
/***********************************************************************/
-/* SW parser L4 shells patch */
-/***********************************************************************/
-#ifdef FM_PRS_L4_SHELL_ERRATA_FMANb
-#define SW_PRS_L4_PATCH \
-{ 0x31,0x92,0x02,0x1f,0x00,0x32,0x00,0x78, \
- 0x00,0x34,0x32,0xf0,0x00,0x50,0x00,0x0c, \
- 0x28,0x5e,0x83,0x8e,0x29,0x32,0xaf,0x8e, \
- 0x31,0xb2,0x9f,0xff,0x00,0x06,0xaf,0xbf, \
- 0x00,0x06,0x29,0x36,0x00,0x01,0x1b,0xff, \
- 0x32,0xf0,0x00,0x50,0x00,0x08,0x28,0x5e, \
- 0x08,0x99,0x00,0x00,0x9f,0x8e,0x31,0xb2, \
- 0x9f,0xff,0x00,0x06,0x29,0x36,0x00,0x01, \
- 0x1b,0xff,0x32,0xf0,0x00,0x50,0x00,0x04, \
- 0x28,0x5e,0x8f,0x9e,0x29,0x32,0x31,0xb2, \
- 0x8f,0xbf,0x00,0x06,0x29,0x36,0x00,0x01, \
- 0x1b,0xff,0x32,0xf0,0x00,0x50,0x00,0x04, \
- 0x28,0x5e,0x8f,0x9e,0x29,0x32,0x31,0xb2, \
- 0x8f,0xbf,0x00,0x06,0x29,0x36,0x00,0x01, \
- 0x1b,0xff,0x00,0x00,0x00,0x00,0x00,0x00};
-
-#define SW_PRS_L4_PATCH_SIZE 120
-#endif /* FM_PRS_L4_SHELL_ERRATA_FMANb */
-
-/****************************/
-/* Parser defines */
-/****************************/
-/* masks */
-#define PRS_ERR_CAP 0x80000000
-#define PRS_ERR_TYPE_DOUBLE 0x40000000
-#define PRS_ERR_SINGLE_ECC_CNT_MASK 0x00FF0000
-#define PRS_ERR_ADDR_MASK 0x000001FF
-#define FM_PCD_PRS_RPIMAC_EN 0x00000001
-#define FM_PCD_PRS_SINGLE_ECC 0x00004000
-#define FM_PCD_PRS_PORT_IDLE_STS 0xffff0000
-#define FM_PCD_PRS_DOUBLE_ECC 0x00004000
-#define FM_PCD_PRS_PPSC_ALL_PORTS 0xffff0000
-
-/* others */
-#define PRS_MAX_CYCLE_LIMIT 8191
-#define PRS_SW_DATA 0x00000800
-#define PRS_REGS_OFFSET 0x00000840
-
-#define GET_FM_PCD_PRS_PORT_ID(prsPortId,hardwarePortId) \
- prsPortId = (uint8_t)(hardwarePortId & 0x0f)
-
-#define GET_FM_PCD_INDEX_FLAG(bitMask, prsPortId) \
- bitMask = 0x80000000>>prsPortId
-
-/***********************************************************************/
-/* Keygen defines */
-/***********************************************************************/
-/* Masks */
-#define FM_PCD_KG_KGGCR_EN 0x80000000
-#define KG_SCH_GEN_VALID 0x80000000
-#define KG_SCH_GEN_EXTRACT_TYPE 0x00008000
-#define KG_ERR_CAP 0x80000000
-#define KG_ERR_TYPE_DOUBLE 0x40000000
-#define KG_ERR_ADDR_MASK 0x00000FFF
-#define FM_PCD_KG_DOUBLE_ECC 0x80000000
-#define FM_PCD_KG_KEYSIZE_OVERFLOW 0x40000000
-#define KG_SCH_MODE_EN 0x80000000
-
-/* shifts */
-#define FM_PCD_KG_PE_CPP_MASK_SHIFT 16
-#define FM_PCD_KG_KGAR_WSEL_SHIFT 8
-
-/* others */
-#define KG_DOUBLE_MEANING_REGS_OFFSET 0x100
-#define NO_VALIDATION 0x70
-#define KG_ACTION_REG_TO 1024
-#define KG_MAX_PROFILE 255
-#define SCHEME_ALWAYS_DIRECT 0xFFFFFFFF
-
-typedef struct {
- bool known;
- uint8_t id;
-} t_FmPcdKgSchemesExtractsEntry;
-
-typedef struct {
- t_FmPcdKgSchemesExtractsEntry extractsArray[FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY];
-} t_FmPcdKgSchemesExtracts;
-
-/***********************************************************************/
/* Policer defines */
/***********************************************************************/
-
-/* masks */
-#define FM_PCD_PLCR_PEMODE_PI 0x80000000
-#define FM_PCD_PLCR_PEMODE_CBLND 0x40000000
-#define FM_PCD_PLCR_PEMODE_ALG_MASK 0x30000000
-#define FM_PCD_PLCR_PEMODE_ALG_RFC2698 0x10000000
-#define FM_PCD_PLCR_PEMODE_ALG_RFC4115 0x20000000
-#define FM_PCD_PLCR_PEMODE_DEFC_MASK 0x0C000000
-#define FM_PCD_PLCR_PEMODE_DEFC_Y 0x04000000
-#define FM_PCD_PLCR_PEMODE_DEFC_R 0x08000000
-#define FM_PCD_PLCR_PEMODE_DEFC_OVERRIDE 0x0C000000
-#define FM_PCD_PLCR_PEMODE_OVCLR_MASK 0x03000000
-#define FM_PCD_PLCR_PEMODE_OVCLR_Y 0x01000000
-#define FM_PCD_PLCR_PEMODE_OVCLR_R 0x02000000
-#define FM_PCD_PLCR_PEMODE_OVCLR_G_NC 0x03000000
-#define FM_PCD_PLCR_PEMODE_PKT 0x00800000
-#define FM_PCD_PLCR_PEMODE_FPP_MASK 0x001F0000
-#define FM_PCD_PLCR_PEMODE_FPP_SHIFT 16
-#define FM_PCD_PLCR_PEMODE_FLS_MASK 0x0000F000
-#define FM_PCD_PLCR_PEMODE_FLS_L2 0x00003000
-#define FM_PCD_PLCR_PEMODE_FLS_L3 0x0000B000
-#define FM_PCD_PLCR_PEMODE_FLS_L4 0x0000E000
-#define FM_PCD_PLCR_PEMODE_FLS_FULL 0x0000F000
-#define FM_PCD_PLCR_PEMODE_RBFLS 0x00000800
-#define FM_PCD_PLCR_PEMODE_TRA 0x00000004
-#define FM_PCD_PLCR_PEMODE_TRB 0x00000002
-#define FM_PCD_PLCR_PEMODE_TRC 0x00000001
+#define FM_PCD_PLCR_GCR_STEN 0x40000000
#define FM_PCD_PLCR_DOUBLE_ECC 0x80000000
#define FM_PCD_PLCR_INIT_ENTRY_ERROR 0x40000000
#define FM_PCD_PLCR_PRAM_SELF_INIT_COMPLETE 0x80000000
#define FM_PCD_PLCR_ATOMIC_ACTION_COMPLETE 0x40000000
-#define FM_PCD_PLCR_NIA_VALID 0x80000000
-
-#define FM_PCD_PLCR_GCR_EN 0x80000000
-#define FM_PCD_PLCR_GCR_STEN 0x40000000
-#define FM_PCD_PLCR_GCR_DAR 0x20000000
-#define FM_PCD_PLCR_GCR_DEFNIA 0x00FFFFFF
-#define FM_PCD_PLCR_NIA_ABS 0x00000100
-
-#define FM_PCD_PLCR_GSR_BSY 0x80000000
-#define FM_PCD_PLCR_GSR_DQS 0x60000000
-#define FM_PCD_PLCR_GSR_RPB 0x20000000
-#define FM_PCD_PLCR_GSR_FQS 0x0C000000
-#define FM_PCD_PLCR_GSR_LPALG 0x0000C000
-#define FM_PCD_PLCR_GSR_LPCA 0x00003000
-#define FM_PCD_PLCR_GSR_LPNUM 0x000000FF
-
-#define FM_PCD_PLCR_EVR_PSIC 0x80000000
-#define FM_PCD_PLCR_EVR_AAC 0x40000000
-
-#define FM_PCD_PLCR_PAR_PSI 0x20000000
-#define FM_PCD_PLCR_PAR_PNUM 0x00FF0000
-/* PWSEL Selctive select options */
-#define FM_PCD_PLCR_PAR_PWSEL_PEMODE 0x00008000 /* 0 */
-#define FM_PCD_PLCR_PAR_PWSEL_PEGNIA 0x00004000 /* 1 */
-#define FM_PCD_PLCR_PAR_PWSEL_PEYNIA 0x00002000 /* 2 */
-#define FM_PCD_PLCR_PAR_PWSEL_PERNIA 0x00001000 /* 3 */
-#define FM_PCD_PLCR_PAR_PWSEL_PECIR 0x00000800 /* 4 */
-#define FM_PCD_PLCR_PAR_PWSEL_PECBS 0x00000400 /* 5 */
-#define FM_PCD_PLCR_PAR_PWSEL_PEPIR_EIR 0x00000200 /* 6 */
-#define FM_PCD_PLCR_PAR_PWSEL_PEPBS_EBS 0x00000100 /* 7 */
-#define FM_PCD_PLCR_PAR_PWSEL_PELTS 0x00000080 /* 8 */
-#define FM_PCD_PLCR_PAR_PWSEL_PECTS 0x00000040 /* 9 */
-#define FM_PCD_PLCR_PAR_PWSEL_PEPTS_ETS 0x00000020 /* 10 */
-#define FM_PCD_PLCR_PAR_PWSEL_PEGPC 0x00000010 /* 11 */
-#define FM_PCD_PLCR_PAR_PWSEL_PEYPC 0x00000008 /* 12 */
-#define FM_PCD_PLCR_PAR_PWSEL_PERPC 0x00000004 /* 13 */
-#define FM_PCD_PLCR_PAR_PWSEL_PERYPC 0x00000002 /* 14 */
-#define FM_PCD_PLCR_PAR_PWSEL_PERRPC 0x00000001 /* 15 */
-
-#define FM_PCD_PLCR_PAR_PMR_BRN_1TO1 0x0000 /* - Full bit replacement. {PBNUM[0:N-1]
- 1-> 2^N specific locations. */
-#define FM_PCD_PLCR_PAR_PMR_BRN_2TO2 0x1 /* - {PBNUM[0:N-2],PNUM[N-1]}.
- 2-> 2^(N-1) base locations. */
-#define FM_PCD_PLCR_PAR_PMR_BRN_4TO4 0x2 /* - {PBNUM[0:N-3],PNUM[N-2:N-1]}.
- 4-> 2^(N-2) base locations. */
-#define FM_PCD_PLCR_PAR_PMR_BRN_8TO8 0x3 /* - {PBNUM[0:N-4],PNUM[N-3:N-1]}.
- 8->2^(N-3) base locations. */
-#define FM_PCD_PLCR_PAR_PMR_BRN_16TO16 0x4 /* - {PBNUM[0:N-5],PNUM[N-4:N-1]}.
- 16-> 2^(N-4) base locations. */
-#define FM_PCD_PLCR_PAR_PMR_BRN_32TO32 0x5 /* {PBNUM[0:N-6],PNUM[N-5:N-1]}.
- 32-> 2^(N-5) base locations. */
-#define FM_PCD_PLCR_PAR_PMR_BRN_64TO64 0x6 /* {PBNUM[0:N-7],PNUM[N-6:N-1]}.
- 64-> 2^(N-6) base locations. */
-#define FM_PCD_PLCR_PAR_PMR_BRN_128TO128 0x7 /* {PBNUM[0:N-8],PNUM[N-7:N-1]}.
- 128-> 2^(N-7) base locations. */
-#define FM_PCD_PLCR_PAR_PMR_BRN_256TO256 0x8 /* - No bit replacement for N=8. {PNUM[N-8:N-1]}.
- When N=8 this option maps all 256 profiles by the DISPATCH bus into one group. */
-
-#define FM_PCD_PLCR_PMR_V 0x80000000
-#define PLCR_ERR_ECC_CAP 0x80000000
-#define PLCR_ERR_ECC_TYPE_DOUBLE 0x40000000
-#define PLCR_ERR_ECC_PNUM_MASK 0x00000FF0
-#define PLCR_ERR_ECC_OFFSET_MASK 0x0000000F
-
-#define PLCR_ERR_UNINIT_CAP 0x80000000
-#define PLCR_ERR_UNINIT_NUM_MASK 0x000000FF
-#define PLCR_ERR_UNINIT_PID_MASK 0x003f0000
-#define PLCR_ERR_UNINIT_ABSOLUTE_MASK 0x00008000
-
-/* shifts */
-#define PLCR_ERR_ECC_PNUM_SHIFT 4
-#define PLCR_ERR_UNINIT_PID_SHIFT 16
-
-#define FM_PCD_PLCR_PMR_BRN_SHIFT 16
-
-/* others */
-#define WAIT_FOR_PLCR_EVR_AAC \
-{\
- uint32_t count = 0; \
- uint32_t tmpReg32; \
- while (count < FM_PCD_PLCR_POLL) \
- { \
- tmpReg32 = GET_UINT32(p_FmPcdPlcrRegs->fmpl_evr);\
- if (!( tmpReg32 & FM_PCD_PLCR_EVR_AAC)) break;\
- count++;\
- }\
-}
-
-#define WAIT_FOR_PLCR_PAR_GO \
-{\
- uint32_t count = 0; \
- uint32_t tmpReg32; \
- while (count < FM_PCD_PLCR_POLL) \
- { \
- tmpReg32 = GET_UINT32(p_FmPcdPlcrRegs->fmpl_par);\
- if (!( tmpReg32 & FM_PCD_PLCR_PAR_GO)) break;\
- count++; \
- }\
-}
-
-#define PLCR_PORT_WINDOW_SIZE(hardwarePortId)
-
-/****************************/
-/* Defaults */
-/****************************/
-#define DEFAULT_plcrAutoRefresh FALSE
-#define DEFAULT_prsMaxParseCycleLimit 0
-#define DEFAULT_fmPcdKgErrorExceptions (FM_PCD_EX_KG_DOUBLE_ECC | FM_PCD_EX_KG_KEYSIZE_OVERFLOW)
-#define DEFAULT_fmPcdPlcrErrorExceptions (FM_PCD_EX_PLCR_DOUBLE_ECC | FM_PCD_EX_PLCR_INIT_ENTRY_ERROR)
-#define DEFAULT_fmPcdPlcrExceptions 0
-#define DEFAULT_fmPcdPrsErrorExceptions (FM_PCD_EX_PRS_DOUBLE_ECC)
-
-#define DEFAULT_fmPcdPrsExceptions FM_PCD_EX_PRS_SINGLE_ECC
-#define DEFAULT_numOfUsedProfilesPerWindow 16
-#define DEFAULT_numOfSharedPlcrProfiles 4
-
/***********************************************************************/
/* Memory map */
/***********************************************************************/
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(push,1)
#endif /* defined(__MWERKS__) && ... */
-#define MEM_MAP_START
-
-typedef _Packed struct {
- volatile uint32_t kgoe_sp;
- volatile uint32_t kgoe_cpp;
-} _PackedType t_FmPcdKgPortConfigRegs;
-
-typedef _Packed struct {
- volatile uint32_t kgcpe[8];
-} _PackedType t_FmPcdKgClsPlanRegs;
-
-typedef _Packed union {
- t_FmPcdKgInterModuleSchemeRegs schemeRegs;
- t_FmPcdKgPortConfigRegs portRegs;
- t_FmPcdKgClsPlanRegs clsPlanRegs;
-} _PackedType u_FmPcdKgIndirectAccessRegs;
-
-typedef _Packed struct {
- volatile uint32_t kggcr;
- volatile uint32_t res0;
- volatile uint32_t res1;
- volatile uint32_t kgeer;
- volatile uint32_t kgeeer;
- volatile uint32_t res2;
- volatile uint32_t res3;
- volatile uint32_t kgseer;
- volatile uint32_t kgseeer;
- volatile uint32_t kggsr;
- volatile uint32_t kgtpc;
- volatile uint32_t kgserc;
- volatile uint32_t res4[4];
- volatile uint32_t kgfdor;
- volatile uint32_t kggdv0r;
- volatile uint32_t kggdv1r;
- volatile uint32_t res5[5];
- volatile uint32_t kgfer;
- volatile uint32_t kgfeer;
- volatile uint32_t res6[38];
- u_FmPcdKgIndirectAccessRegs indirectAccessRegs;
- volatile uint32_t res[42]; /*(0xfc-sizeof(u_FmPcdKgIndirectAccessRegs))/4 */
- volatile uint32_t kgar;
-} _PackedType t_FmPcdKgRegs;
-
-typedef _Packed struct {
+
+
+typedef struct {
/* General Configuration and Status Registers */
volatile uint32_t fmpl_gcr; /* 0x000 FMPL_GCR - FM Policer General Configuration */
volatile uint32_t fmpl_gsr; /* 0x004 FMPL_GSR - FM Policer Global Status Register */
@@ -404,7 +147,7 @@ typedef _Packed struct {
volatile uint32_t fmpl_res0[21]; /* 0x038 - 0x08B Reserved */
/* Profile RAM Access Registers */
volatile uint32_t fmpl_par; /* 0x08C FMPL_PAR - FM Policer Profile Action Register*/
- t_FmPcdPlcrInterModuleProfileRegs profileRegs;
+ t_FmPcdPlcrProfileRegs profileRegs;
/* Error Capture Registers */
volatile uint32_t fmpl_serc; /* 0x100 FMPL_SERC - FM Policer Soft Error Capture */
volatile uint32_t fmpl_upcr; /* 0x104 FMPL_UPCR - FM Policer Uninitialized Profile Capture Register */
@@ -415,42 +158,8 @@ typedef _Packed struct {
volatile uint32_t fmpl_dpmr; /* 0x200 FMPL_DPMR - FM Policer Default Mapping Register */
volatile uint32_t fmpl_pmr[63]; /*+default 0x204-0x2FF FMPL_PMR1 - FMPL_PMR63, - FM Policer Profile Mapping Registers.
(for port-ID 1-11, only for supported Port-ID registers) */
-} _PackedType t_FmPcdPlcrRegs;
-
-typedef _Packed struct {
- volatile uint32_t rpclim;
- volatile uint32_t rpimac;
- volatile uint32_t pmeec;
- volatile uint32_t res1[5];
- volatile uint32_t pevr;
- volatile uint32_t pever;
- volatile uint32_t pevfr;
- volatile uint32_t perr;
- volatile uint32_t perer;
- volatile uint32_t perfr;
- volatile uint32_t res2[0xA];
- volatile uint32_t ppsc;
- volatile uint32_t res3;
- volatile uint32_t pds;
- volatile uint32_t l2rrs;
- volatile uint32_t l3rrs;
- volatile uint32_t l4rrs;
- volatile uint32_t srrs;
- volatile uint32_t l2rres;
- volatile uint32_t l3rres;
- volatile uint32_t l4rres;
- volatile uint32_t srres;
- volatile uint32_t spcs;
- volatile uint32_t spscs;
- volatile uint32_t hxscs;
- volatile uint32_t mrcs;
- volatile uint32_t mwcs;
- volatile uint32_t mrscs;
- volatile uint32_t mwscs;
- volatile uint32_t fcscs;
-} _PackedType t_FmPcdPrsRegs;
-
-#define MEM_MAP_END
+} t_FmPcdPlcrRegs;
+
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(pop)
#endif /* defined(__MWERKS__) && ... */
@@ -461,6 +170,15 @@ typedef _Packed struct {
/***********************************************************************/
typedef struct {
+ bool known;
+ uint8_t id;
+} t_FmPcdKgSchemesExtractsEntry;
+
+typedef struct {
+ t_FmPcdKgSchemesExtractsEntry extractsArray[FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY];
+} t_FmPcdKgSchemesExtracts;
+
+typedef struct {
t_Handle h_Manip;
bool keepRes;
e_FmPcdEngine nextEngine;
@@ -472,13 +190,19 @@ typedef struct {
between the port and PCD regarding the KG scheme.
*//***************************************************************************/
typedef struct {
- uint8_t netEnvId; /* in */
- uint8_t numOfDistinctionUnits; /* in */
- uint8_t unitIds[FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS]; /* in */
- uint32_t vector; /* out */
+ uint8_t netEnvId; /* in */
+ uint8_t numOfDistinctionUnits; /* in */
+ uint8_t unitIds[FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS]; /* in */
+ uint32_t vector; /* out */
} t_NetEnvParams;
typedef struct {
+ bool allocated;
+ uint8_t ownerId; /* guestId for KG in multi-partition only.
+ portId for PLCR in any environment */
+} t_FmPcdAllocMng;
+
+typedef struct {
volatile bool lock;
bool used;
uint8_t owners;
@@ -490,7 +214,9 @@ typedef struct {
} t_FmPcdKgClsPlanGrp;
typedef struct {
- volatile bool lock;
+ t_Handle h_FmPcd;
+ uint8_t schemeId;
+ t_FmPcdLock *p_Lock;
bool valid;
uint8_t netEnvId;
uint8_t owners;
@@ -502,29 +228,34 @@ typedef struct {
t_FmPcdKgKeyOrder orderedArray;
e_FmPcdEngine nextEngine;
e_FmPcdDoneAction doneAction;
- uint8_t pointedOwners;
+ bool requiredActionFlag;
uint32_t requiredAction;
bool extractedOrs;
uint8_t bitOffsetInPlcrProfile;
bool directPlcr;
+#if (DPAA_VERSION >= 11)
+ bool vspe;
+#endif
} t_FmPcdKgScheme;
-typedef struct {
- bool allocated;
- uint8_t ownerId; /* guestId for KG in multi-partition only,
- portId for PLCR in any environment */
-} t_FmPcdAllocMng;
+typedef union {
+ struct fman_kg_scheme_regs schemeRegs;
+ struct fman_kg_pe_regs portRegs;
+ struct fman_kg_cp_regs clsPlanRegs;
+} u_FmPcdKgIndirectAccessRegs;
typedef struct {
- t_FmPcdKgRegs *p_FmPcdKgRegs;
- uint32_t schemeExceptionsBitMask;
- uint8_t numOfSchemes;
- uint8_t schemesIds[FM_PCD_KG_NUM_OF_SCHEMES];
- t_FmPcdKgScheme schemes[FM_PCD_KG_NUM_OF_SCHEMES];
- t_FmPcdKgClsPlanGrp clsPlanGrps[FM_MAX_NUM_OF_PORTS];
- uint8_t emptyClsPlanGrpId;
- t_FmPcdAllocMng schemesMng[FM_PCD_KG_NUM_OF_SCHEMES]; /* only for MASTER ! */
- t_FmPcdAllocMng clsPlanBlocksMng[FM_PCD_MAX_NUM_OF_CLS_PLANS/CLS_PLAN_NUM_PER_GRP];
+ struct fman_kg_regs *p_FmPcdKgRegs;
+ uint32_t schemeExceptionsBitMask;
+ uint8_t numOfSchemes;
+ t_Handle h_HwSpinlock;
+ uint8_t schemesIds[FM_PCD_KG_NUM_OF_SCHEMES];
+ t_FmPcdKgScheme schemes[FM_PCD_KG_NUM_OF_SCHEMES];
+ t_FmPcdKgClsPlanGrp clsPlanGrps[FM_MAX_NUM_OF_PORTS];
+ uint8_t emptyClsPlanGrpId;
+ t_FmPcdAllocMng schemesMng[FM_PCD_KG_NUM_OF_SCHEMES]; /* only for MASTER ! */
+ t_FmPcdAllocMng clsPlanBlocksMng[FM_PCD_MAX_NUM_OF_CLS_PLANS/CLS_PLAN_NUM_PER_GRP];
+ u_FmPcdKgIndirectAccessRegs *p_IndirectAccessRegs;
} t_FmPcdKg;
typedef struct {
@@ -534,11 +265,13 @@ typedef struct {
} t_FmPcdPlcrMapParam;
typedef struct {
- bool valid;
- volatile bool lock;
- t_FmPcdAllocMng profilesMng;
- uint8_t pointedOwners;
- uint32_t requiredAction;
+ uint16_t absoluteProfileId;
+ t_Handle h_FmPcd;
+ bool valid;
+ t_FmPcdLock *p_Lock;
+ t_FmPcdAllocMng profilesMng;
+ bool requiredActionFlag;
+ uint32_t requiredAction;
e_FmPcdEngine nextEngineOnGreen; /**< Green next engine type */
u_FmPcdPlcrNextEngineParams paramsOnGreen; /**< Green next engine params */
@@ -551,17 +284,21 @@ typedef struct {
typedef struct {
t_FmPcdPlcrRegs *p_FmPcdPlcrRegs;
+ uint16_t partPlcrProfilesBase;
+ uint16_t partNumOfPlcrProfiles;
t_FmPcdPlcrProfile profiles[FM_PCD_PLCR_NUM_ENTRIES];
uint16_t numOfSharedProfiles;
uint16_t sharedProfilesIds[FM_PCD_PLCR_NUM_ENTRIES];
t_FmPcdPlcrMapParam portsMapping[FM_MAX_NUM_OF_PORTS];
+ t_Handle h_HwSpinlock;
+ t_Handle h_SwSpinlock;
} t_FmPcdPlcr;
typedef struct {
uint32_t *p_SwPrsCode;
uint32_t *p_CurrSwPrs;
uint8_t currLabel;
- t_FmPcdPrsRegs *p_FmPcdPrsRegs;
+ struct fman_prs_regs *p_FmPcdPrsRegs;
t_FmPcdPrsLabelParams labelsTable[FM_PCD_PRS_NUM_OF_LABELS];
uint32_t fmPcdPrsPortIdStatistics;
} t_FmPcdPrs;
@@ -575,11 +312,14 @@ typedef struct {
typedef struct {
e_NetHeaderType hdr;
+ protocolOpt_t opt; /* only one option !! */
e_NetHeaderType aliasHdr;
} t_FmPcdNetEnvAliases;
typedef struct {
- volatile bool lock;
+ uint8_t netEnvId;
+ t_Handle h_FmPcd;
+ t_Handle h_Spinlock;
bool used;
uint8_t owners;
uint8_t clsPlanGrpId;
@@ -587,21 +327,26 @@ typedef struct {
uint32_t unitsVectors[FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS];
uint32_t lcvs[FM_PCD_PRS_NUM_OF_HDRS];
uint32_t macsecVector;
- t_FmPcdNetEnvAliases aliasHdrs[FM_PCD_MAX_NUM_OF_PRIVATE_HDRS];
+ t_FmPcdNetEnvAliases aliasHdrs[FM_PCD_MAX_NUM_OF_ALIAS_HDRS];
} t_FmPcdNetEnv;
typedef struct {
+ struct fman_prs_cfg dfltCfg;
bool plcrAutoRefresh;
-
uint16_t prsMaxParseCycleLimit;
} t_FmPcdDriverParam;
typedef struct {
t_Handle h_Fm;
t_Handle h_FmMuram;
+ t_FmRevisionInfo fmRevInfo;
+
uint64_t physicalMuramBase;
- volatile bool lock;
+
t_Handle h_Spinlock;
+ t_List freeLocksLst;
+ t_List acquiredLocksLst;
+
t_Handle h_IpcSession; /* relevant for guest only */
bool enabled;
uint8_t guestId; /**< Guest Partition Id */
@@ -613,42 +358,48 @@ typedef struct {
t_FmPcdPlcr *p_FmPcdPlcr;
t_FmPcdPrs *p_FmPcdPrs;
+ void *p_CcShadow; /**< CC MURAM shadow */
+ uint32_t ccShadowSize;
+ uint32_t ccShadowAlign;
+ volatile bool shadowLock;
+ t_Handle h_ShadowSpinlock;
+
t_Handle h_Hc;
uint32_t exceptions;
t_FmPcdExceptionCallback *f_Exception;
t_FmPcdIdExceptionCallback *f_FmPcdIndexedException;
t_Handle h_App;
+ uintptr_t ipv6FrameIdAddr;
+ uintptr_t capwapFrameIdAddr;
+ bool advancedOffloadSupport;
t_FmPcdDriverParam *p_FmPcdDriverParam;
} t_FmPcd;
-
+#if (DPAA_VERSION >= 11)
+typedef uint8_t t_FmPcdFrmReplicUpdateType;
+#define FRM_REPLIC_UPDATE_COUNTER 0x01
+#define FRM_REPLIC_UPDATE_INFO 0x02
+#endif /* (DPAA_VERSION >= 11) */
/***********************************************************************/
/* PCD internal routines */
/***********************************************************************/
-/**************************************************************************//**
-
- @Group FM_PCD_InterModule_grp FM PCD Inter-Module Unit
-
- @Description FM PCD Inter Module functions -
- These are not User API routines but routines that may be called
- from other modules. This will be the case in a single core environment,
- where instead of useing the XX messeging mechanism, the routines may be
- called from other modules. In a multicore environment, the other modules may
- be run by other cores and therefor these routines may not be called directly.
-
- @{
-*//***************************************************************************/
-
t_Error PcdGetVectorForOpt(t_FmPcd *p_FmPcd, uint8_t netEnvId, protocolOpt_t opt, uint32_t *p_Vector);
t_Error PcdGetUnitsVector(t_FmPcd *p_FmPcd, t_NetEnvParams *p_Params);
bool PcdNetEnvIsUnitWithoutOpts(t_FmPcd *p_FmPcd, uint8_t netEnvId, uint32_t unitVector);
t_Error PcdGetClsPlanGrpParams(t_FmPcd *p_FmPcd, t_FmPcdKgInterModuleClsPlanGrpParams *p_GrpParams);
void FmPcdSetClsPlanGrpId(t_FmPcd *p_FmPcd, uint8_t netEnvId, uint8_t clsPlanGrpId);
e_NetHeaderType FmPcdGetAliasHdr(t_FmPcd *p_FmPcd, uint8_t netEnvId, e_NetHeaderType hdr);
-uint8_t FmPcdNetEnvGetUnitIdForSingleHdr(t_Handle h_FmPcd, uint8_t netEnvId, e_NetHeaderType hdr);
+uint8_t FmPcdNetEnvGetUnitIdForSingleHdr(t_FmPcd *p_FmPcd, uint8_t netEnvId, e_NetHeaderType hdr);
+uint8_t FmPcdNetEnvGetUnitId(t_FmPcd *p_FmPcd, uint8_t netEnvId, e_NetHeaderType hdr, bool interchangeable, protocolOpt_t opt);
+
+t_Error FmPcdManipBuildIpReassmScheme(t_FmPcd *p_FmPcd, t_Handle h_NetEnv, t_Handle h_CcTree, t_Handle h_Manip, bool isIpv4, uint8_t groupId);
+t_Error FmPcdManipDeleteIpReassmSchemes(t_Handle h_Manip);
+t_Error FmPcdManipBuildCapwapReassmScheme(t_FmPcd *p_FmPcd, t_Handle h_NetEnv, t_Handle h_CcTree, t_Handle h_Manip, uint8_t groupId);
+t_Error FmPcdManipDeleteCapwapReassmSchemes(t_Handle h_Manip);
+bool FmPcdManipIpReassmIsIpv6Hdr(t_Handle h_Manip);
t_Handle KgConfig( t_FmPcd *p_FmPcd, t_FmPcdParams *p_FmPcdParams);
t_Error KgInit(t_FmPcd *p_FmPcd);
@@ -666,15 +417,21 @@ t_Error FmPcdKgFreeSchemes(t_Handle h_FmPcd, uint8_t numOfSchemes, uint8_t g
/* only for SINGLE partittion */
t_Error KgBindPortToSchemes(t_Handle h_FmPcd , uint8_t hardwarePortId, uint32_t spReg);
+t_FmPcdLock *FmPcdAcquireLock(t_Handle h_FmPcd);
+void FmPcdReleaseLock(t_Handle h_FmPcd, t_FmPcdLock *p_Lock);
+
t_Handle PlcrConfig(t_FmPcd *p_FmPcd, t_FmPcdParams *p_FmPcdParams);
t_Error PlcrInit(t_FmPcd *p_FmPcd);
t_Error PlcrFree(t_FmPcd *p_FmPcd);
void PlcrEnable(t_FmPcd *p_FmPcd);
void PlcrDisable(t_FmPcd *p_FmPcd);
-t_Error PlcrFreeProfiles(t_FmPcd *p_FmPcd, uint8_t hardwarePortId, uint16_t num, uint16_t base);
-t_Error PlcrAllocProfiles(t_FmPcd *p_FmPcd, uint8_t hardwarePortId, uint16_t numOfProfiles, uint16_t *p_Base);
-t_Error PlcrAllocSharedProfiles(t_FmPcd *p_FmPcd, uint16_t numOfProfiles, uint16_t *profilesIds);
-void PlcrFreeSharedProfiles(t_FmPcd *p_FmPcd, uint16_t numOfProfiles, uint16_t *profilesIds);
+uint16_t PlcrAllocProfilesForPartition(t_FmPcd *p_FmPcd, uint16_t base, uint16_t numOfProfiles, uint8_t guestId);
+void PlcrFreeProfilesForPartition(t_FmPcd *p_FmPcd, uint16_t base, uint16_t numOfProfiles, uint8_t guestId);
+t_Error PlcrSetPortProfiles(t_FmPcd *p_FmPcd,
+ uint8_t hardwarePortId,
+ uint16_t numOfProfiles,
+ uint16_t base);
+t_Error PlcrClearPortProfiles(t_FmPcd *p_FmPcd, uint8_t hardwarePortId);
t_Handle PrsConfig(t_FmPcd *p_FmPcd,t_FmPcdParams *p_FmPcdParams);
t_Error PrsInit(t_FmPcd *p_FmPcd);
@@ -683,19 +440,56 @@ void PrsDisable(t_FmPcd *p_FmPcd);
void PrsFree(t_FmPcd *p_FmPcd );
t_Error PrsIncludePortInStatistics(t_FmPcd *p_FmPcd, uint8_t hardwarePortId, bool include);
-t_Handle FmPcdCcConfig(t_Handle h_FmPcd, t_FmPcdParams *p_FmPcdParams);
t_Error FmPcdCcGetGrpParams(t_Handle treeId, uint8_t grpId, uint32_t *p_GrpBits, uint8_t *p_GrpBase);
uint8_t FmPcdCcGetOffset(t_Handle h_CcNode);
uint8_t FmPcdCcGetParseCode(t_Handle h_CcNode);
uint16_t FmPcdCcGetNumOfKeys(t_Handle h_CcNode);
+t_Error ValidateNextEngineParams(t_Handle h_FmPcd, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams, e_FmPcdCcStatsMode supportedStatsMode);
void FmPcdManipUpdateOwner(t_Handle h_Manip, bool add);
-t_Error FmPcdManipCheckParamsForCcNextEgine(t_FmPcdCcNextEngineParams *p_InfoForManip, uint32_t *requiredAction);
-void FmPcdManipUpdateAdResultForCc(t_Handle h_Manip, t_Handle p_Ad, t_Handle *p_AdNew);
+t_Error FmPcdManipCheckParamsForCcNextEngine(t_FmPcdCcNextEngineParams *p_InfoForManip, uint32_t *requiredAction);
+void FmPcdManipUpdateAdResultForCc(t_Handle h_Manip,
+ t_FmPcdCcNextEngineParams *p_CcNextEngineParams,
+ t_Handle p_Ad,
+ t_Handle *p_AdNewPtr);
void FmPcdManipUpdateAdContLookupForCc(t_Handle h_Manip, t_Handle p_Ad, t_Handle *p_AdNew, uint32_t adTableOffset);
-uint32_t FmPcdManipCheckNia(t_Handle h_FmPcd, t_Handle h_Ad);
void FmPcdManipUpdateOwner(t_Handle h_Manip, bool add);
t_Error FmPcdManipCheckParamsWithCcNodeParams(t_Handle h_Manip, t_Handle h_FmPcdCcNode);
+#ifdef FM_CAPWAP_SUPPORT
+t_Handle FmPcdManipApplSpecificBuild(void);
+bool FmPcdManipIsCapwapApplSpecific(t_Handle h_Manip);
+#endif /* FM_CAPWAP_SUPPORT */
+#if (DPAA_VERSION >= 11)
+void * FrmReplicGroupGetSourceTableDescriptor(t_Handle h_ReplicGroup);
+void FrmReplicGroupUpdateOwner(t_Handle h_ReplicGroup, bool add);
+void FrmReplicGroupUpdateAd(t_Handle h_ReplicGroup, void *p_Ad, t_Handle *h_AdNew);
+
+void FmPcdCcGetAdTablesThatPointOnReplicGroup(t_Handle h_Node,
+ t_Handle h_ReplicGroup,
+ t_List *p_AdTables,
+ uint32_t *p_NumOfAdTables);
+#endif /* (DPAA_VERSION >= 11) */
+
+void EnqueueNodeInfoToRelevantLst(t_List *p_List, t_CcNodeInformation *p_CcInfo, t_Handle h_Spinlock);
+void DequeueNodeInfoFromRelevantLst(t_List *p_List, t_Handle h_Info, t_Handle h_Spinlock);
+t_CcNodeInformation* FindNodeInfoInReleventLst(t_List *p_List, t_Handle h_Info, t_Handle h_Spinlock);
+t_List *FmPcdManipGetSpinlock(t_Handle h_Manip);
+t_List *FmPcdManipGetNodeLstPointedOnThisManip(t_Handle h_Manip);
+
+typedef struct
+{
+ t_Handle h_StatsAd;
+ t_Handle h_StatsCounters;
+#if (DPAA_VERSION >= 11)
+ t_Handle h_StatsFLRs;
+#endif /* (DPAA_VERSION >= 11) */
+} t_FmPcdCcStatsParams;
+
+void NextStepAd(t_Handle h_Ad,
+ t_FmPcdCcStatsParams *p_FmPcdCcStatsParams,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams,
+ t_FmPcd *p_FmPcd);
+void ReleaseLst(t_List *p_List);
static __inline__ t_Handle FmPcdGetMuramHandle(t_Handle h_FmPcd)
{
@@ -711,5 +505,39 @@ static __inline__ uint64_t FmPcdGetMuramPhysBase(t_Handle h_FmPcd)
return p_FmPcd->physicalMuramBase;
}
+static __inline__ uint32_t FmPcdLockSpinlock(t_FmPcdLock *p_Lock)
+{
+ ASSERT_COND(p_Lock);
+ return XX_LockIntrSpinlock(p_Lock->h_Spinlock);
+}
+
+static __inline__ void FmPcdUnlockSpinlock(t_FmPcdLock *p_Lock, uint32_t flags)
+{
+ ASSERT_COND(p_Lock);
+ XX_UnlockIntrSpinlock(p_Lock->h_Spinlock, flags);
+}
+
+static __inline__ bool FmPcdLockTryLock(t_FmPcdLock *p_Lock)
+{
+ uint32_t intFlags;
+
+ ASSERT_COND(p_Lock);
+ intFlags = XX_LockIntrSpinlock(p_Lock->h_Spinlock);
+ if (p_Lock->flag)
+ {
+ XX_UnlockIntrSpinlock(p_Lock->h_Spinlock, intFlags);
+ return FALSE;
+ }
+ p_Lock->flag = TRUE;
+ XX_UnlockIntrSpinlock(p_Lock->h_Spinlock, intFlags);
+ return TRUE;
+}
+
+static __inline__ void FmPcdLockUnlock(t_FmPcdLock *p_Lock)
+{
+ ASSERT_COND(p_Lock);
+ p_Lock->flag = FALSE;
+}
+
#endif /* __FM_PCD_H */
diff --git a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_pcd_ipc.h b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_pcd_ipc.h
index 800a72b2ba7c..325d3e335f02 100644
--- a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_pcd_ipc.h
+++ b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_pcd_ipc.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File fm_pcd_ipc.h
@@ -53,7 +54,6 @@
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(push,1)
#endif /* defined(__MWERKS__) && ... */
-#define MEM_MAP_START
/**************************************************************************//**
@Description Structure for getting a sw parser address according to a label
@@ -63,7 +63,7 @@
*//***************************************************************************/
typedef _Packed struct t_FmPcdIpcSwPrsLable
{
- uint32_t enumHdr; /**< IN. The existance of this header will envoke
+ uint32_t enumHdr; /**< IN. The existence of this header will invoke
the sw parser code. */
uint8_t indexPerHdr; /**< IN. Normally 0, if more than one sw parser
attachments for the same header, use this
@@ -79,38 +79,25 @@ typedef _Packed struct t_FmPcdIpcSwPrsLable
Some fields are optional (depending on configuration) and
will be analized by the port and FM modules accordingly.
*//***************************************************************************/
+
typedef struct t_FmPcdIpcKgSchemesParams
{
- uint8_t guestId; /**< IN */
- uint8_t numOfSchemes; /**< IN */
- uint8_t schemesIds[FM_PCD_KG_NUM_OF_SCHEMES]; /**< OUT */
+ uint8_t guestId;
+ uint8_t numOfSchemes;
+ uint8_t schemesIds[FM_PCD_KG_NUM_OF_SCHEMES];
} _PackedType t_FmPcdIpcKgSchemesParams;
typedef struct t_FmPcdIpcKgClsPlanParams
{
- uint8_t guestId; /**< IN */
- uint16_t numOfClsPlanEntries; /**< IN */
- uint8_t clsPlanBase; /**< IN in alloc only */
+ uint8_t guestId;
+ uint16_t numOfClsPlanEntries;
+ uint8_t clsPlanBase;
} _PackedType t_FmPcdIpcKgClsPlanParams;
-typedef _Packed struct t_FmPcdIpcPlcrAllocParams
-{
- uint16_t num;
- uint8_t hardwarePortId;
- uint16_t plcrProfilesBase;
-} _PackedType t_FmPcdIpcPlcrAllocParams;
-
-typedef _Packed struct t_FmPcdIpcSharedPlcrAllocParams
-{
- uint16_t num; /**< IN */
- //uint16_t profilesIds[FM_PCD_PLCR_NUM_ENTRIES]; /**< OUT */
- uint32_t sharedProfilesMask[8];
-} _PackedType t_FmPcdIpcSharedPlcrAllocParams;
-
typedef _Packed struct t_FmPcdIpcPrsIncludePort
{
- uint8_t hardwarePortId; /* IN */
- bool include; /* IN */
+ uint8_t hardwarePortId;
+ bool include;
} _PackedType t_FmPcdIpcPrsIncludePort;
@@ -118,19 +105,22 @@ typedef _Packed struct t_FmPcdIpcPrsIncludePort
#define FM_PCD_MAX_MSG_SIZE 36
#define FM_PCD_MAX_REPLY_BODY_SIZE 36
-typedef _Packed struct
-{
+typedef _Packed struct {
uint32_t msgId;
uint8_t msgBody[FM_PCD_MAX_MSG_SIZE];
} _PackedType t_FmPcdIpcMsg;
-typedef _Packed struct t_FmPcdIpcReply
-{
+typedef _Packed struct t_FmPcdIpcReply {
uint32_t error;
uint8_t replyBody[FM_PCD_MAX_REPLY_BODY_SIZE];
} _PackedType t_FmPcdIpcReply;
-#define MEM_MAP_END
+typedef _Packed struct t_FmIpcResourceAllocParams {
+ uint8_t guestId;
+ uint16_t base;
+ uint16_t num;
+}_PackedType t_FmIpcResourceAllocParams;
+
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(pop)
#endif /* defined(__MWERKS__) && ... */
@@ -160,7 +150,7 @@ typedef _Packed struct t_FmPcdIpcReply
@Description Used by FM PCD front-end in order to allocate Policer profiles
- @Param[in/out] t_FmPcdIpcKgSchemesParams Pointer
+ @Param[in/out] t_FmIpcResourceAllocParams Pointer
*//***************************************************************************/
#define FM_PCD_ALLOC_PROFILES 5
@@ -169,46 +159,48 @@ typedef _Packed struct t_FmPcdIpcReply
@Description Used by FM PCD front-end in order to Free Policer profiles
- @Param[in/out] t_FmPcdIpcPlcrAllocParams Pointer
+ @Param[in/out] t_FmIpcResourceAllocParams Pointer
*//***************************************************************************/
#define FM_PCD_FREE_PROFILES 6
/**************************************************************************//**
- @Function FM_PCD_GET_PHYS_MURAM_BASE
+ @Function FM_PCD_SET_PORT_PROFILES
- @Description Used by FM PCD front-end in order to get MURAM base address
+ @Description Used by FM PCD front-end in order to allocate Policer profiles
+ for specific port
- @Param[in/out] t_FmPcdIcPhysAddr Pointer
+ @Param[in/out] t_FmIpcResourceAllocParams Pointer
*//***************************************************************************/
-#define FM_PCD_GET_PHYS_MURAM_BASE 7
+#define FM_PCD_SET_PORT_PROFILES 7
/**************************************************************************//**
- @Function FM_PCD_GET_SW_PRS_OFFSET
+ @Function FM_PCD_CLEAR_PORT_PROFILES
- @Description Used by FM front-end to get the SW parser offset of the start of
- code relevant to a given label.
+ @Description Used by FM PCD front-end in order to allocate Policer profiles
+ for specific port
- @Param[in/out] t_FmPcdIpcSwPrsLable Pointer
+ @Param[in/out] t_FmIpcResourceAllocParams Pointer
*//***************************************************************************/
-#define FM_PCD_GET_SW_PRS_OFFSET 8
+#define FM_PCD_CLEAR_PORT_PROFILES 8
/**************************************************************************//**
- @Function FM_PCD_ALLOC_SHARED_PROFILES
+ @Function FM_PCD_GET_PHYS_MURAM_BASE
- @Description Used by FM PCD front-end in order to allocate shared profiles
+ @Description Used by FM PCD front-end in order to get MURAM base address
- @Param[in/out] t_FmPcdIpcSharedPlcrAllocParams Pointer
+ @Param[in/out] t_FmPcdIcPhysAddr Pointer
*//***************************************************************************/
-#define FM_PCD_ALLOC_SHARED_PROFILES 9
+#define FM_PCD_GET_PHYS_MURAM_BASE 9
/**************************************************************************//**
- @Function FM_PCD_FREE_SHARED_PROFILES
+ @Function FM_PCD_GET_SW_PRS_OFFSET
- @Description Used by FM PCD front-end in order to free shared profiles
+ @Description Used by FM front-end to get the SW parser offset of the start of
+ code relevant to a given label.
- @Param[in/out] t_FmPcdIpcSharedPlcrAllocParams Pointer
+ @Param[in/out] t_FmPcdIpcSwPrsLable Pointer
*//***************************************************************************/
-#define FM_PCD_FREE_SHARED_PROFILES 10
+#define FM_PCD_GET_SW_PRS_OFFSET 10
/**************************************************************************//**
@Function FM_PCD_MASTER_IS_ENABLED
@@ -231,58 +223,13 @@ typedef _Packed struct t_FmPcdIpcReply
#define FM_PCD_GUEST_DISABLE 16
/**************************************************************************//**
- @Function FM_PCD_DUMP_REGS
-
- @Description Used by FM front-end to dump all PCD registers
-
- @Param[in] None
-*//***************************************************************************/
-#define FM_PCD_DUMP_REGS 17
-
-/**************************************************************************//**
- @Function FM_PCD_KG_DUMP_REGS
-
- @Description Used by FM front-end to dump KG registers
-
- @Param[in] None
-*//***************************************************************************/
-#define FM_PCD_KG_DUMP_REGS 18
-
-/**************************************************************************//**
- @Function FM_PCD_PLCR_DUMP_REGS
-
- @Description Used by FM front-end to dump PLCR registers
-
- @Param[in] None
-*//***************************************************************************/
-#define FM_PCD_PLCR_DUMP_REGS 19
-
-/**************************************************************************//**
- @Function FM_PCD_PLCR_PROFILE_DUMP_REGS
-
- @Description Used by FM front-end to dump PLCR specified profile registers
-
- @Param[in] t_Handle Pointer
-*//***************************************************************************/
-#define FM_PCD_PLCR_PROFILE_DUMP_REGS 20
-
-/**************************************************************************//**
- @Function FM_PCD_PRS_DUMP_REGS
-
- @Description Used by FM front-end to dump PRS registers
-
- @Param[in] None
-*//***************************************************************************/
-#define FM_PCD_PRS_DUMP_REGS 21
-
-/**************************************************************************//**
@Function FM_PCD_FREE_KG_CLSPLAN
@Description Used by FM PCD front-end in order to Free KG classification plan entries
@Param[in/out] t_FmPcdIpcKgClsPlanParams Pointer
*//***************************************************************************/
-#define FM_PCD_FREE_KG_CLSPLAN 22
+#define FM_PCD_FREE_KG_CLSPLAN 22
/**************************************************************************//**
@Function FM_PCD_ALLOC_KG_CLSPLAN
@@ -291,7 +238,7 @@ typedef _Packed struct t_FmPcdIpcReply
@Param[in/out] t_FmPcdIpcKgClsPlanParams Pointer
*//***************************************************************************/
-#define FM_PCD_ALLOC_KG_CLSPLAN 23
+#define FM_PCD_ALLOC_KG_CLSPLAN 23
/**************************************************************************//**
@Function FM_PCD_MASTER_IS_ALIVE
@@ -319,6 +266,13 @@ typedef _Packed struct t_FmPcdIpcReply
@Param[in/out] t_FmPcdIpcPrsIncludePort Pointer
*//***************************************************************************/
#define FM_PCD_PRS_INC_PORT_STATS 26
+
+#if (DPAA_VERSION >= 11)
+/* TODO - doc */
+#define FM_PCD_ALLOC_SP 27
+#endif /* (DPAA_VERSION >= 11) */
+
+
/** @} */ /* end of FM_PCD_IPC_grp group */
/** @} */ /* end of FM_grp group */
diff --git a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_plcr.c b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_plcr.c
index b9f5128d43d3..f23d8b8168b2 100644
--- a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_plcr.c
+++ b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_plcr.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,11 +30,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm_plcr.c
@Description FM PCD POLICER...
*//***************************************************************************/
+#include <linux/math64.h>
#include "std_ext.h"
#include "error_ext.h"
#include "string_ext.h"
@@ -46,17 +48,70 @@
#include "fm_pcd.h"
#include "fm_hc.h"
#include "fm_pcd_ipc.h"
+#include "fm_plcr.h"
+
+
+/****************************************/
+/* static functions */
+/****************************************/
+
+static uint32_t PlcrProfileLock(t_Handle h_Profile)
+{
+ ASSERT_COND(h_Profile);
+ return FmPcdLockSpinlock(((t_FmPcdPlcrProfile *)h_Profile)->p_Lock);
+}
+
+static void PlcrProfileUnlock(t_Handle h_Profile, uint32_t intFlags)
+{
+ ASSERT_COND(h_Profile);
+ FmPcdUnlockSpinlock(((t_FmPcdPlcrProfile *)h_Profile)->p_Lock, intFlags);
+}
+
+static bool PlcrProfileFlagTryLock(t_Handle h_Profile)
+{
+ ASSERT_COND(h_Profile);
+ return FmPcdLockTryLock(((t_FmPcdPlcrProfile *)h_Profile)->p_Lock);
+}
+
+static void PlcrProfileFlagUnlock(t_Handle h_Profile)
+{
+ ASSERT_COND(h_Profile);
+ FmPcdLockUnlock(((t_FmPcdPlcrProfile *)h_Profile)->p_Lock);
+}
+
+static uint32_t PlcrHwLock(t_Handle h_FmPcdPlcr)
+{
+ ASSERT_COND(h_FmPcdPlcr);
+ return XX_LockIntrSpinlock(((t_FmPcdPlcr*)h_FmPcdPlcr)->h_HwSpinlock);
+}
+
+static void PlcrHwUnlock(t_Handle h_FmPcdPlcr, uint32_t intFlags)
+{
+ ASSERT_COND(h_FmPcdPlcr);
+ XX_UnlockIntrSpinlock(((t_FmPcdPlcr*)h_FmPcdPlcr)->h_HwSpinlock, intFlags);
+}
+
+static uint32_t PlcrSwLock(t_Handle h_FmPcdPlcr)
+{
+ ASSERT_COND(h_FmPcdPlcr);
+ return XX_LockIntrSpinlock(((t_FmPcdPlcr*)h_FmPcdPlcr)->h_SwSpinlock);
+}
+static void PlcrSwUnlock(t_Handle h_FmPcdPlcr, uint32_t intFlags)
+{
+ ASSERT_COND(h_FmPcdPlcr);
+ XX_UnlockIntrSpinlock(((t_FmPcdPlcr*)h_FmPcdPlcr)->h_SwSpinlock, intFlags);
+}
-static bool FmPcdPlcrIsProfileShared(t_Handle h_FmPcd, uint16_t absoluteProfileId)
+static bool IsProfileShared(t_Handle h_FmPcd, uint16_t absoluteProfileId)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
uint16_t i;
SANITY_CHECK_RETURN_VALUE(p_FmPcd, E_INVALID_HANDLE, FALSE);
- for(i=0;i<p_FmPcd->p_FmPcdPlcr->numOfSharedProfiles;i++)
- if(p_FmPcd->p_FmPcdPlcr->sharedProfilesIds[i] == absoluteProfileId)
+ for (i=0;i<p_FmPcd->p_FmPcdPlcr->numOfSharedProfiles;i++)
+ if (p_FmPcd->p_FmPcdPlcr->sharedProfilesIds[i] == absoluteProfileId)
return TRUE;
return FALSE;
}
@@ -64,8 +119,8 @@ static bool FmPcdPlcrIsProfileShared(t_Handle h_FmPcd, uint16_t absoluteProfileI
static t_Error SetProfileNia(t_FmPcd *p_FmPcd, e_FmPcdEngine nextEngine, u_FmPcdPlcrNextEngineParams *p_NextEngineParams, uint32_t *nextAction)
{
uint32_t nia;
- uint16_t absoluteProfileId = (uint16_t)(PTR_TO_UINT(p_NextEngineParams->h_Profile)-1);
- uint8_t relativeSchemeId, physicatSchemeId;
+ uint16_t absoluteProfileId;
+ uint8_t relativeSchemeId, physicalSchemeId;
nia = FM_PCD_PLCR_NIA_VALID;
@@ -75,31 +130,32 @@ static t_Error SetProfileNia(t_FmPcd *p_FmPcd, e_FmPcdEngine nextEngine, u_FmPcd
switch (p_NextEngineParams->action)
{
case e_FM_PCD_DROP_FRAME :
- nia |= (NIA_ENG_BMI | NIA_BMI_AC_DISCARD);
+ nia |= GET_NIA_BMI_AC_DISCARD_FRAME(p_FmPcd);
break;
case e_FM_PCD_ENQ_FRAME:
- nia |= (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME);
+ nia |= GET_NIA_BMI_AC_ENQ_FRAME(p_FmPcd);
break;
default:
RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
}
break;
case e_FM_PCD_KG:
- physicatSchemeId = (uint8_t)(PTR_TO_UINT(p_NextEngineParams->h_DirectScheme)-1);
- relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmPcd, physicatSchemeId);
- if(relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)
+ physicalSchemeId = FmPcdKgGetSchemeId(p_NextEngineParams->h_DirectScheme);
+ relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmPcd, physicalSchemeId);
+ if (relativeSchemeId >= FM_PCD_KG_NUM_OF_SCHEMES)
RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);
- if (!FmPcdKgIsSchemeValidSw(p_FmPcd, relativeSchemeId))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid direct scheme."));
- if(!KgIsSchemeAlwaysDirect(p_FmPcd, relativeSchemeId))
+ if (!FmPcdKgIsSchemeValidSw(p_NextEngineParams->h_DirectScheme))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid direct scheme."));
+ if (!KgIsSchemeAlwaysDirect(p_FmPcd, relativeSchemeId))
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Policer Profile may point only to a scheme that is always direct."));
- nia |= NIA_ENG_KG | NIA_KG_DIRECT | physicatSchemeId;
+ nia |= NIA_ENG_KG | NIA_KG_DIRECT | physicalSchemeId;
break;
case e_FM_PCD_PLCR:
- if(!FmPcdPlcrIsProfileShared(p_FmPcd, absoluteProfileId))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next profile must be a shared profile"));
- if(!FmPcdPlcrIsProfileValid(p_FmPcd, absoluteProfileId))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid profile "));
+ absoluteProfileId = ((t_FmPcdPlcrProfile *)p_NextEngineParams->h_Profile)->absoluteProfileId;
+ if (!IsProfileShared(p_FmPcd, absoluteProfileId))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next profile must be a shared profile"));
+ if (!FmPcdPlcrIsProfileValid(p_FmPcd, absoluteProfileId))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid profile "));
nia |= NIA_ENG_PLCR | NIA_PLCR_ABSOLUTE | absoluteProfileId;
break;
default:
@@ -111,24 +167,24 @@ static t_Error SetProfileNia(t_FmPcd *p_FmPcd, e_FmPcdEngine nextEngine, u_FmPcd
return E_OK;
}
-static uint32_t FPP_Function(uint32_t fpp)
+static uint32_t CalcFPP(uint32_t fpp)
{
- if(fpp > 15)
+ if (fpp > 15)
return 15 - (0x1f - fpp);
else
return 16 + fpp;
}
-static void GetInfoRateReg(e_FmPcdPlcrRateMode rateMode,
- uint32_t rate,
- uint64_t tsuInTenthNano,
- uint32_t fppShift,
- uint64_t *p_Integer,
- uint64_t *p_Fraction)
+static void GetInfoRateReg(e_FmPcdPlcrRateMode rateMode,
+ uint32_t rate,
+ uint64_t tsuInTenthNano,
+ uint32_t fppShift,
+ uint64_t *p_Integer,
+ uint64_t *p_Fraction)
{
uint64_t tmp, div;
- if(rateMode == e_FM_PCD_PLCR_BYTE_MODE)
+ if (rateMode == e_FM_PCD_PLCR_BYTE_MODE)
{
/* now we calculate the initial integer for the bigger rate */
/* from Kbps to Bytes/TSU */
@@ -150,46 +206,66 @@ static void GetInfoRateReg(e_FmPcdPlcrRateMode rateMode,
div = 1000000000; /* nano */
div *= 10; /* 10 nano */
}
- *p_Integer = (tmp<<fppShift)/div;
+ *p_Integer = (tmp<<fppShift) / div;
/* for calculating the fraction, we will recalculate cir and deduct the integer.
* For precision, we will multiply by 2^16. we do not divid back, since we write
* this value as fraction - see spec.
*/
- *p_Fraction = (((tmp<<fppShift)<<16) - ((*p_Integer<<16)*div))/div;
+ *p_Fraction = (((tmp<<fppShift)<<16) - ((*p_Integer<<16)*div)) / div;
}
/* .......... */
-static void calcRates(t_Handle h_FmPcd, t_FmPcdPlcrNonPassthroughAlgParams *p_NonPassthroughAlgParam,
- uint32_t *cir, uint32_t *cbs, uint32_t *pir_eir, uint32_t *pbs_ebs, uint32_t *fpp)
+static void CalcRates(uint32_t bitFor1Micro,
+ t_FmPcdPlcrNonPassthroughAlgParams *p_NonPassthroughAlgParam,
+ uint32_t *cir,
+ uint32_t *cbs,
+ uint32_t *pir_eir,
+ uint32_t *pbs_ebs,
+ uint32_t *fpp)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
uint64_t integer, fraction;
- uint32_t temp, tsuInTenthNanos, bitFor1Micro;
+ uint32_t temp, tsuInTenthNanos;
uint8_t fppShift=0;
- bitFor1Micro = FmGetTimeStampScale(p_FmPcd->h_Fm); /* TimeStamp per nano seconds units */
/* we want the tsu to count 10 nano for better precision normally tsu is 3.9 nano, now we will get 39 */
- tsuInTenthNanos = (uint32_t)(1000*10/(1<<bitFor1Micro));
+ tsuInTenthNanos = (uint32_t)(1000*10/(1 << bitFor1Micro));
/* we choose the faster rate to calibrate fpp */
- if (p_NonPassthroughAlgParam->comittedInfoRate > p_NonPassthroughAlgParam->peakOrAccessiveInfoRate)
- GetInfoRateReg(p_NonPassthroughAlgParam->rateMode, p_NonPassthroughAlgParam->comittedInfoRate, tsuInTenthNanos, 0, &integer, &fraction);
+ /* The meaning of this step:
+ * when fppShift is 0 it means all TS bits are treated as integer and TSU is the TS LSB count.
+ * In this configuration we calculate the integer and fraction that represent the higher infoRate
+ * When this is done, we can tell where we have "spare" unused bits and optimize the division of TS
+ * into "integer" and "fraction" where the logic is - as many bits as possible for integer at
+ * high rate, as many bits as possible for fraction at low rate.
+ */
+ if (p_NonPassthroughAlgParam->committedInfoRate > p_NonPassthroughAlgParam->peakOrExcessInfoRate)
+ GetInfoRateReg(p_NonPassthroughAlgParam->rateMode, p_NonPassthroughAlgParam->committedInfoRate, tsuInTenthNanos, 0, &integer, &fraction);
else
- GetInfoRateReg(p_NonPassthroughAlgParam->rateMode, p_NonPassthroughAlgParam->peakOrAccessiveInfoRate, tsuInTenthNanos, 0, &integer, &fraction);
-
+ GetInfoRateReg(p_NonPassthroughAlgParam->rateMode, p_NonPassthroughAlgParam->peakOrExcessInfoRate, tsuInTenthNanos, 0, &integer, &fraction);
/* we shift integer, as in cir/pir it is represented by the MSB 16 bits, and
* the LSB bits are for the fraction */
temp = (uint32_t)((integer<<16) & 0x00000000FFFFFFFF);
/* temp is effected by the rate. For low rates it may be as low as 0, and then we'll
- * take max fpp=31.
+ * take max FP = 31.
* For high rates it will never exceed the 32 bit reg (after the 16 shift), as it is
* limited by the 10G physical port.
*/
- if(temp != 0)
+ if (temp != 0)
{
+ /* In this case, the largest rate integer is non 0, if it does not occupy all (high) 16
+ * bits of the PIR_EIR we can use this fact and enlarge it to occupy all 16 bits.
+ * The logic is to have as many bits for integer in the higher rates, but if we have "0"s
+ * in the integer part of the cir/pir register, than these bits are wasted. So we want
+ * to use these bits for the fraction. in this way we will have for fraction - the number
+ * of "0" bits and the rest - for integer.
+ * In other words: For each bit we shift it in PIR_EIR, we move the FP in the TS
+ * one bit to the left - preserving the relationship and achieving more bits
+ * for integer in the TS.
+ */
+
/* count zeroes left of the higher used bit (in order to shift the value such that
* unused bits may be used for fraction).
*/
@@ -198,7 +274,7 @@ static void calcRates(t_Handle h_FmPcd, t_FmPcdPlcrNonPassthroughAlgParams *p_No
temp = temp << 1;
fppShift++;
}
- if(fppShift > 15)
+ if (fppShift > 15)
{
REPORT_ERROR(MAJOR, E_INVALID_SELECTION, ("timeStampPeriod to Information rate ratio is too small"));
return;
@@ -207,12 +283,12 @@ static void calcRates(t_Handle h_FmPcd, t_FmPcdPlcrNonPassthroughAlgParams *p_No
else
{
temp = (uint32_t)fraction; /* fraction will alyas be smaller than 2^16 */
- if(!temp)
- /* integer and fraction are 0, we set fpp to its max val */
+ if (!temp)
+ /* integer and fraction are 0, we set FP to its max val */
fppShift = 31;
else
{
- /* integer was 0 but fraction is not. fpp is 16 for the integer,
+ /* integer was 0 but fraction is not. FP is 16 for the fraction,
* + all left zeroes of the fraction. */
fppShift=16;
/* count zeroes left of the higher used bit (in order to shift the value such that
@@ -227,20 +303,22 @@ static void calcRates(t_Handle h_FmPcd, t_FmPcdPlcrNonPassthroughAlgParams *p_No
}
/*
- * This means that the FM TS register will now be used so that 'count' bits are for
+ * This means that the FM TS register will now be used so that 'fppShift' bits are for
* fraction and the rest for integer */
- /* now we re-calculate cir */
- GetInfoRateReg(p_NonPassthroughAlgParam->rateMode, p_NonPassthroughAlgParam->comittedInfoRate, tsuInTenthNanos, fppShift, &integer, &fraction);
+ /* now we re-calculate cir and pir_eir with the calculated FP */
+ GetInfoRateReg(p_NonPassthroughAlgParam->rateMode, p_NonPassthroughAlgParam->committedInfoRate, tsuInTenthNanos, fppShift, &integer, &fraction);
*cir = (uint32_t)(integer << 16 | (fraction & 0xFFFF));
- GetInfoRateReg(p_NonPassthroughAlgParam->rateMode, p_NonPassthroughAlgParam->peakOrAccessiveInfoRate, tsuInTenthNanos, fppShift, &integer, &fraction);
+ GetInfoRateReg(p_NonPassthroughAlgParam->rateMode, p_NonPassthroughAlgParam->peakOrExcessInfoRate, tsuInTenthNanos, fppShift, &integer, &fraction);
*pir_eir = (uint32_t)(integer << 16 | (fraction & 0xFFFF));
- *cbs = p_NonPassthroughAlgParam->comittedBurstSize;
- *pbs_ebs = p_NonPassthroughAlgParam->peakOrAccessiveBurstSize;
-
- /* get fpp as it should be written to reg.*/
- *fpp = FPP_Function(fppShift);
+ *cbs = p_NonPassthroughAlgParam->committedBurstSize;
+ *pbs_ebs = p_NonPassthroughAlgParam->peakOrExcessBurstSize;
+ /* convert FP as it should be written to reg.
+ * 0-15 --> 16-31
+ * 16-31 --> 0-15
+ */
+ *fpp = CalcFPP(fppShift);
}
static void WritePar(t_FmPcd *p_FmPcd, uint32_t par)
@@ -250,443 +328,37 @@ static void WritePar(t_FmPcd *p_FmPcd, uint32_t par)
ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
WRITE_UINT32(p_FmPcdPlcrRegs->fmpl_par, par);
- while(GET_UINT32(p_FmPcdPlcrRegs->fmpl_par) & FM_PCD_PLCR_PAR_GO) ;
-
-}
-
-/*********************************************/
-/*............Policer Exception..............*/
-/*********************************************/
-static void PcdPlcrException(t_Handle h_FmPcd)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- uint32_t event, mask, force;
-
- ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
- event = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_evr);
- mask = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ier);
-
- event &= mask;
-
- /* clear the forced events */
- force = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ifr);
- if(force & event)
- WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ifr, force & ~event);
-
-
- WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_evr, event);
-
- if(event & FM_PCD_PLCR_PRAM_SELF_INIT_COMPLETE)
- p_FmPcd->f_Exception(p_FmPcd->h_App,e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE);
- if(event & FM_PCD_PLCR_ATOMIC_ACTION_COMPLETE)
- p_FmPcd->f_Exception(p_FmPcd->h_App,e_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE);
-
-}
-
-/* ..... */
-
-static void PcdPlcrErrorException(t_Handle h_FmPcd)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- uint32_t event, force, captureReg, mask;
-
- ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
- event = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eevr);
- mask = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eier);
-
- event &= mask;
-
- /* clear the forced events */
- force = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eifr);
- if(force & event)
- WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eifr, force & ~event);
-
- WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eevr, event);
-
- if(event & FM_PCD_PLCR_DOUBLE_ECC)
- p_FmPcd->f_Exception(p_FmPcd->h_App,e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC);
- if(event & FM_PCD_PLCR_INIT_ENTRY_ERROR)
- {
- captureReg = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_upcr);
- /*ASSERT_COND(captureReg & PLCR_ERR_UNINIT_CAP);
- p_UnInitCapt->profileNum = (uint8_t)(captureReg & PLCR_ERR_UNINIT_NUM_MASK);
- p_UnInitCapt->portId = (uint8_t)((captureReg & PLCR_ERR_UNINIT_PID_MASK) >>PLCR_ERR_UNINIT_PID_SHIFT) ;
- p_UnInitCapt->absolute = (bool)(captureReg & PLCR_ERR_UNINIT_ABSOLUTE_MASK);*/
- p_FmPcd->f_FmPcdIndexedException(p_FmPcd->h_App,e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR,(uint16_t)(captureReg & PLCR_ERR_UNINIT_NUM_MASK));
- WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_upcr, PLCR_ERR_UNINIT_CAP);
- }
-}
-
-void FmPcdPlcrUpatePointedOwner(t_Handle h_FmPcd, uint16_t absoluteProfileId, bool add)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
-
- ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid);
-
- if(add)
- p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].pointedOwners++;
- else
- p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].pointedOwners--;
-}
-
-uint32_t FmPcdPlcrGetPointedOwners(t_Handle h_FmPcd, uint16_t absoluteProfileId)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
-
- ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid);
-
- return p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].pointedOwners;
-}
-uint32_t FmPcdPlcrGetRequiredAction(t_Handle h_FmPcd, uint16_t absoluteProfileId)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
-
- ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid);
-
- return p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].requiredAction;
-}
-
-t_Error FmPcdPlcrAllocProfiles(t_Handle h_FmPcd, uint8_t hardwarePortId, uint16_t numOfProfiles)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- t_FmPcdIpcPlcrAllocParams ipcPlcrParams;
- t_Error err = E_OK;
- uint16_t base;
- uint16_t swPortIndex = 0;
- t_FmPcdIpcMsg msg;
- uint32_t replyLength;
- t_FmPcdIpcReply reply;
-
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
-
- if(!numOfProfiles)
- return E_OK;
-
- memset(&ipcPlcrParams, 0, sizeof(ipcPlcrParams));
-
- if(p_FmPcd->guestId != NCSW_MASTER_ID)
- {
- /* Alloc resources using IPC messaging */
- memset(&reply, 0, sizeof(reply));
- memset(&msg, 0, sizeof(msg));
- ipcPlcrParams.num = numOfProfiles;
- ipcPlcrParams.hardwarePortId = hardwarePortId;
- msg.msgId = FM_PCD_ALLOC_PROFILES;
- memcpy(msg.msgBody, &ipcPlcrParams, sizeof(ipcPlcrParams));
- replyLength = sizeof(uint32_t) + sizeof(uint16_t);
- if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
- (uint8_t*)&msg,
- sizeof(msg.msgId) +sizeof(ipcPlcrParams),
- (uint8_t*)&reply,
- &replyLength,
- NULL,
- NULL)) != E_OK)
- RETURN_ERROR(MAJOR, err,NO_MSG);
- if (replyLength != sizeof(uint32_t) + sizeof(uint16_t))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
- if((t_Error)reply.error != E_OK)
- RETURN_ERROR(MAJOR, (t_Error)reply.error, ("PLCR profiles allocation failed"));
-
- memcpy((uint8_t*)&base, reply.replyBody, sizeof(uint16_t));
- }
- else /* master */
- {
- err = PlcrAllocProfiles(p_FmPcd, hardwarePortId, numOfProfiles, &base);
- if(err)
- RETURN_ERROR(MAJOR, err,NO_MSG);
- }
- HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId);
-
- p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].numOfProfiles = numOfProfiles;
- p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].profilesBase = base;
-
- return E_OK;
-}
-
-t_Error FmPcdPlcrFreeProfiles(t_Handle h_FmPcd, uint8_t hardwarePortId)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- t_FmPcdIpcPlcrAllocParams ipcPlcrParams;
- t_Error err = E_OK;
- uint16_t swPortIndex = 0;
- t_FmPcdIpcMsg msg;
- uint32_t replyLength;
- t_FmPcdIpcReply reply;
-
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
-
- HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId);
-
- if(p_FmPcd->guestId != NCSW_MASTER_ID)
- {
- /* Alloc resources using IPC messaging */
- memset(&reply, 0, sizeof(reply));
- memset(&msg, 0, sizeof(msg));
- ipcPlcrParams.num = p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].numOfProfiles;
- ipcPlcrParams.hardwarePortId = hardwarePortId;
- ipcPlcrParams.plcrProfilesBase = p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].profilesBase;
- msg.msgId = FM_PCD_FREE_PROFILES;
- memcpy(msg.msgBody, &ipcPlcrParams, sizeof(ipcPlcrParams));
- replyLength = sizeof(uint32_t);
- if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
- (uint8_t*)&msg,
- sizeof(msg.msgId) +sizeof(ipcPlcrParams),
- (uint8_t*)&reply,
- &replyLength,
- NULL,
- NULL)) != E_OK)
- RETURN_ERROR(MAJOR, err,NO_MSG);
- if (replyLength != sizeof(uint32_t))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
- if ((t_Error)reply.error != E_OK)
- RETURN_ERROR(MINOR, (t_Error)reply.error, ("PLCR Free Profiles failed"));
- }
- else /* master */
- {
- err = PlcrFreeProfiles(p_FmPcd, hardwarePortId, p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].numOfProfiles, p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].profilesBase);
- if(err)
- RETURN_ERROR(MAJOR, err,NO_MSG);
- }
- p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].numOfProfiles = 0;
- p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].profilesBase = 0;
-
- return E_OK;
-}
-
-bool FmPcdPlcrIsProfileValid(t_Handle h_FmPcd, uint16_t absoluteProfileId)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- t_FmPcdPlcr *p_FmPcdPlcr = p_FmPcd->p_FmPcdPlcr;
-
- return p_FmPcdPlcr->profiles[absoluteProfileId].valid;
+ while (GET_UINT32(p_FmPcdPlcrRegs->fmpl_par) & FM_PCD_PLCR_PAR_GO) ;
}
-t_Error PlcrAllocProfiles(t_FmPcd *p_FmPcd, uint8_t hardwarePortId, uint16_t numOfProfiles, uint16_t *p_Base)
+static t_Error BuildProfileRegs(t_FmPcd *p_FmPcd,
+ t_FmPcdPlcrProfileParams *p_ProfileParams,
+ t_FmPcdPlcrProfileRegs *p_PlcrRegs)
{
- t_FmPcdPlcrRegs *p_Regs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
- uint32_t profilesFound, log2Num, tmpReg32;
- uint32_t intFlags;
- uint16_t first, i;
-
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
-
- ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
- if(!numOfProfiles)
- return E_OK;
-
- ASSERT_COND(hardwarePortId);
-
- if (numOfProfiles>FM_PCD_PLCR_NUM_ENTRIES)
- RETURN_ERROR(MINOR, E_INVALID_VALUE, ("numProfiles is too big."));
-
- if (!POWER_OF_2(numOfProfiles))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numProfiles must be a power of 2."));
-
- intFlags = FmPcdLock(p_FmPcd);
+ t_Error err = E_OK;
+ uint32_t pemode, gnia, ynia, rnia, bitFor1Micro;
- if(GET_UINT32(p_Regs->fmpl_pmr[hardwarePortId-1]) & FM_PCD_PLCR_PMR_V)
- {
- FmPcdUnlock(p_FmPcd, intFlags);
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("The requesting port has already an allocated profiles window."));
- }
+ ASSERT_COND(p_FmPcd);
- first = 0;
- profilesFound = 0;
- for(i=0;i<FM_PCD_PLCR_NUM_ENTRIES;)
- {
- if(!p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.allocated)
- {
- profilesFound++;
- i++;
- if(profilesFound == numOfProfiles)
- break;
- }
- else
- {
- profilesFound = 0;
- /* advance i to the next aligned address */
- first = i = (uint8_t)(first + numOfProfiles);
- }
- }
- if(profilesFound == numOfProfiles)
- {
- for(i = first; i<first + numOfProfiles; i++)
- {
- p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.allocated = TRUE;
- p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.ownerId = hardwarePortId;
- }
- }
- else
- {
- FmPcdUnlock(p_FmPcd, intFlags);
- RETURN_ERROR(MINOR, E_FULL, ("No profiles."));
- }
-
- /**********************FMPL_PMRx******************/
- LOG2((uint64_t)numOfProfiles, log2Num);
- tmpReg32 = first;
- tmpReg32 |= log2Num << 16;
- tmpReg32 |= FM_PCD_PLCR_PMR_V;
- WRITE_UINT32(p_Regs->fmpl_pmr[hardwarePortId-1], tmpReg32);
-
- *p_Base = first;
-
- FmPcdUnlock(p_FmPcd, intFlags);
-
- return E_OK;
-}
-
-t_Error PlcrAllocSharedProfiles(t_FmPcd *p_FmPcd, uint16_t numOfProfiles, uint16_t *profilesIds)
-{
- uint32_t profilesFound;
- uint16_t i, k=0;
-
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
-
- ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
- if(!numOfProfiles)
- return E_OK;
-
- if (numOfProfiles>FM_PCD_PLCR_NUM_ENTRIES)
- RETURN_ERROR(MINOR, E_INVALID_VALUE, ("numProfiles is too big."));
-
- profilesFound = 0;
- for(i=0;i<FM_PCD_PLCR_NUM_ENTRIES; i++)
- {
- if(!p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.allocated)
- {
- profilesFound++;
- profilesIds[k] = i;
- k++;
- if(profilesFound == numOfProfiles)
- break;
- }
- }
- if(profilesFound != numOfProfiles)
- RETURN_ERROR(MAJOR, E_INVALID_STATE,NO_MSG);
- for(i = 0;i<k;i++)
- {
- p_FmPcd->p_FmPcdPlcr->profiles[profilesIds[i]].profilesMng.allocated = TRUE;
- p_FmPcd->p_FmPcdPlcr->profiles[profilesIds[i]].profilesMng.ownerId = 0;
- }
-
- return E_OK;
-}
-
-t_Error PlcrFreeProfiles(t_FmPcd *p_FmPcd, uint8_t hardwarePortId, uint16_t numOfProfiles, uint16_t base)
-{
- t_FmPcdPlcrRegs *p_Regs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
- uint16_t i;
-
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_HANDLE);
-
- ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
- ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
- WRITE_UINT32(p_Regs->fmpl_pmr[hardwarePortId-1], 0);
-
- for(i = base; i<base+numOfProfiles;i++)
- {
- ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.ownerId == hardwarePortId);
- ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.allocated);
-
- p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.allocated = FALSE;
- p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.ownerId = 0;
- }
-
- return E_OK;
-}
-
-void PlcrFreeSharedProfiles(t_FmPcd *p_FmPcd, uint16_t numOfProfiles, uint16_t *profilesIds)
-{
- uint16_t i;
-
- SANITY_CHECK_RETURN(p_FmPcd, E_INVALID_HANDLE);
-
- ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
- for(i=0;i<numOfProfiles; i++)
- {
- ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[profilesIds[i]].profilesMng.allocated);
- p_FmPcd->p_FmPcdPlcr->profiles[profilesIds[i]].profilesMng.allocated = FALSE;
- }
-}
-
-void PlcrEnable(t_FmPcd *p_FmPcd)
-{
- t_FmPcdPlcrRegs *p_Regs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
-
- WRITE_UINT32(p_Regs->fmpl_gcr, GET_UINT32(p_Regs->fmpl_gcr) | FM_PCD_PLCR_GCR_EN);
-}
-
-void PlcrDisable(t_FmPcd *p_FmPcd)
-{
- t_FmPcdPlcrRegs *p_Regs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
-
- WRITE_UINT32(p_Regs->fmpl_gcr, GET_UINT32(p_Regs->fmpl_gcr) & ~FM_PCD_PLCR_GCR_EN);
-}
-
-t_Error FM_PCD_SetPlcrStatistics(t_Handle h_FmPcd, bool enable)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint32_t tmpReg32;
-
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE);
-
- if(!FmIsMaster(p_FmPcd->h_Fm))
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_SetPlcrStatistics - guest mode!"));
-
- tmpReg32 = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_gcr);
- if(enable)
- tmpReg32 |= FM_PCD_PLCR_GCR_STEN;
- else
- tmpReg32 &= ~FM_PCD_PLCR_GCR_STEN;
-
- WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_gcr, tmpReg32);
- return E_OK;
-}
-
-t_Error FM_PCD_ConfigPlcrAutoRefreshMode(t_Handle h_FmPcd, bool enable)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
-
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdDriverParam, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE);
-
- if(!FmIsMaster(p_FmPcd->h_Fm))
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_ConfigPlcrAutoRefreshMode - guest mode!"));
-
- p_FmPcd->p_FmPcdDriverParam->plcrAutoRefresh = enable;
-
- return E_OK;
-}
-
-
-t_Error FmPcdPlcrBuildProfile(t_Handle h_FmPcd, t_FmPcdPlcrProfileParams *p_Profile, t_FmPcdPlcrInterModuleProfileRegs *p_PlcrRegs)
-{
-
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- t_Error err = E_OK;
- uint32_t pemode, gnia, ynia, rnia;
+ bitFor1Micro = FmGetTimeStampScale(p_FmPcd->h_Fm);
+ if (bitFor1Micro == 0)
+ RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("Timestamp scale"));
/* Set G, Y, R Nia */
- err = SetProfileNia(p_FmPcd, p_Profile->nextEngineOnGreen, &(p_Profile->paramsOnGreen), &gnia);
- if(err)
+ err = SetProfileNia(p_FmPcd, p_ProfileParams->nextEngineOnGreen, &(p_ProfileParams->paramsOnGreen), &gnia);
+ if (err)
RETURN_ERROR(MAJOR, err, NO_MSG);
- err = SetProfileNia(p_FmPcd, p_Profile->nextEngineOnYellow, &(p_Profile->paramsOnYellow), &ynia);
- if(err)
+ err = SetProfileNia(p_FmPcd, p_ProfileParams->nextEngineOnYellow, &(p_ProfileParams->paramsOnYellow), &ynia);
+ if (err)
RETURN_ERROR(MAJOR, err, NO_MSG);
- err = SetProfileNia(p_FmPcd, p_Profile->nextEngineOnRed, &(p_Profile->paramsOnRed), &rnia);
- if(err)
+ err = SetProfileNia(p_FmPcd, p_ProfileParams->nextEngineOnRed, &(p_ProfileParams->paramsOnRed), &rnia);
+ if (err)
RETURN_ERROR(MAJOR, err, NO_MSG);
-
/* Mode fmpl_pemode */
pemode = FM_PCD_PLCR_PEMODE_PI;
- switch (p_Profile->algSelection)
+ switch (p_ProfileParams->algSelection)
{
case e_FM_PCD_PLCR_PASS_THROUGH:
p_PlcrRegs->fmpl_pecir = 0;
@@ -697,11 +369,11 @@ t_Error FmPcdPlcrBuildProfile(t_Handle h_FmPcd, t_FmPcdPlcrProfileParams *p_Prof
p_PlcrRegs->fmpl_pects = 0;
p_PlcrRegs->fmpl_pepts_ets = 0;
pemode &= ~FM_PCD_PLCR_PEMODE_ALG_MASK;
- switch (p_Profile->colorMode)
+ switch (p_ProfileParams->colorMode)
{
case e_FM_PCD_PLCR_COLOR_BLIND:
pemode |= FM_PCD_PLCR_PEMODE_CBLND;
- switch (p_Profile->color.dfltColor)
+ switch (p_ProfileParams->color.dfltColor)
{
case e_FM_PCD_PLCR_GREEN:
pemode &= ~FM_PCD_PLCR_PEMODE_DEFC_MASK;
@@ -731,15 +403,15 @@ t_Error FmPcdPlcrBuildProfile(t_Handle h_FmPcd, t_FmPcdPlcrProfileParams *p_Prof
case e_FM_PCD_PLCR_RFC_2698:
/* Select algorithm MODE[ALG] = "01" */
pemode |= FM_PCD_PLCR_PEMODE_ALG_RFC2698;
- if (p_Profile->nonPassthroughAlgParams.comittedInfoRate > p_Profile->nonPassthroughAlgParams.peakOrAccessiveInfoRate)
- RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("in RFC2698 Peak rate must be equal or larger than comittedInfoRate."));
+ if (p_ProfileParams->nonPassthroughAlgParams.committedInfoRate > p_ProfileParams->nonPassthroughAlgParams.peakOrExcessInfoRate)
+ RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("in RFC2698 Peak rate must be equal or larger than committedInfoRate."));
goto cont_rfc;
case e_FM_PCD_PLCR_RFC_4115:
/* Select algorithm MODE[ALG] = "10" */
pemode |= FM_PCD_PLCR_PEMODE_ALG_RFC4115;
cont_rfc:
/* Select Color-Blind / Color-Aware operation (MODE[CBLND]) */
- switch (p_Profile->colorMode)
+ switch (p_ProfileParams->colorMode)
{
case e_FM_PCD_PLCR_COLOR_BLIND:
pemode |= FM_PCD_PLCR_PEMODE_CBLND;
@@ -747,7 +419,7 @@ cont_rfc:
case e_FM_PCD_PLCR_COLOR_AWARE:
pemode &= ~FM_PCD_PLCR_PEMODE_CBLND;
/*In color aware more select override color interpretation (MODE[OVCLR]) */
- switch (p_Profile->color.override)
+ switch (p_ProfileParams->color.override)
{
case e_FM_PCD_PLCR_GREEN:
pemode &= ~FM_PCD_PLCR_PEMODE_OVCLR_MASK;
@@ -769,11 +441,11 @@ cont_rfc:
RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
}
/* Select Measurement Unit Mode to BYTE or PACKET (MODE[PKT]) */
- switch (p_Profile->nonPassthroughAlgParams.rateMode)
+ switch (p_ProfileParams->nonPassthroughAlgParams.rateMode)
{
case e_FM_PCD_PLCR_BYTE_MODE :
pemode &= ~FM_PCD_PLCR_PEMODE_PKT;
- switch (p_Profile->nonPassthroughAlgParams.byteModeParams.frameLengthSelection)
+ switch (p_ProfileParams->nonPassthroughAlgParams.byteModeParams.frameLengthSelection)
{
case e_FM_PCD_PLCR_L2_FRM_LEN:
pemode |= FM_PCD_PLCR_PEMODE_FLS_L2;
@@ -790,7 +462,7 @@ cont_rfc:
default:
RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
}
- switch (p_Profile->nonPassthroughAlgParams.byteModeParams.rollBackFrameSelection)
+ switch (p_ProfileParams->nonPassthroughAlgParams.byteModeParams.rollBackFrameSelection)
{
case e_FM_PCD_PLCR_ROLLBACK_L2_FRM_LEN:
pemode &= ~FM_PCD_PLCR_PEMODE_RBFLS;
@@ -816,7 +488,7 @@ cont_rfc:
{
uint32_t cir=0, cbs=0, pir_eir=0, pbs_ebs=0, fpp=0;
- calcRates(h_FmPcd, &p_Profile->nonPassthroughAlgParams, &cir, &cbs, &pir_eir, &pbs_ebs, &fpp);
+ CalcRates(bitFor1Micro, &p_ProfileParams->nonPassthroughAlgParams, &cir, &cbs, &pir_eir, &pbs_ebs, &fpp);
/* Set Committed Information Rate (CIR) */
p_PlcrRegs->fmpl_pecir = cir;
@@ -857,26 +529,153 @@ cont_rfc:
return E_OK;
}
-void FmPcdPlcrValidateProfileSw(t_Handle h_FmPcd, uint16_t absoluteProfileId)
+static t_Error AllocSharedProfiles(t_FmPcd *p_FmPcd, uint16_t numOfProfiles, uint16_t *profilesIds)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ uint32_t profilesFound;
+ uint16_t i, k=0;
+ uint32_t intFlags;
- ASSERT_COND(!p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid);
- p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid = TRUE;
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+
+ if (!numOfProfiles)
+ return E_OK;
+
+ if (numOfProfiles>FM_PCD_PLCR_NUM_ENTRIES)
+ RETURN_ERROR(MINOR, E_INVALID_VALUE, ("numProfiles is too big."));
+
+ intFlags = PlcrSwLock(p_FmPcd->p_FmPcdPlcr);
+ /* Find numOfProfiles free profiles (may be spread) */
+ profilesFound = 0;
+ for (i=0;i<FM_PCD_PLCR_NUM_ENTRIES; i++)
+ if (!p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.allocated)
+ {
+ profilesFound++;
+ profilesIds[k] = i;
+ k++;
+ if (profilesFound == numOfProfiles)
+ break;
+ }
+
+ if (profilesFound != numOfProfiles)
+ {
+ PlcrSwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,NO_MSG);
+ }
+
+ for (i = 0;i<k;i++)
+ {
+ p_FmPcd->p_FmPcdPlcr->profiles[profilesIds[i]].profilesMng.allocated = TRUE;
+ p_FmPcd->p_FmPcdPlcr->profiles[profilesIds[i]].profilesMng.ownerId = 0;
+ }
+ PlcrSwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
+
+ return E_OK;
}
-void FmPcdPlcrInvalidateProfileSw(t_Handle h_FmPcd, uint16_t absoluteProfileId)
+static void FreeSharedProfiles(t_FmPcd *p_FmPcd, uint16_t numOfProfiles, uint16_t *profilesIds)
+{
+ uint16_t i;
+
+ SANITY_CHECK_RETURN(p_FmPcd, E_INVALID_HANDLE);
+
+ ASSERT_COND(numOfProfiles);
+
+ for (i=0; i < numOfProfiles; i++)
+ {
+ ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[profilesIds[i]].profilesMng.allocated);
+ p_FmPcd->p_FmPcdPlcr->profiles[profilesIds[i]].profilesMng.allocated = FALSE;
+ p_FmPcd->p_FmPcdPlcr->profiles[profilesIds[i]].profilesMng.ownerId = p_FmPcd->guestId;
+ }
+}
+
+static void UpdateRequiredActionFlag(t_Handle h_FmPcd, uint16_t absoluteProfileId, bool set)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ /* this routine is protected by calling routine */
+
ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid);
- p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid = FALSE;
+
+ if (set)
+ p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].requiredActionFlag = TRUE;
+ else
+ {
+ p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].requiredAction = 0;
+ p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].requiredActionFlag = FALSE;
+ }
+}
+
+/*********************************************/
+/*............Policer Exception..............*/
+/*********************************************/
+static void EventsCB(t_Handle h_FmPcd)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ uint32_t event, mask, force;
+
+ ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
+ event = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_evr);
+ mask = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ier);
+
+ event &= mask;
+
+ /* clear the forced events */
+ force = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ifr);
+ if (force & event)
+ WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_ifr, force & ~event);
+
+
+ WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_evr, event);
+
+ if (event & FM_PCD_PLCR_PRAM_SELF_INIT_COMPLETE)
+ p_FmPcd->f_Exception(p_FmPcd->h_App,e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE);
+ if (event & FM_PCD_PLCR_ATOMIC_ACTION_COMPLETE)
+ p_FmPcd->f_Exception(p_FmPcd->h_App,e_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE);
}
+/* ..... */
+
+static void ErrorExceptionsCB(t_Handle h_FmPcd)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ uint32_t event, force, captureReg, mask;
+
+ ASSERT_COND(FmIsMaster(p_FmPcd->h_Fm));
+ event = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eevr);
+ mask = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eier);
+
+ event &= mask;
+
+ /* clear the forced events */
+ force = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eifr);
+ if (force & event)
+ WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eifr, force & ~event);
+
+ WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_eevr, event);
+
+ if (event & FM_PCD_PLCR_DOUBLE_ECC)
+ p_FmPcd->f_Exception(p_FmPcd->h_App,e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC);
+ if (event & FM_PCD_PLCR_INIT_ENTRY_ERROR)
+ {
+ captureReg = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_upcr);
+ /*ASSERT_COND(captureReg & PLCR_ERR_UNINIT_CAP);
+ p_UnInitCapt->profileNum = (uint8_t)(captureReg & PLCR_ERR_UNINIT_NUM_MASK);
+ p_UnInitCapt->portId = (uint8_t)((captureReg & PLCR_ERR_UNINIT_PID_MASK) >>PLCR_ERR_UNINIT_PID_SHIFT) ;
+ p_UnInitCapt->absolute = (bool)(captureReg & PLCR_ERR_UNINIT_ABSOLUTE_MASK);*/
+ p_FmPcd->f_FmPcdIndexedException(p_FmPcd->h_App,e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR,(uint16_t)(captureReg & PLCR_ERR_UNINIT_NUM_MASK));
+ WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_upcr, PLCR_ERR_UNINIT_CAP);
+ }
+}
+
+
+/*****************************************************************************/
+/* Inter-module API routines */
+/*****************************************************************************/
+
t_Handle PlcrConfig(t_FmPcd *p_FmPcd, t_FmPcdParams *p_FmPcdParams)
{
t_FmPcdPlcr *p_FmPcdPlcr;
- /*uint8_t i=0;*/
+ uint16_t i=0;
UNUSED(p_FmPcd);
UNUSED(p_FmPcdParams);
@@ -888,14 +687,24 @@ t_Handle PlcrConfig(t_FmPcd *p_FmPcd, t_FmPcdParams *p_FmPcdParams)
return NULL;
}
memset(p_FmPcdPlcr, 0, sizeof(t_FmPcdPlcr));
- if(p_FmPcd->guestId == NCSW_MASTER_ID)
+ if (p_FmPcd->guestId == NCSW_MASTER_ID)
{
p_FmPcdPlcr->p_FmPcdPlcrRegs = (t_FmPcdPlcrRegs *)UINT_TO_PTR(FmGetPcdPlcrBaseAddr(p_FmPcdParams->h_Fm));
p_FmPcd->p_FmPcdDriverParam->plcrAutoRefresh = DEFAULT_plcrAutoRefresh;
p_FmPcd->exceptions |= (DEFAULT_fmPcdPlcrExceptions | DEFAULT_fmPcdPlcrErrorExceptions);
}
- p_FmPcdPlcr->numOfSharedProfiles = DEFAULT_numOfSharedPlcrProfiles;
+ p_FmPcdPlcr->numOfSharedProfiles = DEFAULT_numOfSharedPlcrProfiles;
+
+ p_FmPcdPlcr->partPlcrProfilesBase = p_FmPcdParams->partPlcrProfilesBase;
+ p_FmPcdPlcr->partNumOfPlcrProfiles = p_FmPcdParams->partNumOfPlcrProfiles;
+ /* for backward compatabilty. if no policer profile, will set automatically to the max */
+ if ((p_FmPcd->guestId == NCSW_MASTER_ID) &&
+ (p_FmPcdPlcr->partNumOfPlcrProfiles == 0))
+ p_FmPcdPlcr->partNumOfPlcrProfiles = FM_PCD_PLCR_NUM_ENTRIES;
+
+ for (i=0; i<FM_PCD_PLCR_NUM_ENTRIES; i++)
+ p_FmPcdPlcr->profiles[i].profilesMng.ownerId = (uint8_t)ILLEGAL_BASE;
return p_FmPcdPlcr;
}
@@ -904,68 +713,47 @@ t_Error PlcrInit(t_FmPcd *p_FmPcd)
{
t_FmPcdDriverParam *p_Param = p_FmPcd->p_FmPcdDriverParam;
t_FmPcdPlcr *p_FmPcdPlcr = p_FmPcd->p_FmPcdPlcr;
- uint32_t tmpReg32 = 0;
- t_Error err = E_OK;
t_FmPcdPlcrRegs *p_Regs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
- t_FmPcdIpcMsg msg;
- uint32_t replyLength;
- t_FmPcdIpcReply reply;
+ t_Error err = E_OK;
+ uint32_t tmpReg32 = 0;
+ uint16_t base;
- if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
- (p_FmPcdPlcr->numOfSharedProfiles))
- {
- int i, j, index = 0;
- uint32_t walking1Mask = 0x80000000;
- uint32_t sharedProfilesMask[FM_PCD_PLCR_NUM_ENTRIES/32];
+ if ((p_FmPcdPlcr->partPlcrProfilesBase + p_FmPcdPlcr->partNumOfPlcrProfiles) > FM_PCD_PLCR_NUM_ENTRIES)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("partPlcrProfilesBase+partNumOfPlcrProfiles out of range!!!"));
- memset(sharedProfilesMask, 0, FM_PCD_PLCR_NUM_ENTRIES/32 * sizeof(uint32_t));
- memset(&reply, 0, sizeof(reply));
- memset(&msg, 0, sizeof(msg));
- msg.msgId = FM_PCD_ALLOC_SHARED_PROFILES;
- memcpy(msg.msgBody, (uint8_t *)&p_FmPcdPlcr->numOfSharedProfiles, sizeof(uint16_t));
- replyLength = sizeof(uint32_t) + sizeof(sharedProfilesMask);
- if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
- (uint8_t*)&msg,
- sizeof(msg.msgId)+ sizeof(p_FmPcdPlcr->numOfSharedProfiles),
- (uint8_t*)&reply,
- &replyLength,
- NULL,
- NULL)) != E_OK)
- RETURN_ERROR(MAJOR, err,NO_MSG);
- if (replyLength != (sizeof(uint32_t) + sizeof(sharedProfilesMask)))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
+ p_FmPcdPlcr->h_HwSpinlock = XX_InitSpinlock();
+ if (!p_FmPcdPlcr->h_HwSpinlock)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("FM Policer HW spinlock"));
- memcpy(sharedProfilesMask, reply.replyBody, sizeof(sharedProfilesMask));
- /* translate 8 regs of 32 bits masks into an array of up to 256 indexes. */
- for(i = 0; i<FM_PCD_PLCR_NUM_ENTRIES/32 ; i++)
- {
- if(sharedProfilesMask[i])
- {
- for(j = 0 ; j<32 ; j++)
- {
- if(sharedProfilesMask[i] & walking1Mask)
- p_FmPcd->p_FmPcdPlcr->sharedProfilesIds[index++] = (uint16_t)(i*32+j);
- walking1Mask >>= 1;
- }
- walking1Mask = 0x80000000;
- }
- }
- return (t_Error)reply.error;
- }
+ p_FmPcdPlcr->h_SwSpinlock = XX_InitSpinlock();
+ if (!p_FmPcdPlcr->h_SwSpinlock)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("FM Policer SW spinlock"));
+
+ base = PlcrAllocProfilesForPartition(p_FmPcd,
+ p_FmPcdPlcr->partPlcrProfilesBase,
+ p_FmPcdPlcr->partNumOfPlcrProfiles,
+ p_FmPcd->guestId);
+ if (base == (uint16_t)ILLEGAL_BASE)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
- if(p_FmPcdPlcr->numOfSharedProfiles)
+ if (p_FmPcdPlcr->numOfSharedProfiles)
{
- err = PlcrAllocSharedProfiles(p_FmPcd, p_FmPcdPlcr->numOfSharedProfiles, p_FmPcd->p_FmPcdPlcr->sharedProfilesIds);
- if(err)
+ err = AllocSharedProfiles(p_FmPcd,
+ p_FmPcdPlcr->numOfSharedProfiles,
+ p_FmPcdPlcr->sharedProfilesIds);
+ if (err)
RETURN_ERROR(MAJOR, err,NO_MSG);
}
+ if (p_FmPcd->guestId != NCSW_MASTER_ID)
+ return E_OK;
+
/**********************FMPL_GCR******************/
tmpReg32 = 0;
tmpReg32 |= FM_PCD_PLCR_GCR_STEN;
- if(p_Param->plcrAutoRefresh)
+ if (p_Param->plcrAutoRefresh)
tmpReg32 |= FM_PCD_PLCR_GCR_DAR;
- tmpReg32 |= NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME;
+ tmpReg32 |= GET_NIA_BMI_AC_ENQ_FRAME(p_FmPcd);
WRITE_UINT32(p_Regs->fmpl_gcr, tmpReg32);
/**********************FMPL_GCR******************/
@@ -975,12 +763,12 @@ t_Error PlcrInit(t_FmPcd *p_FmPcd)
/**********************FMPL_EEVR******************/
/**********************FMPL_EIER******************/
tmpReg32 = 0;
- if(p_FmPcd->exceptions & FM_PCD_EX_PLCR_DOUBLE_ECC)
+ if (p_FmPcd->exceptions & FM_PCD_EX_PLCR_DOUBLE_ECC)
{
FmEnableRamsEcc(p_FmPcd->h_Fm);
tmpReg32 |= FM_PCD_PLCR_DOUBLE_ECC;
}
- if(p_FmPcd->exceptions & FM_PCD_EX_PLCR_INIT_ENTRY_ERROR)
+ if (p_FmPcd->exceptions & FM_PCD_EX_PLCR_INIT_ENTRY_ERROR)
tmpReg32 |= FM_PCD_PLCR_INIT_ENTRY_ERROR;
WRITE_UINT32(p_Regs->fmpl_eier, tmpReg32);
/**********************FMPL_EIER******************/
@@ -990,16 +778,26 @@ t_Error PlcrInit(t_FmPcd *p_FmPcd)
/**********************FMPL_EVR******************/
/**********************FMPL_IER******************/
tmpReg32 = 0;
- if(p_FmPcd->exceptions & FM_PCD_EX_PLCR_PRAM_SELF_INIT_COMPLETE)
+ if (p_FmPcd->exceptions & FM_PCD_EX_PLCR_PRAM_SELF_INIT_COMPLETE)
tmpReg32 |= FM_PCD_PLCR_PRAM_SELF_INIT_COMPLETE;
- if(p_FmPcd->exceptions & FM_PCD_EX_PLCR_ATOMIC_ACTION_COMPLETE )
+ if (p_FmPcd->exceptions & FM_PCD_EX_PLCR_ATOMIC_ACTION_COMPLETE)
tmpReg32 |= FM_PCD_PLCR_ATOMIC_ACTION_COMPLETE;
WRITE_UINT32(p_Regs->fmpl_ier, tmpReg32);
/**********************FMPL_IER******************/
/* register even if no interrupts enabled, to allow future enablement */
- FmRegisterIntr(p_FmPcd->h_Fm, e_FM_MOD_PLCR, 0, e_FM_INTR_TYPE_ERR, PcdPlcrErrorException, p_FmPcd);
- FmRegisterIntr(p_FmPcd->h_Fm, e_FM_MOD_PLCR, 0, e_FM_INTR_TYPE_NORMAL, PcdPlcrException, p_FmPcd);
+ FmRegisterIntr(p_FmPcd->h_Fm,
+ e_FM_MOD_PLCR,
+ 0,
+ e_FM_INTR_TYPE_ERR,
+ ErrorExceptionsCB,
+ p_FmPcd);
+ FmRegisterIntr(p_FmPcd->h_Fm,
+ e_FM_MOD_PLCR,
+ 0,
+ e_FM_INTR_TYPE_NORMAL,
+ EventsCB,
+ p_FmPcd);
/* driver initializes one DFLT profile at the last entry*/
/**********************FMPL_DPMR******************/
@@ -1012,49 +810,542 @@ t_Error PlcrInit(t_FmPcd *p_FmPcd)
t_Error PlcrFree(t_FmPcd *p_FmPcd)
{
- t_Error err;
- t_FmPcdIpcSharedPlcrAllocParams ipcSharedPlcrParams;
- t_FmPcdIpcMsg msg;
-
FmUnregisterIntr(p_FmPcd->h_Fm, e_FM_MOD_PLCR, 0, e_FM_INTR_TYPE_ERR);
FmUnregisterIntr(p_FmPcd->h_Fm, e_FM_MOD_PLCR, 0, e_FM_INTR_TYPE_NORMAL);
- if(p_FmPcd->p_FmPcdPlcr->numOfSharedProfiles)
+ if (p_FmPcd->p_FmPcdPlcr->numOfSharedProfiles)
+ FreeSharedProfiles(p_FmPcd,
+ p_FmPcd->p_FmPcdPlcr->numOfSharedProfiles,
+ p_FmPcd->p_FmPcdPlcr->sharedProfilesIds);
+
+ if (p_FmPcd->p_FmPcdPlcr->partNumOfPlcrProfiles)
+ PlcrFreeProfilesForPartition(p_FmPcd,
+ p_FmPcd->p_FmPcdPlcr->partPlcrProfilesBase,
+ p_FmPcd->p_FmPcdPlcr->partNumOfPlcrProfiles,
+ p_FmPcd->guestId);
+
+ if (p_FmPcd->p_FmPcdPlcr->h_SwSpinlock)
+ XX_FreeSpinlock(p_FmPcd->p_FmPcdPlcr->h_SwSpinlock);
+
+ if (p_FmPcd->p_FmPcdPlcr->h_HwSpinlock)
+ XX_FreeSpinlock(p_FmPcd->p_FmPcdPlcr->h_HwSpinlock);
+
+ return E_OK;
+}
+
+void PlcrEnable(t_FmPcd *p_FmPcd)
+{
+ t_FmPcdPlcrRegs *p_Regs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
+
+ WRITE_UINT32(p_Regs->fmpl_gcr, GET_UINT32(p_Regs->fmpl_gcr) | FM_PCD_PLCR_GCR_EN);
+}
+
+void PlcrDisable(t_FmPcd *p_FmPcd)
+{
+ t_FmPcdPlcrRegs *p_Regs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
+
+ WRITE_UINT32(p_Regs->fmpl_gcr, GET_UINT32(p_Regs->fmpl_gcr) & ~FM_PCD_PLCR_GCR_EN);
+}
+
+uint16_t PlcrAllocProfilesForPartition(t_FmPcd *p_FmPcd, uint16_t base, uint16_t numOfProfiles, uint8_t guestId)
+{
+ uint32_t intFlags;
+ uint16_t profilesFound = 0;
+ int i = 0;
+
+ ASSERT_COND(p_FmPcd);
+ ASSERT_COND(p_FmPcd->p_FmPcdPlcr);
+
+ if (!numOfProfiles)
+ return 0;
+
+ if ((numOfProfiles > FM_PCD_PLCR_NUM_ENTRIES) ||
+ (base + numOfProfiles > FM_PCD_PLCR_NUM_ENTRIES))
+ return (uint16_t)ILLEGAL_BASE;
+
+ if (p_FmPcd->h_IpcSession)
{
- if(p_FmPcd->guestId != NCSW_MASTER_ID)
+ t_FmIpcResourceAllocParams ipcAllocParams;
+ t_FmPcdIpcMsg msg;
+ t_FmPcdIpcReply reply;
+ t_Error err;
+ uint32_t replyLength;
+
+ memset(&msg, 0, sizeof(msg));
+ memset(&reply, 0, sizeof(reply));
+ memset(&ipcAllocParams, 0, sizeof(t_FmIpcResourceAllocParams));
+ ipcAllocParams.guestId = p_FmPcd->guestId;
+ ipcAllocParams.num = p_FmPcd->p_FmPcdPlcr->partNumOfPlcrProfiles;
+ ipcAllocParams.base = p_FmPcd->p_FmPcdPlcr->partPlcrProfilesBase;
+ msg.msgId = FM_PCD_ALLOC_PROFILES;
+ memcpy(msg.msgBody, &ipcAllocParams, sizeof(t_FmIpcResourceAllocParams));
+ replyLength = sizeof(uint32_t) + sizeof(uint16_t);
+ err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
+ (uint8_t*)&msg,
+ sizeof(msg.msgId) + sizeof(t_FmIpcResourceAllocParams),
+ (uint8_t*)&reply,
+ &replyLength,
+ NULL,
+ NULL);
+ if ((err != E_OK) ||
+ (replyLength != (sizeof(uint32_t) + sizeof(uint16_t))))
{
- int i;
- memset(ipcSharedPlcrParams.sharedProfilesMask, 0, sizeof(ipcSharedPlcrParams.sharedProfilesMask));
- /* Free resources using IPC messaging */
- ipcSharedPlcrParams.num = p_FmPcd->p_FmPcdPlcr->numOfSharedProfiles;
-
- /* translate the allocated profile id's to a 32bit * 8regs mask */
- for(i = 0;i<p_FmPcd->p_FmPcdPlcr->numOfSharedProfiles;i++)
- ipcSharedPlcrParams.sharedProfilesMask[p_FmPcd->p_FmPcdPlcr->sharedProfilesIds[i]/32] |= (0x80000000 >> (p_FmPcd->p_FmPcdPlcr->sharedProfilesIds[i] % 32));
-
- memset(&msg, 0, sizeof(msg));
- msg.msgId = FM_PCD_FREE_SHARED_PROFILES;
- memcpy(msg.msgBody, &ipcSharedPlcrParams, sizeof(ipcSharedPlcrParams));
- if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
- (uint8_t*)&msg,
- sizeof(msg.msgId)+sizeof(ipcSharedPlcrParams),
- NULL,
- NULL,
- NULL,
- NULL)) != E_OK)
- RETURN_ERROR(MAJOR, err,NO_MSG);
+ REPORT_ERROR(MAJOR, err, NO_MSG);
+ return (uint16_t)ILLEGAL_BASE;
+ }
+ else
+ memcpy((uint8_t*)&p_FmPcd->p_FmPcdPlcr->partPlcrProfilesBase, reply.replyBody, sizeof(uint16_t));
+ if (p_FmPcd->p_FmPcdPlcr->partPlcrProfilesBase == (uint16_t)ILLEGAL_BASE)
+ {
+ REPORT_ERROR(MAJOR, err, NO_MSG);
+ return (uint16_t)ILLEGAL_BASE;
}
- /* else
- PlcrFreeSharedProfiles(p_FmPcd, p_FmPcd->p_FmPcdPlcr->numOfSharedProfiles, p_FmPcd->p_FmPcdPlcr->sharedProfilesIds);*/
}
+ else if (p_FmPcd->guestId != NCSW_MASTER_ID)
+ {
+ DBG(WARNING, ("FM Guest mode, without IPC - can't validate Policer-profiles range!"));
+ return (uint16_t)ILLEGAL_BASE;
+ }
+
+ intFlags = XX_LockIntrSpinlock(p_FmPcd->h_Spinlock);
+ for (i=base; i<(base+numOfProfiles); i++)
+ if (p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.ownerId == (uint8_t)ILLEGAL_BASE)
+ profilesFound++;
+ else
+ break;
+
+ if (profilesFound == numOfProfiles)
+ for (i=base; i<(base+numOfProfiles); i++)
+ p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.ownerId = guestId;
+ else
+ {
+ XX_UnlockIntrSpinlock(p_FmPcd->h_Spinlock, intFlags);
+ return (uint16_t)ILLEGAL_BASE;
+ }
+ XX_UnlockIntrSpinlock(p_FmPcd->h_Spinlock, intFlags);
+
+ return base;
+}
+
+void PlcrFreeProfilesForPartition(t_FmPcd *p_FmPcd, uint16_t base, uint16_t numOfProfiles, uint8_t guestId)
+{
+ int i = 0;
+
+ ASSERT_COND(p_FmPcd);
+ ASSERT_COND(p_FmPcd->p_FmPcdPlcr);
+
+ if (p_FmPcd->h_IpcSession)
+ {
+ t_FmIpcResourceAllocParams ipcAllocParams;
+ t_FmPcdIpcMsg msg;
+ t_Error err;
+
+ memset(&msg, 0, sizeof(msg));
+ memset(&ipcAllocParams, 0, sizeof(t_FmIpcResourceAllocParams));
+ ipcAllocParams.guestId = p_FmPcd->guestId;
+ ipcAllocParams.num = p_FmPcd->p_FmPcdPlcr->partNumOfPlcrProfiles;
+ ipcAllocParams.base = p_FmPcd->p_FmPcdPlcr->partPlcrProfilesBase;
+ msg.msgId = FM_PCD_FREE_PROFILES;
+ memcpy(msg.msgBody, &ipcAllocParams, sizeof(t_FmIpcResourceAllocParams));
+ err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
+ (uint8_t*)&msg,
+ sizeof(msg.msgId) + sizeof(t_FmIpcResourceAllocParams),
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ if (err != E_OK)
+ REPORT_ERROR(MAJOR, err, NO_MSG);
+ return;
+ }
+ else if (p_FmPcd->guestId != NCSW_MASTER_ID)
+ {
+ DBG(WARNING, ("FM Guest mode, without IPC - can't validate Policer-profiles range!"));
+ return;
+ }
+
+ for (i=base; i<(base+numOfProfiles); i++)
+ {
+ if (p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.ownerId == guestId)
+ p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.ownerId = (uint8_t)ILLEGAL_BASE;
+ else
+ DBG(WARNING, ("Request for freeing storage profile window which wasn't allocated to this partition"));
+ }
+}
+
+t_Error PlcrSetPortProfiles(t_FmPcd *p_FmPcd,
+ uint8_t hardwarePortId,
+ uint16_t numOfProfiles,
+ uint16_t base)
+{
+ t_FmPcdPlcrRegs *p_Regs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
+ uint32_t log2Num, tmpReg32;
+
+ if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
+ !p_Regs &&
+ p_FmPcd->h_IpcSession)
+ {
+ t_FmIpcResourceAllocParams ipcAllocParams;
+ t_FmPcdIpcMsg msg;
+ t_Error err;
+
+ memset(&msg, 0, sizeof(msg));
+ memset(&ipcAllocParams, 0, sizeof(t_FmIpcResourceAllocParams));
+ ipcAllocParams.guestId = hardwarePortId;
+ ipcAllocParams.num = numOfProfiles;
+ ipcAllocParams.base = base;
+ msg.msgId = FM_PCD_SET_PORT_PROFILES;
+ memcpy(msg.msgBody, &ipcAllocParams, sizeof(t_FmIpcResourceAllocParams));
+ err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
+ (uint8_t*)&msg,
+ sizeof(msg.msgId) + sizeof(t_FmIpcResourceAllocParams),
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ if (err != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ return E_OK;
+ }
+ else if (!p_Regs)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("Either IPC or 'baseAddress' is required!"));
+
+ ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
+
+ if (GET_UINT32(p_Regs->fmpl_pmr[hardwarePortId-1]) & FM_PCD_PLCR_PMR_V)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("The requesting port has already an allocated profiles window."));
+
+ /**********************FMPL_PMRx******************/
+ LOG2((uint64_t)numOfProfiles, log2Num);
+ tmpReg32 = base;
+ tmpReg32 |= log2Num << 16;
+ tmpReg32 |= FM_PCD_PLCR_PMR_V;
+ WRITE_UINT32(p_Regs->fmpl_pmr[hardwarePortId-1], tmpReg32);
+
+ return E_OK;
+}
+
+t_Error PlcrClearPortProfiles(t_FmPcd *p_FmPcd, uint8_t hardwarePortId)
+{
+ t_FmPcdPlcrRegs *p_Regs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
+
+ if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
+ !p_Regs &&
+ p_FmPcd->h_IpcSession)
+ {
+ t_FmIpcResourceAllocParams ipcAllocParams;
+ t_FmPcdIpcMsg msg;
+ t_Error err;
+
+ memset(&msg, 0, sizeof(msg));
+ memset(&ipcAllocParams, 0, sizeof(t_FmIpcResourceAllocParams));
+ ipcAllocParams.guestId = hardwarePortId;
+ msg.msgId = FM_PCD_CLEAR_PORT_PROFILES;
+ memcpy(msg.msgBody, &ipcAllocParams, sizeof(t_FmIpcResourceAllocParams));
+ err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
+ (uint8_t*)&msg,
+ sizeof(msg.msgId) + sizeof(t_FmIpcResourceAllocParams),
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ if (err != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ return E_OK;
+ }
+ else if (!p_Regs)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("Either IPC or 'baseAddress' is required!"));
+
+ ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
+ WRITE_UINT32(p_Regs->fmpl_pmr[hardwarePortId-1], 0);
+
return E_OK;
}
-t_Error FmPcdPlcrGetAbsoluteProfileId(t_Handle h_FmPcd,
- e_FmPcdProfileTypeSelection profileType,
- t_Handle h_FmPort,
- uint16_t relativeProfile,
- uint16_t *p_AbsoluteId)
+t_Error FmPcdPlcrAllocProfiles(t_Handle h_FmPcd, uint8_t hardwarePortId, uint16_t numOfProfiles)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_Error err = E_OK;
+ uint32_t profilesFound;
+ uint32_t intFlags;
+ uint16_t i, first, swPortIndex = 0;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+
+ if (!numOfProfiles)
+ return E_OK;
+
+ ASSERT_COND(hardwarePortId);
+
+ if (numOfProfiles>FM_PCD_PLCR_NUM_ENTRIES)
+ RETURN_ERROR(MINOR, E_INVALID_VALUE, ("numProfiles is too big."));
+
+ if (!POWER_OF_2(numOfProfiles))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numProfiles must be a power of 2."));
+
+ first = 0;
+ profilesFound = 0;
+ intFlags = PlcrSwLock(p_FmPcd->p_FmPcdPlcr);
+
+ for (i=0; i<FM_PCD_PLCR_NUM_ENTRIES; )
+ {
+ if (!p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.allocated)
+ {
+ profilesFound++;
+ i++;
+ if (profilesFound == numOfProfiles)
+ break;
+ }
+ else
+ {
+ profilesFound = 0;
+ /* advance i to the next aligned address */
+ i = first = (uint16_t)(first + numOfProfiles);
+ }
+ }
+
+ if (profilesFound == numOfProfiles)
+ {
+ for (i=first; i<first + numOfProfiles; i++)
+ {
+ p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.allocated = TRUE;
+ p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.ownerId = hardwarePortId;
+ }
+ }
+ else
+ {
+ PlcrSwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
+ RETURN_ERROR(MINOR, E_FULL, ("No profiles."));
+ }
+ PlcrSwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
+
+ err = PlcrSetPortProfiles(p_FmPcd, hardwarePortId, numOfProfiles, first);
+ if (err)
+ {
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+
+ HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId);
+
+ p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].numOfProfiles = numOfProfiles;
+ p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].profilesBase = first;
+
+ return E_OK;
+}
+
+t_Error FmPcdPlcrFreeProfiles(t_Handle h_FmPcd, uint8_t hardwarePortId)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_Error err = E_OK;
+ uint32_t intFlags;
+ uint16_t i, swPortIndex = 0;
+
+ ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
+
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_HANDLE);
+
+ HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId);
+
+ err = PlcrClearPortProfiles(p_FmPcd, hardwarePortId);
+ if (err)
+ RETURN_ERROR(MAJOR, err,NO_MSG);
+
+ intFlags = PlcrSwLock(p_FmPcd->p_FmPcdPlcr);
+ for (i=p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].profilesBase;
+ i<(p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].profilesBase +
+ p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].numOfProfiles);
+ i++)
+ {
+ ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.ownerId == hardwarePortId);
+ ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.allocated);
+
+ p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.allocated = FALSE;
+ p_FmPcd->p_FmPcdPlcr->profiles[i].profilesMng.ownerId = p_FmPcd->guestId;
+ }
+ PlcrSwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
+
+ p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].numOfProfiles = 0;
+ p_FmPcd->p_FmPcdPlcr->portsMapping[swPortIndex].profilesBase = 0;
+
+ return E_OK;
+}
+
+t_Error FmPcdPlcrCcGetSetParams(t_Handle h_FmPcd, uint16_t profileIndx ,uint32_t requiredAction)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
+ t_FmPcdPlcr *p_FmPcdPlcr = p_FmPcd->p_FmPcdPlcr;
+ t_FmPcdPlcrRegs *p_FmPcdPlcrRegs = p_FmPcdPlcr->p_FmPcdPlcrRegs;
+ uint32_t tmpReg32, intFlags;
+ t_Error err;
+
+ /* Calling function locked all PCD modules, so no need to lock here */
+
+ if (profileIndx >= FM_PCD_PLCR_NUM_ENTRIES)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,("Policer profile out of range"));
+
+ if (!FmPcdPlcrIsProfileValid(p_FmPcd, profileIndx))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,("Policer profile is not valid"));
+
+ /*intFlags = PlcrProfileLock(&p_FmPcd->p_FmPcdPlcr->profiles[profileIndx]);*/
+
+ if (p_FmPcd->h_Hc)
+ {
+ err = FmHcPcdPlcrCcGetSetParams(p_FmPcd->h_Hc, profileIndx, requiredAction);
+
+ UpdateRequiredActionFlag(p_FmPcd, profileIndx, TRUE);
+ FmPcdPlcrUpdateRequiredAction(p_FmPcd, profileIndx, requiredAction);
+
+ /*PlcrProfileUnlock(&p_FmPcd->p_FmPcdPlcr->profiles[profileIndx], intFlags);*/
+ return err;
+ }
+
+ /* lock the HW because once we read the registers we don't want them to be changed
+ * by another access. (We can copy to a tmp location and release the lock!) */
+
+ intFlags = PlcrHwLock(p_FmPcdPlcr);
+ WritePar(p_FmPcd, FmPcdPlcrBuildReadPlcrActionReg(profileIndx));
+
+ if (!p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].requiredActionFlag ||
+ !(p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].requiredAction & requiredAction))
+ {
+ if (requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)
+ {
+ if ((p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].nextEngineOnGreen!= e_FM_PCD_DONE) ||
+ (p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].nextEngineOnYellow!= e_FM_PCD_DONE) ||
+ (p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].nextEngineOnRed!= e_FM_PCD_DONE))
+ {
+ PlcrHwUnlock(p_FmPcdPlcr, intFlags);
+ /*PlcrProfileUnlock(&p_FmPcd->p_FmPcdPlcr->profiles[profileIndx], intFlags);*/
+ RETURN_ERROR (MAJOR, E_OK, ("In this case the next engine can be e_FM_PCD_DONE"));
+ }
+
+ if (p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].paramsOnGreen.action == e_FM_PCD_ENQ_FRAME)
+ {
+ tmpReg32 = GET_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pegnia);
+ if (!(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)))
+ {
+ PlcrHwUnlock(p_FmPcdPlcr, intFlags);
+ /*PlcrProfileUnlock(&p_FmPcd->p_FmPcdPlcr->profiles[profileIndx], intFlags);*/
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next engine of this policer profile has to be assigned to FM_PCD_DONE"));
+ }
+ tmpReg32 |= NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
+ WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pegnia, tmpReg32);
+ tmpReg32 = FmPcdPlcrBuildWritePlcrActionReg(profileIndx);
+ tmpReg32 |= FM_PCD_PLCR_PAR_PWSEL_PEGNIA;
+ WritePar(p_FmPcd, tmpReg32);
+ }
+
+ if (p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].paramsOnYellow.action == e_FM_PCD_ENQ_FRAME)
+ {
+ tmpReg32 = GET_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_peynia);
+ if (!(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)))
+ {
+ PlcrHwUnlock(p_FmPcdPlcr, intFlags);
+ /*PlcrProfileUnlock(&p_FmPcd->p_FmPcdPlcr->profiles[profileIndx], intFlags);*/
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next engine of this policer profile has to be assigned to FM_PCD_DONE"));
+ }
+ tmpReg32 |= NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
+ WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_peynia, tmpReg32);
+ tmpReg32 = FmPcdPlcrBuildWritePlcrActionReg(profileIndx);
+ tmpReg32 |= FM_PCD_PLCR_PAR_PWSEL_PEYNIA;
+ WritePar(p_FmPcd, tmpReg32);
+ PlcrHwUnlock(p_FmPcdPlcr, intFlags);
+ }
+
+ if (p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].paramsOnRed.action == e_FM_PCD_ENQ_FRAME)
+ {
+ tmpReg32 = GET_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pernia);
+ if (!(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)))
+ {
+ PlcrHwUnlock(p_FmPcdPlcr, intFlags);
+ /*PlcrProfileUnlock(&p_FmPcd->p_FmPcdPlcr->profiles[profileIndx], intFlags);*/
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next engine of this policer profile has to be assigned to FM_PCD_DONE"));
+ }
+ tmpReg32 |= NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
+ WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pernia, tmpReg32);
+ tmpReg32 = FmPcdPlcrBuildWritePlcrActionReg(profileIndx);
+ tmpReg32 |= FM_PCD_PLCR_PAR_PWSEL_PERNIA;
+ WritePar(p_FmPcd, tmpReg32);
+
+ }
+ }
+ }
+ PlcrHwUnlock(p_FmPcdPlcr, intFlags);
+
+ UpdateRequiredActionFlag(p_FmPcd, profileIndx, TRUE);
+ FmPcdPlcrUpdateRequiredAction(p_FmPcd, profileIndx, requiredAction);
+
+ /*PlcrProfileUnlock(&p_FmPcd->p_FmPcdPlcr->profiles[profileIndx], intFlags);*/
+
+ return E_OK;
+}
+
+uint32_t FmPcdPlcrGetRequiredActionFlag(t_Handle h_FmPcd, uint16_t absoluteProfileId)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+
+ ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid);
+
+ return p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].requiredActionFlag;
+}
+
+uint32_t FmPcdPlcrGetRequiredAction(t_Handle h_FmPcd, uint16_t absoluteProfileId)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+
+ ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid);
+
+ return p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].requiredAction;
+}
+
+bool FmPcdPlcrIsProfileValid(t_Handle h_FmPcd, uint16_t absoluteProfileId)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_FmPcdPlcr *p_FmPcdPlcr = p_FmPcd->p_FmPcdPlcr;
+
+ ASSERT_COND(absoluteProfileId < FM_PCD_PLCR_NUM_ENTRIES);
+
+ return p_FmPcdPlcr->profiles[absoluteProfileId].valid;
+}
+
+void FmPcdPlcrValidateProfileSw(t_Handle h_FmPcd, uint16_t absoluteProfileId)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ uint32_t intFlags;
+
+ ASSERT_COND(!p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid);
+
+ intFlags = PlcrProfileLock(&p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId]);
+ p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid = TRUE;
+ PlcrProfileUnlock(&p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId], intFlags);
+}
+
+void FmPcdPlcrInvalidateProfileSw(t_Handle h_FmPcd, uint16_t absoluteProfileId)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ uint32_t intFlags;
+
+ ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid);
+
+ intFlags = PlcrProfileLock(&p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId]);
+ p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid = FALSE;
+ PlcrProfileUnlock(&p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId], intFlags);
+}
+
+uint16_t FmPcdPlcrProfileGetAbsoluteId(t_Handle h_Profile)
+{
+ return ((t_FmPcdPlcrProfile*)h_Profile)->absoluteProfileId;
+}
+
+t_Error FmPcdPlcrGetAbsoluteIdByProfileParams(t_Handle h_FmPcd,
+ e_FmPcdProfileTypeSelection profileType,
+ t_Handle h_FmPort,
+ uint16_t relativeProfile,
+ uint16_t *p_AbsoluteId)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
t_FmPcdPlcr *p_FmPcdPlcr = p_FmPcd->p_FmPcdPlcr;
@@ -1064,26 +1355,27 @@ t_Error FmPcdPlcrGetAbsoluteProfileId(t_Handle h_FmPcd,
{
case e_FM_PCD_PLCR_PORT_PRIVATE:
/* get port PCD id from port handle */
- for(i=0;i<FM_MAX_NUM_OF_PORTS;i++)
- if(p_FmPcd->p_FmPcdPlcr->portsMapping[i].h_FmPort == h_FmPort)
+ for (i=0;i<FM_MAX_NUM_OF_PORTS;i++)
+ if (p_FmPcd->p_FmPcdPlcr->portsMapping[i].h_FmPort == h_FmPort)
break;
if (i == FM_MAX_NUM_OF_PORTS)
RETURN_ERROR(MAJOR, E_INVALID_STATE , ("Invalid port handle."));
- if(!p_FmPcd->p_FmPcdPlcr->portsMapping[i].numOfProfiles)
+ if (!p_FmPcd->p_FmPcdPlcr->portsMapping[i].numOfProfiles)
RETURN_ERROR(MAJOR, E_INVALID_SELECTION , ("Port has no allocated profiles"));
- if(relativeProfile >= p_FmPcd->p_FmPcdPlcr->portsMapping[i].numOfProfiles)
+ if (relativeProfile >= p_FmPcd->p_FmPcdPlcr->portsMapping[i].numOfProfiles)
RETURN_ERROR(MAJOR, E_INVALID_SELECTION , ("Profile id is out of range"));
*p_AbsoluteId = (uint16_t)(p_FmPcd->p_FmPcdPlcr->portsMapping[i].profilesBase + relativeProfile);
break;
case e_FM_PCD_PLCR_SHARED:
- if(relativeProfile >= p_FmPcdPlcr->numOfSharedProfiles)
+ if (relativeProfile >= p_FmPcdPlcr->numOfSharedProfiles)
RETURN_ERROR(MAJOR, E_INVALID_SELECTION , ("Profile id is out of range"));
*p_AbsoluteId = (uint16_t)(p_FmPcdPlcr->sharedProfilesIds[relativeProfile]);
break;
default:
RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Invalid policer profile type"));
}
+
return E_OK;
}
@@ -1123,7 +1415,7 @@ uint32_t FmPcdPlcrBuildWritePlcrActionRegs(uint16_t absoluteProfileId)
bool FmPcdPlcrHwProfileIsValid(uint32_t profileModeReg)
{
- if(profileModeReg & FM_PCD_PLCR_PEMODE_PI)
+ if (profileModeReg & FM_PCD_PLCR_PEMODE_PI)
return TRUE;
else
return FALSE;
@@ -1139,17 +1431,17 @@ uint32_t FmPcdPlcrBuildReadPlcrActionReg(uint16_t absoluteProfileId)
uint32_t FmPcdPlcrBuildCounterProfileReg(e_FmPcdPlcrProfileCounters counter)
{
- switch(counter)
+ switch (counter)
{
- case(e_FM_PCD_PLCR_PROFILE_GREEN_PACKET_TOTAL_COUNTER):
+ case (e_FM_PCD_PLCR_PROFILE_GREEN_PACKET_TOTAL_COUNTER):
return FM_PCD_PLCR_PAR_PWSEL_PEGPC;
- case(e_FM_PCD_PLCR_PROFILE_YELLOW_PACKET_TOTAL_COUNTER):
+ case (e_FM_PCD_PLCR_PROFILE_YELLOW_PACKET_TOTAL_COUNTER):
return FM_PCD_PLCR_PAR_PWSEL_PEYPC;
- case(e_FM_PCD_PLCR_PROFILE_RED_PACKET_TOTAL_COUNTER) :
+ case (e_FM_PCD_PLCR_PROFILE_RED_PACKET_TOTAL_COUNTER) :
return FM_PCD_PLCR_PAR_PWSEL_PERPC;
- case(e_FM_PCD_PLCR_PROFILE_RECOLOURED_YELLOW_PACKET_TOTAL_COUNTER) :
+ case (e_FM_PCD_PLCR_PROFILE_RECOLOURED_YELLOW_PACKET_TOTAL_COUNTER) :
return FM_PCD_PLCR_PAR_PWSEL_PERYPC;
- case(e_FM_PCD_PLCR_PROFILE_RECOLOURED_RED_PACKET_TOTAL_COUNTER) :
+ case (e_FM_PCD_PLCR_PROFILE_RECOLOURED_RED_PACKET_TOTAL_COUNTER) :
return FM_PCD_PLCR_PAR_PWSEL_PERRPC;
default:
REPORT_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
@@ -1162,11 +1454,11 @@ uint32_t FmPcdPlcrBuildNiaProfileReg(bool green, bool yellow, bool red)
uint32_t tmpReg32 = 0;
- if(green)
+ if (green)
tmpReg32 |= FM_PCD_PLCR_PAR_PWSEL_PEGNIA;
- if(yellow)
+ if (yellow)
tmpReg32 |= FM_PCD_PLCR_PAR_PWSEL_PEYNIA;
- if(red)
+ if (red)
tmpReg32 |= FM_PCD_PLCR_PAR_PWSEL_PERNIA;
return tmpReg32;
@@ -1176,127 +1468,199 @@ void FmPcdPlcrUpdateRequiredAction(t_Handle h_FmPcd, uint16_t absoluteProfileId,
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid);
+ /* this routine is protected by calling routine */
+
+ ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].valid);
- p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].requiredAction = requiredAction;
+ p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].requiredAction |= requiredAction;
}
-t_Error FmPcdPlcrProfileTryLock(t_Handle h_FmPcd, uint16_t profileId, bool intr)
+/*********************** End of inter-module routines ************************/
+
+
+/**************************************************/
+/*............Policer API.........................*/
+/**************************************************/
+
+t_Error FM_PCD_ConfigPlcrAutoRefreshMode(t_Handle h_FmPcd, bool enable)
{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- bool ans;
- if (intr)
- ans = TRY_LOCK(NULL, &p_FmPcd->p_FmPcdPlcr->profiles[profileId].lock);
- else
- ans = TRY_LOCK(p_FmPcd->h_Spinlock, &p_FmPcd->p_FmPcdPlcr->profiles[profileId].lock);
- if (ans)
- return E_OK;
- return ERROR_CODE(E_BUSY);
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE);
+
+ if (!FmIsMaster(p_FmPcd->h_Fm))
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_ConfigPlcrAutoRefreshMode - guest mode!"));
+
+ p_FmPcd->p_FmPcdDriverParam->plcrAutoRefresh = enable;
+
+ return E_OK;
}
-void FmPcdPlcrReleaseProfileLock(t_Handle h_FmPcd, uint16_t profileId)
+t_Error FM_PCD_ConfigPlcrNumOfSharedProfiles(t_Handle h_FmPcd, uint16_t numOfSharedPlcrProfiles)
{
- RELEASE_LOCK(((t_FmPcd*)h_FmPcd)->p_FmPcdPlcr->profiles[profileId].lock);
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE);
+
+ p_FmPcd->p_FmPcdPlcr->numOfSharedProfiles = numOfSharedPlcrProfiles;
+
+ return E_OK;
}
-/**************************************************/
-/*............Policer API.........................*/
-/**************************************************/
+t_Error FM_PCD_SetPlcrStatistics(t_Handle h_FmPcd, bool enable)
+{
+ t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ uint32_t tmpReg32;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE);
+
+ if (!FmIsMaster(p_FmPcd->h_Fm))
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_SetPlcrStatistics - guest mode!"));
+
+ tmpReg32 = GET_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_gcr);
+ if (enable)
+ tmpReg32 |= FM_PCD_PLCR_GCR_STEN;
+ else
+ tmpReg32 &= ~FM_PCD_PLCR_GCR_STEN;
-t_Handle FM_PCD_PlcrSetProfile(t_Handle h_FmPcd,
- t_FmPcdPlcrProfileParams *p_Profile)
+ WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_gcr, tmpReg32);
+ return E_OK;
+}
+
+t_Handle FM_PCD_PlcrProfileSet(t_Handle h_FmPcd,
+ t_FmPcdPlcrProfileParams *p_ProfileParams)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ t_FmPcd *p_FmPcd;
t_FmPcdPlcrRegs *p_FmPcdPlcrRegs;
- t_FmPcdPlcrInterModuleProfileRegs plcrProfileReg;
+ t_FmPcdPlcrProfileRegs plcrProfileReg;
uint32_t intFlags;
uint16_t absoluteProfileId;
t_Error err = E_OK;
uint32_t tmpReg32;
+ t_FmPcdPlcrProfile *p_Profile;
- SANITY_CHECK_RETURN_VALUE(p_FmPcd, E_INVALID_HANDLE, NULL);
- SANITY_CHECK_RETURN_VALUE(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE, NULL);
- SANITY_CHECK_RETURN_VALUE(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE, NULL);
-
- if (p_FmPcd->h_Hc)
- return FmHcPcdPlcrSetProfile(p_FmPcd->h_Hc, p_Profile);
-
- p_FmPcdPlcrRegs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
- SANITY_CHECK_RETURN_VALUE(p_FmPcdPlcrRegs, E_INVALID_HANDLE, NULL);
+ SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, NULL);
- if (p_Profile->modify)
+ if (p_ProfileParams->modify)
{
- absoluteProfileId = (uint16_t)(PTR_TO_UINT(p_Profile->id.h_Profile)-1);
+ p_Profile = (t_FmPcdPlcrProfile *)p_ProfileParams->id.h_Profile;
+ p_FmPcd = p_Profile->h_FmPcd;
+ absoluteProfileId = p_Profile->absoluteProfileId;
if (absoluteProfileId >= FM_PCD_PLCR_NUM_ENTRIES)
{
REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("profileId too Big "));
return NULL;
}
- if (FmPcdPlcrProfileTryLock(p_FmPcd, absoluteProfileId, FALSE))
- return NULL;
- }
+
+ SANITY_CHECK_RETURN_VALUE(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE, NULL);
+
+ /* Try lock profile using flag */
+ if (!PlcrProfileFlagTryLock(p_Profile))
+ {
+ DBG(TRACE, ("Profile Try Lock - BUSY"));
+ /* Signal to caller BUSY condition */
+ p_ProfileParams->id.h_Profile = NULL;
+ return NULL;
+ }
+ }
else
{
- intFlags = FmPcdLock(p_FmPcd);
- err = FmPcdPlcrGetAbsoluteProfileId(h_FmPcd,
- p_Profile->id.newParams.profileType,
- p_Profile->id.newParams.h_FmPort,
- p_Profile->id.newParams.relativeProfileId,
- &absoluteProfileId);
- if (absoluteProfileId >= FM_PCD_PLCR_NUM_ENTRIES)
- {
- REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("profileId too Big "));
- return NULL;
- }
- if(err)
- {
- FmPcdUnlock(p_FmPcd, intFlags);
- REPORT_ERROR(MAJOR, err, NO_MSG);
- return NULL;
- }
- err = FmPcdPlcrProfileTryLock(p_FmPcd, absoluteProfileId, TRUE);
- FmPcdUnlock(p_FmPcd, intFlags);
- if (err)
- return NULL;
- }
+ p_FmPcd = (t_FmPcd*)h_FmPcd;
- /* if no override, check first that this profile is unused */
- if(!p_Profile->modify)
- {
- /* read specified profile into profile registers */
- tmpReg32 = FmPcdPlcrBuildReadPlcrActionReg(absoluteProfileId);
- intFlags = FmPcdLock(p_FmPcd);
- WritePar(p_FmPcd, tmpReg32);
- tmpReg32 = GET_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pemode);
- FmPcdUnlock(p_FmPcd, intFlags);
- if (tmpReg32 & FM_PCD_PLCR_PEMODE_PI)
+ SANITY_CHECK_RETURN_VALUE(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE, NULL);
+
+ /* SMP: needs to be protected only if another core now changes the windows */
+ err = FmPcdPlcrGetAbsoluteIdByProfileParams(h_FmPcd,
+ p_ProfileParams->id.newParams.profileType,
+ p_ProfileParams->id.newParams.h_FmPort,
+ p_ProfileParams->id.newParams.relativeProfileId,
+ &absoluteProfileId);
+ if (err)
{
- RELEASE_LOCK(p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].lock);
- REPORT_ERROR(MAJOR, E_ALREADY_EXISTS, ("Policer Profile is already used"));
- return NULL;
+ REPORT_ERROR(MAJOR, err, NO_MSG);
+ return NULL;
}
+
+ if (absoluteProfileId >= FM_PCD_PLCR_NUM_ENTRIES)
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("profileId too Big "));
+ return NULL;
+ }
+
+ if (FmPcdPlcrIsProfileValid(p_FmPcd, absoluteProfileId))
+ {
+ REPORT_ERROR(MAJOR, E_ALREADY_EXISTS, ("Policer Profile is already used"));
+ return NULL;
+ }
+
+ /* initialize profile struct */
+ p_Profile = &p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId];
+
+ p_Profile->h_FmPcd = p_FmPcd;
+ p_Profile->absoluteProfileId = absoluteProfileId;
+
+ p_Profile->p_Lock = FmPcdAcquireLock(p_FmPcd);
+ if (!p_Profile->p_Lock)
+ REPORT_ERROR(MAJOR, E_NOT_AVAILABLE, ("FM Policer Profile lock obj!"));
}
- memset(&plcrProfileReg, 0, sizeof(t_FmPcdPlcrInterModuleProfileRegs));
+ SANITY_CHECK_RETURN_VALUE(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE, NULL);
+
+ p_Profile->nextEngineOnGreen = p_ProfileParams->nextEngineOnGreen;
+ memcpy(&p_Profile->paramsOnGreen, &(p_ProfileParams->paramsOnGreen), sizeof(u_FmPcdPlcrNextEngineParams));
+
+ p_Profile->nextEngineOnYellow = p_ProfileParams->nextEngineOnYellow;
+ memcpy(&p_Profile->paramsOnYellow, &(p_ProfileParams->paramsOnYellow), sizeof(u_FmPcdPlcrNextEngineParams));
+
+ p_Profile->nextEngineOnRed = p_ProfileParams->nextEngineOnRed;
+ memcpy(&p_Profile->paramsOnRed, &(p_ProfileParams->paramsOnRed), sizeof(u_FmPcdPlcrNextEngineParams));
- err = FmPcdPlcrBuildProfile(h_FmPcd, p_Profile, &plcrProfileReg);
- if(err)
+ memset(&plcrProfileReg, 0, sizeof(t_FmPcdPlcrProfileRegs));
+
+ /* build the policer profile registers */
+ err = BuildProfileRegs(h_FmPcd, p_ProfileParams, &plcrProfileReg);
+ if (err)
{
- RELEASE_LOCK(p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].lock);
REPORT_ERROR(MAJOR, err, NO_MSG);
+ if (p_ProfileParams->modify)
+ /* unlock */
+ PlcrProfileFlagUnlock(p_Profile);
+ if (!p_ProfileParams->modify &&
+ p_Profile->p_Lock)
+ /* release allocated Profile lock */
+ FmPcdReleaseLock(p_FmPcd, p_Profile->p_Lock);
return NULL;
}
- p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].nextEngineOnGreen = p_Profile->nextEngineOnGreen;
- memcpy(&p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].paramsOnGreen, &(p_Profile->paramsOnGreen), sizeof(u_FmPcdPlcrNextEngineParams));
-
- p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].nextEngineOnYellow = p_Profile->nextEngineOnYellow;
- memcpy(&p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].paramsOnYellow, &(p_Profile->paramsOnYellow), sizeof(u_FmPcdPlcrNextEngineParams));
+ if (p_FmPcd->h_Hc)
+ {
+ err = FmHcPcdPlcrSetProfile(p_FmPcd->h_Hc, (t_Handle)p_Profile, &plcrProfileReg);
+ if (p_ProfileParams->modify)
+ PlcrProfileFlagUnlock(p_Profile);
+ if (err)
+ {
+ /* release the allocated scheme lock */
+ if (!p_ProfileParams->modify &&
+ p_Profile->p_Lock)
+ FmPcdReleaseLock(p_FmPcd, p_Profile->p_Lock);
+
+ return NULL;
+ }
+ if (!p_ProfileParams->modify)
+ FmPcdPlcrValidateProfileSw(p_FmPcd,absoluteProfileId);
+ return (t_Handle)p_Profile;
+ }
- p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].nextEngineOnRed = p_Profile->nextEngineOnRed;
- memcpy(&p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].paramsOnRed, &(p_Profile->paramsOnRed), sizeof(u_FmPcdPlcrNextEngineParams));
+ p_FmPcdPlcrRegs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
+ SANITY_CHECK_RETURN_VALUE(p_FmPcdPlcrRegs, E_INVALID_HANDLE, NULL);
- intFlags = FmPcdLock(p_FmPcd);
+ intFlags = PlcrHwLock(p_FmPcd->p_FmPcdPlcr);
WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pemode , plcrProfileReg.fmpl_pemode);
WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pegnia , plcrProfileReg.fmpl_pegnia);
WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_peynia , plcrProfileReg.fmpl_peynia);
@@ -1317,55 +1681,75 @@ t_Handle FM_PCD_PlcrSetProfile(t_Handle h_FmPcd,
tmpReg32 = FmPcdPlcrBuildWritePlcrActionRegs(absoluteProfileId);
WritePar(p_FmPcd, tmpReg32);
- FmPcdUnlock(p_FmPcd, intFlags);
+ PlcrHwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
- if (!p_Profile->modify)
+ if (!p_ProfileParams->modify)
FmPcdPlcrValidateProfileSw(p_FmPcd,absoluteProfileId);
+ else
+ PlcrProfileFlagUnlock(p_Profile);
- RELEASE_LOCK(p_FmPcd->p_FmPcdPlcr->profiles[absoluteProfileId].lock);
-
- return UINT_TO_PTR((uint64_t)absoluteProfileId+1);
+ return (t_Handle)p_Profile;
}
-t_Error FM_PCD_PlcrDeleteProfile(t_Handle h_FmPcd, t_Handle h_Profile)
+t_Error FM_PCD_PlcrProfileDelete(t_Handle h_Profile)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint16_t profileIndx = (uint16_t)(PTR_TO_UINT(h_Profile)-1);
- uint32_t tmpReg32, intFlags;
-
+ t_FmPcdPlcrProfile *p_Profile = (t_FmPcdPlcrProfile*)h_Profile;
+ t_FmPcd *p_FmPcd;
+ uint16_t profileIndx;
+ uint32_t tmpReg32, intFlags;
+ t_Error err;
+
+ SANITY_CHECK_RETURN_ERROR(p_Profile, E_INVALID_HANDLE);
+ p_FmPcd = p_Profile->h_FmPcd;
SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR((profileIndx < FM_PCD_PLCR_NUM_ENTRIES), E_INVALID_SELECTION);
- if (p_FmPcd->h_Hc)
- return FmHcPcdPlcrDeleteProfile(p_FmPcd->h_Hc, h_Profile);
+ profileIndx = p_Profile->absoluteProfileId;
+
+ UpdateRequiredActionFlag(p_FmPcd, profileIndx, FALSE);
FmPcdPlcrInvalidateProfileSw(p_FmPcd,profileIndx);
- intFlags = FmPcdLock(p_FmPcd);
+ if (p_FmPcd->h_Hc)
+ {
+ err = FmHcPcdPlcrDeleteProfile(p_FmPcd->h_Hc, h_Profile);
+ if (p_Profile->p_Lock)
+ /* release allocated Profile lock */
+ FmPcdReleaseLock(p_FmPcd, p_Profile->p_Lock);
+
+ return err;
+ }
+
+ intFlags = PlcrHwLock(p_FmPcd->p_FmPcdPlcr);
WRITE_UINT32(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->profileRegs.fmpl_pemode, ~FM_PCD_PLCR_PEMODE_PI);
tmpReg32 = FmPcdPlcrBuildWritePlcrActionRegs(profileIndx);
WritePar(p_FmPcd, tmpReg32);
- FmPcdUnlock(p_FmPcd, intFlags);
+ PlcrHwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
+
+ if (p_Profile->p_Lock)
+ /* release allocated Profile lock */
+ FmPcdReleaseLock(p_FmPcd, p_Profile->p_Lock);
+
+ /* we do not memset profile as all its fields are being re-initialized at "set",
+ * plus its allocation information is still valid. */
return E_OK;
}
-/* ......... */
/***************************************************/
/*............Policer Profile Counter..............*/
/***************************************************/
-uint32_t FM_PCD_PlcrGetProfileCounter(t_Handle h_FmPcd, t_Handle h_Profile, e_FmPcdPlcrProfileCounters counter)
+uint32_t FM_PCD_PlcrProfileGetCounter(t_Handle h_Profile, e_FmPcdPlcrProfileCounters counter)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint16_t profileIndx = (uint16_t)(PTR_TO_UINT(h_Profile)-1);
- t_FmPcdPlcrRegs *p_FmPcdPlcrRegs;
- uint32_t intFlags, counterVal = 0;
-
- SANITY_CHECK_RETURN_VALUE(p_FmPcd, E_INVALID_HANDLE, 0);
- SANITY_CHECK_RETURN_VALUE(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE, 0);
- SANITY_CHECK_RETURN_VALUE(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE, 0);
+ t_FmPcdPlcrProfile *p_Profile = (t_FmPcdPlcrProfile*)h_Profile;
+ t_FmPcd *p_FmPcd;
+ uint16_t profileIndx;
+ uint32_t intFlags, counterVal = 0;
+ t_FmPcdPlcrRegs *p_FmPcdPlcrRegs;
+
+ SANITY_CHECK_RETURN_ERROR(p_Profile, E_INVALID_HANDLE);
+ p_FmPcd = p_Profile->h_FmPcd;
+ SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
if (p_FmPcd->h_Hc)
return FmHcPcdPlcrGetProfileCounter(p_FmPcd->h_Hc, h_Profile, counter);
@@ -1373,21 +1757,16 @@ uint32_t FM_PCD_PlcrGetProfileCounter(t_Handle h_FmPcd, t_Handle h_Profile, e_Fm
p_FmPcdPlcrRegs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
SANITY_CHECK_RETURN_VALUE(p_FmPcdPlcrRegs, E_INVALID_HANDLE, 0);
+ profileIndx = p_Profile->absoluteProfileId;
+
if (profileIndx >= FM_PCD_PLCR_NUM_ENTRIES)
{
REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("profileId too Big "));
return 0;
}
- intFlags = FmPcdLock(p_FmPcd);
+ intFlags = PlcrHwLock(p_FmPcd->p_FmPcdPlcr);
WritePar(p_FmPcd, FmPcdPlcrBuildReadPlcrActionReg(profileIndx));
- if(!FmPcdPlcrHwProfileIsValid(GET_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pemode)))
- {
- REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Uninitialized profile"));
- FmPcdUnlock(p_FmPcd, intFlags);
- return 0;
- }
-
switch (counter)
{
case e_FM_PCD_PLCR_PROFILE_GREEN_PACKET_TOTAL_COUNTER:
@@ -1409,119 +1788,23 @@ uint32_t FM_PCD_PlcrGetProfileCounter(t_Handle h_FmPcd, t_Handle h_Profile, e_Fm
REPORT_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
break;
}
- FmPcdUnlock(p_FmPcd, intFlags);
+ PlcrHwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
return counterVal;
}
-
-t_Error FmPcdPlcrCcGetSetParams(t_Handle h_FmPcd, uint16_t profileIndx ,uint32_t requiredAction)
+t_Error FM_PCD_PlcrProfileSetCounter(t_Handle h_Profile, e_FmPcdPlcrProfileCounters counter, uint32_t value)
{
- t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- t_FmPcdPlcr *p_FmPcdPlcr = p_FmPcd->p_FmPcdPlcr;
- t_FmPcdPlcrRegs *p_FmPcdPlcrRegs = p_FmPcdPlcr->p_FmPcdPlcrRegs;
- uint32_t tmpReg32, intFlags;
-
- if (p_FmPcd->h_Hc)
- return FmHcPcdPlcrCcGetSetParams(p_FmPcd->h_Hc, profileIndx, requiredAction);
-
- if (profileIndx >= FM_PCD_PLCR_NUM_ENTRIES)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE,("Policer profile out of range"));
-
- if (FmPcdPlcrProfileTryLock(p_FmPcd, profileIndx, FALSE))
- RETURN_ERROR(MAJOR, E_INVALID_STATE,("Lock on PP FAILED"));
-
- intFlags = FmPcdLock(p_FmPcd);
- WritePar(p_FmPcd, FmPcdPlcrBuildReadPlcrActionReg(profileIndx));
-
- if(!FmPcdPlcrHwProfileIsValid(GET_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pemode)))
- {
- FmPcdUnlock(p_FmPcd, intFlags);
- RELEASE_LOCK(p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].lock);
- RETURN_ERROR(MAJOR, E_INVALID_VALUE,("Policer profile is not valid"));
- }
-
- ASSERT_COND(p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].valid);
-
- if(!p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].pointedOwners ||
- !(p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].requiredAction & requiredAction))
- {
- if(requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)
- {
- if((p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].nextEngineOnGreen!= e_FM_PCD_DONE) ||
- (p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].nextEngineOnYellow!= e_FM_PCD_DONE) ||
- (p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].nextEngineOnRed!= e_FM_PCD_DONE))
- {
- FmPcdUnlock(p_FmPcd, intFlags);
- RETURN_ERROR (MAJOR, E_OK, ("In this case the next engine can be e_FM_PCD_DONE"));
- }
-
- if(p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].paramsOnGreen.action == e_FM_PCD_ENQ_FRAME)
- {
- tmpReg32 = GET_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pegnia);
- if(!(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)))
- {
- FmPcdUnlock(p_FmPcd, intFlags);
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next engine of this policer profile has to be assigned to FM_PCD_DONE"));
- }
- tmpReg32 |= NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
- WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pegnia, tmpReg32);
- tmpReg32 = FmPcdPlcrBuildWritePlcrActionReg(profileIndx);
- tmpReg32 |= FM_PCD_PLCR_PAR_PWSEL_PEGNIA;
- WritePar(p_FmPcd, tmpReg32);
- }
-
- if(p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].paramsOnYellow.action == e_FM_PCD_ENQ_FRAME)
- {
- tmpReg32 = GET_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_peynia);
- if(!(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)))
- {
- FmPcdUnlock(p_FmPcd, intFlags);
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next engine of this policer profile has to be assigned to FM_PCD_DONE"));
- }
- tmpReg32 |= NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
- WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_peynia, tmpReg32);
- tmpReg32 = FmPcdPlcrBuildWritePlcrActionReg(profileIndx);
- tmpReg32 |= FM_PCD_PLCR_PAR_PWSEL_PEYNIA;
- WritePar(p_FmPcd, tmpReg32);
- }
-
- if(p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].paramsOnRed.action == e_FM_PCD_ENQ_FRAME)
- {
- tmpReg32 = GET_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pernia);
- if(!(tmpReg32 & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)))
- {
- FmPcdUnlock(p_FmPcd, intFlags);
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Next engine of this policer profile has to be assigned to FM_PCD_DONE"));
- }
- tmpReg32 |= NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;
- WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_pernia, tmpReg32);
- tmpReg32 = FmPcdPlcrBuildWritePlcrActionReg(profileIndx);
- tmpReg32 |= FM_PCD_PLCR_PAR_PWSEL_PERNIA;
- WritePar(p_FmPcd, tmpReg32);
- }
- }
- }
- FmPcdUnlock(p_FmPcd, intFlags);
-
- p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].pointedOwners += 1;
- p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].requiredAction |= requiredAction;
-
- RELEASE_LOCK(p_FmPcd->p_FmPcdPlcr->profiles[profileIndx].lock);
-
- return E_OK;
-}
+ t_FmPcdPlcrProfile *p_Profile = (t_FmPcdPlcrProfile*)h_Profile;
+ t_FmPcd *p_FmPcd;
+ uint16_t profileIndx;
+ uint32_t tmpReg32, intFlags;
+ t_FmPcdPlcrRegs *p_FmPcdPlcrRegs;
-t_Error FM_PCD_PlcrSetProfileCounter(t_Handle h_FmPcd, t_Handle h_Profile, e_FmPcdPlcrProfileCounters counter, uint32_t value)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint16_t profileIndx = (uint16_t)(PTR_TO_UINT(h_Profile)-1);
- t_FmPcdPlcrRegs *p_FmPcdPlcrRegs;
- uint32_t tmpReg32, intFlags;
+ SANITY_CHECK_RETURN_ERROR(p_Profile, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE);
+ p_FmPcd = p_Profile->h_FmPcd;
+ profileIndx = p_Profile->absoluteProfileId;
if (p_FmPcd->h_Hc)
return FmHcPcdPlcrSetProfileCounter(p_FmPcd->h_Hc, h_Profile, counter, value);
@@ -1529,7 +1812,7 @@ t_Error FM_PCD_PlcrSetProfileCounter(t_Handle h_FmPcd, t_Handle h_Profile, e_FmP
p_FmPcdPlcrRegs = p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs;
SANITY_CHECK_RETURN_ERROR(p_FmPcdPlcrRegs, E_INVALID_HANDLE);
- intFlags = FmPcdLock(p_FmPcd);
+ intFlags = PlcrHwLock(p_FmPcd->p_FmPcdPlcr);
switch (counter)
{
case e_FM_PCD_PLCR_PROFILE_GREEN_PACKET_TOTAL_COUNTER:
@@ -1548,6 +1831,7 @@ t_Error FM_PCD_PlcrSetProfileCounter(t_Handle h_FmPcd, t_Handle h_Profile, e_FmP
WRITE_UINT32(p_FmPcdPlcrRegs->profileRegs.fmpl_perrpc ,value);
break;
default:
+ PlcrHwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
}
@@ -1557,146 +1841,7 @@ t_Error FM_PCD_PlcrSetProfileCounter(t_Handle h_FmPcd, t_Handle h_Profile, e_FmP
tmpReg32 = FmPcdPlcrBuildWritePlcrActionReg(profileIndx);
tmpReg32 |= FmPcdPlcrBuildCounterProfileReg(counter);
WritePar(p_FmPcd, tmpReg32);
- FmPcdUnlock(p_FmPcd, intFlags);
-
- return E_OK;
-}
-
-t_Error FM_PCD_ConfigPlcrNumOfSharedProfiles(t_Handle h_FmPcd, uint16_t numOfSharedPlcrProfiles)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
-
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdDriverParam, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE);
-
- p_FmPcd->p_FmPcdPlcr->numOfSharedProfiles = numOfSharedPlcrProfiles;
+ PlcrHwUnlock(p_FmPcd->p_FmPcdPlcr, intFlags);
return E_OK;
}
-
-
-/* ... */
-
-#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
-t_Error FM_PCD_PlcrDumpRegs(t_Handle h_FmPcd)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- int i = 0;
- t_FmPcdIpcMsg msg;
-
- DECLARE_DUMP;
-
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
-
- if(p_FmPcd->guestId != NCSW_MASTER_ID)
- {
- memset(&msg, 0, sizeof(msg));
- msg.msgId = FM_PCD_PLCR_DUMP_REGS;
- return XX_IpcSendMessage(p_FmPcd->h_IpcSession,
- (uint8_t*)&msg,
- sizeof(msg.msgId),
- NULL,
- NULL,
- NULL,
- NULL);
- }
- else
- {
- DUMP_SUBTITLE(("\n"));
- DUMP_TITLE(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, ("FmPcdPlcrRegs Regs"));
-
- DUMP_VAR(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs,fmpl_gcr);
- DUMP_VAR(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs,fmpl_gsr);
- DUMP_VAR(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs,fmpl_evr);
- DUMP_VAR(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs,fmpl_ier);
- DUMP_VAR(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs,fmpl_ifr);
- DUMP_VAR(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs,fmpl_eevr);
- DUMP_VAR(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs,fmpl_eier);
- DUMP_VAR(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs,fmpl_eifr);
- DUMP_VAR(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs,fmpl_rpcnt);
- DUMP_VAR(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs,fmpl_ypcnt);
- DUMP_VAR(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs,fmpl_rrpcnt);
- DUMP_VAR(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs,fmpl_rypcnt);
- DUMP_VAR(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs,fmpl_tpcnt);
- DUMP_VAR(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs,fmpl_flmcnt);
-
- DUMP_VAR(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs,fmpl_serc);
- DUMP_VAR(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs,fmpl_upcr);
- DUMP_VAR(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs,fmpl_dpmr);
-
-
- DUMP_TITLE(&p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_pmr, ("fmpl_pmr"));
- DUMP_SUBSTRUCT_ARRAY(i, 63)
- {
- DUMP_MEMORY(&p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->fmpl_pmr[i], sizeof(uint32_t));
- }
-
- return E_OK;
- }
-}
-
-t_Error FM_PCD_PlcrProfileDumpRegs(t_Handle h_FmPcd, t_Handle h_Profile)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- t_FmPcdPlcrInterModuleProfileRegs *p_ProfilesRegs;
- uint32_t tmpReg, intFlags;
- uint16_t profileIndx = (uint16_t)(PTR_TO_UINT(h_Profile)-1);
- t_FmPcdIpcMsg msg;
-
- DECLARE_DUMP;
-
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPlcr, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
-
- if(p_FmPcd->guestId != NCSW_MASTER_ID)
- {
- memset(&msg, 0, sizeof(msg));
- msg.msgId = FM_PCD_PLCR_PROFILE_DUMP_REGS;
- memcpy(msg.msgBody, (uint8_t *)&h_Profile, sizeof(uint32_t));
- return XX_IpcSendMessage(p_FmPcd->h_IpcSession,
- (uint8_t*)&msg,
- sizeof(msg.msgId) + sizeof(uint32_t),
- NULL,
- NULL,
- NULL,
- NULL);
- }
- else
- {
- DUMP_SUBTITLE(("\n"));
- DUMP_TITLE(p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs, ("FmPcdPlcrRegs Profile Regs"));
-
- p_ProfilesRegs = &p_FmPcd->p_FmPcdPlcr->p_FmPcdPlcrRegs->profileRegs;
-
- tmpReg = FmPcdPlcrBuildReadPlcrActionReg((uint16_t)profileIndx);
- intFlags = FmPcdLock(p_FmPcd);
- WritePar(p_FmPcd, tmpReg);
-
- DUMP_TITLE(p_ProfilesRegs, ("Profile %d regs", profileIndx));
-
- DUMP_VAR(p_ProfilesRegs, fmpl_pemode);
- DUMP_VAR(p_ProfilesRegs, fmpl_pegnia);
- DUMP_VAR(p_ProfilesRegs, fmpl_peynia);
- DUMP_VAR(p_ProfilesRegs, fmpl_pernia);
- DUMP_VAR(p_ProfilesRegs, fmpl_pecir);
- DUMP_VAR(p_ProfilesRegs, fmpl_pecbs);
- DUMP_VAR(p_ProfilesRegs, fmpl_pepepir_eir);
- DUMP_VAR(p_ProfilesRegs, fmpl_pepbs_ebs);
- DUMP_VAR(p_ProfilesRegs, fmpl_pelts);
- DUMP_VAR(p_ProfilesRegs, fmpl_pects);
- DUMP_VAR(p_ProfilesRegs, fmpl_pepts_ets);
- DUMP_VAR(p_ProfilesRegs, fmpl_pegpc);
- DUMP_VAR(p_ProfilesRegs, fmpl_peypc);
- DUMP_VAR(p_ProfilesRegs, fmpl_perpc);
- DUMP_VAR(p_ProfilesRegs, fmpl_perypc);
- DUMP_VAR(p_ProfilesRegs, fmpl_perrpc);
- FmPcdUnlock(p_FmPcd, intFlags);
-
- return E_OK;
- }
-}
-#endif /* (defined(DEBUG_ERRORS) && ... */
diff --git a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_plcr.h b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_plcr.h
new file mode 100644
index 000000000000..2bb8b969956c
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_plcr.h
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/******************************************************************************
+ @File fm_plcr.h
+
+ @Description FM Policer private header
+*//***************************************************************************/
+#ifndef __FM_PLCR_H
+#define __FM_PLCR_H
+
+#include "std_ext.h"
+
+
+/***********************************************************************/
+/* Policer defines */
+/***********************************************************************/
+
+#define FM_PCD_PLCR_PAR_GO 0x80000000
+#define FM_PCD_PLCR_PAR_PWSEL_MASK 0x0000FFFF
+#define FM_PCD_PLCR_PAR_R 0x40000000
+
+/* shifts */
+#define FM_PCD_PLCR_PAR_PNUM_SHIFT 16
+
+/* masks */
+#define FM_PCD_PLCR_PEMODE_PI 0x80000000
+#define FM_PCD_PLCR_PEMODE_CBLND 0x40000000
+#define FM_PCD_PLCR_PEMODE_ALG_MASK 0x30000000
+#define FM_PCD_PLCR_PEMODE_ALG_RFC2698 0x10000000
+#define FM_PCD_PLCR_PEMODE_ALG_RFC4115 0x20000000
+#define FM_PCD_PLCR_PEMODE_DEFC_MASK 0x0C000000
+#define FM_PCD_PLCR_PEMODE_DEFC_Y 0x04000000
+#define FM_PCD_PLCR_PEMODE_DEFC_R 0x08000000
+#define FM_PCD_PLCR_PEMODE_DEFC_OVERRIDE 0x0C000000
+#define FM_PCD_PLCR_PEMODE_OVCLR_MASK 0x03000000
+#define FM_PCD_PLCR_PEMODE_OVCLR_Y 0x01000000
+#define FM_PCD_PLCR_PEMODE_OVCLR_R 0x02000000
+#define FM_PCD_PLCR_PEMODE_OVCLR_G_NC 0x03000000
+#define FM_PCD_PLCR_PEMODE_PKT 0x00800000
+#define FM_PCD_PLCR_PEMODE_FPP_MASK 0x001F0000
+#define FM_PCD_PLCR_PEMODE_FPP_SHIFT 16
+#define FM_PCD_PLCR_PEMODE_FLS_MASK 0x0000F000
+#define FM_PCD_PLCR_PEMODE_FLS_L2 0x00003000
+#define FM_PCD_PLCR_PEMODE_FLS_L3 0x0000B000
+#define FM_PCD_PLCR_PEMODE_FLS_L4 0x0000E000
+#define FM_PCD_PLCR_PEMODE_FLS_FULL 0x0000F000
+#define FM_PCD_PLCR_PEMODE_RBFLS 0x00000800
+#define FM_PCD_PLCR_PEMODE_TRA 0x00000004
+#define FM_PCD_PLCR_PEMODE_TRB 0x00000002
+#define FM_PCD_PLCR_PEMODE_TRC 0x00000001
+#define FM_PCD_PLCR_DOUBLE_ECC 0x80000000
+#define FM_PCD_PLCR_INIT_ENTRY_ERROR 0x40000000
+#define FM_PCD_PLCR_PRAM_SELF_INIT_COMPLETE 0x80000000
+#define FM_PCD_PLCR_ATOMIC_ACTION_COMPLETE 0x40000000
+
+#define FM_PCD_PLCR_NIA_VALID 0x80000000
+
+#define FM_PCD_PLCR_GCR_EN 0x80000000
+#define FM_PCD_PLCR_GCR_STEN 0x40000000
+#define FM_PCD_PLCR_GCR_DAR 0x20000000
+#define FM_PCD_PLCR_GCR_DEFNIA 0x00FFFFFF
+#define FM_PCD_PLCR_NIA_ABS 0x00000100
+
+#define FM_PCD_PLCR_GSR_BSY 0x80000000
+#define FM_PCD_PLCR_GSR_DQS 0x60000000
+#define FM_PCD_PLCR_GSR_RPB 0x20000000
+#define FM_PCD_PLCR_GSR_FQS 0x0C000000
+#define FM_PCD_PLCR_GSR_LPALG 0x0000C000
+#define FM_PCD_PLCR_GSR_LPCA 0x00003000
+#define FM_PCD_PLCR_GSR_LPNUM 0x000000FF
+
+#define FM_PCD_PLCR_EVR_PSIC 0x80000000
+#define FM_PCD_PLCR_EVR_AAC 0x40000000
+
+#define FM_PCD_PLCR_PAR_PSI 0x20000000
+#define FM_PCD_PLCR_PAR_PNUM 0x00FF0000
+/* PWSEL Selctive select options */
+#define FM_PCD_PLCR_PAR_PWSEL_PEMODE 0x00008000 /* 0 */
+#define FM_PCD_PLCR_PAR_PWSEL_PEGNIA 0x00004000 /* 1 */
+#define FM_PCD_PLCR_PAR_PWSEL_PEYNIA 0x00002000 /* 2 */
+#define FM_PCD_PLCR_PAR_PWSEL_PERNIA 0x00001000 /* 3 */
+#define FM_PCD_PLCR_PAR_PWSEL_PECIR 0x00000800 /* 4 */
+#define FM_PCD_PLCR_PAR_PWSEL_PECBS 0x00000400 /* 5 */
+#define FM_PCD_PLCR_PAR_PWSEL_PEPIR_EIR 0x00000200 /* 6 */
+#define FM_PCD_PLCR_PAR_PWSEL_PEPBS_EBS 0x00000100 /* 7 */
+#define FM_PCD_PLCR_PAR_PWSEL_PELTS 0x00000080 /* 8 */
+#define FM_PCD_PLCR_PAR_PWSEL_PECTS 0x00000040 /* 9 */
+#define FM_PCD_PLCR_PAR_PWSEL_PEPTS_ETS 0x00000020 /* 10 */
+#define FM_PCD_PLCR_PAR_PWSEL_PEGPC 0x00000010 /* 11 */
+#define FM_PCD_PLCR_PAR_PWSEL_PEYPC 0x00000008 /* 12 */
+#define FM_PCD_PLCR_PAR_PWSEL_PERPC 0x00000004 /* 13 */
+#define FM_PCD_PLCR_PAR_PWSEL_PERYPC 0x00000002 /* 14 */
+#define FM_PCD_PLCR_PAR_PWSEL_PERRPC 0x00000001 /* 15 */
+
+#define FM_PCD_PLCR_PAR_PMR_BRN_1TO1 0x0000 /* - Full bit replacement. {PBNUM[0:N-1]
+ 1-> 2^N specific locations. */
+#define FM_PCD_PLCR_PAR_PMR_BRN_2TO2 0x1 /* - {PBNUM[0:N-2],PNUM[N-1]}.
+ 2-> 2^(N-1) base locations. */
+#define FM_PCD_PLCR_PAR_PMR_BRN_4TO4 0x2 /* - {PBNUM[0:N-3],PNUM[N-2:N-1]}.
+ 4-> 2^(N-2) base locations. */
+#define FM_PCD_PLCR_PAR_PMR_BRN_8TO8 0x3 /* - {PBNUM[0:N-4],PNUM[N-3:N-1]}.
+ 8->2^(N-3) base locations. */
+#define FM_PCD_PLCR_PAR_PMR_BRN_16TO16 0x4 /* - {PBNUM[0:N-5],PNUM[N-4:N-1]}.
+ 16-> 2^(N-4) base locations. */
+#define FM_PCD_PLCR_PAR_PMR_BRN_32TO32 0x5 /* {PBNUM[0:N-6],PNUM[N-5:N-1]}.
+ 32-> 2^(N-5) base locations. */
+#define FM_PCD_PLCR_PAR_PMR_BRN_64TO64 0x6 /* {PBNUM[0:N-7],PNUM[N-6:N-1]}.
+ 64-> 2^(N-6) base locations. */
+#define FM_PCD_PLCR_PAR_PMR_BRN_128TO128 0x7 /* {PBNUM[0:N-8],PNUM[N-7:N-1]}.
+ 128-> 2^(N-7) base locations. */
+#define FM_PCD_PLCR_PAR_PMR_BRN_256TO256 0x8 /* - No bit replacement for N=8. {PNUM[N-8:N-1]}.
+ When N=8 this option maps all 256 profiles by the DISPATCH bus into one group. */
+
+#define FM_PCD_PLCR_PMR_V 0x80000000
+#define PLCR_ERR_ECC_CAP 0x80000000
+#define PLCR_ERR_ECC_TYPE_DOUBLE 0x40000000
+#define PLCR_ERR_ECC_PNUM_MASK 0x00000FF0
+#define PLCR_ERR_ECC_OFFSET_MASK 0x0000000F
+
+#define PLCR_ERR_UNINIT_CAP 0x80000000
+#define PLCR_ERR_UNINIT_NUM_MASK 0x000000FF
+#define PLCR_ERR_UNINIT_PID_MASK 0x003f0000
+#define PLCR_ERR_UNINIT_ABSOLUTE_MASK 0x00008000
+
+/* shifts */
+#define PLCR_ERR_ECC_PNUM_SHIFT 4
+#define PLCR_ERR_UNINIT_PID_SHIFT 16
+
+#define FM_PCD_PLCR_PMR_BRN_SHIFT 16
+
+#define PLCR_PORT_WINDOW_SIZE(hardwarePortId)
+
+
+#endif /* __FM_PLCR_H */
diff --git a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_prs.c b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_prs.c
index 2191c12d2837..ff4f0a2f23cb 100644
--- a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_prs.c
+++ b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_prs.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,11 +30,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm_pcd.c
@Description FM PCD ...
*//***************************************************************************/
+#include <linux/math64.h>
#include "std_ext.h"
#include "error_ext.h"
#include "string_ext.h"
@@ -44,55 +46,22 @@
#include "fm_common.h"
#include "fm_pcd.h"
#include "fm_pcd_ipc.h"
+#include "fm_prs.h"
+#include "fsl_fman_prs.h"
-t_Handle PrsConfig(t_FmPcd *p_FmPcd,t_FmPcdParams *p_FmPcdParams)
-{
- t_FmPcdPrs *p_FmPcdPrs;
- uintptr_t baseAddr;
-
- UNUSED(p_FmPcd);
- UNUSED(p_FmPcdParams);
-
- p_FmPcdPrs = (t_FmPcdPrs *) XX_Malloc(sizeof(t_FmPcdPrs));
- if (!p_FmPcdPrs)
- {
- REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Parser structure allocation FAILED"));
- return NULL;
- }
- memset(p_FmPcdPrs, 0, sizeof(t_FmPcdPrs));
-
- if (p_FmPcd->guestId == NCSW_MASTER_ID)
- {
- baseAddr = FmGetPcdPrsBaseAddr(p_FmPcdParams->h_Fm);
- p_FmPcdPrs->p_SwPrsCode = (uint32_t *)UINT_TO_PTR(baseAddr);
- p_FmPcdPrs->p_FmPcdPrsRegs = (t_FmPcdPrsRegs *)UINT_TO_PTR(baseAddr + PRS_REGS_OFFSET);
- }
-
- p_FmPcdPrs->fmPcdPrsPortIdStatistics = 0;
- p_FmPcd->p_FmPcdDriverParam->prsMaxParseCycleLimit = DEFAULT_prsMaxParseCycleLimit;
- p_FmPcd->exceptions |= (DEFAULT_fmPcdPrsErrorExceptions | DEFAULT_fmPcdPrsExceptions);
-
- return p_FmPcdPrs;
-}
-
static void PcdPrsErrorException(t_Handle h_FmPcd)
{
t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- uint32_t event, mask, force;
+ uint32_t event, ev_mask;
+ struct fman_prs_regs *PrsRegs = (struct fman_prs_regs *)p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
ASSERT_COND(p_FmPcd->guestId == NCSW_MASTER_ID);
- event = GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->perr);
- mask = GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->perer);
+ ev_mask = fman_prs_get_err_ev_mask(PrsRegs);
- event &= mask;
+ event = fman_prs_get_err_event(PrsRegs, ev_mask);
- /* clear the forced events */
- force = GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->perfr);
- if(force & event)
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->perfr, force & ~event);
-
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->perr, event);
+ fman_prs_ack_err_event(PrsRegs, event);
DBG(TRACE, ("parser error - 0x%08x\n",event));
@@ -103,85 +72,81 @@ static void PcdPrsErrorException(t_Handle h_FmPcd)
static void PcdPrsException(t_Handle h_FmPcd)
{
t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- uint32_t event, force;
+ uint32_t event, ev_mask;
+ struct fman_prs_regs *PrsRegs = (struct fman_prs_regs *)p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
ASSERT_COND(p_FmPcd->guestId == NCSW_MASTER_ID);
- event = GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->pevr);
- event &= GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->pever);
+ ev_mask = fman_prs_get_expt_ev_mask(PrsRegs);
+ event = fman_prs_get_expt_event(PrsRegs, ev_mask);
ASSERT_COND(event & FM_PCD_PRS_SINGLE_ECC);
DBG(TRACE, ("parser event - 0x%08x\n",event));
- /* clear the forced events */
- force = GET_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->pevfr);
- if(force & event)
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->pevfr, force & ~event);
-
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->pevr, event);
+ fman_prs_ack_expt_event(PrsRegs, event);
p_FmPcd->f_Exception(p_FmPcd->h_App,e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC);
}
-static uint32_t GetSwPrsOffset(t_Handle h_FmPcd, e_NetHeaderType hdr, uint8_t indexPerHdr)
+t_Handle PrsConfig(t_FmPcd *p_FmPcd,t_FmPcdParams *p_FmPcdParams)
{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- int i;
- t_FmPcdPrsLabelParams *p_Label;
-
- SANITY_CHECK_RETURN_VALUE(p_FmPcd, E_INVALID_HANDLE, 0);
- SANITY_CHECK_RETURN_VALUE(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_HANDLE, 0);
+ t_FmPcdPrs *p_FmPcdPrs;
+ uintptr_t baseAddr;
- ASSERT_COND(p_FmPcd->guestId == NCSW_MASTER_ID);
- ASSERT_COND(p_FmPcd->p_FmPcdPrs->currLabel < FM_PCD_PRS_NUM_OF_LABELS);
+ UNUSED(p_FmPcd);
+ UNUSED(p_FmPcdParams);
- for (i=0; i < p_FmPcd->p_FmPcdPrs->currLabel; i++)
+ p_FmPcdPrs = (t_FmPcdPrs *) XX_Malloc(sizeof(t_FmPcdPrs));
+ if (!p_FmPcdPrs)
{
- p_Label = &p_FmPcd->p_FmPcdPrs->labelsTable[i];
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Parser structure allocation FAILED"));
+ return NULL;
+ }
+ memset(p_FmPcdPrs, 0, sizeof(t_FmPcdPrs));
+ fman_prs_defconfig(&p_FmPcd->p_FmPcdDriverParam->dfltCfg);
- if ((hdr == p_Label->hdr) && (indexPerHdr == p_Label->indexPerHdr))
- return p_Label->instructionOffset;
+ if (p_FmPcd->guestId == NCSW_MASTER_ID)
+ {
+ baseAddr = FmGetPcdPrsBaseAddr(p_FmPcdParams->h_Fm);
+ p_FmPcdPrs->p_SwPrsCode = (uint32_t *)UINT_TO_PTR(baseAddr);
+ p_FmPcdPrs->p_FmPcdPrsRegs = (struct fman_prs_regs *)UINT_TO_PTR(baseAddr + PRS_REGS_OFFSET);
}
- REPORT_ERROR(MAJOR, E_NOT_FOUND, ("Sw Parser attachment Not found"));
- return (uint32_t)ILLEGAL_BASE;
+ p_FmPcdPrs->fmPcdPrsPortIdStatistics = p_FmPcd->p_FmPcdDriverParam->dfltCfg.port_id_stat;
+ p_FmPcd->p_FmPcdDriverParam->prsMaxParseCycleLimit = p_FmPcd->p_FmPcdDriverParam->dfltCfg.max_prs_cyc_lim;
+ p_FmPcd->exceptions |= p_FmPcd->p_FmPcdDriverParam->dfltCfg.prs_exceptions;
+
+ return p_FmPcdPrs;
}
+#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
+ static uint8_t swPrsPatch[] = SW_PRS_UDP_LITE_PATCH;
+#else
+ static uint8_t swPrsPatch[] = SW_PRS_OFFLOAD_PATCH;
+#endif /* FM_CAPWAP_SUPPORT */
+
t_Error PrsInit(t_FmPcd *p_FmPcd)
{
t_FmPcdDriverParam *p_Param = p_FmPcd->p_FmPcdDriverParam;
- t_FmPcdPrsRegs *p_Regs = p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
- uint32_t tmpReg;
+ uint32_t *p_TmpCode;
+ uint32_t *p_LoadTarget = (uint32_t *)PTR_MOVE(p_FmPcd->p_FmPcdPrs->p_SwPrsCode,
+ FM_PCD_SW_PRS_SIZE-FM_PCD_PRS_SW_PATCHES_SIZE);
+ struct fman_prs_regs *PrsRegs = (struct fman_prs_regs *)p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
+ uint32_t i;
- if(p_FmPcd->guestId != NCSW_MASTER_ID)
- return E_OK;
+ ASSERT_COND(sizeof(swPrsPatch) <= (FM_PCD_PRS_SW_PATCHES_SIZE-FM_PCD_PRS_SW_TAIL_SIZE));
- ASSERT_COND(p_FmPcd->guestId == NCSW_MASTER_ID);
+ /* nothing to do in guest-partition */
+ if (p_FmPcd->guestId != NCSW_MASTER_ID)
+ return E_OK;
-#ifdef FM_PRS_MEM_ERRATA_FMAN_SW003
- {
- uint32_t i;
- uint32_t regsToGlobalOffset = 0x840;
- uint32_t firstPortToGlobalOffset = 0x45800;
- uint64_t globalAddr = PTR_TO_UINT(p_Regs) - regsToGlobalOffset;
- uint32_t firstPortAddr = (uint32_t)(globalAddr - (uint64_t)firstPortToGlobalOffset);
- uint32_t portSize = 0x1000;
- t_FmRevisionInfo revInfo;
-
- FM_GetRevision(p_FmPcd->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- {
- /* clear all parser memory */
- IOMemSet32(UINT_TO_PTR(globalAddr), 0x00000000, 0x800);
- for(i = 0;i<16;i++)
- IOMemSet32(UINT_TO_PTR(firstPortAddr+i*portSize), (uint8_t)0x00000000, (uint32_t)0x80);
- }
- }
-#endif /* FM_PRS_MEM_ERRATA_FMAN_SW003 */
+ p_TmpCode = (uint32_t *)XX_MallocSmart(ROUND_UP(sizeof(swPrsPatch),4), 0, sizeof(uint32_t));
+ if (!p_TmpCode)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Tmp Sw-Parser code allocation FAILED"));
+ memset((uint8_t *)p_TmpCode, 0, ROUND_UP(sizeof(swPrsPatch),4));
+ memcpy((uint8_t *)p_TmpCode, (uint8_t *)swPrsPatch, sizeof(swPrsPatch));
- /**********************RPCLIM******************/
- WRITE_UINT32(p_Regs->rpclim, (uint32_t)p_Param->prsMaxParseCycleLimit);
- /**********************FMPL_RPCLIM******************/
+ fman_prs_init(PrsRegs, &p_Param->dfltCfg);
/* register even if no interrupts enabled, to allow future enablement */
FmRegisterIntr(p_FmPcd->h_Fm, e_FM_MOD_PRS, 0, e_FM_INTR_TYPE_ERR, PcdPrsErrorException, p_FmPcd);
@@ -189,69 +154,22 @@ t_Error PrsInit(t_FmPcd *p_FmPcd)
/* register even if no interrupts enabled, to allow future enablement */
FmRegisterIntr(p_FmPcd->h_Fm, e_FM_MOD_PRS, 0, e_FM_INTR_TYPE_NORMAL, PcdPrsException, p_FmPcd);
- /**********************PEVR******************/
- WRITE_UINT32(p_Regs->pevr, (FM_PCD_PRS_SINGLE_ECC | FM_PCD_PRS_PORT_IDLE_STS) );
- /**********************PEVR******************/
-
- /**********************PEVER******************/
if(p_FmPcd->exceptions & FM_PCD_EX_PRS_SINGLE_ECC)
- {
FmEnableRamsEcc(p_FmPcd->h_Fm);
- WRITE_UINT32(p_Regs->pever, FM_PCD_PRS_SINGLE_ECC);
- }
- else
- WRITE_UINT32(p_Regs->pever, 0);
- /**********************PEVER******************/
- /**********************PERR******************/
- WRITE_UINT32(p_Regs->perr, FM_PCD_PRS_DOUBLE_ECC);
-
- /**********************PERR******************/
-
- /**********************PERER******************/
- tmpReg = 0;
if(p_FmPcd->exceptions & FM_PCD_EX_PRS_DOUBLE_ECC)
- {
FmEnableRamsEcc(p_FmPcd->h_Fm);
- tmpReg |= FM_PCD_PRS_DOUBLE_ECC;
- }
- WRITE_UINT32(p_Regs->perer, tmpReg);
- /**********************PERER******************/
- /**********************PPCS******************/
- WRITE_UINT32(p_Regs->ppsc, p_FmPcd->p_FmPcdPrs->fmPcdPrsPortIdStatistics);
- /**********************PPCS******************/
+ /* load sw parser Ip-Frag patch */
+ for (i=0; i<DIV_CEIL(sizeof(swPrsPatch), 4); i++)
+ WRITE_UINT32(p_LoadTarget[i], GET_UINT32(p_TmpCode[i]));
-#ifdef FM_PRS_L4_SHELL_ERRATA_FMANb
- {
- uint32_t i, j;
- t_FmRevisionInfo revInfo;
- uint8_t swPrsL4Patch[] = SW_PRS_L4_PATCH;
-
- FM_GetRevision(p_FmPcd->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- {
- /* load sw parser L4 patch */
- for(i=0;i<sizeof(swPrsL4Patch)/4;i++)
- {
- tmpReg = 0;
- for(j =0;j<4;j++)
- {
- tmpReg <<= 8;
- tmpReg |= swPrsL4Patch[i*4+j];
-
- }
- WRITE_UINT32(*(p_FmPcd->p_FmPcdPrs->p_SwPrsCode+ FM_PCD_PRS_SW_OFFSET/4 + i), tmpReg);
- }
- p_FmPcd->p_FmPcdPrs->p_CurrSwPrs = FM_PCD_PRS_SW_OFFSET/4 + p_FmPcd->p_FmPcdPrs->p_SwPrsCode+sizeof(swPrsL4Patch)/4;
- }
- }
-#endif /* FM_PRS_L4_SHELL_ERRATA_FMANb */
+ XX_FreeSmart(p_TmpCode);
return E_OK;
}
-void PrsFree(t_FmPcd *p_FmPcd )
+void PrsFree(t_FmPcd *p_FmPcd)
{
ASSERT_COND(p_FmPcd->guestId == NCSW_MASTER_ID);
FmUnregisterIntr(p_FmPcd->h_Fm, e_FM_MOD_PRS, 0, e_FM_INTR_TYPE_ERR);
@@ -259,24 +177,33 @@ void PrsFree(t_FmPcd *p_FmPcd )
FmUnregisterIntr(p_FmPcd->h_Fm, e_FM_MOD_PRS, 0, e_FM_INTR_TYPE_NORMAL);
}
-void PrsEnable(t_FmPcd *p_FmPcd )
+void PrsEnable(t_FmPcd *p_FmPcd)
+{
+ struct fman_prs_regs *PrsRegs = (struct fman_prs_regs *)p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
+
+ ASSERT_COND(p_FmPcd->guestId == NCSW_MASTER_ID);
+ fman_prs_enable(PrsRegs);
+}
+
+void PrsDisable(t_FmPcd *p_FmPcd)
{
- t_FmPcdPrsRegs *p_Regs = p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
+ struct fman_prs_regs *PrsRegs = (struct fman_prs_regs *)p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
ASSERT_COND(p_FmPcd->guestId == NCSW_MASTER_ID);
- WRITE_UINT32(p_Regs->rpimac, GET_UINT32(p_Regs->rpimac) | FM_PCD_PRS_RPIMAC_EN);
+ fman_prs_disable(PrsRegs);
}
-void PrsDisable(t_FmPcd *p_FmPcd )
+int PrsIsEnabled(t_FmPcd *p_FmPcd)
{
- t_FmPcdPrsRegs *p_Regs = p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
+ struct fman_prs_regs *PrsRegs = (struct fman_prs_regs *)p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
ASSERT_COND(p_FmPcd->guestId == NCSW_MASTER_ID);
- WRITE_UINT32(p_Regs->rpimac, GET_UINT32(p_Regs->rpimac) & ~FM_PCD_PRS_RPIMAC_EN);
+ return fman_prs_is_enabled(PrsRegs);
}
t_Error PrsIncludePortInStatistics(t_FmPcd *p_FmPcd, uint8_t hardwarePortId, bool include)
{
+ struct fman_prs_regs *PrsRegs;
uint32_t bitMask = 0;
uint8_t prsPortId;
@@ -284,15 +211,18 @@ t_Error PrsIncludePortInStatistics(t_FmPcd *p_FmPcd, uint8_t hardwarePortId, boo
SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPrs, E_INVALID_HANDLE);
+ PrsRegs = (struct fman_prs_regs *)p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
+
GET_FM_PCD_PRS_PORT_ID(prsPortId, hardwarePortId);
GET_FM_PCD_INDEX_FLAG(bitMask, prsPortId);
- if(include)
+ if (include)
p_FmPcd->p_FmPcdPrs->fmPcdPrsPortIdStatistics |= bitMask;
else
p_FmPcd->p_FmPcdPrs->fmPcdPrsPortIdStatistics &= ~bitMask;
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->ppsc, p_FmPcd->p_FmPcdPrs->fmPcdPrsPortIdStatistics);
+ fman_prs_set_stst_port_msk(PrsRegs,
+ p_FmPcd->p_FmPcdPrs->fmPcdPrsPortIdStatistics);
return E_OK;
}
@@ -300,46 +230,60 @@ t_Error PrsIncludePortInStatistics(t_FmPcd *p_FmPcd, uint8_t hardwarePortId, boo
t_Error FmPcdPrsIncludePortInStatistics(t_Handle h_FmPcd, uint8_t hardwarePortId, bool include)
{
t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- t_FmPcdIpcPrsIncludePort prsIncludePortParams;
- t_FmPcdIpcMsg msg;
t_Error err;
SANITY_CHECK_RETURN_ERROR((hardwarePortId >=1 && hardwarePortId <= 16), E_INVALID_VALUE);
SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPrs, E_INVALID_HANDLE);
- if(p_FmPcd->guestId != NCSW_MASTER_ID)
+ if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
+ p_FmPcd->h_IpcSession)
{
+ t_FmPcdIpcPrsIncludePort prsIncludePortParams;
+ t_FmPcdIpcMsg msg;
+
prsIncludePortParams.hardwarePortId = hardwarePortId;
prsIncludePortParams.include = include;
memset(&msg, 0, sizeof(msg));
msg.msgId = FM_PCD_PRS_INC_PORT_STATS;
memcpy(msg.msgBody, &prsIncludePortParams, sizeof(prsIncludePortParams));
- if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
- (uint8_t*)&msg,
- sizeof(msg.msgId) +sizeof(prsIncludePortParams),
- NULL,
- NULL,
- NULL,
- NULL)) != E_OK)
+ err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
+ (uint8_t*)&msg,
+ sizeof(msg.msgId) +sizeof(prsIncludePortParams),
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ if (err != E_OK)
RETURN_ERROR(MAJOR, err, NO_MSG);
return E_OK;
}
+ else if (p_FmPcd->guestId != NCSW_MASTER_ID)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("running in guest-mode without IPC!"));
+
return PrsIncludePortInStatistics(p_FmPcd, hardwarePortId, include);
}
uint32_t FmPcdGetSwPrsOffset(t_Handle h_FmPcd, e_NetHeaderType hdr, uint8_t indexPerHdr)
{
t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
- t_Error err = E_OK;
- t_FmPcdIpcSwPrsLable labelParams;
- t_FmPcdIpcMsg msg;
- uint32_t prsOffset = 0;
- t_FmPcdIpcReply reply;
- uint32_t replyLength;
+ t_FmPcdPrsLabelParams *p_Label;
+ int i;
- if(p_FmPcd->guestId != NCSW_MASTER_ID)
+ SANITY_CHECK_RETURN_VALUE(p_FmPcd, E_INVALID_HANDLE, 0);
+ SANITY_CHECK_RETURN_VALUE(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_HANDLE, 0);
+
+ if ((p_FmPcd->guestId != NCSW_MASTER_ID) &&
+ p_FmPcd->h_IpcSession)
{
+ t_Error err = E_OK;
+ t_FmPcdIpcSwPrsLable labelParams;
+ t_FmPcdIpcMsg msg;
+ uint32_t prsOffset = 0;
+ t_FmPcdIpcReply reply;
+ uint32_t replyLength;
+
memset(&reply, 0, sizeof(reply));
memset(&msg, 0, sizeof(msg));
labelParams.enumHdr = (uint32_t)hdr;
@@ -347,48 +291,65 @@ uint32_t FmPcdGetSwPrsOffset(t_Handle h_FmPcd, e_NetHeaderType hdr, uint8_t inde
msg.msgId = FM_PCD_GET_SW_PRS_OFFSET;
memcpy(msg.msgBody, &labelParams, sizeof(labelParams));
replyLength = sizeof(uint32_t) + sizeof(uint32_t);
- if ((err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
- (uint8_t*)&msg,
- sizeof(msg.msgId) +sizeof(labelParams),
- (uint8_t*)&reply,
- &replyLength,
- NULL,
- NULL)) != E_OK)
+ err = XX_IpcSendMessage(p_FmPcd->h_IpcSession,
+ (uint8_t*)&msg,
+ sizeof(msg.msgId) +sizeof(labelParams),
+ (uint8_t*)&reply,
+ &replyLength,
+ NULL,
+ NULL);
+ if (err != E_OK)
RETURN_ERROR(MAJOR, err, NO_MSG);
- if(replyLength != sizeof(uint32_t) + sizeof(uint32_t))
+ if (replyLength != sizeof(uint32_t) + sizeof(uint32_t))
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
memcpy((uint8_t*)&prsOffset, reply.replyBody, sizeof(uint32_t));
return prsOffset;
}
+ else if (p_FmPcd->guestId != NCSW_MASTER_ID)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("running in guest-mode without IPC!"));
+
+ ASSERT_COND(p_FmPcd->p_FmPcdPrs->currLabel < FM_PCD_PRS_NUM_OF_LABELS);
+
+ for (i=0; i<p_FmPcd->p_FmPcdPrs->currLabel; i++)
+ {
+ p_Label = &p_FmPcd->p_FmPcdPrs->labelsTable[i];
- return GetSwPrsOffset(h_FmPcd, hdr, indexPerHdr);
+ if ((hdr == p_Label->hdr) && (indexPerHdr == p_Label->indexPerHdr))
+ return p_Label->instructionOffset;
+ }
+
+ REPORT_ERROR(MAJOR, E_NOT_FOUND, ("Sw Parser attachment Not found"));
+ return (uint32_t)ILLEGAL_BASE;
}
void FM_PCD_SetPrsStatistics(t_Handle h_FmPcd, bool enable)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
+ struct fman_prs_regs *PrsRegs;
SANITY_CHECK_RETURN(p_FmPcd, E_INVALID_HANDLE);
SANITY_CHECK_RETURN(p_FmPcd->p_FmPcdPrs, E_INVALID_HANDLE);
+ PrsRegs = (struct fman_prs_regs *)p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs;
+
+
if(p_FmPcd->guestId != NCSW_MASTER_ID)
{
REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_SetPrsStatistics - guest mode!"));
return;
}
- if(enable)
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->ppsc, FM_PCD_PRS_PPSC_ALL_PORTS);
- else
- WRITE_UINT32(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs->ppsc, 0);
+ fman_prs_set_stst(PrsRegs, enable);
}
t_Error FM_PCD_PrsLoadSw(t_Handle h_FmPcd, t_FmPcdPrsSwParams *p_SwPrs)
{
t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- uint32_t *p_LoadTarget, tmpReg;
- int i, j;
+ uint32_t *p_LoadTarget;
+ uint32_t *p_TmpCode;
+ int i;
SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
@@ -396,48 +357,53 @@ t_Error FM_PCD_PrsLoadSw(t_Handle h_FmPcd, t_FmPcdPrsSwParams *p_SwPrs)
SANITY_CHECK_RETURN_ERROR(p_SwPrs, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPcd->enabled, E_INVALID_HANDLE);
- if(p_FmPcd->guestId != NCSW_MASTER_ID)
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM_PCD_PrsLoadSw - guest mode!"));
+ if (p_FmPcd->guestId != NCSW_MASTER_ID)
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM in guest-mode!"));
- if(!p_SwPrs->override)
+ if (!p_SwPrs->override)
{
if(p_FmPcd->p_FmPcdPrs->p_CurrSwPrs > p_FmPcd->p_FmPcdPrs->p_SwPrsCode + p_SwPrs->base*2/4)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("SW parser base must be larger than current loaded code"));
}
- if(p_SwPrs->size > FM_PCD_SW_PRS_SIZE - FM_PCD_PRS_SW_TAIL_SIZE - p_SwPrs->base*2)
+ else
+ p_FmPcd->p_FmPcdPrs->currLabel = 0;
+
+ if (p_SwPrs->size > FM_PCD_SW_PRS_SIZE - FM_PCD_PRS_SW_TAIL_SIZE - p_SwPrs->base*2)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("p_SwPrs->size may not be larger than MAX_SW_PRS_CODE_SIZE"));
- if(p_SwPrs->size % 4)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("p_SwPrs->size must be divisible by 4"));
- /* save sw parser labels */
- if(p_SwPrs->override)
- p_FmPcd->p_FmPcdPrs->currLabel = 0;
- if(p_FmPcd->p_FmPcdPrs->currLabel+ p_SwPrs->numOfLabels > FM_PCD_PRS_NUM_OF_LABELS)
+ if (p_FmPcd->p_FmPcdPrs->currLabel + p_SwPrs->numOfLabels > FM_PCD_PRS_NUM_OF_LABELS)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Exceeded number of labels allowed "));
- memcpy(&p_FmPcd->p_FmPcdPrs->labelsTable[p_FmPcd->p_FmPcdPrs->currLabel], p_SwPrs->labelsTable, p_SwPrs->numOfLabels*sizeof(t_FmPcdPrsLabelParams));
+
+ p_TmpCode = (uint32_t *)XX_MallocSmart(ROUND_UP(p_SwPrs->size,4), 0, sizeof(uint32_t));
+ if (!p_TmpCode)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Tmp Sw-Parser code allocation FAILED"));
+ memset((uint8_t *)p_TmpCode, 0, ROUND_UP(p_SwPrs->size,4));
+ memcpy((uint8_t *)p_TmpCode, p_SwPrs->p_Code, p_SwPrs->size);
+
+ /* save sw parser labels */
+ memcpy(&p_FmPcd->p_FmPcdPrs->labelsTable[p_FmPcd->p_FmPcdPrs->currLabel],
+ p_SwPrs->labelsTable,
+ p_SwPrs->numOfLabels*sizeof(t_FmPcdPrsLabelParams));
p_FmPcd->p_FmPcdPrs->currLabel += p_SwPrs->numOfLabels;
+
/* load sw parser code */
p_LoadTarget = p_FmPcd->p_FmPcdPrs->p_SwPrsCode + p_SwPrs->base*2/4;
- for(i=0;i<p_SwPrs->size/4;i++)
- {
- tmpReg = 0;
- for(j =0;j<4;j++)
- {
- tmpReg <<= 8;
- tmpReg |= *(p_SwPrs->p_Code+i*4+j);
- }
- WRITE_UINT32(*(p_LoadTarget + i), tmpReg);
- }
- p_FmPcd->p_FmPcdPrs->p_CurrSwPrs = p_FmPcd->p_FmPcdPrs->p_SwPrsCode + p_SwPrs->base*2/4 + p_SwPrs->size/4;
+
+ for(i=0; i<DIV_CEIL(p_SwPrs->size, 4); i++)
+ WRITE_UINT32(p_LoadTarget[i], GET_UINT32(p_TmpCode[i]));
+
+ p_FmPcd->p_FmPcdPrs->p_CurrSwPrs =
+ p_FmPcd->p_FmPcdPrs->p_SwPrsCode + p_SwPrs->base*2/4 + ROUND_UP(p_SwPrs->size,4);
/* copy data parameters */
- for(i=0;i<FM_PCD_PRS_NUM_OF_HDRS;i++)
+ for (i=0;i<FM_PCD_PRS_NUM_OF_HDRS;i++)
WRITE_UINT32(*(p_FmPcd->p_FmPcdPrs->p_SwPrsCode+PRS_SW_DATA/4+i), p_SwPrs->swPrsDataParams[i]);
-
/* Clear last 4 bytes */
WRITE_UINT32(*(p_FmPcd->p_FmPcdPrs->p_SwPrsCode+(PRS_SW_DATA-FM_PCD_PRS_SW_TAIL_SIZE)/4), 0);
+ XX_FreeSmart(p_TmpCode);
+
return E_OK;
}
@@ -455,63 +421,3 @@ t_Error FM_PCD_ConfigPrsMaxCycleLimit(t_Handle h_FmPcd,uint16_t value)
return E_OK;
}
-
-
-#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
-t_Error FM_PCD_PrsDumpRegs(t_Handle h_FmPcd)
-{
- t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;
- t_FmPcdIpcMsg msg;
-
- DECLARE_DUMP;
-
- SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPcd->p_FmPcdPrs, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_FmPcd->p_FmPcdDriverParam, E_INVALID_STATE);
-
- if(p_FmPcd->guestId != NCSW_MASTER_ID)
- {
- memset(&msg, 0, sizeof(msg));
- msg.msgId = FM_PCD_PRS_DUMP_REGS;
- return XX_IpcSendMessage(p_FmPcd->h_IpcSession,
- (uint8_t*)&msg,
- sizeof(msg.msgId),
- NULL,
- NULL,
- NULL,
- NULL);
- }
- DUMP_SUBTITLE(("\n"));
- DUMP_TITLE(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs, ("FmPcdPrsRegs Regs"));
-
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,rpclim);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,rpimac);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,pmeec);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,pevr);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,pever);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,pevfr);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,perr);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,perer);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,perfr);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,ppsc);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,pds);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,l2rrs);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,l3rrs);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,l4rrs);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,srrs);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,l2rres);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,l3rres);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,l4rres);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,srres);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,spcs);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,spscs);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,hxscs);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,mrcs);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,mwcs);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,mrscs);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,mwscs);
- DUMP_VAR(p_FmPcd->p_FmPcdPrs->p_FmPcdPrsRegs,fcscs);
-
- return E_OK;
-}
-#endif /* (defined(DEBUG_ERRORS) && ... */
diff --git a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_prs.h b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_prs.h
new file mode 100644
index 000000000000..056f225ef221
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_prs.h
@@ -0,0 +1,316 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/******************************************************************************
+ @File fm_prs.h
+
+ @Description FM Parser private header
+ *//***************************************************************************/
+#ifndef __FM_PRS_H
+#define __FM_PRS_H
+
+#include "std_ext.h"
+
+/***********************************************************************/
+/* SW parser IP_FRAG patch */
+/***********************************************************************/
+
+#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
+#define SW_PRS_UDP_LITE_PATCH \
+{\
+ 0x31,0x52,0x00,0xDA,0xFC,0x00,0x00,0x00,0x00,0x00, \
+ 0x00,0x00,0x50,0x2C,0x40,0x00,0x31,0x92,0x50,0x2C, \
+ 0x00,0x88,0x18,0x2F,0x00,0x01,0x1B,0xFE,0x18,0x71, \
+ 0x02,0x1F,0x00,0x08,0x00,0x83,0x02,0x1F,0x00,0x20, \
+ 0x28,0x1B,0x00,0x05,0x29,0x1F,0x30,0xD0,0x60,0x4F, \
+ 0x00,0x07,0x00,0x05,0x00,0x00,0xC3,0x8F,0x00,0x52, \
+ 0x00,0x01,0x07,0x01,0x60,0x3B,0x00,0x00,0x30,0xD0, \
+ 0x00,0xDA,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00, \
+ 0x40,0x4C,0x00,0x00,0x02,0x8F,0x00,0x00,0x30,0xF2, \
+ 0x00,0x06,0x18,0x5D,0x00,0x00,0x9F,0xFF,0x30,0xF2, \
+ 0x00,0x06,0x29,0x1E,0x07,0x08,0x30,0xD0,0x00,0x52, \
+ 0x00,0x08,0x28,0x1A,0x60,0x37,0x00,0x00,0x30,0xF2, \
+ 0x18,0x5D,0x06,0x00,0x29,0x1E,0x30,0xF2,0x2F,0x0E, \
+ 0x30,0x72,0x00,0x00,0x9B,0x8F,0x00,0x06,0x2F,0x0E, \
+ 0x32,0xF1,0x32,0xB0,0x00,0x4F,0x00,0x57,0x00,0x28, \
+ 0x00,0x00,0x97,0x9E,0x00,0x4E,0x30,0x72,0x00,0x06, \
+ 0x2F,0x0E,0x32,0xC1,0x32,0xF0,0x00,0x4A,0x00,0x80, \
+ 0x00,0x02,0x00,0x00,0x97,0x9E,0x40,0x7E,0x00,0x08, \
+ 0x08,0x16,0x00,0x54,0x00,0x01,0x1B,0xFE,0x00,0x00, \
+ 0x9F,0x9E,0x40,0xB3,0x00,0x00,0x02,0x1F,0x00,0x08, \
+ 0x28,0x1B,0x30,0x73,0x29,0x1F,0x30,0xD0,0x60,0x9F, \
+ 0x00,0x07,0x00,0x05,0x00,0x00,0xC3,0x8F,0x00,0x52, \
+ 0x00,0x01,0x07,0x01,0x60,0x8B,0x00,0x00,0x30,0xD0, \
+ 0x00,0xDA,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00, \
+ 0x40,0x9C,0x00,0x00,0x02,0x8F,0x00,0x00,0x30,0xF2, \
+ 0x00,0x06,0x18,0xAD,0x00,0x00,0x9F,0xFF,0x30,0xF2, \
+ 0x00,0x06,0x29,0x1E,0x07,0x08,0x30,0xD0,0x00,0x52, \
+ 0x00,0x08,0x28,0x1A,0x60,0x87,0x00,0x00,0x30,0xF2, \
+ 0x18,0xAD,0x06,0x00,0x29,0x1E,0x30,0xF2,0x50,0xB3, \
+ 0xFF,0xFF,0x18,0xB8,0x08,0x16,0x00,0x54,0x00,0x01, \
+ 0x1B,0xFE,0x18,0xC5,0x32,0xF1,0x28,0x5D,0x32,0xF1, \
+ 0x00,0x55,0x00,0x08,0x28,0x5F,0x00,0x00,0x8F,0x9F, \
+ 0x29,0x33,0x08,0x16,0x00,0x49,0x00,0x01,0x1B,0xFF, \
+ 0x00,0x01,0x1B,0xFF \
+}
+#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
+
+#if (DPAA_VERSION == 10)
+/* Version: 106.1.9 */
+#define SW_PRS_OFFLOAD_PATCH \
+{ \
+ 0x31,0x52,0x00,0xDA,0x0A,0x00,0x00,0x00,0x00,0x00, \
+ 0x00,0x00,0x43,0x0A,0x00,0x00,0x00,0x01,0x1B,0xFE, \
+ 0x00,0x00,0x99,0x00,0x53,0x13,0x00,0x00,0x00,0x00, \
+ 0x9F,0x98,0x53,0x13,0x00,0x00,0x1B,0x23,0x33,0xF1, \
+ 0x00,0xF9,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00, \
+ 0x28,0x7F,0x00,0x03,0x00,0x02,0x00,0x00,0x00,0x01, \
+ 0x32,0xC1,0x32,0xF0,0x00,0x4A,0x00,0x80,0x1F,0xFF, \
+ 0x00,0x01,0x1B,0xFE,0x31,0x52,0x00,0xDA,0x06,0x00, \
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x2F,0x00,0x00, \
+ 0x00,0x01,0x1B,0xFE,0x31,0x52,0x00,0xDA,0x00,0x40, \
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x53,0x95,0x00,0x00, \
+ 0x00,0x00,0x9B,0x8F,0x2F,0x0F,0x32,0xC1,0x00,0x55, \
+ 0x00,0x28,0x28,0x43,0x30,0x7E,0x43,0x45,0x00,0x00, \
+ 0x30,0x7E,0x43,0x45,0x00,0x3C,0x1B,0x5D,0x32,0x11, \
+ 0x32,0xC0,0x00,0x4F,0x00,0x81,0x00,0x00,0x83,0x8F, \
+ 0x2F,0x0F,0x06,0x00,0x32,0x11,0x32,0xC0,0x00,0x4F, \
+ 0x00,0x55,0x00,0x01,0x00,0x81,0x32,0x11,0x00,0x00, \
+ 0x83,0x8E,0x00,0x50,0x00,0x01,0x01,0x04,0x00,0x4D, \
+ 0x28,0x43,0x06,0x00,0x1B,0x3E,0x30,0x7E,0x53,0x79, \
+ 0x00,0x2B,0x32,0x11,0x32,0xC0,0x00,0x4F,0x00,0x81, \
+ 0x00,0x00,0x87,0x8F,0x28,0x23,0x06,0x00,0x32,0x11, \
+ 0x32,0xC0,0x00,0x4F,0x00,0x55,0x00,0x01,0x00,0x81, \
+ 0x32,0x11,0x00,0x00,0x83,0x8E,0x00,0x50,0x00,0x01, \
+ 0x01,0x04,0x00,0x4D,0x28,0x43,0x06,0x00,0x00,0x01, \
+ 0x1B,0xFE,0x00,0x00,0x9B,0x8E,0x53,0x90,0x00,0x00, \
+ 0x06,0x29,0x00,0x00,0x83,0x8F,0x28,0x23,0x06,0x00, \
+ 0x06,0x29,0x32,0xC1,0x00,0x55,0x00,0x28,0x00,0x00, \
+ 0x83,0x8E,0x00,0x50,0x00,0x01,0x01,0x04,0x00,0x4D, \
+ 0x28,0x43,0x06,0x00,0x00,0x01,0x1B,0xFE,0x32,0xC1, \
+ 0x00,0x55,0x00,0x28,0x28,0x43,0x1B,0xCF,0x00,0x00, \
+ 0x9B,0x8F,0x2F,0x0F,0x32,0xC1,0x00,0x55,0x00,0x28, \
+ 0x28,0x43,0x30,0x7E,0x43,0xBF,0x00,0x2C,0x32,0x11, \
+ 0x32,0xC0,0x00,0x4F,0x00,0x81,0x00,0x00,0x87,0x8F, \
+ 0x28,0x23,0x06,0x00,0x32,0x11,0x32,0xC0,0x00,0x4F, \
+ 0x00,0x81,0x00,0x00,0x83,0x8F,0x2F,0x0F,0x06,0x00, \
+ 0x32,0x11,0x32,0xC0,0x00,0x4F,0x00,0x55,0x00,0x01, \
+ 0x00,0x81,0x32,0x11,0x00,0x00,0x83,0x8E,0x00,0x50, \
+ 0x00,0x01,0x01,0x04,0x00,0x4D,0x28,0x43,0x06,0x00, \
+ 0x1B,0x9C,0x33,0xF1,0x00,0xF9,0x00,0x01,0x00,0x00, \
+ 0x00,0x00,0x00,0x00,0x28,0x7F,0x00,0x03,0x00,0x02, \
+ 0x00,0x00,0x00,0x01,0x32,0xC1,0x32,0xF0,0x00,0x4A, \
+ 0x00,0x80,0x1F,0xFF,0x00,0x01,0x1B,0xFE, \
+}
+
+#else
+#define SW_PRS_OFFLOAD_PATCH \
+{ \
+ 0x31,0x52,0x00,0xDA,0x0E,0x4F,0x00,0x00,0x00,0x00, \
+ 0x00,0x00,0x51,0x16,0x08,0x4B,0x31,0x53,0x00,0xFB, \
+ 0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x29,0x2B, \
+ 0x33,0xF1,0x00,0xFB,0x00,0xDF,0x00,0x00,0x00,0x00, \
+ 0x00,0x00,0x28,0x7F,0x31,0x52,0x00,0xDA,0x0A,0x00, \
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x20,0x00,0x00, \
+ 0x00,0x01,0x1B,0xFE,0x00,0x00,0x99,0x00,0x51,0x29, \
+ 0x00,0x00,0x00,0x00,0x9F,0x98,0x51,0x29,0x00,0x00, \
+ 0x19,0x44,0x09,0x5F,0x00,0x20,0x00,0x00,0x09,0x4F, \
+ 0x00,0x20,0x00,0x00,0x34,0xB7,0x00,0xF9,0x00,0x00, \
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x2B,0x97,0x31,0xB3, \
+ 0x29,0x8F,0x33,0xF1,0x00,0xF9,0x00,0x01,0x00,0x00, \
+ 0x00,0x00,0x00,0x00,0x28,0x7F,0x00,0x03,0x00,0x02, \
+ 0x00,0x00,0x00,0x01,0x1B,0xFE,0x00,0x01,0x1B,0xFE, \
+ 0x31,0x52,0x00,0xDA,0xFC,0x00,0x00,0x00,0x00,0x00, \
+ 0x00,0x00,0x51,0x52,0x40,0x00,0x31,0x92,0x51,0x52, \
+ 0x00,0x88,0x19,0x55,0x08,0x05,0x00,0x00,0x19,0x99, \
+ 0x02,0x1F,0x00,0x08,0x00,0x83,0x02,0x1F,0x00,0x20, \
+ 0x28,0x1B,0x00,0x05,0x29,0x1F,0x30,0xD0,0x61,0x75, \
+ 0x00,0x07,0x00,0x05,0x00,0x00,0xC3,0x8F,0x00,0x52, \
+ 0x00,0x01,0x07,0x01,0x61,0x61,0x00,0x00,0x30,0xD0, \
+ 0x00,0xDA,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00, \
+ 0x41,0x72,0x00,0x00,0x02,0x8F,0x00,0x00,0x30,0xF2, \
+ 0x00,0x06,0x19,0x83,0x00,0x00,0x9F,0xFF,0x30,0xF2, \
+ 0x00,0x06,0x29,0x1E,0x07,0x08,0x30,0xD0,0x00,0x52, \
+ 0x00,0x08,0x28,0x1A,0x61,0x5D,0x00,0x00,0x30,0xF2, \
+ 0x19,0x83,0x06,0x00,0x29,0x1E,0x30,0xF2,0x29,0x0E, \
+ 0x30,0x72,0x00,0x00,0x9B,0x8F,0x00,0x06,0x29,0x0E, \
+ 0x32,0xF1,0x32,0xB0,0x00,0x4F,0x00,0x57,0x00,0x28, \
+ 0x00,0x00,0x97,0x9E,0x00,0x4E,0x30,0x72,0x00,0x06, \
+ 0x29,0x0E,0x08,0x05,0x00,0x01,0x31,0x52,0x00,0xDA, \
+ 0x0E,0x4F,0x00,0x00,0x00,0x00,0x00,0x00,0x51,0xAF, \
+ 0x04,0x4B,0x31,0x53,0x00,0xFB,0xFF,0xF0,0x00,0x00, \
+ 0x00,0x00,0x00,0x00,0x29,0x2B,0x33,0xF1,0x00,0xFB, \
+ 0x00,0xDF,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x7F, \
+ 0x31,0x52,0x00,0xDA,0x06,0x00,0x00,0x00,0x00,0x00, \
+ 0x00,0x00,0x41,0xB9,0x00,0x00,0x00,0x01,0x1B,0xFE, \
+ 0x31,0x52,0x00,0xDA,0x00,0x40,0x00,0x00,0x00,0x00, \
+ 0x00,0x00,0x42,0x06,0x00,0x00,0x00,0x00,0x9B,0x8F, \
+ 0x28,0x01,0x32,0xC1,0x00,0x55,0x00,0x28,0x28,0x43, \
+ 0x30,0x00,0x41,0xEB,0x00,0x2C,0x32,0x11,0x32,0xC0, \
+ 0x00,0x4F,0x00,0x81,0x00,0x00,0x87,0x8F,0x28,0x23, \
+ 0x06,0x00,0x32,0x11,0x32,0xC0,0x00,0x4F,0x00,0x81, \
+ 0x00,0x00,0x83,0x8F,0x28,0x01,0x06,0x00,0x32,0x11, \
+ 0x32,0xC0,0x00,0x4F,0x00,0x55,0x00,0x01,0x00,0x81, \
+ 0x32,0x11,0x00,0x00,0x83,0x8E,0x00,0x50,0x00,0x01, \
+ 0x01,0x04,0x00,0x4D,0x28,0x43,0x06,0x00,0x19,0xC8, \
+ 0x09,0x5F,0x00,0x20,0x00,0x00,0x09,0x4F,0x00,0x20, \
+ 0x00,0x00,0x34,0xB7,0x00,0xF9,0x00,0x00,0x01,0x00, \
+ 0x00,0x00,0x00,0x00,0x2B,0x97,0x31,0xB3,0x29,0x8F, \
+ 0x33,0xF1,0x00,0xF9,0x00,0x01,0x00,0x00,0x00,0x00, \
+ 0x00,0x00,0x28,0x7F,0x00,0x03,0x00,0x02,0x00,0x00, \
+ 0x00,0x01,0x1B,0xFE,0x30,0x50,0x52,0x0B,0x00,0x00, \
+ 0x00,0x01,0x1B,0xFE,0x32,0xF1,0x32,0xC0,0x00,0x4F, \
+ 0x00,0x81,0x00,0x02,0x00,0x00,0x97,0x9E,0x42,0x18, \
+ 0x00,0x08,0x08,0x16,0x00,0x54,0x00,0x01,0x1B,0xFE, \
+ 0x00,0x00,0x9F,0x9E,0x42,0x4D,0x00,0x00,0x02,0x1F, \
+ 0x00,0x08,0x28,0x1B,0x30,0x73,0x29,0x1F,0x30,0xD0, \
+ 0x62,0x39,0x00,0x07,0x00,0x05,0x00,0x00,0xC3,0x8F, \
+ 0x00,0x52,0x00,0x01,0x07,0x01,0x62,0x25,0x00,0x00, \
+ 0x30,0xD0,0x00,0xDA,0x00,0x01,0x00,0x00,0x00,0x00, \
+ 0x00,0x00,0x42,0x36,0x00,0x00,0x02,0x8F,0x00,0x00, \
+ 0x30,0xF2,0x00,0x06,0x1A,0x47,0x00,0x00,0x9F,0xFF, \
+ 0x30,0xF2,0x00,0x06,0x29,0x1E,0x07,0x08,0x30,0xD0, \
+ 0x00,0x52,0x00,0x08,0x28,0x1A,0x62,0x21,0x00,0x00, \
+ 0x30,0xF2,0x1A,0x47,0x06,0x00,0x29,0x1E,0x30,0xF2, \
+ 0x52,0x4D,0xFF,0xFF,0x1A,0x52,0x08,0x16,0x00,0x54, \
+ 0x00,0x01,0x1B,0xFE,0x1A,0x5F,0x32,0xF1,0x28,0x5D, \
+ 0x32,0xF1,0x00,0x55,0x00,0x08,0x28,0x5F,0x00,0x00, \
+ 0x8F,0x9F,0x29,0x33,0x08,0x16,0x00,0x49,0x00,0x01, \
+ 0x1B,0xFF,0x00,0x01,0x1B,0xFF,0x31,0x52,0x00,0xDA, \
+ 0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x52,0x6D, \
+ 0x40,0x00,0x31,0x92,0x52,0x6D,0x00,0x88,0x1A,0x70, \
+ 0x08,0x05,0x00,0x00,0x1A,0xB4,0x02,0x1F,0x00,0x08, \
+ 0x00,0x83,0x02,0x1F,0x00,0x20,0x28,0x1B,0x00,0x05, \
+ 0x29,0x1F,0x30,0xD0,0x62,0x90,0x00,0x07,0x00,0x05, \
+ 0x00,0x00,0xC3,0x8F,0x00,0x52,0x00,0x01,0x07,0x01, \
+ 0x62,0x7C,0x00,0x00,0x30,0xD0,0x00,0xDA,0x00,0x01, \
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x8D,0x00,0x00, \
+ 0x02,0x8F,0x00,0x00,0x30,0xF2,0x00,0x06,0x1A,0x9E, \
+ 0x00,0x00,0x9F,0xFF,0x30,0xF2,0x00,0x06,0x29,0x1E, \
+ 0x07,0x08,0x30,0xD0,0x00,0x52,0x00,0x08,0x28,0x1A, \
+ 0x62,0x78,0x00,0x00,0x30,0xF2,0x1A,0x9E,0x06,0x00, \
+ 0x29,0x1E,0x30,0xF2,0x29,0x0E,0x30,0x72,0x00,0x00, \
+ 0x9B,0x8F,0x00,0x06,0x29,0x0E,0x32,0xF1,0x32,0xB0, \
+ 0x00,0x4F,0x00,0x57,0x00,0x28,0x00,0x00,0x97,0x9E, \
+ 0x00,0x4E,0x30,0x72,0x00,0x06,0x29,0x0E,0x08,0x05, \
+ 0x00,0x01,0x31,0x52,0x00,0xDA,0x0E,0x4F,0x00,0x00, \
+ 0x00,0x00,0x00,0x00,0x52,0xCA,0x04,0x4B,0x31,0x53, \
+ 0x00,0xFB,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00, \
+ 0x29,0x2B,0x33,0xF1,0x00,0xFB,0x00,0xDF,0x00,0x00, \
+ 0x00,0x00,0x00,0x00,0x28,0x7F,0x31,0x52,0x00,0xDA, \
+ 0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x42,0xD4, \
+ 0x00,0x00,0x00,0x01,0x1B,0xFE,0x31,0x52,0x00,0xDA, \
+ 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x53,0x37, \
+ 0x00,0x00,0x00,0x00,0x9B,0x8F,0x28,0x01,0x32,0xC1, \
+ 0x00,0x55,0x00,0x28,0x28,0x43,0x30,0x00,0x42,0xEA, \
+ 0x00,0x00,0x30,0x00,0x42,0xEA,0x00,0x3C,0x1B,0x02, \
+ 0x32,0x11,0x32,0xC0,0x00,0x4F,0x00,0x81,0x00,0x00, \
+ 0x83,0x8F,0x28,0x01,0x06,0x00,0x32,0x11,0x32,0xC0, \
+ 0x00,0x4F,0x00,0x55,0x00,0x01,0x00,0x81,0x32,0x11, \
+ 0x00,0x00,0x83,0x8E,0x00,0x50,0x00,0x01,0x01,0x04, \
+ 0x00,0x4D,0x28,0x43,0x06,0x00,0x1A,0xE3,0x30,0x00, \
+ 0x43,0x20,0x00,0x2B,0x00,0x00,0x9B,0x8E,0x43,0x0E, \
+ 0x00,0x00,0x32,0xC1,0x00,0x55,0x00,0x28,0x28,0x43, \
+ 0x1B,0x1F,0x06,0x29,0x00,0x00,0x83,0x8F,0x28,0x23, \
+ 0x06,0x00,0x06,0x29,0x32,0xC1,0x00,0x55,0x00,0x28, \
+ 0x00,0x00,0x83,0x8E,0x00,0x50,0x00,0x01,0x01,0x04, \
+ 0x00,0x4D,0x28,0x43,0x06,0x00,0x1B,0x37,0x32,0x11, \
+ 0x32,0xC0,0x00,0x4F,0x00,0x81,0x00,0x00,0x87,0x8F, \
+ 0x28,0x23,0x06,0x00,0x32,0x11,0x32,0xC0,0x00,0x4F, \
+ 0x00,0x55,0x00,0x01,0x00,0x81,0x32,0x11,0x00,0x00, \
+ 0x83,0x8E,0x00,0x50,0x00,0x01,0x01,0x04,0x00,0x4D, \
+ 0x28,0x43,0x06,0x00,0x30,0x50,0x53,0x3C,0x00,0x00, \
+ 0x00,0x01,0x1B,0xFE,0x32,0xF1,0x32,0xC0,0x00,0x4F, \
+ 0x00,0x81,0x00,0x02,0x00,0x00,0x97,0x9E,0x43,0x49, \
+ 0x00,0x08,0x08,0x16,0x00,0x54,0x00,0x01,0x1B,0xFE, \
+ 0x00,0x00,0x9F,0x9E,0x43,0x7E,0x00,0x00,0x02,0x1F, \
+ 0x00,0x08,0x28,0x1B,0x30,0x73,0x29,0x1F,0x30,0xD0, \
+ 0x63,0x6A,0x00,0x07,0x00,0x05,0x00,0x00,0xC3,0x8F, \
+ 0x00,0x52,0x00,0x01,0x07,0x01,0x63,0x56,0x00,0x00, \
+ 0x30,0xD0,0x00,0xDA,0x00,0x01,0x00,0x00,0x00,0x00, \
+ 0x00,0x00,0x43,0x67,0x00,0x00,0x02,0x8F,0x00,0x00, \
+ 0x30,0xF2,0x00,0x06,0x1B,0x78,0x00,0x00,0x9F,0xFF, \
+ 0x30,0xF2,0x00,0x06,0x29,0x1E,0x07,0x08,0x30,0xD0, \
+ 0x00,0x52,0x00,0x08,0x28,0x1A,0x63,0x52,0x00,0x00, \
+ 0x30,0xF2,0x1B,0x78,0x06,0x00,0x29,0x1E,0x30,0xF2, \
+ 0x53,0x7E,0xFF,0xFF,0x1B,0x83,0x08,0x16,0x00,0x54, \
+ 0x00,0x01,0x1B,0xFE,0x1B,0x90,0x32,0xF1,0x28,0x5D, \
+ 0x32,0xF1,0x00,0x55,0x00,0x08,0x28,0x5F,0x00,0x00, \
+ 0x8F,0x9F,0x29,0x33,0x08,0x16,0x00,0x49,0x00,0x01, \
+ 0x1B,0xFF,0x00,0x01,0x1B,0xFF,0x08,0x07,0x00,0x02, \
+ 0x00,0x00,0x8D,0x80,0x53,0x9C,0x00,0x01,0x30,0x71, \
+ 0x00,0x55,0x00,0x01,0x28,0x0F,0x00,0x00,0x8D,0x00, \
+ 0x53,0xA4,0x00,0x01,0x30,0x71,0x00,0x55,0x00,0x01, \
+ 0x28,0x0F,0x00,0x00,0x83,0x8E,0x53,0xB9,0x00,0x00, \
+ 0x00,0x00,0x86,0x08,0x30,0x71,0x00,0x7B,0x03,0xB9, \
+ 0x33,0xB4,0x00,0xDA,0xFF,0xFF,0x00,0x0F,0x00,0x00, \
+ 0x00,0x00,0x00,0x00,0x86,0x09,0x01,0x03,0x00,0x7D, \
+ 0x03,0xB9,0x1B,0xC8,0x33,0xD1,0x00,0xF9,0x00,0x10, \
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x7B,0x09,0x5F, \
+ 0x00,0x1A,0x00,0x00,0x09,0x4F,0x00,0x1A,0x00,0x00, \
+ 0x00,0x01,0x1B,0xFF,0x00,0x00,0x8C,0x00,0x53,0xF0, \
+ 0x00,0x01,0x34,0xF5,0x00,0xFB,0xFF,0xFF,0x00,0x7F, \
+ 0x00,0x00,0x00,0x00,0x2A,0x9F,0x00,0x00,0x93,0x8F, \
+ 0x28,0x49,0x00,0x00,0x97,0x8F,0x28,0x4B,0x34,0x61, \
+ 0x28,0x4D,0x34,0x71,0x28,0x4F,0x34,0xB7,0x00,0xF9, \
+ 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x2B,0x97, \
+ 0x33,0xF1,0x00,0xF9,0x00,0x01,0x00,0x00,0x00,0x00, \
+ 0x00,0x00,0x28,0x7F,0x00,0x03,0x00,0x02,0x00,0x00, \
+ 0x00,0x01,0x1B,0xFF,0x00,0x01,0x1B,0xFF, \
+}
+#endif /* (DPAA_VERSION == 10) */
+
+/****************************/
+/* Parser defines */
+/****************************/
+#define FM_PCD_PRS_SW_TAIL_SIZE 4 /**< Number of bytes that must be cleared at
+ the end of the SW parser area */
+
+/* masks */
+#define PRS_ERR_CAP 0x80000000
+#define PRS_ERR_TYPE_DOUBLE 0x40000000
+#define PRS_ERR_SINGLE_ECC_CNT_MASK 0x00FF0000
+#define PRS_ERR_ADDR_MASK 0x000001FF
+
+/* others */
+#define PRS_MAX_CYCLE_LIMIT 8191
+#define PRS_SW_DATA 0x00000800
+#define PRS_REGS_OFFSET 0x00000840
+
+#define GET_FM_PCD_PRS_PORT_ID(prsPortId,hardwarePortId) \
+ prsPortId = (uint8_t)(hardwarePortId & 0x0f)
+
+#define GET_FM_PCD_INDEX_FLAG(bitMask, prsPortId) \
+ bitMask = 0x80000000>>prsPortId
+
+#endif /* __FM_PRS_H */
diff --git a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_replic.c b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_replic.c
new file mode 100644
index 000000000000..ee82f73014b6
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_replic.c
@@ -0,0 +1,984 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/******************************************************************************
+ @File fm_replic.c
+
+ @Description FM frame replicator
+*//***************************************************************************/
+#include "std_ext.h"
+#include "error_ext.h"
+#include "string_ext.h"
+#include "debug_ext.h"
+#include "fm_pcd_ext.h"
+#include "fm_muram_ext.h"
+#include "fm_common.h"
+#include "fm_hc.h"
+#include "fm_replic.h"
+#include "fm_cc.h"
+#include "list_ext.h"
+
+
+/****************************************/
+/* static functions */
+/****************************************/
+static uint8_t GetMemberPosition(t_FmPcdFrmReplicGroup *p_ReplicGroup,
+ uint32_t memberIndex,
+ bool isAddOperation)
+{
+ uint8_t memberPosition;
+ uint32_t lastMemberIndex;
+
+ ASSERT_COND(p_ReplicGroup);
+
+ /* the last member index is different between add and remove operation -
+ in case of remove - this is exactly the last member index
+ in case of add - this is the last member index + 1 - e.g.
+ if we have 4 members, the index of the actual last member is 3(because the
+ index starts from 0) therefore in order to add a new member as the last
+ member we shall use memberIndex = 4 and not 3
+ */
+ if (isAddOperation)
+ lastMemberIndex = p_ReplicGroup->numOfEntries;
+ else
+ lastMemberIndex = p_ReplicGroup->numOfEntries-1;
+
+ /* last */
+ if (memberIndex == lastMemberIndex)
+ memberPosition = FRM_REPLIC_LAST_MEMBER_INDEX;
+ else
+ {
+ /* first */
+ if (memberIndex == 0)
+ memberPosition = FRM_REPLIC_FIRST_MEMBER_INDEX;
+ else
+ {
+ /* middle */
+ ASSERT_COND(memberIndex < lastMemberIndex);
+ memberPosition = FRM_REPLIC_MIDDLE_MEMBER_INDEX;
+ }
+ }
+ return memberPosition;
+}
+
+static t_Error MemberCheckParams(t_Handle h_FmPcd,
+ t_FmPcdCcNextEngineParams *p_MemberParams)
+{
+ t_Error err;
+
+
+ if ((p_MemberParams->nextEngine != e_FM_PCD_DONE) &&
+ (p_MemberParams->nextEngine != e_FM_PCD_KG) &&
+ (p_MemberParams->nextEngine != e_FM_PCD_PLCR))
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Next engine of a member should be MatchTable(cc) or Done or Policer"));
+
+ /* check the regular parameters of the next engine */
+ err = ValidateNextEngineParams(h_FmPcd, p_MemberParams, e_FM_PCD_CC_STATS_MODE_NONE);
+ if (err)
+ RETURN_ERROR(MAJOR, err, ("member next engine parameters"));
+
+ return E_OK;
+}
+
+static t_Error CheckParams(t_Handle h_FmPcd,
+ t_FmPcdFrmReplicGroupParams *p_ReplicGroupParam)
+{
+ int i;
+ t_Error err;
+
+ /* check that max num of entries is at least 2 */
+ if (!IN_RANGE(2, p_ReplicGroupParam->maxNumOfEntries, FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES))
+ RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, ("maxNumOfEntries in the frame replicator parameters should be 2-%d",FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES));
+
+ /* check that number of entries is greater than zero */
+ if (!p_ReplicGroupParam->numOfEntries)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOFEntries in the frame replicator group should be greater than zero"));
+
+ /* check that max num of entries is equal or greater than number of entries */
+ if (p_ReplicGroupParam->maxNumOfEntries < p_ReplicGroupParam->numOfEntries)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("maxNumOfEntries should be equal or greater than numOfEntries"));
+
+ for (i=0; i<p_ReplicGroupParam->numOfEntries; i++)
+ {
+ err = MemberCheckParams(h_FmPcd, &p_ReplicGroupParam->nextEngineParams[i]);
+ if (err)
+ RETURN_ERROR(MAJOR, err, ("member check parameters"));
+ }
+ return E_OK;
+}
+
+static t_FmPcdFrmReplicMember *GetAvailableMember(t_FmPcdFrmReplicGroup *p_ReplicGroup)
+{
+ t_FmPcdFrmReplicMember *p_ReplicMember = NULL;
+ t_List *p_Next;
+
+ if (!LIST_IsEmpty(&p_ReplicGroup->availableMembersList))
+ {
+ p_Next = LIST_FIRST(&p_ReplicGroup->availableMembersList);
+ p_ReplicMember = LIST_OBJECT(p_Next, t_FmPcdFrmReplicMember, node);
+ ASSERT_COND(p_ReplicMember);
+ LIST_DelAndInit(p_Next);
+ }
+ return p_ReplicMember;
+}
+
+static void PutAvailableMember(t_FmPcdFrmReplicGroup *p_ReplicGroup,
+ t_FmPcdFrmReplicMember *p_ReplicMember)
+{
+ LIST_AddToTail(&p_ReplicMember->node, &p_ReplicGroup->availableMembersList);
+}
+
+static void AddMemberToList(t_FmPcdFrmReplicGroup *p_ReplicGroup,
+ t_FmPcdFrmReplicMember *p_CurrentMember,
+ t_List *p_ListHead)
+{
+ LIST_Add(&p_CurrentMember->node, p_ListHead);
+
+ p_ReplicGroup->numOfEntries++;
+}
+
+static void RemoveMemberFromList(t_FmPcdFrmReplicGroup *p_ReplicGroup,
+ t_FmPcdFrmReplicMember *p_CurrentMember)
+{
+ ASSERT_COND(p_ReplicGroup->numOfEntries);
+ LIST_DelAndInit(&p_CurrentMember->node);
+ p_ReplicGroup->numOfEntries--;
+}
+
+static void LinkSourceToMember(t_FmPcdFrmReplicGroup *p_ReplicGroup,
+ t_AdOfTypeContLookup *p_SourceTd,
+ t_FmPcdFrmReplicMember *p_ReplicMember)
+{
+ t_FmPcd *p_FmPcd;
+
+ ASSERT_COND(p_SourceTd);
+ ASSERT_COND(p_ReplicMember);
+ ASSERT_COND(p_ReplicGroup);
+ ASSERT_COND(p_ReplicGroup->h_FmPcd);
+
+ /* Link the first member in the group to the source TD */
+ p_FmPcd = p_ReplicGroup->h_FmPcd;
+
+ WRITE_UINT32(p_SourceTd->matchTblPtr,
+ (uint32_t)(XX_VirtToPhys(p_ReplicMember->p_MemberAd) -
+ p_FmPcd->physicalMuramBase));
+}
+
+static void LinkMemberToMember(t_FmPcdFrmReplicGroup *p_ReplicGroup,
+ t_FmPcdFrmReplicMember *p_CurrentMember,
+ t_FmPcdFrmReplicMember *p_NextMember)
+{
+ t_AdOfTypeResult *p_CurrReplicAd = (t_AdOfTypeResult*)p_CurrentMember->p_MemberAd;
+ t_AdOfTypeResult *p_NextReplicAd = NULL;
+ t_FmPcd *p_FmPcd;
+ uint32_t offset = 0;
+
+ /* Check if the next member exists or it's NULL (- means that this is the last member) */
+ if (p_NextMember)
+ {
+ p_NextReplicAd = (t_AdOfTypeResult*)p_NextMember->p_MemberAd;
+ p_FmPcd = p_ReplicGroup->h_FmPcd;
+ offset = (XX_VirtToPhys(p_NextReplicAd) - (p_FmPcd->physicalMuramBase));
+ offset = ((offset>>NEXT_FRM_REPLIC_ADDR_SHIFT)<< NEXT_FRM_REPLIC_MEMBER_INDEX_SHIFT);
+ }
+
+ /* link the current AD to point to the AD of the next member */
+ WRITE_UINT32(p_CurrReplicAd->res, offset);
+}
+
+static t_Error ModifyDescriptor(t_FmPcdFrmReplicGroup *p_ReplicGroup,
+ void *p_OldDescriptor,
+ void *p_NewDescriptor)
+{
+ t_Handle h_Hc;
+ t_Error err;
+ t_FmPcd *p_FmPcd;
+
+ ASSERT_COND(p_ReplicGroup);
+ ASSERT_COND(p_ReplicGroup->h_FmPcd);
+ ASSERT_COND(p_OldDescriptor);
+ ASSERT_COND(p_NewDescriptor);
+
+ p_FmPcd = p_ReplicGroup->h_FmPcd;
+ h_Hc = FmPcdGetHcHandle(p_FmPcd);
+ if (!h_Hc)
+ RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("Host command"));
+
+ err = FmHcPcdCcDoDynamicChange(h_Hc,
+ (uint32_t)(XX_VirtToPhys(p_OldDescriptor) - p_FmPcd->physicalMuramBase),
+ (uint32_t)(XX_VirtToPhys(p_NewDescriptor) - p_FmPcd->physicalMuramBase));
+ if (err)
+ RETURN_ERROR(MAJOR, err, ("Dynamic change host command"));
+
+ return E_OK;
+}
+
+static void FillReplicAdOfTypeResult(void *p_ReplicAd, bool last)
+{
+ t_AdOfTypeResult *p_CurrReplicAd = (t_AdOfTypeResult*)p_ReplicAd;
+ uint32_t tmp;
+
+ tmp = GET_UINT32(p_CurrReplicAd->plcrProfile);
+ if (last)
+ /* clear the NL bit in case it's the last member in the group*/
+ WRITE_UINT32(p_CurrReplicAd->plcrProfile,(tmp & ~FRM_REPLIC_NL_BIT));
+ else
+ /* set the NL bit in case it's not the last member in the group */
+ WRITE_UINT32(p_CurrReplicAd->plcrProfile, (tmp |FRM_REPLIC_NL_BIT));
+
+ /* set FR bit in the action descriptor */
+ tmp = GET_UINT32(p_CurrReplicAd->nia);
+ WRITE_UINT32(p_CurrReplicAd->nia,
+ (tmp | FRM_REPLIC_FR_BIT | FM_PCD_AD_RESULT_EXTENDED_MODE ));
+}
+
+static void BuildSourceTd(void *p_Ad)
+{
+ t_AdOfTypeContLookup *p_SourceTd;
+
+ ASSERT_COND(p_Ad);
+
+ p_SourceTd = (t_AdOfTypeContLookup *)p_Ad;
+
+ IOMemSet32((uint8_t*)p_SourceTd, 0, FM_PCD_CC_AD_ENTRY_SIZE);
+
+ /* initialize the source table descriptor */
+ WRITE_UINT32(p_SourceTd->ccAdBase, FM_PCD_AD_CONT_LOOKUP_TYPE);
+ WRITE_UINT32(p_SourceTd->pcAndOffsets, FRM_REPLIC_SOURCE_TD_OPCODE);
+}
+
+static t_Error BuildShadowAndModifyDescriptor(t_FmPcdFrmReplicGroup *p_ReplicGroup,
+ t_FmPcdFrmReplicMember *p_NextMember,
+ t_FmPcdFrmReplicMember *p_CurrentMember,
+ bool sourceDescriptor,
+ bool last)
+{
+ t_FmPcd *p_FmPcd;
+ t_FmPcdFrmReplicMember shadowMember;
+ t_Error err;
+
+ ASSERT_COND(p_ReplicGroup);
+ ASSERT_COND(p_ReplicGroup->h_FmPcd);
+
+ p_FmPcd = p_ReplicGroup->h_FmPcd;
+ ASSERT_COND(p_FmPcd->p_CcShadow);
+
+ if (!TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))
+ return ERROR_CODE(E_BUSY);
+
+ if (sourceDescriptor)
+ {
+ BuildSourceTd(p_FmPcd->p_CcShadow);
+ LinkSourceToMember(p_ReplicGroup, p_FmPcd->p_CcShadow, p_NextMember);
+
+ /* Modify the source table descriptor according to the prepared shadow descriptor */
+ err = ModifyDescriptor(p_ReplicGroup,
+ p_ReplicGroup->p_SourceTd,
+ p_FmPcd->p_CcShadow/* new prepared source td */);
+
+ RELEASE_LOCK(p_FmPcd->shadowLock);
+ if (err)
+ RETURN_ERROR(MAJOR, err, ("Modify source Descriptor in BuildShadowAndModifyDescriptor"));
+
+ }
+ else
+ {
+ IO2IOCpy32(p_FmPcd->p_CcShadow,
+ p_CurrentMember->p_MemberAd,
+ FM_PCD_CC_AD_ENTRY_SIZE);
+
+ /* update the last bit in the shadow ad */
+ FillReplicAdOfTypeResult(p_FmPcd->p_CcShadow, last);
+
+ shadowMember.p_MemberAd = p_FmPcd->p_CcShadow;
+
+ /* update the next FR member index */
+ LinkMemberToMember(p_ReplicGroup, &shadowMember, p_NextMember);
+
+ /* Modify the next member according to the prepared shadow descriptor */
+ err = ModifyDescriptor(p_ReplicGroup,
+ p_CurrentMember->p_MemberAd,
+ p_FmPcd->p_CcShadow);
+
+ RELEASE_LOCK(p_FmPcd->shadowLock);
+ if (err)
+ RETURN_ERROR(MAJOR, err, ("Modify Descriptor in BuildShadowAndModifyDescriptor"));
+ }
+
+
+ return E_OK;
+}
+
+static t_FmPcdFrmReplicMember* GetMemberByIndex(t_FmPcdFrmReplicGroup *p_ReplicGroup,
+ uint16_t memberIndex)
+{
+ int i=0;
+ t_List *p_Pos;
+ t_FmPcdFrmReplicMember *p_Member = NULL;
+
+ LIST_FOR_EACH(p_Pos, &p_ReplicGroup->membersList)
+ {
+ if (i == memberIndex)
+ {
+ p_Member = LIST_OBJECT(p_Pos, t_FmPcdFrmReplicMember, node);
+ return p_Member;
+ }
+ i++;
+ }
+ return p_Member;
+}
+
+static t_Error AllocMember(t_FmPcdFrmReplicGroup *p_ReplicGroup)
+{
+ t_FmPcdFrmReplicMember *p_CurrentMember;
+ t_Handle h_Muram;
+
+ ASSERT_COND(p_ReplicGroup);
+
+ h_Muram = FmPcdGetMuramHandle(p_ReplicGroup->h_FmPcd);
+ ASSERT_COND(h_Muram);
+
+ /* Initialize an internal structure of a member to add to the available members list */
+ p_CurrentMember = (t_FmPcdFrmReplicMember *)XX_Malloc(sizeof(t_FmPcdFrmReplicMember));
+ if (!p_CurrentMember)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Frame replicator member"));
+
+ memset(p_CurrentMember, 0 ,sizeof(t_FmPcdFrmReplicMember));
+
+ /* Allocate the member AD */
+ p_CurrentMember->p_MemberAd =
+ (t_AdOfTypeResult*)FM_MURAM_AllocMem(h_Muram,
+ FM_PCD_CC_AD_ENTRY_SIZE,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if (!p_CurrentMember->p_MemberAd)
+ {
+ XX_Free(p_CurrentMember);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("member AD table"));
+ }
+ IOMemSet32((uint8_t*)p_CurrentMember->p_MemberAd, 0, FM_PCD_CC_AD_ENTRY_SIZE);
+
+ /* Add the new member to the available members list */
+ LIST_AddToTail(&p_CurrentMember->node, &(p_ReplicGroup->availableMembersList));
+
+ return E_OK;
+}
+
+static t_FmPcdFrmReplicMember* InitMember(t_FmPcdFrmReplicGroup *p_ReplicGroup,
+ t_FmPcdCcNextEngineParams *p_MemberParams,
+ bool last)
+{
+ t_FmPcdFrmReplicMember *p_CurrentMember = NULL;
+
+ ASSERT_COND(p_ReplicGroup);
+
+ /* Get an available member from the internal members list */
+ p_CurrentMember = GetAvailableMember(p_ReplicGroup);
+ if (!p_CurrentMember)
+ {
+ REPORT_ERROR(MAJOR, E_NOT_FOUND, ("Available member"));
+ return NULL;
+ }
+ p_CurrentMember->h_Manip = NULL;
+
+ /* clear the Ad of the new member */
+ IOMemSet32((uint8_t*)p_CurrentMember->p_MemberAd, 0, FM_PCD_CC_AD_ENTRY_SIZE);
+
+ INIT_LIST(&p_CurrentMember->node);
+
+ /* Initialize the Ad of the member */
+ NextStepAd(p_CurrentMember->p_MemberAd,
+ NULL,
+ p_MemberParams,
+ p_ReplicGroup->h_FmPcd);
+
+ /* save Manip handle (for free needs) */
+ if (p_MemberParams->h_Manip)
+ p_CurrentMember->h_Manip = p_MemberParams->h_Manip;
+
+ /* Initialize the relevant frame replicator fields in the AD */
+ FillReplicAdOfTypeResult(p_CurrentMember->p_MemberAd, last);
+
+ return p_CurrentMember;
+}
+
+static void FreeMember(t_FmPcdFrmReplicGroup *p_ReplicGroup,
+ t_FmPcdFrmReplicMember *p_Member)
+{
+ /* Note: Can't free the member AD just returns the member to the available
+ member list - therefore only memset the AD */
+
+ /* zero the AD */
+ IOMemSet32(p_Member->p_MemberAd, 0, FM_PCD_CC_AD_ENTRY_SIZE);
+
+
+ /* return the member to the available members list */
+ PutAvailableMember(p_ReplicGroup, p_Member);
+}
+
+static t_Error RemoveMember(t_FmPcdFrmReplicGroup *p_ReplicGroup,
+ uint16_t memberIndex)
+{
+ t_FmPcd *p_FmPcd = NULL;
+ t_FmPcdFrmReplicMember *p_CurrentMember = NULL, *p_PreviousMember = NULL, *p_NextMember = NULL;
+ t_Error err;
+ uint8_t memberPosition;
+
+ p_FmPcd = p_ReplicGroup->h_FmPcd;
+ ASSERT_COND(p_FmPcd);
+ UNUSED(p_FmPcd);
+
+ p_CurrentMember = GetMemberByIndex(p_ReplicGroup, memberIndex);
+ ASSERT_COND(p_CurrentMember);
+
+ /* determine the member position in the group */
+ memberPosition = GetMemberPosition(p_ReplicGroup,
+ memberIndex,
+ FALSE/*remove operation*/);
+
+ switch (memberPosition)
+ {
+ case FRM_REPLIC_FIRST_MEMBER_INDEX:
+ p_NextMember = GetMemberByIndex(p_ReplicGroup, (uint16_t)(memberIndex+1));
+ ASSERT_COND(p_NextMember);
+
+ /* update the source td itself by using a host command */
+ err = BuildShadowAndModifyDescriptor(p_ReplicGroup,
+ p_NextMember,
+ NULL,
+ TRUE/*sourceDescriptor*/,
+ FALSE/*last*/);
+ break;
+
+ case FRM_REPLIC_MIDDLE_MEMBER_INDEX:
+ p_PreviousMember = GetMemberByIndex(p_ReplicGroup, (uint16_t)(memberIndex-1));
+ ASSERT_COND(p_PreviousMember);
+
+ p_NextMember = GetMemberByIndex(p_ReplicGroup, (uint16_t)(memberIndex+1));
+ ASSERT_COND(p_NextMember);
+
+ err = BuildShadowAndModifyDescriptor(p_ReplicGroup,
+ p_NextMember,
+ p_PreviousMember,
+ FALSE/*sourceDescriptor*/,
+ FALSE/*last*/);
+
+ break;
+
+ case FRM_REPLIC_LAST_MEMBER_INDEX:
+ p_PreviousMember = GetMemberByIndex(p_ReplicGroup, (uint16_t)(memberIndex-1));
+ ASSERT_COND(p_PreviousMember);
+
+ err = BuildShadowAndModifyDescriptor(p_ReplicGroup,
+ NULL,
+ p_PreviousMember,
+ FALSE/*sourceDescriptor*/,
+ TRUE/*last*/);
+ break;
+
+ default:
+ RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("member position in remove member"));
+ }
+
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ if (p_CurrentMember->h_Manip)
+ {
+ FmPcdManipUpdateOwner(p_CurrentMember->h_Manip, FALSE);
+ p_CurrentMember->h_Manip = NULL;
+ }
+
+ /* remove the member from the driver internal members list */
+ RemoveMemberFromList(p_ReplicGroup, p_CurrentMember);
+
+ /* return the member to the available members list */
+ FreeMember(p_ReplicGroup, p_CurrentMember);
+
+ return E_OK;
+}
+
+static void DeleteGroup(t_FmPcdFrmReplicGroup *p_ReplicGroup)
+{
+ int i, j;
+ t_Handle h_Muram;
+ t_FmPcdFrmReplicMember *p_Member, *p_CurrentMember;
+
+ if (p_ReplicGroup)
+ {
+ ASSERT_COND(p_ReplicGroup->h_FmPcd);
+ h_Muram = FmPcdGetMuramHandle(p_ReplicGroup->h_FmPcd);
+ ASSERT_COND(h_Muram);
+
+ /* free the source table descriptor */
+ if (p_ReplicGroup->p_SourceTd)
+ {
+ FM_MURAM_FreeMem(h_Muram, p_ReplicGroup->p_SourceTd);
+ p_ReplicGroup->p_SourceTd = NULL;
+ }
+
+ /* Remove all members from the members linked list (hw and sw) and
+ return the members to the available members list */
+ if (p_ReplicGroup->numOfEntries)
+ {
+ j = p_ReplicGroup->numOfEntries-1;
+
+ /* manually removal of the member because there are no owners of
+ this group */
+ for (i=j; i>=0; i--)
+ {
+ p_CurrentMember = GetMemberByIndex(p_ReplicGroup, (uint16_t)i/*memberIndex*/);
+ ASSERT_COND(p_CurrentMember);
+
+ if (p_CurrentMember->h_Manip)
+ {
+ FmPcdManipUpdateOwner(p_CurrentMember->h_Manip, FALSE);
+ p_CurrentMember->h_Manip = NULL;
+ }
+
+ /* remove the member from the internal driver members list */
+ RemoveMemberFromList(p_ReplicGroup, p_CurrentMember);
+
+ /* return the member to the available members list */
+ FreeMember(p_ReplicGroup, p_CurrentMember);
+ }
+ }
+
+ /* Free members AD */
+ for (i=0; i<p_ReplicGroup->maxNumOfEntries; i++)
+ {
+ p_Member = GetAvailableMember(p_ReplicGroup);
+ ASSERT_COND(p_Member);
+ if (p_Member->p_MemberAd)
+ {
+ FM_MURAM_FreeMem(h_Muram, p_Member->p_MemberAd);
+ p_Member->p_MemberAd = NULL;
+ }
+ XX_Free(p_Member);
+ }
+
+ /* release the group lock */
+ if (p_ReplicGroup->p_Lock)
+ FmPcdReleaseLock(p_ReplicGroup->h_FmPcd, p_ReplicGroup->p_Lock);
+
+ /* free the replicator group */
+ XX_Free(p_ReplicGroup);
+ }
+}
+
+
+/*****************************************************************************/
+/* Inter-module API routines */
+/*****************************************************************************/
+
+/* NOTE: the inter-module routines are locked by cc in case of using them */
+void * FrmReplicGroupGetSourceTableDescriptor(t_Handle h_ReplicGroup)
+{
+ t_FmPcdFrmReplicGroup *p_ReplicGroup = (t_FmPcdFrmReplicGroup *)h_ReplicGroup;
+ ASSERT_COND(p_ReplicGroup);
+
+ return (p_ReplicGroup->p_SourceTd);
+}
+
+void FrmReplicGroupUpdateAd(t_Handle h_ReplicGroup,
+ void *p_Ad,
+ t_Handle *h_AdNew)
+{
+ t_FmPcdFrmReplicGroup *p_ReplicGroup = (t_FmPcdFrmReplicGroup *)h_ReplicGroup;
+ t_AdOfTypeResult *p_AdResult = (t_AdOfTypeResult*)p_Ad;
+ t_FmPcd *p_FmPcd;
+
+ ASSERT_COND(p_ReplicGroup);
+ p_FmPcd = p_ReplicGroup->h_FmPcd;
+
+ /* build a bypass ad */
+ WRITE_UINT32(p_AdResult->fqid, FM_PCD_AD_BYPASS_TYPE |
+ (uint32_t)((XX_VirtToPhys(p_ReplicGroup->p_SourceTd)) - p_FmPcd->physicalMuramBase));
+
+ *h_AdNew = NULL;
+}
+
+void FrmReplicGroupUpdateOwner(t_Handle h_ReplicGroup,
+ bool add)
+{
+ t_FmPcdFrmReplicGroup *p_ReplicGroup = (t_FmPcdFrmReplicGroup *)h_ReplicGroup;
+ ASSERT_COND(p_ReplicGroup);
+
+ /* update the group owner counter */
+ if (add)
+ p_ReplicGroup->owners++;
+ else
+ {
+ ASSERT_COND(p_ReplicGroup->owners);
+ p_ReplicGroup->owners--;
+ }
+}
+
+t_Error FrmReplicGroupTryLock(t_Handle h_ReplicGroup)
+{
+ t_FmPcdFrmReplicGroup *p_ReplicGroup = (t_FmPcdFrmReplicGroup *)h_ReplicGroup;
+
+ ASSERT_COND(h_ReplicGroup);
+
+ if (FmPcdLockTryLock(p_ReplicGroup->p_Lock))
+ return E_OK;
+
+ return ERROR_CODE(E_BUSY);
+}
+
+void FrmReplicGroupUnlock(t_Handle h_ReplicGroup)
+{
+ t_FmPcdFrmReplicGroup *p_ReplicGroup = (t_FmPcdFrmReplicGroup *)h_ReplicGroup;
+
+ ASSERT_COND(h_ReplicGroup);
+
+ FmPcdLockUnlock(p_ReplicGroup->p_Lock);
+}
+/*********************** End of inter-module routines ************************/
+
+
+/****************************************/
+/* API Init unit functions */
+/****************************************/
+t_Handle FM_PCD_FrmReplicSetGroup(t_Handle h_FmPcd,
+ t_FmPcdFrmReplicGroupParams *p_ReplicGroupParam)
+{
+ t_FmPcdFrmReplicGroup *p_ReplicGroup;
+ t_FmPcdFrmReplicMember *p_CurrentMember, *p_NextMember = NULL;
+ int i;
+ t_Error err;
+ bool last = FALSE;
+ t_Handle h_Muram;
+
+ SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, NULL);
+ SANITY_CHECK_RETURN_VALUE(p_ReplicGroupParam, E_INVALID_HANDLE, NULL);
+
+ if (!FmPcdIsAdvancedOffloadSupported(h_FmPcd))
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Advanced-offload must be enabled"));
+ return NULL;
+ }
+
+ err = CheckParams(h_FmPcd, p_ReplicGroupParam);
+ if (err)
+ {
+ REPORT_ERROR(MAJOR, err, (NO_MSG));
+ return NULL;
+ }
+
+ p_ReplicGroup = (t_FmPcdFrmReplicGroup*)XX_Malloc(sizeof(t_FmPcdFrmReplicGroup));
+ if (!p_ReplicGroup)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("No memory"));
+ return NULL;
+ }
+ memset(p_ReplicGroup, 0, sizeof(t_FmPcdFrmReplicGroup));
+
+ /* initialize lists for internal driver use */
+ INIT_LIST(&p_ReplicGroup->availableMembersList);
+ INIT_LIST(&p_ReplicGroup->membersList);
+
+ p_ReplicGroup->h_FmPcd = h_FmPcd;
+
+ h_Muram = FmPcdGetMuramHandle(p_ReplicGroup->h_FmPcd);
+ ASSERT_COND(h_Muram);
+
+ /* initialize the group lock */
+ p_ReplicGroup->p_Lock = FmPcdAcquireLock(p_ReplicGroup->h_FmPcd);
+ if (!p_ReplicGroup->p_Lock)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Replic group lock"));
+ DeleteGroup(p_ReplicGroup);
+ return NULL;
+ }
+
+ /* Allocate the frame replicator source table descriptor */
+ p_ReplicGroup->p_SourceTd =
+ (t_Handle)FM_MURAM_AllocMem(h_Muram,
+ FM_PCD_CC_AD_ENTRY_SIZE,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if (!p_ReplicGroup->p_SourceTd)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("frame replicator source table descriptor"));
+ DeleteGroup(p_ReplicGroup);
+ return NULL;
+ }
+
+ /* update the shadow size - required for the host commands */
+ err = FmPcdUpdateCcShadow(p_ReplicGroup->h_FmPcd,
+ FM_PCD_CC_AD_ENTRY_SIZE,
+ FM_PCD_CC_AD_TABLE_ALIGN);
+ if (err)
+ {
+ REPORT_ERROR(MAJOR, err, ("Update CC shadow"));
+ DeleteGroup(p_ReplicGroup);
+ return NULL;
+ }
+
+ p_ReplicGroup->maxNumOfEntries = p_ReplicGroupParam->maxNumOfEntries;
+
+ /* Allocate the maximal number of members ADs and Statistics AD for the group
+ It prevents allocation of Muram in run-time */
+ for (i=0; i<p_ReplicGroup->maxNumOfEntries; i++)
+ {
+ err = AllocMember(p_ReplicGroup);
+ if (err)
+ {
+ REPORT_ERROR(MAJOR, err, ("allocate a new member"));
+ DeleteGroup(p_ReplicGroup);
+ return NULL;
+ }
+ }
+
+ /* Initialize the members linked lists:
+ (hw - the one that is used by the FMan controller and
+ sw - the one that is managed by the driver internally) */
+ for (i=(p_ReplicGroupParam->numOfEntries-1); i>=0; i--)
+ {
+ /* check if this is the last member in the group */
+ if (i == (p_ReplicGroupParam->numOfEntries-1))
+ last = TRUE;
+ else
+ last = FALSE;
+
+ /* Initialize a new member */
+ p_CurrentMember = InitMember(p_ReplicGroup,
+ &(p_ReplicGroupParam->nextEngineParams[i]),
+ last);
+ if (!p_CurrentMember)
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_HANDLE, ("No available member"));
+ DeleteGroup(p_ReplicGroup);
+ return NULL;
+ }
+
+ /* Build the members group - link two consecutive members in the hw linked list */
+ LinkMemberToMember(p_ReplicGroup, p_CurrentMember, p_NextMember);
+
+ /* update the driver internal members list to be compatible to the hw members linked list */
+ AddMemberToList(p_ReplicGroup, p_CurrentMember, &p_ReplicGroup->membersList);
+
+ p_NextMember = p_CurrentMember;
+ }
+
+ /* initialize the source table descriptor */
+ BuildSourceTd(p_ReplicGroup->p_SourceTd);
+
+ /* link the source table descriptor to point to the first member in the group */
+ LinkSourceToMember(p_ReplicGroup, p_ReplicGroup->p_SourceTd, p_NextMember);
+
+ return p_ReplicGroup;
+}
+
+t_Error FM_PCD_FrmReplicDeleteGroup(t_Handle h_ReplicGroup)
+{
+ t_FmPcdFrmReplicGroup *p_ReplicGroup = (t_FmPcdFrmReplicGroup *)h_ReplicGroup;
+
+ SANITY_CHECK_RETURN_ERROR(p_ReplicGroup, E_INVALID_HANDLE);
+
+ if (p_ReplicGroup->owners)
+ RETURN_ERROR(MAJOR,
+ E_INVALID_STATE,
+ ("the group has owners and can't be deleted"));
+
+ DeleteGroup(p_ReplicGroup);
+
+ return E_OK;
+}
+
+
+/*****************************************************************************/
+/* API Run-time Frame replicator Control unit functions */
+/*****************************************************************************/
+t_Error FM_PCD_FrmReplicAddMember(t_Handle h_ReplicGroup,
+ uint16_t memberIndex,
+ t_FmPcdCcNextEngineParams *p_MemberParams)
+{
+ t_FmPcdFrmReplicGroup *p_ReplicGroup = (t_FmPcdFrmReplicGroup*) h_ReplicGroup;
+ t_FmPcdFrmReplicMember *p_NewMember, *p_CurrentMember = NULL, *p_PreviousMember = NULL;
+ t_Error err;
+ uint8_t memberPosition;
+
+ SANITY_CHECK_RETURN_ERROR(p_ReplicGroup, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_MemberParams, E_INVALID_HANDLE);
+
+ /* group lock */
+ err = FrmReplicGroupTryLock(p_ReplicGroup);
+ if (GET_ERROR_TYPE(err) == E_BUSY)
+ return ERROR_CODE(E_BUSY);
+
+ if (memberIndex > p_ReplicGroup->numOfEntries)
+ {
+ /* unlock */
+ FrmReplicGroupUnlock(p_ReplicGroup);
+ RETURN_ERROR(MAJOR, E_INVALID_SELECTION,
+ ("memberIndex is greater than the members in the list"));
+ }
+
+ if (memberIndex >= p_ReplicGroup->maxNumOfEntries)
+ {
+ /* unlock */
+ FrmReplicGroupUnlock(p_ReplicGroup);
+ RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("memberIndex is greater than the allowed number of members in the group"));
+ }
+
+ if ((p_ReplicGroup->numOfEntries + 1) > FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES)
+ {
+ /* unlock */
+ FrmReplicGroupUnlock(p_ReplicGroup);
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("numOfEntries with new entry can not be larger than %d\n",
+ FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES));
+ }
+
+ err = MemberCheckParams(p_ReplicGroup->h_FmPcd, p_MemberParams);
+ if (err)
+ {
+ /* unlock */
+ FrmReplicGroupUnlock(p_ReplicGroup);
+ RETURN_ERROR(MAJOR, err, ("member check parameters in add operation"));
+ }
+ /* determine the member position in the group */
+ memberPosition = GetMemberPosition(p_ReplicGroup,
+ memberIndex,
+ TRUE/* add operation */);
+
+ /* Initialize a new member */
+ p_NewMember = InitMember(p_ReplicGroup,
+ p_MemberParams,
+ (memberPosition == FRM_REPLIC_LAST_MEMBER_INDEX ? TRUE : FALSE));
+ if (!p_NewMember)
+ {
+ /* unlock */
+ FrmReplicGroupUnlock(p_ReplicGroup);
+ RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("No available member"));
+ }
+
+ switch (memberPosition)
+ {
+ case FRM_REPLIC_FIRST_MEMBER_INDEX:
+ p_CurrentMember = GetMemberByIndex(p_ReplicGroup, memberIndex);
+ ASSERT_COND(p_CurrentMember);
+
+ LinkMemberToMember(p_ReplicGroup, p_NewMember, p_CurrentMember);
+
+ /* update the internal group source TD */
+ LinkSourceToMember(p_ReplicGroup,
+ p_ReplicGroup->p_SourceTd,
+ p_NewMember);
+
+ /* add member to the internal sw member list */
+ AddMemberToList(p_ReplicGroup,
+ p_NewMember,
+ &p_ReplicGroup->membersList);
+ break;
+
+ case FRM_REPLIC_MIDDLE_MEMBER_INDEX:
+ p_CurrentMember = GetMemberByIndex(p_ReplicGroup, memberIndex);
+ ASSERT_COND(p_CurrentMember);
+
+ p_PreviousMember = GetMemberByIndex(p_ReplicGroup, (uint16_t)(memberIndex-1));
+ ASSERT_COND(p_PreviousMember);
+
+ LinkMemberToMember(p_ReplicGroup, p_NewMember, p_CurrentMember);
+ LinkMemberToMember(p_ReplicGroup, p_PreviousMember, p_NewMember);
+
+ AddMemberToList(p_ReplicGroup, p_NewMember, &p_PreviousMember->node);
+ break;
+
+ case FRM_REPLIC_LAST_MEMBER_INDEX:
+ p_PreviousMember = GetMemberByIndex(p_ReplicGroup, (uint16_t)(memberIndex-1));
+ ASSERT_COND(p_PreviousMember);
+
+ LinkMemberToMember(p_ReplicGroup, p_PreviousMember, p_NewMember);
+ FillReplicAdOfTypeResult(p_PreviousMember->p_MemberAd, FALSE/*last*/);
+
+ /* add the new member to the internal sw member list */
+ AddMemberToList(p_ReplicGroup, p_NewMember, &p_PreviousMember->node);
+ break;
+
+ default:
+ /* unlock */
+ FrmReplicGroupUnlock(p_ReplicGroup);
+ RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("member position in add member"));
+
+ }
+
+ /* unlock */
+ FrmReplicGroupUnlock(p_ReplicGroup);
+
+ return E_OK;
+}
+
+t_Error FM_PCD_FrmReplicRemoveMember(t_Handle h_ReplicGroup,
+ uint16_t memberIndex)
+{
+ t_FmPcdFrmReplicGroup *p_ReplicGroup = (t_FmPcdFrmReplicGroup*) h_ReplicGroup;
+ t_Error err;
+
+ SANITY_CHECK_RETURN_ERROR(p_ReplicGroup, E_INVALID_HANDLE);
+
+ /* lock */
+ err = FrmReplicGroupTryLock(p_ReplicGroup);
+ if (GET_ERROR_TYPE(err) == E_BUSY)
+ return ERROR_CODE(E_BUSY);
+
+ if (memberIndex >= p_ReplicGroup->numOfEntries)
+ RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("member index to remove"));
+
+ /* Design decision: group must contain at least one member
+ No possibility to remove the last member from the group */
+ if (p_ReplicGroup->numOfEntries == 1)
+ RETURN_ERROR(MAJOR, E_CONFLICT, ("Can't remove the last member. At least one member should be related to a group."));
+
+ err = RemoveMember(p_ReplicGroup, memberIndex);
+
+ /* unlock */
+ FrmReplicGroupUnlock(p_ReplicGroup);
+
+ switch (GET_ERROR_TYPE(err))
+ {
+ case E_OK:
+ return E_OK;
+
+ case E_BUSY:
+ DBG(TRACE, ("E_BUSY error"));
+ return ERROR_CODE(E_BUSY);
+
+ default:
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+}
+
+/*********************** End of API routines ************************/
+
+
diff --git a/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_replic.h b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_replic.h
new file mode 100644
index 000000000000..0e8e8bc00cb2
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_replic.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/******************************************************************************
+ @File fm_replic.h
+
+ @Description FM frame replicator
+*//***************************************************************************/
+#ifndef __FM_REPLIC_H
+#define __FM_REPLIC_H
+
+#include "std_ext.h"
+#include "error_ext.h"
+
+
+#define FRM_REPLIC_SOURCE_TD_OPCODE 0x75
+#define NEXT_FRM_REPLIC_ADDR_SHIFT 4
+#define NEXT_FRM_REPLIC_MEMBER_INDEX_SHIFT 16
+#define FRM_REPLIC_FR_BIT 0x08000000
+#define FRM_REPLIC_NL_BIT 0x10000000
+#define FRM_REPLIC_INVALID_MEMBER_INDEX 0xffff
+#define FRM_REPLIC_FIRST_MEMBER_INDEX 0
+
+#define FRM_REPLIC_MIDDLE_MEMBER_INDEX 1
+#define FRM_REPLIC_LAST_MEMBER_INDEX 2
+
+#define SOURCE_TD_ITSELF_OPTION 0x01
+#define SOURCE_TD_COPY_OPTION 0x02
+#define SOURCE_TD_ITSELF_AND_COPY_OPTION SOURCE_TD_ITSELF_OPTION | SOURCE_TD_COPY_OPTION
+#define SOURCE_TD_NONE 0x04
+
+/*typedef enum e_SourceTdOption
+{
+ e_SOURCE_TD_NONE = 0,
+ e_SOURCE_TD_ITSELF_OPTION = 1,
+ e_SOURCE_TD_COPY_OPTION = 2,
+ e_SOURCE_TD_ITSELF_AND_COPY_OPTION = e_SOURCE_TD_ITSELF_OPTION | e_SOURCE_TD_COPY_OPTION
+} e_SourceTdOption;
+*/
+
+typedef struct
+{
+ volatile uint32_t type;
+ volatile uint32_t frGroupPointer;
+ volatile uint32_t operationCode;
+ volatile uint32_t reserved;
+} t_FrmReplicGroupSourceAd;
+
+typedef struct t_FmPcdFrmReplicMember
+{
+ void *p_MemberAd; /**< pointer to the member AD */
+ void *p_StatisticsAd;/**< pointer to the statistics AD of the member */
+ t_Handle h_Manip; /**< manip handle - need for free routines */
+ t_List node;
+} t_FmPcdFrmReplicMember;
+
+typedef struct t_FmPcdFrmReplicGroup
+{
+ t_Handle h_FmPcd;
+
+ uint8_t maxNumOfEntries;/**< maximal number of members in the group */
+ uint8_t numOfEntries; /**< actual number of members in the group */
+ uint16_t owners; /**< how many keys share this frame replicator group */
+ void *p_SourceTd; /**< pointer to the frame replicator source table descriptor */
+ t_List membersList; /**< the members list - should reflect the order of the members as in the hw linked list*/
+ t_List availableMembersList;/**< list of all the available members in the group */
+ t_FmPcdLock *p_Lock;
+} t_FmPcdFrmReplicGroup;
+
+
+#endif /* __FM_REPLIC_H */
diff --git a/sys/contrib/ncsw/Peripherals/FM/Pcd/fman_kg.c b/sys/contrib/ncsw/Peripherals/FM/Pcd/fman_kg.c
new file mode 100644
index 000000000000..49b86e8e4696
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/Pcd/fman_kg.c
@@ -0,0 +1,888 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "fsl_fman_kg.h"
+
+/****************************************/
+/* static functions */
+/****************************************/
+
+
+static uint32_t build_ar_bind_scheme(uint8_t hwport_id, bool write)
+{
+ uint32_t rw;
+
+ rw = write ? (uint32_t)FM_KG_KGAR_WRITE : (uint32_t)FM_KG_KGAR_READ;
+
+ return (uint32_t)(FM_KG_KGAR_GO |
+ rw |
+ FM_PCD_KG_KGAR_SEL_PORT_ENTRY |
+ hwport_id |
+ FM_PCD_KG_KGAR_SEL_PORT_WSEL_SP);
+}
+
+static void clear_pe_all_scheme(struct fman_kg_regs *regs, uint8_t hwport_id)
+{
+ uint32_t ar;
+
+ fman_kg_write_sp(regs, 0xffffffff, 0);
+
+ ar = build_ar_bind_scheme(hwport_id, TRUE);
+ fman_kg_write_ar_wait(regs, ar);
+}
+
+static uint32_t build_ar_bind_cls_plan(uint8_t hwport_id, bool write)
+{
+ uint32_t rw;
+
+ rw = write ? (uint32_t)FM_KG_KGAR_WRITE : (uint32_t)FM_KG_KGAR_READ;
+
+ return (uint32_t)(FM_KG_KGAR_GO |
+ rw |
+ FM_PCD_KG_KGAR_SEL_PORT_ENTRY |
+ hwport_id |
+ FM_PCD_KG_KGAR_SEL_PORT_WSEL_CPP);
+}
+
+static void clear_pe_all_cls_plan(struct fman_kg_regs *regs, uint8_t hwport_id)
+{
+ uint32_t ar;
+
+ fman_kg_write_cpp(regs, 0);
+
+ ar = build_ar_bind_cls_plan(hwport_id, TRUE);
+ fman_kg_write_ar_wait(regs, ar);
+}
+
+static uint8_t get_gen_ht_code(enum fman_kg_gen_extract_src src,
+ bool no_validation,
+ uint8_t *offset)
+{
+ int code;
+
+ switch (src) {
+ case E_FMAN_KG_GEN_EXTRACT_ETH:
+ code = no_validation ? 0x73 : 0x3;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_ETYPE:
+ code = no_validation ? 0x77 : 0x7;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_SNAP:
+ code = no_validation ? 0x74 : 0x4;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_VLAN_TCI_1:
+ code = no_validation ? 0x75 : 0x5;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_VLAN_TCI_N:
+ code = no_validation ? 0x76 : 0x6;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_PPPoE:
+ code = no_validation ? 0x78 : 0x8;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_MPLS_1:
+ code = no_validation ? 0x79 : 0x9;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_MPLS_2:
+ code = no_validation ? FM_KG_SCH_GEN_HT_INVALID : 0x19;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_MPLS_3:
+ code = no_validation ? FM_KG_SCH_GEN_HT_INVALID : 0x29;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_MPLS_N:
+ code = no_validation ? 0x7a : 0xa;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_IPv4_1:
+ code = no_validation ? 0x7b : 0xb;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_IPv6_1:
+ code = no_validation ? 0x7b : 0x1b;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_IPv4_2:
+ code = no_validation ? 0x7c : 0xc;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_IPv6_2:
+ code = no_validation ? 0x7c : 0x1c;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_MINENCAP:
+ code = no_validation ? 0x7c : 0x2c;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_IP_PID:
+ code = no_validation ? 0x72 : 0x2;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_GRE:
+ code = no_validation ? 0x7d : 0xd;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_TCP:
+ code = no_validation ? 0x7e : 0xe;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_UDP:
+ code = no_validation ? 0x7e : 0x1e;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_SCTP:
+ code = no_validation ? 0x7e : 0x3e;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_DCCP:
+ code = no_validation ? 0x7e : 0x4e;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_IPSEC_AH:
+ code = no_validation ? 0x7e : 0x2e;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_IPSEC_ESP:
+ code = no_validation ? 0x7e : 0x6e;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_SHIM_1:
+ code = 0x70;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_SHIM_2:
+ code = 0x71;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_FROM_DFLT:
+ code = 0x10;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_FROM_FRAME_START:
+ code = 0x40;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_FROM_PARSE_RESULT:
+ code = 0x20;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_FROM_END_OF_PARSE:
+ code = 0x7f;
+ break;
+
+ case E_FMAN_KG_GEN_EXTRACT_FROM_FQID:
+ code = 0x20;
+ *offset += 0x20;
+ break;
+
+ default:
+ code = FM_KG_SCH_GEN_HT_INVALID;
+ }
+
+ return (uint8_t)code;
+}
+
+static uint32_t build_ar_scheme(uint8_t scheme,
+ uint8_t hwport_id,
+ bool update_counter,
+ bool write)
+{
+ uint32_t rw;
+
+ rw = (uint32_t)(write ? FM_KG_KGAR_WRITE : FM_KG_KGAR_READ);
+
+ return (uint32_t)(FM_KG_KGAR_GO |
+ rw |
+ FM_KG_KGAR_SEL_SCHEME_ENTRY |
+ hwport_id |
+ ((uint32_t)scheme << FM_KG_KGAR_NUM_SHIFT) |
+ (update_counter ? FM_KG_KGAR_SCM_WSEL_UPDATE_CNT : 0));
+}
+
+static uint32_t build_ar_cls_plan(uint8_t grp,
+ uint8_t entries_mask,
+ uint8_t hwport_id,
+ bool write)
+{
+ uint32_t rw;
+
+ rw = (uint32_t)(write ? FM_KG_KGAR_WRITE : FM_KG_KGAR_READ);
+
+ return (uint32_t)(FM_KG_KGAR_GO |
+ rw |
+ FM_PCD_KG_KGAR_SEL_CLS_PLAN_ENTRY |
+ hwport_id |
+ ((uint32_t)grp << FM_KG_KGAR_NUM_SHIFT) |
+ ((uint32_t)entries_mask << FM_KG_KGAR_WSEL_SHIFT));
+}
+
+int fman_kg_write_ar_wait(struct fman_kg_regs *regs, uint32_t fmkg_ar)
+{
+ iowrite32be(fmkg_ar, &regs->fmkg_ar);
+ /* Wait for GO to be idle and read error */
+ while ((fmkg_ar = ioread32be(&regs->fmkg_ar)) & FM_KG_KGAR_GO) ;
+ if (fmkg_ar & FM_PCD_KG_KGAR_ERR)
+ return -EINVAL;
+ return 0;
+}
+
+void fman_kg_write_sp(struct fman_kg_regs *regs, uint32_t sp, bool add)
+{
+
+ struct fman_kg_pe_regs *kgpe_regs;
+ uint32_t tmp;
+
+ kgpe_regs = (struct fman_kg_pe_regs *)&(regs->fmkg_indirect[0]);
+ tmp = ioread32be(&kgpe_regs->fmkg_pe_sp);
+
+ if (add)
+ tmp |= sp;
+ else /* clear */
+ tmp &= ~sp;
+
+ iowrite32be(tmp, &kgpe_regs->fmkg_pe_sp);
+
+}
+
+void fman_kg_write_cpp(struct fman_kg_regs *regs, uint32_t cpp)
+{
+ struct fman_kg_pe_regs *kgpe_regs;
+
+ kgpe_regs = (struct fman_kg_pe_regs *)&(regs->fmkg_indirect[0]);
+
+ iowrite32be(cpp, &kgpe_regs->fmkg_pe_cpp);
+}
+
+void fman_kg_get_event(struct fman_kg_regs *regs,
+ uint32_t *event,
+ uint32_t *scheme_idx)
+{
+ uint32_t mask, force;
+
+ *event = ioread32be(&regs->fmkg_eer);
+ mask = ioread32be(&regs->fmkg_eeer);
+ *scheme_idx = ioread32be(&regs->fmkg_seer);
+ *scheme_idx &= ioread32be(&regs->fmkg_seeer);
+
+ *event &= mask;
+
+ /* clear the forced events */
+ force = ioread32be(&regs->fmkg_feer);
+ if (force & *event)
+ iowrite32be(force & ~*event ,&regs->fmkg_feer);
+
+ iowrite32be(*event, &regs->fmkg_eer);
+ iowrite32be(*scheme_idx, &regs->fmkg_seer);
+}
+
+
+void fman_kg_init(struct fman_kg_regs *regs,
+ uint32_t exceptions,
+ uint32_t dflt_nia)
+{
+ uint32_t tmp;
+ int i;
+
+ iowrite32be(FM_EX_KG_DOUBLE_ECC | FM_EX_KG_KEYSIZE_OVERFLOW,
+ &regs->fmkg_eer);
+
+ tmp = 0;
+ if (exceptions & FM_EX_KG_DOUBLE_ECC)
+ tmp |= FM_EX_KG_DOUBLE_ECC;
+
+ if (exceptions & FM_EX_KG_KEYSIZE_OVERFLOW)
+ tmp |= FM_EX_KG_KEYSIZE_OVERFLOW;
+
+ iowrite32be(tmp, &regs->fmkg_eeer);
+ iowrite32be(0, &regs->fmkg_fdor);
+ iowrite32be(0, &regs->fmkg_gdv0r);
+ iowrite32be(0, &regs->fmkg_gdv1r);
+ iowrite32be(dflt_nia, &regs->fmkg_gcr);
+
+ /* Clear binding between ports to schemes and classification plans
+ * so that all ports are not bound to any scheme/classification plan */
+ for (i = 0; i < FMAN_MAX_NUM_OF_HW_PORTS; i++) {
+ clear_pe_all_scheme(regs, (uint8_t)i);
+ clear_pe_all_cls_plan(regs, (uint8_t)i);
+ }
+}
+
+void fman_kg_enable_scheme_interrupts(struct fman_kg_regs *regs)
+{
+ /* enable and enable all scheme interrupts */
+ iowrite32be(0xFFFFFFFF, &regs->fmkg_seer);
+ iowrite32be(0xFFFFFFFF, &regs->fmkg_seeer);
+}
+
+void fman_kg_enable(struct fman_kg_regs *regs)
+{
+ iowrite32be(ioread32be(&regs->fmkg_gcr) | FM_KG_KGGCR_EN,
+ &regs->fmkg_gcr);
+}
+
+void fman_kg_disable(struct fman_kg_regs *regs)
+{
+ iowrite32be(ioread32be(&regs->fmkg_gcr) & ~FM_KG_KGGCR_EN,
+ &regs->fmkg_gcr);
+}
+
+void fman_kg_set_data_after_prs(struct fman_kg_regs *regs, uint8_t offset)
+{
+ iowrite32be(offset, &regs->fmkg_fdor);
+}
+
+void fman_kg_set_dflt_val(struct fman_kg_regs *regs,
+ uint8_t def_id,
+ uint32_t val)
+{
+ if(def_id == 0)
+ iowrite32be(val, &regs->fmkg_gdv0r);
+ else
+ iowrite32be(val, &regs->fmkg_gdv1r);
+}
+
+
+void fman_kg_set_exception(struct fman_kg_regs *regs,
+ uint32_t exception,
+ bool enable)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->fmkg_eeer);
+
+ if (enable) {
+ tmp |= exception;
+ } else {
+ tmp &= ~exception;
+ }
+
+ iowrite32be(tmp, &regs->fmkg_eeer);
+}
+
+void fman_kg_get_exception(struct fman_kg_regs *regs,
+ uint32_t *events,
+ uint32_t *scheme_ids,
+ bool clear)
+{
+ uint32_t mask;
+
+ *events = ioread32be(&regs->fmkg_eer);
+ mask = ioread32be(&regs->fmkg_eeer);
+ *events &= mask;
+
+ *scheme_ids = 0;
+
+ if (*events & FM_EX_KG_KEYSIZE_OVERFLOW) {
+ *scheme_ids = ioread32be(&regs->fmkg_seer);
+ mask = ioread32be(&regs->fmkg_seeer);
+ *scheme_ids &= mask;
+ }
+
+ if (clear) {
+ iowrite32be(*scheme_ids, &regs->fmkg_seer);
+ iowrite32be(*events, &regs->fmkg_eer);
+ }
+}
+
+void fman_kg_get_capture(struct fman_kg_regs *regs,
+ struct fman_kg_ex_ecc_attr *ecc_attr,
+ bool clear)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->fmkg_serc);
+
+ if (tmp & KG_FMKG_SERC_CAP) {
+ /* Captured data is valid */
+ ecc_attr->valid = TRUE;
+ ecc_attr->double_ecc =
+ (bool)((tmp & KG_FMKG_SERC_CET) ? TRUE : FALSE);
+ ecc_attr->single_ecc_count =
+ (uint8_t)((tmp & KG_FMKG_SERC_CNT_MSK) >>
+ KG_FMKG_SERC_CNT_SHIFT);
+ ecc_attr->addr = (uint16_t)(tmp & KG_FMKG_SERC_ADDR_MSK);
+
+ if (clear)
+ iowrite32be(KG_FMKG_SERC_CAP, &regs->fmkg_serc);
+ } else {
+ /* No ECC error is captured */
+ ecc_attr->valid = FALSE;
+ }
+}
+
+int fman_kg_build_scheme(struct fman_kg_scheme_params *params,
+ struct fman_kg_scheme_regs *scheme_regs)
+{
+ struct fman_kg_extract_params *extract_params;
+ struct fman_kg_gen_extract_params *gen_params;
+ uint32_t tmp_reg, i, select, mask, fqb;
+ uint8_t offset, shift, ht;
+
+ /* Zero out all registers so no need to care about unused ones */
+ memset(scheme_regs, 0, sizeof(struct fman_kg_scheme_regs));
+
+ /* Mode register */
+ tmp_reg = fm_kg_build_nia(params->next_engine,
+ params->next_engine_action);
+ if (tmp_reg == KG_NIA_INVALID) {
+ return -EINVAL;
+ }
+
+ if (params->next_engine == E_FMAN_PCD_PLCR) {
+ tmp_reg |= FMAN_KG_SCH_MODE_NIA_PLCR;
+ }
+ else if (params->next_engine == E_FMAN_PCD_CC) {
+ tmp_reg |= (uint32_t)params->cc_params.base_offset <<
+ FMAN_KG_SCH_MODE_CCOBASE_SHIFT;
+ }
+
+ tmp_reg |= FMAN_KG_SCH_MODE_EN;
+ scheme_regs->kgse_mode = tmp_reg;
+
+ /* Match vector */
+ scheme_regs->kgse_mv = params->match_vector;
+
+ extract_params = &params->extract_params;
+
+ /* Scheme default values registers */
+ scheme_regs->kgse_dv0 = extract_params->def_scheme_0;
+ scheme_regs->kgse_dv1 = extract_params->def_scheme_1;
+
+ /* Extract Known Fields Command register */
+ scheme_regs->kgse_ekfc = extract_params->known_fields;
+
+ /* Entry Extract Known Default Value register */
+ tmp_reg = 0;
+ tmp_reg |= extract_params->known_fields_def.mac_addr <<
+ FMAN_KG_SCH_DEF_MAC_ADDR_SHIFT;
+ tmp_reg |= extract_params->known_fields_def.vlan_tci <<
+ FMAN_KG_SCH_DEF_VLAN_TCI_SHIFT;
+ tmp_reg |= extract_params->known_fields_def.etype <<
+ FMAN_KG_SCH_DEF_ETYPE_SHIFT;
+ tmp_reg |= extract_params->known_fields_def.ppp_sid <<
+ FMAN_KG_SCH_DEF_PPP_SID_SHIFT;
+ tmp_reg |= extract_params->known_fields_def.ppp_pid <<
+ FMAN_KG_SCH_DEF_PPP_PID_SHIFT;
+ tmp_reg |= extract_params->known_fields_def.mpls <<
+ FMAN_KG_SCH_DEF_MPLS_SHIFT;
+ tmp_reg |= extract_params->known_fields_def.ip_addr <<
+ FMAN_KG_SCH_DEF_IP_ADDR_SHIFT;
+ tmp_reg |= extract_params->known_fields_def.ptype <<
+ FMAN_KG_SCH_DEF_PTYPE_SHIFT;
+ tmp_reg |= extract_params->known_fields_def.ip_tos_tc <<
+ FMAN_KG_SCH_DEF_IP_TOS_TC_SHIFT;
+ tmp_reg |= extract_params->known_fields_def.ipv6_fl <<
+ FMAN_KG_SCH_DEF_IPv6_FL_SHIFT;
+ tmp_reg |= extract_params->known_fields_def.ipsec_spi <<
+ FMAN_KG_SCH_DEF_IPSEC_SPI_SHIFT;
+ tmp_reg |= extract_params->known_fields_def.l4_port <<
+ FMAN_KG_SCH_DEF_L4_PORT_SHIFT;
+ tmp_reg |= extract_params->known_fields_def.tcp_flg <<
+ FMAN_KG_SCH_DEF_TCP_FLG_SHIFT;
+
+ scheme_regs->kgse_ekdv = tmp_reg;
+
+ /* Generic extract registers */
+ if (extract_params->gen_extract_num > FM_KG_NUM_OF_GENERIC_REGS) {
+ return -EINVAL;
+ }
+
+ for (i = 0; i < extract_params->gen_extract_num; i++) {
+ gen_params = extract_params->gen_extract + i;
+
+ tmp_reg = FMAN_KG_SCH_GEN_VALID;
+ tmp_reg |= (uint32_t)gen_params->def_val <<
+ FMAN_KG_SCH_GEN_DEF_SHIFT;
+
+ if (gen_params->type == E_FMAN_KG_HASH_EXTRACT) {
+ if ((gen_params->extract > FMAN_KG_SCH_GEN_SIZE_MAX) ||
+ (gen_params->extract == 0)) {
+ return -EINVAL;
+ }
+ } else {
+ tmp_reg |= FMAN_KG_SCH_GEN_OR;
+ }
+
+ tmp_reg |= (uint32_t)gen_params->extract <<
+ FMAN_KG_SCH_GEN_SIZE_SHIFT;
+ tmp_reg |= (uint32_t)gen_params->mask <<
+ FMAN_KG_SCH_GEN_MASK_SHIFT;
+
+ offset = gen_params->offset;
+ ht = get_gen_ht_code(gen_params->src,
+ gen_params->no_validation,
+ &offset);
+ tmp_reg |= (uint32_t)ht << FMAN_KG_SCH_GEN_HT_SHIFT;
+ tmp_reg |= offset;
+
+ scheme_regs->kgse_gec[i] = tmp_reg;
+ }
+
+ /* Masks registers */
+ if (extract_params->masks_num > FM_KG_EXTRACT_MASKS_NUM) {
+ return -EINVAL;
+ }
+
+ select = 0;
+ mask = 0;
+ fqb = 0;
+ for (i = 0; i < extract_params->masks_num; i++) {
+ /* MCSx fields */
+ KG_GET_MASK_SEL_SHIFT(shift, i);
+ if (extract_params->masks[i].is_known) {
+ /* Mask known field */
+ select |= extract_params->masks[i].field_or_gen_idx <<
+ shift;
+ } else {
+ /* Mask generic extract */
+ select |= (extract_params->masks[i].field_or_gen_idx +
+ FM_KG_MASK_SEL_GEN_BASE) << shift;
+ }
+
+ /* MOx fields - spread between se_bmch and se_fqb registers */
+ KG_GET_MASK_OFFSET_SHIFT(shift, i);
+ if (i < 2) {
+ select |= (uint32_t)extract_params->masks[i].offset <<
+ shift;
+ } else {
+ fqb |= (uint32_t)extract_params->masks[i].offset <<
+ shift;
+ }
+
+ /* BMx fields */
+ KG_GET_MASK_SHIFT(shift, i);
+ mask |= (uint32_t)extract_params->masks[i].mask << shift;
+ }
+
+ /* Finish with rest of BMx fileds -
+ * don't mask bits for unused masks by setting
+ * corresponding BMx field = 0xFF */
+ for (i = extract_params->masks_num; i < FM_KG_EXTRACT_MASKS_NUM; i++) {
+ KG_GET_MASK_SHIFT(shift, i);
+ mask |= 0xFF << shift;
+ }
+
+ scheme_regs->kgse_bmch = select;
+ scheme_regs->kgse_bmcl = mask;
+
+ /* Finish with FQB register initialization.
+ * Check fqid is 24-bit value. */
+ if (params->base_fqid & ~0x00FFFFFF) {
+ return -EINVAL;
+ }
+
+ fqb |= params->base_fqid;
+ scheme_regs->kgse_fqb = fqb;
+
+ /* Hash Configuration register */
+ tmp_reg = 0;
+ if (params->hash_params.use_hash) {
+ /* Check hash mask is 24-bit value */
+ if (params->hash_params.mask & ~0x00FFFFFF) {
+ return -EINVAL;
+ }
+
+ /* Hash function produces 64-bit value, 24 bits of that
+ * are used to generate fq_id and policer profile.
+ * Thus, maximal shift is 40 bits to allow 24 bits out of 64.
+ */
+ if (params->hash_params.shift_r > FMAN_KG_SCH_HASH_HSHIFT_MAX) {
+ return -EINVAL;
+ }
+
+ tmp_reg |= params->hash_params.mask;
+ tmp_reg |= (uint32_t)params->hash_params.shift_r <<
+ FMAN_KG_SCH_HASH_HSHIFT_SHIFT;
+
+ if (params->hash_params.sym) {
+ tmp_reg |= FMAN_KG_SCH_HASH_SYM;
+ }
+
+ }
+
+ if (params->bypass_fqid_gen) {
+ tmp_reg |= FMAN_KG_SCH_HASH_NO_FQID_GEN;
+ }
+
+ scheme_regs->kgse_hc = tmp_reg;
+
+ /* Policer Profile register */
+ if (params->policer_params.bypass_pp_gen) {
+ tmp_reg = 0;
+ } else {
+ /* Lower 8 bits of 24-bits extracted from hash result
+ * are used for policer profile generation.
+ * That leaves maximum shift value = 23. */
+ if (params->policer_params.shift > FMAN_KG_SCH_PP_SHIFT_MAX) {
+ return -EINVAL;
+ }
+
+ tmp_reg = params->policer_params.base;
+ tmp_reg |= ((uint32_t)params->policer_params.shift <<
+ FMAN_KG_SCH_PP_SH_SHIFT) &
+ FMAN_KG_SCH_PP_SH_MASK;
+ tmp_reg |= ((uint32_t)params->policer_params.shift <<
+ FMAN_KG_SCH_PP_SL_SHIFT) &
+ FMAN_KG_SCH_PP_SL_MASK;
+ tmp_reg |= (uint32_t)params->policer_params.mask <<
+ FMAN_KG_SCH_PP_MASK_SHIFT;
+ }
+
+ scheme_regs->kgse_ppc = tmp_reg;
+
+ /* Coarse Classification Bit Select register */
+ if (params->next_engine == E_FMAN_PCD_CC) {
+ scheme_regs->kgse_ccbs = params->cc_params.qlcv_bits_sel;
+ }
+
+ /* Packets Counter register */
+ if (params->update_counter) {
+ scheme_regs->kgse_spc = params->counter_value;
+ }
+
+ return 0;
+}
+
+int fman_kg_write_scheme(struct fman_kg_regs *regs,
+ uint8_t scheme_id,
+ uint8_t hwport_id,
+ struct fman_kg_scheme_regs *scheme_regs,
+ bool update_counter)
+{
+ struct fman_kg_scheme_regs *kgse_regs;
+ uint32_t tmp_reg;
+ int err, i;
+
+ /* Write indirect scheme registers */
+ kgse_regs = (struct fman_kg_scheme_regs *)&(regs->fmkg_indirect[0]);
+
+ iowrite32be(scheme_regs->kgse_mode, &kgse_regs->kgse_mode);
+ iowrite32be(scheme_regs->kgse_ekfc, &kgse_regs->kgse_ekfc);
+ iowrite32be(scheme_regs->kgse_ekdv, &kgse_regs->kgse_ekdv);
+ iowrite32be(scheme_regs->kgse_bmch, &kgse_regs->kgse_bmch);
+ iowrite32be(scheme_regs->kgse_bmcl, &kgse_regs->kgse_bmcl);
+ iowrite32be(scheme_regs->kgse_fqb, &kgse_regs->kgse_fqb);
+ iowrite32be(scheme_regs->kgse_hc, &kgse_regs->kgse_hc);
+ iowrite32be(scheme_regs->kgse_ppc, &kgse_regs->kgse_ppc);
+ iowrite32be(scheme_regs->kgse_spc, &kgse_regs->kgse_spc);
+ iowrite32be(scheme_regs->kgse_dv0, &kgse_regs->kgse_dv0);
+ iowrite32be(scheme_regs->kgse_dv1, &kgse_regs->kgse_dv1);
+ iowrite32be(scheme_regs->kgse_ccbs, &kgse_regs->kgse_ccbs);
+ iowrite32be(scheme_regs->kgse_mv, &kgse_regs->kgse_mv);
+
+ for (i = 0 ; i < FM_KG_NUM_OF_GENERIC_REGS ; i++)
+ iowrite32be(scheme_regs->kgse_gec[i], &kgse_regs->kgse_gec[i]);
+
+ /* Write AR (Action register) */
+ tmp_reg = build_ar_scheme(scheme_id, hwport_id, update_counter, TRUE);
+ err = fman_kg_write_ar_wait(regs, tmp_reg);
+ return err;
+}
+
+int fman_kg_delete_scheme(struct fman_kg_regs *regs,
+ uint8_t scheme_id,
+ uint8_t hwport_id)
+{
+ struct fman_kg_scheme_regs *kgse_regs;
+ uint32_t tmp_reg;
+ int err, i;
+
+ kgse_regs = (struct fman_kg_scheme_regs *)&(regs->fmkg_indirect[0]);
+
+ /* Clear all registers including enable bit in mode register */
+ for (i = 0; i < (sizeof(struct fman_kg_scheme_regs)) / 4; ++i) {
+ iowrite32be(0, ((uint32_t *)kgse_regs + i));
+ }
+
+ /* Write AR (Action register) */
+ tmp_reg = build_ar_scheme(scheme_id, hwport_id, FALSE, TRUE);
+ err = fman_kg_write_ar_wait(regs, tmp_reg);
+ return err;
+}
+
+int fman_kg_get_scheme_counter(struct fman_kg_regs *regs,
+ uint8_t scheme_id,
+ uint8_t hwport_id,
+ uint32_t *counter)
+{
+ struct fman_kg_scheme_regs *kgse_regs;
+ uint32_t tmp_reg;
+ int err;
+
+ kgse_regs = (struct fman_kg_scheme_regs *)&(regs->fmkg_indirect[0]);
+
+ tmp_reg = build_ar_scheme(scheme_id, hwport_id, TRUE, FALSE);
+ err = fman_kg_write_ar_wait(regs, tmp_reg);
+
+ if (err != 0)
+ return err;
+
+ *counter = ioread32be(&kgse_regs->kgse_spc);
+
+ return 0;
+}
+
+int fman_kg_set_scheme_counter(struct fman_kg_regs *regs,
+ uint8_t scheme_id,
+ uint8_t hwport_id,
+ uint32_t counter)
+{
+ struct fman_kg_scheme_regs *kgse_regs;
+ uint32_t tmp_reg;
+ int err;
+
+ kgse_regs = (struct fman_kg_scheme_regs *)&(regs->fmkg_indirect[0]);
+
+ tmp_reg = build_ar_scheme(scheme_id, hwport_id, TRUE, FALSE);
+
+ err = fman_kg_write_ar_wait(regs, tmp_reg);
+ if (err != 0)
+ return err;
+
+ /* Keygen indirect access memory contains all scheme_id registers
+ * by now. Change only counter value. */
+ iowrite32be(counter, &kgse_regs->kgse_spc);
+
+ /* Write back scheme registers */
+ tmp_reg = build_ar_scheme(scheme_id, hwport_id, TRUE, TRUE);
+ err = fman_kg_write_ar_wait(regs, tmp_reg);
+
+ return err;
+}
+
+uint32_t fman_kg_get_schemes_total_counter(struct fman_kg_regs *regs)
+{
+ return ioread32be(&regs->fmkg_tpc);
+}
+
+int fman_kg_build_cls_plan(struct fman_kg_cls_plan_params *params,
+ struct fman_kg_cp_regs *cls_plan_regs)
+{
+ uint8_t entries_set, entry_bit;
+ int i;
+
+ /* Zero out all group's register */
+ memset(cls_plan_regs, 0, sizeof(struct fman_kg_cp_regs));
+
+ /* Go over all classification entries in params->entries_mask and
+ * configure the corresponding cpe register */
+ entries_set = params->entries_mask;
+ for (i = 0; entries_set; i++) {
+ entry_bit = (uint8_t)(0x80 >> i);
+ if ((entry_bit & entries_set) == 0)
+ continue;
+ entries_set ^= entry_bit;
+ cls_plan_regs->kgcpe[i] = params->mask_vector[i];
+ }
+
+ return 0;
+}
+
+int fman_kg_write_cls_plan(struct fman_kg_regs *regs,
+ uint8_t grp_id,
+ uint8_t entries_mask,
+ uint8_t hwport_id,
+ struct fman_kg_cp_regs *cls_plan_regs)
+{
+ struct fman_kg_cp_regs *kgcpe_regs;
+ uint32_t tmp_reg;
+ int i, err;
+
+ /* Check group index is valid and the group isn't empty */
+ if (grp_id >= FM_KG_CLS_PLAN_GRPS_NUM)
+ return -EINVAL;
+
+ /* Write indirect classification plan registers */
+ kgcpe_regs = (struct fman_kg_cp_regs *)&(regs->fmkg_indirect[0]);
+
+ for (i = 0; i < FM_KG_NUM_CLS_PLAN_ENTR; i++) {
+ iowrite32be(cls_plan_regs->kgcpe[i], &kgcpe_regs->kgcpe[i]);
+ }
+
+ tmp_reg = build_ar_cls_plan(grp_id, entries_mask, hwport_id, TRUE);
+ err = fman_kg_write_ar_wait(regs, tmp_reg);
+ return err;
+}
+
+int fman_kg_write_bind_schemes(struct fman_kg_regs *regs,
+ uint8_t hwport_id,
+ uint32_t schemes)
+{
+ struct fman_kg_pe_regs *kg_pe_regs;
+ uint32_t tmp_reg;
+ int err;
+
+ kg_pe_regs = (struct fman_kg_pe_regs *)&(regs->fmkg_indirect[0]);
+
+ iowrite32be(schemes, &kg_pe_regs->fmkg_pe_sp);
+
+ tmp_reg = build_ar_bind_scheme(hwport_id, TRUE);
+ err = fman_kg_write_ar_wait(regs, tmp_reg);
+ return err;
+}
+
+int fman_kg_build_bind_cls_plans(uint8_t grp_base,
+ uint8_t grp_mask,
+ uint32_t *bind_cls_plans)
+{
+ /* Check grp_base and grp_mask are 5-bits values */
+ if ((grp_base & ~0x0000001F) || (grp_mask & ~0x0000001F))
+ return -EINVAL;
+
+ *bind_cls_plans = (uint32_t) ((grp_mask << FMAN_KG_PE_CPP_MASK_SHIFT) | grp_base);
+ return 0;
+}
+
+
+int fman_kg_write_bind_cls_plans(struct fman_kg_regs *regs,
+ uint8_t hwport_id,
+ uint32_t bind_cls_plans)
+{
+ struct fman_kg_pe_regs *kg_pe_regs;
+ uint32_t tmp_reg;
+ int err;
+
+ kg_pe_regs = (struct fman_kg_pe_regs *)&(regs->fmkg_indirect[0]);
+
+ iowrite32be(bind_cls_plans, &kg_pe_regs->fmkg_pe_cpp);
+
+ tmp_reg = build_ar_bind_cls_plan(hwport_id, TRUE);
+ err = fman_kg_write_ar_wait(regs, tmp_reg);
+ return err;
+}
diff --git a/sys/contrib/ncsw/Peripherals/FM/Pcd/fman_prs.c b/sys/contrib/ncsw/Peripherals/FM/Pcd/fman_prs.c
new file mode 100644
index 000000000000..108779dbaf40
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/Pcd/fman_prs.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "fsl_fman_prs.h"
+
+uint32_t fman_prs_get_err_event(struct fman_prs_regs *regs, uint32_t ev_mask)
+{
+ return ioread32be(&regs->fmpr_perr) & ev_mask;
+}
+
+uint32_t fman_prs_get_err_ev_mask(struct fman_prs_regs *regs)
+{
+ return ioread32be(&regs->fmpr_perer);
+}
+
+void fman_prs_ack_err_event(struct fman_prs_regs *regs, uint32_t event)
+{
+ iowrite32be(event, &regs->fmpr_perr);
+}
+
+uint32_t fman_prs_get_expt_event(struct fman_prs_regs *regs, uint32_t ev_mask)
+{
+ return ioread32be(&regs->fmpr_pevr) & ev_mask;
+}
+
+uint32_t fman_prs_get_expt_ev_mask(struct fman_prs_regs *regs)
+{
+ return ioread32be(&regs->fmpr_pever);
+}
+
+void fman_prs_ack_expt_event(struct fman_prs_regs *regs, uint32_t event)
+{
+ iowrite32be(event, &regs->fmpr_pevr);
+}
+
+void fman_prs_defconfig(struct fman_prs_cfg *cfg)
+{
+ cfg->port_id_stat = 0;
+ cfg->max_prs_cyc_lim = DEFAULT_MAX_PRS_CYC_LIM;
+ cfg->prs_exceptions = 0x03000000;
+}
+
+int fman_prs_init(struct fman_prs_regs *regs, struct fman_prs_cfg *cfg)
+{
+ uint32_t tmp;
+
+ iowrite32be(cfg->max_prs_cyc_lim, &regs->fmpr_rpclim);
+ iowrite32be((FM_PCD_PRS_SINGLE_ECC | FM_PCD_PRS_PORT_IDLE_STS),
+ &regs->fmpr_pevr);
+
+ if (cfg->prs_exceptions & FM_PCD_EX_PRS_SINGLE_ECC)
+ iowrite32be(FM_PCD_PRS_SINGLE_ECC, &regs->fmpr_pever);
+ else
+ iowrite32be(0, &regs->fmpr_pever);
+
+ iowrite32be(FM_PCD_PRS_DOUBLE_ECC, &regs->fmpr_perr);
+
+ tmp = 0;
+ if (cfg->prs_exceptions & FM_PCD_EX_PRS_DOUBLE_ECC)
+ tmp |= FM_PCD_PRS_DOUBLE_ECC;
+ iowrite32be(tmp, &regs->fmpr_perer);
+
+ iowrite32be(cfg->port_id_stat, &regs->fmpr_ppsc);
+
+ return 0;
+}
+
+void fman_prs_enable(struct fman_prs_regs *regs)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->fmpr_rpimac) | FM_PCD_PRS_RPIMAC_EN;
+ iowrite32be(tmp, &regs->fmpr_rpimac);
+}
+
+void fman_prs_disable(struct fman_prs_regs *regs)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->fmpr_rpimac) & ~FM_PCD_PRS_RPIMAC_EN;
+ iowrite32be(tmp, &regs->fmpr_rpimac);
+}
+
+int fman_prs_is_enabled(struct fman_prs_regs *regs)
+{
+ return ioread32be(&regs->fmpr_rpimac) & FM_PCD_PRS_RPIMAC_EN;
+}
+
+void fman_prs_set_stst_port_msk(struct fman_prs_regs *regs, uint32_t pid_msk)
+{
+ iowrite32be(pid_msk, &regs->fmpr_ppsc);
+}
+
+void fman_prs_set_stst(struct fman_prs_regs *regs, bool enable)
+{
+ if (enable)
+ iowrite32be(FM_PCD_PRS_PPSC_ALL_PORTS, &regs->fmpr_ppsc);
+ else
+ iowrite32be(0, &regs->fmpr_ppsc);
+}
diff --git a/sys/contrib/ncsw/Peripherals/FM/Port/fm_port.c b/sys/contrib/ncsw/Peripherals/FM/Port/fm_port.c
index 127435873bba..e277b4250689 100644
--- a/sys/contrib/ncsw/Peripherals/FM/Port/fm_port.c
+++ b/sys/contrib/ncsw/Peripherals/FM/Port/fm_port.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,36 +30,46 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm_port.c
@Description FM driver routines implementation.
-*//***************************************************************************/
+ *//***************************************************************************/
#include "error_ext.h"
#include "std_ext.h"
#include "string_ext.h"
#include "sprint_ext.h"
#include "debug_ext.h"
-#include "fm_pcd_ext.h"
+#include "fm_muram_ext.h"
+#include "fman_common.h"
#include "fm_port.h"
-
+#include "fm_port_dsar.h"
+#include "common/general.h"
/****************************************/
/* static functions */
/****************************************/
+static t_Error FmPortConfigAutoResForDeepSleepSupport1(t_FmPort *p_FmPort);
static t_Error CheckInitParameters(t_FmPort *p_FmPort)
{
t_FmPortDriverParam *p_Params = p_FmPort->p_FmPortDriverParam;
- t_Error ans = E_OK;
- uint32_t unusedMask;
- uint8_t i;
- uint8_t j;
- bool found;
+ struct fman_port_cfg *p_DfltConfig = &p_Params->dfltCfg;
+ t_Error ans = E_OK;
+ uint32_t unusedMask;
if (p_FmPort->imEn)
{
+ if (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
+ if (p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth
+ > 2)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("fifoDeqPipelineDepth for IM 10G can't be larger than 2"));
+
if ((ans = FmPortImCheckInitParameters(p_FmPort)) != E_OK)
return ERROR_CODE(ans);
}
@@ -68,67 +78,41 @@ static t_Error CheckInitParameters(t_FmPort *p_FmPort)
/****************************************/
/* Rx only */
/****************************************/
- if((p_FmPort->portType == e_FM_PORT_TYPE_RX) || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_RX)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
{
/* external buffer pools */
- if(!p_Params->extBufPools.numOfPoolsUsed)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("extBufPools.numOfPoolsUsed=0. At least one buffer pool must be defined"));
-
- if(p_Params->extBufPools.numOfPoolsUsed > FM_PORT_MAX_NUM_OF_EXT_POOLS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfPoolsUsed can't be larger than %d", FM_PORT_MAX_NUM_OF_EXT_POOLS));
-
- for(i=0;i<p_Params->extBufPools.numOfPoolsUsed;i++)
- {
- if(p_Params->extBufPools.extBufPool[i].id >= BM_MAX_NUM_OF_POOLS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("extBufPools.extBufPool[%d].id can't be larger than %d", i, BM_MAX_NUM_OF_POOLS));
- if(!p_Params->extBufPools.extBufPool[i].size)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("extBufPools.extBufPool[%d].size is 0", i));
- }
-
- /* backup BM pools indication is valid only for some chip deriviatives
- (limited by the config routine) */
- if(p_Params->p_BackupBmPools)
- {
- if(p_Params->p_BackupBmPools->numOfBackupPools >= p_Params->extBufPools.numOfPoolsUsed)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("p_BackupBmPools must be smaller than extBufPools.numOfPoolsUsed"));
- found = FALSE;
- for(i = 0;i<p_Params->p_BackupBmPools->numOfBackupPools;i++)
- for(j=0;j<p_Params->extBufPools.numOfPoolsUsed;j++)
- if(p_Params->p_BackupBmPools->poolIds[i] == p_Params->extBufPools.extBufPool[j].id)
- found = TRUE;
- if (!found)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("All p_BackupBmPools.poolIds must be included in extBufPools.extBufPool[n].id"));
- }
-
- /* up to extBufPools.numOfPoolsUsed pools may be defined */
- if(p_Params->bufPoolDepletion.numberOfPoolsModeEnable)
- {
- if((p_Params->bufPoolDepletion.numOfPools > p_Params->extBufPools.numOfPoolsUsed))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufPoolDepletion.numOfPools can't be larger than %d and can't be larger than numOfPoolsUsed", FM_PORT_MAX_NUM_OF_EXT_POOLS));
+ if (!p_Params->extBufPools.numOfPoolsUsed)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("extBufPools.numOfPoolsUsed=0. At least one buffer pool must be defined"));
+
+ if (FmSpCheckBufPoolsParams(&p_Params->extBufPools,
+ p_Params->p_BackupBmPools,
+ &p_Params->bufPoolDepletion) != E_OK)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
- if(!p_Params->bufPoolDepletion.numOfPools)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufPoolDepletion.numOfPoolsToConsider can not be 0 when numberOfPoolsModeEnable=TRUE"));
- }
/* Check that part of IC that needs copying is small enough to enter start margin */
- if(p_Params->intContext.size + p_Params->intContext.extBufOffset > p_Params->bufMargins.startMargins)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.size is larger than start margins"));
+ if (p_Params->intContext.size
+ && (p_Params->intContext.size
+ + p_Params->intContext.extBufOffset
+ > p_Params->bufMargins.startMargins))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("intContext.size is larger than start margins"));
- if(p_Params->liodnOffset & ~FM_LIODN_OFFSET_MASK)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("liodnOffset is larger than %d", FM_LIODN_OFFSET_MASK+1));
-#ifdef FM_PARTITION_ARRAY
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- {
- if(p_Params->liodnOffset >= MAX_LIODN_OFFSET)
- {
- p_Params->liodnOffset = (uint16_t)(p_Params->liodnOffset & (MAX_LIODN_OFFSET-1));
- DBG(WARNING, ("liodnOffset number is out of rev1 range - MSB bits cleard."));
- }
- }
- }
-#endif /* FM_PARTITION_ARRAY */
+ if ((p_Params->liodnOffset != (uint16_t)DPAA_LIODN_DONT_OVERRIDE)
+ && (p_Params->liodnOffset & ~FM_LIODN_OFFSET_MASK))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("liodnOffset is larger than %d", FM_LIODN_OFFSET_MASK+1));
+
+#ifdef FM_NO_BACKUP_POOLS
+ if ((p_FmPort->fmRevInfo.majorRev != 4) && (p_FmPort->fmRevInfo.majorRev < 6))
+ if (p_FmPort->p_FmPortDriverParam->p_BackupBmPools)
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("BackupBmPools"));
+#endif /* FM_NO_BACKUP_POOLS */
}
/****************************************/
@@ -136,25 +120,51 @@ static t_Error CheckInitParameters(t_FmPort *p_FmPort)
/****************************************/
else
{
- if(p_Params->deqSubPortal >= MAX_QMI_DEQ_SUBPORTAL)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, (" deqSubPortal has to be in the range of 0 - %d", MAX_QMI_DEQ_SUBPORTAL));
+ if (p_Params->deqSubPortal >= FM_MAX_NUM_OF_SUB_PORTALS)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ (" deqSubPortal has to be in the range of 0 - %d", FM_MAX_NUM_OF_SUB_PORTALS));
/* to protect HW internal-context from overwrite */
- if((p_Params->intContext.size) && (p_Params->intContext.intContextOffset < MIN_TX_INT_OFFSET))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("non-Rx intContext.intContextOffset can't be smaller than %d", MIN_TX_INT_OFFSET));
+ if ((p_Params->intContext.size)
+ && (p_Params->intContext.intContextOffset
+ < MIN_TX_INT_OFFSET))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("non-Rx intContext.intContextOffset can't be smaller than %d", MIN_TX_INT_OFFSET));
+
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_TX)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_TX_10G)
+ /* in O/H DEFAULT_notSupported indicates that it is not supported and should not be checked */
+ || (p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth
+ != DEFAULT_notSupported))
+ {
+ /* Check that not larger than 8 */
+ if ((!p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth)
+ || (p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth
+ > MAX_FIFO_PIPELINE_DEPTH))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("fifoDeqPipelineDepth can't be larger than %d", MAX_FIFO_PIPELINE_DEPTH));
+ }
}
/****************************************/
/* Rx Or Offline Parsing */
/****************************************/
- if((p_FmPort->portType == e_FM_PORT_TYPE_RX) || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G) || (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_RX)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
{
-
- if(!p_Params->dfltFqid)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dfltFqid must be between 1 and 2^24-1"));
+ if (!p_Params->dfltFqid)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("dfltFqid must be between 1 and 2^24-1"));
#if defined(FM_CAPWAP_SUPPORT) && defined(FM_LOCKUP_ALIGNMENT_ERRATA_FMAN_SW004)
- if(p_FmPort->p_FmPortDriverParam->bufferPrefixContent.manipExtraSpace % 16)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufferPrefixContent.manipExtraSpace has to be devidable by 16"));
+ if (p_FmPort->p_FmPortDriverParam->bufferPrefixContent.manipExtraSpace % 16)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufferPrefixContent.manipExtraSpace has to be devidable by 16"));
#endif /* defined(FM_CAPWAP_SUPPORT) && ... */
}
@@ -163,1169 +173,872 @@ static t_Error CheckInitParameters(t_FmPort *p_FmPort)
/****************************************/
/* common BMI registers values */
/* Check that Queue Id is not larger than 2^24, and is not 0 */
- if((p_Params->errFqid & ~0x00FFFFFF) || !p_Params->errFqid)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("errFqid must be between 1 and 2^24-1"));
- if(p_Params->dfltFqid & ~0x00FFFFFF)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dfltFqid must be between 1 and 2^24-1"));
+ if ((p_Params->errFqid & ~0x00FFFFFF) || !p_Params->errFqid)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("errFqid must be between 1 and 2^24-1"));
+ if (p_Params->dfltFqid & ~0x00FFFFFF)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("dfltFqid must be between 1 and 2^24-1"));
}
/****************************************/
/* Rx only */
/****************************************/
- if((p_FmPort->portType == e_FM_PORT_TYPE_RX) || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
- {
- /* Check that divisible by 256 and not larger than 256 */
- if(p_Params->rxFifoPriElevationLevel % BMI_FIFO_UNITS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("rxFifoPriElevationLevel has to be divisible by %d", BMI_FIFO_UNITS));
- if(!p_Params->rxFifoPriElevationLevel || (p_Params->rxFifoPriElevationLevel > BMI_MAX_FIFO_SIZE))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("rxFifoPriElevationLevel has to be in the range of 256 - %d", BMI_MAX_FIFO_SIZE));
- if(p_Params->rxFifoThreshold % BMI_FIFO_UNITS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("rxFifoThreshold has to be divisible by %d", BMI_FIFO_UNITS));
- if(!p_Params->rxFifoThreshold ||(p_Params->rxFifoThreshold > BMI_MAX_FIFO_SIZE))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("rxFifoThreshold has to be in the range of 256 - %d", BMI_MAX_FIFO_SIZE));
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_RX)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
+ {
+ if (p_DfltConfig->rx_pri_elevation % BMI_FIFO_UNITS)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("rxFifoPriElevationLevel has to be divisible by %d", BMI_FIFO_UNITS));
+ if ((p_DfltConfig->rx_pri_elevation < BMI_FIFO_UNITS)
+ || (p_DfltConfig->rx_pri_elevation > MAX_PORT_FIFO_SIZE))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("rxFifoPriElevationLevel has to be in the range of 256 - %d", MAX_PORT_FIFO_SIZE));
+ if (p_DfltConfig->rx_fifo_thr % BMI_FIFO_UNITS)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("rxFifoThreshold has to be divisible by %d", BMI_FIFO_UNITS));
+ if ((p_DfltConfig->rx_fifo_thr < BMI_FIFO_UNITS)
+ || (p_DfltConfig->rx_fifo_thr > MAX_PORT_FIFO_SIZE))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("rxFifoThreshold has to be in the range of 256 - %d", MAX_PORT_FIFO_SIZE));
/* Check that not larger than 16 */
- if(p_Params->cutBytesFromEnd > FRAME_END_DATA_SIZE)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("cutBytesFromEnd can't be larger than %d", FRAME_END_DATA_SIZE));
+ if (p_DfltConfig->rx_cut_end_bytes > FRAME_END_DATA_SIZE)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("cutBytesFromEnd can't be larger than %d", FRAME_END_DATA_SIZE));
- /* Check the margin definition */
- if(p_Params->bufMargins.startMargins > MAX_EXT_BUFFER_OFFSET)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufMargins.startMargins can't be larger than %d", MAX_EXT_BUFFER_OFFSET));
- if(p_Params->bufMargins.endMargins > MAX_EXT_BUFFER_OFFSET)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufMargins.endMargins can't be larger than %d", MAX_EXT_BUFFER_OFFSET));
+ if (FmSpCheckBufMargins(&p_Params->bufMargins) != E_OK)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
/* extra FIFO size (allowed only to Rx ports) */
- if(p_FmPort->fifoBufs.extra % BMI_FIFO_UNITS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fifoBufs.extra has to be divisible by %d", BMI_FIFO_UNITS));
-
- if(p_Params->bufPoolDepletion.numberOfPoolsModeEnable &&
- !p_Params->bufPoolDepletion.numOfPools)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufPoolDepletion.numOfPoolsToConsider can not be 0 when numberOfPoolsModeEnable=TRUE"));
+ if (p_Params->setSizeOfFifo
+ && (p_FmPort->fifoBufs.extra % BMI_FIFO_UNITS))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("fifoBufs.extra has to be divisible by %d", BMI_FIFO_UNITS));
+
+ if (p_Params->bufPoolDepletion.poolsGrpModeEnable
+ && !p_Params->bufPoolDepletion.numOfPools)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("bufPoolDepletion.numOfPools can not be 0 when poolsGrpModeEnable=TRUE"));
#ifdef FM_CSI_CFED_LIMIT
+ if (p_FmPort->fmRevInfo.majorRev == 4)
{
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
-
- if (revInfo.majorRev == 4)
- {
- /* Check that not larger than 16 */
- if(p_Params->cutBytesFromEnd + p_Params->cheksumLastBytesIgnore > FRAME_END_DATA_SIZE)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("cheksumLastBytesIgnore + cutBytesFromEnd can't be larger than %d", FRAME_END_DATA_SIZE));
- }
+ /* Check that not larger than 16 */
+ if (p_DfltConfig->rx_cut_end_bytes + p_DfltConfig->checksum_bytes_ignore > FRAME_END_DATA_SIZE)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("cheksumLastBytesIgnore + cutBytesFromEnd can't be larger than %d", FRAME_END_DATA_SIZE));
}
#endif /* FM_CSI_CFED_LIMIT */
-
}
/****************************************/
/* Non Rx ports */
/****************************************/
+ /* extra FIFO size (allowed only to Rx ports) */
else
- /* extra FIFO size (allowed only to Rx ports) */
- if(p_FmPort->fifoBufs.extra)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, (" No fifoBufs.extra for non Rx ports"));
-
- /****************************************/
- /* Rx & Tx */
- /****************************************/
- if((p_FmPort->portType == e_FM_PORT_TYPE_TX) || (p_FmPort->portType == e_FM_PORT_TYPE_TX_10G) ||
- (p_FmPort->portType == e_FM_PORT_TYPE_RX) || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
- {
- /* Check that not larger than 16 */
- if(p_Params->cheksumLastBytesIgnore > FRAME_END_DATA_SIZE)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("cheksumLastBytesIgnore can't be larger than %d", FRAME_END_DATA_SIZE));
- }
+ if (p_FmPort->fifoBufs.extra)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ (" No fifoBufs.extra for non Rx ports"));
/****************************************/
/* Tx only */
/****************************************/
- if((p_FmPort->portType == e_FM_PORT_TYPE_TX) || (p_FmPort->portType == e_FM_PORT_TYPE_TX_10G))
- {
- /* Check that divisible by 256 and not larger than 256 */
- if(p_Params->txFifoMinFillLevel % BMI_FIFO_UNITS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("txFifoMinFillLevel has to be divisible by %d", BMI_FIFO_UNITS));
- if(p_Params->txFifoMinFillLevel > (BMI_MAX_FIFO_SIZE - 256))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("txFifoMinFillLevel has to be in the range of 0 - %d", BMI_MAX_FIFO_SIZE));
- if(p_Params->txFifoLowComfLevel % BMI_FIFO_UNITS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("txFifoLowComfLevel has to be divisible by %d", BMI_FIFO_UNITS));
- if(!p_Params->txFifoLowComfLevel || (p_Params->txFifoLowComfLevel > BMI_MAX_FIFO_SIZE))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("txFifoLowComfLevel has to be in the range of 256 - %d", BMI_MAX_FIFO_SIZE));
-
- /* Check that not larger than 8 */
- if((!p_FmPort->txFifoDeqPipelineDepth) ||( p_FmPort->txFifoDeqPipelineDepth > MAX_FIFO_PIPELINE_DEPTH))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("txFifoDeqPipelineDepth can't be larger than %d", MAX_FIFO_PIPELINE_DEPTH));
- if(p_FmPort->portType == e_FM_PORT_TYPE_TX)
- if(p_FmPort->txFifoDeqPipelineDepth > 2)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("txFifoDeqPipelineDepth for !G can't be larger than 2"));
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_TX)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_TX_10G))
+ {
+ if (p_DfltConfig->tx_fifo_min_level % BMI_FIFO_UNITS)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("txFifoMinFillLevel has to be divisible by %d", BMI_FIFO_UNITS));
+ if (p_DfltConfig->tx_fifo_min_level > (MAX_PORT_FIFO_SIZE - 256))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("txFifoMinFillLevel has to be in the range of 0 - %d", (MAX_PORT_FIFO_SIZE - 256)));
+ if (p_DfltConfig->tx_fifo_low_comf_level % BMI_FIFO_UNITS)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("txFifoLowComfLevel has to be divisible by %d", BMI_FIFO_UNITS));
+ if ((p_DfltConfig->tx_fifo_low_comf_level < BMI_FIFO_UNITS)
+ || (p_DfltConfig->tx_fifo_low_comf_level > MAX_PORT_FIFO_SIZE))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("txFifoLowComfLevel has to be in the range of 256 - %d", MAX_PORT_FIFO_SIZE));
+
+ if (p_FmPort->portType == e_FM_PORT_TYPE_TX)
+ if (p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth
+ > 2)
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("fifoDeqPipelineDepth for 1G can't be larger than 2"));
}
- else
+
/****************************************/
/* Non Tx Ports */
/****************************************/
- {
- /* If discard override was selected , no frames may be discarded. */
- if(p_Params->frmDiscardOverride && p_Params->errorsToDiscard)
- RETURN_ERROR(MAJOR, E_CONFLICT, ("errorsToDiscard is not empty, but frmDiscardOverride selected (all discarded frames to be enqueued to error queue)."));
- }
+ /* If discard override was selected , no frames may be discarded. */
+ else
+ if (p_DfltConfig->discard_override && p_Params->errorsToDiscard)
+ RETURN_ERROR(
+ MAJOR,
+ E_CONFLICT,
+ ("errorsToDiscard is not empty, but frmDiscardOverride selected (all discarded frames to be enqueued to error queue)."));
/****************************************/
/* Rx and Offline parsing */
/****************************************/
- if((p_FmPort->portType == e_FM_PORT_TYPE_RX) || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
- || (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_RX)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
{
- if(p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
unusedMask = BMI_STATUS_OP_MASK_UNUSED;
else
unusedMask = BMI_STATUS_RX_MASK_UNUSED;
/* Check that no common bits with BMI_STATUS_MASK_UNUSED */
- if(p_Params->errorsToDiscard & unusedMask)
- RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("errorsToDiscard contains undefined bits"));
+ if (p_Params->errorsToDiscard & unusedMask)
+ RETURN_ERROR(MAJOR, E_INVALID_SELECTION,
+ ("errorsToDiscard contains undefined bits"));
+ }
+
+ /****************************************/
+ /* Offline Ports */
+ /****************************************/
+#ifdef FM_OP_OPEN_DMA_MIN_LIMIT
+ if ((p_FmPort->fmRevInfo.majorRev >= 6)
+ && (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ && p_Params->setNumOfOpenDmas
+ && (p_FmPort->openDmas.num < MIN_NUM_OF_OP_DMAS))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("For Offline port, openDmas.num can't be smaller than %d", MIN_NUM_OF_OP_DMAS));
+#endif /* FM_OP_OPEN_DMA_MIN_LIMIT */
+
+ /****************************************/
+ /* Offline & HC Ports */
+ /****************************************/
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND))
+ {
+#ifndef FM_FRAME_END_PARAMS_FOR_OP
+ if ((p_FmPort->fmRevInfo.majorRev < 6) &&
+ (p_FmPort->p_FmPortDriverParam->cheksumLastBytesIgnore != DEFAULT_notSupported))
+ /* this is an indication that user called config for this mode which is not supported in this integration */
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("cheksumLastBytesIgnore is available for Rx & Tx ports only"));
+#endif /* !FM_FRAME_END_PARAMS_FOR_OP */
+
+#ifndef FM_DEQ_PIPELINE_PARAMS_FOR_OP
+ if ((!((p_FmPort->fmRevInfo.majorRev == 4) ||
+ (p_FmPort->fmRevInfo.majorRev >= 6))) &&
+ (p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth != DEFAULT_notSupported))
+ /* this is an indication that user called config for this mode which is not supported in this integration */
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("fifoDeqPipelineDepth is available for Tx ports only"));
+#endif /* !FM_DEQ_PIPELINE_PARAMS_FOR_OP */
}
/****************************************/
/* All ports */
/****************************************/
+ /* Check that not larger than 16 */
+ if ((p_Params->cheksumLastBytesIgnore > FRAME_END_DATA_SIZE)
+ && ((p_Params->cheksumLastBytesIgnore != DEFAULT_notSupported)))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("cheksumLastBytesIgnore can't be larger than %d", FRAME_END_DATA_SIZE));
- /* Check that divisible by 16 and not larger than 240 */
- if(p_Params->intContext.intContextOffset >MAX_INT_OFFSET)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.intContextOffset can't be larger than %d", MAX_INT_OFFSET));
- if(p_Params->intContext.intContextOffset % OFFSET_UNITS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.intContextOffset has to be divisible by %d", OFFSET_UNITS));
-
- /* check that ic size+ic internal offset, does not exceed ic block size */
- if(p_Params->intContext.size + p_Params->intContext.intContextOffset > MAX_IC_SIZE)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.size + intContext.intContextOffset has to be smaller than %d", MAX_IC_SIZE));
- /* Check that divisible by 16 and not larger than 256 */
- if(p_Params->intContext.size % OFFSET_UNITS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.size has to be divisible by %d", OFFSET_UNITS));
-
- /* Check that divisible by 16 and not larger than 4K */
- if(p_Params->intContext.extBufOffset > MAX_EXT_OFFSET)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.extBufOffset can't be larger than %d", MAX_EXT_OFFSET));
- if(p_Params->intContext.extBufOffset % OFFSET_UNITS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.extBufOffset has to be divisible by %d", OFFSET_UNITS));
+ if (FmSpCheckIntContextParams(&p_Params->intContext) != E_OK)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
/* common BMI registers values */
- if((!p_FmPort->tasks.num) || (p_FmPort->tasks.num > MAX_NUM_OF_TASKS))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("tasks.num can't be larger than %d", MAX_NUM_OF_TASKS));
- if(p_FmPort->tasks.extra > MAX_NUM_OF_EXTRA_TASKS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("tasks.extra can't be larger than %d", MAX_NUM_OF_EXTRA_TASKS));
- if((!p_FmPort->openDmas.num) || (p_FmPort->openDmas.num > MAX_NUM_OF_DMAS))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("openDmas.num can't be larger than %d", MAX_NUM_OF_DMAS));
- if(p_FmPort->openDmas.extra > MAX_NUM_OF_EXTRA_DMAS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("openDmas.extra can't be larger than %d", MAX_NUM_OF_EXTRA_DMAS));
- if(!p_FmPort->fifoBufs.num || (p_FmPort->fifoBufs.num > BMI_MAX_FIFO_SIZE))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fifoBufs.num has to be in the range of 256 - %d", BMI_MAX_FIFO_SIZE));
- if(p_FmPort->fifoBufs.num % BMI_FIFO_UNITS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fifoBufs.num has to be divisible by %d", BMI_FIFO_UNITS));
+ if (p_Params->setNumOfTasks
+ && ((!p_FmPort->tasks.num)
+ || (p_FmPort->tasks.num > MAX_NUM_OF_TASKS)))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("tasks.num can't be larger than %d", MAX_NUM_OF_TASKS));
+ if (p_Params->setNumOfTasks
+ && (p_FmPort->tasks.extra > MAX_NUM_OF_EXTRA_TASKS))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("tasks.extra can't be larger than %d", MAX_NUM_OF_EXTRA_TASKS));
+ if (p_Params->setNumOfOpenDmas
+ && ((!p_FmPort->openDmas.num)
+ || (p_FmPort->openDmas.num > MAX_NUM_OF_DMAS)))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("openDmas.num can't be larger than %d", MAX_NUM_OF_DMAS));
+ if (p_Params->setNumOfOpenDmas
+ && (p_FmPort->openDmas.extra > MAX_NUM_OF_EXTRA_DMAS))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("openDmas.extra can't be larger than %d", MAX_NUM_OF_EXTRA_DMAS));
+ if (p_Params->setSizeOfFifo
+ && (!p_FmPort->fifoBufs.num
+ || (p_FmPort->fifoBufs.num > MAX_PORT_FIFO_SIZE)))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("fifoBufs.num has to be in the range of 256 - %d", MAX_PORT_FIFO_SIZE));
+ if (p_Params->setSizeOfFifo && (p_FmPort->fifoBufs.num % BMI_FIFO_UNITS))
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("fifoBufs.num has to be divisible by %d", BMI_FIFO_UNITS));
+
+#ifdef FM_QMI_NO_DEQ_OPTIONS_SUPPORT
+ if (p_FmPort->fmRevInfo.majorRev == 4)
+ if (p_FmPort->p_FmPortDriverParam->deqPrefetchOption != DEFAULT_notSupported)
+ /* this is an indication that user called config for this mode which is not supported in this integration */
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("deqPrefetchOption"));
+#endif /* FM_QMI_NO_DEQ_OPTIONS_SUPPORT */
return E_OK;
}
-static void FmPortDriverParamFree(t_FmPort *p_FmPort)
+static t_Error VerifySizeOfFifo(t_FmPort *p_FmPort)
{
- if(p_FmPort->p_FmPortDriverParam)
- {
- XX_Free(p_FmPort->p_FmPortDriverParam);
- p_FmPort->p_FmPortDriverParam = NULL;
- }
-}
-
-static t_Error SetExtBufferPools(t_FmPort *p_FmPort)
-{
- t_FmPortExtPools *p_ExtBufPools = &p_FmPort->p_FmPortDriverParam->extBufPools;
- t_FmPortBufPoolDepletion *p_BufPoolDepletion = &p_FmPort->p_FmPortDriverParam->bufPoolDepletion;
- volatile uint32_t *p_ExtBufRegs;
- volatile uint32_t *p_BufPoolDepletionReg;
- bool rxPort;
- bool found;
- uint8_t orderedArray[FM_PORT_MAX_NUM_OF_EXT_POOLS];
- uint16_t sizesArray[BM_MAX_NUM_OF_POOLS];
- uint8_t count = 0;
- uint8_t numOfPools;
- uint16_t bufSize = 0, largestBufSize = 0;
- int i=0, j=0, k=0;
- uint32_t tmpReg, vector, minFifoSizeRequired=0;
-
- memset(&orderedArray, 0, sizeof(uint8_t) * FM_PORT_MAX_NUM_OF_EXT_POOLS);
- memset(&sizesArray, 0, sizeof(uint16_t) * BM_MAX_NUM_OF_POOLS);
- memcpy(&p_FmPort->extBufPools, p_ExtBufPools, sizeof(t_FmPortExtPools));
-
- switch(p_FmPort->portType)
- {
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- p_ExtBufRegs = p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_ebmpi;
- p_BufPoolDepletionReg = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_mpd;
- rxPort = TRUE;
- break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- p_ExtBufRegs = p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_oebmpi;
- p_BufPoolDepletionReg = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ompd;
- rxPort = FALSE;
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("Not available for port type"));
+ uint32_t minFifoSizeRequired = 0, optFifoSizeForB2B = 0;
+
+ /*************************/
+ /* TX PORTS */
+ /*************************/
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_TX)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_TX_10G))
+ {
+ minFifoSizeRequired =
+ (uint32_t)(ROUND_UP(p_FmPort->maxFrameLength, BMI_FIFO_UNITS)
+ + (3 * BMI_FIFO_UNITS));
+ if (!p_FmPort->imEn)
+ minFifoSizeRequired +=
+ p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth
+ * BMI_FIFO_UNITS;
+
+ optFifoSizeForB2B = minFifoSizeRequired;
+
+ /* Add some margin for back-to-back capability to improve performance,
+ allows the hardware to pipeline new frame dma while the previous
+ frame not yet transmitted. */
+ if (p_FmPort->portType == e_FM_PORT_TYPE_TX_10G)
+ optFifoSizeForB2B += 3 * BMI_FIFO_UNITS;
+ else
+ optFifoSizeForB2B += 2 * BMI_FIFO_UNITS;
}
- /* First we copy the external buffers pools information to an ordered local array */
- for(i=0;i<p_ExtBufPools->numOfPoolsUsed;i++)
- {
- /* get pool size */
- bufSize = p_ExtBufPools->extBufPool[i].size;
-
- /* keep sizes in an array according to poolId for direct access */
- sizesArray[p_ExtBufPools->extBufPool[i].id] = bufSize;
-
- /* save poolId in an ordered array according to size */
- for (j=0;j<=i;j++)
+ /*************************/
+ /* RX IM PORTS */
+ /*************************/
+ else
+ if (((p_FmPort->portType == e_FM_PORT_TYPE_RX)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
+ && p_FmPort->imEn)
{
- /* this is the next free place in the array */
- if (j==i)
- orderedArray[i] = p_ExtBufPools->extBufPool[i].id;
- else
+ optFifoSizeForB2B =
+ minFifoSizeRequired =
+ (uint32_t)(ROUND_UP(p_FmPort->maxFrameLength, BMI_FIFO_UNITS)
+ + (4 * BMI_FIFO_UNITS));
+ }
+
+ /*************************/
+ /* RX non-IM PORTS */
+ /*************************/
+ else
+ if (((p_FmPort->portType == e_FM_PORT_TYPE_RX)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
+ && !p_FmPort->imEn)
{
- /* find the right place for this poolId */
- if(bufSize < sizesArray[orderedArray[j]])
+ if (p_FmPort->fmRevInfo.majorRev == 4)
{
- /* move the poolIds one place ahead to make room for this poolId */
- for(k=i;k>j;k--)
- orderedArray[k] = orderedArray[k-1];
-
- /* now k==j, this is the place for the new size */
- orderedArray[k] = p_ExtBufPools->extBufPool[i].id;
- break;
+ if (p_FmPort->rxPoolsParams.numOfPools == 1)
+ minFifoSizeRequired = 8 * BMI_FIFO_UNITS;
+ else
+ minFifoSizeRequired =
+ (uint32_t)(ROUND_UP(p_FmPort->rxPoolsParams.secondLargestBufSize, BMI_FIFO_UNITS)
+ + (7 * BMI_FIFO_UNITS));
+ }
+ else
+ {
+#if (DPAA_VERSION >= 11)
+ minFifoSizeRequired =
+ (uint32_t)(ROUND_UP(p_FmPort->maxFrameLength, BMI_FIFO_UNITS)
+ + (5 * BMI_FIFO_UNITS));
+ /* 4 according to spec + 1 for FOF>0 */
+#else
+ minFifoSizeRequired = (uint32_t)
+ (ROUND_UP(MIN(p_FmPort->maxFrameLength, p_FmPort->rxPoolsParams.largestBufSize), BMI_FIFO_UNITS)
+ + (7*BMI_FIFO_UNITS));
+#endif /* (DPAA_VERSION >= 11) */
}
- }
- }
- }
- /* build the register value */
+ optFifoSizeForB2B = minFifoSizeRequired;
- for(i=0;i<p_ExtBufPools->numOfPoolsUsed;i++)
- {
- tmpReg = BMI_EXT_BUF_POOL_VALID | BMI_EXT_BUF_POOL_EN_COUNTER;
- tmpReg |= ((uint32_t)orderedArray[i] << BMI_EXT_BUF_POOL_ID_SHIFT);
- tmpReg |= sizesArray[orderedArray[i]];
- /* functionality available only for some deriviatives (limited by config) */
- if(p_FmPort->p_FmPortDriverParam->p_BackupBmPools)
- for(j=0;j<p_FmPort->p_FmPortDriverParam->p_BackupBmPools->numOfBackupPools;j++)
- if(orderedArray[i] == p_FmPort->p_FmPortDriverParam->p_BackupBmPools->poolIds[j])
+ /* Add some margin for back-to-back capability to improve performance,
+ allows the hardware to pipeline new frame dma while the previous
+ frame not yet transmitted. */
+ if (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
+ optFifoSizeForB2B += 8 * BMI_FIFO_UNITS;
+ else
+ optFifoSizeForB2B += 3 * BMI_FIFO_UNITS;
+ }
+
+ /* For O/H ports, check fifo size and update if necessary */
+ else
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND))
{
- tmpReg |= BMI_EXT_BUF_POOL_BACKUP;
- break;
+#if (DPAA_VERSION >= 11)
+ optFifoSizeForB2B =
+ minFifoSizeRequired =
+ (uint32_t)(ROUND_UP(p_FmPort->maxFrameLength, BMI_FIFO_UNITS)
+ + ((p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth
+ + 5) * BMI_FIFO_UNITS));
+ /* 4 according to spec + 1 for FOF>0 */
+#else
+ optFifoSizeForB2B = minFifoSizeRequired = (uint32_t)((p_FmPort->tasks.num + 2) * BMI_FIFO_UNITS);
+#endif /* (DPAA_VERSION >= 11) */
}
- WRITE_UINT32(*(p_ExtBufRegs+i), tmpReg);
- }
- if(p_FmPort->p_FmPortDriverParam->p_BackupBmPools)
- XX_Free(p_FmPort->p_FmPortDriverParam->p_BackupBmPools);
+ ASSERT_COND(minFifoSizeRequired > 0);
+ ASSERT_COND(optFifoSizeForB2B >= minFifoSizeRequired);
- numOfPools = (uint8_t)(rxPort ? FM_PORT_MAX_NUM_OF_EXT_POOLS:FM_PORT_MAX_NUM_OF_OBSERVED_EXT_POOLS);
+ /* Verify the size */
+ if (p_FmPort->fifoBufs.num < minFifoSizeRequired)
+ DBG(INFO,
+ ("FIFO size is %d and should be enlarged to %d bytes",p_FmPort->fifoBufs.num, minFifoSizeRequired));
+ else if (p_FmPort->fifoBufs.num < optFifoSizeForB2B)
+ DBG(INFO,
+ ("For back-to-back frames processing, FIFO size is %d and needs to enlarge to %d bytes", p_FmPort->fifoBufs.num, optFifoSizeForB2B));
- /* clear unused pools */
- for(i=p_ExtBufPools->numOfPoolsUsed;i<numOfPools;i++)
- WRITE_UINT32(*(p_ExtBufRegs+i), 0);
+ return E_OK;
+}
- p_FmPort->rxPoolsParams.largestBufSize = largestBufSize = sizesArray[orderedArray[p_ExtBufPools->numOfPoolsUsed-1]];
- if((p_FmPort->portType == e_FM_PORT_TYPE_RX) || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
+static void FmPortDriverParamFree(t_FmPort *p_FmPort)
+{
+ if (p_FmPort->p_FmPortDriverParam)
{
-#ifdef FM_FIFO_ALLOCATION_OLD_ALG
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
+ XX_Free(p_FmPort->p_FmPortDriverParam);
+ p_FmPort->p_FmPortDriverParam = NULL;
+ }
+}
- if(revInfo.majorRev != 4)
- {
- minFifoSizeRequired = (uint32_t)(((largestBufSize % BMI_FIFO_UNITS) ?
- ((largestBufSize/BMI_FIFO_UNITS + 1) * BMI_FIFO_UNITS) :
- largestBufSize) +
- (7*BMI_FIFO_UNITS));
- }
- else
-#endif /* FM_FIFO_ALLOCATION_OLD_ALG */
- {
- p_FmPort->rxPoolsParams.numOfPools = p_ExtBufPools->numOfPoolsUsed;
- if(p_ExtBufPools->numOfPoolsUsed == 1)
- minFifoSizeRequired = 8*BMI_FIFO_UNITS;
- else
- {
- uint16_t secondLargestBufSize = sizesArray[orderedArray[p_ExtBufPools->numOfPoolsUsed-2]];
- p_FmPort->rxPoolsParams.secondLargestBufSize = secondLargestBufSize;
- minFifoSizeRequired = (uint32_t)(((secondLargestBufSize % BMI_FIFO_UNITS) ?
- ((secondLargestBufSize/BMI_FIFO_UNITS + 1) * BMI_FIFO_UNITS) :
- secondLargestBufSize) +
- (7*BMI_FIFO_UNITS));
- }
- }
- if(p_FmPort->fifoBufs.num < minFifoSizeRequired)
- {
- p_FmPort->fifoBufs.num = minFifoSizeRequired;
- DBG(INFO, ("FIFO size for Rx port enlarged to %d",minFifoSizeRequired));
- }
+static t_Error SetExtBufferPools(t_FmPort *p_FmPort)
+{
+ t_FmExtPools *p_ExtBufPools = &p_FmPort->p_FmPortDriverParam->extBufPools;
+ t_FmBufPoolDepletion *p_BufPoolDepletion =
+ &p_FmPort->p_FmPortDriverParam->bufPoolDepletion;
+ uint8_t orderedArray[FM_PORT_MAX_NUM_OF_EXT_POOLS];
+ uint16_t sizesArray[BM_MAX_NUM_OF_POOLS];
+ int i = 0, j = 0, err;
+ struct fman_port_bpools bpools;
+
+ memset(&orderedArray, 0, sizeof(uint8_t) * FM_PORT_MAX_NUM_OF_EXT_POOLS);
+ memset(&sizesArray, 0, sizeof(uint16_t) * BM_MAX_NUM_OF_POOLS);
+ memcpy(&p_FmPort->extBufPools, p_ExtBufPools, sizeof(t_FmExtPools));
+
+ FmSpSetBufPoolsInAscOrderOfBufSizes(p_ExtBufPools, orderedArray,
+ sizesArray);
+
+ /* Prepare flibs bpools structure */
+ memset(&bpools, 0, sizeof(struct fman_port_bpools));
+ bpools.count = p_ExtBufPools->numOfPoolsUsed;
+ bpools.counters_enable = TRUE;
+ for (i = 0; i < p_ExtBufPools->numOfPoolsUsed; i++)
+ {
+ bpools.bpool[i].bpid = orderedArray[i];
+ bpools.bpool[i].size = sizesArray[orderedArray[i]];
+ /* functionality available only for some derivatives (limited by config) */
+ if (p_FmPort->p_FmPortDriverParam->p_BackupBmPools)
+ for (j = 0;
+ j
+ < p_FmPort->p_FmPortDriverParam->p_BackupBmPools->numOfBackupPools;
+ j++)
+ if (orderedArray[i]
+ == p_FmPort->p_FmPortDriverParam->p_BackupBmPools->poolIds[j])
+ {
+ bpools.bpool[i].is_backup = TRUE;
+ break;
+ }
}
- /* check if pool size is not too big */
- /* This is a definition problem in which if the fifo for the RX port
- is lower than the largest pool size the hardware will allocate scatter gather
- buffers even though the frame size can fit in a single buffer. */
- if (largestBufSize > p_FmPort->fifoBufs.num)
- DBG(WARNING, ("Frame larger than port Fifo size (%u) will be split to more than a single buffer (S/G) even if shorter than largest buffer size (%u)",
- p_FmPort->fifoBufs.num, largestBufSize));
+ /* save pools parameters for later use */
+ p_FmPort->rxPoolsParams.numOfPools = p_ExtBufPools->numOfPoolsUsed;
+ p_FmPort->rxPoolsParams.largestBufSize =
+ sizesArray[orderedArray[p_ExtBufPools->numOfPoolsUsed - 1]];
+ p_FmPort->rxPoolsParams.secondLargestBufSize =
+ sizesArray[orderedArray[p_ExtBufPools->numOfPoolsUsed - 2]];
- /* pool depletion */
- tmpReg = 0;
- if(p_BufPoolDepletion->numberOfPoolsModeEnable)
+ /* FMBM_RMPD reg. - pool depletion */
+ if (p_BufPoolDepletion->poolsGrpModeEnable)
{
- /* calculate vector for number of pools depletion */
- found = FALSE;
- vector = 0;
- count = 0;
- for(i=0;i<BM_MAX_NUM_OF_POOLS;i++)
+ bpools.grp_bp_depleted_num = p_BufPoolDepletion->numOfPools;
+ for (i = 0; i < BM_MAX_NUM_OF_POOLS; i++)
{
- if(p_BufPoolDepletion->poolsToConsider[i])
+ if (p_BufPoolDepletion->poolsToConsider[i])
{
- for(j=0;j<p_ExtBufPools->numOfPoolsUsed;j++)
+ for (j = 0; j < p_ExtBufPools->numOfPoolsUsed; j++)
{
if (i == orderedArray[j])
{
- vector |= 0x80000000 >> j;
- found = TRUE;
- count++;
+ bpools.bpool[j].grp_bp_depleted = TRUE;
break;
}
}
- if (!found)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Pools selected for depletion are not used."));
- else
- found = FALSE;
}
}
- if (count < p_BufPoolDepletion->numOfPools)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufPoolDepletion.numOfPools is larger than the number of pools defined."));
-
- /* configure num of pools and vector for number of pools mode */
- tmpReg |= (((uint32_t)p_BufPoolDepletion->numOfPools - 1) << BMI_POOL_DEP_NUM_OF_POOLS_SHIFT);
- tmpReg |= vector;
}
- if(p_BufPoolDepletion->singlePoolModeEnable)
+ if (p_BufPoolDepletion->singlePoolModeEnable)
{
- /* calculate vector for number of pools depletion */
- found = FALSE;
- vector = 0;
- count = 0;
- for(i=0;i<BM_MAX_NUM_OF_POOLS;i++)
+ for (i = 0; i < BM_MAX_NUM_OF_POOLS; i++)
{
- if(p_BufPoolDepletion->poolsToConsiderForSingleMode[i])
+ if (p_BufPoolDepletion->poolsToConsiderForSingleMode[i])
{
- for(j=0;j<p_ExtBufPools->numOfPoolsUsed;j++)
+ for (j = 0; j < p_ExtBufPools->numOfPoolsUsed; j++)
{
if (i == orderedArray[j])
- {
- vector |= 0x00000080 >> j;
- found = TRUE;
- count++;
+ {
+ bpools.bpool[j].single_bp_depleted = TRUE;
break;
}
}
- if (!found)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Pools selected for depletion are not used."));
- else
- found = FALSE;
}
}
- if (!count)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("No pools defined for single buffer mode pool depletion."));
+ }
- /* configure num of pools and vector for number of pools mode */
- tmpReg |= vector;
+#if (DPAA_VERSION >= 11)
+ /* fill QbbPEV */
+ if (p_BufPoolDepletion->poolsGrpModeEnable
+ || p_BufPoolDepletion->singlePoolModeEnable)
+ {
+ for (i = 0; i < FM_MAX_NUM_OF_PFC_PRIORITIES; i++)
+ {
+ if (p_BufPoolDepletion->pfcPrioritiesEn[i] == TRUE)
+ {
+ bpools.bpool[i].pfc_priorities_en = TRUE;
+ }
+ }
}
+#endif /* (DPAA_VERSION >= 11) */
+
+ /* Issue flibs function */
+ err = fman_port_set_bpools(&p_FmPort->port, &bpools);
+ if (err != 0)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_set_bpools"));
- WRITE_UINT32(*p_BufPoolDepletionReg, tmpReg);
+ if (p_FmPort->p_FmPortDriverParam->p_BackupBmPools)
+ XX_Free(p_FmPort->p_FmPortDriverParam->p_BackupBmPools);
return E_OK;
}
static t_Error ClearPerfCnts(t_FmPort *p_FmPort)
{
+ if (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ FM_PORT_ModifyCounter(p_FmPort, e_FM_PORT_COUNTERS_QUEUE_UTIL, 0);
FM_PORT_ModifyCounter(p_FmPort, e_FM_PORT_COUNTERS_TASK_UTIL, 0);
- FM_PORT_ModifyCounter(p_FmPort, e_FM_PORT_COUNTERS_QUEUE_UTIL, 0);
FM_PORT_ModifyCounter(p_FmPort, e_FM_PORT_COUNTERS_DMA_UTIL, 0);
FM_PORT_ModifyCounter(p_FmPort, e_FM_PORT_COUNTERS_FIFO_UTIL, 0);
return E_OK;
}
-static t_Error BmiRxPortInit(t_FmPort *p_FmPort)
+static t_Error InitLowLevelDriver(t_FmPort *p_FmPort)
{
- t_FmPortRxBmiRegs *p_Regs = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs;
- uint32_t tmpReg;
- t_FmPortDriverParam *p_Params = p_FmPort->p_FmPortDriverParam;
- uint32_t errorsToEnq = 0;
- t_FmPortPerformanceCnt performanceContersParams;
- t_Error err;
-
- /* check that port is not busy */
- if (GET_UINT32(p_Regs->fmbm_rcfg) & BMI_PORT_CFG_EN)
- RETURN_ERROR(MAJOR, E_INVALID_STATE,
- ("Port(%d,%d) is already enabled",p_FmPort->portType, p_FmPort->portId));
-
- /* Set Config register */
- tmpReg = 0;
- if (p_FmPort->imEn)
- tmpReg |= BMI_PORT_CFG_IM;
- /* No discard - all error frames go to error queue */
- else if (p_Params->frmDiscardOverride)
- tmpReg |= BMI_PORT_CFG_FDOVR;
-
- WRITE_UINT32(p_Regs->fmbm_rcfg, tmpReg);
-
- /* Configure dma attributes */
- tmpReg = 0;
- tmpReg |= (uint32_t)p_Params->dmaSwapData << BMI_DMA_ATTR_SWP_SHIFT;
- tmpReg |= (uint32_t)p_Params->dmaIntContextCacheAttr << BMI_DMA_ATTR_IC_CACHE_SHIFT;
- tmpReg |= (uint32_t)p_Params->dmaHeaderCacheAttr << BMI_DMA_ATTR_HDR_CACHE_SHIFT;
- tmpReg |= (uint32_t)p_Params->dmaScatterGatherCacheAttr << BMI_DMA_ATTR_SG_CACHE_SHIFT;
- if(p_Params->dmaWriteOptimize)
- tmpReg |= BMI_DMA_ATTR_WRITE_OPTIMIZE;
-
- WRITE_UINT32(p_Regs->fmbm_rda, tmpReg);
-
- /* Configure Rx Fifo params */
- tmpReg = 0;
- tmpReg |= ((p_Params->rxFifoPriElevationLevel/BMI_FIFO_UNITS - 1) << BMI_RX_FIFO_PRI_ELEVATION_SHIFT);
- tmpReg |= ((p_Params->rxFifoThreshold/BMI_FIFO_UNITS - 1) << BMI_RX_FIFO_THRESHOLD_SHIFT);
-
- WRITE_UINT32(p_Regs->fmbm_rfp, tmpReg);
-
- {
-#ifdef FM_NO_THRESHOLD_REG
- t_FmRevisionInfo revInfo;
-
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if (revInfo.majorRev > 1)
-#endif /* FM_NO_THRESHOLD_REG */
- /* always allow access to the extra resources */
- WRITE_UINT32(p_Regs->fmbm_reth, BMI_RX_FIFO_THRESHOLD_BC);
- }
-
- /* frame end parameters */
- tmpReg = 0;
- tmpReg |= ((uint32_t)p_Params->cheksumLastBytesIgnore << BMI_RX_FRAME_END_CS_IGNORE_SHIFT);
- tmpReg |= ((uint32_t)p_Params->cutBytesFromEnd<< BMI_RX_FRAME_END_CUT_SHIFT);
-
- WRITE_UINT32(p_Regs->fmbm_rfed, tmpReg);
-
- /* IC parameters */
- tmpReg = 0;
- tmpReg |= (((uint32_t)p_Params->intContext.extBufOffset/OFFSET_UNITS) << BMI_IC_TO_EXT_SHIFT);
- tmpReg |= (((uint32_t)p_Params->intContext.intContextOffset/OFFSET_UNITS) << BMI_IC_FROM_INT_SHIFT);
- tmpReg |= (((uint32_t)p_Params->intContext.size/OFFSET_UNITS) << BMI_IC_SIZE_SHIFT);
-
- WRITE_UINT32(p_Regs->fmbm_ricp, tmpReg);
-
- if (!p_FmPort->imEn)
+ t_FmPortDriverParam *p_DriverParams = p_FmPort->p_FmPortDriverParam;
+ struct fman_port_params portParams;
+ uint32_t tmpVal;
+ t_Error err;
+
+ /* Set up flibs parameters and issue init function */
+
+ memset(&portParams, 0, sizeof(struct fman_port_params));
+ portParams.discard_mask = p_DriverParams->errorsToDiscard;
+ portParams.dflt_fqid = p_DriverParams->dfltFqid;
+ portParams.err_fqid = p_DriverParams->errFqid;
+ portParams.deq_sp = p_DriverParams->deqSubPortal;
+ portParams.dont_release_buf = p_DriverParams->dontReleaseBuf;
+ switch (p_FmPort->portType)
{
- /* check if the largest external buffer pool is large enough */
- if(p_Params->bufMargins.startMargins + MIN_EXT_BUF_SIZE + p_Params->bufMargins.endMargins > p_FmPort->rxPoolsParams.largestBufSize)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufMargins.startMargins (%d) + minimum buf size (64) + bufMargins.endMargins (%d) is larger than maximum external buffer size (%d)",
- p_Params->bufMargins.startMargins, p_Params->bufMargins.endMargins, p_FmPort->rxPoolsParams.largestBufSize));
-
- /* buffer margins */
- tmpReg = 0;
- tmpReg |= (((uint32_t)p_Params->bufMargins.startMargins) << BMI_EXT_BUF_MARG_START_SHIFT);
- tmpReg |= (((uint32_t)p_Params->bufMargins.endMargins) << BMI_EXT_BUF_MARG_END_SHIFT);
-
- WRITE_UINT32(p_Regs->fmbm_rebm, tmpReg);
- }
+ case (e_FM_PORT_TYPE_RX_10G):
+ case (e_FM_PORT_TYPE_RX):
+ portParams.err_mask = (RX_ERRS_TO_ENQ & ~portParams.discard_mask);
+ if (!p_FmPort->imEn)
+ {
+ if (p_DriverParams->forwardReuseIntContext)
+ p_DriverParams->dfltCfg.rx_fd_bits =
+ (uint8_t)(BMI_PORT_RFNE_FRWD_RPD >> 24);
+ }
+ break;
+ case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
+ portParams.err_mask = (OP_ERRS_TO_ENQ & ~portParams.discard_mask);
+ break;
+ break;
- if(p_FmPort->internalBufferOffset)
- {
- tmpReg = (uint32_t)((p_FmPort->internalBufferOffset % OFFSET_UNITS) ?
- (p_FmPort->internalBufferOffset/OFFSET_UNITS + 1):
- (p_FmPort->internalBufferOffset/OFFSET_UNITS));
- p_FmPort->internalBufferOffset = (uint8_t)(tmpReg * OFFSET_UNITS);
- WRITE_UINT32(p_Regs->fmbm_rim, tmpReg << BMI_IM_FOF_SHIFT);
+ default:
+ break;
}
- /* NIA */
- if (p_FmPort->imEn)
- WRITE_UINT32(p_Regs->fmbm_rfne, NIA_ENG_FM_CTL | NIA_FM_CTL_AC_IND_MODE_RX);
+ tmpVal =
+ (uint32_t)(
+ (p_FmPort->internalBufferOffset % OFFSET_UNITS) ? (p_FmPort->internalBufferOffset
+ / OFFSET_UNITS + 1) :
+ (p_FmPort->internalBufferOffset / OFFSET_UNITS));
+ p_FmPort->internalBufferOffset = (uint8_t)(tmpVal * OFFSET_UNITS);
+ p_DriverParams->dfltCfg.int_buf_start_margin =
+ p_FmPort->internalBufferOffset;
+
+ p_DriverParams->dfltCfg.ext_buf_start_margin =
+ p_DriverParams->bufMargins.startMargins;
+ p_DriverParams->dfltCfg.ext_buf_end_margin =
+ p_DriverParams->bufMargins.endMargins;
+
+ p_DriverParams->dfltCfg.ic_ext_offset =
+ p_DriverParams->intContext.extBufOffset;
+ p_DriverParams->dfltCfg.ic_int_offset =
+ p_DriverParams->intContext.intContextOffset;
+ p_DriverParams->dfltCfg.ic_size = p_DriverParams->intContext.size;
+
+ p_DriverParams->dfltCfg.stats_counters_enable = TRUE;
+ p_DriverParams->dfltCfg.perf_counters_enable = TRUE;
+ p_DriverParams->dfltCfg.queue_counters_enable = TRUE;
+
+ p_DriverParams->dfltCfg.perf_cnt_params.task_val =
+ (uint8_t)p_FmPort->tasks.num;
+ if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING ||
+ p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)p_DriverParams->dfltCfg.perf_cnt_params.queue_val = 0;
else
- {
- tmpReg = 0;
- if (p_Params->forwardReuseIntContext)
- tmpReg |= BMI_PORT_RFNE_FRWD_RPD;
- /* L3/L4 checksum verify is enabled by default. */
- /*tmpReg |= BMI_PORT_RFNE_FRWD_DCL4C;*/
- WRITE_UINT32(p_Regs->fmbm_rfne, tmpReg | NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME);
- }
- WRITE_UINT32(p_Regs->fmbm_rfene, NIA_ENG_QMI_ENQ | NIA_ORDER_RESTOR);
-
- /* command attribute */
- tmpReg = BMI_CMD_RX_MR_DEF;
- if (!p_FmPort->imEn)
- {
- tmpReg |= BMI_CMD_ATTR_ORDER;
- if(p_Params->syncReq)
- tmpReg |= BMI_CMD_ATTR_SYNC;
- tmpReg |= ((uint32_t)p_Params->color << BMI_CMD_ATTR_COLOR_SHIFT);
- }
+ p_DriverParams->dfltCfg.perf_cnt_params.queue_val = 1;
+ p_DriverParams->dfltCfg.perf_cnt_params.dma_val =
+ (uint8_t)p_FmPort->openDmas.num;
+ p_DriverParams->dfltCfg.perf_cnt_params.fifo_val = p_FmPort->fifoBufs.num;
- WRITE_UINT32(p_Regs->fmbm_rfca, tmpReg);
+ if (0
+ != fman_port_init(&p_FmPort->port, &p_DriverParams->dfltCfg,
+ &portParams))
+ RETURN_ERROR(MAJOR, E_NO_DEVICE, ("fman_port_init"));
- /* default queues */
- if (!p_FmPort->imEn)
- {
- WRITE_UINT32(p_Regs->fmbm_rfqid, p_Params->dfltFqid);
- WRITE_UINT32(p_Regs->fmbm_refqid, p_Params->errFqid);
- }
-
- /* set counters */
- WRITE_UINT32(p_Regs->fmbm_rstc, BMI_COUNTERS_EN);
-
- performanceContersParams.taskCompVal = (uint8_t)p_FmPort->tasks.num;
- performanceContersParams.queueCompVal = 1;
- performanceContersParams.dmaCompVal =(uint8_t) p_FmPort->openDmas.num;
- performanceContersParams.fifoCompVal = p_FmPort->fifoBufs.num;
- if((err = FM_PORT_SetPerformanceCountersParams(p_FmPort, &performanceContersParams)) != E_OK)
+ if (p_FmPort->imEn && ((err = FmPortImInit(p_FmPort)) != E_OK))
RETURN_ERROR(MAJOR, err, NO_MSG);
-
- WRITE_UINT32(p_Regs->fmbm_rpc, BMI_COUNTERS_EN);
-
- /* error/status mask - check that if discard OV is set, no
- discard is required for specific errors.*/
- WRITE_UINT32(p_Regs->fmbm_rfsdm, p_Params->errorsToDiscard);
-
- errorsToEnq = (RX_ERRS_TO_ENQ & ~p_Params->errorsToDiscard);
- WRITE_UINT32(p_Regs->fmbm_rfsem, errorsToEnq);
-
-#ifdef FM_BMI_TO_RISC_ENQ_ERRATA_FMANc
- if((GET_UINT32(p_Regs->fmbm_rfene) && NIA_ENG_MASK)== NIA_ENG_FM_CTL)
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("NIA not supported at this stage"));
-#endif /* FM_BMI_TO_RISC_ENQ_ERRATA_FMANc */
-
- return E_OK;
-}
-
-static t_Error BmiTxPortInit(t_FmPort *p_FmPort)
-{
- t_FmPortTxBmiRegs *p_Regs = &p_FmPort->p_FmPortBmiRegs->txPortBmiRegs;
- uint32_t tmpReg;
- t_FmPortDriverParam *p_Params = p_FmPort->p_FmPortDriverParam;
- /*uint32_t rateCountUnit;*/
- t_FmPortPerformanceCnt performanceContersParams;
-
- /* check that port is not busy */
- if (GET_UINT32(p_Regs->fmbm_tcfg) & BMI_PORT_CFG_EN)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Port is already enabled"));
-
- tmpReg = 0;
- if (p_FmPort->imEn)
- tmpReg |= BMI_PORT_CFG_IM;
-
- WRITE_UINT32(p_Regs->fmbm_tcfg, tmpReg);
-
- /* Configure dma attributes */
- tmpReg = 0;
- tmpReg |= (uint32_t)p_Params->dmaSwapData << BMI_DMA_ATTR_SWP_SHIFT;
- tmpReg |= (uint32_t)p_Params->dmaIntContextCacheAttr << BMI_DMA_ATTR_IC_CACHE_SHIFT;
- tmpReg |= (uint32_t)p_Params->dmaHeaderCacheAttr << BMI_DMA_ATTR_HDR_CACHE_SHIFT;
- tmpReg |= (uint32_t)p_Params->dmaScatterGatherCacheAttr << BMI_DMA_ATTR_SG_CACHE_SHIFT;
-
- WRITE_UINT32(p_Regs->fmbm_tda, tmpReg);
-
- /* Configure Tx Fifo params */
- tmpReg = 0;
- tmpReg |= ((p_Params->txFifoMinFillLevel/BMI_FIFO_UNITS) << BMI_TX_FIFO_MIN_FILL_SHIFT);
- tmpReg |= (((uint32_t)p_FmPort->txFifoDeqPipelineDepth - 1) << BMI_TX_FIFO_PIPELINE_DEPTH_SHIFT);
- tmpReg |= ((p_Params->txFifoLowComfLevel/BMI_FIFO_UNITS - 1) << BMI_TX_LOW_COMF_SHIFT);
-
- WRITE_UINT32(p_Regs->fmbm_tfp, tmpReg);
-
- /* frame end parameters */
- tmpReg = 0;
- tmpReg |= ((uint32_t)p_Params->cheksumLastBytesIgnore << BMI_TX_FRAME_END_CS_IGNORE_SHIFT);
-
- WRITE_UINT32(p_Regs->fmbm_tfed, tmpReg);
-
- if (!p_FmPort->imEn)
- {
- /* IC parameters */
- tmpReg = 0;
- tmpReg |= (((uint32_t)p_Params->intContext.extBufOffset/OFFSET_UNITS) << BMI_IC_TO_EXT_SHIFT);
- tmpReg |= (((uint32_t)p_Params->intContext.intContextOffset/OFFSET_UNITS) << BMI_IC_FROM_INT_SHIFT);
- tmpReg |= (((uint32_t)p_Params->intContext.size/OFFSET_UNITS) << BMI_IC_SIZE_SHIFT);
-
- WRITE_UINT32(p_Regs->fmbm_ticp, tmpReg);
- }
-
- /* NIA */
- if (p_FmPort->imEn)
+ else
{
- WRITE_UINT32(p_Regs->fmbm_tfne, NIA_ENG_FM_CTL | NIA_FM_CTL_AC_IND_MODE_TX);
- WRITE_UINT32(p_Regs->fmbm_tfene, NIA_ENG_FM_CTL | NIA_FM_CTL_AC_IND_MODE_TX);
+ // from QMIInit
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
+ {
+ if (p_DriverParams->deqPrefetchOption == e_FM_PORT_DEQ_NO_PREFETCH)
+ FmSetPortPreFetchConfiguration(p_FmPort->h_Fm, p_FmPort->portId,
+ FALSE);
+ else
+ FmSetPortPreFetchConfiguration(p_FmPort->h_Fm, p_FmPort->portId,
+ TRUE);
+ }
}
- else
+ /* The code bellow is a trick so the FM will not release the buffer
+ to BM nor will try to enqueue the frame to QM */
+ if (((p_FmPort->portType == e_FM_PORT_TYPE_TX_10G)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_TX)) && (!p_FmPort->imEn))
{
- WRITE_UINT32(p_Regs->fmbm_tfne, NIA_ENG_QMI_DEQ);
- WRITE_UINT32(p_Regs->fmbm_tfene, NIA_ENG_QMI_ENQ | NIA_ORDER_RESTOR);
- /* The line bellow is a trick so the FM will not release the buffer
- to BM nor will try to enq the frame to QM */
- if(!p_Params->dfltFqid && p_Params->dontReleaseBuf)
+ if (!p_DriverParams->dfltFqid && p_DriverParams->dontReleaseBuf)
{
/* override fmbm_tcfqid 0 with a false non-0 value. This will force FM to
- * act acording to tfene. Otherwise, if fmbm_tcfqid is 0 the FM will release
+ * act according to tfene. Otherwise, if fmbm_tcfqid is 0 the FM will release
* buffers to BM regardless of fmbm_tfene
*/
- WRITE_UINT32(p_Regs->fmbm_tcfqid, 0xFFFFFF);
- WRITE_UINT32(p_Regs->fmbm_tfene, NIA_ENG_BMI | NIA_BMI_AC_TX_RELEASE);
+ WRITE_UINT32(p_FmPort->port.bmi_regs->tx.fmbm_tcfqid, 0xFFFFFF);
+ WRITE_UINT32(p_FmPort->port.bmi_regs->tx.fmbm_tfene,
+ NIA_ENG_BMI | NIA_BMI_AC_TX_RELEASE);
}
}
- /* command attribute */
- tmpReg = BMI_CMD_TX_MR_DEF;
- if (p_FmPort->imEn)
- tmpReg |= BMI_CMD_MR_DEAS;
- else
- {
- tmpReg |= BMI_CMD_ATTR_ORDER;
- /* if we set syncReq, we may get stuck when HC command is running */
- /*if(p_Params->syncReq)
- tmpReg |= BMI_CMD_ATTR_SYNC;*/
- tmpReg |= ((uint32_t)p_Params->color << BMI_CMD_ATTR_COLOR_SHIFT);
- }
-
- WRITE_UINT32(p_Regs->fmbm_tfca, tmpReg);
-
- /* default queues */
- if (!p_FmPort->imEn)
- {
- if(p_Params->dfltFqid || !p_Params->dontReleaseBuf)
- WRITE_UINT32(p_Regs->fmbm_tcfqid, p_Params->dfltFqid);
- WRITE_UINT32(p_Regs->fmbm_tfeqid, p_Params->errFqid);
- }
-
- /* statistics & performance counters */
- WRITE_UINT32(p_Regs->fmbm_tstc, BMI_COUNTERS_EN);
-
- performanceContersParams.taskCompVal = (uint8_t)p_FmPort->tasks.num;
- performanceContersParams.queueCompVal = 1;
- performanceContersParams.dmaCompVal = (uint8_t)p_FmPort->openDmas.num;
- performanceContersParams.fifoCompVal = p_FmPort->fifoBufs.num;
- FM_PORT_SetPerformanceCountersParams(p_FmPort, &performanceContersParams);
-
- WRITE_UINT32(p_Regs->fmbm_tpc, BMI_COUNTERS_EN);
-
return E_OK;
}
-static t_Error BmiOhPortInit(t_FmPort *p_FmPort)
+static bool CheckRxBmiCounter(t_FmPort *p_FmPort, e_FmPortCounters counter)
{
- t_FmPortOhBmiRegs *p_Regs = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs;
- uint32_t tmpReg, errorsToEnq = 0;
- t_FmPortDriverParam *p_Params = p_FmPort->p_FmPortDriverParam;
- t_FmPortPerformanceCnt performanceContersParams;
- t_Error err;
-
- /* check that port is not busy */
- if (GET_UINT32(p_Regs->fmbm_ocfg) & BMI_PORT_CFG_EN)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Port is already enabled"));
-
- /* Configure dma attributes */
- tmpReg = 0;
- tmpReg |= (uint32_t)p_Params->dmaSwapData << BMI_DMA_ATTR_SWP_SHIFT;
- tmpReg |= (uint32_t)p_Params->dmaIntContextCacheAttr << BMI_DMA_ATTR_IC_CACHE_SHIFT;
- tmpReg |= (uint32_t)p_Params->dmaHeaderCacheAttr << BMI_DMA_ATTR_HDR_CACHE_SHIFT;
- tmpReg |= (uint32_t)p_Params->dmaScatterGatherCacheAttr << BMI_DMA_ATTR_SG_CACHE_SHIFT;
- if(p_Params->dmaWriteOptimize)
- tmpReg |= BMI_DMA_ATTR_WRITE_OPTIMIZE;
-
- WRITE_UINT32(p_Regs->fmbm_oda, tmpReg);
-
- /* IC parameters */
- tmpReg = 0;
- tmpReg |= (((uint32_t)p_Params->intContext.extBufOffset/OFFSET_UNITS) << BMI_IC_TO_EXT_SHIFT);
- tmpReg |= (((uint32_t)p_Params->intContext.intContextOffset/OFFSET_UNITS) << BMI_IC_FROM_INT_SHIFT);
- tmpReg |= (((uint32_t)p_Params->intContext.size/OFFSET_UNITS) << BMI_IC_SIZE_SHIFT);
-
- WRITE_UINT32(p_Regs->fmbm_oicp, tmpReg);
-
- /* NIA */
- WRITE_UINT32(p_Regs->fmbm_ofdne, NIA_ENG_QMI_DEQ);
-
- if (p_FmPort->portType==e_FM_PORT_TYPE_OH_HOST_COMMAND)
- WRITE_UINT32(p_Regs->fmbm_ofene, NIA_ENG_QMI_ENQ);
- else
- WRITE_UINT32(p_Regs->fmbm_ofene, NIA_ENG_QMI_ENQ | NIA_ORDER_RESTOR);
-
- /* command attribute */
- if (p_FmPort->portType==e_FM_PORT_TYPE_OH_HOST_COMMAND)
- tmpReg = BMI_CMD_MR_DEAS | BMI_CMD_MR_MA;
- else
- tmpReg = BMI_CMD_ATTR_ORDER | BMI_CMD_MR_DEAS | BMI_CMD_MR_MA;
-
- if(p_Params->syncReq)
- tmpReg |= BMI_CMD_ATTR_SYNC;
- tmpReg |= ((uint32_t)p_Params->color << BMI_CMD_ATTR_COLOR_SHIFT);
- WRITE_UINT32(p_Regs->fmbm_ofca, tmpReg);
-
- /* No discard - all error frames go to error queue */
- if (p_Params->frmDiscardOverride)
- tmpReg = BMI_PORT_CFG_FDOVR;
- else
- tmpReg = 0;
- WRITE_UINT32(p_Regs->fmbm_ocfg, tmpReg);
-
- if(p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
- {
- WRITE_UINT32(p_Regs->fmbm_ofsdm, p_Params->errorsToDiscard);
-
- errorsToEnq = (OP_ERRS_TO_ENQ & ~p_Params->errorsToDiscard);
- WRITE_UINT32(p_Regs->fmbm_ofsem, errorsToEnq);
-
- /* NIA */
- WRITE_UINT32(p_Regs->fmbm_ofne, NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME);
- {
-#ifdef FM_NO_OP_OBSERVED_POOLS
- t_FmRevisionInfo revInfo;
-
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if ((revInfo.majorRev == 4) && (p_Params->enBufPoolDepletion))
-#endif /* FM_NO_OP_OBSERVED_POOLS */
- {
- /* define external buffer pools */
- err = SetExtBufferPools(p_FmPort);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
- }
- }
+ UNUSED(p_FmPort);
+
+ switch (counter)
+ {
+ case (e_FM_PORT_COUNTERS_CYCLE):
+ case (e_FM_PORT_COUNTERS_TASK_UTIL):
+ case (e_FM_PORT_COUNTERS_QUEUE_UTIL):
+ case (e_FM_PORT_COUNTERS_DMA_UTIL):
+ case (e_FM_PORT_COUNTERS_FIFO_UTIL):
+ case (e_FM_PORT_COUNTERS_RX_PAUSE_ACTIVATION):
+ case (e_FM_PORT_COUNTERS_FRAME):
+ case (e_FM_PORT_COUNTERS_DISCARD_FRAME):
+ case (e_FM_PORT_COUNTERS_RX_BAD_FRAME):
+ case (e_FM_PORT_COUNTERS_RX_LARGE_FRAME):
+ case (e_FM_PORT_COUNTERS_RX_FILTER_FRAME):
+ case (e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR):
+ case (e_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD):
+ case (e_FM_PORT_COUNTERS_DEALLOC_BUF):
+ case (e_FM_PORT_COUNTERS_PREPARE_TO_ENQUEUE_COUNTER):
+ return TRUE;
+ default:
+ return FALSE;
}
- else
- /* NIA */
- WRITE_UINT32(p_Regs->fmbm_ofne, NIA_ENG_FM_CTL | NIA_FM_CTL_AC_HC);
-
- /* default queues */
- WRITE_UINT32(p_Regs->fmbm_ofqid, p_Params->dfltFqid);
- WRITE_UINT32(p_Regs->fmbm_oefqid, p_Params->errFqid);
+}
- if(p_FmPort->internalBufferOffset)
- {
- tmpReg = (uint32_t)((p_FmPort->internalBufferOffset % OFFSET_UNITS) ?
- (p_FmPort->internalBufferOffset/OFFSET_UNITS + 1):
- (p_FmPort->internalBufferOffset/OFFSET_UNITS));
- p_FmPort->internalBufferOffset = (uint8_t)(tmpReg * OFFSET_UNITS);
- WRITE_UINT32(p_Regs->fmbm_oim, tmpReg << BMI_IM_FOF_SHIFT);
+static bool CheckTxBmiCounter(t_FmPort *p_FmPort, e_FmPortCounters counter)
+{
+ UNUSED(p_FmPort);
+
+ switch (counter)
+ {
+ case (e_FM_PORT_COUNTERS_CYCLE):
+ case (e_FM_PORT_COUNTERS_TASK_UTIL):
+ case (e_FM_PORT_COUNTERS_QUEUE_UTIL):
+ case (e_FM_PORT_COUNTERS_DMA_UTIL):
+ case (e_FM_PORT_COUNTERS_FIFO_UTIL):
+ case (e_FM_PORT_COUNTERS_FRAME):
+ case (e_FM_PORT_COUNTERS_DISCARD_FRAME):
+ case (e_FM_PORT_COUNTERS_LENGTH_ERR):
+ case (e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT):
+ case (e_FM_PORT_COUNTERS_DEALLOC_BUF):
+ return TRUE;
+ default:
+ return FALSE;
}
- /* statistics & performance counters */
- WRITE_UINT32(p_Regs->fmbm_ostc, BMI_COUNTERS_EN);
-
- performanceContersParams.taskCompVal = (uint8_t)p_FmPort->tasks.num;
- performanceContersParams.queueCompVal = 0;
- performanceContersParams.dmaCompVal = (uint8_t)p_FmPort->openDmas.num;
- performanceContersParams.fifoCompVal = p_FmPort->fifoBufs.num;
- FM_PORT_SetPerformanceCountersParams(p_FmPort, &performanceContersParams);
-
- WRITE_UINT32(p_Regs->fmbm_opc, BMI_COUNTERS_EN);
-
- return E_OK;
}
-static t_Error QmiInit(t_FmPort *p_FmPort)
+static bool CheckOhBmiCounter(t_FmPort *p_FmPort, e_FmPortCounters counter)
{
- t_FmPortDriverParam *p_Params = NULL;
- uint32_t tmpReg;
-
- p_Params = p_FmPort->p_FmPortDriverParam;
-
- /* check that port is not busy */
- if(((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) &&
- (p_FmPort->portType != e_FM_PORT_TYPE_RX)) &&
- (GET_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnc) & QMI_PORT_CFG_EN))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Port is already enabled"));
-
- /* enable & clear counters */
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnc, QMI_PORT_CFG_EN_COUNTERS);
-
- /* The following is done for non-Rx ports only */
- if((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) &&
- (p_FmPort->portType != e_FM_PORT_TYPE_RX))
- {
- if((p_FmPort->portType == e_FM_PORT_TYPE_TX_10G) ||
- (p_FmPort->portType == e_FM_PORT_TYPE_TX))
- {
- /* define dequeue NIA */
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs.fmqm_pndn, NIA_ENG_BMI | NIA_BMI_AC_TX);
- /* define enqueue NIA */
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnen, NIA_ENG_BMI | NIA_BMI_AC_TX_RELEASE);
- }
- else /* for HC & OP */
- {
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs.fmqm_pndn, NIA_ENG_BMI | NIA_BMI_AC_FETCH);
- /* define enqueue NIA */
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnen, NIA_ENG_BMI | NIA_BMI_AC_RELEASE);
- }
-
- /* configure dequeue */
- tmpReg = 0;
- if(p_Params->deqHighPriority)
- tmpReg |= QMI_DEQ_CFG_PRI;
-
- switch(p_Params->deqType)
- {
- case(e_FM_PORT_DEQ_TYPE1):
- tmpReg |= QMI_DEQ_CFG_TYPE1;
- break;
- case(e_FM_PORT_DEQ_TYPE2):
- tmpReg |= QMI_DEQ_CFG_TYPE2;
- break;
- case(e_FM_PORT_DEQ_TYPE3):
- tmpReg |= QMI_DEQ_CFG_TYPE3;
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid dequeue type"));
- }
-
-#ifdef FM_QMI_DEQ_OPTIONS_SUPPORT
- switch(p_Params->deqPrefetchOption)
- {
- case(e_FM_PORT_DEQ_NO_PREFETCH):
- /* Do nothing - QMI_DEQ_CFG_PREFETCH_WAITING_TNUM | QMI_DEQ_CFG_PREFETCH_1_FRAME = 0 */
- break;
- case(e_FM_PORT_DEQ_PARTIAL_PREFETCH):
- tmpReg |= QMI_DEQ_CFG_PREFETCH_WAITING_TNUM | QMI_DEQ_CFG_PREFETCH_3_FRAMES;
- break;
- case(e_FM_PORT_DEQ_FULL_PREFETCH):
- tmpReg |= QMI_DEQ_CFG_PREFETCH_NO_TNUM | QMI_DEQ_CFG_PREFETCH_3_FRAMES;
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid dequeue prefetch option"));
- }
-#endif /* FM_QMI_DEQ_OPTIONS_SUPPORT */
-
- tmpReg |= p_Params->deqByteCnt;
- tmpReg |= (uint32_t)p_Params->deqSubPortal << QMI_DEQ_CFG_SUBPORTAL_SHIFT;
-
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs.fmqm_pndc, tmpReg);
+ switch (counter)
+ {
+ case (e_FM_PORT_COUNTERS_CYCLE):
+ case (e_FM_PORT_COUNTERS_TASK_UTIL):
+ case (e_FM_PORT_COUNTERS_DMA_UTIL):
+ case (e_FM_PORT_COUNTERS_FIFO_UTIL):
+ case (e_FM_PORT_COUNTERS_FRAME):
+ case (e_FM_PORT_COUNTERS_DISCARD_FRAME):
+ case (e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR):
+ case (e_FM_PORT_COUNTERS_WRED_DISCARD):
+ case (e_FM_PORT_COUNTERS_LENGTH_ERR):
+ case (e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT):
+ case (e_FM_PORT_COUNTERS_DEALLOC_BUF):
+ return TRUE;
+ case (e_FM_PORT_COUNTERS_RX_FILTER_FRAME):
+ if (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)
+ return FALSE;
+ else
+ return TRUE;
+ default:
+ return FALSE;
}
- else /* rx port */
- /* define enqueue NIA */
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnen, NIA_ENG_BMI | NIA_BMI_AC_RELEASE);
-
- return E_OK;
}
-static t_Error BmiRxPortCheckAndGetCounterPtr(t_FmPort *p_FmPort, e_FmPortCounters counter, volatile uint32_t **p_Ptr)
+static t_Error BmiPortCheckAndGetCounterType(
+ t_FmPort *p_FmPort, e_FmPortCounters counter,
+ enum fman_port_stats_counters *p_StatsType,
+ enum fman_port_perf_counters *p_PerfType, bool *p_IsStats)
{
- t_FmPortRxBmiRegs *p_BmiRegs = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs;
-
- /* check that counters are enabled */
- switch(counter)
- {
- case(e_FM_PORT_COUNTERS_CYCLE):
- case(e_FM_PORT_COUNTERS_TASK_UTIL):
- case(e_FM_PORT_COUNTERS_QUEUE_UTIL):
- case(e_FM_PORT_COUNTERS_DMA_UTIL):
- case(e_FM_PORT_COUNTERS_FIFO_UTIL):
- case(e_FM_PORT_COUNTERS_RX_PAUSE_ACTIVATION):
- /* performance counters - may be read when disabled */
- break;
- case(e_FM_PORT_COUNTERS_FRAME):
- case(e_FM_PORT_COUNTERS_DISCARD_FRAME):
- case(e_FM_PORT_COUNTERS_RX_BAD_FRAME):
- case(e_FM_PORT_COUNTERS_RX_LARGE_FRAME):
- case(e_FM_PORT_COUNTERS_RX_FILTER_FRAME):
- case(e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR):
- case(e_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD):
- case(e_FM_PORT_COUNTERS_DEALLOC_BUF):
- if(!(GET_UINT32(p_BmiRegs->fmbm_rstc) & BMI_COUNTERS_EN))
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter was not enabled"));
- break;
- default:
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter is not available for Rx ports"));
- }
+ volatile uint32_t *p_Reg;
+ bool isValid;
- /* Set counter */
- switch(counter)
+ switch (p_FmPort->portType)
{
- case(e_FM_PORT_COUNTERS_CYCLE):
- *p_Ptr = &p_BmiRegs->fmbm_rccn;
- break;
- case(e_FM_PORT_COUNTERS_TASK_UTIL):
- *p_Ptr = &p_BmiRegs->fmbm_rtuc;
- break;
- case(e_FM_PORT_COUNTERS_QUEUE_UTIL):
- *p_Ptr = &p_BmiRegs->fmbm_rrquc;
- break;
- case(e_FM_PORT_COUNTERS_DMA_UTIL):
- *p_Ptr = &p_BmiRegs->fmbm_rduc;
- break;
- case(e_FM_PORT_COUNTERS_FIFO_UTIL):
- *p_Ptr = &p_BmiRegs->fmbm_rfuc;
- break;
- case(e_FM_PORT_COUNTERS_RX_PAUSE_ACTIVATION):
- *p_Ptr = &p_BmiRegs->fmbm_rpac;
- break;
- case(e_FM_PORT_COUNTERS_FRAME):
- *p_Ptr = &p_BmiRegs->fmbm_rfrc;
- break;
- case(e_FM_PORT_COUNTERS_DISCARD_FRAME):
- *p_Ptr = &p_BmiRegs->fmbm_rfcd;
- break;
- case(e_FM_PORT_COUNTERS_RX_BAD_FRAME):
- *p_Ptr = &p_BmiRegs->fmbm_rfbc;
- break;
- case(e_FM_PORT_COUNTERS_RX_LARGE_FRAME):
- *p_Ptr = &p_BmiRegs->fmbm_rlfc;
- break;
- case(e_FM_PORT_COUNTERS_RX_FILTER_FRAME):
- *p_Ptr = &p_BmiRegs->fmbm_rffc;
- break;
- case(e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR):
-#ifdef FM_PORT_COUNTERS_ERRATA_FMANg
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("Requested counter is not available in rev1"));
- }
-#endif /* FM_PORT_COUNTERS_ERRATA_FMANg */
- *p_Ptr = &p_BmiRegs->fmbm_rfldec;
+ case (e_FM_PORT_TYPE_RX_10G):
+ case (e_FM_PORT_TYPE_RX):
+ p_Reg = &p_FmPort->port.bmi_regs->rx.fmbm_rstc;
+ isValid = CheckRxBmiCounter(p_FmPort, counter);
break;
- case(e_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD):
- *p_Ptr = &p_BmiRegs->fmbm_rodc;
+ case (e_FM_PORT_TYPE_TX_10G):
+ case (e_FM_PORT_TYPE_TX):
+ p_Reg = &p_FmPort->port.bmi_regs->tx.fmbm_tstc;
+ isValid = CheckTxBmiCounter(p_FmPort, counter);
break;
- case(e_FM_PORT_COUNTERS_DEALLOC_BUF):
- *p_Ptr = &p_BmiRegs->fmbm_rbdc;
+ case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
+ case (e_FM_PORT_TYPE_OH_HOST_COMMAND):
+ p_Reg = &p_FmPort->port.bmi_regs->oh.fmbm_ostc;
+ isValid = CheckOhBmiCounter(p_FmPort, counter);
break;
default:
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter is not available for Rx ports"));
+ RETURN_ERROR(MINOR, E_INVALID_STATE, ("Unsupported port type"));
}
- return E_OK;
-}
-
-static t_Error BmiTxPortCheckAndGetCounterPtr(t_FmPort *p_FmPort, e_FmPortCounters counter, volatile uint32_t **p_Ptr)
-{
- t_FmPortTxBmiRegs *p_BmiRegs = &p_FmPort->p_FmPortBmiRegs->txPortBmiRegs;
+ if (!isValid)
+ RETURN_ERROR(MINOR, E_INVALID_STATE,
+ ("Requested counter is not available for this port type"));
- /* check that counters are enabled */
- switch(counter)
- {
- case(e_FM_PORT_COUNTERS_CYCLE):
- case(e_FM_PORT_COUNTERS_TASK_UTIL):
- case(e_FM_PORT_COUNTERS_QUEUE_UTIL):
- case(e_FM_PORT_COUNTERS_DMA_UTIL):
- case(e_FM_PORT_COUNTERS_FIFO_UTIL):
+ /* check that counters are enabled */
+ switch (counter)
+ {
+ case (e_FM_PORT_COUNTERS_CYCLE):
+ case (e_FM_PORT_COUNTERS_TASK_UTIL):
+ case (e_FM_PORT_COUNTERS_QUEUE_UTIL):
+ case (e_FM_PORT_COUNTERS_DMA_UTIL):
+ case (e_FM_PORT_COUNTERS_FIFO_UTIL):
+ case (e_FM_PORT_COUNTERS_RX_PAUSE_ACTIVATION):
/* performance counters - may be read when disabled */
+ *p_IsStats = FALSE;
break;
- case(e_FM_PORT_COUNTERS_FRAME):
- case(e_FM_PORT_COUNTERS_DISCARD_FRAME):
- case(e_FM_PORT_COUNTERS_LENGTH_ERR):
- case(e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT):
- case(e_FM_PORT_COUNTERS_DEALLOC_BUF):
- if(!(GET_UINT32(p_BmiRegs->fmbm_tstc) & BMI_COUNTERS_EN))
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter was not enabled"));
+ case (e_FM_PORT_COUNTERS_FRAME):
+ case (e_FM_PORT_COUNTERS_DISCARD_FRAME):
+ case (e_FM_PORT_COUNTERS_DEALLOC_BUF):
+ case (e_FM_PORT_COUNTERS_RX_BAD_FRAME):
+ case (e_FM_PORT_COUNTERS_RX_LARGE_FRAME):
+ case (e_FM_PORT_COUNTERS_RX_FILTER_FRAME):
+ case (e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR):
+ case (e_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD):
+ case (e_FM_PORT_COUNTERS_LENGTH_ERR):
+ case (e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT):
+ case (e_FM_PORT_COUNTERS_WRED_DISCARD):
+ *p_IsStats = TRUE;
+ if (!(GET_UINT32(*p_Reg) & BMI_COUNTERS_EN))
+ RETURN_ERROR(MINOR, E_INVALID_STATE,
+ ("Requested counter was not enabled"));
break;
default:
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter is not available for Tx ports"));
+ break;
}
/* Set counter */
- switch(counter)
+ switch (counter)
{
- case(e_FM_PORT_COUNTERS_CYCLE):
- *p_Ptr = &p_BmiRegs->fmbm_tccn;
+ case (e_FM_PORT_COUNTERS_CYCLE):
+ *p_PerfType = E_FMAN_PORT_PERF_CNT_CYCLE;
break;
- case(e_FM_PORT_COUNTERS_TASK_UTIL):
- *p_Ptr = &p_BmiRegs->fmbm_ttuc;
+ case (e_FM_PORT_COUNTERS_TASK_UTIL):
+ *p_PerfType = E_FMAN_PORT_PERF_CNT_TASK_UTIL;
break;
- case(e_FM_PORT_COUNTERS_QUEUE_UTIL):
- *p_Ptr = &p_BmiRegs->fmbm_ttcquc;
+ case (e_FM_PORT_COUNTERS_QUEUE_UTIL):
+ *p_PerfType = E_FMAN_PORT_PERF_CNT_QUEUE_UTIL;
break;
- case(e_FM_PORT_COUNTERS_DMA_UTIL):
- *p_Ptr = &p_BmiRegs->fmbm_tduc;
+ case (e_FM_PORT_COUNTERS_DMA_UTIL):
+ *p_PerfType = E_FMAN_PORT_PERF_CNT_DMA_UTIL;
break;
- case(e_FM_PORT_COUNTERS_FIFO_UTIL):
- *p_Ptr = &p_BmiRegs->fmbm_tfuc;
+ case (e_FM_PORT_COUNTERS_FIFO_UTIL):
+ *p_PerfType = E_FMAN_PORT_PERF_CNT_FIFO_UTIL;
break;
- case(e_FM_PORT_COUNTERS_FRAME):
- *p_Ptr = &p_BmiRegs->fmbm_tfrc;
+ case (e_FM_PORT_COUNTERS_RX_PAUSE_ACTIVATION):
+ *p_PerfType = E_FMAN_PORT_PERF_CNT_RX_PAUSE;
break;
- case(e_FM_PORT_COUNTERS_DISCARD_FRAME):
- *p_Ptr = &p_BmiRegs->fmbm_tfdc;
+ case (e_FM_PORT_COUNTERS_FRAME):
+ *p_StatsType = E_FMAN_PORT_STATS_CNT_FRAME;
break;
- case(e_FM_PORT_COUNTERS_LENGTH_ERR):
- *p_Ptr = &p_BmiRegs->fmbm_tfledc;
+ case (e_FM_PORT_COUNTERS_DISCARD_FRAME):
+ *p_StatsType = E_FMAN_PORT_STATS_CNT_DISCARD;
break;
- case(e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT):
- *p_Ptr = &p_BmiRegs->fmbm_tfufdc;
+ case (e_FM_PORT_COUNTERS_DEALLOC_BUF):
+ *p_StatsType = E_FMAN_PORT_STATS_CNT_DEALLOC_BUF;
break;
- case(e_FM_PORT_COUNTERS_DEALLOC_BUF):
- *p_Ptr = &p_BmiRegs->fmbm_tbdc;
+ case (e_FM_PORT_COUNTERS_RX_BAD_FRAME):
+ *p_StatsType = E_FMAN_PORT_STATS_CNT_RX_BAD_FRAME;
break;
- default:
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter is not available for Tx ports"));
- }
-
- return E_OK;
-}
-
-static t_Error BmiOhPortCheckAndGetCounterPtr(t_FmPort *p_FmPort, e_FmPortCounters counter, volatile uint32_t **p_Ptr)
-{
- t_FmPortOhBmiRegs *p_BmiRegs = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs;
-
- /* check that counters are enabled */
- switch(counter)
- {
- case(e_FM_PORT_COUNTERS_CYCLE):
- case(e_FM_PORT_COUNTERS_TASK_UTIL):
- case(e_FM_PORT_COUNTERS_DMA_UTIL):
- case(e_FM_PORT_COUNTERS_FIFO_UTIL):
- /* performance counters - may be read when disabled */
- break;
- case(e_FM_PORT_COUNTERS_FRAME):
- case(e_FM_PORT_COUNTERS_DISCARD_FRAME):
- case(e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR):
- case(e_FM_PORT_COUNTERS_WRED_DISCARD):
- case(e_FM_PORT_COUNTERS_LENGTH_ERR):
- case(e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT):
- case(e_FM_PORT_COUNTERS_DEALLOC_BUF):
- if(!(GET_UINT32(p_BmiRegs->fmbm_ostc) & BMI_COUNTERS_EN))
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter was not enabled"));
- break;
- case(e_FM_PORT_COUNTERS_RX_FILTER_FRAME): /* only valid for offline parsing */
- if(p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter is not available for Host Command ports"));
- if(!(GET_UINT32(p_BmiRegs->fmbm_ostc) & BMI_COUNTERS_EN))
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter was not enabled"));
- break;
- default:
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter is not available for O/H ports"));
- }
-
- /* Set counter */
- switch(counter)
- {
- case(e_FM_PORT_COUNTERS_CYCLE):
- *p_Ptr = &p_BmiRegs->fmbm_occn;
+ case (e_FM_PORT_COUNTERS_RX_LARGE_FRAME):
+ *p_StatsType = E_FMAN_PORT_STATS_CNT_RX_LARGE_FRAME;
break;
- case(e_FM_PORT_COUNTERS_TASK_UTIL):
- *p_Ptr = &p_BmiRegs->fmbm_otuc;
+ case (e_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD):
+ *p_StatsType = E_FMAN_PORT_STATS_CNT_RX_OUT_OF_BUF;
break;
- case(e_FM_PORT_COUNTERS_DMA_UTIL):
- *p_Ptr = &p_BmiRegs->fmbm_oduc;
+ case (e_FM_PORT_COUNTERS_RX_FILTER_FRAME):
+ *p_StatsType = E_FMAN_PORT_STATS_CNT_FILTERED_FRAME;
break;
- case(e_FM_PORT_COUNTERS_FIFO_UTIL):
- *p_Ptr = &p_BmiRegs->fmbm_ofuc;
+ case (e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR):
+ *p_StatsType = E_FMAN_PORT_STATS_CNT_DMA_ERR;
break;
- case(e_FM_PORT_COUNTERS_FRAME):
- *p_Ptr = &p_BmiRegs->fmbm_ofrc;
+ case (e_FM_PORT_COUNTERS_WRED_DISCARD):
+ *p_StatsType = E_FMAN_PORT_STATS_CNT_WRED_DISCARD;
break;
- case(e_FM_PORT_COUNTERS_DISCARD_FRAME):
- *p_Ptr = &p_BmiRegs->fmbm_ofdc;
+ case (e_FM_PORT_COUNTERS_LENGTH_ERR):
+ *p_StatsType = E_FMAN_PORT_STATS_CNT_LEN_ERR;
break;
- case(e_FM_PORT_COUNTERS_RX_FILTER_FRAME):
- *p_Ptr = &p_BmiRegs->fmbm_offc;
- break;
- case(e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR):
-#ifdef FM_PORT_COUNTERS_ERRATA_FMANg
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("Requested counter is not available in rev1"));
- }
-#endif /* FM_PORT_COUNTERS_ERRATA_FMANg */
- *p_Ptr = &p_BmiRegs->fmbm_ofldec;
- break;
- case(e_FM_PORT_COUNTERS_WRED_DISCARD):
- *p_Ptr = &p_BmiRegs->fmbm_ofwdc;
- break;
- case(e_FM_PORT_COUNTERS_LENGTH_ERR):
- *p_Ptr = &p_BmiRegs->fmbm_ofledc;
- break;
- case(e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT):
- *p_Ptr = &p_BmiRegs->fmbm_ofufdc;
- break;
- case(e_FM_PORT_COUNTERS_DEALLOC_BUF):
- *p_Ptr = &p_BmiRegs->fmbm_obdc;
+ case (e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT):
+ *p_StatsType = E_FMAN_PORT_STATS_CNT_UNSUPPORTED_FORMAT;
break;
default:
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter is not available for O/H ports"));
+ break;
}
return E_OK;
}
-static t_Error AdditionalPrsParams(t_FmPort *p_FmPort, t_FmPcdPrsAdditionalHdrParams *p_HdrParams, uint32_t *p_SoftSeqAttachReg)
+static t_Error AdditionalPrsParams(t_FmPort *p_FmPort,
+ t_FmPcdPrsAdditionalHdrParams *p_HdrParams,
+ uint32_t *p_SoftSeqAttachReg)
{
- uint8_t hdrNum, Ipv4HdrNum;
- u_FmPcdHdrPrsOpts *p_prsOpts;
- uint32_t tmpReg = 0, tmpPrsOffset;
+ uint8_t hdrNum, Ipv4HdrNum;
+ u_FmPcdHdrPrsOpts *p_prsOpts;
+ uint32_t tmpReg = *p_SoftSeqAttachReg, tmpPrsOffset;
- if(IS_PRIVATE_HEADER(p_HdrParams->hdr) || IS_SPECIAL_HEADER(p_HdrParams->hdr))
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("No additional parameters for private or special headers."));
+ if (IS_PRIVATE_HEADER(p_HdrParams->hdr)
+ || IS_SPECIAL_HEADER(p_HdrParams->hdr))
+ RETURN_ERROR(
+ MAJOR, E_NOT_SUPPORTED,
+ ("No additional parameters for private or special headers."));
- if(p_HdrParams->errDisable)
+ if (p_HdrParams->errDisable)
tmpReg |= PRS_HDR_ERROR_DIS;
/* Set parser options */
- if(p_HdrParams->usePrsOpts)
+ if (p_HdrParams->usePrsOpts)
{
p_prsOpts = &p_HdrParams->prsOpts;
- switch(p_HdrParams->hdr)
+ switch (p_HdrParams->hdr)
{
- case(HEADER_TYPE_MPLS):
- if(p_prsOpts->mplsPrsOptions.labelInterpretationEnable)
+ case (HEADER_TYPE_MPLS):
+ if (p_prsOpts->mplsPrsOptions.labelInterpretationEnable)
tmpReg |= PRS_HDR_MPLS_LBL_INTER_EN;
- GET_PRS_HDR_NUM(hdrNum, p_prsOpts->mplsPrsOptions.nextParse);
- if(hdrNum == ILLEGAL_HDR_NUM)
+ hdrNum = GetPrsHdrNum(p_prsOpts->mplsPrsOptions.nextParse);
+ if (hdrNum == ILLEGAL_HDR_NUM)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
- GET_PRS_HDR_NUM(Ipv4HdrNum, HEADER_TYPE_IPv4);
- if(hdrNum < Ipv4HdrNum)
+ Ipv4HdrNum = GetPrsHdrNum(HEADER_TYPE_IPv4);
+ if (hdrNum < Ipv4HdrNum)
RETURN_ERROR(MAJOR, E_INVALID_VALUE,
- ("Header must be equal or higher than IPv4"));
- tmpReg |= ((uint32_t)hdrNum * PRS_HDR_ENTRY_SIZE) << PRS_HDR_MPLS_NEXT_HDR_SHIFT;
+ ("Header must be equal or higher than IPv4"));
+ tmpReg |= ((uint32_t)hdrNum * PRS_HDR_ENTRY_SIZE)
+ << PRS_HDR_MPLS_NEXT_HDR_SHIFT;
break;
- case(HEADER_TYPE_PPPoE):
- if(p_prsOpts->pppoePrsOptions.enableMTUCheck)
- {
-#ifdef FM_PPPOE_NO_MTU_CHECK
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Invalid parser option"));
- else
-#endif /* FM_PPPOE_NO_MTU_CHECK */
- tmpReg |= PRS_HDR_PPPOE_MTU_CHECK_EN;
- }
+ case (HEADER_TYPE_PPPoE):
+ if (p_prsOpts->pppoePrsOptions.enableMTUCheck)
+ tmpReg |= PRS_HDR_PPPOE_MTU_CHECK_EN;
break;
- case(HEADER_TYPE_IPv6):
- if(p_prsOpts->ipv6PrsOptions.routingHdrDisable)
- tmpReg |= PRS_HDR_IPV6_ROUTE_HDR_DIS;
+ case (HEADER_TYPE_IPv6):
+ if (p_prsOpts->ipv6PrsOptions.routingHdrEnable)
+ tmpReg |= PRS_HDR_IPV6_ROUTE_HDR_EN;
break;
- case(HEADER_TYPE_TCP):
- if(p_prsOpts->tcpPrsOptions.padIgnoreChecksum)
- tmpReg |= PRS_HDR_TCP_PAD_REMOVAL;
+ case (HEADER_TYPE_TCP):
+ if (p_prsOpts->tcpPrsOptions.padIgnoreChecksum)
+ tmpReg |= PRS_HDR_TCP_PAD_REMOVAL;
+ else
+ tmpReg &= ~PRS_HDR_TCP_PAD_REMOVAL;
break;
- case(HEADER_TYPE_UDP):
- if(p_prsOpts->udpPrsOptions.padIgnoreChecksum)
- tmpReg |= PRS_HDR_TCP_PAD_REMOVAL;
+ case (HEADER_TYPE_UDP):
+ if (p_prsOpts->udpPrsOptions.padIgnoreChecksum)
+ tmpReg |= PRS_HDR_UDP_PAD_REMOVAL;
+ else
+ tmpReg &= ~PRS_HDR_UDP_PAD_REMOVAL;
break;
default:
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid header"));
}
}
- /* set software parsing (address is devided in 2 since parser uses 2 byte access. */
- if(p_HdrParams->swPrsEnable)
+ /* set software parsing (address is divided in 2 since parser uses 2 byte access. */
+ if (p_HdrParams->swPrsEnable)
{
- tmpPrsOffset = FmPcdGetSwPrsOffset(p_FmPort->h_FmPcd, p_HdrParams->hdr, p_HdrParams->indexPerHdr);
- if(tmpPrsOffset == ILLEGAL_BASE)
- RETURN_ERROR(MINOR, E_INVALID_VALUE, NO_MSG);
+ tmpPrsOffset = FmPcdGetSwPrsOffset(p_FmPort->h_FmPcd, p_HdrParams->hdr,
+ p_HdrParams->indexPerHdr);
+ if (tmpPrsOffset == ILLEGAL_BASE)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
tmpReg |= (PRS_HDR_SW_PRS_EN | tmpPrsOffset);
}
*p_SoftSeqAttachReg = tmpReg;
@@ -1333,24 +1046,25 @@ static t_Error AdditionalPrsParams(t_FmPort *p_FmPort, t_FmPcdPrsAdditionalHdrP
return E_OK;
}
-static uint32_t GetPortSchemeBindParams(t_Handle h_FmPort, t_FmPcdKgInterModuleBindPortToSchemes *p_SchemeBind)
+static uint32_t GetPortSchemeBindParams(
+ t_Handle h_FmPort, t_FmPcdKgInterModuleBindPortToSchemes *p_SchemeBind)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- uint32_t walking1Mask = 0x80000000, tmp;
- uint8_t idx = 0;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ uint32_t walking1Mask = 0x80000000, tmp;
+ uint8_t idx = 0;
p_SchemeBind->netEnvId = p_FmPort->netEnvId;
p_SchemeBind->hardwarePortId = p_FmPort->hardwarePortId;
p_SchemeBind->useClsPlan = p_FmPort->useClsPlan;
p_SchemeBind->numOfSchemes = 0;
tmp = p_FmPort->schemesPerPortVector;
- if(tmp)
+ if (tmp)
{
while (tmp)
{
- if(tmp & walking1Mask)
+ if (tmp & walking1Mask)
{
- p_SchemeBind->schemesIds[p_SchemeBind->numOfSchemes] = FmPcdKgGetSchemeSwId(p_FmPort->h_FmPcd, idx);
+ p_SchemeBind->schemesIds[p_SchemeBind->numOfSchemes] = idx;
p_SchemeBind->numOfSchemes++;
tmp &= ~walking1Mask;
}
@@ -1362,400 +1076,357 @@ static uint32_t GetPortSchemeBindParams(t_Handle h_FmPort, t_FmPcdKgInterModuleB
return tmp;
}
-static t_Error BuildBufferStructure(t_FmPort *p_FmPort)
+static void FmPortCheckNApplyMacsec(t_Handle h_FmPort)
{
- uint32_t tmp;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ volatile uint32_t *p_BmiCfgReg = NULL;
+ uint32_t macsecEn = BMI_PORT_CFG_EN_MACSEC;
+ uint32_t lcv, walking1Mask = 0x80000000;
+ uint8_t cnt = 0;
ASSERT_COND(p_FmPort);
+ ASSERT_COND(p_FmPort->h_FmPcd);
+ ASSERT_COND(!p_FmPort->p_FmPortDriverParam);
- /* Align start of internal context data to 16 byte */
- p_FmPort->p_FmPortDriverParam->intContext.extBufOffset =
- (uint16_t)((p_FmPort->p_FmPortDriverParam->bufferPrefixContent.privDataSize & (OFFSET_UNITS-1)) ?
- ((p_FmPort->p_FmPortDriverParam->bufferPrefixContent.privDataSize + OFFSET_UNITS) & ~(uint16_t)(OFFSET_UNITS-1)) :
- p_FmPort->p_FmPortDriverParam->bufferPrefixContent.privDataSize);
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
+ return;
- /* Translate margin and intContext params to FM parameters */
-#ifdef FM_INCORRECT_CS_ERRATA_FMAN18
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- {
- uint8_t mod = p_FmPort->p_FmPortDriverParam->bufferPrefixContent.dataAlign % 256;
- if(mod)
- {
- p_FmPort->p_FmPortDriverParam->bufferPrefixContent.dataAlign += (256-mod);
- DBG(WARNING,("dataAlign modified to next 256 to conform with FMAN18 errata\n"));
- }
- }
- }
-#endif /* FM_INCORRECT_CS_ERRATA_FMAN18 */
-
- /* Initialize with illegal value. Later we'll set legal values. */
- p_FmPort->bufferOffsets.prsResultOffset = (uint32_t)ILLEGAL_BASE;
- p_FmPort->bufferOffsets.timeStampOffset = (uint32_t)ILLEGAL_BASE;
- p_FmPort->bufferOffsets.hashResultOffset= (uint32_t)ILLEGAL_BASE;
- p_FmPort->bufferOffsets.pcdInfoOffset = (uint32_t)ILLEGAL_BASE;
-#ifdef DEBUG
- p_FmPort->bufferOffsets.debugOffset = (uint32_t)ILLEGAL_BASE;
-#endif /* DEBUG */
-
- /* Internally the driver supports 4 options
- 1. prsResult/timestamp/hashResult selection (in fact 8 options, but for simplicity we'll
- relate to it as 1).
- 2. All IC context (from AD) except debug.
- 3. Debug information only.
- 4. All IC context (from AD) including debug.
- Note, that if user asks for prsResult/timestamp/hashResult and Debug, we give them (4) */
-
- /* This 'if' covers options 2 & 4. We copy from beginning of context with or without debug. */
- /* If passAllOtherPCDInfo explicitly requested, or passDebugInfo+prs/ts --> we also take passAllOtherPCDInfo */
- if ((p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passAllOtherPCDInfo)
-#ifdef DEBUG
- || (p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passDebugInfo &&
- (p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passPrsResult ||
- p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passTimeStamp ||
- p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passHashResult))
-#endif /* DEBUG */
- )
- {
-#ifdef DEBUG
- if(p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passDebugInfo)
- {
- p_FmPort->p_FmPortDriverParam->intContext.size = 240;
- p_FmPort->bufferOffsets.debugOffset =
- (uint32_t)(p_FmPort->p_FmPortDriverParam->intContext.extBufOffset + 128);
- }
- else
-#endif /* DEBUG */
- p_FmPort->p_FmPortDriverParam->intContext.size = 128; /* must be aligned to 16 */
- /* Start copying data after 16 bytes (FD) from the beginning of the internal context */
- p_FmPort->p_FmPortDriverParam->intContext.intContextOffset = 16;
-
- if (p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passAllOtherPCDInfo)
- p_FmPort->bufferOffsets.pcdInfoOffset = p_FmPort->p_FmPortDriverParam->intContext.extBufOffset;
- if (p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passPrsResult)
- p_FmPort->bufferOffsets.prsResultOffset =
- (uint32_t)(p_FmPort->p_FmPortDriverParam->intContext.extBufOffset + 16);
- if (p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passTimeStamp)
- p_FmPort->bufferOffsets.timeStampOffset =
- (uint32_t)(p_FmPort->p_FmPortDriverParam->intContext.extBufOffset + 48);
- if (p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passHashResult)
- p_FmPort->bufferOffsets.hashResultOffset =
- (uint32_t)(p_FmPort->p_FmPortDriverParam->intContext.extBufOffset + 56);
- }
- else
+ p_BmiCfgReg = &p_FmPort->port.bmi_regs->rx.fmbm_rcfg;
+ /* get LCV for MACSEC */
+ if ((lcv = FmPcdGetMacsecLcv(p_FmPort->h_FmPcd, p_FmPort->netEnvId))
+ != 0)
{
-#ifdef DEBUG
- if (p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passDebugInfo)
- {
- /* This case covers option 3 */
- p_FmPort->p_FmPortDriverParam->intContext.size = 112;
- p_FmPort->p_FmPortDriverParam->intContext.intContextOffset = 144;
- p_FmPort->bufferOffsets.debugOffset = p_FmPort->p_FmPortDriverParam->intContext.extBufOffset;
- }
- else
-#endif /* DEBUG */
+ while (!(lcv & walking1Mask))
{
- /* This case covers the options under 1 */
- /* Copy size must be in 16-byte granularity. */
- p_FmPort->p_FmPortDriverParam->intContext.size =
- (uint16_t)((p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passPrsResult ? 32 : 0) +
- ((p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passTimeStamp ||
- p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passHashResult) ? 16 : 0));
-
- /* Align start of internal context data to 16 byte */
- p_FmPort->p_FmPortDriverParam->intContext.intContextOffset =
- (uint8_t)(p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passPrsResult ? 32 :
- ((p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passTimeStamp ||
- p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passHashResult) ? 64 : 0));
-
- if(p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passPrsResult)
- p_FmPort->bufferOffsets.prsResultOffset = p_FmPort->p_FmPortDriverParam->intContext.extBufOffset;
- if(p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passTimeStamp)
- p_FmPort->bufferOffsets.timeStampOffset = p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passPrsResult ?
- (p_FmPort->p_FmPortDriverParam->intContext.extBufOffset + sizeof(t_FmPrsResult)) :
- p_FmPort->p_FmPortDriverParam->intContext.extBufOffset;
- if(p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passHashResult)
- /* If PR is not requested, whether TS is requested or not, IC will be copied from TS */
- p_FmPort->bufferOffsets.hashResultOffset = p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passPrsResult ?
- (p_FmPort->p_FmPortDriverParam->intContext.extBufOffset + sizeof(t_FmPrsResult) + 8) :
- p_FmPort->p_FmPortDriverParam->intContext.extBufOffset + 8;
+ cnt++;
+ walking1Mask >>= 1;
}
- }
- p_FmPort->p_FmPortDriverParam->bufMargins.startMargins =
- (uint16_t)(p_FmPort->p_FmPortDriverParam->intContext.extBufOffset +
- p_FmPort->p_FmPortDriverParam->intContext.size);
-#ifdef FM_CAPWAP_SUPPORT
- /* save extra space for manip in both external and internal buffers */
- if(p_FmPort->p_FmPortDriverParam->bufferPrefixContent.manipExtraSpace)
- {
- if((p_FmPort->p_FmPortDriverParam->bufferPrefixContent.manipExtraSpace + FRAG_EXTRA_SPACE) >= 256)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("p_FmPort->p_FmPortDriverParam->bufferPrefixContent.manipExtraSpace + 32 can not be equal or larger to 256"));
- p_FmPort->bufferOffsets.manipOffset = p_FmPort->p_FmPortDriverParam->bufMargins.startMargins;
- p_FmPort->p_FmPortDriverParam->bufMargins.startMargins += (p_FmPort->p_FmPortDriverParam->bufferPrefixContent.manipExtraSpace + FRAG_EXTRA_SPACE);
- p_FmPort->p_FmPortDriverParam->internalBufferOffset =
- (uint8_t)(p_FmPort->p_FmPortDriverParam->bufferPrefixContent.manipExtraSpace + FRAG_EXTRA_SPACE);
+ macsecEn |= (uint32_t)cnt << BMI_PORT_CFG_MS_SEL_SHIFT;
+ WRITE_UINT32(*p_BmiCfgReg, GET_UINT32(*p_BmiCfgReg) | macsecEn);
}
-#endif /* FM_CAPWAP_SUPPORT */
-
- /* align data start */
- tmp = (uint32_t)(p_FmPort->p_FmPortDriverParam->bufMargins.startMargins %
- p_FmPort->p_FmPortDriverParam->bufferPrefixContent.dataAlign);
- if (tmp)
- p_FmPort->p_FmPortDriverParam->bufMargins.startMargins += (p_FmPort->p_FmPortDriverParam->bufferPrefixContent.dataAlign-tmp);
- p_FmPort->bufferOffsets.dataOffset = p_FmPort->p_FmPortDriverParam->bufMargins.startMargins;
- p_FmPort->internalBufferOffset = p_FmPort->p_FmPortDriverParam->internalBufferOffset;
-
- return E_OK;
}
-static t_Error SetPcd(t_Handle h_FmPort, t_FmPortPcdParams *p_PcdParams)
+static t_Error SetPcd(t_FmPort *p_FmPort, t_FmPortPcdParams *p_PcdParams)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- t_Error err = E_OK;
- uint32_t tmpReg;
- volatile uint32_t *p_BmiNia=NULL;
- volatile uint32_t *p_BmiPrsNia=NULL;
- volatile uint32_t *p_BmiPrsStartOffset=NULL;
- volatile uint32_t *p_BmiInitPrsResult=NULL;
- volatile uint32_t *p_BmiCcBase=NULL;
- uint8_t hdrNum, L3HdrNum, greHdrNum;
- int i;
- bool isEmptyClsPlanGrp;
- uint32_t tmpHxs[FM_PCD_PRS_NUM_OF_HDRS];
- uint16_t absoluteProfileId;
- uint8_t physicalSchemeId;
- uint32_t ccTreePhysOffset;
- SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
+ t_Error err = E_OK;
+ uint32_t tmpReg;
+ volatile uint32_t *p_BmiNia = NULL;
+ volatile uint32_t *p_BmiPrsNia = NULL;
+ volatile uint32_t *p_BmiPrsStartOffset = NULL;
+ volatile uint32_t *p_BmiInitPrsResult = NULL;
+ volatile uint32_t *p_BmiCcBase = NULL;
+ uint16_t hdrNum, L3HdrNum, greHdrNum;
+ int i;
+ bool isEmptyClsPlanGrp;
+ uint32_t tmpHxs[FM_PCD_PRS_NUM_OF_HDRS];
+ uint16_t absoluteProfileId;
+ uint8_t physicalSchemeId;
+ uint32_t ccTreePhysOffset;
+ t_FmPcdKgInterModuleBindPortToSchemes schemeBind;
+ uint32_t initialSwPrs = 0;
+
+ ASSERT_COND(p_FmPort);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
if (p_FmPort->imEn)
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for non-independant mode ports only"));
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for non-independant mode ports only"));
- if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) &&
- (p_FmPort->portType != e_FM_PORT_TYPE_RX) &&
- (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx and offline parsing ports only"));
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for Rx and offline parsing ports only"));
- p_FmPort->netEnvId = (uint8_t)(PTR_TO_UINT(p_PcdParams->h_NetEnv)-1);
+ p_FmPort->netEnvId = FmPcdGetNetEnvId(p_PcdParams->h_NetEnv);
p_FmPort->pcdEngines = 0;
/* initialize p_FmPort->pcdEngines field in port's structure */
- switch(p_PcdParams->pcdSupport)
- {
- case(e_FM_PORT_PCD_SUPPORT_NONE):
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("No PCD configuration required if e_FM_PORT_PCD_SUPPORT_NONE selected"));
- case(e_FM_PORT_PCD_SUPPORT_PRS_ONLY):
+ switch (p_PcdParams->pcdSupport)
+ {
+ case (e_FM_PORT_PCD_SUPPORT_NONE):
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("No PCD configuration required if e_FM_PORT_PCD_SUPPORT_NONE selected"));
+ case (e_FM_PORT_PCD_SUPPORT_PRS_ONLY):
p_FmPort->pcdEngines |= FM_PCD_PRS;
break;
- case(e_FM_PORT_PCD_SUPPORT_PLCR_ONLY):
- if (CHECK_FM_CTL_AC_POST_FETCH_PCD(p_FmPort->savedBmiNia))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("parser support is required"));
+ case (e_FM_PORT_PCD_SUPPORT_PLCR_ONLY):
p_FmPort->pcdEngines |= FM_PCD_PLCR;
break;
- case(e_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR):
+ case (e_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR):
p_FmPort->pcdEngines |= FM_PCD_PRS;
p_FmPort->pcdEngines |= FM_PCD_PLCR;
break;
- case(e_FM_PORT_PCD_SUPPORT_PRS_AND_KG):
+ case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG):
p_FmPort->pcdEngines |= FM_PCD_PRS;
p_FmPort->pcdEngines |= FM_PCD_KG;
break;
- case(e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC):
+ case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC):
p_FmPort->pcdEngines |= FM_PCD_PRS;
p_FmPort->pcdEngines |= FM_PCD_CC;
p_FmPort->pcdEngines |= FM_PCD_KG;
break;
- case(e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC_AND_PLCR):
+ case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC_AND_PLCR):
p_FmPort->pcdEngines |= FM_PCD_PRS;
p_FmPort->pcdEngines |= FM_PCD_KG;
p_FmPort->pcdEngines |= FM_PCD_CC;
p_FmPort->pcdEngines |= FM_PCD_PLCR;
break;
- case(e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR):
+ case (e_FM_PORT_PCD_SUPPORT_PRS_AND_CC):
+ p_FmPort->pcdEngines |= FM_PCD_PRS;
+ p_FmPort->pcdEngines |= FM_PCD_CC;
+ break;
+ case (e_FM_PORT_PCD_SUPPORT_PRS_AND_CC_AND_PLCR):
+ p_FmPort->pcdEngines |= FM_PCD_PRS;
+ p_FmPort->pcdEngines |= FM_PCD_CC;
+ p_FmPort->pcdEngines |= FM_PCD_PLCR;
+ break;
+ case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR):
p_FmPort->pcdEngines |= FM_PCD_PRS;
p_FmPort->pcdEngines |= FM_PCD_KG;
p_FmPort->pcdEngines |= FM_PCD_PLCR;
break;
-
-#ifdef FM_CAPWAP_SUPPORT
- case(e_FM_PORT_PCD_SUPPORT_CC_ONLY):
- if (CHECK_FM_CTL_AC_POST_FETCH_PCD(p_FmPort->savedBmiNia))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("parser support is required"));
+ case (e_FM_PORT_PCD_SUPPORT_CC_ONLY):
p_FmPort->pcdEngines |= FM_PCD_CC;
break;
- case(e_FM_PORT_PCD_SUPPORT_CC_AND_KG):
- if (CHECK_FM_CTL_AC_POST_FETCH_PCD(p_FmPort->savedBmiNia))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("parser support is required"));
+#ifdef FM_CAPWAP_SUPPORT
+ case (e_FM_PORT_PCD_SUPPORT_CC_AND_KG):
p_FmPort->pcdEngines |= FM_PCD_CC;
p_FmPort->pcdEngines |= FM_PCD_KG;
break;
- case(e_FM_PORT_PCD_SUPPORT_CC_AND_KG_AND_PLCR):
- if (CHECK_FM_CTL_AC_POST_FETCH_PCD(p_FmPort->savedBmiNia))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("parser support is required"));
+ case (e_FM_PORT_PCD_SUPPORT_CC_AND_KG_AND_PLCR):
p_FmPort->pcdEngines |= FM_PCD_CC;
p_FmPort->pcdEngines |= FM_PCD_KG;
p_FmPort->pcdEngines |= FM_PCD_PLCR;
break;
#endif /* FM_CAPWAP_SUPPORT */
+
default:
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("invalid pcdSupport"));
}
- if((p_FmPort->pcdEngines & FM_PCD_PRS) && (p_PcdParams->p_PrsParams->numOfHdrsWithAdditionalParams > FM_PCD_PRS_NUM_OF_HDRS))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Port parser numOfHdrsWithAdditionalParams may not exceed %d", FM_PCD_PRS_NUM_OF_HDRS));
+ if ((p_FmPort->pcdEngines & FM_PCD_PRS)
+ && (p_PcdParams->p_PrsParams->numOfHdrsWithAdditionalParams
+ > FM_PCD_PRS_NUM_OF_HDRS))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("Port parser numOfHdrsWithAdditionalParams may not exceed %d", FM_PCD_PRS_NUM_OF_HDRS));
/* check that parameters exist for each and only each defined engine */
- if((!!(p_FmPort->pcdEngines & FM_PCD_PRS) != !!p_PcdParams->p_PrsParams) ||
- (!!(p_FmPort->pcdEngines & FM_PCD_KG) != !!p_PcdParams->p_KgParams) ||
- (!!(p_FmPort->pcdEngines & FM_PCD_CC) != !!p_PcdParams->p_CcParams))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("PCD initialization structure is not consistant with pcdSupport"));
+ if ((!!(p_FmPort->pcdEngines & FM_PCD_PRS) != !!p_PcdParams->p_PrsParams)
+ || (!!(p_FmPort->pcdEngines & FM_PCD_KG)
+ != !!p_PcdParams->p_KgParams)
+ || (!!(p_FmPort->pcdEngines & FM_PCD_CC)
+ != !!p_PcdParams->p_CcParams))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("PCD initialization structure is not consistent with pcdSupport"));
/* get PCD registers pointers */
- switch(p_FmPort->portType)
- {
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- p_BmiNia = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfne;
- p_BmiPrsNia = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfpne;
- p_BmiPrsStartOffset = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rpso;
- p_BmiInitPrsResult = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rprai[0];
- p_BmiCcBase = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rccb;
+ switch (p_FmPort->portType)
+ {
+ case (e_FM_PORT_TYPE_RX_10G):
+ case (e_FM_PORT_TYPE_RX):
+ p_BmiNia = &p_FmPort->port.bmi_regs->rx.fmbm_rfne;
+ p_BmiPrsNia = &p_FmPort->port.bmi_regs->rx.fmbm_rfpne;
+ p_BmiPrsStartOffset = &p_FmPort->port.bmi_regs->rx.fmbm_rpso;
+ p_BmiInitPrsResult = &p_FmPort->port.bmi_regs->rx.fmbm_rprai[0];
+ p_BmiCcBase = &p_FmPort->port.bmi_regs->rx.fmbm_rccb;
break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- p_BmiNia = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofne;
- p_BmiPrsNia = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofpne;
- p_BmiPrsStartOffset = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_opso;
- p_BmiInitPrsResult = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_oprai[0];
- p_BmiCcBase = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_occb;
+ case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
+ p_BmiNia = &p_FmPort->port.bmi_regs->oh.fmbm_ofne;
+ p_BmiPrsNia = &p_FmPort->port.bmi_regs->oh.fmbm_ofpne;
+ p_BmiPrsStartOffset = &p_FmPort->port.bmi_regs->oh.fmbm_opso;
+ p_BmiInitPrsResult = &p_FmPort->port.bmi_regs->oh.fmbm_oprai[0];
+ p_BmiCcBase = &p_FmPort->port.bmi_regs->oh.fmbm_occb;
break;
default:
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
}
- if(p_FmPort->pcdEngines & FM_PCD_KG)
+ /* set PCD port parameter */
+ if (p_FmPort->pcdEngines & FM_PCD_CC)
{
+ err = FmPcdCcBindTree(p_FmPort->h_FmPcd, p_PcdParams,
+ p_PcdParams->p_CcParams->h_CcTree,
+ &ccTreePhysOffset, p_FmPort);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
- if(p_PcdParams->p_KgParams->numOfSchemes == 0)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("For ports using Keygen, at lease one scheme must be bound. "));
- /* for each scheme */
- for(i = 0; i<p_PcdParams->p_KgParams->numOfSchemes; i++)
- {
- physicalSchemeId = (uint8_t)(PTR_TO_UINT(p_PcdParams->p_KgParams->h_Schemes[i])-1);
- /* build vector */
- p_FmPort->schemesPerPortVector |= 1 << (31 - (uint32_t)physicalSchemeId);
- }
+ WRITE_UINT32(*p_BmiCcBase, ccTreePhysOffset);
+ p_FmPort->ccTreeId = p_PcdParams->p_CcParams->h_CcTree;
+ }
+
+ if (p_FmPort->pcdEngines & FM_PCD_KG)
+ {
+ if (p_PcdParams->p_KgParams->numOfSchemes == 0)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("For ports using Keygen, at least one scheme must be bound. "));
err = FmPcdKgSetOrBindToClsPlanGrp(p_FmPort->h_FmPcd,
- p_FmPort->hardwarePortId,
- p_FmPort->netEnvId,
- p_FmPort->optArray,
- &p_FmPort->clsPlanGrpId,
- &isEmptyClsPlanGrp);
- if(err)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("FmPcdKgSetOrBindToClsPlanGrp failed. "));
+ p_FmPort->hardwarePortId,
+ p_FmPort->netEnvId,
+ p_FmPort->optArray,
+ &p_FmPort->clsPlanGrpId,
+ &isEmptyClsPlanGrp);
+ if (err)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("FmPcdKgSetOrBindToClsPlanGrp failed. "));
- p_FmPort->useClsPlan = !isEmptyClsPlanGrp;
- }
+ p_FmPort->useClsPlan = !isEmptyClsPlanGrp;
- /* set PCD port parameter */
- if(p_FmPort->pcdEngines & FM_PCD_CC)
- {
- err = FmPcdCcBindTree(p_FmPort->h_FmPcd, p_PcdParams->p_CcParams->h_CcTree, &ccTreePhysOffset, h_FmPort);
- if(err)
- RETURN_ERROR(MINOR, err, NO_MSG);
+ schemeBind.netEnvId = p_FmPort->netEnvId;
+ schemeBind.hardwarePortId = p_FmPort->hardwarePortId;
+ schemeBind.numOfSchemes = p_PcdParams->p_KgParams->numOfSchemes;
+ schemeBind.useClsPlan = p_FmPort->useClsPlan;
- WRITE_UINT32(*p_BmiCcBase, ccTreePhysOffset);
- p_FmPort->ccTreeId = p_PcdParams->p_CcParams->h_CcTree;
+ /* for each scheme */
+ for (i = 0; i < p_PcdParams->p_KgParams->numOfSchemes; i++)
+ {
+ ASSERT_COND(p_PcdParams->p_KgParams->h_Schemes[i]);
+ physicalSchemeId = FmPcdKgGetSchemeId(
+ p_PcdParams->p_KgParams->h_Schemes[i]);
+ schemeBind.schemesIds[i] = physicalSchemeId;
+ /* build vector */
+ p_FmPort->schemesPerPortVector |= 1
+ << (31 - (uint32_t)physicalSchemeId);
+#if (DPAA_VERSION >= 11)
+ /*because of the state that VSPE is defined per port - all PCD path should be according to this requirement
+ if !VSPE - in port, for relevant scheme VSPE can not be set*/
+ if (!p_FmPort->vspe
+ && FmPcdKgGetVspe((p_PcdParams->p_KgParams->h_Schemes[i])))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("VSPE is not at port level"));
+#endif /* (DPAA_VERSION >= 11) */
+ }
+
+ err = FmPcdKgBindPortToSchemes(p_FmPort->h_FmPcd, &schemeBind);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
/***************************/
/* configure NIA after BMI */
/***************************/
- if (!CHECK_FM_CTL_AC_POST_FETCH_PCD(p_FmPort->savedBmiNia))
- /* rfne may contain FDCS bits, so first we read them. */
- p_FmPort->savedBmiNia = GET_UINT32(*p_BmiNia) & BMI_RFNE_FDCS_MASK;
+ /* rfne may contain FDCS bits, so first we read them. */
+ p_FmPort->savedBmiNia = GET_UINT32(*p_BmiNia) & BMI_RFNE_FDCS_MASK;
/* If policer is used directly after BMI or PRS */
- if((p_FmPort->pcdEngines & FM_PCD_PLCR) &&
- ((p_PcdParams->pcdSupport == e_FM_PORT_PCD_SUPPORT_PLCR_ONLY) ||
- (p_PcdParams->pcdSupport == e_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR)))
+ if ((p_FmPort->pcdEngines & FM_PCD_PLCR)
+ && ((p_PcdParams->pcdSupport == e_FM_PORT_PCD_SUPPORT_PLCR_ONLY)
+ || (p_PcdParams->pcdSupport
+ == e_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR)))
{
- absoluteProfileId = (uint16_t)(PTR_TO_UINT(p_PcdParams->p_PlcrParams->h_Profile)-1);
+ if (!p_PcdParams->p_PlcrParams->h_Profile)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("Profile should be initialized"));
+
+ absoluteProfileId = (uint16_t)FmPcdPlcrProfileGetAbsoluteId(
+ p_PcdParams->p_PlcrParams->h_Profile);
- if(!FmPcdPlcrIsProfileValid(p_FmPort->h_FmPcd, absoluteProfileId))
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Private port profile not valid."));
+ if (!FmPcdPlcrIsProfileValid(p_FmPort->h_FmPcd, absoluteProfileId))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("Private port profile not valid."));
tmpReg = (uint32_t)(absoluteProfileId | NIA_PLCR_ABSOLUTE);
- if(p_FmPort->pcdEngines & FM_PCD_PRS) /* e_FM_PCD_SUPPORT_PRS_AND_PLCR */
- {
+ if (p_FmPort->pcdEngines & FM_PCD_PRS) /* e_FM_PCD_SUPPORT_PRS_AND_PLCR */
/* update BMI HPNIA */
WRITE_UINT32(*p_BmiPrsNia, (uint32_t)(NIA_ENG_PLCR | tmpReg));
- }
- else /* e_FM_PCD_SUPPORT_PLCR_ONLY */
+ else
+ /* e_FM_PCD_SUPPORT_PLCR_ONLY */
/* update BMI NIA */
p_FmPort->savedBmiNia |= (uint32_t)(NIA_ENG_PLCR);
}
-#ifdef FM_CAPWAP_SUPPORT
/* if CC is used directly after BMI */
- if((p_PcdParams->pcdSupport == e_FM_PORT_PCD_SUPPORT_CC_ONLY) ||
- (p_PcdParams->pcdSupport == e_FM_PORT_PCD_SUPPORT_CC_AND_KG) ||
- (p_PcdParams->pcdSupport == e_FM_PORT_PCD_SUPPORT_CC_AND_KG_AND_PLCR))
+ if ((p_PcdParams->pcdSupport == e_FM_PORT_PCD_SUPPORT_CC_ONLY)
+#ifdef FM_CAPWAP_SUPPORT
+ || (p_PcdParams->pcdSupport == e_FM_PORT_PCD_SUPPORT_CC_AND_KG)
+ || (p_PcdParams->pcdSupport == e_FM_PORT_PCD_SUPPORT_CC_AND_KG_AND_PLCR)
+#endif /* FM_CAPWAP_SUPPORT */
+ )
{
if (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("e_FM_PORT_PCD_SUPPORT_CC_xx available for offline parsing ports only"));
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_OPERATION,
+ ("e_FM_PORT_PCD_SUPPORT_CC_xx available for offline parsing ports only"));
p_FmPort->savedBmiNia |= (uint32_t)(NIA_ENG_FM_CTL | NIA_FM_CTL_AC_CC);
- /* check that prs start offset == RIM[FOF] */
+ /* check that prs start offset == RIM[FOF] */
}
-#endif /* FM_CAPWAP_SUPPORT */
if (p_FmPort->pcdEngines & FM_PCD_PRS)
{
ASSERT_COND(p_PcdParams->p_PrsParams);
- /* if PRS is used it is always first */
- GET_PRS_HDR_NUM(hdrNum, p_PcdParams->p_PrsParams->firstPrsHdr);
- if (hdrNum == ILLEGAL_HDR_NUM)
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Unsupported header."));
- if (!CHECK_FM_CTL_AC_POST_FETCH_PCD(p_FmPort->savedBmiNia))
- p_FmPort->savedBmiNia |= (uint32_t)(NIA_ENG_PRS | (uint32_t)(hdrNum));
+#if (DPAA_VERSION >= 11)
+ if (p_PcdParams->p_PrsParams->firstPrsHdr == HEADER_TYPE_CAPWAP)
+ hdrNum = OFFLOAD_SW_PATCH_CAPWAP_LABEL;
+ else
+ {
+#endif /* (DPAA_VERSION >= 11) */
+ /* if PRS is used it is always first */
+ hdrNum = GetPrsHdrNum(p_PcdParams->p_PrsParams->firstPrsHdr);
+ if (hdrNum == ILLEGAL_HDR_NUM)
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Unsupported header."));
+#if (DPAA_VERSION >= 11)
+ }
+#endif /* (DPAA_VERSION >= 11) */
+ p_FmPort->savedBmiNia |= (uint32_t)(NIA_ENG_PRS | (uint32_t)(hdrNum));
/* set after parser NIA */
tmpReg = 0;
- switch(p_PcdParams->pcdSupport)
+ switch (p_PcdParams->pcdSupport)
{
- case(e_FM_PORT_PCD_SUPPORT_PRS_ONLY):
- WRITE_UINT32(*p_BmiPrsNia, NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME);
+ case (e_FM_PORT_PCD_SUPPORT_PRS_ONLY):
+ WRITE_UINT32(*p_BmiPrsNia,
+ GET_NIA_BMI_AC_ENQ_FRAME(p_FmPort->h_FmPcd));
break;
- case(e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC):
- case(e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC_AND_PLCR):
+ case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC):
+ case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC_AND_PLCR):
tmpReg = NIA_KG_CC_EN;
- case(e_FM_PORT_PCD_SUPPORT_PRS_AND_KG):
- case(e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR):
- if(p_PcdParams->p_KgParams->directScheme)
+ case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG):
+ case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR):
+ if (p_PcdParams->p_KgParams->directScheme)
{
- physicalSchemeId = (uint8_t)(PTR_TO_UINT(p_PcdParams->p_KgParams->h_DirectScheme)-1);
+ physicalSchemeId = FmPcdKgGetSchemeId(
+ p_PcdParams->p_KgParams->h_DirectScheme);
/* check that this scheme was bound to this port */
- for(i=0 ; i<p_PcdParams->p_KgParams->numOfSchemes; i++)
- if(p_PcdParams->p_KgParams->h_DirectScheme == p_PcdParams->p_KgParams->h_Schemes[i])
+ for (i = 0; i < p_PcdParams->p_KgParams->numOfSchemes; i++)
+ if (p_PcdParams->p_KgParams->h_DirectScheme
+ == p_PcdParams->p_KgParams->h_Schemes[i])
break;
- if(i == p_PcdParams->p_KgParams->numOfSchemes)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Direct scheme is not one of the port selected schemes."));
+ if (i == p_PcdParams->p_KgParams->numOfSchemes)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("Direct scheme is not one of the port selected schemes."));
tmpReg |= (uint32_t)(NIA_KG_DIRECT | physicalSchemeId);
}
WRITE_UINT32(*p_BmiPrsNia, NIA_ENG_KG | tmpReg);
break;
- case(e_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR):
+ case (e_FM_PORT_PCD_SUPPORT_PRS_AND_CC):
+ case (e_FM_PORT_PCD_SUPPORT_PRS_AND_CC_AND_PLCR):
+ WRITE_UINT32(*p_BmiPrsNia,
+ (uint32_t)(NIA_ENG_FM_CTL | NIA_FM_CTL_AC_CC));
+ break;
+ case (e_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR):
break;
default:
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid PCD support"));
}
/* set start parsing offset */
- /* WRITE_UINT32(*p_BmiPrsStartOffset, p_PcdParams->p_PrsParams->parsingOffset); */
+ WRITE_UINT32(*p_BmiPrsStartOffset,
+ p_PcdParams->p_PrsParams->parsingOffset);
/************************************/
/* Parser port parameters */
@@ -1763,227 +1434,322 @@ static t_Error SetPcd(t_Handle h_FmPort, t_FmPortPcdParams *p_PcdParams)
/* stop before configuring */
WRITE_UINT32(p_FmPort->p_FmPortPrsRegs->pcac, PRS_CAC_STOP);
/* wait for parser to be in idle state */
- while(GET_UINT32(p_FmPort->p_FmPortPrsRegs->pcac) & PRS_CAC_ACTIVE) ;
+ while (GET_UINT32(p_FmPort->p_FmPortPrsRegs->pcac) & PRS_CAC_ACTIVE)
+ ;
/* set soft seq attachment register */
- memset(tmpHxs, 0, FM_PCD_PRS_NUM_OF_HDRS*sizeof(uint32_t));
+ memset(tmpHxs, 0, FM_PCD_PRS_NUM_OF_HDRS * sizeof(uint32_t));
/* set protocol options */
- for(i=0;p_FmPort->optArray[i];i++)
- switch(p_FmPort->optArray[i])
+ for (i = 0; p_FmPort->optArray[i]; i++)
+ switch (p_FmPort->optArray[i])
{
- case(ETH_BROADCAST):
- GET_PRS_HDR_NUM(hdrNum, HEADER_TYPE_ETH)
- tmpHxs[hdrNum] |= (i+1) << PRS_HDR_ETH_BC_SHIFT;
+ case (ETH_BROADCAST):
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_ETH);
+ tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_ETH_BC_SHIFT;
break;
- case(ETH_MULTICAST):
- GET_PRS_HDR_NUM(hdrNum, HEADER_TYPE_ETH)
- tmpHxs[hdrNum] |= (i+1) << PRS_HDR_ETH_MC_SHIFT;
+ case (ETH_MULTICAST):
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_ETH);
+ tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_ETH_MC_SHIFT;
break;
- case(VLAN_STACKED):
- GET_PRS_HDR_NUM(hdrNum, HEADER_TYPE_VLAN)
- tmpHxs[hdrNum] |= (i+1)<< PRS_HDR_VLAN_STACKED_SHIFT;
+ case (VLAN_STACKED):
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_VLAN);
+ tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_VLAN_STACKED_SHIFT;
break;
- case(MPLS_STACKED):
- GET_PRS_HDR_NUM(hdrNum, HEADER_TYPE_MPLS)
- tmpHxs[hdrNum] |= (i+1) << PRS_HDR_MPLS_STACKED_SHIFT;
+ case (MPLS_STACKED):
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_MPLS);
+ tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_MPLS_STACKED_SHIFT;
break;
- case(IPV4_BROADCAST_1):
- GET_PRS_HDR_NUM(hdrNum, HEADER_TYPE_IPv4)
- tmpHxs[hdrNum] |= (i+1) << PRS_HDR_IPV4_1_BC_SHIFT;
+ case (IPV4_BROADCAST_1):
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv4);
+ tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_IPV4_1_BC_SHIFT;
break;
- case(IPV4_MULTICAST_1):
- GET_PRS_HDR_NUM(hdrNum, HEADER_TYPE_IPv4)
- tmpHxs[hdrNum] |= (i+1) << PRS_HDR_IPV4_1_MC_SHIFT;
+ case (IPV4_MULTICAST_1):
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv4);
+ tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_IPV4_1_MC_SHIFT;
break;
- case(IPV4_UNICAST_2):
- GET_PRS_HDR_NUM(hdrNum, HEADER_TYPE_IPv4)
- tmpHxs[hdrNum] |= (i+1) << PRS_HDR_IPV4_2_UC_SHIFT;
+ case (IPV4_UNICAST_2):
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv4);
+ tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_IPV4_2_UC_SHIFT;
break;
- case(IPV4_MULTICAST_BROADCAST_2):
- GET_PRS_HDR_NUM(hdrNum, HEADER_TYPE_IPv4)
- tmpHxs[hdrNum] |= (i+1) << PRS_HDR_IPV4_2_MC_BC_SHIFT;
+ case (IPV4_MULTICAST_BROADCAST_2):
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv4);
+ tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_IPV4_2_MC_BC_SHIFT;
break;
- case(IPV6_MULTICAST_1):
- GET_PRS_HDR_NUM(hdrNum, HEADER_TYPE_IPv6)
- tmpHxs[hdrNum] |= (i+1) << PRS_HDR_IPV6_1_MC_SHIFT;
+ case (IPV6_MULTICAST_1):
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv6);
+ tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_IPV6_1_MC_SHIFT;
break;
- case(IPV6_UNICAST_2):
- GET_PRS_HDR_NUM(hdrNum, HEADER_TYPE_IPv6)
- tmpHxs[hdrNum] |= (i+1) << PRS_HDR_IPV6_2_UC_SHIFT;
+ case (IPV6_UNICAST_2):
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv6);
+ tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_IPV6_2_UC_SHIFT;
break;
- case(IPV6_MULTICAST_2):
- GET_PRS_HDR_NUM(hdrNum, HEADER_TYPE_IPv6)
- tmpHxs[hdrNum] |= (i+1) << PRS_HDR_IPV6_2_MC_SHIFT;
+ case (IPV6_MULTICAST_2):
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv6);
+ tmpHxs[hdrNum] |= (i + 1) << PRS_HDR_IPV6_2_MC_SHIFT;
break;
}
- if (FmPcdNetEnvIsHdrExist(p_FmPort->h_FmPcd, p_FmPort->netEnvId, HEADER_TYPE_UDP_ENCAP_ESP))
+ if (FmPcdNetEnvIsHdrExist(p_FmPort->h_FmPcd, p_FmPort->netEnvId,
+ HEADER_TYPE_UDP_ENCAP_ESP))
{
- p_PcdParams->p_PrsParams->additionalParams
- [p_PcdParams->p_PrsParams->numOfHdrsWithAdditionalParams].hdr = HEADER_TYPE_UDP;
- p_PcdParams->p_PrsParams->additionalParams
- [p_PcdParams->p_PrsParams->numOfHdrsWithAdditionalParams].swPrsEnable = TRUE;
+ if (p_PcdParams->p_PrsParams->numOfHdrsWithAdditionalParams == FM_PCD_PRS_NUM_OF_HDRS)
+ RETURN_ERROR(
+ MINOR, E_INVALID_VALUE,
+ ("If HEADER_TYPE_UDP_ENCAP_ESP is used, numOfHdrsWithAdditionalParams may be up to FM_PCD_PRS_NUM_OF_HDRS - 1"));
+
+ p_PcdParams->p_PrsParams->additionalParams[p_PcdParams->p_PrsParams->numOfHdrsWithAdditionalParams].hdr =
+ HEADER_TYPE_UDP;
+ p_PcdParams->p_PrsParams->additionalParams[p_PcdParams->p_PrsParams->numOfHdrsWithAdditionalParams].swPrsEnable =
+ TRUE;
p_PcdParams->p_PrsParams->numOfHdrsWithAdditionalParams++;
}
/* set MPLS default next header - HW reset workaround */
- GET_PRS_HDR_NUM(hdrNum, HEADER_TYPE_MPLS)
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_MPLS);
tmpHxs[hdrNum] |= PRS_HDR_MPLS_LBL_INTER_EN;
- GET_PRS_HDR_NUM(L3HdrNum, HEADER_TYPE_USER_DEFINED_L3);
- tmpHxs[hdrNum] |= (uint32_t)L3HdrNum << PRS_HDR_MPLS_NEXT_HDR_SHIFT;
+ L3HdrNum = GetPrsHdrNum(HEADER_TYPE_USER_DEFINED_L3);
+ tmpHxs[hdrNum] |= (uint32_t)L3HdrNum << PRS_HDR_MPLS_NEXT_HDR_SHIFT;
/* for GRE, disable errors */
- GET_PRS_HDR_NUM(greHdrNum, HEADER_TYPE_GRE);
+ greHdrNum = GetPrsHdrNum(HEADER_TYPE_GRE);
tmpHxs[greHdrNum] |= PRS_HDR_ERROR_DIS;
+ /* For UDP remove PAD from L4 checksum calculation */
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_UDP);
+ tmpHxs[hdrNum] |= PRS_HDR_UDP_PAD_REMOVAL;
+ /* For TCP remove PAD from L4 checksum calculation */
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_TCP);
+ tmpHxs[hdrNum] |= PRS_HDR_TCP_PAD_REMOVAL;
+
/* config additional params for specific headers */
- for(i=0 ; i<p_PcdParams->p_PrsParams->numOfHdrsWithAdditionalParams ; i++)
+ for (i = 0; i < p_PcdParams->p_PrsParams->numOfHdrsWithAdditionalParams;
+ i++)
{
- GET_PRS_HDR_NUM(hdrNum, p_PcdParams->p_PrsParams->additionalParams[i].hdr);
- if(hdrNum== ILLEGAL_HDR_NUM)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
- if(hdrNum==NO_HDR_NUM)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Private headers may not use additional parameters"));
+ /* case for using sw parser as the initial NIA address, before
+ * HW parsing
+ */
+ if ((p_PcdParams->p_PrsParams->additionalParams[i].hdr == HEADER_TYPE_NONE) &&
+ p_PcdParams->p_PrsParams->additionalParams[i].swPrsEnable)
+ {
+ initialSwPrs = FmPcdGetSwPrsOffset(p_FmPort->h_FmPcd, HEADER_TYPE_NONE,
+ p_PcdParams->p_PrsParams->additionalParams[i].indexPerHdr);
+ if (initialSwPrs == ILLEGAL_BASE)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
- err = AdditionalPrsParams(p_FmPort, &p_PcdParams->p_PrsParams->additionalParams[i], &tmpReg);
- if(err)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
+ /* clear parser first HXS */
+ p_FmPort->savedBmiNia &= ~BMI_RFNE_HXS_MASK; /* 0x000000FF */
+ /* rewrite with soft parser start */
+ p_FmPort->savedBmiNia |= initialSwPrs;
+ continue;
+ }
- tmpHxs[hdrNum] |= tmpReg;
+ hdrNum =
+ GetPrsHdrNum(p_PcdParams->p_PrsParams->additionalParams[i].hdr);
+ if (hdrNum == ILLEGAL_HDR_NUM)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
+ if (hdrNum == NO_HDR_NUM)
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("Private headers may not use additional parameters"));
+
+ err = AdditionalPrsParams(
+ p_FmPort, &p_PcdParams->p_PrsParams->additionalParams[i],
+ &tmpHxs[hdrNum]);
+ if (err)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);
}
-#ifdef FM_PRS_L4_SHELL_ERRATA_FMANb
+
+ /* Check if ip-reassembly port - need to link sw-parser code */
+ if (p_FmPort->h_IpReassemblyManip)
{
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
+ /* link to sw parser code for IP Frag - only if no other code is applied. */
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv4);
+ if (!(tmpHxs[hdrNum] & PRS_HDR_SW_PRS_EN))
+ tmpHxs[hdrNum] |= (PRS_HDR_SW_PRS_EN | OFFLOAD_SW_PATCH_IPv4_IPR_LABEL);
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv6);
+ if (!(tmpHxs[hdrNum] & PRS_HDR_SW_PRS_EN))
+ tmpHxs[hdrNum] |= (PRS_HDR_SW_PRS_EN | OFFLOAD_SW_PATCH_IPv6_IPR_LABEL);
+ } else {
+ if (FmPcdNetEnvIsHdrExist(p_FmPort->h_FmPcd, p_FmPort->netEnvId, HEADER_TYPE_UDP_LITE))
{
- /* link to sw parser code for L4 shells - only if no other code is applied. */
- GET_PRS_HDR_NUM(hdrNum, HEADER_TYPE_SCTP)
- if(!(tmpHxs[hdrNum] & PRS_HDR_SW_PRS_EN))
- tmpHxs[hdrNum] |= (PRS_HDR_SW_PRS_EN | SCTP_SW_PATCH_START);
- GET_PRS_HDR_NUM(hdrNum, HEADER_TYPE_DCCP)
- if(!(tmpHxs[hdrNum] & PRS_HDR_SW_PRS_EN))
- tmpHxs[hdrNum] |= (PRS_HDR_SW_PRS_EN | DCCP_SW_PATCH_START);
- GET_PRS_HDR_NUM(hdrNum, HEADER_TYPE_IPSEC_AH)
- if(!(tmpHxs[hdrNum] & PRS_HDR_SW_PRS_EN))
- tmpHxs[hdrNum] |= (PRS_HDR_SW_PRS_EN | IPSEC_SW_PATCH_START);
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv6);
+ if (!(tmpHxs[hdrNum] & PRS_HDR_SW_PRS_EN))
+ tmpHxs[hdrNum] |= (PRS_HDR_SW_PRS_EN | OFFLOAD_SW_PATCH_IPv6_IPF_LABEL);
+ } else if ((FmPcdIsAdvancedOffloadSupported(p_FmPort->h_FmPcd)
+ && (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)))
+ {
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv6);
+ if (!(tmpHxs[hdrNum] & PRS_HDR_SW_PRS_EN))
+ tmpHxs[hdrNum] |= (PRS_HDR_SW_PRS_EN | OFFLOAD_SW_PATCH_IPv6_IPF_LABEL);
+ }
}
- }
-#endif /* FM_PRS_L4_SHELL_ERRATA_FMANb */
- for(i=0 ; i<FM_PCD_PRS_NUM_OF_HDRS ; i++)
+#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
+ if (FmPcdNetEnvIsHdrExist(p_FmPort->h_FmPcd, p_FmPort->netEnvId,
+ HEADER_TYPE_UDP_LITE))
+ {
+ /* link to sw parser code for udp lite - only if no other code is applied. */
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv6);
+ if (!(tmpHxs[hdrNum] & PRS_HDR_SW_PRS_EN))
+ tmpHxs[hdrNum] |= (PRS_HDR_SW_PRS_EN | UDP_LITE_SW_PATCH_LABEL);
+ }
+#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
+ for (i = 0; i < FM_PCD_PRS_NUM_OF_HDRS; i++)
{
/* For all header set LCV as taken from netEnv*/
- WRITE_UINT32(p_FmPort->p_FmPortPrsRegs->hdrs[i].lcv, FmPcdGetLcv(p_FmPort->h_FmPcd, p_FmPort->netEnvId, (uint8_t)i));
+ WRITE_UINT32(
+ p_FmPort->p_FmPortPrsRegs->hdrs[i].lcv,
+ FmPcdGetLcv(p_FmPort->h_FmPcd, p_FmPort->netEnvId, (uint8_t)i));
/* set HXS register according to default+Additional params+protocol options */
- WRITE_UINT32(p_FmPort->p_FmPortPrsRegs->hdrs[i].softSeqAttach, tmpHxs[i]);
+ WRITE_UINT32(p_FmPort->p_FmPortPrsRegs->hdrs[i].softSeqAttach,
+ tmpHxs[i]);
}
/* set tpid. */
tmpReg = PRS_TPID_DFLT;
- if(p_PcdParams->p_PrsParams->setVlanTpid1)
+ if (p_PcdParams->p_PrsParams->setVlanTpid1)
{
tmpReg &= PRS_TPID2_MASK;
- tmpReg |= (uint32_t)p_PcdParams->p_PrsParams->vlanTpid1 << PRS_PCTPID_SHIFT;
+ tmpReg |= (uint32_t)p_PcdParams->p_PrsParams->vlanTpid1
+ << PRS_PCTPID_SHIFT;
}
- if(p_PcdParams->p_PrsParams->setVlanTpid2)
+ if (p_PcdParams->p_PrsParams->setVlanTpid2)
{
tmpReg &= PRS_TPID1_MASK;
tmpReg |= (uint32_t)p_PcdParams->p_PrsParams->vlanTpid2;
- }
- WRITE_UINT32(p_FmPort->p_FmPortPrsRegs->pctpid, tmpReg);
+ }WRITE_UINT32(p_FmPort->p_FmPortPrsRegs->pctpid, tmpReg);
/* enable parser */
WRITE_UINT32(p_FmPort->p_FmPortPrsRegs->pcac, 0);
- if(p_PcdParams->p_PrsParams->prsResultPrivateInfo)
- p_FmPort->privateInfo = p_PcdParams->p_PrsParams->prsResultPrivateInfo;
+ if (p_PcdParams->p_PrsParams->prsResultPrivateInfo)
+ p_FmPort->privateInfo =
+ p_PcdParams->p_PrsParams->prsResultPrivateInfo;
} /* end parser */
- else
+ else {
+ if (FmPcdIsAdvancedOffloadSupported(p_FmPort->h_FmPcd)
+ && (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
+ {
+ hdrNum = GetPrsHdrNum(HEADER_TYPE_IPv6);
+ WRITE_UINT32(p_FmPort->p_FmPortPrsRegs->hdrs[hdrNum].softSeqAttach,
+ (PRS_HDR_SW_PRS_EN | OFFLOAD_SW_PATCH_IPv6_IPF_LABEL));
+ }
+
+ WRITE_UINT32(*p_BmiPrsStartOffset, 0);
+
p_FmPort->privateInfo = 0;
+ }
- WRITE_UINT32(*p_BmiPrsStartOffset, GET_UINT32(*p_BmiPrsStartOffset) + p_FmPort->internalBufferOffset);
+ FmPortCheckNApplyMacsec(p_FmPort);
+
+ WRITE_UINT32(
+ *p_BmiPrsStartOffset,
+ GET_UINT32(*p_BmiPrsStartOffset) + p_FmPort->internalBufferOffset);
/* set initial parser result - used for all engines */
- for (i=0;i<FM_PORT_PRS_RESULT_NUM_OF_WORDS;i++)
+ for (i = 0; i < FM_PORT_PRS_RESULT_NUM_OF_WORDS; i++)
{
if (!i)
- WRITE_UINT32(*(p_BmiInitPrsResult), (uint32_t)(((uint32_t)p_FmPort->privateInfo << BMI_PR_PORTID_SHIFT)
- | BMI_PRS_RESULT_HIGH));
+ WRITE_UINT32(
+ *(p_BmiInitPrsResult),
+ (uint32_t)(((uint32_t)p_FmPort->privateInfo << BMI_PR_PORTID_SHIFT) | BMI_PRS_RESULT_HIGH));
else
- if (i< FM_PORT_PRS_RESULT_NUM_OF_WORDS/2)
+ {
+ if (i < FM_PORT_PRS_RESULT_NUM_OF_WORDS / 2)
WRITE_UINT32(*(p_BmiInitPrsResult+i), BMI_PRS_RESULT_HIGH);
else
WRITE_UINT32(*(p_BmiInitPrsResult+i), BMI_PRS_RESULT_LOW);
+ }
}
return E_OK;
}
-static t_Error DeletePcd(t_Handle h_FmPort)
+static t_Error DeletePcd(t_FmPort *p_FmPort)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- t_Error err = E_OK;
- volatile uint32_t *p_BmiNia=NULL;
+ t_Error err = E_OK;
+ volatile uint32_t *p_BmiNia = NULL;
+ volatile uint32_t *p_BmiPrsStartOffset = NULL;
- SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
+ ASSERT_COND(p_FmPort);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
if (p_FmPort->imEn)
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for non-independant mode ports only"));
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for non-independant mode ports only"));
- if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) &&
- (p_FmPort->portType != e_FM_PORT_TYPE_RX) &&
- (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx and offline parsing ports only"));
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
+ RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
+ ("available for Rx and offline parsing ports only"));
- if(!p_FmPort->pcdEngines)
+ if (!p_FmPort->pcdEngines)
RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("called for non PCD port"));
/* get PCD registers pointers */
- switch(p_FmPort->portType)
+ switch (p_FmPort->portType)
{
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- p_BmiNia = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfne;
+ case (e_FM_PORT_TYPE_RX_10G):
+ case (e_FM_PORT_TYPE_RX):
+ p_BmiNia = &p_FmPort->port.bmi_regs->rx.fmbm_rfne;
+ p_BmiPrsStartOffset = &p_FmPort->port.bmi_regs->rx.fmbm_rpso;
break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- p_BmiNia = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofne;
+ case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
+ p_BmiNia = &p_FmPort->port.bmi_regs->oh.fmbm_ofne;
+ p_BmiPrsStartOffset = &p_FmPort->port.bmi_regs->oh.fmbm_opso;
break;
default:
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
}
- if((GET_UINT32(*p_BmiNia) & (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)) != (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("port has to be detached previousely"));
+ if ((GET_UINT32(*p_BmiNia) & GET_NO_PCD_NIA_BMI_AC_ENQ_FRAME())
+ != GET_NO_PCD_NIA_BMI_AC_ENQ_FRAME())
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("port has to be detached previousely"));
+
+ WRITE_UINT32(*p_BmiPrsStartOffset, 0);
/* "cut" PCD out of the port's flow - go to BMI */
/* WRITE_UINT32(*p_BmiNia, (p_FmPort->savedBmiNia & BMI_RFNE_FDCS_MASK) | (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)); */
- if(p_FmPort->pcdEngines | FM_PCD_PRS)
+ if (p_FmPort->pcdEngines & FM_PCD_PRS)
{
/* stop parser */
WRITE_UINT32(p_FmPort->p_FmPortPrsRegs->pcac, PRS_CAC_STOP);
/* wait for parser to be in idle state */
- while(GET_UINT32(p_FmPort->p_FmPortPrsRegs->pcac) & PRS_CAC_ACTIVE) ;
+ while (GET_UINT32(p_FmPort->p_FmPortPrsRegs->pcac) & PRS_CAC_ACTIVE)
+ ;
}
- if(p_FmPort->pcdEngines & FM_PCD_KG)
+ if (p_FmPort->pcdEngines & FM_PCD_KG)
{
- err = FmPcdKgDeleteOrUnbindPortToClsPlanGrp(p_FmPort->h_FmPcd, p_FmPort->hardwarePortId, p_FmPort->clsPlanGrpId);
- if(err)
- RETURN_ERROR(MINOR, err, NO_MSG);
+ t_FmPcdKgInterModuleBindPortToSchemes schemeBind;
+
+ /* unbind all schemes */
+ p_FmPort->schemesPerPortVector = GetPortSchemeBindParams(p_FmPort,
+ &schemeBind);
+
+ err = FmPcdKgUnbindPortToSchemes(p_FmPort->h_FmPcd, &schemeBind);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ err = FmPcdKgDeleteOrUnbindPortToClsPlanGrp(p_FmPort->h_FmPcd,
+ p_FmPort->hardwarePortId,
+ p_FmPort->clsPlanGrpId);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
p_FmPort->useClsPlan = FALSE;
}
- if(p_FmPort->pcdEngines & FM_PCD_CC)
+ if (p_FmPort->pcdEngines & FM_PCD_CC)
{
/* unbind - we need to get the treeId too */
- err = FmPcdCcUnbindTree(p_FmPort->h_FmPcd, p_FmPort->ccTreeId);
- if(err)
- RETURN_ERROR(MINOR, err, NO_MSG);
+ err = FmPcdCcUnbindTree(p_FmPort->h_FmPcd, p_FmPort->ccTreeId);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
p_FmPort->pcdEngines = 0;
@@ -1991,62 +1757,155 @@ static t_Error DeletePcd(t_Handle h_FmPort)
return E_OK;
}
-
-/********************************************/
-/* Inter-module API */
-/********************************************/
-void FmPortSetMacsecLcv(t_Handle h_FmPort)
+static t_Error AttachPCD(t_FmPort *p_FmPort)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- volatile uint32_t *p_BmiCfgReg = NULL;
- uint32_t macsecEn = BMI_PORT_CFG_EN_MACSEC;
- uint32_t lcv, walking1Mask = 0x80000000;
- uint8_t cnt = 0;
+ volatile uint32_t *p_BmiNia = NULL;
- SANITY_CHECK_RETURN(p_FmPort, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
+ ASSERT_COND(p_FmPort);
+
+ /* get PCD registers pointers */
+ if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ p_BmiNia = &p_FmPort->port.bmi_regs->oh.fmbm_ofne;
+ else
+ p_BmiNia = &p_FmPort->port.bmi_regs->rx.fmbm_rfne;
- if((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
+ /* check that current NIA is BMI to BMI */
+ if ((GET_UINT32(*p_BmiNia) & ~BMI_RFNE_FDCS_MASK)
+ != GET_NO_PCD_NIA_BMI_AC_ENQ_FRAME())
+ RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
+ ("may be called only for ports in BMI-to-BMI state."));
+
+ if (p_FmPort->requiredAction & UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY)
+ if (FmSetNumOfRiscsPerPort(p_FmPort->h_Fm, p_FmPort->hardwarePortId, 1,
+ p_FmPort->orFmanCtrl) != E_OK)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
+
+ if (p_FmPort->requiredAction & UPDATE_NIA_CMNE)
{
- REPORT_ERROR(MAJOR, E_INVALID_OPERATION, ("The routine is relevant for Rx ports only"));
- return;
+ if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ WRITE_UINT32(p_FmPort->port.bmi_regs->oh.fmbm_ocmne,
+ p_FmPort->savedBmiCmne);
+ else
+ WRITE_UINT32(p_FmPort->port.bmi_regs->rx.fmbm_rcmne,
+ p_FmPort->savedBmiCmne);
}
- p_BmiCfgReg = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rcfg;
- /* get LCV for MACSEC */
- if ((p_FmPort->h_FmPcd) && ((lcv = FmPcdGetMacsecLcv(p_FmPort->h_FmPcd, p_FmPort->netEnvId))!= 0))
+ if (p_FmPort->requiredAction & UPDATE_NIA_PNEN)
+ WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnen,
+ p_FmPort->savedQmiPnen);
+
+ if (p_FmPort->requiredAction & UPDATE_NIA_FENE)
{
- while(!(lcv & walking1Mask))
- {
- cnt++;
- walking1Mask >>= 1;
- }
+ if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ WRITE_UINT32(p_FmPort->port.bmi_regs->oh.fmbm_ofene,
+ p_FmPort->savedBmiFene);
+ else
+ WRITE_UINT32(p_FmPort->port.bmi_regs->rx.fmbm_rfene,
+ p_FmPort->savedBmiFene);
+ }
- macsecEn |= (uint32_t)cnt << BMI_PORT_CFG_MS_SEL_SHIFT;
- }
+ if (p_FmPort->requiredAction & UPDATE_NIA_FPNE)
+ {
+ if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ WRITE_UINT32(p_FmPort->port.bmi_regs->oh.fmbm_ofpne,
+ p_FmPort->savedBmiFpne);
+ else
+ WRITE_UINT32(p_FmPort->port.bmi_regs->rx.fmbm_rfpne,
+ p_FmPort->savedBmiFpne);
+ }
+
+ if (p_FmPort->requiredAction & UPDATE_OFP_DPTE)
+ {
+ ASSERT_COND(p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING);
- WRITE_UINT32(*p_BmiCfgReg, GET_UINT32(*p_BmiCfgReg) | macsecEn);
+ WRITE_UINT32(p_FmPort->port.bmi_regs->oh.fmbm_ofp,
+ p_FmPort->savedBmiOfp);
+ }
+
+ WRITE_UINT32(*p_BmiNia, p_FmPort->savedBmiNia);
+
+ if (p_FmPort->requiredAction & UPDATE_NIA_PNDN)
+ {
+ p_FmPort->origNonRxQmiRegsPndn =
+ GET_UINT32(p_FmPort->port.qmi_regs->fmqm_pndn);
+ WRITE_UINT32(p_FmPort->port.qmi_regs->fmqm_pndn,
+ p_FmPort->savedNonRxQmiRegsPndn);
+ }
+
+ return E_OK;
}
+static t_Error DetachPCD(t_FmPort *p_FmPort)
+{
+ volatile uint32_t *p_BmiNia = NULL;
+
+ ASSERT_COND(p_FmPort);
+
+ /* get PCD registers pointers */
+ if (p_FmPort->requiredAction & UPDATE_NIA_PNDN)
+ WRITE_UINT32(p_FmPort->port.qmi_regs->fmqm_pndn,
+ p_FmPort->origNonRxQmiRegsPndn);
+
+ if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ p_BmiNia = &p_FmPort->port.bmi_regs->oh.fmbm_ofne;
+ else
+ p_BmiNia = &p_FmPort->port.bmi_regs->rx.fmbm_rfne;
+
+ WRITE_UINT32(
+ *p_BmiNia,
+ (p_FmPort->savedBmiNia & BMI_RFNE_FDCS_MASK) | GET_NO_PCD_NIA_BMI_AC_ENQ_FRAME());
+
+ if (FmPcdGetHcHandle(p_FmPort->h_FmPcd))
+ FmPcdHcSync(p_FmPort->h_FmPcd);
+
+ if (p_FmPort->requiredAction & UPDATE_NIA_FENE)
+ {
+ if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ WRITE_UINT32(p_FmPort->port.bmi_regs->oh.fmbm_ofene,
+ NIA_ENG_QMI_ENQ | NIA_ORDER_RESTOR);
+ else
+ WRITE_UINT32(p_FmPort->port.bmi_regs->rx.fmbm_rfene,
+ NIA_ENG_QMI_ENQ | NIA_ORDER_RESTOR);
+ }
+
+ if (p_FmPort->requiredAction & UPDATE_NIA_PNEN)
+ WRITE_UINT32(p_FmPort->port.qmi_regs->fmqm_pnen,
+ NIA_ENG_BMI | NIA_BMI_AC_RELEASE);
+
+ if (p_FmPort->requiredAction & UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY)
+ if (FmSetNumOfRiscsPerPort(p_FmPort->h_Fm, p_FmPort->hardwarePortId, 2,
+ p_FmPort->orFmanCtrl) != E_OK)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
+
+ p_FmPort->requiredAction = 0;
+
+ return E_OK;
+}
+
+/*****************************************************************************/
+/* Inter-module API routines */
+/*****************************************************************************/
void FmPortSetMacsecCmd(t_Handle h_FmPort, uint8_t dfltSci)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- volatile uint32_t *p_BmiCfgReg = NULL;
- uint32_t tmpReg;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ volatile uint32_t *p_BmiCfgReg = NULL;
+ uint32_t tmpReg;
SANITY_CHECK_RETURN(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN(p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
- if ((p_FmPort->portType != e_FM_PORT_TYPE_TX_10G) && (p_FmPort->portType != e_FM_PORT_TYPE_TX))
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_TX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_TX))
{
REPORT_ERROR(MAJOR, E_INVALID_OPERATION, ("The routine is relevant for Tx ports only"));
return;
}
- p_BmiCfgReg = &p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tfca;
+ p_BmiCfgReg = &p_FmPort->port.bmi_regs->tx.fmbm_tfca;
tmpReg = GET_UINT32(*p_BmiCfgReg) & ~BMI_CMD_ATTR_MACCMD_MASK;
tmpReg |= BMI_CMD_ATTR_MACCMD_SECURED;
- tmpReg |= (((uint32_t)dfltSci << BMI_CMD_ATTR_MACCMD_SC_SHIFT) & BMI_CMD_ATTR_MACCMD_SC_MASK);
+ tmpReg |= (((uint32_t)dfltSci << BMI_CMD_ATTR_MACCMD_SC_SHIFT)
+ & BMI_CMD_ATTR_MACCMD_SC_MASK);
WRITE_UINT32(*p_BmiCfgReg, tmpReg);
}
@@ -2066,156 +1925,297 @@ uint32_t FmPortGetPcdEngines(t_Handle h_FmPort)
return ((t_FmPort*)h_FmPort)->pcdEngines;
}
-t_Error FmPortAttachPCD(t_Handle h_FmPort)
+#if (DPAA_VERSION >= 11)
+t_Error FmPortSetGprFunc(t_Handle h_FmPort, e_FmPortGprFuncType gprFunc,
+ void **p_Value)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- volatile uint32_t *p_BmiNia=NULL;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ uint32_t muramPageOffset;
-/*TODO - to take care about the chnges that were made in the port because of the previously assigned tree.
-pndn, pnen ... maybe were changed because of the Tree requirement*/
+ ASSERT_COND(p_FmPort);
+ ASSERT_COND(p_Value);
- /* get PCD registers pointers */
- switch(p_FmPort->portType)
+ if (p_FmPort->gprFunc != e_FM_PORT_GPR_EMPTY)
{
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- p_BmiNia = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfne;
- break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- p_BmiNia = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofne;
+ if (p_FmPort->gprFunc != gprFunc)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("gpr was assigned with different func"));
+ }
+ else
+ {
+ switch (gprFunc)
+ {
+ case (e_FM_PORT_GPR_MURAM_PAGE):
+ p_FmPort->p_ParamsPage = FM_MURAM_AllocMem(p_FmPort->h_FmMuram,
+ 256, 8);
+ if (!p_FmPort->p_ParamsPage)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for page"));
+
+ IOMemSet32(p_FmPort->p_ParamsPage, 0, 256);
+ muramPageOffset =
+ (uint32_t)(XX_VirtToPhys(p_FmPort->p_ParamsPage)
+ - p_FmPort->fmMuramPhysBaseAddr);
+ switch (p_FmPort->portType)
+ {
+ case (e_FM_PORT_TYPE_RX_10G):
+ case (e_FM_PORT_TYPE_RX):
+ WRITE_UINT32(
+ p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rgpr,
+ muramPageOffset);
+ break;
+ case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
+ WRITE_UINT32(
+ p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ogpr,
+ muramPageOffset);
+ break;
+ default:
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("Invalid port type"));
+ }
+ break;
+ default:
+ RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
+ }
+ p_FmPort->gprFunc = gprFunc;
+ }
+
+ switch (p_FmPort->gprFunc)
+ {
+ case (e_FM_PORT_GPR_MURAM_PAGE):
+ *p_Value = p_FmPort->p_ParamsPage;
break;
default:
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx and offline parsing ports only"));
+ RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
}
- if(p_FmPort->requiredAction & UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY)
- if(FmSetNumOfRiscsPerPort(p_FmPort->h_Fm, p_FmPort->hardwarePortId, 1)!= E_OK)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
-
- /* check that current NIA is BMI to BMI */
- if((GET_UINT32(*p_BmiNia) & ~BMI_RFNE_FDCS_MASK) != (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("may be called only for ports in BMI-to-BMI state."));
-
- WRITE_UINT32(*p_BmiNia, p_FmPort->savedBmiNia);
-
- if(p_FmPort->requiredAction & UPDATE_NIA_PNEN)
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnen, p_FmPort->savedQmiPnen);
-
- if(p_FmPort->requiredAction & UPDATE_NIA_PNDN)
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs.fmqm_pndn, p_FmPort->savedNonRxQmiRegsPndn);
-
-
return E_OK;
}
+#endif /* (DPAA_VERSION >= 11) */
-t_Error FmPortGetSetCcParams(t_Handle h_FmPort, t_FmPortGetSetCcParams *p_CcParams)
+t_Error FmPortGetSetCcParams(t_Handle h_FmPort,
+ t_FmPortGetSetCcParams *p_CcParams)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- int tmpInt;
- volatile uint32_t *p_BmiPrsStartOffset = NULL;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ int tmpInt;
+ volatile uint32_t *p_BmiPrsStartOffset = NULL;
/* this function called from Cc for pass and receive parameters port params between CC and PORT*/
- if((p_CcParams->getCcParams.type & OFFSET_OF_PR) && (p_FmPort->bufferOffsets.prsResultOffset != ILLEGAL_BASE))
+ if ((p_CcParams->getCcParams.type & OFFSET_OF_PR)
+ && (p_FmPort->bufferOffsets.prsResultOffset != ILLEGAL_BASE))
{
- p_CcParams->getCcParams.prOffset = (uint8_t)p_FmPort->bufferOffsets.prsResultOffset;
+ p_CcParams->getCcParams.prOffset =
+ (uint8_t)p_FmPort->bufferOffsets.prsResultOffset;
p_CcParams->getCcParams.type &= ~OFFSET_OF_PR;
}
- if(p_CcParams->getCcParams.type & HW_PORT_ID)
+ if (p_CcParams->getCcParams.type & HW_PORT_ID)
{
- p_CcParams->getCcParams.hardwarePortId = (uint8_t)p_FmPort->hardwarePortId;
+ p_CcParams->getCcParams.hardwarePortId =
+ (uint8_t)p_FmPort->hardwarePortId;
p_CcParams->getCcParams.type &= ~HW_PORT_ID;
}
- if((p_CcParams->getCcParams.type & OFFSET_OF_DATA) && (p_FmPort->bufferOffsets.dataOffset != ILLEGAL_BASE))
+ if ((p_CcParams->getCcParams.type & OFFSET_OF_DATA)
+ && (p_FmPort->bufferOffsets.dataOffset != ILLEGAL_BASE))
{
- p_CcParams->getCcParams.dataOffset = (uint16_t)p_FmPort->bufferOffsets.dataOffset;
+ p_CcParams->getCcParams.dataOffset =
+ (uint16_t)p_FmPort->bufferOffsets.dataOffset;
p_CcParams->getCcParams.type &= ~OFFSET_OF_DATA;
}
- if(p_CcParams->getCcParams.type & NUM_OF_TASKS)
+ if (p_CcParams->getCcParams.type & NUM_OF_TASKS)
{
- p_CcParams->getCcParams.numOfTasks = p_FmPort->numOfTasks;
+ p_CcParams->getCcParams.numOfTasks = (uint8_t)p_FmPort->tasks.num;
p_CcParams->getCcParams.type &= ~NUM_OF_TASKS;
}
- if(p_CcParams->getCcParams.type & BUFFER_POOL_ID_FOR_MANIP)
+ if (p_CcParams->getCcParams.type & NUM_OF_EXTRA_TASKS)
{
- if(p_CcParams->getCcParams.poolIndex < p_FmPort->extBufPools.numOfPoolsUsed)
- {
- p_CcParams->getCcParams.poolIdForManip = p_FmPort->extBufPools.extBufPool[p_CcParams->getCcParams.poolIndex].id;
- p_CcParams->getCcParams.type &= ~BUFFER_POOL_ID_FOR_MANIP;
- }
+ p_CcParams->getCcParams.numOfExtraTasks =
+ (uint8_t)p_FmPort->tasks.extra;
+ p_CcParams->getCcParams.type &= ~NUM_OF_EXTRA_TASKS;
+ }
+ if (p_CcParams->getCcParams.type & FM_REV)
+ {
+ p_CcParams->getCcParams.revInfo.majorRev = p_FmPort->fmRevInfo.majorRev;
+ p_CcParams->getCcParams.revInfo.minorRev = p_FmPort->fmRevInfo.minorRev;
+ p_CcParams->getCcParams.type &= ~FM_REV;
+ }
+ if (p_CcParams->getCcParams.type & DISCARD_MASK)
+ {
+ if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ p_CcParams->getCcParams.discardMask =
+ GET_UINT32(p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofsdm);
+ else
+ p_CcParams->getCcParams.discardMask =
+ GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfsdm);
+ p_CcParams->getCcParams.type &= ~DISCARD_MASK;
+ }
+ if (p_CcParams->getCcParams.type & MANIP_EXTRA_SPACE)
+ {
+ p_CcParams->getCcParams.internalBufferOffset =
+ p_FmPort->internalBufferOffset;
+ p_CcParams->getCcParams.type &= ~MANIP_EXTRA_SPACE;
+ }
+ if (p_CcParams->getCcParams.type & GET_NIA_FPNE)
+ {
+ if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ p_CcParams->getCcParams.nia =
+ GET_UINT32(p_FmPort->port.bmi_regs->oh.fmbm_ofpne);
+ else
+ p_CcParams->getCcParams.nia =
+ GET_UINT32(p_FmPort->port.bmi_regs->rx.fmbm_rfpne);
+ p_CcParams->getCcParams.type &= ~GET_NIA_FPNE;
+ }
+ if (p_CcParams->getCcParams.type & GET_NIA_PNDN)
+ {
+ if (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
+ p_CcParams->getCcParams.nia =
+ GET_UINT32(p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs.fmqm_pndn);
+ p_CcParams->getCcParams.type &= ~GET_NIA_PNDN;
}
- if((p_CcParams->setCcParams.type & UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY) && !(p_FmPort->requiredAction & UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY))
+ if ((p_CcParams->setCcParams.type & UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY)
+ && !(p_FmPort->requiredAction & UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY))
{
p_FmPort->requiredAction |= UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY;
+ p_FmPort->orFmanCtrl = p_CcParams->setCcParams.orFmanCtrl;
}
- if((p_CcParams->setCcParams.type & UPDATE_NIA_PNEN) && !(p_FmPort->requiredAction & UPDATE_NIA_PNEN))
+ if ((p_CcParams->setCcParams.type & UPDATE_NIA_PNEN)
+ && !(p_FmPort->requiredAction & UPDATE_NIA_PNEN))
{
p_FmPort->savedQmiPnen = p_CcParams->setCcParams.nia;
p_FmPort->requiredAction |= UPDATE_NIA_PNEN;
}
- else if (p_CcParams->setCcParams.type & UPDATE_NIA_PNEN)
- {
- if(p_FmPort->savedQmiPnen != p_CcParams->setCcParams.nia)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("pnen was defined previously different"));
- }
+ else
+ if (p_CcParams->setCcParams.type & UPDATE_NIA_PNEN)
+ {
+ if (p_FmPort->savedQmiPnen != p_CcParams->setCcParams.nia)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("PNEN was defined previously different"));
+ }
- if((p_CcParams->setCcParams.type & UPDATE_NIA_PNDN) && !(p_FmPort->requiredAction & UPDATE_NIA_PNDN))
+ if ((p_CcParams->setCcParams.type & UPDATE_NIA_PNDN)
+ && !(p_FmPort->requiredAction & UPDATE_NIA_PNDN))
{
p_FmPort->savedNonRxQmiRegsPndn = p_CcParams->setCcParams.nia;
p_FmPort->requiredAction |= UPDATE_NIA_PNDN;
}
- else if(p_CcParams->setCcParams.type & UPDATE_NIA_PNDN)
+ else
+ if (p_CcParams->setCcParams.type & UPDATE_NIA_PNDN)
+ {
+ if (p_FmPort->savedNonRxQmiRegsPndn != p_CcParams->setCcParams.nia)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("PNDN was defined previously different"));
+ }
+
+ if ((p_CcParams->setCcParams.type & UPDATE_NIA_FENE)
+ && (p_CcParams->setCcParams.overwrite
+ || !(p_FmPort->requiredAction & UPDATE_NIA_FENE)))
+ {
+ p_FmPort->savedBmiFene = p_CcParams->setCcParams.nia;
+ p_FmPort->requiredAction |= UPDATE_NIA_FENE;
+ }
+ else
+ if (p_CcParams->setCcParams.type & UPDATE_NIA_FENE)
+ {
+ if (p_FmPort->savedBmiFene != p_CcParams->setCcParams.nia)
+ RETURN_ERROR( MAJOR, E_INVALID_STATE,
+ ("xFENE was defined previously different"));
+ }
+
+ if ((p_CcParams->setCcParams.type & UPDATE_NIA_FPNE)
+ && !(p_FmPort->requiredAction & UPDATE_NIA_FPNE))
{
- if(p_FmPort->savedNonRxQmiRegsPndn != p_CcParams->setCcParams.nia)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("pndn was defined previously different"));
+ p_FmPort->savedBmiFpne = p_CcParams->setCcParams.nia;
+ p_FmPort->requiredAction |= UPDATE_NIA_FPNE;
}
+ else
+ if (p_CcParams->setCcParams.type & UPDATE_NIA_FPNE)
+ {
+ if (p_FmPort->savedBmiFpne != p_CcParams->setCcParams.nia)
+ RETURN_ERROR( MAJOR, E_INVALID_STATE,
+ ("xFPNE was defined previously different"));
+ }
+ if ((p_CcParams->setCcParams.type & UPDATE_NIA_CMNE)
+ && !(p_FmPort->requiredAction & UPDATE_NIA_CMNE))
+ {
+ p_FmPort->savedBmiCmne = p_CcParams->setCcParams.nia;
+ p_FmPort->requiredAction |= UPDATE_NIA_CMNE;
+ }
+ else
+ if (p_CcParams->setCcParams.type & UPDATE_NIA_CMNE)
+ {
+ if (p_FmPort->savedBmiCmne != p_CcParams->setCcParams.nia)
+ RETURN_ERROR( MAJOR, E_INVALID_STATE,
+ ("xCMNE was defined previously different"));
+ }
- if((p_CcParams->setCcParams.type & UPDATE_PSO) && !(p_FmPort->requiredAction & UPDATE_PSO))
+ if ((p_CcParams->setCcParams.type & UPDATE_PSO)
+ && !(p_FmPort->requiredAction & UPDATE_PSO))
{
/* get PCD registers pointers */
- switch(p_FmPort->portType)
- {
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- p_BmiPrsStartOffset = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rpso;
- break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- p_BmiPrsStartOffset = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_opso;
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
- }
+ switch (p_FmPort->portType)
+ {
+ case (e_FM_PORT_TYPE_RX_10G):
+ case (e_FM_PORT_TYPE_RX):
+ p_BmiPrsStartOffset = &p_FmPort->port.bmi_regs->rx.fmbm_rpso;
+ break;
+ case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
+ p_BmiPrsStartOffset = &p_FmPort->port.bmi_regs->oh.fmbm_opso;
+ break;
+ default:
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
+ }
+
/* set start parsing offset */
- tmpInt = (int)GET_UINT32(*p_BmiPrsStartOffset)+ p_CcParams->setCcParams.psoSize;
- if(tmpInt>0)
+ tmpInt = (int)GET_UINT32(*p_BmiPrsStartOffset)
+ + p_CcParams->setCcParams.psoSize;
+ if (tmpInt > 0)
WRITE_UINT32(*p_BmiPrsStartOffset, (uint32_t)tmpInt);
p_FmPort->requiredAction |= UPDATE_PSO;
p_FmPort->savedPrsStartOffset = p_CcParams->setCcParams.psoSize;
-
}
- else if (p_CcParams->setCcParams.type & UPDATE_PSO)
+ else
+ if (p_CcParams->setCcParams.type & UPDATE_PSO)
+ {
+ if (p_FmPort->savedPrsStartOffset
+ != p_CcParams->setCcParams.psoSize)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("parser start offset was defoned previousley different"));
+ }
+
+ if ((p_CcParams->setCcParams.type & UPDATE_OFP_DPTE)
+ && !(p_FmPort->requiredAction & UPDATE_OFP_DPTE))
{
- if(p_FmPort->savedPrsStartOffset != p_CcParams->setCcParams.psoSize)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("parser start offset was defoned previousley different"));
+ if (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
+ p_FmPort->savedBmiOfp = GET_UINT32(p_FmPort->port.bmi_regs->oh.fmbm_ofp);
+ p_FmPort->savedBmiOfp &= ~BMI_FIFO_PIPELINE_DEPTH_MASK;
+ p_FmPort->savedBmiOfp |= p_CcParams->setCcParams.ofpDpde
+ << BMI_FIFO_PIPELINE_DEPTH_SHIFT;
+ p_FmPort->requiredAction |= UPDATE_OFP_DPTE;
}
+
return E_OK;
}
-/********************************** End of inter-module routines ********************************/
+/*********************** End of inter-module routines ************************/
/****************************************/
/* API Init unit functions */
/****************************************/
+
t_Handle FM_PORT_Config(t_FmPortParams *p_FmPortParams)
{
- t_FmPort *p_FmPort;
- uintptr_t baseAddr = p_FmPortParams->baseAddr;
+ t_FmPort *p_FmPort;
+ uintptr_t baseAddr = p_FmPortParams->baseAddr;
+ uint32_t tmpReg;
/* Allocate FM structure */
- p_FmPort = (t_FmPort *) XX_Malloc(sizeof(t_FmPort));
+ p_FmPort = (t_FmPort *)XX_Malloc(sizeof(t_FmPort));
if (!p_FmPort)
{
REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM Port driver structure"));
@@ -2224,7 +2224,8 @@ t_Handle FM_PORT_Config(t_FmPortParams *p_FmPortParams)
memset(p_FmPort, 0, sizeof(t_FmPort));
/* Allocate the FM driver's parameters structure */
- p_FmPort->p_FmPortDriverParam = (t_FmPortDriverParam *)XX_Malloc(sizeof(t_FmPortDriverParam));
+ p_FmPort->p_FmPortDriverParam = (t_FmPortDriverParam *)XX_Malloc(
+ sizeof(t_FmPortDriverParam));
if (!p_FmPort->p_FmPortDriverParam)
{
XX_Free(p_FmPort);
@@ -2234,197 +2235,310 @@ t_Handle FM_PORT_Config(t_FmPortParams *p_FmPortParams)
memset(p_FmPort->p_FmPortDriverParam, 0, sizeof(t_FmPortDriverParam));
/* Initialize FM port parameters which will be kept by the driver */
- p_FmPort->portType = p_FmPortParams->portType;
- p_FmPort->portId = p_FmPortParams->portId;
- p_FmPort->pcdEngines = FM_PCD_NONE;
- p_FmPort->f_Exception = p_FmPortParams->f_Exception;
- p_FmPort->h_App = p_FmPortParams->h_App;
- p_FmPort->h_Fm = p_FmPortParams->h_Fm;
+ p_FmPort->portType = p_FmPortParams->portType;
+ p_FmPort->portId = p_FmPortParams->portId;
+ p_FmPort->pcdEngines = FM_PCD_NONE;
+ p_FmPort->f_Exception = p_FmPortParams->f_Exception;
+ p_FmPort->h_App = p_FmPortParams->h_App;
+ p_FmPort->h_Fm = p_FmPortParams->h_Fm;
+
+ /* get FM revision */
+ FM_GetRevision(p_FmPort->h_Fm, &p_FmPort->fmRevInfo);
/* calculate global portId number */
- SW_PORT_ID_TO_HW_PORT_ID(p_FmPort->hardwarePortId, p_FmPort->portType, p_FmPortParams->portId);
-
- /* Initialize FM port parameters for initialization phase only */
- p_FmPort->p_FmPortDriverParam->baseAddr = baseAddr;
- p_FmPort->p_FmPortDriverParam->bufferPrefixContent.privDataSize = DEFAULT_PORT_bufferPrefixContent_privDataSize;
- p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passPrsResult= DEFAULT_PORT_bufferPrefixContent_passPrsResult;
- p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passTimeStamp= DEFAULT_PORT_bufferPrefixContent_passTimeStamp;
- p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passAllOtherPCDInfo
- = DEFAULT_PORT_bufferPrefixContent_passTimeStamp;
-#ifdef DEBUG
- p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passDebugInfo= DEFAULT_PORT_bufferPrefixContent_debugInfo;
-#endif /* DEBUG */
- p_FmPort->p_FmPortDriverParam->bufferPrefixContent.dataAlign = DEFAULT_PORT_bufferPrefixContent_dataAlign;
- p_FmPort->p_FmPortDriverParam->dmaSwapData = DEFAULT_PORT_dmaSwapData;
- p_FmPort->p_FmPortDriverParam->dmaIntContextCacheAttr = DEFAULT_PORT_dmaIntContextCacheAttr;
- p_FmPort->p_FmPortDriverParam->dmaHeaderCacheAttr = DEFAULT_PORT_dmaHeaderCacheAttr;
- p_FmPort->p_FmPortDriverParam->dmaScatterGatherCacheAttr = DEFAULT_PORT_dmaScatterGatherCacheAttr;
- p_FmPort->p_FmPortDriverParam->dmaWriteOptimize = DEFAULT_PORT_dmaWriteOptimize;
- p_FmPort->p_FmPortDriverParam->liodnBase = p_FmPortParams->liodnBase;
+ p_FmPort->hardwarePortId = SwPortIdToHwPortId(p_FmPort->portType,
+ p_FmPortParams->portId,
+ p_FmPort->fmRevInfo.majorRev,
+ p_FmPort->fmRevInfo.minorRev);
+
+ if (p_FmPort->fmRevInfo.majorRev >= 6)
+ {
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)
+ && (p_FmPortParams->portId != FM_OH_PORT_ID))
+ DBG(WARNING,
+ ("Port ID %d is recommended for HC port. Overwriting HW defaults to be suitable for HC.",
+ FM_OH_PORT_ID));
+
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ && (p_FmPortParams->portId == FM_OH_PORT_ID))
+ DBG(WARNING, ("Use non-zero portId for OP port due to insufficient resources on portId 0."));
+ }
+
+ /* Set up FM port parameters for initialization phase only */
+
+ /* First, fill in flibs struct */
+ fman_port_defconfig(&p_FmPort->p_FmPortDriverParam->dfltCfg,
+ (enum fman_port_type)p_FmPort->portType);
+ /* Overwrite some integration specific parameters */
+ p_FmPort->p_FmPortDriverParam->dfltCfg.rx_pri_elevation =
+ DEFAULT_PORT_rxFifoPriElevationLevel;
+ p_FmPort->p_FmPortDriverParam->dfltCfg.rx_fifo_thr =
+ DEFAULT_PORT_rxFifoThreshold;
+
+#if defined(FM_OP_NO_VSP_NO_RELEASE_ERRATA_FMAN_A006675) || defined(FM_ERROR_VSP_NO_MATCH_SW006)
+ p_FmPort->p_FmPortDriverParam->dfltCfg.errata_A006675 = TRUE;
+#else
+ p_FmPort->p_FmPortDriverParam->dfltCfg.errata_A006675 = FALSE;
+#endif
+ if ((p_FmPort->fmRevInfo.majorRev == 6)
+ && (p_FmPort->fmRevInfo.minorRev == 0))
+ p_FmPort->p_FmPortDriverParam->dfltCfg.errata_A006320 = TRUE;
+ else
+ p_FmPort->p_FmPortDriverParam->dfltCfg.errata_A006320 = FALSE;
- /* resource distribution. */
- p_FmPort->fifoBufs.num = DEFAULT_PORT_sizeOfFifo(p_FmPort->portType);
- p_FmPort->fifoBufs.extra = DEFAULT_PORT_extraSizeOfFifo(p_FmPort->portType);
- p_FmPort->openDmas.num = DEFAULT_PORT_numOfOpenDmas(p_FmPort->portType);
- p_FmPort->openDmas.extra = DEFAULT_PORT_extraNumOfOpenDmas(p_FmPort->portType);
- p_FmPort->tasks.num = DEFAULT_PORT_numOfTasks(p_FmPort->portType);
- p_FmPort->tasks.extra = DEFAULT_PORT_extraNumOfTasks(p_FmPort->portType);
- p_FmPort->numOfTasks = (uint8_t)p_FmPort->tasks.num;
-#ifdef FM_PORT_EXCESSIVE_BUDGET_ERRATA_FMANx16
+ /* Excessive Threshold register - exists for pre-FMv3 chips only */
+ if (p_FmPort->fmRevInfo.majorRev < 6)
{
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- {
- p_FmPort->fifoBufs.extra = 0;
- p_FmPort->openDmas.extra = 0;
- p_FmPort->tasks.extra = 0;
- }
+#ifdef FM_NO_RESTRICT_ON_ACCESS_RSRC
+ p_FmPort->p_FmPortDriverParam->dfltCfg.excessive_threshold_register =
+ TRUE;
+#endif
+ p_FmPort->p_FmPortDriverParam->dfltCfg.fmbm_rebm_has_sgd = FALSE;
+ p_FmPort->p_FmPortDriverParam->dfltCfg.fmbm_tfne_has_features = FALSE;
}
-#endif /* FM_PORT_EXCESSIVE_BUDGET_ERRATA_FMANx16 */
-
- p_FmPort->p_FmPortDriverParam->color = DEFAULT_PORT_color;
-#ifdef FM_OP_PORT_QMAN_REJECT_ERRATA_FMAN21
+ else
{
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0) &&
- (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
- p_FmPort->p_FmPortDriverParam->color = e_FM_PORT_COLOR_OVERRIDE;
+ p_FmPort->p_FmPortDriverParam->dfltCfg.excessive_threshold_register =
+ FALSE;
+ p_FmPort->p_FmPortDriverParam->dfltCfg.fmbm_rebm_has_sgd = TRUE;
+ p_FmPort->p_FmPortDriverParam->dfltCfg.fmbm_tfne_has_features = TRUE;
}
-#endif /* FM_OP_PORT_QMAN_REJECT_ERRATA_FMAN21 */
-
- if (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)
- p_FmPort->p_FmPortDriverParam->syncReq = DEFAULT_PORT_syncReqForHc;
+ if (p_FmPort->fmRevInfo.majorRev == 4)
+ p_FmPort->p_FmPortDriverParam->dfltCfg.qmi_deq_options_support = FALSE;
else
- p_FmPort->p_FmPortDriverParam->syncReq = DEFAULT_PORT_syncReq;
+ p_FmPort->p_FmPortDriverParam->dfltCfg.qmi_deq_options_support = TRUE;
-#ifdef FM_PORT_SYNC_ERRATA_FMAN6
+ /* Continue with other parameters */
+ p_FmPort->p_FmPortDriverParam->baseAddr = baseAddr;
+ /* set memory map pointers */
+ p_FmPort->p_FmPortQmiRegs =
+ (t_FmPortQmiRegs *)UINT_TO_PTR(baseAddr + QMI_PORT_REGS_OFFSET);
+ p_FmPort->p_FmPortBmiRegs =
+ (u_FmPortBmiRegs *)UINT_TO_PTR(baseAddr + BMI_PORT_REGS_OFFSET);
+ p_FmPort->p_FmPortPrsRegs =
+ (t_FmPortPrsRegs *)UINT_TO_PTR(baseAddr + PRS_PORT_REGS_OFFSET);
+
+ p_FmPort->p_FmPortDriverParam->bufferPrefixContent.privDataSize =
+ DEFAULT_PORT_bufferPrefixContent_privDataSize;
+ p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passPrsResult =
+ DEFAULT_PORT_bufferPrefixContent_passPrsResult;
+ p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passTimeStamp =
+ DEFAULT_PORT_bufferPrefixContent_passTimeStamp;
+ p_FmPort->p_FmPortDriverParam->bufferPrefixContent.passAllOtherPCDInfo =
+ DEFAULT_PORT_bufferPrefixContent_passTimeStamp;
+ p_FmPort->p_FmPortDriverParam->bufferPrefixContent.dataAlign =
+ DEFAULT_PORT_bufferPrefixContent_dataAlign;
+ /* p_FmPort->p_FmPortDriverParam->dmaSwapData = (e_FmDmaSwapOption)DEFAULT_PORT_dmaSwapData;
+ p_FmPort->p_FmPortDriverParam->dmaIntContextCacheAttr = (e_FmDmaCacheOption)DEFAULT_PORT_dmaIntContextCacheAttr;
+ p_FmPort->p_FmPortDriverParam->dmaHeaderCacheAttr = (e_FmDmaCacheOption)DEFAULT_PORT_dmaHeaderCacheAttr;
+ p_FmPort->p_FmPortDriverParam->dmaScatterGatherCacheAttr = (e_FmDmaCacheOption)DEFAULT_PORT_dmaScatterGatherCacheAttr;
+ p_FmPort->p_FmPortDriverParam->dmaWriteOptimize = DEFAULT_PORT_dmaWriteOptimize;
+ */
+ p_FmPort->p_FmPortDriverParam->liodnBase = p_FmPortParams->liodnBase;
+ p_FmPort->p_FmPortDriverParam->cheksumLastBytesIgnore =
+ DEFAULT_PORT_cheksumLastBytesIgnore;
+
+ p_FmPort->maxFrameLength = DEFAULT_PORT_maxFrameLength;
+ /* resource distribution. */
+ p_FmPort->fifoBufs.num = DEFAULT_PORT_numOfFifoBufs(p_FmPort->portType)
+ * BMI_FIFO_UNITS;
+ p_FmPort->fifoBufs.extra = DEFAULT_PORT_extraNumOfFifoBufs
+ * BMI_FIFO_UNITS;
+ p_FmPort->openDmas.num = DEFAULT_PORT_numOfOpenDmas(p_FmPort->portType);
+ p_FmPort->openDmas.extra =
+ DEFAULT_PORT_extraNumOfOpenDmas(p_FmPort->portType);
+ p_FmPort->tasks.num = DEFAULT_PORT_numOfTasks(p_FmPort->portType);
+ p_FmPort->tasks.extra = DEFAULT_PORT_extraNumOfTasks(p_FmPort->portType);
+
+
+#ifdef FM_HEAVY_TRAFFIC_SEQUENCER_HANG_ERRATA_FMAN_A006981
+ if ((p_FmPort->fmRevInfo.majorRev == 6)
+ && (p_FmPort->fmRevInfo.minorRev == 0)
+ && ((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_TX)))
{
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0) &&
- (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
- p_FmPort->p_FmPortDriverParam->syncReq = FALSE;
+ p_FmPort->openDmas.num = 16;
+ p_FmPort->openDmas.extra = 0;
}
-#endif /* FM_PORT_SYNC_ERRATA_FMAN6 */
+#endif /* FM_HEAVY_TRAFFIC_SEQUENCER_HANG_ERRATA_FMAN_A006981 */
/* Port type specific initialization: */
- if ((p_FmPort->portType != e_FM_PORT_TYPE_TX) &&
- (p_FmPort->portType != e_FM_PORT_TYPE_TX_10G))
- p_FmPort->p_FmPortDriverParam->frmDiscardOverride = DEFAULT_PORT_frmDiscardOverride;
-
- switch(p_FmPort->portType)
- {
- case(e_FM_PORT_TYPE_RX):
- case(e_FM_PORT_TYPE_RX_10G):
- /* Initialize FM port parameters for initialization phase only */
- p_FmPort->p_FmPortDriverParam->cutBytesFromEnd = DEFAULT_PORT_cutBytesFromEnd;
- p_FmPort->p_FmPortDriverParam->enBufPoolDepletion = FALSE;
- p_FmPort->p_FmPortDriverParam->frmDiscardOverride = DEFAULT_PORT_frmDiscardOverride;
- p_FmPort->p_FmPortDriverParam->rxFifoPriElevationLevel = DEFAULT_PORT_rxFifoPriElevationLevel;
- p_FmPort->p_FmPortDriverParam->rxFifoThreshold = DEFAULT_PORT_rxFifoThreshold;
- p_FmPort->p_FmPortDriverParam->bufMargins.endMargins = DEFAULT_PORT_BufMargins_endMargins;
- p_FmPort->p_FmPortDriverParam->errorsToDiscard = DEFAULT_PORT_errorsToDiscard;
- p_FmPort->p_FmPortDriverParam->cheksumLastBytesIgnore = DEFAULT_PORT_cheksumLastBytesIgnore;
- p_FmPort->p_FmPortDriverParam->forwardReuseIntContext = DEFAULT_PORT_forwardIntContextReuse;
- break;
-
- case(e_FM_PORT_TYPE_TX):
- p_FmPort->txFifoDeqPipelineDepth = DEFAULT_PORT_txFifoDeqPipelineDepth_1G;
- p_FmPort->p_FmPortDriverParam->dontReleaseBuf = FALSE;
- case(e_FM_PORT_TYPE_TX_10G):
- if(p_FmPort->portType == e_FM_PORT_TYPE_TX_10G)
- p_FmPort->txFifoDeqPipelineDepth = DEFAULT_PORT_txFifoDeqPipelineDepth_10G;
- p_FmPort->p_FmPortDriverParam->cheksumLastBytesIgnore = DEFAULT_PORT_cheksumLastBytesIgnore;
- p_FmPort->p_FmPortDriverParam->txFifoMinFillLevel = DEFAULT_PORT_txFifoMinFillLevel;
- p_FmPort->p_FmPortDriverParam->txFifoLowComfLevel = DEFAULT_PORT_txFifoLowComfLevel;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- case(e_FM_PORT_TYPE_OH_HOST_COMMAND):
- p_FmPort->p_FmPortDriverParam->deqHighPriority = DEFAULT_PORT_deqHighPriority;
- p_FmPort->p_FmPortDriverParam->deqType = DEFAULT_PORT_deqType;
-#ifdef FM_QMI_DEQ_OPTIONS_SUPPORT
- p_FmPort->p_FmPortDriverParam->deqPrefetchOption = DEFAULT_PORT_deqPrefetchOption;
-#endif /* FM_QMI_DEQ_OPTIONS_SUPPORT */
- p_FmPort->p_FmPortDriverParam->deqByteCnt = DEFAULT_PORT_deqByteCnt;
+ switch (p_FmPort->portType)
+ {
+ case (e_FM_PORT_TYPE_RX):
+ case (e_FM_PORT_TYPE_RX_10G):
+ /* Initialize FM port parameters for initialization phase only */
+ p_FmPort->p_FmPortDriverParam->cutBytesFromEnd =
+ DEFAULT_PORT_cutBytesFromEnd;
+ p_FmPort->p_FmPortDriverParam->enBufPoolDepletion = FALSE;
+ p_FmPort->p_FmPortDriverParam->frmDiscardOverride =
+ DEFAULT_PORT_frmDiscardOverride;
+
+ tmpReg =
+ GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfp);
+ p_FmPort->p_FmPortDriverParam->rxFifoPriElevationLevel =
+ (((tmpReg & BMI_RX_FIFO_PRI_ELEVATION_MASK)
+ >> BMI_RX_FIFO_PRI_ELEVATION_SHIFT) + 1)
+ * BMI_FIFO_UNITS;
+ p_FmPort->p_FmPortDriverParam->rxFifoThreshold = (((tmpReg
+ & BMI_RX_FIFO_THRESHOLD_MASK)
+ >> BMI_RX_FIFO_THRESHOLD_SHIFT) + 1) * BMI_FIFO_UNITS;
+
+ p_FmPort->p_FmPortDriverParam->bufMargins.endMargins =
+ DEFAULT_PORT_BufMargins_endMargins;
+ p_FmPort->p_FmPortDriverParam->errorsToDiscard =
+ DEFAULT_PORT_errorsToDiscard;
+ p_FmPort->p_FmPortDriverParam->forwardReuseIntContext =
+ DEFAULT_PORT_forwardIntContextReuse;
+#if (DPAA_VERSION >= 11)
+ p_FmPort->p_FmPortDriverParam->noScatherGather =
+ DEFAULT_PORT_noScatherGather;
+#endif /* (DPAA_VERSION >= 11) */
+ break;
- if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
- p_FmPort->p_FmPortDriverParam->errorsToDiscard = DEFAULT_PORT_errorsToDiscard;
- break;
+ case (e_FM_PORT_TYPE_TX):
+ p_FmPort->p_FmPortDriverParam->dontReleaseBuf = FALSE;
+#ifdef FM_WRONG_RESET_VALUES_ERRATA_FMAN_A005127
+ tmpReg = 0x00001013;
+ WRITE_UINT32( p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tfp,
+ tmpReg);
+#endif /* FM_WRONG_RESET_VALUES_ERRATA_FMAN_A005127 */
+ case (e_FM_PORT_TYPE_TX_10G):
+ tmpReg =
+ GET_UINT32(p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tfp);
+ p_FmPort->p_FmPortDriverParam->txFifoMinFillLevel = ((tmpReg
+ & BMI_TX_FIFO_MIN_FILL_MASK)
+ >> BMI_TX_FIFO_MIN_FILL_SHIFT) * BMI_FIFO_UNITS;
+ p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth =
+ (uint8_t)(((tmpReg & BMI_FIFO_PIPELINE_DEPTH_MASK)
+ >> BMI_FIFO_PIPELINE_DEPTH_SHIFT) + 1);
+ p_FmPort->p_FmPortDriverParam->txFifoLowComfLevel = (((tmpReg
+ & BMI_TX_LOW_COMF_MASK) >> BMI_TX_LOW_COMF_SHIFT) + 1)
+ * BMI_FIFO_UNITS;
+
+ p_FmPort->p_FmPortDriverParam->deqType = DEFAULT_PORT_deqType;
+ p_FmPort->p_FmPortDriverParam->deqPrefetchOption =
+ DEFAULT_PORT_deqPrefetchOption;
+ p_FmPort->p_FmPortDriverParam->deqHighPriority =
+ (bool)((p_FmPort->portType == e_FM_PORT_TYPE_TX) ? DEFAULT_PORT_deqHighPriority_1G :
+ DEFAULT_PORT_deqHighPriority_10G);
+ p_FmPort->p_FmPortDriverParam->deqByteCnt =
+ (uint16_t)(
+ (p_FmPort->portType == e_FM_PORT_TYPE_TX) ? DEFAULT_PORT_deqByteCnt_1G :
+ DEFAULT_PORT_deqByteCnt_10G);
+ break;
+ case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
+ p_FmPort->p_FmPortDriverParam->errorsToDiscard =
+ DEFAULT_PORT_errorsToDiscard;
+#if (DPAA_VERSION >= 11)
+ p_FmPort->p_FmPortDriverParam->noScatherGather =
+ DEFAULT_PORT_noScatherGather;
+#endif /* (DPAA_VERSION >= 11) */
+ case (e_FM_PORT_TYPE_OH_HOST_COMMAND):
+ p_FmPort->p_FmPortDriverParam->deqPrefetchOption =
+ DEFAULT_PORT_deqPrefetchOption_HC;
+ p_FmPort->p_FmPortDriverParam->deqHighPriority =
+ DEFAULT_PORT_deqHighPriority_1G;
+ p_FmPort->p_FmPortDriverParam->deqType = DEFAULT_PORT_deqType;
+ p_FmPort->p_FmPortDriverParam->deqByteCnt =
+ DEFAULT_PORT_deqByteCnt_1G;
+
+ tmpReg =
+ GET_UINT32(p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofp);
+ p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth =
+ (uint8_t)(((tmpReg & BMI_FIFO_PIPELINE_DEPTH_MASK)
+ >> BMI_FIFO_PIPELINE_DEPTH_SHIFT) + 1);
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)
+ && (p_FmPortParams->portId != FM_OH_PORT_ID))
+ {
+ /* Overwrite HC defaults */
+ p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth =
+ DEFAULT_PORT_fifoDeqPipelineDepth_OH;
+ }
- default:
- XX_Free(p_FmPort->p_FmPortDriverParam);
- XX_Free(p_FmPort);
- REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
- return NULL;
- }
-#ifdef FM_QMI_DEQ_OPTIONS_SUPPORT
- if (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)
- p_FmPort->p_FmPortDriverParam->deqPrefetchOption = DEFAULT_PORT_deqPrefetchOption_HC;
-#endif /* FM_QMI_DEQ_OPTIONS_SUPPORT */
+#ifndef FM_FRAME_END_PARAMS_FOR_OP
+ if (p_FmPort->fmRevInfo.majorRev < 6)
+ p_FmPort->p_FmPortDriverParam->cheksumLastBytesIgnore = DEFAULT_notSupported;
+#endif /* !FM_FRAME_END_PARAMS_FOR_OP */
- if ((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING) ||
- (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND))
- p_FmPort->txFifoDeqPipelineDepth = OH_PIPELINE_DEPTH;
+#ifndef FM_DEQ_PIPELINE_PARAMS_FOR_OP
+ if (!((p_FmPort->fmRevInfo.majorRev == 4) ||
+ (p_FmPort->fmRevInfo.majorRev >= 6)))
+ p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth = DEFAULT_notSupported;
+#endif /* !FM_DEQ_PIPELINE_PARAMS_FOR_OP */
+ break;
+
+ default:
+ XX_Free(p_FmPort->p_FmPortDriverParam);
+ XX_Free(p_FmPort);
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
+ return NULL;
+ }
+#ifdef FM_QMI_NO_DEQ_OPTIONS_SUPPORT
+ if (p_FmPort->fmRevInfo.majorRev == 4)
+ p_FmPort->p_FmPortDriverParam->deqPrefetchOption = (e_FmPortDeqPrefetchOption)DEFAULT_notSupported;
+#endif /* FM_QMI_NO_DEQ_OPTIONS_SUPPORT */
p_FmPort->imEn = p_FmPortParams->independentModeEnable;
if (p_FmPort->imEn)
{
- if ((p_FmPort->portType == e_FM_PORT_TYPE_TX) ||
- (p_FmPort->portType == e_FM_PORT_TYPE_TX_10G))
- p_FmPort->txFifoDeqPipelineDepth = DEFAULT_PORT_txFifoDeqPipelineDepth_IM;
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_TX)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_TX_10G))
+ p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth =
+ DEFAULT_PORT_fifoDeqPipelineDepth_IM;
FmPortConfigIM(p_FmPort, p_FmPortParams);
}
else
{
- switch(p_FmPort->portType)
- {
- case(e_FM_PORT_TYPE_RX):
- case(e_FM_PORT_TYPE_RX_10G):
- /* Initialize FM port parameters for initialization phase only */
- memcpy(&p_FmPort->p_FmPortDriverParam->extBufPools,
- &p_FmPortParams->specificParams.rxParams.extBufPools,
- sizeof(t_FmPortExtPools));
- p_FmPort->p_FmPortDriverParam->errFqid = p_FmPortParams->specificParams.rxParams.errFqid;
- p_FmPort->p_FmPortDriverParam->dfltFqid = p_FmPortParams->specificParams.rxParams.dfltFqid;
- p_FmPort->p_FmPortDriverParam->liodnOffset = p_FmPortParams->specificParams.rxParams.liodnOffset;
- break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
-#ifdef FM_OP_PARTITION_ERRATA_FMANx8
+ switch (p_FmPort->portType)
{
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- p_FmPort->p_FmPortDriverParam->liodnOffset = p_FmPortParams->specificParams.nonRxParams.opLiodnOffset;
- }
-#endif /* FM_OP_PARTITION_ERRATA_FMANx8 */
- case(e_FM_PORT_TYPE_TX):
- case(e_FM_PORT_TYPE_TX_10G):
- case(e_FM_PORT_TYPE_OH_HOST_COMMAND):
- p_FmPort->p_FmPortDriverParam->errFqid = p_FmPortParams->specificParams.nonRxParams.errFqid;
- p_FmPort->p_FmPortDriverParam->deqSubPortal =
- (uint8_t)(p_FmPortParams->specificParams.nonRxParams.qmChannel & QMI_DEQ_CFG_SUBPORTAL_MASK);
- p_FmPort->p_FmPortDriverParam->dfltFqid = p_FmPortParams->specificParams.nonRxParams.dfltFqid;
- break;
- default:
- XX_Free(p_FmPort->p_FmPortDriverParam);
- XX_Free(p_FmPort);
- REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
- return NULL;
+ case (e_FM_PORT_TYPE_RX):
+ case (e_FM_PORT_TYPE_RX_10G):
+ /* Initialize FM port parameters for initialization phase only */
+ memcpy(&p_FmPort->p_FmPortDriverParam->extBufPools,
+ &p_FmPortParams->specificParams.rxParams.extBufPools,
+ sizeof(t_FmExtPools));
+ p_FmPort->p_FmPortDriverParam->errFqid =
+ p_FmPortParams->specificParams.rxParams.errFqid;
+ p_FmPort->p_FmPortDriverParam->dfltFqid =
+ p_FmPortParams->specificParams.rxParams.dfltFqid;
+ p_FmPort->p_FmPortDriverParam->liodnOffset =
+ p_FmPortParams->specificParams.rxParams.liodnOffset;
+ break;
+ case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
+ case (e_FM_PORT_TYPE_TX):
+ case (e_FM_PORT_TYPE_TX_10G):
+ case (e_FM_PORT_TYPE_OH_HOST_COMMAND):
+ p_FmPort->p_FmPortDriverParam->errFqid =
+ p_FmPortParams->specificParams.nonRxParams.errFqid;
+ p_FmPort->p_FmPortDriverParam->deqSubPortal =
+ (uint8_t)(p_FmPortParams->specificParams.nonRxParams.qmChannel
+ & QMI_DEQ_CFG_SUBPORTAL_MASK);
+ p_FmPort->p_FmPortDriverParam->dfltFqid =
+ p_FmPortParams->specificParams.nonRxParams.dfltFqid;
+ break;
+ default:
+ XX_Free(p_FmPort->p_FmPortDriverParam);
+ XX_Free(p_FmPort);
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
+ return NULL;
}
}
memset(p_FmPort->name, 0, (sizeof(char)) * MODULE_NAME_SIZE);
- if(Sprint (p_FmPort->name, "FM-%d-port-%s-%d",
- FmGetId(p_FmPort->h_Fm),
- ((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING ||
- (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)) ?
- "OH" : (p_FmPort->portType == e_FM_PORT_TYPE_RX ?
- "1g-RX" : (p_FmPort->portType == e_FM_PORT_TYPE_TX ?
- "1g-TX" : (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G ?
- "10g-RX" : "10g-TX")))),
- p_FmPort->portId) == 0)
+ if (Sprint(
+ p_FmPort->name,
+ "FM-%d-port-%s-%d",
+ FmGetId(p_FmPort->h_Fm),
+ ((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING
+ || (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)) ? "OH" :
+ (p_FmPort->portType == e_FM_PORT_TYPE_RX ? "1g-RX" :
+ (p_FmPort->portType == e_FM_PORT_TYPE_TX ? "1g-TX" :
+ (p_FmPort->portType
+ == e_FM_PORT_TYPE_RX_10G ? "10g-RX" :
+ "10g-TX")))),
+ p_FmPort->portId) == 0)
{
XX_Free(p_FmPort->p_FmPortDriverParam);
XX_Free(p_FmPort);
@@ -2444,6 +2558,9 @@ t_Handle FM_PORT_Config(t_FmPortParams *p_FmPortParams)
return p_FmPort;
}
+t_FmPort *rx_port = 0;
+t_FmPort *tx_port = 0;
+
/**************************************************************************//**
@Function FM_PORT_Init
@@ -2452,137 +2569,183 @@ t_Handle FM_PORT_Config(t_FmPortParams *p_FmPortParams)
@Param[in] h_FmPort - FM module descriptor
@Return E_OK on success; Error code otherwise.
-*//***************************************************************************/
+ *//***************************************************************************/
t_Error FM_PORT_Init(t_Handle h_FmPort)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- t_FmPortDriverParam *p_Params;
- t_Error err = E_OK;
- t_FmInterModulePortInitParams fmParams;
- uint32_t minFifoSizeRequired = 0;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_FmPortDriverParam *p_DriverParams;
+ t_Error errCode;
+ t_FmInterModulePortInitParams fmParams;
+ t_FmRevisionInfo revInfo;
SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if ((err = BuildBufferStructure(p_FmPort)) != E_OK)
- RETURN_ERROR(MINOR, err, NO_MSG);
+ errCode = FmSpBuildBufferStructure(
+ &p_FmPort->p_FmPortDriverParam->intContext,
+ &p_FmPort->p_FmPortDriverParam->bufferPrefixContent,
+ &p_FmPort->p_FmPortDriverParam->bufMargins,
+ &p_FmPort->bufferOffsets, &p_FmPort->internalBufferOffset);
+ if (errCode != E_OK)
+ RETURN_ERROR(MAJOR, errCode, NO_MSG);
+#ifdef FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669
+ if ((p_FmPort->p_FmPortDriverParam->bcbWorkaround) &&
+ (p_FmPort->portType == e_FM_PORT_TYPE_RX))
+ {
+ p_FmPort->p_FmPortDriverParam->errorsToDiscard |= FM_PORT_FRM_ERR_PHYSICAL;
+ if (!p_FmPort->fifoBufs.num)
+ p_FmPort->fifoBufs.num = DEFAULT_PORT_numOfFifoBufs(p_FmPort->portType)*BMI_FIFO_UNITS;
+ p_FmPort->fifoBufs.num += 4*KILOBYTE;
+ }
+#endif /* FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669 */
CHECK_INIT_PARAMETERS(p_FmPort, CheckInitParameters);
- p_Params = p_FmPort->p_FmPortDriverParam;
-
- /* set memory map pointers */
- p_FmPort->p_FmPortQmiRegs = (t_FmPortQmiRegs *)UINT_TO_PTR(p_Params->baseAddr + QMI_PORT_REGS_OFFSET);
- p_FmPort->p_FmPortBmiRegs = (u_FmPortBmiRegs *)UINT_TO_PTR(p_Params->baseAddr + BMI_PORT_REGS_OFFSET);
- p_FmPort->p_FmPortPrsRegs = (t_FmPortPrsRegs *)UINT_TO_PTR(p_Params->baseAddr + PRS_PORT_REGS_OFFSET);
+ p_DriverParams = p_FmPort->p_FmPortDriverParam;
- /* For O/H ports, check fifo size and update if necessary */
- if ((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING) || (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND))
+ /* Set up flibs port structure */
+ memset(&p_FmPort->port, 0, sizeof(struct fman_port));
+ p_FmPort->port.type = (enum fman_port_type)p_FmPort->portType;
+ FM_GetRevision(p_FmPort->h_Fm, &revInfo);
+ p_FmPort->port.fm_rev_maj = revInfo.majorRev;
+ p_FmPort->port.fm_rev_min = revInfo.minorRev;
+ p_FmPort->port.bmi_regs =
+ (union fman_port_bmi_regs *)UINT_TO_PTR(p_DriverParams->baseAddr + BMI_PORT_REGS_OFFSET);
+ p_FmPort->port.qmi_regs =
+ (struct fman_port_qmi_regs *)UINT_TO_PTR(p_DriverParams->baseAddr + QMI_PORT_REGS_OFFSET);
+ p_FmPort->port.ext_pools_num = (uint8_t)((revInfo.majorRev == 4) ? 4 : 8);
+ p_FmPort->port.im_en = p_FmPort->imEn;
+ p_FmPort->p_FmPortPrsRegs =
+ (t_FmPortPrsRegs *)UINT_TO_PTR(p_DriverParams->baseAddr + PRS_PORT_REGS_OFFSET);
+
+ if (((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_RX)) && !p_FmPort->imEn)
+ {
+ /* Call the external Buffer routine which also checks fifo
+ size and updates it if necessary */
+ /* define external buffer pools and pool depletion*/
+ errCode = SetExtBufferPools(p_FmPort);
+ if (errCode)
+ RETURN_ERROR(MAJOR, errCode, NO_MSG);
+ /* check if the largest external buffer pool is large enough */
+ if (p_DriverParams->bufMargins.startMargins + MIN_EXT_BUF_SIZE
+ + p_DriverParams->bufMargins.endMargins
+ > p_FmPort->rxPoolsParams.largestBufSize)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("bufMargins.startMargins (%d) + minimum buf size (64) + bufMargins.endMargins (%d) is larger than maximum external buffer size (%d)", p_DriverParams->bufMargins.startMargins, p_DriverParams->bufMargins.endMargins, p_FmPort->rxPoolsParams.largestBufSize));
+ }
+ if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
{
- minFifoSizeRequired = (uint32_t)((p_FmPort->txFifoDeqPipelineDepth+4)*BMI_FIFO_UNITS);
- if (p_FmPort->fifoBufs.num < minFifoSizeRequired)
{
- p_FmPort->fifoBufs.num = minFifoSizeRequired;
- DBG(WARNING, ("FIFO size enlarged to %d due to txFifoDeqPipelineDepth size", minFifoSizeRequired));
- }
- }
+#ifdef FM_NO_OP_OBSERVED_POOLS
+ t_FmRevisionInfo revInfo;
- /* For Rx Ports, call the external Buffer routine which also checks fifo
- size and updates it if necessary */
- if(((p_FmPort->portType == e_FM_PORT_TYPE_RX) || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
- && !p_FmPort->imEn)
- {
- /* define external buffer pools and pool depletion*/
- err = SetExtBufferPools(p_FmPort);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
+ FM_GetRevision(p_FmPort->h_Fm, &revInfo);
+ if ((revInfo.majorRev == 4) && (p_DriverParams->enBufPoolDepletion))
+#endif /* FM_NO_OP_OBSERVED_POOLS */
+ {
+ /* define external buffer pools */
+ errCode = SetExtBufferPools(p_FmPort);
+ if (errCode)
+ RETURN_ERROR(MAJOR, errCode, NO_MSG);
+ }
+ }
}
/************************************************************/
/* Call FM module routine for communicating parameters */
/************************************************************/
memset(&fmParams, 0, sizeof(fmParams));
- fmParams.hardwarePortId = p_FmPort->hardwarePortId;
- fmParams.portType = (e_FmPortType)p_FmPort->portType;
- fmParams.numOfTasks = (uint8_t)p_FmPort->tasks.num;
- fmParams.numOfExtraTasks = (uint8_t)p_FmPort->tasks.extra;
- fmParams.numOfOpenDmas = (uint8_t)p_FmPort->openDmas.num;
+ fmParams.hardwarePortId = p_FmPort->hardwarePortId;
+ fmParams.portType = (e_FmPortType)p_FmPort->portType;
+ fmParams.numOfTasks = (uint8_t)p_FmPort->tasks.num;
+ fmParams.numOfExtraTasks = (uint8_t)p_FmPort->tasks.extra;
+ fmParams.numOfOpenDmas = (uint8_t)p_FmPort->openDmas.num;
fmParams.numOfExtraOpenDmas = (uint8_t)p_FmPort->openDmas.extra;
- fmParams.sizeOfFifo = p_FmPort->fifoBufs.num;
- fmParams.extraSizeOfFifo = p_FmPort->fifoBufs.extra;
- fmParams.independentMode = p_FmPort->imEn;
- fmParams.liodnOffset = p_Params->liodnOffset;
- fmParams.liodnBase = p_Params->liodnBase;
- switch(p_FmPort->portType)
+ if (p_FmPort->fifoBufs.num)
+ {
+ errCode = VerifySizeOfFifo(p_FmPort);
+ if (errCode != E_OK)
+ RETURN_ERROR(MAJOR, errCode, NO_MSG);
+ }
+ fmParams.sizeOfFifo = p_FmPort->fifoBufs.num;
+ fmParams.extraSizeOfFifo = p_FmPort->fifoBufs.extra;
+ fmParams.independentMode = p_FmPort->imEn;
+ fmParams.liodnOffset = p_DriverParams->liodnOffset;
+ fmParams.liodnBase = p_DriverParams->liodnBase;
+ fmParams.deqPipelineDepth =
+ p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth;
+ fmParams.maxFrameLength = p_FmPort->maxFrameLength;
+#ifndef FM_DEQ_PIPELINE_PARAMS_FOR_OP
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING) ||
+ (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND))
{
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- break;
- case(e_FM_PORT_TYPE_TX_10G):
- case(e_FM_PORT_TYPE_TX):
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- case(e_FM_PORT_TYPE_OH_HOST_COMMAND):
- fmParams.deqPipelineDepth = p_FmPort->txFifoDeqPipelineDepth;
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
+ if (!((p_FmPort->fmRevInfo.majorRev == 4) ||
+ (p_FmPort->fmRevInfo.majorRev >= 6)))
+ /* HC ports do not have fifoDeqPipelineDepth, but it is needed only
+ * for deq threshold calculation.
+ */
+ fmParams.deqPipelineDepth = 2;
}
+#endif /* !FM_DEQ_PIPELINE_PARAMS_FOR_OP */
- err = FmGetSetPortParams(p_FmPort->h_Fm, &fmParams);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
-
- p_FmPort->tasks.num = fmParams.numOfTasks;
- p_FmPort->tasks.extra = fmParams.numOfExtraTasks;
- p_FmPort->openDmas.num = fmParams.numOfOpenDmas;
- p_FmPort->openDmas.extra = fmParams.numOfExtraOpenDmas;
- p_FmPort->fifoBufs.num = fmParams.sizeOfFifo;
- p_FmPort->fifoBufs.extra = fmParams.extraSizeOfFifo;
+ errCode = FmGetSetPortParams(p_FmPort->h_Fm, &fmParams);
+ if (errCode)
+ RETURN_ERROR(MAJOR, errCode, NO_MSG);
/* get params for use in init */
- p_Params->fmMuramPhysBaseAddr =
- (uint64_t)((uint64_t)(fmParams.fmMuramPhysBaseAddr.low) |
- ((uint64_t)(fmParams.fmMuramPhysBaseAddr.high) << 32));
-
- /**********************/
- /* Init BMI Registers */
- /**********************/
- switch(p_FmPort->portType)
- {
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- err = BmiRxPortInit(p_FmPort);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
- break;
- case(e_FM_PORT_TYPE_TX_10G):
- case(e_FM_PORT_TYPE_TX):
- err = BmiTxPortInit(p_FmPort);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
- break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- case(e_FM_PORT_TYPE_OH_HOST_COMMAND):
- err = BmiOhPortInit(p_FmPort);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
- }
+ p_FmPort->fmMuramPhysBaseAddr =
+ (uint64_t)((uint64_t)(fmParams.fmMuramPhysBaseAddr.low)
+ | ((uint64_t)(fmParams.fmMuramPhysBaseAddr.high) << 32));
+ p_FmPort->h_FmMuram = FmGetMuramHandle(p_FmPort->h_Fm);
- /**********************/
- /* Init QMI Registers */
- /**********************/
- if (!p_FmPort->imEn && ((err = QmiInit(p_FmPort)) != E_OK))
- RETURN_ERROR(MAJOR, err, NO_MSG);
-
- if (p_FmPort->imEn && ((err = FmPortImInit(p_FmPort)) != E_OK))
- RETURN_ERROR(MAJOR, err, NO_MSG);
+ errCode = InitLowLevelDriver(p_FmPort);
+ if (errCode != E_OK)
+ RETURN_ERROR(MAJOR, errCode, NO_MSG);
FmPortDriverParamFree(p_FmPort);
+#if (DPAA_VERSION >= 11)
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_RX)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
+ {
+ t_FmPcdCtrlParamsPage *p_ParamsPage;
+
+ FmPortSetGprFunc(p_FmPort, e_FM_PORT_GPR_MURAM_PAGE,
+ (void**)&p_ParamsPage);
+ ASSERT_COND(p_ParamsPage);
+
+ WRITE_UINT32(p_ParamsPage->misc, FM_CTL_PARAMS_PAGE_ALWAYS_ON);
+#ifdef FM_OP_NO_VSP_NO_RELEASE_ERRATA_FMAN_A006675
+ if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ {
+ WRITE_UINT32(
+ p_ParamsPage->misc,
+ (GET_UINT32(p_ParamsPage->misc) | FM_CTL_PARAMS_PAGE_OP_FIX_EN));
+ WRITE_UINT32(
+ p_ParamsPage->discardMask,
+ GET_UINT32(p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofsdm));
+ }
+#endif /* FM_OP_NO_VSP_NO_RELEASE_ERRATA_FMAN_A006675 */
+#ifdef FM_ERROR_VSP_NO_MATCH_SW006
+ if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ WRITE_UINT32(
+ p_ParamsPage->errorsDiscardMask,
+ (GET_UINT32(p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofsdm) | GET_UINT32(p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofsem)));
+ else
+ WRITE_UINT32(
+ p_ParamsPage->errorsDiscardMask,
+ (GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfsdm) | GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfsem)));
+#endif /* FM_ERROR_VSP_NO_MATCH_SW006 */
+ }
+#endif /* (DPAA_VERSION >= 11) */
+
+ if (p_FmPort->deepSleepVars.autoResMaxSizes)
+ FmPortConfigAutoResForDeepSleepSupport1(p_FmPort);
return E_OK;
}
@@ -2591,21 +2754,24 @@ t_Error FM_PORT_Init(t_Handle h_FmPort)
@Description Frees all resources that were assigned to FM module.
- Calling this routine invalidates the descriptor.
+ Calling this routine invalidates the descriptor.
@Param[in] h_FmPort - FM module descriptor
@Return E_OK on success; Error code otherwise.
-*//***************************************************************************/
+ *//***************************************************************************/
t_Error FM_PORT_Free(t_Handle h_FmPort)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- t_FmInterModulePortFreeParams fmParams;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_FmInterModulePortFreeParams fmParams;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
- if(p_FmPort->pcdEngines)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Trying to free a port with PCD. FM_PORT_DeletePCD must be called first."));
+ if (p_FmPort->pcdEngines)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("Trying to free a port with PCD. FM_PORT_DeletePCD must be called first."));
if (p_FmPort->enabled)
{
@@ -2613,19 +2779,28 @@ t_Error FM_PORT_Free(t_Handle h_FmPort)
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM_PORT_Disable FAILED"));
}
- FmPortDriverParamFree(p_FmPort);
-
if (p_FmPort->imEn)
FmPortImFree(p_FmPort);
+ FmPortDriverParamFree(p_FmPort);
+
+ memset(&fmParams, 0, sizeof(fmParams));
fmParams.hardwarePortId = p_FmPort->hardwarePortId;
fmParams.portType = (e_FmPortType)p_FmPort->portType;
-#ifdef FM_QMI_DEQ_OPTIONS_SUPPORT
- fmParams.deqPipelineDepth = p_FmPort->txFifoDeqPipelineDepth;
-#endif /* FM_QMI_DEQ_OPTIONS_SUPPORT */
+ fmParams.deqPipelineDepth =
+ p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth;
FmFreePortParams(p_FmPort->h_Fm, &fmParams);
-
+
+#if (DPAA_VERSION >= 11)
+ if (FmVSPFreeForPort(p_FmPort->h_Fm, p_FmPort->portType, p_FmPort->portId)
+ != E_OK)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("VSP free of port FAILED"));
+
+ if (p_FmPort->p_ParamsPage)
+ FM_MURAM_FreeMem(p_FmPort->h_FmMuram, p_FmPort->p_ParamsPage);
+#endif /* (DPAA_VERSION >= 11) */
+
if (p_FmPort->h_Spinlock)
XX_FreeSpinlock(p_FmPort->h_Spinlock);
@@ -2634,21 +2809,59 @@ t_Error FM_PORT_Free(t_Handle h_FmPort)
return E_OK;
}
-
/*************************************************/
/* API Advanced Init unit functions */
/*************************************************/
+t_Error FM_PORT_ConfigNumOfOpenDmas(t_Handle h_FmPort, t_FmPortRsrc *p_OpenDmas)
+{
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
+
+ p_FmPort->p_FmPortDriverParam->setNumOfOpenDmas = TRUE;
+ memcpy(&p_FmPort->openDmas, p_OpenDmas, sizeof(t_FmPortRsrc));
+
+ return E_OK;
+}
+
+t_Error FM_PORT_ConfigNumOfTasks(t_Handle h_FmPort, t_FmPortRsrc *p_NumOfTasks)
+{
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
+
+ memcpy(&p_FmPort->tasks, p_NumOfTasks, sizeof(t_FmPortRsrc));
+ p_FmPort->p_FmPortDriverParam->setNumOfTasks = TRUE;
+ return E_OK;
+}
+
+t_Error FM_PORT_ConfigSizeOfFifo(t_Handle h_FmPort, t_FmPortRsrc *p_SizeOfFifo)
+{
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
+
+ p_FmPort->p_FmPortDriverParam->setSizeOfFifo = TRUE;
+ memcpy(&p_FmPort->fifoBufs, p_SizeOfFifo, sizeof(t_FmPortRsrc));
+
+ return E_OK;
+}
+
t_Error FM_PORT_ConfigDeqHighPriority(t_Handle h_FmPort, bool highPri)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G) || (p_FmPort->portType == e_FM_PORT_TYPE_RX))
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_RX))
RETURN_ERROR(MAJOR, E_NO_MEMORY, ("not available for Rx ports"));
- p_FmPort->p_FmPortDriverParam->deqHighPriority = highPri;
+ p_FmPort->p_FmPortDriverParam->dfltCfg.deq_high_pri = highPri;
return E_OK;
}
@@ -2659,50 +2872,52 @@ t_Error FM_PORT_ConfigDeqType(t_Handle h_FmPort, e_FmPortDeqType deqType)
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G) || (p_FmPort->portType == e_FM_PORT_TYPE_RX))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("not available for Rx ports"));
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_RX))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("not available for Rx ports"));
- p_FmPort->p_FmPortDriverParam->deqType = deqType;
+ p_FmPort->p_FmPortDriverParam->dfltCfg.deq_type =
+ (enum fman_port_deq_type)deqType;
return E_OK;
}
-#ifdef FM_QMI_DEQ_OPTIONS_SUPPORT
-t_Error FM_PORT_ConfigDeqPrefetchOption(t_Handle h_FmPort, e_FmPortDeqPrefetchOption deqPrefetchOption)
+t_Error FM_PORT_ConfigDeqPrefetchOption(
+ t_Handle h_FmPort, e_FmPortDeqPrefetchOption deqPrefetchOption)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G) || (p_FmPort->portType == e_FM_PORT_TYPE_RX))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("not available for Rx ports"));
- p_FmPort->p_FmPortDriverParam->deqPrefetchOption = deqPrefetchOption;
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_RX))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("not available for Rx ports"));
+ p_FmPort->p_FmPortDriverParam->dfltCfg.deq_prefetch_opt =
+ (enum fman_port_deq_prefetch)deqPrefetchOption;
+
return E_OK;
}
-#endif /* FM_QMI_DEQ_OPTIONS_SUPPORT */
-t_Error FM_PORT_ConfigBackupPools(t_Handle h_FmPort, t_FmPortBackupBmPools *p_BackupBmPools)
+t_Error FM_PORT_ConfigBackupPools(t_Handle h_FmPort,
+ t_FmBackupBmPools *p_BackupBmPools)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
-#ifdef FM_NO_BACKUP_POOLS
- t_FmRevisionInfo revInfo;
-#endif /* FM_NO_BACKUP_POOLS */
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx ports only"));
-
-#ifdef FM_NO_BACKUP_POOLS
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if (revInfo.majorRev != 4)
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("FM_PORT_ConfigBackupPools"));
-#endif /* FM_NO_BACKUP_POOLS */
-
- p_FmPort->p_FmPortDriverParam->p_BackupBmPools = (t_FmPortBackupBmPools *)XX_Malloc(sizeof(t_FmPortBackupBmPools));
- if(!p_FmPort->p_FmPortDriverParam->p_BackupBmPools)
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for Rx ports only"));
+
+ p_FmPort->p_FmPortDriverParam->p_BackupBmPools =
+ (t_FmBackupBmPools *)XX_Malloc(sizeof(t_FmBackupBmPools));
+ if (!p_FmPort->p_FmPortDriverParam->p_BackupBmPools)
RETURN_ERROR(MAJOR, E_NO_MEMORY, ("p_BackupBmPools allocation failed"));
- memcpy(p_FmPort->p_FmPortDriverParam->p_BackupBmPools, p_BackupBmPools, sizeof(t_FmPortBackupBmPools));
+ memcpy(p_FmPort->p_FmPortDriverParam->p_BackupBmPools, p_BackupBmPools,
+ sizeof(t_FmBackupBmPools));
return E_OK;
}
@@ -2713,370 +2928,455 @@ t_Error FM_PORT_ConfigDeqByteCnt(t_Handle h_FmPort, uint16_t deqByteCnt)
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G) || (p_FmPort->portType == e_FM_PORT_TYPE_RX))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("not available for Rx ports"));
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_RX))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("not available for Rx ports"));
- p_FmPort->p_FmPortDriverParam->deqByteCnt = deqByteCnt;
+ p_FmPort->p_FmPortDriverParam->dfltCfg.deq_byte_cnt = deqByteCnt;
return E_OK;
}
-t_Error FM_PORT_ConfigBufferPrefixContent(t_Handle h_FmPort, t_FmPortBufferPrefixContent *p_FmPortBufferPrefixContent)
+t_Error FM_PORT_ConfigBufferPrefixContent(
+ t_Handle h_FmPort, t_FmBufferPrefixContent *p_FmBufferPrefixContent)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- memcpy(&p_FmPort->p_FmPortDriverParam->bufferPrefixContent, p_FmPortBufferPrefixContent, sizeof(t_FmPortBufferPrefixContent));
- /* if dataAlign was not initialized by user, we return to driver's deafult */
+ memcpy(&p_FmPort->p_FmPortDriverParam->bufferPrefixContent,
+ p_FmBufferPrefixContent, sizeof(t_FmBufferPrefixContent));
+ /* if dataAlign was not initialized by user, we return to driver's default */
if (!p_FmPort->p_FmPortDriverParam->bufferPrefixContent.dataAlign)
- p_FmPort->p_FmPortDriverParam->bufferPrefixContent.dataAlign = DEFAULT_PORT_bufferPrefixContent_dataAlign;
+ p_FmPort->p_FmPortDriverParam->bufferPrefixContent.dataAlign =
+ DEFAULT_PORT_bufferPrefixContent_dataAlign;
return E_OK;
}
-t_Error FM_PORT_ConfigCheksumLastBytesIgnore(t_Handle h_FmPort, uint8_t cheksumLastBytesIgnore)
+t_Error FM_PORT_ConfigCheksumLastBytesIgnore(t_Handle h_FmPort,
+ uint8_t checksumLastBytesIgnore)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING) || (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx & Tx ports only"));
- p_FmPort->p_FmPortDriverParam->cheksumLastBytesIgnore = cheksumLastBytesIgnore;
+ p_FmPort->p_FmPortDriverParam->dfltCfg.checksum_bytes_ignore =
+ checksumLastBytesIgnore;
return E_OK;
}
-t_Error FM_PORT_ConfigCutBytesFromEnd(t_Handle h_FmPort, uint8_t cutBytesFromEnd)
+t_Error FM_PORT_ConfigCutBytesFromEnd(t_Handle h_FmPort,
+ uint8_t cutBytesFromEnd)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx ports only"));
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for Rx ports only"));
- p_FmPort->p_FmPortDriverParam->cutBytesFromEnd = cutBytesFromEnd;
+ p_FmPort->p_FmPortDriverParam->dfltCfg.rx_cut_end_bytes = cutBytesFromEnd;
return E_OK;
}
-t_Error FM_PORT_ConfigPoolDepletion(t_Handle h_FmPort, t_FmPortBufPoolDepletion *p_BufPoolDepletion)
+t_Error FM_PORT_ConfigPoolDepletion(t_Handle h_FmPort,
+ t_FmBufPoolDepletion *p_BufPoolDepletion)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx ports only"));
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for Rx ports only"));
p_FmPort->p_FmPortDriverParam->enBufPoolDepletion = TRUE;
- memcpy(&p_FmPort->p_FmPortDriverParam->bufPoolDepletion, p_BufPoolDepletion, sizeof(t_FmPortBufPoolDepletion));
+ memcpy(&p_FmPort->p_FmPortDriverParam->bufPoolDepletion, p_BufPoolDepletion,
+ sizeof(t_FmBufPoolDepletion));
return E_OK;
}
-t_Error FM_PORT_ConfigObservedPoolDepletion(t_Handle h_FmPort, t_FmPortObservedBufPoolDepletion *p_FmPortObservedBufPoolDepletion)
+t_Error FM_PORT_ConfigObservedPoolDepletion(
+ t_Handle h_FmPort,
+ t_FmPortObservedBufPoolDepletion *p_FmPortObservedBufPoolDepletion)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if(p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for OP ports only"));
+ if (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for OP ports only"));
p_FmPort->p_FmPortDriverParam->enBufPoolDepletion = TRUE;
- memcpy(&p_FmPort->p_FmPortDriverParam->bufPoolDepletion, &p_FmPortObservedBufPoolDepletion->poolDepletionParams, sizeof(t_FmPortBufPoolDepletion));
- memcpy(&p_FmPort->p_FmPortDriverParam->extBufPools, &p_FmPortObservedBufPoolDepletion->poolsParams, sizeof(t_FmPortExtPools));
+ memcpy(&p_FmPort->p_FmPortDriverParam->bufPoolDepletion,
+ &p_FmPortObservedBufPoolDepletion->poolDepletionParams,
+ sizeof(t_FmBufPoolDepletion));
+ memcpy(&p_FmPort->p_FmPortDriverParam->extBufPools,
+ &p_FmPortObservedBufPoolDepletion->poolsParams,
+ sizeof(t_FmExtPools));
return E_OK;
}
-t_Error FM_PORT_ConfigExtBufPools(t_Handle h_FmPort, t_FmPortExtPools *p_FmPortExtPools)
+t_Error FM_PORT_ConfigExtBufPools(t_Handle h_FmPort, t_FmExtPools *p_FmExtPools)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if(p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for OP ports only"));
- memcpy(&p_FmPort->p_FmPortDriverParam->extBufPools, p_FmPortExtPools, sizeof(t_FmPortExtPools));
+ if (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for OP ports only"));
+
+ memcpy(&p_FmPort->p_FmPortDriverParam->extBufPools, p_FmExtPools,
+ sizeof(t_FmExtPools));
return E_OK;
}
-t_Error FM_PORT_ConfigRxFifoThreshold(t_Handle h_FmPort, uint32_t fifoThreshold)
+t_Error FM_PORT_ConfigDontReleaseTxBufToBM(t_Handle h_FmPort)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx ports only"));
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_TX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_TX))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for Tx ports only"));
- p_FmPort->p_FmPortDriverParam->rxFifoThreshold = fifoThreshold;
+ p_FmPort->p_FmPortDriverParam->dontReleaseBuf = TRUE;
return E_OK;
}
-t_Error FM_PORT_ConfigRxFifoPriElevationLevel(t_Handle h_FmPort, uint32_t priElevationLevel)
+t_Error FM_PORT_ConfigDfltColor(t_Handle h_FmPort, e_FmPortColor color)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx ports only"));
-
- p_FmPort->p_FmPortDriverParam->rxFifoPriElevationLevel = priElevationLevel;
+ p_FmPort->p_FmPortDriverParam->dfltCfg.color = (enum fman_port_color)color;
return E_OK;
}
-t_Error FM_PORT_ConfigTxFifoMinFillLevel(t_Handle h_FmPort, uint32_t minFillLevel)
+t_Error FM_PORT_ConfigSyncReq(t_Handle h_FmPort, bool syncReq)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType != e_FM_PORT_TYPE_TX_10G) && (p_FmPort->portType != e_FM_PORT_TYPE_TX))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Tx ports only"));
- p_FmPort->p_FmPortDriverParam->txFifoMinFillLevel = minFillLevel;
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_TX_10G)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_TX))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("Not available for Tx ports"));
+
+ p_FmPort->p_FmPortDriverParam->dfltCfg.sync_req = syncReq;
return E_OK;
}
-t_Error FM_PORT_ConfigTxFifoDeqPipelineDepth(t_Handle h_FmPort, uint8_t deqPipelineDepth)
+t_Error FM_PORT_ConfigFrmDiscardOverride(t_Handle h_FmPort, bool override)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if ((p_FmPort->portType != e_FM_PORT_TYPE_TX_10G) &&
- (p_FmPort->portType != e_FM_PORT_TYPE_TX))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Tx ports only"));
- if (p_FmPort->imEn)
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("Not available for IM ports!"));
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_TX_10G)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_TX))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("Not available for Tx ports"));
- p_FmPort->txFifoDeqPipelineDepth = deqPipelineDepth;
+ p_FmPort->p_FmPortDriverParam->dfltCfg.discard_override = override;
return E_OK;
}
-t_Error FM_PORT_ConfigTxFifoLowComfLevel(t_Handle h_FmPort, uint32_t fifoLowComfLevel)
+t_Error FM_PORT_ConfigErrorsToDiscard(t_Handle h_FmPort,
+ fmPortFrameErrSelect_t errs)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType != e_FM_PORT_TYPE_TX_10G) && (p_FmPort->portType != e_FM_PORT_TYPE_TX))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Tx ports only"));
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
+ RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
+ ("available for Rx and offline parsing ports only"));
- p_FmPort->p_FmPortDriverParam->txFifoLowComfLevel = fifoLowComfLevel;
+ p_FmPort->p_FmPortDriverParam->errorsToDiscard = errs;
return E_OK;
}
-t_Error FM_PORT_ConfigDontReleaseTxBufToBM(t_Handle h_FmPort)
+t_Error FM_PORT_ConfigDmaSwapData(t_Handle h_FmPort, e_FmDmaSwapOption swapData)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType != e_FM_PORT_TYPE_TX_10G) && (p_FmPort->portType != e_FM_PORT_TYPE_TX))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Tx ports only"));
- p_FmPort->p_FmPortDriverParam->dontReleaseBuf = TRUE;
+ p_FmPort->p_FmPortDriverParam->dfltCfg.dma_swap_data =
+ (enum fman_port_dma_swap)swapData;
return E_OK;
}
-t_Error FM_PORT_ConfigDfltColor(t_Handle h_FmPort, e_FmPortColor color)
+t_Error FM_PORT_ConfigDmaIcCacheAttr(t_Handle h_FmPort,
+ e_FmDmaCacheOption intContextCacheAttr)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
-#ifdef FM_OP_PORT_QMAN_REJECT_ERRATA_FMAN21
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("FM_PORT_ConfigDfltColor!"));
- }
-#endif /* FM_OP_PORT_QMAN_REJECT_ERRATA_FMAN21 */
- p_FmPort->p_FmPortDriverParam->color = color;
+
+ p_FmPort->p_FmPortDriverParam->dfltCfg.dma_ic_stash_on =
+ (bool)(intContextCacheAttr == e_FM_DMA_STASH);
return E_OK;
}
-t_Error FM_PORT_ConfigSyncReq(t_Handle h_FmPort, bool syncReq)
+t_Error FM_PORT_ConfigDmaHdrAttr(t_Handle h_FmPort,
+ e_FmDmaCacheOption headerCacheAttr)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
-#ifdef FM_PORT_SYNC_ERRATA_FMAN6
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("port-sync!"));
- }
-#endif /* FM_PORT_SYNC_ERRATA_FMAN6 */
- p_FmPort->p_FmPortDriverParam->syncReq = syncReq;
+ p_FmPort->p_FmPortDriverParam->dfltCfg.dma_header_stash_on =
+ (bool)(headerCacheAttr == e_FM_DMA_STASH);
return E_OK;
}
+t_Error FM_PORT_ConfigDmaScatterGatherAttr(
+ t_Handle h_FmPort, e_FmDmaCacheOption scatterGatherCacheAttr)
+{
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
-t_Error FM_PORT_ConfigFrmDiscardOverride(t_Handle h_FmPort, bool override)
+ SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
+
+ p_FmPort->p_FmPortDriverParam->dfltCfg.dma_sg_stash_on =
+ (bool)(scatterGatherCacheAttr == e_FM_DMA_STASH);
+
+ return E_OK;
+}
+
+t_Error FM_PORT_ConfigDmaWriteOptimize(t_Handle h_FmPort, bool optimize)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType == e_FM_PORT_TYPE_TX_10G) && (p_FmPort->portType == e_FM_PORT_TYPE_TX))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("not available for Tx ports"));
- p_FmPort->p_FmPortDriverParam->frmDiscardOverride = override;
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_TX_10G)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_TX))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("Not available for Tx ports"));
+
+ p_FmPort->p_FmPortDriverParam->dfltCfg.dma_write_optimize = optimize;
return E_OK;
}
-t_Error FM_PORT_ConfigErrorsToDiscard(t_Handle h_FmPort, fmPortFrameErrSelect_t errs)
+#if (DPAA_VERSION >= 11)
+t_Error FM_PORT_ConfigNoScatherGather(t_Handle h_FmPort, bool noScatherGather)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ UNUSED(noScatherGather);
+ UNUSED(p_FmPort);
+
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) && (p_FmPort->portType != e_FM_PORT_TYPE_RX) &&
- (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx and offline parsing ports only"));
- p_FmPort->p_FmPortDriverParam->errorsToDiscard = errs;
+ p_FmPort->p_FmPortDriverParam->noScatherGather = noScatherGather;
return E_OK;
}
+#endif /* (DPAA_VERSION >= 11) */
-t_Error FM_PORT_ConfigDmaSwapData(t_Handle h_FmPort, e_FmPortDmaSwap swapData)
+t_Error FM_PORT_ConfigForwardReuseIntContext(t_Handle h_FmPort,
+ bool forwardReuse)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- p_FmPort->p_FmPortDriverParam->dmaSwapData = swapData;
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for Rx ports only"));
+
+ p_FmPort->p_FmPortDriverParam->forwardReuseIntContext = forwardReuse;
return E_OK;
}
-t_Error FM_PORT_ConfigDmaIcCacheAttr(t_Handle h_FmPort, e_FmPortDmaCache intContextCacheAttr)
+t_Error FM_PORT_ConfigMaxFrameLength(t_Handle h_FmPort, uint16_t length)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- p_FmPort->p_FmPortDriverParam->dmaIntContextCacheAttr = intContextCacheAttr;
+ p_FmPort->maxFrameLength = length;
return E_OK;
}
-t_Error FM_PORT_ConfigDmaHdrAttr(t_Handle h_FmPort, e_FmPortDmaCache headerCacheAttr)
+#ifdef FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669
+t_Error FM_PORT_ConfigBCBWorkaround(t_Handle h_FmPort)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- p_FmPort->p_FmPortDriverParam->dmaHeaderCacheAttr = headerCacheAttr;
+ p_FmPort->p_FmPortDriverParam->bcbWorkaround = TRUE;
return E_OK;
}
+#endif /* FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669 */
-t_Error FM_PORT_ConfigDmaScatterGatherAttr(t_Handle h_FmPort, e_FmPortDmaCache scatterGatherCacheAttr)
+/****************************************************/
+/* Hidden-DEBUG Only API */
+/****************************************************/
+
+t_Error FM_PORT_ConfigTxFifoMinFillLevel(t_Handle h_FmPort,
+ uint32_t minFillLevel)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_TX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_TX))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for Tx ports only"));
- p_FmPort->p_FmPortDriverParam->dmaScatterGatherCacheAttr = scatterGatherCacheAttr;
+ p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_min_level = minFillLevel;
return E_OK;
}
-t_Error FM_PORT_ConfigDmaWriteOptimize(t_Handle h_FmPort, bool optimize)
+t_Error FM_PORT_ConfigFifoDeqPipelineDepth(t_Handle h_FmPort,
+ uint8_t deqPipelineDepth)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType == e_FM_PORT_TYPE_TX_10G) || (p_FmPort->portType == e_FM_PORT_TYPE_TX))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("Not available for Tx ports"));
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_RX))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("Not available for Rx ports"));
- p_FmPort->p_FmPortDriverParam->dmaWriteOptimize = optimize;
+ if (p_FmPort->imEn)
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("Not available for IM ports!"));
+
+ p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_deq_pipeline_depth =
+ deqPipelineDepth;
return E_OK;
}
-t_Error FM_PORT_ConfigForwardReuseIntContext(t_Handle h_FmPort, bool forwardReuse)
+t_Error FM_PORT_ConfigTxFifoLowComfLevel(t_Handle h_FmPort,
+ uint32_t fifoLowComfLevel)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_TX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_TX))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for Tx ports only"));
- if((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx ports only"));
+ p_FmPort->p_FmPortDriverParam->dfltCfg.tx_fifo_low_comf_level =
+ fifoLowComfLevel;
- p_FmPort->p_FmPortDriverParam->forwardReuseIntContext = forwardReuse;
+ return E_OK;
+}
+
+t_Error FM_PORT_ConfigRxFifoThreshold(t_Handle h_FmPort, uint32_t fifoThreshold)
+{
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for Rx ports only"));
+
+ p_FmPort->p_FmPortDriverParam->dfltCfg.rx_fifo_thr = fifoThreshold;
return E_OK;
}
+t_Error FM_PORT_ConfigRxFifoPriElevationLevel(t_Handle h_FmPort,
+ uint32_t priElevationLevel)
+{
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
-/****************************************************/
-/* PCD Advaced config API */
-/****************************************************/
+ SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for Rx ports only"));
+
+ p_FmPort->p_FmPortDriverParam->dfltCfg.rx_pri_elevation = priElevationLevel;
+ return E_OK;
+}
/****************************************************/
/* API Run-time Control unit functions */
/****************************************************/
-t_Error FM_PORT_SetNumOfOpenDmas(t_Handle h_FmPort, t_FmPortRsrc *p_NumOfOpenDmas)
+t_Error FM_PORT_SetNumOfOpenDmas(t_Handle h_FmPort,
+ t_FmPortRsrc *p_NumOfOpenDmas)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- t_Error err;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_Error err;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
-#ifdef FM_PORT_EXCESSIVE_BUDGET_ERRATA_FMANx16
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0) &&
- (p_NumOfOpenDmas->extra))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("excessive resources"));
- }
-#endif /* FM_PORT_EXCESSIVE_BUDGET_ERRATA_FMANx16 */
-
- if((!p_NumOfOpenDmas->num) || (p_NumOfOpenDmas->num > MAX_NUM_OF_DMAS))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("openDmas-num can't be larger than %d", MAX_NUM_OF_DMAS));
- if(p_NumOfOpenDmas->extra > MAX_NUM_OF_EXTRA_DMAS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("openDmas-extra can't be larger than %d", MAX_NUM_OF_EXTRA_DMAS));
- err = FmSetNumOfOpenDmas(p_FmPort->h_Fm, p_FmPort->hardwarePortId, (uint8_t)p_NumOfOpenDmas->num, (uint8_t)p_NumOfOpenDmas->extra, FALSE);
- if(err)
- RETURN_ERROR(MINOR, err, NO_MSG);
+ if ((!p_NumOfOpenDmas->num) || (p_NumOfOpenDmas->num > MAX_NUM_OF_DMAS))
+ RETURN_ERROR( MAJOR, E_INVALID_VALUE,
+ ("openDmas-num can't be larger than %d", MAX_NUM_OF_DMAS));
+ if (p_NumOfOpenDmas->extra > MAX_NUM_OF_EXTRA_DMAS)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("openDmas-extra can't be larger than %d", MAX_NUM_OF_EXTRA_DMAS));
+ err = FmSetNumOfOpenDmas(p_FmPort->h_Fm, p_FmPort->hardwarePortId,
+ (uint8_t*)&p_NumOfOpenDmas->num,
+ (uint8_t*)&p_NumOfOpenDmas->extra, FALSE);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
memcpy(&p_FmPort->openDmas, p_NumOfOpenDmas, sizeof(t_FmPortRsrc));
@@ -3085,33 +3385,30 @@ t_Error FM_PORT_SetNumOfOpenDmas(t_Handle h_FmPort, t_FmPortRsrc *p_NumOfOpenDma
t_Error FM_PORT_SetNumOfTasks(t_Handle h_FmPort, t_FmPortRsrc *p_NumOfTasks)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- t_Error err;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_Error err;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("not available for host command port where number is always 1"));
-
-#ifdef FM_PORT_EXCESSIVE_BUDGET_ERRATA_FMANx16
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0) &&
- (p_NumOfTasks->extra))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("excessive resources"));
- }
-#endif /* FM_PORT_EXCESSIVE_BUDGET_ERRATA_FMANx16 */
-
- if((!p_NumOfTasks->num) || (p_NumOfTasks->num > MAX_NUM_OF_TASKS))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("NumOfTasks-num can't be larger than %d", MAX_NUM_OF_TASKS));
- if(p_NumOfTasks->extra > MAX_NUM_OF_EXTRA_TASKS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("NumOfTasks-extra can't be larger than %d", MAX_NUM_OF_EXTRA_TASKS));
-
- err = FmSetNumOfTasks(p_FmPort->h_Fm, p_FmPort->hardwarePortId, (uint8_t)p_NumOfTasks->num, (uint8_t)p_NumOfTasks->extra, FALSE);
- if(err)
- RETURN_ERROR(MINOR, err, NO_MSG);
+ /* only driver uses host command port, so ASSERT rather than RETURN_ERROR */
+ ASSERT_COND(p_FmPort->portType != e_FM_PORT_TYPE_OH_HOST_COMMAND);
+
+ if ((!p_NumOfTasks->num) || (p_NumOfTasks->num > MAX_NUM_OF_TASKS))
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("NumOfTasks-num can't be larger than %d", MAX_NUM_OF_TASKS));
+ if (p_NumOfTasks->extra > MAX_NUM_OF_EXTRA_TASKS)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("NumOfTasks-extra can't be larger than %d", MAX_NUM_OF_EXTRA_TASKS));
+
+ err = FmSetNumOfTasks(p_FmPort->h_Fm, p_FmPort->hardwarePortId,
+ (uint8_t*)&p_NumOfTasks->num,
+ (uint8_t*)&p_NumOfTasks->extra, FALSE);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
/* update driver's struct */
memcpy(&p_FmPort->tasks, p_NumOfTasks, sizeof(t_FmPortRsrc));
@@ -3120,112 +3417,85 @@ t_Error FM_PORT_SetNumOfTasks(t_Handle h_FmPort, t_FmPortRsrc *p_NumOfTasks)
t_Error FM_PORT_SetSizeOfFifo(t_Handle h_FmPort, t_FmPortRsrc *p_SizeOfFifo)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- t_Error err;
- t_FmInterModulePortRxPoolsParams rxPoolsParams;
- uint32_t minFifoSizeRequired;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_Error err;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
-#ifdef FM_PORT_EXCESSIVE_BUDGET_ERRATA_FMANx16
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0) &&
- (p_SizeOfFifo->extra))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("excessive resources"));
- }
-#endif /* FM_PORT_EXCESSIVE_BUDGET_ERRATA_FMANx16 */
- if(!p_SizeOfFifo->num || (p_SizeOfFifo->num > BMI_MAX_FIFO_SIZE))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("SizeOfFifo-num has to be in the range of 256 - %d", BMI_MAX_FIFO_SIZE));
- if(p_SizeOfFifo->num % BMI_FIFO_UNITS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("SizeOfFifo-num has to be divisible by %d", BMI_FIFO_UNITS));
- if((p_FmPort->portType == e_FM_PORT_TYPE_RX) || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
+ if (!p_SizeOfFifo->num || (p_SizeOfFifo->num > MAX_PORT_FIFO_SIZE))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("SizeOfFifo-num has to be in the range of 256 - %d", MAX_PORT_FIFO_SIZE));
+ if (p_SizeOfFifo->num % BMI_FIFO_UNITS)
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("SizeOfFifo-num has to be divisible by %d", BMI_FIFO_UNITS));
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_RX)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
{
/* extra FIFO size (allowed only to Rx ports) */
- if(p_SizeOfFifo->extra % BMI_FIFO_UNITS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("SizeOfFifo-extra has to be divisible by %d", BMI_FIFO_UNITS));
+ if (p_SizeOfFifo->extra % BMI_FIFO_UNITS)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("SizeOfFifo-extra has to be divisible by %d", BMI_FIFO_UNITS));
}
else
- if(p_SizeOfFifo->extra)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, (" No SizeOfFifo-extra for non Rx ports"));
+ if (p_SizeOfFifo->extra)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ (" No SizeOfFifo-extra for non Rx ports"));
- /* For O/H ports, check fifo size and update if necessary */
- if((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING) || (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND))
- {
- minFifoSizeRequired = (uint32_t)((p_FmPort->txFifoDeqPipelineDepth+4)*BMI_FIFO_UNITS);
- if (p_FmPort->fifoBufs.num < minFifoSizeRequired)
- {
- p_FmPort->fifoBufs.num = minFifoSizeRequired;
- DBG(INFO, ("FIFO size enlarged to %d", minFifoSizeRequired));
- }
- }
- memcpy(&rxPoolsParams, &p_FmPort->rxPoolsParams, sizeof(rxPoolsParams));
- err = FmSetSizeOfFifo(p_FmPort->h_Fm,
- p_FmPort->hardwarePortId,
- p_FmPort->portType,
- p_FmPort->imEn,
- &p_SizeOfFifo->num,
- p_SizeOfFifo->extra,
- p_FmPort->txFifoDeqPipelineDepth,
- &rxPoolsParams,
- FALSE);
- if(err)
- RETURN_ERROR(MINOR, err, NO_MSG);
-
- /* update driver's structure AFTER the FM routine, as it may change by the FM. */
memcpy(&p_FmPort->fifoBufs, p_SizeOfFifo, sizeof(t_FmPortRsrc));
+ /* we do not change user's parameter */
+ err = VerifySizeOfFifo(p_FmPort);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ err = FmSetSizeOfFifo(p_FmPort->h_Fm, p_FmPort->hardwarePortId,
+ &p_SizeOfFifo->num, &p_SizeOfFifo->extra, FALSE);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
return E_OK;
}
uint32_t FM_PORT_GetBufferDataOffset(t_Handle h_FmPort)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, 0);
- SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE, 0);
+ SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE,
+ 0);
return p_FmPort->bufferOffsets.dataOffset;
}
uint8_t * FM_PORT_GetBufferICInfo(t_Handle h_FmPort, char *p_Data)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, 0);
- SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE, 0);
+ SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, NULL);
+ SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE,
+ NULL);
- if(p_FmPort->bufferOffsets.pcdInfoOffset == ILLEGAL_BASE)
+ if (p_FmPort->bufferOffsets.pcdInfoOffset == ILLEGAL_BASE)
return NULL;
return (uint8_t *)PTR_MOVE(p_Data, p_FmPort->bufferOffsets.pcdInfoOffset);
}
-#ifdef DEBUG
-uint8_t * FM_PORT_GetBufferDebugInfo(t_Handle h_FmPort, char *p_Data)
-{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
-
- SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, 0);
- SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE, 0);
-
- if(p_FmPort->bufferOffsets.debugOffset == ILLEGAL_BASE)
- return NULL;
-
- return (uint8_t *)PTR_MOVE(p_Data, p_FmPort->bufferOffsets.debugOffset);
-}
-#endif /* DEBUG */
-
t_FmPrsResult * FM_PORT_GetBufferPrsResult(t_Handle h_FmPort, char *p_Data)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, NULL);
- SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE, NULL);
+ SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE,
+ NULL);
- if(p_FmPort->bufferOffsets.prsResultOffset == ILLEGAL_BASE)
+ if (p_FmPort->bufferOffsets.prsResultOffset == ILLEGAL_BASE)
return NULL;
return (t_FmPrsResult *)PTR_MOVE(p_Data, p_FmPort->bufferOffsets.prsResultOffset);
@@ -3233,12 +3503,13 @@ t_FmPrsResult * FM_PORT_GetBufferPrsResult(t_Handle h_FmPort, char *p_Data)
uint64_t * FM_PORT_GetBufferTimeStamp(t_Handle h_FmPort, char *p_Data)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, NULL);
- SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE, NULL);
+ SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE,
+ NULL);
- if(p_FmPort->bufferOffsets.timeStampOffset == ILLEGAL_BASE)
+ if (p_FmPort->bufferOffsets.timeStampOffset == ILLEGAL_BASE)
return NULL;
return (uint64_t *)PTR_MOVE(p_Data, p_FmPort->bufferOffsets.timeStampOffset);
@@ -3246,12 +3517,13 @@ uint64_t * FM_PORT_GetBufferTimeStamp(t_Handle h_FmPort, char *p_Data)
uint8_t * FM_PORT_GetBufferHashResult(t_Handle h_FmPort, char *p_Data)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, 0);
- SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE, 0);
+ SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, NULL);
+ SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE,
+ NULL);
- if(p_FmPort->bufferOffsets.hashResultOffset == ILLEGAL_BASE)
+ if (p_FmPort->bufferOffsets.hashResultOffset == ILLEGAL_BASE)
return NULL;
return (uint8_t *)PTR_MOVE(p_Data, p_FmPort->bufferOffsets.hashResultOffset);
@@ -3259,466 +3531,364 @@ uint8_t * FM_PORT_GetBufferHashResult(t_Handle h_FmPort, char *p_Data)
t_Error FM_PORT_Disable(t_Handle h_FmPort)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- volatile uint32_t *p_BmiCfgReg = NULL;
- volatile uint32_t *p_BmiStatusReg = NULL;
- bool rxPort = FALSE;
- int tries;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ int err;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
- switch(p_FmPort->portType)
+ if (p_FmPort->imEn)
+ FmPortImDisable(p_FmPort);
+
+ err = fman_port_disable(&p_FmPort->port);
+ if (err == -EBUSY)
{
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- p_BmiCfgReg = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rcfg;
- p_BmiStatusReg = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rst;
- rxPort = TRUE;
- break;
- case(e_FM_PORT_TYPE_TX_10G):
- case(e_FM_PORT_TYPE_TX):
- p_BmiCfgReg = &p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcfg;
- p_BmiStatusReg = &p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tst;
- break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- case(e_FM_PORT_TYPE_OH_HOST_COMMAND):
- p_BmiCfgReg = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ocfg;
- p_BmiStatusReg = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ost;
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
+ DBG(WARNING, ("%s: BMI or QMI is Busy. Port forced down",
+ p_FmPort->name));
}
- /* check if port is already disabled */
- if(!(GET_UINT32(*p_BmiCfgReg) & BMI_PORT_CFG_EN))
- {
- if (!rxPort && !p_FmPort->imEn)
+ else
+ if (err != 0)
{
- if(!(GET_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnc)& QMI_PORT_CFG_EN))
- /* port is disabled */
- return E_OK;
- else
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Inconsistency: Port's QMI is enabled but BMI disabled"));
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_disable"));
}
- /* port is disabled */
- return E_OK;
- }
-
- /* Disable QMI */
- if (!rxPort && !p_FmPort->imEn)
- {
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnc,
- GET_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnc) & ~QMI_PORT_CFG_EN);
- /* wait for QMI to finish Handling dequeue tnums */
- tries=1000;
- while ((GET_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pns) & QMI_PORT_STATUS_DEQ_FD_BSY) &&
- --tries)
- XX_UDelay(1);
- if (!tries)
- RETURN_ERROR(MINOR, E_BUSY, ("%s: can't disable!", p_FmPort->name));
- }
-
- /* Disable BMI */
- WRITE_UINT32(*p_BmiCfgReg, GET_UINT32(*p_BmiCfgReg) & ~BMI_PORT_CFG_EN);
-
- if (p_FmPort->imEn)
- FmPortImDisable(p_FmPort);
-
- tries=5000;
- while ((GET_UINT32(*p_BmiStatusReg) & BMI_PORT_STATUS_BSY) &&
- --tries)
- XX_UDelay(1);
- if (!tries)
- RETURN_ERROR(MINOR, E_BUSY, ("%s: can't disable!", p_FmPort->name));
-
- p_FmPort->enabled = 0;
+ p_FmPort->enabled = FALSE;
return E_OK;
}
t_Error FM_PORT_Enable(t_Handle h_FmPort)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- volatile uint32_t *p_BmiCfgReg = NULL;
- bool rxPort = FALSE;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ int err;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
- switch(p_FmPort->portType)
- {
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- p_BmiCfgReg = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rcfg;
- rxPort = TRUE;
- break;
- case(e_FM_PORT_TYPE_TX_10G):
- case(e_FM_PORT_TYPE_TX):
- p_BmiCfgReg = &p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcfg;
- break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- case(e_FM_PORT_TYPE_OH_HOST_COMMAND):
- p_BmiCfgReg = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ocfg;
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
- }
-
- /* check if port is already enabled */
- if(GET_UINT32(*p_BmiCfgReg) & BMI_PORT_CFG_EN)
- {
- if (!rxPort && !p_FmPort->imEn)
- {
- if(GET_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnc)& QMI_PORT_CFG_EN)
- /* port is enabled */
- return E_OK;
- else
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Inconsistency: Port's BMI is enabled but QMI disabled"));
- }
- /* port is enabled */
- return E_OK;
- }
+ /* Used by FM_PORT_Free routine as indication
+ if to disable port. Thus set it to TRUE prior
+ to enabling itself. This way if part of enable
+ process fails there will be still things
+ to disable during Free. For example, if BMI
+ enable succeeded but QMI failed, still BMI
+ needs to be disabled by Free. */
+ p_FmPort->enabled = TRUE;
if (p_FmPort->imEn)
FmPortImEnable(p_FmPort);
- /* Enable QMI */
- if (!rxPort && !p_FmPort->imEn)
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnc,
- GET_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnc) | QMI_PORT_CFG_EN);
-
- /* Enable BMI */
- WRITE_UINT32(*p_BmiCfgReg, GET_UINT32(*p_BmiCfgReg) | BMI_PORT_CFG_EN);
-
- p_FmPort->enabled = 1;
+ err = fman_port_enable(&p_FmPort->port);
+ if (err != 0)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_enable"));
return E_OK;
}
t_Error FM_PORT_SetRateLimit(t_Handle h_FmPort, t_FmPortRateLimit *p_RateLimit)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- uint32_t tmpRateLimit, tmpRateLimitScale;
- volatile uint32_t *p_RateLimitReg, *p_RateLimitScaleReg;
- uint8_t factor, countUnitBit;
- uint16_t baseGran;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ uint8_t factor, countUnitBit;
+ uint16_t baseGran;
+ struct fman_port_rate_limiter params;
+ int err;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G) || (p_FmPort->portType == e_FM_PORT_TYPE_RX) ||
- (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Tx and Offline parsing ports only"));
-
- switch(p_FmPort->portType)
+ switch (p_FmPort->portType)
{
- case(e_FM_PORT_TYPE_TX_10G):
- case(e_FM_PORT_TYPE_TX):
- p_RateLimitReg = &p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_trlmt;
- p_RateLimitScaleReg = &p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_trlmts;
- baseGran = 16000;
+ case (e_FM_PORT_TYPE_TX_10G):
+ case (e_FM_PORT_TYPE_TX):
+ baseGran = BMI_RATE_LIMIT_GRAN_TX;
+ break;
+ case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
+ baseGran = BMI_RATE_LIMIT_GRAN_OP;
break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- p_RateLimitReg = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_orlmt;
- p_RateLimitScaleReg = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_orlmts;
- baseGran = 10000;
- break;
default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
+ RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
+ ("available for Tx and Offline parsing ports only"));
}
- countUnitBit = (uint8_t)FmGetTimeStampScale(p_FmPort->h_Fm); /* TimeStamp per nano seconds units */
+ countUnitBit = (uint8_t)FmGetTimeStampScale(p_FmPort->h_Fm); /* TimeStamp per nano seconds units */
/* normally, we use 1 usec as the reference count */
factor = 1;
/* if ratelimit is too small for a 1usec factor, multiply the factor */
- while (p_RateLimit->rateLimit < baseGran/factor)
+ while (p_RateLimit->rateLimit < baseGran / factor)
{
- if (countUnitBit==31)
+ if (countUnitBit == 31)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Rate limit is too small"));
countUnitBit++;
factor <<= 1;
}
/* if ratelimit is too large for a 1usec factor, it is also larger than max rate*/
- if (p_RateLimit->rateLimit > ((uint32_t)baseGran * (1<<10) * (uint32_t)factor))
+ if (p_RateLimit->rateLimit
+ > ((uint32_t)baseGran * (1 << 10) * (uint32_t)factor))
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Rate limit is too large"));
- tmpRateLimit = (uint32_t)(p_RateLimit->rateLimit*factor/baseGran - 1);
+ if (!p_RateLimit->maxBurstSize
+ || (p_RateLimit->maxBurstSize > BMI_RATE_LIMIT_MAX_BURST_SIZE))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("maxBurstSize must be between 1K and %dk", BMI_RATE_LIMIT_MAX_BURST_SIZE));
- if(!p_RateLimit->maxBurstSize || (p_RateLimit->maxBurstSize > MAX_BURST_SIZE))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("maxBurstSize must be between 1K and %dk", MAX_BURST_SIZE));
+ params.count_1micro_bit = (uint8_t)FmGetTimeStampScale(p_FmPort->h_Fm);
+ params.high_burst_size_gran = FALSE;
+ params.burst_size = p_RateLimit->maxBurstSize;
+ params.rate = p_RateLimit->rateLimit;
+ params.rate_factor = E_FMAN_PORT_RATE_DOWN_NONE;
- tmpRateLimitScale = ((31 - (uint32_t)countUnitBit) << BMI_COUNT_RATE_UNIT_SHIFT) | BMI_RATE_LIMIT_EN;
-
- if(p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
- tmpRateLimit |= (uint32_t)(p_RateLimit->maxBurstSize - 1) << BMI_MAX_BURST_SHIFT;
- else
+ if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
{
#ifndef FM_NO_ADVANCED_RATE_LIMITER
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if (revInfo.majorRev == 4)
+ if ((p_FmPort->fmRevInfo.majorRev == 4)
+ || (p_FmPort->fmRevInfo.majorRev >= 6))
{
- switch(p_RateLimit->rateLimitDivider)
- {
- case(e_FM_PORT_DUAL_RATE_LIMITER_NONE):
- break;
- case(e_FM_PORT_DUAL_RATE_LIMITER_SCALE_DOWN_BY_2):
- tmpRateLimitScale |= BMI_RATE_LIMIT_SCALE_BY_2;
- break;
- case(e_FM_PORT_DUAL_RATE_LIMITER_SCALE_DOWN_BY_4):
- tmpRateLimitScale |= BMI_RATE_LIMIT_SCALE_BY_4;
- break;
- case(e_FM_PORT_DUAL_RATE_LIMITER_SCALE_DOWN_BY_8):
- tmpRateLimitScale |= BMI_RATE_LIMIT_SCALE_BY_8;
- break;
- default:
- break;
- }
- tmpRateLimit |= BMI_RATE_LIMIT_BURST_SIZE_GRAN;
+ params.high_burst_size_gran = TRUE;
}
else
#endif /* ! FM_NO_ADVANCED_RATE_LIMITER */
{
- if(p_RateLimit->rateLimitDivider != e_FM_PORT_DUAL_RATE_LIMITER_NONE)
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("FM_PORT_ConfigDualRateLimitScaleDown"));
+ if (p_RateLimit->rateLimitDivider
+ != e_FM_PORT_DUAL_RATE_LIMITER_NONE)
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
+ ("FM_PORT_ConfigDualRateLimitScaleDown"));
- if(p_RateLimit->maxBurstSize % 1000)
+ if (p_RateLimit->maxBurstSize % 1000)
{
- p_RateLimit->maxBurstSize = (uint16_t)((p_RateLimit->maxBurstSize/1000)+1);
+ p_RateLimit->maxBurstSize =
+ (uint16_t)((p_RateLimit->maxBurstSize / 1000) + 1);
DBG(WARNING, ("rateLimit.maxBurstSize rounded up to %d", (p_RateLimit->maxBurstSize/1000+1)*1000));
}
else
- p_RateLimit->maxBurstSize = (uint16_t)(p_RateLimit->maxBurstSize/1000);
+ p_RateLimit->maxBurstSize = (uint16_t)(p_RateLimit->maxBurstSize
+ / 1000);
}
- tmpRateLimit |= (uint32_t)(p_RateLimit->maxBurstSize - 1) << BMI_MAX_BURST_SHIFT;
-
+ params.rate_factor =
+ (enum fman_port_rate_limiter_scale_down)p_RateLimit->rateLimitDivider;
+ params.burst_size = p_RateLimit->maxBurstSize;
}
- WRITE_UINT32(*p_RateLimitScaleReg, tmpRateLimitScale);
- WRITE_UINT32(*p_RateLimitReg, tmpRateLimit);
+
+ err = fman_port_set_rate_limiter(&p_FmPort->port, &params);
+ if (err != 0)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_set_rate_limiter"));
return E_OK;
}
t_Error FM_PORT_DeleteRateLimit(t_Handle h_FmPort)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- volatile uint32_t *p_RateLimitReg, *p_RateLimitScaleReg;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ int err;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G) || (p_FmPort->portType == e_FM_PORT_TYPE_RX) ||
- (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Tx and Offline parsing ports only"));
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_RX)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND))
+ RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
+ ("available for Tx and Offline parsing ports only"));
- switch(p_FmPort->portType)
- {
- case(e_FM_PORT_TYPE_TX_10G):
- case(e_FM_PORT_TYPE_TX):
- p_RateLimitReg = &p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_trlmt;
- p_RateLimitScaleReg = &p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_trlmts;
- break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- p_RateLimitReg = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_orlmt;
- p_RateLimitScaleReg = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_orlmts;
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
- }
+ err = fman_port_delete_rate_limiter(&p_FmPort->port);
+ if (err != 0)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_set_rate_limiter"));
+ return E_OK;
+}
+
+t_Error FM_PORT_SetPfcPrioritiesMappingToQmanWQ(t_Handle h_FmPort, uint8_t prio,
+ uint8_t wq)
+{
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ uint32_t tmpReg;
+ uint32_t wqTmpReg;
- WRITE_UINT32(*p_RateLimitScaleReg, 0);
- WRITE_UINT32(*p_RateLimitReg, 0);
+ SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
+
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_TX)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_TX_10G))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("PFC mapping is available for Tx ports only"));
+
+ if (prio > 7)
+ RETURN_ERROR(MAJOR, E_NOT_IN_RANGE,
+ ("PFC priority (%d) is out of range (0-7)", prio));
+ if (wq > 7)
+ RETURN_ERROR(MAJOR, E_NOT_IN_RANGE,
+ ("WQ (%d) is out of range (0-7)", wq));
+
+ tmpReg = GET_UINT32(p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tpfcm[0]);
+ tmpReg &= ~(0xf << ((7 - prio) * 4));
+ wqTmpReg = ((uint32_t)wq << ((7 - prio) * 4));
+ tmpReg |= wqTmpReg;
+
+ WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tpfcm[0],
+ tmpReg);
return E_OK;
}
-
t_Error FM_PORT_SetFrameQueueCounters(t_Handle h_FmPort, bool enable)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- uint32_t tmpReg;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
- tmpReg = GET_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnc);
- if(enable)
- tmpReg |= QMI_PORT_CFG_EN_COUNTERS ;
- else
- tmpReg &= ~QMI_PORT_CFG_EN_COUNTERS;
-
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnc, tmpReg);
+ fman_port_set_queue_cnt_mode(&p_FmPort->port, enable);
return E_OK;
}
t_Error FM_PORT_SetPerformanceCounters(t_Handle h_FmPort, bool enable)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- volatile uint32_t *p_BmiPcReg = NULL;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ int err;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
- switch(p_FmPort->portType)
- {
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- p_BmiPcReg = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rpc;
- break;
- case(e_FM_PORT_TYPE_TX_10G):
- case(e_FM_PORT_TYPE_TX):
- p_BmiPcReg = &p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tpc;
- break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- case(e_FM_PORT_TYPE_OH_HOST_COMMAND):
- p_BmiPcReg = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_opc;
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
- }
-
- if(enable)
- WRITE_UINT32(*p_BmiPcReg, BMI_COUNTERS_EN);
- else
- WRITE_UINT32(*p_BmiPcReg, 0);
-
+ err = fman_port_set_perf_cnt_mode(&p_FmPort->port, enable);
+ if (err != 0)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_set_perf_cnt_mode"));
return E_OK;
}
-t_Error FM_PORT_SetPerformanceCountersParams(t_Handle h_FmPort, t_FmPortPerformanceCnt *p_FmPortPerformanceCnt)
+t_Error FM_PORT_SetPerformanceCountersParams(
+ t_Handle h_FmPort, t_FmPortPerformanceCnt *p_FmPortPerformanceCnt)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- uint32_t tmpReg;
- volatile uint32_t *p_BmiPcpReg = NULL;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ struct fman_port_perf_cnt_params params;
+ int err;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
- switch(p_FmPort->portType)
- {
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- p_BmiPcpReg = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rpcp;
- break;
- case(e_FM_PORT_TYPE_TX_10G):
- case(e_FM_PORT_TYPE_TX):
- p_BmiPcpReg = &p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tpcp;
- break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- case(e_FM_PORT_TYPE_OH_HOST_COMMAND):
- p_BmiPcpReg = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_opcp;
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
- }
-
/* check parameters */
- if (!p_FmPortPerformanceCnt->taskCompVal ||
- (p_FmPortPerformanceCnt->taskCompVal > p_FmPort->tasks.num))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE,
- ("performanceCnt.taskCompVal has to be in the range of 1 - %d (current value)!",
- p_FmPort->tasks.num));
- if (!p_FmPortPerformanceCnt->dmaCompVal ||
- (p_FmPortPerformanceCnt->dmaCompVal > p_FmPort->openDmas.num))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE,
- ("performanceCnt.dmaCompVal has to be in the range of 1 - %d (current value)!",
- p_FmPort->openDmas.num));
- if (!p_FmPortPerformanceCnt->fifoCompVal ||
- (p_FmPortPerformanceCnt->fifoCompVal > p_FmPort->fifoBufs.num))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE,
- ("performanceCnt.fifoCompVal has to be in the range of 256 - %d (current value)!",
- p_FmPort->fifoBufs.num));
+ if (!p_FmPortPerformanceCnt->taskCompVal
+ || (p_FmPortPerformanceCnt->taskCompVal > p_FmPort->tasks.num))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("taskCompVal (%d) has to be in the range of 1 - %d (current value)!", p_FmPortPerformanceCnt->taskCompVal, p_FmPort->tasks.num));
+ if (!p_FmPortPerformanceCnt->dmaCompVal
+ || (p_FmPortPerformanceCnt->dmaCompVal > p_FmPort->openDmas.num))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("dmaCompVal (%d) has to be in the range of 1 - %d (current value)!", p_FmPortPerformanceCnt->dmaCompVal, p_FmPort->openDmas.num));
+ if (!p_FmPortPerformanceCnt->fifoCompVal
+ || (p_FmPortPerformanceCnt->fifoCompVal > p_FmPort->fifoBufs.num))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("fifoCompVal (%d) has to be in the range of 256 - %d (current value)!", p_FmPortPerformanceCnt->fifoCompVal, p_FmPort->fifoBufs.num));
if (p_FmPortPerformanceCnt->fifoCompVal % BMI_FIFO_UNITS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE,
- ("performanceCnt.fifoCompVal has to be divisible by %d",
- BMI_FIFO_UNITS));
- switch(p_FmPort->portType)
- {
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- if (!p_FmPortPerformanceCnt->queueCompVal ||
- (p_FmPortPerformanceCnt->queueCompVal > MAX_PERFORMANCE_RX_QUEUE_COMP))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE,
- ("performanceCnt.queueCompVal for Rx has to be in the range of 1 - %d",
- MAX_PERFORMANCE_RX_QUEUE_COMP));
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("fifoCompVal (%d) has to be divisible by %d", p_FmPortPerformanceCnt->fifoCompVal, BMI_FIFO_UNITS));
+
+ switch (p_FmPort->portType)
+ {
+ case (e_FM_PORT_TYPE_RX_10G):
+ case (e_FM_PORT_TYPE_RX):
+ if (!p_FmPortPerformanceCnt->queueCompVal
+ || (p_FmPortPerformanceCnt->queueCompVal
+ > MAX_PERFORMANCE_RX_QUEUE_COMP))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("performanceCnt.queueCompVal for Rx has to be in the range of 1 - %d", MAX_PERFORMANCE_RX_QUEUE_COMP));
break;
- case(e_FM_PORT_TYPE_TX_10G):
- case(e_FM_PORT_TYPE_TX):
- if (!p_FmPortPerformanceCnt->queueCompVal ||
- (p_FmPortPerformanceCnt->queueCompVal > MAX_PERFORMANCE_TX_QUEUE_COMP))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE,
- ("performanceCnt.queueCompVal for Tx has to be in the range of 1 - %d",
- MAX_PERFORMANCE_TX_QUEUE_COMP));
+ case (e_FM_PORT_TYPE_TX_10G):
+ case (e_FM_PORT_TYPE_TX):
+ if (!p_FmPortPerformanceCnt->queueCompVal
+ || (p_FmPortPerformanceCnt->queueCompVal
+ > MAX_PERFORMANCE_TX_QUEUE_COMP))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("performanceCnt.queueCompVal for Tx has to be in the range of 1 - %d", MAX_PERFORMANCE_TX_QUEUE_COMP));
break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- case(e_FM_PORT_TYPE_OH_HOST_COMMAND):
+ case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
+ case (e_FM_PORT_TYPE_OH_HOST_COMMAND):
if (p_FmPortPerformanceCnt->queueCompVal)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("performanceCnt.queueCompVal is not relevant for H/O ports."));
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("performanceCnt.queueCompVal is not relevant for H/O ports."));
break;
default:
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
}
- tmpReg = 0;
- tmpReg |= ((uint32_t)(p_FmPortPerformanceCnt->queueCompVal - 1) << BMI_PERFORMANCE_PORT_COMP_SHIFT);
- tmpReg |= ((uint32_t)(p_FmPortPerformanceCnt->dmaCompVal- 1) << BMI_PERFORMANCE_DMA_COMP_SHIFT);
- tmpReg |= ((uint32_t)(p_FmPortPerformanceCnt->fifoCompVal/BMI_FIFO_UNITS - 1) << BMI_PERFORMANCE_FIFO_COMP_SHIFT);
- if ((p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING) && (p_FmPort->portType != e_FM_PORT_TYPE_OH_HOST_COMMAND))
- tmpReg |= ((uint32_t)(p_FmPortPerformanceCnt->taskCompVal - 1) << BMI_PERFORMANCE_TASK_COMP_SHIFT);
+ params.task_val = p_FmPortPerformanceCnt->taskCompVal;
+ params.queue_val = p_FmPortPerformanceCnt->queueCompVal;
+ params.dma_val = p_FmPortPerformanceCnt->dmaCompVal;
+ params.fifo_val = p_FmPortPerformanceCnt->fifoCompVal;
- WRITE_UINT32(*p_BmiPcpReg, tmpReg);
+ err = fman_port_set_perf_cnt_params(&p_FmPort->port, &params);
+ if (err != 0)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_set_perf_cnt_params"));
return E_OK;
}
t_Error FM_PORT_AnalyzePerformanceParams(t_Handle h_FmPort)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- t_FmPortPerformanceCnt currParams, savedParams;
- t_Error err;
- bool underTest, failed = FALSE;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_FmPortPerformanceCnt currParams, savedParams;
+ t_Error err;
+ bool underTest, failed = FALSE;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
XX_Print("Analyzing Performance parameters for port (type %d, id%d)\n",
p_FmPort->portType, p_FmPort->portId);
- currParams.taskCompVal = (uint8_t)p_FmPort->tasks.num;
- if ((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING) ||
- (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND))
- currParams.queueCompVal = 0;
+ currParams.taskCompVal = (uint8_t)p_FmPort->tasks.num;
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND))
+ currParams.queueCompVal = 0;
else
- currParams.queueCompVal = 1;
- currParams.dmaCompVal =(uint8_t) p_FmPort->openDmas.num;
- currParams.fifoCompVal = p_FmPort->fifoBufs.num;
+ currParams.queueCompVal = 1;
+ currParams.dmaCompVal = (uint8_t)p_FmPort->openDmas.num;
+ currParams.fifoCompVal = p_FmPort->fifoBufs.num;
FM_PORT_SetPerformanceCounters(p_FmPort, FALSE);
ClearPerfCnts(p_FmPort);
- if ((err = FM_PORT_SetPerformanceCountersParams(p_FmPort, &currParams)) != E_OK)
+ if ((err = FM_PORT_SetPerformanceCountersParams(p_FmPort, &currParams))
+ != E_OK)
RETURN_ERROR(MAJOR, err, NO_MSG);
FM_PORT_SetPerformanceCounters(p_FmPort, TRUE);
XX_UDelay(1000000);
FM_PORT_SetPerformanceCounters(p_FmPort, FALSE);
if (FM_PORT_GetCounter(p_FmPort, e_FM_PORT_COUNTERS_TASK_UTIL))
{
- XX_Print ("Max num of defined port tasks (%d) utilized - Please enlarge\n",p_FmPort->tasks.num);
+ XX_Print(
+ "Max num of defined port tasks (%d) utilized - Please enlarge\n",
+ p_FmPort->tasks.num);
failed = TRUE;
}
if (FM_PORT_GetCounter(p_FmPort, e_FM_PORT_COUNTERS_DMA_UTIL))
{
- XX_Print ("Max num of defined port openDmas (%d) utilized - Please enlarge\n",p_FmPort->openDmas.num);
+ XX_Print(
+ "Max num of defined port openDmas (%d) utilized - Please enlarge\n",
+ p_FmPort->openDmas.num);
failed = TRUE;
}
if (FM_PORT_GetCounter(p_FmPort, e_FM_PORT_COUNTERS_FIFO_UTIL))
{
- XX_Print ("Max size of defined port fifo (%d) utilized - Please enlarge\n",p_FmPort->fifoBufs.num*BMI_FIFO_UNITS);
+ XX_Print(
+ "Max size of defined port fifo (%d) utilized - Please enlarge\n",
+ p_FmPort->fifoBufs.num);
failed = TRUE;
}
if (failed)
- RETURN_ERROR(MINOR, E_INVALID_STATE, NO_MSG);
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
memset(&savedParams, 0, sizeof(savedParams));
while (TRUE)
@@ -3734,7 +3904,8 @@ t_Error FM_PORT_AnalyzePerformanceParams(t_Handle h_FmPort)
currParams.dmaCompVal--;
underTest = TRUE;
}
- if ((currParams.fifoCompVal != BMI_FIFO_UNITS) && !savedParams.fifoCompVal)
+ if ((currParams.fifoCompVal != BMI_FIFO_UNITS)
+ && !savedParams.fifoCompVal)
{
currParams.fifoCompVal -= BMI_FIFO_UNITS;
underTest = TRUE;
@@ -3743,146 +3914,278 @@ t_Error FM_PORT_AnalyzePerformanceParams(t_Handle h_FmPort)
break;
ClearPerfCnts(p_FmPort);
- if ((err = FM_PORT_SetPerformanceCountersParams(p_FmPort, &currParams)) != E_OK)
+ if ((err = FM_PORT_SetPerformanceCountersParams(p_FmPort, &currParams))
+ != E_OK)
RETURN_ERROR(MAJOR, err, NO_MSG);
FM_PORT_SetPerformanceCounters(p_FmPort, TRUE);
XX_UDelay(1000000);
FM_PORT_SetPerformanceCounters(p_FmPort, FALSE);
- if (!savedParams.taskCompVal && FM_PORT_GetCounter(p_FmPort, e_FM_PORT_COUNTERS_TASK_UTIL))
- savedParams.taskCompVal = (uint8_t)(currParams.taskCompVal+2);
- if (!savedParams.dmaCompVal && FM_PORT_GetCounter(p_FmPort, e_FM_PORT_COUNTERS_DMA_UTIL))
- savedParams.dmaCompVal = (uint8_t)(currParams.dmaCompVal+2);
- if (!savedParams.fifoCompVal && FM_PORT_GetCounter(p_FmPort, e_FM_PORT_COUNTERS_FIFO_UTIL))
- savedParams.fifoCompVal = currParams.fifoCompVal+2;
+ if (!savedParams.taskCompVal
+ && FM_PORT_GetCounter(p_FmPort, e_FM_PORT_COUNTERS_TASK_UTIL))
+ savedParams.taskCompVal = (uint8_t)(currParams.taskCompVal + 2);
+ if (!savedParams.dmaCompVal
+ && FM_PORT_GetCounter(p_FmPort, e_FM_PORT_COUNTERS_DMA_UTIL))
+ savedParams.dmaCompVal = (uint8_t)(currParams.dmaCompVal + 2);
+ if (!savedParams.fifoCompVal
+ && FM_PORT_GetCounter(p_FmPort, e_FM_PORT_COUNTERS_FIFO_UTIL))
+ savedParams.fifoCompVal = currParams.fifoCompVal
+ + (2 * BMI_FIFO_UNITS);
}
XX_Print("best vals: tasks %d, dmas %d, fifos %d\n",
- savedParams.taskCompVal, savedParams.dmaCompVal, savedParams.fifoCompVal);
+ savedParams.taskCompVal, savedParams.dmaCompVal,
+ savedParams.fifoCompVal);
return E_OK;
}
t_Error FM_PORT_SetStatisticsCounters(t_Handle h_FmPort, bool enable)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- uint32_t tmpReg;
- volatile uint32_t *p_BmiStcReg = NULL;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ int err;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
- switch(p_FmPort->portType)
- {
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- p_BmiStcReg = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rstc;
- break;
- case(e_FM_PORT_TYPE_TX_10G):
- case(e_FM_PORT_TYPE_TX):
- p_BmiStcReg = &p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tstc;
- break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- case(e_FM_PORT_TYPE_OH_HOST_COMMAND):
- p_BmiStcReg = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ostc;
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
- }
-
- tmpReg = GET_UINT32(*p_BmiStcReg);
-
- if(enable)
- tmpReg |= BMI_COUNTERS_EN;
- else
- tmpReg &= ~BMI_COUNTERS_EN;
-
- WRITE_UINT32(*p_BmiStcReg, tmpReg);
-
+ err = fman_port_set_stats_cnt_mode(&p_FmPort->port, enable);
+ if (err != 0)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_set_stats_cnt_mode"));
return E_OK;
}
-t_Error FM_PORT_SetErrorsRoute(t_Handle h_FmPort, fmPortFrameErrSelect_t errs)
+t_Error FM_PORT_SetErrorsRoute(t_Handle h_FmPort, fmPortFrameErrSelect_t errs)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- volatile uint32_t *p_ErrQReg, *p_ErrDiscard;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ volatile uint32_t *p_ErrDiscard = NULL;
+ int err;
- switch(p_FmPort->portType)
- {
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- p_ErrQReg = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfsem;
- p_ErrDiscard = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfsdm;
- break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- p_ErrQReg = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofsem;
- p_ErrDiscard = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofsdm;
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx and offline parsing ports only"));
- }
+ UNUSED(p_ErrDiscard);
+ err = fman_port_set_err_mask(&p_FmPort->port, (uint32_t)errs);
+ if (err != 0)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_set_err_mask"));
- if (GET_UINT32(*p_ErrDiscard) & errs)
- RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Selectd Errors that were configured to cause frame discard."));
+#ifdef FM_ERROR_VSP_NO_MATCH_SW006
+ if (p_FmPort->fmRevInfo.majorRev >= 6)
+ {
+ t_FmPcdCtrlParamsPage *p_ParamsPage;
- WRITE_UINT32(*p_ErrQReg, errs);
+ FmPortSetGprFunc(p_FmPort, e_FM_PORT_GPR_MURAM_PAGE,
+ (void**)&p_ParamsPage);
+ ASSERT_COND(p_ParamsPage);
+ switch (p_FmPort->portType)
+ {
+ case (e_FM_PORT_TYPE_RX_10G):
+ case (e_FM_PORT_TYPE_RX):
+ p_ErrDiscard =
+ &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfsdm;
+ break;
+ case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
+ p_ErrDiscard =
+ &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofsdm;
+ break;
+ default:
+ RETURN_ERROR(
+ MAJOR, E_INVALID_OPERATION,
+ ("available for Rx and offline parsing ports only"));
+ }
+ WRITE_UINT32(p_ParamsPage->errorsDiscardMask,
+ GET_UINT32(*p_ErrDiscard) | errs);
+ }
+#endif /* FM_ERROR_VSP_NO_MATCH_SW006 */
return E_OK;
}
-t_Error FM_PORT_SetAllocBufCounter(t_Handle h_FmPort, uint8_t poolId, bool enable)
+t_Error FM_PORT_SetAllocBufCounter(t_Handle h_FmPort, uint8_t poolId,
+ bool enable)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- uint32_t tmpReg;
- int i;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ int err;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(poolId<BM_MAX_NUM_OF_POOLS, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
- if((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx ports only"));
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for Rx ports only"));
- for(i=0 ; i< FM_PORT_MAX_NUM_OF_EXT_POOLS ; i++)
- {
- tmpReg = GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_ebmpi[i]);
- if ((uint8_t)((tmpReg & BMI_EXT_BUF_POOL_ID_MASK) >> BMI_EXT_BUF_POOL_ID_SHIFT) == poolId)
- {
- if(enable)
- tmpReg |= BMI_EXT_BUF_POOL_EN_COUNTER;
- else
- tmpReg &= ~BMI_EXT_BUF_POOL_EN_COUNTER;
- WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_ebmpi[i], tmpReg);
- break;
- }
- }
- if (i == FM_PORT_MAX_NUM_OF_EXT_POOLS)
- RETURN_ERROR(MINOR, E_INVALID_VALUE,("poolId %d is not included in this ports pools", poolId));
+ err = fman_port_set_bpool_cnt_mode(&p_FmPort->port, poolId, enable);
+ if (err != 0)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_set_bpool_cnt_mode"));
+ return E_OK;
+}
+
+t_Error FM_PORT_GetBmiCounters(t_Handle h_FmPort, t_FmPortBmiStats *p_BmiStats)
+{
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_RX)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G)){
+ p_BmiStats->cntCycle =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_CYCLE);
+ /* fmbm_rccn */
+ p_BmiStats->cntTaskUtil =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_TASK_UTIL);
+ /* fmbm_rtuc */
+ p_BmiStats->cntQueueUtil =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_QUEUE_UTIL);
+ /* fmbm_rrquc */
+ p_BmiStats->cntDmaUtil =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_DMA_UTIL);
+ /* fmbm_rduc */
+ p_BmiStats->cntFifoUtil =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_FIFO_UTIL);
+ /* fmbm_rfuc */
+ p_BmiStats->cntRxPauseActivation =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_RX_PAUSE_ACTIVATION);
+ /* fmbm_rpac */
+ p_BmiStats->cntFrame =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_FRAME);
+ /* fmbm_rfrc */
+ p_BmiStats->cntDiscardFrame =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_DISCARD_FRAME);
+ /* fmbm_rfdc */
+ p_BmiStats->cntDeallocBuf =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_DEALLOC_BUF);
+ /* fmbm_rbdc */
+ p_BmiStats->cntRxBadFrame =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_RX_BAD_FRAME);
+ /* fmbm_rfbc */
+ p_BmiStats->cntRxLargeFrame =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_RX_LARGE_FRAME);
+ /* fmbm_rlfc */
+ p_BmiStats->cntRxFilterFrame =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_RX_FILTER_FRAME);
+ /* fmbm_rffc */
+ p_BmiStats->cntRxListDmaErr =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR);
+ /* fmbm_rfldec */
+ p_BmiStats->cntRxOutOfBuffersDiscard =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD);
+ /* fmbm_rodc */
+ p_BmiStats->cntWredDiscard = 0;
+ p_BmiStats->cntLengthErr = 0;
+ p_BmiStats->cntUnsupportedFormat = 0;
+ }
+ else if ((p_FmPort->portType == e_FM_PORT_TYPE_TX)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_TX_10G)){
+ p_BmiStats->cntCycle =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_CYCLE);
+ /* fmbm_tccn */
+ p_BmiStats->cntTaskUtil =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_TASK_UTIL);
+ /* fmbm_ttuc */
+ p_BmiStats->cntQueueUtil =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_QUEUE_UTIL);
+ /* fmbm_ttcquc */
+ p_BmiStats->cntDmaUtil =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_DMA_UTIL);
+ /* fmbm_tduc */
+ p_BmiStats->cntFifoUtil =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_FIFO_UTIL);
+ /* fmbm_tfuc */
+ p_BmiStats->cntRxPauseActivation = 0;
+ p_BmiStats->cntFrame =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_FRAME);
+ /* fmbm_tfrc */
+ p_BmiStats->cntDiscardFrame =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_DISCARD_FRAME);
+ /* fmbm_tfdc */
+ p_BmiStats->cntDeallocBuf =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_DEALLOC_BUF);
+ /* fmbm_tbdc */
+ p_BmiStats->cntRxBadFrame = 0;
+ p_BmiStats->cntRxLargeFrame = 0;
+ p_BmiStats->cntRxFilterFrame = 0;
+ p_BmiStats->cntRxListDmaErr = 0;
+ p_BmiStats->cntRxOutOfBuffersDiscard = 0;
+ p_BmiStats->cntWredDiscard = 0;
+ p_BmiStats->cntLengthErr =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_LENGTH_ERR);
+ /* fmbm_tfledc */
+ p_BmiStats->cntUnsupportedFormat =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT);
+ /* fmbm_tfufdc */
+ }
+ else if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING) {
+ p_BmiStats->cntCycle =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_CYCLE);
+ /* fmbm_occn */
+ p_BmiStats->cntTaskUtil =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_TASK_UTIL);
+ /* fmbm_otuc */
+ p_BmiStats->cntQueueUtil = 0;
+ p_BmiStats->cntDmaUtil =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_DMA_UTIL);
+ /* fmbm_oduc */
+ p_BmiStats->cntFifoUtil =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_FIFO_UTIL);
+ /* fmbm_ofuc*/
+ p_BmiStats->cntRxPauseActivation = 0;
+ p_BmiStats->cntFrame =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_FRAME);
+ /* fmbm_ofrc */
+ p_BmiStats->cntDiscardFrame =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_DISCARD_FRAME);
+ /* fmbm_ofdc */
+ p_BmiStats->cntDeallocBuf =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_DEALLOC_BUF);
+ /* fmbm_obdc*/
+ p_BmiStats->cntRxBadFrame = 0;
+ p_BmiStats->cntRxLargeFrame = 0;
+ p_BmiStats->cntRxFilterFrame =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_RX_FILTER_FRAME);
+ /* fmbm_offc */
+ p_BmiStats->cntRxListDmaErr =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR);
+ /* fmbm_ofldec */
+ p_BmiStats->cntRxOutOfBuffersDiscard =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD);
+ /* fmbm_rodc */
+ p_BmiStats->cntWredDiscard =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_WRED_DISCARD);
+ /* fmbm_ofwdc */
+ p_BmiStats->cntLengthErr =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_LENGTH_ERR);
+ /* fmbm_ofledc */
+ p_BmiStats->cntUnsupportedFormat =
+ FM_PORT_GetCounter(h_FmPort, e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT);
+ /* fmbm_ofufdc */
+ }
return E_OK;
}
uint32_t FM_PORT_GetCounter(t_Handle h_FmPort, e_FmPortCounters counter)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- bool bmiCounter = FALSE;
- volatile uint32_t *p_Reg;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ bool bmiCounter = FALSE;
+ enum fman_port_stats_counters statsType;
+ enum fman_port_perf_counters perfType;
+ enum fman_port_qmi_counters queueType;
+ bool isStats;
+ t_Error errCode;
SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, 0);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
- switch(counter)
+ switch (counter)
{
- case(e_FM_PORT_COUNTERS_DEQ_TOTAL):
- case(e_FM_PORT_COUNTERS_DEQ_FROM_DEFAULT):
- case(e_FM_PORT_COUNTERS_DEQ_CONFIRM ):
+ case (e_FM_PORT_COUNTERS_DEQ_TOTAL):
+ case (e_FM_PORT_COUNTERS_DEQ_FROM_DEFAULT):
+ case (e_FM_PORT_COUNTERS_DEQ_CONFIRM):
/* check that counter is available for the port type */
- if((p_FmPort->portType == e_FM_PORT_TYPE_RX) || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_RX)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
{
- REPORT_ERROR(MINOR, E_INVALID_STATE, ("Requested counter is not available for Rx ports"));
+ REPORT_ERROR(MINOR, E_INVALID_STATE,
+ ("Requested counter is not available for Rx ports"));
return 0;
}
bmiCounter = FALSE;
- case(e_FM_PORT_COUNTERS_ENQ_TOTAL):
+ break;
+ case (e_FM_PORT_COUNTERS_ENQ_TOTAL):
bmiCounter = FALSE;
break;
default: /* BMI counters (or error - will be checked in BMI routine )*/
@@ -3890,88 +4193,83 @@ uint32_t FM_PORT_GetCounter(t_Handle h_FmPort, e_FmPortCounters counter)
break;
}
- if(bmiCounter)
+ if (bmiCounter)
{
- switch(p_FmPort->portType)
+ errCode = BmiPortCheckAndGetCounterType(p_FmPort, counter, &statsType,
+ &perfType, &isStats);
+ if (errCode != E_OK)
{
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- if(BmiRxPortCheckAndGetCounterPtr(p_FmPort, counter, &p_Reg))
- {
- REPORT_ERROR(MINOR, E_INVALID_STATE, NO_MSG);
- return 0;
- }
- break;
- case(e_FM_PORT_TYPE_TX_10G):
- case(e_FM_PORT_TYPE_TX):
- if(BmiTxPortCheckAndGetCounterPtr(p_FmPort, counter, &p_Reg))
- {
- REPORT_ERROR(MINOR, E_INVALID_STATE, NO_MSG);
- return 0;
- }
- break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- case(e_FM_PORT_TYPE_OH_HOST_COMMAND):
- if(BmiOhPortCheckAndGetCounterPtr(p_FmPort, counter, &p_Reg))
- {
- REPORT_ERROR(MINOR, E_INVALID_STATE, NO_MSG);
- return 0;
- }
- break;
- default:
- REPORT_ERROR(MINOR, E_INVALID_STATE, ("Unsupported port type"));
- return 0;
+ REPORT_ERROR(MINOR, errCode, NO_MSG);
+ return 0;
}
- return GET_UINT32(*p_Reg);
+ if (isStats)
+ return fman_port_get_stats_counter(&p_FmPort->port, statsType);
+ else
+ return fman_port_get_perf_counter(&p_FmPort->port, perfType);
}
else /* QMI counter */
{
-
/* check that counters are enabled */
- if(!(GET_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnc) & QMI_PORT_CFG_EN_COUNTERS))
+ if (!(GET_UINT32(p_FmPort->port.qmi_regs->fmqm_pnc)
+ & QMI_PORT_CFG_EN_COUNTERS))
+
{
REPORT_ERROR(MINOR, E_INVALID_STATE, ("Requested counter was not enabled"));
return 0;
}
/* Set counter */
- switch(counter)
+ switch (counter)
{
- case(e_FM_PORT_COUNTERS_ENQ_TOTAL):
- return GET_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnetfc);
- case(e_FM_PORT_COUNTERS_DEQ_TOTAL):
- return GET_UINT32(p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs.fmqm_pndtfc);
- case(e_FM_PORT_COUNTERS_DEQ_FROM_DEFAULT):
- return GET_UINT32(p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs.fmqm_pndfdc);
- case(e_FM_PORT_COUNTERS_DEQ_CONFIRM):
- return GET_UINT32(p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs.fmqm_pndcc);
+ case (e_FM_PORT_COUNTERS_ENQ_TOTAL):
+ queueType = E_FMAN_PORT_ENQ_TOTAL;
+ break;
+ case (e_FM_PORT_COUNTERS_DEQ_TOTAL):
+ queueType = E_FMAN_PORT_DEQ_TOTAL;
+ break;
+ case (e_FM_PORT_COUNTERS_DEQ_FROM_DEFAULT):
+ queueType = E_FMAN_PORT_DEQ_FROM_DFLT;
+ break;
+ case (e_FM_PORT_COUNTERS_DEQ_CONFIRM):
+ queueType = E_FMAN_PORT_DEQ_CONFIRM;
+ break;
default:
REPORT_ERROR(MINOR, E_INVALID_STATE, ("Requested counter is not available"));
return 0;
}
+
+ return fman_port_get_qmi_counter(&p_FmPort->port, queueType);
}
return 0;
}
-t_Error FM_PORT_ModifyCounter(t_Handle h_FmPort, e_FmPortCounters counter, uint32_t value)
+t_Error FM_PORT_ModifyCounter(t_Handle h_FmPort, e_FmPortCounters counter,
+ uint32_t value)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- bool bmiCounter = FALSE;
- volatile uint32_t *p_Reg;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ bool bmiCounter = FALSE;
+ enum fman_port_stats_counters statsType;
+ enum fman_port_perf_counters perfType;
+ enum fman_port_qmi_counters queueType;
+ bool isStats;
+ t_Error errCode;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
- switch(counter)
+ switch (counter)
{
- case(e_FM_PORT_COUNTERS_DEQ_TOTAL):
- case(e_FM_PORT_COUNTERS_DEQ_FROM_DEFAULT):
- case(e_FM_PORT_COUNTERS_DEQ_CONFIRM ):
+ case (e_FM_PORT_COUNTERS_DEQ_TOTAL):
+ case (e_FM_PORT_COUNTERS_DEQ_FROM_DEFAULT):
+ case (e_FM_PORT_COUNTERS_DEQ_CONFIRM):
/* check that counter is available for the port type */
- if((p_FmPort->portType == e_FM_PORT_TYPE_RX) || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter is not available for Rx ports"));
- case(e_FM_PORT_COUNTERS_ENQ_TOTAL):
+ if ((p_FmPort->portType == e_FM_PORT_TYPE_RX)
+ || (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
+ RETURN_ERROR(
+ MINOR, E_INVALID_STATE,
+ ("Requested counter is not available for Rx ports"));
+ case (e_FM_PORT_COUNTERS_ENQ_TOTAL):
bmiCounter = FALSE;
break;
default: /* BMI counters (or error - will be checked in BMI routine )*/
@@ -3979,55 +4277,50 @@ t_Error FM_PORT_ModifyCounter(t_Handle h_FmPort, e_FmPortCounters counter, uint3
break;
}
- if(bmiCounter)
+ if (bmiCounter)
{
- switch(p_FmPort->portType)
+ errCode = BmiPortCheckAndGetCounterType(p_FmPort, counter, &statsType,
+ &perfType, &isStats);
+ if (errCode != E_OK)
{
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- if(BmiRxPortCheckAndGetCounterPtr(p_FmPort, counter, &p_Reg))
- RETURN_ERROR(MINOR, E_INVALID_STATE, NO_MSG);
- break;
- case(e_FM_PORT_TYPE_TX_10G):
- case(e_FM_PORT_TYPE_TX):
- if(BmiTxPortCheckAndGetCounterPtr(p_FmPort, counter, &p_Reg))
- RETURN_ERROR(MINOR, E_INVALID_STATE, NO_MSG);
- break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- case(e_FM_PORT_TYPE_OH_HOST_COMMAND):
- if(BmiOhPortCheckAndGetCounterPtr(p_FmPort, counter, &p_Reg))
- RETURN_ERROR(MINOR, E_INVALID_STATE, NO_MSG);
- break;
- default:
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Unsupported port type"));
+ RETURN_ERROR(MINOR, errCode, NO_MSG);
}
- WRITE_UINT32(*p_Reg, value);
+ if (isStats)
+ fman_port_set_stats_counter(&p_FmPort->port, statsType, value);
+ else
+ fman_port_set_perf_counter(&p_FmPort->port, perfType, value);
}
else /* QMI counter */
{
-
/* check that counters are enabled */
- if(!(GET_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnc) & QMI_PORT_CFG_EN_COUNTERS))
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter was not enabled"));
+ if (!(GET_UINT32(p_FmPort->port.qmi_regs->fmqm_pnc)
+ & QMI_PORT_CFG_EN_COUNTERS))
+ {
+ RETURN_ERROR(MINOR, E_INVALID_STATE,
+ ("Requested counter was not enabled"));
+ }
/* Set counter */
- switch(counter)
+ switch (counter)
{
- case(e_FM_PORT_COUNTERS_ENQ_TOTAL):
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnetfc, value);
+ case (e_FM_PORT_COUNTERS_ENQ_TOTAL):
+ queueType = E_FMAN_PORT_ENQ_TOTAL;
break;
- case(e_FM_PORT_COUNTERS_DEQ_TOTAL):
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs.fmqm_pndtfc, value);
+ case (e_FM_PORT_COUNTERS_DEQ_TOTAL):
+ queueType = E_FMAN_PORT_DEQ_TOTAL;
break;
- case(e_FM_PORT_COUNTERS_DEQ_FROM_DEFAULT):
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs.fmqm_pndfdc, value);
+ case (e_FM_PORT_COUNTERS_DEQ_FROM_DEFAULT):
+ queueType = E_FMAN_PORT_DEQ_FROM_DFLT;
break;
- case(e_FM_PORT_COUNTERS_DEQ_CONFIRM):
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs.fmqm_pndcc, value);
+ case (e_FM_PORT_COUNTERS_DEQ_CONFIRM):
+ queueType = E_FMAN_PORT_DEQ_CONFIRM;
break;
default:
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter is not available"));
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("Requested counter is not available"));
}
+
+ fman_port_set_qmi_counter(&p_FmPort->port, queueType, value);
}
return E_OK;
@@ -4035,90 +4328,50 @@ t_Error FM_PORT_ModifyCounter(t_Handle h_FmPort, e_FmPortCounters counter, uint3
uint32_t FM_PORT_GetAllocBufCounter(t_Handle h_FmPort, uint8_t poolId)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- uint32_t extPoolReg;
- uint8_t tmpPool;
- uint8_t i;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, 0);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
- if((p_FmPort->portType != e_FM_PORT_TYPE_RX) && (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX)
+ && (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
{
REPORT_ERROR(MINOR, E_INVALID_STATE, ("Requested counter is not available for non-Rx ports"));
return 0;
}
-
- for(i=0;i<FM_PORT_MAX_NUM_OF_EXT_POOLS;i++)
- {
- extPoolReg = GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_ebmpi[i]);
- if (extPoolReg & BMI_EXT_BUF_POOL_VALID)
- {
- tmpPool = (uint8_t)((extPoolReg & BMI_EXT_BUF_POOL_ID_MASK) >> BMI_EXT_BUF_POOL_ID_SHIFT);
- if(tmpPool == poolId)
- {
- if(extPoolReg & BMI_EXT_BUF_POOL_EN_COUNTER)
- return GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_acnt[i]);
- else
- {
- REPORT_ERROR(MINOR, E_INVALID_STATE, ("Requested counter is not enabled"));
- return 0;
- }
- }
- }
- }
- REPORT_ERROR(MINOR, E_INVALID_STATE, ("Pool %d is not used", poolId));
- return 0;
+ return fman_port_get_bpool_counter(&p_FmPort->port, poolId);
}
-t_Error FM_PORT_ModifyAllocBufCounter(t_Handle h_FmPort, uint8_t poolId, uint32_t value)
+t_Error FM_PORT_ModifyAllocBufCounter(t_Handle h_FmPort, uint8_t poolId,
+ uint32_t value)
{
- t_FmPort *p_FmPort = (t_FmPort *)h_FmPort;
- uint32_t extPoolReg;
- uint8_t tmpPool;
- uint8_t i;
+ t_FmPort *p_FmPort = (t_FmPort *)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
- if((p_FmPort->portType != e_FM_PORT_TYPE_RX) && (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter is not available for non-Rx ports"));
-
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX)
+ && (p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
+ RETURN_ERROR( MINOR, E_INVALID_STATE,
+ ("Requested counter is not available for non-Rx ports"));
- for(i=0;i<FM_PORT_MAX_NUM_OF_EXT_POOLS;i++)
- {
- extPoolReg = GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_ebmpi[i]);
- if (extPoolReg & BMI_EXT_BUF_POOL_VALID)
- {
- tmpPool = (uint8_t)((extPoolReg & BMI_EXT_BUF_POOL_ID_MASK) >> BMI_EXT_BUF_POOL_ID_SHIFT);
- if(tmpPool == poolId)
- {
- if(extPoolReg & BMI_EXT_BUF_POOL_EN_COUNTER)
- {
- WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_acnt[i], value);
- return E_OK;
- }
- else
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter is not enabled"));
- }
- }
- }
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Pool %d is not used", poolId));
+ fman_port_set_bpool_counter(&p_FmPort->port, poolId, value);
+ return E_OK;
}
-
bool FM_PORT_IsStalled(t_Handle h_FmPort)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- t_Error err;
- bool isStalled;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_Error err;
+ bool isStalled;
SANITY_CHECK_RETURN_VALUE(p_FmPort, E_INVALID_HANDLE, FALSE);
- SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE, FALSE);
+ SANITY_CHECK_RETURN_VALUE(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE,
+ FALSE);
err = FmIsPortStalled(p_FmPort->h_Fm, p_FmPort->hardwarePortId, &isStalled);
- if(err != E_OK)
+ if (err != E_OK)
{
- REPORT_ERROR(MINOR, err, NO_MSG);
+ REPORT_ERROR(MAJOR, err, NO_MSG);
return TRUE;
}
return isStalled;
@@ -4126,7 +4379,7 @@ bool FM_PORT_IsStalled(t_Handle h_FmPort)
t_Error FM_PORT_ReleaseStalled(t_Handle h_FmPort)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
@@ -4137,164 +4390,313 @@ t_Error FM_PORT_ReleaseStalled(t_Handle h_FmPort)
t_Error FM_PORT_SetRxL4ChecksumVerify(t_Handle h_FmPort, bool l4Checksum)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- uint32_t tmpReg;
+ int err;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
- if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) &&
- (p_FmPort->portType != e_FM_PORT_TYPE_RX))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx ports only"));
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for Rx ports only"));
- tmpReg = GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfne);
if (l4Checksum)
- tmpReg &= ~BMI_PORT_RFNE_FRWD_DCL4C;
+ err = fman_port_modify_rx_fd_bits(
+ &p_FmPort->port, (uint8_t)(BMI_PORT_RFNE_FRWD_DCL4C >> 24),
+ TRUE);
else
- tmpReg |= BMI_PORT_RFNE_FRWD_DCL4C;
- WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfne, tmpReg);
+ err = fman_port_modify_rx_fd_bits(
+ &p_FmPort->port, (uint8_t)(BMI_PORT_RFNE_FRWD_DCL4C >> 24),
+ FALSE);
+ if (err != 0)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_modify_rx_fd_bits"));
return E_OK;
}
+/*****************************************************************************/
+/* API Run-time PCD Control unit functions */
+/*****************************************************************************/
+
+#if (DPAA_VERSION >= 11)
+t_Error FM_PORT_VSPAlloc(t_Handle h_FmPort, t_FmPortVSPAllocParams *p_VSPParams)
+{
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_Error err = E_OK;
+ volatile uint32_t *p_BmiStorageProfileId = NULL, *p_BmiVspe = NULL;
+ uint32_t tmpReg = 0, tmp = 0;
+ uint16_t hwStoragePrflId;
-/* API Run-time PCD Control unit functions */
+ SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPort->h_Fm, E_INVALID_HANDLE);
+ /*for numOfProfiles = 0 don't call this function*/
+ SANITY_CHECK_RETURN_ERROR(p_VSPParams->numOfProfiles, E_INVALID_VALUE);
+ /*dfltRelativeId should be in the range of numOfProfiles*/
+ SANITY_CHECK_RETURN_ERROR(
+ p_VSPParams->dfltRelativeId < p_VSPParams->numOfProfiles,
+ E_INVALID_VALUE);
+ /*p_FmPort should be from Rx type or OP*/
+ SANITY_CHECK_RETURN_ERROR(
+ ((p_FmPort->portType == e_FM_PORT_TYPE_RX_10G) || (p_FmPort->portType == e_FM_PORT_TYPE_RX) || (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)),
+ E_INVALID_VALUE);
+ /*port should be disabled*/
+ SANITY_CHECK_RETURN_ERROR(!p_FmPort->enabled, E_INVALID_STATE);
+ /*if its called for Rx port relevant Tx Port should be passed (initialized) too and it should be disabled*/
+ SANITY_CHECK_RETURN_ERROR(
+ ((p_VSPParams->h_FmTxPort && !((t_FmPort *)(p_VSPParams->h_FmTxPort))->enabled) || (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)),
+ E_INVALID_VALUE);
+ /*should be called before SetPCD - this port should be without PCD*/
+ SANITY_CHECK_RETURN_ERROR(!p_FmPort->pcdEngines, E_INVALID_STATE);
+
+ /*alloc window of VSPs for this port*/
+ err = FmVSPAllocForPort(p_FmPort->h_Fm, p_FmPort->portType,
+ p_FmPort->portId, p_VSPParams->numOfProfiles);
+ if (err != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ /*get absolute VSP ID for dfltRelative*/
+ err = FmVSPGetAbsoluteProfileId(p_FmPort->h_Fm, p_FmPort->portType,
+ p_FmPort->portId,
+ p_VSPParams->dfltRelativeId,
+ &hwStoragePrflId);
+ if (err != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ /*fill relevant registers for p_FmPort and relative TxPort in the case p_FmPort from Rx type*/
+ switch (p_FmPort->portType)
+ {
+ case (e_FM_PORT_TYPE_RX_10G):
+ case (e_FM_PORT_TYPE_RX):
+ p_BmiStorageProfileId =
+ &(((t_FmPort *)(p_VSPParams->h_FmTxPort))->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcfqid);
+ p_BmiVspe =
+ &(((t_FmPort *)(p_VSPParams->h_FmTxPort))->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tfne);
+
+ tmpReg = GET_UINT32(*p_BmiStorageProfileId) & ~BMI_SP_ID_MASK;
+ tmpReg |= (uint32_t)hwStoragePrflId << BMI_SP_ID_SHIFT;
+ WRITE_UINT32(*p_BmiStorageProfileId, tmpReg);
+
+ tmpReg = GET_UINT32(*p_BmiVspe);
+ WRITE_UINT32(*p_BmiVspe, tmpReg | BMI_SP_EN);
+
+ p_BmiStorageProfileId =
+ &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfqid;
+ p_BmiVspe = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rpp;
+ hwStoragePrflId = p_VSPParams->dfltRelativeId;
+ break;
+
+ case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
+ tmpReg = NIA_ENG_BMI | NIA_BMI_AC_FETCH_ALL_FRAME;
+ WRITE_UINT32( p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs.fmqm_pndn,
+ tmpReg);
+
+ p_BmiStorageProfileId =
+ &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofqid;
+ p_BmiVspe = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_opp;
+ tmp |= BMI_EBD_EN;
+ break;
+
+ default:
+ RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
+ ("available for Rx and offline parsing ports only"));
+ }
+
+ p_FmPort->vspe = TRUE;
+ p_FmPort->dfltRelativeId = p_VSPParams->dfltRelativeId;
+
+ tmpReg = GET_UINT32(*p_BmiStorageProfileId) & ~BMI_SP_ID_MASK;
+ tmpReg |= (uint32_t)hwStoragePrflId << BMI_SP_ID_SHIFT;
+ WRITE_UINT32(*p_BmiStorageProfileId, tmpReg);
+
+ tmpReg = GET_UINT32(*p_BmiVspe);
+ WRITE_UINT32(*p_BmiVspe, tmpReg | BMI_SP_EN | tmp);
+ return E_OK;
+}
+#endif /* (DPAA_VERSION >= 11) */
t_Error FM_PORT_PcdPlcrAllocProfiles(t_Handle h_FmPort, uint16_t numOfProfiles)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- t_Error err = E_OK;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_Error err = E_OK;
p_FmPort->h_FmPcd = FmGetPcdHandle(p_FmPort->h_Fm);
ASSERT_COND(p_FmPort->h_FmPcd);
- if(numOfProfiles)
+ if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
{
- err = FmPcdPlcrAllocProfiles(p_FmPort->h_FmPcd, p_FmPort->hardwarePortId, numOfProfiles);
- if(err)
- RETURN_ERROR(MAJOR, err,NO_MSG);
+ DBG(TRACE, ("FM Port Try Lock - BUSY"));
+ return ERROR_CODE(E_BUSY);
}
+
+ if (numOfProfiles)
+ {
+ err = FmPcdPlcrAllocProfiles(p_FmPort->h_FmPcd,
+ p_FmPort->hardwarePortId, numOfProfiles);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+ /* set the port handle within the PCD policer, even if no profiles defined */
FmPcdPortRegister(p_FmPort->h_FmPcd, h_FmPort, p_FmPort->hardwarePortId);
+ RELEASE_LOCK(p_FmPort->lock);
+
return E_OK;
}
t_Error FM_PORT_PcdPlcrFreeProfiles(t_Handle h_FmPort)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- t_Error err = E_OK;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_Error err = E_OK;
+
+ if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
+ {
+ DBG(TRACE, ("FM Port Try Lock - BUSY"));
+ return ERROR_CODE(E_BUSY);
+ }
err = FmPcdPlcrFreeProfiles(p_FmPort->h_FmPcd, p_FmPort->hardwarePortId);
- if(err)
- RETURN_ERROR(MAJOR, err,NO_MSG);
+
+ RELEASE_LOCK(p_FmPort->lock);
+
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
return E_OK;
}
-t_Error FM_PORT_PcdKgModifyInitialScheme (t_Handle h_FmPort, t_FmPcdKgSchemeSelect *p_FmPcdKgScheme)
+t_Error FM_PORT_PcdKgModifyInitialScheme(t_Handle h_FmPort,
+ t_FmPcdKgSchemeSelect *p_FmPcdKgScheme)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- volatile uint32_t *p_BmiHpnia = NULL;
- uint32_t tmpReg;
- uint8_t relativeSchemeId;
- uint8_t physicalSchemeId;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ volatile uint32_t *p_BmiHpnia = NULL;
+ uint32_t tmpReg;
+ uint8_t relativeSchemeId;
+ uint8_t physicalSchemeId;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
- SANITY_CHECK_RETURN_ERROR(p_FmPort->pcdEngines & FM_PCD_KG , E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPort->pcdEngines & FM_PCD_KG,
+ E_INVALID_STATE);
- tmpReg = (uint32_t)((p_FmPort->pcdEngines & FM_PCD_CC)? NIA_KG_CC_EN:0);
- switch(p_FmPort->portType)
+ tmpReg = (uint32_t)((p_FmPort->pcdEngines & FM_PCD_CC) ? NIA_KG_CC_EN : 0);
+ switch (p_FmPort->portType)
{
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- p_BmiHpnia = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfpne;
+ case (e_FM_PORT_TYPE_RX_10G):
+ case (e_FM_PORT_TYPE_RX):
+ p_BmiHpnia = &p_FmPort->port.bmi_regs->rx.fmbm_rfpne;
break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- p_BmiHpnia = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofpne;
+ case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
+ p_BmiHpnia = &p_FmPort->port.bmi_regs->oh.fmbm_ofpne;
break;
default:
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx and offline parsing ports only"));
+ RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
+ ("available for Rx and offline parsing ports only"));
}
if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
+ {
+ DBG(TRACE, ("FM Port Try Lock - BUSY"));
return ERROR_CODE(E_BUSY);
+ }
+
/* if we want to change to direct scheme, we need to check that this scheme is valid */
- if(p_FmPcdKgScheme->direct)
+ if (p_FmPcdKgScheme->direct)
{
- physicalSchemeId = (uint8_t)(PTR_TO_UINT(p_FmPcdKgScheme->h_DirectScheme)-1);
+ physicalSchemeId = FmPcdKgGetSchemeId(p_FmPcdKgScheme->h_DirectScheme);
/* check that this scheme is bound to this port */
- if(!(p_FmPort->schemesPerPortVector & (uint32_t)(1 << (31 - (uint32_t)physicalSchemeId))))
+ if (!(p_FmPort->schemesPerPortVector
+ & (uint32_t)(1 << (31 - (uint32_t)physicalSchemeId))))
{
RELEASE_LOCK(p_FmPort->lock);
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("called with a scheme that is not bound to this port"));
+ RETURN_ERROR(
+ MAJOR, E_INVALID_STATE,
+ ("called with a scheme that is not bound to this port"));
}
- relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmPort->h_FmPcd, physicalSchemeId);
- if(relativeSchemeId >= FM_PCD_KG_NUM_OF_SCHEMES)
+ relativeSchemeId = FmPcdKgGetRelativeSchemeId(p_FmPort->h_FmPcd,
+ physicalSchemeId);
+ if (relativeSchemeId >= FM_PCD_KG_NUM_OF_SCHEMES)
{
RELEASE_LOCK(p_FmPort->lock);
- RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, ("called with invalid Scheme "));
+ RETURN_ERROR(MAJOR, E_NOT_IN_RANGE,
+ ("called with invalid Scheme "));
}
- if(!FmPcdKgIsSchemeValidSw(p_FmPort->h_FmPcd, relativeSchemeId))
+ if (!FmPcdKgIsSchemeValidSw(p_FmPcdKgScheme->h_DirectScheme))
{
RELEASE_LOCK(p_FmPort->lock);
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("called with uninitialized Scheme "));
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("called with uninitialized Scheme "));
}
- WRITE_UINT32(*p_BmiHpnia, NIA_ENG_KG | tmpReg | NIA_KG_DIRECT | (uint32_t)physicalSchemeId);
+ WRITE_UINT32(
+ *p_BmiHpnia,
+ NIA_ENG_KG | tmpReg | NIA_KG_DIRECT | (uint32_t)physicalSchemeId);
}
- else /* change to indirect scheme */
+ else
+ /* change to indirect scheme */
WRITE_UINT32(*p_BmiHpnia, NIA_ENG_KG | tmpReg);
RELEASE_LOCK(p_FmPort->lock);
return E_OK;
}
-t_Error FM_PORT_PcdPlcrModifyInitialProfile (t_Handle h_FmPort, t_Handle h_Profile)
+t_Error FM_PORT_PcdPlcrModifyInitialProfile(t_Handle h_FmPort,
+ t_Handle h_Profile)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- volatile uint32_t *p_BmiNia;
- volatile uint32_t *p_BmiHpnia;
- uint32_t tmpReg;
- uint16_t absoluteProfileId = (uint16_t)(PTR_TO_UINT(h_Profile)-1);
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ volatile uint32_t *p_BmiNia;
+ volatile uint32_t *p_BmiHpnia;
+ uint32_t tmpReg;
+ uint16_t absoluteProfileId = FmPcdPlcrProfileGetAbsoluteId(h_Profile);
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
- SANITY_CHECK_RETURN_ERROR(p_FmPort->pcdEngines & FM_PCD_PLCR , E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPort->pcdEngines & FM_PCD_PLCR,
+ E_INVALID_STATE);
+
+ /* check relevance of this routine - only when policer is used
+ directly after BMI or Parser */
+ if ((p_FmPort->pcdEngines & FM_PCD_KG)
+ || (p_FmPort->pcdEngines & FM_PCD_CC))
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("relevant only when PCD support mode is e_FM_PCD_SUPPORT_PLCR_ONLY or e_FM_PCD_SUPPORT_PRS_AND_PLCR"));
- /* check relevancy of this routine - only when policer is used
- directly after BMI or Parser */
- if((p_FmPort->pcdEngines & FM_PCD_KG) || (p_FmPort->pcdEngines & FM_PCD_CC))
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("relevant only when PCD support mode is e_FM_PCD_SUPPORT_PLCR_ONLY or e_FM_PCD_SUPPORT_PRS_AND_PLCR"));
-
- switch(p_FmPort->portType)
+ switch (p_FmPort->portType)
{
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- p_BmiNia = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfne;
- p_BmiHpnia = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfpne;
+ case (e_FM_PORT_TYPE_RX_10G):
+ case (e_FM_PORT_TYPE_RX):
+ p_BmiNia = &p_FmPort->port.bmi_regs->rx.fmbm_rfne;
+ p_BmiHpnia = &p_FmPort->port.bmi_regs->rx.fmbm_rfpne;
tmpReg = GET_UINT32(*p_BmiNia) & BMI_RFNE_FDCS_MASK;
break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- p_BmiNia = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofne;
- p_BmiHpnia = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofpne;
+ case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
+ p_BmiNia = &p_FmPort->port.bmi_regs->oh.fmbm_ofne;
+ p_BmiHpnia = &p_FmPort->port.bmi_regs->oh.fmbm_ofpne;
tmpReg = 0;
break;
default:
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx and offline parsing ports only"));
+ RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
+ ("available for Rx and offline parsing ports only"));
}
if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
+ {
+ DBG(TRACE, ("FM Port Try Lock - BUSY"));
return ERROR_CODE(E_BUSY);
- if(!FmPcdPlcrIsProfileValid(p_FmPort->h_FmPcd, absoluteProfileId))
+ }
+
+ if (!FmPcdPlcrIsProfileValid(p_FmPort->h_FmPcd, absoluteProfileId))
{
RELEASE_LOCK(p_FmPort->lock);
RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("Invalid profile"));
}
- tmpReg = (uint32_t)(NIA_ENG_PLCR | NIA_PLCR_ABSOLUTE | absoluteProfileId);
+ tmpReg |= (uint32_t)(NIA_ENG_PLCR | NIA_PLCR_ABSOLUTE | absoluteProfileId);
- if(p_FmPort->pcdEngines & FM_PCD_PRS) /* e_FM_PCD_SUPPORT_PRS_AND_PLCR */
+ if (p_FmPort->pcdEngines & FM_PCD_PRS) /* e_FM_PCD_SUPPORT_PRS_AND_PLCR */
{
/* update BMI HPNIA */
WRITE_UINT32(*p_BmiHpnia, tmpReg);
@@ -4305,107 +4707,133 @@ t_Error FM_PORT_PcdPlcrModifyInitialProfile (t_Handle h_FmPort, t_Handle h_P
tmpReg |= (GET_UINT32(*p_BmiNia) & BMI_RFNE_FDCS_MASK);
/* update BMI NIA */
WRITE_UINT32(*p_BmiNia, tmpReg);
- }
- RELEASE_LOCK(p_FmPort->lock);
+ }RELEASE_LOCK(p_FmPort->lock);
return E_OK;
}
-
-t_Error FM_PORT_PcdCcModifyTree (t_Handle h_FmPort, t_Handle h_CcTree)
+t_Error FM_PORT_PcdCcModifyTree(t_Handle h_FmPort, t_Handle h_CcTree)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- t_Error err = E_OK;
- volatile uint32_t *p_BmiCcBase=NULL;
- volatile uint32_t *p_BmiNia=NULL;
- uint32_t ccTreePhysOffset;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_Error err = E_OK;
+ volatile uint32_t *p_BmiCcBase = NULL;
+ volatile uint32_t *p_BmiNia = NULL;
+ uint32_t ccTreePhysOffset;
- SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_VALUE);
+ SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(h_CcTree, E_INVALID_HANDLE);
if (p_FmPort->imEn)
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for non-independant mode ports only"));
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for non-independent mode ports only"));
/* get PCD registers pointers */
- switch(p_FmPort->portType)
+ switch (p_FmPort->portType)
{
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- p_BmiNia = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfne;
+ case (e_FM_PORT_TYPE_RX_10G):
+ case (e_FM_PORT_TYPE_RX):
+ p_BmiNia = &p_FmPort->port.bmi_regs->rx.fmbm_rfne;
break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- p_BmiNia = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofne;
+ case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
+ p_BmiNia = &p_FmPort->port.bmi_regs->oh.fmbm_ofne;
break;
default:
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx and offline parsing ports only"));
+ RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
+ ("available for Rx and offline parsing ports only"));
}
/* check that current NIA is BMI to BMI */
- if((GET_UINT32(*p_BmiNia) & ~BMI_RFNE_FDCS_MASK) != (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("may be called only for ports in BMI-to-BMI state."));
+ if ((GET_UINT32(*p_BmiNia) & ~BMI_RFNE_FDCS_MASK)
+ != GET_NIA_BMI_AC_ENQ_FRAME(p_FmPort->h_FmPcd))
+ RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
+ ("may be called only for ports in BMI-to-BMI state."));
-/*TODO - to take care of changes due to previous tree. Maybe in the previous tree where chnged pndn, pnen ...
- it has to be returned to the default state - initially*/
-
- p_FmPort->requiredAction = 0;
-
- if(p_FmPort->pcdEngines & FM_PCD_CC)
+ if (p_FmPort->pcdEngines & FM_PCD_CC)
{
- switch(p_FmPort->portType)
+ if (p_FmPort->h_IpReassemblyManip)
+ {
+ err = FmPcdCcTreeAddIPR(p_FmPort->h_FmPcd, h_CcTree, NULL,
+ p_FmPort->h_IpReassemblyManip, FALSE);
+ if (err != E_OK)
+ {
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+ }
+ else
+ if (p_FmPort->h_CapwapReassemblyManip)
+ {
+ err = FmPcdCcTreeAddCPR(p_FmPort->h_FmPcd, h_CcTree, NULL,
+ p_FmPort->h_CapwapReassemblyManip,
+ FALSE);
+ if (err != E_OK)
+ {
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+ }
+ switch (p_FmPort->portType)
{
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- p_BmiCcBase = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rccb;
+ case (e_FM_PORT_TYPE_RX_10G):
+ case (e_FM_PORT_TYPE_RX):
+ p_BmiCcBase = &p_FmPort->port.bmi_regs->rx.fmbm_rccb;
break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- p_BmiCcBase = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_occb;
+ case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
+ p_BmiCcBase = &p_FmPort->port.bmi_regs->oh.fmbm_occb;
break;
default:
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid port type"));
}
if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
+ {
+ DBG(TRACE, ("FM Port Try Lock - BUSY"));
return ERROR_CODE(E_BUSY);
- err = FmPcdCcBindTree(p_FmPort->h_FmPcd, h_CcTree, &ccTreePhysOffset, h_FmPort);
- if(err)
+ }
+ err = FmPcdCcBindTree(p_FmPort->h_FmPcd, NULL, h_CcTree,
+ &ccTreePhysOffset, h_FmPort);
+ if (err)
{
RELEASE_LOCK(p_FmPort->lock);
- RETURN_ERROR(MINOR, err, NO_MSG);
- }
- WRITE_UINT32(*p_BmiCcBase, ccTreePhysOffset);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }WRITE_UINT32(*p_BmiCcBase, ccTreePhysOffset);
p_FmPort->ccTreeId = h_CcTree;
RELEASE_LOCK(p_FmPort->lock);
}
else
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Coarse CLassification not defined for this port."));
+ RETURN_ERROR( MAJOR, E_INVALID_STATE,
+ ("Coarse Classification not defined for this port."));
return E_OK;
}
t_Error FM_PORT_AttachPCD(t_Handle h_FmPort)
{
-
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- t_Error err = E_OK;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_Error err = E_OK;
SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
if (p_FmPort->imEn)
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for non-independant mode ports only"));
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for non-independent mode ports only"));
- /* TODO - may add here checks for:
- SP (or in sw: schemes)
- CPP (or in sw clsPlan)
- Parser enabled and configured(?)
- Tree(?)
- Profile - only if direct.
- Scheme - only if direct
- */
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
+ RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
+ ("available for Rx and offline parsing ports only"));
if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
+ {
+ DBG(TRACE, ("FM Port Try Lock - BUSY"));
return ERROR_CODE(E_BUSY);
- err = FmPortAttachPCD(h_FmPort);
+ }
+
+ if (p_FmPort->h_ReassemblyTree)
+ p_FmPort->pcdEngines |= FM_PCD_CC;
+
+ err = AttachPCD(h_FmPort);
RELEASE_LOCK(p_FmPort->lock);
return err;
@@ -4413,124 +4841,436 @@ t_Error FM_PORT_AttachPCD(t_Handle h_FmPort)
t_Error FM_PORT_DetachPCD(t_Handle h_FmPort)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- volatile uint32_t *p_BmiNia=NULL;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_Error err = E_OK;
SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
if (p_FmPort->imEn)
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for non-independant mode ports only"));
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for non-independent mode ports only"));
- /* get PCD registers pointers */
- switch(p_FmPort->portType)
- {
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- p_BmiNia = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfne;
- break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- p_BmiNia = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofne;
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx and offline parsing ports only"));
- }
-
- WRITE_UINT32(*p_BmiNia, (p_FmPort->savedBmiNia & BMI_RFNE_FDCS_MASK) | (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME));
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
+ RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
+ ("available for Rx and offline parsing ports only"));
-/*TODO - not atomic - it seems that port has to be disabled*/
- if(p_FmPort->requiredAction & UPDATE_NIA_PNEN)
+ if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
{
- switch(p_FmPort->portType)
- {
- case(e_FM_PORT_TYPE_TX_10G):
- case(e_FM_PORT_TYPE_TX):
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnen, NIA_ENG_BMI | NIA_BMI_AC_TX_RELEASE);
- break;
- case(e_FM_PORT_TYPE_OH_HOST_COMMAND):
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- case(e_FM_PORT_TYPE_RX):
- case(e_FM_PORT_TYPE_RX_10G):
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->fmqm_pnen, NIA_ENG_BMI | NIA_BMI_AC_RELEASE);
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Can not reach this stage"));
- }
+ DBG(TRACE, ("FM Port Try Lock - BUSY"));
+ return ERROR_CODE(E_BUSY);
}
- if(p_FmPort->requiredAction & UPDATE_NIA_PNDN)
+ err = DetachPCD(h_FmPort);
+ if (err != E_OK)
{
- switch(p_FmPort->portType)
- {
- case(e_FM_PORT_TYPE_TX_10G):
- case(e_FM_PORT_TYPE_TX):
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs.fmqm_pndn, NIA_ENG_BMI | NIA_BMI_AC_TX);
- break;
- case(e_FM_PORT_TYPE_OH_HOST_COMMAND):
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- WRITE_UINT32(p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs.fmqm_pndn, NIA_ENG_BMI | NIA_BMI_AC_FETCH);
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Can not reach this stage"));
- }
+ RELEASE_LOCK(p_FmPort->lock);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
+ if (p_FmPort->h_ReassemblyTree)
+ p_FmPort->pcdEngines &= ~FM_PCD_CC;
+ RELEASE_LOCK(p_FmPort->lock);
- if(p_FmPort->requiredAction & UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY)
- if(FmSetNumOfRiscsPerPort(p_FmPort->h_Fm, p_FmPort->hardwarePortId, 2)!= E_OK)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
return E_OK;
}
-t_Error FM_PORT_SetPCD(t_Handle h_FmPort, t_FmPortPcdParams *p_PcdParams)
+t_Error FM_PORT_SetPCD(t_Handle h_FmPort, t_FmPortPcdParams *p_PcdParam)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- t_FmPcdKgInterModuleBindPortToSchemes schemeBind;
- t_Error err = E_OK;
- uint8_t i;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_Error err = E_OK;
+ t_FmPortPcdParams modifiedPcdParams, *p_PcdParams;
+ t_FmPcdCcTreeParams *p_FmPcdCcTreeParams;
+ t_FmPortPcdCcParams fmPortPcdCcParams;
+ t_FmPortGetSetCcParams fmPortGetSetCcParams;
SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_PcdParam, E_NULL_POINTER);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
if (p_FmPort->imEn)
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for non-independent mode ports only"));
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for non-independent mode ports only"));
+
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
+ RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
+ ("available for Rx and offline parsing ports only"));
if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
+ {
+ DBG(TRACE, ("FM Port Try Lock - BUSY"));
return ERROR_CODE(E_BUSY);
+ }
+
p_FmPort->h_FmPcd = FmGetPcdHandle(p_FmPort->h_Fm);
ASSERT_COND(p_FmPort->h_FmPcd);
- err = SetPcd( h_FmPort, p_PcdParams);
- if(err)
+ if (p_PcdParam->p_CcParams && !p_PcdParam->p_CcParams->h_CcTree)
+ RETURN_ERROR(MAJOR, E_INVALID_HANDLE,
+ ("Tree handle must be given if CC is required"));
+
+ memcpy(&modifiedPcdParams, p_PcdParam, sizeof(t_FmPortPcdParams));
+ p_PcdParams = &modifiedPcdParams;
+ if ((p_PcdParams->h_IpReassemblyManip)
+#if (DPAA_VERSION >= 11)
+ || (p_PcdParams->h_CapwapReassemblyManip)
+#endif /* (DPAA_VERSION >= 11) */
+ )
+ {
+ if ((p_PcdParams->pcdSupport != e_FM_PORT_PCD_SUPPORT_PRS_AND_KG)
+ && (p_PcdParams->pcdSupport
+ != e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC)
+ && (p_PcdParams->pcdSupport
+ != e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC_AND_PLCR)
+ && (p_PcdParams->pcdSupport
+ != e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR))
+ {
+ RELEASE_LOCK(p_FmPort->lock);
+ RETURN_ERROR( MAJOR, E_INVALID_STATE,
+ ("pcdSupport must have KG for supporting Reassembly"));
+ }
+ p_FmPort->h_IpReassemblyManip = p_PcdParams->h_IpReassemblyManip;
+#if (DPAA_VERSION >= 11)
+ if ((p_PcdParams->h_IpReassemblyManip)
+ && (p_PcdParams->h_CapwapReassemblyManip))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("Either IP-R or CAPWAP-R is allowed"));
+ if ((p_PcdParams->h_CapwapReassemblyManip)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE,
+ ("CAPWAP-R is allowed only on offline-port"));
+ if (p_PcdParams->h_CapwapReassemblyManip)
+ p_FmPort->h_CapwapReassemblyManip =
+ p_PcdParams->h_CapwapReassemblyManip;
+#endif /* (DPAA_VERSION >= 11) */
+
+ if (!p_PcdParams->p_CcParams)
+ {
+ if (!((p_PcdParams->pcdSupport == e_FM_PORT_PCD_SUPPORT_PRS_AND_KG)
+ || (p_PcdParams->pcdSupport
+ == e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR)))
+ {
+ RELEASE_LOCK(p_FmPort->lock);
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_STATE,
+ ("PCD initialization structure is not consistent with pcdSupport"));
+ }
+
+ /* No user-tree, need to build internal tree */
+ p_FmPcdCcTreeParams = (t_FmPcdCcTreeParams*)XX_Malloc(
+ sizeof(t_FmPcdCcTreeParams));
+ if (!p_FmPcdCcTreeParams)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("p_FmPcdCcTreeParams"));
+ memset(p_FmPcdCcTreeParams, 0, sizeof(t_FmPcdCcTreeParams));
+ p_FmPcdCcTreeParams->h_NetEnv = p_PcdParams->h_NetEnv;
+ p_FmPort->h_ReassemblyTree = FM_PCD_CcRootBuild(
+ p_FmPort->h_FmPcd, p_FmPcdCcTreeParams);
+
+ if (!p_FmPort->h_ReassemblyTree)
+ {
+ RELEASE_LOCK(p_FmPort->lock);
+ XX_Free(p_FmPcdCcTreeParams);
+ RETURN_ERROR( MAJOR, E_INVALID_HANDLE,
+ ("FM_PCD_CcBuildTree for Reassembly failed"));
+ }
+ if (p_PcdParams->pcdSupport == e_FM_PORT_PCD_SUPPORT_PRS_AND_KG)
+ p_PcdParams->pcdSupport =
+ e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC;
+ else
+ p_PcdParams->pcdSupport =
+ e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC_AND_PLCR;
+
+ memset(&fmPortPcdCcParams, 0, sizeof(t_FmPortPcdCcParams));
+ fmPortPcdCcParams.h_CcTree = p_FmPort->h_ReassemblyTree;
+ p_PcdParams->p_CcParams = &fmPortPcdCcParams;
+ XX_Free(p_FmPcdCcTreeParams);
+ }
+
+ if (p_FmPort->h_IpReassemblyManip)
+ err = FmPcdCcTreeAddIPR(p_FmPort->h_FmPcd,
+ p_PcdParams->p_CcParams->h_CcTree,
+ p_PcdParams->h_NetEnv,
+ p_FmPort->h_IpReassemblyManip, TRUE);
+#if (DPAA_VERSION >= 11)
+ else
+ if (p_FmPort->h_CapwapReassemblyManip)
+ err = FmPcdCcTreeAddCPR(p_FmPort->h_FmPcd,
+ p_PcdParams->p_CcParams->h_CcTree,
+ p_PcdParams->h_NetEnv,
+ p_FmPort->h_CapwapReassemblyManip,
+ TRUE);
+#endif /* (DPAA_VERSION >= 11) */
+
+ if (err != E_OK)
+ {
+ if (p_FmPort->h_ReassemblyTree)
+ {
+ FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
+ p_FmPort->h_ReassemblyTree = NULL;
+ }RELEASE_LOCK(p_FmPort->lock);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+ }
+
+ if (!FmPcdLockTryLockAll(p_FmPort->h_FmPcd))
+ {
+ if (p_FmPort->h_ReassemblyTree)
+ {
+ FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
+ p_FmPort->h_ReassemblyTree = NULL;
+ }RELEASE_LOCK(p_FmPort->lock);
+ DBG(TRACE, ("Try LockAll - BUSY"));
+ return ERROR_CODE(E_BUSY);
+ }
+
+ err = SetPcd(h_FmPort, p_PcdParams);
+ if (err)
{
+ if (p_FmPort->h_ReassemblyTree)
+ {
+ FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
+ p_FmPort->h_ReassemblyTree = NULL;
+ }
+ FmPcdLockUnlockAll(p_FmPort->h_FmPcd);
RELEASE_LOCK(p_FmPort->lock);
RETURN_ERROR(MAJOR, err, NO_MSG);
}
- if(p_FmPort->pcdEngines & FM_PCD_KG)
+ if ((p_FmPort->pcdEngines & FM_PCD_PRS)
+ && (p_PcdParams->p_PrsParams->includeInPrsStatistics))
{
- schemeBind.netEnvId = p_FmPort->netEnvId;
- schemeBind.hardwarePortId = p_FmPort->hardwarePortId;
- schemeBind.numOfSchemes = p_PcdParams->p_KgParams->numOfSchemes;
- schemeBind.useClsPlan = p_FmPort->useClsPlan;
- for(i = 0;i<schemeBind.numOfSchemes;i++)
- schemeBind.schemesIds[i] = (uint8_t)(PTR_TO_UINT(p_PcdParams->p_KgParams->h_Schemes[i])-1);
-
- err = FmPcdKgBindPortToSchemes(p_FmPort->h_FmPcd, &schemeBind);
- if(err)
+ err = FmPcdPrsIncludePortInStatistics(p_FmPort->h_FmPcd,
+ p_FmPort->hardwarePortId, TRUE);
+ if (err)
{
DeletePcd(p_FmPort);
+ if (p_FmPort->h_ReassemblyTree)
+ {
+ FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
+ p_FmPort->h_ReassemblyTree = NULL;
+ }
+ FmPcdLockUnlockAll(p_FmPort->h_FmPcd);
RELEASE_LOCK(p_FmPort->lock);
RETURN_ERROR(MAJOR, err, NO_MSG);
}
+ p_FmPort->includeInPrsStatistics = TRUE;
}
- if ((p_FmPort->pcdEngines & FM_PCD_PRS) && (p_PcdParams->p_PrsParams->includeInPrsStatistics))
- FmPcdPrsIncludePortInStatistics(p_FmPort->h_FmPcd, p_FmPort->hardwarePortId, TRUE);
-
FmPcdIncNetEnvOwners(p_FmPort->h_FmPcd, p_FmPort->netEnvId);
- err = FmPortAttachPCD(h_FmPort);
+ if (FmPcdIsAdvancedOffloadSupported(p_FmPort->h_FmPcd))
+ {
+ memset(&fmPortGetSetCcParams, 0, sizeof(t_FmPortGetSetCcParams));
+
+ if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ {
+#ifdef FM_KG_ERASE_FLOW_ID_ERRATA_FMAN_SW004
+ if ((p_FmPort->fmRevInfo.majorRev < 6) &&
+ (p_FmPort->pcdEngines & FM_PCD_KG))
+ {
+ int i;
+ for (i = 0; i<p_PcdParams->p_KgParams->numOfSchemes; i++)
+ /* The following function must be locked */
+ FmPcdKgCcGetSetParams(p_FmPort->h_FmPcd,
+ p_PcdParams->p_KgParams->h_Schemes[i],
+ UPDATE_KG_NIA_CC_WA,
+ 0);
+ }
+#endif /* FM_KG_ERASE_FLOW_ID_ERRATA_FMAN_SW004 */
+
+#if (DPAA_VERSION >= 11)
+ {
+ t_FmPcdCtrlParamsPage *p_ParamsPage;
+
+ FmPortSetGprFunc(p_FmPort, e_FM_PORT_GPR_MURAM_PAGE,
+ (void**)&p_ParamsPage);
+ ASSERT_COND(p_ParamsPage);
+ WRITE_UINT32(p_ParamsPage->postBmiFetchNia,
+ p_FmPort->savedBmiNia);
+ }
+#endif /* (DPAA_VERSION >= 11) */
+
+ /* Set post-bmi-fetch nia */
+ p_FmPort->savedBmiNia &= BMI_RFNE_FDCS_MASK;
+ p_FmPort->savedBmiNia |= (NIA_FM_CTL_AC_POST_BMI_FETCH
+ | NIA_ENG_FM_CTL);
+
+ /* Set pre-bmi-fetch nia */
+ fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNDN;
+#if (DPAA_VERSION >= 11)
+ fmPortGetSetCcParams.setCcParams.nia =
+ (NIA_FM_CTL_AC_PRE_BMI_FETCH_FULL_FRAME | NIA_ENG_FM_CTL);
+#else
+ fmPortGetSetCcParams.setCcParams.nia = (NIA_FM_CTL_AC_PRE_BMI_FETCH_HEADER | NIA_ENG_FM_CTL);
+#endif /* (DPAA_VERSION >= 11) */
+ if ((err = FmPortGetSetCcParams(p_FmPort, &fmPortGetSetCcParams))
+ != E_OK)
+ {
+ DeletePcd(p_FmPort);
+ if (p_FmPort->h_ReassemblyTree)
+ {
+ FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
+ p_FmPort->h_ReassemblyTree = NULL;
+ }
+ FmPcdLockUnlockAll(p_FmPort->h_FmPcd);
+ RELEASE_LOCK(p_FmPort->lock);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+ }
+
+ FmPcdLockUnlockAll(p_FmPort->h_FmPcd);
+
+ /* Set pop-to-next-step nia */
+#if (DPAA_VERSION == 10)
+ if (p_FmPort->fmRevInfo.majorRev < 6)
+ {
+ fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_PNEN;
+ fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_POP_TO_N_STEP | NIA_ENG_FM_CTL;
+ }
+ else
+ {
+#endif /* (DPAA_VERSION == 10) */
+ fmPortGetSetCcParams.getCcParams.type = GET_NIA_FPNE;
+#if (DPAA_VERSION == 10)
+ }
+#endif /* (DPAA_VERSION == 10) */
+ if ((err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams))
+ != E_OK)
+ {
+ DeletePcd(p_FmPort);
+ if (p_FmPort->h_ReassemblyTree)
+ {
+ FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
+ p_FmPort->h_ReassemblyTree = NULL;
+ }RELEASE_LOCK(p_FmPort->lock);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+
+ /* Set post-bmi-prepare-to-enq nia */
+ fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_FENE;
+ fmPortGetSetCcParams.setCcParams.nia = (NIA_FM_CTL_AC_POST_BMI_ENQ
+ | NIA_ENG_FM_CTL);
+ if ((err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams))
+ != E_OK)
+ {
+ DeletePcd(p_FmPort);
+ if (p_FmPort->h_ReassemblyTree)
+ {
+ FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
+ p_FmPort->h_ReassemblyTree = NULL;
+ }RELEASE_LOCK(p_FmPort->lock);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+
+ if ((p_FmPort->h_IpReassemblyManip)
+ || (p_FmPort->h_CapwapReassemblyManip))
+ {
+#if (DPAA_VERSION == 10)
+ if (p_FmPort->fmRevInfo.majorRev < 6)
+ {
+ /* Overwrite post-bmi-prepare-to-enq nia */
+ fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_FENE;
+ fmPortGetSetCcParams.setCcParams.nia = (NIA_FM_CTL_AC_POST_BMI_ENQ_ORR | NIA_ENG_FM_CTL | NIA_ORDER_RESTOR);
+ fmPortGetSetCcParams.setCcParams.overwrite = TRUE;
+ }
+ else
+ {
+#endif /* (DPAA_VERSION == 10) */
+ /* Set the ORR bit (for order-restoration) */
+ fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_FPNE;
+ fmPortGetSetCcParams.setCcParams.nia =
+ fmPortGetSetCcParams.getCcParams.nia | NIA_ORDER_RESTOR;
+#if (DPAA_VERSION == 10)
+ }
+#endif /* (DPAA_VERSION == 10) */
+ if ((err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams))
+ != E_OK)
+ {
+ DeletePcd(p_FmPort);
+ if (p_FmPort->h_ReassemblyTree)
+ {
+ FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
+ p_FmPort->h_ReassemblyTree = NULL;
+ }RELEASE_LOCK(p_FmPort->lock);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+ }
+ }
+ else
+ FmPcdLockUnlockAll(p_FmPort->h_FmPcd);
+
+#if (DPAA_VERSION >= 11)
+ {
+ t_FmPcdCtrlParamsPage *p_ParamsPage;
+
+ memset(&fmPortGetSetCcParams, 0, sizeof(t_FmPortGetSetCcParams));
+
+ fmPortGetSetCcParams.setCcParams.type = UPDATE_NIA_CMNE;
+ if (FmPcdIsAdvancedOffloadSupported(p_FmPort->h_FmPcd))
+ fmPortGetSetCcParams.setCcParams.nia = NIA_FM_CTL_AC_POP_TO_N_STEP
+ | NIA_ENG_FM_CTL;
+ else
+ fmPortGetSetCcParams.setCcParams.nia =
+ NIA_FM_CTL_AC_NO_IPACC_POP_TO_N_STEP | NIA_ENG_FM_CTL;
+ if ((err = FmPortGetSetCcParams(h_FmPort, &fmPortGetSetCcParams))
+ != E_OK)
+ {
+ DeletePcd(p_FmPort);
+ if (p_FmPort->h_ReassemblyTree)
+ {
+ FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
+ p_FmPort->h_ReassemblyTree = NULL;
+ }RELEASE_LOCK(p_FmPort->lock);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+
+ FmPortSetGprFunc(p_FmPort, e_FM_PORT_GPR_MURAM_PAGE,
+ (void**)&p_ParamsPage);
+ ASSERT_COND(p_ParamsPage);
+
+ if (FmPcdIsAdvancedOffloadSupported(p_FmPort->h_FmPcd))
+ WRITE_UINT32(
+ p_ParamsPage->misc,
+ GET_UINT32(p_ParamsPage->misc) | FM_CTL_PARAMS_PAGE_OFFLOAD_SUPPORT_EN);
+
+ if ((p_FmPort->h_IpReassemblyManip)
+ || (p_FmPort->h_CapwapReassemblyManip))
+ {
+ if (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)
+ WRITE_UINT32(
+ p_ParamsPage->discardMask,
+ GET_UINT32(p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofsdm));
+ else
+ WRITE_UINT32(
+ p_ParamsPage->discardMask,
+ GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfsdm));
+ }
+#ifdef FM_ERROR_VSP_NO_MATCH_SW006
+ if (p_FmPort->vspe)
+ WRITE_UINT32(
+ p_ParamsPage->misc,
+ GET_UINT32(p_ParamsPage->misc) | (p_FmPort->dfltRelativeId & FM_CTL_PARAMS_PAGE_ERROR_VSP_MASK));
+#endif /* FM_ERROR_VSP_NO_MATCH_SW006 */
+ }
+#endif /* (DPAA_VERSION >= 11) */
+
+ err = AttachPCD(h_FmPort);
+ if (err)
+ {
+ DeletePcd(p_FmPort);
+ if (p_FmPort->h_ReassemblyTree)
+ {
+ FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
+ p_FmPort->h_ReassemblyTree = NULL;
+ }RELEASE_LOCK(p_FmPort->lock);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+
RELEASE_LOCK(p_FmPort->lock);
return err;
@@ -4538,21 +5278,30 @@ t_Error FM_PORT_SetPCD(t_Handle h_FmPort, t_FmPortPcdParams *p_PcdParams)
t_Error FM_PORT_DeletePCD(t_Handle h_FmPort)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- t_FmPcdKgInterModuleBindPortToSchemes schemeBind;
- t_Error err = E_OK;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_Error err = E_OK;
SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
if (p_FmPort->imEn)
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for non-independant mode ports only"));
+ RETURN_ERROR(MAJOR, E_INVALID_OPERATION,
+ ("available for non-independant mode ports only"));
+
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
+ RETURN_ERROR( MAJOR, E_INVALID_OPERATION,
+ ("available for Rx and offline parsing ports only"));
if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
+ {
+ DBG(TRACE, ("FM Port Try Lock - BUSY"));
return ERROR_CODE(E_BUSY);
+ }
- err = FM_PORT_DetachPCD(h_FmPort);
- if(err)
+ err = DetachPCD(h_FmPort);
+ if (err)
{
RELEASE_LOCK(p_FmPort->lock);
RETURN_ERROR(MAJOR, err, NO_MSG);
@@ -4561,86 +5310,124 @@ t_Error FM_PORT_DeletePCD(t_Handle h_FmPort)
FmPcdDecNetEnvOwners(p_FmPort->h_FmPcd, p_FmPort->netEnvId);
/* we do it anyway, instead of checking if included */
- if (FmIsMaster(p_FmPort->h_Fm) &&
- (p_FmPort->pcdEngines & FM_PCD_PRS))
- FmPcdPrsIncludePortInStatistics(p_FmPort->h_FmPcd, p_FmPort->hardwarePortId, FALSE);
+ if ((p_FmPort->pcdEngines & FM_PCD_PRS) && p_FmPort->includeInPrsStatistics)
+ {
+ FmPcdPrsIncludePortInStatistics(p_FmPort->h_FmPcd,
+ p_FmPort->hardwarePortId, FALSE);
+ p_FmPort->includeInPrsStatistics = FALSE;
+ }
- if(p_FmPort->pcdEngines & FM_PCD_KG)
+ if (!FmPcdLockTryLockAll(p_FmPort->h_FmPcd))
{
- /* unbind all schemes */
- p_FmPort->schemesPerPortVector = GetPortSchemeBindParams(p_FmPort, &schemeBind);
+ RELEASE_LOCK(p_FmPort->lock);
+ DBG(TRACE, ("Try LockAll - BUSY"));
+ return ERROR_CODE(E_BUSY);
+ }
- err = FmPcdKgUnbindPortToSchemes(p_FmPort->h_FmPcd, &schemeBind);
- if(err)
+ err = DeletePcd(h_FmPort);
+ FmPcdLockUnlockAll(p_FmPort->h_FmPcd);
+ if (err)
+ {
+ RELEASE_LOCK(p_FmPort->lock);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+
+ if (p_FmPort->h_ReassemblyTree)
+ {
+ err = FM_PCD_CcRootDelete(p_FmPort->h_ReassemblyTree);
+ if (err)
{
RELEASE_LOCK(p_FmPort->lock);
RETURN_ERROR(MAJOR, err, NO_MSG);
}
- }
-
- err = DeletePcd(h_FmPort);
- RELEASE_LOCK(p_FmPort->lock);
+ p_FmPort->h_ReassemblyTree = NULL;
+ }RELEASE_LOCK(p_FmPort->lock);
return err;
}
-t_Error FM_PORT_PcdKgBindSchemes (t_Handle h_FmPort, t_FmPcdPortSchemesParams *p_PortScheme)
+t_Error FM_PORT_PcdKgBindSchemes(t_Handle h_FmPort,
+ t_FmPcdPortSchemesParams *p_PortScheme)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- t_FmPcdKgInterModuleBindPortToSchemes schemeBind;
- t_Error err = E_OK;
- uint32_t tmpScmVec=0;
- int i;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_FmPcdKgInterModuleBindPortToSchemes schemeBind;
+ t_Error err = E_OK;
+ uint32_t tmpScmVec = 0;
+ int i;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
- SANITY_CHECK_RETURN_ERROR(p_FmPort->pcdEngines & FM_PCD_KG , E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPort->pcdEngines & FM_PCD_KG,
+ E_INVALID_STATE);
schemeBind.netEnvId = p_FmPort->netEnvId;
schemeBind.hardwarePortId = p_FmPort->hardwarePortId;
schemeBind.numOfSchemes = p_PortScheme->numOfSchemes;
schemeBind.useClsPlan = p_FmPort->useClsPlan;
- for (i=0; i<schemeBind.numOfSchemes; i++)
+ for (i = 0; i < schemeBind.numOfSchemes; i++)
{
- schemeBind.schemesIds[i] = (uint8_t)(PTR_TO_UINT(p_PortScheme->h_Schemes[i])-1);
+ schemeBind.schemesIds[i] = FmPcdKgGetSchemeId(
+ p_PortScheme->h_Schemes[i]);
/* build vector */
tmpScmVec |= 1 << (31 - (uint32_t)schemeBind.schemesIds[i]);
}
if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
+ {
+ DBG(TRACE, ("FM Port Try Lock - BUSY"));
return ERROR_CODE(E_BUSY);
+ }
+
err = FmPcdKgBindPortToSchemes(p_FmPort->h_FmPcd, &schemeBind);
if (err == E_OK)
p_FmPort->schemesPerPortVector |= tmpScmVec;
+
+#ifdef FM_KG_ERASE_FLOW_ID_ERRATA_FMAN_SW004
+ if ((FmPcdIsAdvancedOffloadSupported(p_FmPort->h_FmPcd)) &&
+ (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING) &&
+ (p_FmPort->fmRevInfo.majorRev < 6))
+ {
+ for (i=0; i<p_PortScheme->numOfSchemes; i++)
+ FmPcdKgCcGetSetParams(p_FmPort->h_FmPcd, p_PortScheme->h_Schemes[i], UPDATE_KG_NIA_CC_WA, 0);
+ }
+#endif /* FM_KG_ERASE_FLOW_ID_ERRATA_FMAN_SW004 */
+
RELEASE_LOCK(p_FmPort->lock);
return err;
}
-t_Error FM_PORT_PcdKgUnbindSchemes (t_Handle h_FmPort, t_FmPcdPortSchemesParams *p_PortScheme)
+t_Error FM_PORT_PcdKgUnbindSchemes(t_Handle h_FmPort,
+ t_FmPcdPortSchemesParams *p_PortScheme)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- t_FmPcdKgInterModuleBindPortToSchemes schemeBind;
- t_Error err = E_OK;
- uint32_t tmpScmVec=0;
- int i;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ t_FmPcdKgInterModuleBindPortToSchemes schemeBind;
+ t_Error err = E_OK;
+ uint32_t tmpScmVec = 0;
+ int i;
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
- SANITY_CHECK_RETURN_ERROR(p_FmPort->pcdEngines & FM_PCD_KG , E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPort->pcdEngines & FM_PCD_KG,
+ E_INVALID_STATE);
schemeBind.netEnvId = p_FmPort->netEnvId;
schemeBind.hardwarePortId = p_FmPort->hardwarePortId;
schemeBind.numOfSchemes = p_PortScheme->numOfSchemes;
- for (i=0; i<schemeBind.numOfSchemes; i++)
+ for (i = 0; i < schemeBind.numOfSchemes; i++)
{
- schemeBind.schemesIds[i] = (uint8_t)(PTR_TO_UINT(p_PortScheme->h_Schemes[i])-1);
+ schemeBind.schemesIds[i] = FmPcdKgGetSchemeId(
+ p_PortScheme->h_Schemes[i]);
/* build vector */
tmpScmVec |= 1 << (31 - (uint32_t)schemeBind.schemesIds[i]);
}
if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
+ {
+ DBG(TRACE, ("FM Port Try Lock - BUSY"));
return ERROR_CODE(E_BUSY);
+ }
+
err = FmPcdKgUnbindPortToSchemes(p_FmPort->h_FmPcd, &schemeBind);
if (err == E_OK)
p_FmPort->schemesPerPortVector &= ~tmpScmVec;
@@ -4649,412 +5436,1003 @@ t_Error FM_PORT_PcdKgUnbindSchemes (t_Handle h_FmPort, t_FmPcdPortSchemesParams
return err;
}
-t_Error FM_PORT_PcdPrsModifyStartOffset (t_Handle h_FmPort, t_FmPcdPrsStart *p_FmPcdPrsStart)
+t_Error FM_PORT_AddCongestionGrps(t_Handle h_FmPort,
+ t_FmPortCongestionGrps *p_CongestionGrps)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- volatile uint32_t *p_BmiPrsStartOffset = NULL;
- volatile uint32_t *p_BmiNia = NULL;
- uint32_t tmpReg;
- uint8_t hdrNum;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ uint8_t priorityTmpArray[FM_PORT_NUM_OF_CONGESTION_GRPS];
+ uint8_t mod, index;
+ uint32_t i, grpsMap[FMAN_PORT_CG_MAP_NUM];
+ int err;
+#if (DPAA_VERSION >= 11)
+ int j;
+#endif /* (DPAA_VERSION >= 11) */
SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
- SANITY_CHECK_RETURN_ERROR(p_FmPort->pcdEngines & FM_PCD_PRS , E_INVALID_STATE);
- switch(p_FmPort->portType)
+ /* un-necessary check of the indexes; probably will be needed in the future when there
+ will be more CGs available ....
+ for (i=0; i<p_CongestionGrps->numOfCongestionGrpsToConsider; i++)
+ if (p_CongestionGrps->congestionGrpsToConsider[i] >= FM_PORT_NUM_OF_CONGESTION_GRPS)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("CG id!"));
+ */
+
+#ifdef FM_NO_OP_OBSERVED_CGS
+ if ((p_FmPort->fmRevInfo.majorRev != 4) &&
+ (p_FmPort->fmRevInfo.majorRev < 6))
{
- case(e_FM_PORT_TYPE_RX_10G):
- case(e_FM_PORT_TYPE_RX):
- p_BmiPrsStartOffset = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rpso;
- p_BmiNia = &p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfne;
- tmpReg = GET_UINT32(*p_BmiNia) & BMI_RFNE_FDCS_MASK;
- break;
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- p_BmiPrsStartOffset = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_opso;
- p_BmiNia = &p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ofne;
- tmpReg = 0;
- break;
- default:
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("available for Rx and offline parsing ports only"));
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) &&
+ (p_FmPort->portType != e_FM_PORT_TYPE_RX))
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Available for Rx ports only"));
+ }
+ else
+#endif /* FM_NO_OP_OBSERVED_CGS */
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
+ ("Available for Rx & OP ports only"));
+
+ /* Prepare groups map array */
+ memset(grpsMap, 0, FMAN_PORT_CG_MAP_NUM * sizeof(uint32_t));
+ for (i = 0; i < p_CongestionGrps->numOfCongestionGrpsToConsider; i++)
+ {
+ index = (uint8_t)(p_CongestionGrps->congestionGrpsToConsider[i] / 32);
+ mod = (uint8_t)(p_CongestionGrps->congestionGrpsToConsider[i] % 32);
+ if (p_FmPort->fmRevInfo.majorRev != 4)
+ grpsMap[7 - index] |= (uint32_t)(1 << mod);
+ else
+ grpsMap[0] |= (uint32_t)(1 << mod);
}
- /* check that current NIA is BMI to BMI */
- if((GET_UINT32(*p_BmiNia) & ~BMI_RFNE_FDCS_MASK) != (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME))
- RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("may be called only for ports in BMI-to-BMI state."));
+ memset(&priorityTmpArray, 0,
+ FM_PORT_NUM_OF_CONGESTION_GRPS * sizeof(uint8_t));
- if (!TRY_LOCK(p_FmPort->h_Spinlock, &p_FmPort->lock))
- return ERROR_CODE(E_BUSY);
- /* set the first header */
- GET_PRS_HDR_NUM(hdrNum, p_FmPcdPrsStart->firstPrsHdr);
- if ((hdrNum == ILLEGAL_HDR_NUM) || (hdrNum == NO_HDR_NUM))
+ for (i = 0; i < p_CongestionGrps->numOfCongestionGrpsToConsider; i++)
{
- RELEASE_LOCK(p_FmPort->lock);
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Unsupported header."));
+#if (DPAA_VERSION >= 11)
+ for (j = 0; j < FM_MAX_NUM_OF_PFC_PRIORITIES; j++)
+ if (p_CongestionGrps->pfcPrioritiesEn[i][j])
+ priorityTmpArray[p_CongestionGrps->congestionGrpsToConsider[i]] |=
+ (0x01 << (FM_MAX_NUM_OF_PFC_PRIORITIES - j - 1));
+#endif /* (DPAA_VERSION >= 11) */
}
- WRITE_UINT32(*p_BmiNia, (uint32_t)(NIA_ENG_PRS | (uint32_t)hdrNum | tmpReg));
- /* set start parsing offset */
- WRITE_UINT32(*p_BmiPrsStartOffset, (uint32_t)(p_FmPcdPrsStart->parsingOffset + p_FmPort->internalBufferOffset));
- RELEASE_LOCK(p_FmPort->lock);
+#if (DPAA_VERSION >= 11)
+ for (i = 0; i < FM_PORT_NUM_OF_CONGESTION_GRPS; i++)
+ {
+ err = FmSetCongestionGroupPFCpriority(p_FmPort->h_Fm, i,
+ priorityTmpArray[i]);
+ if (err)
+ return err;
+ }
+#endif /* (DPAA_VERSION >= 11) */
+
+ err = fman_port_add_congestion_grps(&p_FmPort->port, grpsMap);
+ if (err != 0)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fman_port_add_congestion_grps"));
return E_OK;
}
-#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
-t_Error FM_PORT_DumpRegs(t_Handle h_FmPort)
+t_Error FM_PORT_RemoveCongestionGrps(t_Handle h_FmPort,
+ t_FmPortCongestionGrps *p_CongestionGrps)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- t_Error err = E_OK;
- char arr[30];
- uint8_t flag;
- int i=0;
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
+ uint8_t mod, index;
+ uint32_t i, grpsMap[FMAN_PORT_CG_MAP_NUM];
+ int err;
- DECLARE_DUMP;
+ SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(h_FmPort, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_STATE);
- SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortQmiRegs, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortBmiRegs, E_INVALID_HANDLE);
+ {
+#ifdef FM_NO_OP_OBSERVED_CGS
+ t_FmRevisionInfo revInfo;
- switch (p_FmPort->portType)
+ FM_GetRevision(p_FmPort->h_Fm, &revInfo);
+ if (revInfo.majorRev != 4)
+ {
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) &&
+ (p_FmPort->portType != e_FM_PORT_TYPE_RX))
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Available for Rx ports only"));
+ }
+ else
+#endif /* FM_NO_OP_OBSERVED_CGS */
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_RX)
+ && (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
+ ("Available for Rx & OP ports only"));
+ }
+
+ /* Prepare groups map array */
+ memset(grpsMap, 0, FMAN_PORT_CG_MAP_NUM * sizeof(uint32_t));
+ for (i = 0; i < p_CongestionGrps->numOfCongestionGrpsToConsider; i++)
{
- case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
- strcpy(arr, "PORT_TYPE_OFFLINE_PARSING");
- flag = 0;
- break;
- case (e_FM_PORT_TYPE_OH_HOST_COMMAND):
- strcpy(arr, "PORT_TYPE_HOST_COMMAND");
- flag = 0;
- break;
- case (e_FM_PORT_TYPE_RX):
- strcpy(arr, "PORT_TYPE_RX");
- flag = 1;
- break;
- case (e_FM_PORT_TYPE_RX_10G):
- strcpy(arr, "PORT_TYPE_RX_10G");
- flag = 1;
- break;
- case (e_FM_PORT_TYPE_TX):
- strcpy(arr, "PORT_TYPE_TX");
- flag = 2;
- break;
- case (e_FM_PORT_TYPE_TX_10G):
- strcpy(arr, "PORT_TYPE_TX_10G");
- flag = 2;
- break;
- default:
- return ERROR_CODE(E_INVALID_VALUE);
+ index = (uint8_t)(p_CongestionGrps->congestionGrpsToConsider[i] / 32);
+ mod = (uint8_t)(p_CongestionGrps->congestionGrpsToConsider[i] % 32);
+ if (p_FmPort->fmRevInfo.majorRev != 4)
+ grpsMap[7 - index] |= (uint32_t)(1 << mod);
+ else
+ grpsMap[0] |= (uint32_t)(1 << mod);
}
- DUMP_TITLE(UINT_TO_PTR(p_FmPort->hardwarePortId), ("PortId for %s %d", arr, p_FmPort->portId ));
- DUMP_TITLE(p_FmPort->p_FmPortBmiRegs, ("Bmi Port Regs"));
+#if (DPAA_VERSION >= 11)
+ for (i = 0; i < p_CongestionGrps->numOfCongestionGrpsToConsider; i++)
+ {
+ t_Error err = FmSetCongestionGroupPFCpriority(
+ p_FmPort->h_Fm, p_CongestionGrps->congestionGrpsToConsider[i],
+ 0);
+ if (err)
+ return err;
+ }
+#endif /* (DPAA_VERSION >= 11) */
- err = FmDumpPortRegs(p_FmPort->h_Fm, p_FmPort->hardwarePortId);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
+ err = fman_port_remove_congestion_grps(&p_FmPort->port, grpsMap);
+ if (err != 0)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("fman_port_remove_congestion_grps"));
+ return E_OK;
+}
- switch(flag)
- {
- case(0):
+#if (DPAA_VERSION >= 11)
+t_Error FM_PORT_GetIPv4OptionsCount(t_Handle h_FmPort,
+ uint32_t *p_Ipv4OptionsCount)
+{
+ t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- DUMP_SUBTITLE(("\n"));
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ocfg);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ost);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_oda);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ofdne);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ofne);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ofca);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ofpne);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_opso);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_opp);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_occb);
+ SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(
+ (p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING),
+ E_INVALID_VALUE);
+ SANITY_CHECK_RETURN_ERROR(p_FmPort->p_ParamsPage, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_Ipv4OptionsCount, E_NULL_POINTER);
- DUMP_TITLE(&(p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_oprai), ("fmbm_oprai"));
- DUMP_SUBSTRUCT_ARRAY(i, FM_PORT_PRS_RESULT_NUM_OF_WORDS)
- {
- DUMP_MEMORY(&(p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_oprai[i]), sizeof(uint32_t));
- }
- DUMP_SUBTITLE(("\n"));
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ofqid );
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_oefqid);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ofsdm );
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ofsem );
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ofene );
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_orlmts);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_orlmt);
+ *p_Ipv4OptionsCount = GET_UINT32(p_FmPort->p_ParamsPage->ipfOptionsCounter);
- {
-#ifndef FM_NO_OP_OBSERVED_POOLS
- t_FmRevisionInfo revInfo;
+ return E_OK;
+}
+#endif /* (DPAA_VERSION >= 11) */
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if (revInfo.majorRev == 4)
-#endif /* !FM_NO_OP_OBSERVED_POOLS */
- {
- DUMP_TITLE(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_oebmpi, ("fmbm_oebmpi"));
+t_Error FM_PORT_ConfigDsarSupport(t_Handle h_FmPortRx,
+ t_FmPortDsarTablesSizes *params)
+{
+ t_FmPort *p_FmPort = (t_FmPort *)h_FmPortRx;
+ p_FmPort->deepSleepVars.autoResMaxSizes = XX_Malloc(
+ sizeof(struct t_FmPortDsarTablesSizes));
+ memcpy(p_FmPort->deepSleepVars.autoResMaxSizes, params,
+ sizeof(struct t_FmPortDsarTablesSizes));
+ return E_OK;
+}
- DUMP_SUBSTRUCT_ARRAY(i, FM_PORT_MAX_NUM_OF_OBSERVED_EXT_POOLS)
- {
- DUMP_MEMORY(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_oebmpi[i], sizeof(uint32_t));
- }
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ocgm);
- }
- }
+static t_Error FmPortConfigAutoResForDeepSleepSupport1(t_FmPort *p_FmPort)
+{
+ uint32_t *param_page;
+ t_FmPortDsarTablesSizes *params = p_FmPort->deepSleepVars.autoResMaxSizes;
+ t_ArCommonDesc *ArCommonDescPtr;
+ uint32_t size = sizeof(t_ArCommonDesc);
+ // ARP
+ // should put here if (params->max_num_of_arp_entries)?
+ size = ROUND_UP(size,4);
+ size += sizeof(t_DsarArpDescriptor);
+ size += sizeof(t_DsarArpBindingEntry) * params->maxNumOfArpEntries;
+ size += sizeof(t_DsarArpStatistics);
+ //ICMPV4
+ size = ROUND_UP(size,4);
+ size += sizeof(t_DsarIcmpV4Descriptor);
+ size += sizeof(t_DsarIcmpV4BindingEntry) * params->maxNumOfEchoIpv4Entries;
+ size += sizeof(t_DsarIcmpV4Statistics);
+ //ICMPV6
+ size = ROUND_UP(size,4);
+ size += sizeof(t_DsarIcmpV6Descriptor);
+ size += sizeof(t_DsarIcmpV6BindingEntry) * params->maxNumOfEchoIpv6Entries;
+ size += sizeof(t_DsarIcmpV6Statistics);
+ //ND
+ size = ROUND_UP(size,4);
+ size += sizeof(t_DsarNdDescriptor);
+ size += sizeof(t_DsarIcmpV6BindingEntry) * params->maxNumOfNdpEntries;
+ size += sizeof(t_DsarIcmpV6Statistics);
+ //SNMP
+ size = ROUND_UP(size,4);
+ size += sizeof(t_DsarSnmpDescriptor);
+ size += sizeof(t_DsarSnmpIpv4AddrTblEntry)
+ * params->maxNumOfSnmpIPV4Entries;
+ size += sizeof(t_DsarSnmpIpv6AddrTblEntry)
+ * params->maxNumOfSnmpIPV6Entries;
+ size += sizeof(t_OidsTblEntry) * params->maxNumOfSnmpOidEntries;
+ size += params->maxNumOfSnmpOidChar;
+ size += sizeof(t_DsarIcmpV6Statistics);
+ //filters
+ size = ROUND_UP(size,4);
+ size += params->maxNumOfIpProtFiltering;
+ size = ROUND_UP(size,4);
+ size += params->maxNumOfUdpPortFiltering * sizeof(t_PortTblEntry);
+ size = ROUND_UP(size,4);
+ size += params->maxNumOfTcpPortFiltering * sizeof(t_PortTblEntry);
+
+ // add here for more protocols
+
+ // statistics
+ size = ROUND_UP(size,4);
+ size += sizeof(t_ArStatistics);
+
+ ArCommonDescPtr = FM_MURAM_AllocMem(p_FmPort->h_FmMuram, size, 0x10);
+
+ param_page =
+ XX_PhysToVirt(
+ p_FmPort->fmMuramPhysBaseAddr
+ + GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rgpr));
+ WRITE_UINT32(
+ *param_page,
+ (uint32_t)(XX_VirtToPhys(ArCommonDescPtr) - p_FmPort->fmMuramPhysBaseAddr));
+ return E_OK;
+}
+
+t_FmPortDsarTablesSizes* FM_PORT_GetDsarTablesMaxSizes(t_Handle h_FmPortRx)
+{
+ t_FmPort *p_FmPort = (t_FmPort *)h_FmPortRx;
+ return p_FmPort->deepSleepVars.autoResMaxSizes;
+}
+
+struct arOffsets
+{
+ uint32_t arp;
+ uint32_t nd;
+ uint32_t icmpv4;
+ uint32_t icmpv6;
+ uint32_t snmp;
+ uint32_t stats;
+ uint32_t filtIp;
+ uint32_t filtUdp;
+ uint32_t filtTcp;
+};
+
+static uint32_t AR_ComputeOffsets(struct arOffsets* of,
+ struct t_FmPortDsarParams *params,
+ t_FmPort *p_FmPort)
+{
+ uint32_t size = sizeof(t_ArCommonDesc);
+ // ARP
+ if (params->p_AutoResArpInfo)
+ {
+ size = ROUND_UP(size,4);
+ of->arp = size;
+ size += sizeof(t_DsarArpDescriptor);
+ size += sizeof(t_DsarArpBindingEntry)
+ * params->p_AutoResArpInfo->tableSize;
+ size += sizeof(t_DsarArpStatistics);
+ }
+ // ICMPV4
+ if (params->p_AutoResEchoIpv4Info)
+ {
+ size = ROUND_UP(size,4);
+ of->icmpv4 = size;
+ size += sizeof(t_DsarIcmpV4Descriptor);
+ size += sizeof(t_DsarIcmpV4BindingEntry)
+ * params->p_AutoResEchoIpv4Info->tableSize;
+ size += sizeof(t_DsarIcmpV4Statistics);
+ }
+ // ICMPV6
+ if (params->p_AutoResEchoIpv6Info)
+ {
+ size = ROUND_UP(size,4);
+ of->icmpv6 = size;
+ size += sizeof(t_DsarIcmpV6Descriptor);
+ size += sizeof(t_DsarIcmpV6BindingEntry)
+ * params->p_AutoResEchoIpv6Info->tableSize;
+ size += sizeof(t_DsarIcmpV6Statistics);
+ }
+ // ND
+ if (params->p_AutoResNdpInfo)
+ {
+ size = ROUND_UP(size,4);
+ of->nd = size;
+ size += sizeof(t_DsarNdDescriptor);
+ size += sizeof(t_DsarIcmpV6BindingEntry)
+ * (params->p_AutoResNdpInfo->tableSizeAssigned
+ + params->p_AutoResNdpInfo->tableSizeTmp);
+ size += sizeof(t_DsarIcmpV6Statistics);
+ }
+ // SNMP
+ if (params->p_AutoResSnmpInfo)
+ {
+ size = ROUND_UP(size,4);
+ of->snmp = size;
+ size += sizeof(t_DsarSnmpDescriptor);
+ size += sizeof(t_DsarSnmpIpv4AddrTblEntry)
+ * params->p_AutoResSnmpInfo->numOfIpv4Addresses;
+ size += sizeof(t_DsarSnmpIpv6AddrTblEntry)
+ * params->p_AutoResSnmpInfo->numOfIpv6Addresses;
+ size += sizeof(t_OidsTblEntry) * params->p_AutoResSnmpInfo->oidsTblSize;
+ size += p_FmPort->deepSleepVars.autoResMaxSizes->maxNumOfSnmpOidChar;
+ size += sizeof(t_DsarIcmpV6Statistics);
+ }
+ //filters
+ size = ROUND_UP(size,4);
+ if (params->p_AutoResFilteringInfo)
+ {
+ of->filtIp = size;
+ size += params->p_AutoResFilteringInfo->ipProtTableSize;
+ size = ROUND_UP(size,4);
+ of->filtUdp = size;
+ size += params->p_AutoResFilteringInfo->udpPortsTableSize
+ * sizeof(t_PortTblEntry);
+ size = ROUND_UP(size,4);
+ of->filtTcp = size;
+ size += params->p_AutoResFilteringInfo->tcpPortsTableSize
+ * sizeof(t_PortTblEntry);
+ }
+ // add here for more protocols
+ // statistics
+ size = ROUND_UP(size,4);
+ of->stats = size;
+ size += sizeof(t_ArStatistics);
+ return size;
+}
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ostc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ofrc );
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ofdc );
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ofledc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ofufdc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_offc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ofwdc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ofldec);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_opc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_opcp);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_occn);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_otuc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_oduc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs,fmbm_ofuc);
- break;
- case(1):
- DUMP_SUBTITLE(("\n"));
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rcfg);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rst);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rda);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rfp);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_reth);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rfed);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_ricp);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rebm);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rfne);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rfca);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rfpne);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rpso);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rpp);
-
- DUMP_TITLE(&(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rprai), ("fmbm_rprai"));
- DUMP_SUBSTRUCT_ARRAY(i, FM_PORT_PRS_RESULT_NUM_OF_WORDS)
+uint32_t* ARDesc;
+void PrsEnable(t_Handle p_FmPcd);
+void PrsDisable(t_Handle p_FmPcd);
+int PrsIsEnabled(t_Handle p_FmPcd);
+t_Handle FM_PCD_GetHcPort(t_Handle h_FmPcd);
+
+static t_Error DsarCheckParams(t_FmPortDsarParams *params,
+ t_FmPortDsarTablesSizes *sizes)
+{
+ bool macInit = FALSE;
+ uint8_t mac[6];
+ int i = 0;
+
+ // check table sizes
+ if (params->p_AutoResArpInfo
+ && sizes->maxNumOfArpEntries < params->p_AutoResArpInfo->tableSize)
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("DSAR: Arp table size exceeds the configured maximum size."));
+ if (params->p_AutoResEchoIpv4Info
+ && sizes->maxNumOfEchoIpv4Entries
+ < params->p_AutoResEchoIpv4Info->tableSize)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("DSAR: EchoIpv4 table size exceeds the configured maximum size."));
+ if (params->p_AutoResNdpInfo
+ && sizes->maxNumOfNdpEntries
+ < params->p_AutoResNdpInfo->tableSizeAssigned
+ + params->p_AutoResNdpInfo->tableSizeTmp)
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("DSAR: NDP table size exceeds the configured maximum size."));
+ if (params->p_AutoResEchoIpv6Info
+ && sizes->maxNumOfEchoIpv6Entries
+ < params->p_AutoResEchoIpv6Info->tableSize)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("DSAR: EchoIpv6 table size exceeds the configured maximum size."));
+ if (params->p_AutoResSnmpInfo
+ && sizes->maxNumOfSnmpOidEntries
+ < params->p_AutoResSnmpInfo->oidsTblSize)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("DSAR: Snmp Oid table size exceeds the configured maximum size."));
+ if (params->p_AutoResSnmpInfo
+ && sizes->maxNumOfSnmpIPV4Entries
+ < params->p_AutoResSnmpInfo->numOfIpv4Addresses)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("DSAR: Snmp ipv4 table size exceeds the configured maximum size."));
+ if (params->p_AutoResSnmpInfo
+ && sizes->maxNumOfSnmpIPV6Entries
+ < params->p_AutoResSnmpInfo->numOfIpv6Addresses)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("DSAR: Snmp ipv6 table size exceeds the configured maximum size."));
+ if (params->p_AutoResFilteringInfo)
+ {
+ if (sizes->maxNumOfIpProtFiltering
+ < params->p_AutoResFilteringInfo->ipProtTableSize)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("DSAR: ip filter table size exceeds the configured maximum size."));
+ if (sizes->maxNumOfTcpPortFiltering
+ < params->p_AutoResFilteringInfo->udpPortsTableSize)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("DSAR: udp filter table size exceeds the configured maximum size."));
+ if (sizes->maxNumOfUdpPortFiltering
+ < params->p_AutoResFilteringInfo->tcpPortsTableSize)
+ RETURN_ERROR(
+ MAJOR,
+ E_INVALID_VALUE,
+ ("DSAR: tcp filter table size exceeds the configured maximum size."));
+ }
+ /* check only 1 MAC address is configured (this is what ucode currently supports) */
+ if (params->p_AutoResArpInfo && params->p_AutoResArpInfo->tableSize)
+ {
+ memcpy(mac, params->p_AutoResArpInfo->p_AutoResTable[0].mac, 6);
+ i = 1;
+ macInit = TRUE;
+
+ for (; i < params->p_AutoResArpInfo->tableSize; i++)
+ if (memcmp(mac, params->p_AutoResArpInfo->p_AutoResTable[i].mac, 6))
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("DSAR: Only 1 mac address is currently supported."));
+ }
+ if (params->p_AutoResEchoIpv4Info
+ && params->p_AutoResEchoIpv4Info->tableSize)
+ {
+ i = 0;
+ if (!macInit)
{
- DUMP_MEMORY(&(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rprai[i]), sizeof(uint32_t));
+ memcpy(mac, params->p_AutoResEchoIpv4Info->p_AutoResTable[0].mac,
+ 6);
+ i = 1;
+ macInit = TRUE;
}
- DUMP_SUBTITLE(("\n"));
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rfqid);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_refqid);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rfsdm);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rfsem);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rfene);
- DUMP_TITLE(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_ebmpi, ("fmbm_ebmpi"));
- DUMP_SUBSTRUCT_ARRAY(i, FM_PORT_MAX_NUM_OF_EXT_POOLS)
+ for (; i < params->p_AutoResEchoIpv4Info->tableSize; i++)
+ if (memcmp(mac,
+ params->p_AutoResEchoIpv4Info->p_AutoResTable[i].mac, 6))
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("DSAR: Only 1 mac address is currently supported."));
+ }
+ if (params->p_AutoResEchoIpv6Info
+ && params->p_AutoResEchoIpv6Info->tableSize)
+ {
+ i = 0;
+ if (!macInit)
{
- DUMP_MEMORY(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_ebmpi[i], sizeof(uint32_t));
+ memcpy(mac, params->p_AutoResEchoIpv6Info->p_AutoResTable[0].mac,
+ 6);
+ i = 1;
+ macInit = TRUE;
}
- DUMP_TITLE(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_acnt, ("fmbm_acnt"));
- DUMP_SUBSTRUCT_ARRAY(i, FM_PORT_MAX_NUM_OF_EXT_POOLS)
+ for (; i < params->p_AutoResEchoIpv6Info->tableSize; i++)
+ if (memcmp(mac,
+ params->p_AutoResEchoIpv6Info->p_AutoResTable[i].mac, 6))
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("DSAR: Only 1 mac address is currently supported."));
+ }
+ if (params->p_AutoResNdpInfo && params->p_AutoResNdpInfo->tableSizeAssigned)
+ {
+ i = 0;
+ if (!macInit)
{
- DUMP_MEMORY(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_acnt[i], sizeof(uint32_t));
+ memcpy(mac, params->p_AutoResNdpInfo->p_AutoResTableAssigned[0].mac,
+ 6);
+ i = 1;
+ macInit = TRUE;
}
- DUMP_TITLE(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_cgm, ("fmbm_cgm"));
- DUMP_SUBSTRUCT_ARRAY(i, FM_PORT_NUM_OF_CONGESTION_GRPS/32)
+ for (; i < params->p_AutoResNdpInfo->tableSizeAssigned; i++)
+ if (memcmp(mac,
+ params->p_AutoResNdpInfo->p_AutoResTableAssigned[i].mac,
+ 6))
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("DSAR: Only 1 mac address is currently supported."));
+ }
+ if (params->p_AutoResNdpInfo && params->p_AutoResNdpInfo->tableSizeTmp)
+ {
+ i = 0;
+ if (!macInit)
{
- DUMP_MEMORY(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_cgm[i], sizeof(uint32_t));
+ memcpy(mac, params->p_AutoResNdpInfo->p_AutoResTableTmp[0].mac, 6);
+ i = 1;
}
- DUMP_SUBTITLE(("\n"));
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_mpd);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rstc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rfrc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rfbc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rlfc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rffc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rfcd);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rfldec);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rodc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rpc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rpcp);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rccn);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rtuc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rrquc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rduc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rfuc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rpac);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs,fmbm_rdbg);
- break;
- case(2):
-
- DUMP_SUBTITLE(("\n"));
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tcfg);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tst);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tda);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tfp);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tfed);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_ticp);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tfne);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tfca);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tcfqid);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tfeqid);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tfene);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_trlmts);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_trlmt);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tstc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tfrc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tfdc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tfledc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tfufdc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tpc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tpcp);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tccn);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_ttuc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_ttcquc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tduc);
- DUMP_VAR(&p_FmPort->p_FmPortBmiRegs->txPortBmiRegs,fmbm_tfuc);
- break;
-
- default:
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid flag"));
- }
-
- DUMP_TITLE(p_FmPort->p_FmPortQmiRegs, ("Qmi Port Regs"));
-
- DUMP_VAR(p_FmPort->p_FmPortQmiRegs,fmqm_pnc);
- DUMP_VAR(p_FmPort->p_FmPortQmiRegs,fmqm_pns);
- DUMP_VAR(p_FmPort->p_FmPortQmiRegs,fmqm_pnts);
- DUMP_VAR(p_FmPort->p_FmPortQmiRegs,fmqm_pnen);
- DUMP_VAR(p_FmPort->p_FmPortQmiRegs,fmqm_pnetfc);
-
- if(flag !=1)
- {
- DUMP_VAR(&p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs,fmqm_pndn);
- DUMP_VAR(&p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs,fmqm_pndc);
- DUMP_VAR(&p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs,fmqm_pndtfc);
- DUMP_VAR(&p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs,fmqm_pndfdc);
- DUMP_VAR(&p_FmPort->p_FmPortQmiRegs->nonRxQmiRegs,fmqm_pndcc);
+ for (; i < params->p_AutoResNdpInfo->tableSizeTmp; i++)
+ if (memcmp(mac, params->p_AutoResNdpInfo->p_AutoResTableTmp[i].mac,
+ 6))
+ RETURN_ERROR(
+ MAJOR, E_INVALID_VALUE,
+ ("DSAR: Only 1 mac address is currently supported."));
}
-
return E_OK;
}
-#endif /* (defined(DEBUG_ERRORS) && ... */
-t_Error FM_PORT_AddCongestionGrps(t_Handle h_FmPort, t_FmPortCongestionGrps *p_CongestionGrps)
+static int GetBERLen(uint8_t* buf)
{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- bool tmpArray[FM_PORT_NUM_OF_CONGESTION_GRPS], opPort;
- int i;
- uint8_t mod;
- uint32_t tmpReg = 0;
+ if (*buf & 0x80)
+ {
+ if ((*buf & 0x7F) == 1)
+ return buf[1];
+ else
+ return *(uint16_t*)&buf[1]; // assuming max len is 2
+ }
+ else
+ return buf[0];
+}
+#define TOTAL_BER_LEN(len) (len < 128) ? len + 2 : len + 3
- SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
+#ifdef TODO_SOC_SUSPEND // XXX
+#define SCFG_FMCLKDPSLPCR_ADDR 0xFFE0FC00C
+#define SCFG_FMCLKDPSLPCR_DS_VAL 0x08402000
+#define SCFG_FMCLKDPSLPCR_NORMAL_VAL 0x00402000
+static int fm_soc_suspend(void)
+{
+ uint32_t *fmclk, tmp32;
+ fmclk = ioremap(SCFG_FMCLKDPSLPCR_ADDR, 4);
+ tmp32 = GET_UINT32(*fmclk);
+ WRITE_UINT32(*fmclk, SCFG_FMCLKDPSLPCR_DS_VAL);
+ tmp32 = GET_UINT32(*fmclk);
+ iounmap(fmclk);
+ return 0;
+}
- {
-#ifdef FM_NO_OP_OBSERVED_CGS
- t_FmRevisionInfo revInfo;
+void fm_clk_down(void)
+{
+ uint32_t *fmclk, tmp32;
+ fmclk = ioremap(SCFG_FMCLKDPSLPCR_ADDR, 4);
+ tmp32 = GET_UINT32(*fmclk);
+ WRITE_UINT32(*fmclk, SCFG_FMCLKDPSLPCR_DS_VAL | 0x40000000);
+ tmp32 = GET_UINT32(*fmclk);
+ iounmap(fmclk);
+}
+#endif
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if (revInfo.majorRev != 4)
+#if 0
+t_Error FM_PORT_EnterDsar(t_Handle h_FmPortRx, t_FmPortDsarParams *params)
+{
+ int i, j;
+ t_Error err;
+ uint32_t nia;
+ t_FmPort *p_FmPort = (t_FmPort *)h_FmPortRx;
+ t_FmPort *p_FmPortTx = (t_FmPort *)params->h_FmPortTx;
+ t_DsarArpDescriptor *ArpDescriptor;
+ t_DsarIcmpV4Descriptor* ICMPV4Descriptor;
+ t_DsarIcmpV6Descriptor* ICMPV6Descriptor;
+ t_DsarNdDescriptor* NDDescriptor;
+
+ uint64_t fmMuramVirtBaseAddr = (uint64_t)PTR_TO_UINT(XX_PhysToVirt(p_FmPort->fmMuramPhysBaseAddr));
+ uint32_t *param_page = XX_PhysToVirt(p_FmPort->fmMuramPhysBaseAddr + GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rgpr));
+ t_ArCommonDesc *ArCommonDescPtr = (t_ArCommonDesc*)(XX_PhysToVirt(p_FmPort->fmMuramPhysBaseAddr + GET_UINT32(*param_page)));
+ struct arOffsets* of;
+ uint8_t tmp = 0;
+ t_FmGetSetParams fmGetSetParams;
+ memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
+ fmGetSetParams.setParams.type = UPDATE_FPM_BRKC_SLP;
+ fmGetSetParams.setParams.sleep = 1;
+
+ err = DsarCheckParams(params, p_FmPort->deepSleepVars.autoResMaxSizes);
+ if (err != E_OK)
+ return err;
+
+ p_FmPort->deepSleepVars.autoResOffsets = XX_Malloc(sizeof(struct arOffsets));
+ of = (struct arOffsets *)p_FmPort->deepSleepVars.autoResOffsets;
+ IOMemSet32(ArCommonDescPtr, 0, AR_ComputeOffsets(of, params, p_FmPort));
+
+ // common
+ WRITE_UINT8(ArCommonDescPtr->arTxPort, p_FmPortTx->hardwarePortId);
+ nia = GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfne); // bmi nia
+ if ((nia & 0x007C0000) == 0x00440000) // bmi nia is parser
+ WRITE_UINT32(ArCommonDescPtr->activeHPNIA, GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfpne));
+ else
+ WRITE_UINT32(ArCommonDescPtr->activeHPNIA, nia);
+ WRITE_UINT16(ArCommonDescPtr->snmpPort, 161);
+
+ // ARP
+ if (params->p_AutoResArpInfo)
+ {
+ t_DsarArpBindingEntry* arp_bindings;
+ ArpDescriptor = (t_DsarArpDescriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->arp);
+ WRITE_UINT32(ArCommonDescPtr->p_ArpDescriptor, PTR_TO_UINT(ArpDescriptor) - fmMuramVirtBaseAddr);
+ arp_bindings = (t_DsarArpBindingEntry*)(PTR_TO_UINT(ArpDescriptor) + sizeof(t_DsarArpDescriptor));
+ if (params->p_AutoResArpInfo->enableConflictDetection)
+ WRITE_UINT16(ArpDescriptor->control, 1);
+ else
+ WRITE_UINT16(ArpDescriptor->control, 0);
+ if (params->p_AutoResArpInfo->tableSize)
{
- if((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) &&
- (p_FmPort->portType != e_FM_PORT_TYPE_RX))
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Available for Rx ports only"));
+ t_FmPortDsarArpEntry* arp_entry = params->p_AutoResArpInfo->p_AutoResTable;
+ WRITE_UINT16(*(uint16_t*)&ArCommonDescPtr->macStationAddr[0], *(uint16_t*)&arp_entry[0].mac[0]);
+ WRITE_UINT32(*(uint32_t*)&ArCommonDescPtr->macStationAddr[2], *(uint32_t*)&arp_entry[0].mac[2]);
+ WRITE_UINT16(ArpDescriptor->numOfBindings, params->p_AutoResArpInfo->tableSize);
+
+ for (i = 0; i < params->p_AutoResArpInfo->tableSize; i++)
+ {
+ WRITE_UINT32(arp_bindings[i].ipv4Addr, arp_entry[i].ipAddress);
+ if (arp_entry[i].isVlan)
+ WRITE_UINT16(arp_bindings[i].vlanId, arp_entry[i].vid & 0xFFF);
+ }
+ WRITE_UINT32(ArpDescriptor->p_Bindings, PTR_TO_UINT(arp_bindings) - fmMuramVirtBaseAddr);
}
- else
-#endif /* FM_NO_OP_OBSERVED_CGS */
- if((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) &&
- (p_FmPort->portType != e_FM_PORT_TYPE_RX) &&
- (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Available for Rx & OP ports only"));
+ WRITE_UINT32(ArpDescriptor->p_Statistics, PTR_TO_UINT(arp_bindings) +
+ sizeof(t_DsarArpBindingEntry) * params->p_AutoResArpInfo->tableSize - fmMuramVirtBaseAddr);
}
- opPort = (bool)((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING) ? TRUE:FALSE);
-
- /* to minimize memory access (groups may belong to the same regsiter, and may
- be out of order), we first collect all information into a 256 booleans array,
- representing each possible group. */
+ // ICMPV4
+ if (params->p_AutoResEchoIpv4Info)
+ {
+ t_DsarIcmpV4BindingEntry* icmpv4_bindings;
+ ICMPV4Descriptor = (t_DsarIcmpV4Descriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->icmpv4);
+ WRITE_UINT32(ArCommonDescPtr->p_IcmpV4Descriptor, PTR_TO_UINT(ICMPV4Descriptor) - fmMuramVirtBaseAddr);
+ icmpv4_bindings = (t_DsarIcmpV4BindingEntry*)(PTR_TO_UINT(ICMPV4Descriptor) + sizeof(t_DsarIcmpV4Descriptor));
+ WRITE_UINT16(ICMPV4Descriptor->control, 0);
+ if (params->p_AutoResEchoIpv4Info->tableSize)
+ {
+ t_FmPortDsarArpEntry* arp_entry = params->p_AutoResEchoIpv4Info->p_AutoResTable;
+ WRITE_UINT16(*(uint16_t*)&ArCommonDescPtr->macStationAddr[0], *(uint16_t*)&arp_entry[0].mac[0]);
+ WRITE_UINT32(*(uint32_t*)&ArCommonDescPtr->macStationAddr[2], *(uint32_t*)&arp_entry[0].mac[2]);
+ WRITE_UINT16(ICMPV4Descriptor->numOfBindings, params->p_AutoResEchoIpv4Info->tableSize);
- memset(&tmpArray, 0, FM_PORT_NUM_OF_CONGESTION_GRPS*sizeof(bool));
- for(i=0;i<p_CongestionGrps->numOfCongestionGrpsToConsider;i++)
- tmpArray[p_CongestionGrps->congestionGrpsToConsider[i]] = TRUE;
+ for (i = 0; i < params->p_AutoResEchoIpv4Info->tableSize; i++)
+ {
+ WRITE_UINT32(icmpv4_bindings[i].ipv4Addr, arp_entry[i].ipAddress);
+ if (arp_entry[i].isVlan)
+ WRITE_UINT16(icmpv4_bindings[i].vlanId, arp_entry[i].vid & 0xFFF);
+ }
+ WRITE_UINT32(ICMPV4Descriptor->p_Bindings, PTR_TO_UINT(icmpv4_bindings) - fmMuramVirtBaseAddr);
+ }
+ WRITE_UINT32(ICMPV4Descriptor->p_Statistics, PTR_TO_UINT(icmpv4_bindings) +
+ sizeof(t_DsarIcmpV4BindingEntry) * params->p_AutoResEchoIpv4Info->tableSize - fmMuramVirtBaseAddr);
+ }
- for(i=0;i<FM_PORT_NUM_OF_CONGESTION_GRPS;i++)
+ // ICMPV6
+ if (params->p_AutoResEchoIpv6Info)
{
- mod = (uint8_t)(i%32);
- /* each 32 congestion groups are represented by a register */
- if (mod == 0) /* first in a 32 bunch of congestion groups, get the currest register state */
- tmpReg = opPort ? GET_UINT32(p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ocgm):
- GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_cgm[7-i/32]);
+ t_DsarIcmpV6BindingEntry* icmpv6_bindings;
+ ICMPV6Descriptor = (t_DsarIcmpV6Descriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->icmpv6);
+ WRITE_UINT32(ArCommonDescPtr->p_IcmpV6Descriptor, PTR_TO_UINT(ICMPV6Descriptor) - fmMuramVirtBaseAddr);
+ icmpv6_bindings = (t_DsarIcmpV6BindingEntry*)(PTR_TO_UINT(ICMPV6Descriptor) + sizeof(t_DsarIcmpV6Descriptor));
+ WRITE_UINT16(ICMPV6Descriptor->control, 0);
+ if (params->p_AutoResEchoIpv6Info->tableSize)
+ {
+ t_FmPortDsarNdpEntry* ndp_entry = params->p_AutoResEchoIpv6Info->p_AutoResTable;
+ WRITE_UINT16(*(uint16_t*)&ArCommonDescPtr->macStationAddr[0], *(uint16_t*)&ndp_entry[0].mac[0]);
+ WRITE_UINT32(*(uint32_t*)&ArCommonDescPtr->macStationAddr[2], *(uint32_t*)&ndp_entry[0].mac[2]);
+ WRITE_UINT16(ICMPV6Descriptor->numOfBindings, params->p_AutoResEchoIpv6Info->tableSize);
- /* set in the register, the bit representing the relevant congestion group. */
- if(tmpArray[i])
- tmpReg |= (0x00000001 << (uint32_t)mod);
+ for (i = 0; i < params->p_AutoResEchoIpv6Info->tableSize; i++)
+ {
+ for (j = 0; j < 4; j++)
+ WRITE_UINT32(icmpv6_bindings[i].ipv6Addr[j], ndp_entry[i].ipAddress[j]);
+ if (ndp_entry[i].isVlan)
+ WRITE_UINT16(*(uint16_t*)&icmpv6_bindings[i].ipv6Addr[4], ndp_entry[i].vid & 0xFFF); // writing vlan
+ }
+ WRITE_UINT32(ICMPV6Descriptor->p_Bindings, PTR_TO_UINT(icmpv6_bindings) - fmMuramVirtBaseAddr);
+ }
+ WRITE_UINT32(ICMPV6Descriptor->p_Statistics, PTR_TO_UINT(icmpv6_bindings) +
+ sizeof(t_DsarIcmpV6BindingEntry) * params->p_AutoResEchoIpv6Info->tableSize - fmMuramVirtBaseAddr);
+ }
+
+ // ND
+ if (params->p_AutoResNdpInfo)
+ {
+ t_DsarIcmpV6BindingEntry* icmpv6_bindings;
+ NDDescriptor = (t_DsarNdDescriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->nd);
+ WRITE_UINT32(ArCommonDescPtr->p_NdDescriptor, PTR_TO_UINT(NDDescriptor) - fmMuramVirtBaseAddr);
+ icmpv6_bindings = (t_DsarIcmpV6BindingEntry*)(PTR_TO_UINT(NDDescriptor) + sizeof(t_DsarNdDescriptor));
+ if (params->p_AutoResNdpInfo->enableConflictDetection)
+ WRITE_UINT16(NDDescriptor->control, 1);
+ else
+ WRITE_UINT16(NDDescriptor->control, 0);
+ if (params->p_AutoResNdpInfo->tableSizeAssigned + params->p_AutoResNdpInfo->tableSizeTmp)
+ {
+ t_FmPortDsarNdpEntry* ndp_entry = params->p_AutoResNdpInfo->p_AutoResTableAssigned;
+ WRITE_UINT16(*(uint16_t*)&ArCommonDescPtr->macStationAddr[0], *(uint16_t*)&ndp_entry[0].mac[0]);
+ WRITE_UINT32(*(uint32_t*)&ArCommonDescPtr->macStationAddr[2], *(uint32_t*)&ndp_entry[0].mac[2]);
+ WRITE_UINT16(NDDescriptor->numOfBindings, params->p_AutoResNdpInfo->tableSizeAssigned
+ + params->p_AutoResNdpInfo->tableSizeTmp);
- if (mod == 31) /* last in a 32 bunch of congestion groups - write the corresponding register */
+ for (i = 0; i < params->p_AutoResNdpInfo->tableSizeAssigned; i++)
+ {
+ for (j = 0; j < 4; j++)
+ WRITE_UINT32(icmpv6_bindings[i].ipv6Addr[j], ndp_entry[i].ipAddress[j]);
+ if (ndp_entry[i].isVlan)
+ WRITE_UINT16(*(uint16_t*)&icmpv6_bindings[i].ipv6Addr[4], ndp_entry[i].vid & 0xFFF); // writing vlan
+ }
+ ndp_entry = params->p_AutoResNdpInfo->p_AutoResTableTmp;
+ for (i = 0; i < params->p_AutoResNdpInfo->tableSizeTmp; i++)
+ {
+ for (j = 0; j < 4; j++)
+ WRITE_UINT32(icmpv6_bindings[i + params->p_AutoResNdpInfo->tableSizeAssigned].ipv6Addr[j], ndp_entry[i].ipAddress[j]);
+ if (ndp_entry[i].isVlan)
+ WRITE_UINT16(*(uint16_t*)&icmpv6_bindings[i + params->p_AutoResNdpInfo->tableSizeAssigned].ipv6Addr[4], ndp_entry[i].vid & 0xFFF); // writing vlan
+ }
+ WRITE_UINT32(NDDescriptor->p_Bindings, PTR_TO_UINT(icmpv6_bindings) - fmMuramVirtBaseAddr);
+ }
+ WRITE_UINT32(NDDescriptor->p_Statistics, PTR_TO_UINT(icmpv6_bindings) + sizeof(t_DsarIcmpV6BindingEntry)
+ * (params->p_AutoResNdpInfo->tableSizeAssigned + params->p_AutoResNdpInfo->tableSizeTmp)
+ - fmMuramVirtBaseAddr);
+ WRITE_UINT32(NDDescriptor->solicitedAddr, 0xFFFFFFFF);
+ }
+
+ // SNMP
+ if (params->p_AutoResSnmpInfo)
+ {
+ t_FmPortDsarSnmpInfo *snmpSrc = params->p_AutoResSnmpInfo;
+ t_DsarSnmpIpv4AddrTblEntry* snmpIpv4Addr;
+ t_DsarSnmpIpv6AddrTblEntry* snmpIpv6Addr;
+ t_OidsTblEntry* snmpOid;
+ uint8_t *charPointer;
+ int len;
+ t_DsarSnmpDescriptor* SnmpDescriptor = (t_DsarSnmpDescriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->snmp);
+ WRITE_UINT32(ArCommonDescPtr->p_SnmpDescriptor, PTR_TO_UINT(SnmpDescriptor) - fmMuramVirtBaseAddr);
+ WRITE_UINT16(SnmpDescriptor->control, snmpSrc->control);
+ WRITE_UINT16(SnmpDescriptor->maxSnmpMsgLength, snmpSrc->maxSnmpMsgLength);
+ snmpIpv4Addr = (t_DsarSnmpIpv4AddrTblEntry*)(PTR_TO_UINT(SnmpDescriptor) + sizeof(t_DsarSnmpDescriptor));
+ if (snmpSrc->numOfIpv4Addresses)
+ {
+ t_FmPortDsarSnmpIpv4AddrTblEntry* snmpIpv4AddrSrc = snmpSrc->p_Ipv4AddrTbl;
+ WRITE_UINT16(SnmpDescriptor->numOfIpv4Addresses, snmpSrc->numOfIpv4Addresses);
+ for (i = 0; i < snmpSrc->numOfIpv4Addresses; i++)
+ {
+ WRITE_UINT32(snmpIpv4Addr[i].ipv4Addr, snmpIpv4AddrSrc[i].ipv4Addr);
+ if (snmpIpv4AddrSrc[i].isVlan)
+ WRITE_UINT16(snmpIpv4Addr[i].vlanId, snmpIpv4AddrSrc[i].vid & 0xFFF);
+ }
+ WRITE_UINT32(SnmpDescriptor->p_Ipv4AddrTbl, PTR_TO_UINT(snmpIpv4Addr) - fmMuramVirtBaseAddr);
+ }
+ snmpIpv6Addr = (t_DsarSnmpIpv6AddrTblEntry*)(PTR_TO_UINT(snmpIpv4Addr)
+ + sizeof(t_DsarSnmpIpv4AddrTblEntry) * snmpSrc->numOfIpv4Addresses);
+ if (snmpSrc->numOfIpv6Addresses)
{
- if(opPort)
- WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ocgm, tmpReg);
+ t_FmPortDsarSnmpIpv6AddrTblEntry* snmpIpv6AddrSrc = snmpSrc->p_Ipv6AddrTbl;
+ WRITE_UINT16(SnmpDescriptor->numOfIpv6Addresses, snmpSrc->numOfIpv6Addresses);
+ for (i = 0; i < snmpSrc->numOfIpv6Addresses; i++)
+ {
+ for (j = 0; j < 4; j++)
+ WRITE_UINT32(snmpIpv6Addr[i].ipv6Addr[j], snmpIpv6AddrSrc[i].ipv6Addr[j]);
+ if (snmpIpv6AddrSrc[i].isVlan)
+ WRITE_UINT16(snmpIpv6Addr[i].vlanId, snmpIpv6AddrSrc[i].vid & 0xFFF);
+ }
+ WRITE_UINT32(SnmpDescriptor->p_Ipv6AddrTbl, PTR_TO_UINT(snmpIpv6Addr) - fmMuramVirtBaseAddr);
+ }
+ snmpOid = (t_OidsTblEntry*)(PTR_TO_UINT(snmpIpv6Addr)
+ + sizeof(t_DsarSnmpIpv6AddrTblEntry) * snmpSrc->numOfIpv6Addresses);
+ charPointer = (uint8_t*)(PTR_TO_UINT(snmpOid)
+ + sizeof(t_OidsTblEntry) * snmpSrc->oidsTblSize);
+ len = TOTAL_BER_LEN(GetBERLen(&snmpSrc->p_RdOnlyCommunityStr[1]));
+ Mem2IOCpy32(charPointer, snmpSrc->p_RdOnlyCommunityStr, len);
+ WRITE_UINT32(SnmpDescriptor->p_RdOnlyCommunityStr, PTR_TO_UINT(charPointer) - fmMuramVirtBaseAddr);
+ charPointer += len;
+ len = TOTAL_BER_LEN(GetBERLen(&snmpSrc->p_RdWrCommunityStr[1]));
+ Mem2IOCpy32(charPointer, snmpSrc->p_RdWrCommunityStr, len);
+ WRITE_UINT32(SnmpDescriptor->p_RdWrCommunityStr, PTR_TO_UINT(charPointer) - fmMuramVirtBaseAddr);
+ charPointer += len;
+ WRITE_UINT32(SnmpDescriptor->oidsTblSize, snmpSrc->oidsTblSize);
+ WRITE_UINT32(SnmpDescriptor->p_OidsTbl, PTR_TO_UINT(snmpOid) - fmMuramVirtBaseAddr);
+ for (i = 0; i < snmpSrc->oidsTblSize; i++)
+ {
+ WRITE_UINT16(snmpOid->oidSize, snmpSrc->p_OidsTbl[i].oidSize);
+ WRITE_UINT16(snmpOid->resSize, snmpSrc->p_OidsTbl[i].resSize);
+ Mem2IOCpy32(charPointer, snmpSrc->p_OidsTbl[i].oidVal, snmpSrc->p_OidsTbl[i].oidSize);
+ WRITE_UINT32(snmpOid->p_Oid, PTR_TO_UINT(charPointer) - fmMuramVirtBaseAddr);
+ charPointer += snmpSrc->p_OidsTbl[i].oidSize;
+ if (snmpSrc->p_OidsTbl[i].resSize <= 4)
+ WRITE_UINT32(snmpOid->resValOrPtr, *snmpSrc->p_OidsTbl[i].resVal);
else
- WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_cgm[7-i/32], tmpReg);
+ {
+ Mem2IOCpy32(charPointer, snmpSrc->p_OidsTbl[i].resVal, snmpSrc->p_OidsTbl[i].resSize);
+ WRITE_UINT32(snmpOid->resValOrPtr, PTR_TO_UINT(charPointer) - fmMuramVirtBaseAddr);
+ charPointer += snmpSrc->p_OidsTbl[i].resSize;
+ }
+ snmpOid++;
}
+ charPointer = UINT_TO_PTR(ROUND_UP(PTR_TO_UINT(charPointer),4));
+ WRITE_UINT32(SnmpDescriptor->p_Statistics, PTR_TO_UINT(charPointer) - fmMuramVirtBaseAddr);
}
- return E_OK;
-}
-
-t_Error FM_PORT_RemoveCongestionGrps(t_Handle h_FmPort, t_FmPortCongestionGrps *p_CongestionGrps)
-{
- t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- bool tmpArray[FM_PORT_NUM_OF_CONGESTION_GRPS], opPort;
- int i;
- uint8_t mod;
- uint32_t tmpReg = 0;
+ // filtering
+ if (params->p_AutoResFilteringInfo)
+ {
+ if (params->p_AutoResFilteringInfo->ipProtPassOnHit)
+ tmp |= IP_PROT_TBL_PASS_MASK;
+ if (params->p_AutoResFilteringInfo->udpPortPassOnHit)
+ tmp |= UDP_PORT_TBL_PASS_MASK;
+ if (params->p_AutoResFilteringInfo->tcpPortPassOnHit)
+ tmp |= TCP_PORT_TBL_PASS_MASK;
+ WRITE_UINT8(ArCommonDescPtr->filterControl, tmp);
+ WRITE_UINT16(ArCommonDescPtr->tcpControlPass, params->p_AutoResFilteringInfo->tcpFlagsMask);
- SANITY_CHECK_RETURN_ERROR(p_FmPort, E_INVALID_HANDLE);
+ // ip filtering
+ if (params->p_AutoResFilteringInfo->ipProtTableSize)
+ {
+ uint8_t* ip_tbl = (uint8_t*)(PTR_TO_UINT(ArCommonDescPtr) + of->filtIp);
+ WRITE_UINT8(ArCommonDescPtr->ipProtocolTblSize, params->p_AutoResFilteringInfo->ipProtTableSize);
+ for (i = 0; i < params->p_AutoResFilteringInfo->ipProtTableSize; i++)
+ WRITE_UINT8(ip_tbl[i], params->p_AutoResFilteringInfo->p_IpProtTablePtr[i]);
+ WRITE_UINT32(ArCommonDescPtr->p_IpProtocolFiltTbl, PTR_TO_UINT(ip_tbl) - fmMuramVirtBaseAddr);
+ }
- {
-#ifdef FM_NO_OP_OBSERVED_CGS
- t_FmRevisionInfo revInfo;
+ // udp filtering
+ if (params->p_AutoResFilteringInfo->udpPortsTableSize)
+ {
+ t_PortTblEntry* udp_tbl = (t_PortTblEntry*)(PTR_TO_UINT(ArCommonDescPtr) + of->filtUdp);
+ WRITE_UINT8(ArCommonDescPtr->udpPortTblSize, params->p_AutoResFilteringInfo->udpPortsTableSize);
+ for (i = 0; i < params->p_AutoResFilteringInfo->udpPortsTableSize; i++)
+ {
+ WRITE_UINT32(udp_tbl[i].Ports,
+ (params->p_AutoResFilteringInfo->p_UdpPortsTablePtr[i].srcPort << 16) +
+ params->p_AutoResFilteringInfo->p_UdpPortsTablePtr[i].dstPort);
+ WRITE_UINT32(udp_tbl[i].PortsMask,
+ (params->p_AutoResFilteringInfo->p_UdpPortsTablePtr[i].srcPortMask << 16) +
+ params->p_AutoResFilteringInfo->p_UdpPortsTablePtr[i].dstPortMask);
+ }
+ WRITE_UINT32(ArCommonDescPtr->p_UdpPortFiltTbl, PTR_TO_UINT(udp_tbl) - fmMuramVirtBaseAddr);
+ }
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if (revInfo.majorRev != 4)
+ // tcp filtering
+ if (params->p_AutoResFilteringInfo->tcpPortsTableSize)
{
- if((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) &&
- (p_FmPort->portType != e_FM_PORT_TYPE_RX))
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Available for Rx ports only"));
+ t_PortTblEntry* tcp_tbl = (t_PortTblEntry*)(PTR_TO_UINT(ArCommonDescPtr) + of->filtTcp);
+ WRITE_UINT8(ArCommonDescPtr->tcpPortTblSize, params->p_AutoResFilteringInfo->tcpPortsTableSize);
+ for (i = 0; i < params->p_AutoResFilteringInfo->tcpPortsTableSize; i++)
+ {
+ WRITE_UINT32(tcp_tbl[i].Ports,
+ (params->p_AutoResFilteringInfo->p_TcpPortsTablePtr[i].srcPort << 16) +
+ params->p_AutoResFilteringInfo->p_TcpPortsTablePtr[i].dstPort);
+ WRITE_UINT32(tcp_tbl[i].PortsMask,
+ (params->p_AutoResFilteringInfo->p_TcpPortsTablePtr[i].srcPortMask << 16) +
+ params->p_AutoResFilteringInfo->p_TcpPortsTablePtr[i].dstPortMask);
+ }
+ WRITE_UINT32(ArCommonDescPtr->p_TcpPortFiltTbl, PTR_TO_UINT(tcp_tbl) - fmMuramVirtBaseAddr);
}
- else
-#endif /* FM_NO_OP_OBSERVED_CGS */
- if((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) &&
- (p_FmPort->portType != e_FM_PORT_TYPE_RX) &&
- (p_FmPort->portType != e_FM_PORT_TYPE_OH_OFFLINE_PARSING))
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Available for Rx & OP ports only"));
}
+ // common stats
+ WRITE_UINT32(ArCommonDescPtr->p_ArStats, PTR_TO_UINT(ArCommonDescPtr) + of->stats - fmMuramVirtBaseAddr);
- opPort = (bool)((p_FmPort->portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING) ? TRUE:FALSE);
+ // get into Deep Sleep sequence:
- /* to minimize memory access (groups may belong to the same regsiter, and may
- be out of order), we first collect all information into a 256 booleans array,
- representing each possible group. */
- memset(&tmpArray, 0, FM_PORT_NUM_OF_CONGESTION_GRPS*sizeof(bool));
- for(i=0;i<p_CongestionGrps->numOfCongestionGrpsToConsider;i++)
- tmpArray[p_CongestionGrps->congestionGrpsToConsider[i]] = TRUE;
+ // Ensures that FMan do not enter the idle state. This is done by programing
+ // FMDPSLPCR[FM_STOP] to one.
+ fm_soc_suspend();
- for(i=0;i<FM_PORT_NUM_OF_CONGESTION_GRPS;i++)
- {
- mod = (uint8_t)(i%32);
- /* each 32 congestion groups are represented by a register */
- if (mod == 0) /* first in a 32 bunch of congestion groups, get the currest register state */
- tmpReg = opPort ? GET_UINT32(p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ocgm):
- GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_cgm[7-i/32]);
+ ARDesc = UINT_TO_PTR(XX_VirtToPhys(ArCommonDescPtr));
+ return E_OK;
- /* set in the register, the bit representing the relevant congestion group. */
- if(tmpArray[i])
- tmpReg &= ~(0x00000001 << (uint32_t)mod);
+}
- if (mod == 31) /* last in a 32 bunch of congestion groups - write the corresponding register */
- {
- if(opPort)
- WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->ohPortBmiRegs.fmbm_ocgm, tmpReg);
- else
- WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_cgm[7-i/32], tmpReg);
- }
+void FM_ChangeClock(t_Handle h_Fm, int hardwarePortId);
+t_Error FM_PORT_EnterDsarFinal(t_Handle h_DsarRxPort, t_Handle h_DsarTxPort)
+{
+ t_FmGetSetParams fmGetSetParams;
+ t_FmPort *p_FmPort = (t_FmPort *)h_DsarRxPort;
+ t_FmPort *p_FmPortTx = (t_FmPort *)h_DsarTxPort;
+ t_Handle *h_FmPcd = FmGetPcd(p_FmPort->h_Fm);
+ t_FmPort *p_FmPortHc = FM_PCD_GetHcPort(h_FmPcd);
+ memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
+ fmGetSetParams.setParams.type = UPDATE_FM_CLD;
+ FmGetSetParams(p_FmPort->h_Fm, &fmGetSetParams);
+
+ /* Issue graceful stop to HC port */
+ FM_PORT_Disable(p_FmPortHc);
+
+ // config tx port
+ p_FmPort->deepSleepVars.fmbm_tcfg = GET_UINT32(p_FmPortTx->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcfg);
+ WRITE_UINT32(p_FmPortTx->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcfg, GET_UINT32(p_FmPortTx->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcfg) | BMI_PORT_CFG_IM | BMI_PORT_CFG_EN);
+ // ????
+ p_FmPort->deepSleepVars.fmbm_tcmne = GET_UINT32(p_FmPortTx->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcmne);
+ WRITE_UINT32(p_FmPortTx->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcmne, 0xE);
+ // Stage 7:echo
+ p_FmPort->deepSleepVars.fmbm_rfpne = GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfpne);
+ WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfpne, 0x2E);
+ if (!PrsIsEnabled(h_FmPcd))
+ {
+ p_FmPort->deepSleepVars.dsarEnabledParser = TRUE;
+ PrsEnable(h_FmPcd);
}
+ else
+ p_FmPort->deepSleepVars.dsarEnabledParser = FALSE;
+
+ p_FmPort->deepSleepVars.fmbm_rfne = GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfne);
+ WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfne, 0x440000);
+
+ // save rcfg for restoring: accumulate mode is changed by ucode
+ p_FmPort->deepSleepVars.fmbm_rcfg = GET_UINT32(p_FmPort->port.bmi_regs->rx.fmbm_rcfg);
+ WRITE_UINT32(p_FmPort->port.bmi_regs->rx.fmbm_rcfg, p_FmPort->deepSleepVars.fmbm_rcfg | BMI_PORT_CFG_AM);
+ memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
+ fmGetSetParams.setParams.type = UPDATE_FPM_BRKC_SLP;
+ fmGetSetParams.setParams.sleep = 1;
+ FmGetSetParams(p_FmPort->h_Fm, &fmGetSetParams);
+
+// ***** issue external request sync command
+ memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
+ fmGetSetParams.setParams.type = UPDATE_FPM_EXTC;
+ FmGetSetParams(p_FmPort->h_Fm, &fmGetSetParams);
+ // get
+ memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
+ fmGetSetParams.getParams.type = GET_FMFP_EXTC;
+ FmGetSetParams(p_FmPort->h_Fm, &fmGetSetParams);
+ if (fmGetSetParams.getParams.fmfp_extc != 0)
+ {
+ // clear
+ memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
+ fmGetSetParams.setParams.type = UPDATE_FPM_EXTC_CLEAR;
+ FmGetSetParams(p_FmPort->h_Fm, &fmGetSetParams);
+}
+
+ memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
+ fmGetSetParams.getParams.type = GET_FMFP_EXTC | GET_FM_NPI;
+ do
+ {
+ FmGetSetParams(p_FmPort->h_Fm, &fmGetSetParams);
+ } while (fmGetSetParams.getParams.fmfp_extc != 0 && fmGetSetParams.getParams.fm_npi == 0);
+ if (fmGetSetParams.getParams.fm_npi != 0)
+ XX_Print("FM: Sync did not finish\n");
+
+ // check that all stoped
+ memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
+ fmGetSetParams.getParams.type = GET_FMQM_GS | GET_FM_NPI;
+ FmGetSetParams(p_FmPort->h_Fm, &fmGetSetParams);
+ while (fmGetSetParams.getParams.fmqm_gs & 0xF0000000)
+ FmGetSetParams(p_FmPort->h_Fm, &fmGetSetParams);
+ if (fmGetSetParams.getParams.fmqm_gs == 0 && fmGetSetParams.getParams.fm_npi == 0)
+ XX_Print("FM: Sleeping\n");
+// FM_ChangeClock(p_FmPort->h_Fm, p_FmPort->hardwarePortId);
+
+ return E_OK;
+}
+
+void FM_PORT_Dsar_DumpRegs()
+{
+ uint32_t* hh = XX_PhysToVirt(PTR_TO_UINT(ARDesc));
+ DUMP_MEMORY(hh, 0x220);
+}
+
+void FM_PORT_ExitDsar(t_Handle h_FmPortRx, t_Handle h_FmPortTx)
+{
+ t_FmPort *p_FmPort = (t_FmPort *)h_FmPortRx;
+ t_FmPort *p_FmPortTx = (t_FmPort *)h_FmPortTx;
+ t_Handle *h_FmPcd = FmGetPcd(p_FmPort->h_Fm);
+ t_FmPort *p_FmPortHc = FM_PCD_GetHcPort(h_FmPcd);
+ t_FmGetSetParams fmGetSetParams;
+ memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
+ fmGetSetParams.setParams.type = UPDATE_FPM_BRKC_SLP;
+ fmGetSetParams.setParams.sleep = 0;
+ if (p_FmPort->deepSleepVars.autoResOffsets)
+ {
+ XX_Free(p_FmPort->deepSleepVars.autoResOffsets);
+ p_FmPort->deepSleepVars.autoResOffsets = 0;
+ }
+
+ if (p_FmPort->deepSleepVars.dsarEnabledParser)
+ PrsDisable(FmGetPcd(p_FmPort->h_Fm));
+ WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfpne, p_FmPort->deepSleepVars.fmbm_rfpne);
+ WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfne, p_FmPort->deepSleepVars.fmbm_rfne);
+ WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rcfg, p_FmPort->deepSleepVars.fmbm_rcfg);
+ FmGetSetParams(p_FmPort->h_Fm, &fmGetSetParams);
+ WRITE_UINT32(p_FmPortTx->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcmne, p_FmPort->deepSleepVars.fmbm_tcmne);
+ WRITE_UINT32(p_FmPortTx->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcfg, p_FmPort->deepSleepVars.fmbm_tcfg);
+ FM_PORT_Enable(p_FmPortHc);
+}
- return E_OK;
+bool FM_PORT_IsInDsar(t_Handle h_FmPort)
+{
+ t_FmPort *p_FmPort = (t_FmPort *)h_FmPort;
+ return PTR_TO_UINT(p_FmPort->deepSleepVars.autoResOffsets);
}
+t_Error FM_PORT_GetDsarStats(t_Handle h_FmPortRx, t_FmPortDsarStats *stats)
+{
+ t_FmPort *p_FmPort = (t_FmPort *)h_FmPortRx;
+ struct arOffsets *of = (struct arOffsets*)p_FmPort->deepSleepVars.autoResOffsets;
+ uint8_t* fmMuramVirtBaseAddr = XX_PhysToVirt(p_FmPort->fmMuramPhysBaseAddr);
+ uint32_t *param_page = XX_PhysToVirt(p_FmPort->fmMuramPhysBaseAddr + GET_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rgpr));
+ t_ArCommonDesc *ArCommonDescPtr = (t_ArCommonDesc*)(XX_PhysToVirt(p_FmPort->fmMuramPhysBaseAddr + GET_UINT32(*param_page)));
+ t_DsarArpDescriptor *ArpDescriptor = (t_DsarArpDescriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->arp);
+ t_DsarArpStatistics* arp_stats = (t_DsarArpStatistics*)(PTR_TO_UINT(ArpDescriptor->p_Statistics) + fmMuramVirtBaseAddr);
+ t_DsarIcmpV4Descriptor* ICMPV4Descriptor = (t_DsarIcmpV4Descriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->icmpv4);
+ t_DsarIcmpV4Statistics* icmpv4_stats = (t_DsarIcmpV4Statistics*)(PTR_TO_UINT(ICMPV4Descriptor->p_Statistics) + fmMuramVirtBaseAddr);
+ t_DsarNdDescriptor* NDDescriptor = (t_DsarNdDescriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->nd);
+ t_NdStatistics* nd_stats = (t_NdStatistics*)(PTR_TO_UINT(NDDescriptor->p_Statistics) + fmMuramVirtBaseAddr);
+ t_DsarIcmpV6Descriptor* ICMPV6Descriptor = (t_DsarIcmpV6Descriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->icmpv6);
+ t_DsarIcmpV6Statistics* icmpv6_stats = (t_DsarIcmpV6Statistics*)(PTR_TO_UINT(ICMPV6Descriptor->p_Statistics) + fmMuramVirtBaseAddr);
+ t_DsarSnmpDescriptor* SnmpDescriptor = (t_DsarSnmpDescriptor*)(PTR_TO_UINT(ArCommonDescPtr) + of->snmp);
+ t_DsarSnmpStatistics* snmp_stats = (t_DsarSnmpStatistics*)(PTR_TO_UINT(SnmpDescriptor->p_Statistics) + fmMuramVirtBaseAddr);
+ stats->arpArCnt = arp_stats->arCnt;
+ stats->echoIcmpv4ArCnt = icmpv4_stats->arCnt;
+ stats->ndpArCnt = nd_stats->arCnt;
+ stats->echoIcmpv6ArCnt = icmpv6_stats->arCnt;
+ stats->snmpGetCnt = snmp_stats->snmpGetReqCnt;
+ stats->snmpGetNextCnt = snmp_stats->snmpGetNextReqCnt;
+ return E_OK;
+}
+#endif
diff --git a/sys/contrib/ncsw/Peripherals/FM/Port/fm_port.h b/sys/contrib/ncsw/Peripherals/FM/Port/fm_port.h
index 2e8a99735e26..85986f553c3f 100644
--- a/sys/contrib/ncsw/Peripherals/FM/Port/fm_port.h
+++ b/sys/contrib/ncsw/Peripherals/FM/Port/fm_port.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm_port.h
@@ -43,7 +44,10 @@
#include "fm_port_ext.h"
#include "fm_common.h"
-
+#include "fm_sp_common.h"
+#include "fsl_fman_sp.h"
+#include "fm_port_ext.h"
+#include "fsl_fman_port.h"
#define __ERR_MODULE__ MODULE_FM_PORT
@@ -51,6 +55,7 @@
#define MIN_EXT_BUF_SIZE 64
#define DATA_ALIGNMENT 64
#define MAX_LIODN_OFFSET 64
+#define MAX_PORT_FIFO_SIZE MIN(BMI_MAX_FIFO_SIZE, 1024*BMI_FIFO_UNITS)
/**************************************************************************//**
@Description Memory Map defines
@@ -62,36 +67,31 @@
/**************************************************************************//**
@Description defaults
*//***************************************************************************/
-#define DEFAULT_PORT_deqHighPriority TRUE
+#define DEFAULT_PORT_deqHighPriority_1G FALSE
+#define DEFAULT_PORT_deqHighPriority_10G TRUE
#define DEFAULT_PORT_deqType e_FM_PORT_DEQ_TYPE1
-#ifdef FM_QMI_DEQ_OPTIONS_SUPPORT
#define DEFAULT_PORT_deqPrefetchOption e_FM_PORT_DEQ_FULL_PREFETCH
#define DEFAULT_PORT_deqPrefetchOption_HC e_FM_PORT_DEQ_NO_PREFETCH
-#endif /* FM_QMI_DEQ_OPTIONS_SUPPORT */
-#define DEFAULT_PORT_deqByteCnt 2000
-#define DEFAULT_PORT_bufferPrefixContent_privDataSize 0
-#define DEFAULT_PORT_bufferPrefixContent_passPrsResult FALSE
-#define DEFAULT_PORT_bufferPrefixContent_passTimeStamp FALSE
-#define DEFAULT_PORT_bufferPrefixContent_allOtherPCDInfo FALSE
-#ifdef DEBUG
-#define DEFAULT_PORT_bufferPrefixContent_debugInfo FALSE
-#endif /* DEBUG */
-#define DEFAULT_PORT_bufferPrefixContent_dataAlign DATA_ALIGNMENT
+#define DEFAULT_PORT_deqByteCnt_10G 0x1400
+#define DEFAULT_PORT_deqByteCnt_1G 0x400
+#define DEFAULT_PORT_bufferPrefixContent_privDataSize DEFAULT_FM_SP_bufferPrefixContent_privDataSize
+#define DEFAULT_PORT_bufferPrefixContent_passPrsResult DEFAULT_FM_SP_bufferPrefixContent_passPrsResult
+#define DEFAULT_PORT_bufferPrefixContent_passTimeStamp DEFAULT_FM_SP_bufferPrefixContent_passTimeStamp
+#define DEFAULT_PORT_bufferPrefixContent_allOtherPCDInfo DEFAULT_FM_SP_bufferPrefixContent_allOtherPCDInfo
+#define DEFAULT_PORT_bufferPrefixContent_dataAlign DEFAULT_FM_SP_bufferPrefixContent_dataAlign
#define DEFAULT_PORT_cheksumLastBytesIgnore 0
#define DEFAULT_PORT_cutBytesFromEnd 4
-#define DEFAULT_PORT_txFifoMinFillLevel 0
-#define DEFAULT_PORT_txFifoDeqPipelineDepth_IM 2
-#define DEFAULT_PORT_txFifoDeqPipelineDepth_1G 2
-#define DEFAULT_PORT_txFifoDeqPipelineDepth_10G 8
-#define DEFAULT_PORT_txFifoLowComfLevel (5*KILOBYTE)
-#define DEFAULT_PORT_rxFifoPriElevationLevel BMI_MAX_FIFO_SIZE
-#define DEFAULT_PORT_rxFifoThreshold (BMI_MAX_FIFO_SIZE*3/4)
+#define DEFAULT_PORT_fifoDeqPipelineDepth_IM 2
+
#define DEFAULT_PORT_frmDiscardOverride FALSE
-#define DEFAULT_PORT_dmaSwapData e_FM_PORT_DMA_NO_SWP
-#define DEFAULT_PORT_dmaIntContextCacheAttr e_FM_PORT_DMA_NO_STASH
-#define DEFAULT_PORT_dmaHeaderCacheAttr e_FM_PORT_DMA_NO_STASH
-#define DEFAULT_PORT_dmaScatterGatherCacheAttr e_FM_PORT_DMA_NO_STASH
-#define DEFAULT_PORT_dmaWriteOptimize TRUE
+
+#define DEFAULT_PORT_dmaSwapData (e_FmDmaSwapOption)DEFAULT_FMAN_SP_DMA_SWAP_DATA
+#define DEFAULT_PORT_dmaIntContextCacheAttr (e_FmDmaCacheOption)DEFAULT_FMAN_SP_DMA_INT_CONTEXT_CACHE_ATTR
+#define DEFAULT_PORT_dmaHeaderCacheAttr (e_FmDmaCacheOption)DEFAULT_FMAN_SP_DMA_HEADER_CACHE_ATTR
+#define DEFAULT_PORT_dmaScatterGatherCacheAttr (e_FmDmaCacheOption)DEFAULT_FMAN_SP_DMA_SCATTER_GATHER_CACHE_ATTR
+#define DEFAULT_PORT_dmaWriteOptimize DEFAULT_FMAN_SP_DMA_WRITE_OPTIMIZE
+
+#define DEFAULT_PORT_noScatherGather DEFAULT_FMAN_SP_NO_SCATTER_GATHER
#define DEFAULT_PORT_forwardIntContextReuse FALSE
#define DEFAULT_PORT_BufMargins_startMargins 32
#define DEFAULT_PORT_BufMargins_endMargins 0
@@ -99,9 +99,23 @@
#define DEFAULT_PORT_syncReqForHc FALSE
#define DEFAULT_PORT_color e_FM_PORT_COLOR_GREEN
#define DEFAULT_PORT_errorsToDiscard FM_PORT_FRM_ERR_CLS_DISCARD
-#define DEFAULT_dualRateLimitScaleDown e_FM_PORT_DUAL_RATE_LIMITER_NONE
-#define DEFAULT_rateLimitBurstSizeHighGranularity FALSE
-#define DEFAULT_exception IM_EV_BSY
+/* #define DEFAULT_PORT_dualRateLimitScaleDown e_FM_PORT_DUAL_RATE_LIMITER_NONE */
+/* #define DEFAULT_PORT_rateLimitBurstSizeHighGranularity FALSE */
+#define DEFAULT_PORT_exception IM_EV_BSY
+#define DEFAULT_PORT_maxFrameLength 9600
+
+#define DEFAULT_notSupported 0xff
+
+#if (DPAA_VERSION < 11)
+#define DEFAULT_PORT_rxFifoPriElevationLevel MAX_PORT_FIFO_SIZE
+#define DEFAULT_PORT_rxFifoThreshold (MAX_PORT_FIFO_SIZE*3/4)
+
+#define DEFAULT_PORT_txFifoMinFillLevel 0
+#define DEFAULT_PORT_txFifoLowComfLevel (5*KILOBYTE)
+#define DEFAULT_PORT_fifoDeqPipelineDepth_1G 1
+#define DEFAULT_PORT_fifoDeqPipelineDepth_10G 4
+
+#define DEFAULT_PORT_fifoDeqPipelineDepth_OH 2
/* Host command port MUST NOT be changed to more than 1 !!! */
#define DEFAULT_PORT_numOfTasks(type) \
@@ -112,46 +126,116 @@
((type) == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)) ? 3 : 1))
#define DEFAULT_PORT_extraNumOfTasks(type) \
- (uint32_t)((((type) == e_FM_PORT_TYPE_RX_10G) || \
- ((type) == e_FM_PORT_TYPE_TX_10G)) ? 8 : \
- ((((type) == e_FM_PORT_TYPE_RX) || \
- ((type) == e_FM_PORT_TYPE_TX) || \
- ((type) == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)) ? 2 : 0))
+ (uint32_t)(((type) == e_FM_PORT_TYPE_RX_10G) ? 8 : \
+ (((type) == e_FM_PORT_TYPE_RX) ? 2 : 0))
-#define DEFAULT_PORT_numOfOpenDmas(type) \
- (uint32_t)(((type) == e_FM_PORT_TYPE_TX_10G) ? 8 : \
- (((type) == e_FM_PORT_TYPE_RX_10G) ? 4 : 1))
+#define DEFAULT_PORT_numOfOpenDmas(type) \
+ (uint32_t)((((type) == e_FM_PORT_TYPE_TX_10G) || \
+ ((type) == e_FM_PORT_TYPE_RX_10G)) ? 8 : 1 )
#define DEFAULT_PORT_extraNumOfOpenDmas(type) \
+ (uint32_t)(((type) == e_FM_PORT_TYPE_RX_10G) ? 8 : \
+ (((type) == e_FM_PORT_TYPE_RX) ? 1 : 0))
+
+#define DEFAULT_PORT_numOfFifoBufs(type) \
(uint32_t)((((type) == e_FM_PORT_TYPE_RX_10G) || \
- ((type) == e_FM_PORT_TYPE_TX_10G)) ? 8 : \
- ((((type) == e_FM_PORT_TYPE_RX) || \
- ((type) == e_FM_PORT_TYPE_TX) || \
- ((type) == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)) ? 1 : 0))
+ ((type) == e_FM_PORT_TYPE_TX_10G)) ? 48 : \
+ ((type) == e_FM_PORT_TYPE_RX) ? 45 : \
+ ((type) == e_FM_PORT_TYPE_TX) ? 44 : 8)
-#if defined(CONFIG_FMAN_RESOURCE_ALLOCATION_ALGORITHM)
-/* Let LLD to set minimum fifosize, otherwise fifosize settings will not work */
-#define DEFAULT_PORT_sizeOfFifo(type) \
- (uint32_t)(KILOBYTE)
-#else
-#define DEFAULT_PORT_sizeOfFifo(type) \
- (uint32_t)((((type) == e_FM_PORT_TYPE_RX_10G) || \
- ((type) == e_FM_PORT_TYPE_TX_10G)) ? (16*KILOBYTE) : \
- ((((type) == e_FM_PORT_TYPE_RX) || \
- ((type) == e_FM_PORT_TYPE_TX) || \
- ((type) == e_FM_PORT_TYPE_OH_OFFLINE_PARSING)) ? (4*KILOBYTE) : (1536)))
-#endif
-
-#define DEFAULT_PORT_extraSizeOfFifo(type) \
- (uint32_t)(((type) == e_FM_PORT_TYPE_RX_10G) ? (8*KILOBYTE) : \
- (((type) == e_FM_PORT_TYPE_RX) ? (4*KILOBYTE) : (0)))
+#define DEFAULT_PORT_extraNumOfFifoBufs 0
+
+#else /* (DPAA_VERSION < 11) */
+/* Defaults are registers' reset values */
+#define DEFAULT_PORT_rxFifoPriElevationLevel MAX_PORT_FIFO_SIZE
+#define DEFAULT_PORT_rxFifoThreshold MAX_PORT_FIFO_SIZE
+
+#define DEFAULT_PORT_txFifoMinFillLevel 0
+#define DEFAULT_PORT_txFifoLowComfLevel (5 * KILOBYTE)
+#define DEFAULT_PORT_fifoDeqPipelineDepth_1G 2
+#define DEFAULT_PORT_fifoDeqPipelineDepth_10G 4
+
+#define DEFAULT_PORT_fifoDeqPipelineDepth_OH 2
+
+#define DEFAULT_PORT_numOfTasks(type) \
+ (uint32_t)((((type) == e_FM_PORT_TYPE_RX_10G) || \
+ ((type) == e_FM_PORT_TYPE_TX_10G)) ? 14 : \
+ (((type) == e_FM_PORT_TYPE_RX) || \
+ ((type) == e_FM_PORT_TYPE_TX)) ? 4 : \
+ ((type) == e_FM_PORT_TYPE_OH_OFFLINE_PARSING) ? 6 : 1)
+
+#define DEFAULT_PORT_extraNumOfTasks(type) 0
+
+#define DEFAULT_PORT_numOfOpenDmas(type) \
+ (uint32_t)(((type) == e_FM_PORT_TYPE_RX_10G) ? 8 : \
+ ((type) == e_FM_PORT_TYPE_TX_10G) ? 12 : \
+ ((type) == e_FM_PORT_TYPE_RX) ? 2 : \
+ ((type) == e_FM_PORT_TYPE_TX) ? 3 : \
+ ((type) == e_FM_PORT_TYPE_OH_HOST_COMMAND) ? 2 : 4)
+
+#define DEFAULT_PORT_extraNumOfOpenDmas(type) 0
+
+#define DEFAULT_PORT_numOfFifoBufs(type) \
+ (uint32_t) (((type) == e_FM_PORT_TYPE_RX_10G) ? 96 : \
+ ((type) == e_FM_PORT_TYPE_TX_10G) ? 64 : \
+ ((type) == e_FM_PORT_TYPE_OH_HOST_COMMAND) ? 10 : 50)
+
+#define DEFAULT_PORT_extraNumOfFifoBufs 0
+
+#endif /* (DPAA_VERSION < 11) */
#define DEFAULT_PORT_txBdRingLength 16
#define DEFAULT_PORT_rxBdRingLength 128
#define DEFAULT_PORT_ImfwExtStructsMemId 0
#define DEFAULT_PORT_ImfwExtStructsMemAttr MEMORY_ATTR_CACHEABLE
-#define OH_PIPELINE_DEPTH 2
+#define FM_PORT_CG_REG_NUM(_cgId) (((FM_PORT_NUM_OF_CONGESTION_GRPS/32)-1)-_cgId/32)
+
+/**************************************************************************//**
+ @Collection PCD Engines
+*//***************************************************************************/
+typedef uint32_t fmPcdEngines_t; /**< options as defined below: */
+
+#define FM_PCD_NONE 0 /**< No PCD Engine indicated */
+#define FM_PCD_PRS 0x80000000 /**< Parser indicated */
+#define FM_PCD_KG 0x40000000 /**< Keygen indicated */
+#define FM_PCD_CC 0x20000000 /**< Coarse classification indicated */
+#define FM_PCD_PLCR 0x10000000 /**< Policer indicated */
+#define FM_PCD_MANIP 0x08000000 /**< Manipulation indicated */
+/* @} */
+
+#define FM_PORT_MAX_NUM_OF_EXT_POOLS_ALL_INTEGRATIONS 8
+#define FM_PORT_MAX_NUM_OF_CONGESTION_GRPS_ALL_INTEGRATIONS 256
+#define FM_PORT_CG_REG_NUM(_cgId) (((FM_PORT_NUM_OF_CONGESTION_GRPS/32)-1)-_cgId/32)
+
+#define FM_OH_PORT_ID 0
+
+/***********************************************************************/
+/* SW parser OFFLOAD labels (offsets) */
+/***********************************************************************/
+#if (DPAA_VERSION == 10)
+#define OFFLOAD_SW_PATCH_IPv4_IPR_LABEL 0x300
+#define OFFLOAD_SW_PATCH_IPv6_IPR_LABEL 0x325
+#define OFFLOAD_SW_PATCH_IPv6_IPF_LABEL 0x325
+#else
+#define OFFLOAD_SW_PATCH_IPv4_IPR_LABEL 0x100
+/* Will be used for:
+ * 1. identify fragments
+ * 2. udp-lite
+ */
+#define OFFLOAD_SW_PATCH_IPv6_IPR_LABEL 0x146
+/* Will be used for:
+ * 1. will identify the fragmentable area
+ * 2. udp-lite
+ */
+#define OFFLOAD_SW_PATCH_IPv6_IPF_LABEL 0x261
+#define OFFLOAD_SW_PATCH_CAPWAP_LABEL 0x38d
+#endif /* (DPAA_VERSION == 10) */
+
+#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
+#define UDP_LITE_SW_PATCH_LABEL 0x2E0
+#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
+
/**************************************************************************//**
@Description Memory Mapped Registers
@@ -160,12 +244,8 @@
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(push,1)
#endif /* defined(__MWERKS__) && ... */
-#define MEM_MAP_START
-#define FM_PORT_MAX_NUM_OF_EXT_POOLS_ALL_INTEGRATIONS 8
-#define FM_PORT_NUM_OF_CONGESTION_GRPS_ALL_INTEGRATIONS 256
-
-typedef _Packed struct
+typedef struct
{
volatile uint32_t fmbm_rcfg; /**< Rx Configuration */
volatile uint32_t fmbm_rst; /**< Rx Status */
@@ -182,7 +262,7 @@ typedef _Packed struct
volatile uint32_t fmbm_rpp; /**< Rx Policer Profile */
volatile uint32_t fmbm_rccb; /**< Rx Coarse Classification Base */
volatile uint32_t fmbm_reth; /**< Rx Excessive Threshold */
- volatile uint32_t reserved1[1]; /**< (0x03C 0x03F) */
+ volatile uint32_t reserved1[0x01];/**< (0x03C) */
volatile uint32_t fmbm_rprai[FM_PORT_PRS_RESULT_NUM_OF_WORDS];
/**< Rx Parse Results Array Initialization*/
volatile uint32_t fmbm_rfqid; /**< Rx Frame Queue ID*/
@@ -190,17 +270,19 @@ typedef _Packed struct
volatile uint32_t fmbm_rfsdm; /**< Rx Frame Status Discard Mask*/
volatile uint32_t fmbm_rfsem; /**< Rx Frame Status Error Mask*/
volatile uint32_t fmbm_rfene; /**< Rx Frame Enqueue Next Engine */
- volatile uint32_t reserved2[0x23];/**< (0x074 0x0FF) */
+ volatile uint32_t reserved2[0x02];/**< (0x074-0x078) */
+ volatile uint32_t fmbm_rcmne; /**< Rx Frame Continuous Mode Next Engine */
+ volatile uint32_t reserved3[0x20];/**< (0x080 0x0FF) */
volatile uint32_t fmbm_ebmpi[FM_PORT_MAX_NUM_OF_EXT_POOLS_ALL_INTEGRATIONS];
/**< Buffer Manager pool Information-*/
volatile uint32_t fmbm_acnt[FM_PORT_MAX_NUM_OF_EXT_POOLS_ALL_INTEGRATIONS];
/**< Allocate Counter-*/
- volatile uint32_t reserved3[8];
+ volatile uint32_t reserved4[0x08];
/**< 0x130/0x140 - 0x15F reserved -*/
- volatile uint32_t fmbm_cgm[FM_PORT_NUM_OF_CONGESTION_GRPS_ALL_INTEGRATIONS/32];
+ volatile uint32_t fmbm_rcgm[FM_PORT_MAX_NUM_OF_CONGESTION_GRPS_ALL_INTEGRATIONS/32];
/**< Congestion Group Map*/
- volatile uint32_t fmbm_mpd; /**< BM Pool Depletion */
- volatile uint32_t reserved4[0x1F];/**< (0x184 0x1FF) */
+ volatile uint32_t fmbm_rmpd; /**< BM Pool Depletion */
+ volatile uint32_t reserved5[0x1F];/**< (0x184 0x1FF) */
volatile uint32_t fmbm_rstc; /**< Rx Statistics Counters*/
volatile uint32_t fmbm_rfrc; /**< Rx Frame Counter*/
volatile uint32_t fmbm_rfbc; /**< Rx Bad Frames Counter*/
@@ -210,7 +292,8 @@ typedef _Packed struct
volatile uint32_t fmbm_rfldec; /**< Rx Frames List DMA Error Counter*/
volatile uint32_t fmbm_rodc; /**< Rx Out of Buffers Discard Counter-*/
volatile uint32_t fmbm_rbdc; /**< Rx Buffers Deallocate Counter-*/
- volatile uint32_t reserved5[0x17];/**< (0x224 0x27F) */
+ volatile uint32_t fmbm_rpec; /**< Rx RX Prepare to enqueue Counter-*/
+ volatile uint32_t reserved6[0x16];/**< (0x228 0x27F) */
volatile uint32_t fmbm_rpc; /**< Rx Performance Counters*/
volatile uint32_t fmbm_rpcp; /**< Rx Performance Count Parameters*/
volatile uint32_t fmbm_rccn; /**< Rx Cycle Counter*/
@@ -219,11 +302,13 @@ typedef _Packed struct
volatile uint32_t fmbm_rduc; /**< Rx DMA Utilization Counter*/
volatile uint32_t fmbm_rfuc; /**< Rx FIFO Utilization Counter*/
volatile uint32_t fmbm_rpac; /**< Rx Pause Activation Counter*/
- volatile uint32_t reserved6[0x18];/**< (0x2A0 0x2FF) */
- volatile uint32_t fmbm_rdbg; /**< Rx Debug-*/
-} _PackedType t_FmPortRxBmiRegs;
+ volatile uint32_t reserved7[0x18];/**< (0x2A0-0x2FF) */
+ volatile uint32_t fmbm_rdcfg[0x3];/**< Rx Debug-*/
+ volatile uint32_t fmbm_rgpr; /**< Rx General Purpose Register. */
+ volatile uint32_t reserved8[0x3a];/**< (0x310-0x3FF) */
+} t_FmPortRxBmiRegs;
-typedef _Packed struct
+typedef struct
{
volatile uint32_t fmbm_tcfg; /**< Tx Configuration */
volatile uint32_t fmbm_tst; /**< Tx Status */
@@ -231,21 +316,26 @@ typedef _Packed struct
volatile uint32_t fmbm_tfp; /**< Tx FIFO Parameters */
volatile uint32_t fmbm_tfed; /**< Tx Frame End Data */
volatile uint32_t fmbm_ticp; /**< Tx Internal Context Parameters */
- volatile uint32_t fmbm_tfne; /**< Tx Frame Next Engine. */
+ volatile uint32_t fmbm_tfdne; /**< Tx Frame Dequeue Next Engine. */
volatile uint32_t fmbm_tfca; /**< Tx Frame Command attribute. */
volatile uint32_t fmbm_tcfqid; /**< Tx Confirmation Frame Queue ID. */
volatile uint32_t fmbm_tfeqid; /**< Tx Frame Error Queue ID */
volatile uint32_t fmbm_tfene; /**< Tx Frame Enqueue Next Engine */
volatile uint32_t fmbm_trlmts; /**< Tx Rate Limiter Scale */
volatile uint32_t fmbm_trlmt; /**< Tx Rate Limiter */
- volatile uint32_t reserved0[0x73];/**< (0x038-0x200) */
+ volatile uint32_t fmbm_tccb; /**< Tx Coarse Classification Base */
+ volatile uint32_t reserved0[0x0e];/**< (0x038-0x070) */
+ volatile uint32_t fmbm_tfne; /**< Tx Frame Next Engine */
+ volatile uint32_t fmbm_tpfcm[0x02];/**< Tx Priority based Flow Control (PFC) Mapping */
+ volatile uint32_t fmbm_tcmne; /**< Tx Frame Continuous Mode Next Engine */
+ volatile uint32_t reserved2[0x60];/**< (0x080-0x200) */
volatile uint32_t fmbm_tstc; /**< Tx Statistics Counters */
volatile uint32_t fmbm_tfrc; /**< Tx Frame Counter */
volatile uint32_t fmbm_tfdc; /**< Tx Frames Discard Counter */
volatile uint32_t fmbm_tfledc; /**< Tx Frame Length error discard counter */
volatile uint32_t fmbm_tfufdc; /**< Tx Frame unsupported format discard Counter */
volatile uint32_t fmbm_tbdc; /**< Tx Buffers Deallocate Counter */
- volatile uint32_t reserved1[0x1A];/**< (0x218-0x280) */
+ volatile uint32_t reserved3[0x1A];/**< (0x218-0x280) */
volatile uint32_t fmbm_tpc; /**< Tx Performance Counters*/
volatile uint32_t fmbm_tpcp; /**< Tx Performance Count Parameters*/
volatile uint32_t fmbm_tccn; /**< Tx Cycle Counter*/
@@ -253,9 +343,13 @@ typedef _Packed struct
volatile uint32_t fmbm_ttcquc; /**< Tx Transmit Confirm Queue Utilization Counter*/
volatile uint32_t fmbm_tduc; /**< Tx DMA Utilization Counter*/
volatile uint32_t fmbm_tfuc; /**< Tx FIFO Utilization Counter*/
-} _PackedType t_FmPortTxBmiRegs;
+ volatile uint32_t reserved4[16]; /**< (0x29C-0x2FF) */
+ volatile uint32_t fmbm_tdcfg[0x3];/**< Tx Debug-*/
+ volatile uint32_t fmbm_tgpr; /**< O/H General Purpose Register */
+ volatile uint32_t reserved5[0x3a];/**< (0x310-0x3FF) */
+} t_FmPortTxBmiRegs;
-typedef _Packed struct
+typedef struct
{
volatile uint32_t fmbm_ocfg; /**< O/H Configuration */
volatile uint32_t fmbm_ost; /**< O/H Status */
@@ -269,7 +363,9 @@ typedef _Packed struct
volatile uint32_t fmbm_opp; /**< O/H Policer Profile */
volatile uint32_t fmbm_occb; /**< O/H Coarse Classification base */
volatile uint32_t fmbm_oim; /**< O/H Internal margins*/
- volatile uint32_t reserved0[4]; /**< (0x030 - 0x03F) */
+ volatile uint32_t fmbm_ofp; /**< O/H Fifo Parameters*/
+ volatile uint32_t fmbm_ofed; /**< O/H Frame End Data*/
+ volatile uint32_t reserved0[2]; /**< (0x038 - 0x03F) */
volatile uint32_t fmbm_oprai[FM_PORT_PRS_RESULT_NUM_OF_WORDS];
/**< O/H Parse Results Array Initialization */
volatile uint32_t fmbm_ofqid; /**< O/H Frame Queue ID */
@@ -279,19 +375,14 @@ typedef _Packed struct
volatile uint32_t fmbm_ofene; /**< O/H Frame Enqueue Next Engine */
volatile uint32_t fmbm_orlmts; /**< O/H Rate Limiter Scale */
volatile uint32_t fmbm_orlmt; /**< O/H Rate Limiter */
- volatile uint32_t reserved0a[0x21];
- /**< 0x07C - 0x0FF Reserved */
- union
- {
- volatile uint32_t fmbm_oebmpi[FM_PORT_MAX_NUM_OF_OBSERVED_EXT_POOLS];
- /**< Buffer Manager Observed Pool Information */
- volatile uint32_t reserved0b[0x18];
- }; /**< 0x100 - 0x15F Reserved */
+ volatile uint32_t fmbm_ocmne; /**< O/H Continuous Mode Next Engine */
+ volatile uint32_t reserved1[0x20];/**< (0x080 - 0x0FF) */
+ volatile uint32_t fmbm_oebmpi[2]; /**< Buffer Manager Observed Pool Information */
+ volatile uint32_t reserved2[0x16];/**< (0x108 - 0x15F) */
volatile uint32_t fmbm_ocgm; /**< Observed Congestion Group Map */
- volatile uint32_t reserved0c[0x7];/**< 0x164 - 0x17F Reserved */
+ volatile uint32_t reserved3[0x7]; /**< (0x164 - 0x17F) */
volatile uint32_t fmbm_ompd; /**< Observed BMan Pool Depletion */
- volatile uint32_t reserved0d[0x1F];
- /**< 0x184 - 0x1FF Reserved */
+ volatile uint32_t reserved4[0x1F];/**< (0x184 - 0x1FF) */
volatile uint32_t fmbm_ostc; /**< O/H Statistics Counters */
volatile uint32_t fmbm_ofrc; /**< O/H Frame Counter */
volatile uint32_t fmbm_ofdc; /**< O/H Frames Discard Counter */
@@ -301,23 +392,29 @@ typedef _Packed struct
volatile uint32_t fmbm_ofwdc; /**< - Rx Frames WRED Discard Counter */
volatile uint32_t fmbm_ofldec; /**< O/H Frames List DMA Error Counter */
volatile uint32_t fmbm_obdc; /**< O/H Buffers Deallocate Counter */
- volatile uint32_t reserved2[0x17];/**< (0x218 - 0x27F) */
+ volatile uint32_t fmbm_oodc; /**< O/H Out of Buffers Discard Counter */
+ volatile uint32_t fmbm_opec; /**< O/H Prepare to enqueue Counter */
+ volatile uint32_t reserved5[0x15];/**< ( - 0x27F) */
volatile uint32_t fmbm_opc; /**< O/H Performance Counters */
volatile uint32_t fmbm_opcp; /**< O/H Performance Count Parameters */
volatile uint32_t fmbm_occn; /**< O/H Cycle Counter */
volatile uint32_t fmbm_otuc; /**< O/H Tasks Utilization Counter */
volatile uint32_t fmbm_oduc; /**< O/H DMA Utilization Counter */
volatile uint32_t fmbm_ofuc; /**< O/H FIFO Utilization Counter */
-} _PackedType t_FmPortOhBmiRegs;
+ volatile uint32_t reserved6[26]; /**< (0x298-0x2FF) */
+ volatile uint32_t fmbm_odcfg[0x3];/**< O/H Debug (only 1 in P1023) */
+ volatile uint32_t fmbm_ogpr; /**< O/H General Purpose Register. */
+ volatile uint32_t reserved7[0x3a];/**< (0x310 0x3FF) */
+} t_FmPortOhBmiRegs;
-typedef _Packed union
+typedef union
{
t_FmPortRxBmiRegs rxPortBmiRegs;
t_FmPortTxBmiRegs txPortBmiRegs;
t_FmPortOhBmiRegs ohPortBmiRegs;
-} _PackedType u_FmPortBmiRegs;
+} u_FmPortBmiRegs;
-typedef _Packed struct
+typedef struct
{
volatile uint32_t reserved1[2]; /**< 0xn024 - 0x02B */
volatile uint32_t fmqm_pndn; /**< PortID n Dequeue NIA Register */
@@ -325,9 +422,9 @@ typedef _Packed struct
volatile uint32_t fmqm_pndtfc; /**< PortID n Dequeue Total Frame Counter */
volatile uint32_t fmqm_pndfdc; /**< PortID n Dequeue FQID from Default Counter */
volatile uint32_t fmqm_pndcc; /**< PortID n Dequeue Confirm Counter */
-} _PackedType t_FmPortNonRxQmiRegs;
+} t_FmPortNonRxQmiRegs;
-typedef _Packed struct
+typedef struct
{
volatile uint32_t fmqm_pnc; /**< PortID n Configuration Register */
volatile uint32_t fmqm_pns; /**< PortID n Status Register */
@@ -335,20 +432,20 @@ typedef _Packed struct
volatile uint32_t reserved0[4]; /**< 0xn00C - 0xn01B */
volatile uint32_t fmqm_pnen; /**< PortID n Enqueue NIA Register */
volatile uint32_t fmqm_pnetfc; /**< PortID n Enqueue Total Frame Counter */
- t_FmPortNonRxQmiRegs nonRxQmiRegs; /**< Registers for Tx Hc & Op ports */
-} _PackedType t_FmPortQmiRegs;
+ t_FmPortNonRxQmiRegs nonRxQmiRegs; /**< Registers for Tx Hc & Op ports */
+} t_FmPortQmiRegs;
-typedef _Packed struct
+typedef struct
{
- _Packed struct
+ struct
{
volatile uint32_t softSeqAttach; /**< Soft Sequence Attachment */
volatile uint32_t lcv; /**< Line-up Enable Confirmation Mask */
- } _PackedType hdrs[FM_PCD_PRS_NUM_OF_HDRS];
- volatile uint8_t reserved0[0x378];
+ } hdrs[FM_PCD_PRS_NUM_OF_HDRS];
+ volatile uint32_t reserved0[0xde];
volatile uint32_t pcac; /**< Parse Internal Memory Configuration Access Control Register */
volatile uint32_t pctpid; /**< Parse Internal Memory Configured TPID Register */
-} _PackedType t_FmPortPrsRegs;
+} t_FmPortPrsRegs;
/**************************************************************************//*
@Description Basic buffer descriptor (BD) structure
@@ -386,7 +483,6 @@ typedef _Packed struct
volatile uint8_t reserved1[0xa0]; /**< 0x60 - 0xff */
} _PackedType t_FmPortImPram;
-#define MEM_MAP_END
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(pop)
#endif /* defined(__MWERKS__) && ... */
@@ -399,36 +495,41 @@ typedef _Packed struct
/**************************************************************************//**
@Description BMI defines
*//***************************************************************************/
+#if (DPAA_VERSION >= 11)
+#define BMI_SP_ID_MASK 0xff000000
+#define BMI_SP_ID_SHIFT 24
+#define BMI_SP_EN 0x01000000
+#endif /* (DPAA_VERSION >= 11) */
+
#define BMI_PORT_CFG_EN 0x80000000
#define BMI_PORT_CFG_EN_MACSEC 0x00800000
#define BMI_PORT_CFG_FDOVR 0x02000000
#define BMI_PORT_CFG_IM 0x01000000
+#define BMI_PORT_CFG_AM 0x00000040
#define BMI_PORT_STATUS_BSY 0x80000000
#define BMI_COUNTERS_EN 0x80000000
-#define BMI_DMA_ATTR_WRITE_OPTIMIZE 0x00100000
+
#define BMI_PORT_RFNE_FRWD_DCL4C 0x10000000
#define BMI_PORT_RFNE_FRWD_RPD 0x40000000
#define BMI_RFNE_FDCS_MASK 0xFF000000
+#define BMI_RFNE_HXS_MASK 0x000000FF
#define BMI_CMD_MR_LEAC 0x00200000
#define BMI_CMD_MR_SLEAC 0x00100000
#define BMI_CMD_MR_MA 0x00080000
#define BMI_CMD_MR_DEAS 0x00040000
-#define BMI_CMD_TX_MR_DEF (0)
#define BMI_CMD_RX_MR_DEF (BMI_CMD_MR_LEAC | \
BMI_CMD_MR_SLEAC | \
BMI_CMD_MR_MA | \
BMI_CMD_MR_DEAS)
#define BMI_CMD_ATTR_ORDER 0x80000000
#define BMI_CMD_ATTR_SYNC 0x02000000
+#define BMI_CMD_ATTR_MODE_MISS_ALLIGN_ADDR_EN 0x00080000
#define BMI_CMD_ATTR_MACCMD_MASK 0x0000ff00
#define BMI_CMD_ATTR_MACCMD_OVERRIDE 0x00008000
#define BMI_CMD_ATTR_MACCMD_SECURED 0x00001000
#define BMI_CMD_ATTR_MACCMD_SC_MASK 0x00000f00
-#define BMI_EXT_BUF_POOL_VALID 0x80000000
-#define BMI_EXT_BUF_POOL_EN_COUNTER 0x40000000
-#define BMI_EXT_BUF_POOL_BACKUP 0x20000000
#define BMI_EXT_BUF_POOL_ID_MASK 0x003F0000
#define BMI_STATUS_RX_MASK_UNUSED (uint32_t)(~(FM_PORT_FRM_ERR_DMA | \
FM_PORT_FRM_ERR_PHYSICAL | \
@@ -444,11 +545,13 @@ typedef _Packed struct
FM_PORT_FRM_ERR_PRS_ILL_INSTRUCT | \
FM_PORT_FRM_ERR_BLOCK_LIMIT_EXCEEDED | \
FM_PORT_FRM_ERR_PRS_HDR_ERR | \
- FM_PORT_FRM_ERR_PROCESS_TIMEOUT | \
+ FM_PORT_FRM_ERR_IPRE | \
+ FM_PORT_FRM_ERR_IPR_NCSP | \
FM_PORT_FRM_ERR_KEYSIZE_OVERFLOW))
#define BMI_STATUS_OP_MASK_UNUSED (uint32_t)(BMI_STATUS_RX_MASK_UNUSED & \
~(FM_PORT_FRM_ERR_LENGTH | \
+ FM_PORT_FRM_ERR_NON_FM | \
FM_PORT_FRM_ERR_UNSUPPORTED_FORMAT))
#define BMI_RATE_LIMIT_EN 0x80000000
@@ -462,6 +565,7 @@ typedef _Packed struct
#define BMI_PRS_RESULT_HIGH 0x00000000
#define BMI_PRS_RESULT_LOW 0xFFFFFFFF
+
#define RX_ERRS_TO_ENQ (FM_PORT_FRM_ERR_DMA | \
FM_PORT_FRM_ERR_PHYSICAL | \
FM_PORT_FRM_ERR_SIZE | \
@@ -473,27 +577,26 @@ typedef _Packed struct
FM_PORT_FRM_ERR_PRS_ILL_INSTRUCT | \
FM_PORT_FRM_ERR_BLOCK_LIMIT_EXCEEDED | \
FM_PORT_FRM_ERR_PRS_HDR_ERR | \
- FM_PORT_FRM_ERR_PROCESS_TIMEOUT | \
- FM_PORT_FRM_ERR_KEYSIZE_OVERFLOW)
+ FM_PORT_FRM_ERR_KEYSIZE_OVERFLOW | \
+ FM_PORT_FRM_ERR_IPRE)
-#ifdef FM_CAPWAP_SUPPORT
#define OP_ERRS_TO_ENQ (RX_ERRS_TO_ENQ | \
FM_PORT_FRM_ERR_LENGTH | \
FM_PORT_FRM_ERR_NON_FM | \
FM_PORT_FRM_ERR_UNSUPPORTED_FORMAT)
-#else
-#define OP_ERRS_TO_ENQ (RX_ERRS_TO_ENQ | \
- FM_PORT_FRM_ERR_LENGTH | \
- FM_PORT_FRM_ERR_UNSUPPORTED_FORMAT)
-#endif /* FM_CAPWAP_SUPPORT */
+
+#define BMI_RX_FIFO_PRI_ELEVATION_MASK 0x03FF0000
+#define BMI_RX_FIFO_THRESHOLD_MASK 0x000003FF
+#define BMI_TX_FIFO_MIN_FILL_MASK 0x03FF0000
+#define BMI_FIFO_PIPELINE_DEPTH_MASK 0x0000F000
+#define BMI_TX_LOW_COMF_MASK 0x000003FF
/* shifts */
#define BMI_PORT_CFG_MS_SEL_SHIFT 16
-#define BMI_DMA_ATTR_SWP_SHIFT 30
-#define BMI_DMA_ATTR_IC_CACHE_SHIFT 28
-#define BMI_DMA_ATTR_HDR_CACHE_SHIFT 26
-#define BMI_DMA_ATTR_SG_CACHE_SHIFT 24
+#define BMI_DMA_ATTR_IC_CACHE_SHIFT FMAN_SP_DMA_ATTR_IC_CACHE_SHIFT
+#define BMI_DMA_ATTR_HDR_CACHE_SHIFT FMAN_SP_DMA_ATTR_HDR_CACHE_SHIFT
+#define BMI_DMA_ATTR_SG_CACHE_SHIFT FMAN_SP_DMA_ATTR_SG_CACHE_SHIFT
#define BMI_IM_FOF_SHIFT 28
#define BMI_PR_PORTID_SHIFT 24
@@ -504,14 +607,11 @@ typedef _Packed struct
#define BMI_RX_FRAME_END_CS_IGNORE_SHIFT 24
#define BMI_RX_FRAME_END_CUT_SHIFT 16
-#define BMI_IC_TO_EXT_SHIFT 16
-#define BMI_IC_FROM_INT_SHIFT 8
-#define BMI_IC_SIZE_SHIFT 0
+#define BMI_IC_SIZE_SHIFT FMAN_SP_IC_SIZE_SHIFT
#define BMI_INT_BUF_MARG_SHIFT 28
-#define BMI_EXT_BUF_MARG_START_SHIFT 16
-#define BMI_EXT_BUF_MARG_END_SHIFT 0
+#define BMI_EXT_BUF_MARG_END_SHIFT FMAN_SP_EXT_BUF_MARG_END_SHIFT
#define BMI_CMD_ATTR_COLOR_SHIFT 26
#define BMI_CMD_ATTR_COM_MODE_SHIFT 16
@@ -520,17 +620,11 @@ typedef _Packed struct
#define BMI_CMD_ATTR_MACCMD_SECURED_SHIFT 12
#define BMI_CMD_ATTR_MACCMD_SC_SHIFT 8
-#define BMI_POOL_DEP_NUM_OF_POOLS_SHIFT 16
#define BMI_POOL_DEP_NUM_OF_POOLS_VECTOR_SHIFT 24
-#define BMI_EXT_BUF_POOL_ID_SHIFT 16
-
#define BMI_TX_FIFO_MIN_FILL_SHIFT 16
-#define BMI_TX_FIFO_PIPELINE_DEPTH_SHIFT 12
#define BMI_TX_LOW_COMF_SHIFT 0
-#define BMI_TX_FRAME_END_CS_IGNORE_SHIFT 24
-
#define BMI_PERFORMANCE_TASK_COMP_SHIFT 24
#define BMI_PERFORMANCE_PORT_COMP_SHIFT 16
#define BMI_PERFORMANCE_DMA_COMP_SHIFT 12
@@ -541,13 +635,8 @@ typedef _Packed struct
/* sizes */
#define FRAME_END_DATA_SIZE 16
-#define OFFSET_UNITS 16
#define FRAME_OFFSET_UNITS 16
-#define MAX_EXT_OFFSET 496
-#define MAX_EXT_BUFFER_OFFSET 511
-#define MAX_INT_OFFSET 240
#define MIN_TX_INT_OFFSET 16
-#define MAX_IC_SIZE 256
#define MAX_FRAME_OFFSET 64
#define MAX_FIFO_PIPELINE_DEPTH 8
#define MAX_PERFORMANCE_TASK_COMP 64
@@ -559,7 +648,8 @@ typedef _Packed struct
#define MAX_NUM_OF_DMAS 16
#define MAX_NUM_OF_EXTRA_DMAS 8
#define MAX_BURST_SIZE 1024
-#define FRAG_EXTRA_SPACE 32
+#define MIN_NUM_OF_OP_DMAS 2
+
/**************************************************************************//**
@Description QMI defines
@@ -595,7 +685,7 @@ typedef _Packed struct
#define PRS_TPID_DFLT 0x91009100
#define PRS_HDR_MPLS_LBL_INTER_EN 0x00200000
-#define PRS_HDR_IPV6_ROUTE_HDR_DIS 0x00008000
+#define PRS_HDR_IPV6_ROUTE_HDR_EN 0x00008000
#define PRS_HDR_PPPOE_MTU_CHECK_EN 0x80000000
#define PRS_HDR_UDP_PAD_REMOVAL 0x80000000
#define PRS_HDR_TCP_PAD_REMOVAL 0x80000000
@@ -637,10 +727,6 @@ typedef _Packed struct
#define SCTP_SW_PATCH_START 0x4D
#define DCCP_SW_PATCH_START 0x41
-#define IP_FRAG_SW_PATCH_IPv4 0x300
-#define IP_FRAG_SW_PATCH_IPv6_0 0x320
-#define IP_FRAG_SW_PATCH_IPv6_1 0x372
-
/**************************************************************************//**
@Description IM defines
*//***************************************************************************/
@@ -653,7 +739,6 @@ typedef _Packed struct
#define BD_RX_OV 0x00010000
#define BD_RX_ERRORS (BD_RX_CRE | BD_RX_FTL | BD_RX_FTS | BD_RX_OV)
-#define BD_ERROR_PASS_FRAME BD_RX_ERRORS
#define FM_IM_SIZEOF_BD sizeof(t_FmImBd)
@@ -686,6 +771,11 @@ typedef _Packed struct
#define IM_EV_BSY 0x40000000
#define IM_EV_RX 0x80000000
+
+/**************************************************************************//**
+ @Description Additional defines
+*//***************************************************************************/
+
typedef struct {
t_Handle h_FmMuram;
t_FmPortImPram *p_FmPortImPram;
@@ -710,41 +800,9 @@ typedef struct {
t_FmPortImTxConfCallback *f_TxConf;
} t_FmMacIm;
-/**************************************************************************//**
- @Description structure for defining internal context copying
-*//***************************************************************************/
-typedef struct
-{
- uint16_t extBufOffset; /**< Offset in External buffer to which internal
- context is copied to (Rx) or taken from (Tx, Op). */
- uint8_t intContextOffset; /**< Offset within internal context to copy from
- (Rx) or to copy to (Tx, Op). */
- uint16_t size; /**< Internal offset size to be copied */
-} t_FmPortIntContextDataCopy;
-
-/**************************************************************************//**
- @Description struct for defining external buffer margins
-*//***************************************************************************/
-typedef struct {
- uint16_t startMargins; /**< Number of bytes to be left at the beginning
- of the external buffer (must be divisible by 16) */
- uint16_t endMargins; /**< number of bytes to be left at the end
- of the external buffer(must be divisible by 16) */
-} t_FmPortBufMargins;
-
-typedef struct {
- uint32_t dataOffset;
- uint32_t prsResultOffset;
- uint32_t timeStampOffset;
- uint32_t hashResultOffset;
- uint32_t pcdInfoOffset;
- uint32_t manipOffset;
-#ifdef DEBUG
- uint32_t debugOffset;
-#endif /* DEBUG */
-} t_FmPortBufferOffsets;
typedef struct {
+ struct fman_port_cfg dfltCfg;
uint32_t dfltFqid;
uint32_t confFqid;
uint32_t errFqid;
@@ -752,13 +810,11 @@ typedef struct {
uint8_t deqSubPortal;
bool deqHighPriority;
e_FmPortDeqType deqType;
-#ifdef FM_QMI_DEQ_OPTIONS_SUPPORT
e_FmPortDeqPrefetchOption deqPrefetchOption;
-#endif /* FM_QMI_DEQ_OPTIONS_SUPPORT */
uint16_t deqByteCnt;
uint8_t cheksumLastBytesIgnore;
uint8_t cutBytesFromEnd;
- t_FmPortBufPoolDepletion bufPoolDepletion;
+ t_FmBufPoolDepletion bufPoolDepletion;
uint8_t pipelineDepth;
uint16_t fifoLowComfLevel;
bool frmDiscardOverride;
@@ -768,34 +824,63 @@ typedef struct {
bool enBufPoolDepletion;
uint16_t liodnOffset;
uint16_t liodnBase;
- t_FmPortExtPools extBufPools;
- e_FmPortDmaSwap dmaSwapData;
- e_FmPortDmaCache dmaIntContextCacheAttr;
- e_FmPortDmaCache dmaHeaderCacheAttr;
- e_FmPortDmaCache dmaScatterGatherCacheAttr;
+ t_FmExtPools extBufPools;
+ e_FmDmaSwapOption dmaSwapData;
+ e_FmDmaCacheOption dmaIntContextCacheAttr;
+ e_FmDmaCacheOption dmaHeaderCacheAttr;
+ e_FmDmaCacheOption dmaScatterGatherCacheAttr;
bool dmaReadOptimize;
bool dmaWriteOptimize;
uint32_t txFifoMinFillLevel;
uint32_t txFifoLowComfLevel;
uint32_t rxFifoPriElevationLevel;
uint32_t rxFifoThreshold;
- t_FmPortBufMargins bufMargins;
- t_FmPortIntContextDataCopy intContext;
+ t_FmSpBufMargins bufMargins;
+ t_FmSpIntContextDataCopy intContext;
bool syncReq;
e_FmPortColor color;
fmPortFrameErrSelect_t errorsToDiscard;
fmPortFrameErrSelect_t errorsToEnq;
- uint64_t fmMuramPhysBaseAddr;
bool forwardReuseIntContext;
- t_FmPortBufferPrefixContent bufferPrefixContent;
- uint8_t internalBufferOffset;
- t_FmPortBackupBmPools *p_BackupBmPools;
+ t_FmBufferPrefixContent bufferPrefixContent;
+ t_FmBackupBmPools *p_BackupBmPools;
bool dontReleaseBuf;
+ bool setNumOfTasks;
+ bool setNumOfOpenDmas;
+ bool setSizeOfFifo;
+#if (DPAA_VERSION >= 11)
+ bool noScatherGather;
+#endif /* (DPAA_VERSION >= 11) */
+
+#ifdef FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669
+ bool bcbWorkaround;
+#endif /* FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669 */
} t_FmPortDriverParam;
+
+typedef struct t_FmPortRxPoolsParams
+{
+ uint8_t numOfPools;
+ uint16_t secondLargestBufSize;
+ uint16_t largestBufSize;
+} t_FmPortRxPoolsParams;
+
+typedef struct t_FmPortDsarVars {
+ t_Handle *autoResOffsets;
+ t_FmPortDsarTablesSizes *autoResMaxSizes;
+ uint32_t fmbm_tcfg;
+ uint32_t fmbm_tcmne;
+ uint32_t fmbm_rfne;
+ uint32_t fmbm_rfpne;
+ uint32_t fmbm_rcfg;
+ bool dsarEnabledParser;
+} t_FmPortDsarVars;
typedef struct {
+ struct fman_port port;
t_Handle h_Fm;
t_Handle h_FmPcd;
+ t_Handle h_FmMuram;
+ t_FmRevisionInfo fmRevInfo;
uint8_t portId;
e_FmPortType portType;
int enabled;
@@ -817,11 +902,10 @@ typedef struct {
t_Handle ccTreeId;
t_Handle completeArg;
void (*f_Complete)(t_Handle arg);
- t_FmPortBufferOffsets bufferOffsets;
+ t_FmSpBufferOffsets bufferOffsets;
/* Independent-Mode parameters support */
bool imEn;
t_FmMacIm im;
- uint8_t txFifoDeqPipelineDepth;
volatile bool lock;
t_Handle h_Spinlock;
t_FmPortExceptionCallback *f_Exception;
@@ -830,23 +914,38 @@ typedef struct {
uint8_t fmanCtrlEventId;
uint32_t exceptions;
bool polling;
- uint8_t numOfTasks;
- t_FmPortExtPools extBufPools;
+ t_FmExtPools extBufPools;
uint32_t requiredAction;
uint32_t savedQmiPnen;
+ uint32_t savedBmiFene;
+ uint32_t savedBmiFpne;
+ uint32_t savedBmiCmne;
+ uint32_t savedBmiOfp;
uint32_t savedNonRxQmiRegsPndn;
+ uint32_t origNonRxQmiRegsPndn;
int savedPrsStartOffset;
+ bool includeInPrsStatistics;
+ uint16_t maxFrameLength;
+ t_FmFmanCtrl orFmanCtrl;
t_FmPortRsrc openDmas;
t_FmPortRsrc tasks;
t_FmPortRsrc fifoBufs;
- t_FmInterModulePortRxPoolsParams rxPoolsParams;
+ t_FmPortRxPoolsParams rxPoolsParams;
+// bool explicitUserSizeOfFifo;
+ t_Handle h_IpReassemblyManip;
+ t_Handle h_CapwapReassemblyManip;
+ t_Handle h_ReassemblyTree;
+ uint64_t fmMuramPhysBaseAddr;
+#if (DPAA_VERSION >= 11)
+ bool vspe;
+ uint8_t dfltRelativeId;
+ e_FmPortGprFuncType gprFunc;
+ t_FmPcdCtrlParamsPage *p_ParamsPage;
+#endif /* (DPAA_VERSION >= 11) */
+ t_FmPortDsarVars deepSleepVars;
t_FmPortDriverParam *p_FmPortDriverParam;
} t_FmPort;
-#define CHECK_FM_CTL_AC_POST_FETCH_PCD(savedBmiNia) \
- ((((savedBmiNia) & NIA_ENG_MASK) == NIA_ENG_FM_CTL) && \
- ((((savedBmiNia) & NIA_FM_CTL_AC_MASK) == NIA_FM_CTL_AC_POST_FETCH_PCD) || \
- (((savedBmiNia) & NIA_FM_CTL_AC_MASK) == NIA_FM_CTL_AC_POST_FETCH_PCD_UDP_LEN)))
void FmPortConfigIM (t_FmPort *p_FmPort, t_FmPortParams *p_FmPortParams);
t_Error FmPortImCheckInitParameters(t_FmPort *p_FmPort);
@@ -862,6 +961,10 @@ void FmPortSetMacsecLcv(t_Handle h_FmPort);
void FmPortSetMacsecCmd(t_Handle h_FmPort, uint8_t dfltSci);
+t_Error FM_PORT_SetNumOfOpenDmas(t_Handle h_FmPort, t_FmPortRsrc *p_NumOfOpenDmas);
+t_Error FM_PORT_SetNumOfTasks(t_Handle h_FmPort, t_FmPortRsrc *p_NumOfTasks);
+t_Error FM_PORT_SetSizeOfFifo(t_Handle h_FmPort, t_FmPortRsrc *p_SizeOfFifo);
+
static __inline__ uint8_t * BdBufferGet (t_PhysToVirt *f_PhysToVirt, t_FmImBd *p_Bd)
{
uint64_t physAddr = (uint64_t)((uint64_t)GET_UINT8(p_Bd->buff.high) << 32);
@@ -890,5 +993,7 @@ static __inline__ uint16_t GetNextBdId(t_FmPort *p_FmPort, uint16_t id)
return 0;
}
+void FM_PORT_Dsar_DumpRegs(void);
+
#endif /* __FM_PORT_H */
diff --git a/sys/contrib/ncsw/Peripherals/FM/Port/fm_port_dsar.h b/sys/contrib/ncsw/Peripherals/FM/Port/fm_port_dsar.h
new file mode 100755
index 000000000000..95619eff0bee
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/Port/fm_port_dsar.h
@@ -0,0 +1,494 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**************************************************************************//**
+ @File fm_port_dsar.h
+
+ @Description Deep Sleep Auto Response project - common module header file.
+
+ Author - Eyal Harari
+
+ @Cautions See the FMan Controller spec and design document for more information.
+*//***************************************************************************/
+
+#ifndef __FM_PORT_DSAR_H_
+#define __FM_PORT_DSAR_H_
+
+#define DSAR_GETSER_MASK 0xFF0000FF
+
+#if defined(__MWERKS__) && !defined(__GNUC__)
+#pragma pack(push,1)
+#endif /* defined(__MWERKS__) && ... */
+
+/**************************************************************************//**
+ @Description Deep Sleep Auto Response VLAN-IPv4 Binding Table (for ARP/ICMPv4)
+ Refer to the FMan Controller spec for more details.
+*//***************************************************************************/
+typedef _Packed struct
+{
+ uint32_t ipv4Addr; /*!< 32 bit IPv4 Address. */
+ uint16_t vlanId; /*!< 12 bits VLAN ID. The 4 left-most bits should be cleared */
+ /*!< This field should be 0x0000 for an entry with no VLAN tag or a null VLAN ID. */
+ uint16_t reserved;
+} _PackedType t_DsarArpBindingEntry;
+
+/**************************************************************************//**
+ @Description Deep Sleep Auto Response Address Resolution Protocol Statistics Descriptor
+ Refer to the FMan Controller spec for more details.
+ 0x00 INVAL_CNT Invalid ARP IPv4-Ethernet counter
+ 0x04 ECHO_CNT Echo counter
+ 0x08 CD_CNT Conflict Detection counter
+ 0x0C AR_CNT Auto-Response counter
+ 0x10 RATM_CNT Replies Addressed To Me counter
+ 0x14 UKOP_CNT Unknown Operation counter
+ 0x18 NMTP_CNT Not my TPA counter
+ 0x1C NMVLAN_CNT Not My VLAN counter
+*//***************************************************************************/
+typedef _Packed struct
+{
+ uint32_t invalCnt; /**< Invalid ARP IPv4-Ethernet counter. */
+ uint32_t echoCnt; /**< Echo counter. */
+ uint32_t cdCnt; /**< Conflict Detection counter. */
+ uint32_t arCnt; /**< Auto-Response counter. */
+ uint32_t ratmCnt; /**< Replies Addressed To Me counter. */
+ uint32_t ukopCnt; /**< Unknown Operation counter. */
+ uint32_t nmtpCnt; /**< Not my TPA counter. */
+ uint32_t nmVlanCnt; /**< Not My VLAN counter */
+} _PackedType t_DsarArpStatistics;
+
+
+/**************************************************************************//**
+ @Description Deep Sleep Auto Response Address Resolution Protocol Descriptor
+ 0x0 0-15 Control bits [0-15]. Bit 15 = CDEN.
+ 0x2 0-15 NumOfBindings Number of entries in the binding list.
+ 0x4 0-15 BindingsPointer Bindings Pointer. This points to an IPv4-MAC Addresses Bindings list.
+ 0x6 0-15
+ 0x8 0-15 StatisticsPointer Statistics Pointer. This field points to the ARP Descriptors statistics data structure.
+ 0xA 0-15
+ 0xC 0-15 Reserved Reserved. Must be cleared.
+ 0xE 015
+
+*//***************************************************************************/
+typedef _Packed struct
+{
+ uint16_t control; /** Control bits [0-15]. Bit 15 = CDEN */
+ uint16_t numOfBindings; /**< Number of VLAN-IPv4 */
+ uint32_t p_Bindings; /**< VLAN-IPv4 Bindings table pointer. */
+ uint32_t p_Statistics; /**< Statistics Data Structure pointer. */
+ uint32_t reserved1; /**< Reserved. */
+} _PackedType t_DsarArpDescriptor;
+
+
+/**************************************************************************//**
+ @Description Deep Sleep Auto Response VLAN-IPv4 Binding Table (for ARP/ICMPv4)
+ Refer to the FMan Controller spec for more details.
+*//***************************************************************************/
+typedef _Packed struct
+{
+ uint32_t ipv4Addr; /*!< 32 bit IPv4 Address. */
+ uint16_t vlanId; /*!< 12 bits VLAN ID. The 4 left-most bits should be cleared */
+ /*!< This field should be 0x0000 for an entry with no VLAN tag or a null VLAN ID. */
+ uint16_t reserved;
+} _PackedType t_DsarIcmpV4BindingEntry;
+
+/**************************************************************************//**
+ @Description Deep Sleep Auto Response ICMPv4 Statistics Descriptor
+ Refer to the FMan Controller spec for more details.
+ 0x00 INVAL_CNT Invalid ICMPv4 header counter
+ 0x04 NMVLAN_CNT Not My VLAN counter
+ 0x08 NMIP_CNT Not My IP counter
+ 0x0C AR_CNT Auto-Response counter
+ 0x10 CSERR_CNT Checksum Error counter
+ 0x14 Reserved Reserved
+ 0x18 Reserved Reserved
+ 0x1C Reserved Reserved
+
+*//***************************************************************************/
+typedef _Packed struct
+{
+ uint32_t invalCnt; /**< Invalid ICMPv4 Echo counter. */
+ uint32_t nmVlanCnt; /**< Not My VLAN counter */
+ uint32_t nmIpCnt; /**< Not My IP counter */
+ uint32_t arCnt; /**< Auto-Response counter */
+ uint32_t cserrCnt; /**< Checksum Error counter */
+ uint32_t reserved0; /**< Reserved */
+ uint32_t reserved1; /**< Reserved */
+ uint32_t reserved2; /**< Reserved */
+} _PackedType t_DsarIcmpV4Statistics;
+
+
+
+/**************************************************************************//**
+ @Description Deep Sleep Auto Response ICMPv4 Descriptor
+ 0x0 0-15 Control bits [0-15]
+ 0x2 0-15 NumOfBindings Number of entries in the binding list.
+ 0x4 0-15 BindingsPointer Bindings Pointer. This points to an VLAN-IPv4 Addresses Bindings list.
+ 0x6 0-15
+ 0x8 0-15 StatisticsPointer Statistics Pointer. This field points to the ICMPv4 statistics data structure.
+ 0xA 0-15
+ 0xC 0-15 Reserved Reserved. Must be cleared.
+ 0xE 015
+
+*//***************************************************************************/
+typedef _Packed struct
+{
+ uint16_t control; /** Control bits [0-15]. */
+ uint16_t numOfBindings; /**< Number of VLAN-IPv4 */
+ uint32_t p_Bindings; /**< VLAN-IPv4 Bindings table pointer. */
+ uint32_t p_Statistics; /**< Statistics Data Structure pointer. */
+ uint32_t reserved1; /**< Reserved. */
+} _PackedType t_DsarIcmpV4Descriptor;
+
+/**************************************************************************//**
+ @Description Deep Sleep Auto Response VLAN-IPv4 Binding Table (for ARP/ICMPv4)
+ The 4 left-most bits (15:12) of the VlanId parameter are control flags.
+ Flags[3:1] (VlanId[15:13]): Reserved, should be cleared.
+ Flags[0] (VlanId[12]): Temporary address.
+ • 0 - Assigned IP address.
+ • 1- Temporary (tentative) IP address.
+ Refer to the FMan Controller spec for more details.
+*//***************************************************************************/
+typedef _Packed struct
+{
+ uint32_t ipv6Addr[4]; /*!< 3 * 32 bit IPv4 Address. */
+ uint16_t resFlags:4; /*!< reserved flags. should be cleared */
+ uint16_t vlanId:12; /*!< 12 bits VLAN ID. */
+ /*!< This field should be 0x000 for an entry with no VLAN tag or a null VLAN ID. */
+ uint16_t reserved;
+} _PackedType t_DsarIcmpV6BindingEntry;
+
+/**************************************************************************//**
+ @Description Deep Sleep Auto Response ICMPv4 Statistics Descriptor
+ Refer to the FMan Controller spec for more details.
+ 0x00 INVAL_CNT Invalid ICMPv4 header counter
+ 0x04 NMVLAN_CNT Not My VLAN counter
+ 0x08 NMIP_CNT Not My IP counter
+ 0x0C AR_CNT Auto-Response counter
+ 0x10 CSERR_CNT Checksum Error counter
+ 0x14 MCAST_CNT Multicast counter
+ 0x18 Reserved Reserved
+ 0x1C Reserved Reserved
+
+*//***************************************************************************/
+typedef _Packed struct
+{
+ uint32_t invalCnt; /**< Invalid ICMPv4 Echo counter. */
+ uint32_t nmVlanCnt; /**< Not My VLAN counter */
+ uint32_t nmIpCnt; /**< Not My IP counter */
+ uint32_t arCnt; /**< Auto-Response counter */
+ uint32_t reserved1; /**< Reserved */
+ uint32_t reserved2; /**< Reserved */
+ uint32_t reserved3; /**< Reserved */
+ uint32_t reserved4; /**< Reserved */
+} _PackedType t_DsarIcmpV6Statistics;
+
+/**************************************************************************//**
+ @Description Deep Sleep Auto Response Neighbor Discovery Statistics Descriptor
+ 0x00 INVAL_CNT Invalid Neighbor Discovery message counter
+ 0x04 NMVLAN_CNT Not My VLAN counter
+ 0x08 NMIP_CNT Not My IP counter
+ 0x0C AR_CNT Auto-Response counter
+ 0x10 CSERR_CNT Checksum Error counter
+ 0x14 USADVERT_CNT Unsolicited Neighbor Advertisements counter
+ 0x18 NMMCAST_CNT Not My Multicast group counter
+ 0x1C NSLLA_CNT No Source Link-Layer Address counter. Indicates that there was a match on a Target
+ Address of a packet that its source IP address is a unicast address, but the ICMPv6
+ Source Link-layer Address option is omitted
+*//***************************************************************************/
+typedef _Packed struct
+{
+ uint32_t invalCnt; /**< Invalid ICMPv4 Echo counter. */
+ uint32_t nmVlanCnt; /**< Not My VLAN counter */
+ uint32_t nmIpCnt; /**< Not My IP counter */
+ uint32_t arCnt; /**< Auto-Response counter */
+ uint32_t reserved1; /**< Reserved */
+ uint32_t usadvertCnt; /**< Unsolicited Neighbor Advertisements counter */
+ uint32_t nmmcastCnt; /**< Not My Multicast group counter */
+ uint32_t nsllaCnt; /**< No Source Link-Layer Address counter */
+} _PackedType t_NdStatistics;
+
+/**************************************************************************//**
+ @Description Deep Sleep Auto Response ICMPv6 Descriptor
+ 0x0 0-15 Control bits [0-15]
+ 0x2 0-15 NumOfBindings Number of entries in the binding list.
+ 0x4 0-15 BindingsPointer Bindings Pointer. This points to an VLAN-IPv4 Addresses Bindings list.
+ 0x6 0-15
+ 0x8 0-15 StatisticsPointer Statistics Pointer. This field points to the ICMPv4 statistics data structure.
+ 0xA 0-15
+ 0xC 0-15 Reserved Reserved. Must be cleared.
+ 0xE 015
+
+*//***************************************************************************/
+typedef _Packed struct
+{
+ uint16_t control; /** Control bits [0-15]. */
+ uint16_t numOfBindings; /**< Number of VLAN-IPv6 */
+ uint32_t p_Bindings; /**< VLAN-IPv4 Bindings table pointer. */
+ uint32_t p_Statistics; /**< Statistics Data Structure pointer. */
+ uint32_t reserved1; /**< Reserved. */
+} _PackedType t_DsarIcmpV6Descriptor;
+
+
+/**************************************************************************//**
+ @Description Internet Control Message Protocol (ICMPv6) Echo message header
+ The fields names are taken from RFC 4443.
+*//***************************************************************************/
+/* 0 1 2 3 */
+/* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 */
+/* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */
+/* | Type | Code | Checksum | */
+/* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */
+/* | Identifier | Sequence Number | */
+/* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */
+/* | Data ... */
+/* +-+-+-+-+- */
+typedef _Packed struct
+{
+ uint8_t type;
+ uint8_t code;
+ uint16_t checksum;
+ uint16_t identifier;
+ uint16_t sequenceNumber;
+} _PackedType t_IcmpV6EchoHdr;
+
+/**************************************************************************//**
+ @Description Internet Control Message Protocol (ICMPv6)
+ Neighbor Solicitation/Advertisement header
+ The fields names are taken from RFC 4861.
+ The R/S/O fields are valid for Neighbor Advertisement only
+*//***************************************************************************/
+/* 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Type | Code | Checksum |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |R|S|O| Reserved |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | |
+ * + +
+ * | |
+ * + Target Address +
+ * | |
+ * + +
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Options ...
+ * +-+-+-+-+-+-+-+-+-+-+-+-
+ *
+ * Options Format:
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Type | Length | Link-Layer Address ... |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Link-Layer Address |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+typedef _Packed struct
+{
+ uint8_t type;
+ uint8_t code;
+ uint16_t checksum;
+ uint32_t router:1;
+ uint32_t solicited:1;
+ uint32_t override:1;
+ uint32_t reserved:29;
+ uint32_t targetAddr[4];
+ uint8_t optionType;
+ uint8_t optionLength;
+ uint8_t linkLayerAddr[6];
+} _PackedType t_IcmpV6NdHdr;
+
+/**************************************************************************//**
+ @Description Deep Sleep Auto Response ICMPv6 Descriptor
+ 0x0 0-15 Control bits [0-15]
+ 0x2 0-15 NumOfBindings Number of entries in the binding list.
+ 0x4 0-15 BindingsPointer Bindings Pointer. This points to an VLAN-IPv4 Addresses Bindings list.
+ 0x6 0-15
+ 0x8 0-15 StatisticsPointer Statistics Pointer. This field points to the ICMPv4 statistics data structure.
+ 0xA 0-15
+ 0xC 0-15 Reserved Reserved. Must be cleared.
+ 0xE 015
+
+*//***************************************************************************/
+typedef _Packed struct
+{
+ uint16_t control; /** Control bits [0-15]. */
+ uint16_t numOfBindings; /**< Number of VLAN-IPv6 */
+ uint32_t p_Bindings; /**< VLAN-IPv4 Bindings table pointer. */
+ uint32_t p_Statistics; /**< Statistics Data Structure pointer. */
+ uint32_t solicitedAddr; /**< Solicited Node Multicast Group Address */
+} _PackedType t_DsarNdDescriptor;
+
+/**************************************************************************//**
+@Description Deep Sleep Auto Response SNMP OIDs table entry
+
+*//***************************************************************************/
+typedef struct {
+ uint16_t oidSize; /**< Size in octets of the OID. */
+ uint16_t resSize; /**< Size in octets of the value that is attached to the OID. */
+ uint32_t p_Oid; /**< Pointer to the OID. OID is encoded in BER but type and length are excluded. */
+ uint32_t resValOrPtr; /**< Value (for up to 4 octets) or pointer to the Value. Encoded in BER. */
+ uint32_t reserved;
+} t_OidsTblEntry;
+
+/**************************************************************************//**
+ @Description Deep Sleep Auto Response SNMP IPv4 Addresses Table Entry
+ Refer to the FMan Controller spec for more details.
+*//***************************************************************************/
+typedef struct
+{
+ uint32_t ipv4Addr; /*!< 32 bit IPv4 Address. */
+ uint16_t vlanId; /*!< 12 bits VLAN ID. The 4 left-most bits should be cleared */
+ /*!< This field should be 0x0000 for an entry with no VLAN tag or a null VLAN ID. */
+ uint16_t reserved;
+} t_DsarSnmpIpv4AddrTblEntry;
+
+/**************************************************************************//**
+ @Description Deep Sleep Auto Response SNMP IPv6 Addresses Table Entry
+ Refer to the FMan Controller spec for more details.
+*//***************************************************************************/
+#pragma pack(push,1)
+typedef struct
+{
+ uint32_t ipv6Addr[4]; /*!< 4 * 32 bit IPv6 Address. */
+ uint16_t vlanId; /*!< 12 bits VLAN ID. The 4 left-most bits should be cleared */
+ /*!< This field should be 0x0000 for an entry with no VLAN tag or a null VLAN ID. */
+ uint16_t reserved;
+} t_DsarSnmpIpv6AddrTblEntry;
+#pragma pack(pop)
+
+/**************************************************************************//**
+@Description Deep Sleep Auto Response SNMP statistics table
+
+*//***************************************************************************/
+typedef struct {
+ uint32_t snmpErrCnt; /**< Counts SNMP errors (wrong version, BER encoding, format). */
+ uint32_t snmpCommunityErrCnt; /**< Counts messages that were dropped due to insufficient permission. */
+ uint32_t snmpTotalDiscardCnt; /**< Counts any message that was dropped. */
+ uint32_t snmpGetReqCnt; /**< Counts the number of get-request messages */
+ uint32_t snmpGetNextReqCnt; /**< Counts the number of get-next-request messages */
+} t_DsarSnmpStatistics;
+
+/**************************************************************************//**
+ @Description Deep Sleep Auto Response SNMP Descriptor
+
+*//***************************************************************************/
+typedef struct
+{
+ uint16_t control; /**< Control bits [0-15]. */
+ uint16_t maxSnmpMsgLength; /**< Maximal allowed SNMP message length. */
+ uint16_t numOfIpv4Addresses; /**< Number of entries in IPv4 addresses table. */
+ uint16_t numOfIpv6Addresses; /**< Number of entries in IPv6 addresses table. */
+ uint32_t p_Ipv4AddrTbl; /**< Pointer to IPv4 addresses table. */
+ uint32_t p_Ipv6AddrTbl; /**< Pointer to IPv6 addresses table. */
+ uint32_t p_RdOnlyCommunityStr; /**< Pointer to the Read Only Community String. */
+ uint32_t p_RdWrCommunityStr; /**< Pointer to the Read Write Community String. */
+ uint32_t p_OidsTbl; /**< Pointer to OIDs table. */
+ uint32_t oidsTblSize; /**< Number of entries in OIDs table. */
+ uint32_t p_Statistics; /**< Pointer to SNMP statistics table. */
+} t_DsarSnmpDescriptor;
+
+/**************************************************************************//**
+@Description Deep Sleep Auto Response (Common) Statistics
+
+*//***************************************************************************/
+typedef _Packed struct {
+ uint32_t dsarDiscarded;
+ uint32_t dsarErrDiscarded;
+ uint32_t dsarFragDiscarded;
+ uint32_t dsarTunnelDiscarded;
+ uint32_t dsarArpDiscarded;
+ uint32_t dsarIpDiscarded;
+ uint32_t dsarTcpDiscarded;
+ uint32_t dsarUdpDiscarded;
+ uint32_t dsarIcmpV6ChecksumErr; /* ICMPv6 Checksum Error counter */
+ uint32_t dsarIcmpV6OtherType; /* ICMPv6 'Other' type (not Echo or Neighbor Solicitaion/Advertisement counter */
+ uint32_t dsarIcmpV4OtherType; /* ICMPv4 'Other' type (not Echo) counter */
+} _PackedType t_ArStatistics;
+
+
+/**************************************************************************//**
+@Description Deep Sleep Auto Response TCP/UDP port filter table entry
+
+*//***************************************************************************/
+typedef _Packed struct {
+ uint32_t Ports;
+ uint32_t PortsMask;
+} _PackedType t_PortTblEntry;
+
+
+
+/**************************************************************************//**
+@Description Deep Sleep Auto Response Common Parameters Descriptor
+
+*//***************************************************************************/
+typedef _Packed struct {
+ uint8_t arTxPort; /* 0x00 0-7 Auto Response Transmit Port number */
+ uint8_t controlBits; /* 0x00 8-15 Auto Response control bits */
+ uint16_t res1; /* 0x00 16-31 Reserved */
+ uint32_t activeHPNIA; /* 0x04 0-31 Active mode Hardware Parser NIA */
+ uint16_t snmpPort; /* 0x08 0-15 SNMP Port. */
+ uint8_t macStationAddr[6]; /* 0x08 16-31 and 0x0C 0-31 MAC Station Address */
+ uint8_t res2; /* 0x10 0-7 Reserved */
+ uint8_t filterControl; /* 0x10 8-15 Filtering Control Bits. */
+ uint16_t tcpControlPass; /* 0x10 16-31 TCP control pass flags */
+ uint8_t ipProtocolTblSize; /* 0x14 0-7 IP Protocol Table Size. */
+ uint8_t udpPortTblSize; /* 0x14 8-15 UDP Port Table Size. */
+ uint8_t tcpPortTblSize; /* 0x14 16-23 TCP Port Table Size. */
+ uint8_t res3; /* 0x14 24-31 Reserved */
+ uint32_t p_IpProtocolFiltTbl; /* 0x18 0-31 Pointer to IP Protocol Filter Table */
+ uint32_t p_UdpPortFiltTbl; /* 0x1C 0-31 Pointer to UDP Port Filter Table */
+ uint32_t p_TcpPortFiltTbl; /* 0x20 0-31 Pointer to TCP Port Filter Table */
+ uint32_t res4; /* 0x24 Reserved */
+ uint32_t p_ArpDescriptor; /* 0x28 0-31 ARP Descriptor Pointer. */
+ uint32_t p_NdDescriptor; /* 0x2C 0-31 Neighbor Discovery Descriptor. */
+ uint32_t p_IcmpV4Descriptor; /* 0x30 0-31 ICMPv4 Descriptor pointer. */
+ uint32_t p_IcmpV6Descriptor; /* 0x34 0-31 ICMPv6 Descriptor pointer. */
+ uint32_t p_SnmpDescriptor; /* 0x38 0-31 SNMP Descriptor pointer. */
+ uint32_t p_ArStats; /* 0x3C 0-31 Pointer to Auto Response Statistics */
+} _PackedType t_ArCommonDesc;
+
+#if defined(__MWERKS__) && !defined(__GNUC__)
+#pragma pack(pop)
+#endif /* defined(__MWERKS__) && ... */
+
+/* t_ArCommonDesc.filterControl bits */
+#define IP_PROT_TBL_PASS_MASK 0x08
+#define UDP_PORT_TBL_PASS_MASK 0x04
+#define TCP_PORT_TBL_PASS_MASK 0x02
+
+/* Offset of TCF flags within TCP packet */
+#define TCP_FLAGS_OFFSET 12
+
+
+#endif /* __FM_PORT_DSAR_H_ */
diff --git a/sys/contrib/ncsw/Peripherals/FM/Port/fm_port_im.c b/sys/contrib/ncsw/Peripherals/FM/Port/fm_port_im.c
index e79a61bb2d7f..8de8f5fd9ddb 100644
--- a/sys/contrib/ncsw/Peripherals/FM/Port/fm_port_im.c
+++ b/sys/contrib/ncsw/Peripherals/FM/Port/fm_port_im.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm_port_im.c
@@ -38,6 +39,7 @@
#include "std_ext.h"
#include "string_ext.h"
#include "error_ext.h"
+#include "memcpy_ext.h"
#include "fm_muram_ext.h"
#include "fm_port.h"
@@ -45,25 +47,6 @@
#define TX_CONF_STATUS_UNSENT 0x1
-#ifdef CORE_8BIT_ACCESS_ERRATA
-#undef WRITE_UINT16
-#undef GET_UINT16
-
-#define WRITE_UINT16(addr, val) \
- do{ \
- if((int)&(addr) % 4) \
- WRITE_UINT32(*(uint32_t*)(uint32_t)((uint32_t)&addr & ~0x3L), \
- ((GET_UINT32(*(uint32_t*)(uint32_t)((uint32_t)&addr & ~0x3L)) & 0xffff0000) | (uint32_t)val)); \
- else \
- WRITE_UINT32(*(uint32_t*)&addr, \
- ((GET_UINT32(*(uint32_t*)&addr) & 0x0000ffff) | (uint32_t)val<<16)); \
- }while(0);
-
-#define GET_UINT16(addr) (((uint32_t)&addr%4) ? \
- ((uint16_t)GET_UINT32(*(uint32_t*)(uint32_t)((uint32_t)&addr & ~0x3L))): \
- ((uint16_t)(GET_UINT32(*(uint32_t*)(uint32_t)&addr) >> 16)))
-#endif /* CORE_8BIT_ACCESS_ERRATA */
-
typedef enum e_TxConfType
{
@@ -77,7 +60,7 @@ static void ImException(t_Handle h_FmPort, uint32_t event)
{
t_FmPort *p_FmPort = (t_FmPort*)h_FmPort;
- ASSERT_COND(((event & IM_EV_RX) && FmIsMaster(p_FmPort->h_Fm)) ||
+ ASSERT_COND(((event & (IM_EV_RX | IM_EV_BSY)) && FmIsMaster(p_FmPort->h_Fm)) ||
!FmIsMaster(p_FmPort->h_Fm));
if (event & IM_EV_RX)
@@ -158,7 +141,7 @@ t_Error FmPortImRx(t_FmPort *p_FmPort)
uint32_t bdStatus;
volatile uint8_t buffPos;
uint16_t length;
- uint16_t errors/*, reportErrors*/;
+ uint16_t errors;
uint8_t *p_CurData, *p_Data;
uint32_t flags;
@@ -186,7 +169,6 @@ t_Error FmPortImRx(t_FmPort *p_FmPort)
if (p_FmPort->im.firstBdOfFrameId == IM_ILEGAL_BD_ID)
p_FmPort->im.firstBdOfFrameId = p_FmPort->im.currBdId;
- errors = 0;
p_CurData = BdBufferGet(p_FmPort->im.rxPool.f_PhysToVirt, BD_GET(p_FmPort->im.currBdId));
h_CurrUserPriv = p_FmPort->im.p_BdShadow[p_FmPort->im.currBdId];
length = (uint16_t)((bdStatus & BD_L) ?
@@ -217,9 +199,8 @@ t_Error FmPortImRx(t_FmPort *p_FmPort)
WRITE_UINT16(p_FmPort->im.p_FmPortImPram->rxQd.offsetOut, (uint16_t)(p_FmPort->im.currBdId<<4));
/* Pass the buffer if one of the conditions is true:
- There are no errors
- - This is a part of a larger frame ( the application has already received some buffers )
- - There is an error, but it was defined to be passed anyway. */
- if ((buffPos != SINGLE_BUF) || !errors || (errors & (uint16_t)(BD_ERROR_PASS_FRAME>>16)))
+ - This is a part of a larger frame ( the application has already received some buffers ) */
+ if ((buffPos != SINGLE_BUF) || !errors)
{
if (p_FmPort->im.f_RxStore(p_FmPort->h_App,
p_CurData,
@@ -282,7 +263,7 @@ void FmPortConfigIM (t_FmPort *p_FmPort, t_FmPortParams *p_FmPortParams)
if (p_FmPort->im.mrblr != p_FmPort->im.rxPool.bufferSize)
DBG(WARNING, ("Max-Rx-Buffer-Length set to %d", p_FmPort->im.mrblr));
p_FmPort->im.bdRingSize = DEFAULT_PORT_rxBdRingLength;
- p_FmPort->exceptions = DEFAULT_exception;
+ p_FmPort->exceptions = DEFAULT_PORT_exception;
if (FmIsMaster(p_FmPort->h_Fm))
p_FmPort->polling = FALSE;
else
@@ -312,28 +293,8 @@ t_Error FmPortImCheckInitParameters(t_FmPort *p_FmPort)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("max Rx buffer length must be power of 2!!!"));
if (p_FmPort->im.mrblr < 256)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("max Rx buffer length must at least 256!!!"));
- if(p_FmPort->p_FmPortDriverParam->liodnOffset & ~FM_LIODN_OFFSET_MASK)
+ if (p_FmPort->p_FmPortDriverParam->liodnOffset & ~FM_LIODN_OFFSET_MASK)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("liodnOffset is larger than %d", FM_LIODN_OFFSET_MASK+1));
-#ifdef FM_PARTITION_ARRAY
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_FmPort->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- {
- if(p_FmPort->p_FmPortDriverParam->liodnOffset >= MAX_LIODN_OFFSET)
- {
- p_FmPort->p_FmPortDriverParam->liodnOffset =
- (uint16_t)(p_FmPort->p_FmPortDriverParam->liodnOffset & (MAX_LIODN_OFFSET-1));
- DBG(WARNING, ("liodnOffset number is out of rev1 range - MSB bits cleard."));
- }
- }
- }
-#endif /* FM_PARTITION_ARRAY */
-/* TODO - add checks */
- }
- else
- {
-/* TODO - add checks */
}
return E_OK;
@@ -362,7 +323,10 @@ t_Error FmPortImInit(t_FmPort *p_FmPort)
if ((p_FmPort->portType == e_FM_PORT_TYPE_RX) ||
(p_FmPort->portType == e_FM_PORT_TYPE_RX_10G))
{
- p_FmPort->im.p_BdRing = (t_FmImBd *)XX_MallocSmart((uint32_t)(sizeof(t_FmImBd)*p_FmPort->im.bdRingSize), p_FmPort->im.fwExtStructsMemId, 4);
+ p_FmPort->im.p_BdRing =
+ (t_FmImBd *)XX_MallocSmart((uint32_t)(sizeof(t_FmImBd)*p_FmPort->im.bdRingSize),
+ p_FmPort->im.fwExtStructsMemId,
+ 4);
if (!p_FmPort->im.p_BdRing)
RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Independent-Mode Rx BD ring!!!"));
IOMemSet32(p_FmPort->im.p_BdRing, 0, (uint32_t)(sizeof(t_FmImBd)*p_FmPort->im.bdRingSize));
@@ -392,7 +356,7 @@ t_Error FmPortImInit(t_FmPort *p_FmPort)
WRITE_UINT32(p_FmPort->im.p_FmPortImPram->rxQdPtr,
(uint32_t)((uint64_t)(XX_VirtToPhys(p_FmPort->im.p_FmPortImPram)) -
- p_FmPort->p_FmPortDriverParam->fmMuramPhysBaseAddr + 0x20));
+ p_FmPort->fmMuramPhysBaseAddr + 0x20));
LOG2((uint64_t)p_FmPort->im.mrblr, log2Num);
WRITE_UINT16(p_FmPort->im.p_FmPortImPram->mrblr, log2Num);
@@ -405,24 +369,24 @@ t_Error FmPortImInit(t_FmPort *p_FmPort)
/* Update the IM PRAM address in the BMI */
WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->rxPortBmiRegs.fmbm_rfqid,
(uint32_t)((uint64_t)(XX_VirtToPhys(p_FmPort->im.p_FmPortImPram)) -
- p_FmPort->p_FmPortDriverParam->fmMuramPhysBaseAddr));
+ p_FmPort->fmMuramPhysBaseAddr));
if (!p_FmPort->polling || p_FmPort->exceptions)
{
/* Allocate, configure and register interrupts */
err = FmAllocFmanCtrlEventReg(p_FmPort->h_Fm, &p_FmPort->fmanCtrlEventId);
- if(err)
+ if (err)
RETURN_ERROR(MAJOR, err, NO_MSG);
ASSERT_COND(!(p_FmPort->fmanCtrlEventId & ~IM_RXQD_FPMEVT_SEL_MASK));
tmpReg16 = (uint16_t)(p_FmPort->fmanCtrlEventId & IM_RXQD_FPMEVT_SEL_MASK);
tmpReg32 = 0;
- if(p_FmPort->exceptions & IM_EV_BSY)
+ if (p_FmPort->exceptions & IM_EV_BSY)
{
tmpReg16 |= IM_RXQD_BSYINTM;
tmpReg32 |= IM_EV_BSY;
}
- if(!p_FmPort->polling)
+ if (!p_FmPort->polling)
{
tmpReg16 |= IM_RXQD_RXFINTM;
tmpReg32 |= IM_EV_RX;
@@ -457,7 +421,7 @@ t_Error FmPortImInit(t_FmPort *p_FmPort)
WRITE_UINT32(p_FmPort->im.p_FmPortImPram->txQdPtr,
(uint32_t)((uint64_t)(XX_VirtToPhys(p_FmPort->im.p_FmPortImPram)) -
- p_FmPort->p_FmPortDriverParam->fmMuramPhysBaseAddr + 0x40));
+ p_FmPort->fmMuramPhysBaseAddr + 0x40));
/* Initialize Tx QD */
tmpPhysBase = (uint64_t)(XX_VirtToPhys(p_FmPort->im.p_BdRing));
@@ -467,7 +431,7 @@ t_Error FmPortImInit(t_FmPort *p_FmPort)
/* Update the IM PRAM address in the BMI */
WRITE_UINT32(p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tcfqid,
(uint32_t)((uint64_t)(XX_VirtToPhys(p_FmPort->im.p_FmPortImPram)) -
- p_FmPort->p_FmPortDriverParam->fmMuramPhysBaseAddr));
+ p_FmPort->fmMuramPhysBaseAddr));
}
@@ -593,7 +557,7 @@ t_Error FM_PORT_ConfigIMPolling(t_Handle h_FmPort)
SANITY_CHECK_RETURN_ERROR(p_FmPort->imEn, E_INVALID_STATE);
SANITY_CHECK_RETURN_ERROR(p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
+ if ((p_FmPort->portType != e_FM_PORT_TYPE_RX_10G) && (p_FmPort->portType != e_FM_PORT_TYPE_RX))
RETURN_ERROR(MAJOR, E_INVALID_OPERATION, ("Available for Rx ports only"));
if (!FmIsMaster(p_FmPort->h_Fm))
@@ -616,16 +580,16 @@ t_Error FM_PORT_SetIMExceptions(t_Handle h_FmPort, e_FmPortExceptions exception,
SANITY_CHECK_RETURN_ERROR(p_FmPort->imEn, E_INVALID_STATE);
SANITY_CHECK_RETURN_ERROR(!p_FmPort->p_FmPortDriverParam, E_INVALID_HANDLE);
- if(exception == e_FM_PORT_EXCEPTION_IM_BUSY)
+ if (exception == e_FM_PORT_EXCEPTION_IM_BUSY)
{
- if(enable)
+ if (enable)
{
p_FmPort->exceptions |= IM_EV_BSY;
- if(p_FmPort->fmanCtrlEventId == (uint8_t)NO_IRQ)
+ if (p_FmPort->fmanCtrlEventId == (uint8_t)NO_IRQ)
{
/* Allocate, configure and register interrupts */
err = FmAllocFmanCtrlEventReg(p_FmPort->h_Fm, &p_FmPort->fmanCtrlEventId);
- if(err)
+ if (err)
RETURN_ERROR(MAJOR, err, NO_MSG);
ASSERT_COND(!(p_FmPort->fmanCtrlEventId & ~IM_RXQD_FPMEVT_SEL_MASK));
diff --git a/sys/contrib/ncsw/Peripherals/FM/Port/fman_port.c b/sys/contrib/ncsw/Peripherals/FM/Port/fman_port.c
new file mode 100755
index 000000000000..df86ec3dc378
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/Port/fman_port.c
@@ -0,0 +1,1568 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "common/general.h"
+
+#include "fman_common.h"
+#include "fsl_fman_port.h"
+
+
+/* problem Eyal: the following should not be here*/
+#define NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_ENQ_FRAME 0x00000028
+
+static uint32_t get_no_pcd_nia_bmi_ac_enc_frame(struct fman_port_cfg *cfg)
+{
+ if (cfg->errata_A006675)
+ return NIA_ENG_FM_CTL |
+ NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_ENQ_FRAME;
+ else
+ return NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME;
+}
+
+static int init_bmi_rx(struct fman_port *port,
+ struct fman_port_cfg *cfg,
+ struct fman_port_params *params)
+{
+ struct fman_port_rx_bmi_regs *regs = &port->bmi_regs->rx;
+ uint32_t tmp;
+
+ /* Rx Configuration register */
+ tmp = 0;
+ if (port->im_en)
+ tmp |= BMI_PORT_CFG_IM;
+ else if (cfg->discard_override)
+ tmp |= BMI_PORT_CFG_FDOVR;
+ iowrite32be(tmp, &regs->fmbm_rcfg);
+
+ /* DMA attributes */
+ tmp = (uint32_t)cfg->dma_swap_data << BMI_DMA_ATTR_SWP_SHIFT;
+ if (cfg->dma_ic_stash_on)
+ tmp |= BMI_DMA_ATTR_IC_STASH_ON;
+ if (cfg->dma_header_stash_on)
+ tmp |= BMI_DMA_ATTR_HDR_STASH_ON;
+ if (cfg->dma_sg_stash_on)
+ tmp |= BMI_DMA_ATTR_SG_STASH_ON;
+ if (cfg->dma_write_optimize)
+ tmp |= BMI_DMA_ATTR_WRITE_OPTIMIZE;
+ iowrite32be(tmp, &regs->fmbm_rda);
+
+ /* Rx FIFO parameters */
+ tmp = (cfg->rx_pri_elevation / FMAN_PORT_BMI_FIFO_UNITS - 1) <<
+ BMI_RX_FIFO_PRI_ELEVATION_SHIFT;
+ tmp |= cfg->rx_fifo_thr / FMAN_PORT_BMI_FIFO_UNITS - 1;
+ iowrite32be(tmp, &regs->fmbm_rfp);
+
+ if (cfg->excessive_threshold_register)
+ /* always allow access to the extra resources */
+ iowrite32be(BMI_RX_FIFO_THRESHOLD_ETHE, &regs->fmbm_reth);
+
+ /* Frame end data */
+ tmp = (uint32_t)cfg->checksum_bytes_ignore <<
+ BMI_RX_FRAME_END_CS_IGNORE_SHIFT;
+ tmp |= (uint32_t)cfg->rx_cut_end_bytes <<
+ BMI_RX_FRAME_END_CUT_SHIFT;
+ if (cfg->errata_A006320)
+ tmp &= 0xffe0ffff;
+ iowrite32be(tmp, &regs->fmbm_rfed);
+
+ /* Internal context parameters */
+ tmp = ((uint32_t)cfg->ic_ext_offset / FMAN_PORT_IC_OFFSET_UNITS) <<
+ BMI_IC_TO_EXT_SHIFT;
+ tmp |= ((uint32_t)cfg->ic_int_offset / FMAN_PORT_IC_OFFSET_UNITS) <<
+ BMI_IC_FROM_INT_SHIFT;
+ tmp |= cfg->ic_size / FMAN_PORT_IC_OFFSET_UNITS;
+ iowrite32be(tmp, &regs->fmbm_ricp);
+
+ /* Internal buffer offset */
+ tmp = ((uint32_t)cfg->int_buf_start_margin / FMAN_PORT_IC_OFFSET_UNITS)
+ << BMI_INT_BUF_MARG_SHIFT;
+ iowrite32be(tmp, &regs->fmbm_rim);
+
+ /* External buffer margins */
+ if (!port->im_en)
+ {
+ tmp = (uint32_t)cfg->ext_buf_start_margin <<
+ BMI_EXT_BUF_MARG_START_SHIFT;
+ tmp |= (uint32_t)cfg->ext_buf_end_margin;
+ if (cfg->fmbm_rebm_has_sgd && cfg->no_scatter_gather)
+ tmp |= BMI_SG_DISABLE;
+ iowrite32be(tmp, &regs->fmbm_rebm);
+ }
+
+ /* Frame attributes */
+ tmp = BMI_CMD_RX_MR_DEF;
+ if (!port->im_en)
+ {
+ tmp |= BMI_CMD_ATTR_ORDER;
+ tmp |= (uint32_t)cfg->color << BMI_CMD_ATTR_COLOR_SHIFT;
+ if (cfg->sync_req)
+ tmp |= BMI_CMD_ATTR_SYNC;
+ }
+ iowrite32be(tmp, &regs->fmbm_rfca);
+
+ /* NIA */
+ if (port->im_en)
+ tmp = NIA_ENG_FM_CTL | NIA_FM_CTL_AC_IND_MODE_RX;
+ else
+ {
+ tmp = (uint32_t)cfg->rx_fd_bits << BMI_NEXT_ENG_FD_BITS_SHIFT;
+ tmp |= get_no_pcd_nia_bmi_ac_enc_frame(cfg);
+ }
+ iowrite32be(tmp, &regs->fmbm_rfne);
+
+ /* Enqueue NIA */
+ iowrite32be(NIA_ENG_QMI_ENQ | NIA_ORDER_RESTOR, &regs->fmbm_rfene);
+
+ /* Default/error queues */
+ if (!port->im_en)
+ {
+ iowrite32be((params->dflt_fqid & 0x00FFFFFF), &regs->fmbm_rfqid);
+ iowrite32be((params->err_fqid & 0x00FFFFFF), &regs->fmbm_refqid);
+ }
+
+ /* Discard/error masks */
+ iowrite32be(params->discard_mask, &regs->fmbm_rfsdm);
+ iowrite32be(params->err_mask, &regs->fmbm_rfsem);
+
+ /* Statistics counters */
+ tmp = 0;
+ if (cfg->stats_counters_enable)
+ tmp = BMI_COUNTERS_EN;
+ iowrite32be(tmp, &regs->fmbm_rstc);
+
+ /* Performance counters */
+ fman_port_set_perf_cnt_params(port, &cfg->perf_cnt_params);
+ tmp = 0;
+ if (cfg->perf_counters_enable)
+ tmp = BMI_COUNTERS_EN;
+ iowrite32be(tmp, &regs->fmbm_rpc);
+
+ return 0;
+}
+
+static int init_bmi_tx(struct fman_port *port,
+ struct fman_port_cfg *cfg,
+ struct fman_port_params *params)
+{
+ struct fman_port_tx_bmi_regs *regs = &port->bmi_regs->tx;
+ uint32_t tmp;
+
+ /* Tx Configuration register */
+ tmp = 0;
+ if (port->im_en)
+ tmp |= BMI_PORT_CFG_IM;
+ iowrite32be(tmp, &regs->fmbm_tcfg);
+
+ /* DMA attributes */
+ tmp = (uint32_t)cfg->dma_swap_data << BMI_DMA_ATTR_SWP_SHIFT;
+ if (cfg->dma_ic_stash_on)
+ tmp |= BMI_DMA_ATTR_IC_STASH_ON;
+ if (cfg->dma_header_stash_on)
+ tmp |= BMI_DMA_ATTR_HDR_STASH_ON;
+ if (cfg->dma_sg_stash_on)
+ tmp |= BMI_DMA_ATTR_SG_STASH_ON;
+ iowrite32be(tmp, &regs->fmbm_tda);
+
+ /* Tx FIFO parameters */
+ tmp = (cfg->tx_fifo_min_level / FMAN_PORT_BMI_FIFO_UNITS) <<
+ BMI_TX_FIFO_MIN_FILL_SHIFT;
+ tmp |= ((uint32_t)cfg->tx_fifo_deq_pipeline_depth - 1) <<
+ BMI_FIFO_PIPELINE_DEPTH_SHIFT;
+ tmp |= (uint32_t)(cfg->tx_fifo_low_comf_level /
+ FMAN_PORT_BMI_FIFO_UNITS - 1);
+ iowrite32be(tmp, &regs->fmbm_tfp);
+
+ /* Frame end data */
+ tmp = (uint32_t)cfg->checksum_bytes_ignore <<
+ BMI_FRAME_END_CS_IGNORE_SHIFT;
+ iowrite32be(tmp, &regs->fmbm_tfed);
+
+ /* Internal context parameters */
+ if (!port->im_en)
+ {
+ tmp = ((uint32_t)cfg->ic_ext_offset / FMAN_PORT_IC_OFFSET_UNITS) <<
+ BMI_IC_TO_EXT_SHIFT;
+ tmp |= ((uint32_t)cfg->ic_int_offset / FMAN_PORT_IC_OFFSET_UNITS) <<
+ BMI_IC_FROM_INT_SHIFT;
+ tmp |= cfg->ic_size / FMAN_PORT_IC_OFFSET_UNITS;
+ iowrite32be(tmp, &regs->fmbm_ticp);
+ }
+ /* Frame attributes */
+ tmp = BMI_CMD_TX_MR_DEF;
+ if (port->im_en)
+ tmp |= BMI_CMD_MR_DEAS;
+ else
+ {
+ tmp |= BMI_CMD_ATTR_ORDER;
+ tmp |= (uint32_t)cfg->color << BMI_CMD_ATTR_COLOR_SHIFT;
+ }
+ iowrite32be(tmp, &regs->fmbm_tfca);
+
+ /* Dequeue NIA + enqueue NIA */
+ if (port->im_en)
+ {
+ iowrite32be(NIA_ENG_FM_CTL | NIA_FM_CTL_AC_IND_MODE_TX, &regs->fmbm_tfdne);
+ iowrite32be(NIA_ENG_FM_CTL | NIA_FM_CTL_AC_IND_MODE_TX, &regs->fmbm_tfene);
+ }
+ else
+ {
+ iowrite32be(NIA_ENG_QMI_DEQ, &regs->fmbm_tfdne);
+ iowrite32be(NIA_ENG_QMI_ENQ | NIA_ORDER_RESTOR, &regs->fmbm_tfene);
+ if (cfg->fmbm_tfne_has_features)
+ iowrite32be(!params->dflt_fqid ?
+ BMI_EBD_EN | NIA_BMI_AC_FETCH_ALL_FRAME :
+ NIA_BMI_AC_FETCH_ALL_FRAME, &regs->fmbm_tfne);
+ if (!params->dflt_fqid && params->dont_release_buf)
+ {
+ iowrite32be(0x00FFFFFF, &regs->fmbm_tcfqid);
+ iowrite32be(NIA_ENG_BMI | NIA_BMI_AC_TX_RELEASE, &regs->fmbm_tfene);
+ if (cfg->fmbm_tfne_has_features)
+ iowrite32be(ioread32be(&regs->fmbm_tfne) & ~BMI_EBD_EN, &regs->fmbm_tfne);
+ }
+ }
+
+ /* Confirmation/error queues */
+ if (!port->im_en)
+ {
+ if (params->dflt_fqid || !params->dont_release_buf)
+ iowrite32be(params->dflt_fqid & 0x00FFFFFF, &regs->fmbm_tcfqid);
+ iowrite32be((params->err_fqid & 0x00FFFFFF), &regs->fmbm_tefqid);
+ }
+ /* Statistics counters */
+ tmp = 0;
+ if (cfg->stats_counters_enable)
+ tmp = BMI_COUNTERS_EN;
+ iowrite32be(tmp, &regs->fmbm_tstc);
+
+ /* Performance counters */
+ fman_port_set_perf_cnt_params(port, &cfg->perf_cnt_params);
+ tmp = 0;
+ if (cfg->perf_counters_enable)
+ tmp = BMI_COUNTERS_EN;
+ iowrite32be(tmp, &regs->fmbm_tpc);
+
+ return 0;
+}
+
+static int init_bmi_oh(struct fman_port *port,
+ struct fman_port_cfg *cfg,
+ struct fman_port_params *params)
+{
+ struct fman_port_oh_bmi_regs *regs = &port->bmi_regs->oh;
+ uint32_t tmp;
+
+ /* OP Configuration register */
+ tmp = 0;
+ if (cfg->discard_override)
+ tmp |= BMI_PORT_CFG_FDOVR;
+ iowrite32be(tmp, &regs->fmbm_ocfg);
+
+ /* DMA attributes */
+ tmp = (uint32_t)cfg->dma_swap_data << BMI_DMA_ATTR_SWP_SHIFT;
+ if (cfg->dma_ic_stash_on)
+ tmp |= BMI_DMA_ATTR_IC_STASH_ON;
+ if (cfg->dma_header_stash_on)
+ tmp |= BMI_DMA_ATTR_HDR_STASH_ON;
+ if (cfg->dma_sg_stash_on)
+ tmp |= BMI_DMA_ATTR_SG_STASH_ON;
+ if (cfg->dma_write_optimize)
+ tmp |= BMI_DMA_ATTR_WRITE_OPTIMIZE;
+ iowrite32be(tmp, &regs->fmbm_oda);
+
+ /* Tx FIFO parameters */
+ tmp = ((uint32_t)cfg->tx_fifo_deq_pipeline_depth - 1) <<
+ BMI_FIFO_PIPELINE_DEPTH_SHIFT;
+ iowrite32be(tmp, &regs->fmbm_ofp);
+
+ /* Internal context parameters */
+ tmp = ((uint32_t)cfg->ic_ext_offset / FMAN_PORT_IC_OFFSET_UNITS) <<
+ BMI_IC_TO_EXT_SHIFT;
+ tmp |= ((uint32_t)cfg->ic_int_offset / FMAN_PORT_IC_OFFSET_UNITS) <<
+ BMI_IC_FROM_INT_SHIFT;
+ tmp |= cfg->ic_size / FMAN_PORT_IC_OFFSET_UNITS;
+ iowrite32be(tmp, &regs->fmbm_oicp);
+
+ /* Frame attributes */
+ tmp = BMI_CMD_OP_MR_DEF;
+ tmp |= (uint32_t)cfg->color << BMI_CMD_ATTR_COLOR_SHIFT;
+ if (cfg->sync_req)
+ tmp |= BMI_CMD_ATTR_SYNC;
+ if (port->type == E_FMAN_PORT_TYPE_OP)
+ tmp |= BMI_CMD_ATTR_ORDER;
+ iowrite32be(tmp, &regs->fmbm_ofca);
+
+ /* Internal buffer offset */
+ tmp = ((uint32_t)cfg->int_buf_start_margin / FMAN_PORT_IC_OFFSET_UNITS)
+ << BMI_INT_BUF_MARG_SHIFT;
+ iowrite32be(tmp, &regs->fmbm_oim);
+
+ /* Dequeue NIA */
+ iowrite32be(NIA_ENG_QMI_DEQ, &regs->fmbm_ofdne);
+
+ /* NIA and Enqueue NIA */
+ if (port->type == E_FMAN_PORT_TYPE_HC) {
+ iowrite32be(NIA_ENG_FM_CTL | NIA_FM_CTL_AC_HC,
+ &regs->fmbm_ofne);
+ iowrite32be(NIA_ENG_QMI_ENQ, &regs->fmbm_ofene);
+ } else {
+ iowrite32be(get_no_pcd_nia_bmi_ac_enc_frame(cfg),
+ &regs->fmbm_ofne);
+ iowrite32be(NIA_ENG_QMI_ENQ | NIA_ORDER_RESTOR,
+ &regs->fmbm_ofene);
+ }
+
+ /* Default/error queues */
+ iowrite32be((params->dflt_fqid & 0x00FFFFFF), &regs->fmbm_ofqid);
+ iowrite32be((params->err_fqid & 0x00FFFFFF), &regs->fmbm_oefqid);
+
+ /* Discard/error masks */
+ if (port->type == E_FMAN_PORT_TYPE_OP) {
+ iowrite32be(params->discard_mask, &regs->fmbm_ofsdm);
+ iowrite32be(params->err_mask, &regs->fmbm_ofsem);
+ }
+
+ /* Statistics counters */
+ tmp = 0;
+ if (cfg->stats_counters_enable)
+ tmp = BMI_COUNTERS_EN;
+ iowrite32be(tmp, &regs->fmbm_ostc);
+
+ /* Performance counters */
+ fman_port_set_perf_cnt_params(port, &cfg->perf_cnt_params);
+ tmp = 0;
+ if (cfg->perf_counters_enable)
+ tmp = BMI_COUNTERS_EN;
+ iowrite32be(tmp, &regs->fmbm_opc);
+
+ return 0;
+}
+
+static int init_qmi(struct fman_port *port,
+ struct fman_port_cfg *cfg,
+ struct fman_port_params *params)
+{
+ struct fman_port_qmi_regs *regs = port->qmi_regs;
+ uint32_t tmp;
+
+ tmp = 0;
+ if (cfg->queue_counters_enable)
+ tmp |= QMI_PORT_CFG_EN_COUNTERS;
+ iowrite32be(tmp, &regs->fmqm_pnc);
+
+ /* Rx port configuration */
+ if ((port->type == E_FMAN_PORT_TYPE_RX) ||
+ (port->type == E_FMAN_PORT_TYPE_RX_10G)) {
+ /* Enqueue NIA */
+ iowrite32be(NIA_ENG_BMI | NIA_BMI_AC_RELEASE, &regs->fmqm_pnen);
+ return 0;
+ }
+
+ /* Continue with Tx and O/H port configuration */
+ if ((port->type == E_FMAN_PORT_TYPE_TX) ||
+ (port->type == E_FMAN_PORT_TYPE_TX_10G)) {
+ /* Enqueue NIA */
+ iowrite32be(NIA_ENG_BMI | NIA_BMI_AC_TX_RELEASE,
+ &regs->fmqm_pnen);
+ /* Dequeue NIA */
+ iowrite32be(NIA_ENG_BMI | NIA_BMI_AC_TX, &regs->fmqm_pndn);
+ } else {
+ /* Enqueue NIA */
+ iowrite32be(NIA_ENG_BMI | NIA_BMI_AC_RELEASE, &regs->fmqm_pnen);
+ /* Dequeue NIA */
+ iowrite32be(NIA_ENG_BMI | NIA_BMI_AC_FETCH, &regs->fmqm_pndn);
+ }
+
+ /* Dequeue Configuration register */
+ tmp = 0;
+ if (cfg->deq_high_pri)
+ tmp |= QMI_DEQ_CFG_PRI;
+
+ switch (cfg->deq_type) {
+ case E_FMAN_PORT_DEQ_BY_PRI:
+ tmp |= QMI_DEQ_CFG_TYPE1;
+ break;
+ case E_FMAN_PORT_DEQ_ACTIVE_FQ:
+ tmp |= QMI_DEQ_CFG_TYPE2;
+ break;
+ case E_FMAN_PORT_DEQ_ACTIVE_FQ_NO_ICS:
+ tmp |= QMI_DEQ_CFG_TYPE3;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (cfg->qmi_deq_options_support) {
+ if ((port->type == E_FMAN_PORT_TYPE_HC) &&
+ (cfg->deq_prefetch_opt != E_FMAN_PORT_DEQ_NO_PREFETCH))
+ return -EINVAL;
+
+ switch (cfg->deq_prefetch_opt) {
+ case E_FMAN_PORT_DEQ_NO_PREFETCH:
+ break;
+ case E_FMAN_PORT_DEQ_PART_PREFETCH:
+ tmp |= QMI_DEQ_CFG_PREFETCH_PARTIAL;
+ break;
+ case E_FMAN_PORT_DEQ_FULL_PREFETCH:
+ tmp |= QMI_DEQ_CFG_PREFETCH_FULL;
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
+ tmp |= (uint32_t)(params->deq_sp & QMI_DEQ_CFG_SP_MASK) <<
+ QMI_DEQ_CFG_SP_SHIFT;
+ tmp |= cfg->deq_byte_cnt;
+ iowrite32be(tmp, &regs->fmqm_pndc);
+
+ return 0;
+}
+
+static void get_rx_stats_reg(struct fman_port *port,
+ enum fman_port_stats_counters counter,
+ uint32_t **stats_reg)
+{
+ struct fman_port_rx_bmi_regs *regs = &port->bmi_regs->rx;
+
+ switch (counter) {
+ case E_FMAN_PORT_STATS_CNT_FRAME:
+ *stats_reg = &regs->fmbm_rfrc;
+ break;
+ case E_FMAN_PORT_STATS_CNT_DISCARD:
+ *stats_reg = &regs->fmbm_rfdc;
+ break;
+ case E_FMAN_PORT_STATS_CNT_DEALLOC_BUF:
+ *stats_reg = &regs->fmbm_rbdc;
+ break;
+ case E_FMAN_PORT_STATS_CNT_RX_BAD_FRAME:
+ *stats_reg = &regs->fmbm_rfbc;
+ break;
+ case E_FMAN_PORT_STATS_CNT_RX_LARGE_FRAME:
+ *stats_reg = &regs->fmbm_rlfc;
+ break;
+ case E_FMAN_PORT_STATS_CNT_RX_OUT_OF_BUF:
+ *stats_reg = &regs->fmbm_rodc;
+ break;
+ case E_FMAN_PORT_STATS_CNT_FILTERED_FRAME:
+ *stats_reg = &regs->fmbm_rffc;
+ break;
+ case E_FMAN_PORT_STATS_CNT_DMA_ERR:
+ *stats_reg = &regs->fmbm_rfldec;
+ break;
+ default:
+ *stats_reg = NULL;
+ }
+}
+
+static void get_tx_stats_reg(struct fman_port *port,
+ enum fman_port_stats_counters counter,
+ uint32_t **stats_reg)
+{
+ struct fman_port_tx_bmi_regs *regs = &port->bmi_regs->tx;
+
+ switch (counter) {
+ case E_FMAN_PORT_STATS_CNT_FRAME:
+ *stats_reg = &regs->fmbm_tfrc;
+ break;
+ case E_FMAN_PORT_STATS_CNT_DISCARD:
+ *stats_reg = &regs->fmbm_tfdc;
+ break;
+ case E_FMAN_PORT_STATS_CNT_DEALLOC_BUF:
+ *stats_reg = &regs->fmbm_tbdc;
+ break;
+ case E_FMAN_PORT_STATS_CNT_LEN_ERR:
+ *stats_reg = &regs->fmbm_tfledc;
+ break;
+ case E_FMAN_PORT_STATS_CNT_UNSUPPORTED_FORMAT:
+ *stats_reg = &regs->fmbm_tfufdc;
+ break;
+ default:
+ *stats_reg = NULL;
+ }
+}
+
+static void get_oh_stats_reg(struct fman_port *port,
+ enum fman_port_stats_counters counter,
+ uint32_t **stats_reg)
+{
+ struct fman_port_oh_bmi_regs *regs = &port->bmi_regs->oh;
+
+ switch (counter) {
+ case E_FMAN_PORT_STATS_CNT_FRAME:
+ *stats_reg = &regs->fmbm_ofrc;
+ break;
+ case E_FMAN_PORT_STATS_CNT_DISCARD:
+ *stats_reg = &regs->fmbm_ofdc;
+ break;
+ case E_FMAN_PORT_STATS_CNT_DEALLOC_BUF:
+ *stats_reg = &regs->fmbm_obdc;
+ break;
+ case E_FMAN_PORT_STATS_CNT_FILTERED_FRAME:
+ *stats_reg = &regs->fmbm_offc;
+ break;
+ case E_FMAN_PORT_STATS_CNT_DMA_ERR:
+ *stats_reg = &regs->fmbm_ofldec;
+ break;
+ case E_FMAN_PORT_STATS_CNT_LEN_ERR:
+ *stats_reg = &regs->fmbm_ofledc;
+ break;
+ case E_FMAN_PORT_STATS_CNT_UNSUPPORTED_FORMAT:
+ *stats_reg = &regs->fmbm_ofufdc;
+ break;
+ case E_FMAN_PORT_STATS_CNT_WRED_DISCARD:
+ *stats_reg = &regs->fmbm_ofwdc;
+ break;
+ default:
+ *stats_reg = NULL;
+ }
+}
+
+static void get_rx_perf_reg(struct fman_port *port,
+ enum fman_port_perf_counters counter,
+ uint32_t **perf_reg)
+{
+ struct fman_port_rx_bmi_regs *regs = &port->bmi_regs->rx;
+
+ switch (counter) {
+ case E_FMAN_PORT_PERF_CNT_CYCLE:
+ *perf_reg = &regs->fmbm_rccn;
+ break;
+ case E_FMAN_PORT_PERF_CNT_TASK_UTIL:
+ *perf_reg = &regs->fmbm_rtuc;
+ break;
+ case E_FMAN_PORT_PERF_CNT_QUEUE_UTIL:
+ *perf_reg = &regs->fmbm_rrquc;
+ break;
+ case E_FMAN_PORT_PERF_CNT_DMA_UTIL:
+ *perf_reg = &regs->fmbm_rduc;
+ break;
+ case E_FMAN_PORT_PERF_CNT_FIFO_UTIL:
+ *perf_reg = &regs->fmbm_rfuc;
+ break;
+ case E_FMAN_PORT_PERF_CNT_RX_PAUSE:
+ *perf_reg = &regs->fmbm_rpac;
+ break;
+ default:
+ *perf_reg = NULL;
+ }
+}
+
+static void get_tx_perf_reg(struct fman_port *port,
+ enum fman_port_perf_counters counter,
+ uint32_t **perf_reg)
+{
+ struct fman_port_tx_bmi_regs *regs = &port->bmi_regs->tx;
+
+ switch (counter) {
+ case E_FMAN_PORT_PERF_CNT_CYCLE:
+ *perf_reg = &regs->fmbm_tccn;
+ break;
+ case E_FMAN_PORT_PERF_CNT_TASK_UTIL:
+ *perf_reg = &regs->fmbm_ttuc;
+ break;
+ case E_FMAN_PORT_PERF_CNT_QUEUE_UTIL:
+ *perf_reg = &regs->fmbm_ttcquc;
+ break;
+ case E_FMAN_PORT_PERF_CNT_DMA_UTIL:
+ *perf_reg = &regs->fmbm_tduc;
+ break;
+ case E_FMAN_PORT_PERF_CNT_FIFO_UTIL:
+ *perf_reg = &regs->fmbm_tfuc;
+ break;
+ default:
+ *perf_reg = NULL;
+ }
+}
+
+static void get_oh_perf_reg(struct fman_port *port,
+ enum fman_port_perf_counters counter,
+ uint32_t **perf_reg)
+{
+ struct fman_port_oh_bmi_regs *regs = &port->bmi_regs->oh;
+
+ switch (counter) {
+ case E_FMAN_PORT_PERF_CNT_CYCLE:
+ *perf_reg = &regs->fmbm_occn;
+ break;
+ case E_FMAN_PORT_PERF_CNT_TASK_UTIL:
+ *perf_reg = &regs->fmbm_otuc;
+ break;
+ case E_FMAN_PORT_PERF_CNT_DMA_UTIL:
+ *perf_reg = &regs->fmbm_oduc;
+ break;
+ case E_FMAN_PORT_PERF_CNT_FIFO_UTIL:
+ *perf_reg = &regs->fmbm_ofuc;
+ break;
+ default:
+ *perf_reg = NULL;
+ }
+}
+
+static void get_qmi_counter_reg(struct fman_port *port,
+ enum fman_port_qmi_counters counter,
+ uint32_t **queue_reg)
+{
+ struct fman_port_qmi_regs *regs = port->qmi_regs;
+
+ switch (counter) {
+ case E_FMAN_PORT_ENQ_TOTAL:
+ *queue_reg = &regs->fmqm_pnetfc;
+ break;
+ case E_FMAN_PORT_DEQ_TOTAL:
+ if ((port->type == E_FMAN_PORT_TYPE_RX) ||
+ (port->type == E_FMAN_PORT_TYPE_RX_10G))
+ /* Counter not available for Rx ports */
+ *queue_reg = NULL;
+ else
+ *queue_reg = &regs->fmqm_pndtfc;
+ break;
+ case E_FMAN_PORT_DEQ_FROM_DFLT:
+ if ((port->type == E_FMAN_PORT_TYPE_RX) ||
+ (port->type == E_FMAN_PORT_TYPE_RX_10G))
+ /* Counter not available for Rx ports */
+ *queue_reg = NULL;
+ else
+ *queue_reg = &regs->fmqm_pndfdc;
+ break;
+ case E_FMAN_PORT_DEQ_CONFIRM:
+ if ((port->type == E_FMAN_PORT_TYPE_RX) ||
+ (port->type == E_FMAN_PORT_TYPE_RX_10G))
+ /* Counter not available for Rx ports */
+ *queue_reg = NULL;
+ else
+ *queue_reg = &regs->fmqm_pndcc;
+ break;
+ default:
+ *queue_reg = NULL;
+ }
+}
+
+void fman_port_defconfig(struct fman_port_cfg *cfg, enum fman_port_type type)
+{
+ cfg->dma_swap_data = E_FMAN_PORT_DMA_NO_SWAP;
+ cfg->dma_ic_stash_on = FALSE;
+ cfg->dma_header_stash_on = FALSE;
+ cfg->dma_sg_stash_on = FALSE;
+ cfg->dma_write_optimize = TRUE;
+ cfg->color = E_FMAN_PORT_COLOR_GREEN;
+ cfg->discard_override = FALSE;
+ cfg->checksum_bytes_ignore = 0;
+ cfg->rx_cut_end_bytes = 4;
+ cfg->rx_pri_elevation = ((0x3FF + 1) * FMAN_PORT_BMI_FIFO_UNITS);
+ cfg->rx_fifo_thr = ((0x3FF + 1) * FMAN_PORT_BMI_FIFO_UNITS);
+ cfg->rx_fd_bits = 0;
+ cfg->ic_ext_offset = 0;
+ cfg->ic_int_offset = 0;
+ cfg->ic_size = 0;
+ cfg->int_buf_start_margin = 0;
+ cfg->ext_buf_start_margin = 0;
+ cfg->ext_buf_end_margin = 0;
+ cfg->tx_fifo_min_level = 0;
+ cfg->tx_fifo_low_comf_level = (5 * KILOBYTE);
+ cfg->stats_counters_enable = TRUE;
+ cfg->perf_counters_enable = TRUE;
+ cfg->deq_type = E_FMAN_PORT_DEQ_BY_PRI;
+
+ if (type == E_FMAN_PORT_TYPE_HC) {
+ cfg->sync_req = FALSE;
+ cfg->deq_prefetch_opt = E_FMAN_PORT_DEQ_NO_PREFETCH;
+ } else {
+ cfg->sync_req = TRUE;
+ cfg->deq_prefetch_opt = E_FMAN_PORT_DEQ_FULL_PREFETCH;
+ }
+
+ if (type == E_FMAN_PORT_TYPE_TX_10G) {
+ cfg->tx_fifo_deq_pipeline_depth = 4;
+ cfg->deq_high_pri = TRUE;
+ cfg->deq_byte_cnt = 0x1400;
+ } else {
+ if ((type == E_FMAN_PORT_TYPE_HC) ||
+ (type == E_FMAN_PORT_TYPE_OP))
+ cfg->tx_fifo_deq_pipeline_depth = 2;
+ else
+ cfg->tx_fifo_deq_pipeline_depth = 1;
+
+ cfg->deq_high_pri = FALSE;
+ cfg->deq_byte_cnt = 0x400;
+ }
+ cfg->no_scatter_gather = DEFAULT_FMAN_SP_NO_SCATTER_GATHER;
+}
+
+static uint8_t fman_port_find_bpool(struct fman_port *port, uint8_t bpid)
+{
+ uint32_t *bp_reg, tmp;
+ uint8_t i, id;
+
+ /* Find the pool */
+ bp_reg = port->bmi_regs->rx.fmbm_ebmpi;
+ for (i = 0;
+ (i < port->ext_pools_num && (i < FMAN_PORT_MAX_EXT_POOLS_NUM));
+ i++) {
+ tmp = ioread32be(&bp_reg[i]);
+ id = (uint8_t)((tmp & BMI_EXT_BUF_POOL_ID_MASK) >>
+ BMI_EXT_BUF_POOL_ID_SHIFT);
+
+ if (id == bpid)
+ break;
+ }
+
+ return i;
+}
+
+int fman_port_init(struct fman_port *port,
+ struct fman_port_cfg *cfg,
+ struct fman_port_params *params)
+{
+ int err;
+
+ /* Init BMI registers */
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ err = init_bmi_rx(port, cfg, params);
+ break;
+ case E_FMAN_PORT_TYPE_TX:
+ case E_FMAN_PORT_TYPE_TX_10G:
+ err = init_bmi_tx(port, cfg, params);
+ break;
+ case E_FMAN_PORT_TYPE_OP:
+ case E_FMAN_PORT_TYPE_HC:
+ err = init_bmi_oh(port, cfg, params);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (err)
+ return err;
+
+ /* Init QMI registers */
+ if (!port->im_en)
+ {
+ err = init_qmi(port, cfg, params);
+ return err;
+ }
+ return 0;
+}
+
+int fman_port_enable(struct fman_port *port)
+{
+ uint32_t *bmi_cfg_reg, tmp;
+ bool rx_port;
+
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ bmi_cfg_reg = &port->bmi_regs->rx.fmbm_rcfg;
+ rx_port = TRUE;
+ break;
+ case E_FMAN_PORT_TYPE_TX:
+ case E_FMAN_PORT_TYPE_TX_10G:
+ bmi_cfg_reg = &port->bmi_regs->tx.fmbm_tcfg;
+ rx_port = FALSE;
+ break;
+ case E_FMAN_PORT_TYPE_OP:
+ case E_FMAN_PORT_TYPE_HC:
+ bmi_cfg_reg = &port->bmi_regs->oh.fmbm_ocfg;
+ rx_port = FALSE;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ /* Enable QMI */
+ if (!rx_port) {
+ tmp = ioread32be(&port->qmi_regs->fmqm_pnc) | QMI_PORT_CFG_EN;
+ iowrite32be(tmp, &port->qmi_regs->fmqm_pnc);
+ }
+
+ /* Enable BMI */
+ tmp = ioread32be(bmi_cfg_reg) | BMI_PORT_CFG_EN;
+ iowrite32be(tmp, bmi_cfg_reg);
+
+ return 0;
+}
+
+int fman_port_disable(const struct fman_port *port)
+{
+ uint32_t *bmi_cfg_reg, *bmi_status_reg, tmp;
+ bool rx_port, failure = FALSE;
+ int count;
+
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ bmi_cfg_reg = &port->bmi_regs->rx.fmbm_rcfg;
+ bmi_status_reg = &port->bmi_regs->rx.fmbm_rst;
+ rx_port = TRUE;
+ break;
+ case E_FMAN_PORT_TYPE_TX:
+ case E_FMAN_PORT_TYPE_TX_10G:
+ bmi_cfg_reg = &port->bmi_regs->tx.fmbm_tcfg;
+ bmi_status_reg = &port->bmi_regs->tx.fmbm_tst;
+ rx_port = FALSE;
+ break;
+ case E_FMAN_PORT_TYPE_OP:
+ case E_FMAN_PORT_TYPE_HC:
+ bmi_cfg_reg = &port->bmi_regs->oh.fmbm_ocfg;
+ bmi_status_reg = &port->bmi_regs->oh.fmbm_ost;
+ rx_port = FALSE;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ /* Disable QMI */
+ if (!rx_port) {
+ tmp = ioread32be(&port->qmi_regs->fmqm_pnc) & ~QMI_PORT_CFG_EN;
+ iowrite32be(tmp, &port->qmi_regs->fmqm_pnc);
+
+ /* Wait for QMI to finish FD handling */
+ count = 100;
+ do {
+ DELAY(10);
+ tmp = ioread32be(&port->qmi_regs->fmqm_pns);
+ } while ((tmp & QMI_PORT_STATUS_DEQ_FD_BSY) && --count);
+
+ if (count == 0)
+ {
+ /* Timeout */
+ failure = TRUE;
+ }
+ }
+
+ /* Disable BMI */
+ tmp = ioread32be(bmi_cfg_reg) & ~BMI_PORT_CFG_EN;
+ iowrite32be(tmp, bmi_cfg_reg);
+
+ /* Wait for graceful stop end */
+ count = 500;
+ do {
+ DELAY(10);
+ tmp = ioread32be(bmi_status_reg);
+ } while ((tmp & BMI_PORT_STATUS_BSY) && --count);
+
+ if (count == 0)
+ {
+ /* Timeout */
+ failure = TRUE;
+ }
+
+ if (failure)
+ return -EBUSY;
+
+ return 0;
+}
+
+int fman_port_set_bpools(const struct fman_port *port,
+ const struct fman_port_bpools *bp)
+{
+ uint32_t tmp, *bp_reg, *bp_depl_reg;
+ uint8_t i, max_bp_num;
+ bool grp_depl_used = FALSE, rx_port;
+
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ max_bp_num = port->ext_pools_num;
+ rx_port = TRUE;
+ bp_reg = port->bmi_regs->rx.fmbm_ebmpi;
+ bp_depl_reg = &port->bmi_regs->rx.fmbm_mpd;
+ break;
+ case E_FMAN_PORT_TYPE_OP:
+ if (port->fm_rev_maj != 4)
+ return -EINVAL;
+ max_bp_num = FMAN_PORT_OBS_EXT_POOLS_NUM;
+ rx_port = FALSE;
+ bp_reg = port->bmi_regs->oh.fmbm_oebmpi;
+ bp_depl_reg = &port->bmi_regs->oh.fmbm_ompd;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (rx_port) {
+ /* Check buffers are provided in ascending order */
+ for (i = 0;
+ (i < (bp->count-1) && (i < FMAN_PORT_MAX_EXT_POOLS_NUM - 1));
+ i++) {
+ if (bp->bpool[i].size > bp->bpool[i+1].size)
+ return -EINVAL;
+ }
+ }
+
+ /* Set up external buffers pools */
+ for (i = 0; i < bp->count; i++) {
+ tmp = BMI_EXT_BUF_POOL_VALID;
+ tmp |= ((uint32_t)bp->bpool[i].bpid <<
+ BMI_EXT_BUF_POOL_ID_SHIFT) & BMI_EXT_BUF_POOL_ID_MASK;
+
+ if (rx_port) {
+ if (bp->counters_enable)
+ tmp |= BMI_EXT_BUF_POOL_EN_COUNTER;
+
+ if (bp->bpool[i].is_backup)
+ tmp |= BMI_EXT_BUF_POOL_BACKUP;
+
+ tmp |= (uint32_t)bp->bpool[i].size;
+ }
+
+ iowrite32be(tmp, &bp_reg[i]);
+ }
+
+ /* Clear unused pools */
+ for (i = bp->count; i < max_bp_num; i++)
+ iowrite32be(0, &bp_reg[i]);
+
+ /* Pools depletion */
+ tmp = 0;
+ for (i = 0; i < FMAN_PORT_MAX_EXT_POOLS_NUM; i++) {
+ if (bp->bpool[i].grp_bp_depleted) {
+ grp_depl_used = TRUE;
+ tmp |= 0x80000000 >> i;
+ }
+
+ if (bp->bpool[i].single_bp_depleted)
+ tmp |= 0x80 >> i;
+
+ if (bp->bpool[i].pfc_priorities_en)
+ tmp |= 0x0100 << i;
+ }
+
+ if (grp_depl_used)
+ tmp |= ((uint32_t)bp->grp_bp_depleted_num - 1) <<
+ BMI_POOL_DEP_NUM_OF_POOLS_SHIFT;
+
+ iowrite32be(tmp, bp_depl_reg);
+ return 0;
+}
+
+int fman_port_set_rate_limiter(struct fman_port *port,
+ struct fman_port_rate_limiter *rate_limiter)
+{
+ uint32_t *rate_limit_reg, *rate_limit_scale_reg;
+ uint32_t granularity, tmp;
+ uint8_t usec_bit, factor;
+
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_TX:
+ case E_FMAN_PORT_TYPE_TX_10G:
+ rate_limit_reg = &port->bmi_regs->tx.fmbm_trlmt;
+ rate_limit_scale_reg = &port->bmi_regs->tx.fmbm_trlmts;
+ granularity = BMI_RATE_LIMIT_GRAN_TX;
+ break;
+ case E_FMAN_PORT_TYPE_OP:
+ rate_limit_reg = &port->bmi_regs->oh.fmbm_orlmt;
+ rate_limit_scale_reg = &port->bmi_regs->oh.fmbm_orlmts;
+ granularity = BMI_RATE_LIMIT_GRAN_OP;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ /* Factor is per 1 usec count */
+ factor = 1;
+ usec_bit = rate_limiter->count_1micro_bit;
+
+ /* If rate limit is too small for an 1usec factor, adjust timestamp
+ * scale and multiply the factor */
+ while (rate_limiter->rate < (granularity / factor)) {
+ if (usec_bit == 31)
+ /* Can't configure rate limiter - rate is too small */
+ return -EINVAL;
+
+ usec_bit++;
+ factor <<= 1;
+ }
+
+ /* Figure out register value. The "while" above quarantees that
+ * (rate_limiter->rate * factor / granularity) >= 1 */
+ tmp = (uint32_t)(rate_limiter->rate * factor / granularity - 1);
+
+ /* Check rate limit isn't too large */
+ if (tmp >= BMI_RATE_LIMIT_MAX_RATE_IN_GRAN_UNITS)
+ return -EINVAL;
+
+ /* Check burst size is in allowed range */
+ if ((rate_limiter->burst_size == 0) ||
+ (rate_limiter->burst_size >
+ BMI_RATE_LIMIT_MAX_BURST_SIZE))
+ return -EINVAL;
+
+ tmp |= (uint32_t)(rate_limiter->burst_size - 1) <<
+ BMI_RATE_LIMIT_MAX_BURST_SHIFT;
+
+ if ((port->type == E_FMAN_PORT_TYPE_OP) &&
+ (port->fm_rev_maj == 4)) {
+ if (rate_limiter->high_burst_size_gran)
+ tmp |= BMI_RATE_LIMIT_HIGH_BURST_SIZE_GRAN;
+ }
+
+ iowrite32be(tmp, rate_limit_reg);
+
+ /* Set up rate limiter scale register */
+ tmp = BMI_RATE_LIMIT_SCALE_EN;
+ tmp |= (31 - (uint32_t)usec_bit) << BMI_RATE_LIMIT_SCALE_TSBS_SHIFT;
+
+ if ((port->type == E_FMAN_PORT_TYPE_OP) &&
+ (port->fm_rev_maj == 4))
+ tmp |= rate_limiter->rate_factor;
+
+ iowrite32be(tmp, rate_limit_scale_reg);
+
+ return 0;
+}
+
+int fman_port_delete_rate_limiter(struct fman_port *port)
+{
+ uint32_t *rate_limit_scale_reg;
+
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_TX:
+ case E_FMAN_PORT_TYPE_TX_10G:
+ rate_limit_scale_reg = &port->bmi_regs->tx.fmbm_trlmts;
+ break;
+ case E_FMAN_PORT_TYPE_OP:
+ rate_limit_scale_reg = &port->bmi_regs->oh.fmbm_orlmts;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ iowrite32be(0, rate_limit_scale_reg);
+ return 0;
+}
+
+int fman_port_set_err_mask(struct fman_port *port, uint32_t err_mask)
+{
+ uint32_t *err_mask_reg;
+
+ /* Obtain register address */
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ err_mask_reg = &port->bmi_regs->rx.fmbm_rfsem;
+ break;
+ case E_FMAN_PORT_TYPE_OP:
+ err_mask_reg = &port->bmi_regs->oh.fmbm_ofsem;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ iowrite32be(err_mask, err_mask_reg);
+ return 0;
+}
+
+int fman_port_set_discard_mask(struct fman_port *port, uint32_t discard_mask)
+{
+ uint32_t *discard_mask_reg;
+
+ /* Obtain register address */
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ discard_mask_reg = &port->bmi_regs->rx.fmbm_rfsdm;
+ break;
+ case E_FMAN_PORT_TYPE_OP:
+ discard_mask_reg = &port->bmi_regs->oh.fmbm_ofsdm;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ iowrite32be(discard_mask, discard_mask_reg);
+ return 0;
+}
+
+int fman_port_modify_rx_fd_bits(struct fman_port *port,
+ uint8_t rx_fd_bits,
+ bool add)
+{
+ uint32_t tmp;
+
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ tmp = ioread32be(&port->bmi_regs->rx.fmbm_rfne);
+
+ if (add)
+ tmp |= (uint32_t)rx_fd_bits << BMI_NEXT_ENG_FD_BITS_SHIFT;
+ else
+ tmp &= ~((uint32_t)rx_fd_bits << BMI_NEXT_ENG_FD_BITS_SHIFT);
+
+ iowrite32be(tmp, &port->bmi_regs->rx.fmbm_rfne);
+ return 0;
+}
+
+int fman_port_set_perf_cnt_params(struct fman_port *port,
+ struct fman_port_perf_cnt_params *params)
+{
+ uint32_t *pcp_reg, tmp;
+
+ /* Obtain register address and check parameters are in range */
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ pcp_reg = &port->bmi_regs->rx.fmbm_rpcp;
+ if ((params->queue_val == 0) ||
+ (params->queue_val > MAX_PERFORMANCE_RX_QUEUE_COMP))
+ return -EINVAL;
+ break;
+ case E_FMAN_PORT_TYPE_TX:
+ case E_FMAN_PORT_TYPE_TX_10G:
+ pcp_reg = &port->bmi_regs->tx.fmbm_tpcp;
+ if ((params->queue_val == 0) ||
+ (params->queue_val > MAX_PERFORMANCE_TX_QUEUE_COMP))
+ return -EINVAL;
+ break;
+ case E_FMAN_PORT_TYPE_OP:
+ case E_FMAN_PORT_TYPE_HC:
+ pcp_reg = &port->bmi_regs->oh.fmbm_opcp;
+ if (params->queue_val != 0)
+ return -EINVAL;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if ((params->task_val == 0) ||
+ (params->task_val > MAX_PERFORMANCE_TASK_COMP))
+ return -EINVAL;
+ if ((params->dma_val == 0) ||
+ (params->dma_val > MAX_PERFORMANCE_DMA_COMP))
+ return -EINVAL;
+ if ((params->fifo_val == 0) ||
+ ((params->fifo_val / FMAN_PORT_BMI_FIFO_UNITS) >
+ MAX_PERFORMANCE_FIFO_COMP))
+ return -EINVAL;
+ tmp = (uint32_t)(params->task_val - 1) <<
+ BMI_PERFORMANCE_TASK_COMP_SHIFT;
+ tmp |= (uint32_t)(params->dma_val - 1) <<
+ BMI_PERFORMANCE_DMA_COMP_SHIFT;
+ tmp |= (uint32_t)(params->fifo_val / FMAN_PORT_BMI_FIFO_UNITS - 1);
+
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ case E_FMAN_PORT_TYPE_TX:
+ case E_FMAN_PORT_TYPE_TX_10G:
+ tmp |= (uint32_t)(params->queue_val - 1) <<
+ BMI_PERFORMANCE_QUEUE_COMP_SHIFT;
+ break;
+ default:
+ break;
+ }
+
+
+ iowrite32be(tmp, pcp_reg);
+ return 0;
+}
+
+int fman_port_set_stats_cnt_mode(struct fman_port *port, bool enable)
+{
+ uint32_t *stats_reg, tmp;
+
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ stats_reg = &port->bmi_regs->rx.fmbm_rstc;
+ break;
+ case E_FMAN_PORT_TYPE_TX:
+ case E_FMAN_PORT_TYPE_TX_10G:
+ stats_reg = &port->bmi_regs->tx.fmbm_tstc;
+ break;
+ case E_FMAN_PORT_TYPE_OP:
+ case E_FMAN_PORT_TYPE_HC:
+ stats_reg = &port->bmi_regs->oh.fmbm_ostc;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ tmp = ioread32be(stats_reg);
+
+ if (enable)
+ tmp |= BMI_COUNTERS_EN;
+ else
+ tmp &= ~BMI_COUNTERS_EN;
+
+ iowrite32be(tmp, stats_reg);
+ return 0;
+}
+
+int fman_port_set_perf_cnt_mode(struct fman_port *port, bool enable)
+{
+ uint32_t *stats_reg, tmp;
+
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ stats_reg = &port->bmi_regs->rx.fmbm_rpc;
+ break;
+ case E_FMAN_PORT_TYPE_TX:
+ case E_FMAN_PORT_TYPE_TX_10G:
+ stats_reg = &port->bmi_regs->tx.fmbm_tpc;
+ break;
+ case E_FMAN_PORT_TYPE_OP:
+ case E_FMAN_PORT_TYPE_HC:
+ stats_reg = &port->bmi_regs->oh.fmbm_opc;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ tmp = ioread32be(stats_reg);
+
+ if (enable)
+ tmp |= BMI_COUNTERS_EN;
+ else
+ tmp &= ~BMI_COUNTERS_EN;
+
+ iowrite32be(tmp, stats_reg);
+ return 0;
+}
+
+int fman_port_set_queue_cnt_mode(struct fman_port *port, bool enable)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&port->qmi_regs->fmqm_pnc);
+
+ if (enable)
+ tmp |= QMI_PORT_CFG_EN_COUNTERS;
+ else
+ tmp &= ~QMI_PORT_CFG_EN_COUNTERS;
+
+ iowrite32be(tmp, &port->qmi_regs->fmqm_pnc);
+ return 0;
+}
+
+int fman_port_set_bpool_cnt_mode(struct fman_port *port,
+ uint8_t bpid,
+ bool enable)
+{
+ uint8_t index;
+ uint32_t tmp;
+
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ /* Find the pool */
+ index = fman_port_find_bpool(port, bpid);
+ if (index == port->ext_pools_num || index == FMAN_PORT_MAX_EXT_POOLS_NUM)
+ /* Not found */
+ return -EINVAL;
+
+ tmp = ioread32be(&port->bmi_regs->rx.fmbm_ebmpi[index]);
+
+ if (enable)
+ tmp |= BMI_EXT_BUF_POOL_EN_COUNTER;
+ else
+ tmp &= ~BMI_EXT_BUF_POOL_EN_COUNTER;
+
+ iowrite32be(tmp, &port->bmi_regs->rx.fmbm_ebmpi[index]);
+ return 0;
+}
+
+uint32_t fman_port_get_stats_counter(struct fman_port *port,
+ enum fman_port_stats_counters counter)
+{
+ uint32_t *stats_reg, ret_val;
+
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ get_rx_stats_reg(port, counter, &stats_reg);
+ break;
+ case E_FMAN_PORT_TYPE_TX:
+ case E_FMAN_PORT_TYPE_TX_10G:
+ get_tx_stats_reg(port, counter, &stats_reg);
+ break;
+ case E_FMAN_PORT_TYPE_OP:
+ case E_FMAN_PORT_TYPE_HC:
+ get_oh_stats_reg(port, counter, &stats_reg);
+ break;
+ default:
+ stats_reg = NULL;
+ }
+
+ if (stats_reg == NULL)
+ return 0;
+
+ ret_val = ioread32be(stats_reg);
+ return ret_val;
+}
+
+void fman_port_set_stats_counter(struct fman_port *port,
+ enum fman_port_stats_counters counter,
+ uint32_t value)
+{
+ uint32_t *stats_reg;
+
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ get_rx_stats_reg(port, counter, &stats_reg);
+ break;
+ case E_FMAN_PORT_TYPE_TX:
+ case E_FMAN_PORT_TYPE_TX_10G:
+ get_tx_stats_reg(port, counter, &stats_reg);
+ break;
+ case E_FMAN_PORT_TYPE_OP:
+ case E_FMAN_PORT_TYPE_HC:
+ get_oh_stats_reg(port, counter, &stats_reg);
+ break;
+ default:
+ stats_reg = NULL;
+ }
+
+ if (stats_reg == NULL)
+ return;
+
+ iowrite32be(value, stats_reg);
+}
+
+uint32_t fman_port_get_perf_counter(struct fman_port *port,
+ enum fman_port_perf_counters counter)
+{
+ uint32_t *perf_reg, ret_val;
+
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ get_rx_perf_reg(port, counter, &perf_reg);
+ break;
+ case E_FMAN_PORT_TYPE_TX:
+ case E_FMAN_PORT_TYPE_TX_10G:
+ get_tx_perf_reg(port, counter, &perf_reg);
+ break;
+ case E_FMAN_PORT_TYPE_OP:
+ case E_FMAN_PORT_TYPE_HC:
+ get_oh_perf_reg(port, counter, &perf_reg);
+ break;
+ default:
+ perf_reg = NULL;
+ }
+
+ if (perf_reg == NULL)
+ return 0;
+
+ ret_val = ioread32be(perf_reg);
+ return ret_val;
+}
+
+void fman_port_set_perf_counter(struct fman_port *port,
+ enum fman_port_perf_counters counter,
+ uint32_t value)
+{
+ uint32_t *perf_reg;
+
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ get_rx_perf_reg(port, counter, &perf_reg);
+ break;
+ case E_FMAN_PORT_TYPE_TX:
+ case E_FMAN_PORT_TYPE_TX_10G:
+ get_tx_perf_reg(port, counter, &perf_reg);
+ break;
+ case E_FMAN_PORT_TYPE_OP:
+ case E_FMAN_PORT_TYPE_HC:
+ get_oh_perf_reg(port, counter, &perf_reg);
+ break;
+ default:
+ perf_reg = NULL;
+ }
+
+ if (perf_reg == NULL)
+ return;
+
+ iowrite32be(value, perf_reg);
+}
+
+uint32_t fman_port_get_qmi_counter(struct fman_port *port,
+ enum fman_port_qmi_counters counter)
+{
+ uint32_t *queue_reg, ret_val;
+
+ get_qmi_counter_reg(port, counter, &queue_reg);
+
+ if (queue_reg == NULL)
+ return 0;
+
+ ret_val = ioread32be(queue_reg);
+ return ret_val;
+}
+
+void fman_port_set_qmi_counter(struct fman_port *port,
+ enum fman_port_qmi_counters counter,
+ uint32_t value)
+{
+ uint32_t *queue_reg;
+
+ get_qmi_counter_reg(port, counter, &queue_reg);
+
+ if (queue_reg == NULL)
+ return;
+
+ iowrite32be(value, queue_reg);
+}
+
+uint32_t fman_port_get_bpool_counter(struct fman_port *port, uint8_t bpid)
+{
+ uint8_t index;
+ uint32_t ret_val;
+
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ break;
+ default:
+ return 0;
+ }
+
+ /* Find the pool */
+ index = fman_port_find_bpool(port, bpid);
+ if (index == port->ext_pools_num || index == FMAN_PORT_MAX_EXT_POOLS_NUM)
+ /* Not found */
+ return 0;
+
+ ret_val = ioread32be(&port->bmi_regs->rx.fmbm_acnt[index]);
+ return ret_val;
+}
+
+void fman_port_set_bpool_counter(struct fman_port *port,
+ uint8_t bpid,
+ uint32_t value)
+{
+ uint8_t index;
+
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ break;
+ default:
+ return;
+ }
+
+ /* Find the pool */
+ index = fman_port_find_bpool(port, bpid);
+ if (index == port->ext_pools_num || index == FMAN_PORT_MAX_EXT_POOLS_NUM)
+ /* Not found */
+ return;
+
+ iowrite32be(value, &port->bmi_regs->rx.fmbm_acnt[index]);
+}
+
+int fman_port_add_congestion_grps(struct fman_port *port,
+ uint32_t grps_map[FMAN_PORT_CG_MAP_NUM])
+{
+ int i;
+ uint32_t tmp, *grp_map_reg;
+ uint8_t max_grp_map_num;
+
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ if (port->fm_rev_maj == 4)
+ max_grp_map_num = 1;
+ else
+ max_grp_map_num = FMAN_PORT_CG_MAP_NUM;
+ grp_map_reg = port->bmi_regs->rx.fmbm_rcgm;
+ break;
+ case E_FMAN_PORT_TYPE_OP:
+ max_grp_map_num = 1;
+ if (port->fm_rev_maj != 4)
+ return -EINVAL;
+ grp_map_reg = port->bmi_regs->oh.fmbm_ocgm;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ for (i = (max_grp_map_num - 1); i >= 0; i--) {
+ if (grps_map[i] == 0)
+ continue;
+ tmp = ioread32be(&grp_map_reg[i]);
+ tmp |= grps_map[i];
+ iowrite32be(tmp, &grp_map_reg[i]);
+ }
+
+ return 0;
+}
+
+int fman_port_remove_congestion_grps(struct fman_port *port,
+ uint32_t grps_map[FMAN_PORT_CG_MAP_NUM])
+{
+ int i;
+ uint32_t tmp, *grp_map_reg;
+ uint8_t max_grp_map_num;
+
+ switch (port->type) {
+ case E_FMAN_PORT_TYPE_RX:
+ case E_FMAN_PORT_TYPE_RX_10G:
+ if (port->fm_rev_maj == 4)
+ max_grp_map_num = 1;
+ else
+ max_grp_map_num = FMAN_PORT_CG_MAP_NUM;
+ grp_map_reg = port->bmi_regs->rx.fmbm_rcgm;
+ break;
+ case E_FMAN_PORT_TYPE_OP:
+ max_grp_map_num = 1;
+ if (port->fm_rev_maj != 4)
+ return -EINVAL;
+ grp_map_reg = port->bmi_regs->oh.fmbm_ocgm;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ for (i = (max_grp_map_num - 1); i >= 0; i--) {
+ if (grps_map[i] == 0)
+ continue;
+ tmp = ioread32be(&grp_map_reg[i]);
+ tmp &= ~grps_map[i];
+ iowrite32be(tmp, &grp_map_reg[i]);
+ }
+ return 0;
+}
diff --git a/sys/contrib/ncsw/Peripherals/FM/Rtc/fm_rtc.c b/sys/contrib/ncsw/Peripherals/FM/Rtc/fm_rtc.c
index 13ac04793929..99de427b3ae8 100644
--- a/sys/contrib/ncsw/Peripherals/FM/Rtc/fm_rtc.c
+++ b/sys/contrib/ncsw/Peripherals/FM/Rtc/fm_rtc.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm_rtc.c
@@ -37,7 +38,7 @@
@Cautions None
*//***************************************************************************/
-
+#include <linux/math64.h>
#include "error_ext.h"
#include "debug_ext.h"
#include "string_ext.h"
@@ -49,38 +50,16 @@
#include "fm_common.h"
-/*****************************************************************************/
-static void SetDefaultParam(t_FmRtc *p_Rtc)
-{
- t_FmRtcDriverParam *p_RtcDriverParam = p_Rtc->p_RtcDriverParam;
- int i;
-
- p_Rtc->outputClockDivisor = DEFAULT_outputClockDivisor;
- p_Rtc->p_RtcDriverParam->bypass = DEFAULT_bypass;
- p_RtcDriverParam->srcClk = DEFAULT_srcClock;
- p_RtcDriverParam->invertInputClkPhase = DEFAULT_invertInputClkPhase;
- p_RtcDriverParam->invertOutputClkPhase = DEFAULT_invertOutputClkPhase;
- p_RtcDriverParam->pulseRealign = DEFAULT_pulseRealign;
- for (i=0; i < FM_RTC_NUM_OF_ALARMS; i++)
- {
- p_RtcDriverParam->alarmPolarity[i] = DEFAULT_alarmPolarity;
- }
- for (i=0; i < FM_RTC_NUM_OF_EXT_TRIGGERS; i++)
- {
- p_RtcDriverParam->triggerPolarity[i] = DEFAULT_triggerPolarity;
- }
- p_Rtc->clockPeriodNanoSec = DEFAULT_clockPeriod; /* 1 usec */
-}
/*****************************************************************************/
static t_Error CheckInitParameters(t_FmRtc *p_Rtc)
{
- t_FmRtcDriverParam *p_RtcDriverParam = p_Rtc->p_RtcDriverParam;
+ struct rtc_cfg *p_RtcDriverParam = p_Rtc->p_RtcDriverParam;
int i;
- if ((p_RtcDriverParam->srcClk != e_FM_RTC_SOURCE_CLOCK_EXTERNAL) &&
- (p_RtcDriverParam->srcClk != e_FM_RTC_SOURCE_CLOCK_SYSTEM) &&
- (p_RtcDriverParam->srcClk != e_FM_RTC_SOURCE_CLOCK_OSCILATOR))
+ if ((p_RtcDriverParam->src_clk != E_FMAN_RTC_SOURCE_CLOCK_EXTERNAL) &&
+ (p_RtcDriverParam->src_clk != E_FMAN_RTC_SOURCE_CLOCK_SYSTEM) &&
+ (p_RtcDriverParam->src_clk != E_FMAN_RTC_SOURCE_CLOCK_OSCILATOR))
RETURN_ERROR(MAJOR, E_INVALID_CLOCK, ("Source clock undefined"));
if (p_Rtc->outputClockDivisor == 0)
@@ -91,31 +70,21 @@ static t_Error CheckInitParameters(t_FmRtc *p_Rtc)
for (i=0; i < FM_RTC_NUM_OF_ALARMS; i++)
{
- if ((p_RtcDriverParam->alarmPolarity[i] != e_FM_RTC_ALARM_POLARITY_ACTIVE_LOW) &&
- (p_RtcDriverParam->alarmPolarity[i] != e_FM_RTC_ALARM_POLARITY_ACTIVE_HIGH))
+ if ((p_RtcDriverParam->alarm_polarity[i] != E_FMAN_RTC_ALARM_POLARITY_ACTIVE_LOW) &&
+ (p_RtcDriverParam->alarm_polarity[i] != E_FMAN_RTC_ALARM_POLARITY_ACTIVE_HIGH))
{
RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Alarm %d signal polarity", i));
}
}
for (i=0; i < FM_RTC_NUM_OF_EXT_TRIGGERS; i++)
{
- if ((p_RtcDriverParam->triggerPolarity[i] != e_FM_RTC_TRIGGER_ON_FALLING_EDGE) &&
- (p_RtcDriverParam->triggerPolarity[i] != e_FM_RTC_TRIGGER_ON_RISING_EDGE))
+ if ((p_RtcDriverParam->trigger_polarity[i] != E_FMAN_RTC_TRIGGER_ON_FALLING_EDGE) &&
+ (p_RtcDriverParam->trigger_polarity[i] != E_FMAN_RTC_TRIGGER_ON_RISING_EDGE))
{
RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Trigger %d signal polarity", i));
}
}
-#ifdef FM_1588_SRC_CLK_ERRATA_FMAN1
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_Rtc->h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0)&&
- ((p_RtcDriverParam->srcClk==e_FM_RTC_SOURCE_CLOCK_SYSTEM) && p_RtcDriverParam->invertInputClkPhase))
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Can not use invertInputClkPhase when source clock is e_FM_RTC_SOURCE_CLOCK_SYSTEM"));
- }
-#endif /* FM_1588_SRC_CLK_ERRATA_FMAN1 */
-
return E_OK;
}
@@ -123,55 +92,49 @@ static t_Error CheckInitParameters(t_FmRtc *p_Rtc)
static void RtcExceptions(t_Handle h_FmRtc)
{
t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
- t_FmRtcMemMap *p_MemMap;
+ struct rtc_regs *p_MemMap;
register uint32_t events;
ASSERT_COND(p_Rtc);
p_MemMap = p_Rtc->p_MemMap;
- /* Get valid events */
- events = GET_UINT32(p_MemMap->tmr_tevent);
- events &= GET_UINT32(p_MemMap->tmr_temask);
-
- /* Clear event bits */
- WRITE_UINT32(p_MemMap->tmr_tevent, events);
-
- if (events & TMR_TEVENT_ALM1)
+ events = fman_rtc_check_and_clear_event(p_MemMap);
+ if (events & FMAN_RTC_TMR_TEVENT_ALM1)
{
- if(p_Rtc->alarmParams[0].clearOnExpiration)
+ if (p_Rtc->alarmParams[0].clearOnExpiration)
{
- WRITE_UINT32(p_MemMap->tmr_alarm[0].tmr_alarm_l, 0);
- WRITE_UINT32(p_MemMap->tmr_temask, GET_UINT32(p_MemMap->tmr_temask) & ~TMR_TEVENT_ALM1);
+ fman_rtc_set_timer_alarm_l(p_MemMap, 0, 0);
+ fman_rtc_disable_interupt(p_MemMap, FMAN_RTC_TMR_TEVENT_ALM1);
}
ASSERT_COND(p_Rtc->alarmParams[0].f_AlarmCallback);
p_Rtc->alarmParams[0].f_AlarmCallback(p_Rtc->h_App, 0);
}
- if (events & TMR_TEVENT_ALM2)
+ if (events & FMAN_RTC_TMR_TEVENT_ALM2)
{
- if(p_Rtc->alarmParams[1].clearOnExpiration)
+ if (p_Rtc->alarmParams[1].clearOnExpiration)
{
- WRITE_UINT32(p_MemMap->tmr_alarm[1].tmr_alarm_l, 0);
- WRITE_UINT32(p_MemMap->tmr_temask, GET_UINT32(p_MemMap->tmr_temask) & ~TMR_TEVENT_ALM2);
+ fman_rtc_set_timer_alarm_l(p_MemMap, 1, 0);
+ fman_rtc_disable_interupt(p_MemMap, FMAN_RTC_TMR_TEVENT_ALM2);
}
ASSERT_COND(p_Rtc->alarmParams[1].f_AlarmCallback);
p_Rtc->alarmParams[1].f_AlarmCallback(p_Rtc->h_App, 1);
}
- if (events & TMR_TEVENT_PP1)
+ if (events & FMAN_RTC_TMR_TEVENT_PP1)
{
ASSERT_COND(p_Rtc->periodicPulseParams[0].f_PeriodicPulseCallback);
p_Rtc->periodicPulseParams[0].f_PeriodicPulseCallback(p_Rtc->h_App, 0);
}
- if (events & TMR_TEVENT_PP2)
+ if (events & FMAN_RTC_TMR_TEVENT_PP2)
{
ASSERT_COND(p_Rtc->periodicPulseParams[1].f_PeriodicPulseCallback);
p_Rtc->periodicPulseParams[1].f_PeriodicPulseCallback(p_Rtc->h_App, 1);
}
- if (events & TMR_TEVENT_ETS1)
+ if (events & FMAN_RTC_TMR_TEVENT_ETS1)
{
ASSERT_COND(p_Rtc->externalTriggerParams[0].f_ExternalTriggerCallback);
p_Rtc->externalTriggerParams[0].f_ExternalTriggerCallback(p_Rtc->h_App, 0);
}
- if (events & TMR_TEVENT_ETS2)
+ if (events & FMAN_RTC_TMR_TEVENT_ETS2)
{
ASSERT_COND(p_Rtc->externalTriggerParams[1].f_ExternalTriggerCallback);
p_Rtc->externalTriggerParams[1].f_ExternalTriggerCallback(p_Rtc->h_App, 1);
@@ -197,7 +160,7 @@ t_Handle FM_RTC_Config(t_FmRtcParams *p_FmRtcParam)
memset(p_Rtc, 0, sizeof(t_FmRtc));
/* Allocate memory for the FM RTC driver parameters */
- p_Rtc->p_RtcDriverParam = (t_FmRtcDriverParam *)XX_Malloc(sizeof(t_FmRtcDriverParam));
+ p_Rtc->p_RtcDriverParam = (struct rtc_cfg *)XX_Malloc(sizeof(struct rtc_cfg));
if (!p_Rtc->p_RtcDriverParam)
{
REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM RTC driver parameters"));
@@ -205,16 +168,21 @@ t_Handle FM_RTC_Config(t_FmRtcParams *p_FmRtcParam)
return NULL;
}
- memset(p_Rtc->p_RtcDriverParam, 0, sizeof(t_FmRtcDriverParam));
+ memset(p_Rtc->p_RtcDriverParam, 0, sizeof(struct rtc_cfg));
/* Store RTC configuration parameters */
p_Rtc->h_Fm = p_FmRtcParam->h_Fm;
/* Set default RTC configuration parameters */
- SetDefaultParam(p_Rtc);
+ fman_rtc_defconfig(p_Rtc->p_RtcDriverParam);
+
+ p_Rtc->outputClockDivisor = DEFAULT_OUTPUT_CLOCK_DIVISOR;
+ p_Rtc->p_RtcDriverParam->bypass = DEFAULT_BYPASS;
+ p_Rtc->clockPeriodNanoSec = DEFAULT_CLOCK_PERIOD; /* 1 usec */
+
/* Store RTC parameters in the RTC control structure */
- p_Rtc->p_MemMap = (t_FmRtcMemMap *)UINT_TO_PTR(p_FmRtcParam->baseAddress);
+ p_Rtc->p_MemMap = (struct rtc_regs *)UINT_TO_PTR(p_FmRtcParam->baseAddress);
p_Rtc->h_App = p_FmRtcParam->h_App;
return p_Rtc;
@@ -224,119 +192,57 @@ t_Handle FM_RTC_Config(t_FmRtcParams *p_FmRtcParam)
t_Error FM_RTC_Init(t_Handle h_FmRtc)
{
t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
- t_FmRtcDriverParam *p_RtcDriverParam;
- t_FmRtcMemMap *p_MemMap;
- uint32_t freqCompensation;
- uint32_t tmrCtrl;
- int i;
+ struct rtc_cfg *p_RtcDriverParam;
+ struct rtc_regs *p_MemMap;
+ uint32_t freqCompensation = 0;
uint64_t tmpDouble;
+ bool init_freq_comp = FALSE;
p_RtcDriverParam = p_Rtc->p_RtcDriverParam;
p_MemMap = p_Rtc->p_MemMap;
- if(CheckInitParameters(p_Rtc)!=E_OK)
+ if (CheckInitParameters(p_Rtc)!=E_OK)
RETURN_ERROR(MAJOR, E_CONFLICT,
("Init Parameters are not Valid"));
- /* TODO A check must be added here, that no timestamping MAC's
- * are working in this stage. */
- WRITE_UINT32(p_MemMap->tmr_ctrl, TMR_CTRL_TMSR);
- XX_UDelay(10);
- WRITE_UINT32(p_MemMap->tmr_ctrl, 0);
-
- /* Set the source clock */
- switch (p_RtcDriverParam->srcClk)
- {
- case e_FM_RTC_SOURCE_CLOCK_SYSTEM:
- tmrCtrl = TMR_CTRL_CKSEL_MAC_CLK;
- break;
- case e_FM_RTC_SOURCE_CLOCK_OSCILATOR:
- tmrCtrl = TMR_CTRL_CKSEL_OSC_CLK;
- break;
- default:
- /* Use a clock from the External TMR reference clock.*/
- tmrCtrl = TMR_CTRL_CKSEL_EXT_CLK;
- break;
- }
-
- /* whatever period the user picked, the timestamp will advance in '1' every time
- * the period passed. */
- tmrCtrl |= ((1 << TMR_CTRL_TCLK_PERIOD_SHIFT) & TMR_CTRL_TCLK_PERIOD_MASK);
-
- if (p_RtcDriverParam->invertInputClkPhase)
- tmrCtrl |= TMR_CTRL_CIPH;
- if (p_RtcDriverParam->invertOutputClkPhase)
- tmrCtrl |= TMR_CTRL_COPH;
-
- for (i=0; i < FM_RTC_NUM_OF_ALARMS; i++)
- {
- if (p_RtcDriverParam->alarmPolarity[i] == e_FM_RTC_ALARM_POLARITY_ACTIVE_LOW)
- tmrCtrl |= (TMR_CTRL_ALMP1 >> i);
- }
-
- for (i=0; i < FM_RTC_NUM_OF_EXT_TRIGGERS; i++)
- if (p_RtcDriverParam->triggerPolarity[i] == e_FM_RTC_TRIGGER_ON_FALLING_EDGE)
- tmrCtrl |= (TMR_CTRL_ETEP1 << i);
-
- if (!p_RtcDriverParam->timerSlaveMode && p_Rtc->p_RtcDriverParam->bypass)
- tmrCtrl |= TMR_CTRL_BYP;
-
- WRITE_UINT32(p_MemMap->tmr_ctrl, tmrCtrl);
-
- for (i=0; i < FM_RTC_NUM_OF_ALARMS; i++)
- {
- /* Clear TMR_ALARM registers */
- WRITE_UINT32(p_MemMap->tmr_alarm[i].tmr_alarm_l, 0xFFFFFFFF);
- WRITE_UINT32(p_MemMap->tmr_alarm[i].tmr_alarm_h, 0xFFFFFFFF);
- }
-
- /* Clear TMR_TEVENT */
- WRITE_UINT32(p_MemMap->tmr_tevent, TMR_TEVENT_ALL);
-
- /* Initialize TMR_TEMASK */
- WRITE_UINT32(p_MemMap->tmr_temask, 0);
-
+ /* TODO check that no timestamping MACs are working in this stage. */
/* find source clock frequency in Mhz */
- if (p_Rtc->p_RtcDriverParam->srcClk != e_FM_RTC_SOURCE_CLOCK_SYSTEM)
- p_Rtc->srcClkFreqMhz = p_Rtc->p_RtcDriverParam->extSrcClkFreq;
+ if (p_Rtc->p_RtcDriverParam->src_clk != E_FMAN_RTC_SOURCE_CLOCK_SYSTEM)
+ p_Rtc->srcClkFreqMhz = p_Rtc->p_RtcDriverParam->ext_src_clk_freq;
else
- p_Rtc->srcClkFreqMhz = (uint32_t)(FmGetClockFreq(p_Rtc->h_Fm)/2);
+ p_Rtc->srcClkFreqMhz = (uint32_t)(FmGetMacClockFreq(p_Rtc->h_Fm));
/* if timer in Master mode Initialize TMR_CTRL */
/* We want the counter (TMR_CNT) to count in nano-seconds */
- if (!p_RtcDriverParam->timerSlaveMode && p_Rtc->p_RtcDriverParam->bypass)
- {
+ if (!p_RtcDriverParam->timer_slave_mode && p_Rtc->p_RtcDriverParam->bypass)
p_Rtc->clockPeriodNanoSec = (1000 / p_Rtc->srcClkFreqMhz);
- }
else
{
/* Initialize TMR_ADD with the initial frequency compensation value:
freqCompensation = (2^32 / frequency ratio) */
/* frequency ratio = sorce clock/rtc clock =
* (p_Rtc->srcClkFreqMhz*1000000))/ 1/(p_Rtc->clockPeriodNanoSec * 1000000000) */
+ init_freq_comp = TRUE;
freqCompensation = (uint32_t)DIV_CEIL(ACCUMULATOR_OVERFLOW * 1000,
- p_Rtc->clockPeriodNanoSec * p_Rtc->srcClkFreqMhz);
- WRITE_UINT32(p_MemMap->tmr_add, freqCompensation);
+ p_Rtc->clockPeriodNanoSec * p_Rtc->srcClkFreqMhz);
}
+
/* check the legality of the relation between source and destination clocks */
/* should be larger than 1.0001 */
tmpDouble = 10000 * (uint64_t)p_Rtc->clockPeriodNanoSec * (uint64_t)p_Rtc->srcClkFreqMhz;
- if((tmpDouble) <= 10001)
+ if ((tmpDouble) <= 10001)
RETURN_ERROR(MAJOR, E_CONFLICT,
("Invalid relation between source and destination clocks. Should be larger than 1.0001"));
-
- for (i=0; i < 2; i++)
- /* Clear TMR_FIPER registers */
- WRITE_UINT32(p_MemMap->tmr_fiper[i], 0xFFFFFFFF);
-
- /* Initialize TMR_PRSC */
- WRITE_UINT32(p_MemMap->tmr_prsc, p_Rtc->outputClockDivisor);
-
- /* Clear TMR_OFF */
- WRITE_UINT32(p_MemMap->tmr_off_l, 0);
- WRITE_UINT32(p_MemMap->tmr_off_h, 0);
+ fman_rtc_init(p_RtcDriverParam,
+ p_MemMap,
+ FM_RTC_NUM_OF_ALARMS,
+ FM_RTC_NUM_OF_PERIODIC_PULSES,
+ FM_RTC_NUM_OF_EXT_TRIGGERS,
+ init_freq_comp,
+ freqCompensation,
+ p_Rtc->outputClockDivisor);
/* Register the FM RTC interrupt */
FmRegisterIntr(p_Rtc->h_Fm, e_FM_MOD_TMR, 0, e_FM_INTR_TYPE_NORMAL, RtcExceptions , p_Rtc);
@@ -381,9 +287,9 @@ t_Error FM_RTC_ConfigSourceClock(t_Handle h_FmRtc,
SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
- p_Rtc->p_RtcDriverParam->srcClk = srcClk;
- if(srcClk != e_FM_RTC_SOURCE_CLOCK_SYSTEM)
- p_Rtc->p_RtcDriverParam->extSrcClkFreq = freqInMhz;
+ p_Rtc->p_RtcDriverParam->src_clk = (enum fman_src_clock)srcClk;
+ if (srcClk != e_FM_RTC_SOURCE_CLOCK_SYSTEM)
+ p_Rtc->p_RtcDriverParam->ext_src_clk_freq = freqInMhz;
return E_OK;
}
@@ -422,7 +328,7 @@ t_Error FM_RTC_ConfigInvertedInputClockPhase(t_Handle h_FmRtc, bool inverted)
SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
- p_Rtc->p_RtcDriverParam->invertInputClkPhase = inverted;
+ p_Rtc->p_RtcDriverParam->invert_input_clk_phase = inverted;
return E_OK;
}
@@ -435,7 +341,7 @@ t_Error FM_RTC_ConfigInvertedOutputClockPhase(t_Handle h_FmRtc, bool inverted)
SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
- p_Rtc->p_RtcDriverParam->invertOutputClkPhase = inverted;
+ p_Rtc->p_RtcDriverParam->invert_output_clk_phase = inverted;
return E_OK;
}
@@ -461,7 +367,7 @@ t_Error FM_RTC_ConfigPulseRealignment(t_Handle h_FmRtc, bool enable)
SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
- p_Rtc->p_RtcDriverParam->pulseRealign = enable;
+ p_Rtc->p_RtcDriverParam->pulse_realign = enable;
return E_OK;
}
@@ -477,11 +383,10 @@ t_Error FM_RTC_ConfigAlarmPolarity(t_Handle h_FmRtc,
SANITY_CHECK_RETURN_ERROR(p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
if (alarmId >= FM_RTC_NUM_OF_ALARMS)
- {
RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Alarm ID"));
- }
- p_Rtc->p_RtcDriverParam->alarmPolarity[alarmId] = alarmPolarity;
+ p_Rtc->p_RtcDriverParam->alarm_polarity[alarmId] =
+ (enum fman_rtc_alarm_polarity)alarmPolarity;
return E_OK;
}
@@ -501,7 +406,8 @@ t_Error FM_RTC_ConfigExternalTriggerPolarity(t_Handle h_FmRtc,
RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("External trigger ID"));
}
- p_Rtc->p_RtcDriverParam->triggerPolarity[triggerId] = triggerPolarity;
+ p_Rtc->p_RtcDriverParam->trigger_polarity[triggerId] =
+ (enum fman_rtc_trigger_polarity)triggerPolarity;
return E_OK;
}
@@ -510,27 +416,11 @@ t_Error FM_RTC_ConfigExternalTriggerPolarity(t_Handle h_FmRtc,
t_Error FM_RTC_Enable(t_Handle h_FmRtc, bool resetClock)
{
t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
- uint32_t tmrCtrl;
SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
- tmrCtrl = GET_UINT32(p_Rtc->p_MemMap->tmr_ctrl);
-
- /* TODO A check must be added here, that no timestamping MAC's
- * are working in this stage. */
- if (resetClock)
- {
- WRITE_UINT32(p_Rtc->p_MemMap->tmr_ctrl, (tmrCtrl | TMR_CTRL_TMSR));
-
- XX_UDelay(10);
- /* Clear TMR_OFF */
- WRITE_UINT32(p_Rtc->p_MemMap->tmr_off_l, 0);
- WRITE_UINT32(p_Rtc->p_MemMap->tmr_off_h, 0);
- }
-
- WRITE_UINT32(p_Rtc->p_MemMap->tmr_ctrl, (tmrCtrl | TMR_CTRL_TE));
-
+ fman_rtc_enable(p_Rtc->p_MemMap, resetClock);
return E_OK;
}
@@ -538,15 +428,13 @@ t_Error FM_RTC_Enable(t_Handle h_FmRtc, bool resetClock)
t_Error FM_RTC_Disable(t_Handle h_FmRtc)
{
t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
- uint32_t tmrCtrl;
SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
/* TODO A check must be added here, that no timestamping MAC's
* are working in this stage. */
- tmrCtrl = GET_UINT32(p_Rtc->p_MemMap->tmr_ctrl);
- WRITE_UINT32(p_Rtc->p_MemMap->tmr_ctrl, (tmrCtrl & ~(TMR_CTRL_TE)));
+ fman_rtc_disable(p_Rtc->p_MemMap);
return E_OK;
}
@@ -559,10 +447,7 @@ t_Error FM_RTC_SetClockOffset(t_Handle h_FmRtc, int64_t offset)
SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
- /* TMR_OFF_L must be written first */
- WRITE_UINT32(p_Rtc->p_MemMap->tmr_off_l, (uint32_t)offset);
- WRITE_UINT32(p_Rtc->p_MemMap->tmr_off_h, (uint32_t)(offset >> 32));
-
+ fman_rtc_set_timer_offset(p_Rtc->p_MemMap, offset);
return E_OK;
}
@@ -570,43 +455,36 @@ t_Error FM_RTC_SetClockOffset(t_Handle h_FmRtc, int64_t offset)
t_Error FM_RTC_SetAlarm(t_Handle h_FmRtc, t_FmRtcAlarmParams *p_FmRtcAlarmParams)
{
t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
- t_FmRtcMemMap *p_MemMap;
- uint32_t tmpReg;
uint64_t tmpAlarm;
+ bool enable = FALSE;
SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
- p_MemMap = p_Rtc->p_MemMap;
-
if (p_FmRtcAlarmParams->alarmId >= FM_RTC_NUM_OF_ALARMS)
{
RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Alarm ID"));
}
- if(p_FmRtcAlarmParams->alarmTime < p_Rtc->clockPeriodNanoSec)
- RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Alarm time must be equal or larger than RTC period - %d nanoseconds", p_Rtc->clockPeriodNanoSec));
- if(p_FmRtcAlarmParams->alarmTime % (uint64_t)p_Rtc->clockPeriodNanoSec)
- RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Alarm time must be a multiple of RTC period - %d nanoseconds", p_Rtc->clockPeriodNanoSec));
- tmpAlarm = p_FmRtcAlarmParams->alarmTime/(uint64_t)p_Rtc->clockPeriodNanoSec;
-
- /* TMR_ALARM_L must be written first */
- WRITE_UINT32(p_MemMap->tmr_alarm[p_FmRtcAlarmParams->alarmId].tmr_alarm_l, (uint32_t)tmpAlarm);
- WRITE_UINT32(p_MemMap->tmr_alarm[p_FmRtcAlarmParams->alarmId].tmr_alarm_h,
- (uint32_t)(tmpAlarm >> 32));
+ if (p_FmRtcAlarmParams->alarmTime < p_Rtc->clockPeriodNanoSec)
+ RETURN_ERROR(MAJOR, E_INVALID_SELECTION,
+ ("Alarm time must be equal or larger than RTC period - %d nanoseconds",
+ p_Rtc->clockPeriodNanoSec));
+ tmpAlarm = p_FmRtcAlarmParams->alarmTime;
+ if (do_div(tmpAlarm, p_Rtc->clockPeriodNanoSec))
+ RETURN_ERROR(MAJOR, E_INVALID_SELECTION,
+ ("Alarm time must be a multiple of RTC period - %d nanoseconds",
+ p_Rtc->clockPeriodNanoSec));
if (p_FmRtcAlarmParams->f_AlarmCallback)
{
p_Rtc->alarmParams[p_FmRtcAlarmParams->alarmId].f_AlarmCallback = p_FmRtcAlarmParams->f_AlarmCallback;
p_Rtc->alarmParams[p_FmRtcAlarmParams->alarmId].clearOnExpiration = p_FmRtcAlarmParams->clearOnExpiration;
-
- if(p_FmRtcAlarmParams->alarmId == 0)
- tmpReg = TMR_TEVENT_ALM1;
- else
- tmpReg = TMR_TEVENT_ALM2;
- WRITE_UINT32(p_MemMap->tmr_temask, GET_UINT32(p_MemMap->tmr_temask) | tmpReg);
+ enable = TRUE;
}
+ fman_rtc_set_alarm(p_Rtc->p_MemMap, p_FmRtcAlarmParams->alarmId, (unsigned long)tmpAlarm, enable);
+
return E_OK;
}
@@ -614,43 +492,39 @@ t_Error FM_RTC_SetAlarm(t_Handle h_FmRtc, t_FmRtcAlarmParams *p_FmRtcAlarmParams
t_Error FM_RTC_SetPeriodicPulse(t_Handle h_FmRtc, t_FmRtcPeriodicPulseParams *p_FmRtcPeriodicPulseParams)
{
t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
- t_FmRtcMemMap *p_MemMap;
- uint32_t tmpReg;
+ bool enable = FALSE;
uint64_t tmpFiper;
SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
- p_MemMap = p_Rtc->p_MemMap;
-
if (p_FmRtcPeriodicPulseParams->periodicPulseId >= FM_RTC_NUM_OF_PERIODIC_PULSES)
{
RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Periodic pulse ID"));
}
- if(GET_UINT32(p_MemMap->tmr_ctrl) & TMR_CTRL_TE)
+ if (fman_rtc_is_enabled(p_Rtc->p_MemMap))
RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Can't set Periodic pulse when RTC is enabled."));
- if(p_FmRtcPeriodicPulseParams->periodicPulsePeriod < p_Rtc->clockPeriodNanoSec)
- RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Periodic pulse must be equal or larger than RTC period - %d nanoseconds", p_Rtc->clockPeriodNanoSec));
- if(p_FmRtcPeriodicPulseParams->periodicPulsePeriod % (uint64_t)p_Rtc->clockPeriodNanoSec)
- RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Periodic pulse must be a multiple of RTC period - %d nanoseconds", p_Rtc->clockPeriodNanoSec));
- tmpFiper = p_FmRtcPeriodicPulseParams->periodicPulsePeriod/(uint64_t)p_Rtc->clockPeriodNanoSec;
- if(tmpFiper & 0xffffffff00000000LL)
- RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("Periodic pulse/RTC Period must be smaller than 4294967296", p_Rtc->clockPeriodNanoSec));
-
- WRITE_UINT32(p_MemMap->tmr_fiper[p_FmRtcPeriodicPulseParams->periodicPulseId], (uint32_t)tmpFiper);
+ if (p_FmRtcPeriodicPulseParams->periodicPulsePeriod < p_Rtc->clockPeriodNanoSec)
+ RETURN_ERROR(MAJOR, E_INVALID_SELECTION,
+ ("Periodic pulse must be equal or larger than RTC period - %d nanoseconds",
+ p_Rtc->clockPeriodNanoSec));
+ tmpFiper = p_FmRtcPeriodicPulseParams->periodicPulsePeriod;
+ if (do_div(tmpFiper, p_Rtc->clockPeriodNanoSec))
+ RETURN_ERROR(MAJOR, E_INVALID_SELECTION,
+ ("Periodic pulse must be a multiple of RTC period - %d nanoseconds",
+ p_Rtc->clockPeriodNanoSec));
+ if (tmpFiper & 0xffffffff00000000LL)
+ RETURN_ERROR(MAJOR, E_INVALID_SELECTION,
+ ("Periodic pulse/RTC Period must be smaller than 4294967296",
+ p_Rtc->clockPeriodNanoSec));
if (p_FmRtcPeriodicPulseParams->f_PeriodicPulseCallback)
{
p_Rtc->periodicPulseParams[p_FmRtcPeriodicPulseParams->periodicPulseId].f_PeriodicPulseCallback =
- p_FmRtcPeriodicPulseParams->f_PeriodicPulseCallback;
-
- if(p_FmRtcPeriodicPulseParams->periodicPulseId == 0)
- tmpReg = TMR_TEVENT_PP1;
- else
- tmpReg = TMR_TEVENT_PP2;
- WRITE_UINT32(p_MemMap->tmr_temask, GET_UINT32(p_MemMap->tmr_temask) | tmpReg);
+ p_FmRtcPeriodicPulseParams->f_PeriodicPulseCallback;
+ enable = TRUE;
}
-
+ fman_rtc_set_periodic_pulse(p_Rtc->p_MemMap, p_FmRtcPeriodicPulseParams->periodicPulseId, (uint32_t)tmpFiper, enable);
return E_OK;
}
@@ -658,7 +532,6 @@ t_Error FM_RTC_SetPeriodicPulse(t_Handle h_FmRtc, t_FmRtcPeriodicPulseParams *p_
t_Error FM_RTC_ClearPeriodicPulse(t_Handle h_FmRtc, uint8_t periodicPulseId)
{
t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
- uint32_t tmpReg;
SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
@@ -669,17 +542,7 @@ t_Error FM_RTC_ClearPeriodicPulse(t_Handle h_FmRtc, uint8_t periodicPulseId)
}
p_Rtc->periodicPulseParams[periodicPulseId].f_PeriodicPulseCallback = NULL;
-
- if(periodicPulseId == 0)
- tmpReg = TMR_TEVENT_PP1;
- else
- tmpReg = TMR_TEVENT_PP2;
- WRITE_UINT32(p_Rtc->p_MemMap->tmr_temask, GET_UINT32(p_Rtc->p_MemMap->tmr_temask) & ~tmpReg);
-
- if (GET_UINT32(p_Rtc->p_MemMap->tmr_ctrl) & TMR_CTRL_FS)
- WRITE_UINT32(p_Rtc->p_MemMap->tmr_ctrl, GET_UINT32(p_Rtc->p_MemMap->tmr_ctrl) & ~TMR_CTRL_FS);
-
- WRITE_UINT32(p_Rtc->p_MemMap->tmr_fiper[periodicPulseId], 0xFFFFFFFF);
+ fman_rtc_clear_periodic_pulse(p_Rtc->p_MemMap, periodicPulseId);
return E_OK;
}
@@ -688,7 +551,7 @@ t_Error FM_RTC_ClearPeriodicPulse(t_Handle h_FmRtc, uint8_t periodicPulseId)
t_Error FM_RTC_SetExternalTrigger(t_Handle h_FmRtc, t_FmRtcExternalTriggerParams *p_FmRtcExternalTriggerParams)
{
t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
- uint32_t tmpReg;
+ bool enable = FALSE;
SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
@@ -701,22 +564,10 @@ t_Error FM_RTC_SetExternalTrigger(t_Handle h_FmRtc, t_FmRtcExternalTriggerParams
if (p_FmRtcExternalTriggerParams->f_ExternalTriggerCallback)
{
p_Rtc->externalTriggerParams[p_FmRtcExternalTriggerParams->externalTriggerId].f_ExternalTriggerCallback = p_FmRtcExternalTriggerParams->f_ExternalTriggerCallback;
- if(p_FmRtcExternalTriggerParams->externalTriggerId == 0)
- tmpReg = TMR_TEVENT_ETS1;
- else
- tmpReg = TMR_TEVENT_ETS2;
- WRITE_UINT32(p_Rtc->p_MemMap->tmr_temask, GET_UINT32(p_Rtc->p_MemMap->tmr_temask) | tmpReg);
- }
-
- if(p_FmRtcExternalTriggerParams->usePulseAsInput)
- {
- if(p_FmRtcExternalTriggerParams->externalTriggerId == 0)
- tmpReg = TMR_CTRL_PP1L;
- else
- tmpReg = TMR_CTRL_PP2L;
- WRITE_UINT32(p_Rtc->p_MemMap->tmr_ctrl, GET_UINT32(p_Rtc->p_MemMap->tmr_ctrl) | tmpReg);
+ enable = TRUE;
}
+ fman_rtc_set_ext_trigger(p_Rtc->p_MemMap, p_FmRtcExternalTriggerParams->externalTriggerId, enable, p_FmRtcExternalTriggerParams->usePulseAsInput);
return E_OK;
}
@@ -724,7 +575,6 @@ t_Error FM_RTC_SetExternalTrigger(t_Handle h_FmRtc, t_FmRtcExternalTriggerParams
t_Error FM_RTC_ClearExternalTrigger(t_Handle h_FmRtc, uint8_t externalTriggerId)
{
t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
- uint32_t tmpReg;
SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
@@ -734,19 +584,7 @@ t_Error FM_RTC_ClearExternalTrigger(t_Handle h_FmRtc, uint8_t externalTriggerId)
p_Rtc->externalTriggerParams[externalTriggerId].f_ExternalTriggerCallback = NULL;
- if(externalTriggerId == 0)
- tmpReg = TMR_TEVENT_ETS1;
- else
- tmpReg = TMR_TEVENT_ETS2;
- WRITE_UINT32(p_Rtc->p_MemMap->tmr_temask, GET_UINT32(p_Rtc->p_MemMap->tmr_temask) & ~tmpReg);
-
- if(externalTriggerId == 0)
- tmpReg = TMR_CTRL_PP1L;
- else
- tmpReg = TMR_CTRL_PP2L;
-
- if (GET_UINT32(p_Rtc->p_MemMap->tmr_ctrl) & tmpReg)
- WRITE_UINT32(p_Rtc->p_MemMap->tmr_ctrl, GET_UINT32(p_Rtc->p_MemMap->tmr_ctrl) & ~tmpReg);
+ fman_rtc_clear_external_trigger(p_Rtc->p_MemMap, externalTriggerId);
return E_OK;
}
@@ -757,21 +595,14 @@ t_Error FM_RTC_GetExternalTriggerTimeStamp(t_Handle h_FmRtc,
uint64_t *p_TimeStamp)
{
t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
- uint64_t timeStamp;
SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
if (triggerId >= FM_RTC_NUM_OF_EXT_TRIGGERS)
- {
RETURN_ERROR(MAJOR, E_INVALID_SELECTION, ("External trigger ID"));
- }
-
- timeStamp = (uint64_t)GET_UINT32(p_Rtc->p_MemMap->tmr_etts[triggerId].tmr_etts_l);
- timeStamp |= ((uint64_t)GET_UINT32(p_Rtc->p_MemMap->tmr_etts[triggerId].tmr_etts_h) << 32);
- timeStamp = timeStamp*p_Rtc->clockPeriodNanoSec;
- *p_TimeStamp = timeStamp;
+ *p_TimeStamp = fman_rtc_get_trigger_stamp(p_Rtc->p_MemMap, triggerId)*p_Rtc->clockPeriodNanoSec;
return E_OK;
}
@@ -780,18 +611,11 @@ t_Error FM_RTC_GetExternalTriggerTimeStamp(t_Handle h_FmRtc,
t_Error FM_RTC_GetCurrentTime(t_Handle h_FmRtc, uint64_t *p_Ts)
{
t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
- uint64_t time;
SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
- /* TMR_CNT_L must be read first to get an accurate value */
- time = (uint64_t)GET_UINT32(p_Rtc->p_MemMap->tmr_cnt_l);
- time |= ((uint64_t)GET_UINT32(p_Rtc->p_MemMap->tmr_cnt_h) << 32);
-
- time = time*p_Rtc->clockPeriodNanoSec;
-
- *p_Ts = time;
+ *p_Ts = fman_rtc_get_timer(p_Rtc->p_MemMap)*p_Rtc->clockPeriodNanoSec;
return E_OK;
}
@@ -804,10 +628,8 @@ t_Error FM_RTC_SetCurrentTime(t_Handle h_FmRtc, uint64_t ts)
SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
- ts = ts/p_Rtc->clockPeriodNanoSec;
- /* TMR_CNT_L must be written first to get an accurate value */
- WRITE_UINT32(p_Rtc->p_MemMap->tmr_cnt_l, (uint32_t)ts);
- WRITE_UINT32(p_Rtc->p_MemMap->tmr_cnt_h, (uint32_t)(ts >> 32));
+ do_div(ts, p_Rtc->clockPeriodNanoSec);
+ fman_rtc_set_timer(p_Rtc->p_MemMap, (int64_t)ts);
return E_OK;
}
@@ -820,9 +642,7 @@ t_Error FM_RTC_GetFreqCompensation(t_Handle h_FmRtc, uint32_t *p_Compensation)
SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
- *p_Compensation = (uint32_t)
- DIV_CEIL(ACCUMULATOR_OVERFLOW * 1000,
- p_Rtc->clockPeriodNanoSec * p_Rtc->srcClkFreqMhz);
+ *p_Compensation = fman_rtc_get_frequency_compensation(p_Rtc->p_MemMap);
return E_OK;
}
@@ -836,56 +656,37 @@ t_Error FM_RTC_SetFreqCompensation(t_Handle h_FmRtc, uint32_t freqCompensation)
SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
/* set the new freqCompensation */
- WRITE_UINT32(p_Rtc->p_MemMap->tmr_add, freqCompensation);
+ fman_rtc_set_frequency_compensation(p_Rtc->p_MemMap, freqCompensation);
return E_OK;
}
+#ifdef CONFIG_PTP_1588_CLOCK_DPAA
/*****************************************************************************/
-#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
-t_Error FM_RTC_DumpRegs(t_Handle h_FmRtc)
+t_Error FM_RTC_EnableInterrupt(t_Handle h_FmRtc, uint32_t events)
{
- t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
- t_FmRtcMemMap *p_MemMap = p_Rtc->p_MemMap;
- int i = 0;
+ t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
- DECLARE_DUMP;
+ SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
- if (p_MemMap)
- {
+ /* enable interrupt */
+ fman_rtc_enable_interupt(p_Rtc->p_MemMap, events);
- DUMP_TITLE(p_MemMap, ("RTC:"));
- DUMP_VAR(p_MemMap, tmr_id);
- DUMP_VAR(p_MemMap, tmr_id2);
- DUMP_VAR(p_MemMap, tmr_ctrl);
- DUMP_VAR(p_MemMap, tmr_tevent);
- DUMP_VAR(p_MemMap, tmr_temask);
- DUMP_VAR(p_MemMap, tmr_cnt_h);
- DUMP_VAR(p_MemMap, tmr_cnt_l);
- DUMP_VAR(p_MemMap, tmr_ctrl);
- DUMP_VAR(p_MemMap, tmr_add);
- DUMP_VAR(p_MemMap, tmr_acc);
- DUMP_VAR(p_MemMap, tmr_prsc);
- DUMP_VAR(p_MemMap, tmr_off_h);
- DUMP_VAR(p_MemMap, tmr_off_l);
-
- DUMP_SUBSTRUCT_ARRAY(i, 2)
- {
- DUMP_VAR(p_MemMap, tmr_alarm[i].tmr_alarm_h);
- DUMP_VAR(p_MemMap, tmr_alarm[i].tmr_alarm_l);
- }
- DUMP_SUBSTRUCT_ARRAY(i, 2)
- {
- DUMP_VAR(p_MemMap, tmr_fiper[i]);
- DUMP_VAR(p_MemMap, tmr_fiper[i]);
- }
- DUMP_SUBSTRUCT_ARRAY(i, 2)
- {
- DUMP_VAR(p_MemMap, tmr_etts[i].tmr_etts_l);
- DUMP_VAR(p_MemMap, tmr_etts[i].tmr_etts_l);
- }
- }
+ return E_OK;
+}
- return E_OK;
+/*****************************************************************************/
+t_Error FM_RTC_DisableInterrupt(t_Handle h_FmRtc, uint32_t events)
+{
+ t_FmRtc *p_Rtc = (t_FmRtc *)h_FmRtc;
+
+ SANITY_CHECK_RETURN_ERROR(p_Rtc, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Rtc->p_RtcDriverParam, E_INVALID_STATE);
+
+ /* disable interrupt */
+ fman_rtc_disable_interupt(p_Rtc->p_MemMap, events);
+
+ return E_OK;
}
-#endif /* (defined(DEBUG_ERRORS) && ... */
+#endif
diff --git a/sys/contrib/ncsw/Peripherals/FM/Rtc/fm_rtc.h b/sys/contrib/ncsw/Peripherals/FM/Rtc/fm_rtc.h
index f11222529b36..843ca008ff8b 100644
--- a/sys/contrib/ncsw/Peripherals/FM/Rtc/fm_rtc.h
+++ b/sys/contrib/ncsw/Peripherals/FM/Rtc/fm_rtc.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm_rtc.h
@@ -49,134 +50,12 @@
/* General definitions */
-#define NANOSEC_PER_ONE_HZ_TICK 1000000000
-#define MIN_RTC_CLK_FREQ_HZ 1000
-#define MHz 1000000
-
#define ACCUMULATOR_OVERFLOW ((uint64_t)(1LL << 32))
+#define DEFAULT_OUTPUT_CLOCK_DIVISOR 0x00000002
+#define DEFAULT_BYPASS FALSE
+#define DEFAULT_CLOCK_PERIOD 1000
-/* RTC default values */
-#define DEFAULT_srcClock e_FM_RTC_SOURCE_CLOCK_SYSTEM
-#define DEFAULT_bypass FALSE
-#define DEFAULT_invertInputClkPhase FALSE
-#define DEFAULT_invertOutputClkPhase FALSE
-#define DEFAULT_outputClockDivisor 0x00000002
-#define DEFAULT_alarmPolarity e_FM_RTC_ALARM_POLARITY_ACTIVE_HIGH
-#define DEFAULT_triggerPolarity e_FM_RTC_TRIGGER_ON_FALLING_EDGE
-#define DEFAULT_pulseRealign FALSE
-#define DEFAULT_clockPeriod 1000
-
-/* FM RTC Registers definitions */
-#define TMR_CTRL_ALMP1 0x80000000
-#define TMR_CTRL_ALMP2 0x40000000
-#define TMR_CTRL_FS 0x10000000
-#define TMR_CTRL_PP1L 0x08000000
-#define TMR_CTRL_PP2L 0x04000000
-#define TMR_CTRL_TCLK_PERIOD_MASK 0x03FF0000
-#define TMR_CTRL_FRD 0x00004000
-#define TMR_CTRL_SLV 0x00002000
-#define TMR_CTRL_ETEP1 0x00000100
-#define TMR_CTRL_COPH 0x00000080
-#define TMR_CTRL_CIPH 0x00000040
-#define TMR_CTRL_TMSR 0x00000020
-#define TMR_CTRL_DBG 0x00000010
-#define TMR_CTRL_BYP 0x00000008
-#define TMR_CTRL_TE 0x00000004
-#define TMR_CTRL_CKSEL_OSC_CLK 0x00000003
-#define TMR_CTRL_CKSEL_MAC_CLK 0x00000001
-#define TMR_CTRL_CKSEL_EXT_CLK 0x00000000
-#define TMR_CTRL_TCLK_PERIOD_SHIFT 16
-
-#define TMR_TEVENT_ETS2 0x02000000
-#define TMR_TEVENT_ETS1 0x01000000
-#define TMR_TEVENT_ALM2 0x00020000
-#define TMR_TEVENT_ALM1 0x00010000
-#define TMR_TEVENT_PP1 0x00000080
-#define TMR_TEVENT_PP2 0x00000040
-#define TMR_TEVENT_PP3 0x00000020
-#define TMR_TEVENT_ALL (TMR_TEVENT_ETS2 | TMR_TEVENT_ETS1 | \
- TMR_TEVENT_ALM2 | TMR_TEVENT_ALM1 | \
- TMR_TEVENT_PP1 | TMR_TEVENT_PP2 | TMR_TEVENT_PP3)
-
-#define TMR_PRSC_OCK_MASK 0x0000FFFF
-
-
-/**************************************************************************//**
- @Description Memory Mapped Registers
-*//***************************************************************************/
-
-#if defined(__MWERKS__) && !defined(__GNUC__)
-#pragma pack(push,1)
-#endif /* defined(__MWERKS__) && ... */
-#define MEM_MAP_START
-
-/**************************************************************************//**
- @Description FM RTC timer alarm
-*//***************************************************************************/
-typedef _Packed struct t_TmrAlaram
-{
- volatile uint32_t tmr_alarm_h; /**< */
- volatile uint32_t tmr_alarm_l; /**< */
-} _PackedType t_TmrAlaram;
-/**************************************************************************//**
- @Description FM RTC timer Ex trigger
-*//***************************************************************************/
-typedef _Packed struct t_TmrExtTrigger
-{
- volatile uint32_t tmr_etts_h; /**< */
- volatile uint32_t tmr_etts_l; /**< */
-} _PackedType t_TmrExtTrigger;
-
-typedef _Packed struct
-{
- volatile uint32_t tmr_id; /* Module ID and version register */
- volatile uint32_t tmr_id2; /* Module ID and configuration register */
- volatile uint32_t PTP_RESERVED1[30];
- volatile uint32_t tmr_ctrl; /* timer control register */
- volatile uint32_t tmr_tevent; /* timer event register */
- volatile uint32_t tmr_temask; /* timer event mask register */
- volatile uint32_t PTP_RESERVED2[3];
- volatile uint32_t tmr_cnt_h; /* timer counter high register */
- volatile uint32_t tmr_cnt_l; /* timer counter low register */
- volatile uint32_t tmr_add; /* timer drift compensation addend register */
- volatile uint32_t tmr_acc; /* timer accumulator register */
- volatile uint32_t tmr_prsc; /* timer prescale */
- volatile uint32_t PTP_RESERVED3;
- volatile uint32_t tmr_off_h; /* timer offset high */
- volatile uint32_t tmr_off_l; /* timer offset low */
- volatile t_TmrAlaram tmr_alarm[FM_RTC_NUM_OF_ALARMS]; /* timer alarm */
- volatile uint32_t PTP_RESERVED4[2];
- volatile uint32_t tmr_fiper[FM_RTC_NUM_OF_PERIODIC_PULSES]; /* timer fixed period interval */
- volatile uint32_t PTP_RESERVED5[2];
- volatile t_TmrExtTrigger tmr_etts[FM_RTC_NUM_OF_EXT_TRIGGERS]; /*time stamp general purpose external */
- volatile uint32_t PTP_RESERVED6[3];
-} _PackedType t_FmRtcMemMap;
-
-#define MEM_MAP_END
-#if defined(__MWERKS__) && !defined(__GNUC__)
-#pragma pack(pop)
-#endif /* defined(__MWERKS__) && ... */
-
-
-/**************************************************************************//**
- @Description RTC FM driver parameters structure.
-*//***************************************************************************/
-typedef struct t_FmRtcDriverParam
-{
- t_Handle h_Fm; /**< */
- e_FmSrcClk srcClk; /**< */
- uint32_t extSrcClkFreq; /**< */
- uint32_t rtcFreqHz; /**< */
- bool timerSlaveMode; /*Slave/Master Mode*/
- bool invertInputClkPhase;
- bool invertOutputClkPhase;
- uint32_t eventsMask;
- bool bypass; /**< Indicates if frequency compensation is bypassed */
- bool pulseRealign;
- e_FmRtcAlarmPolarity alarmPolarity[FM_RTC_NUM_OF_ALARMS];
- e_FmRtcTriggerPolarity triggerPolarity[FM_RTC_NUM_OF_EXT_TRIGGERS];
-} t_FmRtcDriverParam;
typedef struct t_FmRtcAlarm
{
@@ -203,14 +82,14 @@ typedef struct t_FmRtc
t_Part *p_Part; /**< Pointer to the integration device */
t_Handle h_Fm;
t_Handle h_App; /**< Application handle */
- t_FmRtcMemMap *p_MemMap; /**< Pointer to RTC memory map */
+ struct rtc_regs *p_MemMap;
uint32_t clockPeriodNanoSec; /**< RTC clock period in nano-seconds (for FS mode) */
uint32_t srcClkFreqMhz;
uint16_t outputClockDivisor; /**< Output clock divisor (for FS mode) */
t_FmRtcAlarm alarmParams[FM_RTC_NUM_OF_ALARMS];
t_FmRtcPeriodicPulse periodicPulseParams[FM_RTC_NUM_OF_PERIODIC_PULSES];
t_FmRtcExternalTrigger externalTriggerParams[FM_RTC_NUM_OF_EXT_TRIGGERS];
- t_FmRtcDriverParam *p_RtcDriverParam; /**< RTC Driver parameters (for Init phase) */
+ struct rtc_cfg *p_RtcDriverParam; /**< RTC Driver parameters (for Init phase) */
} t_FmRtc;
diff --git a/sys/contrib/ncsw/Peripherals/FM/Rtc/fman_rtc.c b/sys/contrib/ncsw/Peripherals/FM/Rtc/fman_rtc.c
new file mode 100755
index 000000000000..f3a02b15abcc
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/Rtc/fman_rtc.c
@@ -0,0 +1,334 @@
+/*
+ * Copyright 2008-2013 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "fsl_fman_rtc.h"
+
+void fman_rtc_defconfig(struct rtc_cfg *cfg)
+{
+ int i;
+ cfg->src_clk = DEFAULT_SRC_CLOCK;
+ cfg->invert_input_clk_phase = DEFAULT_INVERT_INPUT_CLK_PHASE;
+ cfg->invert_output_clk_phase = DEFAULT_INVERT_OUTPUT_CLK_PHASE;
+ cfg->pulse_realign = DEFAULT_PULSE_REALIGN;
+ for (i = 0; i < FMAN_RTC_MAX_NUM_OF_ALARMS; i++)
+ cfg->alarm_polarity[i] = DEFAULT_ALARM_POLARITY;
+ for (i = 0; i < FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS; i++)
+ cfg->trigger_polarity[i] = DEFAULT_TRIGGER_POLARITY;
+}
+
+uint32_t fman_rtc_get_events(struct rtc_regs *regs)
+{
+ return ioread32be(&regs->tmr_tevent);
+}
+
+uint32_t fman_rtc_get_event(struct rtc_regs *regs, uint32_t ev_mask)
+{
+ return ioread32be(&regs->tmr_tevent) & ev_mask;
+}
+
+uint32_t fman_rtc_get_interrupt_mask(struct rtc_regs *regs)
+{
+ return ioread32be(&regs->tmr_temask);
+}
+
+void fman_rtc_set_interrupt_mask(struct rtc_regs *regs, uint32_t mask)
+{
+ iowrite32be(mask, &regs->tmr_temask);
+}
+
+void fman_rtc_ack_event(struct rtc_regs *regs, uint32_t events)
+{
+ iowrite32be(events, &regs->tmr_tevent);
+}
+
+uint32_t fman_rtc_check_and_clear_event(struct rtc_regs *regs)
+{
+ uint32_t event;
+
+ event = ioread32be(&regs->tmr_tevent);
+ event &= ioread32be(&regs->tmr_temask);
+
+ if (event)
+ iowrite32be(event, &regs->tmr_tevent);
+ return event;
+}
+
+uint32_t fman_rtc_get_frequency_compensation(struct rtc_regs *regs)
+{
+ return ioread32be(&regs->tmr_add);
+}
+
+void fman_rtc_set_frequency_compensation(struct rtc_regs *regs, uint32_t val)
+{
+ iowrite32be(val, &regs->tmr_add);
+}
+
+void fman_rtc_enable_interupt(struct rtc_regs *regs, uint32_t events)
+{
+ fman_rtc_set_interrupt_mask(regs, fman_rtc_get_interrupt_mask(regs) | events);
+}
+
+void fman_rtc_disable_interupt(struct rtc_regs *regs, uint32_t events)
+{
+ fman_rtc_set_interrupt_mask(regs, fman_rtc_get_interrupt_mask(regs) & ~events);
+}
+
+void fman_rtc_set_timer_alarm_l(struct rtc_regs *regs, int index, uint32_t val)
+{
+ iowrite32be(val, &regs->tmr_alarm[index].tmr_alarm_l);
+}
+
+void fman_rtc_set_timer_fiper(struct rtc_regs *regs, int index, uint32_t val)
+{
+ iowrite32be(val, &regs->tmr_fiper[index]);
+}
+
+void fman_rtc_set_timer_alarm(struct rtc_regs *regs, int index, int64_t val)
+{
+ iowrite32be((uint32_t)val, &regs->tmr_alarm[index].tmr_alarm_l);
+ iowrite32be((uint32_t)(val >> 32), &regs->tmr_alarm[index].tmr_alarm_h);
+}
+
+void fman_rtc_set_timer_offset(struct rtc_regs *regs, int64_t val)
+{
+ iowrite32be((uint32_t)val, &regs->tmr_off_l);
+ iowrite32be((uint32_t)(val >> 32), &regs->tmr_off_h);
+}
+
+uint64_t fman_rtc_get_trigger_stamp(struct rtc_regs *regs, int id)
+{
+ uint64_t time;
+ /* TMR_CNT_L must be read first to get an accurate value */
+ time = (uint64_t)ioread32be(&regs->tmr_etts[id].tmr_etts_l);
+ time |= ((uint64_t)ioread32be(&regs->tmr_etts[id].tmr_etts_h)
+ << 32);
+
+ return time;
+}
+
+uint32_t fman_rtc_get_timer_ctrl(struct rtc_regs *regs)
+{
+ return ioread32be(&regs->tmr_ctrl);
+}
+
+void fman_rtc_set_timer_ctrl(struct rtc_regs *regs, uint32_t val)
+{
+ iowrite32be(val, &regs->tmr_ctrl);
+}
+
+void fman_rtc_timers_soft_reset(struct rtc_regs *regs)
+{
+ fman_rtc_set_timer_ctrl(regs, FMAN_RTC_TMR_CTRL_TMSR);
+ DELAY(10);
+ fman_rtc_set_timer_ctrl(regs, 0);
+}
+
+void fman_rtc_init(struct rtc_cfg *cfg, struct rtc_regs *regs, int num_alarms,
+ int num_fipers, int num_ext_triggers, bool init_freq_comp,
+ uint32_t freq_compensation, uint32_t output_clock_divisor)
+{
+ uint32_t tmr_ctrl;
+ int i;
+
+ fman_rtc_timers_soft_reset(regs);
+
+ /* Set the source clock */
+ switch (cfg->src_clk) {
+ case E_FMAN_RTC_SOURCE_CLOCK_SYSTEM:
+ tmr_ctrl = FMAN_RTC_TMR_CTRL_CKSEL_MAC_CLK;
+ break;
+ case E_FMAN_RTC_SOURCE_CLOCK_OSCILATOR:
+ tmr_ctrl = FMAN_RTC_TMR_CTRL_CKSEL_OSC_CLK;
+ break;
+ default:
+ /* Use a clock from the External TMR reference clock.*/
+ tmr_ctrl = FMAN_RTC_TMR_CTRL_CKSEL_EXT_CLK;
+ break;
+ }
+
+ /* whatever period the user picked, the timestamp will advance in '1'
+ * every time the period passed. */
+ tmr_ctrl |= ((1 << FMAN_RTC_TMR_CTRL_TCLK_PERIOD_SHIFT) &
+ FMAN_RTC_TMR_CTRL_TCLK_PERIOD_MASK);
+
+ if (cfg->invert_input_clk_phase)
+ tmr_ctrl |= FMAN_RTC_TMR_CTRL_CIPH;
+ if (cfg->invert_output_clk_phase)
+ tmr_ctrl |= FMAN_RTC_TMR_CTRL_COPH;
+
+ for (i = 0; i < num_alarms; i++) {
+ if (cfg->alarm_polarity[i] ==
+ E_FMAN_RTC_ALARM_POLARITY_ACTIVE_LOW)
+ tmr_ctrl |= (FMAN_RTC_TMR_CTRL_ALMP1 >> i);
+ }
+
+ for (i = 0; i < num_ext_triggers; i++)
+ if (cfg->trigger_polarity[i] ==
+ E_FMAN_RTC_TRIGGER_ON_FALLING_EDGE)
+ tmr_ctrl |= (FMAN_RTC_TMR_CTRL_ETEP1 << i);
+
+ if (!cfg->timer_slave_mode && cfg->bypass)
+ tmr_ctrl |= FMAN_RTC_TMR_CTRL_BYP;
+
+ fman_rtc_set_timer_ctrl(regs, tmr_ctrl);
+ if (init_freq_comp)
+ fman_rtc_set_frequency_compensation(regs, freq_compensation);
+
+ /* Clear TMR_ALARM registers */
+ for (i = 0; i < num_alarms; i++)
+ fman_rtc_set_timer_alarm(regs, i, 0xFFFFFFFFFFFFFFFFLL);
+
+ /* Clear TMR_TEVENT */
+ fman_rtc_ack_event(regs, FMAN_RTC_TMR_TEVENT_ALL);
+
+ /* Initialize TMR_TEMASK */
+ fman_rtc_set_interrupt_mask(regs, 0);
+
+ /* Clear TMR_FIPER registers */
+ for (i = 0; i < num_fipers; i++)
+ fman_rtc_set_timer_fiper(regs, i, 0xFFFFFFFF);
+
+ /* Initialize TMR_PRSC */
+ iowrite32be(output_clock_divisor, &regs->tmr_prsc);
+
+ /* Clear TMR_OFF */
+ fman_rtc_set_timer_offset(regs, 0);
+}
+
+bool fman_rtc_is_enabled(struct rtc_regs *regs)
+{
+ return (bool)(fman_rtc_get_timer_ctrl(regs) & FMAN_RTC_TMR_CTRL_TE);
+}
+
+void fman_rtc_enable(struct rtc_regs *regs, bool reset_clock)
+{
+ uint32_t tmr_ctrl = fman_rtc_get_timer_ctrl(regs);
+
+ /* TODO check that no timestamping MACs are working in this stage. */
+ if (reset_clock) {
+ fman_rtc_set_timer_ctrl(regs, (tmr_ctrl | FMAN_RTC_TMR_CTRL_TMSR));
+
+ DELAY(10);
+ /* Clear TMR_OFF */
+ fman_rtc_set_timer_offset(regs, 0);
+ }
+
+ fman_rtc_set_timer_ctrl(regs, (tmr_ctrl | FMAN_RTC_TMR_CTRL_TE));
+}
+
+void fman_rtc_disable(struct rtc_regs *regs)
+{
+ fman_rtc_set_timer_ctrl(regs, (fman_rtc_get_timer_ctrl(regs)
+ & ~(FMAN_RTC_TMR_CTRL_TE)));
+}
+
+void fman_rtc_clear_periodic_pulse(struct rtc_regs *regs, int id)
+{
+ uint32_t tmp_reg;
+ if (id == 0)
+ tmp_reg = FMAN_RTC_TMR_TEVENT_PP1;
+ else
+ tmp_reg = FMAN_RTC_TMR_TEVENT_PP2;
+ fman_rtc_disable_interupt(regs, tmp_reg);
+
+ tmp_reg = fman_rtc_get_timer_ctrl(regs);
+ if (tmp_reg & FMAN_RTC_TMR_CTRL_FS)
+ fman_rtc_set_timer_ctrl(regs, tmp_reg & ~FMAN_RTC_TMR_CTRL_FS);
+
+ fman_rtc_set_timer_fiper(regs, id, 0xFFFFFFFF);
+}
+
+void fman_rtc_clear_external_trigger(struct rtc_regs *regs, int id)
+{
+ uint32_t tmpReg, tmp_ctrl;
+
+ if (id == 0)
+ tmpReg = FMAN_RTC_TMR_TEVENT_ETS1;
+ else
+ tmpReg = FMAN_RTC_TMR_TEVENT_ETS2;
+ fman_rtc_disable_interupt(regs, tmpReg);
+
+ if (id == 0)
+ tmpReg = FMAN_RTC_TMR_CTRL_PP1L;
+ else
+ tmpReg = FMAN_RTC_TMR_CTRL_PP2L;
+ tmp_ctrl = fman_rtc_get_timer_ctrl(regs);
+ if (tmp_ctrl & tmpReg)
+ fman_rtc_set_timer_ctrl(regs, tmp_ctrl & ~tmpReg);
+}
+
+void fman_rtc_set_alarm(struct rtc_regs *regs, int id, uint32_t val, bool enable)
+{
+ uint32_t tmpReg;
+ fman_rtc_set_timer_alarm(regs, id, val);
+ if (enable) {
+ if (id == 0)
+ tmpReg = FMAN_RTC_TMR_TEVENT_ALM1;
+ else
+ tmpReg = FMAN_RTC_TMR_TEVENT_ALM2;
+ fman_rtc_enable_interupt(regs, tmpReg);
+ }
+}
+
+void fman_rtc_set_periodic_pulse(struct rtc_regs *regs, int id, uint32_t val,
+ bool enable)
+{
+ uint32_t tmpReg;
+ fman_rtc_set_timer_fiper(regs, id, val);
+ if (enable) {
+ if (id == 0)
+ tmpReg = FMAN_RTC_TMR_TEVENT_PP1;
+ else
+ tmpReg = FMAN_RTC_TMR_TEVENT_PP2;
+ fman_rtc_enable_interupt(regs, tmpReg);
+ }
+}
+
+void fman_rtc_set_ext_trigger(struct rtc_regs *regs, int id, bool enable,
+ bool use_pulse_as_input)
+{
+ uint32_t tmpReg;
+ if (enable) {
+ if (id == 0)
+ tmpReg = FMAN_RTC_TMR_TEVENT_ETS1;
+ else
+ tmpReg = FMAN_RTC_TMR_TEVENT_ETS2;
+ fman_rtc_enable_interupt(regs, tmpReg);
+ }
+ if (use_pulse_as_input) {
+ if (id == 0)
+ tmpReg = FMAN_RTC_TMR_CTRL_PP1L;
+ else
+ tmpReg = FMAN_RTC_TMR_CTRL_PP2L;
+ fman_rtc_set_timer_ctrl(regs, fman_rtc_get_timer_ctrl(regs) | tmpReg);
+ }
+}
diff --git a/sys/contrib/ncsw/Peripherals/FM/SP/fm_sp.c b/sys/contrib/ncsw/Peripherals/FM/SP/fm_sp.c
new file mode 100644
index 000000000000..0994f34d392d
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/SP/fm_sp.c
@@ -0,0 +1,757 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/******************************************************************************
+ @File fm_sp.c
+
+ @Description FM PCD Storage profile ...
+*//***************************************************************************/
+
+#include "std_ext.h"
+#include "error_ext.h"
+#include "string_ext.h"
+#include "debug_ext.h"
+#include "net_ext.h"
+
+#include "fm_vsp_ext.h"
+#include "fm_sp.h"
+#include "fm_common.h"
+#include "fsl_fman_sp.h"
+
+
+#if (DPAA_VERSION >= 11)
+static t_Error CheckParamsGeneratedInternally(t_FmVspEntry *p_FmVspEntry)
+{
+ t_Error err = E_OK;
+
+ if ((err = FmSpCheckIntContextParams(&p_FmVspEntry->intContext))!= E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ if ((err = FmSpCheckBufMargins(&p_FmVspEntry->bufMargins)) != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ return err;
+
+}
+
+static t_Error CheckParams(t_FmVspEntry *p_FmVspEntry)
+{
+ t_Error err = E_OK;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->h_Fm, E_INVALID_HANDLE);
+
+ if ((err = FmSpCheckBufPoolsParams(&p_FmVspEntry->p_FmVspEntryDriverParams->extBufPools,
+ p_FmVspEntry->p_FmVspEntryDriverParams->p_BackupBmPools,
+ p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion)) != E_OK)
+
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+ if (p_FmVspEntry->p_FmVspEntryDriverParams->liodnOffset & ~FM_LIODN_OFFSET_MASK)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("liodnOffset is larger than %d", FM_LIODN_OFFSET_MASK+1));
+
+ err = FmVSPCheckRelativeProfile(p_FmVspEntry->h_Fm,
+ p_FmVspEntry->portType,
+ p_FmVspEntry->portId,
+ p_FmVspEntry->relativeProfileId);
+
+ return err;
+}
+#endif /* (DPAA_VERSION >= 11) */
+
+
+/*****************************************************************************/
+/* Inter-module API routines */
+/*****************************************************************************/
+void FmSpSetBufPoolsInAscOrderOfBufSizes(t_FmExtPools *p_FmExtPools,
+ uint8_t *orderedArray,
+ uint16_t *sizesArray)
+{
+ uint16_t bufSize = 0;
+ int i=0, j=0, k=0;
+
+ /* First we copy the external buffers pools information to an ordered local array */
+ for (i=0;i<p_FmExtPools->numOfPoolsUsed;i++)
+ {
+ /* get pool size */
+ bufSize = p_FmExtPools->extBufPool[i].size;
+
+ /* keep sizes in an array according to poolId for direct access */
+ sizesArray[p_FmExtPools->extBufPool[i].id] = bufSize;
+
+ /* save poolId in an ordered array according to size */
+ for (j=0;j<=i;j++)
+ {
+ /* this is the next free place in the array */
+ if (j==i)
+ orderedArray[i] = p_FmExtPools->extBufPool[i].id;
+ else
+ {
+ /* find the right place for this poolId */
+ if (bufSize < sizesArray[orderedArray[j]])
+ {
+ /* move the poolIds one place ahead to make room for this poolId */
+ for (k=i;k>j;k--)
+ orderedArray[k] = orderedArray[k-1];
+
+ /* now k==j, this is the place for the new size */
+ orderedArray[k] = p_FmExtPools->extBufPool[i].id;
+ break;
+ }
+ }
+ }
+ }
+}
+
+t_Error FmSpCheckBufPoolsParams(t_FmExtPools *p_FmExtPools,
+ t_FmBackupBmPools *p_FmBackupBmPools,
+ t_FmBufPoolDepletion *p_FmBufPoolDepletion)
+{
+
+ int i = 0, j = 0;
+ bool found;
+ uint8_t count = 0;
+
+ if (p_FmExtPools)
+ {
+ if (p_FmExtPools->numOfPoolsUsed > FM_PORT_MAX_NUM_OF_EXT_POOLS)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numOfPoolsUsed can't be larger than %d", FM_PORT_MAX_NUM_OF_EXT_POOLS));
+
+ for (i=0;i<p_FmExtPools->numOfPoolsUsed;i++)
+ {
+ if (p_FmExtPools->extBufPool[i].id >= BM_MAX_NUM_OF_POOLS)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("extBufPools.extBufPool[%d].id can't be larger than %d", i, BM_MAX_NUM_OF_POOLS));
+ if (!p_FmExtPools->extBufPool[i].size)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("extBufPools.extBufPool[%d].size is 0", i));
+ }
+ }
+ if (!p_FmExtPools && (p_FmBackupBmPools || p_FmBufPoolDepletion))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("backupBmPools ot bufPoolDepletion can not be defined without external pools"));
+
+ /* backup BM pools indication is valid only for some chip derivatives
+ (limited by the config routine) */
+ if (p_FmBackupBmPools)
+ {
+ if (p_FmBackupBmPools->numOfBackupPools >= p_FmExtPools->numOfPoolsUsed)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("p_BackupBmPools must be smaller than extBufPools.numOfPoolsUsed"));
+ found = FALSE;
+ for (i = 0;i<p_FmBackupBmPools->numOfBackupPools;i++)
+ {
+
+ for (j=0;j<p_FmExtPools->numOfPoolsUsed;j++)
+ {
+ if (p_FmBackupBmPools->poolIds[i] == p_FmExtPools->extBufPool[j].id)
+ {
+ found = TRUE;
+ break;
+ }
+ }
+ if (!found)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("All p_BackupBmPools.poolIds must be included in extBufPools.extBufPool[n].id"));
+ else
+ found = FALSE;
+ }
+ }
+
+ /* up to extBufPools.numOfPoolsUsed pools may be defined */
+ if (p_FmBufPoolDepletion && p_FmBufPoolDepletion->poolsGrpModeEnable)
+ {
+ if ((p_FmBufPoolDepletion->numOfPools > p_FmExtPools->numOfPoolsUsed))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufPoolDepletion.numOfPools can't be larger than %d and can't be larger than numOfPoolsUsed", FM_PORT_MAX_NUM_OF_EXT_POOLS));
+
+ if (!p_FmBufPoolDepletion->numOfPools)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufPoolDepletion.numOfPoolsToConsider can not be 0 when poolsGrpModeEnable=TRUE"));
+
+ found = FALSE;
+ count = 0;
+ /* for each pool that is in poolsToConsider, check if it is defined
+ in extBufPool */
+ for (i=0;i<BM_MAX_NUM_OF_POOLS;i++)
+ {
+ if (p_FmBufPoolDepletion->poolsToConsider[i])
+ {
+ for (j=0;j<p_FmExtPools->numOfPoolsUsed;j++)
+ {
+ if (i == p_FmExtPools->extBufPool[j].id)
+ {
+ found = TRUE;
+ count++;
+ break;
+ }
+ }
+ if (!found)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Pools selected for depletion are not used."));
+ else
+ found = FALSE;
+ }
+ }
+ /* check that the number of pools that we have checked is equal to the number announced by the user */
+ if (count != p_FmBufPoolDepletion->numOfPools)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufPoolDepletion.numOfPools is larger than the number of pools defined."));
+ }
+
+ if (p_FmBufPoolDepletion && p_FmBufPoolDepletion->singlePoolModeEnable)
+ {
+ /* calculate vector for number of pools depletion */
+ found = FALSE;
+ count = 0;
+ for (i=0;i<BM_MAX_NUM_OF_POOLS;i++)
+ {
+ if (p_FmBufPoolDepletion->poolsToConsiderForSingleMode[i])
+ {
+ for (j=0;j<p_FmExtPools->numOfPoolsUsed;j++)
+ {
+ if (i == p_FmExtPools->extBufPool[j].id)
+ {
+ found = TRUE;
+ count++;
+ break;
+ }
+ }
+ if (!found)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Pools selected for depletion are not used."));
+ else
+ found = FALSE;
+ }
+ }
+ if (!count)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("No pools defined for single buffer mode pool depletion."));
+ }
+
+ return E_OK;
+}
+
+t_Error FmSpCheckIntContextParams(t_FmSpIntContextDataCopy *p_FmSpIntContextDataCopy)
+{
+ /* Check that divisible by 16 and not larger than 240 */
+ if (p_FmSpIntContextDataCopy->intContextOffset >MAX_INT_OFFSET)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.intContextOffset can't be larger than %d", MAX_INT_OFFSET));
+ if (p_FmSpIntContextDataCopy->intContextOffset % OFFSET_UNITS)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.intContextOffset has to be divisible by %d", OFFSET_UNITS));
+
+ /* check that ic size+ic internal offset, does not exceed ic block size */
+ if (p_FmSpIntContextDataCopy->size + p_FmSpIntContextDataCopy->intContextOffset > MAX_IC_SIZE)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.size + intContext.intContextOffset has to be smaller than %d", MAX_IC_SIZE));
+ /* Check that divisible by 16 and not larger than 256 */
+ if (p_FmSpIntContextDataCopy->size % OFFSET_UNITS)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.size has to be divisible by %d", OFFSET_UNITS));
+
+ /* Check that divisible by 16 and not larger than 4K */
+ if (p_FmSpIntContextDataCopy->extBufOffset > MAX_EXT_OFFSET)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.extBufOffset can't be larger than %d", MAX_EXT_OFFSET));
+ if (p_FmSpIntContextDataCopy->extBufOffset % OFFSET_UNITS)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("intContext.extBufOffset has to be divisible by %d", OFFSET_UNITS));
+
+ return E_OK;
+}
+
+t_Error FmSpCheckBufMargins(t_FmSpBufMargins *p_FmSpBufMargins)
+{
+ /* Check the margin definition */
+ if (p_FmSpBufMargins->startMargins > MAX_EXT_BUFFER_OFFSET)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufMargins.startMargins can't be larger than %d", MAX_EXT_BUFFER_OFFSET));
+ if (p_FmSpBufMargins->endMargins > MAX_EXT_BUFFER_OFFSET)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("bufMargins.endMargins can't be larger than %d", MAX_EXT_BUFFER_OFFSET));
+
+ return E_OK;
+}
+
+t_Error FmSpBuildBufferStructure(t_FmSpIntContextDataCopy *p_FmSpIntContextDataCopy,
+ t_FmBufferPrefixContent *p_BufferPrefixContent,
+ t_FmSpBufMargins *p_FmSpBufMargins,
+ t_FmSpBufferOffsets *p_FmSpBufferOffsets,
+ uint8_t *internalBufferOffset)
+{
+ uint32_t tmp;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmSpIntContextDataCopy, E_INVALID_VALUE);
+ ASSERT_COND(p_FmSpIntContextDataCopy);
+ ASSERT_COND(p_BufferPrefixContent);
+ ASSERT_COND(p_FmSpBufMargins);
+ ASSERT_COND(p_FmSpBufferOffsets);
+
+ /* Align start of internal context data to 16 byte */
+ p_FmSpIntContextDataCopy->extBufOffset =
+ (uint16_t)((p_BufferPrefixContent->privDataSize & (OFFSET_UNITS-1)) ?
+ ((p_BufferPrefixContent->privDataSize + OFFSET_UNITS) & ~(uint16_t)(OFFSET_UNITS-1)) :
+ p_BufferPrefixContent->privDataSize);
+
+ /* Translate margin and intContext params to FM parameters */
+ /* Initialize with illegal value. Later we'll set legal values. */
+ p_FmSpBufferOffsets->prsResultOffset = (uint32_t)ILLEGAL_BASE;
+ p_FmSpBufferOffsets->timeStampOffset = (uint32_t)ILLEGAL_BASE;
+ p_FmSpBufferOffsets->hashResultOffset= (uint32_t)ILLEGAL_BASE;
+ p_FmSpBufferOffsets->pcdInfoOffset = (uint32_t)ILLEGAL_BASE;
+
+ /* Internally the driver supports 4 options
+ 1. prsResult/timestamp/hashResult selection (in fact 8 options, but for simplicity we'll
+ relate to it as 1).
+ 2. All IC context (from AD) not including debug.*/
+
+ /* This 'if' covers option 2. We copy from beginning of context. */
+ if (p_BufferPrefixContent->passAllOtherPCDInfo)
+ {
+ p_FmSpIntContextDataCopy->size = 128; /* must be aligned to 16 */
+ /* Start copying data after 16 bytes (FD) from the beginning of the internal context */
+ p_FmSpIntContextDataCopy->intContextOffset = 16;
+
+ if (p_BufferPrefixContent->passAllOtherPCDInfo)
+ p_FmSpBufferOffsets->pcdInfoOffset = p_FmSpIntContextDataCopy->extBufOffset;
+ if (p_BufferPrefixContent->passPrsResult)
+ p_FmSpBufferOffsets->prsResultOffset =
+ (uint32_t)(p_FmSpIntContextDataCopy->extBufOffset + 16);
+ if (p_BufferPrefixContent->passTimeStamp)
+ p_FmSpBufferOffsets->timeStampOffset =
+ (uint32_t)(p_FmSpIntContextDataCopy->extBufOffset + 48);
+ if (p_BufferPrefixContent->passHashResult)
+ p_FmSpBufferOffsets->hashResultOffset =
+ (uint32_t)(p_FmSpIntContextDataCopy->extBufOffset + 56);
+ }
+ else
+ {
+ /* This case covers the options under 1 */
+ /* Copy size must be in 16-byte granularity. */
+ p_FmSpIntContextDataCopy->size =
+ (uint16_t)((p_BufferPrefixContent->passPrsResult ? 32 : 0) +
+ ((p_BufferPrefixContent->passTimeStamp ||
+ p_BufferPrefixContent->passHashResult) ? 16 : 0));
+
+ /* Align start of internal context data to 16 byte */
+ p_FmSpIntContextDataCopy->intContextOffset =
+ (uint8_t)(p_BufferPrefixContent->passPrsResult ? 32 :
+ ((p_BufferPrefixContent->passTimeStamp ||
+ p_BufferPrefixContent->passHashResult) ? 64 : 0));
+
+ if (p_BufferPrefixContent->passPrsResult)
+ p_FmSpBufferOffsets->prsResultOffset = p_FmSpIntContextDataCopy->extBufOffset;
+ if (p_BufferPrefixContent->passTimeStamp)
+ p_FmSpBufferOffsets->timeStampOffset = p_BufferPrefixContent->passPrsResult ?
+ (p_FmSpIntContextDataCopy->extBufOffset + sizeof(t_FmPrsResult)) :
+ p_FmSpIntContextDataCopy->extBufOffset;
+ if (p_BufferPrefixContent->passHashResult)
+ /* If PR is not requested, whether TS is requested or not, IC will be copied from TS */
+ p_FmSpBufferOffsets->hashResultOffset = p_BufferPrefixContent->passPrsResult ?
+ (p_FmSpIntContextDataCopy->extBufOffset + sizeof(t_FmPrsResult) + 8) :
+ p_FmSpIntContextDataCopy->extBufOffset + 8;
+ }
+
+ if (p_FmSpIntContextDataCopy->size)
+ p_FmSpBufMargins->startMargins =
+ (uint16_t)(p_FmSpIntContextDataCopy->extBufOffset +
+ p_FmSpIntContextDataCopy->size);
+ else
+ /* No Internal Context passing, STartMargin is immediately after privateInfo */
+ p_FmSpBufMargins->startMargins = p_BufferPrefixContent->privDataSize;
+
+ /* save extra space for manip in both external and internal buffers */
+ if (p_BufferPrefixContent->manipExtraSpace)
+ {
+ uint8_t extraSpace;
+#ifdef FM_CAPWAP_SUPPORT
+ if ((p_BufferPrefixContent->manipExtraSpace + CAPWAP_FRAG_EXTRA_SPACE) >= 256)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("p_BufferPrefixContent->manipExtraSpace should be less than %d",
+ 256-CAPWAP_FRAG_EXTRA_SPACE));
+ extraSpace = (uint8_t)(p_BufferPrefixContent->manipExtraSpace + CAPWAP_FRAG_EXTRA_SPACE);
+#else
+ extraSpace = p_BufferPrefixContent->manipExtraSpace;
+#endif /* FM_CAPWAP_SUPPORT */
+ p_FmSpBufferOffsets->manipOffset = p_FmSpBufMargins->startMargins;
+ p_FmSpBufMargins->startMargins += extraSpace;
+ *internalBufferOffset = extraSpace;
+ }
+
+ /* align data start */
+ tmp = (uint32_t)(p_FmSpBufMargins->startMargins % p_BufferPrefixContent->dataAlign);
+ if (tmp)
+ p_FmSpBufMargins->startMargins += (p_BufferPrefixContent->dataAlign-tmp);
+ p_FmSpBufferOffsets->dataOffset = p_FmSpBufMargins->startMargins;
+
+ return E_OK;
+}
+/*********************** End of inter-module routines ************************/
+
+
+#if (DPAA_VERSION >= 11)
+/*****************************************************************************/
+/* API routines */
+/*****************************************************************************/
+t_Handle FM_VSP_Config(t_FmVspParams *p_FmVspParams)
+{
+ t_FmVspEntry *p_FmVspEntry = NULL;
+ struct fm_storage_profile_params fm_vsp_params;
+
+ p_FmVspEntry = (t_FmVspEntry *)XX_Malloc(sizeof(t_FmVspEntry));
+ if (!p_FmVspEntry)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("p_StorageProfile allocation failed"));
+ return NULL;
+ }
+ memset(p_FmVspEntry, 0, sizeof(t_FmVspEntry));
+
+ p_FmVspEntry->p_FmVspEntryDriverParams = (t_FmVspEntryDriverParams *)XX_Malloc(sizeof(t_FmVspEntryDriverParams));
+ if (!p_FmVspEntry->p_FmVspEntryDriverParams)
+ {
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("p_StorageProfile allocation failed"));
+ XX_Free(p_FmVspEntry);
+ return NULL;
+ }
+ memset(p_FmVspEntry->p_FmVspEntryDriverParams, 0, sizeof(t_FmVspEntryDriverParams));
+ fman_vsp_defconfig(&fm_vsp_params);
+ p_FmVspEntry->p_FmVspEntryDriverParams->dmaHeaderCacheAttr = fm_vsp_params.header_cache_attr;
+ p_FmVspEntry->p_FmVspEntryDriverParams->dmaIntContextCacheAttr = fm_vsp_params.int_context_cache_attr;
+ p_FmVspEntry->p_FmVspEntryDriverParams->dmaScatterGatherCacheAttr = fm_vsp_params.scatter_gather_cache_attr;
+ p_FmVspEntry->p_FmVspEntryDriverParams->dmaSwapData = fm_vsp_params.dma_swap_data;
+ p_FmVspEntry->p_FmVspEntryDriverParams->dmaWriteOptimize = fm_vsp_params.dma_write_optimize;
+ p_FmVspEntry->p_FmVspEntryDriverParams->noScatherGather = fm_vsp_params.no_scather_gather;
+ p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.privDataSize = DEFAULT_FM_SP_bufferPrefixContent_privDataSize;
+ p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.passPrsResult= DEFAULT_FM_SP_bufferPrefixContent_passPrsResult;
+ p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.passTimeStamp= DEFAULT_FM_SP_bufferPrefixContent_passTimeStamp;
+ p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.passAllOtherPCDInfo
+ = DEFAULT_FM_SP_bufferPrefixContent_passTimeStamp;
+ p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.dataAlign = DEFAULT_FM_SP_bufferPrefixContent_dataAlign;
+ p_FmVspEntry->p_FmVspEntryDriverParams->liodnOffset = p_FmVspParams->liodnOffset;
+
+ memcpy(&p_FmVspEntry->p_FmVspEntryDriverParams->extBufPools, &p_FmVspParams->extBufPools, sizeof(t_FmExtPools));
+ p_FmVspEntry->h_Fm = p_FmVspParams->h_Fm;
+ p_FmVspEntry->portType = p_FmVspParams->portParams.portType;
+ p_FmVspEntry->portId = p_FmVspParams->portParams.portId;
+
+ p_FmVspEntry->relativeProfileId = p_FmVspParams->relativeProfileId;
+
+ return p_FmVspEntry;
+}
+
+t_Error FM_VSP_Init(t_Handle h_FmVsp)
+{
+
+ t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry *)h_FmVsp;
+ struct fm_storage_profile_params fm_vsp_params;
+ uint8_t orderedArray[FM_PORT_MAX_NUM_OF_EXT_POOLS];
+ uint16_t sizesArray[BM_MAX_NUM_OF_POOLS];
+ t_Error err;
+ uint16_t absoluteProfileId = 0;
+ int i = 0;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams,E_INVALID_HANDLE);
+
+ CHECK_INIT_PARAMETERS(p_FmVspEntry, CheckParams);
+
+ memset(&orderedArray, 0, sizeof(uint8_t) * FM_PORT_MAX_NUM_OF_EXT_POOLS);
+ memset(&sizesArray, 0, sizeof(uint16_t) * BM_MAX_NUM_OF_POOLS);
+
+ err = FmSpBuildBufferStructure(&p_FmVspEntry->intContext,
+ &p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent,
+ &p_FmVspEntry->bufMargins,
+ &p_FmVspEntry->bufferOffsets,
+ &p_FmVspEntry->internalBufferOffset);
+ if (err != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+
+ err = CheckParamsGeneratedInternally(p_FmVspEntry);
+ if (err != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
+
+ p_FmVspEntry->p_FmSpRegsBase =
+ (struct fm_pcd_storage_profile_regs *)FmGetVSPBaseAddr(p_FmVspEntry->h_Fm);
+ if (!p_FmVspEntry->p_FmSpRegsBase)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("impossible to initialize SpRegsBase"));
+
+ /* order external buffer pools in ascending order of buffer pools sizes */
+ FmSpSetBufPoolsInAscOrderOfBufSizes(&(p_FmVspEntry->p_FmVspEntryDriverParams)->extBufPools,
+ orderedArray,
+ sizesArray);
+
+ p_FmVspEntry->extBufPools.numOfPoolsUsed =
+ p_FmVspEntry->p_FmVspEntryDriverParams->extBufPools.numOfPoolsUsed;
+ for (i = 0; i < p_FmVspEntry->extBufPools.numOfPoolsUsed; i++)
+ {
+ p_FmVspEntry->extBufPools.extBufPool[i].id = orderedArray[i];
+ p_FmVspEntry->extBufPools.extBufPool[i].size = sizesArray[orderedArray[i]];
+ }
+
+ /* on user responsibility to fill it according requirement */
+ memset(&fm_vsp_params, 0, sizeof(struct fm_storage_profile_params));
+ fm_vsp_params.dma_swap_data = p_FmVspEntry->p_FmVspEntryDriverParams->dmaSwapData;
+ fm_vsp_params.int_context_cache_attr = p_FmVspEntry->p_FmVspEntryDriverParams->dmaIntContextCacheAttr;
+ fm_vsp_params.header_cache_attr = p_FmVspEntry->p_FmVspEntryDriverParams->dmaHeaderCacheAttr;
+ fm_vsp_params.scatter_gather_cache_attr = p_FmVspEntry->p_FmVspEntryDriverParams->dmaScatterGatherCacheAttr;
+ fm_vsp_params.dma_write_optimize = p_FmVspEntry->p_FmVspEntryDriverParams->dmaWriteOptimize;
+ fm_vsp_params.liodn_offset = p_FmVspEntry->p_FmVspEntryDriverParams->liodnOffset;
+ fm_vsp_params.no_scather_gather = p_FmVspEntry->p_FmVspEntryDriverParams->noScatherGather;
+
+ if (p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion)
+ {
+ fm_vsp_params.buf_pool_depletion.buf_pool_depletion_enabled = TRUE;
+ fm_vsp_params.buf_pool_depletion.pools_grp_mode_enable = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion->poolsGrpModeEnable;
+ fm_vsp_params.buf_pool_depletion.num_pools = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion->numOfPools;
+ fm_vsp_params.buf_pool_depletion.pools_to_consider = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion->poolsToConsider;
+ fm_vsp_params.buf_pool_depletion.single_pool_mode_enable = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion->singlePoolModeEnable;
+ fm_vsp_params.buf_pool_depletion.pools_to_consider_for_single_mode = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion->poolsToConsiderForSingleMode;
+ fm_vsp_params.buf_pool_depletion.has_pfc_priorities = TRUE;
+ fm_vsp_params.buf_pool_depletion.pfc_priorities_en = p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion->pfcPrioritiesEn;
+ }
+ else
+ fm_vsp_params.buf_pool_depletion.buf_pool_depletion_enabled = FALSE;
+
+ if (p_FmVspEntry->p_FmVspEntryDriverParams->p_BackupBmPools)
+ {
+ fm_vsp_params.backup_pools.num_backup_pools = p_FmVspEntry->p_FmVspEntryDriverParams->p_BackupBmPools->numOfBackupPools;
+ fm_vsp_params.backup_pools.pool_ids = p_FmVspEntry->p_FmVspEntryDriverParams->p_BackupBmPools->poolIds;
+ }
+ else
+ fm_vsp_params.backup_pools.num_backup_pools = 0;
+
+ fm_vsp_params.fm_ext_pools.num_pools_used = p_FmVspEntry->extBufPools.numOfPoolsUsed;
+ fm_vsp_params.fm_ext_pools.ext_buf_pool = (struct fman_ext_pool_params*)&p_FmVspEntry->extBufPools.extBufPool;
+ fm_vsp_params.buf_margins = (struct fman_sp_buf_margins*)&p_FmVspEntry->bufMargins;
+ fm_vsp_params.int_context = (struct fman_sp_int_context_data_copy*)&p_FmVspEntry->intContext;
+
+ /* no check on err - it was checked earlier */
+ FmVSPGetAbsoluteProfileId(p_FmVspEntry->h_Fm,
+ p_FmVspEntry->portType,
+ p_FmVspEntry->portId,
+ p_FmVspEntry->relativeProfileId,
+ &absoluteProfileId);
+
+ ASSERT_COND(p_FmVspEntry->p_FmSpRegsBase);
+ ASSERT_COND(fm_vsp_params.int_context);
+ ASSERT_COND(fm_vsp_params.buf_margins);
+ ASSERT_COND((absoluteProfileId <= FM_VSP_MAX_NUM_OF_ENTRIES));
+
+ /* Set all registers related to VSP */
+ fman_vsp_init(p_FmVspEntry->p_FmSpRegsBase, absoluteProfileId, &fm_vsp_params,FM_PORT_MAX_NUM_OF_EXT_POOLS, BM_MAX_NUM_OF_POOLS, FM_MAX_NUM_OF_PFC_PRIORITIES);
+
+ p_FmVspEntry->absoluteSpId = absoluteProfileId;
+
+ if (p_FmVspEntry->p_FmVspEntryDriverParams)
+ XX_Free(p_FmVspEntry->p_FmVspEntryDriverParams);
+ p_FmVspEntry->p_FmVspEntryDriverParams = NULL;
+
+ return E_OK;
+}
+
+t_Error FM_VSP_Free(t_Handle h_FmVsp)
+{
+ t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry *)h_FmVsp;
+ SANITY_CHECK_RETURN_ERROR(h_FmVsp, E_INVALID_HANDLE);
+ XX_Free(p_FmVspEntry);
+ return E_OK;
+}
+
+t_Error FM_VSP_ConfigBufferPrefixContent(t_Handle h_FmVsp, t_FmBufferPrefixContent *p_FmBufferPrefixContent)
+{
+ t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
+
+ memcpy(&p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent, p_FmBufferPrefixContent, sizeof(t_FmBufferPrefixContent));
+ /* if dataAlign was not initialized by user, we return to driver's default */
+ if (!p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.dataAlign)
+ p_FmVspEntry->p_FmVspEntryDriverParams->bufferPrefixContent.dataAlign = DEFAULT_FM_SP_bufferPrefixContent_dataAlign;
+
+ return E_OK;
+}
+
+t_Error FM_VSP_ConfigDmaSwapData(t_Handle h_FmVsp, e_FmDmaSwapOption swapData)
+{
+ t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
+
+ p_FmVspEntry->p_FmVspEntryDriverParams->dmaSwapData = swapData;
+
+ return E_OK;
+}
+
+t_Error FM_VSP_ConfigDmaIcCacheAttr(t_Handle h_FmVsp, e_FmDmaCacheOption intContextCacheAttr)
+{
+ t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
+
+ p_FmVspEntry->p_FmVspEntryDriverParams->dmaIntContextCacheAttr = intContextCacheAttr;
+
+ return E_OK;
+}
+
+t_Error FM_VSP_ConfigDmaHdrAttr(t_Handle h_FmVsp, e_FmDmaCacheOption headerCacheAttr)
+{
+ t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
+
+ p_FmVspEntry->p_FmVspEntryDriverParams->dmaHeaderCacheAttr = headerCacheAttr;
+
+ return E_OK;
+}
+
+t_Error FM_VSP_ConfigDmaScatterGatherAttr(t_Handle h_FmVsp, e_FmDmaCacheOption scatterGatherCacheAttr)
+{
+ t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
+
+ p_FmVspEntry->p_FmVspEntryDriverParams->dmaScatterGatherCacheAttr = scatterGatherCacheAttr;
+
+ return E_OK;
+}
+
+t_Error FM_VSP_ConfigDmaWriteOptimize(t_Handle h_FmVsp, bool optimize)
+{
+ t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
+
+
+ p_FmVspEntry->p_FmVspEntryDriverParams->dmaWriteOptimize = optimize;
+
+ return E_OK;
+}
+
+t_Error FM_VSP_ConfigNoScatherGather(t_Handle h_FmVsp, bool noScatherGather)
+{
+ t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
+
+
+ p_FmVspEntry->p_FmVspEntryDriverParams->noScatherGather = noScatherGather;
+
+ return E_OK;
+}
+
+t_Error FM_VSP_ConfigPoolDepletion(t_Handle h_FmVsp, t_FmBufPoolDepletion *p_BufPoolDepletion)
+{
+ t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
+
+ SANITY_CHECK_RETURN_ERROR(h_FmVsp, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_BufPoolDepletion, E_INVALID_HANDLE);
+
+ p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion = (t_FmBufPoolDepletion *)XX_Malloc(sizeof(t_FmBufPoolDepletion));
+ if (!p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("p_BufPoolDepletion allocation failed"));
+ memcpy(p_FmVspEntry->p_FmVspEntryDriverParams->p_BufPoolDepletion, p_BufPoolDepletion, sizeof(t_FmBufPoolDepletion));
+
+ return E_OK;
+}
+
+t_Error FM_VSP_ConfigBackupPools(t_Handle h_FmVsp, t_FmBackupBmPools *p_BackupBmPools)
+{
+ t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
+
+ SANITY_CHECK_RETURN_ERROR(h_FmVsp, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_BackupBmPools, E_INVALID_HANDLE);
+
+ p_FmVspEntry->p_FmVspEntryDriverParams->p_BackupBmPools = (t_FmBackupBmPools *)XX_Malloc(sizeof(t_FmBackupBmPools));
+ if (!p_FmVspEntry->p_FmVspEntryDriverParams->p_BackupBmPools)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("p_BackupBmPools allocation failed"));
+ memcpy(p_FmVspEntry->p_FmVspEntryDriverParams->p_BackupBmPools, p_BackupBmPools, sizeof(t_FmBackupBmPools));
+
+ return E_OK;
+}
+
+uint32_t FM_VSP_GetBufferDataOffset(t_Handle h_FmVsp)
+{
+ t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
+
+ SANITY_CHECK_RETURN_VALUE(p_FmVspEntry, E_INVALID_HANDLE, 0);
+ SANITY_CHECK_RETURN_VALUE(!p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_STATE, 0);
+
+ return p_FmVspEntry->bufferOffsets.dataOffset;
+}
+
+uint8_t * FM_VSP_GetBufferICInfo(t_Handle h_FmVsp, char *p_Data)
+{
+ t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
+
+ SANITY_CHECK_RETURN_VALUE(p_FmVspEntry, E_INVALID_HANDLE, NULL);
+ SANITY_CHECK_RETURN_VALUE(!p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_STATE, NULL);
+
+ if (p_FmVspEntry->bufferOffsets.pcdInfoOffset == ILLEGAL_BASE)
+ return NULL;
+
+ return (uint8_t *)PTR_MOVE(p_Data, p_FmVspEntry->bufferOffsets.pcdInfoOffset);
+}
+
+t_FmPrsResult * FM_VSP_GetBufferPrsResult(t_Handle h_FmVsp, char *p_Data)
+{
+ t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
+
+ SANITY_CHECK_RETURN_VALUE(p_FmVspEntry, E_INVALID_HANDLE, NULL);
+ SANITY_CHECK_RETURN_VALUE(!p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_STATE, NULL);
+
+ if (p_FmVspEntry->bufferOffsets.prsResultOffset == ILLEGAL_BASE)
+ return NULL;
+
+ return (t_FmPrsResult *)PTR_MOVE(p_Data, p_FmVspEntry->bufferOffsets.prsResultOffset);
+}
+
+uint64_t * FM_VSP_GetBufferTimeStamp(t_Handle h_FmVsp, char *p_Data)
+{
+ t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
+
+ SANITY_CHECK_RETURN_VALUE(p_FmVspEntry, E_INVALID_HANDLE, NULL);
+ SANITY_CHECK_RETURN_VALUE(!p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_STATE, NULL);
+
+ if (p_FmVspEntry->bufferOffsets.timeStampOffset == ILLEGAL_BASE)
+ return NULL;
+
+ return (uint64_t *)PTR_MOVE(p_Data, p_FmVspEntry->bufferOffsets.timeStampOffset);
+}
+
+uint8_t * FM_VSP_GetBufferHashResult(t_Handle h_FmVsp, char *p_Data)
+{
+ t_FmVspEntry *p_FmVspEntry = (t_FmVspEntry*)h_FmVsp;
+
+ SANITY_CHECK_RETURN_VALUE(p_FmVspEntry, E_INVALID_HANDLE, NULL);
+ SANITY_CHECK_RETURN_VALUE(!p_FmVspEntry->p_FmVspEntryDriverParams, E_INVALID_STATE, NULL);
+
+ if (p_FmVspEntry->bufferOffsets.hashResultOffset == ILLEGAL_BASE)
+ return NULL;
+
+ return (uint8_t *)PTR_MOVE(p_Data, p_FmVspEntry->bufferOffsets.hashResultOffset);
+}
+
+#endif /* (DPAA_VERSION >= 11) */
diff --git a/sys/contrib/ncsw/Peripherals/FM/SP/fm_sp.h b/sys/contrib/ncsw/Peripherals/FM/SP/fm_sp.h
new file mode 100644
index 000000000000..9c171d85a5bb
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/SP/fm_sp.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/******************************************************************************
+ @File fm_sp.h
+
+ @Description FM SP ...
+*//***************************************************************************/
+#ifndef __FM_SP_H
+#define __FM_SP_H
+
+#include "std_ext.h"
+#include "error_ext.h"
+#include "list_ext.h"
+
+#include "fm_sp_common.h"
+#include "fm_common.h"
+
+
+#define __ERR_MODULE__ MODULE_FM_SP
+
+typedef struct {
+ t_FmBufferPrefixContent bufferPrefixContent;
+ e_FmDmaSwapOption dmaSwapData;
+ e_FmDmaCacheOption dmaIntContextCacheAttr;
+ e_FmDmaCacheOption dmaHeaderCacheAttr;
+ e_FmDmaCacheOption dmaScatterGatherCacheAttr;
+ bool dmaWriteOptimize;
+ uint16_t liodnOffset;
+ bool noScatherGather;
+ t_FmBufPoolDepletion *p_BufPoolDepletion;
+ t_FmBackupBmPools *p_BackupBmPools;
+ t_FmExtPools extBufPools;
+} t_FmVspEntryDriverParams;
+
+typedef struct {
+ bool valid;
+ volatile bool lock;
+ uint8_t pointedOwners;
+ uint16_t absoluteSpId;
+ uint8_t internalBufferOffset;
+ t_FmSpBufMargins bufMargins;
+ t_FmSpIntContextDataCopy intContext;
+ t_FmSpBufferOffsets bufferOffsets;
+ t_Handle h_Fm;
+ e_FmPortType portType; /**< Port type */
+ uint8_t portId; /**< Port Id - relative to type */
+ uint8_t relativeProfileId;
+ struct fm_pcd_storage_profile_regs *p_FmSpRegsBase;
+ t_FmExtPools extBufPools;
+ t_FmVspEntryDriverParams *p_FmVspEntryDriverParams;
+} t_FmVspEntry;
+
+
+#endif /* __FM_SP_H */
diff --git a/sys/contrib/ncsw/Peripherals/FM/SP/fman_sp.c b/sys/contrib/ncsw/Peripherals/FM/SP/fman_sp.c
new file mode 100755
index 000000000000..0f772e919792
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/SP/fman_sp.c
@@ -0,0 +1,197 @@
+/*
+ * Copyright 2013 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "fsl_fman_sp.h"
+
+
+uint32_t fman_vsp_get_statistics(struct fm_pcd_storage_profile_regs *regs,
+ uint16_t index)
+{
+ struct fm_pcd_storage_profile_regs *sp_regs;
+ sp_regs = &regs[index];
+ return ioread32be(&sp_regs->fm_sp_acnt);
+}
+
+void fman_vsp_set_statistics(struct fm_pcd_storage_profile_regs *regs,
+ uint16_t index, uint32_t value)
+{
+ struct fm_pcd_storage_profile_regs *sp_regs;
+ sp_regs = &regs[index];
+ iowrite32be(value, &sp_regs->fm_sp_acnt);
+}
+
+void fman_vsp_defconfig(struct fm_storage_profile_params *cfg)
+{
+ cfg->dma_swap_data =
+ DEFAULT_FMAN_SP_DMA_SWAP_DATA;
+ cfg->int_context_cache_attr =
+ DEFAULT_FMAN_SP_DMA_INT_CONTEXT_CACHE_ATTR;
+ cfg->header_cache_attr =
+ DEFAULT_FMAN_SP_DMA_HEADER_CACHE_ATTR;
+ cfg->scatter_gather_cache_attr =
+ DEFAULT_FMAN_SP_DMA_SCATTER_GATHER_CACHE_ATTR;
+ cfg->dma_write_optimize =
+ DEFAULT_FMAN_SP_DMA_WRITE_OPTIMIZE;
+ cfg->no_scather_gather =
+ DEFAULT_FMAN_SP_NO_SCATTER_GATHER;
+}
+
+static inline uint32_t calc_vec_dep(int max_pools, bool *pools,
+ struct fman_ext_pools *ext_buf_pools, uint32_t mask)
+{
+ int i, j;
+ uint32_t vector = 0;
+ for (i = 0; i < max_pools; i++)
+ if (pools[i])
+ for (j = 0; j < ext_buf_pools->num_pools_used; j++)
+ if (i == ext_buf_pools->ext_buf_pool[j].id) {
+ vector |= mask >> j;
+ break;
+ }
+ return vector;
+}
+
+void fman_vsp_init(struct fm_pcd_storage_profile_regs *regs,
+ uint16_t index, struct fm_storage_profile_params *fm_vsp_params,
+ int port_max_num_of_ext_pools, int bm_max_num_of_pools,
+ int max_num_of_pfc_priorities)
+{
+ int i = 0, j = 0;
+ struct fm_pcd_storage_profile_regs *sp_regs;
+ uint32_t tmp_reg, vector;
+ struct fman_ext_pools *ext_buf_pools = &fm_vsp_params->fm_ext_pools;
+ struct fman_buf_pool_depletion *buf_pool_depletion =
+ &fm_vsp_params->buf_pool_depletion;
+ struct fman_backup_bm_pools *backup_pools =
+ &fm_vsp_params->backup_pools;
+ struct fman_sp_int_context_data_copy *int_context_data_copy =
+ fm_vsp_params->int_context;
+ struct fman_sp_buf_margins *external_buffer_margins =
+ fm_vsp_params->buf_margins;
+ bool no_scather_gather = fm_vsp_params->no_scather_gather;
+ uint16_t liodn_offset = fm_vsp_params->liodn_offset;
+
+ sp_regs = &regs[index];
+
+ /* fill external buffers manager pool information register*/
+ for (i = 0; i < ext_buf_pools->num_pools_used; i++) {
+ tmp_reg = FMAN_SP_EXT_BUF_POOL_VALID |
+ FMAN_SP_EXT_BUF_POOL_EN_COUNTER;
+ tmp_reg |= ((uint32_t)ext_buf_pools->ext_buf_pool[i].id <<
+ FMAN_SP_EXT_BUF_POOL_ID_SHIFT);
+ tmp_reg |= ext_buf_pools->ext_buf_pool[i].size;
+ /* functionality available only for some deriviatives
+ (limited by config) */
+ for (j = 0; j < backup_pools->num_backup_pools; j++)
+ if (ext_buf_pools->ext_buf_pool[i].id ==
+ backup_pools->pool_ids[j]) {
+ tmp_reg |= FMAN_SP_EXT_BUF_POOL_BACKUP;
+ break;
+ }
+ iowrite32be(tmp_reg, &sp_regs->fm_sp_ebmpi[i]);
+ }
+
+ /* clear unused pools */
+ for (i = ext_buf_pools->num_pools_used;
+ i < port_max_num_of_ext_pools; i++)
+ iowrite32be(0, &sp_regs->fm_sp_ebmpi[i]);
+
+ /* fill pool depletion register*/
+ tmp_reg = 0;
+ if (buf_pool_depletion->buf_pool_depletion_enabled && buf_pool_depletion->pools_grp_mode_enable) {
+ /* calculate vector for number of pools depletion */
+ vector = calc_vec_dep(bm_max_num_of_pools, buf_pool_depletion->
+ pools_to_consider, ext_buf_pools, 0x80000000);
+
+ /* configure num of pools and vector for number of pools mode */
+ tmp_reg |= (((uint32_t)buf_pool_depletion->num_pools - 1) <<
+ FMAN_SP_POOL_DEP_NUM_OF_POOLS_SHIFT);
+ tmp_reg |= vector;
+ }
+
+ if (buf_pool_depletion->buf_pool_depletion_enabled && buf_pool_depletion->single_pool_mode_enable) {
+ /* calculate vector for number of pools depletion */
+ vector = calc_vec_dep(bm_max_num_of_pools, buf_pool_depletion->
+ pools_to_consider_for_single_mode,
+ ext_buf_pools, 0x00000080);
+
+ /* configure num of pools and vector for number of pools mode */
+ tmp_reg |= vector;
+ }
+
+ /* fill QbbPEV */
+ if (buf_pool_depletion->buf_pool_depletion_enabled) {
+ vector = 0;
+ for (i = 0; i < max_num_of_pfc_priorities; i++)
+ if (buf_pool_depletion->pfc_priorities_en[i] == TRUE)
+ vector |= 0x00000100 << i;
+ tmp_reg |= vector;
+ }
+ iowrite32be(tmp_reg, &sp_regs->fm_sp_mpd);
+
+ /* fill dma attributes register */
+ tmp_reg = 0;
+ tmp_reg |= (uint32_t)fm_vsp_params->dma_swap_data <<
+ FMAN_SP_DMA_ATTR_SWP_SHIFT;
+ tmp_reg |= (uint32_t)fm_vsp_params->int_context_cache_attr <<
+ FMAN_SP_DMA_ATTR_IC_CACHE_SHIFT;
+ tmp_reg |= (uint32_t)fm_vsp_params->header_cache_attr <<
+ FMAN_SP_DMA_ATTR_HDR_CACHE_SHIFT;
+ tmp_reg |= (uint32_t)fm_vsp_params->scatter_gather_cache_attr <<
+ FMAN_SP_DMA_ATTR_SG_CACHE_SHIFT;
+ if (fm_vsp_params->dma_write_optimize)
+ tmp_reg |= FMAN_SP_DMA_ATTR_WRITE_OPTIMIZE;
+ iowrite32be(tmp_reg, &sp_regs->fm_sp_da);
+
+ /* IC parameters - fill internal context parameters register */
+ tmp_reg = 0;
+ tmp_reg |= (((uint32_t)int_context_data_copy->ext_buf_offset/
+ OFFSET_UNITS) << FMAN_SP_IC_TO_EXT_SHIFT);
+ tmp_reg |= (((uint32_t)int_context_data_copy->int_context_offset/
+ OFFSET_UNITS) << FMAN_SP_IC_FROM_INT_SHIFT);
+ tmp_reg |= (((uint32_t)int_context_data_copy->size/OFFSET_UNITS) <<
+ FMAN_SP_IC_SIZE_SHIFT);
+ iowrite32be(tmp_reg, &sp_regs->fm_sp_icp);
+
+ /* buffer margins - fill external buffer margins register */
+ tmp_reg = 0;
+ tmp_reg |= (((uint32_t)external_buffer_margins->start_margins) <<
+ FMAN_SP_EXT_BUF_MARG_START_SHIFT);
+ tmp_reg |= (((uint32_t)external_buffer_margins->end_margins) <<
+ FMAN_SP_EXT_BUF_MARG_END_SHIFT);
+ if (no_scather_gather)
+ tmp_reg |= FMAN_SP_SG_DISABLE;
+ iowrite32be(tmp_reg, &sp_regs->fm_sp_ebm);
+
+ /* buffer margins - fill spliodn register */
+ iowrite32be(liodn_offset, &sp_regs->fm_sp_spliodn);
+}
diff --git a/sys/contrib/ncsw/Peripherals/FM/fm.c b/sys/contrib/ncsw/Peripherals/FM/fm.c
index a0f225167d9a..884bc45edd3b 100644
--- a/sys/contrib/ncsw/Peripherals/FM/fm.c
+++ b/sys/contrib/ncsw/Peripherals/FM/fm.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm.c
@@ -42,10 +43,12 @@
#include "sprint_ext.h"
#include "debug_ext.h"
#include "fm_muram_ext.h"
+#include <linux/math64.h>
#include "fm_common.h"
#include "fm_ipc.h"
#include "fm.h"
+#include "fsl_fman.h"
/****************************************/
@@ -63,6 +66,16 @@ static void IpcMsgCompletionCB(t_Handle h_Fm,
blockingFlag = FALSE;
}
+static void FreeInitResources(t_Fm *p_Fm)
+{
+ if (p_Fm->camBaseAddr)
+ FM_MURAM_FreeMem(p_Fm->h_FmMuram, UINT_TO_PTR(p_Fm->camBaseAddr));
+ if (p_Fm->fifoBaseAddr)
+ FM_MURAM_FreeMem(p_Fm->h_FmMuram, UINT_TO_PTR(p_Fm->fifoBaseAddr));
+ if (p_Fm->resAddr)
+ FM_MURAM_FreeMem(p_Fm->h_FmMuram, UINT_TO_PTR(p_Fm->resAddr));
+}
+
static bool IsFmanCtrlCodeLoaded(t_Fm *p_Fm)
{
t_FMIramRegs *p_Iram;
@@ -75,187 +88,229 @@ static bool IsFmanCtrlCodeLoaded(t_Fm *p_Fm)
static t_Error CheckFmParameters(t_Fm *p_Fm)
{
- if (IsFmanCtrlCodeLoaded(p_Fm) && !p_Fm->p_FmDriverParam->resetOnInit)
+ if (IsFmanCtrlCodeLoaded(p_Fm) && !p_Fm->resetOnInit)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Old FMan CTRL code is loaded; FM must be reset!"));
- if(!p_Fm->p_FmDriverParam->dmaAxiDbgNumOfBeats || (p_Fm->p_FmDriverParam->dmaAxiDbgNumOfBeats > DMA_MODE_MAX_AXI_DBG_NUM_OF_BEATS))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("axiDbgNumOfBeats has to be in the range 1 - %d", DMA_MODE_MAX_AXI_DBG_NUM_OF_BEATS));
- if(p_Fm->p_FmDriverParam->dmaCamNumOfEntries % DMA_CAM_UNITS)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dmaCamNumOfEntries has to be divisble by %d", DMA_CAM_UNITS));
- if(!p_Fm->p_FmDriverParam->dmaCamNumOfEntries || (p_Fm->p_FmDriverParam->dmaCamNumOfEntries > DMA_MODE_MAX_CAM_NUM_OF_ENTRIES))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dmaCamNumOfEntries has to be in the range 1 - %d", DMA_MODE_MAX_CAM_NUM_OF_ENTRIES));
- if(p_Fm->p_FmDriverParam->dmaCommQThresholds.assertEmergency > DMA_THRESH_MAX_COMMQ)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dmaCommQThresholds.assertEmergency can not be larger than %d", DMA_THRESH_MAX_COMMQ));
- if(p_Fm->p_FmDriverParam->dmaCommQThresholds.clearEmergency > DMA_THRESH_MAX_COMMQ)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dmaCommQThresholds.clearEmergency can not be larger than %d", DMA_THRESH_MAX_COMMQ));
- if(p_Fm->p_FmDriverParam->dmaCommQThresholds.clearEmergency >= p_Fm->p_FmDriverParam->dmaCommQThresholds.assertEmergency)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dmaCommQThresholds.clearEmergency must be smaller than dmaCommQThresholds.assertEmergency"));
- if(p_Fm->p_FmDriverParam->dmaReadBufThresholds.assertEmergency > DMA_THRESH_MAX_BUF)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dmaReadBufThresholds.assertEmergency can not be larger than %d", DMA_THRESH_MAX_BUF));
- if(p_Fm->p_FmDriverParam->dmaReadBufThresholds.clearEmergency > DMA_THRESH_MAX_BUF)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dmaReadBufThresholds.clearEmergency can not be larger than %d", DMA_THRESH_MAX_BUF));
- if(p_Fm->p_FmDriverParam->dmaReadBufThresholds.clearEmergency >= p_Fm->p_FmDriverParam->dmaReadBufThresholds.assertEmergency)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dmaReadBufThresholds.clearEmergency must be smaller than dmaReadBufThresholds.assertEmergency"));
- if(p_Fm->p_FmDriverParam->dmaWriteBufThresholds.assertEmergency > DMA_THRESH_MAX_BUF)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dmaWriteBufThresholds.assertEmergency can not be larger than %d", DMA_THRESH_MAX_BUF));
- if(p_Fm->p_FmDriverParam->dmaWriteBufThresholds.clearEmergency > DMA_THRESH_MAX_BUF)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dmaWriteBufThresholds.clearEmergency can not be larger than %d", DMA_THRESH_MAX_BUF));
- if(p_Fm->p_FmDriverParam->dmaWriteBufThresholds.clearEmergency >= p_Fm->p_FmDriverParam->dmaWriteBufThresholds.assertEmergency)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dmaWriteBufThresholds.clearEmergency must be smaller than dmaWriteBufThresholds.assertEmergency"));
-
- if(!p_Fm->p_FmStateStruct->fmClkFreq)
+#if (DPAA_VERSION < 11)
+ if (!p_Fm->p_FmDriverParam->dma_axi_dbg_num_of_beats ||
+ (p_Fm->p_FmDriverParam->dma_axi_dbg_num_of_beats > DMA_MODE_MAX_AXI_DBG_NUM_OF_BEATS))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("axiDbgNumOfBeats has to be in the range 1 - %d", DMA_MODE_MAX_AXI_DBG_NUM_OF_BEATS));
+#endif /* (DPAA_VERSION < 11) */
+ if (p_Fm->p_FmDriverParam->dma_cam_num_of_entries % DMA_CAM_UNITS)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_cam_num_of_entries has to be divisble by %d", DMA_CAM_UNITS));
+// if (!p_Fm->p_FmDriverParam->dma_cam_num_of_entries || (p_Fm->p_FmDriverParam->dma_cam_num_of_entries > DMA_MODE_MAX_CAM_NUM_OF_ENTRIES))
+// RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_cam_num_of_entries has to be in the range 1 - %d", DMA_MODE_MAX_CAM_NUM_OF_ENTRIES));
+ if (p_Fm->p_FmDriverParam->dma_comm_qtsh_asrt_emer > DMA_THRESH_MAX_COMMQ)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_comm_qtsh_asrt_emer can not be larger than %d", DMA_THRESH_MAX_COMMQ));
+ if (p_Fm->p_FmDriverParam->dma_comm_qtsh_clr_emer > DMA_THRESH_MAX_COMMQ)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_comm_qtsh_clr_emer can not be larger than %d", DMA_THRESH_MAX_COMMQ));
+ if (p_Fm->p_FmDriverParam->dma_comm_qtsh_clr_emer >= p_Fm->p_FmDriverParam->dma_comm_qtsh_asrt_emer)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_comm_qtsh_clr_emer must be smaller than dma_comm_qtsh_asrt_emer"));
+#if (DPAA_VERSION < 11)
+ if (p_Fm->p_FmDriverParam->dma_read_buf_tsh_asrt_emer > DMA_THRESH_MAX_BUF)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_read_buf_tsh_asrt_emer can not be larger than %d", DMA_THRESH_MAX_BUF));
+ if (p_Fm->p_FmDriverParam->dma_read_buf_tsh_clr_emer > DMA_THRESH_MAX_BUF)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_read_buf_tsh_clr_emer can not be larger than %d", DMA_THRESH_MAX_BUF));
+ if (p_Fm->p_FmDriverParam->dma_read_buf_tsh_clr_emer >= p_Fm->p_FmDriverParam->dma_read_buf_tsh_asrt_emer)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_read_buf_tsh_clr_emer must be smaller than dma_read_buf_tsh_asrt_emer"));
+ if (p_Fm->p_FmDriverParam->dma_write_buf_tsh_asrt_emer > DMA_THRESH_MAX_BUF)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_write_buf_tsh_asrt_emer can not be larger than %d", DMA_THRESH_MAX_BUF));
+ if (p_Fm->p_FmDriverParam->dma_write_buf_tsh_clr_emer > DMA_THRESH_MAX_BUF)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_write_buf_tsh_clr_emer can not be larger than %d", DMA_THRESH_MAX_BUF));
+ if (p_Fm->p_FmDriverParam->dma_write_buf_tsh_clr_emer >= p_Fm->p_FmDriverParam->dma_write_buf_tsh_asrt_emer)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_write_buf_tsh_clr_emer must be smaller than dma_write_buf_tsh_asrt_emer"));
+#else /* (DPAA_VERSION >= 11) */
+ if ((p_Fm->p_FmDriverParam->dma_dbg_cnt_mode == E_FMAN_DMA_DBG_CNT_INT_READ_EM)||
+ (p_Fm->p_FmDriverParam->dma_dbg_cnt_mode == E_FMAN_DMA_DBG_CNT_INT_WRITE_EM) ||
+ (p_Fm->p_FmDriverParam->dma_dbg_cnt_mode == E_FMAN_DMA_DBG_CNT_RAW_WAR_PROT))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_dbg_cnt_mode value not supported by this integration."));
+ if ((p_Fm->p_FmDriverParam->dma_emergency_bus_select == FM_DMA_MURAM_READ_EMERGENCY)||
+ (p_Fm->p_FmDriverParam->dma_emergency_bus_select == FM_DMA_MURAM_WRITE_EMERGENCY))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("emergencyBusSelect value not supported by this integration."));
+ if (p_Fm->p_FmDriverParam->dma_stop_on_bus_error)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_stop_on_bus_error not supported by this integration."));
+#ifdef FM_AID_MODE_NO_TNUM_SW005
+ if (p_Fm->p_FmDriverParam->dma_aid_mode != E_FMAN_DMA_AID_OUT_PORT_ID)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_aid_mode not supported by this integration."));
+#endif /* FM_AID_MODE_NO_TNUM_SW005 */
+ if (p_Fm->p_FmDriverParam->dma_axi_dbg_num_of_beats)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("dma_axi_dbg_num_of_beats not supported by this integration."));
+#endif /* (DPAA_VERSION < 11) */
+
+ if (!p_Fm->p_FmStateStruct->fmClkFreq)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("fmClkFreq must be set."));
- if (USEC_TO_CLK(p_Fm->p_FmDriverParam->dmaWatchdog, p_Fm->p_FmStateStruct->fmClkFreq) > DMA_MAX_WATCHDOG)
+ if (USEC_TO_CLK(p_Fm->p_FmDriverParam->dma_watchdog, p_Fm->p_FmStateStruct->fmClkFreq) > DMA_MAX_WATCHDOG)
RETURN_ERROR(MAJOR, E_INVALID_VALUE,
- ("dmaWatchdog depends on FM clock. dmaWatchdog(in microseconds) * clk (in Mhz), may not exceed 0x08x", DMA_MAX_WATCHDOG));
+ ("dma_watchdog depends on FM clock. dma_watchdog(in microseconds) * clk (in Mhz), may not exceed 0x08x", DMA_MAX_WATCHDOG));
-#ifdef FM_PARTITION_ARRAY
- {
- t_FmRevisionInfo revInfo;
- uint8_t i;
+#if (DPAA_VERSION >= 11)
+ if ((p_Fm->partVSPBase + p_Fm->partNumOfVSPs) > FM_VSP_MAX_NUM_OF_ENTRIES)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("partVSPBase+partNumOfVSPs out of range!!!"));
+#endif /* (DPAA_VERSION >= 11) */
- FM_GetRevision(p_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- for (i=0; i<FM_SIZE_OF_LIODN_TABLE; i++)
- if (p_Fm->p_FmDriverParam->liodnBasePerPort[i] & ~FM_LIODN_BASE_MASK)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("liodn number is out of range"));
- }
-#endif /* FM_PARTITION_ARRAY */
-
- if(p_Fm->p_FmStateStruct->totalFifoSize % BMI_FIFO_UNITS)
+ if (p_Fm->p_FmStateStruct->totalFifoSize % BMI_FIFO_UNITS)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("totalFifoSize number has to be divisible by %d", BMI_FIFO_UNITS));
- if(!p_Fm->p_FmStateStruct->totalFifoSize || (p_Fm->p_FmStateStruct->totalFifoSize > BMI_MAX_FIFO_SIZE))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("totalFifoSize number has to be in the range 256 - %d", BMI_MAX_FIFO_SIZE));
- if(!p_Fm->p_FmStateStruct->totalNumOfTasks || (p_Fm->p_FmStateStruct->totalNumOfTasks > BMI_MAX_NUM_OF_TASKS))
+ if (!p_Fm->p_FmStateStruct->totalFifoSize ||
+ (p_Fm->p_FmStateStruct->totalFifoSize > BMI_MAX_FIFO_SIZE))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("totalFifoSize (currently defined as %d) has to be in the range of 256 to %d",
+ p_Fm->p_FmStateStruct->totalFifoSize,
+ BMI_MAX_FIFO_SIZE));
+ if (!p_Fm->p_FmStateStruct->totalNumOfTasks ||
+ (p_Fm->p_FmStateStruct->totalNumOfTasks > BMI_MAX_NUM_OF_TASKS))
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("totalNumOfTasks number has to be in the range 1 - %d", BMI_MAX_NUM_OF_TASKS));
- if(!p_Fm->p_FmStateStruct->maxNumOfOpenDmas || (p_Fm->p_FmStateStruct->maxNumOfOpenDmas > BMI_MAX_NUM_OF_DMAS))
+
+#ifdef FM_HAS_TOTAL_DMAS
+ if (!p_Fm->p_FmStateStruct->maxNumOfOpenDmas ||
+ (p_Fm->p_FmStateStruct->maxNumOfOpenDmas > BMI_MAX_NUM_OF_DMAS))
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("maxNumOfOpenDmas number has to be in the range 1 - %d", BMI_MAX_NUM_OF_DMAS));
+#endif /* FM_HAS_TOTAL_DMAS */
- if(p_Fm->p_FmDriverParam->thresholds.dispLimit > FPM_MAX_DISP_LIMIT)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("thresholds.dispLimit can't be greater than %d", FPM_MAX_DISP_LIMIT));
+ if (p_Fm->p_FmDriverParam->disp_limit_tsh > FPM_MAX_DISP_LIMIT)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("disp_limit_tsh can't be greater than %d", FPM_MAX_DISP_LIMIT));
- if(!p_Fm->f_Exception)
+ if (!p_Fm->f_Exception)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Exceptions callback not provided"));
- if(!p_Fm->f_BusError)
+ if (!p_Fm->f_BusError)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Exceptions callback not provided"));
+#ifdef FM_NO_WATCHDOG
+ if ((p_Fm->p_FmStateStruct->revInfo.majorRev == 2) &&
+ (p_Fm->p_FmDriverParam->dma_watchdog))
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("watchdog!"));
+#endif /* FM_NO_WATCHDOG */
+
+#ifdef FM_ECC_HALT_NO_SYNC_ERRATA_10GMAC_A008
+ if ((p_Fm->p_FmStateStruct->revInfo.majorRev < 6) &&
+ (p_Fm->p_FmDriverParam->halt_on_unrecov_ecc_err))
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("HaltOnEccError!"));
+#endif /* FM_ECC_HALT_NO_SYNC_ERRATA_10GMAC_A008 */
+
+#ifdef FM_NO_TNUM_AGING
+ if ((p_Fm->p_FmStateStruct->revInfo.majorRev != 4) &&
+ (p_Fm->p_FmStateStruct->revInfo.majorRev < 6))
+ if (p_Fm->p_FmDriverParam->tnum_aging_period)
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("Tnum aging!"));
+#endif /* FM_NO_TNUM_AGING */
+
+ /* check that user did not set revision-dependent exceptions */
+#ifdef FM_NO_DISPATCH_RAM_ECC
+ if ((p_Fm->p_FmStateStruct->revInfo.majorRev != 4) &&
+ (p_Fm->p_FmStateStruct->revInfo.majorRev < 6))
+ if (p_Fm->userSetExceptions & FM_EX_BMI_DISPATCH_RAM_ECC)
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("exception e_FM_EX_BMI_DISPATCH_RAM_ECC!"));
+#endif /* FM_NO_DISPATCH_RAM_ECC */
+
+#ifdef FM_QMI_NO_ECC_EXCEPTIONS
+ if (p_Fm->p_FmStateStruct->revInfo.majorRev == 4)
+ if (p_Fm->userSetExceptions & (FM_EX_QMI_SINGLE_ECC | FM_EX_QMI_DOUBLE_ECC))
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("exception e_FM_EX_QMI_SINGLE_ECC/e_FM_EX_QMI_DOUBLE_ECC!"));
+#endif /* FM_QMI_NO_ECC_EXCEPTIONS */
+
+#ifdef FM_QMI_NO_SINGLE_ECC_EXCEPTION
+ if (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6)
+ if (p_Fm->userSetExceptions & FM_EX_QMI_SINGLE_ECC)
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("exception e_FM_EX_QMI_SINGLE_ECC!"));
+#endif /* FM_QMI_NO_SINGLE_ECC_EXCEPTION */
+
return E_OK;
}
+
static void SendIpcIsr(t_Fm *p_Fm, uint32_t macEvent, uint32_t pendingReg)
{
- t_Error err;
- t_FmIpcIsr fmIpcIsr;
- t_FmIpcMsg msg;
-
ASSERT_COND(p_Fm->guestId == NCSW_MASTER_ID);
- ASSERT_COND(p_Fm->h_IpcSessions[p_Fm->intrMng[macEvent].guestId]);
- if (p_Fm->intrMng[macEvent].guestId != NCSW_MASTER_ID)
+
+ if (p_Fm->intrMng[macEvent].guestId == NCSW_MASTER_ID)
+ p_Fm->intrMng[macEvent].f_Isr(p_Fm->intrMng[macEvent].h_SrcHandle);
+
+ /* If the MAC is running on guest-partition and we have IPC session with it,
+ we inform him about the event through IPC; otherwise, we ignore the event. */
+ else if (p_Fm->h_IpcSessions[p_Fm->intrMng[macEvent].guestId])
{
+ t_Error err;
+ t_FmIpcIsr fmIpcIsr;
+ t_FmIpcMsg msg;
+
memset(&msg, 0, sizeof(msg));
msg.msgId = FM_GUEST_ISR;
fmIpcIsr.pendingReg = pendingReg;
fmIpcIsr.boolErr = FALSE;
memcpy(msg.msgBody, &fmIpcIsr, sizeof(fmIpcIsr));
- if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[p_Fm->intrMng[macEvent].guestId],
- (uint8_t*)&msg,
- sizeof(msg.msgId) + sizeof(fmIpcIsr),
- NULL,
- NULL,
- NULL,
- NULL)) != E_OK)
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[p_Fm->intrMng[macEvent].guestId],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId) + sizeof(fmIpcIsr),
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ if (err != E_OK)
REPORT_ERROR(MINOR, err, NO_MSG);
- return;
}
else
- p_Fm->intrMng[macEvent].f_Isr(p_Fm->intrMng[macEvent].h_SrcHandle);
+ DBG(TRACE, ("FM Guest mode, without IPC - can't call ISR!"));
}
-static void BmiErrEvent(t_Fm *p_Fm)
+static void BmiErrEvent(t_Fm *p_Fm)
{
- uint32_t event, mask, force;
-
- event = GET_UINT32(p_Fm->p_FmBmiRegs->fmbm_ievr);
- mask = GET_UINT32(p_Fm->p_FmBmiRegs->fmbm_ier);
- event &= mask;
-
- /* clear the forced events */
- force = GET_UINT32(p_Fm->p_FmBmiRegs->fmbm_ifr);
- if(force & event)
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_ifr, force & ~event);
+ uint32_t event;
+ struct fman_bmi_regs *bmi_rg = p_Fm->p_FmBmiRegs;
- /* clear the acknowledged events */
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_ievr, event);
+ event = fman_get_bmi_err_event(bmi_rg);
- if(event & BMI_ERR_INTR_EN_PIPELINE_ECC)
- p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_BMI_PIPELINE_ECC);
- if(event & BMI_ERR_INTR_EN_LIST_RAM_ECC)
+ if (event & BMI_ERR_INTR_EN_STORAGE_PROFILE_ECC)
+ p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_BMI_STORAGE_PROFILE_ECC);
+ if (event & BMI_ERR_INTR_EN_LIST_RAM_ECC)
p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_BMI_LIST_RAM_ECC);
- if(event & BMI_ERR_INTR_EN_STATISTICS_RAM_ECC)
+ if (event & BMI_ERR_INTR_EN_STATISTICS_RAM_ECC)
p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_BMI_STATISTICS_RAM_ECC);
- if(event & BMI_ERR_INTR_EN_DISPATCH_RAM_ECC)
+ if (event & BMI_ERR_INTR_EN_DISPATCH_RAM_ECC)
p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_BMI_DISPATCH_RAM_ECC);
}
static void QmiErrEvent(t_Fm *p_Fm)
{
- uint32_t event, mask, force;
-
- event = GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_eie);
- mask = GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_eien);
-
- event &= mask;
-
- /* clear the forced events */
- force = GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_eif);
- if(force & event)
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_eif, force & ~event);
+ uint32_t event;
+ struct fman_qmi_regs *qmi_rg = p_Fm->p_FmQmiRegs;
- /* clear the acknowledged events */
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_eie, event);
+ event = fman_get_qmi_err_event(qmi_rg);
- if(event & QMI_ERR_INTR_EN_DOUBLE_ECC)
+ if (event & QMI_ERR_INTR_EN_DOUBLE_ECC)
p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_QMI_DOUBLE_ECC);
- if(event & QMI_ERR_INTR_EN_DEQ_FROM_DEF)
+ if (event & QMI_ERR_INTR_EN_DEQ_FROM_DEF)
p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID);
}
static void DmaErrEvent(t_Fm *p_Fm)
{
- uint64_t addr=0;
- uint32_t status, mask, tmpReg=0;
+ uint32_t status, com_id;
uint8_t tnum;
uint8_t hardwarePortId;
uint8_t relativePortId;
uint16_t liodn;
+ struct fman_dma_regs *dma_rg = p_Fm->p_FmDmaRegs;
- status = GET_UINT32(p_Fm->p_FmDmaRegs->fmdmsr);
- mask = GET_UINT32(p_Fm->p_FmDmaRegs->fmdmmr);
+ status = fman_get_dma_err_event(dma_rg);
- /* get bus error regs befor clearing BER */
- if ((status & DMA_STATUS_BUS_ERR) && (mask & DMA_MODE_BER))
+ if (status & DMA_STATUS_BUS_ERR)
{
- addr = (uint64_t)GET_UINT32(p_Fm->p_FmDmaRegs->fmdmtal);
- addr |= ((uint64_t)(GET_UINT32(p_Fm->p_FmDmaRegs->fmdmtah)) << 32);
-
- /* get information about the owner of that bus error */
- tmpReg = GET_UINT32(p_Fm->p_FmDmaRegs->fmdmtcid);
- }
-
- /* clear set events */
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmsr, status);
-
- if ((status & DMA_STATUS_BUS_ERR) && (mask & DMA_MODE_BER))
- {
- hardwarePortId = (uint8_t)(((tmpReg & DMA_TRANSFER_PORTID_MASK) >> DMA_TRANSFER_PORTID_SHIFT));
+ com_id = fman_get_dma_com_id(dma_rg);
+ hardwarePortId = (uint8_t)(((com_id & DMA_TRANSFER_PORTID_MASK) >> DMA_TRANSFER_PORTID_SHIFT));
+ ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
HW_PORT_ID_TO_SW_PORT_ID(relativePortId, hardwarePortId);
- tnum = (uint8_t)((tmpReg & DMA_TRANSFER_TNUM_MASK) >> DMA_TRANSFER_TNUM_SHIFT);
- liodn = (uint16_t)(tmpReg & DMA_TRANSFER_LIODN_MASK);
+ tnum = (uint8_t)((com_id & DMA_TRANSFER_TNUM_MASK) >> DMA_TRANSFER_TNUM_SHIFT);
+ liodn = (uint16_t)(com_id & DMA_TRANSFER_LIODN_MASK);
ASSERT_COND(p_Fm->p_FmStateStruct->portsTypes[hardwarePortId] != e_FM_PORT_TYPE_DUMMY);
- p_Fm->f_BusError(p_Fm->h_App, p_Fm->p_FmStateStruct->portsTypes[hardwarePortId], relativePortId, addr, tnum, liodn);
+ p_Fm->f_BusError(p_Fm->h_App,
+ p_Fm->p_FmStateStruct->portsTypes[hardwarePortId],
+ relativePortId,
+ fman_get_dma_addr(dma_rg),
+ tnum,
+ liodn);
}
- if(mask & DMA_MODE_ECC)
- {
+ if (status & DMA_STATUS_FM_SPDAT_ECC)
+ p_Fm->f_Exception(p_Fm->h_App, e_FM_EX_DMA_SINGLE_PORT_ECC);
if (status & DMA_STATUS_READ_ECC)
p_Fm->f_Exception(p_Fm->h_App, e_FM_EX_DMA_READ_ECC);
if (status & DMA_STATUS_SYSTEM_WRITE_ECC)
@@ -263,76 +318,52 @@ static void DmaErrEvent(t_Fm *p_Fm)
if (status & DMA_STATUS_FM_WRITE_ECC)
p_Fm->f_Exception(p_Fm->h_App, e_FM_EX_DMA_FM_WRITE_ECC);
}
-}
static void FpmErrEvent(t_Fm *p_Fm)
{
uint32_t event;
+ struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
- event = GET_UINT32(p_Fm->p_FmFpmRegs->fpmem);
-
- /* clear the all occurred events */
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmem, event);
+ event = fman_get_fpm_err_event(fpm_rg);
- if((event & FPM_EV_MASK_DOUBLE_ECC) && (event & FPM_EV_MASK_DOUBLE_ECC_EN))
+ if ((event & FPM_EV_MASK_DOUBLE_ECC) && (event & FPM_EV_MASK_DOUBLE_ECC_EN))
p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_FPM_DOUBLE_ECC);
- if((event & FPM_EV_MASK_STALL) && (event & FPM_EV_MASK_STALL_EN))
+ if ((event & FPM_EV_MASK_STALL) && (event & FPM_EV_MASK_STALL_EN))
p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_FPM_STALL_ON_TASKS);
- if((event & FPM_EV_MASK_SINGLE_ECC) && (event & FPM_EV_MASK_SINGLE_ECC_EN))
+ if ((event & FPM_EV_MASK_SINGLE_ECC) && (event & FPM_EV_MASK_SINGLE_ECC_EN))
p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_FPM_SINGLE_ECC);
}
static void MuramErrIntr(t_Fm *p_Fm)
{
- uint32_t event, mask;
-
- event = GET_UINT32(p_Fm->p_FmFpmRegs->fmrcr);
- mask = GET_UINT32(p_Fm->p_FmFpmRegs->fmrie);
-
- /* clear MURAM event bit */
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fmrcr, event & ~FPM_RAM_CTL_IRAM_ECC);
+ uint32_t event;
+ struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
- ASSERT_COND(event & FPM_RAM_CTL_MURAM_ECC);
- ASSERT_COND(event & FPM_RAM_CTL_RAMS_ECC_EN);
+ event = fman_get_muram_err_event(fpm_rg);
- if ((mask & FPM_MURAM_ECC_ERR_EX_EN))
+ if (event & FPM_RAM_MURAM_ECC)
p_Fm->f_Exception(p_Fm->h_App, e_FM_EX_MURAM_ECC);
}
static void IramErrIntr(t_Fm *p_Fm)
{
- uint32_t event, mask;
-
- event = GET_UINT32(p_Fm->p_FmFpmRegs->fmrcr) ;
- mask = GET_UINT32(p_Fm->p_FmFpmRegs->fmrie);
- /* clear the acknowledged events (do not clear IRAM event) */
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fmrcr, event & ~FPM_RAM_CTL_MURAM_ECC);
+ uint32_t event;
+ struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
- ASSERT_COND(event & FPM_RAM_CTL_IRAM_ECC);
- ASSERT_COND(event & FPM_RAM_CTL_IRAM_ECC_EN);
+ event = fman_get_iram_err_event(fpm_rg);
- if ((mask & FPM_IRAM_ECC_ERR_EX_EN))
+ if (event & FPM_RAM_IRAM_ECC)
p_Fm->f_Exception(p_Fm->h_App, e_FM_EX_IRAM_ECC);
}
static void QmiEvent(t_Fm *p_Fm)
{
- uint32_t event, mask, force;
-
- event = GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_ie);
- mask = GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_ien);
-
- event &= mask;
-
- /* clear the forced events */
- force = GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_if);
- if(force & event)
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_if, force & ~event);
+ uint32_t event;
+ struct fman_qmi_regs *qmi_rg = p_Fm->p_FmQmiRegs;
- /* clear the acknowledged events */
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_ie, event);
+ event = fman_get_qmi_event(qmi_rg);
- if(event & QMI_INTR_EN_SINGLE_ECC)
+ if (event & QMI_INTR_EN_SINGLE_ECC)
p_Fm->f_Exception(p_Fm->h_App,e_FM_EX_QMI_SINGLE_ECC);
}
@@ -340,74 +371,46 @@ static void UnimplementedIsr(t_Handle h_Arg)
{
UNUSED(h_Arg);
- REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Unimplemented Isr!"));
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Unimplemented ISR!"));
}
static void UnimplementedFmanCtrlIsr(t_Handle h_Arg, uint32_t event)
{
UNUSED(h_Arg); UNUSED(event);
- REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Unimplemented FmCtl Isr!"));
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Unimplemented FmCtl ISR!"));
}
-static void FmEnableTimeStamp(t_Fm *p_Fm)
+static void EnableTimeStamp(t_Fm *p_Fm)
{
- uint32_t tmpReg;
- uint64_t fraction;
- uint32_t integer;
- uint8_t count1MicroBit = 8;
- uint32_t tsFrequency = (uint32_t)(1<<count1MicroBit); /* in Mhz */
+ struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
- /* configure timestamp so that bit 8 will count 1 microsecond */
- /* Find effective count rate at TIMESTAMP least significant bits:
- Effective_Count_Rate = 1MHz x 2^8 = 256MHz
- Find frequency ratio between effective count rate and the clock:
- Effective_Count_Rate / CLK e.g. for 600 MHz clock:
- 256/600 = 0.4266666... */
- integer = tsFrequency/p_Fm->p_FmStateStruct->fmClkFreq;
- /* we multiply by 2^16 to keep the fraction of the division */
- /* we do not divid back, since we write this value as fraction - see spec */
- fraction = ((tsFrequency << 16) - (integer << 16)*p_Fm->p_FmStateStruct->fmClkFreq)/p_Fm->p_FmStateStruct->fmClkFreq;
- /* we check remainder of the division in order to round up if not integer */
- if(((tsFrequency << 16) - (integer << 16)*p_Fm->p_FmStateStruct->fmClkFreq) % p_Fm->p_FmStateStruct->fmClkFreq)
- fraction++;
+ ASSERT_COND(p_Fm->p_FmStateStruct);
+ ASSERT_COND(p_Fm->p_FmStateStruct->count1MicroBit);
- tmpReg = (integer << FPM_TS_INT_SHIFT) | (uint16_t)fraction;
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmtsc2, tmpReg);
+ fman_enable_time_stamp(fpm_rg, p_Fm->p_FmStateStruct->count1MicroBit, p_Fm->p_FmStateStruct->fmClkFreq);
- /* enable timestamp with original clock */
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmtsc1, FPM_TS_CTL_EN);
-
- p_Fm->p_FmStateStruct->count1MicroBit = count1MicroBit;
p_Fm->p_FmStateStruct->enabledTimeStamp = TRUE;
}
-static void FreeInitResources(t_Fm *p_Fm)
-{
- if (p_Fm->camBaseAddr)
- FM_MURAM_FreeMem(p_Fm->h_FmMuram, UINT_TO_PTR(p_Fm->camBaseAddr));
- if (p_Fm->fifoBaseAddr)
- FM_MURAM_FreeMem(p_Fm->h_FmMuram, UINT_TO_PTR(p_Fm->fifoBaseAddr));
- if (p_Fm->resAddr)
- FM_MURAM_FreeMem(p_Fm->h_FmMuram, UINT_TO_PTR(p_Fm->resAddr));
-}
-
static t_Error ClearIRam(t_Fm *p_Fm)
{
t_FMIramRegs *p_Iram;
int i;
+ int iram_size;
ASSERT_COND(p_Fm);
p_Iram = (t_FMIramRegs *)UINT_TO_PTR(p_Fm->baseAddr + FM_MM_IMEM);
+ iram_size = FM_IRAM_SIZE(p_Fm->p_FmStateStruct->revInfo.majorRev,p_Fm->p_FmStateStruct->revInfo.minorRev);
/* Enable the auto-increment */
WRITE_UINT32(p_Iram->iadd, IRAM_IADD_AIE);
while (GET_UINT32(p_Iram->iadd) != IRAM_IADD_AIE) ;
- for (i=0; i < (FM_IRAM_SIZE/4); i++)
+ for (i=0; i < (iram_size/4); i++)
WRITE_UINT32(p_Iram->idata, 0xffffffff);
- WRITE_UINT32(p_Iram->iadd, FM_IRAM_SIZE - 4);
+ WRITE_UINT32(p_Iram->iadd, iram_size - 4);
CORE_MemoryBarrier();
while (GET_UINT32(p_Iram->idata) != 0xffffffff) ;
@@ -428,29 +431,32 @@ static t_Error LoadFmanCtrlCode(t_Fm *p_Fm)
WRITE_UINT32(p_Iram->iadd, IRAM_IADD_AIE);
while (GET_UINT32(p_Iram->iadd) != IRAM_IADD_AIE) ;
- for (i=0; i < (p_Fm->p_FmDriverParam->firmware.size / 4); i++)
- WRITE_UINT32(p_Iram->idata, p_Fm->p_FmDriverParam->firmware.p_Code[i]);
+ for (i=0; i < (p_Fm->firmware.size / 4); i++)
+ WRITE_UINT32(p_Iram->idata, p_Fm->firmware.p_Code[i]);
- compTo16 = (uint8_t)(p_Fm->p_FmDriverParam->firmware.size % 16);
- if(compTo16)
+ compTo16 = (uint8_t)(p_Fm->firmware.size % 16);
+ if (compTo16)
for (i=0; i < ((16-compTo16) / 4); i++)
WRITE_UINT32(p_Iram->idata, 0xffffffff);
- WRITE_UINT32(p_Iram->iadd,p_Fm->p_FmDriverParam->firmware.size-4);
- while(GET_UINT32(p_Iram->iadd) != (p_Fm->p_FmDriverParam->firmware.size-4)) ;
+ WRITE_UINT32(p_Iram->iadd,p_Fm->firmware.size-4);
+ while (GET_UINT32(p_Iram->iadd) != (p_Fm->firmware.size-4)) ;
/* verify that writing has completed */
- while (GET_UINT32(p_Iram->idata) != p_Fm->p_FmDriverParam->firmware.p_Code[(p_Fm->p_FmDriverParam->firmware.size / 4)-1]) ;
+ while (GET_UINT32(p_Iram->idata) != p_Fm->firmware.p_Code[(p_Fm->firmware.size / 4)-1]) ;
- if (p_Fm->p_FmDriverParam->fwVerify)
+ if (p_Fm->fwVerify)
{
WRITE_UINT32(p_Iram->iadd, IRAM_IADD_AIE);
while (GET_UINT32(p_Iram->iadd) != IRAM_IADD_AIE) ;
- for (i=0; i < (p_Fm->p_FmDriverParam->firmware.size / 4); i++)
- if ((tmp=GET_UINT32(p_Iram->idata)) != p_Fm->p_FmDriverParam->firmware.p_Code[i])
+ for (i=0; i < (p_Fm->firmware.size / 4); i++)
+ {
+ tmp = GET_UINT32(p_Iram->idata);
+ if (tmp != p_Fm->firmware.p_Code[i])
RETURN_ERROR(MAJOR, E_WRITE_FAILED,
("UCode write error : write 0x%x, read 0x%x",
- p_Fm->p_FmDriverParam->firmware.p_Code[i],tmp));
+ p_Fm->firmware.p_Code[i],tmp));
+ }
WRITE_UINT32(p_Iram->iadd, 0x0);
}
@@ -458,12 +464,75 @@ static t_Error LoadFmanCtrlCode(t_Fm *p_Fm)
WRITE_UINT32(p_Iram->iready, IRAM_READY);
XX_UDelay(1000);
- DBG(INFO, ("FMan-Controller code (ver %d.%d) loaded to IRAM.",
- ((uint8_t *)p_Fm->p_FmDriverParam->firmware.p_Code)[5],
- ((uint8_t *)p_Fm->p_FmDriverParam->firmware.p_Code)[7]));
+ DBG(INFO, ("FMan-Controller code (ver %d.%d.%d) loaded to IRAM.",
+ ((uint16_t *)p_Fm->firmware.p_Code)[2],
+ ((uint8_t *)p_Fm->firmware.p_Code)[6],
+ ((uint8_t *)p_Fm->firmware.p_Code)[7]));
+
+ return E_OK;
+}
+
+#ifdef FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173
+static t_Error FwNotResetErratumBugzilla6173WA(t_Fm *p_Fm)
+{
+ t_FMIramRegs *p_Iram = (t_FMIramRegs *)UINT_TO_PTR(p_Fm->baseAddr + FM_MM_IMEM);
+ uint32_t tmpReg;
+ uint32_t savedSpliodn[63];
+
+ /* write to IRAM first location the debug instruction */
+ WRITE_UINT32(p_Iram->iadd, 0);
+ while (GET_UINT32(p_Iram->iadd) != 0) ;
+ WRITE_UINT32(p_Iram->idata, FM_FW_DEBUG_INSTRUCTION);
+
+ WRITE_UINT32(p_Iram->iadd, 0);
+ while (GET_UINT32(p_Iram->iadd) != 0) ;
+ while (GET_UINT32(p_Iram->idata) != FM_FW_DEBUG_INSTRUCTION) ;
+
+ /* Enable patch from IRAM */
+ WRITE_UINT32(p_Iram->iready, IRAM_READY);
+ CORE_MemoryBarrier();
+ XX_UDelay(100);
+ IO2MemCpy32((uint8_t *)savedSpliodn,
+ (uint8_t *)p_Fm->p_FmBmiRegs->fmbm_spliodn,
+ 63*sizeof(uint32_t));
+
+ /* reset FMAN */
+ WRITE_UINT32(p_Fm->p_FmFpmRegs->fm_rstc, FPM_RSTC_FM_RESET);
+ CORE_MemoryBarrier();
+ XX_UDelay(100);
+
+ /* verify breakpoint debug status register */
+ tmpReg = GET_UINT32(*(uint32_t *)UINT_TO_PTR(p_Fm->baseAddr + FM_DEBUG_STATUS_REGISTER_OFFSET));
+ if (!tmpReg)
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Invalid debug status register value is '0'"));
+
+ /*************************************/
+ /* Load FMan-Controller code to IRAM */
+ /*************************************/
+ ClearIRam(p_Fm);
+ if (p_Fm->firmware.p_Code &&
+ (LoadFmanCtrlCode(p_Fm) != E_OK))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
+ XX_UDelay(100);
+
+ /* reset FMAN again to start the microcode */
+ WRITE_UINT32(p_Fm->p_FmFpmRegs->fm_rstc, FPM_RSTC_FM_RESET);
+ CORE_MemoryBarrier();
+ XX_UDelay(100);
+ Mem2IOCpy32((uint8_t *)p_Fm->p_FmBmiRegs->fmbm_spliodn,
+ (uint8_t *)savedSpliodn,
+ 63*sizeof(uint32_t));
+
+ if (fman_is_qmi_halt_not_busy_state(p_Fm->p_FmQmiRegs))
+ {
+ fman_resume(p_Fm->p_FmFpmRegs);
+ CORE_MemoryBarrier();
+ XX_UDelay(100);
+ }
return E_OK;
}
+#endif /* FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173 */
static void GuestErrorIsr(t_Fm *p_Fm, uint32_t pending)
{
@@ -487,35 +556,228 @@ do { \
FM_G_CALL_1G_MAC_ERR_ISR(3);
if (pending & ERR_INTR_EN_1G_MAC4)
FM_G_CALL_1G_MAC_ERR_ISR(4);
+ if (pending & ERR_INTR_EN_1G_MAC5)
+ FM_G_CALL_1G_MAC_ERR_ISR(5);
+ if (pending & ERR_INTR_EN_1G_MAC6)
+ FM_G_CALL_1G_MAC_ERR_ISR(6);
+ if (pending & ERR_INTR_EN_1G_MAC7)
+ FM_G_CALL_1G_MAC_ERR_ISR(7);
if (pending & ERR_INTR_EN_10G_MAC0)
FM_G_CALL_10G_MAC_ERR_ISR(0);
+ if (pending & ERR_INTR_EN_10G_MAC1)
+ FM_G_CALL_10G_MAC_ERR_ISR(1);
}
static void GuestEventIsr(t_Fm *p_Fm, uint32_t pending)
{
-#define FM_G_CALL_1G_MAC_TMR_ISR(_id) \
+#define FM_G_CALL_1G_MAC_ISR(_id) \
+do { \
+ p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_1G_MAC0+_id)].f_Isr(p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_1G_MAC0+_id)].h_SrcHandle);\
+} while (0)
+#define FM_G_CALL_10G_MAC_ISR(_id) \
do { \
- p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_1G_MAC0_TMR+_id)].f_Isr(p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_1G_MAC0_TMR+_id)].h_SrcHandle);\
+ p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_10G_MAC0+_id)].f_Isr(p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_10G_MAC0+_id)].h_SrcHandle);\
} while (0)
- if (pending & INTR_EN_1G_MAC0_TMR)
- FM_G_CALL_1G_MAC_TMR_ISR(0);
- if (pending & INTR_EN_1G_MAC1_TMR)
- FM_G_CALL_1G_MAC_TMR_ISR(1);
- if (pending & INTR_EN_1G_MAC2_TMR)
- FM_G_CALL_1G_MAC_TMR_ISR(2);
- if (pending & INTR_EN_1G_MAC3_TMR)
- FM_G_CALL_1G_MAC_TMR_ISR(3);
- if (pending & INTR_EN_1G_MAC4_TMR)
- FM_G_CALL_1G_MAC_TMR_ISR(4);
- if(pending & INTR_EN_TMR)
+ if (pending & INTR_EN_1G_MAC0)
+ FM_G_CALL_1G_MAC_ISR(0);
+ if (pending & INTR_EN_1G_MAC1)
+ FM_G_CALL_1G_MAC_ISR(1);
+ if (pending & INTR_EN_1G_MAC2)
+ FM_G_CALL_1G_MAC_ISR(2);
+ if (pending & INTR_EN_1G_MAC3)
+ FM_G_CALL_1G_MAC_ISR(3);
+ if (pending & INTR_EN_1G_MAC4)
+ FM_G_CALL_1G_MAC_ISR(4);
+ if (pending & INTR_EN_1G_MAC5)
+ FM_G_CALL_1G_MAC_ISR(5);
+ if (pending & INTR_EN_1G_MAC6)
+ FM_G_CALL_1G_MAC_ISR(6);
+ if (pending & INTR_EN_1G_MAC7)
+ FM_G_CALL_1G_MAC_ISR(7);
+ if (pending & INTR_EN_10G_MAC0)
+ FM_G_CALL_10G_MAC_ISR(0);
+ if (pending & INTR_EN_10G_MAC1)
+ FM_G_CALL_10G_MAC_ISR(1);
+ if (pending & INTR_EN_TMR)
p_Fm->intrMng[e_FM_EV_TMR].f_Isr(p_Fm->intrMng[e_FM_EV_TMR].h_SrcHandle);
}
+#if (DPAA_VERSION >= 11)
+static t_Error SetVSPWindow(t_Handle h_Fm,
+ uint8_t hardwarePortId,
+ uint8_t baseStorageProfile,
+ uint8_t log2NumOfProfiles)
+{
+ t_Fm *p_Fm = (t_Fm *)h_Fm;
+
+ ASSERT_COND(h_Fm);
+ ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
+
+ if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ !p_Fm->p_FmBmiRegs &&
+ p_Fm->h_IpcSessions[0])
+ {
+ t_FmIpcVspSetPortWindow fmIpcVspSetPortWindow;
+ t_FmIpcMsg msg;
+ t_Error err = E_OK;
+
+ memset(&msg, 0, sizeof(msg));
+ memset(&fmIpcVspSetPortWindow, 0, sizeof(t_FmIpcVspSetPortWindow));
+ fmIpcVspSetPortWindow.hardwarePortId = hardwarePortId;
+ fmIpcVspSetPortWindow.baseStorageProfile = baseStorageProfile;
+ fmIpcVspSetPortWindow.log2NumOfProfiles = log2NumOfProfiles;
+ msg.msgId = FM_VSP_SET_PORT_WINDOW;
+ memcpy(msg.msgBody, &fmIpcVspSetPortWindow, sizeof(t_FmIpcVspSetPortWindow));
+
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId),
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ if (err != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+ return E_OK;
+ }
+ else if (!p_Fm->p_FmBmiRegs)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("Either IPC or 'baseAddress' is required!"));
+
+ fman_set_vsp_window(p_Fm->p_FmBmiRegs,
+ hardwarePortId,
+ baseStorageProfile,
+ log2NumOfProfiles);
+
+ return E_OK;
+}
+
+static uint8_t AllocVSPsForPartition(t_Handle h_Fm, uint8_t base, uint8_t numOfProfiles, uint8_t guestId)
+{
+ t_Fm *p_Fm = (t_Fm *)h_Fm;
+ uint8_t profilesFound = 0;
+ int i = 0;
+ uint32_t intFlags;
+
+ if (!numOfProfiles)
+ return E_OK;
+
+ if ((numOfProfiles > FM_VSP_MAX_NUM_OF_ENTRIES) ||
+ (base + numOfProfiles > FM_VSP_MAX_NUM_OF_ENTRIES))
+ return (uint8_t)ILLEGAL_BASE;
+
+ if (p_Fm->h_IpcSessions[0])
+ {
+ t_FmIpcResourceAllocParams ipcAllocParams;
+ t_FmIpcMsg msg;
+ t_FmIpcReply reply;
+ t_Error err;
+ uint32_t replyLength;
+
+ memset(&msg, 0, sizeof(msg));
+ memset(&reply, 0, sizeof(reply));
+ memset(&ipcAllocParams, 0, sizeof(t_FmIpcResourceAllocParams));
+ ipcAllocParams.guestId = p_Fm->guestId;
+ ipcAllocParams.num = p_Fm->partNumOfVSPs;
+ ipcAllocParams.base = p_Fm->partVSPBase;
+ msg.msgId = FM_VSP_ALLOC;
+ memcpy(msg.msgBody, &ipcAllocParams, sizeof(t_FmIpcResourceAllocParams));
+ replyLength = sizeof(uint32_t) + sizeof(uint8_t);
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId) + sizeof(t_FmIpcResourceAllocParams),
+ (uint8_t*)&reply,
+ &replyLength,
+ NULL,
+ NULL);
+ if ((err != E_OK) ||
+ (replyLength != (sizeof(uint32_t) + sizeof(uint8_t))))
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ else
+ memcpy((uint8_t*)&p_Fm->partVSPBase, reply.replyBody, sizeof(uint8_t));
+ if (p_Fm->partVSPBase == (uint8_t)(ILLEGAL_BASE))
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+ if (p_Fm->guestId != NCSW_MASTER_ID)
+ {
+ DBG(WARNING, ("FM Guest mode, without IPC - can't validate VSP range!"));
+ return (uint8_t)ILLEGAL_BASE;
+ }
+
+ intFlags = XX_LockIntrSpinlock(p_Fm->h_Spinlock);
+ for (i = base; i < base + numOfProfiles; i++)
+ if (p_Fm->p_FmSp->profiles[i].profilesMng.ownerId == (uint8_t)ILLEGAL_BASE)
+ profilesFound++;
+ else
+ break;
+
+ if (profilesFound == numOfProfiles)
+ for (i = base; i<base + numOfProfiles; i++)
+ p_Fm->p_FmSp->profiles[i].profilesMng.ownerId = guestId;
+ else
+ {
+ XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
+ return (uint8_t)ILLEGAL_BASE;
+ }
+ XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
+
+ return base;
+}
+
+static void FreeVSPsForPartition(t_Handle h_Fm, uint8_t base, uint8_t numOfProfiles, uint8_t guestId)
+{
+ t_Fm *p_Fm = (t_Fm *)h_Fm;
+ int i = 0;
+
+ ASSERT_COND(p_Fm);
+
+ if (p_Fm->h_IpcSessions[0])
+ {
+ t_FmIpcResourceAllocParams ipcAllocParams;
+ t_FmIpcMsg msg;
+ t_FmIpcReply reply;
+ uint32_t replyLength;
+ t_Error err;
+
+ memset(&msg, 0, sizeof(msg));
+ memset(&reply, 0, sizeof(reply));
+ memset(&ipcAllocParams, 0, sizeof(t_FmIpcResourceAllocParams));
+ ipcAllocParams.guestId = p_Fm->guestId;
+ ipcAllocParams.num = p_Fm->partNumOfVSPs;
+ ipcAllocParams.base = p_Fm->partVSPBase;
+ msg.msgId = FM_VSP_FREE;
+ memcpy(msg.msgBody, &ipcAllocParams, sizeof(t_FmIpcResourceAllocParams));
+ replyLength = sizeof(uint32_t) + sizeof(uint8_t);
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId) + sizeof(t_FmIpcResourceAllocParams),
+ (uint8_t*)&reply,
+ &replyLength,
+ NULL,
+ NULL);
+ if (err != E_OK)
+ REPORT_ERROR(MAJOR, err, NO_MSG);
+ return;
+ }
+ if (p_Fm->guestId != NCSW_MASTER_ID)
+ {
+ DBG(WARNING, ("FM Guest mode, without IPC - can't validate VSP range!"));
+ return;
+ }
+
+ ASSERT_COND(p_Fm->p_FmSp);
+
+ for (i=base; i<numOfProfiles; i++)
+ {
+ if (p_Fm->p_FmSp->profiles[i].profilesMng.ownerId == guestId)
+ p_Fm->p_FmSp->profiles[i].profilesMng.ownerId = (uint8_t)ILLEGAL_BASE;
+ else
+ DBG(WARNING, ("Request for freeing storage profile window which wasn't allocated to this partition"));
+ }
+}
+#endif /* (DPAA_VERSION >= 11) */
-/****************************************/
-/* Inter-Module functions */
-/****************************************/
static t_Error FmGuestHandleIpcMsgCB(t_Handle h_Fm,
uint8_t *p_Msg,
uint32_t msgLength,
@@ -537,14 +799,14 @@ static t_Error FmGuestHandleIpcMsgCB(t_Handle h_Fm,
*p_ReplyLength = 0;
- switch(p_IpcMsg->msgId)
+ switch (p_IpcMsg->msgId)
{
case (FM_GUEST_ISR):
{
t_FmIpcIsr ipcIsr;
memcpy((uint8_t*)&ipcIsr, p_IpcMsg->msgBody, sizeof(t_FmIpcIsr));
- if(ipcIsr.boolErr)
+ if (ipcIsr.boolErr)
GuestErrorIsr(p_Fm, ipcIsr.pendingReg);
else
GuestEventIsr(p_Fm, ipcIsr.pendingReg);
@@ -563,6 +825,7 @@ static t_Error FmHandleIpcMsgCB(t_Handle h_Fm,
uint8_t *p_Reply,
uint32_t *p_ReplyLength)
{
+ t_Error err;
t_Fm *p_Fm = (t_Fm*)h_Fm;
t_FmIpcMsg *p_IpcMsg = (t_FmIpcMsg*)p_Msg;
t_FmIpcReply *p_IpcReply = (t_FmIpcReply*)p_Reply;
@@ -579,13 +842,13 @@ static t_Error FmHandleIpcMsgCB(t_Handle h_Fm,
memset(p_IpcReply, 0, (sizeof(uint8_t) * FM_IPC_MAX_REPLY_SIZE));
*p_ReplyLength = 0;
- switch(p_IpcMsg->msgId)
+ switch (p_IpcMsg->msgId)
{
case (FM_GET_SET_PORT_PARAMS):
{
t_FmIpcPortInInitParams ipcInitParams;
t_FmInterModulePortInitParams initParams;
- t_FmIpcPhysAddr ipcPhysAddr;
+ t_FmIpcPortOutInitParams ipcOutInitParams;
memcpy((uint8_t*)&ipcInitParams, p_IpcMsg->msgBody, sizeof(t_FmIpcPortInInitParams));
initParams.hardwarePortId = ipcInitParams.hardwarePortId;
@@ -599,35 +862,34 @@ static t_Error FmHandleIpcMsgCB(t_Handle h_Fm,
initParams.sizeOfFifo = ipcInitParams.sizeOfFifo;
initParams.extraSizeOfFifo = ipcInitParams.extraSizeOfFifo;
initParams.deqPipelineDepth = ipcInitParams.deqPipelineDepth;
+ initParams.maxFrameLength = ipcInitParams.maxFrameLength;
initParams.liodnBase = ipcInitParams.liodnBase;
p_IpcReply->error = (uint32_t)FmGetSetPortParams(h_Fm, &initParams);
- ipcPhysAddr.high = initParams.fmMuramPhysBaseAddr.high;
- ipcPhysAddr.low = initParams.fmMuramPhysBaseAddr.low;
- memcpy(p_IpcReply->replyBody, (uint8_t*)&ipcPhysAddr, sizeof(t_FmIpcPhysAddr));
- *p_ReplyLength = sizeof(uint32_t) + sizeof(t_FmIpcPhysAddr);
+
+ ipcOutInitParams.ipcPhysAddr.high = initParams.fmMuramPhysBaseAddr.high;
+ ipcOutInitParams.ipcPhysAddr.low = initParams.fmMuramPhysBaseAddr.low;
+ ipcOutInitParams.sizeOfFifo = initParams.sizeOfFifo;
+ ipcOutInitParams.extraSizeOfFifo = initParams.extraSizeOfFifo;
+ ipcOutInitParams.numOfTasks = initParams.numOfTasks;
+ ipcOutInitParams.numOfExtraTasks = initParams.numOfExtraTasks;
+ ipcOutInitParams.numOfOpenDmas = initParams.numOfOpenDmas;
+ ipcOutInitParams.numOfExtraOpenDmas = initParams.numOfExtraOpenDmas;
+ memcpy(p_IpcReply->replyBody, (uint8_t*)&ipcOutInitParams, sizeof(ipcOutInitParams));
+ *p_ReplyLength = sizeof(uint32_t) + sizeof(t_FmIpcPortOutInitParams);
break;
}
case (FM_SET_SIZE_OF_FIFO):
{
- t_FmIpcPortFifoParams ipcPortFifoParams;
- t_FmInterModulePortRxPoolsParams rxPoolsParams;
-
- memcpy((uint8_t*)&ipcPortFifoParams, p_IpcMsg->msgBody, sizeof(t_FmIpcPortFifoParams));
- rxPoolsParams.numOfPools = ipcPortFifoParams.numOfPools;
- rxPoolsParams.secondLargestBufSize = ipcPortFifoParams.secondLargestBufSize;
- rxPoolsParams.largestBufSize = ipcPortFifoParams.largestBufSize;
-
- p_IpcReply->error = (uint32_t)FmSetSizeOfFifo(h_Fm, ipcPortFifoParams.rsrcParams.hardwarePortId,
- (e_FmPortType)ipcPortFifoParams.enumPortType,
- (bool)ipcPortFifoParams.boolIndependentMode,
- &ipcPortFifoParams.rsrcParams.val,
- ipcPortFifoParams.rsrcParams.extra,
- ipcPortFifoParams.deqPipelineDepth,
- &rxPoolsParams,
- (bool)ipcPortFifoParams.boolInitialConfig);
- memcpy(p_IpcReply->replyBody, (uint8_t*)&ipcPortFifoParams.rsrcParams.val, sizeof(uint32_t));
- *p_ReplyLength = sizeof(uint32_t) + sizeof(uint32_t);
+ t_FmIpcPortRsrcParams ipcPortRsrcParams;
+
+ memcpy((uint8_t*)&ipcPortRsrcParams, p_IpcMsg->msgBody, sizeof(t_FmIpcPortRsrcParams));
+ p_IpcReply->error = (uint32_t)FmSetSizeOfFifo(h_Fm,
+ ipcPortRsrcParams.hardwarePortId,
+ &ipcPortRsrcParams.val,
+ &ipcPortRsrcParams.extra,
+ (bool)ipcPortRsrcParams.boolInitialConfig);
+ *p_ReplyLength = sizeof(uint32_t);
break;
}
case (FM_SET_NUM_OF_TASKS):
@@ -636,8 +898,8 @@ static t_Error FmHandleIpcMsgCB(t_Handle h_Fm,
memcpy((uint8_t*)&ipcPortRsrcParams, p_IpcMsg->msgBody, sizeof(t_FmIpcPortRsrcParams));
p_IpcReply->error = (uint32_t)FmSetNumOfTasks(h_Fm, ipcPortRsrcParams.hardwarePortId,
- (uint8_t)ipcPortRsrcParams.val,
- (uint8_t)ipcPortRsrcParams.extra,
+ (uint8_t*)&ipcPortRsrcParams.val,
+ (uint8_t*)&ipcPortRsrcParams.extra,
(bool)ipcPortRsrcParams.boolInitialConfig);
*p_ReplyLength = sizeof(uint32_t);
break;
@@ -648,8 +910,8 @@ static t_Error FmHandleIpcMsgCB(t_Handle h_Fm,
memcpy((uint8_t*)&ipcPortRsrcParams, p_IpcMsg->msgBody, sizeof(t_FmIpcPortRsrcParams));
p_IpcReply->error = (uint32_t)FmSetNumOfOpenDmas(h_Fm, ipcPortRsrcParams.hardwarePortId,
- (uint8_t)ipcPortRsrcParams.val,
- (uint8_t)ipcPortRsrcParams.extra,
+ (uint8_t*)&ipcPortRsrcParams.val,
+ (uint8_t*)&ipcPortRsrcParams.extra,
(bool)ipcPortRsrcParams.boolInitialConfig);
*p_ReplyLength = sizeof(uint32_t);
break;
@@ -663,7 +925,7 @@ static t_Error FmHandleIpcMsgCB(t_Handle h_Fm,
uint8_t guestId = p_IpcMsg->msgBody[0];
/* build the FM master partition IPC address */
memset(p_Fm->fmIpcHandlerModuleName[guestId], 0, (sizeof(char)) * MODULE_NAME_SIZE);
- if(Sprint (p_Fm->fmIpcHandlerModuleName[guestId], "FM_%d_%d",p_Fm->p_FmStateStruct->fmId, guestId) != (guestId<10 ? 6:7))
+ if (Sprint (p_Fm->fmIpcHandlerModuleName[guestId], "FM_%d_%d",p_Fm->p_FmStateStruct->fmId, guestId) != (guestId<10 ? 6:7))
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
p_Fm->h_IpcSessions[guestId] = XX_IpcInitSession(p_Fm->fmIpcHandlerModuleName[guestId], p_Fm->fmModuleName);
if (p_Fm->h_IpcSessions[guestId] == NULL)
@@ -694,21 +956,56 @@ static t_Error FmHandleIpcMsgCB(t_Handle h_Fm,
}
case (FM_SET_MAC_MAX_FRAME):
{
- t_Error err;
t_FmIpcMacMaxFrameParams ipcMacMaxFrameParams;
memcpy((uint8_t*)&ipcMacMaxFrameParams, p_IpcMsg->msgBody, sizeof(t_FmIpcMacMaxFrameParams));
- if ((err = FmSetMacMaxFrame(p_Fm,
- (e_FmMacType)(ipcMacMaxFrameParams.macParams.enumType),
- ipcMacMaxFrameParams.macParams.id,
- ipcMacMaxFrameParams.maxFrameLength)) != E_OK)
+ err = FmSetMacMaxFrame(p_Fm,
+ (e_FmMacType)(ipcMacMaxFrameParams.macParams.enumType),
+ ipcMacMaxFrameParams.macParams.id,
+ ipcMacMaxFrameParams.maxFrameLength);
+ if (err != E_OK)
REPORT_ERROR(MINOR, err, NO_MSG);
break;
}
- case (FM_GET_CLK_FREQ):
- memcpy(p_IpcReply->replyBody, (uint8_t*)&p_Fm->p_FmStateStruct->fmClkFreq, sizeof(uint16_t));
- *p_ReplyLength = sizeof(uint32_t) + sizeof(uint16_t);
+#if (DPAA_VERSION >= 11)
+ case (FM_VSP_ALLOC) :
+ {
+ t_FmIpcResourceAllocParams ipcAllocParams;
+ uint8_t vspBase;
+ memcpy(&ipcAllocParams, p_IpcMsg->msgBody, sizeof(t_FmIpcResourceAllocParams));
+ vspBase = AllocVSPsForPartition(h_Fm, (uint8_t)ipcAllocParams.base, (uint8_t)ipcAllocParams.num, ipcAllocParams.guestId);
+ memcpy(p_IpcReply->replyBody, (uint8_t*)&vspBase, sizeof(uint8_t));
+ *p_ReplyLength = sizeof(uint32_t) + sizeof(uint8_t);
break;
+ }
+ case (FM_VSP_FREE) :
+ {
+ t_FmIpcResourceAllocParams ipcAllocParams;
+ memcpy(&ipcAllocParams, p_IpcMsg->msgBody, sizeof(t_FmIpcResourceAllocParams));
+ FreeVSPsForPartition(h_Fm, (uint8_t)ipcAllocParams.base, (uint8_t)ipcAllocParams.num, ipcAllocParams.guestId);
+ break;
+ }
+ case (FM_VSP_SET_PORT_WINDOW) :
+ {
+ t_FmIpcVspSetPortWindow ipcVspSetPortWindow;
+ memcpy(&ipcVspSetPortWindow, p_IpcMsg->msgBody, sizeof(t_FmIpcVspSetPortWindow));
+ err = SetVSPWindow(h_Fm,
+ ipcVspSetPortWindow.hardwarePortId,
+ ipcVspSetPortWindow.baseStorageProfile,
+ ipcVspSetPortWindow.log2NumOfProfiles);
+ return err;
+ }
+ case (FM_SET_CONG_GRP_PFC_PRIO) :
+ {
+ t_FmIpcSetCongestionGroupPfcPriority fmIpcSetCongestionGroupPfcPriority;
+ memcpy(&fmIpcSetCongestionGroupPfcPriority, p_IpcMsg->msgBody, sizeof(t_FmIpcSetCongestionGroupPfcPriority));
+ err = FmSetCongestionGroupPFCpriority(h_Fm,
+ fmIpcSetCongestionGroupPfcPriority.congestionGroupId,
+ fmIpcSetCongestionGroupPfcPriority.priorityBitMap);
+ return err;
+ }
+#endif /* (DPAA_VERSION >= 11) */
+
case (FM_FREE_PORT):
{
t_FmInterModulePortFreeParams portParams;
@@ -717,9 +1014,7 @@ static t_Error FmHandleIpcMsgCB(t_Handle h_Fm,
memcpy((uint8_t*)&ipcPortParams, p_IpcMsg->msgBody, sizeof(t_FmIpcPortFreeParams));
portParams.hardwarePortId = ipcPortParams.hardwarePortId;
portParams.portType = (e_FmPortType)(ipcPortParams.enumPortType);
-#ifdef FM_QMI_DEQ_OPTIONS_SUPPORT
portParams.deqPipelineDepth = ipcPortParams.deqPipelineDepth;
-#endif /* FM_QMI_DEQ_OPTIONS_SUPPORT */
FmFreePortParams(h_Fm, &portParams);
break;
}
@@ -731,35 +1026,34 @@ static t_Error FmHandleIpcMsgCB(t_Handle h_Fm,
p_Fm->intrMng[ipcRegIntr.event].guestId = ipcRegIntr.guestId;
break;
}
-#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
- case (FM_DUMP_REGS):
- {
- t_Error err;
- if ((err = FM_DumpRegs(h_Fm)) != E_OK)
- REPORT_ERROR(MINOR, err, NO_MSG);
- break;
- }
- case (FM_DUMP_PORT_REGS):
+ case (FM_GET_PARAMS):
{
- t_Error err;
+ t_FmIpcParams ipcParams;
- if ((err = FmDumpPortRegs(h_Fm, p_IpcMsg->msgBody[0])) != E_OK)
- REPORT_ERROR(MINOR, err, NO_MSG);
- break;
+ /* Get clock frequency */
+ ipcParams.fmClkFreq = p_Fm->p_FmStateStruct->fmClkFreq;
+ ipcParams.fmMacClkFreq = p_Fm->p_FmStateStruct->fmMacClkFreq;
+
+ fman_get_revision(p_Fm->p_FmFpmRegs,&ipcParams.majorRev,&ipcParams.minorRev);
+
+ memcpy(p_IpcReply->replyBody, (uint8_t*)&ipcParams, sizeof(t_FmIpcParams));
+ *p_ReplyLength = sizeof(uint32_t) + sizeof(t_FmIpcParams);
+ break;
}
-#endif /* (defined(DEBUG_ERRORS) && ... */
- case (FM_GET_REV):
+ case (FM_GET_FMAN_CTRL_CODE_REV):
{
- t_FmRevisionInfo revInfo;
- t_FmIpcRevisionInfo ipcRevInfo;
-
- p_IpcReply->error = (uint32_t)FM_GetRevision(h_Fm, &revInfo);
- ipcRevInfo.majorRev = revInfo.majorRev;
- ipcRevInfo.minorRev = revInfo.minorRev;
- memcpy(p_IpcReply->replyBody, (uint8_t*)&ipcRevInfo, sizeof(t_FmIpcRevisionInfo));
- *p_ReplyLength = sizeof(uint32_t) + sizeof(t_FmIpcRevisionInfo);
+ t_FmCtrlCodeRevisionInfo fmanCtrlRevInfo;
+ t_FmIpcFmanCtrlCodeRevisionInfo ipcRevInfo;
+
+ p_IpcReply->error = (uint32_t)FM_GetFmanCtrlCodeRevision(h_Fm, &fmanCtrlRevInfo);
+ ipcRevInfo.packageRev = fmanCtrlRevInfo.packageRev;
+ ipcRevInfo.majorRev = fmanCtrlRevInfo.majorRev;
+ ipcRevInfo.minorRev = fmanCtrlRevInfo.minorRev;
+ memcpy(p_IpcReply->replyBody, (uint8_t*)&ipcRevInfo, sizeof(t_FmIpcFmanCtrlCodeRevisionInfo));
+ *p_ReplyLength = sizeof(uint32_t) + sizeof(t_FmIpcFmanCtrlCodeRevisionInfo);
break;
}
+
case (FM_DMA_STAT):
{
t_FmDmaStatus dmaStatus;
@@ -771,6 +1065,7 @@ static t_Error FmHandleIpcMsgCB(t_Handle h_Fm,
ipcDmaStatus.boolReadBufEccError = (uint8_t)dmaStatus.readBufEccError;
ipcDmaStatus.boolWriteBufEccSysError = (uint8_t)dmaStatus.writeBufEccSysError;
ipcDmaStatus.boolWriteBufEccFmError = (uint8_t)dmaStatus.writeBufEccFmError;
+ ipcDmaStatus.boolSinglePortEccError = (uint8_t)dmaStatus.singlePortEccError;
memcpy(p_IpcReply->replyBody, (uint8_t*)&ipcDmaStatus, sizeof(t_FmIpcDmaStatus));
*p_ReplyLength = sizeof(uint32_t) + sizeof(t_FmIpcDmaStatus);
break;
@@ -833,33 +1128,39 @@ static t_Error FmHandleIpcMsgCB(t_Handle h_Fm,
}
case (FM_ENABLE_RAM_ECC):
{
- t_Error err;
-
if (((err = FM_EnableRamsEcc(h_Fm)) != E_OK) ||
((err = FM_SetException(h_Fm, e_FM_EX_IRAM_ECC, TRUE)) != E_OK) ||
((err = FM_SetException(h_Fm, e_FM_EX_MURAM_ECC, TRUE)) != E_OK))
+#if (!(defined(DEBUG_ERRORS)) || (DEBUG_ERRORS == 0))
+ UNUSED(err);
+#else
REPORT_ERROR(MINOR, err, NO_MSG);
+#endif /* (!(defined(DEBUG_ERRORS)) || (DEBUG_ERRORS == 0)) */
break;
}
case (FM_DISABLE_RAM_ECC):
{
- t_Error err;
if (((err = FM_SetException(h_Fm, e_FM_EX_IRAM_ECC, FALSE)) != E_OK) ||
((err = FM_SetException(h_Fm, e_FM_EX_MURAM_ECC, FALSE)) != E_OK) ||
((err = FM_DisableRamsEcc(h_Fm)) != E_OK))
+#if (!(defined(DEBUG_ERRORS)) || (DEBUG_ERRORS == 0))
+ UNUSED(err);
+#else
REPORT_ERROR(MINOR, err, NO_MSG);
+#endif /* (!(defined(DEBUG_ERRORS)) || (DEBUG_ERRORS == 0)) */
break;
}
case (FM_SET_NUM_OF_FMAN_CTRL):
{
- t_Error err;
t_FmIpcPortNumOfFmanCtrls ipcPortNumOfFmanCtrls;
memcpy((uint8_t*)&ipcPortNumOfFmanCtrls, p_IpcMsg->msgBody, sizeof(t_FmIpcPortNumOfFmanCtrls));
- if ((err = FmSetNumOfRiscsPerPort(h_Fm,
- ipcPortNumOfFmanCtrls.hardwarePortId,
- ipcPortNumOfFmanCtrls.numOfFmanCtrls)) != E_OK)
+ err = FmSetNumOfRiscsPerPort(h_Fm,
+ ipcPortNumOfFmanCtrls.hardwarePortId,
+ ipcPortNumOfFmanCtrls.numOfFmanCtrls,
+ ipcPortNumOfFmanCtrls.orFmanCtrl);
+ if (err != E_OK)
REPORT_ERROR(MINOR, err, NO_MSG);
break;
}
@@ -876,77 +1177,22 @@ static t_Error FmHandleIpcMsgCB(t_Handle h_Fm,
return E_OK;
}
-static void ErrorIsrCB(t_Handle h_Fm)
-{
-#define FM_M_CALL_1G_MAC_ERR_ISR(_id) \
- { \
- if (p_Fm->guestId != p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_1G_MAC0+_id)].guestId) \
- SendIpcIsr(p_Fm, (e_FmInterModuleEvent)(e_FM_EV_ERR_1G_MAC0+_id), pending); \
- else \
- p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_1G_MAC0+_id)].f_Isr(p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_1G_MAC0+_id)].h_SrcHandle);\
- }
- t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint32_t pending;
-
- SANITY_CHECK_RETURN(h_Fm, E_INVALID_HANDLE);
-
- /* error interrupts */
- pending = GET_UINT32(p_Fm->p_FmFpmRegs->fmepi);
- if (!pending)
- return;
-
- if(pending & ERR_INTR_EN_BMI)
- BmiErrEvent(p_Fm);
- if(pending & ERR_INTR_EN_QMI)
- QmiErrEvent(p_Fm);
- if(pending & ERR_INTR_EN_FPM)
- FpmErrEvent(p_Fm);
- if(pending & ERR_INTR_EN_DMA)
- DmaErrEvent(p_Fm);
- if(pending & ERR_INTR_EN_IRAM)
- IramErrIntr(p_Fm);
- if(pending & ERR_INTR_EN_MURAM)
- MuramErrIntr(p_Fm);
- if(pending & ERR_INTR_EN_PRS)
- p_Fm->intrMng[e_FM_EV_ERR_PRS].f_Isr(p_Fm->intrMng[e_FM_EV_ERR_PRS].h_SrcHandle);
- if(pending & ERR_INTR_EN_PLCR)
- p_Fm->intrMng[e_FM_EV_ERR_PLCR].f_Isr(p_Fm->intrMng[e_FM_EV_ERR_PLCR].h_SrcHandle);
- if(pending & ERR_INTR_EN_KG)
- p_Fm->intrMng[e_FM_EV_ERR_KG].f_Isr(p_Fm->intrMng[e_FM_EV_ERR_KG].h_SrcHandle);
-
- /* MAC events may belong to different partitions */
- if(pending & ERR_INTR_EN_1G_MAC0)
- FM_M_CALL_1G_MAC_ERR_ISR(0);
- if(pending & ERR_INTR_EN_1G_MAC1)
- FM_M_CALL_1G_MAC_ERR_ISR(1);
- if(pending & ERR_INTR_EN_1G_MAC2)
- FM_M_CALL_1G_MAC_ERR_ISR(2);
- if(pending & ERR_INTR_EN_1G_MAC3)
- FM_M_CALL_1G_MAC_ERR_ISR(3);
- if(pending & ERR_INTR_EN_1G_MAC4)
- FM_M_CALL_1G_MAC_ERR_ISR(4);
- if(pending & ERR_INTR_EN_10G_MAC0)
- {
- if (p_Fm->guestId != p_Fm->intrMng[e_FM_EV_ERR_10G_MAC0].guestId)
- SendIpcIsr(p_Fm, e_FM_EV_ERR_10G_MAC0, pending);
- else
- p_Fm->intrMng[e_FM_EV_ERR_10G_MAC0].f_Isr(p_Fm->intrMng[e_FM_EV_ERR_10G_MAC0].h_SrcHandle);
- }
-}
-
+/****************************************/
+/* Inter-Module functions */
+/****************************************/
#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
t_Error Fm10GTxEccWorkaround(t_Handle h_Fm, uint8_t macId)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- int timeout = 1000;
t_Error err = E_OK;
t_FmIpcMsg msg;
t_FmIpcReply reply;
uint32_t replyLength;
uint8_t rxHardwarePortId, txHardwarePortId;
+ struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ if (p_Fm->guestId != NCSW_MASTER_ID)
{
memset(&msg, 0, sizeof(msg));
memset(&reply, 0, sizeof(reply));
@@ -969,30 +1215,139 @@ t_Error Fm10GTxEccWorkaround(t_Handle h_Fm, uint8_t macId)
SANITY_CHECK_RETURN_ERROR((macId == 0), E_NOT_SUPPORTED);
SANITY_CHECK_RETURN_ERROR(IsFmanCtrlCodeLoaded(p_Fm), E_INVALID_STATE);
- SW_PORT_ID_TO_HW_PORT_ID(rxHardwarePortId, e_FM_PORT_TYPE_RX_10G, macId);
- SW_PORT_ID_TO_HW_PORT_ID(txHardwarePortId, e_FM_PORT_TYPE_TX_10G, macId);
+ rxHardwarePortId = SwPortIdToHwPortId(e_FM_PORT_TYPE_RX_10G,
+ macId,
+ p_Fm->p_FmStateStruct->revInfo.majorRev,
+ p_Fm->p_FmStateStruct->revInfo.minorRev);
+ txHardwarePortId = SwPortIdToHwPortId(e_FM_PORT_TYPE_TX_10G,
+ macId,
+ p_Fm->p_FmStateStruct->revInfo.majorRev,
+ p_Fm->p_FmStateStruct->revInfo.minorRev);
if ((p_Fm->p_FmStateStruct->portsTypes[rxHardwarePortId] != e_FM_PORT_TYPE_DUMMY) ||
(p_Fm->p_FmStateStruct->portsTypes[txHardwarePortId] != e_FM_PORT_TYPE_DUMMY))
RETURN_ERROR(MAJOR, E_INVALID_STATE,
- ("MAC should be initialized prior to rx and tx ports!"));
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmextc, 0x40000000);
- CORE_MemoryBarrier();
- while ((GET_UINT32(p_Fm->p_FmFpmRegs->fpmextc) & 0x40000000) &&
- --timeout) ;
- if (!timeout)
- return ERROR_CODE(E_TIMEOUT);
- return E_OK;
+ ("MAC should be initialized prior to Rx and Tx ports!"));
+
+ return fman_set_erratum_10gmac_a004_wa(fpm_rg);
}
#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
+uint16_t FmGetTnumAgingPeriod(t_Handle h_Fm)
+{
+ t_Fm *p_Fm = (t_Fm *)h_Fm;
+
+ SANITY_CHECK_RETURN_VALUE(p_Fm, E_INVALID_HANDLE, 0);
+ SANITY_CHECK_RETURN_VALUE(!p_Fm->p_FmDriverParam, E_INVALID_STATE, 0);
+
+ return p_Fm->tnumAgingPeriod;
+}
+
+t_Error FmSetPortPreFetchConfiguration(t_Handle h_Fm,
+ uint8_t portNum,
+ bool preFetchConfigured)
+{
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+
+ SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
+
+ p_Fm->portsPreFetchConfigured[portNum] = TRUE;
+ p_Fm->portsPreFetchValue[portNum] = preFetchConfigured;
+
+ return E_OK;
+}
+
+t_Error FmGetPortPreFetchConfiguration(t_Handle h_Fm,
+ uint8_t portNum,
+ bool *p_PortConfigured,
+ bool *p_PreFetchConfigured)
+{
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+
+ SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
+
+ /* If the prefetch wasn't configured yet (not enable or disabled)
+ we return the value TRUE as it was already configured */
+ if (!p_Fm->portsPreFetchConfigured[portNum])
+ {
+ *p_PortConfigured = FALSE;
+ *p_PreFetchConfigured = FALSE;
+ }
+ else
+ {
+ *p_PortConfigured = TRUE;
+ *p_PreFetchConfigured = (p_Fm->portsPreFetchConfigured[portNum]);
+ }
+
+ return E_OK;
+}
+
+t_Error FmSetCongestionGroupPFCpriority(t_Handle h_Fm,
+ uint32_t congestionGroupId,
+ uint8_t priorityBitMap)
+{
+ t_Fm *p_Fm = (t_Fm *)h_Fm;
+ uint32_t regNum;
+
+ ASSERT_COND(h_Fm);
+
+ if (congestionGroupId > FM_PORT_NUM_OF_CONGESTION_GRPS)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("Congestion group ID bigger than %d",
+ FM_PORT_NUM_OF_CONGESTION_GRPS));
+
+ if (p_Fm->guestId == NCSW_MASTER_ID)
+ {
+ ASSERT_COND(p_Fm->baseAddr);
+ regNum = (FM_PORT_NUM_OF_CONGESTION_GRPS - 1 - congestionGroupId) / 4;
+ fman_set_congestion_group_pfc_priority((uint32_t *)((p_Fm->baseAddr+FM_MM_CGP)),
+ congestionGroupId,
+ priorityBitMap,
+ regNum);
+ }
+ else if (p_Fm->h_IpcSessions[0])
+ {
+ t_Error err;
+ t_FmIpcMsg msg;
+ t_FmIpcSetCongestionGroupPfcPriority fmIpcSetCongestionGroupPfcPriority;
+
+ memset(&msg, 0, sizeof(msg));
+ memset(&fmIpcSetCongestionGroupPfcPriority, 0, sizeof(t_FmIpcSetCongestionGroupPfcPriority));
+ fmIpcSetCongestionGroupPfcPriority.congestionGroupId = congestionGroupId;
+ fmIpcSetCongestionGroupPfcPriority.priorityBitMap = priorityBitMap;
+
+ msg.msgId = FM_SET_CONG_GRP_PFC_PRIO;
+ memcpy(msg.msgBody, &fmIpcSetCongestionGroupPfcPriority, sizeof(t_FmIpcSetCongestionGroupPfcPriority));
+
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId),
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ if (err != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+ }
+ else
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("guest without IPC!"));
+
+ return E_OK;
+}
+
uintptr_t FmGetPcdPrsBaseAddr(t_Handle h_Fm)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_VALUE(p_Fm, E_INVALID_HANDLE, 0);
- if(p_Fm->guestId != NCSW_MASTER_ID)
- REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Guset"));
+ if (!p_Fm->baseAddr)
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_STATE,
+ ("No base-addr; probably Guest with IPC!"));
+ return 0;
+ }
return (p_Fm->baseAddr + FM_MM_PRS);
}
@@ -1003,8 +1358,12 @@ uintptr_t FmGetPcdKgBaseAddr(t_Handle h_Fm)
SANITY_CHECK_RETURN_VALUE(p_Fm, E_INVALID_HANDLE, 0);
- if(p_Fm->guestId != NCSW_MASTER_ID)
- REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Guset"));
+ if (!p_Fm->baseAddr)
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_STATE,
+ ("No base-addr; probably Guest with IPC!"));
+ return 0;
+ }
return (p_Fm->baseAddr + FM_MM_KG);
}
@@ -1015,12 +1374,27 @@ uintptr_t FmGetPcdPlcrBaseAddr(t_Handle h_Fm)
SANITY_CHECK_RETURN_VALUE(p_Fm, E_INVALID_HANDLE, 0);
- if(p_Fm->guestId != NCSW_MASTER_ID)
- REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Guset"));
+ if (!p_Fm->baseAddr)
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_STATE,
+ ("No base-addr; probably Guest with IPC!"));
+ return 0;
+ }
return (p_Fm->baseAddr + FM_MM_PLCR);
}
+#if (DPAA_VERSION >= 11)
+uintptr_t FmGetVSPBaseAddr(t_Handle h_Fm)
+{
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+
+ SANITY_CHECK_RETURN_VALUE(p_Fm, E_INVALID_HANDLE, 0);
+
+ return p_Fm->vspBaseAddr;
+}
+#endif /* (DPAA_VERSION >= 11) */
+
t_Handle FmGetMuramHandle(t_Handle h_Fm)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
@@ -1033,25 +1407,37 @@ t_Handle FmGetMuramHandle(t_Handle h_Fm)
void FmGetPhysicalMuramBase(t_Handle h_Fm, t_FmPhysAddr *p_FmPhysAddr)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- t_Error err;
- t_FmIpcMsg msg;
- t_FmIpcReply reply;
- uint32_t replyLength;
- t_FmIpcPhysAddr ipcPhysAddr;
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ if (p_Fm->fmMuramPhysBaseAddr)
+ {
+ /* General FM driver initialization */
+ p_FmPhysAddr->low = (uint32_t)p_Fm->fmMuramPhysBaseAddr;
+ p_FmPhysAddr->high = (uint8_t)((p_Fm->fmMuramPhysBaseAddr & 0x000000ff00000000LL) >> 32);
+ return;
+ }
+
+ ASSERT_COND(p_Fm->guestId != NCSW_MASTER_ID);
+
+ if (p_Fm->h_IpcSessions[0])
{
+ t_Error err;
+ t_FmIpcMsg msg;
+ t_FmIpcReply reply;
+ uint32_t replyLength;
+ t_FmIpcPhysAddr ipcPhysAddr;
+
memset(&msg, 0, sizeof(msg));
memset(&reply, 0, sizeof(reply));
msg.msgId = FM_GET_PHYS_MURAM_BASE;
replyLength = sizeof(uint32_t) + sizeof(t_FmPhysAddr);
- if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
- (uint8_t*)&msg,
- sizeof(msg.msgId),
- (uint8_t*)&reply,
- &replyLength,
- NULL,
- NULL)) != E_OK)
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId),
+ (uint8_t*)&reply,
+ &replyLength,
+ NULL,
+ NULL);
+ if (err != E_OK)
{
REPORT_ERROR(MINOR, err, NO_MSG);
return;
@@ -1064,25 +1450,144 @@ void FmGetPhysicalMuramBase(t_Handle h_Fm, t_FmPhysAddr *p_FmPhysAddr)
memcpy((uint8_t*)&ipcPhysAddr, reply.replyBody, sizeof(t_FmIpcPhysAddr));
p_FmPhysAddr->high = ipcPhysAddr.high;
p_FmPhysAddr->low = ipcPhysAddr.low;
- return ;
}
+ else
+ REPORT_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("running in guest-mode without neither IPC nor mapped register!"));
+}
- /* General FM driver initialization */
- p_FmPhysAddr->low = (uint32_t)p_Fm->fmMuramPhysBaseAddr;
- p_FmPhysAddr->high = (uint8_t)((p_Fm->fmMuramPhysBaseAddr & 0x000000ff00000000LL) >> 32);
+#if (DPAA_VERSION >= 11)
+t_Error FmVSPAllocForPort (t_Handle h_Fm,
+ e_FmPortType portType,
+ uint8_t portId,
+ uint8_t numOfVSPs)
+{
+ t_Fm *p_Fm = (t_Fm *)h_Fm;
+ t_Error err = E_OK;
+ uint32_t profilesFound, intFlags;
+ uint8_t first, i;
+ uint8_t log2Num;
+ uint8_t swPortIndex=0, hardwarePortId;
+
+ SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
+
+ if (!numOfVSPs)
+ return E_OK;
+
+ if (numOfVSPs > FM_VSP_MAX_NUM_OF_ENTRIES)
+ RETURN_ERROR(MINOR, E_INVALID_VALUE, ("numProfiles can not be bigger than %d.",FM_VSP_MAX_NUM_OF_ENTRIES));
+
+ if (!POWER_OF_2(numOfVSPs))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("numProfiles must be a power of 2."));
+
+ LOG2((uint64_t)numOfVSPs, log2Num);
+
+ if ((log2Num == 0) || (p_Fm->partVSPBase == 0))
+ first = 0;
+ else
+ first = 1<<log2Num;
+
+ if (first > (p_Fm->partVSPBase + p_Fm->partNumOfVSPs))
+ RETURN_ERROR(MINOR, E_INVALID_VALUE, ("can not allocate storage profile port window"));
+
+ if (first < p_Fm->partVSPBase)
+ while (first < p_Fm->partVSPBase)
+ first = first + numOfVSPs;
+
+ if ((first + numOfVSPs) > (p_Fm->partVSPBase + p_Fm->partNumOfVSPs))
+ RETURN_ERROR(MINOR, E_INVALID_VALUE, ("can not allocate storage profile port window"));
+
+ intFlags = XX_LockIntrSpinlock(p_Fm->h_Spinlock);
+ profilesFound = 0;
+ for (i=first; i < p_Fm->partVSPBase + p_Fm->partNumOfVSPs; )
+ {
+ if (!p_Fm->p_FmSp->profiles[i].profilesMng.allocated)
+ {
+ profilesFound++;
+ i++;
+ if (profilesFound == numOfVSPs)
+ break;
+ }
+ else
+ {
+ profilesFound = 0;
+ /* advance i to the next aligned address */
+ first = i = (uint8_t)(first + numOfVSPs);
+ }
+ }
+ if (profilesFound == numOfVSPs)
+ for (i = first; i<first + numOfVSPs; i++)
+ p_Fm->p_FmSp->profiles[i].profilesMng.allocated = TRUE;
+ else
+ {
+ XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
+ RETURN_ERROR(MINOR, E_FULL, ("No profiles."));
+ }
+
+ hardwarePortId = SwPortIdToHwPortId(portType,
+ portId,
+ p_Fm->p_FmStateStruct->revInfo.majorRev,
+ p_Fm->p_FmStateStruct->revInfo.minorRev);
+ HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId);
+
+ p_Fm->p_FmSp->portsMapping[swPortIndex].numOfProfiles = numOfVSPs;
+ p_Fm->p_FmSp->portsMapping[swPortIndex].profilesBase = first;
+
+ if ((err = SetVSPWindow(h_Fm,hardwarePortId, first,log2Num)) != E_OK)
+ for (i = first; i < first + numOfVSPs; i++)
+ p_Fm->p_FmSp->profiles[i].profilesMng.allocated = FALSE;
+
+ XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
+
+ return err;
+}
+
+t_Error FmVSPFreeForPort(t_Handle h_Fm,
+ e_FmPortType portType,
+ uint8_t portId)
+{
+ t_Fm *p_Fm = (t_Fm *)h_Fm;
+ uint8_t swPortIndex=0, hardwarePortId, first, numOfVSPs, i;
+ uint32_t intFlags;
+
+ SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
+
+ hardwarePortId = SwPortIdToHwPortId(portType,
+ portId,
+ p_Fm->p_FmStateStruct->revInfo.majorRev,
+ p_Fm->p_FmStateStruct->revInfo.minorRev);
+ HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId);
+
+ numOfVSPs = (uint8_t)p_Fm->p_FmSp->portsMapping[swPortIndex].numOfProfiles;
+ first = (uint8_t)p_Fm->p_FmSp->portsMapping[swPortIndex].profilesBase;
+
+ intFlags = XX_LockIntrSpinlock(p_Fm->h_Spinlock);
+ for (i = first; i < first + numOfVSPs; i++)
+ p_Fm->p_FmSp->profiles[i].profilesMng.allocated = FALSE;
+ XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
+
+ p_Fm->p_FmSp->portsMapping[swPortIndex].numOfProfiles = 0;
+ p_Fm->p_FmSp->portsMapping[swPortIndex].profilesBase = 0;
+
+ return E_OK;
}
+#endif /* (DPAA_VERSION >= 11) */
t_Error FmAllocFmanCtrlEventReg(t_Handle h_Fm, uint8_t *p_EventId)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
uint8_t i;
- t_Error err;
- t_FmIpcMsg msg;
- t_FmIpcReply reply;
- uint32_t replyLength;
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
+
+ if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ p_Fm->h_IpcSessions[0])
{
+ t_Error err;
+ t_FmIpcMsg msg;
+ t_FmIpcReply reply;
+ uint32_t replyLength;
+
memset(&msg, 0, sizeof(msg));
memset(&reply, 0, sizeof(reply));
msg.msgId = FM_ALLOC_FMAN_CTRL_EVENT_REG;
@@ -1095,6 +1600,7 @@ t_Error FmAllocFmanCtrlEventReg(t_Handle h_Fm, uint8_t *p_EventId)
NULL,
NULL)) != E_OK)
RETURN_ERROR(MAJOR, err, NO_MSG);
+
if (replyLength != (sizeof(uint32_t) + sizeof(uint8_t)))
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
@@ -1102,8 +1608,11 @@ t_Error FmAllocFmanCtrlEventReg(t_Handle h_Fm, uint8_t *p_EventId)
return (t_Error)(reply.error);
}
+ else if (p_Fm->guestId != NCSW_MASTER_ID)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("running in guest-mode without IPC!"));
- for(i=0;i<FM_NUM_OF_FMAN_CTRL_EVENT_REGS;i++)
+ for (i=0;i<FM_NUM_OF_FMAN_CTRL_EVENT_REGS;i++)
if (!p_Fm->usedEventRegs[i])
{
p_Fm->usedEventRegs[i] = TRUE;
@@ -1112,7 +1621,7 @@ t_Error FmAllocFmanCtrlEventReg(t_Handle h_Fm, uint8_t *p_EventId)
}
if (i==FM_NUM_OF_FMAN_CTRL_EVENT_REGS)
- RETURN_ERROR(MAJOR, E_BUSY, ("No resource - Fman controller event register."));
+ RETURN_ERROR(MAJOR, E_BUSY, ("No resource - FMan controller event register."));
return E_OK;
}
@@ -1120,143 +1629,106 @@ t_Error FmAllocFmanCtrlEventReg(t_Handle h_Fm, uint8_t *p_EventId)
void FmFreeFmanCtrlEventReg(t_Handle h_Fm, uint8_t eventId)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- t_Error err;
- t_FmIpcMsg msg;
- if(((t_Fm *)h_Fm)->guestId != NCSW_MASTER_ID)
+ SANITY_CHECK_RETURN(p_Fm, E_INVALID_HANDLE);
+
+ if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ p_Fm->h_IpcSessions[0])
{
+ t_Error err;
+ t_FmIpcMsg msg;
+
memset(&msg, 0, sizeof(msg));
msg.msgId = FM_FREE_FMAN_CTRL_EVENT_REG;
msg.msgBody[0] = eventId;
- if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
- (uint8_t*)&msg,
- sizeof(msg.msgId)+sizeof(eventId),
- NULL,
- NULL,
- NULL,
- NULL)) != E_OK)
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId)+sizeof(eventId),
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ if (err != E_OK)
REPORT_ERROR(MINOR, err, NO_MSG);
return;
}
-
- ((t_Fm*)h_Fm)->usedEventRegs[eventId] = FALSE;
-}
-
-void FmRegisterIntr(t_Handle h_Fm,
- e_FmEventModules module,
- uint8_t modId,
- e_FmIntrType intrType,
- void (*f_Isr) (t_Handle h_Arg),
- t_Handle h_Arg)
-{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint8_t event= 0;
- t_FmIpcRegisterIntr fmIpcRegisterIntr;
- t_Error err;
- t_FmIpcMsg msg;
-
- ASSERT_COND(h_Fm);
-
- GET_FM_MODULE_EVENT(module, modId,intrType, event);
-
- /* register in local FM structure */
- ASSERT_COND(event != e_FM_EV_DUMMY_LAST);
- p_Fm->intrMng[event].f_Isr = f_Isr;
- p_Fm->intrMng[event].h_SrcHandle = h_Arg;
-
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ else if (p_Fm->guestId != NCSW_MASTER_ID)
{
- if(p_Fm->h_IpcSessions[0])
- {
- /* register in Master FM structure */
- fmIpcRegisterIntr.event = event;
- fmIpcRegisterIntr.guestId = p_Fm->guestId;
- memset(&msg, 0, sizeof(msg));
- msg.msgId = FM_REGISTER_INTR;
- memcpy(msg.msgBody, &fmIpcRegisterIntr, sizeof(fmIpcRegisterIntr));
- if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
- (uint8_t*)&msg,
- sizeof(msg.msgId) + sizeof(fmIpcRegisterIntr),
- NULL,
- NULL,
- NULL,
- NULL)) != E_OK)
- REPORT_ERROR(MINOR, err, NO_MSG);
- }
- else
- DBG(WARNING,("'Register interrupt' - unavailable - No IPC"));
+ REPORT_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("running in guest-mode without IPC!"));
+ return;
}
+ ((t_Fm*)h_Fm)->usedEventRegs[eventId] = FALSE;
}
-void FmUnregisterIntr(t_Handle h_Fm,
- e_FmEventModules module,
- uint8_t modId,
- e_FmIntrType intrType)
-{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint8_t event= 0;
-
- ASSERT_COND(h_Fm);
-
- GET_FM_MODULE_EVENT(module, modId,intrType, event);
-
- ASSERT_COND(event != e_FM_EV_DUMMY_LAST);
- p_Fm->intrMng[event].f_Isr = UnimplementedIsr;
- p_Fm->intrMng[event].h_SrcHandle = NULL;
-}
-
-void FmSetFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId, uint32_t enableEvents)
+void FmSetFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId, uint32_t enableEvents)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- t_FmIpcFmanEvents fmanCtrl;
- t_Error err;
- t_FmIpcMsg msg;
+ struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ !p_Fm->p_FmFpmRegs &&
+ p_Fm->h_IpcSessions[0])
{
+ t_FmIpcFmanEvents fmanCtrl;
+ t_Error err;
+ t_FmIpcMsg msg;
+
fmanCtrl.eventRegId = eventRegId;
fmanCtrl.enableEvents = enableEvents;
memset(&msg, 0, sizeof(msg));
msg.msgId = FM_SET_FMAN_CTRL_EVENTS_ENABLE;
memcpy(msg.msgBody, &fmanCtrl, sizeof(fmanCtrl));
- if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
- (uint8_t*)&msg,
- sizeof(msg.msgId)+sizeof(fmanCtrl),
- NULL,
- NULL,
- NULL,
- NULL)) != E_OK)
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId)+sizeof(fmanCtrl),
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ if (err != E_OK)
REPORT_ERROR(MINOR, err, NO_MSG);
return;
}
+ else if (!p_Fm->p_FmFpmRegs)
+ {
+ REPORT_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("Either IPC or 'baseAddress' is required!"));
+ return;
+ }
ASSERT_COND(eventRegId < FM_NUM_OF_FMAN_CTRL_EVENT_REGS);
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fmfpfcee[eventRegId], enableEvents);
+ fman_set_ctrl_intr(fpm_rg, eventRegId, enableEvents);
}
uint32_t FmGetFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- t_Error err;
- t_FmIpcMsg msg;
- t_FmIpcReply reply;
- uint32_t replyLength, ctrlIntr;
+ struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ !p_Fm->p_FmFpmRegs &&
+ p_Fm->h_IpcSessions[0])
{
+ t_Error err;
+ t_FmIpcMsg msg;
+ t_FmIpcReply reply;
+ uint32_t replyLength, ctrlIntr;
+
memset(&msg, 0, sizeof(msg));
memset(&reply, 0, sizeof(reply));
msg.msgId = FM_GET_FMAN_CTRL_EVENTS_ENABLE;
msg.msgBody[0] = eventRegId;
replyLength = sizeof(uint32_t) + sizeof(uint32_t);
- if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
- (uint8_t*)&msg,
- sizeof(msg.msgId)+sizeof(eventRegId),
- (uint8_t*)&reply,
- &replyLength,
- NULL,
- NULL)) != E_OK)
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId)+sizeof(eventRegId),
+ (uint8_t*)&reply,
+ &replyLength,
+ NULL,
+ NULL);
+ if (err != E_OK)
{
REPORT_ERROR(MINOR, err, NO_MSG);
return 0;
@@ -1269,8 +1741,78 @@ uint32_t FmGetFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId)
memcpy((uint8_t*)&ctrlIntr, reply.replyBody, sizeof(uint32_t));
return ctrlIntr;
}
+ else if (!p_Fm->p_FmFpmRegs)
+ {
+ REPORT_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("Either IPC or 'baseAddress' is required!"));
+ return 0;
+ }
+
+ return fman_get_ctrl_intr(fpm_rg, eventRegId);
+}
+
+void FmRegisterIntr(t_Handle h_Fm,
+ e_FmEventModules module,
+ uint8_t modId,
+ e_FmIntrType intrType,
+ void (*f_Isr) (t_Handle h_Arg),
+ t_Handle h_Arg)
+{
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+ int event = 0;
+
+ ASSERT_COND(h_Fm);
+
+ GET_FM_MODULE_EVENT(module, modId, intrType, event);
+ ASSERT_COND(event < e_FM_EV_DUMMY_LAST);
+
+ /* register in local FM structure */
+ p_Fm->intrMng[event].f_Isr = f_Isr;
+ p_Fm->intrMng[event].h_SrcHandle = h_Arg;
+
+ if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ p_Fm->h_IpcSessions[0])
+ {
+ t_FmIpcRegisterIntr fmIpcRegisterIntr;
+ t_Error err;
+ t_FmIpcMsg msg;
+
+ /* register in Master FM structure */
+ fmIpcRegisterIntr.event = (uint32_t)event;
+ fmIpcRegisterIntr.guestId = p_Fm->guestId;
+ memset(&msg, 0, sizeof(msg));
+ msg.msgId = FM_REGISTER_INTR;
+ memcpy(msg.msgBody, &fmIpcRegisterIntr, sizeof(fmIpcRegisterIntr));
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId) + sizeof(fmIpcRegisterIntr),
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ if (err != E_OK)
+ REPORT_ERROR(MINOR, err, NO_MSG);
+ }
+ else if (p_Fm->guestId != NCSW_MASTER_ID)
+ REPORT_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("running in guest-mode without IPC!"));
+}
- return GET_UINT32(p_Fm->p_FmFpmRegs->fmfpfcee[eventRegId]);
+void FmUnregisterIntr(t_Handle h_Fm,
+ e_FmEventModules module,
+ uint8_t modId,
+ e_FmIntrType intrType)
+{
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+ int event = 0;
+
+ ASSERT_COND(h_Fm);
+
+ GET_FM_MODULE_EVENT(module, modId,intrType, event);
+ ASSERT_COND(event < e_FM_EV_DUMMY_LAST);
+
+ p_Fm->intrMng[event].f_Isr = UnimplementedIsr;
+ p_Fm->intrMng[event].h_SrcHandle = NULL;
}
void FmRegisterFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId, void (*f_Isr) (t_Handle h_Arg, uint32_t event), t_Handle h_Arg)
@@ -1279,10 +1821,10 @@ void FmRegisterFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId, void (*f_Isr) (t
ASSERT_COND(eventRegId<FM_NUM_OF_FMAN_CTRL_EVENT_REGS);
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ if (p_Fm->guestId != NCSW_MASTER_ID)
{
- ASSERT_COND(0);
- /* TODO */
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM in guest-mode"));
+ return;
}
p_Fm->fmanCtrlIntr[eventRegId].f_Isr = f_Isr;
@@ -1295,10 +1837,10 @@ void FmUnregisterFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId)
ASSERT_COND(eventRegId<FM_NUM_OF_FMAN_CTRL_EVENT_REGS);
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ if (p_Fm->guestId != NCSW_MASTER_ID)
{
- ASSERT_COND(0);
- /* TODO */
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("FM in guest-mode"));
+ return;
}
p_Fm->fmanCtrlIntr[eventRegId].f_Isr = UnimplementedFmanCtrlIsr;
@@ -1309,25 +1851,23 @@ void FmRegisterPcd(t_Handle h_Fm, t_Handle h_FmPcd)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- if(p_Fm->h_Pcd)
+ if (p_Fm->h_Pcd)
REPORT_ERROR(MAJOR, E_ALREADY_EXISTS, ("PCD already set"));
p_Fm->h_Pcd = h_FmPcd;
-
}
void FmUnregisterPcd(t_Handle h_Fm)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- if(!p_Fm->h_Pcd)
- REPORT_ERROR(MAJOR, E_ALREADY_EXISTS, ("No PCD"));
+ if (!p_Fm->h_Pcd)
+ REPORT_ERROR(MAJOR, E_NOT_FOUND, ("PCD handle!"));
p_Fm->h_Pcd = NULL;
-
}
-t_Handle FmGetPcdHandle(t_Handle h_Fm)
+t_Handle FmGetPcdHandle(t_Handle h_Fm)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
@@ -1343,89 +1883,106 @@ uint8_t FmGetId(t_Handle h_Fm)
return p_Fm->p_FmStateStruct->fmId;
}
-t_Error FmSetNumOfRiscsPerPort(t_Handle h_Fm, uint8_t hardwarePortId, uint8_t numOfFmanCtrls)
+t_Error FmReset(t_Handle h_Fm)
+{
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+
+ SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
+
+ WRITE_UINT32(p_Fm->p_FmFpmRegs->fm_rstc, FPM_RSTC_FM_RESET);
+ CORE_MemoryBarrier();
+ XX_UDelay(100);
+
+ return E_OK;
+}
+
+t_Error FmSetNumOfRiscsPerPort(t_Handle h_Fm,
+ uint8_t hardwarePortId,
+ uint8_t numOfFmanCtrls,
+ t_FmFmanCtrl orFmanCtrl)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint32_t tmpReg = 0;
- t_Error err;
- t_FmIpcPortNumOfFmanCtrls params;
- t_FmIpcMsg msg;
+ struct fman_fpm_regs *fpm_rg;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(((numOfFmanCtrls > 0) && (numOfFmanCtrls < 3)) , E_INVALID_HANDLE);
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ fpm_rg = p_Fm->p_FmFpmRegs;
+ if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ !p_Fm->p_FmFpmRegs &&
+ p_Fm->h_IpcSessions[0])
{
+ t_Error err;
+ t_FmIpcPortNumOfFmanCtrls params;
+ t_FmIpcMsg msg;
+
memset(&msg, 0, sizeof(msg));
params.hardwarePortId = hardwarePortId;
params.numOfFmanCtrls = numOfFmanCtrls;
+ params.orFmanCtrl = orFmanCtrl;
msg.msgId = FM_SET_NUM_OF_FMAN_CTRL;
memcpy(msg.msgBody, &params, sizeof(params));
- if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
- (uint8_t*)&msg,
- sizeof(msg.msgId) +sizeof(params),
- NULL,
- NULL,
- NULL,
- NULL)) != E_OK)
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId) +sizeof(params),
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ if (err != E_OK)
RETURN_ERROR(MINOR, err, NO_MSG);
-
return E_OK;
}
+ else if (!p_Fm->p_FmFpmRegs)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("Either IPC or 'baseAddress' is required!"));
- XX_LockSpinlock(p_Fm->h_Spinlock);
-
- tmpReg = (uint32_t)(hardwarePortId << FPM_PORT_FM_CTL_PORTID_SHIFT);
-
- /*TODO - maybe to put CTL# according to another criteria*/
-
- if(numOfFmanCtrls == 2)
- tmpReg = FPM_PORT_FM_CTL2 | FPM_PORT_FM_CTL1;
-
- /* order restoration */
- if(hardwarePortId%2)
- tmpReg |= (FPM_PORT_FM_CTL1 << FPM_PRC_ORA_FM_CTL_SEL_SHIFT) | FPM_PORT_FM_CTL1;
- else
- tmpReg |= (FPM_PORT_FM_CTL2 << FPM_PRC_ORA_FM_CTL_SEL_SHIFT) | FPM_PORT_FM_CTL2;
-
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmpr, tmpReg);
- XX_UnlockSpinlock(p_Fm->h_Spinlock);
+ fman_set_num_of_riscs_per_port(fpm_rg, hardwarePortId, numOfFmanCtrls, orFmanCtrl);
return E_OK;
}
-t_Error FmGetSetPortParams(t_Handle h_Fm,t_FmInterModulePortInitParams *p_PortParams)
+t_Error FmGetSetPortParams(t_Handle h_Fm, t_FmInterModulePortInitParams *p_PortParams)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint32_t tmpReg;
- uint8_t hardwarePortId = p_PortParams->hardwarePortId;
- t_FmIpcPortInInitParams portInParams;
- t_FmIpcPhysAddr ipcPhysAddr;
t_Error err;
- t_FmIpcMsg msg;
- t_FmIpcReply reply;
- uint32_t replyLength;
+ uint32_t intFlags;
+ uint8_t hardwarePortId = p_PortParams->hardwarePortId, macId;
+ struct fman_rg fman_rg;
+
+ fman_rg.bmi_rg = p_Fm->p_FmBmiRegs;
+ fman_rg.qmi_rg = p_Fm->p_FmQmiRegs;
+ fman_rg.fpm_rg = p_Fm->p_FmFpmRegs;
+ fman_rg.dma_rg = p_Fm->p_FmDmaRegs;
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ if (p_Fm->guestId != NCSW_MASTER_ID)
{
- portInParams.hardwarePortId = p_PortParams->hardwarePortId;
- portInParams.enumPortType = (uint32_t)p_PortParams->portType;
- portInParams.boolIndependentMode = (uint8_t)p_PortParams->independentMode;
- portInParams.liodnOffset = p_PortParams->liodnOffset;
- portInParams.numOfTasks = p_PortParams->numOfTasks;
- portInParams.numOfExtraTasks = p_PortParams->numOfExtraTasks;
- portInParams.numOfOpenDmas = p_PortParams->numOfOpenDmas;
+ t_FmIpcPortInInitParams portInParams;
+ t_FmIpcPortOutInitParams portOutParams;
+ t_FmIpcMsg msg;
+ t_FmIpcReply reply;
+ uint32_t replyLength;
+
+ portInParams.hardwarePortId = p_PortParams->hardwarePortId;
+ portInParams.enumPortType = (uint32_t)p_PortParams->portType;
+ portInParams.boolIndependentMode= (uint8_t)p_PortParams->independentMode;
+ portInParams.liodnOffset = p_PortParams->liodnOffset;
+ portInParams.numOfTasks = p_PortParams->numOfTasks;
+ portInParams.numOfExtraTasks = p_PortParams->numOfExtraTasks;
+ portInParams.numOfOpenDmas = p_PortParams->numOfOpenDmas;
portInParams.numOfExtraOpenDmas = p_PortParams->numOfExtraOpenDmas;
- portInParams.sizeOfFifo = p_PortParams->sizeOfFifo;
- portInParams.extraSizeOfFifo = p_PortParams->extraSizeOfFifo;
- portInParams.deqPipelineDepth = p_PortParams->deqPipelineDepth;
- portInParams.liodnBase = p_PortParams->liodnBase;
+ portInParams.sizeOfFifo = p_PortParams->sizeOfFifo;
+ portInParams.extraSizeOfFifo = p_PortParams->extraSizeOfFifo;
+ portInParams.deqPipelineDepth = p_PortParams->deqPipelineDepth;
+ portInParams.maxFrameLength = p_PortParams->maxFrameLength;
+ portInParams.liodnBase = p_PortParams->liodnBase;
+
memset(&msg, 0, sizeof(msg));
memset(&reply, 0, sizeof(reply));
msg.msgId = FM_GET_SET_PORT_PARAMS;
memcpy(msg.msgBody, &portInParams, sizeof(portInParams));
- replyLength = (sizeof(uint32_t) + sizeof(p_PortParams->fmMuramPhysBaseAddr));
+ replyLength = (sizeof(uint32_t) + sizeof(t_FmIpcPortOutInitParams));
if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
(uint8_t*)&msg,
sizeof(msg.msgId) +sizeof(portInParams),
@@ -1434,31 +1991,38 @@ t_Error FmGetSetPortParams(t_Handle h_Fm,t_FmInterModulePortInitParams *p_PortPa
NULL,
NULL)) != E_OK)
RETURN_ERROR(MINOR, err, NO_MSG);
- if (replyLength != (sizeof(uint32_t) + sizeof(p_PortParams->fmMuramPhysBaseAddr)))
+ if (replyLength != (sizeof(uint32_t) + sizeof(t_FmIpcPortOutInitParams)))
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
- memcpy((uint8_t*)&ipcPhysAddr, reply.replyBody, sizeof(t_FmIpcPhysAddr));
- p_PortParams->fmMuramPhysBaseAddr.high = ipcPhysAddr.high;
- p_PortParams->fmMuramPhysBaseAddr.low = ipcPhysAddr.low;
+ memcpy((uint8_t*)&portOutParams, reply.replyBody, sizeof(t_FmIpcPortOutInitParams));
+
+ p_PortParams->fmMuramPhysBaseAddr.high = portOutParams.ipcPhysAddr.high;
+ p_PortParams->fmMuramPhysBaseAddr.low = portOutParams.ipcPhysAddr.low;
+ p_PortParams->numOfTasks = portOutParams.numOfTasks;
+ p_PortParams->numOfExtraTasks = portOutParams.numOfExtraTasks;
+ p_PortParams->numOfOpenDmas = portOutParams.numOfOpenDmas;
+ p_PortParams->numOfExtraOpenDmas = portOutParams.numOfExtraOpenDmas;
+ p_PortParams->sizeOfFifo = portOutParams.sizeOfFifo;
+ p_PortParams->extraSizeOfFifo = portOutParams.extraSizeOfFifo;
return (t_Error)(reply.error);
}
ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
- XX_LockSpinlock(p_Fm->h_Spinlock);
- if(p_PortParams->independentMode)
+ intFlags = XX_LockIntrSpinlock(p_Fm->h_Spinlock);
+ if (p_PortParams->independentMode)
{
/* set port parameters */
p_Fm->independentMode = p_PortParams->independentMode;
/* disable dispatch limit */
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmflc, 0);
+ fman_qmi_disable_dispatch_limit(fman_rg.fpm_rg);
}
- if(p_PortParams->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)
+ if (p_PortParams->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)
{
- if(p_Fm->hcPortInitialized)
+ if (p_Fm->hcPortInitialized)
{
- XX_UnlockSpinlock(p_Fm->h_Spinlock);
+ XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Only one host command port is allowed."));
}
else
@@ -1466,55 +2030,49 @@ t_Error FmGetSetPortParams(t_Handle h_Fm,t_FmInterModulePortInitParams *p_PortPa
}
p_Fm->p_FmStateStruct->portsTypes[hardwarePortId] = p_PortParams->portType;
- err = FmSetNumOfTasks(p_Fm, p_PortParams->hardwarePortId, p_PortParams->numOfTasks, p_PortParams->numOfExtraTasks, TRUE);
- if(err)
+ err = FmSetNumOfTasks(p_Fm, hardwarePortId, &p_PortParams->numOfTasks, &p_PortParams->numOfExtraTasks, TRUE);
+ if (err)
{
- XX_UnlockSpinlock(p_Fm->h_Spinlock);
+ XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
RETURN_ERROR(MAJOR, err, NO_MSG);
}
-#ifdef FM_QMI_DEQ_OPTIONS_SUPPORT
- if((p_PortParams->portType != e_FM_PORT_TYPE_RX) && (p_PortParams->portType != e_FM_PORT_TYPE_RX_10G))
+#ifdef FM_QMI_NO_DEQ_OPTIONS_SUPPORT
+ if (p_Fm->p_FmStateStruct->revInfo.majorRev != 4)
+#endif /* FM_QMI_NO_DEQ_OPTIONS_SUPPORT */
+ if ((p_PortParams->portType != e_FM_PORT_TYPE_RX) &&
+ (p_PortParams->portType != e_FM_PORT_TYPE_RX_10G))
/* for transmit & O/H ports */
{
uint8_t enqTh;
uint8_t deqTh;
- bool update = FALSE;
/* update qmi ENQ/DEQ threshold */
p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums += p_PortParams->deqPipelineDepth;
- tmpReg = GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_gc);
- enqTh = (uint8_t)(tmpReg>>8);
+ enqTh = fman_get_qmi_enq_th(fman_rg.qmi_rg);
/* if enqTh is too big, we reduce it to the max value that is still OK */
- if(enqTh >= (QMI_MAX_NUM_OF_TNUMS - p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums))
+ if (enqTh >= (QMI_MAX_NUM_OF_TNUMS - p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums))
{
enqTh = (uint8_t)(QMI_MAX_NUM_OF_TNUMS - p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums - 1);
- tmpReg &= ~QMI_CFG_ENQ_MASK;
- tmpReg |= ((uint32_t)enqTh << 8);
- update = TRUE;
+ fman_set_qmi_enq_th(fman_rg.qmi_rg, enqTh);
}
- deqTh = (uint8_t)tmpReg;
+ deqTh = fman_get_qmi_deq_th(fman_rg.qmi_rg);
/* if deqTh is too small, we enlarge it to the min value that is still OK.
deqTh may not be larger than 63 (QMI_MAX_NUM_OF_TNUMS-1). */
- if((deqTh <= p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums) && (deqTh < QMI_MAX_NUM_OF_TNUMS-1))
+ if ((deqTh <= p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums) && (deqTh < QMI_MAX_NUM_OF_TNUMS-1))
{
deqTh = (uint8_t)(p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums + 1);
- tmpReg &= ~QMI_CFG_DEQ_MASK;
- tmpReg |= (uint32_t)deqTh;
- update = TRUE;
+ fman_set_qmi_deq_th(fman_rg.qmi_rg, deqTh);
}
- if(update)
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_gc, tmpReg);
}
-#endif /* FM_QMI_DEQ_OPTIONS_SUPPORT */
#ifdef FM_LOW_END_RESTRICTION
- if((hardwarePortId==0x1) || (hardwarePortId==0x29))
+ if ((hardwarePortId==0x1) || (hardwarePortId==0x29))
{
- if(p_Fm->p_FmStateStruct->lowEndRestriction)
+ if (p_Fm->p_FmStateStruct->lowEndRestriction)
{
- XX_UnlockSpinlock(p_Fm->h_Spinlock);
+ XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("OP #0 cannot work with Tx Port #1."));
}
else
@@ -1523,75 +2081,64 @@ t_Error FmGetSetPortParams(t_Handle h_Fm,t_FmInterModulePortInitParams *p_PortPa
#endif /* FM_LOW_END_RESTRICTION */
err = FmSetSizeOfFifo(p_Fm,
- p_PortParams->hardwarePortId,
- p_PortParams->portType,
- p_PortParams->independentMode,
- &p_PortParams->sizeOfFifo,
- p_PortParams->extraSizeOfFifo,
- p_PortParams->deqPipelineDepth,
- NULL,
- TRUE);
- if(err)
+ hardwarePortId,
+ &p_PortParams->sizeOfFifo,
+ &p_PortParams->extraSizeOfFifo,
+ TRUE);
+ if (err)
{
- XX_UnlockSpinlock(p_Fm->h_Spinlock);
+ XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
RETURN_ERROR(MAJOR, err, NO_MSG);
}
- err = FmSetNumOfOpenDmas(p_Fm, p_PortParams->hardwarePortId, p_PortParams->numOfOpenDmas, p_PortParams->numOfExtraOpenDmas, TRUE);
- if(err)
+ err = FmSetNumOfOpenDmas(p_Fm,
+ hardwarePortId,
+ &p_PortParams->numOfOpenDmas,
+ &p_PortParams->numOfExtraOpenDmas,
+ TRUE);
+ if (err)
{
- XX_UnlockSpinlock(p_Fm->h_Spinlock);
+ XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
RETURN_ERROR(MAJOR, err, NO_MSG);
}
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_ppid[hardwarePortId-1], (uint32_t)p_PortParams->liodnOffset);
+ fman_set_liodn_per_port(&fman_rg,
+ hardwarePortId,
+ p_PortParams->liodnBase,
+ p_PortParams->liodnOffset);
+
+ if (p_Fm->p_FmStateStruct->revInfo.majorRev < 6)
+ fman_set_order_restoration_per_port(fman_rg.fpm_rg,
+ hardwarePortId,
+ p_PortParams->independentMode,
+ !!((p_PortParams->portType==e_FM_PORT_TYPE_RX) || (p_PortParams->portType==e_FM_PORT_TYPE_RX_10G)));
+
+ HW_PORT_ID_TO_SW_PORT_ID(macId, hardwarePortId);
- tmpReg = (uint32_t)(hardwarePortId << FPM_PORT_FM_CTL_PORTID_SHIFT);
- if(p_PortParams->independentMode)
+#if defined(FM_MAX_NUM_OF_10G_MACS) && (FM_MAX_NUM_OF_10G_MACS)
+ if ((p_PortParams->portType == e_FM_PORT_TYPE_TX_10G) ||
+ (p_PortParams->portType == e_FM_PORT_TYPE_RX_10G))
{
- if((p_PortParams->portType==e_FM_PORT_TYPE_RX) || (p_PortParams->portType==e_FM_PORT_TYPE_RX_10G))
- tmpReg |= (FPM_PORT_FM_CTL1 << FPM_PRC_ORA_FM_CTL_SEL_SHIFT) |FPM_PORT_FM_CTL1;
+ ASSERT_COND(macId < FM_MAX_NUM_OF_10G_MACS);
+ if (p_PortParams->maxFrameLength >= p_Fm->p_FmStateStruct->macMaxFrameLengths10G[macId])
+ p_Fm->p_FmStateStruct->portMaxFrameLengths10G[macId] = p_PortParams->maxFrameLength;
else
- tmpReg |= (FPM_PORT_FM_CTL2 << FPM_PRC_ORA_FM_CTL_SEL_SHIFT) |FPM_PORT_FM_CTL2;
+ RETURN_ERROR(MINOR, E_INVALID_VALUE, ("Port maxFrameLength is smaller than MAC current MTU"));
}
else
+#endif /* defined(FM_MAX_NUM_OF_10G_MACS) && ... */
+ if ((p_PortParams->portType == e_FM_PORT_TYPE_TX) ||
+ (p_PortParams->portType == e_FM_PORT_TYPE_RX))
{
- tmpReg |= (FPM_PORT_FM_CTL2|FPM_PORT_FM_CTL1);
-
- /* order restoration */
- if(hardwarePortId%2)
- tmpReg |= (FPM_PORT_FM_CTL1 << FPM_PRC_ORA_FM_CTL_SEL_SHIFT);
+ ASSERT_COND(macId < FM_MAX_NUM_OF_1G_MACS);
+ if (p_PortParams->maxFrameLength >= p_Fm->p_FmStateStruct->macMaxFrameLengths1G[macId])
+ p_Fm->p_FmStateStruct->portMaxFrameLengths1G[macId] = p_PortParams->maxFrameLength;
else
- tmpReg |= (FPM_PORT_FM_CTL2 << FPM_PRC_ORA_FM_CTL_SEL_SHIFT);
- }
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmpr, tmpReg);
-
- {
-#ifdef FM_PARTITION_ARRAY
- t_FmRevisionInfo revInfo;
-
- FM_GetRevision(p_Fm, &revInfo);
- if (revInfo.majorRev >= 2)
-#endif /* FM_PARTITION_ARRAY */
- {
- /* set LIODN base for this port */
- tmpReg = GET_UINT32(p_Fm->p_FmDmaRegs->fmdmplr[hardwarePortId/2]);
- if(hardwarePortId%2)
- {
- tmpReg &= ~FM_LIODN_BASE_MASK;
- tmpReg |= (uint32_t)p_PortParams->liodnBase;
- }
- else
- {
- tmpReg &= ~(FM_LIODN_BASE_MASK<< DMA_LIODN_SHIFT);
- tmpReg |= (uint32_t)p_PortParams->liodnBase << DMA_LIODN_SHIFT;
- }
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmplr[hardwarePortId/2], tmpReg);
- }
+ RETURN_ERROR(MINOR, E_INVALID_VALUE, ("Port maxFrameLength is smaller than MAC current MTU"));
}
FmGetPhysicalMuramBase(p_Fm, &p_PortParams->fmMuramPhysBaseAddr);
- XX_UnlockSpinlock(p_Fm->h_Spinlock);
+ XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
return E_OK;
}
@@ -1599,39 +2146,41 @@ t_Error FmGetSetPortParams(t_Handle h_Fm,t_FmInterModulePortInitParams *p_PortPa
void FmFreePortParams(t_Handle h_Fm,t_FmInterModulePortFreeParams *p_PortParams)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint32_t tmpReg;
+ uint32_t intFlags;
uint8_t hardwarePortId = p_PortParams->hardwarePortId;
- uint8_t numOfTasks;
+ uint8_t numOfTasks, numOfDmas, macId;
+ uint16_t sizeOfFifo;
t_Error err;
t_FmIpcPortFreeParams portParams;
t_FmIpcMsg msg;
+ struct fman_qmi_regs *qmi_rg = p_Fm->p_FmQmiRegs;
+ struct fman_bmi_regs *bmi_rg = p_Fm->p_FmBmiRegs;
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ if (p_Fm->guestId != NCSW_MASTER_ID)
{
portParams.hardwarePortId = p_PortParams->hardwarePortId;
portParams.enumPortType = (uint32_t)p_PortParams->portType;
-#ifdef FM_QMI_DEQ_OPTIONS_SUPPORT
portParams.deqPipelineDepth = p_PortParams->deqPipelineDepth;
-#endif /* FM_QMI_DEQ_OPTIONS_SUPPORT */
memset(&msg, 0, sizeof(msg));
msg.msgId = FM_FREE_PORT;
memcpy(msg.msgBody, &portParams, sizeof(portParams));
- if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
- (uint8_t*)&msg,
- sizeof(msg.msgId)+sizeof(portParams),
- NULL,
- NULL,
- NULL,
- NULL)) != E_OK)
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId)+sizeof(portParams),
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ if (err != E_OK)
REPORT_ERROR(MINOR, err, NO_MSG);
return;
}
ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
- XX_LockSpinlock(p_Fm->h_Spinlock);
+ intFlags = XX_LockIntrSpinlock(p_Fm->h_Spinlock);
- if(p_PortParams->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)
+ if (p_PortParams->portType == e_FM_PORT_TYPE_OH_HOST_COMMAND)
{
ASSERT_COND(p_Fm->hcPortInitialized);
p_Fm->hcPortInitialized = FALSE;
@@ -1639,102 +2188,109 @@ void FmFreePortParams(t_Handle h_Fm,t_FmInterModulePortFreeParams *p_PortParams)
p_Fm->p_FmStateStruct->portsTypes[hardwarePortId] = e_FM_PORT_TYPE_DUMMY;
- tmpReg = GET_UINT32(p_Fm->p_FmBmiRegs->fmbm_pp[hardwarePortId-1]);
/* free numOfTasks */
- numOfTasks = (uint8_t)(((tmpReg & BMI_NUM_OF_TASKS_MASK) >> BMI_NUM_OF_TASKS_SHIFT) + 1);
+ numOfTasks = fman_get_num_of_tasks(bmi_rg, hardwarePortId);
ASSERT_COND(p_Fm->p_FmStateStruct->accumulatedNumOfTasks >= numOfTasks);
p_Fm->p_FmStateStruct->accumulatedNumOfTasks -= numOfTasks;
/* free numOfOpenDmas */
- ASSERT_COND(p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas >= ((tmpReg & BMI_NUM_OF_DMAS_MASK) >> BMI_NUM_OF_DMAS_SHIFT) + 1);
- p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas -= (((tmpReg & BMI_NUM_OF_DMAS_MASK) >> BMI_NUM_OF_DMAS_SHIFT) + 1);
+ numOfDmas = fman_get_num_of_dmas(bmi_rg, hardwarePortId);
+ ASSERT_COND(p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas >= numOfDmas);
+ p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas -= numOfDmas;
- /* update total num of DMA's with committed number of open DMAS, and max uncommitted pool. */
- tmpReg = GET_UINT32(p_Fm->p_FmBmiRegs->fmbm_cfg2) & ~BMI_CFG2_DMAS_MASK;
- tmpReg |= (uint32_t)(p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas + p_Fm->p_FmStateStruct->extraOpenDmasPoolSize - 1) << BMI_CFG2_DMAS_SHIFT;
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_cfg2, tmpReg);
+#ifdef FM_HAS_TOTAL_DMAS
+ if (p_Fm->p_FmStateStruct->revInfo.majorRev < 6)
+ {
+ /* update total num of DMA's with committed number of open DMAS, and max uncommitted pool. */
+ fman_set_num_of_open_dmas(bmi_rg,
+ hardwarePortId,
+ 1,
+ 0,
+ (uint8_t)(p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas + p_Fm->p_FmStateStruct->extraOpenDmasPoolSize));
+ }
+#endif /* FM_HAS_TOTAL_DMAS */
/* free sizeOfFifo */
- tmpReg = GET_UINT32(p_Fm->p_FmBmiRegs->fmbm_pfs[hardwarePortId-1]);
- ASSERT_COND(p_Fm->p_FmStateStruct->accumulatedFifoSize >=
- (((tmpReg & BMI_FIFO_SIZE_MASK) + 1) * BMI_FIFO_UNITS));
- p_Fm->p_FmStateStruct->accumulatedFifoSize -=
- (((tmpReg & BMI_FIFO_SIZE_MASK) + 1) * BMI_FIFO_UNITS);
-
- /* clear registers */
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_pp[hardwarePortId-1], 0);
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_pfs[hardwarePortId-1], 0);
- /* WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_ppid[hardwarePortId-1], 0); */
-
-#ifdef FM_PORT_DISABLED_ERRATA_FMANx9
- /* this errata means that when a port is taken down, other port may not use its
- * resources for a while as it may still be using it (in case of reject).
- */
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- XX_UDelay(100000);
- }
-#endif /* FM_PORT_DISABLED_ERRATA_FMANx9 */
-
-#ifdef FM_QMI_DEQ_OPTIONS_SUPPORT
- if((p_PortParams->portType != e_FM_PORT_TYPE_RX) && (p_PortParams->portType != e_FM_PORT_TYPE_RX_10G))
+ sizeOfFifo = fman_get_size_of_fifo(bmi_rg, hardwarePortId);
+ ASSERT_COND(p_Fm->p_FmStateStruct->accumulatedFifoSize >= (sizeOfFifo * BMI_FIFO_UNITS));
+ p_Fm->p_FmStateStruct->accumulatedFifoSize -= (sizeOfFifo * BMI_FIFO_UNITS);
+
+#ifdef FM_QMI_NO_DEQ_OPTIONS_SUPPORT
+ if (p_Fm->p_FmStateStruct->revInfo.majorRev != 4)
+#endif /* FM_QMI_NO_DEQ_OPTIONS_SUPPORT */
+ if ((p_PortParams->portType != e_FM_PORT_TYPE_RX) &&
+ (p_PortParams->portType != e_FM_PORT_TYPE_RX_10G))
/* for transmit & O/H ports */
{
uint8_t enqTh;
uint8_t deqTh;
- tmpReg = GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_gc);
/* update qmi ENQ/DEQ threshold */
p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums -= p_PortParams->deqPipelineDepth;
/* p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums is now smaller,
so we can enlarge enqTh */
enqTh = (uint8_t)(QMI_MAX_NUM_OF_TNUMS - p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums - 1);
- tmpReg &= ~QMI_CFG_ENQ_MASK;
- tmpReg |= ((uint32_t)enqTh << QMI_CFG_ENQ_SHIFT);
/* p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums is now smaller,
- so we can reduce deqTh */
+ so we can reduce deqTh */
deqTh = (uint8_t)(p_Fm->p_FmStateStruct->accumulatedNumOfDeqTnums + 1);
- tmpReg &= ~QMI_CFG_DEQ_MASK;
- tmpReg |= (uint32_t)deqTh;
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_gc, tmpReg);
+ fman_set_qmi_enq_th(qmi_rg, enqTh);
+ fman_set_qmi_deq_th(qmi_rg, deqTh);
+ }
+
+ HW_PORT_ID_TO_SW_PORT_ID(macId, hardwarePortId);
+
+#if defined(FM_MAX_NUM_OF_10G_MACS) && (FM_MAX_NUM_OF_10G_MACS)
+ if ((p_PortParams->portType == e_FM_PORT_TYPE_TX_10G) ||
+ (p_PortParams->portType == e_FM_PORT_TYPE_RX_10G))
+ {
+ ASSERT_COND(macId < FM_MAX_NUM_OF_10G_MACS);
+ p_Fm->p_FmStateStruct->portMaxFrameLengths10G[macId] = 0;
+ }
+ else
+#endif /* defined(FM_MAX_NUM_OF_10G_MACS) && ... */
+ if ((p_PortParams->portType == e_FM_PORT_TYPE_TX) ||
+ (p_PortParams->portType == e_FM_PORT_TYPE_RX))
+ {
+ ASSERT_COND(macId < FM_MAX_NUM_OF_1G_MACS);
+ p_Fm->p_FmStateStruct->portMaxFrameLengths1G[macId] = 0;
}
-#endif /* FM_QMI_DEQ_OPTIONS_SUPPORT */
#ifdef FM_LOW_END_RESTRICTION
- if((hardwarePortId==0x1) || (hardwarePortId==0x29))
+ if ((hardwarePortId==0x1) || (hardwarePortId==0x29))
p_Fm->p_FmStateStruct->lowEndRestriction = FALSE;
#endif /* FM_LOW_END_RESTRICTION */
- XX_UnlockSpinlock(p_Fm->h_Spinlock);
+ XX_UnlockIntrSpinlock(p_Fm->h_Spinlock, intFlags);
}
t_Error FmIsPortStalled(t_Handle h_Fm, uint8_t hardwarePortId, bool *p_IsStalled)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint32_t tmpReg;
t_Error err;
t_FmIpcMsg msg;
t_FmIpcReply reply;
uint32_t replyLength;
+ struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ !p_Fm->baseAddr &&
+ p_Fm->h_IpcSessions[0])
{
memset(&msg, 0, sizeof(msg));
memset(&reply, 0, sizeof(reply));
msg.msgId = FM_IS_PORT_STALLED;
msg.msgBody[0] = hardwarePortId;
replyLength = sizeof(uint32_t) + sizeof(uint8_t);
- if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
- (uint8_t*)&msg,
- sizeof(msg.msgId)+sizeof(hardwarePortId),
- (uint8_t*)&reply,
- &replyLength,
- NULL,
- NULL)) != E_OK)
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId)+sizeof(hardwarePortId),
+ (uint8_t*)&reply,
+ &replyLength,
+ NULL,
+ NULL);
+ if (err != E_OK)
RETURN_ERROR(MINOR, err, NO_MSG);
if (replyLength != (sizeof(uint32_t) + sizeof(uint8_t)))
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
@@ -1743,9 +2299,11 @@ t_Error FmIsPortStalled(t_Handle h_Fm, uint8_t hardwarePortId, bool *p_IsStalled
return (t_Error)(reply.error);
}
+ else if (!p_Fm->baseAddr)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("Either IPC or 'baseAddress' is required!"));
- tmpReg = GET_UINT32(p_Fm->p_FmFpmRegs->fmfp_ps[hardwarePortId]);
- *p_IsStalled = (bool)!!(tmpReg & FPM_PS_STALLED);
+ *p_IsStalled = fman_is_port_stalled(fpm_rg, hardwarePortId);
return E_OK;
}
@@ -1753,42 +2311,51 @@ t_Error FmIsPortStalled(t_Handle h_Fm, uint8_t hardwarePortId, bool *p_IsStalled
t_Error FmResumeStalledPort(t_Handle h_Fm, uint8_t hardwarePortId)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint32_t tmpReg;
t_Error err;
bool isStalled;
- t_FmIpcMsg msg;
- t_FmIpcReply reply;
- uint32_t replyLength;
+ struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ !p_Fm->baseAddr &&
+ p_Fm->h_IpcSessions[0])
{
+ t_FmIpcMsg msg;
+ t_FmIpcReply reply;
+ uint32_t replyLength;
+
memset(&msg, 0, sizeof(msg));
memset(&reply, 0, sizeof(reply));
msg.msgId = FM_RESUME_STALLED_PORT;
msg.msgBody[0] = hardwarePortId;
replyLength = sizeof(uint32_t);
- if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
- (uint8_t*)&msg,
- sizeof(msg.msgId) + sizeof(hardwarePortId),
- (uint8_t*)&reply,
- &replyLength,
- NULL,
- NULL)) != E_OK)
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId) + sizeof(hardwarePortId),
+ (uint8_t*)&reply,
+ &replyLength,
+ NULL,
+ NULL);
+ if (err != E_OK)
RETURN_ERROR(MINOR, err, NO_MSG);
if (replyLength != sizeof(uint32_t))
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
return (t_Error)(reply.error);
}
+ else if (!p_Fm->baseAddr)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("Either IPC or 'baseAddress' is required!"));
+
+ if (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6)
+ RETURN_ERROR(MINOR, E_NOT_AVAILABLE, ("Not available for this FM revision!"));
/* Get port status */
err = FmIsPortStalled(h_Fm, hardwarePortId, &isStalled);
- if(err)
+ if (err)
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Can't get port status"));
if (!isStalled)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Port is not stalled"));
+ return E_OK;
- tmpReg = (uint32_t)((hardwarePortId << FPM_PORT_FM_CTL_PORTID_SHIFT) | FPM_PRC_REALSE_STALLED);
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmpr, tmpReg);
+ fman_resume_stalled_port(fpm_rg, hardwarePortId);
return E_OK;
}
@@ -1796,120 +2363,113 @@ t_Error FmResumeStalledPort(t_Handle h_Fm, uint8_t hardwarePortId)
t_Error FmResetMac(t_Handle h_Fm, e_FmMacType type, uint8_t macId)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint32_t bitMask, timeout = 1000;
- t_FmIpcMacParams macParams;
t_Error err;
- t_FmIpcMsg msg;
- t_FmIpcReply reply;
- uint32_t replyLength;
+ struct fman_fpm_regs *fpm_rg = p_Fm->p_FmFpmRegs;
- if(p_Fm->guestId != NCSW_MASTER_ID)
- {
- if(p_Fm->h_IpcSessions[0])
- {
- memset(&msg, 0, sizeof(msg));
- memset(&reply, 0, sizeof(reply));
- macParams.id = macId;
- macParams.enumType = (uint32_t)type;
- msg.msgId = FM_RESET_MAC;
- memcpy(msg.msgBody, &macParams, sizeof(macParams));
- replyLength = sizeof(uint32_t);
- if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
- (uint8_t*)&msg,
- sizeof(msg.msgId)+sizeof(macParams),
- (uint8_t*)&reply,
- &replyLength,
- NULL,
- NULL)) != E_OK)
- RETURN_ERROR(MINOR, err, NO_MSG);
- if (replyLength != sizeof(uint32_t))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
- return (t_Error)(reply.error);
- }
- else
- if(!p_Fm->p_FmFpmRegs)
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("No IPC and no registers address"));
- }
+#if (DPAA_VERSION >= 11)
+ if (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("FMan MAC reset!"));
+#endif /*(DPAA_VERSION >= 11)*/
- /* Get the relevant bit mask */
- if (type == e_FM_MAC_10G)
- {
- switch(macId)
- {
- case(0):
- bitMask = FPM_RSTC_10G0_RESET;
- break;
- default:
- RETURN_ERROR(MINOR, E_INVALID_VALUE, ("Illegal MAC Id"));
- }
- }
- else
+ if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ !p_Fm->baseAddr &&
+ p_Fm->h_IpcSessions[0])
{
- switch(macId)
- {
- case(0):
- bitMask = FPM_RSTC_1G0_RESET;
- break;
- case(1):
- bitMask = FPM_RSTC_1G1_RESET;
- break;
- case(2):
- bitMask = FPM_RSTC_1G2_RESET;
- break;
- case(3):
- bitMask = FPM_RSTC_1G3_RESET;
- break;
- case(4):
- bitMask = FPM_RSTC_1G4_RESET;
- break;
- default:
- RETURN_ERROR(MINOR, E_INVALID_VALUE, ("Illegal MAC Id"));
- }
+ t_FmIpcMacParams macParams;
+ t_FmIpcMsg msg;
+ t_FmIpcReply reply;
+ uint32_t replyLength;
+
+ memset(&msg, 0, sizeof(msg));
+ memset(&reply, 0, sizeof(reply));
+ macParams.id = macId;
+ macParams.enumType = (uint32_t)type;
+ msg.msgId = FM_RESET_MAC;
+ memcpy(msg.msgBody, &macParams, sizeof(macParams));
+ replyLength = sizeof(uint32_t);
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId)+sizeof(macParams),
+ (uint8_t*)&reply,
+ &replyLength,
+ NULL,
+ NULL);
+ if (err != E_OK)
+ RETURN_ERROR(MINOR, err, NO_MSG);
+ if (replyLength != sizeof(uint32_t))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
+ return (t_Error)(reply.error);
}
+ else if (!p_Fm->baseAddr)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("Either IPC or 'baseAddress' is required!"));
+
+ err = (t_Error)fman_reset_mac(fpm_rg, macId, !!(type == e_FM_MAC_10G));
- /* reset */
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fmrstc, bitMask);
- while ((GET_UINT32(p_Fm->p_FmFpmRegs->fmrstc) & bitMask) &&
- --timeout) ;
- if (!timeout)
+ if (err == -EBUSY)
return ERROR_CODE(E_TIMEOUT);
+ else if (err)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal MAC ID"));
+
return E_OK;
}
t_Error FmSetMacMaxFrame(t_Handle h_Fm, e_FmMacType type, uint8_t macId, uint16_t mtu)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- t_FmIpcMacMaxFrameParams macMaxFrameLengthParams;
- t_Error err;
- t_FmIpcMsg msg;
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ p_Fm->h_IpcSessions[0])
{
+ t_FmIpcMacMaxFrameParams macMaxFrameLengthParams;
+ t_Error err;
+ t_FmIpcMsg msg;
+
memset(&msg, 0, sizeof(msg));
macMaxFrameLengthParams.macParams.id = macId;
macMaxFrameLengthParams.macParams.enumType = (uint32_t)type;
macMaxFrameLengthParams.maxFrameLength = (uint16_t)mtu;
msg.msgId = FM_SET_MAC_MAX_FRAME;
memcpy(msg.msgBody, &macMaxFrameLengthParams, sizeof(macMaxFrameLengthParams));
- if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
- (uint8_t*)&msg,
- sizeof(msg.msgId)+sizeof(macMaxFrameLengthParams),
- NULL,
- NULL,
- NULL,
- NULL)) != E_OK)
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId)+sizeof(macMaxFrameLengthParams),
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ if (err != E_OK)
RETURN_ERROR(MINOR, err, NO_MSG);
return E_OK;
}
+ else if (p_Fm->guestId != NCSW_MASTER_ID)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("running in guest-mode without IPC!"));
+ /* if port is already initialized, check that MaxFrameLength is smaller
+ * or equal to the port's max */
#if (defined(FM_MAX_NUM_OF_10G_MACS) && (FM_MAX_NUM_OF_10G_MACS))
if (type == e_FM_MAC_10G)
- p_Fm->p_FmStateStruct->macMaxFrameLengths10G[macId] = mtu;
+ {
+ if ((!p_Fm->p_FmStateStruct->portMaxFrameLengths10G[macId])
+ || (p_Fm->p_FmStateStruct->portMaxFrameLengths10G[macId] &&
+ (mtu <= p_Fm->p_FmStateStruct->portMaxFrameLengths10G[macId])))
+ p_Fm->p_FmStateStruct->macMaxFrameLengths10G[macId] = mtu;
+ else
+ RETURN_ERROR(MINOR, E_INVALID_VALUE, ("MAC maxFrameLength is larger than Port maxFrameLength"));
+
+ }
else
#else
UNUSED(type);
#endif /* (defined(FM_MAX_NUM_OF_10G_MACS) && ... */
+ if ((!p_Fm->p_FmStateStruct->portMaxFrameLengths1G[macId])
+ || (p_Fm->p_FmStateStruct->portMaxFrameLengths1G[macId] &&
+ (mtu <= p_Fm->p_FmStateStruct->portMaxFrameLengths1G[macId])))
p_Fm->p_FmStateStruct->macMaxFrameLengths1G[macId] = mtu;
+ else
+ RETURN_ERROR(MINOR, E_INVALID_VALUE, ("MAC maxFrameLength is larger than Port maxFrameLength"));
return E_OK;
}
@@ -1917,21 +2477,32 @@ t_Error FmSetMacMaxFrame(t_Handle h_Fm, e_FmMacType type, uint8_t macId, uint16_
uint16_t FmGetClockFreq(t_Handle h_Fm)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- /* for MC environment: this depends on the
+
+ /* for multicore environment: this depends on the
* fact that fmClkFreq was properly initialized at "init". */
return p_Fm->p_FmStateStruct->fmClkFreq;
}
+uint16_t FmGetMacClockFreq(t_Handle h_Fm)
+{
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+
+ return p_Fm->p_FmStateStruct->fmMacClkFreq;
+}
+
uint32_t FmGetTimeStampScale(t_Handle h_Fm)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- t_Error err;
- t_FmIpcMsg msg;
- t_FmIpcReply reply;
- uint32_t replyLength, timeStamp;
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ !p_Fm->baseAddr &&
+ p_Fm->h_IpcSessions[0])
{
+ t_Error err;
+ t_FmIpcMsg msg;
+ t_FmIpcReply reply;
+ uint32_t replyLength, timeStamp;
+
memset(&msg, 0, sizeof(msg));
memset(&reply, 0, sizeof(reply));
msg.msgId = FM_GET_TIMESTAMP_SCALE;
@@ -1943,32 +2514,34 @@ uint32_t FmGetTimeStampScale(t_Handle h_Fm)
&replyLength,
NULL,
NULL)) != E_OK)
- RETURN_ERROR(MINOR, err, NO_MSG);
- if(replyLength != (sizeof(uint32_t) + sizeof(uint32_t)))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
+ {
+ REPORT_ERROR(MAJOR, err, NO_MSG);
+ return 0;
+ }
+ if (replyLength != (sizeof(uint32_t) + sizeof(uint32_t)))
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
+ return 0;
+ }
memcpy((uint8_t*)&timeStamp, reply.replyBody, sizeof(uint32_t));
return timeStamp;
}
-
- if(!p_Fm->p_FmStateStruct->enabledTimeStamp)
- FmEnableTimeStamp(p_Fm);
+ else if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ p_Fm->baseAddr)
+ {
+ if (!(GET_UINT32(p_Fm->p_FmFpmRegs->fmfp_tsc1) & FPM_TS_CTL_EN))
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("timestamp is not enabled!"));
+ return 0;
+ }
+ }
+ else if (p_Fm->guestId != NCSW_MASTER_ID)
+ DBG(WARNING, ("No IPC - can't validate FM if timestamp enabled."));
return p_Fm->p_FmStateStruct->count1MicroBit;
}
-bool FmRamsEccIsExternalCtl(t_Handle h_Fm)
-{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint32_t tmpReg;
-
- tmpReg = GET_UINT32(p_Fm->p_FmFpmRegs->fmrcr);
- if(tmpReg & FPM_RAM_CTL_RAMS_ECC_EN_SRC_SEL)
- return TRUE;
- else
- return FALSE;
-}
-
t_Error FmEnableRamsEcc(t_Handle h_Fm)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
@@ -1990,11 +2563,12 @@ t_Error FmDisableRamsEcc(t_Handle h_Fm)
ASSERT_COND(p_Fm->p_FmStateStruct->ramsEccOwners);
p_Fm->p_FmStateStruct->ramsEccOwners--;
- if(p_Fm->p_FmStateStruct->ramsEccOwners==0)
+ if (p_Fm->p_FmStateStruct->ramsEccOwners==0)
{
p_Fm->p_FmStateStruct->internalCall = TRUE;
return FM_DisableRamsEcc(p_Fm);
}
+
return E_OK;
}
@@ -2012,221 +2586,122 @@ bool FmIsMaster(t_Handle h_Fm)
return (p_Fm->guestId == NCSW_MASTER_ID);
}
-t_Error FmSetSizeOfFifo(t_Handle h_Fm,
- uint8_t hardwarePortId,
- e_FmPortType portType,
- bool independentMode,
- uint32_t *p_SizeOfFifo,
- uint32_t extraSizeOfFifo,
- uint8_t deqPipelineDepth,
- t_FmInterModulePortRxPoolsParams *p_RxPoolsParams,
- bool initialConfig)
+t_Error FmSetSizeOfFifo(t_Handle h_Fm,
+ uint8_t hardwarePortId,
+ uint32_t *p_SizeOfFifo,
+ uint32_t *p_ExtraSizeOfFifo,
+ bool initialConfig)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint8_t relativePortId;
- uint16_t macMaxFrameLength = 0, oldVal;
- uint32_t minFifoSizeRequired = 0, sizeOfFifo, tmpReg = 0;
- t_FmIpcPortFifoParams fifoParams;
+ t_FmIpcPortRsrcParams rsrcParams;
t_Error err;
+ struct fman_bmi_regs *bmi_rg = p_Fm->p_FmBmiRegs;
+ uint32_t sizeOfFifo = *p_SizeOfFifo, extraSizeOfFifo = *p_ExtraSizeOfFifo;
+ uint16_t currentVal = 0, currentExtraVal = 0;
- ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
- ASSERT_COND(initialConfig || p_RxPoolsParams);
-
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ !p_Fm->baseAddr &&
+ p_Fm->h_IpcSessions[0])
{
t_FmIpcMsg msg;
t_FmIpcReply reply;
uint32_t replyLength;
- ASSERT_COND(p_RxPoolsParams);
-
- memset(&fifoParams, 0, sizeof(fifoParams));
- fifoParams.rsrcParams.hardwarePortId = hardwarePortId;
- fifoParams.rsrcParams.val = *p_SizeOfFifo;
- fifoParams.rsrcParams.extra = extraSizeOfFifo;
- fifoParams.enumPortType = (uint32_t)portType;
- fifoParams.boolIndependentMode = (uint8_t)independentMode;
- fifoParams.deqPipelineDepth = deqPipelineDepth;
- fifoParams.numOfPools = p_RxPoolsParams->numOfPools;
- fifoParams.secondLargestBufSize = p_RxPoolsParams->secondLargestBufSize;
- fifoParams.largestBufSize = p_RxPoolsParams->largestBufSize;
- fifoParams.boolInitialConfig = (uint8_t)initialConfig;
+ rsrcParams.hardwarePortId = hardwarePortId;
+ rsrcParams.val = sizeOfFifo;
+ rsrcParams.extra = extraSizeOfFifo;
+ rsrcParams.boolInitialConfig = (uint8_t)initialConfig;
memset(&msg, 0, sizeof(msg));
memset(&reply, 0, sizeof(reply));
msg.msgId = FM_SET_SIZE_OF_FIFO;
- memcpy(msg.msgBody, &fifoParams, sizeof(fifoParams));
- replyLength = sizeof(uint32_t) + sizeof(uint32_t);
+ memcpy(msg.msgBody, &rsrcParams, sizeof(rsrcParams));
+ replyLength = sizeof(uint32_t);
if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
(uint8_t*)&msg,
- sizeof(msg.msgId) + sizeof(fifoParams),
+ sizeof(msg.msgId) + sizeof(rsrcParams),
(uint8_t*)&reply,
&replyLength,
NULL,
NULL)) != E_OK)
RETURN_ERROR(MINOR, err, NO_MSG);
- if (replyLength != (sizeof(uint32_t) + sizeof(uint32_t)))
+ if (replyLength != sizeof(uint32_t))
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
- memcpy((uint8_t*)p_SizeOfFifo, reply.replyBody, sizeof(uint32_t));
-
return (t_Error)(reply.error);
}
- sizeOfFifo = *p_SizeOfFifo;
- /* if neseccary (cases where frame length is relevant), update sizeOfFifo field. */
- if((portType == e_FM_PORT_TYPE_TX) || ((portType == e_FM_PORT_TYPE_RX) && independentMode))
+ else if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ p_Fm->baseAddr)
{
- HW_PORT_ID_TO_SW_PORT_ID(relativePortId, hardwarePortId);
- ASSERT_COND(relativePortId < FM_MAX_NUM_OF_1G_MACS);
- macMaxFrameLength = p_Fm->p_FmStateStruct->macMaxFrameLengths1G[relativePortId];
+ DBG(WARNING, ("No IPC - can't validate FM total-fifo size."));
+ fman_set_size_of_fifo(bmi_rg, hardwarePortId, sizeOfFifo, extraSizeOfFifo);
}
+ else if (p_Fm->guestId != NCSW_MASTER_ID)
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
+ ("running in guest-mode without neither IPC nor mapped register!"));
-#if (defined(FM_MAX_NUM_OF_10G_MACS) && (FM_MAX_NUM_OF_10G_MACS))
- if((portType == e_FM_PORT_TYPE_TX_10G) || ((portType == e_FM_PORT_TYPE_RX_10G) && independentMode))
+ if (!initialConfig)
{
- HW_PORT_ID_TO_SW_PORT_ID(relativePortId, hardwarePortId);
- ASSERT_COND(relativePortId < FM_MAX_NUM_OF_10G_MACS);
- macMaxFrameLength = p_Fm->p_FmStateStruct->macMaxFrameLengths10G[relativePortId];
+ /* !initialConfig - runtime change of existing value.
+ * - read the current FIFO and extra FIFO size */
+ currentExtraVal = fman_get_size_of_extra_fifo(bmi_rg, hardwarePortId);
+ currentVal = fman_get_size_of_fifo(bmi_rg, hardwarePortId);
}
-#endif /* (defined(FM_MAX_NUM_OF_10G_MACS) && ... */
- /*************************/
- /* TX PORTS */
- /*************************/
- if((portType == e_FM_PORT_TYPE_TX) || (portType == e_FM_PORT_TYPE_TX_10G))
+ if (extraSizeOfFifo > currentExtraVal)
{
- if(independentMode)
- minFifoSizeRequired = (uint32_t)((macMaxFrameLength % BMI_FIFO_UNITS ?
- (macMaxFrameLength/BMI_FIFO_UNITS + 1) * BMI_FIFO_UNITS :
- macMaxFrameLength) +
- (3*BMI_FIFO_UNITS));
- else
- minFifoSizeRequired = (uint32_t)((macMaxFrameLength % BMI_FIFO_UNITS ?
- (macMaxFrameLength/BMI_FIFO_UNITS + 1) * BMI_FIFO_UNITS :
- macMaxFrameLength) +
- (deqPipelineDepth+3)*BMI_FIFO_UNITS);
- }
- /*************************/
- /* RX IM PORTS */
- /*************************/
- else if(((portType == e_FM_PORT_TYPE_RX) || (portType == e_FM_PORT_TYPE_RX_10G)) && independentMode)
- minFifoSizeRequired = (uint32_t)(((macMaxFrameLength % BMI_FIFO_UNITS) ?
- ((macMaxFrameLength/BMI_FIFO_UNITS + 1) * BMI_FIFO_UNITS) :
- macMaxFrameLength) +
- (4*BMI_FIFO_UNITS));
-
- /* for Rx (non-Im) ports or OP, buffer pools are relevant for fifo size.
- If this routine is called as part of the "GetSet" routine, initialConfig is TRUE
- and these checks where done in the port routine.
- If it is called by an explicit user request ("SetSizeOfFifo"), than these parameters
- should be checked/updated */
- if(!initialConfig &&
- ((portType == e_FM_PORT_TYPE_OH_OFFLINE_PARSING) ||
- (((portType == e_FM_PORT_TYPE_RX) || (portType == e_FM_PORT_TYPE_RX_10G)) && !independentMode)))
- {
- if((portType == e_FM_PORT_TYPE_RX) || (portType == e_FM_PORT_TYPE_RX_10G))
- {
- /*************************/
- /* RX non-IM PORTS */
- /*************************/
-#ifdef FM_FIFO_ALLOCATION_OLD_ALG
- t_FmRevisionInfo revInfo;
-
- FM_GetRevision(p_Fm, &revInfo);
- if(revInfo.majorRev != 4)
- minFifoSizeRequired = (uint32_t)(((p_RxPoolsParams->largestBufSize % BMI_FIFO_UNITS) ?
- ((p_RxPoolsParams->largestBufSize/BMI_FIFO_UNITS + 1) * BMI_FIFO_UNITS) :
- p_RxPoolsParams->largestBufSize) +
- (7*BMI_FIFO_UNITS));
- else
-#endif /* FM_FIFO_ALLOCATION_OLD_ALG */
- {
- if(p_RxPoolsParams->numOfPools == 1)
- minFifoSizeRequired = 8*BMI_FIFO_UNITS;
- else
- {
- minFifoSizeRequired = (uint32_t)(((p_RxPoolsParams->secondLargestBufSize % BMI_FIFO_UNITS) ?
- ((p_RxPoolsParams->secondLargestBufSize/BMI_FIFO_UNITS + 1) * BMI_FIFO_UNITS) :
- p_RxPoolsParams->secondLargestBufSize) +
- (7*BMI_FIFO_UNITS));
- if((sizeOfFifo < minFifoSizeRequired))
- {
- DBG(WARNING, ("User set FIFO size for Rx port is not optimized. (not modified by driver)"));
- minFifoSizeRequired = 8*BMI_FIFO_UNITS;
- }
- }
- }
- }
- else
- {
- /*************************/
- /* OP PORTS */
- /*************************/
- /* check if pool size is not too big */
- if(p_RxPoolsParams->largestBufSize > sizeOfFifo )
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Largest pool size is bigger than ports committed fifo size"));
- }
- }
-
+ if (extraSizeOfFifo && !p_Fm->p_FmStateStruct->extraFifoPoolSize)
+ /* if this is the first time a port requires extraFifoPoolSize, the total extraFifoPoolSize
+ * must be initialized to 1 buffer per port
+ */
+ p_Fm->p_FmStateStruct->extraFifoPoolSize = FM_MAX_NUM_OF_RX_PORTS*BMI_FIFO_UNITS;
- if (minFifoSizeRequired && (sizeOfFifo < minFifoSizeRequired))
- {
- sizeOfFifo = minFifoSizeRequired;
- DBG(WARNING, ("FIFO size enlarged to %d for port %#x", minFifoSizeRequired, hardwarePortId));
- }
-
- if(initialConfig)
- oldVal = 0;
- else
- {
- tmpReg = GET_UINT32(p_Fm->p_FmBmiRegs->fmbm_pfs[hardwarePortId-1]);
- /* read into oldVal the current extra fifo size */
- oldVal = (uint16_t)((((tmpReg & BMI_EXTRA_FIFO_SIZE_MASK) + 1)*BMI_FIFO_UNITS) >> BMI_EXTRA_FIFO_SIZE_SHIFT);
+ p_Fm->p_FmStateStruct->extraFifoPoolSize = MAX(p_Fm->p_FmStateStruct->extraFifoPoolSize, extraSizeOfFifo);
}
- if(extraSizeOfFifo > oldVal)
- p_Fm->p_FmStateStruct->extraFifoPoolSize = NCSW_MAX(p_Fm->p_FmStateStruct->extraFifoPoolSize, extraSizeOfFifo);
-
- if(!initialConfig)
- /* read into oldVal the current num of tasks */
- oldVal = (uint16_t)(((tmpReg & BMI_FIFO_SIZE_MASK) + 1)*BMI_FIFO_UNITS);
-
/* check that there are enough uncommitted fifo size */
- if((p_Fm->p_FmStateStruct->accumulatedFifoSize - oldVal + sizeOfFifo) >
- (p_Fm->p_FmStateStruct->totalFifoSize - p_Fm->p_FmStateStruct->extraFifoPoolSize))
- RETURN_ERROR(MAJOR, E_NOT_AVAILABLE, ("Requested fifo size and extra size exceed total FIFO size."));
+ if ((p_Fm->p_FmStateStruct->accumulatedFifoSize - currentVal + sizeOfFifo) >
+ (p_Fm->p_FmStateStruct->totalFifoSize - p_Fm->p_FmStateStruct->extraFifoPoolSize)){
+ REPORT_ERROR(MAJOR, E_INVALID_VALUE,
+ ("Port request fifo size + accumulated size > total FIFO size:"));
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE,
+ ("port 0x%x requested %d bytes, extra size = %d, accumulated size = %d total size = %d",
+ hardwarePortId, sizeOfFifo, p_Fm->p_FmStateStruct->extraFifoPoolSize,
+ p_Fm->p_FmStateStruct->accumulatedFifoSize,
+ p_Fm->p_FmStateStruct->totalFifoSize));
+ }
else
{
- /* update acummulated */
- ASSERT_COND(p_Fm->p_FmStateStruct->accumulatedFifoSize >= oldVal);
- p_Fm->p_FmStateStruct->accumulatedFifoSize -= oldVal;
+ /* update accumulated */
+ ASSERT_COND(p_Fm->p_FmStateStruct->accumulatedFifoSize >= currentVal);
+ p_Fm->p_FmStateStruct->accumulatedFifoSize -= currentVal;
p_Fm->p_FmStateStruct->accumulatedFifoSize += sizeOfFifo;
- /* calculate reg */
- tmpReg = (uint32_t)((sizeOfFifo/BMI_FIFO_UNITS - 1) |
- ((extraSizeOfFifo/BMI_FIFO_UNITS) << BMI_EXTRA_FIFO_SIZE_SHIFT));
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_pfs[hardwarePortId-1], tmpReg);
+ fman_set_size_of_fifo(bmi_rg, hardwarePortId, sizeOfFifo, extraSizeOfFifo);
}
- *p_SizeOfFifo = sizeOfFifo;
return E_OK;
}
t_Error FmSetNumOfTasks(t_Handle h_Fm,
uint8_t hardwarePortId,
- uint8_t numOfTasks,
- uint8_t numOfExtraTasks,
+ uint8_t *p_NumOfTasks,
+ uint8_t *p_NumOfExtraTasks,
bool initialConfig)
{
t_Fm *p_Fm = (t_Fm *)h_Fm;
- uint8_t oldVal;
- uint32_t tmpReg = 0;
- t_FmIpcPortRsrcParams rsrcParams;
t_Error err;
+ struct fman_bmi_regs *bmi_rg = p_Fm->p_FmBmiRegs;
+ uint8_t currentVal = 0, currentExtraVal = 0, numOfTasks = *p_NumOfTasks, numOfExtraTasks = *p_NumOfExtraTasks;
+
+ ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ !p_Fm->baseAddr &&
+ p_Fm->h_IpcSessions[0])
{
- t_FmIpcMsg msg;
- t_FmIpcReply reply;
- uint32_t replyLength;
+ t_FmIpcPortRsrcParams rsrcParams;
+ t_FmIpcMsg msg;
+ t_FmIpcReply reply;
+ uint32_t replyLength;
rsrcParams.hardwarePortId = hardwarePortId;
rsrcParams.val = numOfTasks;
@@ -2250,65 +2725,69 @@ t_Error FmSetNumOfTasks(t_Handle h_Fm,
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
return (t_Error)(reply.error);
}
-
- ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
-
- if(initialConfig)
- oldVal = 0;
- else
+ else if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ p_Fm->baseAddr)
{
- tmpReg = GET_UINT32(p_Fm->p_FmBmiRegs->fmbm_pp[hardwarePortId-1]);
- /* read into oldVal the current extra tasks */
- oldVal = (uint8_t)((tmpReg & BMI_NUM_OF_EXTRA_TASKS_MASK) >> BMI_EXTRA_NUM_OF_TASKS_SHIFT);
+ DBG(WARNING, ("No IPC - can't validate FM total-num-of-tasks."));
+ fman_set_num_of_tasks(bmi_rg, hardwarePortId, numOfTasks, numOfExtraTasks);
}
+ else if (p_Fm->guestId != NCSW_MASTER_ID)
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
+ ("running in guest-mode without neither IPC nor mapped register!"));
- if(numOfExtraTasks > oldVal)
- p_Fm->p_FmStateStruct->extraTasksPoolSize = (uint8_t)NCSW_MAX(p_Fm->p_FmStateStruct->extraTasksPoolSize, numOfExtraTasks);
+ if (!initialConfig)
+ {
+ /* !initialConfig - runtime change of existing value.
+ * - read the current number of tasks */
+ currentVal = fman_get_num_of_tasks(bmi_rg, hardwarePortId);
+ currentExtraVal = fman_get_num_extra_tasks(bmi_rg, hardwarePortId);
+ }
- if(!initialConfig)
- /* read into oldVal the current num of tasks */
- oldVal = (uint8_t)(((tmpReg & BMI_NUM_OF_TASKS_MASK) >> BMI_NUM_OF_TASKS_SHIFT) + 1);
+ if (numOfExtraTasks > currentExtraVal)
+ p_Fm->p_FmStateStruct->extraTasksPoolSize =
+ (uint8_t)MAX(p_Fm->p_FmStateStruct->extraTasksPoolSize, numOfExtraTasks);
/* check that there are enough uncommitted tasks */
- if((p_Fm->p_FmStateStruct->accumulatedNumOfTasks - oldVal + numOfTasks) >
+ if ((p_Fm->p_FmStateStruct->accumulatedNumOfTasks - currentVal + numOfTasks) >
(p_Fm->p_FmStateStruct->totalNumOfTasks - p_Fm->p_FmStateStruct->extraTasksPoolSize))
RETURN_ERROR(MAJOR, E_NOT_AVAILABLE,
("Requested numOfTasks and extra tasks pool for fm%d exceed total numOfTasks.",
p_Fm->p_FmStateStruct->fmId));
else
{
- ASSERT_COND(p_Fm->p_FmStateStruct->accumulatedNumOfTasks >= oldVal);
- /* update acummulated */
- p_Fm->p_FmStateStruct->accumulatedNumOfTasks -= oldVal;
+ ASSERT_COND(p_Fm->p_FmStateStruct->accumulatedNumOfTasks >= currentVal);
+ /* update accumulated */
+ p_Fm->p_FmStateStruct->accumulatedNumOfTasks -= currentVal;
p_Fm->p_FmStateStruct->accumulatedNumOfTasks += numOfTasks;
- /* calculate reg */
- tmpReg = GET_UINT32(p_Fm->p_FmBmiRegs->fmbm_pp[hardwarePortId-1]) & ~(BMI_NUM_OF_TASKS_MASK | BMI_NUM_OF_EXTRA_TASKS_MASK);
- tmpReg |= (uint32_t)(((numOfTasks-1) << BMI_NUM_OF_TASKS_SHIFT) |
- (numOfExtraTasks << BMI_EXTRA_NUM_OF_TASKS_SHIFT));
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_pp[hardwarePortId-1],tmpReg);
+ fman_set_num_of_tasks(bmi_rg, hardwarePortId, numOfTasks, numOfExtraTasks);
}
return E_OK;
}
t_Error FmSetNumOfOpenDmas(t_Handle h_Fm,
- uint8_t hardwarePortId,
- uint8_t numOfOpenDmas,
- uint8_t numOfExtraOpenDmas,
- bool initialConfig)
+ uint8_t hardwarePortId,
+ uint8_t *p_NumOfOpenDmas,
+ uint8_t *p_NumOfExtraOpenDmas,
+ bool initialConfig)
{
t_Fm *p_Fm = (t_Fm *)h_Fm;
- uint8_t oldVal;
- uint32_t tmpReg = 0;
- t_FmIpcPortRsrcParams rsrcParams;
t_Error err;
+ struct fman_bmi_regs *bmi_rg = p_Fm->p_FmBmiRegs;
+ uint8_t numOfOpenDmas = *p_NumOfOpenDmas, numOfExtraOpenDmas = *p_NumOfExtraOpenDmas;
+ uint8_t totalNumDmas = 0, currentVal = 0, currentExtraVal = 0;
+
+ ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ !p_Fm->baseAddr &&
+ p_Fm->h_IpcSessions[0])
{
- t_FmIpcMsg msg;
- t_FmIpcReply reply;
- uint32_t replyLength;
+ t_FmIpcPortRsrcParams rsrcParams;
+ t_FmIpcMsg msg;
+ t_FmIpcReply reply;
+ uint32_t replyLength;
rsrcParams.hardwarePortId = hardwarePortId;
rsrcParams.val = numOfOpenDmas;
@@ -2332,78 +2811,461 @@ t_Error FmSetNumOfOpenDmas(t_Handle h_Fm,
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
return (t_Error)(reply.error);
}
+#ifdef FM_HAS_TOTAL_DMAS
+ else if (p_Fm->guestId != NCSW_MASTER_ID)
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("running in guest-mode without IPC!"));
+#else
+ else if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ p_Fm->baseAddr &&
+ (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6))
+ {
+ /*DBG(WARNING, ("No IPC - can't validate FM total-num-of-dmas."));*/
- ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
+ if (!numOfOpenDmas)
+ {
+ /* first config without explic it value: Do Nothing - reset value shouldn't be
+ changed, read register for port save */
+ *p_NumOfOpenDmas = fman_get_num_of_dmas(bmi_rg, hardwarePortId);
+ *p_NumOfExtraOpenDmas = fman_get_num_extra_dmas(bmi_rg, hardwarePortId);
+ }
+ else
+ /* whether it is the first time with explicit value, or runtime "set" - write register */
+ fman_set_num_of_open_dmas(bmi_rg,
+ hardwarePortId,
+ numOfOpenDmas,
+ numOfExtraOpenDmas,
+ p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas + p_Fm->p_FmStateStruct->extraOpenDmasPoolSize);
+ }
+ else if (p_Fm->guestId != NCSW_MASTER_ID)
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED,
+ ("running in guest-mode without neither IPC nor mapped register!"));
+#endif /* FM_HAS_TOTAL_DMAS */
- if(initialConfig)
- oldVal = 0;
- else
+ if (!initialConfig)
+ {
+ /* !initialConfig - runtime change of existing value.
+ * - read the current number of open Dma's */
+ currentExtraVal = fman_get_num_extra_dmas(bmi_rg, hardwarePortId);
+ currentVal = fman_get_num_of_dmas(bmi_rg, hardwarePortId);
+ }
+
+#ifdef FM_NO_GUARANTEED_RESET_VALUES
+ /* it's illegal to be in a state where this is not the first set and no value is specified */
+ ASSERT_COND(initialConfig || numOfOpenDmas);
+ if (!numOfOpenDmas)
{
- tmpReg = GET_UINT32(p_Fm->p_FmBmiRegs->fmbm_pp[hardwarePortId-1]);
- /* read into oldVal the current extra tasks */
- oldVal = (uint8_t)((tmpReg & BMI_NUM_OF_EXTRA_DMAS_MASK) >> BMI_EXTRA_NUM_OF_DMAS_SHIFT);
+ /* !numOfOpenDmas - first configuration according to values in regs.
+ * - read the current number of open Dma's */
+ currentExtraVal = fman_get_num_extra_dmas(bmi_rg, hardwarePortId);
+ currentVal = fman_get_num_of_dmas(bmi_rg, hardwarePortId);
+ /* This is the first configuration and user did not specify value (!numOfOpenDmas),
+ * reset values will be used and we just save these values for resource management */
+ p_Fm->p_FmStateStruct->extraOpenDmasPoolSize =
+ (uint8_t)MAX(p_Fm->p_FmStateStruct->extraOpenDmasPoolSize, currentExtraVal);
+ p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas += currentVal;
+ *p_NumOfOpenDmas = currentVal;
+ *p_NumOfExtraOpenDmas = currentExtraVal;
+ return E_OK;
}
+#endif /* FM_NO_GUARANTEED_RESET_VALUES */
+
+ if (numOfExtraOpenDmas > currentExtraVal)
+ p_Fm->p_FmStateStruct->extraOpenDmasPoolSize =
+ (uint8_t)MAX(p_Fm->p_FmStateStruct->extraOpenDmasPoolSize, numOfExtraOpenDmas);
+
+#ifdef FM_HAS_TOTAL_DMAS
+ if ((p_Fm->p_FmStateStruct->revInfo.majorRev < 6) &&
+ (p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas - currentVal + numOfOpenDmas >
+ p_Fm->p_FmStateStruct->maxNumOfOpenDmas))
+ RETURN_ERROR(MAJOR, E_NOT_AVAILABLE,
+ ("Requested numOfOpenDmas for fm%d exceeds total numOfOpenDmas.",
+ p_Fm->p_FmStateStruct->fmId));
+#else
+ if ((p_Fm->p_FmStateStruct->revInfo.majorRev >= 6) &&
+#ifdef FM_HEAVY_TRAFFIC_SEQUENCER_HANG_ERRATA_FMAN_A006981
+ !((p_Fm->p_FmStateStruct->revInfo.majorRev == 6) &&
+ (p_Fm->p_FmStateStruct->revInfo.minorRev == 0)) &&
+#endif /* FM_HEAVY_TRAFFIC_SEQUENCER_HANG_ERRATA_FMAN_A006981 */
+ (p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas - currentVal + numOfOpenDmas > DMA_THRESH_MAX_COMMQ + 1))
+ RETURN_ERROR(MAJOR, E_NOT_AVAILABLE,
+ ("Requested numOfOpenDmas for fm%d exceeds DMA Command queue (%d)",
+ p_Fm->p_FmStateStruct->fmId, DMA_THRESH_MAX_COMMQ+1));
+#endif /* FM_HAS_TOTAL_DMAS */
+ else
+ {
+ ASSERT_COND(p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas >= currentVal);
+ /* update acummulated */
+ p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas -= currentVal;
+ p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas += numOfOpenDmas;
+
+#ifdef FM_HAS_TOTAL_DMAS
+ if (p_Fm->p_FmStateStruct->revInfo.majorRev < 6)
+ totalNumDmas = (uint8_t)(p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas + p_Fm->p_FmStateStruct->extraOpenDmasPoolSize);
+#endif /* FM_HAS_TOTAL_DMAS */
+ fman_set_num_of_open_dmas(bmi_rg,
+ hardwarePortId,
+ numOfOpenDmas,
+ numOfExtraOpenDmas,
+ totalNumDmas);
+ }
- if(numOfExtraOpenDmas > oldVal)
- p_Fm->p_FmStateStruct->extraOpenDmasPoolSize = (uint8_t)NCSW_MAX(p_Fm->p_FmStateStruct->extraOpenDmasPoolSize, numOfExtraOpenDmas);
+ return E_OK;
+}
- if(!initialConfig)
- /* read into oldVal the current num of tasks */
- oldVal = (uint8_t)(((tmpReg & BMI_NUM_OF_DMAS_MASK) >> BMI_NUM_OF_DMAS_SHIFT) + 1);
+#if (DPAA_VERSION >= 11)
+t_Error FmVSPCheckRelativeProfile(t_Handle h_Fm,
+ e_FmPortType portType,
+ uint8_t portId,
+ uint16_t relativeProfile)
+{
+ t_Fm *p_Fm;
+ t_FmSp *p_FmPcdSp;
+ uint8_t swPortIndex=0, hardwarePortId;
- /* check that there are enough uncommitted open DMA's */
- ASSERT_COND(p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas >= oldVal);
- if((p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas - oldVal + numOfOpenDmas) >
- p_Fm->p_FmStateStruct->maxNumOfOpenDmas)
- RETURN_ERROR(MAJOR, E_NOT_AVAILABLE,
- ("Requested numOfOpenDmas for fm%d exceeds total numOfOpenDmas.",
- p_Fm->p_FmStateStruct->fmId));
- else
+ ASSERT_COND(h_Fm);
+ p_Fm = (t_Fm*)h_Fm;
+
+ hardwarePortId = SwPortIdToHwPortId(portType,
+ portId,
+ p_Fm->p_FmStateStruct->revInfo.majorRev,
+ p_Fm->p_FmStateStruct->revInfo.minorRev);
+ ASSERT_COND(hardwarePortId);
+ HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId);
+
+ p_FmPcdSp = p_Fm->p_FmSp;
+ ASSERT_COND(p_FmPcdSp);
+
+ if (!p_FmPcdSp->portsMapping[swPortIndex].numOfProfiles)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE , ("Port has no allocated profiles"));
+ if (relativeProfile >= p_FmPcdSp->portsMapping[swPortIndex].numOfProfiles)
+ RETURN_ERROR(MAJOR, E_NOT_IN_RANGE , ("Profile id is out of range"));
+
+ return E_OK;
+}
+
+t_Error FmVSPGetAbsoluteProfileId(t_Handle h_Fm,
+ e_FmPortType portType,
+ uint8_t portId,
+ uint16_t relativeProfile,
+ uint16_t *p_AbsoluteId)
+{
+ t_Fm *p_Fm;
+ t_FmSp *p_FmPcdSp;
+ uint8_t swPortIndex=0, hardwarePortId;
+ t_Error err;
+
+ ASSERT_COND(h_Fm);
+ p_Fm = (t_Fm*)h_Fm;
+
+ err = FmVSPCheckRelativeProfile(h_Fm, portType, portId, relativeProfile);
+ if (err != E_OK)
+ return err;
+
+ hardwarePortId = SwPortIdToHwPortId(portType,
+ portId,
+ p_Fm->p_FmStateStruct->revInfo.majorRev,
+ p_Fm->p_FmStateStruct->revInfo.minorRev);
+ ASSERT_COND(hardwarePortId);
+ HW_PORT_ID_TO_SW_PORT_INDX(swPortIndex, hardwarePortId);
+
+ p_FmPcdSp = p_Fm->p_FmSp;
+ ASSERT_COND(p_FmPcdSp);
+
+ *p_AbsoluteId = (uint16_t)(p_FmPcdSp->portsMapping[swPortIndex].profilesBase + relativeProfile);
+
+ return E_OK;
+}
+#endif /* (DPAA_VERSION >= 11) */
+
+static t_Error InitFmDma(t_Fm *p_Fm)
+{
+ t_Error err;
+
+ err = (t_Error)fman_dma_init(p_Fm->p_FmDmaRegs, p_Fm->p_FmDriverParam);
+ if (err != E_OK)
+ return err;
+
+ /* Allocate MURAM for CAM */
+ p_Fm->camBaseAddr = PTR_TO_UINT(FM_MURAM_AllocMem(p_Fm->h_FmMuram,
+ (uint32_t)(p_Fm->p_FmDriverParam->dma_cam_num_of_entries*DMA_CAM_SIZEOF_ENTRY),
+ DMA_CAM_ALIGN));
+ if (!p_Fm->camBaseAddr)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for DMA CAM failed"));
+
+ WRITE_BLOCK(UINT_TO_PTR(p_Fm->camBaseAddr),
+ 0,
+ (uint32_t)(p_Fm->p_FmDriverParam->dma_cam_num_of_entries*DMA_CAM_SIZEOF_ENTRY));
+
+ if (p_Fm->p_FmStateStruct->revInfo.majorRev == 2)
{
- /* update acummulated */
- p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas -= oldVal;
- p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas += numOfOpenDmas;
- /* calculate reg */
- tmpReg = GET_UINT32(p_Fm->p_FmBmiRegs->fmbm_pp[hardwarePortId-1]) & ~(BMI_NUM_OF_DMAS_MASK | BMI_NUM_OF_EXTRA_DMAS_MASK);
- tmpReg |= (uint32_t)(((numOfOpenDmas-1) << BMI_NUM_OF_DMAS_SHIFT) |
- (numOfExtraOpenDmas << BMI_EXTRA_NUM_OF_DMAS_SHIFT));
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_pp[hardwarePortId-1], tmpReg);
+ FM_MURAM_FreeMem(p_Fm->h_FmMuram, UINT_TO_PTR(p_Fm->camBaseAddr));
- /* update total num of DMA's with committed number of open DMAS, and max uncommitted pool. */
- tmpReg = GET_UINT32(p_Fm->p_FmBmiRegs->fmbm_cfg2) & ~BMI_CFG2_DMAS_MASK;
- tmpReg |= (uint32_t)(p_Fm->p_FmStateStruct->accumulatedNumOfOpenDmas + p_Fm->p_FmStateStruct->extraOpenDmasPoolSize - 1) << BMI_CFG2_DMAS_SHIFT;
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_cfg2, tmpReg);
+ p_Fm->camBaseAddr = PTR_TO_UINT(FM_MURAM_AllocMem(p_Fm->h_FmMuram,
+ (uint32_t)(p_Fm->p_FmDriverParam->dma_cam_num_of_entries*72 + 128),
+ 64));
+ if (!p_Fm->camBaseAddr)
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for DMA CAM failed"));
+
+ WRITE_BLOCK(UINT_TO_PTR(p_Fm->camBaseAddr),
+ 0,
+ (uint32_t)(p_Fm->p_FmDriverParam->dma_cam_num_of_entries*72 + 128));
+
+ switch(p_Fm->p_FmDriverParam->dma_cam_num_of_entries)
+ {
+ case (8):
+ WRITE_UINT32(*(uint32_t*)p_Fm->camBaseAddr, 0xff000000);
+ break;
+ case (16):
+ WRITE_UINT32(*(uint32_t*)p_Fm->camBaseAddr, 0xffff0000);
+ break;
+ case (24):
+ WRITE_UINT32(*(uint32_t*)p_Fm->camBaseAddr, 0xffffff00);
+ break;
+ case (32):
+ WRITE_UINT32(*(uint32_t*)p_Fm->camBaseAddr, 0xffffffff);
+ break;
+ default:
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("wrong dma_cam_num_of_entries"));
+ }
}
+ p_Fm->p_FmDriverParam->cam_base_addr =
+ (uint32_t)(XX_VirtToPhys(UINT_TO_PTR(p_Fm->camBaseAddr)) - p_Fm->fmMuramPhysBaseAddr);
+
return E_OK;
}
-#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
-t_Error FmDumpPortRegs (t_Handle h_Fm,uint8_t hardwarePortId)
+static t_Error InitFmFpm(t_Fm *p_Fm)
{
- t_Fm *p_Fm = (t_Fm *)h_Fm;
- t_FmIpcMsg msg;
- t_Error err;
+ return (t_Error)fman_fpm_init(p_Fm->p_FmFpmRegs, p_Fm->p_FmDriverParam);
+}
- DECLARE_DUMP;
+static t_Error InitFmBmi(t_Fm *p_Fm)
+{
+ return (t_Error)fman_bmi_init(p_Fm->p_FmBmiRegs, p_Fm->p_FmDriverParam);
+}
+
+static t_Error InitFmQmi(t_Fm *p_Fm)
+{
+ return (t_Error)fman_qmi_init(p_Fm->p_FmQmiRegs, p_Fm->p_FmDriverParam);
+}
+
+static t_Error InitGuestMode(t_Fm *p_Fm)
+{
+ t_Error err = E_OK;
+ int i;
+ t_FmIpcMsg msg;
+ t_FmIpcReply reply;
+ uint32_t replyLength;
+
+ ASSERT_COND(p_Fm);
+ ASSERT_COND(p_Fm->guestId != NCSW_MASTER_ID);
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ /* build the FM guest partition IPC address */
+ if (Sprint (p_Fm->fmModuleName, "FM_%d_%d",p_Fm->p_FmStateStruct->fmId, p_Fm->guestId) != (p_Fm->guestId<10 ? 6:7))
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
+
+ /* build the FM master partition IPC address */
+ memset(p_Fm->fmIpcHandlerModuleName, 0, (sizeof(char)) * MODULE_NAME_SIZE);
+ if (Sprint (p_Fm->fmIpcHandlerModuleName[0], "FM_%d_%d",p_Fm->p_FmStateStruct->fmId, NCSW_MASTER_ID) != 6)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
+
+ for (i=0;i<e_FM_EV_DUMMY_LAST;i++)
+ p_Fm->intrMng[i].f_Isr = UnimplementedIsr;
+
+ p_Fm->h_IpcSessions[0] = XX_IpcInitSession(p_Fm->fmIpcHandlerModuleName[0], p_Fm->fmModuleName);
+ if (p_Fm->h_IpcSessions[0])
{
+ uint8_t isMasterAlive;
+ t_FmIpcParams ipcParams;
+
+ err = XX_IpcRegisterMsgHandler(p_Fm->fmModuleName, FmGuestHandleIpcMsgCB, p_Fm, FM_IPC_MAX_REPLY_SIZE);
+ if (err)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+
memset(&msg, 0, sizeof(msg));
- msg.msgId = FM_DUMP_PORT_REGS;
- msg.msgBody[0] = hardwarePortId;
+ memset(&reply, 0, sizeof(reply));
+ msg.msgId = FM_MASTER_IS_ALIVE;
+ msg.msgBody[0] = p_Fm->guestId;
+ replyLength = sizeof(uint32_t) + sizeof(uint8_t);
+ do
+ {
+ blockingFlag = TRUE;
+ if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId)+sizeof(p_Fm->guestId),
+ (uint8_t*)&reply,
+ &replyLength,
+ IpcMsgCompletionCB,
+ p_Fm)) != E_OK)
+ REPORT_ERROR(MINOR, err, NO_MSG);
+ while (blockingFlag) ;
+ if (replyLength != (sizeof(uint32_t) + sizeof(uint8_t)))
+ REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
+ isMasterAlive = *(uint8_t*)(reply.replyBody);
+ } while (!isMasterAlive);
+
+ /* read FM parameters and save */
+ memset(&msg, 0, sizeof(msg));
+ memset(&reply, 0, sizeof(reply));
+ msg.msgId = FM_GET_PARAMS;
+ replyLength = sizeof(uint32_t) + sizeof(t_FmIpcParams);
if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
- (uint8_t*)&msg,
- sizeof(msg.msgId)+sizeof(hardwarePortId),
- NULL,
- NULL,
- NULL,
- NULL)) != E_OK)
- RETURN_ERROR(MINOR, err, NO_MSG);
- return E_OK;
+ (uint8_t*)&msg,
+ sizeof(msg.msgId),
+ (uint8_t*)&reply,
+ &replyLength,
+ NULL,
+ NULL)) != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ if (replyLength != (sizeof(uint32_t) + sizeof(t_FmIpcParams)))
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
+ memcpy((uint8_t*)&ipcParams, reply.replyBody, sizeof(t_FmIpcParams));
+
+ p_Fm->p_FmStateStruct->fmClkFreq = ipcParams.fmClkFreq;
+ p_Fm->p_FmStateStruct->fmMacClkFreq = ipcParams.fmMacClkFreq;
+ p_Fm->p_FmStateStruct->revInfo.majorRev = ipcParams.majorRev;
+ p_Fm->p_FmStateStruct->revInfo.minorRev = ipcParams.minorRev;
+ }
+ else
+ {
+ DBG(WARNING, ("FM Guest mode - without IPC"));
+ if (!p_Fm->p_FmStateStruct->fmClkFreq)
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("No fmClkFreq configured for guest without IPC"));
+ if (p_Fm->baseAddr)
+ {
+ fman_get_revision(p_Fm->p_FmFpmRegs,
+ &p_Fm->p_FmStateStruct->revInfo.majorRev,
+ &p_Fm->p_FmStateStruct->revInfo.minorRev);
+
+ }
+ }
+
+#if (DPAA_VERSION >= 11)
+ p_Fm->partVSPBase = AllocVSPsForPartition(p_Fm, p_Fm->partVSPBase, p_Fm->partNumOfVSPs, p_Fm->guestId);
+ if (p_Fm->partVSPBase == (uint8_t)(ILLEGAL_BASE))
+ DBG(WARNING, ("partition VSPs allocation is FAILED"));
+#endif /* (DPAA_VERSION >= 11) */
+
+ /* General FM driver initialization */
+ if (p_Fm->baseAddr)
+ p_Fm->fmMuramPhysBaseAddr =
+ (uint64_t)(XX_VirtToPhys(UINT_TO_PTR(p_Fm->baseAddr + FM_MM_MURAM)));
+
+ XX_Free(p_Fm->p_FmDriverParam);
+ p_Fm->p_FmDriverParam = NULL;
+
+ if ((p_Fm->guestId == NCSW_MASTER_ID) ||
+ (p_Fm->h_IpcSessions[0]))
+ {
+ FM_DisableRamsEcc(p_Fm);
+ FmMuramClear(p_Fm->h_FmMuram);
+ FM_EnableRamsEcc(p_Fm);
}
+ return E_OK;
+}
+
+static __inline__ enum fman_exceptions FmanExceptionTrans(e_FmExceptions exception)
+{
+ switch (exception) {
+ case e_FM_EX_DMA_BUS_ERROR:
+ return E_FMAN_EX_DMA_BUS_ERROR;
+ case e_FM_EX_DMA_READ_ECC:
+ return E_FMAN_EX_DMA_READ_ECC;
+ case e_FM_EX_DMA_SYSTEM_WRITE_ECC:
+ return E_FMAN_EX_DMA_SYSTEM_WRITE_ECC;
+ case e_FM_EX_DMA_FM_WRITE_ECC:
+ return E_FMAN_EX_DMA_FM_WRITE_ECC;
+ case e_FM_EX_FPM_STALL_ON_TASKS:
+ return E_FMAN_EX_FPM_STALL_ON_TASKS;
+ case e_FM_EX_FPM_SINGLE_ECC:
+ return E_FMAN_EX_FPM_SINGLE_ECC;
+ case e_FM_EX_FPM_DOUBLE_ECC:
+ return E_FMAN_EX_FPM_DOUBLE_ECC;
+ case e_FM_EX_QMI_SINGLE_ECC:
+ return E_FMAN_EX_QMI_SINGLE_ECC;
+ case e_FM_EX_QMI_DOUBLE_ECC:
+ return E_FMAN_EX_QMI_DOUBLE_ECC;
+ case e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID:
+ return E_FMAN_EX_QMI_DEQ_FROM_UNKNOWN_PORTID;
+ case e_FM_EX_BMI_LIST_RAM_ECC:
+ return E_FMAN_EX_BMI_LIST_RAM_ECC;
+ case e_FM_EX_BMI_STORAGE_PROFILE_ECC:
+ return E_FMAN_EX_BMI_STORAGE_PROFILE_ECC;
+ case e_FM_EX_BMI_STATISTICS_RAM_ECC:
+ return E_FMAN_EX_BMI_STATISTICS_RAM_ECC;
+ case e_FM_EX_BMI_DISPATCH_RAM_ECC:
+ return E_FMAN_EX_BMI_DISPATCH_RAM_ECC;
+ case e_FM_EX_IRAM_ECC:
+ return E_FMAN_EX_IRAM_ECC;
+ case e_FM_EX_MURAM_ECC:
+ return E_FMAN_EX_MURAM_ECC;
+ default:
+ return E_FMAN_EX_DMA_BUS_ERROR;
+ }
+}
+
+uint8_t SwPortIdToHwPortId(e_FmPortType type, uint8_t relativePortId, uint8_t majorRev, uint8_t minorRev)
+{
+ switch (type)
+ {
+ case (e_FM_PORT_TYPE_OH_OFFLINE_PARSING):
+ case (e_FM_PORT_TYPE_OH_HOST_COMMAND):
+ CHECK_PORT_ID_OH_PORTS(relativePortId);
+ return (uint8_t)(BASE_OH_PORTID + (relativePortId));
+ case (e_FM_PORT_TYPE_RX):
+ CHECK_PORT_ID_1G_RX_PORTS(relativePortId);
+ return (uint8_t)(BASE_1G_RX_PORTID + (relativePortId));
+ case (e_FM_PORT_TYPE_RX_10G):
+ /* The 10G port in T1024 (FMan Version 6.4) is the first port.
+ * This is the reason why the 1G port offset is used.
+ */
+ if (majorRev == 6 && minorRev == 4)
+ {
+ CHECK_PORT_ID_1G_RX_PORTS(relativePortId);
+ return (uint8_t)(BASE_1G_RX_PORTID + (relativePortId));
+ }
+ else
+ {
+ CHECK_PORT_ID_10G_RX_PORTS(relativePortId);
+ return (uint8_t)(BASE_10G_RX_PORTID + (relativePortId));
+ }
+ case (e_FM_PORT_TYPE_TX):
+ CHECK_PORT_ID_1G_TX_PORTS(relativePortId);
+ return (uint8_t)(BASE_1G_TX_PORTID + (relativePortId));
+ case (e_FM_PORT_TYPE_TX_10G):
+ /* The 10G port in T1024 (FMan Version 6.4) is the first port.
+ * This is the reason why the 1G port offset is used.
+ */
+ if (majorRev == 6 && minorRev == 4)
+ {
+ CHECK_PORT_ID_1G_TX_PORTS(relativePortId);
+ return (uint8_t)(BASE_1G_TX_PORTID + (relativePortId));
+ }
+ else
+ {
+ CHECK_PORT_ID_10G_TX_PORTS(relativePortId);
+ return (uint8_t)(BASE_10G_TX_PORTID + (relativePortId));
+ }
+ default:
+ REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal port type"));
+ return 0;
+ }
+}
+
+#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
+t_Error FmDumpPortRegs (t_Handle h_Fm, uint8_t hardwarePortId)
+{
+ t_Fm *p_Fm = (t_Fm *)h_Fm;
+
+ DECLARE_DUMP;
+
+ ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
+
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(((p_Fm->guestId == NCSW_MASTER_ID) ||
+ p_Fm->baseAddr), E_INVALID_OPERATION);
DUMP_TITLE(&p_Fm->p_FmBmiRegs->fmbm_pp[hardwarePortId-1], ("fmbm_pp for port %u", (hardwarePortId)));
DUMP_MEMORY(&p_Fm->p_FmBmiRegs->fmbm_pp[hardwarePortId-1], sizeof(uint32_t));
@@ -2411,8 +3273,14 @@ t_Error FmDumpPortRegs (t_Handle h_Fm,uint8_t hardwarePortId)
DUMP_TITLE(&p_Fm->p_FmBmiRegs->fmbm_pfs[hardwarePortId-1], ("fmbm_pfs for port %u", (hardwarePortId )));
DUMP_MEMORY(&p_Fm->p_FmBmiRegs->fmbm_pfs[hardwarePortId-1], sizeof(uint32_t));
- DUMP_TITLE(&p_Fm->p_FmBmiRegs->fmbm_ppid[hardwarePortId-1], ("bm_ppid for port %u", (hardwarePortId)));
- DUMP_MEMORY(&p_Fm->p_FmBmiRegs->fmbm_ppid[hardwarePortId-1], sizeof(uint32_t));
+ DUMP_TITLE(&p_Fm->p_FmBmiRegs->fmbm_spliodn[hardwarePortId-1], ("fmbm_spliodn for port %u", (hardwarePortId)));
+ DUMP_MEMORY(&p_Fm->p_FmBmiRegs->fmbm_spliodn[hardwarePortId-1], sizeof(uint32_t));
+
+ DUMP_TITLE(&p_Fm->p_FmFpmRegs->fmfp_ps[hardwarePortId], ("fmfp_ps for port %u", (hardwarePortId)));
+ DUMP_MEMORY(&p_Fm->p_FmFpmRegs->fmfp_ps[hardwarePortId], sizeof(uint32_t));
+
+ DUMP_TITLE(&p_Fm->p_FmDmaRegs->fmdmplr[hardwarePortId/2], ("fmdmplr for port %u", (hardwarePortId)));
+ DUMP_MEMORY(&p_Fm->p_FmDmaRegs->fmdmplr[hardwarePortId/2], sizeof(uint32_t));
return E_OK;
}
@@ -2424,9 +3292,9 @@ t_Error FmDumpPortRegs (t_Handle h_Fm,uint8_t hardwarePortId)
/*****************************************************************************/
t_Handle FM_Config(t_FmParams *p_FmParam)
{
- t_Fm *p_Fm;
- uint8_t i;
- uintptr_t baseAddr;
+ t_Fm *p_Fm;
+ uint8_t i;
+ uintptr_t baseAddr;
SANITY_CHECK_RETURN_VALUE(p_FmParam, E_NULL_POINTER, NULL);
SANITY_CHECK_RETURN_VALUE(((p_FmParam->firmware.p_Code && p_FmParam->firmware.size) ||
@@ -2457,11 +3325,11 @@ t_Handle FM_Config(t_FmParams *p_FmParam)
p_Fm->p_FmStateStruct->fmId = p_FmParam->fmId;
p_Fm->guestId = p_FmParam->guestId;
- for(i=0; i<FM_MAX_NUM_OF_HW_PORT_IDS; i++)
+ for (i=0; i<FM_MAX_NUM_OF_HW_PORT_IDS; i++)
p_Fm->p_FmStateStruct->portsTypes[i] = e_FM_PORT_TYPE_DUMMY;
/* Allocate the FM driver's parameters structure */
- p_Fm->p_FmDriverParam = (t_FmDriverParam *)XX_Malloc(sizeof(t_FmDriverParam));
+ p_Fm->p_FmDriverParam = (struct fman_cfg *)XX_Malloc(sizeof(struct fman_cfg));
if (!p_Fm->p_FmDriverParam)
{
XX_Free(p_Fm->p_FmStateStruct);
@@ -2469,36 +3337,42 @@ t_Handle FM_Config(t_FmParams *p_FmParam)
REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM driver parameters"));
return NULL;
}
- memset(p_Fm->p_FmDriverParam, 0, sizeof(t_FmDriverParam));
+ memset(p_Fm->p_FmDriverParam, 0, sizeof(struct fman_cfg));
+
+#if (DPAA_VERSION >= 11)
+ p_Fm->p_FmSp = (t_FmSp *)XX_Malloc(sizeof(t_FmSp));
+ if (!p_Fm->p_FmSp)
+ {
+ XX_Free(p_Fm->p_FmDriverParam);
+ XX_Free(p_Fm->p_FmStateStruct);
+ XX_Free(p_Fm);
+ REPORT_ERROR(MAJOR, E_NO_MEMORY, ("allocation for internal data structure failed"));
+ return NULL;
+ }
+ memset(p_Fm->p_FmSp, 0, sizeof(t_FmSp));
+
+ for (i=0; i<FM_VSP_MAX_NUM_OF_ENTRIES; i++)
+ p_Fm->p_FmSp->profiles[i].profilesMng.ownerId = (uint8_t)ILLEGAL_BASE;
+#endif /* (DPAA_VERSION >= 11) */
/* Initialize FM parameters which will be kept by the driver */
- p_Fm->p_FmStateStruct->fmId = p_FmParam->fmId;
- p_Fm->h_FmMuram = p_FmParam->h_FmMuram;
- p_Fm->h_App = p_FmParam->h_App;
- p_Fm->p_FmStateStruct->fmClkFreq = p_FmParam->fmClkFreq;
- p_Fm->f_Exception = p_FmParam->f_Exception;
- p_Fm->f_BusError = p_FmParam->f_BusError;
- p_Fm->p_FmFpmRegs = (t_FmFpmRegs *)UINT_TO_PTR(baseAddr + FM_MM_FPM);
- p_Fm->p_FmBmiRegs = (t_FmBmiRegs *)UINT_TO_PTR(baseAddr + FM_MM_BMI);
- p_Fm->p_FmQmiRegs = (t_FmQmiRegs *)UINT_TO_PTR(baseAddr + FM_MM_QMI);
- p_Fm->p_FmDmaRegs = (t_FmDmaRegs *)UINT_TO_PTR(baseAddr + FM_MM_DMA);
- p_Fm->baseAddr = baseAddr;
- p_Fm->p_FmStateStruct->irq = p_FmParam->irq;
- p_Fm->p_FmStateStruct->errIrq = p_FmParam->errIrq;
- p_Fm->hcPortInitialized = FALSE;
- p_Fm->independentMode = FALSE;
- p_Fm->p_FmStateStruct->ramsEccEnable = FALSE;
- p_Fm->p_FmStateStruct->totalNumOfTasks = DEFAULT_totalNumOfTasks;
- p_Fm->p_FmStateStruct->totalFifoSize = DEFAULT_totalFifoSize;
- p_Fm->p_FmStateStruct->maxNumOfOpenDmas = DEFAULT_maxNumOfOpenDmas;
- p_Fm->p_FmStateStruct->extraFifoPoolSize = FM_MAX_NUM_OF_RX_PORTS*BMI_FIFO_UNITS;
- p_Fm->p_FmStateStruct->exceptions = DEFAULT_exceptions;
- for(i = 0;i<FM_MAX_NUM_OF_1G_MACS;i++)
- p_Fm->p_FmStateStruct->macMaxFrameLengths1G[i] = DEFAULT_mtu;
-#if defined(FM_MAX_NUM_OF_10G_MACS) && (FM_MAX_NUM_OF_10G_MACS)
- for(i = 0;i<FM_MAX_NUM_OF_10G_MACS;i++)
- p_Fm->p_FmStateStruct->macMaxFrameLengths10G[i] = DEFAULT_mtu;
-#endif /*defined(FM_MAX_NUM_OF_10G_MACS) && (FM_MAX_NUM_OF_10G_MACS)*/
+ p_Fm->p_FmStateStruct->fmId = p_FmParam->fmId;
+ p_Fm->h_FmMuram = p_FmParam->h_FmMuram;
+ p_Fm->h_App = p_FmParam->h_App;
+ p_Fm->p_FmStateStruct->fmClkFreq = p_FmParam->fmClkFreq;
+ p_Fm->p_FmStateStruct->fmMacClkFreq = p_FmParam->fmClkFreq / ((!p_FmParam->fmMacClkRatio)? 2: p_FmParam->fmMacClkRatio);
+ p_Fm->f_Exception = p_FmParam->f_Exception;
+ p_Fm->f_BusError = p_FmParam->f_BusError;
+ p_Fm->p_FmFpmRegs = (struct fman_fpm_regs *)UINT_TO_PTR(baseAddr + FM_MM_FPM);
+ p_Fm->p_FmBmiRegs = (struct fman_bmi_regs *)UINT_TO_PTR(baseAddr + FM_MM_BMI);
+ p_Fm->p_FmQmiRegs = (struct fman_qmi_regs *)UINT_TO_PTR(baseAddr + FM_MM_QMI);
+ p_Fm->p_FmDmaRegs = (struct fman_dma_regs *)UINT_TO_PTR(baseAddr + FM_MM_DMA);
+ p_Fm->p_FmRegs = (struct fman_regs *)UINT_TO_PTR(baseAddr + FM_MM_BMI);
+ p_Fm->baseAddr = baseAddr;
+ p_Fm->p_FmStateStruct->irq = p_FmParam->irq;
+ p_Fm->p_FmStateStruct->errIrq = p_FmParam->errIrq;
+ p_Fm->hcPortInitialized = FALSE;
+ p_Fm->independentMode = FALSE;
p_Fm->h_Spinlock = XX_InitSpinlock();
if (!p_Fm->h_Spinlock)
@@ -2506,65 +3380,38 @@ t_Handle FM_Config(t_FmParams *p_FmParam)
XX_Free(p_Fm->p_FmDriverParam);
XX_Free(p_Fm->p_FmStateStruct);
XX_Free(p_Fm);
- REPORT_ERROR(MAJOR, E_INVALID_STATE, ("cant allocate spinlock!"));
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("can't allocate spinlock!"));
return NULL;
}
-#ifdef FM_PARTITION_ARRAY
- /* Initialize FM driver parameters parameters (for initialization phase only) */
- memcpy(p_Fm->p_FmDriverParam->liodnBasePerPort, p_FmParam->liodnBasePerPort, FM_SIZE_OF_LIODN_TABLE*sizeof(uint16_t));
-#endif /* FM_PARTITION_ARRAY */
-
- /*p_Fm->p_FmDriverParam->numOfPartitions = p_FmParam->numOfPartitions; */
- p_Fm->p_FmDriverParam->enCounters = FALSE;
-
- p_Fm->p_FmDriverParam->resetOnInit = DEFAULT_resetOnInit;
-
- p_Fm->p_FmDriverParam->thresholds.dispLimit = DEFAULT_dispLimit;
- p_Fm->p_FmDriverParam->thresholds.prsDispTh = DEFAULT_prsDispTh;
- p_Fm->p_FmDriverParam->thresholds.plcrDispTh = DEFAULT_plcrDispTh;
- p_Fm->p_FmDriverParam->thresholds.kgDispTh = DEFAULT_kgDispTh;
- p_Fm->p_FmDriverParam->thresholds.bmiDispTh = DEFAULT_bmiDispTh;
- p_Fm->p_FmDriverParam->thresholds.qmiEnqDispTh = DEFAULT_qmiEnqDispTh;
- p_Fm->p_FmDriverParam->thresholds.qmiDeqDispTh = DEFAULT_qmiDeqDispTh;
- p_Fm->p_FmDriverParam->thresholds.fmCtl1DispTh = DEFAULT_fmCtl1DispTh;
- p_Fm->p_FmDriverParam->thresholds.fmCtl2DispTh = DEFAULT_fmCtl2DispTh;
-
- p_Fm->p_FmDriverParam->dmaStopOnBusError = DEFAULT_dmaStopOnBusError;
-
- p_Fm->p_FmDriverParam->dmaCacheOverride = DEFAULT_cacheOverride;
- p_Fm->p_FmDriverParam->dmaAidMode = DEFAULT_aidMode;
- p_Fm->p_FmDriverParam->dmaAidOverride = DEFAULT_aidOverride;
- p_Fm->p_FmDriverParam->dmaAxiDbgNumOfBeats = DEFAULT_axiDbgNumOfBeats;
- p_Fm->p_FmDriverParam->dmaCamNumOfEntries = DEFAULT_dmaCamNumOfEntries;
- p_Fm->p_FmDriverParam->dmaWatchdog = DEFAULT_dmaWatchdog;
-
- p_Fm->p_FmDriverParam->dmaCommQThresholds.clearEmergency = DEFAULT_dmaCommQLow;
- p_Fm->p_FmDriverParam->dmaCommQThresholds.assertEmergency = DEFAULT_dmaCommQHigh;
- p_Fm->p_FmDriverParam->dmaReadBufThresholds.clearEmergency = DEFAULT_dmaReadIntBufLow;
- p_Fm->p_FmDriverParam->dmaReadBufThresholds.assertEmergency = DEFAULT_dmaReadIntBufHigh;
- p_Fm->p_FmDriverParam->dmaWriteBufThresholds.clearEmergency = DEFAULT_dmaWriteIntBufLow;
- p_Fm->p_FmDriverParam->dmaWriteBufThresholds.assertEmergency = DEFAULT_dmaWriteIntBufHigh;
- p_Fm->p_FmDriverParam->dmaSosEmergency = DEFAULT_dmaSosEmergency;
-
- p_Fm->p_FmDriverParam->dmaDbgCntMode = DEFAULT_dmaDbgCntMode;
-
- p_Fm->p_FmDriverParam->dmaEnEmergency = FALSE;
- p_Fm->p_FmDriverParam->dmaEnEmergencySmoother = FALSE;
- p_Fm->p_FmDriverParam->catastrophicErr = DEFAULT_catastrophicErr;
- p_Fm->p_FmDriverParam->dmaErr = DEFAULT_dmaErr;
- p_Fm->p_FmDriverParam->haltOnExternalActivation = DEFAULT_haltOnExternalActivation;
- p_Fm->p_FmDriverParam->haltOnUnrecoverableEccError = DEFAULT_haltOnUnrecoverableEccError;
- p_Fm->p_FmDriverParam->enIramTestMode = FALSE;
- p_Fm->p_FmDriverParam->enMuramTestMode = FALSE;
- p_Fm->p_FmDriverParam->externalEccRamsEnable = DEFAULT_externalEccRamsEnable;
-
- p_Fm->p_FmDriverParam->fwVerify = DEFAULT_VerifyUcode;
- p_Fm->p_FmDriverParam->firmware.size = p_FmParam->firmware.size;
- if (p_Fm->p_FmDriverParam->firmware.size)
+#if (DPAA_VERSION >= 11)
+ p_Fm->partVSPBase = p_FmParam->partVSPBase;
+ p_Fm->partNumOfVSPs = p_FmParam->partNumOfVSPs;
+ p_Fm->vspBaseAddr = p_FmParam->vspBaseAddr;
+#endif /* (DPAA_VERSION >= 11) */
+
+ fman_defconfig(p_Fm->p_FmDriverParam,
+ !!(p_Fm->guestId == NCSW_MASTER_ID));
+/* overide macros dependent parameters */
+#ifdef FM_PEDANTIC_DMA
+ p_Fm->p_FmDriverParam->pedantic_dma = TRUE;
+ p_Fm->p_FmDriverParam->dma_aid_override = TRUE;
+#endif /* FM_PEDANTIC_DMA */
+#ifndef FM_QMI_NO_DEQ_OPTIONS_SUPPORT
+ p_Fm->p_FmDriverParam->qmi_deq_option_support = TRUE;
+#endif /* !FM_QMI_NO_DEQ_OPTIONS_SUPPORT */
+
+ p_Fm->p_FmStateStruct->ramsEccEnable = FALSE;
+ p_Fm->p_FmStateStruct->extraFifoPoolSize = 0;
+ p_Fm->p_FmStateStruct->exceptions = DEFAULT_exceptions;
+ p_Fm->resetOnInit = DEFAULT_resetOnInit;
+ p_Fm->f_ResetOnInitOverride = DEFAULT_resetOnInitOverrideCallback;
+ p_Fm->fwVerify = DEFAULT_VerifyUcode;
+ p_Fm->firmware.size = p_FmParam->firmware.size;
+ if (p_Fm->firmware.size)
{
- p_Fm->p_FmDriverParam->firmware.p_Code = (uint32_t *)XX_Malloc(p_Fm->p_FmDriverParam->firmware.size);
- if (!p_Fm->p_FmDriverParam->firmware.p_Code)
+ p_Fm->firmware.p_Code = (uint32_t *)XX_Malloc(p_Fm->firmware.size);
+ if (!p_Fm->firmware.p_Code)
{
XX_FreeSpinlock(p_Fm->h_Spinlock);
XX_Free(p_Fm->p_FmStateStruct);
@@ -2573,10 +3420,51 @@ t_Handle FM_Config(t_FmParams *p_FmParam)
REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM firmware code"));
return NULL;
}
- memcpy(p_Fm->p_FmDriverParam->firmware.p_Code, p_FmParam->firmware.p_Code, p_Fm->p_FmDriverParam->firmware.size);
+ memcpy(p_Fm->firmware.p_Code, p_FmParam->firmware.p_Code ,p_Fm->firmware.size);
}
- return p_Fm;
+ if (p_Fm->guestId != NCSW_MASTER_ID)
+ return p_Fm;
+
+ /* read revision */
+ /* Chip dependent, will be configured in Init */
+ fman_get_revision(p_Fm->p_FmFpmRegs,
+ &p_Fm->p_FmStateStruct->revInfo.majorRev,
+ &p_Fm->p_FmStateStruct->revInfo.minorRev);
+
+#ifdef FM_AID_MODE_NO_TNUM_SW005
+ if (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6)
+ p_Fm->p_FmDriverParam->dma_aid_mode = e_FM_DMA_AID_OUT_PORT_ID;
+#endif /* FM_AID_MODE_NO_TNUM_SW005 */
+#ifndef FM_QMI_NO_DEQ_OPTIONS_SUPPORT
+ if (p_Fm->p_FmStateStruct->revInfo.majorRev != 4)
+ p_Fm->p_FmDriverParam->qmi_def_tnums_thresh = QMI_DEF_TNUMS_THRESH;
+#endif /* FM_QMI_NO_DEQ_OPTIONS_SUPPORT */
+
+ p_Fm->p_FmStateStruct->totalFifoSize = 0;
+ p_Fm->p_FmStateStruct->totalNumOfTasks =
+ DEFAULT_totalNumOfTasks(p_Fm->p_FmStateStruct->revInfo.majorRev,
+ p_Fm->p_FmStateStruct->revInfo.minorRev);
+
+#ifdef FM_HAS_TOTAL_DMAS
+ p_Fm->p_FmStateStruct->maxNumOfOpenDmas = BMI_MAX_NUM_OF_DMAS;
+#endif /* FM_HAS_TOTAL_DMAS */
+#if (DPAA_VERSION < 11)
+ p_Fm->p_FmDriverParam->dma_comm_qtsh_clr_emer = DEFAULT_dmaCommQLow;
+ p_Fm->p_FmDriverParam->dma_comm_qtsh_asrt_emer = DEFAULT_dmaCommQHigh;
+ p_Fm->p_FmDriverParam->dma_cam_num_of_entries = DEFAULT_dmaCamNumOfEntries;
+ p_Fm->p_FmDriverParam->dma_read_buf_tsh_clr_emer = DEFAULT_dmaReadIntBufLow;
+ p_Fm->p_FmDriverParam->dma_read_buf_tsh_asrt_emer = DEFAULT_dmaReadIntBufHigh;
+ p_Fm->p_FmDriverParam->dma_write_buf_tsh_clr_emer = DEFAULT_dmaWriteIntBufLow;
+ p_Fm->p_FmDriverParam->dma_write_buf_tsh_asrt_emer = DEFAULT_dmaWriteIntBufHigh;
+ p_Fm->p_FmDriverParam->dma_axi_dbg_num_of_beats = DEFAULT_axiDbgNumOfBeats;
+#endif /* (DPAA_VERSION < 11) */
+#ifdef FM_NO_TNUM_AGING
+ p_Fm->p_FmDriverParam->tnum_aging_period = 0;
+#endif
+ p_Fm->tnumAgingPeriod = p_Fm->p_FmDriverParam->tnum_aging_period;
+
+ return p_Fm;
}
/**************************************************************************//**
@@ -2591,195 +3479,100 @@ t_Handle FM_Config(t_FmParams *p_FmParam)
t_Error FM_Init(t_Handle h_Fm)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- t_FmDriverParam *p_FmDriverParam = NULL;
+ struct fman_cfg *p_FmDriverParam = NULL;
t_Error err = E_OK;
- uint32_t tmpReg, cfgReg = 0;
int i;
- uint16_t periodInFmClocks;
- uint8_t remainder;
t_FmRevisionInfo revInfo;
+ struct fman_rg fman_rg;
- SANITY_CHECK_RETURN_ERROR(h_Fm, E_INVALID_HANDLE);
-
- if(p_Fm->guestId != NCSW_MASTER_ID)
- {
- uint8_t isMasterAlive;
- t_FmIpcMsg msg;
- t_FmIpcReply reply;
- uint32_t replyLength;
-
- /* build the FM guest partition IPC address */
- if(Sprint (p_Fm->fmModuleName, "FM_%d_%d",p_Fm->p_FmStateStruct->fmId, p_Fm->guestId) != (p_Fm->guestId<10 ? 6:7))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
-
- /* build the FM master partition IPC address */
- memset(p_Fm->fmIpcHandlerModuleName, 0, (sizeof(char)) * MODULE_NAME_SIZE);
- if(Sprint (p_Fm->fmIpcHandlerModuleName[0], "FM_%d_%d",p_Fm->p_FmStateStruct->fmId, NCSW_MASTER_ID) != 6)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
+ SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
- for(i=0;i<e_FM_EV_DUMMY_LAST;i++)
- p_Fm->intrMng[i].f_Isr = UnimplementedIsr;
+ fman_rg.bmi_rg = p_Fm->p_FmBmiRegs;
+ fman_rg.qmi_rg = p_Fm->p_FmQmiRegs;
+ fman_rg.fpm_rg = p_Fm->p_FmFpmRegs;
+ fman_rg.dma_rg = p_Fm->p_FmDmaRegs;
- p_Fm->h_IpcSessions[0] = XX_IpcInitSession(p_Fm->fmIpcHandlerModuleName[0], p_Fm->fmModuleName);
- if (p_Fm->h_IpcSessions[0])
- {
- err = XX_IpcRegisterMsgHandler(p_Fm->fmModuleName, FmGuestHandleIpcMsgCB, p_Fm, FM_IPC_MAX_REPLY_SIZE);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
-
- memset(&msg, 0, sizeof(msg));
- memset(&reply, 0, sizeof(reply));
- msg.msgId = FM_MASTER_IS_ALIVE;
- msg.msgBody[0] = p_Fm->guestId;
- replyLength = sizeof(uint32_t) + sizeof(uint8_t);
- do
- {
- blockingFlag = TRUE;
- if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
- (uint8_t*)&msg,
- sizeof(msg.msgId)+sizeof(p_Fm->guestId),
- (uint8_t*)&reply,
- &replyLength,
- IpcMsgCompletionCB,
- h_Fm)) != E_OK)
- REPORT_ERROR(MINOR, err, NO_MSG);
- while(blockingFlag) ;
- if(replyLength != (sizeof(uint32_t) + sizeof(uint8_t)))
- REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
- isMasterAlive = *(uint8_t*)(reply.replyBody);
- } while (!isMasterAlive);
-
- memset(&msg, 0, sizeof(msg));
- memset(&reply, 0, sizeof(reply));
- msg.msgId = FM_GET_CLK_FREQ;
- replyLength = sizeof(uint32_t) + sizeof(p_Fm->p_FmStateStruct->fmClkFreq);
- if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
- (uint8_t*)&msg,
- sizeof(msg.msgId),
- (uint8_t*)&reply,
- &replyLength,
- NULL,
- NULL)) != E_OK)
- RETURN_ERROR(MAJOR, err, NO_MSG);
- if(replyLength != (sizeof(uint32_t) + sizeof(p_Fm->p_FmStateStruct->fmClkFreq)))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
- memcpy((uint8_t*)&p_Fm->p_FmStateStruct->fmClkFreq, reply.replyBody, sizeof(uint16_t));
- }
- else
- {
- DBG(WARNING, ("FM Guest mode - without IPC"));
- if(!p_Fm->p_FmStateStruct->fmClkFreq )
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("No fmClkFreq configured for guest without IPC"));
- if(!p_Fm->baseAddr)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("No baseAddr configured for guest without IPC"));
- }
+ p_Fm->p_FmStateStruct->count1MicroBit = FM_TIMESTAMP_1_USEC_BIT;
+ p_Fm->p_FmDriverParam->num_of_fman_ctrl_evnt_regs = FM_NUM_OF_FMAN_CTRL_EVENT_REGS;
- XX_Free(p_Fm->p_FmDriverParam);
- p_Fm->p_FmDriverParam = NULL;
+ if (p_Fm->guestId != NCSW_MASTER_ID)
+ return InitGuestMode(p_Fm);
- if ((p_Fm->guestId == NCSW_MASTER_ID) ||
- (p_Fm->h_IpcSessions[0]))
- {
- FM_DisableRamsEcc(p_Fm);
- FmMuramClear(p_Fm->h_FmMuram);
- FM_EnableRamsEcc(p_Fm);
- }
+ /* if user didn't configured totalFifoSize - (totalFifoSize=0) we configure default
+ * according to chip. otherwise, we use user's configuration.
+ */
+ if (p_Fm->p_FmStateStruct->totalFifoSize == 0)
+ p_Fm->p_FmStateStruct->totalFifoSize = DEFAULT_totalFifoSize(p_Fm->p_FmStateStruct->revInfo.majorRev,
+ p_Fm->p_FmStateStruct->revInfo.minorRev);
- return E_OK;
- }
+ CHECK_INIT_PARAMETERS(p_Fm, CheckFmParameters);
- SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ p_FmDriverParam = p_Fm->p_FmDriverParam;
FM_GetRevision(p_Fm, &revInfo);
+ /* clear revision-dependent non existing exception */
#ifdef FM_NO_DISPATCH_RAM_ECC
- if (revInfo.majorRev != 4)
+ if ((revInfo.majorRev != 4) &&
+ (revInfo.majorRev < 6))
p_Fm->p_FmStateStruct->exceptions &= ~FM_EX_BMI_DISPATCH_RAM_ECC;
#endif /* FM_NO_DISPATCH_RAM_ECC */
-#ifdef FM_RAM_LIST_ERR_IRQ_ERRATA_FMAN8
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- p_Fm->p_FmStateStruct->exceptions &= ~FM_EX_BMI_LIST_RAM_ECC;
-#endif /* FM_RAM_LIST_ERR_IRQ_ERRATA_FMAN8 */
-
-#ifdef FM_BMI_PIPELINE_ERR_IRQ_ERRATA_FMAN9
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- p_Fm->p_FmStateStruct->exceptions &= ~FM_EX_BMI_PIPELINE_ECC;
-#endif /* FM_BMI_PIPELINE_ERR_IRQ_ERRATA_FMAN9 */
-
#ifdef FM_QMI_NO_ECC_EXCEPTIONS
if (revInfo.majorRev == 4)
- p_Fm->p_FmStateStruct->exceptions &= ~(FM_EX_QMI_SINGLE_ECC | FM_EX_QMI_DOUBLE_ECC);
+ p_Fm->p_FmStateStruct->exceptions &= ~(FM_EX_QMI_SINGLE_ECC | FM_EX_QMI_DOUBLE_ECC);
#endif /* FM_QMI_NO_ECC_EXCEPTIONS */
- CHECK_INIT_PARAMETERS(p_Fm, CheckFmParameters);
-
- p_FmDriverParam = p_Fm->p_FmDriverParam;
+#ifdef FM_QMI_NO_SINGLE_ECC_EXCEPTION
+ if (revInfo.majorRev >= 6)
+ p_Fm->p_FmStateStruct->exceptions &= ~FM_EX_QMI_SINGLE_ECC;
+#endif /* FM_QMI_NO_SINGLE_ECC_EXCEPTION */
FmMuramClear(p_Fm->h_FmMuram);
-#ifdef FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173
- if (p_FmDriverParam->resetOnInit)
- {
- t_FMIramRegs *p_Iram = (t_FMIramRegs *)UINT_TO_PTR(p_Fm->baseAddr + FM_MM_IMEM);
- uint32_t debug_reg;
-
- /* write to IRAM first location the debug instruction */
- WRITE_UINT32(p_Iram->iadd, 0);
- while (GET_UINT32(p_Iram->iadd) != 0) ;
- WRITE_UINT32(p_Iram->idata, FM_UCODE_DEBUG_INSTRUCTION);
+ /* clear CPG */
+ IOMemSet32(UINT_TO_PTR(p_Fm->baseAddr + FM_MM_CGP), 0, FM_PORT_NUM_OF_CONGESTION_GRPS);
- WRITE_UINT32(p_Iram->iadd, 0);
- while (GET_UINT32(p_Iram->iadd) != 0) ;
- while (GET_UINT32(p_Iram->idata) != FM_UCODE_DEBUG_INSTRUCTION) ;
+ /* add to the default exceptions the user's definitions */
+ p_Fm->p_FmStateStruct->exceptions |= p_Fm->userSetExceptions;
- /* Enable patch from IRAM */
- WRITE_UINT32(p_Iram->iready, IRAM_READY);
- XX_UDelay(100);
+ /* Reset the FM if required */
+ if (p_Fm->resetOnInit)
+ {
+#ifdef FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173
+ if ((err = FwNotResetErratumBugzilla6173WA(p_Fm)) != E_OK)
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+#else /* not FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173 */
- /* reset FMAN */
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fmrstc, FPM_RSTC_FM_RESET);
- XX_UDelay(100);
+ if (p_Fm->f_ResetOnInitOverride)
+ {
+ /* Perform user specific FMan reset */
+ p_Fm->f_ResetOnInitOverride(h_Fm);
+ }
+ else
+ {
+ /* Perform FMan reset */
+ FmReset(h_Fm);
+ }
- /* verify breakpoint debug status register */
- debug_reg = GET_UINT32(*(uint32_t *)UINT_TO_PTR(p_Fm->baseAddr + FM_DEBUG_STATUS_REGISTER_OFFSET));
-#ifndef NCSW_LINUX
- if(!debug_reg)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Invalid debug status register value = 0"));
-#else
- if(!debug_reg)
- DBG(INFO,("Invalid debug status register value = 0"));
-#endif
- /*************************************/
- /* Load FMan-Controller code to Iram */
- /*************************************/
- if (ClearIRam(p_Fm) != E_OK)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
- if (p_Fm->p_FmDriverParam->firmware.p_Code &&
- (LoadFmanCtrlCode(p_Fm) != E_OK))
- RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
- XX_UDelay(100);
-
- /* reset FMAN again to start the microcode */
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fmrstc, FPM_RSTC_FM_RESET);
- XX_UDelay(1000);
+ if (fman_is_qmi_halt_not_busy_state(p_Fm->p_FmQmiRegs))
+ {
+ fman_resume(p_Fm->p_FmFpmRegs);
+ XX_UDelay(100);
+ }
+#endif /* not FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173 */
}
- else
+
+#ifdef FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173
+ if (!p_Fm->resetOnInit) /* Skip operations done in errata workaround */
{
#endif /* FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173 */
- if(p_FmDriverParam->resetOnInit)
- {
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fmrstc, FPM_RSTC_FM_RESET);
- XX_UDelay(100);
- }
+ /* Load FMan-Controller code to IRAM */
- /*************************************/
- /* Load FMan-Controller code to Iram */
- /*************************************/
- if (ClearIRam(p_Fm) != E_OK)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
- if (p_Fm->p_FmDriverParam->firmware.p_Code &&
- (LoadFmanCtrlCode(p_Fm) != E_OK))
+ ClearIRam(p_Fm);
+
+ if (p_Fm->firmware.p_Code && (LoadFmanCtrlCode(p_Fm) != E_OK))
RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
#ifdef FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173
}
@@ -2794,172 +3587,42 @@ t_Error FM_Init(t_Handle h_Fm)
WRITE_BLOCK(UINT_TO_PTR(p_Fm->resAddr), 0, 256);
#endif /* FM_CAPWAP_SUPPORT */
+#if (DPAA_VERSION >= 11)
+ p_Fm->partVSPBase = AllocVSPsForPartition(h_Fm, p_Fm->partVSPBase, p_Fm->partNumOfVSPs, p_Fm->guestId);
+ if (p_Fm->partVSPBase == (uint8_t)(ILLEGAL_BASE))
+ DBG(WARNING, ("partition VSPs allocation is FAILED"));
+#endif /* (DPAA_VERSION >= 11) */
+
/* General FM driver initialization */
- p_Fm->fmMuramPhysBaseAddr = (uint64_t)(XX_VirtToPhys(UINT_TO_PTR(p_Fm->baseAddr + FM_MM_MURAM)));
- for(i=0;i<e_FM_EV_DUMMY_LAST;i++)
+ p_Fm->fmMuramPhysBaseAddr =
+ (uint64_t)(XX_VirtToPhys(UINT_TO_PTR(p_Fm->baseAddr + FM_MM_MURAM)));
+
+ for (i=0;i<e_FM_EV_DUMMY_LAST;i++)
p_Fm->intrMng[i].f_Isr = UnimplementedIsr;
- for(i=0;i<FM_NUM_OF_FMAN_CTRL_EVENT_REGS;i++)
+ for (i=0;i<FM_NUM_OF_FMAN_CTRL_EVENT_REGS;i++)
p_Fm->fmanCtrlIntr[i].f_Isr = UnimplementedFmanCtrlIsr;
+ p_FmDriverParam->exceptions = p_Fm->p_FmStateStruct->exceptions;
+
/**********************/
/* Init DMA Registers */
/**********************/
- /* clear status reg events */
- tmpReg = (DMA_STATUS_BUS_ERR | DMA_STATUS_READ_ECC | DMA_STATUS_SYSTEM_WRITE_ECC | DMA_STATUS_FM_WRITE_ECC);
- /*tmpReg |= (DMA_STATUS_SYSTEM_DPEXT_ECC | DMA_STATUS_FM_DPEXT_ECC | DMA_STATUS_SYSTEM_DPDAT_ECC | DMA_STATUS_FM_DPDAT_ECC | DMA_STATUS_FM_SPDAT_ECC);*/
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmsr, GET_UINT32(p_Fm->p_FmDmaRegs->fmdmsr) | tmpReg);
-
- /* configure mode register */
- tmpReg = 0;
- tmpReg |= p_FmDriverParam->dmaCacheOverride << DMA_MODE_CACHE_OR_SHIFT;
- if(p_FmDriverParam->dmaAidOverride)
- tmpReg |= DMA_MODE_AID_OR;
- if (p_Fm->p_FmStateStruct->exceptions & FM_EX_DMA_BUS_ERROR)
- tmpReg |= DMA_MODE_BER;
- if ((p_Fm->p_FmStateStruct->exceptions & FM_EX_DMA_SYSTEM_WRITE_ECC) | (p_Fm->p_FmStateStruct->exceptions & FM_EX_DMA_READ_ECC) | (p_Fm->p_FmStateStruct->exceptions & FM_EX_DMA_FM_WRITE_ECC))
- tmpReg |= DMA_MODE_ECC;
- if(p_FmDriverParam->dmaStopOnBusError)
- tmpReg |= DMA_MODE_SBER;
- tmpReg |= (uint32_t)(p_FmDriverParam->dmaAxiDbgNumOfBeats - 1) << DMA_MODE_AXI_DBG_SHIFT;
- if (p_FmDriverParam->dmaEnEmergency)
+ err = InitFmDma(p_Fm);
+ if (err != E_OK)
{
- tmpReg |= p_FmDriverParam->dmaEmergency.emergencyBusSelect;
- tmpReg |= p_FmDriverParam->dmaEmergency.emergencyLevel << DMA_MODE_EMERGENCY_LEVEL_SHIFT;
- if(p_FmDriverParam->dmaEnEmergencySmoother)
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmemsr, p_FmDriverParam->dmaEmergencySwitchCounter);
- }
- tmpReg |= ((p_FmDriverParam->dmaCamNumOfEntries/DMA_CAM_UNITS) - 1) << DMA_MODE_CEN_SHIFT;
-
- tmpReg |= DMA_MODE_SECURE_PROT;
- tmpReg |= p_FmDriverParam->dmaDbgCntMode << DMA_MODE_DBG_SHIFT;
- tmpReg |= p_FmDriverParam->dmaAidMode << DMA_MODE_AID_MODE_SHIFT;
-
-#ifdef FM_PEDANTIC_DMA
- tmpReg |= DMA_MODE_EMERGENCY_READ;
-#endif /* FM_PEDANTIC_DMA */
-
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmmr, tmpReg);
-
- /* configure thresholds register */
- tmpReg = ((uint32_t)p_FmDriverParam->dmaCommQThresholds.assertEmergency << DMA_THRESH_COMMQ_SHIFT) |
- ((uint32_t)p_FmDriverParam->dmaReadBufThresholds.assertEmergency << DMA_THRESH_READ_INT_BUF_SHIFT) |
- ((uint32_t)p_FmDriverParam->dmaWriteBufThresholds.assertEmergency);
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmtr, tmpReg);
-
- /* configure hysteresis register */
- tmpReg = ((uint32_t)p_FmDriverParam->dmaCommQThresholds.clearEmergency << DMA_THRESH_COMMQ_SHIFT) |
- ((uint32_t)p_FmDriverParam->dmaReadBufThresholds.clearEmergency << DMA_THRESH_READ_INT_BUF_SHIFT) |
- ((uint32_t)p_FmDriverParam->dmaWriteBufThresholds.clearEmergency);
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmhy, tmpReg);
-
- /* configure emergency threshold */
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmsetr, p_FmDriverParam->dmaSosEmergency);
-
- /* configure Watchdog */
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmwcr, USEC_TO_CLK(p_FmDriverParam->dmaWatchdog, p_Fm->p_FmStateStruct->fmClkFreq));
-
- /* Allocate MURAM for CAM */
- p_Fm->camBaseAddr = PTR_TO_UINT(FM_MURAM_AllocMem(p_Fm->h_FmMuram,
- (uint32_t)(p_FmDriverParam->dmaCamNumOfEntries*DMA_CAM_SIZEOF_ENTRY),
- DMA_CAM_ALIGN));
- if (!p_Fm->camBaseAddr )
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for DMA CAM failed"));
-
- WRITE_BLOCK(UINT_TO_PTR(p_Fm->camBaseAddr), 0, (uint32_t)(p_FmDriverParam->dmaCamNumOfEntries*DMA_CAM_SIZEOF_ENTRY));
-
- /* VirtToPhys */
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmebcr,
- (uint32_t)(XX_VirtToPhys(UINT_TO_PTR(p_Fm->camBaseAddr)) - p_Fm->fmMuramPhysBaseAddr));
-
-#ifdef FM_PARTITION_ARRAY
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- /* liodn-partitions */
- for (i=0 ; i<FM_SIZE_OF_LIODN_TABLE ; i+=2)
- {
- tmpReg = (((uint32_t)p_FmDriverParam->liodnBasePerPort[i] << DMA_LIODN_SHIFT) |
- (uint32_t)p_FmDriverParam->liodnBasePerPort[i+1]);
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmplr[i/2], tmpReg);
- }
+ FreeInitResources(p_Fm);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
-#endif /* FM_PARTITION_ARRAY */
/**********************/
/* Init FPM Registers */
/**********************/
- tmpReg = (uint32_t)(p_FmDriverParam->thresholds.dispLimit << FPM_DISP_LIMIT_SHIFT);
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmflc, tmpReg);
-
- tmpReg = (((uint32_t)p_FmDriverParam->thresholds.prsDispTh << FPM_THR1_PRS_SHIFT) |
- ((uint32_t)p_FmDriverParam->thresholds.kgDispTh << FPM_THR1_KG_SHIFT) |
- ((uint32_t)p_FmDriverParam->thresholds.plcrDispTh << FPM_THR1_PLCR_SHIFT) |
- ((uint32_t)p_FmDriverParam->thresholds.bmiDispTh << FPM_THR1_BMI_SHIFT));
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmdis1, tmpReg);
-
- tmpReg = (((uint32_t)p_FmDriverParam->thresholds.qmiEnqDispTh << FPM_THR2_QMI_ENQ_SHIFT) |
- ((uint32_t)p_FmDriverParam->thresholds.qmiDeqDispTh << FPM_THR2_QMI_DEQ_SHIFT) |
- ((uint32_t)p_FmDriverParam->thresholds.fmCtl1DispTh << FPM_THR2_FM_CTL1_SHIFT) |
- ((uint32_t)p_FmDriverParam->thresholds.fmCtl2DispTh << FPM_THR2_FM_CTL2_SHIFT));
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmdis2, tmpReg);
-
- /* define exceptions and error behavior */
- tmpReg = 0;
- /* Clear events */
- tmpReg |= (FPM_EV_MASK_STALL | FPM_EV_MASK_DOUBLE_ECC | FPM_EV_MASK_SINGLE_ECC);
- /* enable interrupts */
- if(p_Fm->p_FmStateStruct->exceptions & FM_EX_FPM_STALL_ON_TASKS)
- tmpReg |= FPM_EV_MASK_STALL_EN;
- if(p_Fm->p_FmStateStruct->exceptions & FM_EX_FPM_SINGLE_ECC)
- tmpReg |= FPM_EV_MASK_SINGLE_ECC_EN;
- if(p_Fm->p_FmStateStruct->exceptions & FM_EX_FPM_DOUBLE_ECC)
- tmpReg |= FPM_EV_MASK_DOUBLE_ECC_EN;
- tmpReg |= (p_Fm->p_FmDriverParam->catastrophicErr << FPM_EV_MASK_CAT_ERR_SHIFT);
- tmpReg |= (p_Fm->p_FmDriverParam->dmaErr << FPM_EV_MASK_DMA_ERR_SHIFT);
- if(!p_Fm->p_FmDriverParam->haltOnExternalActivation)
- tmpReg |= FPM_EV_MASK_EXTERNAL_HALT;
- if(!p_Fm->p_FmDriverParam->haltOnUnrecoverableEccError)
- tmpReg |= FPM_EV_MASK_ECC_ERR_HALT;
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmem, tmpReg);
-
- /* clear all fmCtls event registers */
- for(i=0;i<FM_NUM_OF_FMAN_CTRL_EVENT_REGS;i++)
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmcev[i], 0xFFFFFFFF);
-
- /* RAM ECC - enable and clear events*/
- /* first we need to clear all parser memory, as it is uninitialized and
- may cause ECC errors */
- tmpReg = 0;
- /* event bits */
- tmpReg = (FPM_RAM_CTL_MURAM_ECC | FPM_RAM_CTL_IRAM_ECC);
- /* Rams enable is not effected by the RCR bit, but by a COP configuration */
- if(p_Fm->p_FmDriverParam->externalEccRamsEnable)
- tmpReg |= FPM_RAM_CTL_RAMS_ECC_EN_SRC_SEL;
-
- /* enable test mode */
- if(p_FmDriverParam->enMuramTestMode)
- tmpReg |= FPM_RAM_CTL_MURAM_TEST_ECC;
- if(p_FmDriverParam->enIramTestMode)
- tmpReg |= FPM_RAM_CTL_IRAM_TEST_ECC;
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fmrcr, tmpReg);
-
- tmpReg = 0;
- if(p_Fm->p_FmStateStruct->exceptions & FM_EX_IRAM_ECC)
- {
- tmpReg |= FPM_IRAM_ECC_ERR_EX_EN;
- FmEnableRamsEcc(p_Fm);
- }
- if(p_Fm->p_FmStateStruct->exceptions & FM_EX_NURAM_ECC)
+ err = InitFmFpm(p_Fm);
+ if (err != E_OK)
{
- tmpReg |= FPM_MURAM_ECC_ERR_EX_EN;
- FmEnableRamsEcc(p_Fm);
+ FreeInitResources(p_Fm);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
}
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fmrie, tmpReg);
-
- /**********************/
- /* Init BMI Registers */
- /**********************/
/* define common resources */
/* allocate MURAM for FIFO according to total size */
@@ -2969,82 +3632,49 @@ t_Error FM_Init(t_Handle h_Fm)
if (!p_Fm->fifoBaseAddr)
{
FreeInitResources(p_Fm);
- RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for FIFO failed"));
- }
-
- tmpReg = (uint32_t)(XX_VirtToPhys(UINT_TO_PTR(p_Fm->fifoBaseAddr)) - p_Fm->fmMuramPhysBaseAddr);
- tmpReg = tmpReg / BMI_FIFO_ALIGN;
-
- tmpReg |= ((p_Fm->p_FmStateStruct->totalFifoSize/BMI_FIFO_UNITS - 1) << BMI_CFG1_FIFO_SIZE_SHIFT);
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_cfg1, tmpReg);
-
- tmpReg = ((uint32_t)(p_Fm->p_FmStateStruct->totalNumOfTasks - 1) << BMI_CFG2_TASKS_SHIFT );
- /* num of DMA's will be dynamically updated when each port is set */
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_cfg2, tmpReg);
-
- /* define unmaskable exceptions, enable and clear events */
- tmpReg = 0;
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_ievr, (BMI_ERR_INTR_EN_LIST_RAM_ECC |
- BMI_ERR_INTR_EN_PIPELINE_ECC |
- BMI_ERR_INTR_EN_STATISTICS_RAM_ECC |
- BMI_ERR_INTR_EN_DISPATCH_RAM_ECC));
- if(p_Fm->p_FmStateStruct->exceptions & FM_EX_BMI_LIST_RAM_ECC)
- tmpReg |= BMI_ERR_INTR_EN_LIST_RAM_ECC;
- if(p_Fm->p_FmStateStruct->exceptions & FM_EX_BMI_PIPELINE_ECC)
- tmpReg |= BMI_ERR_INTR_EN_PIPELINE_ECC;
- if(p_Fm->p_FmStateStruct->exceptions & FM_EX_BMI_STATISTICS_RAM_ECC)
- tmpReg |= BMI_ERR_INTR_EN_STATISTICS_RAM_ECC;
- if(p_Fm->p_FmStateStruct->exceptions & FM_EX_BMI_DISPATCH_RAM_ECC)
- tmpReg |= BMI_ERR_INTR_EN_DISPATCH_RAM_ECC;
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_ier, tmpReg);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM alloc for BMI FIFO failed"));
+ }
+
+ p_FmDriverParam->fifo_base_addr = (uint32_t)(XX_VirtToPhys(UINT_TO_PTR(p_Fm->fifoBaseAddr)) - p_Fm->fmMuramPhysBaseAddr);
+ p_FmDriverParam->total_fifo_size = p_Fm->p_FmStateStruct->totalFifoSize;
+ p_FmDriverParam->total_num_of_tasks = p_Fm->p_FmStateStruct->totalNumOfTasks;
+ p_FmDriverParam->clk_freq = p_Fm->p_FmStateStruct->fmClkFreq;
+
+ /**********************/
+ /* Init BMI Registers */
+ /**********************/
+ err = InitFmBmi(p_Fm);
+ if (err != E_OK)
+ {
+ FreeInitResources(p_Fm);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
/**********************/
/* Init QMI Registers */
/**********************/
- /* Clear error interrupt events */
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_eie, (QMI_ERR_INTR_EN_DOUBLE_ECC | QMI_ERR_INTR_EN_DEQ_FROM_DEF));
- tmpReg = 0;
- if(p_Fm->p_FmStateStruct->exceptions & FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID)
- tmpReg |= QMI_ERR_INTR_EN_DEQ_FROM_DEF;
- if(p_Fm->p_FmStateStruct->exceptions & FM_EX_QMI_DOUBLE_ECC)
- tmpReg |= QMI_ERR_INTR_EN_DOUBLE_ECC;
- /* enable events */
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_eien, tmpReg);
-
- if(p_Fm->p_FmDriverParam->tnumAgingPeriod)
+ err = InitFmQmi(p_Fm);
+ if (err != E_OK)
{
- /* tnumAgingPeriod is in units of microseconds, p_FmClockFreq is in Mhz */
- periodInFmClocks = (uint16_t)(p_Fm->p_FmDriverParam->tnumAgingPeriod*p_Fm->p_FmStateStruct->fmClkFreq);
- /* periodInFmClocks must be a 64 multiply */
- remainder = (uint8_t)(periodInFmClocks % 64);
- if (remainder > 64)
- tmpReg = (uint32_t)((periodInFmClocks/64) + 1);
- else
- {
- tmpReg = (uint32_t)(periodInFmClocks/64);
- if(!tmpReg)
- tmpReg = 1;
- }
- tmpReg <<= QMI_TAPC_TAP;
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_tapc, tmpReg);
-
- }
- tmpReg = 0;
- /* Clear interrupt events */
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_ie, QMI_INTR_EN_SINGLE_ECC);
- if(p_Fm->p_FmStateStruct->exceptions & FM_EX_QMI_SINGLE_ECC)
- tmpReg |= QMI_INTR_EN_SINGLE_ECC;
- /* enable events */
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_ien, tmpReg);
-
- /* clear & enable global counters - calculate reg and save for later,
- because it's the same reg for QMI enable */
- if(p_Fm->p_FmDriverParam->enCounters)
- cfgReg = QMI_CFG_EN_COUNTERS;
-#ifdef FM_QMI_DEQ_OPTIONS_SUPPORT
- cfgReg |= (uint32_t)(((QMI_DEF_TNUMS_THRESH) << 8) | (uint32_t)QMI_DEF_TNUMS_THRESH);
-#endif /* FM_QMI_DEQ_OPTIONS_SUPPORT */
+ FreeInitResources(p_Fm);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+ /* build the FM master partition IPC address */
+ if (Sprint (p_Fm->fmModuleName, "FM_%d_%d",p_Fm->p_FmStateStruct->fmId, NCSW_MASTER_ID) != 6)
+ {
+ FreeInitResources(p_Fm);
+ RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
+ }
+
+ err = XX_IpcRegisterMsgHandler(p_Fm->fmModuleName, FmHandleIpcMsgCB, p_Fm, FM_IPC_MAX_REPLY_SIZE);
+ if (err)
+ {
+ FreeInitResources(p_Fm);
+ RETURN_ERROR(MAJOR, err, NO_MSG);
+ }
+
+ /* Register the FM interrupts handlers */
if (p_Fm->p_FmStateStruct->irq != NO_IRQ)
{
XX_SetIntr(p_Fm->p_FmStateStruct->irq, FM_EventIsr, p_Fm);
@@ -3053,28 +3683,20 @@ t_Error FM_Init(t_Handle h_Fm)
if (p_Fm->p_FmStateStruct->errIrq != NO_IRQ)
{
- XX_SetIntr(p_Fm->p_FmStateStruct->errIrq, ErrorIsrCB, p_Fm);
+ XX_SetIntr(p_Fm->p_FmStateStruct->errIrq, (void (*) (t_Handle))FM_ErrorIsr, p_Fm);
XX_EnableIntr(p_Fm->p_FmStateStruct->errIrq);
}
- /* build the FM master partition IPC address */
- if (Sprint (p_Fm->fmModuleName, "FM_%d_%d",p_Fm->p_FmStateStruct->fmId, NCSW_MASTER_ID) != 6)
- RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Sprint failed"));
-
- err = XX_IpcRegisterMsgHandler(p_Fm->fmModuleName, FmHandleIpcMsgCB, p_Fm, FM_IPC_MAX_REPLY_SIZE);
- if(err)
- RETURN_ERROR(MAJOR, err, NO_MSG);
+ err = (t_Error)fman_enable(&fman_rg , p_FmDriverParam);
+ if (err != E_OK)
+ return err; /* FIXME */
- /**********************/
- /* Enable all modules */
- /**********************/
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_init, BMI_INIT_START);
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_gc, cfgReg | QMI_CFG_ENQ_EN | QMI_CFG_DEQ_EN);
+ EnableTimeStamp(p_Fm);
- if (p_Fm->p_FmDriverParam->firmware.p_Code)
+ if (p_Fm->firmware.p_Code)
{
- XX_Free(p_Fm->p_FmDriverParam->firmware.p_Code);
- p_Fm->p_FmDriverParam->firmware.p_Code = NULL;
+ XX_Free(p_Fm->firmware.p_Code);
+ p_Fm->firmware.p_Code = NULL;
}
XX_Free(p_Fm->p_FmDriverParam);
@@ -3096,15 +3718,32 @@ t_Error FM_Init(t_Handle h_Fm)
*//***************************************************************************/
t_Error FM_Free(t_Handle h_Fm)
{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+ struct fman_rg fman_rg;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
+ fman_rg.bmi_rg = p_Fm->p_FmBmiRegs;
+ fman_rg.qmi_rg = p_Fm->p_FmQmiRegs;
+ fman_rg.fpm_rg = p_Fm->p_FmFpmRegs;
+ fman_rg.dma_rg = p_Fm->p_FmDmaRegs;
+
if (p_Fm->guestId != NCSW_MASTER_ID)
{
- XX_IpcUnregisterMsgHandler(p_Fm->fmModuleName);
+#if (DPAA_VERSION >= 11)
+ FreeVSPsForPartition(h_Fm, p_Fm->partVSPBase, p_Fm->partNumOfVSPs, p_Fm->guestId);
- if(!p_Fm->recoveryMode)
+ if (p_Fm->p_FmSp)
+ {
+ XX_Free(p_Fm->p_FmSp);
+ p_Fm->p_FmSp = NULL;
+ }
+#endif /* (DPAA_VERSION >= 11) */
+
+ if (p_Fm->fmModuleName[0] != 0)
+ XX_IpcUnregisterMsgHandler(p_Fm->fmModuleName);
+
+ if (!p_Fm->recoveryMode)
XX_Free(p_Fm->p_FmStateStruct);
XX_Free(p_Fm);
@@ -3112,16 +3751,7 @@ t_Error FM_Free(t_Handle h_Fm)
return E_OK;
}
- /* disable BMI and QMI */
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_init, 0);
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_gc, 0);
-
- /* release BMI resources */
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_cfg2, 0);
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_cfg1, 0);
-
- /* disable ECC */
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fmrcr, 0);
+ fman_free_resources(&fman_rg);
if ((p_Fm->guestId == NCSW_MASTER_ID) && (p_Fm->fmModuleName[0] != 0))
XX_IpcUnregisterMsgHandler(p_Fm->fmModuleName);
@@ -3140,13 +3770,23 @@ t_Error FM_Free(t_Handle h_Fm)
}
}
+#if (DPAA_VERSION >= 11)
+ FreeVSPsForPartition(h_Fm, p_Fm->partVSPBase, p_Fm->partNumOfVSPs, p_Fm->guestId);
+
+ if (p_Fm->p_FmSp)
+ {
+ XX_Free(p_Fm->p_FmSp);
+ p_Fm->p_FmSp = NULL;
+ }
+#endif /* (DPAA_VERSION >= 11) */
+
if (p_Fm->h_Spinlock)
XX_FreeSpinlock(p_Fm->h_Spinlock);
if (p_Fm->p_FmDriverParam)
{
- if (p_Fm->p_FmDriverParam->firmware.p_Code)
- XX_Free(p_Fm->p_FmDriverParam->firmware.p_Code);
+ if (p_Fm->firmware.p_Code)
+ XX_Free(p_Fm->firmware.p_Code);
XX_Free(p_Fm->p_FmDriverParam);
p_Fm->p_FmDriverParam = NULL;
}
@@ -3167,26 +3807,26 @@ t_Error FM_Free(t_Handle h_Fm)
t_Error FM_ConfigResetOnInit(t_Handle h_Fm, bool enable)
{
-
t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- p_Fm->p_FmDriverParam->resetOnInit = enable;
+ p_Fm->resetOnInit = enable;
return E_OK;
}
-
-t_Error FM_ConfigTotalNumOfTasks(t_Handle h_Fm, uint8_t totalNumOfTasks)
+t_Error FM_ConfigResetOnInitOverrideCallback(t_Handle h_Fm, t_FmResetOnInitOverrideCallback *f_ResetOnInitOverride)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- p_Fm->p_FmStateStruct->totalNumOfTasks = totalNumOfTasks;
+ p_Fm->f_ResetOnInitOverride = f_ResetOnInitOverride;
return E_OK;
}
@@ -3197,471 +3837,513 @@ t_Error FM_ConfigTotalFifoSize(t_Handle h_Fm, uint32_t totalFifoSize)
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
p_Fm->p_FmStateStruct->totalFifoSize = totalFifoSize;
return E_OK;
}
-t_Error FM_ConfigMaxNumOfOpenDmas(t_Handle h_Fm, uint8_t maxNumOfOpenDmas)
+t_Error FM_ConfigDmaCacheOverride(t_Handle h_Fm, e_FmDmaCacheOverride cacheOverride)
{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+ enum fman_dma_cache_override fsl_cache_override;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- p_Fm->p_FmStateStruct->maxNumOfOpenDmas = maxNumOfOpenDmas;
+ FMAN_CACHE_OVERRIDE_TRANS(fsl_cache_override, cacheOverride)
+ p_Fm->p_FmDriverParam->dma_cache_override = fsl_cache_override;
return E_OK;
}
-t_Error FM_ConfigThresholds(t_Handle h_Fm, t_FmThresholds *p_FmThresholds)
+t_Error FM_ConfigDmaAidOverride(t_Handle h_Fm, bool aidOverride)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- memcpy(&p_Fm->p_FmDriverParam->thresholds, p_FmThresholds, sizeof(t_FmThresholds));
+ p_Fm->p_FmDriverParam->dma_aid_override = aidOverride;
return E_OK;
}
-t_Error FM_ConfigDmaCacheOverride(t_Handle h_Fm, e_FmDmaCacheOverride cacheOverride)
+t_Error FM_ConfigDmaAidMode(t_Handle h_Fm, e_FmDmaAidMode aidMode)
{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+ enum fman_dma_aid_mode fsl_aid_mode;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- p_Fm->p_FmDriverParam->dmaCacheOverride = cacheOverride;
+ FMAN_AID_MODE_TRANS(fsl_aid_mode, aidMode);
+ p_Fm->p_FmDriverParam->dma_aid_mode = fsl_aid_mode;
return E_OK;
}
-t_Error FM_ConfigDmaAidOverride(t_Handle h_Fm, bool aidOverride)
+t_Error FM_ConfigDmaAxiDbgNumOfBeats(t_Handle h_Fm, uint8_t axiDbgNumOfBeats)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- p_Fm->p_FmDriverParam->dmaAidOverride = aidOverride;
+#if (DPAA_VERSION >= 11)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("Not available for this FM revision!"));
+#else
+ p_Fm->p_FmDriverParam->dma_axi_dbg_num_of_beats = axiDbgNumOfBeats;
return E_OK;
+#endif /* (DPAA_VERSION >= 11) */
}
-t_Error FM_ConfigDmaAidMode(t_Handle h_Fm, e_FmDmaAidMode aidMode)
+t_Error FM_ConfigDmaCamNumOfEntries(t_Handle h_Fm, uint8_t numOfEntries)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- p_Fm->p_FmDriverParam->dmaAidMode = aidMode;
+ p_Fm->p_FmDriverParam->dma_cam_num_of_entries = numOfEntries;
return E_OK;
}
-t_Error FM_ConfigDmaAxiDbgNumOfBeats(t_Handle h_Fm, uint8_t axiDbgNumOfBeats)
+t_Error FM_ConfigDmaDbgCounter(t_Handle h_Fm, e_FmDmaDbgCntMode fmDmaDbgCntMode)
{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+ enum fman_dma_dbg_cnt_mode fsl_dma_dbg_cnt;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- p_Fm->p_FmDriverParam->dmaAxiDbgNumOfBeats = axiDbgNumOfBeats;
+ FMAN_DMA_DBG_CNT_TRANS(fsl_dma_dbg_cnt, fmDmaDbgCntMode);
+ p_Fm->p_FmDriverParam->dma_dbg_cnt_mode = fsl_dma_dbg_cnt;
return E_OK;
}
-t_Error FM_ConfigDmaCamNumOfEntries(t_Handle h_Fm, uint8_t numOfEntries)
+t_Error FM_ConfigDmaStopOnBusErr(t_Handle h_Fm, bool stop)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- p_Fm->p_FmDriverParam->dmaCamNumOfEntries = numOfEntries;
+ p_Fm->p_FmDriverParam->dma_stop_on_bus_error = stop;
return E_OK;
}
-t_Error FM_ConfigDmaWatchdog(t_Handle h_Fm, uint32_t watchdogValue)
+t_Error FM_ConfigDmaEmergency(t_Handle h_Fm, t_FmDmaEmergency *p_Emergency)
{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+ enum fman_dma_emergency_level fsl_dma_emer;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
-#ifdef FM_NO_WATCHDOG
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(h_Fm, &revInfo);
- if (revInfo.majorRev != 4)
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("watchdog!"));
- }
-#endif /* FM_NO_WATCHDOG */
-
- p_Fm->p_FmDriverParam->dmaWatchdog = watchdogValue;
+ FMAN_DMA_EMER_TRANS(fsl_dma_emer, p_Emergency->emergencyLevel);
+ p_Fm->p_FmDriverParam->dma_en_emergency = TRUE;
+ p_Fm->p_FmDriverParam->dma_emergency_bus_select = (uint32_t)p_Emergency->emergencyBusSelect;
+ p_Fm->p_FmDriverParam->dma_emergency_level = fsl_dma_emer;
return E_OK;
}
-t_Error FM_ConfigDmaWriteBufThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds)
-
+t_Error FM_ConfigDmaEmergencySmoother(t_Handle h_Fm, uint32_t emergencyCnt)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- memcpy(&p_Fm->p_FmDriverParam->dmaWriteBufThresholds, p_FmDmaThresholds, sizeof(t_FmDmaThresholds));
+ p_Fm->p_FmDriverParam->dma_en_emergency_smoother = TRUE;
+ p_Fm->p_FmDriverParam->dma_emergency_switch_counter = emergencyCnt;
return E_OK;
}
-t_Error FM_ConfigDmaCommQThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds)
+t_Error FM_ConfigDmaErr(t_Handle h_Fm, e_FmDmaErr dmaErr)
{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+ enum fman_dma_err fsl_dma_err;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- memcpy(&p_Fm->p_FmDriverParam->dmaCommQThresholds, p_FmDmaThresholds, sizeof(t_FmDmaThresholds));
+ FMAN_DMA_ERR_TRANS(fsl_dma_err, dmaErr);
+ p_Fm->p_FmDriverParam->dma_err = fsl_dma_err;
return E_OK;
}
-t_Error FM_ConfigDmaReadBufThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds)
+t_Error FM_ConfigCatastrophicErr(t_Handle h_Fm, e_FmCatastrophicErr catastrophicErr)
{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+ enum fman_catastrophic_err fsl_catastrophic_err;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- memcpy(&p_Fm->p_FmDriverParam->dmaReadBufThresholds, p_FmDmaThresholds, sizeof(t_FmDmaThresholds));
+ FMAN_CATASTROPHIC_ERR_TRANS(fsl_catastrophic_err, catastrophicErr);
+ p_Fm->p_FmDriverParam->catastrophic_err = fsl_catastrophic_err;
return E_OK;
}
-t_Error FM_ConfigDmaEmergency(t_Handle h_Fm, t_FmDmaEmergency *p_Emergency)
+t_Error FM_ConfigEnableMuramTestMode(t_Handle h_Fm)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- p_Fm->p_FmDriverParam->dmaEnEmergency = TRUE;
- memcpy(&p_Fm->p_FmDriverParam->dmaEmergency, p_Emergency, sizeof(t_FmDmaEmergency));
+ if (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("Not available for this FM revision!"));
+
+ p_Fm->p_FmDriverParam->en_muram_test_mode = TRUE;
return E_OK;
}
-t_Error FM_ConfigDmaEmergencySmoother(t_Handle h_Fm, uint32_t emergencyCnt)
+t_Error FM_ConfigEnableIramTestMode(t_Handle h_Fm)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE );
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- if(!p_Fm->p_FmDriverParam->dmaEnEmergency)
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("FM_ConfigEnDmaEmergencySmoother may be called only after FM_ConfigEnDmaEmergency"));
+ if (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("Not available for this FM revision!"));
- p_Fm->p_FmDriverParam->dmaEnEmergencySmoother = TRUE;
- p_Fm->p_FmDriverParam->dmaEmergencySwitchCounter = emergencyCnt;
+ p_Fm->p_FmDriverParam->en_iram_test_mode = TRUE;
return E_OK;
}
-t_Error FM_ConfigDmaDbgCounter(t_Handle h_Fm, e_FmDmaDbgCntMode fmDmaDbgCntMode)
+t_Error FM_ConfigHaltOnExternalActivation(t_Handle h_Fm, bool enable)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- p_Fm->p_FmDriverParam->dmaDbgCntMode = fmDmaDbgCntMode;
+ p_Fm->p_FmDriverParam->halt_on_external_activ = enable;
return E_OK;
}
-t_Error FM_ConfigDmaStopOnBusErr(t_Handle h_Fm, bool stop)
+t_Error FM_ConfigHaltOnUnrecoverableEccError(t_Handle h_Fm, bool enable)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
+
+ if (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("Not available for this FM revision!"));
- p_Fm->p_FmDriverParam->dmaStopOnBusError = stop;
+ p_Fm->p_FmDriverParam->halt_on_unrecov_ecc_err = enable;
return E_OK;
}
-t_Error FM_ConfigDmaSosEmergencyThreshold(t_Handle h_Fm, uint32_t dmaSosEmergency)
+t_Error FM_ConfigException(t_Handle h_Fm, e_FmExceptions exception, bool enable)
{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+ uint32_t bitMask = 0;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- p_Fm->p_FmDriverParam->dmaSosEmergency = dmaSosEmergency;
+ GET_EXCEPTION_FLAG(bitMask, exception);
+ if (bitMask)
+ {
+ if (enable)
+ p_Fm->userSetExceptions |= bitMask;
+ else
+ p_Fm->p_FmStateStruct->exceptions &= ~bitMask;
+ }
+ else
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
return E_OK;
}
-t_Error FM_ConfigEnableCounters(t_Handle h_Fm)
+t_Error FM_ConfigExternalEccRamsEnable(t_Handle h_Fm, bool enable)
{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- p_Fm->p_FmDriverParam->enCounters = TRUE;
+ p_Fm->p_FmDriverParam->external_ecc_rams_enable = enable;
return E_OK;
}
-t_Error FM_ConfigDmaErr(t_Handle h_Fm, e_FmDmaErr dmaErr)
+t_Error FM_ConfigTnumAgingPeriod(t_Handle h_Fm, uint16_t tnumAgingPeriod)
{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- p_Fm->p_FmDriverParam->dmaErr = dmaErr;
+ p_Fm->p_FmDriverParam->tnum_aging_period = tnumAgingPeriod;
+ p_Fm->tnumAgingPeriod = p_Fm->p_FmDriverParam->tnum_aging_period;
return E_OK;
}
-t_Error FM_ConfigCatastrophicErr(t_Handle h_Fm, e_FmCatastrophicErr catastrophicErr)
+/****************************************************/
+/* Hidden-DEBUG Only API */
+/****************************************************/
+
+t_Error FM_ConfigThresholds(t_Handle h_Fm, t_FmThresholds *p_FmThresholds)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
-
- p_Fm->p_FmDriverParam->catastrophicErr = catastrophicErr;
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
+
+ p_Fm->p_FmDriverParam->disp_limit_tsh = p_FmThresholds->dispLimit;
+ p_Fm->p_FmDriverParam->prs_disp_tsh = p_FmThresholds->prsDispTh;
+ p_Fm->p_FmDriverParam->plcr_disp_tsh = p_FmThresholds->plcrDispTh;
+ p_Fm->p_FmDriverParam->kg_disp_tsh = p_FmThresholds->kgDispTh;
+ p_Fm->p_FmDriverParam->bmi_disp_tsh = p_FmThresholds->bmiDispTh;
+ p_Fm->p_FmDriverParam->qmi_enq_disp_tsh = p_FmThresholds->qmiEnqDispTh;
+ p_Fm->p_FmDriverParam->qmi_deq_disp_tsh = p_FmThresholds->qmiDeqDispTh;
+ p_Fm->p_FmDriverParam->fm_ctl1_disp_tsh = p_FmThresholds->fmCtl1DispTh;
+ p_Fm->p_FmDriverParam->fm_ctl2_disp_tsh = p_FmThresholds->fmCtl2DispTh;
return E_OK;
}
-t_Error FM_ConfigEnableMuramTestMode(t_Handle h_Fm)
+t_Error FM_ConfigDmaSosEmergencyThreshold(t_Handle h_Fm, uint32_t dmaSosEmergency)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- p_Fm->p_FmDriverParam->enMuramTestMode = TRUE;
+ p_Fm->p_FmDriverParam->dma_sos_emergency = dmaSosEmergency;
return E_OK;
}
-t_Error FM_ConfigEnableIramTestMode(t_Handle h_Fm)
+t_Error FM_ConfigDmaWriteBufThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds)
+
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- p_Fm->p_FmDriverParam->enIramTestMode = TRUE;
+#if (DPAA_VERSION >= 11)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("Not available for this FM revision!"));
+#else
+ p_Fm->p_FmDriverParam->dma_write_buf_tsh_asrt_emer = p_FmDmaThresholds->assertEmergency;
+ p_Fm->p_FmDriverParam->dma_write_buf_tsh_clr_emer = p_FmDmaThresholds->clearEmergency;
return E_OK;
+#endif
}
-t_Error FM_ConfigHaltOnExternalActivation(t_Handle h_Fm, bool enable)
+t_Error FM_ConfigDmaCommQThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
-#ifdef FM_HALT_SIG_ERRATA_GEN12
- {
- t_FmRevisionInfo revInfo;
- FM_GetRevision(h_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("HaltOnExternalActivation!"));
- }
-#endif /* FM_HALT_SIG_ERRATA_GEN12 */
-
- p_Fm->p_FmDriverParam->haltOnExternalActivation = enable;
+ p_Fm->p_FmDriverParam->dma_comm_qtsh_asrt_emer = p_FmDmaThresholds->assertEmergency;
+ p_Fm->p_FmDriverParam->dma_comm_qtsh_clr_emer = p_FmDmaThresholds->clearEmergency;
return E_OK;
}
-t_Error FM_ConfigHaltOnUnrecoverableEccError(t_Handle h_Fm, bool enable)
+t_Error FM_ConfigDmaReadBufThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
-#ifdef FM_ECC_HALT_NO_SYNC_ERRATA_10GMAC_A008
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("HaltOnEccError!"));
-#endif /* FM_ECC_HALT_NO_SYNC_ERRATA_10GMAC_A008 */
-
- p_Fm->p_FmDriverParam->haltOnUnrecoverableEccError = enable;
+#if (DPAA_VERSION >= 11)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("Not available for this FM revision!"));
+#else
+ p_Fm->p_FmDriverParam->dma_read_buf_tsh_clr_emer = p_FmDmaThresholds->clearEmergency;
+ p_Fm->p_FmDriverParam->dma_read_buf_tsh_asrt_emer = p_FmDmaThresholds->assertEmergency;
return E_OK;
+#endif
}
-t_Error FM_ConfigException(t_Handle h_Fm, e_FmExceptions exception, bool enable)
+t_Error FM_ConfigDmaWatchdog(t_Handle h_Fm, uint32_t watchdogValue)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint32_t bitMask = 0;
- t_FmRevisionInfo revInfo;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- FM_GetRevision(p_Fm, &revInfo);
-#ifdef FM_BMI_PIPELINE_ERR_IRQ_ERRATA_FMAN9
- if((exception == e_FM_EX_BMI_PIPELINE_ECC) && (enable))
- {
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- {
- REPORT_ERROR(MINOR, E_NOT_SUPPORTED, ("e_FM_EX_BMI_PIPELINE_ECC!"));
- return E_OK;
- }
- }
-#endif /* FM_BMI_PIPELINE_ERR_IRQ_ERRATA_FMAN9 */
-#ifdef FM_RAM_LIST_ERR_IRQ_ERRATA_FMAN8
- if((exception == e_FM_EX_BMI_LIST_RAM_ECC) && (enable))
- {
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- {
- REPORT_ERROR(MINOR, E_NOT_SUPPORTED, ("e_FM_EX_BMI_LIST_RAM_ECC!"));
- return E_OK;
- }
- }
-#endif /* FM_RAM_LIST_ERR_IRQ_ERRATA_FMAN8 */
-#ifdef FM_QMI_NO_ECC_EXCEPTIONS
- if(((exception == e_FM_EX_QMI_SINGLE_ECC) || (exception == e_FM_EX_QMI_DOUBLE_ECC)) &&
- enable)
- {
- if (revInfo.majorRev == 4)
- {
- REPORT_ERROR(MINOR, E_NOT_SUPPORTED, ("QMI ECC exception!"));
- return E_OK;
- }
- }
-#endif /* FM_QMI_NO_ECC_EXCEPTIONS */
-#ifdef FM_NO_DISPATCH_RAM_ECC
- if((exception == e_FM_EX_BMI_DISPATCH_RAM_ECC) && (enable))
- {
- if (revInfo.majorRev != 4)
- {
- REPORT_ERROR(MINOR, E_NOT_SUPPORTED, ("e_FM_EX_BMI_DISPATCH_RAM_ECC!"));
- return E_OK;
- }
- }
-#endif /* FM_NO_DISPATCH_RAM_ECC */
-
- GET_EXCEPTION_FLAG(bitMask, exception);
- if(bitMask)
- {
- if (enable)
- p_Fm->p_FmStateStruct->exceptions |= bitMask;
- else
- p_Fm->p_FmStateStruct->exceptions &= ~bitMask;
- }
- else
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
+ p_Fm->p_FmDriverParam->dma_watchdog = watchdogValue;
return E_OK;
}
-t_Error FM_ConfigExternalEccRamsEnable(t_Handle h_Fm, bool enable)
+t_Error FM_ConfigEnableCounters(t_Handle h_Fm)
{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
-
- p_Fm->p_FmDriverParam->externalEccRamsEnable = enable;
+ SANITY_CHECK_RETURN_ERROR(p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+UNUSED(p_Fm);
return E_OK;
}
-t_Error FM_ConfigTnumAgingPeriod(t_Handle h_Fm, uint16_t tnumAgingPeriod)
+t_Error FmGetSetParams(t_Handle h_Fm, t_FmGetSetParams *p_Params)
{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
-#ifdef FM_NO_TNUM_AGING
- t_FmRevisionInfo revInfo;
-#endif /* FM_NO_TNUM_AGING */
-
- SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
-
-#ifdef FM_NO_TNUM_AGING
- FM_GetRevision(h_Fm, &revInfo);
- if (revInfo.majorRev != 4)
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("FM_ConfigTnumAgingPeriod!"));
-#endif /* FM_NO_TNUM_AGING */
-
- p_Fm->p_FmDriverParam->tnumAgingPeriod = tnumAgingPeriod;
-
- return E_OK;
-
+ t_Fm* p_Fm = (t_Fm*)h_Fm;
+ if (p_Params->setParams.type & UPDATE_FM_CLD)
+ {
+ WRITE_UINT32(p_Fm->p_FmFpmRegs->fm_cld, GET_UINT32(
+ p_Fm->p_FmFpmRegs->fm_cld) | 0x00000800);
+ }
+ if (p_Params->setParams.type & CLEAR_IRAM_READY)
+ {
+ t_FMIramRegs *p_Iram = (t_FMIramRegs *)UINT_TO_PTR(p_Fm->baseAddr + FM_MM_IMEM);
+ WRITE_UINT32(p_Iram->iready,GET_UINT32(p_Iram->iready) & ~IRAM_READY);
+ }
+ if (p_Params->setParams.type & UPDATE_FPM_EXTC)
+ WRITE_UINT32(p_Fm->p_FmFpmRegs->fmfp_extc,0x80000000);
+ if (p_Params->setParams.type & UPDATE_FPM_EXTC_CLEAR)
+ WRITE_UINT32(p_Fm->p_FmFpmRegs->fmfp_extc,0x00800000);
+ if (p_Params->setParams.type & UPDATE_FPM_BRKC_SLP)
+ {
+ if (p_Params->setParams.sleep)
+ WRITE_UINT32(p_Fm->p_FmFpmRegs->fmfp_brkc, GET_UINT32(
+ p_Fm->p_FmFpmRegs->fmfp_brkc) | FPM_BRKC_SLP);
+ else
+ WRITE_UINT32(p_Fm->p_FmFpmRegs->fmfp_brkc, GET_UINT32(
+ p_Fm->p_FmFpmRegs->fmfp_brkc) & ~FPM_BRKC_SLP);
+ }
+ if (p_Params->getParams.type & GET_FM_CLD)
+ p_Params->getParams.fm_cld = GET_UINT32(p_Fm->p_FmFpmRegs->fm_cld);
+ if (p_Params->getParams.type & GET_FMQM_GS)
+ p_Params->getParams.fmqm_gs = GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_gs);
+ if (p_Params->getParams.type & GET_FM_NPI)
+ p_Params->getParams.fm_npi = GET_UINT32(p_Fm->p_FmFpmRegs->fm_npi);
+ if (p_Params->getParams.type & GET_FMFP_EXTC)
+ p_Params->getParams.fmfp_extc = GET_UINT32(p_Fm->p_FmFpmRegs->fmfp_extc);
+ return E_OK;
}
+
/****************************************************/
/* API Run-time Control uint functions */
/****************************************************/
-t_Handle FM_GetPcdHandle(t_Handle h_Fm)
-{
- SANITY_CHECK_RETURN_VALUE(h_Fm, E_INVALID_HANDLE, NULL);
- SANITY_CHECK_RETURN_VALUE(!((t_Fm*)h_Fm)->p_FmDriverParam, E_INVALID_STATE, NULL);
-
- return ((t_Fm*)h_Fm)->h_Pcd;
-}
-
void FM_EventIsr(t_Handle h_Fm)
{
-#define FM_M_CALL_1G_MAC_TMR_ISR(_id) \
- { \
- if (p_Fm->guestId != p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_1G_MAC0_TMR+_id)].guestId) \
- SendIpcIsr(p_Fm, (e_FmInterModuleEvent)(e_FM_EV_1G_MAC0_TMR+_id), pending); \
- else \
- p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_1G_MAC0_TMR+_id)].f_Isr(p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_1G_MAC0_TMR+_id)].h_SrcHandle);\
+#define FM_M_CALL_1G_MAC_ISR(_id) \
+ { \
+ if (p_Fm->guestId != p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_1G_MAC0+_id)].guestId) \
+ SendIpcIsr(p_Fm, (e_FmInterModuleEvent)(e_FM_EV_1G_MAC0+_id), pending); \
+ else \
+ p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_1G_MAC0+_id)].f_Isr(p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_1G_MAC0+_id)].h_SrcHandle);\
+ }
+#define FM_M_CALL_10G_MAC_ISR(_id) \
+ { \
+ if (p_Fm->guestId != p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_10G_MAC0+_id)].guestId) \
+ SendIpcIsr(p_Fm, (e_FmInterModuleEvent)(e_FM_EV_10G_MAC0+_id), pending); \
+ else \
+ p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_10G_MAC0+_id)].f_Isr(p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_10G_MAC0+_id)].h_SrcHandle);\
}
t_Fm *p_Fm = (t_Fm*)h_Fm;
uint32_t pending, event;
+ struct fman_fpm_regs *fpm_rg;
+
+ SANITY_CHECK_RETURN(p_Fm, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN(!p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- SANITY_CHECK_RETURN(h_Fm, E_INVALID_HANDLE);
+ fpm_rg = p_Fm->p_FmFpmRegs;
/* normal interrupts */
- pending = GET_UINT32(p_Fm->p_FmFpmRegs->fmnpi);
- ASSERT_COND(pending);
- if (pending & INTR_EN_BMI)
- REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("BMI Event - undefined!"));
+ pending = fman_get_normal_pending(fpm_rg);
+ if (!pending)
+ return;
+ if (pending & INTR_EN_WAKEUP) // this is a wake up from sleep interrupt
+ {
+ t_FmGetSetParams fmGetSetParams;
+ memset(&fmGetSetParams, 0, sizeof (t_FmGetSetParams));
+ fmGetSetParams.setParams.type = UPDATE_FPM_BRKC_SLP;
+ fmGetSetParams.setParams.sleep = 0;
+ FmGetSetParams(h_Fm, &fmGetSetParams);
+ }
if (pending & INTR_EN_QMI)
QmiEvent(p_Fm);
if (pending & INTR_EN_PRS)
p_Fm->intrMng[e_FM_EV_PRS].f_Isr(p_Fm->intrMng[e_FM_EV_PRS].h_SrcHandle);
if (pending & INTR_EN_PLCR)
p_Fm->intrMng[e_FM_EV_PLCR].f_Isr(p_Fm->intrMng[e_FM_EV_PLCR].h_SrcHandle);
- if (pending & INTR_EN_KG)
- p_Fm->intrMng[e_FM_EV_KG].f_Isr(p_Fm->intrMng[e_FM_EV_KG].h_SrcHandle);
if (pending & INTR_EN_TMR)
p_Fm->intrMng[e_FM_EV_TMR].f_Isr(p_Fm->intrMng[e_FM_EV_TMR].h_SrcHandle);
/* MAC events may belong to different partitions */
- if (pending & INTR_EN_1G_MAC0_TMR)
- FM_M_CALL_1G_MAC_TMR_ISR(0);
- if (pending & INTR_EN_1G_MAC1_TMR)
- FM_M_CALL_1G_MAC_TMR_ISR(1);
- if (pending & INTR_EN_1G_MAC2_TMR)
- FM_M_CALL_1G_MAC_TMR_ISR(2);
- if (pending & INTR_EN_1G_MAC3_TMR)
- FM_M_CALL_1G_MAC_TMR_ISR(3);
- if (pending & INTR_EN_1G_MAC4_TMR)
- FM_M_CALL_1G_MAC_TMR_ISR(4);
+ if (pending & INTR_EN_1G_MAC0)
+ FM_M_CALL_1G_MAC_ISR(0);
+ if (pending & INTR_EN_1G_MAC1)
+ FM_M_CALL_1G_MAC_ISR(1);
+ if (pending & INTR_EN_1G_MAC2)
+ FM_M_CALL_1G_MAC_ISR(2);
+ if (pending & INTR_EN_1G_MAC3)
+ FM_M_CALL_1G_MAC_ISR(3);
+ if (pending & INTR_EN_1G_MAC4)
+ FM_M_CALL_1G_MAC_ISR(4);
+ if (pending & INTR_EN_1G_MAC5)
+ FM_M_CALL_1G_MAC_ISR(5);
+ if (pending & INTR_EN_1G_MAC6)
+ FM_M_CALL_1G_MAC_ISR(6);
+ if (pending & INTR_EN_1G_MAC7)
+ FM_M_CALL_1G_MAC_ISR(7);
+ if (pending & INTR_EN_10G_MAC0)
+ FM_M_CALL_10G_MAC_ISR(0);
+ if (pending & INTR_EN_10G_MAC1)
+ FM_M_CALL_10G_MAC_ISR(1);
/* IM port events may belong to different partitions */
if (pending & INTR_EN_REV0)
{
- event = GET_UINT32(p_Fm->p_FmFpmRegs->fmfpfcev[0]) & GET_UINT32(p_Fm->p_FmFpmRegs->fmfpfcee[0]);
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmcev[0], event);
+ event = fman_get_controller_event(fpm_rg, 0);
if (p_Fm->guestId != p_Fm->intrMng[e_FM_EV_FMAN_CTRL_0].guestId)
/*TODO IPC ISR For Fman Ctrl */
ASSERT_COND(0);
@@ -3672,20 +4354,17 @@ void FM_EventIsr(t_Handle h_Fm)
}
if (pending & INTR_EN_REV1)
{
- event = GET_UINT32(p_Fm->p_FmFpmRegs->fmfpfcev[1]) & GET_UINT32(p_Fm->p_FmFpmRegs->fmfpfcee[1]);
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmcev[1], event);
+ event = fman_get_controller_event(fpm_rg, 1);
if (p_Fm->guestId != p_Fm->intrMng[e_FM_EV_FMAN_CTRL_1].guestId)
/*TODO IPC ISR For Fman Ctrl */
ASSERT_COND(0);
/* SendIpcIsr(p_Fm, e_FM_EV_FMAN_CTRL_1, pending); */
else
p_Fm->fmanCtrlIntr[1].f_Isr(p_Fm->fmanCtrlIntr[1].h_SrcHandle, event);
-
}
if (pending & INTR_EN_REV2)
{
- event = GET_UINT32(p_Fm->p_FmFpmRegs->fmfpfcev[2]) & GET_UINT32(p_Fm->p_FmFpmRegs->fmfpfcee[2]);
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmcev[2], event);
+ event = fman_get_controller_event(fpm_rg, 2);
if (p_Fm->guestId != p_Fm->intrMng[e_FM_EV_FMAN_CTRL_2].guestId)
/*TODO IPC ISR For Fman Ctrl */
ASSERT_COND(0);
@@ -3695,8 +4374,7 @@ void FM_EventIsr(t_Handle h_Fm)
}
if (pending & INTR_EN_REV3)
{
- event = GET_UINT32(p_Fm->p_FmFpmRegs->fmfpfcev[3]) & GET_UINT32(p_Fm->p_FmFpmRegs->fmfpfcee[3]);
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmcev[3], event);
+ event = fman_get_controller_event(fpm_rg, 3);
if (p_Fm->guestId != p_Fm->intrMng[e_FM_EV_FMAN_CTRL_3].guestId)
/*TODO IPC ISR For Fman Ctrl */
ASSERT_COND(0);
@@ -3704,19 +4382,99 @@ void FM_EventIsr(t_Handle h_Fm)
else
p_Fm->fmanCtrlIntr[3].f_Isr(p_Fm->fmanCtrlIntr[3].h_SrcHandle, event);
}
+#ifdef FM_MACSEC_SUPPORT
+ if (pending & INTR_EN_MACSEC_MAC0)
+ {
+ if (p_Fm->guestId != p_Fm->intrMng[e_FM_EV_MACSEC_MAC0].guestId)
+ SendIpcIsr(p_Fm, e_FM_EV_MACSEC_MAC0, pending);
+ else
+ p_Fm->intrMng[e_FM_EV_MACSEC_MAC0].f_Isr(p_Fm->intrMng[e_FM_EV_MACSEC_MAC0].h_SrcHandle);
+ }
+#endif /* FM_MACSEC_SUPPORT */
}
t_Error FM_ErrorIsr(t_Handle h_Fm)
{
+#define FM_M_CALL_1G_MAC_ERR_ISR(_id) \
+ { \
+ if (p_Fm->guestId != p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_1G_MAC0+_id)].guestId) \
+ SendIpcIsr(p_Fm, (e_FmInterModuleEvent)(e_FM_EV_ERR_1G_MAC0+_id), pending); \
+ else \
+ p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_1G_MAC0+_id)].f_Isr(p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_1G_MAC0+_id)].h_SrcHandle);\
+ }
+#define FM_M_CALL_10G_MAC_ERR_ISR(_id) \
+ { \
+ if (p_Fm->guestId != p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_10G_MAC0+_id)].guestId) \
+ SendIpcIsr(p_Fm, (e_FmInterModuleEvent)(e_FM_EV_ERR_10G_MAC0+_id), pending); \
+ else \
+ p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_10G_MAC0+_id)].f_Isr(p_Fm->intrMng[(e_FmInterModuleEvent)(e_FM_EV_ERR_10G_MAC0+_id)].h_SrcHandle);\
+ }
t_Fm *p_Fm = (t_Fm*)h_Fm;
+ uint32_t pending;
+ struct fman_fpm_regs *fpm_rg;
SANITY_CHECK_RETURN_ERROR(h_Fm, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
+
+ fpm_rg = p_Fm->p_FmFpmRegs;
/* error interrupts */
- if (GET_UINT32(p_Fm->p_FmFpmRegs->fmepi) == 0)
+ pending = fman_get_fpm_error_interrupts(fpm_rg);
+ if (!pending)
return ERROR_CODE(E_EMPTY);
- ErrorIsrCB(p_Fm);
+ if (pending & ERR_INTR_EN_BMI)
+ BmiErrEvent(p_Fm);
+ if (pending & ERR_INTR_EN_QMI)
+ QmiErrEvent(p_Fm);
+ if (pending & ERR_INTR_EN_FPM)
+ FpmErrEvent(p_Fm);
+ if (pending & ERR_INTR_EN_DMA)
+ DmaErrEvent(p_Fm);
+ if (pending & ERR_INTR_EN_IRAM)
+ IramErrIntr(p_Fm);
+ if (pending & ERR_INTR_EN_MURAM)
+ MuramErrIntr(p_Fm);
+ if (pending & ERR_INTR_EN_PRS)
+ p_Fm->intrMng[e_FM_EV_ERR_PRS].f_Isr(p_Fm->intrMng[e_FM_EV_ERR_PRS].h_SrcHandle);
+ if (pending & ERR_INTR_EN_PLCR)
+ p_Fm->intrMng[e_FM_EV_ERR_PLCR].f_Isr(p_Fm->intrMng[e_FM_EV_ERR_PLCR].h_SrcHandle);
+ if (pending & ERR_INTR_EN_KG)
+ p_Fm->intrMng[e_FM_EV_ERR_KG].f_Isr(p_Fm->intrMng[e_FM_EV_ERR_KG].h_SrcHandle);
+
+ /* MAC events may belong to different partitions */
+ if (pending & ERR_INTR_EN_1G_MAC0)
+ FM_M_CALL_1G_MAC_ERR_ISR(0);
+ if (pending & ERR_INTR_EN_1G_MAC1)
+ FM_M_CALL_1G_MAC_ERR_ISR(1);
+ if (pending & ERR_INTR_EN_1G_MAC2)
+ FM_M_CALL_1G_MAC_ERR_ISR(2);
+ if (pending & ERR_INTR_EN_1G_MAC3)
+ FM_M_CALL_1G_MAC_ERR_ISR(3);
+ if (pending & ERR_INTR_EN_1G_MAC4)
+ FM_M_CALL_1G_MAC_ERR_ISR(4);
+ if (pending & ERR_INTR_EN_1G_MAC5)
+ FM_M_CALL_1G_MAC_ERR_ISR(5);
+ if (pending & ERR_INTR_EN_1G_MAC6)
+ FM_M_CALL_1G_MAC_ERR_ISR(6);
+ if (pending & ERR_INTR_EN_1G_MAC7)
+ FM_M_CALL_1G_MAC_ERR_ISR(7);
+ if (pending & ERR_INTR_EN_10G_MAC0)
+ FM_M_CALL_10G_MAC_ERR_ISR(0);
+ if (pending & ERR_INTR_EN_10G_MAC1)
+ FM_M_CALL_10G_MAC_ERR_ISR(1);
+
+#ifdef FM_MACSEC_SUPPORT
+ if (pending & ERR_INTR_EN_MACSEC_MAC0)
+ {
+ if (p_Fm->guestId != p_Fm->intrMng[e_FM_EV_ERR_MACSEC_MAC0].guestId)
+ SendIpcIsr(p_Fm, e_FM_EV_ERR_MACSEC_MAC0, pending);
+ else
+ p_Fm->intrMng[e_FM_EV_ERR_MACSEC_MAC0].f_Isr(p_Fm->intrMng[e_FM_EV_ERR_MACSEC_MAC0].h_SrcHandle);
+ }
+#endif /* FM_MACSEC_SUPPORT */
+
return E_OK;
}
@@ -3726,31 +4484,39 @@ t_Error FM_SetPortsBandwidth(t_Handle h_Fm, t_FmPortsBandwidthParams *p_PortsBan
int i;
uint8_t sum;
uint8_t hardwarePortId;
- uint32_t tmpRegs[8] = {0,0,0,0,0,0,0,0};
- uint8_t relativePortId, shift, weight, maxPercent = 0;
+ uint8_t weights[64];
+ uint8_t weight, maxPercent = 0;
+ struct fman_bmi_regs *bmi_rg;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
+
+ bmi_rg = p_Fm->p_FmBmiRegs;
+
+ memset(weights, 0, (sizeof(uint8_t) * 64));
/* check that all ports add up to 100% */
sum = 0;
- for (i=0;i<p_PortsBandwidth->numOfPorts;i++)
+ for (i=0; i < p_PortsBandwidth->numOfPorts; i++)
sum +=p_PortsBandwidth->portsBandwidths[i].bandwidth;
if (sum != 100)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Sum of ports bandwidth differ from 100%"));
- /* find highest precent */
- for (i=0;i<p_PortsBandwidth->numOfPorts;i++)
+ /* find highest percent */
+ for (i=0; i < p_PortsBandwidth->numOfPorts; i++)
{
if (p_PortsBandwidth->portsBandwidths[i].bandwidth > maxPercent)
maxPercent = p_PortsBandwidth->portsBandwidths[i].bandwidth;
}
+ ASSERT_COND(maxPercent > 0); /* guaranteed by sum = 100 */
+
/* calculate weight for each port */
- for (i=0;i<p_PortsBandwidth->numOfPorts;i++)
+ for (i=0; i < p_PortsBandwidth->numOfPorts; i++)
{
- weight = (uint8_t)((p_PortsBandwidth->portsBandwidths[i].bandwidth * PORT_MAX_WEIGHT )/maxPercent);
- /* we want even division between 1-to-PORT_MAX_WEIGHT. so if exect division
+ weight = (uint8_t)((p_PortsBandwidth->portsBandwidths[i].bandwidth * PORT_MAX_WEIGHT ) / maxPercent);
+ /* we want even division between 1-to-PORT_MAX_WEIGHT. so if exact division
is not reached, we round up so that:
0 until maxPercent/PORT_MAX_WEIGHT get "1"
maxPercent/PORT_MAX_WEIGHT+1 until (maxPercent/PORT_MAX_WEIGHT)*2 get "2"
@@ -3760,22 +4526,17 @@ t_Error FM_SetPortsBandwidth(t_Handle h_Fm, t_FmPortsBandwidthParams *p_PortsBan
weight++;
/* find the location of this port within the register */
- SW_PORT_ID_TO_HW_PORT_ID(hardwarePortId,
- p_PortsBandwidth->portsBandwidths[i].type,
- p_PortsBandwidth->portsBandwidths[i].relativePortId);
- relativePortId = (uint8_t)(hardwarePortId % 8);
- shift = (uint8_t)(32-4*(relativePortId+1));
-
-
- if(weight > 1)
- /* Add this port to tmpReg */
- /* (each 8 ports result in one register)*/
- tmpRegs[hardwarePortId/8] |= ((weight-1) << shift);
+ hardwarePortId =
+ SwPortIdToHwPortId(p_PortsBandwidth->portsBandwidths[i].type,
+ p_PortsBandwidth->portsBandwidths[i].relativePortId,
+ p_Fm->p_FmStateStruct->revInfo.majorRev,
+ p_Fm->p_FmStateStruct->revInfo.minorRev);
+
+ ASSERT_COND(IN_RANGE(1, hardwarePortId, 63));
+ weights[hardwarePortId] = weight;
}
- for(i=0;i<8;i++)
- if(tmpRegs[i])
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_arb[i], tmpRegs[i]);
+ fman_set_ports_bandwidth(bmi_rg, weights);
return E_OK;
}
@@ -3783,44 +4544,40 @@ t_Error FM_SetPortsBandwidth(t_Handle h_Fm, t_FmPortsBandwidthParams *p_PortsBan
t_Error FM_EnableRamsEcc(t_Handle h_Fm)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint32_t tmpReg;
+ struct fman_fpm_regs *fpm_rg;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ fpm_rg = p_Fm->p_FmFpmRegs;
+
+ if (p_Fm->guestId != NCSW_MASTER_ID)
{
t_FmIpcMsg msg;
t_Error err;
memset(&msg, 0, sizeof(msg));
msg.msgId = FM_ENABLE_RAM_ECC;
- if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
- (uint8_t*)&msg,
- sizeof(msg.msgId),
- NULL,
- NULL,
- NULL,
- NULL)) != E_OK)
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId),
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ if (err != E_OK)
RETURN_ERROR(MINOR, err, NO_MSG);
return E_OK;
}
- if(!p_Fm->p_FmStateStruct->internalCall)
+ if (!p_Fm->p_FmStateStruct->internalCall)
p_Fm->p_FmStateStruct->explicitEnable = TRUE;
p_Fm->p_FmStateStruct->internalCall = FALSE;
- if(p_Fm->p_FmStateStruct->ramsEccEnable)
+ if (p_Fm->p_FmStateStruct->ramsEccEnable)
return E_OK;
else
{
- tmpReg = GET_UINT32(p_Fm->p_FmFpmRegs->fmrcr);
- if(tmpReg & FPM_RAM_CTL_RAMS_ECC_EN_SRC_SEL)
- {
- DBG(WARNING, ("Rams ECC is configured to be controlled through JTAG"));
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fmrcr, tmpReg | FPM_RAM_CTL_IRAM_ECC_EN);
- }
- else
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fmrcr, tmpReg | (FPM_RAM_CTL_RAMS_ECC_EN | FPM_RAM_CTL_IRAM_ECC_EN));
+ fman_enable_rams_ecc(fpm_rg);
p_Fm->p_FmStateStruct->ramsEccEnable = TRUE;
}
@@ -3830,13 +4587,15 @@ t_Error FM_EnableRamsEcc(t_Handle h_Fm)
t_Error FM_DisableRamsEcc(t_Handle h_Fm)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint32_t tmpReg;
bool explicitDisable = FALSE;
+ struct fman_fpm_regs *fpm_rg;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_HANDLE);
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ fpm_rg = p_Fm->p_FmFpmRegs;
+
+ if (p_Fm->guestId != NCSW_MASTER_ID)
{
t_Error err;
t_FmIpcMsg msg;
@@ -3854,30 +4613,24 @@ t_Error FM_DisableRamsEcc(t_Handle h_Fm)
return E_OK;
}
- if(!p_Fm->p_FmStateStruct->internalCall)
+ if (!p_Fm->p_FmStateStruct->internalCall)
explicitDisable = TRUE;
p_Fm->p_FmStateStruct->internalCall = FALSE;
/* if rams are already disabled, or if rams were explicitly enabled and are
currently called indirectly (not explicitly), ignore this call. */
- if(!p_Fm->p_FmStateStruct->ramsEccEnable || (p_Fm->p_FmStateStruct->explicitEnable && !explicitDisable))
+ if (!p_Fm->p_FmStateStruct->ramsEccEnable ||
+ (p_Fm->p_FmStateStruct->explicitEnable && !explicitDisable))
return E_OK;
else
{
- if(p_Fm->p_FmStateStruct->explicitEnable)
+ if (p_Fm->p_FmStateStruct->explicitEnable)
/* This is the case were both explicit are TRUE.
Turn off this flag for cases were following ramsEnable
routines are called */
p_Fm->p_FmStateStruct->explicitEnable = FALSE;
- tmpReg = GET_UINT32(p_Fm->p_FmFpmRegs->fmrcr);
- if(tmpReg & FPM_RAM_CTL_RAMS_ECC_EN_SRC_SEL)
- {
- DBG(WARNING, ("Rams ECC is configured to be controlled through JTAG"));
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fmrcr, tmpReg & ~FPM_RAM_CTL_IRAM_ECC_EN);
- }
- else
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fmrcr, tmpReg & ~(FPM_RAM_CTL_RAMS_ECC_EN | FPM_RAM_CTL_IRAM_ECC_EN));
+ fman_enable_rams_ecc(fpm_rg);
p_Fm->p_FmStateStruct->ramsEccEnable = FALSE;
}
@@ -3886,216 +4639,32 @@ t_Error FM_DisableRamsEcc(t_Handle h_Fm)
t_Error FM_SetException(t_Handle h_Fm, e_FmExceptions exception, bool enable)
{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint32_t bitMask = 0;
- uint32_t tmpReg;
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+ uint32_t bitMask = 0;
+ enum fman_exceptions fslException;
+ struct fman_rg fman_rg;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
+ fman_rg.bmi_rg = p_Fm->p_FmBmiRegs;
+ fman_rg.qmi_rg = p_Fm->p_FmQmiRegs;
+ fman_rg.fpm_rg = p_Fm->p_FmFpmRegs;
+ fman_rg.dma_rg = p_Fm->p_FmDmaRegs;
+
GET_EXCEPTION_FLAG(bitMask, exception);
- if(bitMask)
+ if (bitMask)
{
if (enable)
p_Fm->p_FmStateStruct->exceptions |= bitMask;
else
p_Fm->p_FmStateStruct->exceptions &= ~bitMask;
- switch(exception)
- {
- case(e_FM_EX_DMA_BUS_ERROR):
- tmpReg = GET_UINT32(p_Fm->p_FmDmaRegs->fmdmmr);
- if(enable)
- tmpReg |= DMA_MODE_BER;
- else
- tmpReg &= ~DMA_MODE_BER;
- /* disable bus error */
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmmr, tmpReg);
- break;
- case(e_FM_EX_DMA_READ_ECC):
- case(e_FM_EX_DMA_SYSTEM_WRITE_ECC):
- case(e_FM_EX_DMA_FM_WRITE_ECC):
- tmpReg = GET_UINT32(p_Fm->p_FmDmaRegs->fmdmmr);
- if(enable)
- tmpReg |= DMA_MODE_ECC;
- else
- tmpReg &= ~DMA_MODE_ECC;
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmmr, tmpReg);
- break;
- case(e_FM_EX_FPM_STALL_ON_TASKS):
- tmpReg = GET_UINT32(p_Fm->p_FmFpmRegs->fpmem);
- if(enable)
- tmpReg |= FPM_EV_MASK_STALL_EN;
- else
- tmpReg &= ~FPM_EV_MASK_STALL_EN;
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmem, tmpReg);
- break;
- case(e_FM_EX_FPM_SINGLE_ECC):
- tmpReg = GET_UINT32(p_Fm->p_FmFpmRegs->fpmem);
- if(enable)
- tmpReg |= FPM_EV_MASK_SINGLE_ECC_EN;
- else
- tmpReg &= ~FPM_EV_MASK_SINGLE_ECC_EN;
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmem, tmpReg);
- break;
- case( e_FM_EX_FPM_DOUBLE_ECC):
- tmpReg = GET_UINT32(p_Fm->p_FmFpmRegs->fpmem);
- if(enable)
- tmpReg |= FPM_EV_MASK_DOUBLE_ECC_EN;
- else
- tmpReg &= ~FPM_EV_MASK_DOUBLE_ECC_EN;
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmem, tmpReg);
- break;
- case( e_FM_EX_QMI_SINGLE_ECC):
- tmpReg = GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_ien);
- if(enable)
- {
-#ifdef FM_QMI_NO_ECC_EXCEPTIONS
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_Fm, &revInfo);
- if (revInfo.majorRev == 4)
- {
- REPORT_ERROR(MINOR, E_NOT_SUPPORTED, ("e_FM_EX_QMI_SINGLE_ECC"));
- return E_OK;
- }
-#endif /* FM_QMI_NO_ECC_EXCEPTIONS */
- tmpReg |= QMI_INTR_EN_SINGLE_ECC;
- }
- else
- tmpReg &= ~QMI_INTR_EN_SINGLE_ECC;
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_ien, tmpReg);
- break;
- case(e_FM_EX_QMI_DOUBLE_ECC):
- tmpReg = GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_eien);
- if(enable)
- {
-#ifdef FM_QMI_NO_ECC_EXCEPTIONS
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_Fm, &revInfo);
- if (revInfo.majorRev == 4)
- {
- REPORT_ERROR(MINOR, E_NOT_SUPPORTED, ("e_FM_EX_QMI_DOUBLE_ECC"));
- return E_OK;
- }
-#endif /* FM_QMI_NO_ECC_EXCEPTIONS */
- tmpReg |= QMI_ERR_INTR_EN_DOUBLE_ECC;
- }
- else
- tmpReg &= ~QMI_ERR_INTR_EN_DOUBLE_ECC;
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_eien, tmpReg);
- break;
- case(e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID):
- tmpReg = GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_eien);
- if(enable)
- tmpReg |= QMI_ERR_INTR_EN_DEQ_FROM_DEF;
- else
- tmpReg &= ~QMI_ERR_INTR_EN_DEQ_FROM_DEF;
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_eien, tmpReg);
- break;
- case(e_FM_EX_BMI_LIST_RAM_ECC):
- tmpReg = GET_UINT32(p_Fm->p_FmBmiRegs->fmbm_ier);
- if(enable)
- {
-#ifdef FM_RAM_LIST_ERR_IRQ_ERRATA_FMAN8
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- {
- REPORT_ERROR(MINOR, E_NOT_SUPPORTED, ("e_FM_EX_BMI_LIST_RAM_ECC"));
- return E_OK;
- }
-#endif /* FM_RAM_LIST_ERR_IRQ_ERRATA_FMAN8 */
- tmpReg |= BMI_ERR_INTR_EN_LIST_RAM_ECC;
- }
- else
- tmpReg &= ~BMI_ERR_INTR_EN_LIST_RAM_ECC;
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_ier, tmpReg);
- break;
- case(e_FM_EX_BMI_PIPELINE_ECC):
- tmpReg = GET_UINT32(p_Fm->p_FmBmiRegs->fmbm_ier);
- if(enable)
- {
-#ifdef FM_BMI_PIPELINE_ERR_IRQ_ERRATA_FMAN9
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_Fm, &revInfo);
- if ((revInfo.majorRev == 1) && (revInfo.minorRev == 0))
- {
- REPORT_ERROR(MINOR, E_NOT_SUPPORTED, ("e_FM_EX_BMI_PIPELINE_ECCBMI_LIST_RAM_ECC"));
- return E_OK;
- }
-#endif /* FM_BMI_PIPELINE_ERR_IRQ_ERRATA_FMAN9 */
- tmpReg |= BMI_ERR_INTR_EN_PIPELINE_ECC;
- }
- else
- tmpReg &= ~BMI_ERR_INTR_EN_PIPELINE_ECC;
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_ier, tmpReg);
- break;
- case(e_FM_EX_BMI_STATISTICS_RAM_ECC):
- tmpReg = GET_UINT32(p_Fm->p_FmBmiRegs->fmbm_ier);
- if(enable)
- tmpReg |= BMI_ERR_INTR_EN_STATISTICS_RAM_ECC;
- else
- tmpReg &= ~BMI_ERR_INTR_EN_STATISTICS_RAM_ECC;
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_ier, tmpReg);
- break;
- case(e_FM_EX_BMI_DISPATCH_RAM_ECC):
- tmpReg = GET_UINT32(p_Fm->p_FmBmiRegs->fmbm_ier);
- if(enable)
- {
-#ifdef FM_NO_DISPATCH_RAM_ECC
- t_FmRevisionInfo revInfo;
- FM_GetRevision(p_Fm, &revInfo);
- if (revInfo.majorRev != 4)
- {
- REPORT_ERROR(MINOR, E_NOT_SUPPORTED, ("e_FM_EX_BMI_DISPATCH_RAM_ECC"));
- return E_OK;
- }
-#endif /* FM_NO_DISPATCH_RAM_ECC */
- tmpReg |= BMI_ERR_INTR_EN_DISPATCH_RAM_ECC;
- }
- else
- tmpReg &= ~BMI_ERR_INTR_EN_DISPATCH_RAM_ECC;
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_ier, tmpReg);
- break;
- case(e_FM_EX_IRAM_ECC):
- tmpReg = GET_UINT32(p_Fm->p_FmFpmRegs->fmrie);
- if(enable)
- {
- /* enable ECC if not enabled */
- FmEnableRamsEcc(p_Fm);
- /* enable ECC interrupts */
- tmpReg |= FPM_IRAM_ECC_ERR_EX_EN;
- }
- else
- {
- /* ECC mechanism may be disabled, depending on driver status */
- FmDisableRamsEcc(p_Fm);
- tmpReg &= ~FPM_IRAM_ECC_ERR_EX_EN;
- }
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fmrie, tmpReg);
- break;
+ fslException = FmanExceptionTrans(exception);
- case(e_FM_EX_MURAM_ECC):
- tmpReg = GET_UINT32(p_Fm->p_FmFpmRegs->fmrie);
- if(enable)
- {
- /* enable ECC if not enabled */
- FmEnableRamsEcc(p_Fm);
- /* enable ECC interrupts */
- tmpReg |= FPM_MURAM_ECC_ERR_EX_EN;
- }
- else
- {
- /* ECC mechanism may be disabled, depending on driver status */
- FmDisableRamsEcc(p_Fm);
- tmpReg &= ~FPM_MURAM_ECC_ERR_EX_EN;
- }
-
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fmrie, tmpReg);
- break;
- default:
- RETURN_ERROR(MINOR, E_INVALID_SELECTION, NO_MSG);
- }
+ return (t_Error)fman_set_exception(&fman_rg,
+ fslException,
+ enable);
}
else
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));
@@ -4105,22 +4674,36 @@ t_Error FM_SetException(t_Handle h_Fm, e_FmExceptions exception, bool enable)
t_Error FM_GetRevision(t_Handle h_Fm, t_FmRevisionInfo *p_FmRevisionInfo)
{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint32_t tmpReg;
- t_Error err;
- t_FmIpcMsg msg;
- t_FmIpcReply reply;
- uint32_t replyLength;
- t_FmIpcRevisionInfo ipcRevInfo;
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+
+ p_FmRevisionInfo->majorRev = p_Fm->p_FmStateStruct->revInfo.majorRev;
+ p_FmRevisionInfo->minorRev = p_Fm->p_FmStateStruct->revInfo.minorRev;
+
+ return E_OK;
+}
+
+t_Error FM_GetFmanCtrlCodeRevision(t_Handle h_Fm, t_FmCtrlCodeRevisionInfo *p_RevisionInfo)
+{
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+ t_FMIramRegs *p_Iram;
+ uint32_t revInfo;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(p_RevisionInfo, E_NULL_POINTER);
- if (p_Fm->guestId != NCSW_MASTER_ID)
+ if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ p_Fm->h_IpcSessions[0])
{
+ t_Error err;
+ t_FmIpcMsg msg;
+ t_FmIpcReply reply;
+ uint32_t replyLength;
+ t_FmIpcFmanCtrlCodeRevisionInfo ipcRevInfo;
+
memset(&msg, 0, sizeof(msg));
memset(&reply, 0, sizeof(reply));
- msg.msgId = FM_GET_REV;
- replyLength = sizeof(uint32_t) + sizeof(t_FmRevisionInfo);
+ msg.msgId = FM_GET_FMAN_CTRL_CODE_REV;
+ replyLength = sizeof(uint32_t) + sizeof(t_FmCtrlCodeRevisionInfo);
if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
(uint8_t*)&msg,
sizeof(msg.msgId),
@@ -4129,227 +4712,196 @@ t_Error FM_GetRevision(t_Handle h_Fm, t_FmRevisionInfo *p_FmRevisionInfo)
NULL,
NULL)) != E_OK)
RETURN_ERROR(MINOR, err, NO_MSG);
- if (replyLength != (sizeof(uint32_t) + sizeof(t_FmRevisionInfo)))
+ if (replyLength != (sizeof(uint32_t) + sizeof(t_FmCtrlCodeRevisionInfo)))
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
- memcpy((uint8_t*)&ipcRevInfo, reply.replyBody, sizeof(t_FmRevisionInfo));
- p_FmRevisionInfo->majorRev = ipcRevInfo.majorRev;
- p_FmRevisionInfo->minorRev = ipcRevInfo.minorRev;
+ memcpy((uint8_t*)&ipcRevInfo, reply.replyBody, sizeof(t_FmCtrlCodeRevisionInfo));
+ p_RevisionInfo->packageRev = ipcRevInfo.packageRev;
+ p_RevisionInfo->majorRev = ipcRevInfo.majorRev;
+ p_RevisionInfo->minorRev = ipcRevInfo.minorRev;
return (t_Error)(reply.error);
}
+ else if (p_Fm->guestId != NCSW_MASTER_ID)
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("running in guest-mode without IPC!"));
- /* read revision register 1 */
- tmpReg = GET_UINT32(p_Fm->p_FmFpmRegs->fm_ip_rev_1);
- p_FmRevisionInfo->majorRev = (uint8_t)((tmpReg & FPM_REV1_MAJOR_MASK) >> FPM_REV1_MAJOR_SHIFT);
- p_FmRevisionInfo->minorRev = (uint8_t)((tmpReg & FPM_REV1_MINOR_MASK) >> FPM_REV1_MINOR_SHIFT);
+ p_Iram = (t_FMIramRegs *)UINT_TO_PTR(p_Fm->baseAddr + FM_MM_IMEM);
+ WRITE_UINT32(p_Iram->iadd, 0x4);
+ while (GET_UINT32(p_Iram->iadd) != 0x4) ;
+ revInfo = GET_UINT32(p_Iram->idata);
+ p_RevisionInfo->packageRev = (uint16_t)((revInfo & 0xFFFF0000) >> 16);
+ p_RevisionInfo->majorRev = (uint8_t)((revInfo & 0x0000FF00) >> 8);
+ p_RevisionInfo->minorRev = (uint8_t)(revInfo & 0x000000FF);
return E_OK;
}
uint32_t FM_GetCounter(t_Handle h_Fm, e_FmCounters counter)
{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
- t_Error err;
- uint32_t counterValue;
- t_FmIpcMsg msg;
- t_FmIpcReply reply;
- uint32_t replyLength, outCounter;
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+ t_Error err;
+ uint32_t counterValue;
+ struct fman_rg fman_rg;
+ enum fman_counters fsl_counter;
SANITY_CHECK_RETURN_VALUE(p_Fm, E_INVALID_HANDLE, 0);
SANITY_CHECK_RETURN_VALUE(!p_Fm->p_FmDriverParam, E_INVALID_STATE, 0);
+ fman_rg.bmi_rg = p_Fm->p_FmBmiRegs;
+ fman_rg.qmi_rg = p_Fm->p_FmQmiRegs;
+ fman_rg.fpm_rg = p_Fm->p_FmFpmRegs;
+ fman_rg.dma_rg = p_Fm->p_FmDmaRegs;
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ !p_Fm->baseAddr &&
+ p_Fm->h_IpcSessions[0])
{
+ t_FmIpcMsg msg;
+ t_FmIpcReply reply;
+ uint32_t replyLength, outCounter;
+
memset(&msg, 0, sizeof(msg));
memset(&reply, 0, sizeof(reply));
msg.msgId = FM_GET_COUNTER;
memcpy(msg.msgBody, (uint8_t *)&counter, sizeof(uint32_t));
replyLength = sizeof(uint32_t) + sizeof(uint32_t);
- if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
(uint8_t*)&msg,
sizeof(msg.msgId) +sizeof(counterValue),
(uint8_t*)&reply,
&replyLength,
NULL,
- NULL)) != E_OK)
- RETURN_ERROR(MAJOR, err, NO_MSG);
- if(replyLength != (sizeof(uint32_t) + sizeof(uint32_t)))
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
- memcpy((uint8_t*)&outCounter, reply.replyBody, sizeof(uint32_t));
+ NULL);
+ if (err != E_OK)
+ {
+ REPORT_ERROR(MAJOR, err, NO_MSG);
+ return 0;
+ }
+ if (replyLength != (sizeof(uint32_t) + sizeof(uint32_t)))
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("IPC reply length mismatch"));
+ return 0;
+ }
+ memcpy((uint8_t*)&outCounter, reply.replyBody, sizeof(uint32_t));
return outCounter;
- }
+ }
+ else if (!p_Fm->baseAddr)
+ {
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Either IPC or 'baseAddress' is required!"));
+ return 0;
+ }
- switch(counter)
+ /* When applicable (when there is an 'enable counters' bit,
+ check that counters are enabled */
+ switch (counter)
{
- case(e_FM_COUNTERS_ENQ_TOTAL_FRAME):
- return GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_etfc);
- case(e_FM_COUNTERS_DEQ_TOTAL_FRAME):
- return GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_dtfc);
- case(e_FM_COUNTERS_DEQ_0):
- return GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_dc0);
- case(e_FM_COUNTERS_DEQ_1):
- return GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_dc1);
- case(e_FM_COUNTERS_DEQ_2):
- return GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_dc2);
- case(e_FM_COUNTERS_DEQ_3):
- return GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_dc3);
- case(e_FM_COUNTERS_DEQ_FROM_DEFAULT):
- return GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_dfdc);
- case(e_FM_COUNTERS_DEQ_FROM_CONTEXT):
- return GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_dfcc);
- case(e_FM_COUNTERS_DEQ_FROM_FD):
- return GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_dffc);
- case(e_FM_COUNTERS_DEQ_CONFIRM):
- return GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_dcc);
- case(e_FM_COUNTERS_SEMAPHOR_ENTRY_FULL_REJECT):
- return GET_UINT32(p_Fm->p_FmDmaRegs->fmdmsefrc);
- case(e_FM_COUNTERS_SEMAPHOR_QUEUE_FULL_REJECT):
- return GET_UINT32(p_Fm->p_FmDmaRegs->fmdmsqfrc);
- case(e_FM_COUNTERS_SEMAPHOR_SYNC_REJECT):
- return GET_UINT32(p_Fm->p_FmDmaRegs->fmdmssrc);
+ case (e_FM_COUNTERS_DEQ_1):
+ case (e_FM_COUNTERS_DEQ_2):
+ case (e_FM_COUNTERS_DEQ_3):
+ if ((p_Fm->p_FmStateStruct->revInfo.majorRev == 4) ||
+ (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6))
+ {
+ REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Requested counter not supported"));
+ return 0;
+ }
+ case (e_FM_COUNTERS_ENQ_TOTAL_FRAME):
+ case (e_FM_COUNTERS_DEQ_TOTAL_FRAME):
+ case (e_FM_COUNTERS_DEQ_0):
+ case (e_FM_COUNTERS_DEQ_FROM_DEFAULT):
+ case (e_FM_COUNTERS_DEQ_FROM_CONTEXT):
+ case (e_FM_COUNTERS_DEQ_FROM_FD):
+ case (e_FM_COUNTERS_DEQ_CONFIRM):
+ if (!(GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_gc) & QMI_CFG_EN_COUNTERS))
+ {
+ REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Requested counter was not enabled"));
+ return 0;
+ }
+ break;
default:
break;
}
- /* should never get here */
- ASSERT_COND(FALSE);
- return 0;
+ FMAN_COUNTERS_TRANS(fsl_counter, counter);
+ return fman_get_counter(&fman_rg, fsl_counter);
}
-t_Error FM_ModifyCounter(t_Handle h_Fm, e_FmCounters counter, uint32_t val)
+t_Error FM_ModifyCounter(t_Handle h_Fm, e_FmCounters counter, uint32_t val)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
+ struct fman_rg fman_rg;
+ enum fman_counters fsl_counter;
- SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
-
- /* When applicable (when there is an 'enable counters' bit,
- check that counters are enabled */
- switch(counter)
- {
- case(e_FM_COUNTERS_ENQ_TOTAL_FRAME):
- case(e_FM_COUNTERS_DEQ_TOTAL_FRAME):
- case(e_FM_COUNTERS_DEQ_0):
- case(e_FM_COUNTERS_DEQ_1):
- case(e_FM_COUNTERS_DEQ_2):
- case(e_FM_COUNTERS_DEQ_3):
- case(e_FM_COUNTERS_DEQ_FROM_DEFAULT):
- case(e_FM_COUNTERS_DEQ_FROM_CONTEXT):
- case(e_FM_COUNTERS_DEQ_FROM_FD):
- case(e_FM_COUNTERS_DEQ_CONFIRM):
- if(!(GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_gc) & QMI_CFG_EN_COUNTERS))
- RETURN_ERROR(MINOR, E_INVALID_STATE, ("Requested counter was not enabled"));
- break;
- default:
- break;
- }
+ SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
- /* Set counter */
- switch(counter)
- {
- case(e_FM_COUNTERS_ENQ_TOTAL_FRAME):
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_etfc, val);
- break;
- case(e_FM_COUNTERS_DEQ_TOTAL_FRAME):
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_dtfc, val);
- break;
- case(e_FM_COUNTERS_DEQ_0):
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_dc0, val);
- break;
- case(e_FM_COUNTERS_DEQ_1):
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_dc1, val);
- break;
- case(e_FM_COUNTERS_DEQ_2):
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_dc2, val);
- break;
- case(e_FM_COUNTERS_DEQ_3):
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_dc3, val);
- break;
- case(e_FM_COUNTERS_DEQ_FROM_DEFAULT):
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_dfdc, val);
- break;
- case(e_FM_COUNTERS_DEQ_FROM_CONTEXT):
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_dfcc, val);
- break;
- case(e_FM_COUNTERS_DEQ_FROM_FD):
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_dffc, val);
- break;
- case(e_FM_COUNTERS_DEQ_CONFIRM):
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_dcc, val);
- break;
- case(e_FM_COUNTERS_SEMAPHOR_ENTRY_FULL_REJECT):
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmsefrc, val);
- break;
- case(e_FM_COUNTERS_SEMAPHOR_QUEUE_FULL_REJECT):
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmsqfrc, val);
- break;
- case(e_FM_COUNTERS_SEMAPHOR_SYNC_REJECT):
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmssrc, val);
- break;
- default:
- break;
- }
+ fman_rg.bmi_rg = p_Fm->p_FmBmiRegs;
+ fman_rg.qmi_rg = p_Fm->p_FmQmiRegs;
+ fman_rg.fpm_rg = p_Fm->p_FmFpmRegs;
+ fman_rg.dma_rg = p_Fm->p_FmDmaRegs;
- return E_OK;
+ FMAN_COUNTERS_TRANS(fsl_counter, counter);
+ return (t_Error)fman_modify_counter(&fman_rg, fsl_counter, val);
}
void FM_SetDmaEmergency(t_Handle h_Fm, e_FmDmaMuramPort muramPort, bool enable)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint32_t bitMask;
+ struct fman_dma_regs *dma_rg;
SANITY_CHECK_RETURN(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
- bitMask = (uint32_t)((muramPort==e_FM_DMA_MURAM_PORT_WRITE) ? DMA_MODE_EMERGENCY_WRITE : DMA_MODE_EMERGENCY_READ);
-
- if(enable)
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmmr, GET_UINT32(p_Fm->p_FmDmaRegs->fmdmmr) | bitMask);
- else /* disable */
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmmr, GET_UINT32(p_Fm->p_FmDmaRegs->fmdmmr) & ~bitMask);
+ dma_rg = p_Fm->p_FmDmaRegs;
- return;
+ fman_set_dma_emergency(dma_rg, !!(muramPort==e_FM_DMA_MURAM_PORT_WRITE), enable);
}
void FM_SetDmaExtBusPri(t_Handle h_Fm, e_FmDmaExtBusPri pri)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
+ struct fman_dma_regs *dma_rg;
SANITY_CHECK_RETURN(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
- WRITE_UINT32(p_Fm->p_FmDmaRegs->fmdmmr, GET_UINT32(p_Fm->p_FmDmaRegs->fmdmmr) | ((uint32_t)pri << DMA_MODE_BUS_PRI_SHIFT) );
+ dma_rg = p_Fm->p_FmDmaRegs;
- return;
+ fman_set_dma_ext_bus_pri(dma_rg, pri);
}
void FM_GetDmaStatus(t_Handle h_Fm, t_FmDmaStatus *p_FmDmaStatus)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint32_t tmpReg;
- t_Error err;
- t_FmIpcMsg msg;
- t_FmIpcReply reply;
- uint32_t replyLength;
- t_FmIpcDmaStatus ipcDmaStatus;
+ uint32_t dmaStatus;
+ struct fman_dma_regs *dma_rg;
SANITY_CHECK_RETURN(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ dma_rg = p_Fm->p_FmDmaRegs;
+
+ if ((p_Fm->guestId != NCSW_MASTER_ID) &&
+ !p_Fm->baseAddr &&
+ p_Fm->h_IpcSessions[0])
{
+ t_FmIpcDmaStatus ipcDmaStatus;
+ t_FmIpcMsg msg;
+ t_FmIpcReply reply;
+ t_Error err;
+ uint32_t replyLength;
+
memset(&msg, 0, sizeof(msg));
memset(&reply, 0, sizeof(reply));
msg.msgId = FM_DMA_STAT;
replyLength = sizeof(uint32_t) + sizeof(t_FmIpcDmaStatus);
- if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
- (uint8_t*)&msg,
- sizeof(msg.msgId),
- (uint8_t*)&reply,
- &replyLength,
- NULL,
- NULL)) != E_OK)
+ err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
+ (uint8_t*)&msg,
+ sizeof(msg.msgId),
+ (uint8_t*)&reply,
+ &replyLength,
+ NULL,
+ NULL);
+ if (err != E_OK)
{
REPORT_ERROR(MINOR, err, NO_MSG);
return;
@@ -4366,240 +4918,296 @@ void FM_GetDmaStatus(t_Handle h_Fm, t_FmDmaStatus *p_FmDmaStatus)
p_FmDmaStatus->readBufEccError = (bool)ipcDmaStatus.boolReadBufEccError; /**< Double ECC error on buffer Read */
p_FmDmaStatus->writeBufEccSysError =(bool)ipcDmaStatus.boolWriteBufEccSysError; /**< Double ECC error on buffer write from system side */
p_FmDmaStatus->writeBufEccFmError = (bool)ipcDmaStatus.boolWriteBufEccFmError; /**< Double ECC error on buffer write from FM side */
+ p_FmDmaStatus->singlePortEccError = (bool)ipcDmaStatus.boolSinglePortEccError; /**< Double ECC error on buffer write from FM side */
+ return;
+ }
+ else if (!p_Fm->baseAddr)
+ {
+ REPORT_ERROR(MINOR, E_NOT_SUPPORTED,
+ ("Either IPC or 'baseAddress' is required!"));
return;
}
- tmpReg = GET_UINT32(p_Fm->p_FmDmaRegs->fmdmsr);
+ dmaStatus = fman_get_dma_status(dma_rg);
- p_FmDmaStatus->cmqNotEmpty = (bool)(tmpReg & DMA_STATUS_CMD_QUEUE_NOT_EMPTY);
- p_FmDmaStatus->busError = (bool)(tmpReg & DMA_STATUS_BUS_ERR);
- p_FmDmaStatus->readBufEccError = (bool)(tmpReg & DMA_STATUS_READ_ECC);
- p_FmDmaStatus->writeBufEccSysError = (bool)(tmpReg & DMA_STATUS_SYSTEM_WRITE_ECC);
- p_FmDmaStatus->writeBufEccFmError = (bool)(tmpReg & DMA_STATUS_FM_WRITE_ECC);
- return;
+ p_FmDmaStatus->cmqNotEmpty = (bool)(dmaStatus & DMA_STATUS_CMD_QUEUE_NOT_EMPTY);
+ p_FmDmaStatus->busError = (bool)(dmaStatus & DMA_STATUS_BUS_ERR);
+ if (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6)
+ p_FmDmaStatus->singlePortEccError = (bool)(dmaStatus & DMA_STATUS_FM_SPDAT_ECC);
+ else
+ {
+ p_FmDmaStatus->readBufEccError = (bool)(dmaStatus & DMA_STATUS_READ_ECC);
+ p_FmDmaStatus->writeBufEccSysError = (bool)(dmaStatus & DMA_STATUS_SYSTEM_WRITE_ECC);
+ p_FmDmaStatus->writeBufEccFmError = (bool)(dmaStatus & DMA_STATUS_FM_WRITE_ECC);
+ }
}
-t_Error FM_ForceIntr (t_Handle h_Fm, e_FmExceptions exception)
+void FM_Resume(t_Handle h_Fm)
{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+ struct fman_fpm_regs *fpm_rg;
+
+ SANITY_CHECK_RETURN(p_Fm, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
+
+ fpm_rg = p_Fm->p_FmFpmRegs;
+
+ fman_resume(fpm_rg);
+}
+
+t_Error FM_GetSpecialOperationCoding(t_Handle h_Fm,
+ fmSpecialOperations_t spOper,
+ uint8_t *p_SpOperCoding)
+{
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+ t_FmCtrlCodeRevisionInfo revInfo;
+ t_Error err;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_SpOperCoding, E_NULL_POINTER);
- switch(exception)
+ if (!spOper)
{
- case e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID:
- if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_eif, QMI_ERR_INTR_EN_DEQ_FROM_DEF);
- break;
- case e_FM_EX_QMI_SINGLE_ECC:
- if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_QMI_SINGLE_ECC))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_if, QMI_INTR_EN_SINGLE_ECC);
- break;
- case e_FM_EX_QMI_DOUBLE_ECC:
- if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_QMI_DOUBLE_ECC))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
- WRITE_UINT32(p_Fm->p_FmQmiRegs->fmqm_eif, QMI_ERR_INTR_EN_DOUBLE_ECC);
- break;
- case e_FM_EX_BMI_LIST_RAM_ECC:
- if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_BMI_LIST_RAM_ECC))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_ifr, BMI_ERR_INTR_EN_LIST_RAM_ECC);
- break;
- case e_FM_EX_BMI_PIPELINE_ECC:
- if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_BMI_PIPELINE_ECC))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_ifr, BMI_ERR_INTR_EN_PIPELINE_ECC);
- break;
- case e_FM_EX_BMI_STATISTICS_RAM_ECC:
- if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_BMI_STATISTICS_RAM_ECC))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_ifr, BMI_ERR_INTR_EN_STATISTICS_RAM_ECC);
- break;
- case e_FM_EX_BMI_DISPATCH_RAM_ECC:
- if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_BMI_DISPATCH_RAM_ECC))
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
- WRITE_UINT32(p_Fm->p_FmBmiRegs->fmbm_ifr, BMI_ERR_INTR_EN_DISPATCH_RAM_ECC);
- break;
+ *p_SpOperCoding = 0;
+ return E_OK;
+ }
+
+ if ((err = FM_GetFmanCtrlCodeRevision(p_Fm, &revInfo)) != E_OK)
+ {
+ DBG(WARNING, ("FM in guest-mode without IPC, can't validate firmware revision."));
+ revInfo.packageRev = IP_OFFLOAD_PACKAGE_NUMBER;
+ }
+ else if (!IS_OFFLOAD_PACKAGE(revInfo.packageRev))
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("Fman ctrl code package"));
+
+ switch (spOper)
+ {
+ case (FM_SP_OP_CAPWAP_DTLS_DEC):
+ *p_SpOperCoding = 9;
+ break;
+ case (FM_SP_OP_CAPWAP_DTLS_ENC):
+ *p_SpOperCoding = 10;
+ break;
+ case (FM_SP_OP_IPSEC|FM_SP_OP_IPSEC_UPDATE_UDP_LEN|FM_SP_OP_IPSEC_MANIP):
+ case (FM_SP_OP_IPSEC|FM_SP_OP_IPSEC_UPDATE_UDP_LEN|FM_SP_OP_IPSEC_MANIP|FM_SP_OP_RPD):
+ *p_SpOperCoding = 5;
+ break;
+ case (FM_SP_OP_IPSEC|FM_SP_OP_IPSEC_MANIP):
+ case (FM_SP_OP_IPSEC|FM_SP_OP_IPSEC_MANIP|FM_SP_OP_RPD):
+ *p_SpOperCoding = 6;
+ break;
+ case (FM_SP_OP_IPSEC|FM_SP_OP_IPSEC_UPDATE_UDP_LEN|FM_SP_OP_RPD):
+ *p_SpOperCoding = 3;
+ break;
+ case (FM_SP_OP_IPSEC|FM_SP_OP_IPSEC_UPDATE_UDP_LEN):
+ *p_SpOperCoding = 1;
+ break;
+ case (FM_SP_OP_IPSEC|FM_SP_OP_IPSEC_UPDATE_UDP_LEN|FM_SP_OP_IPSEC_NO_ETH_HDR):
+ *p_SpOperCoding = 12;
+ break;
+ case (FM_SP_OP_IPSEC|FM_SP_OP_RPD):
+ *p_SpOperCoding = 4;
+ break;
+ case (FM_SP_OP_IPSEC):
+ *p_SpOperCoding = 2;
+ break;
+ case (FM_SP_OP_DCL4C):
+ *p_SpOperCoding = 7;
+ break;
+ case (FM_SP_OP_CLEAR_RPD):
+ *p_SpOperCoding = 8;
+ break;
default:
- RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception may not be forced"));
+ RETURN_ERROR(MINOR, E_INVALID_VALUE, NO_MSG);
}
return E_OK;
}
-void FM_Resume(t_Handle h_Fm)
+t_Error FM_CtrlMonStart(t_Handle h_Fm)
{
- t_Fm *p_Fm = (t_Fm*)h_Fm;
- uint32_t tmpReg;
+ t_Fm *p_Fm = (t_Fm *)h_Fm;
+ t_FmTrbRegs *p_MonRegs;
+ uint8_t i;
- SANITY_CHECK_RETURN(p_Fm, E_INVALID_HANDLE);
- SANITY_CHECK_RETURN(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
- if (p_Fm->guestId == NCSW_MASTER_ID)
+ WRITE_UINT32(p_Fm->p_FmFpmRegs->fmfp_brkc,
+ GET_UINT32(p_Fm->p_FmFpmRegs->fmfp_brkc) | FPM_BRKC_RDBG);
+
+ for (i = 0; i < FM_NUM_OF_CTRL; i++)
{
- tmpReg = GET_UINT32(p_Fm->p_FmFpmRegs->fpmem);
- /* clear tmpReg event bits in order not to clear standing events */
- tmpReg &= ~(FPM_EV_MASK_DOUBLE_ECC | FPM_EV_MASK_STALL | FPM_EV_MASK_SINGLE_ECC);
- WRITE_UINT32(p_Fm->p_FmFpmRegs->fpmem, tmpReg | FPM_EV_MASK_RELEASE_FM);
+ p_MonRegs = (t_FmTrbRegs *)UINT_TO_PTR(p_Fm->baseAddr + FM_MM_TRB(i));
+
+ /* Reset control registers */
+ WRITE_UINT32(p_MonRegs->tcrh, TRB_TCRH_RESET);
+ WRITE_UINT32(p_MonRegs->tcrl, TRB_TCRL_RESET);
+
+ /* Configure: counter #1 counts all stalls in risc - ldsched stall
+ counter #2 counts all stalls in risc - other stall*/
+ WRITE_UINT32(p_MonRegs->tcrl, TRB_TCRL_RESET | TRB_TCRL_UTIL);
+
+ /* Enable monitoring */
+ WRITE_UINT32(p_MonRegs->tcrh, TRB_TCRH_ENABLE_COUNTERS);
}
- else
- ASSERT_COND(0); /* TODO */
+
+ return E_OK;
}
-#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
-t_Error FM_DumpRegs(t_Handle h_Fm)
+t_Error FM_CtrlMonStop(t_Handle h_Fm)
{
t_Fm *p_Fm = (t_Fm *)h_Fm;
- uint8_t i = 0;
- t_Error err;
- t_FmIpcMsg msg;
-
- DECLARE_DUMP;
+ t_FmTrbRegs *p_MonRegs;
+ uint8_t i;
SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
-
- if(p_Fm->guestId != NCSW_MASTER_ID)
+ for (i = 0; i < FM_NUM_OF_CTRL; i++)
{
- memset(&msg, 0, sizeof(msg));
- msg.msgId = FM_DUMP_REGS;
- if ((err = XX_IpcSendMessage(p_Fm->h_IpcSessions[0],
- (uint8_t*)&msg,
- sizeof(msg.msgId),
- NULL,
- NULL,
- NULL,
- NULL)) != E_OK)
- RETURN_ERROR(MINOR, err, NO_MSG);
- return E_OK;
+ p_MonRegs = (t_FmTrbRegs *)UINT_TO_PTR(p_Fm->baseAddr + FM_MM_TRB(i));
+ WRITE_UINT32(p_MonRegs->tcrh, TRB_TCRH_DISABLE_COUNTERS);
}
+ WRITE_UINT32(p_Fm->p_FmFpmRegs->fmfp_brkc,
+ GET_UINT32(p_Fm->p_FmFpmRegs->fmfp_brkc) & ~FPM_BRKC_RDBG);
- DUMP_SUBTITLE(("\n"));
+ return E_OK;
+}
- DUMP_TITLE(p_Fm->p_FmFpmRegs, ("FmFpmRegs Regs"));
+t_Error FM_CtrlMonGetCounters(t_Handle h_Fm, uint8_t fmCtrlIndex, t_FmCtrlMon *p_Mon)
+{
+ t_Fm *p_Fm = (t_Fm *)h_Fm;
+ t_FmTrbRegs *p_MonRegs;
+ uint64_t clkCnt, utilValue, effValue;
- DUMP_VAR(p_Fm->p_FmFpmRegs,fpmtnc);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fpmpr);
- DUMP_VAR(p_Fm->p_FmFpmRegs,brkc);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fpmflc);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fpmdis1);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fpmdis2);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fmepi);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fmrie);
+ SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR((p_Fm->guestId == NCSW_MASTER_ID), E_NOT_SUPPORTED);
+ SANITY_CHECK_RETURN_ERROR(p_Mon, E_NULL_POINTER);
- DUMP_TITLE(&p_Fm->p_FmFpmRegs->fmfpfcev, ("fmfpfcev"));
- DUMP_SUBSTRUCT_ARRAY(i, 4)
- {
- DUMP_MEMORY(&p_Fm->p_FmFpmRegs->fmfpfcev[i], sizeof(uint32_t));
- }
+ if (fmCtrlIndex >= FM_NUM_OF_CTRL)
+ RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("FM Controller index"));
- DUMP_TITLE(&p_Fm->p_FmFpmRegs->fmfpfcee, ("fmfpfcee"));
- DUMP_SUBSTRUCT_ARRAY(i, 4)
- {
- DUMP_MEMORY(&p_Fm->p_FmFpmRegs->fmfpfcee[i], sizeof(uint32_t));
- }
+ p_MonRegs = (t_FmTrbRegs *)UINT_TO_PTR(p_Fm->baseAddr + FM_MM_TRB(fmCtrlIndex));
- DUMP_SUBTITLE(("\n"));
- DUMP_VAR(p_Fm->p_FmFpmRegs,fpmtsc1);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fpmtsc2);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fpmtsp);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fpmtsf);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fmrcr);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fpmextc);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fpmext1);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fpmext2);
+ clkCnt = (uint64_t)
+ ((uint64_t)GET_UINT32(p_MonRegs->tpcch) << 32 | GET_UINT32(p_MonRegs->tpccl));
- DUMP_TITLE(&p_Fm->p_FmFpmRegs->fpmdrd, ("fpmdrd"));
- DUMP_SUBSTRUCT_ARRAY(i, 16)
- {
- DUMP_MEMORY(&p_Fm->p_FmFpmRegs->fpmdrd[i], sizeof(uint32_t));
- }
+ utilValue = (uint64_t)
+ ((uint64_t)GET_UINT32(p_MonRegs->tpc1h) << 32 | GET_UINT32(p_MonRegs->tpc1l));
- DUMP_SUBTITLE(("\n"));
- DUMP_VAR(p_Fm->p_FmFpmRegs,fpmdra);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fm_ip_rev_1);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fm_ip_rev_2);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fmrstc);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fmcld);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fmnpi);
- DUMP_VAR(p_Fm->p_FmFpmRegs,fpmem);
+ effValue = (uint64_t)
+ ((uint64_t)GET_UINT32(p_MonRegs->tpc2h) << 32 | GET_UINT32(p_MonRegs->tpc2l));
- DUMP_TITLE(&p_Fm->p_FmFpmRegs->fpmcev, ("fpmcev"));
- DUMP_SUBSTRUCT_ARRAY(i, 4)
- {
- DUMP_MEMORY(&p_Fm->p_FmFpmRegs->fpmcev[i], sizeof(uint32_t));
- }
+ p_Mon->percentCnt[0] = (uint8_t)(((clkCnt - utilValue) * 100) / clkCnt);
+ if (clkCnt != utilValue)
+ p_Mon->percentCnt[1] = (uint8_t)((((clkCnt - utilValue) - effValue) * 100) / (clkCnt - utilValue));
+ else
+ p_Mon->percentCnt[1] = 0;
- DUMP_TITLE(&p_Fm->p_FmFpmRegs->fmfp_ps, ("fmfp_ps"));
- DUMP_SUBSTRUCT_ARRAY(i, 64)
- {
- DUMP_MEMORY(&p_Fm->p_FmFpmRegs->fmfp_ps[i], sizeof(uint32_t));
- }
-
-
- DUMP_TITLE(p_Fm->p_FmDmaRegs, ("p_FmDmaRegs Regs"));
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmsr);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmmr);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmtr);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmhy);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmsetr);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmtah);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmtal);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmtcid);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmra);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmrd);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmwcr);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmebcr);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmccqdr);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmccqvr1);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmccqvr2);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmcqvr3);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmcqvr4);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmcqvr5);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmsefrc);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmsqfrc);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmssrc);
- DUMP_VAR(p_Fm->p_FmDmaRegs,fmdmdcr);
-
- DUMP_TITLE(&p_Fm->p_FmDmaRegs->fmdmplr, ("fmdmplr"));
-
- DUMP_SUBSTRUCT_ARRAY(i, FM_SIZE_OF_LIODN_TABLE/2)
- {
- DUMP_MEMORY(&p_Fm->p_FmDmaRegs->fmdmplr[i], sizeof(uint32_t));
- }
+ return E_OK;
+}
+
+t_Handle FM_GetMuramHandle(t_Handle h_Fm)
+{
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
- DUMP_TITLE(p_Fm->p_FmBmiRegs, ("p_FmBmiRegs COMMON Regs"));
- DUMP_VAR(p_Fm->p_FmBmiRegs,fmbm_init);
- DUMP_VAR(p_Fm->p_FmBmiRegs,fmbm_cfg1);
- DUMP_VAR(p_Fm->p_FmBmiRegs,fmbm_cfg2);
- DUMP_VAR(p_Fm->p_FmBmiRegs,fmbm_ievr);
- DUMP_VAR(p_Fm->p_FmBmiRegs,fmbm_ier);
+ SANITY_CHECK_RETURN_VALUE(p_Fm, E_INVALID_HANDLE, NULL);
- DUMP_TITLE(&p_Fm->p_FmBmiRegs->fmbm_arb, ("fmbm_arb"));
- DUMP_SUBSTRUCT_ARRAY(i, 8)
+ return (p_Fm->h_FmMuram);
+}
+
+/****************************************************/
+/* Hidden-DEBUG Only API */
+/****************************************************/
+t_Error FM_ForceIntr (t_Handle h_Fm, e_FmExceptions exception)
+{
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+ enum fman_exceptions fslException;
+ struct fman_rg fman_rg;
+
+ SANITY_CHECK_RETURN_ERROR(p_Fm, E_INVALID_HANDLE);
+ SANITY_CHECK_RETURN_ERROR(!p_Fm->p_FmDriverParam, E_INVALID_STATE);
+
+ fman_rg.bmi_rg = p_Fm->p_FmBmiRegs;
+ fman_rg.qmi_rg = p_Fm->p_FmQmiRegs;
+ fman_rg.fpm_rg = p_Fm->p_FmFpmRegs;
+ fman_rg.dma_rg = p_Fm->p_FmDmaRegs;
+
+ switch (exception)
{
- DUMP_MEMORY(&p_Fm->p_FmBmiRegs->fmbm_arb[i], sizeof(uint32_t));
- }
+ case e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID:
+ if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID))
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
+ break;
+ case e_FM_EX_QMI_SINGLE_ECC:
+ if (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6)
+ RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("e_FM_EX_QMI_SINGLE_ECC not supported on this integration."));
+ if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_QMI_SINGLE_ECC))
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
+ break;
+ case e_FM_EX_QMI_DOUBLE_ECC:
+ if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_QMI_DOUBLE_ECC))
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
+ break;
+ case e_FM_EX_BMI_LIST_RAM_ECC:
+ if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_BMI_LIST_RAM_ECC))
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
+ break;
+ case e_FM_EX_BMI_STORAGE_PROFILE_ECC:
+ if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_BMI_STORAGE_PROFILE_ECC))
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
+ break;
+ case e_FM_EX_BMI_STATISTICS_RAM_ECC:
+ if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_BMI_STATISTICS_RAM_ECC))
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
+ break;
+ case e_FM_EX_BMI_DISPATCH_RAM_ECC:
+ if (!(p_Fm->p_FmStateStruct->exceptions & FM_EX_BMI_DISPATCH_RAM_ECC))
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception is masked"));
+ break;
+ default:
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, ("The selected exception may not be forced"));
+ }
- DUMP_TITLE(p_Fm->p_FmQmiRegs, ("p_FmQmiRegs COMMON Regs"));
- DUMP_VAR(p_Fm->p_FmQmiRegs,fmqm_gc);
- DUMP_VAR(p_Fm->p_FmQmiRegs,fmqm_eie);
- DUMP_VAR(p_Fm->p_FmQmiRegs,fmqm_eien);
- DUMP_VAR(p_Fm->p_FmQmiRegs,fmqm_eif);
- DUMP_VAR(p_Fm->p_FmQmiRegs,fmqm_ie);
- DUMP_VAR(p_Fm->p_FmQmiRegs,fmqm_ien);
- DUMP_VAR(p_Fm->p_FmQmiRegs,fmqm_if);
- DUMP_VAR(p_Fm->p_FmQmiRegs,fmqm_gs);
- DUMP_VAR(p_Fm->p_FmQmiRegs,fmqm_ts);
- DUMP_VAR(p_Fm->p_FmQmiRegs,fmqm_etfc);
+ fslException = FmanExceptionTrans(exception);
+ fman_force_intr (&fman_rg, fslException);
return E_OK;
}
-#endif /* (defined(DEBUG_ERRORS) && ... */
+t_Handle FmGetPcd(t_Handle h_Fm)
+{
+ return ((t_Fm*)h_Fm)->h_Pcd;
+}
+#if (DPAA_VERSION >= 11)
+extern void *g_MemacRegs;
+void fm_clk_down(void);
+uint32_t fman_memac_get_event(void *regs, uint32_t ev_mask);
+void FM_ChangeClock(t_Handle h_Fm, int hardwarePortId)
+{
+ int macId;
+ uint32_t event, rcr;
+ t_Fm *p_Fm = (t_Fm*)h_Fm;
+ rcr = GET_UINT32(p_Fm->p_FmFpmRegs->fm_rcr);
+ rcr |= 0x04000000;
+ WRITE_UINT32(p_Fm->p_FmFpmRegs->fm_rcr, rcr);
+
+ HW_PORT_ID_TO_SW_PORT_ID(macId, hardwarePortId);
+ do
+ {
+ event = fman_memac_get_event(g_MemacRegs, 0xFFFFFFFF);
+ } while ((event & 0x00000020) == 0);
+ fm_clk_down();
+ rcr = GET_UINT32(p_Fm->p_FmFpmRegs->fm_rcr);
+ rcr &= ~0x04000000;
+ WRITE_UINT32(p_Fm->p_FmFpmRegs->fm_rcr, rcr);
+}
+#endif
diff --git a/sys/contrib/ncsw/Peripherals/FM/fm.h b/sys/contrib/ncsw/Peripherals/FM/fm.h
index cd61d9661701..d0f96d66851d 100644
--- a/sys/contrib/ncsw/Peripherals/FM/fm.h
+++ b/sys/contrib/ncsw/Peripherals/FM/fm.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm.h
@@ -43,6 +44,7 @@
#include "fm_ext.h"
#include "fm_ipc.h"
+#include "fsl_fman.h"
#define __ERR_MODULE__ MODULE_FM
@@ -63,80 +65,221 @@
#define FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID 0x00800000 /**< Dequeu from default queue id */
#define FM_EX_QMI_DOUBLE_ECC 0x00400000
#define FM_EX_BMI_LIST_RAM_ECC 0x00200000
-#define FM_EX_BMI_PIPELINE_ECC 0x00100000
+#define FM_EX_BMI_STORAGE_PROFILE_ECC 0x00100000
#define FM_EX_BMI_STATISTICS_RAM_ECC 0x00080000
#define FM_EX_IRAM_ECC 0x00040000
-#define FM_EX_NURAM_ECC 0x00020000
+#define FM_EX_MURAM_ECC 0x00020000
#define FM_EX_BMI_DISPATCH_RAM_ECC 0x00010000
-
-#define GET_EXCEPTION_FLAG(bitMask, exception) switch(exception){ \
- case e_FM_EX_DMA_BUS_ERROR: \
- bitMask = FM_EX_DMA_BUS_ERROR; break; \
- case e_FM_EX_DMA_READ_ECC: \
- bitMask = FM_EX_DMA_READ_ECC; break; \
- case e_FM_EX_DMA_SYSTEM_WRITE_ECC: \
- bitMask = FM_EX_DMA_SYSTEM_WRITE_ECC; break; \
- case e_FM_EX_DMA_FM_WRITE_ECC: \
- bitMask = FM_EX_DMA_FM_WRITE_ECC; break; \
- case e_FM_EX_FPM_STALL_ON_TASKS: \
- bitMask = FM_EX_FPM_STALL_ON_TASKS; break; \
- case e_FM_EX_FPM_SINGLE_ECC: \
- bitMask = FM_EX_FPM_SINGLE_ECC; break; \
- case e_FM_EX_FPM_DOUBLE_ECC: \
- bitMask = FM_EX_FPM_DOUBLE_ECC; break; \
- case e_FM_EX_QMI_SINGLE_ECC: \
- bitMask = FM_EX_QMI_SINGLE_ECC; break; \
- case e_FM_EX_QMI_DOUBLE_ECC: \
- bitMask = FM_EX_QMI_DOUBLE_ECC; break; \
- case e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID: \
- bitMask = FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID; break; \
- case e_FM_EX_BMI_LIST_RAM_ECC: \
- bitMask = FM_EX_BMI_LIST_RAM_ECC; break; \
- case e_FM_EX_BMI_PIPELINE_ECC: \
- bitMask = FM_EX_BMI_PIPELINE_ECC; break; \
- case e_FM_EX_BMI_STATISTICS_RAM_ECC: \
- bitMask = FM_EX_BMI_STATISTICS_RAM_ECC; break; \
- case e_FM_EX_BMI_DISPATCH_RAM_ECC: \
- bitMask = FM_EX_BMI_DISPATCH_RAM_ECC; break; \
- case e_FM_EX_IRAM_ECC: \
- bitMask = FM_EX_IRAM_ECC; break; \
- case e_FM_EX_MURAM_ECC: \
- bitMask = FM_EX_NURAM_ECC; break; \
- default: bitMask = 0;break;}
+#define FM_EX_DMA_SINGLE_PORT_ECC 0x00008000
+
+#define DMA_EMSR_EMSTR_MASK 0x0000FFFF
+
+#define DMA_THRESH_COMMQ_MASK 0xFF000000
+#define DMA_THRESH_READ_INT_BUF_MASK 0x007F0000
+#define DMA_THRESH_WRITE_INT_BUF_MASK 0x0000007F
+
+#define GET_EXCEPTION_FLAG(bitMask, exception) \
+switch (exception){ \
+ case e_FM_EX_DMA_BUS_ERROR: \
+ bitMask = FM_EX_DMA_BUS_ERROR; break; \
+ case e_FM_EX_DMA_SINGLE_PORT_ECC: \
+ bitMask = FM_EX_DMA_SINGLE_PORT_ECC; break; \
+ case e_FM_EX_DMA_READ_ECC: \
+ bitMask = FM_EX_DMA_READ_ECC; break; \
+ case e_FM_EX_DMA_SYSTEM_WRITE_ECC: \
+ bitMask = FM_EX_DMA_SYSTEM_WRITE_ECC; break; \
+ case e_FM_EX_DMA_FM_WRITE_ECC: \
+ bitMask = FM_EX_DMA_FM_WRITE_ECC; break; \
+ case e_FM_EX_FPM_STALL_ON_TASKS: \
+ bitMask = FM_EX_FPM_STALL_ON_TASKS; break; \
+ case e_FM_EX_FPM_SINGLE_ECC: \
+ bitMask = FM_EX_FPM_SINGLE_ECC; break; \
+ case e_FM_EX_FPM_DOUBLE_ECC: \
+ bitMask = FM_EX_FPM_DOUBLE_ECC; break; \
+ case e_FM_EX_QMI_SINGLE_ECC: \
+ bitMask = FM_EX_QMI_SINGLE_ECC; break; \
+ case e_FM_EX_QMI_DOUBLE_ECC: \
+ bitMask = FM_EX_QMI_DOUBLE_ECC; break; \
+ case e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID: \
+ bitMask = FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID; break; \
+ case e_FM_EX_BMI_LIST_RAM_ECC: \
+ bitMask = FM_EX_BMI_LIST_RAM_ECC; break; \
+ case e_FM_EX_BMI_STORAGE_PROFILE_ECC: \
+ bitMask = FM_EX_BMI_STORAGE_PROFILE_ECC; break; \
+ case e_FM_EX_BMI_STATISTICS_RAM_ECC: \
+ bitMask = FM_EX_BMI_STATISTICS_RAM_ECC; break; \
+ case e_FM_EX_BMI_DISPATCH_RAM_ECC: \
+ bitMask = FM_EX_BMI_DISPATCH_RAM_ECC; break; \
+ case e_FM_EX_IRAM_ECC: \
+ bitMask = FM_EX_IRAM_ECC; break; \
+ case e_FM_EX_MURAM_ECC: \
+ bitMask = FM_EX_MURAM_ECC; break; \
+ default: bitMask = 0;break; \
+}
+
+#define GET_FM_MODULE_EVENT(_mod, _id, _intrType, _event) \
+ switch (_mod) { \
+ case e_FM_MOD_PRS: \
+ if (_id) _event = e_FM_EV_DUMMY_LAST; \
+ else _event = (_intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_ERR_PRS : e_FM_EV_PRS; \
+ break; \
+ case e_FM_MOD_KG: \
+ if (_id) _event = e_FM_EV_DUMMY_LAST; \
+ else _event = (_intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_ERR_KG : e_FM_EV_DUMMY_LAST; \
+ break; \
+ case e_FM_MOD_PLCR: \
+ if (_id) _event = e_FM_EV_DUMMY_LAST; \
+ else _event = (_intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_ERR_PLCR : e_FM_EV_PLCR; \
+ break; \
+ case e_FM_MOD_TMR: \
+ if (_id) _event = e_FM_EV_DUMMY_LAST; \
+ else _event = (_intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_DUMMY_LAST : e_FM_EV_TMR; \
+ break; \
+ case e_FM_MOD_10G_MAC: \
+ if (_id >= FM_MAX_NUM_OF_10G_MACS) _event = e_FM_EV_DUMMY_LAST; \
+ else _event = (_intrType == e_FM_INTR_TYPE_ERR) ? (e_FM_EV_ERR_10G_MAC0 + _id) : (e_FM_EV_10G_MAC0 + _id); \
+ break; \
+ case e_FM_MOD_1G_MAC: \
+ if (_id >= FM_MAX_NUM_OF_1G_MACS) _event = e_FM_EV_DUMMY_LAST; \
+ else _event = (_intrType == e_FM_INTR_TYPE_ERR) ? (e_FM_EV_ERR_1G_MAC0 + _id) : (e_FM_EV_1G_MAC0 + _id); \
+ break; \
+ case e_FM_MOD_MACSEC: \
+ switch (_id){ \
+ case (0): _event = (_intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_ERR_MACSEC_MAC0:e_FM_EV_MACSEC_MAC0; \
+ break; \
+ } \
+ break; \
+ case e_FM_MOD_FMAN_CTRL: \
+ if (_intrType == e_FM_INTR_TYPE_ERR) _event = e_FM_EV_DUMMY_LAST; \
+ else _event = (e_FM_EV_FMAN_CTRL_0 + _id); \
+ break; \
+ default: _event = e_FM_EV_DUMMY_LAST; \
+ break; \
+ }
+
+#define FMAN_CACHE_OVERRIDE_TRANS(fsl_cache_override, _cache_override) \
+ switch (_cache_override){ \
+ case e_FM_DMA_NO_CACHE_OR: \
+ fsl_cache_override = E_FMAN_DMA_NO_CACHE_OR; break; \
+ case e_FM_DMA_NO_STASH_DATA: \
+ fsl_cache_override = E_FMAN_DMA_NO_STASH_DATA; break; \
+ case e_FM_DMA_MAY_STASH_DATA: \
+ fsl_cache_override = E_FMAN_DMA_MAY_STASH_DATA; break; \
+ case e_FM_DMA_STASH_DATA: \
+ fsl_cache_override = E_FMAN_DMA_STASH_DATA; break; \
+ default: \
+ fsl_cache_override = E_FMAN_DMA_NO_CACHE_OR; break; \
+ }
+
+#define FMAN_AID_MODE_TRANS(fsl_aid_mode, _aid_mode) \
+ switch (_aid_mode){ \
+ case e_FM_DMA_AID_OUT_PORT_ID: \
+ fsl_aid_mode = E_FMAN_DMA_AID_OUT_PORT_ID; break; \
+ case e_FM_DMA_AID_OUT_TNUM: \
+ fsl_aid_mode = E_FMAN_DMA_AID_OUT_TNUM; break; \
+ default: \
+ fsl_aid_mode = E_FMAN_DMA_AID_OUT_PORT_ID; break; \
+ }
+
+#define FMAN_DMA_DBG_CNT_TRANS(fsl_dma_dbg_cnt, _dma_dbg_cnt) \
+ switch (_dma_dbg_cnt){ \
+ case e_FM_DMA_DBG_NO_CNT: \
+ fsl_dma_dbg_cnt = E_FMAN_DMA_DBG_NO_CNT; break; \
+ case e_FM_DMA_DBG_CNT_DONE: \
+ fsl_dma_dbg_cnt = E_FMAN_DMA_DBG_CNT_DONE; break; \
+ case e_FM_DMA_DBG_CNT_COMM_Q_EM: \
+ fsl_dma_dbg_cnt = E_FMAN_DMA_DBG_CNT_COMM_Q_EM; break; \
+ case e_FM_DMA_DBG_CNT_INT_READ_EM: \
+ fsl_dma_dbg_cnt = E_FMAN_DMA_DBG_CNT_INT_READ_EM; break; \
+ case e_FM_DMA_DBG_CNT_INT_WRITE_EM: \
+ fsl_dma_dbg_cnt = E_FMAN_DMA_DBG_CNT_INT_WRITE_EM ; break; \
+ case e_FM_DMA_DBG_CNT_FPM_WAIT: \
+ fsl_dma_dbg_cnt = E_FMAN_DMA_DBG_CNT_FPM_WAIT ; break; \
+ case e_FM_DMA_DBG_CNT_SIGLE_BIT_ECC: \
+ fsl_dma_dbg_cnt = E_FMAN_DMA_DBG_CNT_SIGLE_BIT_ECC ; break; \
+ case e_FM_DMA_DBG_CNT_RAW_WAR_PROT: \
+ fsl_dma_dbg_cnt = E_FMAN_DMA_DBG_CNT_RAW_WAR_PROT ; break; \
+ default: \
+ fsl_dma_dbg_cnt = E_FMAN_DMA_DBG_NO_CNT; break; \
+ }
+
+#define FMAN_DMA_EMER_TRANS(fsl_dma_emer, _dma_emer) \
+ switch (_dma_emer){ \
+ case e_FM_DMA_EM_EBS: \
+ fsl_dma_emer = E_FMAN_DMA_EM_EBS; break; \
+ case e_FM_DMA_EM_SOS: \
+ fsl_dma_emer = E_FMAN_DMA_EM_SOS; break; \
+ default: \
+ fsl_dma_emer = E_FMAN_DMA_EM_EBS; break; \
+ }
+
+#define FMAN_DMA_ERR_TRANS(fsl_dma_err, _dma_err) \
+ switch (_dma_err){ \
+ case e_FM_DMA_ERR_CATASTROPHIC: \
+ fsl_dma_err = E_FMAN_DMA_ERR_CATASTROPHIC; break; \
+ case e_FM_DMA_ERR_REPORT: \
+ fsl_dma_err = E_FMAN_DMA_ERR_REPORT; break; \
+ default: \
+ fsl_dma_err = E_FMAN_DMA_ERR_CATASTROPHIC; break; \
+ }
+
+#define FMAN_CATASTROPHIC_ERR_TRANS(fsl_catastrophic_err, _catastrophic_err) \
+ switch (_catastrophic_err){ \
+ case e_FM_CATASTROPHIC_ERR_STALL_PORT: \
+ fsl_catastrophic_err = E_FMAN_CATAST_ERR_STALL_PORT; break; \
+ case e_FM_CATASTROPHIC_ERR_STALL_TASK: \
+ fsl_catastrophic_err = E_FMAN_CATAST_ERR_STALL_TASK; break; \
+ default: \
+ fsl_catastrophic_err = E_FMAN_CATAST_ERR_STALL_PORT; break; \
+ }
+
+#define FMAN_COUNTERS_TRANS(fsl_counters, _counters) \
+ switch (_counters){ \
+ case e_FM_COUNTERS_ENQ_TOTAL_FRAME: \
+ fsl_counters = E_FMAN_COUNTERS_ENQ_TOTAL_FRAME; break; \
+ case e_FM_COUNTERS_DEQ_TOTAL_FRAME: \
+ fsl_counters = E_FMAN_COUNTERS_DEQ_TOTAL_FRAME; break; \
+ case e_FM_COUNTERS_DEQ_0: \
+ fsl_counters = E_FMAN_COUNTERS_DEQ_0; break; \
+ case e_FM_COUNTERS_DEQ_1: \
+ fsl_counters = E_FMAN_COUNTERS_DEQ_1; break; \
+ case e_FM_COUNTERS_DEQ_2: \
+ fsl_counters = E_FMAN_COUNTERS_DEQ_2; break; \
+ case e_FM_COUNTERS_DEQ_3: \
+ fsl_counters = E_FMAN_COUNTERS_DEQ_3; break; \
+ case e_FM_COUNTERS_DEQ_FROM_DEFAULT: \
+ fsl_counters = E_FMAN_COUNTERS_DEQ_FROM_DEFAULT; break; \
+ case e_FM_COUNTERS_DEQ_FROM_CONTEXT: \
+ fsl_counters = E_FMAN_COUNTERS_DEQ_FROM_CONTEXT; break; \
+ case e_FM_COUNTERS_DEQ_FROM_FD: \
+ fsl_counters = E_FMAN_COUNTERS_DEQ_FROM_FD; break; \
+ case e_FM_COUNTERS_DEQ_CONFIRM: \
+ fsl_counters = E_FMAN_COUNTERS_DEQ_CONFIRM; break; \
+ default: \
+ fsl_counters = E_FMAN_COUNTERS_ENQ_TOTAL_FRAME; break; \
+ }
/**************************************************************************//**
@Description defaults
*//***************************************************************************/
-#define DEFAULT_exceptions (FM_EX_DMA_BUS_ERROR |\
+#define DEFAULT_exceptions (FM_EX_DMA_BUS_ERROR |\
FM_EX_DMA_READ_ECC |\
FM_EX_DMA_SYSTEM_WRITE_ECC |\
FM_EX_DMA_FM_WRITE_ECC |\
FM_EX_FPM_STALL_ON_TASKS |\
FM_EX_FPM_SINGLE_ECC |\
FM_EX_FPM_DOUBLE_ECC |\
- FM_EX_QMI_SINGLE_ECC |\
FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID|\
- FM_EX_QMI_DOUBLE_ECC |\
FM_EX_BMI_LIST_RAM_ECC |\
- FM_EX_BMI_PIPELINE_ECC |\
+ FM_EX_BMI_STORAGE_PROFILE_ECC |\
FM_EX_BMI_STATISTICS_RAM_ECC |\
- FM_EX_BMI_DISPATCH_RAM_ECC |\
FM_EX_IRAM_ECC |\
- FM_EX_NURAM_ECC )
-#define DEFAULT_totalNumOfTasks (BMI_MAX_NUM_OF_TASKS*3/4)
-#define DEFAULT_totalFifoSize (BMI_MAX_FIFO_SIZE*3/4)
-#define DEFAULT_maxNumOfOpenDmas (BMI_MAX_NUM_OF_DMAS*3/4)
+ FM_EX_MURAM_ECC |\
+ FM_EX_BMI_DISPATCH_RAM_ECC |\
+ FM_EX_QMI_DOUBLE_ECC |\
+ FM_EX_QMI_SINGLE_ECC)
+
#define DEFAULT_eccEnable FALSE
-#define DEFAULT_dispLimit 0
-#define DEFAULT_prsDispTh 16
-#define DEFAULT_plcrDispTh 16
-#define DEFAULT_kgDispTh 16
-#define DEFAULT_bmiDispTh 16
-#define DEFAULT_qmiEnqDispTh 16
-#define DEFAULT_qmiDeqDispTh 16
-#define DEFAULT_fmCtl1DispTh 16
-#define DEFAULT_fmCtl2DispTh 16
-#define DEFAULT_cacheOverride e_FM_DMA_NO_CACHE_OR
#ifdef FM_PEDANTIC_DMA
#define DEFAULT_aidOverride TRUE
#else
@@ -146,42 +289,129 @@
#define DEFAULT_dmaStopOnBusError FALSE
#define DEFAULT_stopAtBusError FALSE
#define DEFAULT_axiDbgNumOfBeats 1
-#define DEFAULT_dmaCamNumOfEntries 32
-#define DEFAULT_dmaCommQLow ((DMA_THRESH_MAX_COMMQ+1)/2)
-#define DEFAULT_dmaCommQHigh ((DMA_THRESH_MAX_COMMQ+1)*3/4)
#define DEFAULT_dmaReadIntBufLow ((DMA_THRESH_MAX_BUF+1)/2)
#define DEFAULT_dmaReadIntBufHigh ((DMA_THRESH_MAX_BUF+1)*3/4)
#define DEFAULT_dmaWriteIntBufLow ((DMA_THRESH_MAX_BUF+1)/2)
#define DEFAULT_dmaWriteIntBufHigh ((DMA_THRESH_MAX_BUF+1)*3/4)
-#define DEFAULT_dmaSosEmergency 0
-#define DEFAULT_dmaDbgCntMode e_FM_DMA_DBG_NO_CNT
#define DEFAULT_catastrophicErr e_FM_CATASTROPHIC_ERR_STALL_PORT
#define DEFAULT_dmaErr e_FM_DMA_ERR_CATASTROPHIC
#define DEFAULT_resetOnInit FALSE
+#define DEFAULT_resetOnInitOverrideCallback NULL
#define DEFAULT_haltOnExternalActivation FALSE /* do not change! if changed, must be disabled for rev1 ! */
#define DEFAULT_haltOnUnrecoverableEccError FALSE /* do not change! if changed, must be disabled for rev1 ! */
#define DEFAULT_externalEccRamsEnable FALSE
#define DEFAULT_VerifyUcode FALSE
-#define DEFAULT_tnumAgingPeriod 0
+
+#if (DPAA_VERSION < 11)
+#define DEFAULT_totalFifoSize(major, minor) \
+ (((major == 2) || (major == 5)) ? \
+ (100*KILOBYTE) : ((major == 4) ? \
+ (49*KILOBYTE) : (122*KILOBYTE)))
+#define DEFAULT_totalNumOfTasks(major, minor) \
+ BMI_MAX_NUM_OF_TASKS
+
+#define DEFAULT_dmaCommQLow ((DMA_THRESH_MAX_COMMQ+1)/2)
+#define DEFAULT_dmaCommQHigh ((DMA_THRESH_MAX_COMMQ+1)*3/4)
+#define DEFAULT_cacheOverride e_FM_DMA_NO_CACHE_OR
+#define DEFAULT_dmaCamNumOfEntries 32
+#define DEFAULT_dmaDbgCntMode e_FM_DMA_DBG_NO_CNT
+#define DEFAULT_dmaEnEmergency FALSE
+#define DEFAULT_dmaSosEmergency 0
#define DEFAULT_dmaWatchdog 0 /* disabled */
-#define DEFAULT_mtu 9600
+#define DEFAULT_dmaEnEmergencySmoother FALSE
+#define DEFAULT_dmaEmergencySwitchCounter 0
-/**************************************************************************//**
- @Description Modules registers offsets
-*//***************************************************************************/
-#define FM_MM_MURAM 0x00000000
-#define FM_MM_BMI 0x00080000
-#define FM_MM_QMI 0x00080400
-#define FM_MM_PRS 0x000c7000
-#define FM_MM_KG 0x000C1000
-#define FM_MM_DMA 0x000C2000
-#define FM_MM_FPM 0x000C3000
-#define FM_MM_PLCR 0x000C0000
-#define FM_MM_IMEM 0x000C4000
+#define DEFAULT_dispLimit 0
+#define DEFAULT_prsDispTh 16
+#define DEFAULT_plcrDispTh 16
+#define DEFAULT_kgDispTh 16
+#define DEFAULT_bmiDispTh 16
+#define DEFAULT_qmiEnqDispTh 16
+#define DEFAULT_qmiDeqDispTh 16
+#define DEFAULT_fmCtl1DispTh 16
+#define DEFAULT_fmCtl2DispTh 16
+
+#else /* (DPAA_VERSION < 11) */
+/* Defaults are registers' reset values */
+#define DEFAULT_totalFifoSize(major, minor) \
+ (((major == 6) && ((minor == 1) || (minor == 4))) ? \
+ (156*KILOBYTE) : (295*KILOBYTE))
+
+/* According to the default value of FMBM_CFG2[TNTSKS] */
+#define DEFAULT_totalNumOfTasks(major, minor) \
+ (((major == 6) && ((minor == 1) || (minor == 4))) ? 59 : 124)
+
+#define DEFAULT_dmaCommQLow 0x2A
+#define DEFAULT_dmaCommQHigh 0x3F
+#define DEFAULT_cacheOverride e_FM_DMA_NO_CACHE_OR
+#define DEFAULT_dmaCamNumOfEntries 64
+#define DEFAULT_dmaDbgCntMode e_FM_DMA_DBG_NO_CNT
+#define DEFAULT_dmaEnEmergency FALSE
+#define DEFAULT_dmaSosEmergency 0
+#define DEFAULT_dmaWatchdog 0 /* disabled */
+#define DEFAULT_dmaEnEmergencySmoother FALSE
+#define DEFAULT_dmaEmergencySwitchCounter 0
+
+#define DEFAULT_dispLimit 0
+#define DEFAULT_prsDispTh 16
+#define DEFAULT_plcrDispTh 16
+#define DEFAULT_kgDispTh 16
+#define DEFAULT_bmiDispTh 16
+#define DEFAULT_qmiEnqDispTh 16
+#define DEFAULT_qmiDeqDispTh 16
+#define DEFAULT_fmCtl1DispTh 16
+#define DEFAULT_fmCtl2DispTh 16
+#endif /* (DPAA_VERSION < 11) */
+
+#define FM_TIMESTAMP_1_USEC_BIT 8
/**************************************************************************//**
- @Description Interrupt Enable/Mask
+ @Collection Defines used for enabling/disabling FM interrupts
+ @{
*//***************************************************************************/
+#define ERR_INTR_EN_DMA 0x00010000
+#define ERR_INTR_EN_FPM 0x80000000
+#define ERR_INTR_EN_BMI 0x00800000
+#define ERR_INTR_EN_QMI 0x00400000
+#define ERR_INTR_EN_PRS 0x00200000
+#define ERR_INTR_EN_KG 0x00100000
+#define ERR_INTR_EN_PLCR 0x00080000
+#define ERR_INTR_EN_MURAM 0x00040000
+#define ERR_INTR_EN_IRAM 0x00020000
+#define ERR_INTR_EN_10G_MAC0 0x00008000
+#define ERR_INTR_EN_10G_MAC1 0x00000040
+#define ERR_INTR_EN_1G_MAC0 0x00004000
+#define ERR_INTR_EN_1G_MAC1 0x00002000
+#define ERR_INTR_EN_1G_MAC2 0x00001000
+#define ERR_INTR_EN_1G_MAC3 0x00000800
+#define ERR_INTR_EN_1G_MAC4 0x00000400
+#define ERR_INTR_EN_1G_MAC5 0x00000200
+#define ERR_INTR_EN_1G_MAC6 0x00000100
+#define ERR_INTR_EN_1G_MAC7 0x00000080
+#define ERR_INTR_EN_MACSEC_MAC0 0x00000001
+
+#define INTR_EN_QMI 0x40000000
+#define INTR_EN_PRS 0x20000000
+#define INTR_EN_WAKEUP 0x10000000
+#define INTR_EN_PLCR 0x08000000
+#define INTR_EN_1G_MAC0 0x00080000
+#define INTR_EN_1G_MAC1 0x00040000
+#define INTR_EN_1G_MAC2 0x00020000
+#define INTR_EN_1G_MAC3 0x00010000
+#define INTR_EN_1G_MAC4 0x00000040
+#define INTR_EN_1G_MAC5 0x00000020
+#define INTR_EN_1G_MAC6 0x00000008
+#define INTR_EN_1G_MAC7 0x00000002
+#define INTR_EN_10G_MAC0 0x00200000
+#define INTR_EN_10G_MAC1 0x00100000
+#define INTR_EN_REV0 0x00008000
+#define INTR_EN_REV1 0x00004000
+#define INTR_EN_REV2 0x00002000
+#define INTR_EN_REV3 0x00001000
+#define INTR_EN_BRK 0x00000080
+#define INTR_EN_TMR 0x01000000
+#define INTR_EN_MACSEC_MAC0 0x00000001
+/* @} */
/**************************************************************************//**
@Description Memory Mapped Registers
@@ -190,375 +420,80 @@
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(push,1)
#endif /* defined(__MWERKS__) && ... */
-#define MEM_MAP_START
-typedef _Packed struct
-{
- volatile uint32_t fpmtnc; /**< FPM TNUM Control */
- volatile uint32_t fpmpr; /**< FPM Port_ID FmCtl Association */
- volatile uint32_t brkc; /**< FPM Breakpoint Control */
- volatile uint32_t fpmflc; /**< FPM Flush Control */
- volatile uint32_t fpmdis1; /**< FPM Dispatch Thresholds1 */
- volatile uint32_t fpmdis2; /**< FPM Dispatch Thresholds2 */
- volatile uint32_t fmepi; /**< FM Error Pending Interrupts */
- volatile uint32_t fmrie; /**< FM Error Interrupt Enable */
- volatile uint32_t fmfpfcev[4]; /**< FPM FMan-Controller Event 1-4 */
- volatile uint8_t res1[16]; /**< reserved */
- volatile uint32_t fmfpfcee[4]; /**< PM FMan-Controller Event 1-4 */
- volatile uint8_t res2[16]; /**< reserved */
- volatile uint32_t fpmtsc1; /**< FPM TimeStamp Control1 */
- volatile uint32_t fpmtsc2; /**< FPM TimeStamp Control2 */
- volatile uint32_t fpmtsp; /**< FPM Time Stamp */
- volatile uint32_t fpmtsf; /**< FPM Time Stamp Fraction */
- volatile uint32_t fmrcr; /**< FM Rams Control */
- volatile uint32_t fpmextc; /**< FPM External Requests Control */
- volatile uint32_t fpmext1; /**< FPM External Requests Config1 */
- volatile uint32_t fpmext2; /**< FPM External Requests Config2 */
- volatile uint32_t fpmdrd[16]; /**< FPM Data_Ram Data 0-15 */
- volatile uint32_t fpmdra; /**< FPM Data Ram Access */
- volatile uint32_t fm_ip_rev_1; /**< FM IP Block Revision 1 */
- volatile uint32_t fm_ip_rev_2; /**< FM IP Block Revision 2 */
- volatile uint32_t fmrstc; /**< FM Reset Command */
- volatile uint32_t fmcld; /**< FM Classifier Debug */
- volatile uint32_t fmnpi; /**< FM Normal Pending Interrupts */
- volatile uint32_t fmfp_exte; /**< FPM External Requests Enable */
- volatile uint32_t fpmem; /**< FPM Event & Mask */
- volatile uint32_t fpmcev[4]; /**< FPM CPU Event 1-4 */
- volatile uint8_t res4[16]; /**< reserved */
- volatile uint32_t fmfp_ps[0x40]; /**< FPM Port Status */
- volatile uint8_t reserved1[0x260];
- volatile uint32_t fpmts[128]; /**< 0x400: FPM Task Status */
-} _PackedType t_FmFpmRegs;
-
-#define NUM_OF_DBG_TRAPS 3
-
-typedef _Packed struct
-{
- volatile uint32_t fmbm_init; /**< BMI Initialization */
- volatile uint32_t fmbm_cfg1; /**< BMI Configuration 1 */
- volatile uint32_t fmbm_cfg2; /**< BMI Configuration 2 */
- volatile uint32_t reserved[5];
- volatile uint32_t fmbm_ievr; /**< Interrupt Event Register */
- volatile uint32_t fmbm_ier; /**< Interrupt Enable Register */
- volatile uint32_t fmbm_ifr; /**< Interrupt Force Register */
- volatile uint32_t reserved1[5];
- volatile uint32_t fmbm_arb[8]; /**< BMI Arbitration */
- volatile uint32_t reserved2[12];
- volatile uint32_t fmbm_dtc[NUM_OF_DBG_TRAPS]; /**< BMI Debug Trap Counter */
- volatile uint32_t reserved3;
- volatile uint32_t fmbm_dcv[NUM_OF_DBG_TRAPS][4]; /**< BMI Debug Compare Value */
- volatile uint32_t fmbm_dcm[NUM_OF_DBG_TRAPS][4]; /**< BMI Debug Compare Mask */
- volatile uint32_t fmbm_gde; /**< BMI Global Debug Enable */
- volatile uint32_t fmbm_pp[63]; /**< BMI Port Parameters */
- volatile uint32_t reserved4;
- volatile uint32_t fmbm_pfs[63]; /**< BMI Port FIFO Size */
- volatile uint32_t reserved5;
- volatile uint32_t fmbm_ppid[63]; /**< Port Partition ID */
-} _PackedType t_FmBmiRegs;
-
-typedef _Packed struct
-{
- volatile uint32_t fmqm_gc; /**< General Configuration Register */
- volatile uint32_t Reserved0;
- volatile uint32_t fmqm_eie; /**< Error Interrupt Event Register */
- volatile uint32_t fmqm_eien; /**< Error Interrupt Enable Register */
- volatile uint32_t fmqm_eif; /**< Error Interrupt Force Register */
- volatile uint32_t fmqm_ie; /**< Interrupt Event Register */
- volatile uint32_t fmqm_ien; /**< Interrupt Enable Register */
- volatile uint32_t fmqm_if; /**< Interrupt Force Register */
- volatile uint32_t fmqm_gs; /**< Global Status Register */
- volatile uint32_t fmqm_ts; /**< Task Status Register */
- volatile uint32_t fmqm_etfc; /**< Enqueue Total Frame Counter */
- volatile uint32_t fmqm_dtfc; /**< Dequeue Total Frame Counter */
- volatile uint32_t fmqm_dc0; /**< Dequeue Counter 0 */
- volatile uint32_t fmqm_dc1; /**< Dequeue Counter 1 */
- volatile uint32_t fmqm_dc2; /**< Dequeue Counter 2 */
- volatile uint32_t fmqm_dc3; /**< Dequeue Counter 3 */
- volatile uint32_t fmqm_dfdc; /**< Dequeue FQID from Default Counter */
- volatile uint32_t fmqm_dfcc; /**< Dequeue FQID from Context Counter */
- volatile uint32_t fmqm_dffc; /**< Dequeue FQID from FD Counter */
- volatile uint32_t fmqm_dcc; /**< Dequeue Confirm Counter */
- volatile uint32_t Reserved1a[7];
- volatile uint32_t fmqm_tapc; /**< Tnum Aging Period Control */
- volatile uint32_t fmqm_dmcvc; /**< Dequeue MAC Command Valid Counter */
- volatile uint32_t fmqm_difdcc; /**< Dequeue Invalid FD Command Counter */
- volatile uint32_t fmqm_da1v; /**< Dequeue A1 Valid Counter */
- volatile uint32_t Reserved1b;
- volatile uint32_t fmqm_dtc; /**< 0x0080 Debug Trap Counter */
- volatile uint32_t fmqm_efddd; /**< 0x0084 Enqueue Frame Descriptor Dynamic Debug */
- volatile uint32_t Reserved3[2];
- _Packed struct {
- volatile uint32_t fmqm_dtcfg1; /**< 0x0090 Debug Trap Configuration 1 Register */
- volatile uint32_t fmqm_dtval1; /**< Debug Trap Value 1 Register */
- volatile uint32_t fmqm_dtm1; /**< Debug Trap Mask 1 Register */
- volatile uint32_t fmqm_dtc1; /**< Debug Trap Counter 1 Register */
- volatile uint32_t fmqm_dtcfg2; /**< Debug Trap Configuration 2 Register */
- volatile uint32_t fmqm_dtval2; /**< Debug Trap Value 2 Register */
- volatile uint32_t fmqm_dtm2; /**< Debug Trap Mask 2 Register */
- volatile uint32_t Reserved1;
- } _PackedType dbgTraps[NUM_OF_DBG_TRAPS];
-} _PackedType t_FmQmiRegs;
-
-typedef _Packed struct
+typedef struct
{
- volatile uint32_t fmdmsr; /**< FM DMA status register 0x04 */
- volatile uint32_t fmdmmr; /**< FM DMA mode register 0x08 */
- volatile uint32_t fmdmtr; /**< FM DMA bus threshold register 0x0c */
- volatile uint32_t fmdmhy; /**< FM DMA bus hysteresis register 0x10 */
- volatile uint32_t fmdmsetr; /**< FM DMA SOS emergency Threshold Register 0x14 */
- volatile uint32_t fmdmtah; /**< FM DMA transfer bus address high register 0x18 */
- volatile uint32_t fmdmtal; /**< FM DMA transfer bus address low register 0x1C */
- volatile uint32_t fmdmtcid; /**< FM DMA transfer bus communication ID register 0x20 */
- volatile uint32_t fmdmra; /**< FM DMA bus internal ram address register 0x24 */
- volatile uint32_t fmdmrd; /**< FM DMA bus internal ram data register 0x28 */
- volatile uint32_t fmdmwcr; /**< FM DMA CAM watchdog counter value 0x2C */
- volatile uint32_t fmdmebcr; /**< FM DMA CAM base in MURAM register 0x30 */
- volatile uint32_t fmdmccqdr; /**< FM DMA CAM and CMD Queue Debug register 0x34 */
- volatile uint32_t fmdmccqvr1; /**< FM DMA CAM and CMD Queue Value register #1 0x38 */
- volatile uint32_t fmdmccqvr2; /**< FM DMA CAM and CMD Queue Value register #2 0x3C */
- volatile uint32_t fmdmcqvr3; /**< FM DMA CMD Queue Value register #3 0x40 */
- volatile uint32_t fmdmcqvr4; /**< FM DMA CMD Queue Value register #4 0x44 */
- volatile uint32_t fmdmcqvr5; /**< FM DMA CMD Queue Value register #5 0x48 */
- volatile uint32_t fmdmsefrc; /**< FM DMA Semaphore Entry Full Reject Counter 0x50 */
- volatile uint32_t fmdmsqfrc; /**< FM DMA Semaphore Queue Full Reject Counter 0x54 */
- volatile uint32_t fmdmssrc; /**< FM DMA Semaphore SYNC Reject Counter 0x54 */
- volatile uint32_t fmdmdcr; /**< FM DMA Debug Counter */
- volatile uint32_t fmdmemsr; /**< FM DMA Emrgency Smoother Register */
- volatile uint32_t reserved;
- volatile uint32_t fmdmplr[FM_SIZE_OF_LIODN_TABLE/2];
- /**< FM DMA PID-LIODN # register */
-} _PackedType t_FmDmaRegs;
-
-typedef _Packed struct
+ volatile uint32_t iadd; /**< FM IRAM instruction address register */
+ volatile uint32_t idata; /**< FM IRAM instruction data register */
+ volatile uint32_t itcfg; /**< FM IRAM timing config register */
+ volatile uint32_t iready; /**< FM IRAM ready register */
+ volatile uint32_t res[0x1FFFC];
+} t_FMIramRegs;
+
+/* Trace buffer registers -
+ each FM Controller has its own trace buffer residing at FM_MM_TRB(fmCtrlIndex) offset */
+typedef struct t_FmTrbRegs
{
- volatile uint32_t iadd; /**< FM IRAM instruction address register */
- volatile uint32_t idata; /**< FM IRAM instruction data register */
- volatile uint32_t itcfg; /**< FM IRAM timing config register */
- volatile uint32_t iready; /**< FM IRAM ready register */
- volatile uint8_t res[0x80000-0x10];
-} _PackedType t_FMIramRegs;
-
-#define MEM_MAP_END
+ volatile uint32_t tcrh;
+ volatile uint32_t tcrl;
+ volatile uint32_t tesr;
+ volatile uint32_t tecr0h;
+ volatile uint32_t tecr0l;
+ volatile uint32_t terf0h;
+ volatile uint32_t terf0l;
+ volatile uint32_t tecr1h;
+ volatile uint32_t tecr1l;
+ volatile uint32_t terf1h;
+ volatile uint32_t terf1l;
+ volatile uint32_t tpcch;
+ volatile uint32_t tpccl;
+ volatile uint32_t tpc1h;
+ volatile uint32_t tpc1l;
+ volatile uint32_t tpc2h;
+ volatile uint32_t tpc2l;
+ volatile uint32_t twdimr;
+ volatile uint32_t twicvr;
+ volatile uint32_t tar;
+ volatile uint32_t tdr;
+ volatile uint32_t tsnum1;
+ volatile uint32_t tsnum2;
+ volatile uint32_t tsnum3;
+ volatile uint32_t tsnum4;
+} t_FmTrbRegs;
+
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(pop)
#endif /* defined(__MWERKS__) && ... */
-
/**************************************************************************//**
@Description General defines
*//***************************************************************************/
-
#define FM_DEBUG_STATUS_REGISTER_OFFSET 0x000d1084UL
-#define FM_UCODE_DEBUG_INSTRUCTION 0x6ffff805UL
-
-
-/**************************************************************************//**
- @Description DMA definitions
-*//***************************************************************************/
-
-/* masks */
-#define DMA_MODE_AID_OR 0x20000000
-#define DMA_MODE_SBER 0x10000000
-#define DMA_MODE_BER 0x00200000
-#define DMA_MODE_ECC 0x00000020
-#define DMA_MODE_PRIVILEGE_PROT 0x00001000
-#define DMA_MODE_SECURE_PROT 0x00000800
-#define DMA_MODE_EMERGENCY_READ 0x00080000
-#define DMA_MODE_EMERGENCY_WRITE 0x00040000
-
-#define DMA_TRANSFER_PORTID_MASK 0xFF000000
-#define DMA_TRANSFER_TNUM_MASK 0x00FF0000
-#define DMA_TRANSFER_LIODN_MASK 0x00000FFF
-
-#define DMA_HIGH_LIODN_MASK 0x0FFF0000
-#define DMA_LOW_LIODN_MASK 0x00000FFF
-
-#define DMA_STATUS_CMD_QUEUE_NOT_EMPTY 0x10000000
-#define DMA_STATUS_BUS_ERR 0x08000000
-#define DMA_STATUS_READ_ECC 0x04000000
-#define DMA_STATUS_SYSTEM_WRITE_ECC 0x02000000
-#define DMA_STATUS_FM_WRITE_ECC 0x01000000
-#define DMA_STATUS_SYSTEM_DPEXT_ECC 0x00800000
-#define DMA_STATUS_FM_DPEXT_ECC 0x00400000
-#define DMA_STATUS_SYSTEM_DPDAT_ECC 0x00200000
-#define DMA_STATUS_FM_DPDAT_ECC 0x00100000
-#define DMA_STATUS_FM_SPDAT_ECC 0x00080000
-
-#define FM_LIODN_BASE_MASK 0x00000FFF
-
-/* shifts */
-#define DMA_MODE_CACHE_OR_SHIFT 30
-#define DMA_MODE_BUS_PRI_SHIFT 16
-#define DMA_MODE_AXI_DBG_SHIFT 24
-#define DMA_MODE_CEN_SHIFT 13
-#define DMA_MODE_BUS_PROT_SHIFT 10
-#define DMA_MODE_DBG_SHIFT 7
-#define DMA_MODE_EMERGENCY_LEVEL_SHIFT 6
-#define DMA_MODE_AID_MODE_SHIFT 4
-#define DMA_MODE_MAX_AXI_DBG_NUM_OF_BEATS 16
-#define DMA_MODE_MAX_CAM_NUM_OF_ENTRIES 32
-
-#define DMA_THRESH_COMMQ_SHIFT 24
-#define DMA_THRESH_READ_INT_BUF_SHIFT 16
-
-#define DMA_LIODN_SHIFT 16
-
-#define DMA_TRANSFER_PORTID_SHIFT 24
-#define DMA_TRANSFER_TNUM_SHIFT 16
-
-/* sizes */
-#define DMA_MAX_WATCHDOG 0xffffffff
-
-/* others */
-#define DMA_CAM_SIZEOF_ENTRY 0x40
-#define DMA_CAM_ALIGN 0x1000
-#define DMA_CAM_UNITS 8
-
+#define FM_FW_DEBUG_INSTRUCTION 0x6ffff805UL
/**************************************************************************//**
@Description FPM defines
*//***************************************************************************/
-
/* masks */
-#define FPM_EV_MASK_DOUBLE_ECC 0x80000000
-#define FPM_EV_MASK_STALL 0x40000000
-#define FPM_EV_MASK_SINGLE_ECC 0x20000000
-#define FPM_EV_MASK_RELEASE_FM 0x00010000
-#define FPM_EV_MASK_DOUBLE_ECC_EN 0x00008000
-#define FPM_EV_MASK_STALL_EN 0x00004000
-#define FPM_EV_MASK_SINGLE_ECC_EN 0x00002000
-#define FPM_EV_MASK_EXTERNAL_HALT 0x00000008
-#define FPM_EV_MASK_ECC_ERR_HALT 0x00000004
-
-#define FPM_RAM_CTL_RAMS_ECC_EN 0x80000000
-#define FPM_RAM_CTL_IRAM_ECC_EN 0x40000000
-#define FPM_RAM_CTL_MURAM_ECC 0x00008000
-#define FPM_RAM_CTL_IRAM_ECC 0x00004000
-#define FPM_RAM_CTL_MURAM_TEST_ECC 0x20000000
-#define FPM_RAM_CTL_IRAM_TEST_ECC 0x10000000
-#define FPM_RAM_CTL_RAMS_ECC_EN_SRC_SEL 0x08000000
-
-#define FPM_IRAM_ECC_ERR_EX_EN 0x00020000
-#define FPM_MURAM_ECC_ERR_EX_EN 0x00040000
-
-#define FPM_REV1_MAJOR_MASK 0x0000FF00
-#define FPM_REV1_MINOR_MASK 0x000000FF
-
-#define FPM_REV2_INTEG_MASK 0x00FF0000
-#define FPM_REV2_ERR_MASK 0x0000FF00
-#define FPM_REV2_CFG_MASK 0x000000FF
-
-#define FPM_TS_FRACTION_MASK 0x0000FFFF
-#define FPM_TS_CTL_EN 0x80000000
-
-#define FPM_PORT_FM_CTL1 0x00000001
-#define FPM_PORT_FM_CTL2 0x00000002
-#define FPM_PRC_REALSE_STALLED 0x00800000
-
-#define FPM_PS_STALLED 0x00800000
-#define FPM_PS_FM_CTL1_SEL 0x80000000
-#define FPM_PS_FM_CTL2_SEL 0x40000000
-#define FPM_PS_FM_CTL_SEL_MASK (FPM_PS_FM_CTL1_SEL | FPM_PS_FM_CTL2_SEL)
-
-#define FPM_RSTC_FM_RESET 0x80000000
-#define FPM_RSTC_10G0_RESET 0x04000000
-#define FPM_RSTC_1G0_RESET 0x40000000
-#define FPM_RSTC_1G1_RESET 0x20000000
-#define FPM_RSTC_1G2_RESET 0x10000000
-#define FPM_RSTC_1G3_RESET 0x08000000
-#define FPM_RSTC_1G4_RESET 0x02000000
-
-
-/* shifts */
-#define FPM_DISP_LIMIT_SHIFT 24
-
-#define FPM_THR1_PRS_SHIFT 24
-#define FPM_THR1_KG_SHIFT 16
-#define FPM_THR1_PLCR_SHIFT 8
-#define FPM_THR1_BMI_SHIFT 0
-
-#define FPM_THR2_QMI_ENQ_SHIFT 24
-#define FPM_THR2_QMI_DEQ_SHIFT 0
-#define FPM_THR2_FM_CTL1_SHIFT 16
-#define FPM_THR2_FM_CTL2_SHIFT 8
-
-#define FPM_EV_MASK_CAT_ERR_SHIFT 1
-#define FPM_EV_MASK_DMA_ERR_SHIFT 0
-
-#define FPM_REV1_MAJOR_SHIFT 8
-#define FPM_REV1_MINOR_SHIFT 0
-
-#define FPM_REV2_INTEG_SHIFT 16
-#define FPM_REV2_ERR_SHIFT 8
-#define FPM_REV2_CFG_SHIFT 0
-
-#define FPM_TS_INT_SHIFT 16
-
-#define FPM_PORT_FM_CTL_PORTID_SHIFT 24
-
-#define FPM_PS_FM_CTL_SEL_SHIFT 30
-#define FPM_PRC_ORA_FM_CTL_SEL_SHIFT 16
-
-/* Interrupts defines */
-#define FPM_EVENT_FM_CTL_0 0x00008000
-#define FPM_EVENT_FM_CTL 0x0000FF00
-#define FPM_EVENT_FM_CTL_BRK 0x00000080
-
-/* others */
-#define FPM_MAX_DISP_LIMIT 31
-
+#define FPM_BRKC_RDBG 0x00000200
+#define FPM_BRKC_SLP 0x00000800
/**************************************************************************//**
@Description BMI defines
*//***************************************************************************/
/* masks */
#define BMI_INIT_START 0x80000000
-#define BMI_ERR_INTR_EN_PIPELINE_ECC 0x80000000
+#define BMI_ERR_INTR_EN_STORAGE_PROFILE_ECC 0x80000000
#define BMI_ERR_INTR_EN_LIST_RAM_ECC 0x40000000
#define BMI_ERR_INTR_EN_STATISTICS_RAM_ECC 0x20000000
#define BMI_ERR_INTR_EN_DISPATCH_RAM_ECC 0x10000000
-#define BMI_NUM_OF_TASKS_MASK 0x3F000000
-#define BMI_NUM_OF_EXTRA_TASKS_MASK 0x000F0000
-#define BMI_NUM_OF_DMAS_MASK 0x00000F00
-#define BMI_NUM_OF_EXTRA_DMAS_MASK 0x0000000F
-#define BMI_FIFO_SIZE_MASK 0x000003FF
-#define BMI_EXTRA_FIFO_SIZE_MASK 0x03FF0000
-#define BMI_CFG2_DMAS_MASK 0x0000003F
-
-/* shifts */
-#define BMI_CFG2_TASKS_SHIFT 16
-#define BMI_CFG2_DMAS_SHIFT 0
-#define BMI_CFG1_FIFO_SIZE_SHIFT 16
-#define BMI_FIFO_SIZE_SHIFT 0
-#define BMI_EXTRA_FIFO_SIZE_SHIFT 16
-#define BMI_NUM_OF_TASKS_SHIFT 24
-#define BMI_EXTRA_NUM_OF_TASKS_SHIFT 16
-#define BMI_NUM_OF_DMAS_SHIFT 8
-#define BMI_EXTRA_NUM_OF_DMAS_SHIFT 0
-
-/* others */
-#define BMI_FIFO_ALIGN 0x100
-
-
/**************************************************************************//**
@Description QMI defines
*//***************************************************************************/
/* masks */
-#define QMI_CFG_ENQ_EN 0x80000000
-#define QMI_CFG_DEQ_EN 0x40000000
-#define QMI_CFG_EN_COUNTERS 0x10000000
-#define QMI_CFG_SOFT_RESET 0x01000000
-#define QMI_CFG_DEQ_MASK 0x0000003F
-#define QMI_CFG_ENQ_MASK 0x00003F00
-
#define QMI_ERR_INTR_EN_DOUBLE_ECC 0x80000000
#define QMI_ERR_INTR_EN_DEQ_FROM_DEF 0x40000000
#define QMI_INTR_EN_SINGLE_ECC 0x80000000
-/* shifts */
-#define QMI_CFG_ENQ_SHIFT 8
-#define QMI_TAPC_TAP 22
-
-
/**************************************************************************//**
@Description IRAM defines
*//***************************************************************************/
@@ -566,49 +501,21 @@ typedef _Packed struct
#define IRAM_IADD_AIE 0x80000000
#define IRAM_READY 0x80000000
+/**************************************************************************//**
+ @Description TRB defines
+*//***************************************************************************/
+/* masks */
+#define TRB_TCRH_RESET 0x04000000
+#define TRB_TCRH_ENABLE_COUNTERS 0x84008000
+#define TRB_TCRH_DISABLE_COUNTERS 0x8400C000
+#define TRB_TCRL_RESET 0x20000000
+#define TRB_TCRL_UTIL 0x00000460
typedef struct {
void (*f_Isr) (t_Handle h_Arg, uint32_t event);
t_Handle h_SrcHandle;
} t_FmanCtrlIntrSrc;
-typedef struct
-{
- /* uint8_t numOfPartitions; */
- bool resetOnInit;
-#ifdef FM_PARTITION_ARRAY
- uint16_t liodnBasePerPort[FM_SIZE_OF_LIODN_TABLE];
-#endif
- bool enCounters;
- t_FmThresholds thresholds;
- e_FmDmaCacheOverride dmaCacheOverride;
- e_FmDmaAidMode dmaAidMode;
- bool dmaAidOverride;
- uint8_t dmaAxiDbgNumOfBeats;
- uint8_t dmaCamNumOfEntries;
- uint32_t dmaWatchdog;
- t_FmDmaThresholds dmaCommQThresholds;
- t_FmDmaThresholds dmaWriteBufThresholds;
- t_FmDmaThresholds dmaReadBufThresholds;
- uint32_t dmaSosEmergency;
- e_FmDmaDbgCntMode dmaDbgCntMode;
- bool dmaStopOnBusError;
- bool dmaEnEmergency;
- t_FmDmaEmergency dmaEmergency;
- bool dmaEnEmergencySmoother;
- uint32_t dmaEmergencySwitchCounter;
- bool haltOnExternalActivation;
- bool haltOnUnrecoverableEccError;
- e_FmCatastrophicErr catastrophicErr;
- e_FmDmaErr dmaErr;
- bool enMuramTestMode;
- bool enIramTestMode;
- bool externalEccRamsEnable;
- uint16_t tnumAgingPeriod;
- t_FmPcdFirmwareParams firmware;
- bool fwVerify;
-} t_FmDriverParam;
-
typedef void (t_FmanCtrlIsr)( t_Handle h_Fm, uint32_t event);
typedef struct
@@ -619,6 +526,8 @@ typedef struct
uint8_t fmId;
e_FmPortType portsTypes[FM_MAX_NUM_OF_HW_PORT_IDS];
uint16_t fmClkFreq;
+ uint16_t fmMacClkFreq;
+ t_FmRevisionInfo revInfo;
/**************************/
/* Master Only parameters */
/**************************/
@@ -630,15 +539,13 @@ typedef struct
uint8_t accumulatedNumOfTasks;
uint32_t accumulatedFifoSize;
uint8_t accumulatedNumOfOpenDmas;
-#ifdef FM_QMI_DEQ_OPTIONS_SUPPORT
uint8_t accumulatedNumOfDeqTnums;
-#endif /* FM_QMI_DEQ_OPTIONS_SUPPORT */
#ifdef FM_LOW_END_RESTRICTION
bool lowEndRestriction;
#endif /* FM_LOW_END_RESTRICTION */
uint32_t exceptions;
- int irq;
- int errIrq;
+ uintptr_t irq;
+ uintptr_t errIrq;
bool ramsEccEnable;
bool explicitEnable;
bool internalCall;
@@ -647,12 +554,39 @@ typedef struct
uint8_t extraTasksPoolSize;
uint8_t extraOpenDmasPoolSize;
#if defined(FM_MAX_NUM_OF_10G_MACS) && (FM_MAX_NUM_OF_10G_MACS)
+ uint16_t portMaxFrameLengths10G[FM_MAX_NUM_OF_10G_MACS];
uint16_t macMaxFrameLengths10G[FM_MAX_NUM_OF_10G_MACS];
-#endif /* defined(FM_MAX_NUM_OF_10G_MACS) && (FM_MAX_NUM_OF_10G_MACS) */
+#endif /* defined(FM_MAX_NUM_OF_10G_MACS) && ... */
+ uint16_t portMaxFrameLengths1G[FM_MAX_NUM_OF_1G_MACS];
uint16_t macMaxFrameLengths1G[FM_MAX_NUM_OF_1G_MACS];
} t_FmStateStruct;
-typedef struct
+#if (DPAA_VERSION >= 11)
+typedef struct t_FmMapParam {
+ uint16_t profilesBase;
+ uint16_t numOfProfiles;
+ t_Handle h_FmPort;
+} t_FmMapParam;
+
+typedef struct t_FmAllocMng {
+ bool allocated;
+ uint8_t ownerId; /* guestId for KG in multi-partition only,
+ portId for PLCR in any environment */
+} t_FmAllocMng;
+
+typedef struct t_FmPcdSpEntry {
+ bool valid;
+ t_FmAllocMng profilesMng;
+} t_FmPcdSpEntry;
+
+typedef struct t_FmSp {
+ void *p_FmPcdStoragePrflRegs;
+ t_FmPcdSpEntry profiles[FM_VSP_MAX_NUM_OF_ENTRIES];
+ t_FmMapParam portsMapping[FM_MAX_NUM_OF_PORTS];
+} t_FmSp;
+#endif /* (DPAA_VERSION >= 11) */
+
+typedef struct t_Fm
{
/***************************/
/* Master/Guest parameters */
@@ -671,19 +605,29 @@ typedef struct
/* Master Only parameters */
/**************************/
/* locals for recovery */
- t_FmFpmRegs *p_FmFpmRegs;
- t_FmBmiRegs *p_FmBmiRegs;
- t_FmQmiRegs *p_FmQmiRegs;
- t_FmDmaRegs *p_FmDmaRegs;
+ struct fman_fpm_regs *p_FmFpmRegs;
+ struct fman_bmi_regs *p_FmBmiRegs;
+ struct fman_qmi_regs *p_FmQmiRegs;
+ struct fman_dma_regs *p_FmDmaRegs;
+ struct fman_regs *p_FmRegs;
t_FmExceptionsCallback *f_Exception;
t_FmBusErrorCallback *f_BusError;
t_Handle h_App; /* Application handle */
t_Handle h_Spinlock;
bool recoveryMode;
t_FmStateStruct *p_FmStateStruct;
+ uint16_t tnumAgingPeriod;
+#if (DPAA_VERSION >= 11)
+ t_FmSp *p_FmSp;
+ uint8_t partNumOfVSPs;
+ uint8_t partVSPBase;
+ uintptr_t vspBaseAddr;
+#endif /* (DPAA_VERSION >= 11) */
+ bool portsPreFetchConfigured[FM_MAX_NUM_OF_HW_PORT_IDS]; /* Prefetch configration per Tx-port */
+ bool portsPreFetchValue[FM_MAX_NUM_OF_HW_PORT_IDS]; /* Prefetch configration per Tx-port */
/* un-needed for recovery */
- t_FmDriverParam *p_FmDriverParam;
+ struct fman_cfg *p_FmDriverParam;
t_Handle h_FmMuram;
uint64_t fmMuramPhysBaseAddr;
bool independentMode;
@@ -693,6 +637,11 @@ typedef struct
uintptr_t fifoBaseAddr; /* save for freeing */
t_FmanCtrlIntrSrc fmanCtrlIntr[FM_NUM_OF_FMAN_CTRL_EVENT_REGS]; /* FM exceptions user callback */
bool usedEventRegs[FM_NUM_OF_FMAN_CTRL_EVENT_REGS];
+ t_FmFirmwareParams firmware;
+ bool fwVerify;
+ bool resetOnInit;
+ t_FmResetOnInitOverrideCallback *f_ResetOnInitOverride;
+ uint32_t userSetExceptions;
} t_Fm;
diff --git a/sys/contrib/ncsw/Peripherals/FM/fm_ipc.h b/sys/contrib/ncsw/Peripherals/FM/fm_ipc.h
index 7bb2e48c7fba..7ce36a767e25 100644
--- a/sys/contrib/ncsw/Peripherals/FM/fm_ipc.h
+++ b/sys/contrib/ncsw/Peripherals/FM/fm_ipc.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File fm_ipc.h
@@ -61,7 +62,6 @@
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(push,1)
#endif /* defined(__MWERKS__) && ... */
-#define MEM_MAP_START
/**************************************************************************//**
@Description enum for defining MAC types
@@ -94,6 +94,17 @@ typedef _Packed struct t_FmIpcPhysAddr
volatile uint32_t low;
} _PackedType t_FmIpcPhysAddr;
+
+typedef _Packed struct t_FmIpcPortOutInitParams {
+ uint8_t numOfTasks; /**< OUT */
+ uint8_t numOfExtraTasks; /**< OUT */
+ uint8_t numOfOpenDmas; /**< OUT */
+ uint8_t numOfExtraOpenDmas; /**< OUT */
+ uint32_t sizeOfFifo; /**< OUT */
+ uint32_t extraSizeOfFifo; /**< OUT */
+ t_FmIpcPhysAddr ipcPhysAddr; /**< OUT */
+} _PackedType t_FmIpcPortOutInitParams;
+
/**************************************************************************//**
@Description Structure for IPC communication during FM_PORT_Init.
*//***************************************************************************/
@@ -109,6 +120,7 @@ typedef _Packed struct t_FmIpcPortInInitParams {
uint32_t sizeOfFifo; /**< IN. Port's requested resource */
uint32_t extraSizeOfFifo; /**< IN. Port's requested resource */
uint8_t deqPipelineDepth; /**< IN. Port's requested resource */
+ uint16_t maxFrameLength; /**< IN. Port's max frame length. */
uint16_t liodnBase; /**< IN. Irrelevant for P4080 rev 1.
LIODN base for this port, to be
used together with LIODN offset. */
@@ -148,9 +160,7 @@ typedef _Packed struct t_FmIpcPortFifoParams {
typedef _Packed struct t_FmIpcPortFreeParams {
uint8_t hardwarePortId; /**< IN. port Id */
uint32_t enumPortType; /**< IN. Port type */
-#ifdef FM_QMI_DEQ_OPTIONS_SUPPORT
uint8_t deqPipelineDepth; /**< IN. Port's requested resource */
-#endif /* FM_QMI_DEQ_OPTIONS_SUPPORT */
} _PackedType t_FmIpcPortFreeParams;
/**************************************************************************//**
@@ -162,6 +172,7 @@ typedef _Packed struct t_FmIpcDmaStatus {
uint8_t boolReadBufEccError; /**< Double ECC error on buffer Read */
uint8_t boolWriteBufEccSysError; /**< Double ECC error on buffer write from system side */
uint8_t boolWriteBufEccFmError; /**< Double ECC error on buffer write from FM side */
+ uint8_t boolSinglePortEccError; /**< Single port ECC error from FM side */
} _PackedType t_FmIpcDmaStatus;
typedef _Packed struct t_FmIpcRegisterIntr
@@ -177,12 +188,24 @@ typedef _Packed struct t_FmIpcIsr
} _PackedType t_FmIpcIsr;
/**************************************************************************//**
- @Description structure for returning revision information
+ @Description structure for returning FM parameters
+*//***************************************************************************/
+typedef _Packed struct t_FmIpcParams {
+ uint16_t fmClkFreq; /**< OUT: FM Clock frequency */
+ uint16_t fmMacClkFreq; /**< OUT: FM MAC clock frequence */
+ uint8_t majorRev; /**< OUT: FM Major revision */
+ uint8_t minorRev; /**< OUT: FM Minor revision */
+} _PackedType t_FmIpcParams;
+
+
+/**************************************************************************//**
+ @Description structure for returning Fman Ctrl Code revision information
*//***************************************************************************/
-typedef _Packed struct t_FmIpcRevisionInfo {
+typedef _Packed struct t_FmIpcFmanCtrlCodeRevisionInfo {
+ uint16_t packageRev; /**< OUT: Package revision */
uint8_t majorRev; /**< OUT: Major revision */
uint8_t minorRev; /**< OUT: Minor revision */
-} _PackedType t_FmIpcRevisionInfo;
+} _PackedType t_FmIpcFmanCtrlCodeRevisionInfo;
/**************************************************************************//**
@Description Structure for defining Fm number of Fman controlers
@@ -190,19 +213,38 @@ typedef _Packed struct t_FmIpcRevisionInfo {
typedef _Packed struct t_FmIpcPortNumOfFmanCtrls {
uint8_t hardwarePortId; /**< IN. port Id */
uint8_t numOfFmanCtrls; /**< IN. Port type */
+ t_FmFmanCtrl orFmanCtrl; /**< IN. fman controller for order restoration*/
} t_FmIpcPortNumOfFmanCtrls;
/**************************************************************************//**
@Description structure for setting Fman contriller events
*//***************************************************************************/
typedef _Packed struct t_FmIpcFmanEvents {
- uint8_t eventRegId; /**< IN: Fman controller event register id */
- uint32_t enableEvents; /**< IN/OUT: required enabled events mask */
+ uint8_t eventRegId; /**< IN: Fman controller event register id */
+ uint32_t enableEvents; /**< IN/OUT: required enabled events mask */
} _PackedType t_FmIpcFmanEvents;
-#define FM_IPC_MAX_REPLY_BODY_SIZE 16
+typedef _Packed struct t_FmIpcResourceAllocParams {
+ uint8_t guestId;
+ uint16_t base;
+ uint16_t num;
+}_PackedType t_FmIpcResourceAllocParams;
+
+typedef _Packed struct t_FmIpcVspSetPortWindow {
+ uint8_t hardwarePortId;
+ uint8_t baseStorageProfile;
+ uint8_t log2NumOfProfiles;
+}_PackedType t_FmIpcVspSetPortWindow;
+
+typedef _Packed struct t_FmIpcSetCongestionGroupPfcPriority {
+ uint32_t congestionGroupId;
+ uint8_t priorityBitMap;
+}_PackedType t_FmIpcSetCongestionGroupPfcPriority;
+
+#define FM_IPC_MAX_REPLY_BODY_SIZE 20
#define FM_IPC_MAX_REPLY_SIZE (FM_IPC_MAX_REPLY_BODY_SIZE + sizeof(uint32_t))
#define FM_IPC_MAX_MSG_SIZE 30
+
typedef _Packed struct t_FmIpcMsg
{
uint32_t msgId;
@@ -215,7 +257,6 @@ typedef _Packed struct t_FmIpcReply
uint8_t replyBody[FM_IPC_MAX_REPLY_BODY_SIZE];
} _PackedType t_FmIpcReply;
-#define MEM_MAP_END
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(pop)
#endif /* defined(__MWERKS__) && ... */
@@ -244,16 +285,6 @@ typedef _Packed struct t_FmIpcReply
#define FM_GET_COUNTER 2
/**************************************************************************//**
- @Function FM_DUMP_REGS
-
- @Description Used by FM front-end for the PORT module in order to set and get
- parameters in/from master FM module on FM PORT initialization time.
-
- @Param None
-*//***************************************************************************/
-#define FM_DUMP_REGS 3
-
-/**************************************************************************//**
@Function FM_GET_SET_PORT_PARAMS
@Description Used by FM front-end for the PORT module in order to set and get
@@ -303,24 +334,14 @@ typedef _Packed struct t_FmIpcReply
#define FM_IS_PORT_STALLED 8
/**************************************************************************//**
- @Function FM_DUMP_PORT_REGS
-
- @Description Used by FM front-end for the PORT module in order to dump
- all port registers.
-
- @Param[in] uint8_t Pointer
-*//***************************************************************************/
-#define FM_DUMP_PORT_REGS 9
-
-/**************************************************************************//**
- @Function FM_GET_REV
+ @Function FM_GET_PARAMS
@Description Used by FM front-end for the PORT module in order to dump
- all port registers.
+ return FM parameters.
@Param[in] uint8_t Pointer
*//***************************************************************************/
-#define FM_GET_REV 10
+#define FM_GET_PARAMS 10
/**************************************************************************//**
@Function FM_REGISTER_INTR
@@ -333,15 +354,6 @@ typedef _Packed struct t_FmIpcReply
#define FM_REGISTER_INTR 11
/**************************************************************************//**
- @Function FM_GET_CLK_FREQ
-
- @Description Used by FM Front-end to read the FM clock frequency.
-
- @Param[out] uint32_t Pointer
-*//***************************************************************************/
-#define FM_GET_CLK_FREQ 12
-
-/**************************************************************************//**
@Function FM_DMA_STAT
@Description Used by FM front-end to read the FM DMA status.
@@ -422,7 +434,11 @@ typedef _Packed struct t_FmIpcReply
#define FM_SET_SIZE_OF_FIFO 24
#define FM_SET_NUM_OF_TASKS 25
#define FM_SET_NUM_OF_OPEN_DMAS 26
-
+#define FM_VSP_ALLOC 27
+#define FM_VSP_FREE 28
+#define FM_VSP_SET_PORT_WINDOW 29
+#define FM_GET_FMAN_CTRL_CODE_REV 30
+#define FM_SET_CONG_GRP_PFC_PRIO 31
#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
#define FM_10G_TX_ECC_WA 100
#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
diff --git a/sys/contrib/ncsw/Peripherals/FM/fm_muram.c b/sys/contrib/ncsw/Peripherals/FM/fm_muram.c
index e52f233993ec..0bc67cb74b99 100644
--- a/sys/contrib/ncsw/Peripherals/FM/fm_muram.c
+++ b/sys/contrib/ncsw/Peripherals/FM/fm_muram.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File FM_muram.c
@@ -43,7 +44,6 @@
#include "fm_muram_ext.h"
#include "fm_common.h"
-
#define __ERR_MODULE__ MODULE_FM_MURAM
@@ -158,7 +158,17 @@ t_Error FM_MURAM_FreeMem(t_Handle h_FmMuram, void *ptr)
SANITY_CHECK_RETURN_ERROR(p_FmMuram->h_Mem, E_INVALID_HANDLE);
if (MM_Put(p_FmMuram->h_Mem, PTR_TO_UINT(ptr)) == 0)
- RETURN_ERROR(MINOR, E_INVALID_HANDLE, ("memory pointer!!!"));
+ RETURN_ERROR(MINOR, E_INVALID_ADDRESS, ("memory pointer!!!"));
return E_OK;
}
+
+uint64_t FM_MURAM_GetFreeMemSize(t_Handle h_FmMuram)
+{
+ t_FmMuram *p_FmMuram = ( t_FmMuram *)h_FmMuram;
+
+ SANITY_CHECK_RETURN_VALUE(h_FmMuram, E_INVALID_HANDLE, 0);
+ SANITY_CHECK_RETURN_VALUE(p_FmMuram->h_Mem, E_INVALID_HANDLE, 0);
+
+ return MM_GetFreeMemSize(p_FmMuram->h_Mem);
+}
diff --git a/sys/contrib/ncsw/Peripherals/FM/fman_ncsw.c b/sys/contrib/ncsw/Peripherals/FM/fman_ncsw.c
new file mode 100755
index 000000000000..2c8002e8562c
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/fman_ncsw.c
@@ -0,0 +1,1398 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include <linux/math64.h>
+#include "fsl_fman.h"
+#include "dpaa_integration_ext.h"
+
+uint32_t fman_get_bmi_err_event(struct fman_bmi_regs *bmi_rg)
+{
+ uint32_t event, mask, force;
+
+ event = ioread32be(&bmi_rg->fmbm_ievr);
+ mask = ioread32be(&bmi_rg->fmbm_ier);
+ event &= mask;
+ /* clear the forced events */
+ force = ioread32be(&bmi_rg->fmbm_ifr);
+ if (force & event)
+ iowrite32be(force & ~event, &bmi_rg->fmbm_ifr);
+ /* clear the acknowledged events */
+ iowrite32be(event, &bmi_rg->fmbm_ievr);
+ return event;
+}
+
+uint32_t fman_get_qmi_err_event(struct fman_qmi_regs *qmi_rg)
+{
+ uint32_t event, mask, force;
+
+ event = ioread32be(&qmi_rg->fmqm_eie);
+ mask = ioread32be(&qmi_rg->fmqm_eien);
+ event &= mask;
+
+ /* clear the forced events */
+ force = ioread32be(&qmi_rg->fmqm_eif);
+ if (force & event)
+ iowrite32be(force & ~event, &qmi_rg->fmqm_eif);
+ /* clear the acknowledged events */
+ iowrite32be(event, &qmi_rg->fmqm_eie);
+ return event;
+}
+
+uint32_t fman_get_dma_com_id(struct fman_dma_regs *dma_rg)
+{
+ return ioread32be(&dma_rg->fmdmtcid);
+}
+
+uint64_t fman_get_dma_addr(struct fman_dma_regs *dma_rg)
+{
+ uint64_t addr;
+
+ addr = (uint64_t)ioread32be(&dma_rg->fmdmtal);
+ addr |= ((uint64_t)(ioread32be(&dma_rg->fmdmtah)) << 32);
+
+ return addr;
+}
+
+uint32_t fman_get_dma_err_event(struct fman_dma_regs *dma_rg)
+{
+ uint32_t status, mask;
+
+ status = ioread32be(&dma_rg->fmdmsr);
+ mask = ioread32be(&dma_rg->fmdmmr);
+
+ /* clear DMA_STATUS_BUS_ERR if mask has no DMA_MODE_BER */
+ if ((mask & DMA_MODE_BER) != DMA_MODE_BER)
+ status &= ~DMA_STATUS_BUS_ERR;
+
+ /* clear relevant bits if mask has no DMA_MODE_ECC */
+ if ((mask & DMA_MODE_ECC) != DMA_MODE_ECC)
+ status &= ~(DMA_STATUS_FM_SPDAT_ECC |
+ DMA_STATUS_READ_ECC |
+ DMA_STATUS_SYSTEM_WRITE_ECC |
+ DMA_STATUS_FM_WRITE_ECC);
+
+ /* clear set events */
+ iowrite32be(status, &dma_rg->fmdmsr);
+
+ return status;
+}
+
+uint32_t fman_get_fpm_err_event(struct fman_fpm_regs *fpm_rg)
+{
+ uint32_t event;
+
+ event = ioread32be(&fpm_rg->fmfp_ee);
+ /* clear the all occurred events */
+ iowrite32be(event, &fpm_rg->fmfp_ee);
+ return event;
+}
+
+uint32_t fman_get_muram_err_event(struct fman_fpm_regs *fpm_rg)
+{
+ uint32_t event, mask;
+
+ event = ioread32be(&fpm_rg->fm_rcr);
+ mask = ioread32be(&fpm_rg->fm_rie);
+
+ /* clear MURAM event bit (do not clear IRAM event) */
+ iowrite32be(event & ~FPM_RAM_IRAM_ECC, &fpm_rg->fm_rcr);
+
+ if ((mask & FPM_MURAM_ECC_ERR_EX_EN))
+ return event;
+ else
+ return 0;
+}
+
+uint32_t fman_get_iram_err_event(struct fman_fpm_regs *fpm_rg)
+{
+ uint32_t event, mask;
+
+ event = ioread32be(&fpm_rg->fm_rcr) ;
+ mask = ioread32be(&fpm_rg->fm_rie);
+ /* clear IRAM event bit (do not clear MURAM event) */
+ iowrite32be(event & ~FPM_RAM_MURAM_ECC,
+ &fpm_rg->fm_rcr);
+
+ if ((mask & FPM_IRAM_ECC_ERR_EX_EN))
+ return event;
+ else
+ return 0;
+}
+
+uint32_t fman_get_qmi_event(struct fman_qmi_regs *qmi_rg)
+{
+ uint32_t event, mask, force;
+
+ event = ioread32be(&qmi_rg->fmqm_ie);
+ mask = ioread32be(&qmi_rg->fmqm_ien);
+ event &= mask;
+ /* clear the forced events */
+ force = ioread32be(&qmi_rg->fmqm_if);
+ if (force & event)
+ iowrite32be(force & ~event, &qmi_rg->fmqm_if);
+ /* clear the acknowledged events */
+ iowrite32be(event, &qmi_rg->fmqm_ie);
+ return event;
+}
+
+void fman_enable_time_stamp(struct fman_fpm_regs *fpm_rg,
+ uint8_t count1ubit,
+ uint16_t fm_clk_freq)
+{
+ uint32_t tmp;
+ uint64_t frac;
+ uint32_t intgr;
+ uint32_t ts_freq = (uint32_t)(1 << count1ubit); /* in Mhz */
+
+ /* configure timestamp so that bit 8 will count 1 microsecond
+ * Find effective count rate at TIMESTAMP least significant bits:
+ * Effective_Count_Rate = 1MHz x 2^8 = 256MHz
+ * Find frequency ratio between effective count rate and the clock:
+ * Effective_Count_Rate / CLK e.g. for 600 MHz clock:
+ * 256/600 = 0.4266666... */
+
+ intgr = ts_freq / fm_clk_freq;
+ /* we multiply by 2^16 to keep the fraction of the division
+ * we do not div back, since we write this value as a fraction
+ * see spec */
+
+ frac = ((uint64_t)ts_freq << 16) - ((uint64_t)intgr << 16) * fm_clk_freq;
+ /* we check remainder of the division in order to round up if not int */
+ if (do_div(frac, fm_clk_freq))
+ frac++;
+
+ tmp = (intgr << FPM_TS_INT_SHIFT) | (uint16_t)frac;
+ iowrite32be(tmp, &fpm_rg->fmfp_tsc2);
+
+ /* enable timestamp with original clock */
+ iowrite32be(FPM_TS_CTL_EN, &fpm_rg->fmfp_tsc1);
+}
+
+uint32_t fman_get_fpm_error_interrupts(struct fman_fpm_regs *fpm_rg)
+{
+ return ioread32be(&fpm_rg->fm_epi);
+}
+
+
+int fman_set_erratum_10gmac_a004_wa(struct fman_fpm_regs *fpm_rg)
+{
+ int timeout = 100;
+
+ iowrite32be(0x40000000, &fpm_rg->fmfp_extc);
+
+ while ((ioread32be(&fpm_rg->fmfp_extc) & 0x40000000) && --timeout)
+ DELAY(10);
+
+ if (!timeout)
+ return -EBUSY;
+ return 0;
+}
+
+void fman_set_ctrl_intr(struct fman_fpm_regs *fpm_rg,
+ uint8_t event_reg_id,
+ uint32_t enable_events)
+{
+ iowrite32be(enable_events, &fpm_rg->fmfp_cee[event_reg_id]);
+}
+
+uint32_t fman_get_ctrl_intr(struct fman_fpm_regs *fpm_rg, uint8_t event_reg_id)
+{
+ return ioread32be(&fpm_rg->fmfp_cee[event_reg_id]);
+}
+
+void fman_set_num_of_riscs_per_port(struct fman_fpm_regs *fpm_rg,
+ uint8_t port_id,
+ uint8_t num_fman_ctrls,
+ uint32_t or_fman_ctrl)
+{
+ uint32_t tmp = 0;
+
+ tmp = (uint32_t)(port_id << FPM_PORT_FM_CTL_PORTID_SHIFT);
+ /*TODO - maybe to put CTL# according to another criteria*/
+ if (num_fman_ctrls == 2)
+ tmp = FPM_PRT_FM_CTL2 | FPM_PRT_FM_CTL1;
+ /* order restoration */
+ tmp |= (or_fman_ctrl << FPM_PRC_ORA_FM_CTL_SEL_SHIFT) | or_fman_ctrl;
+
+ iowrite32be(tmp, &fpm_rg->fmfp_prc);
+}
+
+void fman_set_order_restoration_per_port(struct fman_fpm_regs *fpm_rg,
+ uint8_t port_id,
+ bool independent_mode,
+ bool is_rx_port)
+{
+ uint32_t tmp = 0;
+
+ tmp = (uint32_t)(port_id << FPM_PORT_FM_CTL_PORTID_SHIFT);
+ if (independent_mode) {
+ if (is_rx_port)
+ tmp |= (FPM_PRT_FM_CTL1 <<
+ FPM_PRC_ORA_FM_CTL_SEL_SHIFT) | FPM_PRT_FM_CTL1;
+ else
+ tmp |= (FPM_PRT_FM_CTL2 <<
+ FPM_PRC_ORA_FM_CTL_SEL_SHIFT) | FPM_PRT_FM_CTL2;
+ } else {
+ tmp |= (FPM_PRT_FM_CTL2|FPM_PRT_FM_CTL1);
+
+ /* order restoration */
+ if (port_id % 2)
+ tmp |= (FPM_PRT_FM_CTL1 <<
+ FPM_PRC_ORA_FM_CTL_SEL_SHIFT);
+ else
+ tmp |= (FPM_PRT_FM_CTL2 <<
+ FPM_PRC_ORA_FM_CTL_SEL_SHIFT);
+ }
+ iowrite32be(tmp, &fpm_rg->fmfp_prc);
+}
+
+uint8_t fman_get_qmi_deq_th(struct fman_qmi_regs *qmi_rg)
+{
+ return (uint8_t)ioread32be(&qmi_rg->fmqm_gc);
+}
+
+uint8_t fman_get_qmi_enq_th(struct fman_qmi_regs *qmi_rg)
+{
+ return (uint8_t)(ioread32be(&qmi_rg->fmqm_gc) >> 8);
+}
+
+void fman_set_qmi_enq_th(struct fman_qmi_regs *qmi_rg, uint8_t val)
+{
+ uint32_t tmp_reg;
+
+ tmp_reg = ioread32be(&qmi_rg->fmqm_gc);
+ tmp_reg &= ~QMI_CFG_ENQ_MASK;
+ tmp_reg |= ((uint32_t)val << 8);
+ iowrite32be(tmp_reg, &qmi_rg->fmqm_gc);
+}
+
+void fman_set_qmi_deq_th(struct fman_qmi_regs *qmi_rg, uint8_t val)
+{
+ uint32_t tmp_reg;
+
+ tmp_reg = ioread32be(&qmi_rg->fmqm_gc);
+ tmp_reg &= ~QMI_CFG_DEQ_MASK;
+ tmp_reg |= (uint32_t)val;
+ iowrite32be(tmp_reg, &qmi_rg->fmqm_gc);
+}
+
+void fman_qmi_disable_dispatch_limit(struct fman_fpm_regs *fpm_rg)
+{
+ iowrite32be(0, &fpm_rg->fmfp_mxd);
+}
+
+void fman_set_liodn_per_port(struct fman_rg *fman_rg, uint8_t port_id,
+ uint16_t liodn_base,
+ uint16_t liodn_ofst)
+{
+ uint32_t tmp;
+
+ if ((port_id > 63) || (port_id < 1))
+ return;
+
+ /* set LIODN base for this port */
+ tmp = ioread32be(&fman_rg->dma_rg->fmdmplr[port_id / 2]);
+ if (port_id % 2) {
+ tmp &= ~FM_LIODN_BASE_MASK;
+ tmp |= (uint32_t)liodn_base;
+ } else {
+ tmp &= ~(FM_LIODN_BASE_MASK << DMA_LIODN_SHIFT);
+ tmp |= (uint32_t)liodn_base << DMA_LIODN_SHIFT;
+ }
+ iowrite32be(tmp, &fman_rg->dma_rg->fmdmplr[port_id / 2]);
+ iowrite32be((uint32_t)liodn_ofst,
+ &fman_rg->bmi_rg->fmbm_spliodn[port_id - 1]);
+}
+
+bool fman_is_port_stalled(struct fman_fpm_regs *fpm_rg, uint8_t port_id)
+{
+ return (bool)!!(ioread32be(&fpm_rg->fmfp_ps[port_id]) & FPM_PS_STALLED);
+}
+
+void fman_resume_stalled_port(struct fman_fpm_regs *fpm_rg, uint8_t port_id)
+{
+ uint32_t tmp;
+
+ tmp = (uint32_t)((port_id << FPM_PORT_FM_CTL_PORTID_SHIFT) |
+ FPM_PRC_REALSE_STALLED);
+ iowrite32be(tmp, &fpm_rg->fmfp_prc);
+}
+
+int fman_reset_mac(struct fman_fpm_regs *fpm_rg, uint8_t mac_id, bool is_10g)
+{
+ uint32_t msk, timeout = 100;
+
+ /* Get the relevant bit mask */
+ if (is_10g) {
+ switch (mac_id) {
+ case(0):
+ msk = FPM_RSTC_10G0_RESET;
+ break;
+ case(1):
+ msk = FPM_RSTC_10G1_RESET;
+ break;
+ default:
+ return -EINVAL;
+ }
+ } else {
+ switch (mac_id) {
+ case(0):
+ msk = FPM_RSTC_1G0_RESET;
+ break;
+ case(1):
+ msk = FPM_RSTC_1G1_RESET;
+ break;
+ case(2):
+ msk = FPM_RSTC_1G2_RESET;
+ break;
+ case(3):
+ msk = FPM_RSTC_1G3_RESET;
+ break;
+ case(4):
+ msk = FPM_RSTC_1G4_RESET;
+ break;
+ case (5):
+ msk = FPM_RSTC_1G5_RESET;
+ break;
+ case (6):
+ msk = FPM_RSTC_1G6_RESET;
+ break;
+ case (7):
+ msk = FPM_RSTC_1G7_RESET;
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
+ /* reset */
+ iowrite32be(msk, &fpm_rg->fm_rstc);
+ while ((ioread32be(&fpm_rg->fm_rstc) & msk) && --timeout)
+ DELAY(10);
+
+ if (!timeout)
+ return -EBUSY;
+ return 0;
+}
+
+uint16_t fman_get_size_of_fifo(struct fman_bmi_regs *bmi_rg, uint8_t port_id)
+{
+ uint32_t tmp_reg;
+
+ if ((port_id > 63) || (port_id < 1))
+ return 0;
+
+ tmp_reg = ioread32be(&bmi_rg->fmbm_pfs[port_id - 1]);
+ return (uint16_t)((tmp_reg & BMI_FIFO_SIZE_MASK) + 1);
+}
+
+uint32_t fman_get_total_fifo_size(struct fman_bmi_regs *bmi_rg)
+{
+ uint32_t reg, res;
+
+ reg = ioread32be(&bmi_rg->fmbm_cfg1);
+ res = (reg >> BMI_CFG1_FIFO_SIZE_SHIFT) & 0x3ff;
+ return res * FMAN_BMI_FIFO_UNITS;
+}
+
+uint16_t fman_get_size_of_extra_fifo(struct fman_bmi_regs *bmi_rg,
+ uint8_t port_id)
+{
+ uint32_t tmp_reg;
+
+ if ((port_id > 63) || (port_id < 1))
+ return 0;
+
+ tmp_reg = ioread32be(&bmi_rg->fmbm_pfs[port_id-1]);
+ return (uint16_t)((tmp_reg & BMI_EXTRA_FIFO_SIZE_MASK) >>
+ BMI_EXTRA_FIFO_SIZE_SHIFT);
+}
+
+void fman_set_size_of_fifo(struct fman_bmi_regs *bmi_rg,
+ uint8_t port_id,
+ uint32_t sz_fifo,
+ uint32_t extra_sz_fifo)
+{
+ uint32_t tmp;
+
+ if ((port_id > 63) || (port_id < 1))
+ return;
+
+ /* calculate reg */
+ tmp = (uint32_t)((sz_fifo / FMAN_BMI_FIFO_UNITS - 1) |
+ ((extra_sz_fifo / FMAN_BMI_FIFO_UNITS) <<
+ BMI_EXTRA_FIFO_SIZE_SHIFT));
+ iowrite32be(tmp, &bmi_rg->fmbm_pfs[port_id - 1]);
+}
+
+uint8_t fman_get_num_of_tasks(struct fman_bmi_regs *bmi_rg, uint8_t port_id)
+{
+ uint32_t tmp;
+
+ if ((port_id > 63) || (port_id < 1))
+ return 0;
+
+ tmp = ioread32be(&bmi_rg->fmbm_pp[port_id - 1]);
+ return (uint8_t)(((tmp & BMI_NUM_OF_TASKS_MASK) >>
+ BMI_NUM_OF_TASKS_SHIFT) + 1);
+}
+
+uint8_t fman_get_num_extra_tasks(struct fman_bmi_regs *bmi_rg, uint8_t port_id)
+{
+ uint32_t tmp;
+
+ if ((port_id > 63) || (port_id < 1))
+ return 0;
+
+ tmp = ioread32be(&bmi_rg->fmbm_pp[port_id - 1]);
+ return (uint8_t)((tmp & BMI_NUM_OF_EXTRA_TASKS_MASK) >>
+ BMI_EXTRA_NUM_OF_TASKS_SHIFT);
+}
+
+void fman_set_num_of_tasks(struct fman_bmi_regs *bmi_rg,
+ uint8_t port_id,
+ uint8_t num_tasks,
+ uint8_t num_extra_tasks)
+{
+ uint32_t tmp;
+
+ if ((port_id > 63) || (port_id < 1))
+ return;
+
+ /* calculate reg */
+ tmp = ioread32be(&bmi_rg->fmbm_pp[port_id - 1]) &
+ ~(BMI_NUM_OF_TASKS_MASK | BMI_NUM_OF_EXTRA_TASKS_MASK);
+ tmp |= (uint32_t)(((num_tasks - 1) << BMI_NUM_OF_TASKS_SHIFT) |
+ (num_extra_tasks << BMI_EXTRA_NUM_OF_TASKS_SHIFT));
+ iowrite32be(tmp, &bmi_rg->fmbm_pp[port_id - 1]);
+}
+
+uint8_t fman_get_num_of_dmas(struct fman_bmi_regs *bmi_rg, uint8_t port_id)
+{
+ uint32_t tmp;
+
+ if ((port_id > 63) || (port_id < 1))
+ return 0;
+
+ tmp = ioread32be(&bmi_rg->fmbm_pp[port_id - 1]);
+ return (uint8_t)(((tmp & BMI_NUM_OF_DMAS_MASK) >>
+ BMI_NUM_OF_DMAS_SHIFT) + 1);
+}
+
+uint8_t fman_get_num_extra_dmas(struct fman_bmi_regs *bmi_rg, uint8_t port_id)
+{
+ uint32_t tmp;
+
+ if ((port_id > 63) || (port_id < 1))
+ return 0;
+
+ tmp = ioread32be(&bmi_rg->fmbm_pp[port_id - 1]);
+ return (uint8_t)((tmp & BMI_NUM_OF_EXTRA_DMAS_MASK) >>
+ BMI_EXTRA_NUM_OF_DMAS_SHIFT);
+}
+
+void fman_set_num_of_open_dmas(struct fman_bmi_regs *bmi_rg,
+ uint8_t port_id,
+ uint8_t num_open_dmas,
+ uint8_t num_extra_open_dmas,
+ uint8_t total_num_dmas)
+{
+ uint32_t tmp = 0;
+
+ if ((port_id > 63) || (port_id < 1))
+ return;
+
+ /* calculate reg */
+ tmp = ioread32be(&bmi_rg->fmbm_pp[port_id - 1]) &
+ ~(BMI_NUM_OF_DMAS_MASK | BMI_NUM_OF_EXTRA_DMAS_MASK);
+ tmp |= (uint32_t)(((num_open_dmas-1) << BMI_NUM_OF_DMAS_SHIFT) |
+ (num_extra_open_dmas << BMI_EXTRA_NUM_OF_DMAS_SHIFT));
+ iowrite32be(tmp, &bmi_rg->fmbm_pp[port_id - 1]);
+
+ /* update total num of DMA's with committed number of open DMAS,
+ * and max uncommitted pool. */
+ if (total_num_dmas)
+ {
+ tmp = ioread32be(&bmi_rg->fmbm_cfg2) & ~BMI_CFG2_DMAS_MASK;
+ tmp |= (uint32_t)(total_num_dmas - 1) << BMI_CFG2_DMAS_SHIFT;
+ iowrite32be(tmp, &bmi_rg->fmbm_cfg2);
+ }
+}
+
+void fman_set_vsp_window(struct fman_bmi_regs *bmi_rg,
+ uint8_t port_id,
+ uint8_t base_storage_profile,
+ uint8_t log2_num_of_profiles)
+{
+ uint32_t tmp = 0;
+ if ((port_id > 63) || (port_id < 1))
+ return;
+
+ tmp = ioread32be(&bmi_rg->fmbm_spliodn[port_id-1]);
+ tmp |= (uint32_t)((uint32_t)base_storage_profile & 0x3f) << 16;
+ tmp |= (uint32_t)log2_num_of_profiles << 28;
+ iowrite32be(tmp, &bmi_rg->fmbm_spliodn[port_id-1]);
+}
+
+void fman_set_congestion_group_pfc_priority(uint32_t *cpg_rg,
+ uint32_t congestion_group_id,
+ uint8_t priority_bit_map,
+ uint32_t reg_num)
+{
+ uint32_t offset, tmp = 0;
+
+ offset = (congestion_group_id%4)*8;
+
+ tmp = ioread32be(&cpg_rg[reg_num]);
+ tmp &= ~(0xFF<<offset);
+ tmp |= (uint32_t)priority_bit_map << offset;
+
+ iowrite32be(tmp,&cpg_rg[reg_num]);
+}
+
+/*****************************************************************************/
+/* API Init unit functions */
+/*****************************************************************************/
+void fman_defconfig(struct fman_cfg *cfg, bool is_master)
+{
+ memset(cfg, 0, sizeof(struct fman_cfg));
+
+ cfg->catastrophic_err = DEFAULT_CATASTROPHIC_ERR;
+ cfg->dma_err = DEFAULT_DMA_ERR;
+ cfg->halt_on_external_activ = DEFAULT_HALT_ON_EXTERNAL_ACTIVATION;
+ cfg->halt_on_unrecov_ecc_err = DEFAULT_HALT_ON_UNRECOVERABLE_ECC_ERROR;
+ cfg->en_iram_test_mode = FALSE;
+ cfg->en_muram_test_mode = FALSE;
+ cfg->external_ecc_rams_enable = DEFAULT_EXTERNAL_ECC_RAMS_ENABLE;
+
+ if (!is_master)
+ return;
+
+ cfg->dma_aid_override = DEFAULT_AID_OVERRIDE;
+ cfg->dma_aid_mode = DEFAULT_AID_MODE;
+ cfg->dma_comm_qtsh_clr_emer = DEFAULT_DMA_COMM_Q_LOW;
+ cfg->dma_comm_qtsh_asrt_emer = DEFAULT_DMA_COMM_Q_HIGH;
+ cfg->dma_cache_override = DEFAULT_CACHE_OVERRIDE;
+ cfg->dma_cam_num_of_entries = DEFAULT_DMA_CAM_NUM_OF_ENTRIES;
+ cfg->dma_dbg_cnt_mode = DEFAULT_DMA_DBG_CNT_MODE;
+ cfg->dma_en_emergency = DEFAULT_DMA_EN_EMERGENCY;
+ cfg->dma_sos_emergency = DEFAULT_DMA_SOS_EMERGENCY;
+ cfg->dma_watchdog = DEFAULT_DMA_WATCHDOG;
+ cfg->dma_en_emergency_smoother = DEFAULT_DMA_EN_EMERGENCY_SMOOTHER;
+ cfg->dma_emergency_switch_counter = DEFAULT_DMA_EMERGENCY_SWITCH_COUNTER;
+ cfg->disp_limit_tsh = DEFAULT_DISP_LIMIT;
+ cfg->prs_disp_tsh = DEFAULT_PRS_DISP_TH;
+ cfg->plcr_disp_tsh = DEFAULT_PLCR_DISP_TH;
+ cfg->kg_disp_tsh = DEFAULT_KG_DISP_TH;
+ cfg->bmi_disp_tsh = DEFAULT_BMI_DISP_TH;
+ cfg->qmi_enq_disp_tsh = DEFAULT_QMI_ENQ_DISP_TH;
+ cfg->qmi_deq_disp_tsh = DEFAULT_QMI_DEQ_DISP_TH;
+ cfg->fm_ctl1_disp_tsh = DEFAULT_FM_CTL1_DISP_TH;
+ cfg->fm_ctl2_disp_tsh = DEFAULT_FM_CTL2_DISP_TH;
+
+ cfg->pedantic_dma = FALSE;
+ cfg->tnum_aging_period = DEFAULT_TNUM_AGING_PERIOD;
+ cfg->dma_stop_on_bus_error = FALSE;
+ cfg->qmi_deq_option_support = FALSE;
+}
+
+void fman_regconfig(struct fman_rg *fman_rg, struct fman_cfg *cfg)
+{
+ uint32_t tmp_reg;
+
+ /* read the values from the registers as they are initialized by the HW with
+ * the required values.
+ */
+ tmp_reg = ioread32be(&fman_rg->bmi_rg->fmbm_cfg1);
+ cfg->total_fifo_size =
+ (((tmp_reg & BMI_TOTAL_FIFO_SIZE_MASK) >> BMI_CFG1_FIFO_SIZE_SHIFT) + 1) * FMAN_BMI_FIFO_UNITS;
+
+ tmp_reg = ioread32be(&fman_rg->bmi_rg->fmbm_cfg2);
+ cfg->total_num_of_tasks =
+ (uint8_t)(((tmp_reg & BMI_TOTAL_NUM_OF_TASKS_MASK) >> BMI_CFG2_TASKS_SHIFT) + 1);
+
+ tmp_reg = ioread32be(&fman_rg->dma_rg->fmdmtr);
+ cfg->dma_comm_qtsh_asrt_emer = (uint8_t)(tmp_reg >> DMA_THRESH_COMMQ_SHIFT);
+
+ tmp_reg = ioread32be(&fman_rg->dma_rg->fmdmhy);
+ cfg->dma_comm_qtsh_clr_emer = (uint8_t)(tmp_reg >> DMA_THRESH_COMMQ_SHIFT);
+
+ tmp_reg = ioread32be(&fman_rg->dma_rg->fmdmmr);
+ cfg->dma_cache_override = (enum fman_dma_cache_override)((tmp_reg & DMA_MODE_CACHE_OR_MASK) >> DMA_MODE_CACHE_OR_SHIFT);
+ cfg->dma_cam_num_of_entries = (uint8_t)((((tmp_reg & DMA_MODE_CEN_MASK) >> DMA_MODE_CEN_SHIFT) +1)*DMA_CAM_UNITS);
+ cfg->dma_aid_override = (bool)((tmp_reg & DMA_MODE_AID_OR)? TRUE:FALSE);
+ cfg->dma_dbg_cnt_mode = (enum fman_dma_dbg_cnt_mode)((tmp_reg & DMA_MODE_DBG_MASK) >> DMA_MODE_DBG_SHIFT);
+ cfg->dma_en_emergency = (bool)((tmp_reg & DMA_MODE_EB)? TRUE : FALSE);
+
+ tmp_reg = ioread32be(&fman_rg->fpm_rg->fmfp_mxd);
+ cfg->disp_limit_tsh = (uint8_t)((tmp_reg & FPM_DISP_LIMIT_MASK) >> FPM_DISP_LIMIT_SHIFT);
+
+ tmp_reg = ioread32be(&fman_rg->fpm_rg->fmfp_dist1);
+ cfg->prs_disp_tsh = (uint8_t)((tmp_reg & FPM_THR1_PRS_MASK ) >> FPM_THR1_PRS_SHIFT);
+ cfg->plcr_disp_tsh = (uint8_t)((tmp_reg & FPM_THR1_KG_MASK ) >> FPM_THR1_KG_SHIFT);
+ cfg->kg_disp_tsh = (uint8_t)((tmp_reg & FPM_THR1_PLCR_MASK ) >> FPM_THR1_PLCR_SHIFT);
+ cfg->bmi_disp_tsh = (uint8_t)((tmp_reg & FPM_THR1_BMI_MASK ) >> FPM_THR1_BMI_SHIFT);
+
+ tmp_reg = ioread32be(&fman_rg->fpm_rg->fmfp_dist2);
+ cfg->qmi_enq_disp_tsh = (uint8_t)((tmp_reg & FPM_THR2_QMI_ENQ_MASK ) >> FPM_THR2_QMI_ENQ_SHIFT);
+ cfg->qmi_deq_disp_tsh = (uint8_t)((tmp_reg & FPM_THR2_QMI_DEQ_MASK ) >> FPM_THR2_QMI_DEQ_SHIFT);
+ cfg->fm_ctl1_disp_tsh = (uint8_t)((tmp_reg & FPM_THR2_FM_CTL1_MASK ) >> FPM_THR2_FM_CTL1_SHIFT);
+ cfg->fm_ctl2_disp_tsh = (uint8_t)((tmp_reg & FPM_THR2_FM_CTL2_MASK ) >> FPM_THR2_FM_CTL2_SHIFT);
+
+ tmp_reg = ioread32be(&fman_rg->dma_rg->fmdmsetr);
+ cfg->dma_sos_emergency = tmp_reg;
+
+ tmp_reg = ioread32be(&fman_rg->dma_rg->fmdmwcr);
+ cfg->dma_watchdog = tmp_reg/cfg->clk_freq;
+
+ tmp_reg = ioread32be(&fman_rg->dma_rg->fmdmemsr);
+ cfg->dma_en_emergency_smoother = (bool)((tmp_reg & DMA_EMSR_EMSTR_MASK)? TRUE : FALSE);
+ cfg->dma_emergency_switch_counter = (tmp_reg & DMA_EMSR_EMSTR_MASK);
+}
+
+void fman_reset(struct fman_fpm_regs *fpm_rg)
+{
+ iowrite32be(FPM_RSTC_FM_RESET, &fpm_rg->fm_rstc);
+}
+
+/**************************************************************************//**
+ @Function FM_Init
+
+ @Description Initializes the FM module
+
+ @Param[in] h_Fm - FM module descriptor
+
+ @Return E_OK on success; Error code otherwise.
+*//***************************************************************************/
+int fman_dma_init(struct fman_dma_regs *dma_rg, struct fman_cfg *cfg)
+{
+ uint32_t tmp_reg;
+
+ /**********************/
+ /* Init DMA Registers */
+ /**********************/
+ /* clear status reg events */
+ /* oren - check!!! */
+ tmp_reg = (DMA_STATUS_BUS_ERR | DMA_STATUS_READ_ECC |
+ DMA_STATUS_SYSTEM_WRITE_ECC | DMA_STATUS_FM_WRITE_ECC);
+ iowrite32be(ioread32be(&dma_rg->fmdmsr) | tmp_reg,
+ &dma_rg->fmdmsr);
+
+ /* configure mode register */
+ tmp_reg = 0;
+ tmp_reg |= cfg->dma_cache_override << DMA_MODE_CACHE_OR_SHIFT;
+ if (cfg->dma_aid_override)
+ tmp_reg |= DMA_MODE_AID_OR;
+ if (cfg->exceptions & FMAN_EX_DMA_BUS_ERROR)
+ tmp_reg |= DMA_MODE_BER;
+ if ((cfg->exceptions & FMAN_EX_DMA_SYSTEM_WRITE_ECC) |
+ (cfg->exceptions & FMAN_EX_DMA_READ_ECC) |
+ (cfg->exceptions & FMAN_EX_DMA_FM_WRITE_ECC))
+ tmp_reg |= DMA_MODE_ECC;
+ if (cfg->dma_stop_on_bus_error)
+ tmp_reg |= DMA_MODE_SBER;
+ if(cfg->dma_axi_dbg_num_of_beats)
+ tmp_reg |= (uint32_t)(DMA_MODE_AXI_DBG_MASK &
+ ((cfg->dma_axi_dbg_num_of_beats - 1) << DMA_MODE_AXI_DBG_SHIFT));
+
+ if (cfg->dma_en_emergency) {
+ tmp_reg |= cfg->dma_emergency_bus_select;
+ tmp_reg |= cfg->dma_emergency_level << DMA_MODE_EMER_LVL_SHIFT;
+ if (cfg->dma_en_emergency_smoother)
+ iowrite32be(cfg->dma_emergency_switch_counter,
+ &dma_rg->fmdmemsr);
+ }
+ tmp_reg |= ((cfg->dma_cam_num_of_entries / DMA_CAM_UNITS) - 1) <<
+ DMA_MODE_CEN_SHIFT;
+ tmp_reg |= DMA_MODE_SECURE_PROT;
+ tmp_reg |= cfg->dma_dbg_cnt_mode << DMA_MODE_DBG_SHIFT;
+ tmp_reg |= cfg->dma_aid_mode << DMA_MODE_AID_MODE_SHIFT;
+
+ if (cfg->pedantic_dma)
+ tmp_reg |= DMA_MODE_EMER_READ;
+
+ iowrite32be(tmp_reg, &dma_rg->fmdmmr);
+
+ /* configure thresholds register */
+ tmp_reg = ((uint32_t)cfg->dma_comm_qtsh_asrt_emer <<
+ DMA_THRESH_COMMQ_SHIFT) |
+ ((uint32_t)cfg->dma_read_buf_tsh_asrt_emer <<
+ DMA_THRESH_READ_INT_BUF_SHIFT) |
+ ((uint32_t)cfg->dma_write_buf_tsh_asrt_emer);
+
+ iowrite32be(tmp_reg, &dma_rg->fmdmtr);
+
+ /* configure hysteresis register */
+ tmp_reg = ((uint32_t)cfg->dma_comm_qtsh_clr_emer <<
+ DMA_THRESH_COMMQ_SHIFT) |
+ ((uint32_t)cfg->dma_read_buf_tsh_clr_emer <<
+ DMA_THRESH_READ_INT_BUF_SHIFT) |
+ ((uint32_t)cfg->dma_write_buf_tsh_clr_emer);
+
+ iowrite32be(tmp_reg, &dma_rg->fmdmhy);
+
+ /* configure emergency threshold */
+ iowrite32be(cfg->dma_sos_emergency, &dma_rg->fmdmsetr);
+
+ /* configure Watchdog */
+ iowrite32be((cfg->dma_watchdog * cfg->clk_freq),
+ &dma_rg->fmdmwcr);
+
+ iowrite32be(cfg->cam_base_addr, &dma_rg->fmdmebcr);
+
+ return 0;
+}
+
+int fman_fpm_init(struct fman_fpm_regs *fpm_rg, struct fman_cfg *cfg)
+{
+ uint32_t tmp_reg;
+ int i;
+
+ /**********************/
+ /* Init FPM Registers */
+ /**********************/
+ tmp_reg = (uint32_t)(cfg->disp_limit_tsh << FPM_DISP_LIMIT_SHIFT);
+ iowrite32be(tmp_reg, &fpm_rg->fmfp_mxd);
+
+ tmp_reg = (((uint32_t)cfg->prs_disp_tsh << FPM_THR1_PRS_SHIFT) |
+ ((uint32_t)cfg->kg_disp_tsh << FPM_THR1_KG_SHIFT) |
+ ((uint32_t)cfg->plcr_disp_tsh << FPM_THR1_PLCR_SHIFT) |
+ ((uint32_t)cfg->bmi_disp_tsh << FPM_THR1_BMI_SHIFT));
+ iowrite32be(tmp_reg, &fpm_rg->fmfp_dist1);
+
+ tmp_reg = (((uint32_t)cfg->qmi_enq_disp_tsh << FPM_THR2_QMI_ENQ_SHIFT) |
+ ((uint32_t)cfg->qmi_deq_disp_tsh << FPM_THR2_QMI_DEQ_SHIFT) |
+ ((uint32_t)cfg->fm_ctl1_disp_tsh << FPM_THR2_FM_CTL1_SHIFT) |
+ ((uint32_t)cfg->fm_ctl2_disp_tsh << FPM_THR2_FM_CTL2_SHIFT));
+ iowrite32be(tmp_reg, &fpm_rg->fmfp_dist2);
+
+ /* define exceptions and error behavior */
+ tmp_reg = 0;
+ /* Clear events */
+ tmp_reg |= (FPM_EV_MASK_STALL | FPM_EV_MASK_DOUBLE_ECC |
+ FPM_EV_MASK_SINGLE_ECC);
+ /* enable interrupts */
+ if (cfg->exceptions & FMAN_EX_FPM_STALL_ON_TASKS)
+ tmp_reg |= FPM_EV_MASK_STALL_EN;
+ if (cfg->exceptions & FMAN_EX_FPM_SINGLE_ECC)
+ tmp_reg |= FPM_EV_MASK_SINGLE_ECC_EN;
+ if (cfg->exceptions & FMAN_EX_FPM_DOUBLE_ECC)
+ tmp_reg |= FPM_EV_MASK_DOUBLE_ECC_EN;
+ tmp_reg |= (cfg->catastrophic_err << FPM_EV_MASK_CAT_ERR_SHIFT);
+ tmp_reg |= (cfg->dma_err << FPM_EV_MASK_DMA_ERR_SHIFT);
+ if (!cfg->halt_on_external_activ)
+ tmp_reg |= FPM_EV_MASK_EXTERNAL_HALT;
+ if (!cfg->halt_on_unrecov_ecc_err)
+ tmp_reg |= FPM_EV_MASK_ECC_ERR_HALT;
+ iowrite32be(tmp_reg, &fpm_rg->fmfp_ee);
+
+ /* clear all fmCtls event registers */
+ for (i = 0; i < cfg->num_of_fman_ctrl_evnt_regs; i++)
+ iowrite32be(0xFFFFFFFF, &fpm_rg->fmfp_cev[i]);
+
+ /* RAM ECC - enable and clear events*/
+ /* first we need to clear all parser memory,
+ * as it is uninitialized and may cause ECC errors */
+ /* event bits */
+ tmp_reg = (FPM_RAM_MURAM_ECC | FPM_RAM_IRAM_ECC);
+ /* Rams enable not effected by RCR bit, but by a COP configuration */
+ if (cfg->external_ecc_rams_enable)
+ tmp_reg |= FPM_RAM_RAMS_ECC_EN_SRC_SEL;
+
+ /* enable test mode */
+ if (cfg->en_muram_test_mode)
+ tmp_reg |= FPM_RAM_MURAM_TEST_ECC;
+ if (cfg->en_iram_test_mode)
+ tmp_reg |= FPM_RAM_IRAM_TEST_ECC;
+ iowrite32be(tmp_reg, &fpm_rg->fm_rcr);
+
+ tmp_reg = 0;
+ if (cfg->exceptions & FMAN_EX_IRAM_ECC) {
+ tmp_reg |= FPM_IRAM_ECC_ERR_EX_EN;
+ fman_enable_rams_ecc(fpm_rg);
+ }
+ if (cfg->exceptions & FMAN_EX_NURAM_ECC) {
+ tmp_reg |= FPM_MURAM_ECC_ERR_EX_EN;
+ fman_enable_rams_ecc(fpm_rg);
+ }
+ iowrite32be(tmp_reg, &fpm_rg->fm_rie);
+
+ return 0;
+}
+
+int fman_bmi_init(struct fman_bmi_regs *bmi_rg, struct fman_cfg *cfg)
+{
+ uint32_t tmp_reg;
+
+ /**********************/
+ /* Init BMI Registers */
+ /**********************/
+
+ /* define common resources */
+ tmp_reg = cfg->fifo_base_addr;
+ tmp_reg = tmp_reg / BMI_FIFO_ALIGN;
+
+ tmp_reg |= ((cfg->total_fifo_size / FMAN_BMI_FIFO_UNITS - 1) <<
+ BMI_CFG1_FIFO_SIZE_SHIFT);
+ iowrite32be(tmp_reg, &bmi_rg->fmbm_cfg1);
+
+ tmp_reg = ((uint32_t)(cfg->total_num_of_tasks - 1) <<
+ BMI_CFG2_TASKS_SHIFT);
+ /* num of DMA's will be dynamically updated when each port is set */
+ iowrite32be(tmp_reg, &bmi_rg->fmbm_cfg2);
+
+ /* define unmaskable exceptions, enable and clear events */
+ tmp_reg = 0;
+ iowrite32be(BMI_ERR_INTR_EN_LIST_RAM_ECC |
+ BMI_ERR_INTR_EN_STORAGE_PROFILE_ECC |
+ BMI_ERR_INTR_EN_STATISTICS_RAM_ECC |
+ BMI_ERR_INTR_EN_DISPATCH_RAM_ECC,
+ &bmi_rg->fmbm_ievr);
+
+ if (cfg->exceptions & FMAN_EX_BMI_LIST_RAM_ECC)
+ tmp_reg |= BMI_ERR_INTR_EN_LIST_RAM_ECC;
+ if (cfg->exceptions & FMAN_EX_BMI_PIPELINE_ECC)
+ tmp_reg |= BMI_ERR_INTR_EN_STORAGE_PROFILE_ECC;
+ if (cfg->exceptions & FMAN_EX_BMI_STATISTICS_RAM_ECC)
+ tmp_reg |= BMI_ERR_INTR_EN_STATISTICS_RAM_ECC;
+ if (cfg->exceptions & FMAN_EX_BMI_DISPATCH_RAM_ECC)
+ tmp_reg |= BMI_ERR_INTR_EN_DISPATCH_RAM_ECC;
+ iowrite32be(tmp_reg, &bmi_rg->fmbm_ier);
+
+ return 0;
+}
+
+int fman_qmi_init(struct fman_qmi_regs *qmi_rg, struct fman_cfg *cfg)
+{
+ uint32_t tmp_reg;
+ uint16_t period_in_fm_clocks;
+ uint8_t remainder;
+ /**********************/
+ /* Init QMI Registers */
+ /**********************/
+ /* Clear error interrupt events */
+
+ iowrite32be(QMI_ERR_INTR_EN_DOUBLE_ECC | QMI_ERR_INTR_EN_DEQ_FROM_DEF,
+ &qmi_rg->fmqm_eie);
+ tmp_reg = 0;
+ if (cfg->exceptions & FMAN_EX_QMI_DEQ_FROM_UNKNOWN_PORTID)
+ tmp_reg |= QMI_ERR_INTR_EN_DEQ_FROM_DEF;
+ if (cfg->exceptions & FMAN_EX_QMI_DOUBLE_ECC)
+ tmp_reg |= QMI_ERR_INTR_EN_DOUBLE_ECC;
+ /* enable events */
+ iowrite32be(tmp_reg, &qmi_rg->fmqm_eien);
+
+ if (cfg->tnum_aging_period) {
+ /* tnum_aging_period is in units of usec, p_FmClockFreq in Mhz */
+ period_in_fm_clocks = (uint16_t)
+ (cfg->tnum_aging_period * cfg->clk_freq);
+ /* period_in_fm_clocks must be a 64 multiply */
+ remainder = (uint8_t)(period_in_fm_clocks % 64);
+ if (remainder)
+ tmp_reg = (uint32_t)((period_in_fm_clocks / 64) + 1);
+ else{
+ tmp_reg = (uint32_t)(period_in_fm_clocks / 64);
+ if (!tmp_reg)
+ tmp_reg = 1;
+ }
+ tmp_reg <<= QMI_TAPC_TAP;
+ iowrite32be(tmp_reg, &qmi_rg->fmqm_tapc);
+ }
+ tmp_reg = 0;
+ /* Clear interrupt events */
+ iowrite32be(QMI_INTR_EN_SINGLE_ECC, &qmi_rg->fmqm_ie);
+ if (cfg->exceptions & FMAN_EX_QMI_SINGLE_ECC)
+ tmp_reg |= QMI_INTR_EN_SINGLE_ECC;
+ /* enable events */
+ iowrite32be(tmp_reg, &qmi_rg->fmqm_ien);
+
+ return 0;
+}
+
+int fman_enable(struct fman_rg *fman_rg, struct fman_cfg *cfg)
+{
+ uint32_t cfg_reg = 0;
+
+ /**********************/
+ /* Enable all modules */
+ /**********************/
+ /* clear & enable global counters - calculate reg and save for later,
+ because it's the same reg for QMI enable */
+ cfg_reg = QMI_CFG_EN_COUNTERS;
+ if (cfg->qmi_deq_option_support)
+ cfg_reg |= (uint32_t)(((cfg->qmi_def_tnums_thresh) << 8) |
+ (uint32_t)cfg->qmi_def_tnums_thresh);
+
+ iowrite32be(BMI_INIT_START, &fman_rg->bmi_rg->fmbm_init);
+ iowrite32be(cfg_reg | QMI_CFG_ENQ_EN | QMI_CFG_DEQ_EN,
+ &fman_rg->qmi_rg->fmqm_gc);
+
+ return 0;
+}
+
+void fman_free_resources(struct fman_rg *fman_rg)
+{
+ /* disable BMI and QMI */
+ iowrite32be(0, &fman_rg->bmi_rg->fmbm_init);
+ iowrite32be(0, &fman_rg->qmi_rg->fmqm_gc);
+
+ /* release BMI resources */
+ iowrite32be(0, &fman_rg->bmi_rg->fmbm_cfg2);
+ iowrite32be(0, &fman_rg->bmi_rg->fmbm_cfg1);
+
+ /* disable ECC */
+ iowrite32be(0, &fman_rg->fpm_rg->fm_rcr);
+}
+
+/****************************************************/
+/* API Run-time Control uint functions */
+/****************************************************/
+uint32_t fman_get_normal_pending(struct fman_fpm_regs *fpm_rg)
+{
+ return ioread32be(&fpm_rg->fm_npi);
+}
+
+uint32_t fman_get_controller_event(struct fman_fpm_regs *fpm_rg, uint8_t reg_id)
+{
+ uint32_t event;
+
+ event = ioread32be(&fpm_rg->fmfp_fcev[reg_id]) &
+ ioread32be(&fpm_rg->fmfp_cee[reg_id]);
+ iowrite32be(event, &fpm_rg->fmfp_cev[reg_id]);
+
+ return event;
+}
+
+uint32_t fman_get_error_pending(struct fman_fpm_regs *fpm_rg)
+{
+ return ioread32be(&fpm_rg->fm_epi);
+}
+
+void fman_set_ports_bandwidth(struct fman_bmi_regs *bmi_rg, uint8_t *weights)
+{
+ int i;
+ uint8_t shift;
+ uint32_t tmp = 0;
+
+ for (i = 0; i < 64; i++) {
+ if (weights[i] > 1) { /* no need to write 1 since it is 0 */
+ /* Add this port to tmp_reg */
+ /* (each 8 ports result in one register)*/
+ shift = (uint8_t)(32 - 4 * ((i % 8) + 1));
+ tmp |= ((weights[i] - 1) << shift);
+ }
+ if (i % 8 == 7) { /* last in this set */
+ iowrite32be(tmp, &bmi_rg->fmbm_arb[i / 8]);
+ tmp = 0;
+ }
+ }
+}
+
+void fman_enable_rams_ecc(struct fman_fpm_regs *fpm_rg)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&fpm_rg->fm_rcr);
+ if (tmp & FPM_RAM_RAMS_ECC_EN_SRC_SEL)
+ iowrite32be(tmp | FPM_RAM_IRAM_ECC_EN,
+ &fpm_rg->fm_rcr);
+ else
+ iowrite32be(tmp | FPM_RAM_RAMS_ECC_EN |
+ FPM_RAM_IRAM_ECC_EN,
+ &fpm_rg->fm_rcr);
+}
+
+void fman_disable_rams_ecc(struct fman_fpm_regs *fpm_rg)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&fpm_rg->fm_rcr);
+ if (tmp & FPM_RAM_RAMS_ECC_EN_SRC_SEL)
+ iowrite32be(tmp & ~FPM_RAM_IRAM_ECC_EN,
+ &fpm_rg->fm_rcr);
+ else
+ iowrite32be(tmp & ~(FPM_RAM_RAMS_ECC_EN | FPM_RAM_IRAM_ECC_EN),
+ &fpm_rg->fm_rcr);
+}
+
+int fman_set_exception(struct fman_rg *fman_rg,
+ enum fman_exceptions exception,
+ bool enable)
+{
+ uint32_t tmp;
+
+ switch (exception) {
+ case(E_FMAN_EX_DMA_BUS_ERROR):
+ tmp = ioread32be(&fman_rg->dma_rg->fmdmmr);
+ if (enable)
+ tmp |= DMA_MODE_BER;
+ else
+ tmp &= ~DMA_MODE_BER;
+ /* disable bus error */
+ iowrite32be(tmp, &fman_rg->dma_rg->fmdmmr);
+ break;
+ case(E_FMAN_EX_DMA_READ_ECC):
+ case(E_FMAN_EX_DMA_SYSTEM_WRITE_ECC):
+ case(E_FMAN_EX_DMA_FM_WRITE_ECC):
+ tmp = ioread32be(&fman_rg->dma_rg->fmdmmr);
+ if (enable)
+ tmp |= DMA_MODE_ECC;
+ else
+ tmp &= ~DMA_MODE_ECC;
+ iowrite32be(tmp, &fman_rg->dma_rg->fmdmmr);
+ break;
+ case(E_FMAN_EX_FPM_STALL_ON_TASKS):
+ tmp = ioread32be(&fman_rg->fpm_rg->fmfp_ee);
+ if (enable)
+ tmp |= FPM_EV_MASK_STALL_EN;
+ else
+ tmp &= ~FPM_EV_MASK_STALL_EN;
+ iowrite32be(tmp, &fman_rg->fpm_rg->fmfp_ee);
+ break;
+ case(E_FMAN_EX_FPM_SINGLE_ECC):
+ tmp = ioread32be(&fman_rg->fpm_rg->fmfp_ee);
+ if (enable)
+ tmp |= FPM_EV_MASK_SINGLE_ECC_EN;
+ else
+ tmp &= ~FPM_EV_MASK_SINGLE_ECC_EN;
+ iowrite32be(tmp, &fman_rg->fpm_rg->fmfp_ee);
+ break;
+ case(E_FMAN_EX_FPM_DOUBLE_ECC):
+ tmp = ioread32be(&fman_rg->fpm_rg->fmfp_ee);
+ if (enable)
+ tmp |= FPM_EV_MASK_DOUBLE_ECC_EN;
+ else
+ tmp &= ~FPM_EV_MASK_DOUBLE_ECC_EN;
+ iowrite32be(tmp, &fman_rg->fpm_rg->fmfp_ee);
+ break;
+ case(E_FMAN_EX_QMI_SINGLE_ECC):
+ tmp = ioread32be(&fman_rg->qmi_rg->fmqm_ien);
+ if (enable)
+ tmp |= QMI_INTR_EN_SINGLE_ECC;
+ else
+ tmp &= ~QMI_INTR_EN_SINGLE_ECC;
+ iowrite32be(tmp, &fman_rg->qmi_rg->fmqm_ien);
+ break;
+ case(E_FMAN_EX_QMI_DOUBLE_ECC):
+ tmp = ioread32be(&fman_rg->qmi_rg->fmqm_eien);
+ if (enable)
+ tmp |= QMI_ERR_INTR_EN_DOUBLE_ECC;
+ else
+ tmp &= ~QMI_ERR_INTR_EN_DOUBLE_ECC;
+ iowrite32be(tmp, &fman_rg->qmi_rg->fmqm_eien);
+ break;
+ case(E_FMAN_EX_QMI_DEQ_FROM_UNKNOWN_PORTID):
+ tmp = ioread32be(&fman_rg->qmi_rg->fmqm_eien);
+ if (enable)
+ tmp |= QMI_ERR_INTR_EN_DEQ_FROM_DEF;
+ else
+ tmp &= ~QMI_ERR_INTR_EN_DEQ_FROM_DEF;
+ iowrite32be(tmp, &fman_rg->qmi_rg->fmqm_eien);
+ break;
+ case(E_FMAN_EX_BMI_LIST_RAM_ECC):
+ tmp = ioread32be(&fman_rg->bmi_rg->fmbm_ier);
+ if (enable)
+ tmp |= BMI_ERR_INTR_EN_LIST_RAM_ECC;
+ else
+ tmp &= ~BMI_ERR_INTR_EN_LIST_RAM_ECC;
+ iowrite32be(tmp, &fman_rg->bmi_rg->fmbm_ier);
+ break;
+ case(E_FMAN_EX_BMI_STORAGE_PROFILE_ECC):
+ tmp = ioread32be(&fman_rg->bmi_rg->fmbm_ier);
+ if (enable)
+ tmp |= BMI_ERR_INTR_EN_STORAGE_PROFILE_ECC;
+ else
+ tmp &= ~BMI_ERR_INTR_EN_STORAGE_PROFILE_ECC;
+ iowrite32be(tmp, &fman_rg->bmi_rg->fmbm_ier);
+ break;
+ case(E_FMAN_EX_BMI_STATISTICS_RAM_ECC):
+ tmp = ioread32be(&fman_rg->bmi_rg->fmbm_ier);
+ if (enable)
+ tmp |= BMI_ERR_INTR_EN_STATISTICS_RAM_ECC;
+ else
+ tmp &= ~BMI_ERR_INTR_EN_STATISTICS_RAM_ECC;
+ iowrite32be(tmp, &fman_rg->bmi_rg->fmbm_ier);
+ break;
+ case(E_FMAN_EX_BMI_DISPATCH_RAM_ECC):
+ tmp = ioread32be(&fman_rg->bmi_rg->fmbm_ier);
+ if (enable)
+ tmp |= BMI_ERR_INTR_EN_DISPATCH_RAM_ECC;
+ else
+ tmp &= ~BMI_ERR_INTR_EN_DISPATCH_RAM_ECC;
+ iowrite32be(tmp, &fman_rg->bmi_rg->fmbm_ier);
+ break;
+ case(E_FMAN_EX_IRAM_ECC):
+ tmp = ioread32be(&fman_rg->fpm_rg->fm_rie);
+ if (enable) {
+ /* enable ECC if not enabled */
+ fman_enable_rams_ecc(fman_rg->fpm_rg);
+ /* enable ECC interrupts */
+ tmp |= FPM_IRAM_ECC_ERR_EX_EN;
+ } else {
+ /* ECC mechanism may be disabled,
+ * depending on driver status */
+ fman_disable_rams_ecc(fman_rg->fpm_rg);
+ tmp &= ~FPM_IRAM_ECC_ERR_EX_EN;
+ }
+ iowrite32be(tmp, &fman_rg->fpm_rg->fm_rie);
+ break;
+ case(E_FMAN_EX_MURAM_ECC):
+ tmp = ioread32be(&fman_rg->fpm_rg->fm_rie);
+ if (enable) {
+ /* enable ECC if not enabled */
+ fman_enable_rams_ecc(fman_rg->fpm_rg);
+ /* enable ECC interrupts */
+ tmp |= FPM_MURAM_ECC_ERR_EX_EN;
+ } else {
+ /* ECC mechanism may be disabled,
+ * depending on driver status */
+ fman_disable_rams_ecc(fman_rg->fpm_rg);
+ tmp &= ~FPM_MURAM_ECC_ERR_EX_EN;
+ }
+ iowrite32be(tmp, &fman_rg->fpm_rg->fm_rie);
+ break;
+ default:
+ return -EINVAL;
+ }
+ return 0;
+}
+
+void fman_get_revision(struct fman_fpm_regs *fpm_rg,
+ uint8_t *major,
+ uint8_t *minor)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&fpm_rg->fm_ip_rev_1);
+ *major = (uint8_t)((tmp & FPM_REV1_MAJOR_MASK) >> FPM_REV1_MAJOR_SHIFT);
+ *minor = (uint8_t)((tmp & FPM_REV1_MINOR_MASK) >> FPM_REV1_MINOR_SHIFT);
+
+}
+
+uint32_t fman_get_counter(struct fman_rg *fman_rg,
+ enum fman_counters reg_name)
+{
+ uint32_t ret_val;
+
+ switch (reg_name) {
+ case(E_FMAN_COUNTERS_ENQ_TOTAL_FRAME):
+ ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_etfc);
+ break;
+ case(E_FMAN_COUNTERS_DEQ_TOTAL_FRAME):
+ ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_dtfc);
+ break;
+ case(E_FMAN_COUNTERS_DEQ_0):
+ ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_dc0);
+ break;
+ case(E_FMAN_COUNTERS_DEQ_1):
+ ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_dc1);
+ break;
+ case(E_FMAN_COUNTERS_DEQ_2):
+ ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_dc2);
+ break;
+ case(E_FMAN_COUNTERS_DEQ_3):
+ ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_dc3);
+ break;
+ case(E_FMAN_COUNTERS_DEQ_FROM_DEFAULT):
+ ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_dfdc);
+ break;
+ case(E_FMAN_COUNTERS_DEQ_FROM_CONTEXT):
+ ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_dfcc);
+ break;
+ case(E_FMAN_COUNTERS_DEQ_FROM_FD):
+ ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_dffc);
+ break;
+ case(E_FMAN_COUNTERS_DEQ_CONFIRM):
+ ret_val = ioread32be(&fman_rg->qmi_rg->fmqm_dcc);
+ break;
+ default:
+ ret_val = 0;
+ }
+ return ret_val;
+}
+
+int fman_modify_counter(struct fman_rg *fman_rg,
+ enum fman_counters reg_name,
+ uint32_t val)
+{
+ /* When applicable (when there is an 'enable counters' bit,
+ * check that counters are enabled */
+ switch (reg_name) {
+ case(E_FMAN_COUNTERS_ENQ_TOTAL_FRAME):
+ case(E_FMAN_COUNTERS_DEQ_TOTAL_FRAME):
+ case(E_FMAN_COUNTERS_DEQ_0):
+ case(E_FMAN_COUNTERS_DEQ_1):
+ case(E_FMAN_COUNTERS_DEQ_2):
+ case(E_FMAN_COUNTERS_DEQ_3):
+ case(E_FMAN_COUNTERS_DEQ_FROM_DEFAULT):
+ case(E_FMAN_COUNTERS_DEQ_FROM_CONTEXT):
+ case(E_FMAN_COUNTERS_DEQ_FROM_FD):
+ case(E_FMAN_COUNTERS_DEQ_CONFIRM):
+ if (!(ioread32be(&fman_rg->qmi_rg->fmqm_gc) &
+ QMI_CFG_EN_COUNTERS))
+ return -EINVAL;
+ break;
+ default:
+ break;
+ }
+ /* Set counter */
+ switch (reg_name) {
+ case(E_FMAN_COUNTERS_ENQ_TOTAL_FRAME):
+ iowrite32be(val, &fman_rg->qmi_rg->fmqm_etfc);
+ break;
+ case(E_FMAN_COUNTERS_DEQ_TOTAL_FRAME):
+ iowrite32be(val, &fman_rg->qmi_rg->fmqm_dtfc);
+ break;
+ case(E_FMAN_COUNTERS_DEQ_0):
+ iowrite32be(val, &fman_rg->qmi_rg->fmqm_dc0);
+ break;
+ case(E_FMAN_COUNTERS_DEQ_1):
+ iowrite32be(val, &fman_rg->qmi_rg->fmqm_dc1);
+ break;
+ case(E_FMAN_COUNTERS_DEQ_2):
+ iowrite32be(val, &fman_rg->qmi_rg->fmqm_dc2);
+ break;
+ case(E_FMAN_COUNTERS_DEQ_3):
+ iowrite32be(val, &fman_rg->qmi_rg->fmqm_dc3);
+ break;
+ case(E_FMAN_COUNTERS_DEQ_FROM_DEFAULT):
+ iowrite32be(val, &fman_rg->qmi_rg->fmqm_dfdc);
+ break;
+ case(E_FMAN_COUNTERS_DEQ_FROM_CONTEXT):
+ iowrite32be(val, &fman_rg->qmi_rg->fmqm_dfcc);
+ break;
+ case(E_FMAN_COUNTERS_DEQ_FROM_FD):
+ iowrite32be(val, &fman_rg->qmi_rg->fmqm_dffc);
+ break;
+ case(E_FMAN_COUNTERS_DEQ_CONFIRM):
+ iowrite32be(val, &fman_rg->qmi_rg->fmqm_dcc);
+ break;
+ case(E_FMAN_COUNTERS_SEMAPHOR_ENTRY_FULL_REJECT):
+ iowrite32be(val, &fman_rg->dma_rg->fmdmsefrc);
+ break;
+ case(E_FMAN_COUNTERS_SEMAPHOR_QUEUE_FULL_REJECT):
+ iowrite32be(val, &fman_rg->dma_rg->fmdmsqfrc);
+ break;
+ case(E_FMAN_COUNTERS_SEMAPHOR_SYNC_REJECT):
+ iowrite32be(val, &fman_rg->dma_rg->fmdmssrc);
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
+
+void fman_set_dma_emergency(struct fman_dma_regs *dma_rg,
+ bool is_write,
+ bool enable)
+{
+ uint32_t msk;
+
+ msk = (uint32_t)(is_write ? DMA_MODE_EMER_WRITE : DMA_MODE_EMER_READ);
+
+ if (enable)
+ iowrite32be(ioread32be(&dma_rg->fmdmmr) | msk,
+ &dma_rg->fmdmmr);
+ else /* disable */
+ iowrite32be(ioread32be(&dma_rg->fmdmmr) & ~msk,
+ &dma_rg->fmdmmr);
+}
+
+void fman_set_dma_ext_bus_pri(struct fman_dma_regs *dma_rg, uint32_t pri)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&dma_rg->fmdmmr) |
+ (pri << DMA_MODE_BUS_PRI_SHIFT);
+
+ iowrite32be(tmp, &dma_rg->fmdmmr);
+}
+
+uint32_t fman_get_dma_status(struct fman_dma_regs *dma_rg)
+{
+ return ioread32be(&dma_rg->fmdmsr);
+}
+
+void fman_force_intr(struct fman_rg *fman_rg,
+ enum fman_exceptions exception)
+{
+ switch (exception) {
+ case E_FMAN_EX_QMI_DEQ_FROM_UNKNOWN_PORTID:
+ iowrite32be(QMI_ERR_INTR_EN_DEQ_FROM_DEF,
+ &fman_rg->qmi_rg->fmqm_eif);
+ break;
+ case E_FMAN_EX_QMI_SINGLE_ECC:
+ iowrite32be(QMI_INTR_EN_SINGLE_ECC,
+ &fman_rg->qmi_rg->fmqm_if);
+ break;
+ case E_FMAN_EX_QMI_DOUBLE_ECC:
+ iowrite32be(QMI_ERR_INTR_EN_DOUBLE_ECC,
+ &fman_rg->qmi_rg->fmqm_eif);
+ break;
+ case E_FMAN_EX_BMI_LIST_RAM_ECC:
+ iowrite32be(BMI_ERR_INTR_EN_LIST_RAM_ECC,
+ &fman_rg->bmi_rg->fmbm_ifr);
+ break;
+ case E_FMAN_EX_BMI_STORAGE_PROFILE_ECC:
+ iowrite32be(BMI_ERR_INTR_EN_STORAGE_PROFILE_ECC,
+ &fman_rg->bmi_rg->fmbm_ifr);
+ break;
+ case E_FMAN_EX_BMI_STATISTICS_RAM_ECC:
+ iowrite32be(BMI_ERR_INTR_EN_STATISTICS_RAM_ECC,
+ &fman_rg->bmi_rg->fmbm_ifr);
+ break;
+ case E_FMAN_EX_BMI_DISPATCH_RAM_ECC:
+ iowrite32be(BMI_ERR_INTR_EN_DISPATCH_RAM_ECC,
+ &fman_rg->bmi_rg->fmbm_ifr);
+ break;
+ default:
+ break;
+ }
+}
+
+bool fman_is_qmi_halt_not_busy_state(struct fman_qmi_regs *qmi_rg)
+{
+ return (bool)!!(ioread32be(&qmi_rg->fmqm_gs) & QMI_GS_HALT_NOT_BUSY);
+}
+void fman_resume(struct fman_fpm_regs *fpm_rg)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&fpm_rg->fmfp_ee);
+ /* clear tmp_reg event bits in order not to clear standing events */
+ tmp &= ~(FPM_EV_MASK_DOUBLE_ECC |
+ FPM_EV_MASK_STALL |
+ FPM_EV_MASK_SINGLE_ECC);
+ tmp |= FPM_EV_MASK_RELEASE_FM;
+
+ iowrite32be(tmp, &fpm_rg->fmfp_ee);
+}
diff --git a/sys/contrib/ncsw/Peripherals/FM/inc/fm_common.h b/sys/contrib/ncsw/Peripherals/FM/inc/fm_common.h
index d1aaa3d83fea..81a25e976b62 100644
--- a/sys/contrib/ncsw/Peripherals/FM/inc/fm_common.h
+++ b/sys/contrib/ncsw/Peripherals/FM/inc/fm_common.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/******************************************************************************
@File fm_common.h
@@ -41,20 +42,112 @@
#include "error_ext.h"
#include "std_ext.h"
#include "fm_pcd_ext.h"
+#include "fm_ext.h"
#include "fm_port_ext.h"
+
+#define e_FM_PORT_TYPE_OH_HOST_COMMAND e_FM_PORT_TYPE_DUMMY
+
#define CLS_PLAN_NUM_PER_GRP 8
+#define IP_OFFLOAD_PACKAGE_NUMBER 106
+#define CAPWAP_OFFLOAD_PACKAGE_NUMBER 108
+#define IS_OFFLOAD_PACKAGE(num) ((num == IP_OFFLOAD_PACKAGE_NUMBER) || (num == CAPWAP_OFFLOAD_PACKAGE_NUMBER))
+
+
+
+/**************************************************************************//**
+ @Description Modules registers offsets
+*//***************************************************************************/
+#define FM_MM_MURAM 0x00000000
+#define FM_MM_BMI 0x00080000
+#define FM_MM_QMI 0x00080400
+#define FM_MM_PRS 0x000c7000
+#define FM_MM_KG 0x000C1000
+#define FM_MM_DMA 0x000C2000
+#define FM_MM_FPM 0x000C3000
+#define FM_MM_PLCR 0x000C0000
+#define FM_MM_IMEM 0x000C4000
+#define FM_MM_CGP 0x000DB000
+#define FM_MM_TRB(i) (0x000D0200 + 0x400 * (i))
+#if (DPAA_VERSION >= 11)
+#define FM_MM_SP 0x000dc000
+#endif /* (DPAA_VERSION >= 11) */
+
+
+/**************************************************************************//**
+ @Description Enum for inter-module interrupts registration
+*//***************************************************************************/
+typedef enum e_FmEventModules{
+ e_FM_MOD_PRS, /**< Parser event */
+ e_FM_MOD_KG, /**< Keygen event */
+ e_FM_MOD_PLCR, /**< Policer event */
+ e_FM_MOD_10G_MAC, /**< 10G MAC event */
+ e_FM_MOD_1G_MAC, /**< 1G MAC event */
+ e_FM_MOD_TMR, /**< Timer event */
+ e_FM_MOD_FMAN_CTRL, /**< FMAN Controller Timer event */
+ e_FM_MOD_MACSEC,
+ e_FM_MOD_DUMMY_LAST
+} e_FmEventModules;
+
+/**************************************************************************//**
+ @Description Enum for interrupts types
+*//***************************************************************************/
+typedef enum e_FmIntrType {
+ e_FM_INTR_TYPE_ERR,
+ e_FM_INTR_TYPE_NORMAL
+} e_FmIntrType;
+
+/**************************************************************************//**
+ @Description Enum for inter-module interrupts registration
+*//***************************************************************************/
+typedef enum e_FmInterModuleEvent
+{
+ e_FM_EV_PRS = 0, /**< Parser event */
+ e_FM_EV_ERR_PRS, /**< Parser error event */
+ e_FM_EV_KG, /**< Keygen event */
+ e_FM_EV_ERR_KG, /**< Keygen error event */
+ e_FM_EV_PLCR, /**< Policer event */
+ e_FM_EV_ERR_PLCR, /**< Policer error event */
+ e_FM_EV_ERR_10G_MAC0, /**< 10G MAC 0 error event */
+ e_FM_EV_ERR_10G_MAC1, /**< 10G MAC 1 error event */
+ e_FM_EV_ERR_1G_MAC0, /**< 1G MAC 0 error event */
+ e_FM_EV_ERR_1G_MAC1, /**< 1G MAC 1 error event */
+ e_FM_EV_ERR_1G_MAC2, /**< 1G MAC 2 error event */
+ e_FM_EV_ERR_1G_MAC3, /**< 1G MAC 3 error event */
+ e_FM_EV_ERR_1G_MAC4, /**< 1G MAC 4 error event */
+ e_FM_EV_ERR_1G_MAC5, /**< 1G MAC 5 error event */
+ e_FM_EV_ERR_1G_MAC6, /**< 1G MAC 6 error event */
+ e_FM_EV_ERR_1G_MAC7, /**< 1G MAC 7 error event */
+ e_FM_EV_ERR_MACSEC_MAC0,
+ e_FM_EV_TMR, /**< Timer event */
+ e_FM_EV_10G_MAC0, /**< 10G MAC 0 event (Magic packet detection)*/
+ e_FM_EV_10G_MAC1, /**< 10G MAC 1 event (Magic packet detection)*/
+ e_FM_EV_1G_MAC0, /**< 1G MAC 0 event (Magic packet detection)*/
+ e_FM_EV_1G_MAC1, /**< 1G MAC 1 event (Magic packet detection)*/
+ e_FM_EV_1G_MAC2, /**< 1G MAC 2 (Magic packet detection)*/
+ e_FM_EV_1G_MAC3, /**< 1G MAC 3 (Magic packet detection)*/
+ e_FM_EV_1G_MAC4, /**< 1G MAC 4 (Magic packet detection)*/
+ e_FM_EV_1G_MAC5, /**< 1G MAC 5 (Magic packet detection)*/
+ e_FM_EV_1G_MAC6, /**< 1G MAC 6 (Magic packet detection)*/
+ e_FM_EV_1G_MAC7, /**< 1G MAC 7 (Magic packet detection)*/
+ e_FM_EV_MACSEC_MAC0, /**< MACSEC MAC 0 event */
+ e_FM_EV_FMAN_CTRL_0, /**< Fman controller event 0 */
+ e_FM_EV_FMAN_CTRL_1, /**< Fman controller event 1 */
+ e_FM_EV_FMAN_CTRL_2, /**< Fman controller event 2 */
+ e_FM_EV_FMAN_CTRL_3, /**< Fman controller event 3 */
+ e_FM_EV_DUMMY_LAST
+} e_FmInterModuleEvent;
+
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(push,1)
#endif /* defined(__MWERKS__) && ... */
-#define MEM_MAP_START
/**************************************************************************//**
@Description PCD KG scheme registers
*//***************************************************************************/
-typedef _Packed struct t_FmPcdPlcrInterModuleProfileRegs {
+typedef _Packed struct t_FmPcdPlcrProfileRegs {
volatile uint32_t fmpl_pemode; /* 0x090 FMPL_PEMODE - FM Policer Profile Entry Mode*/
volatile uint32_t fmpl_pegnia; /* 0x094 FMPL_PEGNIA - FM Policer Profile Entry GREEN Next Invoked Action*/
volatile uint32_t fmpl_peynia; /* 0x098 FMPL_PEYNIA - FM Policer Profile Entry YELLOW Next Invoked Action*/
@@ -72,28 +165,8 @@ typedef _Packed struct t_FmPcdPlcrInterModuleProfileRegs {
volatile uint32_t fmpl_perypc; /* 0x0C8 FMPL_PERYPC - FM Policer Profile Entry Recolored YELLOW Packet Counter*/
volatile uint32_t fmpl_perrpc; /* 0x0CC FMPL_PERRPC - FM Policer Profile Entry Recolored RED Packet Counter*/
volatile uint32_t fmpl_res1[12]; /* 0x0D0-0x0FF Reserved */
-} _PackedType t_FmPcdPlcrInterModuleProfileRegs;
+} _PackedType t_FmPcdPlcrProfileRegs;
-/**************************************************************************//**
- @Description PCD KG scheme registers
-*//***************************************************************************/
-typedef _Packed struct t_FmPcdKgInterModuleSchemeRegs {
- volatile uint32_t kgse_mode; /**< MODE */
- volatile uint32_t kgse_ekfc; /**< Extract Known Fields Command */
- volatile uint32_t kgse_ekdv; /**< Extract Known Default Value */
- volatile uint32_t kgse_bmch; /**< Bit Mask Command High */
- volatile uint32_t kgse_bmcl; /**< Bit Mask Command Low */
- volatile uint32_t kgse_fqb; /**< Frame Queue Base */
- volatile uint32_t kgse_hc; /**< Hash Command */
- volatile uint32_t kgse_ppc; /**< Policer Profile Command */
- volatile uint32_t kgse_gec[FM_PCD_KG_NUM_OF_GENERIC_REGS];
- /**< Generic Extract Command */
- volatile uint32_t kgse_spc; /**< KeyGen Scheme Entry Statistic Packet Counter */
- volatile uint32_t kgse_dv0; /**< KeyGen Scheme Entry Default Value 0 */
- volatile uint32_t kgse_dv1; /**< KeyGen Scheme Entry Default Value 1 */
- volatile uint32_t kgse_ccbs; /**< KeyGen Scheme Entry Coarse Classification Bit*/
- volatile uint32_t kgse_mv; /**< KeyGen Scheme Entry Match vector */
-} _PackedType t_FmPcdKgInterModuleSchemeRegs;
typedef _Packed struct t_FmPcdCcCapwapReassmTimeoutParams {
volatile uint32_t portIdAndCapwapReassmTbl;
@@ -101,14 +174,50 @@ typedef _Packed struct t_FmPcdCcCapwapReassmTimeoutParams {
volatile uint32_t timeoutRequestTime;
}_PackedType t_FmPcdCcCapwapReassmTimeoutParams;
+/**************************************************************************//**
+ @Description PCD CTRL Parameters Page
+*//***************************************************************************/
+typedef _Packed struct t_FmPcdCtrlParamsPage {
+ volatile uint8_t reserved0[16];
+ volatile uint32_t iprIpv4Nia;
+ volatile uint32_t iprIpv6Nia;
+ volatile uint8_t reserved1[24];
+ volatile uint32_t ipfOptionsCounter;
+ volatile uint8_t reserved2[12];
+ volatile uint32_t misc;
+ volatile uint32_t errorsDiscardMask;
+ volatile uint32_t discardMask;
+ volatile uint8_t reserved3[4];
+ volatile uint32_t postBmiFetchNia;
+ volatile uint8_t reserved4[172];
+} _PackedType t_FmPcdCtrlParamsPage;
+
-#define MEM_MAP_END
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(pop)
#endif /* defined(__MWERKS__) && ... */
+/*for UNDER_CONSTRUCTION_FM_RMU_USE_SEC its defined in fm_ext.h*/
+typedef uint32_t t_FmFmanCtrl;
+
+#define FPM_PORT_FM_CTL1 0x00000001
+#define FPM_PORT_FM_CTL2 0x00000002
+
+
+
+typedef struct t_FmPcdCcFragScratchPoolCmdParams {
+ uint32_t numOfBuffers;
+ uint8_t bufferPoolId;
+} t_FmPcdCcFragScratchPoolCmdParams;
+
+typedef struct t_FmPcdCcReassmTimeoutParams {
+ bool activate;
+ uint8_t tsbs;
+ uint32_t iprcpt;
+} t_FmPcdCcReassmTimeoutParams;
+
typedef struct {
uint8_t baseEntry;
uint16_t numOfClsPlanEntries;
@@ -137,34 +246,42 @@ typedef struct
uint16_t index;
t_List node;
}t_CcNodeInformation;
-#define CC_NODE_F_OBJECT(ptr) LIST_OBJECT(ptr, t_CcNodeInformation, node)
+#define CC_NODE_F_OBJECT(ptr) NCSW_LIST_OBJECT(ptr, t_CcNodeInformation, node)
+
+typedef enum e_ModifyState
+{
+ e_MODIFY_STATE_ADD = 0,
+ e_MODIFY_STATE_REMOVE,
+ e_MODIFY_STATE_CHANGE
+} e_ModifyState;
typedef struct
{
t_Handle h_Manip;
t_List node;
}t_ManipInfo;
-#define CC_NEXT_NODE_F_OBJECT(ptr) LIST_OBJECT(ptr, t_CcNodeInfo, node)
+#define CC_NEXT_NODE_F_OBJECT(ptr) NCSW_LIST_OBJECT(ptr, t_CcNodeInfo, node)
typedef struct {
- uint32_t type;
- uint8_t prOffset;
-
- uint16_t dataOffset;
- uint8_t poolIndex;
-
- uint8_t poolIdForManip;
- uint8_t numOfTasks;
-
- uint8_t hardwarePortId;
-
+ uint32_t type;
+ uint8_t prOffset;
+ uint16_t dataOffset;
+ uint8_t internalBufferOffset;
+ uint8_t numOfTasks;
+ uint8_t numOfExtraTasks;
+ uint8_t hardwarePortId;
+ t_FmRevisionInfo revInfo;
+ uint32_t nia;
+ uint32_t discardMask;
} t_GetCcParams;
typedef struct {
- uint32_t type;
- int psoSize;
- uint32_t nia;
-
+ uint32_t type;
+ int psoSize;
+ uint32_t nia;
+ t_FmFmanCtrl orFmanCtrl;
+ bool overwrite;
+ uint8_t ofpDpde;
} t_SetCcParams;
typedef struct {
@@ -172,6 +289,25 @@ typedef struct {
t_SetCcParams setCcParams;
} t_FmPortGetSetCcParams;
+typedef struct {
+ uint32_t type;
+ bool sleep;
+} t_FmSetParams;
+
+typedef struct {
+ uint32_t type;
+ uint32_t fmqm_gs;
+ uint32_t fm_npi;
+ uint32_t fm_cld;
+ uint32_t fmfp_extc;
+} t_FmGetParams;
+
+typedef struct {
+ t_FmSetParams setParams;
+ t_FmGetParams getParams;
+} t_FmGetSetParams;
+
+t_Error FmGetSetParams(t_Handle h_Fm, t_FmGetSetParams *p_Params);
static __inline__ bool TRY_LOCK(t_Handle h_Spinlock, volatile bool *p_Flag)
{
@@ -180,6 +316,7 @@ static __inline__ bool TRY_LOCK(t_Handle h_Spinlock, volatile bool *p_Flag)
intFlags = XX_LockIntrSpinlock(h_Spinlock);
else
intFlags = XX_DisableAllIntr();
+
if (*p_Flag)
{
if (h_Spinlock)
@@ -189,10 +326,12 @@ static __inline__ bool TRY_LOCK(t_Handle h_Spinlock, volatile bool *p_Flag)
return FALSE;
}
*p_Flag = TRUE;
+
if (h_Spinlock)
XX_UnlockIntrSpinlock(h_Spinlock, intFlags);
else
XX_RestoreAllIntr(intFlags);
+
return TRUE;
}
@@ -204,16 +343,24 @@ static __inline__ bool TRY_LOCK(t_Handle h_Spinlock, volatile bool *p_Flag)
*//***************************************************************************/
#define INTERNAL_CONTEXT_OFFSET 0x80000000
#define OFFSET_OF_PR 0x40000000
-#define BUFFER_POOL_ID_FOR_MANIP 0x20000000
+#define MANIP_EXTRA_SPACE 0x20000000
#define NUM_OF_TASKS 0x10000000
#define OFFSET_OF_DATA 0x08000000
#define HW_PORT_ID 0x04000000
-
+#define FM_REV 0x02000000
+#define GET_NIA_FPNE 0x01000000
+#define GET_NIA_PNDN 0x00800000
+#define NUM_OF_EXTRA_TASKS 0x00400000
+#define DISCARD_MASK 0x00200000
#define UPDATE_NIA_PNEN 0x80000000
#define UPDATE_PSO 0x40000000
#define UPDATE_NIA_PNDN 0x20000000
#define UPDATE_FMFP_PRC_WITH_ONE_RISC_ONLY 0x10000000
+#define UPDATE_OFP_DPTE 0x08000000
+#define UPDATE_NIA_FENE 0x04000000
+#define UPDATE_NIA_CMNE 0x02000000
+#define UPDATE_NIA_FPNE 0x01000000
/* @} */
/**************************************************************************//**
@@ -223,53 +370,21 @@ static __inline__ bool TRY_LOCK(t_Handle h_Spinlock, volatile bool *p_Flag)
#define UPDATE_NIA_ENQ_WITHOUT_DMA 0x80000000
#define UPDATE_CC_WITH_TREE 0x40000000
#define UPDATE_CC_WITH_DELETE_TREE 0x20000000
+#define UPDATE_KG_NIA_CC_WA 0x10000000
+#define UPDATE_KG_OPT_MODE 0x08000000
+#define UPDATE_KG_NIA 0x04000000
+#define UPDATE_CC_SHADOW_CLEAR 0x02000000
/* @} */
-/**************************************************************************//**
- @Collection Defines used for enabling/disabling FM interrupts
- @{
-*//***************************************************************************/
-typedef uint32_t t_FmBlockErrIntrEnable;
-
-#define ERR_INTR_EN_DMA 0x00010000
-#define ERR_INTR_EN_FPM 0x80000000
-#define ERR_INTR_EN_BMI 0x00800000
-#define ERR_INTR_EN_QMI 0x00400000
-#define ERR_INTR_EN_PRS 0x00200000
-#define ERR_INTR_EN_KG 0x00100000
-#define ERR_INTR_EN_PLCR 0x00080000
-#define ERR_INTR_EN_MURAM 0x00040000
-#define ERR_INTR_EN_IRAM 0x00020000
-#define ERR_INTR_EN_10G_MAC0 0x00008000
-#define ERR_INTR_EN_1G_MAC0 0x00004000
-#define ERR_INTR_EN_1G_MAC1 0x00002000
-#define ERR_INTR_EN_1G_MAC2 0x00001000
-#define ERR_INTR_EN_1G_MAC3 0x00000800
-#define ERR_INTR_EN_1G_MAC4 0x00000400
-#define ERR_INTR_EN_MACSEC_MAC0 0x00000200
-
-
-typedef uint32_t t_FmBlockIntrEnable;
-
-#define INTR_EN_BMI 0x80000000
-#define INTR_EN_QMI 0x40000000
-#define INTR_EN_PRS 0x20000000
-#define INTR_EN_KG 0x10000000
-#define INTR_EN_PLCR 0x08000000
-#define INTR_EN_1G_MAC0_TMR 0x00080000
-#define INTR_EN_1G_MAC1_TMR 0x00040000
-#define INTR_EN_1G_MAC2_TMR 0x00020000
-#define INTR_EN_1G_MAC3_TMR 0x00010000
-#define INTR_EN_1G_MAC4_TMR 0x00000040
-#define INTR_EN_REV0 0x00008000
-#define INTR_EN_REV1 0x00004000
-#define INTR_EN_REV2 0x00002000
-#define INTR_EN_REV3 0x00001000
-#define INTR_EN_BRK 0x00000080
-#define INTR_EN_TMR 0x01000000
-#define INTR_EN_MACSEC_MAC0 0x00000001
-/* @} */
-
+#define UPDATE_FPM_BRKC_SLP 0x80000000
+#define UPDATE_FPM_EXTC 0x40000000
+#define UPDATE_FPM_EXTC_CLEAR 0x20000000
+#define GET_FMQM_GS 0x10000000
+#define GET_FM_NPI 0x08000000
+#define GET_FMFP_EXTC 0x04000000
+#define CLEAR_IRAM_READY 0x02000000
+#define UPDATE_FM_CLD 0x01000000
+#define GET_FM_CLD 0x00800000
#define FM_MAX_NUM_OF_PORTS (FM_MAX_NUM_OF_OH_PORTS + \
FM_MAX_NUM_OF_1G_RX_PORTS + \
FM_MAX_NUM_OF_10G_RX_PORTS + \
@@ -284,6 +399,9 @@ typedef uint32_t t_FmBlockIntrEnable;
/**************************************************************************//**
@Description NIA Description
*//***************************************************************************/
+#define NIA_ENG_MASK 0x007C0000
+#define NIA_AC_MASK 0x0003ffff
+
#define NIA_ORDER_RESTOR 0x00800000
#define NIA_ENG_FM_CTL 0x00000000
#define NIA_ENG_PRS 0x00440000
@@ -292,19 +410,25 @@ typedef uint32_t t_FmBlockIntrEnable;
#define NIA_ENG_BMI 0x00500000
#define NIA_ENG_QMI_ENQ 0x00540000
#define NIA_ENG_QMI_DEQ 0x00580000
-#define NIA_ENG_MASK 0x007C0000
#define NIA_FM_CTL_AC_CC 0x00000006
#define NIA_FM_CTL_AC_HC 0x0000000C
#define NIA_FM_CTL_AC_IND_MODE_TX 0x00000008
#define NIA_FM_CTL_AC_IND_MODE_RX 0x0000000A
-#define NIA_FM_CTL_AC_FRAG 0x0000000e
-#define NIA_FM_CTL_AC_PRE_FETCH 0x00000010
-#define NIA_FM_CTL_AC_POST_FETCH_PCD 0x00000012
-#define NIA_FM_CTL_AC_POST_FETCH_PCD_UDP_LEN 0x00000018
-#define NIA_FM_CTL_AC_POST_FETCH_NO_PCD 0x00000012
-#define NIA_FM_CTL_AC_FRAG_CHECK 0x00000014
-#define NIA_FM_CTL_AC_MASK 0x0000001f
+#define NIA_FM_CTL_AC_POP_TO_N_STEP 0x0000000e
+#define NIA_FM_CTL_AC_PRE_BMI_FETCH_HEADER 0x00000010
+#define NIA_FM_CTL_AC_PRE_BMI_FETCH_FULL_FRAME 0x00000018
+#define NIA_FM_CTL_AC_POST_BMI_FETCH 0x00000012
+#define NIA_FM_CTL_AC_PRE_BMI_ENQ_FRAME 0x0000001A
+#define NIA_FM_CTL_AC_PRE_BMI_DISCARD_FRAME 0x0000001E
+#define NIA_FM_CTL_AC_POST_BMI_ENQ_ORR 0x00000014
+#define NIA_FM_CTL_AC_POST_BMI_ENQ 0x00000022
+#define NIA_FM_CTL_AC_PRE_CC 0x00000020
+#define NIA_FM_CTL_AC_POST_TX 0x00000024
+/* V3 only */
+#define NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_ENQ_FRAME 0x00000028
+#define NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_DISCARD_FRAME 0x0000002A
+#define NIA_FM_CTL_AC_NO_IPACC_POP_TO_N_STEP 0x0000002C
#define NIA_BMI_AC_ENQ_FRAME 0x00000002
#define NIA_BMI_AC_TX_RELEASE 0x000002C0
@@ -320,10 +444,47 @@ typedef uint32_t t_FmBlockIntrEnable;
#define NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA 0x00000202
+#if defined(FM_OP_NO_VSP_NO_RELEASE_ERRATA_FMAN_A006675) || defined(FM_ERROR_VSP_NO_MATCH_SW006)
+#define GET_NIA_BMI_AC_ENQ_FRAME(h_FmPcd) \
+ (uint32_t)((FmPcdIsAdvancedOffloadSupported(h_FmPcd)) ? \
+ (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_PRE_BMI_ENQ_FRAME) : \
+ (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_ENQ_FRAME))
+#define GET_NIA_BMI_AC_DISCARD_FRAME(h_FmPcd) \
+ (uint32_t)((FmPcdIsAdvancedOffloadSupported(h_FmPcd)) ? \
+ (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_PRE_BMI_DISCARD_FRAME) : \
+ (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_DISCARD_FRAME))
+#define GET_NO_PCD_NIA_BMI_AC_ENQ_FRAME() \
+ (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_ENQ_FRAME)
+#else
+#define GET_NIA_BMI_AC_ENQ_FRAME(h_FmPcd) \
+ (uint32_t)((FmPcdIsAdvancedOffloadSupported(h_FmPcd)) ? \
+ (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_PRE_BMI_ENQ_FRAME) : \
+ (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME))
+#define GET_NIA_BMI_AC_DISCARD_FRAME(h_FmPcd) \
+ (uint32_t)((FmPcdIsAdvancedOffloadSupported(h_FmPcd)) ? \
+ (NIA_ENG_FM_CTL | NIA_FM_CTL_AC_PRE_BMI_DISCARD_FRAME) : \
+ (NIA_ENG_BMI | NIA_BMI_AC_DISCARD))
+#define GET_NO_PCD_NIA_BMI_AC_ENQ_FRAME() \
+ (NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME)
+#endif /* defined(FM_OP_NO_VSP_NO_RELEASE_ERRATA_FMAN_A006675) || ... */
+
+/**************************************************************************//**
+ @Description CTRL Parameters Page defines
+*//***************************************************************************/
+#define FM_CTL_PARAMS_PAGE_OP_FIX_EN 0x80000000
+#define FM_CTL_PARAMS_PAGE_OFFLOAD_SUPPORT_EN 0x40000000
+#define FM_CTL_PARAMS_PAGE_ALWAYS_ON 0x00000100
+
+#define FM_CTL_PARAMS_PAGE_ERROR_VSP_MASK 0x0000003f
+
/**************************************************************************//**
@Description Port Id defines
*//***************************************************************************/
+#if (DPAA_VERSION == 10)
#define BASE_OH_PORTID 1
+#else
+#define BASE_OH_PORTID 2
+#endif /* (DPAA_VERSION == 10) */
#define BASE_1G_RX_PORTID 8
#define BASE_10G_RX_PORTID 0x10
#define BASE_1G_TX_PORTID 0x28
@@ -344,67 +505,39 @@ typedef uint32_t t_FmBlockIntrEnable;
REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal OH_PORT port id"))
#endif
#if (FM_MAX_NUM_OF_1G_RX_PORTS > 0)
-#define CHECK_PORT_ID_1G_RX_PORTS(_relativePortId) \
- if ((_relativePortId) >= FM_MAX_NUM_OF_1G_RX_PORTS) \
+#define CHECK_PORT_ID_1G_RX_PORTS(_relativePortId) \
+ if ((_relativePortId) >= FM_MAX_NUM_OF_1G_RX_PORTS) \
REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 1G_RX_PORT port id"))
#else
-#define CHECK_PORT_ID_1G_RX_PORTS(_relativePortId) \
+#define CHECK_PORT_ID_1G_RX_PORTS(_relativePortId) \
REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 1G_RX_PORT port id"))
#endif
#if (FM_MAX_NUM_OF_10G_RX_PORTS > 0)
-#define CHECK_PORT_ID_10G_RX_PORTS(_relativePortId) \
- if ((_relativePortId) >= FM_MAX_NUM_OF_10G_RX_PORTS) \
+#define CHECK_PORT_ID_10G_RX_PORTS(_relativePortId) \
+ if ((_relativePortId) >= FM_MAX_NUM_OF_10G_RX_PORTS) \
REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 10G_RX_PORT port id"))
#else
-#define CHECK_PORT_ID_10G_RX_PORTS(_relativePortId) \
+#define CHECK_PORT_ID_10G_RX_PORTS(_relativePortId) \
REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 10G_RX_PORT port id"))
#endif
#if (FM_MAX_NUM_OF_1G_TX_PORTS > 0)
-#define CHECK_PORT_ID_1G_TX_PORTS(_relativePortId) \
- if ((_relativePortId) >= FM_MAX_NUM_OF_1G_TX_PORTS) \
+#define CHECK_PORT_ID_1G_TX_PORTS(_relativePortId) \
+ if ((_relativePortId) >= FM_MAX_NUM_OF_1G_TX_PORTS) \
REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 1G_TX_PORT port id"))
#else
-#define CHECK_PORT_ID_1G_TX_PORTS(_relativePortId) \
+#define CHECK_PORT_ID_1G_TX_PORTS(_relativePortId) \
REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 1G_TX_PORT port id"))
#endif
#if (FM_MAX_NUM_OF_10G_TX_PORTS > 0)
-#define CHECK_PORT_ID_10G_TX_PORTS(_relativePortId) \
- if ((_relativePortId) >= FM_MAX_NUM_OF_10G_TX_PORTS) \
+#define CHECK_PORT_ID_10G_TX_PORTS(_relativePortId) \
+ if ((_relativePortId) >= FM_MAX_NUM_OF_10G_TX_PORTS) \
REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 10G_TX_PORT port id"))
#else
-#define CHECK_PORT_ID_10G_TX_PORTS(_relativePortId) \
+#define CHECK_PORT_ID_10G_TX_PORTS(_relativePortId) \
REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 10G_TX_PORT port id"))
#endif
-
-#define SW_PORT_ID_TO_HW_PORT_ID(_port, _type, _relativePortId) \
-switch(_type) { \
- case(e_FM_PORT_TYPE_OH_OFFLINE_PARSING): \
- case(e_FM_PORT_TYPE_OH_HOST_COMMAND): \
- CHECK_PORT_ID_OH_PORTS(_relativePortId); \
- _port = (uint8_t)(BASE_OH_PORTID + (_relativePortId)); \
- break; \
- case(e_FM_PORT_TYPE_RX): \
- CHECK_PORT_ID_1G_RX_PORTS(_relativePortId); \
- _port = (uint8_t)(BASE_1G_RX_PORTID + (_relativePortId)); \
- break; \
- case(e_FM_PORT_TYPE_RX_10G): \
- CHECK_PORT_ID_10G_RX_PORTS(_relativePortId); \
- _port = (uint8_t)(BASE_10G_RX_PORTID + (_relativePortId)); \
- break; \
- case(e_FM_PORT_TYPE_TX): \
- CHECK_PORT_ID_1G_TX_PORTS(_relativePortId); \
- _port = (uint8_t)(BASE_1G_TX_PORTID + (_relativePortId)); \
- break; \
- case(e_FM_PORT_TYPE_TX_10G): \
- CHECK_PORT_ID_10G_TX_PORTS(_relativePortId); \
- _port = (uint8_t)(BASE_10G_TX_PORTID + (_relativePortId)); \
- break; \
- default: \
- REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal port type")); \
- _port = 0; \
- break; \
-}
+uint8_t SwPortIdToHwPortId(e_FmPortType type, uint8_t relativePortId, uint8_t majorRev, uint8_t minorRev);
#define HW_PORT_ID_TO_SW_PORT_ID(_relativePortId, hardwarePortId) \
{ if (((hardwarePortId) >= BASE_OH_PORTID) && \
@@ -462,6 +595,7 @@ do {
else ASSERT_COND(FALSE); \
} while (0)
+#define BMI_MAX_FIFO_SIZE (FM_MURAM_SIZE)
#define BMI_FIFO_UNITS 0x100
typedef struct {
@@ -477,220 +611,37 @@ typedef struct {
((hdr) == HEADER_TYPE_USER_DEFINED_SHIM2))
#define IS_SPECIAL_HEADER(hdr) ((hdr) == HEADER_TYPE_MACSEC)
-#define GET_PRS_HDR_NUM(num, hdr) \
-switch(hdr) \
-{ case(HEADER_TYPE_ETH): num = 0; break; \
- case(HEADER_TYPE_LLC_SNAP): num = 1; break; \
- case(HEADER_TYPE_VLAN): num = 2; break; \
- case(HEADER_TYPE_PPPoE): num = 3; break; \
- case(HEADER_TYPE_MPLS): num = 4; break; \
- case(HEADER_TYPE_IPv4): num = 5; break; \
- case(HEADER_TYPE_IPv6): num = 6; break; \
- case(HEADER_TYPE_GRE): num = 7; break; \
- case(HEADER_TYPE_MINENCAP): num = 8; break; \
- case(HEADER_TYPE_USER_DEFINED_L3): num = 9; break; \
- case(HEADER_TYPE_TCP): num = 10; break; \
- case(HEADER_TYPE_UDP): num = 11; break; \
- case(HEADER_TYPE_IPSEC_AH): \
- case(HEADER_TYPE_IPSEC_ESP): num = 12; break; \
- case(HEADER_TYPE_SCTP): num = 13; break; \
- case(HEADER_TYPE_DCCP): num = 14; break; \
- case(HEADER_TYPE_USER_DEFINED_L4): num = 15; break; \
- case(HEADER_TYPE_USER_DEFINED_SHIM1): \
- case(HEADER_TYPE_USER_DEFINED_SHIM2): \
- case(HEADER_TYPE_MACSEC): \
- num = NO_HDR_NUM; break; \
- default: \
- REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Unsupported header for parser"));\
- num = ILLEGAL_HDR_NUM; break; \
-}
-
-/***********************************************************************/
-/* Policer defines */
-/***********************************************************************/
-#define FM_PCD_PLCR_PAR_GO 0x80000000
-#define FM_PCD_PLCR_PAR_PWSEL_MASK 0x0000FFFF
-#define FM_PCD_PLCR_PAR_R 0x40000000
-
-/* shifts */
-#define FM_PCD_PLCR_PAR_PNUM_SHIFT 16
-
-
-/***********************************************************************/
-/* Keygen defines */
-/***********************************************************************/
-/* maskes */
-#define KG_SCH_PP_SHIFT_HIGH 0x80000000
-#define KG_SCH_PP_NO_GEN 0x10000000
-#define KG_SCH_PP_SHIFT_LOW 0x0000F000
-#define KG_SCH_MODE_NIA_PLCR 0x40000000
-#define KG_SCH_GEN_EXTRACT_TYPE 0x00008000
-#define KG_SCH_BITMASK_MASK 0x000000FF
-#define KG_SCH_GEN_VALID 0x80000000
-#define KG_SCH_GEN_MASK 0x00FF0000
-#define FM_PCD_KG_KGAR_ERR 0x20000000
-#define FM_PCD_KG_KGAR_SEL_CLS_PLAN_ENTRY 0x01000000
-#define FM_PCD_KG_KGAR_SEL_PORT_ENTRY 0x02000000
-#define FM_PCD_KG_KGAR_SEL_PORT_WSEL_SP 0x00008000
-#define FM_PCD_KG_KGAR_SEL_PORT_WSEL_CPP 0x00004000
-#define FM_PCD_KG_KGAR_WSEL_MASK 0x0000FF00
-#define KG_SCH_HASH_CONFIG_NO_FQID 0x80000000
-#define KG_SCH_HASH_CONFIG_SYM 0x40000000
-
-#define FM_PCD_KG_KGAR_GO 0x80000000
-#define FM_PCD_KG_KGAR_READ 0x40000000
-#define FM_PCD_KG_KGAR_WRITE 0x00000000
-#define FM_PCD_KG_KGAR_SEL_SCHEME_ENTRY 0x00000000
-#define FM_PCD_KG_KGAR_SCHEME_WSEL_UPDATE_CNT 0x00008000
-
-
-typedef uint32_t t_KnownFieldsMasks;
-
-#define KG_SCH_KN_PORT_ID 0x80000000
-#define KG_SCH_KN_MACDST 0x40000000
-#define KG_SCH_KN_MACSRC 0x20000000
-#define KG_SCH_KN_TCI1 0x10000000
-#define KG_SCH_KN_TCI2 0x08000000
-#define KG_SCH_KN_ETYPE 0x04000000
-#define KG_SCH_KN_PPPSID 0x02000000
-#define KG_SCH_KN_PPPID 0x01000000
-#define KG_SCH_KN_MPLS1 0x00800000
-#define KG_SCH_KN_MPLS2 0x00400000
-#define KG_SCH_KN_MPLS_LAST 0x00200000
-#define KG_SCH_KN_IPSRC1 0x00100000
-#define KG_SCH_KN_IPDST1 0x00080000
-#define KG_SCH_KN_PTYPE1 0x00040000
-#define KG_SCH_KN_IPTOS_TC1 0x00020000
-#define KG_SCH_KN_IPV6FL1 0x00010000
-#define KG_SCH_KN_IPSRC2 0x00008000
-#define KG_SCH_KN_IPDST2 0x00004000
-#define KG_SCH_KN_PTYPE2 0x00002000
-#define KG_SCH_KN_IPTOS_TC2 0x00001000
-#define KG_SCH_KN_IPV6FL2 0x00000800
-#define KG_SCH_KN_GREPTYPE 0x00000400
-#define KG_SCH_KN_IPSEC_SPI 0x00000200
-#define KG_SCH_KN_IPSEC_NH 0x00000100
-#define KG_SCH_KN_L4PSRC 0x00000004
-#define KG_SCH_KN_L4PDST 0x00000002
-#define KG_SCH_KN_TFLG 0x00000001
-
-typedef uint8_t t_GenericCodes;
-
-#define KG_SCH_GEN_SHIM1 0x70
-#define KG_SCH_GEN_DEFAULT 0x10
-#define KG_SCH_GEN_PARSE_RESULT_N_FQID 0x20
-#define KG_SCH_GEN_START_OF_FRM 0x40
-#define KG_SCH_GEN_SHIM2 0x71
-#define KG_SCH_GEN_IP_PID_NO_V 0x72
-#define KG_SCH_GEN_ETH 0x03
-#define KG_SCH_GEN_ETH_NO_V 0x73
-#define KG_SCH_GEN_SNAP 0x04
-#define KG_SCH_GEN_SNAP_NO_V 0x74
-#define KG_SCH_GEN_VLAN1 0x05
-#define KG_SCH_GEN_VLAN1_NO_V 0x75
-#define KG_SCH_GEN_VLAN2 0x06
-#define KG_SCH_GEN_VLAN2_NO_V 0x76
-#define KG_SCH_GEN_ETH_TYPE 0x07
-#define KG_SCH_GEN_ETH_TYPE_NO_V 0x77
-#define KG_SCH_GEN_PPP 0x08
-#define KG_SCH_GEN_PPP_NO_V 0x78
-#define KG_SCH_GEN_MPLS1 0x09
-#define KG_SCH_GEN_MPLS2 0x19
-#define KG_SCH_GEN_MPLS3 0x29
-#define KG_SCH_GEN_MPLS1_NO_V 0x79
-#define KG_SCH_GEN_MPLS_LAST 0x0a
-#define KG_SCH_GEN_MPLS_LAST_NO_V 0x7a
-#define KG_SCH_GEN_IPV4 0x0b
-#define KG_SCH_GEN_IPV6 0x1b
-#define KG_SCH_GEN_L3_NO_V 0x7b
-#define KG_SCH_GEN_IPV4_TUNNELED 0x0c
-#define KG_SCH_GEN_IPV6_TUNNELED 0x1c
-#define KG_SCH_GEN_MIN_ENCAP 0x2c
-#define KG_SCH_GEN_IP2_NO_V 0x7c
-#define KG_SCH_GEN_GRE 0x0d
-#define KG_SCH_GEN_GRE_NO_V 0x7d
-#define KG_SCH_GEN_TCP 0x0e
-#define KG_SCH_GEN_UDP 0x1e
-#define KG_SCH_GEN_IPSEC_AH 0x2e
-#define KG_SCH_GEN_SCTP 0x3e
-#define KG_SCH_GEN_DCCP 0x4e
-#define KG_SCH_GEN_IPSEC_ESP 0x6e
-#define KG_SCH_GEN_L4_NO_V 0x7e
-#define KG_SCH_GEN_NEXTHDR 0x7f
-
-/* shifts */
-#define KG_SCH_PP_SHIFT_HIGH_SHIFT 27
-#define KG_SCH_PP_SHIFT_LOW_SHIFT 12
-#define KG_SCH_PP_MASK_SHIFT 16
-#define KG_SCH_MODE_CCOBASE_SHIFT 24
-#define KG_SCH_DEF_MAC_ADDR_SHIFT 30
-#define KG_SCH_DEF_TCI_SHIFT 28
-#define KG_SCH_DEF_ENET_TYPE_SHIFT 26
-#define KG_SCH_DEF_PPP_SESSION_ID_SHIFT 24
-#define KG_SCH_DEF_PPP_PROTOCOL_ID_SHIFT 22
-#define KG_SCH_DEF_MPLS_LABEL_SHIFT 20
-#define KG_SCH_DEF_IP_ADDR_SHIFT 18
-#define KG_SCH_DEF_PROTOCOL_TYPE_SHIFT 16
-#define KG_SCH_DEF_IP_TOS_TC_SHIFT 14
-#define KG_SCH_DEF_IPV6_FLOW_LABEL_SHIFT 12
-#define KG_SCH_DEF_IPSEC_SPI_SHIFT 10
-#define KG_SCH_DEF_L4_PORT_SHIFT 8
-#define KG_SCH_DEF_TCP_FLAG_SHIFT 6
-#define KG_SCH_HASH_CONFIG_SHIFT_SHIFT 24
-#define KG_SCH_GEN_MASK_SHIFT 16
-#define KG_SCH_GEN_HT_SHIFT 8
-#define KG_SCH_GEN_SIZE_SHIFT 24
-#define KG_SCH_GEN_DEF_SHIFT 29
-#define FM_PCD_KG_KGAR_NUM_SHIFT 16
-
-
-/* others */
-#define NUM_OF_SW_DEFAULTS 3
-#define MAX_PP_SHIFT 15
-#define MAX_KG_SCH_SIZE 16
-#define MASK_FOR_GENERIC_BASE_ID 0x20
-#define MAX_HASH_SHIFT 40
-#define MAX_KG_SCH_FQID_BIT_OFFSET 31
-#define MAX_KG_SCH_PP_BIT_OFFSET 15
-#define MAX_DIST_FQID_SHIFT 23
-
-#define GET_MASK_SEL_SHIFT(shift,i) \
-switch(i) { \
- case(0):shift = 26;break; \
- case(1):shift = 20;break; \
- case(2):shift = 10;break; \
- case(3):shift = 4;break; \
- default: \
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);\
-}
-
-#define GET_MASK_OFFSET_SHIFT(shift,i) \
-switch(i) { \
- case(0):shift = 16;break; \
- case(1):shift = 0;break; \
- case(2):shift = 28;break; \
- case(3):shift = 24;break; \
- default: \
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);\
-}
-
-#define GET_MASK_SHIFT(shift,i) \
-switch(i) { \
- case(0):shift = 24;break; \
- case(1):shift = 16;break; \
- case(2):shift = 8;break; \
- case(3):shift = 0;break; \
- default: \
- RETURN_ERROR(MAJOR, E_INVALID_VALUE, NO_MSG);\
+static __inline__ uint8_t GetPrsHdrNum(e_NetHeaderType hdr)
+{
+ switch (hdr)
+ { case (HEADER_TYPE_ETH): return 0;
+ case (HEADER_TYPE_LLC_SNAP): return 1;
+ case (HEADER_TYPE_VLAN): return 2;
+ case (HEADER_TYPE_PPPoE): return 3;
+ case (HEADER_TYPE_PPP): return 3;
+ case (HEADER_TYPE_MPLS): return 4;
+ case (HEADER_TYPE_IPv4): return 5;
+ case (HEADER_TYPE_IPv6): return 6;
+ case (HEADER_TYPE_GRE): return 7;
+ case (HEADER_TYPE_MINENCAP): return 8;
+ case (HEADER_TYPE_USER_DEFINED_L3): return 9;
+ case (HEADER_TYPE_TCP): return 10;
+ case (HEADER_TYPE_UDP): return 11;
+ case (HEADER_TYPE_IPSEC_AH):
+ case (HEADER_TYPE_IPSEC_ESP): return 12;
+ case (HEADER_TYPE_SCTP): return 13;
+ case (HEADER_TYPE_DCCP): return 14;
+ case (HEADER_TYPE_USER_DEFINED_L4): return 15;
+ case (HEADER_TYPE_USER_DEFINED_SHIM1):
+ case (HEADER_TYPE_USER_DEFINED_SHIM2):
+ case (HEADER_TYPE_MACSEC): return NO_HDR_NUM;
+ default:
+ return ILLEGAL_HDR_NUM;
+ }
}
#define FM_PCD_MAX_NUM_OF_OPTIONS(clsPlanEntries) ((clsPlanEntries==256)? 8:((clsPlanEntries==128)? 7: ((clsPlanEntries==64)? 6: ((clsPlanEntries==32)? 5:0))))
-typedef struct {
- uint16_t num;
- uint8_t hardwarePortId;
- uint16_t plcrProfilesBase;
-} t_FmPortPcdInterModulePlcrParams;
/**************************************************************************//**
@Description A structure for initializing a keygen classification plan group
@@ -707,93 +658,88 @@ typedef struct t_FmPcdKgInterModuleClsPlanGrpParams {
/* OUT in FmPcdGetSetClsPlanGrpParams IN in FmPcdKgBuildClsPlanGrp*/
} t_FmPcdKgInterModuleClsPlanGrpParams;
-typedef struct t_FmInterModulePortRxPoolsParams
-{
- uint8_t numOfPools;
- uint16_t secondLargestBufSize;
- uint16_t largestBufSize;
-} t_FmInterModulePortRxPoolsParams;
+typedef struct t_FmPcdLock {
+ t_Handle h_Spinlock;
+ volatile bool flag;
+ t_List node;
+} t_FmPcdLock;
+#define FM_PCD_LOCK_OBJ(ptr) NCSW_LIST_OBJECT(ptr, t_FmPcdLock, node)
typedef t_Error (t_FmPortGetSetCcParamsCallback) (t_Handle h_FmPort,
t_FmPortGetSetCcParams *p_FmPortGetSetCcParams);
+/***********************************************************************/
+/* Common API for FM-PCD module */
+/***********************************************************************/
t_Handle FmPcdGetHcHandle(t_Handle h_FmPcd);
uint32_t FmPcdGetSwPrsOffset(t_Handle h_FmPcd, e_NetHeaderType hdr, uint8_t indexPerHdr);
uint32_t FmPcdGetLcv(t_Handle h_FmPcd, uint32_t netEnvId, uint8_t hdrNum);
uint32_t FmPcdGetMacsecLcv(t_Handle h_FmPcd, uint32_t netEnvId);
void FmPcdIncNetEnvOwners(t_Handle h_FmPcd, uint8_t netEnvId);
void FmPcdDecNetEnvOwners(t_Handle h_FmPcd, uint8_t netEnvId);
+uint8_t FmPcdGetNetEnvId(t_Handle h_NetEnv);
void FmPcdPortRegister(t_Handle h_FmPcd, t_Handle h_FmPort, uint8_t hardwarePortId);
uint32_t FmPcdLock(t_Handle h_FmPcd);
void FmPcdUnlock(t_Handle h_FmPcd, uint32_t intFlags);
bool FmPcdNetEnvIsHdrExist(t_Handle h_FmPcd, uint8_t netEnvId, e_NetHeaderType hdr);
-bool FmPcdIsIpFrag(t_Handle h_FmPcd, uint8_t netEnvId);
-
-t_Error FmPcdCcReleaseModifiedDataStructure(t_Handle h_FmPcd, t_List *h_FmPcdOldPointersLst, t_List *h_FmPcdNewPointersLst, uint16_t numOfGoodChanges, t_Handle *h_Params);
-uint32_t FmPcdCcGetNodeAddrOffset(t_Handle h_FmPcd, t_Handle h_Pointer);
-t_Error FmPcdCcRemoveKey(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode, uint8_t keyIndex, t_List *h_OldLst, t_List *h_NewLst, t_Handle *h_AdditionalParams);
-t_Error FmPcdCcAddKey(t_Handle h_FmPcd, t_Handle h_CcNode, uint8_t keyIndex, uint8_t keySize, t_FmPcdCcKeyParams *p_FmPCdCcKeyParams, t_List *h_OldLst, t_List *h_NewLst, t_Handle *h_Params);
-t_Error FmPcdCcModifyKey(t_Handle h_FmPcd, t_Handle h_CcNode, uint8_t keyIndex, uint8_t keySize, uint8_t *p_Key, uint8_t *p_Mask, t_List *h_OldLst, t_List *h_NewLst, t_Handle *h_AdditionalParams);
-t_Error FmPcdCcModifyKeyAndNextEngine(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode, uint8_t keyIndex, uint8_t keySize, t_FmPcdCcKeyParams *p_FmPcdCcKeyParams, t_List *h_OldLst, t_List *h_NewLst, t_Handle *h_AdditionalParams);
-t_Error FmPcdCcModifyMissNextEngineParamNode(t_Handle h_FmPcd,t_Handle h_FmPcdCcNode, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams,t_List *h_OldPointer, t_List *h_NewPointer,t_Handle *h_AdditionalParams);
-t_Error FmPcdCcModifyNextEngineParamTree(t_Handle h_FmPcd, t_Handle h_FmPcdCcTree, uint8_t grpId, uint8_t index, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams, t_List *h_OldLst, t_List *h_NewLst, t_Handle *h_AdditionalParams);
-t_Error FmPcdCcModiyNextEngineParamNode(t_Handle h_FmPcd,t_Handle h_FmPcdCcNode, uint8_t keyIndex,t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams,t_List *h_OldPointer, t_List *h_NewPointer,t_Handle *h_AdditionalParams);
-uint32_t FmPcdCcGetNodeAddrOffsetFromNodeInfo(t_Handle h_FmPcd, t_Handle h_Pointer);
-t_Error FmPcdCcTreeTryLock(t_Handle h_FmPcdCcTree);
-t_Error FmPcdCcNodeTreeTryLock(t_Handle h_FmPcd,t_Handle h_FmPcdCcNode, t_List *p_List);
-void FmPcdCcTreeReleaseLock(t_Handle h_FmPcdCcTree);
-void FmPcdCcNodeTreeReleaseLock(t_List *p_List);
-t_Handle FmPcdCcTreeGetSavedManipParams(t_Handle h_FmTree, uint8_t manipIndx);
-void FmPcdCcTreeSetSavedManipParams(t_Handle h_FmTree, t_Handle h_SavedManipParams, uint8_t manipIndx);
-
-bool FmPcdKgIsSchemeValidSw(t_Handle h_FmPcd, uint8_t schemeId);
+t_Error FmPcdFragHcScratchPoolInit(t_Handle h_FmPcd, uint8_t scratchBpid);
+t_Error FmPcdRegisterReassmPort(t_Handle h_FmPcd, t_Handle h_IpReasmCommonPramTbl);
+t_Error FmPcdUnregisterReassmPort(t_Handle h_FmPcd, t_Handle h_IpReasmCommonPramTbl);
+bool FmPcdIsAdvancedOffloadSupported(t_Handle h_FmPcd);
+bool FmPcdLockTryLockAll(t_Handle h_FmPcd);
+void FmPcdLockUnlockAll(t_Handle h_FmPcd);
+t_Error FmPcdHcSync(t_Handle h_FmPcd);
+t_Handle FmGetPcd(t_Handle h_Fm);
+/***********************************************************************/
+/* Common API for FM-PCD KG module */
+/***********************************************************************/
uint8_t FmPcdKgGetClsPlanGrpBase(t_Handle h_FmPcd, uint8_t clsPlanGrp);
uint16_t FmPcdKgGetClsPlanGrpSize(t_Handle h_FmPcd, uint8_t clsPlanGrp);
-
-t_Error FmPcdKgBuildScheme(t_Handle h_FmPcd, t_FmPcdKgSchemeParams *p_Scheme, t_FmPcdKgInterModuleSchemeRegs *p_SchemeRegs);
t_Error FmPcdKgBuildClsPlanGrp(t_Handle h_FmPcd, t_FmPcdKgInterModuleClsPlanGrpParams *p_Grp, t_FmPcdKgInterModuleClsPlanSet *p_ClsPlanSet);
-uint8_t FmPcdKgGetNumOfPartitionSchemes(t_Handle h_FmPcd);
-uint8_t FmPcdKgGetPhysicalSchemeId(t_Handle h_FmPcd, uint8_t schemeId);
+
+uint8_t FmPcdKgGetSchemeId(t_Handle h_Scheme);
+#if (DPAA_VERSION >= 11)
+bool FmPcdKgGetVspe(t_Handle h_Scheme);
+#endif /* (DPAA_VERSION >= 11) */
uint8_t FmPcdKgGetRelativeSchemeId(t_Handle h_FmPcd, uint8_t schemeId);
void FmPcdKgDestroyClsPlanGrp(t_Handle h_FmPcd, uint8_t grpId);
-void FmPcdKgValidateSchemeSw(t_Handle h_FmPcd, uint8_t schemeId);
-void FmPcdKgInvalidateSchemeSw(t_Handle h_FmPcd, uint8_t schemeId);
-t_Error FmPcdKgCheckInvalidateSchemeSw(t_Handle h_FmPcd, uint8_t schemeId);
+t_Error FmPcdKgCheckInvalidateSchemeSw(t_Handle h_Scheme);
t_Error FmPcdKgBuildBindPortToSchemes(t_Handle h_FmPcd , t_FmPcdKgInterModuleBindPortToSchemes *p_BindPortToSchemes, uint32_t *p_SpReg, bool add);
-void FmPcdKgIncSchemeOwners(t_Handle h_FmPcd , t_FmPcdKgInterModuleBindPortToSchemes *p_BindPort);
-void FmPcdKgDecSchemeOwners(t_Handle h_FmPcd , t_FmPcdKgInterModuleBindPortToSchemes *p_BindPort);
-bool FmPcdKgIsDriverClsPlan(t_Handle h_FmPcd);
bool FmPcdKgHwSchemeIsValid(uint32_t schemeModeReg);
-uint32_t FmPcdKgBuildCppReg(t_Handle h_FmPcd, uint8_t clsPlanGrpId);
uint32_t FmPcdKgBuildWriteSchemeActionReg(uint8_t schemeId, bool updateCounter);
uint32_t FmPcdKgBuildReadSchemeActionReg(uint8_t schemeId);
uint32_t FmPcdKgBuildWriteClsPlanBlockActionReg(uint8_t grpId);
-uint32_t FmPcdKgBuildReadClsPlanBlockActionReg(uint8_t grpId);
uint32_t FmPcdKgBuildWritePortSchemeBindActionReg(uint8_t hardwarePortId);
uint32_t FmPcdKgBuildReadPortSchemeBindActionReg(uint8_t hardwarePortId);
uint32_t FmPcdKgBuildWritePortClsPlanBindActionReg(uint8_t hardwarePortId);
-uint8_t FmPcdKgGetSchemeSwId(t_Handle h_FmPcd, uint8_t schemeHwId);
-t_Error FmPcdKgSchemeTryLock(t_Handle h_FmPcd, uint8_t schemeId, bool intr);
-void FmPcdKgReleaseSchemeLock(t_Handle h_FmPcd, uint8_t schemeId);
-void FmPcdKgUpatePointedOwner(t_Handle h_FmPcd, uint8_t schemeId, bool add);
+bool FmPcdKgIsSchemeValidSw(t_Handle h_Scheme);
t_Error FmPcdKgBindPortToSchemes(t_Handle h_FmPcd , t_FmPcdKgInterModuleBindPortToSchemes *p_SchemeBind);
t_Error FmPcdKgUnbindPortToSchemes(t_Handle h_FmPcd , t_FmPcdKgInterModuleBindPortToSchemes *p_SchemeBind);
uint32_t FmPcdKgGetRequiredAction(t_Handle h_FmPcd, uint8_t schemeId);
-uint32_t FmPcdKgGetPointedOwners(t_Handle h_FmPcd, uint8_t schemeId);
+uint32_t FmPcdKgGetRequiredActionFlag(t_Handle h_FmPcd, uint8_t schemeId);
e_FmPcdDoneAction FmPcdKgGetDoneAction(t_Handle h_FmPcd, uint8_t schemeId);
e_FmPcdEngine FmPcdKgGetNextEngine(t_Handle h_FmPcd, uint8_t schemeId);
-void FmPcdKgUpdateRequiredAction(t_Handle h_FmPcd, uint8_t schemeId, uint32_t requiredAction);
+void FmPcdKgUpdateRequiredAction(t_Handle h_Scheme, uint32_t requiredAction);
bool FmPcdKgIsDirectPlcr(t_Handle h_FmPcd, uint8_t schemeId);
bool FmPcdKgIsDistrOnPlcrProfile(t_Handle h_FmPcd, uint8_t schemeId);
uint16_t FmPcdKgGetRelativeProfileId(t_Handle h_FmPcd, uint8_t schemeId);
+t_Handle FmPcdKgGetSchemeHandle(t_Handle h_FmPcd, uint8_t relativeSchemeId);
+bool FmPcdKgIsSchemeHasOwners(t_Handle h_Scheme);
+t_Error FmPcdKgCcGetSetParams(t_Handle h_FmPcd, t_Handle h_Scheme, uint32_t requiredAction, uint32_t value);
+t_Error FmPcdKgSetOrBindToClsPlanGrp(t_Handle h_FmPcd, uint8_t hardwarePortId, uint8_t netEnvId, protocolOpt_t *p_OptArray, uint8_t *p_ClsPlanGrpId, bool *p_IsEmptyClsPlanGrp);
+t_Error FmPcdKgDeleteOrUnbindPortToClsPlanGrp(t_Handle h_FmPcd, uint8_t hardwarePortId, uint8_t clsPlanGrpId);
-/* FM-PCD parser API routines */
+/***********************************************************************/
+/* Common API for FM-PCD parser module */
+/***********************************************************************/
t_Error FmPcdPrsIncludePortInStatistics(t_Handle p_FmPcd, uint8_t hardwarePortId, bool include);
-/* FM-PCD policer API routines */
+/***********************************************************************/
+/* Common API for FM-PCD policer module */
+/***********************************************************************/
t_Error FmPcdPlcrAllocProfiles(t_Handle h_FmPcd, uint8_t hardwarePortId, uint16_t numOfProfiles);
t_Error FmPcdPlcrFreeProfiles(t_Handle h_FmPcd, uint8_t hardwarePortId);
bool FmPcdPlcrIsProfileValid(t_Handle h_FmPcd, uint16_t absoluteProfileId);
@@ -803,8 +749,8 @@ uint32_t FmPcdPlcrBuildWritePlcrActionRegs(uint16_t absoluteProfileId);
uint32_t FmPcdPlcrBuildCounterProfileReg(e_FmPcdPlcrProfileCounters counter);
uint32_t FmPcdPlcrBuildWritePlcrActionReg(uint16_t absoluteProfileId);
uint32_t FmPcdPlcrBuildReadPlcrActionReg(uint16_t absoluteProfileId);
-t_Error FmPcdPlcrBuildProfile(t_Handle h_FmPcd, t_FmPcdPlcrProfileParams *p_Profile, t_FmPcdPlcrInterModuleProfileRegs *p_PlcrRegs);
-t_Error FmPcdPlcrGetAbsoluteProfileId(t_Handle h_FmPcd,
+uint16_t FmPcdPlcrProfileGetAbsoluteId(t_Handle h_Profile);
+t_Error FmPcdPlcrGetAbsoluteIdByProfileParams(t_Handle h_FmPcd,
e_FmPcdProfileTypeSelection profileType,
t_Handle h_FmPort,
uint16_t relativeProfile,
@@ -812,36 +758,60 @@ t_Error FmPcdPlcrGetAbsoluteProfileId(t_Handle h_FmPcd,
void FmPcdPlcrInvalidateProfileSw(t_Handle h_FmPcd, uint16_t absoluteProfileId);
void FmPcdPlcrValidateProfileSw(t_Handle h_FmPcd, uint16_t absoluteProfileId);
bool FmPcdPlcrHwProfileIsValid(uint32_t profileModeReg);
-t_Error FmPcdPlcrProfileTryLock(t_Handle h_FmPcd, uint16_t profileId, bool intr);
-void FmPcdPlcrReleaseProfileLock(t_Handle h_FmPcd, uint16_t profileId);
uint32_t FmPcdPlcrGetRequiredAction(t_Handle h_FmPcd, uint16_t absoluteProfileId);
-uint32_t FmPcdPlcrGetPointedOwners(t_Handle h_FmPcd, uint16_t absoluteProfileId);
-void FmPcdPlcrUpatePointedOwner(t_Handle h_FmPcd, uint16_t absoluteProfileId, bool add);
+uint32_t FmPcdPlcrGetRequiredActionFlag(t_Handle h_FmPcd, uint16_t absoluteProfileId);
uint32_t FmPcdPlcrBuildNiaProfileReg(bool green, bool yellow, bool red);
void FmPcdPlcrUpdateRequiredAction(t_Handle h_FmPcd, uint16_t absoluteProfileId, uint32_t requiredAction);
+t_Error FmPcdPlcrCcGetSetParams(t_Handle h_FmPcd, uint16_t profileIndx,uint32_t requiredAction);
-/* FM-PCD Coarse-Classification API routines */
+/***********************************************************************/
+/* Common API for FM-PCD CC module */
+/***********************************************************************/
uint8_t FmPcdCcGetParseCode(t_Handle h_CcNode);
uint8_t FmPcdCcGetOffset(t_Handle h_CcNode);
-
-t_Error FmPcdManipUpdate(t_Handle h_FmPcd, t_Handle h_FmPort, t_Handle h_Manip, t_Handle h_Ad, bool validate, int level, t_Handle h_FmTree, bool modify);
-t_Error FmPortGetSetCcParams(t_Handle h_FmPort, t_FmPortGetSetCcParams *p_FmPortGetSetCcParams);
-uint32_t FmPcdManipGetRequiredAction (t_Handle h_Manip);
-t_Error FmPcdCcBindTree(t_Handle h_FmPcd, t_Handle h_CcTree, uint32_t *p_Offset,t_Handle h_FmPort);
+t_Error FmPcdCcRemoveKey(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode, uint16_t keyIndex);
+t_Error FmPcdCcAddKey(t_Handle h_FmPcd, t_Handle h_CcNode, uint16_t keyIndex, uint8_t keySize, t_FmPcdCcKeyParams *p_FmPCdCcKeyParams);
+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);
+t_Error FmPcdCcModifyKeyAndNextEngine(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode, uint16_t keyIndex, uint8_t keySize, t_FmPcdCcKeyParams *p_FmPcdCcKeyParams);
+t_Error FmPcdCcModifyMissNextEngineParamNode(t_Handle h_FmPcd,t_Handle h_FmPcdCcNode, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
+t_Error FmPcdCcModifyNextEngineParamTree(t_Handle h_FmPcd, t_Handle h_FmPcdCcTree, uint8_t grpId, uint8_t index, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
+uint32_t FmPcdCcGetNodeAddrOffsetFromNodeInfo(t_Handle h_FmPcd, t_Handle h_Pointer);
+t_Handle FmPcdCcTreeGetSavedManipParams(t_Handle h_FmTree);
+void FmPcdCcTreeSetSavedManipParams(t_Handle h_FmTree, t_Handle h_SavedManipParams);
+t_Error FmPcdCcTreeAddIPR(t_Handle h_FmPcd, t_Handle h_FmTree, t_Handle h_NetEnv, t_Handle h_ReassemblyManip, bool schemes);
+t_Error FmPcdCcTreeAddCPR(t_Handle h_FmPcd, t_Handle h_FmTree, t_Handle h_NetEnv, t_Handle h_ReassemblyManip, bool schemes);
+t_Error FmPcdCcBindTree(t_Handle h_FmPcd, t_Handle h_PcdParams, t_Handle h_CcTree, uint32_t *p_Offset,t_Handle h_FmPort);
t_Error FmPcdCcUnbindTree(t_Handle h_FmPcd, t_Handle h_CcTree);
-t_Error FmPcdPlcrCcGetSetParams(t_Handle h_FmPcd, uint16_t profileIndx,uint32_t requiredAction);
-t_Error FmPcdKgCcGetSetParams(t_Handle h_FmPcd, t_Handle h_Scheme, uint32_t requiredAction);
+/***********************************************************************/
+/* Common API for FM-PCD Manip module */
+/***********************************************************************/
+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);
+
+/***********************************************************************/
+/* Common API for FM-Port module */
+/***********************************************************************/
+#if (DPAA_VERSION >= 11)
+typedef enum e_FmPortGprFuncType
+{
+ e_FM_PORT_GPR_EMPTY = 0,
+ e_FM_PORT_GPR_MURAM_PAGE
+} e_FmPortGprFuncType;
+t_Error FmPortSetGprFunc(t_Handle h_FmPort, e_FmPortGprFuncType gprFunc, void **p_Value);
+#endif /* DPAA_VERSION >= 11) */
+t_Error FmGetSetParams(t_Handle h_Fm, t_FmGetSetParams *p_FmGetSetParams);
+t_Error FmPortGetSetCcParams(t_Handle h_FmPort, t_FmPortGetSetCcParams *p_FmPortGetSetCcParams);
uint8_t FmPortGetNetEnvId(t_Handle h_FmPort);
uint8_t FmPortGetHardwarePortId(t_Handle h_FmPort);
uint32_t FmPortGetPcdEngines(t_Handle h_FmPort);
void FmPortPcdKgSwUnbindClsPlanGrp (t_Handle h_FmPort);
-t_Error FmPortAttachPCD(t_Handle h_FmPort);
-t_Error FmPcdKgSetOrBindToClsPlanGrp(t_Handle h_FmPcd, uint8_t hardwarePortId, uint8_t netEnvId, protocolOpt_t *p_OptArray, uint8_t *p_ClsPlanGrpId, bool *p_IsEmptyClsPlanGrp);
-t_Error FmPcdKgDeleteOrUnbindPortToClsPlanGrp(t_Handle h_FmPcd, uint8_t hardwarePortId, uint8_t clsPlanGrpId);
+#if (DPAA_VERSION >= 11)
+t_Error FmPcdFrmReplicUpdate(t_Handle h_FmPcd, t_Handle h_FmPort, t_Handle h_FrmReplic);
+#endif /* (DPAA_VERSION >= 11) */
+
/**************************************************************************//**
@Function FmRegisterIntr
@@ -857,7 +827,7 @@ t_Error FmPcdKgDeleteOrUnbindPortToClsPlanGrp(t_Handle h_FmPcd, uint8_t hard
@Return None.
*//***************************************************************************/
-void FmRegisterIntr(t_Handle h_Fm,
+void FmRegisterIntr(t_Handle h_Fm,
e_FmEventModules mod,
uint8_t modId,
e_FmIntrType intrType,
@@ -926,6 +896,7 @@ typedef struct t_FmInterModulePortInitParams {
uint32_t sizeOfFifo; /**< IN. Port's requested resource */
uint32_t extraSizeOfFifo; /**< IN. Port's requested resource */
uint8_t deqPipelineDepth; /**< IN. Port's requested resource */
+ uint16_t maxFrameLength; /**< IN. Port's max frame length. */
uint16_t liodnBase; /**< IN. Irrelevant for P4080 rev 1.
LIODN base for this port, to be
used together with LIODN offset. */
@@ -938,9 +909,7 @@ typedef struct t_FmInterModulePortInitParams {
typedef struct t_FmInterModulePortFreeParams {
uint8_t hardwarePortId; /**< IN. port Id */
e_FmPortType portType; /**< IN. Port type */
-#ifdef FM_QMI_DEQ_OPTIONS_SUPPORT
uint8_t deqPipelineDepth; /**< IN. Port's requested resource */
-#endif /* FM_QMI_DEQ_OPTIONS_SUPPORT */
} t_FmInterModulePortFreeParams;
/**************************************************************************//**
@@ -1005,13 +974,17 @@ void FmGetPhysicalMuramBase(t_Handle h_Fm, t_FmPhysAddr *fmPhysAddr);
@Description Used internally by other modules in order to get the timeStamp
period as requested by the application.
+ This function returns bit number that is incremented every 1 usec.
+ To calculate timestamp period in nsec, use
+ 1000 / (1 << FmGetTimeStampScale()).
+
@Param[in] h_Fm A handle to an FM Module.
- @Return TimeStamp period in nanoseconds.
+ @Return Bit that counts 1 usec.
@Cautions Allowed only following FM_Init().
*//***************************************************************************/
-uint32_t FmGetTimeStampScale(t_Handle h_Fm);
+uint32_t FmGetTimeStampScale(t_Handle h_Fm);
/**************************************************************************//**
@Function FmResumeStalledPort
@@ -1071,6 +1044,19 @@ t_Error FmResetMac(t_Handle h_Fm, e_FmMacType type, uint8_t macId);
uint16_t FmGetClockFreq(t_Handle h_Fm);
/**************************************************************************//**
+ @Function FmGetMacClockFreq
+
+ @Description Used by MAC driver to get the MAC clock frequency
+
+ @Param[in] h_Fm A handle to an FM Module.
+
+ @Return clock-freq on success; 0 otherwise.
+
+ @Cautions Allowed only following FM_Init().
+*//***************************************************************************/
+uint16_t FmGetMacClockFreq(t_Handle h_Fm);
+
+/**************************************************************************//**
@Function FmGetId
@Description Used by PCD driver to read rhe FM id
@@ -1084,6 +1070,17 @@ uint16_t FmGetClockFreq(t_Handle h_Fm);
uint8_t FmGetId(t_Handle h_Fm);
/**************************************************************************//**
+ @Function FmReset
+
+ @Description Used to reset the FM
+
+ @Param[in] h_Fm A handle to an FM Module.
+
+ @Return E_OK on success; Error code otherwise.
+*//***************************************************************************/
+t_Error FmReset(t_Handle h_Fm);
+
+/**************************************************************************//**
@Function FmGetSetPortParams
@Description Used by FM-PORT driver to pass and receive parameters between
@@ -1113,25 +1110,41 @@ t_Error FmGetSetPortParams(t_Handle h_Fm,t_FmInterModulePortInitParams *p_PortPa
void FmFreePortParams(t_Handle h_Fm,t_FmInterModulePortFreeParams *p_PortParams);
/**************************************************************************//**
- @Function FmSetPortToWorkWithOneRiscOnly
+ @Function FmSetNumOfRiscsPerPort
@Description Used by FM-PORT driver to pass parameter between
PORT and FM modules for working with number of RISC..
@Param[in] h_Fm A handle to an FM Module.
- @Param[in,out] p_PortParams A structure of FM Port parameters.
+ @Param[in] hardwarePortId hardware port Id.
+ @Param[in] numOfFmanCtrls number of Fman Controllers.
+ @Param[in] orFmanCtrl Fman Controller for order restoration.
@Return None.
@Cautions Allowed only following FM_Init().
*//***************************************************************************/
-t_Error FmSetNumOfRiscsPerPort(t_Handle h_Fm, uint8_t hardwarePortId, uint8_t numOfFmanCtrls);
+t_Error FmSetNumOfRiscsPerPort(t_Handle h_Fm, uint8_t hardwarePortId, uint8_t numOfFmanCtrls, t_FmFmanCtrl orFmanCtrl);
+#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
+/**************************************************************************//*
+ @Function FmDumpPortRegs
+
+ @Description Dumps FM port registers which are part of FM common registers
+
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] hardwarePortId HW port id.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only FM_Init().
+*//***************************************************************************/
+t_Error FmDumpPortRegs(t_Handle h_Fm,uint8_t hardwarePortId);
+#endif /* (defined(DEBUG_ERRORS) && ... */
void FmRegisterPcd(t_Handle h_Fm, t_Handle h_FmPcd);
void FmUnregisterPcd(t_Handle h_Fm);
t_Handle FmGetPcdHandle(t_Handle h_Fm);
-bool FmRamsEccIsExternalCtl(t_Handle h_Fm);
t_Error FmEnableRamsEcc(t_Handle h_Fm);
t_Error FmDisableRamsEcc(t_Handle h_Fm);
void FmGetRevision(t_Handle h_Fm, t_FmRevisionInfo *p_FmRevisionInfo);
@@ -1144,30 +1157,58 @@ void FmUnregisterFmanCtrlIntr(t_Handle h_Fm, uint8_t eventRegId);
t_Error FmSetMacMaxFrame(t_Handle h_Fm, e_FmMacType type, uint8_t macId, uint16_t mtu);
bool FmIsMaster(t_Handle h_Fm);
uint8_t FmGetGuestId(t_Handle h_Fm);
+uint16_t FmGetTnumAgingPeriod(t_Handle h_Fm);
+t_Error FmSetPortPreFetchConfiguration(t_Handle h_Fm, uint8_t portNum, bool preFetchConfigured);
+t_Error FmGetPortPreFetchConfiguration(t_Handle h_Fm, uint8_t portNum, bool *p_PortConfigured, bool *p_PreFetchConfigured);
+
+
#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
t_Error Fm10GTxEccWorkaround(t_Handle h_Fm, uint8_t macId);
#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
void FmMuramClear(t_Handle h_FmMuram);
t_Error FmSetNumOfOpenDmas(t_Handle h_Fm,
- uint8_t hardwarePortId,
- uint8_t numOfOpenDmas,
- uint8_t numOfExtraOpenDmas,
- bool initialConfig);
+ uint8_t hardwarePortId,
+ uint8_t *p_NumOfOpenDmas,
+ uint8_t *p_NumOfExtraOpenDmas,
+ bool initialConfig);
t_Error FmSetNumOfTasks(t_Handle h_Fm,
- uint8_t hardwarePortId,
- uint8_t numOfTasks,
- uint8_t numOfExtraTasks,
- bool initialConfig);
-t_Error FmSetSizeOfFifo(t_Handle h_Fm,
- uint8_t hardwarePortId,
- e_FmPortType portType,
- bool independentMode,
- uint32_t *p_SizeOfFifo,
- uint32_t extraSizeOfFifo,
- uint8_t deqPipelineDepth,
- t_FmInterModulePortRxPoolsParams *p_RxPoolsParams,
- bool initialConfig);
+ uint8_t hardwarePortId,
+ uint8_t *p_NumOfTasks,
+ uint8_t *p_NumOfExtraTasks,
+ bool initialConfig);
+t_Error FmSetSizeOfFifo(t_Handle h_Fm,
+ uint8_t hardwarePortId,
+ uint32_t *p_SizeOfFifo,
+ uint32_t *p_ExtraSizeOfFifo,
+ bool initialConfig);
+
+t_Error FmSetCongestionGroupPFCpriority(t_Handle h_Fm,
+ uint32_t congestionGroupId,
+ uint8_t priorityBitMap);
+
+#if (DPAA_VERSION >= 11)
+t_Error FmVSPAllocForPort(t_Handle h_Fm,
+ e_FmPortType portType,
+ uint8_t portId,
+ uint8_t numOfStorageProfiles);
+
+t_Error FmVSPFreeForPort(t_Handle h_Fm,
+ e_FmPortType portType,
+ uint8_t portId);
+
+t_Error FmVSPGetAbsoluteProfileId(t_Handle h_Fm,
+ e_FmPortType portType,
+ uint8_t portId,
+ uint16_t relativeProfile,
+ uint16_t *p_AbsoluteId);
+t_Error FmVSPCheckRelativeProfile(t_Handle h_Fm,
+ e_FmPortType portType,
+ uint8_t portId,
+ uint16_t relativeProfile);
+
+uintptr_t FmGetVSPBaseAddr(t_Handle h_Fm);
+#endif /* (DPAA_VERSION >= 11) */
#endif /* __FM_COMMON_H */
diff --git a/sys/contrib/ncsw/Peripherals/FM/inc/fm_hc.h b/sys/contrib/ncsw/Peripherals/FM/inc/fm_hc.h
index bbcc83c6e46a..492aa8a3aa78 100644
--- a/sys/contrib/ncsw/Peripherals/FM/inc/fm_hc.h
+++ b/sys/contrib/ncsw/Peripherals/FM/inc/fm_hc.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,12 +30,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#ifndef __FM_HC_H
#define __FM_HC_H
#include "std_ext.h"
#include "error_ext.h"
-
+#include "fsl_fman_kg.h"
#define __ERR_MODULE__ MODULE_FM_PCD
@@ -49,28 +50,29 @@ typedef struct t_FmHcParams {
t_Handle FmHcConfigAndInit(t_FmHcParams *p_FmHcParams);
void FmHcFree(t_Handle h_FmHc);
+t_Error FmHcSetFramesDataMemory(t_Handle h_FmHc,
+ uint8_t memId);
t_Error FmHcDumpRegs(t_Handle h_FmHc);
void FmHcTxConf(t_Handle h_FmHc, t_DpaaFD *p_Fd);
-t_Handle FmHcPcdKgSetScheme(t_Handle h_FmHc, t_FmPcdKgSchemeParams *p_Scheme);
+t_Error FmHcPcdKgSetScheme(t_Handle h_FmHc,
+ t_Handle h_Scheme,
+ struct fman_kg_scheme_regs *p_SchemeRegs,
+ bool updateCounter);
t_Error FmHcPcdKgDeleteScheme(t_Handle h_FmHc, t_Handle h_Scheme);
t_Error FmHcPcdCcCapwapTimeoutReassm(t_Handle h_FmHc, t_FmPcdCcCapwapReassmTimeoutParams *p_CcCapwapReassmTimeoutParams );
+t_Error FmHcPcdCcIpFragScratchPollCmd(t_Handle h_FmHc, bool fill, t_FmPcdCcFragScratchPoolCmdParams *p_FmPcdCcFragScratchPoolCmdParams);
+t_Error FmHcPcdCcTimeoutReassm(t_Handle h_FmHc, t_FmPcdCcReassmTimeoutParams *p_CcReassmTimeoutParams, uint8_t *p_Result);
t_Error FmHcPcdKgSetClsPlan(t_Handle h_FmHc, t_FmPcdKgInterModuleClsPlanSet *p_Set);
t_Error FmHcPcdKgDeleteClsPlan(t_Handle h_FmHc, uint8_t clsPlanGrpId);
t_Error FmHcPcdKgSetSchemeCounter(t_Handle h_FmHc, t_Handle h_Scheme, uint32_t value);
uint32_t FmHcPcdKgGetSchemeCounter(t_Handle h_FmHc, t_Handle h_Scheme);
-t_Error FmHcPcdCcModifyTreeNextEngine(t_Handle h_FmHc, t_Handle h_CcTree, uint8_t grpId, uint8_t index, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
-t_Error FmHcPcdCcModifyNodeNextEngine(t_Handle h_FmHc, t_Handle h_CcNode, uint8_t keyIndex, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
-t_Error FmHcPcdCcModifyNodeMissNextEngine(t_Handle h_FmHc, t_Handle h_CcNode, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
-t_Error FmHcPcdCcRemoveKey(t_Handle h_FmHc, t_Handle h_CcNode, uint8_t keyIndex);
-t_Error FmHcPcdCcAddKey(t_Handle h_FmHc, t_Handle h_CcNode, uint8_t keyIndex, uint8_t keySize, t_FmPcdCcKeyParams *p_KeyParams);
-t_Error FmHcPcdCcModifyKeyAndNextEngine(t_Handle h_FmHc, t_Handle h_CcNode, uint8_t keyIndex, uint8_t keySize, t_FmPcdCcKeyParams *p_KeyParams);
-t_Error FmHcPcdCcModifyKey(t_Handle h_FmHc, t_Handle h_CcNode, uint8_t keyIndex, uint8_t keySize, uint8_t *p_Key, uint8_t *p_Mask);
+t_Error FmHcPcdCcDoDynamicChange(t_Handle h_FmHc, uint32_t oldAdAddrOffset, uint32_t newAdAddrOffset);
-t_Handle FmHcPcdPlcrSetProfile(t_Handle h_FmHc,t_FmPcdPlcrProfileParams *p_Profile);
+t_Error FmHcPcdPlcrSetProfile(t_Handle h_FmHc, t_Handle h_Profile, t_FmPcdPlcrProfileRegs *p_PlcrRegs);
t_Error FmHcPcdPlcrDeleteProfile(t_Handle h_FmHc, t_Handle h_Profile);
t_Error FmHcPcdPlcrSetProfileCounter(t_Handle h_FmHc, t_Handle h_Profile, e_FmPcdPlcrProfileCounters counter, uint32_t value);
@@ -79,8 +81,13 @@ uint32_t FmHcPcdPlcrGetProfileCounter(t_Handle h_FmHc, t_Handle h_Profile, e_
t_Error FmHcKgWriteSp(t_Handle h_FmHc, uint8_t hardwarePortId, uint32_t spReg, bool add);
t_Error FmHcKgWriteCpp(t_Handle h_FmHc, uint8_t hardwarePortId, uint32_t cppReg);
-t_Error FmHcPcdKgCcGetSetParams(t_Handle h_FmHc, t_Handle h_Scheme, uint32_t requiredAction);
+t_Error FmHcPcdKgCcGetSetParams(t_Handle h_FmHc, t_Handle h_Scheme, uint32_t requiredAction, uint32_t value);
t_Error FmHcPcdPlcrCcGetSetParams(t_Handle h_FmHc,uint16_t absoluteProfileId, uint32_t requiredAction);
+t_Error FmHcPcdSync(t_Handle h_FmHc);
+t_Handle FmHcGetPort(t_Handle h_FmHc);
+
+
+
#endif /* __FM_HC_H */
diff --git a/sys/contrib/ncsw/Peripherals/FM/inc/fm_sp_common.h b/sys/contrib/ncsw/Peripherals/FM/inc/fm_sp_common.h
new file mode 100644
index 000000000000..f9dd384bb685
--- /dev/null
+++ b/sys/contrib/ncsw/Peripherals/FM/inc/fm_sp_common.h
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/******************************************************************************
+ @File fm_sp_common.h
+
+ @Description FM SP ...
+*//***************************************************************************/
+#ifndef __FM_SP_COMMON_H
+#define __FM_SP_COMMON_H
+
+#include "std_ext.h"
+#include "error_ext.h"
+#include "list_ext.h"
+
+#include "fm_ext.h"
+#include "fm_pcd_ext.h"
+#include "fsl_fman.h"
+
+/**************************************************************************//**
+ @Description defaults
+*//***************************************************************************/
+#define DEFAULT_FM_SP_bufferPrefixContent_privDataSize 0
+#define DEFAULT_FM_SP_bufferPrefixContent_passPrsResult FALSE
+#define DEFAULT_FM_SP_bufferPrefixContent_passTimeStamp FALSE
+#define DEFAULT_FM_SP_bufferPrefixContent_allOtherPCDInfo FALSE
+#define DEFAULT_FM_SP_bufferPrefixContent_dataAlign 64
+
+/**************************************************************************//**
+ @Description structure for defining internal context copying
+*//***************************************************************************/
+typedef struct
+{
+ uint16_t extBufOffset; /**< Offset in External buffer to which internal
+ context is copied to (Rx) or taken from (Tx, Op). */
+ uint8_t intContextOffset; /**< Offset within internal context to copy from
+ (Rx) or to copy to (Tx, Op). */
+ uint16_t size; /**< Internal offset size to be copied */
+} t_FmSpIntContextDataCopy;
+
+/**************************************************************************//**
+ @Description struct for defining external buffer margins
+*//***************************************************************************/
+typedef struct {
+ uint16_t startMargins; /**< Number of bytes to be left at the beginning
+ of the external buffer (must be divisible by 16) */
+ uint16_t endMargins; /**< number of bytes to be left at the end
+ of the external buffer(must be divisible by 16) */
+} t_FmSpBufMargins;
+
+typedef struct {
+ uint32_t dataOffset;
+ uint32_t prsResultOffset;
+ uint32_t timeStampOffset;
+ uint32_t hashResultOffset;
+ uint32_t pcdInfoOffset;
+ uint32_t manipOffset;
+} t_FmSpBufferOffsets;
+
+
+t_Error FmSpBuildBufferStructure(t_FmSpIntContextDataCopy *p_FmPortIntContextDataCopy,
+ t_FmBufferPrefixContent *p_BufferPrefixContent,
+ t_FmSpBufMargins *p_FmPortBufMargins,
+ t_FmSpBufferOffsets *p_FmPortBufferOffsets,
+ uint8_t *internalBufferOffset);
+
+t_Error FmSpCheckIntContextParams(t_FmSpIntContextDataCopy *p_FmSpIntContextDataCopy);
+t_Error FmSpCheckBufPoolsParams(t_FmExtPools *p_FmExtPools,
+ t_FmBackupBmPools *p_FmBackupBmPools,
+ t_FmBufPoolDepletion *p_FmBufPoolDepletion);
+t_Error FmSpCheckBufMargins(t_FmSpBufMargins *p_FmSpBufMargins);
+void FmSpSetBufPoolsInAscOrderOfBufSizes(t_FmExtPools *p_FmExtPools, uint8_t *orderedArray, uint16_t *sizesArray);
+
+t_Error FmPcdSpAllocProfiles(t_Handle h_FmPcd,
+ uint8_t hardwarePortId,
+ uint16_t numOfStorageProfiles,
+ uint16_t *base,
+ uint8_t *log2Num);
+t_Error FmPcdSpGetAbsoluteProfileId(t_Handle h_FmPcd,
+ t_Handle h_FmPort,
+ uint16_t relativeProfile,
+ uint16_t *p_AbsoluteId);
+void SpInvalidateProfileSw(t_Handle h_FmPcd, uint16_t absoluteProfileId);
+void SpValidateProfileSw(t_Handle h_FmPcd, uint16_t absoluteProfileId);
+
+
+#endif /* __FM_SP_COMMON_H */
diff --git a/sys/contrib/ncsw/Peripherals/QM/fsl_qman.h b/sys/contrib/ncsw/Peripherals/QM/fsl_qman.h
index 42573f6964a2..bcb2c243a258 100644
--- a/sys/contrib/ncsw/Peripherals/QM/fsl_qman.h
+++ b/sys/contrib/ncsw/Peripherals/QM/fsl_qman.h
@@ -117,7 +117,7 @@ struct qm_portal_config {
* affinity configured. */
int cpu;
/* portal interrupt line */
- int irq;
+ uintptr_t irq;
/* The portal's dedicated channel id, use this value for initializing
* frame queues to target this portal when scheduled. */
e_QmFQChannel channel;
diff --git a/sys/contrib/ncsw/Peripherals/QM/qm.c b/sys/contrib/ncsw/Peripherals/QM/qm.c
index d1d7032f882b..50b74712e266 100644
--- a/sys/contrib/ncsw/Peripherals/QM/qm.c
+++ b/sys/contrib/ncsw/Peripherals/QM/qm.c
@@ -38,6 +38,10 @@
@Description QM & Portal implementation
*//***************************************************************************/
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <machine/atomic.h>
#include "error_ext.h"
#include "std_ext.h"
#include "string_ext.h"
@@ -209,7 +213,7 @@ static t_Error QmInitPfdr(t_Qm *p_Qm, uint32_t pfdr_start, uint32_t num)
WRITE_UINT32(p_Qm->p_QmRegs->mcp1, (pfdr_start + num - 16));
WRITE_UINT32(p_Qm->p_QmRegs->mcp1, (pfdr_start + num - 1));
- CORE_MemoryBarrier();
+ mb();
WRITE_UINT32(p_Qm->p_QmRegs->mcr, MCR_INIT_PFDR);
/* Poll for the result */
@@ -556,6 +560,7 @@ uint32_t QmFqidGet(t_Qm *p_Qm, uint32_t size, uint32_t alignment, bool force, ui
"QM FQID MEM");
XX_UnlockIntrSpinlock(p_Qm->lock, intFlags);
+ KASSERT(ans < UINT32_MAX, ("Oops, %lx > UINT32_MAX!\n", ans));
return (uint32_t)ans;
}
@@ -784,10 +789,10 @@ t_Error QM_Init(t_Handle h_Qm)
RETURN_ERROR(MAJOR, E_NO_MEMORY, ("FQD obj!!!"));
}
memset(p_Qm->p_FqdBase, 0, dsSize);
- CORE_MemoryBarrier();
+ mb();
for (i=0; i<dsSize; i+=64)
dcbf(PTR_MOVE(p_Qm->p_FqdBase, i));
- CORE_MemoryBarrier();
+ mb();
phyAddr = XX_VirtToPhys(p_Qm->p_FqdBase);
WRITE_UINT32(p_Qm->p_QmRegs->fqd_bare, ((uint32_t)(phyAddr >> 32) & 0x000000ff));
diff --git a/sys/contrib/ncsw/Peripherals/QM/qm.h b/sys/contrib/ncsw/Peripherals/QM/qm.h
index 68af1855b96a..a004dc55a67d 100644
--- a/sys/contrib/ncsw/Peripherals/QM/qm.h
+++ b/sys/contrib/ncsw/Peripherals/QM/qm.h
@@ -482,7 +482,7 @@ typedef struct {
uint32_t exceptions;
t_QmExceptionsCallback *f_Exception;
t_Handle h_App;
- int errIrq; /**< error interrupt line; NO_IRQ if interrupts not used */
+ uintptr_t errIrq; /**< error interrupt line; NO_IRQ if interrupts not used */
uint32_t numOfPfdr;
uint16_t partNumOfCgs;
uint16_t partCgsBase;
diff --git a/sys/contrib/ncsw/Peripherals/QM/qm_portal_fqr.c b/sys/contrib/ncsw/Peripherals/QM/qm_portal_fqr.c
index f1c23ac74671..f49c1f42258d 100644
--- a/sys/contrib/ncsw/Peripherals/QM/qm_portal_fqr.c
+++ b/sys/contrib/ncsw/Peripherals/QM/qm_portal_fqr.c
@@ -38,6 +38,10 @@
@Description QM & Portal implementation
*//***************************************************************************/
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <machine/atomic.h>
+
#include "error_ext.h"
#include "std_ext.h"
#include "string_ext.h"
@@ -45,6 +49,7 @@
#include "qm.h"
#include "qman_low.h"
+#include <machine/vmparam.h>
/****************************************/
/* static functions */
@@ -53,6 +58,40 @@
#define SLOW_POLL_IDLE 1000
#define SLOW_POLL_BUSY 10
+/*
+ * Context entries are 32-bit. The qman driver uses the pointer to the queue as
+ * its context, and the pointer is 64-byte aligned, per the XX_MallocSmart()
+ * call. Take advantage of this fact to shove a 64-bit kernel pointer into a
+ * 32-bit context integer, and back.
+ *
+ * XXX: This depends on the fact that VM_MAX_KERNEL_ADDRESS is less than 38-bit
+ * count from VM_MIN_KERNEL_ADDRESS. If this ever changes, this needs to be
+ * updated.
+ */
+CTASSERT((VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) < (1ULL << 35));
+static inline uint32_t
+aligned_int_from_ptr(const void *p)
+{
+ uintptr_t ctx;
+
+ ctx = (uintptr_t)p;
+ KASSERT(ctx >= VM_MIN_KERNEL_ADDRESS, ("%p is too low!\n", p));
+ ctx -= VM_MIN_KERNEL_ADDRESS;
+ KASSERT((ctx & 0x07) == 0, ("Pointer %p is not 8-byte aligned!\n", p));
+ if ((ctx & (0x7)) != 0)
+ return (0);
+ return (ctx >> 3);
+}
+
+static inline void *
+ptr_from_aligned_int(uint32_t ctx)
+{
+ uintptr_t p;
+
+ p = VM_MIN_KERNEL_ADDRESS + (ctx << 3);
+
+ return ((void *)p);
+}
static t_Error qman_volatile_dequeue(t_QmPortal *p_QmPortal,
struct qman_fq *p_Fq,
@@ -259,7 +298,7 @@ static t_Error qman_retire_fq(t_QmPortal *p_QmPortal,
p_Mcc = qm_mc_start(p_QmPortal->p_LowQmPortal);
p_Mcc->alterfq.fqid = p_Fq->fqid;
if (drain)
- p_Mcc->alterfq.context_b = (uint32_t)PTR_TO_UINT(p_Fq);
+ p_Mcc->alterfq.context_b = aligned_int_from_ptr(p_Fq);
qm_mc_commit(p_QmPortal->p_LowQmPortal,
(uint8_t)((drain)?QM_MCC_VERB_ALTER_RETIRE_CTXB:QM_MCC_VERB_ALTER_RETIRE));
while (!(p_Mcr = qm_mc_result(p_QmPortal->p_LowQmPortal))) ;
@@ -568,8 +607,8 @@ mr_loop:
qmPortalMrPvbUpdate(p_QmPortal->p_LowQmPortal);
p_Msg = qm_mr_current(p_QmPortal->p_LowQmPortal);
if (p_Msg) {
- struct qman_fq *p_FqFqs = UINT_TO_PTR(p_Msg->fq.contextB);
- struct qman_fq *p_FqErn = UINT_TO_PTR(p_Msg->ern.tag);
+ struct qman_fq *p_FqFqs = ptr_from_aligned_int(p_Msg->fq.contextB);
+ struct qman_fq *p_FqErn = ptr_from_aligned_int(p_Msg->ern.tag);
uint8_t verb =(uint8_t)(p_Msg->verb & QM_MR_VERB_TYPE_MASK);
t_QmRejectedFrameInfo rejectedFrameInfo;
@@ -646,7 +685,7 @@ static void LoopDequeueRing(t_Handle h_QmPortal)
p_Dq = qm_dqrr_current(p_QmPortal->p_LowQmPortal);
if (!p_Dq)
break;
- p_Fq = UINT_TO_PTR(p_Dq->contextB);
+ p_Fq = ptr_from_aligned_int(p_Dq->contextB);
if (p_Dq->stat & QM_DQRR_STAT_UNSCHEDULED) {
/* We only set QMAN_FQ_STATE_NE when retiring, so we only need
* to check for clearing it when doing volatile dequeues. It's
@@ -728,7 +767,7 @@ static void LoopDequeueRingDcaOptimized(t_Handle h_QmPortal)
p_Dq = qm_dqrr_current(p_QmPortal->p_LowQmPortal);
if (!p_Dq)
break;
- p_Fq = UINT_TO_PTR(p_Dq->contextB);
+ p_Fq = ptr_from_aligned_int(p_Dq->contextB);
if (p_Dq->stat & QM_DQRR_STAT_UNSCHEDULED) {
/* We only set QMAN_FQ_STATE_NE when retiring, so we only need
* to check for clearing it when doing volatile dequeues. It's
@@ -802,7 +841,7 @@ static void LoopDequeueRingOptimized(t_Handle h_QmPortal)
p_Dq = qm_dqrr_current(p_QmPortal->p_LowQmPortal);
if (!p_Dq)
break;
- p_Fq = UINT_TO_PTR(p_Dq->contextB);
+ p_Fq = ptr_from_aligned_int(p_Dq->contextB);
if (p_Dq->stat & QM_DQRR_STAT_UNSCHEDULED) {
/* We only set QMAN_FQ_STATE_NE when retiring, so we only need
* to check for clearing it when doing volatile dequeues. It's
@@ -1023,13 +1062,8 @@ static t_Error qm_new_fq(t_QmPortal *p_QmPortal,
/* If this FQ will not be used for tx, we can use contextB field */
if (fq_opts.fqd.dest.channel < e_QM_FQ_CHANNEL_FMAN0_SP0)
{
- if (sizeof(p_Fqs[0]) <= sizeof(fq_opts.fqd.context_b))
- {
fq_opts.we_mask |= QM_INITFQ_WE_CONTEXTB;
- fq_opts.fqd.context_b = (uint32_t)PTR_TO_UINT(p_Fqs[0]);
- }
- else
- RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, ("64 bit pointer (virtual) not supported yet!!!"));
+ fq_opts.fqd.context_b = aligned_int_from_ptr(p_Fqs[0]);
}
else if (p_ContextB) /* Tx-Queue */
{
@@ -1102,7 +1136,7 @@ static t_Error qm_free_fq(t_QmPortal *p_QmPortal, struct qman_fq *p_Fq)
{
uint32_t flags=0;
- if (qman_retire_fq(p_QmPortal, p_Fq, &flags, FALSE) != E_OK)
+ if (qman_retire_fq(p_QmPortal, p_Fq, &flags, false) != E_OK)
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("qman_retire_fq() failed!"));
if (flags & QMAN_FQ_STATE_CHANGING)
@@ -1471,7 +1505,7 @@ static t_Error QmPortalPullFrame(t_Handle h_QmPortal, uint32_t pdqcr, t_DpaaFD *
NCSW_PLOCK(p_QmPortal);
qm_dqrr_pdqcr_set(p_QmPortal->p_LowQmPortal, pdqcr);
- CORE_MemoryBarrier();
+ mb();
while (qm_dqrr_pdqcr_get(p_QmPortal->p_LowQmPortal)) ;
prefetch = !(p_QmPortal->options & QMAN_PORTAL_FLAG_RSTASH);
@@ -1483,7 +1517,7 @@ static t_Error QmPortalPullFrame(t_Handle h_QmPortal, uint32_t pdqcr, t_DpaaFD *
p_Dq = qm_dqrr_current(p_QmPortal->p_LowQmPortal);
if (!p_Dq)
continue;
- p_Fq = UINT_TO_PTR(p_Dq->contextB);
+ p_Fq = ptr_from_aligned_int(p_Dq->contextB);
ASSERT_COND(p_Dq->fqid);
p_Dst = (uint32_t *)p_Frame;
p_Src = (uint32_t *)&p_Dq->fd;
@@ -1495,7 +1529,7 @@ static t_Error QmPortalPullFrame(t_Handle h_QmPortal, uint32_t pdqcr, t_DpaaFD *
{
qmPortalDqrrDcaConsume1ptr(p_QmPortal->p_LowQmPortal,
p_Dq,
- FALSE);
+ false);
qm_dqrr_next(p_QmPortal->p_LowQmPortal);
}
else
@@ -1811,7 +1845,7 @@ t_Error QM_PORTAL_PollFrame(t_Handle h_QmPortal, t_QmPortalFrameInfo *p_frameInf
PUNLOCK(p_QmPortal);
return ERROR_CODE(E_EMPTY);
}
- p_Fq = UINT_TO_PTR(p_Dq->contextB);
+ p_Fq = ptr_from_aligned_int(p_Dq->contextB);
ASSERT_COND(p_Dq->fqid);
if (p_Fq)
{
@@ -1830,7 +1864,7 @@ t_Error QM_PORTAL_PollFrame(t_Handle h_QmPortal, t_QmPortalFrameInfo *p_frameInf
if (p_QmPortal->options & QMAN_PORTAL_FLAG_DCA) {
qmPortalDqrrDcaConsume1ptr(p_QmPortal->p_LowQmPortal,
p_Dq,
- FALSE);
+ false);
qm_dqrr_next(p_QmPortal->p_LowQmPortal);
} else {
qm_dqrr_next(p_QmPortal->p_LowQmPortal);
@@ -2064,7 +2098,7 @@ t_Error QM_FQR_FreeWDrain(t_Handle h_QmFqr,
for (i=0;i<p_QmFqr->numOfFqids;i++)
{
- if (qman_retire_fq(p_QmFqr->h_QmPortal, p_QmFqr->p_Fqs[i], 0, TRUE) != E_OK)
+ if (qman_retire_fq(p_QmFqr->h_QmPortal, p_QmFqr->p_Fqs[i], 0, true) != E_OK)
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("qman_retire_fq() failed!"));
if (p_QmFqr->p_Fqs[i]->flags & QMAN_FQ_STATE_CHANGING)
@@ -2141,7 +2175,7 @@ t_Error QM_FQR_Enqueue(t_Handle h_QmFqr, t_Handle h_QmPortal, uint32_t fqidOffse
}
p_Eq->fqid = p_Fq->fqid;
- p_Eq->tag = (uintptr_t)p_Fq;
+ p_Eq->tag = aligned_int_from_ptr(p_Fq);
/* gcc does a dreadful job of the following;
* eq->fd = *fd;
* It causes the entire function to save/restore a wider range of
diff --git a/sys/contrib/ncsw/Peripherals/QM/qman_low.h b/sys/contrib/ncsw/Peripherals/QM/qman_low.h
index 612f4cac8848..1becfc15554a 100644
--- a/sys/contrib/ncsw/Peripherals/QM/qman_low.h
+++ b/sys/contrib/ncsw/Peripherals/QM/qman_low.h
@@ -96,7 +96,7 @@ static __inline__ void *ptr_ADD(void *a, uintptr_t b)
/* Bitwise-OR two pointers */
static __inline__ void *ptr_OR(void *a, uintptr_t b)
{
- return (void *)((uintptr_t)a + b);
+ return (void *)((uintptr_t)a | b);
}
/* Cache-inhibited register access */
@@ -323,7 +323,7 @@ static __inline__ void qmPortalEqcrPciCommit(struct qm_portal *portal, uint8_t m
EQCR_INC(eqcr);
eqcr->available--;
dcbf_64(eqcr->cursor);
- hwsync();
+ mb();
qm_out(EQCR_PI_CINH, EQCR_PTR2IDX(eqcr->cursor));
#ifdef QM_CHECKING
eqcr->busy = 0;
@@ -351,7 +351,7 @@ static __inline__ void qmPortalEqcrPceCommit(struct qm_portal *portal, uint8_t m
EQCR_INC(eqcr);
eqcr->available--;
dcbf_64(eqcr->cursor);
- lwsync();
+ wmb();
qm_cl_out(EQCR_PI, EQCR_PTR2IDX(eqcr->cursor));
#ifdef QM_CHECKING
eqcr->busy = 0;
@@ -366,7 +366,7 @@ static __inline__ void qmPortalEqcrPvbCommit(struct qm_portal *portal, uint8_t m
EQCR_COMMIT_CHECKS(eqcr);
ASSERT_COND(eqcr->pmode == e_QmPortalPVB);
#endif /* QM_CHECKING */
- lwsync();
+ rmb();
eqcursor = eqcr->cursor;
eqcursor->__dont_write_directly__verb = (uint8_t)(myverb | eqcr->vbit);
dcbf_64(eqcursor);
@@ -1086,7 +1086,7 @@ static __inline__ void qm_mc_commit(struct qm_portal *portal, uint8_t myverb)
#ifdef QM_CHECKING
ASSERT_COND(mc->state == mc_user);
#endif /* QM_CHECKING */
- lwsync();
+ rmb();
mc->cr->__dont_write_directly__verb = (uint8_t)(myverb | mc->vbit);
dcbf_64(mc->cr);
dcbit_ro(mc->rr + mc->rridx);
diff --git a/sys/contrib/ncsw/Peripherals/QM/qman_private.h b/sys/contrib/ncsw/Peripherals/QM/qman_private.h
index 5bab41802f89..0b172879099a 100644
--- a/sys/contrib/ncsw/Peripherals/QM/qman_private.h
+++ b/sys/contrib/ncsw/Peripherals/QM/qman_private.h
@@ -55,76 +55,13 @@
* and that dcbzl(), dcbfl(), and dcbi() won't fall victim to compiler or
* execution reordering with respect to other code/instructions that manipulate
* the same cacheline. */
-#ifdef CORE_E500MC
-
-#if defined(_DIAB_TOOL)
-#define hwsync() \
-do { \
-__asm__ __volatile__ ("sync"); \
-} while(0)
-
-#define lwsync() \
-do { \
-__asm__ __volatile__ ("lwsync"); \
-} while(0)
-
-__asm__ __volatile__ void dcbf (volatile void * addr)
-{
-%reg addr
- dcbf r0, addr
-}
-
-__asm__ __volatile__ void dcbt_ro (volatile void * addr)
-{
-%reg addr
- dcbt r0, addr
-}
-
-__asm__ __volatile__ void dcbt_rw (volatile void * addr)
-{
-%reg addr
- dcbtst r0, addr
-}
-
-__asm__ __volatile__ void dcbzl (volatile void * addr)
-{
-%reg addr
- dcbzl r0, addr
-}
-
-#define dcbz_64(p) \
- do { \
- dcbzl(p); \
- } while (0)
-
-#define dcbf_64(p) \
- do { \
- dcbf(p); \
- } while (0)
-
-/* Commonly used combo */
-#define dcbit_ro(p) \
- do { \
- dcbi(p); \
- dcbt_ro(p); \
- } while (0)
-
-#else /* GNU C */
-#define hwsync() \
- do { \
- __asm__ __volatile__ ("sync" : : : "memory"); \
- } while(0)
-
-#define lwsync() \
- do { \
- __asm__ __volatile__ ("lwsync" : : : "memory"); \
- } while(0)
#define dcbf(addr) \
do { \
__asm__ __volatile__ ("dcbf 0, %0" : : "r" (addr)); \
} while(0)
+#ifdef CORE_E500MC
#define dcbt_ro(addr) \
do { \
__asm__ __volatile__ ("dcbt 0, %0" : : "r" (addr)); \
@@ -157,16 +94,8 @@ __asm__ __volatile__ void dcbzl (volatile void * addr)
dcbt_ro(p); \
} while (0)
-#endif /* _DIAB_TOOL */
-
#else
-#define hwsync CORE_MemoryBarrier
-#define lwsync hwsync
-#define dcbf(p) \
- do { \
- __asm__ __volatile__ ("dcbf 0,%0" : : "r" (p)); \
- } while(0)
#define dcbt_ro(p) \
do { \
__asm__ __volatile__ ("dcbt 0,%0" : : "r" (p)); \
@@ -182,21 +111,21 @@ __asm__ __volatile__ void dcbzl (volatile void * addr)
} while (0)
#define dcbz_64(p) \
do { \
- dcbz((uint32_t)p + 32); \
+ dcbz((char *)p + 32); \
dcbz(p); \
} while (0)
#define dcbf_64(p) \
do { \
- dcbf((uint32_t)p + 32); \
+ dcbf((char *)p + 32); \
dcbf(p); \
} while (0)
/* Commonly used combo */
#define dcbit_ro(p) \
do { \
dcbi(p); \
- dcbi((uint32_t)p + 32); \
+ dcbi((char *)p + 32); \
dcbt_ro(p); \
- dcbt_ro((uint32_t)p + 32); \
+ dcbt_ro((char *)p + 32); \
} while (0)
#endif /* CORE_E500MC */
diff --git a/sys/contrib/ncsw/etc/error.c b/sys/contrib/ncsw/etc/error.c
index 896722fe8b5e..fead7f50f2ba 100644
--- a/sys/contrib/ncsw/etc/error.c
+++ b/sys/contrib/ncsw/etc/error.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,14 +30,16 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/*
@File error.c
@Description General errors and events reporting utilities.
*//***************************************************************************/
-
#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
+#include "error_ext.h"
+
const char *dbgLevelStrings[] =
{
@@ -49,70 +51,45 @@ const char *dbgLevelStrings[] =
,"TRACE"
};
-const char *errTypeStrings[] =
-{
- "Invalid State" /* E_INVALID_STATE */
- ,"Invalid Operation" /* E_INVALID_OPERATION */
- ,"Unsupported Operation" /* E_NOT_SUPPORTED */
- ,"No Device" /* E_NO_DEVICE */
- ,"Invalid Handle" /* E_INVALID_HANDLE */
- ,"Invalid ID" /* E_INVALID_ID */
- ,"Unexpected NULL Pointer" /* E_NULL_POINTER */
- ,"Invalid Value" /* E_INVALID_VALUE */
- ,"Invalid Selection" /* E_INVALID_SELECTION */
- ,"Invalid Communication Mode" /* E_INVALID_COMM_MODE */
- ,"Invalid Byte Order" /* E_INVALID_BYTE_ORDER */
- ,"Invalid Memory Type" /* E_INVALID_MEMORY_TYPE */
- ,"Invalid Interrupt Queue" /* E_INVALID_INTR_QUEUE */
- ,"Invalid Priority" /* E_INVALID_PRIORITY */
- ,"Invalid Clock" /* E_INVALID_CLOCK */
- ,"Invalid Rate" /* E_INVALID_RATE */
- ,"Invalid Address" /* E_INVALID_ADDRESS */
- ,"Invalid Bus" /* E_INVALID_BUS */
- ,"Conflict In Bus Selection" /* E_BUS_CONFLICT */
- ,"Conflict In Settings" /* E_CONFLICT */
- ,"Incorrect Alignment" /* E_NOT_ALIGNED */
- ,"Value Out Of Range" /* E_NOT_IN_RANGE */
- ,"Invalid Frame" /* E_INVALID_FRAME */
- ,"Frame Is Empty" /* E_EMPTY_FRAME */
- ,"Buffer Is Empty" /* E_EMPTY_BUFFER */
- ,"Memory Allocation Failed" /* E_NO_MEMORY */
- ,"Resource Not Found" /* E_NOT_FOUND */
- ,"Resource Is Unavailable" /* E_NOT_AVAILABLE */
- ,"Resource Already Exists" /* E_ALREADY_EXISTS */
- ,"Resource Is Full" /* E_FULL */
- ,"Resource Is Empty" /* E_EMPTY */
- ,"Resource Is Busy" /* E_BUSY */
- ,"Resource Already Free" /* E_ALREADY_FREE */
- ,"Read Access Failed" /* E_READ_FAILED */
- ,"Write Access Failed" /* E_WRITE_FAILED */
- ,"Send Operation Failed" /* E_SEND_FAILED */
- ,"Receive Operation Failed" /* E_RECEIVE_FAILED */
- ,"Operation Timed Out" /* E_TIMEOUT */
-};
-
-
-#if (defined(REPORT_EVENTS) && (REPORT_EVENTS > 0))
-const char *eventStrings[] =
+char * ErrTypeStrings (e_ErrorType err)
{
- "Rx Discard" /* EV_RX_DISCARD */
- ,"Rx Error" /* EV_RX_ERROR */
- ,"Tx Error" /* EV_TX_ERROR */
- ,"No Buffer Objects" /* EV_NO_BUFFERS */
- ,"No MB-Frame Objects" /* EV_NO_MB_FRAMES */
- ,"No SB-Frame Objects" /* EV_NO_SB_FRAMES */
- ,"Tx Queue Is Full" /* EV_TX_QUEUE_FULL */
- ,"Rx Queue Is Full" /* EV_RX_QUEUE_FULL */
- ,"Interrupts Queue Is Full" /* EV_INTR_QUEUE_FULL */
- ,"Data Buffer Is Unavailable" /* EV_NO_DATA_BUFFER */
- ,"Objects Pool Is Empty" /* EV_OBJ_POOL_EMPTY */
- ,"Illegal bus access" /* EV_BUS_ERROR */
- ,"PTP Tx Timestamps Queue Is Full" /* EV_PTP_TXTS_QUEUE_FULL */
- ,"PTP Rx Timestamps Queue Is Full" /* EV_PTP_RXTS_QUEUE_FULL */
-};
-
-#endif /* (defined(REPORT_EVENTS) && (REPORT_EVENTS > 0)) */
-
+ switch (err)
+ {
+ case (E_OK): return "OK";
+ case (E_WRITE_FAILED): return "Write Access Failed";
+ case (E_NO_DEVICE): return "No Device";
+ case (E_NOT_AVAILABLE): return "Resource Is Unavailable";
+ case (E_NO_MEMORY): return "Memory Allocation Failed";
+ case (E_INVALID_ADDRESS): return "Invalid Address";
+ case (E_BUSY): return "Resource Is Busy";
+ case (E_ALREADY_EXISTS): return "Resource Already Exists";
+ case (E_INVALID_OPERATION): return "Invalid Operation";
+ case (E_INVALID_VALUE): return "Invalid Value";
+ case (E_NOT_IN_RANGE): return "Value Out Of Range";
+ case (E_NOT_SUPPORTED): return "Unsupported Operation";
+ case (E_INVALID_STATE): return "Invalid State";
+ case (E_INVALID_HANDLE): return "Invalid Handle";
+ case (E_INVALID_ID): return "Invalid ID";
+ case (E_NULL_POINTER): return "Unexpected NULL Pointer";
+ case (E_INVALID_SELECTION): return "Invalid Selection";
+ case (E_INVALID_COMM_MODE): return "Invalid Communication Mode";
+ case (E_INVALID_MEMORY_TYPE): return "Invalid Memory Type";
+ case (E_INVALID_CLOCK): return "Invalid Clock";
+ case (E_CONFLICT): return "Conflict In Settings";
+ case (E_NOT_ALIGNED): return "Incorrect Alignment";
+ case (E_NOT_FOUND): return "Resource Not Found";
+ case (E_FULL): return "Resource Is Full";
+ case (E_EMPTY): return "Resource Is Empty";
+ case (E_ALREADY_FREE): return "Resource Already Free";
+ case (E_READ_FAILED): return "Read Access Failed";
+ case (E_INVALID_FRAME): return "Invalid Frame";
+ case (E_SEND_FAILED): return "Send Operation Failed";
+ case (E_RECEIVE_FAILED): return "Receive Operation Failed";
+ case (E_TIMEOUT): return "Operation Timed Out";
+ default:
+ break;
+ }
+ return NULL;
+}
#endif /* (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0)) */
-
diff --git a/sys/contrib/ncsw/etc/list.c b/sys/contrib/ncsw/etc/list.c
index 62a5fcdf5895..efe0d6727141 100644
--- a/sys/contrib/ncsw/etc/list.c
+++ b/sys/contrib/ncsw/etc/list.c
@@ -40,30 +40,30 @@
#include "list_ext.h"
-void LIST_Append(t_List *p_NewList, t_List *p_Head)
+void NCSW_LIST_Append(t_List *p_NewList, t_List *p_Head)
{
t_List *p_First = NCSW_LIST_FIRST(p_NewList);
if (p_First != p_NewList)
{
- t_List *p_Last = LIST_LAST(p_NewList);
+ t_List *p_Last = NCSW_LIST_LAST(p_NewList);
t_List *p_Cur = NCSW_LIST_NEXT(p_Head);
NCSW_LIST_PREV(p_First) = p_Head;
NCSW_LIST_FIRST(p_Head) = p_First;
NCSW_LIST_NEXT(p_Last) = p_Cur;
- LIST_LAST(p_Cur) = p_Last;
+ NCSW_LIST_LAST(p_Cur) = p_Last;
}
}
-int LIST_NumOfObjs(t_List *p_List)
+int NCSW_LIST_NumOfObjs(t_List *p_List)
{
t_List *p_Tmp;
int numOfObjs = 0;
- if (!LIST_IsEmpty(p_List))
- LIST_FOR_EACH(p_Tmp, p_List)
+ if (!NCSW_LIST_IsEmpty(p_List))
+ NCSW_LIST_FOR_EACH(p_Tmp, p_List)
numOfObjs++;
return numOfObjs;
diff --git a/sys/contrib/ncsw/etc/memcpy.c b/sys/contrib/ncsw/etc/memcpy.c
index 1ed8daeafd52..fa203ec7cebf 100644
--- a/sys/contrib/ncsw/etc/memcpy.c
+++ b/sys/contrib/ncsw/etc/memcpy.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -31,75 +31,30 @@
*/
+
#include "std_ext.h"
#include "xx_ext.h"
#include "memcpy_ext.h"
-
-#ifdef CORE_8BIT_ACCESS_ERRATA
-static void MY_MY_WRITE_UINT8(uint8_t *addr, uint8_t val)
+void * MemCpy8(void* pDst, void* pSrc, uint32_t size)
{
- uint32_t newAddr, newVal;
- newAddr = (uint32_t)addr & ~0x3L;
- switch ((uint32_t)addr%4)
- {
- case (0):
- newVal = GET_UINT32(*(uint32_t*)newAddr);
- newVal = (newVal & 0x00ffffff) | (((uint32_t)val)<<24);
- WRITE_UINT32(*(uint32_t*)newAddr, newVal);
- break;
- case (1):
- newVal = GET_UINT32(*(uint32_t*)newAddr);
- newVal = (newVal & 0xff00ffff) | (((uint32_t)val)<<16);
- WRITE_UINT32(*(uint32_t*)newAddr, newVal);
- break;
- case (2):
- newVal = GET_UINT32(*(uint32_t*)newAddr);
- newVal = (newVal & 0xffff00ff) | (((uint32_t)val)<<8);
- WRITE_UINT32(*(uint32_t*)newAddr, newVal);
- break;
- case (3):
- newVal = GET_UINT32(*(uint32_t*)newAddr);
- newVal = (newVal & 0xffffff00) | val;
- WRITE_UINT32(*(uint32_t*)newAddr, newVal);
- break;
- }
+ int i;
+
+ for(i = 0; i < size; ++i)
+ *(((uint8_t*)(pDst)) + i) = *(((uint8_t*)(pSrc)) + i);
+
+ return pDst;
}
-static uint8_t MY_MY_GET_UINT8(uint8_t *addr)
+void * MemSet8(void* pDst, int c, uint32_t size)
{
- uint32_t newAddr, newVal=0;
- newAddr = (uint32_t)addr & ~0x3L;
- switch ((uint32_t)addr%4)
- {
- case (0):
- newVal = GET_UINT32(*(uint32_t*)newAddr);
- newVal = (newVal & 0xff000000)>>24;
- break;
- case (1):
- newVal = GET_UINT32(*(uint32_t*)newAddr);
- newVal = (newVal & 0x00ff0000)>>16;
- break;
- case (2):
- newVal = GET_UINT32(*(uint32_t*)newAddr);
- newVal = (newVal & 0x0000ff00)>>8;
- break;
- case (3):
- newVal = GET_UINT32(*(uint32_t*)newAddr);
- newVal = (newVal & 0x000000ff);
- break;
- }
-
- return (uint8_t)newVal;
-}
+ int i;
-#define MY_WRITE_UINT8(addr,val) MY_MY_WRITE_UINT8(&addr,val)
-#define MY_GET_UINT8(addr) MY_MY_GET_UINT8(&addr)
-#else
-#define MY_WRITE_UINT8 WRITE_UINT8
-#define MY_GET_UINT8 GET_UINT8
-#endif /* CORE_8BIT_ACCESS_ERRATA */
+ for(i = 0; i < size; ++i)
+ *(((uint8_t*)(pDst)) + i) = (uint8_t)(c);
+ return pDst;
+}
void * MemCpy32(void* pDst,void* pSrc, uint32_t size)
{
@@ -194,7 +149,7 @@ void * IO2IOCpy32(void* pDst,void* pSrc, uint32_t size)
*/
while((PTR_TO_UINT(p_Src8) & 3) && size) /* (pSrc mod 4) > 0 and size > 0 */
{
- MY_WRITE_UINT8(*p_Dst8, MY_GET_UINT8(*p_Src8));
+ WRITE_UINT8(*p_Dst8, GET_UINT8(*p_Src8));
p_Dst8++;p_Src8++;
size--;
}
@@ -202,7 +157,7 @@ void * IO2IOCpy32(void* pDst,void* pSrc, uint32_t size)
/* align destination (possibly disaligning source)*/
while((PTR_TO_UINT(p_Dst8) & 3) && size) /* (pDst mod 4) > 0 and size > 0 */
{
- MY_WRITE_UINT8(*p_Dst8, MY_GET_UINT8(*p_Src8));
+ WRITE_UINT8(*p_Dst8, GET_UINT8(*p_Src8));
p_Dst8++;p_Src8++;
size--;
}
@@ -247,7 +202,7 @@ void * IO2IOCpy32(void* pDst,void* pSrc, uint32_t size)
/* complete the left overs */
while (size--)
{
- MY_WRITE_UINT8(*p_Dst8, MY_GET_UINT8(*p_Src8));
+ WRITE_UINT8(*p_Dst8, GET_UINT8(*p_Src8));
p_Dst8++;p_Src8++;
}
@@ -273,7 +228,7 @@ void * Mem2IOCpy32(void* pDst,void* pSrc, uint32_t size)
*/
while((PTR_TO_UINT(p_Src8) & 3) && size) /* (pSrc mod 4) > 0 and size > 0 */
{
- MY_WRITE_UINT8(*p_Dst8, *p_Src8);
+ WRITE_UINT8(*p_Dst8, *p_Src8);
p_Dst8++;p_Src8++;
size--;
}
@@ -281,7 +236,7 @@ void * Mem2IOCpy32(void* pDst,void* pSrc, uint32_t size)
/* align destination (possibly disaligning source)*/
while((PTR_TO_UINT(p_Dst8) & 3) && size) /* (pDst mod 4) > 0 and size > 0 */
{
- MY_WRITE_UINT8(*p_Dst8, *p_Src8);
+ WRITE_UINT8(*p_Dst8, *p_Src8);
p_Dst8++;p_Src8++;
size--;
}
@@ -325,7 +280,7 @@ void * Mem2IOCpy32(void* pDst,void* pSrc, uint32_t size)
/* complete the left overs */
while (size--)
{
- MY_WRITE_UINT8(*p_Dst8, *p_Src8);
+ WRITE_UINT8(*p_Dst8, *p_Src8);
p_Dst8++;p_Src8++;
}
@@ -351,7 +306,7 @@ void * IO2MemCpy32(void* pDst,void* pSrc, uint32_t size)
*/
while((PTR_TO_UINT(p_Src8) & 3) && size) /* (pSrc mod 4) > 0 and size > 0 */
{
- *p_Dst8 = MY_GET_UINT8(*p_Src8);
+ *p_Dst8 = GET_UINT8(*p_Src8);
p_Dst8++;p_Src8++;
size--;
}
@@ -359,7 +314,7 @@ void * IO2MemCpy32(void* pDst,void* pSrc, uint32_t size)
/* align destination (possibly disaligning source)*/
while((PTR_TO_UINT(p_Dst8) & 3) && size) /* (pDst mod 4) > 0 and size > 0 */
{
- *p_Dst8 = MY_GET_UINT8(*p_Src8);
+ *p_Dst8 = GET_UINT8(*p_Src8);
p_Dst8++;p_Src8++;
size--;
}
@@ -404,7 +359,7 @@ void * IO2MemCpy32(void* pDst,void* pSrc, uint32_t size)
/* complete the left overs */
while (size--)
{
- *p_Dst8 = MY_GET_UINT8(*p_Src8);
+ *p_Dst8 = GET_UINT8(*p_Src8);
p_Dst8++;p_Src8++;
}
@@ -537,7 +492,7 @@ void * IOMemSet32(void* pDst, uint8_t val, uint32_t size)
/* align destination to 32 */
while((PTR_TO_UINT(p_Dst8) & 3) && size) /* (pDst mod 4) > 0 and size > 0 */
{
- MY_WRITE_UINT8(*p_Dst8, val);
+ WRITE_UINT8(*p_Dst8, val);
p_Dst8++;
size--;
}
@@ -555,7 +510,7 @@ void * IOMemSet32(void* pDst, uint8_t val, uint32_t size)
p_Dst8 = (uint8_t*)(p_Dst32);
while (size--)
{
- MY_WRITE_UINT8(*p_Dst8, val);
+ WRITE_UINT8(*p_Dst8, val);
p_Dst8++;
}
diff --git a/sys/contrib/ncsw/etc/mm.c b/sys/contrib/ncsw/etc/mm.c
index 2a8e338cb52e..9fcc46e0b26b 100644
--- a/sys/contrib/ncsw/etc/mm.c
+++ b/sys/contrib/ncsw/etc/mm.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,10 +30,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#include "string_ext.h"
#include "error_ext.h"
#include "std_ext.h"
-#include "sprint_ext.h"
#include "part_ext.h"
#include "xx_ext.h"
@@ -246,6 +246,7 @@ static t_Error AddFree(t_MM *p_MM, uint64_t base, uint64_t end)
else
p_MM->freeBlocks[i] = p_CurrB->p_Next;
XX_Free(p_CurrB);
+ p_CurrB = NULL;
}
break;
}
@@ -575,7 +576,10 @@ static uint64_t MmGetGreaterAlignment(t_MM *p_MM, uint64_t size, uint64_t alignm
/* calls Update routine to update a lists of free blocks */
if ( CutFree ( p_MM, holdBase, holdEnd ) != E_OK )
+ {
+ XX_Free(p_NewBusyB);
return (uint64_t)(ILLEGAL_BASE);
+ }
/* insert the new busy block into the list of busy blocks */
AddBusy ( p_MM, p_NewBusyB );
@@ -614,21 +618,30 @@ t_Error MM_Init(t_Handle *h_MM, uint64_t base, uint64_t size)
RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MM spinlock!"));
}
- /* initializes a new memory block */
- if ((p_MM->memBlocks = CreateNewBlock(base, size)) == NULL)
- RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
+ /* Initializes counter of free memory to total size */
+ p_MM->freeMemSize = size;
/* A busy list is empty */
p_MM->busyBlocks = 0;
- /*Initializes a new free block for each free list*/
+ /* Initializes a new memory block */
+ if ((p_MM->memBlocks = CreateNewBlock(base, size)) == NULL)
+ {
+ MM_Free(p_MM);
+ RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
+ }
+
+ /* Initializes a new free block for each free list*/
for (i=0; i <= MM_MAX_ALIGNMENT; i++)
{
newBase = MAKE_ALIGNED( base, (0x1 << i) );
newSize = size - (newBase - base);
if ((p_MM->freeBlocks[i] = CreateFreeBlock(newBase, newSize)) == NULL)
+ {
+ MM_Free(p_MM);
RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);
+ }
}
*h_MM = p_MM;
@@ -751,9 +764,13 @@ uint64_t MM_Get(t_Handle h_MM, uint64_t size, uint64_t alignment, char* name)
if ( CutFree ( p_MM, holdBase, holdEnd ) != E_OK )
{
XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
+ XX_Free(p_NewBusyB);
return (uint64_t)(ILLEGAL_BASE);
}
+ /* Decreasing the allocated memory size from free memory size */
+ p_MM->freeMemSize -= size;
+
/* insert the new busy block into the list of busy blocks */
AddBusy ( p_MM, p_NewBusyB );
XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
@@ -804,9 +821,13 @@ uint64_t MM_GetForce(t_Handle h_MM, uint64_t base, uint64_t size, char* name)
if ( CutFree ( p_MM, base, base+size ) != E_OK )
{
XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
+ XX_Free(p_NewBusyB);
return (uint64_t)(ILLEGAL_BASE);
}
+ /* Decreasing the allocated memory size from free memory size */
+ p_MM->freeMemSize -= size;
+
/* insert the new busy block into the list of busy blocks */
AddBusy ( p_MM, p_NewBusyB );
XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
@@ -889,9 +910,13 @@ uint64_t MM_GetForceMin(t_Handle h_MM, uint64_t size, uint64_t alignment, uint64
if ( CutFree( p_MM, holdBase, holdEnd ) != E_OK )
{
XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
+ XX_Free(p_NewBusyB);
return (uint64_t)(ILLEGAL_BASE);
}
+ /* Decreasing the allocated memory size from free memory size */
+ p_MM->freeMemSize -= size;
+
/* insert the new busy block into the list of busy blocks */
AddBusy( p_MM, p_NewBusyB );
XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
@@ -942,6 +967,9 @@ uint64_t MM_Put(t_Handle h_MM, uint64_t base)
size = p_BusyB->end - p_BusyB->base;
+ /* Adding the deallocated memory size to free memory size */
+ p_MM->freeMemSize += size;
+
XX_Free(p_BusyB);
XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
@@ -958,6 +986,7 @@ uint64_t MM_PutForce(t_Handle h_MM, uint64_t base, uint64_t size)
ASSERT_COND(p_MM);
intFlags = XX_LockIntrSpinlock(p_MM->h_Spinlock);
+
if ( CutBusy( p_MM, base, end ) != E_OK )
{
XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
@@ -969,6 +998,10 @@ uint64_t MM_PutForce(t_Handle h_MM, uint64_t base, uint64_t size)
XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
return (uint64_t)(0);
}
+
+ /* Adding the deallocated memory size to free memory size */
+ p_MM->freeMemSize += size;
+
XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
return (size);
@@ -988,6 +1021,7 @@ t_Error MM_Add(t_Handle h_MM, uint64_t base, uint64_t size)
* memory block
*/
intFlags = XX_LockIntrSpinlock(p_MM->h_Spinlock);
+
p_MemB = p_MM->memBlocks;
while ( p_MemB->p_Next )
{
@@ -1024,6 +1058,10 @@ t_Error MM_Add(t_Handle h_MM, uint64_t base, uint64_t size)
XX_Free(p_NewMemB);
return ((t_Error)errCode);
}
+
+ /* Adding the new block size to free memory size */
+ p_MM->freeMemSize += size;
+
XX_UnlockIntrSpinlock(p_MM->h_Spinlock, intFlags);
return (E_OK);
@@ -1077,7 +1115,17 @@ bool MM_InRange(t_Handle h_MM, uint64_t addr)
}
/*****************************************************************************/
-void MM_Dump(t_Handle h_MM, void *buff)
+uint64_t MM_GetFreeMemSize(t_Handle h_MM)
+{
+ t_MM *p_MM = (t_MM*)h_MM;
+
+ ASSERT_COND(p_MM);
+
+ return p_MM->freeMemSize;
+}
+
+/*****************************************************************************/
+void MM_Dump(t_Handle h_MM)
{
t_MM *p_MM = (t_MM *)h_MM;
t_FreeBlock *p_FreeB;
@@ -1085,25 +1133,23 @@ void MM_Dump(t_Handle h_MM, void *buff)
int i;
p_BusyB = p_MM->busyBlocks;
- Sprint(buff, "List of busy blocks:\n");
+ XX_Print("List of busy blocks:\n");
while (p_BusyB)
{
- Sprint(buff, "\t0x%p: (%s: b=0x%lx, e=0x%lx)\n",
- p_BusyB, p_BusyB->name, p_BusyB->base, p_BusyB->end );
+ XX_Print("\t0x%p: (%s: b=0x%llx, e=0x%llx)\n", p_BusyB, p_BusyB->name, p_BusyB->base, p_BusyB->end );
p_BusyB = p_BusyB->p_Next;
}
- Sprint(buff, "\nLists of free blocks according to alignment:\n");
+ XX_Print("\nLists of free blocks according to alignment:\n");
for (i=0; i <= MM_MAX_ALIGNMENT; i++)
{
- Sprint(buff, "%d alignment:\n", (0x1 << i));
+ XX_Print("%d alignment:\n", (0x1 << i));
p_FreeB = p_MM->freeBlocks[i];
while (p_FreeB)
{
- Sprint(buff, "\t0x%p: (b=0x%lx, e=0x%lx)\n",
- p_FreeB, p_FreeB->base, p_FreeB->end);
+ XX_Print("\t0x%p: (b=0x%llx, e=0x%llx)\n", p_FreeB, p_FreeB->base, p_FreeB->end);
p_FreeB = p_FreeB->p_Next;
}
- Sprint(buff, "\n");
+ XX_Print("\n");
}
}
diff --git a/sys/contrib/ncsw/etc/mm.h b/sys/contrib/ncsw/etc/mm.h
index 509f6141ab08..43b2298fce5d 100644
--- a/sys/contrib/ncsw/etc/mm.h
+++ b/sys/contrib/ncsw/etc/mm.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/****************************************************************
*
* File: mm.h
@@ -55,7 +56,7 @@
(((uint64_t)(addr) + ((align) - 1)) & (~(((uint64_t)align) - 1)))
-/* t_MemBlock data stucutre defines parameters of the Memory Block */
+/* t_MemBlock data structure defines parameters of the Memory Block */
typedef struct t_MemBlock
{
struct t_MemBlock *p_Next; /* Pointer to the next memory block */
@@ -65,7 +66,7 @@ typedef struct t_MemBlock
} t_MemBlock;
-/* t_FreeBlock data stucutre defines parameters of the Free Block */
+/* t_FreeBlock data structure defines parameters of the Free Block */
typedef struct t_FreeBlock
{
struct t_FreeBlock *p_Next; /* Pointer to the next free block */
@@ -75,7 +76,7 @@ typedef struct t_FreeBlock
} t_FreeBlock;
-/* t_BusyBlock data stucutre defines parameters of the Busy Block */
+/* t_BusyBlock data structure defines parameters of the Busy Block */
typedef struct t_BusyBlock
{
struct t_BusyBlock *p_Next; /* Pointer to the next free block */
@@ -90,11 +91,14 @@ typedef struct t_BusyBlock
/* t_MM data structure defines parameters of the MM object */
typedef struct t_MM
{
+ t_Handle h_Spinlock;
+
t_MemBlock *memBlocks; /* List of memory blocks (Memory list) */
t_BusyBlock *busyBlocks; /* List of busy blocks (Busy list) */
t_FreeBlock *freeBlocks[MM_MAX_ALIGNMENT + 1];
/* Alignment lists of free blocks (Free lists) */
- t_Handle h_Spinlock;
+
+ uint64_t freeMemSize; /* Total size of free memory (in bytes) */
} t_MM;
diff --git a/sys/contrib/ncsw/etc/ncsw_mem.c b/sys/contrib/ncsw/etc/ncsw_mem.c
index f82f0f4af2bc..bc21390a3288 100644
--- a/sys/contrib/ncsw/etc/ncsw_mem.c
+++ b/sys/contrib/ncsw/etc/ncsw_mem.c
@@ -42,6 +42,7 @@
#include "xx_ext.h"
+#if 0
#define PAD_ALIGNMENT(align, x) (((x)%(align)) ? ((align)-((x)%(align))) : 0)
#define ALIGN_BLOCK(p_Block, prefixSize, alignment) \
@@ -761,3 +762,4 @@ void MEM_CheckLeaks(t_Handle h_Mem)
#endif /* DEBUG_MEM_LEAKS */
+#endif
diff --git a/sys/contrib/ncsw/inc/Peripherals/bm_ext.h b/sys/contrib/ncsw/inc/Peripherals/bm_ext.h
index 140cf58831d3..952e95f62e47 100644
--- a/sys/contrib/ncsw/inc/Peripherals/bm_ext.h
+++ b/sys/contrib/ncsw/inc/Peripherals/bm_ext.h
@@ -322,7 +322,7 @@ typedef struct {
uintptr_t ciBaseAddress; /**< Cache-inhibited base address (virtual) */
t_Handle h_Bm; /**< Bm Handle */
e_DpaaSwPortal swPortalId; /**< Portal id */
- int irq; /**< portal interrupt line; NO_IRQ if interrupts not used */
+ uintptr_t irq; /**< portal interrupt line; NO_IRQ if interrupts not used */
} t_BmPortalParam;
@@ -594,30 +594,6 @@ uint16_t BM_POOL_GetBufferSize(t_Handle h_BmPool);
t_Handle BM_POOL_GetBufferContext(t_Handle h_BmPool, void *p_Buff);
/**************************************************************************//**
- @Function BM_POOL_PhysToVirt
-
- @Description Translates a physical address to the matching virtual address.
-
- @Param[in] h_BmPool - A handle to a BM-pool
- @Param[in] addr - The physical address to translate
-
- @Return Virtual address.
-*//***************************************************************************/
-void * BM_POOL_PhysToVirt(t_Handle h_BmPool, physAddress_t addr);
-
-/**************************************************************************//**
- @Function BM_POOL_VirtToPhys
-
- @Description Translates a virtual address to the matching physical address.
-
- @Param[in] h_BmPool - A handle to a BM-pool
- @Param[in] addr - The virtual address to translate
-
- @Return Physical address.
-*//***************************************************************************/
-physAddress_t BM_POOL_VirtToPhys(t_Handle h_BmPool, void *addr);
-
-/**************************************************************************//**
@Function BM_POOL_GetCounter
@Description Reads one of the BM Pool counters.
diff --git a/sys/contrib/ncsw/inc/Peripherals/crc_mac_addr_ext.h b/sys/contrib/ncsw/inc/Peripherals/crc_mac_addr_ext.h
index 5990f7195a63..a84d563116c6 100644
--- a/sys/contrib/ncsw/inc/Peripherals/crc_mac_addr_ext.h
+++ b/sys/contrib/ncsw/inc/Peripherals/crc_mac_addr_ext.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/*------------------------------------------------------*/
/* */
/* File: crc_mac_addr_ext.h */
diff --git a/sys/contrib/ncsw/inc/Peripherals/dpaa_ext.h b/sys/contrib/ncsw/inc/Peripherals/dpaa_ext.h
index 282f41591169..ec0a03a877a0 100644
--- a/sys/contrib/ncsw/inc/Peripherals/dpaa_ext.h
+++ b/sys/contrib/ncsw/inc/Peripherals/dpaa_ext.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
+/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,7 +30,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/******************************************************************************
+
+/**************************************************************************//**
@File dpaa_ext.h
@Description DPAA Application Programming Interface.
@@ -53,14 +54,29 @@
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(push,1)
#endif /* defined(__MWERKS__) && ... */
-#define MEM_MAP_START
+
+#include <machine/endian.h>
+
+#define __BYTE_ORDER__ BYTE_ORDER
+#define __ORDER_BIG_ENDIAN__ BIG_ENDIAN
/**************************************************************************//**
@Description Frame descriptor
*//***************************************************************************/
typedef _Packed struct t_DpaaFD {
- volatile uint32_t id; /**< FD id */
- volatile uint32_t addrl; /**< Data Address */
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ volatile uint8_t liodn;
+ volatile uint8_t bpid;
+ volatile uint8_t elion;
+ volatile uint8_t addrh;
+ volatile uint32_t addrl;
+#else
+ volatile uint32_t addrl;
+ volatile uint8_t addrh;
+ volatile uint8_t elion;
+ volatile uint8_t bpid;
+ volatile uint8_t liodn;
+ #endif
volatile uint32_t length; /**< Frame length */
volatile uint32_t status; /**< FD status */
} _PackedType t_DpaaFD;
@@ -95,25 +111,17 @@ typedef enum e_DpaaFDFormatType {
#define DPAA_FD_OFFSET_MASK 0x1ff00000 /**< FD OFFSET field mask */
#define DPAA_FD_LENGTH_MASK 0x000fffff /**< FD LENGTH field mask */
-#define DPAA_FD_GET_DD(fd) ((((t_DpaaFD *)fd)->id & DPAA_FD_DD_MASK) >> (31-1)) /**< Macro to get FD DD field */
-#define DPAA_FD_GET_PID(fd) (((((t_DpaaFD *)fd)->id & DPAA_FD_PID_MASK) >> (31-7)) | \
- ((((t_DpaaFD *)fd)->id & DPAA_FD_ELIODN_MASK) >> (31-19-6))) /**< Macro to get FD PID field */
-#define DPAA_FD_GET_BPID(fd) ((((t_DpaaFD *)fd)->id & DPAA_FD_BPID_MASK) >> (31-15)) /**< Macro to get FD BPID field */
-#define DPAA_FD_GET_ADDRH(fd) (((t_DpaaFD *)fd)->id & DPAA_FD_ADDRH_MASK) /**< Macro to get FD ADDRH field */
+#define DPAA_FD_GET_ADDRH(fd) ((t_DpaaFD *)fd)->addrh /**< Macro to get FD ADDRH field */
#define DPAA_FD_GET_ADDRL(fd) ((t_DpaaFD *)fd)->addrl /**< Macro to get FD ADDRL field */
#define DPAA_FD_GET_PHYS_ADDR(fd) ((physAddress_t)(((uint64_t)DPAA_FD_GET_ADDRH(fd) << 32) | (uint64_t)DPAA_FD_GET_ADDRL(fd))) /**< Macro to get FD ADDR field */
#define DPAA_FD_GET_FORMAT(fd) ((((t_DpaaFD *)fd)->length & DPAA_FD_FORMAT_MASK) >> (31-2)) /**< Macro to get FD FORMAT field */
#define DPAA_FD_GET_OFFSET(fd) ((((t_DpaaFD *)fd)->length & DPAA_FD_OFFSET_MASK) >> (31-11)) /**< Macro to get FD OFFSET field */
#define DPAA_FD_GET_LENGTH(fd) (((t_DpaaFD *)fd)->length & DPAA_FD_LENGTH_MASK) /**< Macro to get FD LENGTH field */
#define DPAA_FD_GET_STATUS(fd) ((t_DpaaFD *)fd)->status /**< Macro to get FD STATUS field */
-#define DPAA_FD_GET_ADDR(fd) XX_PhysToVirt(DPAA_FD_GET_PHYS_ADDR(fd))
-
-#define DPAA_FD_SET_DD(fd,val) (((t_DpaaFD *)fd)->id = ((((t_DpaaFD *)fd)->id & ~DPAA_FD_DD_MASK) | (((val) << (31-1)) & DPAA_FD_DD_MASK ))) /**< Macro to set FD DD field */
- /**< Macro to set FD PID field or LIODN offset*/
-#define DPAA_FD_SET_PID(fd,val) (((t_DpaaFD *)fd)->id = ((((t_DpaaFD *)fd)->id & ~(DPAA_FD_PID_MASK|DPAA_FD_ELIODN_MASK)) | ((((val) << (31-7)) & DPAA_FD_PID_MASK) | ((((val)>>6) << (31-19)) & DPAA_FD_ELIODN_MASK))))
-#define DPAA_FD_SET_BPID(fd,val) (((t_DpaaFD *)fd)->id = ((((t_DpaaFD *)fd)->id & ~DPAA_FD_BPID_MASK) | (((val) << (31-15)) & DPAA_FD_BPID_MASK))) /**< Macro to set FD BPID field */
-#define DPAA_FD_SET_ADDRH(fd,val) (((t_DpaaFD *)fd)->id = ((((t_DpaaFD *)fd)->id & ~DPAA_FD_ADDRH_MASK) | ((val) & DPAA_FD_ADDRH_MASK))) /**< Macro to set FD ADDRH field */
-#define DPAA_FD_SET_ADDRL(fd,val) ((t_DpaaFD *)fd)->addrl = (val) /**< Macro to set FD ADDRL field */
+#define DPAA_FD_GET_ADDR(fd) XX_PhysToVirt(DPAA_FD_GET_PHYS_ADDR(fd)) /**< Macro to get FD ADDR (virtual) */
+
+#define DPAA_FD_SET_ADDRH(fd,val) ((t_DpaaFD *)fd)->addrh = (val) /**< Macro to set FD ADDRH field */
+#define DPAA_FD_SET_ADDRL(fd,val) ((t_DpaaFD *)fd)->addrl = (val) /**< Macro to set FD ADDRL field */
#define DPAA_FD_SET_ADDR(fd,val) \
do { \
uint64_t physAddr = (uint64_t)(XX_VirtToPhys(val)); \
@@ -123,7 +131,7 @@ do { \
#define DPAA_FD_SET_FORMAT(fd,val) (((t_DpaaFD *)fd)->length = ((((t_DpaaFD *)fd)->length & ~DPAA_FD_FORMAT_MASK) | (((val) << (31-2))& DPAA_FD_FORMAT_MASK))) /**< Macro to set FD FORMAT field */
#define DPAA_FD_SET_OFFSET(fd,val) (((t_DpaaFD *)fd)->length = ((((t_DpaaFD *)fd)->length & ~DPAA_FD_OFFSET_MASK) | (((val) << (31-11))& DPAA_FD_OFFSET_MASK) )) /**< Macro to set FD OFFSET field */
#define DPAA_FD_SET_LENGTH(fd,val) (((t_DpaaFD *)fd)->length = (((t_DpaaFD *)fd)->length & ~DPAA_FD_LENGTH_MASK) | ((val) & DPAA_FD_LENGTH_MASK)) /**< Macro to set FD LENGTH field */
-#define DPAA_FD_SET_STATUS(fd,val) ((t_DpaaFD *)fd)->status = (val) /**< Macro to set FD STATUS field */
+#define DPAA_FD_SET_STATUS(fd,val) ((t_DpaaFD *)fd)->status = (val) /**< Macro to set FD STATUS field */
/* @} */
/**************************************************************************//**
@@ -143,7 +151,7 @@ typedef _Packed struct t_DpaaSGTE {
*//***************************************************************************/
typedef _Packed struct t_DpaaSGT {
t_DpaaSGTE tableEntry[DPAA_NUM_OF_SG_TABLE_ENTRY];
- /**< structure that hold the information about
+ /**< Structure that holds information about
a single S/G entry. */
} _PackedType t_DpaaSGT;
@@ -151,10 +159,10 @@ typedef _Packed struct t_DpaaSGT {
@Description Compound Frame Table
*//***************************************************************************/
typedef _Packed struct t_DpaaCompTbl {
- t_DpaaSGTE outputBuffInfo; /**< structure that holds the information about
+ t_DpaaSGTE outputBuffInfo; /**< Structure that holds information about
the compound-frame output buffer;
NOTE: this may point to a S/G table */
- t_DpaaSGTE inputBuffInfo; /**< structure that holds the information about
+ t_DpaaSGTE inputBuffInfo; /**< Structure that holds information about
the compound-frame input buffer;
NOTE: this may point to a S/G table */
} _PackedType t_DpaaCompTbl;
@@ -195,11 +203,12 @@ do { \
#define DPAA_SGTE_SET_OFFSET(sgte,val) (((t_DpaaSGTE *)sgte)->offset = ((((t_DpaaSGTE *)sgte)->offset & ~DPAA_SGTE_OFFSET_MASK) | (((val) << (31-31))& DPAA_SGTE_OFFSET_MASK) )) /**< Macro to set SGTE OFFSET field */
/* @} */
-#define MEM_MAP_END
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(pop)
#endif /* defined(__MWERKS__) && ... */
+#define DPAA_LIODN_DONT_OVERRIDE (-1)
+
/** @} */ /* end of DPAA_grp group */
diff --git a/sys/contrib/ncsw/inc/Peripherals/fm_ext.h b/sys/contrib/ncsw/inc/Peripherals/fm_ext.h
index a3f56f885bc1..c3633592694c 100644
--- a/sys/contrib/ncsw/inc/Peripherals/fm_ext.h
+++ b/sys/contrib/ncsw/inc/Peripherals/fm_ext.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
+/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File fm_ext.h
@@ -41,7 +42,7 @@
#include "error_ext.h"
#include "std_ext.h"
#include "dpaa_ext.h"
-
+#include "fsl_fman_sp.h"
/**************************************************************************//**
@Group FM_grp Frame Manager API
@@ -54,31 +55,29 @@
/**************************************************************************//**
@Group FM_lib_grp FM library
- @Description FM API functions, definitions and enums
+ @Description FM API functions, definitions and enums.
+
The FM module is the main driver module and is a mandatory module
- for FM driver users. Before any further module initialization,
- this module must be initialized.
- The FM is a "singletone" module. It is responsible of the common
- HW modules: FPM, DMA, common QMI, common BMI initializations and
+ for FM driver users. This module must be initialized first prior
+ to any other drivers modules.
+ The FM is a "singleton" module. It is responsible of the common
+ HW modules: FPM, DMA, common QMI and common BMI initializations and
run-time control routines. This module must be initialized always
when working with any of the FM modules.
- NOTE - We assumes that the FML will be initialize only by core No. 0!
+ NOTE - We assume that the FM library will be initialized only by core No. 0!
@{
*//***************************************************************************/
/**************************************************************************//**
- @Description enum for defining port types
+ @Description Enum for defining port types
*//***************************************************************************/
typedef enum e_FmPortType {
- e_FM_PORT_TYPE_OH_OFFLINE_PARSING = 0, /**< Offline parsing port (id's: 0-6, share id's with
- host command, so must have exclusive id) */
- e_FM_PORT_TYPE_OH_HOST_COMMAND, /**< Host command port (id's: 0-6, share id's with
- offline parsing ports, so must have exclusive id) */
- e_FM_PORT_TYPE_RX, /**< 1G Rx port (id's: 0-3) */
- e_FM_PORT_TYPE_RX_10G, /**< 10G Rx port (id's: 0) */
- e_FM_PORT_TYPE_TX, /**< 1G Tx port (id's: 0-3) */
- e_FM_PORT_TYPE_TX_10G, /**< 10G Tx port (id's: 0) */
+ e_FM_PORT_TYPE_OH_OFFLINE_PARSING = 0, /**< Offline parsing port */
+ e_FM_PORT_TYPE_RX, /**< 1G Rx port */
+ e_FM_PORT_TYPE_RX_10G, /**< 10G Rx port */
+ e_FM_PORT_TYPE_TX, /**< 1G Tx port */
+ e_FM_PORT_TYPE_TX_10G, /**< 10G Tx port */
e_FM_PORT_TYPE_DUMMY
} e_FmPortType;
@@ -93,7 +92,6 @@ typedef enum e_FmPortType {
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(push,1)
#endif /* defined(__MWERKS__) && ... */
-#define MEM_MAP_START
/**************************************************************************//**
@Description FM physical Address
@@ -114,9 +112,12 @@ typedef _Packed struct t_FmPrsResult {
volatile uint8_t l4r; /**< Layer 4 result */
volatile uint8_t cplan; /**< Classification plan id */
volatile uint16_t nxthdr; /**< Next Header */
- volatile uint16_t cksum; /**< Checksum */
- volatile uint32_t lcv; /**< LCV */
- volatile uint8_t shim_off[3]; /**< Shim offset */
+ volatile uint16_t cksum; /**< Running-sum */
+ volatile uint16_t flags_frag_off; /**< Flags & fragment-offset field of the last IP-header */
+ volatile uint8_t route_type; /**< Routing type field of a IPv6 routing extension header */
+ volatile uint8_t rhp_ip_valid; /**< Routing Extension Header Present; last bit is IP valid */
+ volatile uint8_t shim_off[2]; /**< Shim offset */
+ volatile uint8_t ip_pid_off; /**< IP PID (last IP-proto) offset */
volatile uint8_t eth_off; /**< ETH offset */
volatile uint8_t llc_snap_off; /**< LLC_SNAP offset */
volatile uint8_t vlan_off[2]; /**< VLAN offset */
@@ -143,15 +144,71 @@ typedef _Packed struct t_FmPrsResult {
/**************************************************************************//**
@Collection FM Frame descriptor macros
*//***************************************************************************/
-#define FM_FD_CMD_FCO 0x80000000 /**< Frame queue Context Override */
-#define FM_FD_CMD_RPD 0x40000000 /**< Read Prepended Data */
-#define FM_FD_CMD_UPD 0x20000000 /**< Update Prepended Data */
-#define FM_FD_CMD_DTC 0x10000000 /**< Do L4 Checksum */
-#define FM_FD_CMD_DCL4C 0x10000000 /**< Didn't calculate L4 Checksum */
-#define FM_FD_CMD_CFQ 0x00ffffff /**< Confirmation Frame Queue */
-
-#define FM_FD_TX_STATUS_ERR_MASK 0x07000000 /**< TX Error FD bits */
-#define FM_FD_RX_STATUS_ERR_MASK 0x070ee3f8 /**< RX Error FD bits */
+#define FM_FD_CMD_FCO 0x80000000 /**< Frame queue Context Override */
+#define FM_FD_CMD_RPD 0x40000000 /**< Read Prepended Data */
+#define FM_FD_CMD_UPD 0x20000000 /**< Update Prepended Data */
+#define FM_FD_CMD_DTC 0x10000000 /**< Do L4 Checksum */
+#define FM_FD_CMD_DCL4C 0x10000000 /**< Didn't calculate L4 Checksum */
+#define FM_FD_CMD_CFQ 0x00ffffff /**< Confirmation Frame Queue */
+
+#define FM_FD_ERR_UNSUPPORTED_FORMAT 0x04000000 /**< Not for Rx-Port! Unsupported Format */
+#define FM_FD_ERR_LENGTH 0x02000000 /**< Not for Rx-Port! Length Error */
+#define FM_FD_ERR_DMA 0x01000000 /**< DMA Data error */
+
+#define FM_FD_IPR 0x00000001 /**< IPR frame (not error) */
+
+#define FM_FD_ERR_IPR_NCSP (0x00100000 | FM_FD_IPR) /**< IPR non-consistent-sp */
+#define FM_FD_ERR_IPR (0x00200000 | FM_FD_IPR) /**< IPR error */
+#define FM_FD_ERR_IPR_TO (0x00300000 | FM_FD_IPR) /**< IPR timeout */
+
+#ifdef FM_CAPWAP_SUPPORT
+#define FM_FD_ERR_CRE 0x00200000
+#define FM_FD_ERR_CHE 0x00100000
+#endif /* FM_CAPWAP_SUPPORT */
+
+#define FM_FD_ERR_PHYSICAL 0x00080000 /**< Rx FIFO overflow, FCS error, code error, running disparity
+ error (SGMII and TBI modes), FIFO parity error. PHY
+ Sequence error, PHY error control character detected. */
+#define FM_FD_ERR_SIZE 0x00040000 /**< Frame too long OR Frame size exceeds max_length_frame */
+#define FM_FD_ERR_CLS_DISCARD 0x00020000 /**< classification discard */
+#define FM_FD_ERR_EXTRACTION 0x00008000 /**< Extract Out of Frame */
+#define FM_FD_ERR_NO_SCHEME 0x00004000 /**< No Scheme Selected */
+#define FM_FD_ERR_KEYSIZE_OVERFLOW 0x00002000 /**< Keysize Overflow */
+#define FM_FD_ERR_COLOR_RED 0x00000800 /**< Frame color is red */
+#define FM_FD_ERR_COLOR_YELLOW 0x00000400 /**< Frame color is yellow */
+#define FM_FD_ERR_ILL_PLCR 0x00000200 /**< Illegal Policer Profile selected */
+#define FM_FD_ERR_PLCR_FRAME_LEN 0x00000100 /**< Policer frame length error */
+#define FM_FD_ERR_PRS_TIMEOUT 0x00000080 /**< Parser Time out Exceed */
+#define FM_FD_ERR_PRS_ILL_INSTRUCT 0x00000040 /**< Invalid Soft Parser instruction */
+#define FM_FD_ERR_PRS_HDR_ERR 0x00000020 /**< Header error was identified during parsing */
+#define FM_FD_ERR_BLOCK_LIMIT_EXCEEDED 0x00000008 /**< Frame parsed beyind 256 first bytes */
+
+#define FM_FD_TX_STATUS_ERR_MASK (FM_FD_ERR_UNSUPPORTED_FORMAT | \
+ FM_FD_ERR_LENGTH | \
+ FM_FD_ERR_DMA) /**< TX Error FD bits */
+
+#define FM_FD_RX_STATUS_ERR_MASK (FM_FD_ERR_UNSUPPORTED_FORMAT | \
+ FM_FD_ERR_LENGTH | \
+ FM_FD_ERR_DMA | \
+ FM_FD_ERR_IPR | \
+ FM_FD_ERR_IPR_TO | \
+ FM_FD_ERR_IPR_NCSP | \
+ FM_FD_ERR_PHYSICAL | \
+ FM_FD_ERR_SIZE | \
+ FM_FD_ERR_CLS_DISCARD | \
+ FM_FD_ERR_COLOR_RED | \
+ FM_FD_ERR_COLOR_YELLOW | \
+ FM_FD_ERR_ILL_PLCR | \
+ FM_FD_ERR_PLCR_FRAME_LEN | \
+ FM_FD_ERR_EXTRACTION | \
+ FM_FD_ERR_NO_SCHEME | \
+ FM_FD_ERR_KEYSIZE_OVERFLOW | \
+ FM_FD_ERR_PRS_TIMEOUT | \
+ FM_FD_ERR_PRS_ILL_INSTRUCT | \
+ FM_FD_ERR_PRS_HDR_ERR | \
+ FM_FD_ERR_BLOCK_LIMIT_EXCEEDED) /**< RX Error FD bits */
+
+#define FM_FD_RX_STATUS_ERR_NON_FM 0x00400000 /**< non Frame-Manager error */
/* @} */
/**************************************************************************//**
@@ -168,6 +225,23 @@ typedef _Packed struct t_FmContextA {
typedef uint32_t t_FmContextB;
/**************************************************************************//**
+ @Collection Special Operation options
+*//***************************************************************************/
+typedef uint32_t fmSpecialOperations_t; /**< typedef for defining Special Operation options */
+
+#define FM_SP_OP_IPSEC 0x80000000 /**< activate features that related to IPSec (e.g fix Eth-type) */
+#define FM_SP_OP_IPSEC_UPDATE_UDP_LEN 0x40000000 /**< update the UDP-Len after Encryption */
+#define FM_SP_OP_IPSEC_MANIP 0x20000000 /**< handle the IPSec-manip options */
+#define FM_SP_OP_RPD 0x10000000 /**< Set the RPD bit */
+#define FM_SP_OP_DCL4C 0x08000000 /**< Set the DCL4C bit */
+#define FM_SP_OP_CHECK_SEC_ERRORS 0x04000000 /**< Check SEC errors */
+#define FM_SP_OP_CLEAR_RPD 0x02000000 /**< Clear the RPD bit */
+#define FM_SP_OP_CAPWAP_DTLS_ENC 0x01000000 /**< activate features that related to CAPWAP-DTLS post Encryption */
+#define FM_SP_OP_CAPWAP_DTLS_DEC 0x00800000 /**< activate features that related to CAPWAP-DTLS post Decryption */
+#define FM_SP_OP_IPSEC_NO_ETH_HDR 0x00400000 /**< activate features that related to IPSec without Eth hdr */
+/* @} */
+
+/**************************************************************************//**
@Collection Context A macros
*//***************************************************************************/
#define FM_CONTEXTA_OVERRIDE_MASK 0x80000000
@@ -207,7 +281,6 @@ typedef uint32_t t_FmContextB;
#define FM_CONTEXTB_SET_FQID(contextB,val) (*((t_FmContextB *)contextB) = ((*((t_FmContextB *)contextB) & ~FM_CONTEXTB_FQID_MASK) | ((val) & FM_CONTEXTB_FQID_MASK)))
/* @} */
-#define MEM_MAP_END
#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(pop)
#endif /* defined(__MWERKS__) && ... */
@@ -217,18 +290,19 @@ typedef uint32_t t_FmContextB;
@Description FM Exceptions
*//***************************************************************************/
typedef enum e_FmExceptions {
- e_FM_EX_DMA_BUS_ERROR, /**< DMA bus error. */
- e_FM_EX_DMA_READ_ECC, /**< Read Buffer ECC error */
- e_FM_EX_DMA_SYSTEM_WRITE_ECC, /**< Write Buffer ECC error on system side */
- e_FM_EX_DMA_FM_WRITE_ECC, /**< Write Buffer ECC error on FM side */
+ e_FM_EX_DMA_BUS_ERROR = 0, /**< DMA bus error. */
+ e_FM_EX_DMA_READ_ECC, /**< Read Buffer ECC error (Valid for FM rev < 6)*/
+ e_FM_EX_DMA_SYSTEM_WRITE_ECC, /**< Write Buffer ECC error on system side (Valid for FM rev < 6)*/
+ e_FM_EX_DMA_FM_WRITE_ECC, /**< Write Buffer ECC error on FM side (Valid for FM rev < 6)*/
+ e_FM_EX_DMA_SINGLE_PORT_ECC, /**< Single Port ECC error on FM side (Valid for FM rev > 6)*/
e_FM_EX_FPM_STALL_ON_TASKS, /**< Stall of tasks on FPM */
e_FM_EX_FPM_SINGLE_ECC, /**< Single ECC on FPM. */
e_FM_EX_FPM_DOUBLE_ECC, /**< Double ECC error on FPM ram access */
e_FM_EX_QMI_SINGLE_ECC, /**< Single ECC on QMI. */
e_FM_EX_QMI_DOUBLE_ECC, /**< Double bit ECC occurred on QMI */
- e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID,/**< Dequeu from unknown port id */
+ e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID,/**< Dequeue from unknown port id */
e_FM_EX_BMI_LIST_RAM_ECC, /**< Linked List RAM ECC error */
- e_FM_EX_BMI_PIPELINE_ECC, /**< Pipeline Table ECC Error */
+ e_FM_EX_BMI_STORAGE_PROFILE_ECC, /**< Storage Profile ECC Error */
e_FM_EX_BMI_STATISTICS_RAM_ECC, /**< Statistics Count RAM ECC Error Enable */
e_FM_EX_BMI_DISPATCH_RAM_ECC, /**< Dispatch RAM ECC Error Enable */
e_FM_EX_IRAM_ECC, /**< Double bit ECC occurred on IRAM*/
@@ -236,6 +310,26 @@ typedef enum e_FmExceptions {
} e_FmExceptions;
/**************************************************************************//**
+ @Description Enum for defining port DMA swap mode
+*//***************************************************************************/
+typedef enum e_FmDmaSwapOption {
+ e_FM_DMA_NO_SWP = FMAN_DMA_NO_SWP, /**< No swap, transfer data as is.*/
+ e_FM_DMA_SWP_PPC_LE = FMAN_DMA_SWP_PPC_LE, /**< The transferred data should be swapped
+ in PowerPc Little Endian mode. */
+ e_FM_DMA_SWP_BE = FMAN_DMA_SWP_BE /**< The transferred data should be swapped
+ in Big Endian mode */
+} e_FmDmaSwapOption;
+
+/**************************************************************************//**
+ @Description Enum for defining port DMA cache attributes
+*//***************************************************************************/
+typedef enum e_FmDmaCacheOption {
+ e_FM_DMA_NO_STASH = FMAN_DMA_NO_STASH, /**< Cacheable, no Allocate (No Stashing) */
+ e_FM_DMA_STASH = FMAN_DMA_STASH /**< Cacheable and Allocate (Stashing on) */
+} e_FmDmaCacheOption;
+
+
+/**************************************************************************//**
@Group FM_init_grp FM Initialization Unit
@Description FM Initialization Unit
@@ -243,9 +337,9 @@ typedef enum e_FmExceptions {
Initialization Flow
Initialization of the FM Module will be carried out by the application
according to the following sequence:
- a. Calling the configuration routine with basic parameters.
- b. Calling the advance initialization routines to change driver's defaults.
- c. Calling the initialization routine.
+ - Calling the configuration routine with basic parameters.
+ - Calling the advance initialization routines to change driver's defaults.
+ - Calling the initialization routine.
@{
*//***************************************************************************/
@@ -259,8 +353,9 @@ typedef enum e_FmExceptions {
@Param[in] h_App - User's application descriptor.
@Param[in] exception - The exception.
*//***************************************************************************/
-typedef void (t_FmExceptionsCallback) (t_Handle h_App,
- e_FmExceptions exception);
+typedef void (t_FmExceptionsCallback)(t_Handle h_App,
+ e_FmExceptions exception);
+
/**************************************************************************//**
@Function t_FmBusErrorCallback
@@ -283,76 +378,162 @@ typedef void (t_FmBusErrorCallback) (t_Handle h_App,
uint16_t liodn);
/**************************************************************************//**
- @Description structure for defining Ucode patch for loading.
-*//***************************************************************************/
-typedef struct t_FmPcdFirmwareParams {
+ @Description A structure for defining buffer prefix area content.
+*//***************************************************************************/
+typedef struct t_FmBufferPrefixContent {
+ uint16_t privDataSize; /**< Number of bytes to be left at the beginning
+ of the external buffer; Note that the private-area will
+ start from the base of the buffer address. */
+ bool passPrsResult; /**< TRUE to pass the parse result to/from the FM;
+ User may use FM_PORT_GetBufferPrsResult() in order to
+ get the parser-result from a buffer. */
+ bool passTimeStamp; /**< TRUE to pass the timeStamp to/from the FM
+ User may use FM_PORT_GetBufferTimeStamp() in order to
+ get the parser-result from a buffer. */
+ bool passHashResult; /**< TRUE to pass the KG hash result to/from the FM
+ User may use FM_PORT_GetBufferHashResult() in order to
+ get the parser-result from a buffer. */
+ bool passAllOtherPCDInfo;/**< Add all other Internal-Context information:
+ AD, hash-result, key, etc. */
+ uint16_t dataAlign; /**< 0 to use driver's default alignment [DEFAULT_FM_SP_bufferPrefixContent_dataAlign],
+ other value for selecting a data alignment (must be a power of 2);
+ if write optimization is used, must be >= 16. */
+ uint8_t manipExtraSpace; /**< Maximum extra size needed (insertion-size minus removal-size);
+ Note that this field impacts the size of the buffer-prefix
+ (i.e. it pushes the data offset);
+ This field is irrelevant if DPAA_VERSION==10 */
+} t_FmBufferPrefixContent;
+
+/**************************************************************************//**
+ @Description A structure of information about each of the external
+ buffer pools used by a port or storage-profile.
+*//***************************************************************************/
+typedef struct t_FmExtPoolParams {
+ uint8_t id; /**< External buffer pool id */
+ uint16_t size; /**< External buffer pool buffer size */
+} t_FmExtPoolParams;
+
+/**************************************************************************//**
+ @Description A structure for informing the driver about the external
+ buffer pools allocated in the BM and used by a port or a
+ storage-profile.
+*//***************************************************************************/
+typedef struct t_FmExtPools {
+ uint8_t numOfPoolsUsed; /**< Number of pools use by this port */
+ t_FmExtPoolParams extBufPool[FM_PORT_MAX_NUM_OF_EXT_POOLS];
+ /**< Parameters for each port */
+} t_FmExtPools;
+
+/**************************************************************************//**
+ @Description A structure for defining backup BM Pools.
+*//***************************************************************************/
+typedef struct t_FmBackupBmPools {
+ uint8_t numOfBackupPools; /**< Number of BM backup pools -
+ must be smaller than the total number of
+ pools defined for the specified port.*/
+ uint8_t poolIds[FM_PORT_MAX_NUM_OF_EXT_POOLS];
+ /**< numOfBackupPools pool id's, specifying which
+ pools should be used only as backup. Pool
+ id's specified here must be a subset of the
+ pools used by the specified port.*/
+} t_FmBackupBmPools;
+
+/**************************************************************************//**
+ @Description A structure for defining BM pool depletion criteria
+*//***************************************************************************/
+typedef struct t_FmBufPoolDepletion {
+ bool poolsGrpModeEnable; /**< select mode in which pause frames will be sent after
+ a number of pools (all together!) are depleted */
+ uint8_t numOfPools; /**< the number of depleted pools that will invoke
+ pause frames transmission. */
+ bool poolsToConsider[BM_MAX_NUM_OF_POOLS];
+ /**< For each pool, TRUE if it should be considered for
+ depletion (Note - this pool must be used by this port!). */
+ bool singlePoolModeEnable; /**< select mode in which pause frames will be sent after
+ a single-pool is depleted; */
+ bool poolsToConsiderForSingleMode[BM_MAX_NUM_OF_POOLS];
+ /**< For each pool, TRUE if it should be considered for
+ depletion (Note - this pool must be used by this port!) */
+#if (DPAA_VERSION >= 11)
+ bool pfcPrioritiesEn[FM_MAX_NUM_OF_PFC_PRIORITIES];
+ /**< This field is used by the MAC as the Priority Enable Vector in the PFC frame which is transmitted */
+#endif /* (DPAA_VERSION >= 11) */
+} t_FmBufPoolDepletion;
+
+/**************************************************************************//**
+ @Description A Structure for defining Ucode patch for loading.
+*//***************************************************************************/
+typedef struct t_FmFirmwareParams {
uint32_t size; /**< Size of uCode */
uint32_t *p_Code; /**< A pointer to the uCode */
-} t_FmPcdFirmwareParams;
+} t_FmFirmwareParams;
/**************************************************************************//**
- @Description structure representing FM initialization parameters
+ @Description A Structure for defining FM initialization parameters
*//***************************************************************************/
-#define FM_SIZE_OF_LIODN_TABLE 64
typedef struct t_FmParams {
uint8_t fmId; /**< Index of the FM */
-
uint8_t guestId; /**< FM Partition Id */
-
- uintptr_t baseAddr; /**< Relevant when guestId = NCSW_MASSTER_ID only.
- A pointer to base of memory mapped FM registers (virtual);
- NOTE that this should include ALL common regs of the FM including
- the PCD regs area. */
- t_Handle h_FmMuram; /**< Relevant when guestId = NCSW_MASSTER_ID only.
- A handle of an initialized MURAM object,
- to be used by the FM */
- uint16_t fmClkFreq; /**< Relevant when guestId = NCSW_MASSTER_ID only.
- In Mhz */
-#ifdef FM_PARTITION_ARRAY
- uint16_t liodnBasePerPort[FM_SIZE_OF_LIODN_TABLE];
- /**< Relevant when guestId = NCSW_MASSTER_ID only.
- For each partition, LIODN should be configured here. */
-#endif /* FM_PARTITION_ARRAY */
- t_FmExceptionsCallback *f_Exception; /**< Relevant when guestId = NCSW_MASSTER_ID only.
- An application callback routine to
- handle exceptions.*/
- t_FmBusErrorCallback *f_BusError; /**< Relevant when guestId = NCSW_MASSTER_ID only.
- An application callback routine to
- handle exceptions.*/
- t_Handle h_App; /**< Relevant when guestId = NCSW_MASSTER_ID only.
- A handle to an application layer object; This handle will
- be passed by the driver upon calling the above callbacks */
- uintptr_t irq; /**< Relevant when guestId = NCSW_MASSTER_ID only.
- FM interrupt source for normal events */
- uintptr_t errIrq; /**< Relevant when guestId = NCSW_MASSTER_ID only.
- FM interrupt source for errors */
- t_FmPcdFirmwareParams firmware; /**< Relevant when guestId = NCSW_MASSTER_ID only.
- Ucode */
+ uintptr_t baseAddr; /**< A pointer to base of memory mapped FM registers (virtual);
+ this field is optional when the FM runs in "guest-mode"
+ (i.e. guestId != NCSW_MASTER_ID); in that case, the driver will
+ use the memory-map instead of calling the IPC where possible;
+ NOTE that this should include ALL common registers of the FM including
+ the PCD registers area (i.e. until the VSP pages - 880KB). */
+ t_Handle h_FmMuram; /**< A handle of an initialized MURAM object,
+ to be used by the FM. */
+ uint16_t fmClkFreq; /**< In Mhz;
+ Relevant when FM not runs in "guest-mode". */
+ uint16_t fmMacClkRatio; /**< FM MAC Clock ratio, for backward comparability:
+ when fmMacClkRatio = 0, ratio is 2:1
+ when fmMacClkRatio = 1, ratio is 1:1 */
+ t_FmExceptionsCallback *f_Exception; /**< An application callback routine to handle exceptions;
+ Relevant when FM not runs in "guest-mode". */
+ t_FmBusErrorCallback *f_BusError; /**< An application callback routine to handle exceptions;
+ Relevant when FM not runs in "guest-mode". */
+ t_Handle h_App; /**< A handle to an application layer object; This handle will
+ be passed by the driver upon calling the above callbacks;
+ Relevant when FM not runs in "guest-mode". */
+ uintptr_t irq; /**< FM interrupt source for normal events;
+ Relevant when FM not runs in "guest-mode". */
+ uintptr_t errIrq; /**< FM interrupt source for errors;
+ Relevant when FM not runs in "guest-mode". */
+ t_FmFirmwareParams firmware; /**< The firmware parameters structure;
+ Relevant when FM not runs in "guest-mode". */
+
+#if (DPAA_VERSION >= 11)
+ uintptr_t vspBaseAddr; /**< A pointer to base of memory mapped FM VSP registers (virtual);
+ i.e. up to 24KB, depending on the specific chip. */
+ uint8_t partVSPBase; /**< The first Virtual-Storage-Profile-id dedicated to this partition.
+ NOTE: this parameter relevant only when working with multiple partitions. */
+ uint8_t partNumOfVSPs; /**< Number of VSPs dedicated to this partition.
+ NOTE: this parameter relevant only when working with multiple partitions. */
+#endif /* (DPAA_VERSION >= 11) */
} t_FmParams;
/**************************************************************************//**
@Function FM_Config
- @Description Creates descriptor for the FM module.
-
- The routine returns a handle (descriptor) to the FM object.
+ @Description Creates the FM module and returns its handle (descriptor).
This descriptor must be passed as first parameter to all other
FM function calls.
No actual initialization or configuration of FM hardware is
- done by this routine.
+ done by this routine. All FM parameters get default values that
+ may be changed by calling one or more of the advance config routines.
- @Param[in] p_FmParams - A pointer to data structure of parameters
+ @Param[in] p_FmParams - A pointer to a data structure of mandatory FM parameters
- @Return Handle to FM object, or NULL for Failure.
+ @Return A handle to the FM object, or NULL for Failure.
*//***************************************************************************/
t_Handle FM_Config(t_FmParams *p_FmParams);
/**************************************************************************//**
@Function FM_Init
- @Description Initializes the FM module
+ @Description Initializes the FM module by defining the software structure
+ and configuring the hardware registers.
@Param[in] h_Fm - FM module descriptor
@@ -377,13 +558,15 @@ t_Error FM_Free(t_Handle h_Fm);
/**************************************************************************//**
@Group FM_advanced_init_grp FM Advanced Configuration Unit
- @Description Configuration functions used to change default values;
- Note: Advanced init routines are not available for guest partition.
+ @Description Advanced configuration routines are optional routines that may
+ be called in order to change the default driver settings.
+
+ Note: Advanced configuration routines are not available for guest partition.
@{
*//***************************************************************************/
/**************************************************************************//**
- @Description DMA debug mode
+ @Description Enum for selecting DMA debug mode
*//***************************************************************************/
typedef enum e_FmDmaDbgCntMode {
e_FM_DMA_DBG_NO_CNT = 0, /**< No counting */
@@ -397,7 +580,7 @@ typedef enum e_FmDmaDbgCntMode {
} e_FmDmaDbgCntMode;
/**************************************************************************//**
- @Description DMA Cache Override
+ @Description Enum for selecting DMA Cache Override
*//***************************************************************************/
typedef enum e_FmDmaCacheOverride {
e_FM_DMA_NO_CACHE_OR = 0, /**< No override of the Cache field */
@@ -407,7 +590,7 @@ typedef enum e_FmDmaCacheOverride {
} e_FmDmaCacheOverride;
/**************************************************************************//**
- @Description DMA External Bus Priority
+ @Description Enum for selecting DMA External Bus Priority
*//***************************************************************************/
typedef enum e_FmDmaExtBusPri {
e_FM_DMA_EXT_BUS_NORMAL = 0, /**< Normal priority */
@@ -417,7 +600,7 @@ typedef enum e_FmDmaExtBusPri {
} e_FmDmaExtBusPri;
/**************************************************************************//**
- @Description enum for choosing the field that will be output on AID
+ @Description Enum for choosing the field that will be output on AID
*//***************************************************************************/
typedef enum e_FmDmaAidMode {
e_FM_DMA_AID_OUT_PORT_ID = 0, /**< 4 LSB of PORT_ID */
@@ -425,23 +608,24 @@ typedef enum e_FmDmaAidMode {
} e_FmDmaAidMode;
/**************************************************************************//**
- @Description FPM Catasrophic error behaviour
+ @Description Enum for selecting FPM Catastrophic error behavior
*//***************************************************************************/
typedef enum e_FmCatastrophicErr {
e_FM_CATASTROPHIC_ERR_STALL_PORT = 0, /**< Port_ID is stalled (only reset can release it) */
- e_FM_CATASTROPHIC_ERR_STALL_TASK /**< Only errornous task is stalled */
+ e_FM_CATASTROPHIC_ERR_STALL_TASK /**< Only erroneous task is stalled */
} e_FmCatastrophicErr;
/**************************************************************************//**
- @Description FPM DMA error behaviour
+ @Description Enum for selecting FPM DMA Error behavior
*//***************************************************************************/
typedef enum e_FmDmaErr {
- e_FM_DMA_ERR_CATASTROPHIC = 0, /**< Dma error is treated as a catastrophic error */
+ e_FM_DMA_ERR_CATASTROPHIC = 0, /**< Dma error is treated as a catastrophic
+ error (e_FmCatastrophicErr)*/
e_FM_DMA_ERR_REPORT /**< Dma error is just reported */
} e_FmDmaErr;
/**************************************************************************//**
- @Description DMA Emergency level by BMI emergency signal
+ @Description Enum for selecting DMA Emergency level by BMI emergency signal
*//***************************************************************************/
typedef enum e_FmDmaEmergencyLevel {
e_FM_DMA_EM_EBS = 0, /**< EBS emergency */
@@ -449,7 +633,7 @@ typedef enum e_FmDmaEmergencyLevel {
} e_FmDmaEmergencyLevel;
/**************************************************************************//**
- @Collection DMA emergency options
+ @Collection Enum for selecting DMA Emergency options
*//***************************************************************************/
typedef uint32_t fmEmergencyBus_t; /**< DMA emergency options */
@@ -467,7 +651,7 @@ typedef struct t_FmDmaEmergency {
e_FmDmaEmergencyLevel emergencyLevel; /**< EBS/SOS */
} t_FmDmaEmergency;
-/**************************************************************************//**
+/**************************************************************************//*
@Description structure for defining FM threshold
*//***************************************************************************/
typedef struct t_FmThresholds {
@@ -492,8 +676,7 @@ typedef struct t_FmThresholds {
queued in fmCtl2 dispatch queue*/
} t_FmThresholds;
-
-/**************************************************************************//**
+/**************************************************************************//*
@Description structure for defining DMA thresholds
*//***************************************************************************/
typedef struct t_FmDmaThresholds {
@@ -503,12 +686,21 @@ typedef struct t_FmDmaThresholds {
until this value is reached (Hystheresis) */
} t_FmDmaThresholds;
+/**************************************************************************//**
+ @Function t_FmResetOnInitOverrideCallback
+
+ @Description FMan specific reset on init user callback routine,
+ will be used to override the standard FMan reset on init procedure
+
+ @Param[in] h_Fm - FMan handler
+*//***************************************************************************/
+typedef void (t_FmResetOnInitOverrideCallback)(t_Handle h_Fm);
/**************************************************************************//**
@Function FM_ConfigResetOnInit
- @Description Tell the driver whether to reset the FM before initialization or
- not. It changes the default configuration [FALSE].
+ @Description Define whether to reset the FM before initialization.
+ Change the default configuration [DEFAULT_resetOnInit].
@Param[in] h_Fm A handle to an FM Module.
@Param[in] enable When TRUE, FM will be reset before any initialization.
@@ -516,29 +708,34 @@ typedef struct t_FmDmaThresholds {
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigResetOnInit(t_Handle h_Fm, bool enable);
/**************************************************************************//**
- @Function FM_ConfigTotalNumOfTasks
+ @Function FM_ConfigResetOnInitOverrideCallback
- @Description Change the total number of tasks from its default
- configuration [BMI_MAX_NUM_OF_TASKS]
+ @Description Define a special reset of FM before initialization.
+ Change the default configuration [DEFAULT_resetOnInitOverrideCallback].
- @Param[in] h_Fm A handle to an FM Module.
- @Param[in] totalNumOfTasks The selected new value.
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] f_ResetOnInitOverride FM specific reset on init user callback routine.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigTotalNumOfTasks(t_Handle h_Fm, uint8_t totalNumOfTasks);
+t_Error FM_ConfigResetOnInitOverrideCallback(t_Handle h_Fm, t_FmResetOnInitOverrideCallback *f_ResetOnInitOverride);
/**************************************************************************//**
@Function FM_ConfigTotalFifoSize
- @Description Change the total Fifo size from its default
- configuration [BMI_MAX_FIFO_SIZE]
+ @Description Define Total FIFO size for the whole FM.
+ Calling this routine changes the total Fifo size in the internal driver
+ data base from its default configuration [DEFAULT_totalFifoSize]
@Param[in] h_Fm A handle to an FM Module.
@Param[in] totalFifoSize The selected new value.
@@ -546,53 +743,17 @@ t_Error FM_ConfigTotalNumOfTasks(t_Handle h_Fm, uint8_t totalNumOfTasks);
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigTotalFifoSize(t_Handle h_Fm, uint32_t totalFifoSize);
-/**************************************************************************//**
- @Function FM_ConfigMaxNumOfOpenDmas
-
- @Description Change the maximum allowed open DMA's for this FM from its default
- configuration [BMI_MAX_NUM_OF_DMAS]
-
- @Param[in] h_Fm A handle to an FM Module.
- @Param[in] maxNumOfOpenDmas The selected new value.
-
- @Return E_OK on success; Error code otherwise.
-
- @Cautions Allowed only following FM_Config() and before FM_Init().
-*//***************************************************************************/
-t_Error FM_ConfigMaxNumOfOpenDmas(t_Handle h_Fm, uint8_t maxNumOfOpenDmas);
-
-/**************************************************************************//**
- @Function FM_ConfigThresholds
-
- @Description Calling this routine changes the internal driver data base
- from its default FM threshold configuration:
- dispLimit: [0]
- prsDispTh: [16]
- plcrDispTh: [16]
- kgDispTh: [16]
- bmiDispTh: [16]
- qmiEnqDispTh: [16]
- qmiDeqDispTh: [16]
- fmCtl1DispTh: [16]
- fmCtl2DispTh: [16]
-
- @Param[in] h_Fm A handle to an FM Module.
- @Param[in] p_FmThresholds A structure of threshold parameters.
-
- @Return E_OK on success; Error code otherwise.
-
- @Cautions Allowed only following FM_Config() and before FM_Init().
-*//***************************************************************************/
-t_Error FM_ConfigThresholds(t_Handle h_Fm, t_FmThresholds *p_FmThresholds);
-
/**************************************************************************//**
@Function FM_ConfigDmaCacheOverride
- @Description Calling this routine changes the internal driver data base
- from its default configuration of cache override mode [e_FM_DMA_NO_CACHE_OR]
+ @Description Define cache override mode.
+ Calling this routine changes the cache override mode
+ in the internal driver data base from its default configuration [DEFAULT_cacheOverride]
@Param[in] h_Fm A handle to an FM Module.
@Param[in] cacheOverride The selected new value.
@@ -600,14 +761,17 @@ t_Error FM_ConfigThresholds(t_Handle h_Fm, t_FmThresholds *p_FmThresholds);
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaCacheOverride(t_Handle h_Fm, e_FmDmaCacheOverride cacheOverride);
/**************************************************************************//**
@Function FM_ConfigDmaAidOverride
- @Description Calling this routine changes the internal driver data base
- from its default configuration of aid override mode [TRUE]
+ @Description Define DMA AID override mode.
+ Calling this routine changes the AID override mode
+ in the internal driver data base from its default configuration [DEFAULT_aidOverride]
@Param[in] h_Fm A handle to an FM Module.
@Param[in] aidOverride The selected new value.
@@ -615,14 +779,17 @@ t_Error FM_ConfigDmaCacheOverride(t_Handle h_Fm, e_FmDmaCacheOverride cacheOverr
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaAidOverride(t_Handle h_Fm, bool aidOverride);
/**************************************************************************//**
@Function FM_ConfigDmaAidMode
- @Description Calling this routine changes the internal driver data base
- from its default configuration of aid mode [e_FM_DMA_AID_OUT_TNUM]
+ @Description Define DMA AID mode.
+ Calling this routine changes the AID mode in the internal
+ driver data base from its default configuration [DEFAULT_aidMode]
@Param[in] h_Fm A handle to an FM Module.
@Param[in] aidMode The selected new value.
@@ -630,14 +797,17 @@ t_Error FM_ConfigDmaAidOverride(t_Handle h_Fm, bool aidOverride);
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaAidMode(t_Handle h_Fm, e_FmDmaAidMode aidMode);
/**************************************************************************//**
@Function FM_ConfigDmaAxiDbgNumOfBeats
- @Description Calling this routine changes the internal driver data base
- from its default configuration of axi debug [1]
+ @Description Define DMA AXI number of beats.
+ Calling this routine changes the AXI number of beats in the internal
+ driver data base from its default configuration [DEFAULT_axiDbgNumOfBeats]
@Param[in] h_Fm A handle to an FM Module.
@Param[in] axiDbgNumOfBeats The selected new value.
@@ -645,14 +815,17 @@ t_Error FM_ConfigDmaAidMode(t_Handle h_Fm, e_FmDmaAidMode aidMode);
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaAxiDbgNumOfBeats(t_Handle h_Fm, uint8_t axiDbgNumOfBeats);
/**************************************************************************//**
@Function FM_ConfigDmaCamNumOfEntries
- @Description Calling this routine changes the internal driver data base
- from its default configuration of number of CAM entries [32]
+ @Description Define number of CAM entries.
+ Calling this routine changes the number of CAM entries in the internal
+ driver data base from its default configuration [DEFAULT_dmaCamNumOfEntries].
@Param[in] h_Fm A handle to an FM Module.
@Param[in] numOfEntries The selected new value.
@@ -660,318 +833,402 @@ t_Error FM_ConfigDmaAxiDbgNumOfBeats(t_Handle h_Fm, uint8_t axiDbgNumOfBeats);
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaCamNumOfEntries(t_Handle h_Fm, uint8_t numOfEntries);
/**************************************************************************//**
- @Function FM_ConfigDmaWatchdog
+ @Function FM_ConfigEnableCounters
- @Description Calling this routine changes the internal driver data base
- from its default watchdog configuration, which is disabled
- [0].
+ @Description Obsolete, always return E_OK.
- @Param[in] h_Fm A handle to an FM Module.
- @Param[in] watchDogValue The selected new value - in microseconds.
+ @Param[in] h_Fm A handle to an FM Module.
+
+ @Return E_OK on success; Error code otherwise.
+*//***************************************************************************/
+t_Error FM_ConfigEnableCounters(t_Handle h_Fm);
+
+/**************************************************************************//**
+ @Function FM_ConfigDmaDbgCounter
+
+ @Description Define DMA debug counter.
+ Calling this routine changes the number of the DMA debug counter in the internal
+ driver data base from its default configuration [DEFAULT_dmaDbgCntMode].
+
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] fmDmaDbgCntMode An enum selecting the debug counter mode.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigDmaWatchdog(t_Handle h_Fm, uint32_t watchDogValue);
+t_Error FM_ConfigDmaDbgCounter(t_Handle h_Fm, e_FmDmaDbgCntMode fmDmaDbgCntMode);
/**************************************************************************//**
- @Function FM_ConfigDmaWriteBufThresholds
+ @Function FM_ConfigDmaStopOnBusErr
- @Description Calling this routine changes the internal driver data base
- from its default configuration of DMA write buffer threshold
- assertEmergency: [DMA_THRESH_MAX_BUF]
- clearEmergency: [DMA_THRESH_MAX_BUF]
+ @Description Define bus error behavior.
+ Calling this routine changes the bus error behavior definition
+ in the internal driver data base from its default
+ configuration [DEFAULT_dmaStopOnBusError].
- @Param[in] h_Fm A handle to an FM Module.
- @Param[in] p_FmDmaThresholds A structure of thresholds to define emergency behavior -
- When 'assertEmergency' value is reached, emergency is asserted,
- then it is held until 'clearEmergency' value is reached.
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] stop TRUE to stop on bus error, FALSE to continue.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ Only if bus error is enabled.
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigDmaWriteBufThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds);
+t_Error FM_ConfigDmaStopOnBusErr(t_Handle h_Fm, bool stop);
- /**************************************************************************//**
- @Function FM_ConfigDmaCommQThresholds
+/**************************************************************************//**
+ @Function FM_ConfigDmaEmergency
- @Description Calling this routine changes the internal driver data base
- from its default configuration of DMA command queue threshold
- assertEmergency: [DMA_THRESH_MAX_COMMQ]
- clearEmergency: [DMA_THRESH_MAX_COMMQ]
+ @Description Define DMA emergency.
+ Calling this routine changes the DMA emergency definition
+ in the internal driver data base from its default
+ configuration where's it's disabled.
- @Param[in] h_Fm A handle to an FM Module.
- @Param[in] p_FmDmaThresholds A structure of thresholds to define emergency behavior -
- When 'assertEmergency' value is reached, emergency is asserted,
- then it is held until 'clearEmergency' value is reached..
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] p_Emergency An OR mask of all required options.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigDmaCommQThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds);
+t_Error FM_ConfigDmaEmergency(t_Handle h_Fm, t_FmDmaEmergency *p_Emergency);
/**************************************************************************//**
- @Function FM_ConfigDmaReadBufThresholds
+ @Function FM_ConfigDmaErr
- @Description Calling this routine changes the internal driver data base
- from its default configuration of DMA read buffer threshold
- assertEmergency: [DMA_THRESH_MAX_BUF]
- clearEmergency: [DMA_THRESH_MAX_BUF]
+ @Description DMA error treatment.
+ Calling this routine changes the DMA error treatment
+ in the internal driver data base from its default
+ configuration [DEFAULT_dmaErr].
- @Param[in] h_Fm A handle to an FM Module.
- @Param[in] p_FmDmaThresholds A structure of thresholds to define emergency behavior -
- When 'assertEmergency' value is reached, emergency is asserted,
- then it is held until 'clearEmergency' value is reached..
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] dmaErr The selected new choice.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigDmaReadBufThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds);
+t_Error FM_ConfigDmaErr(t_Handle h_Fm, e_FmDmaErr dmaErr);
/**************************************************************************//**
- @Function FM_ConfigDmaSosEmergencyThreshold
+ @Function FM_ConfigCatastrophicErr
- @Description Calling this routine changes the internal driver data base
- from its default dma SOS emergency configuration [0]
+ @Description Define FM behavior on catastrophic error.
+ Calling this routine changes the FM behavior on catastrophic
+ error in the internal driver data base from its default
+ [DEFAULT_catastrophicErr].
@Param[in] h_Fm A handle to an FM Module.
- @Param[in] dmaSosEmergency The selected new value.
+ @Param[in] catastrophicErr The selected new choice.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigDmaSosEmergencyThreshold(t_Handle h_Fm, uint32_t dmaSosEmergency);
+t_Error FM_ConfigCatastrophicErr(t_Handle h_Fm, e_FmCatastrophicErr catastrophicErr);
/**************************************************************************//**
- @Function FM_ConfigEnableCounters
+ @Function FM_ConfigEnableMuramTestMode
- @Description Calling this routine changes the internal driver data base
- from its default counters configuration where counters are disabled.
+ @Description Enable MURAM test mode.
+ Calling this routine changes the internal driver data base
+ from its default selection of test mode where it's disabled.
+ This routine is only avaiable on old FM revisions (FMan v2).
@Param[in] h_Fm A handle to an FM Module.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigEnableCounters(t_Handle h_Fm);
+t_Error FM_ConfigEnableMuramTestMode(t_Handle h_Fm);
/**************************************************************************//**
- @Function FM_ConfigDmaDbgCounter
+ @Function FM_ConfigEnableIramTestMode
- @Description Calling this routine changes the internal driver data base
- from its default DMA debug counters configuration [e_FM_DMA_DBG_NO_CNT]
+ @Description Enable IRAM test mode.
+ Calling this routine changes the internal driver data base
+ from its default selection of test mode where it's disabled.
+ This routine is only avaiable on old FM revisions (FMan v2).
- @Param[in] h_Fm A handle to an FM Module.
- @Param[in] fmDmaDbgCntMode An enum selecting the debug counter mode.
+ @Param[in] h_Fm A handle to an FM Module.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigDmaDbgCounter(t_Handle h_Fm, e_FmDmaDbgCntMode fmDmaDbgCntMode);
+t_Error FM_ConfigEnableIramTestMode(t_Handle h_Fm);
/**************************************************************************//**
- @Function FM_ConfigDmaStopOnBusErr
-
- @Description Calling this routine changes the internal driver data base
- from its default selection of bus error behavior [FALSE]
+ @Function FM_ConfigHaltOnExternalActivation
+ @Description Define FM behavior on external halt activation.
+ Calling this routine changes the FM behavior on external halt
+ activation in the internal driver data base from its default
+ [DEFAULT_haltOnExternalActivation].
- @Param[in] h_Fm A handle to an FM Module.
- @Param[in] stop TRUE to stop on bus error, FALSE to continue.
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] enable TRUE to enable halt on external halt
+ activation.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
- Only if bus error is enabled.
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigDmaStopOnBusErr(t_Handle h_Fm, bool stop);
+t_Error FM_ConfigHaltOnExternalActivation(t_Handle h_Fm, bool enable);
/**************************************************************************//**
- @Function FM_ConfigDmaEmergency
+ @Function FM_ConfigHaltOnUnrecoverableEccError
- @Description Calling this routine changes the internal driver data base
- from its default selection of DMA emergency where's it's disabled.
+ @Description Define FM behavior on external halt activation.
+ Calling this routine changes the FM behavior on unrecoverable
+ ECC error in the internal driver data base from its default
+ [DEFAULT_haltOnUnrecoverableEccError].
+ This routine is only avaiable on old FM revisions (FMan v2).
- @Param[in] h_Fm A handle to an FM Module.
- @Param[in] p_Emergency An OR mask of all required options.
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] enable TRUE to enable halt on unrecoverable Ecc error
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigDmaEmergency(t_Handle h_Fm, t_FmDmaEmergency *p_Emergency);
+t_Error FM_ConfigHaltOnUnrecoverableEccError(t_Handle h_Fm, bool enable);
/**************************************************************************//**
- @Function FM_ConfigDmaEmergencySmoother
+ @Function FM_ConfigException
- @Description sets the minimum amount of DATA beats transferred on the AXI
- READ and WRITE ports before lowering the emergency level.
- By default smother is disabled.
+ @Description Define FM exceptions.
+ Calling this routine changes the exceptions defaults in the
+ internal driver data base where all exceptions are enabled.
@Param[in] h_Fm A handle to an FM Module.
- @Param[in] emergencyCnt emergency switching counter.
+ @Param[in] exception The exception to be selected.
+ @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigDmaEmergencySmoother(t_Handle h_Fm, uint32_t emergencyCnt);
+t_Error FM_ConfigException(t_Handle h_Fm, e_FmExceptions exception, bool enable);
/**************************************************************************//**
- @Function FM_ConfigDmaErr
+ @Function FM_ConfigExternalEccRamsEnable
- @Description Calling this routine changes the internal driver data base
- from its default DMA error treatment [e_FM_DMA_ERR_CATASTROPHIC]
+ @Description Select external ECC enabling.
+ Calling this routine changes the ECC enabling control in the internal
+ driver data base from its default [DEFAULT_externalEccRamsEnable].
+ When this option is enabled Rams ECC enabling is not effected
+ by FM_EnableRamsEcc/FM_DisableRamsEcc, but by a JTAG.
- @Param[in] h_Fm A handle to an FM Module.
- @Param[in] dmaErr The selected new choice.
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] enable TRUE to enable this option.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigDmaErr(t_Handle h_Fm, e_FmDmaErr dmaErr);
+t_Error FM_ConfigExternalEccRamsEnable(t_Handle h_Fm, bool enable);
/**************************************************************************//**
- @Function FM_ConfigCatastrophicErr
+ @Function FM_ConfigTnumAgingPeriod
- @Description Calling this routine changes the internal driver data base
- from its default behavior on catastrophic error [e_FM_CATASTROPHIC_ERR_STALL_PORT]
+ @Description Define Tnum aging period.
+ Calling this routine changes the Tnum aging of dequeue TNUMs
+ in the QMI in the internal driver data base from its default
+ [DEFAULT_tnumAgingPeriod].
@Param[in] h_Fm A handle to an FM Module.
- @Param[in] catastrophicErr The selected new choice.
+ @Param[in] tnumAgingPeriod Tnum Aging Period in microseconds.
+ Note that period is recalculated in units of
+ 64 FM clocks. Driver will pick the closest
+ possible period.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
+ NOTE that if some MAC is configured for PFC, '0' value is NOT
+ allowed.
*//***************************************************************************/
-t_Error FM_ConfigCatastrophicErr(t_Handle h_Fm, e_FmCatastrophicErr catastrophicErr);
+t_Error FM_ConfigTnumAgingPeriod(t_Handle h_Fm, uint16_t tnumAgingPeriod);
-/**************************************************************************//**
- @Function FM_ConfigEnableMuramTestMode
+/**************************************************************************//*
+ @Function FM_ConfigDmaEmergencySmoother
- @Description Calling this routine changes the internal driver data base
- from its default selection of test mode where it's disabled.
+ @Description Define DMA emergency smoother.
+ Calling this routine changes the definition of the minimum
+ amount of DATA beats transferred on the AXI READ and WRITE
+ ports before lowering the emergency level.
+ By default smoother is disabled.
- @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] emergencyCnt emergency switching counter.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigEnableMuramTestMode(t_Handle h_Fm);
+t_Error FM_ConfigDmaEmergencySmoother(t_Handle h_Fm, uint32_t emergencyCnt);
-/**************************************************************************//**
- @Function FM_ConfigEnableIramTestMode
+/**************************************************************************//*
+ @Function FM_ConfigThresholds
@Description Calling this routine changes the internal driver data base
- from its default selection of test mode where it's disabled.
+ from its default FM threshold configuration:
+ dispLimit: [DEFAULT_dispLimit]
+ prsDispTh: [DEFAULT_prsDispTh]
+ plcrDispTh: [DEFAULT_plcrDispTh]
+ kgDispTh: [DEFAULT_kgDispTh]
+ bmiDispTh: [DEFAULT_bmiDispTh]
+ qmiEnqDispTh: [DEFAULT_qmiEnqDispTh]
+ qmiDeqDispTh: [DEFAULT_qmiDeqDispTh]
+ fmCtl1DispTh: [DEFAULT_fmCtl1DispTh]
+ fmCtl2DispTh: [DEFAULT_fmCtl2DispTh]
- @Param[in] h_Fm A handle to an FM Module.
+
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] p_FmThresholds A structure of threshold parameters.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigEnableIramTestMode(t_Handle h_Fm);
+t_Error FM_ConfigThresholds(t_Handle h_Fm, t_FmThresholds *p_FmThresholds);
-/**************************************************************************//**
- @Function FM_ConfigHaltOnExternalActivation
+/**************************************************************************//*
+ @Function FM_ConfigDmaSosEmergencyThreshold
@Description Calling this routine changes the internal driver data base
- from its default selection of FM behaviour on external halt
- activation [FALSE].
+ from its default dma SOS emergency configuration [DEFAULT_dmaSosEmergency]
- @Param[in] h_Fm A handle to an FM Module.
- @Param[in] enable TRUE to enable halt on external halt
- activation.
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] dmaSosEmergency The selected new value.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigHaltOnExternalActivation(t_Handle h_Fm, bool enable);
+t_Error FM_ConfigDmaSosEmergencyThreshold(t_Handle h_Fm, uint32_t dmaSosEmergency);
-/**************************************************************************//**
- @Function FM_ConfigHaltOnUnrecoverableEccError
+/**************************************************************************//*
+ @Function FM_ConfigDmaWriteBufThresholds
@Description Calling this routine changes the internal driver data base
- from its default selection of FM behaviour on unrecoverable
- Ecc error [FALSE].
+ from its default configuration of DMA write buffer threshold
+ assertEmergency: [DEFAULT_dmaWriteIntBufLow]
+ clearEmergency: [DEFAULT_dmaWriteIntBufHigh]
+ This routine is only avaiable on old FM revisions (FMan v2).
- @Param[in] h_Fm A handle to an FM Module.
- @Param[in] enable TRUE to enable halt on unrecoverable Ecc error
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] p_FmDmaThresholds A structure of thresholds to define emergency behavior -
+ When 'assertEmergency' value is reached, emergency is asserted,
+ then it is held until 'clearEmergency' value is reached.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigHaltOnUnrecoverableEccError(t_Handle h_Fm, bool enable);
+t_Error FM_ConfigDmaWriteBufThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds);
-/**************************************************************************//**
- @Function FM_ConfigException
+ /**************************************************************************//*
+ @Function FM_ConfigDmaCommQThresholds
@Description Calling this routine changes the internal driver data base
- from its default selection of exceptions enablement.
- By default all exceptions are enabled.
+ from its default configuration of DMA command queue threshold
+ assertEmergency: [DEFAULT_dmaCommQLow]
+ clearEmergency: [DEFAULT_dmaCommQHigh]
- @Param[in] h_Fm A handle to an FM Module.
- @Param[in] exception The exception to be selected.
- @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] p_FmDmaThresholds A structure of thresholds to define emergency behavior -
+ When 'assertEmergency' value is reached, emergency is asserted,
+ then it is held until 'clearEmergency' value is reached..
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigException(t_Handle h_Fm, e_FmExceptions exception, bool enable);
+t_Error FM_ConfigDmaCommQThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds);
-/**************************************************************************//**
- @Function FM_ConfigExternalEccRamsEnable
+/**************************************************************************//*
+ @Function FM_ConfigDmaReadBufThresholds
@Description Calling this routine changes the internal driver data base
- from its default [FALSE].
- When this option is enabled Rams ECC enable is not effected
- by the FPM RCR bit, but by a JTAG.
+ from its default configuration of DMA read buffer threshold
+ assertEmergency: [DEFAULT_dmaReadIntBufLow]
+ clearEmergency: [DEFAULT_dmaReadIntBufHigh]
+ This routine is only avaiable on old FM revisions (FMan v2).
- @Param[in] h_Fm A handle to an FM Module.
- @Param[in] enable TRUE to enable this option.
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] p_FmDmaThresholds A structure of thresholds to define emergency behavior -
+ When 'assertEmergency' value is reached, emergency is asserted,
+ then it is held until 'clearEmergency' value is reached..
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigExternalEccRamsEnable(t_Handle h_Fm, bool enable);
+t_Error FM_ConfigDmaReadBufThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds);
-/**************************************************************************//**
- @Function FM_ConfigTnumAgingPeriod
+/**************************************************************************//*
+ @Function FM_ConfigDmaWatchdog
@Description Calling this routine changes the internal driver data base
- from its default configuration for aging of dequeue TNUM's
- in the QMI.[0]
- Note that this functionality is not available in all chips.
+ from its default watchdog configuration, which is disabled
+ [DEFAULT_dmaWatchdog].
- @Param[in] h_Fm A handle to an FM Module.
- @Param[in] tnumAgingPeriod Tnum Aging Period in microseconds.
- Note that period is recalculated in units of
- 64 FM clocks. Driver will pick the closest
- possible period.
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] watchDogValue The selected new value - in microseconds.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_ConfigTnumAgingPeriod(t_Handle h_Fm, uint16_t tnumAgingPeriod);
+t_Error FM_ConfigDmaWatchdog(t_Handle h_Fm, uint32_t watchDogValue);
/** @} */ /* end of FM_advanced_init_grp group */
/** @} */ /* end of FM_init_grp group */
@@ -981,7 +1238,7 @@ t_Error FM_ConfigTnumAgingPeriod(t_Handle h_Fm, uint16_t tnumAgingPeriod);
@Group FM_runtime_control_grp FM Runtime Control Unit
@Description FM Runtime control unit API functions, definitions and enums.
- The FM driver provides a set of control routines for each module.
+ The FM driver provides a set of control routines.
These routines may only be called after the module was fully
initialized (both configuration and initialization routines were
called). They are typically used to get information from hardware
@@ -998,11 +1255,11 @@ t_Error FM_ConfigTnumAgingPeriod(t_Handle h_Fm, uint16_t tnumAgingPeriod);
FM_MAX_NUM_OF_1G_RX_PORTS + \
FM_MAX_NUM_OF_10G_RX_PORTS + \
FM_MAX_NUM_OF_1G_TX_PORTS + \
- FM_MAX_NUM_OF_10G_TX_PORTS)
+ FM_MAX_NUM_OF_10G_TX_PORTS) /**< Number of available FM ports */
/* @} */
-/**************************************************************************//**
- @Description Structure for Port bandwidth requirement. Port is identified
+/**************************************************************************//*
+ @Description A Structure for Port bandwidth requirement. Port is identified
by type and relative id.
*//***************************************************************************/
typedef struct t_FmPortBandwidth {
@@ -1011,14 +1268,15 @@ typedef struct t_FmPortBandwidth {
uint8_t bandwidth; /**< bandwidth - (in term of percents) */
} t_FmPortBandwidth;
-/**************************************************************************//**
+/**************************************************************************//*
@Description A Structure containing an array of Port bandwidth requirements.
The user should state the ports requiring bandwidth in terms of
percentage - i.e. all port's bandwidths in the array must add
up to 100.
*//***************************************************************************/
typedef struct t_FmPortsBandwidthParams {
- uint8_t numOfPorts; /**< num of ports listed in the array below */
+ uint8_t numOfPorts; /**< The number of relevant ports, which is the
+ number of valid entries in the array below */
t_FmPortBandwidth portsBandwidths[FM_MAX_NUM_OF_VALID_PORTS];
/**< for each port, it's bandwidth (all port's
bandwidths must add up to 100.*/
@@ -1033,7 +1291,7 @@ typedef enum e_FmDmaMuramPort {
} e_FmDmaMuramPort;
/**************************************************************************//**
- @Description enum for defining FM counters
+ @Description Enum for defining FM counters
*//***************************************************************************/
typedef enum e_FmCounters {
e_FM_COUNTERS_ENQ_TOTAL_FRAME = 0, /**< QMI total enqueued frames counter */
@@ -1045,14 +1303,11 @@ typedef enum e_FmCounters {
e_FM_COUNTERS_DEQ_FROM_DEFAULT, /**< QMI dequeue from default queue counter */
e_FM_COUNTERS_DEQ_FROM_CONTEXT, /**< QMI dequeue from FQ context counter */
e_FM_COUNTERS_DEQ_FROM_FD, /**< QMI dequeue from FD command field counter */
- e_FM_COUNTERS_DEQ_CONFIRM, /**< QMI dequeue confirm counter */
- e_FM_COUNTERS_SEMAPHOR_ENTRY_FULL_REJECT, /**< DMA semaphor reject due to full entry counter */
- e_FM_COUNTERS_SEMAPHOR_QUEUE_FULL_REJECT, /**< DMA semaphor reject due to full CAM queue counter */
- e_FM_COUNTERS_SEMAPHOR_SYNC_REJECT /**< DMA semaphor reject due to sync counter */
+ e_FM_COUNTERS_DEQ_CONFIRM /**< QMI dequeue confirm counter */
} e_FmCounters;
/**************************************************************************//**
- @Description structure for returning revision information
+ @Description A Structure for returning FM revision information
*//***************************************************************************/
typedef struct t_FmRevisionInfo {
uint8_t majorRev; /**< Major revision */
@@ -1060,16 +1315,33 @@ typedef struct t_FmRevisionInfo {
} t_FmRevisionInfo;
/**************************************************************************//**
- @Description struct for defining DMA status
+ @Description A Structure for returning FM ctrl code revision information
+*//***************************************************************************/
+typedef struct t_FmCtrlCodeRevisionInfo {
+ uint16_t packageRev; /**< Package revision */
+ uint8_t majorRev; /**< Major revision */
+ uint8_t minorRev; /**< Minor revision */
+} t_FmCtrlCodeRevisionInfo;
+
+/**************************************************************************//**
+ @Description A Structure for defining DMA status
*//***************************************************************************/
typedef struct t_FmDmaStatus {
bool cmqNotEmpty; /**< Command queue is not empty */
bool busError; /**< Bus error occurred */
- bool readBufEccError; /**< Double ECC error on buffer Read */
- bool writeBufEccSysError; /**< Double ECC error on buffer write from system side */
- bool writeBufEccFmError; /**< Double ECC error on buffer write from FM side */
+ bool readBufEccError; /**< Double ECC error on buffer Read (Valid for FM rev < 6)*/
+ bool writeBufEccSysError; /**< Double ECC error on buffer write from system side (Valid for FM rev < 6)*/
+ bool writeBufEccFmError; /**< Double ECC error on buffer write from FM side (Valid for FM rev < 6) */
+ bool singlePortEccError; /**< Single Port ECC error from FM side (Valid for FM rev >= 6)*/
} t_FmDmaStatus;
+/**************************************************************************//**
+ @Description A Structure for obtaining FM controller monitor values
+*//***************************************************************************/
+typedef struct t_FmCtrlMon {
+ uint8_t percentCnt[2]; /**< Percentage value */
+} t_FmCtrlMon;
+
#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
/**************************************************************************//**
@@ -1081,7 +1353,7 @@ typedef struct t_FmDmaStatus {
@Return E_OK on success;
- @Cautions Allowed only FM_Init().
+ @Cautions Allowed only following FM_Init().
*//***************************************************************************/
t_Error FM_DumpRegs(t_Handle h_Fm);
#endif /* (defined(DEBUG_ERRORS) && ... */
@@ -1090,7 +1362,6 @@ t_Error FM_DumpRegs(t_Handle h_Fm);
@Function FM_SetException
@Description Calling this routine enables/disables the specified exception.
- Note: Not available for guest partition.
@Param[in] h_Fm A handle to an FM Module.
@Param[in] exception The exception to be selected.
@@ -1099,26 +1370,12 @@ t_Error FM_DumpRegs(t_Handle h_Fm);
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_SetException(t_Handle h_Fm, e_FmExceptions exception, bool enable);
/**************************************************************************//**
- @Function FM_SetPortsBandwidth
-
- @Description Sets relative weights between ports when accessing common resources.
- Note: Not available for guest partition.
-
- @Param[in] h_Fm A handle to an FM Module.
- @Param[in] p_PortsBandwidth A structure of ports bandwidths in percentage, i.e.
- total must equal 100.
-
- @Return E_OK on success; Error code otherwise.
-
- @Cautions Allowed only following FM_Init().
-*//***************************************************************************/
-t_Error FM_SetPortsBandwidth(t_Handle h_Fm, t_FmPortsBandwidthParams *p_PortsBandwidth);
-
-/**************************************************************************//**
@Function FM_EnableRamsEcc
@Description Enables ECC mechanism for all the different FM RAM's; E.g. IRAM,
@@ -1128,13 +1385,14 @@ t_Error FM_SetPortsBandwidth(t_Handle h_Fm, t_FmPortsBandwidthParams *p_PortsBan
setting of ECC, this routine effects IRAM ECC only.
This routine is also called by the driver if an ECC exception is
enabled.
- Note: Not available for guest partition.
@Param[in] h_Fm A handle to an FM Module.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_EnableRamsEcc(t_Handle h_Fm);
@@ -1148,14 +1406,14 @@ t_Error FM_EnableRamsEcc(t_Handle h_Fm);
setting of ECC, this routine effects IRAM ECC only.
In opposed to FM_EnableRamsEcc, this routine must be called
explicitly to disable all Rams ECC.
- Note: Not available for guest partition.
-
@Param[in] h_Fm A handle to an FM Module.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Config() and before FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_DisableRamsEcc(t_Handle h_Fm);
@@ -1174,6 +1432,20 @@ t_Error FM_DisableRamsEcc(t_Handle h_Fm);
t_Error FM_GetRevision(t_Handle h_Fm, t_FmRevisionInfo *p_FmRevisionInfo);
/**************************************************************************//**
+ @Function FM_GetFmanCtrlCodeRevision
+
+ @Description Returns the Fman controller code revision
+
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[out] p_RevisionInfo A structure of revision information parameters.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_Init().
+*//***************************************************************************/
+t_Error FM_GetFmanCtrlCodeRevision(t_Handle h_Fm, t_FmCtrlCodeRevisionInfo *p_RevisionInfo);
+
+/**************************************************************************//**
@Function FM_GetCounter
@Description Reads one of the FM counters.
@@ -1194,7 +1466,6 @@ uint32_t FM_GetCounter(t_Handle h_Fm, e_FmCounters counter);
@Function FM_ModifyCounter
@Description Sets a value to an enabled counter. Use "0" to reset the counter.
- Note: Not available for guest partition.
@Param[in] h_Fm A handle to an FM Module.
@Param[in] counter The requested counter.
@@ -1203,6 +1474,8 @@ uint32_t FM_GetCounter(t_Handle h_Fm, e_FmCounters counter);
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ModifyCounter(t_Handle h_Fm, e_FmCounters counter, uint32_t val);
@@ -1210,11 +1483,14 @@ t_Error FM_ModifyCounter(t_Handle h_Fm, e_FmCounters counter, uint32_t val);
@Function FM_Resume
@Description Release FM after halt FM command or after unrecoverable ECC error.
- Note: Not available for guest partition.
@Param[in] h_Fm A handle to an FM Module.
@Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
void FM_Resume(t_Handle h_Fm);
@@ -1222,7 +1498,6 @@ void FM_Resume(t_Handle h_Fm);
@Function FM_SetDmaEmergency
@Description Manual emergency set
- Note: Not available for guest partition.
@Param[in] h_Fm A handle to an FM Module.
@Param[in] muramPort MURAM direction select.
@@ -1231,14 +1506,15 @@ void FM_Resume(t_Handle h_Fm);
@Return None.
@Cautions Allowed only following FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
void FM_SetDmaEmergency(t_Handle h_Fm, e_FmDmaMuramPort muramPort, bool enable);
/**************************************************************************//**
@Function FM_SetDmaExtBusPri
- @Description Manual emergency set
- Note: Not available for guest partition.
+ @Description Set the DMA external bus priority
@Param[in] h_Fm A handle to an FM Module.
@Param[in] pri External bus priority select
@@ -1246,102 +1522,210 @@ void FM_SetDmaEmergency(t_Handle h_Fm, e_FmDmaMuramPort muramPort, bool enable);
@Return None.
@Cautions Allowed only following FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
void FM_SetDmaExtBusPri(t_Handle h_Fm, e_FmDmaExtBusPri pri);
/**************************************************************************//**
- @Function FM_ForceIntr
+ @Function FM_GetDmaStatus
- @Description Causes an interrupt event on the requested source.
- Note: Not available for guest partition.
+ @Description Reads the DMA current status
@Param[in] h_Fm A handle to an FM Module.
- @Param[in] exception An exception to be forced.
-
- @Return E_OK on success; Error code if the exception is not enabled,
- or is not able to create interrupt.
+ @Param[out] p_FmDmaStatus A structure of DMA status parameters.
@Cautions Allowed only following FM_Init().
*//***************************************************************************/
-t_Error FM_ForceIntr (t_Handle h_Fm, e_FmExceptions exception);
+void FM_GetDmaStatus(t_Handle h_Fm, t_FmDmaStatus *p_FmDmaStatus);
/**************************************************************************//**
- @Function FM_GetDmaStatus
+ @Function FM_ErrorIsr
- @Description Reads the DMA current status
+ @Description FM interrupt-service-routine for errors.
- @Param[in] h_Fm A handle to an FM Module.
- @Param[out] p_FmDmaStatus A structure of DMA status parameters.
+ @Param[in] h_Fm A handle to an FM Module.
- @Return None
+ @Return E_OK on success; E_EMPTY if no errors found in register, other
+ error code otherwise.
@Cautions Allowed only following FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-void FM_GetDmaStatus(t_Handle h_Fm, t_FmDmaStatus *p_FmDmaStatus);
+t_Error FM_ErrorIsr(t_Handle h_Fm);
+
+/**************************************************************************//**
+ @Function FM_EventIsr
+
+ @Description FM interrupt-service-routine for normal events.
+
+ @Param[in] h_Fm A handle to an FM Module.
+
+ @Cautions Allowed only following FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
+*//***************************************************************************/
+void FM_EventIsr(t_Handle h_Fm);
/**************************************************************************//**
- @Function FM_GetPcdHandle
+ @Function FM_GetSpecialOperationCoding
- @Description Used by FMC in order to get PCD handle
+ @Description Return a specific coding according to the input mask.
- @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] spOper special operation mask.
+ @Param[out] p_SpOperCoding special operation code.
- @Return A handle to the PCD module, NULL if uninitialized.
+ @Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Init().
*//***************************************************************************/
-t_Handle FM_GetPcdHandle(t_Handle h_Fm);
+t_Error FM_GetSpecialOperationCoding(t_Handle h_Fm,
+ fmSpecialOperations_t spOper,
+ uint8_t *p_SpOperCoding);
/**************************************************************************//**
- @Function FM_ErrorIsr
- Note: Not available for guest partition.
+ @Function FM_CtrlMonStart
- @Description FM interrupt-service-routine for errors.
+ @Description Start monitoring utilization of all available FM controllers.
+
+ In order to obtain FM controllers utilization the following sequence
+ should be used:
+ -# FM_CtrlMonStart()
+ -# FM_CtrlMonStop()
+ -# FM_CtrlMonGetCounters() - issued for each FM controller
@Param[in] h_Fm A handle to an FM Module.
- @Return E_OK on success; E_EMPTY if no errors found in register, other
- error code otherwise.
+ @Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Init().
This routine should NOT be called from guest-partition
- (i.e. guestId != NCSW_MASTER_ID)
+ (i.e. guestId != NCSW_MASTER_ID).
*//***************************************************************************/
-t_Error FM_ErrorIsr(t_Handle h_Fm);
+t_Error FM_CtrlMonStart(t_Handle h_Fm);
/**************************************************************************//**
- @Function FM_EventIsr
- Note: Not available for guest partition.
+ @Function FM_CtrlMonStop
- @Description FM interrupt-service-routine for normal events.
+ @Description Stop monitoring utilization of all available FM controllers.
+
+ In order to obtain FM controllers utilization the following sequence
+ should be used:
+ -# FM_CtrlMonStart()
+ -# FM_CtrlMonStop()
+ -# FM_CtrlMonGetCounters() - issued for each FM controller
@Param[in] h_Fm A handle to an FM Module.
+ @Return E_OK on success; Error code otherwise.
+
@Cautions Allowed only following FM_Init().
This routine should NOT be called from guest-partition
- (i.e. guestId != NCSW_MASTER_ID)
+ (i.e. guestId != NCSW_MASTER_ID).
*//***************************************************************************/
-void FM_EventIsr(t_Handle h_Fm);
+t_Error FM_CtrlMonStop(t_Handle h_Fm);
-#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
/**************************************************************************//**
- @Function FmDumpPortRegs
+ @Function FM_CtrlMonGetCounters
+
+ @Description Obtain FM controller utilization parameters.
- @Description Dumps FM port registers which are part of FM common registers
+ In order to obtain FM controllers utilization the following sequence
+ should be used:
+ -# FM_CtrlMonStart()
+ -# FM_CtrlMonStop()
+ -# FM_CtrlMonGetCounters() - issued for each FM controller
@Param[in] h_Fm A handle to an FM Module.
- @Param[in] hardwarePortId HW port id.
+ @Param[in] fmCtrlIndex FM Controller index for that utilization results
+ are requested.
+ @Param[in] p_Mon Pointer to utilization results structure.
@Return E_OK on success; Error code otherwise.
- @Cautions Allowed only FM_Init().
+ @Cautions Allowed only following FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID).
*//***************************************************************************/
-t_Error FmDumpPortRegs(t_Handle h_Fm,uint8_t hardwarePortId);
-#endif /* (defined(DEBUG_ERRORS) && ... */
+t_Error FM_CtrlMonGetCounters(t_Handle h_Fm, uint8_t fmCtrlIndex, t_FmCtrlMon *p_Mon);
+
+
+/**************************************************************************//*
+ @Function FM_ForceIntr
+
+ @Description Causes an interrupt event on the requested source.
+
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] exception An exception to be forced.
+
+ @Return E_OK on success; Error code if the exception is not enabled,
+ or is not able to create interrupt.
+
+ @Cautions Allowed only following FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
+*//***************************************************************************/
+t_Error FM_ForceIntr (t_Handle h_Fm, e_FmExceptions exception);
+/**************************************************************************//*
+ @Function FM_SetPortsBandwidth
+
+ @Description Sets relative weights between ports when accessing common resources.
+
+ @Param[in] h_Fm A handle to an FM Module.
+ @Param[in] p_PortsBandwidth A structure of ports bandwidths in percentage, i.e.
+ total must equal 100.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
+*//***************************************************************************/
+t_Error FM_SetPortsBandwidth(t_Handle h_Fm, t_FmPortsBandwidthParams *p_PortsBandwidth);
+
+/**************************************************************************//*
+ @Function FM_GetMuramHandle
+
+ @Description Gets the corresponding MURAM handle
+
+ @Param[in] h_Fm A handle to an FM Module.
+
+ @Return MURAM handle; NULL otherwise.
+
+ @Cautions Allowed only following FM_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
+*//***************************************************************************/
+t_Handle FM_GetMuramHandle(t_Handle h_Fm);
/** @} */ /* end of FM_runtime_control_grp group */
/** @} */ /* end of FM_lib_grp group */
/** @} */ /* end of FM_grp group */
+
+#ifdef NCSW_BACKWARD_COMPATIBLE_API
+typedef t_FmFirmwareParams t_FmPcdFirmwareParams;
+typedef t_FmBufferPrefixContent t_FmPortBufferPrefixContent;
+typedef t_FmExtPoolParams t_FmPortExtPoolParams;
+typedef t_FmExtPools t_FmPortExtPools;
+typedef t_FmBackupBmPools t_FmPortBackupBmPools;
+typedef t_FmBufPoolDepletion t_FmPortBufPoolDepletion;
+typedef e_FmDmaSwapOption e_FmPortDmaSwapOption;
+typedef e_FmDmaCacheOption e_FmPortDmaCacheOption;
+
+#define FM_CONTEXTA_GET_OVVERIDE FM_CONTEXTA_GET_OVERRIDE
+#define FM_CONTEXTA_SET_OVVERIDE FM_CONTEXTA_SET_OVERRIDE
+
+#define e_FM_EX_BMI_PIPELINE_ECC e_FM_EX_BMI_STORAGE_PROFILE_ECC
+#define e_FM_PORT_DMA_NO_SWP e_FM_DMA_NO_SWP
+#define e_FM_PORT_DMA_SWP_PPC_LE e_FM_DMA_SWP_PPC_LE
+#define e_FM_PORT_DMA_SWP_BE e_FM_DMA_SWP_BE
+#define e_FM_PORT_DMA_NO_STASH e_FM_DMA_NO_STASH
+#define e_FM_PORT_DMA_STASH e_FM_DMA_STASH
+#endif /* NCSW_BACKWARD_COMPATIBLE_API */
+
+
#endif /* __FM_EXT */
diff --git a/sys/contrib/ncsw/inc/Peripherals/fm_mac_ext.h b/sys/contrib/ncsw/inc/Peripherals/fm_mac_ext.h
index 5abb60089cfe..da7e0463480a 100644
--- a/sys/contrib/ncsw/inc/Peripherals/fm_mac_ext.h
+++ b/sys/contrib/ncsw/inc/Peripherals/fm_mac_ext.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File fm_mac_ext.h
@@ -59,45 +60,51 @@
@{
*//***************************************************************************/
+#define FM_MAC_NO_PFC 0xff
+
/**************************************************************************//**
@Description FM MAC Exceptions
*//***************************************************************************/
typedef enum e_FmMacExceptions {
- e_FM_MAC_EX_10G_MDIO_SCAN_EVENTMDIO = 0
- ,e_FM_MAC_EX_10G_MDIO_CMD_CMPL
- ,e_FM_MAC_EX_10G_REM_FAULT
- ,e_FM_MAC_EX_10G_LOC_FAULT
- ,e_FM_MAC_EX_10G_1TX_ECC_ER
- ,e_FM_MAC_EX_10G_TX_FIFO_UNFL
- ,e_FM_MAC_EX_10G_TX_FIFO_OVFL
- ,e_FM_MAC_EX_10G_TX_ER
- ,e_FM_MAC_EX_10G_RX_FIFO_OVFL
- ,e_FM_MAC_EX_10G_RX_ECC_ER
- ,e_FM_MAC_EX_10G_RX_JAB_FRM
- ,e_FM_MAC_EX_10G_RX_OVRSZ_FRM
- ,e_FM_MAC_EX_10G_RX_RUNT_FRM
- ,e_FM_MAC_EX_10G_RX_FRAG_FRM
- ,e_FM_MAC_EX_10G_RX_LEN_ER
- ,e_FM_MAC_EX_10G_RX_CRC_ER
- ,e_FM_MAC_EX_10G_RX_ALIGN_ER
- ,e_FM_MAC_EX_1G_BAB_RX
- ,e_FM_MAC_EX_1G_RX_CTL
- ,e_FM_MAC_EX_1G_GRATEFUL_TX_STP_COMPLET
- ,e_FM_MAC_EX_1G_BAB_TX
- ,e_FM_MAC_EX_1G_TX_CTL
- ,e_FM_MAC_EX_1G_TX_ERR
- ,e_FM_MAC_EX_1G_LATE_COL
- ,e_FM_MAC_EX_1G_COL_RET_LMT
- ,e_FM_MAC_EX_1G_TX_FIFO_UNDRN
- ,e_FM_MAC_EX_1G_MAG_PCKT
- ,e_FM_MAC_EX_1G_MII_MNG_RD_COMPLET
- ,e_FM_MAC_EX_1G_MII_MNG_WR_COMPLET
- ,e_FM_MAC_EX_1G_GRATEFUL_RX_STP_COMPLET
- ,e_FM_MAC_EX_1G_TX_DATA_ERR
- ,e_FM_MAC_EX_1G_RX_DATA_ERR
- ,e_FM_MAC_EX_1G_1588_TS_RX_ERR
- ,e_FM_MAC_EX_1G_RX_MIB_CNT_OVFL
+ e_FM_MAC_EX_10G_MDIO_SCAN_EVENTMDIO = 0 /**< 10GEC MDIO scan event interrupt */
+ ,e_FM_MAC_EX_10G_MDIO_CMD_CMPL /**< 10GEC MDIO command completion interrupt */
+ ,e_FM_MAC_EX_10G_REM_FAULT /**< 10GEC, mEMAC Remote fault interrupt */
+ ,e_FM_MAC_EX_10G_LOC_FAULT /**< 10GEC, mEMAC Local fault interrupt */
+ ,e_FM_MAC_EX_10G_1TX_ECC_ER /**< 10GEC, mEMAC Transmit frame ECC error interrupt */
+ ,e_FM_MAC_EX_10G_TX_FIFO_UNFL /**< 10GEC, mEMAC Transmit FIFO underflow interrupt */
+ ,e_FM_MAC_EX_10G_TX_FIFO_OVFL /**< 10GEC, mEMAC Transmit FIFO overflow interrupt */
+ ,e_FM_MAC_EX_10G_TX_ER /**< 10GEC Transmit frame error interrupt */
+ ,e_FM_MAC_EX_10G_RX_FIFO_OVFL /**< 10GEC, mEMAC Receive FIFO overflow interrupt */
+ ,e_FM_MAC_EX_10G_RX_ECC_ER /**< 10GEC, mEMAC Receive frame ECC error interrupt */
+ ,e_FM_MAC_EX_10G_RX_JAB_FRM /**< 10GEC Receive jabber frame interrupt */
+ ,e_FM_MAC_EX_10G_RX_OVRSZ_FRM /**< 10GEC Receive oversized frame interrupt */
+ ,e_FM_MAC_EX_10G_RX_RUNT_FRM /**< 10GEC Receive runt frame interrupt */
+ ,e_FM_MAC_EX_10G_RX_FRAG_FRM /**< 10GEC Receive fragment frame interrupt */
+ ,e_FM_MAC_EX_10G_RX_LEN_ER /**< 10GEC Receive payload length error interrupt */
+ ,e_FM_MAC_EX_10G_RX_CRC_ER /**< 10GEC Receive CRC error interrupt */
+ ,e_FM_MAC_EX_10G_RX_ALIGN_ER /**< 10GEC Receive alignment error interrupt */
+ ,e_FM_MAC_EX_1G_BAB_RX /**< dTSEC Babbling receive error */
+ ,e_FM_MAC_EX_1G_RX_CTL /**< dTSEC Receive control (pause frame) interrupt */
+ ,e_FM_MAC_EX_1G_GRATEFUL_TX_STP_COMPLET /**< dTSEC Graceful transmit stop complete */
+ ,e_FM_MAC_EX_1G_BAB_TX /**< dTSEC Babbling transmit error */
+ ,e_FM_MAC_EX_1G_TX_CTL /**< dTSEC Transmit control (pause frame) interrupt */
+ ,e_FM_MAC_EX_1G_TX_ERR /**< dTSEC Transmit error */
+ ,e_FM_MAC_EX_1G_LATE_COL /**< dTSEC Late collision */
+ ,e_FM_MAC_EX_1G_COL_RET_LMT /**< dTSEC Collision retry limit */
+ ,e_FM_MAC_EX_1G_TX_FIFO_UNDRN /**< dTSEC Transmit FIFO underrun */
+ ,e_FM_MAC_EX_1G_MAG_PCKT /**< dTSEC Magic Packet detection */
+ ,e_FM_MAC_EX_1G_MII_MNG_RD_COMPLET /**< dTSEC MII management read completion */
+ ,e_FM_MAC_EX_1G_MII_MNG_WR_COMPLET /**< dTSEC MII management write completion */
+ ,e_FM_MAC_EX_1G_GRATEFUL_RX_STP_COMPLET /**< dTSEC Graceful receive stop complete */
+ ,e_FM_MAC_EX_1G_TX_DATA_ERR /**< dTSEC Internal data error on transmit */
+ ,e_FM_MAC_EX_1G_RX_DATA_ERR /**< dTSEC Internal data error on receive */
+ ,e_FM_MAC_EX_1G_1588_TS_RX_ERR /**< dTSEC Time-Stamp Receive Error */
+ ,e_FM_MAC_EX_1G_RX_MIB_CNT_OVFL /**< dTSEC MIB counter overflow */
+ ,e_FM_MAC_EX_TS_FIFO_ECC_ERR /**< mEMAC Time-stamp FIFO ECC error interrupt;
+ not supported on T4240/B4860 rev1 chips */
+ ,e_FM_MAC_EX_MAGIC_PACKET_INDICATION = e_FM_MAC_EX_1G_MAG_PCKT
+ /**< mEMAC Magic Packet Indication Interrupt */
} e_FmMacExceptions;
/**************************************************************************//**
@@ -105,11 +112,26 @@ typedef enum e_FmMacExceptions {
*//***************************************************************************/
typedef enum e_FmMacStatisticsLevel {
e_FM_MAC_NONE_STATISTICS = 0, /**< No statistics */
- e_FM_MAC_PARTIAL_STATISTICS, /**< Only error counters are available. Optimized for performance */
- e_FM_MAC_FULL_STATISTICS /**< All counters available. Not optimized for performance */
+ e_FM_MAC_PARTIAL_STATISTICS, /**< Only error counters are available; Optimized for performance */
+ e_FM_MAC_FULL_STATISTICS /**< All counters available; Not optimized for performance */
} e_FmMacStatisticsLevel;
+#if (DPAA_VERSION >= 11)
+/**************************************************************************//**
+ @Description Priority Flow Control Parameters
+*//***************************************************************************/
+typedef struct t_FmMacPfcParams {
+ bool pfcEnable; /**< Enable/Disable PFC */
+
+ uint16_t pauseQuanta[FM_MAX_NUM_OF_PFC_PRIORITIES]; /**< Pause Quanta per priority to be sent in a pause frame. Each quanta represents a 512 bit-times*/
+
+ uint16_t pauseThresholdQuanta[FM_MAX_NUM_OF_PFC_PRIORITIES];/**< Pause threshold per priority, when timer passes this threshold time a PFC frames is sent again if the port is still congested or BM pool in depletion*/
+
+
+} t_FmMacPfcParams;
+#endif /* (DPAA_VERSION >= 11) */
+
/**************************************************************************//**
@Function t_FmMacExceptionCallback
@@ -119,7 +141,6 @@ typedef enum e_FmMacStatisticsLevel {
@Param[in] exceptions - The exception that occurred
-
@Return void.
*//***************************************************************************/
typedef void (t_FmMacExceptionCallback)(t_Handle h_App, e_FmMacExceptions exceptions);
@@ -140,17 +161,20 @@ typedef struct t_FmMacStatistics {
/* */
uint64_t eStatFragments; /**< Total number of packets that were less than 64 octets long with a wrong CRC.*/
uint64_t eStatJabbers; /**< Total number of packets longer than valid maximum length octets */
- uint64_t eStatsDropEvents; /**< number of dropped packets due to internal errors of the MAC Client. */
+ uint64_t eStatsDropEvents; /**< number of dropped packets due to internal errors of the MAC Client (during receive). */
uint64_t eStatCRCAlignErrors; /**< Incremented when frames of correct length but with CRC error are received.*/
- uint64_t eStatUndersizePkts; /**< Total number of packets that were less than 64 octets long with a good CRC.*/
- uint64_t eStatOversizePkts; /**< T,B.D*/
+ uint64_t eStatUndersizePkts; /**< Incremented for frames under 64 bytes with a valid FCS and otherwise well formed;
+ This count does not include range length errors */
+ uint64_t eStatOversizePkts; /**< Incremented for frames which exceed 1518 (non VLAN) or 1522 (VLAN) and contains
+ a valid FCS and otherwise well formed */
/* Pause */
uint64_t teStatPause; /**< Pause MAC Control received */
uint64_t reStatPause; /**< Pause MAC Control sent */
-
/* MIB II */
uint64_t ifInOctets; /**< Total number of byte received. */
uint64_t ifInPkts; /**< Total number of packets received.*/
+ uint64_t ifInUcastPkts; /**< Total number of unicast frame received;
+ NOTE: this counter is not supported on dTSEC MAC */
uint64_t ifInMcastPkts; /**< Total number of multicast frame received*/
uint64_t ifInBcastPkts; /**< Total number of broadcast frame received */
uint64_t ifInDiscards; /**< Frames received, but discarded due to problems within the MAC RX. */
@@ -162,6 +186,8 @@ typedef struct t_FmMacStatistics {
- The dedicated Error Code (0xfe, not a code error) was received */
uint64_t ifOutOctets; /**< Total number of byte sent. */
uint64_t ifOutPkts; /**< Total number of packets sent .*/
+ uint64_t ifOutUcastPkts; /**< Total number of unicast frame sent;
+ NOTE: this counter is not supported on dTSEC MAC */
uint64_t ifOutMcastPkts; /**< Total number of multicast frame sent */
uint64_t ifOutBcastPkts; /**< Total number of multicast frame sent */
uint64_t ifOutDiscards; /**< Frames received, but discarded due to problems within the MAC TX N/A!.*/
@@ -173,7 +199,7 @@ typedef struct t_FmMacStatistics {
/**************************************************************************//**
- @Group FM_mac_init_grp Initialization Unit
+ @Group FM_mac_init_grp FM MAC Initialization Unit
@Description FM MAC Initialization Unit
@@ -186,8 +212,24 @@ typedef struct t_FmMacStatistics {
typedef struct t_FmMacParams {
uintptr_t baseAddr; /**< Base of memory mapped FM MAC registers */
t_EnetAddr addr; /**< MAC address of device; First octet is sent first */
- uint8_t macId; /**< MAC ID <dTSEC 0-3> <10G 0> */
- e_EnetMode enetMode; /**< Ethernet operation mode (MAC-PHY interface and speed) */
+ uint8_t macId; /**< MAC ID;
+ numbering of dTSEC and 1G-mEMAC:
+ 0 - FM_MAX_NUM_OF_1G_MACS;
+ numbering of 10G-MAC (TGEC) and 10G-mEMAC:
+ 0 - FM_MAX_NUM_OF_10G_MACS */
+ e_EnetMode enetMode; /**< Ethernet operation mode (MAC-PHY interface and speed);
+ Note that the speed should indicate the maximum rate that
+ this MAC should support rather than the actual speed;
+ i.e. user should use the FM_MAC_AdjustLink() routine to
+ provide accurate speed;
+ In case of mEMAC RGMII mode, the MAC is configured to RGMII
+ automatic mode, where actual speed/duplex mode information
+ is provided by PHY automatically in-band; FM_MAC_AdjustLink()
+ function should be used to switch to manual RGMII speed/duplex mode
+ configuration if RGMII PHY doesn't support in-band status signaling;
+ In addition, in mEMAC, in case where user is using the higher MACs
+ (i.e. the MACs that should support 10G), user should pass here
+ speed=10000 even if the interface is not allowing that (e.g. SGMII). */
t_Handle h_Fm; /**< A handle to the FM object this port related to */
int mdioIrq; /**< MDIO exceptions interrupt source - not valid for all
MACs; MUST be set to 'NO_IRQ' for MACs that don't have
@@ -215,7 +257,7 @@ typedef struct t_FmMacParams {
@Retval Handle to FM MAC object, or NULL for Failure.
*//***************************************************************************/
-t_Handle FM_MAC_Config (t_FmMacParams *p_FmMacParam);
+t_Handle FM_MAC_Config(t_FmMacParams *p_FmMacParam);
/**************************************************************************//**
@Function FM_MAC_Init
@@ -226,7 +268,7 @@ t_Handle FM_MAC_Config (t_FmMacParams *p_FmMacParam);
@Return E_OK on success; Error code otherwise.
*//***************************************************************************/
-t_Error FM_MAC_Init (t_Handle h_FmMac);
+t_Error FM_MAC_Init(t_Handle h_FmMac);
/**************************************************************************//**
@Function FM_Free
@@ -239,11 +281,11 @@ t_Error FM_MAC_Init (t_Handle h_FmMac);
@Return E_OK on success; Error code otherwise.
*//***************************************************************************/
-t_Error FM_MAC_Free (t_Handle h_FmMac);
+t_Error FM_MAC_Free(t_Handle h_FmMac);
/**************************************************************************//**
- @Group FM_mac_advanced_init_grp Advanced Configuration Unit
+ @Group FM_mac_advanced_init_grp FM MAC Advanced Configuration Unit
@Description Configuration functions used to change default values.
@@ -254,7 +296,7 @@ t_Error FM_MAC_Free (t_Handle h_FmMac);
@Function FM_MAC_ConfigResetOnInit
@Description Tell the driver whether to reset the FM MAC before initialization or
- not. It changes the default configuration [FALSE].
+ not. It changes the default configuration [DEFAULT_resetOnInit].
@Param[in] h_FmMac A handle to a FM MAC Module.
@Param[in] enable When TRUE, FM will be reset before any initialization.
@@ -263,7 +305,7 @@ t_Error FM_MAC_Free (t_Handle h_FmMac);
@Cautions Allowed only following FM_MAC_Config() and before FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_ConfigResetOnInit (t_Handle h_FmMac, bool enable);
+t_Error FM_MAC_ConfigResetOnInit(t_Handle h_FmMac, bool enable);
/**************************************************************************//**
@Function FM_MAC_ConfigLoopback
@@ -277,12 +319,12 @@ t_Error FM_MAC_ConfigResetOnInit (t_Handle h_FmMac, bool enable);
@Cautions Allowed only following FM_MAC_Config() and before FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_ConfigLoopback (t_Handle h_FmMac, bool enable);
+t_Error FM_MAC_ConfigLoopback(t_Handle h_FmMac, bool enable);
/**************************************************************************//**
@Function FM_MAC_ConfigMaxFrameLength
- @Description Setup maximum Frame Length
+ @Description Setup maximum Rx Frame Length (in 1G MAC, effects also Tx)
@Param[in] h_FmMac A handle to a FM MAC Module.
@Param[in] newVal MAX Frame length
@@ -291,12 +333,12 @@ t_Error FM_MAC_ConfigLoopback (t_Handle h_FmMac, bool enable);
@Cautions Allowed only following FM_MAC_Config() and before FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_ConfigMaxFrameLength (t_Handle h_FmMac, uint16_t newVal);
+t_Error FM_MAC_ConfigMaxFrameLength(t_Handle h_FmMac, uint16_t newVal);
/**************************************************************************//**
@Function FM_MAC_ConfigWan
- @Description ENABLE WAN mode in 10G MAC
+ @Description ENABLE WAN mode in 10G-MAC
@Param[in] h_FmMac A handle to a FM MAC Module.
@Param[in] enable TRUE to enable or FALSE to disable.
@@ -305,7 +347,7 @@ t_Error FM_MAC_ConfigMaxFrameLength (t_Handle h_FmMac, uint16_t newVal);
@Cautions Allowed only following FM_MAC_Config() and before FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_ConfigWan (t_Handle h_FmMac, bool enable);
+t_Error FM_MAC_ConfigWan(t_Handle h_FmMac, bool enable);
/**************************************************************************//**
@Function FM_MAC_ConfigPadAndCrc
@@ -318,8 +360,11 @@ t_Error FM_MAC_ConfigWan (t_Handle h_FmMac, bool enable);
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_MAC_Config() and before FM_MAC_Init().
+ Not supported on 10G-MAC (i.e. CRC & PAD are added automatically
+ by HW); on mEMAC, this routine supports only PAD (i.e. CRC is
+ added automatically by HW).
*//***************************************************************************/
-t_Error FM_MAC_ConfigPadAndCrc (t_Handle h_FmMac, bool enable);
+t_Error FM_MAC_ConfigPadAndCrc(t_Handle h_FmMac, bool enable);
/**************************************************************************//**
@Function FM_MAC_ConfigHalfDuplex
@@ -333,12 +378,26 @@ t_Error FM_MAC_ConfigPadAndCrc (t_Handle h_FmMac, bool enable);
@Cautions Allowed only following FM_MAC_Config() and before FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_ConfigHalfDuplex (t_Handle h_FmMac, bool enable);
+t_Error FM_MAC_ConfigHalfDuplex(t_Handle h_FmMac, bool enable);
+
+/**************************************************************************//**
+ @Function FM_MAC_ConfigTbiPhyAddr
+
+ @Description Configures the address of internal TBI PHY.
+
+ @Param[in] h_FmMac A handle to a FM MAC Module.
+ @Param[in] newVal TBI PHY address (1-31).
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MAC_Config() and before FM_MAC_Init().
+*//***************************************************************************/
+t_Error FM_MAC_ConfigTbiPhyAddr(t_Handle h_FmMac, uint8_t newVal);
/**************************************************************************//**
@Function FM_MAC_ConfigLengthCheck
- @Description Configure thef frame length checking.
+ @Description Configure the frame length checking.
@Param[in] h_FmMac A handle to a FM MAC Module.
@Param[in] enable TRUE to enable or FALSE to disable.
@@ -347,7 +406,7 @@ t_Error FM_MAC_ConfigHalfDuplex (t_Handle h_FmMac, bool enable);
@Cautions Allowed only following FM_MAC_Config() and before FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_ConfigLengthCheck (t_Handle h_FmMac, bool enable);
+t_Error FM_MAC_ConfigLengthCheck(t_Handle h_FmMac, bool enable);
/**************************************************************************//**
@Function FM_MAC_ConfigException
@@ -358,7 +417,6 @@ t_Error FM_MAC_ConfigLengthCheck (t_Handle h_FmMac, bool enable);
@Param[in] ex Type of the desired exceptions
@Param[in] enable TRUE to enable the specified exception, FALSE to disable it.
-
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_MAC_Config() and before FM_MAC_Init().
@@ -373,7 +431,7 @@ t_Error FM_MAC_ConfigSkipFman11Workaround (t_Handle h_FmMac);
/**************************************************************************//**
- @Group FM_mac_runtime_control_grp Runtime Control Unit
+ @Group FM_mac_runtime_control_grp FM MAC Runtime Control Unit
@Description FM MAC Runtime control unit API functions, definitions and enums.
@@ -392,7 +450,7 @@ t_Error FM_MAC_ConfigSkipFman11Workaround (t_Handle h_FmMac);
@Cautions Allowed only following FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_Enable (t_Handle h_FmMac, e_CommMode mode);
+t_Error FM_MAC_Enable(t_Handle h_FmMac, e_CommMode mode);
/**************************************************************************//**
@Function FM_MAC_Disable
@@ -406,7 +464,20 @@ t_Error FM_MAC_Enable (t_Handle h_FmMac, e_CommMode mode);
@Cautions Allowed only following FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_Disable (t_Handle h_FmMac, e_CommMode mode);
+t_Error FM_MAC_Disable(t_Handle h_FmMac, e_CommMode mode);
+
+/**************************************************************************//**
+ @Function FM_MAC_Resume
+
+ @Description Re-init the MAC after suspend
+
+ @Param[in] h_FmMac A handle to a FM MAC Module.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MAC_Init().
+*//***************************************************************************/
+t_Error FM_MAC_Resume(t_Handle h_FmMac);
/**************************************************************************//**
@Function FM_MAC_Enable1588TimeStamp
@@ -437,56 +508,108 @@ t_Error FM_MAC_Disable1588TimeStamp(t_Handle h_Fm);
/**************************************************************************//**
@Function FM_MAC_SetTxAutoPauseFrames
- @Description Enable/Disable transmition of Pause-Frames.
+ @Description Enable/Disable transmission of Pause-Frames.
+ The routine changes the default configuration [DEFAULT_TX_PAUSE_TIME].
- @Param[in] h_FmMac A handle to a FM MAC Module.
- @Param[in] pauseTime Pause quanta value used with transmitted pause frames.
- Each quanta represents a 512 bit-times; Note that '0'
- as an input here will be used as disabling the
- transmission of the pause-frames.
+ @Param[in] h_FmMac - A handle to a FM MAC Module.
+ @Param[in] pauseTime - Pause quanta value used with transmitted pause frames.
+ Each quanta represents a 512 bit-times; Note that '0'
+ as an input here will be used as disabling the
+ transmission of the pause-frames.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_SetTxAutoPauseFrames (t_Handle h_FmMac, uint16_t pauseTime);
+t_Error FM_MAC_SetTxAutoPauseFrames(t_Handle h_FmMac,
+ uint16_t pauseTime);
+
+ /**************************************************************************//**
+ @Function FM_MAC_SetTxPauseFrames
+
+ @Description Enable/Disable transmission of Pause-Frames.
+ The routine changes the default configuration:
+ pause-time - [DEFAULT_TX_PAUSE_TIME]
+ threshold-time - [0]
+
+ @Param[in] h_FmMac - A handle to a FM MAC Module.
+ @Param[in] priority - the PFC class of service; use 'FM_MAC_NO_PFC'
+ to indicate legacy pause support (i.e. no PFC).
+ @Param[in] pauseTime - Pause quanta value used with transmitted pause frames.
+ Each quanta represents a 512 bit-times;
+ Note that '0' as an input here will be used as disabling the
+ transmission of the pause-frames.
+ @Param[in] threshTime - Pause Threshold equanta value used by the MAC to retransmit pause frame.
+ if the situation causing a pause frame to be sent didn't finish when the timer
+ reached the threshold quanta, the MAC will retransmit the pause frame.
+ Each quanta represents a 512 bit-times.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MAC_Init().
+ In order for PFC to work properly the user must configure
+ TNUM-aging in the tx-port it is recommended that pre-fetch and
+ rate limit in the tx port should be disabled;
+ PFC is supported only on new mEMAC; i.e. in MACs that don't have
+ PFC support (10G-MAC and dTSEC), user should use 'FM_MAC_NO_PFC'
+ in the 'priority' field.
+*//***************************************************************************/
+t_Error FM_MAC_SetTxPauseFrames(t_Handle h_FmMac,
+ uint8_t priority,
+ uint16_t pauseTime,
+ uint16_t threshTime);
/**************************************************************************//**
@Function FM_MAC_SetRxIgnorePauseFrames
@Description Enable/Disable ignoring of Pause-Frames.
- @Param[in] h_FmMac A handle to a FM MAC Module.
- @Param[in] en boolean indicates whether to ignore the incoming pause
- frames or not.
+ @Param[in] h_FmMac - A handle to a FM MAC Module.
+ @Param[in] en - boolean indicates whether to ignore the incoming pause
+ frames or not.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MAC_Init().
+*//***************************************************************************/
+t_Error FM_MAC_SetRxIgnorePauseFrames(t_Handle h_FmMac, bool en);
+
+/**************************************************************************//**
+ @Function FM_MAC_SetWakeOnLan
+
+ @Description Enable/Disable Wake On Lan support
+
+ @Param[in] h_FmMac - A handle to a FM MAC Module.
+ @Param[in] en - boolean indicates whether to enable Wake On Lan
+ support or not.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_SetRxIgnorePauseFrames (t_Handle h_FmMac, bool en);
+t_Error FM_MAC_SetWakeOnLan(t_Handle h_FmMac, bool en);
/**************************************************************************//**
@Function FM_MAC_ResetCounters
@Description reset all statistics counters
- @Param[in] h_FmMac A handle to a FM MAC Module.
+ @Param[in] h_FmMac - A handle to a FM MAC Module.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_ResetCounters (t_Handle h_FmMac);
+t_Error FM_MAC_ResetCounters(t_Handle h_FmMac);
/**************************************************************************//**
@Function FM_MAC_SetException
@Description Enable/Disable a specific Exception
- @Param[in] h_FmMac A handle to a FM MAC Module.
- @Param[in] ex Type of the desired exceptions
- @Param[in] enable TRUE to enable the specified exception, FALSE to disable it.
+ @Param[in] h_FmMac - A handle to a FM MAC Module.
+ @Param[in] ex - Type of the desired exceptions
+ @Param[in] enable - TRUE to enable the specified exception, FALSE to disable it.
@Return E_OK on success; Error code otherwise.
@@ -499,35 +622,36 @@ t_Error FM_MAC_SetException(t_Handle h_FmMac, e_FmMacExceptions ex, bool enable)
@Function FM_MAC_SetStatistics
@Description Define Statistics level.
- Where applicable, the routine also enables the MIB counters
- overflow interrupt in order to keep counters accurate
- and account for overflows.
+ Where applicable, the routine also enables the MIB counters
+ overflow interrupt in order to keep counters accurate
+ and account for overflows.
+ This routine is relevant only for dTSEC.
- @Param[in] h_FmMac A handle to a FM MAC Module.
- @Param[in] statisticsLevel Full statistics level provides all standard counters but may
- reduce performance. Partial statistics provides only special
- event counters (errors etc.). If selected, regular counters (such as
- byte/packet) will be invalid and will return -1.
+ @Param[in] h_FmMac - A handle to a FM MAC Module.
+ @Param[in] statisticsLevel - Full statistics level provides all standard counters but may
+ reduce performance. Partial statistics provides only special
+ event counters (errors etc.). If selected, regular counters (such as
+ byte/packet) will be invalid and will return -1.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_SetStatistics (t_Handle h_FmMac, e_FmMacStatisticsLevel statisticsLevel);
+t_Error FM_MAC_SetStatistics(t_Handle h_FmMac, e_FmMacStatisticsLevel statisticsLevel);
/**************************************************************************//**
@Function FM_MAC_GetStatistics
@Description get all statistics counters
- @Param[in] h_FmMac A handle to a FM MAC Module.
- @Param[in] p_Statistics Staructure with statistics
+ @Param[in] h_FmMac - A handle to a FM MAC Module.
+ @Param[in] p_Statistics - Structure with statistics
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_Init().
*//***************************************************************************/
-t_Error FM_MAC_GetStatistics (t_Handle h_FmMac, t_FmMacStatistics *p_Statistics);
+t_Error FM_MAC_GetStatistics(t_Handle h_FmMac, t_FmMacStatistics *p_Statistics);
/**************************************************************************//**
@Function FM_MAC_ModifyMacAddr
@@ -541,7 +665,7 @@ t_Error FM_MAC_GetStatistics (t_Handle h_FmMac, t_FmMacStatistics *p_Statistics)
@Cautions Allowed only after FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_ModifyMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
+t_Error FM_MAC_ModifyMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
/**************************************************************************//**
@Function FM_MAC_AddHashMacAddr
@@ -556,7 +680,7 @@ t_Error FM_MAC_ModifyMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
@Cautions Allowed only following FM_MAC_Init(). It is a filter only address.
@Cautions Some address need to be filterd out in upper FM blocks.
*//***************************************************************************/
-t_Error FM_MAC_AddHashMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
+t_Error FM_MAC_AddHashMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
/**************************************************************************//**
@Function FM_MAC_RemoveHashMacAddr
@@ -570,7 +694,7 @@ t_Error FM_MAC_AddHashMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
@Cautions Allowed only following FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_RemoveHashMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
+t_Error FM_MAC_RemoveHashMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
/**************************************************************************//**
@Function FM_MAC_AddExactMatchMacAddr
@@ -585,7 +709,7 @@ t_Error FM_MAC_RemoveHashMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
@Cautions Allowed only after FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_AddExactMatchMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
+t_Error FM_MAC_AddExactMatchMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
/**************************************************************************//**
@Function FM_MAC_RemovelExactMatchMacAddr
@@ -599,7 +723,7 @@ t_Error FM_MAC_AddExactMatchMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
@Cautions Allowed only after FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_RemovelExactMatchMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
+t_Error FM_MAC_RemovelExactMatchMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
/**************************************************************************//**
@Function FM_MAC_SetPromiscuous
@@ -613,23 +737,46 @@ t_Error FM_MAC_RemovelExactMatchMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAdd
@Cautions Allowed only after FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_SetPromiscuous (t_Handle h_FmMac, bool enable);
+t_Error FM_MAC_SetPromiscuous(t_Handle h_FmMac, bool enable);
/**************************************************************************//**
@Function FM_MAC_AdjustLink
@Description Adjusts the Ethernet link with new speed/duplex setup.
+ This routine is relevant for dTSEC and mEMAC.
+ In case of mEMAC, this routine is also used for manual
+ re-configuration of RGMII speed and duplex mode for
+ RGMII PHYs not supporting in-band status information
+ to MAC.
@Param[in] h_FmMac - A handle to a FM Module.
@Param[in] speed - Ethernet speed.
- @Param[in] fullDuplex - TRUE for Full-Duplex mode;
- FALSE for Half-Duplex mode.
+ @Param[in] fullDuplex - TRUE for full-duplex mode;
+ FALSE for half-duplex mode.
@Return E_OK on success; Error code otherwise.
*//***************************************************************************/
t_Error FM_MAC_AdjustLink(t_Handle h_FmMac, e_EnetSpeed speed, bool fullDuplex);
/**************************************************************************//**
+ @Function FM_MAC_RestartAutoneg
+
+ @Description Restarts the auto-negotiation process.
+ When auto-negotiation process is invoked under traffic the
+ auto-negotiation process between the internal SGMII PHY and the
+ external PHY does not always complete successfully. Calling this
+ function will restart the auto-negotiation process that will end
+ successfully. It is recommended to call this function after issuing
+ auto-negotiation restart command to the Eth Phy.
+ This routine is relevant only for dTSEC.
+
+ @Param[in] h_FmMac - A handle to a FM Module.
+
+ @Return E_OK on success; Error code otherwise.
+*//***************************************************************************/
+t_Error FM_MAC_RestartAutoneg(t_Handle h_FmMac);
+
+/**************************************************************************//**
@Function FM_MAC_GetId
@Description Return the MAC ID
@@ -641,7 +788,7 @@ t_Error FM_MAC_AdjustLink(t_Handle h_FmMac, e_EnetSpeed speed, bool fullDuplex);
@Cautions Allowed only after FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_GetId (t_Handle h_FmMac, uint32_t *p_MacId);
+t_Error FM_MAC_GetId(t_Handle h_FmMac, uint32_t *p_MacId);
/**************************************************************************//**
@Function FM_MAC_GetVesrion
@@ -655,7 +802,7 @@ t_Error FM_MAC_GetId (t_Handle h_FmMac, uint32_t *p_MacId);
@Cautions Allowed only after FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_GetVesrion (t_Handle h_FmMac, uint32_t *p_MacVresion);
+t_Error FM_MAC_GetVesrion(t_Handle h_FmMac, uint32_t *p_MacVresion);
/**************************************************************************//**
@Function FM_MAC_MII_WritePhyReg
@@ -671,7 +818,7 @@ t_Error FM_MAC_GetVesrion (t_Handle h_FmMac, uint32_t *p_MacVresion);
@Cautions Allowed only after FM_MAC_Init().
*//***************************************************************************/
-t_Error FM_MAC_MII_WritePhyReg (t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, uint16_t data);
+t_Error FM_MAC_MII_WritePhyReg(t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, uint16_t data);
/**************************************************************************//**
@Function FM_MAC_MII_ReadPhyReg
@@ -709,5 +856,4 @@ t_Error FM_MAC_DumpRegs(t_Handle h_FmMac);
/** @} */ /* end of FM_grp group */
-
#endif /* __FM_MAC_EXT_H */
diff --git a/sys/contrib/ncsw/inc/Peripherals/fm_macsec_ext.h b/sys/contrib/ncsw/inc/Peripherals/fm_macsec_ext.h
new file mode 100644
index 000000000000..57925f1040b9
--- /dev/null
+++ b/sys/contrib/ncsw/inc/Peripherals/fm_macsec_ext.h
@@ -0,0 +1,1271 @@
+/*
+ * Copyright 2008-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**************************************************************************//**
+ @File fm_macsec_ext.h
+
+ @Description FM MACSEC ...
+*//***************************************************************************/
+#ifndef __FM_MACSEC_EXT_H
+#define __FM_MACSEC_EXT_H
+
+#include "std_ext.h"
+
+
+/**************************************************************************//**
+ @Group FM_grp Frame Manager API
+
+ @Description FM API functions, definitions and enums
+
+ @{
+*//***************************************************************************/
+
+/**************************************************************************//**
+ @Group FM_MACSEC_grp FM MACSEC
+
+ @Description FM MACSEC API functions, definitions and enums
+
+ @{
+*//***************************************************************************/
+
+/**************************************************************************//**
+ @Description MACSEC Exceptions
+*//***************************************************************************/
+typedef enum e_FmMacsecExceptions {
+ e_FM_MACSEC_EX_SINGLE_BIT_ECC, /**< Single bit ECC error */
+ e_FM_MACSEC_EX_MULTI_BIT_ECC /**< Multi bit ECC error */
+} e_FmMacsecExceptions;
+
+
+/**************************************************************************//**
+ @Group FM_MACSEC_init_grp FM-MACSEC Initialization Unit
+
+ @Description FM MACSEC Initialization Unit
+
+ @{
+*//***************************************************************************/
+
+/**************************************************************************//**
+ @Function t_FmMacsecExceptionsCallback
+
+ @Description Exceptions user callback routine, will be called upon an
+ exception passing the exception identification.
+
+ @Param[in] h_App A handle to an application layer object; This handle
+ will be passed by the driver upon calling this callback.
+ @Param[in] exception The exception.
+*//***************************************************************************/
+typedef void (t_FmMacsecExceptionsCallback) ( t_Handle h_App,
+ e_FmMacsecExceptions exception);
+
+
+/**************************************************************************//**
+ @Description FM MACSEC config input
+*//***************************************************************************/
+typedef struct t_FmMacsecParams {
+ t_Handle h_Fm; /**< A handle to the FM object related to */
+ bool guestMode; /**< Partition-id */
+ union {
+ struct {
+ uint8_t fmMacId; /**< FM MAC id */
+ } guestParams;
+
+ struct {
+ uintptr_t baseAddr; /**< Base of memory mapped FM MACSEC registers */
+ t_Handle h_FmMac; /**< A handle to the FM MAC object related to */
+ t_FmMacsecExceptionsCallback *f_Exception; /**< Exception Callback Routine */
+ t_Handle h_App; /**< A handle to an application layer object; This handle will
+ be passed by the driver upon calling the above callbacks */
+ } nonGuestParams;
+ };
+} t_FmMacsecParams;
+
+/**************************************************************************//**
+ @Function FM_MACSEC_Config
+
+ @Description Creates descriptor for the FM MACSEC module;
+
+ The routine returns a handle (descriptor) to the FM MACSEC object;
+ This descriptor must be passed as first parameter to all other
+ FM MACSEC function calls;
+
+ No actual initialization or configuration of FM MACSEC hardware is
+ done by this routine.
+
+ @Param[in] p_FmMacsecParam Pointer to data structure of parameters.
+
+ @Retval Handle to FM MACSEC object, or NULL for Failure.
+*//***************************************************************************/
+t_Handle FM_MACSEC_Config(t_FmMacsecParams *p_FmMacsecParam);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_Init
+
+ @Description Initializes the FM MACSEC module.
+
+ @Param[in] h_FmMacsec FM MACSEC module descriptor.
+
+ @Return E_OK on success; Error code otherwise.
+*//***************************************************************************/
+t_Error FM_MACSEC_Init(t_Handle h_FmMacsec);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_Free
+
+ @Description Frees all resources that were assigned to FM MACSEC module;
+
+ Calling this routine invalidates the descriptor.
+
+ @Param[in] h_FmMacsec FM MACSEC module descriptor.
+
+ @Return E_OK on success; Error code otherwise.
+*//***************************************************************************/
+t_Error FM_MACSEC_Free(t_Handle h_FmMacsec);
+
+
+/**************************************************************************//**
+ @Group FM_MACSEC_advanced_init_grp FM-MACSEC Advanced Configuration Unit
+
+ @Description Configuration functions used to change default values.
+
+ @{
+*//***************************************************************************/
+
+/**************************************************************************//**
+ @Description enum for unknown sci frame treatment
+*//***************************************************************************/
+typedef enum e_FmMacsecUnknownSciFrameTreatment {
+ e_FM_MACSEC_UNKNOWN_SCI_FRAME_TREATMENT_DISCARD_BOTH = 0, /**< Controlled port - Strict mode */
+ e_FM_MACSEC_UNKNOWN_SCI_FRAME_TREATMENT_DISCARD_UNCONTROLLED_DELIVER_OR_DISCARD_CONTROLLED, /**< If C bit clear deliver on controlled port, else discard
+ Controlled port - Check or Disable mode */
+ e_FM_MACSEC_UNKNOWN_SCI_FRAME_TREATMENT_DELIVER_UNCONTROLLED_DISCARD_CONTROLLED, /**< Controlled port - Strict mode */
+ e_FM_MACSEC_UNKNOWN_SCI_FRAME_TREATMENT_DELIVER_OR_DISCARD_UNCONTROLLED_DELIVER_OR_DISCARD_CONTROLLED /**< If C bit set deliver on uncontrolled port and discard on controlled port,
+ else discard on uncontrolled port and deliver on controlled port
+ Controlled port - Check or Disable mode */
+} e_FmMacsecUnknownSciFrameTreatment;
+
+/**************************************************************************//**
+ @Description enum for untag frame treatment
+*//***************************************************************************/
+typedef enum e_FmMacsecUntagFrameTreatment {
+ e_FM_MACSEC_UNTAG_FRAME_TREATMENT_DELIVER_UNCONTROLLED_DISCARD_CONTROLLED = 0, /**< Controlled port - Strict mode */
+ e_FM_MACSEC_UNTAG_FRAME_TREATMENT_DISCARD_BOTH, /**< Controlled port - Strict mode */
+ e_FM_MACSEC_UNTAG_FRAME_TREATMENT_DISCARD_UNCONTROLLED_DELIVER_CONTROLLED_UNMODIFIED /**< Controlled port - Strict mode */
+} e_FmMacsecUntagFrameTreatment;
+
+/**************************************************************************//**
+ @Function FM_MACSEC_ConfigUnknownSciFrameTreatment
+
+ @Description Change the treatment for received frames with unknown sci from its default
+ configuration [DEFAULT_unknownSciFrameTreatment].
+
+ @Param[in] h_FmMacsec FM MACSEC module descriptor.
+ @Param[in] treatMode The selected mode.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_ConfigUnknownSciFrameTreatment(t_Handle h_FmMacsec, e_FmMacsecUnknownSciFrameTreatment treatMode);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_ConfigInvalidTagsFrameTreatment
+
+ @Description Change the treatment for received frames with invalid tags or
+ a zero value PN or an invalid ICV from its default configuration
+ [DEFAULT_invalidTagsFrameTreatment].
+
+ @Param[in] h_FmMacsec FM MACSEC module descriptor.
+ @Param[in] deliverUncontrolled If True deliver on the uncontrolled port, else discard;
+ In both cases discard on the controlled port;
+ this provide Strict, Check or Disable mode.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_ConfigInvalidTagsFrameTreatment(t_Handle h_FmMacsec, bool deliverUncontrolled);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_ConfigEncryptWithNoChangedTextFrameTreatment
+
+ @Description Change the treatment for received frames with the Encryption bit
+ set and the Changed Text bit clear from its default configuration
+ [DEFAULT_encryptWithNoChangedTextFrameTreatment].
+
+ @Param[in] h_FmMacsec FM MACSEC module descriptor.
+ @Param[in] discardUncontrolled If True discard on the uncontrolled port, else deliver;
+ In both cases discard on the controlled port;
+ this provide Strict, Check or Disable mode.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_ConfigEncryptWithNoChangedTextFrameTreatment(t_Handle h_FmMacsec, bool discardUncontrolled);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_ConfigChangedTextWithNoEncryptFrameTreatment
+
+ @Description Change the treatment for received frames with the Encryption bit
+ clear and the Changed Text bit set from its default configuration
+ [DEFAULT_changedTextWithNoEncryptFrameTreatment].
+
+ @Param[in] h_FmMacsec FM MACSEC module descriptor.
+ @Param[in] deliverUncontrolled If True deliver on the uncontrolled port, else discard;
+ In both cases discard on the controlled port;
+ this provide Strict, Check or Disable mode.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_ConfigChangedTextWithNoEncryptFrameTreatment(t_Handle h_FmMacsec, bool deliverUncontrolled);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_ConfigUntagFrameTreatment
+
+ @Description Change the treatment for received frames without the MAC security tag (SecTAG)
+ from its default configuration [DEFAULT_untagFrameTreatment].
+
+ @Param[in] h_FmMacsec FM MACSEC module descriptor.
+ @Param[in] treatMode The selected mode.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_ConfigUntagFrameTreatment(t_Handle h_FmMacsec, e_FmMacsecUntagFrameTreatment treatMode);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_ConfigOnlyScbIsSetFrameTreatment
+
+ @Description Change the treatment for received frames with only SCB bit set
+ from its default configuration [DEFAULT_onlyScbIsSetFrameTreatment].
+
+ @Param[in] h_FmMacsec FM MACSEC module descriptor.
+ @Param[in] deliverUncontrolled If True deliver on the uncontrolled port, else discard;
+ In both cases discard on the controlled port;
+ this provide Strict, Check or Disable mode.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_ConfigOnlyScbIsSetFrameTreatment(t_Handle h_FmMacsec, bool deliverUncontrolled);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_ConfigPnExhaustionThreshold
+
+ @Description It's provide the ability to configure a PN exhaustion threshold;
+ When the NextPn crosses this value an interrupt event
+ is asserted to warn that the active SA should re-key.
+
+ @Param[in] h_FmMacsec FM MACSEC module descriptor.
+ @Param[in] pnExhThr If the threshold is reached, an interrupt event
+ is asserted to re-key.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_ConfigPnExhaustionThreshold(t_Handle h_FmMacsec, uint32_t pnExhThr);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_ConfigKeysUnreadable
+
+ @Description Turn on privacy mode; All the keys and their hash values can't be read any more;
+ Can not be cleared unless hard reset.
+
+ @Param[in] h_FmMacsec FM MACSEC module descriptor.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_ConfigKeysUnreadable(t_Handle h_FmMacsec);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_ConfigSectagWithoutSCI
+
+ @Description Promise that all generated Sectag will be without SCI included.
+
+ @Param[in] h_FmMacsec FM MACSEC module descriptor.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_ConfigSectagWithoutSCI(t_Handle h_FmMacsec);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_ConfigException
+
+ @Description Calling this routine changes the internal driver data base
+ from its default selection of exceptions enablement;
+ By default all exceptions are enabled.
+
+ @Param[in] h_FmMacsec FM MACSEC module descriptor.
+ @Param[in] exception The exception to be selected.
+ @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_Config() and before FM_MACSEC_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_ConfigException(t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable);
+
+/** @} */ /* end of FM_MACSEC_advanced_init_grp group */
+/** @} */ /* end of FM_MACSEC_init_grp group */
+
+
+/**************************************************************************//**
+ @Group FM_MACSEC_runtime_control_grp FM-MACSEC Runtime Control Data Unit
+
+ @Description FM MACSEC runtime control data unit API functions, definitions and enums.
+
+ @{
+*//***************************************************************************/
+
+/**************************************************************************//**
+ @Function FM_MACSEC_GetRevision
+
+ @Description Return MACSEC HW chip revision
+
+ @Param[in] h_FmMacsec FM MACSEC module descriptor.
+ @Param[out] p_MacsecRevision MACSEC revision as defined by the chip.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only after FM_MACSEC_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_GetRevision(t_Handle h_FmMacsec, uint32_t *p_MacsecRevision);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_Enable
+
+ @Description This routine should be called after MACSEC is initialized for enabling all
+ MACSEC engines according to their existing configuration.
+
+ @Param[in] h_FmMacsec FM MACSEC module descriptor.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_Init() and when MACSEC is disabled.
+*//***************************************************************************/
+t_Error FM_MACSEC_Enable(t_Handle h_FmMacsec);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_Disable
+
+ @Description This routine may be called when MACSEC is enabled in order to
+ disable all MACSEC engines; The MACSEC is working in bypass mode.
+
+ @Param[in] h_FmMacsec FM MACSEC module descriptor.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_Init() and when MACSEC is enabled.
+*//***************************************************************************/
+t_Error FM_MACSEC_Disable(t_Handle h_FmMacsec);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SetException
+
+ @Description Calling this routine enables/disables the specified exception.
+
+ @Param[in] h_FmMacsec FM MACSEC module descriptor.
+ @Param[in] exception The exception to be selected.
+ @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_SetException(t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable);
+
+#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
+/**************************************************************************//**
+ @Function FM_MACSEC_DumpRegs
+
+ @Description Dump internal registers.
+
+ @Param[in] h_FmMacsec - FM MACSEC module descriptor.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only after FM_MACSEC_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_DumpRegs(t_Handle h_FmMacsec);
+#endif /* (defined(DEBUG_ERRORS) && ... */
+
+#ifdef VERIFICATION_SUPPORT
+/********************* VERIFICATION ONLY ********************************/
+/**************************************************************************//**
+ @Function FM_MACSEC_BackdoorSet
+
+ @Description Set register of the MACSEC memory map
+
+ @Param[in] h_FmMacsec FM MACSEC module descriptor.
+ @Param[out] offset Register offset.
+ @Param[out] value Value to write.
+
+
+ @Return None
+
+ @Cautions Allowed only following FM_MACSEC_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_BackdoorSet(t_Handle h_FmMacsec, uint32_t offset, uint32_t value);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_BackdoorGet
+
+ @Description Read from register of the MACSEC memory map.
+
+ @Param[in] h_FmMacsec FM MACSEC module descriptor.
+ @Param[out] offset Register offset.
+
+ @Return Value read
+
+ @Cautions Allowed only following FM_MACSEC_Init().
+*//***************************************************************************/
+uint32_t FM_MACSEC_BackdoorGet(t_Handle h_FmMacsec, uint32_t offset);
+#endif /* VERIFICATION_SUPPORT */
+
+/** @} */ /* end of FM_MACSEC_runtime_control_grp group */
+
+
+/**************************************************************************//**
+ @Group FM_MACSEC_SECY_grp FM-MACSEC SecY
+
+ @Description FM-MACSEC SecY API functions, definitions and enums
+
+ @{
+*//***************************************************************************/
+
+typedef uint8_t macsecSAKey_t[32];
+typedef uint64_t macsecSCI_t;
+typedef uint8_t macsecAN_t;
+
+/**************************************************************************//**
+@Description MACSEC SECY Cipher Suite
+*//***************************************************************************/
+typedef enum e_FmMacsecSecYCipherSuite {
+ e_FM_MACSEC_SECY_GCM_AES_128 = 0, /**< GCM-AES-128 */
+#if (DPAA_VERSION >= 11)
+ e_FM_MACSEC_SECY_GCM_AES_256 /**< GCM-AES-256 */
+#endif /* (DPAA_VERSION >= 11) */
+} e_FmMacsecSecYCipherSuite;
+
+/**************************************************************************//**
+ @Description MACSEC SECY Exceptions
+*//***************************************************************************/
+typedef enum e_FmMacsecSecYExceptions {
+ e_FM_MACSEC_SECY_EX_FRAME_DISCARDED /**< Frame Discarded */
+} e_FmMacsecSecYExceptions;
+
+/**************************************************************************//**
+ @Description MACSEC SECY Events
+*//***************************************************************************/
+typedef enum e_FmMacsecSecYEvents {
+ e_FM_MACSEC_SECY_EV_NEXT_PN /**< Next Packet Number exhaustion threshold reached */
+} e_FmMacsecSecYEvents;
+
+/**************************************************************************//**
+ @Collection MACSEC SECY Frame Discarded Descriptor error
+*//***************************************************************************/
+typedef uint8_t macsecTxScFrameDiscardedErrSelect_t; /**< typedef for defining Frame Discarded Descriptor errors */
+
+#define FM_MACSEC_SECY_TX_SC_FRM_DISCAR_ERR_NEXT_PN_ZERO 0x8000 /**< NextPn == 0 */
+#define FM_MACSEC_SECY_TX_SC_FRM_DISCAR_ERR_SC_DISBALE 0x4000 /**< SC is disable */
+/* @} */
+
+/**************************************************************************//**
+ @Function t_FmMacsecSecYExceptionsCallback
+
+ @Description Exceptions user callback routine, will be called upon an
+ exception passing the exception identification.
+
+ @Param[in] h_App A handle to an application layer object; This handle
+ will be passed by the driver upon calling this callback.
+ @Param[in] exception The exception.
+*//***************************************************************************/
+typedef void (t_FmMacsecSecYExceptionsCallback) ( t_Handle h_App,
+ e_FmMacsecSecYExceptions exception);
+
+/**************************************************************************//**
+ @Function t_FmMacsecSecYEventsCallback
+
+ @Description Events user callback routine, will be called upon an
+ event passing the event identification.
+
+ @Param[in] h_App A handle to an application layer object; This handle
+ will be passed by the driver upon calling this callback.
+ @Param[in] event The event.
+*//***************************************************************************/
+typedef void (t_FmMacsecSecYEventsCallback) ( t_Handle h_App,
+ e_FmMacsecSecYEvents event);
+
+/**************************************************************************//**
+ @Description RFC2863 MIB
+*//***************************************************************************/
+typedef struct t_MIBStatistics {
+ uint64_t ifInOctets; /**< Total number of byte received */
+ uint64_t ifInPkts; /**< Total number of packets received */
+ uint64_t ifInMcastPkts; /**< Total number of multicast frame received */
+ uint64_t ifInBcastPkts; /**< Total number of broadcast frame received */
+ uint64_t ifInDiscards; /**< Frames received, but discarded due to problems within the MAC RX :
+ - InPktsNoTag,
+ - InPktsLate,
+ - InPktsOverrun */
+ uint64_t ifInErrors; /**< Number of frames received with error:
+ - InPktsBadTag,
+ - InPktsNoSCI,
+ - InPktsNotUsingSA
+ - InPktsNotValid */
+ uint64_t ifOutOctets; /**< Total number of byte sent */
+ uint64_t ifOutPkts; /**< Total number of packets sent */
+ uint64_t ifOutMcastPkts; /**< Total number of multicast frame sent */
+ uint64_t ifOutBcastPkts; /**< Total number of multicast frame sent */
+ uint64_t ifOutDiscards; /**< Frames received, but discarded due to problems within the MAC TX N/A! */
+ uint64_t ifOutErrors; /**< Number of frames transmitted with error:
+ - FIFO Overflow Error
+ - FIFO Underflow Error
+ - Other */
+} t_MIBStatistics;
+
+/**************************************************************************//**
+ @Description MACSEC SecY Rx SA Statistics
+*//***************************************************************************/
+typedef struct t_FmMacsecSecYRxSaStatistics {
+ uint32_t inPktsOK; /**< The number of frames with resolved SCI, have passed all
+ frame validation frame validation with the validateFrame not set to disable */
+ uint32_t inPktsInvalid; /**< The number of frames with resolved SCI, that have failed frame
+ validation with the validateFrame set to check */
+ uint32_t inPktsNotValid; /**< The number of frames with resolved SCI, discarded on the controlled port,
+ that have failed frame validation with the validateFrame set to strict or the c bit is set */
+ uint32_t inPktsNotUsingSA; /**< The number of frames received with resolved SCI and discarded on disabled or
+ not provisioned SA with validateFrame in the strict mode or the C bit is set */
+ uint32_t inPktsUnusedSA; /**< The number of frames received with resolved SCI on disabled or not provisioned SA
+ with validateFrame not in the strict mode and the C bit is cleared */
+} t_FmMacsecSecYRxSaStatistics;
+
+/**************************************************************************//**
+ @Description MACSEC SecY Tx SA Statistics
+*//***************************************************************************/
+typedef struct t_FmMacsecSecYTxSaStatistics {
+ uint64_t outPktsProtected; /**< The number of frames, that the user of the controlled port requested to
+ be transmitted, which were integrity protected */
+ uint64_t outPktsEncrypted; /**< The number of frames, that the user of the controlled port requested to
+ be transmitted, which were confidentiality protected */
+} t_FmMacsecSecYTxSaStatistics;
+
+/**************************************************************************//**
+ @Description MACSEC SecY Rx SC Statistics
+*//***************************************************************************/
+typedef struct t_FmMacsecSecYRxScStatistics {
+ uint64_t inPktsUnchecked; /**< The number of frames with resolved SCI, delivered to the user of a controlled port,
+ that are not validated with the validateFrame set to disable */
+ uint64_t inPktsDelayed; /**< The number of frames with resolved SCI, delivered to the user of a controlled port,
+ that have their PN smaller than the lowest_PN with the validateFrame set to
+ disable or replayProtect disabled */
+ uint64_t inPktsLate; /**< The number of frames with resolved SCI, discarded on the controlled port,
+ that have their PN smaller than the lowest_PN with the validateFrame set to
+ Check or Strict and replayProtect enabled */
+ uint64_t inPktsOK; /**< The number of frames with resolved SCI, have passed all
+ frame validation frame validation with the validateFrame not set to disable */
+ uint64_t inPktsInvalid; /**< The number of frames with resolved SCI, that have failed frame
+ validation with the validateFrame set to check */
+ uint64_t inPktsNotValid; /**< The number of frames with resolved SCI, discarded on the controlled port,
+ that have failed frame validation with the validateFrame set to strict or the c bit is set */
+ uint64_t inPktsNotUsingSA; /**< The number of frames received with resolved SCI and discarded on disabled or
+ not provisioned SA with validateFrame in the strict mode or the C bit is set */
+ uint64_t inPktsUnusedSA; /**< The number of frames received with resolved SCI on disabled or not provisioned SA
+ with validateFrame not in the strict mode and the C bit is cleared */
+} t_FmMacsecSecYRxScStatistics;
+
+/**************************************************************************//**
+ @Description MACSEC SecY Tx SC Statistics
+*//***************************************************************************/
+typedef struct t_FmMacsecSecYTxScStatistics {
+ uint64_t outPktsProtected; /**< The number of frames, that the user of the controlled port requested to
+ be transmitted, which were integrity protected */
+ uint64_t outPktsEncrypted; /**< The number of frames, that the user of the controlled port requested to
+ be transmitted, which were confidentiality protected */
+} t_FmMacsecSecYTxScStatistics;
+
+/**************************************************************************//**
+ @Description MACSEC SecY Statistics
+*//***************************************************************************/
+typedef struct t_FmMacsecSecYStatistics {
+ t_MIBStatistics mibCtrlStatistics; /**< Controlled port MIB statistics */
+ t_MIBStatistics mibNonCtrlStatistics; /**< Uncontrolled port MIB statistics */
+/* Frame verification statistics */
+ uint64_t inPktsUntagged; /**< The number of received packets without the MAC security tag
+ (SecTAG) with validateFrames which is not in the strict mode */
+ uint64_t inPktsNoTag; /**< The number of received packets discarded without the
+ MAC security tag (SecTAG) with validateFrames which is in the strict mode */
+ uint64_t inPktsBadTag; /**< The number of received packets discarded with an invalid
+ SecTAG or a zero value PN or an invalid ICV */
+ uint64_t inPktsUnknownSCI; /**< The number of received packets with unknown SCI with the
+ condition : validateFrames is not in the strict mode and the
+ C bit in the SecTAG is not set */
+ uint64_t inPktsNoSCI; /**< The number of received packets discarded with unknown SCI
+ information with the condition : validateFrames is in the strict mode
+ or the C bit in the SecTAG is set */
+ uint64_t inPktsOverrun; /**< The number of packets discarded because the number of
+ received packets exceeded the cryptographic performance capabilities */
+/* Frame validation statistics */
+ uint64_t inOctetsValidated; /**< The number of octets of plaintext recovered from received frames with
+ resolved SCI that were integrity protected but not encrypted */
+ uint64_t inOctetsDecrypted; /**< The number of octets of plaintext recovered from received frames with
+ resolved SCI that were integrity protected and encrypted */
+/* Frame generation statistics */
+ uint64_t outPktsUntagged; /**< The number of frames, that the user of the controlled port requested to
+ be transmitted, with protectFrame false */
+ uint64_t outPktsTooLong; /**< The number of frames, that the user of the controlled port requested to
+ be transmitted, discarded due to length being larger than Maximum Frame Length (MACSEC_MFL) */
+/* Frame protection statistics */
+ uint64_t outOctetsProtected; /**< The number of octets of User Data in transmitted frames that were
+ integrity protected but not encrypted */
+ uint64_t outOctetsEncrypted; /**< The number of octets of User Data in transmitted frames that were
+ both integrity protected and encrypted */
+} t_FmMacsecSecYStatistics;
+
+
+/**************************************************************************//**
+ @Description MACSEC SecY SC Params
+*//***************************************************************************/
+typedef struct t_FmMacsecSecYSCParams {
+ macsecSCI_t sci; /**< The secure channel identification of the SC */
+ e_FmMacsecSecYCipherSuite cipherSuite; /**< Cipher suite to be used for the SC */
+} t_FmMacsecSecYSCParams;
+
+/**************************************************************************//**
+ @Group FM_MACSEC_SECY_init_grp FM-MACSEC SecY Initialization Unit
+
+ @Description FM-MACSEC SecY Initialization Unit
+
+ @{
+*//***************************************************************************/
+
+/**************************************************************************//**
+ @Description enum for validate frames
+*//***************************************************************************/
+typedef enum e_FmMacsecValidFrameBehavior {
+ e_FM_MACSEC_VALID_FRAME_BEHAVIOR_DISABLE = 0, /**< disable the validation function */
+ e_FM_MACSEC_VALID_FRAME_BEHAVIOR_CHECK, /**< enable the validation function but only for checking
+ without filtering out invalid frames */
+ e_FM_MACSEC_VALID_FRAME_BEHAVIOR_STRICT /**< enable the validation function and also strictly filter
+ out those invalid frames */
+} e_FmMacsecValidFrameBehavior;
+
+/**************************************************************************//**
+ @Description enum for sci insertion
+*//***************************************************************************/
+typedef enum e_FmMacsecSciInsertionMode {
+ e_FM_MACSEC_SCI_INSERTION_MODE_EXPLICIT_SECTAG = 0, /**< explicit sci in the sectag */
+ e_FM_MACSEC_SCI_INSERTION_MODE_EXPLICIT_MAC_SA, /**< mac sa is overwritten with the sci*/
+ e_FM_MACSEC_SCI_INSERTION_MODE_IMPLICT_PTP /**< implicit point-to-point sci (pre-shared) */
+} e_FmMacsecSciInsertionMode;
+
+/**************************************************************************//**
+ @Description FM MACSEC SecY config input
+*//***************************************************************************/
+typedef struct t_FmMacsecSecYParams {
+ t_Handle h_FmMacsec; /**< A handle to the FM MACSEC object */
+ t_FmMacsecSecYSCParams txScParams; /**< Tx SC Params */
+ uint32_t numReceiveChannels; /**< Number of receive channels dedicated to this SecY */
+ t_FmMacsecSecYExceptionsCallback *f_Exception; /**< Callback routine to be called by the driver upon SecY exception */
+ t_FmMacsecSecYEventsCallback *f_Event; /**< Callback routine to be called by the driver upon SecY event */
+ t_Handle h_App; /**< A handle to an application layer object; This handle will
+ be passed by the driver upon calling the above callbacks */
+} t_FmMacsecSecYParams;
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_Config
+
+ @Description Creates descriptor for the FM MACSEC SECY module;
+
+ The routine returns a handle (descriptor) to the FM MACSEC SECY object;
+ This descriptor must be passed as first parameter to all other
+ FM MACSEC SECY function calls;
+ No actual initialization or configuration of FM MACSEC SecY hardware is
+ done by this routine.
+
+ @Param[in] p_FmMacsecSecYParam Pointer to data structure of parameters.
+
+ @Return Handle to FM MACSEC SECY object, or NULL for Failure.
+*//***************************************************************************/
+t_Handle FM_MACSEC_SECY_Config(t_FmMacsecSecYParams *p_FmMacsecSecYParam);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_Init
+
+ @Description Initializes the FM MACSEC SECY module.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+
+ @Return E_OK on success; Error code otherwise.
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_Init(t_Handle h_FmMacsecSecY);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_Free
+
+ @Description Frees all resources that were assigned to FM MACSEC SECY module.
+
+ Calling this routine invalidates the descriptor.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+
+ @Return E_OK on success; Error code otherwise.
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_Free(t_Handle h_FmMacsecSecY);
+
+/**************************************************************************//**
+ @Group FM_MACSEC_SECY_advanced_init_grp FM-MACSEC SecY Advanced Configuration Unit
+
+ @Description Configuration functions used to change default values.
+
+ @{
+*//***************************************************************************/
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_ConfigSciInsertionMode
+
+ @Description Calling this routine changes the SCI-insertion-mode in the
+ internal driver data base from its default configuration
+ [DEFAULT_sciInsertionMode]
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] sciInsertionMode Sci insertion mode
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Config() and before FM_MACSEC_SECY_Init();
+
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_ConfigSciInsertionMode(t_Handle h_FmMacsecSecY, e_FmMacsecSciInsertionMode sciInsertionMode);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_ConfigProtectFrames
+
+ @Description Calling this routine changes the protect-frame mode in the
+ internal driver data base from its default configuration
+ [DEFAULT_protectFrames]
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] protectFrames If FALSE, frames are transmitted without modification
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Config() and before FM_MACSEC_SECY_Init();
+
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_ConfigProtectFrames(t_Handle h_FmMacsecSecY, bool protectFrames);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_ConfigReplayWindow
+
+ @Description Calling this routine changes the replay-window settings in the
+ internal driver data base from its default configuration
+ [DEFAULT_replayEnable], [DEFAULT_replayWindow]
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] replayProtect; Replay protection function mode
+ @Param[in] replayWindow; The size of the replay window
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Config() and before FM_MACSEC_SECY_Init();
+
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_ConfigReplayWindow(t_Handle h_FmMacsecSecY, bool replayProtect, uint32_t replayWindow);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_ConfigValidationMode
+
+ @Description Calling this routine changes the frame-validation-behavior mode
+ in the internal driver data base from its default configuration
+ [DEFAULT_validateFrames]
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] validateFrames Validation function mode
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Config() and before FM_MACSEC_SECY_Init();
+
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_ConfigValidationMode(t_Handle h_FmMacsecSecY, e_FmMacsecValidFrameBehavior validateFrames);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_ConfigConfidentiality
+
+ @Description Calling this routine changes the confidentiality settings in the
+ internal driver data base from its default configuration
+ [DEFAULT_confidentialityEnable], [DEFAULT_confidentialityOffset]
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] confidentialityEnable TRUE - confidentiality protection and integrity protection
+ FALSE - no confidentiality protection, only integrity protection
+ @Param[in] confidentialityOffset The number of initial octets of each MSDU without confidentiality protection
+ common values are 0, 30, and 50
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Config() and before FM_MACSEC_SECY_Init();
+
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_ConfigConfidentiality(t_Handle h_FmMacsecSecY, bool confidentialityEnable, uint16_t confidentialityOffset);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_ConfigPointToPoint
+
+ @Description configure this SecY to work in point-to-point mode, means that
+ it will have only one rx sc;
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Config() and before FM_MACSEC_SECY_Init();
+ Can be called only once in a system; only the first secY that will call this
+ routine will be able to operate in Point-To-Point mode.
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_ConfigPointToPoint(t_Handle h_FmMacsecSecY);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_ConfigException
+
+ @Description Calling this routine changes the internal driver data base
+ from its default selection of exceptions enablement;
+ By default all exceptions are enabled.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] exception The exception to be selected.
+ @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Config() and before FM_MACSEC_SECY_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_ConfigException(t_Handle h_FmMacsecSecY, e_FmMacsecSecYExceptions exception, bool enable);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_ConfigEvent
+
+ @Description Calling this routine changes the internal driver data base
+ from its default selection of events enablement;
+ By default all events are enabled.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] event The event to be selected.
+ @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Config() and before FM_MACSEC_SECY_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_ConfigEvent(t_Handle h_FmMacsecSecY, e_FmMacsecSecYEvents event, bool enable);
+
+/** @} */ /* end of FM_MACSEC_SECY_advanced_init_grp group */
+/** @} */ /* end of FM_MACSEC_SECY_init_grp group */
+
+
+/**************************************************************************//**
+ @Group FM_MACSEC_SECY_runtime_control_grp FM-MACSEC SecY Runtime Control Unit
+
+ @Description FM MACSEC SECY Runtime control unit API functions, definitions and enums.
+
+ @{
+*//***************************************************************************/
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_CreateRxSc
+
+ @Description Create a receive secure channel.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] scParams secure channel params.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Init().
+*//***************************************************************************/
+t_Handle FM_MACSEC_SECY_CreateRxSc(t_Handle h_FmMacsecSecY, t_FmMacsecSecYSCParams *p_ScParams);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_DeleteRxSc
+
+ @Description Deleting an initialized secure channel.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] h_Sc SC handle as returned by FM_MACSEC_SECY_CreateRxSc.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_CreateRxSc().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_DeleteRxSc(t_Handle h_FmMacsecSecY, t_Handle h_Sc);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_CreateRxSa
+
+ @Description Create a receive secure association for the secure channel;
+ the SA cannot be used to receive frames until FM_MACSEC_SECY_RxSaEnableReceive is called.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] h_Sc SC handle as returned by FM_MACSEC_SECY_CreateRxSc.
+ @Param[in] an association number represent the SA.
+ @Param[in] lowestPn the lowest acceptable PN value for a received frame.
+ @Param[in] key the desired key for this SA.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_CreateRxSc().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_CreateRxSa(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, uint32_t lowestPn, macsecSAKey_t key);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_DeleteRxSa
+
+ @Description Deleting an initialized secure association.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] h_Sc SC handle as returned by FM_MACSEC_SECY_CreateRxSc.
+ @Param[in] an association number represent the SA.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_DeleteRxSa(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_RxSaEnableReceive
+
+ @Description Enabling the SA to receive frames.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] h_Sc SC handle as returned by FM_MACSEC_SECY_CreateRxSc.
+ @Param[in] an association number represent the SA.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_CreateRxSa().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_RxSaEnableReceive(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_RxSaDisableReceive
+
+ @Description Disabling the SA from receive frames.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] h_Sc SC handle as returned by FM_MACSEC_SECY_CreateRxSc.
+ @Param[in] an association number represent the SA.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_CreateRxSa().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_RxSaDisableReceive(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_RxSaUpdateNextPn
+
+ @Description Update the next packet number expected on RX;
+ The value of nextPN shall be set to the greater of its existing value and the
+ supplied of updtNextPN (802.1AE-2006 10.7.15).
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] h_Sc SC handle as returned by FM_MACSEC_SECY_CreateRxSc.
+ @Param[in] an association number represent the SA.
+ @Param[in] updtNextPN the next PN value for a received frame.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_CreateRxSa().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_RxSaUpdateNextPn(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, uint32_t updtNextPN);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_RxSaUpdateLowestPn
+
+ @Description Update the lowest packet number expected on RX;
+ The value of lowestPN shall be set to the greater of its existing value and the
+ supplied of updtLowestPN (802.1AE-2006 10.7.15).
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] h_Sc SC handle as returned by FM_MACSEC_SECY_CreateRxSc.
+ @Param[in] an association number represent the SA.
+ @Param[in] updtLowestPN the lowest PN acceptable value for a received frame.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_CreateRxSa().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_RxSaUpdateLowestPn(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, uint32_t updtLowestPN);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_RxSaModifyKey
+
+ @Description Modify the current key of the SA with a new one.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] h_Sc SC handle as returned by FM_MACSEC_SECY_CreateRxSc.
+ @Param[in] an association number represent the SA.
+ @Param[in] key new key to replace the current key.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_CreateRxSa().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_RxSaModifyKey(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, macsecSAKey_t key);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_CreateTxSa
+
+ @Description Create a transmit secure association for the secure channel;
+ the SA cannot be used to transmit frames until FM_MACSEC_SECY_TxSaSetActivate is called;
+ Only one SA can be active at a time.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] an association number represent the SA.
+ @Param[in] key the desired key for this SA.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_CreateTxSa(t_Handle h_FmMacsecSecY, macsecAN_t an, macsecSAKey_t key);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_DeleteTxSa
+
+ @Description Deleting an initialized secure association.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] an association number represent the SA.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_DeleteTxSa(t_Handle h_FmMacsecSecY, macsecAN_t an);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_TxSaModifyKey
+
+ @Description Modify the key of the inactive SA with a new one.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] nextActiveAn association number represent the next SA to be activated.
+ @Param[in] key new key to replace the current key.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_TxSaModifyKey(t_Handle h_FmMacsecSecY, macsecAN_t nextActiveAn, macsecSAKey_t key);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_TxSaSetActive
+
+ @Description Set this SA to the active SA to be used on TX for SC;
+ only one SA can be active at a time.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] an association number represent the SA.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_TxSaSetActive(t_Handle h_FmMacsecSecY, macsecAN_t an);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_TxSaGetActive
+
+ @Description Get the active SA that being used for TX.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[out] p_An the active an.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_TxSaGetActive(t_Handle h_FmMacsecSecY, macsecAN_t *p_An);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_GetStatistics
+
+ @Description get all statistics counters.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] p_Statistics Structure with statistics.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_GetStatistics(t_Handle h_FmMacsecSecY, t_FmMacsecSecYStatistics *p_Statistics);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_RxScGetStatistics
+
+ @Description get all statistics counters.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] h_Sc Rx Sc handle.
+ @Param[in] p_Statistics Structure with statistics.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_RxScGetStatistics(t_Handle h_FmMacsecSecY, t_Handle h_Sc, t_FmMacsecSecYRxScStatistics *p_Statistics);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_RxSaGetStatistics
+
+ @Description get all statistics counters
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] h_Sc Rx Sc handle.
+ @Param[in] an association number represent the SA.
+ @Param[in] p_Statistics Structure with statistics.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_RxSaGetStatistics(t_Handle h_FmMacsecSecY, t_Handle h_Sc, macsecAN_t an, t_FmMacsecSecYRxSaStatistics *p_Statistics);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_TxScGetStatistics
+
+ @Description get all statistics counters.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] p_Statistics Structure with statistics.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_TxScGetStatistics(t_Handle h_FmMacsecSecY, t_FmMacsecSecYTxScStatistics *p_Statistics);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_TxSaGetStatistics
+
+ @Description get all statistics counters.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] an association number represent the SA.
+ @Param[in] p_Statistics Structure with statistics.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_TxSaGetStatistics(t_Handle h_FmMacsecSecY, macsecAN_t an, t_FmMacsecSecYTxSaStatistics *p_Statistics);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_SetException
+
+ @Description Calling this routine enables/disables the specified exception.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] exception The exception to be selected.
+ @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_SetException(t_Handle h_FmMacsecSecY, e_FmMacsecExceptions exception, bool enable);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_SetEvent
+
+ @Description Calling this routine enables/disables the specified event.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] event The event to be selected.
+ @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Config() and before FM_MACSEC_SECY_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_SetEvent(t_Handle h_FmMacsecSecY, e_FmMacsecSecYEvents event, bool enable);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_GetRxScPhysId
+
+ @Description return the physical id of the Secure Channel.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[in] h_Sc SC handle as returned by FM_MACSEC_SECY_CreateRxSc.
+ @Param[out] p_ScPhysId the SC physical id.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_CreateRxSc().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_GetRxScPhysId(t_Handle h_FmMacsecSecY, t_Handle h_Sc, uint32_t *p_ScPhysId);
+
+/**************************************************************************//**
+ @Function FM_MACSEC_SECY_GetTxScPhysId
+
+ @Description return the physical id of the Secure Channel.
+
+ @Param[in] h_FmMacsecSecY FM MACSEC SECY module descriptor.
+ @Param[out] p_ScPhysId the SC physical id.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MACSEC_SECY_Init().
+*//***************************************************************************/
+t_Error FM_MACSEC_SECY_GetTxScPhysId(t_Handle h_FmMacsecSecY, uint32_t *p_ScPhysId);
+
+/** @} */ /* end of FM_MACSEC_SECY_runtime_control_grp group */
+/** @} */ /* end of FM_MACSEC_SECY_grp group */
+/** @} */ /* end of FM_MACSEC_grp group */
+/** @} */ /* end of FM_grp group */
+
+
+#endif /* __FM_MACSEC_EXT_H */
diff --git a/sys/contrib/ncsw/inc/Peripherals/fm_muram_ext.h b/sys/contrib/ncsw/inc/Peripherals/fm_muram_ext.h
index 0c99ef3f4480..ef62c8ef28d5 100644
--- a/sys/contrib/ncsw/inc/Peripherals/fm_muram_ext.h
+++ b/sys/contrib/ncsw/inc/Peripherals/fm_muram_ext.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File fm_muram_ext.h
@@ -60,7 +61,7 @@
*//***************************************************************************/
/**************************************************************************//**
- @Group FM_muram_init_grp FM MURAM Initialization
+ @Group FM_muram_init_grp FM MURAM Initialization Unit
@Description FM MURAM initialization API functions, definitions and enums
@@ -103,7 +104,7 @@ t_Error FM_MURAM_Free(t_Handle h_FmMuram);
/**************************************************************************//**
- @Group FM_muram_ctrl_grp FM MURAM Control
+ @Group FM_muram_ctrl_grp FM MURAM Control Unit
@Description FM MURAM control API functions, definitions and enums
@@ -149,6 +150,17 @@ void * FM_MURAM_AllocMemForce(t_Handle h_FmMuram, uint64_t base, uint32_t size)
*//***************************************************************************/
t_Error FM_MURAM_FreeMem(t_Handle h_FmMuram, void *ptr);
+/**************************************************************************//**
+ @Function FM_MURAM_GetFreeMemSize
+
+ @Description Returns the size (in bytes) of free MURAM memory.
+
+ @Param[in] h_FmMuram - FM-MURAM module descriptor.
+
+ @Return Free MURAM memory size in bytes.
+*//***************************************************************************/
+uint64_t FM_MURAM_GetFreeMemSize(t_Handle h_FmMuram);
+
/** @} */ /* end of FM_muram_ctrl_grp group */
/** @} */ /* end of FM_muram_grp group */
/** @} */ /* end of FM_grp group */
diff --git a/sys/contrib/ncsw/inc/Peripherals/fm_pcd_ext.h b/sys/contrib/ncsw/inc/Peripherals/fm_pcd_ext.h
index 6de21e736960..8d1c3d889451 100644
--- a/sys/contrib/ncsw/inc/Peripherals/fm_pcd_ext.h
+++ b/sys/contrib/ncsw/inc/Peripherals/fm_pcd_ext.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
+/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,10 +30,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File fm_pcd_ext.h
- @Description FM PCD ...
+ @Description FM PCD API definitions
*//***************************************************************************/
#ifndef __FM_PCD_EXT
#define __FM_PCD_EXT
@@ -42,13 +43,13 @@
#include "net_ext.h"
#include "list_ext.h"
#include "fm_ext.h"
+#include "fsl_fman_kg.h"
/**************************************************************************//**
-
@Group FM_grp Frame Manager API
- @Description FM API functions, definitions and enums
+ @Description Frame Manager Application Programming Interface
@{
*//***************************************************************************/
@@ -56,18 +57,18 @@
/**************************************************************************//**
@Group FM_PCD_grp FM PCD
- @Description FM PCD API functions, definitions and enums
+ @Description Frame Manager PCD (Parse-Classify-Distribute) API.
The FM PCD module is responsible for the initialization of all
global classifying FM modules. This includes the parser general and
common registers, the key generator global and common registers,
- and the Policer global and common registers.
+ and the policer global and common registers.
In addition, the FM PCD SW module will initialize all required
- key generator schemes, coarse classification flows, and Policer
- profiles. When An FM module is configured to work with one of these
+ key generator schemes, coarse classification flows, and policer
+ profiles. When FM module is configured to work with one of these
entities, it will register to it using the FM PORT API. The PCD
module will manage the PCD resources - i.e. resource management of
- Keygen schemes, etc.
+ KeyGen schemes, etc.
@{
*//***************************************************************************/
@@ -75,52 +76,41 @@
/**************************************************************************//**
@Collection General PCD defines
*//***************************************************************************/
-typedef uint32_t fmPcdEngines_t; /**< options as defined below: */
-
-#define FM_PCD_NONE 0 /**< No PCD Engine indicated */
-#define FM_PCD_PRS 0x80000000 /**< Parser indicated */
-#define FM_PCD_KG 0x40000000 /**< Keygen indicated */
-#define FM_PCD_CC 0x20000000 /**< Coarse classification indicated */
-#define FM_PCD_PLCR 0x10000000 /**< Policer indicated */
-#define FM_PCD_MANIP 0x08000000 /**< Manipulation indicated */
-
#define FM_PCD_MAX_NUM_OF_PRIVATE_HDRS 2 /**< Number of units/headers saved for user */
#define FM_PCD_PRS_NUM_OF_HDRS 16 /**< Number of headers supported by HW parser */
#define FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS (32 - FM_PCD_MAX_NUM_OF_PRIVATE_HDRS)
- /**< number of distinction units is limited by
- register size (32), - reserved bits for
- private headers. */
-
-#define FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS 4 /**< Maximum number of interchangeable headers in a distinction unit */
-#define FM_PCD_KG_NUM_OF_GENERIC_REGS 8 /**< Total number of generic KG registers */
-#define FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY 35 /**< Max number allowed on any configuration.
- For reason of HW implementation, in most
- cases less than this will be allowed. The
- driver will return error in initialization
- time if resource is overused. */
-#define FM_PCD_KG_NUM_OF_EXTRACT_MASKS 4 /**< Total number of masks allowed on KG extractions. */
+ /**< Number of distinction units is limited by
+ register size (32 bits) minus reserved bits
+ for private headers. */
+#define FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS 4 /**< Maximum number of interchangeable headers
+ in a distinction unit */
+#define FM_PCD_KG_NUM_OF_GENERIC_REGS FM_KG_NUM_OF_GENERIC_REGS /**< Total number of generic KeyGen registers */
+#define FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY 35 /**< Max number allowed on any configuration;
+ For HW implementation reasons, in most
+ cases less than this will be allowed; The
+ driver will return an initialization error
+ if resource is unavailable. */
+#define FM_PCD_KG_NUM_OF_EXTRACT_MASKS 4 /**< Total number of masks allowed on KeyGen extractions. */
#define FM_PCD_KG_NUM_OF_DEFAULT_GROUPS 16 /**< Number of default value logical groups */
-#define FM_PCD_PRS_NUM_OF_LABELS 32 /**< Max number of SW parser label */
-#define FM_PCD_SW_PRS_SIZE 0x00000800 /**< Total size of sw parser area */
-#define FM_PCD_PRS_SW_OFFSET 0x00000040 /**< Size of illegal addresses at the beginning
- of the SW parser area */
-#define FM_PCD_PRS_SW_PATCHES_SIZE 0x00000200 /**< Number of bytes saved for patches */
-#define FM_PCD_PRS_SW_TAIL_SIZE 4 /**< Number of bytes that must be cleared at
- the end of the SW parser area */
-#define FM_SW_PRS_MAX_IMAGE_SIZE (FM_PCD_SW_PRS_SIZE-FM_PCD_PRS_SW_OFFSET-FM_PCD_PRS_SW_TAIL_SIZE-FM_PCD_PRS_SW_PATCHES_SIZE)
- /**< Max possible size of SW parser code */
-
-#define FM_PCD_MAX_MANIP_INSRT_TEMPLATE_SIZE 128 /**< Max possible size of insertion template for
- insert manipulation*/
+#define FM_PCD_PRS_NUM_OF_LABELS 32 /**< Maximum number of SW parser labels */
+#define FM_SW_PRS_MAX_IMAGE_SIZE (FM_PCD_SW_PRS_SIZE /*- FM_PCD_PRS_SW_OFFSET -FM_PCD_PRS_SW_TAIL_SIZE*/-FM_PCD_PRS_SW_PATCHES_SIZE)
+ /**< Maximum size of SW parser code */
+
+#define FM_PCD_MAX_MANIP_INSRT_TEMPLATE_SIZE 128 /**< Maximum size of insertion template for
+ insert manipulation */
+
+#if (DPAA_VERSION >= 11)
+#define FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES 64 /**< Maximum possible entries for frame replicator group */
+#endif /* (DPAA_VERSION >= 11) */
/* @} */
/**************************************************************************//**
@Group FM_PCD_init_grp FM PCD Initialization Unit
- @Description FM PCD Initialization Unit
+ @Description Frame Manager PCD Initialization Unit API
@{
*//***************************************************************************/
@@ -129,44 +119,46 @@ typedef uint32_t fmPcdEngines_t; /**< options as defined below: */
@Description PCD counters
*//***************************************************************************/
typedef enum e_FmPcdCounters {
- e_FM_PCD_KG_COUNTERS_TOTAL, /**< Policer counter */
- e_FM_PCD_PLCR_COUNTERS_YELLOW, /**< Policer counter */
- e_FM_PCD_PLCR_COUNTERS_RED, /**< Policer counter */
- e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_RED, /**< Policer counter */
- e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_YELLOW, /**< Policer counter */
- e_FM_PCD_PLCR_COUNTERS_TOTAL, /**< Policer counter */
- e_FM_PCD_PLCR_COUNTERS_LENGTH_MISMATCH, /**< Policer counter */
- e_FM_PCD_PRS_COUNTERS_PARSE_DISPATCH, /**< Parser counter */
- e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED, /**< Parser counter */
- e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED, /**< Parser counter */
- e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED, /**< Parser counter */
- e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED, /**< Parser counter */
- e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED_WITH_ERR, /**< Parser counter */
- e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED_WITH_ERR, /**< Parser counter */
- e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED_WITH_ERR, /**< Parser counter */
- e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED_WITH_ERR, /**< Parser counter */
- e_FM_PCD_PRS_COUNTERS_SOFT_PRS_CYCLES, /**< Parser counter */
- e_FM_PCD_PRS_COUNTERS_SOFT_PRS_STALL_CYCLES, /**< Parser counter */
- e_FM_PCD_PRS_COUNTERS_HARD_PRS_CYCLE_INCL_STALL_CYCLES, /**< Parser counter */
- e_FM_PCD_PRS_COUNTERS_MURAM_READ_CYCLES, /**< MURAM counter */
- e_FM_PCD_PRS_COUNTERS_MURAM_READ_STALL_CYCLES, /**< MURAM counter */
- e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_CYCLES, /**< MURAM counter */
- e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_STALL_CYCLES, /**< MURAM counter */
- e_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES /**< FPM counter */
+ e_FM_PCD_KG_COUNTERS_TOTAL, /**< KeyGen counter */
+ e_FM_PCD_PLCR_COUNTERS_RED, /**< Policer counter - counts the total number of RED packets that exit the Policer. */
+ e_FM_PCD_PLCR_COUNTERS_YELLOW, /**< Policer counter - counts the total number of YELLOW packets that exit the Policer. */
+ e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_RED, /**< Policer counter - counts the number of packets that changed color to RED by the Policer;
+ This is a subset of e_FM_PCD_PLCR_COUNTERS_RED packet count, indicating active color changes. */
+ e_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_YELLOW, /**< Policer counter - counts the number of packets that changed color to YELLOW by the Policer;
+ This is a subset of e_FM_PCD_PLCR_COUNTERS_YELLOW packet count, indicating active color changes. */
+ e_FM_PCD_PLCR_COUNTERS_TOTAL, /**< Policer counter - counts the total number of packets passed in the Policer. */
+ e_FM_PCD_PLCR_COUNTERS_LENGTH_MISMATCH, /**< Policer counter - counts the number of packets with length mismatch. */
+ e_FM_PCD_PRS_COUNTERS_PARSE_DISPATCH, /**< Parser counter - counts the number of times the parser block is dispatched. */
+ e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED, /**< Parser counter - counts the number of times L2 parse result is returned (including errors). */
+ e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED, /**< Parser counter - counts the number of times L3 parse result is returned (including errors). */
+ e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED, /**< Parser counter - counts the number of times L4 parse result is returned (including errors). */
+ e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED, /**< Parser counter - counts the number of times SHIM parse result is returned (including errors). */
+ e_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED_WITH_ERR, /**< Parser counter - counts the number of times L2 parse result is returned with errors. */
+ e_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED_WITH_ERR, /**< Parser counter - counts the number of times L3 parse result is returned with errors. */
+ e_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED_WITH_ERR, /**< Parser counter - counts the number of times L4 parse result is returned with errors. */
+ e_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED_WITH_ERR, /**< Parser counter - counts the number of times SHIM parse result is returned with errors. */
+ e_FM_PCD_PRS_COUNTERS_SOFT_PRS_CYCLES, /**< Parser counter - counts the number of cycles spent executing soft parser instruction (including stall cycles). */
+ e_FM_PCD_PRS_COUNTERS_SOFT_PRS_STALL_CYCLES, /**< Parser counter - counts the number of cycles stalled waiting for parser internal memory reads while executing soft parser instruction. */
+ e_FM_PCD_PRS_COUNTERS_HARD_PRS_CYCLE_INCL_STALL_CYCLES, /**< Parser counter - counts the number of cycles spent executing hard parser (including stall cycles). */
+ e_FM_PCD_PRS_COUNTERS_MURAM_READ_CYCLES, /**< MURAM counter - counts the number of cycles while performing FMan Memory read. */
+ e_FM_PCD_PRS_COUNTERS_MURAM_READ_STALL_CYCLES, /**< MURAM counter - counts the number of cycles stalled while performing FMan Memory read. */
+ e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_CYCLES, /**< MURAM counter - counts the number of cycles while performing FMan Memory write. */
+ e_FM_PCD_PRS_COUNTERS_MURAM_WRITE_STALL_CYCLES, /**< MURAM counter - counts the number of cycles stalled while performing FMan Memory write. */
+ e_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES /**< FPM counter - counts the number of cycles stalled while performing a FPM Command. */
} e_FmPcdCounters;
/**************************************************************************//**
@Description PCD interrupts
*//***************************************************************************/
typedef enum e_FmPcdExceptions {
- e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC, /**< Keygen ECC error */
- e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC, /**< Read Buffer ECC error */
- e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW, /**< Write Buffer ECC error on system side */
- e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR, /**< Write Buffer ECC error on FM side */
- e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE, /**< Self init complete */
- e_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE, /**< Atomic action complete */
- e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC, /**< Parser ECC error */
- e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC /**< Parser single ECC */
+ e_FM_PCD_KG_EXCEPTION_DOUBLE_ECC, /**< KeyGen double-bit ECC error is detected on internal memory read access. */
+ e_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW, /**< KeyGen scheme configuration error indicating a key size larger than 56 bytes. */
+ e_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC, /**< Policer double-bit ECC error has been detected on PRAM read access. */
+ e_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR, /**< Policer access to a non-initialized profile has been detected. */
+ e_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE, /**< Policer RAM self-initialization complete */
+ e_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE, /**< Policer atomic action complete */
+ e_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC, /**< Parser double-bit ECC error */
+ e_FM_PCD_PRS_EXCEPTION_SINGLE_ECC /**< Parser single-bit ECC error */
} e_FmPcdExceptions;
@@ -194,7 +186,7 @@ typedef void (t_FmPcdIdExceptionCallback) ( t_Handle h_App,
/**************************************************************************//**
@Description A callback for enqueuing frame onto a QM queue.
- @Param[in] h_App - User's application descriptor.
+ @Param[in] h_QmArg - Application's handle passed to QM module on enqueue.
@Param[in] p_Fd - Frame descriptor for the frame.
@Return E_OK on success; Error code otherwise.
@@ -202,54 +194,60 @@ typedef void (t_FmPcdIdExceptionCallback) ( t_Handle h_App,
typedef t_Error (t_FmPcdQmEnqueueCallback) (t_Handle h_QmArg, void *p_Fd);
/**************************************************************************//**
- @Description A structure for Host-Command
+ @Description Host-Command parameters structure.
+
When using Host command for PCD functionalities, a dedicated port
must be used. If this routine is called for a PCD in a single partition
- environment, or it is the Master partition in a Multi partition
+ environment, or it is the Master partition in a Multi-partition
environment, The port will be initialized by the PCD driver
initialization routine.
*//***************************************************************************/
typedef struct t_FmPcdHcParams {
- uintptr_t portBaseAddr; /**< Host-Command Port Virtual Address of
- memory mapped registers.*/
- uint8_t portId; /**< Host-Command Port Id (0-6 relative
- to Host-Command/Offline parsing ports) */
- uint16_t liodnBase; /**< Irrelevant for P4080 rev 1. LIODN base for this port, to be
- used together with LIODN offset. */
- uint32_t errFqid; /**< Host-Command Port Error Queue Id. */
- uint32_t confFqid; /**< Host-Command Port Confirmation queue Id. */
- uint32_t qmChannel; /**< Host-Command port - QM-channel dedicated to
- this port will be used by the FM for dequeue. */
- t_FmPcdQmEnqueueCallback *f_QmEnqueue; /**< Call back routine for enqueuing a frame to the QM */
- t_Handle h_QmArg; /**< A handle of the QM module */
+ uintptr_t portBaseAddr; /**< Virtual Address of Host-Command Port memory mapped registers.*/
+ uint8_t portId; /**< Port Id (0-6 relative to Host-Command/Offline-Parsing ports);
+ NOTE: When configuring Host Command port for
+ FMANv3 devices (DPAA_VERSION 11 and higher),
+ portId=0 MUST be used. */
+ uint16_t liodnBase; /**< LIODN base for this port, to be used together with LIODN offset
+ (irrelevant for P4080 revision 1.0) */
+ uint32_t errFqid; /**< Host-Command Port error queue Id. */
+ uint32_t confFqid; /**< Host-Command Port confirmation queue Id. */
+ uint32_t qmChannel; /**< QM channel dedicated to this Host-Command port;
+ will be used by the FM for dequeue. */
+ t_FmPcdQmEnqueueCallback *f_QmEnqueue; /**< Callback routine for enqueuing a frame to the QM */
+ t_Handle h_QmArg; /**< Application's handle passed to QM module on enqueue */
} t_FmPcdHcParams;
/**************************************************************************//**
@Description The main structure for PCD initialization
*//***************************************************************************/
typedef struct t_FmPcdParams {
- bool prsSupport; /**< TRUE if Parser will be used for any
- of the FM ports */
+ bool prsSupport; /**< TRUE if Parser will be used for any of the FM ports. */
bool ccSupport; /**< TRUE if Coarse Classification will be used for any
- of the FM ports */
- bool kgSupport; /**< TRUE if Keygen will be used for any
- of the FM ports */
- bool plcrSupport; /**< TRUE if Policer will be used for any
- of the FM ports */
- t_Handle h_Fm; /**< A handle to the FM module */
- uint8_t numOfSchemes; /**< Number of schemes dedicated to this partition. */
+ of the FM ports. */
+ bool kgSupport; /**< TRUE if KeyGen will be used for any of the FM ports. */
+ bool plcrSupport; /**< TRUE if Policer will be used for any of the FM ports. */
+ t_Handle h_Fm; /**< A handle to the FM module. */
+ uint8_t numOfSchemes; /**< Number of schemes dedicated to this partition.
+ this parameter is relevant if 'kgSupport'=TRUE. */
bool useHostCommand; /**< Optional for single partition, Mandatory for Multi partition */
- t_FmPcdHcParams hc; /**< Relevant only if useHostCommand=TRUE.
- Host Command parameters. */
-
- t_FmPcdExceptionCallback *f_Exception; /**< Relevant for master (or single) partition only: Callback routine
- to be called of PCD exception */
- t_FmPcdIdExceptionCallback *f_ExceptionId; /**< Relevant for master (or single) partition only: Callback routine
- to be used for a single scheme and
- profile exceptions */
- t_Handle h_App; /**< Relevant for master (or single) partition only: A handle to an
- application layer object; This handle will
- be passed by the driver upon calling the above callbacks */
+ t_FmPcdHcParams hc; /**< Host Command parameters, relevant only if 'useHostCommand'=TRUE;
+ Relevant when FM not runs in "guest-mode". */
+
+ t_FmPcdExceptionCallback *f_Exception; /**< Callback routine for general PCD exceptions;
+ Relevant when FM not runs in "guest-mode". */
+ t_FmPcdIdExceptionCallback *f_ExceptionId; /**< Callback routine for specific KeyGen scheme or
+ Policer profile exceptions;
+ Relevant when FM not runs in "guest-mode". */
+ t_Handle h_App; /**< A handle to an application layer object; This handle will
+ be passed by the driver upon calling the above callbacks;
+ Relevant when FM not runs in "guest-mode". */
+ uint8_t partPlcrProfilesBase; /**< The first policer-profile-id dedicated to this partition.
+ this parameter is relevant if 'plcrSupport'=TRUE.
+ NOTE: this parameter relevant only when working with multiple partitions. */
+ uint16_t partNumOfPlcrProfiles; /**< Number of policer-profiles dedicated to this partition.
+ this parameter is relevant if 'plcrSupport'=TRUE.
+ NOTE: this parameter relevant only when working with multiple partitions. */
} t_FmPcdParams;
@@ -290,58 +288,77 @@ t_Error FM_PCD_Init(t_Handle h_FmPcd);
t_Error FM_PCD_Free(t_Handle h_FmPcd);
/**************************************************************************//**
- @Group FM_PCD_advanced_init_grp FM PCD Advanced Configuration Unit
+ @Group FM_PCD_advanced_cfg_grp FM PCD Advanced Configuration Unit
- @Description Configuration functions used to change default values.
+ @Description Frame Manager PCD Advanced Configuration API.
@{
*//***************************************************************************/
/**************************************************************************//**
- @Function FM_PCD_ConfigPlcrNumOfSharedProfiles
+ @Function FM_PCD_ConfigException
@Description Calling this routine changes the internal driver data base
- from its default selection of exceptions enablement.
- [4].
+ from its default selection of exceptions enabling.
+ [DEFAULT_numOfSharedPlcrProfiles].
- @Param[in] h_FmPcd FM PCD module descriptor.
- @Param[in] numOfSharedPlcrProfiles Number of profiles to
- be shared between ports on this partition
+ @Param[in] h_FmPcd FM PCD module descriptor.
+ @Param[in] exception The exception to be selected.
+ @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
@Return E_OK on success; Error code otherwise.
+
+ @Cautions This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_PCD_ConfigPlcrNumOfSharedProfiles(t_Handle h_FmPcd, uint16_t numOfSharedPlcrProfiles);
+t_Error FM_PCD_ConfigException(t_Handle h_FmPcd, e_FmPcdExceptions exception, bool enable);
/**************************************************************************//**
- @Function FM_PCD_ConfigException
+ @Function FM_PCD_ConfigHcFramesDataMemory
- @Description Calling this routine changes the internal driver data base
- from its default selection of exceptions enablement.
- By default all exceptions are enabled.
+ @Description Configures memory-partition-id for FMan-Controller Host-Command
+ frames. Calling this routine changes the internal driver data
+ base from its default configuration [0].
@Param[in] h_FmPcd FM PCD module descriptor.
- @Param[in] exception The exception to be selected.
- @Param[in] enable TRUE to enable interrupt, FALSE to mask it.
+ @Param[in] memId Memory partition ID.
@Return E_OK on success; Error code otherwise.
- @Cautions Not available for guest partition.
+ @Cautions This routine may be called only if 'useHostCommand' was TRUE
+ when FM_PCD_Config() routine was called.
*//***************************************************************************/
-t_Error FM_PCD_ConfigException(t_Handle h_FmPcd, e_FmPcdExceptions exception, bool enable);
+t_Error FM_PCD_ConfigHcFramesDataMemory(t_Handle h_FmPcd, uint8_t memId);
+
+/**************************************************************************//**
+ @Function FM_PCD_ConfigPlcrNumOfSharedProfiles
+
+ @Description Calling this routine changes the internal driver data base
+ from its default selection of exceptions enablement.
+ [DEFAULT_numOfSharedPlcrProfiles].
+
+ @Param[in] h_FmPcd FM PCD module descriptor.
+ @Param[in] numOfSharedPlcrProfiles Number of profiles to
+ be shared between ports on this partition
+
+ @Return E_OK on success; Error code otherwise.
+*//***************************************************************************/
+t_Error FM_PCD_ConfigPlcrNumOfSharedProfiles(t_Handle h_FmPcd, uint16_t numOfSharedPlcrProfiles);
/**************************************************************************//**
@Function FM_PCD_ConfigPlcrAutoRefreshMode
@Description Calling this routine changes the internal driver data base
from its default selection of exceptions enablement.
- By default autorefresh is enabled.
+ By default auto-refresh is [DEFAULT_plcrAutoRefresh].
@Param[in] h_FmPcd FM PCD module descriptor.
@Param[in] enable TRUE to enable, FALSE to disable
@Return E_OK on success; Error code otherwise.
- @Cautions Not available for guest partition.
+ @Cautions This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_PCD_ConfigPlcrAutoRefreshMode(t_Handle h_FmPcd, bool enable);
@@ -350,7 +367,7 @@ t_Error FM_PCD_ConfigPlcrAutoRefreshMode(t_Handle h_FmPcd, bool enable);
@Description Calling this routine changes the internal data structure for
the maximum parsing time from its default value
- [0].
+ [DEFAULT_MAX_PRS_CYC_LIM].
@Param[in] h_FmPcd FM PCD module descriptor.
@Param[in] value 0 to disable the mechanism, or new
@@ -358,46 +375,46 @@ t_Error FM_PCD_ConfigPlcrAutoRefreshMode(t_Handle h_FmPcd, bool enable);
@Return E_OK on success; Error code otherwise.
- @Cautions Not available for guest partition.
+ @Cautions This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_PCD_ConfigPrsMaxCycleLimit(t_Handle h_FmPcd,uint16_t value);
-/** @} */ /* end of FM_PCD_advanced_init_grp group */
+/** @} */ /* end of FM_PCD_advanced_cfg_grp group */
/** @} */ /* end of FM_PCD_init_grp group */
/**************************************************************************//**
@Group FM_PCD_Runtime_grp FM PCD Runtime Unit
- @Description FM PCD Runtime Unit
+ @Description Frame Manager PCD Runtime Unit API
The runtime control allows creation of PCD infrastructure modules
such as Network Environment Characteristics, Classification Plan
Groups and Coarse Classification Trees.
It also allows on-the-fly initialization, modification and removal
- of PCD modules such as Keygen schemes, coarse classification nodes
+ of PCD modules such as KeyGen schemes, coarse classification nodes
and Policer profiles.
-
In order to explain the programming model of the PCD driver interface
a few terms should be explained, and will be used below.
- * Distinction Header - One of the 16 protocols supported by the FM parser,
- or one of the shim headers (1 or 2). May be a header with a special
+ - Distinction Header - One of the 16 protocols supported by the FM parser,
+ or one of the SHIM headers (1 or 2). May be a header with a special
option (see below).
- * Interchangeable Headers Group- This is a group of Headers recognized
+ - Interchangeable Headers Group - This is a group of Headers recognized
by either one of them. For example, if in a specific context the user
chooses to treat IPv4 and IPV6 in the same way, they may create an
interchangeable Headers Unit consisting of these 2 headers.
- * A Distinction Unit - a Distinction Header or an Interchangeable Headers
+ - A Distinction Unit - a Distinction Header or an Interchangeable Headers
Group.
- * Header with special option - applies to ethernet, mpls, vlan, ipv4 and
- ipv6, includes multicast, broadcast and other protocol specific options.
+ - Header with special option - applies to Ethernet, MPLS, VLAN, IPv4 and
+ IPv6, includes multicast, broadcast and other protocol specific options.
In terms of hardware it relates to the options available in the classification
plan.
- * Network Environment Characteristics - a set of Distinction Units that define
+ - Network Environment Characteristics - a set of Distinction Units that define
the total recognizable header selection for a certain environment. This is
NOT the list of all headers that will ever appear in a flow, but rather
- everything that needs distinction in a flow, where distinction is made by keygen
+ everything that needs distinction in a flow, where distinction is made by KeyGen
schemes and coarse classification action descriptors.
The PCD runtime modules initialization is done in stages. The first stage after
@@ -410,20 +427,23 @@ t_Error FM_PCD_ConfigPrsMaxCycleLimit(t_Handle h_FmPcd,uint16_t value);
*//***************************************************************************/
/**************************************************************************//**
- @Description A structure for sw parser labels
+ @Description A structure for SW parser labels
*//***************************************************************************/
typedef struct t_FmPcdPrsLabelParams {
uint32_t instructionOffset; /**< SW parser label instruction offset (2 bytes
resolution), relative to Parser RAM. */
- e_NetHeaderType hdr; /**< The existance of this header will envoke
- the sw parser code. */
- uint8_t indexPerHdr; /**< Normally 0, if more than one sw parser
+ e_NetHeaderType hdr; /**< The existence of this header will invoke
+ the SW parser code; Use HEADER_TYPE_NONE
+ to indicate that sw parser is to run
+ independent of the existence of any protocol
+ (run before HW parser). */
+ uint8_t indexPerHdr; /**< Normally 0, if more than one SW parser
attachments for the same header, use this
index to distinguish between them. */
} t_FmPcdPrsLabelParams;
/**************************************************************************//**
- @Description A structure for sw parser
+ @Description A structure for SW parser
*//***************************************************************************/
typedef struct t_FmPcdPrsSwParams {
bool override; /**< FALSE to invoke a check that nothing else
@@ -472,7 +492,6 @@ t_Error FM_PCD_Enable(t_Handle h_FmPcd);
*//***************************************************************************/
t_Error FM_PCD_Disable(t_Handle h_FmPcd);
-
/**************************************************************************//**
@Function FM_PCD_GetCounter
@@ -491,28 +510,45 @@ t_Error FM_PCD_Disable(t_Handle h_FmPcd);
uint32_t FM_PCD_GetCounter(t_Handle h_FmPcd, e_FmPcdCounters counter);
/**************************************************************************//**
-@Function FM_PCD_PrsLoadSw
+@Function FM_PCD_PrsLoadSw
-@Description This routine may be called in order to load software parsing code.
+@Description This routine may be called in order to load software parsing code.
-@Param[in] h_FmPcd FM PCD module descriptor.
-@Param[in] p_SwPrs A pointer to a structure of software
+@Param[in] h_FmPcd FM PCD module descriptor.
+@Param[in] p_SwPrs A pointer to a structure of software
parser parameters, including the software
parser image.
+@Return E_OK on success; Error code otherwise.
+
+@Cautions Allowed only following FM_PCD_Init() and when PCD is disabled.
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
+*//***************************************************************************/
+t_Error FM_PCD_PrsLoadSw(t_Handle h_FmPcd, t_FmPcdPrsSwParams *p_SwPrs);
+
+/**************************************************************************//**
+@Function FM_PCD_SetAdvancedOffloadSupport
+
+@Description This routine must be called in order to support the following features:
+ IP-fragmentation, IP-reassembly, IPsec, Header-manipulation, frame-replicator.
+
+@Param[in] h_FmPcd FM PCD module descriptor.
+
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PCD_Init() and when PCD is disabled.
- Not available for guest partition.
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
-t_Error FM_PCD_PrsLoadSw(t_Handle h_FmPcd, t_FmPcdPrsSwParams *p_SwPrs);
+t_Error FM_PCD_SetAdvancedOffloadSupport(t_Handle h_FmPcd);
/**************************************************************************//**
@Function FM_PCD_KgSetDfltValue
@Description Calling this routine sets a global default value to be used
- by the keygen when parser does not recognize a required
+ by the KeyGen when parser does not recognize a required
field/header.
By default default values are 0.
@@ -523,14 +559,15 @@ t_Error FM_PCD_PrsLoadSw(t_Handle h_FmPcd, t_FmPcdPrsSwParams *p_SwPrs);
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PCD_Init() and when PCD is disabled.
- Not available for guest partition.
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_PCD_KgSetDfltValue(t_Handle h_FmPcd, uint8_t valueId, uint32_t value);
/**************************************************************************//**
@Function FM_PCD_KgSetAdditionalDataAfterParsing
- @Description Calling this routine allows the keygen to access data past
+ @Description Calling this routine allows the KeyGen to access data past
the parser finishing point.
@Param[in] h_FmPcd FM PCD module descriptor.
@@ -539,7 +576,8 @@ t_Error FM_PCD_KgSetDfltValue(t_Handle h_FmPcd, uint8_t valueId, uint32_t value)
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PCD_Init() and when PCD is disabled.
- Not available for guest partition.
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_PCD_KgSetAdditionalDataAfterParsing(t_Handle h_FmPcd, uint8_t payloadOffset);
@@ -555,7 +593,8 @@ t_Error FM_PCD_KgSetAdditionalDataAfterParsing(t_Handle h_FmPcd, uint8_t payload
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PCD_Init().
- Not available for guest partition.
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_PCD_SetException(t_Handle h_FmPcd, e_FmPcdExceptions exception, bool enable);
@@ -571,7 +610,8 @@ t_Error FM_PCD_SetException(t_Handle h_FmPcd, e_FmPcdExceptions exception, bool
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PCD_Init().
- Not available for guest partition.
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_PCD_ModifyCounter(t_Handle h_FmPcd, e_FmPcdCounters counter, uint32_t value);
@@ -587,7 +627,8 @@ t_Error FM_PCD_ModifyCounter(t_Handle h_FmPcd, e_FmPcdCounters counter, uint32_t
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PCD_Init().
- Not available for guest partition.
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_PCD_SetPlcrStatistics(t_Handle h_FmPcd, bool enable);
@@ -602,11 +643,26 @@ t_Error FM_PCD_SetPlcrStatistics(t_Handle h_FmPcd, bool enable);
@Return None
@Cautions Allowed only following FM_PCD_Init().
- Not available for guest partition.
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
void FM_PCD_SetPrsStatistics(t_Handle h_FmPcd, bool enable);
/**************************************************************************//**
+ @Function FM_PCD_HcTxConf
+
+ @Description This routine should be called to confirm frames that were
+ received on the HC confirmation queue.
+
+ @Param[in] h_FmPcd A handle to an FM PCD Module.
+ @Param[in] p_Fd Frame descriptor of the received frame.
+
+ @Cautions Allowed only following FM_PCD_Init(). Allowed only if 'useHostCommand'
+ option was selected in the initialization.
+*//***************************************************************************/
+void FM_PCD_HcTxConf(t_Handle h_FmPcd, t_DpaaFD *p_Fd);
+
+/**************************************************************************//*
@Function FM_PCD_ForceIntr
@Description Causes an interrupt event on the requested source.
@@ -618,24 +674,11 @@ void FM_PCD_SetPrsStatistics(t_Handle h_FmPcd, bool enable);
or is not able to create interrupt.
@Cautions Allowed only following FM_PCD_Init().
- Not available for guest partition.
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_PCD_ForceIntr (t_Handle h_FmPcd, e_FmPcdExceptions exception);
-/**************************************************************************//**
- @Function FM_PCD_HcTxConf
-
- @Description This routine should be called to confirm frames that were
- received on the HC confirmation queue.
-
- @Param[in] h_FmPcd A handle to an FM PCD Module.
- @Param[in] p_Fd Frame descriptor of the received frame.
-
- @Cautions Allowed only following FM_PCD_Init(). Allowed only if 'useHostCommand'
- option was selected in the initialization.
-*//***************************************************************************/
-void FM_PCD_HcTxConf(t_Handle h_FmPcd, t_DpaaFD *p_Fd);
-
#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
/**************************************************************************//**
@Function FM_PCD_DumpRegs
@@ -647,6 +690,9 @@ void FM_PCD_HcTxConf(t_Handle h_FmPcd, t_DpaaFD *p_Fd);
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PCD_Init().
+ NOTE: this routine may be called only for FM in master mode
+ (i.e. 'guestId'=NCSW_MASTER_ID) or in a case that the registers
+ are mapped.
*//***************************************************************************/
t_Error FM_PCD_DumpRegs(t_Handle h_FmPcd);
@@ -660,46 +706,57 @@ t_Error FM_PCD_DumpRegs(t_Handle h_FmPcd);
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PCD_Init().
+ NOTE: this routine may be called only for FM in master mode
+ (i.e. 'guestId'=NCSW_MASTER_ID) or in a case that the registers
+ are mapped.
*//***************************************************************************/
t_Error FM_PCD_KgDumpRegs(t_Handle h_FmPcd);
/**************************************************************************//**
@Function FM_PCD_PlcrDumpRegs
- @Description Dumps all PCD Plcr registers
+ @Description Dumps all PCD Policer registers
@Param[in] h_FmPcd A handle to an FM PCD Module.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PCD_Init().
+ NOTE: this routine may be called only for FM in master mode
+ (i.e. 'guestId'=NCSW_MASTER_ID) or in a case that the registers
+ are mapped.
*//***************************************************************************/
t_Error FM_PCD_PlcrDumpRegs(t_Handle h_FmPcd);
/**************************************************************************//**
@Function FM_PCD_PlcrProfileDumpRegs
- @Description Dumps all PCD Plcr registers
+ @Description Dumps all PCD Policer profile registers
- @Param[in] h_FmPcd A handle to an FM PCD Module.
- @Param[in] h_Profile A handle to a profile.
+ @Param[in] h_Profile A handle to a Policer profile.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PCD_Init().
+ NOTE: this routine may be called only for FM in master mode
+ (i.e. 'guestId'=NCSW_MASTER_ID) or in a case that the registers
+ are mapped.
*//***************************************************************************/
-t_Error FM_PCD_PlcrProfileDumpRegs(t_Handle h_FmPcd, t_Handle h_Profile);
+t_Error FM_PCD_PlcrProfileDumpRegs(t_Handle h_Profile);
/**************************************************************************//**
@Function FM_PCD_PrsDumpRegs
- @Description Dumps all PCD Prs registers
+ @Description Dumps all PCD Parser registers
@Param[in] h_FmPcd A handle to an FM PCD Module.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PCD_Init().
+ NOTE: this routine may be called only for FM in master mode
+ (i.e. 'guestId'=NCSW_MASTER_ID) or in a case that the registers
+ are mapped.
*//***************************************************************************/
t_Error FM_PCD_PrsDumpRegs(t_Handle h_FmPcd);
@@ -713,6 +770,8 @@ t_Error FM_PCD_PrsDumpRegs(t_Handle h_FmPcd);
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PCD_Init().
+ NOTE: this routine may be called only for FM in master mode
+ (i.e. 'guestId'=NCSW_MASTER_ID).
*//***************************************************************************/
t_Error FM_PCD_HcDumpRegs(t_Handle h_FmPcd);
#endif /* (defined(DEBUG_ERRORS) && ... */
@@ -720,9 +779,9 @@ t_Error FM_PCD_HcDumpRegs(t_Handle h_FmPcd);
/**************************************************************************//**
- @Group FM_PCD_Runtime_tree_buildgrp FM PCD Tree building Unit
+ KeyGen FM_PCD_Runtime_build_grp FM PCD Runtime Building Unit
- @Description FM PCD Runtime Unit
+ @Description Frame Manager PCD Runtime Building API
This group contains routines for setting, deleting and modifying
PCD resources, for defining the total PCD tree.
@@ -731,16 +790,19 @@ t_Error FM_PCD_HcDumpRegs(t_Handle h_FmPcd);
/**************************************************************************//**
@Collection Definitions of coarse classification
- parameters as required by keygen (when coarse classification
+ parameters as required by KeyGen (when coarse classification
is the next engine after this scheme).
*//***************************************************************************/
-#define FM_PCD_MAX_NUM_OF_CC_NODES 255
-#define FM_PCD_MAX_NUM_OF_CC_TREES 8
-#define FM_PCD_MAX_NUM_OF_CC_GROUPS 16
-#define FM_PCD_MAX_NUM_OF_CC_UNITS 4
-#define FM_PCD_MAX_NUM_OF_KEYS 256
-#define FM_PCD_MAX_SIZE_OF_KEY 56
-#define FM_PCD_MAX_NUM_OF_CC_ENTRIES_IN_GRP 16
+#define FM_PCD_MAX_NUM_OF_CC_TREES 8
+#define FM_PCD_MAX_NUM_OF_CC_GROUPS 16
+#define FM_PCD_MAX_NUM_OF_CC_UNITS 4
+#define FM_PCD_MAX_NUM_OF_KEYS 256
+#define FM_PCD_MAX_NUM_OF_FLOWS (4*KILOBYTE)
+#define FM_PCD_MAX_SIZE_OF_KEY 56
+#define FM_PCD_MAX_NUM_OF_CC_ENTRIES_IN_GRP 16
+#define FM_PCD_LAST_KEY_INDEX 0xffff
+
+#define FM_PCD_MAX_NUM_OF_CC_NODES 255 /* Obsolete, not used - will be removed in the future */
/* @} */
/**************************************************************************//**
@@ -753,11 +815,11 @@ typedef protocolOpt_t ethProtocolOpt_t; /**< Ethernet protocol options.
#define ETH_BROADCAST 0x80000000 /**< Ethernet Broadcast. */
#define ETH_MULTICAST 0x40000000 /**< Ethernet Multicast. */
-typedef protocolOpt_t vlanProtocolOpt_t; /**< Vlan protocol options. */
-#define VLAN_STACKED 0x20000000 /**< Vlan Stacked. */
+typedef protocolOpt_t vlanProtocolOpt_t; /**< VLAN protocol options. */
+#define VLAN_STACKED 0x20000000 /**< Stacked VLAN. */
typedef protocolOpt_t mplsProtocolOpt_t; /**< MPLS protocol options. */
-#define MPLS_STACKED 0x10000000 /**< MPLS Stacked. */
+#define MPLS_STACKED 0x10000000 /**< Stacked MPLS. */
typedef protocolOpt_t ipv4ProtocolOpt_t; /**< IPv4 protocol options. */
#define IPV4_BROADCAST_1 0x08000000 /**< IPv4 Broadcast. */
@@ -765,10 +827,70 @@ typedef protocolOpt_t ipv4ProtocolOpt_t; /**< IPv4 protocol options. */
#define IPV4_UNICAST_2 0x02000000 /**< Tunneled IPv4 - Unicast. */
#define IPV4_MULTICAST_BROADCAST_2 0x01000000 /**< Tunneled IPv4 - Broadcast/Multicast. */
+#define IPV4_FRAG_1 0x00000008 /**< IPV4 reassembly option.
+ IPV4 Reassembly manipulation requires network
+ environment with IPV4 header and IPV4_FRAG_1 option */
+
typedef protocolOpt_t ipv6ProtocolOpt_t; /**< IPv6 protocol options. */
#define IPV6_MULTICAST_1 0x00800000 /**< IPv6 Multicast. */
#define IPV6_UNICAST_2 0x00400000 /**< Tunneled IPv6 - Unicast. */
#define IPV6_MULTICAST_2 0x00200000 /**< Tunneled IPv6 - Multicast. */
+
+#define IPV6_FRAG_1 0x00000004 /**< IPV6 reassembly option.
+ IPV6 Reassembly manipulation requires network
+ environment with IPV6 header and IPV6_FRAG_1 option;
+ in case where fragment found, the fragment-extension offset
+ may be found at 'shim2' (in parser-result). */
+#if (DPAA_VERSION >= 11)
+typedef protocolOpt_t capwapProtocolOpt_t; /**< CAPWAP protocol options. */
+#define CAPWAP_FRAG_1 0x00000008 /**< CAPWAP reassembly option.
+ CAPWAP Reassembly manipulation requires network
+ environment with CAPWAP header and CAPWAP_FRAG_1 option;
+ in case where fragment found, the fragment-extension offset
+ may be found at 'shim2' (in parser-result). */
+#endif /* (DPAA_VERSION >= 11) */
+
+
+/* @} */
+
+#define FM_PCD_MANIP_MAX_HDR_SIZE 256
+#define FM_PCD_MANIP_DSCP_TO_VLAN_TRANS 64
+
+/**************************************************************************//**
+ @Collection A set of definitions to support Header Manipulation selection.
+*//***************************************************************************/
+typedef uint32_t hdrManipFlags_t; /**< A general type to define a HMan update command flags. */
+
+typedef hdrManipFlags_t ipv4HdrManipUpdateFlags_t; /**< IPv4 protocol HMan update command flags. */
+
+#define HDR_MANIP_IPV4_TOS 0x80000000 /**< update TOS with the given value ('tos' field
+ of t_FmPcdManipHdrFieldUpdateIpv4) */
+#define HDR_MANIP_IPV4_ID 0x40000000 /**< update IP ID with the given value ('id' field
+ of t_FmPcdManipHdrFieldUpdateIpv4) */
+#define HDR_MANIP_IPV4_TTL 0x20000000 /**< Decrement TTL by 1 */
+#define HDR_MANIP_IPV4_SRC 0x10000000 /**< update IP source address with the given value
+ ('src' field of t_FmPcdManipHdrFieldUpdateIpv4) */
+#define HDR_MANIP_IPV4_DST 0x08000000 /**< update IP destination address with the given value
+ ('dst' field of t_FmPcdManipHdrFieldUpdateIpv4) */
+
+typedef hdrManipFlags_t ipv6HdrManipUpdateFlags_t; /**< IPv6 protocol HMan update command flags. */
+
+#define HDR_MANIP_IPV6_TC 0x80000000 /**< update Traffic Class address with the given value
+ ('trafficClass' field of t_FmPcdManipHdrFieldUpdateIpv6) */
+#define HDR_MANIP_IPV6_HL 0x40000000 /**< Decrement Hop Limit by 1 */
+#define HDR_MANIP_IPV6_SRC 0x20000000 /**< update IP source address with the given value
+ ('src' field of t_FmPcdManipHdrFieldUpdateIpv6) */
+#define HDR_MANIP_IPV6_DST 0x10000000 /**< update IP destination address with the given value
+ ('dst' field of t_FmPcdManipHdrFieldUpdateIpv6) */
+
+typedef hdrManipFlags_t tcpUdpHdrManipUpdateFlags_t;/**< TCP/UDP protocol HMan update command flags. */
+
+#define HDR_MANIP_TCP_UDP_SRC 0x80000000 /**< update TCP/UDP source address with the given value
+ ('src' field of t_FmPcdManipHdrFieldUpdateTcpUdp) */
+#define HDR_MANIP_TCP_UDP_DST 0x40000000 /**< update TCP/UDP destination address with the given value
+ ('dst' field of t_FmPcdManipHdrFieldUpdateTcpUdp) */
+#define HDR_MANIP_TCP_UDP_CHECKSUM 0x20000000 /**< update TCP/UDP checksum */
+
/* @} */
/**************************************************************************//**
@@ -784,16 +906,20 @@ typedef uint8_t t_FmPcdKgKeyOrder [FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY];
@Description All PCD engines
*//***************************************************************************/
typedef enum e_FmPcdEngine {
- e_FM_PCD_INVALID = 0, /**< Invalid PCD engine indicated*/
+ e_FM_PCD_INVALID = 0, /**< Invalid PCD engine */
e_FM_PCD_DONE, /**< No PCD Engine indicated */
- e_FM_PCD_KG, /**< Keygen indicated */
- e_FM_PCD_CC, /**< Coarse classification indicated */
- e_FM_PCD_PLCR, /**< Policer indicated */
- e_FM_PCD_PRS /**< Parser indicated */
+ e_FM_PCD_KG, /**< KeyGen */
+ e_FM_PCD_CC, /**< Coarse classifier */
+ e_FM_PCD_PLCR, /**< Policer */
+ e_FM_PCD_PRS, /**< Parser */
+#if (DPAA_VERSION >= 11)
+ e_FM_PCD_FR, /**< Frame-Replicator */
+#endif /* (DPAA_VERSION >= 11) */
+ e_FM_PCD_HASH /**< Hash table */
} e_FmPcdEngine;
/**************************************************************************//**
- @Description An enum for selecting extraction by header types
+ @Description Enumeration type for selecting extraction by header types
*//***************************************************************************/
typedef enum e_FmPcdExtractByHdrType {
e_FM_PCD_EXTRACT_FROM_HDR, /**< Extract bytes from header */
@@ -802,22 +928,22 @@ typedef enum e_FmPcdExtractByHdrType {
} e_FmPcdExtractByHdrType;
/**************************************************************************//**
- @Description An enum for selecting extraction source
+ @Description Enumeration type for selecting extraction source
(when it is not the header)
*//***************************************************************************/
typedef enum e_FmPcdExtractFrom {
e_FM_PCD_EXTRACT_FROM_FRAME_START, /**< KG & CC: Extract from beginning of frame */
e_FM_PCD_EXTRACT_FROM_DFLT_VALUE, /**< KG only: Extract from a default value */
- e_FM_PCD_EXTRACT_FROM_CURR_END_OF_PARSE, /**< KG only: Extract from the point where parsing had finished */
+ e_FM_PCD_EXTRACT_FROM_CURR_END_OF_PARSE, /**< KG & CC: Extract from the point where parsing had finished */
e_FM_PCD_EXTRACT_FROM_KEY, /**< CC only: Field where saved KEY */
e_FM_PCD_EXTRACT_FROM_HASH, /**< CC only: Field where saved HASH */
- e_FM_PCD_EXTRACT_FROM_PARSE_RESULT, /**< KG & CC: Extract from the parser result */
+ e_FM_PCD_EXTRACT_FROM_PARSE_RESULT, /**< KG only: Extract from the parser result */
e_FM_PCD_EXTRACT_FROM_ENQ_FQID, /**< KG & CC: Extract from enqueue FQID */
e_FM_PCD_EXTRACT_FROM_FLOW_ID /**< CC only: Field where saved Dequeue FQID */
} e_FmPcdExtractFrom;
/**************************************************************************//**
- @Description An enum for selecting extraction type
+ @Description Enumeration type for selecting extraction type
*//***************************************************************************/
typedef enum e_FmPcdExtractType {
e_FM_PCD_EXTRACT_BY_HDR, /**< Extract according to header */
@@ -826,7 +952,7 @@ typedef enum e_FmPcdExtractType {
} e_FmPcdExtractType;
/**************************************************************************//**
- @Description An enum for selecting a default
+ @Description Enumeration type for selecting default extraction value
*//***************************************************************************/
typedef enum e_FmPcdKgExtractDfltSelect {
e_FM_PCD_KG_DFLT_GBL_0, /**< Default selection is KG register 0 */
@@ -837,9 +963,8 @@ typedef enum e_FmPcdKgExtractDfltSelect {
} e_FmPcdKgExtractDfltSelect;
/**************************************************************************//**
- @Description An enum defining all default groups -
- each group shares a default value, one of 4 user
- initialized values.
+ @Description Enumeration type defining all default groups - each group shares
+ a default value, one of four user-initialized values.
*//***************************************************************************/
typedef enum e_FmPcdKgKnownFieldsDfltTypes {
e_FM_PCD_KG_MAC_ADDR, /**< MAC Address */
@@ -848,25 +973,26 @@ typedef enum e_FmPcdKgKnownFieldsDfltTypes {
e_FM_PCD_KG_PPP_SESSION_ID, /**< PPP Session id */
e_FM_PCD_KG_PPP_PROTOCOL_ID, /**< PPP Protocol id */
e_FM_PCD_KG_MPLS_LABEL, /**< MPLS label */
- e_FM_PCD_KG_IP_ADDR, /**< IP addr */
+ e_FM_PCD_KG_IP_ADDR, /**< IP address */
e_FM_PCD_KG_PROTOCOL_TYPE, /**< Protocol type */
e_FM_PCD_KG_IP_TOS_TC, /**< TOS or TC */
e_FM_PCD_KG_IPV6_FLOW_LABEL, /**< IPV6 flow label */
e_FM_PCD_KG_IPSEC_SPI, /**< IPSEC SPI */
e_FM_PCD_KG_L4_PORT, /**< L4 Port */
e_FM_PCD_KG_TCP_FLAG, /**< TCP Flag */
- e_FM_PCD_KG_GENERIC_FROM_DATA, /**< grouping implemented by sw,
+ e_FM_PCD_KG_GENERIC_FROM_DATA, /**< grouping implemented by SW,
any data extraction that is not the full
field described above */
- e_FM_PCD_KG_GENERIC_FROM_DATA_NO_V, /**< grouping implemented by sw,
+ e_FM_PCD_KG_GENERIC_FROM_DATA_NO_V, /**< grouping implemented by SW,
any data extraction without validation */
- e_FM_PCD_KG_GENERIC_NOT_FROM_DATA /**< grouping implemented by sw,
+ e_FM_PCD_KG_GENERIC_NOT_FROM_DATA /**< grouping implemented by SW,
extraction from parser result or
direct use of default value */
} e_FmPcdKgKnownFieldsDfltTypes;
/**************************************************************************//**
- @Description enum for defining header index when headers may repeat
+ @Description Enumeration type for defining header index for scenarios with
+ multiple (tunneled) headers
*//***************************************************************************/
typedef enum e_FmPcdHdrIndex {
e_FM_PCD_HDR_INDEX_NONE = 0, /**< used when multiple headers not used, also
@@ -878,7 +1004,7 @@ typedef enum e_FmPcdHdrIndex {
} e_FmPcdHdrIndex;
/**************************************************************************//**
- @Description A structure for selcting the policer profile functional type
+ @Description Enumeration type for selecting the policer profile functional type
*//***************************************************************************/
typedef enum e_FmPcdProfileTypeSelection {
e_FM_PCD_PLCR_PORT_PRIVATE, /**< Port dedicated profile */
@@ -886,16 +1012,16 @@ typedef enum e_FmPcdProfileTypeSelection {
} e_FmPcdProfileTypeSelection;
/**************************************************************************//**
- @Description A structure for selcting the policer profile algorithem
+ @Description Enumeration type for selecting the policer profile algorithm
*//***************************************************************************/
typedef enum e_FmPcdPlcrAlgorithmSelection {
e_FM_PCD_PLCR_PASS_THROUGH, /**< Policer pass through */
- e_FM_PCD_PLCR_RFC_2698, /**< Policer algorythm RFC 2698 */
- e_FM_PCD_PLCR_RFC_4115 /**< Policer algorythm RFC 4115 */
+ e_FM_PCD_PLCR_RFC_2698, /**< Policer algorithm RFC 2698 */
+ e_FM_PCD_PLCR_RFC_4115 /**< Policer algorithm RFC 4115 */
} e_FmPcdPlcrAlgorithmSelection;
/**************************************************************************//**
- @Description A structure for selcting the policer profile color mode
+ @Description Enumeration type for selecting a policer profile color mode
*//***************************************************************************/
typedef enum e_FmPcdPlcrColorMode {
e_FM_PCD_PLCR_COLOR_BLIND, /**< Color blind */
@@ -903,17 +1029,17 @@ typedef enum e_FmPcdPlcrColorMode {
} e_FmPcdPlcrColorMode;
/**************************************************************************//**
- @Description A structure for selcting the policer profile color functional mode
+ @Description Enumeration type for selecting a policer profile color
*//***************************************************************************/
typedef enum e_FmPcdPlcrColor {
- e_FM_PCD_PLCR_GREEN, /**< Green */
- e_FM_PCD_PLCR_YELLOW, /**< Yellow */
- e_FM_PCD_PLCR_RED, /**< Red */
- e_FM_PCD_PLCR_OVERRIDE /**< Color override */
+ e_FM_PCD_PLCR_GREEN, /**< Green color code */
+ e_FM_PCD_PLCR_YELLOW, /**< Yellow color code */
+ e_FM_PCD_PLCR_RED, /**< Red color code */
+ e_FM_PCD_PLCR_OVERRIDE /**< Color override code */
} e_FmPcdPlcrColor;
/**************************************************************************//**
- @Description A structure for selcting the policer profile packet frame length selector
+ @Description Enumeration type for selecting the policer profile packet frame length selector
*//***************************************************************************/
typedef enum e_FmPcdPlcrFrameLengthSelect {
e_FM_PCD_PLCR_L2_FRM_LEN, /**< L2 frame length */
@@ -923,15 +1049,15 @@ typedef enum e_FmPcdPlcrFrameLengthSelect {
} e_FmPcdPlcrFrameLengthSelect;
/**************************************************************************//**
- @Description An enum for selecting rollback frame
+ @Description Enumeration type for selecting roll-back frame
*//***************************************************************************/
typedef enum e_FmPcdPlcrRollBackFrameSelect {
- e_FM_PCD_PLCR_ROLLBACK_L2_FRM_LEN, /**< Rollback L2 frame length */
- e_FM_PCD_PLCR_ROLLBACK_FULL_FRM_LEN /**< Rollback Full frame length */
+ e_FM_PCD_PLCR_ROLLBACK_L2_FRM_LEN, /**< Roll-back L2 frame length */
+ e_FM_PCD_PLCR_ROLLBACK_FULL_FRM_LEN /**< Roll-back Full frame length */
} e_FmPcdPlcrRollBackFrameSelect;
/**************************************************************************//**
- @Description A structure for selcting the policer profile packet or byte mode
+ @Description Enumeration type for selecting the policer profile packet or byte mode
*//***************************************************************************/
typedef enum e_FmPcdPlcrRateMode {
e_FM_PCD_PLCR_BYTE_MODE, /**< Byte mode */
@@ -939,15 +1065,17 @@ typedef enum e_FmPcdPlcrRateMode {
} e_FmPcdPlcrRateMode;
/**************************************************************************//**
- @Description An enum for defining action of frame
+ @Description Enumeration type for defining action of frame
*//***************************************************************************/
typedef enum e_FmPcdDoneAction {
e_FM_PCD_ENQ_FRAME = 0, /**< Enqueue frame */
- e_FM_PCD_DROP_FRAME /**< Drop frame */
+ e_FM_PCD_DROP_FRAME /**< Mark this frame as error frame and continue
+ to error flow; 'FM_PORT_FRM_ERR_CLS_DISCARD'
+ flag will be set for this frame. */
} e_FmPcdDoneAction;
/**************************************************************************//**
- @Description A structure for selecting the policer counter
+ @Description Enumeration type for selecting the policer counter
*//***************************************************************************/
typedef enum e_FmPcdPlcrProfileCounters {
e_FM_PCD_PLCR_PROFILE_GREEN_PACKET_TOTAL_COUNTER, /**< Green packets counter */
@@ -958,72 +1086,216 @@ typedef enum e_FmPcdPlcrProfileCounters {
} e_FmPcdPlcrProfileCounters;
/**************************************************************************//**
- @Description A structure for selecting action
+ @Description Enumeration type for selecting the PCD action after extraction
*//***************************************************************************/
typedef enum e_FmPcdAction {
e_FM_PCD_ACTION_NONE, /**< NONE */
- e_FM_PCD_ACTION_EXACT_MATCH, /**< Exact match on the selected extraction*/
- e_FM_PCD_ACTION_INDEXED_LOOKUP /**< Indexed lookup on the selected extraction*/
+ e_FM_PCD_ACTION_EXACT_MATCH, /**< Exact match on the selected extraction */
+ e_FM_PCD_ACTION_INDEXED_LOOKUP /**< Indexed lookup on the selected extraction */
} e_FmPcdAction;
-#if defined(FM_CAPWAP_SUPPORT)
/**************************************************************************//**
- @Description An enum for selecting type of insert manipulation
+ @Description Enumeration type for selecting type of insert manipulation
+*//***************************************************************************/
+typedef enum e_FmPcdManipHdrInsrtType {
+ e_FM_PCD_MANIP_INSRT_GENERIC, /**< Insert according to offset & size */
+ e_FM_PCD_MANIP_INSRT_BY_HDR, /**< Insert according to protocol */
+#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
+ e_FM_PCD_MANIP_INSRT_BY_TEMPLATE /**< Insert template to start of frame */
+#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
+} e_FmPcdManipHdrInsrtType;
+
+/**************************************************************************//**
+ @Description Enumeration type for selecting type of remove manipulation
+*//***************************************************************************/
+typedef enum e_FmPcdManipHdrRmvType {
+ e_FM_PCD_MANIP_RMV_GENERIC, /**< Remove according to offset & size */
+ e_FM_PCD_MANIP_RMV_BY_HDR /**< Remove according to offset & size */
+} e_FmPcdManipHdrRmvType;
+
+/**************************************************************************//**
+ @Description Enumeration type for selecting specific L2 fields removal
+*//***************************************************************************/
+typedef enum e_FmPcdManipHdrRmvSpecificL2 {
+ e_FM_PCD_MANIP_HDR_RMV_ETHERNET, /**< Ethernet/802.3 MAC */
+ e_FM_PCD_MANIP_HDR_RMV_STACKED_QTAGS, /**< stacked QTags */
+ e_FM_PCD_MANIP_HDR_RMV_ETHERNET_AND_MPLS, /**< MPLS and Ethernet/802.3 MAC header until
+ the header which follows the MPLS header */
+ e_FM_PCD_MANIP_HDR_RMV_MPLS, /**< Remove MPLS header (Unlimited MPLS labels) */
+ e_FM_PCD_MANIP_HDR_RMV_PPPOE /**< Remove the PPPoE header and PPP protocol field. */
+} e_FmPcdManipHdrRmvSpecificL2;
+
+/**************************************************************************//**
+ @Description Enumeration type for selecting specific fields updates
+*//***************************************************************************/
+typedef enum e_FmPcdManipHdrFieldUpdateType {
+ e_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN, /**< VLAN updates */
+ e_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV4, /**< IPV4 updates */
+ e_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV6, /**< IPV6 updates */
+ e_FM_PCD_MANIP_HDR_FIELD_UPDATE_TCP_UDP, /**< TCP_UDP updates */
+} e_FmPcdManipHdrFieldUpdateType;
+
+/**************************************************************************//**
+ @Description Enumeration type for selecting VLAN updates
+*//***************************************************************************/
+typedef enum e_FmPcdManipHdrFieldUpdateVlan {
+ e_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN_VPRI, /**< Replace VPri of outer most VLAN tag. */
+ e_FM_PCD_MANIP_HDR_FIELD_UPDATE_DSCP_TO_VLAN /**< DSCP to VLAN priority bits translation */
+} e_FmPcdManipHdrFieldUpdateVlan;
+
+/**************************************************************************//**
+ @Description Enumeration type for selecting specific L2 header insertion
+*//***************************************************************************/
+typedef enum e_FmPcdManipHdrInsrtSpecificL2 {
+ e_FM_PCD_MANIP_HDR_INSRT_MPLS, /**< Insert MPLS header (Unlimited MPLS labels) */
+ e_FM_PCD_MANIP_HDR_INSRT_PPPOE /**< Insert PPPOE */
+} e_FmPcdManipHdrInsrtSpecificL2;
+
+#if (DPAA_VERSION >= 11)
+/**************************************************************************//**
+ @Description Enumeration type for selecting QoS mapping mode
+
+ Note: In all cases except 'e_FM_PCD_MANIP_HDR_QOS_MAPPING_NONE'
+ User should instruct the port to read the hash-result
+*//***************************************************************************/
+typedef enum e_FmPcdManipHdrQosMappingMode {
+ e_FM_PCD_MANIP_HDR_QOS_MAPPING_NONE = 0, /**< No mapping, QoS field will not be changed */
+ e_FM_PCD_MANIP_HDR_QOS_MAPPING_AS_IS, /**< QoS field will be overwritten by the last byte in the hash-result. */
+} e_FmPcdManipHdrQosMappingMode;
+
+/**************************************************************************//**
+ @Description Enumeration type for selecting QoS source
+
+ Note: In all cases except 'e_FM_PCD_MANIP_HDR_QOS_SRC_NONE'
+ User should left room for the hash-result on input/output buffer
+ and instruct the port to read/write the hash-result to the buffer (RPD should be set)
*//***************************************************************************/
-typedef enum e_FmPcdManipInsrtType {
- e_FM_PCD_MANIP_INSRT_NONE = 0, /**< No insertion */
- e_FM_PCD_MANIP_INSRT_TO_START_OF_FRAME_INT_FRAME_HDR, /**< Insert internal frame header to start of frame */
- e_FM_PCD_MANIP_INSRT_TO_START_OF_FRAME_TEMPLATE /**< Insert template to start of frame*/
-} e_FmPcdManipInsrtType;
+typedef enum e_FmPcdManipHdrQosSrc {
+ e_FM_PCD_MANIP_HDR_QOS_SRC_NONE = 0, /**< TODO */
+ e_FM_PCD_MANIP_HDR_QOS_SRC_USER_DEFINED, /**< QoS will be taken from the last byte in the hash-result. */
+} e_FmPcdManipHdrQosSrc;
+#endif /* (DPAA_VERSION >= 11) */
/**************************************************************************//**
- @Description An enum for selecting type of remove manipulation
+ @Description Enumeration type for selecting type of header insertion
*//***************************************************************************/
-typedef enum e_FmPcdManipRmvParamsType {
- e_FM_PCD_MANIP_RMV_NONE = 0, /**< No remove */
- e_FM_PCD_MANIP_RMV_FROM_START_OF_FRAME_TILL_SPECIFIC_LOCATION, /**< Remove from start of frame till (excluding) specified indication */
- e_FM_PCD_MANIP_RMV_FROM_START_OF_FRAME_INCLUDE_SPECIFIC_LOCATION, /**< Remove from start of frame till (including) specified indication */
- e_FM_PCD_MANIP_RMV_INT_FRAME_HDR /**< Remove internal frame header to start of frame */
-} e_FmPcdManipRmvParamsType;
+typedef enum e_FmPcdManipHdrInsrtByHdrType {
+ e_FM_PCD_MANIP_INSRT_BY_HDR_SPECIFIC_L2, /**< Specific L2 fields insertion */
+#if (DPAA_VERSION >= 11)
+ e_FM_PCD_MANIP_INSRT_BY_HDR_IP, /**< IP insertion */
+ e_FM_PCD_MANIP_INSRT_BY_HDR_UDP, /**< UDP insertion */
+ e_FM_PCD_MANIP_INSRT_BY_HDR_UDP_LITE, /**< UDP lite insertion */
+ e_FM_PCD_MANIP_INSRT_BY_HDR_CAPWAP /**< CAPWAP insertion */
+#endif /* (DPAA_VERSION >= 11) */
+} e_FmPcdManipHdrInsrtByHdrType;
/**************************************************************************//**
- @Description An enum for selecting type of location
+ @Description Enumeration type for selecting specific customCommand
*//***************************************************************************/
-typedef enum e_FmPcdManipLocateType {
- e_FM_PCD_MANIP_LOC_BY_HDR = 0, /**< Locate according to header */
- e_FM_PCD_MANIP_LOC_NON_HDR /**< Locate from data that is not the header */
-} e_FmPcdManipLocateType;
+typedef enum e_FmPcdManipHdrCustomType {
+ e_FM_PCD_MANIP_HDR_CUSTOM_IP_REPLACE, /**< Replace IPv4/IPv6 */
+ e_FM_PCD_MANIP_HDR_CUSTOM_GEN_FIELD_REPLACE, /**< Replace IPv4/IPv6 */
+} e_FmPcdManipHdrCustomType;
/**************************************************************************//**
- @Description An enum for selecting type of Timeout mode
+ @Description Enumeration type for selecting specific customCommand
+*//***************************************************************************/
+typedef enum e_FmPcdManipHdrCustomIpReplace {
+ e_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV4_BY_IPV6, /**< Replace IPv4 by IPv6 */
+ e_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV6_BY_IPV4 /**< Replace IPv6 by IPv4 */
+} e_FmPcdManipHdrCustomIpReplace;
+
+/**************************************************************************//**
+ @Description Enumeration type for selecting type of header removal
+*//***************************************************************************/
+typedef enum e_FmPcdManipHdrRmvByHdrType {
+ e_FM_PCD_MANIP_RMV_BY_HDR_SPECIFIC_L2 = 0, /**< Specific L2 fields removal */
+#if (DPAA_VERSION >= 11)
+ e_FM_PCD_MANIP_RMV_BY_HDR_CAPWAP, /**< CAPWAP removal */
+#endif /* (DPAA_VERSION >= 11) */
+#if (DPAA_VERSION >= 11) || ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
+ e_FM_PCD_MANIP_RMV_BY_HDR_FROM_START, /**< Locate from data that is not the header */
+#endif /* (DPAA_VERSION >= 11) || ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
+} e_FmPcdManipHdrRmvByHdrType;
+
+/**************************************************************************//**
+ @Description Enumeration type for selecting type of timeout mode
*//***************************************************************************/
typedef enum e_FmPcdManipReassemTimeOutMode {
- e_FM_PCD_MANIP_TIME_OUT_BETWEEN_FRAMES, /**< limits the time of the reassm process from the first frag to the last */
- e_FM_PCD_MANIP_TIME_OUT_BETWEEN_FRAG /**< limits the time of receiving the fragment */
+ e_FM_PCD_MANIP_TIME_OUT_BETWEEN_FRAMES, /**< Limits the time of the reassembly process
+ from the first fragment to the last */
+ e_FM_PCD_MANIP_TIME_OUT_BETWEEN_FRAG /**< Limits the time of receiving the fragment */
} e_FmPcdManipReassemTimeOutMode;
/**************************************************************************//**
- @Description An enum for selecting type of WaysNumber mode
+ @Description Enumeration type for selecting type of WaysNumber mode
*//***************************************************************************/
typedef enum e_FmPcdManipReassemWaysNumber {
- e_FM_PCD_MANIP_ONE_WAY_HASH = 1, /**< -------------- */
- e_FM_PCD_MANIP_TWO_WAYS_HASH, /**< -------------- */
- e_FM_PCD_MANIP_THREE_WAYS_HASH, /**< -------------- */
- e_FM_PCD_MANIP_FOUR_WAYS_HASH, /**< four ways hash */
- e_FM_PCD_MANIP_FIVE_WAYS_HASH, /**< -------------- */
- e_FM_PCD_MANIP_SIX_WAYS_HASH, /**< -------------- */
- e_FM_PCD_MANIP_SEVEN_WAYS_HASH, /**< -------------- */
- e_FM_PCD_MANIP_EIGHT_WAYS_HASH /**< eight ways hash*/
+ e_FM_PCD_MANIP_ONE_WAY_HASH = 1, /**< One way hash */
+ e_FM_PCD_MANIP_TWO_WAYS_HASH, /**< Two ways hash */
+ e_FM_PCD_MANIP_THREE_WAYS_HASH, /**< Three ways hash */
+ e_FM_PCD_MANIP_FOUR_WAYS_HASH, /**< Four ways hash */
+ e_FM_PCD_MANIP_FIVE_WAYS_HASH, /**< Five ways hash */
+ e_FM_PCD_MANIP_SIX_WAYS_HASH, /**< Six ways hash */
+ e_FM_PCD_MANIP_SEVEN_WAYS_HASH, /**< Seven ways hash */
+ e_FM_PCD_MANIP_EIGHT_WAYS_HASH /**< Eight ways hash */
} e_FmPcdManipReassemWaysNumber;
+#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
/**************************************************************************//**
- @Description An enum for selecting type of statistics mode
+ @Description Enumeration type for selecting type of statistics mode
*//***************************************************************************/
typedef enum e_FmPcdStatsType {
- e_FM_PCD_STATS_PER_FLOWID = 0 /**< type where flowId used as index for getting statistics */
+ e_FM_PCD_STATS_PER_FLOWID = 0 /**< Flow ID is used as index for getting statistics */
} e_FmPcdStatsType;
+#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
-#endif /* FM_CAPWAP_SUPPORT */
+/**************************************************************************//**
+ @Description Enumeration type for selecting manipulation type
+*//***************************************************************************/
+typedef enum e_FmPcdManipType {
+ e_FM_PCD_MANIP_HDR = 0, /**< Header manipulation */
+ e_FM_PCD_MANIP_REASSEM, /**< Reassembly */
+ e_FM_PCD_MANIP_FRAG, /**< Fragmentation */
+ e_FM_PCD_MANIP_SPECIAL_OFFLOAD /**< Special Offloading */
+} e_FmPcdManipType;
+
+/**************************************************************************//**
+ @Description Enumeration type for selecting type of statistics mode
+*//***************************************************************************/
+typedef enum e_FmPcdCcStatsMode {
+ e_FM_PCD_CC_STATS_MODE_NONE = 0, /**< No statistics support */
+ e_FM_PCD_CC_STATS_MODE_FRAME, /**< Frame count statistics */
+ e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME, /**< Byte and frame count statistics */
+#if (DPAA_VERSION >= 11)
+ e_FM_PCD_CC_STATS_MODE_RMON, /**< Byte and frame length range count statistics;
+ This mode is supported only on B4860 device */
+#endif /* (DPAA_VERSION >= 11) */
+} e_FmPcdCcStatsMode;
+
+/**************************************************************************//**
+ @Description Enumeration type for determining the action in case an IP packet
+ is larger than MTU but its DF (Don't Fragment) bit is set.
+*//***************************************************************************/
+typedef enum e_FmPcdManipDontFragAction {
+ e_FM_PCD_MANIP_DISCARD_PACKET = 0, /**< Discard packet */
+ e_FM_PCD_MANIP_ENQ_TO_ERR_Q_OR_DISCARD_PACKET = e_FM_PCD_MANIP_DISCARD_PACKET,
+ /**< Obsolete, cannot enqueue to error queue;
+ In practice, selects to discard packets;
+ Will be removed in the future */
+ e_FM_PCD_MANIP_FRAGMENT_PACKET, /**< Fragment packet and continue normal processing */
+ e_FM_PCD_MANIP_CONTINUE_WITHOUT_FRAG /**< Continue normal processing without fragmenting the packet */
+} e_FmPcdManipDontFragAction;
+
+/**************************************************************************//**
+ @Description Enumeration type for selecting type of special offload manipulation
+*//***************************************************************************/
+typedef enum e_FmPcdManipSpecialOffloadType {
+ e_FM_PCD_MANIP_SPECIAL_OFFLOAD_IPSEC, /**< IPSec offload manipulation */
+#if (DPAA_VERSION >= 11)
+ e_FM_PCD_MANIP_SPECIAL_OFFLOAD_CAPWAP /**< CAPWAP offload manipulation */
+#endif /* (DPAA_VERSION >= 11) */
+} e_FmPcdManipSpecialOffloadType;
/**************************************************************************//**
@@ -1031,36 +1303,158 @@ typedef enum e_FmPcdStatsType {
*//***************************************************************************/
typedef union u_FmPcdHdrProtocolOpt {
ethProtocolOpt_t ethOpt; /**< Ethernet options */
- vlanProtocolOpt_t vlanOpt; /**< Vlan options */
+ vlanProtocolOpt_t vlanOpt; /**< VLAN options */
mplsProtocolOpt_t mplsOpt; /**< MPLS options */
ipv4ProtocolOpt_t ipv4Opt; /**< IPv4 options */
ipv6ProtocolOpt_t ipv6Opt; /**< IPv6 options */
+#if (DPAA_VERSION >= 11)
+ capwapProtocolOpt_t capwapOpt; /**< CAPWAP options */
+#endif /* (DPAA_VERSION >= 11) */
} u_FmPcdHdrProtocolOpt;
/**************************************************************************//**
- @Description A union holding all known protocol fields
+ @Description A union holding protocol fields
+
+
+ Fields supported as "full fields":
+ HEADER_TYPE_ETH:
+ NET_HEADER_FIELD_ETH_DA
+ NET_HEADER_FIELD_ETH_SA
+ NET_HEADER_FIELD_ETH_TYPE
+
+ HEADER_TYPE_LLC_SNAP:
+ NET_HEADER_FIELD_LLC_SNAP_TYPE
+
+ HEADER_TYPE_VLAN:
+ NET_HEADER_FIELD_VLAN_TCI
+ (index may apply:
+ e_FM_PCD_HDR_INDEX_NONE/e_FM_PCD_HDR_INDEX_1,
+ e_FM_PCD_HDR_INDEX_LAST)
+
+ HEADER_TYPE_MPLS:
+ NET_HEADER_FIELD_MPLS_LABEL_STACK
+ (index may apply:
+ e_FM_PCD_HDR_INDEX_NONE/e_FM_PCD_HDR_INDEX_1,
+ e_FM_PCD_HDR_INDEX_2,
+ e_FM_PCD_HDR_INDEX_LAST)
+
+ HEADER_TYPE_IPv4:
+ NET_HEADER_FIELD_IPv4_SRC_IP
+ NET_HEADER_FIELD_IPv4_DST_IP
+ NET_HEADER_FIELD_IPv4_PROTO
+ NET_HEADER_FIELD_IPv4_TOS
+ (index may apply:
+ e_FM_PCD_HDR_INDEX_NONE/e_FM_PCD_HDR_INDEX_1,
+ e_FM_PCD_HDR_INDEX_2/e_FM_PCD_HDR_INDEX_LAST)
+
+ HEADER_TYPE_IPv6:
+ NET_HEADER_FIELD_IPv6_SRC_IP
+ NET_HEADER_FIELD_IPv6_DST_IP
+ NET_HEADER_FIELD_IPv6_NEXT_HDR
+ NET_HEADER_FIELD_IPv6_VER | NET_HEADER_FIELD_IPv6_FL | NET_HEADER_FIELD_IPv6_TC (must come together!)
+ (index may apply:
+ e_FM_PCD_HDR_INDEX_NONE/e_FM_PCD_HDR_INDEX_1,
+ e_FM_PCD_HDR_INDEX_2/e_FM_PCD_HDR_INDEX_LAST)
+
+ (Note that starting from DPAA 1-1, NET_HEADER_FIELD_IPv6_NEXT_HDR applies to
+ the last next header indication, meaning the next L4, which may be
+ present at the Ipv6 last extension. On earlier revisions this field
+ applies to the Next-Header field of the main IPv6 header)
+
+ HEADER_TYPE_IP:
+ NET_HEADER_FIELD_IP_PROTO
+ (index may apply:
+ e_FM_PCD_HDR_INDEX_LAST)
+ NET_HEADER_FIELD_IP_DSCP
+ (index may apply:
+ e_FM_PCD_HDR_INDEX_NONE/e_FM_PCD_HDR_INDEX_1)
+ HEADER_TYPE_GRE:
+ NET_HEADER_FIELD_GRE_TYPE
+
+ HEADER_TYPE_MINENCAP
+ NET_HEADER_FIELD_MINENCAP_SRC_IP
+ NET_HEADER_FIELD_MINENCAP_DST_IP
+ NET_HEADER_FIELD_MINENCAP_TYPE
+
+ HEADER_TYPE_TCP:
+ NET_HEADER_FIELD_TCP_PORT_SRC
+ NET_HEADER_FIELD_TCP_PORT_DST
+ NET_HEADER_FIELD_TCP_FLAGS
+
+ HEADER_TYPE_UDP:
+ NET_HEADER_FIELD_UDP_PORT_SRC
+ NET_HEADER_FIELD_UDP_PORT_DST
+
+ HEADER_TYPE_UDP_LITE:
+ NET_HEADER_FIELD_UDP_LITE_PORT_SRC
+ NET_HEADER_FIELD_UDP_LITE_PORT_DST
+
+ HEADER_TYPE_IPSEC_AH:
+ NET_HEADER_FIELD_IPSEC_AH_SPI
+ NET_HEADER_FIELD_IPSEC_AH_NH
+
+ HEADER_TYPE_IPSEC_ESP:
+ NET_HEADER_FIELD_IPSEC_ESP_SPI
+
+ HEADER_TYPE_SCTP:
+ NET_HEADER_FIELD_SCTP_PORT_SRC
+ NET_HEADER_FIELD_SCTP_PORT_DST
+
+ HEADER_TYPE_DCCP:
+ NET_HEADER_FIELD_DCCP_PORT_SRC
+ NET_HEADER_FIELD_DCCP_PORT_DST
+
+ HEADER_TYPE_PPPoE:
+ NET_HEADER_FIELD_PPPoE_PID
+ NET_HEADER_FIELD_PPPoE_SID
+
+ *****************************************************************
+ Fields supported as "from fields":
+ HEADER_TYPE_ETH (with or without validation):
+ NET_HEADER_FIELD_ETH_TYPE
+
+ HEADER_TYPE_VLAN (with or without validation):
+ NET_HEADER_FIELD_VLAN_TCI
+ (index may apply:
+ e_FM_PCD_HDR_INDEX_NONE/e_FM_PCD_HDR_INDEX_1,
+ e_FM_PCD_HDR_INDEX_LAST)
+
+ HEADER_TYPE_IPv4 (without validation):
+ NET_HEADER_FIELD_IPv4_PROTO
+ (index may apply:
+ e_FM_PCD_HDR_INDEX_NONE/e_FM_PCD_HDR_INDEX_1,
+ e_FM_PCD_HDR_INDEX_2/e_FM_PCD_HDR_INDEX_LAST)
+
+ HEADER_TYPE_IPv6 (without validation):
+ NET_HEADER_FIELD_IPv6_NEXT_HDR
+ (index may apply:
+ e_FM_PCD_HDR_INDEX_NONE/e_FM_PCD_HDR_INDEX_1,
+ e_FM_PCD_HDR_INDEX_2/e_FM_PCD_HDR_INDEX_LAST)
+
*//***************************************************************************/
typedef union t_FmPcdFields {
- headerFieldEth_t eth; /**< eth */
- headerFieldVlan_t vlan; /**< vlan */
- headerFieldLlcSnap_t llcSnap; /**< llcSnap */
- headerFieldPppoe_t pppoe; /**< pppoe */
- headerFieldMpls_t mpls; /**< mpls */
- headerFieldIpv4_t ipv4; /**< ipv4 */
- headerFieldIpv6_t ipv6; /**< ipv6 */
- headerFieldUdp_t udp; /**< udp */
- headerFieldTcp_t tcp; /**< tcp */
- headerFieldSctp_t sctp; /**< sctp */
- headerFieldDccp_t dccp; /**< dccp */
- headerFieldGre_t gre; /**< gre */
- headerFieldMinencap_t minencap; /**< minencap */
- headerFieldIpsecAh_t ipsecAh; /**< ipsecAh */
- headerFieldIpsecEsp_t ipsecEsp; /**< ipsecEsp */
- headerFieldUdpEncapEsp_t udpEncapEsp; /**< udpEncapEsp */
+ headerFieldEth_t eth; /**< Ethernet */
+ headerFieldVlan_t vlan; /**< VLAN */
+ headerFieldLlcSnap_t llcSnap; /**< LLC SNAP */
+ headerFieldPppoe_t pppoe; /**< PPPoE */
+ headerFieldMpls_t mpls; /**< MPLS */
+ headerFieldIp_t ip; /**< IP */
+ headerFieldIpv4_t ipv4; /**< IPv4 */
+ headerFieldIpv6_t ipv6; /**< IPv6 */
+ headerFieldUdp_t udp; /**< UDP */
+ headerFieldUdpLite_t udpLite; /**< UDP Lite */
+ headerFieldTcp_t tcp; /**< TCP */
+ headerFieldSctp_t sctp; /**< SCTP */
+ headerFieldDccp_t dccp; /**< DCCP */
+ headerFieldGre_t gre; /**< GRE */
+ headerFieldMinencap_t minencap; /**< Minimal Encapsulation */
+ headerFieldIpsecAh_t ipsecAh; /**< IPSec AH */
+ headerFieldIpsecEsp_t ipsecEsp; /**< IPSec ESP */
+ headerFieldUdpEncapEsp_t udpEncapEsp; /**< UDP Encapsulation ESP */
} t_FmPcdFields;
/**************************************************************************//**
- @Description structure for defining header extraction for key generation
+ @Description Parameters for defining header extraction for key generation
*//***************************************************************************/
typedef struct t_FmPcdFromHdr {
uint8_t size; /**< Size in byte */
@@ -1068,7 +1462,7 @@ typedef struct t_FmPcdFromHdr {
} t_FmPcdFromHdr;
/**************************************************************************//**
- @Description structure for defining field extraction for key generation
+ @Description Parameters for defining field extraction for key generation
*//***************************************************************************/
typedef struct t_FmPcdFromField {
t_FmPcdFields field; /**< Field selection */
@@ -1077,24 +1471,25 @@ typedef struct t_FmPcdFromField {
} t_FmPcdFromField;
/**************************************************************************//**
- @Description A structure of parameters used to define a single network
- environment unit.
- A unit should be defined if it will later be used by one or
- more PCD engines to distinguich between flows.
+ @Description Parameters for defining a single network environment unit
+
+ A distinction unit should be defined if it will later be used
+ by one or more PCD engines to distinguish between flows.
*//***************************************************************************/
typedef struct t_FmPcdDistinctionUnit {
struct {
e_NetHeaderType hdr; /**< One of the headers supported by the FM */
- u_FmPcdHdrProtocolOpt opt; /**< only one option !! */
+ u_FmPcdHdrProtocolOpt opt; /**< Select only one option ! */
} hdrs[FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS];
} t_FmPcdDistinctionUnit;
/**************************************************************************//**
- @Description A structure of parameters used to define the different
- units supported by a specific PCD Network Environment
- Characteristics module. Each unit represent
- a protocol or a group of protocols that may be used later
- by the different PCD engined to distinguich between flows.
+ @Description Parameters for defining all different distinction units supported
+ by a specific PCD Network Environment Characteristics module.
+
+ Each unit represent a protocol or a group of protocols that may
+ be used later by the different PCD engines to distinguish
+ between flows.
*//***************************************************************************/
typedef struct t_FmPcdNetEnvParams {
uint8_t numOfDistinctionUnits; /**< Number of different units to be identified */
@@ -1103,8 +1498,8 @@ typedef struct t_FmPcdNetEnvParams {
} t_FmPcdNetEnvParams;
/**************************************************************************//**
- @Description structure for defining a single extraction action
- when creating a key
+ @Description Parameters for defining a single extraction action when
+ creating a key
*//***************************************************************************/
typedef struct t_FmPcdExtractEntry {
e_FmPcdExtractType type; /**< Extraction type select */
@@ -1114,19 +1509,22 @@ typedef struct t_FmPcdExtractEntry {
bool ignoreProtocolValidation;
/**< Ignore protocol validation */
e_FmPcdHdrIndex hdrIndex; /**< Relevant only for MPLS, VLAN and tunneled
- IP. Otherwise should be cleared.*/
+ IP. Otherwise should be cleared. */
e_FmPcdExtractByHdrType type; /**< Header extraction type select */
union {
t_FmPcdFromHdr fromHdr; /**< Extract bytes from header parameters */
- t_FmPcdFromField fromField; /**< Extract bytes from field parameters*/
- t_FmPcdFields fullField; /**< Extract full filed parameters*/
+ t_FmPcdFromField fromField; /**< Extract bytes from field parameters */
+ t_FmPcdFields fullField; /**< Extract full filed parameters */
} extractByHdrType;
} extractByHdr; /**< used when type = e_FM_PCD_KG_EXTRACT_BY_HDR */
struct {
e_FmPcdExtractFrom src; /**< Non-header extraction source */
e_FmPcdAction action; /**< Relevant for CC Only */
- uint16_t icIndxMask; /**< Relevant only for CC where
- action=e_FM_PCD_ACTION_INDEXED_LOOKUP */
+ uint16_t icIndxMask; /**< Relevant only for CC when
+ action = e_FM_PCD_ACTION_INDEXED_LOOKUP;
+ Note that the number of bits that are set within
+ this mask must be log2 of the CC-node 'numOfKeys'.
+ Note that the mask cannot be set on the lower bits. */
uint8_t offset; /**< Byte offset */
uint8_t size; /**< Size in byte */
} extractNonHdr; /**< used when type = e_FM_PCD_KG_EXTRACT_NON_HDR */
@@ -1134,27 +1532,24 @@ typedef struct t_FmPcdExtractEntry {
} t_FmPcdExtractEntry;
/**************************************************************************//**
- @Description A structure for defining masks for each extracted
- field in the key.
+ @Description Parameters for defining masks for each extracted field in the key.
*//***************************************************************************/
typedef struct t_FmPcdKgExtractMask {
- uint8_t extractArrayIndex; /**< Index in the extraction array, as initialized by user */
- uint8_t offset; /**< Byte offset */
- uint8_t mask; /**< A byte mask (selected bits will be used) */
+ uint8_t extractArrayIndex; /**< Index in the extraction array, as initialized by user */
+ uint8_t offset; /**< Byte offset */
+ uint8_t mask; /**< A byte mask (selected bits will be used) */
} t_FmPcdKgExtractMask;
/**************************************************************************//**
- @Description A structure for defining default selection per groups
- of fields
+ @Description Parameters for defining default selection per groups of fields
*//***************************************************************************/
typedef struct t_FmPcdKgExtractDflt {
- e_FmPcdKgKnownFieldsDfltTypes type; /**< Default type select*/
+ e_FmPcdKgKnownFieldsDfltTypes type; /**< Default type select */
e_FmPcdKgExtractDfltSelect dfltSelect; /**< Default register select */
} t_FmPcdKgExtractDflt;
/**************************************************************************//**
- @Description A structure for defining all parameters needed for
- generation a key and using a hash function
+ @Description Parameters for defining key extraction and hashing
*//***************************************************************************/
typedef struct t_FmPcdKgKeyExtractAndHashParams {
uint32_t privateDflt0; /**< Scheme default register 0 */
@@ -1181,8 +1576,7 @@ typedef struct t_FmPcdKgKeyExtractAndHashParams {
} t_FmPcdKgKeyExtractAndHashParams;
/**************************************************************************//**
- @Description A structure of parameters for defining a single
- Fqid mask (extracted OR).
+ @Description Parameters for defining a single FQID mask (extracted OR).
*//***************************************************************************/
typedef struct t_FmPcdKgExtractedOrParams {
e_FmPcdExtractType type; /**< Extraction type select */
@@ -1193,7 +1587,7 @@ typedef struct t_FmPcdKgExtractedOrParams {
IP. Otherwise should be cleared.*/
bool ignoreProtocolValidation;
/**< continue extraction even if protocol is not recognized */
- } extractByHdr;
+ } extractByHdr; /**< Header to extract by */
e_FmPcdExtractFrom src; /**< used when type = e_FM_PCD_KG_EXTRACT_NON_HDR */
};
uint8_t extractionOffset; /**< Offset for extraction (in bytes). */
@@ -1226,7 +1620,7 @@ typedef struct t_FmPcdKgExtractedOrParams {
} t_FmPcdKgExtractedOrParams;
/**************************************************************************//**
- @Description A structure for configuring scheme counter
+ @Description Parameters for configuring a scheme counter
*//***************************************************************************/
typedef struct t_FmPcdKgSchemeCounter {
bool update; /**< FALSE to keep the current counter state
@@ -1237,54 +1631,85 @@ typedef struct t_FmPcdKgSchemeCounter {
} t_FmPcdKgSchemeCounter;
/**************************************************************************//**
- @Description A structure for defining policer profile
- parameters as required by keygen (when policer
- is the next engine after this scheme).
+ @Description Parameters for configuring a policer profile for a KeyGen scheme
+ (when policer is the next engine after this scheme).
*//***************************************************************************/
typedef struct t_FmPcdKgPlcrProfile {
bool sharedProfile; /**< TRUE if this profile is shared between ports
- (i.e. managed by master partition) May not be TRUE
+ (managed by master partition); Must not be TRUE
if profile is after Coarse Classification*/
bool direct; /**< if TRUE, directRelativeProfileId only selects the profile
id, if FALSE fqidOffsetRelativeProfileIdBase is used
together with fqidOffsetShift and numOfProfiles
parameters, to define a range of profiles from
- which the keygen result will determine the
+ which the KeyGen result will determine the
destination policer profile. */
union {
uint16_t directRelativeProfileId; /**< Used if 'direct' is TRUE, to select policer profile.
- This parameter should
- indicate the policer profile offset within the port's
- policer profiles or SHARED window. */
+ should indicate the policer profile offset within the
+ port's policer profiles or shared window. */
struct {
- uint8_t fqidOffsetShift; /**< shift of KG results without the qid base */
+ uint8_t fqidOffsetShift; /**< Shift on the KeyGen create FQID offset (i.e. not the
+ final FQID - without the FQID base). */
uint8_t fqidOffsetRelativeProfileIdBase;
- /**< OR of KG results without the qid base
- This parameter should indicate the policer profile
- offset within the port's policer profiles window or
- SHARED window depends on sharedProfile */
+ /**< The base of the FMan Port's relative Storage-Profile ID;
+ this value will be "OR'ed" with the KeyGen create FQID
+ offset (i.e. not the final FQID - without the FQID base);
+ the final result should indicate the Storage-Profile offset
+ within the FMan Port's relative Storage-Profiles window/
+ (or the SHARED window depends on 'sharedProfile'). */
uint8_t numOfProfiles; /**< Range of profiles starting at base */
- } indirectProfile;
- } profileSelect;
+ } indirectProfile; /**< Indirect profile parameters */
+ } profileSelect; /**< Direct/indirect profile selection and parameters */
} t_FmPcdKgPlcrProfile;
+#if (DPAA_VERSION >= 11)
+/**************************************************************************//**
+ @Description Parameters for configuring a storage profile for a KeyGen scheme.
+*//***************************************************************************/
+typedef struct t_FmPcdKgStorageProfile {
+ bool direct; /**< If TRUE, directRelativeProfileId only selects the
+ profile id;
+ If FALSE, fqidOffsetRelativeProfileIdBase is used
+ together with fqidOffsetShift and numOfProfiles
+ parameters to define a range of profiles from which
+ the KeyGen result will determine the destination
+ storage profile. */
+ union {
+ uint16_t directRelativeProfileId; /**< Used when 'direct' is TRUE, to select a storage profile;
+ should indicate the storage profile offset within the
+ port's storage profiles window. */
+ struct {
+ uint8_t fqidOffsetShift; /**< Shift on the KeyGen create FQID offset (i.e. not the
+ final FQID - without the FQID base). */
+ uint8_t fqidOffsetRelativeProfileIdBase;
+ /**< The base of the FMan Port's relative Storage-Profile ID;
+ this value will be "OR'ed" with the KeyGen create FQID
+ offset (i.e. not the final FQID - without the FQID base);
+ the final result should indicate the Storage-Profile offset
+ within the FMan Port's relative Storage-Profiles window. */
+ uint8_t numOfProfiles; /**< Range of profiles starting at base. */
+ } indirectProfile; /**< Indirect profile parameters. */
+ } profileSelect; /**< Direct/indirect profile selection and parameters. */
+} t_FmPcdKgStorageProfile;
+#endif /* (DPAA_VERSION >= 11) */
+
/**************************************************************************//**
- @Description A structure for CC parameters if CC is the next engine after KG
+ @Description Parameters for defining CC as the next engine after KeyGen
*//***************************************************************************/
typedef struct t_FmPcdKgCc {
- t_Handle h_CcTree; /**< A handle to a CC Tree */
- uint8_t grpId; /**< CC group id within the CC tree */
- bool plcrNext; /**< TRUE if after CC, in case of data frame,
- policing is required. */
- bool bypassPlcrProfileGeneration;
- /**< TRUE to bypass keygen policer profile
- generation (profile selected is the one selected at
- port initialization). */
- t_FmPcdKgPlcrProfile plcrProfile; /**< only if plcrNext=TRUE and bypassPlcrProfileGeneration=FALSE */
+ t_Handle h_CcTree; /**< A handle to a CC Tree */
+ uint8_t grpId; /**< CC group id within the CC tree */
+ bool plcrNext; /**< TRUE if after CC, in case of data frame,
+ policing is required. */
+ bool bypassPlcrProfileGeneration; /**< TRUE to bypass KeyGen policer profile generation;
+ selected profile is the one set at port initialization. */
+ t_FmPcdKgPlcrProfile plcrProfile; /**< Valid only if plcrNext = TRUE and
+ bypassPlcrProfileGeneration = FALSE */
} t_FmPcdKgCc;
/**************************************************************************//**
- @Description A structure for initializing a keygen single scheme
+ @Description Parameters for defining initializing a KeyGen scheme
*//***************************************************************************/
typedef struct t_FmPcdKgSchemeParams {
bool modify; /**< TRUE to change an existing scheme */
@@ -1292,35 +1717,41 @@ typedef struct t_FmPcdKgSchemeParams {
{
uint8_t relativeSchemeId; /**< if modify=FALSE:Partition relative scheme id */
t_Handle h_Scheme; /**< if modify=TRUE: a handle of the existing scheme */
- }id;
- bool alwaysDirect; /**< This scheme is reached only directly, i.e. no need for match vector. Keygen will ignore
- it when matching */
+ } id;
+ bool alwaysDirect; /**< This scheme is reached only directly, i.e. no need
+ for match vector; KeyGen will ignore it when matching */
struct { /**< HL Relevant only if alwaysDirect = FALSE */
t_Handle h_NetEnv; /**< A handle to the Network environment as returned
- by FM_PCD_SetNetEnvCharacteristics() */
- uint8_t numOfDistinctionUnits; /**< Number of netenv units listed in unitIds array */
+ by FM_PCD_NetEnvCharacteristicsSet() */
+ uint8_t numOfDistinctionUnits; /**< Number of NetEnv units listed in unitIds array */
uint8_t unitIds[FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS];
/**< Indexes as passed to SetNetEnvCharacteristics array*/
} netEnvParams;
- bool useHash; /**< use the KG Hash functionality */
+ bool useHash; /**< use the KeyGen Hash functionality */
t_FmPcdKgKeyExtractAndHashParams keyExtractAndHashParams;
/**< used only if useHash = TRUE */
bool bypassFqidGeneration; /**< Normally - FALSE, TRUE to avoid FQID update in the IC;
- In such a case FQID after KG will be the default FQID
+ In such a case FQID after KeyGen will be the default FQID
defined for the relevant port, or the FQID defined by CC
in cases where CC was the previous engine. */
uint32_t baseFqid; /**< Base FQID; Relevant only if bypassFqidGeneration = FALSE;
If hash is used and an even distribution is expected
according to hashDistributionNumOfFqids, baseFqid must be aligned to
- hashDistributionNumOfFqids. */
- uint8_t numOfUsedExtractedOrs; /**< Number of Fqid masks listed in extractedOrs array*/
+ hashDistributionNumOfFqids. */
+ uint8_t numOfUsedExtractedOrs; /**< Number of FQID masks listed in extractedOrs array */
t_FmPcdKgExtractedOrParams extractedOrs[FM_PCD_KG_NUM_OF_GENERIC_REGS];
- /**< IN: FM_PCD_KG_NUM_OF_GENERIC_REGS
+ /**< FM_PCD_KG_NUM_OF_GENERIC_REGS
registers are shared between qidMasks
functionality and some of the extraction
actions; Normally only some will be used
for qidMask. Driver will return error if
resource is full at initialization time. */
+
+#if (DPAA_VERSION >= 11)
+ bool overrideStorageProfile; /**< TRUE if KeyGen override previously decided storage profile */
+ t_FmPcdKgStorageProfile storageProfile; /**< Used when overrideStorageProfile TRUE */
+#endif /* (DPAA_VERSION >= 11) */
+
e_FmPcdEngine nextEngine; /**< may be BMI, PLCR or CC */
union { /**< depends on nextEngine */
e_FmPcdDoneAction doneAction; /**< Used when next engine is BMI (done) */
@@ -1332,23 +1763,40 @@ typedef struct t_FmPcdKgSchemeParams {
} t_FmPcdKgSchemeParams;
/**************************************************************************//**
- @Description A structure for defining CC params when CC is the
- next engine after a CC node.
+ @Collection Definitions for CC statistics
+*//***************************************************************************/
+#if (DPAA_VERSION >= 11)
+#define FM_PCD_CC_STATS_MAX_NUM_OF_FLR 10 /* Maximal supported number of frame length ranges */
+#define FM_PCD_CC_STATS_FLR_SIZE 2 /* Size in bytes of a frame length range limit */
+#endif /* (DPAA_VERSION >= 11) */
+#define FM_PCD_CC_STATS_COUNTER_SIZE 4 /* Size in bytes of a frame length range counter */
+/* @} */
+
+/**************************************************************************//**
+ @Description Parameters for defining CC as the next engine after a CC node.
*//***************************************************************************/
typedef struct t_FmPcdCcNextCcParams {
t_Handle h_CcNode; /**< A handle of the next CC node */
} t_FmPcdCcNextCcParams;
+#if (DPAA_VERSION >= 11)
/**************************************************************************//**
- @Description A structure for defining PLCR params when PLCR is the
- next engine after a CC node.
+ @Description Parameters for defining Frame replicator as the next engine after a CC node.
+*//***************************************************************************/
+typedef struct t_FmPcdCcNextFrParams {
+ t_Handle h_FrmReplic; /**< A handle of the next frame replicator group */
+} t_FmPcdCcNextFrParams;
+#endif /* (DPAA_VERSION >= 11) */
+
+/**************************************************************************//**
+ @Description Parameters for defining Policer as the next engine after a CC node.
*//***************************************************************************/
typedef struct t_FmPcdCcNextPlcrParams {
bool overrideParams; /**< TRUE if CC override previously decided parameters*/
bool sharedProfile; /**< Relevant only if overrideParams=TRUE:
TRUE if this profile is shared between ports */
uint16_t newRelativeProfileId; /**< Relevant only if overrideParams=TRUE:
- (otherwise profile id is taken from keygen);
+ (otherwise profile id is taken from KeyGen);
This parameter should indicate the policer
profile offset within the port's
policer profiles or from SHARED window.*/
@@ -1357,107 +1805,200 @@ typedef struct t_FmPcdCcNextPlcrParams {
In earlier chips if policer next engine is KEYGEN,
this parameter can be 0, because the KEYGEN
always decides the enqueue FQID.*/
- bool statisticsEn; /**< In the case of TRUE Statistic counter is
- incremented for each received frame passed through
- this Coarse Classification entry.*/
+#if (DPAA_VERSION >= 11)
+ uint8_t newRelativeStorageProfileId;
+ /**< Indicates the relative storage profile offset within
+ the port's storage profiles window;
+ Relevant only if the port was configured with VSP. */
+#endif /* (DPAA_VERSION >= 11) */
} t_FmPcdCcNextPlcrParams;
/**************************************************************************//**
- @Description A structure for defining enqueue params when BMI is the
- next engine after a CC node.
+ @Description Parameters for defining enqueue as the next action after a CC node.
*//***************************************************************************/
typedef struct t_FmPcdCcNextEnqueueParams {
-
e_FmPcdDoneAction action; /**< Action - when next engine is BMI (done) */
- bool overrideFqid; /**< TRUE if CC override previously decided Fqid(by Keygen),
+ bool overrideFqid; /**< TRUE if CC override previously decided fqid and vspid,
relevant if action = e_FM_PCD_ENQ_FRAME */
uint32_t newFqid; /**< Valid if overrideFqid=TRUE, FQID for enqueuing the frame
- (otherwise FQID is taken from keygen),
- relevant if action = e_FM_PCD_ENQ_FRAME*/
- bool statisticsEn; /**< In the case of TRUE Statistic counter is
- incremented for each received frame passed through
- this Coarse Classification entry.*/
+ (otherwise FQID is taken from KeyGen),
+ relevant if action = e_FM_PCD_ENQ_FRAME */
+#if (DPAA_VERSION >= 11)
+ uint8_t newRelativeStorageProfileId;
+ /**< Valid if overrideFqid=TRUE, Indicates the relative virtual
+ storage profile offset within the port's storage profiles
+ window; Relevant only if the port was configured with VSP. */
+#endif /* (DPAA_VERSION >= 11) */
} t_FmPcdCcNextEnqueueParams;
/**************************************************************************//**
- @Description A structure for defining KG params when KG is the
- next engine after a CC node.
+ @Description Parameters for defining KeyGen as the next engine after a CC node.
*//***************************************************************************/
typedef struct t_FmPcdCcNextKgParams {
- bool overrideFqid; /**< TRUE if CC override previously decided Fqid (by keygen),
- Note - this parameters irrelevant for earlier chips*/
+ bool overrideFqid; /**< TRUE if CC override previously decided fqid and vspid,
+ Note - this parameters irrelevant for earlier chips */
uint32_t newFqid; /**< Valid if overrideFqid=TRUE, FQID for enqueuing the frame
- (otherwise FQID is taken from keygen),
- Note - this parameters irrelevant for earlier chips*/
+ (otherwise FQID is taken from KeyGen),
+ Note - this parameters irrelevant for earlier chips */
+#if (DPAA_VERSION >= 11)
+ uint8_t newRelativeStorageProfileId;
+ /**< Valid if overrideFqid=TRUE, Indicates the relative virtual
+ storage profile offset within the port's storage profiles
+ window; Relevant only if the port was configured with VSP. */
+#endif /* (DPAA_VERSION >= 11) */
+
t_Handle h_DirectScheme; /**< Direct scheme handle to go to. */
- bool statisticsEn; /**< In the case of TRUE Statistic counter is
- incremented for each received frame passed through
- this Coarse Classification entry.*/
} t_FmPcdCcNextKgParams;
/**************************************************************************//**
- @Description A structure for defining next engine params after a CC node.
+ @Description Parameters for defining the next engine after a CC node.
*//***************************************************************************/
typedef struct t_FmPcdCcNextEngineParams {
- e_FmPcdEngine nextEngine; /**< User has to initialize parameters
- according to nextEngine definition */
+ e_FmPcdEngine nextEngine; /**< User has to initialize parameters
+ according to nextEngine definition */
union {
- t_FmPcdCcNextCcParams ccParams; /**< Parameters in case next engine is CC */
- t_FmPcdCcNextPlcrParams plcrParams; /**< Parameters in case next engine is PLCR */
- t_FmPcdCcNextEnqueueParams enqueueParams; /**< Parameters in case next engine is BMI */
- t_FmPcdCcNextKgParams kgParams; /**< Parameters in case next engine is KG */
- } params;
-#if defined(FM_CAPWAP_SUPPORT)
- t_Handle h_Manip; /**< Handler to headerManip.
- Relevant if next engine of the type result
- (e_FM_PCD_PLCR, e_FM_PCD_KG, e_FM_PCD_DONE) */
-#endif /* defined(FM_CAPWAP_SUPPORT) || ... */
+ t_FmPcdCcNextCcParams ccParams; /**< Parameters in case next engine is CC */
+ t_FmPcdCcNextPlcrParams plcrParams; /**< Parameters in case next engine is PLCR */
+ t_FmPcdCcNextEnqueueParams enqueueParams; /**< Parameters in case next engine is BMI */
+ t_FmPcdCcNextKgParams kgParams; /**< Parameters in case next engine is KG */
+#if (DPAA_VERSION >= 11)
+ t_FmPcdCcNextFrParams frParams; /**< Parameters in case next engine is FR */
+#endif /* (DPAA_VERSION >= 11) */
+ } params; /**< union used for all the next-engine parameters options */
+
+ t_Handle h_Manip; /**< Handle to Manipulation object.
+ Relevant if next engine is of type result
+ (e_FM_PCD_PLCR, e_FM_PCD_KG, e_FM_PCD_DONE) */
+
+ bool statisticsEn; /**< If TRUE, statistics counters are incremented
+ for each frame passing through this
+ Coarse Classification entry. */
} t_FmPcdCcNextEngineParams;
/**************************************************************************//**
- @Description A structure for defining a single CC Key parameters
+ @Description Parameters for defining a single CC key
*//***************************************************************************/
typedef struct t_FmPcdCcKeyParams {
- uint8_t *p_Key; /**< pointer to the key of the size defined in keySize*/
- uint8_t *p_Mask; /**< pointer to the Mask per key of the size defined
+ uint8_t *p_Key; /**< Relevant only if 'action' = e_FM_PCD_ACTION_EXACT_MATCH;
+ pointer to the key of the size defined in keySize */
+ uint8_t *p_Mask; /**< Relevant only if 'action' = e_FM_PCD_ACTION_EXACT_MATCH;
+ pointer to the Mask per key of the size defined
in keySize. p_Key and p_Mask (if defined) has to be
- of the same size defined in the keySize */
+ of the same size defined in the keySize;
+ NOTE that if this value is equal for all entries whithin
+ this table, the driver will automatically use global-mask
+ (i.e. one common mask for all entries) instead of private
+ one; that is done in order to spare some memory and for
+ better performance. */
t_FmPcdCcNextEngineParams ccNextEngineParams;
/**< parameters for the next for the defined Key in
the p_Key */
} t_FmPcdCcKeyParams;
/**************************************************************************//**
- @Description A structure for defining CC Keys parameters
+ @Description Parameters for defining CC keys parameters
+ The driver supports two methods for CC node allocation: dynamic and static.
+ Static mode was created in order to prevent runtime alloc/free
+ of FMan memory (MURAM), which may cause fragmentation; in this mode,
+ the driver automatically allocates the memory according to
+ 'maxNumOfKeys' parameter. The driver calculates the maximal memory
+ size that may be used for this CC-Node taking into consideration
+ 'maskSupport' and 'statisticsMode' parameters.
+ When 'action' = e_FM_PCD_ACTION_INDEXED_LOOKUP in the extraction
+ parameters of this node, 'maxNumOfKeys' must be equal to 'numOfKeys'.
+ In dynamic mode, 'maxNumOfKeys' must be zero. At initialization,
+ all required structures are allocated according to 'numOfKeys'
+ parameter. During runtime modification, these structures are
+ re-allocated according to the updated number of keys.
+
+ Please note that 'action' and 'icIndxMask' mentioned in the
+ specific parameter explanations are passed in the extraction
+ parameters of the node (fields of extractCcParams.extractNonHdr).
*//***************************************************************************/
typedef struct t_KeysParams {
- uint8_t numOfKeys; /**< Number Of relevant Keys */
- uint8_t keySize; /**< size of the key - in the case of the extraction of
- the type FULL_FIELD keySize has to be as standard size of the relevant
- key. In the another type of extraction keySize has to be as size of extraction.
- In the case of action = e_FM_PCD_ACTION_INDEXED_LOOKUP the size of keySize has to be 2*/
+ uint16_t maxNumOfKeys; /**< Maximum number of keys that will (ever) be used in this CC-Node;
+ A value of zero may be used for dynamic memory allocation. */
+ bool maskSupport; /**< This parameter is relevant only if a node is initialized with
+ 'action' = e_FM_PCD_ACTION_EXACT_MATCH and maxNumOfKeys > 0;
+ Should be TRUE to reserve table memory for key masks, even if
+ initial keys do not contain masks, or if the node was initialized
+ as 'empty' (without keys); this will allow user to add keys with
+ masks at runtime.
+ NOTE that if user want to use only global-masks (i.e. one common mask
+ for all the entries within this table, this parameter should set to 'FALSE'. */
+ e_FmPcdCcStatsMode statisticsMode; /**< Determines the supported statistics mode for all node's keys.
+ To enable statistics gathering, statistics should be enabled per
+ every key, using 'statisticsEn' in next engine parameters structure
+ of that key;
+ If 'maxNumOfKeys' is set, all required structures will be
+ preallocated for all keys. */
+#if (DPAA_VERSION >= 11)
+ uint16_t frameLengthRanges[FM_PCD_CC_STATS_MAX_NUM_OF_FLR];
+ /**< Relevant only for 'RMON' statistics mode
+ (this feature is supported only on B4860 device);
+ Holds a list of programmable thresholds - for each received frame,
+ its length in bytes is examined against these range thresholds and
+ the appropriate counter is incremented by 1 - for example, to belong
+ to range i, the following should hold:
+ range i-1 threshold < frame length <= range i threshold
+ Each range threshold must be larger then its preceding range
+ threshold, and last range threshold must be 0xFFFF. */
+#endif /* (DPAA_VERSION >= 11) */
+ uint16_t numOfKeys; /**< Number of initial keys;
+ Note that in case of 'action' = e_FM_PCD_ACTION_INDEXED_LOOKUP,
+ this field should be power-of-2 of the number of bits that are
+ set in 'icIndxMask'. */
+ uint8_t keySize; /**< Size of key - for extraction of type FULL_FIELD, 'keySize' has
+ to be the standard size of the selected key; For other extraction
+ types, 'keySize' has to be as size of extraction; When 'action' =
+ e_FM_PCD_ACTION_INDEXED_LOOKUP, 'keySize' must be 2. */
t_FmPcdCcKeyParams keyParams[FM_PCD_MAX_NUM_OF_KEYS];
- /**< it's array with numOfKeys entries each entry in
- the array of the type t_FmPcdCcKeyParams */
+ /**< An array with 'numOfKeys' entries, each entry specifies the
+ corresponding key parameters;
+ When 'action' = e_FM_PCD_ACTION_EXACT_MATCH, this value must not
+ exceed 255 (FM_PCD_MAX_NUM_OF_KEYS-1) as the last entry is saved
+ for the 'miss' entry. */
t_FmPcdCcNextEngineParams ccNextEngineParamsForMiss;
- /**< parameters for the next step of
- unfound (or undefined) key . Not relevant in the case
- of action = e_FM_PCD_ACTION_INDEXED_LOOKUP*/
+ /**< Parameters for defining the next engine when a key is not matched;
+ Not relevant if action = e_FM_PCD_ACTION_INDEXED_LOOKUP. */
} t_KeysParams;
+
/**************************************************************************//**
- @Description A structure for defining the CC node params
+ @Description Parameters for defining a CC node
*//***************************************************************************/
typedef struct t_FmPcdCcNodeParams {
- t_FmPcdExtractEntry extractCcParams; /**< params which defines extraction parameters */
- t_KeysParams keysParams; /**< params which defines Keys parameters of the
- extraction defined in extractCcParams */
+ t_FmPcdExtractEntry extractCcParams; /**< Extraction parameters */
+ t_KeysParams keysParams; /**< Keys definition matching the selected extraction */
} t_FmPcdCcNodeParams;
/**************************************************************************//**
- @Description A structure for defining each CC tree group in term of
- NetEnv units and the action to be taken in each case.
- the unitIds list must be in order from lower to higher indexes.
+ @Description Parameters for defining a hash table
+*//***************************************************************************/
+typedef struct t_FmPcdHashTableParams {
+ uint16_t maxNumOfKeys; /**< Maximum Number Of Keys that will (ever) be used in this Hash-table */
+ e_FmPcdCcStatsMode statisticsMode; /**< If not e_FM_PCD_CC_STATS_MODE_NONE, the required structures for the
+ requested statistics mode will be allocated according to maxNumOfKeys. */
+ uint8_t kgHashShift; /**< KG-Hash-shift as it was configured in the KG-scheme
+ that leads to this hash-table. */
+ uint16_t hashResMask; /**< Mask that will be used on the hash-result;
+ The number-of-sets for this hash will be calculated
+ as (2^(number of bits set in 'hashResMask'));
+ The 4 lower bits must be cleared. */
+ uint8_t hashShift; /**< Byte offset from the beginning of the KeyGen hash result to the
+ 2-bytes to be used as hash index. */
+ uint8_t matchKeySize; /**< Size of the exact match keys held by the hash buckets */
+
+ t_FmPcdCcNextEngineParams ccNextEngineParamsForMiss; /**< Parameters for defining the next engine when a key is not matched */
+
+} t_FmPcdHashTableParams;
+
+/**************************************************************************//**
+ @Description Parameters for defining a CC tree group.
+
+ This structure defines a CC group in terms of NetEnv units
+ and the action to be taken in each case. The unitIds list must
+ be given in order from low to high indices.
t_FmPcdCcNextEngineParams is a list of 2^numOfDistinctionUnits
structures where each defines the next action to be taken for
@@ -1474,26 +2015,46 @@ typedef struct t_FmPcdCcNodeParams {
unit 1 - found; unit 3 - found;
*//***************************************************************************/
typedef struct t_FmPcdCcGrpParams {
- uint8_t numOfDistinctionUnits; /**< up to 4 */
+ uint8_t numOfDistinctionUnits; /**< Up to 4 */
uint8_t unitIds[FM_PCD_MAX_NUM_OF_CC_UNITS];
- /**< Indexes of the units as defined in
- FM_PCD_SetNetEnvCharacteristics() */
+ /**< Indices of the units as defined in
+ FM_PCD_NetEnvCharacteristicsSet() */
t_FmPcdCcNextEngineParams nextEnginePerEntriesInGrp[FM_PCD_MAX_NUM_OF_CC_ENTRIES_IN_GRP];
- /**< Max size is 16 - if only one group used */
+ /**< Maximum entries per group is 16 */
} t_FmPcdCcGrpParams;
/**************************************************************************//**
- @Description A structure for defining the CC tree groups
+ @Description Parameters for defining CC tree groups
*//***************************************************************************/
typedef struct t_FmPcdCcTreeParams {
- t_Handle h_NetEnv; /**< A handle to the Network environment as returned
- by FM_PCD_SetNetEnvCharacteristics() */
- uint8_t numOfGrps; /**< Number of CC groups within the CC tree */
- t_FmPcdCcGrpParams ccGrpParams[FM_PCD_MAX_NUM_OF_CC_GROUPS]; /**< Parameters for each group. */
+ t_Handle h_NetEnv; /**< A handle to the Network environment as returned
+ by FM_PCD_NetEnvCharacteristicsSet() */
+ uint8_t numOfGrps; /**< Number of CC groups within the CC tree */
+ t_FmPcdCcGrpParams ccGrpParams[FM_PCD_MAX_NUM_OF_CC_GROUPS];
+ /**< Parameters for each group. */
} t_FmPcdCcTreeParams;
+
/**************************************************************************//**
- @Description A structure for defining parameters for byte rate
+ @Description CC key statistics structure
+*//***************************************************************************/
+typedef struct t_FmPcdCcKeyStatistics {
+ uint32_t byteCount; /**< This counter reflects byte count of frames that
+ were matched by this key. */
+ uint32_t frameCount; /**< This counter reflects count of frames that
+ were matched by this key. */
+#if (DPAA_VERSION >= 11)
+ uint32_t frameLengthRangeCount[FM_PCD_CC_STATS_MAX_NUM_OF_FLR];
+ /**< These counters reflect how many frames matched
+ this key in 'RMON' statistics mode:
+ Each counter holds the number of frames of a
+ specific frames length range, according to the
+ ranges provided at initialization. */
+#endif /* (DPAA_VERSION >= 11) */
+} t_FmPcdCcKeyStatistics;
+
+/**************************************************************************//**
+ @Description Parameters for defining policer byte rate
*//***************************************************************************/
typedef struct t_FmPcdPlcrByteRateModeParams {
e_FmPcdPlcrFrameLengthSelect frameLengthSelection; /**< Frame length selection */
@@ -1502,30 +2063,30 @@ typedef struct t_FmPcdPlcrByteRateModeParams {
} t_FmPcdPlcrByteRateModeParams;
/**************************************************************************//**
- @Description A structure for selcting the policer profile RFC-2698 or
- RFC-4115 parameters
+ @Description Parameters for defining the policer profile (based on
+ RFC-2698 or RFC-4115 attributes).
*//***************************************************************************/
typedef struct t_FmPcdPlcrNonPassthroughAlgParams {
- e_FmPcdPlcrRateMode rateMode; /**< Byte / Packet */
+ e_FmPcdPlcrRateMode rateMode; /**< Byte mode or Packet mode */
t_FmPcdPlcrByteRateModeParams byteModeParams; /**< Valid for Byte NULL for Packet */
- uint32_t comittedInfoRate; /**< KBits/Sec or Packets/Sec */
- uint32_t comittedBurstSize; /**< Bytes/Packets */
- uint32_t peakOrAccessiveInfoRate; /**< KBits/Sec or Packets/Sec */
- uint32_t peakOrAccessiveBurstSize; /**< Bytes/Packets */
+ uint32_t committedInfoRate; /**< KBits/Second or Packets/Second */
+ uint32_t committedBurstSize; /**< Bytes/Packets */
+ uint32_t peakOrExcessInfoRate; /**< KBits/Second or Packets/Second */
+ uint32_t peakOrExcessBurstSize; /**< Bytes/Packets */
} t_FmPcdPlcrNonPassthroughAlgParams;
/**************************************************************************//**
- @Description A union for defining Policer next engine parameters
+ @Description Parameters for defining the next engine after policer
*//***************************************************************************/
typedef union u_FmPcdPlcrNextEngineParams {
- e_FmPcdDoneAction action; /**< Action - when next engine is BMI (done) */
- t_Handle h_Profile; /**< Policer profile handle - used when next engine
- is PLCR, must be a SHARED profile */
- t_Handle h_DirectScheme; /**< Direct scheme select - when next engine is Keygen */
+ e_FmPcdDoneAction action; /**< Action - when next engine is BMI (done) */
+ t_Handle h_Profile; /**< Policer profile handle - used when next engine
+ is Policer, must be a SHARED profile */
+ t_Handle h_DirectScheme; /**< Direct scheme select - when next engine is KeyGen */
} u_FmPcdPlcrNextEngineParams;
/**************************************************************************//**
- @Description A structure for selecting the policer profile entry parameters
+ @Description Parameters for defining the policer profile entry
*//***************************************************************************/
typedef struct t_FmPcdPlcrProfileParams {
bool modify; /**< TRUE to change an existing profile */
@@ -1534,87 +2095,80 @@ typedef struct t_FmPcdPlcrProfileParams {
e_FmPcdProfileTypeSelection profileType; /**< Type of policer profile */
t_Handle h_FmPort; /**< Relevant for per-port profiles only */
uint16_t relativeProfileId; /**< Profile id - relative to shared group or to port */
- } newParams; /**< use it when modify=FALSE */
+ } newParams; /**< use it when modify = FALSE */
t_Handle h_Profile; /**< A handle to a profile - use it when modify=TRUE */
} id;
e_FmPcdPlcrAlgorithmSelection algSelection; /**< Profile Algorithm PASS_THROUGH, RFC_2698, RFC_4115 */
e_FmPcdPlcrColorMode colorMode; /**< COLOR_BLIND, COLOR_AWARE */
union {
- e_FmPcdPlcrColor dfltColor; /**< For Color-Blind Pass-Through mode. the policer will re-color
+ e_FmPcdPlcrColor dfltColor; /**< For Color-Blind Pass-Through mode; the policer will re-color
any incoming packet with the default value. */
- e_FmPcdPlcrColor override; /**< For Color-Aware modes. The profile response to a
+ e_FmPcdPlcrColor override; /**< For Color-Aware modes; the profile response to a
pre-color value of 2'b11. */
} color;
- t_FmPcdPlcrNonPassthroughAlgParams nonPassthroughAlgParams; /**< RFC2698 or RFC4115 params */
+ t_FmPcdPlcrNonPassthroughAlgParams nonPassthroughAlgParams; /**< RFC2698 or RFC4115 parameters */
- e_FmPcdEngine nextEngineOnGreen; /**< Green next engine type */
- u_FmPcdPlcrNextEngineParams paramsOnGreen; /**< Green next engine params */
+ e_FmPcdEngine nextEngineOnGreen; /**< Next engine for green-colored frames */
+ u_FmPcdPlcrNextEngineParams paramsOnGreen; /**< Next engine parameters for green-colored frames */
- e_FmPcdEngine nextEngineOnYellow; /**< Yellow next engine type */
- u_FmPcdPlcrNextEngineParams paramsOnYellow; /**< Yellow next engine params */
+ e_FmPcdEngine nextEngineOnYellow; /**< Next engine for yellow-colored frames */
+ u_FmPcdPlcrNextEngineParams paramsOnYellow; /**< Next engine parameters for yellow-colored frames */
- e_FmPcdEngine nextEngineOnRed; /**< Red next engine type */
- u_FmPcdPlcrNextEngineParams paramsOnRed; /**< Red next engine params */
+ e_FmPcdEngine nextEngineOnRed; /**< Next engine for red-colored frames */
+ u_FmPcdPlcrNextEngineParams paramsOnRed; /**< Next engine parameters for red-colored frames */
- bool trapProfileOnFlowA; /**< Trap on flow A */
- bool trapProfileOnFlowB; /**< Trap on flow B */
- bool trapProfileOnFlowC; /**< Trap on flow C */
+ bool trapProfileOnFlowA; /**< Obsolete - do not use */
+ bool trapProfileOnFlowB; /**< Obsolete - do not use */
+ bool trapProfileOnFlowC; /**< Obsolete - do not use */
} t_FmPcdPlcrProfileParams;
-#if defined(FM_CAPWAP_SUPPORT)
/**************************************************************************//**
- @Description A structure for selecting the location of manipulation
+ @Description Parameters for selecting a location for requested manipulation
*//***************************************************************************/
-typedef struct t_FmPcdManipLocationParams {
- e_FmPcdManipLocateType type; /**< location of manipulation type select */
- struct { /**< used when type = e_FM_PCD_MANIP_BY_HDR */
- e_NetHeaderType hdr; /**< Header selection */
- e_FmPcdHdrIndex hdrIndex; /**< Relevant only for MPLS, VLAN and tunneled
- IP. Otherwise should be cleared. */
- bool byField; /**< TRUE if the location of manipulation is according to some field in the specific header*/
- t_FmPcdFields fullField; /**< Relevant only when byField = TRUE: Extract field */
- } manipByHdr;
-} t_FmPcdManipLocationParams;
+typedef struct t_FmManipHdrInfo {
+ e_NetHeaderType hdr; /**< Header selection */
+ e_FmPcdHdrIndex hdrIndex; /**< Relevant only for MPLS, VLAN and tunneled IP. Otherwise should be cleared. */
+ bool byField; /**< TRUE if the location of manipulation is according to some field in the specific header*/
+ t_FmPcdFields fullField; /**< Relevant only when byField = TRUE: Extract field */
+} t_FmManipHdrInfo;
+#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
/**************************************************************************//**
- @Description structure for defining insert manipulation
- of the type e_FM_PCD_MANIP_INSRT_TO_START_OF_FRAME_TEMPLATE
+ @Description Parameters for defining an insertion manipulation
+ of type e_FM_PCD_MANIP_INSRT_TO_START_OF_FRAME_TEMPLATE
*//***************************************************************************/
-typedef struct t_FmPcdManipInsrtByTemplateParams {
- uint8_t size; /**< size of insert template to the start of the frame. */
+typedef struct t_FmPcdManipHdrInsrtByTemplateParams {
+ uint8_t size; /**< Size of insert template to the start of the frame. */
uint8_t hdrTemplate[FM_PCD_MAX_MANIP_INSRT_TEMPLATE_SIZE];
- /**< array of the insertion template. */
+ /**< Array of the insertion template. */
bool modifyOuterIp; /**< TRUE if user want to modify some fields in outer IP. */
struct {
- uint16_t ipOuterOffset; /**< offset of outer IP in the insert template, relevant if modifyOuterIp = TRUE.*/
+ uint16_t ipOuterOffset; /**< Offset of outer IP in the insert template, relevant if modifyOuterIp = TRUE.*/
uint16_t dscpEcn; /**< value of dscpEcn in IP outer, relevant if modifyOuterIp = TRUE.
in IPV4 dscpEcn only byte - it has to be adjusted to the right*/
bool udpPresent; /**< TRUE if UDP is present in the insert template, relevant if modifyOuterIp = TRUE.*/
- uint8_t udpOffset; /**< offset in the insert template of UDP, relevant if modifyOuterIp = TRUE and udpPresent=TRUE.*/
+ uint8_t udpOffset; /**< Offset in the insert template of UDP, relevant if modifyOuterIp = TRUE and udpPresent=TRUE.*/
uint8_t ipIdentGenId; /**< Used by FMan-CTRL to calculate IP-identification field,relevant if modifyOuterIp = TRUE.*/
bool recalculateLength; /**< TRUE if recalculate length has to be performed due to the engines in the path which can change the frame later, relevant if modifyOuterIp = TRUE.*/
struct {
- uint8_t blockSize; /**< The CAAM block-size; Used by FMan-CTRL to calculate the IP-total-len field.*/
- uint8_t extraBytesAddedAlignedToBlockSize; /**< Used by FMan-CTRL to calculate the IP-total-len field and UDP length*/
- uint8_t extraBytesAddedNotAlignedToBlockSize;/**< Used by FMan-CTRL to calculate the IP-total-len field and UDP length.*/
- } recalculateLengthParams; /**< recalculate length parameters - relevant if modifyOuterIp = TRUE and recalculateLength = TRUE */
+ uint8_t blockSize; /**< The CAAM block-size; Used by FMan-CTRL to calculate the IP Total Length field.*/
+ uint8_t extraBytesAddedAlignedToBlockSize; /**< Used by FMan-CTRL to calculate the IP Total Length field and UDP length*/
+ uint8_t extraBytesAddedNotAlignedToBlockSize;/**< Used by FMan-CTRL to calculate the IP Total Length field and UDP length.*/
+ } recalculateLengthParams; /**< Recalculate length parameters - relevant if modifyOuterIp = TRUE and recalculateLength = TRUE */
} modifyOuterIpParams; /**< Outer IP modification parameters - ignored if modifyOuterIp is FALSE */
- bool modifyOuterVlan; /**< TRUE if user wants to modify vpri field in the outer VLAN header*/
+ bool modifyOuterVlan; /**< TRUE if user wants to modify VPri field in the outer VLAN header*/
struct {
- uint8_t vpri; /**< value of vpri, relevant if modifyOuterVlan = TRUE
- vpri only 3 bits, it has to be adjusted to the right*/
+ uint8_t vpri; /**< Value of VPri, relevant if modifyOuterVlan = TRUE
+ VPri only 3 bits, it has to be adjusted to the right*/
} modifyOuterVlanParams;
-} t_FmPcdManipInsrtByTemplateParams;
-#endif /* defined(FM_CAPWAP_SUPPORT) || ... */
-
+} t_FmPcdManipHdrInsrtByTemplateParams;
-#ifdef FM_CAPWAP_SUPPORT
/**************************************************************************//**
- @Description structure for defining CAPWAP fragmentation
+ @Description Parameters for defining CAPWAP fragmentation
*//***************************************************************************/
typedef struct t_CapwapFragmentationParams {
uint16_t sizeForFragmentation; /**< if length of the frame is greater than this value, CAPWAP fragmentation will be executed.*/
@@ -1624,120 +2178,758 @@ typedef struct t_CapwapFragmentationParams {
} t_CapwapFragmentationParams;
/**************************************************************************//**
- @Description structure for defining CAPWAP Re-assembly
+ @Description Parameters for defining CAPWAP reassembly
*//***************************************************************************/
typedef struct t_CapwapReassemblyParams {
- uint16_t maxNumFramesInProcess; /**< Number of frames which can be processed by Reassembly in the same time.
- It has to be power of 2.
- In the case numOfFramesPerHashEntry == e_FM_PCD_MANIP_FOUR_WAYS_HASH,
+ uint16_t maxNumFramesInProcess; /**< Number of frames which can be reassembled concurrently; must be power of 2.
+ In case numOfFramesPerHashEntry == e_FM_PCD_MANIP_FOUR_WAYS_HASH,
maxNumFramesInProcess has to be in the range of 4 - 512,
- In the case numOfFramesPerHashEntry == e_FM_PCD_MANIP_EIGHT_WAYS_HASH,
+ In case numOfFramesPerHashEntry == e_FM_PCD_MANIP_EIGHT_WAYS_HASH,
maxNumFramesInProcess has to be in the range of 8 - 2048 */
- bool haltOnDuplicationFrag; /**< In the case of TRUE, Reassembly process halted due to duplicated fragment,
- and all processed fragments passed for enqueue with error indication.
- In the case of FALSE, only duplicated fragment passed for enqueue with error indication */
+ bool haltOnDuplicationFrag; /**< If TRUE, reassembly process will be halted due to duplicated fragment,
+ and all processed fragments will be enqueued with error indication;
+ If FALSE, only duplicated fragments will be enqueued with error indication. */
- e_FmPcdManipReassemTimeOutMode timeOutMode; /**< Expiration delay initialized by Reassembly process */
- uint32_t fqidForTimeOutFrames; /**< Fqid in which time out frames will enqueue during Time Out Process */
+ e_FmPcdManipReassemTimeOutMode timeOutMode; /**< Expiration delay initialized by the reassembly process */
+ uint32_t fqidForTimeOutFrames; /**< FQID in which time out frames will enqueue during Time Out Process */
uint32_t timeoutRoutineRequestTime;
/**< Represents the time interval in microseconds between consecutive
timeout routine requests It has to be power of 2. */
uint32_t timeoutThresholdForReassmProcess;
- /**< Represents the time interval in microseconds which defines
- if opened frame (at least one fragment was processed but not all the fragments)is found as too old*/
+ /**< Time interval (microseconds) for marking frames in process as too old;
+ Frames in process are those for which at least one fragment was received
+ but not all fragments. */
- e_FmPcdManipReassemWaysNumber numOfFramesPerHashEntry;/**< Number of frames per hash entry needed for reassembly process */
+ e_FmPcdManipReassemWaysNumber numOfFramesPerHashEntry;/**< Number of frames per hash entry (needed for the reassembly process) */
} t_CapwapReassemblyParams;
-#endif /* FM_CAPWAP_SUPPORT */
-
-#if defined(FM_CAPWAP_SUPPORT)
/**************************************************************************//**
- @Description structure for defining fragmentation/reassembly
+ @Description Parameters for defining fragmentation/reassembly manipulation
*//***************************************************************************/
typedef struct t_FmPcdManipFragOrReasmParams {
bool frag; /**< TRUE if using the structure for fragmentation,
otherwise this structure is used for reassembly */
- uint8_t extBufPoolIndx; /**< Index of the buffer pool ID which was configured for port
- and can be used for manipulation;
- NOTE: This field is relevant only for CAPWAP fragmentation
- and reassembly */
+ uint8_t sgBpid; /**< Scatter/Gather buffer pool id;
+ Same LIODN number is used for these buffers as for
+ the received frames buffers, so buffers of this pool
+ need to be allocated in the same memory area as the
+ received buffers. If the received buffers arrive
+ from different sources, the Scatter/Gather BP id
+ should be mutual to all these sources. */
e_NetHeaderType hdr; /**< Header selection */
union {
-#ifdef FM_CAPWAP_SUPPORT
- t_CapwapFragmentationParams capwapFragParams; /**< Structure for CAPWAP fragmentation, relevant if frag = TRUE, hdr = HEADER_TYPE_CAPWAP */
- t_CapwapReassemblyParams capwapReasmParams; /**< Structure for CAPWAP reassembly, relevant if frag = FALSE, hdr = HEADER_TYPE_CAPWAP */
-#endif /* FM_CAPWAP_SUPPORT */
- };
+ t_CapwapFragmentationParams capwapFragParams; /**< Structure for CAPWAP fragmentation,
+ relevant if 'frag' = TRUE, 'hdr' = HEADER_TYPE_CAPWAP */
+ t_CapwapReassemblyParams capwapReasmParams; /**< Structure for CAPWAP reassembly,
+ relevant if 'frag' = FALSE, 'hdr' = HEADER_TYPE_CAPWAP */
+ } u;
} t_FmPcdManipFragOrReasmParams;
+#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
+
/**************************************************************************//**
- @Description structure for defining insert manipulation
+ @Description Parameters for defining header removal by header type
*//***************************************************************************/
-typedef struct t_FmPcdManipInsrtParams {
- e_FmPcdManipInsrtType type; /**< Type of insert manipulation */
+typedef struct t_FmPcdManipHdrRmvByHdrParams {
+ e_FmPcdManipHdrRmvByHdrType type; /**< Selection of header removal location */
union {
- t_FmPcdManipInsrtByTemplateParams insrtByTemplateParams;
- /**< parameters for insert manipulation, relevant if
- type = e_FM_PCD_MANIP_INSRT_TO_START_OF_FRAME_TEMPLATE */
- };
-} t_FmPcdManipInsrtParams;
+#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
+ struct {
+ bool include; /**< If FALSE, remove until the specified header (not including the header);
+ If TRUE, remove also the specified header. */
+ t_FmManipHdrInfo hdrInfo;
+ } fromStartByHdr; /**< Relevant when type = e_FM_PCD_MANIP_RMV_BY_HDR_FROM_START */
+#endif /* (DPAA_VERSION >= 11) || ... */
+#if (DPAA_VERSION >= 11)
+ t_FmManipHdrInfo hdrInfo; /**< Relevant when type = e_FM_PCD_MANIP_RMV_BY_HDR_FROM_START */
+#endif /* (DPAA_VERSION >= 11) */
+ e_FmPcdManipHdrRmvSpecificL2 specificL2; /**< Relevant when type = e_FM_PCD_MANIP_BY_HDR_SPECIFIC_L2;
+ Defines which L2 headers to remove. */
+ } u;
+} t_FmPcdManipHdrRmvByHdrParams;
+
+/**************************************************************************//**
+ @Description Parameters for configuring IP fragmentation manipulation
+
+ Restrictions:
+ - IP Fragmentation output fragments must not be forwarded to application directly.
+ - Maximum number of fragments per frame is 16.
+ - Fragmentation of IP fragments is not supported.
+ - IPv4 packets containing header Option fields are fragmented by copying all option
+ fields to each fragment, regardless of the copy bit value.
+ - Transmit confirmation is not supported.
+ - Fragmentation after SEC can't handle S/G frames.
+ - Fragmentation nodes must be set as the last PCD action (i.e. the
+ corresponding CC node key must have next engine set to e_FM_PCD_DONE).
+ - Only BMan buffers shall be used for frames to be fragmented.
+ - IPF does not support VSP. Therefore, on the same port where we have IPF
+ we cannot support VSP.
+ - NOTE: The following comment is relevant only for FMAN v3 devices: IPF
+ does not support VSP. Therefore, on the same port where we have IPF we
+ cannot support VSP.
+*//***************************************************************************/
+typedef struct t_FmPcdManipFragIpParams {
+ uint16_t sizeForFragmentation; /**< If length of the frame is greater than this value,
+ IP fragmentation will be executed.*/
+#if (DPAA_VERSION == 10)
+ uint8_t scratchBpid; /**< Absolute buffer pool id according to BM configuration.*/
+#endif /* (DPAA_VERSION == 10) */
+ bool sgBpidEn; /**< Enable a dedicated buffer pool id for the Scatter/Gather buffer allocation;
+ If disabled, the Scatter/Gather buffer will be allocated from the same pool as the
+ received frame's buffer. */
+ uint8_t sgBpid; /**< Scatter/Gather buffer pool id;
+ This parameters is relevant when 'sgBpidEn=TRUE';
+ Same LIODN number is used for these buffers as for the received frames buffers, so buffers
+ of this pool need to be allocated in the same memory area as the received buffers.
+ If the received buffers arrive from different sources, the Scatter/Gather BP id should be
+ mutual to all these sources. */
+ e_FmPcdManipDontFragAction dontFragAction; /**< Don't Fragment Action - If an IP packet is larger
+ than MTU and its DF bit is set, then this field will
+ determine the action to be taken.*/
+} t_FmPcdManipFragIpParams;
+
+/**************************************************************************//**
+ @Description Parameters for configuring IP reassembly manipulation.
+
+ This is a common structure for both IPv4 and IPv6 reassembly
+ manipulation. For reassembly of both IPv4 and IPv6, make sure to
+ set the 'hdr' field in t_FmPcdManipReassemParams to HEADER_TYPE_IPv6.
+
+ Restrictions:
+ - Application must define at least one scheme to catch the reassembled frames.
+ - Maximum number of fragments per frame is 16.
+ - Reassembly of IPv4 fragments containing Option fields is supported.
+
+*//***************************************************************************/
+typedef struct t_FmPcdManipReassemIpParams {
+ uint8_t relativeSchemeId[2]; /**< Partition relative scheme id:
+ relativeSchemeId[0] - Relative scheme ID for IPV4 Reassembly manipulation;
+ relativeSchemeId[1] - Relative scheme ID for IPV6 Reassembly manipulation;
+ NOTE: The following comment is relevant only for FMAN v2 devices:
+ Relative scheme ID for IPv4/IPv6 Reassembly manipulation must be smaller than
+ the user schemes id to ensure that the reassembly schemes will be first match;
+ Rest schemes, if defined, should have higher relative scheme ID. */
+#if (DPAA_VERSION >= 11)
+ uint32_t nonConsistentSpFqid; /**< In case that other fragments of the frame corresponds to different storage
+ profile than the opening fragment (Non-Consistent-SP state)
+ then one of two possible scenarios occurs:
+ if 'nonConsistentSpFqid != 0', the reassembled frame will be enqueued to
+ this fqid, otherwise a 'Non Consistent SP' bit will be set in the FD[status].*/
+#else
+ uint8_t sgBpid; /**< Buffer pool id for the S/G frame created by the reassembly process */
+#endif /* (DPAA_VERSION >= 11) */
+ uint8_t dataMemId; /**< Memory partition ID for the IPR's external tables structure */
+ uint16_t dataLiodnOffset; /**< LIODN offset for access the IPR's external tables structure. */
+ uint16_t minFragSize[2]; /**< Minimum fragment size:
+ minFragSize[0] - for ipv4, minFragSize[1] - for ipv6 */
+ e_FmPcdManipReassemWaysNumber numOfFramesPerHashEntry[2];
+ /**< Number of frames per hash entry needed for reassembly process:
+ numOfFramesPerHashEntry[0] - for ipv4 (max value is e_FM_PCD_MANIP_EIGHT_WAYS_HASH);
+ numOfFramesPerHashEntry[1] - for ipv6 (max value is e_FM_PCD_MANIP_SIX_WAYS_HASH). */
+ uint16_t maxNumFramesInProcess; /**< Number of frames which can be processed by Reassembly in the same time;
+ Must be power of 2;
+ In the case numOfFramesPerHashEntry == e_FM_PCD_MANIP_FOUR_WAYS_HASH,
+ maxNumFramesInProcess has to be in the range of 4 - 512;
+ In the case numOfFramesPerHashEntry == e_FM_PCD_MANIP_EIGHT_WAYS_HASH,
+ maxNumFramesInProcess has to be in the range of 8 - 2048. */
+ e_FmPcdManipReassemTimeOutMode timeOutMode; /**< Expiration delay initialized by Reassembly process */
+ uint32_t fqidForTimeOutFrames; /**< FQID in which time out frames will enqueue during Time Out Process;
+ Recommended value for this field is 0; in this way timed-out frames will be discarded */
+ uint32_t timeoutThresholdForReassmProcess;
+ /**< Represents the time interval in microseconds which defines
+ if opened frame (at least one fragment was processed but not all the fragments)is found as too old*/
+} t_FmPcdManipReassemIpParams;
+
+/**************************************************************************//**
+ @Description structure for defining IPSEC manipulation
+*//***************************************************************************/
+typedef struct t_FmPcdManipSpecialOffloadIPSecParams {
+ bool decryption; /**< TRUE if being used in decryption direction;
+ FALSE if being used in encryption direction. */
+ bool ecnCopy; /**< TRUE to copy the ECN bits from inner/outer to outer/inner
+ (direction depends on the 'decryption' field). */
+ bool dscpCopy; /**< TRUE to copy the DSCP bits from inner/outer to outer/inner
+ (direction depends on the 'decryption' field). */
+ bool variableIpHdrLen; /**< TRUE for supporting variable IP header length in decryption. */
+ bool variableIpVersion; /**< TRUE for supporting both IP version on the same SA in encryption */
+ uint8_t outerIPHdrLen; /**< if 'variableIpVersion == TRUE' then this field must be set to non-zero value;
+ It is specifies the length of the outer IP header that was configured in the
+ corresponding SA. */
+ uint16_t arwSize; /**< if <> '0' then will perform ARW check for this SA;
+ The value must be a multiplication of 16 */
+ uintptr_t arwAddr; /**< if arwSize <> '0' then this field must be set to non-zero value;
+ MUST be allocated from FMAN's MURAM that the post-sec op-port belongs to;
+ Must be 4B aligned. Required MURAM size is 'NEXT_POWER_OF_2(arwSize+32))/8+4' Bytes */
+} t_FmPcdManipSpecialOffloadIPSecParams;
+
+#if (DPAA_VERSION >= 11)
+/**************************************************************************//**
+ @Description Parameters for configuring CAPWAP fragmentation manipulation
+
+ Restrictions:
+ - Maximum number of fragments per frame is 16.
+ - Transmit confirmation is not supported.
+ - Fragmentation nodes must be set as the last PCD action (i.e. the
+ corresponding CC node key must have next engine set to e_FM_PCD_DONE).
+ - Only BMan buffers shall be used for frames to be fragmented.
+ - NOTE: The following comment is relevant only for FMAN v3 devices: IPF
+ does not support VSP. Therefore, on the same port where we have IPF we
+ cannot support VSP.
+*//***************************************************************************/
+typedef struct t_FmPcdManipFragCapwapParams {
+ uint16_t sizeForFragmentation; /**< If length of the frame is greater than this value,
+ CAPWAP fragmentation will be executed.*/
+ bool sgBpidEn; /**< Enable a dedicated buffer pool id for the Scatter/Gather buffer allocation;
+ If disabled, the Scatter/Gather buffer will be allocated from the same pool as the
+ received frame's buffer. */
+ uint8_t sgBpid; /**< Scatter/Gather buffer pool id;
+ This parameters is relevant when 'sgBpidEn=TRUE';
+ Same LIODN number is used for these buffers as for the received frames buffers, so buffers
+ of this pool need to be allocated in the same memory area as the received buffers.
+ If the received buffers arrive from different sources, the Scatter/Gather BP id should be
+ mutual to all these sources. */
+ bool compressModeEn; /**< CAPWAP Header Options Compress Enable mode;
+ When this mode is enabled then only the first fragment include the CAPWAP header options
+ field (if user provides it in the input frame) and all other fragments exclude the CAPWAP
+ options field (CAPWAP header is updated accordingly).*/
+} t_FmPcdManipFragCapwapParams;
+
+/**************************************************************************//**
+ @Description Parameters for configuring CAPWAP reassembly manipulation.
+
+ Restrictions:
+ - Application must define one scheme to catch the reassembled frames.
+ - Maximum number of fragments per frame is 16.
+
+*//***************************************************************************/
+typedef struct t_FmPcdManipReassemCapwapParams {
+ uint8_t relativeSchemeId; /**< Partition relative scheme id;
+ NOTE: this id must be smaller than the user schemes id to ensure that the reassembly scheme will be first match;
+ Rest schemes, if defined, should have higher relative scheme ID. */
+ uint8_t dataMemId; /**< Memory partition ID for the IPR's external tables structure */
+ uint16_t dataLiodnOffset; /**< LIODN offset for access the IPR's external tables structure. */
+ uint16_t maxReassembledFrameLength;/**< The maximum CAPWAP reassembled frame length in bytes;
+ If maxReassembledFrameLength == 0, any successful reassembled frame length is
+ considered as a valid length;
+ if maxReassembledFrameLength > 0, a successful reassembled frame which its length
+ exceeds this value is considered as an error frame (FD status[CRE] bit is set). */
+ e_FmPcdManipReassemWaysNumber numOfFramesPerHashEntry;
+ /**< Number of frames per hash entry needed for reassembly process */
+ uint16_t maxNumFramesInProcess; /**< Number of frames which can be processed by reassembly in the same time;
+ Must be power of 2;
+ In the case numOfFramesPerHashEntry == e_FM_PCD_MANIP_FOUR_WAYS_HASH,
+ maxNumFramesInProcess has to be in the range of 4 - 512;
+ In the case numOfFramesPerHashEntry == e_FM_PCD_MANIP_EIGHT_WAYS_HASH,
+ maxNumFramesInProcess has to be in the range of 8 - 2048. */
+ e_FmPcdManipReassemTimeOutMode timeOutMode; /**< Expiration delay initialized by Reassembly process */
+ uint32_t fqidForTimeOutFrames; /**< FQID in which time out frames will enqueue during Time Out Process;
+ Recommended value for this field is 0; in this way timed-out frames will be discarded */
+ uint32_t timeoutThresholdForReassmProcess;
+ /**< Represents the time interval in microseconds which defines
+ if opened frame (at least one fragment was processed but not all the fragments)is found as too old*/
+} t_FmPcdManipReassemCapwapParams;
/**************************************************************************//**
- @Description structure for defining remove manipulation
+ @Description structure for defining CAPWAP manipulation
*//***************************************************************************/
-typedef struct t_FmPcdManipRmvParams {
- e_FmPcdManipRmvParamsType type; /**< Type of remove manipulation */
- t_FmPcdManipLocationParams rmvSpecificLocationParams;
- /**< Specified location of remove manipulation;
- This params should be initialized in cases:
- - e_FM_PCD_MANIP_RMV_FROM_START_OF_FRAME_TILL_SPECIFIC_LOCATION
- - e_FM_PCD_MANIP_RMV_FROM_START_OF_FRAME_INCLUDE_SPECIFIC_LOCATION */
-} t_FmPcdManipRmvParams;
+typedef struct t_FmPcdManipSpecialOffloadCapwapParams {
+ bool dtls; /**< TRUE if continue to SEC DTLS encryption */
+ e_FmPcdManipHdrQosSrc qosSrc; /**< TODO */
+} t_FmPcdManipSpecialOffloadCapwapParams;
+
+#endif /* (DPAA_VERSION >= 11) */
+
/**************************************************************************//**
- @Description structure for defining manipulation
+ @Description Parameters for defining special offload manipulation
*//***************************************************************************/
-typedef struct t_FmPcdManipParams {
- bool rmv; /**< TRUE, if defined remove manipulation */
- t_FmPcdManipRmvParams rmvParams; /**< Parameters for remove manipulation, relevant if rmv = TRUE */
+typedef struct t_FmPcdManipSpecialOffloadParams {
+ e_FmPcdManipSpecialOffloadType type; /**< Type of special offload manipulation */
+ union
+ {
+ t_FmPcdManipSpecialOffloadIPSecParams ipsec; /**< Parameters for IPSec; Relevant when
+ type = e_FM_PCD_MANIP_SPECIAL_OFFLOAD_IPSEC */
+#if (DPAA_VERSION >= 11)
+ t_FmPcdManipSpecialOffloadCapwapParams capwap; /**< Parameters for CAPWAP; Relevant when
+ type = e_FM_PCD_MANIP_SPECIAL_OFFLOAD_CAPWAP */
+#endif /* (DPAA_VERSION >= 11) */
+ } u;
+} t_FmPcdManipSpecialOffloadParams;
- bool insrt; /**< TRUE, if defined insert manipulation */
- t_FmPcdManipInsrtParams insrtParams; /**< Parameters for insert manipulation, relevant if insrt = TRUE */
+/**************************************************************************//**
+ @Description Parameters for defining insertion manipulation
+*//***************************************************************************/
+typedef struct t_FmPcdManipHdrInsrt {
+ uint8_t size; /**< size of inserted section */
+ uint8_t *p_Data; /**< data to be inserted */
+} t_FmPcdManipHdrInsrt;
- bool fragOrReasm; /**< TRUE, if defined fragmentation/reassembly manipulation */
- t_FmPcdManipFragOrReasmParams fragOrReasmParams; /**< Parameters for fragmentation/reassembly manipulation, relevant if fragOrReasm = TRUE */
- /**< General parameters */
- bool treatFdStatusFieldsAsErrors;
- /**< Set to TRUE when the port that is using this manip is chained
- to SEC (i.e. the traffic was forwarded from SEC) */
+/**************************************************************************//**
+ @Description Parameters for defining generic removal manipulation
+*//***************************************************************************/
+typedef struct t_FmPcdManipHdrRmvGenericParams {
+ uint8_t offset; /**< Offset from beginning of header to the start
+ location of the removal */
+ uint8_t size; /**< Size of removed section */
+} t_FmPcdManipHdrRmvGenericParams;
+
+/**************************************************************************//**
+ @Description Parameters for defining generic insertion manipulation
+*//***************************************************************************/
+typedef struct t_FmPcdManipHdrInsrtGenericParams {
+ uint8_t offset; /**< Offset from beginning of header to the start
+ location of the insertion */
+ uint8_t size; /**< Size of inserted section */
+ bool replace; /**< TRUE to override (replace) existing data at
+ 'offset', FALSE to insert */
+ uint8_t *p_Data; /**< Pointer to data to be inserted */
+} t_FmPcdManipHdrInsrtGenericParams;
+
+/**************************************************************************//**
+ @Description Parameters for defining header manipulation VLAN DSCP To Vpri translation
+*//***************************************************************************/
+typedef struct t_FmPcdManipHdrFieldUpdateVlanDscpToVpri {
+ uint8_t dscpToVpriTable[FM_PCD_MANIP_DSCP_TO_VLAN_TRANS];
+ /**< A table of VPri values for each DSCP value;
+ The index is the DSCP value (0-0x3F) and the
+ value is the corresponding VPRI (0-15). */
+ uint8_t vpriDefVal; /**< 0-7, Relevant only if if updateType =
+ e_FM_PCD_MANIP_HDR_FIELD_UPDATE_DSCP_TO_VLAN,
+ this field is the Q Tag default value if the
+ IP header is not found. */
+} t_FmPcdManipHdrFieldUpdateVlanDscpToVpri;
+
+/**************************************************************************//**
+ @Description Parameters for defining header manipulation VLAN fields updates
+*//***************************************************************************/
+typedef struct t_FmPcdManipHdrFieldUpdateVlan {
+ e_FmPcdManipHdrFieldUpdateVlan updateType; /**< Selects VLAN update type */
+ union {
+ uint8_t vpri; /**< 0-7, Relevant only if If updateType =
+ e_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN_PRI, this
+ is the new VLAN pri. */
+ t_FmPcdManipHdrFieldUpdateVlanDscpToVpri dscpToVpri; /**< Parameters structure, Relevant only if updateType
+ = e_FM_PCD_MANIP_HDR_FIELD_UPDATE_DSCP_TO_VLAN. */
+ } u;
+} t_FmPcdManipHdrFieldUpdateVlan;
+
+/**************************************************************************//**
+ @Description Parameters for defining header manipulation IPV4 fields updates
+*//***************************************************************************/
+typedef struct t_FmPcdManipHdrFieldUpdateIpv4 {
+ ipv4HdrManipUpdateFlags_t validUpdates; /**< ORed flag, selecting the required updates */
+ uint8_t tos; /**< 8 bit New TOS; Relevant if validUpdates contains
+ HDR_MANIP_IPV4_TOS */
+ uint16_t id; /**< 16 bit New IP ID; Relevant only if validUpdates
+ contains HDR_MANIP_IPV4_ID */
+ uint32_t src; /**< 32 bit New IP SRC; Relevant only if validUpdates
+ contains HDR_MANIP_IPV4_SRC */
+ uint32_t dst; /**< 32 bit New IP DST; Relevant only if validUpdates
+ contains HDR_MANIP_IPV4_DST */
+} t_FmPcdManipHdrFieldUpdateIpv4;
+
+/**************************************************************************//**
+ @Description Parameters for defining header manipulation IPV6 fields updates
+*//***************************************************************************/
+typedef struct t_FmPcdManipHdrFieldUpdateIpv6 {
+ ipv6HdrManipUpdateFlags_t validUpdates; /**< ORed flag, selecting the required updates */
+ uint8_t trafficClass; /**< 8 bit New Traffic Class; Relevant if validUpdates contains
+ HDR_MANIP_IPV6_TC */
+ uint8_t src[NET_HEADER_FIELD_IPv6_ADDR_SIZE];
+ /**< 16 byte new IP SRC; Relevant only if validUpdates
+ contains HDR_MANIP_IPV6_SRC */
+ uint8_t dst[NET_HEADER_FIELD_IPv6_ADDR_SIZE];
+ /**< 16 byte new IP DST; Relevant only if validUpdates
+ contains HDR_MANIP_IPV6_DST */
+} t_FmPcdManipHdrFieldUpdateIpv6;
+
+/**************************************************************************//**
+ @Description Parameters for defining header manipulation TCP/UDP fields updates
+*//***************************************************************************/
+typedef struct t_FmPcdManipHdrFieldUpdateTcpUdp {
+ tcpUdpHdrManipUpdateFlags_t validUpdates; /**< ORed flag, selecting the required updates */
+ uint16_t src; /**< 16 bit New TCP/UDP SRC; Relevant only if validUpdates
+ contains HDR_MANIP_TCP_UDP_SRC */
+ uint16_t dst; /**< 16 bit New TCP/UDP DST; Relevant only if validUpdates
+ contains HDR_MANIP_TCP_UDP_DST */
+} t_FmPcdManipHdrFieldUpdateTcpUdp;
+
+/**************************************************************************//**
+ @Description Parameters for defining header manipulation fields updates
+*//***************************************************************************/
+typedef struct t_FmPcdManipHdrFieldUpdateParams {
+ e_FmPcdManipHdrFieldUpdateType type; /**< Type of header field update manipulation */
+ union {
+ t_FmPcdManipHdrFieldUpdateVlan vlan; /**< Parameters for VLAN update. Relevant when
+ type = e_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN */
+ t_FmPcdManipHdrFieldUpdateIpv4 ipv4; /**< Parameters for IPv4 update. Relevant when
+ type = e_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV4 */
+ t_FmPcdManipHdrFieldUpdateIpv6 ipv6; /**< Parameters for IPv6 update. Relevant when
+ type = e_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV6 */
+ t_FmPcdManipHdrFieldUpdateTcpUdp tcpUdp; /**< Parameters for TCP/UDP update. Relevant when
+ type = e_FM_PCD_MANIP_HDR_FIELD_UPDATE_TCP_UDP */
+ } u;
+} t_FmPcdManipHdrFieldUpdateParams;
+
+
+
+/**************************************************************************//**
+ @Description Parameters for defining custom header manipulation for generic field replacement
+*//***************************************************************************/
+typedef struct t_FmPcdManipHdrCustomGenFieldReplace {
+ uint8_t srcOffset; /**< Location of new data - Offset from
+ Parse Result (>= 16, srcOffset+size <= 32, ) */
+ uint8_t dstOffset; /**< Location of data to be overwritten - Offset from
+ start of frame (dstOffset + size <= 256). */
+ uint8_t size; /**< The number of bytes (<=16) to be replaced */
+ uint8_t mask; /**< Optional 1 byte mask. Set to select bits for
+ replacement (1 - bit will be replaced);
+ Clear to use field as is. */
+ uint8_t maskOffset; /**< Relevant if mask != 0;
+ Mask offset within the replaces "size" */
+} t_FmPcdManipHdrCustomGenFieldReplace;
+
+/**************************************************************************//**
+ @Description Parameters for defining custom header manipulation for IP replacement
+*//***************************************************************************/
+typedef struct t_FmPcdManipHdrCustomIpHdrReplace {
+ e_FmPcdManipHdrCustomIpReplace replaceType; /**< Selects replace update type */
+ bool decTtlHl; /**< Decrement TTL (IPV4) or Hop limit (IPV6) by 1 */
+ bool updateIpv4Id; /**< Relevant when replaceType =
+ e_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV6_BY_IPV4 */
+ uint16_t id; /**< 16 bit New IP ID; Relevant only if
+ updateIpv4Id = TRUE */
+ uint8_t hdrSize; /**< The size of the new IP header */
+ uint8_t hdr[FM_PCD_MANIP_MAX_HDR_SIZE];
+ /**< The new IP header */
+} t_FmPcdManipHdrCustomIpHdrReplace;
+
+/**************************************************************************//**
+ @Description Parameters for defining custom header manipulation
+*//***************************************************************************/
+typedef struct t_FmPcdManipHdrCustomParams {
+ e_FmPcdManipHdrCustomType type; /**< Type of header field update manipulation */
+ union {
+ t_FmPcdManipHdrCustomIpHdrReplace ipHdrReplace; /**< Parameters IP header replacement */
+ t_FmPcdManipHdrCustomGenFieldReplace genFieldReplace; /**< Parameters IP header replacement */
+ } u;
+} t_FmPcdManipHdrCustomParams;
+
+/**************************************************************************//**
+ @Description Parameters for defining specific L2 insertion manipulation
+*//***************************************************************************/
+typedef struct t_FmPcdManipHdrInsrtSpecificL2Params {
+ e_FmPcdManipHdrInsrtSpecificL2 specificL2; /**< Selects which L2 headers to insert */
+ bool update; /**< TRUE to update MPLS header */
+ uint8_t size; /**< size of inserted section */
+ uint8_t *p_Data; /**< data to be inserted */
+} t_FmPcdManipHdrInsrtSpecificL2Params;
+
+#if (DPAA_VERSION >= 11)
+/**************************************************************************//**
+ @Description Parameters for defining IP insertion manipulation
+*//***************************************************************************/
+typedef struct t_FmPcdManipHdrInsrtIpParams {
+ bool calcL4Checksum; /**< Calculate L4 checksum. */
+ e_FmPcdManipHdrQosMappingMode mappingMode; /**< TODO */
+ uint8_t lastPidOffset; /**< the offset of the last Protocol within
+ the inserted header */
+ uint16_t id; /**< 16 bit New IP ID */
+ bool dontFragOverwrite;
+ /**< IPv4 only. DF is overwritten with the hash-result next-to-last byte.
+ * This byte is configured to be overwritten when RPD is set. */
+ uint8_t lastDstOffset;
+ /**< IPv6 only. if routing extension exist, user should set the offset of the destination address
+ * in order to calculate UDP checksum pseudo header;
+ * Otherwise set it to '0'. */
+ t_FmPcdManipHdrInsrt insrt; /**< size and data to be inserted. */
+} t_FmPcdManipHdrInsrtIpParams;
+#endif /* (DPAA_VERSION >= 11) */
+
+/**************************************************************************//**
+ @Description Parameters for defining header insertion manipulation by header type
+*//***************************************************************************/
+typedef struct t_FmPcdManipHdrInsrtByHdrParams {
+ e_FmPcdManipHdrInsrtByHdrType type; /**< Selects manipulation type */
+ union {
+
+ t_FmPcdManipHdrInsrtSpecificL2Params specificL2Params;
+ /**< Used when type = e_FM_PCD_MANIP_INSRT_BY_HDR_SPECIFIC_L2:
+ Selects which L2 headers to insert */
+#if (DPAA_VERSION >= 11)
+ t_FmPcdManipHdrInsrtIpParams ipParams; /**< Used when type = e_FM_PCD_MANIP_INSRT_BY_HDR_IP */
+ t_FmPcdManipHdrInsrt insrt; /**< Used when type is one of e_FM_PCD_MANIP_INSRT_BY_HDR_UDP,
+ e_FM_PCD_MANIP_INSRT_BY_HDR_UDP_LITE, or
+ e_FM_PCD_MANIP_INSRT_BY_HDR_CAPWAP */
+#endif /* (DPAA_VERSION >= 11) */
+ } u;
+} t_FmPcdManipHdrInsrtByHdrParams;
+
+/**************************************************************************//**
+ @Description Parameters for defining header insertion manipulation
+*//***************************************************************************/
+typedef struct t_FmPcdManipHdrInsrtParams {
+ e_FmPcdManipHdrInsrtType type; /**< Type of insertion manipulation */
+ union {
+ t_FmPcdManipHdrInsrtByHdrParams byHdr; /**< Parameters for defining header insertion manipulation by header type,
+ relevant if 'type' = e_FM_PCD_MANIP_INSRT_BY_HDR */
+ t_FmPcdManipHdrInsrtGenericParams generic; /**< Parameters for defining generic header insertion manipulation,
+ relevant if 'type' = e_FM_PCD_MANIP_INSRT_GENERIC */
+#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
+ t_FmPcdManipHdrInsrtByTemplateParams byTemplate; /**< Parameters for defining header insertion manipulation by template,
+ relevant if 'type' = e_FM_PCD_MANIP_INSRT_BY_TEMPLATE */
+#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
+ } u;
+} t_FmPcdManipHdrInsrtParams;
+
+/**************************************************************************//**
+ @Description Parameters for defining header removal manipulation
+*//***************************************************************************/
+typedef struct t_FmPcdManipHdrRmvParams {
+ e_FmPcdManipHdrRmvType type; /**< Type of header removal manipulation */
+ union {
+ t_FmPcdManipHdrRmvByHdrParams byHdr; /**< Parameters for defining header removal manipulation by header type,
+ relevant if type = e_FM_PCD_MANIP_RMV_BY_HDR */
+ t_FmPcdManipHdrRmvGenericParams generic; /**< Parameters for defining generic header removal manipulation,
+ relevant if type = e_FM_PCD_MANIP_RMV_GENERIC */
+ } u;
+} t_FmPcdManipHdrRmvParams;
+
+/**************************************************************************//**
+ @Description Parameters for defining header manipulation node
+*//***************************************************************************/
+typedef struct t_FmPcdManipHdrParams {
+ bool rmv; /**< TRUE, to define removal manipulation */
+ t_FmPcdManipHdrRmvParams rmvParams; /**< Parameters for removal manipulation, relevant if 'rmv' = TRUE */
+
+ bool insrt; /**< TRUE, to define insertion manipulation */
+ t_FmPcdManipHdrInsrtParams insrtParams; /**< Parameters for insertion manipulation, relevant if 'insrt' = TRUE */
+
+ bool fieldUpdate; /**< TRUE, to define field update manipulation */
+ t_FmPcdManipHdrFieldUpdateParams fieldUpdateParams; /**< Parameters for field update manipulation, relevant if 'fieldUpdate' = TRUE */
+
+ bool custom; /**< TRUE, to define custom manipulation */
+ t_FmPcdManipHdrCustomParams customParams; /**< Parameters for custom manipulation, relevant if 'custom' = TRUE */
+
+ bool dontParseAfterManip;/**< TRUE to de-activate the parser after the manipulation defined in this node.
+ Restrictions:
+ 1. MUST be set if the next engine after the CC is not another CC node
+ (but rather Policer or Keygen), and this is the last (no h_NextManip) in a chain
+ of manipulation nodes. This includes single nodes (i.e. no h_NextManip and
+ also never pointed as h_NextManip of other manipulation nodes)
+ 2. MUST be set if the next engine after the CC is another CC node, and
+ this is NOT the last manipulation node (i.e. it has h_NextManip).*/
+} t_FmPcdManipHdrParams;
+
+/**************************************************************************//**
+ @Description Parameters for defining fragmentation manipulation
+*//***************************************************************************/
+typedef struct t_FmPcdManipFragParams {
+ e_NetHeaderType hdr; /**< Header selection */
+ union {
+#if (DPAA_VERSION >= 11)
+ t_FmPcdManipFragCapwapParams capwapFrag; /**< Parameters for defining CAPWAP fragmentation,
+ relevant if 'hdr' = HEADER_TYPE_CAPWAP */
+#endif /* (DPAA_VERSION >= 11) */
+ t_FmPcdManipFragIpParams ipFrag; /**< Parameters for defining IP fragmentation,
+ relevant if 'hdr' = HEADER_TYPE_Ipv4 or HEADER_TYPE_Ipv6 */
+ } u;
+} t_FmPcdManipFragParams;
+
+/**************************************************************************//**
+ @Description Parameters for defining reassembly manipulation
+*//***************************************************************************/
+typedef struct t_FmPcdManipReassemParams {
+ e_NetHeaderType hdr; /**< Header selection */
+ union {
+#if (DPAA_VERSION >= 11)
+ t_FmPcdManipReassemCapwapParams capwapReassem; /**< Parameters for defining CAPWAP reassembly,
+ relevant if 'hdr' = HEADER_TYPE_CAPWAP */
+#endif /* (DPAA_VERSION >= 11) */
+
+ t_FmPcdManipReassemIpParams ipReassem; /**< Parameters for defining IP reassembly,
+ relevant if 'hdr' = HEADER_TYPE_Ipv4 or HEADER_TYPE_Ipv6 */
+ } u;
+} t_FmPcdManipReassemParams;
+
+/**************************************************************************//**
+ @Description Parameters for defining a manipulation node
+*//***************************************************************************/
+typedef struct t_FmPcdManipParams {
+ e_FmPcdManipType type; /**< Selects type of manipulation node */
+ union{
+ t_FmPcdManipHdrParams hdr; /**< Parameters for defining header manipulation node */
+ t_FmPcdManipReassemParams reassem; /**< Parameters for defining reassembly manipulation node */
+ t_FmPcdManipFragParams frag; /**< Parameters for defining fragmentation manipulation node */
+ t_FmPcdManipSpecialOffloadParams specialOffload; /**< Parameters for defining special offload manipulation node */
+ } u;
+
+ t_Handle h_NextManip; /**< Supported for Header Manipulation only;
+ Handle to another (previously defined) manipulation node;
+ Allows concatenation of manipulation actions;
+ This parameter is optional and may be NULL. */
+#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
+ bool fragOrReasm; /**< TRUE, if defined fragmentation/reassembly manipulation */
+ t_FmPcdManipFragOrReasmParams fragOrReasmParams; /**< Parameters for fragmentation/reassembly manipulation,
+ relevant if fragOrReasm = TRUE */
+#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
} t_FmPcdManipParams;
/**************************************************************************//**
+ @Description Structure for retrieving IP reassembly statistics
+*//***************************************************************************/
+typedef struct t_FmPcdManipReassemIpStats {
+ /* common counters for both IPv4 and IPv6 */
+ uint32_t timeout; /**< Counts the number of timeout occurrences */
+ uint32_t rfdPoolBusy; /**< Counts the number of failed attempts to allocate
+ a Reassembly Frame Descriptor */
+ uint32_t internalBufferBusy; /**< Counts the number of times an internal buffer busy occurred */
+ uint32_t externalBufferBusy; /**< Counts the number of times external buffer busy occurred */
+ uint32_t sgFragments; /**< Counts the number of Scatter/Gather fragments */
+ uint32_t dmaSemaphoreDepletion; /**< Counts the number of failed attempts to allocate a DMA semaphore */
+#if (DPAA_VERSION >= 11)
+ uint32_t nonConsistentSp; /**< Counts the number of Non Consistent Storage Profile events for
+ successfully reassembled frames */
+#endif /* (DPAA_VERSION >= 11) */
+ struct {
+ uint32_t successfullyReassembled; /**< Counts the number of successfully reassembled frames */
+ uint32_t validFragments; /**< Counts the total number of valid fragments that
+ have been processed for all frames */
+ uint32_t processedFragments; /**< Counts the number of processed fragments
+ (valid and error fragments) for all frames */
+ uint32_t malformedFragments; /**< Counts the number of malformed fragments processed for all frames */
+ uint32_t discardedFragments; /**< Counts the number of fragments discarded by the reassembly process */
+ uint32_t autoLearnBusy; /**< Counts the number of times a busy condition occurs when attempting
+ to access an IP-Reassembly Automatic Learning Hash set */
+ uint32_t moreThan16Fragments; /**< Counts the fragment occurrences in which the number of fragments-per-frame
+ exceeds 16 */
+ } specificHdrStatistics[2]; /**< slot '0' is for IPv4, slot '1' is for IPv6 */
+} t_FmPcdManipReassemIpStats;
+
+/**************************************************************************//**
+ @Description Structure for retrieving IP fragmentation statistics
+*//***************************************************************************/
+typedef struct t_FmPcdManipFragIpStats {
+ uint32_t totalFrames; /**< Number of frames that passed through the manipulation node */
+ uint32_t fragmentedFrames; /**< Number of frames that were fragmented */
+ uint32_t generatedFragments; /**< Number of fragments that were generated */
+} t_FmPcdManipFragIpStats;
+
+#if (DPAA_VERSION >= 11)
+/**************************************************************************//**
+ @Description Structure for retrieving CAPWAP reassembly statistics
+*//***************************************************************************/
+typedef struct t_FmPcdManipReassemCapwapStats {
+ uint32_t timeout; /**< Counts the number of timeout occurrences */
+ uint32_t rfdPoolBusy; /**< Counts the number of failed attempts to allocate
+ a Reassembly Frame Descriptor */
+ uint32_t internalBufferBusy; /**< Counts the number of times an internal buffer busy occurred */
+ uint32_t externalBufferBusy; /**< Counts the number of times external buffer busy occurred */
+ uint32_t sgFragments; /**< Counts the number of Scatter/Gather fragments */
+ uint32_t dmaSemaphoreDepletion; /**< Counts the number of failed attempts to allocate a DMA semaphore */
+ uint32_t successfullyReassembled; /**< Counts the number of successfully reassembled frames */
+ uint32_t validFragments; /**< Counts the total number of valid fragments that
+ have been processed for all frames */
+ uint32_t processedFragments; /**< Counts the number of processed fragments
+ (valid and error fragments) for all frames */
+ uint32_t malformedFragments; /**< Counts the number of malformed fragments processed for all frames */
+ uint32_t autoLearnBusy; /**< Counts the number of times a busy condition occurs when attempting
+ to access an Reassembly Automatic Learning Hash set */
+ uint32_t discardedFragments; /**< Counts the number of fragments discarded by the reassembly process */
+ uint32_t moreThan16Fragments; /**< Counts the fragment occurrences in which the number of fragments-per-frame
+ exceeds 16 */
+ uint32_t exceedMaxReassemblyFrameLen;/**< ounts the number of times that a successful reassembled frame
+ length exceeds MaxReassembledFrameLength value */
+} t_FmPcdManipReassemCapwapStats;
+
+/**************************************************************************//**
+ @Description Structure for retrieving CAPWAP fragmentation statistics
+*//***************************************************************************/
+typedef struct t_FmPcdManipFragCapwapStats {
+ uint32_t totalFrames; /**< Number of frames that passed through the manipulation node */
+ uint32_t fragmentedFrames; /**< Number of frames that were fragmented */
+ uint32_t generatedFragments; /**< Number of fragments that were generated */
+#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
+ uint8_t sgAllocationFailure; /**< Number of allocation failure of s/g buffers */
+#endif /* (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0)) */
+} t_FmPcdManipFragCapwapStats;
+#endif /* (DPAA_VERSION >= 11) */
+
+/**************************************************************************//**
+ @Description Structure for retrieving reassembly statistics
+*//***************************************************************************/
+typedef struct t_FmPcdManipReassemStats {
+ union {
+ t_FmPcdManipReassemIpStats ipReassem; /**< Structure for IP reassembly statistics */
+#if (DPAA_VERSION >= 11)
+ t_FmPcdManipReassemCapwapStats capwapReassem; /**< Structure for CAPWAP reassembly statistics */
+#endif /* (DPAA_VERSION >= 11) */
+ } u;
+} t_FmPcdManipReassemStats;
+
+/**************************************************************************//**
+ @Description Structure for retrieving fragmentation statistics
+*//***************************************************************************/
+typedef struct t_FmPcdManipFragStats {
+ union {
+ t_FmPcdManipFragIpStats ipFrag; /**< Structure for IP fragmentation statistics */
+#if (DPAA_VERSION >= 11)
+ t_FmPcdManipFragCapwapStats capwapFrag; /**< Structure for CAPWAP fragmentation statistics */
+#endif /* (DPAA_VERSION >= 11) */
+ } u;
+} t_FmPcdManipFragStats;
+
+/**************************************************************************//**
+ @Description Structure for selecting manipulation statistics
+*//***************************************************************************/
+typedef struct t_FmPcdManipStats {
+ union {
+ t_FmPcdManipReassemStats reassem; /**< Structure for reassembly statistics */
+ t_FmPcdManipFragStats frag; /**< Structure for fragmentation statistics */
+ } u;
+} t_FmPcdManipStats;
+
+#if (DPAA_VERSION >= 11)
+/**************************************************************************//**
+ @Description Parameters for defining frame replicator group and its members
+*//***************************************************************************/
+typedef struct t_FmPcdFrmReplicGroupParams {
+ uint8_t maxNumOfEntries; /**< Maximal number of members in the group;
+ Must be at least 2. */
+ uint8_t numOfEntries; /**< Number of members in the group;
+ Must be at least 1. */
+ t_FmPcdCcNextEngineParams nextEngineParams[FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES];
+ /**< Array of members' parameters */
+} t_FmPcdFrmReplicGroupParams;
+#endif /* (DPAA_VERSION >= 11) */
+
+#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
+/**************************************************************************//**
@Description structure for defining statistics node
*//***************************************************************************/
typedef struct t_FmPcdStatsParams {
- e_FmPcdStatsType type; /**< type of statistics node */
+ e_FmPcdStatsType type; /**< type of statistics node */
} t_FmPcdStatsParams;
-#endif /* defined(FM_CAPWAP_SUPPORT) || ... */
-
+#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
/**************************************************************************//**
- @Function FM_PCD_SetNetEnvCharacteristics
+ @Function FM_PCD_NetEnvCharacteristicsSet
@Description Define a set of Network Environment Characteristics.
+
When setting an environment it is important to understand its
application. It is not meant to describe the flows that will run
on the ports using this environment, but what the user means TO DO
with the PCD mechanisms in order to parse-classify-distribute those
frames.
By specifying a distinction unit, the user means it would use that option
- for distinction between frames at either a keygen scheme keygen or a coarse
+ for distinction between frames at either a KeyGen scheme or a coarse
classification action descriptor. Using interchangeable headers to define a
unit means that the user is indifferent to which of the interchangeable
- headers is present in the frame, and they want the distinction to be based
+ headers is present in the frame, and wants the distinction to be based
on the presence of either one of them.
+
Depending on context, there are limitations to the use of environments. A
port using the PCD functionality is bound to an environment. Some or even
all ports may share an environment but also an environment per port is
@@ -1746,6 +2938,7 @@ typedef struct t_FmPcdStatsParams {
stated and related to. When a port is bound to a scheme, a classification
plan group, or a coarse classification tree, it MUST be bound to the same
environment.
+
The different PCD modules, may relate (for flows definition) ONLY on
distinction units as defined by their environment. When initializing a
scheme for example, it may not choose to select IPV4 as a match for
@@ -1753,6 +2946,7 @@ typedef struct t_FmPcdStatsParams {
fact, to guide the user through the configuration of the PCD, each module's
characterization in terms of flows is not done using protocol names, but using
environment indexes.
+
In terms of HW implementation, the list of distinction units sets the LCV vectors
and later used for match vector, classification plan vectors and coarse classification
indexing.
@@ -1765,346 +2959,813 @@ typedef struct t_FmPcdStatsParams {
@Cautions Allowed only following FM_PCD_Init().
*//***************************************************************************/
-t_Handle FM_PCD_SetNetEnvCharacteristics(t_Handle h_FmPcd, t_FmPcdNetEnvParams *p_NetEnvParams);
+t_Handle FM_PCD_NetEnvCharacteristicsSet(t_Handle h_FmPcd, t_FmPcdNetEnvParams *p_NetEnvParams);
/**************************************************************************//**
- @Function FM_PCD_DeleteNetEnvCharacteristics
+ @Function FM_PCD_NetEnvCharacteristicsDelete
@Description Deletes a set of Network Environment Characteristics.
- @Param[in] h_FmPcd FM PCD module descriptor.
@Param[in] h_NetEnv A handle to the Network environment.
@Return E_OK on success; Error code otherwise.
*//***************************************************************************/
-t_Error FM_PCD_DeleteNetEnvCharacteristics(t_Handle h_FmPcd, t_Handle h_NetEnv);
+t_Error FM_PCD_NetEnvCharacteristicsDelete(t_Handle h_NetEnv);
/**************************************************************************//**
- @Function FM_PCD_KgSetScheme
+ @Function FM_PCD_KgSchemeSet
- @Description Initializing or modifying and enabling a scheme for the keygen.
+ @Description Initializing or modifying and enabling a scheme for the KeyGen.
This routine should be called for adding or modifying a scheme.
When a scheme needs modifying, the API requires that it will be
rewritten. In such a case 'modify' should be TRUE. If the
routine is called for a valid scheme and 'modify' is FALSE,
it will return error.
- @Param[in] h_FmPcd A handle to an FM PCD Module.
- @Param[in,out] p_Scheme A structure of parameters for defining the scheme
+ @Param[in] h_FmPcd If this is a new scheme - A handle to an FM PCD Module.
+ Otherwise NULL (ignored by driver).
+ @Param[in,out] p_SchemeParams A structure of parameters for defining the scheme
@Return A handle to the initialized scheme on success; NULL code otherwise.
+ When used as "modify" (rather than for setting a new scheme),
+ p_SchemeParams->id.h_Scheme will return NULL if action fails due to scheme
+ BUSY state.
@Cautions Allowed only following FM_PCD_Init().
*//***************************************************************************/
-t_Handle FM_PCD_KgSetScheme (t_Handle h_FmPcd,
- t_FmPcdKgSchemeParams *p_Scheme);
+t_Handle FM_PCD_KgSchemeSet(t_Handle h_FmPcd,
+ t_FmPcdKgSchemeParams *p_SchemeParams);
/**************************************************************************//**
- @Function FM_PCD_KgDeleteScheme
+ @Function FM_PCD_KgSchemeDelete
@Description Deleting an initialized scheme.
- @Param[in] h_FmPcd A handle to an FM PCD Module.
- @Param[in] h_Scheme scheme handle as returned by FM_PCD_KgSetScheme
+ @Param[in] h_Scheme scheme handle as returned by FM_PCD_KgSchemeSet()
@Return E_OK on success; Error code otherwise.
- @Cautions Allowed only following FM_PCD_Init().
+
+ @Cautions Allowed only following FM_PCD_Init() & FM_PCD_KgSchemeSet().
*//***************************************************************************/
-t_Error FM_PCD_KgDeleteScheme(t_Handle h_FmPcd, t_Handle h_Scheme);
+t_Error FM_PCD_KgSchemeDelete(t_Handle h_Scheme);
/**************************************************************************//**
- @Function FM_PCD_KgGetSchemeCounter
+ @Function FM_PCD_KgSchemeGetCounter
@Description Reads scheme packet counter.
- @Param[in] h_FmPcd FM PCD module descriptor.
- @Param[in] h_Scheme scheme handle as returned by FM_PCD_KgSetScheme.
+ @Param[in] h_Scheme scheme handle as returned by FM_PCD_KgSchemeSet().
@Return Counter's current value.
- @Cautions Allowed only following FM_PCD_Init().
+ @Cautions Allowed only following FM_PCD_Init() & FM_PCD_KgSchemeSet().
*//***************************************************************************/
-uint32_t FM_PCD_KgGetSchemeCounter(t_Handle h_FmPcd, t_Handle h_Scheme);
+uint32_t FM_PCD_KgSchemeGetCounter(t_Handle h_Scheme);
/**************************************************************************//**
- @Function FM_PCD_KgSetSchemeCounter
+ @Function FM_PCD_KgSchemeSetCounter
@Description Writes scheme packet counter.
- @Param[in] h_FmPcd FM PCD module descriptor.
- @Param[in] h_Scheme scheme handle as returned by FM_PCD_KgSetScheme.
+ @Param[in] h_Scheme scheme handle as returned by FM_PCD_KgSchemeSet().
@Param[in] value New scheme counter value - typically '0' for
resetting the counter.
+
@Return E_OK on success; Error code otherwise.
+ @Cautions Allowed only following FM_PCD_Init() & FM_PCD_KgSchemeSet().
+*//***************************************************************************/
+t_Error FM_PCD_KgSchemeSetCounter(t_Handle h_Scheme, uint32_t value);
+
+/**************************************************************************//**
+ @Function FM_PCD_PlcrProfileSet
+
+ @Description Sets a profile entry in the policer profile table.
+ The routine overrides any existing value.
+
+ @Param[in] h_FmPcd A handle to an FM PCD Module.
+ @Param[in] p_Profile A structure of parameters for defining a
+ policer profile entry.
+
+ @Return A handle to the initialized object on success; NULL code otherwise.
+ When used as "modify" (rather than for setting a new profile),
+ p_Profile->id.h_Profile will return NULL if action fails due to profile
+ BUSY state.
@Cautions Allowed only following FM_PCD_Init().
*//***************************************************************************/
-t_Error FM_PCD_KgSetSchemeCounter(t_Handle h_FmPcd, t_Handle h_Scheme, uint32_t value);
+t_Handle FM_PCD_PlcrProfileSet(t_Handle h_FmPcd,
+ t_FmPcdPlcrProfileParams *p_Profile);
/**************************************************************************//**
- @Function FM_PCD_CcBuildTree
+ @Function FM_PCD_PlcrProfileDelete
+
+ @Description Delete a profile entry in the policer profile table.
+ The routine set entry to invalid.
+
+ @Param[in] h_Profile A handle to the profile.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PCD_Init().
+*//***************************************************************************/
+t_Error FM_PCD_PlcrProfileDelete(t_Handle h_Profile);
+
+/**************************************************************************//**
+ @Function FM_PCD_PlcrProfileGetCounter
+
+ @Description Sets an entry in the classification plan.
+ The routine overrides any existing value.
+
+ @Param[in] h_Profile A handle to the profile.
+ @Param[in] counter Counter selector.
+
+ @Return specific counter value.
+
+ @Cautions Allowed only following FM_PCD_Init().
+*//***************************************************************************/
+uint32_t FM_PCD_PlcrProfileGetCounter(t_Handle h_Profile,
+ e_FmPcdPlcrProfileCounters counter);
+
+/**************************************************************************//**
+ @Function FM_PCD_PlcrProfileSetCounter
+
+ @Description Sets an entry in the classification plan.
+ The routine overrides any existing value.
+
+ @Param[in] h_Profile A handle to the profile.
+ @Param[in] counter Counter selector.
+ @Param[in] value value to set counter with.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PCD_Init().
+*//***************************************************************************/
+t_Error FM_PCD_PlcrProfileSetCounter(t_Handle h_Profile,
+ e_FmPcdPlcrProfileCounters counter,
+ uint32_t value);
+
+/**************************************************************************//**
+ @Function FM_PCD_CcRootBuild
@Description This routine must be called to define a complete coarse
classification tree. This is the way to define coarse
- classification to a certain flow - the keygen schemes
+ classification to a certain flow - the KeyGen schemes
may point only to trees defined in this way.
- @Param[in] h_FmPcd FM PCD module descriptor.
- @Param[in] p_FmPcdCcTreeParams A structure of parameters to define the tree.
+ @Param[in] h_FmPcd FM PCD module descriptor.
+ @Param[in] p_Params A structure of parameters to define the tree.
@Return A handle to the initialized object on success; NULL code otherwise.
@Cautions Allowed only following FM_PCD_Init().
*//***************************************************************************/
-t_Handle FM_PCD_CcBuildTree (t_Handle h_FmPcd,
- t_FmPcdCcTreeParams *p_FmPcdCcTreeParams);
+t_Handle FM_PCD_CcRootBuild (t_Handle h_FmPcd,
+ t_FmPcdCcTreeParams *p_Params);
/**************************************************************************//**
- @Function FM_PCD_CcDeleteTree
+ @Function FM_PCD_CcRootDelete
@Description Deleting an built tree.
- @Param[in] h_FmPcd A handle to an FM PCD Module.
@Param[in] h_CcTree A handle to a CC tree.
+ @Return E_OK on success; Error code otherwise.
+
@Cautions Allowed only following FM_PCD_Init().
*//***************************************************************************/
-t_Error FM_PCD_CcDeleteTree(t_Handle h_FmPcd, t_Handle h_CcTree);
+t_Error FM_PCD_CcRootDelete(t_Handle h_CcTree);
/**************************************************************************//**
- @Function FM_PCD_CcSetNode
+ @Function FM_PCD_CcRootModifyNextEngine
+
+ @Description Modify the Next Engine Parameters in the entry of the tree.
+
+ @Param[in] h_CcTree A handle to the tree
+ @Param[in] grpId A Group index in the tree
+ @Param[in] index Entry index in the group defined by grpId
+ @Param[in] p_FmPcdCcNextEngineParams Pointer to new next engine parameters
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PCD_CcBuildTree().
+*//***************************************************************************/
+t_Error FM_PCD_CcRootModifyNextEngine(t_Handle h_CcTree,
+ uint8_t grpId,
+ uint8_t index,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
+
+/**************************************************************************//**
+ @Function FM_PCD_MatchTableSet
@Description This routine should be called for each CC (coarse classification)
node. The whole CC tree should be built bottom up so that each
node points to already defined nodes.
- @Param[in] h_FmPcd FM PCD module descriptor.
- @Param[in] p_CcNodeParam A structure of parameters defining the CC node
+ @Param[in] h_FmPcd FM PCD module descriptor.
+ @Param[in] p_Param A structure of parameters defining the CC node
@Return A handle to the initialized object on success; NULL code otherwise.
@Cautions Allowed only following FM_PCD_Init().
*//***************************************************************************/
-t_Handle FM_PCD_CcSetNode(t_Handle h_FmPcd,
- t_FmPcdCcNodeParams *p_CcNodeParam);
+t_Handle FM_PCD_MatchTableSet(t_Handle h_FmPcd, t_FmPcdCcNodeParams *p_Param);
/**************************************************************************//**
- @Function FM_PCD_CcDeleteNode
+ @Function FM_PCD_MatchTableDelete
@Description Deleting an built node.
- @Param[in] h_FmPcd A handle to an FM PCD Module.
@Param[in] h_CcNode A handle to a CC node.
+ @Return E_OK on success; Error code otherwise.
+
@Cautions Allowed only following FM_PCD_Init().
*//***************************************************************************/
-t_Error FM_PCD_CcDeleteNode(t_Handle h_FmPcd, t_Handle h_CcNode);
+t_Error FM_PCD_MatchTableDelete(t_Handle h_CcNode);
/**************************************************************************//**
- @Function FM_PCD_CcTreeModifyNextEngine
+ @Function FM_PCD_MatchTableModifyMissNextEngine
- @Description Modify the Next Engine Parameters in the entry of the tree.
+ @Description Modify the Next Engine Parameters of the Miss key case of the node.
- @Param[in] h_FmPcd A handle to an FM PCD Module.
- @Param[in] h_CcTree A handle to the tree
- @Param[in] grpId A Group index in the tree
- @Param[in] index Entry index in the group defined by grpId
- @Param[in] p_FmPcdCcNextEngineParams A structure for defining new next engine params
+ @Param[in] h_CcNode A handle to the node
+ @Param[in] p_FmPcdCcNextEngineParams Parameters for defining next engine
@Return E_OK on success; Error code otherwise.
- @Cautions Allowed only following FM_PCD_CcBuildTree().
+ @Cautions Allowed only following FM_PCD_MatchTableSet();
+ Not relevant in the case the node is of type 'INDEXED_LOOKUP'.
+ When configuring nextEngine = e_FM_PCD_CC, note that
+ p_FmPcdCcNextEngineParams->ccParams.h_CcNode must be different
+ from the currently changed table.
+
*//***************************************************************************/
-t_Error FM_PCD_CcTreeModifyNextEngine(t_Handle h_FmPcd, t_Handle h_CcTree, uint8_t grpId, uint8_t index, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
+t_Error FM_PCD_MatchTableModifyMissNextEngine(t_Handle h_CcNode,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
/**************************************************************************//**
- @Function FM_PCD_CcNodeModifyNextEngine
+ @Function FM_PCD_MatchTableRemoveKey
- @Description Modify the Next Engine Parameters in the relevant key entry of the node.
+ @Description Remove the key (including next engine parameters of this key)
+ defined by the index of the relevant node.
- @Param[in] h_FmPcd A handle to an FM PCD Module.
@Param[in] h_CcNode A handle to the node
- @Param[in] keyIndex Key index for Next Engine Params modifications
- @Param[in] p_FmPcdCcNextEngineParams A structure for defining new next engine params
+ @Param[in] keyIndex Key index for removing
@Return E_OK on success; Error code otherwise.
- @Cautions Allowed only following FM_PCD_CcSetNode().
+ @Cautions Allowed only following FM_PCD_MatchTableSet() was called for this
+ node and the nodes that lead to it.
*//***************************************************************************/
-t_Error FM_PCD_CcNodeModifyNextEngine(t_Handle h_FmPcd, t_Handle h_CcNode, uint8_t keyIndex, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
+t_Error FM_PCD_MatchTableRemoveKey(t_Handle h_CcNode, uint16_t keyIndex);
/**************************************************************************//**
- @Function FM_PCD_CcNodeModifyMissNextEngine
+ @Function FM_PCD_MatchTableAddKey
- @Description Modify the Next Engine Parameters of the Miss key case of the node.
+ @Description Add the key (including next engine parameters of this key in the
+ index defined by the keyIndex. Note that 'FM_PCD_LAST_KEY_INDEX'
+ may be used by user that don't care about the position of the
+ key in the table - in that case, the key will be automatically
+ added by the driver in the last available entry.
- @Param[in] h_FmPcd A handle to an FM PCD Module.
- @Param[in] h_CcNode A handle to the node
- @Param[in] p_FmPcdCcNextEngineParams A structure for defining new next engine params
+ @Param[in] h_CcNode A handle to the node
+ @Param[in] keyIndex Key index for adding.
+ @Param[in] keySize Key size of added key
+ @Param[in] p_KeyParams A pointer to the parameters includes
+ new key with Next Engine Parameters
@Return E_OK on success; Error code otherwise.
- @Cautions Allowed only following FM_PCD_CcSetNode().
+ @Cautions Allowed only following FM_PCD_MatchTableSet() was called for this
+ node and the nodes that lead to it.
*//***************************************************************************/
-t_Error FM_PCD_CcNodeModifyMissNextEngine(t_Handle h_FmPcd, t_Handle h_CcNode, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
+t_Error FM_PCD_MatchTableAddKey(t_Handle h_CcNode,
+ uint16_t keyIndex,
+ uint8_t keySize,
+ t_FmPcdCcKeyParams *p_KeyParams);
/**************************************************************************//**
- @Function FM_PCD_CcNodeRemoveKey
+ @Function FM_PCD_MatchTableModifyNextEngine
- @Description Remove the key (include Next Engine Parameters of this key) defined by the index of the relevant node .
+ @Description Modify the Next Engine Parameters in the relevant key entry of the node.
- @Param[in] h_FmPcd A handle to an FM PCD Module.
@Param[in] h_CcNode A handle to the node
- @Param[in] keyIndex Key index for removing
+ @Param[in] keyIndex Key index for Next Engine modifications
+ @Param[in] p_FmPcdCcNextEngineParams Parameters for defining next engine
@Return E_OK on success; Error code otherwise.
- @Cautions Allowed only following FM_PCD_CcSetNode() not only of the relevant node but also
- the node that points to this node
+ @Cautions Allowed only following FM_PCD_MatchTableSet().
+ When configuring nextEngine = e_FM_PCD_CC, note that
+ p_FmPcdCcNextEngineParams->ccParams.h_CcNode must be different
+ from the currently changed table.
+
*//***************************************************************************/
-t_Error FM_PCD_CcNodeRemoveKey(t_Handle h_FmPcd, t_Handle h_CcNode, uint8_t keyIndex);
+t_Error FM_PCD_MatchTableModifyNextEngine(t_Handle h_CcNode,
+ uint16_t keyIndex,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
/**************************************************************************//**
- @Function FM_PCD_CcNodeAddKey
+ @Function FM_PCD_MatchTableModifyKeyAndNextEngine
- @Description Add the key(include Next Engine Parameters of this key)in the index defined by the keyIndex .
+ @Description Modify the key and Next Engine Parameters of this key in the
+ index defined by the keyIndex.
- @Param[in] h_FmPcd A handle to an FM PCD Module.
@Param[in] h_CcNode A handle to the node
@Param[in] keyIndex Key index for adding
@Param[in] keySize Key size of added key
- @Param[in] p_KeyParams A pointer to the parameters includes new key with Next Engine Parameters
+ @Param[in] p_KeyParams A pointer to the parameters includes
+ modified key and modified Next Engine Parameters
@Return E_OK on success; Error code otherwise.
- @Cautions Allowed only following FM_PCD_CcSetNode() not only of the relevant node but also
- the node that points to this node
+ @Cautions Allowed only following FM_PCD_MatchTableSet() was called for this
+ node and the nodes that lead to it.
+ When configuring nextEngine = e_FM_PCD_CC, note that
+ p_FmPcdCcNextEngineParams->ccParams.h_CcNode must be different
+ from the currently changed table.
*//***************************************************************************/
-t_Error FM_PCD_CcNodeAddKey(t_Handle h_FmPcd, t_Handle h_CcNode, uint8_t keyIndex, uint8_t keySize, t_FmPcdCcKeyParams *p_KeyParams);
+t_Error FM_PCD_MatchTableModifyKeyAndNextEngine(t_Handle h_CcNode,
+ uint16_t keyIndex,
+ uint8_t keySize,
+ t_FmPcdCcKeyParams *p_KeyParams);
/**************************************************************************//**
- @Function FM_PCD_CcNodeModifyKeyAndNextEngine
+ @Function FM_PCD_MatchTableModifyKey
- @Description Modify the key and Next Engine Parameters of this key in the index defined by the keyIndex .
+ @Description Modify the key in the index defined by the keyIndex.
- @Param[in] h_FmPcd A handle to an FM PCD Module.
@Param[in] h_CcNode A handle to the node
@Param[in] keyIndex Key index for adding
@Param[in] keySize Key size of added key
- @Param[in] p_KeyParams A pointer to the parameters includes modified key and modified Next Engine Parameters
+ @Param[in] p_Key A pointer to the new key
+ @Param[in] p_Mask A pointer to the new mask if relevant,
+ otherwise pointer to NULL
@Return E_OK on success; Error code otherwise.
- @Cautions Allowed only following FM_PCD_CcSetNode() not only of the relevant node but also
- the node that points to this node
+ @Cautions Allowed only following FM_PCD_MatchTableSet() was called for this
+ node and the nodes that lead to it.
*//***************************************************************************/
-t_Error FM_PCD_CcNodeModifyKeyAndNextEngine(t_Handle h_FmPcd, t_Handle h_CcNode, uint8_t keyIndex, uint8_t keySize, t_FmPcdCcKeyParams *p_KeyParams);
+t_Error FM_PCD_MatchTableModifyKey(t_Handle h_CcNode,
+ uint16_t keyIndex,
+ uint8_t keySize,
+ uint8_t *p_Key,
+ uint8_t *p_Mask);
/**************************************************************************//**
- @Function FM_PCD_CcNodeModifyKey
+ @Function FM_PCD_MatchTableFindNRemoveKey
- @Description Modify the key in the index defined by the keyIndex .
+ @Description Remove the key (including next engine parameters of this key)
+ defined by the key and mask. Note that this routine will search
+ the node to locate the index of the required key (& mask) to remove.
- @Param[in] h_FmPcd A handle to an FM PCD Module.
@Param[in] h_CcNode A handle to the node
- @Param[in] keyIndex Key index for adding
- @Param[in] keySize Key size of added key
- @Param[in] p_Key A pointer to the new key
- @Param[in] p_Mask A pointer to the new mask if relevant, otherwise pointer to NULL
+ @Param[in] keySize Key size of the one to remove.
+ @Param[in] p_Key A pointer to the requested key to remove.
+ @Param[in] p_Mask A pointer to the mask if relevant,
+ otherwise pointer to NULL
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PCD_MatchTableSet() was called for this
+ node and the nodes that lead to it.
+*//***************************************************************************/
+t_Error FM_PCD_MatchTableFindNRemoveKey(t_Handle h_CcNode,
+ uint8_t keySize,
+ uint8_t *p_Key,
+ uint8_t *p_Mask);
+
+/**************************************************************************//**
+ @Function FM_PCD_MatchTableFindNModifyNextEngine
+
+ @Description Modify the Next Engine Parameters in the relevant key entry of
+ the node. Note that this routine will search the node to locate
+ the index of the required key (& mask) to modify.
+
+ @Param[in] h_CcNode A handle to the node
+ @Param[in] keySize Key size of the one to modify.
+ @Param[in] p_Key A pointer to the requested key to modify.
+ @Param[in] p_Mask A pointer to the mask if relevant,
+ otherwise pointer to NULL
+ @Param[in] p_FmPcdCcNextEngineParams Parameters for defining next engine
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PCD_MatchTableSet().
+ When configuring nextEngine = e_FM_PCD_CC, note that
+ p_FmPcdCcNextEngineParams->ccParams.h_CcNode must be different
+ from the currently changed table.
+*//***************************************************************************/
+t_Error FM_PCD_MatchTableFindNModifyNextEngine(t_Handle h_CcNode,
+ uint8_t keySize,
+ uint8_t *p_Key,
+ uint8_t *p_Mask,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
+
+/**************************************************************************//**
+ @Function FM_PCD_MatchTableFindNModifyKeyAndNextEngine
+
+ @Description Modify the key and Next Engine Parameters of this key in the
+ index defined by the keyIndex. Note that this routine will search
+ the node to locate the index of the required key (& mask) to modify.
+
+ @Param[in] h_CcNode A handle to the node
+ @Param[in] keySize Key size of the one to modify.
+ @Param[in] p_Key A pointer to the requested key to modify.
+ @Param[in] p_Mask A pointer to the mask if relevant,
+ otherwise pointer to NULL
+ @Param[in] p_KeyParams A pointer to the parameters includes
+ modified key and modified Next Engine Parameters
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PCD_MatchTableSet() was called for this
+ node and the nodes that lead to it.
+ When configuring nextEngine = e_FM_PCD_CC, note that
+ p_FmPcdCcNextEngineParams->ccParams.h_CcNode must be different
+ from the currently changed table.
+*//***************************************************************************/
+t_Error FM_PCD_MatchTableFindNModifyKeyAndNextEngine(t_Handle h_CcNode,
+ uint8_t keySize,
+ uint8_t *p_Key,
+ uint8_t *p_Mask,
+ t_FmPcdCcKeyParams *p_KeyParams);
+
+/**************************************************************************//**
+ @Function FM_PCD_MatchTableFindNModifyKey
+
+ @Description Modify the key in the index defined by the keyIndex. Note that
+ this routine will search the node to locate the index of the
+ required key (& mask) to modify.
+
+ @Param[in] h_CcNode A handle to the node
+ @Param[in] keySize Key size of the one to modify.
+ @Param[in] p_Key A pointer to the requested key to modify.
+ @Param[in] p_Mask A pointer to the mask if relevant,
+ otherwise pointer to NULL
+ @Param[in] p_NewKey A pointer to the new key
+ @Param[in] p_NewMask A pointer to the new mask if relevant,
+ otherwise pointer to NULL
@Return E_OK on success; Error code otherwise.
- @Cautions Allowed only following FM_PCD_CcSetNode() not only of the relevant node but also
- the node that points to this node
+ @Cautions Allowed only following FM_PCD_MatchTableSet() was called for this
+ node and the nodes that lead to it.
*//***************************************************************************/
-t_Error FM_PCD_CcNodeModifyKey(t_Handle h_FmPcd, t_Handle h_CcNode, uint8_t keyIndex, uint8_t keySize, uint8_t *p_Key, uint8_t *p_Mask);
+t_Error FM_PCD_MatchTableFindNModifyKey(t_Handle h_CcNode,
+ uint8_t keySize,
+ uint8_t *p_Key,
+ uint8_t *p_Mask,
+ uint8_t *p_NewKey,
+ uint8_t *p_NewMask);
/**************************************************************************//**
- @Function FM_PCD_CcNodeGetKeyCounter
+ @Function FM_PCD_MatchTableGetKeyCounter
@Description This routine may be used to get a counter of specific key in a CC
Node; This counter reflects how many frames passed that were matched
this key.
- @Param[in] h_FmPcd A handle to an FM PCD Module.
- @Param[in] h_CcNode A handle to the node
- @Param[in] keyIndex Key index for adding
+ @Param[in] h_CcNode A handle to the node
+ @Param[in] keyIndex Key index for adding
@Return The specific key counter.
- @Cautions Allowed only following FM_PCD_CcSetNode() not only of the relevant node but also
- the node that points to this node
+ @Cautions Allowed only following FM_PCD_MatchTableSet().
*//***************************************************************************/
-uint32_t FM_PCD_CcNodeGetKeyCounter(t_Handle h_FmPcd, t_Handle h_CcNode, uint8_t keyIndex);
+uint32_t FM_PCD_MatchTableGetKeyCounter(t_Handle h_CcNode, uint16_t keyIndex);
/**************************************************************************//**
- @Function FM_PCD_PlcrSetProfile
+ @Function FM_PCD_MatchTableGetKeyStatistics
- @Description Sets a profile entry in the policer profile table.
- The routine overrides any existing value.
+ @Description This routine may be used to get statistics counters of specific key
+ in a CC Node.
- @Param[in] h_FmPcd A handle to an FM PCD Module.
- @Param[in] p_Profile A structure of parameters for defining a
- policer profile entry.
+ If 'e_FM_PCD_CC_STATS_MODE_FRAME' and
+ 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this node,
+ these counters reflect how many frames passed that were matched
+ this key; The total frames count will be returned in the counter
+ of the first range (as only one frame length range was defined).
+ If 'e_FM_PCD_CC_STATS_MODE_RMON' was set for this node, the total
+ frame count will be separated to frame length counters, based on
+ provided frame length ranges.
+
+ @Param[in] h_CcNode A handle to the node
+ @Param[in] keyIndex Key index for adding
+ @Param[out] p_KeyStatistics Key statistics counters
+
+ @Return The specific key statistics.
+
+ @Cautions Allowed only following FM_PCD_MatchTableSet().
+*//***************************************************************************/
+t_Error FM_PCD_MatchTableGetKeyStatistics(t_Handle h_CcNode,
+ uint16_t keyIndex,
+ t_FmPcdCcKeyStatistics *p_KeyStatistics);
+
+/**************************************************************************//**
+ @Function FM_PCD_MatchTableGetMissStatistics
+
+ @Description This routine may be used to get statistics counters of miss entry
+ in a CC Node.
+
+ If 'e_FM_PCD_CC_STATS_MODE_FRAME' and
+ 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this node,
+ these counters reflect how many frames were not matched to any
+ existing key and therefore passed through the miss entry; The
+ total frames count will be returned in the counter of the
+ first range (as only one frame length range was defined).
+
+ @Param[in] h_CcNode A handle to the node
+ @Param[out] p_MissStatistics Statistics counters for 'miss'
+
+ @Return The statistics for 'miss'.
+
+ @Cautions Allowed only following FM_PCD_MatchTableSet().
+*//***************************************************************************/
+t_Error FM_PCD_MatchTableGetMissStatistics(t_Handle h_CcNode,
+ t_FmPcdCcKeyStatistics *p_MissStatistics);
+
+/**************************************************************************//**
+ @Function FM_PCD_MatchTableFindNGetKeyStatistics
+
+ @Description This routine may be used to get statistics counters of specific key
+ in a CC Node.
+
+ If 'e_FM_PCD_CC_STATS_MODE_FRAME' and
+ 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this node,
+ these counters reflect how many frames passed that were matched
+ this key; The total frames count will be returned in the counter
+ of the first range (as only one frame length range was defined).
+ If 'e_FM_PCD_CC_STATS_MODE_RMON' was set for this node, the total
+ frame count will be separated to frame length counters, based on
+ provided frame length ranges.
+ Note that this routine will search the node to locate the index
+ of the required key based on received key parameters.
+
+ @Param[in] h_CcNode A handle to the node
+ @Param[in] keySize Size of the requested key
+ @Param[in] p_Key A pointer to the requested key
+ @Param[in] p_Mask A pointer to the mask if relevant,
+ otherwise pointer to NULL
+ @Param[out] p_KeyStatistics Key statistics counters
+
+ @Return The specific key statistics.
+
+ @Cautions Allowed only following FM_PCD_MatchTableSet().
+*//***************************************************************************/
+t_Error FM_PCD_MatchTableFindNGetKeyStatistics(t_Handle h_CcNode,
+ uint8_t keySize,
+ uint8_t *p_Key,
+ uint8_t *p_Mask,
+ t_FmPcdCcKeyStatistics *p_KeyStatistics);
+
+/**************************************************************************//*
+ @Function FM_PCD_MatchTableGetNextEngine
+
+ @Description Gets NextEngine of the relevant keyIndex.
+
+ @Param[in] h_CcNode A handle to the node.
+ @Param[in] keyIndex keyIndex in the relevant node.
+ @Param[out] p_FmPcdCcNextEngineParams here updated nextEngine parameters for
+ the relevant keyIndex of the CC Node
+ received as parameter to this function
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PCD_Init().
+*//***************************************************************************/
+t_Error FM_PCD_MatchTableGetNextEngine(t_Handle h_CcNode,
+ uint16_t keyIndex,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
+
+/**************************************************************************//*
+ @Function FM_PCD_MatchTableGetIndexedHashBucket
+
+ @Description This routine simulates KeyGen operation on the provided key and
+ calculates to which hash bucket it will be mapped.
+
+ @Param[in] h_CcNode A handle to the node.
+ @Param[in] kgKeySize Key size as it was configured in the KG
+ scheme that leads to this hash.
+ @Param[in] p_KgKey Pointer to the key; must be like the key
+ that the KG is generated, i.e. the same
+ extraction and with mask if exist.
+ @Param[in] kgHashShift Hash-shift as it was configured in the KG
+ scheme that leads to this hash.
+ @Param[out] p_CcNodeBucketHandle Pointer to the bucket of the provided key.
+ @Param[out] p_BucketIndex Index to the bucket of the provided key
+ @Param[out] p_LastIndex Pointer to last index in the bucket of the
+ provided key.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PCD_HashTableSet()
+*//***************************************************************************/
+t_Error FM_PCD_MatchTableGetIndexedHashBucket(t_Handle h_CcNode,
+ uint8_t kgKeySize,
+ uint8_t *p_KgKey,
+ uint8_t kgHashShift,
+ t_Handle *p_CcNodeBucketHandle,
+ uint8_t *p_BucketIndex,
+ uint16_t *p_LastIndex);
+
+/**************************************************************************//**
+ @Function FM_PCD_HashTableSet
+
+ @Description This routine initializes a hash table structure.
+ KeyGen hash result determines the hash bucket.
+ Next, KeyGen key is compared against all keys of this
+ bucket (exact match).
+ Number of sets (number of buckets) of the hash equals to the
+ number of 1-s in 'hashResMask' in the provided parameters.
+ Number of hash table ways is then calculated by dividing
+ 'maxNumOfKeys' equally between the hash sets. This is the maximal
+ number of keys that a hash bucket may hold.
+ The hash table is initialized empty and keys may be
+ added to it following the initialization. Keys masks are not
+ supported in current hash table implementation.
+ The initialized hash table can be integrated as a node in a
+ CC tree.
+
+ @Param[in] h_FmPcd FM PCD module descriptor.
+ @Param[in] p_Param A structure of parameters defining the hash table
@Return A handle to the initialized object on success; NULL code otherwise.
@Cautions Allowed only following FM_PCD_Init().
*//***************************************************************************/
-t_Handle FM_PCD_PlcrSetProfile(t_Handle h_FmPcd,
- t_FmPcdPlcrProfileParams *p_Profile);
+t_Handle FM_PCD_HashTableSet(t_Handle h_FmPcd, t_FmPcdHashTableParams *p_Param);
/**************************************************************************//**
- @Function FM_PCD_PlcrDeleteProfile
+ @Function FM_PCD_HashTableDelete
- @Description Delete a profile entry in the policer profile table.
- The routine set entry to invalid.
+ @Description This routine deletes the provided hash table and released all
+ its allocated resources.
- @Param[in] h_FmPcd A handle to an FM PCD Module.
- @Param[in] h_Profile A handle to the profile.
+ @Param[in] h_HashTbl A handle to a hash table
@Return E_OK on success; Error code otherwise.
- @Cautions Allowed only following FM_PCD_Init().
+ @Cautions Allowed only following FM_PCD_HashTableSet().
*//***************************************************************************/
-t_Error FM_PCD_PlcrDeleteProfile(t_Handle h_FmPcd, t_Handle h_Profile);
+t_Error FM_PCD_HashTableDelete(t_Handle h_HashTbl);
/**************************************************************************//**
- @Function FM_PCD_PlcrGetProfileCounter
+ @Function FM_PCD_HashTableAddKey
- @Description Sets an entry in the classification plan.
- The routine overrides any existing value.
+ @Description This routine adds the provided key (including next engine
+ parameters of this key) to the hash table.
+ The key is added as the last key of the bucket that it is
+ mapped to.
- @Param[in] h_FmPcd A handle to an FM PCD Module.
- @Param[in] h_Profile A handle to the profile.
- @Param[in] counter Counter selector.
+ @Param[in] h_HashTbl A handle to a hash table
+ @Param[in] keySize Key size of added key
+ @Param[in] p_KeyParams A pointer to the parameters includes
+ new key with next engine parameters; The pointer
+ to the key mask must be NULL, as masks are not
+ supported in hash table implementation.
- @Return specific counter value.
+ @Return E_OK on success; Error code otherwise.
- @Cautions Allowed only following FM_PCD_Init().
+ @Cautions Allowed only following FM_PCD_HashTableSet().
*//***************************************************************************/
-uint32_t FM_PCD_PlcrGetProfileCounter(t_Handle h_FmPcd, t_Handle h_Profile, e_FmPcdPlcrProfileCounters counter);
+t_Error FM_PCD_HashTableAddKey(t_Handle h_HashTbl,
+ uint8_t keySize,
+ t_FmPcdCcKeyParams *p_KeyParams);
/**************************************************************************//**
- @Function FM_PCD_PlcrSetProfileCounter
+ @Function FM_PCD_HashTableRemoveKey
- @Description Sets an entry in the classification plan.
- The routine overrides any existing value.
+ @Description This routine removes the requested key (including next engine
+ parameters of this key) from the hash table.
- @Param[in] h_FmPcd A handle to an FM PCD Module.
- @Param[in] h_Profile A handle to the profile.
- @Param[in] counter Counter selector.
- @Param[in] value value to set counter with.
+ @Param[in] h_HashTbl A handle to a hash table
+ @Param[in] keySize Key size of the one to remove.
+ @Param[in] p_Key A pointer to the requested key to remove.
@Return E_OK on success; Error code otherwise.
- @Cautions Allowed only following FM_PCD_Init().
+ @Cautions Allowed only following FM_PCD_HashTableSet().
+*//***************************************************************************/
+t_Error FM_PCD_HashTableRemoveKey(t_Handle h_HashTbl,
+ uint8_t keySize,
+ uint8_t *p_Key);
+
+/**************************************************************************//**
+ @Function FM_PCD_HashTableModifyNextEngine
+
+ @Description This routine modifies the next engine for the provided key. The
+ key should be previously added to the hash table.
+
+ @Param[in] h_HashTbl A handle to a hash table
+ @Param[in] keySize Key size of the key to modify.
+ @Param[in] p_Key A pointer to the requested key to modify.
+ @Param[in] p_FmPcdCcNextEngineParams A structure for defining new next engine
+ parameters.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PCD_HashTableSet().
+ When configuring nextEngine = e_FM_PCD_CC, note that
+ p_FmPcdCcNextEngineParams->ccParams.h_CcNode must be different
+ from the currently changed table.
*//***************************************************************************/
-t_Error FM_PCD_PlcrSetProfileCounter(t_Handle h_FmPcd, t_Handle h_Profile, e_FmPcdPlcrProfileCounters counter, uint32_t value);
+t_Error FM_PCD_HashTableModifyNextEngine(t_Handle h_HashTbl,
+ uint8_t keySize,
+ uint8_t *p_Key,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
-#if defined(FM_CAPWAP_SUPPORT)
/**************************************************************************//**
- @Function FM_PCD_ManipSetNode
+ @Function FM_PCD_HashTableModifyMissNextEngine
+
+ @Description This routine modifies the next engine on key match miss.
+
+ @Param[in] h_HashTbl A handle to a hash table
+ @Param[in] p_FmPcdCcNextEngineParams A structure for defining new next engine
+ parameters.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PCD_HashTableSet().
+ When configuring nextEngine = e_FM_PCD_CC, note that
+ p_FmPcdCcNextEngineParams->ccParams.h_CcNode must be different
+ from the currently changed table.
+*//***************************************************************************/
+t_Error FM_PCD_HashTableModifyMissNextEngine(t_Handle h_HashTbl,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
+
+/**************************************************************************//*
+ @Function FM_PCD_HashTableGetMissNextEngine
+
+ @Description Gets NextEngine in case of key match miss.
+
+ @Param[in] h_HashTbl A handle to a hash table
+ @Param[out] p_FmPcdCcNextEngineParams Next engine parameters for the specified
+ hash table.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PCD_HashTableSet().
+*//***************************************************************************/
+t_Error FM_PCD_HashTableGetMissNextEngine(t_Handle h_HashTbl,
+ t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
+
+/**************************************************************************//**
+ @Function FM_PCD_HashTableFindNGetKeyStatistics
+
+ @Description This routine may be used to get statistics counters of specific key
+ in a hash table.
+
+ If 'e_FM_PCD_CC_STATS_MODE_FRAME' and
+ 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this node,
+ these counters reflect how many frames passed that were matched
+ this key; The total frames count will be returned in the counter
+ of the first range (as only one frame length range was defined).
+ If 'e_FM_PCD_CC_STATS_MODE_RMON' was set for this node, the total
+ frame count will be separated to frame length counters, based on
+ provided frame length ranges.
+ Note that this routine will identify the bucket of this key in
+ the hash table and will search the bucket to locate the index
+ of the required key based on received key parameters.
+
+ @Param[in] h_HashTbl A handle to a hash table
+ @Param[in] keySize Size of the requested key
+ @Param[in] p_Key A pointer to the requested key
+ @Param[out] p_KeyStatistics Key statistics counters
+
+ @Return The specific key statistics.
+
+ @Cautions Allowed only following FM_PCD_HashTableSet().
+*//***************************************************************************/
+t_Error FM_PCD_HashTableFindNGetKeyStatistics(t_Handle h_HashTbl,
+ uint8_t keySize,
+ uint8_t *p_Key,
+ t_FmPcdCcKeyStatistics *p_KeyStatistics);
+
+/**************************************************************************//**
+ @Function FM_PCD_HashTableGetMissStatistics
+
+ @Description This routine may be used to get statistics counters of 'miss'
+ entry of the a hash table.
+
+ If 'e_FM_PCD_CC_STATS_MODE_FRAME' and
+ 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this node,
+ these counters reflect how many frames were not matched to any
+ existing key and therefore passed through the miss entry;
+
+ @Param[in] h_HashTbl A handle to a hash table
+ @Param[out] p_MissStatistics Statistics counters for 'miss'
+
+ @Return The statistics for 'miss'.
+
+ @Cautions Allowed only following FM_PCD_HashTableSet().
+*//***************************************************************************/
+t_Error FM_PCD_HashTableGetMissStatistics(t_Handle h_HashTbl,
+ t_FmPcdCcKeyStatistics *p_MissStatistics);
+
+/**************************************************************************//**
+ @Function FM_PCD_ManipNodeSet
@Description This routine should be called for defining a manipulation
node. A manipulation node must be defined before the CC node
@@ -2117,28 +3778,116 @@ t_Error FM_PCD_PlcrSetProfileCounter(t_Handle h_FmPcd, t_Handle h_Profile, e_FmP
@Cautions Allowed only following FM_PCD_Init().
*//***************************************************************************/
-t_Handle FM_PCD_ManipSetNode(t_Handle h_FmPcd, t_FmPcdManipParams *p_FmPcdManipParams);
+t_Handle FM_PCD_ManipNodeSet(t_Handle h_FmPcd, t_FmPcdManipParams *p_FmPcdManipParams);
/**************************************************************************//**
- @Function FM_PCD_ManipDeleteNode
+ @Function FM_PCD_ManipNodeDelete
- @Description Delete an existing manip node.
+ @Description Delete an existing manipulation node.
- @Param[in] h_FmPcd A handle to an FM PCD Module.
- @Param[in] h_HdrManipNode A handle to a Manip node.
+ @Param[in] h_ManipNode A handle to a manipulation node.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PCD_ManipNodeSet().
+*//***************************************************************************/
+t_Error FM_PCD_ManipNodeDelete(t_Handle h_ManipNode);
+
+/**************************************************************************//**
+ @Function FM_PCD_ManipGetStatistics
+
+ @Description Retrieve the manipulation statistics.
+
+ @Param[in] h_ManipNode A handle to a manipulation node.
+ @Param[out] p_FmPcdManipStats A structure for retrieving the manipulation statistics
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PCD_ManipNodeSet().
+*//***************************************************************************/
+t_Error FM_PCD_ManipGetStatistics(t_Handle h_ManipNode, t_FmPcdManipStats *p_FmPcdManipStats);
+
+/**************************************************************************//**
+ @Function FM_PCD_ManipNodeReplace
+
+ @Description Change existing manipulation node to be according to new requirement.
+
+ @Param[in] h_ManipNode A handle to a manipulation node.
+ @Param[out] p_ManipParams A structure of parameters defining the change requirement
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PCD_ManipNodeSet().
+*//***************************************************************************/
+t_Error FM_PCD_ManipNodeReplace(t_Handle h_ManipNode, t_FmPcdManipParams *p_ManipParams);
+
+#if (DPAA_VERSION >= 11)
+/**************************************************************************//**
+ @Function FM_PCD_FrmReplicSetGroup
+
+ @Description Initialize a Frame Replicator group.
+
+ @Param[in] h_FmPcd FM PCD module descriptor.
+ @Param[in] p_FrmReplicGroupParam A structure of parameters for the initialization of
+ the frame replicator group.
+
+ @Return A handle to the initialized object on success; NULL code otherwise.
@Cautions Allowed only following FM_PCD_Init().
*//***************************************************************************/
-t_Error FM_PCD_ManipDeleteNode(t_Handle h_FmPcd, t_Handle h_HdrManipNode);
-#endif /* defined(FM_CAPWAP_SUPPORT) || ... */
+t_Handle FM_PCD_FrmReplicSetGroup(t_Handle h_FmPcd, t_FmPcdFrmReplicGroupParams *p_FrmReplicGroupParam);
+
+/**************************************************************************//**
+ @Function FM_PCD_FrmReplicDeleteGroup
+
+ @Description Delete a Frame Replicator group.
+
+ @Param[in] h_FrmReplicGroup A handle to the frame replicator group.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PCD_FrmReplicSetGroup().
+*//***************************************************************************/
+t_Error FM_PCD_FrmReplicDeleteGroup(t_Handle h_FrmReplicGroup);
+
+/**************************************************************************//**
+ @Function FM_PCD_FrmReplicAddMember
+ @Description Add the member in the index defined by the memberIndex.
+
+ @Param[in] h_FrmReplicGroup A handle to the frame replicator group.
+ @Param[in] memberIndex member index for adding.
+ @Param[in] p_MemberParams A pointer to the new member parameters.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PCD_FrmReplicSetGroup() of this group.
+*//***************************************************************************/
+t_Error FM_PCD_FrmReplicAddMember(t_Handle h_FrmReplicGroup,
+ uint16_t memberIndex,
+ t_FmPcdCcNextEngineParams *p_MemberParams);
-#ifdef FM_CAPWAP_SUPPORT
+/**************************************************************************//**
+ @Function FM_PCD_FrmReplicRemoveMember
+
+ @Description Remove the member defined by the index from the relevant group.
+
+ @Param[in] h_FrmReplicGroup A handle to the frame replicator group.
+ @Param[in] memberIndex member index for removing.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PCD_FrmReplicSetGroup() of this group.
+*//***************************************************************************/
+t_Error FM_PCD_FrmReplicRemoveMember(t_Handle h_FrmReplicGroup,
+ uint16_t memberIndex);
+#endif /* (DPAA_VERSION >= 11) */
+
+#if ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT))
/**************************************************************************//**
@Function FM_PCD_StatisticsSetNode
- @Description This routine should be called for defining a statistics
- node.
+ @Description This routine should be called for defining a statistics node.
@Param[in] h_FmPcd FM PCD module descriptor.
@Param[in] p_FmPcdstatsParams A structure of parameters defining the statistics
@@ -2148,13 +3897,78 @@ t_Error FM_PCD_ManipDeleteNode(t_Handle h_FmPcd, t_Handle h_HdrManipNode);
@Cautions Allowed only following FM_PCD_Init().
*//***************************************************************************/
t_Handle FM_PCD_StatisticsSetNode(t_Handle h_FmPcd, t_FmPcdStatsParams *p_FmPcdstatsParams);
-#endif /* FM_CAPWAP_SUPPORT */
+#endif /* ((DPAA_VERSION == 10) && defined(FM_CAPWAP_SUPPORT)) */
-/** @} */ /* end of FM_PCD_Runtime_tree_buildgrp group */
+/** @} */ /* end of FM_PCD_Runtime_build_grp group */
/** @} */ /* end of FM_PCD_Runtime_grp group */
/** @} */ /* end of FM_PCD_grp group */
/** @} */ /* end of FM_grp group */
+#ifdef NCSW_BACKWARD_COMPATIBLE_API
+#define FM_PCD_MAX_NUM_OF_INTERCHANGABLE_HDRS FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS
+#define e_FM_PCD_MANIP_ONE_WAYS_HASH e_FM_PCD_MANIP_ONE_WAY_HASH
+#define e_FM_PCD_MANIP_TOW_WAYS_HASH e_FM_PCD_MANIP_TWO_WAYS_HASH
+
+#define e_FM_PCD_MANIP_FRAGMENT_PACKECT e_FM_PCD_MANIP_FRAGMENT_PACKET /* Feb13 */
+
+#define FM_PCD_SetNetEnvCharacteristics(_pcd, _params) \
+ FM_PCD_NetEnvCharacteristicsSet(_pcd, _params)
+#define FM_PCD_KgSetScheme(_pcd, _params) FM_PCD_KgSchemeSet(_pcd, _params)
+#define FM_PCD_CcBuildTree(_pcd, _params) FM_PCD_CcRootBuild(_pcd, _params)
+#define FM_PCD_CcSetNode(_pcd, _params) FM_PCD_MatchTableSet(_pcd, _params)
+#define FM_PCD_PlcrSetProfile(_pcd, _params) FM_PCD_PlcrProfileSet(_pcd, _params)
+#define FM_PCD_ManipSetNode(_pcd, _params) FM_PCD_ManipNodeSet(_pcd, _params)
+
+#define FM_PCD_DeleteNetEnvCharacteristics(_pcd, ...) \
+ FM_PCD_NetEnvCharacteristicsDelete(__VA_ARGS__)
+#define FM_PCD_KgDeleteScheme(_pcd, ...) \
+ FM_PCD_KgSchemeDelete(__VA_ARGS__)
+#define FM_PCD_KgGetSchemeCounter(_pcd, ...) \
+ FM_PCD_KgSchemeGetCounter(__VA_ARGS__)
+#define FM_PCD_KgSetSchemeCounter(_pcd, ...) \
+ FM_PCD_KgSchemeSetCounter(__VA_ARGS__)
+#define FM_PCD_PlcrDeleteProfile(_pcd, ...) \
+ FM_PCD_PlcrProfileDelete(__VA_ARGS__)
+#define FM_PCD_PlcrGetProfileCounter(_pcd, ...) \
+ FM_PCD_PlcrProfileGetCounter(__VA_ARGS__)
+#define FM_PCD_PlcrSetProfileCounter(_pcd, ...) \
+ FM_PCD_PlcrProfileSetCounter(__VA_ARGS__)
+#define FM_PCD_CcDeleteTree(_pcd, ...) \
+ FM_PCD_CcRootDelete(__VA_ARGS__)
+#define FM_PCD_CcTreeModifyNextEngine(_pcd, ...) \
+ FM_PCD_CcRootModifyNextEngine(__VA_ARGS__)
+#define FM_PCD_CcDeleteNode(_pcd, ...) \
+ FM_PCD_MatchTableDelete(__VA_ARGS__)
+#define FM_PCD_CcNodeModifyMissNextEngine(_pcd, ...) \
+ FM_PCD_MatchTableModifyMissNextEngine(__VA_ARGS__)
+#define FM_PCD_CcNodeRemoveKey(_pcd, ...) \
+ FM_PCD_MatchTableRemoveKey(__VA_ARGS__)
+#define FM_PCD_CcNodeAddKey(_pcd, ...) \
+ FM_PCD_MatchTableAddKey(__VA_ARGS__)
+#define FM_PCD_CcNodeModifyNextEngine(_pcd, ...) \
+ FM_PCD_MatchTableModifyNextEngine(__VA_ARGS__)
+#define FM_PCD_CcNodeModifyKeyAndNextEngine(_pcd, ...) \
+ FM_PCD_MatchTableModifyKeyAndNextEngine(__VA_ARGS__)
+#define FM_PCD_CcNodeModifyKey(_pcd, ...) \
+ FM_PCD_MatchTableModifyKey(__VA_ARGS__)
+#define FM_PCD_CcNodeFindNRemoveKey(_pcd, ...) \
+ FM_PCD_MatchTableFindNRemoveKey(__VA_ARGS__)
+#define FM_PCD_CcNodeFindNModifyNextEngine(_pcd, ...) \
+ FM_PCD_MatchTableFindNModifyNextEngine(__VA_ARGS__)
+#define FM_PCD_CcNodeFindNModifyKeyAndNextEngine(_pcd, ...) \
+ FM_PCD_MatchTableFindNModifyKeyAndNextEngine(__VA_ARGS__)
+#define FM_PCD_CcNodeFindNModifyKey(_pcd, ...) \
+ FM_PCD_MatchTableFindNModifyKey(__VA_ARGS__)
+#define FM_PCD_CcIndexedHashNodeGetBucket(_pcd, ...) \
+ FM_PCD_MatchTableGetIndexedHashBucket(__VA_ARGS__)
+#define FM_PCD_CcNodeGetNextEngine(_pcd, ...) \
+ FM_PCD_MatchTableGetNextEngine(__VA_ARGS__)
+#define FM_PCD_CcNodeGetKeyCounter(_pcd, ...) \
+ FM_PCD_MatchTableGetKeyCounter(__VA_ARGS__)
+#define FM_PCD_ManipDeleteNode(_pcd, ...) \
+ FM_PCD_ManipNodeDelete(__VA_ARGS__)
+#endif /* NCSW_BACKWARD_COMPATIBLE_API */
+
#endif /* __FM_PCD_EXT */
diff --git a/sys/contrib/ncsw/inc/Peripherals/fm_port_ext.h b/sys/contrib/ncsw/inc/Peripherals/fm_port_ext.h
index d1df4ea2dfc6..08a5aa59ab9d 100644
--- a/sys/contrib/ncsw/inc/Peripherals/fm_port_ext.h
+++ b/sys/contrib/ncsw/inc/Peripherals/fm_port_ext.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
+/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File fm_port_ext.h
@@ -60,21 +61,18 @@
@Description FM Port API
The FM uses a general module called "port" to represent a Tx port
- (MAC), an Rx port (MAC), offline parsing flow or host command
- flow. There may be up to 17 (may change) ports in an FM - 5 Tx
- ports (4 for the 1G MACs, 1 for the 10G MAC), 5 Rx Ports, and 7
- Host command/Offline parsing ports. The SW driver manages these
- ports as sub-modules of the FM, i.e. after an FM is initialized,
- its ports may be initialized and operated upon.
+ (MAC), an Rx port (MAC) or Offline Parsing port.
+ The number of ports in an FM varies between SOCs.
+ The SW driver manages these ports as sub-modules of the FM, i.e.
+ after an FM is initialized, its ports may be initialized and
+ operated upon.
The port is initialized aware of its type, but other functions on
a port may be indifferent to its type. When necessary, the driver
- verifies coherency and returns error if applicable.
+ verifies coherence and returns error if applicable.
On initialization, user specifies the port type and it's index
- (relative to the port's type). Host command and Offline parsing
- ports share the same id range, I.e user may not initialized host
- command port 0 and offline parsing port 0.
+ (relative to the port's type) - always starting at 0.
@{
*//***************************************************************************/
@@ -85,22 +83,28 @@
all engines have to be used, but all have to be enabled. The real
flow of a specific frame depends on the PCD configuration and the
frame headers and payload.
+ Note: the first engine and the first engine after the parser (if
+ exists) should be in order, the order is important as it will
+ define the flow of the port. However, as for the rest engines
+ (the ones that follows), the order is not important anymore as
+ it is defined by the PCD graph itself.
*//***************************************************************************/
typedef enum e_FmPortPcdSupport {
- e_FM_PORT_PCD_SUPPORT_NONE = 0, /**< BMI to BMI, PCD is not used */
- e_FM_PORT_PCD_SUPPORT_PRS_ONLY, /**< Use only Parser */
- e_FM_PORT_PCD_SUPPORT_PLCR_ONLY, /**< Use only Policer */
- e_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR, /**< Use Parser and Policer */
- e_FM_PORT_PCD_SUPPORT_PRS_AND_KG, /**< Use Parser and Keygen */
- e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC, /**< Use Parser, Keygen and Coarse Classification */
- e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC_AND_PLCR,
- /**< Use all PCD engines */
- e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR /**< Use Parser, Keygen and Policer */
+ e_FM_PORT_PCD_SUPPORT_NONE = 0 /**< BMI to BMI, PCD is not used */
+ , e_FM_PORT_PCD_SUPPORT_PRS_ONLY /**< Use only Parser */
+ , e_FM_PORT_PCD_SUPPORT_PLCR_ONLY /**< Use only Policer */
+ , e_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR /**< Use Parser and Policer */
+ , e_FM_PORT_PCD_SUPPORT_PRS_AND_KG /**< Use Parser and Keygen */
+ , e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC /**< Use Parser, Keygen and Coarse Classification */
+ , e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC_AND_PLCR
+ /**< Use all PCD engines */
+ , e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR /**< Use Parser, Keygen and Policer */
+ , e_FM_PORT_PCD_SUPPORT_PRS_AND_CC /**< Use Parser and Coarse Classification */
+ , e_FM_PORT_PCD_SUPPORT_PRS_AND_CC_AND_PLCR /**< Use Parser and Coarse Classification and Policer */
+ , e_FM_PORT_PCD_SUPPORT_CC_ONLY /**< Use only Coarse Classification */
#ifdef FM_CAPWAP_SUPPORT
- ,
- e_FM_PORT_PCD_SUPPORT_CC_ONLY, /**< Use only Coarse Classification */
- e_FM_PORT_PCD_SUPPORT_CC_AND_KG, /**< Use Coarse Classification,and Keygen */
- e_FM_PORT_PCD_SUPPORT_CC_AND_KG_AND_PLCR /**< Use Coarse Classification, Keygen and Policer */
+ , e_FM_PORT_PCD_SUPPORT_CC_AND_KG /**< Use Coarse Classification,and Keygen */
+ , e_FM_PORT_PCD_SUPPORT_CC_AND_KG_AND_PLCR /**< Use Coarse Classification, Keygen and Policer */
#endif /* FM_CAPWAP_SUPPORT */
} e_FmPortPcdSupport;
@@ -123,30 +127,39 @@ typedef enum e_FmPortExceptions {
*//***************************************************************************/
typedef uint32_t fmPortFrameErrSelect_t; /**< typedef for defining Frame Descriptor errors */
-#define FM_PORT_FRM_ERR_UNSUPPORTED_FORMAT 0x04000000 /**< Offline parsing only! Unsupported Format */
-#define FM_PORT_FRM_ERR_LENGTH 0x02000000 /**< Offline parsing only! Length Error */
-#define FM_PORT_FRM_ERR_DMA 0x01000000 /**< DMA Data error */
+#define FM_PORT_FRM_ERR_UNSUPPORTED_FORMAT FM_FD_ERR_UNSUPPORTED_FORMAT /**< Not for Rx-Port! Unsupported Format */
+#define FM_PORT_FRM_ERR_LENGTH FM_FD_ERR_LENGTH /**< Not for Rx-Port! Length Error */
+#define FM_PORT_FRM_ERR_DMA FM_FD_ERR_DMA /**< DMA Data error */
+#define FM_PORT_FRM_ERR_NON_FM FM_FD_RX_STATUS_ERR_NON_FM /**< non Frame-Manager error; probably come from SEC that
+ was chained to FM */
+
+#define FM_PORT_FRM_ERR_IPRE (FM_FD_ERR_IPR & ~FM_FD_IPR) /**< IPR error */
+#define FM_PORT_FRM_ERR_IPR_NCSP (FM_FD_ERR_IPR_NCSP & ~FM_FD_IPR) /**< IPR non-consistent-sp */
+
+#define FM_PORT_FRM_ERR_IPFE 0 /**< Obsolete; will be removed in the future */
+
#ifdef FM_CAPWAP_SUPPORT
-#define FM_PORT_FRM_ERR_NON_FM 0x00400000 /**< non Frame-Manager error; probably come from SEC that
- was chained to FM */
+#define FM_PORT_FRM_ERR_CRE FM_FD_ERR_CRE
+#define FM_PORT_FRM_ERR_CHE FM_FD_ERR_CHE
#endif /* FM_CAPWAP_SUPPORT */
-#define FM_PORT_FRM_ERR_PHYSICAL 0x00080000 /**< Rx FIFO overflow, FCS error, code error, running disparity
- error (SGMII and TBI modes), FIFO parity error. PHY
- Sequence error, PHY error control character detected. */
-#define FM_PORT_FRM_ERR_SIZE 0x00040000 /**< Frame too long OR Frame size exceeds max_length_frame */
-#define FM_PORT_FRM_ERR_CLS_DISCARD 0x00020000 /**< classification discard */
-#define FM_PORT_FRM_ERR_EXTRACTION 0x00008000 /**< Extract Out of Frame */
-#define FM_PORT_FRM_ERR_NO_SCHEME 0x00004000 /**< No Scheme Selected */
-#define FM_PORT_FRM_ERR_KEYSIZE_OVERFLOW 0x00002000 /**< Keysize Overflow */
-#define FM_PORT_FRM_ERR_COLOR_YELLOW 0x00000400 /**< Frame color is yellow */
-#define FM_PORT_FRM_ERR_COLOR_RED 0x00000800 /**< Frame color is red */
-#define FM_PORT_FRM_ERR_ILL_PLCR 0x00000200 /**< Illegal Policer Profile selected */
-#define FM_PORT_FRM_ERR_PLCR_FRAME_LEN 0x00000100 /**< Policer frame length error */
-#define FM_PORT_FRM_ERR_PRS_TIMEOUT 0x00000080 /**< Parser Time out Exceed */
-#define FM_PORT_FRM_ERR_PRS_ILL_INSTRUCT 0x00000040 /**< Invalid Soft Parser instruction */
-#define FM_PORT_FRM_ERR_PRS_HDR_ERR 0x00000020 /**< Header error was identified during parsing */
-#define FM_PORT_FRM_ERR_BLOCK_LIMIT_EXCEEDED 0x00000008 /**< Frame parsed beyind 256 first bytes */
-#define FM_PORT_FRM_ERR_PROCESS_TIMEOUT 0x00000001 /**< FPM Frame Processing Timeout Exceeded */
+
+#define FM_PORT_FRM_ERR_PHYSICAL FM_FD_ERR_PHYSICAL /**< Rx FIFO overflow, FCS error, code error, running disparity
+ error (SGMII and TBI modes), FIFO parity error. PHY
+ Sequence error, PHY error control character detected. */
+#define FM_PORT_FRM_ERR_SIZE FM_FD_ERR_SIZE /**< Frame too long OR Frame size exceeds max_length_frame */
+#define FM_PORT_FRM_ERR_CLS_DISCARD FM_FD_ERR_CLS_DISCARD /**< indicates a classifier "drop" operation */
+#define FM_PORT_FRM_ERR_EXTRACTION FM_FD_ERR_EXTRACTION /**< Extract Out of Frame */
+#define FM_PORT_FRM_ERR_NO_SCHEME FM_FD_ERR_NO_SCHEME /**< No Scheme Selected */
+#define FM_PORT_FRM_ERR_KEYSIZE_OVERFLOW FM_FD_ERR_KEYSIZE_OVERFLOW /**< Keysize Overflow */
+#define FM_PORT_FRM_ERR_COLOR_RED FM_FD_ERR_COLOR_RED /**< Frame color is red */
+#define FM_PORT_FRM_ERR_COLOR_YELLOW FM_FD_ERR_COLOR_YELLOW /**< Frame color is yellow */
+#define FM_PORT_FRM_ERR_ILL_PLCR FM_FD_ERR_ILL_PLCR /**< Illegal Policer Profile selected */
+#define FM_PORT_FRM_ERR_PLCR_FRAME_LEN FM_FD_ERR_PLCR_FRAME_LEN /**< Policer frame length error */
+#define FM_PORT_FRM_ERR_PRS_TIMEOUT FM_FD_ERR_PRS_TIMEOUT /**< Parser Time out Exceed */
+#define FM_PORT_FRM_ERR_PRS_ILL_INSTRUCT FM_FD_ERR_PRS_ILL_INSTRUCT /**< Invalid Soft Parser instruction */
+#define FM_PORT_FRM_ERR_PRS_HDR_ERR FM_FD_ERR_PRS_HDR_ERR /**< Header error was identified during parsing */
+#define FM_PORT_FRM_ERR_BLOCK_LIMIT_EXCEEDED FM_FD_ERR_BLOCK_LIMIT_EXCEEDED /**< Frame parsed beyind 256 first bytes */
+#define FM_PORT_FRM_ERR_PROCESS_TIMEOUT 0x00000001 /**< FPM Frame Processing Timeout Exceeded */
/* @} */
@@ -210,52 +223,30 @@ typedef void (t_FmPortImTxConfCallback) (t_Handle h_App,
t_Handle h_BufContext);
/**************************************************************************//**
- @Description A structure of information about each of the external
- buffer pools used by the port,
-*//***************************************************************************/
-typedef struct t_FmPortExtPoolParams {
- uint8_t id; /**< External buffer pool id */
- uint16_t size; /**< External buffer pool buffer size */
-} t_FmPortExtPoolParams;
-
-/**************************************************************************//**
- @Description A structure for informing the driver about the external
- buffer pools allocated in the BM and used by this port.
-*//***************************************************************************/
-typedef struct t_FmPortExtPools {
- uint8_t numOfPoolsUsed; /**< Number of pools use by this port */
- t_FmPortExtPoolParams extBufPool[FM_PORT_MAX_NUM_OF_EXT_POOLS];
- /**< Parameters for each port */
-} t_FmPortExtPools;
-
-/**************************************************************************//**
- @Description structure for additional Rx port parameters
+ @Description A structure for additional Rx port parameters
*//***************************************************************************/
typedef struct t_FmPortRxParams {
uint32_t errFqid; /**< Error Queue Id. */
uint32_t dfltFqid; /**< Default Queue Id. */
uint16_t liodnOffset; /**< Port's LIODN offset. */
- t_FmPortExtPools extBufPools; /**< Which external buffer pools are used
+ t_FmExtPools extBufPools; /**< Which external buffer pools are used
(up to FM_PORT_MAX_NUM_OF_EXT_POOLS), and their sizes. */
} t_FmPortRxParams;
/**************************************************************************//**
- @Description structure for additional non-Rx port parameters
+ @Description A structure for additional non-Rx port parameters
*//***************************************************************************/
typedef struct t_FmPortNonRxParams {
uint32_t errFqid; /**< Error Queue Id. */
- uint32_t dfltFqid; /**< For Tx and HC - Default Confirmation queue,
+ uint32_t dfltFqid; /**< For Tx - Default Confirmation queue,
0 means no Tx confirmation for processed
- frames. For OP - default Rx queue. */
+ frames. For OP port - default Rx queue. */
uint32_t qmChannel; /**< QM-channel dedicated to this port; will be used
by the FM for dequeue. */
-#ifdef FM_OP_PARTITION_ERRATA_FMANx8
- uint16_t opLiodnOffset; /**< For Offline Parsing ports only. Port's LIODN offset. */
-#endif /* FM_OP_PARTITION_ERRATA_FMANx8 */
} t_FmPortNonRxParams;
/**************************************************************************//**
- @Description structure for additional Rx port parameters
+ @Description A structure for additional Rx port parameters
*//***************************************************************************/
typedef struct t_FmPortImRxTxParams {
t_Handle h_FmMuram; /**< A handle of the FM-MURAM partition */
@@ -268,7 +259,7 @@ typedef struct t_FmPortImRxTxParams {
} t_FmPortImRxTxParams;
/**************************************************************************//**
- @Description Union for additional parameters depending on port type
+ @Description A union for additional parameters depending on port type
*//***************************************************************************/
typedef union u_FmPortSpecificParams {
t_FmPortImRxTxParams imRxTxParams; /**< Rx/Tx Independent-Mode port parameter structure */
@@ -277,13 +268,17 @@ typedef union u_FmPortSpecificParams {
} u_FmPortSpecificParams;
/**************************************************************************//**
- @Description structure representing FM initialization parameters
+ @Description A structure representing FM initialization parameters
*//***************************************************************************/
typedef struct t_FmPortParams {
uintptr_t baseAddr; /**< Virtual Address of memory mapped FM Port registers.*/
t_Handle h_Fm; /**< A handle to the FM object this port related to */
e_FmPortType portType; /**< Port type */
- uint8_t portId; /**< Port Id - relative to type */
+ uint8_t portId; /**< Port Id - relative to type;
+ NOTE: When configuring Offline Parsing port for
+ FMANv3 devices (DPAA_VERSION 11 and higher),
+ it is highly recommended NOT to use portId=0 due to lack
+ of HW resources on portId=0. */
bool independentModeEnable;
/**< This port is Independent-Mode - Used for Rx/Tx ports only! */
uint16_t liodnBase; /**< Irrelevant for P4080 rev 1. LIODN base for this port, to be
@@ -291,7 +286,7 @@ typedef struct t_FmPortParams {
u_FmPortSpecificParams specificParams; /**< Additional parameters depending on port
type. */
- t_FmPortExceptionCallback *f_Exception; /**< Callback routine to be called of PCD exception */
+ t_FmPortExceptionCallback *f_Exception; /**< Relevant for IM only Callback routine to be called on BUSY exception */
t_Handle h_App; /**< A handle to an application layer object; This handle will
be passed by the driver upon calling the above callbacks */
} t_FmPortParams;
@@ -300,7 +295,7 @@ typedef struct t_FmPortParams {
/**************************************************************************//**
@Function FM_PORT_Config
- @Description Creates descriptor for the FM PORT module.
+ @Description Creates a descriptor for the FM PORT module.
The routine returns a handle (descriptor) to the FM PORT object.
This descriptor must be passed as first parameter to all other
@@ -318,7 +313,8 @@ t_Handle FM_PORT_Config(t_FmPortParams *p_FmPortParams);
/**************************************************************************//**
@Function FM_PORT_Init
- @Description Initializes the FM PORT module
+ @Description Initializes the FM PORT module by defining the software structure
+ and configuring the hardware registers.
@Param[in] h_FmPort - FM PORT module descriptor
@@ -360,7 +356,6 @@ typedef enum e_FmPortDeqType {
and override Intra-Class Scheduling */
} e_FmPortDeqType;
-#ifdef FM_QMI_DEQ_OPTIONS_SUPPORT
/**************************************************************************//**
@Description enum for defining QM frame dequeue
*//***************************************************************************/
@@ -373,26 +368,6 @@ typedef enum e_FmPortDeqPrefetchOption {
no dedicated portId tnums are waiting. */
} e_FmPortDeqPrefetchOption;
-#endif /* FM_QMI_DEQ_OPTIONS_SUPPORT */
-
-/**************************************************************************//**
- @Description enum for defining port DMA swap mode
-*//***************************************************************************/
-typedef enum e_FmPortDmaSwap {
- e_FM_PORT_DMA_NO_SWP, /**< No swap, transfer data as is.*/
- e_FM_PORT_DMA_SWP_PPC_LE, /**< The transferred data should be swapped
- in PowerPc Little Endian mode. */
- e_FM_PORT_DMA_SWP_BE /**< The transferred data should be swapped
- in Big Endian mode */
-} e_FmPortDmaSwap;
-
-/**************************************************************************//**
- @Description enum for defining port DMA cache attributes
-*//***************************************************************************/
-typedef enum e_FmPortDmaCache {
- e_FM_PORT_DMA_NO_STASH = 0, /**< Cacheable, no Allocate (No Stashing) */
- e_FM_PORT_DMA_STASH = 1 /**< Cacheable and Allocate (Stashing on) */
-} e_FmPortDmaCache;
/**************************************************************************//**
@Description enum for defining port default color
@@ -405,7 +380,7 @@ typedef enum e_FmPortColor {
} e_FmPortColor;
/**************************************************************************//**
- @Description struct for defining Dual Tx rate limiting scale
+ @Description A structure for defining Dual Tx rate limiting scale
*//***************************************************************************/
typedef enum e_FmPortDualRateLimiterScaleDown {
e_FM_PORT_DUAL_RATE_LIMITER_NONE = 0, /**< Use only single rate limiter */
@@ -416,7 +391,7 @@ typedef enum e_FmPortDualRateLimiterScaleDown {
/**************************************************************************//**
- @Description struct for defining FM port resources
+ @Description A structure for defining FM port resources
*//***************************************************************************/
typedef struct t_FmPortRsrc {
uint32_t num; /**< Committed required resource */
@@ -424,50 +399,32 @@ typedef struct t_FmPortRsrc {
} t_FmPortRsrc;
/**************************************************************************//**
- @Description struct for defining pool depletion criteria
-*//***************************************************************************/
-typedef struct t_FmPortBufPoolDepletion {
- bool numberOfPoolsModeEnable; /**< select mode in which pause frames will be sent after
- a number of pools are depleted */
- uint8_t numOfPools; /**< the minimum number of depleted pools that will
- invoke pause frames transmission. */
- bool poolsToConsider[BM_MAX_NUM_OF_POOLS];
- /**< For each pool, TRUE if it should be considered for
- depletion (Note - this pool must be used by this port!) */
- bool singlePoolModeEnable; /**< select mode in which pause frames will be sent after
- a single of pools are depleted */
- bool poolsToConsiderForSingleMode[BM_MAX_NUM_OF_POOLS];
- /**< For each pool, TRUE if it should be considered for
- depletion (Note - this pool must be used by this port!) */
-} t_FmPortBufPoolDepletion;
-
-/**************************************************************************//**
- @Description struct for defining observed pool depletion
+ @Description A structure for defining observed pool depletion
*//***************************************************************************/
typedef struct t_FmPortObservedBufPoolDepletion {
- t_FmPortBufPoolDepletion poolDepletionParams;/**< parameters to define pool depletion */
- t_FmPortExtPools poolsParams; /**< Which external buffer pools are observed
- (up to FM_PORT_MAX_NUM_OF_OBSERVED_EXT_POOLS),
- and their sizes. */
+ t_FmBufPoolDepletion poolDepletionParams;/**< parameters to define pool depletion */
+ t_FmExtPools poolsParams; /**< Which external buffer pools are observed
+ (up to FM_PORT_MAX_NUM_OF_OBSERVED_EXT_POOLS),
+ and their sizes. */
} t_FmPortObservedBufPoolDepletion;
/**************************************************************************//**
- @Description struct for defining Tx rate limiting
+ @Description A structure for defining Tx rate limiting
*//***************************************************************************/
typedef struct t_FmPortRateLimit {
- uint16_t maxBurstSize; /**< in kBytes for Tx ports, in frames
- for offline parsing ports. (note that
+ uint16_t maxBurstSize; /**< in KBytes for Tx ports, in frames
+ for OP ports. (note that
for early chips burst size is
rounded up to a multiply of 1000 frames).*/
uint32_t rateLimit; /**< in Kb/sec for Tx ports, in frame/sec for
- offline parsing ports. Rate limit refers to
+ OP ports. Rate limit refers to
data rate (rather than line rate). */
- e_FmPortDualRateLimiterScaleDown rateLimitDivider; /**< For offline parsing ports only. Not-valid
+ e_FmPortDualRateLimiterScaleDown rateLimitDivider; /**< For OP ports only. Not-valid
for some earlier chip revisions */
} t_FmPortRateLimit;
/**************************************************************************//**
- @Description struct for defining define the parameters of
+ @Description A structure for defining the parameters of
the Rx port performance counters
*//***************************************************************************/
typedef struct t_FmPortPerformanceCnt {
@@ -478,219 +435,183 @@ typedef struct t_FmPortPerformanceCnt {
uint32_t fifoCompVal; /**< Fifo compare value (in bytes) */
} t_FmPortPerformanceCnt;
-/**************************************************************************//**
- @Description struct for defining buffer content.
-*//***************************************************************************/
-typedef struct t_FmPortBufferPrefixContent {
- uint16_t privDataSize; /**< Number of bytes to be left at the beginning
- of the external buffer */
- bool passPrsResult; /**< TRUE to pass the parse result to/from the FM */
- bool passTimeStamp; /**< TRUE to pass the timeStamp to/from the FM */
- bool passHashResult; /**< TRUE to pass the KG hash result to/from the FM */
- bool passAllOtherPCDInfo;/**< Add all other Internal-Context information:
- AD, hash-result, key, etc. */
- uint16_t dataAlign; /**< 0 to use driver's default alignment, other value
- for selecting a data alignment (must be a
- power of 2) */
-#ifdef DEBUG
- bool passDebugInfo; /**< Debug-information */
-#endif /* DEBUG */
-#ifdef FM_CAPWAP_SUPPORT
- uint8_t manipExtraSpace; /**< Maximum extra size needed (insertion-size minus removal-size) */
-#endif /* FM_CAPWAP_SUPPORT */
-} t_FmPortBufferPrefixContent;
/**************************************************************************//**
- @Description struct for defining backup Bm Pools.
+ @Description A structure for defining the sizes of the Deep Sleep
+ the Auto Response tables
*//***************************************************************************/
-typedef struct t_FmPortBackupBmPools {
- uint8_t numOfBackupPools; /**< Number of BM backup pools -
- must be smaller than the total number of
- pools defined for the specified port.*/
- uint8_t poolIds[FM_PORT_MAX_NUM_OF_EXT_POOLS];
- /**< numOfBackupPools pool id's, specifying which
- pools should be used only as backup. Pool
- id's specified here must be a subset of the
- pools used by the specified port.*/
-} t_FmPortBackupBmPools;
+typedef struct t_FmPortDsarTablesSizes
+{
+ uint16_t maxNumOfArpEntries;
+ uint16_t maxNumOfEchoIpv4Entries;
+ uint16_t maxNumOfNdpEntries;
+ uint16_t maxNumOfEchoIpv6Entries;
+ uint16_t maxNumOfSnmpIPV4Entries;
+ uint16_t maxNumOfSnmpIPV6Entries;
+ uint16_t maxNumOfSnmpOidEntries;
+ uint16_t maxNumOfSnmpOidChar; /* total amount of character needed for the snmp table */
+
+ uint16_t maxNumOfIpProtFiltering;
+ uint16_t maxNumOfTcpPortFiltering;
+ uint16_t maxNumOfUdpPortFiltering;
+} t_FmPortDsarTablesSizes;
/**************************************************************************//**
- @Function FM_PORT_ConfigDeqHighPriority
+ @Function FM_PORT_ConfigDsarSupport
- @Description Calling this routine changes the dequeue priority in the
- internal driver data base from its default configuration
- [TRUE]
+ @Description This function will allocate the amount of MURAM needed for
+ this max number of entries for Deep Sleep Auto Response.
+ it will calculate all needed MURAM for autoresponse including
+ necesary common stuff.
- May be used for Non-Rx ports only
@Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] highPri TRUE to select high priority, FALSE for normal operation.
+ @Param[in] params A pointer to a structure containing the maximum
+ sizes of the auto response tables
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_ConfigDeqHighPriority(t_Handle h_FmPort, bool highPri);
+t_Error FM_PORT_ConfigDsarSupport(t_Handle h_FmPortRx, t_FmPortDsarTablesSizes *params);
/**************************************************************************//**
- @Function FM_PORT_ConfigDeqType
+ @Function FM_PORT_ConfigNumOfOpenDmas
- @Description Calling this routine changes the dequeue type parameter in the
+ @Description Calling this routine changes the max number of open DMA's
+ available for this port. It changes this parameter in the
internal driver data base from its default configuration
- [e_FM_PORT_DEQ_TYPE1].
-
- May be used for Non-Rx ports only
+ [OP: 1]
+ [1G-RX, 1G-TX: 1 (+1)]
+ [10G-RX, 10G-TX: 8 (+8)]
@Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] deqType According to QM definition.
+ @Param[in] p_OpenDmas A pointer to a structure of parameters defining
+ the open DMA allocation.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_ConfigDeqType(t_Handle h_FmPort, e_FmPortDeqType deqType);
+t_Error FM_PORT_ConfigNumOfOpenDmas(t_Handle h_FmPort, t_FmPortRsrc *p_OpenDmas);
-#ifdef FM_QMI_DEQ_OPTIONS_SUPPORT
/**************************************************************************//**
- @Function FM_PORT_ConfigDeqPrefetchOption
+ @Function FM_PORT_ConfigNumOfTasks
- @Description Calling this routine changes the dequeue prefetch option parameter in the
+ @Description Calling this routine changes the max number of tasks
+ available for this port. It changes this parameter in the
internal driver data base from its default configuration
- [e_FM_PORT_DEQ_FULL_PREFETCH]
- Note: Available for some chips only
-
- May be used for Non-Rx ports only
-
- @Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] deqPrefetchOption New option
-
- @Return E_OK on success; Error code otherwise.
-
- @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
-*//***************************************************************************/
-t_Error FM_PORT_ConfigDeqPrefetchOption(t_Handle h_FmPort, e_FmPortDeqPrefetchOption deqPrefetchOption);
-#endif /* FM_QMI_DEQ_OPTIONS_SUPPORT */
-
-/**************************************************************************//**
- @Function FM_PORT_ConfigDeqByteCnt
-
- @Description Calling this routine changes the dequeue byte count parameter in
- the internal driver data base from its default configuration [2000].
-
- May be used for Non-Rx ports only
+ [OP: 1]
+ [1G-RX, 1G-TX: 3 (+2)]
+ [10G-RX, 10G-TX: 16 (+8)]
@Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] deqByteCnt New byte count
+ @Param[in] p_NumOfTasks A pointer to a structure of parameters defining
+ the tasks allocation.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_ConfigDeqByteCnt(t_Handle h_FmPort, uint16_t deqByteCnt);
+t_Error FM_PORT_ConfigNumOfTasks(t_Handle h_FmPort, t_FmPortRsrc *p_NumOfTasks);
/**************************************************************************//**
- @Function FM_PORT_ConfigTxFifoMinFillLevel
+ @Function FM_PORT_ConfigSizeOfFifo
- @Description Calling this routine changes the fifo minimum
- fill level parameter in the internal driver data base
- from its default configuration [0]
+ @Description Calling this routine changes the max FIFO size configured for this port.
- May be used for Tx ports only
+ This function changes the internal driver data base from its
+ default configuration. Please refer to the driver's User Guide for
+ information on default FIFO sizes in the various devices.
+ [OP: 2KB]
+ [1G-RX, 1G-TX: 11KB]
+ [10G-RX, 10G-TX: 12KB]
@Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] minFillLevel New value
+ @Param[in] p_SizeOfFifo A pointer to a structure of parameters defining
+ the FIFO allocation.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_ConfigTxFifoMinFillLevel(t_Handle h_FmPort, uint32_t minFillLevel);
+t_Error FM_PORT_ConfigSizeOfFifo(t_Handle h_FmPort, t_FmPortRsrc *p_SizeOfFifo);
/**************************************************************************//**
- @Function FM_PORT_ConfigTxFifoDeqPipelineDepth
-
- @Description Calling this routine changes the fifo dequeue
- pipeline depth parameter in the internal driver data base
+ @Function FM_PORT_ConfigDeqHighPriority
- from its default configuration: 1G ports: [2],
- 10G port: [8]
+ @Description Calling this routine changes the dequeue priority in the
+ internal driver data base from its default configuration
+ 1G: [DEFAULT_PORT_deqHighPriority_1G]
+ 10G: [DEFAULT_PORT_deqHighPriority_10G]
- May be used for Tx ports only
+ May be used for Non-Rx ports only
- @Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] deqPipelineDepth New value
+ @Param[in] h_FmPort A handle to a FM Port module.
+ @Param[in] highPri TRUE to select high priority, FALSE for normal operation.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_ConfigTxFifoDeqPipelineDepth(t_Handle h_FmPort, uint8_t deqPipelineDepth);
+t_Error FM_PORT_ConfigDeqHighPriority(t_Handle h_FmPort, bool highPri);
/**************************************************************************//**
- @Function FM_PORT_ConfigTxFifoLowComfLevel
+ @Function FM_PORT_ConfigDeqType
- @Description Calling this routine changes the fifo low comfort level
- parameter in internal driver data base
- from its default configuration [5]
+ @Description Calling this routine changes the dequeue type parameter in the
+ internal driver data base from its default configuration
+ [DEFAULT_PORT_deqType].
- May be used for Tx ports only
+ May be used for Non-Rx ports only
- @Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] fifoLowComfLevel New value
+ @Param[in] h_FmPort A handle to a FM Port module.
+ @Param[in] deqType According to QM definition.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_ConfigTxFifoLowComfLevel(t_Handle h_FmPort, uint32_t fifoLowComfLevel);
+t_Error FM_PORT_ConfigDeqType(t_Handle h_FmPort, e_FmPortDeqType deqType);
/**************************************************************************//**
- @Function FM_PORT_ConfigRxFifoThreshold
-
- @Description Calling this routine changes the threshold of the FIFO
- fill level parameter in the internal driver data base
- from its default configuration [BMI_MAX_FIFO_SIZE]
+ @Function FM_PORT_ConfigDeqPrefetchOption
- If the total number of buffers which are
- currently in use and associated with the
- specific RX port exceed this threshold, the
- BMI will signal the MAC to send a pause frame
- over the link.
+ @Description Calling this routine changes the dequeue prefetch option parameter in the
+ internal driver data base from its default configuration
+ [DEFAULT_PORT_deqPrefetchOption]
+ Note: Available for some chips only
- May be used for Rx ports only
+ May be used for Non-Rx ports only
@Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] fifoThreshold New value
+ @Param[in] deqPrefetchOption New option
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_ConfigRxFifoThreshold(t_Handle h_FmPort, uint32_t fifoThreshold);
+t_Error FM_PORT_ConfigDeqPrefetchOption(t_Handle h_FmPort, e_FmPortDeqPrefetchOption deqPrefetchOption);
/**************************************************************************//**
- @Function FM_PORT_ConfigRxFifoPriElevationLevel
-
- @Description Calling this routine changes the priority elevation level
- parameter in the internal driver data base from its default
- configuration [BMI_MAX_FIFO_SIZE]
+ @Function FM_PORT_ConfigDeqByteCnt
- If the total number of buffers which are currently in use and
- associated with the specific RX port exceed the amount specified
- in priElevationLevel, BMI will signal the main FM's DMA to
- elevate the FM priority on the system bus.
+ @Description Calling this routine changes the dequeue byte count parameter in
+ the internal driver data base from its default configuration
+ 1G:[DEFAULT_PORT_deqByteCnt_1G].
+ 10G:[DEFAULT_PORT_deqByteCnt_10G].
- May be used for Rx ports only
+ May be used for Non-Rx ports only
- @Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] priElevationLevel New value
+ @Param[in] h_FmPort A handle to a FM Port module.
+ @Param[in] deqByteCnt New byte count
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_ConfigRxFifoPriElevationLevel(t_Handle h_FmPort, uint32_t priElevationLevel);
+t_Error FM_PORT_ConfigDeqByteCnt(t_Handle h_FmPort, uint16_t deqByteCnt);
/**************************************************************************//**
@Function FM_PORT_ConfigBufferPrefixContent
@@ -705,14 +626,14 @@ t_Error FM_PORT_ConfigRxFifoPriElevationLevel(t_Handle h_FmPort, uint32_t priEle
application buffer, and to offset.
Calling this routine changes the buffer margins definitions
in the internal driver data base from its default
- configuration: Data size: [0]
- Pass Parser result: [FALSE].
- Pass timestamp: [FALSE].
+ configuration: Data size: [DEFAULT_PORT_bufferPrefixContent_privDataSize]
+ Pass Parser result: [DEFAULT_PORT_bufferPrefixContent_passPrsResult].
+ Pass timestamp: [DEFAULT_PORT_bufferPrefixContent_passTimeStamp].
May be used for all ports
@Param[in] h_FmPort A handle to a FM Port module.
- @Param[in,out] p_FmPortBufferPrefixContent A structure of parameters describing the
+ @Param[in,out] p_FmBufferPrefixContent A structure of parameters describing the
structure of the buffer.
Out parameter: Start margin - offset
of data from start of external buffer.
@@ -721,20 +642,20 @@ t_Error FM_PORT_ConfigRxFifoPriElevationLevel(t_Handle h_FmPort, uint32_t priEle
@Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_ConfigBufferPrefixContent(t_Handle h_FmPort, t_FmPortBufferPrefixContent *p_FmPortBufferPrefixContent);
-
+t_Error FM_PORT_ConfigBufferPrefixContent(t_Handle h_FmPort,
+ t_FmBufferPrefixContent *p_FmBufferPrefixContent);
/**************************************************************************//**
@Function FM_PORT_ConfigCheksumLastBytesIgnore
@Description Calling this routine changes the number of checksum bytes to ignore
parameter in the internal driver data base from its default configuration
- [0]
+ [DEFAULT_PORT_cheksumLastBytesIgnore]
May be used by Tx & Rx ports only
@Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] cheksumLastBytesIgnore New value
+ @Param[in] cheksumLastBytesIgnore New value
@Return E_OK on success; Error code otherwise.
@@ -747,7 +668,7 @@ t_Error FM_PORT_ConfigCheksumLastBytesIgnore(t_Handle h_FmPort, uint8_t cheksumL
@Description Calling this routine changes the number of bytes to cut from a
frame's end parameter in the internal driver data base
- from its default configuration [4]
+ from its default configuration [DEFAULT_PORT_cutBytesFromEnd]
Note that if the result of (frame length before chop - cutBytesFromEnd) is
less than 14 bytes, the chop operation is not executed.
@@ -778,7 +699,7 @@ t_Error FM_PORT_ConfigCutBytesFromEnd(t_Handle h_FmPort, uint8_t cutBytesFromEnd
@Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_ConfigPoolDepletion(t_Handle h_FmPort, t_FmPortBufPoolDepletion *p_BufPoolDepletion);
+t_Error FM_PORT_ConfigPoolDepletion(t_Handle h_FmPort, t_FmBufPoolDepletion *p_BufPoolDepletion);
/**************************************************************************//**
@Function FM_PORT_ConfigObservedPoolDepletion
@@ -790,39 +711,38 @@ t_Error FM_PORT_ConfigPoolDepletion(t_Handle h_FmPort, t_FmPortBufPoolDepletion
Note: Available for some chips only
- May be used for Offline Parsing ports only
+ May be used for OP ports only
@Param[in] h_FmPort A handle to a FM Port module.
@Param[in] p_FmPortObservedBufPoolDepletion A structure of parameters for pool depletion.
-
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_ConfigObservedPoolDepletion(t_Handle h_FmPort, t_FmPortObservedBufPoolDepletion *p_FmPortObservedBufPoolDepletion);
+t_Error FM_PORT_ConfigObservedPoolDepletion(t_Handle h_FmPort,
+ t_FmPortObservedBufPoolDepletion *p_FmPortObservedBufPoolDepletion);
/**************************************************************************//**
@Function FM_PORT_ConfigExtBufPools
- @Description This routine should be called for offline parsing ports
+ @Description This routine should be called for OP ports
that internally use BM buffer pools. In such cases, e.g. for fragmentation and
re-assembly, the FM needs new BM buffers. By calling this routine the user
specifies the BM buffer pools that should be used.
Note: Available for some chips only
- May be used for Offline Parsing ports only
+ May be used for OP ports only
@Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] p_FmPortExtPools A structure of parameters for the external pools.
-
+ @Param[in] p_FmExtPools A structure of parameters for the external pools.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_ConfigExtBufPools(t_Handle h_FmPort, t_FmPortExtPools *p_FmPortExtPools);
+t_Error FM_PORT_ConfigExtBufPools(t_Handle h_FmPort, t_FmExtPools *p_FmExtPools);
/**************************************************************************//**
@Function FM_PORT_ConfigBackupPools
@@ -842,19 +762,19 @@ t_Error FM_PORT_ConfigExtBufPools(t_Handle h_FmPort, t_FmPortExtPools *p_FmPortE
@Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_ConfigBackupPools(t_Handle h_FmPort, t_FmPortBackupBmPools *p_FmPortBackupBmPools);
+t_Error FM_PORT_ConfigBackupPools(t_Handle h_FmPort, t_FmBackupBmPools *p_FmPortBackupBmPools);
/**************************************************************************//**
@Function FM_PORT_ConfigFrmDiscardOverride
@Description Calling this routine changes the error frames destination parameter
in the internal driver data base from its default configuration:
- override = [FALSE]
+ override = [DEFAULT_PORT_frmDiscardOverride]
- May be used for Rx and offline parsing ports only
+ May be used for Rx and OP ports only
@Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] override TRUE to override dicarding of error frames and
+ @Param[in] override TRUE to override discarding of error frames and
enqueueing them to error queue.
@Return E_OK on success; Error code otherwise.
@@ -868,14 +788,13 @@ t_Error FM_PORT_ConfigFrmDiscardOverride(t_Handle h_FmPort, bool override);
@Description Calling this routine changes the behaviour on error parameter
in the internal driver data base from its default configuration:
- [FM_PORT_FRM_ERR_CLS_DISCARD].
+ [DEFAULT_PORT_errorsToDiscard].
If a requested error was previously defined as "ErrorsToEnqueue" it's
definition will change and the frame will be discarded.
Errors that were not defined either as "ErrorsToEnqueue" nor as
"ErrorsToDiscard", will be forwarded to CPU.
-
- May be used for Rx and offline parsing ports only
+ May be used for Rx and OP ports only
@Param[in] h_FmPort A handle to a FM Port module.
@Param[in] errs A list of errors to discard
@@ -891,7 +810,7 @@ t_Error FM_PORT_ConfigErrorsToDiscard(t_Handle h_FmPort, fmPortFrameErrSelect_t
@Description Calling this routine changes the DMA swap data aparameter
in the internal driver data base from its default
- configuration [e_FM_PORT_DMA_NO_SWP]
+ configuration [DEFAULT_PORT_dmaSwapData]
May be used for all port types
@@ -902,14 +821,14 @@ t_Error FM_PORT_ConfigErrorsToDiscard(t_Handle h_FmPort, fmPortFrameErrSelect_t
@Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_ConfigDmaSwapData(t_Handle h_FmPort, e_FmPortDmaSwap swapData);
+t_Error FM_PORT_ConfigDmaSwapData(t_Handle h_FmPort, e_FmDmaSwapOption swapData);
/**************************************************************************//**
@Function FM_PORT_ConfigDmaIcCacheAttr
@Description Calling this routine changes the internal context cache
attribute parameter in the internal driver data base
- from its default configuration [e_FM_PORT_DMA_NO_STASH]
+ from its default configuration [DEFAULT_PORT_dmaIntContextCacheAttr]
May be used for all port types
@@ -920,14 +839,14 @@ t_Error FM_PORT_ConfigDmaSwapData(t_Handle h_FmPort, e_FmPortDmaSwap swapData);
@Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_ConfigDmaIcCacheAttr(t_Handle h_FmPort, e_FmPortDmaCache intContextCacheAttr);
+t_Error FM_PORT_ConfigDmaIcCacheAttr(t_Handle h_FmPort, e_FmDmaCacheOption intContextCacheAttr);
/**************************************************************************//**
@Function FM_PORT_ConfigDmaHdrAttr
@Description Calling this routine changes the header cache
attribute parameter in the internal driver data base
- from its default configuration [e_FM_PORT_DMA_NO_STASH]
+ from its default configuration [DEFAULT_PORT_dmaHeaderCacheAttr]
May be used for all port types
@@ -938,14 +857,14 @@ t_Error FM_PORT_ConfigDmaIcCacheAttr(t_Handle h_FmPort, e_FmPortDmaCache intCont
@Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_ConfigDmaHdrAttr(t_Handle h_FmPort, e_FmPortDmaCache headerCacheAttr);
+t_Error FM_PORT_ConfigDmaHdrAttr(t_Handle h_FmPort, e_FmDmaCacheOption headerCacheAttr);
/**************************************************************************//**
@Function FM_PORT_ConfigDmaScatterGatherAttr
@Description Calling this routine changes the scatter gather cache
attribute parameter in the internal driver data base
- from its default configuration [e_FM_PORT_DMA_NO_STASH]
+ from its default configuration [DEFAULT_PORT_dmaScatterGatherCacheAttr]
May be used for all port types
@@ -956,16 +875,23 @@ t_Error FM_PORT_ConfigDmaHdrAttr(t_Handle h_FmPort, e_FmPortDmaCache headerCache
@Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_ConfigDmaScatterGatherAttr(t_Handle h_FmPort, e_FmPortDmaCache scatterGatherCacheAttr);
+t_Error FM_PORT_ConfigDmaScatterGatherAttr(t_Handle h_FmPort, e_FmDmaCacheOption scatterGatherCacheAttr);
/**************************************************************************//**
@Function FM_PORT_ConfigDmaWriteOptimize
@Description Calling this routine changes the write optimization
parameter in the internal driver data base
- from its default configuration: optimize = [TRUE]
+ from its default configuration: By default optimize = [DEFAULT_PORT_dmaWriteOptimize].
+ Note:
+
+ 1. For head optimization, data alignment must be >= 16 (supported by default).
- May be used for non-Tx port types
+ 3. For tail optimization, note that the optimization is performed by extending the write transaction
+ of the frame payload at the tail as needed to achieve optimal bus transfers, so that the last write
+ is extended to be on 16/64 bytes aligned block (chip dependent).
+
+ Relevant for non-Tx port types
@Param[in] h_FmPort A handle to a FM Port module.
@Param[in] optimize TRUE to enable optimization, FALSE for normal operation
@@ -977,11 +903,27 @@ t_Error FM_PORT_ConfigDmaScatterGatherAttr(t_Handle h_FmPort, e_FmPortDmaCache s
t_Error FM_PORT_ConfigDmaWriteOptimize(t_Handle h_FmPort, bool optimize);
/**************************************************************************//**
+ @Function FM_PORT_ConfigNoScatherGather
+
+ @Description Calling this routine changes the noScatherGather parameter in internal driver data base
+ from its default configuration.
+
+ @Param[in] h_FmPort A handle to a FM Port module.
+ @Param[in] noScatherGather (TRUE - frame is discarded if can not be stored in single buffer,
+ FALSE - frame can be stored in scatter gather (S/G) format).
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
+*//***************************************************************************/
+t_Error FM_PORT_ConfigNoScatherGather(t_Handle h_FmPort, bool noScatherGather);
+
+/**************************************************************************//**
@Function FM_PORT_ConfigDfltColor
@Description Calling this routine changes the internal default color parameter
in the internal driver data base
- from its default configuration [e_FM_PORT_COLOR_GREEN]
+ from its default configuration [DEFAULT_PORT_color]
May be used for all port types
@@ -999,7 +941,7 @@ t_Error FM_PORT_ConfigDfltColor(t_Handle h_FmPort, e_FmPortColor color);
@Description Calling this routine changes the synchronization attribute parameter
in the internal driver data base from its default configuration:
- syncReq = [TRUE]
+ syncReq = [DEFAULT_PORT_syncReq]
May be used for all port types
@@ -1015,16 +957,16 @@ t_Error FM_PORT_ConfigSyncReq(t_Handle h_FmPort, bool syncReq);
/**************************************************************************//**
@Function FM_PORT_ConfigForwardReuseIntContext
- @Description This routine is relevant for Rx ports that are routed to offline
- parsing. It changes the internal context reuse option
- in the internal driver data base from its default configuration:
- reuse = [FALSE]
+ @Description This routine is relevant for Rx ports that are routed to OP port.
+ It changes the internal context reuse option in the internal
+ driver data base from its default configuration:
+ reuse = [DEFAULT_PORT_forwardIntContextReuse]
May be used for Rx ports only
@Param[in] h_FmPort A handle to a FM Port module.
@Param[in] reuse TRUE to reuse internal context on frames
- forwarded to offline parsing.
+ forwarded to OP port.
@Return E_OK on success; Error code otherwise.
@@ -1084,7 +1026,7 @@ t_Error FM_PORT_ConfigIMMaxRxBufLength(t_Handle h_FmPort, uint16_t newVal);
@Function FM_PORT_ConfigIMRxBdRingLength
@Description Changes the receive BD ring length from its default
- configuration:[128]
+ configuration:[DEFAULT_PORT_rxBdRingLength]
@Param[in] h_FmPort A handle to a FM Port module.
@Param[in] newVal The desired BD ring length.
@@ -1100,7 +1042,7 @@ t_Error FM_PORT_ConfigIMRxBdRingLength(t_Handle h_FmPort, uint16_t newVal);
@Function FM_PORT_ConfigIMTxBdRingLength
@Description Changes the transmit BD ring length from its default
- configuration:[16]
+ configuration:[DEFAULT_PORT_txBdRingLength]
@Param[in] h_FmPort A handle to a FM Port module.
@Param[in] newVal The desired BD ring length.
@@ -1119,7 +1061,7 @@ t_Error FM_PORT_ConfigIMTxBdRingLength(t_Handle h_FmPort, uint16_t newVal);
data structures (e.g. BD rings).
Calling this routine changes the internal driver data base
from its default configuration
- [0 , MEMORY_ATTR_CACHEABLE].
+ [DEFAULT_PORT_ImfwExtStructsMemId, DEFAULT_PORT_ImfwExtStructsMemAttr].
@Param[in] h_FmPort A handle to a FM Port module.
@Param[in] memId Memory partition ID.
@@ -1145,6 +1087,173 @@ t_Error FM_PORT_ConfigIMFmanCtrlExternalStructsMemory(t_Handle h_FmPort,
*//***************************************************************************/
t_Error FM_PORT_ConfigIMPolling(t_Handle h_FmPort);
+/**************************************************************************//**
+ @Function FM_PORT_ConfigMaxFrameLength
+
+ @Description Changes the definition of the max size of frame that should be
+ transmitted/received on this port from its default value [DEFAULT_PORT_maxFrameLength].
+ This parameter is used for confirmation of the minimum Fifo
+ size calculations and only for Tx ports or ports working in
+ independent mode. This should be larger than the maximum possible
+ MTU that will be used for this port (i.e. its MAC).
+
+ @Param[in] h_FmPort A handle to a FM Port module.
+ @Param[in] length Max size of frame
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
+ This routine is to be used only if Independent-Mode is enabled.
+*//***************************************************************************/
+t_Error FM_PORT_ConfigMaxFrameLength(t_Handle h_FmPort, uint16_t length);
+
+/**************************************************************************//*
+ @Function FM_PORT_ConfigTxFifoMinFillLevel
+
+ @Description Calling this routine changes the fifo minimum
+ fill level parameter in the internal driver data base
+ from its default configuration [DEFAULT_PORT_txFifoMinFillLevel]
+
+ May be used for Tx ports only
+
+ @Param[in] h_FmPort A handle to a FM Port module.
+ @Param[in] minFillLevel New value
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
+*//***************************************************************************/
+t_Error FM_PORT_ConfigTxFifoMinFillLevel(t_Handle h_FmPort, uint32_t minFillLevel);
+
+/**************************************************************************//*
+ @Function FM_PORT_ConfigFifoDeqPipelineDepth
+
+ @Description Calling this routine changes the fifo dequeue
+ pipeline depth parameter in the internal driver data base
+
+ from its default configuration: 1G ports: [DEFAULT_PORT_fifoDeqPipelineDepth_1G],
+ 10G port: [DEFAULT_PORT_fifoDeqPipelineDepth_10G],
+ OP port: [DEFAULT_PORT_fifoDeqPipelineDepth_OH]
+
+ May be used for Tx/OP ports only
+
+ @Param[in] h_FmPort A handle to a FM Port module.
+ @Param[in] deqPipelineDepth New value
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
+*//***************************************************************************/
+t_Error FM_PORT_ConfigFifoDeqPipelineDepth(t_Handle h_FmPort, uint8_t deqPipelineDepth);
+
+/**************************************************************************//*
+ @Function FM_PORT_ConfigTxFifoLowComfLevel
+
+ @Description Calling this routine changes the fifo low comfort level
+ parameter in internal driver data base
+ from its default configuration [DEFAULT_PORT_txFifoLowComfLevel]
+
+ May be used for Tx ports only
+
+ @Param[in] h_FmPort A handle to a FM Port module.
+ @Param[in] fifoLowComfLevel New value
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
+*//***************************************************************************/
+t_Error FM_PORT_ConfigTxFifoLowComfLevel(t_Handle h_FmPort, uint32_t fifoLowComfLevel);
+
+/**************************************************************************//*
+ @Function FM_PORT_ConfigRxFifoThreshold
+
+ @Description Calling this routine changes the threshold of the FIFO
+ fill level parameter in the internal driver data base
+ from its default configuration [DEFAULT_PORT_rxFifoThreshold]
+
+ If the total number of buffers which are
+ currently in use and associated with the
+ specific RX port exceed this threshold, the
+ BMI will signal the MAC to send a pause frame
+ over the link.
+
+ May be used for Rx ports only
+
+ @Param[in] h_FmPort A handle to a FM Port module.
+ @Param[in] fifoThreshold New value
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
+*//***************************************************************************/
+t_Error FM_PORT_ConfigRxFifoThreshold(t_Handle h_FmPort, uint32_t fifoThreshold);
+
+/**************************************************************************//*
+ @Function FM_PORT_ConfigRxFifoPriElevationLevel
+
+ @Description Calling this routine changes the priority elevation level
+ parameter in the internal driver data base from its default
+ configuration [DEFAULT_PORT_rxFifoPriElevationLevel]
+
+ If the total number of buffers which are currently in use and
+ associated with the specific RX port exceed the amount specified
+ in priElevationLevel, BMI will signal the main FM's DMA to
+ elevate the FM priority on the system bus.
+
+ May be used for Rx ports only
+
+ @Param[in] h_FmPort A handle to a FM Port module.
+ @Param[in] priElevationLevel New value
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
+*//***************************************************************************/
+t_Error FM_PORT_ConfigRxFifoPriElevationLevel(t_Handle h_FmPort, uint32_t priElevationLevel);
+
+#ifdef FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669
+/**************************************************************************//*
+ @Function FM_PORT_ConfigBCBWorkaround
+
+ @Description Configures BCB errata workaround.
+
+ When BCB errata is applicable, the workaround is always
+ performed by FM Controller. Thus, this functions doesn't
+ actually enable errata workaround but rather allows driver
+ to perform adjustments required due to errata workaround
+ execution in FM controller.
+
+ Applying BCB workaround also configures FM_PORT_FRM_ERR_PHYSICAL
+ errors to be discarded. Thus FM_PORT_FRM_ERR_PHYSICAL can't be
+ set by FM_PORT_SetErrorsRoute() function.
+
+ @Param[in] h_FmPort A handle to a FM Port module.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
+*//***************************************************************************/
+t_Error FM_PORT_ConfigBCBWorkaround(t_Handle h_FmPort);
+#endif /* FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669 */
+
+#if (DPAA_VERSION >= 11)
+/**************************************************************************//*
+ @Function FM_PORT_ConfigInternalBuffOffset
+
+ @Description Configures internal buffer offset.
+
+ May be used for Rx and OP ports only
+
+ @Param[in] h_FmPort A handle to a FM Port module.
+ @Param[in] val New value
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PORT_Config() and before FM_PORT_Init().
+*//***************************************************************************/
+t_Error FM_PORT_ConfigInternalBuffOffset(t_Handle h_FmPort, uint8_t val);
+#endif /* (DPAA_VERSION >= 11) */
+
/** @} */ /* end of FM_PORT_advanced_init_grp group */
/** @} */ /* end of FM_PORT_init_grp group */
@@ -1172,18 +1281,39 @@ typedef enum e_FmPortCounters {
e_FM_PORT_COUNTERS_DEALLOC_BUF, /**< BMI deallocate buffer statistics counter */
e_FM_PORT_COUNTERS_RX_BAD_FRAME, /**< BMI Rx only statistics counter */
e_FM_PORT_COUNTERS_RX_LARGE_FRAME, /**< BMI Rx only statistics counter */
- e_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD, /**< BMI Rx only statistics counter */
e_FM_PORT_COUNTERS_RX_FILTER_FRAME, /**< BMI Rx & OP only statistics counter */
e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR, /**< BMI Rx, OP & HC only statistics counter */
+ e_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD, /**< BMI Rx, OP & HC statistics counter */
+ e_FM_PORT_COUNTERS_PREPARE_TO_ENQUEUE_COUNTER, /**< BMI Rx, OP & HC only statistics counter */
e_FM_PORT_COUNTERS_WRED_DISCARD, /**< BMI OP & HC only statistics counter */
e_FM_PORT_COUNTERS_LENGTH_ERR, /**< BMI non-Rx statistics counter */
e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT, /**< BMI non-Rx statistics counter */
- e_FM_PORT_COUNTERS_DEQ_TOTAL, /**< QMI counter */
- e_FM_PORT_COUNTERS_ENQ_TOTAL, /**< QMI counter */
+ e_FM_PORT_COUNTERS_DEQ_TOTAL, /**< QMI total QM dequeues counter */
+ e_FM_PORT_COUNTERS_ENQ_TOTAL, /**< QMI total QM enqueues counter */
e_FM_PORT_COUNTERS_DEQ_FROM_DEFAULT, /**< QMI counter */
e_FM_PORT_COUNTERS_DEQ_CONFIRM /**< QMI counter */
} e_FmPortCounters;
+typedef struct t_FmPortBmiStats {
+ uint32_t cntCycle;
+ uint32_t cntTaskUtil;
+ uint32_t cntQueueUtil;
+ uint32_t cntDmaUtil;
+ uint32_t cntFifoUtil;
+ uint32_t cntRxPauseActivation;
+ uint32_t cntFrame;
+ uint32_t cntDiscardFrame;
+ uint32_t cntDeallocBuf;
+ uint32_t cntRxBadFrame;
+ uint32_t cntRxLargeFrame;
+ uint32_t cntRxFilterFrame;
+ uint32_t cntRxListDmaErr;
+ uint32_t cntRxOutOfBuffersDiscard;
+ uint32_t cntWredDiscard;
+ uint32_t cntLengthErr;
+ uint32_t cntUnsupportedFormat;
+} t_FmPortBmiStats;
+
/**************************************************************************//**
@Description Structure for Port id parameters.
Fields commented 'IN' are passed by the port module to be used
@@ -1191,14 +1321,284 @@ typedef enum e_FmPortCounters {
Fields commented 'OUT' will be filled by FM before returning to port.
*//***************************************************************************/
typedef struct t_FmPortCongestionGrps {
- uint16_t numOfCongestionGrpsToConsider; /**< The number of required congestion groups
+ uint16_t numOfCongestionGrpsToConsider; /**< The number of required CGs
to define the size of the following array */
uint8_t congestionGrpsToConsider[FM_PORT_NUM_OF_CONGESTION_GRPS];
- /**< An array of 'numOfCongestionGrpsToConsider'
- describing the groups */
+ /**< An array of CG indexes;
+ Note that the size of the array should be
+ 'numOfCongestionGrpsToConsider'. */
+#if (DPAA_VERSION >= 11)
+ bool pfcPrioritiesEn[FM_PORT_NUM_OF_CONGESTION_GRPS][FM_MAX_NUM_OF_PFC_PRIORITIES];
+ /**< a matrix that represents the map between the CG ids
+ defined in 'congestionGrpsToConsider' to the priorties
+ mapping array. */
+#endif /* (DPAA_VERSION >= 11) */
} t_FmPortCongestionGrps;
+/**************************************************************************//**
+ @Description Structure for Deep Sleep Auto Response ARP Entry
+*//***************************************************************************/
+typedef struct t_FmPortDsarArpEntry
+{
+ uint32_t ipAddress;
+ uint8_t mac[6];
+ bool isVlan;
+ uint16_t vid;
+} t_FmPortDsarArpEntry;
+
+/**************************************************************************//**
+ @Description Structure for Deep Sleep Auto Response ARP info
+*//***************************************************************************/
+typedef struct t_FmPortDsarArpInfo
+{
+ uint8_t tableSize;
+ t_FmPortDsarArpEntry *p_AutoResTable;
+ bool enableConflictDetection; /* when TRUE Conflict Detection will be checked and wake the host if needed */
+} t_FmPortDsarArpInfo;
+
+/**************************************************************************//**
+ @Description Structure for Deep Sleep Auto Response NDP Entry
+*//***************************************************************************/
+typedef struct t_FmPortDsarNdpEntry
+{
+ uint32_t ipAddress[4];
+ uint8_t mac[6];
+ bool isVlan;
+ uint16_t vid;
+} t_FmPortDsarNdpEntry;
+
+/**************************************************************************//**
+ @Description Structure for Deep Sleep Auto Response NDP info
+*//***************************************************************************/
+typedef struct t_FmPortDsarNdpInfo
+{
+ uint32_t multicastGroup;
+
+ uint8_t tableSizeAssigned;
+ t_FmPortDsarNdpEntry *p_AutoResTableAssigned; /* This list refer to solicitation IP addresses.
+ Note that all IP adresses must be from the same multicast group.
+ This will be checked and if not operation will fail. */
+ uint8_t tableSizeTmp;
+ t_FmPortDsarNdpEntry *p_AutoResTableTmp; /* This list refer to temp IP addresses.
+ Note that all temp IP adresses must be from the same multicast group.
+ This will be checked and if not operation will fail. */
+
+ bool enableConflictDetection; /* when TRUE Conflict Detection will be checked and wake the host if needed */
+
+} t_FmPortDsarNdpInfo;
+
+/**************************************************************************//**
+ @Description Structure for Deep Sleep Auto Response ICMPV4 info
+*//***************************************************************************/
+typedef struct t_FmPortDsarEchoIpv4Info
+{
+ uint8_t tableSize;
+ t_FmPortDsarArpEntry *p_AutoResTable;
+} t_FmPortDsarEchoIpv4Info;
+
+/**************************************************************************//**
+ @Description Structure for Deep Sleep Auto Response ICMPV6 info
+*//***************************************************************************/
+typedef struct t_FmPortDsarEchoIpv6Info
+{
+ uint8_t tableSize;
+ t_FmPortDsarNdpEntry *p_AutoResTable;
+} t_FmPortDsarEchoIpv6Info;
+
+/**************************************************************************//**
+@Description Deep Sleep Auto Response SNMP OIDs table entry
+
+*//***************************************************************************/
+typedef struct {
+ uint16_t oidSize;
+ uint8_t *oidVal; /* only the oid string */
+ uint16_t resSize;
+ uint8_t *resVal; /* resVal will be the entire reply,
+ i.e. "Type|Length|Value" */
+} t_FmPortDsarOidsEntry;
+
+/**************************************************************************//**
+ @Description Deep Sleep Auto Response SNMP IPv4 Addresses Table Entry
+ Refer to the FMan Controller spec for more details.
+*//***************************************************************************/
+typedef struct
+{
+ uint32_t ipv4Addr; /*!< 32 bit IPv4 Address. */
+ bool isVlan;
+ uint16_t vid; /*!< 12 bits VLAN ID. The 4 left-most bits should be cleared */
+ /*!< This field should be 0x0000 for an entry with no VLAN tag or a null VLAN ID. */
+} t_FmPortDsarSnmpIpv4AddrTblEntry;
+
+/**************************************************************************//**
+ @Description Deep Sleep Auto Response SNMP IPv6 Addresses Table Entry
+ Refer to the FMan Controller spec for more details.
+*//***************************************************************************/
+typedef struct
+{
+ uint32_t ipv6Addr[4]; /*!< 4 * 32 bit IPv6 Address. */
+ bool isVlan;
+ uint16_t vid; /*!< 12 bits VLAN ID. The 4 left-most bits should be cleared */
+ /*!< This field should be 0x0000 for an entry with no VLAN tag or a null VLAN ID. */
+} t_FmPortDsarSnmpIpv6AddrTblEntry;
+
+/**************************************************************************//**
+ @Description Deep Sleep Auto Response SNMP Descriptor
+
+*//***************************************************************************/
+typedef struct
+{
+ uint16_t control; /**< Control bits [0-15]. */
+ uint16_t maxSnmpMsgLength; /**< Maximal allowed SNMP message length. */
+ uint16_t numOfIpv4Addresses; /**< Number of entries in IPv4 addresses table. */
+ uint16_t numOfIpv6Addresses; /**< Number of entries in IPv6 addresses table. */
+ t_FmPortDsarSnmpIpv4AddrTblEntry *p_Ipv4AddrTbl; /**< Pointer to IPv4 addresses table. */
+ t_FmPortDsarSnmpIpv6AddrTblEntry *p_Ipv6AddrTbl; /**< Pointer to IPv6 addresses table. */
+ uint8_t *p_RdOnlyCommunityStr; /**< Pointer to the Read Only Community String. */
+ uint8_t *p_RdWrCommunityStr; /**< Pointer to the Read Write Community String. */
+ t_FmPortDsarOidsEntry *p_OidsTbl; /**< Pointer to OIDs table. */
+ uint32_t oidsTblSize; /**< Number of entries in OIDs table. */
+} t_FmPortDsarSnmpInfo;
+
+/**************************************************************************//**
+ @Description Structure for Deep Sleep Auto Response filtering Entry
+*//***************************************************************************/
+typedef struct t_FmPortDsarFilteringEntry
+{
+ uint16_t srcPort;
+ uint16_t dstPort;
+ uint16_t srcPortMask;
+ uint16_t dstPortMask;
+} t_FmPortDsarFilteringEntry;
+
+/**************************************************************************//**
+ @Description Structure for Deep Sleep Auto Response filtering info
+*//***************************************************************************/
+typedef struct t_FmPortDsarFilteringInfo
+{
+ /* IP protocol filtering parameters */
+ uint8_t ipProtTableSize;
+ uint8_t *p_IpProtTablePtr;
+ bool ipProtPassOnHit; /* when TRUE, miss in the table will cause the packet to be droped,
+ hit will pass the packet to UDP/TCP filters if needed and if not
+ to the classification tree. If the classification tree will pass
+ the packet to a queue it will cause a wake interupt.
+ When FALSE it the other way around. */
+ /* UDP port filtering parameters */
+ uint8_t udpPortsTableSize;
+ t_FmPortDsarFilteringEntry *p_UdpPortsTablePtr;
+ bool udpPortPassOnHit; /* when TRUE, miss in the table will cause the packet to be droped,
+ hit will pass the packet to classification tree.
+ If the classification tree will pass the packet to a queue it
+ will cause a wake interupt.
+ When FALSE it the other way around. */
+ /* TCP port filtering parameters */
+ uint16_t tcpFlagsMask;
+ uint8_t tcpPortsTableSize;
+ t_FmPortDsarFilteringEntry *p_TcpPortsTablePtr;
+ bool tcpPortPassOnHit; /* when TRUE, miss in the table will cause the packet to be droped,
+ hit will pass the packet to classification tree.
+ If the classification tree will pass the packet to a queue it
+ will cause a wake interupt.
+ When FALSE it the other way around. */
+} t_FmPortDsarFilteringInfo;
+
+/**************************************************************************//**
+ @Description Structure for Deep Sleep Auto Response parameters
+*//***************************************************************************/
+typedef struct t_FmPortDsarParams
+{
+ t_Handle h_FmPortTx;
+ t_FmPortDsarArpInfo *p_AutoResArpInfo;
+ t_FmPortDsarEchoIpv4Info *p_AutoResEchoIpv4Info;
+ t_FmPortDsarNdpInfo *p_AutoResNdpInfo;
+ t_FmPortDsarEchoIpv6Info *p_AutoResEchoIpv6Info;
+ t_FmPortDsarSnmpInfo *p_AutoResSnmpInfo;
+ t_FmPortDsarFilteringInfo *p_AutoResFilteringInfo;
+} t_FmPortDsarParams;
+
+/**************************************************************************//**
+ @Function FM_PORT_EnterDsar
+
+ @Description Enter Deep Sleep Auto Response mode.
+ This function write the apropriate values to in the relevant
+ tables in the MURAM.
+
+ @Param[in] h_FmPortRx - FM PORT module descriptor
+ @Param[in] params - Auto Response parameters
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PORT_Init().
+*//***************************************************************************/
+t_Error FM_PORT_EnterDsar(t_Handle h_FmPortRx, t_FmPortDsarParams *params);
+
+/**************************************************************************//**
+ @Function FM_PORT_EnterDsarFinal
+
+ @Description Enter Deep Sleep Auto Response mode.
+ This function sets the Tx port in independent mode as needed
+ and redirect the receive flow to go through the
+ Dsar Fman-ctrl code
+
+ @Param[in] h_DsarRxPort - FM Rx PORT module descriptor
+ @Param[in] h_DsarTxPort - FM Tx PORT module descriptor
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PORT_Init().
+*//***************************************************************************/
+t_Error FM_PORT_EnterDsarFinal(t_Handle h_DsarRxPort, t_Handle h_DsarTxPort);
+
+/**************************************************************************//**
+ @Function FM_PORT_ExitDsar
+
+ @Description Exit Deep Sleep Auto Response mode.
+ This function reverse the AR mode and put the ports back into
+ their original wake mode
+
+ @Param[in] h_FmPortRx - FM PORT Rx module descriptor
+ @Param[in] h_FmPortTx - FM PORT Tx module descriptor
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PORT_EnterDsar().
+*//***************************************************************************/
+void FM_PORT_ExitDsar(t_Handle h_FmPortRx, t_Handle h_FmPortTx);
+/**************************************************************************//**
+ @Function FM_PORT_IsInDsar
+
+ @Description This function returns TRUE if the port was set as Auto Response
+ and FALSE if not. Once Exit AR mode it will return FALSE as well
+ until re-enabled once more.
+
+ @Param[in] h_FmPort - FM PORT module descriptor
+
+ @Return E_OK on success; Error code otherwise.
+*//***************************************************************************/
+bool FM_PORT_IsInDsar(t_Handle h_FmPort);
+
+typedef struct t_FmPortDsarStats
+{
+ uint32_t arpArCnt;
+ uint32_t echoIcmpv4ArCnt;
+ uint32_t ndpArCnt;
+ uint32_t echoIcmpv6ArCnt;
+ uint32_t snmpGetCnt;
+ uint32_t snmpGetNextCnt;
+} t_FmPortDsarStats;
+
+/**************************************************************************//**
+ @Function FM_PORT_GetDsarStats
+
+ @Description Return statistics for Deep Sleep Auto Response
+
+ @Param[in] h_FmPortRx - FM PORT module descriptor
+ @Param[out] stats - structure containing the statistics counters
+
+ @Return E_OK on success; Error code otherwise.
+*//***************************************************************************/
+t_Error FM_PORT_GetDsarStats(t_Handle h_FmPortRx, t_FmPortDsarStats *stats);
#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
/**************************************************************************//**
@@ -1237,7 +1637,7 @@ uint32_t FM_PORT_GetBufferDataOffset(t_Handle h_FmPort);
@Description Returns the Internal Context offset from the beginning of the data buffer
@Param[in] h_FmPort - FM PORT module descriptor
- @Param[in] p_Data - A pointer to the data buffer.
+ @Param[in] p_Data - A pointer to the data buffer.
@Return Internal context info pointer on success, NULL if 'allOtherInfo' was not
configured for this port.
@@ -1246,23 +1646,6 @@ uint32_t FM_PORT_GetBufferDataOffset(t_Handle h_FmPort);
*//***************************************************************************/
uint8_t * FM_PORT_GetBufferICInfo(t_Handle h_FmPort, char *p_Data);
-#ifdef DEBUG
-/**************************************************************************//**
- @Function FM_PORT_GetBufferDebugInfo
-
- @Description Returns the debug info offset from the beginning of the data buffer
-
- @Param[in] h_FmPort - FM PORT module descriptor
- @Param[in] p_Data - A pointer to the data buffer.
-
- @Return Debug info pointer on success, NULL if 'passDebugInfo' was not
- configured for this port.
-
- @Cautions Allowed only following FM_PORT_Init().
-*//***************************************************************************/
-uint8_t * FM_PORT_GetBufferDebugInfo(t_Handle h_FmPort, char *p_Data);
-#endif /* DEBUG */
-
/**************************************************************************//**
@Function FM_PORT_GetBufferPrsResult
@@ -1358,7 +1741,7 @@ t_Error FM_PORT_Enable(t_Handle h_FmPort);
The selected rate limit specified here would be
rounded DOWN to the nearest 16M.
- May be used for Tx and offline parsing ports only
+ May be used for Tx and OP ports only
@Param[in] h_FmPort A handle to a FM Port module.
@Param[in] p_RateLimit A structure of rate limit parameters
@@ -1366,6 +1749,8 @@ t_Error FM_PORT_Enable(t_Handle h_FmPort);
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PORT_Init().
+ If rate limit is set on a port that need to send PFC frames,
+ it might violate the stop transmit timing.
*//***************************************************************************/
t_Error FM_PORT_SetRateLimit(t_Handle h_FmPort, t_FmPortRateLimit *p_RateLimit);
@@ -1375,7 +1760,7 @@ t_Error FM_PORT_SetRateLimit(t_Handle h_FmPort, t_FmPortRateLimit *p_RateLimit);
@Description Calling this routine disables and clears rate limit
initialization.
- May be used for Tx and offline parsing ports only
+ May be used for Tx and OP ports only
@Param[in] h_FmPort A handle to a FM Port module.
@@ -1386,29 +1771,30 @@ t_Error FM_PORT_SetRateLimit(t_Handle h_FmPort, t_FmPortRateLimit *p_RateLimit);
t_Error FM_PORT_DeleteRateLimit(t_Handle h_FmPort);
/**************************************************************************//**
- @Function FM_PORT_SetStatisticsCounters
+ @Function FM_PORT_SetPfcPrioritiesMappingToQmanWQ
- @Description Calling this routine enables/disables port's statistics counters.
- By default, counters are enabled.
+ @Description Calling this routine maps each PFC received priority to the transmit WQ.
+ This WQ will be blocked upon receiving a PFC frame with this priority.
- May be used for all port types
+ May be used for Tx ports only.
- @Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] enable TRUE to enable, FALSE to disable.
+ @Param[in] h_FmPort A handle to a FM Port module.
+ @Param[in] prio PFC priority (0-7).
+ @Param[in] wq Work Queue (0-7).
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_SetStatisticsCounters(t_Handle h_FmPort, bool enable);
+t_Error FM_PORT_SetPfcPrioritiesMappingToQmanWQ(t_Handle h_FmPort, uint8_t prio, uint8_t wq);
/**************************************************************************//**
- @Function FM_PORT_SetFrameQueueCounters
+ @Function FM_PORT_SetStatisticsCounters
- @Description Calling this routine enables/disables port's enqueue/dequeue counters.
+ @Description Calling this routine enables/disables port's statistics counters.
By default, counters are enabled.
- May be used for all ports
+ May be used for all port types
@Param[in] h_FmPort A handle to a FM Port module.
@Param[in] enable TRUE to enable, FALSE to disable.
@@ -1417,49 +1803,31 @@ t_Error FM_PORT_SetStatisticsCounters(t_Handle h_FmPort, bool enable);
@Cautions Allowed only following FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_SetFrameQueueCounters(t_Handle h_FmPort, bool enable);
+t_Error FM_PORT_SetStatisticsCounters(t_Handle h_FmPort, bool enable);
/**************************************************************************//**
- @Function FM_PORT_SetPerformanceCounters
+ @Function FM_PORT_SetFrameQueueCounters
- @Description Calling this routine enables/disables port's performance counters.
+ @Description Calling this routine enables/disables port's enqueue/dequeue counters.
By default, counters are enabled.
- May be used for all port types
-
- @Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] enable TRUE to enable, FALSE to disable.
-
- @Return E_OK on success; Error code otherwise.
-
- @Cautions Allowed only following FM_PORT_Init().
-*//***************************************************************************/
-t_Error FM_PORT_SetPerformanceCounters(t_Handle h_FmPort, bool enable);
-
-/**************************************************************************//**
- @Function FM_PORT_SetPerformanceCounters
-
- @Description Calling this routine defines port's performance
- counters parameters.
-
- May be used for all port types
+ May be used for all ports
- @Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] p_FmPortPerformanceCnt A pointer to a structure of performance
- counters parameters.
+ @Param[in] h_FmPort A handle to a FM Port module.
+ @Param[in] enable TRUE to enable, FALSE to disable.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_SetPerformanceCountersParams(t_Handle h_FmPort, t_FmPortPerformanceCnt *p_FmPortPerformanceCnt);
+t_Error FM_PORT_SetFrameQueueCounters(t_Handle h_FmPort, bool enable);
/**************************************************************************//**
@Function FM_PORT_AnalyzePerformanceParams
@Description User may call this routine to so the driver will analyze if the
basic performance parameters are correct and also the driver may
- suggest of improvments; The basic parameters are FIFO sizes, number
+ suggest of improvements; The basic parameters are FIFO sizes, number
of DMAs and number of TNUMs for the port.
May be used for all port types
@@ -1472,77 +1840,40 @@ t_Error FM_PORT_SetPerformanceCountersParams(t_Handle h_FmPort, t_FmPortPerforma
*//***************************************************************************/
t_Error FM_PORT_AnalyzePerformanceParams(t_Handle h_FmPort);
-/**************************************************************************//**
- @Function FM_PORT_SetNumOfOpenDmas
-
- @Description Calling this routine updates the number of open DMA requested for
- this port.
-
-
- May be used for all port types.
-
- @Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] p_NumOfOpenDmas A structure of resource requested parameters
-
- @Return E_OK on success; Error code otherwise.
-
- @Cautions Allowed only following FM_PORT_Init().
-*//***************************************************************************/
-t_Error FM_PORT_SetNumOfOpenDmas(t_Handle h_FmPort, t_FmPortRsrc *p_NumOfOpenDmas);
-
-/**************************************************************************//**
- @Function FM_PORT_SetNumOfTasks
-
- @Description Calling this routine updates the number of tasks requested for
- this port.
-
- May be used for all port types.
-
- @Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] p_NumOfTasks A structure of resource requested parameters
-
- @Return E_OK on success; Error code otherwise.
-
- @Cautions Allowed only following FM_PORT_Init().
-*//***************************************************************************/
-t_Error FM_PORT_SetNumOfTasks(t_Handle h_FmPort, t_FmPortRsrc *p_NumOfTasks);
/**************************************************************************//**
- @Function FM_PORT_SetSizeOfFifo
+ @Function FM_PORT_SetAllocBufCounter
- @Description Calling this routine updates the Fifo size resource requested for
- this port.
+ @Description Calling this routine enables/disables BM pool allocate
+ buffer counters.
+ By default, counters are enabled.
- May be used for all port types - note that only Rx has 'extra'
- fifo size. For other ports 'extra' field must be disabled.
+ May be used for Rx ports only
- @Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] p_SizeOfFifo A structure of resource requested parameters
+ @Param[in] h_FmPort A handle to a FM Port module.
+ @Param[in] poolId BM pool id.
+ @Param[in] enable TRUE to enable, FALSE to disable.
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_SetSizeOfFifo(t_Handle h_FmPort, t_FmPortRsrc *p_SizeOfFifo);
+t_Error FM_PORT_SetAllocBufCounter(t_Handle h_FmPort, uint8_t poolId, bool enable);
/**************************************************************************//**
- @Function FM_PORT_SetAllocBufCounter
+ @Function FM_PORT_GetBmiCounters
- @Description Calling this routine enables/disables BM pool allocate
- buffer counters.
- By default, counters are enabled.
-
- May be used for Rx ports only
+ @Description Read port's BMI stat counters and place them into
+ a designated structure of counters.
@Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] poolId BM pool id.
- @Param[in] enable TRUE to enable, FALSE to disable.
+ @Param[out] p_BmiStats counters structure
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PORT_Init().
*//***************************************************************************/
-t_Error FM_PORT_SetAllocBufCounter(t_Handle h_FmPort, uint8_t poolId, bool enable);
+t_Error FM_PORT_GetBmiCounters(t_Handle h_FmPort, t_FmPortBmiStats *p_BmiStats);
/**************************************************************************//**
@Function FM_PORT_GetCounter
@@ -1618,7 +1949,7 @@ t_Error FM_PORT_ModifyAllocBufCounter(t_Handle h_FmPort, uint8_t poolId, uint32
Each call to this routine may add one or more congestion
groups to be considered relevant to this port.
- May be used for Rx, or RX+OP ports only (depending on chip)
+ May be used for Rx, or RX+OP ports only (depending on chip)
@Param[in] h_FmPort A handle to a FM Port module.
@Param[in] p_CongestionGrps A pointer to an array of congestion groups
@@ -1670,6 +2001,8 @@ bool FM_PORT_IsStalled(t_Handle h_FmPort);
@Description This routine may be called in case the port was stalled and may
now be released.
+ Note that this routine is available only on older FMan revisions
+ (FMan v2, DPAA v1.0 only).
@Param[in] h_FmPort A handle to a FM Port module.
@@ -1707,7 +2040,7 @@ t_Error FM_PORT_SetRxL4ChecksumVerify(t_Handle h_FmPort, bool l4Checksum);
Errors that were configured to be discarded (at initialization)
may not be selected here.
- May be used for Rx and offline parsing ports only
+ May be used for Rx and OP ports only
@Param[in] h_FmPort A handle to a FM Port module.
@Param[in] errs A list of errors to enqueue to error queue
@@ -1722,7 +2055,6 @@ t_Error FM_PORT_SetErrorsRoute(t_Handle h_FmPort, fmPortFrameErrSelect_t errs);
@Function FM_PORT_SetIMExceptions
@Description Calling this routine enables/disables FM PORT interrupts.
- Note: Not available for guest partition.
@Param[in] h_FmPort FM PORT module descriptor.
@Param[in] exception The exception to be selected.
@@ -1731,10 +2063,45 @@ t_Error FM_PORT_SetErrorsRoute(t_Handle h_FmPort, fmPortFrameErrSelect_t errs);
@Return E_OK on success; Error code otherwise.
@Cautions Allowed only following FM_PORT_Init().
+ This routine should NOT be called from guest-partition
+ (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_PORT_SetIMExceptions(t_Handle h_FmPort, e_FmPortExceptions exception, bool enable);
+/**************************************************************************//*
+ @Function FM_PORT_SetPerformanceCounters
+
+ @Description Calling this routine enables/disables port's performance counters.
+ By default, counters are enabled.
+
+ May be used for all port types
+
+ @Param[in] h_FmPort A handle to a FM Port module.
+ @Param[in] enable TRUE to enable, FALSE to disable.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PORT_Init().
+*//***************************************************************************/
+t_Error FM_PORT_SetPerformanceCounters(t_Handle h_FmPort, bool enable);
+
+/**************************************************************************//*
+ @Function FM_PORT_SetPerformanceCountersParams
+
+ @Description Calling this routine defines port's performance
+ counters parameters.
+
+ May be used for all port types
+
+ @Param[in] h_FmPort A handle to a FM Port module.
+ @Param[in] p_FmPortPerformanceCnt A pointer to a structure of performance
+ counters parameters.
+
+ @Return E_OK on success; Error code otherwise.
+ @Cautions Allowed only following FM_PORT_Init().
+*//***************************************************************************/
+t_Error FM_PORT_SetPerformanceCountersParams(t_Handle h_FmPort, t_FmPortPerformanceCnt *p_FmPortPerformanceCnt);
/**************************************************************************//**
@Group FM_PORT_pcd_runtime_control_grp FM Port PCD Runtime Control Unit
@@ -1752,9 +2119,9 @@ t_Error FM_PORT_SetIMExceptions(t_Handle h_FmPort, e_FmPortExceptions exception,
*//***************************************************************************/
typedef struct t_FmPcdKgSchemeSelect {
- bool direct; /**< TRUE to use 'h_Scheme' directly, FALSE to use LCV.*/
- t_Handle h_DirectScheme; /**< Relevant for 'direct'=TRUE only.
- 'h_DirectScheme' selects the scheme after parser. */
+ bool direct; /**< TRUE to use 'h_Scheme' directly, FALSE to use LCV. */
+ t_Handle h_DirectScheme; /**< Scheme handle, selects the scheme after parser;
+ Relevant only when 'direct' is TRUE. */
} t_FmPcdKgSchemeSelect;
/**************************************************************************//**
@@ -1791,7 +2158,7 @@ typedef union u_FmPcdHdrPrsOpts {
/* IPV6 */
struct{
- bool routingHdrDisable; /**< Disable routing header */
+ bool routingHdrEnable; /**< TRUE to enable routing header, otherwise ignore */
} ipv6PrsOptions;
/* UDP */
@@ -1809,7 +2176,12 @@ typedef union u_FmPcdHdrPrsOpts {
@Description A structure for defining each header for the parser
*//***************************************************************************/
typedef struct t_FmPcdPrsAdditionalHdrParams {
- e_NetHeaderType hdr; /**< Selected header */
+ e_NetHeaderType hdr; /**< Selected header; use HEADER_TYPE_NONE
+ to indicate that sw parser is to run first
+ (before HW parser, and independent of the
+ existence of any protocol), in this case,
+ swPrsEnable must be set, and all other
+ parameters are irrelevant. */
bool errDisable; /**< TRUE to disable error indication */
bool swPrsEnable; /**< Enable jump to SW parser when this
header is recognized by the HW parser. */
@@ -1835,7 +2207,8 @@ typedef struct t_FmPortPcdPrsParams {
uint8_t parsingOffset; /**< Number of bytes from beginning of packet to start parsing */
e_NetHeaderType firstPrsHdr; /**< The type of the first header expected at 'parsingOffset' */
bool includeInPrsStatistics; /**< TRUE to include this port in the parser statistics;
- NOTE: this field is not valid when the FN is in "guest" mode. */
+ NOTE: this field is not valid when the FM is in "guest" mode
+ and IPC is not available. */
uint8_t numOfHdrsWithAdditionalParams; /**< Normally 0, some headers may get
special parameters */
t_FmPcdPrsAdditionalHdrParams additionalParams[FM_PCD_PRS_NUM_OF_HDRS];
@@ -1877,13 +2250,7 @@ typedef struct t_FmPortPcdKgParams {
@Description struct for defining policer parameters
*//***************************************************************************/
typedef struct t_FmPortPcdPlcrParams {
- t_Handle h_Profile; /**< Selected profile handle; Relevant for one of
- following cases:
- e_FM_PORT_PCD_SUPPORT_PLCR_ONLY or
- e_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR were selected,
- or if any flow uses a KG scheme were policer
- profile is not generated
- (bypassPlcrProfileGeneration selected) */
+ t_Handle h_Profile; /**< Selected profile handle */
} t_FmPortPcdPlcrParams;
/**************************************************************************//**
@@ -1896,7 +2263,17 @@ typedef struct t_FmPortPcdParams {
t_FmPortPcdPrsParams *p_PrsParams; /**< Parser parameters for this port */
t_FmPortPcdCcParams *p_CcParams; /**< Coarse classification parameters for this port */
t_FmPortPcdKgParams *p_KgParams; /**< Keygen parameters for this port */
- t_FmPortPcdPlcrParams *p_PlcrParams; /**< Policer parameters for this port */
+ t_FmPortPcdPlcrParams *p_PlcrParams; /**< Policer parameters for this port; Relevant for one of
+ following cases:
+ e_FM_PORT_PCD_SUPPORT_PLCR_ONLY or
+ e_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR were selected,
+ or if any flow uses a KG scheme were policer
+ profile is not generated
+ ('bypassPlcrProfileGeneration selected'). */
+ t_Handle h_IpReassemblyManip; /**< IP Reassembly manipulation */
+#if (DPAA_VERSION >= 11)
+ t_Handle h_CapwapReassemblyManip;/**< CAPWAP Reassembly manipulation */
+#endif /* (DPAA_VERSION >= 11) */
} t_FmPortPcdParams;
/**************************************************************************//**
@@ -1909,6 +2286,19 @@ typedef struct t_FmPcdPrsStart {
'parsingOffset' */
} t_FmPcdPrsStart;
+#if (DPAA_VERSION >= 11)
+/**************************************************************************//**
+ @Description struct for defining external buffer margins
+*//***************************************************************************/
+typedef struct t_FmPortVSPAllocParams {
+ uint8_t numOfProfiles; /**< Number of Virtual Storage Profiles; must be a power of 2 */
+ uint8_t dfltRelativeId; /**< The default Virtual-Storage-Profile-id dedicated to Rx/OP port
+ The same default Virtual-Storage-Profile-id will be for coupled Tx port
+ if relevant function called for Rx port */
+ t_Handle h_FmTxPort; /**< Handle to coupled Tx Port; not relevant for OP port. */
+} t_FmPortVSPAllocParams;
+#endif /* (DPAA_VERSION >= 11) */
+
/**************************************************************************//**
@Function FM_PORT_SetPCD
@@ -1918,7 +2308,7 @@ typedef struct t_FmPcdPrsStart {
disabled (BMI to BMI) and configures it according to the passed
parameters.
- May be used for Rx and offline parsing ports only
+ May be used for Rx and OP ports only
@Param[in] h_FmPort A handle to a FM Port module.
@Param[in] p_FmPortPcd A Structure of parameters defining the port's PCD
@@ -1937,7 +2327,7 @@ t_Error FM_PORT_SetPCD(t_Handle h_FmPort, t_FmPortPcdParams *p_FmPortPcd);
The port returns to its default configuration which is PCD
disabled (BMI to BMI) and all PCD configuration is removed.
- May be used for Rx and offline parsing ports which are
+ May be used for Rx and OP ports which are
in PCD mode only
@Param[in] h_FmPort A handle to a FM Port module.
@@ -1956,7 +2346,7 @@ t_Error FM_PORT_DeletePCD(t_Handle h_FmPort);
The couple of routines are used to allow PCD configuration changes
that demand that PCD will not be used while changes take place.
- May be used for Rx and offline parsing ports which are
+ May be used for Rx and OP ports which are
in PCD mode only
@Param[in] h_FmPort A handle to a FM Port module.
@@ -1973,7 +2363,7 @@ t_Error FM_PORT_AttachPCD(t_Handle h_FmPort);
@Description Calling this routine detaches the port from its PCD functionality.
The port returns to its default flow which is BMI to BMI.
- May be used for Rx and offline parsing ports which are
+ May be used for Rx and OP ports which are
in PCD mode only
@Param[in] h_FmPort A handle to a FM Port module.
@@ -1995,7 +2385,8 @@ t_Error FM_PORT_DetachPCD(t_Handle h_FmPort);
@Return E_OK on success; Error code otherwise.
- @Cautions Allowed only following FM_PORT_Init() and FM_PCD_Init(), and before FM_PORT_SetPCD().
+ @Cautions Allowed only following FM_PORT_Init() and FM_PCD_Init(),
+ and before FM_PORT_SetPCD().
*//***************************************************************************/
t_Error FM_PORT_PcdPlcrAllocProfiles(t_Handle h_FmPort, uint16_t numOfProfiles);
@@ -2008,10 +2399,30 @@ t_Error FM_PORT_PcdPlcrAllocProfiles(t_Handle h_FmPort, uint16_t numOfProfiles);
@Return E_OK on success; Error code otherwise.
- @Cautions Allowed only following FM_PORT_Init() and FM_PCD_Init(), and before FM_PORT_SetPCD().
+ @Cautions Allowed only following FM_PORT_Init() and FM_PCD_Init(),
+ and before FM_PORT_SetPCD().
*//***************************************************************************/
t_Error FM_PORT_PcdPlcrFreeProfiles(t_Handle h_FmPort);
+#if (DPAA_VERSION >= 11)
+/**************************************************************************//**
+ @Function FM_PORT_VSPAlloc
+
+ @Description This routine allocated VSPs per port and forces the port to work
+ in VSP mode. Note that the port is initialized by default with the
+ physical-storage-profile only.
+
+ @Param[in] h_FmPort A handle to a FM Port module.
+ @Param[in] p_Params A structure of parameters for allocation VSP's per port
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_PORT_Init(), and before FM_PORT_SetPCD()
+ and also before FM_PORT_Enable(); i.e. the port should be disabled.
+*//***************************************************************************/
+t_Error FM_PORT_VSPAlloc(t_Handle h_FmPort, t_FmPortVSPAllocParams *p_Params);
+#endif /* (DPAA_VERSION >= 11) */
+
/**************************************************************************//**
@Function FM_PORT_PcdKgModifyInitialScheme
@@ -2099,21 +2510,18 @@ t_Error FM_PORT_PcdKgBindSchemes (t_Handle h_FmPort, t_FmPcdPortSchemesParams *p
t_Error FM_PORT_PcdKgUnbindSchemes (t_Handle h_FmPort, t_FmPcdPortSchemesParams *p_PortScheme);
/**************************************************************************//**
- @Function FM_PORT_PcdPrsModifyStartOffset
+ @Function FM_PORT_GetIPv4OptionsCount
- @Description Runtime change of the parser start offset within the header.
- The routine may not be called while port
- receives packets using the PCD functionalities, therefore port must be first detached
- from the PCD, only than the routine may be called, and than port be attached to PCD again.
- @Param[in] h_FmPort A handle to a FM Port module.
- @Param[in] p_FmPcdPrsStart A structure of parameters for defining the
- start point for the parser.
+ @Description TODO
+
+ @Param[in] h_FmPort A handle to a FM Port module.
+ @Param[out] p_Ipv4OptionsCount will hold the counter value
@Return E_OK on success; Error code otherwise.
- @Cautions Allowed only following FM_PORT_Init(), FM_PORT_SetPCD() and FM_PORT_DetatchPCD().
+ @Cautions Allowed only following FM_PORT_Init()
*//***************************************************************************/
-t_Error FM_PORT_PcdPrsModifyStartOffset (t_Handle h_FmPort, t_FmPcdPrsStart *p_FmPcdPrsStart);
+t_Error FM_PORT_GetIPv4OptionsCount(t_Handle h_FmPort, uint32_t *p_Ipv4OptionsCount);
/** @} */ /* end of FM_PORT_pcd_runtime_control_grp group */
/** @} */ /* end of FM_PORT_runtime_control_grp group */
@@ -2192,5 +2600,9 @@ t_Error FM_PORT_ImRx(t_Handle h_FmPort);
+#ifdef NCSW_BACKWARD_COMPATIBLE_API
+#define FM_PORT_ConfigTxFifoDeqPipelineDepth FM_PORT_ConfigFifoDeqPipelineDepth
+#endif /* NCSW_BACKWARD_COMPATIBLE_API */
+
#endif /* __FM_PORT_EXT */
diff --git a/sys/contrib/ncsw/inc/Peripherals/fm_rtc_ext.h b/sys/contrib/ncsw/inc/Peripherals/fm_rtc_ext.h
index 8827d2aa476d..72078ac42c10 100644
--- a/sys/contrib/ncsw/inc/Peripherals/fm_rtc_ext.h
+++ b/sys/contrib/ncsw/inc/Peripherals/fm_rtc_ext.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File fm_rtc_ext.h
@@ -44,7 +45,7 @@
#include "error_ext.h"
#include "std_ext.h"
-
+#include "fsl_fman_rtc.h"
/**************************************************************************//**
@@ -76,8 +77,8 @@
*//***************************************************************************/
typedef enum e_FmRtcAlarmPolarity
{
- e_FM_RTC_ALARM_POLARITY_ACTIVE_HIGH, /**< Active-high output polarity */
- e_FM_RTC_ALARM_POLARITY_ACTIVE_LOW /**< Active-low output polarity */
+ e_FM_RTC_ALARM_POLARITY_ACTIVE_HIGH = E_FMAN_RTC_ALARM_POLARITY_ACTIVE_HIGH, /**< Active-high output polarity */
+ e_FM_RTC_ALARM_POLARITY_ACTIVE_LOW = E_FMAN_RTC_ALARM_POLARITY_ACTIVE_LOW /**< Active-low output polarity */
} e_FmRtcAlarmPolarity;
/**************************************************************************//**
@@ -85,8 +86,8 @@ typedef enum e_FmRtcAlarmPolarity
*//***************************************************************************/
typedef enum e_FmRtcTriggerPolarity
{
- e_FM_RTC_TRIGGER_ON_RISING_EDGE, /**< Trigger on rising edge */
- e_FM_RTC_TRIGGER_ON_FALLING_EDGE /**< Trigger on falling edge */
+ e_FM_RTC_TRIGGER_ON_RISING_EDGE = E_FMAN_RTC_TRIGGER_ON_RISING_EDGE, /**< Trigger on rising edge */
+ e_FM_RTC_TRIGGER_ON_FALLING_EDGE = E_FMAN_RTC_TRIGGER_ON_FALLING_EDGE /**< Trigger on falling edge */
} e_FmRtcTriggerPolarity;
/**************************************************************************//**
@@ -94,9 +95,9 @@ typedef enum e_FmRtcTriggerPolarity
*//***************************************************************************/
typedef enum e_FmSrcClock
{
- e_FM_RTC_SOURCE_CLOCK_EXTERNAL, /**< external high precision timer reference clock */
- e_FM_RTC_SOURCE_CLOCK_SYSTEM, /**< MAC system clock */
- e_FM_RTC_SOURCE_CLOCK_OSCILATOR /**< RTC clock oscilator */
+ e_FM_RTC_SOURCE_CLOCK_EXTERNAL = E_FMAN_RTC_SOURCE_CLOCK_EXTERNAL, /**< external high precision timer reference clock */
+ e_FM_RTC_SOURCE_CLOCK_SYSTEM = E_FMAN_RTC_SOURCE_CLOCK_SYSTEM, /**< MAC system clock */
+ e_FM_RTC_SOURCE_CLOCK_OSCILATOR = E_FMAN_RTC_SOURCE_CLOCK_OSCILATOR /**< RTC clock oscilator */
}e_FmSrcClk;
/**************************************************************************//**
@@ -169,7 +170,7 @@ t_Error FM_RTC_Free(t_Handle h_FmRtc);
@Function FM_RTC_ConfigPeriod
@Description Configures the period of the timestamp if different than
- default [1000].
+ default [DEFAULT_clockPeriod].
@Param[in] h_FmRtc - Handle to FM RTC object.
@Param[in] period - Period in nano-seconds.
@@ -201,7 +202,7 @@ t_Error FM_RTC_ConfigSourceClock(t_Handle h_FmRtc,
@Function FM_RTC_ConfigPulseRealignment
@Description Configures the RTC to automatic FIPER pulse realignment in
- response to timer adjustments [FALSE]
+ response to timer adjustments [DEFAULT_pulseRealign]
In this mode, the RTC clock is identical to the source clock.
This feature can be useful when the system contains an external
@@ -220,7 +221,7 @@ t_Error FM_RTC_ConfigPulseRealignment(t_Handle h_FmRtc, bool enable);
@Function FM_RTC_ConfigFrequencyBypass
@Description Configures the RTC to bypass the frequency compensation
- mechanism. [FALSE]
+ mechanism. [DEFAULT_bypass]
In this mode, the RTC clock is identical to the source clock.
This feature can be useful when the system contains an external
@@ -240,7 +241,7 @@ t_Error FM_RTC_ConfigFrequencyBypass(t_Handle h_FmRtc, bool enabled);
@Function FM_RTC_ConfigInvertedInputClockPhase
@Description Configures the RTC to invert the source clock phase on input.
- [FALSE]
+ [DEFAULT_invertInputClkPhase]
@Param[in] h_FmRtc - Handle to FM RTC object.
@Param[in] inverted - TRUE to invert the source clock phase on input.
@@ -256,7 +257,7 @@ t_Error FM_RTC_ConfigInvertedInputClockPhase(t_Handle h_FmRtc, bool inverted);
@Function FM_RTC_ConfigInvertedOutputClockPhase
@Description Configures the RTC to invert the output clock phase.
- [FALSE]
+ [DEFAULT_invertOutputClkPhase]
@Param[in] h_FmRtc - Handle to FM RTC object.
@Param[in] inverted - TRUE to invert the output clock phase.
@@ -272,7 +273,7 @@ t_Error FM_RTC_ConfigInvertedOutputClockPhase(t_Handle h_FmRtc, bool inverted);
@Function FM_RTC_ConfigOutputClockDivisor
@Description Configures the divisor for generating the output clock from
- the RTC clock. [0x00000002]
+ the RTC clock. [DEFAULT_outputClockDivisor]
@Param[in] h_FmRtc - Handle to FM RTC object.
@Param[in] divisor - Divisor for generation of the output clock.
@@ -287,7 +288,7 @@ t_Error FM_RTC_ConfigOutputClockDivisor(t_Handle h_FmRtc, uint16_t divisor);
@Function FM_RTC_ConfigAlarmPolarity
@Description Configures the polarity (active-high/active-low) of a specific
- alarm signal. [e_FM_RTC_ALARM_POLARITY_ACTIVE_HIGH]
+ alarm signal. [DEFAULT_alarmPolarity]
@Param[in] h_FmRtc - Handle to FM RTC object.
@Param[in] alarmId - Alarm ID.
@@ -305,7 +306,7 @@ t_Error FM_RTC_ConfigAlarmPolarity(t_Handle h_FmRtc,
@Function FM_RTC_ConfigExternalTriggerPolarity
@Description Configures the polarity (rising/falling edge) of a specific
- external trigger signal. [e_FM_RTC_TRIGGER_ON_FALLING_EDGE]
+ external trigger signal. [DEFAULT_triggerPolarity]
@Param[in] h_FmRtc - Handle to FM RTC object.
@Param[in] triggerId - Trigger ID.
@@ -540,11 +541,11 @@ t_Error FM_RTC_GetCurrentTime(t_Handle h_FmRtc, uint64_t *p_Ts);
@Cautions h_FmRtc must have been previously initialized using FM_RTC_Init().
*//***************************************************************************/
t_Error FM_RTC_SetCurrentTime(t_Handle h_FmRtc, uint64_t ts);
-
+
/**************************************************************************//**
@Function FM_RTC_GetFreqCompensation
- @Description TODO
+ @Description Retrieves the frequency compensation value
@Param[in] h_FmRtc - Handle to FM RTC object.
@Param[out] p_Compensation - A pointer to the returned value of compensation.
@@ -558,10 +559,10 @@ t_Error FM_RTC_GetFreqCompensation(t_Handle h_FmRtc, uint32_t *p_Compensation);
/**************************************************************************//**
@Function FM_RTC_SetFreqCompensation
- @Description TODO
+ @Description Sets a new frequency compensation value.
@Param[in] h_FmRtc - Handle to FM RTC object.
- @Param[in] freqCompensation - the new desired compensation value to be set.
+ @Param[in] freqCompensation - The new frequency compensation value to set.
@Return E_OK on success; Error code otherwise.
@@ -569,6 +570,32 @@ t_Error FM_RTC_GetFreqCompensation(t_Handle h_FmRtc, uint32_t *p_Compensation);
*//***************************************************************************/
t_Error FM_RTC_SetFreqCompensation(t_Handle h_FmRtc, uint32_t freqCompensation);
+#ifdef CONFIG_PTP_1588_CLOCK_DPAA
+/**************************************************************************//**
+*@Function FM_RTC_EnableInterrupt
+*
+*@Description Enable interrupt of FM RTC.
+*
+*@Param[in] h_FmRtc - Handle to FM RTC object.
+*@Param[in] events - Interrupt events.
+*
+*@Return E_OK on success; Error code otherwise.
+*//***************************************************************************/
+t_Error FM_RTC_EnableInterrupt(t_Handle h_FmRtc, uint32_t events);
+
+/**************************************************************************//**
+*@Function FM_RTC_DisableInterrupt
+*
+*@Description Disable interrupt of FM RTC.
+*
+*@Param[in] h_FmRtc - Handle to FM RTC object.
+*@Param[in] events - Interrupt events.
+*
+*@Return E_OK on success; Error code otherwise.
+*//***************************************************************************/
+t_Error FM_RTC_DisableInterrupt(t_Handle h_FmRtc, uint32_t events);
+#endif
+
#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
/**************************************************************************//**
@Function FM_RTC_DumpRegs
diff --git a/sys/contrib/ncsw/inc/Peripherals/fm_vsp_ext.h b/sys/contrib/ncsw/inc/Peripherals/fm_vsp_ext.h
new file mode 100644
index 000000000000..f9aed0363d7c
--- /dev/null
+++ b/sys/contrib/ncsw/inc/Peripherals/fm_vsp_ext.h
@@ -0,0 +1,411 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/**************************************************************************//**
+ @File fm_vsp_ext.h
+
+ @Description FM Virtual Storage-Profile ...
+*//***************************************************************************/
+#ifndef __FM_VSP_EXT_H
+#define __FM_VSP_EXT_H
+
+#include "std_ext.h"
+#include "error_ext.h"
+#include "string_ext.h"
+#include "debug_ext.h"
+
+#include "fm_ext.h"
+
+
+/**************************************************************************//**
+
+ @Group FM_grp Frame Manager API
+
+ @Description FM API functions, definitions and enums
+
+ @{
+*//***************************************************************************/
+
+/**************************************************************************//**
+ @Group FM_VSP_grp FM Virtual-Storage-Profile
+
+ @Description FM Virtual-Storage-Profile API
+
+ @{
+*//***************************************************************************/
+
+/**************************************************************************//**
+ @Group FM_VSP_init_grp FM VSP Initialization Unit
+
+ @Description FM VSP initialization API.
+
+ @{
+*//***************************************************************************/
+
+/**************************************************************************//**
+ @Description Virtual Storage Profile
+*//***************************************************************************/
+typedef struct t_FmVspParams {
+ t_Handle h_Fm; /**< A handle to the FM object this VSP related to */
+ t_FmExtPools extBufPools; /**< Which external buffer pools are used
+ (up to FM_PORT_MAX_NUM_OF_EXT_POOLS), and their sizes.
+ parameter associated with Rx / OP port */
+ uint16_t liodnOffset; /**< VSP's LIODN offset */
+ struct {
+ e_FmPortType portType; /**< Port type */
+ uint8_t portId; /**< Port Id - relative to type */
+ } portParams;
+ uint8_t relativeProfileId; /**< VSP Id - relative to VSP's range
+ defined in relevant FM object */
+} t_FmVspParams;
+
+
+/**************************************************************************//**
+ @Function FM_VSP_Config
+
+ @Description Creates descriptor for the FM VSP module.
+
+ The routine returns a handle (descriptor) to the FM VSP object.
+ This descriptor must be passed as first parameter to all other
+ FM VSP function calls.
+
+ No actual initialization or configuration of FM hardware is
+ done by this routine.
+
+@Param[in] p_FmVspParams Pointer to data structure of parameters
+
+ @Retval Handle to FM VSP object, or NULL for Failure.
+*//***************************************************************************/
+t_Handle FM_VSP_Config(t_FmVspParams *p_FmVspParams);
+
+/**************************************************************************//**
+ @Function FM_VSP_Init
+
+ @Description Initializes the FM VSP module
+
+ @Param[in] h_FmVsp - FM VSP module descriptor
+
+ @Return E_OK on success; Error code otherwise.
+*//***************************************************************************/
+t_Error FM_VSP_Init(t_Handle h_FmVsp);
+
+/**************************************************************************//**
+ @Function FM_VSP_Free
+
+ @Description Frees all resources that were assigned to FM VSP module.
+
+ Calling this routine invalidates the descriptor.
+
+ @Param[in] h_FmVsp - FM VSP module descriptor
+
+ @Return E_OK on success; Error code otherwise.
+*//***************************************************************************/
+t_Error FM_VSP_Free(t_Handle h_FmVsp);
+
+
+/**************************************************************************//**
+ @Group FM_VSP_adv_config_grp FM VSP Advanced Configuration Unit
+
+ @Description FM VSP advanced configuration functions.
+
+ @{
+*//***************************************************************************/
+
+/**************************************************************************//**
+ @Function FM_VSP_ConfigBufferPrefixContent
+
+ @Description Defines the structure, size and content of the application buffer.
+
+ The prefix will
+ In VSPs defined for Tx ports, if 'passPrsResult', the application
+ should set a value to their offsets in the prefix of
+ the FM will save the first 'privDataSize', than,
+ depending on 'passPrsResult' and 'passTimeStamp', copy parse result
+ and timeStamp, and the packet itself (in this order), to the
+ application buffer, and to offset.
+
+ Calling this routine changes the buffer margins definitions
+ in the internal driver data base from its default
+ configuration: Data size: [DEFAULT_FM_SP_bufferPrefixContent_privDataSize]
+ Pass Parser result: [DEFAULT_FM_SP_bufferPrefixContent_passPrsResult].
+ Pass timestamp: [DEFAULT_FM_SP_bufferPrefixContent_passTimeStamp].
+
+ @Param[in] h_FmVsp A handle to a FM VSP module.
+ @Param[in,out] p_FmBufferPrefixContent A structure of parameters describing the
+ structure of the buffer.
+ Out parameter: Start margin - offset
+ of data from start of external buffer.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
+*//***************************************************************************/
+t_Error FM_VSP_ConfigBufferPrefixContent(t_Handle h_FmVsp,
+ t_FmBufferPrefixContent *p_FmBufferPrefixContent);
+
+/**************************************************************************//**
+ @Function FM_VSP_ConfigDmaSwapData
+
+ @Description Calling this routine changes the DMA swap data parameter
+ in the internal driver data base from its default
+ configuration [DEFAULT_FM_SP_dmaSwapData]
+
+ @Param[in] h_FmVsp A handle to a FM VSP module.
+ @Param[in] swapData New selection
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
+*//***************************************************************************/
+t_Error FM_VSP_ConfigDmaSwapData(t_Handle h_FmVsp, e_FmDmaSwapOption swapData);
+
+/**************************************************************************//**
+ @Function FM_VSP_ConfigDmaIcCacheAttr
+
+ @Description Calling this routine changes the internal context cache
+ attribute parameter in the internal driver data base
+ from its default configuration [DEFAULT_FM_SP_dmaIntContextCacheAttr]
+
+ @Param[in] h_FmVsp A handle to a FM VSP module.
+ @Param[in] intContextCacheAttr New selection
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
+*//***************************************************************************/
+t_Error FM_VSP_ConfigDmaIcCacheAttr(t_Handle h_FmVsp,
+ e_FmDmaCacheOption intContextCacheAttr);
+
+/**************************************************************************//**
+ @Function FM_VSP_ConfigDmaHdrAttr
+
+ @Description Calling this routine changes the header cache
+ attribute parameter in the internal driver data base
+ from its default configuration [DEFAULT_FM_SP_dmaHeaderCacheAttr]
+
+ @Param[in] h_FmVsp A handle to a FM VSP module.
+ @Param[in] headerCacheAttr New selection
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
+*//***************************************************************************/
+t_Error FM_VSP_ConfigDmaHdrAttr(t_Handle h_FmVsp, e_FmDmaCacheOption headerCacheAttr);
+
+/**************************************************************************//**
+ @Function FM_VSP_ConfigDmaScatterGatherAttr
+
+ @Description Calling this routine changes the scatter gather cache
+ attribute parameter in the internal driver data base
+ from its default configuration [DEFAULT_FM_SP_dmaScatterGatherCacheAttr]
+
+ @Param[in] h_FmVsp A handle to a FM VSP module.
+ @Param[in] scatterGatherCacheAttr New selection
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
+*//***************************************************************************/
+t_Error FM_VSP_ConfigDmaScatterGatherAttr(t_Handle h_FmVsp,
+ e_FmDmaCacheOption scatterGatherCacheAttr);
+
+/**************************************************************************//**
+ @Function FM_VSP_ConfigDmaWriteOptimize
+
+ @Description Calling this routine changes the write optimization
+ parameter in the internal driver data base
+ from its default configuration: optimize = [DEFAULT_FM_SP_dmaWriteOptimize]
+
+ @Param[in] h_FmVsp A handle to a FM VSP module.
+ @Param[in] optimize TRUE to enable optimization, FALSE for normal operation
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
+*//***************************************************************************/
+t_Error FM_VSP_ConfigDmaWriteOptimize(t_Handle h_FmVsp, bool optimize);
+
+/**************************************************************************//**
+ @Function FM_VSP_ConfigNoScatherGather
+
+ @Description Calling this routine changes the possibility to receive S/G frame
+ in the internal driver data base
+ from its default configuration: optimize = [DEFAULT_FM_SP_noScatherGather]
+
+ @Param[in] h_FmVsp A handle to a FM VSP module.
+ @Param[in] noScatherGather TRUE to operate without scatter/gather capability.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
+*//***************************************************************************/
+t_Error FM_VSP_ConfigNoScatherGather(t_Handle h_FmVsp, bool noScatherGather);
+
+/**************************************************************************//**
+ @Function FM_VSP_ConfigPoolDepletion
+
+ @Description Calling this routine enables pause frame generation depending on the
+ depletion status of BM pools. It also defines the conditions to activate
+ this functionality. By default, this functionality is disabled.
+
+ @Param[in] h_FmVsp A handle to a FM VSP module.
+ @Param[in] p_BufPoolDepletion A structure of pool depletion parameters
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
+*//***************************************************************************/
+t_Error FM_VSP_ConfigPoolDepletion(t_Handle h_FmVsp, t_FmBufPoolDepletion *p_BufPoolDepletion);
+
+/**************************************************************************//**
+ @Function FM_VSP_ConfigBackupPools
+
+ @Description Calling this routine allows the configuration of some of the BM pools
+ defined for this port as backup pools.
+ A pool configured to be a backup pool will be used only if all other
+ enabled non-backup pools are depleted.
+
+ @Param[in] h_FmVsp A handle to a FM VSP module.
+ @Param[in] p_BackupBmPools An array of pool id's. All pools specified here will
+ be defined as backup pools.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_VSP_Config() and before FM_VSP_Init().
+*//***************************************************************************/
+t_Error FM_VSP_ConfigBackupPools(t_Handle h_FmVsp, t_FmBackupBmPools *p_BackupBmPools);
+
+/** @} */ /* end of FM_VSP_adv_config_grp group */
+/** @} */ /* end of FM_VSP_init_grp group */
+
+
+/**************************************************************************//**
+ @Group FM_VSP_control_grp FM VSP Control Unit
+
+ @Description FM VSP runtime control API.
+
+ @{
+*//***************************************************************************/
+
+/**************************************************************************//**
+ @Function FM_VSP_GetBufferDataOffset
+
+ @Description Relevant for Rx ports.
+ Returns the data offset from the beginning of the data buffer
+
+ @Param[in] h_FmVsp - FM PORT module descriptor
+
+ @Return data offset.
+
+ @Cautions Allowed only following FM_VSP_Init().
+*//***************************************************************************/
+uint32_t FM_VSP_GetBufferDataOffset(t_Handle h_FmVsp);
+
+/**************************************************************************//**
+ @Function FM_VSP_GetBufferICInfo
+
+ @Description Returns the Internal Context offset from the beginning of the data buffer
+
+ @Param[in] h_FmVsp - FM PORT module descriptor
+ @Param[in] p_Data - A pointer to the data buffer.
+
+ @Return Internal context info pointer on success, NULL if 'allOtherInfo' was not
+ configured for this port.
+
+ @Cautions Allowed only following FM_VSP_Init().
+*//***************************************************************************/
+uint8_t * FM_VSP_GetBufferICInfo(t_Handle h_FmVsp, char *p_Data);
+
+/**************************************************************************//**
+ @Function FM_VSP_GetBufferPrsResult
+
+ @Description Returns the pointer to the parse result in the data buffer.
+ In Rx ports this is relevant after reception, if parse
+ result is configured to be part of the data passed to the
+ application. For non Rx ports it may be used to get the pointer
+ of the area in the buffer where parse result should be
+ initialized - if so configured.
+ See FM_VSP_ConfigBufferPrefixContent for data buffer prefix
+ configuration.
+
+ @Param[in] h_FmVsp - FM PORT module descriptor
+ @Param[in] p_Data - A pointer to the data buffer.
+
+ @Return Parse result pointer on success, NULL if parse result was not
+ configured for this port.
+
+ @Cautions Allowed only following FM_VSP_Init().
+*//***************************************************************************/
+t_FmPrsResult * FM_VSP_GetBufferPrsResult(t_Handle h_FmVsp, char *p_Data);
+
+/**************************************************************************//**
+ @Function FM_VSP_GetBufferTimeStamp
+
+ @Description Returns the time stamp in the data buffer.
+ Relevant for Rx ports for getting the buffer time stamp.
+ See FM_VSP_ConfigBufferPrefixContent for data buffer prefix
+ configuration.
+
+ @Param[in] h_FmVsp - FM PORT module descriptor
+ @Param[in] p_Data - A pointer to the data buffer.
+
+ @Return A pointer to the hash result on success, NULL otherwise.
+
+ @Cautions Allowed only following FM_VSP_Init().
+*//***************************************************************************/
+uint64_t * FM_VSP_GetBufferTimeStamp(t_Handle h_FmVsp, char *p_Data);
+
+/**************************************************************************//**
+ @Function FM_VSP_GetBufferHashResult
+
+ @Description Given a data buffer, on the condition that hash result was defined
+ as a part of the buffer content (see FM_VSP_ConfigBufferPrefixContent)
+ this routine will return the pointer to the hash result location in the
+ buffer prefix.
+
+ @Param[in] h_FmVsp - FM PORT module descriptor
+ @Param[in] p_Data - A pointer to the data buffer.
+
+ @Return A pointer to the hash result on success, NULL otherwise.
+
+ @Cautions Allowed only following FM_VSP_Init().
+*//***************************************************************************/
+uint8_t * FM_VSP_GetBufferHashResult(t_Handle h_FmVsp, char *p_Data);
+
+
+/** @} */ /* end of FM_VSP_control_grp group */
+/** @} */ /* end of FM_VSP_grp group */
+/** @} */ /* end of FM_grp group */
+
+
+#endif /* __FM_VSP_EXT_H */
diff --git a/sys/contrib/ncsw/inc/Peripherals/mii_acc_ext.h b/sys/contrib/ncsw/inc/Peripherals/mii_acc_ext.h
new file mode 100644
index 000000000000..f635d3c24de0
--- /dev/null
+++ b/sys/contrib/ncsw/inc/Peripherals/mii_acc_ext.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+
+#ifndef __MII_ACC_EXT_H
+#define __MII_ACC_EXT_H
+
+
+/**************************************************************************//**
+ @Function MII_ReadPhyReg
+
+ @Description This routine is called to read a specified PHY
+ register value.
+
+ @Param[in] h_MiiAccess - Handle to MII configuration access registers
+ @Param[in] phyAddr - PHY address (0-31).
+ @Param[in] reg - PHY register to read
+ @Param[out] p_Data - Gets the register value.
+
+ @Return Always zero (success).
+*//***************************************************************************/
+int MII_ReadPhyReg(t_Handle h_MiiAccess,
+ uint8_t phyAddr,
+ uint8_t reg,
+ uint16_t *p_Data);
+
+/**************************************************************************//**
+ @Function MII_WritePhyReg
+
+ @Description This routine is called to write data to a specified PHY
+ register.
+
+ @Param[in] h_MiiAccess - Handle to MII configuration access registers
+ @Param[in] phyAddr - PHY address (0-31).
+ @Param[in] reg - PHY register to write
+ @Param[in] data - Data to write in register.
+
+ @Return Always zero (success).
+*//***************************************************************************/
+int MII_WritePhyReg(t_Handle h_MiiAccess,
+ uint8_t phyAddr,
+ uint8_t reg,
+ uint16_t data);
+
+
+#endif /* __MII_ACC_EXT_H */
diff --git a/sys/contrib/ncsw/inc/Peripherals/qm_ext.h b/sys/contrib/ncsw/inc/Peripherals/qm_ext.h
index 98f4b37892d7..6a4bc9fcfe6f 100644
--- a/sys/contrib/ncsw/inc/Peripherals/qm_ext.h
+++ b/sys/contrib/ncsw/inc/Peripherals/qm_ext.h
@@ -627,7 +627,7 @@ typedef struct {
uintptr_t ciBaseAddress; /**< Cache-inhibited base address (virtual) */
t_Handle h_Qm; /**< Qm Handle */
e_DpaaSwPortal swPortalId; /**< Portal id */
- int irq; /**< portal interrupt line; used only if useIrq set to TRUE */
+ uintptr_t irq; /**< portal interrupt line; used only if useIrq set to TRUE */
uint16_t fdLiodnOffset; /**< liodn to be used for all frames enqueued via this software portal */
t_QmReceivedFrameCallback *f_DfltFrame; /**< this callback will be called unless specific callback assigned to the FQ*/
t_QmRejectedFrameCallback *f_RejectedFrame; /**< this callback will be called for rejected frames. */
diff --git a/sys/contrib/ncsw/inc/core_ext.h b/sys/contrib/ncsw/inc/core_ext.h
index 022de2b30e5c..ec89a6dde4cd 100644
--- a/sys/contrib/ncsw/inc/core_ext.h
+++ b/sys/contrib/ncsw/inc/core_ext.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File core_ext.h
@@ -42,7 +43,10 @@
#ifndef __CORE_EXT_H
#define __CORE_EXT_H
-
+#ifdef CONFIG_FMAN_ARM
+#include "arm_ext.h"
+#include <linux/smp.h>
+#else
#ifdef NCSW_PPC_CORE
#include "ppc_ext.h"
#elif defined(NCSW_VXWORKS)
@@ -55,6 +59,12 @@
#error "Must define core as little-endian or big-endian!"
#endif /* (!defined(CORE_IS_LITTLE_ENDIAN) && ... */
+#ifndef CORE_CACHELINE_SIZE
+#error "Must define the core cache-line size!"
+#endif /* !CORE_CACHELINE_SIZE */
+
+#endif /* CONFIG_FMAN_ARM */
+
/**************************************************************************//**
@Function CORE_GetId
@@ -75,7 +85,6 @@ uint32_t CORE_GetId(void);
@Return None.
*//***************************************************************************/
void CORE_MemoryBarrier(void);
-
+#define fsl_mem_core_barrier() CORE_MemoryBarrier()
#endif /* __CORE_EXT_H */
-
diff --git a/sys/contrib/ncsw/inc/cores/arm_ext.h b/sys/contrib/ncsw/inc/cores/arm_ext.h
new file mode 100644
index 000000000000..e63444a7d676
--- /dev/null
+++ b/sys/contrib/ncsw/inc/cores/arm_ext.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/**************************************************************************//**
+ @File arm_ext.h
+
+ @Description Core API for ARM cores
+
+ These routines must be implemented by each specific PowerPC
+ core driver.
+*//***************************************************************************/
+#ifndef __ARM_EXT_H
+#define __ARM_EXT_H
+
+#include "part_ext.h"
+
+
+#define CORE_IS_LITTLE_ENDIAN
+
+static __inline__ void CORE_MemoryBarrier(void)
+{
+ mb();
+}
+
+#endif /* __PPC_EXT_H */
diff --git a/sys/contrib/ncsw/inc/cores/e500v2_ext.h b/sys/contrib/ncsw/inc/cores/e500v2_ext.h
index df545ff4b2de..e79b1ddff121 100644
--- a/sys/contrib/ncsw/inc/cores/e500v2_ext.h
+++ b/sys/contrib/ncsw/inc/cores/e500v2_ext.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File e500v2_ext.h
@@ -58,6 +59,8 @@ void L1DCache_Disable(void);
void L1ICache_Disable(void);
void L1DCache_Flush(void);
void L1ICache_Flush(void);
+uint32_t L1ICache_IsEnabled(void);
+uint32_t L1DCache_IsEnabled(void);
/*
*
*/
@@ -193,6 +196,7 @@ typedef enum e_E500mcL2CacheMode
e_L2_CACHE_MODE_DATA_AND_INST = 0x00000003 /**< Cache data and instructions */
} e_E500mcL2CacheMode;
+#if defined(CORE_E500MC) || defined(CORE_E5500)
/**************************************************************************//**
@Function E500_L2CacheEnable
@@ -237,6 +241,65 @@ void E500_L2CacheFlush(void);
@Return None.
*//***************************************************************************/
void E500_L2SetStashId(uint8_t stashId);
+#endif /* defined(CORE_E500MC) || defined(CORE_E5500) */
+
+#ifdef CORE_E6500
+/**************************************************************************//**
+ @Function E6500_L2CacheEnable
+
+ @Description Enables the cache for memory pages that are not cache inhibited.
+
+ @param[in] mode - L2 cache mode: support data & instruction only.
+
+ @Return None.
+
+ @Cautions This routine must be call only ONCE for both caches. I.e. it is
+ not possible to call this routine for i-cache and than to call
+ again for d-cache; The second call will override the first one.
+*//***************************************************************************/
+void E6500_L2CacheEnable(uintptr_t clusterBase);
+
+/**************************************************************************//**
+ @Function E6500_L2CacheDisable
+
+ @Description Disables the cache (data instruction or both).
+
+ @Return None.
+
+*//***************************************************************************/
+void E6500_L2CacheDisable(uintptr_t clusterBase);
+
+/**************************************************************************//**
+ @Function E6500_L2CacheFlush
+
+ @Description Flushes the cache.
+
+ @Return None.
+*//***************************************************************************/
+void E6500_L2CacheFlush(uintptr_t clusterBase);
+
+/**************************************************************************//**
+ @Function E6500_L2SetStashId
+
+ @Description Set Stash Id
+
+ @Param[in] stashId the stash id to be set.
+
+ @Return None.
+*//***************************************************************************/
+void E6500_L2SetStashId(uintptr_t clusterBase, uint8_t stashId);
+
+/**************************************************************************//**
+ @Function E6500_GetCcsrBase
+
+ @Description Obtain SoC CCSR base address
+
+ @Param[in] None.
+
+ @Return Physical CCSR base address.
+*//***************************************************************************/
+physAddress_t E6500_GetCcsrBase(void);
+#endif /* CORE_E6500 */
/**************************************************************************//**
@Function E500_AddressBusStreamingEnable
@@ -374,9 +437,9 @@ int E500_TestAndSet(volatile int *p);
*//***************************************************************************/
static __inline__ void E500_MemoryBarrier(void)
{
-#ifdef CORE_E500MC
+#ifndef CORE_E500V2
__asm__ ("mbar 1");
-#else
+#else /* CORE_E500V2 */
/**** ERRATA WORK AROUND START ****/
/* ERRATA num: CPU1 */
/* Description: "mbar MO = 1" instruction fails to order caching-inhibited
@@ -387,7 +450,7 @@ static __inline__ void E500_MemoryBarrier(void)
__asm__ ("msync");
/**** ERRATA WORK AROUND END ****/
-#endif
+#endif /* CORE_E500V2 */
}
/**************************************************************************//**
diff --git a/sys/contrib/ncsw/inc/cores/ppc_ext.h b/sys/contrib/ncsw/inc/cores/ppc_ext.h
index e045c3173bc9..6639affd4e71 100644
--- a/sys/contrib/ncsw/inc/cores/ppc_ext.h
+++ b/sys/contrib/ncsw/inc/cores/ppc_ext.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File ppc_ext.h
@@ -46,6 +47,14 @@
#define CORE_IS_BIG_ENDIAN
+#if defined(CORE_E300) || defined(CORE_E500V2)
+#define CORE_CACHELINE_SIZE 32
+#elif defined(CORE_E500MC) || defined(CORE_E5500) || defined(CORE_E6500)
+#define CORE_CACHELINE_SIZE 64
+#else
+#error "Core not defined!"
+#endif /* defined(CORE_E300) || ... */
+
/**************************************************************************//**
@Function CORE_TestAndSet
@@ -117,14 +126,6 @@ void CORE_ICacheDisable(void);
-
-#if defined(CORE_E300)
-#include "e300_ext.h"
-#elif defined(CORE_E500V2) || defined(CORE_E500MC)
#include "e500v2_ext.h"
-#else
-#error "Core not defined!"
-#endif
-
#endif /* __PPC_EXT_H */
diff --git a/sys/contrib/ncsw/inc/ddr_std_ext.h b/sys/contrib/ncsw/inc/ddr_std_ext.h
index c4d9ed66f433..8bb343fc2852 100644
--- a/sys/contrib/ncsw/inc/ddr_std_ext.h
+++ b/sys/contrib/ncsw/inc/ddr_std_ext.h
@@ -1,38 +1,34 @@
-/******************************************************************************
-
- © 1995-2003, 2004, 2005-2011 Freescale Semiconductor, Inc.
- All rights reserved.
-
- This is proprietary source code of Freescale Semiconductor Inc.,
- and its use is subject to the NetComm Device Drivers EULA.
- The copyright notice above does not evidence any actual or intended
- publication of such source code.
-
- ALTERNATIVELY, redistribution and use in source and binary forms, with
- or without modification, are permitted provided that the following
- conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of Freescale Semiconductor nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
-
- **************************************************************************/
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
#ifndef __DDR_SDT_EXT_H
#define __DDR_SDT_EXT_H
@@ -60,7 +56,8 @@ typedef enum e_DdrType
e_DDR_DDR1,
e_DDR_DDR2,
e_DDR_DDR3,
- e_DDR_DDR3L
+ e_DDR_DDR3L,
+ e_DDR_DDR4
} e_DdrType;
/**************************************************************************//**
diff --git a/sys/contrib/ncsw/inc/debug_ext.h b/sys/contrib/ncsw/inc/debug_ext.h
index 37f5b83af5e2..57db0a1486cd 100644
--- a/sys/contrib/ncsw/inc/debug_ext.h
+++ b/sys/contrib/ncsw/inc/debug_ext.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File debug_ext.h
@@ -54,24 +55,26 @@
#define DUMP_Print XX_Print
#define DUMP_MAX_LEVELS 6
+#define DUMP_IDX_LEN 6
#define DUMP_MAX_STR 64
#define _CREATE_DUMP_SUBSTR(phrase) \
dumpTmpLevel = 0; dumpSubStr[0] = '\0'; \
- sprintf(dumpTmpStr, "%s", #phrase); \
+ snprintf(dumpTmpStr, DUMP_MAX_STR, "%s", #phrase); \
p_DumpToken = strtok(dumpTmpStr, (dumpIsArr[0] ? "[" : ".")); \
- while (p_DumpToken != NULL) \
+ while ((p_DumpToken != NULL) && (dumpTmpLevel < DUMP_MAX_LEVELS)) \
{ \
- strcat(dumpSubStr, p_DumpToken); \
+ strlcat(dumpSubStr, p_DumpToken, DUMP_MAX_STR); \
if (dumpIsArr[dumpTmpLevel]) \
{ \
- strcat(dumpSubStr, dumpIdxStr[dumpTmpLevel]); \
+ strlcat(dumpSubStr, dumpIdxStr[dumpTmpLevel], DUMP_MAX_STR); \
p_DumpToken = strtok(NULL, "."); \
} \
- if ((p_DumpToken = strtok(NULL, (dumpIsArr[++dumpTmpLevel] ? "[" : "."))) != 0) \
- strcat(dumpSubStr, "."); \
- }\
+ if ((p_DumpToken != NULL) && \
+ ((p_DumpToken = strtok(NULL, (dumpIsArr[++dumpTmpLevel] ? "[" : "."))) != NULL)) \
+ strlcat(dumpSubStr, ".", DUMP_MAX_STR); \
+ }
/**************************************************************************//**
@@ -98,11 +101,11 @@
starts.
*//***************************************************************************/
#define DECLARE_DUMP \
- char dumpIdxStr[DUMP_MAX_LEVELS + 1][6] = { "", }; \
+ char dumpIdxStr[DUMP_MAX_LEVELS + 1][DUMP_IDX_LEN] = { "", }; \
char dumpSubStr[DUMP_MAX_STR] = ""; \
char dumpTmpStr[DUMP_MAX_STR] = ""; \
char *p_DumpToken = NULL; \
- int dumpArrIdx = 0, dumpArrSize = 0, dumpVarSize = 0, dumpLevel = 0, dumpTmpLevel = 0; \
+ int dumpArrIdx = 0, dumpArrSize = 0, dumpLevel = 0, dumpTmpLevel = 0; \
uint8_t dumpIsArr[DUMP_MAX_LEVELS + 1] = { 0 }; \
/* Prevent warnings if not all used */ \
UNUSED(dumpIdxStr[0][0]); \
@@ -111,7 +114,6 @@
UNUSED(p_DumpToken); \
UNUSED(dumpArrIdx); \
UNUSED(dumpArrSize); \
- UNUSED(dumpVarSize); \
UNUSED(dumpLevel); \
UNUSED(dumpTmpLevel); \
UNUSED(dumpIsArr[0]);
@@ -123,11 +125,11 @@
The inputs for this macro are the structure/memory title and
its base addresses.
*//***************************************************************************/
-#define DUMP_TITLE(addr, msg) \
+#define DUMP_TITLE(addr, msg) \
DUMP_Print("\r\n"); DUMP_Print msg; \
- DUMP_Print(" (0x%p)\r\n" \
- "---------------------------------------------------------\r\n", \
- (addr))
+ if (addr) \
+ DUMP_Print(" (%p)", (addr)); \
+ DUMP_Print("\r\n---------------------------------------------------------\r\n");
/**************************************************************************//**
@Description Prints a subtitle for a subsequent dumped sub-structure (optional).
@@ -163,8 +165,8 @@
*//***************************************************************************/
#define DUMP_SUBSTRUCT_ARRAY(idx, cnt) \
for (idx=0, dumpIsArr[dumpLevel++] = 1; \
- (idx < cnt) && sprintf(dumpIdxStr[dumpLevel-1], "[%d]", idx); \
- idx++, ((idx < cnt) || ((dumpIsArr[--dumpLevel] = 0) == 0)))
+ (idx < cnt) && (dumpLevel > 0) && snprintf(dumpIdxStr[dumpLevel-1], DUMP_IDX_LEN, "[%d]", idx); \
+ idx++, ((idx < cnt) || (dumpIsArr[--dumpLevel] = 0)))
/**************************************************************************//**
@@ -185,21 +187,11 @@
*//***************************************************************************/
#define DUMP_VAR(st, phrase) \
do { \
- void *addr = (void *)&((st)->phrase); \
+ void *addr = (void *)&((st)->phrase); \
+ physAddress_t physAddr = XX_VirtToPhys(addr); \
_CREATE_DUMP_SUBSTR(phrase); \
- dumpVarSize = sizeof((st)->phrase); \
- switch (dumpVarSize) \
- { \
- case 1: DUMP_Print("0x%08X: 0x%02x%14s\t%s\r\n", \
- addr, GET_UINT8(*(uint8_t*)addr), "", dumpSubStr); break; \
- case 2: DUMP_Print("0x%08X: 0x%04x%12s\t%s\r\n", \
- addr, GET_UINT16(*(uint16_t*)addr), "", dumpSubStr); break; \
- case 4: DUMP_Print("0x%08X: 0x%08x%8s\t%s\r\n", \
- addr, GET_UINT32(*(uint32_t*)addr), "", dumpSubStr); break; \
- case 8: DUMP_Print("0x%08X: 0x%016llx\t%s\r\n", \
- addr, GET_UINT64(*(uint64_t*)addr), dumpSubStr); break; \
- default: DUMP_Print("Bad size %d (" #st "->" #phrase ")\r\n", dumpVarSize); \
- } \
+ DUMP_Print("0x%010llX: 0x%08x%8s\t%s\r\n", \
+ physAddr, GET_UINT32(*(uint32_t*)addr), "", dumpSubStr); \
} while (0)
@@ -218,36 +210,18 @@
*//***************************************************************************/
#define DUMP_ARR(st, phrase) \
do { \
+ physAddress_t physAddr; \
_CREATE_DUMP_SUBSTR(phrase); \
dumpArrSize = ARRAY_SIZE((st)->phrase); \
- dumpVarSize = sizeof((st)->phrase[0]); \
- switch (dumpVarSize) \
- { \
- case 1: \
- for (dumpArrIdx=0; dumpArrIdx < dumpArrSize; dumpArrIdx++) { \
- DUMP_Print("0x%08X: 0x%02x%14s\t%s[%d]\r\n", \
- &((st)->phrase[dumpArrIdx]), GET_UINT8((st)->phrase[dumpArrIdx]), "", dumpSubStr, dumpArrIdx); \
- } break; \
- case 2: \
- for (dumpArrIdx=0; dumpArrIdx < dumpArrSize; dumpArrIdx++) { \
- DUMP_Print("0x%08X: 0x%04x%12s\t%s[%d]\r\n", \
- &((st)->phrase[dumpArrIdx]), GET_UINT16((st)->phrase[dumpArrIdx]), "", dumpSubStr, dumpArrIdx); \
- } break; \
- case 4: \
- for (dumpArrIdx=0; dumpArrIdx < dumpArrSize; dumpArrIdx++) { \
- DUMP_Print("0x%08X: 0x%08x%8s\t%s[%d]\r\n", \
- &((st)->phrase[dumpArrIdx]), GET_UINT32((st)->phrase[dumpArrIdx]), "", dumpSubStr, dumpArrIdx); \
- } break; \
- case 8: \
- for (dumpArrIdx=0; dumpArrIdx < dumpArrSize; dumpArrIdx++) { \
- DUMP_Print("0x%08X: 0x%016llx\t%s[%d]\r\n", \
- &((st)->phrase[dumpArrIdx]), GET_UINT64((st)->phrase[dumpArrIdx]), dumpSubStr, dumpArrIdx); \
- } break; \
- default: DUMP_Print("Bad size %d (" #st "->" #phrase "[0])\r\n", dumpVarSize); \
+ for (dumpArrIdx=0; dumpArrIdx < dumpArrSize; dumpArrIdx++) { \
+ physAddr = XX_VirtToPhys((void *)&((st)->phrase[dumpArrIdx])); \
+ DUMP_Print("0x%010llX: 0x%08x%8s\t%s[%d]\r\n", \
+ physAddr, GET_UINT32((st)->phrase[dumpArrIdx]), "", dumpSubStr, dumpArrIdx); \
} \
} while (0)
+
#endif /* DEBUG_ERRORS > 0 */
diff --git a/sys/contrib/ncsw/inc/endian_ext.h b/sys/contrib/ncsw/inc/endian_ext.h
index 7084e8285a0d..5cdec668aedf 100644
--- a/sys/contrib/ncsw/inc/endian_ext.h
+++ b/sys/contrib/ncsw/inc/endian_ext.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File endian_ext.h
diff --git a/sys/contrib/ncsw/inc/enet_ext.h b/sys/contrib/ncsw/inc/enet_ext.h
index 14f7760b72bc..ef3bee55e897 100644
--- a/sys/contrib/ncsw/inc/enet_ext.h
+++ b/sys/contrib/ncsw/inc/enet_ext.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
+/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File enet_ext.h
@@ -39,6 +40,7 @@
#ifndef __ENET_EXT_H
#define __ENET_EXT_H
+#include "fsl_enet.h"
#define ENET_NUM_OCTETS_PER_ADDRESS 6 /**< Number of octets (8-bit bytes) in an ethernet address */
#define ENET_GROUP_ADDR 0x01 /**< Group address mask for ethernet addresses */
@@ -59,24 +61,32 @@ typedef enum e_EnetAddrType
e_ENET_ADDR_TYPE_BROADCAST /**< Broadcast address */
} e_EnetAddrType;
-
/**************************************************************************//**
@Description Ethernet MAC-PHY Interface
*//***************************************************************************/
typedef enum e_EnetInterface
{
- e_ENET_IF_MII = 0x00010000, /**< MII interface */
- e_ENET_IF_RMII = 0x00020000, /**< RMII interface */
- e_ENET_IF_SMII = 0x00030000, /**< SMII interface */
- e_ENET_IF_GMII = 0x00040000, /**< GMII interface */
- e_ENET_IF_RGMII = 0x00050000, /**< RGMII interface */
- e_ENET_IF_TBI = 0x00060000, /**< TBI interface */
- e_ENET_IF_RTBI = 0x00070000, /**< RTBI interface */
- e_ENET_IF_SGMII = 0x00080000, /**< SGMII interface */
- e_ENET_IF_XGMII = 0x00090000, /**< XGMII interface */
- e_ENET_IF_QSGMII= 0x000a0000 /**< QSGMII interface */
+ e_ENET_IF_MII = E_ENET_IF_MII, /**< MII interface */
+ e_ENET_IF_RMII = E_ENET_IF_RMII, /**< RMII interface */
+ e_ENET_IF_SMII = E_ENET_IF_SMII, /**< SMII interface */
+ e_ENET_IF_GMII = E_ENET_IF_GMII, /**< GMII interface */
+ e_ENET_IF_RGMII = E_ENET_IF_RGMII, /**< RGMII interface */
+ e_ENET_IF_TBI = E_ENET_IF_TBI, /**< TBI interface */
+ e_ENET_IF_RTBI = E_ENET_IF_RTBI, /**< RTBI interface */
+ e_ENET_IF_SGMII = E_ENET_IF_SGMII, /**< SGMII interface */
+ e_ENET_IF_XGMII = E_ENET_IF_XGMII, /**< XGMII interface */
+ e_ENET_IF_QSGMII= E_ENET_IF_QSGMII, /**< QSGMII interface */
+ e_ENET_IF_XFI = E_ENET_IF_XFI /**< XFI interface */
} e_EnetInterface;
+#define ENET_IF_SGMII_BASEX 0x80000000 /**< SGMII/QSGII interface with 1000BaseX
+ auto-negotiation between MAC and phy
+ or backplane;
+ Note: 1000BaseX auto-negotiation relates
+ only to interface between MAC and phy/backplane,
+ SGMII phy can still synchronize with far-end phy
+ at 10Mbps, 100Mbps or 1000Mbps */
+
/**************************************************************************//**
@Description Ethernet Duplex Mode
*//***************************************************************************/
@@ -91,10 +101,11 @@ typedef enum e_EnetDuplexMode
*//***************************************************************************/
typedef enum e_EnetSpeed
{
- e_ENET_SPEED_10 = 10, /**< 10 Mbps */
- e_ENET_SPEED_100 = 100, /**< 100 Mbps */
- e_ENET_SPEED_1000 = 1000, /**< 1000 Mbps = 1 Gbps */
- e_ENET_SPEED_10000 = 10000 /**< 10000 Mbps = 10 Gbps */
+ e_ENET_SPEED_10 = E_ENET_SPEED_10, /**< 10 Mbps */
+ e_ENET_SPEED_100 = E_ENET_SPEED_100, /**< 100 Mbps */
+ e_ENET_SPEED_1000 = E_ENET_SPEED_1000, /**< 1000 Mbps = 1 Gbps */
+ e_ENET_SPEED_2500 = E_ENET_SPEED_2500, /**< 2500 Mbps = 2.5 Gbps */
+ e_ENET_SPEED_10000 = E_ENET_SPEED_10000 /**< 10000 Mbps = 10 Gbps */
} e_EnetSpeed;
/**************************************************************************//**
@@ -102,24 +113,46 @@ typedef enum e_EnetSpeed
*//***************************************************************************/
typedef enum e_EnetMode
{
- e_ENET_MODE_INVALID = 0, /**< Invalid Ethernet mode */
- e_ENET_MODE_MII_10 = (e_ENET_IF_MII | e_ENET_SPEED_10), /**< 10 Mbps MII */
- e_ENET_MODE_MII_100 = (e_ENET_IF_MII | e_ENET_SPEED_100), /**< 100 Mbps MII */
- e_ENET_MODE_RMII_10 = (e_ENET_IF_RMII | e_ENET_SPEED_10), /**< 10 Mbps RMII */
- e_ENET_MODE_RMII_100 = (e_ENET_IF_RMII | e_ENET_SPEED_100), /**< 100 Mbps RMII */
- e_ENET_MODE_SMII_10 = (e_ENET_IF_SMII | e_ENET_SPEED_10), /**< 10 Mbps SMII */
- e_ENET_MODE_SMII_100 = (e_ENET_IF_SMII | e_ENET_SPEED_100), /**< 100 Mbps SMII */
- e_ENET_MODE_GMII_1000 = (e_ENET_IF_GMII | e_ENET_SPEED_1000), /**< 1000 Mbps GMII */
- e_ENET_MODE_RGMII_10 = (e_ENET_IF_RGMII | e_ENET_SPEED_10), /**< 10 Mbps RGMII */
- e_ENET_MODE_RGMII_100 = (e_ENET_IF_RGMII | e_ENET_SPEED_100), /**< 100 Mbps RGMII */
- e_ENET_MODE_RGMII_1000 = (e_ENET_IF_RGMII | e_ENET_SPEED_1000), /**< 1000 Mbps RGMII */
- e_ENET_MODE_TBI_1000 = (e_ENET_IF_TBI | e_ENET_SPEED_1000), /**< 1000 Mbps TBI */
- e_ENET_MODE_RTBI_1000 = (e_ENET_IF_RTBI | e_ENET_SPEED_1000), /**< 1000 Mbps RTBI */
- e_ENET_MODE_SGMII_10 = (e_ENET_IF_SGMII | e_ENET_SPEED_10), /**< 10 Mbps SGMII */
- e_ENET_MODE_SGMII_100 = (e_ENET_IF_SGMII | e_ENET_SPEED_100), /**< 100 Mbps SGMII */
- e_ENET_MODE_SGMII_1000 = (e_ENET_IF_SGMII | e_ENET_SPEED_1000), /**< 1000 Mbps SGMII */
- e_ENET_MODE_XGMII_10000 = (e_ENET_IF_XGMII | e_ENET_SPEED_10000), /**< 10000 Mbps XGMII */
- e_ENET_MODE_QSGMII_1000 = (e_ENET_IF_QSGMII| e_ENET_SPEED_1000) /**< 1000 Mbps QSGMII */
+ e_ENET_MODE_INVALID = 0, /**< Invalid Ethernet mode */
+ e_ENET_MODE_MII_10 = (e_ENET_IF_MII | e_ENET_SPEED_10), /**< 10 Mbps MII */
+ e_ENET_MODE_MII_100 = (e_ENET_IF_MII | e_ENET_SPEED_100), /**< 100 Mbps MII */
+ e_ENET_MODE_RMII_10 = (e_ENET_IF_RMII | e_ENET_SPEED_10), /**< 10 Mbps RMII */
+ e_ENET_MODE_RMII_100 = (e_ENET_IF_RMII | e_ENET_SPEED_100), /**< 100 Mbps RMII */
+ e_ENET_MODE_SMII_10 = (e_ENET_IF_SMII | e_ENET_SPEED_10), /**< 10 Mbps SMII */
+ e_ENET_MODE_SMII_100 = (e_ENET_IF_SMII | e_ENET_SPEED_100), /**< 100 Mbps SMII */
+ e_ENET_MODE_GMII_1000 = (e_ENET_IF_GMII | e_ENET_SPEED_1000), /**< 1000 Mbps GMII */
+ e_ENET_MODE_RGMII_10 = (e_ENET_IF_RGMII | e_ENET_SPEED_10), /**< 10 Mbps RGMII */
+ e_ENET_MODE_RGMII_100 = (e_ENET_IF_RGMII | e_ENET_SPEED_100), /**< 100 Mbps RGMII */
+ e_ENET_MODE_RGMII_1000 = (e_ENET_IF_RGMII | e_ENET_SPEED_1000), /**< 1000 Mbps RGMII */
+ e_ENET_MODE_TBI_1000 = (e_ENET_IF_TBI | e_ENET_SPEED_1000), /**< 1000 Mbps TBI */
+ e_ENET_MODE_RTBI_1000 = (e_ENET_IF_RTBI | e_ENET_SPEED_1000), /**< 1000 Mbps RTBI */
+ e_ENET_MODE_SGMII_10 = (e_ENET_IF_SGMII | e_ENET_SPEED_10),
+ /**< 10 Mbps SGMII with auto-negotiation between MAC and
+ SGMII phy according to Cisco SGMII specification */
+ e_ENET_MODE_SGMII_100 = (e_ENET_IF_SGMII | e_ENET_SPEED_100),
+ /**< 100 Mbps SGMII with auto-negotiation between MAC and
+ SGMII phy according to Cisco SGMII specification */
+ e_ENET_MODE_SGMII_1000 = (e_ENET_IF_SGMII | e_ENET_SPEED_1000),
+ /**< 1000 Mbps SGMII with auto-negotiation between MAC and
+ SGMII phy according to Cisco SGMII specification */
+ e_ENET_MODE_SGMII_2500 = (e_ENET_IF_SGMII | e_ENET_SPEED_2500),
+ e_ENET_MODE_SGMII_BASEX_10 = (ENET_IF_SGMII_BASEX | e_ENET_IF_SGMII | e_ENET_SPEED_10),
+ /**< 10 Mbps SGMII with 1000BaseX auto-negotiation between
+ MAC and SGMII phy or backplane */
+ e_ENET_MODE_SGMII_BASEX_100 = (ENET_IF_SGMII_BASEX | e_ENET_IF_SGMII | e_ENET_SPEED_100),
+ /**< 100 Mbps SGMII with 1000BaseX auto-negotiation between
+ MAC and SGMII phy or backplane */
+ e_ENET_MODE_SGMII_BASEX_1000 = (ENET_IF_SGMII_BASEX | e_ENET_IF_SGMII | e_ENET_SPEED_1000),
+ /**< 1000 Mbps SGMII with 1000BaseX auto-negotiation between
+ MAC and SGMII phy or backplane */
+ e_ENET_MODE_QSGMII_1000 = (e_ENET_IF_QSGMII| e_ENET_SPEED_1000),
+ /**< 1000 Mbps QSGMII with auto-negotiation between MAC and
+ QSGMII phy according to Cisco QSGMII specification */
+ e_ENET_MODE_QSGMII_BASEX_1000 = (ENET_IF_SGMII_BASEX | e_ENET_IF_QSGMII| e_ENET_SPEED_1000),
+ /**< 1000 Mbps QSGMII with 1000BaseX auto-negotiation between
+ MAC and QSGMII phy or backplane */
+ e_ENET_MODE_XGMII_10000 = (e_ENET_IF_XGMII | e_ENET_SPEED_10000), /**< 10000 Mbps XGMII */
+ e_ENET_MODE_XFI_10000 = (e_ENET_IF_XFI | e_ENET_SPEED_10000) /**< 10000 Mbps XFI */
} e_EnetMode;
@@ -139,16 +172,34 @@ typedef enum e_EnetMode
((mode) == e_ENET_MODE_SGMII_10 ) || \
((mode) == e_ENET_MODE_SGMII_100 ) || \
((mode) == e_ENET_MODE_SGMII_1000 ) || \
+ ((mode) == e_ENET_MODE_SGMII_BASEX_10 ) || \
+ ((mode) == e_ENET_MODE_SGMII_BASEX_100 ) || \
+ ((mode) == e_ENET_MODE_SGMII_BASEX_1000 ) || \
((mode) == e_ENET_MODE_XGMII_10000) || \
- ((mode) == e_ENET_MODE_QSGMII_1000))
+ ((mode) == e_ENET_MODE_QSGMII_1000) || \
+ ((mode) == e_ENET_MODE_QSGMII_BASEX_1000) || \
+ ((mode) == e_ENET_MODE_XFI_10000))
#define MAKE_ENET_MODE(_interface, _speed) (e_EnetMode)((_interface) | (_speed))
-#define ENET_INTERFACE_FROM_MODE(mode) (e_EnetInterface)((mode) & 0xFFFF0000)
+#define ENET_INTERFACE_FROM_MODE(mode) (e_EnetInterface)((mode) & 0x0FFF0000)
#define ENET_SPEED_FROM_MODE(mode) (e_EnetSpeed)((mode) & 0x0000FFFF)
+#define ENET_ADDR_TO_UINT64(_enetAddr) \
+ (uint64_t)(((uint64_t)(_enetAddr)[0] << 40) | \
+ ((uint64_t)(_enetAddr)[1] << 32) | \
+ ((uint64_t)(_enetAddr)[2] << 24) | \
+ ((uint64_t)(_enetAddr)[3] << 16) | \
+ ((uint64_t)(_enetAddr)[4] << 8) | \
+ ((uint64_t)(_enetAddr)[5]))
+#define MAKE_ENET_ADDR_FROM_UINT64(_addr64, _enetAddr) \
+ do { \
+ int i; \
+ for (i=0; i < ENET_NUM_OCTETS_PER_ADDRESS; i++) \
+ (_enetAddr)[i] = (uint8_t)((_addr64) >> ((5-i)*8)); \
+ } while (0)
-#endif /* __ENET_EXT_H */
+#endif /* __ENET_EXT_H */
diff --git a/sys/contrib/ncsw/inc/error_ext.h b/sys/contrib/ncsw/inc/error_ext.h
index 3963b843e309..7afafe9fbc2b 100644
--- a/sys/contrib/ncsw/inc/error_ext.h
+++ b/sys/contrib/ncsw/inc/error_ext.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
+/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,7 +30,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/**
+
+/**************************************************************************//**
@File error_ext.h
@Description Error definitions.
@@ -39,10 +40,19 @@
#ifndef __ERROR_EXT_H
#define __ERROR_EXT_H
+#if defined(NCSW_FREEBSD)
+#include <sys/param.h>
+#include <sys/errno.h>
+#include <sys/pcpu.h>
+#endif
+
#include "std_ext.h"
#include "xx_ext.h"
#include "core_ext.h"
+
+
+
/**************************************************************************//**
@Group gen_id General Drivers Utilities
@@ -85,18 +95,45 @@ The scheme below provides the bits description for error codes:
typedef enum e_ErrorType /* Comments / Associated Message Strings */
{ /* ------------------------------------------------------------ */
E_OK = 0 /* Never use "RETURN_ERROR" with E_OK; Use "return E_OK;" */
-
- /* Invalid Function Calls */
- ,E_INVALID_STATE /**< The operation is not allowed in current module state. */
+ ,E_WRITE_FAILED = EIO /**< Write access failed on memory/device. */
+ /* String: none, or device name. */
+ ,E_NO_DEVICE = ENXIO /**< The associated device is not initialized. */
/* String: none. */
- ,E_INVALID_OPERATION /**< The operation/command is invalid (unrecognized). */
+ ,E_NOT_AVAILABLE = EAGAIN
+ /**< Resource is unavailable. */
+ /* String: none, unless the operation is not the main goal
+ of the function (in this case add resource description). */
+ ,E_NO_MEMORY = ENOMEM /**< External memory allocation failed. */
+ /* String: description of item for which allocation failed. */
+ ,E_INVALID_ADDRESS = EFAULT
+ /**< Invalid address. */
+ /* String: description of the specific violation. */
+ ,E_BUSY = EBUSY /**< Resource or module is busy. */
+ /* String: none, unless the operation is not the main goal
+ of the function (in this case add resource description). */
+ ,E_ALREADY_EXISTS = EEXIST
+ /**< Requested resource or item already exists. */
+ /* Use when resource duplication or sharing are not allowed.
+ String: none, unless the operation is not the main goal
+ of the function (in this case add item description). */
+ ,E_INVALID_OPERATION = ENODEV
+ /**< The operation/command is invalid (unrecognized). */
/* String: none. */
- ,E_NOT_SUPPORTED /**< The function is not supported or not implemented. */
+ ,E_INVALID_VALUE = EDOM /**< Invalid value. */
+ /* Use for non-enumeration parameters, and
+ only when other error types are not suitable.
+ String: parameter description + "(should be <attribute>)",
+ e.g: "Maximum Rx buffer length (should be divisible by 8)",
+ "Channel number (should be even)". */
+ ,E_NOT_IN_RANGE = ERANGE/**< Parameter value is out of range. */
+ /* Don't use this error for enumeration parameters.
+ String: parameter description + "(should be %d-%d)",
+ e.g: "Number of pad characters (should be 0-15)". */
+ ,E_NOT_SUPPORTED = ENOSYS
+ /**< The function is not supported or not implemented. */
/* String: none. */
- ,E_NO_DEVICE /**< The associated device is not initialized. */
+ ,E_INVALID_STATE /**< The operation is not allowed in current module state. */
/* String: none. */
-
- /* Invalid Parameters */
,E_INVALID_HANDLE /**< Invalid handle of module or object. */
/* String: none, unless the function takes in more than one
handle (in this case add the handle description) */
@@ -105,12 +142,6 @@ typedef enum e_ErrorType /* Comments / Associated Message Strings
ID (in this case add the ID description) */
,E_NULL_POINTER /**< Unexpected NULL pointer. */
/* String: pointer description. */
- ,E_INVALID_VALUE /**< Invalid value. */
- /* Use for non-enumeration parameters, and
- only when other error types are not suitable.
- String: parameter description + "(should be <attribute>)",
- e.g: "Maximum Rx buffer length (should be divisible by 8)",
- "Channel number (should be even)". */
,E_INVALID_SELECTION /**< Invalid selection or mode. */
/* Use for enumeration values, only when other error types
are not suitable.
@@ -119,101 +150,47 @@ typedef enum e_ErrorType /* Comments / Associated Message Strings
/* String: none, unless the function takes in more than one
communication mode indications (in this case add
parameter description). */
- ,E_INVALID_BYTE_ORDER /**< Invalid byte order. */
- /* String: none, unless the function takes in more than one
- byte order indications (in this case add parameter
- description). */
,E_INVALID_MEMORY_TYPE /**< Invalid memory type. */
/* String: none, unless the function takes in more than one
memory types (in this case add memory description,
e.g: "Data memory", "Buffer descriptors memory"). */
- ,E_INVALID_INTR_QUEUE /**< Invalid interrupt queue. */
- /* String: none, unless the function takes in more than one
- interrupt queues (in this case add queue description,
- e.g: "Rx interrupt queue", "Tx interrupt queue"). */
- ,E_INVALID_PRIORITY /**< Invalid priority. */
- /* String: none, unless the function takes in more than one
- priority (in this case add priority description). */
,E_INVALID_CLOCK /**< Invalid clock. */
/* String: none, unless the function takes in more than one
clocks (in this case add clock description,
e.g: "Rx clock", "Tx clock"). */
- ,E_INVALID_RATE /**< Invalid rate value. */
- /* String: none, unless the function takes in more than one
- rate values (in this case add rate description). */
- ,E_INVALID_ADDRESS /**< Invalid address. */
- /* String: description of the specific violation. */
- ,E_INVALID_BUS /**< Invalid bus type. */
- /* String: none, unless the function takes in more than one
- bus parameters (in this case add bus description). */
- ,E_BUS_CONFLICT /**< Bus (or memory) type conflicts with another setting. */
- /* String: description of the conflicting buses/memories. */
,E_CONFLICT /**< Some setting conflicts with another setting. */
/* String: description of the conflicting settings. */
,E_NOT_ALIGNED /**< Non-aligned address. */
/* String: parameter description + "(should be %d-bytes aligned)",
e.g: "Rx data buffer (should be 32-bytes aligned)". */
- ,E_NOT_IN_RANGE /**< Parameter value is out of range. */
- /* Don't use this error for enumeration parameters.
- String: parameter description + "(should be %d-%d)",
- e.g: "Number of pad characters (should be 0-15)". */
-
- /* Frame/Buffer Errors */
- ,E_INVALID_FRAME /**< Invalid frame object (NULL handle or missing buffers). */
- /* String: none. */
- ,E_EMPTY_FRAME /**< Frame object is empty (has no buffers). */
- /* String: none. */
- ,E_EMPTY_BUFFER /**< Buffer object is empty (no data, or zero data length). */
- /* String: none. */
-
- /* Resource Errors */
- ,E_NO_MEMORY /**< External memory allocation failed. */
- /* String: description of item for which allocation failed. */
,E_NOT_FOUND /**< Requested resource or item was not found. */
/* Use only when the resource/item is uniquely identified.
String: none, unless the operation is not the main goal
of the function (in this case add item description). */
- ,E_NOT_AVAILABLE /**< Resource is unavailable. */
- /* String: none, unless the operation is not the main goal
- of the function (in this case add resource description). */
- ,E_ALREADY_EXISTS /**< Requested resource or item already exists. */
- /* Use when resource duplication or sharing are not allowed.
- String: none, unless the operation is not the main goal
- of the function (in this case add item description). */
,E_FULL /**< Resource is full. */
/* String: none, unless the operation is not the main goal
of the function (in this case add resource description). */
,E_EMPTY /**< Resource is empty. */
/* String: none, unless the operation is not the main goal
of the function (in this case add resource description). */
- ,E_BUSY /**< Resource or module is busy. */
- /* String: none, unless the operation is not the main goal
- of the function (in this case add resource description). */
,E_ALREADY_FREE /**< Specified resource or item is already free or deleted. */
/* String: none, unless the operation is not the main goal
of the function (in this case add item description). */
-
- /* Read/Write Access Errors */
,E_READ_FAILED /**< Read access failed on memory/device. */
/* String: none, or device name. */
- ,E_WRITE_FAILED /**< Write access failed on memory/device. */
- /* String: none, or device name. */
-
- /* Send/Receive Failures */
+ ,E_INVALID_FRAME /**< Invalid frame object (NULL handle or missing buffers). */
+ /* String: none. */
,E_SEND_FAILED /**< Send operation failed on device. */
/* String: none, or device name. */
,E_RECEIVE_FAILED /**< Receive operation failed on device. */
/* String: none, or device name. */
-
- /* Operation time-out */
- ,E_TIMEOUT /**< The operation timed out. */
+ ,E_TIMEOUT/* = ETIMEDOUT*/ /**< The operation timed out. */
/* String: none. */
,E_DUMMY_LAST /* NEVER USED */
} e_ErrorType;
-
/**************************************************************************//**
@Description Event Type Enumeration
*//***************************************************************************/
@@ -352,9 +329,7 @@ int ERROR_DYNAMIC_LEVEL = ERROR_GLOBAL_LEVEL;
#endif /* !ERROR_DYNAMIC_LEVEL */
#define PRINT_FORMAT "[CPU%02d, %s:%d %s]"
-#define PRINT_FMT_PARAMS CORE_GetId(), __FILE__, __LINE__, __FUNCTION__
-#define _ERR_STRING(err) #err
-#define ERR_STRING(err) _ERR_STRING(err)
+#define PRINT_FMT_PARAMS PCPU_GET(cpuid), __FILE__, __LINE__, __FUNCTION__
#if (!(defined(DEBUG_ERRORS)) || (DEBUG_ERRORS == 0))
/* No debug/error/event messages at all */
@@ -384,12 +359,12 @@ int ERROR_DYNAMIC_LEVEL = ERROR_GLOBAL_LEVEL;
#else /* DEBUG_ERRORS > 0 */
extern const char *dbgLevelStrings[];
-extern const char *errTypeStrings[];
-extern const char *moduleStrings[];
#if (REPORT_EVENTS > 0)
extern const char *eventStrings[];
#endif /* (REPORT_EVENTS > 0) */
+char * ErrTypeStrings (e_ErrorType err);
+
#if ((defined(DEBUG_USING_STATIC_LEVEL)) && (DEBUG_DYNAMIC_LEVEL < REPORT_LEVEL_WARNING))
/* No need for DBG macro - debug level is higher anyway */
@@ -400,7 +375,7 @@ extern const char *eventStrings[];
if (REPORT_LEVEL_##_level <= DEBUG_DYNAMIC_LEVEL) { \
XX_Print("> %s (%s) " PRINT_FORMAT ": ", \
dbgLevelStrings[REPORT_LEVEL_##_level - 1], \
- ERR_STRING(__ERR_MODULE__), \
+ __STRING(__ERR_MODULE__), \
PRINT_FMT_PARAMS); \
XX_Print _vmsg; \
XX_Print("\r\n"); \
@@ -414,9 +389,9 @@ extern const char *eventStrings[];
if (REPORT_LEVEL_##_level <= ERROR_DYNAMIC_LEVEL) { \
XX_Print("! %s %s Error " PRINT_FORMAT ": %s; ", \
dbgLevelStrings[REPORT_LEVEL_##_level - 1], \
- ERR_STRING(__ERR_MODULE__), \
+ __STRING(__ERR_MODULE__), \
PRINT_FMT_PARAMS, \
- errTypeStrings[(GET_ERROR_TYPE(_err) - E_OK - 1)]); \
+ ErrTypeStrings((e_ErrorType)GET_ERROR_TYPE(_err))); \
XX_Print _vmsg; \
XX_Print("\r\n"); \
} \
@@ -437,7 +412,7 @@ extern const char *eventStrings[];
if (_ev##_LEVEL <= EVENT_DYNAMIC_LEVEL) { \
XX_Print("~ %s %s Event " PRINT_FORMAT ": %s (flags: 0x%04x); ", \
dbgLevelStrings[_ev##_LEVEL - 1], \
- ERR_STRING(__ERR_MODULE__), \
+ __STRING(__ERR_MODULE__), \
PRINT_FMT_PARAMS, \
eventStrings[((_ev) - EV_NO_EVENT - 1)], \
(uint16_t)(_flg)); \
diff --git a/sys/contrib/ncsw/inc/etc/list_ext.h b/sys/contrib/ncsw/inc/etc/list_ext.h
index d6f3a662fa5f..743b2785b9e9 100644
--- a/sys/contrib/ncsw/inc/etc/list_ext.h
+++ b/sys/contrib/ncsw/inc/etc/list_ext.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
+/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File list_ext.h
@@ -71,16 +72,16 @@ typedef struct List
/**************************************************************************//**
- @Function NCSW_LIST_FIRST/LIST_LAST/NCSW_LIST_NEXT/NCSW_LIST_PREV
+ @Function NCSW_LIST_FIRST/NCSW_LIST_LAST/NCSW_LIST_NEXT/NCSW_LIST_PREV
@Description Macro to get first/last/next/previous entry in a list.
@Param[in] p_List - A pointer to a list.
*//***************************************************************************/
#define NCSW_LIST_FIRST(p_List) (p_List)->p_Next
-#define LIST_LAST(p_List) (p_List)->p_Prev
+#define NCSW_LIST_LAST(p_List) (p_List)->p_Prev
#define NCSW_LIST_NEXT NCSW_LIST_FIRST
-#define NCSW_LIST_PREV LIST_LAST
+#define NCSW_LIST_PREV NCSW_LIST_LAST
/**************************************************************************//**
@@ -94,13 +95,13 @@ typedef struct List
/**************************************************************************//**
- @Function LIST
+ @Function NCSW_LIST
@Description Macro to declare of a list.
@Param[in] listName - The list object name.
*//***************************************************************************/
-#define LIST(listName) t_List listName = NCSW_LIST_INIT(listName)
+#define NCSW_LIST(listName) t_List listName = NCSW_LIST_INIT(listName)
/**************************************************************************//**
@@ -110,11 +111,11 @@ typedef struct List
@Param[in] p_List - The list pointer.
*//***************************************************************************/
-#define INIT_LIST(p_List) NCSW_LIST_FIRST(p_List) = LIST_LAST(p_List) = (p_List)
+#define INIT_LIST(p_List) NCSW_LIST_FIRST(p_List) = NCSW_LIST_LAST(p_List) = (p_List)
/**************************************************************************//**
- @Function LIST_OBJECT
+ @Function NCSW_LIST_OBJECT
@Description Macro to get the struct (object) for this entry.
@@ -124,12 +125,12 @@ typedef struct List
@Return The structure pointer for this entry.
*//***************************************************************************/
#define MEMBER_OFFSET(type, member) (PTR_TO_UINT(&((type *)0)->member))
-#define LIST_OBJECT(p_List, type, member) \
+#define NCSW_LIST_OBJECT(p_List, type, member) \
((type *)((char *)(p_List)-MEMBER_OFFSET(type, member)))
/**************************************************************************//**
- @Function LIST_FOR_EACH
+ @Function NCSW_LIST_FOR_EACH
@Description Macro to iterate over a list.
@@ -137,14 +138,14 @@ typedef struct List
@Param[in] p_Head - A pointer to the head for your list pointer.
@Cautions You can't delete items with this routine.
- For deletion use LIST_FOR_EACH_SAFE().
+ For deletion use NCSW_LIST_FOR_EACH_SAFE().
*//***************************************************************************/
-#define LIST_FOR_EACH(p_Pos, p_Head) \
+#define NCSW_LIST_FOR_EACH(p_Pos, p_Head) \
for (p_Pos = NCSW_LIST_FIRST(p_Head); p_Pos != (p_Head); p_Pos = NCSW_LIST_NEXT(p_Pos))
/**************************************************************************//**
- @Function LIST_FOR_EACH_SAFE
+ @Function NCSW_LIST_FOR_EACH_SAFE
@Description Macro to iterate over a list safe against removal of list entry.
@@ -152,14 +153,14 @@ typedef struct List
@Param[in] p_Tmp - Another pointer to a list to use as temporary storage.
@Param[in] p_Head - A pointer to the head for your list pointer.
*//***************************************************************************/
-#define LIST_FOR_EACH_SAFE(p_Pos, p_Tmp, p_Head) \
+#define NCSW_LIST_FOR_EACH_SAFE(p_Pos, p_Tmp, p_Head) \
for (p_Pos = NCSW_LIST_FIRST(p_Head), p_Tmp = NCSW_LIST_FIRST(p_Pos); \
p_Pos != (p_Head); \
p_Pos = p_Tmp, p_Tmp = NCSW_LIST_NEXT(p_Pos))
/**************************************************************************//**
- @Function LIST_FOR_EACH_OBJECT_SAFE
+ @Function NCSW_LIST_FOR_EACH_OBJECT_SAFE
@Description Macro to iterate over list of given type safely.
@@ -170,17 +171,17 @@ typedef struct List
@Param[in] member - The name of the list_struct within the struct.
@Cautions You can't delete items with this routine.
- For deletion use LIST_FOR_EACH_SAFE().
+ For deletion use NCSW_LIST_FOR_EACH_SAFE().
*//***************************************************************************/
-#define LIST_FOR_EACH_OBJECT_SAFE(p_Pos, p_Tmp, p_Head, type, member) \
- for (p_Pos = LIST_OBJECT(NCSW_LIST_FIRST(p_Head), type, member), \
- p_Tmp = LIST_OBJECT(NCSW_LIST_FIRST(&p_Pos->member), type, member); \
+#define NCSW_LIST_FOR_EACH_OBJECT_SAFE(p_Pos, p_Tmp, p_Head, type, member) \
+ for (p_Pos = NCSW_LIST_OBJECT(NCSW_LIST_FIRST(p_Head), type, member), \
+ p_Tmp = NCSW_LIST_OBJECT(NCSW_LIST_FIRST(&p_Pos->member), type, member); \
&p_Pos->member != (p_Head); \
p_Pos = p_Tmp, \
- p_Tmp = LIST_OBJECT(NCSW_LIST_FIRST(&p_Pos->member), type, member))
+ p_Tmp = NCSW_LIST_OBJECT(NCSW_LIST_FIRST(&p_Pos->member), type, member))
/**************************************************************************//**
- @Function LIST_FOR_EACH_OBJECT
+ @Function NCSW_LIST_FOR_EACH_OBJECT
@Description Macro to iterate over list of given type.
@@ -190,16 +191,16 @@ typedef struct List
@Param[in] member - The name of the list_struct within the struct.
@Cautions You can't delete items with this routine.
- For deletion use LIST_FOR_EACH_SAFE().
+ For deletion use NCSW_LIST_FOR_EACH_SAFE().
*//***************************************************************************/
-#define LIST_FOR_EACH_OBJECT(p_Pos, type, p_Head, member) \
- for (p_Pos = LIST_OBJECT(NCSW_LIST_FIRST(p_Head), type, member); \
+#define NCSW_LIST_FOR_EACH_OBJECT(p_Pos, type, p_Head, member) \
+ for (p_Pos = NCSW_LIST_OBJECT(NCSW_LIST_FIRST(p_Head), type, member); \
&p_Pos->member != (p_Head); \
- p_Pos = LIST_OBJECT(NCSW_LIST_FIRST(&(p_Pos->member)), type, member))
+ p_Pos = NCSW_LIST_OBJECT(NCSW_LIST_FIRST(&(p_Pos->member)), type, member))
/**************************************************************************//**
- @Function LIST_Add
+ @Function NCSW_LIST_Add
@Description Add a new entry to a list.
@@ -211,7 +212,7 @@ typedef struct List
@Return none.
*//***************************************************************************/
-static __inline__ void LIST_Add(t_List *p_New, t_List *p_Head)
+static __inline__ void NCSW_LIST_Add(t_List *p_New, t_List *p_Head)
{
NCSW_LIST_PREV(NCSW_LIST_NEXT(p_Head)) = p_New;
NCSW_LIST_NEXT(p_New) = NCSW_LIST_NEXT(p_Head);
@@ -221,7 +222,7 @@ static __inline__ void LIST_Add(t_List *p_New, t_List *p_Head)
/**************************************************************************//**
- @Function LIST_AddToTail
+ @Function NCSW_LIST_AddToTail
@Description Add a new entry to a list.
@@ -229,11 +230,11 @@ static __inline__ void LIST_Add(t_List *p_New, t_List *p_Head)
This is useful for implementing queues.
@Param[in] p_New - A pointer to a new list entry to be added.
- @Param[in] p_Head - A pointer to a list head to add it after.
+ @Param[in] p_Head - A pointer to a list head to add it before.
@Return none.
*//***************************************************************************/
-static __inline__ void LIST_AddToTail(t_List *p_New, t_List *p_Head)
+static __inline__ void NCSW_LIST_AddToTail(t_List *p_New, t_List *p_Head)
{
NCSW_LIST_NEXT(NCSW_LIST_PREV(p_Head)) = p_New;
NCSW_LIST_PREV(p_New) = NCSW_LIST_PREV(p_Head);
@@ -243,7 +244,7 @@ static __inline__ void LIST_AddToTail(t_List *p_New, t_List *p_Head)
/**************************************************************************//**
- @Function LIST_Del
+ @Function NCSW_LIST_Del
@Description Deletes entry from a list.
@@ -251,10 +252,10 @@ static __inline__ void LIST_AddToTail(t_List *p_New, t_List *p_Head)
@Return none.
- @Cautions LIST_IsEmpty() on entry does not return true after this,
+ @Cautions NCSW_LIST_IsEmpty() on entry does not return true after this,
the entry is in an undefined state.
*//***************************************************************************/
-static __inline__ void LIST_Del(t_List *p_Entry)
+static __inline__ void NCSW_LIST_Del(t_List *p_Entry)
{
NCSW_LIST_PREV(NCSW_LIST_NEXT(p_Entry)) = NCSW_LIST_PREV(p_Entry);
NCSW_LIST_NEXT(NCSW_LIST_PREV(p_Entry)) = NCSW_LIST_NEXT(p_Entry);
@@ -262,7 +263,7 @@ static __inline__ void LIST_Del(t_List *p_Entry)
/**************************************************************************//**
- @Function LIST_DelAndInit
+ @Function NCSW_LIST_DelAndInit
@Description Deletes entry from list and reinitialize it.
@@ -270,15 +271,15 @@ static __inline__ void LIST_Del(t_List *p_Entry)
@Return none.
*//***************************************************************************/
-static __inline__ void LIST_DelAndInit(t_List *p_Entry)
+static __inline__ void NCSW_LIST_DelAndInit(t_List *p_Entry)
{
- LIST_Del(p_Entry);
+ NCSW_LIST_Del(p_Entry);
INIT_LIST(p_Entry);
}
/**************************************************************************//**
- @Function LIST_Move
+ @Function NCSW_LIST_Move
@Description Delete from one list and add as another's head.
@@ -287,15 +288,15 @@ static __inline__ void LIST_DelAndInit(t_List *p_Entry)
@Return none.
*//***************************************************************************/
-static __inline__ void LIST_Move(t_List *p_Entry, t_List *p_Head)
+static __inline__ void NCSW_LIST_Move(t_List *p_Entry, t_List *p_Head)
{
- LIST_Del(p_Entry);
- LIST_Add(p_Entry, p_Head);
+ NCSW_LIST_Del(p_Entry);
+ NCSW_LIST_Add(p_Entry, p_Head);
}
/**************************************************************************//**
- @Function LIST_MoveToTail
+ @Function NCSW_LIST_MoveToTail
@Description Delete from one list and add as another's tail.
@@ -304,15 +305,15 @@ static __inline__ void LIST_Move(t_List *p_Entry, t_List *p_Head)
@Return none.
*//***************************************************************************/
-static __inline__ void LIST_MoveToTail(t_List *p_Entry, t_List *p_Head)
+static __inline__ void NCSW_LIST_MoveToTail(t_List *p_Entry, t_List *p_Head)
{
- LIST_Del(p_Entry);
- LIST_AddToTail(p_Entry, p_Head);
+ NCSW_LIST_Del(p_Entry);
+ NCSW_LIST_AddToTail(p_Entry, p_Head);
}
/**************************************************************************//**
- @Function LIST_IsEmpty
+ @Function NCSW_LIST_IsEmpty
@Description Tests whether a list is empty.
@@ -320,14 +321,14 @@ static __inline__ void LIST_MoveToTail(t_List *p_Entry, t_List *p_Head)
@Return 1 if the list is empty, 0 otherwise.
*//***************************************************************************/
-static __inline__ int LIST_IsEmpty(t_List *p_List)
+static __inline__ int NCSW_LIST_IsEmpty(t_List *p_List)
{
return (NCSW_LIST_FIRST(p_List) == p_List);
}
/**************************************************************************//**
- @Function LIST_Append
+ @Function NCSW_LIST_Append
@Description Join two lists.
@@ -336,11 +337,11 @@ static __inline__ int LIST_IsEmpty(t_List *p_List)
@Return none.
*//***************************************************************************/
-void LIST_Append(t_List *p_NewList, t_List *p_Head);
+void NCSW_LIST_Append(t_List *p_NewList, t_List *p_Head);
/**************************************************************************//**
- @Function LIST_NumOfObjs
+ @Function NCSW_LIST_NumOfObjs
@Description Counts number of objects in the list
@@ -348,7 +349,7 @@ void LIST_Append(t_List *p_NewList, t_List *p_Head);
@Return Number of objects in the list.
*//***************************************************************************/
-int LIST_NumOfObjs(t_List *p_List);
+int NCSW_LIST_NumOfObjs(t_List *p_List);
/** @} */ /* end of list_id group */
/** @} */ /* end of etc_id group */
diff --git a/sys/contrib/ncsw/inc/etc/mem_ext.h b/sys/contrib/ncsw/inc/etc/mem_ext.h
index 16592d5ddadb..d0565d410ca4 100644
--- a/sys/contrib/ncsw/inc/etc/mem_ext.h
+++ b/sys/contrib/ncsw/inc/etc/mem_ext.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
+/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File mem_ext.h
@@ -258,7 +259,7 @@ uint32_t MEM_ComputePartitionSize(uint32_t num,
uint16_t alignment);
#ifdef DEBUG_MEM_LEAKS
-#if !(defined(__MWERKS__) && (__dest_os == __ppc_eabi))
+#if !((defined(__MWERKS__) || defined(__GNUC__)) && (__dest_os == __ppc_eabi))
#error "Memory-Leaks-Debug option is supported only for freescale CodeWarrior"
#endif /* !(defined(__MWERKS__) && ... */
diff --git a/sys/contrib/ncsw/inc/etc/memcpy_ext.h b/sys/contrib/ncsw/inc/etc/memcpy_ext.h
index e50c8a9f8e17..1b3a2fac5fad 100644
--- a/sys/contrib/ncsw/inc/etc/memcpy_ext.h
+++ b/sys/contrib/ncsw/inc/etc/memcpy_ext.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
+/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File memcpy_ext.h
@@ -166,6 +167,40 @@ void * MemSet64(void* pDst, uint8_t val, uint32_t size);
*//***************************************************************************/
void MemDisp(uint8_t *addr, int size);
+/**************************************************************************//**
+ @Function MemCpy8
+
+ @Description Trivial copy one memory buffer into another byte by byte
+
+ @Param[in] pDst - The address of the destination buffer.
+ @Param[in] pSrc - The address of the source buffer.
+ @Param[in] size - The number of bytes that will be copied from pSrc to pDst.
+
+ @Return pDst (the address of the destination buffer).
+
+ @Cautions There is no parameter or boundary checking! It is up to the user
+ to supply non-null parameters as source & destination and size
+ that actually fits into the destination buffer.
+*//***************************************************************************/
+void * MemCpy8(void* pDst,void* pSrc, uint32_t size);
+
+/**************************************************************************//**
+ @Function MemSet8
+
+ @Description Sets all bytes of a memory buffer to a specific value byte by byte.
+
+ @Param[in] pDst - The address of the destination buffer.
+ @Param[in] c - Value to set destination bytes to.
+ @Param[in] size - The number of bytes that will be set to val.
+
+ @Return pDst (the address of the destination buffer).
+
+ @Cautions There is no parameter or boundary checking! It is up to the user
+ to supply non null parameter as destination and size
+ that actually fits into the destination buffer.
+*//***************************************************************************/
+void * MemSet8(void* pDst, int c, uint32_t size);
+
/** @} */ /* end of mem_cpy group */
/** @} */ /* end of etc_id group */
diff --git a/sys/contrib/ncsw/inc/etc/mm_ext.h b/sys/contrib/ncsw/inc/etc/mm_ext.h
index 030f8775e1e2..fa7c85e3b2b8 100644
--- a/sys/contrib/ncsw/inc/etc/mm_ext.h
+++ b/sys/contrib/ncsw/inc/etc/mm_ext.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
+/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,8 +30,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
- /**************************************************************************//**
+/**************************************************************************//**
@File mm_ext.h
@Description Memory Manager Application Programming Interface
@@ -245,12 +245,11 @@ t_Error MM_Add(t_Handle h_MM, uint64_t base, uint64_t size);
/**************************************************************************//**
@Function MM_Dump
- @Description Prints results of free and busy lists into the file.
+ @Description Prints results of free and busy lists.
@Param[in] h_MM - Handle to the MM object.
- @Param[in] buff - A pointer to a buffer
*//***************************************************************************/
-void MM_Dump(t_Handle h_MM, void *buff);
+void MM_Dump(t_Handle h_MM);
/**************************************************************************//**
@Function MM_Free
@@ -293,6 +292,17 @@ uint64_t MM_GetMemBlock(t_Handle h_MM, int index);
*//***************************************************************************/
bool MM_InRange(t_Handle h_MM, uint64_t addr);
+/**************************************************************************//**
+ @Function MM_GetFreeMemSize
+
+ @Description Returns the size (in bytes) of free memory.
+
+ @Param[in] h_MM - Handle to the MM object.
+
+ @Return Free memory size in bytes.
+*//***************************************************************************/
+uint64_t MM_GetFreeMemSize(t_Handle h_MM);
+
/** @} */ /* end of mm_grp group */
/** @} */ /* end of etc_id group */
diff --git a/sys/contrib/ncsw/inc/etc/sprint_ext.h b/sys/contrib/ncsw/inc/etc/sprint_ext.h
index e94fac00b74d..0a53b7ce02a0 100644
--- a/sys/contrib/ncsw/inc/etc/sprint_ext.h
+++ b/sys/contrib/ncsw/inc/etc/sprint_ext.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
+/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,8 +30,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/******************************************************************************
+/**************************************************************************//**
@File sprint_ext.h
@Description Debug routines (externals).
@@ -45,13 +45,6 @@
#if defined(NCSW_LINUX) && defined(__KERNEL__)
#include <linux/kernel.h>
-#elif defined(NCSW_LINUX_USD)
-#include <stdio.h>
-#include "stdarg_ext.h"
-#include "std_ext.h"
-
-extern int vsscanf(const char *, const char *, va_list);
-
#elif defined(NCSW_VXWORKS)
#include "private/stdioP.h"
diff --git a/sys/contrib/ncsw/Peripherals/FM/fm_guest.c b/sys/contrib/ncsw/inc/flib/common/arch/ppc_access.h
index 886f6a07d891..c7b9b46f269b 100644
--- a/sys/contrib/ncsw/Peripherals/FM/fm_guest.c
+++ b/sys/contrib/ncsw/inc/flib/common/arch/ppc_access.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef FL_E500_MACROS_H
+#define FL_E500_MACROS_H
-
+#endif /* FL_E500_MACROS_H */
diff --git a/sys/contrib/ncsw/inc/flib/common/general.h b/sys/contrib/ncsw/inc/flib/common/general.h
new file mode 100644
index 000000000000..1b2ce7242805
--- /dev/null
+++ b/sys/contrib/ncsw/inc/flib/common/general.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __GENERAL_H
+#define __GENERAL_H
+
+#include "std_ext.h"
+#if !defined(NCSW_LINUX) && !defined(NCSW_FREEBSD)
+#include "errno.h"
+#endif
+
+
+extern uint32_t get_mac_addr_crc(uint64_t _addr);
+
+#ifndef CONFIG_FMAN_ARM
+#define iowrite32be(val, addr) WRITE_UINT32(*addr, val)
+#define ioread32be(addr) GET_UINT32(*addr)
+#endif
+
+#define ether_crc(len, addr) get_mac_addr_crc(*(uint64_t *)(addr)>>16)
+
+
+#endif /* __GENERAL_H */
diff --git a/sys/contrib/ncsw/inc/flib/fman_common.h b/sys/contrib/ncsw/inc/flib/fman_common.h
new file mode 100755
index 000000000000..8b194e995561
--- /dev/null
+++ b/sys/contrib/ncsw/inc/flib/fman_common.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2008-2013 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef __FMAN_COMMON_H
+#define __FMAN_COMMON_H
+
+/**************************************************************************//**
+ @Description NIA Description
+*//***************************************************************************/
+#define NIA_ORDER_RESTOR 0x00800000
+#define NIA_ENG_FM_CTL 0x00000000
+#define NIA_ENG_PRS 0x00440000
+#define NIA_ENG_KG 0x00480000
+#define NIA_ENG_PLCR 0x004C0000
+#define NIA_ENG_BMI 0x00500000
+#define NIA_ENG_QMI_ENQ 0x00540000
+#define NIA_ENG_QMI_DEQ 0x00580000
+#define NIA_ENG_MASK 0x007C0000
+
+#define NIA_FM_CTL_AC_CC 0x00000006
+#define NIA_FM_CTL_AC_HC 0x0000000C
+#define NIA_FM_CTL_AC_IND_MODE_TX 0x00000008
+#define NIA_FM_CTL_AC_IND_MODE_RX 0x0000000A
+#define NIA_FM_CTL_AC_FRAG 0x0000000e
+#define NIA_FM_CTL_AC_PRE_FETCH 0x00000010
+#define NIA_FM_CTL_AC_POST_FETCH_PCD 0x00000012
+#define NIA_FM_CTL_AC_POST_FETCH_PCD_UDP_LEN 0x00000018
+#define NIA_FM_CTL_AC_POST_FETCH_NO_PCD 0x00000012
+#define NIA_FM_CTL_AC_FRAG_CHECK 0x00000014
+#define NIA_FM_CTL_AC_PRE_CC 0x00000020
+
+
+#define NIA_BMI_AC_ENQ_FRAME 0x00000002
+#define NIA_BMI_AC_TX_RELEASE 0x000002C0
+#define NIA_BMI_AC_RELEASE 0x000000C0
+#define NIA_BMI_AC_DISCARD 0x000000C1
+#define NIA_BMI_AC_TX 0x00000274
+#define NIA_BMI_AC_FETCH 0x00000208
+#define NIA_BMI_AC_MASK 0x000003FF
+
+#define NIA_KG_DIRECT 0x00000100
+#define NIA_KG_CC_EN 0x00000200
+#define NIA_PLCR_ABSOLUTE 0x00008000
+
+#define NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA 0x00000202
+#define NIA_BMI_AC_FETCH_ALL_FRAME 0x0000020c
+
+#endif /* __FMAN_COMMON_H */
diff --git a/sys/contrib/ncsw/inc/flib/fsl_enet.h b/sys/contrib/ncsw/inc/flib/fsl_enet.h
new file mode 100644
index 000000000000..caa87fc6b21d
--- /dev/null
+++ b/sys/contrib/ncsw/inc/flib/fsl_enet.h
@@ -0,0 +1,273 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __FSL_ENET_H
+#define __FSL_ENET_H
+
+/**
+ @Description Ethernet MAC-PHY Interface
+*/
+
+enum enet_interface {
+ E_ENET_IF_MII = 0x00010000, /**< MII interface */
+ E_ENET_IF_RMII = 0x00020000, /**< RMII interface */
+ E_ENET_IF_SMII = 0x00030000, /**< SMII interface */
+ E_ENET_IF_GMII = 0x00040000, /**< GMII interface */
+ E_ENET_IF_RGMII = 0x00050000, /**< RGMII interface */
+ E_ENET_IF_TBI = 0x00060000, /**< TBI interface */
+ E_ENET_IF_RTBI = 0x00070000, /**< RTBI interface */
+ E_ENET_IF_SGMII = 0x00080000, /**< SGMII interface */
+ E_ENET_IF_XGMII = 0x00090000, /**< XGMII interface */
+ E_ENET_IF_QSGMII = 0x000a0000, /**< QSGMII interface */
+ E_ENET_IF_XFI = 0x000b0000 /**< XFI interface */
+};
+
+/**
+ @Description Ethernet Speed (nominal data rate)
+*/
+enum enet_speed {
+ E_ENET_SPEED_10 = 10, /**< 10 Mbps */
+ E_ENET_SPEED_100 = 100, /**< 100 Mbps */
+ E_ENET_SPEED_1000 = 1000, /**< 1000 Mbps = 1 Gbps */
+ E_ENET_SPEED_2500 = 2500, /**< 2500 Mbps = 2.5 Gbps */
+ E_ENET_SPEED_10000 = 10000 /**< 10000 Mbps = 10 Gbps */
+};
+
+enum mac_type {
+ E_MAC_DTSEC,
+ E_MAC_TGEC,
+ E_MAC_MEMAC
+};
+
+/**************************************************************************//**
+ @Description Enum for inter-module interrupts registration
+*//***************************************************************************/
+enum fman_event_modules {
+ E_FMAN_MOD_PRS, /**< Parser event */
+ E_FMAN_MOD_KG, /**< Keygen event */
+ E_FMAN_MOD_PLCR, /**< Policer event */
+ E_FMAN_MOD_10G_MAC, /**< 10G MAC event */
+ E_FMAN_MOD_1G_MAC, /**< 1G MAC event */
+ E_FMAN_MOD_TMR, /**< Timer event */
+ E_FMAN_MOD_FMAN_CTRL, /**< FMAN Controller Timer event */
+ E_FMAN_MOD_MACSEC,
+ E_FMAN_MOD_DUMMY_LAST
+};
+
+/**************************************************************************//**
+ @Description Enum for interrupts types
+*//***************************************************************************/
+enum fman_intr_type {
+ E_FMAN_INTR_TYPE_ERR,
+ E_FMAN_INTR_TYPE_NORMAL
+};
+
+/**************************************************************************//**
+ @Description enum for defining MAC types
+*//***************************************************************************/
+enum fman_mac_type {
+ E_FMAN_MAC_10G = 0, /**< 10G MAC */
+ E_FMAN_MAC_1G /**< 1G MAC */
+};
+
+enum fman_mac_exceptions {
+ E_FMAN_MAC_EX_10G_MDIO_SCAN_EVENTMDIO = 0,
+ /**< 10GEC MDIO scan event interrupt */
+ E_FMAN_MAC_EX_10G_MDIO_CMD_CMPL,
+ /**< 10GEC MDIO command completion interrupt */
+ E_FMAN_MAC_EX_10G_REM_FAULT,
+ /**< 10GEC, mEMAC Remote fault interrupt */
+ E_FMAN_MAC_EX_10G_LOC_FAULT,
+ /**< 10GEC, mEMAC Local fault interrupt */
+ E_FMAN_MAC_EX_10G_1TX_ECC_ER,
+ /**< 10GEC, mEMAC Transmit frame ECC error interrupt */
+ E_FMAN_MAC_EX_10G_TX_FIFO_UNFL,
+ /**< 10GEC, mEMAC Transmit FIFO underflow interrupt */
+ E_FMAN_MAC_EX_10G_TX_FIFO_OVFL,
+ /**< 10GEC, mEMAC Transmit FIFO overflow interrupt */
+ E_FMAN_MAC_EX_10G_TX_ER,
+ /**< 10GEC Transmit frame error interrupt */
+ E_FMAN_MAC_EX_10G_RX_FIFO_OVFL,
+ /**< 10GEC, mEMAC Receive FIFO overflow interrupt */
+ E_FMAN_MAC_EX_10G_RX_ECC_ER,
+ /**< 10GEC, mEMAC Receive frame ECC error interrupt */
+ E_FMAN_MAC_EX_10G_RX_JAB_FRM,
+ /**< 10GEC Receive jabber frame interrupt */
+ E_FMAN_MAC_EX_10G_RX_OVRSZ_FRM,
+ /**< 10GEC Receive oversized frame interrupt */
+ E_FMAN_MAC_EX_10G_RX_RUNT_FRM,
+ /**< 10GEC Receive runt frame interrupt */
+ E_FMAN_MAC_EX_10G_RX_FRAG_FRM,
+ /**< 10GEC Receive fragment frame interrupt */
+ E_FMAN_MAC_EX_10G_RX_LEN_ER,
+ /**< 10GEC Receive payload length error interrupt */
+ E_FMAN_MAC_EX_10G_RX_CRC_ER,
+ /**< 10GEC Receive CRC error interrupt */
+ E_FMAN_MAC_EX_10G_RX_ALIGN_ER,
+ /**< 10GEC Receive alignment error interrupt */
+ E_FMAN_MAC_EX_1G_BAB_RX,
+ /**< dTSEC Babbling receive error */
+ E_FMAN_MAC_EX_1G_RX_CTL,
+ /**< dTSEC Receive control (pause frame) interrupt */
+ E_FMAN_MAC_EX_1G_GRATEFUL_TX_STP_COMPLET,
+ /**< dTSEC Graceful transmit stop complete */
+ E_FMAN_MAC_EX_1G_BAB_TX,
+ /**< dTSEC Babbling transmit error */
+ E_FMAN_MAC_EX_1G_TX_CTL,
+ /**< dTSEC Transmit control (pause frame) interrupt */
+ E_FMAN_MAC_EX_1G_TX_ERR,
+ /**< dTSEC Transmit error */
+ E_FMAN_MAC_EX_1G_LATE_COL,
+ /**< dTSEC Late collision */
+ E_FMAN_MAC_EX_1G_COL_RET_LMT,
+ /**< dTSEC Collision retry limit */
+ E_FMAN_MAC_EX_1G_TX_FIFO_UNDRN,
+ /**< dTSEC Transmit FIFO underrun */
+ E_FMAN_MAC_EX_1G_MAG_PCKT,
+ /**< dTSEC Magic Packet detection */
+ E_FMAN_MAC_EX_1G_MII_MNG_RD_COMPLET,
+ /**< dTSEC MII management read completion */
+ E_FMAN_MAC_EX_1G_MII_MNG_WR_COMPLET,
+ /**< dTSEC MII management write completion */
+ E_FMAN_MAC_EX_1G_GRATEFUL_RX_STP_COMPLET,
+ /**< dTSEC Graceful receive stop complete */
+ E_FMAN_MAC_EX_1G_TX_DATA_ERR,
+ /**< dTSEC Internal data error on transmit */
+ E_FMAN_MAC_EX_1G_RX_DATA_ERR,
+ /**< dTSEC Internal data error on receive */
+ E_FMAN_MAC_EX_1G_1588_TS_RX_ERR,
+ /**< dTSEC Time-Stamp Receive Error */
+ E_FMAN_MAC_EX_1G_RX_MIB_CNT_OVFL,
+ /**< dTSEC MIB counter overflow */
+ E_FMAN_MAC_EX_TS_FIFO_ECC_ERR,
+ /**< mEMAC Time-stamp FIFO ECC error interrupt;
+ not supported on T4240/B4860 rev1 chips */
+};
+
+#define ENET_IF_SGMII_BASEX 0x80000000
+ /**< SGMII/QSGII interface with 1000BaseX auto-negotiation between MAC
+ and phy or backplane;
+ Note: 1000BaseX auto-negotiation relates only to interface between MAC
+ and phy/backplane, SGMII phy can still synchronize with far-end phy at
+ 10Mbps, 100Mbps or 1000Mbps */
+
+enum enet_mode {
+ E_ENET_MODE_INVALID = 0,
+ /**< Invalid Ethernet mode */
+ E_ENET_MODE_MII_10 = (E_ENET_IF_MII | E_ENET_SPEED_10),
+ /**< 10 Mbps MII */
+ E_ENET_MODE_MII_100 = (E_ENET_IF_MII | E_ENET_SPEED_100),
+ /**< 100 Mbps MII */
+ E_ENET_MODE_RMII_10 = (E_ENET_IF_RMII | E_ENET_SPEED_10),
+ /**< 10 Mbps RMII */
+ E_ENET_MODE_RMII_100 = (E_ENET_IF_RMII | E_ENET_SPEED_100),
+ /**< 100 Mbps RMII */
+ E_ENET_MODE_SMII_10 = (E_ENET_IF_SMII | E_ENET_SPEED_10),
+ /**< 10 Mbps SMII */
+ E_ENET_MODE_SMII_100 = (E_ENET_IF_SMII | E_ENET_SPEED_100),
+ /**< 100 Mbps SMII */
+ E_ENET_MODE_GMII_1000 = (E_ENET_IF_GMII | E_ENET_SPEED_1000),
+ /**< 1000 Mbps GMII */
+ E_ENET_MODE_RGMII_10 = (E_ENET_IF_RGMII | E_ENET_SPEED_10),
+ /**< 10 Mbps RGMII */
+ E_ENET_MODE_RGMII_100 = (E_ENET_IF_RGMII | E_ENET_SPEED_100),
+ /**< 100 Mbps RGMII */
+ E_ENET_MODE_RGMII_1000 = (E_ENET_IF_RGMII | E_ENET_SPEED_1000),
+ /**< 1000 Mbps RGMII */
+ E_ENET_MODE_TBI_1000 = (E_ENET_IF_TBI | E_ENET_SPEED_1000),
+ /**< 1000 Mbps TBI */
+ E_ENET_MODE_RTBI_1000 = (E_ENET_IF_RTBI | E_ENET_SPEED_1000),
+ /**< 1000 Mbps RTBI */
+ E_ENET_MODE_SGMII_10 = (E_ENET_IF_SGMII | E_ENET_SPEED_10),
+ /**< 10 Mbps SGMII with auto-negotiation between MAC and
+ SGMII phy according to Cisco SGMII specification */
+ E_ENET_MODE_SGMII_100 = (E_ENET_IF_SGMII | E_ENET_SPEED_100),
+ /**< 100 Mbps SGMII with auto-negotiation between MAC and
+ SGMII phy according to Cisco SGMII specification */
+ E_ENET_MODE_SGMII_1000 = (E_ENET_IF_SGMII | E_ENET_SPEED_1000),
+ /**< 1000 Mbps SGMII with auto-negotiation between MAC and
+ SGMII phy according to Cisco SGMII specification */
+ E_ENET_MODE_SGMII_BASEX_10 = (ENET_IF_SGMII_BASEX | E_ENET_IF_SGMII
+ | E_ENET_SPEED_10),
+ /**< 10 Mbps SGMII with 1000BaseX auto-negotiation between
+ MAC and SGMII phy or backplane */
+ E_ENET_MODE_SGMII_BASEX_100 = (ENET_IF_SGMII_BASEX | E_ENET_IF_SGMII
+ | E_ENET_SPEED_100),
+ /**< 100 Mbps SGMII with 1000BaseX auto-negotiation between
+ MAC and SGMII phy or backplane */
+ E_ENET_MODE_SGMII_BASEX_1000 = (ENET_IF_SGMII_BASEX | E_ENET_IF_SGMII
+ | E_ENET_SPEED_1000),
+ /**< 1000 Mbps SGMII with 1000BaseX auto-negotiation between
+ MAC and SGMII phy or backplane */
+ E_ENET_MODE_QSGMII_1000 = (E_ENET_IF_QSGMII | E_ENET_SPEED_1000),
+ /**< 1000 Mbps QSGMII with auto-negotiation between MAC and
+ QSGMII phy according to Cisco QSGMII specification */
+ E_ENET_MODE_QSGMII_BASEX_1000 = (ENET_IF_SGMII_BASEX | E_ENET_IF_QSGMII
+ | E_ENET_SPEED_1000),
+ /**< 1000 Mbps QSGMII with 1000BaseX auto-negotiation between
+ MAC and QSGMII phy or backplane */
+ E_ENET_MODE_XGMII_10000 = (E_ENET_IF_XGMII | E_ENET_SPEED_10000),
+ /**< 10000 Mbps XGMII */
+ E_ENET_MODE_XFI_10000 = (E_ENET_IF_XFI | E_ENET_SPEED_10000)
+ /**< 10000 Mbps XFI */
+};
+
+enum fmam_mac_statistics_level {
+ E_FMAN_MAC_NONE_STATISTICS, /**< No statistics */
+ E_FMAN_MAC_PARTIAL_STATISTICS, /**< Only error counters are available;
+ Optimized for performance */
+ E_FMAN_MAC_FULL_STATISTICS /**< All counters available; Not
+ optimized for performance */
+};
+
+#define _MAKE_ENET_MODE(_interface, _speed) (enum enet_mode)((_interface) \
+ | (_speed))
+
+#define _ENET_INTERFACE_FROM_MODE(mode) (enum enet_interface) \
+ ((mode) & 0x0FFF0000)
+#define _ENET_SPEED_FROM_MODE(mode) (enum enet_speed)((mode) & 0x0000FFFF)
+#define _ENET_ADDR_TO_UINT64(_enet_addr) \
+ (uint64_t)(((uint64_t)(_enet_addr)[0] << 40) | \
+ ((uint64_t)(_enet_addr)[1] << 32) | \
+ ((uint64_t)(_enet_addr)[2] << 24) | \
+ ((uint64_t)(_enet_addr)[3] << 16) | \
+ ((uint64_t)(_enet_addr)[4] << 8) | \
+ ((uint64_t)(_enet_addr)[5]))
+
+#define _MAKE_ENET_ADDR_FROM_UINT64(_addr64, _enet_addr) \
+ do { \
+ int i; \
+ for (i = 0; i < ENET_NUM_OCTETS_PER_ADDRESS; i++) \
+ (_enet_addr)[i] = (uint8_t)((_addr64) >> ((5-i)*8));\
+ } while (0)
+
+#endif /* __FSL_ENET_H */
diff --git a/sys/contrib/ncsw/inc/flib/fsl_fman.h b/sys/contrib/ncsw/inc/flib/fsl_fman.h
new file mode 100755
index 000000000000..96a63fa7f283
--- /dev/null
+++ b/sys/contrib/ncsw/inc/flib/fsl_fman.h
@@ -0,0 +1,825 @@
+/*
+ * Copyright 2013 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __FSL_FMAN_H
+#define __FSL_FMAN_H
+
+#include "common/general.h"
+
+struct fman_ext_pool_params {
+ uint8_t id; /**< External buffer pool id */
+ uint16_t size; /**< External buffer pool buffer size */
+};
+
+struct fman_ext_pools {
+ uint8_t num_pools_used; /**< Number of pools use by this port */
+ struct fman_ext_pool_params *ext_buf_pool;
+ /**< Parameters for each port */
+};
+
+struct fman_backup_bm_pools {
+ uint8_t num_backup_pools; /**< Number of BM backup pools -
+ must be smaller than the total number
+ of pools defined for the specified
+ port.*/
+ uint8_t *pool_ids; /**< numOfBackupPools pool id's,
+ specifying which pools should be used
+ only as backup. Pool id's specified
+ here must be a subset of the pools
+ used by the specified port.*/
+};
+
+/**************************************************************************//**
+ @Description A structure for defining BM pool depletion criteria
+*//***************************************************************************/
+struct fman_buf_pool_depletion {
+ bool buf_pool_depletion_enabled;
+ bool pools_grp_mode_enable; /**< select mode in which pause frames
+ will be sent after a number of pools
+ (all together!) are depleted */
+ uint8_t num_pools; /**< the number of depleted pools that
+ will invoke pause frames transmission.
+ */
+ bool *pools_to_consider; /**< For each pool, TRUE if it should be
+ considered for depletion (Note - this
+ pool must be used by this port!). */
+ bool single_pool_mode_enable; /**< select mode in which pause frames
+ will be sent after a single-pool
+ is depleted; */
+ bool *pools_to_consider_for_single_mode;
+ /**< For each pool, TRUE if it should be
+ considered for depletion (Note - this
+ pool must be used by this port!) */
+ bool has_pfc_priorities;
+ bool *pfc_priorities_en; /**< This field is used by the MAC as
+ the Priority Enable Vector in the PFC
+ frame which is transmitted */
+};
+
+/**************************************************************************//**
+ @Description Enum for defining port DMA swap mode
+*//***************************************************************************/
+enum fman_dma_swap_option {
+ FMAN_DMA_NO_SWP, /**< No swap, transfer data as is.*/
+ FMAN_DMA_SWP_PPC_LE, /**< The transferred data should be swapped
+ in PowerPc Little Endian mode. */
+ FMAN_DMA_SWP_BE /**< The transferred data should be swapped
+ in Big Endian mode */
+};
+
+/**************************************************************************//**
+ @Description Enum for defining port DMA cache attributes
+*//***************************************************************************/
+enum fman_dma_cache_option {
+ FMAN_DMA_NO_STASH = 0, /**< Cacheable, no Allocate (No Stashing) */
+ FMAN_DMA_STASH = 1 /**< Cacheable and Allocate (Stashing on) */
+};
+
+typedef struct t_FmPrsResult fm_prs_result_t;
+typedef enum e_EnetMode enet_mode_t;
+typedef t_Handle handle_t;
+
+struct fman_revision_info {
+ uint8_t majorRev; /**< Major revision */
+ uint8_t minorRev; /**< Minor revision */
+};
+
+/* sizes */
+#define CAPWAP_FRAG_EXTRA_SPACE 32
+#define OFFSET_UNITS 16
+#define MAX_INT_OFFSET 240
+#define MAX_IC_SIZE 256
+#define MAX_EXT_OFFSET 496
+#define MAX_EXT_BUFFER_OFFSET 511
+
+/**************************************************************************
+ @Description Memory Mapped Registers
+***************************************************************************/
+#define FMAN_LIODN_TBL 64 /* size of LIODN table */
+
+struct fman_fpm_regs {
+ uint32_t fmfp_tnc; /**< FPM TNUM Control 0x00 */
+ uint32_t fmfp_prc; /**< FPM Port_ID FmCtl Association 0x04 */
+ uint32_t fmfp_brkc; /**< FPM Breakpoint Control 0x08 */
+ uint32_t fmfp_mxd; /**< FPM Flush Control 0x0c */
+ uint32_t fmfp_dist1; /**< FPM Dispatch Thresholds1 0x10 */
+ uint32_t fmfp_dist2; /**< FPM Dispatch Thresholds2 0x14 */
+ uint32_t fm_epi; /**< FM Error Pending Interrupts 0x18 */
+ uint32_t fm_rie; /**< FM Error Interrupt Enable 0x1c */
+ uint32_t fmfp_fcev[4]; /**< FPM FMan-Controller Event 1-4 0x20-0x2f */
+ uint32_t res0030[4]; /**< res 0x30 - 0x3f */
+ uint32_t fmfp_cee[4]; /**< PM FMan-Controller Event 1-4 0x40-0x4f */
+ uint32_t res0050[4]; /**< res 0x50-0x5f */
+ uint32_t fmfp_tsc1; /**< FPM TimeStamp Control1 0x60 */
+ uint32_t fmfp_tsc2; /**< FPM TimeStamp Control2 0x64 */
+ uint32_t fmfp_tsp; /**< FPM Time Stamp 0x68 */
+ uint32_t fmfp_tsf; /**< FPM Time Stamp Fraction 0x6c */
+ uint32_t fm_rcr; /**< FM Rams Control 0x70 */
+ uint32_t fmfp_extc; /**< FPM External Requests Control 0x74 */
+ uint32_t fmfp_ext1; /**< FPM External Requests Config1 0x78 */
+ uint32_t fmfp_ext2; /**< FPM External Requests Config2 0x7c */
+ uint32_t fmfp_drd[16]; /**< FPM Data_Ram Data 0-15 0x80 - 0xbf */
+ uint32_t fmfp_dra; /**< FPM Data Ram Access 0xc0 */
+ uint32_t fm_ip_rev_1; /**< FM IP Block Revision 1 0xc4 */
+ uint32_t fm_ip_rev_2; /**< FM IP Block Revision 2 0xc8 */
+ uint32_t fm_rstc; /**< FM Reset Command 0xcc */
+ uint32_t fm_cld; /**< FM Classifier Debug 0xd0 */
+ uint32_t fm_npi; /**< FM Normal Pending Interrupts 0xd4 */
+ uint32_t fmfp_exte; /**< FPM External Requests Enable 0xd8 */
+ uint32_t fmfp_ee; /**< FPM Event & Mask 0xdc */
+ uint32_t fmfp_cev[4]; /**< FPM CPU Event 1-4 0xe0-0xef */
+ uint32_t res00f0[4]; /**< res 0xf0-0xff */
+ uint32_t fmfp_ps[64]; /**< FPM Port Status 0x100-0x1ff */
+ uint32_t fmfp_clfabc; /**< FPM CLFABC 0x200 */
+ uint32_t fmfp_clfcc; /**< FPM CLFCC 0x204 */
+ uint32_t fmfp_clfaval; /**< FPM CLFAVAL 0x208 */
+ uint32_t fmfp_clfbval; /**< FPM CLFBVAL 0x20c */
+ uint32_t fmfp_clfcval; /**< FPM CLFCVAL 0x210 */
+ uint32_t fmfp_clfamsk; /**< FPM CLFAMSK 0x214 */
+ uint32_t fmfp_clfbmsk; /**< FPM CLFBMSK 0x218 */
+ uint32_t fmfp_clfcmsk; /**< FPM CLFCMSK 0x21c */
+ uint32_t fmfp_clfamc; /**< FPM CLFAMC 0x220 */
+ uint32_t fmfp_clfbmc; /**< FPM CLFBMC 0x224 */
+ uint32_t fmfp_clfcmc; /**< FPM CLFCMC 0x228 */
+ uint32_t fmfp_decceh; /**< FPM DECCEH 0x22c */
+ uint32_t res0230[116]; /**< res 0x230 - 0x3ff */
+ uint32_t fmfp_ts[128]; /**< 0x400: FPM Task Status 0x400 - 0x5ff */
+ uint32_t res0600[0x400 - 384];
+};
+
+struct fman_bmi_regs {
+ uint32_t fmbm_init; /**< BMI Initialization 0x00 */
+ uint32_t fmbm_cfg1; /**< BMI Configuration 1 0x04 */
+ uint32_t fmbm_cfg2; /**< BMI Configuration 2 0x08 */
+ uint32_t res000c[5]; /**< 0x0c - 0x1f */
+ uint32_t fmbm_ievr; /**< Interrupt Event Register 0x20 */
+ uint32_t fmbm_ier; /**< Interrupt Enable Register 0x24 */
+ uint32_t fmbm_ifr; /**< Interrupt Force Register 0x28 */
+ uint32_t res002c[5]; /**< 0x2c - 0x3f */
+ uint32_t fmbm_arb[8]; /**< BMI Arbitration 0x40 - 0x5f */
+ uint32_t res0060[12]; /**<0x60 - 0x8f */
+ uint32_t fmbm_dtc[3]; /**< Debug Trap Counter 0x90 - 0x9b */
+ uint32_t res009c; /**< 0x9c */
+ uint32_t fmbm_dcv[3][4]; /**< Debug Compare val 0xa0-0xcf */
+ uint32_t fmbm_dcm[3][4]; /**< Debug Compare Mask 0xd0-0xff */
+ uint32_t fmbm_gde; /**< BMI Global Debug Enable 0x100 */
+ uint32_t fmbm_pp[63]; /**< BMI Port Parameters 0x104 - 0x1ff */
+ uint32_t res0200; /**< 0x200 */
+ uint32_t fmbm_pfs[63]; /**< BMI Port FIFO Size 0x204 - 0x2ff */
+ uint32_t res0300; /**< 0x300 */
+ uint32_t fmbm_spliodn[63]; /**< Port Partition ID 0x304 - 0x3ff */
+};
+
+struct fman_qmi_regs {
+ uint32_t fmqm_gc; /**< General Configuration Register 0x00 */
+ uint32_t res0004; /**< 0x04 */
+ uint32_t fmqm_eie; /**< Error Interrupt Event Register 0x08 */
+ uint32_t fmqm_eien; /**< Error Interrupt Enable Register 0x0c */
+ uint32_t fmqm_eif; /**< Error Interrupt Force Register 0x10 */
+ uint32_t fmqm_ie; /**< Interrupt Event Register 0x14 */
+ uint32_t fmqm_ien; /**< Interrupt Enable Register 0x18 */
+ uint32_t fmqm_if; /**< Interrupt Force Register 0x1c */
+ uint32_t fmqm_gs; /**< Global Status Register 0x20 */
+ uint32_t fmqm_ts; /**< Task Status Register 0x24 */
+ uint32_t fmqm_etfc; /**< Enqueue Total Frame Counter 0x28 */
+ uint32_t fmqm_dtfc; /**< Dequeue Total Frame Counter 0x2c */
+ uint32_t fmqm_dc0; /**< Dequeue Counter 0 0x30 */
+ uint32_t fmqm_dc1; /**< Dequeue Counter 1 0x34 */
+ uint32_t fmqm_dc2; /**< Dequeue Counter 2 0x38 */
+ uint32_t fmqm_dc3; /**< Dequeue Counter 3 0x3c */
+ uint32_t fmqm_dfdc; /**< Dequeue FQID from Default Counter 0x40 */
+ uint32_t fmqm_dfcc; /**< Dequeue FQID from Context Counter 0x44 */
+ uint32_t fmqm_dffc; /**< Dequeue FQID from FD Counter 0x48 */
+ uint32_t fmqm_dcc; /**< Dequeue Confirm Counter 0x4c */
+ uint32_t res0050[7]; /**< 0x50 - 0x6b */
+ uint32_t fmqm_tapc; /**< Tnum Aging Period Control 0x6c */
+ uint32_t fmqm_dmcvc; /**< Dequeue MAC Command Valid Counter 0x70 */
+ uint32_t fmqm_difdcc; /**< Dequeue Invalid FD Command Counter 0x74 */
+ uint32_t fmqm_da1v; /**< Dequeue A1 Valid Counter 0x78 */
+ uint32_t res007c; /**< 0x7c */
+ uint32_t fmqm_dtc; /**< 0x80 Debug Trap Counter 0x80 */
+ uint32_t fmqm_efddd; /**< 0x84 Enqueue Frame desc Dynamic dbg 0x84 */
+ uint32_t res0088[2]; /**< 0x88 - 0x8f */
+ struct {
+ uint32_t fmqm_dtcfg1; /**< 0x90 dbg trap cfg 1 Register 0x00 */
+ uint32_t fmqm_dtval1; /**< Debug Trap Value 1 Register 0x04 */
+ uint32_t fmqm_dtm1; /**< Debug Trap Mask 1 Register 0x08 */
+ uint32_t fmqm_dtc1; /**< Debug Trap Counter 1 Register 0x0c */
+ uint32_t fmqm_dtcfg2; /**< dbg Trap cfg 2 Register 0x10 */
+ uint32_t fmqm_dtval2; /**< Debug Trap Value 2 Register 0x14 */
+ uint32_t fmqm_dtm2; /**< Debug Trap Mask 2 Register 0x18 */
+ uint32_t res001c; /**< 0x1c */
+ } dbg_traps[3]; /**< 0x90 - 0xef */
+ uint8_t res00f0[0x400 - 0xf0]; /**< 0xf0 - 0x3ff */
+};
+
+struct fman_dma_regs {
+ uint32_t fmdmsr; /**< FM DMA status register 0x00 */
+ uint32_t fmdmmr; /**< FM DMA mode register 0x04 */
+ uint32_t fmdmtr; /**< FM DMA bus threshold register 0x08 */
+ uint32_t fmdmhy; /**< FM DMA bus hysteresis register 0x0c */
+ uint32_t fmdmsetr; /**< FM DMA SOS emergency Threshold Register 0x10 */
+ uint32_t fmdmtah; /**< FM DMA transfer bus address high reg 0x14 */
+ uint32_t fmdmtal; /**< FM DMA transfer bus address low reg 0x18 */
+ uint32_t fmdmtcid; /**< FM DMA transfer bus communication ID reg 0x1c */
+ uint32_t fmdmra; /**< FM DMA bus internal ram address register 0x20 */
+ uint32_t fmdmrd; /**< FM DMA bus internal ram data register 0x24 */
+ uint32_t fmdmwcr; /**< FM DMA CAM watchdog counter value 0x28 */
+ uint32_t fmdmebcr; /**< FM DMA CAM base in MURAM register 0x2c */
+ uint32_t fmdmccqdr; /**< FM DMA CAM and CMD Queue Debug reg 0x30 */
+ uint32_t fmdmccqvr1; /**< FM DMA CAM and CMD Queue Value reg #1 0x34 */
+ uint32_t fmdmccqvr2; /**< FM DMA CAM and CMD Queue Value reg #2 0x38 */
+ uint32_t fmdmcqvr3; /**< FM DMA CMD Queue Value register #3 0x3c */
+ uint32_t fmdmcqvr4; /**< FM DMA CMD Queue Value register #4 0x40 */
+ uint32_t fmdmcqvr5; /**< FM DMA CMD Queue Value register #5 0x44 */
+ uint32_t fmdmsefrc; /**< FM DMA Semaphore Entry Full Reject Cntr 0x48 */
+ uint32_t fmdmsqfrc; /**< FM DMA Semaphore Queue Full Reject Cntr 0x4c */
+ uint32_t fmdmssrc; /**< FM DMA Semaphore SYNC Reject Counter 0x50 */
+ uint32_t fmdmdcr; /**< FM DMA Debug Counter 0x54 */
+ uint32_t fmdmemsr; /**< FM DMA Emergency Smoother Register 0x58 */
+ uint32_t res005c; /**< 0x5c */
+ uint32_t fmdmplr[FMAN_LIODN_TBL / 2]; /**< DMA LIODN regs 0x60-0xdf */
+ uint32_t res00e0[0x400 - 56];
+};
+
+struct fman_rg {
+ struct fman_fpm_regs *fpm_rg;
+ struct fman_dma_regs *dma_rg;
+ struct fman_bmi_regs *bmi_rg;
+ struct fman_qmi_regs *qmi_rg;
+};
+
+enum fman_dma_cache_override {
+ E_FMAN_DMA_NO_CACHE_OR = 0, /**< No override of the Cache field */
+ E_FMAN_DMA_NO_STASH_DATA, /**< No data stashing in system level cache */
+ E_FMAN_DMA_MAY_STASH_DATA, /**< Stashing allowed in sys level cache */
+ E_FMAN_DMA_STASH_DATA /**< Stashing performed in system level cache */
+};
+
+enum fman_dma_aid_mode {
+ E_FMAN_DMA_AID_OUT_PORT_ID = 0, /**< 4 LSB of PORT_ID */
+ E_FMAN_DMA_AID_OUT_TNUM /**< 4 LSB of TNUM */
+};
+
+enum fman_dma_dbg_cnt_mode {
+ E_FMAN_DMA_DBG_NO_CNT = 0, /**< No counting */
+ E_FMAN_DMA_DBG_CNT_DONE, /**< Count DONE commands */
+ E_FMAN_DMA_DBG_CNT_COMM_Q_EM, /**< command Q emergency signal */
+ E_FMAN_DMA_DBG_CNT_INT_READ_EM, /**< Read buf emergency signal */
+ E_FMAN_DMA_DBG_CNT_INT_WRITE_EM, /**< Write buf emergency signal */
+ E_FMAN_DMA_DBG_CNT_FPM_WAIT, /**< FPM WAIT signal */
+ E_FMAN_DMA_DBG_CNT_SIGLE_BIT_ECC, /**< Single bit ECC errors */
+ E_FMAN_DMA_DBG_CNT_RAW_WAR_PROT /**< RAW & WAR protection counter */
+};
+
+enum fman_dma_emergency_level {
+ E_FMAN_DMA_EM_EBS = 0, /**< EBS emergency */
+ E_FMAN_DMA_EM_SOS /**< SOS emergency */
+};
+
+enum fman_catastrophic_err {
+ E_FMAN_CATAST_ERR_STALL_PORT = 0, /**< Port_ID stalled reset required */
+ E_FMAN_CATAST_ERR_STALL_TASK /**< Only erroneous task is stalled */
+};
+
+enum fman_dma_err {
+ E_FMAN_DMA_ERR_CATASTROPHIC = 0, /**< Catastrophic DMA error */
+ E_FMAN_DMA_ERR_REPORT /**< Reported DMA error */
+};
+
+struct fman_cfg {
+ uint16_t liodn_bs_pr_port[FMAN_LIODN_TBL];/* base per port */
+ bool en_counters;
+ uint8_t disp_limit_tsh;
+ uint8_t prs_disp_tsh;
+ uint8_t plcr_disp_tsh;
+ uint8_t kg_disp_tsh;
+ uint8_t bmi_disp_tsh;
+ uint8_t qmi_enq_disp_tsh;
+ uint8_t qmi_deq_disp_tsh;
+ uint8_t fm_ctl1_disp_tsh;
+ uint8_t fm_ctl2_disp_tsh;
+ enum fman_dma_cache_override dma_cache_override;
+ enum fman_dma_aid_mode dma_aid_mode;
+ bool dma_aid_override;
+ uint8_t dma_axi_dbg_num_of_beats;
+ uint8_t dma_cam_num_of_entries;
+ uint32_t dma_watchdog;
+ uint8_t dma_comm_qtsh_asrt_emer;
+ uint8_t dma_write_buf_tsh_asrt_emer;
+ uint8_t dma_read_buf_tsh_asrt_emer;
+ uint8_t dma_comm_qtsh_clr_emer;
+ uint8_t dma_write_buf_tsh_clr_emer;
+ uint8_t dma_read_buf_tsh_clr_emer;
+ uint32_t dma_sos_emergency;
+ enum fman_dma_dbg_cnt_mode dma_dbg_cnt_mode;
+ bool dma_stop_on_bus_error;
+ bool dma_en_emergency;
+ uint32_t dma_emergency_bus_select;
+ enum fman_dma_emergency_level dma_emergency_level;
+ bool dma_en_emergency_smoother;
+ uint32_t dma_emergency_switch_counter;
+ bool halt_on_external_activ;
+ bool halt_on_unrecov_ecc_err;
+ enum fman_catastrophic_err catastrophic_err;
+ enum fman_dma_err dma_err;
+ bool en_muram_test_mode;
+ bool en_iram_test_mode;
+ bool external_ecc_rams_enable;
+ uint16_t tnum_aging_period;
+ uint32_t exceptions;
+ uint16_t clk_freq;
+ bool pedantic_dma;
+ uint32_t cam_base_addr;
+ uint32_t fifo_base_addr;
+ uint32_t total_fifo_size;
+ uint8_t total_num_of_tasks;
+ bool qmi_deq_option_support;
+ uint32_t qmi_def_tnums_thresh;
+ bool fman_partition_array;
+ uint8_t num_of_fman_ctrl_evnt_regs;
+};
+
+/**************************************************************************//**
+ @Description Exceptions
+*//***************************************************************************/
+#define FMAN_EX_DMA_BUS_ERROR 0x80000000
+#define FMAN_EX_DMA_READ_ECC 0x40000000
+#define FMAN_EX_DMA_SYSTEM_WRITE_ECC 0x20000000
+#define FMAN_EX_DMA_FM_WRITE_ECC 0x10000000
+#define FMAN_EX_FPM_STALL_ON_TASKS 0x08000000
+#define FMAN_EX_FPM_SINGLE_ECC 0x04000000
+#define FMAN_EX_FPM_DOUBLE_ECC 0x02000000
+#define FMAN_EX_QMI_SINGLE_ECC 0x01000000
+#define FMAN_EX_QMI_DEQ_FROM_UNKNOWN_PORTID 0x00800000
+#define FMAN_EX_QMI_DOUBLE_ECC 0x00400000
+#define FMAN_EX_BMI_LIST_RAM_ECC 0x00200000
+#define FMAN_EX_BMI_PIPELINE_ECC 0x00100000
+#define FMAN_EX_BMI_STATISTICS_RAM_ECC 0x00080000
+#define FMAN_EX_IRAM_ECC 0x00040000
+#define FMAN_EX_NURAM_ECC 0x00020000
+#define FMAN_EX_BMI_DISPATCH_RAM_ECC 0x00010000
+
+enum fman_exceptions {
+ E_FMAN_EX_DMA_BUS_ERROR = 0, /**< DMA bus error. */
+ E_FMAN_EX_DMA_READ_ECC, /**< Read Buffer ECC error */
+ E_FMAN_EX_DMA_SYSTEM_WRITE_ECC, /**< Write Buffer ECC err on sys side */
+ E_FMAN_EX_DMA_FM_WRITE_ECC, /**< Write Buffer ECC error on FM side */
+ E_FMAN_EX_FPM_STALL_ON_TASKS, /**< Stall of tasks on FPM */
+ E_FMAN_EX_FPM_SINGLE_ECC, /**< Single ECC on FPM. */
+ E_FMAN_EX_FPM_DOUBLE_ECC, /**< Double ECC error on FPM ram access */
+ E_FMAN_EX_QMI_SINGLE_ECC, /**< Single ECC on QMI. */
+ E_FMAN_EX_QMI_DOUBLE_ECC, /**< Double bit ECC occurred on QMI */
+ E_FMAN_EX_QMI_DEQ_FROM_UNKNOWN_PORTID,/**< DeQ from unknown port id */
+ E_FMAN_EX_BMI_LIST_RAM_ECC, /**< Linked List RAM ECC error */
+ E_FMAN_EX_BMI_STORAGE_PROFILE_ECC, /**< storage profile */
+ E_FMAN_EX_BMI_STATISTICS_RAM_ECC, /**< Statistics RAM ECC Err Enable */
+ E_FMAN_EX_BMI_DISPATCH_RAM_ECC, /**< Dispatch RAM ECC Error Enable */
+ E_FMAN_EX_IRAM_ECC, /**< Double bit ECC occurred on IRAM*/
+ E_FMAN_EX_MURAM_ECC /**< Double bit ECC occurred on MURAM*/
+};
+
+enum fman_counters {
+ E_FMAN_COUNTERS_ENQ_TOTAL_FRAME = 0, /**< QMI tot enQ frames counter */
+ E_FMAN_COUNTERS_DEQ_TOTAL_FRAME, /**< QMI tot deQ frames counter */
+ E_FMAN_COUNTERS_DEQ_0, /**< QMI 0 frames from QMan counter */
+ E_FMAN_COUNTERS_DEQ_1, /**< QMI 1 frames from QMan counter */
+ E_FMAN_COUNTERS_DEQ_2, /**< QMI 2 frames from QMan counter */
+ E_FMAN_COUNTERS_DEQ_3, /**< QMI 3 frames from QMan counter */
+ E_FMAN_COUNTERS_DEQ_FROM_DEFAULT, /**< QMI deQ from dflt queue cntr */
+ E_FMAN_COUNTERS_DEQ_FROM_CONTEXT, /**< QMI deQ from FQ context cntr */
+ E_FMAN_COUNTERS_DEQ_FROM_FD, /**< QMI deQ from FD command field cntr */
+ E_FMAN_COUNTERS_DEQ_CONFIRM, /**< QMI dequeue confirm counter */
+ E_FMAN_COUNTERS_SEMAPHOR_ENTRY_FULL_REJECT, /**< DMA full entry cntr */
+ E_FMAN_COUNTERS_SEMAPHOR_QUEUE_FULL_REJECT, /**< DMA full CAM Q cntr */
+ E_FMAN_COUNTERS_SEMAPHOR_SYNC_REJECT /**< DMA sync counter */
+};
+
+#define FPM_PRT_FM_CTL1 0x00000001
+#define FPM_PRT_FM_CTL2 0x00000002
+
+/**************************************************************************//**
+ @Description DMA definitions
+*//***************************************************************************/
+
+/* masks */
+#define DMA_MODE_AID_OR 0x20000000
+#define DMA_MODE_SBER 0x10000000
+#define DMA_MODE_BER 0x00200000
+#define DMA_MODE_EB 0x00100000
+#define DMA_MODE_ECC 0x00000020
+#define DMA_MODE_PRIVILEGE_PROT 0x00001000
+#define DMA_MODE_SECURE_PROT 0x00000800
+#define DMA_MODE_EMER_READ 0x00080000
+#define DMA_MODE_EMER_WRITE 0x00040000
+#define DMA_MODE_CACHE_OR_MASK 0xC0000000
+#define DMA_MODE_CEN_MASK 0x0000E000
+#define DMA_MODE_DBG_MASK 0x00000380
+#define DMA_MODE_AXI_DBG_MASK 0x0F000000
+
+#define DMA_EMSR_EMSTR_MASK 0x0000FFFF
+
+#define DMA_TRANSFER_PORTID_MASK 0xFF000000
+#define DMA_TRANSFER_TNUM_MASK 0x00FF0000
+#define DMA_TRANSFER_LIODN_MASK 0x00000FFF
+
+#define DMA_HIGH_LIODN_MASK 0x0FFF0000
+#define DMA_LOW_LIODN_MASK 0x00000FFF
+
+#define DMA_STATUS_CMD_QUEUE_NOT_EMPTY 0x10000000
+#define DMA_STATUS_BUS_ERR 0x08000000
+#define DMA_STATUS_READ_ECC 0x04000000
+#define DMA_STATUS_SYSTEM_WRITE_ECC 0x02000000
+#define DMA_STATUS_FM_WRITE_ECC 0x01000000
+#define DMA_STATUS_SYSTEM_DPEXT_ECC 0x00800000
+#define DMA_STATUS_FM_DPEXT_ECC 0x00400000
+#define DMA_STATUS_SYSTEM_DPDAT_ECC 0x00200000
+#define DMA_STATUS_FM_DPDAT_ECC 0x00100000
+#define DMA_STATUS_FM_SPDAT_ECC 0x00080000
+
+#define FM_LIODN_BASE_MASK 0x00000FFF
+
+/* shifts */
+#define DMA_MODE_CACHE_OR_SHIFT 30
+#define DMA_MODE_BUS_PRI_SHIFT 16
+#define DMA_MODE_AXI_DBG_SHIFT 24
+#define DMA_MODE_CEN_SHIFT 13
+#define DMA_MODE_BUS_PROT_SHIFT 10
+#define DMA_MODE_DBG_SHIFT 7
+#define DMA_MODE_EMER_LVL_SHIFT 6
+#define DMA_MODE_AID_MODE_SHIFT 4
+#define DMA_MODE_MAX_AXI_DBG_NUM_OF_BEATS 16
+#define DMA_MODE_MAX_CAM_NUM_OF_ENTRIES 32
+
+#define DMA_THRESH_COMMQ_SHIFT 24
+#define DMA_THRESH_READ_INT_BUF_SHIFT 16
+
+#define DMA_LIODN_SHIFT 16
+
+#define DMA_TRANSFER_PORTID_SHIFT 24
+#define DMA_TRANSFER_TNUM_SHIFT 16
+
+/* sizes */
+#define DMA_MAX_WATCHDOG 0xffffffff
+
+/* others */
+#define DMA_CAM_SIZEOF_ENTRY 0x40
+#define DMA_CAM_ALIGN 0x1000
+#define DMA_CAM_UNITS 8
+
+/**************************************************************************//**
+ @Description General defines
+*//***************************************************************************/
+
+#define FM_DEBUG_STATUS_REGISTER_OFFSET 0x000d1084UL
+#define FM_UCODE_DEBUG_INSTRUCTION 0x6ffff805UL
+
+/**************************************************************************//**
+ @Description FPM defines
+*//***************************************************************************/
+
+/* masks */
+#define FPM_EV_MASK_DOUBLE_ECC 0x80000000
+#define FPM_EV_MASK_STALL 0x40000000
+#define FPM_EV_MASK_SINGLE_ECC 0x20000000
+#define FPM_EV_MASK_RELEASE_FM 0x00010000
+#define FPM_EV_MASK_DOUBLE_ECC_EN 0x00008000
+#define FPM_EV_MASK_STALL_EN 0x00004000
+#define FPM_EV_MASK_SINGLE_ECC_EN 0x00002000
+#define FPM_EV_MASK_EXTERNAL_HALT 0x00000008
+#define FPM_EV_MASK_ECC_ERR_HALT 0x00000004
+
+#define FPM_RAM_RAMS_ECC_EN 0x80000000
+#define FPM_RAM_IRAM_ECC_EN 0x40000000
+#define FPM_RAM_MURAM_ECC 0x00008000
+#define FPM_RAM_IRAM_ECC 0x00004000
+#define FPM_RAM_MURAM_TEST_ECC 0x20000000
+#define FPM_RAM_IRAM_TEST_ECC 0x10000000
+#define FPM_RAM_RAMS_ECC_EN_SRC_SEL 0x08000000
+
+#define FPM_IRAM_ECC_ERR_EX_EN 0x00020000
+#define FPM_MURAM_ECC_ERR_EX_EN 0x00040000
+
+#define FPM_REV1_MAJOR_MASK 0x0000FF00
+#define FPM_REV1_MINOR_MASK 0x000000FF
+
+#define FPM_REV2_INTEG_MASK 0x00FF0000
+#define FPM_REV2_ERR_MASK 0x0000FF00
+#define FPM_REV2_CFG_MASK 0x000000FF
+
+#define FPM_TS_FRACTION_MASK 0x0000FFFF
+#define FPM_TS_CTL_EN 0x80000000
+
+#define FPM_PRC_REALSE_STALLED 0x00800000
+
+#define FPM_PS_STALLED 0x00800000
+#define FPM_PS_FM_CTL1_SEL 0x80000000
+#define FPM_PS_FM_CTL2_SEL 0x40000000
+#define FPM_PS_FM_CTL_SEL_MASK (FPM_PS_FM_CTL1_SEL | FPM_PS_FM_CTL2_SEL)
+
+#define FPM_RSTC_FM_RESET 0x80000000
+#define FPM_RSTC_10G0_RESET 0x04000000
+#define FPM_RSTC_1G0_RESET 0x40000000
+#define FPM_RSTC_1G1_RESET 0x20000000
+#define FPM_RSTC_1G2_RESET 0x10000000
+#define FPM_RSTC_1G3_RESET 0x08000000
+#define FPM_RSTC_1G4_RESET 0x02000000
+
+
+#define FPM_DISP_LIMIT_MASK 0x1F000000
+#define FPM_THR1_PRS_MASK 0xFF000000
+#define FPM_THR1_KG_MASK 0x00FF0000
+#define FPM_THR1_PLCR_MASK 0x0000FF00
+#define FPM_THR1_BMI_MASK 0x000000FF
+
+#define FPM_THR2_QMI_ENQ_MASK 0xFF000000
+#define FPM_THR2_QMI_DEQ_MASK 0x000000FF
+#define FPM_THR2_FM_CTL1_MASK 0x00FF0000
+#define FPM_THR2_FM_CTL2_MASK 0x0000FF00
+
+/* shifts */
+#define FPM_DISP_LIMIT_SHIFT 24
+
+#define FPM_THR1_PRS_SHIFT 24
+#define FPM_THR1_KG_SHIFT 16
+#define FPM_THR1_PLCR_SHIFT 8
+#define FPM_THR1_BMI_SHIFT 0
+
+#define FPM_THR2_QMI_ENQ_SHIFT 24
+#define FPM_THR2_QMI_DEQ_SHIFT 0
+#define FPM_THR2_FM_CTL1_SHIFT 16
+#define FPM_THR2_FM_CTL2_SHIFT 8
+
+#define FPM_EV_MASK_CAT_ERR_SHIFT 1
+#define FPM_EV_MASK_DMA_ERR_SHIFT 0
+
+#define FPM_REV1_MAJOR_SHIFT 8
+#define FPM_REV1_MINOR_SHIFT 0
+
+#define FPM_REV2_INTEG_SHIFT 16
+#define FPM_REV2_ERR_SHIFT 8
+#define FPM_REV2_CFG_SHIFT 0
+
+#define FPM_TS_INT_SHIFT 16
+
+#define FPM_PORT_FM_CTL_PORTID_SHIFT 24
+
+#define FPM_PS_FM_CTL_SEL_SHIFT 30
+#define FPM_PRC_ORA_FM_CTL_SEL_SHIFT 16
+
+#define FPM_DISP_LIMIT_SHIFT 24
+
+/* Interrupts defines */
+#define FPM_EVENT_FM_CTL_0 0x00008000
+#define FPM_EVENT_FM_CTL 0x0000FF00
+#define FPM_EVENT_FM_CTL_BRK 0x00000080
+
+/* others */
+#define FPM_MAX_DISP_LIMIT 31
+#define FPM_RSTC_FM_RESET 0x80000000
+#define FPM_RSTC_1G0_RESET 0x40000000
+#define FPM_RSTC_1G1_RESET 0x20000000
+#define FPM_RSTC_1G2_RESET 0x10000000
+#define FPM_RSTC_1G3_RESET 0x08000000
+#define FPM_RSTC_10G0_RESET 0x04000000
+#define FPM_RSTC_1G4_RESET 0x02000000
+#define FPM_RSTC_1G5_RESET 0x01000000
+#define FPM_RSTC_1G6_RESET 0x00800000
+#define FPM_RSTC_1G7_RESET 0x00400000
+#define FPM_RSTC_10G1_RESET 0x00200000
+/**************************************************************************//**
+ @Description BMI defines
+*//***************************************************************************/
+/* masks */
+#define BMI_INIT_START 0x80000000
+#define BMI_ERR_INTR_EN_STORAGE_PROFILE_ECC 0x80000000
+#define BMI_ERR_INTR_EN_LIST_RAM_ECC 0x40000000
+#define BMI_ERR_INTR_EN_STATISTICS_RAM_ECC 0x20000000
+#define BMI_ERR_INTR_EN_DISPATCH_RAM_ECC 0x10000000
+#define BMI_NUM_OF_TASKS_MASK 0x3F000000
+#define BMI_NUM_OF_EXTRA_TASKS_MASK 0x000F0000
+#define BMI_NUM_OF_DMAS_MASK 0x00000F00
+#define BMI_NUM_OF_EXTRA_DMAS_MASK 0x0000000F
+#define BMI_FIFO_SIZE_MASK 0x000003FF
+#define BMI_EXTRA_FIFO_SIZE_MASK 0x03FF0000
+#define BMI_CFG2_DMAS_MASK 0x0000003F
+#define BMI_TOTAL_FIFO_SIZE_MASK 0x07FF0000
+#define BMI_TOTAL_NUM_OF_TASKS_MASK 0x007F0000
+
+/* shifts */
+#define BMI_CFG2_TASKS_SHIFT 16
+#define BMI_CFG2_DMAS_SHIFT 0
+#define BMI_CFG1_FIFO_SIZE_SHIFT 16
+#define BMI_FIFO_SIZE_SHIFT 0
+#define BMI_EXTRA_FIFO_SIZE_SHIFT 16
+#define BMI_NUM_OF_TASKS_SHIFT 24
+#define BMI_EXTRA_NUM_OF_TASKS_SHIFT 16
+#define BMI_NUM_OF_DMAS_SHIFT 8
+#define BMI_EXTRA_NUM_OF_DMAS_SHIFT 0
+
+/* others */
+#define BMI_FIFO_ALIGN 0x100
+#define FMAN_BMI_FIFO_UNITS 0x100
+
+
+/**************************************************************************//**
+ @Description QMI defines
+*//***************************************************************************/
+/* masks */
+#define QMI_CFG_ENQ_EN 0x80000000
+#define QMI_CFG_DEQ_EN 0x40000000
+#define QMI_CFG_EN_COUNTERS 0x10000000
+#define QMI_CFG_SOFT_RESET 0x01000000
+#define QMI_CFG_DEQ_MASK 0x0000003F
+#define QMI_CFG_ENQ_MASK 0x00003F00
+
+#define QMI_ERR_INTR_EN_DOUBLE_ECC 0x80000000
+#define QMI_ERR_INTR_EN_DEQ_FROM_DEF 0x40000000
+#define QMI_INTR_EN_SINGLE_ECC 0x80000000
+
+/* shifts */
+#define QMI_CFG_ENQ_SHIFT 8
+#define QMI_TAPC_TAP 22
+
+#define QMI_GS_HALT_NOT_BUSY 0x00000002
+
+/**************************************************************************//**
+ @Description IRAM defines
+*//***************************************************************************/
+/* masks */
+#define IRAM_IADD_AIE 0x80000000
+#define IRAM_READY 0x80000000
+
+uint32_t fman_get_bmi_err_event(struct fman_bmi_regs *bmi_rg);
+uint32_t fman_get_qmi_err_event(struct fman_qmi_regs *qmi_rg);
+uint32_t fman_get_dma_com_id(struct fman_dma_regs *dma_rg);
+uint64_t fman_get_dma_addr(struct fman_dma_regs *dma_rg);
+uint32_t fman_get_dma_err_event(struct fman_dma_regs *dma_rg);
+uint32_t fman_get_fpm_err_event(struct fman_fpm_regs *fpm_rg);
+uint32_t fman_get_muram_err_event(struct fman_fpm_regs *fpm_rg);
+uint32_t fman_get_iram_err_event(struct fman_fpm_regs *fpm_rg);
+uint32_t fman_get_qmi_event(struct fman_qmi_regs *qmi_rg);
+uint32_t fman_get_fpm_error_interrupts(struct fman_fpm_regs *fpm_rg);
+uint32_t fman_get_ctrl_intr(struct fman_fpm_regs *fpm_rg,
+ uint8_t event_reg_id);
+uint8_t fman_get_qmi_deq_th(struct fman_qmi_regs *qmi_rg);
+uint8_t fman_get_qmi_enq_th(struct fman_qmi_regs *qmi_rg);
+uint16_t fman_get_size_of_fifo(struct fman_bmi_regs *bmi_rg, uint8_t port_id);
+uint32_t fman_get_total_fifo_size(struct fman_bmi_regs *bmi_rg);
+uint16_t fman_get_size_of_extra_fifo(struct fman_bmi_regs *bmi_rg,
+ uint8_t port_id);
+uint8_t fman_get_num_of_tasks(struct fman_bmi_regs *bmi_rg, uint8_t port_id);
+uint8_t fman_get_num_extra_tasks(struct fman_bmi_regs *bmi_rg,
+ uint8_t port_id);
+uint8_t fman_get_num_of_dmas(struct fman_bmi_regs *bmi_rg, uint8_t port_id);
+uint8_t fman_get_num_extra_dmas(struct fman_bmi_regs *bmi_rg,
+ uint8_t port_id);
+uint32_t fman_get_normal_pending(struct fman_fpm_regs *fpm_rg);
+uint32_t fman_get_controller_event(struct fman_fpm_regs *fpm_rg,
+ uint8_t reg_id);
+uint32_t fman_get_error_pending(struct fman_fpm_regs *fpm_rg);
+void fman_get_revision(struct fman_fpm_regs *fpm_rg, uint8_t *major,
+ uint8_t *minor);
+uint32_t fman_get_counter(struct fman_rg *fman_rg,
+ enum fman_counters reg_name);
+uint32_t fman_get_dma_status(struct fman_dma_regs *dma_rg);
+
+
+int fman_set_erratum_10gmac_a004_wa(struct fman_fpm_regs *fpm_rg);
+void fman_set_ctrl_intr(struct fman_fpm_regs *fpm_rg, uint8_t event_reg_id,
+ uint32_t enable_events);
+void fman_set_num_of_riscs_per_port(struct fman_fpm_regs *fpm_rg,
+ uint8_t port_id,
+ uint8_t num_fman_ctrls,
+ uint32_t or_fman_ctrl);
+void fman_set_order_restoration_per_port(struct fman_fpm_regs *fpm_rg,
+ uint8_t port_id,
+ bool independent_mode,
+ bool is_rx_port);
+void fman_set_qmi_enq_th(struct fman_qmi_regs *qmi_rg, uint8_t val);
+void fman_set_qmi_deq_th(struct fman_qmi_regs *qmi_rg, uint8_t val);
+void fman_set_liodn_per_port(struct fman_rg *fman_rg,
+ uint8_t port_id,
+ uint16_t liodn_base,
+ uint16_t liodn_offset);
+void fman_set_size_of_fifo(struct fman_bmi_regs *bmi_rg,
+ uint8_t port_id,
+ uint32_t size_of_fifo,
+ uint32_t extra_size_of_fifo);
+void fman_set_num_of_tasks(struct fman_bmi_regs *bmi_rg,
+ uint8_t port_id,
+ uint8_t num_of_tasks,
+ uint8_t num_of_extra_tasks);
+void fman_set_num_of_open_dmas(struct fman_bmi_regs *bmi_rg,
+ uint8_t port_id,
+ uint8_t num_of_open_dmas,
+ uint8_t num_of_extra_open_dmas,
+ uint8_t total_num_of_dmas);
+void fman_set_ports_bandwidth(struct fman_bmi_regs *bmi_rg, uint8_t *weights);
+int fman_set_exception(struct fman_rg *fman_rg,
+ enum fman_exceptions exception,
+ bool enable);
+void fman_set_dma_emergency(struct fman_dma_regs *dma_rg, bool is_write,
+ bool enable);
+void fman_set_dma_ext_bus_pri(struct fman_dma_regs *dma_rg, uint32_t pri);
+void fman_set_congestion_group_pfc_priority(uint32_t *cpg_rg,
+ uint32_t congestion_group_id,
+ uint8_t piority_bit_map,
+ uint32_t reg_num);
+
+
+void fman_defconfig(struct fman_cfg *cfg, bool is_master);
+void fman_regconfig(struct fman_rg *fman_rg, struct fman_cfg *cfg);
+int fman_fpm_init(struct fman_fpm_regs *fpm_rg, struct fman_cfg *cfg);
+int fman_bmi_init(struct fman_bmi_regs *bmi_rg, struct fman_cfg *cfg);
+int fman_qmi_init(struct fman_qmi_regs *qmi_rg, struct fman_cfg *cfg);
+int fman_dma_init(struct fman_dma_regs *dma_rg, struct fman_cfg *cfg);
+void fman_free_resources(struct fman_rg *fman_rg);
+int fman_enable(struct fman_rg *fman_rg, struct fman_cfg *cfg);
+void fman_reset(struct fman_fpm_regs *fpm_rg);
+void fman_resume(struct fman_fpm_regs *fpm_rg);
+
+
+void fman_enable_time_stamp(struct fman_fpm_regs *fpm_rg,
+ uint8_t count1ubit,
+ uint16_t fm_clk_freq);
+void fman_enable_rams_ecc(struct fman_fpm_regs *fpm_rg);
+void fman_qmi_disable_dispatch_limit(struct fman_fpm_regs *fpm_rg);
+void fman_disable_rams_ecc(struct fman_fpm_regs *fpm_rg);
+void fman_resume_stalled_port(struct fman_fpm_regs *fpm_rg, uint8_t port_id);
+int fman_reset_mac(struct fman_fpm_regs *fpm_rg, uint8_t macId, bool is_10g);
+bool fman_is_port_stalled(struct fman_fpm_regs *fpm_rg, uint8_t port_id);
+bool fman_rams_ecc_is_external_ctl(struct fman_fpm_regs *fpm_rg);
+bool fman_is_qmi_halt_not_busy_state(struct fman_qmi_regs *qmi_rg);
+int fman_modify_counter(struct fman_rg *fman_rg,
+ enum fman_counters reg_name,
+ uint32_t val);
+void fman_force_intr(struct fman_rg *fman_rg,
+ enum fman_exceptions exception);
+void fman_set_vsp_window(struct fman_bmi_regs *bmi_rg,
+ uint8_t port_id,
+ uint8_t base_storage_profile,
+ uint8_t log2_num_of_profiles);
+
+/**************************************************************************//**
+ @Description default values
+*//***************************************************************************/
+#define DEFAULT_CATASTROPHIC_ERR E_FMAN_CATAST_ERR_STALL_PORT
+#define DEFAULT_DMA_ERR E_FMAN_DMA_ERR_CATASTROPHIC
+#define DEFAULT_HALT_ON_EXTERNAL_ACTIVATION FALSE /* do not change! if changed, must be disabled for rev1 ! */
+#define DEFAULT_HALT_ON_UNRECOVERABLE_ECC_ERROR FALSE /* do not change! if changed, must be disabled for rev1 ! */
+#define DEFAULT_EXTERNAL_ECC_RAMS_ENABLE FALSE
+#define DEFAULT_AID_OVERRIDE FALSE
+#define DEFAULT_AID_MODE E_FMAN_DMA_AID_OUT_TNUM
+#define DEFAULT_DMA_COMM_Q_LOW 0x2A
+#define DEFAULT_DMA_COMM_Q_HIGH 0x3F
+#define DEFAULT_CACHE_OVERRIDE E_FMAN_DMA_NO_CACHE_OR
+#define DEFAULT_DMA_CAM_NUM_OF_ENTRIES 64
+#define DEFAULT_DMA_DBG_CNT_MODE E_FMAN_DMA_DBG_NO_CNT
+#define DEFAULT_DMA_EN_EMERGENCY FALSE
+#define DEFAULT_DMA_SOS_EMERGENCY 0
+#define DEFAULT_DMA_WATCHDOG 0 /* disabled */
+#define DEFAULT_DMA_EN_EMERGENCY_SMOOTHER FALSE
+#define DEFAULT_DMA_EMERGENCY_SWITCH_COUNTER 0
+#define DEFAULT_DISP_LIMIT 0
+#define DEFAULT_PRS_DISP_TH 16
+#define DEFAULT_PLCR_DISP_TH 16
+#define DEFAULT_KG_DISP_TH 16
+#define DEFAULT_BMI_DISP_TH 16
+#define DEFAULT_QMI_ENQ_DISP_TH 16
+#define DEFAULT_QMI_DEQ_DISP_TH 16
+#define DEFAULT_FM_CTL1_DISP_TH 16
+#define DEFAULT_FM_CTL2_DISP_TH 16
+#define DEFAULT_TNUM_AGING_PERIOD 4
+
+
+#endif /* __FSL_FMAN_H */
diff --git a/sys/contrib/ncsw/inc/flib/fsl_fman_dtsec.h b/sys/contrib/ncsw/inc/flib/fsl_fman_dtsec.h
new file mode 100644
index 000000000000..6004e478081a
--- /dev/null
+++ b/sys/contrib/ncsw/inc/flib/fsl_fman_dtsec.h
@@ -0,0 +1,1096 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __FSL_FMAN_DTSEC_H
+#define __FSL_FMAN_DTSEC_H
+
+#include "common/general.h"
+#include "fsl_enet.h"
+
+/**
+ * DOC: dTSEC Init sequence
+ *
+ * To prepare dTSEC block for transfer use the following call sequence:
+ *
+ * - fman_dtsec_defconfig() - This step is optional and yet recommended. Its
+ * use is to obtain the default dTSEC configuration parameters.
+ *
+ * - Change dtsec configuration in &dtsec_cfg. This structure will be used
+ * to customize the dTSEC behavior.
+ *
+ * - fman_dtsec_init() - Applies the configuration on dTSEC hardware. Note that
+ * dTSEC is initialized while both Tx and Rx are disabled.
+ *
+ * - fman_dtsec_set_mac_address() - Set the station address (mac address).
+ * This is used by dTSEC to match against received packets.
+ *
+ * - fman_dtsec_adjust_link() - Set the link speed and duplex parameters
+ * after the PHY establishes the link.
+ *
+ * - dtsec_enable_tx() and dtsec_enable_rx() to enable transmission and
+ * reception.
+ */
+
+/**
+ * DOC: dTSEC Graceful stop
+ *
+ * To temporary stop dTSEC activity use fman_dtsec_stop_tx() and
+ * fman_dtsec_stop_rx(). Note that these functions request dTSEC graceful stop
+ * but return before this stop is complete. To query for graceful stop
+ * completion use fman_dtsec_get_event() and check DTSEC_IEVENT_GTSC and
+ * DTSEC_IEVENT_GRSC bits. Alternatively the dTSEC interrupt mask can be set to
+ * enable graceful stop interrupts.
+ *
+ * To resume operation after graceful stop use fman_dtsec_start_tx() and
+ * fman_dtsec_start_rx().
+ */
+
+/**
+ * DOC: dTSEC interrupt handling
+ *
+ * This code does not provide an interrupt handler for dTSEC. Instead this
+ * handler should be implemented and registered to the operating system by the
+ * caller. Some primitives for accessing the event status and mask registers
+ * are provided.
+ *
+ * See "dTSEC Events" section for a list of events that dTSEC can generate.
+ */
+
+/**
+ * DOC: dTSEC Events
+ *
+ * Interrupt events cause dTSEC event bits to be set. Software may poll the
+ * event register at any time to check for pending interrupts. If an event
+ * occurs and its corresponding enable bit is set in the interrupt mask
+ * register, the event also causes a hardware interrupt at the PIC.
+ *
+ * To poll for event status use the fman_dtsec_get_event() function.
+ * To configure the interrupt mask use fman_dtsec_enable_interrupt() and
+ * fman_dtsec_disable_interrupt() functions.
+ * After servicing a dTSEC interrupt use fman_dtsec_ack_event to reset the
+ * serviced event bit.
+ *
+ * The following events may be signaled by dTSEC hardware:
+ *
+ * %DTSEC_IEVENT_BABR - Babbling receive error. This bit indicates that
+ * a frame was received with length in excess of the MAC's maximum frame length
+ * register.
+ *
+ * %DTSEC_IEVENT_RXC - Receive control (pause frame) interrupt. A pause
+ * control frame was received while Rx pause frame handling is enabled.
+ * Also see fman_dtsec_handle_rx_pause().
+ *
+ * %DTSEC_IEVENT_MSRO - MIB counter overflow. The count for one of the MIB
+ * counters has exceeded the size of its register.
+ *
+ * %DTSEC_IEVENT_GTSC - Graceful transmit stop complete. Graceful stop is now
+ * complete. The transmitter is in a stopped state, in which only pause frames
+ * can be transmitted.
+ * Also see fman_dtsec_stop_tx().
+ *
+ * %DTSEC_IEVENT_BABT - Babbling transmit error. The transmitted frame length
+ * has exceeded the value in the MAC's Maximum Frame Length register.
+ *
+ * %DTSEC_IEVENT_TXC - Transmit control (pause frame) interrupt. his bit
+ * indicates that a control frame was transmitted.
+ *
+ * %DTSEC_IEVENT_TXE - Transmit error. This bit indicates that an error
+ * occurred on the transmitted channel. This bit is set whenever any transmit
+ * error occurs which causes the dTSEC to discard all or part of a frame
+ * (LC, CRL, XFUN).
+ *
+ * %DTSEC_IEVENT_LC - Late collision. This bit indicates that a collision
+ * occurred beyond the collision window (slot time) in half-duplex mode.
+ * The frame is truncated with a bad CRC and the remainder of the frame
+ * is discarded.
+ *
+ * %DTSEC_IEVENT_CRL - Collision retry limit. is bit indicates that the number
+ * of successive transmission collisions has exceeded the MAC's half-duplex
+ * register's retransmission maximum count. The frame is discarded without
+ * being transmitted and transmission of the next frame commences. This only
+ * occurs while in half-duplex mode.
+ * The number of retransmit attempts can be set in
+ * &dtsec_halfdup_cfg.@retransmit before calling fman_dtsec_init().
+ *
+ * %DTSEC_IEVENT_XFUN - Transmit FIFO underrun. This bit indicates that the
+ * transmit FIFO became empty before the complete frame was transmitted.
+ * The frame is truncated with a bad CRC and the remainder of the frame is
+ * discarded.
+ *
+ * %DTSEC_IEVENT_MAG - TBD
+ *
+ * %DTSEC_IEVENT_MMRD - MII management read completion.
+ *
+ * %DTSEC_IEVENT_MMWR - MII management write completion.
+ *
+ * %DTSEC_IEVENT_GRSC - Graceful receive stop complete. It allows the user to
+ * know if the system has completed the stop and it is safe to write to receive
+ * registers (status, control or configuration registers) that are used by the
+ * system during normal operation.
+ *
+ * %DTSEC_IEVENT_TDPE - Internal data error on transmit. This bit indicates
+ * that the dTSEC has detected a parity error on its stored transmit data, which
+ * is likely to compromise the validity of recently transferred frames.
+ *
+ * %DTSEC_IEVENT_RDPE - Internal data error on receive. This bit indicates that
+ * the dTSEC has detected a parity error on its stored receive data, which is
+ * likely to compromise the validity of recently transferred frames.
+ */
+/* Interrupt Mask Register (IMASK) */
+#define DTSEC_IMASK_BREN 0x80000000
+#define DTSEC_IMASK_RXCEN 0x40000000
+#define DTSEC_IMASK_MSROEN 0x04000000
+#define DTSEC_IMASK_GTSCEN 0x02000000
+#define DTSEC_IMASK_BTEN 0x01000000
+#define DTSEC_IMASK_TXCEN 0x00800000
+#define DTSEC_IMASK_TXEEN 0x00400000
+#define DTSEC_IMASK_LCEN 0x00040000
+#define DTSEC_IMASK_CRLEN 0x00020000
+#define DTSEC_IMASK_XFUNEN 0x00010000
+#define DTSEC_IMASK_ABRTEN 0x00008000
+#define DTSEC_IMASK_IFERREN 0x00004000
+#define DTSEC_IMASK_MAGEN 0x00000800
+#define DTSEC_IMASK_MMRDEN 0x00000400
+#define DTSEC_IMASK_MMWREN 0x00000200
+#define DTSEC_IMASK_GRSCEN 0x00000100
+#define DTSEC_IMASK_TDPEEN 0x00000002
+#define DTSEC_IMASK_RDPEEN 0x00000001
+
+#define DTSEC_EVENTS_MASK \
+ ((uint32_t)(DTSEC_IMASK_BREN | \
+ DTSEC_IMASK_RXCEN | \
+ DTSEC_IMASK_BTEN | \
+ DTSEC_IMASK_TXCEN | \
+ DTSEC_IMASK_TXEEN | \
+ DTSEC_IMASK_ABRTEN | \
+ DTSEC_IMASK_LCEN | \
+ DTSEC_IMASK_CRLEN | \
+ DTSEC_IMASK_XFUNEN | \
+ DTSEC_IMASK_IFERREN | \
+ DTSEC_IMASK_MAGEN | \
+ DTSEC_IMASK_TDPEEN | \
+ DTSEC_IMASK_RDPEEN))
+
+/* dtsec timestamp event bits */
+#define TMR_PEMASK_TSREEN 0x00010000
+#define TMR_PEVENT_TSRE 0x00010000
+
+/* Group address bit indication */
+#define MAC_GROUP_ADDRESS 0x0000010000000000ULL
+/* size in bytes of L2 address */
+#define MAC_ADDRLEN 6
+
+#define DEFAULT_HALFDUP_ON FALSE
+#define DEFAULT_HALFDUP_RETRANSMIT 0xf
+#define DEFAULT_HALFDUP_COLL_WINDOW 0x37
+#define DEFAULT_HALFDUP_EXCESS_DEFER TRUE
+#define DEFAULT_HALFDUP_NO_BACKOFF FALSE
+#define DEFAULT_HALFDUP_BP_NO_BACKOFF FALSE
+#define DEFAULT_HALFDUP_ALT_BACKOFF_VAL 0x0A
+#define DEFAULT_HALFDUP_ALT_BACKOFF_EN FALSE
+#define DEFAULT_RX_DROP_BCAST FALSE
+#define DEFAULT_RX_SHORT_FRM TRUE
+#define DEFAULT_RX_LEN_CHECK FALSE
+#define DEFAULT_TX_PAD_CRC TRUE
+#define DEFAULT_TX_CRC FALSE
+#define DEFAULT_RX_CTRL_ACC FALSE
+#define DEFAULT_TX_PAUSE_TIME 0xf000
+#define DEFAULT_TBIPA 5
+#define DEFAULT_RX_PREPEND 0
+#define DEFAULT_PTP_TSU_EN TRUE
+#define DEFAULT_PTP_EXCEPTION_EN TRUE
+#define DEFAULT_PREAMBLE_LEN 7
+#define DEFAULT_RX_PREAMBLE FALSE
+#define DEFAULT_TX_PREAMBLE FALSE
+#define DEFAULT_LOOPBACK FALSE
+#define DEFAULT_RX_TIME_STAMP_EN FALSE
+#define DEFAULT_TX_TIME_STAMP_EN FALSE
+#define DEFAULT_RX_FLOW TRUE
+#define DEFAULT_TX_FLOW TRUE
+#define DEFAULT_RX_GROUP_HASH_EXD FALSE
+#define DEFAULT_TX_PAUSE_TIME_EXTD 0
+#define DEFAULT_RX_PROMISC FALSE
+#define DEFAULT_NON_BACK_TO_BACK_IPG1 0x40
+#define DEFAULT_NON_BACK_TO_BACK_IPG2 0x60
+#define DEFAULT_MIN_IFG_ENFORCEMENT 0x50
+#define DEFAULT_BACK_TO_BACK_IPG 0x60
+#define DEFAULT_MAXIMUM_FRAME 0x600
+#define DEFAULT_TBI_PHY_ADDR 5
+#define DEFAULT_WAKE_ON_LAN FALSE
+
+/* register related defines (bits, field offsets..) */
+#define DTSEC_ID1_ID 0xffff0000
+#define DTSEC_ID1_REV_MJ 0x0000FF00
+#define DTSEC_ID1_REV_MN 0x000000ff
+
+#define DTSEC_ID2_INT_REDUCED_OFF 0x00010000
+#define DTSEC_ID2_INT_NORMAL_OFF 0x00020000
+
+#define DTSEC_ECNTRL_CLRCNT 0x00004000
+#define DTSEC_ECNTRL_AUTOZ 0x00002000
+#define DTSEC_ECNTRL_STEN 0x00001000
+#define DTSEC_ECNTRL_CFG_RO 0x80000000
+#define DTSEC_ECNTRL_GMIIM 0x00000040
+#define DTSEC_ECNTRL_TBIM 0x00000020
+#define DTSEC_ECNTRL_SGMIIM 0x00000002
+#define DTSEC_ECNTRL_RPM 0x00000010
+#define DTSEC_ECNTRL_R100M 0x00000008
+#define DTSEC_ECNTRL_RMM 0x00000004
+#define DTSEC_ECNTRL_QSGMIIM 0x00000001
+
+#define DTSEC_TCTRL_THDF 0x00000800
+#define DTSEC_TCTRL_TTSE 0x00000040
+#define DTSEC_TCTRL_GTS 0x00000020
+#define DTSEC_TCTRL_TFC_PAUSE 0x00000010
+
+/* PTV offsets */
+#define PTV_PTE_OFST 16
+
+#define RCTRL_CFA 0x00008000
+#define RCTRL_GHTX 0x00000400
+#define RCTRL_RTSE 0x00000040
+#define RCTRL_GRS 0x00000020
+#define RCTRL_BC_REJ 0x00000010
+#define RCTRL_MPROM 0x00000008
+#define RCTRL_RSF 0x00000004
+#define RCTRL_UPROM 0x00000001
+#define RCTRL_PROM (RCTRL_UPROM | RCTRL_MPROM)
+
+#define TMR_CTL_ESFDP 0x00000800
+#define TMR_CTL_ESFDE 0x00000400
+
+#define MACCFG1_SOFT_RESET 0x80000000
+#define MACCFG1_LOOPBACK 0x00000100
+#define MACCFG1_RX_FLOW 0x00000020
+#define MACCFG1_TX_FLOW 0x00000010
+#define MACCFG1_TX_EN 0x00000001
+#define MACCFG1_RX_EN 0x00000004
+#define MACCFG1_RESET_RxMC 0x00080000
+#define MACCFG1_RESET_TxMC 0x00040000
+#define MACCFG1_RESET_RxFUN 0x00020000
+#define MACCFG1_RESET_TxFUN 0x00010000
+
+#define MACCFG2_NIBBLE_MODE 0x00000100
+#define MACCFG2_BYTE_MODE 0x00000200
+#define MACCFG2_PRE_AM_Rx_EN 0x00000080
+#define MACCFG2_PRE_AM_Tx_EN 0x00000040
+#define MACCFG2_LENGTH_CHECK 0x00000010
+#define MACCFG2_MAGIC_PACKET_EN 0x00000008
+#define MACCFG2_PAD_CRC_EN 0x00000004
+#define MACCFG2_CRC_EN 0x00000002
+#define MACCFG2_FULL_DUPLEX 0x00000001
+
+#define PREAMBLE_LENGTH_SHIFT 12
+
+#define IPGIFG_NON_BACK_TO_BACK_IPG_1_SHIFT 24
+#define IPGIFG_NON_BACK_TO_BACK_IPG_2_SHIFT 16
+#define IPGIFG_MIN_IFG_ENFORCEMENT_SHIFT 8
+
+#define IPGIFG_NON_BACK_TO_BACK_IPG_1 0x7F000000
+#define IPGIFG_NON_BACK_TO_BACK_IPG_2 0x007F0000
+#define IPGIFG_MIN_IFG_ENFORCEMENT 0x0000FF00
+#define IPGIFG_BACK_TO_BACK_IPG 0x0000007F
+
+#define HAFDUP_ALT_BEB 0x00080000
+#define HAFDUP_BP_NO_BACKOFF 0x00040000
+#define HAFDUP_NO_BACKOFF 0x00020000
+#define HAFDUP_EXCESS_DEFER 0x00010000
+#define HAFDUP_COLLISION_WINDOW 0x000003ff
+
+#define HAFDUP_ALTERNATE_BEB_TRUNCATION_SHIFT 20
+#define HAFDUP_RETRANSMISSION_MAX_SHIFT 12
+#define HAFDUP_RETRANSMISSION_MAX 0x0000f000
+
+#define NUM_OF_HASH_REGS 8 /* Number of hash table registers */
+
+/* CAR1/2 bits */
+#define DTSEC_CAR1_TR64 0x80000000
+#define DTSEC_CAR1_TR127 0x40000000
+#define DTSEC_CAR1_TR255 0x20000000
+#define DTSEC_CAR1_TR511 0x10000000
+#define DTSEC_CAR1_TRK1 0x08000000
+#define DTSEC_CAR1_TRMAX 0x04000000
+#define DTSEC_CAR1_TRMGV 0x02000000
+
+#define DTSEC_CAR1_RBYT 0x00010000
+#define DTSEC_CAR1_RPKT 0x00008000
+#define DTSEC_CAR1_RFCS 0x00004000
+#define DTSEC_CAR1_RMCA 0x00002000
+#define DTSEC_CAR1_RBCA 0x00001000
+#define DTSEC_CAR1_RXCF 0x00000800
+#define DTSEC_CAR1_RXPF 0x00000400
+#define DTSEC_CAR1_RXUO 0x00000200
+#define DTSEC_CAR1_RALN 0x00000100
+#define DTSEC_CAR1_RFLR 0x00000080
+#define DTSEC_CAR1_RCDE 0x00000040
+#define DTSEC_CAR1_RCSE 0x00000020
+#define DTSEC_CAR1_RUND 0x00000010
+#define DTSEC_CAR1_ROVR 0x00000008
+#define DTSEC_CAR1_RFRG 0x00000004
+#define DTSEC_CAR1_RJBR 0x00000002
+#define DTSEC_CAR1_RDRP 0x00000001
+
+#define DTSEC_CAR2_TJBR 0x00080000
+#define DTSEC_CAR2_TFCS 0x00040000
+#define DTSEC_CAR2_TXCF 0x00020000
+#define DTSEC_CAR2_TOVR 0x00010000
+#define DTSEC_CAR2_TUND 0x00008000
+#define DTSEC_CAR2_TFRG 0x00004000
+#define DTSEC_CAR2_TBYT 0x00002000
+#define DTSEC_CAR2_TPKT 0x00001000
+#define DTSEC_CAR2_TMCA 0x00000800
+#define DTSEC_CAR2_TBCA 0x00000400
+#define DTSEC_CAR2_TXPF 0x00000200
+#define DTSEC_CAR2_TDFR 0x00000100
+#define DTSEC_CAR2_TEDF 0x00000080
+#define DTSEC_CAR2_TSCL 0x00000040
+#define DTSEC_CAR2_TMCL 0x00000020
+#define DTSEC_CAR2_TLCL 0x00000010
+#define DTSEC_CAR2_TXCL 0x00000008
+#define DTSEC_CAR2_TNCL 0x00000004
+#define DTSEC_CAR2_TDRP 0x00000001
+
+#define CAM1_ERRORS_ONLY \
+ (DTSEC_CAR1_RXPF | DTSEC_CAR1_RALN | DTSEC_CAR1_RFLR \
+ | DTSEC_CAR1_RCDE | DTSEC_CAR1_RCSE | DTSEC_CAR1_RUND \
+ | DTSEC_CAR1_ROVR | DTSEC_CAR1_RFRG | DTSEC_CAR1_RJBR \
+ | DTSEC_CAR1_RDRP)
+
+#define CAM2_ERRORS_ONLY (DTSEC_CAR2_TFCS | DTSEC_CAR2_TXPF | DTSEC_CAR2_TDRP)
+
+/*
+ * Group of dTSEC specific counters relating to the standard RMON MIB Group 1
+ * (or Ethernet) statistics.
+ */
+#define CAM1_MIB_GRP_1 \
+ (DTSEC_CAR1_RDRP | DTSEC_CAR1_RBYT | DTSEC_CAR1_RPKT | DTSEC_CAR1_RMCA\
+ | DTSEC_CAR1_RBCA | DTSEC_CAR1_RALN | DTSEC_CAR1_RUND | DTSEC_CAR1_ROVR\
+ | DTSEC_CAR1_RFRG | DTSEC_CAR1_RJBR \
+ | DTSEC_CAR1_TR64 | DTSEC_CAR1_TR127 | DTSEC_CAR1_TR255 \
+ | DTSEC_CAR1_TR511 | DTSEC_CAR1_TRMAX)
+
+#define CAM2_MIB_GRP_1 (DTSEC_CAR2_TNCL | DTSEC_CAR2_TDRP)
+
+/* memory map */
+
+struct dtsec_regs {
+ /* dTSEC General Control and Status Registers */
+ uint32_t tsec_id; /* 0x000 ETSEC_ID register */
+ uint32_t tsec_id2; /* 0x004 ETSEC_ID2 register */
+ uint32_t ievent; /* 0x008 Interrupt event register */
+ uint32_t imask; /* 0x00C Interrupt mask register */
+ uint32_t reserved0010[1];
+ uint32_t ecntrl; /* 0x014 E control register */
+ uint32_t ptv; /* 0x018 Pause time value register */
+ uint32_t tbipa; /* 0x01C TBI PHY address register */
+ uint32_t tmr_ctrl; /* 0x020 Time-stamp Control register */
+ uint32_t tmr_pevent; /* 0x024 Time-stamp event register */
+ uint32_t tmr_pemask; /* 0x028 Timer event mask register */
+ uint32_t reserved002c[5];
+ uint32_t tctrl; /* 0x040 Transmit control register */
+ uint32_t reserved0044[3];
+ uint32_t rctrl; /* 0x050 Receive control register */
+ uint32_t reserved0054[11];
+ uint32_t igaddr[8]; /* 0x080-0x09C Individual/group address */
+ uint32_t gaddr[8]; /* 0x0A0-0x0BC Group address registers 0-7 */
+ uint32_t reserved00c0[16];
+ uint32_t maccfg1; /* 0x100 MAC configuration #1 */
+ uint32_t maccfg2; /* 0x104 MAC configuration #2 */
+ uint32_t ipgifg; /* 0x108 IPG/IFG */
+ uint32_t hafdup; /* 0x10C Half-duplex */
+ uint32_t maxfrm; /* 0x110 Maximum frame */
+ uint32_t reserved0114[10];
+ uint32_t ifstat; /* 0x13C Interface status */
+ uint32_t macstnaddr1; /* 0x140 Station Address,part 1 */
+ uint32_t macstnaddr2; /* 0x144 Station Address,part 2 */
+ struct {
+ uint32_t exact_match1; /* octets 1-4 */
+ uint32_t exact_match2; /* octets 5-6 */
+ } macaddr[15]; /* 0x148-0x1BC mac exact match addresses 1-15 */
+ uint32_t reserved01c0[16];
+ uint32_t tr64; /* 0x200 transmit and receive 64 byte frame counter */
+ uint32_t tr127; /* 0x204 transmit and receive 65 to 127 byte frame
+ * counter */
+ uint32_t tr255; /* 0x208 transmit and receive 128 to 255 byte frame
+ * counter */
+ uint32_t tr511; /* 0x20C transmit and receive 256 to 511 byte frame
+ * counter */
+ uint32_t tr1k; /* 0x210 transmit and receive 512 to 1023 byte frame
+ * counter */
+ uint32_t trmax; /* 0x214 transmit and receive 1024 to 1518 byte frame
+ * counter */
+ uint32_t trmgv; /* 0x218 transmit and receive 1519 to 1522 byte good
+ * VLAN frame count */
+ uint32_t rbyt; /* 0x21C receive byte counter */
+ uint32_t rpkt; /* 0x220 receive packet counter */
+ uint32_t rfcs; /* 0x224 receive FCS error counter */
+ uint32_t rmca; /* 0x228 RMCA receive multicast packet counter */
+ uint32_t rbca; /* 0x22C receive broadcast packet counter */
+ uint32_t rxcf; /* 0x230 receive control frame packet counter */
+ uint32_t rxpf; /* 0x234 receive pause frame packet counter */
+ uint32_t rxuo; /* 0x238 receive unknown OP code counter */
+ uint32_t raln; /* 0x23C receive alignment error counter */
+ uint32_t rflr; /* 0x240 receive frame length error counter */
+ uint32_t rcde; /* 0x244 receive code error counter */
+ uint32_t rcse; /* 0x248 receive carrier sense error counter */
+ uint32_t rund; /* 0x24C receive undersize packet counter */
+ uint32_t rovr; /* 0x250 receive oversize packet counter */
+ uint32_t rfrg; /* 0x254 receive fragments counter */
+ uint32_t rjbr; /* 0x258 receive jabber counter */
+ uint32_t rdrp; /* 0x25C receive drop */
+ uint32_t tbyt; /* 0x260 transmit byte counter */
+ uint32_t tpkt; /* 0x264 transmit packet counter */
+ uint32_t tmca; /* 0x268 transmit multicast packet counter */
+ uint32_t tbca; /* 0x26C transmit broadcast packet counter */
+ uint32_t txpf; /* 0x270 transmit pause control frame counter */
+ uint32_t tdfr; /* 0x274 transmit deferral packet counter */
+ uint32_t tedf; /* 0x278 transmit excessive deferral packet counter */
+ uint32_t tscl; /* 0x27C transmit single collision packet counter */
+ uint32_t tmcl; /* 0x280 transmit multiple collision packet counter */
+ uint32_t tlcl; /* 0x284 transmit late collision packet counter */
+ uint32_t txcl; /* 0x288 transmit excessive collision packet counter */
+ uint32_t tncl; /* 0x28C transmit total collision counter */
+ uint32_t reserved0290[1];
+ uint32_t tdrp; /* 0x294 transmit drop frame counter */
+ uint32_t tjbr; /* 0x298 transmit jabber frame counter */
+ uint32_t tfcs; /* 0x29C transmit FCS error counter */
+ uint32_t txcf; /* 0x2A0 transmit control frame counter */
+ uint32_t tovr; /* 0x2A4 transmit oversize frame counter */
+ uint32_t tund; /* 0x2A8 transmit undersize frame counter */
+ uint32_t tfrg; /* 0x2AC transmit fragments frame counter */
+ uint32_t car1; /* 0x2B0 carry register one register* */
+ uint32_t car2; /* 0x2B4 carry register two register* */
+ uint32_t cam1; /* 0x2B8 carry register one mask register */
+ uint32_t cam2; /* 0x2BC carry register two mask register */
+ uint32_t reserved02c0[848];
+};
+
+/**
+ * struct dtsec_mib_grp_1_counters - MIB counter overflows
+ *
+ * @tr64: Transmit and Receive 64 byte frame count. Increment for each
+ * good or bad frame, of any type, transmitted or received, which
+ * is 64 bytes in length.
+ * @tr127: Transmit and Receive 65 to 127 byte frame count. Increments for
+ * each good or bad frame of any type, transmitted or received,
+ * which is 65-127 bytes in length.
+ * @tr255: Transmit and Receive 128 to 255 byte frame count. Increments
+ * for each good or bad frame, of any type, transmitted or
+ * received, which is 128-255 bytes in length.
+ * @tr511: Transmit and Receive 256 to 511 byte frame count. Increments
+ * for each good or bad frame, of any type, transmitted or
+ * received, which is 256-511 bytes in length.
+ * @tr1k: Transmit and Receive 512 to 1023 byte frame count. Increments
+ * for each good or bad frame, of any type, transmitted or
+ * received, which is 512-1023 bytes in length.
+ * @trmax: Transmit and Receive 1024 to 1518 byte frame count. Increments
+ * for each good or bad frame, of any type, transmitted or
+ * received, which is 1024-1518 bytes in length.
+ * @rfrg: Receive fragments count. Increments for each received frame
+ * which is less than 64 bytes in length and contains an invalid
+ * FCS. This includes integral and non-integral lengths.
+ * @rjbr: Receive jabber count. Increments for received frames which
+ * exceed 1518 (non VLAN) or 1522 (VLAN) bytes and contain an
+ * invalid FCS. This includes alignment errors.
+ * @rdrp: Receive dropped packets count. Increments for received frames
+ * which are streamed to system but are later dropped due to lack
+ * of system resources. Does not increment for frames rejected due
+ * to address filtering.
+ * @raln: Receive alignment error count. Increments for each received
+ * frame from 64 to 1518 (non VLAN) or 1522 (VLAN) which contains
+ * an invalid FCS and is not an integral number of bytes.
+ * @rund: Receive undersize packet count. Increments each time a frame is
+ * received which is less than 64 bytes in length and contains a
+ * valid FCS and is otherwise well formed. This count does not
+ * include range length errors.
+ * @rovr: Receive oversize packet count. Increments each time a frame is
+ * received which exceeded 1518 (non VLAN) or 1522 (VLAN) and
+ * contains a valid FCS and is otherwise well formed.
+ * @rbyt: Receive byte count. Increments by the byte count of frames
+ * received, including those in bad packets, excluding preamble and
+ * SFD but including FCS bytes.
+ * @rpkt: Receive packet count. Increments for each received frame
+ * (including bad packets, all unicast, broadcast, and multicast
+ * packets).
+ * @rmca: Receive multicast packet count. Increments for each multicast
+ * frame with valid CRC and of lengths 64 to 1518 (non VLAN) or
+ * 1522 (VLAN), excluding broadcast frames. This count does not
+ * include range/length errors.
+ * @rbca: Receive broadcast packet count. Increments for each broadcast
+ * frame with valid CRC and of lengths 64 to 1518 (non VLAN) or
+ * 1522 (VLAN), excluding multicast frames. Does not include
+ * range/length errors.
+ * @tdrp: Transmit drop frame count. Increments each time a memory error
+ * or an underrun has occurred.
+ * @tncl: Transmit total collision counter. Increments by the number of
+ * collisions experienced during the transmission of a frame. Does
+ * not increment for aborted frames.
+ *
+ * The structure contains a group of dTSEC HW specific counters relating to the
+ * standard RMON MIB Group 1 (or Ethernet statistics) counters. This structure
+ * is counting only the carry events of the corresponding HW counters.
+ *
+ * tr64 to trmax notes: Frame sizes specified are considered excluding preamble
+ * and SFD but including FCS bytes.
+ */
+struct dtsec_mib_grp_1_counters {
+ uint64_t rdrp;
+ uint64_t tdrp;
+ uint64_t rbyt;
+ uint64_t rpkt;
+ uint64_t rbca;
+ uint64_t rmca;
+ uint64_t raln;
+ uint64_t rund;
+ uint64_t rovr;
+ uint64_t rfrg;
+ uint64_t rjbr;
+ uint64_t tncl;
+ uint64_t tr64;
+ uint64_t tr127;
+ uint64_t tr255;
+ uint64_t tr511;
+ uint64_t tr1k;
+ uint64_t trmax;
+};
+
+enum dtsec_stat_counters {
+ E_DTSEC_STAT_TR64,
+ E_DTSEC_STAT_TR127,
+ E_DTSEC_STAT_TR255,
+ E_DTSEC_STAT_TR511,
+ E_DTSEC_STAT_TR1K,
+ E_DTSEC_STAT_TRMAX,
+ E_DTSEC_STAT_TRMGV,
+ E_DTSEC_STAT_RBYT,
+ E_DTSEC_STAT_RPKT,
+ E_DTSEC_STAT_RMCA,
+ E_DTSEC_STAT_RBCA,
+ E_DTSEC_STAT_RXPF,
+ E_DTSEC_STAT_RALN,
+ E_DTSEC_STAT_RFLR,
+ E_DTSEC_STAT_RCDE,
+ E_DTSEC_STAT_RCSE,
+ E_DTSEC_STAT_RUND,
+ E_DTSEC_STAT_ROVR,
+ E_DTSEC_STAT_RFRG,
+ E_DTSEC_STAT_RJBR,
+ E_DTSEC_STAT_RDRP,
+ E_DTSEC_STAT_TFCS,
+ E_DTSEC_STAT_TBYT,
+ E_DTSEC_STAT_TPKT,
+ E_DTSEC_STAT_TMCA,
+ E_DTSEC_STAT_TBCA,
+ E_DTSEC_STAT_TXPF,
+ E_DTSEC_STAT_TNCL,
+ E_DTSEC_STAT_TDRP
+};
+
+enum dtsec_stat_level {
+ /* No statistics */
+ E_MAC_STAT_NONE = 0,
+ /* Only RMON MIB group 1 (ether stats). Optimized for performance */
+ E_MAC_STAT_MIB_GRP1,
+ /* Only error counters are available. Optimized for performance */
+ E_MAC_STAT_PARTIAL,
+ /* All counters available. Not optimized for performance */
+ E_MAC_STAT_FULL
+};
+
+
+/**
+ * struct dtsec_cfg - dTSEC configuration
+ *
+ * @halfdup_on: Transmit half-duplex flow control, under software
+ * control for 10/100-Mbps half-duplex media. If set,
+ * back pressure is applied to media by raising carrier.
+ * @halfdup_retransmit: Number of retransmission attempts following a collision.
+ * If this is exceeded dTSEC aborts transmission due to
+ * excessive collisions. The standard specifies the
+ * attempt limit to be 15.
+ * @halfdup_coll_window:The number of bytes of the frame during which
+ * collisions may occur. The default value of 55
+ * corresponds to the frame byte at the end of the
+ * standard 512-bit slot time window. If collisions are
+ * detected after this byte, the late collision event is
+ * asserted and transmission of current frame is aborted.
+ * @rx_drop_bcast: Discard broadcast frames. If set, all broadcast frames
+ * will be discarded by dTSEC.
+ * @rx_short_frm: Accept short frames. If set, dTSEC will accept frames
+ * of length 14..63 bytes.
+ * @rx_len_check: Length check for received frames. If set, the MAC
+ * checks the frame's length field on receive to ensure it
+ * matches the actual data field length. This only works
+ * for received frames with length field less than 1500.
+ * No check is performed for larger frames.
+ * @tx_pad_crc: Pad and append CRC. If set, the MAC pads all
+ * transmitted short frames and appends a CRC to every
+ * frame regardless of padding requirement.
+ * @tx_crc: Transmission CRC enable. If set, the MAC appends a CRC
+ * to all frames. If frames presented to the MAC have a
+ * valid length and contain a valid CRC, @tx_crc should be
+ * reset.
+ * This field is ignored if @tx_pad_crc is set.
+ * @rx_ctrl_acc: Control frame accept. If set, this overrides 802.3
+ * standard control frame behavior, and all Ethernet frames
+ * that have an ethertype of 0x8808 are treated as normal
+ * Ethernet frames and passed up to the packet interface on
+ * a DA match. Received pause control frames are passed to
+ * the packet interface only if Rx flow control is also
+ * disabled. See fman_dtsec_handle_rx_pause() function.
+ * @tx_pause_time: Transmit pause time value. This pause value is used as
+ * part of the pause frame to be sent when a transmit pause
+ * frame is initiated. If set to 0 this disables
+ * transmission of pause frames.
+ * @rx_preamble: Receive preamble enable. If set, the MAC recovers the
+ * received Ethernet 7-byte preamble and passes it to the
+ * packet interface at the start of each received frame.
+ * This field should be reset for internal MAC loop-back
+ * mode.
+ * @tx_preamble: User defined preamble enable for transmitted frames.
+ * If set, a user-defined preamble must passed to the MAC
+ * and it is transmitted instead of the standard preamble.
+ * @preamble_len: Length, in bytes, of the preamble field preceding each
+ * Ethernet start-of-frame delimiter byte. The default
+ * value of 0x7 should be used in order to guarantee
+ * reliable operation with IEEE 802.3 compliant hardware.
+ * @rx_prepend: Packet alignment padding length. The specified number
+ * of bytes (1-31) of zero padding are inserted before the
+ * start of each received frame. For Ethernet, where
+ * optional preamble extraction is enabled, the padding
+ * appears before the preamble, otherwise the padding
+ * precedes the layer 2 header.
+ *
+ * This structure contains basic dTSEC configuration and must be passed to
+ * fman_dtsec_init() function. A default set of configuration values can be
+ * obtained by calling fman_dtsec_defconfig().
+ */
+struct dtsec_cfg {
+ bool halfdup_on;
+ bool halfdup_alt_backoff_en;
+ bool halfdup_excess_defer;
+ bool halfdup_no_backoff;
+ bool halfdup_bp_no_backoff;
+ uint8_t halfdup_alt_backoff_val;
+ uint16_t halfdup_retransmit;
+ uint16_t halfdup_coll_window;
+ bool rx_drop_bcast;
+ bool rx_short_frm;
+ bool rx_len_check;
+ bool tx_pad_crc;
+ bool tx_crc;
+ bool rx_ctrl_acc;
+ unsigned short tx_pause_time;
+ unsigned short tbipa;
+ bool ptp_tsu_en;
+ bool ptp_exception_en;
+ bool rx_preamble;
+ bool tx_preamble;
+ unsigned char preamble_len;
+ unsigned char rx_prepend;
+ bool loopback;
+ bool rx_time_stamp_en;
+ bool tx_time_stamp_en;
+ bool rx_flow;
+ bool tx_flow;
+ bool rx_group_hash_exd;
+ bool rx_promisc;
+ uint8_t tbi_phy_addr;
+ uint16_t tx_pause_time_extd;
+ uint16_t maximum_frame;
+ uint32_t non_back_to_back_ipg1;
+ uint32_t non_back_to_back_ipg2;
+ uint32_t min_ifg_enforcement;
+ uint32_t back_to_back_ipg;
+ bool wake_on_lan;
+};
+
+
+/**
+ * fman_dtsec_defconfig() - Get default dTSEC configuration
+ * @cfg: pointer to configuration structure.
+ *
+ * Call this function to obtain a default set of configuration values for
+ * initializing dTSEC. The user can overwrite any of the values before calling
+ * fman_dtsec_init(), if specific configuration needs to be applied.
+ */
+void fman_dtsec_defconfig(struct dtsec_cfg *cfg);
+
+/**
+ * fman_dtsec_init() - Init dTSEC hardware block
+ * @regs: Pointer to dTSEC register block
+ * @cfg: dTSEC configuration data
+ * @iface_mode: dTSEC interface mode, the type of MAC - PHY interface.
+ * @iface_speed: 1G or 10G
+ * @macaddr: MAC station address to be assigned to the device
+ * @fm_rev_maj: major rev number
+ * @fm_rev_min: minor rev number
+ * @exceptions_mask: initial exceptions mask
+ *
+ * This function initializes dTSEC and applies basic configuration.
+ *
+ * dTSEC initialization sequence:
+ * Before enabling Rx/Tx call dtsec_set_address() to set MAC address,
+ * fman_dtsec_adjust_link() to configure interface speed and duplex and finally
+ * dtsec_enable_tx()/dtsec_enable_rx() to start transmission and reception.
+ *
+ * Returns: 0 if successful, an error code otherwise.
+ */
+int fman_dtsec_init(struct dtsec_regs *regs, struct dtsec_cfg *cfg,
+ enum enet_interface iface_mode,
+ enum enet_speed iface_speed,
+ uint8_t *macaddr, uint8_t fm_rev_maj,
+ uint8_t fm_rev_min,
+ uint32_t exception_mask);
+
+/**
+ * fman_dtsec_enable() - Enable dTSEC Tx and Tx
+ * @regs: Pointer to dTSEC register block
+ * @apply_rx: enable rx side
+ * @apply_tx: enable tx side
+ *
+ * This function resets Tx and Rx graceful stop bit and enables dTSEC Tx and Rx.
+ */
+void fman_dtsec_enable(struct dtsec_regs *regs, bool apply_rx, bool apply_tx);
+
+/**
+ * fman_dtsec_disable() - Disable dTSEC Tx and Rx
+ * @regs: Pointer to dTSEC register block
+ * @apply_rx: disable rx side
+ * @apply_tx: disable tx side
+ *
+ * This function disables Tx and Rx in dTSEC.
+ */
+void fman_dtsec_disable(struct dtsec_regs *regs, bool apply_rx, bool apply_tx);
+
+/**
+ * fman_dtsec_get_revision() - Get dTSEC hardware revision
+ * @regs: Pointer to dTSEC register block
+ *
+ * Returns dtsec_id content
+ *
+ * Call this function to obtain the dTSEC hardware version.
+ */
+uint32_t fman_dtsec_get_revision(struct dtsec_regs *regs);
+
+/**
+ * fman_dtsec_set_mac_address() - Set MAC station address
+ * @regs: Pointer to dTSEC register block
+ * @macaddr: MAC address array
+ *
+ * This function sets MAC station address. To enable unicast reception call
+ * this after fman_dtsec_init(). While promiscuous mode is disabled dTSEC will
+ * match the destination address of received unicast frames against this
+ * address.
+ */
+void fman_dtsec_set_mac_address(struct dtsec_regs *regs, uint8_t *macaddr);
+
+/**
+ * fman_dtsec_get_mac_address() - Query MAC station address
+ * @regs: Pointer to dTSEC register block
+ * @macaddr: MAC address array
+ */
+void fman_dtsec_get_mac_address(struct dtsec_regs *regs, uint8_t *macaddr);
+
+/**
+ * fman_dtsec_set_uc_promisc() - Sets unicast promiscuous mode
+ * @regs: Pointer to dTSEC register block
+ * @enable: Enable unicast promiscuous mode
+ *
+ * Use this function to enable/disable dTSEC L2 address filtering. If the
+ * address filtering is disabled all unicast packets are accepted.
+ * To set dTSEC in promiscuous mode call both fman_dtsec_set_uc_promisc() and
+ * fman_dtsec_set_mc_promisc() to disable filtering for both unicast and
+ * multicast addresses.
+ */
+void fman_dtsec_set_uc_promisc(struct dtsec_regs *regs, bool enable);
+
+/**
+ * fman_dtsec_set_wol() - Enable/Disable wake on lan
+ * (magic packet support)
+ * @regs: Pointer to dTSEC register block
+ * @en: Enable Wake On Lan support in dTSEC
+ *
+ */
+void fman_dtsec_set_wol(struct dtsec_regs *regs, bool en);
+
+/**
+ * fman_dtsec_adjust_link() - Adjust dTSEC speed/duplex settings
+ * @regs: Pointer to dTSEC register block
+ * @iface_mode: dTSEC interface mode
+ * @speed: Link speed
+ * @full_dx: True for full-duplex, false for half-duplex.
+ *
+ * This function configures the MAC to function and the desired rates. Use it
+ * to configure dTSEC after fman_dtsec_init() and whenever the link speed
+ * changes (for instance following PHY auto-negociation).
+ *
+ * Returns: 0 if successful, an error code otherwise.
+ */
+int fman_dtsec_adjust_link(struct dtsec_regs *regs,
+ enum enet_interface iface_mode,
+ enum enet_speed speed, bool full_dx);
+
+/**
+ * fman_dtsec_set_tbi_phy_addr() - Updates TBI address field
+ * @regs: Pointer to dTSEC register block
+ * @address: Valid PHY address in the range of 1 to 31. 0 is reserved.
+ *
+ * In SGMII mode, the dTSEC's TBIPA field must contain a valid TBI PHY address
+ * so that the associated TBI PHY (i.e. the link) may be initialized.
+ *
+ * Returns: 0 if successful, an error code otherwise.
+ */
+int fman_dtsec_set_tbi_phy_addr(struct dtsec_regs *regs,
+ uint8_t addr);
+
+/**
+ * fman_dtsec_set_max_frame_len() - Set max frame length
+ * @regs: Pointer to dTSEC register block
+ * @length: Max frame length.
+ *
+ * Sets maximum frame length for received and transmitted frames. Frames that
+ * exceeds this length are truncated.
+ */
+void fman_dtsec_set_max_frame_len(struct dtsec_regs *regs, uint16_t length);
+
+/**
+ * fman_dtsec_get_max_frame_len() - Query max frame length
+ * @regs: Pointer to dTSEC register block
+ *
+ * Returns: the current value of the maximum frame length.
+ */
+uint16_t fman_dtsec_get_max_frame_len(struct dtsec_regs *regs);
+
+/**
+ * fman_dtsec_handle_rx_pause() - Configure pause frame handling
+ * @regs: Pointer to dTSEC register block
+ * @en: Enable pause frame handling in dTSEC
+ *
+ * If enabled, dTSEC will handle pause frames internally. This must be disabled
+ * if dTSEC is set in half-duplex mode.
+ * If pause frame handling is disabled and &dtsec_cfg.rx_ctrl_acc is set, pause
+ * frames will be transferred to the packet interface just like regular Ethernet
+ * frames.
+ */
+void fman_dtsec_handle_rx_pause(struct dtsec_regs *regs, bool en);
+
+/**
+ * fman_dtsec_set_tx_pause_frames() - Configure Tx pause time
+ * @regs: Pointer to dTSEC register block
+ * @time: Time value included in pause frames
+ *
+ * Call this function to set the time value used in transmitted pause frames.
+ * If time is 0, transmission of pause frames is disabled
+ */
+void fman_dtsec_set_tx_pause_frames(struct dtsec_regs *regs, uint16_t time);
+
+/**
+ * fman_dtsec_ack_event() - Acknowledge handled events
+ * @regs: Pointer to dTSEC register block
+ * @ev_mask: Events to acknowledge
+ *
+ * After handling events signaled by dTSEC in either polling or interrupt mode,
+ * call this function to reset the associated status bits in dTSEC event
+ * register.
+ */
+void fman_dtsec_ack_event(struct dtsec_regs *regs, uint32_t ev_mask);
+
+/**
+ * fman_dtsec_get_event() - Returns currently asserted events
+ * @regs: Pointer to dTSEC register block
+ * @ev_mask: Mask of relevant events
+ *
+ * Call this function to obtain a bit-mask of events that are currently asserted
+ * in dTSEC, taken from IEVENT register.
+ *
+ * Returns: a bit-mask of events asserted in dTSEC.
+ */
+uint32_t fman_dtsec_get_event(struct dtsec_regs *regs, uint32_t ev_mask);
+
+/**
+ * fman_dtsec_get_interrupt_mask() - Returns a bit-mask of enabled interrupts
+ * @regs: Pointer to dTSEC register block
+ *
+ * Call this function to obtain a bit-mask of enabled interrupts
+ * in dTSEC, taken from IMASK register.
+ *
+ * Returns: a bit-mask of enabled interrupts in dTSEC.
+ */
+uint32_t fman_dtsec_get_interrupt_mask(struct dtsec_regs *regs);
+
+void fman_dtsec_clear_addr_in_paddr(struct dtsec_regs *regs,
+ uint8_t paddr_num);
+
+void fman_dtsec_add_addr_in_paddr(struct dtsec_regs *regs,
+ uint64_t addr,
+ uint8_t paddr_num);
+
+void fman_dtsec_enable_tmr_interrupt (struct dtsec_regs *regs);
+
+void fman_dtsec_disable_tmr_interrupt(struct dtsec_regs *regs);
+
+/**
+ * fman_dtsec_disable_interrupt() - Disables interrupts for the specified events
+ * @regs: Pointer to dTSEC register block
+ * @ev_mask: Mask of relevant events
+ *
+ * Call this function to disable interrupts in dTSEC for the specified events.
+ * To enable interrupts use fman_dtsec_enable_interrupt().
+ */
+void fman_dtsec_disable_interrupt(struct dtsec_regs *regs, uint32_t ev_mask);
+
+/**
+ * fman_dtsec_enable_interrupt() - Enable interrupts for the specified events
+ * @regs: Pointer to dTSEC register block
+ * @ev_mask: Mask of relevant events
+ *
+ * Call this function to enable interrupts in dTSEC for the specified events.
+ * To disable interrupts use fman_dtsec_disable_interrupt().
+ */
+void fman_dtsec_enable_interrupt(struct dtsec_regs *regs, uint32_t ev_mask);
+
+/**
+ * fman_dtsec_set_ts() - Enables dTSEC timestamps
+ * @regs: Pointer to dTSEC register block
+ * @en: true to enable timestamps, false to disable them
+ *
+ * Call this function to enable/disable dTSEC timestamps. This affects both
+ * Tx and Rx.
+ */
+void fman_dtsec_set_ts(struct dtsec_regs *regs, bool en);
+
+/**
+ * fman_dtsec_set_bucket() - Enables/disables a filter bucket
+ * @regs: Pointer to dTSEC register block
+ * @bucket: Bucket index
+ * @enable: true/false to enable/disable this bucket
+ *
+ * This function enables or disables the specified bucket. Enabling a bucket
+ * associated with an address configures dTSEC to accept received packets
+ * with that destination address.
+ * Multiple addresses may be associated with the same bucket. Disabling a
+ * bucket will affect all addresses associated with that bucket. A bucket that
+ * is enabled requires further filtering and verification in the upper layers
+ *
+ */
+void fman_dtsec_set_bucket(struct dtsec_regs *regs, int bucket, bool enable);
+
+/**
+ * dtsec_set_hash_table() - insert a crc code into thr filter table
+ * @regs: Pointer to dTSEC register block
+ * @crc: crc to insert
+ * @mcast: true is this is a multicast address
+ * @ghtx: true if we are in ghtx mode
+ *
+ * This function inserts a crc code into the filter table.
+ */
+void fman_dtsec_set_hash_table(struct dtsec_regs *regs, uint32_t crc,
+ bool mcast, bool ghtx);
+
+/**
+ * fman_dtsec_reset_filter_table() - Resets the address filtering table
+ * @regs: Pointer to dTSEC register block
+ * @mcast: Reset multicast entries
+ * @ucast: Reset unicast entries
+ *
+ * Resets all entries in L2 address filter table. After calling this function
+ * all buckets enabled using fman_dtsec_set_bucket() will be disabled.
+ * If dtsec_init_filter_table() was called with @unicast_hash set to false,
+ * @ucast argument is ignored.
+ * This does not affect the primary nor the 15 additional addresses configured
+ * using dtsec_set_address() or dtsec_set_match_address().
+ */
+void fman_dtsec_reset_filter_table(struct dtsec_regs *regs, bool mcast,
+ bool ucast);
+
+/**
+ * fman_dtsec_set_mc_promisc() - Set multicast promiscuous mode
+ * @regs: Pointer to dTSEC register block
+ * @enable: Enable multicast promiscuous mode
+ *
+ * Call this to enable/disable L2 address filtering for multicast packets.
+ */
+void fman_dtsec_set_mc_promisc(struct dtsec_regs *regs, bool enable);
+
+/* statistics APIs */
+
+/**
+ * fman_dtsec_set_stat_level() - Enable a group of MIB statistics counters
+ * @regs: Pointer to dTSEC register block
+ * @level: Specifies a certain group of dTSEC MIB HW counters or _all_,
+ * to specify all the existing counters.
+ * If set to _none_, it disables all the counters.
+ *
+ * Enables the MIB statistics hw counters and sets up the carry interrupt
+ * masks for the counters corresponding to the @level input parameter.
+ *
+ * Returns: error if invalid @level value given.
+ */
+int fman_dtsec_set_stat_level(struct dtsec_regs *regs,
+ enum dtsec_stat_level level);
+
+/**
+ * fman_dtsec_reset_stat() - Completely resets all dTSEC HW counters
+ * @regs: Pointer to dTSEC register block
+ */
+void fman_dtsec_reset_stat(struct dtsec_regs *regs);
+
+/**
+ * fman_dtsec_get_clear_carry_regs() - Read and clear carry bits (CAR1-2 registers)
+ * @regs: Pointer to dTSEC register block
+ * @car1: car1 register value
+ * @car2: car2 register value
+ *
+ * When set, the carry bits signal that an overflow occurred on the
+ * corresponding counters.
+ * Note that the carry bits (CAR1-2 registers) will assert the
+ * %DTSEC_IEVENT_MSRO interrupt if unmasked (via CAM1-2 regs).
+ *
+ * Returns: true if overflow occurred, otherwise - false
+ */
+bool fman_dtsec_get_clear_carry_regs(struct dtsec_regs *regs,
+ uint32_t *car1, uint32_t *car2);
+
+uint32_t fman_dtsec_check_and_clear_tmr_event(struct dtsec_regs *regs);
+
+uint32_t fman_dtsec_get_stat_counter(struct dtsec_regs *regs,
+ enum dtsec_stat_counters reg_name);
+
+void fman_dtsec_start_tx(struct dtsec_regs *regs);
+void fman_dtsec_start_rx(struct dtsec_regs *regs);
+void fman_dtsec_stop_tx(struct dtsec_regs *regs);
+void fman_dtsec_stop_rx(struct dtsec_regs *regs);
+uint32_t fman_dtsec_get_rctrl(struct dtsec_regs *regs);
+
+
+#endif /* __FSL_FMAN_DTSEC_H */
diff --git a/sys/contrib/ncsw/inc/flib/fsl_fman_dtsec_mii_acc.h b/sys/contrib/ncsw/inc/flib/fsl_fman_dtsec_mii_acc.h
new file mode 100644
index 000000000000..0dda09c3c388
--- /dev/null
+++ b/sys/contrib/ncsw/inc/flib/fsl_fman_dtsec_mii_acc.h
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2008-2013 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __FSL_FMAN_DTSEC_MII_ACC_H
+#define __FSL_FMAN_DTSEC_MII_ACC_H
+
+#include "common/general.h"
+
+
+/* MII Management Configuration Register */
+#define MIIMCFG_RESET_MGMT 0x80000000
+#define MIIMCFG_MGNTCLK_MASK 0x00000007
+#define MIIMCFG_MGNTCLK_SHIFT 0
+
+/* MII Management Command Register */
+#define MIIMCOM_SCAN_CYCLE 0x00000002
+#define MIIMCOM_READ_CYCLE 0x00000001
+
+/* MII Management Address Register */
+#define MIIMADD_PHY_ADDR_SHIFT 8
+#define MIIMADD_PHY_ADDR_MASK 0x00001f00
+
+#define MIIMADD_REG_ADDR_SHIFT 0
+#define MIIMADD_REG_ADDR_MASK 0x0000001f
+
+/* MII Management Indicator Register */
+#define MIIMIND_BUSY 0x00000001
+
+
+/* PHY Control Register */
+#define PHY_CR_PHY_RESET 0x8000
+#define PHY_CR_LOOPBACK 0x4000
+#define PHY_CR_SPEED0 0x2000
+#define PHY_CR_ANE 0x1000
+#define PHY_CR_RESET_AN 0x0200
+#define PHY_CR_FULLDUPLEX 0x0100
+#define PHY_CR_SPEED1 0x0040
+
+#define PHY_TBICON_SRESET 0x8000
+#define PHY_TBICON_SPEED2 0x0020
+#define PHY_TBICON_CLK_SEL 0x0020
+#define PHY_TBIANA_SGMII 0x4001
+#define PHY_TBIANA_1000X 0x01a0
+/* register map */
+
+/* MII Configuration Control Memory Map Registers */
+struct dtsec_mii_reg {
+ uint32_t reserved1[72];
+ uint32_t miimcfg; /* MII Mgmt:configuration */
+ uint32_t miimcom; /* MII Mgmt:command */
+ uint32_t miimadd; /* MII Mgmt:address */
+ uint32_t miimcon; /* MII Mgmt:control 3 */
+ uint32_t miimstat; /* MII Mgmt:status */
+ uint32_t miimind; /* MII Mgmt:indicators */
+};
+
+/* dTSEC MII API */
+
+/* functions to access the mii registers for phy configuration.
+ * this functionality may not be available for all dtsecs in the system.
+ * consult the reference manual for details */
+void fman_dtsec_mii_reset(struct dtsec_mii_reg *regs);
+/* frequency is in MHz.
+ * note that dtsec clock is 1/2 of fman clock */
+void fman_dtsec_mii_init(struct dtsec_mii_reg *regs, uint16_t dtsec_freq);
+int fman_dtsec_mii_write_reg(struct dtsec_mii_reg *regs,
+ uint8_t addr,
+ uint8_t reg,
+ uint16_t data,
+ uint16_t dtsec_freq);
+
+int fman_dtsec_mii_read_reg(struct dtsec_mii_reg *regs,
+ uint8_t addr,
+ uint8_t reg,
+ uint16_t *data,
+ uint16_t dtsec_freq);
+
+#endif /* __FSL_FMAN_DTSEC_MII_ACC_H */
diff --git a/sys/contrib/ncsw/inc/flib/fsl_fman_kg.h b/sys/contrib/ncsw/inc/flib/fsl_fman_kg.h
new file mode 100644
index 000000000000..010e4b709d63
--- /dev/null
+++ b/sys/contrib/ncsw/inc/flib/fsl_fman_kg.h
@@ -0,0 +1,514 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __FSL_FMAN_KG_H
+#define __FSL_FMAN_KG_H
+
+#include "common/general.h"
+
+#define FM_KG_NUM_OF_GENERIC_REGS 8 /**< Num of generic KeyGen regs */
+#define FMAN_MAX_NUM_OF_HW_PORTS 64
+/**< Total num of masks allowed on KG extractions */
+#define FM_KG_EXTRACT_MASKS_NUM 4
+#define FM_KG_NUM_CLS_PLAN_ENTR 8 /**< Num of class. plan regs */
+#define FM_KG_CLS_PLAN_GRPS_NUM 32 /**< Max num of class. groups */
+
+struct fman_kg_regs {
+ uint32_t fmkg_gcr;
+ uint32_t res004;
+ uint32_t res008;
+ uint32_t fmkg_eer;
+ uint32_t fmkg_eeer;
+ uint32_t res014;
+ uint32_t res018;
+ uint32_t fmkg_seer;
+ uint32_t fmkg_seeer;
+ uint32_t fmkg_gsr;
+ uint32_t fmkg_tpc;
+ uint32_t fmkg_serc;
+ uint32_t res030[4];
+ uint32_t fmkg_fdor;
+ uint32_t fmkg_gdv0r;
+ uint32_t fmkg_gdv1r;
+ uint32_t res04c[6];
+ uint32_t fmkg_feer;
+ uint32_t res068[38];
+ uint32_t fmkg_indirect[63];
+ uint32_t fmkg_ar;
+};
+
+struct fman_kg_scheme_regs {
+ uint32_t kgse_mode; /**< MODE */
+ uint32_t kgse_ekfc; /**< Extract Known Fields Command */
+ uint32_t kgse_ekdv; /**< Extract Known Default Value */
+ uint32_t kgse_bmch; /**< Bit Mask Command High */
+ uint32_t kgse_bmcl; /**< Bit Mask Command Low */
+ uint32_t kgse_fqb; /**< Frame Queue Base */
+ uint32_t kgse_hc; /**< Hash Command */
+ uint32_t kgse_ppc; /**< Policer Profile Command */
+ uint32_t kgse_gec[FM_KG_NUM_OF_GENERIC_REGS];
+ /**< Generic Extract Command */
+ uint32_t kgse_spc; /**< KeyGen Scheme Entry Statistic Packet Counter */
+ uint32_t kgse_dv0; /**< KeyGen Scheme Entry Default Value 0 */
+ uint32_t kgse_dv1; /**< KeyGen Scheme Entry Default Value 1 */
+ uint32_t kgse_ccbs; /**< KeyGen Scheme Entry Coarse Classification Bit*/
+ uint32_t kgse_mv; /**< KeyGen Scheme Entry Match vector */
+ uint32_t kgse_om; /**< KeyGen Scheme Entry Operation Mode bits */
+ uint32_t kgse_vsp; /**< KeyGen Scheme Entry Virtual Storage Profile */
+};
+
+struct fman_kg_pe_regs{
+ uint32_t fmkg_pe_sp;
+ uint32_t fmkg_pe_cpp;
+};
+
+struct fman_kg_cp_regs {
+ uint32_t kgcpe[FM_KG_NUM_CLS_PLAN_ENTR];
+};
+
+
+#define FM_KG_KGAR_GO 0x80000000
+#define FM_KG_KGAR_READ 0x40000000
+#define FM_KG_KGAR_WRITE 0x00000000
+#define FM_KG_KGAR_SEL_SCHEME_ENTRY 0x00000000
+#define FM_KG_KGAR_SCM_WSEL_UPDATE_CNT 0x00008000
+
+#define KG_SCH_PP_SHIFT_HIGH 0x80000000
+#define KG_SCH_PP_NO_GEN 0x10000000
+#define KG_SCH_PP_SHIFT_LOW 0x0000F000
+#define KG_SCH_MODE_NIA_PLCR 0x40000000
+#define KG_SCH_GEN_EXTRACT_TYPE 0x00008000
+#define KG_SCH_BITMASK_MASK 0x000000FF
+#define KG_SCH_GEN_VALID 0x80000000
+#define KG_SCH_GEN_MASK 0x00FF0000
+#define FM_PCD_KG_KGAR_ERR 0x20000000
+#define FM_PCD_KG_KGAR_SEL_CLS_PLAN_ENTRY 0x01000000
+#define FM_PCD_KG_KGAR_SEL_PORT_ENTRY 0x02000000
+#define FM_PCD_KG_KGAR_SEL_PORT_WSEL_SP 0x00008000
+#define FM_PCD_KG_KGAR_SEL_PORT_WSEL_CPP 0x00004000
+#define FM_PCD_KG_KGAR_WSEL_MASK 0x0000FF00
+#define KG_SCH_HASH_CONFIG_NO_FQID 0x80000000
+#define KG_SCH_HASH_CONFIG_SYM 0x40000000
+
+#define FM_EX_KG_DOUBLE_ECC 0x80000000
+#define FM_EX_KG_KEYSIZE_OVERFLOW 0x40000000
+
+/* ECC capture register */
+#define KG_FMKG_SERC_CAP 0x80000000
+#define KG_FMKG_SERC_CET 0x40000000
+#define KG_FMKG_SERC_CNT_MSK 0x00FF0000
+#define KG_FMKG_SERC_CNT_SHIFT 16
+#define KG_FMKG_SERC_ADDR_MSK 0x000003FF
+
+/* Masks */
+#define FM_KG_KGGCR_EN 0x80000000
+#define KG_SCH_GEN_VALID 0x80000000
+#define KG_SCH_GEN_EXTRACT_TYPE 0x00008000
+#define KG_ERR_TYPE_DOUBLE 0x40000000
+#define KG_ERR_ADDR_MASK 0x00000FFF
+#define KG_SCH_MODE_EN 0x80000000
+
+/* shifts */
+#define FM_KG_KGAR_NUM_SHIFT 16
+#define FM_KG_PE_CPP_MASK_SHIFT 16
+#define FM_KG_KGAR_WSEL_SHIFT 8
+
+#define FM_KG_SCH_GEN_HT_INVALID 0
+
+#define FM_KG_MASK_SEL_GEN_BASE 0x20
+
+#define KG_GET_MASK_SEL_SHIFT(shift, i) \
+switch (i) \
+{ \
+ case 0: (shift) = 26; break; \
+ case 1: (shift) = 20; break; \
+ case 2: (shift) = 10; break; \
+ case 3: (shift) = 4; break; \
+ default: (shift) = 0; \
+}
+
+#define KG_GET_MASK_OFFSET_SHIFT(shift, i) \
+switch (i) \
+{ \
+ case 0: (shift) = 16; break; \
+ case 1: (shift) = 0; break; \
+ case 2: (shift) = 28; break; \
+ case 3: (shift) = 24; break; \
+ default: (shift) = 0; \
+}
+
+#define KG_GET_MASK_SHIFT(shift, i) \
+switch (i) \
+{ \
+ case 0: shift = 24; break; \
+ case 1: shift = 16; break; \
+ case 2: shift = 8; break; \
+ case 3: shift = 0; break; \
+ default: shift = 0; \
+}
+
+/* Port entry CPP register */
+#define FMAN_KG_PE_CPP_MASK_SHIFT 16
+
+/* Scheme registers */
+#define FMAN_KG_SCH_MODE_EN 0x80000000
+#define FMAN_KG_SCH_MODE_NIA_PLCR 0x40000000
+#define FMAN_KG_SCH_MODE_CCOBASE_SHIFT 24
+
+#define FMAN_KG_SCH_DEF_MAC_ADDR_SHIFT 30
+#define FMAN_KG_SCH_DEF_VLAN_TCI_SHIFT 28
+#define FMAN_KG_SCH_DEF_ETYPE_SHIFT 26
+#define FMAN_KG_SCH_DEF_PPP_SID_SHIFT 24
+#define FMAN_KG_SCH_DEF_PPP_PID_SHIFT 22
+#define FMAN_KG_SCH_DEF_MPLS_SHIFT 20
+#define FMAN_KG_SCH_DEF_IP_ADDR_SHIFT 18
+#define FMAN_KG_SCH_DEF_PTYPE_SHIFT 16
+#define FMAN_KG_SCH_DEF_IP_TOS_TC_SHIFT 14
+#define FMAN_KG_SCH_DEF_IPv6_FL_SHIFT 12
+#define FMAN_KG_SCH_DEF_IPSEC_SPI_SHIFT 10
+#define FMAN_KG_SCH_DEF_L4_PORT_SHIFT 8
+#define FMAN_KG_SCH_DEF_TCP_FLG_SHIFT 6
+
+#define FMAN_KG_SCH_GEN_VALID 0x80000000
+#define FMAN_KG_SCH_GEN_SIZE_MAX 16
+#define FMAN_KG_SCH_GEN_OR 0x00008000
+
+#define FMAN_KG_SCH_GEN_DEF_SHIFT 29
+#define FMAN_KG_SCH_GEN_SIZE_SHIFT 24
+#define FMAN_KG_SCH_GEN_MASK_SHIFT 16
+#define FMAN_KG_SCH_GEN_HT_SHIFT 8
+
+#define FMAN_KG_SCH_HASH_HSHIFT_SHIFT 24
+#define FMAN_KG_SCH_HASH_HSHIFT_MAX 0x28
+#define FMAN_KG_SCH_HASH_SYM 0x40000000
+#define FMAN_KG_SCH_HASH_NO_FQID_GEN 0x80000000
+
+#define FMAN_KG_SCH_PP_SH_SHIFT 27
+#define FMAN_KG_SCH_PP_SL_SHIFT 12
+#define FMAN_KG_SCH_PP_SH_MASK 0x80000000
+#define FMAN_KG_SCH_PP_SL_MASK 0x0000F000
+#define FMAN_KG_SCH_PP_SHIFT_MAX 0x17
+#define FMAN_KG_SCH_PP_MASK_SHIFT 16
+#define FMAN_KG_SCH_PP_NO_GEN 0x10000000
+
+enum fman_kg_gen_extract_src {
+ E_FMAN_KG_GEN_EXTRACT_ETH,
+ E_FMAN_KG_GEN_EXTRACT_ETYPE,
+ E_FMAN_KG_GEN_EXTRACT_SNAP,
+ E_FMAN_KG_GEN_EXTRACT_VLAN_TCI_1,
+ E_FMAN_KG_GEN_EXTRACT_VLAN_TCI_N,
+ E_FMAN_KG_GEN_EXTRACT_PPPoE,
+ E_FMAN_KG_GEN_EXTRACT_MPLS_1,
+ E_FMAN_KG_GEN_EXTRACT_MPLS_2,
+ E_FMAN_KG_GEN_EXTRACT_MPLS_3,
+ E_FMAN_KG_GEN_EXTRACT_MPLS_N,
+ E_FMAN_KG_GEN_EXTRACT_IPv4_1,
+ E_FMAN_KG_GEN_EXTRACT_IPv6_1,
+ E_FMAN_KG_GEN_EXTRACT_IPv4_2,
+ E_FMAN_KG_GEN_EXTRACT_IPv6_2,
+ E_FMAN_KG_GEN_EXTRACT_MINENCAP,
+ E_FMAN_KG_GEN_EXTRACT_IP_PID,
+ E_FMAN_KG_GEN_EXTRACT_GRE,
+ E_FMAN_KG_GEN_EXTRACT_TCP,
+ E_FMAN_KG_GEN_EXTRACT_UDP,
+ E_FMAN_KG_GEN_EXTRACT_SCTP,
+ E_FMAN_KG_GEN_EXTRACT_DCCP,
+ E_FMAN_KG_GEN_EXTRACT_IPSEC_AH,
+ E_FMAN_KG_GEN_EXTRACT_IPSEC_ESP,
+ E_FMAN_KG_GEN_EXTRACT_SHIM_1,
+ E_FMAN_KG_GEN_EXTRACT_SHIM_2,
+ E_FMAN_KG_GEN_EXTRACT_FROM_DFLT,
+ E_FMAN_KG_GEN_EXTRACT_FROM_FRAME_START,
+ E_FMAN_KG_GEN_EXTRACT_FROM_PARSE_RESULT,
+ E_FMAN_KG_GEN_EXTRACT_FROM_END_OF_PARSE,
+ E_FMAN_KG_GEN_EXTRACT_FROM_FQID
+};
+
+struct fman_kg_ex_ecc_attr
+{
+ bool valid;
+ bool double_ecc;
+ uint16_t addr;
+ uint8_t single_ecc_count;
+};
+
+enum fman_kg_def_select
+{
+ E_FMAN_KG_DEF_GLOBAL_0,
+ E_FMAN_KG_DEF_GLOBAL_1,
+ E_FMAN_KG_DEF_SCHEME_0,
+ E_FMAN_KG_DEF_SCHEME_1
+};
+
+struct fman_kg_extract_def
+{
+ enum fman_kg_def_select mac_addr;
+ enum fman_kg_def_select vlan_tci;
+ enum fman_kg_def_select etype;
+ enum fman_kg_def_select ppp_sid;
+ enum fman_kg_def_select ppp_pid;
+ enum fman_kg_def_select mpls;
+ enum fman_kg_def_select ip_addr;
+ enum fman_kg_def_select ptype;
+ enum fman_kg_def_select ip_tos_tc;
+ enum fman_kg_def_select ipv6_fl;
+ enum fman_kg_def_select ipsec_spi;
+ enum fman_kg_def_select l4_port;
+ enum fman_kg_def_select tcp_flg;
+};
+
+enum fman_kg_gen_extract_type
+{
+ E_FMAN_KG_HASH_EXTRACT,
+ E_FMAN_KG_OR_EXTRACT
+};
+
+struct fman_kg_gen_extract_params
+{
+ /* Hash or Or-ed extract */
+ enum fman_kg_gen_extract_type type;
+ enum fman_kg_gen_extract_src src;
+ bool no_validation;
+ /* Extraction offset from the header location specified above */
+ uint8_t offset;
+ /* Size of extraction for FMAN_KG_HASH_EXTRACT,
+ * hash result shift for FMAN_KG_OR_EXTRACT */
+ uint8_t extract;
+ uint8_t mask;
+ /* Default value to use when header specified
+ * by fman_kg_gen_extract_src doesn't present */
+ enum fman_kg_def_select def_val;
+};
+
+struct fman_kg_extract_mask
+{
+ /**< Indication if mask is on known field extraction or
+ * on general extraction; TRUE for known field */
+ bool is_known;
+ /**< One of FMAN_KG_EXTRACT_xxx defines for known fields mask and
+ * generic register index for generic extracts mask */
+ uint32_t field_or_gen_idx;
+ /**< Byte offset from start of the extracted data specified
+ * by field_or_gen_idx */
+ uint8_t offset;
+ /**< Byte mask (selected bits will be used) */
+ uint8_t mask;
+};
+
+struct fman_kg_extract_params
+{
+ /* Or-ed mask of FMAN_KG_EXTRACT_xxx defines */
+ uint32_t known_fields;
+ struct fman_kg_extract_def known_fields_def;
+ /* Number of entries in gen_extract */
+ uint8_t gen_extract_num;
+ struct fman_kg_gen_extract_params gen_extract[FM_KG_NUM_OF_GENERIC_REGS];
+ /* Number of entries in masks */
+ uint8_t masks_num;
+ struct fman_kg_extract_mask masks[FM_KG_EXTRACT_MASKS_NUM];
+ uint32_t def_scheme_0;
+ uint32_t def_scheme_1;
+};
+
+struct fman_kg_hash_params
+{
+ bool use_hash;
+ uint8_t shift_r;
+ uint32_t mask; /**< 24-bit mask */
+ bool sym; /**< Symmetric hash for src and dest pairs */
+};
+
+struct fman_kg_pp_params
+{
+ uint8_t base;
+ uint8_t shift;
+ uint8_t mask;
+ bool bypass_pp_gen;
+};
+
+struct fman_kg_cc_params
+{
+ uint8_t base_offset;
+ uint32_t qlcv_bits_sel;
+};
+
+enum fman_pcd_engine
+{
+ E_FMAN_PCD_INVALID = 0, /**< Invalid PCD engine indicated*/
+ E_FMAN_PCD_DONE, /**< No PCD Engine indicated */
+ E_FMAN_PCD_KG, /**< Keygen indicated */
+ E_FMAN_PCD_CC, /**< Coarse classification indicated */
+ E_FMAN_PCD_PLCR, /**< Policer indicated */
+ E_FMAN_PCD_PRS /**< Parser indicated */
+};
+
+struct fman_kg_cls_plan_params
+{
+ uint8_t entries_mask;
+ uint32_t mask_vector[FM_KG_NUM_CLS_PLAN_ENTR];
+};
+
+struct fman_kg_scheme_params
+{
+ uint32_t match_vector;
+ struct fman_kg_extract_params extract_params;
+ struct fman_kg_hash_params hash_params;
+ uint32_t base_fqid;
+ /* What we do w/features supported per FM version ?? */
+ bool bypass_fqid_gen;
+ struct fman_kg_pp_params policer_params;
+ struct fman_kg_cc_params cc_params;
+ bool update_counter;
+ /**< counter_value: Set scheme counter to the specified value;
+ * relevant only when update_counter = TRUE. */
+ uint32_t counter_value;
+ enum fman_pcd_engine next_engine;
+ /**< Next engine action code */
+ uint32_t next_engine_action;
+};
+
+
+
+int fman_kg_write_ar_wait(struct fman_kg_regs *regs, uint32_t fmkg_ar);
+void fman_kg_write_sp(struct fman_kg_regs *regs, uint32_t sp, bool add);
+void fman_kg_write_cpp(struct fman_kg_regs *regs, uint32_t cpp);
+void fman_kg_get_event(struct fman_kg_regs *regs,
+ uint32_t *event,
+ uint32_t *scheme_idx);
+void fman_kg_init(struct fman_kg_regs *regs,
+ uint32_t exceptions,
+ uint32_t dflt_nia);
+void fman_kg_enable_scheme_interrupts(struct fman_kg_regs *regs);
+void fman_kg_enable(struct fman_kg_regs *regs);
+void fman_kg_disable(struct fman_kg_regs *regs);
+int fman_kg_write_bind_cls_plans(struct fman_kg_regs *regs,
+ uint8_t hwport_id,
+ uint32_t bind_cls_plans);
+int fman_kg_build_bind_cls_plans(uint8_t grp_base,
+ uint8_t grp_mask,
+ uint32_t *bind_cls_plans);
+int fman_kg_write_bind_schemes(struct fman_kg_regs *regs,
+ uint8_t hwport_id,
+ uint32_t schemes);
+int fman_kg_write_cls_plan(struct fman_kg_regs *regs,
+ uint8_t grp_id,
+ uint8_t entries_mask,
+ uint8_t hwport_id,
+ struct fman_kg_cp_regs *cls_plan_regs);
+int fman_kg_build_cls_plan(struct fman_kg_cls_plan_params *params,
+ struct fman_kg_cp_regs *cls_plan_regs);
+uint32_t fman_kg_get_schemes_total_counter(struct fman_kg_regs *regs);
+int fman_kg_set_scheme_counter(struct fman_kg_regs *regs,
+ uint8_t scheme_id,
+ uint8_t hwport_id,
+ uint32_t counter);
+int fman_kg_get_scheme_counter(struct fman_kg_regs *regs,
+ uint8_t scheme_id,
+ uint8_t hwport_id,
+ uint32_t *counter);
+int fman_kg_delete_scheme(struct fman_kg_regs *regs,
+ uint8_t scheme_id,
+ uint8_t hwport_id);
+int fman_kg_write_scheme(struct fman_kg_regs *regs,
+ uint8_t scheme_id,
+ uint8_t hwport_id,
+ struct fman_kg_scheme_regs *scheme_regs,
+ bool update_counter);
+int fman_kg_build_scheme(struct fman_kg_scheme_params *params,
+ struct fman_kg_scheme_regs *scheme_regs);
+void fman_kg_get_capture(struct fman_kg_regs *regs,
+ struct fman_kg_ex_ecc_attr *ecc_attr,
+ bool clear);
+void fman_kg_get_exception(struct fman_kg_regs *regs,
+ uint32_t *events,
+ uint32_t *scheme_ids,
+ bool clear);
+void fman_kg_set_exception(struct fman_kg_regs *regs,
+ uint32_t exception,
+ bool enable);
+void fman_kg_set_dflt_val(struct fman_kg_regs *regs,
+ uint8_t def_id,
+ uint32_t val);
+void fman_kg_set_data_after_prs(struct fman_kg_regs *regs, uint8_t offset);
+
+
+
+/**************************************************************************//**
+ @Description NIA Description
+*//***************************************************************************/
+#define KG_NIA_ORDER_RESTOR 0x00800000
+#define KG_NIA_ENG_FM_CTL 0x00000000
+#define KG_NIA_ENG_PRS 0x00440000
+#define KG_NIA_ENG_KG 0x00480000
+#define KG_NIA_ENG_PLCR 0x004C0000
+#define KG_NIA_ENG_BMI 0x00500000
+#define KG_NIA_ENG_QMI_ENQ 0x00540000
+#define KG_NIA_ENG_QMI_DEQ 0x00580000
+#define KG_NIA_ENG_MASK 0x007C0000
+
+#define KG_NIA_AC_MASK 0x0003FFFF
+
+#define KG_NIA_INVALID 0xFFFFFFFF
+
+static __inline__ uint32_t fm_kg_build_nia(enum fman_pcd_engine next_engine,
+ uint32_t next_engine_action)
+{
+ uint32_t nia;
+
+ if (next_engine_action & ~KG_NIA_AC_MASK)
+ return KG_NIA_INVALID;
+
+ switch (next_engine) {
+ case E_FMAN_PCD_DONE:
+ nia = KG_NIA_ENG_BMI | next_engine_action;
+ break;
+
+ case E_FMAN_PCD_KG:
+ nia = KG_NIA_ENG_KG | next_engine_action;
+ break;
+
+ case E_FMAN_PCD_CC:
+ nia = KG_NIA_ENG_FM_CTL | next_engine_action;
+ break;
+
+ case E_FMAN_PCD_PLCR:
+ nia = KG_NIA_ENG_PLCR | next_engine_action;
+ break;
+
+ default:
+ nia = KG_NIA_INVALID;
+ }
+
+ return nia;
+}
+
+#endif /* __FSL_FMAN_KG_H */
diff --git a/sys/contrib/ncsw/inc/flib/fsl_fman_memac.h b/sys/contrib/ncsw/inc/flib/fsl_fman_memac.h
new file mode 100644
index 000000000000..0dd8286bda93
--- /dev/null
+++ b/sys/contrib/ncsw/inc/flib/fsl_fman_memac.h
@@ -0,0 +1,427 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef __FSL_FMAN_MEMAC_H
+#define __FSL_FMAN_MEMAC_H
+
+#include "common/general.h"
+#include "fsl_enet.h"
+
+
+#define MEMAC_NUM_OF_PADDRS 7 /* Num of additional exact match MAC adr regs */
+
+/* Control and Configuration Register (COMMAND_CONFIG) */
+#define CMD_CFG_MG 0x80000000 /* 00 Magic Packet detection */
+#define CMD_CFG_REG_LOWP_RXETY 0x01000000 /* 07 Rx low power indication */
+#define CMD_CFG_TX_LOWP_ENA 0x00800000 /* 08 Tx Low Power Idle Enable */
+#define CMD_CFG_SFD_ANY 0x00200000 /* 10 Disable SFD check */
+#define CMD_CFG_PFC_MODE 0x00080000 /* 12 Enable PFC */
+#define CMD_CFG_NO_LEN_CHK 0x00020000 /* 14 Payload length check disable */
+#define CMD_CFG_SEND_IDLE 0x00010000 /* 15 Force idle generation */
+#define CMD_CFG_CNT_FRM_EN 0x00002000 /* 18 Control frame rx enable */
+#define CMD_CFG_SW_RESET 0x00001000 /* 19 S/W Reset, self clearing bit */
+#define CMD_CFG_TX_PAD_EN 0x00000800 /* 20 Enable Tx padding of frames */
+#define CMD_CFG_LOOPBACK_EN 0x00000400 /* 21 XGMII/GMII loopback enable */
+#define CMD_CFG_TX_ADDR_INS 0x00000200 /* 22 Tx source MAC addr insertion */
+#define CMD_CFG_PAUSE_IGNORE 0x00000100 /* 23 Ignore Pause frame quanta */
+#define CMD_CFG_PAUSE_FWD 0x00000080 /* 24 Terminate/frwd Pause frames */
+#define CMD_CFG_CRC_FWD 0x00000040 /* 25 Terminate/frwd CRC of frames */
+#define CMD_CFG_PAD_EN 0x00000020 /* 26 Frame padding removal */
+#define CMD_CFG_PROMIS_EN 0x00000010 /* 27 Promiscuous operation enable */
+#define CMD_CFG_WAN_MODE 0x00000008 /* 28 WAN mode enable */
+#define CMD_CFG_RX_EN 0x00000002 /* 30 MAC receive path enable */
+#define CMD_CFG_TX_EN 0x00000001 /* 31 MAC transmit path enable */
+
+/* Transmit FIFO Sections Register (TX_FIFO_SECTIONS) */
+#define TX_FIFO_SECTIONS_TX_EMPTY_MASK 0xFFFF0000
+#define TX_FIFO_SECTIONS_TX_AVAIL_MASK 0x0000FFFF
+#define TX_FIFO_SECTIONS_TX_EMPTY_DEFAULT_10G 0x00400000
+#define TX_FIFO_SECTIONS_TX_EMPTY_DEFAULT_1G 0x00100000
+#define TX_FIFO_SECTIONS_TX_EMPTY_PFC_10G 0x00360000
+#define TX_FIFO_SECTIONS_TX_EMPTY_PFC_1G 0x00040000
+#define TX_FIFO_SECTIONS_TX_AVAIL_10G 0x00000019
+#define TX_FIFO_SECTIONS_TX_AVAIL_1G 0x00000020
+#define TX_FIFO_SECTIONS_TX_AVAIL_SLOW_10G 0x00000060
+
+#define GET_TX_EMPTY_DEFAULT_VALUE(_val) \
+_val &= ~TX_FIFO_SECTIONS_TX_EMPTY_MASK; \
+((_val == TX_FIFO_SECTIONS_TX_AVAIL_10G) ? \
+ (_val |= TX_FIFO_SECTIONS_TX_EMPTY_DEFAULT_10G) : \
+ (_val |= TX_FIFO_SECTIONS_TX_EMPTY_DEFAULT_1G));
+
+#define GET_TX_EMPTY_PFC_VALUE(_val) \
+_val &= ~TX_FIFO_SECTIONS_TX_EMPTY_MASK; \
+((_val == TX_FIFO_SECTIONS_TX_AVAIL_10G) ? \
+ (_val |= TX_FIFO_SECTIONS_TX_EMPTY_PFC_10G) : \
+ (_val |= TX_FIFO_SECTIONS_TX_EMPTY_PFC_1G));
+
+/* Interface Mode Register (IF_MODE) */
+#define IF_MODE_MASK 0x00000003 /* 30-31 Mask on i/f mode bits */
+#define IF_MODE_XGMII 0x00000000 /* 30-31 XGMII (10G) interface */
+#define IF_MODE_GMII 0x00000002 /* 30-31 GMII (1G) interface */
+#define IF_MODE_RGMII 0x00000004
+#define IF_MODE_RGMII_AUTO 0x00008000
+#define IF_MODE_RGMII_1000 0x00004000 /* 10 - 1000Mbps RGMII */
+#define IF_MODE_RGMII_100 0x00000000 /* 00 - 100Mbps RGMII */
+#define IF_MODE_RGMII_10 0x00002000 /* 01 - 10Mbps RGMII */
+#define IF_MODE_RGMII_SP_MASK 0x00006000 /* Setsp mask bits */
+#define IF_MODE_RGMII_FD 0x00001000 /* Full duplex RGMII */
+#define IF_MODE_HD 0x00000040 /* Half duplex operation */
+
+/* Hash table Control Register (HASHTABLE_CTRL) */
+#define HASH_CTRL_MCAST_SHIFT 26
+#define HASH_CTRL_MCAST_EN 0x00000100 /* 23 Mcast frame rx for hash */
+#define HASH_CTRL_ADDR_MASK 0x0000003F /* 26-31 Hash table address code */
+
+#define GROUP_ADDRESS 0x0000010000000000LL /* MAC mcast indication */
+#define HASH_TABLE_SIZE 64 /* Hash tbl size */
+
+/* Transmit Inter-Packet Gap Length Register (TX_IPG_LENGTH) */
+#define MEMAC_TX_IPG_LENGTH_MASK 0x0000003F
+
+/* Statistics Configuration Register (STATN_CONFIG) */
+#define STATS_CFG_CLR 0x00000004 /* 29 Reset all counters */
+#define STATS_CFG_CLR_ON_RD 0x00000002 /* 30 Clear on read */
+#define STATS_CFG_SATURATE 0x00000001 /* 31 Saturate at the maximum val */
+
+/* Interrupt Mask Register (IMASK) */
+#define MEMAC_IMASK_MGI 0x40000000 /* 1 Magic pkt detect indication */
+#define MEMAC_IMASK_TSECC_ER 0x20000000 /* 2 Timestamp FIFO ECC error evnt */
+#define MEMAC_IMASK_TECC_ER 0x02000000 /* 6 Transmit frame ECC error evnt */
+#define MEMAC_IMASK_RECC_ER 0x01000000 /* 7 Receive frame ECC error evnt */
+
+#define MEMAC_ALL_ERRS_IMASK \
+ ((uint32_t)(MEMAC_IMASK_TSECC_ER | \
+ MEMAC_IMASK_TECC_ER | \
+ MEMAC_IMASK_RECC_ER | \
+ MEMAC_IMASK_MGI))
+
+#define MEMAC_IEVNT_PCS 0x80000000 /* PCS (XG). Link sync (G) */
+#define MEMAC_IEVNT_AN 0x40000000 /* Auto-negotiation */
+#define MEMAC_IEVNT_LT 0x20000000 /* Link Training/New page */
+#define MEMAC_IEVNT_MGI 0x00004000 /* Magic pkt detection */
+#define MEMAC_IEVNT_TS_ECC_ER 0x00002000 /* Timestamp FIFO ECC error */
+#define MEMAC_IEVNT_RX_FIFO_OVFL 0x00001000 /* Rx FIFO overflow */
+#define MEMAC_IEVNT_TX_FIFO_UNFL 0x00000800 /* Tx FIFO underflow */
+#define MEMAC_IEVNT_TX_FIFO_OVFL 0x00000400 /* Tx FIFO overflow */
+#define MEMAC_IEVNT_TX_ECC_ER 0x00000200 /* Tx frame ECC error */
+#define MEMAC_IEVNT_RX_ECC_ER 0x00000100 /* Rx frame ECC error */
+#define MEMAC_IEVNT_LI_FAULT 0x00000080 /* Link Interruption flt */
+#define MEMAC_IEVNT_RX_EMPTY 0x00000040 /* Rx FIFO empty */
+#define MEMAC_IEVNT_TX_EMPTY 0x00000020 /* Tx FIFO empty */
+#define MEMAC_IEVNT_RX_LOWP 0x00000010 /* Low Power Idle */
+#define MEMAC_IEVNT_PHY_LOS 0x00000004 /* Phy loss of signal */
+#define MEMAC_IEVNT_REM_FAULT 0x00000002 /* Remote fault (XGMII) */
+#define MEMAC_IEVNT_LOC_FAULT 0x00000001 /* Local fault (XGMII) */
+
+enum memac_counters {
+ E_MEMAC_COUNTER_R64,
+ E_MEMAC_COUNTER_R127,
+ E_MEMAC_COUNTER_R255,
+ E_MEMAC_COUNTER_R511,
+ E_MEMAC_COUNTER_R1023,
+ E_MEMAC_COUNTER_R1518,
+ E_MEMAC_COUNTER_R1519X,
+ E_MEMAC_COUNTER_RFRG,
+ E_MEMAC_COUNTER_RJBR,
+ E_MEMAC_COUNTER_RDRP,
+ E_MEMAC_COUNTER_RALN,
+ E_MEMAC_COUNTER_TUND,
+ E_MEMAC_COUNTER_ROVR,
+ E_MEMAC_COUNTER_RXPF,
+ E_MEMAC_COUNTER_TXPF,
+ E_MEMAC_COUNTER_ROCT,
+ E_MEMAC_COUNTER_RMCA,
+ E_MEMAC_COUNTER_RBCA,
+ E_MEMAC_COUNTER_RPKT,
+ E_MEMAC_COUNTER_RUCA,
+ E_MEMAC_COUNTER_RERR,
+ E_MEMAC_COUNTER_TOCT,
+ E_MEMAC_COUNTER_TMCA,
+ E_MEMAC_COUNTER_TBCA,
+ E_MEMAC_COUNTER_TUCA,
+ E_MEMAC_COUNTER_TERR
+};
+
+#define DEFAULT_PAUSE_QUANTA 0xf000
+#define DEFAULT_FRAME_LENGTH 0x600
+#define DEFAULT_TX_IPG_LENGTH 12
+
+/*
+ * memory map
+ */
+
+struct mac_addr {
+ uint32_t mac_addr_l; /* Lower 32 bits of 48-bit MAC address */
+ uint32_t mac_addr_u; /* Upper 16 bits of 48-bit MAC address */
+};
+
+struct memac_regs {
+ /* General Control and Status */
+ uint32_t res0000[2];
+ uint32_t command_config; /* 0x008 Ctrl and cfg */
+ struct mac_addr mac_addr0; /* 0x00C-0x010 MAC_ADDR_0...1 */
+ uint32_t maxfrm; /* 0x014 Max frame length */
+ uint32_t res0018[1];
+ uint32_t rx_fifo_sections; /* Receive FIFO configuration reg */
+ uint32_t tx_fifo_sections; /* Transmit FIFO configuration reg */
+ uint32_t res0024[2];
+ uint32_t hashtable_ctrl; /* 0x02C Hash table control */
+ uint32_t res0030[4];
+ uint32_t ievent; /* 0x040 Interrupt event */
+ uint32_t tx_ipg_length; /* 0x044 Transmitter inter-packet-gap */
+ uint32_t res0048;
+ uint32_t imask; /* 0x04C Interrupt mask */
+ uint32_t res0050;
+ uint32_t pause_quanta[4]; /* 0x054 Pause quanta */
+ uint32_t pause_thresh[4]; /* 0x064 Pause quanta threshold */
+ uint32_t rx_pause_status; /* 0x074 Receive pause status */
+ uint32_t res0078[2];
+ struct mac_addr mac_addr[MEMAC_NUM_OF_PADDRS]; /* 0x80-0x0B4 mac padr */
+ uint32_t lpwake_timer; /* 0x0B8 Low Power Wakeup Timer */
+ uint32_t sleep_timer; /* 0x0BC Transmit EEE Low Power Timer */
+ uint32_t res00c0[8];
+ uint32_t statn_config; /* 0x0E0 Statistics configuration */
+ uint32_t res00e4[7];
+ /* Rx Statistics Counter */
+ uint32_t reoct_l;
+ uint32_t reoct_u;
+ uint32_t roct_l;
+ uint32_t roct_u;
+ uint32_t raln_l;
+ uint32_t raln_u;
+ uint32_t rxpf_l;
+ uint32_t rxpf_u;
+ uint32_t rfrm_l;
+ uint32_t rfrm_u;
+ uint32_t rfcs_l;
+ uint32_t rfcs_u;
+ uint32_t rvlan_l;
+ uint32_t rvlan_u;
+ uint32_t rerr_l;
+ uint32_t rerr_u;
+ uint32_t ruca_l;
+ uint32_t ruca_u;
+ uint32_t rmca_l;
+ uint32_t rmca_u;
+ uint32_t rbca_l;
+ uint32_t rbca_u;
+ uint32_t rdrp_l;
+ uint32_t rdrp_u;
+ uint32_t rpkt_l;
+ uint32_t rpkt_u;
+ uint32_t rund_l;
+ uint32_t rund_u;
+ uint32_t r64_l;
+ uint32_t r64_u;
+ uint32_t r127_l;
+ uint32_t r127_u;
+ uint32_t r255_l;
+ uint32_t r255_u;
+ uint32_t r511_l;
+ uint32_t r511_u;
+ uint32_t r1023_l;
+ uint32_t r1023_u;
+ uint32_t r1518_l;
+ uint32_t r1518_u;
+ uint32_t r1519x_l;
+ uint32_t r1519x_u;
+ uint32_t rovr_l;
+ uint32_t rovr_u;
+ uint32_t rjbr_l;
+ uint32_t rjbr_u;
+ uint32_t rfrg_l;
+ uint32_t rfrg_u;
+ uint32_t rcnp_l;
+ uint32_t rcnp_u;
+ uint32_t rdrntp_l;
+ uint32_t rdrntp_u;
+ uint32_t res01d0[12];
+ /* Tx Statistics Counter */
+ uint32_t teoct_l;
+ uint32_t teoct_u;
+ uint32_t toct_l;
+ uint32_t toct_u;
+ uint32_t res0210[2];
+ uint32_t txpf_l;
+ uint32_t txpf_u;
+ uint32_t tfrm_l;
+ uint32_t tfrm_u;
+ uint32_t tfcs_l;
+ uint32_t tfcs_u;
+ uint32_t tvlan_l;
+ uint32_t tvlan_u;
+ uint32_t terr_l;
+ uint32_t terr_u;
+ uint32_t tuca_l;
+ uint32_t tuca_u;
+ uint32_t tmca_l;
+ uint32_t tmca_u;
+ uint32_t tbca_l;
+ uint32_t tbca_u;
+ uint32_t res0258[2];
+ uint32_t tpkt_l;
+ uint32_t tpkt_u;
+ uint32_t tund_l;
+ uint32_t tund_u;
+ uint32_t t64_l;
+ uint32_t t64_u;
+ uint32_t t127_l;
+ uint32_t t127_u;
+ uint32_t t255_l;
+ uint32_t t255_u;
+ uint32_t t511_l;
+ uint32_t t511_u;
+ uint32_t t1023_l;
+ uint32_t t1023_u;
+ uint32_t t1518_l;
+ uint32_t t1518_u;
+ uint32_t t1519x_l;
+ uint32_t t1519x_u;
+ uint32_t res02a8[6];
+ uint32_t tcnp_l;
+ uint32_t tcnp_u;
+ uint32_t res02c8[14];
+ /* Line Interface Control */
+ uint32_t if_mode; /* 0x300 Interface Mode Control */
+ uint32_t if_status; /* 0x304 Interface Status */
+ uint32_t res0308[14];
+ /* HiGig/2 */
+ uint32_t hg_config; /* 0x340 Control and cfg */
+ uint32_t res0344[3];
+ uint32_t hg_pause_quanta; /* 0x350 Pause quanta */
+ uint32_t res0354[3];
+ uint32_t hg_pause_thresh; /* 0x360 Pause quanta threshold */
+ uint32_t res0364[3];
+ uint32_t hgrx_pause_status; /* 0x370 Receive pause status */
+ uint32_t hg_fifos_status; /* 0x374 fifos status */
+ uint32_t rhm; /* 0x378 rx messages counter */
+ uint32_t thm; /* 0x37C tx messages counter */
+};
+
+struct memac_cfg {
+ bool reset_on_init;
+ bool rx_error_discard;
+ bool pause_ignore;
+ bool pause_forward_enable;
+ bool no_length_check_enable;
+ bool cmd_frame_enable;
+ bool send_idle_enable;
+ bool wan_mode_enable;
+ bool promiscuous_mode_enable;
+ bool tx_addr_ins_enable;
+ bool loopback_enable;
+ bool lgth_check_nostdr;
+ bool time_stamp_enable;
+ bool pad_enable;
+ bool phy_tx_ena_on;
+ bool rx_sfd_any;
+ bool rx_pbl_fwd;
+ bool tx_pbl_fwd;
+ bool debug_mode;
+ bool wake_on_lan;
+ uint16_t max_frame_length;
+ uint16_t pause_quanta;
+ uint32_t tx_ipg_length;
+};
+
+
+/**
+ * fman_memac_defconfig() - Get default MEMAC configuration
+ * @cfg: pointer to configuration structure.
+ *
+ * Call this function to obtain a default set of configuration values for
+ * initializing MEMAC. The user can overwrite any of the values before calling
+ * fman_memac_init(), if specific configuration needs to be applied.
+ */
+void fman_memac_defconfig(struct memac_cfg *cfg);
+
+int fman_memac_init(struct memac_regs *regs,
+ struct memac_cfg *cfg,
+ enum enet_interface enet_interface,
+ enum enet_speed enet_speed,
+ bool slow_10g_if,
+ uint32_t exceptions);
+
+void fman_memac_enable(struct memac_regs *regs, bool apply_rx, bool apply_tx);
+
+void fman_memac_disable(struct memac_regs *regs, bool apply_rx, bool apply_tx);
+
+void fman_memac_set_promiscuous(struct memac_regs *regs, bool val);
+
+void fman_memac_add_addr_in_paddr(struct memac_regs *regs,
+ uint8_t *adr,
+ uint8_t paddr_num);
+
+void fman_memac_clear_addr_in_paddr(struct memac_regs *regs,
+ uint8_t paddr_num);
+
+uint64_t fman_memac_get_counter(struct memac_regs *regs,
+ enum memac_counters reg_name);
+
+void fman_memac_set_tx_pause_frames(struct memac_regs *regs,
+ uint8_t priority, uint16_t pauseTime, uint16_t threshTime);
+
+uint16_t fman_memac_get_max_frame_len(struct memac_regs *regs);
+
+void fman_memac_set_exception(struct memac_regs *regs, uint32_t val,
+ bool enable);
+
+void fman_memac_reset_stat(struct memac_regs *regs);
+
+void fman_memac_reset(struct memac_regs *regs);
+
+void fman_memac_reset_filter_table(struct memac_regs *regs);
+
+void fman_memac_set_hash_table_entry(struct memac_regs *regs, uint32_t crc);
+
+void fman_memac_set_hash_table(struct memac_regs *regs, uint32_t val);
+
+void fman_memac_set_rx_ignore_pause_frames(struct memac_regs *regs,
+ bool enable);
+
+void fman_memac_set_wol(struct memac_regs *regs, bool enable);
+
+uint32_t fman_memac_get_event(struct memac_regs *regs, uint32_t ev_mask);
+
+void fman_memac_ack_event(struct memac_regs *regs, uint32_t ev_mask);
+
+uint32_t fman_memac_get_interrupt_mask(struct memac_regs *regs);
+
+void fman_memac_adjust_link(struct memac_regs *regs,
+ enum enet_interface iface_mode,
+ enum enet_speed speed, bool full_dx);
+
+
+
+#endif /*__FSL_FMAN_MEMAC_H*/
diff --git a/sys/contrib/ncsw/inc/flib/fsl_fman_memac_mii_acc.h b/sys/contrib/ncsw/inc/flib/fsl_fman_memac_mii_acc.h
new file mode 100755
index 000000000000..b43044501b80
--- /dev/null
+++ b/sys/contrib/ncsw/inc/flib/fsl_fman_memac_mii_acc.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2008-2013 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __FSL_FMAN_MEMAC_MII_ACC_H
+#define __FSL_FMAN_MEMAC_MII_ACC_H
+
+#include "common/general.h"
+#include "fsl_enet.h"
+/* MII Management Registers */
+#define MDIO_CFG_CLK_DIV_MASK 0x0080ff80
+#define MDIO_CFG_CLK_DIV_SHIFT 7
+#define MDIO_CFG_HOLD_MASK 0x0000001c
+#define MDIO_CFG_ENC45 0x00000040
+#define MDIO_CFG_READ_ERR 0x00000002
+#define MDIO_CFG_BSY 0x00000001
+
+#define MDIO_CTL_PHY_ADDR_SHIFT 5
+#define MDIO_CTL_READ 0x00008000
+
+#define MDIO_DATA_BSY 0x80000000
+
+/*MEMAC Internal PHY Registers - SGMII */
+#define PHY_SGMII_CR_PHY_RESET 0x8000
+#define PHY_SGMII_CR_RESET_AN 0x0200
+#define PHY_SGMII_CR_DEF_VAL 0x1140
+#define PHY_SGMII_DEV_ABILITY_SGMII 0x4001
+#define PHY_SGMII_DEV_ABILITY_1000X 0x01A0
+#define PHY_SGMII_IF_MODE_AN 0x0002
+#define PHY_SGMII_IF_MODE_SGMII 0x0001
+#define PHY_SGMII_IF_MODE_1000X 0x0000
+
+/*----------------------------------------------------*/
+/* MII Configuration Control Memory Map Registers */
+/*----------------------------------------------------*/
+struct memac_mii_access_mem_map {
+ uint32_t mdio_cfg; /* 0x030 */
+ uint32_t mdio_ctrl; /* 0x034 */
+ uint32_t mdio_data; /* 0x038 */
+ uint32_t mdio_addr; /* 0x03c */
+};
+
+int fman_memac_mii_read_phy_reg(struct memac_mii_access_mem_map *mii_regs,
+ uint8_t phy_addr, uint8_t reg, uint16_t *data,
+ enum enet_speed enet_speed);
+int fman_memac_mii_write_phy_reg(struct memac_mii_access_mem_map *mii_regs,
+ uint8_t phy_addr, uint8_t reg, uint16_t data,
+ enum enet_speed enet_speed);
+
+#endif /* __MAC_API_MEMAC_MII_ACC_H */
diff --git a/sys/contrib/ncsw/inc/flib/fsl_fman_port.h b/sys/contrib/ncsw/inc/flib/fsl_fman_port.h
new file mode 100755
index 000000000000..080a23e963b9
--- /dev/null
+++ b/sys/contrib/ncsw/inc/flib/fsl_fman_port.h
@@ -0,0 +1,593 @@
+/*
+ * Copyright 2008-2013 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __FSL_FMAN_PORT_H
+#define __FSL_FMAN_PORT_H
+
+#include "fsl_fman_sp.h"
+
+/** @Collection Registers bit fields */
+
+/** @Description BMI defines */
+#define BMI_EBD_EN 0x80000000
+
+#define BMI_PORT_CFG_EN 0x80000000
+#define BMI_PORT_CFG_FDOVR 0x02000000
+#define BMI_PORT_CFG_IM 0x01000000
+
+#define BMI_PORT_STATUS_BSY 0x80000000
+
+#define BMI_DMA_ATTR_SWP_SHIFT FMAN_SP_DMA_ATTR_SWP_SHIFT
+#define BMI_DMA_ATTR_IC_STASH_ON 0x10000000
+#define BMI_DMA_ATTR_HDR_STASH_ON 0x04000000
+#define BMI_DMA_ATTR_SG_STASH_ON 0x01000000
+#define BMI_DMA_ATTR_WRITE_OPTIMIZE FMAN_SP_DMA_ATTR_WRITE_OPTIMIZE
+
+#define BMI_RX_FIFO_PRI_ELEVATION_SHIFT 16
+#define BMI_RX_FIFO_THRESHOLD_ETHE 0x80000000
+
+#define BMI_TX_FRAME_END_CS_IGNORE_SHIFT 24
+#define BMI_RX_FRAME_END_CS_IGNORE_SHIFT 24
+#define BMI_RX_FRAME_END_CUT_SHIFT 16
+
+#define BMI_IC_TO_EXT_SHIFT FMAN_SP_IC_TO_EXT_SHIFT
+#define BMI_IC_FROM_INT_SHIFT FMAN_SP_IC_FROM_INT_SHIFT
+
+#define BMI_INT_BUF_MARG_SHIFT 28
+#define BMI_EXT_BUF_MARG_START_SHIFT FMAN_SP_EXT_BUF_MARG_START_SHIFT
+
+#define BMI_CMD_MR_LEAC 0x00200000
+#define BMI_CMD_MR_SLEAC 0x00100000
+#define BMI_CMD_MR_MA 0x00080000
+#define BMI_CMD_MR_DEAS 0x00040000
+#define BMI_CMD_RX_MR_DEF (BMI_CMD_MR_LEAC | \
+ BMI_CMD_MR_SLEAC | \
+ BMI_CMD_MR_MA | \
+ BMI_CMD_MR_DEAS)
+#define BMI_CMD_TX_MR_DEF 0
+#define BMI_CMD_OP_MR_DEF (BMI_CMD_MR_DEAS | \
+ BMI_CMD_MR_MA)
+
+#define BMI_CMD_ATTR_ORDER 0x80000000
+#define BMI_CMD_ATTR_SYNC 0x02000000
+#define BMI_CMD_ATTR_COLOR_SHIFT 26
+
+#define BMI_FIFO_PIPELINE_DEPTH_SHIFT 12
+#define BMI_NEXT_ENG_FD_BITS_SHIFT 24
+#define BMI_FRAME_END_CS_IGNORE_SHIFT 24
+
+#define BMI_COUNTERS_EN 0x80000000
+
+#define BMI_EXT_BUF_POOL_VALID FMAN_SP_EXT_BUF_POOL_VALID
+#define BMI_EXT_BUF_POOL_EN_COUNTER FMAN_SP_EXT_BUF_POOL_EN_COUNTER
+#define BMI_EXT_BUF_POOL_BACKUP FMAN_SP_EXT_BUF_POOL_BACKUP
+#define BMI_EXT_BUF_POOL_ID_SHIFT 16
+#define BMI_EXT_BUF_POOL_ID_MASK 0x003F0000
+#define BMI_POOL_DEP_NUM_OF_POOLS_SHIFT 16
+
+#define BMI_TX_FIFO_MIN_FILL_SHIFT 16
+#define BMI_TX_FIFO_PIPELINE_DEPTH_SHIFT 12
+
+#define MAX_PERFORMANCE_TASK_COMP 64
+#define MAX_PERFORMANCE_RX_QUEUE_COMP 64
+#define MAX_PERFORMANCE_TX_QUEUE_COMP 8
+#define MAX_PERFORMANCE_DMA_COMP 16
+#define MAX_PERFORMANCE_FIFO_COMP 1024
+
+#define BMI_PERFORMANCE_TASK_COMP_SHIFT 24
+#define BMI_PERFORMANCE_QUEUE_COMP_SHIFT 16
+#define BMI_PERFORMANCE_DMA_COMP_SHIFT 12
+
+#define BMI_RATE_LIMIT_GRAN_TX 16000 /* In Kbps */
+#define BMI_RATE_LIMIT_GRAN_OP 10000 /* In frames */
+#define BMI_RATE_LIMIT_MAX_RATE_IN_GRAN_UNITS 1024
+#define BMI_RATE_LIMIT_MAX_BURST_SIZE 1024 /* In KBytes */
+#define BMI_RATE_LIMIT_MAX_BURST_SHIFT 16
+#define BMI_RATE_LIMIT_HIGH_BURST_SIZE_GRAN 0x80000000
+#define BMI_RATE_LIMIT_SCALE_TSBS_SHIFT 16
+#define BMI_RATE_LIMIT_SCALE_EN 0x80000000
+#define BMI_SG_DISABLE FMAN_SP_SG_DISABLE
+
+/** @Description QMI defines */
+#define QMI_PORT_CFG_EN 0x80000000
+#define QMI_PORT_CFG_EN_COUNTERS 0x10000000
+
+#define QMI_PORT_STATUS_DEQ_TNUM_BSY 0x80000000
+#define QMI_PORT_STATUS_DEQ_FD_BSY 0x20000000
+
+#define QMI_DEQ_CFG_PRI 0x80000000
+#define QMI_DEQ_CFG_TYPE1 0x10000000
+#define QMI_DEQ_CFG_TYPE2 0x20000000
+#define QMI_DEQ_CFG_TYPE3 0x30000000
+#define QMI_DEQ_CFG_PREFETCH_PARTIAL 0x01000000
+#define QMI_DEQ_CFG_PREFETCH_FULL 0x03000000
+#define QMI_DEQ_CFG_SP_MASK 0xf
+#define QMI_DEQ_CFG_SP_SHIFT 20
+
+
+/** @Description General port defines */
+#define FMAN_PORT_EXT_POOLS_NUM(fm_rev_maj) \
+ (((fm_rev_maj) == 4) ? 4 : 8)
+#define FMAN_PORT_MAX_EXT_POOLS_NUM 8
+#define FMAN_PORT_OBS_EXT_POOLS_NUM 2
+#define FMAN_PORT_CG_MAP_NUM 8
+#define FMAN_PORT_PRS_RESULT_WORDS_NUM 8
+#define FMAN_PORT_BMI_FIFO_UNITS 0x100
+#define FMAN_PORT_IC_OFFSET_UNITS 0x10
+
+
+/** @Collection FM Port Register Map */
+
+/** @Description BMI Rx port register map */
+struct fman_port_rx_bmi_regs {
+ uint32_t fmbm_rcfg; /**< Rx Configuration */
+ uint32_t fmbm_rst; /**< Rx Status */
+ uint32_t fmbm_rda; /**< Rx DMA attributes*/
+ uint32_t fmbm_rfp; /**< Rx FIFO Parameters*/
+ uint32_t fmbm_rfed; /**< Rx Frame End Data*/
+ uint32_t fmbm_ricp; /**< Rx Internal Context Parameters*/
+ uint32_t fmbm_rim; /**< Rx Internal Buffer Margins*/
+ uint32_t fmbm_rebm; /**< Rx External Buffer Margins*/
+ uint32_t fmbm_rfne; /**< Rx Frame Next Engine*/
+ uint32_t fmbm_rfca; /**< Rx Frame Command Attributes.*/
+ uint32_t fmbm_rfpne; /**< Rx Frame Parser Next Engine*/
+ uint32_t fmbm_rpso; /**< Rx Parse Start Offset*/
+ uint32_t fmbm_rpp; /**< Rx Policer Profile */
+ uint32_t fmbm_rccb; /**< Rx Coarse Classification Base */
+ uint32_t fmbm_reth; /**< Rx Excessive Threshold */
+ uint32_t reserved003c[1]; /**< (0x03C 0x03F) */
+ uint32_t fmbm_rprai[FMAN_PORT_PRS_RESULT_WORDS_NUM];
+ /**< Rx Parse Results Array Init*/
+ uint32_t fmbm_rfqid; /**< Rx Frame Queue ID*/
+ uint32_t fmbm_refqid; /**< Rx Error Frame Queue ID*/
+ uint32_t fmbm_rfsdm; /**< Rx Frame Status Discard Mask*/
+ uint32_t fmbm_rfsem; /**< Rx Frame Status Error Mask*/
+ uint32_t fmbm_rfene; /**< Rx Frame Enqueue Next Engine */
+ uint32_t reserved0074[0x2]; /**< (0x074-0x07C) */
+ uint32_t fmbm_rcmne; /**< Rx Frame Continuous Mode Next Engine */
+ uint32_t reserved0080[0x20];/**< (0x080 0x0FF) */
+ uint32_t fmbm_ebmpi[FMAN_PORT_MAX_EXT_POOLS_NUM];
+ /**< Buffer Manager pool Information-*/
+ uint32_t fmbm_acnt[FMAN_PORT_MAX_EXT_POOLS_NUM];
+ /**< Allocate Counter-*/
+ uint32_t reserved0130[8];
+ /**< 0x130/0x140 - 0x15F reserved -*/
+ uint32_t fmbm_rcgm[FMAN_PORT_CG_MAP_NUM];
+ /**< Congestion Group Map*/
+ uint32_t fmbm_mpd; /**< BM Pool Depletion */
+ uint32_t reserved0184[0x1F]; /**< (0x184 0x1FF) */
+ uint32_t fmbm_rstc; /**< Rx Statistics Counters*/
+ uint32_t fmbm_rfrc; /**< Rx Frame Counter*/
+ uint32_t fmbm_rfbc; /**< Rx Bad Frames Counter*/
+ uint32_t fmbm_rlfc; /**< Rx Large Frames Counter*/
+ uint32_t fmbm_rffc; /**< Rx Filter Frames Counter*/
+ uint32_t fmbm_rfdc; /**< Rx Frame Discard Counter*/
+ uint32_t fmbm_rfldec; /**< Rx Frames List DMA Error Counter*/
+ uint32_t fmbm_rodc; /**< Rx Out of Buffers Discard nntr*/
+ uint32_t fmbm_rbdc; /**< Rx Buffers Deallocate Counter*/
+ uint32_t reserved0224[0x17]; /**< (0x224 0x27F) */
+ uint32_t fmbm_rpc; /**< Rx Performance Counters*/
+ uint32_t fmbm_rpcp; /**< Rx Performance Count Parameters*/
+ uint32_t fmbm_rccn; /**< Rx Cycle Counter*/
+ uint32_t fmbm_rtuc; /**< Rx Tasks Utilization Counter*/
+ uint32_t fmbm_rrquc; /**< Rx Receive Queue Utilization cntr*/
+ uint32_t fmbm_rduc; /**< Rx DMA Utilization Counter*/
+ uint32_t fmbm_rfuc; /**< Rx FIFO Utilization Counter*/
+ uint32_t fmbm_rpac; /**< Rx Pause Activation Counter*/
+ uint32_t reserved02a0[0x18]; /**< (0x2A0 0x2FF) */
+ uint32_t fmbm_rdbg; /**< Rx Debug-*/
+};
+
+/** @Description BMI Tx port register map */
+struct fman_port_tx_bmi_regs {
+ uint32_t fmbm_tcfg; /**< Tx Configuration */
+ uint32_t fmbm_tst; /**< Tx Status */
+ uint32_t fmbm_tda; /**< Tx DMA attributes */
+ uint32_t fmbm_tfp; /**< Tx FIFO Parameters */
+ uint32_t fmbm_tfed; /**< Tx Frame End Data */
+ uint32_t fmbm_ticp; /**< Tx Internal Context Parameters */
+ uint32_t fmbm_tfdne; /**< Tx Frame Dequeue Next Engine. */
+ uint32_t fmbm_tfca; /**< Tx Frame Command attribute. */
+ uint32_t fmbm_tcfqid; /**< Tx Confirmation Frame Queue ID. */
+ uint32_t fmbm_tefqid; /**< Tx Frame Error Queue ID */
+ uint32_t fmbm_tfene; /**< Tx Frame Enqueue Next Engine */
+ uint32_t fmbm_trlmts; /**< Tx Rate Limiter Scale */
+ uint32_t fmbm_trlmt; /**< Tx Rate Limiter */
+ uint32_t reserved0034[0x0e]; /**< (0x034-0x6c) */
+ uint32_t fmbm_tccb; /**< Tx Coarse Classification base */
+ uint32_t fmbm_tfne; /**< Tx Frame Next Engine */
+ uint32_t fmbm_tpfcm[0x02]; /**< Tx Priority based Flow Control (PFC) Mapping */
+ uint32_t fmbm_tcmne; /**< Tx Frame Continuous Mode Next Engine */
+ uint32_t reserved0080[0x60]; /**< (0x080-0x200) */
+ uint32_t fmbm_tstc; /**< Tx Statistics Counters */
+ uint32_t fmbm_tfrc; /**< Tx Frame Counter */
+ uint32_t fmbm_tfdc; /**< Tx Frames Discard Counter */
+ uint32_t fmbm_tfledc; /**< Tx Frame len error discard cntr */
+ uint32_t fmbm_tfufdc; /**< Tx Frame unsprt frmt discard cntr*/
+ uint32_t fmbm_tbdc; /**< Tx Buffers Deallocate Counter */
+ uint32_t reserved0218[0x1A]; /**< (0x218-0x280) */
+ uint32_t fmbm_tpc; /**< Tx Performance Counters*/
+ uint32_t fmbm_tpcp; /**< Tx Performance Count Parameters*/
+ uint32_t fmbm_tccn; /**< Tx Cycle Counter*/
+ uint32_t fmbm_ttuc; /**< Tx Tasks Utilization Counter*/
+ uint32_t fmbm_ttcquc; /**< Tx Transmit conf Q util Counter*/
+ uint32_t fmbm_tduc; /**< Tx DMA Utilization Counter*/
+ uint32_t fmbm_tfuc; /**< Tx FIFO Utilization Counter*/
+};
+
+/** @Description BMI O/H port register map */
+struct fman_port_oh_bmi_regs {
+ uint32_t fmbm_ocfg; /**< O/H Configuration */
+ uint32_t fmbm_ost; /**< O/H Status */
+ uint32_t fmbm_oda; /**< O/H DMA attributes */
+ uint32_t fmbm_oicp; /**< O/H Internal Context Parameters */
+ uint32_t fmbm_ofdne; /**< O/H Frame Dequeue Next Engine */
+ uint32_t fmbm_ofne; /**< O/H Frame Next Engine */
+ uint32_t fmbm_ofca; /**< O/H Frame Command Attributes. */
+ uint32_t fmbm_ofpne; /**< O/H Frame Parser Next Engine */
+ uint32_t fmbm_opso; /**< O/H Parse Start Offset */
+ uint32_t fmbm_opp; /**< O/H Policer Profile */
+ uint32_t fmbm_occb; /**< O/H Coarse Classification base */
+ uint32_t fmbm_oim; /**< O/H Internal margins*/
+ uint32_t fmbm_ofp; /**< O/H Fifo Parameters*/
+ uint32_t fmbm_ofed; /**< O/H Frame End Data*/
+ uint32_t reserved0030[2]; /**< (0x038 - 0x03F) */
+ uint32_t fmbm_oprai[FMAN_PORT_PRS_RESULT_WORDS_NUM];
+ /**< O/H Parse Results Array Initialization */
+ uint32_t fmbm_ofqid; /**< O/H Frame Queue ID */
+ uint32_t fmbm_oefqid; /**< O/H Error Frame Queue ID */
+ uint32_t fmbm_ofsdm; /**< O/H Frame Status Discard Mask */
+ uint32_t fmbm_ofsem; /**< O/H Frame Status Error Mask */
+ uint32_t fmbm_ofene; /**< O/H Frame Enqueue Next Engine */
+ uint32_t fmbm_orlmts; /**< O/H Rate Limiter Scale */
+ uint32_t fmbm_orlmt; /**< O/H Rate Limiter */
+ uint32_t fmbm_ocmne; /**< O/H Continuous Mode Next Engine */
+ uint32_t reserved0080[0x20]; /**< 0x080 - 0x0FF Reserved */
+ uint32_t fmbm_oebmpi[2]; /**< Buf Mngr Observed Pool Info */
+ uint32_t reserved0108[0x16]; /**< 0x108 - 0x15F Reserved */
+ uint32_t fmbm_ocgm[FMAN_PORT_CG_MAP_NUM]; /**< Observed Congestion Group Map */
+ uint32_t fmbm_ompd; /**< Observed BMan Pool Depletion */
+ uint32_t reserved0184[0x1F]; /**< 0x184 - 0x1FF Reserved */
+ uint32_t fmbm_ostc; /**< O/H Statistics Counters */
+ uint32_t fmbm_ofrc; /**< O/H Frame Counter */
+ uint32_t fmbm_ofdc; /**< O/H Frames Discard Counter */
+ uint32_t fmbm_ofledc; /**< O/H Frames Len Err Discard Cntr */
+ uint32_t fmbm_ofufdc; /**< O/H Frames Unsprtd Discard Cutr */
+ uint32_t fmbm_offc; /**< O/H Filter Frames Counter */
+ uint32_t fmbm_ofwdc; /**< Rx Frames WRED Discard Counter */
+ uint32_t fmbm_ofldec; /**< O/H Frames List DMA Error Cntr */
+ uint32_t fmbm_obdc; /**< O/H Buffers Deallocate Counter */
+ uint32_t reserved0218[0x17]; /**< (0x218 - 0x27F) */
+ uint32_t fmbm_opc; /**< O/H Performance Counters */
+ uint32_t fmbm_opcp; /**< O/H Performance Count Parameters */
+ uint32_t fmbm_occn; /**< O/H Cycle Counter */
+ uint32_t fmbm_otuc; /**< O/H Tasks Utilization Counter */
+ uint32_t fmbm_oduc; /**< O/H DMA Utilization Counter */
+ uint32_t fmbm_ofuc; /**< O/H FIFO Utilization Counter */
+};
+
+/** @Description BMI port register map */
+union fman_port_bmi_regs {
+ struct fman_port_rx_bmi_regs rx;
+ struct fman_port_tx_bmi_regs tx;
+ struct fman_port_oh_bmi_regs oh;
+};
+
+/** @Description QMI port register map */
+struct fman_port_qmi_regs {
+ uint32_t fmqm_pnc; /**< PortID n Configuration Register */
+ uint32_t fmqm_pns; /**< PortID n Status Register */
+ uint32_t fmqm_pnts; /**< PortID n Task Status Register */
+ uint32_t reserved00c[4]; /**< 0xn00C - 0xn01B */
+ uint32_t fmqm_pnen; /**< PortID n Enqueue NIA Register */
+ uint32_t fmqm_pnetfc; /**< PortID n Enq Total Frame Counter */
+ uint32_t reserved024[2]; /**< 0xn024 - 0x02B */
+ uint32_t fmqm_pndn; /**< PortID n Dequeue NIA Register */
+ uint32_t fmqm_pndc; /**< PortID n Dequeue Config Register */
+ uint32_t fmqm_pndtfc; /**< PortID n Dequeue tot Frame cntr */
+ uint32_t fmqm_pndfdc; /**< PortID n Dequeue FQID Dflt Cntr */
+ uint32_t fmqm_pndcc; /**< PortID n Dequeue Confirm Counter */
+};
+
+
+enum fman_port_dma_swap {
+ E_FMAN_PORT_DMA_NO_SWAP, /**< No swap, transfer data as is */
+ E_FMAN_PORT_DMA_SWAP_LE,
+ /**< The transferred data should be swapped in PPC Little Endian mode */
+ E_FMAN_PORT_DMA_SWAP_BE
+ /**< The transferred data should be swapped in Big Endian mode */
+};
+
+/* Default port color */
+enum fman_port_color {
+ E_FMAN_PORT_COLOR_GREEN, /**< Default port color is green */
+ E_FMAN_PORT_COLOR_YELLOW, /**< Default port color is yellow */
+ E_FMAN_PORT_COLOR_RED, /**< Default port color is red */
+ E_FMAN_PORT_COLOR_OVERRIDE /**< Ignore color */
+};
+
+/* QMI dequeue from the SP channel - types */
+enum fman_port_deq_type {
+ E_FMAN_PORT_DEQ_BY_PRI,
+ /**< Priority precedence and Intra-Class scheduling */
+ E_FMAN_PORT_DEQ_ACTIVE_FQ,
+ /**< Active FQ precedence and Intra-Class scheduling */
+ E_FMAN_PORT_DEQ_ACTIVE_FQ_NO_ICS
+ /**< Active FQ precedence and override Intra-Class scheduling */
+};
+
+/* QMI dequeue prefetch modes */
+enum fman_port_deq_prefetch {
+ E_FMAN_PORT_DEQ_NO_PREFETCH, /**< No prefetch mode */
+ E_FMAN_PORT_DEQ_PART_PREFETCH, /**< Partial prefetch mode */
+ E_FMAN_PORT_DEQ_FULL_PREFETCH /**< Full prefetch mode */
+};
+
+/* Parameters for defining performance counters behavior */
+struct fman_port_perf_cnt_params {
+ uint8_t task_val; /**< Task compare value */
+ uint8_t queue_val;
+ /**< Rx or Tx conf queue compare value (unused for O/H ports) */
+ uint8_t dma_val; /**< Dma compare value */
+ uint32_t fifo_val; /**< Fifo compare value (in bytes) */
+};
+
+/** @Description FM Port configuration structure, used at init */
+struct fman_port_cfg {
+ struct fman_port_perf_cnt_params perf_cnt_params;
+ /* BMI parameters */
+ enum fman_port_dma_swap dma_swap_data;
+ bool dma_ic_stash_on;
+ bool dma_header_stash_on;
+ bool dma_sg_stash_on;
+ bool dma_write_optimize;
+ uint16_t ic_ext_offset;
+ uint8_t ic_int_offset;
+ uint16_t ic_size;
+ enum fman_port_color color;
+ bool sync_req;
+ bool discard_override;
+ uint8_t checksum_bytes_ignore;
+ uint8_t rx_cut_end_bytes;
+ uint32_t rx_pri_elevation;
+ uint32_t rx_fifo_thr;
+ uint8_t rx_fd_bits;
+ uint8_t int_buf_start_margin;
+ uint16_t ext_buf_start_margin;
+ uint16_t ext_buf_end_margin;
+ uint32_t tx_fifo_min_level;
+ uint32_t tx_fifo_low_comf_level;
+ uint8_t tx_fifo_deq_pipeline_depth;
+ bool stats_counters_enable;
+ bool perf_counters_enable;
+ /* QMI parameters */
+ bool deq_high_pri;
+ enum fman_port_deq_type deq_type;
+ enum fman_port_deq_prefetch deq_prefetch_opt;
+ uint16_t deq_byte_cnt;
+ bool queue_counters_enable;
+ bool no_scatter_gather;
+ int errata_A006675;
+ int errata_A006320;
+ int excessive_threshold_register;
+ int fmbm_rebm_has_sgd;
+ int fmbm_tfne_has_features;
+ int qmi_deq_options_support;
+};
+
+enum fman_port_type {
+ E_FMAN_PORT_TYPE_OP = 0,
+ /**< Offline parsing port, shares id-s with
+ * host command, so must have exclusive id-s */
+ E_FMAN_PORT_TYPE_RX, /**< 1G Rx port */
+ E_FMAN_PORT_TYPE_RX_10G, /**< 10G Rx port */
+ E_FMAN_PORT_TYPE_TX, /**< 1G Tx port */
+ E_FMAN_PORT_TYPE_TX_10G, /**< 10G Tx port */
+ E_FMAN_PORT_TYPE_DUMMY,
+ E_FMAN_PORT_TYPE_HC = E_FMAN_PORT_TYPE_DUMMY
+ /**< Host command port, shares id-s with
+ * offline parsing ports, so must have exclusive id-s */
+};
+
+struct fman_port_params {
+ uint32_t discard_mask;
+ uint32_t err_mask;
+ uint32_t dflt_fqid;
+ uint32_t err_fqid;
+ uint8_t deq_sp;
+ bool dont_release_buf;
+};
+
+/* Port context - used by most API functions */
+struct fman_port {
+ enum fman_port_type type;
+ uint8_t fm_rev_maj;
+ uint8_t fm_rev_min;
+ union fman_port_bmi_regs *bmi_regs;
+ struct fman_port_qmi_regs *qmi_regs;
+ bool im_en;
+ uint8_t ext_pools_num;
+};
+
+/** @Description External buffer pools configuration */
+struct fman_port_bpools {
+ uint8_t count; /**< Num of pools to set up */
+ bool counters_enable; /**< Enable allocate counters */
+ uint8_t grp_bp_depleted_num;
+ /**< Number of depleted pools - if reached the BMI indicates
+ * the MAC to send a pause frame */
+ struct {
+ uint8_t bpid; /**< BM pool ID */
+ uint16_t size;
+ /**< Pool's size - must be in ascending order */
+ bool is_backup;
+ /**< If this is a backup pool */
+ bool grp_bp_depleted;
+ /**< Consider this buffer in multiple pools depletion criteria*/
+ bool single_bp_depleted;
+ /**< Consider this buffer in single pool depletion criteria */
+ bool pfc_priorities_en;
+ } bpool[FMAN_PORT_MAX_EXT_POOLS_NUM];
+};
+
+enum fman_port_rate_limiter_scale_down {
+ E_FMAN_PORT_RATE_DOWN_NONE,
+ E_FMAN_PORT_RATE_DOWN_BY_2,
+ E_FMAN_PORT_RATE_DOWN_BY_4,
+ E_FMAN_PORT_RATE_DOWN_BY_8
+};
+
+/* Rate limiter configuration */
+struct fman_port_rate_limiter {
+ uint8_t count_1micro_bit;
+ bool high_burst_size_gran;
+ /**< Defines burst_size granularity for OP ports; when TRUE,
+ * burst_size below counts in frames, otherwise in 10^3 frames */
+ uint16_t burst_size;
+ /**< Max burst size, in KBytes for Tx port, according to
+ * high_burst_size_gran definition for OP port */
+ uint32_t rate;
+ /**< In Kbps for Tx port, in frames/sec for OP port */
+ enum fman_port_rate_limiter_scale_down rate_factor;
+};
+
+/* BMI statistics counters */
+enum fman_port_stats_counters {
+ E_FMAN_PORT_STATS_CNT_FRAME,
+ /**< Number of processed frames; valid for all ports */
+ E_FMAN_PORT_STATS_CNT_DISCARD,
+ /**< For Rx ports - frames discarded by QMAN, for Tx or O/H ports -
+ * frames discarded due to DMA error; valid for all ports */
+ E_FMAN_PORT_STATS_CNT_DEALLOC_BUF,
+ /**< Number of buffer deallocate operations; valid for all ports */
+ E_FMAN_PORT_STATS_CNT_RX_BAD_FRAME,
+ /**< Number of bad Rx frames, like CRC error, Rx FIFO overflow etc;
+ * valid for Rx ports only */
+ E_FMAN_PORT_STATS_CNT_RX_LARGE_FRAME,
+ /**< Number of Rx oversized frames, that is frames exceeding max frame
+ * size configured for the corresponding ETH controller;
+ * valid for Rx ports only */
+ E_FMAN_PORT_STATS_CNT_RX_OUT_OF_BUF,
+ /**< Frames discarded due to lack of external buffers; valid for
+ * Rx ports only */
+ E_FMAN_PORT_STATS_CNT_LEN_ERR,
+ /**< Frames discarded due to frame length error; valid for Tx and
+ * O/H ports only */
+ E_FMAN_PORT_STATS_CNT_UNSUPPORTED_FORMAT,
+ /**< Frames discarded due to unsupported FD format; valid for Tx
+ * and O/H ports only */
+ E_FMAN_PORT_STATS_CNT_FILTERED_FRAME,
+ /**< Number of frames filtered out by PCD module; valid for
+ * Rx and OP ports only */
+ E_FMAN_PORT_STATS_CNT_DMA_ERR,
+ /**< Frames rejected by QMAN that were not able to release their
+ * buffers due to DMA error; valid for Rx and O/H ports only */
+ E_FMAN_PORT_STATS_CNT_WRED_DISCARD
+ /**< Frames going through O/H port that were not able to to enter the
+ * return queue due to WRED algorithm; valid for O/H ports only */
+};
+
+/* BMI performance counters */
+enum fman_port_perf_counters {
+ E_FMAN_PORT_PERF_CNT_CYCLE, /**< Cycle counter */
+ E_FMAN_PORT_PERF_CNT_TASK_UTIL, /**< Tasks utilization counter */
+ E_FMAN_PORT_PERF_CNT_QUEUE_UTIL,
+ /**< For Rx ports - Rx queue utilization, for Tx ports - Tx conf queue
+ * utilization; not valid for O/H ports */
+ E_FMAN_PORT_PERF_CNT_DMA_UTIL, /**< DMA utilization counter */
+ E_FMAN_PORT_PERF_CNT_FIFO_UTIL, /**< FIFO utilization counter */
+ E_FMAN_PORT_PERF_CNT_RX_PAUSE
+ /**< Number of cycles in which Rx pause activation control is on;
+ * valid for Rx ports only */
+};
+
+/* QMI counters */
+enum fman_port_qmi_counters {
+ E_FMAN_PORT_ENQ_TOTAL, /**< EnQ tot frame cntr */
+ E_FMAN_PORT_DEQ_TOTAL, /**< DeQ tot frame cntr; invalid for Rx ports */
+ E_FMAN_PORT_DEQ_FROM_DFLT,
+ /**< Dequeue from default FQID counter not valid for Rx ports */
+ E_FMAN_PORT_DEQ_CONFIRM /**< DeQ confirm cntr invalid for Rx ports */
+};
+
+
+/** @Collection FM Port API */
+void fman_port_defconfig(struct fman_port_cfg *cfg, enum fman_port_type type);
+int fman_port_init(struct fman_port *port,
+ struct fman_port_cfg *cfg,
+ struct fman_port_params *params);
+int fman_port_enable(struct fman_port *port);
+int fman_port_disable(const struct fman_port *port);
+int fman_port_set_bpools(const struct fman_port *port,
+ const struct fman_port_bpools *bp);
+int fman_port_set_rate_limiter(struct fman_port *port,
+ struct fman_port_rate_limiter *rate_limiter);
+int fman_port_delete_rate_limiter(struct fman_port *port);
+int fman_port_set_err_mask(struct fman_port *port, uint32_t err_mask);
+int fman_port_set_discard_mask(struct fman_port *port, uint32_t discard_mask);
+int fman_port_modify_rx_fd_bits(struct fman_port *port,
+ uint8_t rx_fd_bits,
+ bool add);
+int fman_port_set_perf_cnt_params(struct fman_port *port,
+ struct fman_port_perf_cnt_params *params);
+int fman_port_set_stats_cnt_mode(struct fman_port *port, bool enable);
+int fman_port_set_perf_cnt_mode(struct fman_port *port, bool enable);
+int fman_port_set_queue_cnt_mode(struct fman_port *port, bool enable);
+int fman_port_set_bpool_cnt_mode(struct fman_port *port,
+ uint8_t bpid,
+ bool enable);
+uint32_t fman_port_get_stats_counter(struct fman_port *port,
+ enum fman_port_stats_counters counter);
+void fman_port_set_stats_counter(struct fman_port *port,
+ enum fman_port_stats_counters counter,
+ uint32_t value);
+uint32_t fman_port_get_perf_counter(struct fman_port *port,
+ enum fman_port_perf_counters counter);
+void fman_port_set_perf_counter(struct fman_port *port,
+ enum fman_port_perf_counters counter,
+ uint32_t value);
+uint32_t fman_port_get_qmi_counter(struct fman_port *port,
+ enum fman_port_qmi_counters counter);
+void fman_port_set_qmi_counter(struct fman_port *port,
+ enum fman_port_qmi_counters counter,
+ uint32_t value);
+uint32_t fman_port_get_bpool_counter(struct fman_port *port, uint8_t bpid);
+void fman_port_set_bpool_counter(struct fman_port *port,
+ uint8_t bpid,
+ uint32_t value);
+int fman_port_add_congestion_grps(struct fman_port *port,
+ uint32_t grps_map[FMAN_PORT_CG_MAP_NUM]);
+int fman_port_remove_congestion_grps(struct fman_port *port,
+ uint32_t grps_map[FMAN_PORT_CG_MAP_NUM]);
+
+
+#endif /* __FSL_FMAN_PORT_H */
diff --git a/sys/contrib/ncsw/inc/flib/fsl_fman_prs.h b/sys/contrib/ncsw/inc/flib/fsl_fman_prs.h
new file mode 100644
index 000000000000..b18997dc0b8a
--- /dev/null
+++ b/sys/contrib/ncsw/inc/flib/fsl_fman_prs.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __FSL_FMAN_PRS_H
+#define __FSL_FMAN_PRS_H
+
+#include "common/general.h"
+
+#define FM_PCD_EX_PRS_DOUBLE_ECC 0x02000000
+#define FM_PCD_EX_PRS_SINGLE_ECC 0x01000000
+
+#define FM_PCD_PRS_PPSC_ALL_PORTS 0xffff0000
+#define FM_PCD_PRS_RPIMAC_EN 0x00000001
+#define FM_PCD_PRS_PORT_IDLE_STS 0xffff0000
+#define FM_PCD_PRS_SINGLE_ECC 0x00004000
+#define FM_PCD_PRS_DOUBLE_ECC 0x00004000
+#define PRS_MAX_CYCLE_LIMIT 8191
+
+#define DEFAULT_MAX_PRS_CYC_LIM 0
+
+struct fman_prs_regs {
+ uint32_t fmpr_rpclim;
+ uint32_t fmpr_rpimac;
+ uint32_t pmeec;
+ uint32_t res00c[5];
+ uint32_t fmpr_pevr;
+ uint32_t fmpr_pever;
+ uint32_t res028;
+ uint32_t fmpr_perr;
+ uint32_t fmpr_perer;
+ uint32_t res034;
+ uint32_t res038[10];
+ uint32_t fmpr_ppsc;
+ uint32_t res064;
+ uint32_t fmpr_pds;
+ uint32_t fmpr_l2rrs;
+ uint32_t fmpr_l3rrs;
+ uint32_t fmpr_l4rrs;
+ uint32_t fmpr_srrs;
+ uint32_t fmpr_l2rres;
+ uint32_t fmpr_l3rres;
+ uint32_t fmpr_l4rres;
+ uint32_t fmpr_srres;
+ uint32_t fmpr_spcs;
+ uint32_t fmpr_spscs;
+ uint32_t fmpr_hxscs;
+ uint32_t fmpr_mrcs;
+ uint32_t fmpr_mwcs;
+ uint32_t fmpr_mrscs;
+ uint32_t fmpr_mwscs;
+ uint32_t fmpr_fcscs;
+};
+
+struct fman_prs_cfg {
+ uint32_t port_id_stat;
+ uint16_t max_prs_cyc_lim;
+ uint32_t prs_exceptions;
+};
+
+uint32_t fman_prs_get_err_event(struct fman_prs_regs *regs, uint32_t ev_mask);
+uint32_t fman_prs_get_err_ev_mask(struct fman_prs_regs *regs);
+void fman_prs_ack_err_event(struct fman_prs_regs *regs, uint32_t event);
+uint32_t fman_prs_get_expt_event(struct fman_prs_regs *regs, uint32_t ev_mask);
+uint32_t fman_prs_get_expt_ev_mask(struct fman_prs_regs *regs);
+void fman_prs_ack_expt_event(struct fman_prs_regs *regs, uint32_t event);
+void fman_prs_defconfig(struct fman_prs_cfg *cfg);
+int fman_prs_init(struct fman_prs_regs *regs, struct fman_prs_cfg *cfg);
+void fman_prs_enable(struct fman_prs_regs *regs);
+void fman_prs_disable(struct fman_prs_regs *regs);
+int fman_prs_is_enabled(struct fman_prs_regs *regs);
+void fman_prs_set_stst_port_msk(struct fman_prs_regs *regs, uint32_t pid_msk);
+void fman_prs_set_stst(struct fman_prs_regs *regs, bool enable);
+#endif /* __FSL_FMAN_PRS_H */
diff --git a/sys/contrib/ncsw/inc/flib/fsl_fman_rtc.h b/sys/contrib/ncsw/inc/flib/fsl_fman_rtc.h
new file mode 100755
index 000000000000..f6b69a1fbb05
--- /dev/null
+++ b/sys/contrib/ncsw/inc/flib/fsl_fman_rtc.h
@@ -0,0 +1,449 @@
+/*
+ * Copyright 2013 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __FSL_FMAN_RTC_H
+#define __FSL_FMAN_RTC_H
+
+#include "common/general.h"
+
+/* FM RTC Registers definitions */
+#define FMAN_RTC_TMR_CTRL_ALMP1 0x80000000
+#define FMAN_RTC_TMR_CTRL_ALMP2 0x40000000
+#define FMAN_RTC_TMR_CTRL_FS 0x10000000
+#define FMAN_RTC_TMR_CTRL_PP1L 0x08000000
+#define FMAN_RTC_TMR_CTRL_PP2L 0x04000000
+#define FMAN_RTC_TMR_CTRL_TCLK_PERIOD_MASK 0x03FF0000
+#define FMAN_RTC_TMR_CTRL_FRD 0x00004000
+#define FMAN_RTC_TMR_CTRL_SLV 0x00002000
+#define FMAN_RTC_TMR_CTRL_ETEP1 0x00000100
+#define FMAN_RTC_TMR_CTRL_COPH 0x00000080
+#define FMAN_RTC_TMR_CTRL_CIPH 0x00000040
+#define FMAN_RTC_TMR_CTRL_TMSR 0x00000020
+#define FMAN_RTC_TMR_CTRL_DBG 0x00000010
+#define FMAN_RTC_TMR_CTRL_BYP 0x00000008
+#define FMAN_RTC_TMR_CTRL_TE 0x00000004
+#define FMAN_RTC_TMR_CTRL_CKSEL_OSC_CLK 0x00000003
+#define FMAN_RTC_TMR_CTRL_CKSEL_MAC_CLK 0x00000001
+#define FMAN_RTC_TMR_CTRL_CKSEL_EXT_CLK 0x00000000
+#define FMAN_RTC_TMR_CTRL_TCLK_PERIOD_SHIFT 16
+
+#define FMAN_RTC_TMR_TEVENT_ETS2 0x02000000
+#define FMAN_RTC_TMR_TEVENT_ETS1 0x01000000
+#define FMAN_RTC_TMR_TEVENT_ALM2 0x00020000
+#define FMAN_RTC_TMR_TEVENT_ALM1 0x00010000
+#define FMAN_RTC_TMR_TEVENT_PP1 0x00000080
+#define FMAN_RTC_TMR_TEVENT_PP2 0x00000040
+#define FMAN_RTC_TMR_TEVENT_PP3 0x00000020
+#define FMAN_RTC_TMR_TEVENT_ALL (FMAN_RTC_TMR_TEVENT_ETS2 |\
+ FMAN_RTC_TMR_TEVENT_ETS1 |\
+ FMAN_RTC_TMR_TEVENT_ALM2 |\
+ FMAN_RTC_TMR_TEVENT_ALM1 |\
+ FMAN_RTC_TMR_TEVENT_PP1 |\
+ FMAN_RTC_TMR_TEVENT_PP2 |\
+ FMAN_RTC_TMR_TEVENT_PP3)
+
+#define FMAN_RTC_TMR_PRSC_OCK_MASK 0x0000FFFF
+
+/**************************************************************************//**
+ @Description FM RTC Alarm Polarity Options.
+*//***************************************************************************/
+enum fman_rtc_alarm_polarity {
+ E_FMAN_RTC_ALARM_POLARITY_ACTIVE_HIGH, /**< Active-high output polarity */
+ E_FMAN_RTC_ALARM_POLARITY_ACTIVE_LOW /**< Active-low output polarity */
+};
+
+/**************************************************************************//**
+ @Description FM RTC Trigger Polarity Options.
+*//***************************************************************************/
+enum fman_rtc_trigger_polarity {
+ E_FMAN_RTC_TRIGGER_ON_RISING_EDGE, /**< Trigger on rising edge */
+ E_FMAN_RTC_TRIGGER_ON_FALLING_EDGE /**< Trigger on falling edge */
+};
+
+/**************************************************************************//**
+ @Description IEEE1588 Timer Module FM RTC Optional Clock Sources.
+*//***************************************************************************/
+enum fman_src_clock {
+ E_FMAN_RTC_SOURCE_CLOCK_EXTERNAL, /**< external high precision timer
+ reference clock */
+ E_FMAN_RTC_SOURCE_CLOCK_SYSTEM, /**< MAC system clock */
+ E_FMAN_RTC_SOURCE_CLOCK_OSCILATOR /**< RTC clock oscilator */
+};
+
+/* RTC default values */
+#define DEFAULT_SRC_CLOCK E_FMAN_RTC_SOURCE_CLOCK_SYSTEM
+#define DEFAULT_INVERT_INPUT_CLK_PHASE FALSE
+#define DEFAULT_INVERT_OUTPUT_CLK_PHASE FALSE
+#define DEFAULT_ALARM_POLARITY E_FMAN_RTC_ALARM_POLARITY_ACTIVE_HIGH
+#define DEFAULT_TRIGGER_POLARITY E_FMAN_RTC_TRIGGER_ON_FALLING_EDGE
+#define DEFAULT_PULSE_REALIGN FALSE
+
+#define FMAN_RTC_MAX_NUM_OF_ALARMS 3
+#define FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES 4
+#define FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS 3
+
+/**************************************************************************//**
+ @Description FM RTC timer alarm
+*//***************************************************************************/
+struct t_tmr_alarm{
+ uint32_t tmr_alarm_h; /**< */
+ uint32_t tmr_alarm_l; /**< */
+};
+
+/**************************************************************************//**
+ @Description FM RTC timer Ex trigger
+*//***************************************************************************/
+struct t_tmr_ext_trigger{
+ uint32_t tmr_etts_h; /**< */
+ uint32_t tmr_etts_l; /**< */
+};
+
+struct rtc_regs {
+ uint32_t tmr_id; /* 0x000 Module ID register */
+ uint32_t tmr_id2; /* 0x004 Controller ID register */
+ uint32_t reserved0008[30];
+ uint32_t tmr_ctrl; /* 0x0080 timer control register */
+ uint32_t tmr_tevent; /* 0x0084 timer event register */
+ uint32_t tmr_temask; /* 0x0088 timer event mask register */
+ uint32_t reserved008c[3];
+ uint32_t tmr_cnt_h; /* 0x0098 timer counter high register */
+ uint32_t tmr_cnt_l; /* 0x009c timer counter low register */
+ uint32_t tmr_add; /* 0x00a0 timer drift compensation addend register */
+ uint32_t tmr_acc; /* 0x00a4 timer accumulator register */
+ uint32_t tmr_prsc; /* 0x00a8 timer prescale */
+ uint32_t reserved00ac;
+ uint32_t tmr_off_h; /* 0x00b0 timer offset high */
+ uint32_t tmr_off_l; /* 0x00b4 timer offset low */
+ struct t_tmr_alarm tmr_alarm[FMAN_RTC_MAX_NUM_OF_ALARMS]; /* 0x00b8 timer
+ alarm */
+ uint32_t tmr_fiper[FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES]; /* 0x00d0 timer
+ fixed period interval */
+ struct t_tmr_ext_trigger tmr_etts[FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS];
+ /* 0x00e0 time stamp general purpose external */
+ uint32_t reserved00f0[4];
+};
+
+struct rtc_cfg {
+ enum fman_src_clock src_clk;
+ uint32_t ext_src_clk_freq;
+ uint32_t rtc_freq_hz;
+ bool timer_slave_mode;
+ bool invert_input_clk_phase;
+ bool invert_output_clk_phase;
+ uint32_t events_mask;
+ bool bypass; /**< Indicates if frequency compensation
+ is bypassed */
+ bool pulse_realign;
+ enum fman_rtc_alarm_polarity alarm_polarity[FMAN_RTC_MAX_NUM_OF_ALARMS];
+ enum fman_rtc_trigger_polarity trigger_polarity
+ [FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS];
+};
+
+/**
+ * fman_rtc_defconfig() - Get default RTC configuration
+ * @cfg: pointer to configuration structure.
+ *
+ * Call this function to obtain a default set of configuration values for
+ * initializing RTC. The user can overwrite any of the values before calling
+ * fman_rtc_init(), if specific configuration needs to be applied.
+ */
+void fman_rtc_defconfig(struct rtc_cfg *cfg);
+
+/**
+ * fman_rtc_get_events() - Get the events
+ * @regs: Pointer to RTC register block
+ *
+ * Returns: The events
+ */
+uint32_t fman_rtc_get_events(struct rtc_regs *regs);
+
+/**
+ * fman_rtc_get_interrupt_mask() - Get the events mask
+ * @regs: Pointer to RTC register block
+ *
+ * Returns: The events mask
+ */
+uint32_t fman_rtc_get_interrupt_mask(struct rtc_regs *regs);
+
+
+/**
+ * fman_rtc_set_interrupt_mask() - Set the events mask
+ * @regs: Pointer to RTC register block
+ * @mask: The mask to set
+ */
+void fman_rtc_set_interrupt_mask(struct rtc_regs *regs, uint32_t mask);
+
+/**
+ * fman_rtc_get_event() - Check if specific events occurred
+ * @regs: Pointer to RTC register block
+ * @ev_mask: a mask of the events to check
+ *
+ * Returns: 0 if the events did not occur. Non zero if one of the events occurred
+ */
+uint32_t fman_rtc_get_event(struct rtc_regs *regs, uint32_t ev_mask);
+
+/**
+ * fman_rtc_check_and_clear_event() - Clear events which are on
+ * @regs: Pointer to RTC register block
+ *
+ * Returns: A mask of the events which were cleared
+ */
+uint32_t fman_rtc_check_and_clear_event(struct rtc_regs *regs);
+
+/**
+ * fman_rtc_ack_event() - Clear events
+ * @regs: Pointer to RTC register block
+ * @events: The events to disable
+ */
+void fman_rtc_ack_event(struct rtc_regs *regs, uint32_t events);
+
+/**
+ * fman_rtc_enable_interupt() - Enable events interrupts
+ * @regs: Pointer to RTC register block
+ * @mask: The events to disable
+ */
+void fman_rtc_enable_interupt(struct rtc_regs *regs, uint32_t mask);
+
+/**
+ * fman_rtc_disable_interupt() - Disable events interrupts
+ * @regs: Pointer to RTC register block
+ * @mask: The events to disable
+ */
+void fman_rtc_disable_interupt(struct rtc_regs *regs, uint32_t mask);
+
+/**
+ * fman_rtc_get_timer_ctrl() - Get the control register
+ * @regs: Pointer to RTC register block
+ *
+ * Returns: The control register value
+ */
+uint32_t fman_rtc_get_timer_ctrl(struct rtc_regs *regs);
+
+/**
+ * fman_rtc_set_timer_ctrl() - Set timer control register
+ * @regs: Pointer to RTC register block
+ * @val: The value to set
+ */
+void fman_rtc_set_timer_ctrl(struct rtc_regs *regs, uint32_t val);
+
+/**
+ * fman_rtc_get_frequency_compensation() - Get the frequency compensation
+ * @regs: Pointer to RTC register block
+ *
+ * Returns: The timer counter
+ */
+uint32_t fman_rtc_get_frequency_compensation(struct rtc_regs *regs);
+
+/**
+ * fman_rtc_set_frequency_compensation() - Set frequency compensation
+ * @regs: Pointer to RTC register block
+ * @val: The value to set
+ */
+void fman_rtc_set_frequency_compensation(struct rtc_regs *regs, uint32_t val);
+
+/**
+ * fman_rtc_get_trigger_stamp() - Get a trigger stamp
+ * @regs: Pointer to RTC register block
+ * @id: The id of the trigger stamp
+ *
+ * Returns: The time stamp
+ */
+uint64_t fman_rtc_get_trigger_stamp(struct rtc_regs *regs, int id);
+
+/**
+ * fman_rtc_set_timer_alarm_l() - Set timer alarm low register
+ * @regs: Pointer to RTC register block
+ * @index: The index of alarm to set
+ * @val: The value to set
+ */
+void fman_rtc_set_timer_alarm_l(struct rtc_regs *regs, int index,
+ uint32_t val);
+
+/**
+ * fman_rtc_set_timer_alarm() - Set timer alarm
+ * @regs: Pointer to RTC register block
+ * @index: The index of alarm to set
+ * @val: The value to set
+ */
+void fman_rtc_set_timer_alarm(struct rtc_regs *regs, int index, int64_t val);
+
+/**
+ * fman_rtc_set_timer_fiper() - Set timer fiper
+ * @regs: Pointer to RTC register block
+ * @index: The index of fiper to set
+ * @val: The value to set
+ */
+void fman_rtc_set_timer_fiper(struct rtc_regs *regs, int index, uint32_t val);
+
+/**
+ * fman_rtc_set_timer_offset() - Set timer offset
+ * @regs: Pointer to RTC register block
+ * @val: The value to set
+ */
+void fman_rtc_set_timer_offset(struct rtc_regs *regs, int64_t val);
+
+/**
+ * fman_rtc_get_timer() - Get the timer counter
+ * @regs: Pointer to RTC register block
+ *
+ * Returns: The timer counter
+ */
+static inline uint64_t fman_rtc_get_timer(struct rtc_regs *regs)
+{
+ uint64_t time;
+ /* TMR_CNT_L must be read first to get an accurate value */
+ time = (uint64_t)ioread32be(&regs->tmr_cnt_l);
+ time |= ((uint64_t)ioread32be(&regs->tmr_cnt_h) << 32);
+
+ return time;
+}
+
+/**
+ * fman_rtc_set_timer() - Set timer counter
+ * @regs: Pointer to RTC register block
+ * @val: The value to set
+ */
+static inline void fman_rtc_set_timer(struct rtc_regs *regs, int64_t val)
+{
+ iowrite32be((uint32_t)val, &regs->tmr_cnt_l);
+ iowrite32be((uint32_t)(val >> 32), &regs->tmr_cnt_h);
+}
+
+/**
+ * fman_rtc_timers_soft_reset() - Soft reset
+ * @regs: Pointer to RTC register block
+ *
+ * Resets all the timer registers and state machines for the 1588 IP and
+ * the attached client 1588
+ */
+void fman_rtc_timers_soft_reset(struct rtc_regs *regs);
+
+/**
+ * fman_rtc_clear_external_trigger() - Clear an external trigger
+ * @regs: Pointer to RTC register block
+ * @id: The id of the trigger to clear
+ */
+void fman_rtc_clear_external_trigger(struct rtc_regs *regs, int id);
+
+/**
+ * fman_rtc_clear_periodic_pulse() - Clear periodic pulse
+ * @regs: Pointer to RTC register block
+ * @id: The id of the fiper to clear
+ */
+void fman_rtc_clear_periodic_pulse(struct rtc_regs *regs, int id);
+
+/**
+ * fman_rtc_enable() - Enable RTC hardware block
+ * @regs: Pointer to RTC register block
+ */
+void fman_rtc_enable(struct rtc_regs *regs, bool reset_clock);
+
+/**
+ * fman_rtc_is_enabled() - Is RTC hardware block enabled
+ * @regs: Pointer to RTC register block
+ *
+ * Return: TRUE if enabled
+ */
+bool fman_rtc_is_enabled(struct rtc_regs *regs);
+
+/**
+ * fman_rtc_disable() - Disable RTC hardware block
+ * @regs: Pointer to RTC register block
+ */
+void fman_rtc_disable(struct rtc_regs *regs);
+
+/**
+ * fman_rtc_init() - Init RTC hardware block
+ * @cfg: RTC configuration data
+ * @regs: Pointer to RTC register block
+ * @num_alarms: Number of alarms in RTC
+ * @num_fipers: Number of fipers in RTC
+ * @num_ext_triggers: Number of external triggers in RTC
+ * @freq_compensation: Frequency compensation
+ * @output_clock_divisor: Output clock divisor
+ *
+ * This function initializes RTC and applies basic configuration.
+ */
+void fman_rtc_init(struct rtc_cfg *cfg, struct rtc_regs *regs, int num_alarms,
+ int num_fipers, int num_ext_triggers, bool init_freq_comp,
+ uint32_t freq_compensation, uint32_t output_clock_divisor);
+
+/**
+ * fman_rtc_set_alarm() - Set an alarm
+ * @regs: Pointer to RTC register block
+ * @id: id of alarm
+ * @val: value to write
+ * @enable: should interrupt be enabled
+ */
+void fman_rtc_set_alarm(struct rtc_regs *regs, int id, uint32_t val, bool enable);
+
+/**
+ * fman_rtc_set_periodic_pulse() - Set an alarm
+ * @regs: Pointer to RTC register block
+ * @id: id of fiper
+ * @val: value to write
+ * @enable: should interrupt be enabled
+ */
+void fman_rtc_set_periodic_pulse(struct rtc_regs *regs, int id, uint32_t val,
+ bool enable);
+
+/**
+ * fman_rtc_set_ext_trigger() - Set an external trigger
+ * @regs: Pointer to RTC register block
+ * @id: id of trigger
+ * @enable: should interrupt be enabled
+ * @use_pulse_as_input: use the pulse as input
+ */
+void fman_rtc_set_ext_trigger(struct rtc_regs *regs, int id, bool enable,
+ bool use_pulse_as_input);
+
+struct fm_rtc_alarm_params {
+ uint8_t alarm_id; /**< 0 or 1 */
+ uint64_t alarm_time; /**< In nanoseconds, the time when the
+ alarm should go off - must be a
+ multiple of the RTC period */
+ void (*f_alarm_callback)(void* app, uint8_t id); /**< This routine will
+ be called when RTC reaches alarmTime */
+ bool clear_on_expiration; /**< TRUE to turn off the alarm once
+ expired.*/
+};
+
+struct fm_rtc_periodic_pulse_params {
+ uint8_t periodic_pulse_id; /**< 0 or 1 */
+ uint64_t periodic_pulse_period; /**< In Nanoseconds. Must be a multiple
+ of the RTC period */
+ void (*f_periodic_pulse_callback)(void* app, uint8_t id); /**< This
+ routine will be called every
+ periodicPulsePeriod. */
+};
+
+#endif /* __FSL_FMAN_RTC_H */
diff --git a/sys/contrib/ncsw/inc/flib/fsl_fman_sp.h b/sys/contrib/ncsw/inc/flib/fsl_fman_sp.h
new file mode 100755
index 000000000000..f8ef7d569e10
--- /dev/null
+++ b/sys/contrib/ncsw/inc/flib/fsl_fman_sp.h
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2013 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __FSL_FMAN_SP_H
+#define __FSL_FMAN_SP_H
+
+#include "common/general.h"
+#include "fsl_fman.h"
+
+
+struct fm_pcd_storage_profile_regs{
+ uint32_t fm_sp_ebmpi[8];
+ /*offset 0 - 0xc*/
+ /**< Buffer Manager pool Information */
+
+ uint32_t fm_sp_acnt; /*offset 0x20*/
+ uint32_t fm_sp_ebm; /*offset 0x24*/
+ uint32_t fm_sp_da; /*offset 0x28*/
+ uint32_t fm_sp_icp; /*offset 0x2c*/
+ uint32_t fm_sp_mpd; /*offset 0x30*/
+ uint32_t res1[2]; /*offset 0x34 - 0x38*/
+ uint32_t fm_sp_spliodn; /*offset 0x3c*/
+};
+
+/**************************************************************************//**
+ @Description structure for defining internal context copying
+*//***************************************************************************/
+struct fman_sp_int_context_data_copy{
+ uint16_t ext_buf_offset; /**< Offset in External buffer to which
+ internal context is copied to (Rx)
+ or taken from (Tx, Op). */
+ uint8_t int_context_offset; /**< Offset within internal context to copy
+ from (Rx) or to copy to (Tx, Op).*/
+ uint16_t size; /**< Internal offset size to be copied */
+};
+
+/**************************************************************************//**
+ @Description struct for defining external buffer margins
+*//***************************************************************************/
+struct fman_sp_buf_margins{
+ uint16_t start_margins; /**< Number of bytes to be left at the
+ beginning of the external buffer (must be
+ divisible by 16) */
+ uint16_t end_margins; /**< number of bytes to be left at the end of
+ the external buffer(must be divisible by 16)*/
+};
+
+struct fm_storage_profile_params {
+ struct fman_ext_pools fm_ext_pools;
+ struct fman_backup_bm_pools backup_pools;
+ struct fman_sp_int_context_data_copy *int_context;
+ struct fman_sp_buf_margins *buf_margins;
+ enum fman_dma_swap_option dma_swap_data;
+ enum fman_dma_cache_option int_context_cache_attr;
+ enum fman_dma_cache_option header_cache_attr;
+ enum fman_dma_cache_option scatter_gather_cache_attr;
+ bool dma_write_optimize;
+ uint16_t liodn_offset;
+ bool no_scather_gather;
+ struct fman_buf_pool_depletion buf_pool_depletion;
+};
+
+/**************************************************************************//**
+ @Description Registers bit fields
+*//***************************************************************************/
+#define FMAN_SP_EXT_BUF_POOL_EN_COUNTER 0x40000000
+#define FMAN_SP_EXT_BUF_POOL_VALID 0x80000000
+#define FMAN_SP_EXT_BUF_POOL_BACKUP 0x20000000
+#define FMAN_SP_DMA_ATTR_WRITE_OPTIMIZE 0x00100000
+#define FMAN_SP_SG_DISABLE 0x80000000
+
+/* shifts */
+#define FMAN_SP_EXT_BUF_POOL_ID_SHIFT 16
+#define FMAN_SP_POOL_DEP_NUM_OF_POOLS_SHIFT 16
+#define FMAN_SP_EXT_BUF_MARG_START_SHIFT 16
+#define FMAN_SP_EXT_BUF_MARG_END_SHIFT 0
+#define FMAN_SP_DMA_ATTR_SWP_SHIFT 30
+#define FMAN_SP_DMA_ATTR_IC_CACHE_SHIFT 28
+#define FMAN_SP_DMA_ATTR_HDR_CACHE_SHIFT 26
+#define FMAN_SP_DMA_ATTR_SG_CACHE_SHIFT 24
+#define FMAN_SP_IC_TO_EXT_SHIFT 16
+#define FMAN_SP_IC_FROM_INT_SHIFT 8
+#define FMAN_SP_IC_SIZE_SHIFT 0
+
+/**************************************************************************//**
+ @Description defaults
+*//***************************************************************************/
+#define DEFAULT_FMAN_SP_DMA_SWAP_DATA FMAN_DMA_NO_SWP
+#define DEFAULT_FMAN_SP_DMA_INT_CONTEXT_CACHE_ATTR FMAN_DMA_NO_STASH
+#define DEFAULT_FMAN_SP_DMA_HEADER_CACHE_ATTR FMAN_DMA_NO_STASH
+#define DEFAULT_FMAN_SP_DMA_SCATTER_GATHER_CACHE_ATTR FMAN_DMA_NO_STASH
+#define DEFAULT_FMAN_SP_DMA_WRITE_OPTIMIZE TRUE
+#define DEFAULT_FMAN_SP_NO_SCATTER_GATHER FALSE
+
+void fman_vsp_defconfig(struct fm_storage_profile_params *cfg);
+
+void fman_vsp_init(struct fm_pcd_storage_profile_regs *regs,
+ uint16_t index, struct fm_storage_profile_params *fm_vsp_params,
+ int port_max_num_of_ext_pools, int bm_max_num_of_pools,
+ int max_num_of_pfc_priorities);
+
+uint32_t fman_vsp_get_statistics(struct fm_pcd_storage_profile_regs *regs,
+ uint16_t index);
+
+void fman_vsp_set_statistics(struct fm_pcd_storage_profile_regs *regs,
+ uint16_t index, uint32_t value);
+
+
+#endif /* __FSL_FMAN_SP_H */
diff --git a/sys/contrib/ncsw/inc/flib/fsl_fman_tgec.h b/sys/contrib/ncsw/inc/flib/fsl_fman_tgec.h
new file mode 100644
index 000000000000..a0373141ac68
--- /dev/null
+++ b/sys/contrib/ncsw/inc/flib/fsl_fman_tgec.h
@@ -0,0 +1,479 @@
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __FSL_FMAN_TGEC_H
+#define __FSL_FMAN_TGEC_H
+
+#include "common/general.h"
+#include "fsl_enet.h"
+
+
+/* Transmit Inter-Packet Gap Length Register (TX_IPG_LENGTH) */
+#define TGEC_TX_IPG_LENGTH_MASK 0x000003ff
+
+enum tgec_counters {
+ E_TGEC_COUNTER_R64,
+ E_TGEC_COUNTER_R127,
+ E_TGEC_COUNTER_R255,
+ E_TGEC_COUNTER_R511,
+ E_TGEC_COUNTER_R1023,
+ E_TGEC_COUNTER_R1518,
+ E_TGEC_COUNTER_R1519X,
+ E_TGEC_COUNTER_TRFRG,
+ E_TGEC_COUNTER_TRJBR,
+ E_TGEC_COUNTER_RDRP,
+ E_TGEC_COUNTER_RALN,
+ E_TGEC_COUNTER_TRUND,
+ E_TGEC_COUNTER_TROVR,
+ E_TGEC_COUNTER_RXPF,
+ E_TGEC_COUNTER_TXPF,
+ E_TGEC_COUNTER_ROCT,
+ E_TGEC_COUNTER_RMCA,
+ E_TGEC_COUNTER_RBCA,
+ E_TGEC_COUNTER_RPKT,
+ E_TGEC_COUNTER_RUCA,
+ E_TGEC_COUNTER_RERR,
+ E_TGEC_COUNTER_TOCT,
+ E_TGEC_COUNTER_TMCA,
+ E_TGEC_COUNTER_TBCA,
+ E_TGEC_COUNTER_TUCA,
+ E_TGEC_COUNTER_TERR
+};
+
+/* Command and Configuration Register (COMMAND_CONFIG) */
+#define CMD_CFG_EN_TIMESTAMP 0x00100000
+#define CMD_CFG_TX_ADDR_INS_SEL 0x00080000
+#define CMD_CFG_NO_LEN_CHK 0x00020000
+#define CMD_CFG_SEND_IDLE 0x00010000
+#define CMD_CFG_RX_ER_DISC 0x00004000
+#define CMD_CFG_CMD_FRM_EN 0x00002000
+#define CMD_CFG_STAT_CLR 0x00001000
+#define CMD_CFG_LOOPBACK_EN 0x00000400
+#define CMD_CFG_TX_ADDR_INS 0x00000200
+#define CMD_CFG_PAUSE_IGNORE 0x00000100
+#define CMD_CFG_PAUSE_FWD 0x00000080
+#define CMD_CFG_PROMIS_EN 0x00000010
+#define CMD_CFG_WAN_MODE 0x00000008
+#define CMD_CFG_RX_EN 0x00000002
+#define CMD_CFG_TX_EN 0x00000001
+
+/* Interrupt Mask Register (IMASK) */
+#define TGEC_IMASK_MDIO_SCAN_EVENT 0x00010000
+#define TGEC_IMASK_MDIO_CMD_CMPL 0x00008000
+#define TGEC_IMASK_REM_FAULT 0x00004000
+#define TGEC_IMASK_LOC_FAULT 0x00002000
+#define TGEC_IMASK_TX_ECC_ER 0x00001000
+#define TGEC_IMASK_TX_FIFO_UNFL 0x00000800
+#define TGEC_IMASK_TX_FIFO_OVFL 0x00000400
+#define TGEC_IMASK_TX_ER 0x00000200
+#define TGEC_IMASK_RX_FIFO_OVFL 0x00000100
+#define TGEC_IMASK_RX_ECC_ER 0x00000080
+#define TGEC_IMASK_RX_JAB_FRM 0x00000040
+#define TGEC_IMASK_RX_OVRSZ_FRM 0x00000020
+#define TGEC_IMASK_RX_RUNT_FRM 0x00000010
+#define TGEC_IMASK_RX_FRAG_FRM 0x00000008
+#define TGEC_IMASK_RX_LEN_ER 0x00000004
+#define TGEC_IMASK_RX_CRC_ER 0x00000002
+#define TGEC_IMASK_RX_ALIGN_ER 0x00000001
+
+#define TGEC_EVENTS_MASK \
+ ((uint32_t)(TGEC_IMASK_MDIO_SCAN_EVENT | \
+ TGEC_IMASK_MDIO_CMD_CMPL | \
+ TGEC_IMASK_REM_FAULT | \
+ TGEC_IMASK_LOC_FAULT | \
+ TGEC_IMASK_TX_ECC_ER | \
+ TGEC_IMASK_TX_FIFO_UNFL | \
+ TGEC_IMASK_TX_FIFO_OVFL | \
+ TGEC_IMASK_TX_ER | \
+ TGEC_IMASK_RX_FIFO_OVFL | \
+ TGEC_IMASK_RX_ECC_ER | \
+ TGEC_IMASK_RX_JAB_FRM | \
+ TGEC_IMASK_RX_OVRSZ_FRM | \
+ TGEC_IMASK_RX_RUNT_FRM | \
+ TGEC_IMASK_RX_FRAG_FRM | \
+ TGEC_IMASK_RX_LEN_ER | \
+ TGEC_IMASK_RX_CRC_ER | \
+ TGEC_IMASK_RX_ALIGN_ER))
+
+/* Hashtable Control Register (HASHTABLE_CTRL) */
+#define TGEC_HASH_MCAST_SHIFT 23
+#define TGEC_HASH_MCAST_EN 0x00000200
+#define TGEC_HASH_ADR_MSK 0x000001ff
+
+#define DEFAULT_WAN_MODE_ENABLE FALSE
+#define DEFAULT_PROMISCUOUS_MODE_ENABLE FALSE
+#define DEFAULT_PAUSE_FORWARD_ENABLE FALSE
+#define DEFAULT_PAUSE_IGNORE FALSE
+#define DEFAULT_TX_ADDR_INS_ENABLE FALSE
+#define DEFAULT_LOOPBACK_ENABLE FALSE
+#define DEFAULT_CMD_FRAME_ENABLE FALSE
+#define DEFAULT_RX_ERROR_DISCARD FALSE
+#define DEFAULT_SEND_IDLE_ENABLE FALSE
+#define DEFAULT_NO_LENGTH_CHECK_ENABLE TRUE
+#define DEFAULT_LGTH_CHECK_NOSTDR FALSE
+#define DEFAULT_TIME_STAMP_ENABLE FALSE
+#define DEFAULT_TX_IPG_LENGTH 12
+#define DEFAULT_MAX_FRAME_LENGTH 0x600
+#define DEFAULT_PAUSE_QUANT 0xf000
+
+/*
+ * 10G memory map
+ */
+struct tgec_regs {
+ uint32_t tgec_id; /* 0x000 Controller ID */
+ uint32_t reserved001[1]; /* 0x004 */
+ uint32_t command_config; /* 0x008 Control and configuration */
+ uint32_t mac_addr_0; /* 0x00c Lower 32 bits of the MAC adr */
+ uint32_t mac_addr_1; /* 0x010 Upper 16 bits of the MAC adr */
+ uint32_t maxfrm; /* 0x014 Maximum frame length */
+ uint32_t pause_quant; /* 0x018 Pause quanta */
+ uint32_t rx_fifo_sections; /* 0x01c */
+ uint32_t tx_fifo_sections; /* 0x020 */
+ uint32_t rx_fifo_almost_f_e; /* 0x024 */
+ uint32_t tx_fifo_almost_f_e; /* 0x028 */
+ uint32_t hashtable_ctrl; /* 0x02c Hash table control*/
+ uint32_t mdio_cfg_status; /* 0x030 */
+ uint32_t mdio_command; /* 0x034 */
+ uint32_t mdio_data; /* 0x038 */
+ uint32_t mdio_regaddr; /* 0x03c */
+ uint32_t status; /* 0x040 */
+ uint32_t tx_ipg_len; /* 0x044 Transmitter inter-packet-gap */
+ uint32_t mac_addr_2; /* 0x048 Lower 32 bits of 2nd MAC adr */
+ uint32_t mac_addr_3; /* 0x04c Upper 16 bits of 2nd MAC adr */
+ uint32_t rx_fifo_ptr_rd; /* 0x050 */
+ uint32_t rx_fifo_ptr_wr; /* 0x054 */
+ uint32_t tx_fifo_ptr_rd; /* 0x058 */
+ uint32_t tx_fifo_ptr_wr; /* 0x05c */
+ uint32_t imask; /* 0x060 Interrupt mask */
+ uint32_t ievent; /* 0x064 Interrupt event */
+ uint32_t udp_port; /* 0x068 Defines a UDP Port number */
+ uint32_t type_1588v2; /* 0x06c Type field for 1588v2 */
+ uint32_t reserved070[4]; /* 0x070 */
+ /*10Ge Statistics Counter */
+ uint32_t tfrm_u; /* 80 aFramesTransmittedOK */
+ uint32_t tfrm_l; /* 84 aFramesTransmittedOK */
+ uint32_t rfrm_u; /* 88 aFramesReceivedOK */
+ uint32_t rfrm_l; /* 8c aFramesReceivedOK */
+ uint32_t rfcs_u; /* 90 aFrameCheckSequenceErrors */
+ uint32_t rfcs_l; /* 94 aFrameCheckSequenceErrors */
+ uint32_t raln_u; /* 98 aAlignmentErrors */
+ uint32_t raln_l; /* 9c aAlignmentErrors */
+ uint32_t txpf_u; /* A0 aPAUSEMACCtrlFramesTransmitted */
+ uint32_t txpf_l; /* A4 aPAUSEMACCtrlFramesTransmitted */
+ uint32_t rxpf_u; /* A8 aPAUSEMACCtrlFramesReceived */
+ uint32_t rxpf_l; /* Ac aPAUSEMACCtrlFramesReceived */
+ uint32_t rlong_u; /* B0 aFrameTooLongErrors */
+ uint32_t rlong_l; /* B4 aFrameTooLongErrors */
+ uint32_t rflr_u; /* B8 aInRangeLengthErrors */
+ uint32_t rflr_l; /* Bc aInRangeLengthErrors */
+ uint32_t tvlan_u; /* C0 VLANTransmittedOK */
+ uint32_t tvlan_l; /* C4 VLANTransmittedOK */
+ uint32_t rvlan_u; /* C8 VLANReceivedOK */
+ uint32_t rvlan_l; /* Cc VLANReceivedOK */
+ uint32_t toct_u; /* D0 ifOutOctets */
+ uint32_t toct_l; /* D4 ifOutOctets */
+ uint32_t roct_u; /* D8 ifInOctets */
+ uint32_t roct_l; /* Dc ifInOctets */
+ uint32_t ruca_u; /* E0 ifInUcastPkts */
+ uint32_t ruca_l; /* E4 ifInUcastPkts */
+ uint32_t rmca_u; /* E8 ifInMulticastPkts */
+ uint32_t rmca_l; /* Ec ifInMulticastPkts */
+ uint32_t rbca_u; /* F0 ifInBroadcastPkts */
+ uint32_t rbca_l; /* F4 ifInBroadcastPkts */
+ uint32_t terr_u; /* F8 ifOutErrors */
+ uint32_t terr_l; /* Fc ifOutErrors */
+ uint32_t reserved100[2]; /* 100-108*/
+ uint32_t tuca_u; /* 108 ifOutUcastPkts */
+ uint32_t tuca_l; /* 10c ifOutUcastPkts */
+ uint32_t tmca_u; /* 110 ifOutMulticastPkts */
+ uint32_t tmca_l; /* 114 ifOutMulticastPkts */
+ uint32_t tbca_u; /* 118 ifOutBroadcastPkts */
+ uint32_t tbca_l; /* 11c ifOutBroadcastPkts */
+ uint32_t rdrp_u; /* 120 etherStatsDropEvents */
+ uint32_t rdrp_l; /* 124 etherStatsDropEvents */
+ uint32_t reoct_u; /* 128 etherStatsOctets */
+ uint32_t reoct_l; /* 12c etherStatsOctets */
+ uint32_t rpkt_u; /* 130 etherStatsPkts */
+ uint32_t rpkt_l; /* 134 etherStatsPkts */
+ uint32_t trund_u; /* 138 etherStatsUndersizePkts */
+ uint32_t trund_l; /* 13c etherStatsUndersizePkts */
+ uint32_t r64_u; /* 140 etherStatsPkts64Octets */
+ uint32_t r64_l; /* 144 etherStatsPkts64Octets */
+ uint32_t r127_u; /* 148 etherStatsPkts65to127Octets */
+ uint32_t r127_l; /* 14c etherStatsPkts65to127Octets */
+ uint32_t r255_u; /* 150 etherStatsPkts128to255Octets */
+ uint32_t r255_l; /* 154 etherStatsPkts128to255Octets */
+ uint32_t r511_u; /* 158 etherStatsPkts256to511Octets */
+ uint32_t r511_l; /* 15c etherStatsPkts256to511Octets */
+ uint32_t r1023_u; /* 160 etherStatsPkts512to1023Octets */
+ uint32_t r1023_l; /* 164 etherStatsPkts512to1023Octets */
+ uint32_t r1518_u; /* 168 etherStatsPkts1024to1518Octets */
+ uint32_t r1518_l; /* 16c etherStatsPkts1024to1518Octets */
+ uint32_t r1519x_u; /* 170 etherStatsPkts1519toX */
+ uint32_t r1519x_l; /* 174 etherStatsPkts1519toX */
+ uint32_t trovr_u; /* 178 etherStatsOversizePkts */
+ uint32_t trovr_l; /* 17c etherStatsOversizePkts */
+ uint32_t trjbr_u; /* 180 etherStatsJabbers */
+ uint32_t trjbr_l; /* 184 etherStatsJabbers */
+ uint32_t trfrg_u; /* 188 etherStatsFragments */
+ uint32_t trfrg_l; /* 18C etherStatsFragments */
+ uint32_t rerr_u; /* 190 ifInErrors */
+ uint32_t rerr_l; /* 194 ifInErrors */
+};
+
+/**
+ * struct tgec_cfg - TGEC configuration
+ *
+ * @rx_error_discard: Receive Erroneous Frame Discard Enable. When set to 1
+ * any frame received with an error is discarded in the
+ * Core and not forwarded to the Client interface.
+ * When set to 0 (Reset value), erroneous Frames are
+ * forwarded to the Client interface with ff_rx_err
+ * asserted.
+ * @pause_ignore: Ignore Pause Frame Quanta. If set to 1 received pause
+ * frames are ignored by the MAC. When set to 0
+ * (Reset value) the transmit process is stopped for the
+ * amount of time specified in the pause quanta received
+ * within a pause frame.
+ * @pause_forward_enable:
+ * Terminate / Forward Pause Frames. If set to 1 pause
+ * frames are forwarded to the user application. When set
+ * to 0 (Reset value) pause frames are terminated and
+ * discarded within the MAC.
+ * @no_length_check_enable:
+ * Payload Length Check Disable. When set to 0
+ * (Reset value), the Core checks the frame's payload
+ * length with the Frame Length/Type field, when set to 1
+ * the payload length check is disabled.
+ * @cmd_frame_enable: Enables reception of all command frames. When set to 1
+ * all Command Frames are accepted, when set to 0
+ * (Reset Value) only Pause Frames are accepted and all
+ * other Command Frames are rejected.
+ * @send_idle_enable: Force Idle Generation. When set to 1, the MAC
+ * permanently sends XGMII Idle sequences even when faults
+ * are received.
+ * @wan_mode_enable: WAN Mode Enable. Sets WAN mode (1) or LAN mode
+ * (0, default) of operation.
+ * @promiscuous_mode_enable:
+ * Enables MAC promiscuous operation. When set to 1, all
+ * frames are received without any MAC address filtering,
+ * when set to 0 (Reset value) Unicast Frames with a
+ * destination address not matching the Core MAC Address
+ * (MAC Address programmed in Registers MAC_ADDR_0 and
+ * MAC_ADDR_1 or the MAC address programmed in Registers
+ * MAC_ADDR_2 and MAC_ADDR_3) are rejected.
+ * @tx_addr_ins_enable: Set Source MAC Address on Transmit. If set to 1 the
+ * MAC overwrites the source MAC address received from the
+ * Client Interface with one of the MAC addresses. If set
+ * to 0 (Reset value), the source MAC address from the
+ * Client Interface is transmitted unmodified to the line.
+ * @loopback_enable: PHY Interface Loopback. When set to 1, the signal
+ * loop_ena is set to '1', when set to 0 (Reset value)
+ * the signal loop_ena is set to 0.
+ * @lgth_check_nostdr: The Core interprets the Length/Type field differently
+ * depending on the value of this Bit
+ * @time_stamp_enable: This bit selects between enabling and disabling the
+ * IEEE 1588 functionality. 1: IEEE 1588 is enabled
+ * 0: IEEE 1588 is disabled
+ * @max_frame_length: Maximum supported received frame length.
+ * The 10GEC MAC supports reception of any frame size up
+ * to 16,352 bytes (0x3FE0). Typical settings are
+ * 0x05EE (1,518 bytes) for standard frames.
+ * Default setting is 0x0600 (1,536 bytes).
+ * Received frames that exceed this stated maximum
+ * are truncated.
+ * @pause_quant: Pause quanta value used with transmitted pause frames.
+ * Each quanta represents a 512 bit-times.
+ * @tx_ipg_length: Transmit Inter-Packet-Gap (IPG) value. A 6-bit value:
+ * Depending on LAN or WAN mode of operation the value has
+ * the following meaning: - LAN Mode: Number of octets in
+ * steps of 4. Valid values are 8, 12, 16, ... 100. DIC is
+ * fully supported (see 10.6.1 page 49) for any setting. A
+ * default of 12 (reset value) must be set to conform to
+ * IEEE802.3ae. Warning: When set to 8, PCS layers may not
+ * be able to perform clock rate compensation. - WAN Mode:
+ * Stretch factor. Valid values are 4..15. The stretch
+ * factor is calculated as (value+1)*8. A default of 12
+ * (reset value) must be set to conform to IEEE 802.3ae
+ * (i.e. 13*8=104). A larger value shrinks the IPG
+ * (increasing bandwidth).
+ *
+ * This structure contains basic TGEC configuration and must be passed to
+ * fman_tgec_init() function. A default set of configuration values can be
+ * obtained by calling fman_tgec_defconfig().
+ */
+struct tgec_cfg {
+ bool rx_error_discard;
+ bool pause_ignore;
+ bool pause_forward_enable;
+ bool no_length_check_enable;
+ bool cmd_frame_enable;
+ bool send_idle_enable;
+ bool wan_mode_enable;
+ bool promiscuous_mode_enable;
+ bool tx_addr_ins_enable;
+ bool loopback_enable;
+ bool lgth_check_nostdr;
+ bool time_stamp_enable;
+ uint16_t max_frame_length;
+ uint16_t pause_quant;
+ uint32_t tx_ipg_length;
+ bool skip_fman11_workaround;
+};
+
+
+void fman_tgec_defconfig(struct tgec_cfg *cfg);
+
+/**
+ * fman_tgec_init() - Init tgec hardware block
+ * @regs: Pointer to tgec register block
+ * @cfg: tgec configuration data
+ * @exceptions_mask: initial exceptions mask
+ *
+ * This function initializes the tgec controller and applies its
+ * basic configuration.
+ *
+ * Returns: 0 if successful, an error code otherwise.
+ */
+
+int fman_tgec_init(struct tgec_regs *regs, struct tgec_cfg *cfg,
+ uint32_t exception_mask);
+
+void fman_tgec_enable(struct tgec_regs *regs, bool apply_rx, bool apply_tx);
+
+void fman_tgec_disable(struct tgec_regs *regs, bool apply_rx, bool apply_tx);
+
+uint32_t fman_tgec_get_revision(struct tgec_regs *regs);
+
+void fman_tgec_set_mac_address(struct tgec_regs *regs, uint8_t *macaddr);
+
+void fman_tgec_set_promiscuous(struct tgec_regs *regs, bool val);
+
+/**
+ * fman_tgec_reset_stat() - Completely resets all TGEC HW counters
+ * @regs: Pointer to TGEC register block
+ */
+void fman_tgec_reset_stat(struct tgec_regs *regs);
+
+/**
+ * fman_tgec_get_counter() - Reads TGEC HW counters
+ * @regs: Pointer to TGEC register block
+ * @reg_name: Counter name according to the appropriate enum
+ *
+ * Returns: Required counter value
+ */
+uint64_t fman_tgec_get_counter(struct tgec_regs *regs,
+ enum tgec_counters reg_name);
+
+/**
+ * fman_tgec_set_hash_table() - Sets the Hashtable Control Register
+ * @regs: Pointer to TGEC register block
+ * @value: Value to be written in Hashtable Control Register
+ */
+void fman_tgec_set_hash_table(struct tgec_regs *regs, uint32_t value);
+
+/**
+ * fman_tgec_set_tx_pause_frames() - Sets the Pause Quanta Register
+ * @regs: Pointer to TGEC register block
+ * @pause_time: Pause quanta value used with transmitted pause frames.
+ * Each quanta represents a 512 bit-times
+ */
+void fman_tgec_set_tx_pause_frames(struct tgec_regs *regs, uint16_t pause_time);
+
+/**
+ * fman_tgec_set_rx_ignore_pause_frames() - Changes the policy WRT pause frames
+ * @regs: Pointer to TGEC register block
+ * @en: Ignore/Respond to pause frame quanta
+ *
+ * Sets the value of PAUSE_IGNORE field in the COMMAND_CONFIG Register
+ * 0 - MAC stops transmit process for the duration specified
+ * in the Pause frame quanta of a received Pause frame.
+ * 1 - MAC ignores received Pause frames.
+ */
+void fman_tgec_set_rx_ignore_pause_frames(struct tgec_regs *regs, bool en);
+
+/**
+ * fman_tgec_enable_1588_time_stamp() - change timestamp functionality
+ * @regs: Pointer to TGEC register block
+ * @en: enable/disable timestamp functionality
+ *
+ * Sets the value of EN_TIMESTAMP field in the COMMAND_CONFIG Register
+ * IEEE 1588 timestamp functionality control:
+ * 0 disabled, 1 enabled
+ */
+
+void fman_tgec_enable_1588_time_stamp(struct tgec_regs *regs, bool en);
+
+uint32_t fman_tgec_get_event(struct tgec_regs *regs, uint32_t ev_mask);
+
+void fman_tgec_ack_event(struct tgec_regs *regs, uint32_t ev_mask);
+
+uint32_t fman_tgec_get_interrupt_mask(struct tgec_regs *regs);
+
+/**
+ * fman_tgec_add_addr_in_paddr() - Sets additional exact match MAC address
+ * @regs: Pointer to TGEC register block
+ * @addr_ptr: Pointer to 6-byte array containing the MAC address
+ *
+ * Sets the additional station MAC address
+ */
+void fman_tgec_add_addr_in_paddr(struct tgec_regs *regs, uint8_t *addr_ptr);
+
+void fman_tgec_clear_addr_in_paddr(struct tgec_regs *regs);
+
+void fman_tgec_enable_interrupt(struct tgec_regs *regs, uint32_t ev_mask);
+
+void fman_tgec_disable_interrupt(struct tgec_regs *regs, uint32_t ev_mask);
+
+void fman_tgec_reset_filter_table(struct tgec_regs *regs);
+
+void fman_tgec_set_hash_table_entry(struct tgec_regs *regs, uint32_t crc);
+
+
+/**
+ * fman_tgec_get_max_frame_len() - Returns the maximum frame length value
+ * @regs: Pointer to TGEC register block
+ */
+uint16_t fman_tgec_get_max_frame_len(struct tgec_regs *regs);
+
+/**
+ * fman_tgec_set_erratum_tx_fifo_corruption_10gmac_a007() - Initialize the
+ * main tgec configuration parameters
+ * @regs: Pointer to TGEC register block
+ *
+ * TODO
+ */
+void fman_tgec_set_erratum_tx_fifo_corruption_10gmac_a007(struct tgec_regs
+ *regs);
+
+
+#endif /* __FSL_FMAN_TGEC_H */
diff --git a/sys/contrib/ncsw/inc/integrations/dpaa_integration_ext.h b/sys/contrib/ncsw/inc/integrations/dpaa_integration_ext.h
index 88443fa86316..27bb5d402378 100644
--- a/sys/contrib/ncsw/inc/integrations/dpaa_integration_ext.h
+++ b/sys/contrib/ncsw/inc/integrations/dpaa_integration_ext.h
@@ -177,7 +177,7 @@ typedef enum
/* RAMs defines */
#define FM_MURAM_SIZE (160 * KILOBYTE)
-#define FM_IRAM_SIZE ( 64 * KILOBYTE)
+#define FM_IRAM_SIZE(a,b) ( 64 * KILOBYTE)
/* PCD defines */
#define FM_PCD_PLCR_NUM_ENTRIES 256 /**< Total number of policer profiles */
@@ -208,113 +208,6 @@ typedef enum
#define PORT_MAX_WEIGHT 16
-/**************************************************************************//**
- @Description Enum for inter-module interrupts registration
-*//***************************************************************************/
-typedef enum e_FmEventModules
-{
- e_FM_MOD_PRS, /**< Parser event */
- e_FM_MOD_KG, /**< Keygen event */
- e_FM_MOD_PLCR, /**< Policer event */
- e_FM_MOD_10G_MAC, /**< 10G MAC error event */
- e_FM_MOD_1G_MAC, /**< 1G MAC error event */
- e_FM_MOD_TMR, /**< Timer event */
- e_FM_MOD_1G_MAC_TMR, /**< 1G MAC timer event */
- e_FM_MOD_FMAN_CTRL, /**< FMAN Controller timer event */
- e_FM_MOD_DUMMY_LAST
-} e_FmEventModules;
-
-/**************************************************************************//**
- @Description Enum for interrupts types
-*//***************************************************************************/
-typedef enum e_FmIntrType
-{
- e_FM_INTR_TYPE_ERR,
- e_FM_INTR_TYPE_NORMAL
-} e_FmIntrType;
-
-/**************************************************************************//**
- @Description Enum for inter-module interrupts registration
-*//***************************************************************************/
-typedef enum e_FmInterModuleEvent
-{
- e_FM_EV_PRS, /**< Parser event */
- e_FM_EV_ERR_PRS, /**< Parser error event */
- e_FM_EV_KG, /**< Keygen event */
- e_FM_EV_ERR_KG, /**< Keygen error event */
- e_FM_EV_PLCR, /**< Policer event */
- e_FM_EV_ERR_PLCR, /**< Policer error event */
- e_FM_EV_ERR_10G_MAC0, /**< 10G MAC 0 error event */
- e_FM_EV_ERR_1G_MAC0, /**< 1G MAC 0 error event */
- e_FM_EV_ERR_1G_MAC1, /**< 1G MAC 1 error event */
- e_FM_EV_ERR_1G_MAC2, /**< 1G MAC 2 error event */
- e_FM_EV_ERR_1G_MAC3, /**< 1G MAC 3 error event */
- e_FM_EV_ERR_1G_MAC4, /**< 1G MAC 4 error event */
- e_FM_EV_TMR, /**< Timer event */
- e_FM_EV_1G_MAC0_TMR, /**< 1G MAC 0 timer event */
- e_FM_EV_1G_MAC1_TMR, /**< 1G MAC 1 timer event */
- e_FM_EV_1G_MAC2_TMR, /**< 1G MAC 2 timer event */
- e_FM_EV_1G_MAC3_TMR, /**< 1G MAC 3 timer event */
- e_FM_EV_1G_MAC4_TMR, /**< 1G MAC 4 timer event */
- e_FM_EV_FMAN_CTRL_0, /**< Fman controller event 0 */
- e_FM_EV_FMAN_CTRL_1, /**< Fman controller event 1 */
- e_FM_EV_FMAN_CTRL_2, /**< Fman controller event 2 */
- e_FM_EV_FMAN_CTRL_3, /**< Fman controller event 3 */
- e_FM_EV_DUMMY_LAST
-} e_FmInterModuleEvent;
-
-#define GET_FM_MODULE_EVENT(mod, id, intrType, event) \
- switch(mod){ \
- case e_FM_MOD_PRS: \
- if (id) event = e_FM_EV_DUMMY_LAST; \
- else event = (intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_ERR_PRS : e_FM_EV_PRS; \
- break; \
- case e_FM_MOD_KG: \
- if (id) event = e_FM_EV_DUMMY_LAST; \
- else event = (intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_ERR_KG : e_FM_EV_DUMMY_LAST; \
- break; \
- case e_FM_MOD_PLCR: \
- if (id) event = e_FM_EV_DUMMY_LAST; \
- else event = (intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_ERR_PLCR : e_FM_EV_PLCR; \
- break; \
- case e_FM_MOD_10G_MAC: \
- if (id) event = e_FM_EV_DUMMY_LAST; \
- else event = (intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_ERR_10G_MAC0 : e_FM_EV_DUMMY_LAST; \
- break; \
- case e_FM_MOD_1G_MAC: \
- switch(id){ \
- case(0): event = (intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_ERR_1G_MAC0 : e_FM_EV_DUMMY_LAST; break; \
- case(1): event = (intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_ERR_1G_MAC1 : e_FM_EV_DUMMY_LAST; break; \
- case(2): event = (intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_ERR_1G_MAC2 : e_FM_EV_DUMMY_LAST; break; \
- case(3): event = (intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_ERR_1G_MAC3 : e_FM_EV_DUMMY_LAST; break; \
- case(4): event = (intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_ERR_1G_MAC4 : e_FM_EV_DUMMY_LAST; break; \
- } \
- break; \
- case e_FM_MOD_TMR: \
- if (id) event = e_FM_EV_DUMMY_LAST; \
- else event = (intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_DUMMY_LAST : e_FM_EV_TMR; \
- break; \
- case e_FM_MOD_1G_MAC_TMR: \
- switch(id){ \
- case(0): event = (intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_DUMMY_LAST : e_FM_EV_1G_MAC0_TMR; break; \
- case(1): event = (intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_DUMMY_LAST : e_FM_EV_1G_MAC1_TMR; break; \
- case(2): event = (intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_DUMMY_LAST : e_FM_EV_1G_MAC2_TMR; break; \
- case(3): event = (intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_DUMMY_LAST : e_FM_EV_1G_MAC3_TMR; break; \
- case(4): event = (intrType == e_FM_INTR_TYPE_ERR) ? e_FM_EV_DUMMY_LAST : e_FM_EV_1G_MAC4_TMR; break; \
- } \
- break; \
- case e_FM_MOD_FMAN_CTRL: \
- if (intrType == e_FM_INTR_TYPE_ERR) event = e_FM_EV_DUMMY_LAST; \
- else switch(id){ \
- case(0): event = e_FM_EV_FMAN_CTRL_0; break; \
- case(1): event = e_FM_EV_FMAN_CTRL_1; break; \
- case(2): event = e_FM_EV_FMAN_CTRL_2; break; \
- case(3): event = e_FM_EV_FMAN_CTRL_3; break; \
- } \
- break; \
- default: event = e_FM_EV_DUMMY_LAST; \
- break;}
-
#define FM_CHECK_PORT_RESTRICTIONS(__validPorts, __newPortIndx) TRUE
/* P5020 unique features */
@@ -374,5 +267,9 @@ typedef enum e_FmInterModuleEvent
#define FM_PRS_MEM_ERRATA_FMAN_SW003
#define FM_LEN_CHECK_ERRATA_FMAN_SW002
+#define DPAA_VERSION 10
+#define FM_PCD_SW_PRS_SIZE 0x00000800
+#define FM_PCD_PRS_SW_PATCHES_SIZE 0x00000200
+#define FM_NUM_OF_CTRL 2
#endif /* __DPAA_INTEGRATION_EXT_H */
diff --git a/sys/contrib/ncsw/inc/integrations/part_ext.h b/sys/contrib/ncsw/inc/integrations/part_ext.h
index 8052c43129a5..0fa702993892 100644
--- a/sys/contrib/ncsw/inc/integrations/part_ext.h
+++ b/sys/contrib/ncsw/inc/integrations/part_ext.h
@@ -44,21 +44,8 @@
#include "enet_ext.h"
#include "dpaa_integration_ext.h"
-#define CORE_E500MC
-
-/*****************************************************************************
- INTEGRATION-SPECIFIC MODULE CODES
-******************************************************************************/
-#define MODULE_MEM 0x00010000
-#define MODULE_MM 0x00020000
-#define MODULE_QM 0x000d0000
-#define MODULE_BM 0x000e0000
-#define MODULE_FM 0x00130000
-#define MODULE_FM_MURAM 0x00140000
-#define MODULE_FM_PCD 0x00150000
-#define MODULE_FM_RTC 0x00160000
-#define MODULE_FM_MAC 0x00170000
-#define MODULE_FM_PORT 0x00180000
+#define CORE_E500MC
+#define INTG_MAX_NUM_OF_CORES 24
/**************************************************************************//*
@Description Part data structure - must be contained in any integration
diff --git a/sys/contrib/ncsw/inc/math_ext.h b/sys/contrib/ncsw/inc/math_ext.h
deleted file mode 100644
index 95b9560d8d60..000000000000
--- a/sys/contrib/ncsw/inc/math_ext.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Freescale Semiconductor nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- *
- * ALTERNATIVELY, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") as published by the Free Software
- * Foundation, either version 2 of that License or (at your option) any
- * later version.
- *
- * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MATH_EXT_H
-#define __MATH_EXT_H
-
-
-#if defined(NCSW_LINUX) && defined(__KERNEL__)
-#include <linux/math.h>
-
-#elif defined(__MWERKS__)
-#define LOW(x) ( sizeof(x)==8 ? *(1+(int32_t*)&x) : (*(int32_t*)&x))
-#define HIGH(x) (*(int32_t*)&x)
-#define ULOW(x) ( sizeof(x)==8 ? *(1+(uint32_t*)&x) : (*(uint32_t*)&x))
-#define UHIGH(x) (*(uint32_t*)&x)
-
-static const double big = 1.0e300;
-
-/* Macro for checking if a number is a power of 2 */
-static __inline__ double ceil(double x)
-{
- int32_t i0,i1,j0; /*- cc 020130 -*/
- uint32_t i,j; /*- cc 020130 -*/
- i0 = HIGH(x);
- i1 = LOW(x);
- j0 = ((i0>>20)&0x7ff)-0x3ff;
- if(j0<20) {
- if(j0<0) { /* raise inexact if x != 0 */
- if(big+x>0.0) {/* return 0*sign(x) if |x|<1 */
- if(i0<0) {i0=0x80000000;i1=0;}
- else if((i0|i1)!=0) { i0=0x3ff00000;i1=0;}
- }
- } else {
- i = (uint32_t)(0x000fffff)>>j0;
- if(((i0&i)|i1)==0) return x; /* x is integral */
- if(big+x>0.0) { /* raise inexact flag */
- if(i0>0) i0 += (0x00100000)>>j0;
- i0 &= (~i); i1=0;
- }
- }
- } else if (j0>51) {
- if(j0==0x400) return x+x; /* inf or NaN */
- else return x; /* x is integral */
- } else {
- i = ((uint32_t)(0xffffffff))>>(j0-20); /*- cc 020130 -*/
- if((i1&i)==0) return x; /* x is integral */
- if(big+x>0.0) { /* raise inexact flag */
- if(i0>0) {
- if(j0==20) i0+=1;
- else {
- j = (uint32_t)(i1 + (1<<(52-j0)));
- if(j<i1) i0+=1; /* got a carry */
- i1 = (int32_t)j;
- }
- }
- i1 &= (~i);
- }
- }
- HIGH(x) = i0;
- LOW(x) = i1;
- return x;
-}
-
-#else
-#include <math.h>
-#endif /* defined(NCSW_LINUX) && defined(__KERNEL__) */
-
-
-#endif /* __MATH_EXT_H */
diff --git a/sys/contrib/ncsw/inc/ncsw_ext.h b/sys/contrib/ncsw/inc/ncsw_ext.h
index e9f059dff496..ec7aca01fda4 100644
--- a/sys/contrib/ncsw/inc/ncsw_ext.h
+++ b/sys/contrib/ncsw/inc/ncsw_ext.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
+/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,7 +30,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
- /**************************************************************************//**
+
+/**************************************************************************//**
@File ncsw_ext.h
@Description General NetCommSw Standard Definitions
@@ -39,11 +40,11 @@
#ifndef __NCSW_EXT_H
#define __NCSW_EXT_H
-#include "memcpy_ext.h"
+#include "memcpy_ext.h"
-#define WRITE_BLOCK IOMemSet32
-#define COPY_BLOCK Mem2IOCpy32
+#define WRITE_BLOCK IOMemSet32 /* include memcpy_ext.h */
+#define COPY_BLOCK Mem2IOCpy32 /* include memcpy_ext.h */
#define PTR_TO_UINT(_ptr) ((uintptr_t)(_ptr))
#define UINT_TO_PTR(_val) ((void*)(uintptr_t)(_val))
@@ -51,8 +52,10 @@
#define PTR_MOVE(_ptr, _offset) (void*)((uint8_t*)(_ptr) + (_offset))
-#define WRITE_UINT8_UINT24(arg, data08, data24) WRITE_UINT32(arg,((uint32_t)(data08)<<24)|((uint32_t)(data24)&0x00FFFFFF))
-#define WRITE_UINT24_UINT8(arg, data24, data08) WRITE_UINT32(arg,((uint32_t)(data24)<< 8)|((uint32_t)(data08)&0x000000FF))
+#define WRITE_UINT8_UINT24(arg, data08, data24) \
+ WRITE_UINT32(arg,((uint32_t)(data08)<<24)|((uint32_t)(data24)&0x00FFFFFF))
+#define WRITE_UINT24_UINT8(arg, data24, data08) \
+ WRITE_UINT32(arg,((uint32_t)(data24)<< 8)|((uint32_t)(data08)&0x000000FF))
/* Little-Endian access macros */
@@ -93,14 +96,16 @@
/* Miscellaneous macros */
/*----------------------*/
-#define UNUSED(X) (X=X)
+#define UNUSED(_x) ((void)(_x))
#define KILOBYTE 0x400UL /* 1024 */
#define MEGABYTE (KILOBYTE * KILOBYTE) /* 1024*1024 */
-#define GIGABYTE (KILOBYTE * MEGABYTE) /* 1024*1024*1024 */
+#define GIGABYTE ((uint64_t)(KILOBYTE * MEGABYTE)) /* 1024*1024*1024 */
+#define TERABYTE ((uint64_t)(KILOBYTE * GIGABYTE)) /* 1024*1024*1024*1024 */
-#undef NO_IRQ
-#define NO_IRQ (-1)
+#ifndef NO_IRQ
+#define NO_IRQ (0)
+#endif
#define NCSW_MASTER_ID (0)
/* Macro for checking if a number is a power of 2 */
@@ -137,7 +142,7 @@ do \
} while (0)
/* Ceiling division - not the fastest way, but safer in terms of overflow */
-#define DIV_CEIL(x,y) (((x)/(y)) + ((((((x)/(y)))*(y)) == (x)) ? 0 : 1))
+#define DIV_CEIL(x,y) (((x)/(y)) + (((((x)/(y))*(y)) == (x)) ? 0 : 1))
/* Round up a number to be a multiple of a second number */
#define ROUND_UP(x,y) ((((x) + (y) - 1) / (y)) * (y))
@@ -157,8 +162,6 @@ do \
#define CYCLES_TO_PSEC(cycles,clk) (((cycles) * 1000000) / (clk))
/* Min, Max macros */
-#define NCSW_MIN(a,b) ((a) < (b) ? (a) : (b))
-#define NCSW_MAX(a,b) ((a) > (b) ? (a) : (b))
#define IN_RANGE(min,val,max) ((min)<=(val) && (val)<=(max))
#define ABS(a) ((a<0)?(a*-1):a)
diff --git a/sys/contrib/ncsw/inc/net_ext.h b/sys/contrib/ncsw/inc/net_ext.h
index c41b7c940f3b..8f3bc369247e 100644
--- a/sys/contrib/ncsw/inc/net_ext.h
+++ b/sys/contrib/ncsw/inc/net_ext.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File net_ext.h
@@ -82,6 +83,16 @@ typedef uint8_t headerFieldEth_t;
#define NET_HEADER_FIELD_ETH_PADDING (NET_HEADER_FIELD_ETH_DA << 5)
#define NET_HEADER_FIELD_ETH_ALL_FIELDS ((NET_HEADER_FIELD_ETH_DA << 6) - 1)
+#define NET_HEADER_FIELD_ETH_ADDR_SIZE 6
+
+typedef uint16_t headerFieldIp_t;
+
+#define NET_HEADER_FIELD_IP_VER (1)
+#define NET_HEADER_FIELD_IP_DSCP (NET_HEADER_FIELD_IP_VER << 2)
+#define NET_HEADER_FIELD_IP_ECN (NET_HEADER_FIELD_IP_VER << 3)
+#define NET_HEADER_FIELD_IP_PROTO (NET_HEADER_FIELD_IP_VER << 4)
+
+#define NET_HEADER_FIELD_IP_PROTO_SIZE 1
typedef uint16_t headerFieldIpv4_t;
@@ -102,6 +113,9 @@ typedef uint16_t headerFieldIpv4_t;
#define NET_HEADER_FIELD_IPv4_OPTS_COUNT (NET_HEADER_FIELD_IPv4_VER << 14)
#define NET_HEADER_FIELD_IPv4_ALL_FIELDS ((NET_HEADER_FIELD_IPv4_VER << 15) - 1)
+#define NET_HEADER_FIELD_IPv4_ADDR_SIZE 4
+#define NET_HEADER_FIELD_IPv4_PROTO_SIZE 1
+
typedef uint8_t headerFieldIpv6_t;
@@ -114,6 +128,9 @@ typedef uint8_t headerFieldIpv6_t;
#define NET_HEADER_FIELD_IPv6_HOP_LIMIT (NET_HEADER_FIELD_IPv6_VER << 6)
#define NET_HEADER_FIELD_IPv6_ALL_FIELDS ((NET_HEADER_FIELD_IPv6_VER << 7) - 1)
+#define NET_HEADER_FIELD_IPv6_ADDR_SIZE 16
+#define NET_HEADER_FIELD_IPv6_NEXT_HDR_SIZE 1
+
#define NET_HEADER_FIELD_ICMP_TYPE (1)
#define NET_HEADER_FIELD_ICMP_CODE (NET_HEADER_FIELD_ICMP_TYPE << 1)
#define NET_HEADER_FIELD_ICMP_CKSUM (NET_HEADER_FIELD_ICMP_TYPE << 2)
@@ -121,6 +138,9 @@ typedef uint8_t headerFieldIpv6_t;
#define NET_HEADER_FIELD_ICMP_SQ_NUM (NET_HEADER_FIELD_ICMP_TYPE << 4)
#define NET_HEADER_FIELD_ICMP_ALL_FIELDS ((NET_HEADER_FIELD_ICMP_TYPE << 5) - 1)
+#define NET_HEADER_FIELD_ICMP_CODE_SIZE 1
+#define NET_HEADER_FIELD_ICMP_TYPE_SIZE 1
+
#define NET_HEADER_FIELD_IGMP_VERSION (1)
#define NET_HEADER_FIELD_IGMP_TYPE (NET_HEADER_FIELD_IGMP_VERSION << 1)
#define NET_HEADER_FIELD_IGMP_CKSUM (NET_HEADER_FIELD_IGMP_VERSION << 2)
@@ -143,6 +163,8 @@ typedef uint16_t headerFieldTcp_t;
#define NET_HEADER_FIELD_TCP_OPTS_COUNT (NET_HEADER_FIELD_TCP_PORT_SRC << 10)
#define NET_HEADER_FIELD_TCP_ALL_FIELDS ((NET_HEADER_FIELD_TCP_PORT_SRC << 11) - 1)
+#define NET_HEADER_FIELD_TCP_PORT_SIZE 2
+
typedef uint8_t headerFieldSctp_t;
@@ -152,6 +174,7 @@ typedef uint8_t headerFieldSctp_t;
#define NET_HEADER_FIELD_SCTP_CKSUM (NET_HEADER_FIELD_SCTP_PORT_SRC << 3)
#define NET_HEADER_FIELD_SCTP_ALL_FIELDS ((NET_HEADER_FIELD_SCTP_PORT_SRC << 4) - 1)
+#define NET_HEADER_FIELD_SCTP_PORT_SIZE 2
typedef uint8_t headerFieldDccp_t;
@@ -159,6 +182,8 @@ typedef uint8_t headerFieldDccp_t;
#define NET_HEADER_FIELD_DCCP_PORT_DST (NET_HEADER_FIELD_DCCP_PORT_SRC << 1)
#define NET_HEADER_FIELD_DCCP_ALL_FIELDS ((NET_HEADER_FIELD_DCCP_PORT_SRC << 2) - 1)
+#define NET_HEADER_FIELD_DCCP_PORT_SIZE 2
+
typedef uint8_t headerFieldUdp_t;
@@ -168,6 +193,16 @@ typedef uint8_t headerFieldUdp_t;
#define NET_HEADER_FIELD_UDP_CKSUM (NET_HEADER_FIELD_UDP_PORT_SRC << 3)
#define NET_HEADER_FIELD_UDP_ALL_FIELDS ((NET_HEADER_FIELD_UDP_PORT_SRC << 4) - 1)
+#define NET_HEADER_FIELD_UDP_PORT_SIZE 2
+
+typedef uint8_t headerFieldUdpLite_t;
+
+#define NET_HEADER_FIELD_UDP_LITE_PORT_SRC (1)
+#define NET_HEADER_FIELD_UDP_LITE_PORT_DST (NET_HEADER_FIELD_UDP_LITE_PORT_SRC << 1)
+#define NET_HEADER_FIELD_UDP_LITE_ALL_FIELDS ((NET_HEADER_FIELD_UDP_LITE_PORT_SRC << 2) - 1)
+
+#define NET_HEADER_FIELD_UDP_LITE_PORT_SIZE 2
+
typedef uint8_t headerFieldUdpEncapEsp_t;
#define NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC (1)
@@ -178,6 +213,9 @@ typedef uint8_t headerFieldUdpEncapEsp_t;
#define NET_HEADER_FIELD_UDP_ENCAP_ESP_SEQUENCE_NUM (NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC << 5)
#define NET_HEADER_FIELD_UDP_ENCAP_ESP_ALL_FIELDS ((NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SRC << 6) - 1)
+#define NET_HEADER_FIELD_UDP_ENCAP_ESP_PORT_SIZE 2
+#define NET_HEADER_FIELD_UDP_ENCAP_ESP_SPI_SIZE 4
+
#define NET_HEADER_FIELD_IPHC_CID (1)
#define NET_HEADER_FIELD_IPHC_CID_TYPE (NET_HEADER_FIELD_IPHC_CID << 1)
#define NET_HEADER_FIELD_IPHC_HCINDEX (NET_HEADER_FIELD_IPHC_CID << 2)
@@ -326,6 +364,8 @@ typedef uint8_t headerFieldIpsecEsp_t;
#define NET_HEADER_FIELD_IPSEC_ESP_SEQUENCE_NUM (NET_HEADER_FIELD_IPSEC_ESP_SPI << 1)
#define NET_HEADER_FIELD_IPSEC_ESP_ALL_FIELDS ((NET_HEADER_FIELD_IPSEC_ESP_SPI << 2) - 1)
+#define NET_HEADER_FIELD_IPSEC_ESP_SPI_SIZE 4
+
typedef uint8_t headerFieldMpls_t;
@@ -346,8 +386,10 @@ typedef enum {
HEADER_TYPE_VLAN,
HEADER_TYPE_IPv4,
HEADER_TYPE_IPv6,
+ HEADER_TYPE_IP,
HEADER_TYPE_TCP,
HEADER_TYPE_UDP,
+ HEADER_TYPE_UDP_LITE,
HEADER_TYPE_IPHC,
HEADER_TYPE_SCTP,
HEADER_TYPE_SCTP_CHUNK_DATA,
diff --git a/sys/contrib/ncsw/inc/std_ext.h b/sys/contrib/ncsw/inc/std_ext.h
index 4d2ba4434b51..d91e6fddf507 100644
--- a/sys/contrib/ncsw/inc/std_ext.h
+++ b/sys/contrib/ncsw/inc/std_ext.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
+/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,8 +30,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
- /**************************************************************************//**
+/**************************************************************************//**
@File std_ext.h
@Description General Standard Definitions
diff --git a/sys/contrib/ncsw/inc/stdarg_ext.h b/sys/contrib/ncsw/inc/stdarg_ext.h
index 39e46ef276a9..7379a4e5ed52 100644
--- a/sys/contrib/ncsw/inc/stdarg_ext.h
+++ b/sys/contrib/ncsw/inc/stdarg_ext.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/sys/contrib/ncsw/inc/stdlib_ext.h b/sys/contrib/ncsw/inc/stdlib_ext.h
index 16f2a2a715ac..bc89030f13ec 100644
--- a/sys/contrib/ncsw/inc/stdlib_ext.h
+++ b/sys/contrib/ncsw/inc/stdlib_ext.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/sys/contrib/ncsw/inc/string_ext.h b/sys/contrib/ncsw/inc/string_ext.h
index 32c64572ce57..e2d413067277 100644
--- a/sys/contrib/ncsw/inc/string_ext.h
+++ b/sys/contrib/ncsw/inc/string_ext.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
- * All rights reserved.
+/*
+ * Copyright 2008-2012 Freescale Semiconductor Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/sys/contrib/ncsw/inc/types_ext.h b/sys/contrib/ncsw/inc/types_ext.h
index 03b6db4b7799..da524cc882be 100644
--- a/sys/contrib/ncsw/inc/types_ext.h
+++ b/sys/contrib/ncsw/inc/types_ext.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
+/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,7 +30,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
- /**************************************************************************//**
+
+/**************************************************************************//**
@File types_ext.h
@Description General types Standard Definitions
@@ -39,76 +40,26 @@
#ifndef __TYPES_EXT_H
#define __TYPES_EXT_H
-
#if defined(NCSW_LINUX)
#include "types_linux.h"
-#elif defined(NCSW_LINUX_USD)
-#include "types_linux_usd.h"
-
#elif defined(NCSW_VXWORKS)
#include "types_vxworks.h"
-#elif defined(__MWERKS__) && defined(__GNUC__) && defined(__cplusplus)
+#elif defined(__GNUC__) && defined(__cplusplus)
#include "types_bb_gpp.h"
-#elif defined(__MWERKS__) && defined(__GNUC__)
+#elif defined(__FreeBSD__)
+#include "types_freebsd.h"
+
+#elif defined(__GNUC__)
#include "types_bb_gcc.h"
#elif defined(__ghs__)
#include "types_ghs.h"
-#elif defined(NCSW_FREEBSD)
-#include "types_freebsd.h"
-
#else
#include "types_dflt.h"
#endif /* defined (__ROCOO__) */
-
-static __inline__ void TypesChecker(void)
-{
-#if defined(__MWERKS__) && !defined(__GNUC__)
-#pragma pack(push,1)
-#endif /* defined(__MWERKS__) && ... */
-#define MEM_MAP_START
- _Packed struct strct {
- __volatile__ int vi;
- } _PackedType;
-#define MEM_MAP_END
-#if defined(__MWERKS__) && !defined(__GNUC__)
-#pragma pack(pop)
-#endif /* defined(__MWERKS__) && ... */
- size_t size = 0;
- bool tr = TRUE, fls = FALSE;
- struct strct *p_Strct = NULL;
- physAddress_t addr = 0x100;
-
- tr = fls;
- p_Strct = p_Strct;
- size++;
- if (tr) size++;
-
- WRITE_UINT8(*((uint8_t*)((size_t)(addr))),
- GET_UINT8(*((uint8_t*)((size_t)(addr)))));
-
- WRITE_UINT8(*((uint8_t*)((size_t)(UINT8_MAX))),
- GET_UINT8(*((uint8_t*)((size_t)(UINT8_MAX)))));
- WRITE_UINT16(*((uint16_t*)((size_t)(UINT16_MAX))),
- GET_UINT16(*((uint16_t*)((size_t)(UINT16_MAX)))));
- WRITE_UINT32(*((uint32_t*)((size_t)(UINT32_MAX))),
- GET_UINT32(*((uint32_t*)((size_t)(UINT32_MAX)))));
- WRITE_UINT64(*((uint64_t*)((size_t)(UINT64_MAX))),
- GET_UINT64(*((uint64_t*)((size_t)(UINT64_MAX)))));
- WRITE_UINT8(*((uint8_t*)((size_t)(INT8_MAX))),
- GET_UINT8(*((uint8_t*)((size_t)(INT8_MIN)))));
- WRITE_UINT16(*((uint16_t*)((size_t)(INT16_MAX))),
- GET_UINT16(*((uint16_t*)((size_t)(INT16_MIN)))));
- WRITE_UINT32(*((uint32_t*)((size_t)(INT32_MAX))),
- GET_UINT32(*((uint32_t*)((size_t)(INT32_MIN)))));
- WRITE_UINT64(*((uint64_t*)((size_t)(INT64_MAX))),
- GET_UINT64(*((uint64_t*)((size_t)(INT64_MIN)))));
-}
-
-
#endif /* __TYPES_EXT_H */
diff --git a/sys/contrib/ncsw/inc/xx_common.h b/sys/contrib/ncsw/inc/xx_common.h
new file mode 100644
index 000000000000..8247b9921678
--- /dev/null
+++ b/sys/contrib/ncsw/inc/xx_common.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/**************************************************************************//**
+ @File debug_ext.h
+
+ @Description Debug mode definitions.
+*//***************************************************************************/
+
+#ifndef __XX_COMMON_H
+#define __XX_COMMON_H
+
+/*****************************************************************************
+ * UNIFIED MODULE CODES
+ *****************************************************************************/
+#define MODULE_UNKNOWN 0x00000000
+#define MODULE_FM 0x00010000
+#define MODULE_FM_MURAM 0x00020000
+#define MODULE_FM_PCD 0x00030000
+#define MODULE_FM_RTC 0x00040000
+#define MODULE_FM_MAC 0x00050000
+#define MODULE_FM_PORT 0x00060000
+#define MODULE_MM 0x00070000
+#define MODULE_FM_SP 0x00080000
+#define MODULE_FM_MACSEC 0x00090000
+#define MODULE_QM 0x000a0000
+#define MODULE_BM 0x000b0000
+#endif /* __XX_COMMON_H */
diff --git a/sys/contrib/ncsw/inc/xx_ext.h b/sys/contrib/ncsw/inc/xx_ext.h
index f011b58b65a2..32e0c39d3634 100644
--- a/sys/contrib/ncsw/inc/xx_ext.h
+++ b/sys/contrib/ncsw/inc/xx_ext.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
+/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,6 +30,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**************************************************************************//**
@File xx_ext.h
@@ -41,11 +42,9 @@
#define __XX_EXT_H
#include "std_ext.h"
+#include "xx_common.h"
#include "part_ext.h"
-#if defined(__MWERKS__) && defined(OPTIMIZED_FOR_SPEED)
-#include "xx_integration_ext.h"
-#endif /* defined(__MWERKS__) && defined(OPTIMIZED_FOR_SPEED) */
/**************************************************************************//**
@@ -57,26 +56,6 @@
@{
*//***************************************************************************/
-#if (defined(REPORT_EVENTS) && (REPORT_EVENTS > 0))
-/**************************************************************************//**
- @Function XX_EventById
-
- @Description Event reporting routine - executed only when REPORT_EVENTS=1.
-
- @Param[in] event - Event code (e_Event).
- @Param[in] appId - Application identifier.
- @Param[in] flags - Event flags.
- @Param[in] msg - Event message.
-
- @Return None
-*//***************************************************************************/
-void XX_EventById(uint32_t event, t_Handle appId, uint16_t flags, char *msg);
-
-#else /* not REPORT_EVENTS */
-#define XX_EventById(event, appId, flags, msg)
-#endif /* REPORT_EVENTS */
-
-
#ifdef DEBUG_XX_MALLOC
void * XX_MallocDebug(uint32_t size, char *fname, int line);
@@ -105,15 +84,6 @@ void * XX_MallocSmartDebug(uint32_t size,
void * XX_Malloc(uint32_t size);
/**************************************************************************//**
- @Function XX_MallocSmartInit
-
- @Description Initializes SmartMalloc allocator.
-
- @Return E_OK on success, error code otherwise.
-*//***************************************************************************/
-int XX_MallocSmartInit(void);
-
-/**************************************************************************//**
@Function XX_MallocSmart
@Description Allocates contiguous block of memory in a specified
@@ -127,6 +97,8 @@ int XX_MallocSmartInit(void);
@Return The address of the newly allocated block on success, NULL on failure.
*//***************************************************************************/
void * XX_MallocSmart(uint32_t size, int memPartitionId, uint32_t alignment);
+
+int XX_MallocSmartInit(void);
#endif /* not DEBUG_XX_MALLOC */
/**************************************************************************//**
@@ -152,21 +124,6 @@ void XX_FreeSmart(void *p_Memory);
*//***************************************************************************/
void XX_Free(void *p_Memory);
-#ifndef NCSW_LINUX
-/**************************************************************************//**
- @Function XX_GetMemPartitionBase
-
- @Description This routine gets the address of a memory segment according to
- the memory type.
-
- @Param[in] memPartitionId - Memory partition ID; The value zero must
- be mapped to the default heap partition.
-
- @Return The address of the required memory type.
-*//***************************************************************************/
-void * XX_GetMemPartitionBase(int memPartitionId);
-#endif
-
/**************************************************************************//**
@Function XX_Print
@@ -176,39 +133,7 @@ void * XX_GetMemPartitionBase(int memPartitionId);
@Return None.
*//***************************************************************************/
-void XX_Print(char *str, ...);
-
-/**************************************************************************//**
- @Function XX_GetChar
-
- @Description Get character from console.
-
- @Return Character is returned on success. Zero is returned otherwise.
-*//***************************************************************************/
-char XX_GetChar(void);
-
-/**************************************************************************//**
- @Function XX_PreallocAndBindIntr
-
- @Description Preallocate and optionally bind it to given CPU.
-
- @Param[in] irq - Interrupt ID (system-specific number).
- @Param[in] cpu - CPU to bind to or -1 if iRQ should be unbound.
-
- @Return E_OK on success; error code otherwise..
-*//***************************************************************************/
-t_Error XX_PreallocAndBindIntr(uintptr_t irq, unsigned int cpu);
-
-/**************************************************************************//**
- @Function XX_DeallocIntr
-
- @Description Deallocate preallocated interupt.
-
- @Param[in] irq - Interrupt ID (system-specific number).
-
- @Return E_OK on success; error code otherwise..
-*//***************************************************************************/
-t_Error XX_DeallocIntr(uintptr_t irq);
+void XX_Print(char *str, ...);
/**************************************************************************//**
@Function XX_SetIntr
@@ -256,7 +181,6 @@ t_Error XX_EnableIntr(uintptr_t irq);
*//***************************************************************************/
t_Error XX_DisableIntr(uintptr_t irq);
-#if !(defined(__MWERKS__) && defined(OPTIMIZED_FOR_SPEED))
/**************************************************************************//**
@Function XX_DisableAllIntr
@@ -279,29 +203,10 @@ uint32_t XX_DisableAllIntr(void);
@Return None.
*//***************************************************************************/
void XX_RestoreAllIntr(uint32_t flags);
-#endif /* !(defined(__MWERKS__) && defined(OPTIMIZED_FOR_SPEED)) */
-
-/**************************************************************************//**
- @Function XX_Call
- @Description Call a service in another task.
- Activate the routine "f" via the queue identified by "IntrManagerId". The
- parameter to "f" is Id - the handle of the destination object
-
- @Param[in] intrManagerId - Queue ID.
- @Param[in] f - routine pointer.
- @Param[in] Id - the parameter to be passed to f().
- @Param[in] h_App - Application handle.
- @Param[in] flags - Unused,
-
- @Return E_OK is returned on success. E_FAIL is returned otherwise (usually an operating system level failure).
-*//***************************************************************************/
-t_Error XX_Call( uint32_t intrManagerId,
- t_Error (* f)(t_Handle),
- t_Handle Id,
- t_Handle h_App,
- uint16_t flags );
+t_Error XX_PreallocAndBindIntr(uintptr_t irq, unsigned int cpu);
+t_Error XX_DeallocIntr(uintptr_t irq);
/**************************************************************************//**
@Function XX_Exit
@@ -312,6 +217,7 @@ t_Error XX_Call( uint32_t intrManagerId,
*//***************************************************************************/
void XX_Exit(int status);
+
/*****************************************************************************/
/* Tasklet Service Routines */
/*****************************************************************************/
@@ -553,18 +459,6 @@ void XX_StartTimer(t_Handle h_Timer,
void XX_StopTimer(t_Handle h_Timer);
/**************************************************************************//**
- @Function XX_GetExpirationTime
-
- @Description Returns the time (in milliseconds) remaining until the
- expiration of a timer.
-
- @Param[in] h_Timer - A handle to a timer.
-
- @Return The time left until the timer expires.
-*//***************************************************************************/
-uint32_t XX_GetExpirationTime(t_Handle h_Timer);
-
-/**************************************************************************//**
@Function XX_ModTimer
@Description Updates the expiration time of a timer.
@@ -581,24 +475,14 @@ uint32_t XX_GetExpirationTime(t_Handle h_Timer);
void XX_ModTimer(t_Handle h_Timer, uint32_t msecs);
/**************************************************************************//**
- @Function XX_TimerIsActive
-
- @Description Checks whether a timer is active (pending) or not.
-
- @Param[in] h_Timer - A handle to a timer.
-
- @Return 0 - the timer is inactive; Non-zero value - the timer is active;
-*//***************************************************************************/
-int XX_TimerIsActive(t_Handle h_Timer);
-
-/**************************************************************************//**
@Function XX_Sleep
@Description Non-busy wait until the desired time (in milliseconds) has passed.
@Param[in] msecs - The requested sleep time (in milliseconds).
- @Return None.
+ @Return Zero if the requested time has elapsed; Otherwise, the value
+ returned will be the unslept amount) in milliseconds.
@Cautions This routine enables interrupts during its wait time.
*//***************************************************************************/
@@ -647,28 +531,6 @@ void * XX_PhysToVirt(physAddress_t addr);
*//***************************************************************************/
physAddress_t XX_VirtToPhys(void *addr);
-/**************************************************************************//**
- @Function XX_PortalSetInfo
-
- @Description Save physical and virtual adresses of the portals.
-
- @Param[in] dev - Portals device - either bman or qman.
-
- @Return Physical, virtual addresses and size.
-*//***************************************************************************/
-void XX_PortalSetInfo(device_t dev);
-
-/**************************************************************************//**
- @Function XX_FmanSetIntrInfo
-
- @Description Workaround for FMan interrupt, which must be binded to one CPU
- only.
-
- @Param[in] irq - Interrupt number.
-
- @Return None.
-*//***************************************************************************/
-void XX_FmanFixIntr(int irq);
/**************************************************************************//**
@Group xx_ipc XX Inter-Partition-Communication API
@@ -930,4 +792,7 @@ t_Error XX_IpcSendMessage(t_Handle h_Session,
/** @} */ /* end of xx_ipc group */
/** @} */ /* end of xx_id group */
+
+void XX_PortalSetInfo(device_t dev);
+void XX_FmanFixIntr(int irq);
#endif /* __XX_EXT_H */
diff --git a/sys/contrib/ncsw/user/env/xx.c b/sys/contrib/ncsw/user/env/xx.c
index c153c69dcef2..d422942d1daa 100644
--- a/sys/contrib/ncsw/user/env/xx.c
+++ b/sys/contrib/ncsw/user/env/xx.c
@@ -120,7 +120,7 @@ struct XX_PortalInfo {
uint32_t portal_ci_size[2][MAXCPU];
vm_offset_t portal_ce_va[2];
vm_offset_t portal_ci_va[2];
- uint32_t portal_intr[2][MAXCPU];
+ uintptr_t portal_intr[2][MAXCPU];
};
static struct XX_PortalInfo XX_PInfo;
@@ -283,16 +283,8 @@ XX_RestoreAllIntr(uint32_t flags)
intr_restore(flags);
}
-t_Error
-XX_Call(uint32_t qid, t_Error (* f)(t_Handle), t_Handle id, t_Handle appId, uint16_t flags )
-{
- /* Not referenced */
- printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
- return (E_OK);
-}
-
static bool
-XX_IsPortalIntr(int irq)
+XX_IsPortalIntr(uintptr_t irq)
{
int cpu, type;
/* Check interrupt numbers of all available portals */
@@ -600,71 +592,6 @@ XX_UnlockIntrSpinlock(t_Handle h_Spinlock, uint32_t intrFlags)
}
uint32_t
-XX_CurrentTime(void)
-{
- /* Not referenced */
- printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
- return (0);
-}
-
-
-t_Handle
-XX_CreateTimer(void)
-{
- /* Not referenced */
- printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
- return (NULL);
-}
-
-void
-XX_FreeTimer(t_Handle h_Timer)
-{
- /* Not referenced */
- printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
-}
-
-void
-XX_StartTimer(t_Handle h_Timer,
- uint32_t msecs,
- bool periodic,
- void (*f_TimerExpired)(t_Handle),
- t_Handle h_Arg)
-{
- /* Not referenced */
- printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
-}
-
-uint32_t
-XX_GetExpirationTime(t_Handle h_Timer)
-{
- /* Not referenced */
- printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
- return (0);
-}
-
-void
-XX_StopTimer(t_Handle h_Timer)
-{
- /* Not referenced */
- printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
-}
-
-void
-XX_ModTimer(t_Handle h_Timer, uint32_t msecs)
-{
- /* Not referenced */
- printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
-}
-
-int
-XX_TimerIsActive(t_Handle h_Timer)
-{
- /* Not referenced */
- printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
- return (0);
-}
-
-uint32_t
XX_Sleep(uint32_t msecs)
{