Index: head/sys/dev/cxgb/cxgb_adapter.h =================================================================== --- head/sys/dev/cxgb/cxgb_adapter.h +++ head/sys/dev/cxgb/cxgb_adapter.h @@ -576,4 +576,11 @@ void cxgb_qflush(struct ifnet *ifp); void t3_iterate(void (*)(struct adapter *, void *), void *); void cxgb_refresh_stats(struct port_info *); + +#ifdef NETDUMP +int cxgb_netdump_encap(struct sge_qset *qs, struct mbuf **m); +int cxgb_netdump_poll_rx(adapter_t *adap, struct sge_qset *qs); +int cxgb_netdump_poll_tx(struct sge_qset *qs); +#endif + #endif Index: head/sys/dev/cxgb/cxgb_main.c =================================================================== --- head/sys/dev/cxgb/cxgb_main.c +++ head/sys/dev/cxgb/cxgb_main.c @@ -74,6 +74,7 @@ #include #include #include +#include #include #include @@ -191,6 +192,8 @@ DRIVER_MODULE(cxgb, cxgbc, cxgb_port_driver, cxgb_port_devclass, 0, 0); MODULE_VERSION(cxgb, 1); +NETDUMP_DEFINE(cxgb); + static struct mtx t3_list_lock; static SLIST_HEAD(, adapter) t3_list; #ifdef TCP_OFFLOAD @@ -1045,6 +1048,9 @@ ether_ifattach(ifp, p->hw_addr); + /* Attach driver netdump methods. */ + NETDUMP_SET(ifp, cxgb); + #ifdef DEFAULT_JUMBO if (sc->params.nports <= 2) ifp->if_mtu = ETHERMTU_JUMBO; @@ -3578,3 +3584,72 @@ return (rc); } + +#ifdef NETDUMP +static void +cxgb_netdump_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize) +{ + struct port_info *pi; + adapter_t *adap; + + pi = if_getsoftc(ifp); + adap = pi->adapter; + ADAPTER_LOCK(adap); + *nrxr = SGE_QSETS; + *ncl = adap->sge.qs[0].fl[1].size; + *clsize = adap->sge.qs[0].fl[1].buf_size; + ADAPTER_UNLOCK(adap); +} + +static void +cxgb_netdump_event(struct ifnet *ifp, enum netdump_ev event) +{ + struct port_info *pi; + struct sge_qset *qs; + int i; + + pi = if_getsoftc(ifp); + if (event == NETDUMP_START) + for (i = 0; i < SGE_QSETS; i++) { + qs = &pi->adapter->sge.qs[i]; + + /* Need to reinit after netdump_mbuf_dump(). */ + qs->fl[0].zone = zone_pack; + qs->fl[1].zone = zone_clust; + qs->lro.enabled = 0; + } +} + +static int +cxgb_netdump_transmit(struct ifnet *ifp, struct mbuf *m) +{ + struct port_info *pi; + struct sge_qset *qs; + + pi = if_getsoftc(ifp); + if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != + IFF_DRV_RUNNING) + return (ENOENT); + + qs = &pi->adapter->sge.qs[pi->first_qset]; + return (cxgb_netdump_encap(qs, &m)); +} + +static int +cxgb_netdump_poll(struct ifnet *ifp, int count) +{ + struct port_info *pi; + adapter_t *adap; + int i; + + pi = if_getsoftc(ifp); + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) + return (ENOENT); + + adap = pi->adapter; + for (i = 0; i < SGE_QSETS; i++) + (void)cxgb_netdump_poll_rx(adap, &adap->sge.qs[i]); + (void)cxgb_netdump_poll_tx(&adap->sge.qs[pi->first_qset]); + return (0); +} +#endif /* NETDUMP */ Index: head/sys/dev/cxgb/cxgb_sge.c =================================================================== --- head/sys/dev/cxgb/cxgb_sge.c +++ head/sys/dev/cxgb/cxgb_sge.c @@ -390,6 +390,15 @@ return (reclaim); } +#ifdef NETDUMP +int +cxgb_netdump_poll_tx(struct sge_qset *qs) +{ + + return (reclaim_completed_tx(qs, TX_RECLAIM_MAX, TXQ_ETH)); +} +#endif + /** * should_restart_tx - are there enough resources to restart a Tx queue? * @q: the Tx queue @@ -1586,6 +1595,23 @@ return (0); } +#ifdef NETDUMP +int +cxgb_netdump_encap(struct sge_qset *qs, struct mbuf **m) +{ + int error; + + error = t3_encap(qs, m); + if (error == 0) + check_ring_tx_db(qs->port->adapter, &qs->txq[TXQ_ETH], 1); + else if (*m != NULL) { + m_freem(*m); + *m = NULL; + } + return (error); +} +#endif + void cxgb_tx_watchdog(void *arg) { @@ -3014,6 +3040,14 @@ return (work); } +#ifdef NETDUMP +int +cxgb_netdump_poll_rx(adapter_t *adap, struct sge_qset *qs) +{ + + return (process_responses_gts(adap, &qs->rspq)); +} +#endif /* * Interrupt handler for legacy INTx interrupts for T3B-based cards.