diff mbox series

[bpf-next,v5,13/21] ice: Implement checksum hint

Message ID 20230811161509.19722-14-larysa.zaremba@intel.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series XDP metadata via kfuncs for ice | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-4 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-5 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-6 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-20 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-21 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-23 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-24 success Logs for test_progs_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-25 success Logs for test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-27 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-29 success Logs for veristat
bpf/vmtest-bpf-next-VM_Test-7 success Logs for test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-11 fail Logs for test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-13 fail Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-14 fail Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-15 fail Logs for test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-17 fail Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-18 fail Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-19 success Logs for test_progs_no_alu32_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-22 success Logs for test_progs_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-16 fail Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-26 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-12 fail Logs for test_progs on s390x with gcc
netdev/series_format fail Series longer than 15 patches (and no cover letter)
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1330 this patch: 1330
netdev/cc_maintainers warning 7 maintainers not CCed: hawk@kernel.org jesse.brandeburg@intel.com intel-wired-lan@lists.osuosl.org davem@davemloft.net anthony.l.nguyen@intel.com pabeni@redhat.com edumazet@google.com
netdev/build_clang success Errors and warnings before: 1353 this patch: 1353
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1353 this patch: 1353
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 34 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR fail PR summary
bpf/vmtest-bpf-next-VM_Test-8 success Logs for test_maps on s390x with gcc

Commit Message

Larysa Zaremba Aug. 11, 2023, 4:15 p.m. UTC
Implement .xmo_rx_csum callback to allow XDP code to determine,
whether HW has validated any checksums.

Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)

Comments

Alexei Starovoitov Aug. 17, 2023, 9:58 p.m. UTC | #1
On Fri, Aug 11, 2023 at 06:15:01PM +0200, Larysa Zaremba wrote:
> Implement .xmo_rx_csum callback to allow XDP code to determine,
> whether HW has validated any checksums.
> 
> Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
> ---
>  drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 26 +++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> index 6ae57a98a4d8..f11a245705bc 100644
> --- a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> @@ -660,8 +660,34 @@ static int ice_xdp_rx_vlan_tag(const struct xdp_md *ctx, u16 *vlan_tci,
>  	return 0;
>  }
>  
> +/**
> + * ice_xdp_rx_csum - RX checksum XDP hint handler
> + * @ctx: XDP buff pointer
> + * @csum_status: status destination address
> + * @csum: not used
> + */
> +static int ice_xdp_rx_csum(const struct xdp_md *ctx,
> +			   enum xdp_csum_status *csum_status, __wsum *csum)
> +{
> +	const struct ice_xdp_buff *xdp_ext = (void *)ctx;
> +	const union ice_32b_rx_flex_desc *eop_desc;
> +	enum ice_rx_csum_status status;
> +	u16 ptype;
> +
> +	eop_desc = xdp_ext->pkt_ctx.eop_desc;
> +	ptype = ice_get_ptype(eop_desc);
> +
> +	status = ice_get_rx_csum_status(eop_desc, ptype);
> +	if (status & ICE_RX_CSUM_FAIL)
> +		return -ENODATA;
> +
> +	*csum_status = XDP_CHECKSUM_VERIFIED;
> +	return 0;
> +}
> +
>  const struct xdp_metadata_ops ice_xdp_md_ops = {
>  	.xmo_rx_timestamp		= ice_xdp_rx_hw_ts,
>  	.xmo_rx_hash			= ice_xdp_rx_hash,
>  	.xmo_rx_vlan_tag		= ice_xdp_rx_vlan_tag,
> +	.xmo_rx_csum			= ice_xdp_rx_csum,

timestamp hint is implemented by igc, mlx4, mlx5, stmmac
hash hint is implemneted by igc, mlx4, mlx5.
With above csum and vlan hints will be in ice only.
I'd like to see at least one more driver to implement them as well to make sure
the proposed API works for other vendors.
Larysa Zaremba Aug. 22, 2023, 9:07 a.m. UTC | #2
On Thu, Aug 17, 2023 at 02:58:26PM -0700, Alexei Starovoitov wrote:
> On Fri, Aug 11, 2023 at 06:15:01PM +0200, Larysa Zaremba wrote:
> > Implement .xmo_rx_csum callback to allow XDP code to determine,
> > whether HW has validated any checksums.
> > 
> > Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
> > ---
> >  drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 26 +++++++++++++++++++
> >  1 file changed, 26 insertions(+)
> > 
> > diff --git a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> > index 6ae57a98a4d8..f11a245705bc 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> > +++ b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> > @@ -660,8 +660,34 @@ static int ice_xdp_rx_vlan_tag(const struct xdp_md *ctx, u16 *vlan_tci,
> >  	return 0;
> >  }
> >  
> > +/**
> > + * ice_xdp_rx_csum - RX checksum XDP hint handler
> > + * @ctx: XDP buff pointer
> > + * @csum_status: status destination address
> > + * @csum: not used
> > + */
> > +static int ice_xdp_rx_csum(const struct xdp_md *ctx,
> > +			   enum xdp_csum_status *csum_status, __wsum *csum)
> > +{
> > +	const struct ice_xdp_buff *xdp_ext = (void *)ctx;
> > +	const union ice_32b_rx_flex_desc *eop_desc;
> > +	enum ice_rx_csum_status status;
> > +	u16 ptype;
> > +
> > +	eop_desc = xdp_ext->pkt_ctx.eop_desc;
> > +	ptype = ice_get_ptype(eop_desc);
> > +
> > +	status = ice_get_rx_csum_status(eop_desc, ptype);
> > +	if (status & ICE_RX_CSUM_FAIL)
> > +		return -ENODATA;
> > +
> > +	*csum_status = XDP_CHECKSUM_VERIFIED;
> > +	return 0;
> > +}
> > +
> >  const struct xdp_metadata_ops ice_xdp_md_ops = {
> >  	.xmo_rx_timestamp		= ice_xdp_rx_hw_ts,
> >  	.xmo_rx_hash			= ice_xdp_rx_hash,
> >  	.xmo_rx_vlan_tag		= ice_xdp_rx_vlan_tag,
> > +	.xmo_rx_csum			= ice_xdp_rx_csum,
> 
> timestamp hint is implemented by igc, mlx4, mlx5, stmmac
> hash hint is implemneted by igc, mlx4, mlx5.
> With above csum and vlan hints will be in ice only.
> I'd like to see at least one more driver to implement them as well to make sure
> the proposed API works for other vendors.

I have no other vendors on my current setup :/

I could send an RFC of v5 + a compile-tested implementation for some other 
vendor, so you can see, how it might look.

What do you think?
Alexei Starovoitov Aug. 22, 2023, 7:50 p.m. UTC | #3
On Tue, Aug 22, 2023 at 2:13 AM Larysa Zaremba <larysa.zaremba@intel.com> wrote:
>
> On Thu, Aug 17, 2023 at 02:58:26PM -0700, Alexei Starovoitov wrote:
> > On Fri, Aug 11, 2023 at 06:15:01PM +0200, Larysa Zaremba wrote:
> > > Implement .xmo_rx_csum callback to allow XDP code to determine,
> > > whether HW has validated any checksums.
> > >
> > > Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
> > > ---
> > >  drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 26 +++++++++++++++++++
> > >  1 file changed, 26 insertions(+)
> > >
> > > diff --git a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> > > index 6ae57a98a4d8..f11a245705bc 100644
> > > --- a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> > > +++ b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> > > @@ -660,8 +660,34 @@ static int ice_xdp_rx_vlan_tag(const struct xdp_md *ctx, u16 *vlan_tci,
> > >     return 0;
> > >  }
> > >
> > > +/**
> > > + * ice_xdp_rx_csum - RX checksum XDP hint handler
> > > + * @ctx: XDP buff pointer
> > > + * @csum_status: status destination address
> > > + * @csum: not used
> > > + */
> > > +static int ice_xdp_rx_csum(const struct xdp_md *ctx,
> > > +                      enum xdp_csum_status *csum_status, __wsum *csum)
> > > +{
> > > +   const struct ice_xdp_buff *xdp_ext = (void *)ctx;
> > > +   const union ice_32b_rx_flex_desc *eop_desc;
> > > +   enum ice_rx_csum_status status;
> > > +   u16 ptype;
> > > +
> > > +   eop_desc = xdp_ext->pkt_ctx.eop_desc;
> > > +   ptype = ice_get_ptype(eop_desc);
> > > +
> > > +   status = ice_get_rx_csum_status(eop_desc, ptype);
> > > +   if (status & ICE_RX_CSUM_FAIL)
> > > +           return -ENODATA;
> > > +
> > > +   *csum_status = XDP_CHECKSUM_VERIFIED;
> > > +   return 0;
> > > +}
> > > +
> > >  const struct xdp_metadata_ops ice_xdp_md_ops = {
> > >     .xmo_rx_timestamp               = ice_xdp_rx_hw_ts,
> > >     .xmo_rx_hash                    = ice_xdp_rx_hash,
> > >     .xmo_rx_vlan_tag                = ice_xdp_rx_vlan_tag,
> > > +   .xmo_rx_csum                    = ice_xdp_rx_csum,
> >
> > timestamp hint is implemented by igc, mlx4, mlx5, stmmac
> > hash hint is implemneted by igc, mlx4, mlx5.
> > With above csum and vlan hints will be in ice only.
> > I'd like to see at least one more driver to implement them as well to make sure
> > the proposed API works for other vendors.
>
> I have no other vendors on my current setup :/
>
> I could send an RFC of v5 + a compile-tested implementation for some other
> vendor, so you can see, how it might look.

compiled tested is a good step.
nvidia folks would need to test it and ack it, of course.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
index 6ae57a98a4d8..f11a245705bc 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
@@ -660,8 +660,34 @@  static int ice_xdp_rx_vlan_tag(const struct xdp_md *ctx, u16 *vlan_tci,
 	return 0;
 }
 
+/**
+ * ice_xdp_rx_csum - RX checksum XDP hint handler
+ * @ctx: XDP buff pointer
+ * @csum_status: status destination address
+ * @csum: not used
+ */
+static int ice_xdp_rx_csum(const struct xdp_md *ctx,
+			   enum xdp_csum_status *csum_status, __wsum *csum)
+{
+	const struct ice_xdp_buff *xdp_ext = (void *)ctx;
+	const union ice_32b_rx_flex_desc *eop_desc;
+	enum ice_rx_csum_status status;
+	u16 ptype;
+
+	eop_desc = xdp_ext->pkt_ctx.eop_desc;
+	ptype = ice_get_ptype(eop_desc);
+
+	status = ice_get_rx_csum_status(eop_desc, ptype);
+	if (status & ICE_RX_CSUM_FAIL)
+		return -ENODATA;
+
+	*csum_status = XDP_CHECKSUM_VERIFIED;
+	return 0;
+}
+
 const struct xdp_metadata_ops ice_xdp_md_ops = {
 	.xmo_rx_timestamp		= ice_xdp_rx_hw_ts,
 	.xmo_rx_hash			= ice_xdp_rx_hash,
 	.xmo_rx_vlan_tag		= ice_xdp_rx_vlan_tag,
+	.xmo_rx_csum			= ice_xdp_rx_csum,
 };