Subversion Repositories shark

Rev

Rev 3 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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