+#ifdef KERNEL_PRIVATE
+/* Valid values for version */
+#define IFNET_INIT_VERSION_2 2
+#define IFNET_INIT_CURRENT_VERSION IFNET_INIT_VERSION_2
+
+/* Valid values for flags */
+#define IFNET_INIT_LEGACY 0x1 /* legacy network interface model */
+#define IFNET_INIT_INPUT_POLL 0x2 /* opportunistic input polling model */
+
+/*
+ @typedef ifnet_pre_enqueue_func
+ @discussion ifnet_pre_enqueue_func is called for each outgoing packet
+ for the interface. The driver may perform last-minute changes
+ on the (fully formed) packet, but it is responsible for calling
+ ifnet_enqueue() to enqueue the packet upon completion.
+ @param interface The interface being sent on.
+ @param data The packet to be sent.
+ */
+typedef errno_t (*ifnet_pre_enqueue_func)(ifnet_t interface, mbuf_t data);
+
+/*
+ @typedef ifnet_start_func
+ @discussion ifnet_start_func is used to indicate to the driver that
+ one or more packets may be dequeued by calling ifnet_dequeue()
+ or ifnet_dequeue_multi(). This routine gets invoked when
+ ifnet_start() is called; the ifnet_start_func callback will
+ be executed within the context of a dedicated kernel thread,
+ hence it is guaranteed to be single threaded. The driver must
+ employ additional serializations if this callback routine is
+ to be called directly from another context, in order to prevent
+ race condition related issues (e.g. out-of-order packets.)
+ The dequeued packets will be fully formed packets (including
+ frame headers). The packets must be freed by the driver.
+ @param interface The interface being sent on.
+ */
+typedef void (*ifnet_start_func)(ifnet_t interface);
+
+/*
+ @typedef ifnet_input_poll_func
+ @discussion ifnet_input_poll_func is called by the network stack to
+ retrieve one or more packets from the driver which implements
+ the new driver input model.
+ @param interface The interface to retrieve the packets from.
+ @param flags For future use.
+ @param max_count The maximum number of packets to be dequeued.
+ @param first_packet Pointer to the first packet being dequeued.
+ @param last_packet Pointer to the last packet being dequeued.
+ @param cnt Pointer to a storage for the number of packets dequeued.
+ @param len Pointer to a storage for the total length (in bytes)
+ of the dequeued packets.
+ */
+typedef void (*ifnet_input_poll_func)(ifnet_t interface, u_int32_t flags,
+ u_int32_t max_count, mbuf_t *first_packet, mbuf_t *last_packet,
+ u_int32_t *cnt, u_int32_t *len);
+
+/*
+ @enum Interface control commands
+ @abstract Constants defining control commands.
+ @constant IFNET_CTL_SET_INPUT_MODEL Set input model.
+ @constant IFNET_CTL_GET_INPUT_MODEL Get input model.
+ */
+enum {
+ IFNET_CTL_SET_INPUT_MODEL = 1,
+ IFNET_CTL_GET_INPUT_MODEL = 2,
+};
+
+/*
+ @typedef ifnet_ctl_cmd_t
+ @abstract Storage type for the interface control command.
+ */
+typedef u_int32_t ifnet_ctl_cmd_t;
+
+/*
+ @enum Interface model sub-commands
+ @abstract Constants defining model sub-commands.
+ @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
+ proceed to pushing the packets up to the network stack as in
+ the legacy input model, and if applicable, the driver should
+ also enable receive interrupt for the hardware. During get,
+ this indicates that the driver is currently operating in
+ the legacy/push input model.
+ @constant IFNET_MODEL_INPUT_POLL_ON Polling is active. When set, the
+ network stack will begin to invoke the input_poll callback to
+ retrieve packets from the driver until the next time polling
+ is turned off; the driver should no longer be pushing packets
+ up to the network stack, and if applicable, the driver should
+ also disable receive interrupt for the hardware. During get,
+ this indicates that the driver is currently operating in
+ the new/pull input model.
+ */
+enum {
+ IFNET_MODEL_INPUT_POLL_OFF = 0,
+ IFNET_MODEL_INPUT_POLL_ON = 1,
+};
+
+/*
+ @typedef ifnet_model_t
+ @abstract Storage type for the interface model sub-command.
+ */
+typedef u_int32_t ifnet_model_t;
+
+/*
+ @struct ifnet_model_params
+ @discussion This structure is used as parameter to the ifnet model
+ sub-commands.
+ @field model The interface model.
+ */
+struct ifnet_model_params {
+ ifnet_model_t model;
+ u_int32_t reserved[3];
+};
+
+/*
+ @typedef ifnet_ctl_func
+ @discussion ifnet_ctl_func is called by the network stack to inform
+ about changes in parameters, or retrieve the parameters
+ related to the output or input processing or capabilities.
+ @param interface The interface.
+ @param cmd The ifnet_ctl_cmd_t interface control command.
+ @param arglen The length of the command argument.
+ @param arg The command argument.
+ @result 0 upon success, otherwise errno error.
+ */
+typedef errno_t (*ifnet_ctl_func)(ifnet_t interface, ifnet_ctl_cmd_t cmd,
+ u_int32_t arglen, void *arg);
+
+/*
+ @struct ifnet_init_eparams
+ @discussion This structure is used to define various properties of
+ the interface when calling ifnet_allocate_extended. A copy of
+ these values will be stored in the ifnet and cannot be modified
+ while the interface is attached.
+ @field ver The current structure version (IFNET_INIT_CURRENT_VERSION)
+ @field len The length of this structure.
+ @field flags See above values for flags.
+ @field uniqueid An identifier unique to this instance of the
+ interface.
+ @field uniqueid_len The length, in bytes, of the uniqueid.
+ @field name The interface name (i.e. en).
+ @field unit The interface unit number (en0's unit number is 0).
+ @field family The interface family.
+ @field type The interface type (see sys/if_types.h). Must be less
+ than 256. For new types, use IFT_OTHER.
+ @field sndq_maxlen The maximum size of the output queue; valid only
+ if IFNET_INIT_LEGACY is not set.
+ @field output The output function for the interface. Every packet the
+ stack attempts to send through this interface will go out
+ 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 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_bw The effective output bandwidth (in bits per second.)
+ @field output_bw_max The maximum theoretical output bandwidth
+ (in bits per second.)
+ @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.
+ @field input_ctl The input control function for the interface, valid
+ only if IFNET_INIT_LEGACY is not set and only if opportunistic
+ input polling is enabled via IFNET_INIT_INPUT_POLL flag.
+ @field rcvq_maxlen The size of the driver's receive ring or the total
+ count of descriptors used in the receive path; valid only if
+ IFNET_INIT_INPUT_POLL is set.
+ @field input_bw The effective input bandwidth (in bits per second.)
+ @field input_bw_max The maximum theoretical input bandwidth
+ (in bits per second.)
+ @field demux The function used to determine the protocol family of an
+ incoming packet.
+ @field add_proto The function used to attach a protocol to this
+ interface.
+ @field del_proto The function used to remove a protocol from this
+ interface.
+ @field framer The function used to frame outbound packets, may be NULL.
+ @field softc Driver specific storage. This value can be retrieved from
+ the ifnet using the ifnet_softc function.
+ @field ioctl The function used to handle ioctls.
+ @field set_bpf_tap The function used to set the bpf_tap function.
+ @field detach The function called to let the driver know the interface
+ has been detached.
+ @field event The function to notify the interface of various interface
+ specific kernel events.
+ @field broadcast_addr The link-layer broadcast address for this
+ interface.
+ @field broadcast_len The length of the link-layer broadcast address.
+*/
+struct ifnet_init_eparams {
+ u_int32_t ver; /* required */
+ u_int32_t len; /* required */
+ u_int32_t flags; /* optional */
+
+ /* used to match recycled interface */
+ const void *uniqueid; /* optional */
+ u_int32_t uniqueid_len; /* optional */
+
+ /* used to fill out initial values for interface */
+ const char *name; /* required */
+ u_int32_t unit; /* required */
+ ifnet_family_t family; /* required */
+ u_int32_t type; /* required */
+ u_int32_t sndq_maxlen; /* optional, only for new model */
+ ifnet_output_func output; /* required only for legacy model */
+ ifnet_pre_enqueue_func pre_enqueue; /* optional, only for new model */
+ 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_int64_t output_bw; /* optional */
+ u_int64_t output_bw_max; /* optional */
+ u_int64_t _reserved[4]; /* 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 */
+ u_int32_t __reserved; /* for future use */
+ u_int64_t input_bw; /* optional */
+ u_int64_t input_bw_max; /* optional */
+ u_int64_t ___reserved[4]; /* for future use */
+ ifnet_demux_func demux; /* required */
+ ifnet_add_proto_func add_proto; /* required */
+ ifnet_del_proto_func del_proto; /* required */
+ ifnet_check_multi check_multi; /* required for non point-to-point interfaces */
+ ifnet_framer_func framer; /* optional */
+ void *softc; /* optional */
+ ifnet_ioctl_func ioctl; /* optional */
+ ifnet_set_bpf_tap set_bpf_tap; /* deprecated */
+ ifnet_detached_func detach; /* optional */
+ ifnet_event_func event; /* optional */
+ const void *broadcast_addr; /* required for non point-to-point interfaces */
+ u_int32_t broadcast_len; /* required for non point-to-point interfaces */
+ u_int64_t ____reserved[4]; /* for future use */
+};
+#endif /* KERNEL_PRIVATE */
+