ncsw: port DPAA1 NCSW layer to ARM64

Port the NetCommSW (NCSW) library from PowerPC to ARM64 for the
NXP LS1046A. Adds ARM64 environment layer (xx_arm64.c, core_arm64.c,
dflags_arm64.h), fixes big-endian portal access, cache operations,
and integration headers for DPAA_VERSION 11 (FManv3/mEMAC).

Includes enhanced hash table support (fm_ehash.c) for CDX PCD,
MURAM batch-write fixes for ARM64 store behavior, QMan FQR RSS
expansion, and BMan/QMan portal initialization changes.

Enable device dpaa in GATEWAY config with NCSW file list.
This commit is contained in:
Tomaz Zaman 2026-03-04 21:09:42 +01:00 • committed by Maurice Walker
parent 4b3943cf68
commit ba1e85edb1
39 changed files with 4728 additions and 178 deletions

View file

@ -52,6 +52,9 @@ device pca954x # NXP PCA9545/9546/9548 I2C mux/switch
# GPIO power-off (STUSB4500 USB-C PD reset)
device gpiopower
# DPAA1 (FMan/QMan/BMan) -- NXP LS1046A packet acceleration
include "dpaa/config.dpaa_arm64"
device dpaa
device sff # Small Form Factor Transceivers (SFP+)
# caam is built as an out-of-tree module in opnsense-deps/drivers/caam/

View file

@ -4,3 +4,88 @@
# - core.c -> core_arm64.c (ARM64 CORE_GetId etc.)
# - xx.c -> xx_arm64.c (no PowerPC ccsrbar/LAW/TLB deps)
# - if_dtsec* excluded (LS1046A uses mEMAC, not dTSEC)
contrib/ncsw/etc/error.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/etc/ncsw_list.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/etc/ncsw_memcpy.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/etc/mm.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/etc/ncsw_mem.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/etc/sprint.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/BM/bm.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/BM/bman_low.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/BM/bm_pool.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/BM/bm_portal.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/SP/fm_sp.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD} -Wno-enum-conversion"
contrib/ncsw/Peripherals/FM/SP/fman_sp.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/Rtc/fm_rtc.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/Rtc/fman_rtc.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/Port/fman_port.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/Port/fm_port.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/Port/fm_port_im.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/Pcd/fm_cc.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/Pcd/fm_ehash.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/Pcd/fm_kg.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/Pcd/fman_kg.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/Pcd/fm_manip.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/Pcd/fm_pcd.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/Pcd/fm_plcr.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/Pcd/fm_prs.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/Pcd/fman_prs.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/Pcd/fm_replic.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
# mEMAC — the MAC type used by LS1046A FManv3 (DPAA_VERSION >= 11)
contrib/ncsw/Peripherals/FM/MAC/memac.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/MAC/memac_mii_acc.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/MAC/fman_memac.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/MAC/fman_memac_mii_acc.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/MAC/fm_mac.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/HC/hc.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/fm_muram.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/FM/fm_ncsw.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD} -Wno-unused-but-set-variable"
contrib/ncsw/Peripherals/FM/fman_ncsw.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD} ${NO_WMISLEADING_INDENTATION}"
contrib/ncsw/Peripherals/QM/qm.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/Peripherals/QM/qm_portal_fqr.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/user/env/stdlib.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
# ARM64 replacements for xx.c and core.c (no PowerPC deps)
contrib/ncsw/user/env/xx_arm64.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"
contrib/ncsw/user/env/core_arm64.c optional dpaa \
no-depend compile-with "${DPAA_COMPILE_CMD}"

View file

@ -441,7 +441,7 @@ t_Error BmGetRevision(t_Handle h_Bm, t_BmRevisionInfo *p_BmRevisionInfo)
static void FreeInitResources(t_Bm *p_Bm)
{
if (p_Bm->p_FbprBase)
if (p_Bm->p_FbprBase && !p_Bm->fbprExternal)
XX_FreeSmart(p_Bm->p_FbprBase);
if (p_Bm->h_Session)
XX_IpcFreeSession(p_Bm->h_Session);
@ -491,6 +491,8 @@ t_Handle BM_Config(t_BmParam *p_BmParam)
p_Bm->p_BmDriverParams->fbprMemPartitionId = p_BmParam->fbprMemPartitionId;
p_Bm->p_BmDriverParams->fbprThreshold = DEFAULT_fbprThreshold;
p_Bm->p_BmDriverParams->liodn = p_BmParam->liodn;
p_Bm->p_BmDriverParams->p_FbprBaseExt = p_BmParam->p_FbprBase;
p_Bm->p_BmDriverParams->fbprSizeExt = p_BmParam->fbprSize;
}
/* build the BM partition IPC address */
@ -534,26 +536,50 @@ t_Error BM_Init(t_Handle h_Bm)
WRITE_UINT32(p_Bm->p_BmRegs->liodnr, (uint16_t)p_Bm->p_BmDriverParams->liodn);
/* FBPR memory */
dsSize = (uint32_t)(p_Bm->p_BmDriverParams->totalNumOfBuffers * (FBPR_ENTRY_SIZE / 8));
LOG2(dsSize, exp);
if (!POWER_OF_2(dsSize)) (exp++);
dsSize = (uint32_t)(1 << exp);
if (dsSize < (4*KILOBYTE))
if (p_Bm->p_BmDriverParams->p_FbprBaseExt)
{
dsSize = (4*KILOBYTE);
/* Use pre-allocated FBPR memory from caller */
p_Bm->p_FbprBase = p_Bm->p_BmDriverParams->p_FbprBaseExt;
p_Bm->fbprExternal = TRUE;
dsSize = p_Bm->p_BmDriverParams->fbprSizeExt;
LOG2(dsSize, exp);
if (!POWER_OF_2(dsSize)) (exp++);
dsSize = (uint32_t)(1 << exp);
}
p_Bm->p_FbprBase = XX_MallocSmart(dsSize, (int)p_Bm->p_BmDriverParams->fbprMemPartitionId, dsSize);
if (!p_Bm->p_FbprBase)
else
{
FreeInitResources(p_Bm);
RETURN_ERROR(MAJOR, E_NO_MEMORY, ("FBPR obj!!!"));
dsSize = (uint32_t)(p_Bm->p_BmDriverParams->totalNumOfBuffers * (FBPR_ENTRY_SIZE / 8));
LOG2(dsSize, exp);
if (!POWER_OF_2(dsSize)) (exp++);
dsSize = (uint32_t)(1 << exp);
if (dsSize < (4*KILOBYTE))
{
dsSize = (4*KILOBYTE);
LOG2(dsSize, exp);
}
p_Bm->p_FbprBase = XX_MallocSmart(dsSize, (int)p_Bm->p_BmDriverParams->fbprMemPartitionId, dsSize);
if (!p_Bm->p_FbprBase)
{
FreeInitResources(p_Bm);
RETURN_ERROR(MAJOR, E_NO_MEMORY, ("FBPR obj!!!"));
}
}
phyAddr = XX_VirtToPhys(p_Bm->p_FbprBase);
WRITE_UINT32(p_Bm->p_BmRegs->fbpr_bare, ((uint32_t)(phyAddr >> 32) & 0xffff));
WRITE_UINT32(p_Bm->p_BmRegs->fbpr_bar, (uint32_t)phyAddr);
WRITE_UINT32(p_Bm->p_BmRegs->fbpr_ar, (exp - 1));
/* Readback and verify FBPR BAR programming */
{
uint32_t rb_bare = GET_UINT32(p_Bm->p_BmRegs->fbpr_bare);
uint32_t rb_bar = GET_UINT32(p_Bm->p_BmRegs->fbpr_bar);
uint32_t rb_ar = GET_UINT32(p_Bm->p_BmRegs->fbpr_ar);
XX_Print("BM FBPR: va=%p phys=0x%08x%08x bare=0x%08x bar=0x%08x ar=0x%08x (exp=%d, size=0x%x)\n",
p_Bm->p_FbprBase,
(uint32_t)(phyAddr >> 32), (uint32_t)phyAddr,
rb_bare, rb_bar, rb_ar, exp, dsSize);
}
WRITE_UINT32(p_Bm->p_BmRegs->fbpr_fp_lwit, p_Bm->p_BmDriverParams->fbprThreshold);
WRITE_UINT32(p_Bm->p_BmRegs->err_isr, p_Bm->exceptions);
WRITE_UINT32(p_Bm->p_BmRegs->err_ier, p_Bm->exceptions);

View file

@ -290,6 +290,8 @@ typedef struct {
uint32_t fbprMemPartitionId;
uint32_t fbprThreshold;
uint16_t liodn;
void *p_FbprBaseExt; /* Pre-allocated FBPR, or NULL */
uint32_t fbprSizeExt;
} t_BmDriverParams;
typedef struct {
@ -301,6 +303,7 @@ typedef struct {
char moduleName[MODULE_NAME_SIZE];
t_BmRegs *p_BmRegs;
void *p_FbprBase;
bool fbprExternal; /* FBPR memory externally allocated */
uint32_t exceptions;
t_BmExceptionsCallback *f_Exception;
t_Handle h_App;

View file

@ -61,6 +61,7 @@ static void depletion_link(t_BmPool *p_BmPool)
NCSW_PLOCK(p_Portal);
p_Portal->depletionPoolsTable[p_BmPool->bpid] = p_BmPool;
bman_depletion_set(&p_Portal->pools[0], (uint8_t)p_BmPool->bpid);
bm_isr_bscn_mask(p_Portal->p_BmPortalLow, (uint8_t)p_BmPool->bpid, 1);
PUNLOCK(p_Portal);
}
@ -71,6 +72,7 @@ static void depletion_unlink(t_BmPool *p_BmPool)
NCSW_PLOCK(p_Portal);
p_Portal->depletionPoolsTable[p_BmPool->bpid] = NULL;
bman_depletion_unset(&p_Portal->pools[0], (uint8_t)p_BmPool->bpid);
bm_isr_bscn_mask(p_Portal->p_BmPortalLow, (uint8_t)p_BmPool->bpid, 0);
PUNLOCK(p_Portal);
}

View file

@ -381,16 +381,23 @@ t_Error BmPortalRelease(t_Handle h_BmPortal,
if (!r) {
if (flags & BMAN_RELEASE_FLAG_WAIT) {
t_Error ret = wait_rel_start(p_BmPortal, &r, flags);
if (ret)
if (ret) {
printf("BmPortalRelease: wait_rel_start FAILED E_BUSY, avail=%u, "
"rcr.ci=%u, rcr.cursor=%p, rcr.vbit=%u\n",
bm_rcr_get_avail(p_BmPortal->p_BmPortalLow),
p_BmPortal->p_BmPortalLow->rcr.ci,
p_BmPortal->p_BmPortalLow->rcr.cursor,
p_BmPortal->p_BmPortalLow->rcr.vbit);
return ret;
}
} else
return ERROR_CODE(E_BUSY);
ASSERT_COND(r != NULL);
}
r->bpid = bpid;
for (i = 0; i < num; i++) {
r->bufs[i].hi = bufs[i].hi;
r->bufs[i].lo = bufs[i].lo;
WRITE_UINT16(r->bufs[i].hi, bufs[i].hi);
WRITE_UINT32(r->bufs[i].lo, bufs[i].lo);
}
/* Issue the release command and wait for sync if requested. NB: the
* commit can't fail, only waiting can. Don't propagate any failure if a
@ -423,8 +430,8 @@ uint8_t BmPortalAcquire(t_Handle h_BmPortal,
ASSERT_COND(num <= 8);
while (num--) {
bufs[num].bpid = bpid;
bufs[num].hi = mcr->acquire.bufs[num].hi;
bufs[num].lo = mcr->acquire.bufs[num].lo;
bufs[num].hi = GET_UINT16(mcr->acquire.bufs[num].hi);
bufs[num].lo = GET_UINT32(mcr->acquire.bufs[num].lo);
}
PUNLOCK(p_BmPortal);
return ret;
@ -495,7 +502,7 @@ t_Handle BM_PORTAL_Config(t_BmPortalParam *p_BmPortalParam)
p_BmPortal->h_Bm = p_BmPortalParam->h_Bm;
p_BmPortal->p_BmPortalDriverParams->hwExtStructsMemAttr = DEFAULT_memAttr;
bman_depletion_fill(&p_BmPortal->p_BmPortalDriverParams->mask);
bman_depletion_init(&p_BmPortal->p_BmPortalDriverParams->mask);
return p_BmPortal;
}

View file

@ -40,6 +40,7 @@
*//***************************************************************************/
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <machine/atomic.h>
#include "std_ext.h"
@ -55,15 +56,28 @@
/***************************/
/* Cache-inhibited register offsets */
#if defined(__aarch64__)
/*
* ARM64 Layerscape (LS1046A etc.): CI space is 16KB per portal.
* Register offsets are spread out compared to PowerPC.
* See Linux drivers/soc/fsl/qbman/bman.c for reference.
*/
#define REG_RCR_PI_CINH 0x3000
#define REG_RCR_CI_CINH 0x3100
#define REG_RCR_ITR 0x3200
#define REG_CFG 0x3300
#define REG_SCN(n) (0x3400 + ((n) << 6))
#define REG_ISR 0x3e00
#define BM_ISR_SHIFT 6 /* ISR/IER/ISDR/IIR stride: 64 bytes */
#else /* PowerPC */
#define REG_RCR_PI_CINH 0x0000
#define REG_RCR_CI_CINH 0x0004
#define REG_RCR_ITR 0x0008
#define REG_CFG 0x0100
#define REG_SCN(n) (0x0200 + ((n) << 2))
#define REG_ISR 0x0e00
#define REG_IER 0x0e04
#define REG_ISDR 0x0e08
#define REG_IIR 0x0e0c
#define BM_ISR_SHIFT 2 /* ISR/IER/ISDR/IIR stride: 4 bytes */
#endif
/* Cache-enabled register offsets */
#define CL_CR 0x0000
@ -258,9 +272,17 @@ struct bm_rcr_entry *bm_rcr_pend_and_next(struct bm_portal *portal, uint8_t myve
void bm_rcr_pci_commit(struct bm_portal *portal, uint8_t myverb)
{
register struct bm_rcr *rcr = &portal->rcr;
struct bm_rcr_entry *rcursor;
ASSERT_COND(rcr->busy);
ASSERT_COND(rcr->pmode == e_BmPortalPCI);
rcr->cursor->__dont_write_directly__verb = (uint8_t)(myverb | rcr->vbit);
rcursor = rcr->cursor;
rcursor->__dont_write_directly__verb = (uint8_t)(myverb | rcr->vbit);
/*
* ARM64: The portal hardware cannot snoop the CPU cache via CCI-400.
* Explicitly flush the entry from cache to portal CE memory before
* writing PI. On PowerPC the CCF provides hardware coherency.
*/
dcbf_64(rcursor);
RCR_INC(rcr);
rcr->available--;
mb();
@ -298,7 +320,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);
rmb();
wmb();
rcursor = rcr->cursor;
rcursor->__dont_write_directly__verb = (uint8_t)(myverb | rcr->vbit);
dcbf_64(rcursor);
@ -487,12 +509,12 @@ void bm_isr_bscn_mask(struct bm_portal *portal, uint8_t bpid, int enable)
uint32_t __bm_isr_read(struct bm_portal *portal, enum bm_isr_reg n)
{
return __bm_in(&portal->addr, REG_ISR + (n << 2));
return __bm_in(&portal->addr, REG_ISR + (n << BM_ISR_SHIFT));
}
void __bm_isr_write(struct bm_portal *portal, enum bm_isr_reg n, uint32_t val)
{
__bm_out(&portal->addr, REG_ISR + (n << 2), val);
__bm_out(&portal->addr, REG_ISR + (n << BM_ISR_SHIFT), val);
}

View file

@ -55,6 +55,39 @@
* execution reordering with respect to other code/instructions that manipulate
* the same cacheline. */
#if defined(__aarch64__)
/*
* ARM64 cache operations.
*
* Portal CE region is mapped Normal Non-Cacheable (matching Linux's
* MEMREMAP_WC), so stores go directly to hardware. However, dcbf is
* also used on cacheable DMA memory (buffer pools) — there we need
* real cache clean to make CPU writes visible to BMan hardware.
*
* dc cvac (clean by VA to PoC) is the ARM64 equivalent of PPC dcbf.
* On NC addresses it's a harmless no-op; on cached addresses it writes
* dirty lines back to memory.
*
* dc zva MUST NOT be used on portal NC memory — it generates a special
* bus transaction that can hang the interconnect. Use memset instead.
*/
#define lwsync() __asm__ __volatile__ ("dmb ish" : : : "memory")
#define dcbf(addr) do { \
__asm__ __volatile__ ("dc cvac, %0" : : "r"(addr) : "memory"); \
__asm__ __volatile__ ("dsb st" : : : "memory"); \
} while(0)
#define dcbi(p) __asm__ __volatile__ ("dsb sy" : : : "memory")
#define dcbt_ro(addr) do { } while(0)
#define dcbt_rw(addr) do { } while(0)
#define dcbz_64(p) do { memset((p), 0, 64); } while(0)
#define dcbf_64(p) do { \
__asm__ __volatile__ ("dc cvac, %0" : : "r"(p) : "memory"); \
__asm__ __volatile__ ("dsb st" : : : "memory"); \
} while(0)
#define dcbit_ro(p) do { } while(0)
#else /* PowerPC */
#define dcbf(addr) \
do { \
__asm__ __volatile__ ("dcbf 0, %0" : : "r" (addr)); \
@ -127,6 +160,8 @@
#define dcbi(p) dcbf(p)
#endif /* __aarch64__ */
struct bm_addr {
void *addr_ce; /* cache-enabled */
void *addr_ci; /* cache-inhibited */

View file

@ -228,7 +228,12 @@ static __inline__ t_Error EnQFrm(t_FmHc *p_FmHc, t_DpaaFD *p_FmFd, uint32_t seqN
XX_UDelay(100);
if (!timeout)
{
intFlags = FmPcdLock(p_FmHc->h_FmPcd);
p_FmHc->enqueued[seqNum] = FALSE;
FmPcdUnlock(p_FmHc->h_FmPcd, intFlags);
RETURN_ERROR(MINOR, E_TIMEOUT, ("HC Callback, timeout exceeded"));
}
return err;
}

View file

@ -38,6 +38,7 @@
*//***************************************************************************/
#include <sys/cdefs.h>
#include <sys/endian.h>
#include "std_ext.h"
#include "error_ext.h"
#include "string_ext.h"
@ -51,6 +52,15 @@
#include "fm_cc.h"
#include "crc64.h"
#ifdef USE_ENHANCED_EHASH
#include "fm_ehash.h"
extern t_Handle ExternalHashTableSet(t_Handle h_FmPcd,
t_FmPcdHashTableParams *p_Param);
extern t_Error ExternalHashTableModifyMissNextEngine(t_Handle h_HashTbl,
t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
extern void copy_td_to_ccbase(void *handle, t_Handle p_CcTreeTmp);
#endif /* USE_ENHANCED_EHASH */
/****************************************/
/* static functions */
/****************************************/
@ -344,6 +354,24 @@ static void FillAdOfTypeContLookup(t_Handle h_Ad,
/* if (p_AdNewPtr = NULL) --> Done. (case (3)) */
if (p_AdNewPtr)
{
#if (DPAA_VERSION >= 11)
if (p_Node->externalHash)
{
/*
* External hash table (CDX): write a zeroed placeholder AD.
* CDX will overwrite this AD with its opcode-format entries
* when it takes over the hash table. Until then, the zero
* AD acts as a "result" type with FQID=0 / NIA=0, which
* causes FMan to enqueue to the default queue.
*/
WRITE_UINT32(p_AdContLookup->ccAdBase, 0);
WRITE_UINT32(p_AdContLookup->matchTblPtr, 0);
WRITE_UINT32(p_AdContLookup->pcAndOffsets, 0);
WRITE_UINT32(p_AdContLookup->gmask, 0);
}
else
#endif /* (DPAA_VERSION >= 11) */
{
/* cases (1) & (2) */
tmpReg32 = 0;
tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;
@ -371,6 +399,7 @@ static void FillAdOfTypeContLookup(t_Handle h_Ad,
MemCpy8((void*)&p_AdContLookup->gmask, p_Node->p_GlblMask,
CC_GLBL_MASK_SIZE);
}
}
}
@ -1071,6 +1100,7 @@ static bool IsCapwapApplSpecific(t_Handle h_Node)
}
#endif /* FM_CAPWAP_SUPPORT */
#ifndef USE_ENHANCED_EHASH
static t_Error CcUpdateParam(
t_Handle h_FmPcd, t_Handle h_PcdParams, t_Handle h_FmPort,
t_FmPcdCcKeyAndNextEngineParams *p_CcKeyAndNextEngineParams,
@ -1165,6 +1195,34 @@ static t_Error CcUpdateParam(
return E_OK;
}
#else /* USE_ENHANCED_EHASH */
/*
* With enhanced ehash, CC tree entries contain CDX enhanced AD content
* written by copy_td_to_ccbase(). No NCSW internal parameter update
* or recursive tree walking needed — h_CcNode handles are en_exthash_info*
* not t_FmPcdCcNode*, so the internal code would crash.
* Matching Linux SDK fm_cc.c:1209-1221.
*/
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)
{
UNUSED(h_FmPcd);
UNUSED(h_PcdParams);
UNUSED(h_FmPort);
UNUSED(p_CcKeyAndNextEngineParams);
UNUSED(numOfEntries);
UNUSED(h_Ad);
UNUSED(validate);
UNUSED(level);
UNUSED(h_FmTree);
UNUSED(modify);
return E_OK;
}
#endif /* USE_ENHANCED_EHASH */
static ccPrivateInfo_t IcDefineCode(t_FmPcdCcNodeParams *p_CcNodeParam)
{
@ -6005,8 +6063,10 @@ t_Handle FM_PCD_CcRootBuild(t_Handle h_FmPcd,
t_NetEnvParams netEnvParams;
uint8_t lastOne = 0;
uint32_t requiredAction = 0;
#ifndef USE_ENHANCED_EHASH
t_FmPcdCcNode *p_FmPcdCcNextNode;
t_CcNodeInformation ccNodeInfo, *p_CcInformation;
#endif
SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, NULL);
SANITY_CHECK_RETURN_VALUE(p_PcdGroupsParam, E_INVALID_HANDLE, NULL);
@ -6190,6 +6250,7 @@ t_Handle FM_PCD_CcRootBuild(t_Handle h_FmPcd,
p_CcTreeTmp = UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr);
#ifndef USE_ENHANCED_EHASH
for (i = 0; i < numOfEntries; i++)
{
p_KeyAndNextEngineParams = p_Params + i;
@ -6225,10 +6286,59 @@ t_Handle FM_PCD_CcRootBuild(t_Handle h_FmPcd,
p_CcInformation->index++;
}
}
#else /* USE_ENHANCED_EHASH */
for (i = 0; i < numOfEntries; i++)
{
t_FmPcdCcNextEngineParams *nexteng;
p_KeyAndNextEngineParams = p_Params + i;
nexteng = &p_KeyAndNextEngineParams->nextEngineParams;
if (nexteng->nextEngine == e_FM_PCD_CC &&
nexteng->params.ccParams.h_CcNode)
{
/* Enhanced external hash table: copy AD into CC tree MURAM slot */
copy_td_to_ccbase(nexteng->params.ccParams.h_CcNode, p_CcTreeTmp);
}
else
{
/* Non-CC entry (KG/PLCR/DONE): use standard result AD */
NextStepAd(p_CcTreeTmp, NULL, nexteng, p_FmPcd);
}
p_CcTreeTmp = PTR_MOVE(p_CcTreeTmp, FM_PCD_CC_AD_ENTRY_SIZE);
memcpy(&p_FmPcdCcTree->keyAndNextEngineParams[i],
p_KeyAndNextEngineParams,
sizeof(t_FmPcdCcKeyAndNextEngineParams));
}
/*
* Fill unused CC tree entries (numOfEntries..15) with a copy of
* entry 0. A zeroed EHASH AD has table_base=0x0 — FMan DMA to
* physical address 0 (not DDR) hangs the task permanently.
* Copying entry 0 gives a valid table_base, int_buf_pool, and
* global_mem_offset. The miss_action starts as DONE (0);
* ExternalHashTableModifyMissNextEngine propagates the correct
* miss action to all copies by scanning for matching table_base_lo.
*/
if (numOfEntries > 0 && numOfEntries < FM_PCD_MAX_NUM_OF_CC_GROUPS)
{
uint8_t *base = (uint8_t *)
UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr);
for (i = numOfEntries; i < FM_PCD_MAX_NUM_OF_CC_GROUPS; i++)
{
memcpy(base + i * FM_PCD_CC_AD_ENTRY_SIZE,
base,
FM_PCD_CC_AD_ENTRY_SIZE);
}
}
#endif /* USE_ENHANCED_EHASH */
FmPcdIncNetEnvOwners(h_FmPcd, p_FmPcdCcTree->netEnvId);
p_CcTreeTmp = UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr);
#ifndef USE_ENHANCED_EHASH
if (!FmPcdLockTryLockAll(p_FmPcd))
{
FM_PCD_CcRootDelete(p_FmPcdCcTree);
@ -6259,6 +6369,7 @@ t_Handle FM_PCD_CcRootBuild(t_Handle h_FmPcd,
}
FmPcdLockUnlockAll(p_FmPcd);
#endif /* USE_ENHANCED_EHASH */
p_FmPcdCcTree->p_Lock = FmPcdAcquireLock(p_FmPcd);
if (!p_FmPcdCcTree->p_Lock)
{
@ -7112,6 +7223,9 @@ t_Error FM_PCD_MatchTableGetIndexedHashBucket(t_Handle h_CcNode,
t_Handle FM_PCD_HashTableSet(t_Handle h_FmPcd, t_FmPcdHashTableParams *p_Param)
{
#ifdef USE_ENHANCED_EHASH
return ExternalHashTableSet(h_FmPcd, p_Param);
#else /* !USE_ENHANCED_EHASH */
t_FmPcdCcNode *p_CcNodeHashTbl;
t_FmPcdCcNodeParams *p_IndxHashCcNodeParam, *p_ExactMatchCcNodeParam;
t_FmPcdCcNode *p_CcNode;
@ -7151,6 +7265,57 @@ t_Handle FM_PCD_HashTableSet(t_Handle h_FmPcd, t_FmPcdHashTableParams *p_Param)
("RMON statistics mode is not supported for hash table"));
return NULL;
}
if (p_Param->externalHash)
{
/*
* External hash table: CDX manages the hash buckets in DDR.
* NCSW only allocates a minimal t_FmPcdCcNode with a MURAM AD
* placeholder. CDX will take over the AD and rewrite it with
* CDX opcode entries.
*
* The AD is initially zeroed (safe: result type, enqueue to
* default FQ). Packets reaching this node before CDX takes
* over will be enqueued to the default queue harmlessly.
*/
t_FmPcdCcNode *p_ExtNode;
t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;
p_ExtNode = (t_FmPcdCcNode *)XX_Malloc(sizeof(t_FmPcdCcNode));
if (!p_ExtNode)
{
REPORT_ERROR(MAJOR, E_NO_MEMORY, ("external hash CC node"));
return NULL;
}
memset(p_ExtNode, 0, sizeof(t_FmPcdCcNode));
p_ExtNode->externalHash = TRUE;
p_ExtNode->h_FmPcd = h_FmPcd;
p_ExtNode->kgHashShift = p_Param->kgHashShift;
p_ExtNode->statisticsMode = p_Param->statisticsMode;
/* Allocate MURAM AD for this node */
p_ExtNode->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_ExtNode->h_Ad)
{
XX_Free(p_ExtNode);
REPORT_ERROR(MAJOR, E_NO_MEMORY,
("MURAM allocation for external hash AD"));
return NULL;
}
MemSet8(p_ExtNode->h_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);
p_ExtNode->h_Spinlock = XX_InitSpinlock();
INIT_LIST(&p_ExtNode->ccPrevNodesLst);
INIT_LIST(&p_ExtNode->ccTreeIdLst);
INIT_LIST(&p_ExtNode->ccTreesLst);
INIT_LIST(&p_ExtNode->availableStatsLst);
return (t_Handle)p_ExtNode;
}
#endif /* (DPAA_VERSION >= 11) */
p_ExactMatchCcNodeParam = (t_FmPcdCcNodeParams*)XX_Malloc(
@ -7305,10 +7470,14 @@ t_Handle FM_PCD_HashTableSet(t_Handle h_FmPcd, t_FmPcdHashTableParams *p_Param)
XX_Free(p_ExactMatchCcNodeParam);
return p_CcNodeHashTbl;
#endif /* !USE_ENHANCED_EHASH */
}
t_Error FM_PCD_HashTableDelete(t_Handle h_HashTbl)
{
#ifdef USE_ENHANCED_EHASH
return (t_Error)-1; /* delete not implemented for enhanced ehash */
#else
t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
t_Handle h_FmPcd;
t_Handle *p_HashBuckets, h_MissStatsCounters;
@ -7317,6 +7486,19 @@ t_Error FM_PCD_HashTableDelete(t_Handle h_HashTbl)
SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);
#if (DPAA_VERSION >= 11)
if (p_HashTbl->externalHash)
{
if (p_HashTbl->h_Ad)
FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_HashTbl->h_FmPcd),
p_HashTbl->h_Ad);
if (p_HashTbl->h_Spinlock)
XX_FreeSpinlock(p_HashTbl->h_Spinlock);
XX_Free(p_HashTbl);
return E_OK;
}
#endif /* (DPAA_VERSION >= 11) */
/* Store all hash buckets before the hash is freed */
numOfBuckets = p_HashTbl->numOfKeys;
@ -7348,11 +7530,20 @@ t_Error FM_PCD_HashTableDelete(t_Handle h_HashTbl)
RETURN_ERROR(MAJOR, err, NO_MSG);
return E_OK;
#endif /* !USE_ENHANCED_EHASH */
}
t_Error FM_PCD_HashTableAddKey(t_Handle h_HashTbl, uint8_t keySize,
t_FmPcdCcKeyParams *p_KeyParams)
{
#ifdef USE_ENHANCED_EHASH
/* CDX adds keys directly via ExternalHashTableAddKey (different
* signature). This NCSW dispatch path is not used. */
UNUSED(h_HashTbl);
UNUSED(keySize);
UNUSED(p_KeyParams);
return E_NOT_SUPPORTED;
#else
t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
t_Handle h_HashBucket;
uint8_t bucketIndex;
@ -7377,8 +7568,10 @@ t_Error FM_PCD_HashTableAddKey(t_Handle h_HashTbl, uint8_t keySize,
return FM_PCD_MatchTableAddKey(h_HashBucket, FM_PCD_LAST_KEY_INDEX, keySize,
p_KeyParams);
#endif /* !USE_ENHANCED_EHASH */
}
#ifndef USE_ENHANCED_EHASH
t_Error FM_PCD_HashTableRemoveKey(t_Handle h_HashTbl, uint8_t keySize,
uint8_t *p_Key)
{
@ -7426,11 +7619,16 @@ t_Error FM_PCD_HashTableModifyNextEngine(
NULL,
p_FmPcdCcNextEngineParams);
}
#endif /* !USE_ENHANCED_EHASH */
t_Error FM_PCD_HashTableModifyMissNextEngine(
t_Handle h_HashTbl,
t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
{
#ifdef USE_ENHANCED_EHASH
return ExternalHashTableModifyMissNextEngine(h_HashTbl,
p_FmPcdCcNextEngineParams);
#else
t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;
t_Handle h_HashBucket;
uint8_t i;
@ -7483,9 +7681,11 @@ t_Error FM_PCD_HashTableModifyMissNextEngine(
}
return E_OK;
#endif /* !USE_ENHANCED_EHASH */
}
#ifndef USE_ENHANCED_EHASH
t_Error FM_PCD_HashTableGetMissNextEngine(
t_Handle h_HashTbl,
t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
@ -7549,3 +7749,4 @@ t_Error FM_PCD_HashTableGetMissStatistics(
return FM_PCD_MatchTableGetMissStatistics(h_HashBucket, p_MissStatistics);
}
#endif /* !USE_ENHANCED_EHASH */

View file

@ -348,6 +348,11 @@ typedef struct
uint32_t shadowAction;
uint8_t userSizeOfExtraction;
uint8_t userOffset;
#if (DPAA_VERSION >= 11)
bool externalHash; /* CDX external hash table */
#endif /* (DPAA_VERSION >= 11) */
uint8_t kgHashShift; /* used in hash-table */
t_Handle h_Spinlock;

File diff suppressed because it is too large Load diff

View file

@ -1035,6 +1035,12 @@ static t_Error BuildSchemeRegs(t_FmPcdKgScheme *p_Scheme,
memset(swDefaults, 0, NUM_OF_SW_DEFAULTS*sizeof(t_FmPcdKgExtractDflt));
memset(p_SchemeRegs, 0, sizeof(struct fman_kg_scheme_regs));
/* Default: disable policer profile generation. PLCR and
* CC-with-plcrNext cases below overwrite kgse_ppc when PGEN
* is actually needed. Without this, kgse_ppc=0 leaves
* PP_NO_GEN clear → implicit PGEN with profile 0. */
p_SchemeRegs->kgse_ppc = KG_SCH_PP_NO_GEN;
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));
@ -1250,7 +1256,13 @@ static t_Error BuildSchemeRegs(t_FmPcdKgScheme *p_Scheme,
}
p_SchemeRegs->kgse_mode = tmpReg;
p_SchemeRegs->kgse_mv = p_Scheme->matchVector;
/* SCHEME_ALWAYS_DIRECT (0xFFFFFFFF) means "match all frames" in NCSW
* software, but FMan KG hardware interprets the MV register literally:
* (classification_vector & kgse_mv) == kgse_mv. With 0xFFFFFFFF, all
* 32 classification bits must be set — no frame can ever match.
* Write 0 instead: the hardware treats MV=0 as "always match." */
p_SchemeRegs->kgse_mv = (p_Scheme->matchVector == SCHEME_ALWAYS_DIRECT)
? 0 : p_Scheme->matchVector;
#if (DPAA_VERSION >= 11)
if (p_SchemeParams->overrideStorageProfile)
@ -1569,6 +1581,17 @@ static t_Error BuildSchemeRegs(t_FmPcdKgScheme *p_Scheme,
generic = FALSE;
}
}
/*
* CDX/ASK flow offload requires the port ID to always be
* present as the first byte of every KG key output. The
* PCD XML <combine portid="true"> only adds it to
* extractedOrs (for FQID modification), but the CDX hash
* table key (union dpa_key) expects portid at byte 0.
* Force KG_SCH_KN_PORT_ID into the known-fields set so
* the hardware extracts it as known-field ID 0 (bit 31,
* highest priority → first in key output).
*/
knownTmp |= KG_SCH_KN_PORT_ID;
p_SchemeRegs->kgse_ekfc = knownTmp;
selectTmp = 0;

View file

@ -437,6 +437,7 @@ t_Handle PrsConfig(t_FmPcd *p_FmPcd,t_FmPcdParams *p_FmPcdParams);
t_Error PrsInit(t_FmPcd *p_FmPcd);
void PrsEnable(t_FmPcd *p_FmPcd);
void PrsDisable(t_FmPcd *p_FmPcd);
int PrsIsEnabled(t_FmPcd *p_FmPcd);
void PrsFree(t_FmPcd *p_FmPcd );
t_Error PrsIncludePortInStatistics(t_FmPcd *p_FmPcd, uint8_t hardwarePortId, bool include);
@ -540,4 +541,6 @@ static __inline__ void FmPcdLockUnlock(t_FmPcdLock *p_Lock)
}
t_Handle FM_PCD_GetHcPort(t_Handle h_FmPcd);
#endif /* __FM_PCD_H */

View file

@ -158,6 +158,14 @@ static t_Error SetProfileNia(t_FmPcd *p_FmPcd, e_FmPcdEngine nextEngine, u_FmPcd
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Invalid profile "));
nia |= NIA_ENG_PLCR | NIA_PLCR_ABSOLUTE | absoluteProfileId;
break;
case e_FM_PCD_PRS:
/* Post-policer: re-enter PCD pipeline via KG engine */
nia |= 0x00480200;
break;
case e_FM_PCD_CC:
/* Post-policer: coarse classifier engine */
nia |= 0x26;
break;
default:
RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);
}

View file

@ -144,7 +144,7 @@ static t_FmPcdFrmReplicMember *GetAvailableMember(t_FmPcdFrmReplicGroup *p_Repli
if (!LIST_IsEmpty(&p_ReplicGroup->availableMembersList))
{
p_Next = LIST_FIRST(&p_ReplicGroup->availableMembersList);
p_Next = NCSW_LIST_FIRST(&p_ReplicGroup->availableMembersList);
p_ReplicMember = LIST_OBJECT(p_Next, t_FmPcdFrmReplicMember, node);
ASSERT_COND(p_ReplicMember);
LIST_DelAndInit(p_Next);
@ -643,7 +643,7 @@ void FrmReplicGroupUpdateOwner(t_Handle h_ReplicGroup,
}
}
t_Error FrmReplicGroupTryLock(t_Handle h_ReplicGroup)
static t_Error FrmReplicGroupTryLock(t_Handle h_ReplicGroup)
{
t_FmPcdFrmReplicGroup *p_ReplicGroup = (t_FmPcdFrmReplicGroup *)h_ReplicGroup;
@ -655,7 +655,7 @@ t_Error FrmReplicGroupTryLock(t_Handle h_ReplicGroup)
return ERROR_CODE(E_BUSY);
}
void FrmReplicGroupUnlock(t_Handle h_ReplicGroup)
static void FrmReplicGroupUnlock(t_Handle h_ReplicGroup)
{
t_FmPcdFrmReplicGroup *p_ReplicGroup = (t_FmPcdFrmReplicGroup *)h_ReplicGroup;

View file

@ -36,6 +36,9 @@
@Description FM driver routines implementation.
*//***************************************************************************/
#ifdef __FreeBSD__
#endif
#include "error_ext.h"
#include "std_ext.h"
#include "string_ext.h"
@ -1349,7 +1352,7 @@ static t_Error SetPcd(t_FmPort *p_FmPort, t_FmPortPcdParams *p_PcdParams)
}
/* if CC is used directly after BMI */
if ((p_PcdParams->pcdSupport == e_FM_PORT_PCD_SUPPORT_CC_ONLY)
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)
@ -5271,6 +5274,7 @@ t_Error FM_PORT_SetPCD(t_Handle h_FmPort, t_FmPortPcdParams *p_PcdParam)
RETURN_ERROR(MAJOR, err, NO_MSG);
}
/* Diagnostic: dump all BMI NIA registers after SetPCD */
RELEASE_LOCK(p_FmPort->lock);
return err;
@ -5668,7 +5672,7 @@ static t_Error FmPortConfigAutoResForDeepSleepSupport1(t_FmPort *p_FmPort)
return E_OK;
}
t_FmPortDsarTablesSizes* FM_PORT_GetDsarTablesMaxSizes(t_Handle h_FmPortRx)
static t_FmPortDsarTablesSizes* FM_PORT_GetDsarTablesMaxSizes(t_Handle h_FmPortRx)
{
t_FmPort *p_FmPort = (t_FmPort *)h_FmPortRx;
return p_FmPort->deepSleepVars.autoResMaxSizes;

View file

@ -88,8 +88,11 @@ static bool IsFmanCtrlCodeLoaded(t_Fm *p_Fm)
static t_Error CheckFmParameters(t_Fm *p_Fm)
{
#ifndef __aarch64__
/* On ARM64, U-Boot preloads FMan microcode into IRAM; reuse it */
if (IsFmanCtrlCodeLoaded(p_Fm) && !p_Fm->resetOnInit)
RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Old FMan CTRL code is loaded; FM must be reset!"));
#endif
#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))
@ -3434,7 +3437,7 @@ t_Handle FM_Config(t_FmParams *p_FmParam)
#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;
p_Fm->p_FmDriverParam->dma_aid_mode = E_FMAN_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)
@ -3568,12 +3571,15 @@ t_Error FM_Init(t_Handle h_Fm)
if (!p_Fm->resetOnInit) /* Skip operations done in errata workaround */
{
#endif /* FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173 */
/* Load FMan-Controller code to IRAM */
/* Load FMan-Controller code to IRAM (skip if no firmware provided,
e.g. when U-Boot has already loaded microcode) */
if (p_Fm->firmware.p_Code)
{
ClearIRam(p_Fm);
ClearIRam(p_Fm);
if (p_Fm->firmware.p_Code && (LoadFmanCtrlCode(p_Fm) != E_OK))
RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
if (LoadFmanCtrlCode(p_Fm) != E_OK)
RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);
}
#ifdef FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173
}
#endif /* FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173 */
@ -4825,6 +4831,86 @@ uint32_t FM_GetCounter(t_Handle h_Fm, e_FmCounters counter)
return fman_get_counter(&fman_rg, fsl_counter);
}
#ifdef __aarch64__
void FM_ErrorDiag(t_Handle h_Fm, uint8_t hwPortId)
{
t_Fm *p = (t_Fm *)h_Fm;
uint32_t ps, epi, cld, npi, gs, ts, eie, dmsr, ievr;
uint32_t dmtah, dmtal;
/* FPM: port stall status + error pending */
ps = ioread32be(&p->p_FmFpmRegs->fmfp_ps[hwPortId]);
epi = ioread32be(&p->p_FmFpmRegs->fm_epi);
cld = ioread32be(&p->p_FmFpmRegs->fm_cld);
npi = ioread32be(&p->p_FmFpmRegs->fm_npi);
/* QMI: global status + task status + error */
gs = ioread32be(&p->p_FmQmiRegs->fmqm_gs);
ts = ioread32be(&p->p_FmQmiRegs->fmqm_ts);
eie = ioread32be(&p->p_FmQmiRegs->fmqm_eie);
/* DMA: status + last transfer address */
dmsr = ioread32be(&p->p_FmDmaRegs->fmdmsr);
dmtah = ioread32be(&p->p_FmDmaRegs->fmdmtah);
dmtal = ioread32be(&p->p_FmDmaRegs->fmdmtal);
/* BMI: interrupt event */
ievr = ioread32be(&p->p_FmBmiRegs->fmbm_ievr);
printf("fman: FPM port[%u] ps=0x%08x %s\n",
hwPortId, ps, (ps & 0x00800000) ? "STALLED" : "ok");
printf("fman: FPM epi=0x%08x npi=0x%08x cld=0x%08x\n", epi, npi, cld);
printf("fman: QMI gs=0x%08x ts=0x%08x eie=0x%08x\n", gs, ts, eie);
printf("fman: DMA sr=0x%08x addr=0x%08x%08x\n", dmsr, dmtah, dmtal);
printf("fman: BMI ievr=0x%08x\n", ievr);
}
void FM_TaskStatusDiag(t_Handle h_Fm, uint8_t hwPortId)
{
t_Fm *p = (t_Fm *)h_Fm;
uint32_t pp, ts;
int t, port_tasks = 0, total_active = 0;
uint8_t port_count[256];
int i, dumped = 0;
if (hwPortId == 0 || hwPortId > 63)
return;
memset(port_count, 0, sizeof(port_count));
/* Read configured tasks from BMI Port Parameters */
pp = ioread32be(&p->p_FmBmiRegs->fmbm_pp[hwPortId - 1]);
printf("fman: BMI pp[%u]=0x%08x (tasks=%u, extra=%u)\n",
hwPortId, pp,
((pp >> 24) & 0x3f) + 1,
(pp >> 16) & 0xf);
/* Scan FPM task status registers — dump first 8 non-zero raw values */
for (t = 0; t < 128; t++) {
ts = ioread32be(&p->p_FmFpmRegs->fmfp_ts[t]);
if (ts != 0) {
uint8_t owner = (ts >> 24) & 0xff;
total_active++;
port_count[owner]++;
if (owner == hwPortId)
port_tasks++;
if (dumped < 8) {
printf("fman: ts[%d]=0x%08x (owner=%u)\n", t, ts, owner);
dumped++;
}
}
}
/* Print per-port task breakdown for all ports with active tasks */
printf("fman: task breakdown:");
for (i = 0; i < 256; i++) {
if (port_count[i] > 0)
printf(" port%d=%d", i, port_count[i]);
}
printf(" (total=%d, port%u=%d)\n", total_active, hwPortId, port_tasks);
}
#endif
t_Error FM_ModifyCounter(t_Handle h_Fm, e_FmCounters counter, uint32_t val)
{
t_Fm *p_Fm = (t_Fm*)h_Fm;
@ -5191,7 +5277,7 @@ t_Handle FmGetPcd(t_Handle h_Fm)
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)
static void FM_ChangeClock(t_Handle h_Fm, int hardwarePortId)
{
int macId;
uint32_t event, rcr;

View file

@ -52,7 +52,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))
#define ASK_UCODE_PACKAGE_NUMBER 209
#define IS_OFFLOAD_PACKAGE(num) ((num == IP_OFFLOAD_PACKAGE_NUMBER) || (num == CAPWAP_OFFLOAD_PACKAGE_NUMBER) || (num >= ASK_UCODE_PACKAGE_NUMBER))
@ -189,7 +190,13 @@ typedef _Packed struct t_FmPcdCtrlParamsPage {
volatile uint32_t discardMask;
volatile uint8_t reserved3[4];
volatile uint32_t postBmiFetchNia;
#if (DPAA_VERSION >= 11)
volatile uint32_t internalFEBufferManagementIndexAddr;
volatile uint32_t internalFEBufferDepletionCounter;
volatile uint8_t reserved4[164];
#else
volatile uint8_t reserved4[172];
#endif
} _PackedType t_FmPcdCtrlParamsPage;

View file

