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 2023/01/11 10:08:01 UTC

[GitHub] [nuttx] anchao opened a new pull request, #8082: net/devif_poll: optimize device buffer alloc in txpoll

anchao opened a new pull request, #8082:
URL: https://github.com/apache/nuttx/pull/8082

   ## Summary
   
   1. net/devif_poll: optimize device buffer alloc in txpoll
   
   Allocate the device buffer only if the protocol really need to send data.
   not all protocols require the driver to prepare additional iob before
   sending, especially UDP, each iob reserves l2/l3 header in advance
   after prepare write buffer, net device could reuse this entry to send directly
   
   Signed-off-by: chao an <an...@xiaomi.com>
   
   2. net/devif: reuse devif_send() for can/pkt/icmp stack
   
   ## Impact
   
   N/A
   
   ## Testing
   
   iperf udp test


-- 
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


[GitHub] [nuttx] xiaoxiang781216 merged pull request #8082: net/devif_poll: optimize device buffer alloc in txpoll

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged PR #8082:
URL: https://github.com/apache/nuttx/pull/8082


-- 
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


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #8082: net/devif_poll: optimize device buffer alloc in txpoll

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #8082:
URL: https://github.com/apache/nuttx/pull/8082#discussion_r1067306798


##########
net/udp/udp_sendto_unbuffered.c:
##########
@@ -202,15 +211,6 @@ static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev,
           sendto_ipselect(dev, pstate);
 #endif
 
