if_sbnivar.h revision 139749
1139749Simp/*-
286752Sfjoe * Copyright (c) 1997-2001 Granch, Ltd. All rights reserved.
386752Sfjoe * Author: Denis I.Timofeev <timofeev@granch.ru>
486752Sfjoe *
586752Sfjoe * Redistributon and use in source and binary forms, with or without
686752Sfjoe * modification, are permitted provided that the following conditions
786752Sfjoe * are met:
886752Sfjoe * 1. Redistributions of source code must retain the above copyright
986752Sfjoe *    notice unmodified, this list of conditions, and the following
1086752Sfjoe *    disclaimer.
1186752Sfjoe * 2. Redistributions in binary form must reproduce the above copyright
1286752Sfjoe *    notice, this list of conditions and the following disclaimer in the
1386752Sfjoe *    documentation and/or other materials provided with the distribution.
1486752Sfjoe *
1586752Sfjoe * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1686752Sfjoe * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1786752Sfjoe * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1886752Sfjoe * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1986752Sfjoe * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2086752Sfjoe * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2186752Sfjoe * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2286752Sfjoe * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2386752Sfjoe * LIABILITY, OR TORT (INCLUDING NEIGENCE OR OTHERWISE) ARISING IN ANY WAY
2486752Sfjoe * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2586752Sfjoe * SUCH DAMAGE.
2686752Sfjoe *
2786752Sfjoe * $FreeBSD: head/sys/dev/sbni/if_sbnivar.h 139749 2005-01-06 01:43:34Z imp $
2886752Sfjoe */
2986752Sfjoe
3086752Sfjoe/*
3186752Sfjoe * SBNI12 definitions
3286752Sfjoe */
3386752Sfjoe
3486752Sfjoe/*
3586752Sfjoe * CONFIGURATION PARAMETER:
3686752Sfjoe *
3786752Sfjoe *	Uncomment this if you want to use model SBNI12D-11/ISA with same IRQ
3886752Sfjoe *	for both first and second channels.
3986752Sfjoe */
4086752Sfjoe#define SBNI_DUAL_COMPOUND 1
4186752Sfjoe
4286752Sfjoe#define SBNI_DEBUG 0
4386752Sfjoe
4486752Sfjoe#if SBNI_DEBUG
4586752Sfjoe#define DP(A) A
4686752Sfjoe#else
4786752Sfjoe#define DP(A)
4886752Sfjoe#endif
4986752Sfjoe
5086752Sfjoestruct sbni_in_stats {
5186752Sfjoe	u_int32_t	all_rx_number;
5286752Sfjoe	u_int32_t	bad_rx_number;
5386752Sfjoe	u_int32_t	timeout_number;
5486752Sfjoe	u_int32_t	all_tx_number;
5586752Sfjoe	u_int32_t	resend_tx_number;
5686752Sfjoe};
5786752Sfjoe
5886752Sfjoestruct sbni_flags {
5986752Sfjoe	u_int	mac_addr	: 24;
6086752Sfjoe	u_int	rxl		: 4;
6186752Sfjoe	u_int	rate		: 2;
6286752Sfjoe	u_int	fixed_rxl	: 1;
6386752Sfjoe	u_int	fixed_rate	: 1;
6486752Sfjoe};
6586752Sfjoe
6686752Sfjoe
6786752Sfjoe#ifdef _KERNEL	/* to avoid compile this decls with sbniconfig */
6886752Sfjoe
6986752Sfjoestruct sbni_softc {
7086752Sfjoe	struct	arpcom arpcom;		/* ethernet common */
7186752Sfjoe
7286752Sfjoe	int	io_rid;
73101400Sfjoe	struct	resource *io_res;
74101400Sfjoe	int	io_off;
75101400Sfjoe
7686752Sfjoe	int	irq_rid;
7786752Sfjoe	struct	resource *irq_res;
7886752Sfjoe	void	*irq_handle;
7986752Sfjoe
8086752Sfjoe	struct	mbuf *rx_buf_p;		/* receive buffer ptr */
8186752Sfjoe	struct	mbuf *tx_buf_p;		/* transmit buffer ptr */
8286752Sfjoe
8386752Sfjoe	u_int	pktlen;			/* length of transmitting pkt */
8486752Sfjoe	u_int	framelen;		/* current frame length */
8586752Sfjoe	u_int	maxframe;		/* maximum valid frame length */
8686752Sfjoe	u_int	state;
8786752Sfjoe	u_int	inppos;			/* positions in rx/tx buffers */
8886752Sfjoe	u_int	outpos;			/* positions in rx/tx buffers */
8986752Sfjoe
9086752Sfjoe	/* transmitting frame number - from frames qty to 1 */
9186752Sfjoe	u_int	tx_frameno;
9286752Sfjoe
9386752Sfjoe	/* expected number of next receiving frame */
9486752Sfjoe	u_int	wait_frameno;
9586752Sfjoe
9686752Sfjoe	/* count of failed attempts to frame send - 32 attempts do before
9786752Sfjoe	   error - while receiver tunes on opposite side of wire */
9886752Sfjoe	u_int	trans_errors;
9986752Sfjoe
10086752Sfjoe	/* idle time; send pong when limit exceeded */
10186752Sfjoe	u_int	timer_ticks;
10286752Sfjoe
10386752Sfjoe	/* fields used for receive level autoselection */
10486752Sfjoe	int	delta_rxl;
10586752Sfjoe	u_int	cur_rxl_index;
10686752Sfjoe	u_int	timeout_rxl;
10786752Sfjoe	u_int32_t	cur_rxl_rcvd;
10886752Sfjoe	u_int32_t	prev_rxl_rcvd;
10986752Sfjoe
11086752Sfjoe	struct	sbni_csr1 csr1;			/* current value of CSR1 */
11186752Sfjoe	struct	sbni_in_stats in_stats; 	/* internal statistics */
11286752Sfjoe
11386752Sfjoe	struct	callout_handle wch;
11486752Sfjoe
11586752Sfjoe	struct	sbni_softc *slave_sc;
11686752Sfjoe
11786752Sfjoe#ifdef SBNI_DUAL_COMPOUND
11886752Sfjoe	struct	sbni_softc *link;
11986752Sfjoe#endif
12086752Sfjoe};
12186752Sfjoe
12286752Sfjoevoid	sbni_intr(void *);
12386752Sfjoeint	sbni_probe(struct sbni_softc *);
12486752Sfjoevoid	sbni_attach(struct sbni_softc *, int, struct sbni_flags);
12586752Sfjoe
12686752Sfjoeextern u_int32_t next_sbni_unit;
12786752Sfjoe
12886752Sfjoe#ifdef SBNI_DUAL_COMPOUND
12989092Smsmithextern struct sbni_softc *sbni_headlist;
13086752Sfjoe
13186752Sfjoestruct sbni_softc	*connect_to_master(struct sbni_softc *);
13286752Sfjoe#endif
13386752Sfjoe#endif	/* _KERNEL */
13486752Sfjoe
13586752Sfjoe/*
13686752Sfjoe * SBNI socket ioctl params
13786752Sfjoe */
13886752Sfjoe#define	SIOCGHWFLAGS	_IOWR('i', 62, struct ifreq)	/* get flags */
13986752Sfjoe#define	SIOCSHWFLAGS	_IOWR('i', 61, struct ifreq)	/* set flags */
14086752Sfjoe#define SIOCGINSTATS	_IOWR('i', 60, struct ifreq)	/* get internal stats */
14186752Sfjoe#define SIOCRINSTATS	_IOWR('i', 63, struct ifreq)	/* reset internal stats */
14286752Sfjoe
14386752Sfjoe
14486752Sfjoe/*
14586752Sfjoe * CRC-32 stuff
14686752Sfjoe */
14786752Sfjoe#define CRC32(c,crc) (crc32tab[((size_t)(crc) ^ (c)) & 0xff] ^ (((crc) >> 8) & 0x00ffffff))
14886752Sfjoe      /* CRC generator EDB88320 */
14986752Sfjoe      /* CRC remainder 2144DF1C */
15086752Sfjoe      /* CRC initial value 0 */
15186752Sfjoe#define CRC32_REMAINDER 0x2144df1c
15286752Sfjoe#define CRC32_INITIAL 0x00000000
153