Lines Matching +full:cpsw +full:- +full:switch
1 // SPDX-License-Identifier: GPL-2.0
7 * Sandeep Paulraj <s-paulraj@ti.com>
10 * Wingman Kwok <w-kwok2@ti.com>
23 #include "cpsw.h"
37 #define GBE_MODULE_NAME "netcp-gbe"
56 #define GBENU_MODULE_NAME "netcp-gbenu"
61 ((GBE_IDENT((d)->ss_version) == GBE_SS_ID_NU) || \
62 (GBE_IDENT((d)->ss_version) == GBE_SS_ID_2U))
65 (GBE_IDENT((d)->ss_version) == GBE_SS_ID_NU)
68 (GBE_IDENT((d)->ss_version) == GBE_SS_VERSION_14)
70 (GBE_IDENT((d)->ss_version) == GBE_SS_ID_2U)
85 #define XGBE_MODULE_NAME "netcp-xgbe"
94 #define IS_SS_ID_XGBE(d) ((d)->ss_version == XGBE_SS_VERSION_10)
110 #define GMACSL_RET_WARN_RESET_INCOMPLETE -2
126 #define GBE_PORT_MASK(x) (BIT(x) - 1)
156 /* s: 0-based slave_port */
158 (((s) < 2) ? (d)->sgmii_port_regs : (d)->sgmii_port34_regs)
164 #define SLAVE_LINK_IS_XGMII(s) ((s)->link_interface >= XGMII_LINK_MAC_PHY)
166 (((s)->link_interface >= RGMII_LINK_MAC_PHY) && \
167 ((s)->link_interface <= RGMII_LINK_MAC_PHY_NO_MDIO))
169 ((s)->link_interface <= SGMII_LINK_MAC_PHY_NO_MDIO)
170 #define NETCP_LINK_STATE_INVALID -1
172 #define GBE_SET_REG_OFS(p, rb, rn) p->rb##_ofs.rn = \
174 #define GBENU_SET_REG_OFS(p, rb, rn) p->rb##_ofs.rn = \
176 #define XGBE_SET_REG_OFS(p, rb, rn) p->rb##_ofs.rn = \
178 #define GBE_REG_ADDR(p, rb, rn) (p->rb + p->rb##_ofs.rn)
228 /* The PTP event messages - Sync, Delay_Req, Pdelay_Req, and Pdelay_Resp. */
1726 list_for_each_entry((i), &(priv)->gbe_intf_head, gbe_intf_list)
1729 list_for_each_entry((slave), &(priv)->secondary_slaves, slave_list)
1732 list_first_entry(&priv->secondary_slaves, \
1738 strncpy(info->driver, NETCP_DRIVER_NAME, sizeof(info->driver)); in keystone_get_drvinfo()
1739 strncpy(info->version, NETCP_DRIVER_VERSION, sizeof(info->version)); in keystone_get_drvinfo()
1746 return netcp->msg_enable; in keystone_get_msglevel()
1753 netcp->msg_enable = value; in keystone_set_msglevel()
1778 gbe_dev = gbe_intf->gbe_dev; in keystone_get_stat_strings()
1780 switch (stringset) { in keystone_get_stat_strings()
1782 for (i = 0; i < gbe_dev->num_et_stats; i++) { in keystone_get_stat_strings()
1783 memcpy(data, gbe_dev->et_stats[i].desc, in keystone_get_stat_strings()
1801 return -EINVAL; in keystone_get_sset_count()
1802 gbe_dev = gbe_intf->gbe_dev; in keystone_get_sset_count()
1804 switch (stringset) { in keystone_get_sset_count()
1808 return gbe_dev->num_et_stats; in keystone_get_sset_count()
1810 return -EINVAL; in keystone_get_sset_count()
1816 void __iomem *base = gbe_dev->hw_stats_regs[stats_mod]; in gbe_reset_mod_stats()
1820 for (i = 0; i < gbe_dev->num_et_stats; i++) { in gbe_reset_mod_stats()
1821 if (gbe_dev->et_stats[i].type == stats_mod) { in gbe_reset_mod_stats()
1822 p_stats_entry = base + gbe_dev->et_stats[i].offset; in gbe_reset_mod_stats()
1823 gbe_dev->hw_stats[i] = 0; in gbe_reset_mod_stats()
1824 gbe_dev->hw_stats_prev[i] = readl(p_stats_entry); in gbe_reset_mod_stats()
1839 base = gbe_dev->hw_stats_regs[gbe_dev->et_stats[et_stats_entry].type]; in gbe_update_hw_stats_entry()
1840 p_stats_entry = base + gbe_dev->et_stats[et_stats_entry].offset; in gbe_update_hw_stats_entry()
1842 delta = curr - gbe_dev->hw_stats_prev[et_stats_entry]; in gbe_update_hw_stats_entry()
1843 gbe_dev->hw_stats_prev[et_stats_entry] = curr; in gbe_update_hw_stats_entry()
1844 gbe_dev->hw_stats[et_stats_entry] += delta; in gbe_update_hw_stats_entry()
1851 for (i = 0; i < gbe_dev->num_et_stats; i++) { in gbe_update_stats()
1855 data[i] = gbe_dev->hw_stats[i]; in gbe_update_stats()
1866 switch (stats_mod) { in gbe_stats_mod_visible_ver14()
1891 u32 half_num_et_stats = (gbe_dev->num_et_stats / 2); in gbe_update_stats_ver14()
1904 data[et_entry] = gbe_dev->hw_stats[et_entry]; in gbe_update_stats_ver14()
1921 gbe_dev = gbe_intf->gbe_dev; in keystone_get_ethtool_stats()
1922 spin_lock_bh(&gbe_dev->hw_stats_lock); in keystone_get_ethtool_stats()
1927 spin_unlock_bh(&gbe_dev->hw_stats_lock); in keystone_get_ethtool_stats()
1934 struct phy_device *phy = ndev->phydev; in keystone_get_link_ksettings()
1938 return -EINVAL; in keystone_get_link_ksettings()
1942 return -EINVAL; in keystone_get_link_ksettings()
1944 if (!gbe_intf->slave) in keystone_get_link_ksettings()
1945 return -EINVAL; in keystone_get_link_ksettings()
1948 cmd->base.port = gbe_intf->slave->phy_port_t; in keystone_get_link_ksettings()
1957 struct phy_device *phy = ndev->phydev; in keystone_set_link_ksettings()
1959 u8 port = cmd->base.port; in keystone_set_link_ksettings()
1964 cmd->link_modes.advertising); in keystone_set_link_ksettings()
1966 cmd->link_modes.supported); in keystone_set_link_ksettings()
1970 return -EINVAL; in keystone_set_link_ksettings()
1974 return -EINVAL; in keystone_set_link_ksettings()
1976 if (!gbe_intf->slave) in keystone_set_link_ksettings()
1977 return -EINVAL; in keystone_set_link_ksettings()
1979 if (port != gbe_intf->slave->phy_port_t) { in keystone_set_link_ksettings()
1981 return -EINVAL; in keystone_set_link_ksettings()
1984 return -EINVAL; in keystone_set_link_ksettings()
1987 return -EINVAL; in keystone_set_link_ksettings()
1990 return -EINVAL; in keystone_set_link_ksettings()
1993 return -EINVAL; in keystone_set_link_ksettings()
1996 gbe_intf->slave->phy_port_t = port; in keystone_set_link_ksettings()
2008 if (!gbe_intf || !gbe_intf->gbe_dev->cpts) in keystone_get_ts_info()
2009 return -EINVAL; in keystone_get_ts_info()
2011 info->so_timestamping = in keystone_get_ts_info()
2018 info->phc_index = gbe_intf->gbe_dev->cpts->phc_index; in keystone_get_ts_info()
2019 info->tx_types = in keystone_get_ts_info()
2022 info->rx_filters = in keystone_get_ts_info()
2032 info->so_timestamping = in keystone_get_ts_info()
2036 info->phc_index = -1; in keystone_get_ts_info()
2037 info->tx_types = 0; in keystone_get_ts_info()
2038 info->rx_filters = 0; in keystone_get_ts_info()
2059 struct net_device *ndev = gbe_intf->ndev; in gbe_set_slave_mac()
2061 writel(mac_hi(ndev->dev_addr), GBE_REG_ADDR(slave, port_regs, sa_hi)); in gbe_set_slave_mac()
2062 writel(mac_lo(ndev->dev_addr), GBE_REG_ADDR(slave, port_regs, sa_lo)); in gbe_set_slave_mac()
2067 if (priv->host_port == 0) in gbe_get_slave_port()
2078 struct phy_device *phy = slave->phy; in netcp_ethss_link_state_action()
2082 mac_control = slave->mac_control; in netcp_ethss_link_state_action()
2083 if (phy && (phy->speed == SPEED_1000)) { in netcp_ethss_link_state_action()
2086 } else if (phy && (phy->speed == SPEED_10000)) { in netcp_ethss_link_state_action()
2094 cpsw_ale_control_set(gbe_dev->ale, slave->port_num, in netcp_ethss_link_state_action()
2098 if (ndev && slave->open && in netcp_ethss_link_state_action()
2099 ((slave->link_interface != SGMII_LINK_MAC_PHY) && in netcp_ethss_link_state_action()
2100 (slave->link_interface != RGMII_LINK_MAC_PHY) && in netcp_ethss_link_state_action()
2101 (slave->link_interface != XGMII_LINK_MAC_PHY))) in netcp_ethss_link_state_action()
2106 cpsw_ale_control_set(gbe_dev->ale, slave->port_num, in netcp_ethss_link_state_action()
2110 ((slave->link_interface != SGMII_LINK_MAC_PHY) && in netcp_ethss_link_state_action()
2111 (slave->link_interface != RGMII_LINK_MAC_PHY) && in netcp_ethss_link_state_action()
2112 (slave->link_interface != XGMII_LINK_MAC_PHY))) in netcp_ethss_link_state_action()
2122 return !slave->phy || slave->phy->link; in gbe_phy_link_status()
2140 int sp = slave->slave_num, link_state; in netcp_ethss_update_link_state()
2142 if (!slave->open) in netcp_ethss_update_link_state()
2155 if (atomic_xchg(&slave->link_state, link_state) != link_state) in netcp_ethss_update_link_state()
2169 netcp_ethss_update_link_state(gbe_intf->gbe_dev, gbe_intf->slave, in xgbe_adjust_link()
2182 netcp_ethss_update_link_state(gbe_intf->gbe_dev, gbe_intf->slave, in gbe_adjust_link()
2228 (slave->link_interface >= XGMII_LINK_MAC_PHY)) { in gbe_port_config()
2230 xgmii_mode |= (1 << slave->slave_num); in gbe_port_config()
2240 writel(slave->mac_control, GBE_REG_ADDR(slave, emac_regs, mac_control)); in gbe_port_config()
2249 netcp_sgmii_rtreset(SGMII_BASE(priv, slave->slave_num), in gbe_sgmii_rtreset()
2250 slave->slave_num, set); in gbe_sgmii_rtreset()
2255 struct gbe_priv *gbe_dev = intf->gbe_dev; in gbe_slave_stop()
2256 struct gbe_slave *slave = intf->slave; in gbe_slave_stop()
2262 cpsw_ale_control_set(gbe_dev->ale, slave->port_num, in gbe_slave_stop()
2264 cpsw_ale_del_mcast(gbe_dev->ale, intf->ndev->broadcast, in gbe_slave_stop()
2265 1 << slave->port_num, 0, 0); in gbe_slave_stop()
2267 if (!slave->phy) in gbe_slave_stop()
2270 phy_stop(slave->phy); in gbe_slave_stop()
2271 phy_disconnect(slave->phy); in gbe_slave_stop()
2272 slave->phy = NULL; in gbe_slave_stop()
2280 netcp_sgmii_reset(SGMII_BASE(priv, slave->slave_num), slave->slave_num); in gbe_sgmii_config()
2281 netcp_sgmii_config(SGMII_BASE(priv, slave->slave_num), slave->slave_num, in gbe_sgmii_config()
2282 slave->link_interface); in gbe_sgmii_config()
2287 struct gbe_priv *priv = gbe_intf->gbe_dev; in gbe_slave_open()
2288 struct gbe_slave *slave = gbe_intf->slave; in gbe_slave_open()
2300 gbe_port_config(priv, slave, priv->rx_packet_max); in gbe_slave_open()
2302 /* For NU & 2U switch, map the vlan priorities to zero in gbe_slave_open()
2310 cpsw_ale_control_set(priv->ale, slave->port_num, in gbe_slave_open()
2312 cpsw_ale_add_mcast(priv->ale, gbe_intf->ndev->broadcast, in gbe_slave_open()
2313 1 << slave->port_num, 0, 0, ALE_MCAST_FWD_2); in gbe_slave_open()
2315 if (slave->link_interface == SGMII_LINK_MAC_PHY) { in gbe_slave_open()
2318 slave->phy_port_t = PORT_MII; in gbe_slave_open()
2319 } else if (slave->link_interface == RGMII_LINK_MAC_PHY) { in gbe_slave_open()
2321 err = of_get_phy_mode(slave->node, &phy_mode); in gbe_slave_open()
2322 /* if phy-mode is not present, default to in gbe_slave_open()
2329 dev_err(priv->dev, in gbe_slave_open()
2331 return -EINVAL; in gbe_slave_open()
2333 slave->phy_port_t = PORT_MII; in gbe_slave_open()
2334 } else if (slave->link_interface == XGMII_LINK_MAC_PHY) { in gbe_slave_open()
2337 slave->phy_port_t = PORT_FIBRE; in gbe_slave_open()
2344 slave->phy = of_phy_connect(gbe_intf->ndev, in gbe_slave_open()
2345 slave->phy_node, in gbe_slave_open()
2348 if (!slave->phy) { in gbe_slave_open()
2349 dev_err(priv->dev, "phy not found on slave %d\n", in gbe_slave_open()
2350 slave->slave_num); in gbe_slave_open()
2351 return -ENODEV; in gbe_slave_open()
2353 dev_dbg(priv->dev, "phy found: id is: 0x%s\n", in gbe_slave_open()
2354 phydev_name(slave->phy)); in gbe_slave_open()
2355 phy_start(slave->phy); in gbe_slave_open()
2373 cpsw_ale_start(priv->ale); in gbe_init_host_port()
2375 if (priv->enable_ale) in gbe_init_host_port()
2378 cpsw_ale_control_set(priv->ale, 0, ALE_BYPASS, bypass_en); in gbe_init_host_port()
2380 cpsw_ale_control_set(priv->ale, 0, ALE_NO_PORT_VLAN, 1); in gbe_init_host_port()
2382 cpsw_ale_control_set(priv->ale, priv->host_port, in gbe_init_host_port()
2385 cpsw_ale_control_set(priv->ale, 0, in gbe_init_host_port()
2387 GBE_PORT_MASK(priv->ale_ports)); in gbe_init_host_port()
2389 cpsw_ale_control_set(priv->ale, 0, in gbe_init_host_port()
2391 GBE_PORT_MASK(priv->ale_ports - 1)); in gbe_init_host_port()
2393 cpsw_ale_control_set(priv->ale, 0, in gbe_init_host_port()
2395 GBE_PORT_MASK(priv->ale_ports)); in gbe_init_host_port()
2397 cpsw_ale_control_set(priv->ale, 0, in gbe_init_host_port()
2399 GBE_PORT_MASK(priv->ale_ports)); in gbe_init_host_port()
2404 struct gbe_priv *gbe_dev = gbe_intf->gbe_dev; in gbe_add_mcast_addr()
2407 cpsw_ale_add_mcast(gbe_dev->ale, addr, in gbe_add_mcast_addr()
2408 GBE_PORT_MASK(gbe_dev->ale_ports), 0, 0, in gbe_add_mcast_addr()
2410 for_each_set_bit(vlan_id, gbe_intf->active_vlans, VLAN_N_VID) { in gbe_add_mcast_addr()
2411 cpsw_ale_add_mcast(gbe_dev->ale, addr, in gbe_add_mcast_addr()
2412 GBE_PORT_MASK(gbe_dev->ale_ports), in gbe_add_mcast_addr()
2419 struct gbe_priv *gbe_dev = gbe_intf->gbe_dev; in gbe_add_ucast_addr()
2422 cpsw_ale_add_ucast(gbe_dev->ale, addr, gbe_dev->host_port, 0, 0); in gbe_add_ucast_addr()
2424 for_each_set_bit(vlan_id, gbe_intf->active_vlans, VLAN_N_VID) in gbe_add_ucast_addr()
2425 cpsw_ale_add_ucast(gbe_dev->ale, addr, gbe_dev->host_port, in gbe_add_ucast_addr()
2431 struct gbe_priv *gbe_dev = gbe_intf->gbe_dev; in gbe_del_mcast_addr()
2434 cpsw_ale_del_mcast(gbe_dev->ale, addr, 0, 0, 0); in gbe_del_mcast_addr()
2436 for_each_set_bit(vlan_id, gbe_intf->active_vlans, VLAN_N_VID) { in gbe_del_mcast_addr()
2437 cpsw_ale_del_mcast(gbe_dev->ale, addr, 0, ALE_VLAN, vlan_id); in gbe_del_mcast_addr()
2443 struct gbe_priv *gbe_dev = gbe_intf->gbe_dev; in gbe_del_ucast_addr()
2446 cpsw_ale_del_ucast(gbe_dev->ale, addr, gbe_dev->host_port, 0, 0); in gbe_del_ucast_addr()
2448 for_each_set_bit(vlan_id, gbe_intf->active_vlans, VLAN_N_VID) { in gbe_del_ucast_addr()
2449 cpsw_ale_del_ucast(gbe_dev->ale, addr, gbe_dev->host_port, in gbe_del_ucast_addr()
2457 struct gbe_priv *gbe_dev = gbe_intf->gbe_dev; in gbe_add_addr()
2459 dev_dbg(gbe_dev->dev, "ethss adding address %pM, type %d\n", in gbe_add_addr()
2460 naddr->addr, naddr->type); in gbe_add_addr()
2462 switch (naddr->type) { in gbe_add_addr()
2465 gbe_add_mcast_addr(gbe_intf, naddr->addr); in gbe_add_addr()
2469 gbe_add_ucast_addr(gbe_intf, naddr->addr); in gbe_add_addr()
2483 struct gbe_priv *gbe_dev = gbe_intf->gbe_dev; in gbe_del_addr()
2485 dev_dbg(gbe_dev->dev, "ethss deleting address %pM, type %d\n", in gbe_del_addr()
2486 naddr->addr, naddr->type); in gbe_del_addr()
2488 switch (naddr->type) { in gbe_del_addr()
2491 gbe_del_mcast_addr(gbe_intf, naddr->addr); in gbe_del_addr()
2495 gbe_del_ucast_addr(gbe_intf, naddr->addr); in gbe_del_addr()
2509 struct gbe_priv *gbe_dev = gbe_intf->gbe_dev; in gbe_add_vid()
2511 set_bit(vid, gbe_intf->active_vlans); in gbe_add_vid()
2513 cpsw_ale_add_vlan(gbe_dev->ale, vid, in gbe_add_vid()
2514 GBE_PORT_MASK(gbe_dev->ale_ports), in gbe_add_vid()
2516 GBE_PORT_MASK(gbe_dev->ale_ports), in gbe_add_vid()
2517 GBE_PORT_MASK(gbe_dev->ale_ports - 1)); in gbe_add_vid()
2525 struct gbe_priv *gbe_dev = gbe_intf->gbe_dev; in gbe_del_vid()
2527 cpsw_ale_del_vlan(gbe_dev->ale, vid, 0); in gbe_del_vid()
2528 clear_bit(vid, gbe_intf->active_vlans); in gbe_del_vid()
2537 struct gbe_priv *gbe_dev = gbe_intf->gbe_dev; in gbe_txtstamp()
2539 cpts_tx_timestamp(gbe_dev->cpts, skb); in gbe_txtstamp()
2545 struct sk_buff *skb = p_info->skb; in gbe_need_txtstamp()
2547 return cpts_can_timestamp(gbe_intf->gbe_dev->cpts, skb); in gbe_need_txtstamp()
2553 struct phy_device *phydev = p_info->skb->dev->phydev; in gbe_txtstamp_mark_pkt()
2554 struct gbe_priv *gbe_dev = gbe_intf->gbe_dev; in gbe_txtstamp_mark_pkt()
2556 if (!(skb_shinfo(p_info->skb)->tx_flags & SKBTX_HW_TSTAMP) || in gbe_txtstamp_mark_pkt()
2557 !gbe_dev->tx_ts_enabled) in gbe_txtstamp_mark_pkt()
2565 skb_shinfo(p_info->skb)->tx_flags |= SKBTX_IN_PROGRESS; in gbe_txtstamp_mark_pkt()
2570 p_info->txtstamp = gbe_txtstamp; in gbe_txtstamp_mark_pkt()
2571 p_info->ts_context = (void *)gbe_intf; in gbe_txtstamp_mark_pkt()
2572 skb_shinfo(p_info->skb)->tx_flags |= SKBTX_IN_PROGRESS; in gbe_txtstamp_mark_pkt()
2580 struct phy_device *phydev = p_info->skb->dev->phydev; in gbe_rxtstamp()
2581 struct gbe_priv *gbe_dev = gbe_intf->gbe_dev; in gbe_rxtstamp()
2583 if (p_info->rxtstamp_complete) in gbe_rxtstamp()
2587 p_info->rxtstamp_complete = true; in gbe_rxtstamp()
2591 if (gbe_dev->rx_ts_enabled) in gbe_rxtstamp()
2592 cpts_rx_timestamp(gbe_dev->cpts, p_info->skb); in gbe_rxtstamp()
2594 p_info->rxtstamp_complete = true; in gbe_rxtstamp()
2601 struct gbe_priv *gbe_dev = gbe_intf->gbe_dev; in gbe_hwtstamp_get()
2602 struct cpts *cpts = gbe_dev->cpts; in gbe_hwtstamp_get()
2606 return -EOPNOTSUPP; in gbe_hwtstamp_get()
2609 cfg.tx_type = gbe_dev->tx_ts_enabled ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; in gbe_hwtstamp_get()
2610 cfg.rx_filter = gbe_dev->rx_ts_enabled; in gbe_hwtstamp_get()
2612 return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; in gbe_hwtstamp_get()
2617 struct gbe_priv *gbe_dev = gbe_intf->gbe_dev; in gbe_hwtstamp()
2618 struct gbe_slave *slave = gbe_intf->slave; in gbe_hwtstamp()
2621 if (!gbe_dev->rx_ts_enabled && in gbe_hwtstamp()
2622 !gbe_dev->tx_ts_enabled) { in gbe_hwtstamp()
2630 (slave->ts_ctl.dst_port_map << TS_CTL_DST_PORT_SHIFT) | in gbe_hwtstamp()
2631 (slave->ts_ctl.uni ? TS_UNI_EN : in gbe_hwtstamp()
2632 slave->ts_ctl.maddr_map << TS_CTL_MADDR_SHIFT); in gbe_hwtstamp()
2634 if (gbe_dev->tx_ts_enabled) in gbe_hwtstamp()
2637 if (gbe_dev->rx_ts_enabled) in gbe_hwtstamp()
2647 struct gbe_priv *gbe_dev = gbe_intf->gbe_dev; in gbe_hwtstamp_set()
2648 struct cpts *cpts = gbe_dev->cpts; in gbe_hwtstamp_set()
2652 return -EOPNOTSUPP; in gbe_hwtstamp_set()
2654 if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) in gbe_hwtstamp_set()
2655 return -EFAULT; in gbe_hwtstamp_set()
2659 return -EINVAL; in gbe_hwtstamp_set()
2661 switch (cfg.tx_type) { in gbe_hwtstamp_set()
2663 gbe_dev->tx_ts_enabled = 0; in gbe_hwtstamp_set()
2666 gbe_dev->tx_ts_enabled = 1; in gbe_hwtstamp_set()
2669 return -ERANGE; in gbe_hwtstamp_set()
2672 switch (cfg.rx_filter) { in gbe_hwtstamp_set()
2674 gbe_dev->rx_ts_enabled = HWTSTAMP_FILTER_NONE; in gbe_hwtstamp_set()
2679 gbe_dev->rx_ts_enabled = HWTSTAMP_FILTER_PTP_V1_L4_EVENT; in gbe_hwtstamp_set()
2691 gbe_dev->rx_ts_enabled = HWTSTAMP_FILTER_PTP_V2_EVENT; in gbe_hwtstamp_set()
2695 return -ERANGE; in gbe_hwtstamp_set()
2700 return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; in gbe_hwtstamp_set()
2705 if (!gbe_dev->cpts) in gbe_register_cpts()
2708 if (gbe_dev->cpts_registered > 0) in gbe_register_cpts()
2711 if (cpts_register(gbe_dev->cpts)) { in gbe_register_cpts()
2712 dev_err(gbe_dev->dev, "error registering cpts device\n"); in gbe_register_cpts()
2717 ++gbe_dev->cpts_registered; in gbe_register_cpts()
2722 if (!gbe_dev->cpts || (gbe_dev->cpts_registered <= 0)) in gbe_unregister_cpts()
2725 if (--gbe_dev->cpts_registered) in gbe_unregister_cpts()
2728 cpts_unregister(gbe_dev->cpts); in gbe_unregister_cpts()
2746 return -EOPNOTSUPP; in gbe_hwtstamp()
2759 return -EOPNOTSUPP; in gbe_hwtstamp_get()
2764 return -EOPNOTSUPP; in gbe_hwtstamp_set()
2771 struct gbe_priv *gbe_dev = gbe_intf->gbe_dev; in gbe_set_rx_mode()
2772 struct cpsw_ale *ale = gbe_dev->ale; in gbe_set_rx_mode()
2774 int i, ret = -ETIMEDOUT; in gbe_set_rx_mode()
2779 for (i = 0; i <= gbe_dev->num_slaves; i++) { in gbe_set_rx_mode()
2789 dev_vdbg(gbe_dev->dev, "promiscuous mode disabled\n"); in gbe_set_rx_mode()
2814 GBE_PORT_MASK(gbe_dev->ale_ports), in gbe_set_rx_mode()
2815 -1); in gbe_set_rx_mode()
2819 dev_vdbg(gbe_dev->dev, "promiscuous mode enabled\n"); in gbe_set_rx_mode()
2826 struct phy_device *phy = gbe_intf->slave->phy; in gbe_ioctl()
2829 switch (cmd) { in gbe_ioctl()
2840 return -EOPNOTSUPP; in gbe_ioctl()
2851 if (!gbe_intf->slave->open) in netcp_ethss_timer()
2853 netcp_ethss_update_link_state(gbe_dev, gbe_intf->slave, in netcp_ethss_timer()
2854 gbe_intf->ndev); in netcp_ethss_timer()
2863 spin_lock(&gbe_dev->hw_stats_lock); in netcp_ethss_timer()
2870 spin_unlock(&gbe_dev->hw_stats_lock); in netcp_ethss_timer()
2872 gbe_dev->timer.expires = jiffies + GBE_TIMER_INTERVAL; in netcp_ethss_timer()
2873 add_timer(&gbe_dev->timer); in netcp_ethss_timer()
2880 p_info->tx_pipe = &gbe_intf->tx_pipe; in gbe_txhook()
2895 struct gbe_priv *gbe_dev = gbe_intf->gbe_dev; in gbe_open()
2897 struct gbe_slave *slave = gbe_intf->slave; in gbe_open()
2898 int port_num = slave->port_num; in gbe_open()
2903 dev_dbg(gbe_dev->dev, "initializing gbe version %d.%d (%d) GBE identification value 0x%x\n", in gbe_open()
2909 gbe_intf->tx_pipe.flags = SWITCH_TO_PORT_IN_TAGINFO; in gbe_open()
2911 if (gbe_dev->enable_ale) in gbe_open()
2912 gbe_intf->tx_pipe.switch_to_port = 0; in gbe_open()
2914 gbe_intf->tx_pipe.switch_to_port = port_num; in gbe_open()
2916 dev_dbg(gbe_dev->dev, in gbe_open()
2918 gbe_intf->tx_pipe.dma_chan_name, in gbe_open()
2919 gbe_intf->tx_pipe.dma_channel, in gbe_open()
2920 gbe_intf->tx_pipe.switch_to_port, in gbe_open()
2921 gbe_intf->tx_pipe.flags); in gbe_open()
2932 netcp->hw_cap = ETH_SW_CAN_REMOVE_ETH_FCS; in gbe_open()
2937 writel(gbe_dev->stats_en_mask, GBE_REG_ADDR(gbe_dev, switch_regs, in gbe_open()
2947 slave->open = true; in gbe_open()
2963 struct gbe_priv *gbe_dev = gbe_intf->gbe_dev; in gbe_close()
2972 gbe_intf->slave->open = false; in gbe_close()
2973 atomic_set(&gbe_intf->slave->link_state, NETCP_LINK_STATE_INVALID); in gbe_close()
2980 slave->ts_ctl.uni = 1; in init_slave_ts_ctl()
2981 slave->ts_ctl.dst_port_map = in init_slave_ts_ctl()
2983 slave->ts_ctl.maddr_map = in init_slave_ts_ctl()
3000 if (of_property_read_u32(node, "slave-port", &slave->slave_num)) { in init_slave()
3001 dev_err(gbe_dev->dev, "missing slave-port parameter\n"); in init_slave()
3002 return -EINVAL; in init_slave()
3005 if (of_property_read_u32(node, "link-interface", in init_slave()
3006 &slave->link_interface)) { in init_slave()
3007 dev_warn(gbe_dev->dev, in init_slave()
3008 "missing link-interface value defaulting to 1G mac-phy link\n"); in init_slave()
3009 slave->link_interface = SGMII_LINK_MAC_PHY; in init_slave()
3012 slave->node = node; in init_slave()
3013 slave->open = false; in init_slave()
3014 if ((slave->link_interface == SGMII_LINK_MAC_PHY) || in init_slave()
3015 (slave->link_interface == RGMII_LINK_MAC_PHY) || in init_slave()
3016 (slave->link_interface == XGMII_LINK_MAC_PHY)) in init_slave()
3017 slave->phy_node = of_parse_phandle(node, "phy-handle", 0); in init_slave()
3018 slave->port_num = gbe_get_slave_port(gbe_dev, slave->slave_num); in init_slave()
3020 if (slave->link_interface >= XGMII_LINK_MAC_PHY) in init_slave()
3021 slave->mac_control = GBE_DEF_10G_MAC_CONTROL; in init_slave()
3023 slave->mac_control = GBE_DEF_1G_MAC_CONTROL; in init_slave()
3026 port_reg_num = slave->slave_num; in init_slave()
3028 if (slave->slave_num > 1) { in init_slave()
3030 port_reg_num -= 2; in init_slave()
3048 dev_err(gbe_dev->dev, "unknown ethss(0x%x)\n", in init_slave()
3049 gbe_dev->ss_version); in init_slave()
3050 return -EINVAL; in init_slave()
3053 slave->port_regs = gbe_dev->switch_regs + port_reg_ofs + in init_slave()
3055 slave->emac_regs = gbe_dev->switch_regs + emac_reg_ofs + in init_slave()
3056 (emac_reg_blk_sz * slave->slave_num); in init_slave()
3111 atomic_set(&slave->link_state, NETCP_LINK_STATE_INVALID); in init_slave()
3120 struct device *dev = gbe_dev->dev; in init_secondary_ports()
3146 gbe_port_config(gbe_dev, slave, gbe_dev->rx_packet_max); in init_secondary_ports()
3147 list_add_tail(&slave->slave_list, &gbe_dev->secondary_slaves); in init_secondary_ports()
3148 gbe_dev->num_slaves++; in init_secondary_ports()
3149 if ((slave->link_interface == SGMII_LINK_MAC_PHY) || in init_secondary_ports()
3150 (slave->link_interface == XGMII_LINK_MAC_PHY)) in init_secondary_ports()
3153 slave->open = true; in init_secondary_ports()
3154 if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves) { in init_secondary_ports()
3160 /* of_phy_connect() is needed only for MAC-PHY interface */ in init_secondary_ports()
3165 gbe_dev->dummy_ndev = alloc_netdev(sizeof(gbe_dev), "dummy", in init_secondary_ports()
3167 if (!gbe_dev->dummy_ndev) { in init_secondary_ports()
3172 priv = netdev_priv(gbe_dev->dummy_ndev); in init_secondary_ports()
3175 if (slave->link_interface == SGMII_LINK_MAC_PHY) { in init_secondary_ports()
3177 slave->phy_port_t = PORT_MII; in init_secondary_ports()
3178 } else if (slave->link_interface == RGMII_LINK_MAC_PHY) { in init_secondary_ports()
3180 slave->phy_port_t = PORT_MII; in init_secondary_ports()
3183 slave->phy_port_t = PORT_FIBRE; in init_secondary_ports()
3187 if ((slave->link_interface != SGMII_LINK_MAC_PHY) && in init_secondary_ports()
3188 (slave->link_interface != RGMII_LINK_MAC_PHY) && in init_secondary_ports()
3189 (slave->link_interface != XGMII_LINK_MAC_PHY)) in init_secondary_ports()
3191 slave->phy = in init_secondary_ports()
3192 of_phy_connect(gbe_dev->dummy_ndev, in init_secondary_ports()
3193 slave->phy_node, in init_secondary_ports()
3196 if (!slave->phy) { in init_secondary_ports()
3198 slave->slave_num); in init_secondary_ports()
3201 phydev_name(slave->phy)); in init_secondary_ports()
3202 phy_start(slave->phy); in init_secondary_ports()
3211 while (!list_empty(&gbe_dev->secondary_slaves)) { in free_secondary_ports()
3214 if (slave->phy) in free_secondary_ports()
3215 phy_disconnect(slave->phy); in free_secondary_ports()
3216 list_del(&slave->slave_list); in free_secondary_ports()
3218 if (gbe_dev->dummy_ndev) in free_secondary_ports()
3219 free_netdev(gbe_dev->dummy_ndev); in free_secondary_ports()
3231 dev_err(gbe_dev->dev, in set_xgbe_ethss10_priv()
3237 regs = devm_ioremap_resource(gbe_dev->dev, &res); in set_xgbe_ethss10_priv()
3239 dev_err(gbe_dev->dev, "Failed to map xgbe ss register base\n"); in set_xgbe_ethss10_priv()
3242 gbe_dev->ss_regs = regs; in set_xgbe_ethss10_priv()
3246 dev_err(gbe_dev->dev, in set_xgbe_ethss10_priv()
3252 regs = devm_ioremap_resource(gbe_dev->dev, &res); in set_xgbe_ethss10_priv()
3254 dev_err(gbe_dev->dev, "Failed to map xgbe sm register base\n"); in set_xgbe_ethss10_priv()
3257 gbe_dev->switch_regs = regs; in set_xgbe_ethss10_priv()
3261 dev_err(gbe_dev->dev, in set_xgbe_ethss10_priv()
3267 regs = devm_ioremap_resource(gbe_dev->dev, &res); in set_xgbe_ethss10_priv()
3269 dev_err(gbe_dev->dev, "Failed to map xgbe serdes register base\n"); in set_xgbe_ethss10_priv()
3272 gbe_dev->xgbe_serdes_regs = regs; in set_xgbe_ethss10_priv()
3274 gbe_dev->num_stats_mods = gbe_dev->max_num_ports; in set_xgbe_ethss10_priv()
3275 gbe_dev->et_stats = xgbe10_et_stats; in set_xgbe_ethss10_priv()
3276 gbe_dev->num_et_stats = ARRAY_SIZE(xgbe10_et_stats); in set_xgbe_ethss10_priv()
3278 gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev, in set_xgbe_ethss10_priv()
3279 gbe_dev->num_et_stats, sizeof(u64), in set_xgbe_ethss10_priv()
3281 if (!gbe_dev->hw_stats) { in set_xgbe_ethss10_priv()
3282 dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n"); in set_xgbe_ethss10_priv()
3283 return -ENOMEM; in set_xgbe_ethss10_priv()
3286 gbe_dev->hw_stats_prev = in set_xgbe_ethss10_priv()
3287 devm_kcalloc(gbe_dev->dev, in set_xgbe_ethss10_priv()
3288 gbe_dev->num_et_stats, sizeof(u32), in set_xgbe_ethss10_priv()
3290 if (!gbe_dev->hw_stats_prev) { in set_xgbe_ethss10_priv()
3291 dev_err(gbe_dev->dev, in set_xgbe_ethss10_priv()
3293 return -ENOMEM; in set_xgbe_ethss10_priv()
3296 gbe_dev->ss_version = XGBE_SS_VERSION_10; in set_xgbe_ethss10_priv()
3297 gbe_dev->sgmii_port_regs = gbe_dev->ss_regs + in set_xgbe_ethss10_priv()
3299 gbe_dev->host_port_regs = gbe_dev->ss_regs + XGBE10_HOST_PORT_OFFSET; in set_xgbe_ethss10_priv()
3301 for (i = 0; i < gbe_dev->max_num_ports; i++) in set_xgbe_ethss10_priv()
3302 gbe_dev->hw_stats_regs[i] = gbe_dev->switch_regs + in set_xgbe_ethss10_priv()
3305 gbe_dev->ale_reg = gbe_dev->switch_regs + XGBE10_ALE_OFFSET; in set_xgbe_ethss10_priv()
3306 gbe_dev->cpts_reg = gbe_dev->switch_regs + XGBE10_CPTS_OFFSET; in set_xgbe_ethss10_priv()
3307 gbe_dev->ale_ports = gbe_dev->max_num_ports; in set_xgbe_ethss10_priv()
3308 gbe_dev->host_port = XGBE10_HOST_PORT_NUM; in set_xgbe_ethss10_priv()
3309 gbe_dev->stats_en_mask = (1 << (gbe_dev->max_num_ports)) - 1; in set_xgbe_ethss10_priv()
3315 /* Switch module registers */ in set_xgbe_ethss10_priv()
3338 dev_err(gbe_dev->dev, in get_gbe_resource_version()
3344 regs = devm_ioremap_resource(gbe_dev->dev, &res); in get_gbe_resource_version()
3346 dev_err(gbe_dev->dev, "Failed to map gbe register base\n"); in get_gbe_resource_version()
3349 gbe_dev->ss_regs = regs; in get_gbe_resource_version()
3350 gbe_dev->ss_version = readl(gbe_dev->ss_regs); in get_gbe_resource_version()
3363 dev_err(gbe_dev->dev, in set_gbe_ethss14_priv()
3369 regs = devm_ioremap_resource(gbe_dev->dev, &res); in set_gbe_ethss14_priv()
3371 dev_err(gbe_dev->dev, in set_gbe_ethss14_priv()
3375 gbe_dev->sgmii_port34_regs = regs; in set_gbe_ethss14_priv()
3379 dev_err(gbe_dev->dev, in set_gbe_ethss14_priv()
3385 regs = devm_ioremap_resource(gbe_dev->dev, &res); in set_gbe_ethss14_priv()
3387 dev_err(gbe_dev->dev, in set_gbe_ethss14_priv()
3388 "Failed to map gbe switch module register base\n"); in set_gbe_ethss14_priv()
3391 gbe_dev->switch_regs = regs; in set_gbe_ethss14_priv()
3393 gbe_dev->num_stats_mods = gbe_dev->max_num_slaves; in set_gbe_ethss14_priv()
3394 gbe_dev->et_stats = gbe13_et_stats; in set_gbe_ethss14_priv()
3395 gbe_dev->num_et_stats = ARRAY_SIZE(gbe13_et_stats); in set_gbe_ethss14_priv()
3397 gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev, in set_gbe_ethss14_priv()
3398 gbe_dev->num_et_stats, sizeof(u64), in set_gbe_ethss14_priv()
3400 if (!gbe_dev->hw_stats) { in set_gbe_ethss14_priv()
3401 dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n"); in set_gbe_ethss14_priv()
3402 return -ENOMEM; in set_gbe_ethss14_priv()
3405 gbe_dev->hw_stats_prev = in set_gbe_ethss14_priv()
3406 devm_kcalloc(gbe_dev->dev, in set_gbe_ethss14_priv()
3407 gbe_dev->num_et_stats, sizeof(u32), in set_gbe_ethss14_priv()
3409 if (!gbe_dev->hw_stats_prev) { in set_gbe_ethss14_priv()
3410 dev_err(gbe_dev->dev, in set_gbe_ethss14_priv()
3412 return -ENOMEM; in set_gbe_ethss14_priv()
3415 gbe_dev->sgmii_port_regs = gbe_dev->ss_regs + GBE13_SGMII_MODULE_OFFSET; in set_gbe_ethss14_priv()
3416 gbe_dev->host_port_regs = gbe_dev->switch_regs + GBE13_HOST_PORT_OFFSET; in set_gbe_ethss14_priv()
3422 for (i = 0; i < gbe_dev->max_num_slaves; i++) { in set_gbe_ethss14_priv()
3423 gbe_dev->hw_stats_regs[i] = in set_gbe_ethss14_priv()
3424 gbe_dev->switch_regs + GBE13_HW_STATS_OFFSET + in set_gbe_ethss14_priv()
3428 gbe_dev->cpts_reg = gbe_dev->switch_regs + GBE13_CPTS_OFFSET; in set_gbe_ethss14_priv()
3429 gbe_dev->ale_reg = gbe_dev->switch_regs + GBE13_ALE_OFFSET; in set_gbe_ethss14_priv()
3430 gbe_dev->ale_ports = gbe_dev->max_num_ports; in set_gbe_ethss14_priv()
3431 gbe_dev->host_port = GBE13_HOST_PORT_NUM; in set_gbe_ethss14_priv()
3432 gbe_dev->stats_en_mask = GBE13_REG_VAL_STAT_ENABLE_ALL; in set_gbe_ethss14_priv()
3437 /* Switch module registers */ in set_gbe_ethss14_priv()
3458 gbe_dev->num_stats_mods = gbe_dev->max_num_ports; in set_gbenu_ethss_priv()
3459 gbe_dev->et_stats = gbenu_et_stats; in set_gbenu_ethss_priv()
3462 gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE + in set_gbenu_ethss_priv()
3463 (gbe_dev->max_num_slaves * GBENU_ET_STATS_PORT_SIZE); in set_gbenu_ethss_priv()
3465 gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE + in set_gbenu_ethss_priv()
3468 gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev, in set_gbenu_ethss_priv()
3469 gbe_dev->num_et_stats, sizeof(u64), in set_gbenu_ethss_priv()
3471 if (!gbe_dev->hw_stats) { in set_gbenu_ethss_priv()
3472 dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n"); in set_gbenu_ethss_priv()
3473 return -ENOMEM; in set_gbenu_ethss_priv()
3476 gbe_dev->hw_stats_prev = in set_gbenu_ethss_priv()
3477 devm_kcalloc(gbe_dev->dev, in set_gbenu_ethss_priv()
3478 gbe_dev->num_et_stats, sizeof(u32), in set_gbenu_ethss_priv()
3480 if (!gbe_dev->hw_stats_prev) { in set_gbenu_ethss_priv()
3481 dev_err(gbe_dev->dev, in set_gbenu_ethss_priv()
3483 return -ENOMEM; in set_gbenu_ethss_priv()
3488 dev_err(gbe_dev->dev, in set_gbenu_ethss_priv()
3494 regs = devm_ioremap_resource(gbe_dev->dev, &res); in set_gbenu_ethss_priv()
3496 dev_err(gbe_dev->dev, in set_gbenu_ethss_priv()
3497 "Failed to map gbenu switch module register base\n"); in set_gbenu_ethss_priv()
3500 gbe_dev->switch_regs = regs; in set_gbenu_ethss_priv()
3503 gbe_dev->sgmii_port_regs = in set_gbenu_ethss_priv()
3504 gbe_dev->ss_regs + GBENU_SGMII_MODULE_OFFSET; in set_gbenu_ethss_priv()
3510 gbe_dev->sgmii_port34_regs = gbe_dev->sgmii_port_regs + in set_gbenu_ethss_priv()
3513 gbe_dev->host_port_regs = gbe_dev->switch_regs + GBENU_HOST_PORT_OFFSET; in set_gbenu_ethss_priv()
3515 for (i = 0; i < (gbe_dev->max_num_ports); i++) in set_gbenu_ethss_priv()
3516 gbe_dev->hw_stats_regs[i] = gbe_dev->switch_regs + in set_gbenu_ethss_priv()
3519 gbe_dev->cpts_reg = gbe_dev->switch_regs + GBENU_CPTS_OFFSET; in set_gbenu_ethss_priv()
3520 gbe_dev->ale_reg = gbe_dev->switch_regs + GBENU_ALE_OFFSET; in set_gbenu_ethss_priv()
3521 gbe_dev->ale_ports = gbe_dev->max_num_ports; in set_gbenu_ethss_priv()
3522 gbe_dev->host_port = GBENU_HOST_PORT_NUM; in set_gbenu_ethss_priv()
3523 gbe_dev->stats_en_mask = (1 << (gbe_dev->max_num_ports)) - 1; in set_gbenu_ethss_priv()
3530 /* Switch module registers */ in set_gbenu_ethss_priv()
3541 * NU cppi port 0 tx pkt streaming interface has (n-1)*8 egress threads in set_gbenu_ethss_priv()
3560 return -ENODEV; in gbe_probe()
3565 return -ENOMEM; in gbe_probe()
3567 if (of_device_is_compatible(node, "ti,netcp-gbe-5") || in gbe_probe()
3568 of_device_is_compatible(node, "ti,netcp-gbe")) { in gbe_probe()
3569 gbe_dev->max_num_slaves = 4; in gbe_probe()
3570 } else if (of_device_is_compatible(node, "ti,netcp-gbe-9")) { in gbe_probe()
3571 gbe_dev->max_num_slaves = 8; in gbe_probe()
3572 } else if (of_device_is_compatible(node, "ti,netcp-gbe-2")) { in gbe_probe()
3573 gbe_dev->max_num_slaves = 1; in gbe_probe()
3575 } else if (of_device_is_compatible(node, "ti,netcp-xgbe")) { in gbe_probe()
3576 gbe_dev->max_num_slaves = 2; in gbe_probe()
3579 return -EINVAL; in gbe_probe()
3581 gbe_dev->max_num_ports = gbe_dev->max_num_slaves + 1; in gbe_probe()
3583 gbe_dev->dev = dev; in gbe_probe()
3584 gbe_dev->netcp_device = netcp_device; in gbe_probe()
3585 gbe_dev->rx_packet_max = NETCP_MAX_FRAME_SIZE; in gbe_probe()
3588 spin_lock_init(&gbe_dev->hw_stats_lock); in gbe_probe()
3590 if (of_find_property(node, "enable-ale", NULL)) { in gbe_probe()
3591 gbe_dev->enable_ale = true; in gbe_probe()
3594 gbe_dev->enable_ale = false; in gbe_probe()
3598 ret = of_property_read_u32(node, "tx-queue", in gbe_probe()
3599 &gbe_dev->tx_queue_id); in gbe_probe()
3602 gbe_dev->tx_queue_id = GBE_TX_QUEUE; in gbe_probe()
3605 ret = of_property_read_string(node, "tx-channel", in gbe_probe()
3606 &gbe_dev->dma_chan_name); in gbe_probe()
3608 dev_err(dev, "missing \"tx-channel\" parameter\n"); in gbe_probe()
3609 return -EINVAL; in gbe_probe()
3617 dev_dbg(dev, "ss_version: 0x%08x\n", gbe_dev->ss_version); in gbe_probe()
3624 ret = -ENODEV; in gbe_probe()
3630 ret = netcp_xgbe_serdes_init(gbe_dev->xgbe_serdes_regs, in gbe_probe()
3631 gbe_dev->ss_regs); in gbe_probe()
3634 ret = -ENODEV; in gbe_probe()
3644 ret = netcp_txpipe_init(&gbe_dev->tx_pipe, netcp_device, in gbe_probe()
3645 gbe_dev->dma_chan_name, gbe_dev->tx_queue_id); in gbe_probe()
3651 ret = netcp_txpipe_open(&gbe_dev->tx_pipe); in gbe_probe()
3658 INIT_LIST_HEAD(&gbe_dev->gbe_intf_head); in gbe_probe()
3660 ret = of_property_read_u32(interface, "slave-port", &slave_num); in gbe_probe()
3662 dev_err(dev, "missing slave-port parameter, skipping interface configuration for %pOFn\n", in gbe_probe()
3666 gbe_dev->num_slaves++; in gbe_probe()
3667 if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves) { in gbe_probe()
3674 if (!gbe_dev->num_slaves) in gbe_probe()
3678 secondary_ports = of_get_child_by_name(node, "secondary-slave-ports"); in gbe_probe()
3679 INIT_LIST_HEAD(&gbe_dev->secondary_slaves); in gbe_probe()
3680 if (secondary_ports && (gbe_dev->num_slaves < gbe_dev->max_num_slaves)) in gbe_probe()
3684 if (!gbe_dev->num_slaves) { in gbe_probe()
3687 ret = -ENODEV; in gbe_probe()
3692 ale_params.dev = gbe_dev->dev; in gbe_probe()
3693 ale_params.ale_regs = gbe_dev->ale_reg; in gbe_probe()
3695 ale_params.ale_ports = gbe_dev->ale_ports; in gbe_probe()
3696 ale_params.dev_id = "cpsw"; in gbe_probe()
3702 ale_params.dev_id = "66ak2h-xgbe"; in gbe_probe()
3704 gbe_dev->ale = cpsw_ale_create(&ale_params); in gbe_probe()
3705 if (IS_ERR(gbe_dev->ale)) { in gbe_probe()
3706 dev_err(gbe_dev->dev, "error initializing ale engine\n"); in gbe_probe()
3707 ret = PTR_ERR(gbe_dev->ale); in gbe_probe()
3710 dev_dbg(gbe_dev->dev, "Created a gbe ale engine\n"); in gbe_probe()
3717 gbe_dev->cpts = cpts_create(gbe_dev->dev, gbe_dev->cpts_reg, in gbe_probe()
3720 if (IS_ENABLED(CONFIG_TI_CPTS) && IS_ERR(gbe_dev->cpts)) { in gbe_probe()
3721 ret = PTR_ERR(gbe_dev->cpts); in gbe_probe()
3728 spin_lock_bh(&gbe_dev->hw_stats_lock); in gbe_probe()
3729 for (i = 0; i < gbe_dev->num_stats_mods; i++) { in gbe_probe()
3735 spin_unlock_bh(&gbe_dev->hw_stats_lock); in gbe_probe()
3737 timer_setup(&gbe_dev->timer, netcp_ethss_timer, 0); in gbe_probe()
3738 gbe_dev->timer.expires = jiffies + GBE_TIMER_INTERVAL; in gbe_probe()
3739 add_timer(&gbe_dev->timer); in gbe_probe()
3756 dev_err(gbe_dev->dev, "interface node not available\n"); in gbe_attach()
3757 return -ENODEV; in gbe_attach()
3760 gbe_intf = devm_kzalloc(gbe_dev->dev, sizeof(*gbe_intf), GFP_KERNEL); in gbe_attach()
3762 return -ENOMEM; in gbe_attach()
3764 gbe_intf->ndev = ndev; in gbe_attach()
3765 gbe_intf->dev = gbe_dev->dev; in gbe_attach()
3766 gbe_intf->gbe_dev = gbe_dev; in gbe_attach()
3768 gbe_intf->slave = devm_kzalloc(gbe_dev->dev, in gbe_attach()
3769 sizeof(*gbe_intf->slave), in gbe_attach()
3771 if (!gbe_intf->slave) { in gbe_attach()
3772 ret = -ENOMEM; in gbe_attach()
3776 if (init_slave(gbe_dev, gbe_intf->slave, node)) { in gbe_attach()
3777 ret = -ENODEV; in gbe_attach()
3781 gbe_intf->tx_pipe = gbe_dev->tx_pipe; in gbe_attach()
3782 ndev->ethtool_ops = &keystone_ethtool_ops; in gbe_attach()
3783 list_add_tail(&gbe_intf->gbe_intf_list, &gbe_dev->gbe_intf_head); in gbe_attach()
3788 if (gbe_intf->slave) in gbe_attach()
3789 devm_kfree(gbe_dev->dev, gbe_intf->slave); in gbe_attach()
3791 devm_kfree(gbe_dev->dev, gbe_intf); in gbe_attach()
3799 gbe_intf->ndev->ethtool_ops = NULL; in gbe_release()
3800 list_del(&gbe_intf->gbe_intf_list); in gbe_release()
3801 devm_kfree(gbe_intf->dev, gbe_intf->slave); in gbe_release()
3802 devm_kfree(gbe_intf->dev, gbe_intf); in gbe_release()
3810 del_timer_sync(&gbe_dev->timer); in gbe_remove()
3811 cpts_release(gbe_dev->cpts); in gbe_remove()
3812 cpsw_ale_stop(gbe_dev->ale); in gbe_remove()
3813 netcp_txpipe_close(&gbe_dev->tx_pipe); in gbe_remove()
3816 if (!list_empty(&gbe_dev->gbe_intf_head)) in gbe_remove()
3817 dev_alert(gbe_dev->dev, in gbe_remove()