diff options
| author | Gleb Smirnoff <glebius@FreeBSD.org> | 2021-10-21 04:08:13 +0000 |
|---|---|---|
| committer | Gleb Smirnoff <glebius@FreeBSD.org> | 2021-10-22 18:41:36 +0000 |
| commit | 6aae3517ed2500fb963ba0a4264b4756088dd0f4 (patch) | |
| tree | 908d4029e181694478c80ea53b4eefc11e30b517 /sys/dev/cp | |
| parent | a23e18ea545675aca7551ef2395f6df40a3acb29 (diff) | |
Diffstat (limited to 'sys/dev/cp')
| -rw-r--r-- | sys/dev/cp/cserial.h | 519 | ||||
| -rw-r--r-- | sys/dev/cp/if_cp.c | 316 | ||||
| -rw-r--r-- | sys/dev/cp/ng_cp.h | 4 |
3 files changed, 525 insertions, 314 deletions
diff --git a/sys/dev/cp/cserial.h b/sys/dev/cp/cserial.h new file mode 100644 index 000000000000..833976a30a16 --- /dev/null +++ b/sys/dev/cp/cserial.h @@ -0,0 +1,519 @@ +/*- + * Ioctl interface to Cronyx serial drivers. + * + * Copyright (C) 1997-2002 Cronyx Engineering. + * Author: Serge Vakulenko, <vak@cronyx.ru> + * + * Copyright (C) 2001-2005 Cronyx Engineering. + * Author: Roman Kurakin, <rik@FreeBSD.org> + * + * Copyright (C) 2004-2005 Cronyx Engineering. + * Author: Leo Yuriev, <ly@cronyx.ru> + * + * This software is distributed with NO WARRANTIES, not even the implied + * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Authors grant any other persons or organisations permission to use + * or modify this software as long as this message is kept with the software, + * all derivative works or modified versions. + * + * Cronyx Id: cserial.h,v 1.4.2.2 2005/11/09 13:01:35 rik Exp $ + * $FreeBSD$ + */ + +/* + * General channel statistics. + */ +struct serial_statistics { + unsigned long rintr; /* receive interrupts */ + unsigned long tintr; /* transmit interrupts */ + unsigned long mintr; /* modem interrupts */ + unsigned long ibytes; /* input bytes */ + unsigned long ipkts; /* input packets */ + unsigned long ierrs; /* input errors */ + unsigned long obytes; /* output bytes */ + unsigned long opkts; /* output packets */ + unsigned long oerrs; /* output errors */ +}; + +/* + * Statistics for E1/G703 channels. + */ +struct e1_counters { + unsigned long bpv; /* bipolar violations */ + unsigned long fse; /* frame sync errors */ + unsigned long crce; /* CRC errors */ + unsigned long rcrce; /* remote CRC errors (E-bit) */ + unsigned long uas; /* unavailable seconds */ + unsigned long les; /* line errored seconds */ + unsigned long es; /* errored seconds */ + unsigned long bes; /* bursty errored seconds */ + unsigned long ses; /* severely errored seconds */ + unsigned long oofs; /* out of frame seconds */ + unsigned long css; /* controlled slip seconds */ + unsigned long dm; /* degraded minutes */ +}; + +struct e1_statistics { + unsigned long status; /* line status bit mask */ + unsigned long cursec; /* seconds in current interval */ + unsigned long totsec; /* total seconds elapsed */ + struct e1_counters currnt; /* current 15-min interval data */ + struct e1_counters total; /* total statistics data */ + struct e1_counters interval [48]; /* 12 hour period data */ +}; + +struct e3_statistics { + unsigned long status; + unsigned long cursec; + unsigned long totsec; + unsigned long ccv; + unsigned long tcv; + unsigned long icv[48]; +}; + +#define M_ASYNC 0 /* asynchronous mode */ +#define M_HDLC 1 /* bit-sync mode (HDLC) */ +#define M_G703 2 +#define M_E1 3 + +/* + * Receive error codes. + */ +#define ER_FRAMING 1 /* framing error */ +#define ER_CHECKSUM 2 /* parity/CRC error */ +#define ER_BREAK 3 /* break state */ +#define ER_OVERFLOW 4 /* receive buffer overflow */ +#define ER_OVERRUN 5 /* receive fifo overrun */ +#define ER_UNDERRUN 6 /* transmit fifo underrun */ +#define ER_SCC_FRAMING 7 /* subchannel framing error */ +#define ER_SCC_OVERFLOW 8 /* subchannel receive buffer overflow */ +#define ER_SCC_OVERRUN 9 /* subchannel receiver overrun */ +#define ER_SCC_UNDERRUN 10 /* subchannel transmitter underrun */ +#define ER_BUS 11 /* system bus is too busy (e.g PCI) */ + +/* + * E1 channel status. + */ +#define E1_NOALARM 0x0001 /* no alarm present */ +#define E1_FARLOF 0x0002 /* receiving far loss of framing */ +#define E1_CRC4E 0x0004 /* crc4 errors */ +#define E1_AIS 0x0008 /* receiving all ones */ +#define E1_LOF 0x0020 /* loss of framing */ +#define E1_LOS 0x0040 /* loss of signal */ +#define E1_AIS16 0x0100 /* receiving all ones in timeslot 16 */ +#define E1_FARLOMF 0x0200 /* receiving alarm in timeslot 16 */ +#define E1_LOMF 0x0400 /* loss of multiframe sync */ +#define E1_TSTREQ 0x0800 /* test code detected */ +#define E1_TSTERR 0x1000 /* test error */ + +#define E3_LOS 0x00000002 /* Lost of synchronization */ +#define E3_TXE 0x00000004 /* Transmit error */ + +/* + * Query the mask of all registered channels, max 128. + */ +#define SERIAL_GETREGISTERED _IOR ('x', 0, char[16]) + +/* + * Attach/detach the protocol to the channel. + * The protocol is given by its name, char[8]. + * For example "async", "hdlc", "cisco", "fr", "ppp". + */ +#define SERIAL_GETPROTO _IOR ('x', 1, char [8]) +#define SERIAL_SETPROTO _IOW ('x', 1, char [8]) + +/* + * Query/set the hardware mode for the channel. + */ +#define SERIAL_GETMODE _IOR ('x', 2, int) +#define SERIAL_SETMODE _IOW ('x', 2, int) + +#define SERIAL_ASYNC 1 +#define SERIAL_HDLC 2 +#define SERIAL_RAW 3 + +/* + * Get/clear the channel statistics. + */ +#define SERIAL_GETSTAT _IOR ('x', 3, struct serial_statistics) +#define SERIAL_GETESTAT _IOR ('x', 3, struct e1_statistics) +#define SERIAL_GETE3STAT _IOR ('x', 3, struct e3_statistics) +#define SERIAL_CLRSTAT _IO ('x', 3) + +/* + * Query/set the synchronization mode and baud rate. + * If baud==0 then the external clock is used. + */ +#define SERIAL_GETBAUD _IOR ('x', 4, long) +#define SERIAL_SETBAUD _IOW ('x', 4, long) + +/* + * Query/set the internal loopback mode, + * useful for debugging purposes. + */ +#define SERIAL_GETLOOP _IOR ('x', 5, int) +#define SERIAL_SETLOOP _IOW ('x', 5, int) + +/* + * Query/set the DPLL mode, commonly used with NRZI + * for channels lacking synchro signals. + */ +#define SERIAL_GETDPLL _IOR ('x', 6, int) +#define SERIAL_SETDPLL _IOW ('x', 6, int) + +/* + * Query/set the NRZI encoding (default is NRZ). + */ +#define SERIAL_GETNRZI _IOR ('x', 7, int) +#define SERIAL_SETNRZI _IOW ('x', 7, int) + +/* + * Invert receive and transmit clock. + */ +#define SERIAL_GETINVCLK _IOR ('x', 8, int) +#define SERIAL_SETINVCLK _IOW ('x', 8, int) + +/* + * Query/set the E1/G703 synchronization mode. + */ +#define SERIAL_GETCLK _IOR ('x', 9, int) +#define SERIAL_SETCLK _IOW ('x', 9, int) + +#define E1CLK_RECOVERY -1 +#define E1CLK_INTERNAL 0 +#define E1CLK_RECEIVE 1 +#define E1CLK_RECEIVE_CHAN0 2 +#define E1CLK_RECEIVE_CHAN1 3 +#define E1CLK_RECEIVE_CHAN2 4 +#define E1CLK_RECEIVE_CHAN3 5 + +/* + * Query/set the E1 timeslot mask. + */ +#define SERIAL_GETTIMESLOTS _IOR ('x', 10, long) +#define SERIAL_SETTIMESLOTS _IOW ('x', 10, long) + +/* + * Query/set the E1 subchannel timeslot mask. + */ +#define SERIAL_GETSUBCHAN _IOR ('x', 11, long) +#define SERIAL_SETSUBCHAN _IOW ('x', 11, long) + +/* + * Query/set the high input sensitivity mode (E1). + */ +#define SERIAL_GETHIGAIN _IOR ('x', 12, int) +#define SERIAL_SETHIGAIN _IOW ('x', 12, int) + +/* + * Query the input signal level in santibells. + */ +#define SERIAL_GETLEVEL _IOR ('x', 13, int) + +/* + * Get the channel name. + */ +#define SERIAL_GETNAME _IOR ('x', 14, char [32]) + +/* + * Get version string. + */ +#define SERIAL_GETVERSIONSTRING _IOR ('x', 15, char [256]) + +/* + * Query/set master channel. + */ +#define SERIAL_GETMASTER _IOR ('x', 16, char [16]) +#define SERIAL_SETMASTER _IOW ('x', 16, char [16]) + +/* + * Query/set keepalive. + */ +#define SERIAL_GETKEEPALIVE _IOR ('x', 17, int) +#define SERIAL_SETKEEPALIVE _IOW ('x', 17, int) + +/* + * Query/set E1 configuration. + */ +#define SERIAL_GETCFG _IOR ('x', 18, char) +#define SERIAL_SETCFG _IOW ('x', 18, char) + +/* + * Query/set debug. + */ +#define SERIAL_GETDEBUG _IOR ('x', 19, int) +#define SERIAL_SETDEBUG _IOW ('x', 19, int) + +/* + * Query/set phony mode (E1). + */ +#define SERIAL_GETPHONY _IOR ('x', 20, int) +#define SERIAL_SETPHONY _IOW ('x', 20, int) + +/* + * Query/set timeslot 16 usage mode (E1). + */ +#define SERIAL_GETUSE16 _IOR ('x', 21, int) +#define SERIAL_SETUSE16 _IOW ('x', 21, int) + +/* + * Query/set crc4 mode (E1). + */ +#define SERIAL_GETCRC4 _IOR ('x', 22, int) +#define SERIAL_SETCRC4 _IOW ('x', 22, int) + +/* + * Query/set the timeout to recover after transmit interrupt loss. + * If timo==0 recover will be disabled. + */ +#define SERIAL_GETTIMO _IOR ('x', 23, long) +#define SERIAL_SETTIMO _IOW ('x', 23, long) + +/* + * Query/set port type for old models of Sigma + * -1 Fixed or cable select + * 0 RS-232 + * 1 V35 + * 2 RS-449 + * 3 E1 (only for Windows 2000) + * 4 G.703 (only for Windows 2000) + * 5 DATA (only for Windows 2000) + * 6 E3 (only for Windows 2000) + * 7 T3 (only for Windows 2000) + * 8 STS1 (only for Windows 2000) + */ +#define SERIAL_GETPORT _IOR ('x', 25, int) +#define SERIAL_SETPORT _IOW ('x', 25, int) + +/* + * Add the virtual channel DLCI (Frame Relay). + */ +#define SERIAL_ADDDLCI _IOW ('x', 26, int) + +/* + * Invert receive clock. + */ +#define SERIAL_GETINVRCLK _IOR ('x', 27, int) +#define SERIAL_SETINVRCLK _IOW ('x', 27, int) + +/* + * Invert transmit clock. + */ +#define SERIAL_GETINVTCLK _IOR ('x', 28, int) +#define SERIAL_SETINVTCLK _IOW ('x', 28, int) + +/* + * Unframed E1 mode. + */ +#define SERIAL_GETUNFRAM _IOR ('x', 29, int) +#define SERIAL_SETUNFRAM _IOW ('x', 29, int) + +/* + * E1 monitoring mode. + */ +#define SERIAL_GETMONITOR _IOR ('x', 30, int) +#define SERIAL_SETMONITOR _IOW ('x', 30, int) + +/* + * Interrupt number. + */ +#define SERIAL_GETIRQ _IOR ('x', 31, int) + +/* + * Reset. + */ +#define SERIAL_RESET _IO ('x', 32) + +/* + * Hard reset. + */ +#define SERIAL_HARDRESET _IO ('x', 33) + +/* + * Query cable type. + */ +#define SERIAL_GETCABLE _IOR ('x', 34, int) + +/* + * Assignment of HDLC ports to E1 channels. + */ +#define SERIAL_GETDIR _IOR ('x', 35, int) +#define SERIAL_SETDIR _IOW ('x', 35, int) + +struct dxc_table { /* cross-connector parameters */ + unsigned char ts [32]; /* timeslot number */ + unsigned char link [32]; /* E1 link number */ +}; + +/* + * DXC cross-connector settings for E1 channels. + */ +#define SERIAL_GETDXC _IOR ('x', 36, struct dxc_table) +#define SERIAL_SETDXC _IOW ('x', 36, struct dxc_table) + +/* + * Scrambler for G.703. + */ +#define SERIAL_GETSCRAMBLER _IOR ('x', 37, int) +#define SERIAL_SETSCRAMBLER _IOW ('x', 37, int) + +/* + * Length of cable for T3 and STS-1. + */ +#define SERIAL_GETCABLEN _IOR ('x', 38, int) +#define SERIAL_SETCABLEN _IOW ('x', 38, int) + +/* + * Remote loopback for E3, T3 and STS-1. + */ +#define SERIAL_GETRLOOP _IOR ('x', 39, int) +#define SERIAL_SETRLOOP _IOW ('x', 39, int) + +/* + * G.703 line code + */ +#define SERIAL_GETLCODE _IOR ('x', 40, int) +#define SERIAL_SETLCODE _IOW ('x', 40, int) + +/* + * MTU + */ +#define SERIAL_GETMTU _IOR ('x', 41, int) +#define SERIAL_SETMTU _IOW ('x', 41, int) + +/* + * Receive Queue Length + */ +#define SERIAL_GETRQLEN _IOR ('x', 42, int) +#define SERIAL_SETRQLEN _IOW ('x', 42, int) + +#ifdef __KERNEL__ +#ifdef CRONYX_LYSAP +# define LYSAP_PEER_ADD _IOWR('x', 101, lysap_peer_config_t) +# define LYSAP_PEER_REMOVE _IOW('x', 102, unsigned) +# define LYSAP_PEER_INFO _IOWR('x', 103, lysap_peer_info_t) +# define LYSAP_PEER_COUNT _IOR('x', 104, unsigned) +# define LYSAP_PEER_ENUM _IOWR('x', 105, unsigned) +# define LYSAP_PEER_CLEAR _IOW('x', 106, unsigned) + +# define LYSAP_CHAN_ADD _IOWR('x', 111, lysap_channel_config_t) +# define LYSAP_CHAN_REMOVE _IO('x', 112) +# define LYSAP_CHAN_INFO _IOR('x', 113, lysap_channel_info_t) +# define LYSAP_CHAN_COUNT _IOR('x', 114, unsigned) +# define LYSAP_CHAN_ENUM _IOWR('x', 115, unsigned) +# define LYSAP_CHAN_CLEAR _IO('x', 116) +# include "lysap-linux.h" +#else /* CRONYX_LYSAP */ + typedef struct _lysap_channel_t lysap_channel_t; + typedef struct _lysap_channel_config_t lysap_channel_config_t; + typedef struct _LYSAP_DeviceInterfaceConfig LYSAP_DeviceInterfaceConfig; + typedef struct _LYSAP_ChannelConfig LYSAP_ChannelConfig; + typedef struct _lysap_buf_t lysap_buf_t; +#endif /* !CRONYX_LYSAP */ + +/* + * Dynamic binder interface. + */ +typedef struct _chan_t chan_t; +typedef struct _proto_t proto_t; + +void binder_register_protocol (proto_t *p); +void binder_unregister_protocol (proto_t *p); + +int binder_register_channel (chan_t *h, char *prefix, int minor); +void binder_unregister_channel (chan_t *h); + +/* + * Hardware channel driver structure. + */ +struct sk_buff; + +struct _chan_t { + char name [16]; + int mtu; /* max packet size */ + int fifosz; /* total hardware i/o buffer size */ + int port; /* hardware base i/o port */ + int irq; /* hardware interrupt line */ + int minor; /* minor number 0..127, assigned by binder */ + int debug; /* debug level, 0..2 */ + int running; /* running, 0..1 */ + struct _proto_t *proto; /* protocol interface data */ + void *sw; /* protocol private data */ + void *hw; /* hardware layer private data */ + + /* Interface to protocol */ + int (*up) (chan_t *h); + void (*down) (chan_t *h); + int (*transmit) (chan_t *h, struct sk_buff *skb); + void (*set_dtr) (chan_t *h, int val); + void (*set_rts) (chan_t *h, int val); + int (*query_dtr) (chan_t *h); + int (*query_rts) (chan_t *h); + int (*query_dsr) (chan_t *h); + int (*query_cts) (chan_t *h); + int (*query_dcd) (chan_t *h); + + /* Interface to async protocol */ + void (*set_async_param) (chan_t *h, int baud, int bits, int parity, + int stop2, int ignpar, int rtscts, + int ixon, int ixany, int symstart, int symstop); + void (*send_break) (chan_t *h, int msec); + void (*send_xon) (chan_t *h); + void (*send_xoff) (chan_t *h); + void (*start_transmitter) (chan_t *h); + void (*stop_transmitter) (chan_t *h); + void (*flush_transmit_buffer) (chan_t *h); + + /* Control interface */ + int (*control) (chan_t *h, unsigned int cmd, unsigned long arg); + + /* LYSAP interface */ + struct lysap_t + { + lysap_channel_t *link; + int (*inspect_config)(chan_t *h, lysap_channel_config_t *, + LYSAP_DeviceInterfaceConfig *, LYSAP_ChannelConfig *); + unsigned long (*probe_freq)(chan_t *h, unsigned long freq); + unsigned long (*set_freq)(chan_t *h, unsigned long freq); + unsigned (*get_status)(chan_t *h); + int (*transmit) (chan_t *h, lysap_buf_t *b); + lysap_buf_t* (*alloc_buf) (chan_t *h, unsigned len); + int (*set_clock_master)(chan_t *h, int enable); + unsigned long (*get_master_freq)(chan_t *h); + } lysap; +}; + +/* + * Protocol driver structure. + */ +struct _proto_t { + char *name; + struct _proto_t *next; + + /* Interface to channel */ + void (*receive) (chan_t *h, struct sk_buff *skb); + void (*receive_error) (chan_t *h, int errcode); + void (*transmit) (chan_t *h); + void (*modem_event) (chan_t *h); + + /* Interface to binder */ + int (*open) (chan_t *h); + void (*close) (chan_t *h); + int (*read) (chan_t *h, unsigned short flg, char *buf, int len); + int (*write) (chan_t *h, unsigned short flg, const char *buf, int len); + int (*select) (chan_t *h, int type, void *st, struct file *filp); + struct fasync_struct *fasync; + + /* Control interface */ + int (*attach) (chan_t *h); + int (*detach) (chan_t *h); + int (*control) (chan_t *h, unsigned int cmd, unsigned long arg); + + /* LYSAP interface */ + void (*transmit_error) (chan_t *h, int errcode); + void (*lysap_notify_receive) (chan_t *h, lysap_buf_t *b); + void (*lysap_notify_transmit) (chan_t *h); + lysap_buf_t* (*lysap_get_data)(chan_t *h); +}; +#endif /* KERNEL */ diff --git a/sys/dev/cp/if_cp.c b/sys/dev/cp/if_cp.c index c8d080fcc601..d2f7fa58b02f 100644 --- a/sys/dev/cp/if_cp.c +++ b/sys/dev/cp/if_cp.c @@ -47,32 +47,14 @@ __FBSDID("$FreeBSD$"); #include <dev/pci/pcireg.h> #include <machine/bus.h> #include <sys/rman.h> -#include "opt_ng_cronyx.h" -#ifdef NETGRAPH_CRONYX -# include "opt_netgraph.h" -# ifndef NETGRAPH -# error #option NETGRAPH missed from configuration -# endif -# include <netgraph/ng_message.h> -# include <netgraph/netgraph.h> -# include <dev/cp/ng_cp.h> -#else -# include <net/if_sppp.h> -# include <net/if_types.h> -#include <dev/pci/pcivar.h> -# define PP_CISCO IFF_LINK2 -# include <net/bpf.h> -#endif +#include <netgraph/ng_message.h> +#include <netgraph/netgraph.h> +#include <dev/cp/ng_cp.h> #include <dev/cp/machdep.h> #include <dev/cp/cpddk.h> -#include <machine/cserial.h> +#include <dev/cp/cserial.h> #include <machine/resource.h> -/* If we don't have Cronyx's sppp version, we don't have fr support via sppp */ -#ifndef PP_FR -#define PP_FR 0 -#endif - #define CP_DEBUG(d,s) ({if (d->chan->debug) {\ printf ("%s: ", d->name); printf s;}}) #define CP_DEBUG2(d,s) ({if (d->chan->debug>1) {\ @@ -110,17 +92,12 @@ typedef struct _drv_t { cp_chan_t *chan; cp_board_t *board; cp_dma_mem_t dmamem; -#ifdef NETGRAPH - char nodename [NG_NODESIZE]; + char nodename [NG_NODESIZ]; hook_p hook; hook_p debug_hook; node_p node; struct ifqueue queue; struct ifqueue hi_queue; -#else - struct ifqueue queue; - struct ifnet *ifp; -#endif short timeout; struct callout timeout_handle; struct cdev *devt; @@ -152,15 +129,7 @@ static void cp_start (drv_t *d); static void cp_down (drv_t *d); static void cp_watchdog (drv_t *d); static void cp_watchdog_timer (void *arg); -#ifdef NETGRAPH -extern struct ng_type typestruct; -#else -static void cp_ifstart (struct ifnet *ifp); -static void cp_tlf (struct sppp *sp); -static void cp_tls (struct sppp *sp); -static int cp_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data); -static void cp_initialize (void *softc); -#endif +static struct ng_type typestruct; static cp_board_t *adapter [NBRD]; static drv_t *channel [NBRD*NCHAN]; @@ -274,9 +243,6 @@ static void cp_intr (void *arg) { bdrv_t *bd = arg; cp_board_t *b = bd->board; -#ifndef NETGRAPH - int i; -#endif int s = splimp (); if (cp_destroy) { splx (s); @@ -300,21 +266,6 @@ static void cp_intr (void *arg) CP_UNLOCK (bd); splx (s); -#ifndef NETGRAPH - /* Pass packets in a lock-free state */ - for (i = 0; i < NCHAN && b->chan[i].type; i++) { - drv_t *d = b->chan[i].sys; - struct mbuf *m; - if (!d || !d->running) - continue; - while (_IF_QLEN(&d->queue)) { - IF_DEQUEUE (&d->queue,m); - if (!m) - continue; - sppp_input (d->ifp, m); - } - } -#endif } static void @@ -474,7 +425,6 @@ static int cp_attach (device_t dev) d->chan = c; c->sys = d; callout_init (&d->timeout_handle, 1); -#ifdef NETGRAPH if (ng_make_node_common (&typestruct, &d->node) != 0) { printf ("%s: cannot make common node\n", d->name); d->node = NULL; @@ -492,29 +442,6 @@ static int cp_attach (device_t dev) d->hi_queue.ifq_maxlen = ifqmaxlen; mtx_init (&d->queue.ifq_mtx, "cp_queue", NULL, MTX_DEF); mtx_init (&d->hi_queue.ifq_mtx, "cp_queue_hi", NULL, MTX_DEF); -#else /*NETGRAPH*/ - d->ifp = if_alloc(IFT_PPP); - if (d->ifp == NULL) { - printf ("%s: cannot if_alloc() interface\n", d->name); - continue; - } - d->ifp->if_softc = d; - if_initname (d->ifp, "cp", b->num * NCHAN + c->num); - d->ifp->if_mtu = PP_MTU; - d->ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST; - d->ifp->if_ioctl = cp_sioctl; - d->ifp->if_start = cp_ifstart; - d->ifp->if_init = cp_initialize; - d->queue.ifq_maxlen = NRBUF; - mtx_init (&d->queue.ifq_mtx, "cp_queue", NULL, MTX_DEF); - sppp_attach (d->ifp); - if_attach (d->ifp); - IFP2SP(d->ifp)->pp_tlf = cp_tlf; - IFP2SP(d->ifp)->pp_tls = cp_tls; - /* If BPF is in the kernel, call the attach for it. - * The header size of PPP or Cisco/HDLC is 4 bytes. */ - bpfattach (d->ifp, DLT_PPP, 4); -#endif /*NETGRAPH*/ cp_start_e1 (c); cp_start_chan (c, 1, 1, d->dmamem.virt, d->dmamem.phys); @@ -586,19 +513,6 @@ static int cp_detach (device_t dev) if (! d || ! d->chan->type) continue; callout_stop (&d->timeout_handle); -#ifndef NETGRAPH - /* Detach from the packet filter list of interfaces. */ - bpfdetach (d->ifp); - - /* Detach from the sync PPP list. */ - sppp_detach (d->ifp); - - /* Detach from the system list of interfaces. */ - if_detach (d->ifp); - if_free (d->ifp); - IF_DRAIN (&d->queue); - mtx_destroy (&d->queue.ifq_mtx); -#else if (d->node) { ng_rmnode_self (d->node); NG_NODE_UNREF (d->node); @@ -606,7 +520,6 @@ static int cp_detach (device_t dev) } mtx_destroy (&d->queue.ifq_mtx); mtx_destroy (&d->hi_queue.ifq_mtx); -#endif destroy_dev (d->devt); } @@ -639,96 +552,6 @@ static int cp_detach (device_t dev) return 0; } -#ifndef NETGRAPH -static void cp_ifstart (struct ifnet *ifp) -{ - drv_t *d = ifp->if_softc; - bdrv_t *bd = d->board->sys; - - CP_LOCK (bd); - cp_start (d); - CP_UNLOCK (bd); -} - -static void cp_tlf (struct sppp *sp) -{ - drv_t *d = SP2IFP(sp)->if_softc; - - CP_DEBUG2 (d, ("cp_tlf\n")); - /* XXXRIK: Don't forget to protect them by LOCK, or kill them. */ -/* cp_set_dtr (d->chan, 0);*/ -/* cp_set_rts (d->chan, 0);*/ - if (!(sp->pp_flags & PP_FR) && !(d->ifp->if_flags & PP_CISCO)) - sp->pp_down (sp); -} - -static void cp_tls (struct sppp *sp) -{ - drv_t *d = SP2IFP(sp)->if_softc; - - CP_DEBUG2 (d, ("cp_tls\n")); - if (!(sp->pp_flags & PP_FR) && !(d->ifp->if_flags & PP_CISCO)) - sp->pp_up (sp); -} - -/* - * Process an ioctl request. - */ -static int cp_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data) -{ - drv_t *d = ifp->if_softc; - bdrv_t *bd = d->board->sys; - int error, s, was_up, should_be_up; - - was_up = (ifp->if_drv_flags & IFF_DRV_RUNNING) != 0; - error = sppp_ioctl (ifp, cmd, data); - - if (error) - return error; - - if (! (ifp->if_flags & IFF_DEBUG)) - d->chan->debug = 0; - else - d->chan->debug = d->chan->debug_shadow; - - switch (cmd) { - default: CP_DEBUG2 (d, ("ioctl 0x%lx\n", cmd)); return 0; - case SIOCADDMULTI: CP_DEBUG2 (d, ("ioctl SIOCADDMULTI\n")); return 0; - case SIOCDELMULTI: CP_DEBUG2 (d, ("ioctl SIOCDELMULTI\n")); return 0; - case SIOCSIFFLAGS: CP_DEBUG2 (d, ("ioctl SIOCSIFFLAGS\n")); break; - case SIOCSIFADDR: CP_DEBUG2 (d, ("ioctl SIOCSIFADDR\n")); break; - } - - /* We get here only in case of SIFFLAGS or SIFADDR. */ - s = splimp (); - CP_LOCK (bd); - should_be_up = (ifp->if_drv_flags & IFF_DRV_RUNNING) != 0; - if (! was_up && should_be_up) { - /* Interface goes up -- start it. */ - cp_up (d); - cp_start (d); - } else if (was_up && ! should_be_up) { - /* Interface is going down -- stop it. */ -/* if ((IFP2SP(ifp)->pp_flags & PP_FR) || (ifp->if_flags & PP_CISCO))*/ - cp_down (d); - } - CP_DEBUG (d, ("ioctl 0x%lx p4\n", cmd)); - CP_UNLOCK (bd); - splx (s); - return 0; -} - -/* - * Initialization of interface. - * It seems to be never called by upper level? - */ -static void cp_initialize (void *softc) -{ - drv_t *d = softc; - - CP_DEBUG (d, ("cp_initialize\n")); -} -#endif /*NETGRAPH*/ /* * Stop the interface. Called on splimp(). @@ -778,18 +601,11 @@ static void cp_send (drv_t *d) while (cp_transmit_space (d->chan)) { /* Get the packet to send. */ -#ifdef NETGRAPH IF_DEQUEUE (&d->hi_queue, m); if (! m) IF_DEQUEUE (&d->queue, m); -#else - m = sppp_dequeue (d->ifp); -#endif if (! m) return; -#ifndef NETGRAPH - BPF_MTAP (d->ifp, m); -#endif len = m_length (m, NULL); if (len >= BUFSZ) printf ("%s: too long packet: %d bytes: ", @@ -805,9 +621,6 @@ static void cp_send (drv_t *d) /* Set up transmit timeout, if the transmit ring is not empty.*/ d->timeout = 10; } -#ifndef NETGRAPH - d->ifp->if_drv_flags |= IFF_DRV_OACTIVE; -#endif } /* @@ -864,10 +677,6 @@ static void cp_transmit (cp_chan_t *c, void *attachment, int len) drv_t *d = c->sys; d->timeout = 0; -#ifndef NETGRAPH - if_inc_counter(d->ifp, IFCOUNTER_OPACKETS, 1); - d->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; -#endif cp_start (d); } @@ -875,9 +684,7 @@ static void cp_receive (cp_chan_t *c, unsigned char *data, int len) { drv_t *d = c->sys; struct mbuf *m; -#ifdef NETGRAPH int error; -#endif if (! d->running) return; @@ -885,24 +692,12 @@ static void cp_receive (cp_chan_t *c, unsigned char *data, int len) m = makembuf (data, len); if (! m) { CP_DEBUG (d, ("no memory for packet\n")); -#ifndef NETGRAPH - if_inc_counter(d->ifp, IFCOUNTER_IQDROPS, 1); -#endif return; } if (c->debug > 1) m_print (m, 0); -#ifdef NETGRAPH m->m_pkthdr.rcvif = 0; NG_SEND_DATA_ONLY (error, d->hook, m); -#else - if_inc_counter(d->ifp, IFCOUNTER_IPACKETS, 1); - m->m_pkthdr.rcvif = d->ifp; - /* Check if there's a BPF listener on this interface. - * If so, hand off the raw packet to bpf. */ - BPF_MTAP(d->ifp, m); - IF_ENQUEUE (&d->queue, m); -#endif } static void cp_error (cp_chan_t *c, int data) @@ -912,36 +707,19 @@ static void cp_error (cp_chan_t *c, int data) switch (data) { case CP_FRAME: CP_DEBUG (d, ("frame error\n")); -#ifndef NETGRAPH - if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); -#endif break; case CP_CRC: CP_DEBUG (d, ("crc error\n")); -#ifndef NETGRAPH - if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); -#endif break; case CP_OVERRUN: CP_DEBUG (d, ("overrun error\n")); -#ifndef NETGRAPH - if_inc_counter(d->ifp, IFCOUNTER_COLLISIONS, 1); - if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); -#endif break; case CP_OVERFLOW: CP_DEBUG (d, ("overflow error\n")); -#ifndef NETGRAPH - if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); -#endif break; case CP_UNDERRUN: CP_DEBUG (d, ("underrun error\n")); d->timeout = 0; -#ifndef NETGRAPH - if_inc_counter(d->ifp, IFCOUNTER_OERRORS, 1); - d->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; -#endif cp_start (d); break; default: @@ -1016,65 +794,6 @@ static int cp_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc bcopy (mask, data, sizeof (mask)); return 0; -#ifndef NETGRAPH - case SERIAL_GETPROTO: - CP_DEBUG2 (d, ("ioctl: getproto\n")); - strcpy ((char*)data, (IFP2SP(d->ifp)->pp_flags & PP_FR) ? "fr" : - (d->ifp->if_flags & PP_CISCO) ? "cisco" : "ppp"); - return 0; - - case SERIAL_SETPROTO: - CP_DEBUG2 (d, ("ioctl: setproto\n")); - /* Only for superuser! */ - error = priv_check (td, PRIV_DRIVER); - if (error) - return error; - if (d->ifp->if_drv_flags & IFF_DRV_RUNNING) - return EBUSY; - if (! strcmp ("cisco", (char*)data)) { - IFP2SP(d->ifp)->pp_flags &= ~(PP_FR); - IFP2SP(d->ifp)->pp_flags |= PP_KEEPALIVE; - d->ifp->if_flags |= PP_CISCO; -#if PP_FR != 0 - } else if (! strcmp ("fr", (char*)data)) { - d->ifp->if_flags &= ~(PP_CISCO); - IFP2SP(d->ifp)->pp_flags |= PP_FR | PP_KEEPALIVE; -#endif - } else if (! strcmp ("ppp", (char*)data)) { - IFP2SP(d->ifp)->pp_flags &= ~PP_FR; - IFP2SP(d->ifp)->pp_flags &= ~PP_KEEPALIVE; - d->ifp->if_flags &= ~(PP_CISCO); - } else - return EINVAL; - return 0; - - case SERIAL_GETKEEPALIVE: - CP_DEBUG2 (d, ("ioctl: getkeepalive\n")); - if ((IFP2SP(d->ifp)->pp_flags & PP_FR) || - (d->ifp->if_flags & PP_CISCO)) - return EINVAL; - *(int*)data = (IFP2SP(d->ifp)->pp_flags & PP_KEEPALIVE) ? 1 : 0; - return 0; - - case SERIAL_SETKEEPALIVE: - CP_DEBUG2 (d, ("ioctl: setkeepalive\n")); - /* Only for superuser! */ - error = priv_check (td, PRIV_DRIVER); - if (error) - return error; - if ((IFP2SP(d->ifp)->pp_flags & PP_FR) || - (d->ifp->if_flags & PP_CISCO)) - return EINVAL; - s = splimp (); - CP_LOCK (bd); - if (*(int*)data) - IFP2SP(d->ifp)->pp_flags |= PP_KEEPALIVE; - else - IFP2SP(d->ifp)->pp_flags &= ~PP_KEEPALIVE; - CP_UNLOCK (bd); - splx (s); - return 0; -#endif /*NETGRAPH*/ case SERIAL_GETMODE: CP_DEBUG2 (d, ("ioctl: getmode\n")); @@ -1308,18 +1027,7 @@ static int cp_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc error = priv_check (td, PRIV_DRIVER); if (error) return error; -#ifndef NETGRAPH - /* - * The debug_shadow is always greater than zero for logic - * simplicity. For switching debug off the IFF_DEBUG is - * responsible. - */ - d->chan->debug_shadow = (*(int*)data) ? (*(int*)data) : 1; - if (d->ifp->if_flags & IFF_DEBUG) - d->chan->debug = d->chan->debug_shadow; -#else d->chan->debug = *(int*)data; -#endif return 0; case SERIAL_GETHIGAIN: @@ -1783,7 +1491,6 @@ static int cp_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc return ENOTTY; } -#ifdef NETGRAPH static int ng_cp_constructor (node_p node) { drv_t *d = NG_NODE_PRIVATE (node); @@ -2209,7 +1916,6 @@ static int ng_cp_disconnect (hook_p hook) } return 0; } -#endif static int cp_modevent (module_t mod, int type, void *unused) { @@ -2217,10 +1923,8 @@ static int cp_modevent (module_t mod, int type, void *unused) switch (type) { case MOD_LOAD: -#ifdef NETGRAPH if (ng_newtype (&typestruct)) printf ("Failed to register ng_cp\n"); -#endif ++load_count; callout_init (&timeout_handle, 1); callout_reset (&timeout_handle, hz*5, cp_timeout, 0); @@ -2228,9 +1932,7 @@ static int cp_modevent (module_t mod, int type, void *unused) case MOD_UNLOAD: if (load_count == 1) { printf ("Removing device entry for Tau-PCI\n"); -#ifdef NETGRAPH ng_rmtype (&typestruct); -#endif } /* If we were wait it than it reasserted now, just stop it. * Actually we shouldn't get this condition. But code could be @@ -2246,7 +1948,6 @@ static int cp_modevent (module_t mod, int type, void *unused) return 0; } -#ifdef NETGRAPH static struct ng_type typestruct = { .version = NG_ABI_VERSION, .name = NG_CP_NODE_TYPE, @@ -2258,12 +1959,7 @@ static struct ng_type typestruct = { .rcvdata = ng_cp_rcvdata, .disconnect = ng_cp_disconnect, }; -#endif /*NETGRAPH*/ -#ifdef NETGRAPH MODULE_DEPEND (ng_cp, netgraph, NG_ABI_VERSION, NG_ABI_VERSION, NG_ABI_VERSION); -#else -MODULE_DEPEND (cp, sppp, 1, 1, 1); -#endif DRIVER_MODULE (cp, pci, cp_driver, cp_devclass, cp_modevent, NULL); MODULE_VERSION (cp, 1); diff --git a/sys/dev/cp/ng_cp.h b/sys/dev/cp/ng_cp.h index f35d81760499..f14461d4d683 100644 --- a/sys/dev/cp/ng_cp.h +++ b/sys/dev/cp/ng_cp.h @@ -16,8 +16,6 @@ * $FreeBSD$ */ -#ifdef NETGRAPH - #ifndef _CP_NETGRAPH_H_ #define _CP_NETGRAPH_H_ @@ -27,5 +25,3 @@ #define NG_CP_HOOK_DEBUG "debug" #endif /* _CP_NETGRAPH_H_ */ - -#endif /* NETGRAPH */ |
