From 6e8f4259d17e48b5e39210f92a89aa3a99c947f1 Mon Sep 17 00:00:00 2001 From: Ryzee119 Date: Wed, 29 May 2024 18:17:07 +0930 Subject: [PATCH] nvnetdrv: Reorder variables with logical grouping --- lib/net/nvnetdrv/nvnetdrv.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/lib/net/nvnetdrv/nvnetdrv.c b/lib/net/nvnetdrv/nvnetdrv.c index 57bd36291..82583477e 100644 --- a/lib/net/nvnetdrv/nvnetdrv.c +++ b/lib/net/nvnetdrv/nvnetdrv.c @@ -79,37 +79,34 @@ static KINTERRUPT g_interrupt; static HANDLE g_irqThread; static KEVENT g_irqEvent; -// Manage RX ring +// Manage RX and TX rings static volatile struct descriptor_t *g_rxRing; -static KSEMAPHORE g_rxRingFreeDescriptors; -static HANDLE g_rxRingRequeueThread; +static volatile struct descriptor_t *g_txRing; +static size_t g_rxRingSize; +static size_t g_txRingSize; static size_t g_rxRingHead; -static size_t g_rxRingTail; +static size_t g_txRingHead; +static atomic_size_t g_txPendingCount; +static KSEMAPHORE g_rxPendingCount; +static atomic_size_t g_rxRingTail; +static atomic_size_t g_txRingTail; +static KSEMAPHORE g_txRingFreeCount; +struct tx_misc_t g_txData[TX_RING_SIZE]; static uint8_t *g_rxRingUserBuffers; static uint32_t g_rxRingBufferVtoP; -// Manage RX buffer callbacks to user network stack +// Manage RX buffers +static KSEMAPHORE g_rxRingFreeDescriptors; +static HANDLE g_rxRingRequeueThread; static nvnetdrv_rx_callback_t g_rxCallback; -static KSEMAPHORE g_rxPendingCount; static HANDLE g_rxCallbackThread; struct rx_misc_t *g_rxCallbackQueue; static size_t g_rxCallbackTail; - -// Manage RX buffer pool to supply RX ring static void **g_rxBuffPool; static size_t g_rxBuffPoolHead; -static size_t g_rxRingSize; static RTL_CRITICAL_SECTION g_rxBuffPoolLock; static KSEMAPHORE g_rxFreeBuffers; -// Manage TX ring -static volatile struct descriptor_t *g_txRing; -static size_t g_txRingHead; -static atomic_size_t g_txRingTail; -static atomic_size_t g_txPendingCount; -static KSEMAPHORE g_txRingFreeCount; -struct tx_misc_t g_txData[TX_RING_SIZE]; - // Time constants used in nvnetdrv #define NO_SLEEP \ &(LARGE_INTEGER) \ @@ -511,8 +508,8 @@ int nvnetdrv_init (size_t rx_buffer_count, nvnetdrv_rx_callback_t rx_callback) RtlZeroMemory(g_txData, sizeof(g_txData)); // Setup the TX and RX ring descriptor pointers - g_rxRing = (struct descriptor_t *)descriptors; - g_txRing = (struct descriptor_t *)descriptors + RX_RING_SIZE; + g_rxRing = (volatile struct descriptor_t *)descriptors; + g_txRing = (volatile struct descriptor_t *)descriptors + RX_RING_SIZE; // Remember the offset between virtual and physical address g_rxRingBufferVtoP = ((uint32_t)g_rxRingUserBuffers) - (uint32_t)MmGetPhysicalAddress(g_rxRingUserBuffers);