Skip to content

Commit ce31b31

Browse files
ffainellidavem330
authored andcommitted
net: dsa: allow updating fixed PHY link information
Allow switch drivers to hook a PHY link update callback to perform port-specific link work. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ec9436b commit ce31b31

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎include/net/dsa.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/workqueue.h>
1818
#include <linux/of.h>
1919
#include <linux/phy.h>
20+
#include <linux/phy_fixed.h>
2021

2122
#define DSA_MAX_SWITCHES 4
2223
#define DSA_MAX_PORTS 12
@@ -187,6 +188,8 @@ struct dsa_switch_driver {
187188
*/
188189
void (*adjust_link)(struct dsa_switch *ds, int port,
189190
struct phy_device *phydev);
191+
void (*fixed_link_update)(struct dsa_switch *ds, int port,
192+
struct fixed_phy_status *st);
190193

191194
/*
192195
* ethtool hardware statistics.

‎net/dsa/slave.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,26 @@ static void dsa_slave_adjust_link(struct net_device *dev)
358358
phy_print_status(p->phy);
359359
}
360360

361+
static int dsa_slave_fixed_link_update(struct net_device *dev,
362+
struct fixed_phy_status *status)
363+
{
364+
struct dsa_slave_priv *p = netdev_priv(dev);
365+
struct dsa_switch *ds = p->parent;
366+
367+
if (ds->drv->fixed_link_update)
368+
ds->drv->fixed_link_update(ds, p->port, status);
369+
370+
return 0;
371+
}
372+
361373
/* slave device setup *******************************************************/
362374
static void dsa_slave_phy_setup(struct dsa_slave_priv *p,
363375
struct net_device *slave_dev)
364376
{
365377
struct dsa_switch *ds = p->parent;
366378
struct dsa_chip_data *cd = ds->pd;
367379
struct device_node *phy_dn, *port_dn;
380+
bool phy_is_fixed = false;
368381
int ret;
369382

370383
port_dn = cd->port_dn[p->port];
@@ -380,6 +393,7 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p,
380393
pr_err("failed to register fixed PHY\n");
381394
return;
382395
}
396+
phy_is_fixed = true;
383397
phy_dn = port_dn;
384398
}
385399

@@ -388,6 +402,9 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p,
388402
dsa_slave_adjust_link, 0,
389403
p->phy_interface);
390404

405+
if (p->phy && phy_is_fixed)
406+
fixed_phy_set_link_update(p->phy, dsa_slave_fixed_link_update);
407+
391408
/* We could not connect to a designated PHY, so use the switch internal
392409
* MDIO bus instead
393410
*/

0 commit comments

Comments
 (0)