diff mbox series

[net-next] net: ethernet: mtk_ppe: add MTK_FOE_ENTRY_V{1,2}_SIZE macros

Message ID 725aa4b427e8ae2384ff1c8a32111fb24ceda231.1689762482.git.lorenzo@kernel.org (mailing list archive)
State Accepted
Commit a5dc694e16d31fbf85596de1239ebf4ca8426042
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: ethernet: mtk_ppe: add MTK_FOE_ENTRY_V{1,2}_SIZE macros | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-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: 1352 this patch: 1352
netdev/cc_maintainers warning 4 maintainers not CCed: matthias.bgg@gmail.com angelogioacchino.delregno@collabora.com linux-mediatek@lists.infradead.org linux-arm-kernel@lists.infradead.org
netdev/build_clang success Errors and warnings before: 1365 this patch: 1365
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: 1375 this patch: 1375
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 51 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Lorenzo Bianconi July 19, 2023, 10:29 a.m. UTC
Introduce MTK_FOE_ENTRY_V{1,2}_SIZE macros in order to make more
explicit foe_entry size for different chipset revisions.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 10 +++++-----
 drivers/net/ethernet/mediatek/mtk_ppe.h     |  3 +++
 2 files changed, 8 insertions(+), 5 deletions(-)

Comments

