mirror of
https://github.com/torvalds/linux.git
synced 2026-10-17 14:30:03 +02:00
Add completion queue (CQ) service for the admin channel work queue (WQ) and receive queue (RQ), driven by a dedicated MSI-X interrupt and a workqueue-based CQ poller. The admin WQ CQ service advances the completion ring and returns the number of descriptors consumed. The admin RQ CQ service does the same for receive completions and copies each received message out of its pre-posted DMA buffer into a dynamically allocated queue entry. The pending queue is bounded to ENIC_ADMIN_MSG_MAX (256) entries so a buggy or hostile VF cannot drive the host out of memory; messages are enqueued for deferred dispatch by a separate work_struct so the CQ poller stays short. When the MSI-X interrupt fires, the ISR schedules the CQ poll work. The work handler drains all pending completions, kicks message dispatch if work was done, and returns credits to unmask the interrupt. The admin vector is kept masked from the time the IRQ is requested until the rings are initialised and filled during channel open, so an early or spurious interrupt cannot run the poll handler against uninitialised rings. The poll handler snapshots the pending credit count before draining the CQ so it acknowledges exactly what the hardware reported for this interrupt; any credits that accrue during draining are serviced by the next interrupt. The credit write also sets the mask bit to re-arm the vector, and that unmask is applied independently of the credit count, so the vector is re-armed even when zero credits are returned -- which matters here because the admin channel is not re-polled like the NAPI data path. If an admin RQ buffer refill fails under transient memory pressure, reschedule the CQ poll work itself after a short delay to retry the refill and re-arm the RQ, so the admin channel cannot stall when the ring would otherwise be left empty with no completion to drive the next refill. The poll work is a delayed_work for this reason; routing the retry through it keeps the admin RQ ring owned by a single context so refills never run concurrently. Signed-off-by: Satish Kharat <satishkh@cisco.com> Link: https://patch.msgid.link/20260812-enic-sriov-v2-admin-channel-v2-v13-4-b3809e448aba@cisco.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
28 lines
786 B
C
28 lines
786 B
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/* Copyright 2025 Cisco Systems, Inc. All rights reserved. */
|
|
|
|
#ifndef _ENIC_ADMIN_H_
|
|
#define _ENIC_ADMIN_H_
|
|
|
|
#define ENIC_ADMIN_DESC_COUNT 64
|
|
#define ENIC_ADMIN_BUF_SIZE 2048
|
|
|
|
struct enic;
|
|
|
|
/* Wrapper for received admin messages queued for deferred processing.
|
|
* The admin CQ poll work handler enqueues these; a separate work handler
|
|
* processes them where sleeping (mutex, GFP_KERNEL) is safe.
|
|
*/
|
|
struct enic_admin_msg {
|
|
struct list_head list;
|
|
unsigned int len;
|
|
u8 data[] __aligned(8);
|
|
};
|
|
|
|
int enic_admin_channel_open(struct enic *enic);
|
|
void enic_admin_channel_close(struct enic *enic);
|
|
unsigned int enic_admin_wq_cq_service(struct enic *enic);
|
|
unsigned int enic_admin_rq_cq_service(struct enic *enic);
|
|
|
|
#endif /* _ENIC_ADMIN_H_ */
|