Subversion Repositories shark

Rev

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