Re: [PATCH net-next 3/4] net: stmmac: Add glue driver for Motorcomm YT6801 ethernet controller

Yao Zi
2025-10-19T03:05:32Z

On Sat, Oct 18, 2025 at 04:53:04PM +0200, Andrew Lunn wrote:
> > > I was also wondering about all the other parameters you set. Why have
> > > i not seen any other glue driver with similar code? What makes this
> > > glue driver different?
> >
> > Most glue drivers are for SoC-integrated IPs, for which
> > stmmac_pltfr_probe() helper could be used to retrieve configuration
> > arguments from devicetree to fill plat_stmmacenet_data. However, YT6801
> > is a PCIe-based controller, and we couldn't rely on devicetree to carry
> > these parameters.
> >
> > You could find similar parameter setup code in stmmac_pltfr_probe(), and
> > also other glue drivers for PCIe-based controllers, like dwmac-intel.c
> > (intel_mgbe_common_data) and dwmac-loongson.c (loongson_default_data).
>
> Is there anything common with these two drivers? One of the problems
> stmmac has had in the past is that glue driver writers just
> copy/paste, rather than refactor other glue drivers to share code. If
> there is shared code, maybe move it into stmmac_pci.c as helpers?

I don't think there's code that could be shared. Parameters configured
in plat(.{dma_cfg,axi}) are mostly hardware-details and dependent on
synthesis parameters, making them repeat less across drivers, e.g.
dwmac-loongson.c configures no AXI parameter, while
intel_mgbe_common_data() configures axi_blen as up to 16, but the
motorcomm controller is capable of burst length up to 32.

Another example is the rx/tx queue number (plat.{rx,tx}_queues_to_use),
which even varies among different controllers supported by dwmac-intel.c

Maybe the most common part among these argument setup routines is the
allocation of plat_stmmacenet_data and its members, but I doubt whether
extracting this part out as a routine helps much for maintenance.

But outside of plat_stmmacenet_data setup code, there is some code
duplicated across PCIe controller drivers and could be effectively
re-used. dwmac-intel.c, dwmac-loongson.c and stmmac_pci.c have the
same implementation for platform suspend/resume routines
(plat_stmmacenet_data.{suspend,resume}). I could send a series to
extract this part out, and re-use the common routine in the motorcomm
glue driver as well, though we still need to define a new function to
addtionally deassert EPHY_RESET.

> Andrew

Best regards.
Yao Zi