mirror of
https://github.com/apache/nuttx.git
synced 2026-10-03 20:27:53 +00:00
net/netdev: add NETDEV_TX_STAMP and handle SIOCETHTOOL ETHTOOL_GET_TS_INFO
Add the NETDEV_TX_STAMP capability flag to d_features, next to the existing NETDEV_RX_STAMP, so a driver can declare that it delivers hardware TX timestamps. SIOCETHTOOL and ETHTOOL_GET_TS_INFO were already defined but not implemented. Add struct ethtool_ts_info, with the same layout as Linux, and handle SIOCETHTOOL in netdev_ioctl.c so that userspace (such as ptpd) can query the timestamping capabilities of an interface the same way linuxptp/ptp4l does on Linux: - ETHTOOL_GET_TS_INFO fills so_timestamping from d_features: RX_HARDWARE | RAW_HARDWARE with NETDEV_RX_STAMP, otherwise RX_SOFTWARE | SOFTWARE (the stack stamps received packets with CLOCK_REALTIME), and TX_HARDWARE | RAW_HARDWARE with NETDEV_TX_STAMP. phc_index is -1, tx_types and rx_filters are zero. - Any other ethtool command is passed to the driver's d_ioctl when CONFIG_NETDEV_IOCTL is enabled, otherwise -ENOTTY is returned. Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
This commit is contained in:
parent
b7001f2d9f
commit
6e14c8cfe5
3 changed files with 117 additions and 0 deletions
|
|
@ -23,6 +23,12 @@
|
|||
#ifndef __INCLUDE_NUTTX_ETHTOOL_H
|
||||
#define __INCLUDE_NUTTX_ETHTOOL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
|
@ -221,4 +227,29 @@ struct ethtool_cmd
|
|||
uint32_t reserved[2];
|
||||
};
|
||||
|
||||
/* struct ethtool_ts_info - holds a device's timestamping and PHC
|
||||
* association (ETHTOOL_GET_TS_INFO), same layout as Linux.
|
||||
* @cmd: command number = %ETHTOOL_GET_TS_INFO
|
||||
* @so_timestamping: bit mask of the sum of the supported SO_TIMESTAMPING
|
||||
* flags (SOF_TIMESTAMPING_*)
|
||||
* @phc_index: device index of the associated PHC, or -1 if there is none
|
||||
* @tx_types: bit mask of the supported hwtstamp_tx_types values; zero,
|
||||
* NuttX has no SIOCSHWTSTAMP to select them
|
||||
* @tx_reserved: reserved for future use, zero
|
||||
* @rx_filters: bit mask of the supported hwtstamp_rx_filters values; zero,
|
||||
* NuttX has no SIOCSHWTSTAMP to select them
|
||||
* @rx_reserved: reserved for future use, zero
|
||||
*/
|
||||
|
||||
struct ethtool_ts_info
|
||||
{
|
||||
uint32_t cmd;
|
||||
uint32_t so_timestamping;
|
||||
int32_t phc_index;
|
||||
uint32_t tx_types;
|
||||
uint32_t tx_reserved[3];
|
||||
uint32_t rx_filters;
|
||||
uint32_t rx_reserved[3];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@
|
|||
#define NETDEV_TX_CSUM (1 << 1) /* Netdev support hardware tx checksum */
|
||||
#define NETDEV_RX_CSUM (1 << 2) /* Netdev support hardware rx checksum */
|
||||
#define NETDEV_RX_STAMP (1 << 3) /* Netdev support hardware timestamp */
|
||||
#define NETDEV_TX_STAMP (1 << 4) /* Netdev provides hardware TX timestamps */
|
||||
|
||||
/* Determine the largest possible address */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue