2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
6 * Definitions for the Interfaces handler.
8 * Version: @(#)dev.h 1.0.10 08/12/93
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu>
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Corey Minyard <wf-rch!minyard@relay.EU.net>
13 * Donald J. Becker, <becker@cesdis.gsfc.nasa.gov>
14 * Alan Cox, <Alan.Cox@linux.org>
15 * Bjorn Ekwall. <bj0rn@blox.se>
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License
19 * as published by the Free Software Foundation; either version
20 * 2 of the License, or (at your option) any later version.
22 * Moved to /usr/include/linux for NET3
24 #ifndef _LINUX_NETDEVICE_H
25 #define _LINUX_NETDEVICE_H
27 #include <linux/config.h>
29 #include <linux/if_ether.h>
30 #include <linux/if_packet.h>
32 #include <asm/atomic.h>
35 #ifdef CONFIG_NET_PROFILE
36 #include <net/profile.h>
41 * For future expansion when we will have different priorities.
44 #define MAX_ADDR_LEN 7 /* Largest hardware address length */
47 * Compute the worst case header length according to the protocols
51 #if !defined(CONFIG_AX25) && !defined(CONFIG_AX25_MODULE) && !defined(CONFIG_TR)
52 #define LL_MAX_HEADER 32
54 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
55 #define LL_MAX_HEADER 96
57 #define LL_MAX_HEADER 48
61 #if !defined(CONFIG_NET_IPIP) && \
62 !defined(CONFIG_IPV6) && !defined(CONFIG_IPV6_MODULE)
63 #define MAX_HEADER LL_MAX_HEADER
65 #define MAX_HEADER (LL_MAX_HEADER + 48)
69 * Network device statistics. Akin to the 2.0 ether stats but
73 struct net_device_stats
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
;
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 */
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
;
102 unsigned long rx_compressed
;
103 unsigned long tx_compressed
;
106 #ifdef CONFIG_NET_FASTROUTE
107 struct net_fastroute_stats
112 int latency_reduction
;
116 /* Media selection options. */
129 extern const char *if_port_text
[];
131 #include <linux/skbuff.h>
138 * We tag multicasts with these structures.
143 struct dev_mc_list
*next
;
144 __u8 dmi_addr
[MAX_ADDR_LEN
];
145 unsigned char dmi_addrlen
;
152 struct hh_cache
*hh_next
; /* Next entry */
153 atomic_t hh_refcnt
; /* number of users */
154 unsigned short hh_type
; /* protocol identifier, f.e ETH_P_IP */
155 int (*hh_output
)(struct sk_buff
*skb
);
157 /* cached hardware header; allow for machine alignment needs. */
158 unsigned long hh_data
[16/sizeof(unsigned long)];
163 * The DEVICE structure.
164 * Actually, this whole structure is a big mistake. It mixes I/O
165 * data with strictly "high-level" data, and it has to know about
166 * almost every data structure used in the INET module.
168 * FIXME: cleanup struct device such that network protocol info
176 * This is the first field of the "visible" part of this structure
177 * (i.e. as seen by users in the "Space.c" file). It is the name
183 * I/O specific fields
184 * FIXME: Merge these and struct ifmap into one
186 unsigned long rmem_end
; /* shmem "recv" end */
187 unsigned long rmem_start
; /* shmem "recv" start */
188 unsigned long mem_end
; /* shared mem end */
189 unsigned long mem_start
; /* shared mem start */
190 unsigned long base_addr
; /* device I/O address */
191 unsigned int irq
; /* device IRQ number */
193 /* Low-level status flags. */
194 volatile unsigned char start
; /* start an operation */
196 * These two are just single-bit flags, but due to atomicity
197 * reasons they have to be inside a "unsigned long". However,
198 * they should be inside the SAME unsigned long instead of
199 * this wasteful use of memory..
201 unsigned long interrupt
; /* bitops.. */
202 unsigned long tbusy
; /* transmitter busy */
206 /* The device initialization function. Called only once. */
207 int (*init
)(struct device
*dev
);
208 void (*destructor
)(struct device
*dev
);
210 /* Interface index. Unique device identifier */
215 * Some hardware also needs these fields, but they are not
216 * part of the usual set specified in Space.c.
219 unsigned char if_port
; /* Selectable AUI, TP,..*/
220 unsigned char dma
; /* DMA channel */
222 struct net_device_stats
* (*get_stats
)(struct device
*dev
);
223 struct iw_statistics
* (*get_wireless_stats
)(struct device
*dev
);
226 * This marks the end of the "visible" part of the structure. All
227 * fields hereafter are internal to the system, and may change at
228 * will (read: may be cleaned up at will).
231 /* These may be needed for future network-power-down code. */
232 unsigned long trans_start
; /* Time (in jiffies) of last Tx */
233 unsigned long last_rx
; /* Time of last Rx */
235 unsigned short flags
; /* interface flags (a la BSD) */
236 unsigned short gflags
;
237 unsigned mtu
; /* interface MTU value */
238 unsigned short type
; /* interface hardware type */
239 unsigned short hard_header_len
; /* hardware hdr length */
240 void *priv
; /* pointer to private data */
242 /* Interface address info. */
243 unsigned char broadcast
[MAX_ADDR_LEN
]; /* hw bcast add */
244 unsigned char pad
; /* make dev_addr aligned to 8 bytes */
245 unsigned char dev_addr
[MAX_ADDR_LEN
]; /* hw address */
246 unsigned char addr_len
; /* hardware address length */
248 struct dev_mc_list
*mc_list
; /* Multicast mac addresses */
249 int mc_count
; /* Number of installed mcasts */
253 /* For load balancing driver pair support */
255 unsigned long pkt_queue
; /* Packets queued */
256 struct device
*slave
; /* Slave device */
258 /* Protocol specific pointers */
260 void *atalk_ptr
; /* AppleTalk link */
261 void *ip_ptr
; /* IPv4 specific data */
262 void *dn_ptr
; /* DECnet specific data */
265 struct Qdisc
*qdisc_sleeping
;
266 struct Qdisc
*qdisc_list
;
267 unsigned long tx_queue_len
; /* Max frames per queue allowed */
269 /* hard_start_xmit synchronizer */
270 spinlock_t xmit_lock
;
272 /* Pointers to interface service routines. */
273 int (*open
)(struct device
*dev
);
274 int (*stop
)(struct device
*dev
);
275 int (*hard_start_xmit
) (struct sk_buff
*skb
,
277 int (*hard_header
) (struct sk_buff
*skb
,
283 int (*rebuild_header
)(struct sk_buff
*skb
);
284 #define HAVE_MULTICAST
285 void (*set_multicast_list
)(struct device
*dev
);
286 #define HAVE_SET_MAC_ADDR
287 int (*set_mac_address
)(struct device
*dev
,
289 #define HAVE_PRIVATE_IOCTL
290 int (*do_ioctl
)(struct device
*dev
,
291 struct ifreq
*ifr
, int cmd
);
292 #define HAVE_SET_CONFIG
293 int (*set_config
)(struct device
*dev
,
295 #define HAVE_HEADER_CACHE
296 int (*hard_header_cache
)(struct neighbour
*neigh
,
297 struct hh_cache
*hh
);
298 void (*header_cache_update
)(struct hh_cache
*hh
,
300 unsigned char * haddr
);
301 #define HAVE_CHANGE_MTU
302 int (*change_mtu
)(struct device
*dev
, int new_mtu
);
304 int (*hard_header_parse
)(struct sk_buff
*skb
,
305 unsigned char *haddr
);
306 int (*neigh_setup
)(struct device
*dev
, struct neigh_parms
*);
307 int (*accept_fastpath
)(struct device
*, struct dst_entry
*);
309 #ifdef CONFIG_NET_FASTROUTE
310 /* Really, this semaphore may be necessary and for not fastroute code;
314 #define NETDEV_FASTROUTE_HMASK 0xF
315 /* Semi-private data. Keep it at the end of device struct. */
316 struct dst_entry
*fastpath
[NETDEV_FASTROUTE_HMASK
+1];
323 unsigned short type
; /* This is really htons(ether_type). */
324 struct device
*dev
; /* NULL is wildcarded here */
325 int (*func
) (struct sk_buff
*, struct device
*,
326 struct packet_type
*);
327 void *data
; /* Private to the packet type */
328 struct packet_type
*next
;
332 #include <linux/interrupt.h>
333 #include <linux/notifier.h>
335 extern struct device loopback_dev
; /* The loopback */
336 extern struct device
*dev_base
; /* All devices */
337 extern rwlock_t dev_base_lock
; /* Device list lock */
338 extern struct packet_type
*ptype_base
[16]; /* Hashed types */
339 extern int netdev_dropping
;
340 extern int net_cpu_congestion
;
342 extern struct device
*dev_getbyhwaddr(unsigned short type
, char *hwaddr
);
343 extern void dev_add_pack(struct packet_type
*pt
);
344 extern void dev_remove_pack(struct packet_type
*pt
);
345 extern struct device
*dev_get(const char *name
);
346 extern struct device
*dev_alloc(const char *name
, int *err
);
347 extern int dev_alloc_name(struct device
*dev
, const char *name
);
348 extern int dev_open(struct device
*dev
);
349 extern int dev_close(struct device
*dev
);
350 extern int dev_queue_xmit(struct sk_buff
*skb
);
351 extern void dev_loopback_xmit(struct sk_buff
*skb
);
352 extern int register_netdevice(struct device
*dev
);
353 extern int unregister_netdevice(struct device
*dev
);
354 extern int register_netdevice_notifier(struct notifier_block
*nb
);
355 extern int unregister_netdevice_notifier(struct notifier_block
*nb
);
356 extern int dev_new_index(void);
357 extern struct device
*dev_get_by_index(int ifindex
);
358 extern int dev_restart(struct device
*dev
);
360 typedef int gifconf_func_t(struct device
* dev
, char * bufptr
, int len
);
361 extern int register_gifconf(unsigned int family
, gifconf_func_t
* gifconf
);
362 extern __inline__
int unregister_gifconf(unsigned int family
)
364 return register_gifconf(family
, 0);
367 #define HAVE_NETIF_RX 1
368 extern void netif_rx(struct sk_buff
*skb
);
369 extern void net_bh(void);
370 extern int dev_get_info(char *buffer
, char **start
, off_t offset
, int length
, int dummy
);
371 extern int dev_ioctl(unsigned int cmd
, void *);
372 extern int dev_change_flags(struct device
*, unsigned);
373 extern void dev_queue_xmit_nit(struct sk_buff
*skb
, struct device
*dev
);
375 extern void dev_init(void);
377 extern int netdev_nit
;
379 /* Locking protection for page faults during outputs to devices unloaded during the fault */
381 extern atomic_t dev_lockct
;
384 * These two don't currently need to be atomic
385 * but they may do soon. Do it properly anyway.
388 extern __inline__
void dev_lock_list(void)
390 atomic_inc(&dev_lockct
);
393 extern __inline__
void dev_unlock_list(void)
395 atomic_dec(&dev_lockct
);
399 * This almost never occurs, isn't in performance critical paths
400 * and we can thus be relaxed about it.
402 * FIXME: What if this is being run as a real time process ??
403 * Linus: We need a way to force a yield here ?
405 * FIXME: Though dev_lockct is atomic varible, locking procedure
409 extern __inline__
void dev_lock_wait(void)
411 while (atomic_read(&dev_lockct
)) {
412 current
->policy
|= SCHED_YIELD
;
417 extern __inline__
void dev_init_buffers(struct device
*dev
)
422 /* These functions live elsewhere (drivers/net/net_init.c, but related) */
424 extern void ether_setup(struct device
*dev
);
425 extern void fddi_setup(struct device
*dev
);
426 extern void tr_setup(struct device
*dev
);
427 extern void tr_freedev(struct device
*dev
);
428 extern int ether_config(struct device
*dev
, struct ifmap
*map
);
429 /* Support for loadable net-drivers */
430 extern int register_netdev(struct device
*dev
);
431 extern void unregister_netdev(struct device
*dev
);
432 extern int register_trdev(struct device
*dev
);
433 extern void unregister_trdev(struct device
*dev
);
434 /* Functions used for multicast support */
435 extern void dev_mc_upload(struct device
*dev
);
436 extern int dev_mc_delete(struct device
*dev
, void *addr
, int alen
, int all
);
437 extern int dev_mc_add(struct device
*dev
, void *addr
, int alen
, int newonly
);
438 extern void dev_mc_discard(struct device
*dev
);
439 extern void dev_set_promiscuity(struct device
*dev
, int inc
);
440 extern void dev_set_allmulti(struct device
*dev
, int inc
);
441 extern void netdev_state_change(struct device
*dev
);
442 /* Load a device via the kmod */
443 extern void dev_load(const char *name
);
444 extern void dev_mcast_init(void);
445 extern int netdev_register_fc(struct device
*dev
, void (*stimul
)(struct device
*dev
));
446 extern void netdev_unregister_fc(int bit
);
447 extern int netdev_dropping
;
448 extern int netdev_max_backlog
;
449 extern atomic_t netdev_rx_dropped
;
450 extern unsigned long netdev_fc_xoff
;
451 #ifdef CONFIG_NET_FASTROUTE
452 extern int netdev_fastroute
;
453 extern int netdev_fastroute_obstacles
;
454 extern void dev_clear_fastroute(struct device
*dev
);
455 extern struct net_fastroute_stats dev_fastroute_stat
;
459 #endif /* __KERNEL__ */
461 #endif /* _LINUX_DEV_H */