History

xsk: Add TX timestamp and TX checksum offload support

This change actually defines the (initial) metadata layout that should be used by AF_XDP userspace (xsk_tx_metadata). The first field is flags which requests appropriate offloads, followed by the offload-specific fields. The supported per-device offloads are exported via netlink (new xsk-flags). The offloads themselves are still implemented in a bit of a framework-y fashion that's left from my initial kfunc attempt. I'm introducing new xsk_tx_metadata_ops which drivers are supposed to implement. The drivers are also supposed to call xsk_tx_metadata_request/xsk_tx_metadata_complete in the right places. Since xsk_tx_metadata_{request,_complete} are static inline, we don't incur any extra overhead doing indirect calls. The benefit of this scheme is as follows: - keeps all metadata layout parsing away from driver code - makes it easy to grep and see which drivers implement what - don't need any extra flags to maintain to keep track of what offloads are implemented; if the callback is implemented - the offload is supported (used by netlink reporting code) Two offloads are defined right now: 1. XDP_TXMD_FLAGS_CHECKSUM: skb-style csum_start+csum_offset 2. XDP_TXMD_FLAGS_TIMESTAMP: writes TX timestamp back into metadata area upon completion (tx_timestamp field) XDP_TXMD_FLAGS_TIMESTAMP is also implemented for XDP_COPY mode: it writes SW timestamp from the skb destructor (note I'm reusing hwtstamps to pass metadata pointer). The struct is forward-compatible and can be extended in the future by appending more fields.

Stanislav Fomichev committed 2 years ago

Commit 48eb03d1 parent 341ac9815 files · +348 −9Browse files

Showing the changes to tools/include/uapi/linux/netdev.h (1 of 15 files). Show all

Unified · Split

tools/include/uapi/linux/netdev.h+16−0
@@ -53,12 +53,28 @@ enum netdev_xdp_rx_metadata { · 52 unmodified lines
5353 NETDEV_XDP_RX_METADATA_MASK = 3,
5454 };
5555
56+/**
57+ * enum netdev_xsk_flags
58+ * @NETDEV_XSK_FLAGS_TX_TIMESTAMP: HW timestamping egress packets is supported
59+ * by the driver.
60+ * @NETDEV_XSK_FLAGS_TX_CHECKSUM: L3 checksum HW offload is supported by the
61+ * driver.
62+ */
63+enum netdev_xsk_flags {
64+ NETDEV_XSK_FLAGS_TX_TIMESTAMP = 1,
65+ NETDEV_XSK_FLAGS_TX_CHECKSUM = 2,
66+
67+ /* private: */
68+ NETDEV_XSK_FLAGS_MASK = 3,
69+};
70+
5671 enum {
5772 NETDEV_A_DEV_IFINDEX = 1,
5873 NETDEV_A_DEV_PAD,
5974 NETDEV_A_DEV_XDP_FEATURES,
6075 NETDEV_A_DEV_XDP_ZC_MAX_SEGS,
6176 NETDEV_A_DEV_XDP_RX_METADATA_FEATURES,
77+ NETDEV_A_DEV_XSK_FEATURES,
6278
6379 __NETDEV_A_DEV_MAX,
6480 NETDEV_A_DEV_MAX = (__NETDEV_A_DEV_MAX - 1)