Deleted Added
sdiff udiff text old ( 217044 ) new ( 223324 )
full compact
1/*-
2 * Copyright (C) 2010 Nathan Whitehorn
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 8 unchanged lines hidden (view full) ---

17 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * $FreeBSD: head/sys/powerpc/ps3/if_glc.c 217044 2011-01-06 04:12:29Z nwhitehorn $
26 */
27
28#include <sys/param.h>
29#include <sys/systm.h>
30#include <sys/sockio.h>
31#include <sys/endian.h>
32#include <sys/mbuf.h>
33#include <sys/module.h>

--- 96 unchanged lines hidden (view full) ---

130 sc->sc_dev = ps3bus_get_device(dev);
131 sc->sc_self = dev;
132
133 mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
134 MTX_DEF);
135 callout_init_mtx(&sc->sc_tick_ch, &sc->sc_mtx, 0);
136 sc->next_txdma_slot = 0;
137 sc->bsy_txdma_slots = 0;
138 sc->first_used_txdma_slot = -1;
139
140 /*
141 * Shut down existing tasks.
142 */
143
144 lv1_net_stop_tx_dma(sc->sc_bus, sc->sc_dev, 0);
145 lv1_net_stop_rx_dma(sc->sc_bus, sc->sc_dev, 0);

--- 224 unchanged lines hidden (view full) ---

370
371static void
372glc_tick(void *xsc)
373{
374 struct glc_softc *sc = xsc;
375
376 mtx_assert(&sc->sc_mtx, MA_OWNED);
377
378 if (sc->sc_wdog_timer == 0 || --sc->sc_wdog_timer != 0) {
379 callout_reset(&sc->sc_tick_ch, hz, glc_tick, sc);
380 return;
381 }
382
383 /* Problems */
384 device_printf(sc->sc_self, "device timeout\n");
385

--- 316 unchanged lines hidden (view full) ---

702static void
703glc_rxintr(struct glc_softc *sc)
704{
705 int i, restart_rxdma, error;
706 struct mbuf *m;
707 struct ifnet *ifp = sc->sc_ifp;
708
709 bus_dmamap_sync(sc->sc_dmadesc_tag, sc->sc_rxdmadesc_map,
710 BUS_DMASYNC_PREWRITE);
711
712 restart_rxdma = 0;
713 while ((sc->sc_rxdmadesc[sc->sc_next_rxdma_slot].cmd_stat &
714 GELIC_DESCR_OWNED) == 0) {
715 i = sc->sc_next_rxdma_slot;
716 if (sc->sc_rxdmadesc[i].rxerror & GELIC_RXERRORS) {
717 ifp->if_ierrors++;
718 goto requeue;
719 }
720
721 m = sc->sc_rxsoft[i].rxs_mbuf;
722 if (sc->sc_rxdmadesc[i].data_stat & GELIC_RX_IPCSUM) {
723 m->m_pkthdr.csum_flags |=

--- 9 unchanged lines hidden (view full) ---

733 ifp->if_ierrors++;
734 goto requeue;
735 }
736
737 ifp->if_ipackets++;
738 m->m_pkthdr.rcvif = ifp;
739 m->m_len = sc->sc_rxdmadesc[i].valid_size;
740 m->m_pkthdr.len = m->m_len;
741 sc->sc_next_rxdma_slot++;
742 if (sc->sc_next_rxdma_slot >= GLC_MAX_RX_PACKETS)
743 sc->sc_next_rxdma_slot = 0;
744
745 if (sc->sc_rx_vlan >= 0)
746 m_adj(m, 2);
747
748 mtx_unlock(&sc->sc_mtx);
749 (*ifp->if_input)(ifp, m);
750 mtx_lock(&sc->sc_mtx);
751
752 requeue:
753 if (sc->sc_rxdmadesc[i].cmd_stat & GELIC_CMDSTAT_CHAIN_END)
754 restart_rxdma = 1;
755 glc_add_rxbuf_dma(sc, i);
756 if (restart_rxdma) {
757 error = lv1_net_start_rx_dma(sc->sc_bus, sc->sc_dev,
758 sc->sc_rxsoft[i].rxs_desc, 0);
759 if (error != 0)
760 device_printf(sc->sc_self,
761 "lv1_net_start_rx_dma error: %d\n", error);
762 }
763 }
764}
765
766static void
767glc_txintr(struct glc_softc *sc)
768{
769 struct ifnet *ifp = sc->sc_ifp;
770 struct glc_txsoft *txs;
771 int progress = 0, kickstart = 0, error;
772
773 while ((txs = STAILQ_FIRST(&sc->sc_txdirtyq)) != NULL) {
774 if (sc->sc_txdmadesc[txs->txs_lastdesc].cmd_stat
775 & GELIC_DESCR_OWNED)
776 break;
777
778 STAILQ_REMOVE_HEAD(&sc->sc_txdirtyq, txs_q);
779 bus_dmamap_unload(sc->sc_txdma_tag, txs->txs_dmamap);
780 sc->bsy_txdma_slots -= txs->txs_ndescs;

--- 19 unchanged lines hidden (view full) ---

800 progress = 1;
801 }
802
803 if (txs != NULL)
804 sc->first_used_txdma_slot = txs->txs_firstdesc;
805 else
806 sc->first_used_txdma_slot = -1;
807
808 if (kickstart && txs != NULL) {
809 error = lv1_net_start_tx_dma(sc->sc_bus, sc->sc_dev,
810 sc->sc_txdmadesc_phys +
811 txs->txs_firstdesc*sizeof(struct glc_dmadesc), 0);
812 if (error != 0)
813 device_printf(sc->sc_self,
814 "lv1_net_start_tx_dma error: %d\n", error);
815 }
816

--- 122 unchanged lines hidden ---