net: phylink: rename mac_link_state() op to mac_pcs_get_state()
authorRussell King <rmk+kernel@armlinux.org.uk>
Thu, 21 Nov 2019 00:36:22 +0000 (00:36 +0000)
committerJakub Kicinski <jakub.kicinski@netronome.com>
Sun, 24 Nov 2019 00:13:39 +0000 (16:13 -0800)
Rename the mac_link_state() method to mac_pcs_get_state() to make it
clear that it should be returning the MACs PCS current state, which
is used for inband negotiation rather than just reading back what the
MAC has been configured for. Update the documentation to explicitly
mention that this is for inband.

We drop the return value as well; most of phylink doesn't check the
return value and it is not clear what it should do on error - instead
arrange for state->link to be false.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
drivers/net/ethernet/cadence/macb_main.c
drivers/net/ethernet/marvell/mvneta.c
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
drivers/net/ethernet/mediatek/mtk_eth_soc.c
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ethernet/xilinx/xilinx_axienet_main.c
drivers/net/phy/phylink.c
include/linux/phylink.h
net/dsa/dsa_priv.h
net/dsa/port.c

index 8fc2e21f0bb1a59a5d890f604161b5b1c0b8b504..d5ae2e1e0b0e249d305cb10d1c69abba8f16be45 100644 (file)
@@ -505,10 +505,10 @@ static void macb_validate(struct phylink_config *config,
                   __ETHTOOL_LINK_MODE_MASK_NBITS);
 }
 
-static int macb_mac_link_state(struct phylink_config *config,
-                              struct phylink_link_state *state)
+static void macb_mac_pcs_get_state(struct phylink_config *config,
+                                  struct phylink_link_state *state)
 {
-       return -EOPNOTSUPP;
+       state->link = 0;
 }
 
 static void macb_mac_an_restart(struct phylink_config *config)
@@ -604,7 +604,7 @@ static void macb_mac_link_up(struct phylink_config *config, unsigned int mode,
 
 static const struct phylink_mac_ops macb_phylink_ops = {
        .validate = macb_validate,
-       .mac_link_state = macb_mac_link_state,
+       .mac_pcs_get_state = macb_mac_pcs_get_state,
        .mac_an_restart = macb_mac_an_restart,
        .mac_config = macb_mac_config,
        .mac_link_down = macb_mac_link_down,
index a06d109c9e808ea2a803b5985d662de9edc3d964..71a872d46bc487ea3a9113e03b8ccaec89f2c0f8 100644 (file)
@@ -3694,8 +3694,8 @@ static void mvneta_validate(struct phylink_config *config,
        phylink_helper_basex_speed(state);
 }
 
-static int mvneta_mac_link_state(struct phylink_config *config,
-                                struct phylink_link_state *state)
+static void mvneta_mac_pcs_get_state(struct phylink_config *config,
+                                    struct phylink_link_state *state)
 {
        struct net_device *ndev = to_net_dev(config->dev);
        struct mvneta_port *pp = netdev_priv(ndev);
@@ -3721,8 +3721,6 @@ static int mvneta_mac_link_state(struct phylink_config *config,
                state->pause |= MLO_PAUSE_RX;
        if (gmac_stat & MVNETA_GMAC_TX_FLOW_CTRL_ENABLE)
                state->pause |= MLO_PAUSE_TX;
-
-       return 1;
 }
 
 static void mvneta_mac_an_restart(struct phylink_config *config)
@@ -3915,7 +3913,7 @@ static void mvneta_mac_link_up(struct phylink_config *config, unsigned int mode,
 
 static const struct phylink_mac_ops mvneta_phylink_ops = {
        .validate = mvneta_validate,
-       .mac_link_state = mvneta_mac_link_state,
+       .mac_pcs_get_state = mvneta_mac_pcs_get_state,
        .mac_an_restart = mvneta_mac_an_restart,
        .mac_config = mvneta_mac_config,
        .mac_link_down = mvneta_mac_link_down,
index 17e24c1e1c2bd59bc2635458fbd84d6b3252c4cb..62dc2f362a1699a3cfaeccdee79f33e77198f9bd 100644 (file)
@@ -4823,8 +4823,8 @@ empty_set:
        bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
 }
 
-static void mvpp22_xlg_link_state(struct mvpp2_port *port,
-                                 struct phylink_link_state *state)
+static void mvpp22_xlg_pcs_get_state(struct mvpp2_port *port,
+                                    struct phylink_link_state *state)
 {
        u32 val;
 
@@ -4843,8 +4843,8 @@ static void mvpp22_xlg_link_state(struct mvpp2_port *port,
                state->pause |= MLO_PAUSE_RX;
 }
 
-static void mvpp2_gmac_link_state(struct mvpp2_port *port,
-                                 struct phylink_link_state *state)
+static void mvpp2_gmac_pcs_get_state(struct mvpp2_port *port,
+                                    struct phylink_link_state *state)
 {
        u32 val;
 
@@ -4877,8 +4877,8 @@ static void mvpp2_gmac_link_state(struct mvpp2_port *port,
                state->pause |= MLO_PAUSE_TX;
 }
 
-static int mvpp2_phylink_mac_link_state(struct phylink_config *config,
-                                       struct phylink_link_state *state)
+static void mvpp2_phylink_mac_pcs_get_state(struct phylink_config *config,
+                                           struct phylink_link_state *state)
 {
        struct mvpp2_port *port = container_of(config, struct mvpp2_port,
                                               phylink_config);
@@ -4888,13 +4888,12 @@ static int mvpp2_phylink_mac_link_state(struct phylink_config *config,
                mode &= MVPP22_XLG_CTRL3_MACMODESELECT_MASK;
 
                if (mode == MVPP22_XLG_CTRL3_MACMODESELECT_10G) {
-                       mvpp22_xlg_link_state(port, state);
-                       return 1;
+                       mvpp22_xlg_pcs_get_state(port, state);
+                       return;
                }
        }
 
-       mvpp2_gmac_link_state(port, state);
-       return 1;
+       mvpp2_gmac_pcs_get_state(port, state);
 }
 
 static void mvpp2_mac_an_restart(struct phylink_config *config)
@@ -5186,7 +5185,7 @@ static void mvpp2_mac_link_down(struct phylink_config *config,
 
 static const struct phylink_mac_ops mvpp2_phylink_ops = {
        .validate = mvpp2_phylink_validate,
-       .mac_link_state = mvpp2_phylink_mac_link_state,
+       .mac_pcs_get_state = mvpp2_phylink_mac_pcs_get_state,
        .mac_an_restart = mvpp2_mac_an_restart,
        .mac_config = mvpp2_mac_config,
        .mac_link_up = mvpp2_mac_link_up,
index 1923ba76a1ecb6f0547c76a28efaa26d6a27adcc..527ad2aadccadbdd1e894833befc62ee3d10e71a 100644 (file)
@@ -361,8 +361,8 @@ init_err:
                mac->id, phy_modes(state->interface), err);
 }
 
-static int mtk_mac_link_state(struct phylink_config *config,
-                             struct phylink_link_state *state)
+static void mtk_mac_pcs_get_state(struct phylink_config *config,
+                                 struct phylink_link_state *state)
 {
        struct mtk_mac *mac = container_of(config, struct mtk_mac,
                                           phylink_config);
@@ -391,8 +391,6 @@ static int mtk_mac_link_state(struct phylink_config *config,
                state->pause |= MLO_PAUSE_RX;
        if (pmsr & MAC_MSR_TX_FC)
                state->pause |= MLO_PAUSE_TX;
-
-       return 1;
 }
 
 static void mtk_mac_an_restart(struct phylink_config *config)
@@ -514,7 +512,7 @@ static void mtk_validate(struct phylink_config *config,
 
 static const struct phylink_mac_ops mtk_phylink_ops = {
        .validate = mtk_validate,
-       .mac_link_state = mtk_mac_link_state,
+       .mac_pcs_get_state = mtk_mac_pcs_get_state,
        .mac_an_restart = mtk_mac_an_restart,
        .mac_config = mtk_mac_config,
        .mac_link_down = mtk_mac_link_down,
index 8cc4cd0cc51571f785d7539b6d8348f8dec72961..644cb5d1fd4f4a4ff9652c4debfe50b6bd2c3694 100644 (file)
@@ -868,10 +868,10 @@ static void stmmac_validate(struct phylink_config *config,
                      __ETHTOOL_LINK_MODE_MASK_NBITS);
 }
 
-static int stmmac_mac_link_state(struct phylink_config *config,
-                                struct phylink_link_state *state)
+static void stmmac_mac_pcs_get_state(struct phylink_config *config,
+                                    struct phylink_link_state *state)
 {
-       return -EOPNOTSUPP;
+       state->link = 0;
 }
 
 static void stmmac_mac_config(struct phylink_config *config, unsigned int mode,
@@ -965,7 +965,7 @@ static void stmmac_mac_link_up(struct phylink_config *config,
 
 static const struct phylink_mac_ops stmmac_phylink_mac_ops = {
        .validate = stmmac_validate,
-       .mac_link_state = stmmac_mac_link_state,
+       .mac_pcs_get_state = stmmac_mac_pcs_get_state,
        .mac_config = stmmac_mac_config,
        .mac_an_restart = stmmac_mac_an_restart,
        .mac_link_down = stmmac_mac_link_down,
index 8f32db6d2c454614c8b7193c8d9f15f5901152bb..20746b8019596f82ad3d0920de23b9054280bfff 100644 (file)
@@ -1405,8 +1405,8 @@ static void axienet_validate(struct phylink_config *config,
                   __ETHTOOL_LINK_MODE_MASK_NBITS);
 }
 
-static int axienet_mac_link_state(struct phylink_config *config,
-                                 struct phylink_link_state *state)
+static void axienet_mac_pcs_get_state(struct phylink_config *config,
+                                     struct phylink_link_state *state)
 {
        struct net_device *ndev = to_net_dev(config->dev);
        struct axienet_local *lp = netdev_priv(ndev);
@@ -1431,8 +1431,6 @@ static int axienet_mac_link_state(struct phylink_config *config,
 
        state->an_complete = 0;
        state->duplex = 1;
-
-       return 1;
 }
 
 static void axienet_mac_an_restart(struct phylink_config *config)
@@ -1497,7 +1495,7 @@ static void axienet_mac_link_up(struct phylink_config *config,
 
 static const struct phylink_mac_ops axienet_phylink_ops = {
        .validate = axienet_validate,
-       .mac_link_state = axienet_mac_link_state,
+       .mac_pcs_get_state = axienet_mac_pcs_get_state,
        .mac_an_restart = axienet_mac_an_restart,
        .mac_config = axienet_mac_config,
        .mac_link_down = axienet_mac_link_down,
index 8e2a128857896cef417175e9549a4b0a2e3b923e..9a616d6bc4eb22dfd484a69f48b12ba077eca393 100644 (file)
@@ -357,9 +357,9 @@ static void phylink_mac_an_restart(struct phylink *pl)
                pl->ops->mac_an_restart(pl->config);
 }
 
-static int phylink_get_mac_state(struct phylink *pl, struct phylink_link_state *state)
+static void phylink_mac_pcs_get_state(struct phylink *pl,
+                                     struct phylink_link_state *state)
 {
-
        linkmode_copy(state->advertising, pl->link_config.advertising);
        linkmode_zero(state->lp_advertising);
        state->interface = pl->link_config.interface;
@@ -370,7 +370,7 @@ static int phylink_get_mac_state(struct phylink *pl, struct phylink_link_state *
        state->an_complete = 0;
        state->link = 1;
 
-       return pl->ops->mac_link_state(pl->config, state);
+       pl->ops->mac_pcs_get_state(pl->config, state);
 }
 
 /* The fixed state is... fixed except for the link state,
@@ -493,7 +493,7 @@ static void phylink_resolve(struct work_struct *w)
                        break;
 
                case MLO_AN_INBAND:
-                       phylink_get_mac_state(pl, &link_state);
+                       phylink_mac_pcs_get_state(pl, &link_state);
 
                        /* If we have a phy, the "up" state is the union of
                         * both the PHY and the MAC */
@@ -1142,7 +1142,7 @@ int phylink_ethtool_ksettings_get(struct phylink *pl,
                if (pl->phydev)
                        break;
 
-               phylink_get_mac_state(pl, &link_state);
+               phylink_mac_pcs_get_state(pl, &link_state);
 
                /* The MAC is reporting the link results from its own PCS
                 * layer via in-band status. Report these as the current
@@ -1561,10 +1561,7 @@ static int phylink_mii_read(struct phylink *pl, unsigned int phy_id,
 
        case MLO_AN_INBAND:
                if (phy_id == 0) {
-                       val = phylink_get_mac_state(pl, &state);
-                       if (val < 0)
-                               return val;
-
+                       phylink_mac_pcs_get_state(pl, &state);
                        val = phylink_mii_emul_read(reg, &state);
                }
                break;
index 300ecdb6790a7ae8655e74bd43e6cf8e991c67fe..fed5488e3c75857e5b391ab5a87f4b3a8c1bf97c 100644 (file)
@@ -72,7 +72,7 @@ struct phylink_config {
 /**
  * struct phylink_mac_ops - MAC operations structure.
  * @validate: Validate and update the link configuration.
- * @mac_link_state: Read the current link state from the hardware.
+ * @mac_pcs_get_state: Read the current link state from the hardware.
  * @mac_config: configure the MAC for the selected mode and state.
  * @mac_an_restart: restart 802.3z BaseX autonegotiation.
  * @mac_link_down: take the link down.
@@ -84,8 +84,8 @@ struct phylink_mac_ops {
        void (*validate)(struct phylink_config *config,
                         unsigned long *supported,
                         struct phylink_link_state *state);
-       int (*mac_link_state)(struct phylink_config *config,
-                             struct phylink_link_state *state);
+       void (*mac_pcs_get_state)(struct phylink_config *config,
+                                 struct phylink_link_state *state);
        void (*mac_config)(struct phylink_config *config, unsigned int mode,
                           const struct phylink_link_state *state);
        void (*mac_an_restart)(struct phylink_config *config);
@@ -127,18 +127,19 @@ void validate(struct phylink_config *config, unsigned long *supported,
              struct phylink_link_state *state);
 
 /**
- * mac_link_state() - Read the current link state from the hardware
+ * mac_pcs_get_state() - Read the current inband link state from the hardware
  * @config: a pointer to a &struct phylink_config.
  * @state: a pointer to a &struct phylink_link_state.
  *
- * Read the current link state from the MAC, reporting the current
- * speed in @state->speed, duplex mode in @state->duplex, pause mode
- * in @state->pause using the %MLO_PAUSE_RX and %MLO_PAUSE_TX bits,
- * negotiation completion state in @state->an_complete, and link
- * up state in @state->link.
+ * Read the current inband link state from the MAC PCS, reporting the
+ * current speed in @state->speed, duplex mode in @state->duplex, pause
+ * mode in @state->pause using the %MLO_PAUSE_RX and %MLO_PAUSE_TX bits,
+ * negotiation completion state in @state->an_complete, and link up state
+ * in @state->link. If possible, @state->lp_advertising should also be
+ * populated.
  */
-int mac_link_state(struct phylink_config *config,
-                  struct phylink_link_state *state);
+void mac_pcs_get_state(struct phylink_config *config,
+                      struct phylink_link_state *state);
 
 /**
  * mac_config() - configure the MAC for the selected mode and state
@@ -166,7 +167,7 @@ int mac_link_state(struct phylink_config *config,
  *   1000base-X or Cisco SGMII mode depending on the @state->interface
  *   mode). In both cases, link state management (whether the link
  *   is up or not) is performed by the MAC, and reported via the
- *   mac_link_state() callback. Changes in link state must be made
+ *   mac_pcs_get_state() callback. Changes in link state must be made
  *   by calling phylink_mac_change().
  *
  *   If in 802.3z mode, the link speed is fixed, dependent on the
index 53e7577896b6568e6cb7b84c23c1d9c08ef7f2c4..2dd86d9bcda91441c6368f9d13a960d533eee9cc 100644 (file)
@@ -153,8 +153,8 @@ void dsa_port_link_unregister_of(struct dsa_port *dp);
 void dsa_port_phylink_validate(struct phylink_config *config,
                               unsigned long *supported,
                               struct phylink_link_state *state);
-int dsa_port_phylink_mac_link_state(struct phylink_config *config,
-                                   struct phylink_link_state *state);
+void dsa_port_phylink_mac_pcs_get_state(struct phylink_config *config,
+                                       struct phylink_link_state *state);
 void dsa_port_phylink_mac_config(struct phylink_config *config,
                                 unsigned int mode,
                                 const struct phylink_link_state *state);
index 6e93c36bf0c07cefca3fc65d4f8913dc57acbced..46ac9ba219871c4c86b360b2e83fd550f77e11d0 100644 (file)
@@ -429,19 +429,22 @@ void dsa_port_phylink_validate(struct phylink_config *config,
 }
 EXPORT_SYMBOL_GPL(dsa_port_phylink_validate);
 
-int dsa_port_phylink_mac_link_state(struct phylink_config *config,
-                                   struct phylink_link_state *state)
+void dsa_port_phylink_mac_pcs_get_state(struct phylink_config *config,
+                                       struct phylink_link_state *state)
 {
        struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
        struct dsa_switch *ds = dp->ds;
 
-       /* Only called for SGMII and 802.3z */
-       if (!ds->ops->phylink_mac_link_state)
-               return -EOPNOTSUPP;
+       /* Only called for inband modes */
+       if (!ds->ops->phylink_mac_link_state) {
+               state->link = 0;
+               return;
+       }
 
-       return ds->ops->phylink_mac_link_state(ds, dp->index, state);
+       if (ds->ops->phylink_mac_link_state(ds, dp->index, state) < 0)
+               state->link = 0;
 }
-EXPORT_SYMBOL_GPL(dsa_port_phylink_mac_link_state);
+EXPORT_SYMBOL_GPL(dsa_port_phylink_mac_pcs_get_state);
 
 void dsa_port_phylink_mac_config(struct phylink_config *config,
                                 unsigned int mode,
@@ -510,7 +513,7 @@ EXPORT_SYMBOL_GPL(dsa_port_phylink_mac_link_up);
 
 const struct phylink_mac_ops dsa_port_phylink_mac_ops = {
        .validate = dsa_port_phylink_validate,
-       .mac_link_state = dsa_port_phylink_mac_link_state,
+       .mac_pcs_get_state = dsa_port_phylink_mac_pcs_get_state,
        .mac_config = dsa_port_phylink_mac_config,
        .mac_an_restart = dsa_port_phylink_mac_an_restart,
        .mac_link_down = dsa_port_phylink_mac_link_down,