/* Structures labeled with "HW DATA" are exchanged with the hardware. All of * them are naturally aligned and hence don't need __packed.
*/
/* Shared memory channel protocol header * * msg_type: set on request and response; response matches request. * msg_version: newer PF writes back older response (matching request) * older PF acts on latest version known and sets that version in result * (less than request). * direction: 0 for request, VF->PF; 1 for response, PF->VF. * status: 0 on request, * operation result on response (success = 0, failure = 1 or greater). * reset_vf: If set on either establish or destroy request, indicates perform * FLR before/after the operation. * owner_is_pf: 1 indicates PF owned, 0 indicates VF owned.
*/ union smc_proto_hdr {
u32 as_uint32;
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, * but let's do it in a loop just in case the hardware or the PF * driver are temporarily busy.
*/ 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) return 0;
/* If bit_31 is set, the PF currently owns the SMC. */ if (!(last_dword & BIT(31))) return 0;
/* 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. * * Addresses must be page frame aligned, so only frame address bits * are transferred. * * 52-bit frame addresses are split into the lower 48 bits and upper * 4 bits. Lower 48 bits of 4 address are written sequentially from * the start of the 256-bit shared memory region followed by 16 bits * containing the upper 4 bits of the 4 addresses in sequence. * * A 16 bit EQ vector number fills out the next-to-last 32-bit dword. * * The final 32-bit dword is used for protocol control information as * defined in smc_proto_hdr.
*/
/* Write 256-message buffer to shared memory (final 32-bit write * triggers HW to set possession bit to PF).
*/
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. * For setup, waiting for response on shared memory is not strictly * necessary, since wait occurs later for results to appear in EQE'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;
}
return 0;
}
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 * to set possession bit to PF.
*/
writel(hdr.as_uint32, sc->base + SMC_LAST_DWORD * SMC_BASIC_UNIT);
/* Read shmem response (polling for VF possession) and validate. * For teardown, waiting for response is required to ensure hardware * invalidates MST entries before software frees memory.
*/
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;
}
return 0;
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.0 Sekunden
(vorverarbeitet)
¤
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.