Subversion Repositories shark

Rev

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