net/hns3: support power monitor

Message ID 20240205083521.3782951-1-haijie1@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/hns3: support power monitor |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-intel-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Jie Hai Feb. 5, 2024, 8:35 a.m. UTC
  From: Chengwen Feng <fengchengwen@huawei.com>

This commit supports power monitor on the Rx queue descriptor of the
next poll.

Note: Although rte_power_monitor() on the ARM platform does not support
callback, this commit still implements the callback so that it does not
need to be adjusted after the ARM platform supports callback.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c    |  1 +
 drivers/net/hns3/hns3_ethdev_vf.c |  1 +
 drivers/net/hns3/hns3_rxtx.c      | 21 +++++++++++++++++++++
 drivers/net/hns3/hns3_rxtx.h      |  1 +
 4 files changed, 24 insertions(+)
  

Comments

Ferruh Yigit Feb. 7, 2024, 6:29 p.m. UTC | #1
On 2/5/2024 8:35 AM, Jie Hai wrote:
> From: Chengwen Feng <fengchengwen@huawei.com>
> 
> This commit supports power monitor on the Rx queue descriptor of the
> next poll.
> 
> Note: Although rte_power_monitor() on the ARM platform does not support
> callback, this commit still implements the callback so that it does not
> need to be adjusted after the ARM platform supports callback.
> 
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> Signed-off-by: Jie Hai <haijie1@huawei.com>
>

Applied to dpdk-next-net/main, thanks.
  

Patch

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index eafcf2c6f644..b10d1216d2d1 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -6501,6 +6501,7 @@  static const struct eth_dev_ops hns3_eth_dev_ops = {
 	.eth_dev_priv_dump          = hns3_eth_dev_priv_dump,
 	.eth_rx_descriptor_dump     = hns3_rx_descriptor_dump,
 	.eth_tx_descriptor_dump     = hns3_tx_descriptor_dump,
+	.get_monitor_addr           = hns3_get_monitor_addr,
 };
 
 static const struct hns3_reset_ops hns3_reset_ops = {
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 83d3d660056d..4eeb46a34448 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -2209,6 +2209,7 @@  static const struct eth_dev_ops hns3vf_eth_dev_ops = {
 	.eth_dev_priv_dump  = hns3_eth_dev_priv_dump,
 	.eth_rx_descriptor_dump = hns3_rx_descriptor_dump,
 	.eth_tx_descriptor_dump = hns3_tx_descriptor_dump,
+	.get_monitor_addr       = hns3_get_monitor_addr,
 };
 
 static const struct hns3_reset_ops hns3vf_reset_ops = {
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 228490eb6e01..7e636a0a2e99 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -4884,3 +4884,24 @@  hns3_start_rxtx_datapath(struct rte_eth_dev *dev)
 
 	hns3_mp_req_start_rxtx(dev);
 }
+
+static int
+hns3_monitor_callback(const uint64_t value,
+		const uint64_t arg[RTE_POWER_MONITOR_OPAQUE_SZ] __rte_unused)
+{
+	const uint64_t vld = rte_le_to_cpu_32(BIT(HNS3_RXD_VLD_B));
+	return (value & vld) == vld ? -1 : 0;
+}
+
+int
+hns3_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc)
+{
+	struct hns3_rx_queue *rxq = rx_queue;
+	struct hns3_desc *rxdp = &rxq->rx_ring[rxq->next_to_use];
+
+	pmc->addr = &rxdp->rx.bd_base_info;
+	pmc->fn = hns3_monitor_callback;
+	pmc->size = sizeof(uint32_t);
+
+	return 0;
+}
diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h
index c1c8bd29d8ea..e2ad42bb8e30 100644
--- a/drivers/net/hns3/hns3_rxtx.h
+++ b/drivers/net/hns3/hns3_rxtx.h
@@ -815,5 +815,6 @@  void hns3_stop_tx_datapath(struct rte_eth_dev *dev);
 void hns3_start_tx_datapath(struct rte_eth_dev *dev);
 void hns3_stop_rxtx_datapath(struct rte_eth_dev *dev);
 void hns3_start_rxtx_datapath(struct rte_eth_dev *dev);
+int hns3_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc);
 
 #endif /* HNS3_RXTX_H */