On Mon, Oct 16, 2023 at 01:57:11PM -0700, Sivaprasad Tummala wrote:
> Currently sw eventdev pmd does not support ``rte_power_monitor`` api.
> This patch adds support by adding monitor callback that is called
> whenever we enter sleep state and need to check if it is time to
> wake up.
> 
> Signed-off-by: Sivaprasad Tummala <sivaprasad.tumm...@amd.com>
> ---
>  drivers/event/sw/sw_evdev.c        |  1 +
>  drivers/event/sw/sw_evdev.h        |  2 ++
>  drivers/event/sw/sw_evdev_worker.c | 27 +++++++++++++++++++++++++++
>  3 files changed, 30 insertions(+)
> 
> diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
> index 6d1816b76d..99b3c0d92f 100644
> --- a/drivers/event/sw/sw_evdev.c
> +++ b/drivers/event/sw/sw_evdev.c
> @@ -958,6 +958,7 @@ sw_probe(struct rte_vdev_device *vdev)
>                       .port_link = sw_port_link,
>                       .port_unlink = sw_port_unlink,
>                       .port_unlinks_in_progress = sw_port_unlinks_in_progress,
> +                     .get_monitor_addr = sw_event_get_monitor_addr,
>  
>                       .eth_rx_adapter_caps_get = sw_eth_rx_adapter_caps_get,
>  
> diff --git a/drivers/event/sw/sw_evdev.h b/drivers/event/sw/sw_evdev.h
> index c7b943a72b..26aa2fe283 100644
> --- a/drivers/event/sw/sw_evdev.h
> +++ b/drivers/event/sw/sw_evdev.h
> @@ -312,6 +312,8 @@ int sw_xstats_reset(struct rte_eventdev *dev,
>               int16_t queue_port_id,
>               const uint64_t ids[],
>               uint32_t nb_ids);
> +int sw_event_get_monitor_addr(void *port,
> +             struct rte_power_monitor_cond *pmc);
>  
>  int test_sw_eventdev(void);
>  
> diff --git a/drivers/event/sw/sw_evdev_worker.c 
> b/drivers/event/sw/sw_evdev_worker.c
> index 063b919c7e..139c98cfe2 100644
> --- a/drivers/event/sw/sw_evdev_worker.c
> +++ b/drivers/event/sw/sw_evdev_worker.c
> @@ -10,6 +10,33 @@
>  
>  #define PORT_ENQUEUE_MAX_BURST_SIZE 64
>  
> +static int
> +sw_event_ring_monitor_callback(const uint64_t value,
> +             const uint64_t arg[RTE_POWER_MONITOR_OPAQUE_SZ])
> +{
> +     /* Check if the head pointer has changed */
> +     return value != arg[0];
> +}
> +
> +int
> +sw_event_get_monitor_addr(void *port, struct rte_power_monitor_cond *pmc)
> +{
> +     struct sw_port *p = (void *)port;
                             ^^^^^^ cast seems redundant

Reply via email to