Network Card Buffer Management Using Dual Ring Queues
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
The existing network card driver and upper-layer application processes require locking and unlocking operations on buffer structures, which affects packet receiving and sending efficiency and can cause deadlocks, leading to network card driver breakdowns.
Innovation Solution
Implementing a method that uses two ring buffer queues, a busy queue, and an idle queue to manage data packet buffering, where the network card driver classifies and buffers packets in the busy queue and maps addresses into the idle queue, allowing the upper-layer application to process packets without needing locking and unlocking, thereby improving efficiency and stability.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If locking and unlocking processing is performed on elements in the buffer structure to enable simultaneous processing by network card driver and upper-layer application, then data processing correctness is ensured, but packet receiving and sending efficiency deteriorates and deadlock may occur
Solution Approach 1:
The buffer structure is segmented into multiple independent buffer queues (first buffer queue, second buffer queue, etc.), each managed by separate locking mechanisms. This allows different threads to access different buffer queues simultaneously without requiring global locking, thus maintaining data correctness while improving processing efficiency and avoiding deadlocks.
Solution Approach 2:
The patent introduces a buffer queue management mechanism that acts as an intermediary between the network card driver and upper-layer application. The management layer handles locking, unlocking, and buffer allocation operations, allowing simultaneous access without direct locking conflicts. This intermediary layer ensures data correctness while enabling efficient parallel processing.
2Stability of the object's composition
If locking processing is performed on buffer structure elements, then simultaneous access by multiple threads is controlled, but system complexity increases due to locking management requirements
Solution Approach 1:
The buffer structure is divided into multiple independent buffer queues, each with its own locking mechanism. This segmentation allows fine-grained locking where only the specific buffer queue being accessed is locked, rather than locking the entire buffer structure. This reduces locking management complexity while maintaining stable buffer access control.
Solution Approach 2:
Each buffer queue is designed to be self-managed with its own locking and unlocking operations. The network card driver and upper-layer application can independently access different buffer queues without requiring complex centralized locking management. This self-service approach simplifies the overall locking management while ensuring stable buffer access control.
Data Source
AI summary
A method and apparatus for managing buffering of data packets of a network card, a terminal and a storage medium are provided. The method includes: setting ring buffer queues, setting a length of each ring buffer queue, then setting a buffer pool formed by two ring buffer queues, and setting the two ring buffer queues in the buffer pool as a busy queue and an idle queue, respectively; a network card driver receiving data packets from a data link, classifying the data packets, sequentially buffering the classified data packets into the busy queue, and then sequentially mapping addresses of the buffered data packets in the busy queue into the idle queue; acquiring latest addresses of the buffered data packets in the busy queue; and the upper-layer application successively acquiring and processing the buffered data packets, and successively releasing the addresses of the processed buffered data packets in the busy queue.


