Lines Matching refs:mac
20 static int dpaa2_mac_cmp_ver(struct dpaa2_mac *mac, in dpaa2_mac_cmp_ver() argument
23 if (mac->ver_major == ver_major) in dpaa2_mac_cmp_ver()
24 return mac->ver_minor - ver_minor; in dpaa2_mac_cmp_ver()
25 return mac->ver_major - ver_major; in dpaa2_mac_cmp_ver()
28 static void dpaa2_mac_detect_features(struct dpaa2_mac *mac) in dpaa2_mac_detect_features() argument
30 mac->features = 0; in dpaa2_mac_detect_features()
32 if (dpaa2_mac_cmp_ver(mac, DPMAC_PROTOCOL_CHANGE_VER_MAJOR, in dpaa2_mac_detect_features()
34 mac->features |= DPAA2_MAC_FEATURE_PROTOCOL_CHANGE; in dpaa2_mac_detect_features()
155 struct dpaa2_mac *mac = phylink_to_dpaa2_mac(config); in dpaa2_mac_select_pcs() local
157 return mac->pcs; in dpaa2_mac_select_pcs()
163 struct dpaa2_mac *mac = phylink_to_dpaa2_mac(config); in dpaa2_mac_config() local
164 struct dpmac_link_state *dpmac_state = &mac->state; in dpaa2_mac_config()
173 err = dpmac_set_link_state(mac->mc_io, 0, in dpaa2_mac_config()
174 mac->mc_dev->mc_handle, dpmac_state); in dpaa2_mac_config()
176 netdev_err(mac->net_dev, "%s: dpmac_set_link_state() = %d\n", in dpaa2_mac_config()
179 if (!mac->serdes_phy) in dpaa2_mac_config()
183 err = dpmac_set_protocol(mac->mc_io, 0, mac->mc_dev->mc_handle, in dpaa2_mac_config()
186 netdev_err(mac->net_dev, "dpmac_set_protocol() = %d\n", err); in dpaa2_mac_config()
188 err = phy_set_mode_ext(mac->serdes_phy, PHY_MODE_ETHERNET, state->interface); in dpaa2_mac_config()
190 netdev_err(mac->net_dev, "phy_set_mode_ext() = %d\n", err); in dpaa2_mac_config()
199 struct dpaa2_mac *mac = phylink_to_dpaa2_mac(config); in dpaa2_mac_link_up() local
200 struct dpmac_link_state *dpmac_state = &mac->state; in dpaa2_mac_link_up()
222 err = dpmac_set_link_state(mac->mc_io, 0, in dpaa2_mac_link_up()
223 mac->mc_dev->mc_handle, dpmac_state); in dpaa2_mac_link_up()
225 netdev_err(mac->net_dev, "%s: dpmac_set_link_state() = %d\n", in dpaa2_mac_link_up()
233 struct dpaa2_mac *mac = phylink_to_dpaa2_mac(config); in dpaa2_mac_link_down() local
234 struct dpmac_link_state *dpmac_state = &mac->state; in dpaa2_mac_link_down()
238 err = dpmac_set_link_state(mac->mc_io, 0, in dpaa2_mac_link_down()
239 mac->mc_dev->mc_handle, dpmac_state); in dpaa2_mac_link_down()
241 netdev_err(mac->net_dev, "dpmac_set_link_state() = %d\n", err); in dpaa2_mac_link_down()
251 static int dpaa2_pcs_create(struct dpaa2_mac *mac, in dpaa2_pcs_create() argument
261 netdev_warn(mac->net_dev, "pcs-handle node not found\n"); in dpaa2_pcs_create()
269 netdev_dbg(mac->net_dev, "missing PCS device\n"); in dpaa2_pcs_create()
274 netdev_err(mac->net_dev, "pcs-handle node not available\n"); in dpaa2_pcs_create()
279 netdev_err(mac->net_dev, in dpaa2_pcs_create()
284 mac->pcs = pcs; in dpaa2_pcs_create()
289 static void dpaa2_pcs_destroy(struct dpaa2_mac *mac) in dpaa2_pcs_destroy() argument
291 struct phylink_pcs *phylink_pcs = mac->pcs; in dpaa2_pcs_destroy()
295 mac->pcs = NULL; in dpaa2_pcs_destroy()
299 static void dpaa2_mac_set_supported_interfaces(struct dpaa2_mac *mac) in dpaa2_mac_set_supported_interfaces() argument
307 __set_bit(mac->if_mode, mac->phylink_config.supported_interfaces); in dpaa2_mac_set_supported_interfaces()
308 if (mac->pcs) { in dpaa2_mac_set_supported_interfaces()
309 switch (mac->if_mode) { in dpaa2_mac_set_supported_interfaces()
313 mac->phylink_config.supported_interfaces); in dpaa2_mac_set_supported_interfaces()
315 mac->phylink_config.supported_interfaces); in dpaa2_mac_set_supported_interfaces()
323 if (!mac->serdes_phy) in dpaa2_mac_set_supported_interfaces()
334 err = phy_validate(mac->serdes_phy, PHY_MODE_ETHERNET, intf, NULL); in dpaa2_mac_set_supported_interfaces()
338 __set_bit(intf, mac->phylink_config.supported_interfaces); in dpaa2_mac_set_supported_interfaces()
342 void dpaa2_mac_start(struct dpaa2_mac *mac) in dpaa2_mac_start() argument
346 if (mac->serdes_phy) in dpaa2_mac_start()
347 phy_power_on(mac->serdes_phy); in dpaa2_mac_start()
349 phylink_start(mac->phylink); in dpaa2_mac_start()
352 void dpaa2_mac_stop(struct dpaa2_mac *mac) in dpaa2_mac_stop() argument
356 phylink_stop(mac->phylink); in dpaa2_mac_stop()
358 if (mac->serdes_phy) in dpaa2_mac_stop()
359 phy_power_off(mac->serdes_phy); in dpaa2_mac_stop()
362 int dpaa2_mac_connect(struct dpaa2_mac *mac) in dpaa2_mac_connect() argument
364 struct net_device *net_dev = mac->net_dev; in dpaa2_mac_connect()
370 mac->if_link_type = mac->attr.link_type; in dpaa2_mac_connect()
372 dpmac_node = mac->fw_node; in dpaa2_mac_connect()
374 netdev_err(net_dev, "No dpmac@%d node found.\n", mac->attr.id); in dpaa2_mac_connect()
378 err = dpaa2_mac_get_if_mode(dpmac_node, mac->attr); in dpaa2_mac_connect()
381 mac->if_mode = err; in dpaa2_mac_connect()
383 if (mac->features & DPAA2_MAC_FEATURE_PROTOCOL_CHANGE && in dpaa2_mac_connect()
384 !phy_interface_mode_is_rgmii(mac->if_mode) && in dpaa2_mac_connect()
395 mac->serdes_phy = serdes_phy; in dpaa2_mac_connect()
402 (mac->if_mode == PHY_INTERFACE_MODE_RGMII_ID || in dpaa2_mac_connect()
403 mac->if_mode == PHY_INTERFACE_MODE_RGMII_RXID || in dpaa2_mac_connect()
404 mac->if_mode == PHY_INTERFACE_MODE_RGMII_TXID)) { in dpaa2_mac_connect()
409 if ((mac->attr.link_type == DPMAC_LINK_TYPE_PHY && in dpaa2_mac_connect()
410 mac->attr.eth_if != DPMAC_ETH_IF_RGMII) || in dpaa2_mac_connect()
411 mac->attr.link_type == DPMAC_LINK_TYPE_BACKPLANE) { in dpaa2_mac_connect()
412 err = dpaa2_pcs_create(mac, dpmac_node, mac->attr.id); in dpaa2_mac_connect()
417 memset(&mac->phylink_config, 0, sizeof(mac->phylink_config)); in dpaa2_mac_connect()
418 mac->phylink_config.dev = &net_dev->dev; in dpaa2_mac_connect()
419 mac->phylink_config.type = PHYLINK_NETDEV; in dpaa2_mac_connect()
421 mac->phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_ASYM_PAUSE | in dpaa2_mac_connect()
425 dpaa2_mac_set_supported_interfaces(mac); in dpaa2_mac_connect()
427 phylink = phylink_create(&mac->phylink_config, in dpaa2_mac_connect()
428 dpmac_node, mac->if_mode, in dpaa2_mac_connect()
434 mac->phylink = phylink; in dpaa2_mac_connect()
437 err = phylink_fwnode_phy_connect(mac->phylink, dpmac_node, 0); in dpaa2_mac_connect()
447 phylink_destroy(mac->phylink); in dpaa2_mac_connect()
449 dpaa2_pcs_destroy(mac); in dpaa2_mac_connect()
454 void dpaa2_mac_disconnect(struct dpaa2_mac *mac) in dpaa2_mac_disconnect() argument
457 phylink_disconnect_phy(mac->phylink); in dpaa2_mac_disconnect()
460 phylink_destroy(mac->phylink); in dpaa2_mac_disconnect()
461 dpaa2_pcs_destroy(mac); in dpaa2_mac_disconnect()
462 of_phy_put(mac->serdes_phy); in dpaa2_mac_disconnect()
463 mac->serdes_phy = NULL; in dpaa2_mac_disconnect()
466 int dpaa2_mac_open(struct dpaa2_mac *mac) in dpaa2_mac_open() argument
468 struct fsl_mc_device *dpmac_dev = mac->mc_dev; in dpaa2_mac_open()
469 struct net_device *net_dev = mac->net_dev; in dpaa2_mac_open()
473 err = dpmac_open(mac->mc_io, 0, dpmac_dev->obj_desc.id, in dpaa2_mac_open()
480 err = dpmac_get_attributes(mac->mc_io, 0, dpmac_dev->mc_handle, in dpaa2_mac_open()
481 &mac->attr); in dpaa2_mac_open()
487 err = dpmac_get_api_version(mac->mc_io, 0, &mac->ver_major, &mac->ver_minor); in dpaa2_mac_open()
493 dpaa2_mac_detect_features(mac); in dpaa2_mac_open()
498 fw_node = dpaa2_mac_get_node(&mac->mc_dev->dev, mac->attr.id); in dpaa2_mac_open()
504 mac->fw_node = fw_node; in dpaa2_mac_open()
505 net_dev->dev.of_node = to_of_node(mac->fw_node); in dpaa2_mac_open()
510 dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle); in dpaa2_mac_open()
514 void dpaa2_mac_close(struct dpaa2_mac *mac) in dpaa2_mac_close() argument
516 struct fsl_mc_device *dpmac_dev = mac->mc_dev; in dpaa2_mac_close()
518 dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle); in dpaa2_mac_close()
519 if (mac->fw_node) in dpaa2_mac_close()
520 fwnode_handle_put(mac->fw_node); in dpaa2_mac_close()
572 void dpaa2_mac_get_ethtool_stats(struct dpaa2_mac *mac, u64 *data) in dpaa2_mac_get_ethtool_stats() argument
574 struct fsl_mc_device *dpmac_dev = mac->mc_dev; in dpaa2_mac_get_ethtool_stats()
579 err = dpmac_get_counter(mac->mc_io, 0, dpmac_dev->mc_handle, in dpaa2_mac_get_ethtool_stats()
582 netdev_err_once(mac->net_dev, in dpaa2_mac_get_ethtool_stats()