Skip to content

Commit

Permalink
nvnetdrv: Reorder variables with logical grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryzee119 authored and thrimbor committed Dec 29, 2024
1 parent d58ef43 commit 6e8f425
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions lib/net/nvnetdrv/nvnetdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6e8f425

Please sign in to comment.