1 /* Intel PRO/1000 Family Driver
2 * Copyright (C) 2004 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
4 * Permission to use, copy, modify and distribute this software and its
5 * documentation for any purpose and without fee is hereby granted, provided
6 * that the above copyright notice appear in all copies, and that both the
7 * copyright notice and this permission notice appear in supporting documentation.
9 * Marcus Overhagen makes no representations about the suitability of this software
10 * for any purpose. It is provided "as is" without express or implied warranty.
12 * MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
13 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS
14 * OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
15 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
17 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 #include <net/if_dl.h>
25 #include <net/if_media.h>
27 #include "if_em_osdep.h" // for TAILQ_...
29 #define __FreeBSD_version 500001
31 #define IFF_RUNNING 0x10000
32 #define IFF_OACTIVE 0x20000
34 #define IFCAP_HWCSUM 0x0001
35 #define IFCAP_VLAN_HWTAGGING 0x0002
36 #define IFCAP_VLAN_MTU 0x0004
37 #define IFCAP_TXCSUM 0x0010
38 #define IFCAP_RXCSUM 0x0020
40 #ifdef HAIKU_TARGET_PLATFORM_HAIKU
42 # define IFM_FDX IFM_FULL_DUPLEX
43 # define IFM_HDX IFM_HALF_DUPLEX
44 # define IFM_1000_TX IFM_1000_T
46 # define IFM_ACTIVE 0x0001
47 # define IFM_FDX 0x0002
48 # define IFM_HDX 0x0004
49 # define IFM_10_T 0x0008
50 # define IFM_100_TX 0x0010
51 # define IFM_1000_T 0x0020
52 # define IFM_1000_TX 0x0040
53 # define IFM_1000_SX 0x0080
54 # define IFM_ETHER 0x0100
55 # define IFM_AUTO 0x0200
56 # define IFM_AVALID 0x0400
57 # define IFM_GMASK (IFM_FDX | IFM_HDX)
58 # define IFM_TYPE_MASK (IFM_ETHER)
59 # define IFM_SUBTYPE_MASK \
60 (IFM_AUTO | IFM_1000_SX | IFM_1000_TX | IFM_1000_T | IFM_100_TX | IFM_10_T)
61 # define IFM_TYPE(media) ((media) & IFM_TYPE_MASK)
62 # define IFM_SUBTYPE(media) ((media) & IFM_SUBTYPE_MASK)
65 #define CSUM_TCP 0x0001 // ifnet::if_hwassist
66 #define CSUM_UDP 0x0002 // ifnet::if_hwassist
67 #define CSUM_IP_CHECKED 0x0004
68 #define CSUM_IP_VALID 0x0008
69 #define CSUM_DATA_VALID 0x0010
70 #define CSUM_PSEUDO_HDR 0x0020
72 #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
73 #define ETHER_TYPE_LEN 2 /* length of the Ethernet type field */
74 #define ETHER_CRC_LEN 4 /* length of the Ethernet CRC */
75 #define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
76 #define ETHER_MIN_LEN 64 /* minimum frame len, including CRC */
77 #define ETHER_MAX_LEN 1518 /* maximum frame len, including CRC */
78 #define ETHER_MAX_LEN_JUMBO 9018 /* max jumbo frame len, including CRC */
79 #define ETHER_VLAN_ENCAP_LEN 4 /* len of 802.1Q VLAN encapsulation */
80 #define ETHERMTU ETHER_MAX_LEN_JUMBO
81 #define IP_HEADER_SIZE 20
82 #define OFFSETOF_IPHDR_SUM 10
83 #define OFFSETOF_TCPHDR_SUM 16
84 #define OFFSETOF_UDPHDR_SUM 6
87 // vlan stuff is not supported
88 #define ETHERTYPE_VLAN 0x8100
89 #define VLAN_INPUT_TAG(a, b, c, d)
90 #define VLAN_TAG_VALUE(mtag) 0
91 #define VLAN_OUTPUT_TAG(ifp, m_head) 0
94 // BPF listener not supported
95 #define BPF_MTAP(a, b)
98 // sysctl stuff is not supported
99 #define sysctl_ctx_init(a)
100 #define sysctl_ctx_free(a)
101 #define SYSCTL_HANDLER_ARGS void
102 #define SYSCTL_ADD_NODE(a, b, c, d, e, f, g) \
103 (struct sysctl_oid *) 1
104 #define SYSCTL_ADD_PROC(a, b, c, d, e, f, g, h, i, j)
106 struct sysctl_ctx_list
127 volatile struct mbuf
* ifq_head
;
128 volatile struct mbuf
* ifq_tail
;
129 int ifq_maxlen
; // ignored
132 typedef void (*if_start
)(struct ifnet
*);
133 typedef int (*if_ioctl
)(struct ifnet
*, u_long
, caddr_t
);
134 typedef void (*if_watchdog
)(struct ifnet
*);
135 typedef void (*if_init
)(void *);
136 typedef void (*if_input
)(struct ifnet
*, struct mbuf
*);
143 struct ifnet
* rcvif
; // set by receive int
153 struct mbuf
* m_next
; // next buffer in chain (e.g. for jumboframes)
154 struct mbuf
* m_nextq
; // next buffer in queue
158 struct m_pkthdr m_pkthdr
;
162 #define M_DONTWAIT 0x01
164 #define M_PKTHDR 0x04
166 #define MCLBYTES 2048
168 struct mbuf
*m_gethdr(int how
, int type
);
170 // Allocate and return a single M_PKTHDR mbuf. NULL is returned on failure.
171 #define MGETHDR(mb, how, type) ((mb) = m_gethdr((how), (type)))
173 void m_clget(struct mbuf
* mb
, int how
);
175 // Fetch a single mbuf cluster and attach it to an existing mbuf. If
176 // successfull, configures the provided mbuf to have mbuf->m_ext.ext_buf
177 // pointing to the cluster, and sets the M_EXT bit in the mbuf's flags.
178 // The M_EXT bit is not set on failure
179 #define MCLGET(mb, how) m_clget((mb), (how))
181 struct mbuf
*if_dequeue(struct if_queue
*queue
);
183 void if_prepend(struct if_queue
*queue
, struct mbuf
*mb
);
184 void if_append(struct if_queue
*queue
, struct mbuf
*mb
);
186 #define IF_DEQUEUE(queue, mb) ((mb) = if_dequeue((queue)))
187 #define IF_PREPEND(queue, mb) if_prepend((queue), (mb))
188 #define IF_APPEND(queue, mb) if_append((queue), (mb))
190 void m_adj(struct mbuf
*mp
, int bytes
);
191 void m_freem(struct mbuf
*mp
);
193 #define mtod(m, t) ((t)((m)->m_data))
195 void ether_ifattach(struct ifnet
*ifp
, const uint8
*etheraddr
);
196 void ether_ifdetach(struct ifnet
*ifp
);
198 int ether_add_multi(struct ifnet
*ifp
, const struct sockaddr
*address
);
199 int ether_rem_multi(struct ifnet
*ifp
, const struct sockaddr
*address
);
201 TAILQ_HEAD(ifmultihead
, ifmultiaddr
);
205 TAILQ_ENTRY(ifmultiaddr
) ifma_link
;
206 struct sockaddr
*ifma_addr
;
210 struct sockaddr_dl ifma_addr_storage
;
218 struct ether_vlan_header
220 uint8 evl_dhost
[ETHER_ADDR_LEN
];
221 uint8 evl_shost
[ETHER_ADDR_LEN
];
222 uint16 evl_encap_proto
;
231 struct adapter
*if_softc
;
235 volatile uint32 if_flags
;
236 uint32 if_capabilities
;
245 uint64 if_collisions
;
251 struct if_queue if_snd
; // send queue
252 struct if_queue if_rcv
; // recveive queue
256 struct if_data if_data
;
257 struct ifmultihead if_multiaddrs
;
261 if_watchdog if_watchdog
;
266 void *if_output
; // unused
267 #define ether_output 0
273 uint8 ac_enaddr
[ETHER_ADDR_LEN
];
276 #define device_get_softc(dev) \
277 (dev->adapter ? dev->adapter : (dev->adapter = (struct adapter *)malloc(sizeof(struct adapter), 0, 0)))
279 #define device_get_unit(dev) \
282 enum { // ioctl commands
283 SIOCSIFADDR
= 0x7000,
294 // used for media properties
295 #define ifmedia_init(a, b, c, d)
296 #define ifmedia_add(a, b, c, d)
297 #define ifmedia_set(a, b)
298 #define ifmedia_ioctl(ifp, ifr, media, command) 0
300 // called for SIOCxIFADDR (Get/Set Interface Addr)
301 #define ether_ioctl(ifp, command, data)
303 #endif // __IF_COMPAT_H