Simon Horman July 20, 2023, 5:55 p.m. UTC | #1
On Wed, Jul 19, 2023 at 12:29:49PM +0200, Lorenzo Bianconi wrote:
> Introduce MTK_FOE_ENTRY_V{1,2}_SIZE macros in order to make more
> explicit foe_entry size for different chipset revisions.
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
>  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 10 +++++-----
>  drivers/net/ethernet/mediatek/mtk_ppe.h     |  3 +++
>  2 files changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index 834c644b67db..7f9e23ddb3c4 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -4811,7 +4811,7 @@ static const struct mtk_soc_data mt7621_data = {
>  	.required_pctl = false,
>  	.offload_version = 1,
>  	.hash_offset = 2,
> -	.foe_entry_size = sizeof(struct mtk_foe_entry) - 16,
> +	.foe_entry_size = MTK_FOE_ENTRY_V1_SIZE,
>  	.txrx = {
>  		.txd_size = sizeof(struct mtk_tx_dma),
>  		.rxd_size = sizeof(struct mtk_rx_dma),

...

> @@ -4889,8 +4889,8 @@ static const struct mtk_soc_data mt7981_data = {
>  	.required_pctl = false,
>  	.offload_version = 2,
>  	.hash_offset = 4,
> -	.foe_entry_size = sizeof(struct mtk_foe_entry),
>  	.has_accounting = true,
> +	.foe_entry_size = MTK_FOE_ENTRY_V2_SIZE,
>  	.txrx = {
>  		.txd_size = sizeof(struct mtk_tx_dma_v2),
>  		.rxd_size = sizeof(struct mtk_rx_dma_v2),

...

> diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.h b/drivers/net/ethernet/mediatek/mtk_ppe.h
> index e51de31a52ec..fb6bf58172d9 100644
> --- a/drivers/net/ethernet/mediatek/mtk_ppe.h
> +++ b/drivers/net/ethernet/mediatek/mtk_ppe.h
> @@ -216,6 +216,9 @@ struct mtk_foe_ipv6_6rd {
>  	struct mtk_foe_mac_info l2;
>  };
>  
> +#define MTK_FOE_ENTRY_V1_SIZE	80
> +#define MTK_FOE_ENTRY_V2_SIZE	96

Hi Lorenzo,

Would it make sense to define these in terms of sizeof(struct mtk_foe_entry) ?

...
Lorenzo Bianconi July 20, 2023, 8:52 p.m. UTC | #2
> On Wed, Jul 19, 2023 at 12:29:49PM +0200, Lorenzo Bianconi wrote:
> > Introduce MTK_FOE_ENTRY_V{1,2}_SIZE macros in order to make more
> > explicit foe_entry size for different chipset revisions.
> > 
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> >  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 10 +++++-----
> >  drivers/net/ethernet/mediatek/mtk_ppe.h     |  3 +++
> >  2 files changed, 8 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> > index 834c644b67db..7f9e23ddb3c4 100644
> > --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> > +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> > @@ -4811,7 +4811,7 @@ static const struct mtk_soc_data mt7621_data = {
> >  	.required_pctl = false,
> >  	.offload_version = 1,
> >  	.hash_offset = 2,
> > -	.foe_entry_size = sizeof(struct mtk_foe_entry) - 16,
> > +	.foe_entry_size = MTK_FOE_ENTRY_V1_SIZE,
> >  	.txrx = {
> >  		.txd_size = sizeof(struct mtk_tx_dma),
> >  		.rxd_size = sizeof(struct mtk_rx_dma),
> 
> ...
> 
> > @@ -4889,8 +4889,8 @@ static const struct mtk_soc_data mt7981_data = {
> >  	.required_pctl = false,
> >  	.offload_version = 2,
> >  	.hash_offset = 4,
> > -	.foe_entry_size = sizeof(struct mtk_foe_entry),
> >  	.has_accounting = true,
> > +	.foe_entry_size = MTK_FOE_ENTRY_V2_SIZE,
> >  	.txrx = {
> >  		.txd_size = sizeof(struct mtk_tx_dma_v2),
> >  		.rxd_size = sizeof(struct mtk_rx_dma_v2),
> 
> ...
> 
> > diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.h b/drivers/net/ethernet/mediatek/mtk_ppe.h
> > index e51de31a52ec..fb6bf58172d9 100644
> > --- a/drivers/net/ethernet/mediatek/mtk_ppe.h
> > +++ b/drivers/net/ethernet/mediatek/mtk_ppe.h
> > @@ -216,6 +216,9 @@ struct mtk_foe_ipv6_6rd {
> >  	struct mtk_foe_mac_info l2;
> >  };
> >  
> > +#define MTK_FOE_ENTRY_V1_SIZE	80
> > +#define MTK_FOE_ENTRY_V2_SIZE	96
> 
> Hi Lorenzo,
> 
> Would it make sense to define these in terms of sizeof(struct mtk_foe_entry) ?
> 

Hi Simon,

I was discussing with Felix to have something like:

struct mtk_foe_entry_v1 {
	u32 data[19];
};

struct mtk_foe_entry_v2 {
	u32 data[23];
};

struct mtk_foe_entry {
	u32 ib1;

	union {
		...
		struct mtk_foe_entry_v1 e;
		struct mtk_foe_entry_v2 e2;
	};
};

and then relying on sizeof of struct mtk_foe_entry_v1/mtk_foe_entry_v2
but then we decided to have a simpler approach. What do you think?

Regards,
Lorenzo

> ...
Simon Horman July 21, 2023, 6:52 a.m. UTC | #3
On Thu, Jul 20, 2023 at 10:52:15PM +0200, Lorenzo Bianconi wrote:
> > On Wed, Jul 19, 2023 at 12:29:49PM +0200, Lorenzo Bianconi wrote:
> > > Introduce MTK_FOE_ENTRY_V{1,2}_SIZE macros in order to make more
> > > explicit foe_entry size for different chipset revisions.
> > > 
> > > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > > ---
> > >  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 10 +++++-----
> > >  drivers/net/ethernet/mediatek/mtk_ppe.h     |  3 +++
> > >  2 files changed, 8 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> > > index 834c644b67db..7f9e23ddb3c4 100644
> > > --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> > > +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> > > @@ -4811,7 +4811,7 @@ static const struct mtk_soc_data mt7621_data = {
> > >  	.required_pctl = false,
> > >  	.offload_version = 1,
> > >  	.hash_offset = 2,
> > > -	.foe_entry_size = sizeof(struct mtk_foe_entry) - 16,
> > > +	.foe_entry_size = MTK_FOE_ENTRY_V1_SIZE,
> > >  	.txrx = {
> > >  		.txd_size = sizeof(struct mtk_tx_dma),
> > >  		.rxd_size = sizeof(struct mtk_rx_dma),
> > 
> > ...
> > 
> > > @@ -4889,8 +4889,8 @@ static const struct mtk_soc_data mt7981_data = {
> > >  	.required_pctl = false,
> > >  	.offload_version = 2,
> > >  	.hash_offset = 4,
> > > -	.foe_entry_size = sizeof(struct mtk_foe_entry),
> > >  	.has_accounting = true,
> > > +	.foe_entry_size = MTK_FOE_ENTRY_V2_SIZE,
> > >  	.txrx = {
> > >  		.txd_size = sizeof(struct mtk_tx_dma_v2),
> > >  		.rxd_size = sizeof(struct mtk_rx_dma_v2),
> > 
> > ...
> > 
> > > diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.h b/drivers/net/ethernet/mediatek/mtk_ppe.h
> > > index e51de31a52ec..fb6bf58172d9 100644
> > > --- a/drivers/net/ethernet/mediatek/mtk_ppe.h
> > > +++ b/drivers/net/ethernet/mediatek/mtk_ppe.h
> > > @@ -216,6 +216,9 @@ struct mtk_foe_ipv6_6rd {
> > >  	struct mtk_foe_mac_info l2;
> > >  };
> > >  
> > > +#define MTK_FOE_ENTRY_V1_SIZE	80
> > > +#define MTK_FOE_ENTRY_V2_SIZE	96
> > 
> > Hi Lorenzo,
> > 
> > Would it make sense to define these in terms of sizeof(struct mtk_foe_entry) ?
> > 
> 
> Hi Simon,
> 
> I was discussing with Felix to have something like:
> 
> struct mtk_foe_entry_v1 {
> 	u32 data[19];
> };
> 
> struct mtk_foe_entry_v2 {
> 	u32 data[23];
> };
> 
> struct mtk_foe_entry {
> 	u32 ib1;
> 
> 	union {
> 		...
> 		struct mtk_foe_entry_v1 e;
> 		struct mtk_foe_entry_v2 e2;
> 	};
> };
> 
> and then relying on sizeof of struct mtk_foe_entry_v1/mtk_foe_entry_v2
> but then we decided to have a simpler approach. What do you think?

Hi Lorenzo,

I do see some value in something like what you have above.
But I also appreciate the value of simplicity.

So I have no objections if you prefer the patch in it's current form.

Reviewed-by: Simon Horman <simon.horman@corigine.com>
patchwork-bot+netdevbpf@kernel.org July 21, 2023, 7:50 a.m. UTC | #4
Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Wed, 19 Jul 2023 12:29:49 +0200 you wrote:
> Introduce MTK_FOE_ENTRY_V{1,2}_SIZE macros in order to make more
> explicit foe_entry size for different chipset revisions.
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
>  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 10 +++++-----
>  drivers/net/ethernet/mediatek/mtk_ppe.h     |  3 +++
>  2 files changed, 8 insertions(+), 5 deletions(-)

Here is the summary with links:
  - [net-next] net: ethernet: mtk_ppe: add MTK_FOE_ENTRY_V{1,2}_SIZE macros
    https://git.kernel.org/netdev/net-next/c/a5dc694e16d3

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 834c644b67db..7f9e23ddb3c4 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -4811,7 +4811,7 @@  static const struct mtk_soc_data mt7621_data = {
 	.required_pctl = false,
 	.offload_version = 1,
 	.hash_offset = 2,
-	.foe_entry_size = sizeof(struct mtk_foe_entry) - 16,
+	.foe_entry_size = MTK_FOE_ENTRY_V1_SIZE,
 	.txrx = {
 		.txd_size = sizeof(struct mtk_tx_dma),
 		.rxd_size = sizeof(struct mtk_rx_dma),
@@ -4832,7 +4832,7 @@  static const struct mtk_soc_data mt7622_data = {
 	.offload_version = 2,
 	.hash_offset = 2,
 	.has_accounting = true,
-	.foe_entry_size = sizeof(struct mtk_foe_entry) - 16,
+	.foe_entry_size = MTK_FOE_ENTRY_V1_SIZE,
 	.txrx = {
 		.txd_size = sizeof(struct mtk_tx_dma),
 		.rxd_size = sizeof(struct mtk_rx_dma),
@@ -4851,7 +4851,7 @@  static const struct mtk_soc_data mt7623_data = {
 	.required_pctl = true,
 	.offload_version = 1,
 	.hash_offset = 2,
-	.foe_entry_size = sizeof(struct mtk_foe_entry) - 16,
+	.foe_entry_size = MTK_FOE_ENTRY_V1_SIZE,
 	.txrx = {
 		.txd_size = sizeof(struct mtk_tx_dma),
 		.rxd_size = sizeof(struct mtk_rx_dma),
@@ -4889,8 +4889,8 @@  static const struct mtk_soc_data mt7981_data = {
 	.required_pctl = false,
 	.offload_version = 2,
 	.hash_offset = 4,
-	.foe_entry_size = sizeof(struct mtk_foe_entry),
 	.has_accounting = true,
+	.foe_entry_size = MTK_FOE_ENTRY_V2_SIZE,
 	.txrx = {
 		.txd_size = sizeof(struct mtk_tx_dma_v2),
 		.rxd_size = sizeof(struct mtk_rx_dma_v2),
@@ -4910,8 +4910,8 @@  static const struct mtk_soc_data mt7986_data = {
 	.required_pctl = false,
 	.offload_version = 2,
 	.hash_offset = 4,
-	.foe_entry_size = sizeof(struct mtk_foe_entry),
 	.has_accounting = true,
+	.foe_entry_size = MTK_FOE_ENTRY_V2_SIZE,
 	.txrx = {
 		.txd_size = sizeof(struct mtk_tx_dma_v2),
 		.rxd_size = sizeof(struct mtk_rx_dma_v2),
diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.h b/drivers/net/ethernet/mediatek/mtk_ppe.h
index e51de31a52ec..fb6bf58172d9 100644
--- a/drivers/net/ethernet/mediatek/mtk_ppe.h
+++ b/drivers/net/ethernet/mediatek/mtk_ppe.h
@@ -216,6 +216,9 @@  struct mtk_foe_ipv6_6rd {
 	struct mtk_foe_mac_info l2;
 };
 
+#define MTK_FOE_ENTRY_V1_SIZE	80
+#define MTK_FOE_ENTRY_V2_SIZE	96
+
 struct mtk_foe_entry {
 	u32 ib1;