1195972f6Sopenharmony_ciFrom 590873482f9b6a5e2635a95720acb37b5f516ab0 Mon Sep 17 00:00:00 2001
2195972f6Sopenharmony_ciFrom: kircher <majun65@huawei.com>
3195972f6Sopenharmony_ciDate: Tue, 21 Feb 2023 15:05:41 +0800
4195972f6Sopenharmony_ciSubject: [PATCH] lwip add need_tso_send
5195972f6Sopenharmony_ci
6195972f6Sopenharmony_ci---
7195972f6Sopenharmony_ci src/api/api_msg.c      | 1 +
8195972f6Sopenharmony_ci src/core/tcp_out.c     | 5 ++++-
9195972f6Sopenharmony_ci src/include/lwip/tcp.h | 2 ++
10195972f6Sopenharmony_ci 3 files changed, 7 insertions(+), 1 deletion(-)
11195972f6Sopenharmony_ci
12195972f6Sopenharmony_cidiff --git a/src/api/api_msg.c b/src/api/api_msg.c
13195972f6Sopenharmony_ciindex 1fedaad..3a4a473 100644
14195972f6Sopenharmony_ci--- a/src/api/api_msg.c
15195972f6Sopenharmony_ci+++ b/src/api/api_msg.c
16195972f6Sopenharmony_ci@@ -1744,6 +1744,7 @@ lwip_netconn_do_writemore(struct netconn *conn  WRITE_DELAYED_PARAM)
17195972f6Sopenharmony_ci       write_more = 0;
18195972f6Sopenharmony_ci       err = tcp_write(conn->pcb.tcp, conn->current_msg->msg.w.vector->ptr, len, apiflags);
19195972f6Sopenharmony_ci       conn->current_msg->msg.w.len = len;
20195972f6Sopenharmony_ci+      conn->pcb.tcp->need_tso_send = 1;
21195972f6Sopenharmony_ci #else
22195972f6Sopenharmony_ci       err = tcp_write(conn->pcb.tcp, dataptr, len, apiflags);
23195972f6Sopenharmony_ci #endif
24195972f6Sopenharmony_cidiff --git a/src/core/tcp_out.c b/src/core/tcp_out.c
25195972f6Sopenharmony_ciindex c538f2a..bf23381 100644
26195972f6Sopenharmony_ci--- a/src/core/tcp_out.c
27195972f6Sopenharmony_ci+++ b/src/core/tcp_out.c
28195972f6Sopenharmony_ci@@ -1473,7 +1473,7 @@ tcp_output(struct tcp_pcb *pcb)
29195972f6Sopenharmony_ci 
30195972f6Sopenharmony_ci   u32_t send_len = 0;
31195972f6Sopenharmony_ci #if USE_LIBOS
32195972f6Sopenharmony_ci-  if (get_eth_params_tx_ol() & DEV_TX_OFFLOAD_TCP_TSO) {
33195972f6Sopenharmony_ci+  if ((get_eth_params_tx_ol() & DEV_TX_OFFLOAD_TCP_TSO) && pcb->need_tso_send) {
34195972f6Sopenharmony_ci     while(seg && send_len < 0xffff) {
35195972f6Sopenharmony_ci       /**
36195972f6Sopenharmony_ci        * 1) walk unsent queue, find all seg witch wait to send. chain buf in these segs.
37195972f6Sopenharmony_ci@@ -1529,6 +1529,7 @@ tcp_output(struct tcp_pcb *pcb)
38195972f6Sopenharmony_ci         if (err != ERR_OK) {
39195972f6Sopenharmony_ci           if (pcb->unsent == NULL)
40195972f6Sopenharmony_ci             pcb->last_unsent = NULL;
41195972f6Sopenharmony_ci+	  pcb->need_tso_send = 0;
42195972f6Sopenharmony_ci           return err;
43195972f6Sopenharmony_ci         }
44195972f6Sopenharmony_ci         pcb->unsent = seg->next;
45195972f6Sopenharmony_ci@@ -1552,6 +1553,7 @@ tcp_output(struct tcp_pcb *pcb)
46195972f6Sopenharmony_ci       pbuf_remove_header(new_seg.p, new_seg.p->tot_len - new_seg.len - TCPH_HDRLEN_BYTES(new_seg.tcphdr));
47195972f6Sopenharmony_ci       new_seg.p->tot_len = new_seg.p->len;
48195972f6Sopenharmony_ci     }
49195972f6Sopenharmony_ci+  pcb->need_tso_send = 0;
50195972f6Sopenharmony_ci   } else
51195972f6Sopenharmony_ci #endif
52195972f6Sopenharmony_ci {
53195972f6Sopenharmony_ci@@ -1647,6 +1649,7 @@ tcp_output(struct tcp_pcb *pcb)
54195972f6Sopenharmony_ci #endif /* TCP_OVERSIZE */
55195972f6Sopenharmony_ci 
56195972f6Sopenharmony_ci output_done:
57195972f6Sopenharmony_ci+  pcb->need_tso_send = 0;
58195972f6Sopenharmony_ci   if (pcb->unsent == NULL)
59195972f6Sopenharmony_ci     pcb->last_unsent = NULL;
60195972f6Sopenharmony_ci   tcp_clear_flags(pcb, TF_NAGLEMEMERR);
61195972f6Sopenharmony_cidiff --git a/src/include/lwip/tcp.h b/src/include/lwip/tcp.h
62195972f6Sopenharmony_ciindex 0b65b01..2fc683d 100644
63195972f6Sopenharmony_ci--- a/src/include/lwip/tcp.h
64195972f6Sopenharmony_ci+++ b/src/include/lwip/tcp.h
65195972f6Sopenharmony_ci@@ -409,6 +409,8 @@ struct tcp_pcb {
66195972f6Sopenharmony_ci   u8_t snd_scale;
67195972f6Sopenharmony_ci   u8_t rcv_scale;
68195972f6Sopenharmony_ci #endif
69195972f6Sopenharmony_ci+
70195972f6Sopenharmony_ci+  u8_t need_tso_send;
71195972f6Sopenharmony_ci };
72195972f6Sopenharmony_ci 
73195972f6Sopenharmony_ci #if TCP_PCB_HASH
74195972f6Sopenharmony_ci-- 
75195972f6Sopenharmony_ci2.33.0
76195972f6Sopenharmony_ci
77