2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-23 10:28:00 +00:00
ovs/lib/dpif-netdev-private-dpif.h

74 lines
2.6 KiB
C
Raw Normal View History

/*
* Copyright (c) 2021 Intel Corporation.
*
* 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 DPIF_NETDEV_PRIVATE_DPIF_H
#define DPIF_NETDEV_PRIVATE_DPIF_H 1
#include "openvswitch/types.h"
/* Forward declarations to avoid including files. */
struct dp_netdev_pmd_thread;
struct dp_packet_batch;
dpif-netdev: Add command to switch dpif implementation. This commit adds a new command to allow the user to switch the active DPIF implementation at runtime. A probe function is executed before switching the DPIF implementation, to ensure the CPU is capable of running the ISA required. For example, the below code will switch to the AVX512 enabled DPIF assuming that the runtime CPU is capable of running AVX512 instructions: $ ovs-appctl dpif-netdev/dpif-impl-set dpif_avx512 A new configuration flag is added to allow selection of the default DPIF. This is useful for running the unit-tests against the available DPIF implementations, without modifying each unit test. The design of the testing & validation for ISA optimized DPIF implementations is based around the work already upstream for DPCLS. Note however that a DPCLS lookup has no state or side-effects, allowing the auto-validator implementation to perform multiple lookups and provide consistent statistic counters. The DPIF component does have state, so running two implementations in parallel and comparing output is not a valid testing method, as there are changes in DPIF statistic counters (side effects). As a result, the DPIF is tested directly against the unit-tests. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> Co-authored-by: Cian Ferriter <cian.ferriter@intel.com> Signed-off-by: Cian Ferriter <cian.ferriter@intel.com> Acked-by: Flavio Leitner <fbl@sysclose.org> Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2021-07-09 15:58:18 +00:00
/* Typedef for DPIF functions.
* Returns whether all packets were processed successfully.
*/
typedef int32_t (*dp_netdev_input_func)(struct dp_netdev_pmd_thread *pmd,
struct dp_packet_batch *packets,
odp_port_t port_no);
/* Probe a DPIF implementation. This allows the implementation to validate CPU
* ISA availability. Returns -ENOTSUP if not available, returns 0 if valid to
* use.
*/
typedef int32_t (*dp_netdev_input_func_probe)(void);
/* Structure describing each available DPIF implementation. */
struct dpif_netdev_impl_info_t {
/* Function pointer to execute to have this DPIF implementation run. */
dp_netdev_input_func input_func;
/* Function pointer to execute to check the CPU ISA is available to run. If
* not necessary, it must be set to NULL which implies that it is always
* valid to use. */
dp_netdev_input_func_probe probe;
/* Name used to select this DPIF implementation. */
const char *name;
};
/* Returns the default DPIF which is first ./configure selected, but can be
* overridden at runtime. */
dp_netdev_input_func dp_netdev_impl_get_default(void);
/* Overrides the default DPIF with the user set DPIF. */
int32_t dp_netdev_impl_set_default_by_name(const char *name);
/* Available DPIF implementations below. */
dpif-netdev: Add command to switch dpif implementation. This commit adds a new command to allow the user to switch the active DPIF implementation at runtime. A probe function is executed before switching the DPIF implementation, to ensure the CPU is capable of running the ISA required. For example, the below code will switch to the AVX512 enabled DPIF assuming that the runtime CPU is capable of running AVX512 instructions: $ ovs-appctl dpif-netdev/dpif-impl-set dpif_avx512 A new configuration flag is added to allow selection of the default DPIF. This is useful for running the unit-tests against the available DPIF implementations, without modifying each unit test. The design of the testing & validation for ISA optimized DPIF implementations is based around the work already upstream for DPCLS. Note however that a DPCLS lookup has no state or side-effects, allowing the auto-validator implementation to perform multiple lookups and provide consistent statistic counters. The DPIF component does have state, so running two implementations in parallel and comparing output is not a valid testing method, as there are changes in DPIF statistic counters (side effects). As a result, the DPIF is tested directly against the unit-tests. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> Co-authored-by: Cian Ferriter <cian.ferriter@intel.com> Signed-off-by: Cian Ferriter <cian.ferriter@intel.com> Acked-by: Flavio Leitner <fbl@sysclose.org> Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2021-07-09 15:58:18 +00:00
int32_t
dp_netdev_input(struct dp_netdev_pmd_thread *pmd,
struct dp_packet_batch *packets,
odp_port_t in_port);
/* AVX512 enabled DPIF implementation and probe functions. */
int32_t
dp_netdev_input_outer_avx512_probe(void);
int32_t
dp_netdev_input_outer_avx512(struct dp_netdev_pmd_thread *pmd,
struct dp_packet_batch *packets,
odp_port_t in_port);
#endif /* netdev-private.h */