2 * Copyright (c) 1999-2010 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
32 #include <sys/kernel_types.h>
33 #include <net/kpi_interface.h>
42 /* Ethernet specific types */
43 #define DLIL_DESC_ETYPE2 4
44 #define DLIL_DESC_SAP 5
45 #define DLIL_DESC_SNAP 6
47 * DLIL_DESC_ETYPE2 - native_type must point to 2 byte ethernet raw protocol,
48 * variants.native_type_length must be set to 2
49 * DLIL_DESC_SAP - native_type must point to 3 byte SAP protocol
50 * variants.native_type_length must be set to 3
51 * DLIL_DESC_SNAP - native_type must point to 5 byte SNAP protocol
52 * variants.native_type_length must be set to 5
54 * All protocols must be in Network byte order.
56 * Future interface families may define more protocol types they know about.
57 * The type implies the offset and context of the protocol data at native_type.
58 * The length of the protocol data specified at native_type must be set in
59 * variants.native_type_length.
65 #include <net/if_var.h>
66 #include <sys/kern_event.h>
67 #include <kern/thread.h>
68 #include <kern/locks.h>
81 #define DLIL_THREADNAME_LEN 32
83 struct dlil_threading_info
{
84 decl_lck_mtx_data(, input_lck
);
85 lck_grp_t
*lck_grp
; /* lock group (for lock stats) */
86 mbuf_t mbuf_head
; /* start of mbuf list from if */
89 boolean_t net_affinity
; /* affinity set is available */
90 u_int32_t input_waiting
; /* DLIL condition of thread */
91 struct thread
*input_thread
; /* thread data for this input */
92 struct thread
*workloop_thread
; /* current workloop thread */
93 u_int32_t tag
; /* current affinity tag */
94 char input_name
[DLIL_THREADNAME_LEN
];
95 #if IFNET_INPUT_SANITY_CHK
96 u_int32_t input_wake_cnt
; /* number of times the thread was awaken with packets to process */
97 u_long input_mbuf_cnt
; /* total number of mbuf packets processed by this thread */
102 * The following are shared with kpi_protocol.c so that it may wakeup
103 * the input thread to run through packets queued for protocol input.
105 #define DLIL_INPUT_RUNNING 0x80000000
106 #define DLIL_INPUT_WAITING 0x40000000
107 #define DLIL_PROTO_REGISTER 0x20000000
108 #define DLIL_PROTO_WAITING 0x10000000
109 #define DLIL_INPUT_TERMINATE 0x08000000
111 extern void dlil_init(void);
113 extern errno_t
dlil_set_bpf_tap(ifnet_t
, bpf_tap_mode
, bpf_packet_func
);
116 * Send arp internal bypasses the check for IPv4LL.
118 extern errno_t
dlil_send_arp_internal(ifnet_t
, u_int16_t
,
119 const struct sockaddr_dl
*, const struct sockaddr
*,
120 const struct sockaddr_dl
*, const struct sockaddr
*);
122 extern int dlil_output(ifnet_t
, protocol_family_t
, mbuf_t
, void *,
123 const struct sockaddr
*, int);
125 extern void dlil_input_packet_list(struct ifnet
*, struct mbuf
*);
127 extern errno_t
dlil_resolve_multi(struct ifnet
*,
128 const struct sockaddr
*, struct sockaddr
*, size_t);
130 extern errno_t
dlil_send_arp(ifnet_t
, u_int16_t
, const struct sockaddr_dl
*,
131 const struct sockaddr
*, const struct sockaddr_dl
*,
132 const struct sockaddr
*);
134 extern int dlil_attach_filter(ifnet_t
, const struct iff_filter
*,
135 interface_filter_t
*);
136 extern void dlil_detach_filter(interface_filter_t
);
138 extern void dlil_proto_unplumb_all(ifnet_t
);
140 extern void dlil_post_msg(struct ifnet
*, u_int32_t
, u_int32_t
,
141 struct net_event_data
*, u_int32_t
);
144 * dlil_if_acquire is obsolete. Use ifnet_allocate.
146 extern int dlil_if_acquire(u_int32_t
, const void *, size_t, struct ifnet
**);
148 * dlil_if_release is obsolete. The equivalent is called automatically when
149 * an interface is detached.
151 extern void dlil_if_release(struct ifnet
*ifp
);
153 extern u_int32_t ifnet_aggressive_drainers
;
155 extern errno_t
dlil_if_ref(struct ifnet
*);
156 extern errno_t
dlil_if_free(struct ifnet
*);
158 #endif /* KERNEL_PRIVATE */