2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 01:51:26 +00:00
ovs/lib/odp-execute-private.h
Emma Finn eec8227614 odp-execute: Add auto validation function for actions.
This commit introduced the auto-validation function which
allows users to compare the batch of packets obtained from
different action implementations against the linear
action implementation.

The autovalidator function can be triggered at runtime using the
following command:

$ ovs-appctl odp-execute/action-impl-set autovalidator

Signed-off-by: Emma Finn <emma.finn@intel.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2022-07-15 11:38:54 +01:00

82 lines
2.8 KiB
C

/*
* Copyright (c) 2022 Intel.
*
* 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 ODP_EXTRACT_PRIVATE
#define ODP_EXTRACT_PRIVATE 1
#include "dp-packet.h"
#include "odp-execute.h"
#include "odp-netlink.h"
#include "ovs-atomic.h"
/* Forward declaration for typedef. */
struct odp_execute_action_impl;
/* Typedef for an initialization function that can initialize each
* implementation, checking requirements such as CPU ISA. */
typedef int (*odp_execute_action_init_func)
(struct odp_execute_action_impl *self);
/* Structure represents an implementation of the odp actions. */
struct odp_execute_action_impl {
/* When set, the CPU ISA required for this implementation is available
* and the implementation can be used. */
bool available;
/* Name of the implementation. */
const char *name;
/* Function is used to detect if this CPU has the ISA required
* to run the optimized action implementation and if available, initializes
* the implementation for use. */
odp_execute_action_init_func init_func;
/* An array of callback functions, one for each action. */
ATOMIC(odp_execute_action_cb) funcs[__OVS_ACTION_ATTR_MAX];
};
/* Order of Actions implementations. */
enum odp_execute_action_impl_idx {
ACTION_IMPL_SCALAR,
ACTION_IMPL_AUTOVALIDATOR,
/* See ACTION_IMPL_BEGIN below, for "first to-be-validated" impl.
* Do not change the autovalidator position in this list without updating
* the define below. */
ACTION_IMPL_MAX,
};
/* Index to start verifying implementations from. */
BUILD_ASSERT_DECL(ACTION_IMPL_SCALAR == 0);
BUILD_ASSERT_DECL(ACTION_IMPL_AUTOVALIDATOR == 1);
#define ACTION_IMPL_BEGIN (ACTION_IMPL_AUTOVALIDATOR + 1)
/* Odp execute init handles setting up the state of the actions functions at
* initialization time. It cannot return errors, as it must always succeed in
* initializing the scalar/generic codepath. */
void odp_execute_action_init(void);
/* Init functions for the action implementations. Initializes the function
* pointers for optimized action types. */
int odp_action_scalar_init(struct odp_execute_action_impl *self);
struct odp_execute_action_impl * odp_execute_action_set(const char *name);
int action_autoval_init(struct odp_execute_action_impl *self);
#endif /* ODP_EXTRACT_PRIVATE */