patch-2.1.15 linux/include/linux/netdevice.h

Next file: linux/include/linux/netlink.h
Previous file: linux/include/linux/netbeui.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.14/linux/include/linux/netdevice.h linux/include/linux/netdevice.h
@@ -55,6 +55,12 @@
 #define IS_INVBCAST	4		/* Wrong netmask bcast not for us (unused)*/
 #define IS_MULTICAST	5		/* Multicast IP address */
 
+/* NOTE: move to ipv4_device.h */
+
+#define IFF_IP_ADDR_OK	1
+#define IFF_IP_MASK_OK	2
+#define IFF_IP_BRD_OK	4
+
 #ifdef __KERNEL__
 
 #include <linux/skbuff.h>
@@ -74,10 +80,6 @@
 struct hh_cache
 {
 	struct hh_cache *hh_next;
-	void		*hh_arp;	/* Opaque pointer, used by
-					 * any address resolution module,
-					 * not only ARP.
-					 */
 	int		hh_refcnt;	/* number of users */
 	unsigned short  hh_type;	/* protocol identifier, f.e ETH_P_IP */
 	char		hh_uptodate;	/* hh_data is valid */
@@ -85,133 +87,154 @@
 };
 
 /*
- * The DEVICE structure.
- * Actually, this whole structure is a big mistake.  It mixes I/O
- * data with strictly "high-level" data, and it has to know about
- * almost every data structure used in the INET module.  
+ *	The DEVICE structure.
+ *	Actually, this whole structure is a big mistake.  It mixes I/O
+ *	data with strictly "high-level" data, and it has to know about
+ *	almost every data structure used in the INET module.
+ *
+ *	FIXME: cleanup struct device such that network protocol info
+ *	moves out.
  */
