Lines Matching +full:clkdiv +full:- +full:-
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
39 * a 3-port store-and-forward switch connected to two independent
252 { -1, 0 }
331 if ((_sc)->debug) { \
341 mtx_assert(&(sc)->rx.lock, MA_NOTOWNED); \
342 mtx_lock(&(sc)->tx.lock); \
345 #define CPSW_TX_UNLOCK(sc) mtx_unlock(&(sc)->tx.lock)
346 #define CPSW_TX_LOCK_ASSERT(sc) mtx_assert(&(sc)->tx.lock, MA_OWNED)
349 mtx_assert(&(sc)->tx.lock, MA_NOTOWNED); \
350 mtx_lock(&(sc)->rx.lock); \
353 #define CPSW_RX_UNLOCK(sc) mtx_unlock(&(sc)->rx.lock)
354 #define CPSW_RX_LOCK_ASSERT(sc) mtx_assert(&(sc)->rx.lock, MA_OWNED)
357 mtx_assert(&(_sc)->lock, MA_NOTOWNED); \
358 mtx_lock(&(_sc)->lock); \
361 #define CPSW_PORT_UNLOCK(_sc) mtx_unlock(&(_sc)->lock)
362 #define CPSW_PORT_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->lock, MA_OWNED)
367 #define cpsw_read_4(_sc, _reg) bus_read_4((_sc)->mem_res, (_reg))
369 bus_write_4((_sc)->mem_res, (_reg), (_val))
374 BUS_SPACE_PHYSADDR(sc->mem_res, slot->bd_offset)
376 bus_read_region_4(sc->mem_res, slot->bd_offset, (uint32_t *) val, 4)
378 bus_write_region_4(sc->mem_res, slot->bd_offset, (uint32_t *) val, 4)
380 cpsw_write_4(sc, slot->bd_offset, cpsw_cpdma_bd_paddr(sc, next_slot))
382 bus_write_2(sc->mem_res, slot->bd_offset + 14, val)
384 bus_read_2(sc->mem_res, slot->bd_offset + 14)
386 cpsw_write_4(sc, (queue)->hdp_offset, cpsw_cpdma_bd_paddr(sc, slot))
387 #define CP_OFFSET (CPSW_CPDMA_TX_CP(0) - CPSW_CPDMA_TX_HDP(0))
389 cpsw_read_4(sc, (queue)->hdp_offset + CP_OFFSET)
391 cpsw_write_4(sc, (queue)->hdp_offset + CP_OFFSET, (val))
400 uint32_t reg = queue->hdp_offset;
437 if (bd.flags & (1 << (15 - i))) { in cpsw_dump_slot()
443 if (slot->mbuf) { in cpsw_dump_slot()
445 (char *)(slot->mbuf->m_data), " "); in cpsw_dump_slot()
447 (char *)(slot->mbuf->m_data) + 14, " "); in cpsw_dump_slot()
488 STAILQ_INIT(&sc->avail); in cpsw_init_slots()
491 for (i = 0; i < nitems(sc->_slots); i++) { in cpsw_init_slots()
492 slot = &sc->_slots[i]; in cpsw_init_slots()
493 slot->bd_offset = cpsw_cpdma_bd_offset(i); in cpsw_init_slots()
494 STAILQ_INSERT_TAIL(&sc->avail, slot, next); in cpsw_init_slots()
501 const int max_slots = nitems(sc->_slots); in cpsw_add_slots()
509 slot = STAILQ_FIRST(&sc->avail); in cpsw_add_slots()
512 if (bus_dmamap_create(sc->mbuf_dtag, 0, &slot->dmamap)) { in cpsw_add_slots()
513 device_printf(sc->dev, "failed to create dmamap\n"); in cpsw_add_slots()
516 STAILQ_REMOVE_HEAD(&sc->avail, next); in cpsw_add_slots()
517 STAILQ_INSERT_TAIL(&queue->avail, slot, next); in cpsw_add_slots()
518 ++queue->avail_queue_len; in cpsw_add_slots()
519 ++queue->queue_slots; in cpsw_add_slots()
529 if (slot->dmamap) { in cpsw_free_slot()
530 if (slot->mbuf) in cpsw_free_slot()
531 bus_dmamap_unload(sc->mbuf_dtag, slot->dmamap); in cpsw_free_slot()
532 error = bus_dmamap_destroy(sc->mbuf_dtag, slot->dmamap); in cpsw_free_slot()
534 slot->dmamap = NULL; in cpsw_free_slot()
536 if (slot->mbuf) { in cpsw_free_slot()
537 m_freem(slot->mbuf); in cpsw_free_slot()
538 slot->mbuf = NULL; in cpsw_free_slot()
547 callout_stop(&sc->watchdog.callout); in cpsw_reset()
613 if (sc->dualemac) in cpsw_init()
658 /* Initialze MDIO - ENABLE, PREAMBLE=0, FAULTENB, CLKDIV=0xFF */ in cpsw_init()
659 /* TODO Calculate MDCLK=CLK/(CLKDIV+1) */ in cpsw_init()
666 slot = STAILQ_FIRST(&sc->tx.active); in cpsw_init()
668 cpsw_write_hdp_slot(sc, &sc->tx, slot); in cpsw_init()
669 slot = STAILQ_FIRST(&sc->rx.active); in cpsw_init()
671 cpsw_write_hdp_slot(sc, &sc->rx, slot); in cpsw_init()
673 cpsw_write_4(sc, CPSW_CPDMA_RX_FREEBUFFER(0), sc->rx.active_queue_len); in cpsw_init()
677 sc->rx.running = 1; in cpsw_init()
678 sc->tx.running = 1; in cpsw_init()
679 sc->watchdog.timer = 0; in cpsw_init()
680 callout_init(&sc->watchdog.callout, 0); in cpsw_init()
681 callout_reset(&sc->watchdog.callout, hz, cpsw_tx_watchdog, sc); in cpsw_init()
700 device_set_desc(dev, "3-port Switch Ethernet Subsystem"); in cpsw_probe()
710 if (bus_setup_intr(sc->dev, sc->irq_res[i], in cpsw_intr_attach()
712 cpsw_intr_cb[i].cb, sc, &sc->ih_cookie[i]) != 0) { in cpsw_intr_attach()
713 return (-1); in cpsw_intr_attach()
726 if (sc->ih_cookie[i]) { in cpsw_intr_detach()
727 bus_teardown_intr(sc->dev, sc->irq_res[i], in cpsw_intr_detach()
728 sc->ih_cookie[i]); in cpsw_intr_detach()
742 /* Find any slave with phy-handle/phy_id */ in cpsw_get_fdt_data()
743 phy = -1; in cpsw_get_fdt_data()
744 vlan = -1; in cpsw_get_fdt_data()
745 for (child = OF_child(sc->node); child != 0; child = OF_peer(child)) { in cpsw_get_fdt_data()
760 phy = -1; in cpsw_get_fdt_data()
780 if (phy == -1) in cpsw_get_fdt_data()
782 sc->port[port].phy = phy; in cpsw_get_fdt_data()
783 sc->port[port].vlan = vlan; in cpsw_get_fdt_data()
796 sc->dev = dev; in cpsw_attach()
797 sc->node = ofw_bus_get_node(dev); in cpsw_attach()
798 getbinuptime(&sc->attach_uptime); in cpsw_attach()
800 if (OF_getencprop(sc->node, "active_slave", &sc->active_slave, in cpsw_attach()
801 sizeof(sc->active_slave)) <= 0) { in cpsw_attach()
802 sc->active_slave = 0; in cpsw_attach()
804 if (sc->active_slave > 1) in cpsw_attach()
805 sc->active_slave = 1; in cpsw_attach()
807 if (OF_hasprop(sc->node, "dual_emac")) in cpsw_attach()
808 sc->dualemac = 1; in cpsw_attach()
811 if (!sc->dualemac && i != sc->active_slave) in cpsw_attach()
821 mtx_init(&sc->tx.lock, device_get_nameunit(dev), in cpsw_attach()
823 mtx_init(&sc->rx.lock, device_get_nameunit(dev), in cpsw_attach()
827 error = bus_alloc_resources(dev, irq_res_spec, sc->irq_res); in cpsw_attach()
834 sc->mem_rid = 0; in cpsw_attach()
835 sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, in cpsw_attach()
836 &sc->mem_rid, RF_ACTIVE); in cpsw_attach()
837 if (sc->mem_res == NULL) { in cpsw_attach()
838 device_printf(sc->dev, "failed to allocate memory resource\n"); in cpsw_attach()
851 bus_get_dma_tag(sc->dev), /* parent */ in cpsw_attach()
859 &sc->mbuf_dtag); /* dmatag */ in cpsw_attach()
867 sc->nullpad = malloc(ETHER_MIN_LEN, M_DEVBUF, M_WAITOK | M_ZERO); in cpsw_attach()
872 STAILQ_INIT(&sc->rx.avail); in cpsw_attach()
873 STAILQ_INIT(&sc->rx.active); in cpsw_attach()
874 STAILQ_INIT(&sc->tx.avail); in cpsw_attach()
875 STAILQ_INIT(&sc->tx.active); in cpsw_attach()
878 if (cpsw_add_slots(sc, &sc->tx, 128) || in cpsw_attach()
879 cpsw_add_slots(sc, &sc->rx, -1)) { in cpsw_attach()
885 sc->tx.queue_slots, sc->rx.queue_slots); in cpsw_attach()
887 sc->tx.hdp_offset = CPSW_CPDMA_TX_HDP(0); in cpsw_attach()
888 sc->rx.hdp_offset = CPSW_CPDMA_RX_HDP(0); in cpsw_attach()
890 if (cpsw_intr_attach(sc) == -1) { in cpsw_attach()
898 cpsw_vgroups[i].vid = -1; in cpsw_attach()
906 if (!sc->dualemac && i != sc->active_slave) in cpsw_attach()
908 sc->port[i].dev = device_add_child(dev, "cpsw", i); in cpsw_attach()
909 if (sc->port[i].dev == NULL) { in cpsw_attach()
930 if (sc->port[i].dev) in cpsw_detach()
931 device_delete_child(dev, sc->port[i].dev); in cpsw_detach()
935 callout_stop(&sc->watchdog.callout); in cpsw_detach()
936 callout_drain(&sc->watchdog.callout); in cpsw_detach()
943 for (i = 0; i < nitems(sc->_slots); ++i) in cpsw_detach()
944 cpsw_free_slot(sc, &sc->_slots[i]); in cpsw_detach()
947 if (sc->nullpad) in cpsw_detach()
948 free(sc->nullpad, M_DEVBUF); in cpsw_detach()
951 if (sc->mbuf_dtag) { in cpsw_detach()
952 error = bus_dma_tag_destroy(sc->mbuf_dtag); in cpsw_detach()
957 if (sc->mem_res != NULL) in cpsw_detach()
958 bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem_res); in cpsw_detach()
959 bus_release_resources(dev, irq_res_spec, sc->irq_res); in cpsw_detach()
962 mtx_destroy(&sc->rx.lock); in cpsw_detach()
963 mtx_destroy(&sc->tx.lock); in cpsw_detach()
1006 sc->dev = dev; in cpswp_attach()
1007 sc->pdev = device_get_parent(dev); in cpswp_attach()
1008 sc->swsc = device_get_softc(sc->pdev); in cpswp_attach()
1009 sc->unit = device_get_unit(dev); in cpswp_attach()
1010 sc->phy = sc->swsc->port[sc->unit].phy; in cpswp_attach()
1011 sc->vlan = sc->swsc->port[sc->unit].vlan; in cpswp_attach()
1012 if (sc->swsc->dualemac && sc->vlan == -1) in cpswp_attach()
1013 sc->vlan = sc->unit + 1; in cpswp_attach()
1015 if (sc->unit == 0) { in cpswp_attach()
1016 sc->physel = MDIOUSERPHYSEL0; in cpswp_attach()
1017 sc->phyaccess = MDIOUSERACCESS0; in cpswp_attach()
1019 sc->physel = MDIOUSERPHYSEL1; in cpswp_attach()
1020 sc->phyaccess = MDIOUSERACCESS1; in cpswp_attach()
1023 mtx_init(&sc->lock, device_get_nameunit(dev), "cpsw port lock", in cpswp_attach()
1027 ifp = sc->ifp = if_alloc(IFT_ETHER); in cpswp_attach()
1028 if_initname(ifp, device_get_name(sc->dev), sc->unit); in cpswp_attach()
1038 if_setsendqlen(ifp, sc->swsc->tx.queue_slots); in cpswp_attach()
1041 /* FIXME: For now; Go and kidnap syscon from opp-table */ in cpswp_attach()
1043 opp_table = OF_finddevice("/opp-table"); in cpswp_attach()
1044 if (opp_table == -1) { in cpswp_attach()
1045 device_printf(dev, "Cant find /opp-table\n"); in cpswp_attach()
1050 device_printf(dev, "/opp-table doesnt have required syscon property\n"); in cpswp_attach()
1061 reg = SYSCON_READ_4(syscon, SCM_MAC_ID0_HI + sc->unit * 8); in cpswp_attach()
1068 reg = SYSCON_READ_4(syscon, SCM_MAC_ID0_LO + sc->unit * 8); in cpswp_attach()
1072 error = mii_attach(dev, &sc->miibus, ifp, cpswp_ifmedia_upd, in cpswp_attach()
1073 cpswp_ifmedia_sts, BMSR_DEFCAPMASK, sc->phy, MII_OFFSET_ANY, 0); in cpswp_attach()
1079 sc->mii = device_get_softc(sc->miibus); in cpswp_attach()
1082 cpsw_write_4(sc->swsc, sc->physel, in cpswp_attach()
1083 MDIO_PHYSEL_LINKINTENB | (sc->phy & 0x1F)); in cpswp_attach()
1085 ether_ifattach(sc->ifp, mac_addr); in cpswp_attach()
1086 callout_init(&sc->mii_callout, 0); in cpswp_attach()
1097 CPSW_DEBUGF(sc->swsc, ("")); in cpswp_detach()
1099 ether_ifdetach(sc->ifp); in cpswp_detach()
1103 callout_drain(&sc->mii_callout); in cpswp_detach()
1108 if_free(sc->ifp); in cpswp_detach()
1109 mtx_destroy(&sc->lock); in cpswp_detach()
1126 if (!sc->dualemac) in cpsw_ports_down()
1128 psc = device_get_softc(sc->port[0].dev); in cpsw_ports_down()
1129 ifp1 = psc->ifp; in cpsw_ports_down()
1130 psc = device_get_softc(sc->port[1].dev); in cpsw_ports_down()
1131 ifp2 = psc->ifp; in cpsw_ports_down()
1143 CPSW_DEBUGF(sc->swsc, ("")); in cpswp_init()
1159 CPSW_DEBUGF(sc->swsc, ("")); in cpswp_init_locked()
1161 ifp = sc->ifp; in cpswp_init_locked()
1165 getbinuptime(&sc->init_uptime); in cpswp_init_locked()
1167 if (!sc->swsc->rx.running && !sc->swsc->tx.running) { in cpswp_init_locked()
1169 cpsw_reset(sc->swsc); in cpswp_init_locked()
1170 cpsw_init(sc->swsc); in cpswp_init_locked()
1174 cpsw_write_4(sc->swsc, CPSW_SL_RX_PRI_MAP(sc->unit), 0x76543210); in cpswp_init_locked()
1175 cpsw_write_4(sc->swsc, CPSW_PORT_P_TX_PRI_MAP(sc->unit + 1), in cpswp_init_locked()
1177 cpsw_write_4(sc->swsc, CPSW_SL_RX_MAXLEN(sc->unit), 0x5f2); in cpswp_init_locked()
1181 reg = cpsw_read_4(sc->swsc, CPSW_SL_MACCONTROL(sc->unit)); in cpswp_init_locked()
1183 cpsw_write_4(sc->swsc, CPSW_SL_MACCONTROL(sc->unit), reg); in cpswp_init_locked()
1186 cpsw_write_4(sc->swsc, CPSW_ALE_PORTCTL(sc->unit + 1), in cpswp_init_locked()
1190 if (sc->swsc->dualemac) { in cpswp_init_locked()
1192 cpsw_write_4(sc->swsc, CPSW_PORT_P_VLAN(sc->unit + 1), in cpswp_init_locked()
1193 sc->vlan & 0xfff); in cpswp_init_locked()
1194 cpsw_ale_update_vlan_table(sc->swsc, sc->vlan, in cpswp_init_locked()
1195 (1 << (sc->unit + 1)) | (1 << 0), /* Member list */ in cpswp_init_locked()
1196 (1 << (sc->unit + 1)) | (1 << 0), /* Untagged egress */ in cpswp_init_locked()
1197 (1 << (sc->unit + 1)) | (1 << 0), 0); /* mcast reg flood */ in cpswp_init_locked()
1200 if (cpsw_vgroups[i].vid != -1) in cpswp_init_locked()
1202 cpsw_vgroups[i].vid = sc->vlan; in cpswp_init_locked()
1208 mii_mediachg(sc->mii); in cpswp_init_locked()
1209 callout_reset(&sc->mii_callout, hz, cpswp_tick, sc); in cpswp_init_locked()
1224 if (!sc->dualemac && i != sc->active_slave) in cpsw_shutdown()
1226 psc = device_get_softc(sc->port[i].dev); in cpsw_shutdown()
1242 sc->rx.teardown = 1; in cpsw_rx_teardown()
1245 while (sc->rx.running) { in cpsw_rx_teardown()
1247 device_printf(sc->dev, in cpsw_rx_teardown()
1253 if (!sc->rx.running) in cpsw_rx_teardown()
1265 if (STAILQ_FIRST(&sc->tx.active) != NULL) in cpsw_tx_teardown()
1268 sc->tx.teardown = 1; in cpsw_tx_teardown()
1270 while (sc->tx.running && ++i < 10) { in cpsw_tx_teardown()
1274 if (sc->tx.running) { in cpsw_tx_teardown()
1275 device_printf(sc->dev, in cpsw_tx_teardown()
1280 sc->tx.active_queue_len)); in cpsw_tx_teardown()
1290 ifp = sc->ifp; in cpswp_stop_locked()
1291 CPSW_DEBUGF(sc->swsc, ("")); in cpswp_stop_locked()
1302 callout_stop(&sc->mii_callout); in cpswp_stop_locked()
1305 if (cpsw_ports_down(sc->swsc)) { in cpswp_stop_locked()
1306 cpsw_rx_teardown(sc->swsc); in cpswp_stop_locked()
1307 cpsw_tx_teardown(sc->swsc); in cpswp_stop_locked()
1311 reg = cpsw_read_4(sc->swsc, CPSW_SL_MACCONTROL(sc->unit)); in cpswp_stop_locked()
1313 cpsw_write_4(sc->swsc, CPSW_SL_MACCONTROL(sc->unit), reg); in cpswp_stop_locked()
1315 if (cpsw_ports_down(sc->swsc)) { in cpswp_stop_locked()
1317 cpsw_stats_collect(sc->swsc); in cpswp_stop_locked()
1319 cpsw_reset(sc->swsc); in cpswp_stop_locked()
1320 cpsw_init(sc->swsc); in cpswp_stop_locked()
1338 if (!sc->dualemac && i != sc->active_slave) in cpsw_suspend()
1340 psc = device_get_softc(sc->port[i].dev); in cpsw_suspend()
1378 reg = cpsw_read_4(sc->swsc, CPSW_ALE_CONTROL); in cpsw_set_promisc()
1382 cpsw_write_4(sc->swsc, CPSW_ALE_CONTROL, reg); in cpsw_set_promisc()
1389 printf("All-multicast mode unimplemented\n"); in cpsw_set_allmulti()
1407 changed = if_getcapenable(ifp) ^ ifr->ifr_reqcap; in cpswp_ioctl()
1409 if ((ifr->ifr_reqcap & changed) & IFCAP_HWCSUM) in cpswp_ioctl()
1420 changed = if_getflags(ifp) ^ sc->if_flags; in cpswp_ioctl()
1421 CPSW_DEBUGF(sc->swsc, in cpswp_ioctl()
1431 CPSW_DEBUGF(sc->swsc, in cpswp_ioctl()
1436 CPSW_DEBUGF(sc->swsc, ("SIOCSIFFLAGS: shutting down")); in cpswp_ioctl()
1440 sc->if_flags = if_getflags(ifp); in cpswp_ioctl()
1454 error = ifmedia_ioctl(ifp, ifr, &sc->mii->mii_media, command); in cpswp_ioctl()
1472 while (--retries) { in cpswp_miibus_ready()
1489 if (!cpswp_miibus_ready(sc->swsc, sc->phyaccess)) { in cpswp_miibus_readreg()
1496 cpsw_write_4(sc->swsc, sc->phyaccess, cmd); in cpswp_miibus_readreg()
1498 if (!cpswp_miibus_ready(sc->swsc, sc->phyaccess)) { in cpswp_miibus_readreg()
1503 r = cpsw_read_4(sc->swsc, sc->phyaccess); in cpswp_miibus_readreg()
1518 if (!cpswp_miibus_ready(sc->swsc, sc->phyaccess)) { in cpswp_miibus_writereg()
1526 cpsw_write_4(sc->swsc, sc->phyaccess, cmd); in cpswp_miibus_writereg()
1528 if (!cpswp_miibus_ready(sc->swsc, sc->phyaccess)) { in cpswp_miibus_writereg()
1543 CPSW_DEBUGF(sc->swsc, ("")); in cpswp_miibus_statchg()
1545 reg = CPSW_SL_MACCONTROL(sc->unit); in cpswp_miibus_statchg()
1546 mac_control = cpsw_read_4(sc->swsc, reg); in cpswp_miibus_statchg()
1550 switch(IFM_SUBTYPE(sc->mii->mii_media_active)) { in cpswp_miibus_statchg()
1562 if (sc->mii->mii_media_active & IFM_FDX) in cpswp_miibus_statchg()
1565 cpsw_write_4(sc->swsc, reg, mac_control); in cpswp_miibus_statchg()
1582 if (sc->rx.teardown) { in cpsw_intr_rx()
1583 sc->rx.running = 0; in cpsw_intr_rx()
1584 sc->rx.teardown = 0; in cpsw_intr_rx()
1585 cpsw_write_cp(sc, &sc->rx, 0xfffffffc); in cpsw_intr_rx()
1593 next = received->m_nextpkt; in cpsw_intr_rx()
1594 received->m_nextpkt = NULL; in cpsw_intr_rx()
1595 ifp = received->m_pkthdr.rcvif; in cpsw_intr_rx()
1620 while ((slot = STAILQ_FIRST(&sc->rx.active)) != NULL) { in cpsw_rx_dequeue()
1634 STAILQ_REMOVE_HEAD(&sc->rx.active, next); in cpsw_rx_dequeue()
1635 STAILQ_INSERT_TAIL(&sc->rx.avail, slot, next); in cpsw_rx_dequeue()
1637 bus_dmamap_sync(sc->mbuf_dtag, slot->dmamap, BUS_DMASYNC_POSTREAD); in cpsw_rx_dequeue()
1638 bus_dmamap_unload(sc->mbuf_dtag, slot->dmamap); in cpsw_rx_dequeue()
1640 m = slot->mbuf; in cpsw_rx_dequeue()
1641 slot->mbuf = NULL; in cpsw_rx_dequeue()
1646 sc->rx.running = 0; in cpsw_rx_dequeue()
1647 sc->rx.teardown = 0; in cpsw_rx_dequeue()
1651 port = (bd.flags & CPDMA_BD_PORT_MASK) - 1; in cpsw_rx_dequeue()
1654 psc = device_get_softc(sc->port[port].dev); in cpsw_rx_dequeue()
1657 m->m_data += bd.bufoff; in cpsw_rx_dequeue()
1658 m->m_len = bd.buflen; in cpsw_rx_dequeue()
1660 m->m_pkthdr.len = bd.pktlen; in cpsw_rx_dequeue()
1661 m->m_pkthdr.rcvif = psc->ifp; in cpsw_rx_dequeue()
1662 m->m_flags |= M_PKTHDR; in cpsw_rx_dequeue()
1667 m->m_next = NULL; in cpsw_rx_dequeue()
1668 m->m_nextpkt = NULL; in cpsw_rx_dequeue()
1671 m_adj(m0, -ETHER_CRC_LEN); in cpsw_rx_dequeue()
1674 if (nsegs > sc->rx.longest_chain) in cpsw_rx_dequeue()
1675 sc->rx.longest_chain = nsegs; in cpsw_rx_dequeue()
1679 if ((if_getcapenable(psc->ifp) & IFCAP_RXCSUM) != 0) { in cpsw_rx_dequeue()
1684 m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; in cpsw_rx_dequeue()
1685 m->m_pkthdr.csum_flags |= CSUM_IP_VALID; in cpsw_rx_dequeue()
1686 m->m_pkthdr.csum_data = 0xffff; in cpsw_rx_dequeue()
1690 if (STAILQ_FIRST(&sc->rx.active) != NULL && in cpsw_rx_dequeue()
1693 cpsw_write_hdp_slot(sc, &sc->rx, in cpsw_rx_dequeue()
1694 STAILQ_FIRST(&sc->rx.active)); in cpsw_rx_dequeue()
1695 sc->rx.queue_restart++; in cpsw_rx_dequeue()
1700 mb_tail->m_nextpkt = m; in cpsw_rx_dequeue()
1702 mb_tail->m_next = m; in cpsw_rx_dequeue()
1707 __func__, if_name(psc->ifp)); in cpsw_rx_dequeue()
1717 cpsw_write_cp_slot(sc, &sc->rx, last); in cpsw_rx_dequeue()
1718 sc->rx.queue_removes += removed; in cpsw_rx_dequeue()
1719 sc->rx.avail_queue_len += removed; in cpsw_rx_dequeue()
1720 sc->rx.active_queue_len -= removed; in cpsw_rx_dequeue()
1721 if (sc->rx.avail_queue_len > sc->rx.max_avail_queue_len) in cpsw_rx_dequeue()
1722 sc->rx.max_avail_queue_len = sc->rx.avail_queue_len; in cpsw_rx_dequeue()
1739 last_old_slot = STAILQ_LAST(&sc->rx.active, cpsw_slot, next); in cpsw_rx_enqueue()
1740 while ((slot = STAILQ_FIRST(&sc->rx.avail)) != NULL) { in cpsw_rx_enqueue()
1743 if (slot->mbuf == NULL) { in cpsw_rx_enqueue()
1744 slot->mbuf = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); in cpsw_rx_enqueue()
1745 if (slot->mbuf == NULL) { in cpsw_rx_enqueue()
1746 device_printf(sc->dev, in cpsw_rx_enqueue()
1750 slot->mbuf->m_len = in cpsw_rx_enqueue()
1751 slot->mbuf->m_pkthdr.len = in cpsw_rx_enqueue()
1752 slot->mbuf->m_ext.ext_size; in cpsw_rx_enqueue()
1755 error = bus_dmamap_load_mbuf_sg(sc->mbuf_dtag, slot->dmamap, in cpsw_rx_enqueue()
1756 slot->mbuf, seg, &nsegs, BUS_DMA_NOWAIT); in cpsw_rx_enqueue()
1761 device_printf(sc->dev, in cpsw_rx_enqueue()
1764 bus_dmamap_unload(sc->mbuf_dtag, slot->dmamap); in cpsw_rx_enqueue()
1765 m_freem(slot->mbuf); in cpsw_rx_enqueue()
1766 slot->mbuf = NULL; in cpsw_rx_enqueue()
1770 bus_dmamap_sync(sc->mbuf_dtag, slot->dmamap, BUS_DMASYNC_PREREAD); in cpsw_rx_enqueue()
1777 bd.bufptr = seg->ds_addr; in cpsw_rx_enqueue()
1779 bd.buflen = MCLBYTES - 1; in cpsw_rx_enqueue()
1785 STAILQ_REMOVE_HEAD(&sc->rx.avail, next); in cpsw_rx_enqueue()
1786 STAILQ_INSERT_TAIL(&sc->rx.active, slot, next); in cpsw_rx_enqueue()
1797 cpsw_write_hdp_slot(sc, &sc->rx, first_new_slot); in cpsw_rx_enqueue()
1802 sc->rx.queue_adds += added; in cpsw_rx_enqueue()
1803 sc->rx.avail_queue_len -= added; in cpsw_rx_enqueue()
1804 sc->rx.active_queue_len += added; in cpsw_rx_enqueue()
1806 if (sc->rx.active_queue_len > sc->rx.max_active_queue_len) in cpsw_rx_enqueue()
1807 sc->rx.max_active_queue_len = sc->rx.active_queue_len; in cpsw_rx_enqueue()
1817 sc->swsc->tx.running == 0) { in cpswp_start()
1820 CPSW_TX_LOCK(sc->swsc); in cpswp_start()
1822 cpsw_tx_dequeue(sc->swsc); in cpswp_start()
1823 CPSW_TX_UNLOCK(sc->swsc); in cpswp_start()
1834 cpsw_write_cp(sc, &sc->tx, 0xfffffffc); in cpsw_intr_tx()
1852 last_old_slot = STAILQ_LAST(&sc->swsc->tx.active, cpsw_slot, next); in cpswp_tx_enqueue()
1853 while ((slot = STAILQ_FIRST(&sc->swsc->tx.avail)) != NULL) { in cpswp_tx_enqueue()
1854 m0 = if_dequeue(sc->ifp); in cpswp_tx_enqueue()
1858 slot->mbuf = m0; in cpswp_tx_enqueue()
1859 padlen = ETHER_MIN_LEN - ETHER_CRC_LEN - m0->m_pkthdr.len; in cpswp_tx_enqueue()
1863 m_append(slot->mbuf, padlen, sc->swsc->nullpad); in cpswp_tx_enqueue()
1866 error = bus_dmamap_load_mbuf_sg(sc->swsc->mbuf_dtag, in cpswp_tx_enqueue()
1867 slot->dmamap, slot->mbuf, segs, &nsegs, BUS_DMA_NOWAIT); in cpswp_tx_enqueue()
1870 (error == 0 && nsegs > sc->swsc->tx.avail_queue_len)) { in cpswp_tx_enqueue()
1871 bus_dmamap_unload(sc->swsc->mbuf_dtag, slot->dmamap); in cpswp_tx_enqueue()
1872 m0 = m_defrag(slot->mbuf, M_NOWAIT); in cpswp_tx_enqueue()
1874 device_printf(sc->dev, in cpswp_tx_enqueue()
1876 m_freem(slot->mbuf); in cpswp_tx_enqueue()
1878 CPSW_DEBUGF(sc->swsc, in cpswp_tx_enqueue()
1880 if_sendq_prepend(sc->ifp, m0); in cpswp_tx_enqueue()
1882 slot->mbuf = NULL; in cpswp_tx_enqueue()
1886 device_printf(sc->dev, in cpswp_tx_enqueue()
1889 bus_dmamap_unload(sc->swsc->mbuf_dtag, slot->dmamap); in cpswp_tx_enqueue()
1890 m_freem(slot->mbuf); in cpswp_tx_enqueue()
1891 slot->mbuf = NULL; in cpswp_tx_enqueue()
1895 bus_dmamap_sync(sc->swsc->mbuf_dtag, slot->dmamap, in cpswp_tx_enqueue()
1898 CPSW_DEBUGF(sc->swsc, in cpswp_tx_enqueue()
1907 cpsw_cpdma_write_bd_next(sc->swsc, last, slot); in cpswp_tx_enqueue()
1909 slot->ifp = sc->ifp; in cpswp_tx_enqueue()
1916 bd.next = cpsw_cpdma_bd_paddr(sc->swsc, next); in cpswp_tx_enqueue()
1923 bd.pktlen = m_length(slot->mbuf, NULL); in cpswp_tx_enqueue()
1925 if (sc->swsc->dualemac) { in cpswp_tx_enqueue()
1927 bd.flags |= ((sc->unit + 1) & CPDMA_BD_PORT_MASK); in cpswp_tx_enqueue()
1931 cpsw_cpdma_write_bd(sc->swsc, slot, &bd); in cpswp_tx_enqueue()
1932 STAILQ_REMOVE_HEAD(&sc->swsc->tx.avail, next); in cpswp_tx_enqueue()
1933 STAILQ_INSERT_TAIL(&sc->swsc->tx.active, slot, next); in cpswp_tx_enqueue()
1934 slot = STAILQ_FIRST(&sc->swsc->tx.avail); in cpswp_tx_enqueue()
1939 bd.next = cpsw_cpdma_bd_paddr(sc->swsc, next); in cpswp_tx_enqueue()
1951 cpsw_cpdma_write_bd(sc->swsc, slot, &bd); in cpswp_tx_enqueue()
1952 STAILQ_REMOVE_HEAD(&sc->swsc->tx.avail, next); in cpswp_tx_enqueue()
1953 STAILQ_INSERT_TAIL(&sc->swsc->tx.active, slot, next); in cpswp_tx_enqueue()
1957 if (nsegs > sc->swsc->tx.longest_chain) in cpswp_tx_enqueue()
1958 sc->swsc->tx.longest_chain = nsegs; in cpswp_tx_enqueue()
1960 BPF_MTAP(sc->ifp, m0); in cpswp_tx_enqueue()
1968 (cpsw_cpdma_read_bd_flags(sc->swsc, last_old_slot) & in cpswp_tx_enqueue()
1971 cpsw_cpdma_write_bd_next(sc->swsc, last_old_slot, in cpswp_tx_enqueue()
1975 cpsw_write_hdp_slot(sc->swsc, &sc->swsc->tx, first_new_slot); in cpswp_tx_enqueue()
1977 sc->swsc->tx.queue_adds += added; in cpswp_tx_enqueue()
1978 sc->swsc->tx.avail_queue_len -= added; in cpswp_tx_enqueue()
1979 sc->swsc->tx.active_queue_len += added; in cpswp_tx_enqueue()
1980 if (sc->swsc->tx.active_queue_len > sc->swsc->tx.max_active_queue_len) { in cpswp_tx_enqueue()
1981 sc->swsc->tx.max_active_queue_len = sc->swsc->tx.active_queue_len; in cpswp_tx_enqueue()
1983 CPSW_DEBUGF(sc->swsc, ("Queued %d TX packet(s)", added)); in cpswp_tx_enqueue()
1994 slot = STAILQ_FIRST(&sc->tx.active); in cpsw_tx_dequeue()
2001 sc->tx.teardown = 1; in cpsw_tx_dequeue()
2005 (CPDMA_BD_SOP | CPDMA_BD_OWNER) && sc->tx.teardown == 0) in cpsw_tx_dequeue()
2008 bus_dmamap_sync(sc->mbuf_dtag, slot->dmamap, BUS_DMASYNC_POSTWRITE); in cpsw_tx_dequeue()
2009 bus_dmamap_unload(sc->mbuf_dtag, slot->dmamap); in cpsw_tx_dequeue()
2010 m_freem(slot->mbuf); in cpsw_tx_dequeue()
2011 slot->mbuf = NULL; in cpsw_tx_dequeue()
2013 if (slot->ifp) { in cpsw_tx_dequeue()
2014 if (sc->tx.teardown == 0) in cpsw_tx_dequeue()
2015 if_inc_counter(slot->ifp, IFCOUNTER_OPACKETS, 1); in cpsw_tx_dequeue()
2017 if_inc_counter(slot->ifp, IFCOUNTER_OQDROPS, 1); in cpsw_tx_dequeue()
2021 while (slot != NULL && slot->mbuf == NULL) { in cpsw_tx_dequeue()
2022 STAILQ_REMOVE_HEAD(&sc->tx.active, next); in cpsw_tx_dequeue()
2023 STAILQ_INSERT_TAIL(&sc->tx.avail, slot, next); in cpsw_tx_dequeue()
2026 slot = STAILQ_FIRST(&sc->tx.active); in cpsw_tx_dequeue()
2029 cpsw_write_cp_slot(sc, &sc->tx, last_removed_slot); in cpsw_tx_dequeue()
2036 cpsw_write_hdp_slot(sc, &sc->tx, slot); in cpsw_tx_dequeue()
2037 sc->tx.queue_restart++; in cpsw_tx_dequeue()
2043 sc->tx.queue_removes += removed; in cpsw_tx_dequeue()
2044 sc->tx.active_queue_len -= removed; in cpsw_tx_dequeue()
2045 sc->tx.avail_queue_len += removed; in cpsw_tx_dequeue()
2046 if (sc->tx.avail_queue_len > sc->tx.max_avail_queue_len) in cpsw_tx_dequeue()
2047 sc->tx.max_avail_queue_len = sc->tx.avail_queue_len; in cpsw_tx_dequeue()
2051 if (sc->tx.teardown && STAILQ_EMPTY(&sc->tx.active)) { in cpsw_tx_dequeue()
2053 sc->tx.teardown = 0; in cpsw_tx_dequeue()
2054 sc->tx.running = 0; in cpsw_tx_dequeue()
2081 next = received->m_nextpkt; in cpsw_intr_rx_thresh()
2082 received->m_nextpkt = NULL; in cpsw_intr_rx_thresh()
2083 ifp = received->m_pkthdr.rcvif; in cpsw_intr_rx_thresh()
2098 device_printf(sc->dev, in cpsw_intr_misc_host_error()
2102 device_printf(sc->dev, "CPSW_CPDMA_DMA_INTSTAT_MASKED=0x%x\n", intstat); in cpsw_intr_misc_host_error()
2104 device_printf(sc->dev, "CPSW_CPDMA_DMASTATUS=0x%x\n", dmastat); in cpsw_intr_misc_host_error()
2134 cpsw_dump_queue(sc, &sc->tx.active); in cpsw_intr_misc_host_error()
2156 cpsw_dump_queue(sc, &sc->rx.active); in cpsw_intr_misc_host_error()
2207 mii_tick(sc->mii); in cpswp_tick()
2208 if (sc->media_status != sc->mii->mii_media.ifm_media) { in cpswp_tick()
2210 sc->mii->mii_media.ifm_media); in cpswp_tick()
2211 cpswp_ifmedia_upd(sc->ifp); in cpswp_tick()
2215 callout_reset(&sc->mii_callout, hz, cpswp_tick, sc); in cpswp_tick()
2225 CPSW_DEBUGF(sc->swsc, ("")); in cpswp_ifmedia_sts()
2228 mii = sc->mii; in cpswp_ifmedia_sts()
2231 ifmr->ifm_active = mii->mii_media_active; in cpswp_ifmedia_sts()
2232 ifmr->ifm_status = mii->mii_media_status; in cpswp_ifmedia_sts()
2242 CPSW_DEBUGF(sc->swsc, ("")); in cpswp_ifmedia_upd()
2244 mii_mediachg(sc->mii); in cpswp_ifmedia_upd()
2245 sc->media_status = sc->mii->mii_media.ifm_media; in cpswp_ifmedia_upd()
2258 device_printf(sc->dev, "watchdog timeout\n"); in cpsw_tx_watchdog_full_reset()
2263 cpsw_dump_queue(sc, &sc->tx.active); in cpsw_tx_watchdog_full_reset()
2265 if (!sc->dualemac && i != sc->active_slave) in cpsw_tx_watchdog_full_reset()
2267 psc = device_get_softc(sc->port[i].dev); in cpsw_tx_watchdog_full_reset()
2281 if (sc->tx.active_queue_len == 0 || !sc->tx.running) { in cpsw_tx_watchdog()
2282 sc->watchdog.timer = 0; /* Nothing to do. */ in cpsw_tx_watchdog()
2283 } else if (sc->tx.queue_removes > sc->tx.queue_removes_at_last_tick) { in cpsw_tx_watchdog()
2284 sc->watchdog.timer = 0; /* Stuff done while we weren't looking. */ in cpsw_tx_watchdog()
2286 sc->watchdog.timer = 0; /* We just did something. */ in cpsw_tx_watchdog()
2289 ++sc->watchdog.timer; in cpsw_tx_watchdog()
2290 if (sc->watchdog.timer > 5) { in cpsw_tx_watchdog()
2291 sc->watchdog.timer = 0; in cpsw_tx_watchdog()
2292 ++sc->watchdog.resets; in cpsw_tx_watchdog()
2296 sc->tx.queue_removes_at_last_tick = sc->tx.queue_removes; in cpsw_tx_watchdog()
2300 callout_reset(&sc->watchdog.callout, hz, cpsw_tx_watchdog, sc); in cpsw_tx_watchdog()
2349 int free_index = -1, matching_index = -1, i; in cpsw_ale_mc_entry_set()
2377 if (vlan != -1) in cpsw_ale_mc_entry_set()
2444 if (sc->swsc->dualemac) in cpswp_set_maddr()
2445 portmask = 1 << (sc->unit + 1) | 1 << 0; in cpswp_set_maddr()
2449 cpsw_ale_mc_entry_set(sc->swsc, portmask, sc->vlan, LLADDR(sdl)); in cpswp_set_maddr()
2460 if (sc->swsc->dualemac) { in cpswp_ale_update_addresses()
2461 ale_type = ALE_TYPE_VLAN_ADDR << 28 | sc->vlan << 16; in cpswp_ale_update_addresses()
2462 portmask = 1 << (sc->unit + 1) | 1 << 0; in cpswp_ale_update_addresses()
2473 mac = LLADDR((struct sockaddr_dl *)if_getifaddr(sc->ifp)->ifa_addr); in cpswp_ale_update_addresses()
2477 cpsw_ale_write_entry(sc->swsc, 0 + 2 * sc->unit, ale_entry); in cpswp_ale_update_addresses()
2480 cpsw_write_4(sc->swsc, CPSW_PORT_P_SA_HI(sc->unit + 1), in cpswp_ale_update_addresses()
2482 cpsw_write_4(sc->swsc, CPSW_PORT_P_SA_LO(sc->unit + 1), in cpswp_ale_update_addresses()
2490 cpsw_ale_write_entry(sc->swsc, 1 + 2 * sc->unit, ale_entry); in cpswp_ale_update_addresses()
2495 cpsw_ale_remove_all_mc_entries(sc->swsc); in cpswp_ale_update_addresses()
2498 if_foreach_llmaddr(sc->ifp, cpswp_set_maddr, sc); in cpswp_ale_update_addresses()
2510 free_index = matching_index = -1; in cpsw_ale_update_vlan_table()
2527 return (-1); in cpsw_ale_update_vlan_table()
2557 (intmax_t)sc->shadow_stats[i], r,
2558 (intmax_t)sc->shadow_stats[i] + r));
2574 sc->shadow_stats[i] += r; in cpsw_stats_collect()
2588 stat = &cpsw_stat_sysctls[oidp->oid_number]; in cpsw_stats_sysctl()
2589 result = sc->shadow_stats[oidp->oid_number]; in cpsw_stats_sysctl()
2590 result += cpsw_read_4(sc, CPSW_STATS_OFFSET + stat->reg); in cpsw_stats_sysctl()
2603 bintime_sub(&t, &sc->attach_uptime); in cpsw_stat_attached()
2616 error = sysctl_handle_int(oidp, &sc->coal_us, 0, req); in cpsw_intr_coalesce()
2617 if (error != 0 || req->newptr == NULL) in cpsw_intr_coalesce()
2622 if (sc->coal_us == 0) { in cpsw_intr_coalesce()
2630 if (sc->coal_us > CPSW_WR_C_IMAX_US_MAX) in cpsw_intr_coalesce()
2631 sc->coal_us = CPSW_WR_C_IMAX_US_MAX; in cpsw_intr_coalesce()
2632 if (sc->coal_us < CPSW_WR_C_IMAX_US_MIN) in cpsw_intr_coalesce()
2633 sc->coal_us = CPSW_WR_C_IMAX_US_MIN; in cpsw_intr_coalesce()
2634 intr_per_ms = 1000 / sc->coal_us; in cpsw_intr_coalesce()
2662 sc = device_get_softc(swsc->port[arg2].dev); in cpsw_stat_uptime()
2663 if (if_getdrvflags(sc->ifp) & IFF_DRV_RUNNING) { in cpsw_stat_uptime()
2665 bintime_sub(&t, &sc->init_uptime); in cpsw_stat_uptime()
2680 CTLFLAG_RD, &queue->queue_slots, 0, in cpsw_add_queue_sysctls()
2683 CTLFLAG_RD, &queue->active_queue_len, 0, in cpsw_add_queue_sysctls()
2686 CTLFLAG_RD, &queue->max_active_queue_len, 0, in cpsw_add_queue_sysctls()
2689 CTLFLAG_RD, &queue->avail_queue_len, 0, in cpsw_add_queue_sysctls()
2693 CTLFLAG_RD, &queue->max_avail_queue_len, 0, in cpsw_add_queue_sysctls()
2696 CTLFLAG_RD, &queue->queue_adds, 0, in cpsw_add_queue_sysctls()
2699 CTLFLAG_RD, &queue->queue_removes, 0, in cpsw_add_queue_sysctls()
2702 CTLFLAG_RD, &queue->queue_restart, 0, in cpsw_add_queue_sysctls()
2705 CTLFLAG_RD, &queue->longest_chain, 0, in cpsw_add_queue_sysctls()
2717 CTLFLAG_RD, &sc->watchdog.resets, 0, in cpsw_add_watchdog_sysctls()
2731 ctx = device_get_sysctl_ctx(sc->dev); in cpsw_add_sysctls()
2732 parent = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)); in cpsw_add_sysctls()
2735 CTLFLAG_RW, &sc->debug, 0, "Enable switch debug messages"); in cpsw_add_sysctls()
2751 if (!sc->dualemac && i != sc->active_slave) in cpsw_add_sysctls()
2781 cpsw_add_queue_sysctls(ctx, node, &sc->tx); in cpsw_add_sysctls()
2785 cpsw_add_queue_sysctls(ctx, node, &sc->rx); in cpsw_add_sysctls()
2815 if (p->es_port < 0 || p->es_port > CPSW_PORTS) in cpsw_getport()
2820 if (p->es_port == CPSW_CPU_PORT) { in cpsw_getport()
2821 p->es_flags |= ETHERSWITCH_PORT_CPU; in cpsw_getport()
2822 ifmr = &p->es_ifmr; in cpsw_getport()
2823 ifmr->ifm_current = ifmr->ifm_active = in cpsw_getport()
2825 ifmr->ifm_mask = 0; in cpsw_getport()
2826 ifmr->ifm_status = IFM_ACTIVE | IFM_AVALID; in cpsw_getport()
2827 ifmr->ifm_count = 0; in cpsw_getport()
2829 psc = device_get_softc(sc->port[p->es_port - 1].dev); in cpsw_getport()
2830 err = ifmedia_ioctl(psc->ifp, &p->es_ifr, in cpsw_getport()
2831 &psc->mii->mii_media, SIOCGIFMEDIA); in cpsw_getport()
2833 reg = cpsw_read_4(sc, CPSW_PORT_P_VLAN(p->es_port)); in cpsw_getport()
2834 p->es_pvid = reg & ETHERSWITCH_VID_MASK; in cpsw_getport()
2836 reg = cpsw_read_4(sc, CPSW_ALE_PORTCTL(p->es_port)); in cpsw_getport()
2838 p->es_flags |= ETHERSWITCH_PORT_DROPUNTAGGED; in cpsw_getport()
2840 p->es_flags |= ETHERSWITCH_PORT_INGRESS; in cpsw_getport()
2853 if (p->es_port < 0 || p->es_port > CPSW_PORTS) in cpsw_setport()
2857 if (p->es_pvid != 0) { in cpsw_setport()
2858 cpsw_write_4(sc, CPSW_PORT_P_VLAN(p->es_port), in cpsw_setport()
2859 p->es_pvid & ETHERSWITCH_VID_MASK); in cpsw_setport()
2862 reg = cpsw_read_4(sc, CPSW_ALE_PORTCTL(p->es_port)); in cpsw_setport()
2863 if (p->es_flags & ETHERSWITCH_PORT_DROPUNTAGGED) in cpsw_setport()
2867 if (p->es_flags & ETHERSWITCH_PORT_INGRESS) in cpsw_setport()
2871 cpsw_write_4(sc, CPSW_ALE_PORTCTL(p->es_port), reg); in cpsw_setport()
2874 if (p->es_port == CPSW_CPU_PORT) in cpsw_setport()
2877 psc = device_get_softc(sc->port[p->es_port - 1].dev); in cpsw_setport()
2878 ifm = &psc->mii->mii_media; in cpsw_setport()
2880 return (ifmedia_ioctl(psc->ifp, &p->es_ifr, ifm, SIOCSIFMEDIA)); in cpsw_setport()
2888 conf->cmd = ETHERSWITCH_CONF_VLAN_MODE; in cpsw_getconf()
2889 conf->vlan_mode = ETHERSWITCH_VLAN_DOT1Q; in cpsw_getconf()
2903 if (vg->es_vlangroup >= CPSW_VLANS) in cpsw_getvgroup()
2906 vg->es_vid = 0; in cpsw_getvgroup()
2907 vid = cpsw_vgroups[vg->es_vlangroup].vid; in cpsw_getvgroup()
2908 if (vid == -1) in cpsw_getvgroup()
2918 vg->es_fid = 0; in cpsw_getvgroup()
2919 vg->es_vid = ALE_VLAN(ale_entry) | ETHERSWITCH_VID_VALID; in cpsw_getvgroup()
2920 vg->es_member_ports = ALE_VLAN_MEMBERS(ale_entry); in cpsw_getvgroup()
2921 vg->es_untagged_ports = ALE_VLAN_UNTAG(ale_entry); in cpsw_getvgroup()
2955 if (vg->es_vlangroup != i && cpsw_vgroups[i].vid == vg->es_vid) in cpsw_setvgroup()
2959 if (vg->es_vid == 0) { in cpsw_setvgroup()
2960 if (cpsw_vgroups[vg->es_vlangroup].vid == -1) in cpsw_setvgroup()
2962 cpsw_remove_vlan(sc, cpsw_vgroups[vg->es_vlangroup].vid); in cpsw_setvgroup()
2963 cpsw_vgroups[vg->es_vlangroup].vid = -1; in cpsw_setvgroup()
2964 vg->es_untagged_ports = 0; in cpsw_setvgroup()
2965 vg->es_member_ports = 0; in cpsw_setvgroup()
2966 vg->es_vid = 0; in cpsw_setvgroup()
2970 vg->es_vid &= ETHERSWITCH_VID_MASK; in cpsw_setvgroup()
2971 vg->es_member_ports &= CPSW_PORTS_MASK; in cpsw_setvgroup()
2972 vg->es_untagged_ports &= CPSW_PORTS_MASK; in cpsw_setvgroup()
2974 if (cpsw_vgroups[vg->es_vlangroup].vid != -1 && in cpsw_setvgroup()
2975 cpsw_vgroups[vg->es_vlangroup].vid != vg->es_vid) in cpsw_setvgroup()
2978 cpsw_vgroups[vg->es_vlangroup].vid = vg->es_vid; in cpsw_setvgroup()
2979 cpsw_ale_update_vlan_table(sc, vg->es_vid, vg->es_member_ports, in cpsw_setvgroup()
2980 vg->es_untagged_ports, vg->es_member_ports, 0); in cpsw_setvgroup()