Add iflib man pages for developers.

Doc review is probably waranted here for editing.

Submitted by:	Nicole Graziano
This commit is contained in:
Sean Bruno 2017-01-28 00:40:36 +00:00
parent 978f10562f
commit 34bac11eba
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=312909
4 changed files with 501 additions and 0 deletions

View File

@ -158,6 +158,9 @@ MAN= accept_filter.9 \
ieee80211_regdomain.9 \
ieee80211_scan.9 \
ieee80211_vap.9 \
iflibdd.9 \
iflibdi.9 \
iflibtxrx.9 \
ifnet.9 \
inittodr.9 \
insmntque.9 \

181
share/man/man9/iflibdd.9 Normal file
View File

@ -0,0 +1,181 @@
.\" $FreeBSD$
.Dd January 27, 2017
.Dt IFlIBDD(9)
.Os
.Sh NAME
.Nm iflibdd
.Nd Device Dependent Configuration Functions
.Sh SYNOPSIS
.In "ifdi_if.h"
.Ss "Soft Queue Setup and Teardown Functions"
.Ss "Mandatory Functions"
.Ft int
.Fn ifdi_queues_alloc "if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs, int nqs"
.Ft int
.Fn ifdi_queues_free "if_ctx_t ctx"
.Ss "Optional Functions"
.Ft int
.Fn ifdi_txq_setup "if_ctx_t ctx, uint16_t qid"
.Ft int
.Fn ifdi_rxq_setup "if_ctx_t ctx, uint16_t qid"
.Ss "Device Setup and Teardown Functions"
.Ss "Mandatory Functions"
.Ft int
.Fn ifdi_attach_pre "if_ctx_t ctx"
.Ft int
.Fn ifdi_attach_post "if_ctx_t ctx"
.Ft int
.Fn ifdi_detach "if_ctx_t ctx"
.Ss "Optional Functions"
.Ft void
.Fn ifdi_vlan_register "if_ctx_t ctx, uint16_t vtag"
.Ft void
.Fn ifdi_vlan_unregister "if_ctx_t ctx, uint16_t vtag"
.Ft int
.Fn ifdi_suspend "if_ctx_t ctx"
.Ft int
.Fn ifdi_resume "if_ctx_t ctx"
.Ss "Device Configuration Functions"
.Ss "Mandatory Functions"
.Ft void
.Fn ifdi_init "if_ctx_t ctx"
.Ft void
.Fn ifdi_stop "if_ctx_t ctx"
.Ft void
.Fn ifdi_multi_set "if_ctx_t ctx"
.Ft int
.Fn ifdi_mtu_set "if_ctx_t ctx, uint32_t mtu"
.Ft void
.Fn ifdi_media_status "if_ctx_t ctx, struct ifmediareq *ifr"
.Ft int
.Fn ifdi_media_change "if_ctx_t ctx"
.Ft void
.Fn ifdi_promisc_set "if_ctx_t ctx, int flags"
.Ft uint64_t
.Fn ifdi_get_counter "if_ctx_t ctx, ift_counter cnt"
.Ft void
.Fn ifdi_update_admin_status "if_ctx_t ctx"
.Ss "Optional Functions"
.Ft void
.Fn ifdi_media_set "if_ctx_t ctx"
.Ss "Interrupt enable/disable"
.Ss "Mandatory Functions"
.Ft void
.Fn ifdi_intr_enable "if_ctx_t ctx"
.Ft void
.Fn ifdi_queue_intr_enable "if_ctx_t ctx, uint16_t qid"
.Ft void
.Fn ifdi_intr_disable "if_ctx_t ctx"
.Ss IOV Support
.Ft init
.Fn iov_init "if_ctx_t, uint16_t num_vfs, const nvlist_t *params"
.Ft void
.Fn iov_uinit "if_ctx_t ctx"
.Ft void
.Fn ifdi_vflr_handle "if_ctx_t ctx"
.Ft int
.Fn ifdi_vf_add "if_ctx_t ctx, uint16_t vfnum, const nvlist_t *params"
.Ss "Optional Functions"
.Ft void
.Fn ifdi_link_intr_enable "if_ctx_t ctx"
.Ss "Optional Service Routines"
.Ft void
.Fn ifdi_timer "if_ctx_t ctx"
.Ft void
.Fn ifdi_watchdog_reset "if_ctx_t ctx"
.Ss "Additional Functions"
.Ft void
.Fn ifdi_led_func "if_ctx_t ctx, int onoff"
.Ft int
.Fn ifdi_sysctl_int_delay "if_ctx_t ctx, if_int_delay_info_t iidi"
.Ft int
.Fn ifdi_i2c_req "if_ctx_t ctx, struct ifi2creq *req"
.Sh FUNCTIONS
The above named functions are device dependent configuration functions. These routines are registerd with iflib by the driver and are called from the corresponding iflib function to configure device specific functions and registers.
.Ss Device Dependent Functions
.Ss Soft Queue Setup and Teardown
.Bl -ohang -offset indent
.It Fn ifdi_queues_alloc
Manditory queues allocation function that is called during iflib_attach. vaddrs and paddrs are arrays of virtual and physical addresses respectively of the hardware transmit and receive queues, and if relevany, any command completion queues. nqs is the number of queues per qset. For example, a driver with a single receive and transmit queue would have a nqs equal to 2.
.It Fn ifdi_queues_free
Mandatory function that frees the allocated queues and associated transmit buffers.
.It Fn ifdi_txq_setup
Optional function for each transmit queue that handles device specific initialization.
.It Fn ifdi_rxq_setup
Optional function for each receive queue that handles device specific initialization.
.El
.Ss Device Setup and Teardown
.Bl -ohang -offset indent
.It Fn ifdi_attach_pre
Mandatory function implemented by the driver to perform any attach logic that procedes interrupt and queue allocation, queue setup, and interrupt assignment.
.It Fn ifdi_attach_post
Mandatory function implemented by the driver to perform any attach logic that occurs after ifdi_attach_pre, and iflib's queue setup and MSI/MSIX(X) or legacy interrupt assignment.
.It Fn ifdi_detach
Mandatory function that frees any resources allocated by the driver in ifdi_attach_pre and ifdi_attach_post.
.It Fn ifdi_vlan_register
Optional function called by the VLAN config eventhandler. _vtag is the new VLAN tag.
.It Fn ifdi_vlan_unregister
Optional function called by the VLAN unconfig eventhandler.
.It Fn ifdi_suspend
Optional function that suspends the driver.
.It Fn ifdi_resume
Optional function that resumes a driver.
.El
.Ss Device Configuration Functions
.Bl -ohang -offset indent
.It Fn ifdi_init
Mandatory function that will initialize and bring up the hardware. For example, it will reset the chip and enable the receiver unit. It should mark the interface running, but not active (IFF_DRV_RUNNING, ~IIF_DRV_OACTIVE).
.It Fn ifdi_stop
Mandatory function that should disable all traffic on the interface by issuing a global reset on the MAC and deallocating the TX and RX buffers.
.It Fn ifdi_multi_set
Programs the interfaces multicast addresses
.It Fn ifdi_media_status
Media Ioctl Callback. Function is called whenever the user queries the status of the interface using ifconfig. The driver sets the appropriate link type and speed in ifmr->ifm_active.
.It Fn ifdi_mtu_set
Sets the mtu interface to the value of the second function parameter mtu.
.It Fn ifdi_media_change
Function is called when the user changes speed/duplex using the media/mediaopt option with ifconfig.
.It Fn ifdi_promisc_set
Enables or disables promisc settings depending upon the flags value. Flags contains the interfaces' ifnet flags.
.It Fn ifdi_get_counter
Returns the value for counter cnt depending upon counter type.
.It Fn ifdi_update_admin_status
Sets the link_up state to TRUE or FALSE depending upon the OS link state. A real check of the hardware only happens with a link interrupt.
.It Fn ifdi_media_set
Need to define
.El
.Ss Interrupt Enable/Disable
.Bl -ohang -offset indent
.It Fn ifdi_intr_enable
Mandatory function that enables all interrupts.
.It Fn ifdi_intr_disable
Mandatory function that disables all interrupts.
.It Fn ifdi_queue_intr_enable
Mandatory function that enables interrupts on queue qid.
.It Fn iov_init
Initialize num_vfs VFs.
.It Fn io_uninit
Tear down the context for all VFs.
.It Fn ifdi_vflr_handle
Handle any VFs that have reset themselves via a Function Level Reset(FLR).
.It Fn ifdi_vf_add
Set parameters in params in VF vfnum.
.El
.Ss Service Routines
.Bl -ohang -offset indent
.It ifdi_timer
Optional timer routine that will be run every 500ms.
.It ifdi_watchdog_reset
Optional function to run when a transmit queue is hung.
.El
.Ss Additional Functions
.Bl -ohang -offset indent
.It ifdi_led_func
.It ifdi_sysctl_int_delay
.It ifdi_i2c_req
.El
.Sh "SEE ALSO"
iflibtxrx(9), iflibdd(9)
.Sh AUTHORS
This manual page was written by
.An Nicole Graziano

152
share/man/man9/iflibdi.9 Normal file
View File

@ -0,0 +1,152 @@
.\" $FreeBSD$
.Dd January 27, 2017
.Dt IFlIBDI(9)
.Os
.Sh NAME
.Nm iflibdi
.Nd Device Independent Configuration Functions
.Sh SYNOPSIS
.In "ifdi_if.h"
.Ss "Device Independent Functions"
.Ft int
.Fn iflib_device_attach "device_t dev"
.Ft int
.Fn iflib_device_detach "device_t dev"
.Ft int
.Fn iflib_device_suspend "device_t dev"
.Ft int
.Fn iflib_device_resume "device_t dev"
.Ft int
.Fn iflib_device_register "device_t dev, void *softc, if_shared_ctx_t sctx, if_ctx_t *ctxp"
.Ft int
.Fn iflib_device_deregister "if_ctx_t ctx"
.Ft int
.Fn iflib_irq_alloc "if_ctx_t ctx, if_irq_t irq_info, int rid, driver_filter_t filter, void *filter_arg, driver_intr_t handler, void *arg, char *name"
.Ft int
.Fn iflib_irq_alloc_generic "if_ctx_t, ctx, if_irq_t irq, int rid, intr_type_t type, driver_filter_t *filter, void *filter_arg, int qid, char *name"
.Ft void
.Fn iflib_led_create "if_ctx_t ctx"
.Ft void
.Fn iflib_tx_intr_deferred "if_ctx_t ctx, int txqid"
.Ft void
.Fn iflib_rx_intr_deferred "if_ctx_t ctx, int rxqid"
.Ft void
.Fn iflib_link_intr_deferred "if_ctx_t ctx"
.Ft void
.Fn iflib_link_state_change "if_ctx_t ctx, int linkstate"
.Ft void
.Fn iflib_led_create "if_ctx_t ctx"
.Ft void
.Fn iflib_add_int_delay_sysctl "if_ctx_t ctx, const char *, const char *, if_int_delay_info_t, int, int"
.Ss "Global Variables"
.Vt extern struct if_txrx
.Sh DATA STRUCTURES
The \fIif_ctx_t\fP Structure is the device independent data structure that contains statistics and identifying information used to transmit and receive data packets. The interface is associated with an array of queues assigned sequentially. Each queu has its own transmit (iflib_txq_t) and receive (iflib_rxq_t) queue. The transmit queue is used to hold packets while the interface is in the process of sending another. The receive queue is used to receive packets that are awaiting processing.
.Pp
.Ss The if_ctx_t Structure
The fields of
.Vt "struct if_ctx_t"
are as follows:
.Bl -tag -width ".Va if_capabilities" -offset indent
.It Va if_softc
.Pq Vt "void"
A pointer to the driver's private state block.
.It Va ifc_dev
.Pq Vt "device_t"
The underlying device structure.
.It Va ifc_ip
.Pq Vt "if_t"
A link back to the interface structure
.It Va ifc_cpus
.Pq Vt "cpuset_t"
.It Va ifc_mutex
.Pq Vt "struct mtx"
Mutex lock used to maintain data integrity
.It Va ifc_mtx_name
.Pq Vt "char *"
The name of the mutex
.It Va ifc_txqs
.Pq Vt "iflib_txq_t"
Device independent transmit queue maintained internally by iflib
.It Va ifc_rxqs
.Pq Vt "iflib_rxq_t"
Device independent receive queue maintained internally by iflib
.It Va ifc_qsets
.Pq Vt "iflib_qset_t"
Output queue that contains a single transmit (ifc_txq_t) and receive (ifc_rxq_t) queue
.It Va ifc_if_flags
.Pq Vt "uint32_t"
Flags describing the operational parameter of the interface
.It Va ifc_in_detach
.Pq Vt "int"
.It Va ifc_link_state
.Pq Vt "int"
Describes the current link state of the Ethernet interface. It's possible values are either active or inactive.
.It Va ifc_link_irq
.Pq Vt "int"
.It Va ifc_vlan_attach_event
.Pq Vt "eventhandler_tag"
.It Va ifc_vlan_detach_event
.Pq Vt "eventhandler_tag"
.It Va ifc_pause_frames
.Pq Vt "int"
.It Va ifc_watchdog_events
.Pq Vt "int"
.It Va ifc_mac
.Pq Vt "uint8_t"
.It Va ifc_msix_mem
.Pq Vt "struct resource *"
.It Va ifc_legacy_irq
.Pq Vt "struct if_irq"
.It Va ifc_admin_task
.Pq Vt "struct grouptask"
Taskqueue task scheduled for link state change events of the interface
.It Va ifc_filter_info
.Pq Vt "struct iflib_filter_info"
Statistics and information relating to the interface device filter
.It Va ifc_media
.Pq Vt "struct ifmedia"
.It Va ifc_txrx
.Pq Vt "struct if_txrx"
.El
.Sh FUNCTIONS
The above named functions are found exclusively in iflib. They are independent of the underlying hardware type or configuration.
.Ss Device Independent Functions
.Bl -ohang -offset indent
.It Fn iflib_device_attach
Function initiates a device registration with the iflib framework. It calls the iflib_register function, which is responsible for allocating and initializing the \fIif_ctx_t\fP structure.
.It Fn iflib_device_detach
Shutdown and detach the device. Unregister vlan events, drain any dependent tasks, and release irq, pci, and msix memory.
.It Fn iflib_device_suspend
Suspend a device by calling the device dependent suspend function and bus_generic_suspend.
.It Fn iflib_device_resume
Resume a device by calling the device dependent resume function, the iflib_init_locked function, and bus_generic_resume.
.It Fn iflib_device_register
Register a device with the iflib framework. Allocate and initialize the \fIif_ctx_t\fP structure. Setup and initialize the MSI or MSI/X interrupt queues if necessary. Allocate memory for queues and qset structure setup.
.It Fn iflib_device_irq_alloc
Allocate an interrupt resource for a given rid value with an associated filter and handler function.
.It Fn iflib_device_irq_alloc_generic
Performs the same function as iflib_device_irq_alloc along with the additional functionality of adding a taskgroup. The data fields and callback function are determined by the type of interrupt, such as IFLIB_INTR_TX, IFLIB_INTR_RX, and IFLIB_INTR_ADMIN.
.It Fn iflib_led_create
Calls led_create to initialize the ctx->ifc_led_dev field
.It Fn iflib_tx_intr_deferred
Calls GROUPTASK_ENQUEUE to enqueue the transfer queues ift_task.
.It Fn iflib_rx_intr_deferred
Calls GROUPTASK_ENQUEUE to enqueue the receive queues ifr_task.
.It Fn iflib_link_intr_deferred
Calls GROUPTASK_ENQUEUE to enqueue the link task
.It Fn iflib_link_state_change
Change the interface link status to either LINK_STATE_UP or LINK_STATE_DOWN as specified by the second argument to the function.
\fBInterface Link States\fP
The following link states are currently defined:
LINK_STATE_UP The link is up.
LINK_STATE_DOWN The link is down.
.It Fn iflib_add_int_delay_sysctl
Modifies settings to user defined values for a given set of variables.
.El
.Sh "SEE ALSO"
iflibtxrx(9), iflibdd(9)
.Sh AUTHORS
This manual page was written by
.An Nicole Graziano

165
share/man/man9/iflibtxrx.9 Normal file
View File

@ -0,0 +1,165 @@
.\" $FreeBSD$
.Dd January 27, 2017
.Dt IFlIBTXTX(9)
.Os
.Sh NAME
.Nm iflibtxrx
.Nd Device Dependent Transmit and Receive Functions
.Sh SYNOPSIS
.In "ifdi_if.h"
.Ss "Interface Manipulation Functions"
.Ft int
.Fn isc_txd_encap "void *sc, if_pkt_into_t pi"
.Ft void
.Fn isc_txd_flush "void *sc, uint16_t qid, uint32_t _pidx_or_credits_"
.Ft int *
.Fn isc_txd_credits_update "void *sc, uint16_t qid, uint32_t credits"
.Ft int *
.Fn isc_rxd_available "void *sc, uint16_t qsid, uint32_t cidx"
.Ft void *
.Fn isc_rxd_refill "void *sc, uint16_t qsid, uint8_t flid, uint32_t pidx, uint64_t *paddrs, caddr_t *vaddrs, uint16_t count"
.Ft void *
.Fn isc_rxd_flush "void *sc, uint16_t qsid, uint8_t flid, uint32_t pidx"
.Ft int
.Fn isc_rxd_pkt_get "void *sc, if_rxd_info_t ri"
.Ss "Global Variables"
.Vt extern struct if_txrx
.Sh DATA STRUCTURES
The device dependent mechanisms for handling packet transmit and receive are primarily defined by the functions named above. The if_pkt_info data structure contains statistics and identifying info necessary for packet transmission. While the data structure for packet receipt is the if_rxd_info structure.
.Pp
.Ss The if_pkt_info Structure
The fields of
.Vt "struct if_pkt_info"
are as follows:
.Bl -tag -width ".Va if_capabilities" -offset indent
.It Va ipi_len
.Pq Vt "uint32_t"
Denotes the size of packet to be sent on the transmit queue.
.It Va ipi_segs
.Pq Vt "bus_dma_segment_t *"
A pointer to the bus_dma_segment of the device independent transfer queue defined in iflib.
.It Va ipi_qsidx
Unique index value assigned sequentially to each transmit queue. Used to reference the currently transmitting queue.
.It Va ipi_nsegs
.Pq Vt "uint16_t"
Number of descriptors to be read into the device dependent transfer descriptors.
.It Va ipi_ndescs
.Pq Vt "uint16_t"
Number of descriptors in use. Calculated by subtracting the old pidx value from the new pidx value.
.It Va ipi_flags
.Pq Vt "uint16_t"
Flags defined on a per packet basis.
.It Va ipi_pidx
.Pq Vt "uint32_t"
Value of first pidx sent to the isc_encap function for encapsulation and subsequent transmission.
.It Va ipi_new_pidx
.Pq Vt "uint32_t"
Value set after the termination of the isc_encap function. This value will become the first pidx sent to the isc-encap the next time that the function is called.
.It Va \fBThe Following Fields Are Used For Offload Handling\fP
.It Va ipi_csum_flags
.Pq Vt "uint64_t"
Flags describing the checksum values. Used on a per packet basis.
.It Va ipi_tso_segsz
.Pq Vt "uint16_t"
Size of the TSO Segment Size.
.It Va ipi_mflags
.Pq Vt "uint16_t"
Flags describing the operational parameters of the mbuf.
.It Va ipi_vtag
.Pq Vt "uint16_t"
Contains the VLAN information in the Ethernet Frame.
.It Va ipi_etype
.Pq Vt "uint16_t"
Type of ethernet header protocol as contained by the struct ether_vlan_header.
.It Va ipi_ehrdlen
.Pq Vt "uint8_t"
Length of the Ethernet Header.
.It Va ipi_ip_hlen
.Pq Vt "uint8_t"
Length of the TCP Header
.It Va ipi_tcp_hlen
.Pq Vt "uint8_t"
Length of the TCP Header.
.It Va ipi_tcp_hflags
.Pq Vt "uint8_t"
Flags describing the operational parameters of the TCP Header.
.It Va ipi_ipproto
.Pq Vt "uint8_t"
Specifies the type of IP Protocol in use. Example TCP, UDP, or SCTP.
.El
.Ss The if_rxd_info Structure
The fields of
.Vt "struct if_rxd_info"
are as follows:
.Bl -tag -width ".Va if_capabilities" -offset indent
.It Va iri_qsidx
.Pq Vt "uint16_t"
Unique index value assigned sequentially to each receive queue. Used to reference the currently receiving queue.
.It Va iri_vtag
.Pq Vt "uint16_t"
Contains the VLAN information in the Ethernet Frame.
.It Va iri_len
.Pq Vt "uint16_t"
Denotes the size of a received packet.
.It Va iri_next_offset
.Pq Vt "uint16_t"
Denotes the offset value for the next packet to be receive. A Null value signifies the end of packet.
.It Va iri_cidx
.Pq Vt "uint32_t"
Denotes the index value of the packet currently being processed in the consumer queue.
.It Va iri_flowid
.Pq Vt "uint32_t"
Value of the RSS hash for the packet.
.It Va iri_flags
.Pq Vt "uint"
Flags describing the operational parameters of the mbuf contained in the receive packet.
.It Va iri_csum_flags
.Pq Vt "uint32_t"
Flags describing the checksum value contained in the receive packet.
.It Va iri_csum_data
.Pq Vt "uint32_t"
Checksum data contained in the mbuf packet header.
.It Va iri_m
.Pq Vt "struct mbuf *"
A mbuf for drivers that manage their own receive queues.
.It Va iri_ifp
.Pq Vt "struct ifnet *"
A link back to the interface structure. Utilized by drivers that have multiple interface per softc.
.It Va iri_rsstype
.Pq Vt "uint8_t"
The value of the RSS hash type.
.It Va iri_pad
.Pq Vt "uint8_t"
The length of any padding contained by the received data.
.It Va iri_qidx
.Pq Vt "uint8_t"
Represents the type of queue event. If value >= 0 then it is the freelist id otherwise it is a completion queue event.
.El
.Sh FUNCTIONS
All function calls are associated exclusively with either packet transmission or receipt.
The void *sc passed as the first arguement to all of the following functions repressents the driver's softc.
.Ss Transmit Packet Functions
.Bl -ohang -offset indent
.It Fn isc_txd_encap
Transmit function that sends a packet on an interface. The if_pkt_info data structure contains data information fields describing the packet. This function returns 0 if successful, otherwise an error value is returned.
.It Fn isc_txd_flush
Flush function is called immediately after the isc_txd_encap function transmits a packet. It updates the hardware producer index or increments the descriptors used to pidx_or_credits in the queue designated by the qid number. This is often referred to as poking the doorbell register.
.It Fn isc_txd_credits_update
Credit function advances the buffer ring and calculates the credits (descriptors) processed. Until the I/O is complete it cleans the range in case of multisegments and updates the count of processed packets. The function returns the number of processed credits.
.El
.Ss Receive Packet Functions
.Bl -ohang -offset indent
.It Fn isc_rxd_available
Function calculates the remaining number of descriptors from a position given by idx. The function returns this value.
.It Fn isc_rxd_refill
Starting with the physical address paddrs, the function reads a packet into the rx_ring until a value designated by count is reached. vaddrs is typically not needed and is provided for devices that place their own metadata in the packet header.
.It Fn isc_rxd_flush
Flush function updates the producer pointer on the free list flid in queue set number qid to pidx to reflect the presence of new buffers.
.It Fn isc_rxd_pkt_get
Process a single software descriptor. rxr->rx_base[i] contains a descriptor that describes a received packet. Hardware specific information about the buffer referred to by ri is returned in the data structure if_rxd_info
.El
.Sh "SEE ALSO"
iflibdd(9), iflibdi(9)
.Sh AUTHORS
This manual page was written by
.An Nicole Graziano