From: Oleksandr Kolomeiets <okl-plv@napatech.com>
To: dev@dpdk.org
Cc: mko-plv@napatech.com, sil-plv@napatech.com, ckm@napatech.com,
stephen@networkplumber.org
Subject: [PATCH v1 1/4] net/ntnic: implement start/stop for Rx/Tx queues
Date: Fri, 20 Jun 2025 13:27:04 +0200 [thread overview]
Message-ID: <20250620112707.294596-2-okl-plv@napatech.com> (raw)
In-Reply-To: <20250620112707.294596-1-okl-plv@napatech.com>
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-plv@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
next prev parent reply other threads:[~2025-06-20 11:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 11:27 [PATCH v1 0/4] net/ntnic: implement start, stop and deferred start " Oleksandr Kolomeiets
2025-06-20 11:27 ` Oleksandr Kolomeiets [this message]
2025-06-20 11:27 ` [PATCH v1 2/4] net/ntnic: implement " Oleksandr Kolomeiets
2025-06-20 11:27 ` [PATCH v1 3/4] net/ntnic: unmap DMA during queue release Oleksandr Kolomeiets
2025-06-20 11:27 ` [PATCH v1 4/4] net/ntnic: add warning when sending on a stopped queue Oleksandr Kolomeiets
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250620112707.294596-2-okl-plv@napatech.com \
--to=okl-plv@napatech.com \
--cc=ckm@napatech.com \
--cc=dev@dpdk.org \
--cc=mko-plv@napatech.com \
--cc=sil-plv@napatech.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).