Lines Matching refs:mac
78 static bool dpaa2_mac_phy_mode_mismatch(struct dpaa2_mac *mac, in dpaa2_mac_phy_mode_mismatch() argument
90 return (interface != mac->if_mode); in dpaa2_mac_phy_mode_mismatch()
100 struct dpaa2_mac *mac = phylink_to_dpaa2_mac(config); in dpaa2_mac_validate() local
104 dpaa2_mac_phy_mode_mismatch(mac, state->interface)) { in dpaa2_mac_validate()
149 struct dpaa2_mac *mac = phylink_to_dpaa2_mac(config); in dpaa2_mac_config() local
150 struct dpmac_link_state *dpmac_state = &mac->state; in dpaa2_mac_config()
158 err = dpmac_set_link_state(mac->mc_io, 0, in dpaa2_mac_config()
159 mac->mc_dev->mc_handle, dpmac_state); in dpaa2_mac_config()
161 netdev_err(mac->net_dev, "%s: dpmac_set_link_state() = %d\n", in dpaa2_mac_config()
171 struct dpaa2_mac *mac = phylink_to_dpaa2_mac(config); in dpaa2_mac_link_up() local
172 struct dpmac_link_state *dpmac_state = &mac->state; in dpaa2_mac_link_up()
177 if (mac->if_link_type == DPMAC_LINK_TYPE_PHY) { in dpaa2_mac_link_up()
202 err = dpmac_set_link_state(mac->mc_io, 0, in dpaa2_mac_link_up()
203 mac->mc_dev->mc_handle, dpmac_state); in dpaa2_mac_link_up()
205 netdev_err(mac->net_dev, "%s: dpmac_set_link_state() = %d\n", in dpaa2_mac_link_up()
213 struct dpaa2_mac *mac = phylink_to_dpaa2_mac(config); in dpaa2_mac_link_down() local
214 struct dpmac_link_state *dpmac_state = &mac->state; in dpaa2_mac_link_down()
218 err = dpmac_set_link_state(mac->mc_io, 0, in dpaa2_mac_link_down()
219 mac->mc_dev->mc_handle, dpmac_state); in dpaa2_mac_link_down()
221 netdev_err(mac->net_dev, "dpmac_set_link_state() = %d\n", err); in dpaa2_mac_link_down()
257 static int dpaa2_pcs_create(struct dpaa2_mac *mac, in dpaa2_pcs_create() argument
266 netdev_warn(mac->net_dev, "pcs-handle node not found\n"); in dpaa2_pcs_create()
271 netdev_err(mac->net_dev, "pcs-handle node not available\n"); in dpaa2_pcs_create()
281 mac->pcs = lynx_pcs_create(mdiodev); in dpaa2_pcs_create()
282 if (!mac->pcs) { in dpaa2_pcs_create()
283 netdev_err(mac->net_dev, "lynx_pcs_create() failed\n"); in dpaa2_pcs_create()
291 static void dpaa2_pcs_destroy(struct dpaa2_mac *mac) in dpaa2_pcs_destroy() argument
293 struct lynx_pcs *pcs = mac->pcs; in dpaa2_pcs_destroy()
299 mac->pcs = NULL; in dpaa2_pcs_destroy()
303 int dpaa2_mac_connect(struct dpaa2_mac *mac) in dpaa2_mac_connect() argument
305 struct fsl_mc_device *dpmac_dev = mac->mc_dev; in dpaa2_mac_connect()
306 struct net_device *net_dev = mac->net_dev; in dpaa2_mac_connect()
312 err = dpmac_open(mac->mc_io, 0, dpmac_dev->obj_desc.id, in dpaa2_mac_connect()
319 err = dpmac_get_attributes(mac->mc_io, 0, dpmac_dev->mc_handle, &attr); in dpaa2_mac_connect()
325 mac->if_link_type = attr.link_type; in dpaa2_mac_connect()
339 mac->if_mode = err; in dpaa2_mac_connect()
346 (mac->if_mode == PHY_INTERFACE_MODE_RGMII_ID || in dpaa2_mac_connect()
347 mac->if_mode == PHY_INTERFACE_MODE_RGMII_RXID || in dpaa2_mac_connect()
348 mac->if_mode == PHY_INTERFACE_MODE_RGMII_TXID)) { in dpaa2_mac_connect()
356 err = dpaa2_pcs_create(mac, dpmac_node, attr.id); in dpaa2_mac_connect()
361 mac->phylink_config.dev = &net_dev->dev; in dpaa2_mac_connect()
362 mac->phylink_config.type = PHYLINK_NETDEV; in dpaa2_mac_connect()
364 phylink = phylink_create(&mac->phylink_config, in dpaa2_mac_connect()
365 of_fwnode_handle(dpmac_node), mac->if_mode, in dpaa2_mac_connect()
371 mac->phylink = phylink; in dpaa2_mac_connect()
373 if (mac->pcs) in dpaa2_mac_connect()
374 phylink_set_pcs(mac->phylink, &mac->pcs->pcs); in dpaa2_mac_connect()
376 err = phylink_of_phy_connect(mac->phylink, dpmac_node, 0); in dpaa2_mac_connect()
387 phylink_destroy(mac->phylink); in dpaa2_mac_connect()
389 dpaa2_pcs_destroy(mac); in dpaa2_mac_connect()
393 dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle); in dpaa2_mac_connect()
397 void dpaa2_mac_disconnect(struct dpaa2_mac *mac) in dpaa2_mac_disconnect() argument
399 if (!mac->phylink) in dpaa2_mac_disconnect()
402 phylink_disconnect_phy(mac->phylink); in dpaa2_mac_disconnect()
403 phylink_destroy(mac->phylink); in dpaa2_mac_disconnect()
404 dpaa2_pcs_destroy(mac); in dpaa2_mac_disconnect()
406 dpmac_close(mac->mc_io, 0, mac->mc_dev->mc_handle); in dpaa2_mac_disconnect()
458 void dpaa2_mac_get_ethtool_stats(struct dpaa2_mac *mac, u64 *data) in dpaa2_mac_get_ethtool_stats() argument
460 struct fsl_mc_device *dpmac_dev = mac->mc_dev; in dpaa2_mac_get_ethtool_stats()
465 err = dpmac_get_counter(mac->mc_io, 0, dpmac_dev->mc_handle, in dpaa2_mac_get_ethtool_stats()
468 netdev_err_once(mac->net_dev, in dpaa2_mac_get_ethtool_stats()