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) 73 * We tag multicasts with these structures. 78 struct dev_mc_list
*next
; 79 __u8 dmi_addr
[MAX_ADDR_LEN
]; 80 unsigned char dmi_addrlen
; 87 struct hh_cache
*hh_next
;/* Next entry */ 88 atomic_t hh_refcnt
;/* number of users */ 89 unsigned short hh_type
;/* protocol identifier, f.e ETH_P_IP */ 90 int(*hh_output
)(struct sk_buff
*skb
); 91 /* cached hardware header; allow for machine alignment needs. */ 92 unsigned long hh_data
[16/sizeof(unsigned long)]; 96 * Network device statistics. Akin to the 2.0 ether stats but 100 struct net_device_stats
102 unsigned long rx_packets
;/* total packets received */ 103 unsigned long tx_packets
;/* total packets transmitted */ 104 unsigned long rx_bytes
;/* total bytes received */ 105 unsigned long tx_bytes
;/* total bytes transmitted */ 106 unsigned long rx_errors
;/* bad packets received */ 107 unsigned long tx_errors
;/* packet transmit problems */ 108 unsigned long rx_dropped
;/* no space in linux buffers */ 109 unsigned long tx_dropped
;/* no space available in linux */ 110 unsigned long multicast
;/* multicast packets received */ 111 unsigned long collisions
; 113 /* detailed rx_errors: */ 114 unsigned long rx_length_errors
; 115 unsigned long rx_over_errors
;/* receiver ring buff overflow */ 116 unsigned long rx_crc_errors
;/* recved pkt with crc error */ 117 unsigned long rx_frame_errors
;/* recv'd frame alignment error */ 118 unsigned long rx_fifo_errors
;/* recv'r fifo overrun */ 119 unsigned long rx_missed_errors
;/* receiver missed packet */ 121 /* detailed tx_errors */ 122 unsigned long tx_aborted_errors
; 123 unsigned long tx_carrier_errors
; 124 unsigned long tx_fifo_errors
; 125 unsigned long tx_heartbeat_errors
; 126 unsigned long tx_window_errors
; 129 unsigned long rx_compressed
; 130 unsigned long tx_compressed
; 133 #ifdef CONFIG_NET_FASTROUTE 134 struct net_fastroute_stats
139 int latency_reduction
; 143 /* Media selection options. */ 156 externconst char*if_port_text
[]; 158 #include <linux/skbuff.h> 161 * The DEVICE structure. 162 * Actually, this whole structure is a big mistake. It mixes I/O 163 * data with strictly "high-level" data, and it has to know about 164 * almost every data structure used in the INET module. 166 * FIXME: cleanup struct device such that network protocol info 174 * This is the first field of the "visible" part of this structure 175 * (i.e. as seen by users in the "Space.c" file). It is the name 181 * I/O specific fields 182 * FIXME: Merge these and struct ifmap into one 184 unsigned long rmem_end
;/* shmem "recv" end */ 185 unsigned long rmem_start
;/* shmem "recv" start */ 186 unsigned long mem_end
;/* shared mem end */ 187 unsigned long mem_start
;/* shared mem start */ 188 unsigned long base_addr
;/* device I/O address */ 189 unsigned int irq
;/* device IRQ number */ 191 /* Low-level status flags. */ 192 volatileunsigned char start
;/* start an operation */ 194 * These two are just single-bit flags, but due to atomicity 195 * reasons they have to be inside a "unsigned long". However, 196 * they should be inside the SAME unsigned long instead of 197 * this wasteful use of memory.. 199 unsigned long interrupt
;/* bitops.. */ 200 unsigned long tbusy
;/* transmitter busy */ 204 /* The device initialization function. Called only once. */ 205 int(*init
)(struct device
*dev
); 206 void(*destructor
)(struct device
*dev
); 208 /* Interface index. Unique device identifier */ 213 * Some hardware also needs these fields, but they are not 214 * part of the usual set specified in Space.c. 217 unsigned char if_port
;/* Selectable AUI, TP,..*/ 218 unsigned char dma
;/* DMA channel */ 220 struct net_device_stats
* (*get_stats
)(struct device
*dev
); 221 struct iw_statistics
* (*get_wireless_stats
)(struct device
*dev
); 224 * This marks the end of the "visible" part of the structure. All 225 * fields hereafter are internal to the system, and may change at 226 * will (read: may be cleaned up at will). 229 /* These may be needed for future network-power-down code. */ 230 unsigned long trans_start
;/* Time (in jiffies) of last Tx */ 231 unsigned long last_rx
;/* Time of last Rx */ 233 unsigned short flags
;/* interface flags (a la BSD) */ 234 unsigned short gflags
; 235 unsigned mtu
;/* interface MTU value */ 236 unsigned short type
;/* interface hardware type */ 237 unsigned short hard_header_len
;/* hardware hdr length */ 238 void*priv
;/* pointer to private data */ 240 /* Interface address info. */ 241 unsigned char broadcast
[MAX_ADDR_LEN
];/* hw bcast add */ 242 unsigned char pad
;/* make dev_addr aligned to 8 bytes */ 243 unsigned char dev_addr
[MAX_ADDR_LEN
];/* hw address */ 244 unsigned char addr_len
;/* hardware address length */ 246 struct dev_mc_list
*mc_list
;/* Multicast mac addresses */ 247 int mc_count
;/* Number of installed mcasts */ 251 /* For load balancing driver pair support */ 253 unsigned long pkt_queue
;/* Packets queued */ 254 struct device
*slave
;/* Slave device */ 256 /* Protocol specific pointers */ 258 void*atalk_ptr
;/* AppleTalk link */ 259 void*ip_ptr
;/* IPv4 specific data */ 260 void*dn_ptr
;/* DECnet specific data */ 263 struct Qdisc
*qdisc_sleeping
; 264 struct Qdisc
*qdisc_list
; 265 unsigned long tx_queue_len
;/* Max frames per queue allowed */ 267 /* Pointers to interface service routines. */ 268 int(*open
)(struct device
*dev
); 269 int(*stop
)(struct device
*dev
); 270 int(*hard_start_xmit
) (struct sk_buff
*skb
, 272 int(*hard_header
) (struct sk_buff
*skb
, 278 int(*rebuild_header
)(struct sk_buff
*skb
); 279 #define HAVE_MULTICAST 280 void(*set_multicast_list
)(struct device
*dev
); 281 #define HAVE_SET_MAC_ADDR 282 int(*set_mac_address
)(struct device
*dev
, 284 #define HAVE_PRIVATE_IOCTL 285 int(*do_ioctl
)(struct device
*dev
, 286 struct ifreq
*ifr
,int cmd
); 287 #define HAVE_SET_CONFIG 288 int(*set_config
)(struct device
*dev
, 290 #define HAVE_HEADER_CACHE 291 int(*hard_header_cache
)(struct neighbour
*neigh
, 292 struct hh_cache
*hh
); 293 void(*header_cache_update
)(struct hh_cache
*hh
, 295 unsigned char* haddr
); 296 #define HAVE_CHANGE_MTU 297 int(*change_mtu
)(struct device
*dev
,int new_mtu
); 299 int(*hard_header_parse
)(struct sk_buff
*skb
, 300 unsigned char*haddr
); 301 int(*neigh_setup
)(struct device
*dev
,struct neigh_parms
*); 302 int(*accept_fastpath
)(struct device
*,struct dst_entry
*); 304 #ifdef CONFIG_NET_FASTROUTE 305 /* Really, this semaphore may be necessary and for not fastroute code; 309 #define NETDEV_FASTROUTE_HMASK 0xF 310 /* Semi-private data. Keep it at the end of device struct. */ 311 struct dst_entry
*fastpath
[NETDEV_FASTROUTE_HMASK
+1]; 318 unsigned short type
;/* This is really htons(ether_type). */ 319 struct device
*dev
;/* NULL is wildcarded here */ 320 int(*func
) (struct sk_buff
*,struct device
*, 321 struct packet_type
*); 322 void*data
;/* Private to the packet type */ 323 struct packet_type
*next
; 327 #include <linux/interrupt.h> 328 #include <linux/notifier.h> 330 externstruct device loopback_dev
;/* The loopback */ 331 externstruct device
*dev_base
;/* All devices */ 332 externstruct packet_type
*ptype_base
[16];/* Hashed types */ 333 externint netdev_dropping
; 334 externint net_cpu_congestion
; 336 externstruct device
*dev_getbyhwaddr(unsigned short type
,char*hwaddr
); 337 externvoiddev_add_pack(struct packet_type
*pt
); 338 externvoiddev_remove_pack(struct packet_type
*pt
); 339 externstruct device
*dev_get(const char*name
); 340 externstruct device
*dev_alloc(const char*name
,int*err
); 341 externintdev_alloc_name(struct device
*dev
,const char*name
); 342 externintdev_open(struct device
*dev
); 343 externintdev_close(struct device
*dev
); 344 externintdev_queue_xmit(struct sk_buff
*skb
); 345 externvoiddev_loopback_xmit(struct sk_buff
*skb
); 346 externintregister_netdevice(struct device
*dev
); 347 externintunregister_netdevice(struct device
*dev
); 348 externintregister_netdevice_notifier(struct notifier_block
*nb
); 349 externintunregister_netdevice_notifier(struct notifier_block
*nb
); 350 externintdev_new_index(void); 351 externstruct device
*dev_get_by_index(int ifindex
); 352 externintdev_restart(struct device
*dev
); 354 typedefintgifconf_func_t(struct device
* dev
,char* bufptr
,int len
); 355 externintregister_gifconf(unsigned int family
, gifconf_func_t
* gifconf
); 356 extern __inline__
intunregister_gifconf(unsigned int family
) 358 returnregister_gifconf(family
,0); 361 #define HAVE_NETIF_RX 1 362 externvoidnetif_rx(struct sk_buff
*skb
); 363 externvoidnet_bh(void); 364 externintdev_get_info(char*buffer
,char**start
, off_t offset
,int length
,int dummy
); 365 externintdev_ioctl(unsigned int cmd
,void*); 366 externintdev_change_flags(struct device
*,unsigned); 367 externvoiddev_queue_xmit_nit(struct sk_buff
*skb
,struct device
*dev
); 369 externvoiddev_init(void); 371 externint netdev_nit
; 373 /* Locking protection for page faults during outputs to devices unloaded during the fault */ 375 extern atomic_t dev_lockct
; 378 * These two don't currently need to be atomic 379 * but they may do soon. Do it properly anyway. 382 extern __inline__
voiddev_lock_list(void) 384 atomic_inc(&dev_lockct
); 387 extern __inline__
voiddev_unlock_list(void) 389 atomic_dec(&dev_lockct
); 393 * This almost never occurs, isn't in performance critical paths 394 * and we can thus be relaxed about it. 396 * FIXME: What if this is being run as a real time process ?? 397 * Linus: We need a way to force a yield here ? 399 * FIXME: Though dev_lockct is atomic varible, locking procedure 403 extern __inline__
voiddev_lock_wait(void) 405 while(atomic_read(&dev_lockct
)) { 411 extern __inline__
voiddev_init_buffers(struct device
*dev
) 416 /* These functions live elsewhere (drivers/net/net_init.c, but related) */ 418 externvoidether_setup(struct device
*dev
); 419 externvoidfddi_setup(struct device
*dev
); 420 externvoidtr_setup(struct device
*dev
); 421 externvoidtr_freedev(struct device
*dev
); 422 externintether_config(struct device
*dev
,struct ifmap
*map
); 423 /* Support for loadable net-drivers */ 424 externintregister_netdev(struct device
*dev
); 425 externvoidunregister_netdev(struct device
*dev
); 426 externintregister_trdev(struct device
*dev
); 427 externvoidunregister_trdev(struct device
*dev
); 428 /* Functions used for multicast support */ 429 externvoiddev_mc_upload(struct device
*dev
); 430 externintdev_mc_delete(struct device
*dev
,void*addr
,int alen
,int all
); 431 externintdev_mc_add(struct device
*dev
,void*addr
,int alen
,int newonly
); 432 externvoiddev_mc_discard(struct device
*dev
); 433 externvoiddev_set_promiscuity(struct device
*dev
,int inc
); 434 externvoiddev_set_allmulti(struct device
*dev
,int inc
); 435 /* Load a device via the kmod */ 436 externvoiddev_load(const char*name
); 437 externvoiddev_mcast_init(void); 438 externintnetdev_register_fc(struct device
*dev
,void(*stimul
)(struct device
*dev
)); 439 externvoidnetdev_unregister_fc(int bit
); 440 externint netdev_dropping
; 441 externint netdev_max_backlog
; 442 extern atomic_t netdev_rx_dropped
; 443 externunsigned long netdev_fc_xoff
; 444 #ifdef CONFIG_NET_FASTROUTE 445 externint netdev_fastroute
; 446 externint netdev_fastroute_obstacles
; 447 externvoiddev_clear_fastroute(struct device
*dev
); 448 externstruct net_fastroute_stats dev_fastroute_stat
; 452 #endif/* __KERNEL__ */ 454 #endif/* _LINUX_DEV_H */