Deleted Added
full compact
if_tsec.c (257993) if_tsec.c (271849)
1/*-
2 * Copyright (C) 2007-2008 Semihalf, Rafal Jaworowski
3 * Copyright (C) 2006-2007 Semihalf, Piotr Kruszynski
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

23 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27/*
28 * Freescale integrated Three-Speed Ethernet Controller (TSEC) driver.
29 */
30#include <sys/cdefs.h>
1/*-
2 * Copyright (C) 2007-2008 Semihalf, Rafal Jaworowski
3 * Copyright (C) 2006-2007 Semihalf, Piotr Kruszynski
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

23 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27/*
28 * Freescale integrated Three-Speed Ethernet Controller (TSEC) driver.
29 */
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/tsec/if_tsec.c 257993 2013-11-11 15:43:21Z nwhitehorn $");
31__FBSDID("$FreeBSD: head/sys/dev/tsec/if_tsec.c 271849 2014-09-19 03:51:26Z glebius $");
32
33#ifdef HAVE_KERNEL_OPTION_HEADERS
34#include "opt_device_polling.h"
35#endif
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/bus.h>

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

682 struct ifnet *ifp;
683
684 TSEC_GLOBAL_LOCK_ASSERT(sc);
685
686 if (sc->tsec_watchdog == 0 || --sc->tsec_watchdog > 0)
687 return;
688
689 ifp = sc->tsec_ifp;
32
33#ifdef HAVE_KERNEL_OPTION_HEADERS
34#include "opt_device_polling.h"
35#endif
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/bus.h>

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

682 struct ifnet *ifp;
683
684 TSEC_GLOBAL_LOCK_ASSERT(sc);
685
686 if (sc->tsec_watchdog == 0 || --sc->tsec_watchdog > 0)
687 return;
688
689 ifp = sc->tsec_ifp;
690 ifp->if_oerrors++;
690 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
691 if_printf(ifp, "watchdog timeout\n");
692
693 tsec_stop(sc);
694 tsec_init_locked(sc);
695}
696
697static void
698tsec_start(struct ifnet *ifp)

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

1344
1345 if ((flags & TSEC_RXBD_L) != 0) {
1346 m = sc->frame;
1347 sc->frame = NULL;
1348 }
1349
1350 if (tsec_new_rxbuf(sc->tsec_rx_mtag, rx_data[i].map,
1351 &rx_data[i].mbuf, &rx_data[i].paddr)) {
691 if_printf(ifp, "watchdog timeout\n");
692
693 tsec_stop(sc);
694 tsec_init_locked(sc);
695}
696
697static void
698tsec_start(struct ifnet *ifp)

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

1344
1345 if ((flags & TSEC_RXBD_L) != 0) {
1346 m = sc->frame;
1347 sc->frame = NULL;
1348 }
1349
1350 if (tsec_new_rxbuf(sc->tsec_rx_mtag, rx_data[i].map,
1351 &rx_data[i].mbuf, &rx_data[i].paddr)) {
1352 ifp->if_ierrors++;
1352 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
1353 /*
1354 * We ran out of mbufs; didn't consume current
1355 * descriptor and have to return it to the queue.
1356 */
1357 TSEC_BACK_CUR_RX_DESC(sc);
1358 break;
1359 }
1360

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

1425 bus_dmamap_t *mapp;
1426 int send = 0;
1427
1428 TSEC_TRANSMIT_LOCK_ASSERT(sc);
1429
1430 ifp = sc->tsec_ifp;
1431
1432 /* Update collision statistics */
1353 /*
1354 * We ran out of mbufs; didn't consume current
1355 * descriptor and have to return it to the queue.
1356 */
1357 TSEC_BACK_CUR_RX_DESC(sc);
1358 break;
1359 }
1360

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

1425 bus_dmamap_t *mapp;
1426 int send = 0;
1427
1428 TSEC_TRANSMIT_LOCK_ASSERT(sc);
1429
1430 ifp = sc->tsec_ifp;
1431
1432 /* Update collision statistics */
1433 ifp->if_collisions += TSEC_READ(sc, TSEC_REG_MON_TNCL);
1433 if_inc_counter(ifp, IFCOUNTER_COLLISIONS, TSEC_READ(sc, TSEC_REG_MON_TNCL));
1434
1435 /* Reset collision counters in hardware */
1436 TSEC_WRITE(sc, TSEC_REG_MON_TSCL, 0);
1437 TSEC_WRITE(sc, TSEC_REG_MON_TMCL, 0);
1438 TSEC_WRITE(sc, TSEC_REG_MON_TLCL, 0);
1439 TSEC_WRITE(sc, TSEC_REG_MON_TXCL, 0);
1440 TSEC_WRITE(sc, TSEC_REG_MON_TNCL, 0);
1441

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

1460
1461 bus_dmamap_sync(sc->tsec_tx_mtag, *mapp,
1462 BUS_DMASYNC_POSTWRITE);
1463 bus_dmamap_unload(sc->tsec_tx_mtag, *mapp);
1464
1465 TSEC_FREE_TX_MAP(sc, mapp);
1466 m_freem(m0);
1467
1434
1435 /* Reset collision counters in hardware */
1436 TSEC_WRITE(sc, TSEC_REG_MON_TSCL, 0);
1437 TSEC_WRITE(sc, TSEC_REG_MON_TMCL, 0);
1438 TSEC_WRITE(sc, TSEC_REG_MON_TLCL, 0);
1439 TSEC_WRITE(sc, TSEC_REG_MON_TXCL, 0);
1440 TSEC_WRITE(sc, TSEC_REG_MON_TNCL, 0);
1441

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

1460
1461 bus_dmamap_sync(sc->tsec_tx_mtag, *mapp,
1462 BUS_DMASYNC_POSTWRITE);
1463 bus_dmamap_unload(sc->tsec_tx_mtag, *mapp);
1464
1465 TSEC_FREE_TX_MAP(sc, mapp);
1466 m_freem(m0);
1467
1468 ifp->if_opackets++;
1468 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
1469 send = 1;
1470 }
1471 bus_dmamap_sync(sc->tsec_tx_dtag, sc->tsec_tx_dmap,
1472 BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
1473
1474 if (send) {
1475 /* Now send anything that was pending */
1476 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;

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

1517 /* Clear events bits in hardware */
1518 TSEC_WRITE(sc, TSEC_REG_IEVENT, TSEC_IEVENT_RXC | TSEC_IEVENT_BSY |
1519 TSEC_IEVENT_EBERR | TSEC_IEVENT_MSRO | TSEC_IEVENT_BABT |
1520 TSEC_IEVENT_TXC | TSEC_IEVENT_TXE | TSEC_IEVENT_LC |
1521 TSEC_IEVENT_CRL | TSEC_IEVENT_XFUN);
1522
1523 /* Check transmitter errors */
1524 if (eflags & TSEC_IEVENT_TXE) {
1469 send = 1;
1470 }
1471 bus_dmamap_sync(sc->tsec_tx_dtag, sc->tsec_tx_dmap,
1472 BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
1473
1474 if (send) {
1475 /* Now send anything that was pending */
1476 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;

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

1517 /* Clear events bits in hardware */
1518 TSEC_WRITE(sc, TSEC_REG_IEVENT, TSEC_IEVENT_RXC | TSEC_IEVENT_BSY |
1519 TSEC_IEVENT_EBERR | TSEC_IEVENT_MSRO | TSEC_IEVENT_BABT |
1520 TSEC_IEVENT_TXC | TSEC_IEVENT_TXE | TSEC_IEVENT_LC |
1521 TSEC_IEVENT_CRL | TSEC_IEVENT_XFUN);
1522
1523 /* Check transmitter errors */
1524 if (eflags & TSEC_IEVENT_TXE) {
1525 ifp->if_oerrors++;
1525 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
1526
1527 if (eflags & TSEC_IEVENT_LC)
1526
1527 if (eflags & TSEC_IEVENT_LC)
1528 ifp->if_collisions++;
1528 if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
1529
1530 TSEC_WRITE(sc, TSEC_REG_TSTAT, TSEC_TSTAT_THLT);
1531 }
1532
1533 /* Check receiver errors */
1534 if (eflags & TSEC_IEVENT_BSY) {
1529
1530 TSEC_WRITE(sc, TSEC_REG_TSTAT, TSEC_TSTAT_THLT);
1531 }
1532
1533 /* Check receiver errors */
1534 if (eflags & TSEC_IEVENT_BSY) {
1535 ifp->if_ierrors++;
1536 ifp->if_iqdrops++;
1535 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
1536 if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
1537
1538 /* Get data from RX buffers */
1539 tsec_receive_intr_locked(sc, count);
1540 }
1541
1542 if (ifp->if_flags & IFF_DEBUG)
1543 if_printf(ifp, "tsec_error_intr(): event flags: 0x%x\n",
1544 eflags);
1545
1546 if (eflags & TSEC_IEVENT_EBERR) {
1547 if_printf(ifp, "System bus error occurred during"
1548 "DMA transaction (flags: 0x%x)\n", eflags);
1549 tsec_init_locked(sc);
1550 }
1551
1552 if (eflags & TSEC_IEVENT_BABT)
1537
1538 /* Get data from RX buffers */
1539 tsec_receive_intr_locked(sc, count);
1540 }
1541
1542 if (ifp->if_flags & IFF_DEBUG)
1543 if_printf(ifp, "tsec_error_intr(): event flags: 0x%x\n",
1544 eflags);
1545
1546 if (eflags & TSEC_IEVENT_EBERR) {
1547 if_printf(ifp, "System bus error occurred during"
1548 "DMA transaction (flags: 0x%x)\n", eflags);
1549 tsec_init_locked(sc);
1550 }
1551
1552 if (eflags & TSEC_IEVENT_BABT)
1553 ifp->if_oerrors++;
1553 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
1554
1555 if (eflags & TSEC_IEVENT_BABR)
1554
1555 if (eflags & TSEC_IEVENT_BABR)
1556 ifp->if_ierrors++;
1556 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
1557}
1558
1559void
1560tsec_error_intr(void *arg)
1561{
1562 struct tsec_softc *sc = arg;
1563
1564 TSEC_GLOBAL_LOCK(sc);

--- 376 unchanged lines hidden ---
1557}
1558
1559void
1560tsec_error_intr(void *arg)
1561{
1562 struct tsec_softc *sc = arg;
1563
1564 TSEC_GLOBAL_LOCK(sc);

--- 376 unchanged lines hidden ---