@@ -123,35 +123,16 @@ static void dpaa2_mac_config(struct phylink_config *config, unsigned int mode,
123
123
struct dpmac_link_state * dpmac_state = & mac -> state ;
124
124
int err ;
125
125
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
-
136
126
if (state -> an_enabled )
137
127
dpmac_state -> options |= DPMAC_LINK_OPT_AUTONEG ;
138
128
else
139
129
dpmac_state -> options &= ~DPMAC_LINK_OPT_AUTONEG ;
140
130
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
-
151
131
err = dpmac_set_link_state (mac -> mc_io , 0 ,
152
132
mac -> mc_dev -> mc_handle , dpmac_state );
153
133
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 );
155
136
}
156
137
157
138
static void dpaa2_mac_link_up (struct phylink_config * config ,
@@ -165,10 +146,37 @@ static void dpaa2_mac_link_up(struct phylink_config *config,
165
146
int err ;
166
147
167
148
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
+
168
175
err = dpmac_set_link_state (mac -> mc_io , 0 ,
169
176
mac -> mc_dev -> mc_handle , dpmac_state );
170
177
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 );
172
180
}
173
181
174
182
static void dpaa2_mac_link_down (struct phylink_config * config ,
@@ -241,6 +249,8 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
241
249
goto err_close_dpmac ;
242
250
}
243
251
252
+ mac -> if_link_type = attr .link_type ;
253
+
244
254
dpmac_node = dpaa2_mac_get_node (attr .id );
245
255
if (!dpmac_node ) {
246
256
netdev_err (net_dev , "No dpmac@%d node found.\n" , attr .id );
0 commit comments