Re: [PATCH iwl-next v5 1/9] net: ethtool: mm: extract stmmac verification logic into common library

From: Furong Xu
Date: Fri Feb 21 2025 - 05:24:53 EST


On Fri, 21 Feb 2025 11:56:51 +0200, Vladimir Oltean <vladimir.oltean@xxxxxxx> wrote:

> On Fri, Feb 21, 2025 at 05:42:49PM +0800, Furong Xu wrote:
> > > +void ethtool_mmsv_link_state_handle(struct ethtool_mmsv *mmsv, bool up)
> > > +{
> > > + unsigned long flags;
> > > +
> > > + ethtool_mmsv_stop(mmsv);
> > > +
> > > + spin_lock_irqsave(&mmsv->lock, flags);
> > > +
> > > + if (up && mmsv->pmac_enabled) {
> > > + /* VERIFY process requires pMAC enabled when NIC comes up */
> > > + ethtool_mmsv_configure_pmac(mmsv, true);
> > > +
> > > + /* New link => maybe new partner => new verification process */
> > > + ethtool_mmsv_apply(mmsv);
> > > + } else {
> > > + mmsv->status = ETHTOOL_MM_VERIFY_STATUS_INITIAL;
> >
> > Tested this patch on my side, everything works well, but the verify-status
> > is a little weird:
> >
> > # kernel booted, check initial states:
> > ethtool --include-statistics --json --show-mm eth1
> > [ {
> > "ifname": "eth1",
> > "pmac-enabled": false,
> > "tx-enabled": false,
> > "tx-active": false,
> > "tx-min-frag-size": 60,
> > "rx-min-frag-size": 60,
> > "verify-enabled": false,
> > "verify-time": 128,
> > "max-verify-time": 128,
> > "verify-status": "INITIAL",
> > "statistics": {
> > "MACMergeFrameAssErrorCount": 0,
> > "MACMergeFrameSmdErrorCount": 0,
> > "MACMergeFrameAssOkCount": 0,
> > "MACMergeFragCountRx": 0,
> > "MACMergeFragCountTx": 0,
> > "MACMergeHoldCount": 0
> > }
> > } ]
> >
> > # Enable pMAC by: ethtool --set-mm eth1 pmac-enabled on
> > ethtool --include-statistics --json --show-mm eth1
> > [ {
> > "ifname": "eth1",
> > "pmac-enabled": true,
> > "tx-enabled": false,
> > "tx-active": false,
> > "tx-min-frag-size": 60,
> > "rx-min-frag-size": 60,
> > "verify-enabled": false,
> > "verify-time": 128,
> > "max-verify-time": 128,
> > "verify-status": "DISABLED",
> > "statistics": {
> > "MACMergeFrameAssErrorCount": 0,
> > "MACMergeFrameSmdErrorCount": 0,
> > "MACMergeFrameAssOkCount": 0,
> > "MACMergeFragCountRx": 0,
> > "MACMergeFragCountTx": 0,
> > "MACMergeHoldCount": 0
> > }
> > } ]
> >
> > # Disable pMAC by: ethtool --set-mm eth1 pmac-enabled off
> > ethtool --include-statistics --json --show-mm eth1
> > [ {
> > "ifname": "eth1",
> > "pmac-enabled": true,
> > "tx-enabled": false,
> > "tx-active": false,
> > "tx-min-frag-size": 60,
> > "rx-min-frag-size": 60,
> > "verify-enabled": false,
> > "verify-time": 128,
> > "max-verify-time": 128,
> > "verify-status": "DISABLED",
> > "statistics": {
> > "MACMergeFrameAssErrorCount": 0,
> > "MACMergeFrameSmdErrorCount": 0,
> > "MACMergeFrameAssOkCount": 0,
> > "MACMergeFragCountRx": 0,
> > "MACMergeFragCountTx": 0,
> > "MACMergeHoldCount": 0
> > }
> > } ]
> >
> > verify-status always normal on other cases.
>
> Thanks for testing and for reporting this inconsistency.
>
> > @Vladimir, maybe we shouldn't update mmsv->status in ethtool_mmsv_link_state_handle()?
> > Or, update mmsv->status like below:
> > mmsv->status = mmsv->pmac_enabled ?
> > ETHTOOL_MM_VERIFY_STATUS_INITIAL :
> > ETHTOOL_MM_VERIFY_STATUS_DISABLED;
>
> You mean mmsv->status = mmsv->verify_enabled ? ETHTOOL_MM_VERIFY_STATUS_INITIAL :
> ~~~~~~~~~~~~~~~~~~~~ ETHTOOL_MM_VERIFY_STATUS_DISABLED?

Your fix is better when link is up/down, so I vote verify_enabled.