Skip to content

Commit 37556a4

Browse files
Russell Kingdavem330
authored andcommitted
net: dpaa2-mac: use resolved link config in mac_link_up()
Convert the DPAA2 ethernet driver to use the finalised link parameters in mac_link_up() rather than the parameters in mac_config(), which are more suited to the needs of the DPAA2 MC firmware than those available via mac_config(). Tested-by: Ioana Ciornei <[email protected]> Signed-off-by: Russell King <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9534784 commit 37556a4

File tree

2 files changed

+33
-22
lines changed

2 files changed

+33
-22
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -123,35 +123,16 @@ static void dpaa2_mac_config(struct phylink_config *config, unsigned int mode,
123123
struct dpmac_link_state *dpmac_state = &mac->state;
124124
int err;
125125

126-
if (state->speed != SPEED_UNKNOWN)
127-
dpmac_state->rate = state->speed;
128-
129-
if (state->duplex != DUPLEX_UNKNOWN) {
130-
if (!state->duplex)
131-
dpmac_state->options |= DPMAC_LINK_OPT_HALF_DUPLEX;
132-
else
133-
dpmac_state->options &= ~DPMAC_LINK_OPT_HALF_DUPLEX;
134-
}
135-
136126
if (state->an_enabled)
137127
dpmac_state->options |= DPMAC_LINK_OPT_AUTONEG;
138128
else
139129
dpmac_state->options &= ~DPMAC_LINK_OPT_AUTONEG;
140130

141-
if (state->pause & MLO_PAUSE_RX)
142-
dpmac_state->options |= DPMAC_LINK_OPT_PAUSE;
143-
else
144-
dpmac_state->options &= ~DPMAC_LINK_OPT_PAUSE;
145-
146-
if (!!(state->pause & MLO_PAUSE_RX) ^ !!(state->pause & MLO_PAUSE_TX))
147-
dpmac_state->options |= DPMAC_LINK_OPT_ASYM_PAUSE;
148-
else
149-
dpmac_state->options &= ~DPMAC_LINK_OPT_ASYM_PAUSE;
150-
151131
err = dpmac_set_link_state(mac->mc_io, 0,
152132
mac->mc_dev->mc_handle, dpmac_state);
153133
if (err)
154-
netdev_err(mac->net_dev, "dpmac_set_link_state() = %d\n", err);
134+
netdev_err(mac->net_dev, "%s: dpmac_set_link_state() = %d\n",
135+
__func__, err);
155136
}
156137

157138
static void dpaa2_mac_link_up(struct phylink_config *config,
@@ -165,10 +146,37 @@ static void dpaa2_mac_link_up(struct phylink_config *config,
165146
int err;
166147

167148
dpmac_state->up = 1;
149+
150+
if (mac->if_link_type == DPMAC_LINK_TYPE_PHY) {
151+
/* If the DPMAC is configured for PHY mode, we need
152+
* to pass the link parameters to the MC firmware.
153+
*/
154+
dpmac_state->rate = speed;
155+
156+
if (duplex == DUPLEX_HALF)
157+
dpmac_state->options |= DPMAC_LINK_OPT_HALF_DUPLEX;
158+
else if (duplex == DUPLEX_FULL)
159+
dpmac_state->options &= ~DPMAC_LINK_OPT_HALF_DUPLEX;
160+
161+
/* This is lossy; the firmware really should take the pause
162+
* enablement status rather than pause/asym pause status.
163+
*/
164+
if (rx_pause)
165+
dpmac_state->options |= DPMAC_LINK_OPT_PAUSE;
166+
else
167+
dpmac_state->options &= ~DPMAC_LINK_OPT_PAUSE;
168+
169+
if (rx_pause ^ tx_pause)
170+
dpmac_state->options |= DPMAC_LINK_OPT_ASYM_PAUSE;
171+
else
172+
dpmac_state->options &= ~DPMAC_LINK_OPT_ASYM_PAUSE;
173+
}
174+
168175
err = dpmac_set_link_state(mac->mc_io, 0,
169176
mac->mc_dev->mc_handle, dpmac_state);
170177
if (err)
171-
netdev_err(mac->net_dev, "dpmac_set_link_state() = %d\n", err);
178+
netdev_err(mac->net_dev, "%s: dpmac_set_link_state() = %d\n",
179+
__func__, err);
172180
}
173181

174182
static void dpaa2_mac_link_down(struct phylink_config *config,
@@ -241,6 +249,8 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
241249
goto err_close_dpmac;
242250
}
243251

252+
mac->if_link_type = attr.link_type;
253+
244254
dpmac_node = dpaa2_mac_get_node(attr.id);
245255
if (!dpmac_node) {
246256
netdev_err(net_dev, "No dpmac@%d node found.\n", attr.id);

drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ struct dpaa2_mac {
2020
struct phylink_config phylink_config;
2121
struct phylink *phylink;
2222
phy_interface_t if_mode;
23+
enum dpmac_link_type if_link_type;
2324
};
2425

2526
bool dpaa2_mac_is_type_fixed(struct fsl_mc_device *dpmac_dev,

0 commit comments

Comments
 (0)