| 1695 | } |
| 1696 | |
| 1697 | static void |
| 1698 | arge_start_locked(struct ifnet *ifp) |
| 1699 | { |
| 1700 | struct arge_softc *sc; |
| 1701 | struct mbuf *m_head; |
| 1702 | int enq = 0; |
| 1703 | |
| 1704 | sc = ifp->if_softc; |
| 1705 | |
| 1706 | ARGE_LOCK_ASSERT(sc); |
| 1707 | |
| 1708 | ARGEDEBUG(sc, ARGE_DBG_TX, "%s: beginning\n", __func__); |
| 1709 | |
| 1710 | if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != |
| 1711 | IFF_DRV_RUNNING || sc->arge_link_status == 0 ) |
| 1712 | return; |
| 1713 | |
| 1714 | /* |
| 1715 | * Before we go any further, check whether we're already full. |
| 1716 | * The below check errors out immediately if the ring is full |
| 1717 | * and never gets a chance to set this flag. Although it's |
| 1718 | * likely never needed, this at least avoids an unexpected |
| 1719 | * situation. |
| 1720 | */ |
| 1721 | if (sc->arge_cdata.arge_tx_cnt >= ARGE_TX_RING_COUNT - 2) { |
| 1722 | ifp->if_drv_flags |= IFF_DRV_OACTIVE; |
| 1723 | ARGEDEBUG(sc, ARGE_DBG_ERR, |
| 1724 | "%s: tx_cnt %d >= max %d; setting IFF_DRV_OACTIVE\n", |
| 1725 | __func__, sc->arge_cdata.arge_tx_cnt, |
| 1726 | ARGE_TX_RING_COUNT - 2); |
| 1727 | return; |
| 1728 | } |
| 1729 | |
| 1730 | arge_flush_ddr(sc); |
| 1731 | |
| 1732 | for (enq = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd) && |
| 1733 | sc->arge_cdata.arge_tx_cnt < ARGE_TX_RING_COUNT - 2; ) { |
| 1734 | IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head); |
| 1735 | if (m_head == NULL) |
| 1736 | break; |
| 1737 | |
| 1738 | /* |
| 1739 | * Pack the data into the transmit ring. |
| 1740 | */ |
| 1741 | if (arge_encap(sc, &m_head)) { |
| 1742 | if (m_head == NULL) |
| 1743 | break; |
| 1744 | IFQ_DRV_PREPEND(&ifp->if_snd, m_head); |
| 1745 | ifp->if_drv_flags |= IFF_DRV_OACTIVE; |
| 1746 | break; |
| 1747 | } |
| 1748 | |
| 1749 | enq++; |
| 1750 | /* |
| 1751 | * If there's a BPF listener, bounce a copy of this frame |
| 1752 | * to him. |
| 1753 | */ |
| 1754 | ETHER_BPF_MTAP(ifp, m_head); |
no test coverage detected