-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DPDK: add devname tool to dpdk directory
- Loading branch information
Showing
4 changed files
with
194 additions
and
0 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
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', | ||
) |