[PATCH 2/3] xdp: Add Rx GSO hint

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is an implementation of functionality that allows drivers to
expose GSO information to XDP.
This information includes:
  - GSO info, including GSO type and size in skb_shared_info

Signed-off-by: Muyang Tian <tianmuyang@xxxxxxxxxx>
---
 Documentation/netlink/specs/netdev.yaml      |  4 ++++
 Documentation/networking/xdp-rx-metadata.rst |  3 +++
 include/net/xdp.h                            | 12 ++++++++++++
 include/uapi/linux/netdev.h                  |  3 +++
 net/core/xdp.c                               | 18 ++++++++++++++++++
 tools/include/uapi/linux/netdev.h            |  3 +++
 6 files changed, 43 insertions(+)

diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml
index e6045b447fc1..5beee7c8e7cf 100644
--- a/Documentation/netlink/specs/netdev.yaml
+++ b/Documentation/netlink/specs/netdev.yaml
@@ -62,6 +62,10 @@ definitions:
         name: csum
         doc:
           Device is capable of exposing receive packet checksum via bpf_xdp_metadata_rx_csum().
+      -
+        name: gso
+        doc:
+          Device is capable of exposing receive packet GSO via bpf_xdp_metadata_rx_gso().
   -
     type: flags
     name: xsk-flags
diff --git a/Documentation/networking/xdp-rx-metadata.rst b/Documentation/networking/xdp-rx-metadata.rst
index 6cf273b33ee6..618b9ba606e5 100644
--- a/Documentation/networking/xdp-rx-metadata.rst
+++ b/Documentation/networking/xdp-rx-metadata.rst
@@ -31,6 +31,9 @@ metadata is supported, this set will grow:
 .. kernel-doc:: net/core/xdp.c
    :identifiers: bpf_xdp_metadata_rx_csum
 
+.. kernel-doc:: net/core/xdp.c
+   :identifiers: bpf_xdp_metadata_rx_gso
+
 An XDP program can use these kfuncs to read the metadata into stack
 variables for its own consumption. Or, to pass the metadata on to other
 consumers, an XDP program can store it into the metadata area carried
diff --git a/include/net/xdp.h b/include/net/xdp.h
index 7886658975c4..2e08f54106d3 100644
--- a/include/net/xdp.h
+++ b/include/net/xdp.h
@@ -412,6 +412,10 @@ void xdp_attachment_setup(struct xdp_attachment_info *info,
 			   NETDEV_XDP_RX_METADATA_CSUM, \
 			   bpf_xdp_metadata_rx_csum, \
 			   xmo_rx_csum) \
+	XDP_METADATA_KFUNC(XDP_METADATA_KFUNC_RX_GSO, \
+			   NETDEV_XDP_RX_METADATA_GSO, \
+			   bpf_xdp_metadata_rx_gso, \
+			   xmo_rx_gso) \
 
 enum xdp_rx_metadata {
 #define XDP_METADATA_KFUNC(name, _, __, ___) name,
@@ -501,6 +505,13 @@ union xdp_csum_info {
 	};
 };
 
+struct xdp_gso_info {
+	/* GSO info in skb_shared_info */
+
+	unsigned int	gso_type;
+	unsigned short	gso_size;
+};
+
 struct xdp_metadata_ops {
 	int	(*xmo_rx_timestamp)(const struct xdp_md *ctx, u64 *timestamp);
 	int	(*xmo_rx_hash)(const struct xdp_md *ctx, u32 *hash,
@@ -509,6 +520,7 @@ struct xdp_metadata_ops {
 				   u16 *vlan_tci);
 	int (*xmo_rx_csum)(const struct xdp_md *ctx, enum xdp_csum_status *csum_status,
 				   union xdp_csum_info *csum_info);
+	int	(*xmo_rx_gso)(const struct xdp_md *ctx, struct xdp_gso_info *gso_info);
 };
 
 #ifdef CONFIG_NET
diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h
index a969b25529a3..1e711d6a4c6b 100644
--- a/include/uapi/linux/netdev.h
+++ b/include/uapi/linux/netdev.h
@@ -48,12 +48,15 @@ enum netdev_xdp_act {
  *   packet VLAN tag via bpf_xdp_metadata_rx_vlan_tag().
  * @NETDEV_XDP_RX_METADATA_CSUM: Device is capable of exposing receive packet
  *   checksum via bpf_xdp_metadata_rx_csum().
+ * @NETDEV_XDP_RX_METADATA_GSO: Device is capable of exposing receive packet
+ *   GSO via bpf_xdp_metadata_rx_gso().
  */
 enum netdev_xdp_rx_metadata {
 	NETDEV_XDP_RX_METADATA_TIMESTAMP = 1,
 	NETDEV_XDP_RX_METADATA_HASH = 2,
 	NETDEV_XDP_RX_METADATA_VLAN_TAG = 4,
 	NETDEV_XDP_RX_METADATA_CSUM = 8,
+	NETDEV_XDP_RX_METADATA_GSO = 16,
 };
 
 /**
diff --git a/net/core/xdp.c b/net/core/xdp.c
index 583e00d3580a..983440e2b3bf 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -789,6 +789,24 @@ __bpf_kfunc int bpf_xdp_metadata_rx_csum(const struct xdp_md *ctx,
 	return -EOPNOTSUPP;
 }
 
+/**
+ * bpf_xdp_metadata_rx_gso - Read XDP frame GSO info.
+ * @ctx: XDP context pointer.
+ * @gso_info: Destination pointer for GSO info.
+ *
+ * Info (@gso_info) includes GSO type and size from skb_shared_info.
+ *
+ * Return:
+ * * Returns 0 on success or ``-errno`` on error.
+ * * ``-EOPNOTSUPP`` : means device driver doesn't implement kfunc
+ * * ``-ENODATA``    : means no GSO info available for this frame
+ */
+__bpf_kfunc int bpf_xdp_metadata_rx_gso(const struct xdp_md *ctx,
+					 struct xdp_gso_info *gso_info)
+{
+	return -EOPNOTSUPP;
+}
+
 __bpf_kfunc_end_defs();
 
 BTF_KFUNCS_START(xdp_metadata_kfunc_ids)
diff --git a/tools/include/uapi/linux/netdev.h b/tools/include/uapi/linux/netdev.h
index a969b25529a3..1e711d6a4c6b 100644
--- a/tools/include/uapi/linux/netdev.h
+++ b/tools/include/uapi/linux/netdev.h
@@ -48,12 +48,15 @@ enum netdev_xdp_act {
  *   packet VLAN tag via bpf_xdp_metadata_rx_vlan_tag().
  * @NETDEV_XDP_RX_METADATA_CSUM: Device is capable of exposing receive packet
  *   checksum via bpf_xdp_metadata_rx_csum().
+ * @NETDEV_XDP_RX_METADATA_GSO: Device is capable of exposing receive packet
+ *   GSO via bpf_xdp_metadata_rx_gso().
  */
 enum netdev_xdp_rx_metadata {
 	NETDEV_XDP_RX_METADATA_TIMESTAMP = 1,
 	NETDEV_XDP_RX_METADATA_HASH = 2,
 	NETDEV_XDP_RX_METADATA_VLAN_TAG = 4,
 	NETDEV_XDP_RX_METADATA_CSUM = 8,
+	NETDEV_XDP_RX_METADATA_GSO = 16,
 };
 
 /**
-- 
2.41.0





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux