diff mbox series

[21.08,v1,2/2] net/af_xdp: add power monitor support

Message ID 9dabec2f673cbf733a958a23a9769802e9adf852.1620747068.git.anatoly.burakov@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series [21.08,v1,1/2] power: invert the monitor check | expand

Checks

Context Check Description
ci/iol-mellanox-Functional success Functional Testing PASS
ci/github-robot success github build: passed
ci/iol-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/checkpatch warning coding style issues

Commit Message

Anatoly Burakov May 11, 2021, 3:31 p.m. UTC
Implement support for .get_monitor_addr in AF_XDP driver.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 52 ++++++++++++++++++++---------
 1 file changed, 37 insertions(+), 15 deletions(-)

Comments

Anatoly Burakov May 11, 2021, 3:37 p.m. UTC | #1
On 11-May-21 4:31 PM, Anatoly Burakov wrote:
> Implement support for .get_monitor_addr in AF_XDP driver.
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---

<snip>

>   static const struct eth_dev_ops ops = {
> -	.dev_start = eth_dev_start,
> -	.dev_stop = eth_dev_stop,
> -	.dev_close = eth_dev_close,
> -	.dev_configure = eth_dev_configure,
> -	.dev_infos_get = eth_dev_info,
> -	.mtu_set = eth_dev_mtu_set,
> -	.promiscuous_enable = eth_dev_promiscuous_enable,
> -	.promiscuous_disable = eth_dev_promiscuous_disable,
> -	.rx_queue_setup = eth_rx_queue_setup,
> -	.tx_queue_setup = eth_tx_queue_setup,
> -	.rx_queue_release = eth_queue_release,
> -	.tx_queue_release = eth_queue_release,
> -	.link_update = eth_link_update,
> -	.stats_get = eth_stats_get,
> -	.stats_reset = eth_stats_reset,
> +    .dev_start = eth_dev_start,
> +    .dev_stop = eth_dev_stop,
> +    .dev_close = eth_dev_close,
> +    .dev_configure = eth_dev_configure,
> +    .dev_infos_get = eth_dev_info,
> +    .mtu_set = eth_dev_mtu_set,
> +    .promiscuous_enable = eth_dev_promiscuous_enable,
> +    .promiscuous_disable = eth_dev_promiscuous_disable,
> +    .rx_queue_setup = eth_rx_queue_setup,
> +    .tx_queue_setup = eth_tx_queue_setup,
> +    .rx_queue_release = eth_queue_release,
> +    .tx_queue_release = eth_queue_release,
> +    .link_update = eth_link_update,
> +    .stats_get = eth_stats_get,
> +    .stats_reset = eth_stats_reset,
> +    .get_monitor_addr = eth_get_monitor_addr
>   };
>   
>   /** parse busy_budget argument */
> 

Oops, accidental whitespace changes...
Ciara Loftus May 12, 2021, 10:43 a.m. UTC | #2
> 
> Implement support for .get_monitor_addr in AF_XDP driver.
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>  drivers/net/af_xdp/rte_eth_af_xdp.c | 52 ++++++++++++++++++++---------
>  1 file changed, 37 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c
> b/drivers/net/af_xdp/rte_eth_af_xdp.c
> index 0c91a40c4a..a4b4a4b75d 100644
> --- a/drivers/net/af_xdp/rte_eth_af_xdp.c
> +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
> @@ -37,6 +37,7 @@
>  #include <rte_malloc.h>
>  #include <rte_ring.h>
>  #include <rte_spinlock.h>
> +#include <rte_power_intrinsics.h>
> 
>  #include "compat.h"
> 
> @@ -778,6 +779,26 @@ eth_dev_configure(struct rte_eth_dev *dev)
>  	return 0;
>  }
> 
> +static int
> +eth_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond
> *pmc)
> +{
> +	struct pkt_rx_queue *rxq = rx_queue;
> +	unsigned int *prod = rxq->fq.producer;
> +	const uint32_t cur_val = rxq->fq.cached_prod; /* use cached value

The above two lines should use the producer from the rx ring 'rx' instead of the fill queue 'fq'.
So instead of rxq->fq.* should be rxq->rx.*

Other than that, and once the additional whitespace you identified below is removed it LGTM.

Thanks,
Ciara

> */
> +
> +	/* watch for changes in producer ring */
> +	pmc->addr = (void*)prod;
> +
> +	/* store current value */
> +	pmc->val = cur_val;
> +	pmc->mask = (uint32_t)~0; /* mask entire uint32_t value */
> +
> +	/* AF_XDP producer ring index is 32-bit */
> +	pmc->size = sizeof(uint32_t);
> +
> +	return 0;
> +}
> +
>  static int
>  eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
>  {
> @@ -1423,21 +1444,22 @@ eth_dev_promiscuous_disable(struct
> rte_eth_dev *dev)
>  }
> 
>  static const struct eth_dev_ops ops = {
> -	.dev_start = eth_dev_start,
> -	.dev_stop = eth_dev_stop,
> -	.dev_close = eth_dev_close,
> -	.dev_configure = eth_dev_configure,
> -	.dev_infos_get = eth_dev_info,
> -	.mtu_set = eth_dev_mtu_set,
> -	.promiscuous_enable = eth_dev_promiscuous_enable,
> -	.promiscuous_disable = eth_dev_promiscuous_disable,
> -	.rx_queue_setup = eth_rx_queue_setup,
> -	.tx_queue_setup = eth_tx_queue_setup,
> -	.rx_queue_release = eth_queue_release,
> -	.tx_queue_release = eth_queue_release,
> -	.link_update = eth_link_update,
> -	.stats_get = eth_stats_get,
> -	.stats_reset = eth_stats_reset,
> +    .dev_start = eth_dev_start,
> +    .dev_stop = eth_dev_stop,
> +    .dev_close = eth_dev_close,
> +    .dev_configure = eth_dev_configure,
> +    .dev_infos_get = eth_dev_info,
> +    .mtu_set = eth_dev_mtu_set,
> +    .promiscuous_enable = eth_dev_promiscuous_enable,
> +    .promiscuous_disable = eth_dev_promiscuous_disable,
> +    .rx_queue_setup = eth_rx_queue_setup,
> +    .tx_queue_setup = eth_tx_queue_setup,
> +    .rx_queue_release = eth_queue_release,
> +    .tx_queue_release = eth_queue_release,
> +    .link_update = eth_link_update,
> +    .stats_get = eth_stats_get,
> +    .stats_reset = eth_stats_reset,
> +    .get_monitor_addr = eth_get_monitor_addr
>  };
> 
>  /** parse busy_budget argument */
> --
> 2.25.1
Liang Ma June 1, 2021, 3:02 p.m. UTC | #3
AF_XDP eventually support umwait.  looking forward to reviewing the
updated version
diff mbox series

Patch

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 0c91a40c4a..a4b4a4b75d 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -37,6 +37,7 @@ 
 #include <rte_malloc.h>
 #include <rte_ring.h>
 #include <rte_spinlock.h>
+#include <rte_power_intrinsics.h>
 
 #include "compat.h"
 
@@ -778,6 +779,26 @@  eth_dev_configure(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+eth_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc)
+{
+	struct pkt_rx_queue *rxq = rx_queue;
+	unsigned int *prod = rxq->fq.producer;
+	const uint32_t cur_val = rxq->fq.cached_prod; /* use cached value */
+
+	/* watch for changes in producer ring */
+	pmc->addr = (void*)prod;
+
+	/* store current value */
+	pmc->val = cur_val;
+	pmc->mask = (uint32_t)~0; /* mask entire uint32_t value */
+
+	/* AF_XDP producer ring index is 32-bit */
+	pmc->size = sizeof(uint32_t);
+
+	return 0;
+}
+
 static int
 eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
@@ -1423,21 +1444,22 @@  eth_dev_promiscuous_disable(struct rte_eth_dev *dev)
 }
 
 static const struct eth_dev_ops ops = {
-	.dev_start = eth_dev_start,
-	.dev_stop = eth_dev_stop,
-	.dev_close = eth_dev_close,
-	.dev_configure = eth_dev_configure,
-	.dev_infos_get = eth_dev_info,
-	.mtu_set = eth_dev_mtu_set,
-	.promiscuous_enable = eth_dev_promiscuous_enable,
-	.promiscuous_disable = eth_dev_promiscuous_disable,
-	.rx_queue_setup = eth_rx_queue_setup,
-	.tx_queue_setup = eth_tx_queue_setup,
-	.rx_queue_release = eth_queue_release,
-	.tx_queue_release = eth_queue_release,
-	.link_update = eth_link_update,
-	.stats_get = eth_stats_get,
-	.stats_reset = eth_stats_reset,
+    .dev_start = eth_dev_start,
+    .dev_stop = eth_dev_stop,
+    .dev_close = eth_dev_close,
+    .dev_configure = eth_dev_configure,
+    .dev_infos_get = eth_dev_info,
+    .mtu_set = eth_dev_mtu_set,
+    .promiscuous_enable = eth_dev_promiscuous_enable,
+    .promiscuous_disable = eth_dev_promiscuous_disable,
+    .rx_queue_setup = eth_rx_queue_setup,
+    .tx_queue_setup = eth_tx_queue_setup,
+    .rx_queue_release = eth_queue_release,
+    .tx_queue_release = eth_queue_release,
+    .link_update = eth_link_update,
+    .stats_get = eth_stats_get,
+    .stats_reset = eth_stats_reset,
+    .get_monitor_addr = eth_get_monitor_addr
 };
 
 /** parse busy_budget argument */