From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6BAB943A74; Mon, 5 Feb 2024 09:39:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 05994402BE; Mon, 5 Feb 2024 09:39:42 +0100 (CET) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mails.dpdk.org (Postfix) with ESMTP id 5556B400D6 for ; Mon, 5 Feb 2024 09:39:39 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TT0BD0yYJz29ktl; Mon, 5 Feb 2024 16:37:40 +0800 (CST) Received: from kwepemd100004.china.huawei.com (unknown [7.221.188.31]) by mail.maildlp.com (Postfix) with ESMTPS id D86CE140593; Mon, 5 Feb 2024 16:39:34 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemd100004.china.huawei.com (7.221.188.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.28; Mon, 5 Feb 2024 16:39:34 +0800 From: Jie Hai To: CC: , , , , Subject: [PATCH] net/hns3: support power monitor Date: Mon, 5 Feb 2024 16:35:21 +0800 Message-ID: <20240205083521.3782951-1-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemd100004.china.huawei.com (7.221.188.31) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Chengwen Feng 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 Signed-off-by: Jie Hai --- 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(+) 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 */ -- 2.30.0