This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit cf78962356e7da550e80247ec8c30aea26477bf7
Author: wenquan1 <[email protected]>
AuthorDate: Wed Mar 11 16:07:19 2026 +0800

    net/socket: merge CONFIG_NET_TIMESTAMPING into CONFIG_NET_TIMESTAMP
    
    Consolidate the two separate timestamp Kconfig options into a single
    CONFIG_NET_TIMESTAMP option that covers SO_TIMESTAMP, SO_TIMESTAMPNS
    and SO_TIMESTAMPING socket options.
    
    Previously CONFIG_NET_TIMESTAMPING was a separate option only used by
    PKT sockets for hardware TX/RX timestamps and error queue support.
    Since both options guard the same io_time field in iob_s and share
    the s_options bitmask, merging them simplifies configuration without
    functional impact.
    
    Changes:
    - Replace all CONFIG_NET_TIMESTAMPING with CONFIG_NET_TIMESTAMP in
      pkt_input.c, pkt_recvmsg.c, pkt_sendmsg_buffered.c,
      pkt_sendmsg_unbuffered.c, pkt_sockif.c, pkt_netpoll.c, pkt.h,
      setsockopt.c, getsockopt.c
    - Simplify iob.h conditional from OR of both to single option
    - Remove NET_TIMESTAMPING Kconfig entry, update NET_TIMESTAMP
      description to cover all three socket options
    
    Signed-off-by: wenquan1 <[email protected]>
---
 include/nuttx/mm/iob.h           | 10 ++++------
 net/pkt/pkt.h                    |  2 +-
 net/pkt/pkt_input.c              |  2 +-
 net/pkt/pkt_netpoll.c            |  6 +++---
 net/pkt/pkt_recvmsg.c            |  6 +++---
 net/pkt/pkt_sendmsg_buffered.c   |  2 +-
 net/pkt/pkt_sendmsg_unbuffered.c |  2 +-
 net/pkt/pkt_sockif.c             |  2 +-
 net/socket/Kconfig               | 14 ++++----------
 net/socket/getsockopt.c          |  2 --
 net/socket/setsockopt.c          |  2 --
 11 files changed, 19 insertions(+), 31 deletions(-)

diff --git a/include/nuttx/mm/iob.h b/include/nuttx/mm/iob.h
index 9a1265835e5..125dd2627ea 100644
--- a/include/nuttx/mm/iob.h
+++ b/include/nuttx/mm/iob.h
@@ -37,7 +37,7 @@
 #  include <nuttx/wqueue.h>
 #endif
 
-#if defined(CONFIG_NET_TIMESTAMP) || defined(CONFIG_NET_TIMESTAMPING)
+#ifdef CONFIG_NET_TIMESTAMP
 #  include <sys/time.h>
 #endif
 
@@ -130,7 +130,9 @@ struct iob_s
 #endif
   unsigned int io_pktlen; /* Total length of the packet */
 
-#if defined(CONFIG_NET_TIMESTAMP) || defined(CONFIG_NET_TIMESTAMPING)
+  FAR struct socket_conn_s *io_conn;
+
+#ifdef CONFIG_NET_TIMESTAMP
   /* timestamp of the packet.
    * d_features is the member of net_driver_s struct, if the NETDEV_RX_STAMP
    * bit of d_features is set, the timestamp is provided by hardware driver.
@@ -140,10 +142,6 @@ struct iob_s
 
   struct timespec io_time;
 #endif
-#endif
-#ifdef CONFIG_NET_TIMESTAMPING
-  FAR struct socket_conn_s *io_conn;
-#endif
 #ifdef CONFIG_IOB_ALLOC
   iob_free_cb_t io_free;  /* Custom free callback */
   FAR uint8_t  *io_data;
diff --git a/net/pkt/pkt.h b/net/pkt/pkt.h
index 2b2a3685334..2aaa52f6258 100644
--- a/net/pkt/pkt.h
+++ b/net/pkt/pkt.h
@@ -104,7 +104,7 @@ struct pkt_conn_s
 
   struct iob_queue_s readahead;   /* Read-ahead buffering */
 
-#ifdef CONFIG_NET_TIMESTAMPING
+#ifdef CONFIG_NET_TIMESTAMP
   struct iob_queue_s errahead;    /* Error-ahead buffering */
 #endif
 
