• Home
  • Raw
  • Download

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()
149 struct dpaa2_mac *mac = phylink_to_dpaa2_mac(config); in dpaa2_mac_select_pcs() local
151 return mac->pcs; in dpaa2_mac_select_pcs()
157 struct dpaa2_mac *mac = phylink_to_dpaa2_mac(config); in dpaa2_mac_config() local
158 struct dpmac_link_state *dpmac_state = &mac->state; in dpaa2_mac_config()
166 err = dpmac_set_link_state(mac->mc_io, 0, in dpaa2_mac_config()
167 mac->mc_dev->mc_handle, dpmac_state); in dpaa2_mac_config()
169 netdev_err(mac->net_dev, "%s: dpmac_set_link_state() = %d\n", in dpaa2_mac_config()
172 if (!mac->serdes_phy) in dpaa2_mac_config()
176 err = dpmac_set_protocol(mac->mc_io, 0, mac->mc_dev->mc_handle, in dpaa2_mac_config()
179 netdev_err(mac->net_dev, "dpmac_set_protocol() = %d\n", err); in dpaa2_mac_config()
181 err = phy_set_mode_ext(mac->serdes_phy, PHY_MODE_ETHERNET, state->interface); in dpaa2_mac_config()
183 netdev_err(mac->net_dev, "phy_set_mode_ext() = %d\n", err); in dpaa2_mac_config()
192 struct dpaa2_mac *mac = phylink_to_dpaa2_mac(config); in dpaa2_mac_link_up() local
193 struct dpmac_link_state *dpmac_state = &mac->state; in dpaa2_mac_link_up()
215 err = dpmac_set_link_state(mac->mc_io, 0, in dpaa2_mac_link_up()
216 mac->mc_dev->mc_handle, dpmac_state); in dpaa2_mac_link_up()
218 netdev_err(mac->net_dev, "%s: dpmac_set_link_state() = %d\n", in dpaa2_mac_link_up()
226 struct dpaa2_mac *mac = phylink_to_dpaa2_mac(config); in dpaa2_mac_link_down() local
227 struct dpmac_link_state *dpmac_state = &mac->state; in dpaa2_mac_link_down()
231 err = dpmac_set_link_state(mac->mc_io, 0, in dpaa2_mac_link_down()
232 mac->mc_dev->mc_handle, dpmac_state); in dpaa2_mac_link_down()
234 netdev_err(mac->net_dev, "dpmac_set_link_state() = %d\n", err); in dpaa2_mac_link_down()
245 static int dpaa2_pcs_create(struct dpaa2_mac *mac, in dpaa2_pcs_create() argument
255 netdev_warn(mac->net_dev, "pcs-handle node not found\n"); in dpaa2_pcs_create()
260 netdev_err(mac->net_dev, "pcs-handle node not available\n"); in dpaa2_pcs_create()
270 mac->pcs = lynx_pcs_create(mdiodev); in dpaa2_pcs_create()
271 if (!mac->pcs) { in dpaa2_pcs_create()
272 netdev_err(mac->net_dev, "lynx_pcs_create() failed\n"); in dpaa2_pcs_create()
280 static void dpaa2_pcs_destroy(struct dpaa2_mac *mac) in dpaa2_pcs_destroy() argument
282 struct phylink_pcs *phylink_pcs = mac->pcs; in dpaa2_pcs_destroy()
290 mac->pcs = NULL; in dpaa2_pcs_destroy()
294 static void dpaa2_mac_set_supported_interfaces(struct dpaa2_mac *mac) in dpaa2_mac_set_supported_interfaces() argument
302 __set_bit(mac->if_mode, mac->phylink_config.supported_interfaces); in dpaa2_mac_set_supported_interfaces()
303 if (mac->pcs) { in dpaa2_mac_set_supported_interfaces()
304 switch (mac->if_mode) { in dpaa2_mac_set_supported_interfaces()
308 mac->phylink_config.supported_interfaces); in dpaa2_mac_set_supported_interfaces()
310 mac->phylink_config.supported_interfaces); in dpaa2_mac_set_supported_interfaces()
318 if (!mac->serdes_phy) in dpaa2_mac_set_supported_interfaces()
329 err = phy_validate(mac->serdes_phy, PHY_MODE_ETHERNET, intf, NULL); in dpaa2_mac_set_supported_interfaces()
333 __set_bit(intf, mac->phylink_config.supported_interfaces); in dpaa2_mac_set_supported_interfaces()
337 void dpaa2_mac_start(struct dpaa2_mac *mac) in dpaa2_mac_start() argument
339 if (mac->serdes_phy) in dpaa2_mac_start()
340 phy_power_on(mac->serdes_phy); in dpaa2_mac_start()
343 void dpaa2_mac_stop(struct dpaa2_mac *mac) in dpaa2_mac_stop() argument
345 if (mac->serdes_phy) in dpaa2_mac_stop()
346 phy_power_off(mac->serdes_phy); in dpaa2_mac_stop()
349 int dpaa2_mac_connect(struct dpaa2_mac *mac) in dpaa2_mac_connect() argument
351 struct net_device *net_dev = mac->net_dev; in dpaa2_mac_connect()
357 mac->if_link_type = mac->attr.link_type; in dpaa2_mac_connect()
359 dpmac_node = mac->fw_node; in dpaa2_mac_connect()
361 netdev_err(net_dev, "No dpmac@%d node found.\n", mac->attr.id); in dpaa2_mac_connect()
365 err = dpaa2_mac_get_if_mode(dpmac_node, mac->attr); in dpaa2_mac_connect()
368 mac->if_mode = err; in dpaa2_mac_connect()
370 if (mac->features & DPAA2_MAC_FEATURE_PROTOCOL_CHANGE && in dpaa2_mac_connect()
371 !phy_interface_mode_is_rgmii(mac->if_mode) && in dpaa2_mac_connect()
382 mac->serdes_phy = serdes_phy; in dpaa2_mac_connect()
389 (mac->if_mode == PHY_INTERFACE_MODE_RGMII_ID || in dpaa2_mac_connect()
390 mac->if_mode == PHY_INTERFACE_MODE_RGMII_RXID || in dpaa2_mac_connect()
391 mac->if_mode == PHY_INTERFACE_MODE_RGMII_TXID)) { in dpaa2_mac_connect()
396 if ((mac->attr.link_type == DPMAC_LINK_TYPE_PHY && in dpaa2_mac_connect()
397 mac->attr.eth_if != DPMAC_ETH_IF_RGMII) || in dpaa2_mac_connect()
398 mac->attr.link_type == DPMAC_LINK_TYPE_BACKPLANE) { in dpaa2_mac_connect()
399 err = dpaa2_pcs_create(mac, dpmac_node, mac->attr.id); in dpaa2_mac_connect()
404 memset(&mac->phylink_config, 0, sizeof(mac->phylink_config)); in dpaa2_mac_connect()
405 mac->phylink_config.dev = &net_dev->dev; in dpaa2_mac_connect()
406 mac->phylink_config.type = PHYLINK_NETDEV; in dpaa2_mac_connect()
408 mac->phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_ASYM_PAUSE | in dpaa2_mac_connect()
412 dpaa2_mac_set_supported_interfaces(mac); in dpaa2_mac_connect()
414 phylink = phylink_create(&mac->phylink_config, in dpaa2_mac_connect()
415 dpmac_node, mac->if_mode, in dpaa2_mac_connect()
421 mac->phylink = phylink; in dpaa2_mac_connect()
423 err = phylink_fwnode_phy_connect(mac->phylink, dpmac_node, 0); in dpaa2_mac_connect()
432 phylink_destroy(mac->phylink); in dpaa2_mac_connect()
434 dpaa2_pcs_destroy(mac); in dpaa2_mac_connect()
439 void dpaa2_mac_disconnect(struct dpaa2_mac *mac) in dpaa2_mac_disconnect() argument
441 if (!mac->phylink) in dpaa2_mac_disconnect()
444 phylink_disconnect_phy(mac->phylink); in dpaa2_mac_disconnect()
445 phylink_destroy(mac->phylink); in dpaa2_mac_disconnect()
446 dpaa2_pcs_destroy(mac); in dpaa2_mac_disconnect()
447 of_phy_put(mac->serdes_phy); in dpaa2_mac_disconnect()
448 mac->serdes_phy = NULL; in dpaa2_mac_disconnect()
451 int dpaa2_mac_open(struct dpaa2_mac *mac) in dpaa2_mac_open() argument
453 struct fsl_mc_device *dpmac_dev = mac->mc_dev; in dpaa2_mac_open()
454 struct net_device *net_dev = mac->net_dev; in dpaa2_mac_open()
458 err = dpmac_open(mac->mc_io, 0, dpmac_dev->obj_desc.id, in dpaa2_mac_open()
465 err = dpmac_get_attributes(mac->mc_io, 0, dpmac_dev->mc_handle, in dpaa2_mac_open()
466 &mac->attr); in dpaa2_mac_open()
472 err = dpmac_get_api_version(mac->mc_io, 0, &mac->ver_major, &mac->ver_minor); in dpaa2_mac_open()
478 dpaa2_mac_detect_features(mac); in dpaa2_mac_open()
483 fw_node = dpaa2_mac_get_node(&mac->mc_dev->dev, mac->attr.id); in dpaa2_mac_open()
489 mac->fw_node = fw_node; in dpaa2_mac_open()
490 net_dev->dev.of_node = to_of_node(mac->fw_node); in dpaa2_mac_open()
495 dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle); in dpaa2_mac_open()
499 void dpaa2_mac_close(struct dpaa2_mac *mac) in dpaa2_mac_close() argument
501 struct fsl_mc_device *dpmac_dev = mac->mc_dev; in dpaa2_mac_close()
503 dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle); in dpaa2_mac_close()
504 if (mac->fw_node) in dpaa2_mac_close()
505 fwnode_handle_put(mac->fw_node); in dpaa2_mac_close()
557 void dpaa2_mac_get_ethtool_stats(struct dpaa2_mac *mac, u64 *data) in dpaa2_mac_get_ethtool_stats() argument
559 struct fsl_mc_device *dpmac_dev = mac->mc_dev; in dpaa2_mac_get_ethtool_stats()
564 err = dpmac_get_counter(mac->mc_io, 0, dpmac_dev->mc_handle, in dpaa2_mac_get_ethtool_stats()
567 netdev_err_once(mac->net_dev, in dpaa2_mac_get_ethtool_stats()