欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

關(guān)于vb.netifin的信息

內(nèi)核什么函數(shù)接收netif

背景:

10年積累的網(wǎng)站建設(shè)、做網(wǎng)站經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站設(shè)計(jì)后付款的網(wǎng)站建設(shè)流程,更有潞州免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

內(nèi)核接收分組的方式有兩種:第一種:傳統(tǒng)方式,使用中斷的方式;第二種:NAPI,使用中斷和輪詢結(jié)合的方式。

中斷方式:

下圖為一個(gè)分組到達(dá)NIC之后,該分組穿過內(nèi)核到達(dá)網(wǎng)絡(luò)層函數(shù)的路徑。

此圖的下半部分為中斷處理,上半部分為軟中斷。在中斷處理中,函數(shù)net_interupt是

設(shè)備驅(qū)動(dòng)程序的中斷處理程序,它將確認(rèn)此中斷是否由接收到分組引發(fā)的,如果確實(shí)如此,

則控制權(quán)移交到函數(shù)net_rx。函數(shù)net_rx也是特定于NIC,首先創(chuàng)建一個(gè)新的套接字緩沖區(qū),

分組的內(nèi)容接下來(lái)從NIC傳輸?shù)骄彌_區(qū)(進(jìn)入到物理內(nèi)存中),然后使用內(nèi)核源碼中針對(duì)

各個(gè)傳輸類型的庫(kù)函數(shù)來(lái)分析首部的數(shù)據(jù)。函數(shù)netif_rx函數(shù)不是特定于網(wǎng)絡(luò)驅(qū)動(dòng)函數(shù),該

函數(shù)位于net/core/dev.c,調(diào)用該函數(shù),標(biāo)志著控制由特定于網(wǎng)卡的代碼轉(zhuǎn)移到了網(wǎng)絡(luò)層的

通用接口部分。此函數(shù)的作用在于,將接收分組放置到一個(gè)特定于CPU的等待隊(duì)列上,并

退出中斷上下文。內(nèi)核使用softnet_data來(lái)管理進(jìn)出流量,其定義入下:

2352 /*

2353 * Incoming packets are placed on per-cpu queues

2354 */

2355 struct softnet_data {

2356 struct list_head poll_list;

2357 struct sk_buff_head process_queue;

2358

2359 /* stats */

2360 unsigned int processed;

2361 unsigned int time_squeeze;

2362 unsigned int cpu_collision;

2363 unsigned int received_rps;

2364 #ifdef CONFIG_RPS

2365 struct softnet_data *rps_ipi_list;

2366 #endif

2367 #ifdef CONFIG_NET_FLOW_LIMIT

2368 struct sd_flow_limit __rcu *flow_limit;

2369 #endif

2370 struct Qdisc *output_queue;

2371 struct Qdisc **output_queue_tailp;

2372 struct sk_buff *completion_queue;

2373

2374 #ifdef CONFIG_RPS

2375 /* Elements below can be accessed between CPUs for RPS */

2376 struct call_single_data csd ____cacheline_aligned_in_smp;

2377 struct softnet_data *rps_ipi_next;

2378 unsigned int cpu;

2379 unsigned int input_queue_head;

2380 unsigned int input_queue_tail;

2381 #endif

2382 unsigned int dropped;

2383 struct sk_buff_head input_pkt_queue; //對(duì)所有進(jìn)入分組建立一個(gè)鏈表。

2384 struct napi_struct backlog;

2385

2386 };

第2383行的input_pkt_queue即是CPU的等待隊(duì)列。netif_rx的實(shí)現(xiàn)如下:

3329 static int netif_rx_internal(struct sk_buff *skb)

3330 {

3331 int ret;

3332

3333 net_timestamp_check(netdev_tstamp_prequeue, skb);

3334

3335 trace_netif_rx(skb);

3336 #ifdef CONFIG_RPS //RPS 和 RFS 相關(guān)代碼

3337 if (static_key_false(rps_needed)) {

3338 struct rps_dev_flow voidflow, *rflow = voidflow;

3339 int cpu;

3340

3341 preempt_disable();

3342 rcu_read_lock();

3343

3344 cpu = get_rps_cpu(skb-dev, skb, rflow); //選擇合適的CPU id

3345 if (cpu 0)

3346 cpu = smp_processor_id();

3347

3348 ret = enqueue_to_backlog(skb, cpu, rflow-last_qtail);

3349

3350 rcu_read_unlock();

3351 preempt_enable();

3352 } else

3353 #endif

3354 {

3355 unsigned int qtail;

3356 ret = enqueue_to_backlog(skb, get_cpu(), qtail); //將skb入隊(duì)

3357 put_cpu();

3358 }

3359 return ret;

3360 }

3361

3362 /**

3363 * netif_rx - post buffer to the network code

3364 * @skb: buffer to post

3365 *

3366 * This function receives a packet from a device driver and queues it for

3367 * the upper (protocol) levels to process. It always succeeds. The buffer

3368 * may be dropped during processing for congestion control or by the

3369 * protocol layers.

3370 *

3371 * return values:

3372 * NET_RX_SUCCESS (no congestion)

3373 * NET_RX_DROP (packet was dropped)

3374 *

3375 */

3376

3377 int netif_rx(struct sk_buff *skb)

3378 {

3379 trace_netif_rx_entry(skb);

3380

3381 return netif_rx_internal(skb);

3382 }

入隊(duì)函數(shù) enqueue_to_backlog的實(shí)現(xiàn)如下:

View Code

NAPI

NAPI是混合了中斷和輪詢機(jī)制,當(dāng)一個(gè)新的分組到達(dá),而前一個(gè)分組依然在處理,這時(shí)內(nèi)核

