Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d7e3ea7 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'syststamp-removal'



Willem de Bruijn says:

====================
net: remove deprecated syststamp

The network stack can generate two kinds of hardware timestamps:
- hwtstamp stores a hw timestamp in device-specific raw format
- syststamp convers the raw format to system time

The second is deprecated and only implemented by a single device
driver. The suggested alternative is to communicate hwtstamp +
directly expose the NIC PTP clock device through ptp_clock_info.
The remaining driver (octeon) does not expose such a standard
interface as of now. It does have its own PTP library that depends
on its own shared memory PTP clock interface.

This patchset
1. reverts the syststamp code in the one driver (octeon)
2. reverts an unnecessary zero initialization in another (vxge)
3. modifies PF_PACKET to use syststamp is != 0 (because always == 0)
4. modifies SCM_TIMESTAMPING in the same way

For backwards compatibility, the interfaces are not removed.
Applications can still request SOF_TIMESTAMPING_SYS_HARDWARE. The
response field in scm_timestamping also remains. As was the case
for hardware/drivers that did not implement the feature, the
setsockopt succeeds, but the response field is always zero.
====================

Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 13e9b997 4d276eb6
Loading
Loading
Loading
Loading
+6 −12
Original line number Original line Diff line number Diff line
@@ -1008,14 +1008,9 @@ hardware timestamps to be used. Note: you may need to enable the generation
of hardware timestamps with SIOCSHWTSTAMP (see related information from
of hardware timestamps with SIOCSHWTSTAMP (see related information from
Documentation/networking/timestamping.txt).
Documentation/networking/timestamping.txt).


PACKET_TIMESTAMP accepts the same integer bit field as
PACKET_TIMESTAMP accepts the same integer bit field as SO_TIMESTAMPING:
SO_TIMESTAMPING.  However, only the SOF_TIMESTAMPING_SYS_HARDWARE

and SOF_TIMESTAMPING_RAW_HARDWARE values are recognized by
    int req = SOF_TIMESTAMPING_RAW_HARDWARE;
PACKET_TIMESTAMP.  SOF_TIMESTAMPING_SYS_HARDWARE takes precedence over
SOF_TIMESTAMPING_RAW_HARDWARE if both bits are set.

    int req = 0;
    req |= SOF_TIMESTAMPING_SYS_HARDWARE;
    setsockopt(fd, SOL_PACKET, PACKET_TIMESTAMP, (void *) &req, sizeof(req))
    setsockopt(fd, SOL_PACKET, PACKET_TIMESTAMP, (void *) &req, sizeof(req))


For the mmap(2)ed ring buffers, such timestamps are stored in the
For the mmap(2)ed ring buffers, such timestamps are stored in the
@@ -1023,14 +1018,13 @@ tpacket{,2,3}_hdr structure's tp_sec and tp_{n,u}sec members. To determine
what kind of timestamp has been reported, the tp_status field is binary |'ed
what kind of timestamp has been reported, the tp_status field is binary |'ed
with the following possible bits ...
with the following possible bits ...


    TP_STATUS_TS_SYS_HARDWARE
    TP_STATUS_TS_RAW_HARDWARE
    TP_STATUS_TS_RAW_HARDWARE
    TP_STATUS_TS_SOFTWARE
    TP_STATUS_TS_SOFTWARE


... that are equivalent to its SOF_TIMESTAMPING_* counterparts. For the
... that are equivalent to its SOF_TIMESTAMPING_* counterparts. For the
RX_RING, if none of those 3 are set (i.e. PACKET_TIMESTAMP is not set),
RX_RING, if neither is set (i.e. PACKET_TIMESTAMP is not set), then a
then this means that a software fallback was invoked *within* PF_PACKET's
software fallback was invoked *within* PF_PACKET's processing code (less
processing code (less precise).
precise).


Getting timestamps for the TX_RING works as follows: i) fill the ring frames,
Getting timestamps for the TX_RING works as follows: i) fill the ring frames,
ii) call sendto() e.g. in blocking mode, iii) wait for status of relevant
ii) call sendto() e.g. in blocking mode, iii) wait for status of relevant
+2 −10
Original line number Original line Diff line number Diff line
@@ -88,15 +88,8 @@ hwtimeraw is the original hardware time stamp. Filled in if
SOF_TIMESTAMPING_RAW_HARDWARE is set. No assumptions about its
SOF_TIMESTAMPING_RAW_HARDWARE is set. No assumptions about its
relation to system time should be made.
relation to system time should be made.


