2 ** *************************************************************************
8 ** RedCreek InterFace include file.
10 ** ---------------------------------------------------------------------
11 ** --- Copyright (c) 1998-1999, RedCreek Communications Inc. ---
12 ** --- All rights reserved. ---
13 ** ---------------------------------------------------------------------
17 ** Header file private ioctl commands.
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.
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.
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 ** *************************************************************************
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 */
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
))
51 typedef struct { /* a single TCB */
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 ** +-----------------------+ _/
65 U32 bcount
; /* buffer count */
66 singleB b
; /* buffer */
68 } __attribute__ ((packed
))
69 singleTCB
, *psingleTCB
;
72 When adding new entries, please add all 5 related changes, since
73 it helps keep everything consistent:
74 1) User structure entry
76 3) Structure short-cut entry
77 4) Data short-cut entry
78 5) Command identifier entry
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
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.
100 typedef struct RC_user_tag RCuser_struct
;
102 /* 1) User structure entry */
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
;
114 } RCgetinfo
; /* <---- RCgetinfo */
116 /* GETSPEED structure */
117 struct RCgetspeed_tag
{
119 } RCgetspeed
; /* <---- RCgetspeed */
121 /* SETSPEED structure */
122 struct RCsetspeed_tag
{
124 } RCsetspeed
; /* <---- RCsetspeed */
126 /* GETPROM structure */
127 struct RCgetprom_tag
{
129 } RCgetprom
; /* <---- RCgetprom */
131 /* SETPROM structure */
132 struct RCsetprom_tag
{
134 } RCsetprom
; /* <---- RCsetprom */
136 /* GETBROADCAST structure */
137 struct RCgetbroadcast_tag
{
139 } RCgetbroadcast
; /* <---- RCgetbroadcast */
141 /* SETBROADCAST structure */
142 struct RCsetbroadcast_tag
{
144 } RCsetbroadcast
; /* <---- RCsetbroadcast */
146 /* GETFIRMWAREVER structure */
147 #define FirmStringLen 80
148 struct RCgetfwver_tag
{
149 U8 FirmString
[FirmStringLen
];
150 } RCgetfwver
; /* <---- RCgetfwver */
152 /* GETIPANDMASK structure */
153 struct RCgetipnmask_tag
{
156 } RCgetipandmask
; /* <---- RCgetipandmask */
158 /* SETIPANDMASK structure */
159 struct RCsetipnmask_tag
{
162 } RCsetipandmask
; /* <---- RCsetipandmask */
164 /* GETMAC structure */
166 struct RCgetmac_tag
{
168 } RCgetmac
; /* <---- RCgetmac */
170 /* SETMAC structure */
171 struct RCsetmac_tag
{
173 } RCsetmac
; /* <---- RCsetmac */
175 /* GETLINKSTATUS structure */
176 struct RCgetlnkstatus_tag
{
178 } RCgetlnkstatus
; /* <---- RCgetlnkstatus */
180 /* GETLINKSTATISTICS structure */
181 struct RCgetlinkstats_tag
{
182 RCLINKSTATS StatsReturn
;
183 } RCgetlinkstats
; /* <---- RCgetlinkstats */
185 /* DEFAULT structure (when no command was recognized) */
186 struct RCdefault_tag
{
188 } RCdefault
; /* <---- RCdefault */
192 }; /* struct RC_user_tag { ... } */
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 */
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;
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
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
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
273 Intended use for the above defines is shown below (GETINFO, as this example):
275 RCuser_struct RCuser; // declare RCuser structure
276 struct ifreq ifr; // declare an interface request structure
278 RCuser.cmd = RCUC_GETINFO; // set user command to GETINFO
279 ifr->ifr_data = (caddr_t) &RCuser; // set point to user structure
281 sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW); // get a socket
282 ioctl(sock, RCU_COMMAND, &ifr); // do ioctl on socket
284 RCUD_GETINFO = &RCuser.RCUS_GETINFO; // set data pointer for GETINFO
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);