[ovs-dev] [PATCH V2 13/19] netdev-dpdk: Getter function for dpdk port id API

Ilya Maximets i.maximets at ovn.org
Wed Dec 4 15:21:55 UTC 2019


On 02.12.2019 09:41, Eli Britstein wrote:
> Add a getter function for using the dpdk port id outside the scope of
> netdev-dpdk.c to be used for HW offload.
> 
> Signed-off-by: Eli Britstein <elibr at mellanox.com>
> Reviewed-by: Oz Shlomo <ozsh at mellanox.com>
> ---
>  lib/netdev-dpdk.c | 9 +++++++++
>  lib/netdev-dpdk.h | 2 ++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> index c891d3ed9..d047f4439 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -4426,6 +4426,15 @@ unlock:
>      return err;
>  }
>  
> +int
> +netdev_dpdk_get_port_id(const struct netdev *netdev)
> +{
> +    if (!is_dpdk_class(netdev->netdev_class)) {
> +        return -1;
> +    }
> +    return CONTAINER_OF(netdev, struct netdev_dpdk, up)->port_id;

You need to hold netdev mutex while using the port_id.
So, this is not a good solution.

> +}
> +
>  bool
>  netdev_dpdk_flow_api_supported(struct netdev *netdev)
>  {
> diff --git a/lib/netdev-dpdk.h b/lib/netdev-dpdk.h
> index 8e79bcdf8..54582ed90 100644
> --- a/lib/netdev-dpdk.h
> +++ b/lib/netdev-dpdk.h
> @@ -56,6 +56,8 @@ netdev_dpdk_rte_flow_query(struct netdev *netdev,
>                             struct rte_flow *rte_flow,
>                             struct rte_flow_query_count *query,
>                             struct rte_flow_error *error);
> +int
> +netdev_dpdk_get_port_id(const struct netdev *netdev);
>  
>  #else
>  
> 


More information about the dev mailing list