forked from openvswitch/ovs
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dpif-netdev: Add command line and function pointer for miniflow extract
This patch introduces the mfex function pointers which allows the user to switch between different miniflow extract implementations which are provided by the OVS based on optimized ISA CPU. The user can query for the available minflow extract variants available for that CPU by following commands: $ovs-appctl dpif-netdev/miniflow-parser-get Similarly an user can set the miniflow implementation by the following command : $ ovs-appctl dpif-netdev/miniflow-parser-set name This allow for more performance and flexibility to the user to choose the miniflow implementation according to the needs. Signed-off-by: Kumar Amber <kumar.amber@intel.com> Co-authored-by: Harry van Haaren <harry.van.haaren@intel.com> Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> Signed-off-by: Ian Stokes <ian.stokes@intel.com>
- Loading branch information
Showing
6 changed files
with
337 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright (c) 2021 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. | ||
*/ | ||
|
||
#include <config.h> | ||
#include <errno.h> | ||
#include <stdint.h> | ||
#include <string.h> | ||
|
||
#include "dp-packet.h" | ||
#include "dpif-netdev-private-dpcls.h" | ||
#include "dpif-netdev-private-extract.h" | ||
#include "dpif-netdev-private-thread.h" | ||
#include "flow.h" | ||
#include "openvswitch/vlog.h" | ||
#include "ovs-thread.h" | ||
#include "util.h" | ||
|
||
VLOG_DEFINE_THIS_MODULE(dpif_netdev_extract); | ||
|
||
/* Implementations of available extract options. */ | ||
static struct dpif_miniflow_extract_impl mfex_impls[] = { | ||
{ | ||
.probe = NULL, | ||
.extract_func = NULL, | ||
.name = "disable", | ||
}, | ||
}; | ||
|
||
BUILD_ASSERT_DECL(MFEX_IMPLS_MAX_SIZE > ARRAY_SIZE(mfex_impls)); | ||
|
||
int32_t | ||
dpif_miniflow_extract_opt_get(const char *name, | ||
struct dpif_miniflow_extract_impl **opt) | ||
{ | ||
ovs_assert(opt); | ||
ovs_assert(name); | ||
|
||
uint32_t i; | ||
for (i = 0; i < ARRAY_SIZE(mfex_impls); i++) { | ||
if (strcmp(name, mfex_impls[i].name) == 0) { | ||
*opt = &mfex_impls[i]; | ||
return 0; | ||
} | ||
} | ||
return -ENOTSUP; | ||
} | ||
|
||
void | ||
dpif_miniflow_extract_init(void) | ||
{ | ||
/* Call probe on each impl, and cache the result. */ | ||
uint32_t i; | ||
for (i = 0; i < ARRAY_SIZE(mfex_impls); i++) { | ||
int avail = 1; | ||
if (mfex_impls[i].probe) { | ||
/* Return zero is success, non-zero means error. */ | ||
avail = (mfex_impls[i].probe() == 0); | ||
} | ||
VLOG_INFO("Miniflow Extract implementation %s (available: %s)\n", | ||
mfex_impls[i].name, avail ? "True" : "False"); | ||
mfex_impls[i].available = avail; | ||
} | ||
} | ||
|
||
int32_t | ||
dpif_miniflow_extract_info_get(struct dpif_miniflow_extract_impl **out_ptr) | ||
{ | ||
if (out_ptr == NULL) { | ||
return -EINVAL; | ||
} | ||
*out_ptr = mfex_impls; | ||
return ARRAY_SIZE(mfex_impls); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright (c) 2021 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 DPIF_NETDEV_AVX512_EXTRACT | ||
#define DPIF_NETDEV_AVX512_EXTRACT 1 | ||
|
||
#include <sys/types.h> | ||
|
||
#include "openvswitch/types.h" | ||
|
||
/* Max size of dpif_miniflow_extract_impl array. */ | ||
#define MFEX_IMPLS_MAX_SIZE (16) | ||
|
||
/* Forward declarations. */ | ||
struct dp_packet; | ||
struct miniflow; | ||
struct dp_netdev_pmd_thread; | ||
struct dp_packet_batch; | ||
struct netdev_flow_key; | ||
|
||
/* Function pointer prototype to be implemented in the optimized miniflow | ||
* extract code. | ||
* returns the hitmask of the processed packets on success. | ||
* returns zero on failure. | ||
*/ | ||
typedef uint32_t (*miniflow_extract_func)(struct dp_packet_batch *batch, | ||
struct netdev_flow_key *keys, | ||
uint32_t keys_size, | ||
odp_port_t in_port, | ||
void *pmd_handle); | ||
|
||
/* Probe function is used to detect if this CPU has the ISA required | ||
* to run the optimized miniflow implementation. | ||
* returns one on successful probe. | ||
* returns zero on failure. | ||
*/ | ||
typedef int32_t (*miniflow_extract_probe)(void); | ||
|
||
/* Structure representing the attributes of an optimized implementation. */ | ||
struct dpif_miniflow_extract_impl { | ||
/* When non-zero, this impl has passed the probe() checks. */ | ||
uint8_t available; | ||
|
||
/* Probe function is used to detect if this CPU has the ISA required | ||
* to run the optimized miniflow implementation. | ||
*/ | ||
miniflow_extract_probe probe; | ||
|
||
/* Function to call to extract miniflows for a burst of packets. */ | ||
miniflow_extract_func extract_func; | ||
|
||
/* Name of the optimized implementation. */ | ||
char *name; | ||
}; | ||
|
||
/* Retrieve the opt structure for the requested implementation by name. | ||
* Returns zero on success, and opt points to a valid struct, or | ||
* returns a negative failure status. | ||
* -ENOTSUP : invalid name requested | ||
*/ | ||
int32_t | ||
dpif_miniflow_extract_opt_get(const char *name, | ||
struct dpif_miniflow_extract_impl **opt); | ||
|
||
/* Initializes the available miniflow extract implementations by probing for | ||
* the CPU ISA requirements. As the runtime available CPU ISA does not change | ||
* and the required ISA of the implementation also does not change, it is safe | ||
* to cache the probe() results, and not call probe() at runtime. | ||
*/ | ||
void | ||
dpif_miniflow_extract_init(void); | ||
|
||
/* Retrieve the array of miniflow implementations for iteration. | ||
* On error, returns a negative number. | ||
* On success, returns the size of the arrays pointed to by the out parameter. | ||
*/ | ||
int32_t | ||
dpif_miniflow_extract_info_get(struct dpif_miniflow_extract_impl **out_ptr); | ||
|
||
|
||
#endif /* DPIF_NETDEV_AVX512_EXTRACT */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.