dpaa: PLCR/KG miss fixup, portal quiesce, OH dist callbacks
fm_ehash: Rewrite ModifyMissNextEngine to match Linux SDK two-phase pattern (DROP→update→real action). Support KG (with CC_EN), PLCR (shared profile), and DONE engines. Remove verify-retry loop and CC tree copy propagation — single WRITE_UINT32 per word suffices with the two-phase approach. qman_portals: Add qman_portal_quiesce() to drain all per-CPU portal poll taskqueues. Called after FQR retire to ensure no in-flight QM_PORTAL_Poll references a stale callback from an unloading module. if_dtsec_rm: Add dtsec_rm_pool_rx_refill_bpid() for external callers (CDX dist FQ callback) to trigger BMan pool refill by BPID. dpaa_oh: Add distribution FQ callback registry (register/unregister/ lookup by BPID) for OH port consumers (WiFi, IPsec) to receive frames from CDX distribution FQs. Add MODULE_VERSION.
This commit is contained in:
parent
7e747b3417
commit
5391092ae5
6 changed files with 230 additions and 106 deletions
|
|
@ -592,10 +592,10 @@ ExternalHashTableSet(t_Handle h_FmPcd, t_FmPcdHashTableParams *p_Param)
|
|||
t_FmPcdCcNextKgParams *kgparams =
|
||||
&p_Param->ccNextEngineParamsForMiss.params.kgParams;
|
||||
|
||||
node->word_2 = NIA_ENG_KG | NIA_KG_DIRECT;
|
||||
node->word_2 = NIA_ENG_KG | NIA_KG_DIRECT |
|
||||
NIA_KG_CC_EN;
|
||||
if (kgparams->overrideFqid)
|
||||
node->word_2 |= kgparams->newFqid |
|
||||
NIA_KG_CC_EN;
|
||||
node->word_2 |= kgparams->newFqid;
|
||||
node->word_2 |=
|
||||
FmPcdKgGetSchemeId(kgparams->h_DirectScheme);
|
||||
miss_action = EN_EHASH_MISS_ACTION_NIA;
|
||||
|
|
@ -973,22 +973,31 @@ ExternalHashTableEntryGetStatsAndTS(void *tbl_entry,
|
|||
/*
|
||||
* ExternalHashTableModifyMissNextEngine — Change the miss action.
|
||||
*
|
||||
* Modifies the MURAM AD node directly (via info->h_Ad, set by
|
||||
* copy_td_to_ccbase). ALL 4 words of the AD must be written in
|
||||
* a single batch — partial writes corrupt the unwritten words
|
||||
* (LS1046A MURAM / Normal-NC ARM64 store behavior).
|
||||
* Matches Linux NXP SDK fm_ehash.c:1090-1181 with ARM64 MURAM
|
||||
* write adaptations:
|
||||
*
|
||||
* Uses info->node as the base (unchanged table_base_lo, word_1)
|
||||
* and modifies word_0 (miss action) and word_2 (FQID/NIA).
|
||||
* Also updates info->node so it stays in sync for future calls.
|
||||
* 1. Re-read current AD from MURAM (not cached info->node) — the
|
||||
* CDX microcode or NCSW PCD setup may have modified the AD
|
||||
* since copy_td_to_ccbase() wrote it.
|
||||
*
|
||||
* 2. Two-phase write: set miss action to DROP first, then update
|
||||
* word_2 (NIA/FQID) and word_0 (real miss action). Prevents
|
||||
* microcode from seeing a partially-updated AD.
|
||||
*
|
||||
* 3. All 4 words written in batch — partial writes corrupt
|
||||
* unwritten words (LS1046A MURAM / Normal-NC ARM64 behavior).
|
||||
*
|
||||
* 4. KG always sets NIA_KG_CC_EN (Linux fm_ehash.c:1115).
|
||||
*
|
||||
* 5. PLCR uses newRelativeProfileId directly (Linux fm_ehash.c:1151).
|
||||
*/
|
||||
t_Error
|
||||
ExternalHashTableModifyMissNextEngine(t_Handle h_HashTbl,
|
||||
t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)
|
||||
{
|
||||
struct en_exthash_info *info;
|
||||
volatile uint32_t *p;
|
||||
struct en_exthash_node *ptr;
|
||||
struct en_exthash_node *ad;
|
||||
uint32_t w0, w3;
|
||||
|
||||
info = (struct en_exthash_info *)h_HashTbl;
|
||||
if (info->h_Ad == NULL) {
|
||||
|
|
@ -997,111 +1006,82 @@ ExternalHashTableModifyMissNextEngine(t_Handle h_HashTbl,
|
|||
return (E_INVALID_STATE);
|
||||
}
|
||||
|
||||
ptr = &info->node;
|
||||
ad = (struct en_exthash_node *)info->h_Ad;
|
||||
|
||||
/*
|
||||
* Enhanced hash AD miss action patching.
|
||||
*
|
||||
* Modify word_0 (miss_action bits [31:30]) and word_2 (FQID/NIA)
|
||||
* while preserving table_base_lo and word_1 (hash table params).
|
||||
*
|
||||
* Build #208: reverted from standard Result AD format which the
|
||||
* CDX microcode cannot interpret (build #207 showed all frames
|
||||
* discarded with QMan Invalid Enqueue State for KG baseFqid).
|
||||
* Read current word_0 and word_2 from MURAM.
|
||||
* Match Linux fm_ehash.c:1097-1098.
|
||||
*/
|
||||
{
|
||||
uint32_t fqid = 0;
|
||||
w0 = GET_UINT32(ad->word_0);
|
||||
w3 = GET_UINT32(ad->word_2);
|
||||
|
||||
switch (p_FmPcdCcNextEngineParams->nextEngine) {
|
||||
case e_FM_PCD_DONE: {
|
||||
t_FmPcdCcNextEnqueueParams *enqparams =
|
||||
&p_FmPcdCcNextEngineParams->params.enqueueParams;
|
||||
if (enqparams->overrideFqid)
|
||||
fqid = enqparams->newFqid & 0x00FFFFFF;
|
||||
/*
|
||||
* Phase 1: Set miss action to DROP while we update.
|
||||
* Match Linux fm_ehash.c:1100-1102.
|
||||
* Write ONLY word_0 — do NOT touch other words.
|
||||
*/
|
||||
WRITE_UINT32(ad->word_0, (w0 & ~EHASH_W0_MISS_ACTION_MASK) |
|
||||
EHASH_W0_MISS_ACTION(EN_EHASH_MISS_ACTION_DROP));
|
||||
|
||||
/* Set miss_action to ENQUE, preserve other word_0 fields */
|
||||
ptr->word_0 = (ptr->word_0 & ~EHASH_W0_MISS_ACTION_MASK) |
|
||||
/*
|
||||
* Phase 2: Build new miss action.
|
||||
* Match Linux fm_ehash.c:1105-1164.
|
||||
*/
|
||||
switch (p_FmPcdCcNextEngineParams->nextEngine) {
|
||||
case e_FM_PCD_KG: {
|
||||
t_FmPcdCcNextKgParams *kgparams =
|
||||
&p_FmPcdCcNextEngineParams->params.kgParams;
|
||||
|
||||
w3 = NIA_ENG_KG | NIA_KG_DIRECT | NIA_KG_CC_EN;
|
||||
w3 |= FmPcdKgGetSchemeId(kgparams->h_DirectScheme);
|
||||
w0 = (w0 & ~EHASH_W0_MISS_ACTION_MASK) |
|
||||
EHASH_W0_MISS_ACTION(EN_EHASH_MISS_ACTION_NIA);
|
||||
break;
|
||||
}
|
||||
case e_FM_PCD_PLCR: {
|
||||
t_FmPcdCcNextPlcrParams *plcrparams =
|
||||
&p_FmPcdCcNextEngineParams->params.plcrParams;
|
||||
|
||||
if (plcrparams->sharedProfile)
|
||||
w3 = NIA_ENG_PLCR | NIA_PLCR_ABSOLUTE |
|
||||
plcrparams->newRelativeProfileId;
|
||||
else
|
||||
w3 = NIA_ENG_PLCR |
|
||||
plcrparams->newRelativeProfileId;
|
||||
w0 = (w0 & ~EHASH_W0_MISS_ACTION_MASK) |
|
||||
EHASH_W0_MISS_ACTION(EN_EHASH_MISS_ACTION_NIA);
|
||||
break;
|
||||
}
|
||||
case e_FM_PCD_DONE: {
|
||||
t_FmPcdCcNextEnqueueParams *enqparams =
|
||||
&p_FmPcdCcNextEngineParams->params.enqueueParams;
|
||||
|
||||
if (enqparams->overrideFqid) {
|
||||
w3 = enqparams->newFqid;
|
||||
w0 = (w0 & ~EHASH_W0_MISS_ACTION_MASK) |
|
||||
EHASH_W0_MISS_ACTION(EN_EHASH_MISS_ACTION_ENQUE);
|
||||
ptr->word_2 = fqid;
|
||||
break;
|
||||
} else {
|
||||
w0 = (w0 & ~EHASH_W0_MISS_ACTION_MASK) |
|
||||
EHASH_W0_MISS_ACTION(EN_EHASH_MISS_ACTION_DONE);
|
||||
}
|
||||
default:
|
||||
printf("fm_ehash: ModifyMiss: unhandled engine %d\n",
|
||||
p_FmPcdCcNextEngineParams->nextEngine);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
printf("fm_ehash: ModifyMiss: unhandled engine %d\n",
|
||||
p_FmPcdCcNextEngineParams->nextEngine);
|
||||
w0 = (w0 & ~EHASH_W0_MISS_ACTION_MASK) |
|
||||
EHASH_W0_MISS_ACTION(EN_EHASH_MISS_ACTION_DROP);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the 16-byte AD to MURAM.
|
||||
* Verify + retry in case of CCI-400/AXI flush timing.
|
||||
* Phase 3: Write ONLY word_2 then word_0 to MURAM.
|
||||
* Match Linux fm_ehash.c:1166-1167 exactly.
|
||||
* Use WRITE_UINT32 (NCSW macro = out32rb + dsb per store).
|
||||
* Do NOT touch table_base_lo or word_1.
|
||||
*/
|
||||
p = (volatile uint32_t *)info->h_Ad;
|
||||
{
|
||||
uint32_t v0, v1, v2, v3;
|
||||
int retry;
|
||||
|
||||
for (retry = 0; retry < 4; retry++) {
|
||||
muram_wr32(&p[2], ptr->word_1); /* offset 8 */
|
||||
muram_wr32(&p[1], ptr->table_base_lo); /* offset 4 */
|
||||
muram_wr32(&p[3], ptr->word_2); /* offset 12 */
|
||||
muram_wr32(&p[0], ptr->word_0); /* offset 0 */
|
||||
muram_barrier();
|
||||
|
||||
v0 = muram_rd32(&p[0]);
|
||||
v1 = muram_rd32(&p[1]);
|
||||
v2 = muram_rd32(&p[2]);
|
||||
v3 = muram_rd32(&p[3]);
|
||||
if (v0 == ptr->word_0 &&
|
||||
v1 == ptr->table_base_lo &&
|
||||
v2 == ptr->word_1 &&
|
||||
v3 == ptr->word_2)
|
||||
break;
|
||||
|
||||
printf("fm_ehash: ModifyMiss AD=%p attempt %d "
|
||||
"VERIFY FAIL [%08x %08x %08x %08x] != "
|
||||
"[%08x %08x %08x %08x]\n",
|
||||
info->h_Ad, retry + 1,
|
||||
v0, v1, v2, v3,
|
||||
ptr->word_0, ptr->table_base_lo,
|
||||
ptr->word_1, ptr->word_2);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Propagate miss action to CC tree copy entries.
|
||||
*
|
||||
* The CC tree fill logic (fm_cc.c CcRootBuild) copies entry 0
|
||||
* to unused slots (indices numOfEntries..15) via raw memcpy.
|
||||
* These copies have the pre-ModifyMiss state because
|
||||
* copy_td_to_ccbase only tracks a single h_Ad per hash table.
|
||||
*
|
||||
* Scan all 16 CC tree entries: any entry (other than h_Ad
|
||||
* itself) that is a copy and needs its miss action updated.
|
||||
*
|
||||
* CC tree is 256-byte aligned (FM_PCD_CC_TREE_ADDR_ALIGN).
|
||||
*/
|
||||
{
|
||||
uintptr_t tree_base =
|
||||
(uintptr_t)info->h_Ad & ~(uintptr_t)0xFF;
|
||||
int j;
|
||||
|
||||
for (j = 0; j < FM_PCD_MAX_NUM_OF_CC_GROUPS; j++) {
|
||||
volatile uint32_t *ep = (volatile uint32_t *)
|
||||
(tree_base + j * FM_PCD_CC_AD_ENTRY_SIZE);
|
||||
if (ep == (volatile uint32_t *)info->h_Ad)
|
||||
continue; /* skip the entry we just wrote */
|
||||
if (muram_rd32(&ep[1]) == ptr->table_base_lo) {
|
||||
/* Copy with same table — update all 4 words */
|
||||
muram_wr32(&ep[2], ptr->word_1);
|
||||
muram_wr32(&ep[1], ptr->table_base_lo);
|
||||
muram_wr32(&ep[3], ptr->word_2);
|
||||
muram_wr32(&ep[0], ptr->word_0);
|
||||
muram_barrier();
|
||||
}
|
||||
}
|
||||
}
|
||||
WRITE_UINT32(ad->word_2, w3);
|
||||
WRITE_UINT32(ad->word_0, w0);
|
||||
|
||||
return (E_OK);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -436,6 +436,77 @@ dpaa_oh_detach(device_t dev)
|
|||
/** @} */
|
||||
|
||||
|
||||
/**
|
||||
* @group Distribution FQ callback registry.
|
||||
*
|
||||
* BPID-keyed table for OH port consumers to register distribution FQ
|
||||
* handlers. CDX calls dpaa_oh_lookup_dist_cb() in its distribution
|
||||
* FQ callback to dispatch frames to the appropriate consumer.
|
||||
* @{
|
||||
*/
|
||||
#define DPAA_OH_MAX_DIST_CBS 4
|
||||
|
||||
static struct {
|
||||
uint8_t bpid;
|
||||
bool active;
|
||||
dpaa_oh_dist_cb_t fn;
|
||||
t_Handle app;
|
||||
} dpaa_oh_dist_cbs[DPAA_OH_MAX_DIST_CBS];
|
||||
|
||||
int
|
||||
dpaa_oh_register_dist_cb(uint8_t bpid, dpaa_oh_dist_cb_t fn, t_Handle app)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < DPAA_OH_MAX_DIST_CBS; i++) {
|
||||
if (!dpaa_oh_dist_cbs[i].active) {
|
||||
dpaa_oh_dist_cbs[i].bpid = bpid;
|
||||
dpaa_oh_dist_cbs[i].fn = fn;
|
||||
dpaa_oh_dist_cbs[i].app = app;
|
||||
atomic_thread_fence_rel();
|
||||
dpaa_oh_dist_cbs[i].active = true;
|
||||
printf("dpaa_oh: dist cb registered for bpid %u\n",
|
||||
bpid);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
return (ENOSPC);
|
||||
}
|
||||
|
||||
void
|
||||
dpaa_oh_unregister_dist_cb(uint8_t bpid)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < DPAA_OH_MAX_DIST_CBS; i++) {
|
||||
if (dpaa_oh_dist_cbs[i].active &&
|
||||
dpaa_oh_dist_cbs[i].bpid == bpid) {
|
||||
dpaa_oh_dist_cbs[i].active = false;
|
||||
atomic_thread_fence_rel();
|
||||
printf("dpaa_oh: dist cb unregistered for bpid %u\n",
|
||||
bpid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dpaa_oh_dist_cb_t
|
||||
dpaa_oh_lookup_dist_cb(uint8_t bpid, t_Handle *app)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < DPAA_OH_MAX_DIST_CBS; i++) {
|
||||
if (dpaa_oh_dist_cbs[i].active &&
|
||||
dpaa_oh_dist_cbs[i].bpid == bpid) {
|
||||
*app = dpaa_oh_dist_cbs[i].app;
|
||||
return (dpaa_oh_dist_cbs[i].fn);
|
||||
}
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
/** @} */
|
||||
|
||||
|
||||
/**
|
||||
* @group Public API.
|
||||
* @{
|
||||
|
|
@ -563,4 +634,5 @@ static driver_t dpaa_oh_driver = {
|
|||
};
|
||||
|
||||
DRIVER_MODULE(dpaa_oh, fman, dpaa_oh_driver, 0, 0);
|
||||
MODULE_VERSION(dpaa_oh, 1);
|
||||
/** @} */
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
#include <contrib/ncsw/inc/ncsw_ext.h>
|
||||
#include <contrib/ncsw/inc/integrations/dpaa_integration_ext.h>
|
||||
#include <contrib/ncsw/inc/Peripherals/dpaa_ext.h>
|
||||
#include <contrib/ncsw/inc/Peripherals/qm_ext.h>
|
||||
|
||||
/**
|
||||
* Find an OH port device by its cell-index (hardware port ID).
|
||||
|
|
@ -87,4 +89,29 @@ int dpaa_oh_enqueue(device_t dev, t_DpaaFD *fd);
|
|||
int dpaa_oh_register_cb(device_t dev,
|
||||
t_QmReceivedFrameCallback *callback, t_Handle app);
|
||||
|
||||
/**
|
||||
* Distribution FQ callback type.
|
||||
* Same signature as t_QmReceivedFrameCallback.
|
||||
*/
|
||||
typedef e_RxStoreResponse (*dpaa_oh_dist_cb_t)(t_Handle app,
|
||||
t_Handle fqr, t_Handle portal, uint32_t fqid_off, t_DpaaFD *fd);
|
||||
|
||||
/**
|
||||
* Register a distribution FQ callback keyed by BMan pool ID.
|
||||
*
|
||||
* When CDX takes over PCD, frames matching KeyGen distribution
|
||||
* schemes on OH ports arrive at CDX distribution FQs. OH port
|
||||
* consumers (WiFi, IPsec) register here so CDX can dispatch
|
||||
* these frames instead of dropping them.
|
||||
*
|
||||
* @param bpid BMan pool ID that identifies the consumer's frames.
|
||||
* @param fn Callback function for frame delivery.
|
||||
* @param app Opaque argument passed to callback.
|
||||
* @return 0 on success, ENOSPC if registry is full.
|
||||
*/
|
||||
int dpaa_oh_register_dist_cb(uint8_t bpid,
|
||||
dpaa_oh_dist_cb_t fn, t_Handle app);
|
||||
void dpaa_oh_unregister_dist_cb(uint8_t bpid);
|
||||
dpaa_oh_dist_cb_t dpaa_oh_lookup_dist_cb(uint8_t bpid, t_Handle *app);
|
||||
|
||||
#endif /* DPAA_OH_H_ */
|
||||
|
|
|
|||
|
|
@ -663,6 +663,30 @@ dtsec_rm_buf_free_external(uint8_t bpid, void *buf)
|
|||
(void *)(*(uintptr_t *)buf)); /* recover stashed KVA */
|
||||
atomic_subtract_32(&sc->sc_rx_buf_total, 1);
|
||||
}
|
||||
|
||||
void
|
||||
dtsec_rm_pool_rx_refill_bpid(uint8_t bpid)
|
||||
{
|
||||
struct dtsec_softc *sc;
|
||||
uint32_t total;
|
||||
unsigned int n, added;
|
||||
|
||||
sc = dtsec_bpid_map[bpid];
|
||||
if (__predict_false(sc == NULL))
|
||||
return;
|
||||
|
||||
if (__predict_false(bman_count(sc->sc_rx_pool) <
|
||||
DTSEC_RM_POOL_RX_REFILL_THRESH) &&
|
||||
atomic_load_32(&sc->sc_rx_buf_total) <
|
||||
DTSEC_RM_POOL_RX_MAX_TOTAL) {
|
||||
total = atomic_load_32(&sc->sc_rx_buf_total);
|
||||
n = DTSEC_RM_POOL_RX_REFILL_COUNT;
|
||||
if (n > DTSEC_RM_POOL_RX_MAX_TOTAL - total)
|
||||
n = DTSEC_RM_POOL_RX_MAX_TOTAL - total;
|
||||
added = dtsec_rm_pool_rx_refill(sc, n);
|
||||
atomic_add_32(&sc->sc_rx_buf_total, added);
|
||||
}
|
||||
}
|
||||
/** @} */
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -280,6 +280,7 @@ uint32_t qman_get_sfdr_in_use(void);
|
|||
t_Handle qman_portal_init_cpu(struct qman_softc *, int);
|
||||
void qman_portal_dqrr_diag(void);
|
||||
void qman_ccsr_diag(void);
|
||||
void qman_portal_quiesce(void);
|
||||
struct mbuf;
|
||||
void qman_rx_defer(struct mbuf *);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -285,6 +285,26 @@ qman_portal_poll_task(void *arg, int pending)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* qman_portal_quiesce — Drain all per-CPU portal poll taskqueues.
|
||||
*
|
||||
* Waits for any in-flight QM_PORTAL_Poll() call to complete on every
|
||||
* CPU. Must be called after retiring FQRs to ensure no portal poll
|
||||
* task references a stale DQRR callback from a module about to be
|
||||
* unloaded.
|
||||
*/
|
||||
void
|
||||
qman_portal_quiesce(void)
|
||||
{
|
||||
int cpu;
|
||||
|
||||
for (cpu = 0; cpu < mp_ncpus; cpu++) {
|
||||
if (qman_napi[cpu].tq != NULL)
|
||||
taskqueue_drain(qman_napi[cpu].tq,
|
||||
&qman_napi[cpu].task);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize a QMan portal for a specific CPU with NAPI-style
|
||||
* interrupt handling. Like Linux's qman_create_affine_portal +
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue