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 <wenquan1@xiaomi.com>
This commit is contained in:
wenquan1 2026-03-11 16:07:19 +08:00 • committed by Xiang Xiao
parent 7c87b4586c
commit cf78962356
11 changed files with 19 additions and 31 deletions

View file

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

View file

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

View file

@ -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 */

View file

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

View file

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

View file

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

View file

@ -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))
{

View file

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

View file

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

View file

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

View file

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