Skip to content

Commit 8876769

Browse files
Russell King (Oracle)davem330
authored andcommitted
net: macb: use .mac_select_pcs() interface
Convert the PCS selection to use mac_select_pcs, which allows the PCS to perform any validation it needs. We must use separate phylink_pcs instances for the USX and SGMII PCS, rather than just changing the "ops" pointer before re-setting it to phylink as this interface queries the PCS, rather than requesting it to be changed. Acked-by: Nicolas Ferre <[email protected]> Signed-off-by: Russell King (Oracle) <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent eac1b93 commit 8876769

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

drivers/net/ethernet/cadence/macb.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,8 @@ struct macb {
12711271
struct mii_bus *mii_bus;
12721272
struct phylink *phylink;
12731273
struct phylink_config phylink_config;
1274-
struct phylink_pcs phylink_pcs;
1274+
struct phylink_pcs phylink_usx_pcs;
1275+
struct phylink_pcs phylink_sgmii_pcs;
12751276

12761277
u32 caps;
12771278
unsigned int dma_burst_length;

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ static void macb_usx_pcs_link_up(struct phylink_pcs *pcs, unsigned int mode,
510510
phy_interface_t interface, int speed,
511511
int duplex)
512512
{
513-
struct macb *bp = container_of(pcs, struct macb, phylink_pcs);
513+
struct macb *bp = container_of(pcs, struct macb, phylink_usx_pcs);
514514
u32 config;
515515

516516
config = gem_readl(bp, USX_CONTROL);
@@ -524,7 +524,7 @@ static void macb_usx_pcs_link_up(struct phylink_pcs *pcs, unsigned int mode,
524524
static void macb_usx_pcs_get_state(struct phylink_pcs *pcs,
525525
struct phylink_link_state *state)
526526
{
527-
struct macb *bp = container_of(pcs, struct macb, phylink_pcs);
527+
struct macb *bp = container_of(pcs, struct macb, phylink_usx_pcs);
528528
u32 val;
529529

530530
state->speed = SPEED_10000;
@@ -544,7 +544,7 @@ static int macb_usx_pcs_config(struct phylink_pcs *pcs,
544544
const unsigned long *advertising,
545545
bool permit_pause_to_mac)
546546
{
547-
struct macb *bp = container_of(pcs, struct macb, phylink_pcs);
547+
struct macb *bp = container_of(pcs, struct macb, phylink_usx_pcs);
548548

549549
gem_writel(bp, USX_CONTROL, gem_readl(bp, USX_CONTROL) |
550550
GEM_BIT(SIGNAL_OK));
@@ -727,28 +727,23 @@ static void macb_mac_link_up(struct phylink_config *config,
727727
netif_tx_wake_all_queues(ndev);
728728
}
729729

730-
static int macb_mac_prepare(struct phylink_config *config, unsigned int mode,
731-
phy_interface_t interface)
730+
static struct phylink_pcs *macb_mac_select_pcs(struct phylink_config *config,
731+
phy_interface_t interface)
732732
{
733733
struct net_device *ndev = to_net_dev(config->dev);
734734
struct macb *bp = netdev_priv(ndev);
735735

736736
if (interface == PHY_INTERFACE_MODE_10GBASER)
737-
bp->phylink_pcs.ops = &macb_phylink_usx_pcs_ops;
737+
return &bp->phylink_usx_pcs;
738738
else if (interface == PHY_INTERFACE_MODE_SGMII)
739-
bp->phylink_pcs.ops = &macb_phylink_pcs_ops;
739+
return &bp->phylink_sgmii_pcs;
740740
else
741-
bp->phylink_pcs.ops = NULL;
742-
743-
if (bp->phylink_pcs.ops)
744-
phylink_set_pcs(bp->phylink, &bp->phylink_pcs);
745-
746-
return 0;
741+
return NULL;
747742
}
748743

749744
static const struct phylink_mac_ops macb_phylink_ops = {
750745
.validate = phylink_generic_validate,
751-
.mac_prepare = macb_mac_prepare,
746+
.mac_select_pcs = macb_mac_select_pcs,
752747
.mac_config = macb_mac_config,
753748
.mac_link_down = macb_mac_link_down,
754749
.mac_link_up = macb_mac_link_up,
@@ -806,6 +801,9 @@ static int macb_mii_probe(struct net_device *dev)
806801
{
807802
struct macb *bp = netdev_priv(dev);
808803

804+
bp->phylink_sgmii_pcs.ops = &macb_phylink_pcs_ops;
805+
bp->phylink_usx_pcs.ops = &macb_phylink_usx_pcs_ops;
806+
809807
bp->phylink_config.dev = &dev->dev;
810808
bp->phylink_config.type = PHYLINK_NETDEV;
811809

0 commit comments

Comments
 (0)