From: Muyang Tian <tianmuyang@huawei.com>
To: <bpf@vger.kernel.org>
Cc: "David S . Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Donald Hunter" <donald.hunter@gmail.com>,
"Björn Töpel" <bjorn@kernel.org>,
"Magnus Karlsson" <magnus.karlsson@intel.com>,
"Maciej Fijalkowski" <maciej.fijalkowski@intel.com>,
"Jonathan Lemon" <jonathan.lemon@gmail.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
"John Fastabend" <john.fastabend@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, yanan@huawei.com,
xiesongyang@huawei.com, wuchangye@huawei.com,
liuxin350@huawei.com, zhangmingyi5@huawei.com,
liwei883@huawei.com, tianmuyang@huawei.com
Subject: [PATCH bpf-next v2 3/3] xsk: Add Tx GSO type and size offload support
Date: Fri, 18 Oct 2024 17:15:02 +0800 [thread overview]
Message-ID: <20241018091502.411513-4-tianmuyang@huawei.com> (raw)
In-Reply-To: <20241018091502.411513-1-tianmuyang@huawei.com>
This change extends the xsk_tx_metadata struct with
GSO type and size fields.
A new offload XDP_TX_METADATA_GSO is defined, which
offloads gso_type and gso_size in skb_shared_info to XDP.
Signed-off-by: Muyang Tian <tianmuyang@huawei.com>
---
Documentation/netlink/specs/netdev.yaml | 4 ++++
include/net/xdp_sock.h | 8 ++++++++
include/net/xdp_sock_drv.h | 1 +
include/uapi/linux/if_xdp.h | 11 +++++++++++
include/uapi/linux/netdev.h | 2 ++
net/xdp/xsk.c | 5 +++++
tools/include/uapi/linux/if_xdp.h | 11 +++++++++++
tools/include/uapi/linux/netdev.h | 2 ++
8 files changed, 44 insertions(+)
diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml
index 5beee7c8e7cf..f4aa04eba54c 100644
--- a/Documentation/netlink/specs/netdev.yaml
+++ b/Documentation/netlink/specs/netdev.yaml
@@ -78,6 +78,10 @@ definitions:
name: tx-checksum
doc:
L3 checksum HW offload is supported by the driver.
+ -
+ name: tx-gso
+ doc:
+ GSO type and size is supported by the driver.
-
name: queue-type
type: enum
diff --git a/include/net/xdp_sock.h b/include/net/xdp_sock.h
index bfe625b55d55..e5acb27c3e07 100644
--- a/include/net/xdp_sock.h
+++ b/include/net/xdp_sock.h
@@ -110,11 +110,14 @@ struct xdp_sock {
* indicates position where checksumming should start.
* csum_offset indicates position where checksum should be stored.
*
+ * void (*tmo_request_gso)(u32 gso_type, u16 gso_size, void *priv)
+ * Called when AF_XDP frame requested GSO info.
*/
struct xsk_tx_metadata_ops {
void (*tmo_request_timestamp)(void *priv);
u64 (*tmo_fill_timestamp)(void *priv);
void (*tmo_request_checksum)(u16 csum_start, u16 csum_offset, void *priv);
+ void (*tmo_request_gso)(u32 gso_type, u16 gso_size, void *priv);
};
#ifdef CONFIG_XDP_SOCKETS
@@ -170,6 +173,11 @@ static inline void xsk_tx_metadata_request(const struct xsk_tx_metadata *meta,
if (meta->flags & XDP_TXMD_FLAGS_CHECKSUM)
ops->tmo_request_checksum(meta->request.csum_start,
meta->request.csum_offset, priv);
+
+ if (ops->tmo_request_gso)
+ if (meta->flags & XDP_TXMD_FLAGS_GSO)
+ ops->tmo_request_gso(meta->request.gso_type,
+ meta->request.gso_size, priv);
}
/**
diff --git a/include/net/xdp_sock_drv.h b/include/net/xdp_sock_drv.h
index 0a5dca2b2b3f..b192dab2b835 100644
--- a/include/net/xdp_sock_drv.h
+++ b/include/net/xdp_sock_drv.h
@@ -198,6 +198,7 @@ static inline void *xsk_buff_raw_get_data(struct xsk_buff_pool *pool, u64 addr)
#define XDP_TXMD_FLAGS_VALID ( \
XDP_TXMD_FLAGS_TIMESTAMP | \
XDP_TXMD_FLAGS_CHECKSUM | \
+ XDP_TXMD_FLAGS_GSO | \
0)
static inline bool xsk_buff_valid_tx_metadata(struct xsk_tx_metadata *meta)
diff --git a/include/uapi/linux/if_xdp.h b/include/uapi/linux/if_xdp.h
index 42ec5ddaab8d..c3ea368bf613 100644
--- a/include/uapi/linux/if_xdp.h
+++ b/include/uapi/linux/if_xdp.h
@@ -127,6 +127,11 @@ struct xdp_options {
*/
#define XDP_TXMD_FLAGS_CHECKSUM (1 << 1)
+/* Request transmit GSO info. GSO type and size are communicated via
+ * csum_start and csum_offset fields of struct xsk_tx_metadata.
+ */
+#define XDP_TXMD_FLAGS_GSO (1 << 2)
+
/* AF_XDP offloads request. 'request' union member is consumed by the driver
* when the packet is being transmitted. 'completion' union member is
* filled by the driver when the transmit completion arrives.
@@ -142,6 +147,12 @@ struct xsk_tx_metadata {
__u16 csum_start;
/* Offset from csum_start where checksum should be stored. */
__u16 csum_offset;
+
+ /* XDP_TXMD_FLAGS_GSO */
+ /* Identical to skb_shared_info.gso_type*/
+ __u32 gso_type;
+ /* Identical to skb_shared_info.gso_size*/
+ __u16 gso_size;
} request;
struct {
diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h
index 1e711d6a4c6b..bd175afb3c6b 100644
--- a/include/uapi/linux/netdev.h
+++ b/include/uapi/linux/netdev.h
@@ -65,10 +65,12 @@ enum netdev_xdp_rx_metadata {
* by the driver.
* @NETDEV_XSK_FLAGS_TX_CHECKSUM: L3 checksum HW offload is supported by the
* driver.
+ * @NETDEV_XSK_FLAGS_TX_GSO: GSO type and size is supported by the driver.
*/
enum netdev_xsk_flags {
NETDEV_XSK_FLAGS_TX_TIMESTAMP = 1,
NETDEV_XSK_FLAGS_TX_CHECKSUM = 2,
+ NETDEV_XSK_FLAGS_TX_GSO = 4,
};
enum netdev_queue_type {
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 1140b2a120ca..5a19edfce16c 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -745,6 +745,11 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
goto free_err;
}
}
+
+ if (meta->flags & XDP_TXMD_FLAGS_GSO) {
+ skb_shinfo(skb)->gso_type = meta->request.gso_type;
+ skb_shinfo(skb)->gso_size = meta->request.gso_size;
+ }
}
}
diff --git a/tools/include/uapi/linux/if_xdp.h b/tools/include/uapi/linux/if_xdp.h
index 2f082b01ff22..5714d0be8c53 100644
--- a/tools/include/uapi/linux/if_xdp.h
+++ b/tools/include/uapi/linux/if_xdp.h
@@ -127,6 +127,11 @@ struct xdp_options {
*/
#define XDP_TXMD_FLAGS_CHECKSUM (1 << 1)
+/* Request transmit GSO info. GSO type and size are communicated via
+ * csum_start and csum_offset fields of struct xsk_tx_metadata.
+ */
+#define XDP_TXMD_FLAGS_GSO (1 << 2)
+
/* AF_XDP offloads request. 'request' union member is consumed by the driver
* when the packet is being transmitted. 'completion' union member is
* filled by the driver when the transmit completion arrives.
@@ -142,6 +147,12 @@ struct xsk_tx_metadata {
__u16 csum_start;
/* Offset from csum_start where checksum should be stored. */
__u16 csum_offset;
+
+ /* XDP_TXMD_FLAGS_GSO */
+ /* Identical to skb_shared_info.gso_type*/
+ __u32 gso_type;
+ /* Identical to skb_shared_info.gso_size*/
+ __u16 gso_size;
} request;
struct {
diff --git a/tools/include/uapi/linux/netdev.h b/tools/include/uapi/linux/netdev.h
index 1e711d6a4c6b..bd175afb3c6b 100644
--- a/tools/include/uapi/linux/netdev.h
+++ b/tools/include/uapi/linux/netdev.h
@@ -65,10 +65,12 @@ enum netdev_xdp_rx_metadata {
* by the driver.
* @NETDEV_XSK_FLAGS_TX_CHECKSUM: L3 checksum HW offload is supported by the
* driver.
+ * @NETDEV_XSK_FLAGS_TX_GSO: GSO type and size is supported by the driver.
*/
enum netdev_xsk_flags {
NETDEV_XSK_FLAGS_TX_TIMESTAMP = 1,
NETDEV_XSK_FLAGS_TX_CHECKSUM = 2,
+ NETDEV_XSK_FLAGS_TX_GSO = 4,
};
enum netdev_queue_type {
--
2.41.0
next prev parent reply other threads:[~2024-10-18 9:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 9:14 [PATCH bpf-next v2 0/3] XDP metadata: Rx checksum/GSO hint; Tx GSO offload Muyang Tian
2024-10-18 9:15 ` [PATCH bpf-next v2 1/3] xdp: Add Rx checksum hint Muyang Tian
2024-10-18 9:15 ` [PATCH bpf-next v2 2/3] xdp: Add Rx GSO hint Muyang Tian
2024-10-18 9:15 ` Muyang Tian [this message]
2024-10-18 16:39 ` [PATCH bpf-next v2 0/3] XDP metadata: Rx checksum/GSO hint; Tx GSO offload Stanislav Fomichev
2024-10-20 20:51 ` Willem de Bruijn
2024-10-21 12:04 ` Magnus Karlsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241018091502.411513-4-tianmuyang@huawei.com \
--to=tianmuyang@huawei.com \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=jonathan.lemon@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuxin350@huawei.com \
--cc=liwei883@huawei.com \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=wuchangye@huawei.com \
--cc=xiesongyang@huawei.com \
--cc=yanan@huawei.com \
--cc=zhangmingyi5@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox