kernel: backport phylink changes from mainline Linux
[openwrt/staging/pepe2k.git] / target / linux / generic / backport-6.1 / 792-v6.6-net-phylink-add-pcs_enable-pcs_disable-methods.patch
index 893a81246d8811139c3a42f0a3e7e98373bd245a..f82c8fc622b99d21a79879a5d9b9ca3f48c9e932 100644 (file)
@@ -27,15 +27,15 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
  };
  
  /**
-@@ -71,6 +75,7 @@ struct phylink {
-       struct mutex state_mutex;
+@@ -72,6 +76,7 @@ struct phylink {
        struct phylink_link_state phy_state;
        struct work_struct resolve;
+       unsigned int pcs_neg_mode;
 +      unsigned int pcs_state;
  
        bool mac_link_dropped;
        bool using_mac_select_pcs;
-@@ -990,6 +995,22 @@ static void phylink_mac_pcs_an_restart(s
+@@ -992,6 +997,22 @@ static void phylink_resolve_an_pause(str
        }
  }
  
@@ -55,16 +55,17 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
 +      return err;
 +}
 +
- static void phylink_major_config(struct phylink *pl, bool restart,
-                                 const struct phylink_link_state *state)
- {
-@@ -1026,11 +1047,16 @@ static void phylink_major_config(struct
+ static int phylink_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
+                             const struct phylink_link_state *state,
+                             bool permit_pause_to_mac)
+@@ -1094,11 +1115,17 @@ static void phylink_major_config(struct
        /* If we have a new PCS, switch to the new PCS after preparing the MAC
         * for the change.
         */
 -      if (pcs_changed)
 +      if (pcs_changed) {
 +              phylink_pcs_disable(pl->pcs);
++
                pl->pcs = pcs;
 +      }
  
@@ -73,18 +74,18 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
 +      if (pl->pcs_state == PCS_STATE_STARTING || pcs_changed)
 +              phylink_pcs_enable(pl->pcs);
 +
-       if (pl->pcs) {
-               err = pl->pcs->ops->pcs_config(pl->pcs, pl->cur_link_an_mode,
-                                              state->interface,
-@@ -1502,6 +1528,7 @@ struct phylink *phylink_create(struct ph
+       neg_mode = pl->cur_link_an_mode;
+       if (pl->pcs && pl->pcs->neg_mode)
+               neg_mode = pl->pcs_neg_mode;
+@@ -1586,6 +1613,7 @@ struct phylink *phylink_create(struct ph
+       pl->link_config.pause = MLO_PAUSE_AN;
        pl->link_config.speed = SPEED_UNKNOWN;
        pl->link_config.duplex = DUPLEX_UNKNOWN;
-       pl->link_config.an_enabled = true;
 +      pl->pcs_state = PCS_STATE_DOWN;
        pl->mac_ops = mac_ops;
        __set_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state);
        timer_setup(&pl->link_poll, phylink_fixed_poll, 0);
-@@ -1903,6 +1930,8 @@ void phylink_start(struct phylink *pl)
+@@ -1987,6 +2015,8 @@ void phylink_start(struct phylink *pl)
        if (pl->netdev)
                netif_carrier_off(pl->netdev);
  
@@ -93,7 +94,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
        /* Apply the link configuration to the MAC when starting. This allows
         * a fixed-link to start with the correct parameters, and also
         * ensures that we set the appropriate advertisement for Serdes links.
-@@ -1913,6 +1942,8 @@ void phylink_start(struct phylink *pl)
+@@ -1997,6 +2027,8 @@ void phylink_start(struct phylink *pl)
         */
        phylink_mac_initial_config(pl, true);
  
@@ -102,7 +103,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
        phylink_enable_and_run_resolve(pl, PHYLINK_DISABLE_STOPPED);
  
        if (pl->cfg_link_an_mode == MLO_AN_FIXED && pl->link_gpio) {
-@@ -1931,15 +1962,9 @@ void phylink_start(struct phylink *pl)
+@@ -2015,15 +2047,9 @@ void phylink_start(struct phylink *pl)
                        poll = true;
        }
  
@@ -120,7 +121,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
        if (poll)
                mod_timer(&pl->link_poll, jiffies + HZ);
        if (pl->phydev)
-@@ -1976,6 +2001,10 @@ void phylink_stop(struct phylink *pl)
+@@ -2060,6 +2086,10 @@ void phylink_stop(struct phylink *pl)
        }
  
        phylink_run_resolve_and_disable(pl, PHYLINK_DISABLE_STOPPED);
@@ -133,7 +134,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
  
 --- a/include/linux/phylink.h
 +++ b/include/linux/phylink.h
-@@ -446,6 +446,8 @@ struct phylink_pcs {
+@@ -533,6 +533,8 @@ struct phylink_pcs {
  /**
   * struct phylink_pcs_ops - MAC PCS operations structure.
   * @pcs_validate: validate the link configuration.
@@ -142,7 +143,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
   * @pcs_get_state: read the current MAC PCS link state from the hardware.
   * @pcs_config: configure the MAC PCS for the selected mode and state.
   * @pcs_an_restart: restart 802.3z BaseX autonegotiation.
-@@ -455,6 +457,8 @@ struct phylink_pcs {
+@@ -542,6 +544,8 @@ struct phylink_pcs {
  struct phylink_pcs_ops {
        int (*pcs_validate)(struct phylink_pcs *pcs, unsigned long *supported,
                            const struct phylink_link_state *state);
@@ -150,8 +151,8 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
 +      void (*pcs_disable)(struct phylink_pcs *pcs);
        void (*pcs_get_state)(struct phylink_pcs *pcs,
                              struct phylink_link_state *state);
-       int (*pcs_config)(struct phylink_pcs *pcs, unsigned int mode,
-@@ -485,6 +489,18 @@ int pcs_validate(struct phylink_pcs *pcs
+       int (*pcs_config)(struct phylink_pcs *pcs, unsigned int neg_mode,
+@@ -572,6 +576,18 @@ int pcs_validate(struct phylink_pcs *pcs
                 const struct phylink_link_state *state);
  
  /**