When I saw the NIC Driver, I didn't know it. I checked the structure and shared it below.
2. Queue Layer
What is the queue layer? Generally, when the network adapter sends and receives data, it needs to maintain a Buffer Queue to cache possible burst data, similar to the previous DMA ring buffer.
The queue layer contains a file called struct softnet_data:
Struct softnet_data
{
/* Throttle is used for congestion control. When congestion occurs, throttle is set and subsequent incoming packets are discarded */
Int throttle;
/* The congestion level returned by the netif_rx function */
Int cng_level;
Int avg_blog;
/* The softnet_data structure contains a pointer to the receiving and transmission queues. The input_pkt_queue Member points to the prepared transmission queue.
The first pointer to the sk_buffs package linked list at the network layer. The package in this queue is submitted by the netif_rx function */
Struct sk_buff_head input_pkt_queue;
Struct list_head poll_list;
Struct net_device * output_queue;
Struct sk_buff * completion_queue;
Struct net_device backlog_dev;/* sorry. 8 )*/
};
The kernel uses a variable softnet_data with the same name. It is a per-CPU variable and each CPU has one.
[I] net/CORE/dev. C [/I]
Declare_per_cpu (struct softnet_data, softnet_data); [/Code]
I found the problem here. What is the CPU? The driver is a newbie. Make sure you understand it.
Return softnet_data [this_cpu]. cng_level;
How to explain the this_cpu parameter?
A new problem occurs here, queue = & softnet_data [this_cpu]
Queue-> input_pkt_queue.qlen
Queue-> throttle is used for congestion control.CodeWhich function is used to change it?
Start from here:
If (queue-> throttle)
Goto drop;
Enqueue:
Dev_hold (SKB-> Dev );
_ Skb_queue_tail (& queue-> input_pkt_queue, SKB );
/* Runs from irqs or BH's, no need to Waka BH */
Cpu_raise_softirq (this_cpu, net_rx_softirq );
Local_irq_restore (flags );
....
Return softnet_data [this_cpu]. cng_level;
}
If (queue-> throttle ){
Queue-> throttle = 0 ;}
If the following functions have nothing to change this value, then it cannot execute this If statement;
Dev_hold (SKB-> Dev );
_ Skb_queue_tail (& queue-> input_pkt_queue, SKB );
/* Runs from irqs or BH's, no need to Waka BH */
Cpu_raise_softirq (this_cpu, net_rx_softirq );
Local_irq_restore (flags );
Let's take a look at the above functions (for future analysis)