Deleted Added
full compact
if_cp.c (271373) if_cp.c (271849)
1/*-
2 * Cronyx-Tau-PCI adapter driver for FreeBSD.
3 * Supports PPP/HDLC, Cisco/HDLC and FrameRelay protocol in synchronous mode,
4 * and asynchronous channels with full modem control.
5 * Keepalive protocol implemented in both Cisco and PPP modes.
6 *
7 * Copyright (C) 1999-2004 Cronyx Engineering.
8 * Author: Kurakin Roman, <rik@cronyx.ru>

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

17 * modify and redistribute this software in source and binary forms,
18 * as long as this message is kept with the software, all derivative
19 * works or modified versions.
20 *
21 * Cronyx Id: if_cp.c,v 1.1.2.41 2004/06/23 17:09:13 rik Exp $
22 */
23
24#include <sys/cdefs.h>
1/*-
2 * Cronyx-Tau-PCI adapter driver for FreeBSD.
3 * Supports PPP/HDLC, Cisco/HDLC and FrameRelay protocol in synchronous mode,
4 * and asynchronous channels with full modem control.
5 * Keepalive protocol implemented in both Cisco and PPP modes.
6 *
7 * Copyright (C) 1999-2004 Cronyx Engineering.
8 * Author: Kurakin Roman, <rik@cronyx.ru>

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

17 * modify and redistribute this software in source and binary forms,
18 * as long as this message is kept with the software, all derivative
19 * works or modified versions.
20 *
21 * Cronyx Id: if_cp.c,v 1.1.2.41 2004/06/23 17:09:13 rik Exp $
22 */
23
24#include <sys/cdefs.h>
25__FBSDID("$FreeBSD: head/sys/dev/cp/if_cp.c 271373 2014-09-10 09:57:32Z rwatson $");
25__FBSDID("$FreeBSD: head/sys/dev/cp/if_cp.c 271849 2014-09-19 03:51:26Z glebius $");
26
27#include <sys/param.h>
28#include <sys/ucred.h>
29#include <sys/proc.h>
30#include <sys/systm.h>
31#include <sys/mbuf.h>
32#include <sys/kernel.h>
33#include <sys/module.h>

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

862}
863
864static void cp_transmit (cp_chan_t *c, void *attachment, int len)
865{
866 drv_t *d = c->sys;
867
868 d->timeout = 0;
869#ifndef NETGRAPH
26
27#include <sys/param.h>
28#include <sys/ucred.h>
29#include <sys/proc.h>
30#include <sys/systm.h>
31#include <sys/mbuf.h>
32#include <sys/kernel.h>
33#include <sys/module.h>

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

862}
863
864static void cp_transmit (cp_chan_t *c, void *attachment, int len)
865{
866 drv_t *d = c->sys;
867
868 d->timeout = 0;
869#ifndef NETGRAPH
870 ++d->ifp->if_opackets;
870 if_inc_counter(d->ifp, IFCOUNTER_OPACKETS, 1);
871 d->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
872#endif
873 cp_start (d);
874}
875
876static void cp_receive (cp_chan_t *c, unsigned char *data, int len)
877{
878 drv_t *d = c->sys;

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

883
884 if (! d->running)
885 return;
886
887 m = makembuf (data, len);
888 if (! m) {
889 CP_DEBUG (d, ("no memory for packet\n"));
890#ifndef NETGRAPH
871 d->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
872#endif
873 cp_start (d);
874}
875
876static void cp_receive (cp_chan_t *c, unsigned char *data, int len)
877{
878 drv_t *d = c->sys;

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

883
884 if (! d->running)
885 return;
886
887 m = makembuf (data, len);
888 if (! m) {
889 CP_DEBUG (d, ("no memory for packet\n"));
890#ifndef NETGRAPH
891 ++d->ifp->if_iqdrops;
891 if_inc_counter(d->ifp, IFCOUNTER_IQDROPS, 1);
892#endif
893 return;
894 }
895 if (c->debug > 1)
896 m_print (m, 0);
897#ifdef NETGRAPH
898 m->m_pkthdr.rcvif = 0;
899 NG_SEND_DATA_ONLY (error, d->hook, m);
900#else
892#endif
893 return;
894 }
895 if (c->debug > 1)
896 m_print (m, 0);
897#ifdef NETGRAPH
898 m->m_pkthdr.rcvif = 0;
899 NG_SEND_DATA_ONLY (error, d->hook, m);
900#else
901 ++d->ifp->if_ipackets;
901 if_inc_counter(d->ifp, IFCOUNTER_IPACKETS, 1);
902 m->m_pkthdr.rcvif = d->ifp;
903 /* Check if there's a BPF listener on this interface.
904 * If so, hand off the raw packet to bpf. */
905 BPF_TAP (d->ifp, data, len);
906 IF_ENQUEUE (&d->queue, m);
907#endif
908}
909
910static void cp_error (cp_chan_t *c, int data)
911{
912 drv_t *d = c->sys;
913
914 switch (data) {
915 case CP_FRAME:
916 CP_DEBUG (d, ("frame error\n"));
917#ifndef NETGRAPH
902 m->m_pkthdr.rcvif = d->ifp;
903 /* Check if there's a BPF listener on this interface.
904 * If so, hand off the raw packet to bpf. */
905 BPF_TAP (d->ifp, data, len);
906 IF_ENQUEUE (&d->queue, m);
907#endif
908}
909
910static void cp_error (cp_chan_t *c, int data)
911{
912 drv_t *d = c->sys;
913
914 switch (data) {
915 case CP_FRAME:
916 CP_DEBUG (d, ("frame error\n"));
917#ifndef NETGRAPH
918 ++d->ifp->if_ierrors;
918 if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1);
919#endif
920 break;
921 case CP_CRC:
922 CP_DEBUG (d, ("crc error\n"));
923#ifndef NETGRAPH
919#endif
920 break;
921 case CP_CRC:
922 CP_DEBUG (d, ("crc error\n"));
923#ifndef NETGRAPH
924 ++d->ifp->if_ierrors;
924 if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1);
925#endif
926 break;
927 case CP_OVERRUN:
928 CP_DEBUG (d, ("overrun error\n"));
929#ifndef NETGRAPH
925#endif
926 break;
927 case CP_OVERRUN:
928 CP_DEBUG (d, ("overrun error\n"));
929#ifndef NETGRAPH
930 ++d->ifp->if_collisions;
931 ++d->ifp->if_ierrors;
930 if_inc_counter(d->ifp, IFCOUNTER_COLLISIONS, 1);
931 if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1);
932#endif
933 break;
934 case CP_OVERFLOW:
935 CP_DEBUG (d, ("overflow error\n"));
936#ifndef NETGRAPH
932#endif
933 break;
934 case CP_OVERFLOW:
935 CP_DEBUG (d, ("overflow error\n"));
936#ifndef NETGRAPH
937 ++d->ifp->if_ierrors;
937 if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1);
938#endif
939 break;
940 case CP_UNDERRUN:
941 CP_DEBUG (d, ("underrun error\n"));
942 d->timeout = 0;
943#ifndef NETGRAPH
938#endif
939 break;
940 case CP_UNDERRUN:
941 CP_DEBUG (d, ("underrun error\n"));
942 d->timeout = 0;
943#ifndef NETGRAPH
944 ++d->ifp->if_oerrors;
944 if_inc_counter(d->ifp, IFCOUNTER_OERRORS, 1);
945 d->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
946#endif
947 cp_start (d);
948 break;
949 default:
950 CP_DEBUG (d, ("error #%d\n", data));
951 break;
952 }

--- 1320 unchanged lines hidden ---
945 d->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
946#endif
947 cp_start (d);
948 break;
949 default:
950 CP_DEBUG (d, ("error #%d\n", data));
951 break;
952 }

--- 1320 unchanged lines hidden ---