SP230 raises the aggregated Rx interrupt even when the application does not request queue interrupts, and nothing acknowledges it. The HTN tile has no microcode to mask it and its RQ context has no invalid-INTR encoding, unlike the STN tile used by SP560.
The INTR field is a plain vector index, so 0 selects the AEQ vector and every Rx queue raises there. With per-queue MSI-X vectors available, program the queue vector and leave it disabled: Rx keeps polling and no interrupt is delivered. hinic3_dev_rx_queue_intr_enable() returns 0 for SP230 without touching the hardware, so an application that needs Rx interrupts must set intr_conf.rxq at configure time. Signed-off-by: Jiacheng Ye <[email protected]> --- drivers/net/hinic3/hinic3_ethdev.c | 77 +++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 6 deletions(-) diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c index e74dfa22da..34d7753ff8 100644 --- a/drivers/net/hinic3/hinic3_ethdev.c +++ b/drivers/net/hinic3/hinic3_ethdev.c @@ -1503,6 +1503,9 @@ hinic3_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id) struct hinic3_nic_dev *nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); uint16_t msix_intr; + if (HINIC3_IS_SP230_NIC(nic_dev) && !dev->data->dev_conf.intr_conf.rxq) + return 0; + if (!rte_intr_dp_is_en(intr_handle) || !intr_handle->intr_vec) return 0; @@ -1765,11 +1768,8 @@ hinic3_init_rxq_msix_attr(void *hwdev, uint16_t msix_index) info.resend_timer_cfg = HINIC3_TXRX_MSIX_RESEND_TIMER_CFG; info.msix_index = msix_index; err = hinic3_set_interrupt_cfg(hwdev, info); - if (err) { - PMD_DRV_LOG(ERR, "Set msix attr failed, msix_index %d", - msix_index); + if (err) return -EFAULT; - } return 0; } @@ -1786,6 +1786,38 @@ hinic3_deinit_rxq_intr(struct rte_eth_dev *dev) } } +/** + * Check that the Rx queue vectors fit in the device MSI-X vector table. + * + * @param[in] dev + * Pointer to ethernet device structure. + * @param[in] nb_rx_queues + * Number of Rx queues to be given a vector. + * + * @return + * 0 if the configuration fits, -EINVAL otherwise. + */ +static int +hinic3_check_rxq_intr_vec(struct rte_eth_dev *dev, uint32_t nb_rx_queues) +{ + struct hinic3_nic_dev *nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); + uint16_t num_irqs = HINIC3_HWIF_NUM_IRQS(nic_dev->hwdev->hwif); + uint32_t last_vec; + + if (nb_rx_queues == 0) + return 0; + + last_vec = (uint32_t)HINIC3_RX_VEC_START + nb_rx_queues - 1; + if (last_vec >= (uint32_t)num_irqs) { + PMD_DRV_LOG(ERR, + "Not enough MSI-X vectors for %u Rx queues, need %u vectors, have %u", + nb_rx_queues, last_vec + 1, num_irqs); + return -EINVAL; + } + + return 0; +} + /** * Initialize RX queue interrupts by enabling MSI-X, allocate interrupt vectors, * and configure interrupt attributes for each RX queue. @@ -1798,6 +1830,11 @@ hinic3_deinit_rxq_intr(struct rte_eth_dev *dev) * - -ENOTSUP if MSI-X interrupts are not supported. * - Error code if enabling event file descriptors fails. * - -ENOMEM if allocating interrupt vectors fails. + * - -EINVAL if the Rx queues do not fit in the MSI-X vector table. + * + * On SP230 with per-queue MSI-X vectors, when the application does not + * request Rx interrupts, the queue vector is named in each RQ context but + * never enabled, and no interrupt resources are allocated. */ static int hinic3_init_rxq_intr(struct rte_eth_dev *dev) @@ -1810,8 +1847,29 @@ hinic3_init_rxq_intr(struct rte_eth_dev *dev) intr_handle = dev->intr_handle; nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); - if (!dev->data->dev_conf.intr_conf.rxq) + + if (!dev->data->dev_conf.intr_conf.rxq) { + /* + * SP230 raises the Rx MSI-X vector even without Rx interrupts. + * Name a valid vector in the RQ context; the vector is never + * enabled, so no interrupt is reported. + */ + if (!HINIC3_IS_SP230_NIC(nic_dev) || + !rte_intr_cap_multiple(intr_handle)) + return 0; + + err = hinic3_check_rxq_intr_vec(dev, dev->data->nb_rx_queues); + if (err) + return err; + + for (i = 0; i < dev->data->nb_rx_queues; i++) { + rxq = dev->data->rx_queues[i]; + rxq->dp_intr_en = 1; + rxq->msix_entry_idx = (uint16_t)(i + HINIC3_RX_VEC_START); + } + return 0; + } if (!rte_intr_cap_multiple(intr_handle)) { PMD_DRV_LOG(ERR, "Rx queue interrupts require MSI-X interrupts (vfio-pci driver)"); @@ -1819,6 +1877,10 @@ hinic3_init_rxq_intr(struct rte_eth_dev *dev) } nb_rx_queues = dev->data->nb_rx_queues; + err = hinic3_check_rxq_intr_vec(dev, nb_rx_queues); + if (err) + return err; + err = rte_intr_efd_enable(intr_handle, nb_rx_queues); if (err) { PMD_DRV_LOG(ERR, @@ -1829,8 +1891,8 @@ hinic3_init_rxq_intr(struct rte_eth_dev *dev) intr_handle->intr_vec = rte_zmalloc("hinic_intr_vec", nb_rx_queues * sizeof(int), 0); if (intr_handle->intr_vec == NULL) { - PMD_DRV_LOG(ERR, "Failed to allocate intr_vec"); rte_intr_efd_disable(intr_handle); + PMD_DRV_LOG(ERR, "Failed to allocate intr_vec"); return -ENOMEM; } intr_handle->vec_list_size = nb_rx_queues; @@ -1845,6 +1907,9 @@ hinic3_init_rxq_intr(struct rte_eth_dev *dev) err = hinic3_init_rxq_msix_attr(nic_dev->hwdev, rxq->msix_entry_idx); if (err) { + PMD_DRV_LOG(ERR, + "Set msix attr failed, msix_index %d", + rxq->msix_entry_idx); hinic3_deinit_rxq_intr(dev); return err; } -- 2.33.0