@ -295,9 +295,9 @@ static uint32_t ReserveFqids(t_Qm *p_Qm, uint32_t size, uint32_t alignment, bool
static void FreeInitResources(t_Qm *p_Qm)
{
if (p_Qm->p_FqdBase)
if (p_Qm->p_FqdBase && !p_Qm->fqdExternal)
XX_FreeSmart(p_Qm->p_FqdBase);
if (p_Qm->p_PfdrBase)
if (p_Qm->p_PfdrBase && !p_Qm->pfdrExternal)
XX_FreeSmart(p_Qm->p_PfdrBase);
if (p_Qm->h_Session)
XX_IpcFreeSession(p_Qm->h_Session);
@ -705,6 +705,10 @@ t_Handle QM_Config(t_QmParam *p_QmParam)
p_Qm->p_QmDriverParams->pfdrThreshold = DEFAULT_pfdrThreshold;
p_Qm->p_QmDriverParams->sfdrThreshold = DEFAULT_sfdrThreshold;
p_Qm->p_QmDriverParams->pfdrBaseConstant = DEFAULT_pfdrBaseConstant;
p_Qm->p_QmDriverParams->p_FqdBaseExt = p_QmParam->p_FqdBase;
p_Qm->p_QmDriverParams->fqdSizeExt = p_QmParam->fqdSize;
p_Qm->p_QmDriverParams->p_PfdrBaseExt = p_QmParam->p_PfdrBase;
p_Qm->p_QmDriverParams->pfdrSizeExt = p_QmParam->pfdrSize;
for(i= 0;i<DPAA_MAX_NUM_OF_DC_PORTALS;i++)
p_Qm->p_QmDriverParams->dcPortalsParams[i].sendToSw =
(bool)((i < e_DPAA_DCPORTAL2) ? FALSE : TRUE);
@ -774,19 +778,32 @@ t_Error QM_Init(t_Handle h_Qm)
WRITE_UINT32(p_Qm->p_QmRegs->liodnr, (uint16_t)p_QmDriverParams->liodn);
/* FQD memory */
dsSize = (uint32_t)(p_QmDriverParams->totalNumOfFqids * FQD_ENTRY_SIZE);
LOG2(dsSize, exp);
if (!POWER_OF_2(dsSize)) (exp++);
dsSize = (uint32_t)(1 << exp);
if (dsSize < (4*KILOBYTE))
if (p_QmDriverParams->p_FqdBaseExt)
{
dsSize = (4*KILOBYTE);
/* Use pre-allocated FQD memory from caller (e.g. DT reserved-memory) */
p_Qm->p_FqdBase = p_QmDriverParams->p_FqdBaseExt;
p_Qm->fqdExternal = TRUE;
dsSize = p_QmDriverParams->fqdSizeExt;
LOG2(dsSize, exp);
if (!POWER_OF_2(dsSize)) (exp++);
dsSize = (uint32_t)(1 << exp);
}
p_Qm->p_FqdBase = XX_MallocSmart(dsSize, (int)p_QmDriverParams->fqdMemPartitionId, dsSize);
if (!p_Qm->p_FqdBase)
else
{
RETURN_ERROR(MAJOR, E_NO_MEMORY, ("FQD obj!!!"));
dsSize = (uint32_t)(p_QmDriverParams->totalNumOfFqids * FQD_ENTRY_SIZE);
LOG2(dsSize, exp);
if (!POWER_OF_2(dsSize)) (exp++);
dsSize = (uint32_t)(1 << exp);
if (dsSize < (4*KILOBYTE))
{
dsSize = (4*KILOBYTE);
LOG2(dsSize, exp);
}
p_Qm->p_FqdBase = XX_MallocSmart(dsSize, (int)p_QmDriverParams->fqdMemPartitionId, dsSize);
if (!p_Qm->p_FqdBase)
{
RETURN_ERROR(MAJOR, E_NO_MEMORY, ("FQD obj!!!"));
}
}
memset(p_Qm->p_FqdBase, 0, dsSize);
mb();
@ -799,29 +816,67 @@ t_Error QM_Init(t_Handle h_Qm)
WRITE_UINT32(p_Qm->p_QmRegs->fqd_bar, (uint32_t)phyAddr);
WRITE_UINT32(p_Qm->p_QmRegs->fqd_ar, AR_ENABLE | (exp - 1));
/* PFDR memory */
dsSize = (uint32_t)(p_QmDriverParams->rtFramesDepth * (PFDR_ENTRY_SIZE/3));
LOG2(dsSize, exp);
if (!POWER_OF_2(dsSize)) (exp++);
dsSize = (uint32_t)(1 << exp);
if (dsSize < (4*KILOBYTE))
/* Readback and verify FQD BAR programming */
{
dsSize = (4*KILOBYTE);
LOG2(dsSize, exp);
uint32_t rb_bare = GET_UINT32(p_Qm->p_QmRegs->fqd_bare);
uint32_t rb_bar = GET_UINT32(p_Qm->p_QmRegs->fqd_bar);
uint32_t rb_ar = GET_UINT32(p_Qm->p_QmRegs->fqd_ar);
XX_Print("QM FQD: va=%p phys=0x%08x%08x bare=0x%08x bar=0x%08x ar=0x%08x (exp=%d, size=0x%x)\n",
p_Qm->p_FqdBase,
(uint32_t)(phyAddr >> 32), (uint32_t)phyAddr,
rb_bare, rb_bar, rb_ar, exp, dsSize);
}
p_Qm->p_PfdrBase = XX_MallocSmart(dsSize, (int)p_QmDriverParams->pfdrMemPartitionId, dsSize);
if (!p_Qm->p_PfdrBase)
RETURN_ERROR(MAJOR, E_NO_MEMORY, ("PFDR obj!!!"));
/* PFDR memory */
if (p_QmDriverParams->p_PfdrBaseExt)
{
/* Use pre-allocated PFDR memory from caller */
p_Qm->p_PfdrBase = p_QmDriverParams->p_PfdrBaseExt;
p_Qm->pfdrExternal = TRUE;
dsSize = p_QmDriverParams->pfdrSizeExt;
LOG2(dsSize, exp);
if (!POWER_OF_2(dsSize)) (exp++);
dsSize = (uint32_t)(1 << exp);
}
else
{
dsSize = (uint32_t)(p_QmDriverParams->rtFramesDepth * (PFDR_ENTRY_SIZE/3));
LOG2(dsSize, exp);
if (!POWER_OF_2(dsSize)) (exp++);
dsSize = (uint32_t)(1 << exp);
if (dsSize < (4*KILOBYTE))
{
dsSize = (4*KILOBYTE);
LOG2(dsSize, exp);
}
p_Qm->p_PfdrBase = XX_MallocSmart(dsSize, (int)p_QmDriverParams->pfdrMemPartitionId, dsSize);
if (!p_Qm->p_PfdrBase)
RETURN_ERROR(MAJOR, E_NO_MEMORY, ("PFDR obj!!!"));
}
phyAddr = XX_VirtToPhys(p_Qm->p_PfdrBase);
WRITE_UINT32(p_Qm->p_QmRegs->pfdr_bare, ((uint32_t)(phyAddr >> 32) & 0x000000ff));
WRITE_UINT32(p_Qm->p_QmRegs->pfdr_bar, (uint32_t)phyAddr);
WRITE_UINT32(p_Qm->p_QmRegs->pfdr_ar, AR_ENABLE | (exp - 1));
/* Readback and verify PFDR BAR programming */
{
uint32_t rb_bare = GET_UINT32(p_Qm->p_QmRegs->pfdr_bare);
uint32_t rb_bar = GET_UINT32(p_Qm->p_QmRegs->pfdr_bar);
uint32_t rb_ar = GET_UINT32(p_Qm->p_QmRegs->pfdr_ar);
XX_Print("QM PFDR: va=%p phys=0x%08x%08x bare=0x%08x bar=0x%08x ar=0x%08x (exp=%d, size=0x%x)\n",
p_Qm->p_PfdrBase,
(uint32_t)(phyAddr >> 32), (uint32_t)phyAddr,
rb_bare, rb_bar, rb_ar, exp, dsSize);
XX_Print("QM PFDR init: pfdr_start=8, num=%d\n", dsSize / 64 - 8);
}
if (QmInitPfdr(p_Qm, 8, dsSize / 64 - 8) != E_OK)
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("PFDR init failed!!!"));
XX_Print("QM PFDR init: SUCCESS, pfdr_fpc=%d\n",
GET_UINT32(p_Qm->p_QmRegs->pfdr_fpc));
/* thresholds */
WRITE_UINT32(p_Qm->p_QmRegs->pfdr_fp_lwit, (p_Qm->p_QmDriverParams->pfdrThreshold & 0xffffff));
WRITE_UINT32(p_Qm->p_QmRegs->pfdr_cfg, p_Qm->p_QmDriverParams->pfdrBaseConstant);
@ -1037,6 +1092,27 @@ uint32_t QM_GetCounter(t_Handle h_Qm, e_QmCounters counter)
return 0;
}
#ifdef __aarch64__
void QM_ErrorDiag(t_Handle h_Qm, uint32_t *err_isr, uint32_t *ecsr,
uint32_t *ecir, uint32_t *pfdr_fpc, uint32_t *sfdr_in_use,
uint32_t *idle_stat, uint32_t *dcp0_cfg, uint32_t *dcp0_dlm_avg,
uint32_t *dcp_dd_ihrsr, uint32_t *dcp_dd_hasr)
{
t_Qm *p_Qm = (t_Qm *)h_Qm;
*err_isr = GET_UINT32(p_Qm->p_QmRegs->err_isr);
*ecsr = GET_UINT32(p_Qm->p_QmRegs->ecsr);
*ecir = GET_UINT32(p_Qm->p_QmRegs->ecir);
*pfdr_fpc = GET_UINT32(p_Qm->p_QmRegs->pfdr_fpc);
*sfdr_in_use = GET_UINT32(p_Qm->p_QmRegs->sfdr_in_use);
*idle_stat = GET_UINT32(p_Qm->p_QmRegs->idle_stat);
*dcp0_cfg = GET_UINT32(p_Qm->p_QmRegs->dcpConfRegs[0].cfg);
*dcp0_dlm_avg = GET_UINT32(p_Qm->p_QmRegs->dcpConfRegs[0].dlm_avg);
*dcp_dd_ihrsr = GET_UINT32(p_Qm->p_QmRegs->dcp_dd_ihrsr);
*dcp_dd_hasr = GET_UINT32(p_Qm->p_QmRegs->dcp_dd_hasr);
}
#endif
void QM_ErrorIsr(t_Handle h_Qm)
{
t_Qm *p_Qm = (t_Qm *)h_Qm;

View file

@ -373,7 +373,11 @@ typedef _Packed struct
#define QM_CGR_TARGET_DCP(portlaId) (QM_CGR_TARG_FIRST_DCPORTAL >> portlaId)
#define QM_DCP_CFG_ED 0x00000100
#ifdef __aarch64__
#define QM_DCP_CFG_ED 0x00001000 /* QMan v3 (LS1046A) */
#else
#define QM_DCP_CFG_ED 0x00000100 /* QMan v1/v2 (P5020) */
#endif
/*
#define CGR_VALID 0x80
#define CGR_VERB_INIT 0x50
@ -467,6 +471,10 @@ typedef struct {
uint32_t pfdrBaseConstant;
uint16_t liodn;
t_QmDcPortalParams dcPortalsParams[DPAA_MAX_NUM_OF_DC_PORTALS];
void *p_FqdBaseExt; /* Pre-allocated FQD, or NULL */
uint32_t fqdSizeExt;
void *p_PfdrBaseExt; /* Pre-allocated PFDR, or NULL */
uint32_t pfdrSizeExt;
} t_QmDriverParams;
typedef struct {
@ -479,6 +487,8 @@ typedef struct {
t_QmRegs *p_QmRegs;
uint32_t *p_FqdBase;
uint32_t *p_PfdrBase;
bool fqdExternal; /* FQD memory externally allocated */
bool pfdrExternal; /* PFDR memory externally allocated */
uint32_t exceptions;
t_QmExceptionsCallback *f_Exception;
t_Handle h_App;

View file

@ -1,6 +1,6 @@
/******************************************************************************
© 1995-2003, 2004, 2005-2011 Freescale Semiconductor, Inc.
<EFBFBD> 1995-2003, 2004, 2005-2011 Freescale Semiconductor, Inc.
All rights reserved.
This is proprietary source code of Freescale Semiconductor Inc.,
@ -64,22 +64,69 @@
* 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.
* On ARM64, encode the physical address shifted by 6 (64-byte alignment).
* XX_MallocSmart uses malloc() which returns DMAP addresses — virtual
* address encoding is not feasible because the DMAP-to-KVA offset exceeds
* 32 bits. Physical addresses on LS1046A are ≤10GB, so shifted by 6 they
* fit trivially in 32 bits (max ~160M). Reconstruction uses XX_PhysToVirt
* which returns the DMAP virtual address.
*
* On PowerPC, shift by 3 (8-byte alignment) relative to VM_MIN_KERNEL_ADDRESS.
*/
#if defined(__aarch64__)
#define QMAN_CTX_SHIFT 6
static inline uint32_t
aligned_int_from_ptr(const void *p)
{
physAddress_t pa;
uint32_t result;
pa = XX_VirtToPhys((void *)(uintptr_t)p);
KASSERT((pa & ((1 << QMAN_CTX_SHIFT) - 1)) == 0,
("Pointer %p (pa %#lx) is not %d-byte aligned!\n",
p, (unsigned long)pa, 1 << QMAN_CTX_SHIFT));
result = (uint32_t)(pa >> QMAN_CTX_SHIFT);
KASSERT((physAddress_t)result == (pa >> QMAN_CTX_SHIFT),
("%s: %p (pa %#lx) overflows 32-bit context\n",
__func__, p, (unsigned long)pa));
return (result);
}
static inline void *
ptr_from_aligned_int(uint32_t ctx)
{
physAddress_t pa;
pa = (physAddress_t)ctx << QMAN_CTX_SHIFT;
return (XX_PhysToVirt(pa));
}
#else
CTASSERT((VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) < (1ULL << 35));
#define QMAN_CTX_SHIFT 3
#define QMAN_CTX_BASE VM_MIN_KERNEL_ADDRESS
static inline uint32_t
aligned_int_from_ptr(const void *p)
{
uintptr_t ctx;
uint32_t result;
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));
KASSERT(ctx >= QMAN_CTX_BASE,
("%s: %p is below base %#lx\n", __func__, p,
(unsigned long)QMAN_CTX_BASE));
ctx -= QMAN_CTX_BASE;
KASSERT((ctx & ((1 << QMAN_CTX_SHIFT) - 1)) == 0,
("Pointer %p is not %d-byte aligned!\n", p, 1 << QMAN_CTX_SHIFT));
return (ctx >> 3);
result = (ctx >> QMAN_CTX_SHIFT);
KASSERT((uintptr_t)result == (ctx >> QMAN_CTX_SHIFT),
("%s: %p overflows 32-bit context (shifted %#lx)\n",
__func__, p, (unsigned long)(ctx >> QMAN_CTX_SHIFT)));
return (result);
}
static inline void *
@ -88,10 +135,59 @@ ptr_from_aligned_int(uint32_t ctx)
uintptr_t p;
p = ctx;
p = VM_MIN_KERNEL_ADDRESS + (p << 3);
p = QMAN_CTX_BASE + (p << QMAN_CTX_SHIFT);
return ((void *)p);
}
#endif
/*
* Copy a frame descriptor from CE portal memory (big-endian) to a native
* t_DpaaFD struct with proper byte-swapping. On big-endian (PowerPC),
* GET_UINT32 is a plain load so this is equivalent to a raw copy.
*
* On LE (ARM64), t_DpaaFD swaps the word order of the first 8 bytes:
* HW (BE): [liodn,bpid,elion,addrh][addrl_BE]
* t_DpaaFD LE: [addrl_LE][addrh,elion,bpid,liodn]
* So we swap word positions AND byte-swap each word (equivalent to bswap64).
*/
static inline void
qm_fd_read(t_DpaaFD *dst, const volatile struct qm_fd *src)
{
const volatile uint32_t *s = (const volatile uint32_t *)src;
uint32_t *d = (uint32_t *)dst;
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
d[0] = s[0];
d[1] = s[1];
#else
d[0] = GET_UINT32(s[1]);
d[1] = GET_UINT32(s[0]);
#endif
d[2] = GET_UINT32(s[2]);
d[3] = GET_UINT32(s[3]);
}
/*
* Copy a native t_DpaaFD to CE portal memory (big-endian) with proper
* byte-swapping. Reverse of qm_fd_read().
*/
static inline void
qm_fd_write(volatile struct qm_fd *dst, const t_DpaaFD *src)
{
volatile uint32_t *d = (volatile uint32_t *)dst;
const uint32_t *s = (const uint32_t *)src;
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
d[0] = s[0];
d[1] = s[1];
#else
WRITE_UINT32(d[0], s[1]);
WRITE_UINT32(d[1], s[0]);
#endif
WRITE_UINT32(d[2], s[2]);
WRITE_UINT32(d[3], s[3]);
}
static t_Error qman_volatile_dequeue(t_QmPortal *p_QmPortal,
struct qman_fq *p_Fq,
@ -152,7 +248,7 @@ static t_Error qman_create_fq(t_QmPortal *p_QmPortal,
/* Everything else is RECOVER support */
NCSW_PLOCK(p_QmPortal);
p_Mcc = qm_mc_start(p_QmPortal->p_LowQmPortal);
p_Mcc->queryfq.fqid = fqid;
WRITE_UINT32(p_Mcc->queryfq.fqid, fqid);
qm_mc_commit(p_QmPortal->p_LowQmPortal, QM_MCC_VERB_QUERYFQ);
while (!(p_Mcr = qm_mc_result(p_QmPortal->p_LowQmPortal))) ;
ASSERT_COND((p_Mcr->verb & QM_MCR_VERB_MASK) == QM_MCC_VERB_QUERYFQ);
@ -162,7 +258,7 @@ static t_Error qman_create_fq(t_QmPortal *p_QmPortal,
}
fqd = p_Mcr->queryfq.fqd;
p_Mcc = qm_mc_start(p_QmPortal->p_LowQmPortal);
p_Mcc->queryfq_np.fqid = fqid;
WRITE_UINT32(p_Mcc->queryfq_np.fqid, fqid);
qm_mc_commit(p_QmPortal->p_LowQmPortal, QM_MCC_VERB_QUERYFQ_NP);
while (!(p_Mcr = qm_mc_result(p_QmPortal->p_LowQmPortal))) ;
ASSERT_COND((p_Mcr->verb & QM_MCR_VERB_MASK) == QM_MCC_VERB_QUERYFQ_NP);
@ -245,7 +341,56 @@ static t_Error qman_init_fq(t_QmPortal *p_QmPortal,
return ERROR_CODE(E_BUSY);
}
p_Mcc = qm_mc_start(p_QmPortal->p_LowQmPortal);
#ifdef __aarch64__
/*
* Portal CE memory is big-endian on QorIQ ARM64 (LS1046A).
* Mem2IOCpy32 doesn't handle LE→BE conversion correctly for packed
* structs whose fields span 32-bit word boundaries — the byte-by-byte
* prefix and the unaligned shift-merge were designed for big-endian
* PowerPC only. Write each field individually using WRITE_UINTxx
* (out{8,16,32}rb) which byte-swap LE values to BE portal bytes.
*
* Bitfield-containing sub-fields (dest_wq, td_thresh) must be manually
* reconstructed in BE bit layout because GCC allocates bitfields from
* LSB on LE vs MSB on BE.
*/
WRITE_UINT8(p_Mcc->initfq.reserved1, 0);
WRITE_UINT16(p_Mcc->initfq.we_mask, p_Opts->we_mask);
WRITE_UINT32(p_Mcc->initfq.fqid, p_Opts->fqid);
WRITE_UINT16(p_Mcc->initfq.count, p_Opts->count);
/* FQD sub-struct */
WRITE_UINT8(p_Mcc->initfq.fqd.orpc, p_Opts->fqd.orpc);
WRITE_UINT8(p_Mcc->initfq.fqd.cgid, p_Opts->fqd.cgid);
WRITE_UINT16(p_Mcc->initfq.fqd.fq_ctrl, p_Opts->fqd.fq_ctrl);
{
/* dest_wq has bitfields channel:13 wq:3.
* BE bit layout: channel(bits15-3) wq(bits2-0). */
uint16_t dest_wq_be = ((uint16_t)(p_Opts->fqd.dest.channel & 0x1FFF) << 3) |
(p_Opts->fqd.dest.wq & 0x7);
WRITE_UINT16(p_Mcc->initfq.fqd.dest_wq, dest_wq_be);
}
{
/* reserved2:1 + ics_cred:15 are bare bitfields with no union accessor.
* Address the 16-bit word via the preceding dest_wq union. */
volatile uint16_t *p_ics = (volatile uint16_t *)&p_Mcc->initfq.fqd.dest_wq + 1;
/* BE bit layout: reserved2(bit15) ics_cred(bits14-0). reserved2=0. */
uint16_t ics_be = (uint16_t)(p_Opts->fqd.ics_cred & 0x7FFF);
WRITE_UINT16(*p_ics, ics_be);
}
{
/* td_thresh has bitfields reserved1:3 mant:8 exp:5.
* BE bit layout: reserved(bits15-13) mant(bits12-5) exp(bits4-0). */
uint16_t td_be = ((uint16_t)(p_Opts->fqd.td.mant & 0xFF) << 5) |
(p_Opts->fqd.td.exp & 0x1F);
WRITE_UINT16(p_Mcc->initfq.fqd.td_thresh, td_be);
}
WRITE_UINT32(p_Mcc->initfq.fqd.context_b, p_Opts->fqd.context_b);
WRITE_UINT32(p_Mcc->initfq.fqd.context_a.hi, p_Opts->fqd.context_a.hi);
WRITE_UINT32(p_Mcc->initfq.fqd.context_a.lo, p_Opts->fqd.context_a.lo);
/* reserved3[32] already zeroed by dcbz_64 in qm_mc_start */
#else
Mem2IOCpy32((void*)&p_Mcc->initfq, p_Opts, sizeof(struct qm_mcc_initfq));
#endif
qm_mc_commit(p_QmPortal->p_LowQmPortal, myverb);
while (!(p_Mcr = qm_mc_result(p_QmPortal->p_LowQmPortal))) ;
ASSERT_COND((p_Mcr->verb & QM_MCR_VERB_MASK) == myverb);
@ -253,17 +398,19 @@ static t_Error qman_init_fq(t_QmPortal *p_QmPortal,
if (res != QM_MCR_RESULT_OK) {
FQUNLOCK(p_Fq);
PUNLOCK(p_QmPortal);
RETURN_ERROR(MINOR, E_INVALID_STATE,("INITFQ failed: %s", mcr_result_str(res)));
RETURN_ERROR(MINOR, E_INVALID_STATE,("INITFQ failed: fqid=%d %s",
p_Fq->fqid, mcr_result_str(res)));
}
if (p_Mcc->initfq.we_mask & QM_INITFQ_WE_FQCTRL) {
if (p_Mcc->initfq.fqd.fq_ctrl & QM_FQCTRL_CGE)
/* Read flags back from the source struct, not portal CE (which is BE) */
if (p_Opts->we_mask & QM_INITFQ_WE_FQCTRL) {
if (p_Opts->fqd.fq_ctrl & QM_FQCTRL_CGE)
p_Fq->flags |= QMAN_FQ_STATE_CGR_EN;
else
p_Fq->flags &= ~QMAN_FQ_STATE_CGR_EN;
}
if (p_Mcc->initfq.we_mask & QM_INITFQ_WE_CGID)
p_Fq->cgr_groupid = p_Mcc->initfq.fqd.cgid;
if (p_Opts->we_mask & QM_INITFQ_WE_CGID)
p_Fq->cgr_groupid = p_Opts->fqd.cgid;
p_Fq->state = (flags & QMAN_INITFQ_FLAG_SCHED) ?
qman_fq_state_sched : qman_fq_state_parked;
FQUNLOCK(p_Fq);
@ -296,9 +443,9 @@ static t_Error qman_retire_fq(t_QmPortal *p_QmPortal,
goto out;
}
p_Mcc = qm_mc_start(p_QmPortal->p_LowQmPortal);
p_Mcc->alterfq.fqid = p_Fq->fqid;
WRITE_UINT32(p_Mcc->alterfq.fqid, p_Fq->fqid);
if (drain)
p_Mcc->alterfq.context_b = aligned_int_from_ptr(p_Fq);
WRITE_UINT32(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))) ;
@ -347,7 +494,7 @@ static t_Error qman_oos_fq(t_QmPortal *p_QmPortal, struct qman_fq *p_Fq)
return ERROR_CODE(E_BUSY);
}
p_Mcc = qm_mc_start(p_QmPortal->p_LowQmPortal);
p_Mcc->alterfq.fqid = p_Fq->fqid;
WRITE_UINT32(p_Mcc->alterfq.fqid, p_Fq->fqid);
qm_mc_commit(p_QmPortal->p_LowQmPortal, QM_MCC_VERB_ALTER_OOS);
while (!(p_Mcr = qm_mc_result(p_QmPortal->p_LowQmPortal))) ;
ASSERT_COND((p_Mcr->verb & QM_MCR_VERB_MASK) == QM_MCR_VERB_ALTER_OOS);
@ -383,7 +530,7 @@ static t_Error qman_schedule_fq(t_QmPortal *p_QmPortal, struct qman_fq *p_Fq)
return ERROR_CODE(E_BUSY);
}
p_Mcc = qm_mc_start(p_QmPortal->p_LowQmPortal);
p_Mcc->alterfq.fqid = p_Fq->fqid;
WRITE_UINT32(p_Mcc->alterfq.fqid, p_Fq->fqid);
qm_mc_commit(p_QmPortal->p_LowQmPortal, QM_MCC_VERB_ALTER_SCHED);
while (!(p_Mcr = qm_mc_result(p_QmPortal->p_LowQmPortal))) ;
ASSERT_COND((p_Mcr->verb & QM_MCR_VERB_MASK) == QM_MCR_VERB_ALTER_SCHED);
@ -607,14 +754,30 @@ mr_loop:
qmPortalMrPvbUpdate(p_QmPortal->p_LowQmPortal);
p_Msg = qm_mr_current(p_QmPortal->p_LowQmPortal);
if (p_Msg) {
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);
struct qman_fq *p_FqFqs = ptr_from_aligned_int(GET_UINT32(p_Msg->fq.contextB));
struct qman_fq *p_FqErn = ptr_from_aligned_int(GET_UINT32(p_Msg->ern.tag));
uint8_t verb =(uint8_t)(p_Msg->verb & QM_MR_VERB_TYPE_MASK);
t_QmRejectedFrameInfo rejectedFrameInfo;
t_DpaaFD mr_fd;
memset(&rejectedFrameInfo, 0, sizeof(t_QmRejectedFrameInfo));
if (!(verb & QM_MR_VERB_DC_ERN))
{
qm_fd_read(&mr_fd, &p_Msg->ern.fd);
{
static int ern_print_count;
if (ern_print_count++ < 20)
XX_Print("QM ERN: verb=0x%02x rc=0x%02x fqid=%u "
"fd_addr=0x%08x%08x fd_status=0x%x\n",
verb, p_Msg->ern.rc,
p_FqErn ? p_FqErn->fqid : 0,
DPAA_FD_GET_ADDRH(&mr_fd),
DPAA_FD_GET_ADDRL(&mr_fd),
DPAA_FD_GET_STATUS(&mr_fd));
}
if (DPAA_FD_GET_PHYS_ADDR(&mr_fd) == 0)
XX_Print("LoopMessageRing: ERN FD.addr=0 verb=0x%02x rc=0x%02x\n",
verb, p_Msg->ern.rc);
switch(p_Msg->ern.rc)
{
case(QM_MR_RC_CGR_TAILDROP):
@ -635,11 +798,17 @@ mr_loop:
REPORT_ERROR(MINOR, E_NOT_SUPPORTED, ("Unknown rejection code"));
}
if (!p_FqErn)
p_QmPortal->p_NullCB->ern(p_QmPortal->h_App, NULL, p_QmPortal, 0, (t_DpaaFD*)&p_Msg->ern.fd, &rejectedFrameInfo);
p_QmPortal->p_NullCB->ern(p_QmPortal->h_App, NULL, p_QmPortal, 0, &mr_fd, &rejectedFrameInfo);
else
p_FqErn->cb.ern(p_FqErn->h_App, p_FqErn->h_QmFqr, p_QmPortal, p_FqErn->fqidOffset, (t_DpaaFD*)&p_Msg->ern.fd, &rejectedFrameInfo);
p_FqErn->cb.ern(p_FqErn->h_App, p_FqErn->h_QmFqr, p_QmPortal, p_FqErn->fqidOffset, &mr_fd, &rejectedFrameInfo);
} else if (verb == QM_MR_VERB_DC_ERN)
{
{
static int dc_ern_count;
if (dc_ern_count++ < 20)
XX_Print("QM DC_ERN: fqid=%u\n",
p_FqErn ? p_FqErn->fqid : 0);
}
if (!p_FqErn)
p_QmPortal->p_NullCB->dc_ern(NULL, p_QmPortal, NULL, p_Msg);
else
@ -676,6 +845,7 @@ static void LoopDequeueRing(t_Handle h_QmPortal)
e_RxStoreResponse tmpRes;
t_QmPortal *p_QmPortal = (t_QmPortal *)h_QmPortal;
int prefetch = !(p_QmPortal->options & QMAN_PORTAL_FLAG_RSTASH);
t_DpaaFD fd;
while (res != qman_cb_dqrr_pause)
{
@ -685,12 +855,13 @@ static void LoopDequeueRing(t_Handle h_QmPortal)
p_Dq = qm_dqrr_current(p_QmPortal->p_LowQmPortal);
if (!p_Dq)
break;
p_Fq = ptr_from_aligned_int(p_Dq->contextB);
p_Fq = ptr_from_aligned_int(GET_UINT32(p_Dq->contextB));
qm_fd_read(&fd, &p_Dq->fd);
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
* one less thing to check in the critical path (SDQCR). */
tmpRes = p_Fq->cb.dqrr(p_Fq->h_App, p_Fq->h_QmFqr, p_QmPortal, p_Fq->fqidOffset, (t_DpaaFD*)&p_Dq->fd);
tmpRes = p_Fq->cb.dqrr(p_Fq->h_App, p_Fq->h_QmFqr, p_QmPortal, p_Fq->fqidOffset, &fd);
if (tmpRes == e_RX_STORE_RESPONSE_PAUSE)
res = qman_cb_dqrr_pause;
/* Check for VDQCR completion */
@ -706,14 +877,14 @@ static void LoopDequeueRing(t_Handle h_QmPortal)
{
/* Interpret 'dq' from the owner's perspective. */
/* use portal default handlers */
ASSERT_COND(p_Dq->fqid);
ASSERT_COND(GET_UINT32(p_Dq->fqid));
if (p_Fq)
{
tmpRes = p_Fq->cb.dqrr(p_Fq->h_App,
p_Fq->h_QmFqr,
p_QmPortal,
p_Fq->fqidOffset,
(t_DpaaFD*)&p_Dq->fd);
&fd);
if (tmpRes == e_RX_STORE_RESPONSE_PAUSE)
res = qman_cb_dqrr_pause;
else if (p_Fq->state == qman_fq_state_waiting_parked)
@ -724,8 +895,8 @@ static void LoopDequeueRing(t_Handle h_QmPortal)
tmpRes = p_QmPortal->p_NullCB->dqrr(p_QmPortal->h_App,
NULL,
p_QmPortal,
p_Dq->fqid,
(t_DpaaFD*)&p_Dq->fd);
GET_UINT32(p_Dq->fqid),
&fd);
if (tmpRes == e_RX_STORE_RESPONSE_PAUSE)
res = qman_cb_dqrr_pause;
}
@ -760,6 +931,7 @@ static void LoopDequeueRingDcaOptimized(t_Handle h_QmPortal)
enum qman_cb_dqrr_result res = qman_cb_dqrr_consume;
e_RxStoreResponse tmpRes;
t_QmPortal *p_QmPortal = (t_QmPortal *)h_QmPortal;
t_DpaaFD fd;
while (res != qman_cb_dqrr_pause)
{
@ -767,12 +939,13 @@ static void LoopDequeueRingDcaOptimized(t_Handle h_QmPortal)
p_Dq = qm_dqrr_current(p_QmPortal->p_LowQmPortal);
if (!p_Dq)
break;
p_Fq = ptr_from_aligned_int(p_Dq->contextB);
p_Fq = ptr_from_aligned_int(GET_UINT32(p_Dq->contextB));
qm_fd_read(&fd, &p_Dq->fd);
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
* one less thing to check in the critical path (SDQCR). */
tmpRes = p_Fq->cb.dqrr(p_Fq->h_App, p_Fq->h_QmFqr, p_QmPortal, p_Fq->fqidOffset, (t_DpaaFD*)&p_Dq->fd);
tmpRes = p_Fq->cb.dqrr(p_Fq->h_App, p_Fq->h_QmFqr, p_QmPortal, p_Fq->fqidOffset, &fd);
if (tmpRes == e_RX_STORE_RESPONSE_PAUSE)
res = qman_cb_dqrr_pause;
/* Check for VDQCR completion */
@ -788,14 +961,14 @@ static void LoopDequeueRingDcaOptimized(t_Handle h_QmPortal)
{
/* Interpret 'dq' from the owner's perspective. */
/* use portal default handlers */
ASSERT_COND(p_Dq->fqid);
ASSERT_COND(GET_UINT32(p_Dq->fqid));
if (p_Fq)
{
tmpRes = p_Fq->cb.dqrr(p_Fq->h_App,
p_Fq->h_QmFqr,
p_QmPortal,
p_Fq->fqidOffset,
(t_DpaaFD*)&p_Dq->fd);
&fd);
if (tmpRes == e_RX_STORE_RESPONSE_PAUSE)
res = qman_cb_dqrr_pause;
else if (p_Fq->state == qman_fq_state_waiting_parked)
@ -806,8 +979,8 @@ static void LoopDequeueRingDcaOptimized(t_Handle h_QmPortal)
tmpRes = p_QmPortal->p_NullCB->dqrr(p_QmPortal->h_App,
NULL,
p_QmPortal,
p_Dq->fqid,
(t_DpaaFD*)&p_Dq->fd);
GET_UINT32(p_Dq->fqid),
&fd);
if (tmpRes == e_RX_STORE_RESPONSE_PAUSE)
res = qman_cb_dqrr_pause;
}
@ -834,6 +1007,7 @@ static void LoopDequeueRingOptimized(t_Handle h_QmPortal)
enum qman_cb_dqrr_result res = qman_cb_dqrr_consume;
e_RxStoreResponse tmpRes;
t_QmPortal *p_QmPortal = (t_QmPortal *)h_QmPortal;
t_DpaaFD fd;
while (res != qman_cb_dqrr_pause)
{
@ -841,12 +1015,13 @@ static void LoopDequeueRingOptimized(t_Handle h_QmPortal)
p_Dq = qm_dqrr_current(p_QmPortal->p_LowQmPortal);
if (!p_Dq)
break;
p_Fq = ptr_from_aligned_int(p_Dq->contextB);
p_Fq = ptr_from_aligned_int(GET_UINT32(p_Dq->contextB));
qm_fd_read(&fd, &p_Dq->fd);
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
* one less thing to check in the critical path (SDQCR). */
tmpRes = p_Fq->cb.dqrr(p_Fq->h_App, p_Fq->h_QmFqr, p_QmPortal, p_Fq->fqidOffset, (t_DpaaFD*)&p_Dq->fd);
tmpRes = p_Fq->cb.dqrr(p_Fq->h_App, p_Fq->h_QmFqr, p_QmPortal, p_Fq->fqidOffset, &fd);
if (tmpRes == e_RX_STORE_RESPONSE_PAUSE)
res = qman_cb_dqrr_pause;
/* Check for VDQCR completion */
@ -862,14 +1037,14 @@ static void LoopDequeueRingOptimized(t_Handle h_QmPortal)
{
/* Interpret 'dq' from the owner's perspective. */
/* use portal default handlers */
ASSERT_COND(p_Dq->fqid);
ASSERT_COND(GET_UINT32(p_Dq->fqid));
if (p_Fq)
{
tmpRes = p_Fq->cb.dqrr(p_Fq->h_App,
p_Fq->h_QmFqr,
p_QmPortal,
p_Fq->fqidOffset,
(t_DpaaFD*)&p_Dq->fd);
&fd);
if (tmpRes == e_RX_STORE_RESPONSE_PAUSE)
res = qman_cb_dqrr_pause;
else if (p_Fq->state == qman_fq_state_waiting_parked)
@ -880,8 +1055,8 @@ static void LoopDequeueRingOptimized(t_Handle h_QmPortal)
tmpRes = p_QmPortal->p_NullCB->dqrr(p_QmPortal->h_App,
NULL,
p_QmPortal,
p_Dq->fqid,
(t_DpaaFD*)&p_Dq->fd);
GET_UINT32(p_Dq->fqid),
&fd);
if (tmpRes == e_RX_STORE_RESPONSE_PAUSE)
res = qman_cb_dqrr_pause;
}
@ -909,6 +1084,26 @@ static void portal_isr(void *ptr)
DBG(TRACE, ("software-portal %d got interrupt", p_QmPortal->p_LowQmPortal->config.cpu));
#ifdef __aarch64__
{
/* Per-portal ISR invocation counters (max 16 portals) */
static volatile uint32_t portal_isr_cnt[16];
int cpu = p_QmPortal->p_LowQmPortal->config.cpu;
uint32_t cnt;
if (cpu >= 0 && cpu < 16)
cnt = ++portal_isr_cnt[cpu];
else
cnt = 0;
if (cnt <= 10 || (cnt % 1000 == 0))
printf("qman: portal_isr cpu=%d count=%u ISR=0x%x IER=0x%x "
"dqrr_fill=%u\n",
cpu, cnt,
qm_isr_status_read(p_QmPortal->p_LowQmPortal),
enableEvents,
(unsigned)p_QmPortal->p_LowQmPortal->dqrr.fill);
}
#endif
event |= (qm_isr_status_read(p_QmPortal->p_LowQmPortal) &
enableEvents);
@ -930,7 +1125,7 @@ static t_Error qman_query_fq_np(t_QmPortal *p_QmPortal, struct qman_fq *p_Fq, st
NCSW_PLOCK(p_QmPortal);
p_Mcc = qm_mc_start(p_QmPortal->p_LowQmPortal);
p_Mcc->queryfq_np.fqid = p_Fq->fqid;
WRITE_UINT32(p_Mcc->queryfq_np.fqid, p_Fq->fqid);
qm_mc_commit(p_QmPortal->p_LowQmPortal, QM_MCC_VERB_QUERYFQ_NP);
while (!(p_Mcr = qm_mc_result(p_QmPortal->p_LowQmPortal))) ;
ASSERT_COND((p_Mcr->verb & QM_MCR_VERB_MASK) == QM_MCR_VERB_QUERYFQ_NP);
@ -1198,6 +1393,105 @@ drain_loop:
}
}
/*
* Clean up stale frame queues left by a previous boot (e.g. U-Boot).
* The QMan hardware's FQD cache may retain FQs in SCHED/ACTIVE state
* across a soft reboot. If not retired, these stale FQs will produce
* DQRR entries with invalid contextB pointers, causing a page fault.
*
* Called during portal creation after DQRR, MR, and MC are initialized
* but before ISR setup and SDQCR enable.
*/
#define CLEANUP_MAX_FQID 256
static void qman_cleanup_stale_fqs(struct qm_portal *portal)
{
static volatile int cleanup_done = 0;
struct qm_mc_command *mcc;
struct qm_mc_result *mcr;
uint32_t fqid;
int cleaned = 0;
uint8_t state, res;
/* All portals see the same global FQ state — only clean up once.
* Running on subsequent portals would retire FQs that drivers
* legitimately created after the first portal's cleanup. */
if (atomic_cmpset_int(&cleanup_done, 0, 1) == 0)
return;
/* Drain any stale DQRR entries from previous boot */
while (qmPortalDqrrPvbUpdate(portal),
qm_dqrr_current(portal) != NULL) {
qm_dqrr_next(portal);
qmPortalDqrrCciConsume(portal, 1);
}
/* Drain any stale MR entries from previous boot */
while (qmPortalMrPvbUpdate(portal),
qm_mr_current(portal) != NULL) {
qm_mr_next(portal);
qmPortalMrCciConsume(portal, 1);
}
/* Retire stale FQs via MC commands */
for (fqid = 0; fqid < CLEANUP_MAX_FQID; fqid++) {
/* QUERYFQ_NP */
mcc = qm_mc_start(portal);
WRITE_UINT32(mcc->queryfq_np.fqid, fqid);
qm_mc_commit(portal, QM_MCC_VERB_QUERYFQ_NP);
while (!(mcr = qm_mc_result(portal)))
;
res = mcr->result;
if (res != QM_MCR_RESULT_OK)
continue;
state = mcr->queryfq_np.state & QM_MCR_NP_STATE_MASK;
if (state == QM_MCR_NP_STATE_OOS)
continue;
if (state == QM_MCR_NP_STATE_RETIRED)
goto do_oos;
/* ALTER_RETIRE */
mcc = qm_mc_start(portal);
WRITE_UINT32(mcc->alterfq.fqid, fqid);
qm_mc_commit(portal, QM_MCC_VERB_ALTER_RETIRE);
while (!(mcr = qm_mc_result(portal)))
;
res = mcr->result;
if (res == QM_MCR_RESULT_PENDING) {
/* Wait for FQRNI on MR */
int timeout = 10000;
while (timeout--) {
qmPortalMrPvbUpdate(portal);
if (qm_mr_current(portal) != NULL) {
qm_mr_next(portal);
qmPortalMrCciConsume(portal, 1);
break;
}
}
} else if (res != QM_MCR_RESULT_OK) {
XX_Print("qman_cleanup: fqid %u retire failed 0x%02x\n",
fqid, res);
continue;
}
do_oos:
/* ALTER_OOS */
mcc = qm_mc_start(portal);
WRITE_UINT32(mcc->alterfq.fqid, fqid);
qm_mc_commit(portal, QM_MCC_VERB_ALTER_OOS);
while (!(mcr = qm_mc_result(portal)))
;
res = mcr->result;
if (res != QM_MCR_RESULT_OK) {
/* OOS may fail if FQ has pending frames.
* RETIRED state is safe — FQ won't be scheduled. */
XX_Print("qman_cleanup: fqid %u OOS failed 0x%02x "
"(left retired)\n", fqid, res);
}
cleaned++;
}
if (cleaned)
printf("qman: retired %d stale FQs\n", cleaned);
}
static t_Error qman_create_portal(t_QmPortal *p_QmPortal,
uint32_t flags,
uint32_t sdqcrFlags,
@ -1230,6 +1524,8 @@ static t_Error qman_create_portal(t_QmPortal *p_QmPortal,
REPORT_ERROR(MAJOR, E_INVALID_STATE, ("MC initialization failed"));
goto fail_mc;
}
/* Clean up stale FQs from previous boot before enabling SDQCR */
qman_cleanup_stale_fqs(p_QmPortal->p_LowQmPortal);
if (qm_isr_init(p_QmPortal->p_LowQmPortal)) {
REPORT_ERROR(MAJOR, E_INVALID_STATE, ("ISR initialization failed"));
goto fail_isr;
@ -1272,7 +1568,37 @@ goto fail_dqrr_mr_empty;
goto fail_dqrr_mr_empty;
}
qm_isr_disable_write(p_QmPortal->p_LowQmPortal, 0);
/*
* Inhibit ISR before enabling SDQCR — stale FQs from a previous boot
* (e.g. Linux) may still be in SCHED state. Enabling SDQCR causes
* the hardware to push their DQRR entries immediately. Drain them
* here before the ISR can see them (their contextB pointers are
* garbage in this kernel's address space).
*/
qm_isr_inhibit(p_QmPortal->p_LowQmPortal);
qm_dqrr_sdqcr_set(p_QmPortal->p_LowQmPortal, sdqcrFlags);
{
int idle = 0;
while (idle < 1000) {
qmPortalDqrrPvbUpdate(p_QmPortal->p_LowQmPortal);
if (qm_dqrr_current(p_QmPortal->p_LowQmPortal) != NULL) {
qm_dqrr_next(p_QmPortal->p_LowQmPortal);
qmPortalDqrrCciConsume(p_QmPortal->p_LowQmPortal, 1);
idle = 0;
} else {
XX_UDelay(10);
idle++;
}
}
/* Also drain any MR entries that appeared */
while (qmPortalMrPvbUpdate(p_QmPortal->p_LowQmPortal),
qm_mr_current(p_QmPortal->p_LowQmPortal) != NULL) {
qm_mr_next(p_QmPortal->p_LowQmPortal);
qmPortalMrCciConsume(p_QmPortal->p_LowQmPortal, 1);
}
}
qm_isr_status_clear(p_QmPortal->p_LowQmPortal, 0xffffffff);
qm_isr_uninhibit(p_QmPortal->p_LowQmPortal);
return E_OK;
fail_dqrr_mr_empty:
fail_eqcr_empty:
@ -1341,8 +1667,8 @@ static t_Error qman_orp_update(t_QmPortal *p_QmPortal,
else
/* No need to check 4 QMAN_ENQUEUE_FLAG_HOLE */
orpSeqnum &= ~QM_EQCR_SEQNUM_NESN;
p_Eq->seqnum = orpSeqnum;
p_Eq->orp = orpId;
WRITE_UINT16(p_Eq->seqnum, orpSeqnum);
WRITE_UINT32(p_Eq->orp, orpId);
qmPortalEqcrPvbCommit(p_QmPortal->p_LowQmPortal, (uint8_t)QM_EQCR_VERB_ORP);
PUNLOCK(p_QmPortal);
@ -1394,7 +1720,7 @@ static t_Error QmPortalUnregisterCg(t_Handle h_QmPortal, uint8_t cgId)
if(!(p_QmPortal->cgrs[0].q.__state[cgId/32] & (0x80000000 >> (cgId % 32))))
RETURN_ERROR(MINOR, E_BUSY, ("CG is not in use"));
p_QmPortal->cgrs[0].q.__state[cgId/32] &= ~0x80000000 >> (cgId % 32);
p_QmPortal->cgrs[0].q.__state[cgId/32] &= ~(0x80000000 >> (cgId % 32));
p_QmPortal->cgsHandles[cgId] = NULL;
return E_OK;
@ -1494,7 +1820,6 @@ static t_Error QmPortalPullFrame(t_Handle h_QmPortal, uint32_t pdqcr, t_DpaaFD *
t_QmPortal *p_QmPortal = (t_QmPortal *)h_QmPortal;
struct qm_dqrr_entry *p_Dq;
int prefetch;
uint32_t *p_Dst, *p_Src;
ASSERT_COND(p_QmPortal);
ASSERT_COND(p_Frame);
@ -1515,13 +1840,8 @@ 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;
ASSERT_COND(p_Dq->fqid);
p_Dst = (uint32_t *)p_Frame;
p_Src = (uint32_t *)&p_Dq->fd;
p_Dst[0] = p_Src[0];
p_Dst[1] = p_Src[1];
p_Dst[2] = p_Src[2];
p_Dst[3] = p_Src[3];
ASSERT_COND(GET_UINT32(p_Dq->fqid));
qm_fd_read(p_Frame, &p_Dq->fd);
if (p_QmPortal->options & QMAN_PORTAL_FLAG_DCA)
{
qmPortalDqrrDcaConsume1ptr(p_QmPortal->p_LowQmPortal,
@ -1792,6 +2112,12 @@ t_Error QM_PORTAL_AddPoolChannel(t_Handle h_QmPortal, uint8_t poolChannelId)
sdqcrFlags |= QM_SDQCR_CHANNELS_POOL(poolChannelId+1);
qm_dqrr_sdqcr_set(p_QmPortal->p_LowQmPortal, sdqcrFlags);
#ifdef __aarch64__
XX_Print("QM_PORTAL_AddPoolChannel: cpu=%d poolCh=%u SDQCR=0x%08x\n",
p_QmPortal->p_LowQmPortal->config.cpu,
(unsigned)poolChannelId, sdqcrFlags);
#endif
return E_OK;
}
@ -1820,6 +2146,51 @@ t_Error QM_PORTAL_Poll(t_Handle h_QmPortal, e_QmPortalPollSource source)
return E_OK;
}
#ifdef __aarch64__
/*
* Read DQRR state from hardware for diagnostics.
* Returns software PI/CI/fill and hardware PI/CI registers.
*/
void QM_PORTAL_DqrrDiag(t_Handle h_QmPortal, uint8_t *sw_pi, uint8_t *sw_ci,
uint8_t *sw_fill, uint8_t *hw_pi, uint8_t *hw_ci)
{
t_QmPortal *p_QmPortal = (t_QmPortal *)h_QmPortal;
struct qm_portal *portal = p_QmPortal->p_LowQmPortal;
struct qm_dqrr *dqrr = &portal->dqrr;
*sw_pi = dqrr->pi;
*sw_ci = dqrr->ci;
*sw_fill = dqrr->fill;
*hw_pi = (uint8_t)(qm_in(DQRR_PI_CINH) & (QM_DQRR_SIZE - 1));
*hw_ci = (uint8_t)(qm_in(DQRR_CI_CINH) & (QM_DQRR_SIZE - 1));
}
void QM_PORTAL_IsrDiag(t_Handle h_QmPortal, uint32_t *isr, uint32_t *ier,
uint32_t *iir)
{
t_QmPortal *p = (t_QmPortal *)h_QmPortal;
*isr = qm_isr_status_read(p->p_LowQmPortal);
*ier = qm_isr_enable_read(p->p_LowQmPortal);
*iir = __qm_isr_read(p->p_LowQmPortal, qm_isr_inhibit);
}
void QM_PORTAL_Inhibit(t_Handle h_QmPortal)
{
t_QmPortal *p = (t_QmPortal *)h_QmPortal;
qm_isr_inhibit(p->p_LowQmPortal);
}
void QM_PORTAL_Uninhibit(t_Handle h_QmPortal)
{
t_QmPortal *p = (t_QmPortal *)h_QmPortal;
qm_isr_status_clear(p->p_LowQmPortal, 0xffffffff);
qm_isr_uninhibit(p->p_LowQmPortal);
}
#endif
t_Error QM_PORTAL_PollFrame(t_Handle h_QmPortal, t_QmPortalFrameInfo *p_frameInfo)
{
t_QmPortal *p_QmPortal = (t_QmPortal *)h_QmPortal;
@ -1842,21 +2213,21 @@ t_Error QM_PORTAL_PollFrame(t_Handle h_QmPortal, t_QmPortalFrameInfo *p_frameInf
PUNLOCK(p_QmPortal);
return ERROR_CODE(E_EMPTY);
}
p_Fq = ptr_from_aligned_int(p_Dq->contextB);
ASSERT_COND(p_Dq->fqid);
p_Fq = ptr_from_aligned_int(GET_UINT32(p_Dq->contextB));
ASSERT_COND(GET_UINT32(p_Dq->fqid));
if (p_Fq)
{
p_frameInfo->h_App = p_Fq->h_App;
p_frameInfo->h_QmFqr = p_Fq->h_QmFqr;
p_frameInfo->fqidOffset = p_Fq->fqidOffset;
memcpy((void*)&p_frameInfo->frame, (void*)&p_Dq->fd, sizeof(t_DpaaFD));
qm_fd_read(&p_frameInfo->frame, &p_Dq->fd);
}
else
{
p_frameInfo->h_App = p_QmPortal->h_App;
p_frameInfo->h_QmFqr = NULL;
p_frameInfo->fqidOffset = p_Dq->fqid;
memcpy((void*)&p_frameInfo->frame, (void*)&p_Dq->fd, sizeof(t_DpaaFD));
p_frameInfo->fqidOffset = GET_UINT32(p_Dq->fqid);
qm_fd_read(&p_frameInfo->frame, &p_Dq->fd);
}
if (p_QmPortal->options & QMAN_PORTAL_FLAG_DCA) {
qmPortalDqrrDcaConsume1ptr(p_QmPortal->p_LowQmPortal,
@ -2138,7 +2509,6 @@ t_Error QM_FQR_Enqueue(t_Handle h_QmFqr, t_Handle h_QmPortal, uint32_t fqidOffse
t_QmFqr *p_QmFqr = (t_QmFqr *)h_QmFqr;
t_QmPortal *p_QmPortal;
struct qm_eqcr_entry *p_Eq;
uint32_t *p_Dst, *p_Src;
const struct qman_fq *p_Fq;
SANITY_CHECK_RETURN_ERROR(p_QmFqr, E_INVALID_HANDLE);
@ -2171,19 +2541,9 @@ t_Error QM_FQR_Enqueue(t_Handle h_QmFqr, t_Handle h_QmPortal, uint32_t fqidOffse
return ERROR_CODE(E_BUSY);
}
p_Eq->fqid = p_Fq->fqid;
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
* registers, and comes up with instruction-waste galore. This will do
* until we can rework the function for better code-generation. */
p_Dst = (uint32_t *)&p_Eq->fd;
p_Src = (uint32_t *)p_Frame;
p_Dst[0] = p_Src[0];
p_Dst[1] = p_Src[1];
p_Dst[2] = p_Src[2];
p_Dst[3] = p_Src[3];
WRITE_UINT32(p_Eq->fqid, p_Fq->fqid);
WRITE_UINT32(p_Eq->tag, aligned_int_from_ptr(p_Fq));
qm_fd_write(&p_Eq->fd, p_Frame);
qmPortalEqcrPvbCommit(p_QmPortal->p_LowQmPortal,
(uint8_t)(QM_EQCR_VERB_CMD_ENQUEUE/* |
@ -2193,6 +2553,33 @@ t_Error QM_FQR_Enqueue(t_Handle h_QmFqr, t_Handle h_QmPortal, uint32_t fqidOffse
return E_OK;
}
t_Error QM_PORTAL_EnqueueFqid(t_Handle h_QmPortal, uint32_t fqid, t_DpaaFD *p_Frame)
{
t_QmPortal *p_QmPortal;
struct qm_eqcr_entry *p_Eq;
SANITY_CHECK_RETURN_ERROR(h_QmPortal, E_INVALID_HANDLE);
p_QmPortal = (t_QmPortal *)h_QmPortal;
NCSW_PLOCK(p_QmPortal);
p_Eq = try_eq_start(p_QmPortal);
if (!p_Eq)
{
PUNLOCK(p_QmPortal);
return ERROR_CODE(E_BUSY);
}
WRITE_UINT32(p_Eq->fqid, fqid);
WRITE_UINT32(p_Eq->tag, 0);
qm_fd_write(&p_Eq->fd, p_Frame);
qmPortalEqcrPvbCommit(p_QmPortal->p_LowQmPortal,
(uint8_t)QM_EQCR_VERB_CMD_ENQUEUE);
PUNLOCK(p_QmPortal);
return E_OK;
}
t_Error QM_FQR_PullFrame(t_Handle h_QmFqr, t_Handle h_QmPortal, uint32_t fqidOffset, t_DpaaFD *p_Frame)
{

View file

@ -51,6 +51,30 @@
/***************************/
/* Cache-inhibited register offsets */
#if defined(__aarch64__)
/*
* ARM64 Layerscape (LS1046A etc.): CI space is 16KB per portal.
* Register offsets differ from PowerPC.
* See Linux drivers/soc/fsl/qbman/qman.c for reference.
*/
#define REG_EQCR_PI_CINH 0x3000
#define REG_EQCR_CI_CINH 0x3040
#define REG_EQCR_ITR 0x3080
#define REG_DQRR_PI_CINH 0x3100
#define REG_DQRR_CI_CINH 0x3140
#define REG_DQRR_ITR 0x3180
#define REG_DQRR_DCAP 0x31C0
#define REG_DQRR_SDQCR 0x3200
#define REG_DQRR_VDQCR 0x3240
#define REG_DQRR_PDQCR 0x3280
#define REG_MR_PI_CINH 0x3300
#define REG_MR_CI_CINH 0x3340
#define REG_MR_ITR 0x3380
#define REG_CFG 0x3500
#define REG_ISR 0x3600
#define REG_ITPR 0x3740
#define QM_ISR_SHIFT 6 /* ISR/IER/ISDR/IIR stride: 64 bytes */
#else /* PowerPC */
#define REG_EQCR_PI_CINH 0x0000
#define REG_EQCR_CI_CINH 0x0004
#define REG_EQCR_ITR 0x0008
@ -66,22 +90,29 @@
#define REG_MR_ITR 0x0088
#define REG_CFG 0x0100
#define REG_ISR 0x0e00
#define REG_IER 0x0e04
#define REG_ISDR 0x0e08
#define REG_IIR 0x0e0c
#define REG_ITPR 0x0e14
#define QM_ISR_SHIFT 2 /* ISR/IER/ISDR/IIR stride: 4 bytes */
#endif
/* Cache-enabled register offsets */
#define CL_EQCR 0x0000
#define CL_DQRR 0x1000
#define CL_MR 0x2000
#define CL_EQCR_PI_CENA 0x3000
#if defined(__aarch64__)
#define CL_EQCR_CI_CENA 0x3040
#define CL_DQRR_PI_CENA 0x3100
#define CL_DQRR_CI_CENA 0x3140
#define CL_MR_PI_CENA 0x3300
#define CL_MR_CI_CENA 0x3340
#else /* PowerPC */
#define CL_EQCR_CI_CENA 0x3100
#define CL_DQRR_PI_CENA 0x3200
#define CL_DQRR_CI_CENA 0x3300
#define CL_MR_PI_CENA 0x3400
#define CL_MR_CI_CENA 0x3500
#define CL_RORI_CENA 0x3600
#endif
#define CL_CR 0x3800
#define CL_RR0 0x3900
#define CL_RR1 0x3940
@ -300,11 +331,18 @@ static __inline__ struct qm_eqcr_entry *qm_eqcr_pend_and_next(struct qm_portal *
}
#ifdef QM_CHECKING
/*
* EQCR entries live in CE portal memory (big-endian on hardware).
* On ARM64, WRITE_UINT32 byte-swaps values for the hardware, so we
* must use GET_UINT32 to read them back in host order for validation.
*/
#define EQCR_COMMIT_CHECKS(eqcr) \
do { \
ASSERT_COND(eqcr->busy); \
ASSERT_COND(eqcr->cursor->orp == (eqcr->cursor->orp & 0x00ffffff)); \
ASSERT_COND(eqcr->cursor->fqid == (eqcr->cursor->fqid & 0x00ffffff)); \
ASSERT_COND(GET_UINT32(eqcr->cursor->orp) == \
(GET_UINT32(eqcr->cursor->orp) & 0x00ffffff)); \
ASSERT_COND(GET_UINT32(eqcr->cursor->fqid) == \
(GET_UINT32(eqcr->cursor->fqid) & 0x00ffffff)); \
} while(0)
#else
@ -878,6 +916,7 @@ static __inline__ void qm_mr_current_prefetch(struct qm_portal *portal)
{
register struct qm_mr *mr = &portal->mr;
dcbt_ro(mr->cursor);
(void)mr;
}
static __inline__ struct qm_mr_entry *qm_mr_current(struct qm_portal *portal)
@ -1139,10 +1178,10 @@ static __inline__ void qm_isr_set_iperiod(struct qm_portal *portal, uint16_t ipe
static __inline__ uint32_t __qm_isr_read(struct qm_portal *portal, enum qm_isr_reg n)
{
return __qm_in(&portal->addr, REG_ISR + (n << 2));
return __qm_in(&portal->addr, REG_ISR + (n << QM_ISR_SHIFT));
}
static __inline__ void __qm_isr_write(struct qm_portal *portal, enum qm_isr_reg n, uint32_t val)
{
__qm_out(&portal->addr, REG_ISR + (n << 2), val);
__qm_out(&portal->addr, REG_ISR + (n << QM_ISR_SHIFT), val);
}

View file

@ -56,6 +56,39 @@
* execution reordering with respect to other code/instructions that manipulate
* the same cacheline. */
#if defined(__aarch64__)
/*
* ARM64 cache operations.
*
* Portal CE region is mapped Normal Non-Cacheable (matching Linux's
* MEMREMAP_WC), so stores go directly to hardware. However, dcbf is
* also used on cacheable DMA memory (FQD, PFDR) in qm.c — there we
* need real cache clean to make CPU writes visible to QMan hardware.
*
* dc cvac (clean by VA to PoC) is the ARM64 equivalent of PPC dcbf.
* On NC addresses it's a harmless no-op; on cached addresses it writes
* dirty lines back to memory.
*
* dc zva MUST NOT be used on portal NC memory — it generates a special
* bus transaction that can hang the interconnect. Use memset instead.
*/
#define lwsync() __asm__ __volatile__ ("dmb ish" : : : "memory")
#define dcbf(addr) do { \
__asm__ __volatile__ ("dc cvac, %0" : : "r"(addr) : "memory"); \
__asm__ __volatile__ ("dsb st" : : : "memory"); \
} while(0)
#define dcbi(p) __asm__ __volatile__ ("dsb sy" : : : "memory")
#define dcbt_ro(addr) do { } while(0)
#define dcbt_rw(addr) do { } while(0)
#define dcbz_64(p) do { memset((p), 0, 64); } while(0)
#define dcbf_64(p) do { \
__asm__ __volatile__ ("dc cvac, %0" : : "r"(p) : "memory"); \
__asm__ __volatile__ ("dsb st" : : : "memory"); \
} while(0)
#define dcbit_ro(p) do { } while(0)
#else /* PowerPC */
#define dcbf(addr) \
do { \
__asm__ __volatile__ ("dcbf 0, %0" : : "r" (addr)); \
@ -132,6 +165,8 @@
#define dcbi(p) dcbf(p)
#endif /* __aarch64__ */
struct qm_addr {
void *addr_ce; /* cache-enabled */
void *addr_ci; /* cache-inhibited */

View file

@ -0,0 +1,86 @@
/*-
* Copyright (c) 2026 Mono Technologies 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 THE AUTHOR OR CONTRIBUTORS 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.
*/
/*
* DPAA1 / NetCommSW build flags for ARM64 (LS1046A).
*
* Equivalent to dflags.h (which targets PowerPC e500mc/P5020).
* Force-included before every ncsw source file via config.dpaa_arm64.
*/
#ifndef DFLAGS_ARM64_H_
#define DFLAGS_ARM64_H_
#include "opt_platform.h"
#include "events_mapping.h"
/*
* Core selection: ARM64 (Cortex-A72).
* The PPC path uses NCSW_PPC_CORE which pulls in ppc_ext.h and e500v2_ext.h.
* Our ARM path uses NCSW_ARM_CORE which pulls in arm_ext.h with FreeBSD
* ARM64 implementations.
*/
#define NCSW_ARM_CORE
#define NCSW_FREEBSD
/* Cortex-A72 cache line size (LS1046A) */
#define CORE_CACHELINE_SIZE 64
/* Linux-ism helpers needed by mEMAC flib code */
#include <asm/byteorder.h>
#include <linux/delay.h>
/*
* LIST_ compatibility macros — FreeBSD's list_ext.h prefixes everything
* with NCSW_ to avoid conflicts with <sys/queue.h>. The mEMAC code
* uses the unprefixed original names from the NXP SDK.
*
* Note: LIST_FIRST/NEXT/PREV/LAST conflict with <sys/queue.h> and
* are intentionally omitted here.
*/
#define LIST_Add NCSW_LIST_Add
#define LIST_AddToTail NCSW_LIST_AddToTail
#define LIST_DelAndInit NCSW_LIST_DelAndInit
#define LIST_IsEmpty NCSW_LIST_IsEmpty
#define LIST_OBJECT NCSW_LIST_OBJECT
#define LIST_FOR_EACH NCSW_LIST_FOR_EACH
#define LIST_FOR_EACH_SAFE NCSW_LIST_FOR_EACH_SAFE
#define LIST_FOR_EACH_OBJECT NCSW_LIST_FOR_EACH_OBJECT
#define LIST_FOR_EACH_OBJECT_SAFE NCSW_LIST_FOR_EACH_OBJECT_SAFE
/* Debugging */
#define DEBUG_ERRORS 1
#define DPAA_DEBUG 1
#if defined(DPAA_DEBUG)
#define DEBUG_GLOBAL_LEVEL REPORT_LEVEL_INFO
#else
#define DEBUG_GLOBAL_LEVEL REPORT_LEVEL_WARNING
#endif
/* Events */
#define REPORT_EVENTS 1
#define EVENT_GLOBAL_LEVEL REPORT_LEVEL_MINOR
#endif /* DFLAGS_ARM64_H_ */

View file

@ -0,0 +1,6 @@
/*
* Wrapper to compile ncsw memcpy.c as ncsw_memcpy.o, avoiding
* a name collision with arm64/arm64/memcpy.S (which also produces
* memcpy.o and defines memcpy/memmove).
*/
#include "memcpy.c"

View file

@ -131,6 +131,9 @@ typedef struct {
NOTE: this parameter relevant only when working with multiple partitions. */
uint8_t partNumOfPools; /**< Number of Pools dedicated to this partition.
NOTE: this parameter relevant only when working with multiple partitions. */
void *p_FbprBase; /**< Pre-allocated FBPR memory (virtual), or NULL for internal allocation.
Must be physically contiguous, naturally aligned, and non-cacheable. */
uint32_t fbprSize; /**< Size of pre-allocated FBPR memory in bytes. */
} t_BmParam;

View file

@ -182,29 +182,42 @@ typedef _Packed struct t_DpaaCompTbl {
#define DPAA_SGTE_BPID_MASK 0x00ff0000 /**< SGTE BPID field mask */
#define DPAA_SGTE_OFFSET_MASK 0x00001fff /**< SGTE OFFSET field mask */
#define DPAA_SGTE_GET_ADDRH(sgte) (((t_DpaaSGTE *)sgte)->addrh & DPAA_SGTE_ADDRH_MASK) /**< Macro to get SGTE ADDRH field */
#define DPAA_SGTE_GET_ADDRL(sgte) ((t_DpaaSGTE *)sgte)->addrl /**< Macro to get SGTE ADDRL field */
#define DPAA_SGTE_GET_PHYS_ADDR(sgte) ((physAddress_t)(((uint64_t)DPAA_SGTE_GET_ADDRH(sgte) << 32) | (uint64_t)DPAA_SGTE_GET_ADDRL(sgte))) /**< Macro to get FD ADDR field */
#define DPAA_SGTE_GET_EXTENSION(sgte) ((((t_DpaaSGTE *)sgte)->length & DPAA_SGTE_E_MASK) >> (31-0)) /**< Macro to get SGTE EXTENSION field */
#define DPAA_SGTE_GET_FINAL(sgte) ((((t_DpaaSGTE *)sgte)->length & DPAA_SGTE_F_MASK) >> (31-1)) /**< Macro to get SGTE FINAL field */
#define DPAA_SGTE_GET_LENGTH(sgte) (((t_DpaaSGTE *)sgte)->length & DPAA_SGTE_LENGTH_MASK) /**< Macro to get SGTE LENGTH field */
#define DPAA_SGTE_GET_BPID(sgte) ((((t_DpaaSGTE *)sgte)->offset & DPAA_SGTE_BPID_MASK) >> (31-15)) /**< Macro to get SGTE BPID field */
#define DPAA_SGTE_GET_OFFSET(sgte) (((t_DpaaSGTE *)sgte)->offset & DPAA_SGTE_OFFSET_MASK) /**< Macro to get SGTE OFFSET field */
/*
* SGT entries live in host DMA memory and are read/written by FMan in
* big-endian byte order. On big-endian hosts (PowerPC) no swap is needed.
* On little-endian hosts (ARM64) each 32-bit field must be byte-swapped.
*/
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define _DPAA_SGTE_R32(field) (field)
#define _DPAA_SGTE_W32(field, val) ((field) = (val))
#else
#define _DPAA_SGTE_R32(field) __builtin_bswap32(field)
#define _DPAA_SGTE_W32(field, val) ((field) = __builtin_bswap32(val))
#endif
#define DPAA_SGTE_GET_ADDRH(sgte) (_DPAA_SGTE_R32(((t_DpaaSGTE *)sgte)->addrh) & DPAA_SGTE_ADDRH_MASK)
#define DPAA_SGTE_GET_ADDRL(sgte) _DPAA_SGTE_R32(((t_DpaaSGTE *)sgte)->addrl)
#define DPAA_SGTE_GET_PHYS_ADDR(sgte) ((physAddress_t)(((uint64_t)DPAA_SGTE_GET_ADDRH(sgte) << 32) | (uint64_t)DPAA_SGTE_GET_ADDRL(sgte)))
#define DPAA_SGTE_GET_EXTENSION(sgte) ((_DPAA_SGTE_R32(((t_DpaaSGTE *)sgte)->length) & DPAA_SGTE_E_MASK) >> (31-0))
#define DPAA_SGTE_GET_FINAL(sgte) ((_DPAA_SGTE_R32(((t_DpaaSGTE *)sgte)->length) & DPAA_SGTE_F_MASK) >> (31-1))
#define DPAA_SGTE_GET_LENGTH(sgte) (_DPAA_SGTE_R32(((t_DpaaSGTE *)sgte)->length) & DPAA_SGTE_LENGTH_MASK)
#define DPAA_SGTE_GET_BPID(sgte) ((_DPAA_SGTE_R32(((t_DpaaSGTE *)sgte)->offset) & DPAA_SGTE_BPID_MASK) >> (31-15))
#define DPAA_SGTE_GET_OFFSET(sgte) (_DPAA_SGTE_R32(((t_DpaaSGTE *)sgte)->offset) & DPAA_SGTE_OFFSET_MASK)
#define DPAA_SGTE_GET_ADDR(sgte) XX_PhysToVirt(DPAA_SGTE_GET_PHYS_ADDR(sgte))
#define DPAA_SGTE_SET_ADDRH(sgte,val) (((t_DpaaSGTE *)sgte)->addrh = ((((t_DpaaSGTE *)sgte)->addrh & ~DPAA_SGTE_ADDRH_MASK) | ((val) & DPAA_SGTE_ADDRH_MASK))) /**< Macro to set SGTE ADDRH field */
#define DPAA_SGTE_SET_ADDRL(sgte,val) ((t_DpaaSGTE *)sgte)->addrl = (val) /**< Macro to set SGTE ADDRL field */
#define DPAA_SGTE_SET_ADDRH(sgte,val) _DPAA_SGTE_W32(((t_DpaaSGTE *)sgte)->addrh, (_DPAA_SGTE_R32(((t_DpaaSGTE *)sgte)->addrh) & ~DPAA_SGTE_ADDRH_MASK) | ((val) & DPAA_SGTE_ADDRH_MASK))
#define DPAA_SGTE_SET_ADDRL(sgte,val) _DPAA_SGTE_W32(((t_DpaaSGTE *)sgte)->addrl, (val))
#define DPAA_SGTE_SET_ADDR(sgte,val) \
do { \
uint64_t physAddr = (uint64_t)(XX_VirtToPhys(val)); \
DPAA_SGTE_SET_ADDRH(sgte, ((uint32_t)(physAddr >> 32))); \
DPAA_SGTE_SET_ADDRL(sgte, (uint32_t)physAddr); \
} while (0) /**< Macro to set SGTE ADDR field */
#define DPAA_SGTE_SET_EXTENSION(sgte,val) (((t_DpaaSGTE *)sgte)->length = ((((t_DpaaSGTE *)sgte)->length & ~DPAA_SGTE_E_MASK) | (((val) << (31-0))& DPAA_SGTE_E_MASK))) /**< Macro to set SGTE EXTENSION field */
#define DPAA_SGTE_SET_FINAL(sgte,val) (((t_DpaaSGTE *)sgte)->length = ((((t_DpaaSGTE *)sgte)->length & ~DPAA_SGTE_F_MASK) | (((val) << (31-1))& DPAA_SGTE_F_MASK))) /**< Macro to set SGTE FINAL field */
#define DPAA_SGTE_SET_LENGTH(sgte,val) (((t_DpaaSGTE *)sgte)->length = (((t_DpaaSGTE *)sgte)->length & ~DPAA_SGTE_LENGTH_MASK) | ((val) & DPAA_SGTE_LENGTH_MASK)) /**< Macro to set SGTE LENGTH field */
#define DPAA_SGTE_SET_BPID(sgte,val) (((t_DpaaSGTE *)sgte)->offset = ((((t_DpaaSGTE *)sgte)->offset & ~DPAA_SGTE_BPID_MASK) | (((val) << (31-15))& DPAA_SGTE_BPID_MASK))) /**< Macro to set SGTE BPID field */
#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 */
} while (0)
#define DPAA_SGTE_SET_EXTENSION(sgte,val) _DPAA_SGTE_W32(((t_DpaaSGTE *)sgte)->length, (_DPAA_SGTE_R32(((t_DpaaSGTE *)sgte)->length) & ~DPAA_SGTE_E_MASK) | (((val) << (31-0)) & DPAA_SGTE_E_MASK))
#define DPAA_SGTE_SET_FINAL(sgte,val) _DPAA_SGTE_W32(((t_DpaaSGTE *)sgte)->length, (_DPAA_SGTE_R32(((t_DpaaSGTE *)sgte)->length) & ~DPAA_SGTE_F_MASK) | (((val) << (31-1)) & DPAA_SGTE_F_MASK))
#define DPAA_SGTE_SET_LENGTH(sgte,val) _DPAA_SGTE_W32(((t_DpaaSGTE *)sgte)->length, (_DPAA_SGTE_R32(((t_DpaaSGTE *)sgte)->length) & ~DPAA_SGTE_LENGTH_MASK) | ((val) & DPAA_SGTE_LENGTH_MASK))
#define DPAA_SGTE_SET_BPID(sgte,val) _DPAA_SGTE_W32(((t_DpaaSGTE *)sgte)->offset, (_DPAA_SGTE_R32(((t_DpaaSGTE *)sgte)->offset) & ~DPAA_SGTE_BPID_MASK) | (((val) << (31-15)) & DPAA_SGTE_BPID_MASK))
#define DPAA_SGTE_SET_OFFSET(sgte,val) _DPAA_SGTE_W32(((t_DpaaSGTE *)sgte)->offset, (_DPAA_SGTE_R32(((t_DpaaSGTE *)sgte)->offset) & ~DPAA_SGTE_OFFSET_MASK) | (((val) << (31-31)) & DPAA_SGTE_OFFSET_MASK))
/* @} */
#if defined(__MWERKS__) && !defined(__GNUC__)

View file

@ -0,0 +1,738 @@
/*
* Shadow fm_ehash.h — FMan External Hash Table API
*
* Replaces the SDK header (which contains Linux-specific inline functions).
* Struct layouts match the NXP SDK exactly:
* sdk_fman/inc/Peripherals/fm_ehash.h
*
* NOTE: en_exthash_info and en_exthash_node are NOT defined here — they
* are defined locally in fm_ehash_freebsd.c (EXCLUDE_FMAN_IPR_OFFLOAD
* variant). CDX code treats table handles as opaque void*.
*
* Copyright 2011, 2014 Freescale Semiconductor, Inc.
* Copyright (c) 2026 Mono Technologies Inc.
* SPDX-License-Identifier: BSD-2-Clause
*/
#ifndef FM_EHASH_H
#define FM_EHASH_H 1
#include <sys/types.h>
/* ----------------------------------------------------------------
* Constants
* ---------------------------------------------------------------- */
#define MAX_KEY_LEN 56
#define MAX_EN_EHASH_EXT_ENTRY_SIZE 320
#define MAX_EN_EHASH_ENTRY_SIZE 256
#define EN_EHASH_ENTRY_ALIGN 256
#define TBLENTRY_OPC_ALIGN sizeof(uint32_t)
#define MAX_OPCODES 16
/* ----------------------------------------------------------------
* Entry flag accessors
* ---------------------------------------------------------------- */
#define SET_INVALID_ENTRY_64BIT(entry) (entry |= (((uint64_t)1) << 63))
#define SET_INVALID_ENTRY(flags) (flags |= (1 << 15))
#define SET_TIMESTAMP_ENABLE(flags) (flags |= (1 << 13))
#define SET_STATS_ENABLE(flags) (flags |= (1 << 12))
#define SET_OPC_OFFSET(flags, offset) (flags |= ((offset >> 2) << 6))
#define SET_PARAM_OFFSET(flags, offset) (flags |= (offset >> 2))
#define GET_INVALID_ENTRY_64BIT(entry) (entry & (((uint64_t)1) << 63))
#define GET_INVALID_ENTRY(flags) (flags & (1 << 15))
#define GET_TIMESTAMP_ENABLE(flags) ((flags >> 13) & 1)
#define GET_STATS_ENABLE(flags) (flags & (1 << 12))
#define GET_OPC_OFFSET(x) (((x >> 6) & 0x1f) << 2)
#define GET_PARAM_OFFSET(x) ((x & 0x3f) << 2)
/* ----------------------------------------------------------------
* Hash table entry — on-hardware representation
* ---------------------------------------------------------------- */
struct en_ehash_entry {
union {
struct {
union {
struct {
uint16_t flags;
uint16_t next_entry_hi;
uint32_t next_entry_lo;
};
uint64_t next_entry;
};
uint8_t key[0];
} __attribute__((packed));
struct {
uint8_t hash_entry[MAX_EN_EHASH_ENTRY_SIZE];
uint64_t packet_count;
uint64_t packet_bytes;
uint32_t timestamp;
uint32_t reserved;
uint32_t timestamp_counter;
} __attribute__((packed));
uint8_t hash_ext_entry[MAX_EN_EHASH_EXT_ENTRY_SIZE];
} __attribute__((packed));
} __attribute__((packed));
/* ----------------------------------------------------------------
* DPA Classifier table entry statistics
* ---------------------------------------------------------------- */
#define STATS_VALID (1 << 0)
#define TIMESTAMP_VALID (1 << 1)
struct en_tbl_entry_stats {
uint64_t pkts;
uint64_t bytes;
uint32_t timestamp;
uint32_t flags;
};
/* ----------------------------------------------------------------
* Opcodes
* ---------------------------------------------------------------- */
#define ENQUEUE_PKT 0x01
#define REPLICATE_PKT 0x02
#define ENQUEUE_ONLY 0x03
#define UPDATE_ETH_RX_STATS 0x04
#define PREEMPTIVE_CHECKS_ON_PKT 0x05
#define PREEMPTIVE_CHECKS_ON_IPSEC_PKT 0x06
#define STRIP_ETH_HDR 0x11
#define STRIP_ALL_VLAN_HDRS 0x12
#define STRIP_PPPoE_HDR 0x14
#define STRIP_L2_HDR 0x17
#define STRIP_FIRST_VLAN_HDR 0x18
#define REMOVE_FIRST_IP_HDR 0x19
#define VALIDATE_IPSEC_ID 0x1a
#define UPDATE_TTL 0x21
#define UPDATE_SIP_V4 0x22
#define UPDATE_DIP_V4 0x24
#define UPDATE_HOPLIMIT 0x29
#define UPDATE_SIP_V6 0x2A
#define UPDATE_DIP_V6 0x2C
#define UPDATE_SPORT 0x31
#define UPDATE_DPORT 0x32
#define INSERT_L2_HDR 0x41
#define INSERT_VLAN_HDR 0x42
#define INSERT_PPPoE_HDR 0x43
#define INSERT_L3_HDR 0x44
#define REPLACE_PPPOE_HDR 0x45
#define NATPT_4to6 0x51
#define NATPT_6to4 0x52
#define PROCESS_RTP_PAYLOAD 0x61
#define PROCESS_RTCP_PAYLOAD 0x62
#define UPDATE_GLOBAL_STATS 0x80
/* ----------------------------------------------------------------
* Preemptive check parameters
* ---------------------------------------------------------------- */
#define PREEMPT_TX_VALIDATE (1 << 0)
#define PREEMPT_DFBIT_HONOR (1 << 1)
#define PREEMPT_POLICE_PKT (1 << 2)
#define PREEMPT_MATCH_DSCP (1 << 3)
#define PREEMPT_REPLACE_DSCP (1 << 4)
struct en_ehash_preempt_op {
uint8_t mtu_offset;
uint8_t OpMask;
uint8_t dscp_match_value;
uint8_t pp_no;
uint8_t new_dscp_val;
uint8_t pad;
uint16_t pad1;
} __attribute__((packed));
/* ----------------------------------------------------------------
* IPSec preemptive check parameters
* ---------------------------------------------------------------- */
#define MAX_VLAN_PER_FLOW 2
#define MAX_SPI_PER_FLOW 16
#define VALIDATE_SPI (0x1 << 0)
struct spi_info {
uint32_t spi;
uint32_t fqid;
} __attribute__((packed));
struct en_ehash_ipsec_preempt_op {
uint8_t op_flags;
uint8_t unused;
uint16_t natt_arr_mask;
uint16_t pppoe_session_id;
uint16_t pad;
struct spi_info spi_param[MAX_SPI_PER_FLOW];
} __attribute__((packed));
/* ----------------------------------------------------------------
* Enqueue parameters
* ---------------------------------------------------------------- */
#define EN_EHASH_DISABLE_FRAG 0xffff
struct en_ehash_enqueue_param {
uint16_t mtu;
uint8_t hdr_xpnd_sz;
uint8_t bpid;
uint32_t fqid;
union {
struct {
uint32_t rspid:8;
uint32_t stats_ptr:24;
};
uint32_t word;
};
union {
struct {
uint32_t dscp_fq_enable:8;
uint32_t muram_frag_param_addr:24;
};
uint32_t word2;
};
} __attribute__((packed));
/* ----------------------------------------------------------------
* RTP relay parameters
* ---------------------------------------------------------------- */
#define EEH_RTP_SEND_FIRST_PACKET_TO_CP 0x0001
#define EEH_RTP_DUPLICATE_PKT_SEND_TO_CP 0x0002
#define EEH_RTP_ENABLE_VLAN_P_BIT_LEARN 0x0004
struct en_ehash_rtprelay_param {
uint32_t rtpinfo_ptr;
uint32_t in_sock_stats_ptr;
uint32_t out_sock_stats_ptr;
union {
uint32_t src_ipv4_val;
uint32_t src_ipv6_val[4];
} __attribute__((packed));
uint32_t TimeStampIncr;
uint32_t SSRC_1;
uint16_t seq_base;
uint16_t egress_socketID;
uint8_t DTMF_PT[2];
uint16_t rtp_flags;
uint16_t seq_incr;
uint32_t chksum_ptr;
uint32_t rtp_hdr;
uint32_t ts_incr;
uint32_t cur_ts_msec;
int32_t rtp_check;
} __attribute__((packed));
/* ----------------------------------------------------------------
* Replicate parameters (multicast)
* ---------------------------------------------------------------- */
struct en_ehash_replicate_param {
union {
struct {
uint16_t rsvd;
uint16_t first_member_flow_addr_hi;
uint32_t first_member_flow_addr_lo;
};
uint64_t first_member_flow_addr;
};
void *first_listener_entry;
} __attribute__((packed));
/* ----------------------------------------------------------------
* Update ethernet RX stats
* ---------------------------------------------------------------- */
struct en_ehash_update_ether_rx_stats {
uint32_t stats_ptr;
} __attribute__((packed));
/* ----------------------------------------------------------------
* Strip first VLAN header
* ---------------------------------------------------------------- */
struct en_ehash_strip_first_vlan_hdr {
uint32_t stats_ptr;
uint16_t vlan_id;
uint16_t pad;
} __attribute__((packed));
/* ----------------------------------------------------------------
* Strip all VLAN headers
* ---------------------------------------------------------------- */
#define OP_SKIP_VLAN_VALIDATE (1 << 0)
#define OP_VLAN_FILTER_EN (1 << 1)
#define OP_VLAN_FILTER_PVID_SET (1 << 2)
struct en_ehash_strip_all_vlan_hdrs {
uint16_t vlan_id[MAX_VLAN_PER_FLOW];
union {
struct {
uint32_t padding:2;
uint32_t num_entries:6;
uint32_t stats_ptr:24;
};
uint32_t word;
};
uint8_t op_flags;
uint8_t pad;
uint16_t pad1;
uint8_t stats_offsets[0];
} __attribute__((packed));
/* ----------------------------------------------------------------
* Strip PPPoE header
* ---------------------------------------------------------------- */
struct en_ehash_strip_pppoe_hdr {
uint32_t stats_ptr;
} __attribute__((packed));
/* ----------------------------------------------------------------
* Strip all L2 headers
* ---------------------------------------------------------------- */
struct en_ehash_strip_l2_hdrs {
uint16_t vlan_id[MAX_VLAN_PER_FLOW];
union {
struct {
uint32_t padding:2;
uint32_t num_entries:6;
uint32_t stats_ptr:24;
};
uint32_t word;
};
uint8_t stats_offsets[0];
} __attribute__((packed));
/* ----------------------------------------------------------------
* Validate IPSec ID
* ---------------------------------------------------------------- */
struct en_ehash_validate_ipsec {
uint32_t reserved:16;
uint32_t identifier:16;
} __attribute__((packed));
/* ----------------------------------------------------------------
* Update IP addresses
* ---------------------------------------------------------------- */
struct en_ehash_update_ipv4_ip {
uint32_t ip_v4;
} __attribute__((packed));
struct en_ehash_update_ipv6_ip {
uint8_t ip_v6[16];
} __attribute__((packed));
/* ----------------------------------------------------------------
* Update DSCP
* ---------------------------------------------------------------- */
struct en_ehash_update_dscp {
union {
struct {
uint32_t rsvd:24;
uint32_t dscp_mark_value:6;
uint32_t dscp_mark_flag:1;
uint32_t padding:1;
};
uint32_t dscp;
};
} __attribute__((packed));
/* ----------------------------------------------------------------
* Update ports
* ---------------------------------------------------------------- */
struct en_ehash_update_port {
uint16_t dport;
uint16_t sport;
} __attribute__((packed));
/* ----------------------------------------------------------------
* Insert L2 header
* ---------------------------------------------------------------- */
struct en_ehash_insert_l2_hdr {
union {
struct {
uint8_t replace:1;
uint8_t header_padding:2;
uint8_t reserved:5;
uint8_t stats_count;
uint8_t reserved_1;
uint8_t hdr_len;
};
uint32_t word;
};
uint8_t l2hdr[0];
} __attribute__((packed));
struct en_ehash_insert_l2_hdr_stats {
union {
struct {
uint32_t padding:2;
uint32_t reserved:6;
uint32_t stats_ptr:24;
};
uint32_t word;
};
uint8_t stats_offsets[0];
} __attribute__((packed));
/* ----------------------------------------------------------------
* Insert VLAN header
* ---------------------------------------------------------------- */
struct en_ehash_insert_vlan_hdr {
union {
struct {
uint32_t reserved:1;
uint32_t dscp_vlanpcp_map_enable:1;
uint32_t num_hdrs:6;
uint32_t statptr:24;
} __attribute__((packed));
uint32_t word;
} __attribute__((packed));
uint32_t vlanhdr[0];
} __attribute__((packed));
struct en_ehash_insert_vlan_hdr_stats {
uint8_t stats_offsets[1];
} __attribute__((packed));
/* ----------------------------------------------------------------
* Insert/replace PPPoE header
* ---------------------------------------------------------------- */
#define PPPoE_VERSION 1
#define PPPoE_TYPE 1
#define PPPoE_CODE 0
struct en_ehash_insert_pppoe_hdr {
uint32_t stats_ptr;
union {
struct {
uint32_t version:4;
uint32_t type:4;
uint32_t code:8;
uint32_t session_id:16;
};
uint32_t word;
};
} __attribute__((packed));
struct en_ehash_replace_pppoe_hdr_params {
uint8_t destination_mac[6];
uint8_t source_mac[6];
uint16_t session_id;
uint16_t pad;
uint32_t fqid;
uint32_t stats_ptr;
} __attribute__((packed));
/* ----------------------------------------------------------------
* Insert L3 header (tunnels)
* ---------------------------------------------------------------- */
#define TYPE_CUSTOM 0
#define TYPE_4o6 1
#define TYPE_6o4 2
#define IPID_STARTVAL 1
struct en_ehash_insert_l3_hdr {
union {
struct {
uint8_t reserved:3;
uint8_t calc_cksum:1;
uint8_t qos:1;
uint8_t df:1;
uint8_t type:2;
uint8_t hdr_len;
uint16_t ipident;
};
uint32_t word;
};
union {
struct {
uint32_t route_dest_offset:8;
uint32_t stats_ptr:24;
};
uint32_t word_1;
};
uint8_t l3hdr[0];
} __attribute__((packed));
#define COPY_DSCP_OUTER_INNER (1 << 24)
/* ----------------------------------------------------------------
* Remove first IP header (tunnel decap)
* ---------------------------------------------------------------- */
struct en_ehash_remove_first_ip_hdr {
uint32_t flags:8;
uint32_t stats_ptr:24;
} __attribute__((packed));
/* ----------------------------------------------------------------
* Port info / interface stats structures
* ---------------------------------------------------------------- */
struct en_ehash_portinfo {
uint32_t reserved[3];
uint32_t port_info;
} __attribute__((packed));
struct en_ehash_ifportinfo {
struct en_ehash_portinfo rxpinfo;
struct en_ehash_portinfo txpinfo;
} __attribute__((packed));
struct en_ehash_stats {
uint64_t bytes;
uint32_t pkts;
uint32_t reserved;
} __attribute__((packed));
struct en_ehash_stats_with_ts {
uint64_t bytes;
uint32_t pkts;
uint32_t pad;
uint64_t timestamp;
} __attribute__((packed));
struct en_ehash_ifstats {
struct en_ehash_stats rxstats;
struct en_ehash_stats txstats;
} __attribute__((packed));
#define STATS_WITH_TS (1 << 7)
struct en_ehash_ifstats_with_ts {
struct en_ehash_stats_with_ts rxstats;
struct en_ehash_stats_with_ts txstats;
} __attribute__((packed));
/* Statistics table */
struct en_ehash_stats_tbl {
uint32_t table_indicator:1;
uint32_t num_entries:7;
uint32_t stats_ptr:24;
} __attribute__((packed));
/* ----------------------------------------------------------------
* NATPT structures
* ---------------------------------------------------------------- */
struct en_ehash_natpt_hdr {
union {
struct {
uint32_t reserved:6;
uint32_t tcu:1;
uint32_t hlu:1;
uint32_t hdrlen:8;
uint32_t reserved1:16;
} ip4to6;
struct {
uint16_t reserved:5;
uint16_t ipu:1;
uint16_t tou:1;
uint16_t tlu:1;
uint16_t hdrlen:8;
uint16_t ipident;
} ip6to4;
uint32_t word;
};
uint8_t l3hdr[0];
} __attribute__((packed));
/* NATPT 4-to-6 flags */
#define NATPT_TCU (1 << 25)
#define NATPT_HLU (1 << 24)
/* NATPT 6-to-4 flags */
#define NATPT_IPU (1 << 26)
#define NATPT_TOU (1 << 25)
#define NATPT_TLU (1 << 24)
/* ----------------------------------------------------------------
* SEC failure statistics
* ---------------------------------------------------------------- */
typedef struct en_SEC_failure_stats_s {
uint32_t icv_failures;
uint32_t hw_errs;
uint32_t CCM_AAD_size_errs;
uint32_t anti_replay_late_errs;
uint32_t anti_replay_replay_errs;
uint32_t seq_num_overflows;
uint32_t DMA_errs;
uint32_t DECO_watchdog_timer_timedout_errs;
uint32_t input_frame_read_errs;
uint32_t protocol_format_errs;
uint32_t ipsec_ttl_zero_errs;
uint32_t ipsec_pad_chk_failures;
uint32_t output_frame_length_rollover_errs;
uint32_t tbl_buff_too_small_errs;
uint32_t tbl_buff_pool_depletion_errs;
uint32_t output_frame_too_large_errs;
uint32_t cmpnd_frame_write_errs;
uint32_t buff_too_small_errs;
uint32_t buff_pool_depletion_errs;
uint32_t output_frame_write_errs;
uint32_t cmpnd_frame_read_errs;
uint32_t prehdr_read_errs;
uint32_t other_errs;
} __attribute__((packed)) en_SEC_failure_stats;
/* ----------------------------------------------------------------
* DSCP-to-VLAN PCP mapping
* ---------------------------------------------------------------- */
#define MAX_VLAN_PCP 7
typedef struct en_dscp_vlanpcp_map_cfg_s {
uint8_t dscp_vlanpcp[MAX_VLAN_PCP + 1];
} __attribute__((packed)) en_dscp_vlanpcp_map_cfg;
/* ----------------------------------------------------------------
* Global MURAM data area — at pool + EN_INTERNAL_BUFF_POOL_SIZE
*
* Contains DSCP-to-VLAN PCP mapping (8 bytes) followed by SEC
* failure statistics (92 bytes). Total: 100 bytes within a
* 256-byte MURAM slot. CDX microcode reads/writes these at runtime.
* ---------------------------------------------------------------- */
typedef struct en_exthash_global_mem_s {
en_dscp_vlanpcp_map_cfg dscp_vlanpcp_map; /* +0, 8B */
en_SEC_failure_stats SEC_failure_stats; /* +8, 92B */
} __attribute__((packed)) en_exthash_global_mem;
/* ----------------------------------------------------------------
* IP reassembly MURAM parameters — written by FMan microcode,
* fields configured by ExternalHashSetReasslyPool().
*
* This is the hardware layout in MURAM, pointed to by
* en_exthash_node.word_2 (reassm_param << 8) for REASSM tables.
* All multi-byte fields are stored big-endian.
* ---------------------------------------------------------------- */
#define MAX_REASSM_BUCKETS 16
struct ip_reassembly_stats {
uint64_t num_frag_pkts;
uint64_t num_reassemblies;
uint64_t num_completed_reassly;
uint64_t num_sess_matches;
uint64_t num_frags_too_small;
uint64_t num_reassm_timeouts;
uint64_t num_overlapping_frags;
uint64_t num_too_many_frags;
uint64_t num_failed_bufallocs;
uint64_t num_failed_ctxallocs;
uint64_t num_fatal_errors;
uint64_t num_failed_ctxdeallocs;
uint32_t reassm_count;
uint32_t pad;
} __attribute__((packed));
struct ip_reassembly_params {
uint32_t table_base_hi;
uint32_t table_base_lo;
struct ip_reassembly_stats stats;
uint32_t table_mask;
uint32_t type;
uint32_t ipr_timer;
uint32_t timeout_val;
uint32_t timeout_fqid;
uint32_t min_frag_size;
uint32_t reassem_bpid;
uint32_t reassem_bsize;
uint32_t frag_bpid;
uint32_t frag_bsize;
uint32_t reassly_dbg;
uint32_t context_info;
uint32_t curr_sessions;
uint32_t txc_fqid;
uint32_t timer_tnum;
uint32_t max_frags;
uint32_t max_con_reassm;
uint32_t bucket_base;
uint32_t bucket_lock[MAX_REASSM_BUCKETS];
uint32_t bucket_head[MAX_REASSM_BUCKETS];
} __attribute__((packed));
/* ----------------------------------------------------------------
* IP reassembly info (for devman.h forward reference)
* ---------------------------------------------------------------- */
struct ip_reassembly_info {
uint64_t num_frag_pkts;
uint64_t num_reassemblies;
uint64_t num_completed_reassly;
uint64_t num_sess_matches;
uint64_t num_frags_too_small;
uint64_t num_reassm_timeouts;
uint64_t num_overlapping_frags;
uint64_t num_too_many_frags;
uint64_t num_failed_bufallocs;
uint64_t num_failed_ctxallocs;
uint64_t num_fatal_errors;
uint64_t num_failed_ctxdeallocs;
uint32_t table_mask;
uint32_t ipr_timer;
uint32_t timeout_val;
uint32_t timeout_fqid;
uint32_t max_frags;
uint32_t min_frag_size;
uint32_t max_con_reassm;
uint32_t reassem_bpid;
uint32_t reassem_bsize;
uint32_t frag_bpid;
uint32_t frag_bsize;
uint32_t timer_tnum;
uint32_t reassly_dbg;
uint32_t curr_sessions;
uint32_t txc_fqid;
};
/* ----------------------------------------------------------------
* Software table entry wrapping the hardware entry
* ---------------------------------------------------------------- */
struct en_exthash_tbl_entry {
struct en_ehash_entry hashentry;
struct en_exthash_tbl_entry *prev;
struct en_exthash_tbl_entry *next;
uint8_t *replicate_params;
union {
uint8_t *enqueue_params;
uint8_t *ipsec_preempt_params;
};
};
/* Hash table bucket */
struct en_exthash_bucket {
uint64_t h;
uint64_t pad;
};
/* ----------------------------------------------------------------
* Debug display — no-op stubs replacing SDK inline functions
* that use printk/phys_to_virt/etc. Tier 1 code calls these
* but they're debug-only and not needed for correct operation.
* ---------------------------------------------------------------- */
static inline void
display_ehash_tbl_entry(struct en_ehash_entry *entry __attribute__((unused)),
uint32_t keysize __attribute__((unused)))
{
}
/* ----------------------------------------------------------------
* ExternalHash API
* ---------------------------------------------------------------- */
extern void *ExternalHashTableAllocEntry(void *h_HashTbl);
extern void ExternalHashTableEntryFree(void *entry);
extern int ExternalHashTableFmPcdHcSync(void *h_HashTbl);
extern int ExternalHashTableAddKey(void *h_HashTbl, uint8_t keySize,
void *tbl_entry);
extern int ExternalHashTableDeleteKey(void *h_HashTbl, uint16_t index,
void *tbl_entry);
extern int ExternalHashTableEntryGetStatsAndTS(void *tbl_entry,
struct en_tbl_entry_stats *stats);
extern int32_t ExternalHashGetSECfailureStats(en_SEC_failure_stats *stats);
extern int32_t ExternalHashResetSECfailureStats(void);
extern int32_t ExternalHashSetDscpVlanpcpMapCfg(en_dscp_vlanpcp_map_cfg *map);
extern int32_t ExternalHashGetDscpVlanpcpMapCfg(en_dscp_vlanpcp_map_cfg *map);
extern int ExternalHashSetReasslyPool(uint32_t type, uint32_t ctx_bpid,
uint32_t ctx_bpsize, uint32_t frag_bpid, uint32_t frag_size,
uint32_t txc_fqid, uint32_t ipr_timer_freq);
/* Kernel-internal ehash API (called from fm_cc.c) */
extern t_Handle ExternalHashTableSet(t_Handle h_FmPcd,
t_FmPcdHashTableParams *p_Param);
extern void copy_td_to_ccbase(void *handle, t_Handle p_CcTreeTmp);
extern t_Error ExternalHashTableModifyMissNextEngine(t_Handle h_HashTbl,
t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams);
extern void ExternalHashTableDelete(t_Handle h_HashTbl);
extern int ExternalHashReasslyTableExists(uint32_t type);
/* CDX module exports */
extern void ipr_update_timestamp(void);
extern void cdx_ehash_update_timestamp(uint32_t id, uint32_t value);
extern uint32_t cdx_ehash_get_timestamp_addr(uint32_t id);
#endif /* FM_EHASH_H */

View file

@ -1462,6 +1462,11 @@ t_Error FM_GetFmanCtrlCodeRevision(t_Handle h_Fm, t_FmCtrlCodeRevisionInfo *p_Re
*//***************************************************************************/
uint32_t FM_GetCounter(t_Handle h_Fm, e_FmCounters counter);
#ifdef __aarch64__
void FM_ErrorDiag(t_Handle h_Fm, uint8_t hwPortId);
void FM_TaskStatusDiag(t_Handle h_Fm, uint8_t hwPortId);
#endif
/**************************************************************************//**
@Function FM_ModifyCounter

View file

@ -39,6 +39,10 @@
#ifndef __FM_PCD_EXT
#define __FM_PCD_EXT
/* CDX enhanced external hash tables — redirect FM_PCD_HashTable* APIs
* to ExternalHashTable* implementations (matching Linux SDK). */
#define USE_ENHANCED_EHASH 1
#include "std_ext.h"
#include "net_ext.h"
#include "list_ext.h"
@ -1718,6 +1722,8 @@ 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 shared; /**< This scheme is shared between ports
(must match ioc_fm_pcd_kg_scheme_params_t layout) */
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 */
@ -1991,6 +1997,34 @@ typedef struct t_FmPcdHashTableParams {
t_FmPcdCcNextEngineParams ccNextEngineParamsForMiss; /**< Parameters for defining the next engine when a key is not matched */
bool agingSupport; /**< TRUE to enable aging support for all keys of this
hash table; allows monitoring whether a key was
accessed during a given period. */
#if (DPAA_VERSION >= 11)
bool externalHash; /**< TRUE to use external hash table (CDX manages
the hash buckets in DDR; NCSW only allocates the
MURAM AD placeholder). */
#ifndef EXCLUDE_FMAN_IPR_OFFLOAD
uint32_t table_type; /**< IP reassembly table type
(must match ioc_fm_pcd_hash_table_params_t layout) */
struct {
uint32_t timeout_val; /**< reassembly timeout */
uint32_t timeout_fqid; /**< fqid for reassembly failures */
uint32_t max_frags; /**< max allowed fragments */
uint32_t min_frag_size; /**< min allowed frag size except last frag */
uint32_t max_sessions; /**< max conn reassembly sessions */
};
#endif /* EXCLUDE_FMAN_IPR_OFFLOAD */
struct {
uint8_t dataMemId; /**< Memory partition ID for external hash table
buckets and contexts; must not cross 4GB boundary */
uint16_t dataLiodnOffs; /**< LIODN offset for external hash table access */
uintptr_t missMonitorAddr; /**< User-allocated miss monitor address */
} externalHashParams;
#endif /* (DPAA_VERSION >= 11) */
} t_FmPcdHashTableParams;
/**************************************************************************//**

View file

@ -1,6 +1,6 @@
/******************************************************************************
Š 1995-2003, 2004, 2005-2011 Freescale Semiconductor, Inc.
<EFBFBD> 1995-2003, 2004, 2005-2011 Freescale Semiconductor, Inc.
All rights reserved.
This is proprietary source code of Freescale Semiconductor Inc.,
@ -258,6 +258,13 @@ typedef struct {
NOTE: this parameter relevant only when working with multiple partitions. */
uint16_t partNumOfCgs; /**< Number of cgr's dedicated to this partition.
NOTE: this parameter relevant only when working with multiple partitions. */
void *p_FqdBase; /**< Pre-allocated FQD memory (virtual), or NULL for internal allocation.
Must be physically contiguous, naturally aligned, and non-cacheable.
When set, totalNumOfFqids is computed from fqdSize / 64. */
uint32_t fqdSize; /**< Size of pre-allocated FQD memory in bytes. */
void *p_PfdrBase; /**< Pre-allocated PFDR memory (virtual), or NULL for internal allocation.
Must be physically contiguous, naturally aligned, and non-cacheable. */
uint32_t pfdrSize; /**< Size of pre-allocated PFDR memory in bytes. */
} t_QmParam;
@ -791,6 +798,40 @@ typedef struct t_QmPortalFrameInfo {
*//***************************************************************************/
t_Error QM_PORTAL_Poll(t_Handle h_QmPortal, e_QmPortalPollSource source);
#ifdef __aarch64__
void QM_PORTAL_DqrrDiag(t_Handle h_QmPortal, uint8_t *sw_pi, uint8_t *sw_ci,
uint8_t *sw_fill, uint8_t *hw_pi, uint8_t *hw_ci);
void QM_PORTAL_IsrDiag(t_Handle h_QmPortal, uint32_t *isr, uint32_t *ier,
uint32_t *iir);
void QM_ErrorDiag(t_Handle h_Qm, uint32_t *err_isr, uint32_t *ecsr,
uint32_t *ecir, uint32_t *pfdr_fpc, uint32_t *sfdr_in_use,
uint32_t *idle_stat, uint32_t *dcp0_cfg, uint32_t *dcp0_dlm_avg,
uint32_t *dcp_dd_ihrsr, uint32_t *dcp_dd_hasr);
/**************************************************************************//**
@Function QM_PORTAL_Inhibit
@Description Inhibit all interrupts for this portal (IIR=1).
Used by NAPI-style FILTER handler to mask interrupts
at the source before scheduling deferred processing.
@Param[in] h_QmPortal - A handle to a QM-Portal module
*//***************************************************************************/
void QM_PORTAL_Inhibit(t_Handle h_QmPortal);
/**************************************************************************//**
@Function QM_PORTAL_Uninhibit
@Description Clear all pending ISR status and uninhibit portal
interrupts (IIR=0). Called after draining DQRR/MR
to re-enable interrupt delivery.
@Param[in] h_QmPortal - A handle to a QM-Portal module
*//***************************************************************************/
void QM_PORTAL_Uninhibit(t_Handle h_QmPortal);
#endif
/**************************************************************************//**
@Function QM_PORTAL_PollFrame
@ -1058,6 +1099,21 @@ uint32_t QM_FQR_GetCounter(t_Handle h_QmFqr, t_Handle h_QmPortal, uint32_t fqidO
*//***************************************************************************/
t_Error QM_FQR_Enqueue(t_Handle h_QmFqr, t_Handle h_QmPortal, uint32_t fqidOffset, t_DpaaFD *p_Frame);
/**************************************************************************//**
@Function QM_PORTAL_EnqueueFqid
@Description Enqueue a frame to a specific FQID without requiring an FQR
handle. Used for CEETM frame queues which are managed by
CEETM hardware rather than NCSW FQR.
@Param[in] h_QmPortal - A handle to a QM Portal Module.
@Param[in] fqid - The target Frame Queue ID.
@Param[in] p_Frame - Pointer to the frame to enqueue.
@Return E_OK on success; Error code otherwise.
*//***************************************************************************/
t_Error QM_PORTAL_EnqueueFqid(t_Handle h_QmPortal, uint32_t fqid, t_DpaaFD *p_Frame);
/**************************************************************************//**
@Function QM_FQR_PullFrame

View file

@ -43,7 +43,11 @@
#ifndef __CORE_EXT_H
#define __CORE_EXT_H
#ifdef CONFIG_FMAN_ARM
#if defined(NCSW_ARM_CORE)
/* FreeBSD ARM64 path — CORE_CACHELINE_SIZE set in dflags_arm64.h */
#include "arm_ext.h"
#elif defined(CONFIG_FMAN_ARM)
/* Linux ARM path */
#include "arm_ext.h"
#include <linux/smp.h>
#else
@ -63,7 +67,7 @@
#error "Must define the core cache-line size!"
#endif /* !CORE_CACHELINE_SIZE */
#endif /* CONFIG_FMAN_ARM */
#endif /* NCSW_ARM_CORE / CONFIG_FMAN_ARM */
/**************************************************************************//**

View file

@ -35,9 +35,6 @@
@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
@ -52,4 +49,28 @@ static __inline__ void CORE_MemoryBarrier(void)
mb();
}
#endif /* __PPC_EXT_H */
#if defined(NCSW_ARM_CORE) && defined(NCSW_FREEBSD)
/*
* FreeBSD ARM64 core function bindings.
* Implementations are in core_arm64.c.
*
* Follow the same pattern as PPC: e500v2_ext.h defines
* CORE_GetId -> E500_GetId, etc. We map to ARM64_* equivalents.
*/
uint32_t ARM64_GetId(void);
int ARM64_TestAndSet(volatile int *p);
void ARM64_InstructionSync(void);
#define CORE_GetId ARM64_GetId
#define CORE_TestAndSet ARM64_TestAndSet
#define CORE_InstructionSync ARM64_InstructionSync
/* Cache management — handled by the kernel on ARM64, no-ops here */
#define CORE_DCacheEnable() do { } while (0)
#define CORE_ICacheEnable() do { } while (0)
#define CORE_DCacheDisable() do { } while (0)
#define CORE_ICacheDisable() do { } while (0)
#endif /* NCSW_ARM_CORE && NCSW_FREEBSD */
#endif /* __ARM_EXT_H */

View file

@ -103,6 +103,45 @@ typedef enum
e_QM_FQ_CHANNEL_SWPORTAL8,
e_QM_FQ_CHANNEL_SWPORTAL9,
#ifdef __aarch64__
/* QMan v3 (LS1046A): pool channels at 0x401-0x40F, FMan DC at 0x800+,
* CAAM at 0x840. SW portal channels (0-9) are unchanged. */
e_QM_FQ_CHANNEL_POOL1 = 0x401,
e_QM_FQ_CHANNEL_POOL2,
e_QM_FQ_CHANNEL_POOL3,
e_QM_FQ_CHANNEL_POOL4,
e_QM_FQ_CHANNEL_POOL5,
e_QM_FQ_CHANNEL_POOL6,
e_QM_FQ_CHANNEL_POOL7,
e_QM_FQ_CHANNEL_POOL8,
e_QM_FQ_CHANNEL_POOL9,
e_QM_FQ_CHANNEL_POOL10,
e_QM_FQ_CHANNEL_POOL11,
e_QM_FQ_CHANNEL_POOL12,
e_QM_FQ_CHANNEL_POOL13,
e_QM_FQ_CHANNEL_POOL14,
e_QM_FQ_CHANNEL_POOL15,
e_QM_FQ_CHANNEL_FMAN0_SP0 = 0x800,
e_QM_FQ_CHANNEL_FMAN0_SP1,
e_QM_FQ_CHANNEL_FMAN0_SP2,
e_QM_FQ_CHANNEL_FMAN0_SP3,
e_QM_FQ_CHANNEL_FMAN0_SP4,
e_QM_FQ_CHANNEL_FMAN0_SP5,
e_QM_FQ_CHANNEL_FMAN0_SP6,
e_QM_FQ_CHANNEL_FMAN0_SP7,
e_QM_FQ_CHANNEL_FMAN0_SP8,
e_QM_FQ_CHANNEL_FMAN0_SP9,
e_QM_FQ_CHANNEL_FMAN0_SP10,
e_QM_FQ_CHANNEL_FMAN0_SP11,
e_QM_FQ_CHANNEL_FMAN0_SP12,
e_QM_FQ_CHANNEL_FMAN0_SP13,
e_QM_FQ_CHANNEL_FMAN0_SP14,
e_QM_FQ_CHANNEL_FMAN0_SP15,
e_QM_FQ_CHANNEL_CAAM = 0x840
#else
/* QMan v1/v2 (P5020): pool channels at 0x21-0x2F, FMan DC at 0x40+ */
e_QM_FQ_CHANNEL_POOL1 = 0x21, /**< Pool channels that can be serviced by any of the software portals */
e_QM_FQ_CHANNEL_POOL2,
e_QM_FQ_CHANNEL_POOL3,
@ -144,6 +183,7 @@ typedef enum
connected to PME */
e_QM_FQ_CHANNEL_RAID = 0xC0 /**< Dedicated channel serviced by Direct Connect Portal 4:
connected to RAID */
#endif
} e_QmFQChannel;
/*****************************************************************************
@ -156,11 +196,31 @@ typedef enum
******************************************************************************/
#define INTG_MAX_NUM_OF_FM 1
/*
* ---------- Architecture-dependent integration parameters ----------
*
* ARM64 (LS1046A / FManv3, DPAA 1.1)
* Values from NXP Linux SDK LS1043 dpaa_integration_ext.h
* PowerPC (P5020 / FManv2, DPAA 1.0)
* Original FreeBSD values
*/
#ifdef __aarch64__
#define DPAA_VERSION 11
#else
#define DPAA_VERSION 10
#endif
/* Ports defines */
#ifdef __aarch64__
#define FM_MAX_NUM_OF_1G_MACS 6
#define FM_MAX_NUM_OF_10G_MACS 2
#define FM_MAX_NUM_OF_OH_PORTS 6
#else
#define FM_MAX_NUM_OF_1G_MACS 5
#define FM_MAX_NUM_OF_10G_MACS 1
#define FM_MAX_NUM_OF_MACS (FM_MAX_NUM_OF_1G_MACS + FM_MAX_NUM_OF_10G_MACS)
#define FM_MAX_NUM_OF_OH_PORTS 7
#endif
#define FM_MAX_NUM_OF_MACS (FM_MAX_NUM_OF_1G_MACS + FM_MAX_NUM_OF_10G_MACS)
#define FM_MAX_NUM_OF_1G_RX_PORTS FM_MAX_NUM_OF_1G_MACS
#define FM_MAX_NUM_OF_10G_RX_PORTS FM_MAX_NUM_OF_10G_MACS
@ -170,46 +230,85 @@ typedef enum
#define FM_MAX_NUM_OF_10G_TX_PORTS FM_MAX_NUM_OF_10G_MACS
#define FM_MAX_NUM_OF_TX_PORTS (FM_MAX_NUM_OF_10G_TX_PORTS + FM_MAX_NUM_OF_1G_TX_PORTS)
#ifdef __aarch64__
#define FM_PORT_MAX_NUM_OF_EXT_POOLS 4 /**< Number of external BM pools per Rx port */
#define FM_MAX_NUM_OF_SUB_PORTALS 16
#else
#define FM_PORT_MAX_NUM_OF_EXT_POOLS 8 /**< Number of external BM pools per Rx port */
#define FM_PORT_NUM_OF_CONGESTION_GRPS 256 /**< Total number of congestion groups in QM */
#define FM_MAX_NUM_OF_SUB_PORTALS 12
#endif
#define FM_PORT_NUM_OF_CONGESTION_GRPS 256 /**< Total number of congestion groups in QM */
#define FM_PORT_MAX_NUM_OF_OBSERVED_EXT_POOLS 0
#if (DPAA_VERSION >= 11)
#define FM_VSP_MAX_NUM_OF_ENTRIES 64
#define FM_MAX_NUM_OF_PFC_PRIORITIES 8
#endif
/* RAMs defines */
#define FM_MURAM_SIZE (160 * KILOBYTE)
#ifdef __aarch64__
#define FM_MURAM_SIZE (384 * KILOBYTE) /**< LS1046A FManv3: 384KB MURAM */
#else
#define FM_MURAM_SIZE (160 * KILOBYTE) /**< P5020 FManv2: 160KB MURAM */
#endif
#define FM_IRAM_SIZE(a,b) ( 64 * KILOBYTE)
/* PCD defines */
#define FM_PCD_PLCR_NUM_ENTRIES 256 /**< Total number of policer profiles */
#define FM_PCD_KG_NUM_OF_SCHEMES 32 /**< Total number of KG schemes */
#define FM_PCD_MAX_NUM_OF_CLS_PLANS 256 /**< Number of classification plan entries. */
#define FM_PCD_SW_PRS_SIZE 0x00000800
#ifdef __aarch64__
#define FM_PCD_PRS_SW_PATCHES_SIZE 0x00000600
#else
#define FM_PCD_PRS_SW_PATCHES_SIZE 0x00000200
#endif
/* RTC defines */
#define FM_RTC_NUM_OF_ALARMS 2 /**< RTC number of alarms */
#ifdef __aarch64__
#define FM_RTC_NUM_OF_PERIODIC_PULSES 3 /**< RTC number of periodic pulses */
#else
#define FM_RTC_NUM_OF_PERIODIC_PULSES 2 /**< RTC number of periodic pulses */
#endif
#define FM_RTC_NUM_OF_EXT_TRIGGERS 2 /**< RTC number of external triggers */
/* QMI defines */
#define QMI_MAX_NUM_OF_TNUMS 64
#ifdef __aarch64__
#define QMI_DEF_TNUMS_THRESH 32
#else
#define MAX_QMI_DEQ_SUBPORTAL 12
#define QMI_DEF_TNUMS_THRESH 48
#endif
/* FPM defines */
#define FM_NUM_OF_FMAN_CTRL_EVENT_REGS 4
/* DMA defines */
#ifdef __aarch64__
#define DMA_THRESH_MAX_COMMQ 83
#else
#define DMA_THRESH_MAX_COMMQ 31
#endif
#define DMA_THRESH_MAX_BUF 127
/* BMI defines */
#define BMI_MAX_NUM_OF_TASKS 128
#ifdef __aarch64__
#define BMI_MAX_NUM_OF_DMAS 84
#define FM_NUM_OF_CTRL 4
#else
#define BMI_MAX_NUM_OF_DMAS 32
#define FM_NUM_OF_CTRL 2
#endif
#define BMI_MAX_FIFO_SIZE (FM_MURAM_SIZE)
#define PORT_MAX_WEIGHT 16
#define FM_CHECK_PORT_RESTRICTIONS(__validPorts, __newPortIndx) TRUE
#ifndef __aarch64__
/* P5020 unique features */
#define FM_QMI_DEQ_OPTIONS_SUPPORT
#define FM_NO_DISPATCH_RAM_ECC
@ -250,8 +349,6 @@ typedef enum
#define FM_IM_LARGE_MRBLR_ERRATA_FMAN15 /* Implemented by ucode */
#define FM_BMI_TO_RISC_ENQ_ERRATA_FMANc /* No implementation, Out of LLD scope */
#define FM_INVALID_SWPRS_DATA_ERRATA_FMANd
//#define FM_PRS_MPLS_SSA_ERRATA_FMANj /* No implementation, No patch yet */
//#define FM_PRS_INITIAL_PLANID_ERRATA_FMANk /* No implementation, No patch yet */
#define FM_NO_COPY_CTXA_CTXB_ERRATA_FMAN_SW001
@ -260,16 +357,35 @@ typedef enum
/* P2041 */
#define FM_BAD_VLAN_DETECT_ERRATA_10GMAC_A010
/* Common to all */
/* Common to P5020 */
#define FM_RX_PREAM_4_ERRATA_DTSEC_A001 FM_NO_RX_PREAM_ERRATA_DTSECx1
#define FM_UCODE_NOT_RESET_ERRATA_BUGZILLA6173
#define FM_MAGIC_PACKET_UNRECOGNIZED_ERRATA_DTSEC2 /* No implementation, Out of LLD scope */
#define FM_PRS_MEM_ERRATA_FMAN_SW003
#else /* __aarch64__ — LS1046A / FManv3 errata and features */
#define FM_OP_OPEN_DMA_MIN_LIMIT
#define FM_NO_RESTRICT_ON_ACCESS_RSRC
#define FM_NO_OP_OBSERVED_POOLS
#define FM_FRAME_END_PARAMS_FOR_OP
#define FM_DEQ_PIPELINE_PARAMS_FOR_OP
#define FM_QMI_NO_SINGLE_ECC_EXCEPTION
#define FM_NO_GUARANTEED_RESET_VALUES
/* LS1046A / FManv3 errata */
#define FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669
#define FM_WRONG_RESET_VALUES_ERRATA_FMAN_A005127
#define FM_RX_FIFO_CORRUPT_ERRATA_10GMAC_A006320
#define FM_OP_NO_VSP_NO_RELEASE_ERRATA_FMAN_A006675
#define FM_HEAVY_TRAFFIC_SEQUENCER_HANG_ERRATA_FMAN_A006981
#define FM_BCB_ERRATA_BMI_SW001
#define FM_AID_MODE_NO_TNUM_SW005
#define FM_ERROR_VSP_NO_MATCH_SW006
#endif /* __aarch64__ */
/* Common to all platforms */
#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 */

View file

@ -44,8 +44,14 @@
#include "enet_ext.h"
#include "dpaa_integration_ext.h"
#if defined(NCSW_ARM_CORE)
/* ARM64 — LS1046A has 4x Cortex-A72; no PPC core type */
#define INTG_MAX_NUM_OF_CORES 4
#else
/* PowerPC — P5020/P3041/P5040 */
#define CORE_E500MC
#define INTG_MAX_NUM_OF_CORES 24
#endif
/**************************************************************************//*
@Description Part data structure - must be contained in any integration

View file

@ -36,7 +36,7 @@
#include <machine/pio.h>
#if !defined(__bool_true_false_are_defined)
typedef boolean_t bool;
typedef _Bool bool;
#endif
#define TRUE 1
#define FALSE 0
@ -48,22 +48,39 @@ typedef vm_paddr_t physAddress_t;
/**
* Accessor defines.
* TODO: These are only stubs and have to be redefined (use bus_space
* facilities).
* DPAA1 registers are big-endian. On PowerPC (big-endian), native
* in32/out32 match. On ARM64 (little-endian), use the reverse-byte
* variants (in32rb/out32rb) to byte-swap.
*/
#ifdef __aarch64__
#define GET_UINT32(arg) in32rb(&(arg))
#define GET_UINT64(arg) in64(&(arg))
#define _WRITE_UINT32(arg, data) out32rb(&(arg), (data))
#define _WRITE_UINT64(arg, data) out64(&(arg), (data))
#else
#define GET_UINT32(arg) in32(&(arg))
#define GET_UINT64(arg) in64(&(arg))
#define _WRITE_UINT32(arg, data) out32(&(arg), (data))
#define _WRITE_UINT64(arg, data) out64(&(arg), (data))
#endif
#ifndef QE_32_BIT_ACCESS_RESTRICTION
#ifdef __aarch64__
#define GET_UINT8(arg) in8(&(arg))
#define GET_UINT16(arg) in16rb(&(arg))
#define _WRITE_UINT8(arg, data) out8(&(arg), (data))
#define _WRITE_UINT16(arg, data) out16rb(&(arg), (data))
#else
#define GET_UINT8(arg) in8(&(arg))
#define GET_UINT16(arg) in16(&(arg))
#define _WRITE_UINT8(arg, data) out8(&(arg), (data))
#define _WRITE_UINT16(arg, data) out16(&(arg), (data))
#endif
#else /* QE_32_BIT_ACCESS_RESTRICTION */

60
sys/contrib/ncsw/user/env/core_arm64.c vendored Normal file
View file

@ -0,0 +1,60 @@
/*-
* Copyright (c) 2026 Mono Technologies 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 THE AUTHOR OR CONTRIBUTORS 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.
*/
/*
* ARM64 core functions for NetCommSW (DPAA1).
* Equivalent to core.c (which provides E500_GetId for PowerPC).
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/pcpu.h>
#include <machine/atomic.h>
#include "types_ext.h"
#include "core_ext.h"
uint32_t
ARM64_GetId(void)
{
return (PCPU_GET(cpuid));
}
int
ARM64_TestAndSet(volatile int *p)
{
return (!atomic_cmpset_int((volatile u_int *)p, 0, 1));
}
void
ARM64_InstructionSync(void)
{
__asm __volatile("isb" ::: "memory");
}

797
sys/contrib/ncsw/user/env/xx_arm64.c vendored Normal file
View file

@ -0,0 +1,797 @@
/*-
* Copyright (c) 2011 Semihalf.
* Copyright (c) 2026 Mono Technologies 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 THE AUTHOR OR CONTRIBUTORS 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.
*/
/*
* NetCommSW (ncsw) environment layer for FreeBSD ARM64.
*
* Adapted from xx.c (PowerPC version) by Semihalf. Key differences:
*
* 1. No ccsrbar_va/pa (ARM64 uses FDT-based bus_space mappings)
* 2. No law_enable (ARM64 doesn't have Local Access Windows)
* 3. No powerpc_intr_mask/unmask (GIC handles interrupt masking)
* 4. No TLB1 management (ARM64 uses page tables)
* 5. XX_VirtToPhys/XX_PhysToVirt use DMAP exclusively
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/bus.h>
#include <sys/interrupt.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/queue.h>
#include <sys/rman.h>
#include <sys/sched.h>
#include <machine/stdarg.h>
#include <sys/taskqueue.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_page.h>
#include <machine/cpufunc.h>
#include <machine/pmap.h>
#include <dev/dpaa/bman.h>
#include <dev/dpaa/qman.h>
#include <dev/dpaa/portals.h>
#include "error_ext.h"
#include "std_ext.h"
#include "list_ext.h"
#include "mm_ext.h"
/* Malloc Pool for NetCommSW */
MALLOC_DEFINE(M_NETCOMMSW, "NetCommSW", "NetCommSW software stack");
MALLOC_DEFINE(M_NETCOMMSW_MT, "NetCommSWTrack",
"NetCommSW software allocation tracker");
static struct mtx XX_MallocTrackLock;
MTX_SYSINIT(XX_MallocTrackLockInit, &XX_MallocTrackLock,
"NetCommSW MallocTrack Lock", MTX_DEF);
/* Interrupt info */
#define XX_INTR_FLAG_PREALLOCATED (1 << 0)
/*
* ARM64 GIC can have many more interrupts than PowerPC (INTR_VECTORS=256).
* DPAA1 only uses a handful; 512 is plenty.
*/
#define XX_MAX_INTR 512
struct XX_IntrInfo {
driver_intr_t *handler;
void *arg;
int cpu;
int flags;
void *cookie;
/* NAPI mode: non-NULL napi_tq enables FILTER handler */
struct taskqueue *napi_tq;
struct task *napi_task;
t_Handle napi_portal;
};
static struct XX_IntrInfo XX_IntrInfo[XX_MAX_INTR];
/* Portal type identifiers */
enum XX_PortalIdent{
BM_PORTAL = 0,
QM_PORTAL,
};
/* Structure to store portals' properties */
struct XX_PortalInfo {
vm_paddr_t portal_ce_pa[2][MAXCPU];
vm_paddr_t portal_ci_pa[2][MAXCPU];
uint32_t portal_ce_size[2][MAXCPU];
uint32_t portal_ci_size[2][MAXCPU];
vm_offset_t portal_ce_va[2];
vm_offset_t portal_ci_va[2];
uintptr_t portal_intr[2][MAXCPU];
};
static struct XX_PortalInfo XX_PInfo;
void
XX_Exit(int status)
{
panic("NetCommSW: Exit called with status %i", status);
}
void
XX_Print(char *str, ...)
{
va_list ap;
va_start(ap, str);
vprintf(str, ap);
va_end(ap);
}
void *
XX_Malloc(uint32_t size)
{
void *p = (malloc(size, M_NETCOMMSW, M_NOWAIT));
return (p);
}
/*
* XX_MallocSmartInit — no-op, kept for API compatibility.
* Previously allocated a fixed contigmalloc pool; now XX_MallocSmart
* delegates to XX_Malloc (kernel heap) with manual alignment, matching
* the Linux NCSW implementation.
*/
int
XX_MallocSmartInit(void)
{
return (E_OK);
}
/*
* XX_MallocSmart — aligned allocation via kernel heap.
*
* Matches Linux NCSW xx_arm_linux.c: allocate size + alignment + header,
* align the returned pointer, store the original malloc pointer in the
* word immediately before it so XX_FreeSmart can recover it.
*/
void *
XX_MallocSmart(uint32_t size, int memPartitionId, uint32_t alignment)
{
uintptr_t *aligned, raw;
if (alignment < sizeof(uintptr_t))
alignment = sizeof(uintptr_t);
size += alignment + sizeof(uintptr_t);
raw = (uintptr_t)XX_Malloc(size);
if (raw == 0)
return (NULL);
aligned = (uintptr_t *)((raw + alignment + sizeof(uintptr_t))
& ~((uintptr_t)alignment - 1));
*(aligned - 1) = raw;
return ((void *)aligned);
}
void
XX_FreeSmart(void *p)
{
if (p != NULL)
XX_Free((void *)(*(((uintptr_t *)p) - 1)));
}
void
XX_Free(void *p)
{
free(p, M_NETCOMMSW);
}
uint32_t
XX_DisableAllIntr(void)
{
return (intr_disable());
}
void
XX_RestoreAllIntr(uint32_t flags)
{
intr_restore(flags);
}
static bool
XX_IsPortalIntr(uintptr_t irq)
{
int cpu, type;
/* Check interrupt numbers of all available portals */
for (type = 0; type < 2; type++)
for (cpu = 0; cpu < MAXCPU; cpu++)
if (irq == XX_PInfo.portal_intr[type][cpu])
return (1);
return (0);
}
static void
XX_Dispatch(void *arg)
{
struct XX_IntrInfo *info;
info = arg;
if (info->handler == NULL) {
printf("%s(): IRQ handler is NULL!\n", __func__);
return;
}
info->handler(info->arg);
}
/*
* FILTER interrupt handler for NAPI-style portal processing.
* Runs in hard IRQ context — inhibits portal interrupts at the
* source (IIR=1) and schedules a taskqueue task for deferred
* DQRR/MR drain. Matches Linux's portal_isr → napi_schedule pattern.
*/
static int
XX_PortalFilter(void *arg)
{
struct XX_IntrInfo *info = arg;
if (__predict_false(info->napi_portal == NULL))
return (FILTER_STRAY);
QM_PORTAL_Inhibit(info->napi_portal);
taskqueue_enqueue(info->napi_tq, info->napi_task);
return (FILTER_HANDLED);
}
/*
* Configure NAPI mode for a portal interrupt. Must be called
* before QM_PORTAL_Init (which calls XX_SetIntr internally).
*/
void XX_ConfigPortalNapi(uintptr_t irq, struct taskqueue *tq, struct task *task);
void XX_SetPortalNapiHandle(uintptr_t irq, t_Handle portal);
void
XX_ConfigPortalNapi(uintptr_t irq, struct taskqueue *tq, struct task *task)
{
struct resource *r;
unsigned int inum;
r = (struct resource *)irq;
inum = rman_get_start(r);
if (inum >= XX_MAX_INTR)
return;
XX_IntrInfo[inum].napi_tq = tq;
XX_IntrInfo[inum].napi_task = task;
XX_IntrInfo[inum].napi_portal = NULL;
}
/*
* Set the portal handle for a NAPI-configured interrupt.
* Called after QM_PORTAL_Init returns the portal handle.
*/
void
XX_SetPortalNapiHandle(uintptr_t irq, t_Handle portal)
{
struct resource *r;
unsigned int inum;
r = (struct resource *)irq;
inum = rman_get_start(r);
if (inum >= XX_MAX_INTR)
return;
XX_IntrInfo[inum].napi_portal = portal;
}
t_Error
XX_PreallocAndBindIntr(device_t dev, uintptr_t irq, unsigned int cpu)
{
struct resource *r;
unsigned int inum;
r = (struct resource *)irq;
inum = rman_get_start(r);
if (inum >= XX_MAX_INTR) {
printf("NetCommSW: IRQ %u exceeds XX_MAX_INTR (%d)\n",
inum, XX_MAX_INTR);
return (E_FULL);
}
/*
* Don't call bus_setup_intr here — just record the CPU binding.
* The OS interrupt handler will be registered later when the
* portal driver calls XX_SetIntr with a real handler. This
* prevents interrupt storms from stale portal state on warm
* reboot (portal hardware may assert IRQ before the driver
* is ready to clear it).
*/
XX_IntrInfo[inum].flags = XX_INTR_FLAG_PREALLOCATED;
XX_IntrInfo[inum].cpu = cpu;
return (E_OK);
}
t_Error
XX_DeallocIntr(uintptr_t irq)
{
struct resource *r;
unsigned int inum;
r = (struct resource *)irq;
inum = rman_get_start(r);
if (inum >= XX_MAX_INTR)
return (E_INVALID_STATE);
if ((XX_IntrInfo[inum].flags & XX_INTR_FLAG_PREALLOCATED) == 0)
return (E_INVALID_STATE);
XX_IntrInfo[inum].flags = 0;
XX_IntrInfo[inum].handler = NULL;
XX_IntrInfo[inum].arg = NULL;
/* Tear down OS handler only if it was registered */
if (XX_IntrInfo[inum].cookie != NULL)
return (XX_FreeIntr(irq));
return (E_OK);
}
t_Error
XX_SetIntr(uintptr_t irq, t_Isr *f_Isr, t_Handle handle)
{
device_t dev;
struct resource *r;
unsigned int flags;
int err;
r = (struct resource *)irq;
dev = rman_get_device(r);
irq = rman_get_start(r);
if (irq >= XX_MAX_INTR)
return (E_FULL);
/* Handle preallocated interrupts */
if (XX_IntrInfo[irq].flags & XX_INTR_FLAG_PREALLOCATED) {
if (XX_IntrInfo[irq].handler != NULL)
return (E_BUSY);
XX_IntrInfo[irq].handler = f_Isr;
XX_IntrInfo[irq].arg = handle;
/* Register OS handler now that portal driver is ready */
if (XX_IntrInfo[irq].cookie == NULL) {
unsigned int iflags;
int err;
iflags = INTR_TYPE_NET | INTR_MPSAFE;
if (XX_IsPortalIntr(irq))
iflags |= INTR_EXCL;
if (XX_IntrInfo[irq].napi_tq != NULL) {
/* NAPI mode: FILTER-only, no ithread */
err = bus_setup_intr(dev, r, iflags,
XX_PortalFilter, NULL,
&XX_IntrInfo[irq],
&XX_IntrInfo[irq].cookie);
} else {
/* Legacy ithread mode */
err = bus_setup_intr(dev, r, iflags, NULL,
XX_Dispatch, &XX_IntrInfo[irq],
&XX_IntrInfo[irq].cookie);
}
if (err)
return (E_NOT_AVAILABLE);
bus_bind_intr(dev, r, XX_IntrInfo[irq].cpu);
}
return (E_OK);
}
flags = INTR_TYPE_NET | INTR_MPSAFE;
/* BMAN/QMAN Portal interrupts must be exclusive */
if (XX_IsPortalIntr(irq))
flags |= INTR_EXCL;
err = bus_setup_intr(dev, r, flags, NULL, f_Isr, handle,
&XX_IntrInfo[irq].cookie);
return (err);
}
t_Error
XX_FreeIntr(uintptr_t irq)
{
device_t dev;
struct resource *r;
r = (struct resource *)irq;
dev = rman_get_device(r);
irq = rman_get_start(r);
if (irq >= XX_MAX_INTR)
return (E_INVALID_STATE);
/* Handle preallocated interrupts */
if (XX_IntrInfo[irq].flags & XX_INTR_FLAG_PREALLOCATED) {
if (XX_IntrInfo[irq].handler == NULL)
return (E_INVALID_STATE);
XX_IntrInfo[irq].handler = NULL;
XX_IntrInfo[irq].arg = NULL;
return (E_OK);
}
return (bus_teardown_intr(dev, r, XX_IntrInfo[irq].cookie));
}
t_Error
XX_EnableIntr(uintptr_t irq)
{
/*
* On ARM64 with GIC, interrupt masking/unmasking is handled
* by the interrupt framework. Portal interrupts are set up
* with INTR_EXCL; the GIC re-enables them after handler return.
*/
(void)irq;
return (E_OK);
}
t_Error
XX_DisableIntr(uintptr_t irq)
{
/*
* See XX_EnableIntr — no explicit mask needed on ARM64.
*/
(void)irq;
return (E_OK);
}
t_TaskletHandle
XX_InitTasklet (void (*routine)(void *), void *data)
{
/* Not referenced */
printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
return (NULL);
}
void
XX_FreeTasklet (t_TaskletHandle h_Tasklet)
{
/* Not referenced */
printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
}
int
XX_ScheduleTask(t_TaskletHandle h_Tasklet, int immediate)
{
/* Not referenced */
printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
return (0);
}
void
XX_FlushScheduledTasks(void)
{
/* Not referenced */
printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
}
int
XX_TaskletIsQueued(t_TaskletHandle h_Tasklet)
{
/* Not referenced */
printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
return (0);
}
void
XX_SetTaskletData(t_TaskletHandle h_Tasklet, t_Handle data)
{
/* Not referenced */
printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
}
t_Handle
XX_GetTaskletData(t_TaskletHandle h_Tasklet)
{
/* Not referenced */
printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
return (NULL);
}
t_Handle
XX_InitSpinlock(void)
{
struct mtx *m;
m = malloc(sizeof(*m), M_NETCOMMSW, M_NOWAIT | M_ZERO);
if (!m)
return (0);
mtx_init(m, "NetCommSW Lock", NULL, MTX_DEF | MTX_DUPOK);
return (m);
}
void
XX_FreeSpinlock(t_Handle h_Spinlock)
{
struct mtx *m;
m = h_Spinlock;
mtx_destroy(m);
free(m, M_NETCOMMSW);
}
void
XX_LockSpinlock(t_Handle h_Spinlock)
{
struct mtx *m;
m = h_Spinlock;
mtx_lock(m);
}
void
XX_UnlockSpinlock(t_Handle h_Spinlock)
{
struct mtx *m;
m = h_Spinlock;
mtx_unlock(m);
}
uint32_t
XX_LockIntrSpinlock(t_Handle h_Spinlock)
{
XX_LockSpinlock(h_Spinlock);
return (0);
}
void
XX_UnlockIntrSpinlock(t_Handle h_Spinlock, uint32_t intrFlags)
{
XX_UnlockSpinlock(h_Spinlock);
}
uint32_t
XX_Sleep(uint32_t msecs)
{
XX_UDelay(1000 * msecs);
return (0);
}
void
XX_UDelay(uint32_t usecs)
{
DELAY(usecs);
}
t_Error
XX_IpcRegisterMsgHandler(char addr[XX_IPC_MAX_ADDR_NAME_LENGTH],
t_IpcMsgHandler *f_MsgHandler, t_Handle h_Module, uint32_t replyLength)
{
/*
* This function returns fake E_OK status and does nothing
* as NetCommSW IPC is not used by FreeBSD drivers.
*/
return (E_OK);
}
t_Error
XX_IpcUnregisterMsgHandler(char addr[XX_IPC_MAX_ADDR_NAME_LENGTH])
{
/*
* This function returns fake E_OK status and does nothing
* as NetCommSW IPC is not used by FreeBSD drivers.
*/
return (E_OK);
}
t_Error
XX_IpcSendMessage(t_Handle h_Session,
uint8_t *p_Msg, uint32_t msgLength, uint8_t *p_Reply,
uint32_t *p_ReplyLength, t_IpcMsgCompletion *f_Completion, t_Handle h_Arg)
{
/* Should not be called */
printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
return (E_OK);
}
t_Handle
XX_IpcInitSession(char destAddr[XX_IPC_MAX_ADDR_NAME_LENGTH],
char srcAddr[XX_IPC_MAX_ADDR_NAME_LENGTH])
{
/* Should not be called */
printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
return (NULL);
}
t_Error
XX_IpcFreeSession(t_Handle h_Session)
{
/* Should not be called */
printf("NetCommSW: Unimplemented function %s() called!\n", __func__);
return (E_OK);
}
physAddress_t
XX_VirtToPhys(void *addr)
{
vm_paddr_t paddr;
int cpu;
cpu = PCPU_GET(cpuid);
/* Handle NULL address */
if (addr == NULL)
return (-1);
/*
* No CCSR check needed on ARM64 — registers are mapped via
* bus_space, not through a global ccsrbar mapping.
*/
/* Handle BMAN mappings */
if (((vm_offset_t)addr >= XX_PInfo.portal_ce_va[BM_PORTAL]) &&
((vm_offset_t)addr < XX_PInfo.portal_ce_va[BM_PORTAL] +
XX_PInfo.portal_ce_size[BM_PORTAL][cpu]))
return (XX_PInfo.portal_ce_pa[BM_PORTAL][cpu] +
(vm_offset_t)addr - XX_PInfo.portal_ce_va[BM_PORTAL]);
if (((vm_offset_t)addr >= XX_PInfo.portal_ci_va[BM_PORTAL]) &&
((vm_offset_t)addr < XX_PInfo.portal_ci_va[BM_PORTAL] +
XX_PInfo.portal_ci_size[BM_PORTAL][cpu]))
return (XX_PInfo.portal_ci_pa[BM_PORTAL][cpu] +
(vm_offset_t)addr - XX_PInfo.portal_ci_va[BM_PORTAL]);
/* Handle QMAN mappings */
if (((vm_offset_t)addr >= XX_PInfo.portal_ce_va[QM_PORTAL]) &&
((vm_offset_t)addr < XX_PInfo.portal_ce_va[QM_PORTAL] +
XX_PInfo.portal_ce_size[QM_PORTAL][cpu]))
return (XX_PInfo.portal_ce_pa[QM_PORTAL][cpu] +
(vm_offset_t)addr - XX_PInfo.portal_ce_va[QM_PORTAL]);
if (((vm_offset_t)addr >= XX_PInfo.portal_ci_va[QM_PORTAL]) &&
((vm_offset_t)addr < XX_PInfo.portal_ci_va[QM_PORTAL] +
XX_PInfo.portal_ci_size[QM_PORTAL][cpu]))
return (XX_PInfo.portal_ci_pa[QM_PORTAL][cpu] +
(vm_offset_t)addr - XX_PInfo.portal_ci_va[QM_PORTAL]);
/* ARM64 always has DMAP */
if ((vm_offset_t)addr >= DMAP_MIN_ADDRESS &&
(vm_offset_t)addr < DMAP_MAX_ADDRESS)
return (DMAP_TO_PHYS((vm_offset_t)addr));
paddr = pmap_kextract((vm_offset_t)addr);
if (paddr == 0)
printf("NetCommSW: "
"Unable to translate virtual address %p!\n", addr);
return (paddr);
}
void *
XX_PhysToVirt(physAddress_t addr)
{
int cpu;
cpu = PCPU_GET(cpuid);
/*
* No CCSR check needed on ARM64 — see XX_VirtToPhys comment.
*/
/* Handle BMAN mappings */
if ((addr >= XX_PInfo.portal_ce_pa[BM_PORTAL][cpu]) &&
(addr < XX_PInfo.portal_ce_pa[BM_PORTAL][cpu] +
XX_PInfo.portal_ce_size[BM_PORTAL][cpu]))
return ((void *)(XX_PInfo.portal_ce_va[BM_PORTAL] +
(vm_offset_t)(addr - XX_PInfo.portal_ce_pa[BM_PORTAL][cpu])));
if ((addr >= XX_PInfo.portal_ci_pa[BM_PORTAL][cpu]) &&
(addr < XX_PInfo.portal_ci_pa[BM_PORTAL][cpu] +
XX_PInfo.portal_ci_size[BM_PORTAL][cpu]))
return ((void *)(XX_PInfo.portal_ci_va[BM_PORTAL] +
(vm_offset_t)(addr - XX_PInfo.portal_ci_pa[BM_PORTAL][cpu])));
/* Handle QMAN mappings */
if ((addr >= XX_PInfo.portal_ce_pa[QM_PORTAL][cpu]) &&
(addr < XX_PInfo.portal_ce_pa[QM_PORTAL][cpu] +
XX_PInfo.portal_ce_size[QM_PORTAL][cpu]))
return ((void *)(XX_PInfo.portal_ce_va[QM_PORTAL] +
(vm_offset_t)(addr - XX_PInfo.portal_ce_pa[QM_PORTAL][cpu])));
if ((addr >= XX_PInfo.portal_ci_pa[QM_PORTAL][cpu]) &&
(addr < XX_PInfo.portal_ci_pa[QM_PORTAL][cpu] +
XX_PInfo.portal_ci_size[QM_PORTAL][cpu]))
return ((void *)(XX_PInfo.portal_ci_va[QM_PORTAL] +
(vm_offset_t)(addr - XX_PInfo.portal_ci_pa[QM_PORTAL][cpu])));
/*
* Reject PA outside DRAM range (catches stale FD addresses from
* a previous boot and PA=0 which maps below dmap_phys_base).
*/
if (__predict_false(!PHYS_IN_DMAP_RANGE(addr)))
return (NULL);
return ((void *)(uintptr_t)PHYS_TO_DMAP(addr));
}
void
XX_PortalSetInfo(device_t dev)
{
struct dpaa_portals_softc *sc;
const char *dev_name;
int i, type;
dev_name = device_get_name(dev);
if (strcmp(dev_name, "bman-portals") == 0)
type = BM_PORTAL;
else if (strcmp(dev_name, "qman-portals") == 0)
type = QM_PORTAL;
else
return;
sc = device_get_softc(dev);
for (i = 0; i < MAXCPU && sc->sc_dp[i].dp_ce_pa != 0; i++) {
XX_PInfo.portal_ce_pa[type][i] = sc->sc_dp[i].dp_ce_pa;
XX_PInfo.portal_ci_pa[type][i] = sc->sc_dp[i].dp_ci_pa;
XX_PInfo.portal_ce_size[type][i] = sc->sc_dp[i].dp_ce_size;
XX_PInfo.portal_ci_size[type][i] = sc->sc_dp[i].dp_ci_size;
XX_PInfo.portal_intr[type][i] = sc->sc_dp[i].dp_intr_num;
}
XX_PInfo.portal_ce_va[type] = rman_get_bushandle(sc->sc_rres[0]);
XX_PInfo.portal_ci_va[type] = rman_get_bushandle(sc->sc_rres[1]);
}
/*
* Stub for dead FManv3 clock-change code in fm_ncsw.c (FM_ChangeClock).
* fm_clk_down() is referenced but defined under #ifdef TODO_SOC_SUSPEND
* in fm_port.c — never compiled. g_MemacRegs is provided by memac.c.
*/
void fm_clk_down(void);
void
fm_clk_down(void)
{
printf("NetCommSW: fm_clk_down() stub called — not implemented\n");
}