root/include/linux/netdevice.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. dev_lock_list
  2. dev_unlock_list
  3. dev_lock_wait

   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/if.h>
  28 #include <linux/if_ether.h>
  29 #include <linux/skbuff.h>
  30 
  31 /* for future expansion when we will have different priorities. */
  32 #define DEV_NUMBUFFS    3
  33 #define MAX_ADDR_LEN    7
  34 #ifndef CONFIG_AX25
  35 #ifndef CONFIG_TR
  36 #define MAX_HEADER      32              /* We really need about 18 worst case .. so 32 is aligned */
  37 #else
  38 #define MAX_HEADER      48              /* Token Ring header needs 40 bytes ... 48 is aligned */ 
  39 #endif
  40 #else
  41 #define MAX_HEADER      96              /* AX.25 + NetROM */
  42 #endif
  43 
  44 #define IS_MYADDR       1               /* address is (one of) our own  */
  45 #define IS_LOOPBACK     2               /* address is for LOOPBACK      */
  46 #define IS_BROADCAST    3               /* address is a valid broadcast */
  47 #define IS_INVBCAST     4               /* Wrong netmask bcast not for us (unused)*/
  48 #define IS_MULTICAST    5               /* Multicast IP address */
  49 
  50 /*
  51  *      We tag these structures with multicasts.
  52  */
  53  
  54 struct dev_mc_list
  55 {       
  56         struct dev_mc_list *next;
  57         char dmi_addr[MAX_ADDR_LEN];
  58         unsigned short dmi_addrlen;
  59         unsigned short dmi_users;
  60 };
  61 
  62 /*
  63  * The DEVICE structure.
  64  * Actually, this whole structure is a big mistake.  It mixes I/O
  65  * data with strictly "high-level" data, and it has to know about
  66  * almost every data structure used in the INET module.  
  67  */
  68 struct device 
  69 {
  70 
  71   /*
  72    * This is the first field of the "visible" part of this structure
  73    * (i.e. as seen by users in the "Space.c" file).  It is the name
  74    * the interface.
  75    */
  76   char                    *name;
  77 
  78   /* I/O specific fields - FIXME: Merge these and struct ifmap into one */
  79   unsigned long           rmem_end;             /* shmem "recv" end     */
  80   unsigned long           rmem_start;           /* shmem "recv" start   */
  81   unsigned long           mem_end;              /* sahared mem end      */
  82   unsigned long           mem_start;            /* shared mem start     */
  83   unsigned long           base_addr;            /* device I/O address   */
  84   unsigned char           irq;                  /* device IRQ number    */
  85 
  86   /* Low-level status flags. */
  87   volatile unsigned char  start,                /* start an operation   */
  88                           interrupt;            /* interrupt arrived    */
  89   unsigned long           tbusy;                /* transmitter busy must be long for bitops */
  90 
  91   struct device           *next;
  92 
  93   /* The device initialization function. Called only once. */
  94   int                     (*init)(struct device *dev);
  95 
  96   /* Some hardware also needs these fields, but they are not part of the
  97      usual set specified in Space.c. */
  98   unsigned char           if_port;              /* Selectable AUI, TP,..*/
  99   unsigned char           dma;                  /* DMA channel          */
 100 
 101   struct enet_statistics* (*get_stats)(struct device *dev);
 102 
 103   /*
 104    * This marks the end of the "visible" part of the structure. All
 105    * fields hereafter are internal to the system, and may change at
 106    * will (read: may be cleaned up at will).
 107    */
 108 
 109   /* These may be needed for future network-power-down code. */
 110   unsigned long           trans_start;  /* Time (in jiffies) of last Tx */
 111   unsigned long           last_rx;      /* Time of last Rx              */
 112 
 113   unsigned short          flags;        /* interface flags (a la BSD)   */
 114   unsigned short          family;       /* address family ID (AF_INET)  */
 115   unsigned short          metric;       /* routing metric (not used)    */
 116   unsigned short          mtu;          /* interface MTU value          */
 117   unsigned short          type;         /* interface hardware type      */
 118   unsigned short          hard_header_len;      /* hardware hdr length  */
 119   void                    *priv;        /* pointer to private data      */
 120 
 121   /* Interface address info. */
 122   unsigned char           broadcast[MAX_ADDR_LEN];      /* hw bcast add */
 123   unsigned char           pad;                          /* make dev_addr aligned to 8 bytes */
 124   unsigned char           dev_addr[MAX_ADDR_LEN];       /* hw address   */
 125   unsigned char           addr_len;     /* hardware address length      */
 126   unsigned long           pa_addr;      /* protocol address             */
 127   unsigned long           pa_brdaddr;   /* protocol broadcast addr      */
 128   unsigned long           pa_dstaddr;   /* protocol P-P other side addr */
 129   unsigned long           pa_mask;      /* protocol netmask             */
 130   unsigned short          pa_alen;      /* protocol address length      */
 131 
 132   struct dev_mc_list     *mc_list;      /* Multicast mac addresses      */
 133   int                    mc_count;      /* Number of installed mcasts   */
 134   
 135   struct ip_mc_list      *ip_mc_list;   /* IP multicast filter chain    */
 136     
 137   /* For load balancing driver pair support */
 138   
 139   unsigned long            pkt_queue;   /* Packets queued */
 140   struct device           *slave;       /* Slave device */
 141   
 142 
 143   /* Pointer to the interface buffers. */
 144   struct sk_buff_head     buffs[DEV_NUMBUFFS];
 145 
 146   /* Pointers to interface service routines. */
 147   int                     (*open)(struct device *dev);
 148   int                     (*stop)(struct device *dev);
 149   int                     (*hard_start_xmit) (struct sk_buff *skb,
 150                                               struct device *dev);
 151   int                     (*hard_header) (struct sk_buff *skb,
 152                                           struct device *dev,
 153                                           unsigned short type,
 154                                           void *daddr,
 155                                           void *saddr,
 156                                           unsigned len);
 157   int                     (*rebuild_header)(void *eth, struct device *dev,
 158                                 unsigned long raddr, struct sk_buff *skb);
 159 #define HAVE_MULTICAST                   
 160   void                    (*set_multicast_list)(struct device *dev,
 161                                          int num_addrs, void *addrs);
 162 #define HAVE_SET_MAC_ADDR                
 163   int                     (*set_mac_address)(struct device *dev, void *addr);
 164 #define HAVE_PRIVATE_IOCTL
 165   int                     (*do_ioctl)(struct device *dev, struct ifreq *ifr, int cmd);
 166 #define HAVE_SET_CONFIG
 167   int                     (*set_config)(struct device *dev, struct ifmap *map);
 168   void                    (*header_cache)(struct device *dev, struct sock *sk, unsigned long saddr, unsigned long daddr);
 169 };
 170 
 171 
 172 struct packet_type {
 173   unsigned short        type;   /* This is really htons(ether_type). */
 174   struct device *       dev;
 175   int                   (*func) (struct sk_buff *, struct device *,
 176                                  struct packet_type *);
 177   void                  *data;
 178   struct packet_type    *next;
 179 };
 180 
 181 
 182 #ifdef __KERNEL__
 183 
 184 #include <linux/notifier.h>
 185 
 186 /* Used by dev_rint */
 187 #define IN_SKBUFF       1
 188 
 189 extern volatile char in_bh;
 190 
 191 extern struct device    loopback_dev;
 192 extern struct device    *dev_base;
 193 extern struct packet_type *ptype_base[16];
 194 
 195 
 196 extern int              ip_addr_match(unsigned long addr1, unsigned long addr2);
 197 extern int              ip_chk_addr(unsigned long addr);
 198 extern struct device    *ip_dev_check(unsigned long daddr);
 199 extern unsigned long    ip_my_addr(void);
 200 extern unsigned long    ip_get_mask(unsigned long addr);
 201 extern struct device    *ip_dev_find(unsigned long addr);
 202 
 203 extern void             dev_add_pack(struct packet_type *pt);
 204 extern void             dev_remove_pack(struct packet_type *pt);
 205 extern struct device    *dev_get(const char *name);
 206 extern int              dev_open(struct device *dev);
 207 extern int              dev_close(struct device *dev);
 208 extern void             dev_queue_xmit(struct sk_buff *skb, struct device *dev,
 209                                        int pri);
 210 #define HAVE_NETIF_RX 1
 211 extern void             netif_rx(struct sk_buff *skb);
 212 /* The old interface to netif_rx(). */
 213 extern int              dev_rint(unsigned char *buff, long len, int flags,
 214                                  struct device * dev);
 215 extern void             dev_transmit(void);
 216 extern int              in_net_bh(void);
 217 extern void             net_bh(void *tmp);
 218 extern void             dev_tint(struct device *dev);
 219 extern int              dev_get_info(char *buffer, char **start, off_t offset, int length, int dummy);
 220 extern int              dev_ioctl(unsigned int cmd, void *);
 221 
 222 extern void             dev_init(void);
 223 
 224 /* Locking protection for page faults during outputs to devices unloaded during the fault */
 225 
 226 extern int              dev_lockct;
 227 
 228 /*
 229  *      These two dont currently need to be interrupt safe
 230  *      but they may do soon. Do it properly anyway.
 231  */
 232 
 233 extern __inline__ void  dev_lock_list(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 234 {
 235         unsigned long flags;
 236         save_flags(flags);
 237         cli();
 238         dev_lockct++;
 239         restore_flags(flags);
 240 }
 241 
 242 extern __inline__ void  dev_unlock_list(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 243 {
 244         unsigned long flags;
 245         save_flags(flags);
 246         cli();
 247         dev_lockct--;
 248         restore_flags(flags);
 249 }
 250 
 251 /*
 252  *      This almost never occurs, isnt in performance critical paths
 253  *      and we can thus be relaxed about it
 254  */
 255  
 256 extern __inline__ void dev_lock_wait(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 257 {
 258         while(dev_lockct)
 259                 schedule();
 260 }
 261 
 262 
 263 /* These functions live elsewhere (drivers/net/net_init.c, but related) */
 264 
 265 extern void             ether_setup(struct device *dev);
 266 extern void             tr_setup(struct device *dev);
 267 extern int              ether_config(struct device *dev, struct ifmap *map);
 268 /* Support for loadable net-drivers */
 269 extern int              register_netdev(struct device *dev);
 270 extern void             unregister_netdev(struct device *dev);
 271 extern int              register_netdevice_notifier(struct notifier_block *nb);
 272 extern int              unregister_netdevice_notifier(struct notifier_block *nb);
 273 /* Functions used for multicast support */
 274 extern void             dev_mc_upload(struct device *dev);
 275 extern void             dev_mc_delete(struct device *dev, void *addr, int alen, int all);
 276 extern void             dev_mc_add(struct device *dev, void *addr, int alen, int newonly);
 277 extern void             dev_mc_discard(struct device *dev);
 278 /* This is the wrong place but it'll do for the moment */
 279 extern void             ip_mc_allhost(struct device *dev);
 280 #endif /* __KERNEL__ */
 281 
 282 #endif  /* _LINUX_DEV_H */

/* [previous][next][first][last][top][bottom][index][help] */