Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Trunk/i386/include/IOKit/network/IOEthernetController.h

1/*
2 * Copyright (c) 1998-2008 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23#ifndef _IOETHERNETCONTROLLER_H
24#define _IOETHERNETCONTROLLER_H
25
26#include <IOKit/network/IONetworkController.h>
27
28/*! @defined kIOEthernetControllerClass
29 @abstract kIOEthernetControllerClass is the name of the
30 IOEthernetController class. */
31
32#define kIOEthernetControllerClass "IOEthernetController"
33
34/*! @defined kIOEthernetAddressSize
35 @abstract The number of bytes in an Ethernet hardware address. */
36
37#define kIOEthernetAddressSize 6
38
39/*! @defined kIOEthernetMaxPacketSize
40 @abstract The maximum size of an Ethernet packet, including
41 the FCS bytes. */
42
43#define kIOEthernetMaxPacketSize 1518
44
45/*! @defined kIOEthernetMinPacketSize
46 @abstract The minimum size of an Ethernet packet, including
47 the FCS bytes. */
48
49#define kIOEthernetMinPacketSize 64
50
51/*! @defined kIOEthernetCRCSize
52 @abstract The size in bytes of the 32-bit CRC value appended
53 to the end of each Ethernet frame. */
54
55#define kIOEthernetCRCSize 4
56
57/*! @defined kIOEthernetWakeOnLANFilterGroup
58 @abstract kIOEthernetWakeOnLANFilterGroup describes the name assigned
59 to the Ethernet Wake-On-LAN filter group. This group represents
60 wake filters that are supported by the controller. */
61
62#define kIOEthernetWakeOnLANFilterGroup "IOEthernetWakeOnLANFilterGroup"
63
64/*! @defined kIOEthernetDisabledWakeOnLANFilterGroup
65 @abstract kIOEthernetDisabledWakeOnLANFilterGroup describes the name
66 assigned to the disabled Ethernet Wake-On-LAN filter group. This
67 group represents wake filters that are currently disabled.
68 Membership in this group is dynamic. */
69
70#define kIOEthernetDisabledWakeOnLANFilterGroup \
71 "IOEthernetDisabledWakeOnLANFilterGroup"
72
73/*! @enum WakeOnLANFilters.
74 @abstract All filters in the Wake-on-LAN filter group.
75 @discussion Each filter listed will respond to a network event that
76 will trigger a system wake-up.
77 @constant kIOEthernetWakeOnMagicPacket Reception of a Magic Packet.
78 @constant kIOEthernetWakeOnPacketAddressMatch Reception of a packet
79 which passes through any of the address filtering mechanisms based
80 on its destination Ethernet address. This may include unicast,
81 broadcast, or multicast addresses depending on the current state
82 and setting of the corresponding packet filters. */
83
84enum {
85 kIOEthernetWakeOnMagicPacket = 0x00000001,
86 kIOEthernetWakeOnPacketAddressMatch = 0x00000002
87};
88
89/*
90 * Kernel
91 */
92#if defined(KERNEL) && defined(__cplusplus)
93
94struct IOEthernetAddress {
95UInt8 bytes[kIOEthernetAddressSize];
96};
97
98/*! @const gIOEthernetWakeOnLANFilterGroup
99 @discussion gIOEthernetWakeOnLANFilterGroup is an OSSymbol object
100 that contains the name of the Ethernet Wake-on-LAN filter group
101 defined by kIOEthernetWakeOnLANFilterGroup. */
102
103extern const OSSymbol * gIOEthernetWakeOnLANFilterGroup;
104
105/*! @const gIOEthernetDisabledWakeOnLANFilterGroup
106 @discussion gIOEthernetDisabledWakeOnLANFilterGroup is an OSSymbol object
107 that contains the name of the disabled Ethernet Wake-on-LAN filter group
108 defined by kIOEthernetDisabledWakeOnLANFilterGroup. */
109
110extern const OSSymbol * gIOEthernetDisabledWakeOnLANFilterGroup;
111
112/*! @class IOEthernetController
113 @abstract Abstract superclass for Ethernet controllers.
114 @discussion Ethernet controller drivers should subclass IOEthernetController, and implement
115 or override the hardware specific methods to create an Ethernet driver.
116 An interface object (an IOEthernetInterface instance) must be
117 instantiated by the driver, through attachInterface(), to connect
118 the controller driver to the data link layer.
119*/
120
121class IOEthernetController : public IONetworkController
122{
123 OSDeclareAbstractStructors( IOEthernetController )
124
125protected:
126 struct ExpansionData { };
127 /*! @var reserved
128 Reserved for future use. (Internal use only) */
129 ExpansionData * _reserved;
130
131
132public:
133
134/*! @function initialize
135 @abstract IOEthernetController class initializer.
136 @discussion Creates global OSSymbol objects that are used as keys. */
137
138 static void initialize();
139
140/*! @function init
141 @abstract Initializes an IOEthernetController object.
142 @param properties A dictionary object containing a property table
143 associated with this instance.
144 @result Returns true on success, false otherwise.
145*/
146
147 virtual bool init(OSDictionary * properties);
148
149/*! @function getPacketFilters
150 @abstract Gets the set of packet filters supported by the Ethernet
151 controller in the given filter group.
152 @discussion The default implementation of the abstract method inherited
153 from IONetworkController. When the filter group specified is
154 gIONetworkFilterGroup, then this method will return a value formed by
155 a bitwise OR of kIOPacketFilterUnicast, kIOPacketFilterBroadcast,
156 kIOPacketFilterMulticast, kIOPacketFilterPromiscuous. Otherwise, the
157 return value will be set to zero (0). Subclasses must override this
158 method if their filtering capability differs from what is reported by
159 this default implementation. This method is called from the workloop
160 context, and the result is published to the I/O Kit Registry.
161 @param group The name of the filter group.
162 @param filters Pointer to the mask of supported filters returned by
163 this method.
164 @result Returns kIOReturnSuccess. Drivers that override this
165 method must return kIOReturnSuccess to indicate success, or an error
166 return code otherwise.
167*/
168
169 virtual IOReturn getPacketFilters(const OSSymbol * group,
170 UInt32 * filters) const;
171
172/*! @function enablePacketFilter
173 @abstract Enables one of the supported packet filters from the
174 given filter group.
175 @discussion The default implementation of the abstract method inherited
176 from IONetworkController. This method will call setMulticastMode() or
177 setPromiscuousMode() when the multicast or the promiscuous filter is to be
178 enabled. Requests to disable the Unicast or Broadcast filters are handled
179 silently, without informing the subclass. Subclasses can override this
180 method to change this default behavior, or to extend it to handle
181 additional filter types or filter groups. This method call is synchronized
182 by the workloop's gate.
183 @param group The name of the filter group containing the filter to be
184 enabled.
185 @param aFilter The filter to enable.
186 @param enabledFilters All filters currently enabled by the client.
187 @param options Optional flags for the enable request.
188 @result Returns the value returned by setMulticastMode() or setPromiscuousMode() if
189 either of those two methods are called. Returns kIOReturnSuccess if the filter
190 specified is kIOPacketFilterUnicast or kIOPacketFilterBroadcast.
191 Returns kIOReturnUnsupported if the filter group specified is not
192 gIONetworkFilterGroup.
193*/
194
195 virtual IOReturn enablePacketFilter(const OSSymbol * group,
196 UInt32 aFilter,
197 UInt32 enabledFilters,
198 IOOptionBits options = 0);
199
200/*! @function disablePacketFilter
201 @abstract Disables a packet filter that is currently enabled from the
202 given filter group.
203 @discussion The default implementation of the abstract method inherited
204 from IONetworkController. This method will call setMulticastMode() or
205 setPromiscuousMode() when the multicast or the promiscuous filter is to be
206 disabled. Requests to disable the Unicast or Broadcast filters are handled
207 silently, without informing the subclass. Subclasses can override this
208 method to change this default behavior, or to extend it to handle
209 additional filter types or filter groups. This method call is synchronized
210 by the workloop's gate.
211 @param group The name of the filter group containing the filter to be
212 disabled.
213 @param aFilter The filter to disable.
214 @param enabledFilters All filters currently enabled by the client.
215 @param options Optional flags for the disable request.
216 @result Returns the value returned by setMulticastMode() or setPromiscuousMode() if
217 either of those two methods are called. Returns kIOReturnSuccess if the filter
218 specified is kIOPacketFilterUnicast or kIOPacketFilterBroadcast.
219 Returns kIOReturnUnsupported if the filter group specified is not
220 gIONetworkFilterGroup.
221*/
222
223 virtual IOReturn disablePacketFilter(const OSSymbol * group,
224 UInt32 aFilter,
225 UInt32 enabledFilters,
226 IOOptionBits options = 0);
227
228/*! @function getHardwareAddress
229 @abstract Gets the Ethernet controller's station address.
230 @discussion The default implementation of the abstract method inherited
231 from IONetworkController. This method will call the overloaded form
232 IOEthernetController::getHardwareAddress() that subclasses are expected
233 to override.
234 @param addr The buffer where the controller's hardware address should
235 be written.
236 @param inOutAddrBytes The size of the address buffer provided by the
237 client, and replaced by this method with the actual size of
238 the hardware address in bytes.
239 @result Returns kIOReturnSuccess on success, or an error otherwise.
240*/
241
242 virtual IOReturn getHardwareAddress(void * addr,
243 UInt32 * inOutAddrBytes);
244
245/*! @function setHardwareAddress
246 @abstract Sets or changes the station address used by the Ethernet
247 controller.
248 @discussion The default implementation of the abstract method inherited
249 from IONetworkController. This method will call the overloaded form
250 IOEthernetController::setHardwareAddress() that subclasses are expected
251 to override.
252 @param addr The buffer containing the hardware address provided by
253 the client.
254 @param addrBytes The size of the address buffer provided by the
255 client in bytes.
256 @result Returns kIOReturnSuccess on success, or an error otherwise.
257*/
258
259 virtual IOReturn setHardwareAddress(const void * addr,
260 UInt32 addrBytes);
261
262/*! @function getMaxPacketSize
263 @abstract Gets the maximum packet size supported by the Ethernet
264 controller, including the frame header and FCS.
265 @param maxSize Pointer to the return value.
266 @result Returns kIOReturnSuccess on success, or an error code otherwise.
267*/
268
269 virtual IOReturn getMaxPacketSize(UInt32 * maxSize) const;
270
271/*! @function getMinPacketSize
272 @abstract Gets the minimum packet size supported by the Ethernet
273 controller, including the frame header and FCS.
274 @param minSize Pointer to the return value.
275 @result Returns kIOReturnSuccess on success, or an error code otherwise.
276*/
277
278 virtual IOReturn getMinPacketSize(UInt32 * minSize) const;
279
280/*! @function getPacketFilters
281 @abstract Gets the set of packet filters supported by the Ethernet
282 controller in the network filter group.
283 @param filters Pointer to the return value containing a mask of
284 supported filters.
285 @result Returns kIOReturnSuccess. Drivers that override this
286 method must return kIOReturnSuccess to indicate success, or an error
287 return code otherwise.
288*/
289
290 virtual IOReturn getPacketFilters(UInt32 * filters) const;
291
292/*! @function getHardwareAddress
293 @abstract Gets the Ethernet controller's permanent station address.
294 @discussion Ethernet drivers must implement this method, by reading the
295 address from hardware and writing it to the buffer provided. This method
296 is called from the workloop context.
297 @param addrP Pointer to an IOEthernetAddress where the hardware address
298 should be returned.
299 @result Returns kIOReturnSuccess on success, or an error return code otherwise.
300*/
301
302 virtual IOReturn getHardwareAddress(IOEthernetAddress * addrP) = 0;
303
304/*! @function setHardwareAddress
305 @abstract Sets or changes the station address used by the Ethernet
306 controller.
307 @discussion This method is called in response to a client command to
308 change the station address used by the Ethernet controller. Implementation
309 of this method is optional. This method is called from the workloop context.
310 @param addrP Pointer to an IOEthernetAddress containing the new station
311 address.
312 @result The default implementation will always return kIOReturnUnsupported.
313 If overridden, drivers must return kIOReturnSuccess on success, or an error
314 return code otherwise.
315*/
316
317 virtual IOReturn setHardwareAddress(const IOEthernetAddress * addrP);
318
319/*! @function setMulticastMode
320 @abstract Enables or disables multicast mode.
321 @discussion Called by enablePacketFilter() or disablePacketFilter()
322 when there is a change in the activation state of the multicast filter
323 identified by kIOPacketFilterMulticast. This method is called from the
324 workloop context.
325 @param active True to enable multicast mode, false to disable it.
326 @result Returns kIOReturnUnsupported. If overridden, drivers must return
327 kIOReturnSuccess on success, or an error return code otherwise.
328*/
329
330 virtual IOReturn setMulticastMode(bool active);
331
332/*! @function setMulticastList
333 @abstract Sets the list of multicast addresses a multicast filter
334 should use to match against the destination address of an incoming frame.
335 @discussion This method sets the list of multicast addresses that the multicast filter
336 should use to match against the destination address of an incoming frame.
337 The frame should be accepted when a match occurs. Called when the multicast group membership of an interface
338 object is changed. Drivers that support kIOPacketFilterMulticast should
339 override this method and update the hardware multicast filter using the
340 list of Ethernet addresses provided. Perfect multicast filtering is
341 preferred if supported by the hardware, in order to reduce the number of
342 unwanted packets received. If the number of multicast addresses in the
343 list exceeds what the hardware is capable of supporting, or if perfect
344 filtering is not supported, then ideally the hardware should be programmed
345 to perform imperfect filtering, through some form of hash filtering
346 mechanism. Only as a last resort should the driver enable reception of
347 all multicast packets to satisfy this request. This method is called
348 from the workloop context, and only if the driver reports
349 kIOPacketFilterMulticast support in getPacketFilters().
350 @param addrs An array of Ethernet addresses. This argument must be
351 ignored if the count argument is 0.
352 @param count The number of Ethernet addresses in the list. This value
353 will be zero when the list becomes empty.
354 @result Returns kIOReturnUnsupported. Drivers must return kIOReturnSuccess to
355 indicate success, or an error return code otherwise.
356*/
357
358 virtual IOReturn setMulticastList(IOEthernetAddress * addrs,
359 UInt32 count);
360
361/*! @function setPromiscuousMode
362 @abstract Enables or disables promiscuous mode.
363 @discussion Called by enablePacketFilter() or disablePacketFilter()
364 when there is a change in the activation state of the promiscuous
365 filter identified by kIOPacketFilterPromiscuous. This method is
366 called from the workloop context.
367 @param active True to enable promiscuous mode, false to disable it.
368 @result Returns kIOReturnUnsupported. If overridden, drivers must return
369 kIOReturnSuccess on success, or an error return code otherwise.
370*/
371
372 virtual IOReturn setPromiscuousMode(bool active);
373
374/*! @function setWakeOnMagicPacket
375 @abstract Enables or disables the wake on Magic Packet support.
376 @discussion Called by enablePacketFilter() or disablePacketFilter()
377 when there is a change in the activation state of the Wake-on-LAN
378 filter identified by kIOEthernetWakeOnMagicPacket. This method is
379 called from the workloop context.
380 @param active True to enable support for system wake on reception
381 of a Magic Packet, false to disable it.
382 @result Returns kIOReturnUnsupported. If overridden, drivers must return
383 kIOReturnSuccess on success, or an error return code otherwise.
384*/
385
386 virtual IOReturn setWakeOnMagicPacket(bool active);
387
388protected:
389
390/*! @function createInterface
391 @abstract Creates an IOEthernetInterface object.
392 @discussion This method allocates and returns a new IOEthernetInterface instance.
393 A subclass of IONetworkController must implement this method and return
394 a matching interface object. The implementation in IOEthernetController
395 will return an IOEthernetInterface object. Subclasses of
396 IOEthernetController, such as Ethernet controller drivers, will have
397 little reason to override this implementation.
398 @result Returns a newly allocated and initialized IOEthernetInterface object.
399*/
400
401 virtual IONetworkInterface * createInterface();
402
403/*! @function free
404 @abstract Frees the IOEthernetController instance.
405 @discussion This method releases resources, and is
406 then followed by a call to super::free(). */
407
408 virtual void free();
409
410/*! @function publishProperties
411 @abstract Publishes Ethernet controller properties and capabilities.
412 @discussion This method publishes Ethernet controller properties to the property
413 table. For instance, getHardwareAddress() is called to fetch the
414 hardware address, and the address is then published to the property
415 table. This method call is synchronized by the workloop's gate,
416 and must never be called directly by subclasses.
417 @result Returns true if all properties and capabilities were discovered,
418 and published successfully, false otherwise. Returning false will
419 prevent client objects from attaching to the Ethernet controller
420 since a property that a client relies upon may be missing.
421*/
422
423 virtual bool publishProperties();
424
425/*! @function getVlanTagDemand
426@abstract Fetch the demand for hardware vlan tag stuffing
427for the given packet before it is transmitted on the network.
428@discussion A network controller that can insert 802.1Q vlan tags for output
429packets must call this method to obtain vlan tag information that it must
430insert into the given output packet.
431@param packet A mbuf containing a packet that may require vlan tag stuffing.
432@param vlanTag After calling, the low order 16 bits contain the 802.1Q priority and
433vlan ID tag in host order. The hi-order 16 bits are currently unused and should be ignored.
434@result true if vlanTag has been set and should be used.
435false if no vlan tag stuffing is required for this packet. */
436
437 OSMetaClassDeclareReservedUsed( IOEthernetController, 0);
438virtual bool getVlanTagDemand(mbuf_t m, UInt32 *vlanTag);
439
440/*! @function setVlanTag
441@abstract Encode a received packet with the vlan tag result reported
442by the hardware.
443@discussion A network controller that can strip 802.1Q vlan tag information for a
444received packet should call this method to encode the result on the
445packet, before passing it up towards the protocol stacks.
446@param packet A mbuf containing a packet that has had its 802.1q vlan tag stripped by
447the hardware.
448@param vlanTag A value in host order that contains the 802.1q vlan tag and priority
449in the low order 16 bits. The hi order word is currently unused and should be set to 0. */
450
451OSMetaClassDeclareReservedUsed( IOEthernetController, 1);
452virtual void setVlanTag(mbuf_t m, UInt32 vlanTag);
453
454 // Virtual function padding
455 OSMetaClassDeclareReservedUnused( IOEthernetController, 2);
456 OSMetaClassDeclareReservedUnused( IOEthernetController, 3);
457 OSMetaClassDeclareReservedUnused( IOEthernetController, 4);
458 OSMetaClassDeclareReservedUnused( IOEthernetController, 5);
459 OSMetaClassDeclareReservedUnused( IOEthernetController, 6);
460 OSMetaClassDeclareReservedUnused( IOEthernetController, 7);
461 OSMetaClassDeclareReservedUnused( IOEthernetController, 8);
462 OSMetaClassDeclareReservedUnused( IOEthernetController, 9);
463 OSMetaClassDeclareReservedUnused( IOEthernetController, 10);
464 OSMetaClassDeclareReservedUnused( IOEthernetController, 11);
465 OSMetaClassDeclareReservedUnused( IOEthernetController, 12);
466 OSMetaClassDeclareReservedUnused( IOEthernetController, 13);
467 OSMetaClassDeclareReservedUnused( IOEthernetController, 14);
468 OSMetaClassDeclareReservedUnused( IOEthernetController, 15);
469 OSMetaClassDeclareReservedUnused( IOEthernetController, 16);
470 OSMetaClassDeclareReservedUnused( IOEthernetController, 17);
471 OSMetaClassDeclareReservedUnused( IOEthernetController, 18);
472 OSMetaClassDeclareReservedUnused( IOEthernetController, 19);
473 OSMetaClassDeclareReservedUnused( IOEthernetController, 20);
474 OSMetaClassDeclareReservedUnused( IOEthernetController, 21);
475 OSMetaClassDeclareReservedUnused( IOEthernetController, 22);
476 OSMetaClassDeclareReservedUnused( IOEthernetController, 23);
477 OSMetaClassDeclareReservedUnused( IOEthernetController, 24);
478 OSMetaClassDeclareReservedUnused( IOEthernetController, 25);
479 OSMetaClassDeclareReservedUnused( IOEthernetController, 26);
480 OSMetaClassDeclareReservedUnused( IOEthernetController, 27);
481 OSMetaClassDeclareReservedUnused( IOEthernetController, 28);
482 OSMetaClassDeclareReservedUnused( IOEthernetController, 29);
483 OSMetaClassDeclareReservedUnused( IOEthernetController, 30);
484 OSMetaClassDeclareReservedUnused( IOEthernetController, 31);
485};
486
487/*
488 * FIXME: remove this.
489 */
490enum {
491 kIOEnetPromiscuousModeOff = false,
492 kIOEnetPromiscuousModeOn = true,
493 kIOEnetPromiscuousModeAll = true,
494 kIOEnetMulticastModeOff = false,
495 kIOEnetMulticastModeFilter = true
496};
497typedef bool IOEnetPromiscuousMode;
498typedef bool IOEnetMulticastMode;
499
500#endif /* defined(KERNEL) && defined(__cplusplus) */
501
502#endif /* !_IOETHERNETCONTROLLER_H */
503

Archive Download this file

Revision: 1622