19872237dSMateusz Piotrowski.Dd September 27, 2018 27049547cSStephen Hurd.Dt IFLIB 4 37049547cSStephen Hurd.Os 47049547cSStephen Hurd.Sh NAME 57049547cSStephen Hurd.Nm iflib 67049547cSStephen Hurd.Nd Network Interface Driver Framework 77049547cSStephen Hurd.Sh SYNOPSIS 87049547cSStephen Hurd.Cd "device pci" 97049547cSStephen Hurd.Cd "device iflib" 107049547cSStephen Hurd.Sh DESCRIPTION 117049547cSStephen Hurd.Nm 127049547cSStephen Hurdis a framework for network interface drivers for 137049547cSStephen Hurd.Fx . 147049547cSStephen HurdIt is designed to remove a large amount of the boilerplate that is often 157049547cSStephen Hurdneeded for modern network interface devices, allowing driver authors to 167049547cSStephen Hurdfocus on the specific code needed for their hardware. 177049547cSStephen HurdThis allows for a shared set of 187049547cSStephen Hurd.Xr sysctl 8 197049547cSStephen Hurdnames, rather than each driver naming them individually. 207049547cSStephen Hurd.Sh SYSCTL VARIABLES 217049547cSStephen HurdThese variables must be set before loading the driver, either via 227049547cSStephen Hurd.Xr loader.conf 5 237049547cSStephen Hurdor through the use of 247049547cSStephen Hurd.Xr kenv 1 . 257049547cSStephen HurdThey are all prefixed by 269872237dSMateusz Piotrowski.Va dev.X.Y.iflib\&. 277049547cSStephen Hurdwhere X is the driver name, and Y is the instance number. 287049547cSStephen Hurd.Bl -tag -width indent 297049547cSStephen Hurd.It Va override_nrxds 307049547cSStephen HurdOverride the number of RX descriptors for each queue. 317049547cSStephen HurdThe value is a comma separated list of positive integers. 327049547cSStephen HurdSome drivers only use a single value, but others may use more. 337049547cSStephen HurdThese numbers must be powers of two, and zero means to use the default. 347049547cSStephen HurdIndividual drivers may have additional restrictions on allowable values. 357049547cSStephen HurdDefaults to all zeros. 367049547cSStephen Hurd.It Va override_ntxds 377049547cSStephen HurdOverride the number of TX descriptors for each queue. 387049547cSStephen HurdThe value is a comma separated list of positive integers. 397049547cSStephen HurdSome drivers only use a single value, but others may use more. 407049547cSStephen HurdThese numbers must be powers of two, and zero means to use the default. 417049547cSStephen HurdIndividual drivers may have additional restrictions on allowable values. 427049547cSStephen HurdDefaults to all zeros. 437049547cSStephen Hurd.It Va override_qs_enable 447049547cSStephen HurdWhen set, allows the number of transmit and receive queues to be different. 457049547cSStephen HurdIf not set, the lower of the number of TX or RX queues will be used for both. 467049547cSStephen Hurd.It Va override_nrxqs 477049547cSStephen HurdSet the number of RX queues. 487049547cSStephen HurdIf zero, the number of RX queues is derived from the number of cores on the 497049547cSStephen Hurdsocket connected to the controller. 507049547cSStephen HurdDefaults to 0. 517049547cSStephen Hurd.It Va override_ntxqs 527049547cSStephen HurdSet the number of TX queues. 537049547cSStephen HurdIf zero, the number of TX queues is derived from the number of cores on the 547049547cSStephen Hurdsocket connected to the controller. 557049547cSStephen Hurd.It Va disable_msix 567049547cSStephen HurdDisables MSI-X interrupts for the device. 57f154ece0SStephen Hurd.It Va core_offset 58f154ece0SStephen HurdSpecifies a starting core offset to assign queues to. 59f154ece0SStephen HurdIf the value is unspecified or 65535, cores are assigned sequentially across 60f154ece0SStephen Hurdcontrollers. 61f154ece0SStephen Hurd.It Va separate_txrx 62f154ece0SStephen HurdRequests that RX and TX queues not be paired on the same core. 63f154ece0SStephen HurdIf this is zero or not set, an RX and TX queue pair will be assigned to each 64f154ece0SStephen Hurdcore. 65f154ece0SStephen HurdWhen set to a non-zero value, TX queues are assigned to cores following the 66f154ece0SStephen Hurdlast RX queue. 677049547cSStephen Hurd.El 687049547cSStephen Hurd.Pp 697049547cSStephen HurdThese 707049547cSStephen Hurd.Xr sysctl 8 717049547cSStephen Hurdvariables can be changed at any time: 727049547cSStephen Hurd.Bl -tag -width indent 737049547cSStephen Hurd.It Va tx_abdicate 747049547cSStephen HurdControls how the transmit ring is serviced. 757049547cSStephen HurdIf set to zero, when a frame is submitted to the transmission ring, the same 767049547cSStephen Hurdtask that is submitting it will service the ring unless there's already a 777049547cSStephen Hurdtask servicing the TX ring. 787049547cSStephen HurdThis ensures that whenever there is a pending transmission, 797049547cSStephen Hurdthe transmit ring is being serviced. 807049547cSStephen HurdThis results in higher transmit throughput. 817049547cSStephen HurdIf set to a non-zero value, task returns immediately and the transmit 827049547cSStephen Hurdring is serviced by a different task. 837049547cSStephen HurdThis returns control to the caller faster and under high receive load, 847049547cSStephen Hurdmay result in fewer dropped RX frames. 857049547cSStephen Hurd.It Va rx_budget 867049547cSStephen HurdSets the maximum number of frames to be received at a time. 877049547cSStephen HurdZero (the default) indicates the default (currently 16) should be used. 887049547cSStephen Hurd.El 897049547cSStephen Hurd.Pp 907049547cSStephen HurdThere are also some global sysctls which can change behaviour for all drivers, 917049547cSStephen Hurdand may be changed at any time. 927049547cSStephen Hurd.Bl -tag -width indent 937049547cSStephen Hurd.It Va net.iflib.min_tx_latency 947049547cSStephen HurdIf this is set to a non-zero value, iflib will avoid any attempt to combine 957049547cSStephen Hurdmultiple transmits, and notify the hardware as quickly as possible of 967049547cSStephen Hurdnew descriptors. 977049547cSStephen HurdThis will lower the maximum throughput, but will also lower transmit latency. 987049547cSStephen Hurd.It Va net.iflib.no_tx_batch 997049547cSStephen HurdSome NICs allow processing completed transmit descriptors in batches. 1007049547cSStephen HurdDoing so usually increases the transmit throughput by reducing the number of 1017049547cSStephen Hurdtransmit interrupts. 1027049547cSStephen HurdSetting this to a non-zero value will disable the use of this feature. 1037049547cSStephen Hurd.El 1047049547cSStephen Hurd.Pp 1057049547cSStephen HurdThese 1067049547cSStephen Hurd.Xr sysctl 8 1077049547cSStephen Hurdvariables are read-only: 1087049547cSStephen Hurd.Bl -tag -width indent 1097049547cSStephen Hurd.It Va driver_version 1107049547cSStephen HurdA string indicating the internal version of the driver. 1117049547cSStephen Hurd.El 1127049547cSStephen Hurd.Pp 1137049547cSStephen HurdThere are a number of queue state 1147049547cSStephen Hurd.Xr sysctl 8 1157049547cSStephen Hurdvariables as well: 1167049547cSStephen Hurd.Bl -tag -width indent 1177049547cSStephen Hurd.It Va txqZ 1187049547cSStephen HurdThe following are repeated for each transmit queue, where Z is the transmit 1197049547cSStephen Hurdqueue instance number: 1207049547cSStephen Hurd.Bl -tag -width indent 1217049547cSStephen Hurd.It Va r_abdications 1227049547cSStephen HurdNumber of consumer abdications in the MP ring for this queue. 1237049547cSStephen HurdAn abdication occurs on every ring submission when tx_abdicate is true. 1247049547cSStephen Hurd.It Va r_restarts 1257049547cSStephen HurdNumber of consumer restarts in the MP ring for this queue. 1267049547cSStephen HurdA restart occurs when an attempt to drain a non-empty ring fails, 1277049547cSStephen Hurdand the ring is already in the STALLED state. 1287049547cSStephen Hurd.It Va r_stalls 1297049547cSStephen HurdNumber of consumer stalls in the MP ring for this queue. 1307049547cSStephen HurdA stall occurs when an attempt to drain a non-empty ring fails. 1317049547cSStephen Hurd.It Va r_starts 1327049547cSStephen HurdNumber of normal consumer starts in the MP ring for this queue. 1337049547cSStephen HurdA start occurs when the MP ring transitions from IDLE to BUSY. 1347049547cSStephen Hurd.It Va r_drops 1357049547cSStephen HurdNumber of drops in the MP ring for this queue. 1367049547cSStephen HurdA drop occurs when there is an attempt to add an entry to an MP ring with 1377049547cSStephen Hurdno available space. 1387049547cSStephen Hurd.It Va r_enqueues 1397049547cSStephen HurdNumber of entries which have been enqueued to the MP ring for this queue. 1407049547cSStephen Hurd.It Va ring_state 1417049547cSStephen HurdMP (soft) ring state. 142*ffc4f93eSBenedict ReuschlingThis provides a snapshot of the current MP ring state, including the producer 1437049547cSStephen Hurdhead and tail indexes, the consumer index, and the state. 1447049547cSStephen HurdThe state is one of "IDLE", "BUSY", 1457049547cSStephen Hurd"STALLED", or "ABDICATED". 1467049547cSStephen Hurd.It Va txq_cleaned 1477049547cSStephen HurdThe number of transmit descriptors which have been reclaimed. 1487049547cSStephen HurdTotal cleaned. 1497049547cSStephen Hurd.It Va txq_processed 1507049547cSStephen HurdThe number of transmit descriptors which have been processed, but may not yet 1517049547cSStephen Hurdhave been reclaimed. 1527049547cSStephen Hurd.It Va txq_in_use 1537049547cSStephen HurdDescriptors which have been added to the transmit queue, 1547049547cSStephen Hurdbut have not yet been cleaned. 1557049547cSStephen HurdThis value will include both untransmitted descriptors as well as descriptors 1567049547cSStephen Hurdwhich have been processed. 1577049547cSStephen Hurd.It Va txq_cidx_processed 1587049547cSStephen HurdThe transmit queue consumer index of the next descriptor to process. 1597049547cSStephen Hurd.It Va txq_cidx 1607049547cSStephen HurdThe transmit queue consumer index of the oldest descriptor to reclaim. 1617049547cSStephen Hurd.It Va txq_pidx 1627049547cSStephen HurdThe transmit queue producer index where the next descriptor to transmit will 1637049547cSStephen Hurdbe inserted. 1647049547cSStephen Hurd.It Va no_tx_dma_setup 1659872237dSMateusz PiotrowskiNumber of times DMA mapping a transmit mbuf failed for reasons other than 1669872237dSMateusz Piotrowski.Er EFBIG . 1677049547cSStephen Hurd.It Va txd_encap_efbig 1687049547cSStephen HurdNumber of times DMA mapping a transmit mbuf failed due to requiring too many 1697049547cSStephen Hurdsegments. 1707049547cSStephen Hurd.It Va tx_map_failed 1717049547cSStephen HurdNumber of times DMA mapping a transmit mbuf failed for any reason 1727049547cSStephen Hurd(sum of no_tx_dma_setup and txd_encap_efbig) 1737049547cSStephen Hurd.It Va no_desc_avail 1747049547cSStephen HurdNumber of times a descriptor couldn't be added to the transmit ring because 1757049547cSStephen Hurdthe transmit ring was full. 1767049547cSStephen Hurd.It Va mbuf_defrag_failed 1777049547cSStephen HurdNumber of times both 1787049547cSStephen Hurd.Xr m_collapse 9 1797049547cSStephen Hurdand 1807049547cSStephen Hurd.Xr m_defrag 9 1819872237dSMateusz Piotrowskifailed after an 1829872237dSMateusz Piotrowski.Er EFBIG 1839872237dSMateusz Piotrowskierror 1847049547cSStephen Hurdresult from DMA mapping a transmit mbuf. 1857049547cSStephen Hurd.It Va m_pullups 1869872237dSMateusz PiotrowskiNumber of times 1879872237dSMateusz Piotrowski.Xr m_pullup 9 1889872237dSMateusz Piotrowskiwas called attempting to parse a header. 1897049547cSStephen Hurd.It Va mbuf_defrag 1909872237dSMateusz PiotrowskiNumber of times 1919872237dSMateusz Piotrowski.Xr m_defrag 9 1929872237dSMateusz Piotrowskiwas called. 1937049547cSStephen Hurd.El 1947049547cSStephen Hurd.It Va rxqZ 1957049547cSStephen HurdThe following are repeated for each receive queue, where Z is the 1967049547cSStephen Hurdreceive queue instance number: 1977049547cSStephen Hurd.Bl -tag -width indent 1987049547cSStephen Hurd.It Va rxq_fl0.credits 1997049547cSStephen HurdCredits currently available in the receive ring. 2007049547cSStephen Hurd.It Va rxq_fl0.cidx 2017049547cSStephen HurdCurrent receive ring consumer index. 2027049547cSStephen Hurd.It Va rxq_fl0.pidx 2037049547cSStephen HurdCurrent receive ring producer index. 2047049547cSStephen Hurd.El 2057049547cSStephen Hurd.El 2069872237dSMateusz Piotrowski.Pp 2077049547cSStephen HurdAdditional OIDs useful for driver and iflib development are exposed when the 2087049547cSStephen HurdINVARIANTS and/or WITNESS options are enabled in the kernel. 2097049547cSStephen Hurd.Sh SEE ALSO 2107049547cSStephen Hurd.Xr iflib 9 2117049547cSStephen Hurd.Sh HISTORY 2129872237dSMateusz PiotrowskiThis framework was introduced in 2139872237dSMateusz Piotrowski.Fx 11.0 . 214