linux/include/uapi/linux/net_tstamp.h
<<
>>
Prefs
   1/*
   2 * Userspace API for hardware time stamping of network packets
   3 *
   4 * Copyright (C) 2008,2009 Intel Corporation
   5 * Author: Patrick Ohly <patrick.ohly@intel.com>
   6 *
   7 */
   8
   9#ifndef _NET_TIMESTAMPING_H
  10#define _NET_TIMESTAMPING_H
  11
  12#include <linux/socket.h>   /* for SO_TIMESTAMPING */
  13
  14/* SO_TIMESTAMPING gets an integer bit field comprised of these values */
  15enum {
  16        SOF_TIMESTAMPING_TX_HARDWARE = (1<<0),
  17        SOF_TIMESTAMPING_TX_SOFTWARE = (1<<1),
  18        SOF_TIMESTAMPING_RX_HARDWARE = (1<<2),
  19        SOF_TIMESTAMPING_RX_SOFTWARE = (1<<3),
  20        SOF_TIMESTAMPING_SOFTWARE = (1<<4),
  21        SOF_TIMESTAMPING_SYS_HARDWARE = (1<<5),
  22        SOF_TIMESTAMPING_RAW_HARDWARE = (1<<6),
  23        SOF_TIMESTAMPING_OPT_ID = (1<<7),
  24        SOF_TIMESTAMPING_TX_SCHED = (1<<8),
  25        SOF_TIMESTAMPING_TX_ACK = (1<<9),
  26        SOF_TIMESTAMPING_OPT_CMSG = (1<<10),
  27        SOF_TIMESTAMPING_OPT_TSONLY = (1<<11),
  28
  29        SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_OPT_TSONLY,
  30        SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST - 1) |
  31                                 SOF_TIMESTAMPING_LAST
  32};
  33
  34/*
  35 * SO_TIMESTAMPING flags are either for recording a packet timestamp or for
  36 * reporting the timestamp to user space.
  37 * Recording flags can be set both via socket options and control messages.
  38 */
  39#define SOF_TIMESTAMPING_TX_RECORD_MASK (SOF_TIMESTAMPING_TX_HARDWARE | \
  40                                         SOF_TIMESTAMPING_TX_SOFTWARE | \
  41                                         SOF_TIMESTAMPING_TX_SCHED | \
  42                                         SOF_TIMESTAMPING_TX_ACK)
  43
  44/**
  45 * struct hwtstamp_config - %SIOCGHWTSTAMP and %SIOCSHWTSTAMP parameter
  46 *
  47 * @flags:      no flags defined right now, must be zero for %SIOCSHWTSTAMP
  48 * @tx_type:    one of HWTSTAMP_TX_*
  49 * @rx_filter:  one of HWTSTAMP_FILTER_*
  50 *
  51 * %SIOCGHWTSTAMP and %SIOCSHWTSTAMP expect a &struct ifreq with a
  52 * ifr_data pointer to this structure.  For %SIOCSHWTSTAMP, if the
  53 * driver or hardware does not support the requested @rx_filter value,
  54 * the driver may use a more general filter mode.  In this case
  55 * @rx_filter will indicate the actual mode on return.
  56 */
  57struct hwtstamp_config {
  58        int flags;
  59        int tx_type;
  60        int rx_filter;
  61};
  62
  63/* possible values for hwtstamp_config->tx_type */
  64enum hwtstamp_tx_types {
  65        /*
  66         * No outgoing packet will need hardware time stamping;
  67         * should a packet arrive which asks for it, no hardware
  68         * time stamping will be done.
  69         */
  70        HWTSTAMP_TX_OFF,
  71
  72        /*
  73         * Enables hardware time stamping for outgoing packets;
  74         * the sender of the packet decides which are to be
  75         * time stamped by setting %SOF_TIMESTAMPING_TX_SOFTWARE
  76         * before sending the packet.
  77         */
  78        HWTSTAMP_TX_ON,
  79
  80        /*
  81         * Enables time stamping for outgoing packets just as
  82         * HWTSTAMP_TX_ON does, but also enables time stamp insertion
  83         * directly into Sync packets. In this case, transmitted Sync
  84         * packets will not received a time stamp via the socket error
  85         * queue.
  86         */
  87        HWTSTAMP_TX_ONESTEP_SYNC,
  88};
  89
  90/* possible values for hwtstamp_config->rx_filter */
  91enum hwtstamp_rx_filters {
  92        /* time stamp no incoming packet at all */
  93        HWTSTAMP_FILTER_NONE,
  94
  95        /* time stamp any incoming packet */
  96        HWTSTAMP_FILTER_ALL,
  97
  98        /* return value: time stamp all packets requested plus some others */
  99        HWTSTAMP_FILTER_SOME,
 100
 101        /* PTP v1, UDP, any kind of event packet */
 102        HWTSTAMP_FILTER_PTP_V1_L4_EVENT,
 103        /* PTP v1, UDP, Sync packet */
 104        HWTSTAMP_FILTER_PTP_V1_L4_SYNC,
 105        /* PTP v1, UDP, Delay_req packet */
 106        HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ,
 107        /* PTP v2, UDP, any kind of event packet */
 108        HWTSTAMP_FILTER_PTP_V2_L4_EVENT,
 109        /* PTP v2, UDP, Sync packet */
 110        HWTSTAMP_FILTER_PTP_V2_L4_SYNC,
 111        /* PTP v2, UDP, Delay_req packet */
 112        HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ,
 113
 114        /* 802.AS1, Ethernet, any kind of event packet */
 115        HWTSTAMP_FILTER_PTP_V2_L2_EVENT,
 116        /* 802.AS1, Ethernet, Sync packet */
 117        HWTSTAMP_FILTER_PTP_V2_L2_SYNC,
 118        /* 802.AS1, Ethernet, Delay_req packet */
 119        HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ,
 120
 121        /* PTP v2/802.AS1, any layer, any kind of event packet */
 122        HWTSTAMP_FILTER_PTP_V2_EVENT,
 123        /* PTP v2/802.AS1, any layer, Sync packet */
 124        HWTSTAMP_FILTER_PTP_V2_SYNC,
 125        /* PTP v2/802.AS1, any layer, Delay_req packet */
 126        HWTSTAMP_FILTER_PTP_V2_DELAY_REQ,
 127};
 128
 129#endif /* _NET_TIMESTAMPING_H */
 130