Commit 52323ef7 authored by Oleksandr Mazur's avatar Oleksandr Mazur Committed by David S. Miller

net: marvell: prestera: add phylink support

For SFP port prestera driver will use kernel
phylink infrastucture to configure port mode based on
the module that has beed inserted
Co-developed-by: default avatarYevhen Orlov <yevhen.orlov@plvision.eu>
Signed-off-by: default avatarYevhen Orlov <yevhen.orlov@plvision.eu>
Co-developed-by: default avatarTaras Chornyi <taras.chornyi@plvision.eu>
Signed-off-by: default avatarTaras Chornyi <taras.chornyi@plvision.eu>
Signed-off-by: default avatarOleksandr Mazur <oleksandr.mazur@plvision.eu>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ffcdd119
...@@ -8,6 +8,7 @@ config PRESTERA ...@@ -8,6 +8,7 @@ config PRESTERA
depends on NET_SWITCHDEV && VLAN_8021Q depends on NET_SWITCHDEV && VLAN_8021Q
depends on BRIDGE || BRIDGE=n depends on BRIDGE || BRIDGE=n
select NET_DEVLINK select NET_DEVLINK
select PHYLINK
help help
This driver supports Marvell Prestera Switch ASICs family. This driver supports Marvell Prestera Switch ASICs family.
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/phylink.h>
#include <net/devlink.h> #include <net/devlink.h>
#include <uapi/linux/if_ether.h> #include <uapi/linux/if_ether.h>
...@@ -92,6 +93,7 @@ struct prestera_lag { ...@@ -92,6 +93,7 @@ struct prestera_lag {
struct prestera_flow_block; struct prestera_flow_block;
struct prestera_port_mac_state { struct prestera_port_mac_state {
bool valid;
u32 mode; u32 mode;
u32 speed; u32 speed;
bool oper; bool oper;
...@@ -151,6 +153,13 @@ struct prestera_port { ...@@ -151,6 +153,13 @@ struct prestera_port {
struct prestera_port_phy_config cfg_phy; struct prestera_port_phy_config cfg_phy;
struct prestera_port_mac_state state_mac; struct prestera_port_mac_state state_mac;
struct prestera_port_phy_state state_phy; struct prestera_port_phy_state state_phy;
struct phylink_config phy_config;
struct phylink *phy_link;
struct phylink_pcs phylink_pcs;
/* protects state_mac */
spinlock_t state_mac_lock;
}; };
struct prestera_device { struct prestera_device {
...@@ -291,6 +300,7 @@ struct prestera_switch { ...@@ -291,6 +300,7 @@ struct prestera_switch {
u32 mtu_min; u32 mtu_min;
u32 mtu_max; u32 mtu_max;
u8 id; u8 id;
struct device_node *np;
struct prestera_router *router; struct prestera_router *router;
struct prestera_lag *lags; struct prestera_lag *lags;
struct prestera_counter *counter; struct prestera_counter *counter;
......
...@@ -521,6 +521,9 @@ prestera_ethtool_get_link_ksettings(struct net_device *dev, ...@@ -521,6 +521,9 @@ prestera_ethtool_get_link_ksettings(struct net_device *dev,
ecmd->base.speed = SPEED_UNKNOWN; ecmd->base.speed = SPEED_UNKNOWN;
ecmd->base.duplex = DUPLEX_UNKNOWN; ecmd->base.duplex = DUPLEX_UNKNOWN;
if (port->phy_link)
return phylink_ethtool_ksettings_get(port->phy_link, ecmd);
ecmd->base.autoneg = port->autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE; ecmd->base.autoneg = port->autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE;
if (port->caps.type == PRESTERA_PORT_TYPE_TP) { if (port->caps.type == PRESTERA_PORT_TYPE_TP) {
...@@ -648,6 +651,9 @@ prestera_ethtool_set_link_ksettings(struct net_device *dev, ...@@ -648,6 +651,9 @@ prestera_ethtool_set_link_ksettings(struct net_device *dev,
u8 adver_fec; u8 adver_fec;
int err; int err;
if (port->phy_link)
return phylink_ethtool_ksettings_set(port->phy_link, ecmd);
err = prestera_port_type_set(ecmd, port); err = prestera_port_type_set(ecmd, port);
if (err) if (err)
return err; return err;
...@@ -782,28 +788,6 @@ static int prestera_ethtool_nway_reset(struct net_device *dev) ...@@ -782,28 +788,6 @@ static int prestera_ethtool_nway_reset(struct net_device *dev)
return -EINVAL; return -EINVAL;
} }
void prestera_ethtool_port_state_changed(struct prestera_port *port,
struct prestera_port_event *evt)
{
struct prestera_port_mac_state *smac = &port->state_mac;
smac->oper = evt->data.mac.oper;
if (smac->oper) {
smac->mode = evt->data.mac.mode;
smac->speed = evt->data.mac.speed;
smac->duplex = evt->data.mac.duplex;
smac->fc = evt->data.mac.fc;
smac->fec = evt->data.mac.fec;
} else {
smac->mode = PRESTERA_MAC_MODE_MAX;
smac->speed = SPEED_UNKNOWN;
smac->duplex = DUPLEX_UNKNOWN;
smac->fc = 0;
smac->fec = 0;
}
}
const struct ethtool_ops prestera_ethtool_ops = { const struct ethtool_ops prestera_ethtool_ops = {
.get_drvinfo = prestera_ethtool_get_drvinfo, .get_drvinfo = prestera_ethtool_get_drvinfo,
.get_link_ksettings = prestera_ethtool_get_link_ksettings, .get_link_ksettings = prestera_ethtool_get_link_ksettings,
......
...@@ -11,7 +11,4 @@ struct prestera_port; ...@@ -11,7 +11,4 @@ struct prestera_port;
extern const struct ethtool_ops prestera_ethtool_ops; extern const struct ethtool_ops prestera_ethtool_ops;
void prestera_ethtool_port_state_changed(struct prestera_port *port,
struct prestera_port_event *evt);
#endif /* _PRESTERA_ETHTOOL_H_ */ #endif /* _PRESTERA_ETHTOOL_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment