134bac11eSSean Bruno.\" $FreeBSD$ 2*a3cea1deSKevin Lo.Dd May 21, 2019 3fa504546SEnji Cooper.Dt IFLIBDI 9 434bac11eSSean Bruno.Os 534bac11eSSean Bruno.Sh NAME 634bac11eSSean Bruno.Nm iflibdi 734bac11eSSean Bruno.Nd Device Independent Configuration Functions 834bac11eSSean Bruno.Sh SYNOPSIS 934bac11eSSean Bruno.In "ifdi_if.h" 1034bac11eSSean Bruno.Ss "Device Independent Functions" 1134bac11eSSean Bruno.Ft int 12fa504546SEnji Cooper.Fo iflib_device_attach 13fa504546SEnji Cooper.Fa "device_t dev" 14fa504546SEnji Cooper.Fc 1534bac11eSSean Bruno.Ft int 16fa504546SEnji Cooper.Fo iflib_device_detach 17fa504546SEnji Cooper.Fa "device_t dev" 18fa504546SEnji Cooper.Fc 1934bac11eSSean Bruno.Ft int 20fa504546SEnji Cooper.Fo iflib_device_suspend 21fa504546SEnji Cooper.Fa "device_t dev" 22fa504546SEnji Cooper.Fc 2334bac11eSSean Bruno.Ft int 24fa504546SEnji Cooper.Fo iflib_device_resume 25fa504546SEnji Cooper.Fa "device_t dev" 26fa504546SEnji Cooper.Fc 2734bac11eSSean Bruno.Ft int 28fa504546SEnji Cooper.Fo iflib_device_register 29fa504546SEnji Cooper.Fa "device_t dev" 30fa504546SEnji Cooper.Fa "void *softc" 31fa504546SEnji Cooper.Fa "if_shared_ctx_t sctx" 32fa504546SEnji Cooper.Fa "if_ctx_t *ctxp" 33fa504546SEnji Cooper.Fc 3434bac11eSSean Bruno.Ft int 35fa504546SEnji Cooper.Fo iflib_device_deregister 36fa504546SEnji Cooper.Fa "if_ctx_t ctx" 37fa504546SEnji Cooper.Fc 3834bac11eSSean Bruno.Ft int 39fa504546SEnji Cooper.Fo iflib_irq_alloc 40fa504546SEnji Cooper.Fa "if_ctx_t ctx" 41fa504546SEnji Cooper.Fa "if_irq_t irq_info" 42fa504546SEnji Cooper.Fa "int rid" 43fa504546SEnji Cooper.Fa "driver_filter_t filter" 44fa504546SEnji Cooper.Fa "void *filter_arg" 45fa504546SEnji Cooper.Fa "driver_intr_t handler" 46fa504546SEnji Cooper.Fa "void *arg" 47fa504546SEnji Cooper.Fa "char *name" 48fa504546SEnji Cooper.Fc 4934bac11eSSean Bruno.Ft int 50fa504546SEnji Cooper.Fo iflib_irq_alloc_generic 51fa504546SEnji Cooper.Fa "if_ctx_t ctx" 52fa504546SEnji Cooper.Fa "if_irq_t irq" 53fa504546SEnji Cooper.Fa "int rid" 54fa504546SEnji Cooper.Fa "intr_type_t type" 55fa504546SEnji Cooper.Fa "driver_filter_t *filter" 56fa504546SEnji Cooper.Fa "void *filter_arg" 57fa504546SEnji Cooper.Fa "int qid" 58fa504546SEnji Cooper.Fa "char *name" 59fa504546SEnji Cooper.Fc 6034bac11eSSean Bruno.Ft void 61fa504546SEnji Cooper.Fo iflib_led_create 62fa504546SEnji Cooper.Fa "if_ctx_t ctx" 63fa504546SEnji Cooper.Fc 6434bac11eSSean Bruno.Ft void 65fa504546SEnji Cooper.Fo iflib_tx_intr_deferred 66fa504546SEnji Cooper.Fa "if_ctx_t ctx" 67fa504546SEnji Cooper.Fa "int txqid" 68fa504546SEnji Cooper.Fc 6934bac11eSSean Bruno.Ft void 70fa504546SEnji Cooper.Fo iflib_rx_intr_deferred 71fa504546SEnji Cooper.Fa "if_ctx_t ctx" 72fa504546SEnji Cooper.Fa "int rxqid" 73fa504546SEnji Cooper.Fc 7434bac11eSSean Bruno.Ft void 75fa504546SEnji Cooper.Fo iflib_link_intr_deferred 76fa504546SEnji Cooper.Fa "if_ctx_t ctx" 77fa504546SEnji Cooper.Fc 7834bac11eSSean Bruno.Ft void 79fa504546SEnji Cooper.Fo iflib_link_state_change 80fa504546SEnji Cooper.Fa "if_ctx_t ctx" 81fa504546SEnji Cooper.Fa "int linkstate" 82fa504546SEnji Cooper.Fc 8334bac11eSSean Bruno.Ft void 84fa504546SEnji Cooper.Fo iflib_add_int_delay_sysctl 85fa504546SEnji Cooper.Fa "if_ctx_t ctx" 86fa504546SEnji Cooper.Fa "const char *" 87fa504546SEnji Cooper.Fa "const char *" 88fa504546SEnji Cooper.Fa "if_int_delay_info_t" 89fa504546SEnji Cooper.Fa "int" 90fa504546SEnji Cooper.Fa "int" 91fa504546SEnji Cooper.Fc 9234bac11eSSean Bruno.Ss "Global Variables" 9334bac11eSSean Bruno.Vt extern struct if_txrx 9434bac11eSSean Bruno.Sh DATA STRUCTURES 95fa504546SEnji CooperThe \fIif_ctx_t\fP Structure is the device independent data structure that 96fa504546SEnji Coopercontains statistics and identifying information used to transmit and receive 97fa504546SEnji Cooperdata packets. 98fa504546SEnji CooperThe interface is associated with an array of queues assigned sequentially. 99fa504546SEnji CooperEach queue has its own transmit (iflib_txq_t) and receive (iflib_rxq_t) queue. 100fa504546SEnji CooperThe transmit queue is used to hold packets while the interface is in the 101fa504546SEnji Cooperprocess of sending another. 102fa504546SEnji CooperThe receive queue is used to receive packets that are awaiting processing. 10334bac11eSSean Bruno.Pp 10434bac11eSSean Bruno.Ss The if_ctx_t Structure 10534bac11eSSean BrunoThe fields of 10634bac11eSSean Bruno.Vt "struct if_ctx_t" 10734bac11eSSean Brunoare as follows: 10834bac11eSSean Bruno.Bl -tag -width ".Va if_capabilities" -offset indent 10934bac11eSSean Bruno.It Va if_softc 11034bac11eSSean Bruno.Pq Vt "void" 11134bac11eSSean BrunoA pointer to the driver's private state block. 11234bac11eSSean Bruno.It Va ifc_dev 11334bac11eSSean Bruno.Pq Vt "device_t" 11434bac11eSSean BrunoThe underlying device structure. 11534bac11eSSean Bruno.It Va ifc_ip 11634bac11eSSean Bruno.Pq Vt "if_t" 11734bac11eSSean BrunoA link back to the interface structure 11834bac11eSSean Bruno.It Va ifc_cpus 11934bac11eSSean Bruno.Pq Vt "cpuset_t" 12034bac11eSSean Bruno.It Va ifc_mutex 12134bac11eSSean Bruno.Pq Vt "struct mtx" 12234bac11eSSean BrunoMutex lock used to maintain data integrity 12334bac11eSSean Bruno.It Va ifc_mtx_name 12434bac11eSSean Bruno.Pq Vt "char *" 12534bac11eSSean BrunoThe name of the mutex 12634bac11eSSean Bruno.It Va ifc_txqs 12734bac11eSSean Bruno.Pq Vt "iflib_txq_t" 12834bac11eSSean BrunoDevice independent transmit queue maintained internally by iflib 12934bac11eSSean Bruno.It Va ifc_rxqs 13034bac11eSSean Bruno.Pq Vt "iflib_rxq_t" 13134bac11eSSean BrunoDevice independent receive queue maintained internally by iflib 13234bac11eSSean Bruno.It Va ifc_qsets 13334bac11eSSean Bruno.Pq Vt "iflib_qset_t" 134fa504546SEnji CooperOutput queue that contains a single transmit (ifc_txq_t) and receive 135fa504546SEnji Cooper(ifc_rxq_t) queue 13634bac11eSSean Bruno.It Va ifc_if_flags 13734bac11eSSean Bruno.Pq Vt "uint32_t" 13834bac11eSSean BrunoFlags describing the operational parameter of the interface 13934bac11eSSean Bruno.It Va ifc_in_detach 14034bac11eSSean Bruno.Pq Vt "int" 14134bac11eSSean Bruno.It Va ifc_link_state 14234bac11eSSean Bruno.Pq Vt "int" 143fa504546SEnji CooperDescribes the current link state of the Ethernet interface. 144fa504546SEnji CooperIts possible values are either active or inactive. 14534bac11eSSean Bruno.It Va ifc_link_irq 14634bac11eSSean Bruno.Pq Vt "int" 14734bac11eSSean Bruno.It Va ifc_vlan_attach_event 14834bac11eSSean Bruno.Pq Vt "eventhandler_tag" 14934bac11eSSean Bruno.It Va ifc_vlan_detach_event 15034bac11eSSean Bruno.Pq Vt "eventhandler_tag" 15134bac11eSSean Bruno.It Va ifc_pause_frames 15234bac11eSSean Bruno.Pq Vt "int" 15334bac11eSSean Bruno.It Va ifc_watchdog_events 15434bac11eSSean Bruno.Pq Vt "int" 15534bac11eSSean Bruno.It Va ifc_mac 15634bac11eSSean Bruno.Pq Vt "uint8_t" 15734bac11eSSean Bruno.It Va ifc_msix_mem 15834bac11eSSean Bruno.Pq Vt "struct resource *" 15934bac11eSSean Bruno.It Va ifc_legacy_irq 16034bac11eSSean Bruno.Pq Vt "struct if_irq" 16134bac11eSSean Bruno.It Va ifc_admin_task 16234bac11eSSean Bruno.Pq Vt "struct grouptask" 16334bac11eSSean BrunoTaskqueue task scheduled for link state change events of the interface 16434bac11eSSean Bruno.It Va ifc_filter_info 16534bac11eSSean Bruno.Pq Vt "struct iflib_filter_info" 16634bac11eSSean BrunoStatistics and information relating to the interface device filter 16734bac11eSSean Bruno.It Va ifc_media 16834bac11eSSean Bruno.Pq Vt "struct ifmedia" 16934bac11eSSean Bruno.It Va ifc_txrx 17034bac11eSSean Bruno.Pq Vt "struct if_txrx" 17134bac11eSSean Bruno.El 17234bac11eSSean Bruno.Sh FUNCTIONS 173fa504546SEnji CooperThe above named functions are found exclusively in iflib. 174fa504546SEnji CooperThey are independent of the underlying hardware type or configuration. 17534bac11eSSean Bruno.Ss Device Independent Functions 17634bac11eSSean Bruno.Bl -ohang -offset indent 17734bac11eSSean Bruno.It Fn iflib_device_attach 178fa504546SEnji CooperFunction initiates a device registration with the iflib framework. 179fa504546SEnji CooperIt calls the iflib_register function, which is responsible for allocating 180fa504546SEnji Cooperand initializing the \fIif_ctx_t\fP structure. 18134bac11eSSean Bruno.It Fn iflib_device_detach 182fa504546SEnji CooperShutdown and detach the device. 183fa504546SEnji CooperUnregister vlan events, drain any dependent tasks, and release irq, pci, and 184fa504546SEnji Coopermsix memory. 18534bac11eSSean Bruno.It Fn iflib_device_suspend 186fa504546SEnji CooperSuspend a device by calling the device dependent suspend function and 187fa504546SEnji Cooperbus_generic_suspend. 18834bac11eSSean Bruno.It Fn iflib_device_resume 189fa504546SEnji CooperResume a device by calling the device dependent resume function, the 190fa504546SEnji Cooperiflib_init_locked function, and bus_generic_resume. 19134bac11eSSean Bruno.It Fn iflib_device_register 192fa504546SEnji CooperRegister a device with the iflib framework. 193fa504546SEnji CooperAllocate and initialize the 194fa504546SEnji Cooper\fIif_ctx_t\fP structure. 195fa504546SEnji CooperSetup and initialize the MSI or MSI/X interrupt queues if necessary. 196fa504546SEnji CooperAllocate memory for queues and qset structure setup. 197*a3cea1deSKevin Lo.It Fn iflib_irq_alloc 198fa504546SEnji CooperAllocate an interrupt resource for a given rid value with an associated filter 199fa504546SEnji Cooperand handler function. 200*a3cea1deSKevin Lo.It Fn iflib_irq_alloc_generic 201fa504546SEnji CooperPerforms the same function as iflib_device_irq_alloc along with the additional 202fa504546SEnji Cooperfunctionality of adding a taskgroup. 203fa504546SEnji CooperThe data fields and callback function are determined by the type of interrupt, 204fa504546SEnji Coopersuch as 205fa504546SEnji Cooper.Dv IFLIB_INTR_TX , 206fa504546SEnji Cooper.Dv IFLIB_INTR_RX , 207fa504546SEnji Cooperand 208fa504546SEnji Cooper.Dv IFLIB_INTR_ADMIN . 20934bac11eSSean Bruno.It Fn iflib_led_create 21034bac11eSSean BrunoCalls led_create to initialize the ctx->ifc_led_dev field 21134bac11eSSean Bruno.It Fn iflib_tx_intr_deferred 21234bac11eSSean BrunoCalls GROUPTASK_ENQUEUE to enqueue the transfer queues ift_task. 21334bac11eSSean Bruno.It Fn iflib_rx_intr_deferred 21434bac11eSSean BrunoCalls GROUPTASK_ENQUEUE to enqueue the receive queues ifr_task. 21534bac11eSSean Bruno.It Fn iflib_link_intr_deferred 21634bac11eSSean BrunoCalls GROUPTASK_ENQUEUE to enqueue the link task 21734bac11eSSean Bruno.It Fn iflib_link_state_change 218fa504546SEnji CooperChange the interface link status to either 219fa504546SEnji Cooper.Dv LINK_STATE_UP 220fa504546SEnji Cooperor 221fa504546SEnji Cooper.Dv LINK_STATE_DOWN 222fa504546SEnji Cooperas specified by the second argument to the function. 223fa504546SEnji Cooper.Pp 224fa504546SEnji Cooper.Em Interface Link States 22534bac11eSSean BrunoThe following link states are currently defined: 226fa504546SEnji Cooper.It Dv LINK_STATE_UP 227fa504546SEnji CooperThe link is up. 228fa504546SEnji Cooper.It Dv LINK_STATE_DOWN 229fa504546SEnji CooperThe link is down. 23034bac11eSSean Bruno.It Fn iflib_add_int_delay_sysctl 23134bac11eSSean BrunoModifies settings to user defined values for a given set of variables. 23234bac11eSSean Bruno.El 233fa504546SEnji Cooper.Sh SEE ALSO 234fa504546SEnji Cooper.Xr iflibdd 9 , 235fa504546SEnji Cooper.Xr iflibtxrx 9 23634bac11eSSean Bruno.Sh AUTHORS 23734bac11eSSean BrunoThis manual page was written by 23834bac11eSSean Bruno.An Nicole Graziano 239