Lines Matching refs:mac

93 static bool dpaa2_mac_phy_mode_mismatch(struct dpaa2_mac *mac,  in dpaa2_mac_phy_mode_mismatch()  argument
102 if (mac->pcs && in dpaa2_mac_phy_mode_mismatch()
103 (mac->if_mode == PHY_INTERFACE_MODE_SGMII || in dpaa2_mac_phy_mode_mismatch()
104 mac->if_mode == PHY_INTERFACE_MODE_1000BASEX)) in dpaa2_mac_phy_mode_mismatch()
106 return interface != mac->if_mode; in dpaa2_mac_phy_mode_mismatch()
115 return (interface != mac->if_mode); in dpaa2_mac_phy_mode_mismatch()
125 struct dpaa2_mac *mac = phylink_to_dpaa2_mac(config); in dpaa2_mac_validate() local
129 dpaa2_mac_phy_mode_mismatch(mac, state->interface)) { in dpaa2_mac_validate()
178 struct dpaa2_mac *mac = phylink_to_dpaa2_mac(config); in dpaa2_mac_config() local
179 struct dpmac_link_state *dpmac_state = &mac->state; in dpaa2_mac_config()
187 err = dpmac_set_link_state(mac->mc_io, 0, in dpaa2_mac_config()
188 mac->mc_dev->mc_handle, dpmac_state); in dpaa2_mac_config()
190 netdev_err(mac->net_dev, "%s: dpmac_set_link_state() = %d\n", in dpaa2_mac_config()
200 struct dpaa2_mac *mac = phylink_to_dpaa2_mac(config); in dpaa2_mac_link_up() local
201 struct dpmac_link_state *dpmac_state = &mac->state; in dpaa2_mac_link_up()
223 err = dpmac_set_link_state(mac->mc_io, 0, in dpaa2_mac_link_up()
224 mac->mc_dev->mc_handle, dpmac_state); in dpaa2_mac_link_up()
226 netdev_err(mac->net_dev, "%s: dpmac_set_link_state() = %d\n", in dpaa2_mac_link_up()
234 struct dpaa2_mac *mac = phylink_to_dpaa2_mac(config); in dpaa2_mac_link_down() local
235 struct dpmac_link_state *dpmac_state = &mac->state; in dpaa2_mac_link_down()
239 err = dpmac_set_link_state(mac->mc_io, 0, in dpaa2_mac_link_down()
240 mac->mc_dev->mc_handle, dpmac_state); in dpaa2_mac_link_down()
242 netdev_err(mac->net_dev, "dpmac_set_link_state() = %d\n", err); in dpaa2_mac_link_down()
252 static int dpaa2_pcs_create(struct dpaa2_mac *mac, in dpaa2_pcs_create() argument
262 netdev_warn(mac->net_dev, "pcs-handle node not found\n"); in dpaa2_pcs_create()
267 netdev_err(mac->net_dev, "pcs-handle node not available\n"); in dpaa2_pcs_create()
277 mac->pcs = lynx_pcs_create(mdiodev); in dpaa2_pcs_create()
278 if (!mac->pcs) { in dpaa2_pcs_create()
279 netdev_err(mac->net_dev, "lynx_pcs_create() failed\n"); in dpaa2_pcs_create()
287 static void dpaa2_pcs_destroy(struct dpaa2_mac *mac) in dpaa2_pcs_destroy() argument
289 struct lynx_pcs *pcs = mac->pcs; in dpaa2_pcs_destroy()
295 mac->pcs = NULL; in dpaa2_pcs_destroy()
299 int dpaa2_mac_connect(struct dpaa2_mac *mac) in dpaa2_mac_connect() argument
301 struct net_device *net_dev = mac->net_dev; in dpaa2_mac_connect()
306 mac->if_link_type = mac->attr.link_type; in dpaa2_mac_connect()
308 dpmac_node = mac->fw_node; in dpaa2_mac_connect()
310 netdev_err(net_dev, "No dpmac@%d node found.\n", mac->attr.id); in dpaa2_mac_connect()
314 err = dpaa2_mac_get_if_mode(dpmac_node, mac->attr); in dpaa2_mac_connect()
317 mac->if_mode = err; in dpaa2_mac_connect()
324 (mac->if_mode == PHY_INTERFACE_MODE_RGMII_ID || in dpaa2_mac_connect()
325 mac->if_mode == PHY_INTERFACE_MODE_RGMII_RXID || in dpaa2_mac_connect()
326 mac->if_mode == PHY_INTERFACE_MODE_RGMII_TXID)) { in dpaa2_mac_connect()
331 if ((mac->attr.link_type == DPMAC_LINK_TYPE_PHY && in dpaa2_mac_connect()
332 mac->attr.eth_if != DPMAC_ETH_IF_RGMII) || in dpaa2_mac_connect()
333 mac->attr.link_type == DPMAC_LINK_TYPE_BACKPLANE) { in dpaa2_mac_connect()
334 err = dpaa2_pcs_create(mac, dpmac_node, mac->attr.id); in dpaa2_mac_connect()
339 mac->phylink_config.dev = &net_dev->dev; in dpaa2_mac_connect()
340 mac->phylink_config.type = PHYLINK_NETDEV; in dpaa2_mac_connect()
342 phylink = phylink_create(&mac->phylink_config, in dpaa2_mac_connect()
343 dpmac_node, mac->if_mode, in dpaa2_mac_connect()
349 mac->phylink = phylink; in dpaa2_mac_connect()
351 if (mac->pcs) in dpaa2_mac_connect()
352 phylink_set_pcs(mac->phylink, &mac->pcs->pcs); in dpaa2_mac_connect()
354 err = phylink_fwnode_phy_connect(mac->phylink, dpmac_node, 0); in dpaa2_mac_connect()
363 phylink_destroy(mac->phylink); in dpaa2_mac_connect()
365 dpaa2_pcs_destroy(mac); in dpaa2_mac_connect()
370 void dpaa2_mac_disconnect(struct dpaa2_mac *mac) in dpaa2_mac_disconnect() argument
372 if (!mac->phylink) in dpaa2_mac_disconnect()
375 phylink_disconnect_phy(mac->phylink); in dpaa2_mac_disconnect()
376 phylink_destroy(mac->phylink); in dpaa2_mac_disconnect()
377 dpaa2_pcs_destroy(mac); in dpaa2_mac_disconnect()
380 int dpaa2_mac_open(struct dpaa2_mac *mac) in dpaa2_mac_open() argument
382 struct fsl_mc_device *dpmac_dev = mac->mc_dev; in dpaa2_mac_open()
383 struct net_device *net_dev = mac->net_dev; in dpaa2_mac_open()
386 err = dpmac_open(mac->mc_io, 0, dpmac_dev->obj_desc.id, in dpaa2_mac_open()
393 err = dpmac_get_attributes(mac->mc_io, 0, dpmac_dev->mc_handle, in dpaa2_mac_open()
394 &mac->attr); in dpaa2_mac_open()
403 mac->fw_node = dpaa2_mac_get_node(&mac->mc_dev->dev, mac->attr.id); in dpaa2_mac_open()
404 net_dev->dev.of_node = to_of_node(mac->fw_node); in dpaa2_mac_open()
409 dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle); in dpaa2_mac_open()
413 void dpaa2_mac_close(struct dpaa2_mac *mac) in dpaa2_mac_close() argument
415 struct fsl_mc_device *dpmac_dev = mac->mc_dev; in dpaa2_mac_close()
417 dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle); in dpaa2_mac_close()
418 if (mac->fw_node) in dpaa2_mac_close()
419 fwnode_handle_put(mac->fw_node); in dpaa2_mac_close()
471 void dpaa2_mac_get_ethtool_stats(struct dpaa2_mac *mac, u64 *data) in dpaa2_mac_get_ethtool_stats() argument
473 struct fsl_mc_device *dpmac_dev = mac->mc_dev; in dpaa2_mac_get_ethtool_stats()
478 err = dpmac_get_counter(mac->mc_io, 0, dpmac_dev->mc_handle, in dpaa2_mac_get_ethtool_stats()
481 netdev_err_once(mac->net_dev, in dpaa2_mac_get_ethtool_stats()