lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
 <DM6PR11MB4236812E54A02741C068E312839E2@DM6PR11MB4236.namprd11.prod.outlook.com>
Date: Fri, 6 Sep 2024 06:54:20 +0000
From: <Mohan.Prasad@...rochip.com>
To: <bcreeley@....com>, <netdev@...r.kernel.org>, <davem@...emloft.net>,
	<kuba@...nel.org>
CC: <shuah@...nel.org>, <Bryan.Whitehead@...rochip.com>,
	<UNGLinuxDriver@...rochip.com>, <edumazet@...gle.com>, <pabeni@...hat.com>,
	<linux-kernel@...r.kernel.org>, <linux-kselftest@...r.kernel.org>,
	<horms@...nel.org>, <brett.creeley@....com>, <rosenp@...il.com>
Subject: RE: [PATCH net-next 1/3] selftests: lan743x: Add testfile for lan743x
 network driver

Hi Brett,

Thank you for the review comments.

> EXTERNAL EMAIL: Do not click links or open attachments unless you know the
> content is safe
> 
> On 9/3/2024 3:15 PM, Mohan Prasad J wrote:
> > Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> >
> >
> > Add testfile for lan743x network driver.
> > Testfile includes the verification of status of autonegotiation.
> > Ksft modules and ethtool are used for the testing.
> > net/lib libraries are included for testing.
> > Add the __init__.py file.
> > Include /microchip/lan743x as a target in Makefile.
> > Updated MAINTAINERS list.
> >
> > Signed-off-by: Mohan Prasad J <mohan.prasad@...rochip.com>
> > ---
> >   MAINTAINERS                                   |  2 +
> >   tools/testing/selftests/Makefile              |  2 +-
> >   .../drivers/net/hw/microchip/lan743x/Makefile |  7 +++
> >   .../net/hw/microchip/lan743x/lan743x.py       | 51 +++++++++++++++++++
> >   .../hw/microchip/lan743x/lib/py/__init__.py   | 16 ++++++
> >   5 files changed, 77 insertions(+), 1 deletion(-)
> >   create mode 100644
> tools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefile
> >   create mode 100755
> tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py
> >   create mode 100644
> > tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__init
> > __.py
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS index baf88e74c..461f94ae0
> > 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -14960,10 +14960,12 @@ F:    net/dsa/tag_ksz.c
> >
> >   MICROCHIP LAN743X ETHERNET DRIVER
> >   M:     Bryan Whitehead <bryan.whitehead@...rochip.com>
> > +M:     Mohan Prasad J <mohan.prasad@...rochip.com>
> 
> It seems like updating the maintainers list should be a separate patch.

I will update it in the next version.

