staticint mana_smc_poll_register(void __iomem *base, bool reset)
{ void __iomem *ptr = base + SMC_LAST_DWORD * SMC_BASIC_UNIT;
u32 last_dword; int i;
/* Poll the hardware for the ownership bit. This should be pretty fast, *butlet'sdoitinaloopjustincasethehardwareorthePF *driveraretemporarilybusy.
*/ for (i = 0; i < 20 * 1000; i++) {
last_dword = readl(ptr);
/* shmem reads as 0xFFFFFFFF in the reset case */ if (reset && last_dword == SHMEM_VF_RESET_STATE) return0;
/* If bit_31 is set, the PF currently owns the SMC. */ if (!(last_dword & BIT(31))) return0;
/* Ensure VF already has possession of shared memory */
err = mana_smc_poll_register(sc->base, false); if (err) {
dev_err(sc->dev, "Timeout when setting up HWC: %d\n", err); return err;
}
if (!MANA_PAGE_ALIGNED(eq_addr) || !MANA_PAGE_ALIGNED(cq_addr) ||
!MANA_PAGE_ALIGNED(rq_addr) || !MANA_PAGE_ALIGNED(sq_addr)) return -EINVAL;
if ((eq_msix_index & VECTOR_MASK) != eq_msix_index) return -EINVAL;
/* Scheme for packing four addresses and extra info into 256 bits. * *Addressesmustbepageframealigned,soonlyframeaddressbits *aretransferred. * *52-bitframeaddressesaresplitintothelower48bitsandupper *4bits.Lower48bitsof4addressarewrittensequentiallyfrom *thestartofthe256-bitsharedmemoryregionfollowedby16bits *containingtheupper4bitsofthe4addressesinsequence. * *A16bitEQvectornumberfillsoutthenext-to-last32-bitdword. * *Thefinal32-bitdwordisusedforprotocolcontrolinformationas *definedinsmc_proto_hdr.
*/
/* Write 256-message buffer to shared memory (final 32-bit write *triggersHWtosetpossessionbittoPF).
*/
dword = (u32 *)shm_buf; for (i = 0; i < SMC_APERTURE_DWORDS; i++)
writel(*dword++, sc->base + i * SMC_BASIC_UNIT);
/* Read shmem response (polling for VF possession) and validate. *Forsetup,waitingforresponseonsharedmemoryisnotstrictly *necessary,sincewaitoccurslaterforresultstoappearinEQE's.
*/
err = mana_smc_read_response(sc, SMC_MSG_TYPE_ESTABLISH_HWC,
SMC_MSG_TYPE_ESTABLISH_HWC_VERSION,
reset_vf); if (err) {
dev_err(sc->dev, "Error when setting up HWC: %d\n", err); return err;
}
return0;
}
int mana_smc_teardown_hwc(struct shm_channel *sc, bool reset_vf)
{ union smc_proto_hdr hdr = {}; int err;
/* Ensure already has possession of shared memory */
err = mana_smc_poll_register(sc->base, false); if (err) {
dev_err(sc->dev, "Timeout when tearing down HWC\n"); return err;
}
/* Set up protocol header for HWC destroy message */
hdr.msg_type = SMC_MSG_TYPE_DESTROY_HWC;
hdr.msg_version = SMC_MSG_TYPE_DESTROY_HWC_VERSION;
hdr.direction = SMC_MSG_DIRECTION_REQUEST;
hdr.reset_vf = reset_vf;
/* Write message in high 32 bits of 256-bit shared memory, causing HW *tosetpossessionbittoPF.
*/
writel(hdr.as_uint32, sc->base + SMC_LAST_DWORD * SMC_BASIC_UNIT);
/* Read shmem response (polling for VF possession) and validate. *Forteardown,waitingforresponseisrequiredtoensurehardware *invalidatesMSTentriesbeforesoftwarefreesmemory.
*/
err = mana_smc_read_response(sc, SMC_MSG_TYPE_DESTROY_HWC,
SMC_MSG_TYPE_DESTROY_HWC_VERSION,
reset_vf); if (err) {
dev_err(sc->dev, "Error when tearing down HWC: %d\n", err); return err;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.