The following functions exported by the driver were stubs which merely changed the status flags: * rx_queue_start * rx_queue_stop * tx_queue_start * tx_queue_stop
Proper implementation was added to control queues's state. Signed-off-by: Oleksandr Kolomeiets <okl-...@napatech.com> --- drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c | 12 +++ drivers/net/ntnic/include/ntnic_dbs.h | 2 + drivers/net/ntnic/nthw/dbs/nthw_dbs.c | 20 +++++ drivers/net/ntnic/ntnic_ethdev.c | 80 ++++++++++++++++++- drivers/net/ntnic/ntnic_mod_reg.h | 2 + 5 files changed, 112 insertions(+), 4 deletions(-) diff --git a/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c b/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c index 94b0c97d27..0b049a8559 100644 --- a/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c +++ b/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c @@ -1115,6 +1115,16 @@ nthw_setup_mngd_tx_virt_queue(nthw_dbs_t *p_nthw_dbs, return NULL; } +static int nthw_switch_rx_virt_queue(nthw_dbs_t *p_nthw_dbs, uint32_t index, uint32_t enable) +{ + return set_rx_am_data_enable(p_nthw_dbs, index, enable); +} + +static int nthw_switch_tx_virt_queue(nthw_dbs_t *p_nthw_dbs, uint32_t index, uint32_t enable) +{ + return set_tx_am_data_enable(p_nthw_dbs, index, enable); +} + static uint16_t nthw_get_rx_packets(struct nthw_virt_queue *rxvq, uint16_t n, struct nthw_received_packets *rp, @@ -1419,6 +1429,8 @@ static struct sg_ops_s sg_ops = { .nthw_release_mngd_rx_virt_queue = nthw_release_mngd_rx_virt_queue, .nthw_setup_mngd_tx_virt_queue = nthw_setup_mngd_tx_virt_queue, .nthw_release_mngd_tx_virt_queue = nthw_release_mngd_tx_virt_queue, + .nthw_switch_rx_virt_queue = nthw_switch_rx_virt_queue, + .nthw_switch_tx_virt_queue = nthw_switch_tx_virt_queue, .nthw_get_rx_packets = nthw_get_rx_packets, .nthw_release_rx_packets = nthw_release_rx_packets, .nthw_get_tx_packets = nthw_get_tx_packets, diff --git a/drivers/net/ntnic/include/ntnic_dbs.h b/drivers/net/ntnic/include/ntnic_dbs.h index 247ae76d98..c35a7cb99b 100644 --- a/drivers/net/ntnic/include/ntnic_dbs.h +++ b/drivers/net/ntnic/include/ntnic_dbs.h @@ -267,6 +267,7 @@ int set_rx_am_data(nthw_dbs_t *p, uint32_t host_id, uint32_t packed, uint32_t int_enable); +int set_rx_am_data_enable(nthw_dbs_t *p, uint32_t index, uint32_t enable); int set_tx_am_data(nthw_dbs_t *p, uint32_t index, uint64_t guest_physical_address, @@ -274,6 +275,7 @@ int set_tx_am_data(nthw_dbs_t *p, uint32_t host_id, uint32_t packed, uint32_t int_enable); +int set_tx_am_data_enable(nthw_dbs_t *p, uint32_t index, uint32_t enable); int set_rx_uw_data(nthw_dbs_t *p, uint32_t index, uint64_t guest_physical_address, diff --git a/drivers/net/ntnic/nthw/dbs/nthw_dbs.c b/drivers/net/ntnic/nthw/dbs/nthw_dbs.c index aed52f67f5..da64dbab48 100644 --- a/drivers/net/ntnic/nthw/dbs/nthw_dbs.c +++ b/drivers/net/ntnic/nthw/dbs/nthw_dbs.c @@ -618,6 +618,16 @@ int set_rx_am_data(nthw_dbs_t *p, return 0; } +int set_rx_am_data_enable(nthw_dbs_t *p, uint32_t index, uint32_t enable) +{ + if (!p->mp_reg_rx_avail_monitor_data) + return -ENOTSUP; + + nthw_dbs_set_shadow_rx_am_data_enable(p, index, enable); + flush_rx_am_data(p, index); + return 0; +} + static void set_tx_am_data_index(nthw_dbs_t *p, uint32_t index) { nthw_field_set_val32(p->mp_fld_tx_avail_monitor_control_adr, index); @@ -680,6 +690,16 @@ int set_tx_am_data(nthw_dbs_t *p, return 0; } +int set_tx_am_data_enable(nthw_dbs_t *p, uint32_t index, uint32_t enable) +{ + if (!p->mp_reg_tx_avail_monitor_data) + return -ENOTSUP; + + p->m_tx_am_shadow[index].enable = enable; + flush_tx_am_data(p, index); + return 0; +} + static void set_rx_uw_data_index(nthw_dbs_t *p, uint32_t index) { nthw_field_set_val32(p->mp_fld_rx_used_writer_control_adr, index); diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index c2a507675c..d961edb903 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -1180,25 +1180,97 @@ static int dev_set_mtu_inline(struct rte_eth_dev *eth_dev, uint16_t mtu) static int eth_rx_queue_start(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id) { + if (sg_ops == NULL) { + NT_LOG_DBGX(DBG, NTNIC, "SG module is not initialized"); + return -1; + } + + struct pmd_internals *internals = eth_dev->data->dev_private; + struct drv_s *p_drv = internals->p_drv; + struct ntdrv_4ga_s *p_nt_drv = &p_drv->ntdrv; + nthw_dbs_t *p_nthw_dbs = p_nt_drv->adapter_info.fpga_info.mp_nthw_dbs; + struct ntnic_rx_queue *rx_q = &internals->rxq_scg[rx_queue_id]; + int index = rx_q->queue.hw_id; + + if (sg_ops->nthw_switch_rx_virt_queue(p_nthw_dbs, index, 1) != 0) { + NT_LOG_DBGX(DBG, NTNIC, "Failed to start Rx queue #%d", index); + return -1; + } + + rx_q->enabled = 1; eth_dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED; return 0; } static int eth_rx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id) { + if (sg_ops == NULL) { + NT_LOG_DBGX(DBG, NTNIC, "SG module is not initialized"); + return -1; + } + + struct pmd_internals *internals = eth_dev->data->dev_private; + struct drv_s *p_drv = internals->p_drv; + struct ntdrv_4ga_s *p_nt_drv = &p_drv->ntdrv; + nthw_dbs_t *p_nthw_dbs = p_nt_drv->adapter_info.fpga_info.mp_nthw_dbs; + struct ntnic_rx_queue *rx_q = &internals->rxq_scg[rx_queue_id]; + int index = rx_q->queue.hw_id; + + if (sg_ops->nthw_switch_rx_virt_queue(p_nthw_dbs, index, 0) != 0) { + NT_LOG_DBGX(DBG, NTNIC, "Failed to stop Rx queue #%d", index); + return -1; + } + + rx_q->enabled = 0; eth_dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED; return 0; } -static int eth_tx_queue_start(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id) +static int eth_tx_queue_start(struct rte_eth_dev *eth_dev, uint16_t tx_queue_id) { - eth_dev->data->tx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED; + if (sg_ops == NULL) { + NT_LOG_DBGX(DBG, NTNIC, "SG module is not initialized"); + return -1; + } + + struct pmd_internals *internals = eth_dev->data->dev_private; + struct drv_s *p_drv = internals->p_drv; + struct ntdrv_4ga_s *p_nt_drv = &p_drv->ntdrv; + nthw_dbs_t *p_nthw_dbs = p_nt_drv->adapter_info.fpga_info.mp_nthw_dbs; + struct ntnic_tx_queue *tx_q = &internals->txq_scg[tx_queue_id]; + int index = tx_q->queue.hw_id; + + if (sg_ops->nthw_switch_tx_virt_queue(p_nthw_dbs, index, 1) != 0) { + NT_LOG_DBGX(DBG, NTNIC, "Failed to start Tx queue #%d", index); + return -1; + } + + tx_q->enabled = 1; + eth_dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED; return 0; } -static int eth_tx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id) +static int eth_tx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t tx_queue_id) { - eth_dev->data->tx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED; + if (sg_ops == NULL) { + NT_LOG_DBGX(DBG, NTNIC, "SG module is not initialized"); + return -1; + } + + struct pmd_internals *internals = eth_dev->data->dev_private; + struct drv_s *p_drv = internals->p_drv; + struct ntdrv_4ga_s *p_nt_drv = &p_drv->ntdrv; + nthw_dbs_t *p_nthw_dbs = p_nt_drv->adapter_info.fpga_info.mp_nthw_dbs; + struct ntnic_tx_queue *tx_q = &internals->txq_scg[tx_queue_id]; + int index = tx_q->queue.hw_id; + + if (sg_ops->nthw_switch_tx_virt_queue(p_nthw_dbs, index, 0) != 0) { + NT_LOG_DBGX(DBG, NTNIC, "Failed to stop Tx queue #%d", index); + return -1; + } + + tx_q->enabled = 0; + eth_dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED; return 0; } diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index 9d14bebd7a..7f5bd5e0ec 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -94,6 +94,8 @@ struct sg_ops_s { int irq_vector, uint32_t in_order); int (*nthw_release_mngd_tx_virt_queue)(struct nthw_virt_queue *txvq); + int (*nthw_switch_rx_virt_queue)(nthw_dbs_t *p_nthw_dbs, uint32_t index, uint32_t enable); + int (*nthw_switch_tx_virt_queue)(nthw_dbs_t *p_nthw_dbs, uint32_t index, uint32_t enable); /* * These functions handles both Split and Packed including merged buffers (jumbo) */ -- 2.47.1