2021-07-09 15:58:17 +00:00
|
|
|
/*
|
|
|
|
* 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;
|
2021-07-09 15:58:19 +00:00
|
|
|
struct ds;
|
2021-07-09 15:58:17 +00:00
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2021-07-09 15:58:19 +00:00
|
|
|
/* This function returns all available implementations to the caller. */
|
|
|
|
void
|
|
|
|
dp_netdev_impl_get(struct ds *reply, struct dp_netdev_pmd_thread **pmd_list,
|
|
|
|
size_t n);
|
|
|
|
|
2021-07-09 15:58:18 +00:00
|
|
|
/* 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);
|
|
|
|
|
2022-07-07 13:05:19 +00:00
|
|
|
bool
|
|
|
|
dp_netdev_simple_match_enabled(const struct dp_netdev_pmd_thread *pmd,
|
|
|
|
odp_port_t in_port);
|
|
|
|
|
|
|
|
uint64_t
|
|
|
|
dp_netdev_simple_match_mark(odp_port_t in_port, ovs_be16 dl_type,
|
|
|
|
uint8_t nw_frag, ovs_be16 vlan_tci);
|
|
|
|
struct dp_netdev_flow *
|
|
|
|
dp_netdev_simple_match_lookup(const struct dp_netdev_pmd_thread *pmd,
|
|
|
|
odp_port_t in_port, ovs_be16 dl_type,
|
|
|
|
uint8_t nw_frag, ovs_be16 vlan_tci);
|
|
|
|
|
2021-07-09 15:58:17 +00:00
|
|
|
/* Available DPIF implementations below. */
|
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);
|
|
|
|
|
dpif-netdev: Refactor AVX512 runtime checks.
As described in the bugzilla below, cpu_has_isa code may be compiled
with some AVX512 instructions in it, because cpu.c is built as part of
the libopenvswitchavx512.
This is a problem when this function (supposed to probe for AVX512
instructions availability) is invoked from generic OVS code, on older
CPUs that don't support them.
For the same reason, dpcls_subtable_avx512_gather_probe,
dp_netdev_input_outer_avx512_probe, mfex_avx512_probe and
mfex_avx512_vbmi_probe are potential runtime bombs and can't either be
built as part of libopenvswitchavx512.
Move cpu.c to be part of the "normal" libopenvswitch.
And move other helpers in generic OVS code.
Note:
- dpcls_subtable_avx512_gather_probe is split in two, because it also
needs to do its own magic,
- while moving those helpers, prefer direct calls to cpu_has_isa and
avoid cast to intermediate integer variables when a simple boolean
is enough,
Fixes: 352b6c7116cd ("dpif-lookup: add avx512 gather implementation.")
Fixes: abb807e27dd4 ("dpif-netdev: Add command to switch dpif implementation.")
Fixes: 250ceddcc2d0 ("dpif-netdev/mfex: Add AVX512 based optimized miniflow extract")
Fixes: b366fa2f4947 ("dpif-netdev: Call cpuid for x86 isa availability.")
Reported-at: https://bugzilla.redhat.com/2100393
Reported-by: Ales Musil <amusil@redhat.com>
Co-authored-by: Ales Musil <amusil@redhat.com>
Signed-off-by: Ales Musil <amusil@redhat.com>
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Acked-by: Ales Musil <amusil@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-06-29 09:32:24 +02:00
|
|
|
/* AVX512 enabled DPIF implementation function. */
|
2021-07-09 15:58:17 +00:00
|
|
|
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 */
|