kernel: xt_FLOWOFFLOAD: fix use of uninitialized dir variable
[openwrt/openwrt.git] / target / linux / generic / hack-6.6 / 750-net-pcs-mtk-lynxi-workaround-2500BaseX-no-an.patch
1 From 880d1311335120f64447ca9d11933872d734e19a Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Mon, 27 Mar 2023 18:41:54 +0100
4 Subject: [PATCH] generic: pcs-mtk-lynxi: add hack to use 2500Base-X without AN
5
6 Using 2500Base-T SFP modules e.g. on the BananaPi R3 requires manually
7 disabling auto-negotiation, e.g. using ethtool. While a proper fix
8 using SFP quirks is being discussed upstream, bring a work-around to
9 restore user experience to what it was before the switch to the
10 dedicated SGMII PCS driver.
11
12 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
13
14 --- a/drivers/net/pcs/pcs-mtk-lynxi.c
15 +++ b/drivers/net/pcs/pcs-mtk-lynxi.c
16 @@ -114,14 +114,23 @@ static void mtk_pcs_lynxi_get_state(stru
17 struct phylink_link_state *state)
18 {
19 struct mtk_pcs_lynxi *mpcs = pcs_to_mtk_pcs_lynxi(pcs);
20 - unsigned int bm, adv;
21 + unsigned int bm, bmsr, adv;
22
23 /* Read the BMSR and LPA */
24 regmap_read(mpcs->regmap, SGMSYS_PCS_CONTROL_1, &bm);
25 - regmap_read(mpcs->regmap, SGMSYS_PCS_ADVERTISE, &adv);
26 + bmsr = FIELD_GET(SGMII_BMSR, bm);
27 +
28 + if (state->interface == PHY_INTERFACE_MODE_2500BASEX) {
29 + state->link = !!(bmsr & BMSR_LSTATUS);
30 + state->an_complete = !!(bmsr & BMSR_ANEGCOMPLETE);
31 + state->speed = SPEED_2500;
32 + state->duplex = DUPLEX_FULL;
33 +
34 + return;
35 + }
36
37 - phylink_mii_c22_pcs_decode_state(state, FIELD_GET(SGMII_BMSR, bm),
38 - FIELD_GET(SGMII_LPA, adv));
39 + regmap_read(mpcs->regmap, SGMSYS_PCS_ADVERTISE, &adv);
40 + phylink_mii_c22_pcs_decode_state(state, bmsr, FIELD_GET(SGMII_LPA, adv));
41 }
42
43 static void mtk_sgmii_reset(struct mtk_pcs_lynxi *mpcs)
44 @@ -142,7 +151,7 @@ static int mtk_pcs_lynxi_config(struct p
45 {
46 struct mtk_pcs_lynxi *mpcs = pcs_to_mtk_pcs_lynxi(pcs);
47 bool mode_changed = false, changed;
48 - unsigned int rgc3, sgm_mode, bmcr;
49 + unsigned int rgc3, sgm_mode, bmcr = 0;
50 int advertise, link_timer;
51
52 advertise = phylink_mii_c22_pcs_encode_advertisement(interface,
53 @@ -165,9 +174,8 @@ static int mtk_pcs_lynxi_config(struct p
54 if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) {
55 if (interface == PHY_INTERFACE_MODE_SGMII)
56 sgm_mode |= SGMII_SPEED_DUPLEX_AN;
57 - bmcr = BMCR_ANENABLE;
58 - } else {
59 - bmcr = 0;
60 + if (interface != PHY_INTERFACE_MODE_2500BASEX)
61 + bmcr = BMCR_ANENABLE;
62 }
63
64 if (mpcs->interface != interface) {