Subversion Repositories shark

Rev

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