if_cgem.c (4e27d36d38f4c3b12bcc1855c5d41527d08d1ce0) if_cgem.c (c8dfaf382fa6df9dc6fd1e1c3356e0c8bf607e6a)
1/*-
2 * Copyright (c) 2012-2014 Thomas Skibo <thomasskibo@yahoo.com>
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

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

553 * cluster (which is much bigger than the largest ethernet
554 * packet).
555 */
556 if ((ctl & CGEM_RXDESC_BAD_FCS) != 0 ||
557 (ctl & (CGEM_RXDESC_SOF | CGEM_RXDESC_EOF)) !=
558 (CGEM_RXDESC_SOF | CGEM_RXDESC_EOF)) {
559 /* discard. */
560 m_free(m);
1/*-
2 * Copyright (c) 2012-2014 Thomas Skibo <thomasskibo@yahoo.com>
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

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

553 * cluster (which is much bigger than the largest ethernet
554 * packet).
555 */
556 if ((ctl & CGEM_RXDESC_BAD_FCS) != 0 ||
557 (ctl & (CGEM_RXDESC_SOF | CGEM_RXDESC_EOF)) !=
558 (CGEM_RXDESC_SOF | CGEM_RXDESC_EOF)) {
559 /* discard. */
560 m_free(m);
561 ifp->if_ierrors++;
561 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
562 continue;
563 }
564
565 /* Ready it to hand off to upper layers. */
566 m->m_data += ETHER_ALIGN;
567 m->m_len = (ctl & CGEM_RXDESC_LENGTH_MASK);
568 m->m_pkthdr.rcvif = ifp;
569 m->m_pkthdr.len = m->m_len;

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

599 cgem_fill_rqueue(sc);
600
601 /* Unlock and send up packets. */
602 CGEM_UNLOCK(sc);
603 while (m_hd != NULL) {
604 m = m_hd;
605 m_hd = m_hd->m_next;
606 m->m_next = NULL;
562 continue;
563 }
564
565 /* Ready it to hand off to upper layers. */
566 m->m_data += ETHER_ALIGN;
567 m->m_len = (ctl & CGEM_RXDESC_LENGTH_MASK);
568 m->m_pkthdr.rcvif = ifp;
569 m->m_pkthdr.len = m->m_len;

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

599 cgem_fill_rqueue(sc);
600
601 /* Unlock and send up packets. */
602 CGEM_UNLOCK(sc);
603 while (m_hd != NULL) {
604 m = m_hd;
605 m_hd = m_hd->m_next;
606 m->m_next = NULL;
607 ifp->if_ipackets++;
607 if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
608 (*ifp->if_input)(ifp, m);
609 }
610 CGEM_LOCK(sc);
611}
612
613/* Find completed transmits and free their mbufs. */
614static void
615cgem_clean_tx(struct cgem_softc *sc)

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

641 /* Check the status. */
642 if ((ctl & CGEM_TXDESC_AHB_ERR) != 0) {
643 /* Serious bus error. log to console. */
644 device_printf(sc->dev, "cgem_clean_tx: Whoa! "
645 "AHB error, addr=0x%x\n",
646 sc->txring[sc->txring_tl_ptr].addr);
647 } else if ((ctl & (CGEM_TXDESC_RETRY_ERR |
648 CGEM_TXDESC_LATE_COLL)) != 0) {
608 (*ifp->if_input)(ifp, m);
609 }
610 CGEM_LOCK(sc);
611}
612
613/* Find completed transmits and free their mbufs. */
614static void
615cgem_clean_tx(struct cgem_softc *sc)

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

641 /* Check the status. */
642 if ((ctl & CGEM_TXDESC_AHB_ERR) != 0) {
643 /* Serious bus error. log to console. */
644 device_printf(sc->dev, "cgem_clean_tx: Whoa! "
645 "AHB error, addr=0x%x\n",
646 sc->txring[sc->txring_tl_ptr].addr);
647 } else if ((ctl & (CGEM_TXDESC_RETRY_ERR |
648 CGEM_TXDESC_LATE_COLL)) != 0) {
649 sc->ifp->if_oerrors++;
649 if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1);
650 } else
650 } else
651 sc->ifp->if_opackets++;
651 if_inc_counter(sc->ifp, IFCOUNTER_OPACKETS, 1);
652
653 /* If the packet spanned more than one tx descriptor,
654 * skip descriptors until we find the end so that only
655 * start-of-frame descriptors are processed.
656 */
657 while ((ctl & CGEM_TXDESC_LAST_BUF) == 0) {
658 if ((ctl & CGEM_TXDESC_WRAP) != 0)
659 sc->txring_tl_ptr = 0;

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

816 sc->stats.tx_frames_128to255b += RD4(sc, CGEM_FRAMES_128_255B_TX);
817 sc->stats.tx_frames_256to511b += RD4(sc, CGEM_FRAMES_256_511B_TX);
818 sc->stats.tx_frames_512to1023b += RD4(sc, CGEM_FRAMES_512_1023B_TX);
819 sc->stats.tx_frames_1024to1536b += RD4(sc, CGEM_FRAMES_1024_1518B_TX);
820 sc->stats.tx_under_runs += RD4(sc, CGEM_TX_UNDERRUNS);
821
822 n = RD4(sc, CGEM_SINGLE_COLL_FRAMES);
823 sc->stats.tx_single_collisn += n;
652
653 /* If the packet spanned more than one tx descriptor,
654 * skip descriptors until we find the end so that only
655 * start-of-frame descriptors are processed.
656 */
657 while ((ctl & CGEM_TXDESC_LAST_BUF) == 0) {
658 if ((ctl & CGEM_TXDESC_WRAP) != 0)
659 sc->txring_tl_ptr = 0;

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

816 sc->stats.tx_frames_128to255b += RD4(sc, CGEM_FRAMES_128_255B_TX);
817 sc->stats.tx_frames_256to511b += RD4(sc, CGEM_FRAMES_256_511B_TX);
818 sc->stats.tx_frames_512to1023b += RD4(sc, CGEM_FRAMES_512_1023B_TX);
819 sc->stats.tx_frames_1024to1536b += RD4(sc, CGEM_FRAMES_1024_1518B_TX);
820 sc->stats.tx_under_runs += RD4(sc, CGEM_TX_UNDERRUNS);
821
822 n = RD4(sc, CGEM_SINGLE_COLL_FRAMES);
823 sc->stats.tx_single_collisn += n;
824 sc->ifp->if_collisions += n;
824 if_inc_counter(sc->ifp, IFCOUNTER_COLLISIONS, n);
825 n = RD4(sc, CGEM_MULTI_COLL_FRAMES);
826 sc->stats.tx_multi_collisn += n;
825 n = RD4(sc, CGEM_MULTI_COLL_FRAMES);
826 sc->stats.tx_multi_collisn += n;
827 sc->ifp->if_collisions += n;
827 if_inc_counter(sc->ifp, IFCOUNTER_COLLISIONS, n);
828 n = RD4(sc, CGEM_EXCESSIVE_COLL_FRAMES);
829 sc->stats.tx_excsv_collisn += n;
828 n = RD4(sc, CGEM_EXCESSIVE_COLL_FRAMES);
829 sc->stats.tx_excsv_collisn += n;
830 sc->ifp->if_collisions += n;
830 if_inc_counter(sc->ifp, IFCOUNTER_COLLISIONS, n);
831 n = RD4(sc, CGEM_LATE_COLL);
832 sc->stats.tx_late_collisn += n;
831 n = RD4(sc, CGEM_LATE_COLL);
832 sc->stats.tx_late_collisn += n;
833 sc->ifp->if_collisions += n;
833 if_inc_counter(sc->ifp, IFCOUNTER_COLLISIONS, n);
834
835 sc->stats.tx_deferred_frames += RD4(sc, CGEM_DEFERRED_TX_FRAMES);
836 sc->stats.tx_carrier_sense_errs += RD4(sc, CGEM_CARRIER_SENSE_ERRS);
837
838 sc->stats.rx_bytes += RD4(sc, CGEM_OCTETS_RX_BOT);
839 sc->stats.rx_bytes += (uint64_t)RD4(sc, CGEM_OCTETS_RX_TOP) << 32;
840
841 sc->stats.rx_frames += RD4(sc, CGEM_FRAMES_RX);

--- 985 unchanged lines hidden ---
834
835 sc->stats.tx_deferred_frames += RD4(sc, CGEM_DEFERRED_TX_FRAMES);
836 sc->stats.tx_carrier_sense_errs += RD4(sc, CGEM_CARRIER_SENSE_ERRS);
837
838 sc->stats.rx_bytes += RD4(sc, CGEM_OCTETS_RX_BOT);
839 sc->stats.rx_bytes += (uint64_t)RD4(sc, CGEM_OCTETS_RX_TOP) << 32;
840
841 sc->stats.rx_frames += RD4(sc, CGEM_FRAMES_RX);

--- 985 unchanged lines hidden ---