/*
- * Copyright (c) 2004-2013 Apple Inc. All rights reserved.
+ * Copyright (c) 2004-2015 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#include <sys/kernel_types.h>
#ifdef KERNEL_PRIVATE
+struct if_interface_state;
#include <sys/kpi_mbuf.h>
#endif /* KERNEL_PRIVATE */
#ifdef XNU_KERNEL_PRIVATE
#define KPI_INTERFACE_EMBEDDED 0
#else
-#if TARGET_OS_EMBEDDED
-#define KPI_INTERFACE_EMBEDDED 1
-#else
#define KPI_INTERFACE_EMBEDDED 0
#endif
-#endif
struct timeval;
struct sockaddr;
/*!
@enum Interface Families
@abstract Constants defining interface families.
+ @discussion
@constant IFNET_FAMILY_ANY Match interface of any family type.
@constant IFNET_FAMILY_LOOPBACK A software loopback interface.
@constant IFNET_FAMILY_ETHERNET An Ethernet interface.
IFNET_SUBFAMILY_BLUETOOTH = 2,
IFNET_SUBFAMILY_WIFI = 3,
IFNET_SUBFAMILY_THUNDERBOLT = 4,
+ IFNET_SUBFAMILY_RESERVED = 5,
};
/*
/*!
@enum BPF tap mode
@abstract Constants defining interface families.
+ @discussion
@constant BPF_MODE_DISABLED Disable bpf.
@constant BPF_MODE_INPUT Enable input only.
@constant BPF_MODE_OUTPUT Enable output only.
/*!
@enum Interface Abilities
@abstract Constants defining interface offload support.
+ @discussion
@constant IFNET_CSUM_IP Hardware will calculate IPv4 checksums.
@constant IFNET_CSUM_TCP Hardware will calculate TCP checksums.
@constant IFNET_CSUM_UDP Hardware will calculate UDP checksums.
/*
@enum Interface control commands
@abstract Constants defining control commands.
+ @discussion
@constant IFNET_CTL_SET_INPUT_MODEL Set input model.
@constant IFNET_CTL_GET_INPUT_MODEL Get input model.
@constant IFNET_CTL_SET_LOG Set logging level.
/*
@enum Interface model sub-commands
@abstract Constants defining model sub-commands.
+ @discussion
@constant IFNET_MODEL_INPUT_POLL_OFF Polling is inactive. When set,
the network stack will no longer invoke the input_poll callback
until the next time polling is turned on; the driver should
@abstract Constants defining logging levels/priorities. A level
includes all other levels below it. It is expected that
verbosity increases along with the level.
+ @discussion
@constant IFNET_LOG_DEFAULT Revert to default logging level.
@constant IFNET_LOG_ALERT Log actions that must be taken immediately.
@constant IFNET_LOG_CRITICAL Log critical conditions.
@enum Interface logging facilities
@abstract Constants defining the logging facilities which
are to be configured with the specified logging level.
+ @discussion
@constant IFNET_LOGF_DLIL The DLIL layer.
@constant IFNET_LOGF_FAMILY The networking family layer.
@constant IFNET_LOGF_DRIVER The device driver layer.
/*
@enum Interface logging category
@abstract Constants defininig categories for issues experienced.
+ @discussion
@constant IFNET_LOGCAT_CONNECTIVITY Connectivity related issues.
@constant IFNET_LOGCAT_QUALITY Quality/fidelity related issues.
@constant IFNET_LOGCAT_PERFORMANCE Performance related issues.
through this function.
@field pre_enqueue The pre_enqueue function for the interface, valid
only if IFNET_INIT_LEGACY is not set, and optional if it is set.
- @field start The start function for the interface, valid only if
- IFNET_INIT_LEGACY is not set, and required if it is set.
+ @field start The start function for the interface, valid and required
+ only if IFNET_INIT_LEGACY is not set.
@field output_ctl The output control function for the interface, valid
only if IFNET_INIT_LEGACY is not set.
@field output_sched_model The IFNET_SCHED_MODEL value for the output
queue, as defined in net/if.h
+ @field output_target_qdelay The target queue delay is used for
+ dynamically sizing the output queue, valid only if
+ IFNET_INIT_LEGACY is not set.
@field output_bw The effective output bandwidth (in bits per second.)
@field output_bw_max The maximum theoretical output bandwidth
(in bits per second.)
@field output_lt The effective output latency (in nanosecond.)
@field output_lt_max The maximum theoretical output latency
(in nanosecond.)
+ @field start_delay_qlen The maximum length of output queue for
+ delaying start callback to the driver. This is an
+ optimization for coalescing output packets.
+ @field start_delay_timeout The timeout in microseconds to delay
+ start callback. If start_delay_qlen number of packets are
+ not in the output queue when the timer fires, the start
+ callback will be invoked. Maximum allowed value is
+ 20ms (in microseconds).
@field input_poll The poll function for the interface, valid only if
IFNET_INIT_LEGACY is not set and only if IFNET_INIT_INPUT_POLL
is set.
ifnet_start_func start; /* required only for new model */
ifnet_ctl_func output_ctl; /* optional, only for new model */
u_int32_t output_sched_model; /* optional, only for new model */
- u_int32_t reserved; /* for future use */
+ u_int32_t output_target_qdelay; /* optional, only for new model, value in ms */
u_int64_t output_bw; /* optional */
u_int64_t output_bw_max; /* optional */
u_int64_t output_lt; /* optional */
u_int64_t output_lt_max; /* optional */
- u_int64_t _reserved[2]; /* for future use */
+ u_int16_t start_delay_qlen; /* optional */
+ u_int16_t start_delay_timeout; /* optional */
+ u_int32_t _reserved[3]; /* for future use */
ifnet_input_poll_func input_poll; /* optional, ignored for legacy model */
ifnet_ctl_func input_ctl; /* required for opportunistic polling */
u_int32_t rcvq_maxlen; /* optional, only for opportunistic polling */
*/
extern int ifnet_link_quality(ifnet_t interface);
+/*
+ @function ifnet_set_interface_state
+ @discussion Sets the interface state for the ifnet.
+ @param interface Interface for which the interface state should
+ be set to.
+ @param if_interface_state as defined in net/if_var.h.
+ @result 0 on success otherwise the errno error. EINVAL if quality
+ is not a valid value. ENXIO if the interface is not attached.
+*/
+extern errno_t ifnet_set_interface_state(ifnet_t interface,
+ struct if_interface_state *if_interface_state);
+
+/*
+ @function ifnet_get_interface_state
+ @discussion Returns the interface state for the ifnet.
+ @param if_interface_state to ret.
+ @result 0 on success, errno otherwise
+*/
+extern int ifnet_get_interface_state(ifnet_t interface,
+ struct if_interface_state *if_interface_state);
+
/*
@struct ifnet_llreach_info
@discussion This structure is used to describe the link-layer
/*!
@enum Interface wake properties
@abstract Constants defining Interface wake properties.
+ @discussion
@constant IFNET_WAKE_ON_MAGIC_PACKET Wake on Magic Packet.
*/
enum {
*/
extern errno_t ifnet_get_local_ports(ifnet_t ifp, u_int8_t *bitfield);
+#define IFNET_GET_LOCAL_PORTS_WILDCARDOK 0x01
+#define IFNET_GET_LOCAL_PORTS_NOWAKEUPOK 0x02
+#define IFNET_GET_LOCAL_PORTS_TCPONLY 0x04
+#define IFNET_GET_LOCAL_PORTS_UDPONLY 0x08
+#define IFNET_GET_LOCAL_PORTS_RECVANYIFONLY 0x10
+#define IFNET_GET_LOCAL_PORTS_EXTBGIDLEONLY 0x20
+#define IFNET_GET_LOCAL_PORTS_ACTIVEONLY 0x40
/*
@function ifnet_get_local_ports_extended
@discussion Returns a bitfield indicating which local ports of the
all interfaces.
@param protocol The protocol family of the sockets. PF_UNSPEC (0)
means all protocols, otherwise PF_INET or PF_INET6.
- @param wildcardok A boolean value (0 or 1) indicating whether or not
- the list of local ports should include those that are used
- by sockets that aren't bound to any local address.
+ @param flags A bitwise of the following flags:
+ IFNET_GET_LOCAL_PORTS_WILDCARDOK: When bit is set,
+ the list of local ports should include those that are
+ used by sockets that aren't bound to any local address.
+ IFNET_GET_LOCAL_PORTS_NOWAKEUPOK: When bit is
+ set, the list of local ports should return all sockets
+ including the ones that do not need a wakeup from sleep.
+ Sockets that do not want to wake from sleep are marked
+ with a socket option.
+ IFNET_GET_LOCAL_PORTS_TCPONLY: When bit is set, the list
+ of local ports should return the ports used by TCP sockets.
+ IFNET_GET_LOCAL_PORTS_UDPONLY: When bit is set, the list
+ of local ports should return the ports used by UDP sockets.
+ only.
+ IFNET_GET_LOCAL_PORTS_RECVANYIFONLY: When bit is set, the
+ port is in the list only if the socket has the option
+ SO_RECV_ANYIF set
+ IFNET_GET_LOCAL_PORTS_EXTBGIDLEONLY: When bit is set, the
+ port is in the list only if the socket has the option
+ SO_EXTENDED_BK_IDLE set
+ IFNET_GET_LOCAL_PORTS_ACTIVETCPONLY: When bit is set, the
+ port is in the list only if the socket is not in a final TCP
+ state or the connection is not idle in a final TCP state
@param bitfield A pointer to 8192 bytes.
@result Returns 0 on success.
*/
extern errno_t ifnet_get_local_ports_extended(ifnet_t ifp,
- protocol_family_t protocol, u_int32_t wildcardok, u_int8_t *bitfield);
+ protocol_family_t protocol, u_int32_t flags, u_int8_t *bitfield);
/******************************************************************************/
/* for reporting issues */
@enum Per packet phy level transmit completion status values
@abstract Constants defining possible completion status values
A driver may support all or some of these values
+ @discussion
@constant IFNET_TX_COMPL_SUCCESS link transmission succeeded
@constant IFNET_TX_COMPL_FAIL link transmission failed
@constant IFNET_TX_COMPL_ABORTED link transmission aborted, may retry
*/
extern errno_t
ifnet_get_delegate(ifnet_t ifp, ifnet_t *pdelegated_ifp);
+
+/*************************************************************************/
+/* for interface keep alive offload support */
+/*************************************************************************/
+
+#define IFNET_KEEPALIVE_OFFLOAD_FRAME_DATA_SIZE 128
+struct ifnet_keepalive_offload_frame {
+ u_int8_t data[IFNET_KEEPALIVE_OFFLOAD_FRAME_DATA_SIZE]; /* data bytes */
+#define IFNET_KEEPALIVE_OFFLOAD_FRAME_IPSEC 0x0
+#define IFNET_KEEPALIVE_OFFLOAD_FRAME_AIRPLAY 0x1
+ u_int8_t type; /* type of application */
+ u_int8_t length; /* Number of valid data bytes including offset */
+ u_int16_t interval; /* Keep alive interval in seconds */
+#define IFNET_KEEPALIVE_OFFLOAD_FRAME_ETHERTYPE_IPV4 0x0
+#define IFNET_KEEPALIVE_OFFLOAD_FRAME_ETHERTYPE_IPV6 0x1
+ u_int8_t ether_type; /* Ether type IPv4 or IPv6 */
+ u_int8_t __reserved[3]; /* For future */
+};
+
+/*
+ @function ifnet_get_keepalive_offload_frames
+ @discussion Fills out frames_array with IP packets to send at
+ periodic intervals as Keep-alive or heartbeat messages.
+ These are UDP datagrams. This can be used to offload
+ IPSec keep alives.
+ @param ifp The interface to send frames out on. This is used to
+ select which sockets or IPSec SAs should generate the
+ packets.
+ @param frames_array An array of ifnet_keepalive_offload_frame
+ structs. This is allocated by the caller, and has
+ frames_array_count frames of valid memory.
+ @param frames_array_count The number of valid frames allocated
+ by the caller in frames_array
+ @param frame_data_offset The offset in bytes into each frame data
+ at which the IPv4/IPv6 packet and payload should be written
+ @param used_frames_count The returned number of frames that were
+ filled out with valid information.
+ @result Returns 0 on success, error number otherwise.
+*/
+extern errno_t ifnet_get_keepalive_offload_frames(ifnet_t ifp,
+ struct ifnet_keepalive_offload_frame *frames_array,
+ u_int32_t frames_array_count, size_t frame_data_offset,
+ u_int32_t *used_frames_count);
+
+/*************************************************************************/
+/* Link level notifications */
+/*************************************************************************/
+/*
+ @function ifnet_link_status_report
+ @discussion A KPI to let the driver provide link specific
+ status information to the protocol stack. The KPI will
+ copy contents from the buffer based on the version and
+ length provided by the driver. The contents of the buffer
+ will be read but will not be modified.
+ @param ifp The interface that is generating the report
+ @param buffer Buffer containing the link specific information
+ for this interface. It is the caller's responsibility
+ to free this buffer.
+ @param buffer_len Valid length of the buffer provided by the caller
+ @result Returns 0 on success, error number otherwise.
+*/
+extern errno_t ifnet_link_status_report(ifnet_t ifp, const void *buffer,
+ size_t buffer_len);
+
+/*************************************************************************/
+/* Packet preamble */
+/*************************************************************************/
+/*!
+ @function ifnet_set_packetpreamblelen
+ @discussion
+ Allows a driver to specify a leading space to be
+ reserved in front of the link layer header.
+ The preamble is logically adjoining the link layer which
+ itself is logically contiguous to the network protocol header
+ (e.g. IP).
+ There is no guarantee that packets being sent to the
+ driver has leading space reserved for the preamble.
+ There is also no guarantee the packet will be laid out in a
+ contiguous block of memory.
+ The network protocol header is 32 bit aligned and this dictates
+ the alignment of the link layer header which in turn affects
+ the alignment the packet preamble.
+ This function is intended to be called by the driver. A kext
+ must not call this function on an interface the kext does not
+ own.
+ @param interface The interface.
+ @param len The length of the packet preamble.
+ @result 0 on success otherwise the errno error.
+ */
+extern errno_t ifnet_set_packetpreamblelen(ifnet_t interface, u_int32_t len);
+
+/*!
+ @function ifnet_packetpreamblelen
+ @param interface The interface.
+ @result The current packet preamble length.
+ */
+extern u_int32_t ifnet_packetpreamblelen(ifnet_t interface);
+
+/*!
+ @function ifnet_maxpacketpreamblelen
+ @result The maximum packet preamble length supported by the system
+ */
+extern u_int32_t ifnet_maxpacketpreamblelen(void);
+
+
#endif /* KERNEL_PRIVATE */
__END_DECLS