[PATCH net-next v4] net: ethernet: mtk_eth_soc: ppe: add support for multiple PPEs

Daniel Golle daniel at makrotopia.org
Tue May 28 17:42:21 PDT 2024


Hi Elad,

now that net-next is opened again I finally also had some time to take
a deeper look at your patch ;)

On Sat, May 11, 2024 at 03:26:53PM GMT, Elad Yifee wrote:
> Add the missing pieces to allow multiple PPEs units, one for each GMAC.
> [...]
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index 179c0230655a..67e19bd25f7a 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> [...]
> @@ -1311,6 +1311,7 @@ struct mtk_eth {
>  struct mtk_mac {
>  	int				id;
>  	phy_interface_t			interface;
> +	u8						ppe_idx;

I think it would be smarter to just use
ifindex % mtk_get_ppe_num(eth)

Reasons:
 - no need for an additional field in mtk_mac
 - works for all net_device, not just mtk_eth type

>  	int				speed;
>  	struct device_node		*of_node;
>  	struct phylink			*phylink;
> @@ -1421,6 +1422,14 @@ static inline u32 mtk_get_ib2_multicast_mask(struct mtk_eth *eth)
>  	return MTK_FOE_IB2_MULTICAST;
>  }
>  
> +static inline u8 mtk_get_ppe_num(struct mtk_eth *eth)
> +{
> +	if (!eth->soc->offload_version)
> +		return 0;
> +
> +	return eth->soc->version;

Overloading the coincidentally identical hw version and number of PPEs
doesn't feel quite right. Better extend struct mtk_reg_map and turn the
gdma_to_ppe field into an array. Then the number of PPEs for a specific
SoC is the size of that array.

Reasons:
 - we already got that mtk_reg_map structure for hw abstraction, no
   need to introduce more SoC-specific macros like MTK_GDMA_TO_PPEx.
 - no need for mtk_get_ppe_num inline function, or at least no
   overloading of offload_version meaning.


Cheers


Daniel



More information about the linux-arm-kernel mailing list