hwtimetrans is the hardware time stamp transformed so that it
hwtimetrans is always zero. This field is deprecated. It used to hold
corresponds as good as possible to system time. This correlation is
hw timestamps converted to system time. Instead, expose the hardware
not perfect; as a consequence, sorting packets received via different
NICs by their hwtimetrans may differ from the order in which they were
received. hwtimetrans may be non-monotonic even for the same NIC.
Filled in if SOF_TIMESTAMPING_SYS_HARDWARE is set. Requires support
by the network device and will be empty without that support. This
field is DEPRECATED. Only one driver computes this value. New device
drivers must leave this zero. Instead, they can expose the hardware
clock device on the NIC directly as a HW PTP clock source, to allow
clock device on the NIC directly as a HW PTP clock source, to allow
time conversion in userspace and optionally synchronize system time
time conversion in userspace and optionally synchronize system time
with a userspace PTP stack such as linuxptp. For the PTP clock API,
with a userspace PTP stack such as linuxptp. For the PTP clock API,
@@ -191,7 +184,6 @@ struct skb_shared_hwtstamps {
	 * since arbitrary point in time
	 * since arbitrary point in time
	 */
	 */
	ktime_t	hwtstamp;
	ktime_t	hwtstamp;
	ktime_t	syststamp; /* hwtstamp transformed to system time base */
};
};


Time stamps for outgoing packets are to be generated as follows:
Time stamps for outgoing packets are to be generated as follows:
+1 −6
Original line number Original line Diff line number Diff line
@@ -76,7 +76,6 @@ static void usage(const char *error)
	       "  SOF_TIMESTAMPING_RX_HARDWARE - hardware time stamping of incoming packets\n"
	       "  SOF_TIMESTAMPING_RX_HARDWARE - hardware time stamping of incoming packets\n"
	       "  SOF_TIMESTAMPING_RX_SOFTWARE - software fallback for incoming packets\n"
	       "  SOF_TIMESTAMPING_RX_SOFTWARE - software fallback for incoming packets\n"
	       "  SOF_TIMESTAMPING_SOFTWARE - request reporting of software time stamps\n"
	       "  SOF_TIMESTAMPING_SOFTWARE - request reporting of software time stamps\n"
	       "  SOF_TIMESTAMPING_SYS_HARDWARE - request reporting of transformed HW time stamps\n"
	       "  SOF_TIMESTAMPING_RAW_HARDWARE - request reporting of raw HW time stamps\n"
	       "  SOF_TIMESTAMPING_RAW_HARDWARE - request reporting of raw HW time stamps\n"
	       "  SIOCGSTAMP - check last socket time stamp\n"
	       "  SIOCGSTAMP - check last socket time stamp\n"
	       "  SIOCGSTAMPNS - more accurate socket time stamp\n");
	       "  SIOCGSTAMPNS - more accurate socket time stamp\n");
