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