> 
> Thanks,
> 
> Brett
> 
> >   M:     UNGLinuxDriver@...rochip.com
> >   L:     netdev@...r.kernel.org
> >   S:     Maintained
> >   F:     drivers/net/ethernet/microchip/lan743x_*
> > +F:     tools/testing/selftests/drivers/net/hw/microchip/lan743x/
> >
> >   MICROCHIP LAN87xx/LAN937x T1 PHY DRIVER
> >   M:     Arun Ramadoss <arun.ramadoss@...rochip.com>
> > diff --git a/tools/testing/selftests/Makefile
> > b/tools/testing/selftests/Makefile
> > index a5f1c0c27..8059529c9 100644
> > --- a/tools/testing/selftests/Makefile
> > +++ b/tools/testing/selftests/Makefile
> > @@ -122,7 +122,7 @@ TARGETS_HOTPLUG = cpu-hotplug
> >   TARGETS_HOTPLUG += memory-hotplug
> >
> >   # Networking tests want the net/lib target, include it automatically
> > -ifneq ($(filter net drivers/net drivers/net/hw,$(TARGETS)),)
> > +ifneq ($(filter net drivers/net drivers/net/hw
> > +drivers/net/hw/microchip/lan743x,$(TARGETS)),)
> >   ifeq ($(filter net/lib,$(TARGETS)),)
> >          INSTALL_DEP_TARGETS := net/lib
> >   endif
> > diff --git
> > a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefile
> > b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefile
> > new file mode 100644
> > index 000000000..542128678
> > --- /dev/null
> > +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefil
> > +++ e
> > @@ -0,0 +1,7 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +TEST_INCLUDES := $(wildcard lib/py/*.py ../../../lib/py/*.py)
> > +
> > +TEST_PROGS := lan743x.py
> > +
> > +include ../../../../../lib.mk
> > diff --git
> > a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py
> > b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py
> > new file mode 100755
> > index 000000000..f1ad97dc2
> > --- /dev/null
> > +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x
> > +++ .py
> > @@ -0,0 +1,51 @@
> > +#!/usr/bin/env python3
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +import time
> > +import re
> > +from lib.py import ksft_run, ksft_exit, ksft_pr, ksft_eq from lib.py
> > +import KsftFailEx, KsftSkipEx from lib.py import NetDrvEpEnv from
> > +lib.py import cmd from lib.py import ethtool
> > +
> > +def verify_link_up(ifname: str) -> None:
> > +    """Verify whether the link is up initially"""
> > +    with open(f"/sys/class/net/{ifname}/operstate", "r") as fp:
> > +        link_state = fp.read().strip()
> > +
> > +    if link_state == "down":
> > +        raise KsftSkipEx(f"Link state of interface {ifname} is DOWN")
> > +
> > +def set_autonegotiation_state(ifname: str, state: str) -> None:
> > +    """Set the autonegotiation state for the interface"""
> > +    process = ethtool(f"-s {ifname} speed 10 duplex half autoneg {state}")
> > +    if process.ret != 0:
> > +        raise KsftFailEx(f"Not able to set autoneg parameter for {ifname}")
> > +    ksft_pr(f"Autoneg set as {state} for {ifname}")
> > +
> > +def verify_autonegotiation(ifname: str, expected_state: str) -> None:
> > +    verify_link_up(ifname)
> > +    """Verifying the autonegotiation state"""
> > +    output = ethtool(f"{ifname}")
> > +    autoneg_match = re.search(r'Auto-negotiation:\s+(\w+)',
> > +output.stdout)
> > +
> > +    if not autoneg_match:
> > +        raise KsftFailEx("Failed to find autonegotiation information
> > + in ethtool output.")
> > +
> > +    actual_state = autoneg_match.group(1)
> > +    ksft_eq(actual_state, expected_state)
> > +
> > +def test_autonegotiation(cfg) -> None:
> > +    for state in ["off", "on"]:
> > +        set_autonegotiation_state(cfg.ifname, state)
> > +        time.sleep(5)
> > +        verify_autonegotiation(cfg.ifname, state)
> > +
> > +def main() -> None:
> > +    with NetDrvEpEnv(__file__) as cfg:
> > +        ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg,))
> > +    ksft_exit()
> > +
> > +if __name__ == "__main__":
> > +    main()
> > diff --git
> > a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__in
> > it__.py
> > b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__in
> > it__.py
> > new file mode 100644
> > index 000000000..e571631af
> > --- /dev/null
> > +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/
> > +++ __init__.py
> > @@ -0,0 +1,16 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +import sys
> > +from pathlib import Path
> > +
> > +KSFT_DIR = (Path(__file__).parent / "../../../../../../..").resolve()
> > +
> > +try:
> > +    sys.path.append(KSFT_DIR.as_posix())
> > +    from net.lib.py import *
> > +    from drivers.net.lib.py import *
> > +except ModuleNotFoundError as e:
> > +    ksft_pr("Failed importing `net` library from kernel sources")
> > +    ksft_pr(str(e))
> > +    ktap_result(True, comment="SKIP")
> > +    sys.exit(4)
> > --
> > 2.43.0
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