Skip to content

Commit 4cde0e4

Browse files
vladimirolteankuba-moo
authored andcommitted
net: cpsw: isolate cpsw_ndo_ioctl() to just the old driver
cpsw->slaves[slave_no].phy should be equal to netdev->phydev, because it is assigned from phy_attach_direct(). The latter is indirectly called from the two identically named cpsw_slave_open() functions, one in cpsw.c and another in cpsw_new.c. Thus, the driver should not need custom logic to find the PHY, the core can find it, and phy_do_ioctl_running() achieves exactly that. However, that is only the case for cpsw_new and for the cpsw driver in dual EMAC mode. This is explained in more detail in the previous commit. Thus, allow the simpler core logic to execute for cpsw_new, and move cpsw_ndo_ioctl() to cpsw.c. Signed-off-by: Vladimir Oltean <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 36d9b54 commit 4cde0e4

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

drivers/net/ethernet/ti/cpsw.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,27 @@ static void cpsw_ndo_poll_controller(struct net_device *ndev)
11561156
}
11571157
#endif
11581158

1159+
/* We need a custom implementation of phy_do_ioctl_running() because in switch
1160+
* mode, dev->phydev may be different than the phy of the active_slave. We need
1161+
* to operate on the locally saved phy instead.
1162+
*/
1163+
static int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
1164+
{
1165+
struct cpsw_priv *priv = netdev_priv(dev);
1166+
struct cpsw_common *cpsw = priv->cpsw;
1167+
int slave_no = cpsw_slave_index(cpsw, priv);
1168+
struct phy_device *phy;
1169+
1170+
if (!netif_running(dev))
1171+
return -EINVAL;
1172+
1173+
phy = cpsw->slaves[slave_no].phy;
1174+
if (phy)
1175+
return phy_mii_ioctl(phy, req, cmd);
1176+
1177+
return -EOPNOTSUPP;
1178+
}
1179+
11591180
static const struct net_device_ops cpsw_netdev_ops = {
11601181
.ndo_open = cpsw_ndo_open,
11611182
.ndo_stop = cpsw_ndo_stop,

drivers/net/ethernet/ti/cpsw_new.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ static const struct net_device_ops cpsw_netdev_ops = {
11321132
.ndo_stop = cpsw_ndo_stop,
11331133
.ndo_start_xmit = cpsw_ndo_start_xmit,
11341134
.ndo_set_mac_address = cpsw_ndo_set_mac_address,
1135-
.ndo_eth_ioctl = cpsw_ndo_ioctl,
1135+
.ndo_eth_ioctl = phy_do_ioctl_running,
11361136
.ndo_validate_addr = eth_validate_addr,
11371137
.ndo_tx_timeout = cpsw_ndo_tx_timeout,
11381138
.ndo_set_rx_mode = cpsw_ndo_set_rx_mode,

drivers/net/ethernet/ti/cpsw_priv.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -710,23 +710,6 @@ int cpsw_hwtstamp_set(struct net_device *dev,
710710
}
711711
#endif /*CONFIG_TI_CPTS*/
712712

713-
int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
714-
{
715-
struct cpsw_priv *priv = netdev_priv(dev);
716-
struct cpsw_common *cpsw = priv->cpsw;
717-
int slave_no = cpsw_slave_index(cpsw, priv);
718-
struct phy_device *phy;
719-
720-
if (!netif_running(dev))
721-
return -EINVAL;
722-
723-
phy = cpsw->slaves[slave_no].phy;
724-
if (phy)
725-
return phy_mii_ioctl(phy, req, cmd);
726-
727-
return -EOPNOTSUPP;
728-
}
729-
730713
int cpsw_ndo_set_tx_maxrate(struct net_device *ndev, int queue, u32 rate)
731714
{
732715
struct cpsw_priv *priv = netdev_priv(ndev);

drivers/net/ethernet/ti/cpsw_priv.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,6 @@ void soft_reset(const char *module, void __iomem *reg);
461461
void cpsw_set_slave_mac(struct cpsw_slave *slave, struct cpsw_priv *priv);
462462
void cpsw_ndo_tx_timeout(struct net_device *ndev, unsigned int txqueue);
463463
int cpsw_need_resplit(struct cpsw_common *cpsw);
464-
int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd);
465464
int cpsw_ndo_set_tx_maxrate(struct net_device *ndev, int queue, u32 rate);
466465
int cpsw_ndo_setup_tc(struct net_device *ndev, enum tc_setup_type type,
467466
void *type_data);

0 commit comments

Comments
 (0)