-          /* Copy the user data into d_appdata and send it */
-
-          devif_send(dev, pstate->st_buffer,
-                     pstate->st_buflen, udpip_hdrsize(pstate->st_conn));
-          if (dev->d_sndlen == 0)
-            {
-              return flags;

Review Comment:
   remove the extra space at line 219



##########
net/udp/udp_devpoll.c:
##########
@@ -93,17 +93,6 @@ void udp_poll(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn)
 
   if (conn->lport != 0)
     {
-      /* Set up for the callback.  We can't know in advance if the
-       * application is going to send a IPv4 or an IPv6 packet, so this setup
-       * may not actually be used.
-       */
-
-#if defined(CONFIG_NET_IPv4)
-      udp_ipv4_select(dev);
-#else /* if defined(CONFIG_NET_IPv6) */
-      udp_ipv6_select(dev);
-#endif
-
       dev->d_len     = 0;

Review Comment:
   remove the extra space



##########
net/pkt/pkt_poll.c:
##########
@@ -65,7 +65,6 @@ void pkt_poll(FAR struct net_driver_s *dev, FAR struct pkt_conn_s *conn)
     {
       /* Setup for the application callback */
 
-      dev->d_appdata = IPBUF(0);
       dev->d_len     = 0;

Review Comment:
   remove the extra space



##########
net/udp/udp_sendto_unbuffered.c:
##########
@@ -192,6 +192,15 @@ static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev,
 
       else
         {
+          /* Copy the user data into d_appdata and send it */
+
+          devif_send(dev, pstate->st_buffer,

Review Comment:
   why change the order



##########
net/icmp/icmp_sendmsg.c:
##########
@@ -107,25 +115,16 @@ static void sendto_request(FAR struct net_driver_s *dev,
 
   dev->d_len = IPv4_HDRLEN + pstate->snd_buflen;
 
-  /* The total size of the data (including the size of the ICMP header) */
-
-  dev->d_sndlen += pstate->snd_buflen;
-
-  /* Copy the ICMP header and payload into place after the IPv4 header */
-
-  icmp              = IPBUF(IPv4_HDRLEN);
-
-  iob_update_pktlen(dev->d_iob, IPv4_HDRLEN);
-
-  iob_copyin(dev->d_iob, pstate->snd_buf,
-             pstate->snd_buflen, IPv4_HDRLEN, false);
-
   /* Initialize the IP header. */
 
   ipv4_build_header(IPv4BUF, dev->d_len, IP_PROTO_ICMP,
                     &dev->d_ipaddr, &pstate->snd_toaddr,
                     IP_TTL_DEFAULT, NULL);
 
+  /* Copy the ICMP header and payload into place after the IPv4 header */
+
+  icmp              = IPBUF(IPv4_HDRLEN);

Review Comment:
   remove the extra space at line 130



##########
net/mld/mld_poll.c:
##########
@@ -60,7 +60,6 @@ void mld_poll(FAR struct net_driver_s *dev)
 
   /* Setup the poll operation */
 
-  dev->d_appdata = IPBUF(IPv6_HDRLEN);

Review Comment:
   remove the extra space



##########
net/icmp/icmp_poll.c:
##########
@@ -66,7 +66,6 @@ void icmp_poll(FAR struct net_driver_s *dev, FAR struct icmp_conn_s *conn)
 
   /* Setup for the application callback */
 
-  dev->d_appdata = IPBUF(IPICMP_HDRLEN);
   dev->d_len     = 0;

Review Comment:
   remove the extra space



##########
net/igmp/igmp_poll.c:
##########
@@ -151,13 +151,9 @@ static inline void igmp_sched_send(FAR struct net_driver_s *dev,
 void igmp_poll(FAR struct net_driver_s *dev)
 {
   FAR struct igmp_group_s *group;
-  uint16_t iphdrlen;
 
   /* Setup the poll operation */
 
-  iphdrlen       = IPv4_HDRLEN + RASIZE;
-
-  dev->d_appdata = IPBUF(iphdrlen + IGMP_HDRLEN);
   dev->d_len     = 0;

Review Comment:
   remove the extra space



##########
net/can/can_poll.c:
##########
@@ -66,7 +66,6 @@ void can_poll(FAR struct net_driver_s *dev, FAR struct can_conn_s *conn)
 
   /* Setup for the application callback */
 
-  dev->d_appdata = IPBUF(0);
   dev->d_len     = 0;

Review Comment:
   remove the extra space



-- 
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


[GitHub] [nuttx] anchao commented on a diff in pull request #8082: net/devif_poll: optimize device buffer alloc in txpoll

Posted by GitBox <gi...@apache.org>.
anchao commented on code in PR #8082:
URL: https://github.com/apache/nuttx/pull/8082#discussion_r1068991788


##########
net/icmp/icmp_sendmsg.c:
##########
@@ -107,25 +115,16 @@ static void sendto_request(FAR struct net_driver_s *dev,
 
   dev->d_len = IPv4_HDRLEN + pstate->snd_buflen;
 
-  /* The total size of the data (including the size of the ICMP header) */
-
-  dev->d_sndlen += pstate->snd_buflen;
-
-  /* Copy the ICMP header and payload into place after the IPv4 header */
-
-  icmp              = IPBUF(IPv4_HDRLEN);
-
-  iob_update_pktlen(dev->d_iob, IPv4_HDRLEN);
-
-  iob_copyin(dev->d_iob, pstate->snd_buf,
-             pstate->snd_buflen, IPv4_HDRLEN, false);
-
   /* Initialize the IP header. */
 
   ipv4_build_header(IPv4BUF, dev->d_len, IP_PROTO_ICMP,
                     &dev->d_ipaddr, &pstate->snd_toaddr,
                     IP_TTL_DEFAULT, NULL);
 
+  /* Copy the ICMP header and payload into place after the IPv4 header */
+
+  icmp              = IPBUF(IPv4_HDRLEN);
+
   /* Calculate the ICMP checksum. */
 
   icmp->icmpchksum  = 0;

Review Comment:
   Done



-- 
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


[GitHub] [nuttx] anchao commented on a diff in pull request #8082: net/devif_poll: optimize device buffer alloc in txpoll

Posted by GitBox <gi...@apache.org>.
anchao commented on code in PR #8082:
URL: https://github.com/apache/nuttx/pull/8082#discussion_r1067664351


##########
net/udp/udp_sendto_unbuffered.c:
##########
@@ -192,6 +192,15 @@ static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev,
 
       else
         {
+          /* Copy the user data into d_appdata and send it */
+
+          devif_send(dev, pstate->st_buffer,

Review Comment:
   New send flow will prepare the d_iob buffer in devif_send(), sendto_ipselect() depends on d_iob to update d_appdata



-- 
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


[GitHub] [nuttx] anchao commented on a diff in pull request #8082: net/devif_poll: optimize device buffer alloc in txpoll

Posted by GitBox <gi...@apache.org>.
anchao commented on code in PR #8082:
URL: https://github.com/apache/nuttx/pull/8082#discussion_r1067665963


##########
net/udp/udp_devpoll.c:
##########
@@ -93,17 +93,6 @@ void udp_poll(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn)
 
   if (conn->lport != 0)
     {
-      /* Set up for the callback.  We can't know in advance if the
-       * application is going to send a IPv4 or an IPv6 packet, so this setup
-       * may not actually be used.
-       */
-
-#if defined(CONFIG_NET_IPv4)
-      udp_ipv4_select(dev);
-#else /* if defined(CONFIG_NET_IPv6) */
-      udp_ipv6_select(dev);
-#endif
-
       dev->d_len     = 0;

Review Comment:
   Done



##########
net/udp/udp_sendto_unbuffered.c:
##########
@@ -202,15 +211,6 @@ static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev,
           sendto_ipselect(dev, pstate);
 #endif
 
-          /* Copy the user data into d_appdata and send it */
-
-          devif_send(dev, pstate->st_buffer,
-                     pstate->st_buflen, udpip_hdrsize(pstate->st_conn));
-          if (dev->d_sndlen == 0)
-            {
-              return flags;

Review Comment:
   Done



-- 
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


[GitHub] [nuttx] anchao commented on a diff in pull request #8082: net/devif_poll: optimize device buffer alloc in txpoll

Posted by GitBox <gi...@apache.org>.
anchao commented on code in PR #8082:
URL: https://github.com/apache/nuttx/pull/8082#discussion_r1067665891


##########
net/icmp/icmp_sendmsg.c:
##########
@@ -107,25 +115,16 @@ static void sendto_request(FAR struct net_driver_s *dev,
 
   dev->d_len = IPv4_HDRLEN + pstate->snd_buflen;
 
-  /* The total size of the data (including the size of the ICMP header) */
-
-  dev->d_sndlen += pstate->snd_buflen;
-
-  /* Copy the ICMP header and payload into place after the IPv4 header */
-
-  icmp              = IPBUF(IPv4_HDRLEN);
-
-  iob_update_pktlen(dev->d_iob, IPv4_HDRLEN);
-
-  iob_copyin(dev->d_iob, pstate->snd_buf,
-             pstate->snd_buflen, IPv4_HDRLEN, false);
-
   /* Initialize the IP header. */
 
   ipv4_build_header(IPv4BUF, dev->d_len, IP_PROTO_ICMP,
                     &dev->d_ipaddr, &pstate->snd_toaddr,
                     IP_TTL_DEFAULT, NULL);
 
+  /* Copy the ICMP header and payload into place after the IPv4 header */
+
+  icmp              = IPBUF(IPv4_HDRLEN);

Review Comment:
   Done



##########
net/icmp/icmp_poll.c:
##########
@@ -66,7 +66,6 @@ void icmp_poll(FAR struct net_driver_s *dev, FAR struct icmp_conn_s *conn)
 
   /* Setup for the application callback */
 
-  dev->d_appdata = IPBUF(IPICMP_HDRLEN);
   dev->d_len     = 0;

Review Comment:
   Done



##########
net/pkt/pkt_poll.c:
##########
@@ -65,7 +65,6 @@ void pkt_poll(FAR struct net_driver_s *dev, FAR struct pkt_conn_s *conn)
     {
       /* Setup for the application callback */
 
-      dev->d_appdata = IPBUF(0);
       dev->d_len     = 0;

Review Comment:
   Done



##########
net/mld/mld_poll.c:
##########
@@ -60,7 +60,6 @@ void mld_poll(FAR struct net_driver_s *dev)
 
   /* Setup the poll operation */
 
-  dev->d_appdata = IPBUF(IPv6_HDRLEN);

Review Comment:
   Done



-- 
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


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #8082: net/devif_poll: optimize device buffer alloc in txpoll

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #8082:
URL: https://github.com/apache/nuttx/pull/8082#discussion_r1068471794


##########
net/icmp/icmp_sendmsg.c:
##########
@@ -107,25 +115,16 @@ static void sendto_request(FAR struct net_driver_s *dev,
 
   dev->d_len = IPv4_HDRLEN + pstate->snd_buflen;
 
-  /* The total size of the data (including the size of the ICMP header) */
-
-  dev->d_sndlen += pstate->snd_buflen;
-
-  /* Copy the ICMP header and payload into place after the IPv4 header */
-
-  icmp              = IPBUF(IPv4_HDRLEN);
-
-  iob_update_pktlen(dev->d_iob, IPv4_HDRLEN);
-
-  iob_copyin(dev->d_iob, pstate->snd_buf,
-             pstate->snd_buflen, IPv4_HDRLEN, false);
-
   /* Initialize the IP header. */
 
   ipv4_build_header(IPv4BUF, dev->d_len, IP_PROTO_ICMP,
                     &dev->d_ipaddr, &pstate->snd_toaddr,
                     IP_TTL_DEFAULT, NULL);
 
+  /* Copy the ICMP header and payload into place after the IPv4 header */
+
+  icmp              = IPBUF(IPv4_HDRLEN);
+
   /* Calculate the ICMP checksum. */
 
   icmp->icmpchksum  = 0;

Review Comment:
   remove the extra spae



-- 
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