You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/07/07 02:48:27 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #4070: net/tcp: add window scale support

xiaoxiang781216 commented on a change in pull request #4070:
URL: https://github.com/apache/incubator-nuttx/pull/4070#discussion_r664998575



##########
File path: net/tcp/tcp_recvwindow.c
##########
@@ -127,18 +115,19 @@ static uint16_t tcp_maxrcvwin(FAR struct tcp_conn_s *conn)
  *   Calculate the TCP receive window for the specified device.
  *
  * Input Parameters:
- *   dev - The device whose TCP receive window will be updated.
+ *   dev  - The device whose TCP receive window will be updated.
+ *   conn - The TCP connection structure holding connection information.
  *
  * Returned Value:
  *   The value of the TCP receive window to use.
  *
  ****************************************************************************/
 
-uint16_t tcp_get_recvwindow(FAR struct net_driver_s *dev,
+uint32_t tcp_get_recvwindow(FAR struct net_driver_s *dev,
                             FAR struct tcp_conn_s *conn)
 {
-  uint16_t tailroom;
-  uint16_t recvwndo;
+  unsigned int tailroom;

Review comment:
       uint32_t

##########
File path: net/tcp/tcp_recvwindow.c
##########
@@ -251,15 +265,21 @@ bool tcp_should_send_recvwindow(FAR struct tcp_conn_s *conn)
       oldwin = 0;
     }
 
-  win = tcp_get_recvwindow(dev, conn);
+  win = tcp_get_scalewindow(dev, conn);
+#ifdef CONFIG_NET_TCP_WINDOW_SCALE
+  if (conn->rcv_scale > 0)
+    {
+      win <<= conn->rcv_scale;

Review comment:
       directly scale

##########
File path: net/tcp/tcp_send.c
##########
@@ -363,23 +363,23 @@ static void tcp_sendcommon(FAR struct net_driver_s *dev,
       /* Update the TCP received window based on I/O buffer availability */
 
       uint32_t rcvseq = tcp_getsequence(conn->rcvseq);
-      uint16_t recvwndo = tcp_get_recvwindow(dev, conn);
+      uint32_t recvwndo = tcp_get_scalewindow(dev, conn);
 
-      /* Update the Receiver Window */
+      /* Set the TCP Window */
 
-      conn->rcv_adv = rcvseq + recvwndo;
+      tcp->wnd[0] = recvwndo >> 8;
+      tcp->wnd[1] = recvwndo & 0xff;
 
 #ifdef CONFIG_NET_TCP_WINDOW_SCALE
-      if (recvwndo > 0 && conn->rcv_scale > 0)
+      if (conn->rcv_scale > 0)

Review comment:
       directly simply shift.

##########
File path: net/tcp/tcp_input.c
##########
@@ -440,7 +449,12 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain,
 
   /* Update the connection's window size */
 
-  conn->snd_wnd = ((uint16_t)tcp->wnd[0] << 8) + (uint16_t)tcp->wnd[1];
+#ifdef CONFIG_NET_TCP_WINDOW_SCALE
+  conn->snd_wnd = (((uint16_t)tcp->wnd[0] << 8) + (uint16_t)tcp->wnd[1]) <<

Review comment:
       uint32_t

##########
File path: net/tcp/tcp_send.c
##########
@@ -365,14 +365,21 @@ static void tcp_sendcommon(FAR struct net_driver_s *dev,
       uint32_t rcvseq = tcp_getsequence(conn->rcvseq);
       uint16_t recvwndo = tcp_get_recvwindow(dev, conn);
 
+      /* Update the Receiver Window */
+
+      conn->rcv_adv = rcvseq + recvwndo;
+
+#ifdef CONFIG_NET_TCP_WINDOW_SCALE
+      if (recvwndo > 0 && conn->rcv_scale > 0)

Review comment:
       it's more simple and fast to shift directly without check

##########
File path: net/tcp/tcp.h
##########
@@ -198,6 +209,7 @@ struct tcp_conn_s
 #else
   uint16_t tx_unacked;    /* Number bytes sent but not yet ACKed */
 #endif
+  uint16_t flags;         /* Flags of TCP-specific options */

Review comment:
       bool wscale;
   and remove TCP_WSCALE

##########
File path: net/tcp/tcp_recvwindow.c
##########
@@ -224,14 +203,49 @@ uint16_t tcp_get_recvwindow(FAR struct net_driver_s *dev,
   return tcp_calc_rcvsize(conn, recvwndo);
 }
 
+/****************************************************************************
+ * Name: tcp_get_scalewindow

Review comment:
       lets' expose only one function here but not both:
   
   1. tcp_get_recvwindow return the bytes(after UINT16_MAX process)
   2. or tcp_get_scaled_recvwindow return the scaled value(after UINT16_MAX process too)

##########
File path: net/tcp/tcp_recvwindow.c
##########
@@ -224,14 +203,49 @@ uint16_t tcp_get_recvwindow(FAR struct net_driver_s *dev,
   return tcp_calc_rcvsize(conn, recvwndo);
 }
 
+/****************************************************************************
+ * Name: tcp_get_scalewindow
+ *
+ * Description:
+ *   Calculate the TCP receive window scale for the specified device.
+ *
+ * Input Parameters:
+ *   dev  - The device whose TCP receive window will be updated.
+ *   conn - The TCP connection structure holding connection information.
+ *
+ * Returned Value:
+ *   The value of the TCP receive window scale to use.
+ *
+ ****************************************************************************/
+
+uint32_t tcp_get_scalewindow(FAR struct net_driver_s *dev,
+                             FAR struct tcp_conn_s *conn)
+{
+  uint32_t recvwndo = tcp_get_recvwindow(dev, conn);
+
+#ifdef CONFIG_NET_TCP_WINDOW_SCALE
+  if (recvwndo > 0 && conn->rcv_scale > 0)
+    {
+      recvwndo >>= conn->rcv_scale;

Review comment:
       directly shift




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org