Skip to content

Commit ec9436b

Browse files
ffainellidavem330
authored andcommitted
net: dsa: allow drivers to do link adjustment
Whenever libphy determines that the link status of a given PHY/port has changed, allow to call into the switch driver link adjustment callback so proper actions can be taken care of by the switch driver upon link notification. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5aed85c commit ec9436b

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎include/net/dsa.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/timer.h>
1717
#include <linux/workqueue.h>
1818
#include <linux/of.h>
19+
#include <linux/phy.h>
1920

2021
#define DSA_MAX_SWITCHES 4
2122
#define DSA_MAX_PORTS 12
@@ -181,6 +182,12 @@ struct dsa_switch_driver {
181182
*/
182183
void (*poll_link)(struct dsa_switch *ds);
183184

185+
/*
186+
* Link state adjustment (called from libphy)
187+
*/
188+
void (*adjust_link)(struct dsa_switch *ds, int port,
189+
struct phy_device *phydev);
190+
184191
/*
185192
* ethtool hardware statistics.
186193
*/

‎net/dsa/slave.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ static const struct dsa_device_ops notag_netdev_ops = {
333333
static void dsa_slave_adjust_link(struct net_device *dev)
334334
{
335335
struct dsa_slave_priv *p = netdev_priv(dev);
336+
struct dsa_switch *ds = p->parent;
336337
unsigned int status_changed = 0;
337338

338339
if (p->old_link != p->phy->link) {
@@ -350,6 +351,9 @@ static void dsa_slave_adjust_link(struct net_device *dev)
350351
p->old_pause = p->phy->pause;
351352
}
352353

354+
if (ds->drv->adjust_link && status_changed)
355+
ds->drv->adjust_link(ds, p->port, p->phy);
356+
353357
if (status_changed)
354358
phy_print_status(p->phy);
355359
}

0 commit comments

Comments
 (0)