linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v4] net: airoha: Add missing filed to ppe_mbox_data struct
@ 2025-04-29 14:17 Lorenzo Bianconi
  2025-04-29 20:08 ` Jacob Keller
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Lorenzo Bianconi @ 2025-04-29 14:17 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Lorenzo Bianconi
  Cc: linux-arm-kernel, linux-mediatek, netdev, Simon Horman,
	Jacob Keller

The official Airoha EN7581 firmware requires adding max_packet filed in
ppe_mbox_data struct while the unofficial one used to develop the Airoha
EN7581 flowtable support does not require this field.
This patch does not introduce any real backwards compatible issue since
EN7581 fw is not publicly available in linux-firmware or other
repositories (e.g. OpenWrt) yet and the official fw version will use this
new layout. For this reason this change needs to be backported.
Moreover, add __packed attribute to ppe_mbox_data struct definition and
make the fw layout padding explicit in init_info struct.
At the same time use u32 instead of int for init_info and set_info
struct definitions in ppe_mbox_data struct.

Fixes: 23290c7bc190d ("net: airoha: Introduce Airoha NPU support")
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
Changes in v4:
- use u32 instead of int in ppe_mbox_data struct
- add __packed attribute to struct definitions and make the fw layout
  padding explicit in init_info struct
- Link to v3: https://lore.kernel.org/r/20250422-airoha-en7581-fix-ppe_mbox_data-v3-1-87dd50d2956e@kernel.org

Changes in v3:
- resend targeting net tree
- Link to v2: https://lore.kernel.org/r/20250417-airoha-en7581-fix-ppe_mbox_data-v2-1-43433cfbe874@kernel.org

Changes in v2:
- Add more details to commit log
- Link to v1: https://lore.kernel.org/r/20250415-airoha-en7581-fix-ppe_mbox_data-v1-1-4408c60ba964@kernel.org
---
 drivers/net/ethernet/airoha/airoha_npu.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c
index 7a5710f9ccf6a4a4f555ab63d67cb6b318de9b52..c81e25139d5ff4b6c52ce8802dd9c9b9b6c8c721 100644
--- a/drivers/net/ethernet/airoha/airoha_npu.c
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
@@ -104,17 +104,19 @@ struct ppe_mbox_data {
 			u8 xpon_hal_api;
 			u8 wan_xsi;
 			u8 ct_joyme4;
-			int ppe_type;
-			int wan_mode;
-			int wan_sel;
-		} init_info;
+			u8 max_packet;
+			u8 rsv[3]; /* align to fw layout */
+			u32 ppe_type;
+			u32 wan_mode;
+			u32 wan_sel;
+		} __packed init_info;
 		struct {
-			int func_id;
+			u32 func_id;
 			u32 size;
 			u32 data;
-		} set_info;
+		} __packed set_info;
 	};
-};
+} __packed;
 
 static int airoha_npu_send_msg(struct airoha_npu *npu, int func_id,
 			       void *p, int size)

---
base-commit: d4cb1ecc22908ef46f2885ee2978a4f22e90f365
change-id: 20250422-airoha-en7581-fix-ppe_mbox_data-56df12d4df72

Best regards,
-- 
Lorenzo Bianconi <lorenzo@kernel.org>



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH net v4] net: airoha: Add missing filed to ppe_mbox_data struct
  2025-04-29 14:17 [PATCH net v4] net: airoha: Add missing filed to ppe_mbox_data struct Lorenzo Bianconi
@ 2025-04-29 20:08 ` Jacob Keller
  2025-04-29 20:09 ` Jacob Keller
  2025-05-01 14:15 ` Jakub Kicinski
  2 siblings, 0 replies; 9+ messages in thread
From: Jacob Keller @ 2025-04-29 20:08 UTC (permalink / raw)
  To: Lorenzo Bianconi, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: linux-arm-kernel, linux-mediatek, netdev, Simon Horman



On 4/29/2025 7:17 AM, Lorenzo Bianconi wrote:
> The official Airoha EN7581 firmware requires adding max_packet filed in
> ppe_mbox_data struct while the unofficial one used to develop the Airoha
> EN7581 flowtable support does not require this field.
> This patch does not introduce any real backwards compatible issue since
> EN7581 fw is not publicly available in linux-firmware or other
> repositories (e.g. OpenWrt) yet and the official fw version will use this
> new layout. For this reason this change needs to be backported.
> Moreover, add __packed attribute to ppe_mbox_data struct definition and
> make the fw layout padding explicit in init_info struct.
> At the same time use u32 instead of int for init_info and set_info
> struct definitions in ppe_mbox_data struct.
> 
nit: subject has a typo, s/filed/field/?


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net v4] net: airoha: Add missing filed to ppe_mbox_data struct
  2025-04-29 14:17 [PATCH net v4] net: airoha: Add missing filed to ppe_mbox_data struct Lorenzo Bianconi
  2025-04-29 20:08 ` Jacob Keller
@ 2025-04-29 20:09 ` Jacob Keller
  2025-05-01 14:15 ` Jakub Kicinski
  2 siblings, 0 replies; 9+ messages in thread
From: Jacob Keller @ 2025-04-29 20:09 UTC (permalink / raw)
  To: Lorenzo Bianconi, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: linux-arm-kernel, linux-mediatek, netdev, Simon Horman



On 4/29/2025 7:17 AM, Lorenzo Bianconi wrote:
> The official Airoha EN7581 firmware requires adding max_packet filed in
> ppe_mbox_data struct while the unofficial one used to develop the Airoha
> EN7581 flowtable support does not require this field.
> This patch does not introduce any real backwards compatible issue since
> EN7581 fw is not publicly available in linux-firmware or other
> repositories (e.g. OpenWrt) yet and the official fw version will use this
> new layout. For this reason this change needs to be backported.
> Moreover, add __packed attribute to ppe_mbox_data struct definition and
> make the fw layout padding explicit in init_info struct.
> At the same time use u32 instead of int for init_info and set_info
> struct definitions in ppe_mbox_data struct.
> 
> Fixes: 23290c7bc190d ("net: airoha: Introduce Airoha NPU support")
> Reviewed-by: Simon Horman <horms@kernel.org>
> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> Changes in v4:
> - use u32 instead of int in ppe_mbox_data struct
> - add __packed attribute to struct definitions and make the fw layout
>   padding explicit in init_info struct
> - Link to v3: https://lore.kernel.org/r/20250422-airoha-en7581-fix-ppe_mbox_data-v3-1-87dd50d2956e@kernel.org
> 
> Changes in v3:
> - resend targeting net tree
> - Link to v2: https://lore.kernel.org/r/20250417-airoha-en7581-fix-ppe_mbox_data-v2-1-43433cfbe874@kernel.org
> 
> Changes in v2:
> - Add more details to commit log
> - Link to v1: https://lore.kernel.org/r/20250415-airoha-en7581-fix-ppe_mbox_data-v1-1-4408c60ba964@kernel.org
> ---
>  drivers/net/ethernet/airoha/airoha_npu.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c
> index 7a5710f9ccf6a4a4f555ab63d67cb6b318de9b52..c81e25139d5ff4b6c52ce8802dd9c9b9b6c8c721 100644
> --- a/drivers/net/ethernet/airoha/airoha_npu.c
> +++ b/drivers/net/ethernet/airoha/airoha_npu.c
> @@ -104,17 +104,19 @@ struct ppe_mbox_data {
>  			u8 xpon_hal_api;
>  			u8 wan_xsi;
>  			u8 ct_joyme4;
> -			int ppe_type;
> -			int wan_mode;
> -			int wan_sel;
> -		} init_info;
> +			u8 max_packet;
> +			u8 rsv[3]; /* align to fw layout */
> +			u32 ppe_type;
> +			u32 wan_mode;
> +			u32 wan_sel;
> +		} __packed init_info;
>  		struct {
> -			int func_id;
> +			u32 func_id;
>  			u32 size;
>  			u32 data;
> -		} set_info;
> +		} __packed set_info;
>  	};
> -};
> +} __packed;
>  
>  

Content makes sense, and I appreciate the padding and layout being explicit.

With or without the typo fix in the subject:

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net v4] net: airoha: Add missing filed to ppe_mbox_data struct
  2025-04-29 14:17 [PATCH net v4] net: airoha: Add missing filed to ppe_mbox_data struct Lorenzo Bianconi
  2025-04-29 20:08 ` Jacob Keller
  2025-04-29 20:09 ` Jacob Keller
@ 2025-05-01 14:15 ` Jakub Kicinski
  2025-05-01 20:47   ` Lorenzo Bianconi
  2 siblings, 1 reply; 9+ messages in thread
From: Jakub Kicinski @ 2025-05-01 14:15 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
	linux-arm-kernel, linux-mediatek, netdev, Simon Horman,
	Jacob Keller

On Tue, 29 Apr 2025 16:17:41 +0200 Lorenzo Bianconi wrote:
> Moreover, add __packed attribute to ppe_mbox_data struct definition and
> make the fw layout padding explicit in init_info struct.

Why? everything looks naturally packed now :(
__packed also forces the compiler to assume the data is unaligned AFAIU.
The recommended way to ensure the compiler doesn't insert padding is
to do a compile time assert.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net v4] net: airoha: Add missing filed to ppe_mbox_data struct
  2025-05-01 14:15 ` Jakub Kicinski