diff --git a/net/pkt/pkt_input.c b/net/pkt/pkt_input.c
index 60b93b97253..638befdbee1 100644
--- a/net/pkt/pkt_input.c
+++ b/net/pkt/pkt_input.c
@@ -159,7 +159,7 @@ static int pkt_in(FAR struct net_driver_s *dev)
           return OK;
         }
 
-#ifdef CONFIG_NET_TIMESTAMPING
+#ifdef CONFIG_NET_TIMESTAMP
 
       /* Handle hardware timestamp */
 
diff --git a/net/pkt/pkt_netpoll.c b/net/pkt/pkt_netpoll.c
index 4adf8eaff2d..5e07cd9bf03 100644
--- a/net/pkt/pkt_netpoll.c
+++ b/net/pkt/pkt_netpoll.c
@@ -134,7 +134,7 @@ static uint32_t pkt_poll_eventhandler(FAR struct 
net_driver_s *dev,
           eventset |= POLLOUT;
         }
 
-#ifdef CONFIG_NET_TIMESTAMPING
+#ifdef CONFIG_NET_TIMESTAMP
       /* Check for timestamping data */
 
       if (!IOB_QEMPTY(&info->conn->errahead))
@@ -246,7 +246,7 @@ int pkt_pollsetup(FAR struct socket *psock, FAR struct 
pollfd *fds)
       cb->flags |= PKT_NEWDATA;
     }
 
