-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Review] Dpdk: add symmetric_mp test #3629
Draft
mcgov
wants to merge
4
commits into
main
Choose a base branch
from
mcgov/symmetric-pr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+523
−17
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright(c) 2010-2014 Intel Corporation | ||
|
||
# binary name | ||
APP = devname | ||
|
||
# all source are stored in SRCS-y | ||
SRCS-y := main.c | ||
|
||
PKGCONF ?= pkg-config | ||
|
||
# Build using pkg-config variables if possible | ||
ifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0) | ||
$(error "no installation of DPDK found") | ||
endif | ||
|
||
all: shared | ||
.PHONY: shared static | ||
shared: build/$(APP)-shared | ||
ln -sf $(APP)-shared build/$(APP) | ||
static: build/$(APP)-static | ||
ln -sf $(APP)-static build/$(APP) | ||
|
||
PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) | ||
CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) | ||
LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) | ||
LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) | ||
|
||
ifeq ($(MAKECMDGOALS),static) | ||
# check for broken pkg-config | ||
ifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),) | ||
$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.") | ||
$(error "Cannot generate statically-linked binaries with this version of pkg-config") | ||
endif | ||
endif | ||
|
||
CFLAGS += -DALLOW_EXPERIMENTAL_API | ||
|
||
build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build | ||
$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) | ||
|
||
build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build | ||
$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) | ||
|
||
build: | ||
@mkdir -p $@ | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared | ||
test -d build && rmdir -p build || true |
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,33 @@ | ||
# dpdk-devname | ||
|
||
Print info about DPDK ports on a system. | ||
|
||
## NOTE: This is a frozen copy from https://www.github.com/mcgov/devname | ||
|
||
## build | ||
clone into dpdk/examples | ||
``` bash | ||
git clone https://www.github.com/DPDK/dpdk.git | ||
cd ./dpdk/examples | ||
git clone https://github.com/mcgov/devname.git | ||
cd .. | ||
meson setup -Dexamples=devname [other options] build | ||
cd build && ninja && ninja install | ||
``` | ||
|
||
## usage: | ||
``` | ||
$ ./build/examples/dpdk-devname | ||
EAL: Detected CPU lcores: 32 | ||
EAL: Detected NUMA nodes: 1 | ||
EAL: Detected static linkage of DPDK | ||
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket | ||
EAL: Selected IOVA mode 'PA' | ||
EAL: Probe PCI driver: net_mana (1414:ba) device: 7870:00:00.0 (socket 0) | ||
mana_init_once(): MP INIT PRIMARY | ||
TELEMETRY: No legacy callbacks, legacy socket not created | ||
dpdk-devname found port=0 driver=net_mana eth_dev_info_name=7870:00:00.0 get_name_by_port_name=7870:00:00.0_port3 owner_id=0x0000000000000002 owner_name=f8615163-0002-1000-2000-6045bda6bbc0 macaddr=60:45:bd:a6:bb:c0 | ||
dpdk-devname found port=1 driver=net_mana eth_dev_info_name=7870:00:00.0 get_name_by_port_name=7870:00:00.0_port2 owner_id=0x0000000000000001 owner_name=f8615163-0001-1000-2000-6045bda6bd76 macaddr=60:45:bd:a6:bd:76 | ||
dpdk-devname found port=2 driver=net_netvsc eth_dev_info_name=f8615163-0001-1000-2000-6045bda6bd76 get_name_by_port_name=f8615163-0001-1000-2000-6045bda6bd76 owner_id=0x0000000000000000 owner_name=null macaddr=60:45:bd:a6:bd:76 | ||
dpdk-devname found port=3 driver=net_netvsc eth_dev_info_name=f8615163-0002-1000-2000-6045bda6bbc0 get_name_by_port_name=f8615163-0002-1000-2000-6045bda6bbc0 owner_id=0x0000000000000000 owner_name=null macaddr=60:45:bd:a6:bb:c0 | ||
``` |
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,98 @@ | ||
/* SPDX-License-Identifier: BSD-3-Clause | ||
* Copyright(c) 2010-2014 Intel Corporation | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
#include <stdint.h> | ||
#include <errno.h> | ||
#include <sys/queue.h> | ||
#include <rte_memory.h> | ||
#include <rte_launch.h> | ||
#include <rte_eal.h> | ||
#include <rte_per_lcore.h> | ||
#include <rte_lcore.h> | ||
#include <rte_debug.h> | ||
#include <rte_ethdev.h> | ||
#include <rte_dev.h> | ||
|
||
const char usage_info[] = "usage: dpdk-devname\n"; | ||
|
||
/*a tiny application to print dpdk device and port id info */ | ||
int main(int argc, char **argv) | ||
{ | ||
int ret; | ||
/* Initialization of Environment Abstraction Layer (EAL). */ | ||
ret = rte_eal_init(argc, argv); | ||
if (ret < 0) | ||
rte_panic("Cannot init EAL\n"); | ||
/* >8 End of initialization of Environment Abstraction Layer */ | ||
|
||
struct rte_eth_dev_info device_info; | ||
char device_name_by_port[RTE_ETH_NAME_MAX_LEN] = {0}; | ||
for (uint16_t portid = 0; portid < RTE_MAX_ETHPORTS; portid++) | ||
{ | ||
if (!rte_eth_dev_is_valid_port(portid)) | ||
continue; | ||
|
||
ret = rte_eth_dev_info_get(portid, &device_info); | ||
if (ret < 0) | ||
{ | ||
fprintf(stderr, | ||
"Invalid or no info for port %i, err: %s\n", | ||
portid, rte_strerror(ret)); | ||
continue; | ||
} | ||
ret = rte_eth_dev_get_name_by_port(portid, device_name_by_port); | ||
if (ret < 0) | ||
{ | ||
fprintf(stderr, | ||
"No name info returned for port %i, err: %s\n", | ||
portid, rte_strerror(ret)); | ||
continue; | ||
} | ||
struct rte_eth_dev_owner device_owner; | ||
ret = rte_eth_dev_owner_get(portid, &device_owner); | ||
if (ret < 0) | ||
{ | ||
fprintf(stderr, "Could not get ownership for port %i (%s)\n", | ||
portid, device_name_by_port); | ||
memset(&device_owner, 0, sizeof(struct rte_eth_dev_owner)); | ||
} | ||
|
||
if (!device_owner.name[0]) | ||
strcpy(device_owner.name, "null"); | ||
|
||
struct rte_ether_addr macaddr; | ||
ret = rte_eth_macaddr_get(portid, &macaddr); | ||
if (ret < 0) | ||
{ | ||
fprintf(stderr, "Could not get macaddr info for port %i (%s)\n", | ||
portid, device_name_by_port); | ||
memset(&macaddr, 0, sizeof(struct rte_ether_addr)); | ||
} | ||
printf("dpdk-devname found port=%i " | ||
"driver=%s " | ||
"get_name_by_port_name=%s " | ||
"owner_id=0x%016lx " | ||
"owner_name=%s " | ||
"macaddr=%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n", | ||
portid, | ||
device_info.driver_name, | ||
device_name_by_port, | ||
device_owner.id, | ||
device_owner.name, | ||
macaddr.addr_bytes[0], | ||
macaddr.addr_bytes[1], | ||
macaddr.addr_bytes[2], | ||
macaddr.addr_bytes[3], | ||
macaddr.addr_bytes[4], | ||
macaddr.addr_bytes[5] | ||
); | ||
} | ||
|
||
/* clean up the EAL */ | ||
rte_eal_cleanup(); | ||
|
||
return 0; | ||
} |
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,12 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright(c) 2017 Intel Corporation | ||
|
||
# meson file, for building this example as part of a main DPDK build. | ||
# | ||
# To build this example as a standalone application with an already-installed | ||
# DPDK instance, use 'make' | ||
|
||
allow_experimental_apis = true | ||
sources = files( | ||
'main.c', | ||
) |
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 |
---|---|---|
|
@@ -198,6 +198,8 @@ class DpdkSourceInstall(Installer): | |
"l3fwd", | ||
"multi_process/client_server_mp/mp_server", | ||
"multi_process/client_server_mp/mp_client", | ||
"multi_process/symmetric_mp", | ||
"devname", | ||
] | ||
|
||
def _check_if_installed(self) -> bool: | ||
|
@@ -255,8 +257,21 @@ def get_installed_version(self) -> VersionInfo: | |
"libdpdk", update_cached=True | ||
) | ||
|
||
__devname_files = ["main.c", "Makefile", "meson.build"] | ||
|
||
def _install(self) -> None: | ||
super()._install() | ||
# copy devname application into the examples directory | ||
devname_local_folder = PurePath(__file__).parent.joinpath("devname") | ||
self._node.shell.mkdir( | ||
self.asset_path.joinpath("examples/devname"), parents=False, exist_ok=False | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might not want to have exist_ok=False? But it would be a good check if I end up trying to build DPDK twice without wiping the directory... Not sure. |
||
) | ||
for file in self.__devname_files: | ||
self._node.shell.copy( | ||
devname_local_folder.joinpath(file), | ||
self.asset_path.joinpath(f"examples/devname/{file}"), | ||
) | ||
# stringify the example app list | ||
if self._sample_applications: | ||
sample_apps = f"-Dexamples={','.join(self._sample_applications)}" | ||
else: | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops. Need a real description here and below. Will fix