net: ethtool: mm: extract stmmac verification logic into common library
authorVladimir Oltean <vladimir.oltean@nxp.com>
Tue, 18 Mar 2025 03:07:30 +0000 (23:07 -0400)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Fri, 18 Apr 2025 15:43:09 +0000 (08:43 -0700)
commit9ff2aa4206eff40a202e425f232036bc84ad4c0e
tree61f2a980f2220dfe9e0a1d7af79ca440e6552282
parentb375984f0df0ed5a45e8e9dc5600d6666cdb92e7
net: ethtool: mm: extract stmmac verification logic into common library

It appears that stmmac is not the only hardware which requires a
software-driven verification state machine for the MAC Merge layer.

While on the one hand it's good to encourage hardware implementations,
on the other hand it's quite difficult to tolerate multiple drivers
implementing independently fairly non-trivial logic.

Extract the hardware-independent logic from stmmac into library code and
put it in ethtool. Name the state structure "mmsv" for MAC Merge
Software Verification. Let this expose an operations structure for
executing the hardware stuff: sync hardware with the tx_active boolean
(result of verification process), enable/disable the pMAC, send mPackets,
notify library of external events (reception of mPackets), as well as
link state changes.

Note that it is assumed that the external events are received in hardirq
context. If they are not, it is probably a good idea to disable hardirqs
when calling ethtool_mmsv_event_handle(), because the library does not
do so.

Also, the MM software verification process has no business with the
tx_min_frag_size, that is all the driver's to handle.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Co-developed-by: Choong Yong Liang <yong.liang.choong@linux.intel.com>
Signed-off-by: Choong Yong Liang <yong.liang.choong@linux.intel.com>
Tested-by: Choong Yong Liang <yong.liang.choong@linux.intel.com>
Tested-by: Furong Xu <0x1207@gmail.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Faizal Rahim <faizal.abdul.rahim@linux.intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/stmicro/stmmac/Kconfig
drivers/net/ethernet/stmicro/stmmac/stmmac.h
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c
drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
include/linux/ethtool.h
net/ethtool/mm.c