1 /* 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. 5 * 6 * Definitions for the Interfaces handler. 7 * 8 * Version: @(#)dev.h 1.0.10 08/12/93 9 * 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@super.org> 14 * Alan Cox, <A.Cox@swansea.ac.uk> 15 * Bjorn Ekwall. <bj0rn@blox.se> 16 * 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. 21 * 22 * Moved to /usr/include/linux for NET3 23 */ 24 #ifndef_LINUX_NETDEVICE_H 25 #define_LINUX_NETDEVICE_H 26
27 #include <linux/config.h>
28 #include <linux/if.h>
29 #include <linux/if_ether.h>
30 #include <linux/skbuff.h>
31
32 /* for future expansion when we will have different priorities. */ 33 #defineDEV_NUMBUFFS 3
34 #defineMAX_ADDR_LEN 7
35 #ifndefCONFIG_AX25 36 #ifndefCONFIG_TR 37 #defineMAX_HEADER 32 /* We really need about 18 worst case .. so 32 is aligned */ 38 #else 39 #defineMAX_HEADER 48 /* Token Ring header needs 40 bytes ... 48 is aligned */ 40 #endif 41 #else 42 #defineMAX_HEADER 96 /* AX.25 + NetROM */ 43 #endif 44
45 #defineIS_MYADDR 1 /* address is (one of) our own */ 46 #define IS_LOOPBACK 2 /* address is for LOOPBACK */ 47 #defineIS_BROADCAST 3 /* address is a valid broadcast */ 48 #define IS_INVBCAST 4 /* Wrong netmask bcast not for us (unused)*/ 49 #defineIS_MULTICAST 5 /* Multicast IP address */ 50
51 /* 52 * We tag multicasts with these structures. 53 */ 54
55 structdev_mc_list 56 { 57 structdev_mc_list *next;
58 chardmi_addr[MAX_ADDR_LEN];
59 unsignedshortdmi_addrlen;
60 unsignedshortdmi_users;
61 };
62
63 structhh_cache 64 { 65 structhh_cache *hh_next;
66 void *hh_arp; /* Opaque pointer, used by 67 * any address resolution module, 68 * not only ARP. 69 */ 70 unsignedinthh_refcnt; /* number of users */ 71 unsignedshorthh_type; /* protocol identifier, f.e ETH_P_IP */ 72 charhh_uptodate; /* hh_data is valid */ 73 charhh_data[16]; /* cached hardware header */ 74 };
75
76 /* 77 * The DEVICE structure. 78 * Actually, this whole structure is a big mistake. It mixes I/O 79 * data with strictly "high-level" data, and it has to know about 80 * almost every data structure used in the INET module. 81 */ 82 structdevice 83 { 84
85 /* 86 * This is the first field of the "visible" part of this structure 87 * (i.e. as seen by users in the "Space.c" file). It is the name 88 * the interface. 89 */ 90 char *name;
91
92 /* I/O specific fields - FIXME: Merge these and struct ifmap into one */ 93 unsignedlongrmem_end; /* shmem "recv" end */ 94 unsignedlongrmem_start; /* shmem "recv" start */ 95 unsignedlongmem_end; /* shared mem end */ 96 unsignedlongmem_start; /* shared mem start */ 97 unsignedlongbase_addr; /* device I/O address */ 98 unsignedcharirq; /* device IRQ number */ 99
100 /* Low-level status flags. */ 101 volatileunsignedcharstart, /* start an operation */ 102 interrupt; /* interrupt arrived */ 103 unsignedlongtbusy; /* transmitter busy must be long for bitops */ 104
105 structdevice *next;
106
107 /* The device initialization function. Called only once. */ 108 int (*init)(structdevice *dev);
109
110 /* Some hardware also needs these fields, but they are not part of the 111 usual set specified in Space.c. */ 112 unsignedcharif_port; /* Selectable AUI, TP,..*/ 113 unsignedchardma; /* DMA channel */ 114
115 structenet_statistics* (*get_stats)(structdevice *dev);
116
117 /* 118 * This marks the end of the "visible" part of the structure. All 119 * fields hereafter are internal to the system, and may change at 120 * will (read: may be cleaned up at will). 121 */ 122
123 /* These may be needed for future network-power-down code. */ 124 unsignedlongtrans_start; /* Time (in jiffies) of last Tx */ 125 unsignedlonglast_rx; /* Time of last Rx */ 126
127 unsignedshortflags; /* interface flags (a la BSD) */ 128 unsignedshortfamily; /* address family ID (AF_INET) */ 129 unsignedshortmetric; /* routing metric (not used) */ 130 unsignedshortmtu; /* interface MTU value */ 131 unsignedshorttype; /* interface hardware type */ 132 unsignedshorthard_header_len; /* hardware hdr length */ 133 void *priv; /* pointer to private data */ 134
135 /* Interface address info. */ 136 unsignedcharbroadcast[MAX_ADDR_LEN]; /* hw bcast add */ 137 unsignedcharpad; /* make dev_addr aligned to 8 bytes */ 138 unsignedchardev_addr[MAX_ADDR_LEN]; /* hw address */ 139 unsignedcharaddr_len; /* hardware address length */ 140 unsignedlongpa_addr; /* protocol address */ 141 unsignedlongpa_brdaddr; /* protocol broadcast addr */ 142 unsignedlongpa_dstaddr; /* protocol P-P other side addr */ 143 unsignedlongpa_mask; /* protocol netmask */ 144 unsignedshortpa_alen; /* protocol address length */ 145
146 structdev_mc_list *mc_list; /* Multicast mac addresses */ 147 intmc_count; /* Number of installed mcasts */ 148
149 structip_mc_list *ip_mc_list; /* IP multicast filter chain */ 150 __u32tx_queue_len; /* Max frames per queue allowed */ 151
152 /* For load balancing driver pair support */ 153
154 unsignedlong pkt_queue; /* Packets queued */ 155 structdevice *slave; /* Slave device */ 156 structnet_alias_info *alias_info; /* main dev alias info */ 157 structnet_alias *my_alias; /* alias devs */ 158
159 /* Pointer to the interface buffers. */ 160 structsk_buff_headbuffs[DEV_NUMBUFFS];
161
162 /* Pointers to interface service routines. */ 163 int (*open)(structdevice *dev);
164 int (*stop)(structdevice *dev);
165 int (*hard_start_xmit) (structsk_buff *skb,
166 structdevice *dev);
167 int (*hard_header) (structsk_buff *skb,
168 structdevice *dev,
169 unsignedshorttype,
170 void *daddr,
171 void *saddr,
172 unsignedlen);
173 int (*rebuild_header)(void *eth, structdevice *dev,
174 unsignedlongraddr, structsk_buff *skb);
175 #define HAVE_MULTICAST
176 void (*set_multicast_list)(structdevice *dev);
177 #defineHAVE_SET_MAC_ADDR 178 int (*set_mac_address)(structdevice *dev, void *addr);
179 #define HAVE_PRIVATE_IOCTL
180 int (*do_ioctl)(structdevice *dev, structifreq *ifr, intcmd);
181 #define HAVE_SET_CONFIG
182 int (*set_config)(structdevice *dev, structifmap *map);
183 #define HAVE_HEADER_CACHE
184 void (*header_cache_bind)(structhh_cache **hhp, structdevice *dev, unsignedshorthtype, __u32daddr);
185 void (*header_cache_update)(structhh_cache *hh, structdevice *dev, unsignedchar * haddr);
186 };
187
188
189 structpacket_type{ 190 unsignedshorttype; /* This is really htons(ether_type). */ 191 structdevice * dev;
192 int (*func) (structsk_buff *, structdevice *,
193 structpacket_type *);
194 void *data;
195 structpacket_type *next;
196 };
197
198
199 #ifdef__KERNEL__ 200
201 #include <linux/notifier.h>
202
203 /* Used by dev_rint */ 204 #define IN_SKBUFF 1
205
206 externvolatileunsignedlongin_bh;
207
208 externstructdeviceloopback_dev;
209 externstructdevice *dev_base;
210 externstructpacket_type *ptype_base[16];
211
212
213 externint ip_addr_match(unsignedlong addr1, unsignedlong addr2);
214 externintip_chk_addr(unsignedlongaddr);
215 externstructdevice *ip_dev_check(unsignedlongdaddr);
216 externunsignedlongip_my_addr(void);
217 externunsignedlongip_get_mask(unsignedlongaddr);
218 externstructdevice *ip_dev_find(unsignedlongaddr);
219 externstructdevice *dev_getbytype(unsignedshorttype);
220
221 externvoiddev_add_pack(structpacket_type *pt);
222 externvoiddev_remove_pack(structpacket_type *pt);
223 externstructdevice *dev_get(constchar *name);
224 externintdev_open(structdevice *dev);
225 externintdev_close(structdevice *dev);
226 externvoiddev_queue_xmit(structsk_buff *skb, structdevice *dev,
227 intpri);
228 #define HAVE_NETIF_RX 1
229 externvoidnetif_rx(structsk_buff *skb);
230 externvoiddev_transmit(void);
231 externintin_net_bh(void);
232 externvoidnet_bh(void *tmp);
233 externvoiddev_tint(structdevice *dev);
234 externintdev_get_info(char *buffer, char **start, off_toffset, intlength, intdummy);
235 externintdev_ioctl(unsignedintcmd, void *);
236
237 externvoid dev_init(void);
238
239 /* Locking protection for page faults during outputs to devices unloaded during the fault */ 240
241 externintdev_lockct;
242
243 /* 244 * These two dont currently need to be interrupt safe 245 * but they may do soon. Do it properly anyway. 246 */ 247
248 extern__inline__voiddev_lock_list(void)
/* */ 249 { 250 unsignedlongflags;
251 save_flags(flags);
252 cli();
253 dev_lockct++;
254 restore_flags(flags);
255 } 256
257 extern__inline__voiddev_unlock_list(void)
/* */ 258 { 259 unsignedlongflags;
260 save_flags(flags);
261 cli();
262 dev_lockct--;
263 restore_flags(flags);
264 } 265
266 /* 267 * This almost never occurs, isnt in performance critical paths 268 * and we can thus be relaxed about it 269 */ 270
271 extern__inline__voiddev_lock_wait(void)
/* */ 272 { 273 while(dev_lockct)
274 schedule();
275 } 276
277
278 /* These functions live elsewhere (drivers/net/net_init.c, but related) */ 279
280 externvoidether_setup(structdevice *dev);
281 externvoidtr_setup(structdevice *dev);
282 externintether_config(structdevice *dev, structifmap *map);
283 /* Support for loadable net-drivers */ 284 externintregister_netdev(structdevice *dev);
285 externvoidunregister_netdev(structdevice *dev);
286 externintregister_netdevice_notifier(structnotifier_block *nb);
287 externintunregister_netdevice_notifier(structnotifier_block *nb);
288 /* Functions used for multicast support */ 289 externvoiddev_mc_upload(structdevice *dev);
290 externvoiddev_mc_delete(structdevice *dev, void *addr, intalen, intall);
291 externvoiddev_mc_add(structdevice *dev, void *addr, intalen, intnewonly);
292 externvoiddev_mc_discard(structdevice *dev);
293 /* This is the wrong place but it'll do for the moment */ 294 externvoidip_mc_allhost(structdevice *dev);
295 #endif/* __KERNEL__ */ 296
297 #endif/* _LINUX_DEV_H */