@ 2025-05-01 20:47   ` Lorenzo Bianconi
  2025-05-02  0:41     ` Jakub Kicinski
  0 siblings, 1 reply; 9+ messages in thread
From: Lorenzo Bianconi @ 2025-05-01 20:47 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
	linux-arm-kernel, linux-mediatek, netdev, Simon Horman,
	Jacob Keller

[-- Attachment #1: Type: text/plain, Size: 707 bytes --]

On May 01, Jakub Kicinski wrote:
> On Tue, 29 Apr 2025 16:17:41 +0200 Lorenzo Bianconi wrote:
> > Moreover, add __packed attribute to ppe_mbox_data struct definition and
> > make the fw layout padding explicit in init_info struct.
> 
> Why? everything looks naturally packed now :(

What I mean here is the padding in the ppe_mbox_data struct used by the fw running
on the NPU, not in the version used by the airoha_eth driver, got my point?
Sorry, re-reading it, it was not so clear, I agree.

Regards,
Lorenzo

> __packed also forces the compiler to assume the data is unaligned AFAIU.
> The recommended way to ensure the compiler doesn't insert padding is
> to do a compile time assert.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net v4] net: airoha: Add missing filed to ppe_mbox_data struct
  2025-05-01 20:47   ` Lorenzo Bianconi
@ 2025-05-02  0:41     ` Jakub Kicinski
  2025-05-02  7:24       ` Lorenzo Bianconi
  0 siblings, 1 reply; 9+ messages in thread
From: Jakub Kicinski @ 2025-05-02  0:41 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
	linux-arm-kernel, linux-mediatek, netdev, Simon Horman,
	Jacob Keller

On Thu, 1 May 2025 22:47:06 +0200 Lorenzo Bianconi wrote:
> On May 01, Jakub Kicinski wrote:
> > On Tue, 29 Apr 2025 16:17:41 +0200 Lorenzo Bianconi wrote:  
> > > Moreover, add __packed attribute to ppe_mbox_data struct definition and
> > > make the fw layout padding explicit in init_info struct.  
> > 
> > Why? everything looks naturally packed now :(  
> 
> What I mean here is the padding in the ppe_mbox_data struct used by the fw running
> on the NPU, not in the version used by the airoha_eth driver, got my point?
> Sorry, re-reading it, it was not so clear, I agree.

You mean adding the "u8 rsv[3];" ? that is fine.
I don't get why we also need to add the 3 __packed


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net v4] net: airoha: Add missing filed to ppe_mbox_data struct
  2025-05-02  0:41     ` Jakub Kicinski
@ 2025-05-02  7:24       ` Lorenzo Bianconi
  2025-05-03  1:12         ` Jakub Kicinski
  0 siblings, 1 reply; 9+ messages in thread
From: Lorenzo Bianconi @ 2025-05-02  7:24 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
	linux-arm-kernel, linux-mediatek, netdev, Simon Horman,
	Jacob Keller

[-- Attachment #1: Type: text/plain, Size: 897 bytes --]

> On Thu, 1 May 2025 22:47:06 +0200 Lorenzo Bianconi wrote:
> > On May 01, Jakub Kicinski wrote:
> > > On Tue, 29 Apr 2025 16:17:41 +0200 Lorenzo Bianconi wrote:  
> > > > Moreover, add __packed attribute to ppe_mbox_data struct definition and
> > > > make the fw layout padding explicit in init_info struct.  
> > > 
> > > Why? everything looks naturally packed now :(  
> > 
> > What I mean here is the padding in the ppe_mbox_data struct used by the fw running
> > on the NPU, not in the version used by the airoha_eth driver, got my point?
> > Sorry, re-reading it, it was not so clear, I agree.
> 
> You mean adding the "u8 rsv[3];" ? that is fine.
> I don't get why we also need to add the 3 __packed

I agree the __packed attributes are not mandatory at the moment, we just agreed
with Jacob that is fine to add them. Do you prefer to get rid of them?

Regards,
Lorenzo

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net v4] net: airoha: Add missing filed to ppe_mbox_data struct
  2025-05-02  7:24       ` Lorenzo Bianconi
@ 2025-05-03  1:12         ` Jakub Kicinski
  2025-05-03  8:39           ` Lorenzo Bianconi
  0 siblings, 1 reply; 9+ messages in thread
From: Jakub Kicinski @ 2025-05-03  1:12 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
	linux-arm-kernel, linux-mediatek, netdev, Simon Horman,
	Jacob Keller

On Fri, 2 May 2025 09:24:49 +0200 Lorenzo Bianconi wrote:
> > > What I mean here is the padding in the ppe_mbox_data struct used by the fw running
> > > on the NPU, not in the version used by the airoha_eth driver, got my point?
> > > Sorry, re-reading it, it was not so clear, I agree.  
> > 
> > You mean adding the "u8 rsv[3];" ? that is fine.
> > I don't get why we also need to add the 3 __packed  
> 
> I agree the __packed attributes are not mandatory at the moment, we just agreed
> with Jacob that is fine to add them. Do you prefer to get rid of them?

Yes, they also imply the structure may not be aligned, AFAIU.
__packed used to be one of DaveM's big no-nos back in the day.
Especially in vendor drivers it gets sprinkled everywhere without
thinking. So maybe it's all school of me, but yes, please remove.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net v4] net: airoha: Add missing filed to ppe_mbox_data struct
  2025-05-03  1:12         ` Jakub Kicinski
@ 2025-05-03  8:39           ` Lorenzo Bianconi
  0 siblings, 0 replies; 9+ messages in thread
From: Lorenzo Bianconi @ 2025-05-03  8:39 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
	linux-arm-kernel, linux-mediatek, netdev, Simon Horman,
	Jacob Keller

[-- Attachment #1: Type: text/plain, Size: 964 bytes --]

On May 02, Jakub Kicinski wrote:
> On Fri, 2 May 2025 09:24:49 +0200 Lorenzo Bianconi wrote:
> > > > What I mean here is the padding in the ppe_mbox_data struct used by the fw running
> > > > on the NPU, not in the version used by the airoha_eth driver, got my point?
> > > > Sorry, re-reading it, it was not so clear, I agree.  
> > > 
> > > You mean adding the "u8 rsv[3];" ? that is fine.
> > > I don't get why we also need to add the 3 __packed  
> > 
> > I agree the __packed attributes are not mandatory at the moment, we just agreed
> > with Jacob that is fine to add them. Do you prefer to get rid of them?
> 
> Yes, they also imply the structure may not be aligned, AFAIU.
> __packed used to be one of DaveM's big no-nos back in the day.
> Especially in vendor drivers it gets sprinkled everywhere without
> thinking. So maybe it's all school of me, but yes, please remove.

ack, fine. I will get rid of them in v5.

Regards,
Lorenzo

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-05-03  8:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-29 14:17 [PATCH net v4] net: airoha: Add missing filed to ppe_mbox_data struct Lorenzo Bianconi
2025-04-29 20:08 ` Jacob Keller
2025-04-29 20:09 ` Jacob Keller
2025-05-01 14:15 ` Jakub Kicinski
2025-05-01 20:47   ` Lorenzo Bianconi
2025-05-02  0:41     ` Jakub Kicinski
2025-05-02  7:24       ` Lorenzo Bianconi
2025-05-03  1:12         ` Jakub Kicinski
2025-05-03  8:39           ` Lorenzo Bianconi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).