On 7/16/23 13:57, Ivan Malov wrote:
> This may be required by some PMDs in offload scenarios.

Seems reasonable.  I don't have HW with a driver that implements this
API, but the change doesn't seem too risky.  So, applied and backported
down to 3.1.  Thanks!

> 
> Fixes: e8a2b5bf92bb ("netdev-dpdk: implement flow offload with rte flow")

This is not the right tag, because the metadata negotiation API
didn't exist back then.  It should've been a patch that added
support for DPDK 22.11 instead.  But I realized that after I pushed
the change.  So it will stay this way in the repo...  Sorry.

Best regards, Ilya Maximets.

> Signed-off-by: Ivan Malov <[email protected]>
> ---
>  v2: add missing experimental api ifdef
> 
>  lib/netdev-dpdk.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 56 insertions(+)
> 
> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> index aa87ee546..ea4cc6977 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -512,6 +512,9 @@ struct netdev_dpdk {
>  
>          /* Array of vhost rxq states, see vring_state_changed. */
>          bool *vhost_rxq_enabled;
> +
> +        /* Ensures that Rx metadata delivery is configured only once. */
> +        bool rx_metadata_delivery_configured;
>      );
>  
>      PADDED_MEMBERS(CACHE_LINE_SIZE,
> @@ -1220,6 +1223,45 @@ dpdk_eth_flow_ctrl_setup(struct netdev_dpdk *dev) 
> OVS_REQUIRES(dev->mutex)
>      }
>  }
>  
> +static void
> +dpdk_eth_dev_init_rx_metadata(struct netdev_dpdk *dev)
> +{
> +    uint64_t rx_metadata = 0;
> +    int ret;
> +
> +    if (dev->rx_metadata_delivery_configured) {
> +        return;
> +    }
> +
> +    /* For the fallback offload (non-"transfer" rules) */
> +    rx_metadata |= RTE_ETH_RX_METADATA_USER_MARK;
> +
> +#ifdef ALLOW_EXPERIMENTAL_API
> +    /* For the tunnel offload  */
> +    rx_metadata |= RTE_ETH_RX_METADATA_TUNNEL_ID;
> +#endif /* ALLOW_EXPERIMENTAL_API */
> +
> +    ret = rte_eth_rx_metadata_negotiate(dev->port_id, &rx_metadata);
> +    if (ret == 0) {
> +        if (!(rx_metadata & RTE_ETH_RX_METADATA_USER_MARK)) {
> +            VLOG_DBG("%s: The NIC will not provide per-packet USER_MARK",
> +                     netdev_get_name(&dev->up));
> +        }
> +#ifdef ALLOW_EXPERIMENTAL_API
> +        if (!(rx_metadata & RTE_ETH_RX_METADATA_TUNNEL_ID)) {
> +            VLOG_DBG("%s: The NIC will not provide per-packet TUNNEL_ID",
> +                     netdev_get_name(&dev->up));
> +        }
> +#endif /* ALLOW_EXPERIMENTAL_API */
> +    } else {
> +        VLOG(ret == -ENOTSUP ? VLL_DBG : VLL_WARN,
> +             "%s: Cannot negotiate Rx metadata: %s",
> +             netdev_get_name(&dev->up), rte_strerror(-ret));
> +    }
> +
> +    dev->rx_metadata_delivery_configured = true;
> +}
> +
>  static int
>  dpdk_eth_dev_init(struct netdev_dpdk *dev)
>      OVS_REQUIRES(dev->mutex)
> @@ -1233,6 +1275,18 @@ dpdk_eth_dev_init(struct netdev_dpdk *dev)
>                                       RTE_ETH_RX_OFFLOAD_TCP_CKSUM |
>                                       RTE_ETH_RX_OFFLOAD_IPV4_CKSUM;
>  
> +    if (netdev_is_flow_api_enabled()) {
> +        /*
> +         * Full tunnel offload requires that tunnel ID metadata be
> +         * delivered with "miss" packets from the hardware to the
> +         * PMD. The same goes for megaflow mark metadata which is
> +         * used in MARK + RSS offload scenario.
> +         *
> +         * Request delivery of such metadata.
> +         */
> +        dpdk_eth_dev_init_rx_metadata(dev);
> +    }
> +
>      rte_eth_dev_info_get(dev->port_id, &info);
>  
>      if (strstr(info.driver_name, "vf") != NULL) {
> @@ -1421,6 +1475,8 @@ common_construct(struct netdev *netdev, dpdk_port_t 
> port_no,
>      /* Initilize the hardware offload flags to 0 */
>      dev->hw_ol_features = 0;
>  
> +    dev->rx_metadata_delivery_configured = false;
> +
>      dev->flags = NETDEV_UP | NETDEV_PROMISC;
>  
>      ovs_list_push_back(&dpdk_list, &dev->list_node);

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to