How to support SIOCGMIIREG on DPAA2 eth driver

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to support SIOCGMIIREG on DPAA2 eth driver

Jump to solution
1,063 Views
howardlu1
Contributor I

Hi,

 

I found DPAA eth driver support SIOCGMIIREG ioctl but DPAA2 didn't.

how to support SIOCGMIIREG on DPAA2 eth driver?

 

Thanks,

Howard.

0 Kudos
1 Solution
1,055 Views
yipingwang
NXP TechSupport
NXP TechSupport

See if this patch helps:

 

From a46ef98f3677c6e68768a2a4fd7752de4ddd779b Mon Sep 17 00:00:00 2001

From: Radu Bulie <radu-andrei.bulie@nxp.com>

Date: Fri, 11 Dec 2020 01:51:27 +0200

Subject: [PATCH] Add support for SIOCGMIIREG and SIOCSMIIREG

 

The support is added onto the mac device which actually defines a dummy netdevice needed to configure the phydev.

 

Signed-off-by: Radu Bulie <radu-andrei.bulie@nxp.com>

---

 drivers/staging/fsl-dpaa2/mac/mac.c | 18 ++++++++++++++++++

 1 file changed, 18 insertions(+)

 

diff --git a/drivers/staging/fsl-dpaa2/mac/mac.c b/drivers/staging/fsl-dpaa2/mac/mac.c

index 65cbdbe7f313..1435462e8cb0 100644

--- a/drivers/staging/fsl-dpaa2/mac/mac.c

+++ b/drivers/staging/fsl-dpaa2/mac/mac.c

@@ -393,11 +393,29 @@ static int dpaa2_mac_get_sset_count(struct net_device *dev, int sset)

       }

 }

 

+int dpaa2_mac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)

+{

+      int ret = -EINVAL;

+

+

+      if (cmd == SIOCGMIIREG || cmd == SIOCSMIIREG) {

+               if (!dev->phydev)

+                       ret = -EINVAL;

+               else {

+                       ret = phy_mii_ioctl(dev->phydev, rq, cmd);

+               }

+      } else

+               ret = -EOPNOTSUPP;

+

+      return ret;

+}

+

 static const struct net_device_ops dpaa2_mac_ndo_ops = {

       .ndo_open               = &dpaa2_mac_open,

       .ndo_stop                 = &dpaa2_mac_stop,

       .ndo_start_xmit               = &dpaa2_mac_drop_frame,

       .ndo_get_stats64    = &dpaa2_mac_get_stats,

+      .ndo_do_ioctl          = &dpaa2_mac_ioctl,

 };

 

 static const struct ethtool_ops dpaa2_mac_ethtool_ops = {

--

2.17.1

 

To use something with this patch - example phytool you need to:

 

 

CONFIG_FSL_DPAA2_MAC_NETDEVS=y

  •        Apply the patch from archive
  •        Rebuild the kernel.
  •        Clone phytool and build it from: https://github.com/wkz/phytool.git or use the binary from archive

 

 

Once you booted and created an interface that is connected let's say to dpmac.2, when you do an ifconfig -a you will see a strange interface called mac2. (exactly like this). Use that netdevice to communicate with the phy. Example:

./phytool write mac3/4:0x1E/0xC47A 0x1803

View solution in original post

0 Kudos
3 Replies
1,056 Views
yipingwang
NXP TechSupport
NXP TechSupport

See if this patch helps:

 

From a46ef98f3677c6e68768a2a4fd7752de4ddd779b Mon Sep 17 00:00:00 2001

From: Radu Bulie <radu-andrei.bulie@nxp.com>

Date: Fri, 11 Dec 2020 01:51:27 +0200

Subject: [PATCH] Add support for SIOCGMIIREG and SIOCSMIIREG

 

The support is added onto the mac device which actually defines a dummy netdevice needed to configure the phydev.

 

Signed-off-by: Radu Bulie <radu-andrei.bulie@nxp.com>

---

 drivers/staging/fsl-dpaa2/mac/mac.c | 18 ++++++++++++++++++

 1 file changed, 18 insertions(+)

 

diff --git a/drivers/staging/fsl-dpaa2/mac/mac.c b/drivers/staging/fsl-dpaa2/mac/mac.c

index 65cbdbe7f313..1435462e8cb0 100644

--- a/drivers/staging/fsl-dpaa2/mac/mac.c

+++ b/drivers/staging/fsl-dpaa2/mac/mac.c

@@ -393,11 +393,29 @@ static int dpaa2_mac_get_sset_count(struct net_device *dev, int sset)

       }

 }

 

+int dpaa2_mac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)

+{

+      int ret = -EINVAL;

+

+

+      if (cmd == SIOCGMIIREG || cmd == SIOCSMIIREG) {

+               if (!dev->phydev)

+                       ret = -EINVAL;

+               else {

+                       ret = phy_mii_ioctl(dev->phydev, rq, cmd);

+               }

+      } else

+               ret = -EOPNOTSUPP;

+

+      return ret;

+}

+

 static const struct net_device_ops dpaa2_mac_ndo_ops = {

       .ndo_open               = &dpaa2_mac_open,

       .ndo_stop                 = &dpaa2_mac_stop,

       .ndo_start_xmit               = &dpaa2_mac_drop_frame,

       .ndo_get_stats64    = &dpaa2_mac_get_stats,

+      .ndo_do_ioctl          = &dpaa2_mac_ioctl,

 };

 

 static const struct ethtool_ops dpaa2_mac_ethtool_ops = {

--

2.17.1

 

To use something with this patch - example phytool you need to:

 

 

CONFIG_FSL_DPAA2_MAC_NETDEVS=y

  •        Apply the patch from archive
  •        Rebuild the kernel.
  •        Clone phytool and build it from: https://github.com/wkz/phytool.git or use the binary from archive

 

 

Once you booted and created an interface that is connected let's say to dpmac.2, when you do an ifconfig -a you will see a strange interface called mac2. (exactly like this). Use that netdevice to communicate with the phy. Example:

./phytool write mac3/4:0x1E/0xC47A 0x1803

0 Kudos
1,050 Views
yipingwang
NXP TechSupport
NXP TechSupport

Sorry for the typo(instead of mac3 mac2 must appear as below):

 

./phytool write mac2/4:0x1E/0xC47A 0x1803

0 Kudos
1,043 Views
howardlu1
Contributor I

Hi, Yiping Wang:

 

Thanks, it works.

 

 

0 Kudos