diff options
Diffstat (limited to 'Documentation/networking/timestamping.txt')
| -rw-r--r-- | Documentation/networking/timestamping.txt | 67 | 
1 files changed, 42 insertions, 25 deletions
diff --git a/Documentation/networking/timestamping.txt b/Documentation/networking/timestamping.txt index 98097d8cb91..bc355412490 100644 --- a/Documentation/networking/timestamping.txt +++ b/Documentation/networking/timestamping.txt @@ -21,26 +21,38 @@ has such a feature).  SO_TIMESTAMPING: -Instructs the socket layer which kind of information is wanted. The -parameter is an integer with some of the following bits set. Setting -other bits is an error and doesn't change the current state. - -SOF_TIMESTAMPING_TX_HARDWARE:  try to obtain send time stamp in hardware -SOF_TIMESTAMPING_TX_SOFTWARE:  if SOF_TIMESTAMPING_TX_HARDWARE is off or -                               fails, then do it in software -SOF_TIMESTAMPING_RX_HARDWARE:  return the original, unmodified time stamp -                               as generated by the hardware -SOF_TIMESTAMPING_RX_SOFTWARE:  if SOF_TIMESTAMPING_RX_HARDWARE is off or -                               fails, then do it in software -SOF_TIMESTAMPING_RAW_HARDWARE: return original raw hardware time stamp -SOF_TIMESTAMPING_SYS_HARDWARE: return hardware time stamp transformed to -                               the system time base -SOF_TIMESTAMPING_SOFTWARE:     return system time stamp generated in -                               software - -SOF_TIMESTAMPING_TX/RX determine how time stamps are generated. -SOF_TIMESTAMPING_RAW/SYS determine how they are reported in the -following control message: +Instructs the socket layer which kind of information should be collected +and/or reported.  The parameter is an integer with some of the following +bits set. Setting other bits is an error and doesn't change the current +state. + +Four of the bits are requests to the stack to try to generate +timestamps.  Any combination of them is valid. + +SOF_TIMESTAMPING_TX_HARDWARE:  try to obtain send time stamps in hardware +SOF_TIMESTAMPING_TX_SOFTWARE:  try to obtain send time stamps in software +SOF_TIMESTAMPING_RX_HARDWARE:  try to obtain receive time stamps in hardware +SOF_TIMESTAMPING_RX_SOFTWARE:  try to obtain receive time stamps in software + +The other three bits control which timestamps will be reported in a +generated control message.  If none of these bits are set or if none of +the set bits correspond to data that is available, then the control +message will not be generated: + +SOF_TIMESTAMPING_SOFTWARE:     report systime if available +SOF_TIMESTAMPING_SYS_HARDWARE: report hwtimetrans if available +SOF_TIMESTAMPING_RAW_HARDWARE: report hwtimeraw if available + +It is worth noting that timestamps may be collected for reasons other +than being requested by a particular socket with +SOF_TIMESTAMPING_[TR]X_(HARD|SOFT)WARE.  For example, most drivers that +can generate hardware receive timestamps ignore +SOF_TIMESTAMPING_RX_HARDWARE.  It is still a good idea to set that flag +in case future drivers pay attention. + +If timestamps are reported, they will appear in a control message with +cmsg_level==SOL_SOCKET, cmsg_type==SO_TIMESTAMPING, and a payload like +this:  struct scm_timestamping {  	struct timespec systime; @@ -85,7 +97,7 @@ Filled in if SOF_TIMESTAMPING_SYS_HARDWARE is set. Requires support  by the network device and will be empty without that support. -SIOCSHWTSTAMP: +SIOCSHWTSTAMP, SIOCGHWTSTAMP:  Hardware time stamping must also be initialized for each device driver  that is expected to do hardware time stamping. The parameter is defined in @@ -115,6 +127,10 @@ Only a processes with admin rights may change the configuration. User  space is responsible to ensure that multiple processes don't interfere  with each other and that the settings are reset. +Any process can read the actual configuration by passing this +structure to ioctl(SIOCGHWTSTAMP) in the same way.  However, this has +not been implemented in all drivers. +  /* possible values for hwtstamp_config->tx_type */  enum {  	/* @@ -157,7 +173,8 @@ DEVICE IMPLEMENTATION  A driver which supports hardware time stamping must support the  SIOCSHWTSTAMP ioctl and update the supplied struct hwtstamp_config with -the actual values as described in the section on SIOCSHWTSTAMP. +the actual values as described in the section on SIOCSHWTSTAMP.  It +should also support SIOCGHWTSTAMP.  Time stamps for received packets must be stored in the skb. To get a pointer  to the shared time stamp structure of the skb call skb_hwtstamps(). Then @@ -185,6 +202,9 @@ Time stamps for outgoing packets are to be generated as follows:    and not free the skb. A driver not supporting hardware time stamping doesn't    do that. A driver must never touch sk_buff::tstamp! It is used to store    software generated time stamps by the network subsystem. +- Driver should call skb_tx_timestamp() as close to passing sk_buff to hardware +  as possible. skb_tx_timestamp() provides a software time stamp if requested +  and hardware timestamping is not possible (SKBTX_IN_PROGRESS not set).  - As soon as the driver has sent the packet and/or obtained a    hardware time stamp for it, it passes the time stamp back by    calling skb_hwtstamp_tx() with the original skb, the raw @@ -195,6 +215,3 @@ Time stamps for outgoing packets are to be generated as follows:    this would occur at a later time in the processing pipeline than other    software time stamping and therefore could lead to unexpected deltas    between time stamps. -- If the driver did not set the SKBTX_IN_PROGRESS flag (see above), then -  dev_hard_start_xmit() checks whether software time stamping -  is wanted as fallback and potentially generates the time stamp.  | 
