* add p cc
[mascara-docs.git] / i386 / linux / linux-2.3.21 / drivers / net / wan / sbni.h
blob2e34d8d3451d8a3fdb1912d9a6d50c8e947b6d23
1 /*
2 * sbni.h - header file for sbni linux device driver
4 * Copyright (C) 1999 Granch ltd., Yaroslav Polyakov (xenon@granch.ru).
6 */
8 /*
9 * SBNI12 definitions
11 * Revision 2.0.0 1997/08/27
12 * Initial revision
14 * Revision 2.1.0 1999/04/26
15 * dev_priv structure changed to support balancing and some other features.
19 #ifndef __SBNI_H
20 #define __SBNI_H
22 #define SBNI_DEBUG 0
24 #if SBNI_DEBUG
25 #define DP( A ) A
26 #else
27 #define DP( A )
28 #endif
30 typedef unsigned char BOOLEAN;
32 #define TRUE 1
33 #define FALSE 0
35 #define SBNI_IO_EXTENT 0x4
36 #define SB_MAX_BUFFER_ARRAY 1023
38 #define CSR0 0
39 #define CSR1 1
41 #define DAT 2
43 /* CSR0 mapping */
44 #define BU_EMP (1 << 1) /* r z */
45 #define RC_CHK (1 << 2) /* rw */
46 #define CT_ZER (1 << 3) /* w */
47 #define TR_REQ (1 << 4) /* rwz* */
49 #define TR_RDY (1 << 5) /* r z */
50 #define EN_INT (1 << 6) /* rwz* */
51 #define RC_RDY (1 << 7) /* r z */
53 /* CSR1 mapping */
54 #define PR_RES (1 << 7) /* w */
56 struct sbni_csr1 {
57 unsigned rxl:5;
58 unsigned rate:2;
59 unsigned:1;
62 #define DEF_RXL_DELTA -1
63 #define DEF_RXL 0xf
64 #define DEF_RATE 0
65 #define DEF_FRAME_LEN (1023 - 14 - 9)
67 #ifdef MODULE
69 #define SBNI_MAX_NUM_CARDS 8
70 #define SBNI_MAX_SLAVES 8
73 #endif /* MODULE */
75 #define SBNI_SIG 0x5a
77 #define SB_ETHER_MIN_LEN 60
79 #define SB_FILLING_CHAR (unsigned char)0x00
80 #define TR_ERROR_COUNT 32
81 #define CHANGE_LEVEL_START_TICKS 4
82 #define SBNI_INTERNAL_QUEUE_SIZE 10 /* 100 ? */
84 #define PACKET_FIRST_FRAME (unsigned short)0x8000
85 #define RECEIVE_FRAME_RESEND (unsigned short)0x0800
86 #define PACKET_RESEND 0x4000
87 #define PACKET_SEND_OK 0x3000
88 #define PACKET_LEN_MASK (unsigned short)0x03ff
89 #define PACKET_INF_MASK (unsigned short)0x7000
91 #define ETHER_ADDR_LEN 6
93 #define SBNI_TIMEOUT HZ/10 /* ticks to wait for pong or packet */
94 /* sbni watchdog called SBNI_HZ times per sec. */
96 struct sbni_in_stats {
97 unsigned int all_rx_number;
98 unsigned int bad_rx_number;
99 unsigned int timeout_number;
100 unsigned int all_tx_number;
101 unsigned int resend_tx_number;
106 * Board-specific info in dev->priv.
108 struct net_local {
109 struct enet_statistics stats;
111 struct timer_list watchdog;
112 unsigned int realframelen; /* the current size of the SB-frame */
113 unsigned int eth_trans_buffer_len; /* tx buffer length */
114 unsigned int outpos;
115 unsigned int inppos;
116 unsigned int frame_len; /* The set SB-frame size */
117 unsigned int tr_err;
118 unsigned int timer_ticks;
119 BOOLEAN last_receive_OK;
120 BOOLEAN tr_resend;
122 unsigned char wait_frame_number;
123 unsigned char eth_trans_buffer[1520]; /* tx buffer */
124 unsigned char HSCounter; /* Reserved field */
125 unsigned char eth_rcv_buffer[2600]; /* rx buffer */
126 struct sbni_csr1 csr1;
127 /* Internal Statistics */
128 struct sbni_in_stats in_stats;
130 int rxl_curr; /* current receive level value [0..0xf] */
131 int rxl_delta; /* receive level delta (+1, -1)
132 rxl_delta == 0 - receive level
133 autodetection
134 disabled */
135 unsigned int ok_curr; /* current ok frames received */
136 unsigned int ok_prev; /* previous ok frames received */
137 unsigned int timeout_rxl;
139 struct sk_buff_head queue;
140 struct sk_buff *currframe;
141 BOOLEAN waitack;
143 struct net_device *m; /* master */
144 struct net_device *me; /* me */
145 struct net_local *next_lp; /* next lp */
147 int carrier;
153 struct sbni_hard_header {
155 /* internal sbni stuff */
156 unsigned int crc; /* 4 */
157 unsigned short packetlen; /* 2 */
158 unsigned char number; /* 1 */
159 unsigned char reserv; /* 1 */
161 /* 8 */
163 /* ethernet stuff */
164 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
165 unsigned char h_source[ETH_ALEN]; /* source ether addr */
166 unsigned short h_proto; /* packet type ID field */
167 /* +14 */
168 /* 22 */
172 #define SBNI_HH_SZ 22
174 struct sbni_flags {
175 unsigned rxl:4;
176 unsigned rate:2;
177 unsigned fixed_rxl:1;
178 unsigned fixed_rate:1;
181 #define RCV_NO 0
182 #define RCV_OK 1
183 #define RCV_WR 2
186 #define SIOCDEVGETINSTATS SIOCDEVPRIVATE
187 #define SIOCDEVRESINSTATS SIOCDEVPRIVATE+1
188 #define SIOCDEVGHWSTATE SIOCDEVPRIVATE+2
189 #define SIOCDEVSHWSTATE SIOCDEVPRIVATE+3
190 #define SIOCDEVENSLAVE SIOCDEVPRIVATE+4
191 #define SIOCDEVEMANSIPATE SIOCDEVPRIVATE+5
194 #endif /* __SBNI_H */