Skip to content

Commit 0cb6da0

Browse files
Russell King (Oracle)kuba-moo
authored andcommitted
net: dsa: mv88e6xxx: provide own phylink MAC operations
Convert mv88e6xxx to provide its own phylink MAC operations, thus avoiding the shim layer in DSA's port.c Reviewed-by: Andrew Lunn <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: Russell King (Oracle) <[email protected]> Reviewed-by: Vladimir Oltean <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent cae425c commit 0cb6da0

File tree

1 file changed

+39
-24
lines changed
  • drivers/net/dsa/mv88e6xxx

1 file changed

+39
-24
lines changed

drivers/net/dsa/mv88e6xxx/chip.c

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -790,24 +790,27 @@ static void mv88e6xxx_get_caps(struct dsa_switch *ds, int port,
790790
}
791791
}
792792

793-
static struct phylink_pcs *mv88e6xxx_mac_select_pcs(struct dsa_switch *ds,
794-
int port,
795-
phy_interface_t interface)
793+
static struct phylink_pcs *
794+
mv88e6xxx_mac_select_pcs(struct phylink_config *config,
795+
phy_interface_t interface)
796796
{
797-
struct mv88e6xxx_chip *chip = ds->priv;
797+
struct dsa_port *dp = dsa_phylink_to_port(config);
798+
struct mv88e6xxx_chip *chip = dp->ds->priv;
798799
struct phylink_pcs *pcs = ERR_PTR(-EOPNOTSUPP);
799800

800801
if (chip->info->ops->pcs_ops)
801-
pcs = chip->info->ops->pcs_ops->pcs_select(chip, port,
802+
pcs = chip->info->ops->pcs_ops->pcs_select(chip, dp->index,
802803
interface);
803804

804805
return pcs;
805806
}
806807

807-
static int mv88e6xxx_mac_prepare(struct dsa_switch *ds, int port,
808+
static int mv88e6xxx_mac_prepare(struct phylink_config *config,
808809
unsigned int mode, phy_interface_t interface)
809810
{
810-
struct mv88e6xxx_chip *chip = ds->priv;
811+
struct dsa_port *dp = dsa_phylink_to_port(config);
812+
struct mv88e6xxx_chip *chip = dp->ds->priv;
813+
int port = dp->index;
811814
int err = 0;
812815

813816
/* In inband mode, the link may come up at any time while the link
@@ -826,11 +829,13 @@ static int mv88e6xxx_mac_prepare(struct dsa_switch *ds, int port,
826829
return err;
827830
}
828831

829-
static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
832+
static void mv88e6xxx_mac_config(struct phylink_config *config,
830833
unsigned int mode,
831834
const struct phylink_link_state *state)
832835
{
833-
struct mv88e6xxx_chip *chip = ds->priv;
836+
struct dsa_port *dp = dsa_phylink_to_port(config);
837+
struct mv88e6xxx_chip *chip = dp->ds->priv;
838+
int port = dp->index;
834839
int err = 0;
835840

836841
mv88e6xxx_reg_lock(chip);
@@ -846,13 +851,15 @@ static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
846851
mv88e6xxx_reg_unlock(chip);
847852

848853
if (err && err != -EOPNOTSUPP)
849-
dev_err(ds->dev, "p%d: failed to configure MAC/PCS\n", port);
854+
dev_err(chip->dev, "p%d: failed to configure MAC/PCS\n", port);
850855
}
851856

852-
static int mv88e6xxx_mac_finish(struct dsa_switch *ds, int port,
857+
static int mv88e6xxx_mac_finish(struct phylink_config *config,
853858
unsigned int mode, phy_interface_t interface)
854859
{
855-
struct mv88e6xxx_chip *chip = ds->priv;
860+
struct dsa_port *dp = dsa_phylink_to_port(config);
861+
struct mv88e6xxx_chip *chip = dp->ds->priv;
862+
int port = dp->index;
856863
int err = 0;
857864

858865
/* Undo the forced down state above after completing configuration
@@ -876,12 +883,14 @@ static int mv88e6xxx_mac_finish(struct dsa_switch *ds, int port,
876883
return err;
877884
}
878885

879-
static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
886+
static void mv88e6xxx_mac_link_down(struct phylink_config *config,
880887
unsigned int mode,
881888
phy_interface_t interface)
882889
{
883-
struct mv88e6xxx_chip *chip = ds->priv;
890+
struct dsa_port *dp = dsa_phylink_to_port(config);
891+
struct mv88e6xxx_chip *chip = dp->ds->priv;
884892
const struct mv88e6xxx_ops *ops;
893+
int port = dp->index;
885894
int err = 0;
886895

887896
ops = chip->info->ops;
@@ -904,14 +913,16 @@ static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
904913
"p%d: failed to force MAC link down\n", port);
905914
}
906915

907-
static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
908-
unsigned int mode, phy_interface_t interface,
916+
static void mv88e6xxx_mac_link_up(struct phylink_config *config,
909917
struct phy_device *phydev,
918+
unsigned int mode, phy_interface_t interface,
910919
int speed, int duplex,
911920
bool tx_pause, bool rx_pause)
912921
{
913-
struct mv88e6xxx_chip *chip = ds->priv;
922+
struct dsa_port *dp = dsa_phylink_to_port(config);
923+
struct mv88e6xxx_chip *chip = dp->ds->priv;
914924
const struct mv88e6xxx_ops *ops;
925+
int port = dp->index;
915926
int err = 0;
916927

917928
ops = chip->info->ops;
@@ -937,7 +948,7 @@ static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
937948
mv88e6xxx_reg_unlock(chip);
938949

939950
if (err && err != -EOPNOTSUPP)
940-
dev_err(ds->dev,
951+
dev_err(chip->dev,
941952
"p%d: failed to configure MAC link up\n", port);
942953
}
943954

@@ -6922,6 +6933,15 @@ static int mv88e6xxx_crosschip_lag_leave(struct dsa_switch *ds, int sw_index,
69226933
return err_sync ? : err_pvt;
69236934
}
69246935

6936+
static const struct phylink_mac_ops mv88e6xxx_phylink_mac_ops = {
6937+
.mac_select_pcs = mv88e6xxx_mac_select_pcs,
6938+
.mac_prepare = mv88e6xxx_mac_prepare,
6939+
.mac_config = mv88e6xxx_mac_config,
6940+
.mac_finish = mv88e6xxx_mac_finish,
6941+
.mac_link_down = mv88e6xxx_mac_link_down,
6942+
.mac_link_up = mv88e6xxx_mac_link_up,
6943+
};
6944+
69256945
static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
69266946
.get_tag_protocol = mv88e6xxx_get_tag_protocol,
69276947
.change_tag_protocol = mv88e6xxx_change_tag_protocol,
@@ -6930,12 +6950,6 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
69306950
.port_setup = mv88e6xxx_port_setup,
69316951
.port_teardown = mv88e6xxx_port_teardown,
69326952
.phylink_get_caps = mv88e6xxx_get_caps,
6933-
.phylink_mac_select_pcs = mv88e6xxx_mac_select_pcs,
6934-
.phylink_mac_prepare = mv88e6xxx_mac_prepare,
6935-
.phylink_mac_config = mv88e6xxx_mac_config,
6936-
.phylink_mac_finish = mv88e6xxx_mac_finish,
6937-
.phylink_mac_link_down = mv88e6xxx_mac_link_down,
6938-
.phylink_mac_link_up = mv88e6xxx_mac_link_up,
69396953
.get_strings = mv88e6xxx_get_strings,
69406954
.get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
69416955
.get_eth_mac_stats = mv88e6xxx_get_eth_mac_stats,
@@ -7004,6 +7018,7 @@ static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
70047018
ds->priv = chip;
70057019
ds->dev = dev;
70067020
ds->ops = &mv88e6xxx_switch_ops;
7021+
ds->phylink_mac_ops = &mv88e6xxx_phylink_mac_ops;
70077022
ds->ageing_time_min = chip->info->age_time_coeff;
70087023
ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
70097024

0 commit comments

Comments
 (0)