This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / drivers / net / rcif.h
1 /*
2 ** *************************************************************************
3 **
4 **
5 **     R C I F . H
6 **
7 **
8 **  RedCreek InterFace include file.
9 **
10 **  ---------------------------------------------------------------------
11 **  ---     Copyright (c) 1998-1999, RedCreek Communications Inc.     ---
12 **  ---                   All rights reserved.                        ---
13 **  ---------------------------------------------------------------------
14 **
15 ** File Description:
16 **
17 ** Header file private ioctl commands.
18 **
19 **
20 **  This program is free software; you can redistribute it and/or modify
21 **  it under the terms of the GNU General Public License as published by
22 **  the Free Software Foundation; either version 2 of the License, or
23 **  (at your option) any later version.
24
25 **  This program is distributed in the hope that it will be useful,
26 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
27 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28 **  GNU General Public License for more details.
29
30 **  You should have received a copy of the GNU General Public License
31 **  along with this program; if not, write to the Free Software
32 **  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33 ** *************************************************************************
34 */
35
36 #ifndef RCIF_H
37 #define RCIF_H
38
39 /* The following protocol revision # should be incremented every time
40    a new protocol or new structures are used in this file. */
41 int USER_PROTOCOL_REV = 2;      /* used to track different protocol revisions */
42
43 /* define a single TCB & buffer */
44 typedef struct {                /* a single buffer */
45         U32 context;            /* context */
46         U32 scount;             /* segment count */
47         U32 size;               /* segment size */
48         U32 addr;               /* segment physical address */
49 } __attribute__ ((packed))
50     singleB, *psingleB;
51 typedef struct {                /* a single TCB */
52         /*
53            **  +-----------------------+
54            **  |         1             |  one buffer in the TCB
55            **  +-----------------------+
56            **  |  <user's Context>     |  user's buffer reference
57            **  +-----------------------+
58            **  |         1             |  one segment buffer
59            **  +-----------------------+                            _
60            **  |    <buffer size>      |  size                       \ 
61            **  +-----------------------+                              \ segment descriptor
62            **  |  <physical address>   |  physical address of buffer  /
63            **  +-----------------------+                            _/
64          */
65         U32 bcount;             /* buffer count */
66         singleB b;              /* buffer */
67
68 } __attribute__ ((packed))
69     singleTCB, *psingleTCB;
70
71 /*
72    When adding new entries, please add all 5 related changes, since 
73    it helps keep everything consistent:
74       1) User structure entry
75       2) User data entry
76       3) Structure short-cut entry
77       4) Data short-cut entry
78       5) Command identifier entry
79
80    For Example ("GETSPEED"):
81       1) struct  RCgetspeed_tag { U32 LinkSpeedCode; } RCgetspeed;
82       2) struct  RCgetspeed_tag *getspeed;
83       3) #define RCUS_GETSPEED  data.RCgetspeed;
84       4) #define RCUD_GETSPEED  _RC_user_data.getspeed
85       5) #define RCUC_GETSPEED  0x02
86   
87    Notes for the "GETSPEED" entry, above:
88       1) RCgetspeed      - RC{name}
89          RCgetspeed_tag  - RC{name}_tag
90          LinkSpeedCode   - create any structure format desired (not too large,
91                            since memory will be unioned with all other entries)
92       2) RCgetspeed_tag  - RC{name}_tag chosen in #1
93          getspeed        - arbitrary name (ptr to structure in #1)
94       3) RCUS_GETSPEED   - RCUS_{NAME}   ("NAME" & "name" do not have to the same)
95          data.RCgetspeed - data.RC{name}  ("RC{name}" from #1)
96       4) RCUD_GETSPEED   - _RC_user_data.getspeed  ("getspeed" from #2)
97       5) RCUC_GETSPEED   - unique hex identifier entry.
98 */
99
100 typedef struct RC_user_tag RCuser_struct;
101
102 /* 1) User structure entry */
103 struct RC_user_tag {
104         int cmd;
105         union {
106                 /* GETINFO structure */
107                 struct RCgetinfo_tag {
108                         unsigned long int mem_start;
109                         unsigned long int mem_end;
110                         unsigned long int base_addr;
111                         unsigned char irq;
112                         unsigned char dma;
113                         unsigned char port;
114                 } RCgetinfo;    /* <---- RCgetinfo */
115
116                 /* GETSPEED structure */
117                 struct RCgetspeed_tag {
118                         U32 LinkSpeedCode;
119                 } RCgetspeed;   /* <---- RCgetspeed */
120
121                 /* SETSPEED structure */
122                 struct RCsetspeed_tag {
123                         U16 LinkSpeedCode;
124                 } RCsetspeed;   /* <---- RCsetspeed */
125
126                 /* GETPROM structure */
127                 struct RCgetprom_tag {
128                         U32 PromMode;
129                 } RCgetprom;    /* <---- RCgetprom */
130
131                 /* SETPROM structure */
132                 struct RCsetprom_tag {
133                         U16 PromMode;
134                 } RCsetprom;    /* <---- RCsetprom */
135
136                 /* GETBROADCAST structure */
137                 struct RCgetbroadcast_tag {
138                         U32 BroadcastMode;
139                 } RCgetbroadcast;       /* <---- RCgetbroadcast */
140
141                 /* SETBROADCAST structure */
142                 struct RCsetbroadcast_tag {
143                         U16 BroadcastMode;
144                 } RCsetbroadcast;       /* <---- RCsetbroadcast */
145
146                 /* GETFIRMWAREVER structure */
147 #define FirmStringLen 80
148                 struct RCgetfwver_tag {
149                         U8 FirmString[FirmStringLen];
150                 } RCgetfwver;   /* <---- RCgetfwver */
151
152                 /* GETIPANDMASK structure */
153                 struct RCgetipnmask_tag {
154                         U32 IpAddr;
155                         U32 NetMask;
156                 } RCgetipandmask;       /* <---- RCgetipandmask */
157
158                 /* SETIPANDMASK structure */
159                 struct RCsetipnmask_tag {
160                         U32 IpAddr;
161                         U32 NetMask;
162                 } RCsetipandmask;       /* <---- RCsetipandmask */
163
164                 /* GETMAC structure */
165 #define MAC_SIZE 10
166                 struct RCgetmac_tag {
167                         U8 mac[MAC_SIZE];
168                 } RCgetmac;     /* <---- RCgetmac */
169
170                 /* SETMAC structure */
171                 struct RCsetmac_tag {
172                         U8 mac[MAC_SIZE];
173                 } RCsetmac;     /* <---- RCsetmac */
174
175                 /* GETLINKSTATUS structure */
176                 struct RCgetlnkstatus_tag {
177                         U32 ReturnStatus;
178                 } RCgetlnkstatus;       /* <---- RCgetlnkstatus */
179
180                 /* GETLINKSTATISTICS structure */
181                 struct RCgetlinkstats_tag {
182                         RCLINKSTATS StatsReturn;
183                 } RCgetlinkstats;       /* <---- RCgetlinkstats */
184
185                 /* DEFAULT structure (when no command was recognized) */
186                 struct RCdefault_tag {
187                         int rc;
188                 } RCdefault;    /* <---- RCdefault */
189
190         } data;
191
192 };                              /* struct RC_user_tag { ... } */
193
194 /* 2) User data entry */
195 /* RCUD = RedCreek User Data */
196 union RC_user_data_tag {        /* structure tags used are taken from RC_user_tag structure above */
197         struct RCgetinfo_tag *getinfo;
198         struct RCgetspeed_tag *getspeed;
199         struct RCgetprom_tag *getprom;
200         struct RCgetbroadcast_tag *getbroadcast;
201         struct RCgetfwver_tag *getfwver;
202         struct RCgetipnmask_tag *getipandmask;
203         struct RCgetmac_tag *getmac;
204         struct RCgetlnkstatus_tag *getlinkstatus;
205         struct RCgetlinkstats_tag *getlinkstatistics;
206         struct RCdefault_tag *rcdefault;
207         struct RCsetspeed_tag *setspeed;
208         struct RCsetprom_tag *setprom;
209         struct RCsetbroadcast_tag *setbroadcast;
210         struct RCsetipnmask_tag *setipandmask;
211         struct RCsetmac_tag *setmac;
212 } _RC_user_data;                /* declare as a global, so the defines below will work */
213
214 /* 3) Structure short-cut entry */
215 /* define structure short-cuts *//* structure names are taken from RC_user_tag structure above */
216 #define RCUS_GETINFO           data.RCgetinfo;
217 #define RCUS_GETSPEED          data.RCgetspeed;
218 #define RCUS_GETPROM           data.RCgetprom;
219 #define RCUS_GETBROADCAST      data.RCgetbroadcast;
220 #define RCUS_GETFWVER          data.RCgetfwver;
221 #define RCUS_GETIPANDMASK      data.RCgetipandmask;
222 #define RCUS_GETMAC            data.RCgetmac;
223 #define RCUS_GETLINKSTATUS     data.RCgetlnkstatus;
224 #define RCUS_GETLINKSTATISTICS data.RCgetlinkstats;
225 #define RCUS_DEFAULT           data.RCdefault;
226 #define RCUS_SETSPEED          data.RCsetspeed;
227 #define RCUS_SETPROM           data.RCsetprom;
228 #define RCUS_SETBROADCAST      data.RCsetbroadcast;
229 #define RCUS_SETIPANDMASK      data.RCsetipandmask;
230 #define RCUS_SETMAC            data.RCsetmac;
231
232 /* 4) Data short-cut entry */
233 /* define data short-cuts *//* pointer names are from RC_user_data_tag union (just below RC_user_tag) */
234 #define RCUD_GETINFO           _RC_user_data.getinfo
235 #define RCUD_GETSPEED          _RC_user_data.getspeed
236 #define RCUD_GETPROM           _RC_user_data.getprom
237 #define RCUD_GETBROADCAST      _RC_user_data.getbroadcast
238 #define RCUD_GETFWVER          _RC_user_data.getfwver
239 #define RCUD_GETIPANDMASK      _RC_user_data.getipandmask
240 #define RCUD_GETMAC            _RC_user_data.getmac
241 #define RCUD_GETLINKSTATUS     _RC_user_data.getlinkstatus
242 #define RCUD_GETLINKSTATISTICS _RC_user_data.getlinkstatistics
243 #define RCUD_DEFAULT           _RC_user_data.rcdefault
244 #define RCUD_SETSPEED          _RC_user_data.setspeed
245 #define RCUD_SETPROM           _RC_user_data.setprom
246 #define RCUD_SETBROADCAST      _RC_user_data.setbroadcast
247 #define RCUD_SETIPANDMASK      _RC_user_data.setipandmask
248 #define RCUD_SETMAC            _RC_user_data.setmac
249
250 /* 5) Command identifier entry */
251 /* define command identifiers */
252 #define RCUC_GETINFO            0x01
253 #define RCUC_GETSPEED           0x02
254 #define RCUC_GETFWVER           0x03
255 #define RCUC_GETIPANDMASK       0x04
256 #define RCUC_GETMAC             0x05
257 #define RCUC_GETLINKSTATUS      0x06
258 #define RCUC_GETLINKSTATISTICS  0x07
259 #define RCUC_GETPROM            0x14
260 #define RCUC_GETBROADCAST       0x15
261 #define RCUC_DEFAULT            0xff
262 #define RCUC_SETSPEED           0x08
263 #define RCUC_SETIPANDMASK       0x09
264 #define RCUC_SETMAC             0x0a
265 #define RCUC_SETPROM            0x16
266 #define RCUC_SETBROADCAST       0x17
267
268 /* define ioctl commands to use, when talking to RC 45/PCI driver */
269 #define RCU_PROTOCOL_REV         SIOCDEVPRIVATE
270 #define RCU_COMMAND              SIOCDEVPRIVATE+1
271
272 /*
273    Intended use for the above defines is shown below (GETINFO, as this example):
274
275       RCuser_struct RCuser;           // declare RCuser structure
276       struct ifreq ifr;               // declare an interface request structure
277
278       RCuser.cmd = RCUC_GETINFO;           // set user command to GETINFO
279       ifr->ifr_data = (caddr_t) &RCuser;   // set point to user structure
280
281       sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);   // get a socket
282       ioctl(sock, RCU_COMMAND, &ifr);                  // do ioctl on socket
283
284       RCUD_GETINFO = &RCuser.RCUS_GETINFO;   // set data pointer for GETINFO
285
286       // print results
287       printf("memory 0x%lx-0x%lx, base address 0x%x, irq 0x%x\n",
288               RCUD_GETINFO->mem_start, RCUD_GETINFO->mem_end,
289               RCUD_GETINFO->base_addr, RCUD_GETINFO->irq);
290 */
291
292 #endif                          /* RCIF_H */