@@ -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
157138static 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
174182static 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 );
0 commit comments