Skip to content

Commit

Permalink
net: dsa: felix: provide own phylink MAC operations
Browse files Browse the repository at this point in the history
Convert felix to provide its own phylink MAC operations, thus
avoiding the shim layer in DSA's port.c.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://lore.kernel.org/r/E1sByYA-00EM0y-Jn@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Russell King (Oracle) authored and Jakub Kicinski committed May 30, 2024
1 parent bbb31b7 commit ef0e51d
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 18 deletions.
54 changes: 36 additions & 18 deletions drivers/net/dsa/ocelot/felix.c
Original file line number Diff line number Diff line change
Expand Up @@ -1050,36 +1050,46 @@ static void felix_phylink_get_caps(struct dsa_switch *ds, int port,
config->supported_interfaces);
}

static void felix_phylink_mac_config(struct dsa_switch *ds, int port,
static void felix_phylink_mac_config(struct phylink_config *config,
unsigned int mode,
const struct phylink_link_state *state)
{
struct ocelot *ocelot = ds->priv;
struct felix *felix = ocelot_to_felix(ocelot);
struct dsa_port *dp = dsa_phylink_to_port(config);
struct ocelot *ocelot = dp->ds->priv;
int port = dp->index;
struct felix *felix;

felix = ocelot_to_felix(ocelot);

if (felix->info->phylink_mac_config)
felix->info->phylink_mac_config(ocelot, port, mode, state);
}

static struct phylink_pcs *felix_phylink_mac_select_pcs(struct dsa_switch *ds,
int port,
phy_interface_t iface)
static struct phylink_pcs *
felix_phylink_mac_select_pcs(struct phylink_config *config,
phy_interface_t iface)
{
struct ocelot *ocelot = ds->priv;
struct felix *felix = ocelot_to_felix(ocelot);
struct dsa_port *dp = dsa_phylink_to_port(config);
struct ocelot *ocelot = dp->ds->priv;
struct phylink_pcs *pcs = NULL;
int port = dp->index;
struct felix *felix;

felix = ocelot_to_felix(ocelot);

if (felix->pcs && felix->pcs[port])
pcs = felix->pcs[port];

return pcs;
}

static void felix_phylink_mac_link_down(struct dsa_switch *ds, int port,
static void felix_phylink_mac_link_down(struct phylink_config *config,
unsigned int link_an_mode,
phy_interface_t interface)
{
struct ocelot *ocelot = ds->priv;
struct dsa_port *dp = dsa_phylink_to_port(config);
struct ocelot *ocelot = dp->ds->priv;
int port = dp->index;
struct felix *felix;

felix = ocelot_to_felix(ocelot);
Expand All @@ -1088,15 +1098,19 @@ static void felix_phylink_mac_link_down(struct dsa_switch *ds, int port,
felix->info->quirks);
}

static void felix_phylink_mac_link_up(struct dsa_switch *ds, int port,
static void felix_phylink_mac_link_up(struct phylink_config *config,
struct phy_device *phydev,
unsigned int link_an_mode,
phy_interface_t interface,
struct phy_device *phydev,
int speed, int duplex,
bool tx_pause, bool rx_pause)
{
struct ocelot *ocelot = ds->priv;
struct felix *felix = ocelot_to_felix(ocelot);
struct dsa_port *dp = dsa_phylink_to_port(config);
struct ocelot *ocelot = dp->ds->priv;
int port = dp->index;
struct felix *felix;

felix = ocelot_to_felix(ocelot);

ocelot_phylink_mac_link_up(ocelot, port, phydev, link_an_mode,
interface, speed, duplex, tx_pause, rx_pause,
Expand Down Expand Up @@ -2083,6 +2097,14 @@ static void felix_get_mm_stats(struct dsa_switch *ds, int port,
ocelot_port_get_mm_stats(ocelot, port, stats);
}

const struct phylink_mac_ops felix_phylink_mac_ops = {
.mac_select_pcs = felix_phylink_mac_select_pcs,
.mac_config = felix_phylink_mac_config,
.mac_link_down = felix_phylink_mac_link_down,
.mac_link_up = felix_phylink_mac_link_up,
};
EXPORT_SYMBOL_GPL(felix_phylink_mac_ops);

const struct dsa_switch_ops felix_switch_ops = {
.get_tag_protocol = felix_get_tag_protocol,
.change_tag_protocol = felix_change_tag_protocol,
Expand All @@ -2104,10 +2126,6 @@ const struct dsa_switch_ops felix_switch_ops = {
.get_sset_count = felix_get_sset_count,
.get_ts_info = felix_get_ts_info,
.phylink_get_caps = felix_phylink_get_caps,
.phylink_mac_config = felix_phylink_mac_config,
.phylink_mac_select_pcs = felix_phylink_mac_select_pcs,
.phylink_mac_link_down = felix_phylink_mac_link_down,
.phylink_mac_link_up = felix_phylink_mac_link_up,
.port_enable = felix_port_enable,
.port_fast_age = felix_port_fast_age,
.port_fdb_dump = felix_fdb_dump,
Expand Down
1 change: 1 addition & 0 deletions drivers/net/dsa/ocelot/felix.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ struct felix_tag_proto_ops {
struct netlink_ext_ack *extack);
};

extern const struct phylink_mac_ops felix_phylink_mac_ops;
extern const struct dsa_switch_ops felix_switch_ops;

/* DSA glue / front-end for struct ocelot */
Expand Down
1 change: 1 addition & 0 deletions drivers/net/dsa/ocelot/felix_vsc9959.c
Original file line number Diff line number Diff line change
Expand Up @@ -2717,6 +2717,7 @@ static int felix_pci_probe(struct pci_dev *pdev,
ds->num_ports = felix->info->num_ports;
ds->num_tx_queues = felix->info->num_tx_queues;
ds->ops = &felix_switch_ops;
ds->phylink_mac_ops = &felix_phylink_mac_ops;
ds->priv = ocelot;
felix->ds = ds;
felix->tag_proto = DSA_TAG_PROTO_OCELOT;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/dsa/ocelot/ocelot_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ static int ocelot_ext_probe(struct platform_device *pdev)
ds->num_tx_queues = felix->info->num_tx_queues;

ds->ops = &felix_switch_ops;
ds->phylink_mac_ops = &felix_phylink_mac_ops;
ds->priv = ocelot;
felix->ds = ds;
felix->tag_proto = DSA_TAG_PROTO_OCELOT;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/dsa/ocelot/seville_vsc9953.c
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,7 @@ static int seville_probe(struct platform_device *pdev)
ds->dev = &pdev->dev;
ds->num_ports = felix->info->num_ports;
ds->ops = &felix_switch_ops;
ds->phylink_mac_ops = &felix_phylink_mac_ops;
ds->priv = ocelot;
felix->ds = ds;
felix->tag_proto = DSA_TAG_PROTO_SEVILLE;
Expand Down

0 comments on commit ef0e51d

Please sign in to comment.