2024-03-27 15:09:05

by Alexander Lobakin

[permalink] [raw]
Subject: [PATCH net-next v2 0/3] compiler_types: add Endianness-dependent __counted_by_{le,be}

Some structures contain flexible arrays at the end and the counter for
them, but the counter has explicit Endianness and thus __counted_by()
can't be used directly.

To increase test coverage for potential problems without breaking
anything, introduce __counted_by_{le,be} defined depending on platform's
Endianness to either __counted_by() when applicable or noop otherwise.
The first user will be virtchnl2.h from idpf just as example with 9 flex
structures having Little Endian counters.

Maybe it would be a good idea to introduce such attributes on compiler
level if possible, but for now let's stop on what we have.

Alexander Lobakin (3):
compiler_types: add Endianness-dependent __counted_by_{le,be}
idpf: make virtchnl2.h self-contained
idpf: sprinkle __counted_by{,_le}() in the virtchnl2 header

Documentation/conf.py | 2 ++
scripts/kernel-doc | 1 +
include/linux/compiler_types.h | 11 ++++++++++
drivers/net/ethernet/intel/idpf/idpf_txrx.h | 2 ++
drivers/net/ethernet/intel/idpf/virtchnl2.h | 24 ++++++++++-----------
5 files changed, 28 insertions(+), 12 deletions(-)

---
From v1[0]:
* fix compilation of #2 (Jakub);
* pick Acked-bys (Gustavo).

From RFC[1]:

* teach kdoc new attributes (Simon, Kees);
* add Acked-by (Kees);
* fix a couple typos;
* send to net-next (Kees).

[0] https://lore.kernel.org/netdev/[email protected]
[1] https://lore.kernel.org/netdev/[email protected]
--
2.44.0



2024-03-27 15:09:49

by Alexander Lobakin

[permalink] [raw]
Subject: [PATCH net-next v2 2/3] idpf: make virtchnl2.h self-contained

To ease maintaining of virtchnl2.h, which already is messy enough,
make it self-contained by adding missing if_ether.h include due to
%ETH_ALEN usage.
At the same time, virtchnl2_lan_desc.h is not used anywhere in the
file, so move this include to idpf_txrx.h to speed up C preprocessing.

Acked-by: Kees Cook <[email protected]>
Acked-by: Gustavo A. R. Silva <[email protected]>
Signed-off-by: Alexander Lobakin <[email protected]>
---
drivers/net/ethernet/intel/idpf/idpf_txrx.h | 2 ++
drivers/net/ethernet/intel/idpf/virtchnl2.h | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.h b/drivers/net/ethernet/intel/idpf/idpf_txrx.h
index df76493faa75..3d046b81e507 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_txrx.h
+++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.h
@@ -8,6 +8,8 @@
#include <net/tcp.h>
#include <net/netdev_queues.h>

+#include "virtchnl2_lan_desc.h"
+
#define IDPF_LARGE_MAX_Q 256
#define IDPF_MAX_Q 16
#define IDPF_MIN_Q 2
diff --git a/drivers/net/ethernet/intel/idpf/virtchnl2.h b/drivers/net/ethernet/intel/idpf/virtchnl2.h
index 4a3c4454d25a..29419211b3d9 100644
--- a/drivers/net/ethernet/intel/idpf/virtchnl2.h
+++ b/drivers/net/ethernet/intel/idpf/virtchnl2.h
@@ -4,6 +4,8 @@
#ifndef _VIRTCHNL2_H_
#define _VIRTCHNL2_H_

+#include <linux/if_ether.h>
+
/* All opcodes associated with virtchnl2 are prefixed with virtchnl2 or
* VIRTCHNL2. Any future opcodes, offloads/capabilities, structures,
* and defines must be prefixed with virtchnl2 or VIRTCHNL2 to avoid confusion.
@@ -17,8 +19,6 @@
* must remain unchanged over time, so we specify explicit values for all enums.
*/

-#include "virtchnl2_lan_desc.h"
-
/* This macro is used to generate compilation errors if a structure
* is not exactly the correct length.
*/
--
2.44.0


2024-03-28 10:33:31

by Przemek Kitszel

[permalink] [raw]
Subject: Re: [PATCH net-next v2 0/3] compiler_types: add Endianness-dependent __counted_by_{le,be}

On 3/27/24 15:22, Alexander Lobakin wrote:
> Some structures contain flexible arrays at the end and the counter for
> them, but the counter has explicit Endianness and thus __counted_by()
> can't be used directly.
>
> To increase test coverage for potential problems without breaking
> anything, introduce __counted_by_{le,be} defined depending on platform's
> Endianness to either __counted_by() when applicable or noop otherwise.
> The first user will be virtchnl2.h from idpf just as example with 9 flex
> structures having Little Endian counters.
>
> Maybe it would be a good idea to introduce such attributes on compiler
> level if possible, but for now let's stop on what we have.
>
> Alexander Lobakin (3):
> compiler_types: add Endianness-dependent __counted_by_{le,be}
> idpf: make virtchnl2.h self-contained
> idpf: sprinkle __counted_by{,_le}() in the virtchnl2 header
>
> Documentation/conf.py | 2 ++
> scripts/kernel-doc | 1 +
> include/linux/compiler_types.h | 11 ++++++++++
> drivers/net/ethernet/intel/idpf/idpf_txrx.h | 2 ++
> drivers/net/ethernet/intel/idpf/virtchnl2.h | 24 ++++++++++-----------
> 5 files changed, 28 insertions(+), 12 deletions(-)
>
> ---
> From v1[0]:
> * fix compilation of #2 (Jakub);
> * pick Acked-bys (Gustavo).
>
> From RFC[1]:
>
> * teach kdoc new attributes (Simon, Kees);
> * add Acked-by (Kees);
> * fix a couple typos;
> * send to net-next (Kees).
>
> [0] https://lore.kernel.org/netdev/[email protected]
> [1] https://lore.kernel.org/netdev/[email protected]

nice,
Reviewed-by: Przemek Kitszel <[email protected]>

2024-03-29 02:20:46

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH net-next v2 0/3] compiler_types: add Endianness-dependent __counted_by_{le,be}

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <[email protected]>:

On Wed, 27 Mar 2024 15:22:38 +0100 you wrote:
> Some structures contain flexible arrays at the end and the counter for
> them, but the counter has explicit Endianness and thus __counted_by()
> can't be used directly.
>
> To increase test coverage for potential problems without breaking
> anything, introduce __counted_by_{le,be} defined depending on platform's
> Endianness to either __counted_by() when applicable or noop otherwise.
> The first user will be virtchnl2.h from idpf just as example with 9 flex
> structures having Little Endian counters.
>
> [...]

Here is the summary with links:
- [net-next,v2,1/3] compiler_types: add Endianness-dependent __counted_by_{le,be}
https://git.kernel.org/netdev/net-next/c/ca7e324e8ad3
- [net-next,v2,2/3] idpf: make virtchnl2.h self-contained
https://git.kernel.org/netdev/net-next/c/c00d33f1fc79
- [net-next,v2,3/3] idpf: sprinkle __counted_by{,_le}() in the virtchnl2 header
https://git.kernel.org/netdev/net-next/c/93d24acfa05e

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html