-struct device 
+
+struct device
 {
 
-  /*
-   * This is the first field of the "visible" part of this structure
-   * (i.e. as seen by users in the "Space.c" file).  It is the name
-   * the interface.
-   */
-  char			  *name;
-
-  /* I/O specific fields - FIXME: Merge these and struct ifmap into one */
-  unsigned long		  rmem_end;		/* shmem "recv" end	*/
-  unsigned long		  rmem_start;		/* shmem "recv" start	*/
-  unsigned long		  mem_end;		/* shared mem end	*/
-  unsigned long		  mem_start;		/* shared mem start	*/
-  unsigned long		  base_addr;		/* device I/O address	*/
-  unsigned char		  irq;			/* device IRQ number	*/
-
-  /* Low-level status flags. */
-  volatile unsigned char  start,		/* start an operation	*/
-                          interrupt;		/* interrupt arrived	*/
-  unsigned long		  tbusy;		/* transmitter busy must be long for bitops */
-
-  struct device		  *next;
-
-  /* The device initialization function. Called only once. */
-  int			  (*init)(struct device *dev);
-
-  /* Some hardware also needs these fields, but they are not part of the
-     usual set specified in Space.c. */
-  unsigned char		  if_port;		/* Selectable AUI, TP,..*/
-  unsigned char		  dma;			/* DMA channel		*/
-
-  struct enet_statistics* (*get_stats)(struct device *dev);
-
-  /*
-   * This marks the end of the "visible" part of the structure. All
-   * fields hereafter are internal to the system, and may change at
-   * will (read: may be cleaned up at will).
-   */
-
-  /* These may be needed for future network-power-down code. */
-  unsigned long		  trans_start;	/* Time (in jiffies) of last Tx	*/
-  unsigned long		  last_rx;	/* Time of last Rx		*/
-
-  unsigned short	  flags;	/* interface flags (a la BSD)	*/
-  unsigned short	  family;	/* address family ID (AF_INET)	*/
-  unsigned short	  metric;	/* routing metric (not used)	*/
-  unsigned short	  mtu;		/* interface MTU value		*/
-  unsigned short	  type;		/* interface hardware type	*/
-  unsigned short	  hard_header_len;	/* hardware hdr length	*/
-  void			  *priv;	/* pointer to private data	*/
-
-  /* Interface address info. */
-  unsigned char		  broadcast[MAX_ADDR_LEN];	/* hw bcast add	*/
-  unsigned char		  pad;				/* make dev_addr aligned to 8 bytes */
-  unsigned char		  dev_addr[MAX_ADDR_LEN];	/* hw address	*/
-  unsigned char		  addr_len;	/* hardware address length	*/
-#if 0
-  __u32			  pa_addr_arr[4];
-  __u16			  pa_prefix_len;
-#define pa_addr		  pa_addr_arr[3];
-#else
-  unsigned long		  pa_addr;	/* protocol address		*/
+	/*
+	 * This is the first field of the "visible" part of this structure
+	 * (i.e. as seen by users in the "Space.c" file).  It is the name
+	 * the interface.
+	 */
+	char			*name;
+
+	/*
+	 *	I/O specific fields
+	 *	FIXME: Merge these and struct ifmap into one
+	 */
+	unsigned long		rmem_end;	/* shmem "recv" end	*/
+	unsigned long		rmem_start;	/* shmem "recv" start	*/
+	unsigned long		mem_end;	/* shared mem end	*/
+	unsigned long		mem_start;	/* shared mem start	*/
+	unsigned long		base_addr;	/* device I/O address	*/
+	unsigned char		irq;		/* device IRQ number	*/
+	
+	/* Low-level status flags. */
+	volatile unsigned char	start,		/* start an operation	*/
+				interrupt;	/* interrupt arrived	*/
+	unsigned long		tbusy;		/* transmitter busy must be
+						   long for bitops	*/
+	
+	struct device		*next;
+	
+	/* The device initialization function. Called only once. */
+	int			(*init)(struct device *dev);
+
+	/* Interface index. Unique device identifier	*/
+	int			ifindex;
+	struct device		*next_up;
+
+	/*
+	 *	Some hardware also needs these fields, but they are not
+	 *	part of the usual set specified in Space.c.
+	 */
+	unsigned char		if_port;	/* Selectable AUI, TP,..*/
+	unsigned char		dma;		/* DMA channel		*/
+
+	struct enet_statistics* (*get_stats)(struct device *dev);
+#ifdef CONFIG_NET_RADIO
+	struct iw_statistics*	(*get_wireless_stats)(struct device *dev);
 #endif
-  unsigned long		  pa_brdaddr;	/* protocol broadcast addr	*/
-  unsigned long		  pa_dstaddr;	/* protocol P-P other side addr	*/
-  unsigned long		  pa_mask;	/* protocol netmask		*/
-  unsigned short	  pa_alen;	/* protocol address length	*/
 
-  struct dev_mc_list	 *mc_list;	/* Multicast mac addresses	*/
-  int			 mc_count;	/* Number of installed mcasts	*/
+	/*
+	 * This marks the end of the "visible" part of the structure. All
+	 * fields hereafter are internal to the system, and may change at
+	 * will (read: may be cleaned up at will).
+	 */
+
+	/* These may be needed for future network-power-down code. */
+	unsigned long		trans_start;	/* Time (in jiffies) of last Tx	*/
+	unsigned long		last_rx;	/* Time of last Rx	*/
+	
+	unsigned short		flags;	/* interface flags (a la BSD)	*/
+	unsigned short		family;	/* address family ID (AF_INET)	*/
+	unsigned short		metric;	/* routing metric (not used)	*/
+	unsigned short		mtu;	/* interface MTU value		*/
+	unsigned short		type;	/* interface hardware type	*/
+	unsigned short		hard_header_len;	/* hardware hdr length	*/
+	void			*priv;	/* pointer to private data	*/
+	
+	/* Interface address info. */
+	unsigned char		broadcast[MAX_ADDR_LEN];	/* hw bcast add	*/
+	unsigned char		pad;		/* make dev_addr aligned to 8 bytes */
+	unsigned char		dev_addr[MAX_ADDR_LEN];	/* hw address	*/
+	unsigned char		addr_len;	/* hardware address length	*/
+	unsigned long		pa_addr;	/* protocol address		*/
+
+	unsigned long		pa_brdaddr;	/* protocol broadcast addr	*/
+	unsigned long		pa_dstaddr;	/* protocol P-P other side addr	*/
+	unsigned long		pa_mask;	/* protocol netmask		*/
+	unsigned short		pa_alen;	/* protocol address length	*/
+
+	struct dev_mc_list	*mc_list;	/* Multicast mac addresses	*/
+	int			mc_count;	/* Number of installed mcasts	*/
   
-  struct ip_mc_list	 *ip_mc_list;	/* IP multicast filter chain    */
-  __u32			tx_queue_len;	/* Max frames per queue allowed */
+	struct ip_mc_list	*ip_mc_list;	/* IP multicast filter chain    */
+	unsigned		ip_flags;
+	__u8			hash;	
+	__u32			tx_queue_len;	/* Max frames per queue allowed */
     
-  /* For load balancing driver pair support */
+	/* For load balancing driver pair support */
   
-  unsigned long		   pkt_queue;	/* Packets queued */
-  struct device		  *slave;	/* Slave device */
-  struct net_alias_info		*alias_info;	/* main dev alias info */
-  struct net_alias		*my_alias;	/* alias devs */
+	unsigned long		pkt_queue;	/* Packets queued	*/
+	struct device		*slave;		/* Slave device		*/
+	struct net_alias_info	*alias_info;	/* main dev alias info	*/
+	struct net_alias	*my_alias;	/* alias devs		*/
   
-  /* Pointer to the interface buffers. */
-  struct sk_buff_head	  buffs[DEV_NUMBUFFS];
+	/* Pointer to the interface buffers.	*/
+	struct sk_buff_head	buffs[DEV_NUMBUFFS];
 
-  /* Pointers to interface service routines. */
-  int			  (*open)(struct device *dev);
-  int			  (*stop)(struct device *dev);
-  int			  (*hard_start_xmit) (struct sk_buff *skb,
-					      struct device *dev);
-  int			  (*hard_header) (struct sk_buff *skb,
-					  struct device *dev,
-					  unsigned short type,
-					  void *daddr,
-					  void *saddr,
-					  unsigned len);
-  int			  (*rebuild_header)(void *eth, struct device *dev,
-				unsigned long raddr, struct sk_buff *skb);
+	/* Pointers to interface service routines.	*/
+	int			(*open)(struct device *dev);
+	int			(*stop)(struct device *dev);
+	int			(*hard_start_xmit) (struct sk_buff *skb,
+						    struct device *dev);
+	int			(*hard_header) (struct sk_buff *skb,
+						struct device *dev,
+						unsigned short type,
+						void *daddr,
+						void *saddr,
+						unsigned len);
+	int			(*rebuild_header)(struct sk_buff *skb);
 #define HAVE_MULTICAST			 
-  void			  (*set_multicast_list)(struct device *dev);
+	void			(*set_multicast_list)(struct device *dev);
 #define HAVE_SET_MAC_ADDR  		 
-  int			  (*set_mac_address)(struct device *dev, void *addr);
+	int			(*set_mac_address)(struct device *dev,
+						   void *addr);
 #define HAVE_PRIVATE_IOCTL
-  int			  (*do_ioctl)(struct device *dev, struct ifreq *ifr, int cmd);
+	int			(*do_ioctl)(struct device *dev,
+					    struct ifreq *ifr, int cmd);
 #define HAVE_SET_CONFIG
-  int			  (*set_config)(struct device *dev, struct ifmap *map);
+	int			(*set_config)(struct device *dev,
+					      struct ifmap *map);
 #define HAVE_HEADER_CACHE
-  void			  (*header_cache_bind)(struct hh_cache **hhp, struct device *dev, unsigned short htype, __u32 daddr);
-  void			  (*header_cache_update)(struct hh_cache *hh, struct device *dev, unsigned char *  haddr);
+	int			(*hard_header_cache)(struct dst_entry *dst,
+						     struct dst_entry *neigh,
+						     struct hh_cache *hh);
+	void			(*header_cache_update)(struct hh_cache *hh,
+						       struct device *dev,
+						       unsigned char *  haddr);
 #define HAVE_CHANGE_MTU
-  int			  (*change_mtu)(struct device *dev, int new_mtu);            
+	int			(*change_mtu)(struct device *dev, int new_mtu);
+
 };
 
 
 struct packet_type {
-  unsigned short	type;	/* This is really htons(ether_type). */
-  struct device *	dev;
-  int			(*func) (struct sk_buff *, struct device *,
-				 struct packet_type *);
-  void			*data;
-  struct packet_type	*next;
+	unsigned short		type;	/* This is really htons(ether_type). */
+	struct device		*dev;
+	int			(*func) (struct sk_buff *, struct device *,
+					 struct packet_type *);
+	void			*data;
+	struct packet_type	*next;
 };
 
 
@@ -221,28 +244,27 @@
 /* Used by dev_rint */
 #define IN_SKBUFF	1
 
-extern volatile unsigned long in_bh;
-
 extern struct device	loopback_dev;
 extern struct device	*dev_base;
 extern struct packet_type *ptype_base[16];
 
+/* NOTE: move to INET specific header;
+   __ip_chk_addr is deprecated, do not use if it's possible.
+ */
+extern int		__ip_chk_addr(unsigned long addr);
+extern struct device 	*ip_dev_find(unsigned long addr, char *name);
+/* This is the wrong place but it'll do for the moment */
+extern void		ip_mc_allhost(struct device *dev);
+extern int		devinet_ioctl(unsigned int cmd, void *);
 
-extern int		ip_addr_match(unsigned long addr1, unsigned long addr2);
-extern int		ip_chk_addr(unsigned long addr);
-extern struct device	*ip_dev_bynet(unsigned long daddr, unsigned long mask);
-extern unsigned long	ip_my_addr(void);
-extern unsigned long	ip_get_mask(unsigned long addr);
-extern struct device 	*ip_dev_find(unsigned long addr);
-extern struct device    *dev_getbytype(unsigned short type);
-
+extern struct device    *dev_getbyhwaddr(unsigned short type, char *hwaddr);
 extern void		dev_add_pack(struct packet_type *pt);
 extern void		dev_remove_pack(struct packet_type *pt);
 extern struct device	*dev_get(const char *name);
 extern int		dev_open(struct device *dev);
 extern int		dev_close(struct device *dev);
