Lines Matching +full:rx +full:- +full:device
1 /* SPDX-License-Identifier: BSD-3-Clause */
104 * FreeBSD Device Interface Entry Points
109 * @brief device methods for the iavf driver
111 * Device method callbacks used to interact with the driver. For iflib this
115 /* Device interface */
215 * iavf_register - iflib callback to obtain the shared context pointer
216 * @dev: the device being registered
220 * describes the device features.
231 * iavf_allocate_pci_resources - Allocate PCI resources
232 * @sc: the device private softc
236 * @returns zero or a non-zero error code on failure
245 * iavf_if_attach_pre - Begin attaching the device to the driver
251 * @returns zero or a non-zero error code on failure.
267 vsi = &sc->vsi; in iavf_if_attach_pre()
268 vsi->back = sc; in iavf_if_attach_pre()
269 sc->dev = sc->osdep.dev = dev; in iavf_if_attach_pre()
270 hw = &sc->hw; in iavf_if_attach_pre()
272 vsi->dev = dev; in iavf_if_attach_pre()
273 vsi->hw = &sc->hw; in iavf_if_attach_pre()
274 vsi->num_vlans = 0; in iavf_if_attach_pre()
275 vsi->ctx = ctx; in iavf_if_attach_pre()
276 sc->media = iflib_get_media(ctx); in iavf_if_attach_pre()
277 vsi->ifp = iflib_get_ifp(ctx); in iavf_if_attach_pre()
278 vsi->shared = scctx = iflib_get_softc_ctx(ctx); in iavf_if_attach_pre()
283 snprintf(sc->vc_mtx_name, sizeof(sc->vc_mtx_name), in iavf_if_attach_pre()
285 mtx_init(&sc->vc_mtx, sc->vc_mtx_name, NULL, MTX_DEF); in iavf_if_attach_pre()
287 /* Do PCI setup - map BAR0, etc */ in iavf_if_attach_pre()
295 iavf_dbg_init(sc, "Allocated PCI resources and MSI-X vectors\n"); in iavf_if_attach_pre()
306 device_printf(dev, "%s: Device is still being reset\n", in iavf_if_attach_pre()
311 iavf_dbg_init(sc, "VF Device is ready for configuration\n"); in iavf_if_attach_pre()
354 iflib_set_mac(ctx, hw->mac.addr); in iavf_if_attach_pre()
360 scctx->isc_ntxqsets_max = scctx->isc_nrxqsets_max = in iavf_if_attach_pre()
361 sc->vsi_res->num_queue_pairs; in iavf_if_attach_pre()
362 if (vsi->enable_head_writeback) { in iavf_if_attach_pre()
363 scctx->isc_txqsizes[0] = roundup2(scctx->isc_ntxd[0] in iavf_if_attach_pre()
365 scctx->isc_txrx = &iavf_txrx_hwb; in iavf_if_attach_pre()
367 scctx->isc_txqsizes[0] = roundup2(scctx->isc_ntxd[0] in iavf_if_attach_pre()
369 scctx->isc_txrx = &iavf_txrx_dwb; in iavf_if_attach_pre()
371 scctx->isc_rxqsizes[0] = roundup2(scctx->isc_nrxd[0] in iavf_if_attach_pre()
373 scctx->isc_msix_bar = pci_msix_table_bar(dev); in iavf_if_attach_pre()
374 scctx->isc_tx_nsegments = IAVF_MAX_TX_SEGS; in iavf_if_attach_pre()
375 scctx->isc_tx_tso_segments_max = IAVF_MAX_TSO_SEGS; in iavf_if_attach_pre()
376 scctx->isc_tx_tso_size_max = IAVF_TSO_SIZE; in iavf_if_attach_pre()
377 scctx->isc_tx_tso_segsize_max = IAVF_MAX_DMA_SEG_SIZE; in iavf_if_attach_pre()
378 scctx->isc_rss_table_size = IAVF_RSS_VSI_LUT_SIZE; in iavf_if_attach_pre()
379 scctx->isc_capabilities = scctx->isc_capenable = IAVF_CAPS; in iavf_if_attach_pre()
380 scctx->isc_tx_csum_flags = CSUM_OFFLOAD; in iavf_if_attach_pre()
385 taskqueue_free(sc->vc_tq); in iavf_if_attach_pre()
387 free(sc->vf_res, M_IAVF); in iavf_if_attach_pre()
398 * iavf_vc_task - task used to process VC messages
399 * @arg: device softc
415 * iavf_setup_vc_tq - Setup task queues
416 * @sc: device softc
419 * is done in a separate non-iflib taskqueue so that the iflib context lock
427 device_t dev = sc->dev; in iavf_setup_vc_tq()
430 TASK_INIT(&sc->vc_task, 0, iavf_vc_task, sc); in iavf_setup_vc_tq()
432 sc->vc_tq = taskqueue_create_fast("iavf_vc", M_NOWAIT, in iavf_setup_vc_tq()
433 taskqueue_thread_enqueue, &sc->vc_tq); in iavf_setup_vc_tq()
434 if (!sc->vc_tq) { in iavf_setup_vc_tq()
438 error = taskqueue_start_threads(&sc->vc_tq, 1, PI_NET, "%s vc", in iavf_setup_vc_tq()
443 taskqueue_free(sc->vc_tq); in iavf_setup_vc_tq()
451 * iavf_if_attach_post - Finish attaching the device to the driver
455 * the attach process for a device. Attach logic which must occur after Tx and
456 * Rx queues are setup belongs here.
458 * @returns zero or a non-zero error code on failure
474 vsi = &sc->vsi; in iavf_if_attach_post()
475 hw = &sc->hw; in iavf_if_attach_post()
478 vsi->num_rx_queues = vsi->shared->isc_nrxqsets; in iavf_if_attach_post()
479 vsi->num_tx_queues = vsi->shared->isc_ntxqsets; in iavf_if_attach_post()
487 bzero(&sc->vsi.eth_stats, sizeof(struct iavf_eth_stats)); in iavf_if_attach_post()
490 atomic_store_rel_32(&sc->queues_enabled, 0); in iavf_if_attach_post()
491 iavf_set_state(&sc->state, IAVF_STATE_INITIALIZED); in iavf_if_attach_post()
502 * iavf_if_detach - Detach a device from the driver
503 * @ctx: the iflib context of the device to detach
505 * Called by iflib to detach a given device from the driver. Clean up any
506 * resources associated with the driver and shut the device down.
518 struct iavf_hw *hw = &sc->hw; in iavf_if_detach()
519 device_t dev = sc->dev; in iavf_if_detach()
524 iavf_clear_state(&sc->state, IAVF_STATE_INITIALIZED); in iavf_if_detach()
527 taskqueue_free(sc->vc_tq); in iavf_if_detach()
531 ifmedia_removeall(sc->media); in iavf_if_detach()
534 status = iavf_shutdown_adminq(&sc->hw); in iavf_if_detach()
541 free(sc->vf_res, M_IAVF); in iavf_if_detach()
542 sc->vf_res = NULL; in iavf_if_detach()
551 * iavf_if_shutdown - called by iflib to handle shutdown
565 * iavf_if_suspend - called by iflib to handle suspend
579 * iavf_if_resume - called by iflib to handle resume
593 * iavf_vc_sleep_wait - Sleep for a response from a VC message
594 * @sc: device softc
612 &sc->vc_mtx, PRI_MAX, "iavf_vc", IAVF_AQ_TIMEOUT); in iavf_vc_sleep_wait()
618 * iavf_send_vc_msg_sleep - Send a virtchnl message and wait for a response
619 * @sc: device softc
625 * @remark this function does not wait if the device is detaching, on kernels
626 * that support indicating to the driver that the device is detaching
633 if_ctx_t ctx = sc->vsi.ctx; in iavf_send_vc_msg_sleep()
643 /* Don't wait for a response if the device is being detached. */ in iavf_send_vc_msg_sleep()
649 device_printf(sc->dev, "%b timed out\n", op, IAVF_FLAGS); in iavf_send_vc_msg_sleep()
657 * iavf_send_vc_msg - Send a virtchnl message to the PF
658 * @sc: device softc
678 * iavf_init_queues - initialize Tx and Rx queues
681 * Refresh the Tx and Rx ring contents and update the tail pointers for each
687 struct iavf_tx_queue *tx_que = vsi->tx_queues; in iavf_init_queues()
688 struct iavf_rx_queue *rx_que = vsi->rx_queues; in iavf_init_queues()
692 mbuf_sz = iflib_get_rx_mbuf_sz(vsi->ctx); in iavf_init_queues()
695 for (int i = 0; i < vsi->num_tx_queues; i++, tx_que++) in iavf_init_queues()
698 for (int i = 0; i < vsi->num_rx_queues; i++, rx_que++) { in iavf_init_queues()
699 rxr = &rx_que->rxr; in iavf_init_queues()
701 rxr->mbuf_sz = mbuf_sz; in iavf_init_queues()
702 wr32(vsi->hw, rxr->tail, 0); in iavf_init_queues()
707 * iavf_if_init - Initialize device for operation
710 * Initializes a device for operation. Called by iflib in response to an
720 struct iavf_vsi *vsi = &sc->vsi; in iavf_if_init()
721 struct iavf_hw *hw = &sc->hw; in iavf_if_init()
725 device_t dev = sc->dev; in iavf_if_init()
734 device_printf(sc->dev, "%s: VF reset failed\n", in iavf_if_init()
739 iavf_dbg_info(sc, "ASQ is not alive, re-initializing AQ\n"); in iavf_if_init()
763 if (!cmp_etheraddr(hw->mac.addr, tmpaddr) && in iavf_if_init()
765 error = iavf_del_mac_filter(sc, hw->mac.addr); in iavf_if_init()
769 bcopy(tmpaddr, hw->mac.addr, ETH_ALEN); in iavf_if_init()
772 error = iavf_add_mac_filter(sc, hw->mac.addr, 0); in iavf_if_init()
775 iflib_set_mac(ctx, hw->mac.addr); in iavf_if_init()
792 if (vsi->enable_head_writeback) in iavf_if_init()
803 iavf_set_state(&sc->state, IAVF_STATE_RUNNING); in iavf_if_init()
807 * iavf_if_msix_intr_assign - Assign MSI-X interrupts
809 * @msix: the number of MSI-X vectors available
811 * Called by iflib to assign MSI-X interrupt vectors to queues. Assigns and
812 * sets up vectors for each Tx and Rx queue, as well as the administrative
821 struct iavf_vsi *vsi = &sc->vsi; in iavf_if_msix_intr_assign()
822 struct iavf_rx_queue *rx_que = vsi->rx_queues; in iavf_if_msix_intr_assign()
823 struct iavf_tx_queue *tx_que = vsi->tx_queues; in iavf_if_msix_intr_assign()
827 MPASS(vsi->shared->isc_nrxqsets > 0); in iavf_if_msix_intr_assign()
828 MPASS(vsi->shared->isc_ntxqsets > 0); in iavf_if_msix_intr_assign()
832 err = iflib_irq_alloc_generic(ctx, &vsi->irq, rid, IFLIB_INTR_ADMIN, in iavf_if_msix_intr_assign()
835 iflib_irq_free(ctx, &vsi->irq); in iavf_if_msix_intr_assign()
842 for (i = 0, vector = 1; i < vsi->shared->isc_nrxqsets; i++, vector++, rx_que++) { in iavf_if_msix_intr_assign()
846 err = iflib_irq_alloc_generic(ctx, &rx_que->que_irq, rid, in iavf_if_msix_intr_assign()
847 IFLIB_INTR_RXTX, iavf_msix_que, rx_que, rx_que->rxr.me, buf); in iavf_if_msix_intr_assign()
850 "Failed to allocate queue RX int vector %d, err: %d\n", i, err); in iavf_if_msix_intr_assign()
851 vsi->num_rx_queues = i + 1; in iavf_if_msix_intr_assign()
854 rx_que->msix = vector; in iavf_if_msix_intr_assign()
859 for (i = 0; i < vsi->shared->isc_ntxqsets; i++, tx_que++) { in iavf_if_msix_intr_assign()
862 &vsi->rx_queues[i % vsi->shared->isc_nrxqsets].que_irq, in iavf_if_msix_intr_assign()
863 IFLIB_INTR_TX, tx_que, tx_que->txr.me, buf); in iavf_if_msix_intr_assign()
865 tx_que->msix = (i % vsi->shared->isc_nrxqsets) + 1; in iavf_if_msix_intr_assign()
870 iflib_irq_free(ctx, &vsi->irq); in iavf_if_msix_intr_assign()
871 rx_que = vsi->rx_queues; in iavf_if_msix_intr_assign()
872 for (i = 0; i < vsi->num_rx_queues; i++, rx_que++) in iavf_if_msix_intr_assign()
873 iflib_irq_free(ctx, &rx_que->que_irq); in iavf_if_msix_intr_assign()
878 * iavf_if_enable_intr - Enable all interrupts for a device
887 struct iavf_vsi *vsi = &sc->vsi; in iavf_if_enable_intr()
893 * iavf_if_disable_intr - Disable all interrupts for a device
902 struct iavf_vsi *vsi = &sc->vsi; in iavf_if_disable_intr()
908 * iavf_if_rx_queue_intr_enable - Enable one Rx queue interrupt
910 * @rxqid: Rx queue index
912 * Enables the interrupt associated with a specified Rx queue.
920 struct iavf_vsi *vsi = &sc->vsi; in iavf_if_rx_queue_intr_enable()
921 struct iavf_hw *hw = vsi->hw; in iavf_if_rx_queue_intr_enable()
922 struct iavf_rx_queue *rx_que = &vsi->rx_queues[rxqid]; in iavf_if_rx_queue_intr_enable()
924 iavf_enable_queue_irq(hw, rx_que->msix - 1); in iavf_if_rx_queue_intr_enable()
929 * iavf_if_tx_queue_intr_enable - Enable one Tx queue interrupt
941 struct iavf_vsi *vsi = &sc->vsi; in iavf_if_tx_queue_intr_enable()
942 struct iavf_hw *hw = vsi->hw; in iavf_if_tx_queue_intr_enable()
943 struct iavf_tx_queue *tx_que = &vsi->tx_queues[txqid]; in iavf_if_tx_queue_intr_enable()
945 iavf_enable_queue_irq(hw, tx_que->msix - 1); in iavf_if_tx_queue_intr_enable()
950 * iavf_if_tx_queues_alloc - Allocate Tx queue memory
962 * @returns zero or a non-zero error code on failure
968 struct iavf_vsi *vsi = &sc->vsi; in iavf_if_tx_queues_alloc()
969 if_softc_ctx_t scctx = vsi->shared; in iavf_if_tx_queues_alloc()
973 MPASS(scctx->isc_ntxqsets > 0); in iavf_if_tx_queues_alloc()
975 MPASS(scctx->isc_ntxqsets == ntxqsets); in iavf_if_tx_queues_alloc()
978 if (!(vsi->tx_queues = in iavf_if_tx_queues_alloc()
984 for (i = 0, que = vsi->tx_queues; i < ntxqsets; i++, que++) { in iavf_if_tx_queues_alloc()
985 struct tx_ring *txr = &que->txr; in iavf_if_tx_queues_alloc()
987 txr->me = i; in iavf_if_tx_queues_alloc()
988 que->vsi = vsi; in iavf_if_tx_queues_alloc()
990 if (!vsi->enable_head_writeback) { in iavf_if_tx_queues_alloc()
992 if (!(txr->tx_rsq = (qidx_t *)malloc(sizeof(qidx_t) * scctx->isc_ntxd[0], M_IAVF, M_NOWAIT))) { in iavf_if_tx_queues_alloc()
998 for (j = 0; j < scctx->isc_ntxd[0]; j++) in iavf_if_tx_queues_alloc()
999 txr->tx_rsq[j] = QIDX_INVALID; in iavf_if_tx_queues_alloc()
1002 txr->tail = IAVF_QTX_TAIL1(txr->me); in iavf_if_tx_queues_alloc()
1003 txr->tx_base = (struct iavf_tx_desc *)vaddrs[i * ntxqs]; in iavf_if_tx_queues_alloc()
1004 txr->tx_paddr = paddrs[i * ntxqs]; in iavf_if_tx_queues_alloc()
1005 txr->que = que; in iavf_if_tx_queues_alloc()
1015 * iavf_if_rx_queues_alloc - Allocate Rx queue memory
1019 * @nrxqs: number of Rx queues per group (should always be 1)
1020 * @nrxqsets: the number of Rx queues to allocate
1022 * Called by iflib to allocate driver memory for a number of Rx queues.
1023 * Allocates memory for the drivers private Rx queue data structure, and saves
1026 * @returns zero or a non-zero error code on failure
1032 struct iavf_vsi *vsi = &sc->vsi; in iavf_if_rx_queues_alloc()
1037 if_softc_ctx_t scctx = vsi->shared; in iavf_if_rx_queues_alloc()
1038 MPASS(scctx->isc_nrxqsets > 0); in iavf_if_rx_queues_alloc()
1040 MPASS(scctx->isc_nrxqsets == nrxqsets); in iavf_if_rx_queues_alloc()
1044 if (!(vsi->rx_queues = in iavf_if_rx_queues_alloc()
1047 device_printf(iflib_get_dev(ctx), "Unable to allocate RX ring memory\n"); in iavf_if_rx_queues_alloc()
1052 for (i = 0, que = vsi->rx_queues; i < nrxqsets; i++, que++) { in iavf_if_rx_queues_alloc()
1053 struct rx_ring *rxr = &que->rxr; in iavf_if_rx_queues_alloc()
1055 rxr->me = i; in iavf_if_rx_queues_alloc()
1056 que->vsi = vsi; in iavf_if_rx_queues_alloc()
1059 rxr->tail = IAVF_QRX_TAIL1(rxr->me); in iavf_if_rx_queues_alloc()
1060 rxr->rx_base = (union iavf_rx_desc *)vaddrs[i * nrxqs]; in iavf_if_rx_queues_alloc()
1061 rxr->rx_paddr = paddrs[i * nrxqs]; in iavf_if_rx_queues_alloc()
1062 rxr->que = que; in iavf_if_rx_queues_alloc()
1072 * iavf_if_queues_free - Free driver queue memory
1076 * Tx and Rx queues.
1087 struct iavf_vsi *vsi = &sc->vsi; in iavf_if_queues_free()
1089 if (!vsi->enable_head_writeback) { in iavf_if_queues_free()
1093 for (i = 0, que = vsi->tx_queues; i < vsi->shared->isc_ntxqsets; i++, que++) { in iavf_if_queues_free()
1094 struct tx_ring *txr = &que->txr; in iavf_if_queues_free()
1095 if (txr->tx_rsq != NULL) { in iavf_if_queues_free()
1096 free(txr->tx_rsq, M_IAVF); in iavf_if_queues_free()
1097 txr->tx_rsq = NULL; in iavf_if_queues_free()
1102 if (vsi->tx_queues != NULL) { in iavf_if_queues_free()
1103 free(vsi->tx_queues, M_IAVF); in iavf_if_queues_free()
1104 vsi->tx_queues = NULL; in iavf_if_queues_free()
1106 if (vsi->rx_queues != NULL) { in iavf_if_queues_free()
1107 free(vsi->rx_queues, M_IAVF); in iavf_if_queues_free()
1108 vsi->rx_queues = NULL; in iavf_if_queues_free()
1113 * iavf_check_aq_errors - Check for AdminQ errors
1114 * @sc: device softc
1119 * @post if there are errors, the VF device will be stopped and a reset will
1122 * @returns zero if there are no issues, EBUSY if the device is resetting,
1128 struct iavf_hw *hw = &sc->hw; in iavf_check_aq_errors()
1129 device_t dev = sc->dev; in iavf_check_aq_errors()
1133 oldreg = reg = rd32(hw, hw->aq.arq.len); in iavf_check_aq_errors()
1135 /* Check if device is in reset */ in iavf_check_aq_errors()
1158 wr32(hw, hw->aq.arq.len, reg); in iavf_check_aq_errors()
1160 oldreg = reg = rd32(hw, hw->aq.asq.len); in iavf_check_aq_errors()
1177 wr32(hw, hw->aq.asq.len, reg); in iavf_check_aq_errors()
1183 * iavf_process_adminq - Process adminq responses from the PF
1184 * @sc: device softc
1197 struct iavf_hw *hw = &sc->hw; in iavf_process_adminq()
1202 if (iavf_test_state(&sc->state, IAVF_STATE_RESET_PENDING)) { in iavf_process_adminq()
1214 event.msg_buf = sc->aq_buffer; in iavf_process_adminq()
1228 iavf_vc_completion(sc, v_msg->v_opcode, in iavf_process_adminq()
1229 v_msg->v_retval, event.msg_buf, event.msg_len); in iavf_process_adminq()
1235 /* Re-enable admin queue interrupt cause */ in iavf_process_adminq()
1244 * iavf_if_update_admin_status - Administrative status task
1255 struct iavf_hw *hw = &sc->hw; in iavf_if_update_admin_status()
1263 * Otherwise, re-enable the Admin Queue interrupt. in iavf_if_update_admin_status()
1272 * iavf_if_multi_set - Set multicast address filters
1276 * device.
1287 * iavf_if_mtu_set - Set the device MTU
1291 * Called by iflib to set the device MTU.
1299 struct iavf_vsi *vsi = &sc->vsi; in iavf_if_mtu_set()
1303 device_printf(sc->dev, "mtu %d is not in valid range [%d-%d]\n", in iavf_if_mtu_set()
1308 vsi->shared->isc_max_frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + in iavf_if_mtu_set()
1315 * iavf_if_media_status - Report current media status
1330 * iavf_if_media_change - Change the current media settings
1344 * iavf_if_promisc_set - Set device promiscuous mode
1348 * Called by iflib to request that the device enter promiscuous mode.
1361 * iavf_if_timer - Periodic timer called by iflib
1375 struct iavf_hw *hw = &sc->hw; in iavf_if_timer()
1398 * iavf_if_vlan_register - Register a VLAN
1408 struct iavf_vsi *vsi = &sc->vsi; in iavf_if_vlan_register()
1414 if (vsi->num_vlans == 0) in iavf_if_vlan_register()
1419 ++vsi->num_vlans; in iavf_if_vlan_register()
1425 * iavf_if_vlan_unregister - Unregister a VLAN
1435 struct iavf_vsi *vsi = &sc->vsi; in iavf_if_vlan_unregister()
1438 if ((vtag == 0) || (vtag > 4095) || (vsi->num_vlans == 0)) /* Invalid */ in iavf_if_vlan_unregister()
1442 vsi->num_vlans -= i; in iavf_if_vlan_unregister()
1445 if (vsi->num_vlans == 0) in iavf_if_vlan_unregister()
1453 * iavf_if_get_counter - Get network statistic counters
1465 struct iavf_vsi *vsi = &sc->vsi; in iavf_if_get_counter()
1470 return (vsi->ipackets); in iavf_if_get_counter()
1472 return (vsi->ierrors); in iavf_if_get_counter()
1474 return (vsi->opackets); in iavf_if_get_counter()
1476 return (vsi->oerrors); in iavf_if_get_counter()
1481 return (vsi->ibytes); in iavf_if_get_counter()
1483 return (vsi->obytes); in iavf_if_get_counter()
1485 return (vsi->imcasts); in iavf_if_get_counter()
1487 return (vsi->omcasts); in iavf_if_get_counter()
1489 return (vsi->iqdrops); in iavf_if_get_counter()
1491 return (vsi->oqdrops); in iavf_if_get_counter()
1493 return (vsi->noproto); in iavf_if_get_counter()
1499 /* iavf_if_needs_restart - Tell iflib when the driver needs to be reinitialized
1519 * iavf_free_pci_resources - Free PCI resources
1520 * @sc: device softc
1528 struct iavf_vsi *vsi = &sc->vsi; in iavf_free_pci_resources()
1529 struct iavf_rx_queue *rx_que = vsi->rx_queues; in iavf_free_pci_resources()
1530 device_t dev = sc->dev; in iavf_free_pci_resources()
1537 iflib_irq_free(vsi->ctx, &vsi->irq); in iavf_free_pci_resources()
1539 for (int i = 0; i < vsi->num_rx_queues; i++, rx_que++) in iavf_free_pci_resources()
1540 iflib_irq_free(vsi->ctx, &rx_que->que_irq); in iavf_free_pci_resources()
1543 if (sc->pci_mem != NULL) in iavf_free_pci_resources()
1545 rman_get_rid(sc->pci_mem), sc->pci_mem); in iavf_free_pci_resources()
1549 * iavf_setup_interface - Setup the device interface
1550 * @sc: device softc
1552 * Called to setup some device interface settings, such as the ifmedia
1558 struct iavf_vsi *vsi = &sc->vsi; in iavf_setup_interface()
1559 if_ctx_t ctx = vsi->ctx; in iavf_setup_interface()
1564 vsi->shared->isc_max_frame_size = in iavf_setup_interface()
1570 ifmedia_add(sc->media, IFM_ETHER | IFM_AUTO, 0, NULL); in iavf_setup_interface()
1571 ifmedia_set(sc->media, IFM_ETHER | IFM_AUTO); in iavf_setup_interface()
1575 * iavf_msix_adminq - Admin Queue interrupt handler
1576 * @arg: void pointer to the device softc
1578 * Interrupt handler for the non-queue interrupt causes. Primarily this will
1588 struct iavf_hw *hw = &sc->hw; in iavf_msix_adminq()
1591 ++sc->admin_irq; in iavf_msix_adminq()
1593 if (!iavf_test_state(&sc->state, IAVF_STATE_INITIALIZED)) in iavf_msix_adminq()
1599 * they can be re-enabled in iavf_msix_adminq()
1608 taskqueue_enqueue(sc->vc_tq, &sc->vc_task); in iavf_msix_adminq()
1618 * iavf_enable_intr - Enable device interrupts
1626 struct iavf_hw *hw = vsi->hw; in iavf_enable_intr()
1627 struct iavf_rx_queue *que = vsi->rx_queues; in iavf_enable_intr()
1630 for (int i = 0; i < vsi->num_rx_queues; i++, que++) in iavf_enable_intr()
1631 iavf_enable_queue_irq(hw, que->rxr.me); in iavf_enable_intr()
1635 * iavf_disable_intr - Disable device interrupts
1645 struct iavf_hw *hw = vsi->hw; in iavf_disable_intr()
1646 struct iavf_rx_queue *que = vsi->rx_queues; in iavf_disable_intr()
1648 for (int i = 0; i < vsi->num_rx_queues; i++, que++) in iavf_disable_intr()
1649 iavf_disable_queue_irq(hw, que->rxr.me); in iavf_disable_intr()
1653 * iavf_enable_queue_irq - Enable IRQ register for a queue interrupt
1671 * iavf_disable_queue_irq - Disable IRQ register for a queue interrupt
1686 * iavf_configure_itr - Get initial ITR values from tunable values.
1687 * @sc: device softc
1699 * iavf_set_queue_rx_itr - Update Rx ITR value
1700 * @que: Rx queue to update
1702 * Provide a update to the queue RX interrupt moderation value.
1707 struct iavf_vsi *vsi = que->vsi; in iavf_set_queue_rx_itr()
1708 struct iavf_hw *hw = vsi->hw; in iavf_set_queue_rx_itr()
1709 struct rx_ring *rxr = &que->rxr; in iavf_set_queue_rx_itr()
1712 if (rxr->bytes == 0) in iavf_set_queue_rx_itr()
1716 if (rxr->itr != vsi->rx_itr_setting) { in iavf_set_queue_rx_itr()
1717 rxr->itr = vsi->rx_itr_setting; in iavf_set_queue_rx_itr()
1719 que->rxr.me), rxr->itr); in iavf_set_queue_rx_itr()
1724 * iavf_msix_que - Main Rx queue interrupt handler
1725 * @arg: void pointer to the Rx queue
1727 * Main MSI-X interrupt handler for Rx queue interrupts
1729 * @returns FILTER_SCHEDULE_THREAD if the main thread for Rx needs to run,
1736 struct iavf_sc *sc = rx_que->vsi->back; in iavf_msix_que()
1738 ++rx_que->irqs; in iavf_msix_que()
1740 if (!iavf_test_state(&sc->state, IAVF_STATE_RUNNING)) in iavf_msix_que()
1749 * iavf_update_link_status - Update iflib Link status
1750 * @sc: device softc
1752 * Notify the iflib stack of changes in link status. Called after the device
1758 struct iavf_vsi *vsi = &sc->vsi; in iavf_update_link_status()
1761 if (sc->link_up){ in iavf_update_link_status()
1762 if (vsi->link_active == FALSE) { in iavf_update_link_status()
1763 vsi->link_active = TRUE; in iavf_update_link_status()
1766 iflib_link_state_change(vsi->ctx, LINK_STATE_UP, baudrate); in iavf_update_link_status()
1769 if (vsi->link_active == TRUE) { in iavf_update_link_status()
1770 vsi->link_active = FALSE; in iavf_update_link_status()
1771 iflib_link_state_change(vsi->ctx, LINK_STATE_DOWN, 0); in iavf_update_link_status()
1777 * iavf_stop - Stop the interface
1778 * @sc: device softc
1782 * Tx/Rx LAN queues.
1787 iavf_clear_state(&sc->state, IAVF_STATE_RUNNING); in iavf_stop()
1789 iavf_disable_intr(&sc->vsi); in iavf_stop()
1795 * iavf_if_stop - iflib stop handler
1809 * iavf_del_mac_filter - Delete a MAC filter
1810 * @sc: device softc
1826 f->flags |= IAVF_FILTER_DEL; in iavf_del_mac_filter()
1831 * iavf_init_tx_rsqs - Initialize Report Status array
1840 if_softc_ctx_t scctx = vsi->shared; in iavf_init_tx_rsqs()
1844 for (i = 0, tx_que = vsi->tx_queues; i < vsi->num_tx_queues; i++, tx_que++) { in iavf_init_tx_rsqs()
1845 struct tx_ring *txr = &tx_que->txr; in iavf_init_tx_rsqs()
1847 txr->tx_rs_cidx = txr->tx_rs_pidx; in iavf_init_tx_rsqs()
1851 * off-by-one error when calculating how many descriptors are in iavf_init_tx_rsqs()
1854 txr->tx_cidx_processed = scctx->isc_ntxd[0] - 1; in iavf_init_tx_rsqs()
1856 for (j = 0; j < scctx->isc_ntxd[0]; j++) in iavf_init_tx_rsqs()
1857 txr->tx_rsq[j] = QIDX_INVALID; in iavf_init_tx_rsqs()
1862 * iavf_init_tx_cidx - Initialize Tx cidx values
1871 if_softc_ctx_t scctx = vsi->shared; in iavf_init_tx_cidx()
1875 for (i = 0, tx_que = vsi->tx_queues; i < vsi->num_tx_queues; i++, tx_que++) { in iavf_init_tx_cidx()
1876 struct tx_ring *txr = &tx_que->txr; in iavf_init_tx_cidx()
1878 txr->tx_cidx_processed = scctx->isc_ntxd[0] - 1; in iavf_init_tx_cidx()
1883 * iavf_add_device_sysctls - Add device sysctls for configuration
1884 * @sc: device softc
1886 * Add the main sysctl nodes and sysctls for device configuration.
1891 struct iavf_vsi *vsi = &sc->vsi; in iavf_add_device_sysctls()
1892 device_t dev = sc->dev; in iavf_add_device_sysctls()
1904 sc, 0, iavf_sysctl_queue_interrupt_table, "A", "View MSI-X indices for TX/RX queues"); in iavf_add_device_sysctls()
1923 * iavf_add_queues_sysctls - Add per-queue sysctls
1924 * @dev: device pointer
1927 * Add sysctls for each Tx and Rx queue.
1942 vsi_list = SYSCTL_CHILDREN(vsi->vsi_node); in iavf_add_queues_sysctls()
1945 for (int q = 0; q < vsi->num_rx_queues; q++) { in iavf_add_queues_sysctls()
1949 OID_AUTO, queue_namebuf, CTLFLAG_RD, NULL, "RX Queue #"); in iavf_add_queues_sysctls()
1952 rx_que = &(vsi->rx_queues[q]); in iavf_add_queues_sysctls()
1953 rxr = &(rx_que->rxr); in iavf_add_queues_sysctls()
1956 CTLFLAG_RD, &(rx_que->irqs), in iavf_add_queues_sysctls()
1957 "irqs on this queue (both Tx and Rx)"); in iavf_add_queues_sysctls()
1960 CTLFLAG_RD, &(rxr->rx_packets), in iavf_add_queues_sysctls()
1963 CTLFLAG_RD, &(rxr->rx_bytes), in iavf_add_queues_sysctls()
1966 CTLFLAG_RD, &(rxr->desc_errs), in iavf_add_queues_sysctls()
1967 "Queue Rx Descriptor Errors"); in iavf_add_queues_sysctls()
1969 CTLFLAG_RD, &(rxr->itr), 0, in iavf_add_queues_sysctls()
1970 "Queue Rx ITR Interval"); in iavf_add_queues_sysctls()
1972 for (int q = 0; q < vsi->num_tx_queues; q++) { in iavf_add_queues_sysctls()
1979 tx_que = &(vsi->tx_queues[q]); in iavf_add_queues_sysctls()
1980 txr = &(tx_que->txr); in iavf_add_queues_sysctls()
1983 CTLFLAG_RD, &(tx_que->tso), in iavf_add_queues_sysctls()
1986 CTLFLAG_RD, &(txr->mss_too_small), in iavf_add_queues_sysctls()
1989 CTLFLAG_RD, &(txr->tx_packets), in iavf_add_queues_sysctls()
1992 CTLFLAG_RD, &(txr->tx_bytes), in iavf_add_queues_sysctls()
1995 CTLFLAG_RD, &(txr->itr), 0, in iavf_add_queues_sysctls()
2001 * iavf_driver_is_detaching - Check if the driver is detaching/unloading
2002 * @sc: device private softc
2012 * detach-based race conditions as it is possible for a thread to race with
2018 return (!iavf_test_state(&sc->state, IAVF_STATE_INITIALIZED) || in iavf_driver_is_detaching()
2019 iflib_in_detach(sc->vsi.ctx)); in iavf_driver_is_detaching()
2023 * iavf_sysctl_queue_interrupt_table - Sysctl for displaying Tx queue mapping
2025 * @arg1: void pointer to device softc
2029 * Print out mapping of TX queue indexes and Rx queue indexes to MSI-X vectors.
2037 struct iavf_vsi *vsi = &sc->vsi; in iavf_sysctl_queue_interrupt_table()
2038 device_t dev = sc->dev; in iavf_sysctl_queue_interrupt_table()
2057 for (int i = 0; i < vsi->num_rx_queues; i++) { in iavf_sysctl_queue_interrupt_table()
2058 rx_que = &vsi->rx_queues[i]; in iavf_sysctl_queue_interrupt_table()
2059 sbuf_printf(buf, "(rxq %3d): %d\n", i, rx_que->msix); in iavf_sysctl_queue_interrupt_table()
2061 for (int i = 0; i < vsi->num_tx_queues; i++) { in iavf_sysctl_queue_interrupt_table()
2062 tx_que = &vsi->tx_queues[i]; in iavf_sysctl_queue_interrupt_table()
2063 sbuf_printf(buf, "(txq %3d): %d\n", i, tx_que->msix); in iavf_sysctl_queue_interrupt_table()
2078 * iavf_sysctl_vf_reset - Request a VF reset
2080 * @arg1: void pointer to device softc
2084 * Request a VF reset for the device.
2100 if ((error) || (req->newptr == NULL)) in iavf_sysctl_vf_reset()
2105 if (CTX_ACTIVE(sc->vsi.ctx)) in iavf_sysctl_vf_reset()
2106 iflib_request_reset(sc->vsi.ctx); in iavf_sysctl_vf_reset()
2113 * iavf_sysctl_vflr_reset - Trigger a PCIe FLR for the device
2115 * @arg1: void pointer to device softc
2127 device_t dev = sc->dev; in iavf_sysctl_vflr_reset()
2136 if ((error) || (req->newptr == NULL)) in iavf_sysctl_vflr_reset()
2144 else if (CTX_ACTIVE(sc->vsi.ctx)) in iavf_sysctl_vflr_reset()
2145 iflib_request_reset(sc->vsi.ctx); in iavf_sysctl_vflr_reset()