Extend socket timestamping API
Subsystems (20)
PATCH v3 1/7 net: define receive timestamp filter for NTP
In reply to Miroslav LichvarAdd HWTSTAMP_FILTER_NTP_ALL to the hwtstamp_rx_filters enum for timestamping of NTP packets. There is currently only one driver (phyter) that could support it directly.
--- include/uapi/linux/net_tstamp.h | 3 +++ net/core/dev_ioctl.c | 2 ++ 2 files changed, 5 insertions(+)
include/uapi/linux/net_tstamp.h +3 -0
@@ -125,6 +125,9 @@ enum hwtstamp_rx_filters {HWTSTAMP_FILTER_PTP_V2_SYNC ,/* PTP v2/802.AS1, any layer, Delay_req packet */ HWTSTAMP_FILTER_PTP_V2_DELAY_REQ , + +/* NTP, UDP, all versions and packet modes */ + HWTSTAMP_FILTER_NTP_ALL, };#endif /* _NET_TIMESTAMPING_H */
net/core/dev_ioctl.c +2 -0
@@ -227,6 +227,8 @@ static int net_hwtstamp_validate(struct ifreq *ifr)case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ : rx_filter_valid =1 ;break ; +case HWTSTAMP_FILTER_NTP_ALL : +break ; }if (!tx_type_valid || !rx_filter_valid)
Signature · 1 line
2.9.3
PATCH v3 2/7 net: ethernet: update drivers to handle HWTSTAMP_FILTER_NTP_ALL
In reply to Miroslav LichvarInclude HWTSTAMP_FILTER_NTP_ALL in net_hwtstamp_validate() as a valid filter and update drivers which can timestamp all packets, or which explicitly list unsupported filters instead of using a default case, to handle the filter.
--- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 1 + drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 1 + drivers/net/ethernet/cavium/liquidio/lio_main.c | 1 + drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 1 + drivers/net/ethernet/cavium/octeon/octeon_mgmt.c | 1 + drivers/net/ethernet/intel/e1000e/netdev.c | 1 + drivers/net/ethernet/intel/i40e/i40e_ptp.c | 1 + drivers/net/ethernet/intel/igb/igb_ptp.c | 1 + drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c | 1 + drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 1 + drivers/net/ethernet/mellanox/mlx5/core/en_clock.c | 1 + drivers/net/ethernet/neterion/vxge/vxge-main.c | 1 + drivers/net/ethernet/qlogic/qede/qede_ptp.c | 1 + drivers/net/ethernet/sfc/ef10.c | 1 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1 + drivers/net/ethernet/ti/cpsw.c | 1 + drivers/net/ethernet/tile/tilegx.c | 1 + net/core/dev_ioctl.c | 3 +-- 18 files changed, 18 insertions(+), 2 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +1 -0
@@ -1268,6 +1268,7 @@ static int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata,case HWTSTAMP_FILTER_NONE :break ; +case HWTSTAMP_FILTER_NTP_ALL :case HWTSTAMP_FILTER_ALL :XGMAC_SET_BITS (mac_tscr,MAC_TSCR ,TSENALL ,1 );XGMAC_SET_BITS (mac_tscr,MAC_TSCR ,TSENA ,1 );
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +1 -0
@@ -15351,6 +15351,7 @@ int bnx2x_configure_ptp_filters(struct bnx2x *bp)break ;case HWTSTAMP_FILTER_ALL :case HWTSTAMP_FILTER_SOME : +case HWTSTAMP_FILTER_NTP_ALL : bp->rx_filter =HWTSTAMP_FILTER_NONE ;break ;case HWTSTAMP_FILTER_PTP_V1_L4_EVENT :
drivers/net/ethernet/cavium/liquidio/lio_main.c +1 -0
@@ -3020,6 +3020,7 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr)case HWTSTAMP_FILTER_PTP_V2_EVENT :case HWTSTAMP_FILTER_PTP_V2_SYNC :case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ : +case HWTSTAMP_FILTER_NTP_ALL : conf.rx_filter =HWTSTAMP_FILTER_ALL ;break ;default :
drivers/net/ethernet/cavium/liquidio/lio_vf_main.c +1 -0
@@ -2100,6 +2100,7 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr)case HWTSTAMP_FILTER_PTP_V2_EVENT :case HWTSTAMP_FILTER_PTP_V2_SYNC :case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ : +case HWTSTAMP_FILTER_NTP_ALL : conf.rx_filter =HWTSTAMP_FILTER_ALL ;break ;default :
drivers/net/ethernet/cavium/octeon/octeon_mgmt.c +1 -0
@@ -755,6 +755,7 @@ static int octeon_mgmt_ioctl_hwtstamp(struct net_device *netdev,case HWTSTAMP_FILTER_PTP_V2_EVENT :case HWTSTAMP_FILTER_PTP_V2_SYNC :case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ : +case HWTSTAMP_FILTER_NTP_ALL : p->has_rx_tstamp = have_hw_timestamps; config.rx_filter =HWTSTAMP_FILTER_ALL ;if (p->has_rx_tstamp) {
drivers/net/ethernet/intel/e1000e/netdev.c +1 -0
@@ -3680,6 +3680,7 @@ static int e1000e_config_hwtstamp(struct e1000_adapter *adapter,* Delay Request messages but not both so fall-through to * time stamp all packets. */ +case HWTSTAMP_FILTER_NTP_ALL :case HWTSTAMP_FILTER_ALL : is_l2 = true; is_l4 = true;
drivers/net/ethernet/intel/i40e/i40e_ptp.c +1 -0
@@ -562,6 +562,7 @@ static int i40e_ptp_set_timestamp_mode(struct i40e_pf *pf, config->rx_filter =HWTSTAMP_FILTER_PTP_V2_L2_EVENT ; }break ; +case HWTSTAMP_FILTER_NTP_ALL :case HWTSTAMP_FILTER_ALL :default :return -ERANGE ;
drivers/net/ethernet/intel/igb/igb_ptp.c +1 -0
@@ -941,6 +941,7 @@ static int igb_ptp_set_timestamp_mode(struct igb_adapter *adapter, is_l4 = true;break ;case HWTSTAMP_FILTER_PTP_V1_L4_EVENT : +case HWTSTAMP_FILTER_NTP_ALL :case HWTSTAMP_FILTER_ALL :/* 82576 cannot timestamp all packets, which it needs to do to * support both V1 Sync and Delay_Req messages
drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c +1 -0
@@ -883,6 +883,7 @@ static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter, IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER);break ;case HWTSTAMP_FILTER_PTP_V1_L4_EVENT : +case HWTSTAMP_FILTER_NTP_ALL :case HWTSTAMP_FILTER_ALL :/* The X550 controller is capable of timestamping all packets, * which allows it to accept any filter.
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +1 -0
@@ -2375,6 +2375,7 @@ static int mlx4_en_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)case HWTSTAMP_FILTER_PTP_V2_EVENT :case HWTSTAMP_FILTER_PTP_V2_SYNC :case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ : +case HWTSTAMP_FILTER_NTP_ALL : config.rx_filter =HWTSTAMP_FILTER_ALL ;break ;default :
drivers/net/ethernet/mellanox/mlx5/core/en_clock.c +1 -0
@@ -128,6 +128,7 @@ int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr)case HWTSTAMP_FILTER_PTP_V2_EVENT :case HWTSTAMP_FILTER_PTP_V2_SYNC :case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ : +case HWTSTAMP_FILTER_NTP_ALL :/* Disable CQE compression */ netdev_warn (dev,"Disabling cqe compression" ); err =mlx5e_modify_rx_cqe_compression_locked (priv, false);
drivers/net/ethernet/neterion/vxge/vxge-main.c +1 -0
@@ -3218,6 +3218,7 @@ static int vxge_hwtstamp_set(struct vxgedev *vdev, void __user *data)case HWTSTAMP_FILTER_PTP_V2_EVENT :case HWTSTAMP_FILTER_PTP_V2_SYNC :case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ : +case HWTSTAMP_FILTER_NTP_ALL :if (vdev->devh->config.hwts_en !=VXGE_HW_HWTS_ENABLE )return -EFAULT ;
drivers/net/ethernet/qlogic/qede/qede_ptp.c +1 -0
@@ -244,6 +244,7 @@ static int qede_ptp_cfg_filters(struct qede_dev *edev)break ;case HWTSTAMP_FILTER_ALL :case HWTSTAMP_FILTER_SOME : +case HWTSTAMP_FILTER_NTP_ALL : ptp->rx_filter =HWTSTAMP_FILTER_NONE ; rx_filter =QED_PTP_FILTER_ALL ;break ;
drivers/net/ethernet/sfc/ef10.c +1 -0
@@ -6068,6 +6068,7 @@ static int efx_ef10_ptp_set_ts_config(struct efx_nic *efx,case HWTSTAMP_FILTER_PTP_V2_EVENT :case HWTSTAMP_FILTER_PTP_V2_SYNC :case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ : +case HWTSTAMP_FILTER_NTP_ALL : init->rx_filter =HWTSTAMP_FILTER_ALL ; rc =efx_ptp_change_mode (efx, true,0 );if (!rc)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -0
@@ -644,6 +644,7 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr) ptp_over_ethernet =PTP_TCR_TSIPENA ;break ; +case HWTSTAMP_FILTER_NTP_ALL :case HWTSTAMP_FILTER_ALL :/* time stamp any incoming packet */ config.rx_filter =HWTSTAMP_FILTER_ALL ;
drivers/net/ethernet/ti/cpsw.c +1 -0
@@ -1734,6 +1734,7 @@ static int cpsw_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)case HWTSTAMP_FILTER_PTP_V1_L4_EVENT :case HWTSTAMP_FILTER_PTP_V1_L4_SYNC :case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ : +case HWTSTAMP_FILTER_NTP_ALL :return -ERANGE ;case HWTSTAMP_FILTER_PTP_V2_L4_EVENT :case HWTSTAMP_FILTER_PTP_V2_L4_SYNC :
drivers/net/ethernet/tile/tilegx.c +1 -0
@@ -512,6 +512,7 @@ static int tile_hwtstamp_set(struct net_device *dev, struct ifreq *rq)case HWTSTAMP_FILTER_PTP_V2_EVENT :case HWTSTAMP_FILTER_PTP_V2_SYNC :case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ : +case HWTSTAMP_FILTER_NTP_ALL : config.rx_filter =HWTSTAMP_FILTER_ALL ;break ;default :
net/core/dev_ioctl.c +1 -2
@@ -225,9 +225,8 @@ static int net_hwtstamp_validate(struct ifreq *ifr)case HWTSTAMP_FILTER_PTP_V2_EVENT :case HWTSTAMP_FILTER_PTP_V2_SYNC :case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ : - rx_filter_valid =1 ; -break ;case HWTSTAMP_FILTER_NTP_ALL : + rx_filter_valid =1 ;break ; }
Signature · 1 line
2.9.3
PATCH v3 5/7 net: don't make false software transmit timestamps
In reply to Miroslav LichvarIf software timestamping is enabled by the SO_TIMESTAMP(NS) option when a message without timestamp is already waiting in the queue, the __sock_recv_timestamp() function will read the current time to make a timestamp in order to always have something for the application.
However, this applies also to outgoing packets looped back to the error queue when hardware timestamping is enabled by the SO_TIMESTAMPING option. A software transmit timestamp made after the actual transmission is added to messages with hardware timestamps.
Modify the function to save the current time as a software timestamp only if it's for a received packet (i.e. it's not in the error queue).
--- net/socket.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/socket.c +2 -1
@@ -689,7 +689,8 @@ static void put_ts_pktinfo(struct msghdr *msg, struct sk_buff *skb)void __sock_recv_timestamp (struct msghdr *msg,struct sock *sk,struct sk_buff *skb) { -int need_software_tstamp =sock_flag (sk,SOCK_RCVTSTAMP ); +int need_software_tstamp =sock_flag (sk,SOCK_RCVTSTAMP ) && + !skb_is_err_queue (skb);struct scm_timestamping tss;int empty =1 ; struct skb_shared_hwtstamps *shhwtstamps =
Signature · 1 line
2.9.3
v3 cover Extend socket timestamping API
Changes v2->v3:
- modified struct scm_ts_pktinfo to use fixed-width integer types
- added WARN_ON_ONCE for missing RCU lock in dev_get_by_napi_id()
- modified dev_get_by_napi_id() to not return dev in unexpected branch
- modified recv to return SCM_TIMESTAMPING_PKTINFO even if the interface index is unknown
Changes v1->v2:
- added separate patch for new NAPI functions
- split code from __sock_recv_timestamp() for better readability
- fixed RCU locking
- fixed compiler warning (missing case in switch in first patch)
- inline sw_tx_timestamp() in its only user
Changes RFC->v1:
- reworked SOF_TIMESTAMPING_OPT_PKTINFO patch to not add new fields to skb shared info (net device is now looked up by napi_id), not require any changes in drivers, and restrict the cmsg to incoming packets
- renamed SOF_TIMESTAMPING_OPT_MULTIMSG to SOF_TIMESTAMPING_OPT_TX_SWHW and fixed its description
- moved struct scm_ts_pktinfo from errqueue.h to net_tstamp.h as it can't be received from the error queue anymore
- improved commit descriptions and removed incorrect comment
This patchset adds new options to the timestamping API that will be useful for NTP implementations and possibly other applications.
The first patch specifies a timestamp filter for NTP packets. The second patch updates drivers that can timestamp all packets, or need to list the filter as unsupported. There is no attempt to add the support to the phyter driver.
The third patch adds two helper functions working with NAPI ID, which is needed by the next patch. The fourth patch adds a new option to get a new control message with the L2 length and interface index for incoming packets with hardware timestamps.
The fifth patch fixes the code to not make a false software TX timestamp when hardware timestamping is enabled. The sixth patch depends on this fix.
The sixth patch adds a new option to request both software and hardware timestamps for outgoing packets. The seventh patch updates drivers that assumed software timestamping cannot be used together with hardware timestamping.
The patches have been tested on x86_64 machines with igb and e1000e drivers.
Miroslav Lichvar (7):
net: define receive timestamp filter for NTP
net: ethernet: update drivers to handle HWTSTAMP_FILTER_NTP_ALL
net: add function to retrieve original skb device using NAPI ID
net: add new control message for incoming HW-timestamped packets
net: don't make false software transmit timestamps
net: allow simultaneous SW and HW transmit timestamping
net: ethernet: update drivers to make both SW and HW TX timestamps
Documentation/networking/timestamping.txt | 23 ++++++++++-- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 4 +-- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 1 + drivers/net/ethernet/cavium/liquidio/lio_main.c | 1 + drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 1 + drivers/net/ethernet/cavium/octeon/octeon_mgmt.c | 1 + drivers/net/ethernet/intel/e1000e/netdev.c | 5 +-- drivers/net/ethernet/intel/i40e/i40e_ptp.c | 1 + drivers/net/ethernet/intel/igb/igb_ptp.c | 1 + drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c | 1 + drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 1 + drivers/net/ethernet/mellanox/mlx5/core/en_clock.c | 1 + drivers/net/ethernet/neterion/vxge/vxge-main.c | 1 + drivers/net/ethernet/qlogic/qede/qede_ptp.c | 1 + drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c | 3 +- drivers/net/ethernet/sfc/ef10.c | 1 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 ++-- drivers/net/ethernet/ti/cpsw.c | 1 + drivers/net/ethernet/tile/tilegx.c | 1 + include/linux/netdevice.h | 1 + include/linux/skbuff.h | 19 +++++----- include/uapi/asm-generic/socket.h | 2 ++ include/uapi/linux/net_tstamp.h | 14 +++++++- net/core/dev.c | 26 ++++++++++++++ net/core/dev_ioctl.c | 1 + net/core/skbuff.c | 4 +++ net/socket.c | 41 ++++++++++++++++++++-- 27 files changed, 141 insertions(+), 23 deletions(-)
Signature · 1 line
2.9.3
PATCH v3 6/7 net: allow simultaneous SW and HW transmit timestamping
Add SOF_TIMESTAMPING_OPT_TX_SWHW option to allow an outgoing packet to be looped to the socket's error queue with a software timestamp even when a hardware transmit timestamp is expected to be provided by the driver.
Applications using this option will receive two separate messages from the error queue, one with a software timestamp and the other with a hardware timestamp. As the hardware timestamp is saved to the shared skb info, which may happen before the first message with software timestamp is received by the application, the hardware timestamp is copied to the SCM_TIMESTAMPING control message only when the skb has no software timestamp or it is an incoming packet.
While changing sw_tx_timestamp(), inline it in skb_tx_timestamp() as there are no other users.
--- Documentation/networking/timestamping.txt | 14 ++++++++++++-- include/linux/skbuff.h | 10 ++-------- include/uapi/linux/net_tstamp.h | 3 ++- net/core/skbuff.c | 4 ++++ net/socket.c | 11 +++++++++++ 5 files changed, 31 insertions(+), 11 deletions(-)
Documentation/networking/timestamping.txt +12 -2
@@ -202,6 +202,14 @@ SOF_TIMESTAMPING_OPT_PKTINFO: interface index will be returned only if CONFIG_NET_RX_BUSY_POLL is enabled and the driver is using NAPI. +SOF_TIMESTAMPING_OPT_TX_SWHW: + + Request both hardware and software timestamps for outgoing packets + when SOF_TIMESTAMPING_TX_HARDWARE and SOF_TIMESTAMPING_TX_SOFTWARE + are enabled at the same time. If both timestamps are generated, + two separate messages will be looped to the socket's error queue, + each containing just one timestamp. + New applications are encouraged to pass SOF_TIMESTAMPING_OPT_ID to disambiguate timestamps and SOF_TIMESTAMPING_OPT_TSONLY to operate regardless of the setting of sysctl net.core.tstamp_allow_data.
@@ -321,8 +329,10 @@ struct scm_timestamping { }; The structure can return up to three timestamps. This is a legacy -feature. Only one field is non-zero at any time. Most timestamps -are passed in ts[0]. Hardware timestamps are passed in ts[2]. +feature. Most timestamps are passed in ts[0]. Hardware timestamps +are passed in ts[2]. Incoming packets may have timestamps in both +ts[0] and ts[2], but for outgoing packets only one field is non-zero +at any time. ts[1] used to hold hardware timestamps converted to system time. Instead, expose the hardware clock device on the NIC directly as
include/linux/skbuff.h +2 -8
@@ -3307,13 +3307,6 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb,void skb_tstamp_tx (struct sk_buff *orig_skb,struct skb_shared_hwtstamps *hwtstamps); -static inline void sw_tx_timestamp (struct sk_buff *skb) -{ -if (skb_shinfo (skb)->tx_flags &SKBTX_SW_TSTAMP && - !(skb_shinfo (skb)->tx_flags &SKBTX_IN_PROGRESS )) -skb_tstamp_tx (skb,NULL ); -} -/** * skb_tx_timestamp() - Driver hook for transmit timestamping *
@@ -3329,7 +3322,8 @@ static inline void sw_tx_timestamp(struct sk_buff *skb)static inline void skb_tx_timestamp (struct sk_buff *skb) {skb_clone_tx_timestamp (skb); -sw_tx_timestamp (skb); +if (skb_shinfo (skb)->tx_flags &SKBTX_SW_TSTAMP ) +skb_tstamp_tx (skb,NULL ); }/**
include/uapi/linux/net_tstamp.h +2 -1
@@ -28,8 +28,9 @@ enum {SOF_TIMESTAMPING_OPT_TSONLY = (1 <<11 ),SOF_TIMESTAMPING_OPT_STATS = (1 <<12 ),SOF_TIMESTAMPING_OPT_PKTINFO = (1 <<13 ), +SOF_TIMESTAMPING_OPT_TX_SWHW = (1 <<14 ), -SOF_TIMESTAMPING_LAST =SOF_TIMESTAMPING_OPT_PKTINFO , +SOF_TIMESTAMPING_LAST =SOF_TIMESTAMPING_OPT_TX_SWHW ,SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST -1 ) | SOF_TIMESTAMPING_LAST };
net/core/skbuff.c +4 -0
@@ -3875,6 +3875,10 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb,if (!sk)return ; +if (!hwtstamps && !(sk->sk_tsflags &SOF_TIMESTAMPING_OPT_TX_SWHW ) && +skb_shinfo (orig_skb)->tx_flags &SKBTX_IN_PROGRESS ) +return ; + tsonly = sk->sk_tsflags &SOF_TIMESTAMPING_OPT_TSONLY ;if (!skb_may_tx_timestamp (sk, tsonly))return ;
net/socket.c +11 -0
@@ -662,6 +662,16 @@ static bool skb_is_err_queue(const struct sk_buff *skb)return skb->pkt_type ==PACKET_OUTGOING ; } +/* On transmit, software and hardware timestamps are returned independently. +* As the two skb clones share the hardware timestamp, which may be updated +* before the software timestamp is received, a hardware TX timestamp may be +* returned only if there is no software TX timestamp. +*/ +static bool skb_is_swtx_tstamp (const struct sk_buff *skb) +{ +return skb->tstamp &&skb_is_err_queue (skb); +} +static void put_ts_pktinfo (struct msghdr *msg,struct sk_buff *skb) {struct scm_ts_pktinfo ts_pktinfo;
@@ -721,6 +731,7 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, empty =0 ;if (shhwtstamps && (sk->sk_tsflags &SOF_TIMESTAMPING_RAW_HARDWARE ) && + !skb_is_swtx_tstamp (skb) &&ktime_to_timespec_cond (shhwtstamps->hwtstamp, tss.ts +2 )) { empty =0 ; if ((sk->sk_tsflags & SOF_TIMESTAMPING_OPT_PKTINFO) &&
Signature · 1 line
2.9.3
PATCH v3 3/7 net: add function to retrieve original skb device using NAPI ID
In reply to Miroslav LichvarSince commit b68581778cd0 ("net: Make skb->skb_iif always track skb->dev") skbs don't have the original index of the interface which received the packet. This information is now needed for a new control message related to hardware timestamping.
Instead of adding a new field to skb, we can find the device by the NAPI ID if it is available, i.e. CONFIG_NET_RX_BUSY_POLL is enabled and the driver is using NAPI. Add dev_get_by_napi_id() and also skb_napi_id() to hide the CONFIG_NET_RX_BUSY_POLL ifdef.
--- include/linux/netdevice.h | 1 + include/linux/skbuff.h | 9 +++++++++ net/core/dev.c | 26 ++++++++++++++++++++++++++ 3 files changed, 36 insertions(+)
include/linux/netdevice.h +1 -0
@@ -2456,6 +2456,7 @@ static inline int dev_recursion_level(void)struct net_device *dev_get_by_index (struct net *net,int ifindex);struct net_device *__dev_get_by_index (struct net *net,int ifindex);struct net_device *dev_get_by_index_rcu (struct net *net,int ifindex); +struct net_device *dev_get_by_napi_id (unsigned int napi_id);int netdev_get_name (struct net *net,char *name,int ifindex);int dev_restart (struct net_device *dev);int skb_gro_receive (struct sk_buff **head,struct sk_buff *skb);
include/linux/skbuff.h +9 -0
@@ -915,6 +915,15 @@ static inline bool skb_pkt_type_ok(u32 ptype)return ptype <=PACKET_OTHERHOST ; } +static inline unsigned int skb_napi_id (const struct sk_buff *skb) +{ +#ifdef CONFIG_NET_RX_BUSY_POLL +return skb->napi_id; +#else +return 0 ; +#endif +} +void kfree_skb (struct sk_buff *skb);void kfree_skb_list (struct sk_buff *segs);void skb_tx_error (struct sk_buff *skb);
net/core/dev.c +26 -0
@@ -161,6 +161,7 @@ static int netif_rx_internal(struct sk_buff *skb);static int call_netdevice_notifiers_info (unsigned long val,struct net_device *dev,struct netdev_notifier_info *info); +static struct napi_struct *napi_by_id (unsigned int napi_id);/* * The @dev_base_head list is protected by @dev_base_lock and the rtnl
@@ -865,6 +866,31 @@ struct net_device *dev_get_by_index(struct net *net, int ifindex)EXPORT_SYMBOL (dev_get_by_index);/** +* dev_get_by_napi_id - find a device by napi_id +* @napi_id: ID of the NAPI struct +* +* Search for an interface by NAPI ID. Returns %NULL if the device +* is not found or a pointer to the device. The device has not had +* its reference counter increased so the caller must be careful +* about locking. The caller must hold RCU lock. +*/ + +struct net_device *dev_get_by_napi_id (unsigned int napi_id) +{ +struct napi_struct *napi; + +WARN_ON_ONCE (!rcu_read_lock_held ()); + +if (napi_id <MIN_NAPI_ID ) +return NULL ; + + napi =napi_by_id (napi_id); + +return napi ? napi->dev :NULL ; +} +EXPORT_SYMBOL (dev_get_by_napi_id); + +/** * netdev_get_name - get a netdevice name, knowing its ifindex. * @net: network namespace * @name: a pointer to the buffer where the name will be stored.
Signature · 1 line
2.9.3
PATCH v3 7/7 net: ethernet: update drivers to make both SW and HW TX timestamps
In reply to Miroslav LichvarSome drivers were calling the skb_tx_timestamp() function only when a hardware timestamp was not requested. Now that applications can use the SOF_TIMESTAMPING_OPT_TX_SWHW option to request both software and hardware timestamps, the drivers need to be modified to unconditionally call skb_tx_timestamp().
--- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 3 +-- drivers/net/ethernet/intel/e1000e/netdev.c | 4 ++-- drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c | 3 +-- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++---- 4 files changed, 6 insertions(+), 10 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +1 -2
@@ -1391,8 +1391,7 @@ static void xgbe_prep_tx_tstamp(struct xgbe_prv_data *pdata,spin_unlock_irqrestore (&pdata->tstamp_lock, flags); } -if (!XGMAC_GET_BITS (packet->attributes,TX_PACKET_ATTRIBUTES ,PTP )) -skb_tx_timestamp (skb); +skb_tx_timestamp (skb); }static void xgbe_prep_vlan (struct sk_buff *skb,struct xgbe_packet_data *packet)
drivers/net/ethernet/intel/e1000e/netdev.c +2 -2
@@ -5868,10 +5868,10 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, adapter->tx_hwtstamp_skb =skb_get (skb); adapter->tx_hwtstamp_start = jiffies;schedule_work (&adapter->tx_hwtstamp_work); - }else { -skb_tx_timestamp (skb); } +skb_tx_timestamp (skb); +netdev_sent_queue (netdev, skb->len);e1000_tx_queue (tx_ring, tx_flags, count);/* Make sure there is space in the ring for the next send. */
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c +1 -2
@@ -1418,8 +1418,7 @@ static netdev_tx_t sxgbe_xmit(struct sk_buff *skb, struct net_device *dev) priv->hw->desc->tx_enable_tstamp (first_desc); } -if (!tqueue->hwts_tx_en) -skb_tx_timestamp (skb); +skb_tx_timestamp (skb); priv->hw->dma->enable_dma_transmission (priv->ioaddr, txq_index);
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -4
@@ -2880,8 +2880,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) priv->xstats.tx_set_ic_bit++; } -if (!priv->hwts_tx_en) -skb_tx_timestamp (skb); +skb_tx_timestamp (skb);if (unlikely ((skb_shinfo (skb)->tx_flags &SKBTX_HW_TSTAMP ) && priv->hwts_tx_en)) {
@@ -3084,8 +3083,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) priv->xstats.tx_set_ic_bit++; } -if (!priv->hwts_tx_en) -skb_tx_timestamp (skb); +skb_tx_timestamp (skb);/* Ready to fill the first descriptor and set the OWN bit w/o any * problems because all the descriptors are actually ready to be
Signature · 1 line
2.9.3
PATCH v3 4/7 net: add new control message for incoming HW-timestamped packets
In reply to Miroslav LichvarAdd SOF_TIMESTAMPING_OPT_PKTINFO option to request a new control message for incoming packets with hardware timestamps. It contains the index of the real interface which received the packet and the length of the packet at layer 2.
The index is useful with bonding, bridges and other interfaces, where IP_PKTINFO doesn't allow applications to determine which PHC made the timestamp. With the L2 length (and link speed) it is possible to transpose preamble timestamps to trailer timestamps, which are used in the NTP protocol.
While this information could be provided by two new socket options independently from timestamping, it doesn't look like they would be very useful. With this option any performance impact is limited to hardware timestamping.
Use dev_get_by_napi_id() to get the device and its index. On kernels with disabled CONFIG_NET_RX_BUSY_POLL or drivers not using NAPI, a zero index will be returned in the control message.
--- Documentation/networking/timestamping.txt | 9 +++++++++ include/uapi/asm-generic/socket.h | 2 ++ include/uapi/linux/net_tstamp.h | 10 +++++++++- net/socket.c | 27 ++++++++++++++++++++++++++- 4 files changed, 46 insertions(+), 2 deletions(-)
Documentation/networking/timestamping.txt +9 -0
@@ -193,6 +193,15 @@ SOF_TIMESTAMPING_OPT_STATS: the transmit timestamps, such as how long a certain block of data was limited by peer's receiver window. +SOF_TIMESTAMPING_OPT_PKTINFO: + + Enable the SCM_TIMESTAMPING_PKTINFO control message for incoming + packets with hardware timestamps. The message contains struct + scm_ts_pktinfo, which supplies the index of the real interface which + received the packet and its length at layer 2. A valid (non-zero) + interface index will be returned only if CONFIG_NET_RX_BUSY_POLL is + enabled and the driver is using NAPI. + New applications are encouraged to pass SOF_TIMESTAMPING_OPT_ID to disambiguate timestamps and SOF_TIMESTAMPING_OPT_TSONLY to operate regardless of the setting of sysctl net.core.tstamp_allow_data.
include/uapi/asm-generic/socket.h +2 -0
@@ -100,4 +100,6 @@#define SO_COOKIE 57 +#define SCM_TIMESTAMPING_PKTINFO 58 +#endif /* __ASM_GENERIC_SOCKET_H */
include/uapi/linux/net_tstamp.h +9 -1
@@ -9,6 +9,7 @@#ifndef _NET_TIMESTAMPING_H#define _NET_TIMESTAMPING_H +#include <linux/types.h> #include <linux/socket.h> /* for SO_TIMESTAMPING */ /* SO_TIMESTAMPING gets an integer bit field comprised of these values */
@@ -26,8 +27,9 @@ enum {SOF_TIMESTAMPING_OPT_CMSG = (1 <<10 ),SOF_TIMESTAMPING_OPT_TSONLY = (1 <<11 ),SOF_TIMESTAMPING_OPT_STATS = (1 <<12 ), +SOF_TIMESTAMPING_OPT_PKTINFO = (1 <<13 ), -SOF_TIMESTAMPING_LAST =SOF_TIMESTAMPING_OPT_STATS , +SOF_TIMESTAMPING_LAST =SOF_TIMESTAMPING_OPT_PKTINFO ,SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST -1 ) | SOF_TIMESTAMPING_LAST };
@@ -130,4 +132,10 @@ enum hwtstamp_rx_filters { HWTSTAMP_FILTER_NTP_ALL, }; +/* SCM_TIMESTAMPING_PKTINFO control message */ +struct scm_ts_pktinfo { +__u32 if_index; +__u32 pkt_length; +}; +#endif /* _NET_TIMESTAMPING_H */
net/socket.c +26 -1
@@ -662,6 +662,27 @@ static bool skb_is_err_queue(const struct sk_buff *skb)return skb->pkt_type ==PACKET_OUTGOING ; } +static void put_ts_pktinfo (struct msghdr *msg,struct sk_buff *skb) +{ +struct scm_ts_pktinfo ts_pktinfo; +struct net_device *orig_dev; +int ifindex =0 ; + +if (!skb_mac_header_was_set (skb)) +return ; + +rcu_read_lock (); + orig_dev =dev_get_by_napi_id (skb_napi_id (skb)); +if (orig_dev) + ifindex = orig_dev->ifindex; +rcu_read_unlock (); + + ts_pktinfo.if_index = ifindex; + ts_pktinfo.pkt_length = skb->len -skb_mac_offset (skb); +put_cmsg (msg,SOL_SOCKET ,SCM_TIMESTAMPING_PKTINFO , +sizeof (ts_pktinfo), &ts_pktinfo); +} +/* * called from sock_recv_timestamp() if sock_flag(sk, SOCK_RCVTSTAMP) */
@@ -699,8 +720,12 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, empty =0 ;if (shhwtstamps && (sk->sk_tsflags &SOF_TIMESTAMPING_RAW_HARDWARE ) && -ktime_to_timespec_cond (shhwtstamps->hwtstamp, tss.ts +2 )) +ktime_to_timespec_cond (shhwtstamps->hwtstamp, tss.ts +2 )) { empty =0 ; +if ((sk->sk_tsflags &SOF_TIMESTAMPING_OPT_PKTINFO ) && + !skb_is_err_queue (skb)) +put_ts_pktinfo (msg, skb); + }if (!empty) {put_cmsg (msg,SOL_SOCKET ,SCM_TIMESTAMPING ,sizeof (tss), &tss);
Signature · 1 line
2.9.3
Re: [PATCH v3 net-next 3/7] net: add function to retrieve original skb device using NAPI ID
In reply to Miroslav LichvarQuoted 10 lines · Miroslav Lichvar
Since commit
b68581778cd0("net: Makeskb->skb_iifalways trackskb->dev") skbs don't have the original index of the interface which received the packet. This information is now needed for a new control message related to hardware timestamping.Instead of adding a new field to skb, we can find the device by the NAPI ID if it is available, i.e.
CONFIG_NET_RX_BUSY_POLLis enabled and the driver is using NAPI. Adddev_get_by_napi_id()and alsoskb_napi_id()to hide theCONFIG_NET_RX_BUSY_POLLifdef.
Quoted 4 lines
CC Richard Cochran <[email protected]>CC Willem de Bruijn <[email protected]>Suggested-by Willem de Bruijn <[email protected]>Signed-off-by Miroslav Lichvar <[email protected]>
Re: [PATCH v3 net-next 4/7] net: add new control message for incoming HW-timestamped packets
In reply to Miroslav LichvarQuoted 16 lines · Miroslav Lichvar
Add
SOF_TIMESTAMPING_OPT_PKTINFOoption to request a new control message for incoming packets with hardware timestamps. It contains the index of the real interface which received the packet and the length of the packet at layer 2.The index is useful with bonding, bridges and other interfaces, where
IP_PKTINFOdoesn't allow applications to determine which PHC made the timestamp. With the L2 length (and link speed) it is possible to transpose preamble timestamps to trailer timestamps, which are used in the NTP protocol.While this information could be provided by two new socket options independently from timestamping, it doesn't look like they would be very useful. With this option any performance impact is limited to hardware timestamping.
Quoted 7 lines
Use
dev_get_by_napi_id()to get the device and its index. On kernels with disabledCONFIG_NET_RX_BUSY_POLLor drivers not using NAPI, a zero index will be returned in the control message.CC Richard Cochran <[email protected]>CC Willem de Bruijn <[email protected]>Signed-off-by Miroslav Lichvar <[email protected]>
Re: [PATCH v3 net-next 6/7] net: allow simultaneous SW and HW transmit timestamping
In reply to Miroslav LichvarQuoted 13 lines · Miroslav Lichvar
Add
SOF_TIMESTAMPING_OPT_TX_SWHWoption to allow an outgoing packet to be looped to the socket's error queue with a software timestamp even when a hardware transmit timestamp is expected to be provided by the driver.Applications using this option will receive two separate messages from the error queue, one with a software timestamp and the other with a hardware timestamp. As the hardware timestamp is saved to the shared skb info, which may happen before the first message with software timestamp is received by the application, the hardware timestamp is copied to the
SCM_TIMESTAMPINGcontrol message only when the skb has no software timestamp or it is an incoming packet.
Quoted 6 lines
While changing
sw_tx_timestamp(), inline it inskb_tx_timestamp()as there are no other users.CC Richard Cochran <[email protected]>CC Willem de Bruijn <[email protected]>Signed-off-by Miroslav Lichvar <[email protected]>
Willem de Bruijn
maintainerRe: [PATCH v3 net-next 5/7] net: don't make false software transmit timestamps
In reply to Miroslav LichvarQuoted 8 lines · Miroslav Lichvar
If software timestamping is enabled by the
SO_TIMESTAMP(NS)option when a message without timestamp is already waiting in the queue, the__sock_recv_timestamp()function will read the current time to make a timestamp in order to always have something for the application.However, this applies also to outgoing packets looped back to the error queue when hardware timestamping is enabled by the
SO_TIMESTAMPINGoption.
This is already the case for sockets that have both software receive timestamps and hardware tx timestamps enabled, independent from the new option SOF_TIMESTAMPING_OPT_TX_SWHW, right? If so, then this behavior must remain.
Re: [PATCH v3 net-next 5/7] net: don't make false software transmit timestamps
Quoted 6 lines · Willem de Bruijn
Quoted 5 lines · Miroslav Lichvar
If software timestamping is enabled by the
SO_TIMESTAMP(NS)option when a message without timestamp is already waiting in the queue, the__sock_recv_timestamp()function will read the current time to make a timestamp in order to always have something for the application.
Quoted 8 lines
Quoted 3 lines
However, this applies also to outgoing packets looped back to the error queue when hardware timestamping is enabled by the
SO_TIMESTAMPINGoption.This is already the case for sockets that have both software receive timestamps and hardware tx timestamps enabled, independent from the new option
SOF_TIMESTAMPING_OPT_TX_SWHW, right? If so, then this behavior must remain.
Even if we consider that it's not actually returning a valid TX timestamp and it didn't behave as documented ("Only one field is non-zero at any time")?
On the RX side this timestamp does make some sense as it could be viewed as a very late timestamp, correctly ordered after the HW timestamp, but on the TX side the order is reversed and returning a timestamp later than the actual transmission might break a protocol.
If you don't see it as a bug fix, I think this weird interaction between the SO_TIMESTAMPING(NS) and SO_TIMESTAMPING options needs to be documented.
Signature · 1 line
Miroslav Lichvar
Willem de Bruijn
maintainerRe: [PATCH v3 net-next 5/7] net: don't make false software transmit timestamps
Quoted 11 lines · Miroslav Lichvar
Quoted 10 lines · Willem de Bruijn
Quoted 8 lines · Miroslav Lichvar
If software timestamping is enabled by the
SO_TIMESTAMP(NS)option when a message without timestamp is already waiting in the queue, the__sock_recv_timestamp()function will read the current time to make a timestamp in order to always have something for the application.However, this applies also to outgoing packets looped back to the error queue when hardware timestamping is enabled by the
SO_TIMESTAMPINGoption.
Quoted 8 lines
Quoted 4 lines
This is already the case for sockets that have both software receive timestamps and hardware tx timestamps enabled, independent from the new option
SOF_TIMESTAMPING_OPT_TX_SWHW, right? If so, then this behavior must remain.Even if we consider that it's not actually returning a valid TX timestamp and it didn't behave as documented ("Only one field is non-zero at any time")?
Even if it is not a very useful timestamp. Applications may read it nonetheless. I think that the documentation is newer than the feature, and wrong in this case.
Quoted 3 lines
On the RX side this timestamp does make some sense as it could be viewed as a very late timestamp, correctly ordered after the HW timestamp,
Actually, on Rx it is equally problematic. It can easily generate out of order timestamps. When enabling timestamping, the first packets will have a timestamp generated at recvmsg while the following have one generated at __netif_receive_skb_core.
Quoted 6 lines
but on the TX side the order is reversed and returning a timestamp later than the actual transmission might break a protocol.
If you don't see it as a bug fix, I think this weird interaction between the
SO_TIMESTAMPING(NS)andSO_TIMESTAMPINGoptions needs to be documented.
I agree. I don't think that it's all that useful, but it is established behavior.
Re: [PATCH v3 net-next 4/7] net: add new control message for incoming HW-timestamped packets
In reply to Miroslav LichvarQuoted 85 lines · Miroslav Lichvar
Add
SOF_TIMESTAMPING_OPT_PKTINFOoption to request a new control message for incoming packets with hardware timestamps. It contains the index of the real interface which received the packet and the length of the packet at layer 2.The index is useful with bonding, bridges and other interfaces, where
IP_PKTINFOdoesn't allow applications to determine which PHC made the timestamp. With the L2 length (and link speed) it is possible to transpose preamble timestamps to trailer timestamps, which are used in the NTP protocol.While this information could be provided by two new socket options independently from timestamping, it doesn't look like they would be very useful. With this option any performance impact is limited to hardware timestamping.
Use
dev_get_by_napi_id()to get the device and its index. On kernels with disabledCONFIG_NET_RX_BUSY_POLLor drivers not using NAPI, a zero index will be returned in the control message.CC Richard Cochran <[email protected]>CC Willem de Bruijn <[email protected]>Signed-off-by Miroslav Lichvar <[email protected]>--- Documentation/networking/timestamping.txt | 9 +++++++++ include/uapi/asm-generic/socket.h | 2 ++ include/uapi/linux/net_tstamp.h | 10 +++++++++- net/socket.c | 27 ++++++++++++++++++++++++++- 4 files changed, 46 insertions(+), 2 deletions(-)Documentation/networking/timestamping.txt +9
-0@@ -193,6 +193,15 @@ SOF_TIMESTAMPING_OPT_STATS: the transmit timestamps, such as how long a certain block of data was limited by peer's receiver window. +SOF_TIMESTAMPING_OPT_PKTINFO: + + Enable the SCM_TIMESTAMPING_PKTINFO control message for incoming + packets with hardware timestamps. The message contains struct + scm_ts_pktinfo, which supplies the index of the real interface which + received the packet and its length at layer 2. A valid (non-zero) + interface index will be returned only if CONFIG_NET_RX_BUSY_POLL is + enabled and the driver is using NAPI. + New applications are encouraged to pass SOF_TIMESTAMPING_OPT_ID to disambiguate timestamps and SOF_TIMESTAMPING_OPT_TSONLY to operate regardless of the setting of sysctl net.core.tstamp_allow_data.include/uapi/asm-generic/socket.h +2
-0@@ -100,4 +100,6 @@#define SO_COOKIE 57 +#define SCM_TIMESTAMPING_PKTINFO 58 +#endif /* __ASM_GENERIC_SOCKET_H */ include/uapi/linux/net_tstamp.h +3
-1@@ -9,6 +9,7 @@#ifndef _NET_TIMESTAMPING_H#define _NET_TIMESTAMPING_H +#include <linux/types.h> #include <linux/socket.h> /* for SO_TIMESTAMPING */ /* SO_TIMESTAMPING gets an integer bit field comprised of these values */ @@ -26,8 +27,9 @@ enum {SOF_TIMESTAMPING_OPT_CMSG = (1 <<10 ),SOF_TIMESTAMPING_OPT_TSONLY = (1 <<11 ),SOF_TIMESTAMPING_OPT_STATS = (1 <<12 ), +SOF_TIMESTAMPING_OPT_PKTINFO = (1 <<13 ), -SOF_TIMESTAMPING_LAST =SOF_TIMESTAMPING_OPT_STATS , +SOF_TIMESTAMPING_LAST =SOF_TIMESTAMPING_OPT_PKTINFO ,SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST -1 ) | SOF_TIMESTAMPING_LAST };
include/uapi/linux/net_tstamp.h enum hwtstamp_rx_filters { · line 140
Quoted 9 lines
include/uapi/linux/net_tstamp.h +6
-0@@ -130,4 +132,10 @@ enum hwtstamp_rx_filters { HWTSTAMP_FILTER_NTP_ALL, }; +/* SCM_TIMESTAMPING_PKTINFO control message */ +struct scm_ts_pktinfo { +__u32 if_index; +__u32 pkt_length; +}; +
Given that this structure can change in the future, it might be worth considering using TLVs (e.g., netlink attributes), similar to what tcp_get_timestamping_opt_stats() does. This would simplify adding/removing fields to/from the control message.
Thanks,
Soheil
Quoted 50 lines
include/uapi/linux/net_tstamp.h +0
-0#endif /* _NET_TIMESTAMPING_H */ net/socket.c +26
-2@@ -662,6 +662,27 @@ static bool skb_is_err_queue(const struct sk_buff *skb)return skb->pkt_type ==PACKET_OUTGOING ; } +static void put_ts_pktinfo (struct msghdr *msg,struct sk_buff *skb) +{ +struct scm_ts_pktinfo ts_pktinfo; +struct net_device *orig_dev; +int ifindex =0 ; + +if (!skb_mac_header_was_set (skb)) +return ; + +rcu_read_lock (); + orig_dev =dev_get_by_napi_id (skb_napi_id (skb)); +if (orig_dev) + ifindex = orig_dev->ifindex; +rcu_read_unlock (); + + ts_pktinfo.if_index = ifindex; + ts_pktinfo.pkt_length = skb->len -skb_mac_offset (skb); +put_cmsg (msg,SOL_SOCKET ,SCM_TIMESTAMPING_PKTINFO , +sizeof (ts_pktinfo), &ts_pktinfo); +} +/* * called from sock_recv_timestamp() if sock_flag(sk, SOCK_RCVTSTAMP) */ @@ -699,8 +720,12 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, empty =0 ;if (shhwtstamps && (sk->sk_tsflags &SOF_TIMESTAMPING_RAW_HARDWARE ) && -ktime_to_timespec_cond (shhwtstamps->hwtstamp, tss.ts +2 )) +ktime_to_timespec_cond (shhwtstamps->hwtstamp, tss.ts +2 )) { empty =0 ; +if ((sk->sk_tsflags &SOF_TIMESTAMPING_OPT_PKTINFO ) && + !skb_is_err_queue (skb)) +put_ts_pktinfo (msg, skb); + }if (!empty) {put_cmsg (msg,SOL_SOCKET ,SCM_TIMESTAMPING ,sizeof (tss), &tss); --2.9.3
Re: [PATCH v3 net-next 4/7] net: add new control message for incoming HW-timestamped packets
Quoted 12 lines · Soheil Hassas Yeganeh
include/uapi/linux/net_tstamp.h enum hwtstamp_rx_filters { · line 140
Quoted 6 lines · Miroslav Lichvar
include/uapi/linux/net_tstamp.h +6
-0+/* SCM_TIMESTAMPING_PKTINFO control message */ +struct scm_ts_pktinfo { +__u32 if_index; +__u32 pkt_length; +}; +Given that this structure can change in the future, it might be worth considering using TLVs (e.g., netlink attributes), similar to what
tcp_get_timestamping_opt_stats()does. This would simplify adding/removing fields to/from the control message.
[ BTW, please trim your replies. ]
Personally, I dislike TLVs. Alternatively, you could add some reserved fields for future use.
Thanks,
Richard