Subversion Repositories shark

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
629 giacomo 1
#ifndef __NETDEVICE__
2
#define __NETDEVICE__
3
 
4
#include <linux/config.h>
5
#include <linux/compatib.h>
6
 
7
#include <linux/if.h>
8
 
9
#include <linux/skbuff.h>
10
#include <linux/notifier.h>
11
#include <time.h>
12
#include "ll/sys/cdefs.h"
13
 
14
__BEGIN_DECLS
15
 
16
// for 3c59x.c (!!!)
17
#define le32_to_cpu(val) (val)
18
#define cpu_to_le32(val) (val)
19
#define cpu_to_le16(val) (val)
20
#define test_and_set_bit(val, addr) set_bit(val, addr)
21
 
22
static __inline__ void mdelay(int x)
23
{
24
  struct timespec delay;
25
  delay.tv_sec=x/1000;
26
  delay.tv_nsec=(x%1000)*1000000;
27
  nanosleep(&delay, NULL);
28
}
29
 
30
#define kfree(x) free(x)
31
#define ioremap(a,b) \
32
        (((a)<0x100000) ? (void *)((u_long)(a)) : 0)
33
// was vremap(a,b)) instead of 0)) PJ
34
 
35
#define iounmap(v) 
36
//PJ was #define iounmap do { if ((u_long)(v) > 0x100000) vfree(v); } while (0)
37
 
38
/* for future expansion when we will have different priorities. */
39
#define DEV_NUMBUFFS    3
40
#define MAX_ADDR_LEN    7
41
#ifndef CONFIG_AX25
42
#ifndef CONFIG_TR
43
#ifndef CONFIG_NET_IPIP
44
#define MAX_HEADER      32              /* We really need about 18 worst case .. so 32 is aligned */
45
#else
46
#define MAX_HEADER      80              /* We need to allow for having tunnel headers */
47
#endif  /* IPIP */
48
#else
49
#define MAX_HEADER      48              /* Token Ring header needs 40 bytes ... 48 is aligned */ 
50
#endif /* TR */
51
#else
52
#define MAX_HEADER      96              /* AX.25 + NetROM */
53
#endif /* AX25 */
54
 
55
#define IS_MYADDR       1               /* address is (one of) our own  */
56
#define IS_LOOPBACK     2               /* address is for LOOPBACK      */
57
#define IS_BROADCAST    3               /* address is a valid broadcast */
58
#define IS_INVBCAST     4               /* Wrong netmask bcast not for us (unused)*/
59
#define IS_MULTICAST    5               /* Multicast IP address */
60
 
61
 
62
 
63
struct dev_mc_list
64
{      
65
        struct dev_mc_list      *next;
66
        __u8                    dmi_addr[MAX_ADDR_LEN];
67
        unsigned char           dmi_addrlen;
68
        int                     dmi_users;
69
        int                     dmi_gusers;
70
};
71
 
72
 
73
 
74
/*
75
 *      Network device statistics. Akin to the 2.0 ether stats but
76
 *      with byte counters.
77
 */
78
 
79
struct net_device_stats
80
{
81
        unsigned long   rx_packets;             /* total packets received       */
82
        unsigned long   tx_packets;             /* total packets transmitted    */
83
        unsigned long   rx_bytes;               /* total bytes received         */
84
        unsigned long   tx_bytes;               /* total bytes transmitted      */
85
        unsigned long   rx_errors;              /* bad packets received         */
86
        unsigned long   tx_errors;              /* packet transmit problems     */
87
        unsigned long   rx_dropped;             /* no space in linux buffers    */
88
        unsigned long   tx_dropped;             /* no space available in linux  */
89
        unsigned long   multicast;              /* multicast packets received   */
90
        unsigned long   collisions;
91
 
92
        /* detailed rx_errors: */
93
        unsigned long   rx_length_errors;
94
        unsigned long   rx_over_errors;         /* receiver ring buff overflow  */
95
        unsigned long   rx_crc_errors;          /* recved pkt with crc error    */
96
        unsigned long   rx_frame_errors;        /* recv'd frame alignment error */
97
        unsigned long   rx_fifo_errors;         /* recv'r fifo overrun          */
98
        unsigned long   rx_missed_errors;       /* receiver missed packet       */
99
 
100
        /* detailed tx_errors */
101
        unsigned long   tx_aborted_errors;
102
        unsigned long   tx_carrier_errors;
103
        unsigned long   tx_fifo_errors;
104
        unsigned long   tx_heartbeat_errors;
105
        unsigned long   tx_window_errors;
106
 
107
        /* for cslip etc */
108
        unsigned long   rx_compressed;
109
        unsigned long   tx_compressed;
110
};
111
 
112
 
113
struct hh_cache
114
{
115
        struct hh_cache *hh_next;
116
        void            *hh_arp;        /* Opaque pointer, used by
117
                                         * any address resolution module,
118
                                         * not only ARP.
119
                                         */
120
        int             hh_refcnt;      /* number of users */
121
        unsigned short  hh_type;        /* protocol identifier, f.e ETH_P_IP */
122
        char            hh_uptodate;    /* hh_data is valid */
123
        char            hh_data[16];    /* cached hardware header */
124
};
125
 
126
/*
127
 * The DEVICE structure.
128
 * Actually, this whole structure is a big mistake.  It mixes I/O
129
 * data with strictly "high-level" data, and it has to know about
130
 * almost every data structure used in the INET module.  
131
 */
132
struct device
133
{
134
 
135
  /*
136
   * This is the first field of the "visible" part of this structure
137
   * (i.e. as seen by users in the "Space.c" file).  It is the name
138
   * the interface.
139
   */
140
  char                    *name;
141
 
142
  /* I/O specific fields - FIXME: Merge these and struct ifmap into one */
143
  unsigned long           rmem_end;             /* shmem "recv" end     */
144
  unsigned long           rmem_start;           /* shmem "recv" start   */
145
  unsigned long           mem_end;              /* shared mem end       */
146
  unsigned long           mem_start;            /* shared mem start     */
147
  unsigned long           base_addr;            /* device I/O address   */
148
  unsigned char           irq;                  /* device IRQ number    */
149
 
150
  /* Low-level status flags. */
151
  volatile unsigned char  start,                /* start an operation   */
152
                          interrupt;            /* interrupt arrived    */
153
  unsigned long           tbusy;                /* transmitter busy must be long for bitops */
154
 
155
  struct device           *next;
156
 
157
  /* The device initialization function. Called only once. */
158
  int                     (*init)(struct device *dev);
159
 
160
  /* Some hardware also needs these fields, but they are not part of the
161
     usual set specified in Space.c. */
162
  unsigned char           if_port;              /* Selectable AUI, TP,..*/
163
  unsigned char           dma;                  /* DMA channel          */
164
 
165
  struct enet_statistics* (*get_stats)(struct device *dev);
166
 
167
  /*
168
   * This marks the end of the "visible" part of the structure. All
169
   * fields hereafter are internal to the system, and may change at
170
   * will (read: may be cleaned up at will).
171
   */
172
 
173
  /* These may be needed for future network-power-down code. */
174
  unsigned long           trans_start;  /* Time (in jiffies) of last Tx */
175
  unsigned long           last_rx;      /* Time of last Rx              */
176
 
177
  unsigned short          flags;        /* interface flags (a la BSD)   */
178
  unsigned short          family;       /* address family ID (AF_INET)  */
179
  unsigned short          metric;       /* routing metric (not used)    */
180
  unsigned short          mtu;          /* interface MTU value          */
181
  unsigned short          type;         /* interface hardware type      */
182
  unsigned short          hard_header_len;      /* hardware hdr length  */
183
  void                    *priv;        /* pointer to private data      */
184
 
185
  /* Interface address info. */
186
  unsigned char           broadcast[MAX_ADDR_LEN];      /* hw bcast add */
187
  unsigned char           pad;                          /* make dev_addr aligned to 8 bytes */
188
  unsigned char           dev_addr[MAX_ADDR_LEN];       /* hw address   */
189
  unsigned char           addr_len;     /* hardware address length      */
190
  unsigned long           pa_addr;      /* protocol address             */
191
  unsigned long           pa_brdaddr;   /* protocol broadcast addr      */
192
  unsigned long           pa_dstaddr;   /* protocol P-P other side addr */
193
  unsigned long           pa_mask;      /* protocol netmask             */
194
  unsigned short          pa_alen;      /* protocol address length      */
195
 
196
  struct dev_mc_list     *mc_list;      /* Multicast mac addresses      */
197
  int                    mc_count;      /* Number of installed mcasts   */
198
 
199
  struct ip_mc_list      *ip_mc_list;   /* IP multicast filter chain    */
200
  __u32                 tx_queue_len;   /* Max frames per queue allowed */
201
 
202
  /* For load balancing driver pair support */
203
 
204
  unsigned long            pkt_queue;   /* Packets queued */
205
  struct device           *slave;       /* Slave device */
206
  struct net_alias_info         *alias_info;    /* main dev alias info */
207
  struct net_alias              *my_alias;      /* alias devs */
208
 
209
  /* Pointer to the interface buffers. */
210
  struct sk_buff_head     buffs[DEV_NUMBUFFS];
211
 
212
  /* Pointers to interface service routines. */
213
  int                     (*open)(struct device *dev);
214
  int                     (*stop)(struct device *dev);
215
  int                     (*hard_start_xmit) (struct sk_buff *skb,
216
                                              struct device *dev);
217
  int                     (*hard_header) (struct sk_buff *skb,
218
                                          struct device *dev,
219
                                          unsigned short type,
220
                                          void *daddr,
221
                                          void *saddr,
222
                                          unsigned len);
223
  int                     (*rebuild_header)(void *eth, struct device *dev,
224
                                unsigned long raddr, struct sk_buff *skb);
225
 
226
 
227
 
228
#define HAVE_PRIVATE_IOCTL
229
  int                     (*do_ioctl)(struct device *dev, struct ifreq *ifr, int cmd);
230
#define HAVE_SET_CONFIG
231
  int                     (*set_config)(struct device *dev, struct ifmap *map);
232
#define HAVE_CHANGE_MTU
233
  int                     (*change_mtu)(struct device *dev, int new_mtu);            
234
#define HAVE_SET_MAC_ADDR                
235
  int                     (*set_mac_address)(struct device *dev, void *addr);
236
 
237
#define HAVE_HEADER_CACHE
238
  void                    (*header_cache_bind)(struct hh_cache **hhp, struct device *dev, unsigned short htype, __u32 daddr);
239
  void                    (*header_cache_update)(struct hh_cache *hh, struct device *dev, unsigned char *  haddr);
240
 
241
#define HAVE_MULTICAST                   
242
  void                    (*set_multicast_list)(struct device *dev);
243
};
244
 
245
extern struct device    loopback_dev;
246
extern struct device    *dev_base;
247
extern struct packet_type *ptype_base[16];
248
 
249
 
250
extern void             ether_setup(struct device *dev);
251
extern void             tr_setup(struct device *dev);
252
extern void             fddi_setup(struct device *dev);
253
extern int              ether_config(struct device *dev, struct ifmap *map);
254
/* Support for loadable net-drivers */
255
extern int              register_netdev(struct device *dev);
256
extern void             unregister_netdev(struct device *dev);
257
extern int              register_netdevice_notifier(struct notifier_block *nb);
258
extern int              unregister_netdevice_notifier(struct notifier_block *nb);
259
 
260
/*
261
unsigned short htons(unsigned short host);
262
unsigned short ntohs(unsigned short net);
263
*/
264
 
265
void netif_rx(struct sk_buff *skb);
266
 
267
__END_DECLS
268
#endif
269
 
270