mediatek: Add support for Xiaomi Redmi Router AX6S
[openwrt/openwrt.git] / target / linux / layerscape / patches-5.4 / 701-net-0178-staging-dpaa2-mac-add-link-up-down-events-for-dpmac.patch
1 From 3b07b109823a593f43e794cbf44ba3a84ceefbdb Mon Sep 17 00:00:00 2001
2 From: Florin Chiculita <florinlaurentiu.chiculita@nxp.com>
3 Date: Fri, 23 Aug 2019 18:02:27 +0300
4 Subject: [PATCH] staging: dpaa2-mac: add link up/down events for dpmac
5
6 Fix a limitation that affects the networking behavior when the user
7 issues ifconfig down/up on a DPNI and the link remains down.
8 The actual problem was that the mac driver was not aware of the
9 dpni link change event. Now, the event is sent by firmware and
10 phylib state machine is manipulated conveniently.
11
12 Signed-off-by: Florin Chiculita <florinlaurentiu.chiculita@nxp.com>
13 Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
14 ---
15 drivers/staging/fsl-dpaa2/mac/dpmac.h | 5 +++++
16 drivers/staging/fsl-dpaa2/mac/mac.c | 15 ++++++++++++---
17 2 files changed, 17 insertions(+), 3 deletions(-)
18
19 --- a/drivers/staging/fsl-dpaa2/mac/dpmac.h
20 +++ b/drivers/staging/fsl-dpaa2/mac/dpmac.h
21 @@ -124,6 +124,11 @@ int dpmac_destroy(struct fsl_mc_io *mc_i
22 * IRQ event - Indicates that the link state changed
23 */
24 #define DPMAC_IRQ_EVENT_LINK_CHANGED 0x00000002
25 +/**
26 + * IRQ event - Indicate if the phy needs to suspend or resume
27 + */
28 +#define DPMAC_IRQ_EVENT_LINK_UP_REQ 0x00000004
29 +#define DPMAC_IRQ_EVENT_LINK_DOWN_REQ 0x00000008
30
31 int dpmac_set_irq_enable(struct fsl_mc_io *mc_io,
32 u32 cmd_flags,
33 --- a/drivers/staging/fsl-dpaa2/mac/mac.c
34 +++ b/drivers/staging/fsl-dpaa2/mac/mac.c
35 @@ -181,6 +181,7 @@ static void dpaa2_mac_link_changed(struc
36 dev_err(&priv->mc_dev->dev, "dpmac_set_link_state: %d\n", err);
37 }
38
39 +#ifdef CONFIG_FSL_DPAA2_MAC_NETDEVS
40 static int dpaa2_mac_open(struct net_device *netdev)
41 {
42 /* start PHY state machine */
43 @@ -188,6 +189,7 @@ static int dpaa2_mac_open(struct net_dev
44
45 return 0;
46 }
47 +#endif
48
49 static int dpaa2_mac_stop(struct net_device *netdev)
50 {
51 @@ -450,6 +452,7 @@ static irqreturn_t dpaa2_mac_irq_handler
52 struct device *dev = (struct device *)arg;
53 struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
54 struct dpaa2_mac_priv *priv = dev_get_drvdata(dev);
55 + struct net_device *ndev = priv->netdev;
56 struct dpmac_link_cfg link_cfg = { 0 };
57 u32 status;
58 int err;
59 @@ -475,6 +478,12 @@ static irqreturn_t dpaa2_mac_irq_handler
60 configure_link(priv, &link_cfg);
61 }
62
63 + if (status & DPMAC_IRQ_EVENT_LINK_UP_REQ)
64 + phy_start(ndev->phydev);
65 +
66 + if (status & DPMAC_IRQ_EVENT_LINK_DOWN_REQ)
67 + phy_stop(ndev->phydev);
68 +
69 out:
70 dpmac_clear_irq_status(mc_dev->mc_io, 0, mc_dev->mc_handle,
71 DPMAC_IRQ_INDEX, status);
72 @@ -505,7 +514,9 @@ static int setup_irqs(struct fsl_mc_devi
73 }
74
75 err = dpmac_set_irq_mask(mc_dev->mc_io, 0, mc_dev->mc_handle,
76 - DPMAC_IRQ_INDEX, DPMAC_IRQ_EVENT_LINK_CFG_REQ);
77 + DPMAC_IRQ_INDEX, DPMAC_IRQ_EVENT_LINK_CFG_REQ |
78 + DPMAC_IRQ_EVENT_LINK_UP_REQ |
79 + DPMAC_IRQ_EVENT_LINK_DOWN_REQ);
80 if (err) {
81 dev_err(&mc_dev->dev, "dpmac_set_irq_mask err %d\n", err);
82 goto free_irq;
83 @@ -734,8 +745,6 @@ probe_fixed_link:
84 dev_info(dev, "Registered fixed PHY.\n");
85 }
86
87 - dpaa2_mac_open(netdev);
88 -
89 return 0;
90
91 err_no_if_mode: