ath10k: enable napi on RX path for sdio
PATCH v6 1/1 ath10k: enable napi on RX path for sdio
For tcp RX, the quantity of tcp acks to remote is 1/2 of the quantity of tcp data from remote, then it will have many small length packets on TX path of sdio bus, then it reduce the RX packets's bandwidth of tcp.
This patch enable napi on RX path, then the RX packet of tcp will not feed to tcp stack immeditely from mac80211 since GRO is enabled by default, it will feed to tcp stack after napi complete, if rx bundle is enabled, then it will feed to tcp stack one time for each bundle of RX. For example, RX bundle size is 32, then tcp stack will receive one large length packet, its length is neary 1500*32, then tcp stack will send a tcp ack for this large packet, this will reduce the tcp acks ratio from 1/2 to 1/32. This results in significant performance improvement for tcp RX.
Tcp rx throughout is 240Mbps without this patch, and it arrive 390Mbps with this patch. The cpu usage has no obvious difference with and without NAPI.
call stack for each RX packet on GRO path:
(skb length is about 1500 bytes)
skb_gro_receive ([kernel.kallsyms]) tcp4_gro_receive ([kernel.kallsyms]) inet_gro_receive ([kernel.kallsyms]) dev_gro_receive ([kernel.kallsyms]) napi_gro_receive ([kernel.kallsyms]) ieee80211_deliver_skb ([mac80211]) ieee80211_rx_handlers ([mac80211]) ieee80211_prepare_and_rx_handle ([mac80211]) ieee80211_rx_napi ([mac80211]) ath10k_htt_rx_proc_rx_ind_hl ([ath10k_core]) ath10k_htt_rx_pktlog_completion_handler ([ath10k_core]) ath10k_sdio_napi_poll ([ath10k_sdio]) net_rx_action ([kernel.kallsyms]) softirqentry_text_start ([kernel.kallsyms]) do_softirq ([kernel.kallsyms])
call stack for napi complete and send tcp ack from tcp stack:
(skb length is about 1500*32 bytes)
_tcp_ack_snd_check ([kernel.kallsyms]) tcp_v4_do_rcv ([kernel.kallsyms])
tcp_v4_rcv ([kernel.kallsyms]) local_deliver_finish ([kernel.kallsyms]) ip_local_deliver ([kernel.kallsyms])
ip_rcv_finish ([kernel.kallsyms])
ip_rcv ([kernel.kallsyms])
netif_receive_skb_core ([kernel.kallsyms]) netif_receive_skb_one_core([kernel.kallsyms]) netif_receive_skb ([kernel.kallsyms]) netif_receive_skb_internal ([kernel.kallsyms]) napi_gro_complete ([kernel.kallsyms]) napi_gro_flush ([kernel.kallsyms]) napi_complete_done ([kernel.kallsyms]) ath10k_sdio_napi_poll ([ath10k_sdio]) net_rx_action ([kernel.kallsyms]) __softirqentry_text_start ([kernel.kallsyms]) do_softirq ([kernel.kallsyms])
Tested with QCA6174 SDIO with firmware
WLAN.RMH.4.4.1-00017-QCARMSWP-1.
---
v6: add napi check for ath10k_htt_rx_proc_rx_ind_hl
this is 1 patches of the 7 patches from ath10k: improve throughout of tcp/udp TX/RX of sdio. it depends on patches: "ath10k: improve throughout of RX of sdio"
v5: move skb_queue_head_init(&ar->htt.rx_indication_head)
from ath10k_htt_connect to ath10k_core_create to forbidden
init 2 times
v4: change some code style
v3: change some code style
v2: no change
drivers/net/wireless/ath/ath10k/core.c | 2 + drivers/net/wireless/ath/ath10k/htt.h | 3 ++ drivers/net/wireless/ath/ath10k/htt_rx.c | 48 ++++++++++++++++++++---- drivers/net/wireless/ath/ath10k/sdio.c | 33 ++++++++++++++++ 4 files changed, 78 insertions(+), 8 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +2 -0
@@ -3223,6 +3223,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,init_waitqueue_head (&ar->htt.empty_tx_wq);init_waitqueue_head (&ar->wmi.tx_credits_wq); +skb_queue_head_init (&ar->htt.rx_indication_head); +init_completion (&ar->offchan_tx_completed);INIT_WORK (&ar->offchan_tx_work, ath10k_offchan_tx_work);skb_queue_head_init (&ar->offchan_tx_queue);
drivers/net/wireless/ath/ath10k/htt.h +3 -0
@@ -1869,6 +1869,8 @@ struct ath10k_htt {struct ath10k *ar;enum ath10k_htc_ep_id eid; +struct sk_buff_head rx_indication_head; +u8 target_version_major;u8 target_version_minor;struct completion target_version_received;
@@ -2283,6 +2285,7 @@ int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu);void ath10k_htt_rx_pktlog_completion_handler (struct ath10k *ar,struct sk_buff *skb);int ath10k_htt_txrx_compl_task (struct ath10k *ar,int budget); +int ath10k_htt_rx_hl_indication (struct ath10k *ar,int budget);void ath10k_htt_set_tx_ops (struct ath10k_htt *htt);void ath10k_htt_set_rx_ops (struct ath10k_htt *htt);#endif
drivers/net/wireless/ath/ath10k/htt_rx.c +40 -8
67 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/sdio.c +33 -0
@@ -1341,6 +1341,9 @@ static void ath10k_rx_indication_async_work(struct work_struct *work) ep = &ar->htc.endpoint[cb->eid]; ep->ep_ops.ep_rx_complete (ar, skb); } + +if (test_bit (ATH10K_FLAG_CORE_REGISTERED , &ar->dev_flags)) +napi_schedule (&ar->napi); }static void ath10k_sdio_write_async_work (struct work_struct *work)
@@ -1731,6 +1734,8 @@ static int ath10k_sdio_hif_start(struct ath10k *ar)struct ath10k_sdio *ar_sdio =ath10k_sdio_priv (ar);int ret; +napi_enable (&ar->napi); +/* Sleep 20 ms before HIF interrupts are disabled. * This will give target plenty of time to process the BMI done * request before interrupts are disabled.
@@ -1855,6 +1860,9 @@ static void ath10k_sdio_hif_stop(struct ath10k *ar) }spin_unlock_bh (&ar_sdio->wr_async_lock); + +napi_synchronize (&ar->napi); +napi_disable (&ar->napi); }#ifdef CONFIG_PM
@@ -2030,6 +2038,26 @@ static SIMPLE_DEV_PM_OPS(ath10k_sdio_pm_ops, ath10k_sdio_pm_suspend,#endif /* CONFIG_PM_SLEEP */ +static int ath10k_sdio_napi_poll (struct napi_struct *ctx,int budget) +{ + struct ath10k *ar = container_of(ctx, struct ath10k, napi); +int done; + + done =ath10k_htt_rx_hl_indication (ar, budget); +ath10k_dbg (ar,ATH10K_DBG_SDIO ,"napi poll: done: %d, budget:%d\n" , done, budget); + +if (done < budget) +napi_complete_done (ctx, done); + +return done; +} + +void ath10k_sdio_init_napi (struct ath10k *ar) +{ +netif_napi_add (&ar->napi_dev, &ar->napi, ath10k_sdio_napi_poll, +ATH10K_NAPI_BUDGET ); +} +static int ath10k_sdio_probe (struct sdio_func *func,const struct sdio_device_id *id) {
@@ -2055,6 +2083,8 @@ static int ath10k_sdio_probe(struct sdio_func *func,return -ENOMEM ; } +ath10k_sdio_init_napi (ar); + ath10k_dbg(ar, ATH10K_DBG_BOOT, "sdio new func %d vendor 0x%x device 0x%x block 0x%x/0x%x\n", func->num, func->vendor, func->device,
@@ -2165,6 +2195,9 @@ static void ath10k_sdio_remove(struct sdio_func *func) func->num, func->vendor, func->device);ath10k_core_unregister (ar); + +netif_napi_del (&ar->napi); +ath10k_core_destroy (ar);flush_workqueue (ar_sdio->workqueue);
Signature · 1 line
2.23.0
Quoted 62 lines · Wen Gong
For tcp RX, the quantity of tcp acks to remote is 1/2 of the quantity of tcp data from remote, then it will have many small length packets on TX path of sdio bus, then it reduce the RX packets's bandwidth of tcp.
This patch enable napi on RX path, then the RX packet of tcp will not feed to tcp stack immeditely from mac80211 since GRO is enabled by default, it will feed to tcp stack after napi complete, if rx bundle is enabled, then it will feed to tcp stack one time for each bundle of RX. For example, RX bundle size is 32, then tcp stack will receive one large length packet, its length is neary 1500*32, then tcp stack will send a tcp ack for this large packet, this will reduce the tcp acks ratio from 1/2 to 1/32. This results in significant performance improvement for tcp RX.
Tcp rx throughout is 240Mbps without this patch, and it arrive 390Mbps with this patch. The cpu usage has no obvious difference with and without NAPI.
call stack for each RX packet on GRO path:
(skb length is about 1500 bytes)
skb_gro_receive([kernel.kallsyms])tcp4_gro_receive([kernel.kallsyms])inet_gro_receive([kernel.kallsyms])dev_gro_receive([kernel.kallsyms])napi_gro_receive([kernel.kallsyms])ieee80211_deliver_skb([mac80211])ieee80211_rx_handlers([mac80211])ieee80211_prepare_and_rx_handle([mac80211])ieee80211_rx_napi([mac80211])ath10k_htt_rx_proc_rx_ind_hl([ath10k_core])ath10k_htt_rx_pktlog_completion_handler([ath10k_core])ath10k_sdio_napi_poll([ath10k_sdio])net_rx_action([kernel.kallsyms])softirqentry_text_start([kernel.kallsyms])do_softirq([kernel.kallsyms])call stack for napi complete and send tcp ack from tcp stack:
(skb length is about 1500*32 bytes)
_tcp_ack_snd_check([kernel.kallsyms])tcp_v4_do_rcv([kernel.kallsyms])
tcp_v4_rcv([kernel.kallsyms])local_deliver_finish([kernel.kallsyms])ip_local_deliver([kernel.kallsyms])
ip_rcv_finish([kernel.kallsyms])
ip_rcv([kernel.kallsyms])
netif_receive_skb_core([kernel.kallsyms])netif_receive_skb_one_core([kernel.kallsyms])netif_receive_skb([kernel.kallsyms])netif_receive_skb_internal([kernel.kallsyms])napi_gro_complete([kernel.kallsyms])napi_gro_flush([kernel.kallsyms])napi_complete_done([kernel.kallsyms])ath10k_sdio_napi_poll([ath10k_sdio])net_rx_action([kernel.kallsyms])__softirqentry_text_start([kernel.kallsyms])do_softirq([kernel.kallsyms])Tested with QCA6174 SDIO with firmware
WLAN.RMH.4.4.1-00017-QCARMSWP-1.Signed-off-by Wen Gong <[email protected]>
[...]
drivers/net/wireless/ath/ath10k/sdio.c static SIMPLE_DEV_PM_OPS(ath10k_sdio_pm_ops, ath10k_sdio_pm_suspend, · line 2059
Quoted 5 lines
drivers/net/wireless/ath/ath10k/sdio.c +5
-0+void ath10k_sdio_init_napi (struct ath10k *ar) +{ +netif_napi_add (&ar->napi_dev, &ar->napi, ath10k_sdio_napi_poll, +ATH10K_NAPI_BUDGET ); +}
This had a new warning:
drivers/net/wireless/ath/ath10k/sdio.c:2053:6: warning: no previous prototype for 'ath10k_sdio_init_napi' [-Wmissing-prototypes] drivers/net/wireless/ath/ath10k/sdio.c:2053:6: warning: symbol 'ath10k_sdio_init_napi' was not declared. Should it be static?
But as you are calling this function from only ath10k_sdio_probe(), in the pending branch I removed the function and moved the napi call there.
Signature · 1 line
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 15 lines · Wen Gong
For tcp RX, the quantity of tcp acks to remote is 1/2 of the quantity of tcp data from remote, then it will have many small length packets on TX path of sdio bus, then it reduce the RX packets's bandwidth of tcp.
This patch enable napi on RX path, then the RX packet of tcp will not feed to tcp stack immeditely from mac80211 since GRO is enabled by default, it will feed to tcp stack after napi complete, if rx bundle is enabled, then it will feed to tcp stack one time for each bundle of RX. For example, RX bundle size is 32, then tcp stack will receive one large length packet, its length is neary 1500*32, then tcp stack will send a tcp ack for this large packet, this will reduce the tcp acks ratio from 1/2 to 1/32. This results in significant performance improvement for tcp RX.
Quoted 3 lines
Tcp rx throughout is 240Mbps without this patch, and it arrive 390Mbps with this patch. The cpu usage has no obvious difference with and without NAPI.
I have not done thorough review yet, but few quick questions:
This adds a new skb queue ar->htt.rx_indication_head to RX path, but on one of your earlier patches you also add another skb queue ar_sdio->rx_head. Is it really necessary to have two separate queues in RX path? Sounds like extra complexity to me.
The way I have understood that NAPI is used as a mechanism to disable interrupts on the device and gain throughput from that. But in your patch the poll function ath10k_sdio_napi_poll() doesn't touch the hardware at all, it just processes packets from ar->htt.rx_indication_head queue until budget runs out. I'm no NAPI expert so I can't claim it's wrong, but at least it feels odd to me.
Signature · 6 lines
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Quoted 21 lines · Kalle Valo
Quoted 15 lines · Wen Gong
For tcp RX, the quantity of tcp acks to remote is 1/2 of the quantity of tcp data from remote, then it will have many small length packets on TX path of sdio bus, then it reduce the RX packets's bandwidth of tcp.
This patch enable napi on RX path, then the RX packet of tcp will not feed to tcp stack immeditely from mac80211 since GRO is enabled by default, it will feed to tcp stack after napi complete, if rx bundle is enabled, then it will feed to tcp stack one time for each bundle of RX. For example, RX bundle size is 32, then tcp stack will receive one large length packet, its length is neary 1500*32, then tcp stack will send a tcp ack for this large packet, this will reduce the tcp acks ratio from 1/2 to 1/32. This results in significant performance improvement for tcp RX.
Quoted 3 lines
Tcp rx throughout is 240Mbps without this patch, and it arrive 390Mbps with this patch. The cpu usage has no obvious difference with and without NAPI.
Quoted 6 lines
I have not done thorough review yet, but few quick questions:
This adds a new skb queue
ar->htt.rx_indication_headto RX path, but on one of your earlier patches you also add another skb queuear_sdio->rx_head. Is it really necessary to have two separate queues in RX path? Sounds like extra complexity to me.
it is because the ar_sdio->rx_head is for all rx of sdio bus, include wmi event, fw log event, pkt log event, htt event... and ar_sdio->rx_head is a lower layer of stack,
but the NAPI it to improve htt rx data's performance, it is only for htt rx, also pcie has the same queue in ath10k_htt for napi, but it only used for low latency.
Quoted 7 lines
The way I have understood that NAPI is used as a mechanism to disable interrupts on the device and gain throughput from that. But in your patch the poll function
ath10k_sdio_napi_poll()doesn't touch the hardware at all, it just processes packets fromar->htt.rx_indication_headqueue until budget runs out. I'm no NAPI expert so I can't claim it's wrong, but at least it feels odd to me.
The difference of this sdio NAPI and pcie NAPI is PCIE's napi_schedule is called in isr,
and sdio is called in indication_work of sdio rx, because ath10k's isr is not a real isr, it is
owned by sdio host, and actually it is a thread.
When napi_schedule called, it will raise a soft irq in the same context, it will block current thread
but not block current isr, in order not to block sdio host thread, so called napi_schedule in indication_work of sdio rx is the best choise.
_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
Quoted 58 lines · Wen Gong
For tcp RX, the quantity of tcp acks to remote is 1/2 of the quantity of tcp data from remote, then it will have many small length packets on TX path of sdio bus, then it reduce the RX packets's bandwidth of tcp.
This patch enable napi on RX path, then the RX packet of tcp will not feed to tcp stack immeditely from mac80211 since GRO is enabled by default, it will feed to tcp stack after napi complete, if rx bundle is enabled, then it will feed to tcp stack one time for each bundle of RX. For example, RX bundle size is 32, then tcp stack will receive one large length packet, its length is neary 1500*32, then tcp stack will send a tcp ack for this large packet, this will reduce the tcp acks ratio from 1/2 to 1/32. This results in significant performance improvement for tcp RX.
Tcp rx throughout is 240Mbps without this patch, and it arrive 390Mbps with this patch. The cpu usage has no obvious difference with and without NAPI.
call stack for each RX packet on GRO path:
(skb length is about 1500 bytes)
skb_gro_receive([kernel.kallsyms])tcp4_gro_receive([kernel.kallsyms])inet_gro_receive([kernel.kallsyms])dev_gro_receive([kernel.kallsyms])napi_gro_receive([kernel.kallsyms])ieee80211_deliver_skb([mac80211])ieee80211_rx_handlers([mac80211])ieee80211_prepare_and_rx_handle([mac80211])ieee80211_rx_napi([mac80211])ath10k_htt_rx_proc_rx_ind_hl([ath10k_core])ath10k_htt_rx_pktlog_completion_handler([ath10k_core])ath10k_sdio_napi_poll([ath10k_sdio])net_rx_action([kernel.kallsyms])softirqentry_text_start([kernel.kallsyms])do_softirq([kernel.kallsyms])call stack for napi complete and send tcp ack from tcp stack:
(skb length is about 1500*32 bytes)
_tcp_ack_snd_check([kernel.kallsyms])tcp_v4_do_rcv([kernel.kallsyms])
tcp_v4_rcv([kernel.kallsyms])local_deliver_finish([kernel.kallsyms])ip_local_deliver([kernel.kallsyms])
ip_rcv_finish([kernel.kallsyms])
ip_rcv([kernel.kallsyms])
netif_receive_skb_core([kernel.kallsyms])netif_receive_skb_one_core([kernel.kallsyms])netif_receive_skb([kernel.kallsyms])netif_receive_skb_internal([kernel.kallsyms])napi_gro_complete([kernel.kallsyms])napi_gro_flush([kernel.kallsyms])napi_complete_done([kernel.kallsyms])ath10k_sdio_napi_poll([ath10k_sdio])net_rx_action([kernel.kallsyms])__softirqentry_text_start([kernel.kallsyms])do_softirq([kernel.kallsyms])
Quoted 5 lines
Tested with QCA6174 SDIO with firmware
WLAN.RMH.4.4.1-00017-QCARMSWP-1.Signed-off-by Wen Gong <[email protected]>Signed-off-by Kalle Valo <[email protected]>
Patch applied to ath-next branch of ath.git, thanks.
cfee8793a74d ath10k: enable napi on RX path for sdio
Signature · 3 lines
https://patchwork.kernel.org/patch/11188393/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 58 lines · Wen Gong
For tcp RX, the quantity of tcp acks to remote is 1/2 of the quantity of tcp data from remote, then it will have many small length packets on TX path of sdio bus, then it reduce the RX packets's bandwidth of tcp.
This patch enable napi on RX path, then the RX packet of tcp will not feed to tcp stack immeditely from mac80211 since GRO is enabled by default, it will feed to tcp stack after napi complete, if rx bundle is enabled, then it will feed to tcp stack one time for each bundle of RX. For example, RX bundle size is 32, then tcp stack will receive one large length packet, its length is neary 1500*32, then tcp stack will send a tcp ack for this large packet, this will reduce the tcp acks ratio from 1/2 to 1/32. This results in significant performance improvement for tcp RX.
Tcp rx throughout is 240Mbps without this patch, and it arrive 390Mbps with this patch. The cpu usage has no obvious difference with and without NAPI.
call stack for each RX packet on GRO path:
(skb length is about 1500 bytes)
skb_gro_receive([kernel.kallsyms])tcp4_gro_receive([kernel.kallsyms])inet_gro_receive([kernel.kallsyms])dev_gro_receive([kernel.kallsyms])napi_gro_receive([kernel.kallsyms])ieee80211_deliver_skb([mac80211])ieee80211_rx_handlers([mac80211])ieee80211_prepare_and_rx_handle([mac80211])ieee80211_rx_napi([mac80211])ath10k_htt_rx_proc_rx_ind_hl([ath10k_core])ath10k_htt_rx_pktlog_completion_handler([ath10k_core])ath10k_sdio_napi_poll([ath10k_sdio])net_rx_action([kernel.kallsyms])softirqentry_text_start([kernel.kallsyms])do_softirq([kernel.kallsyms])call stack for napi complete and send tcp ack from tcp stack:
(skb length is about 1500*32 bytes)
_tcp_ack_snd_check([kernel.kallsyms])tcp_v4_do_rcv([kernel.kallsyms])
tcp_v4_rcv([kernel.kallsyms])local_deliver_finish([kernel.kallsyms])ip_local_deliver([kernel.kallsyms])
ip_rcv_finish([kernel.kallsyms])
ip_rcv([kernel.kallsyms])
netif_receive_skb_core([kernel.kallsyms])netif_receive_skb_one_core([kernel.kallsyms])netif_receive_skb([kernel.kallsyms])netif_receive_skb_internal([kernel.kallsyms])napi_gro_complete([kernel.kallsyms])napi_gro_flush([kernel.kallsyms])napi_complete_done([kernel.kallsyms])ath10k_sdio_napi_poll([ath10k_sdio])net_rx_action([kernel.kallsyms])__softirqentry_text_start([kernel.kallsyms])do_softirq([kernel.kallsyms])
Quoted 5 lines
Tested with QCA6174 SDIO with firmware
WLAN.RMH.4.4.1-00017-QCARMSWP-1.Signed-off-by Wen Gong <[email protected]>Signed-off-by Kalle Valo <[email protected]>
Patch applied to ath-next branch of ath.git, thanks.
cfee8793a74d ath10k: enable napi on RX path for sdio
Signature · 9 lines
https://patchwork.kernel.org/patch/11188393/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k