-#ifdef CONFIG_NET_TIMESTAMPING
+#ifdef CONFIG_NET_TIMESTAMP
   if ((fds->events & POLLPRI) != 0)
     {
       cb->flags |= PKT_NEWDATA;
@@ -279,7 +279,7 @@ int pkt_pollsetup(FAR struct socket *psock, FAR struct 
pollfd *fds)
 
   /* Check for timestamping data */
 
-#ifdef CONFIG_NET_TIMESTAMPING
+#ifdef CONFIG_NET_TIMESTAMP
   if (!IOB_QEMPTY(&conn->errahead))
     {
       eventset |= POLLPRI | POLLERR;
diff --git a/net/pkt/pkt_recvmsg.c b/net/pkt/pkt_recvmsg.c
index c2c0bf02d77..ad488064ec7 100644
--- a/net/pkt/pkt_recvmsg.c
+++ b/net/pkt/pkt_recvmsg.c
@@ -185,7 +185,7 @@ static uint32_t pkt_recvfrom_eventhandler(FAR struct 
net_driver_s *dev,
     {
       /* If a new packet is available, then complete the read action. */
 
-#ifdef CONFIG_NET_TIMESTAMPING
+#ifdef CONFIG_NET_TIMESTAMP
       if ((flags & PKT_NEWDATA) != 0 && dev->d_iob->io_conn != NULL)
         {
           pstate->pr_cb->flags = 0;
@@ -346,7 +346,7 @@ static void append_timestamp(FAR struct pkt_recvfrom_s 
*pstate,
 #endif
 }
 
-#ifdef CONFIG_NET_TIMESTAMPING
+#ifdef CONFIG_NET_TIMESTAMP
 static void append_timestamping(FAR struct pkt_recvfrom_s *pstate,
                                 FAR struct iob_s *iob)
 {
@@ -502,7 +502,7 @@ ssize_t pkt_recvmsg(FAR struct socket *psock, FAR struct 
msghdr *msg,
 
   conn_dev_lock(&conn->sconn, dev);
 
-#ifdef CONFIG_NET_TIMESTAMPING
+#ifdef CONFIG_NET_TIMESTAMP
   if (flags & MSG_ERRQUEUE)
     {
       if (!IOB_QEMPTY(&conn->errahead))
diff --git a/net/pkt/pkt_sendmsg_buffered.c b/net/pkt/pkt_sendmsg_buffered.c
index 3743f7ffda1..cb2d9f05b83 100644
--- a/net/pkt/pkt_sendmsg_buffered.c
+++ b/net/pkt/pkt_sendmsg_buffered.c
@@ -294,7 +294,7 @@ ssize_t pkt_sendmsg(FAR struct socket *psock, FAR const 
struct msghdr *msg,
   iob_reserve(iob, CONFIG_NET_LL_GUARDSIZE);
   iob_update_pktlen(iob, 0, false);
 
-#ifdef CONFIG_NET_TIMESTAMPING
+#ifdef CONFIG_NET_TIMESTAMP
   if (_SO_GETOPT(conn->sconn.s_options, SO_TIMESTAMPING))
     {
       iob->io_conn = &conn->sconn;
diff --git a/net/pkt/pkt_sendmsg_unbuffered.c b/net/pkt/pkt_sendmsg_unbuffered.c
index 62d35e8af92..ac4be4c91d5 100644
--- a/net/pkt/pkt_sendmsg_unbuffered.c
+++ b/net/pkt/pkt_sendmsg_unbuffered.c
@@ -131,7 +131,7 @@ static uint32_t psock_send_eventhandler(FAR struct 
net_driver_s *dev,
           pstate->snd_sent          = pstate->snd_buflen;
           pstate->snd_conn->pendiob = dev->d_iob;
 
-#ifdef CONFIG_NET_TIMESTAMPING
+#ifdef CONFIG_NET_TIMESTAMP
           if (_SO_GETOPT(pstate->snd_conn->sconn.s_options,
                          SO_TIMESTAMPING))
             {
diff --git a/net/pkt/pkt_sockif.c b/net/pkt/pkt_sockif.c
index 7da08a0dd85..b2a3c2ced3c 100644
--- a/net/pkt/pkt_sockif.c
+++ b/net/pkt/pkt_sockif.c
@@ -368,7 +368,7 @@ static int pkt_close(FAR struct socket *psock)
 
               iob_free_queue(&conn->readahead);
 
-#ifdef CONFIG_NET_TIMESTAMPING
+#ifdef CONFIG_NET_TIMESTAMP
               iob_free_queue(&conn->errahead);
 #endif
 
diff --git a/net/socket/Kconfig b/net/socket/Kconfig
index 663860b923a..2ceaa2c88fa 100644
--- a/net/socket/Kconfig
+++ b/net/socket/Kconfig
@@ -78,18 +78,12 @@ config NET_SOLINGER
                write buffer support.
 
 config NET_TIMESTAMP
-       bool "SO_TIMESTAMP socket option"
+       bool "SO_TIMESTAMP/SO_TIMESTAMPING socket option"
        default n
        ---help---
-               Enable or disable support for the SO_TIMESTAMP socket option.
-               Supported on SocketCAN and Ethernet/UDP.
-
-config NET_TIMESTAMPING
-       bool "SO_TIMESTAMPING socket option"
-       default n
-       ---help---
-               Enable or disable support for the SO_TIMESTAMPING socket option.
-               Supported on Ethernet/PKT.
+               Enable or disable support for the SO_TIMESTAMP,
+               SO_TIMESTAMPNS and SO_TIMESTAMPING socket options.
+               Supported on SocketCAN, Ethernet/UDP and Ethernet/PKT.
 
 config NET_BINDTODEVICE
        bool "SO_BINDTODEVICE socket option Bind-to-device support"
diff --git a/net/socket/getsockopt.c b/net/socket/getsockopt.c
index e2d5bdd85a7..2d0d876986e 100644
--- a/net/socket/getsockopt.c
+++ b/net/socket/getsockopt.c
@@ -150,8 +150,6 @@ static int psock_socketlevel_option(FAR struct socket 
*psock, int option,
 #ifdef CONFIG_NET_TIMESTAMP
       case SO_TIMESTAMP:   /* Generates a timestamp in us for each incoming 
packet */
       case SO_TIMESTAMPNS: /* Generates a timestamp in ns for each incoming 
packet */
-#endif
-#ifdef CONFIG_NET_TIMESTAMPING
       case SO_TIMESTAMPING: /* Timestamping options */
 #endif
         {
diff --git a/net/socket/setsockopt.c b/net/socket/setsockopt.c
index c22efce8f3b..ca0bcb8bd66 100644
--- a/net/socket/setsockopt.c
+++ b/net/socket/setsockopt.c
@@ -140,8 +140,6 @@ static int psock_socketlevel_option(FAR struct socket 
*psock, int option,
 #ifdef CONFIG_NET_TIMESTAMP
       case SO_TIMESTAMP:   /* Generates a timestamp in us for each incoming 
packet */
       case SO_TIMESTAMPNS: /* Generates a timestamp in ns for each incoming 
packet */
-#endif
-#ifdef CONFIG_NET_TIMESTAMPING
       case SO_TIMESTAMPING: /* Timestamp all packets */
 #endif
         {

Reply via email to