aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-5.4/701-net-0110-sdk_dpaa-adapt-to-kernel-5.1.0-rc1.patch
blob: 72fa196479470caee51ab6b1f7e789b863393651 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
From 68b77d267414d790e5cbd76f46a77501559e5748 Mon Sep 17 00:00:00 2001
From: Camelia Groza <camelia.groza@nxp.com>
Date: Tue, 26 Mar 2019 18:27:11 +0200
Subject: [PATCH] sdk_dpaa: adapt to kernel 5.1.0 rc1

Apply fixes corresponding to the following upstream patches:
3c1bcc8 net: ethernet: Convert phydev advertize and supported from u32 to link mode
1e562c8 ptp_qoriq: make structure/function names more consistent
70814e8 net: ethernet: Add helper for set_pauseparam for Asym Pause
22b7d29 net: ethernet: Add helper to determine if pause configuration is supported

Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
---
 .../net/ethernet/freescale/sdk_dpaa/dpaa_ethtool.c | 31 +++-------------------
 drivers/net/ethernet/freescale/sdk_dpaa/mac-api.c  | 27 +++++++++----------
 2 files changed, 16 insertions(+), 42 deletions(-)

--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_ethtool.c
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_ethtool.c
@@ -225,7 +225,6 @@ static int __cold dpa_set_pauseparam(str
 	struct mac_device       *mac_dev;
 	struct phy_device       *phy_dev;
 	int _errno;
-	u32 newadv, oldadv;
 	bool rx_pause, tx_pause;
 
 	priv = netdev_priv(net_dev);
@@ -242,9 +241,7 @@ static int __cold dpa_set_pauseparam(str
 		return -ENODEV;
 	}
 
-	if (!(phy_dev->supported & SUPPORTED_Pause) ||
-			(!(phy_dev->supported & SUPPORTED_Asym_Pause) &&
-			(epause->rx_pause != epause->tx_pause)))
+	if (!phy_validate_pause(phy_dev, epause))
 		return -EINVAL;
 
 	/* The MAC should know how to handle PAUSE frame autonegotiation before
@@ -258,29 +255,7 @@ static int __cold dpa_set_pauseparam(str
 	/* Determine the sym/asym advertised PAUSE capabilities from the desired
 	 * rx/tx pause settings.
 	 */
-	newadv = 0;
-	if (epause->rx_pause)
-		newadv = ADVERTISED_Pause | ADVERTISED_Asym_Pause;
-	if (epause->tx_pause)
-		newadv |= ADVERTISED_Asym_Pause;
-
-	oldadv = phy_dev->advertising &
-			(ADVERTISED_Pause | ADVERTISED_Asym_Pause);
-
-	/* If there are differences between the old and the new advertised
-	 * values, restart PHY autonegotiation and advertise the new values.
-	 */
-	if (oldadv != newadv) {
-		phy_dev->advertising &= ~(ADVERTISED_Pause
-				| ADVERTISED_Asym_Pause);
-		phy_dev->advertising |= newadv;
-		if (phy_dev->autoneg) {
-			_errno = phy_start_aneg(phy_dev);
-			if (unlikely(_errno < 0))
-				netdev_err(net_dev, "phy_start_aneg() = %d\n",
-						_errno);
-		}
-	}
+	phy_set_asym_pause(phy_dev, epause->rx_pause, epause->tx_pause);
 
 	get_pause_cfg(mac_dev, &rx_pause, &tx_pause);
 	_errno = set_mac_active_pause(mac_dev, rx_pause, tx_pause);
@@ -530,7 +505,7 @@ static int dpaa_get_ts_info(struct net_d
 	struct device_node *mac_node = dev->of_node;
 	struct device_node *fman_node = NULL, *ptp_node = NULL;
 	struct platform_device *ptp_dev = NULL;
-	struct qoriq_ptp *ptp = NULL;
+	struct ptp_qoriq *ptp = NULL;
 
 	info->phc_index = -1;
 
--- a/drivers/net/ethernet/freescale/sdk_dpaa/mac-api.c
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/mac-api.c
@@ -385,11 +385,7 @@ void get_pause_cfg(struct mac_device *ma
 	 */
 
 	/* get local capabilities */
-	lcl_adv = 0;
-	if (phy_dev->advertising & ADVERTISED_Pause)
-		lcl_adv |= ADVERTISE_PAUSE_CAP;
-	if (phy_dev->advertising & ADVERTISED_Asym_Pause)
-		lcl_adv |= ADVERTISE_PAUSE_ASYM;
+	lcl_adv = linkmode_adv_to_lcl_adv_t(phy_dev->advertising);
 
 	/* get link partner capabilities */
 	rmt_adv = 0;
@@ -439,6 +435,7 @@ static int dtsec_init_phy(struct net_dev
 			  struct mac_device *mac_dev)
 {
 	struct phy_device	*phy_dev;
+	__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
 
 	if (of_phy_is_fixed_link(mac_dev->phy_node))
 		phy_dev = of_phy_attach(net_dev, mac_dev->phy_node,
@@ -455,12 +452,12 @@ static int dtsec_init_phy(struct net_dev
 	}
 
 	/* Remove any features not supported by the controller */
-	phy_dev->supported &= mac_dev->if_support;
+	ethtool_convert_legacy_u32_to_link_mode(mask, mac_dev->if_support);
+	linkmode_and(phy_dev->supported, phy_dev->supported, mask);
 	/* Enable the symmetric and asymmetric PAUSE frame advertisements,
 	 * as most of the PHY drivers do not enable them by default.
 	 */
-	phy_dev->supported |= (SUPPORTED_Pause | SUPPORTED_Asym_Pause);
-	phy_dev->advertising = phy_dev->supported;
+	phy_support_asym_pause(phy_dev);
 
 	mac_dev->phy_dev = phy_dev;
 
@@ -471,6 +468,7 @@ static int xgmac_init_phy(struct net_dev
 			  struct mac_device *mac_dev)
 {
 	struct phy_device *phy_dev;
+	__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
 
 	if (of_phy_is_fixed_link(mac_dev->phy_node))
 		phy_dev = of_phy_attach(net_dev, mac_dev->phy_node,
@@ -486,12 +484,12 @@ static int xgmac_init_phy(struct net_dev
 		return phy_dev == NULL ? -ENODEV : PTR_ERR(phy_dev);
 	}
 
-	phy_dev->supported &= mac_dev->if_support;
+	ethtool_convert_legacy_u32_to_link_mode(mask, mac_dev->if_support);
+	linkmode_and(phy_dev->supported, phy_dev->supported, mask);
 	/* Enable the symmetric and asymmetric PAUSE frame advertisements,
 	 * as most of the PHY drivers do not enable them by default.
 	 */
-	phy_dev->supported |= (SUPPORTED_Pause | SUPPORTED_Asym_Pause);
-	phy_dev->advertising = phy_dev->supported;
+	phy_support_asym_pause(phy_dev);
 
 	mac_dev->phy_dev = phy_dev;
 
@@ -502,6 +500,7 @@ static int memac_init_phy(struct net_dev
 			  struct mac_device *mac_dev)
 {
 	struct phy_device       *phy_dev;
+	__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
 	void (*adjust_link_handler)(struct net_device *);
 
 	if ((macdev2enetinterface(mac_dev) == e_ENET_MODE_XGMII_10000) ||
@@ -547,12 +546,12 @@ static int memac_init_phy(struct net_dev
 	}
 
 	/* Remove any features not supported by the controller */
-	phy_dev->supported &= mac_dev->if_support;
+	ethtool_convert_legacy_u32_to_link_mode(mask, mac_dev->if_support);
+	linkmode_and(phy_dev->supported, phy_dev->supported, mask);
 	/* Enable the symmetric and asymmetric PAUSE frame advertisements,
 	 * as most of the PHY drivers do not enable them by default.
 	 */
-	phy_dev->supported |= (SUPPORTED_Pause | SUPPORTED_Asym_Pause);
-	phy_dev->advertising = phy_dev->supported;
+	phy_support_asym_pause(phy_dev);
 
 	mac_dev->phy_dev = phy_dev;