if_sbni.c (263102) | if_sbni.c (271849) |
---|---|
1/*- 2 * Copyright (c) 1997-2001 Granch, Ltd. All rights reserved. 3 * Author: Denis I.Timofeev <timofeev@granch.ru> 4 * 5 * Redistributon 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 --- 13 unchanged lines hidden (view full) --- 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 */ 28 29#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997-2001 Granch, Ltd. All rights reserved. 3 * Author: Denis I.Timofeev <timofeev@granch.ru> 4 * 5 * Redistributon 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 --- 13 unchanged lines hidden (view full) --- 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sys/dev/sbni/if_sbni.c 263102 2014-03-13 03:42:24Z glebius $"); | 30__FBSDID("$FreeBSD: head/sys/dev/sbni/if_sbni.c 271849 2014-09-19 03:51:26Z glebius $"); |
31 32/* 33 * Device driver for Granch SBNI12 leased line adapters 34 * 35 * Revision 2.0.0 1997/08/06 36 * Initial revision by Alexey Zverev 37 * 38 * Revision 2.0.1 1997/08/11 --- 568 unchanged lines hidden (view full) --- 607 608 /* 609 * if CRC is right but framelen incorrect then transmitter 610 * error was occured... drop entire packet 611 */ 612 } else if ((frame_ok = skip_tail(sc, framelen, crc)) != 0) { 613 sc->wait_frameno = 0; 614 sc->inppos = 0; | 31 32/* 33 * Device driver for Granch SBNI12 leased line adapters 34 * 35 * Revision 2.0.0 1997/08/06 36 * Initial revision by Alexey Zverev 37 * 38 * Revision 2.0.1 1997/08/11 --- 568 unchanged lines hidden (view full) --- 607 608 /* 609 * if CRC is right but framelen incorrect then transmitter 610 * error was occured... drop entire packet 611 */ 612 } else if ((frame_ok = skip_tail(sc, framelen, crc)) != 0) { 613 sc->wait_frameno = 0; 614 sc->inppos = 0; |
615 sc->ifp->if_ierrors++; | 615 if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); |
616 /* now skip all frames until is_first != 0 */ 617 } 618 } else 619 frame_ok = skip_tail(sc, framelen, crc); 620 621 if (is_first && !frame_ok) { 622 /* 623 * Frame has been violated, but we have stored 624 * is_first already... Drop entire packet. 625 */ 626 sc->wait_frameno = 0; | 616 /* now skip all frames until is_first != 0 */ 617 } 618 } else 619 frame_ok = skip_tail(sc, framelen, crc); 620 621 if (is_first && !frame_ok) { 622 /* 623 * Frame has been violated, but we have stored 624 * is_first already... Drop entire packet. 625 */ 626 sc->wait_frameno = 0; |
627 sc->ifp->if_ierrors++; | 627 if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); |
628 } 629 630 return (frame_ok); 631} 632 633 634static __inline void send_complete(struct sbni_softc *); 635 636static __inline void 637send_complete(struct sbni_softc *sc) 638{ 639 m_freem(sc->tx_buf_p); 640 sc->tx_buf_p = NULL; | 628 } 629 630 return (frame_ok); 631} 632 633 634static __inline void send_complete(struct sbni_softc *); 635 636static __inline void 637send_complete(struct sbni_softc *sc) 638{ 639 m_freem(sc->tx_buf_p); 640 sc->tx_buf_p = NULL; |
641 sc->ifp->if_opackets++; | 641 if_inc_counter(sc->ifp, IFCOUNTER_OPACKETS, 1); |
642} 643 644 645static void 646interpret_ack(struct sbni_softc *sc, u_int ack) 647{ 648 if (ack == FRAME_SENT_OK) { 649 sc->state &= ~FL_NEED_RESEND; --- 34 unchanged lines hidden (view full) --- 684 p = sc->rx_buf_p->m_data + sc->inppos; 685 sbni_insb(sc, p, framelen); 686 if (calc_crc32(crc, p, framelen) != CRC32_REMAINDER) 687 return (0); 688 689 sc->inppos += framelen - 4; 690 if (--sc->wait_frameno == 0) { /* last frame received */ 691 indicate_pkt(sc); | 642} 643 644 645static void 646interpret_ack(struct sbni_softc *sc, u_int ack) 647{ 648 if (ack == FRAME_SENT_OK) { 649 sc->state &= ~FL_NEED_RESEND; --- 34 unchanged lines hidden (view full) --- 684 p = sc->rx_buf_p->m_data + sc->inppos; 685 sbni_insb(sc, p, framelen); 686 if (calc_crc32(crc, p, framelen) != CRC32_REMAINDER) 687 return (0); 688 689 sc->inppos += framelen - 4; 690 if (--sc->wait_frameno == 0) { /* last frame received */ 691 indicate_pkt(sc); |
692 sc->ifp->if_ipackets++; | 692 if_inc_counter(sc->ifp, IFCOUNTER_IPACKETS, 1); |
693 } 694 695 return (1); 696} 697 698 699/* 700 * Prepare to start output on adapter. Current priority must be set to splimp --- 49 unchanged lines hidden (view full) --- 750static void 751drop_xmit_queue(struct sbni_softc *sc) 752{ 753 struct mbuf *m; 754 755 if (sc->tx_buf_p) { 756 m_freem(sc->tx_buf_p); 757 sc->tx_buf_p = NULL; | 693 } 694 695 return (1); 696} 697 698 699/* 700 * Prepare to start output on adapter. Current priority must be set to splimp --- 49 unchanged lines hidden (view full) --- 750static void 751drop_xmit_queue(struct sbni_softc *sc) 752{ 753 struct mbuf *m; 754 755 if (sc->tx_buf_p) { 756 m_freem(sc->tx_buf_p); 757 sc->tx_buf_p = NULL; |
758 sc->ifp->if_oerrors++; | 758 if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); |
759 } 760 761 for (;;) { 762 IF_DEQUEUE(&sc->ifp->if_snd, m); 763 if (m == NULL) 764 break; 765 m_freem(m); | 759 } 760 761 for (;;) { 762 IF_DEQUEUE(&sc->ifp->if_snd, m); 763 if (m == NULL) 764 break; 765 m_freem(m); |
766 sc->ifp->if_oerrors++; | 766 if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); |
767 } 768 769 sc->tx_frameno = 0; 770 sc->framelen = 0; 771 sc->outpos = 0; 772 sc->state &= ~(FL_WAIT_ACK | FL_NEED_RESEND); 773 sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 774} --- 504 unchanged lines hidden --- | 767 } 768 769 sc->tx_frameno = 0; 770 sc->framelen = 0; 771 sc->outpos = 0; 772 sc->state &= ~(FL_WAIT_ACK | FL_NEED_RESEND); 773 sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 774} --- 504 unchanged lines hidden --- |