-extern void		dev_queue_xmit(struct sk_buff *skb, struct device *dev,
-				       int pri);
+extern int		dev_queue_xmit(struct sk_buff *skb);
+extern void		dev_loopback_xmit(struct sk_buff *skb);
 				      
 #define HAVE_NETIF_RX 1
 extern void		netif_rx(struct sk_buff *skb);
@@ -255,29 +277,21 @@
 
 /* Locking protection for page faults during outputs to devices unloaded during the fault */
 
-extern int		dev_lockct;
+extern atomic_t		dev_lockct;
 
 /*
- *	These two don't currently need to be interrupt-safe
+ *	These two don't currently need to be atomic
  *	but they may do soon. Do it properly anyway.
  */
 
 extern __inline__ void  dev_lock_list(void)
 {
-	unsigned long flags;
-	save_flags(flags);
-	cli();
-	dev_lockct++;
-	restore_flags(flags);
+	atomic_inc(&dev_lockct);
 }
 
 extern __inline__ void  dev_unlock_list(void)
 {
-	unsigned long flags;
-	save_flags(flags);
-	cli();
-	dev_lockct--;
-	restore_flags(flags);
+	atomic_dec(&dev_lockct);
 }
 
 /*
@@ -291,6 +305,31 @@
 		schedule();
 }
 
+/* NOTE: about to be replaced with if_index */
+
+static __inline__ __u8 dev_hash_name(char *name)
+{
+	__u8 hash = 0;
+	__u8 *p;
+	for (p=name; *p; p++)
+		hash ^= *p;
+	return hash;
+}
+
+static __inline__ __u8 dev_hash_mc_name(char *name)
+{
+	int i;
+	__u8 hash = 0;
+	unsigned *p = (unsigned*)name;
+	for (i=0; i<MAX_ADDR_LEN/sizeof(unsigned); i++) {
+		unsigned h = p[i];
+		h ^= (h>>16);
+		h ^= (h>>8);
+		hash ^= h;
+	}
+	return hash;
+}
+
 
 /* These functions live elsewhere (drivers/net/net_init.c, but related) */
 
@@ -308,8 +347,7 @@
 extern void 		dev_mc_delete(struct device *dev, void *addr, int alen, int all);
 extern void		dev_mc_add(struct device *dev, void *addr, int alen, int newonly);
 extern void		dev_mc_discard(struct device *dev);
-/* This is the wrong place but it'll do for the moment */
-extern void		ip_mc_allhost(struct device *dev);
+
 #endif /* __KERNEL__ */
 
 #endif	/* _LINUX_DEV_H */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov