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_len
; /* length of header */
156 int (*hh_output
)(struct sk_buff
*skb
);
158 /* cached hardware header; allow for machine alignment needs. */
159 unsigned long hh_data
[16/sizeof(unsigned long)];
164 * The DEVICE structure.
165 * Actually, this whole structure is a big mistake. It mixes I/O
166 * data with strictly "high-level" data, and it has to know about
167 * almost every data structure used in the INET module.
169 * FIXME: cleanup struct device such that network protocol info
177 * This is the first field of the "visible" part of this structure
178 * (i.e. as seen by users in the "Space.c" file). It is the name
184 * I/O specific fields
185 * FIXME: Merge these and struct ifmap into one
187 unsigned long rmem_end
; /* shmem "recv" end */
188 unsigned long rmem_start
; /* shmem "recv" start */
189 unsigned long mem_end
; /* shared mem end */
190 unsigned long mem_start
; /* shared mem start */
191 unsigned long base_addr
; /* device I/O address */
192 unsigned int irq
; /* device IRQ number */
194 /* Low-level status flags. */
195 volatile unsigned char start
; /* start an operation */
197 * These two are just single-bit flags, but due to atomicity
198 * reasons they have to be inside a "unsigned long". However,
199 * they should be inside the SAME unsigned long instead of
200 * this wasteful use of memory..
202 unsigned long interrupt
; /* bitops.. */
203 unsigned long tbusy
; /* transmitter busy */
207 /* The device initialization function. Called only once. */
208 int (*init
)(struct device
*dev
);
209 void (*destructor
)(struct device
*dev
);
211 /* Interface index. Unique device identifier */
216 * Some hardware also needs these fields, but they are not
217 * part of the usual set specified in Space.c.
220 unsigned char if_port
; /* Selectable AUI, TP,..*/
221 unsigned char dma
; /* DMA channel */
223 struct net_device_stats
* (*get_stats
)(struct device
*dev
);
224 struct iw_statistics
* (*get_wireless_stats
)(struct device
*dev
);
227 * This marks the end of the "visible" part of the structure. All
228 * fields hereafter are internal to the system, and may change at
229 * will (read: may be cleaned up at will).
232 /* These may be needed for future network-power-down code. */
233 unsigned long trans_start
; /* Time (in jiffies) of last Tx */
234 unsigned long last_rx
; /* Time of last Rx */
236 unsigned short flags
; /* interface flags (a la BSD) */
237 unsigned short gflags
;
238 unsigned mtu
; /* interface MTU value */
239 unsigned short type
; /* interface hardware type */
240 unsigned short hard_header_len
; /* hardware hdr length */
241 void *priv
; /* pointer to private data */
243 /* Interface address info. */
244 unsigned char broadcast
[MAX_ADDR_LEN
]; /* hw bcast add */
245 unsigned char pad
; /* make dev_addr aligned to 8 bytes */
246 unsigned char dev_addr
[MAX_ADDR_LEN
]; /* hw address */
247 unsigned char addr_len
; /* hardware address length */
249 struct dev_mc_list
*mc_list
; /* Multicast mac addresses */
250 int mc_count
; /* Number of installed mcasts */
254 /* For load balancing driver pair support */
256 unsigned long pkt_queue
; /* Packets queued */
257 struct device
*slave
; /* Slave device */
259 /* Protocol specific pointers */
261 void *atalk_ptr
; /* AppleTalk link */
262 void *ip_ptr
; /* IPv4 specific data */
263 void *dn_ptr
; /* DECnet specific data */
264 void *ip6_ptr
; /* IPv6 specific data */
267 struct Qdisc
*qdisc_sleeping
;
268 struct Qdisc
*qdisc_list
;
269 unsigned long tx_queue_len
; /* Max frames per queue allowed */
271 /* hard_start_xmit synchronizer */
272 spinlock_t xmit_lock
;
273 /* cpu id of processor entered to hard_start_xmit or -1,
274 if nobody entered there.
277 /* device queue lock */
278 spinlock_t queue_lock
;
281 /* Pointers to interface service routines. */
282 int (*open
)(struct device
*dev
);
283 int (*stop
)(struct device
*dev
);
284 int (*hard_start_xmit
) (struct sk_buff
*skb
,
286 int (*hard_header
) (struct sk_buff
*skb
,
292 int (*rebuild_header
)(struct sk_buff
*skb
);
293 #define HAVE_MULTICAST
294 void (*set_multicast_list
)(struct device
*dev
);
295 #define HAVE_SET_MAC_ADDR
296 int (*set_mac_address
)(struct device
*dev
,
298 #define HAVE_PRIVATE_IOCTL
299 int (*do_ioctl
)(struct device
*dev
,
300 struct ifreq
*ifr
, int cmd
);
301 #define HAVE_SET_CONFIG
302 int (*set_config
)(struct device
*dev
,
304 #define HAVE_HEADER_CACHE
305 int (*hard_header_cache
)(struct neighbour
*neigh
,
306 struct hh_cache
*hh
);
307 void (*header_cache_update
)(struct hh_cache
*hh
,
309 unsigned char * haddr
);
310 #define HAVE_CHANGE_MTU
311 int (*change_mtu
)(struct device
*dev
, int new_mtu
);
313 int (*hard_header_parse
)(struct sk_buff
*skb
,
314 unsigned char *haddr
);
315 int (*neigh_setup
)(struct device
*dev
, struct neigh_parms
*);
316 int (*accept_fastpath
)(struct device
*, struct dst_entry
*);
318 #ifdef CONFIG_NET_FASTROUTE
319 /* Really, this semaphore may be necessary and for not fastroute code;
323 #define NETDEV_FASTROUTE_HMASK 0xF
324 /* Semi-private data. Keep it at the end of device struct. */
325 struct dst_entry
*fastpath
[NETDEV_FASTROUTE_HMASK
+1];
332 unsigned short type
; /* This is really htons(ether_type). */
333 struct device
*dev
; /* NULL is wildcarded here */
334 int (*func
) (struct sk_buff
*, struct device
*,
335 struct packet_type
*);
336 void *data
; /* Private to the packet type */
337 struct packet_type
*next
;
341 #include <linux/interrupt.h>
342 #include <linux/notifier.h>
344 extern struct device loopback_dev
; /* The loopback */
345 extern struct device
*dev_base
; /* All devices */
346 extern rwlock_t dev_base_lock
; /* Device list lock */
347 extern int netdev_dropping
;
348 extern int net_cpu_congestion
;
350 extern struct device
*dev_getbyhwaddr(unsigned short type
, char *hwaddr
);
351 extern void dev_add_pack(struct packet_type
*pt
);
352 extern void dev_remove_pack(struct packet_type
*pt
);
353 extern struct device
*dev_get(const char *name
);
354 extern struct device
*dev_alloc(const char *name
, int *err
);
355 extern int dev_alloc_name(struct device
*dev
, const char *name
);
356 extern int dev_open(struct device
*dev
);
357 extern int dev_close(struct device
*dev
);
358 extern int dev_queue_xmit(struct sk_buff
*skb
);
359 extern void dev_loopback_xmit(struct sk_buff
*skb
);
360 extern int register_netdevice(struct device
*dev
);
361 extern int unregister_netdevice(struct device
*dev
);
362 extern int register_netdevice_notifier(struct notifier_block
*nb
);
363 extern int unregister_netdevice_notifier(struct notifier_block
*nb
);
364 extern int dev_new_index(void);
365 extern struct device
*dev_get_by_index(int ifindex
);
366 extern int dev_restart(struct device
*dev
);
368 typedef int gifconf_func_t(struct device
* dev
, char * bufptr
, int len
);
369 extern int register_gifconf(unsigned int family
, gifconf_func_t
* gifconf
);
370 extern __inline__
int unregister_gifconf(unsigned int family
)
372 return register_gifconf(family
, 0);
375 #define HAVE_NETIF_RX 1
376 extern void netif_rx(struct sk_buff
*skb
);
377 extern void net_bh(void);
378 extern int dev_get_info(char *buffer
, char **start
, off_t offset
, int length
, int dummy
);
379 extern int dev_ioctl(unsigned int cmd
, void *);
380 extern int dev_change_flags(struct device
*, unsigned);
381 extern void dev_queue_xmit_nit(struct sk_buff
*skb
, struct device
*dev
);
383 extern void dev_init(void);
385 extern int netdev_nit
;
387 /* Locking protection for page faults during outputs to devices unloaded during the fault */
389 extern atomic_t dev_lockct
;
392 * These two don't currently need to be atomic
393 * but they may do soon. Do it properly anyway.
396 extern __inline__
void dev_lock_list(void)
398 atomic_inc(&dev_lockct
);
401 extern __inline__
void dev_unlock_list(void)
403 atomic_dec(&dev_lockct
);
407 * This almost never occurs, isn't in performance critical paths
408 * and we can thus be relaxed about it.
410 * FIXME: What if this is being run as a real time process ??
411 * Linus: We need a way to force a yield here ?
413 * FIXME: Though dev_lockct is atomic varible, locking procedure
417 extern __inline__
void dev_lock_wait(void)
419 while (atomic_read(&dev_lockct
)) {
420 current
->policy
|= SCHED_YIELD
;
425 extern __inline__
void dev_init_buffers(struct device
*dev
)
430 /* These functions live elsewhere (drivers/net/net_init.c, but related) */
432 extern void ether_setup(struct device
*dev
);
433 extern void fddi_setup(struct device
*dev
);
434 extern void tr_setup(struct device
*dev
);
435 extern void tr_freedev(struct device
*dev
);
436 extern int ether_config(struct device
*dev
, struct ifmap
*map
);
437 /* Support for loadable net-drivers */
438 extern int register_netdev(struct device
*dev
);
439 extern void unregister_netdev(struct device
*dev
);
440 extern int register_trdev(struct device
*dev
);
441 extern void unregister_trdev(struct device
*dev
);
442 /* Functions used for multicast support */
443 extern void dev_mc_upload(struct device
*dev
);
444 extern int dev_mc_delete(struct device
*dev
, void *addr
, int alen
, int all
);
445 extern int dev_mc_add(struct device
*dev
, void *addr
, int alen
, int newonly
);
446 extern void dev_mc_discard(struct device
*dev
);
447 extern void dev_set_promiscuity(struct device
*dev
, int inc
);
448 extern void dev_set_allmulti(struct device
*dev
, int inc
);
449 extern void netdev_state_change(struct device
*dev
);
450 /* Load a device via the kmod */
451 extern void dev_load(const char *name
);
452 extern void dev_mcast_init(void);
453 extern int netdev_register_fc(struct device
*dev
, void (*stimul
)(struct device
*dev
));
454 extern void netdev_unregister_fc(int bit
);
455 extern int netdev_dropping
;
456 extern int netdev_max_backlog
;
457 extern atomic_t netdev_rx_dropped
;
458 extern unsigned long netdev_fc_xoff
;
459 #ifdef CONFIG_NET_FASTROUTE
460 extern int netdev_fastroute
;
461 extern int netdev_fastroute_obstacles
;
462 extern void dev_clear_fastroute(struct device
*dev
);
463 extern struct net_fastroute_stats dev_fastroute_stat
;
467 #endif /* __KERNEL__ */
469 #endif /* _LINUX_DEV_H */