Make all network interrupt service routines MPSAFE part 1/3.
[dragonfly.git] / sys / dev / netif / sbni / if_sbnireg.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
9  *    notice unmodified, this list of conditions, and the following
10  *    disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
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  * $FreeBSD: src/sys/dev/sbni/if_sbnireg.h,v 1.1.2.1 2001/12/19 20:59:28 fjoe Exp $
28  * $DragonFly: src/sys/dev/netif/sbni/if_sbnireg.h,v 1.2 2003/06/17 04:28:29 dillon Exp $
29  */
30
31 /*
32  * We don't have registered vendor id yet...
33  */
34 #define SBNI_PCI_VENDOR         0x55 
35 #define SBNI_PCI_DEVICE         0x9f
36
37 #define ISA_MODE 0x00
38 #define PCI_MODE 0x01
39
40 #define SBNI_PORTS      4
41
42 enum sbni_reg {
43         CSR0 = 0,
44         CSR1 = 1,
45         DAT  = 2
46 };
47
48 /* CSR0 mapping */
49 enum {
50         BU_EMP = 0x02,
51         RC_CHK = 0x04,
52         CT_ZER = 0x08,
53         TR_REQ = 0x10,
54         TR_RDY = 0x20,
55         EN_INT = 0x40,
56         RC_RDY = 0x80
57 };
58
59
60 /* CSR1 mapping */
61 #define PR_RES 0x80
62
63 struct sbni_csr1 {
64         unsigned rxl    : 5;
65         unsigned rate   : 2;
66         unsigned        : 1;
67 };
68
69
70
71 #define FRAME_ACK_MASK  (u_int16_t)0x7000
72 #define FRAME_LEN_MASK  (u_int16_t)0x03FF
73 #define FRAME_FIRST     (u_int16_t)0x8000
74 #define FRAME_RETRY     (u_int16_t)0x0800
75
76 #define FRAME_SENT_BAD  (u_int16_t)0x4000
77 #define FRAME_SENT_OK   (u_int16_t)0x3000
78
79
80 enum {
81         FL_WAIT_ACK    = 1,
82         FL_NEED_RESEND = 2,
83         FL_PREV_OK     = 4,
84         FL_SLOW_MODE   = 8
85 };
86
87
88 enum {
89         DEFAULT_IOBASEADDR = 0x210,
90         DEFAULT_INTERRUPTNUMBER = 5,
91         DEFAULT_RATE = 0,
92         DEFAULT_FRAME_LEN = 1012
93 };
94
95 #define DEF_RXL_DELTA   -1
96 #define DEF_RXL         0xf
97
98 #define SBNI_SIG 0x5a
99
100 #define SBNI_MIN_LEN    (ETHER_MIN_LEN - 4)
101 #define SBNI_MAX_FRAME  1023
102
103 #define SBNI_HZ 18 /* ticks to wait for pong or packet */
104                 /* sbni watchdog called SBNI_HZ times per sec. */
105
106 #define TR_ERROR_COUNT 32
107 #define CHANGE_LEVEL_START_TICKS 4