mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 09:58:01 +00:00
Until now there was only two options for XDP mode in OVS: SKB or DRV. i.e. 'generic XDP' or 'native XDP with zero-copy enabled'. Devices like 'veth' interfaces in Linux supports native XDP, but doesn't support zero-copy mode. This case can not be covered by existing API and we have to use slower generic XDP for such devices. There are few more issues, e.g. TCP is not supported in generic XDP mode for veth interfaces due to kernel limitations, however it is supported in native mode. This change introduces ability to use native XDP without zero-copy along with best-effort configuration option that enabled by default. In best-effort case OVS will sequentially try different modes starting from the fastest one and will choose the first acceptable for current interface. This will guarantee the best possible performance. If user will want to choose specific mode, it's still possible by setting the 'options:xdp-mode'. This change additionally changes the API by renaming the configuration knob from 'xdpmode' to 'xdp-mode' and also renaming the modes themselves to be more user-friendly. The full list of currently supported modes: * native-with-zerocopy - former DRV * native - new one, DRV without zero-copy * generic - former SKB * best-effort - new one, chooses the best available from 3 above modes Since 'best-effort' is a default mode, users will not need to explicitely set 'xdp-mode' in most cases. TCP related tests enabled back in system afxdp testsuite, because 'best-effort' will choose 'native' mode for veth interfaces and this mode has no issues with TCP. Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: William Tu <u9012063@gmail.com> Acked-by: Eelco Chaudron <echaudro@redhat.com>
87 lines
2.6 KiB
C
87 lines
2.6 KiB
C
/*
|
|
* Copyright (c) 2018, 2019 Nicira, Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at:
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#ifndef NETDEV_AFXDP_H
|
|
#define NETDEV_AFXDP_H 1
|
|
|
|
#ifdef HAVE_AF_XDP
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
/* These functions are Linux AF_XDP specific, so they should be used directly
|
|
* only by Linux-specific code. */
|
|
|
|
enum afxdp_mode {
|
|
OVS_AF_XDP_MODE_UNSPEC,
|
|
OVS_AF_XDP_MODE_BEST_EFFORT,
|
|
OVS_AF_XDP_MODE_NATIVE_ZC,
|
|
OVS_AF_XDP_MODE_NATIVE,
|
|
OVS_AF_XDP_MODE_GENERIC,
|
|
OVS_AF_XDP_MODE_MAX,
|
|
};
|
|
|
|
struct netdev;
|
|
struct xsk_socket_info;
|
|
struct xdp_umem;
|
|
struct dp_packet_batch;
|
|
struct smap;
|
|
struct dp_packet;
|
|
struct netdev_rxq;
|
|
struct netdev_stats;
|
|
struct netdev_custom_stats;
|
|
|
|
int netdev_afxdp_rxq_construct(struct netdev_rxq *rxq_);
|
|
void netdev_afxdp_rxq_destruct(struct netdev_rxq *rxq_);
|
|
int netdev_afxdp_construct(struct netdev *netdev_);
|
|
void netdev_afxdp_destruct(struct netdev *netdev_);
|
|
int netdev_afxdp_verify_mtu_size(const struct netdev *netdev, int mtu);
|
|
|
|
int netdev_afxdp_rxq_recv(struct netdev_rxq *rxq_,
|
|
struct dp_packet_batch *batch,
|
|
int *qfill);
|
|
int netdev_afxdp_batch_send(struct netdev *netdev_, int qid,
|
|
struct dp_packet_batch *batch,
|
|
bool concurrent_txq);
|
|
int netdev_afxdp_set_config(struct netdev *netdev, const struct smap *args,
|
|
char **errp);
|
|
int netdev_afxdp_get_config(const struct netdev *netdev, struct smap *args);
|
|
int netdev_afxdp_get_numa_id(const struct netdev *netdev);
|
|
int netdev_afxdp_get_stats(const struct netdev *netdev_,
|
|
struct netdev_stats *stats);
|
|
int netdev_afxdp_get_custom_stats(const struct netdev *netdev,
|
|
struct netdev_custom_stats *custom_stats);
|
|
|
|
|
|
void free_afxdp_buf(struct dp_packet *p);
|
|
int netdev_afxdp_reconfigure(struct netdev *netdev);
|
|
void signal_remove_xdp(struct netdev *netdev);
|
|
|
|
#else /* !HAVE_AF_XDP */
|
|
|
|
#include "openvswitch/compiler.h"
|
|
|
|
struct dp_packet;
|
|
|
|
static inline void
|
|
free_afxdp_buf(struct dp_packet *p OVS_UNUSED)
|
|
{
|
|
/* Nothing. */
|
|
}
|
|
|
|
#endif /* HAVE_AF_XDP */
|
|
#endif /* netdev-afxdp.h */
|