@@ -202,9 +201,7 @@ static void printpacket(struct msghdr *msg, int res,
				       (long)stamp->tv_sec,
				       (long)stamp->tv_sec,
				       (long)stamp->tv_nsec);
				       (long)stamp->tv_nsec);
				stamp++;
				stamp++;
				printf("HW transformed %ld.%09ld ",
				/* skip deprecated HW transformed */
				       (long)stamp->tv_sec,
				       (long)stamp->tv_nsec);
				stamp++;
				stamp++;
				printf("HW raw %ld.%09ld",
				printf("HW raw %ld.%09ld",
				       (long)stamp->tv_sec,
				       (long)stamp->tv_sec,
@@ -361,8 +358,6 @@ int main(int argc, char **argv)
			so_timestamping_flags |= SOF_TIMESTAMPING_RX_SOFTWARE;
			so_timestamping_flags |= SOF_TIMESTAMPING_RX_SOFTWARE;
		else if (!strcasecmp(argv[i], "SOF_TIMESTAMPING_SOFTWARE"))
		else if (!strcasecmp(argv[i], "SOF_TIMESTAMPING_SOFTWARE"))
			so_timestamping_flags |= SOF_TIMESTAMPING_SOFTWARE;
			so_timestamping_flags |= SOF_TIMESTAMPING_SOFTWARE;
		else if (!strcasecmp(argv[i], "SOF_TIMESTAMPING_SYS_HARDWARE"))
			so_timestamping_flags |= SOF_TIMESTAMPING_SYS_HARDWARE;
		else if (!strcasecmp(argv[i], "SOF_TIMESTAMPING_RAW_HARDWARE"))
		else if (!strcasecmp(argv[i], "SOF_TIMESTAMPING_RAW_HARDWARE"))
			so_timestamping_flags |= SOF_TIMESTAMPING_RAW_HARDWARE;
			so_timestamping_flags |= SOF_TIMESTAMPING_RAW_HARDWARE;
		else
		else
+0 −1
Original line number Original line Diff line number Diff line
@@ -503,7 +503,6 @@ vxge_rx_1b_compl(struct __vxge_hw_ring *ringh, void *dtr,


			skb_hwts = skb_hwtstamps(skb);
			skb_hwts = skb_hwtstamps(skb);
			skb_hwts->hwtstamp = ns_to_ktime(ns);
			skb_hwts->hwtstamp = ns_to_ktime(ns);
			skb_hwts->syststamp.tv64 = 0;
		}
		}


		/* rth_hash_type and rth_it_hit are non-zero regardless of
		/* rth_hash_type and rth_it_hit are non-zero regardless of
+1 −24
Original line number Original line Diff line number Diff line
@@ -247,28 +247,6 @@ static void octeon_mgmt_rx_fill_ring(struct net_device *netdev)
	}
	}
}
}


static ktime_t ptp_to_ktime(u64 ptptime)
{
	ktime_t ktimebase;
	u64 ptpbase;
	unsigned long flags;

	local_irq_save(flags);
	/* Fill the icache with the code */
	ktime_get_real();
	/* Flush all pending operations */
	mb();
	/* Read the time and PTP clock as close together as
	 * possible. It is important that this sequence take the same
	 * amount of time to reduce jitter
	 */
	ktimebase = ktime_get_real();
	ptpbase = cvmx_read_csr(CVMX_MIO_PTP_CLOCK_HI);
	local_irq_restore(flags);

	return ktime_sub_ns(ktimebase, ptpbase - ptptime);
}

static void octeon_mgmt_clean_tx_buffers(struct octeon_mgmt *p)
static void octeon_mgmt_clean_tx_buffers(struct octeon_mgmt *p)
{
{
	union cvmx_mixx_orcnt mix_orcnt;
	union cvmx_mixx_orcnt mix_orcnt;
@@ -312,12 +290,12 @@ static void octeon_mgmt_clean_tx_buffers(struct octeon_mgmt *p)
		/* Read the hardware TX timestamp if one was recorded */
		/* Read the hardware TX timestamp if one was recorded */
		if (unlikely(re.s.tstamp)) {
		if (unlikely(re.s.tstamp)) {
			struct skb_shared_hwtstamps ts;
			struct skb_shared_hwtstamps ts;
			memset(&ts, 0, sizeof(ts));
			/* Read the timestamp */
			/* Read the timestamp */
			u64 ns = cvmx_read_csr(CVMX_MIXX_TSTAMP(p->port));
			u64 ns = cvmx_read_csr(CVMX_MIXX_TSTAMP(p->port));
			/* Remove the timestamp from the FIFO */
			/* Remove the timestamp from the FIFO */
			cvmx_write_csr(CVMX_MIXX_TSCTL(p->port), 0);
			cvmx_write_csr(CVMX_MIXX_TSCTL(p->port), 0);
			/* Tell the kernel about the timestamp */
			/* Tell the kernel about the timestamp */
			ts.syststamp = ptp_to_ktime(ns);
			ts.hwtstamp = ns_to_ktime(ns);
			ts.hwtstamp = ns_to_ktime(ns);
			skb_tstamp_tx(skb, &ts);
			skb_tstamp_tx(skb, &ts);
		}
		}
@@ -429,7 +407,6 @@ good:
			struct skb_shared_hwtstamps *ts;
			struct skb_shared_hwtstamps *ts;
			ts = skb_hwtstamps(skb);
			ts = skb_hwtstamps(skb);
			ts->hwtstamp = ns_to_ktime(ns);
			ts->hwtstamp = ns_to_ktime(ns);
			ts->syststamp = ptp_to_ktime(ns);
			__skb_pull(skb, 8);
			__skb_pull(skb, 8);
		}
		}
		skb->protocol = eth_type_trans(skb, netdev);
		skb->protocol = eth_type_trans(skb, netdev);
Loading