OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [before_ORP/] [uclinux/] [uClinux-2.0.x/] [drivers/] [net/] [rcif.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
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
{
46
     U32 context;               /* context */
47
     U32 scount;                /* segment count */
48
     U32 size;                  /* segment size */
49
     U32 addr;                  /* segment physical address */
50
}
51
__attribute__((packed))
52
singleB, *psingleB ;
53
typedef struct                  /* a single TCB */
54
{
55
     /*
56
     **  +-----------------------+
57
     **  |         1             |  one buffer in the TCB
58
     **  +-----------------------+
59
     **  |  <user's Context>     |  user's buffer reference
60
     **  +-----------------------+
61
     **  |         1             |  one segment buffer
62
     **  +-----------------------+                            _
63
     **  |    <buffer size>      |  size                       \
64
     **  +-----------------------+                              \ segment descriptor
65
     **  |  <physical address>   |  physical address of buffer  /
66
     **  +-----------------------+                            _/
67
     */
68
     U32 bcount;                /* buffer count */
69
     singleB b;                 /* buffer */
70
 
71
}
72
__attribute__((packed))
73
singleTCB, *psingleTCB;
74
 
75
/*
76
   When adding new entries, please add all 5 related changes, since
77
   it helps keep everything consistent:
78
      1) User structure entry
79
      2) User data entry
80
      3) Structure short-cut entry
81
      4) Data short-cut entry
82
      5) Command identifier entry
83
 
84
   For Example ("GETSPEED"):
85
      1) struct  RCgetspeed_tag { U32 LinkSpeedCode; } RCgetspeed;
86
      2) struct  RCgetspeed_tag *getspeed;
87
      3) #define RCUS_GETSPEED  data.RCgetspeed;
88
      4) #define RCUD_GETSPEED  _RC_user_data.getspeed
89
      5) #define RCUC_GETSPEED  0x02
90
 
91
   Notes for the "GETSPEED" entry, above:
92
      1) RCgetspeed      - RC{name}
93
         RCgetspeed_tag  - RC{name}_tag
94
         LinkSpeedCode   - create any structure format desired (not too large,
95
                           since memory will be unioned with all other entries)
96
      2) RCgetspeed_tag  - RC{name}_tag chosen in #1
97
         getspeed        - arbitrary name (ptr to structure in #1)
98
      3) RCUS_GETSPEED   - RCUS_{NAME}   ("NAME" & "name" do not have to the same)
99
         data.RCgetspeed - data.RC{name}  ("RC{name}" from #1)
100
      4) RCUD_GETSPEED   - _RC_user_data.getspeed  ("getspeed" from #2)
101
      5) RCUC_GETSPEED   - unique hex identifier entry.
102
*/
103
 
104
typedef struct RC_user_tag RCuser_struct;
105
 
106
/* 1) User structure entry */
107
struct RC_user_tag
108
{
109
    int cmd;
110
    union
111
    {
112
        /* GETINFO structure */
113
        struct RCgetinfo_tag {
114
            unsigned long int mem_start;
115
            unsigned long int mem_end;
116
            unsigned long int base_addr;
117
            unsigned char irq;
118
            unsigned char dma;
119
            unsigned char port;
120
        } RCgetinfo;                    /* <---- RCgetinfo */
121
 
122
        /* GETSPEED structure */
123
        struct  RCgetspeed_tag {
124
            U32 LinkSpeedCode;
125
        } RCgetspeed;                   /* <---- RCgetspeed */
126
 
127
        /* SETSPEED structure */
128
        struct RCsetspeed_tag {
129
            U16 LinkSpeedCode;
130
        } RCsetspeed;                   /* <---- RCsetspeed */
131
 
132
        /* GETPROM structure */
133
        struct  RCgetprom_tag {
134
            U32 PromMode;
135
        } RCgetprom;                   /* <---- RCgetprom */
136
 
137
        /* SETPROM structure */
138
        struct RCsetprom_tag {
139
            U16 PromMode;
140
        } RCsetprom;                   /* <---- RCsetprom */
141
 
142
        /* GETBROADCAST structure */
143
        struct  RCgetbroadcast_tag {
144
            U32 BroadcastMode;
145
        } RCgetbroadcast;                   /* <---- RCgetbroadcast */
146
 
147
        /* SETBROADCAST structure */
148
        struct RCsetbroadcast_tag {
149
            U16 BroadcastMode;
150
        } RCsetbroadcast;                   /* <---- RCsetbroadcast */
151
 
152
        /* GETFIRMWAREVER structure */
153
        #define FirmStringLen 80
154
        struct RCgetfwver_tag {
155
            U8 FirmString[FirmStringLen];
156
        } RCgetfwver;                   /* <---- RCgetfwver */
157
 
158
        /* GETIPANDMASK structure */
159
        struct RCgetipnmask_tag {
160
            U32 IpAddr;
161
            U32 NetMask;
162
        } RCgetipandmask;               /* <---- RCgetipandmask */
163
 
164
        /* SETIPANDMASK structure */
165
        struct RCsetipnmask_tag {
166
            U32 IpAddr;
167
            U32 NetMask;
168
        } RCsetipandmask;               /* <---- RCsetipandmask */
169
 
170
        /* GETMAC structure */
171
        #define MAC_SIZE 10
172
        struct RCgetmac_tag {
173
            U8 mac[MAC_SIZE];
174
        } RCgetmac;                     /* <---- RCgetmac */
175
 
176
        /* SETMAC structure */
177
        struct RCsetmac_tag {
178
            U8 mac[MAC_SIZE];
179
        } RCsetmac;                     /* <---- RCsetmac */
180
 
181
        /* GETLINKSTATUS structure */
182
        struct RCgetlnkstatus_tag {
183
            U32 ReturnStatus;
184
        } RCgetlnkstatus;               /* <---- RCgetlnkstatus */
185
 
186
        /* GETLINKSTATISTICS structure */
187
        struct RCgetlinkstats_tag {
188
            RCLINKSTATS StatsReturn;
189
        } RCgetlinkstats;               /* <---- RCgetlinkstats */
190
 
191
        /* DEFAULT structure (when no command was recognized) */
192
        struct RCdefault_tag {
193
            int rc;
194
        } RCdefault;                    /* <---- RCdefault */
195
 
196
    } data;
197
 
198
};   /* struct RC_user_tag { ... } */
199
 
200
/* 2) User data entry */
201
/* RCUD = RedCreek User Data */
202
union RC_user_data_tag {        /* structure tags used are taken from RC_user_tag structure above */
203
    struct RCgetinfo_tag      *getinfo;
204
    struct RCgetspeed_tag     *getspeed;
205
    struct RCgetprom_tag *getprom;
206
    struct RCgetbroadcast_tag   *getbroadcast;
207
    struct RCgetfwver_tag     *getfwver;
208
    struct RCgetipnmask_tag   *getipandmask;
209
    struct RCgetmac_tag       *getmac;
210
    struct RCgetlnkstatus_tag *getlinkstatus;
211
    struct RCgetlinkstats_tag *getlinkstatistics;
212
    struct RCdefault_tag      *rcdefault;
213
    struct RCsetspeed_tag     *setspeed;
214
    struct RCsetprom_tag     *setprom;
215
    struct RCsetbroadcast_tag     *setbroadcast;
216
    struct RCsetipnmask_tag   *setipandmask;
217
    struct RCsetmac_tag       *setmac;
218
} _RC_user_data;  /* declare as a global, so the defines below will work */
219
 
220
/* 3) Structure short-cut entry */
221
/* define structure short-cuts */   /* structure names are taken from RC_user_tag structure above */
222
#define RCUS_GETINFO           data.RCgetinfo;
223
#define RCUS_GETSPEED          data.RCgetspeed;
224
#define RCUS_GETPROM           data.RCgetprom;
225
#define RCUS_GETBROADCAST      data.RCgetbroadcast;
226
#define RCUS_GETFWVER          data.RCgetfwver;
227
#define RCUS_GETIPANDMASK      data.RCgetipandmask;
228
#define RCUS_GETMAC            data.RCgetmac;
229
#define RCUS_GETLINKSTATUS     data.RCgetlnkstatus;
230
#define RCUS_GETLINKSTATISTICS data.RCgetlinkstats;
231
#define RCUS_DEFAULT           data.RCdefault;
232
#define RCUS_SETSPEED          data.RCsetspeed;
233
#define RCUS_SETPROM           data.RCsetprom;
234
#define RCUS_SETBROADCAST      data.RCsetbroadcast;
235
#define RCUS_SETIPANDMASK      data.RCsetipandmask;
236
#define RCUS_SETMAC            data.RCsetmac;
237
 
238
/* 4) Data short-cut entry */
239
/* define data short-cuts */    /* pointer names are from RC_user_data_tag union (just below RC_user_tag) */
240
#define RCUD_GETINFO           _RC_user_data.getinfo
241
#define RCUD_GETSPEED          _RC_user_data.getspeed
242
#define RCUD_GETPROM           _RC_user_data.getprom
243
#define RCUD_GETBROADCAST      _RC_user_data.getbroadcast
244
#define RCUD_GETFWVER          _RC_user_data.getfwver
245
#define RCUD_GETIPANDMASK      _RC_user_data.getipandmask
246
#define RCUD_GETMAC            _RC_user_data.getmac
247
#define RCUD_GETLINKSTATUS     _RC_user_data.getlinkstatus
248
#define RCUD_GETLINKSTATISTICS _RC_user_data.getlinkstatistics
249
#define RCUD_DEFAULT           _RC_user_data.rcdefault
250
#define RCUD_SETSPEED          _RC_user_data.setspeed
251
#define RCUD_SETPROM           _RC_user_data.setprom
252
#define RCUD_SETBROADCAST      _RC_user_data.setbroadcast
253
#define RCUD_SETIPANDMASK      _RC_user_data.setipandmask
254
#define RCUD_SETMAC            _RC_user_data.setmac
255
 
256
/* 5) Command identifier entry */
257
/* define command identifiers */
258
#define RCUC_GETINFO            0x01
259
#define RCUC_GETSPEED           0x02
260
#define RCUC_GETFWVER           0x03
261
#define RCUC_GETIPANDMASK       0x04
262
#define RCUC_GETMAC             0x05
263
#define RCUC_GETLINKSTATUS      0x06
264
#define RCUC_GETLINKSTATISTICS  0x07
265
#define RCUC_GETPROM            0x14
266
#define RCUC_GETBROADCAST       0x15
267
#define RCUC_DEFAULT            0xff
268
#define RCUC_SETSPEED           0x08
269
#define RCUC_SETIPANDMASK       0x09
270
#define RCUC_SETMAC             0x0a
271
#define RCUC_SETPROM            0x16
272
#define RCUC_SETBROADCAST       0x17
273
 
274
/* define ioctl commands to use, when talking to RC 45/PCI driver */
275
#define RCU_PROTOCOL_REV         SIOCDEVPRIVATE
276
#define RCU_COMMAND              SIOCDEVPRIVATE+1
277
 
278
/*
279
   Intended use for the above defines is shown below (GETINFO, as this example):
280
 
281
      RCuser_struct RCuser;           // declare RCuser structure
282
      struct ifreq ifr;               // declare an interface request structure
283
 
284
      RCuser.cmd = RCUC_GETINFO;           // set user command to GETINFO
285
      ifr->ifr_data = (caddr_t) &RCuser;   // set point to user structure
286
 
287
      sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);   // get a socket
288
      ioctl(sock, RCU_COMMAND, &ifr);                  // do ioctl on socket
289
 
290
      RCUD_GETINFO = &RCuser.RCUS_GETINFO;   // set data pointer for GETINFO
291
 
292
      // print results
293
      printf("memory 0x%lx-0x%lx, base address 0x%x, irq 0x%x\n",
294
              RCUD_GETINFO->mem_start, RCUD_GETINFO->mem_end,
295
              RCUD_GETINFO->base_addr, RCUD_GETINFO->irq);
296
*/
297
 
298
#endif   /* RCIF_H */
299
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.