并不需要產(chǎn)生中斷,內(nèi)核會(huì)繼續(xù)處理并在處理完畢后將中斷開啟。這樣內(nèi)核就利用了中斷和輪詢的好處,

只有有分組到達(dá)的時(shí)候,才會(huì)進(jìn)行輪詢。

NAPI存在兩個(gè)優(yōu)勢(shì)

1.減少了CPU使用率,因?yàn)楦俚闹袛唷?/p>

2.處理各種設(shè)備更加公平

只有設(shè)備滿足如下兩個(gè)條件時(shí),才能實(shí)現(xiàn)NAPI:

1.設(shè)備必須能夠保留多個(gè)接收的分組

2.設(shè)備必須能夠禁用用于分組接收的IRQ。而且,發(fā)送分組或其他可能通過IRQ進(jìn)行的操作,都仍然

必須是啟用的。

其運(yùn)行概覽如下:

如上所示,各個(gè)設(shè)備在進(jìn)入poll list前需要禁用IRQ,而設(shè)備中的分組都處理完畢后重新開啟IRQ。poll list使用

napi_struct來(lái)管理設(shè)備,其定義如下:

View Code

變量state可以為NAPI_STATE_SCHED或NAPI_STATE_DISABLE, 前者表示設(shè)備將在

內(nèi)核的下一次循環(huán)時(shí)被輪詢,后者表示輪詢已經(jīng)結(jié)束且沒有更多的分組等待處理,但

設(shè)備并沒有從poll list移除。

支持NAPI的NIC需要修改中斷處理程序,將此設(shè)備放置在poll list上。示例代碼如下:

View Code

函數(shù)__napi_schedule的定義入下:

View Code

設(shè)備除了對(duì)中斷處理進(jìn)行修改,還需要提供一個(gè)poll函數(shù),使用此函數(shù)從NIC中獲取分組。示例代碼如下:

特定于硬件的方法 hyper_do_poll 從NIC中獲取分組,返回值work_done為處理的分組數(shù)目。當(dāng)分組處理完后,

會(huì)調(diào)用netif_rx_complete將此設(shè)備從poll list中移除。ixgbe網(wǎng)卡的poll函數(shù)為ixgbe_poll, 而對(duì)于非NAPI的函數(shù),

內(nèi)核提供默認(rèn)的處理函數(shù)process_backlog。

軟中斷處理相關(guān)

無(wú)論是NAPI接口還是非NAPI最后都是使用 net_rx_action 作為軟中斷處理函數(shù)。因此整個(gè)流程如下:

上圖中有些函數(shù)名已經(jīng)發(fā)生變更,但是流程依然如此。在最新的3.19內(nèi)核代碼中,非NAPI的調(diào)用流程如下:

neif_rx會(huì)調(diào)用enqueue_to_backlog 將skb存入softnet_data,并調(diào)用____napi_schedule函數(shù)。

netif_rx===netif_rx_internal===enqueue_to_backlog===____napi_schedule===net_rx_action===process_backlog===__netif_receive_skb

e100網(wǎng)卡的NAPI調(diào)用流程入下:

e100_intr===__napi_schedule===net_rx_action===e100_poll===e100_rx_clean===e100_rx_indicate===netif_receive_skb

asp.net時(shí)間判斷的問題

System.DateTime currentTime=new System.DateTime();

string str="";

int h=currentTime.Hour;

if(h12)

{

str="下午";

}

else

{

str="上午";

}

1、DateTime 數(shù)字型

System.DateTime currentTime=new System.DateTime();

1.1 取當(dāng)前年月日時(shí)分秒

currentTime=System.DateTime.Now;

1.2 取當(dāng)前年

int 年=currentTime.Year;

1.3 取當(dāng)前月

int 月=currentTime.Month;

1.4 取當(dāng)前日

int 日=currentTime.Day;

1.5 取當(dāng)前時(shí)

int 時(shí)=currentTime.Hour;

1.6 取當(dāng)前分

int 分=currentTime.Minute;

1.7 取當(dāng)前秒

int 秒=currentTime.Second;

1.8 取當(dāng)前毫秒

int 毫秒=currentTime.Millisecond;

(變量可用中文)

1.9 取中文日期顯示——年月日時(shí)分

string strY=currentTime.ToString("f"); //不顯示秒

1.10 取中文日期顯示_年月

string strYM=currentTime.ToString("y");

1.11 取中文日期顯示_月日

string strMD=currentTime.ToString("m");

1.12 取中文年月日

string strYMD=currentTime.ToString("D");

1.13 取當(dāng)前時(shí)分,格式為:14:24

string strT=currentTime.ToString("t");

1.14 取當(dāng)前時(shí)間,格式為:2003-09-23T14:46:48

string strT=currentTime.ToString("s");

1.15 取當(dāng)前時(shí)間,格式為:2003-09-23 14:48:30Z

string strT=currentTime.ToString("u");

1.16 取當(dāng)前時(shí)間,格式為:2003-09-23 14:48

string strT=currentTime.ToString("g");

1.17 取當(dāng)前時(shí)間,格式為:Tue, 23 Sep 2003 14:52:40 GMT

string strT=currentTime.ToString("r");

1.18獲得當(dāng)前時(shí)間 n 天后的日期時(shí)間

DateTime newDay = DateTime.Now.AddDays(100);

當(dāng)前標(biāo)題:關(guān)于vb.netifin的信息
本文地址:http://chinadenli.net/article16/dsieddg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器、網(wǎng)站設(shè)計(jì)、全網(wǎng)營(yíng)銷推廣、定制開發(fā)軟件開發(fā)、響應(yīng)式網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

1成都定制網(wǎng)站建設(shè)