[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <166256557140.1434226.13138556693050092410.stgit@firesoul>
Date: Wed, 07 Sep 2022 17:46:11 +0200
From: Jesper Dangaard Brouer <brouer@...hat.com>
To: bpf@...r.kernel.org
Cc: Jesper Dangaard Brouer <brouer@...hat.com>, netdev@...r.kernel.org,
xdp-hints@...-project.net, larysa.zaremba@...el.com,
memxor@...il.com, Lorenzo Bianconi <lorenzo@...nel.org>,
mtahhan@...hat.com,
Alexei Starovoitov <alexei.starovoitov@...il.com>,
Daniel Borkmann <borkmann@...earbox.net>,
Andrii Nakryiko <andrii.nakryiko@...il.com>,
dave@...cker.co.uk, Magnus Karlsson <magnus.karlsson@...el.com>,
bjorn@...nel.org
Subject: [PATCH RFCv2 bpf-next 14/18] i40e: Add xdp_hints_union
The union named "xdp_hints_union" must contain all the xdp_hints_*
struct's available in this driver. This is used when decoding the
modules BTF to identify the available XDP-hints struct's. As metadata
grows backwards padding are needed for proper alignment. This alignment
is verified by compile time checks via BUILD_BUG_ON().
Signed-off-by: Jesper Dangaard Brouer <brouer@...hat.com>
---
drivers/net/ethernet/intel/i40e/i40e_txrx.c | 31 +++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index d945ac122d4c..e21f3ff4c811 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -1953,6 +1953,36 @@ struct xdp_hints_i40e_timestamp {
struct xdp_hints_i40e base;
};
+/* xdp_hints_union defines xdp_hints_* structs available in this driver.
+ * As metadata grows backwards structure are padded to align.
+ */
+union xdp_hints_union {
+ struct xdp_hints_i40e_timestamp i40e_ts;
+ struct {
+ u64 pad1_ts;
+ struct xdp_hints_i40e i40e;
+ };
+ struct {
+ u64 pad2_ts;
+ u32 pad3_i40e;
+ struct xdp_hints_common common;
+ };
+}; // __aligned(4) __attribute__((packed));
+
+union xdp_hints_union define_union;
+
+#define OFFSET1 offsetof(union xdp_hints_union, common)
+#define OFFSET2 offsetof(union xdp_hints_union, i40e.common)
+#define OFFSET3 offsetof(union xdp_hints_union, i40e_ts.base.common)
+
+static void xdp_hints_compile_check(void)
+{
+ union xdp_hints_union my_union = {};
+
+ BUILD_BUG_ON(OFFSET1 != OFFSET2);
+ BUILD_BUG_ON(OFFSET1 != OFFSET3);
+}
+
/* Extending xdp_hints_flags */
enum xdp_hints_flags_driver {
HINT_FLAG_RX_TIMESTAMP = BIT(16),
@@ -1968,6 +1998,7 @@ static inline u32 i40e_rx_checksum_xdp(struct i40e_vsi *vsi, u64 qword1,
{
struct i40e_rx_checksum_ret ret;
+ xdp_hints_compile_check();
ret = _i40e_rx_checksum(vsi, qword1, ptype);
return xdp_hints_set_rx_csum(&xdp_hints->common, ret.ip_summed, ret.csum_level);
}
Powered by blists - more mailing lists