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 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version
18 * 2 of the License, or (at your option) any later version.
19 *
20 * Moved to /usr/include/linux for NET3
21 */
22 #ifndef _LINUX_NETDEVICE_H
23 #define _LINUX_NETDEVICE_H
24
25 #include <linux/if.h>
26 #include <linux/if_ether.h>
27 #include <linux/skbuff.h>
28
29 /* for future expansion when we will have different priorities. */
30 #define DEV_NUMBUFFS 3
31 #define MAX_ADDR_LEN 7
32 #define MAX_HEADER 18
33
34 #define IS_MYADDR 1 /* address is (one of) our own */
35 #define IS_LOOPBACK 2 /* address is for LOOPBACK */
36 #define IS_BROADCAST 3 /* address is a valid broadcast */
37 #define IS_INVBCAST 4 /* Wrong netmask bcast not for us */
38
39 /*
40 * The DEVICE structure.
41 * Actually, this whole structure is a big mistake. It mixes I/O
42 * data with strictly "high-level" data, and it has to know about
43 * almost every data structure used in the INET module.
44 */
45 struct device
46 {
47
48 /*
49 * This is the first field of the "visible" part of this structure
50 * (i.e. as seen by users in the "Space.c" file). It is the name
51 * the interface.
52 */
53 char *name;
54
55 /* I/O specific fields. These will be moved to DDI soon. */
56 unsigned long rmem_end; /* shmem "recv" end */
57 unsigned long rmem_start; /* shmem "recv" start */
58 unsigned long mem_end; /* sahared mem end */
59 unsigned long mem_start; /* shared mem start */
60 unsigned short base_addr; /* device I/O address */
61 unsigned char irq; /* device IRQ number */
62
63 /* Low-level status flags. */
64 volatile unsigned char start, /* start an operation */
65 tbusy, /* transmitter busy */
66 interrupt; /* interrupt arrived */
67
68 /*
69 * Another mistake.
70 * This points to the next device in the "dev" chain. It will
71 * be moved to the "invisible" part of the structure as soon as
72 * it has been cleaned up. -FvK
73 */
74 struct device *next;
75
76 /* The device initialization function. Called only once. */
77 int (*init)(struct device *dev);
78
79 /* Some hardware also needs these fields, but they are not part of the
80 usual set specified in Space.c. */
81 unsigned char if_port; /* Selectable AUI, TP,..*/
82 unsigned char dma; /* DMA channel */
83
84 struct enet_statistics* (*get_stats)(struct device *dev);
85
86 /*
87 * This marks the end of the "visible" part of the structure. All
88 * fields hereafter are internal to the system, and may change at
89 * will (read: may be cleaned up at will).
90 */
91
92 /* These may be needed for future network-power-down code. */
93 unsigned long trans_start; /* Time (in jiffies) of last Tx */
94 unsigned long last_rx; /* Time of last Rx */
95
96 unsigned short flags; /* interface flags (a la BSD) */
97 unsigned short family; /* address family ID (AF_INET) */
98 unsigned short metric; /* routing metric (not used) */
99 unsigned short mtu; /* interface MTU value */
100 unsigned short type; /* interface hardware type */
101 unsigned short hard_header_len; /* hardware hdr length */
102 void *priv; /* pointer to private data */
103
104 /* Interface address info. */
105 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
106 unsigned char dev_addr[MAX_ADDR_LEN]; /* hw address */
107 unsigned char addr_len; /* harfware address length */
108 unsigned long pa_addr; /* protocol address */
109 unsigned long pa_brdaddr; /* protocol broadcast addr */
110 unsigned long pa_dstaddr; /* protocol P-P other side addr */
111 unsigned long pa_mask; /* protocol netmask */
112 unsigned short pa_alen; /* protocol address length */
113
114 /* Pointer to the interface buffers. */
115 struct sk_buff_head buffs[DEV_NUMBUFFS];
116
117 /* Pointers to interface service routines. */
118 int (*open)(struct device *dev);
119 int (*stop)(struct device *dev);
120 int (*hard_start_xmit) (struct sk_buff *skb,
121 struct device *dev);
122 int (*hard_header) (unsigned char *buff,
123 struct device *dev,
124 unsigned short type,
125 void *daddr,
126 void *saddr,
127 unsigned len,
128 struct sk_buff *skb);
129 int (*rebuild_header)(void *eth, struct device *dev,
130 unsigned long raddr, struct sk_buff *skb);
131 unsigned short (*type_trans) (struct sk_buff *skb,
132 struct device *dev);
133 #define HAVE_MULTICAST
134 void (*set_multicast_list)(struct device *dev,
135 int num_addrs, void *addrs);
136 #define HAVE_SET_MAC_ADDR
137 int (*set_mac_address)(struct device *dev, void *addr);
138 };
139
140
141 struct packet_type {
142 unsigned short type; /* This is really htons(ether_type). */
143 unsigned short copy:1;
144 int (*func) (struct sk_buff *, struct device *,
145 struct packet_type *);
146 void *data;
147 struct packet_type *next;
148 };
149
150
151 #ifdef __KERNEL__
152
153 /* Used by dev_rint */
154 #define IN_SKBUFF 1
155
156 extern volatile char in_bh;
157
158 extern struct device *dev_base;
159 extern struct packet_type *ptype_base;
160
161
162 extern int ip_addr_match(unsigned long addr1, unsigned long addr2);
163 extern int ip_chk_addr(unsigned long addr);
164 extern struct device *ip_dev_check(unsigned long daddr);
165 extern unsigned long ip_my_addr(void);
166 extern unsigned long ip_get_mask(unsigned long addr);
167
168 extern void dev_add_pack(struct packet_type *pt);
169 extern void dev_remove_pack(struct packet_type *pt);
170 extern struct device *dev_get(char *name);
171 extern int dev_open(struct device *dev);
172 extern int dev_close(struct device *dev);
173 extern void dev_queue_xmit(struct sk_buff *skb, struct device *dev,
174 int pri);
175 #define HAVE_NETIF_RX 1
176 extern void netif_rx(struct sk_buff *skb);
177 /* The old interface to netif_rx(). */
178 extern int dev_rint(unsigned char *buff, long len, int flags,
179 struct device * dev);
180 extern void dev_transmit(void);
181 extern int in_inet_bh(void);
182 extern void inet_bh(void *tmp);
183 extern void dev_tint(struct device *dev);
184 extern int dev_get_info(char *buffer, char **start, off_t offset, int length);
185 extern int dev_ioctl(unsigned int cmd, void *);
186
187 extern void dev_init(void);
188
189 /* This function lives elsewhere (drivers/net/net_init.c but is related) */
190
191 extern void ether_setup(struct device *dev);
192
193 #endif /* __KERNEL__ */
194
195 #endif /* _LINUX_DEV_H */