]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/dev/arl/if_arlreg.h
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / dev / arl / if_arlreg.h
1 /*-
2  * Copyright (c) 1999-2001, Ivan Sharov, Vitaly Belekhov.
3  * Copyright (c) 2004 Stanislav Svirid.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following 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 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 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 NEGLIGENCE 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  * $RISS: if_arl/dev/arl/if_arlreg.h,v 1.4 2004/03/16 04:43:27 count Exp $
28  * $FreeBSD$
29  */
30
31 #ifndef _IF_ARLREG_H
32 #define _IF_ARLREG_H
33
34 #define ARL_BASE_START   0xC0000
35 #define ARL_BASE_END     0xDE000
36 #define ARL_BASE_STEP    0x2000
37
38 #define ARLAN_NAME_SIZE 16
39 #define ARLAN_NAME      "ArLan655-SCT"
40
41 /*
42  * Statistics
43  */
44 struct arl_stats {
45         u_int32_t numDatagramsTransmitted;
46         u_int32_t numReTransmissions;
47         u_int32_t numFramesDiscarded;
48         u_int32_t numDatagramsReceived;
49         u_int32_t numDuplicateReceivedFrames;
50         u_int32_t numDatagramsDiscarded;
51         u_int16_t maxNumReTransmitDatagram;
52         u_int16_t maxNumReTransmitFrames;
53         u_int16_t maxNumConsecutiveDuplicateFrames;
54         u_int32_t numBytesTransmitted;
55         u_int32_t numBytesReceived;
56         u_int32_t numCRCErrors;
57         u_int32_t numLengthErrors;
58         u_int32_t numAbortErrors;
59         u_int32_t numTXUnderruns;
60         u_int32_t numRXOverruns;
61         u_int32_t numHoldOffs;
62         u_int32_t numFramesTransmitted;
63         u_int32_t numFramesReceived;
64         u_int32_t numReceiveFramesLost;
65         u_int32_t numRXBufferOverflows;
66         u_int32_t numFramesDiscardedAddrMismatch;
67         u_int32_t numFramesDiscardedSIDMismatch;
68         u_int32_t numPollsTransmistted;
69         u_int32_t numPollAcknowledges;
70         u_int32_t numStatusVectorTimeouts;
71         u_int32_t numNACKReceived;
72 } __attribute__((packed));
73
74 /*
75  * Arlan private structure in memomory
76  */
77 struct arl_private {
78         /* Header Signature */
79         char                    textRegion[48];
80         u_int8_t                resetFlag;
81         u_int8_t                diagnosticInfo;
82         u_int16_t               diagnosticOffset;
83         u_int8_t                _1[12];
84         u_int8_t                lanCardNodeId[6];
85         u_int8_t                broadcastAddress[6];
86         u_int8_t                hardwareType;
87         u_int8_t                majorHardwareVersion;
88         u_int8_t                minorHardwareVersion;
89         u_int8_t                radioModule;
90         u_int8_t                defaultChannelSet;
91         u_int8_t                _2[47];
92
93         /* Control/Status Block - 0x0080 */
94         u_int8_t                interruptInProgress;
95         u_int8_t                cntrlRegImage;
96         u_int8_t                _3[14];
97         u_int8_t                commandByte;
98         u_int8_t                commandParameter[15];
99
100         /* Receive Status - 0x00a0 */
101         u_int8_t                rxStatusVector;
102         u_int8_t                rxFrmType;
103         u_int16_t               rxOffset;
104         u_int16_t               rxLength;
105         u_int8_t                rxSrc[6];
106         u_int8_t                rxBroadcastFlag;
107         u_int8_t                rxQuality;
108         u_int8_t                scrambled;
109         u_int8_t                _4[1];
110
111         /* Transmit Status - 0x00b0 */
112         u_int8_t                txStatusVector;
113         u_int8_t                txAckQuality;
114         u_int8_t                numRetries;
115         u_int8_t                _5[14];
116         u_int8_t                registeredRouter[6];
117         u_int8_t                backboneRouter[6];
118         u_int8_t                registrationStatus;
119         u_int8_t                configuredStatusFlag;
120         u_int8_t                _6[1];
121         u_int8_t                ultimateDestAddress[6];
122         u_int8_t                immedDestAddress[6];
123         u_int8_t                immedSrcAddress[6];
124         u_int16_t               rxSequenceNumber;
125         u_int8_t                assignedLocaltalkAddress;
126         u_int8_t                _7[27];
127
128         /* System Parameter Block */
129
130         /* - Driver Parameters (Novell Specific) */
131
132         u_int16_t               txTimeout;
133         u_int16_t               transportTime;
134         u_int8_t                _8[4];
135
136         /* - Configuration Parameters */
137         u_int8_t                irqLevel;
138         u_int8_t                spreadingCode;
139         u_int8_t                channelSet;
140         u_int8_t                channelNumber;
141         u_int16_t               radioNodeId;
142         u_int8_t                _9[2];
143         u_int8_t                scramblingDisable;
144         u_int8_t                radioType;
145         u_int16_t               routerId;
146         u_int8_t                _10[9];
147         u_int8_t                txAttenuation;
148         u_int8_t                systemId[4]; /* on an odd address for a long !!! */
149         u_int16_t               globalChecksum;
150         u_int8_t                _11[4];
151         u_int16_t               maxDatagramSize;
152         u_int16_t               maxFrameSize;
153         u_int8_t                maxRetries;
154         u_int8_t                receiveMode;
155         u_int8_t                priority;
156         u_int8_t                rootOrRepeater;
157         u_int8_t                specifiedRouter[6];
158         u_int16_t               fastPollPeriod;
159         u_int8_t                pollDecay;
160         u_int8_t                fastPollDelay[2];
161         u_int8_t                arlThreshold;
162         u_int8_t                arlDecay;
163         u_int8_t                _12[1];
164         u_int16_t               specRouterTimeout;
165         u_int8_t                _13[5];
166
167         /* Scrambled Area */
168         u_int8_t                SID[4];
169         u_int8_t                encryptionKey[12];
170         u_int8_t                _14[2];
171         u_int8_t                waitTime[2];
172         u_int8_t                lParameter[2];
173         u_int8_t                _15[3];
174         u_int16_t               headerSize;
175         u_int16_t               sectionChecksum;
176
177         u_int8_t                registrationMode;
178         u_int8_t                registrationFill;
179         u_int16_t               pollPeriod;
180         u_int16_t               refreshPeriod;
181         u_int8_t                name[ARLAN_NAME_SIZE];
182         u_int8_t                NID[6];
183         u_int8_t                localTalkAddress;
184         u_int8_t                codeFormat;
185         u_int8_t                SSCode[64];
186
187         u_int8_t                _16[0x140];
188
189         /* Statistics Block - 0x0300 */
190         u_int8_t                hostcpuLock;
191         u_int8_t                lancpuLock;
192         u_int8_t                resetTime[18];
193
194         struct arl_stats        stat;
195
196         u_int8_t                _17[0x86];
197
198         u_int8_t                txBuffer[0x800];
199         u_int8_t                rxBuffer[0x800];
200
201         u_int8_t                _18[0x0bfd];
202         u_int8_t                resetFlag1;
203         u_int8_t                _19;
204         u_int8_t                controlRegister;
205 };
206
207 /*
208  * Transmit parametrs
209  */
210 struct arl_tx_param {
211         u_int16_t       offset;
212         u_int16_t       length;
213         u_int8_t        dest[6];
214         u_int8_t        clear;
215         u_int8_t        retries;
216         u_int8_t        routing;
217         u_int8_t        scrambled;
218 };
219
220 #define ARL_HARDWARE_RESET              0x01
221 #define ARL_CHANNEL_ATTENTION           0x02
222 #define ARL_INTERRUPT_ENABLE            0x04
223 #define ARL_CLEAR_INTERRUPT             0x08
224
225 /* additions for sys/sockio.h ( socket ioctl parameters for arlan card ) */
226
227 #define SIOCGARLQLT     _IOWR('i', 70, struct ifreq)    /* get QUALITY */
228 #define SIOCGARLALL     _IOWR('i', 71, struct ifreq)    /* get ALL */
229 #define SIOCSARLALL     _IOWR('i', 72, struct ifreq)    /* set paramter (who_set) */
230 #define SIOCGARLSTB     _IOWR('i', 73, struct ifreq)    /* get statistic block */
231
232 /*
233  * Arlan request struct via ioctl
234  */
235 struct arl_cfg_param {
236         u_char          name[ARLAN_NAME_SIZE];
237         u_int8_t        sid[4];
238         u_int8_t        channelSet;
239         u_int8_t        channelNumber;
240         u_int8_t        spreadingCode;
241         u_int8_t        registrationMode;
242         u_int8_t        lanCardNodeId[6];
243         u_int8_t        specifiedRouter[6];
244         u_int8_t        hardwareType;
245         u_int8_t        majorHardwareVersion;
246         u_int8_t        minorHardwareVersion;
247         u_int8_t        radioModule;
248         u_int8_t        priority;
249         u_int8_t        receiveMode;
250         u_int8_t        txRetry;
251 };
252
253 struct arl_req {
254         u_int32_t               what_set;
255         struct arl_cfg_param    cfg;
256 };
257
258 #ifdef ARLCACHE
259 #define MAXARLCACHE     16
260 #define ARLCACHE_RX 0
261 #define ARLCACHE_TX 1
262
263 struct arl_sigcache {
264         u_int8_t        macsrc[6];      /* unique MAC address for entry */
265         u_int8_t        level[2];
266         u_int8_t        quality[2];
267 };
268 #endif
269
270 #define ARLAN_SET_name                  0x0001
271 #define ARLAN_SET_sid                   0x0002
272 #define ARLAN_SET_channelSet            0x0004
273 #define ARLAN_SET_channelNumber         0x0008
274 #define ARLAN_SET_spreadingCode         0x0010
275 #define ARLAN_SET_registrationMode      0x0020
276 #define ARLAN_SET_lanCardNodeId         0x0040
277 #define ARLAN_SET_specifiedRouter       0x0080
278 #define ARLAN_SET_priority              0x0100
279 #define ARLAN_SET_receiveMode           0x0200
280 #define ARLAN_SET_txRetry               0x0400
281
282 #ifdef _KERNEL
283 struct arl_softc {
284         struct ifnet            *arl_ifp;
285
286         int                     arl_unit;
287         struct arl_private *    arl_mem;        /* arlan data */
288
289         struct arl_cfg_param    arl_cfg;        /* arlan vars in our mem */
290         u_char                  arl_control;
291
292         int     mem_rid;                /* resource id for mem */
293         struct resource* mem_res;       /* resource for mem */
294         int     irq_rid;                /* resource id for irq */
295         struct resource* irq_res;       /* resource for irq */
296         void*   irq_handle;             /* handle for irq handler */
297
298         u_char  arl_tx[2048];
299         int     tx_len;
300         u_char  arl_rx[2048];
301         int     rx_len;
302
303 #ifdef ARLCACHE
304         struct arl_sigcache     arl_sigcache[MAXARLCACHE];
305 #endif
306         struct ifmedia          arl_ifmedia;
307 };
308 #endif
309
310 #define ARLAN_SIGN              "TELESYSTEM"
311 #define ARLAN_HEADER_SIZE       0x0C
312
313 #define ar      sc->arl_mem
314 #define arcfg   sc->arl_cfg
315
316 #define ARDELAY         10000
317 #define ARDELAY1        50000
318
319 #define WAIT_RESET(cnt, delay) \
320         do { \
321                 int i; \
322                 for (i = cnt; i && ar->resetFlag; i--) { \
323                         DELAY(delay); \
324                 } \
325         } while (0)
326
327 #ifdef _KERNEL
328 void    arl_release_resources   (device_t);
329 int     arl_alloc_memory        (device_t, int, int);
330 int     arl_alloc_irq           (device_t, int, int);
331 int     arl_attach              (device_t);
332 int     arl_wait_reset          (struct arl_softc *, int, int);
333 void    arl_stop                (struct arl_softc *);
334
335 driver_intr_t   arl_intr;
336 #endif
337
338 #endif /* _IF_ARLREG_H */