app/testpmd: drop PCI register commands

Those commands date back to the early stages of DPDK when only PCI
devices were supported.
At the time, developers may have used those commands to help in
debugging their buggy^Wwork in progress drivers.

Removing them, we can drop the dependency on the PCI bus and library and
make testpmd bus agnostic.

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
This commit is contained in:
David Marchand 2022-07-28 17:26:18 +02:00
parent 9c1b4ae5c0
commit 1bcb7ba9de
21 changed files with 17 additions and 694 deletions

View File

@ -5,6 +5,7 @@
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>

View File

@ -8,6 +8,7 @@
#include <errno.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <inttypes.h>
@ -29,7 +30,6 @@
#include <rte_ring.h>
#include <rte_mempool.h>
#include <rte_interrupts.h>
#include <rte_pci.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_string_fns.h>
@ -90,7 +90,6 @@ static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
"information.\n"
" help config : Configuration information.\n"
" help ports : Configuring ports.\n"
" help registers : Reading and setting port registers.\n"
" help filters : Filters configuration help.\n"
" help traffic_management : Traffic Management commands.\n"
" help devices : Device related commands.\n"
@ -800,34 +799,6 @@ static void cmd_help_long_parsed(void *parsed_result,
);
}
if (show_all || !strcmp(res->section, "registers")) {
cmdline_printf(
cl,
"\n"
"Registers:\n"
"----------\n\n"
"read reg (port_id) (address)\n"
" Display value of a port register.\n\n"
"read regfield (port_id) (address) (bit_x) (bit_y)\n"
" Display a port register bit field.\n\n"
"read regbit (port_id) (address) (bit_x)\n"
" Display a single port register bit.\n\n"
"write reg (port_id) (address) (value)\n"
" Set value of a port register.\n\n"
"write regfield (port_id) (address) (bit_x) (bit_y)"
" (value)\n"
" Set bit field of a port register.\n\n"
"write regbit (port_id) (address) (bit_x) (value)\n"
" Set single bit value of a port register.\n\n"
);
}
if (show_all || !strcmp(res->section, "filters")) {
cmdline_printf(
@ -1078,13 +1049,13 @@ static cmdline_parse_token_string_t cmd_help_long_help =
static cmdline_parse_token_string_t cmd_help_long_section =
TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
"all#control#display#config#ports#registers#"
"all#control#display#config#ports#"
"filters#traffic_management#devices#drivers");
static cmdline_parse_inst_t cmd_help_long = {
.f = cmd_help_long_parsed,
.data = NULL,
.help_str = "help all|control|display|config|ports|register|"
.help_str = "help all|control|display|config|ports|"
"filters|traffic_management|devices|drivers: "
"Show help",
.tokens = {
@ -7391,305 +7362,6 @@ static cmdline_parse_inst_t cmd_showfwdall = {
},
};
/* *** READ PORT REGISTER *** */
struct cmd_read_reg_result {
cmdline_fixed_string_t read;
cmdline_fixed_string_t reg;
portid_t port_id;
uint32_t reg_off;
};
static void
cmd_read_reg_parsed(void *parsed_result,
__rte_unused struct cmdline *cl,
__rte_unused void *data)
{
struct cmd_read_reg_result *res = parsed_result;
port_reg_display(res->port_id, res->reg_off);
}
static cmdline_parse_token_string_t cmd_read_reg_read =
TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
static cmdline_parse_token_string_t cmd_read_reg_reg =
TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
static cmdline_parse_token_num_t cmd_read_reg_port_id =
TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
static cmdline_parse_token_num_t cmd_read_reg_reg_off =
TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
static cmdline_parse_inst_t cmd_read_reg = {
.f = cmd_read_reg_parsed,
.data = NULL,
.help_str = "read reg <port_id> <reg_off>",
.tokens = {
(void *)&cmd_read_reg_read,
(void *)&cmd_read_reg_reg,
(void *)&cmd_read_reg_port_id,
(void *)&cmd_read_reg_reg_off,
NULL,
},
};
/* *** READ PORT REGISTER BIT FIELD *** */
struct cmd_read_reg_bit_field_result {
cmdline_fixed_string_t read;
cmdline_fixed_string_t regfield;
portid_t port_id;
uint32_t reg_off;
uint8_t bit1_pos;
uint8_t bit2_pos;
};
static void
cmd_read_reg_bit_field_parsed(void *parsed_result,
__rte_unused struct cmdline *cl,
__rte_unused void *data)
{
struct cmd_read_reg_bit_field_result *res = parsed_result;
port_reg_bit_field_display(res->port_id, res->reg_off,
res->bit1_pos, res->bit2_pos);
}
static cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
"read");
static cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
regfield, "regfield");
static cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
RTE_UINT16);
static cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
RTE_UINT32);
static cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
RTE_UINT8);
static cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
RTE_UINT8);
static cmdline_parse_inst_t cmd_read_reg_bit_field = {
.f = cmd_read_reg_bit_field_parsed,
.data = NULL,
.help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
"Read register bit field between bit_x and bit_y included",
.tokens = {
(void *)&cmd_read_reg_bit_field_read,
(void *)&cmd_read_reg_bit_field_regfield,
(void *)&cmd_read_reg_bit_field_port_id,
(void *)&cmd_read_reg_bit_field_reg_off,
(void *)&cmd_read_reg_bit_field_bit1_pos,
(void *)&cmd_read_reg_bit_field_bit2_pos,
NULL,
},
};
/* *** READ PORT REGISTER BIT *** */
struct cmd_read_reg_bit_result {
cmdline_fixed_string_t read;
cmdline_fixed_string_t regbit;
portid_t port_id;
uint32_t reg_off;
uint8_t bit_pos;
};
static void
cmd_read_reg_bit_parsed(void *parsed_result,
__rte_unused struct cmdline *cl,
__rte_unused void *data)
{
struct cmd_read_reg_bit_result *res = parsed_result;
port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
}
static cmdline_parse_token_string_t cmd_read_reg_bit_read =
TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
static cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
regbit, "regbit");
static cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
RTE_UINT16);
static cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
RTE_UINT32);
static cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
RTE_UINT8);
static cmdline_parse_inst_t cmd_read_reg_bit = {
.f = cmd_read_reg_bit_parsed,
.data = NULL,
.help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
.tokens = {
(void *)&cmd_read_reg_bit_read,
(void *)&cmd_read_reg_bit_regbit,
(void *)&cmd_read_reg_bit_port_id,
(void *)&cmd_read_reg_bit_reg_off,
(void *)&cmd_read_reg_bit_bit_pos,
NULL,
},
};
/* *** WRITE PORT REGISTER *** */
struct cmd_write_reg_result {
cmdline_fixed_string_t write;
cmdline_fixed_string_t reg;
portid_t port_id;
uint32_t reg_off;
uint32_t value;
};
static void
cmd_write_reg_parsed(void *parsed_result,
__rte_unused struct cmdline *cl,
__rte_unused void *data)
{
struct cmd_write_reg_result *res = parsed_result;
port_reg_set(res->port_id, res->reg_off, res->value);
}
static cmdline_parse_token_string_t cmd_write_reg_write =
TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
static cmdline_parse_token_string_t cmd_write_reg_reg =
TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
static cmdline_parse_token_num_t cmd_write_reg_port_id =
TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
static cmdline_parse_token_num_t cmd_write_reg_reg_off =
TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
static cmdline_parse_token_num_t cmd_write_reg_value =
TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
static cmdline_parse_inst_t cmd_write_reg = {
.f = cmd_write_reg_parsed,
.data = NULL,
.help_str = "write reg <port_id> <reg_off> <reg_value>",
.tokens = {
(void *)&cmd_write_reg_write,
(void *)&cmd_write_reg_reg,
(void *)&cmd_write_reg_port_id,
(void *)&cmd_write_reg_reg_off,
(void *)&cmd_write_reg_value,
NULL,
},
};
/* *** WRITE PORT REGISTER BIT FIELD *** */
struct cmd_write_reg_bit_field_result {
cmdline_fixed_string_t write;
cmdline_fixed_string_t regfield;
portid_t port_id;
uint32_t reg_off;
uint8_t bit1_pos;
uint8_t bit2_pos;
uint32_t value;
};
static void
cmd_write_reg_bit_field_parsed(void *parsed_result,
__rte_unused struct cmdline *cl,
__rte_unused void *data)
{
struct cmd_write_reg_bit_field_result *res = parsed_result;
port_reg_bit_field_set(res->port_id, res->reg_off,
res->bit1_pos, res->bit2_pos, res->value);
}
static cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
"write");
static cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
regfield, "regfield");
static cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
RTE_UINT16);
static cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
RTE_UINT32);
static cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
RTE_UINT8);
static cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
RTE_UINT8);
static cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
RTE_UINT32);
static cmdline_parse_inst_t cmd_write_reg_bit_field = {
.f = cmd_write_reg_bit_field_parsed,
.data = NULL,
.help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
"<reg_value>: "
"Set register bit field between bit_x and bit_y included",
.tokens = {
(void *)&cmd_write_reg_bit_field_write,
(void *)&cmd_write_reg_bit_field_regfield,
(void *)&cmd_write_reg_bit_field_port_id,
(void *)&cmd_write_reg_bit_field_reg_off,
(void *)&cmd_write_reg_bit_field_bit1_pos,
(void *)&cmd_write_reg_bit_field_bit2_pos,
(void *)&cmd_write_reg_bit_field_value,
NULL,
},
};
/* *** WRITE PORT REGISTER BIT *** */
struct cmd_write_reg_bit_result {
cmdline_fixed_string_t write;
cmdline_fixed_string_t regbit;
portid_t port_id;
uint32_t reg_off;
uint8_t bit_pos;
uint8_t value;
};
static void
cmd_write_reg_bit_parsed(void *parsed_result,
__rte_unused struct cmdline *cl,
__rte_unused void *data)
{
struct cmd_write_reg_bit_result *res = parsed_result;
port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
}
static cmdline_parse_token_string_t cmd_write_reg_bit_write =
TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
"write");
static cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
regbit, "regbit");
static cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
RTE_UINT16);
static cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
RTE_UINT32);
static cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
RTE_UINT8);
static cmdline_parse_token_num_t cmd_write_reg_bit_value =
TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
RTE_UINT8);
static cmdline_parse_inst_t cmd_write_reg_bit = {
.f = cmd_write_reg_bit_parsed,
.data = NULL,
.help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
"0 <= bit_x <= 31",
.tokens = {
(void *)&cmd_write_reg_bit_write,
(void *)&cmd_write_reg_bit_regbit,
(void *)&cmd_write_reg_bit_port_id,
(void *)&cmd_write_reg_bit_reg_off,
(void *)&cmd_write_reg_bit_bit_pos,
(void *)&cmd_write_reg_bit_value,
NULL,
},
};
/* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
struct cmd_read_rxd_txd_result {
cmdline_fixed_string_t read;
@ -14223,12 +13895,6 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
(cmdline_parse_inst_t *)&cmd_queue_priority_flow_control_set,
(cmdline_parse_inst_t *)&cmd_config_dcb,
(cmdline_parse_inst_t *)&cmd_read_reg,
(cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
(cmdline_parse_inst_t *)&cmd_read_reg_bit,
(cmdline_parse_inst_t *)&cmd_write_reg,
(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
(cmdline_parse_inst_t *)&cmd_write_reg_bit,
(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
(cmdline_parse_inst_t *)&cmd_stop,
(cmdline_parse_inst_t *)&cmd_mac_addr,

View File

@ -6,6 +6,7 @@
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <errno.h>
#include <ctype.h>

View File

@ -2,6 +2,8 @@
* Copyright(c) 2017 Intel Corporation
*/
#include <stdlib.h>
#include <cmdline_parse.h>
#include <cmdline_parse_num.h>
#include <cmdline_parse_string.h>

View File

@ -3,6 +3,7 @@
*/
#include <ctype.h>
#include <stdlib.h>
#include <cmdline_parse.h>
#include <cmdline_parse_num.h>

View File

@ -7,6 +7,7 @@
#include <stdarg.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <inttypes.h>
@ -32,7 +33,6 @@
#include <rte_mempool.h>
#include <rte_mbuf.h>
#include <rte_interrupts.h>
#include <rte_pci.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_string_fns.h>
@ -1139,200 +1139,6 @@ vlan_id_is_invalid(uint16_t vlan_id)
return 1;
}
static int
port_reg_off_is_invalid(portid_t port_id, uint32_t reg_off)
{
const struct rte_pci_device *pci_dev;
const struct rte_bus *bus;
uint64_t pci_len;
if (reg_off & 0x3) {
fprintf(stderr,
"Port register offset 0x%X not aligned on a 4-byte boundary\n",
(unsigned int)reg_off);
return 1;
}
if (!ports[port_id].dev_info.device) {
fprintf(stderr, "Invalid device\n");
return 0;
}
bus = rte_bus_find_by_device(ports[port_id].dev_info.device);
if (bus && !strcmp(bus->name, "pci")) {
pci_dev = RTE_DEV_TO_PCI(ports[port_id].dev_info.device);
} else {
fprintf(stderr, "Not a PCI device\n");
return 1;
}
pci_len = pci_dev->mem_resource[0].len;
if (reg_off >= pci_len) {
fprintf(stderr,
"Port %d: register offset %u (0x%X) out of port PCI resource (length=%"PRIu64")\n",
port_id, (unsigned int)reg_off, (unsigned int)reg_off,
pci_len);
return 1;
}
return 0;
}
static int
reg_bit_pos_is_invalid(uint8_t bit_pos)
{
if (bit_pos <= 31)
return 0;
fprintf(stderr, "Invalid bit position %d (must be <= 31)\n", bit_pos);
return 1;
}
#define display_port_and_reg_off(port_id, reg_off) \
printf("port %d PCI register at offset 0x%X: ", (port_id), (reg_off))
static inline void
display_port_reg_value(portid_t port_id, uint32_t reg_off, uint32_t reg_v)
{
display_port_and_reg_off(port_id, (unsigned)reg_off);
printf("0x%08X (%u)\n", (unsigned)reg_v, (unsigned)reg_v);
}
void
port_reg_bit_display(portid_t port_id, uint32_t reg_off, uint8_t bit_x)
{
uint32_t reg_v;
if (port_id_is_invalid(port_id, ENABLED_WARN))
return;
if (port_reg_off_is_invalid(port_id, reg_off))
return;
if (reg_bit_pos_is_invalid(bit_x))
return;
reg_v = port_id_pci_reg_read(port_id, reg_off);
display_port_and_reg_off(port_id, (unsigned)reg_off);
printf("bit %d=%d\n", bit_x, (int) ((reg_v & (1 << bit_x)) >> bit_x));
}
void
port_reg_bit_field_display(portid_t port_id, uint32_t reg_off,
uint8_t bit1_pos, uint8_t bit2_pos)
{
uint32_t reg_v;
uint8_t l_bit;
uint8_t h_bit;
if (port_id_is_invalid(port_id, ENABLED_WARN))
return;
if (port_reg_off_is_invalid(port_id, reg_off))
return;
if (reg_bit_pos_is_invalid(bit1_pos))
return;
if (reg_bit_pos_is_invalid(bit2_pos))
return;
if (bit1_pos > bit2_pos)
l_bit = bit2_pos, h_bit = bit1_pos;
else
l_bit = bit1_pos, h_bit = bit2_pos;
reg_v = port_id_pci_reg_read(port_id, reg_off);
reg_v >>= l_bit;
if (h_bit < 31)
reg_v &= ((1 << (h_bit - l_bit + 1)) - 1);
display_port_and_reg_off(port_id, (unsigned)reg_off);
printf("bits[%d, %d]=0x%0*X (%u)\n", l_bit, h_bit,
((h_bit - l_bit) / 4) + 1, (unsigned)reg_v, (unsigned)reg_v);
}
void
port_reg_display(portid_t port_id, uint32_t reg_off)
{
uint32_t reg_v;
if (port_id_is_invalid(port_id, ENABLED_WARN))
return;
if (port_reg_off_is_invalid(port_id, reg_off))
return;
reg_v = port_id_pci_reg_read(port_id, reg_off);
display_port_reg_value(port_id, reg_off, reg_v);
}
void
port_reg_bit_set(portid_t port_id, uint32_t reg_off, uint8_t bit_pos,
uint8_t bit_v)
{
uint32_t reg_v;
if (port_id_is_invalid(port_id, ENABLED_WARN))
return;
if (port_reg_off_is_invalid(port_id, reg_off))
return;
if (reg_bit_pos_is_invalid(bit_pos))
return;
if (bit_v > 1) {
fprintf(stderr, "Invalid bit value %d (must be 0 or 1)\n",
(int) bit_v);
return;
}
reg_v = port_id_pci_reg_read(port_id, reg_off);
if (bit_v == 0)
reg_v &= ~(1 << bit_pos);
else
reg_v |= (1 << bit_pos);
port_id_pci_reg_write(port_id, reg_off, reg_v);
display_port_reg_value(port_id, reg_off, reg_v);
}
void
port_reg_bit_field_set(portid_t port_id, uint32_t reg_off,
uint8_t bit1_pos, uint8_t bit2_pos, uint32_t value)
{
uint32_t max_v;
uint32_t reg_v;
uint8_t l_bit;
uint8_t h_bit;
if (port_id_is_invalid(port_id, ENABLED_WARN))
return;
if (port_reg_off_is_invalid(port_id, reg_off))
return;
if (reg_bit_pos_is_invalid(bit1_pos))
return;
if (reg_bit_pos_is_invalid(bit2_pos))
return;
if (bit1_pos > bit2_pos)
l_bit = bit2_pos, h_bit = bit1_pos;
else
l_bit = bit1_pos, h_bit = bit2_pos;
if ((h_bit - l_bit) < 31)
max_v = (1 << (h_bit - l_bit + 1)) - 1;
else
max_v = 0xFFFFFFFF;
if (value > max_v) {
fprintf(stderr, "Invalid value %u (0x%x) must be < %u (0x%x)\n",
(unsigned)value, (unsigned)value,
(unsigned)max_v, (unsigned)max_v);
return;
}
reg_v = port_id_pci_reg_read(port_id, reg_off);
reg_v &= ~(max_v << l_bit); /* Keep unchanged bits */
reg_v |= (value << l_bit); /* Set changed bits */
port_id_pci_reg_write(port_id, reg_off, reg_v);
display_port_reg_value(port_id, reg_off, reg_v);
}
void
port_reg_set(portid_t port_id, uint32_t reg_off, uint32_t reg_v)
{
if (port_id_is_invalid(port_id, ENABLED_WARN))
return;
if (port_reg_off_is_invalid(port_id, reg_off))
return;
port_id_pci_reg_write(port_id, reg_off, reg_v);
display_port_reg_value(port_id, reg_off, reg_v);
}
static uint32_t
eth_dev_get_overhead_len(uint32_t max_rx_pktlen, uint16_t max_mtu)
{

View File

@ -28,7 +28,6 @@
#include <rte_mempool.h>
#include <rte_mbuf.h>
#include <rte_interrupts.h>
#include <rte_pci.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_ip.h>

View File

@ -28,7 +28,6 @@
#include <rte_mempool.h>
#include <rte_mbuf.h>
#include <rte_interrupts.h>
#include <rte_pci.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_ip.h>

View File

@ -28,7 +28,6 @@
#include <rte_mempool.h>
#include <rte_mbuf.h>
#include <rte_interrupts.h>
#include <rte_pci.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_string_fns.h>

View File

@ -28,7 +28,6 @@
#include <rte_mempool.h>
#include <rte_mbuf.h>
#include <rte_interrupts.h>
#include <rte_pci.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_ip.h>

View File

@ -28,7 +28,6 @@
#include <rte_mempool.h>
#include <rte_mbuf.h>
#include <rte_interrupts.h>
#include <rte_pci.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_ip.h>

View File

@ -32,7 +32,7 @@ if dpdk_conf.has('RTE_HAS_JANSSON')
ext_deps += jansson_dep
endif
deps += ['ethdev', 'cmdline', 'bus_pci']
deps += ['ethdev', 'cmdline']
if dpdk_conf.has('RTE_CRYPTO_SCHEDULER')
deps += 'crypto_scheduler'
endif

View File

@ -4,6 +4,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <errno.h>

View File

@ -33,7 +33,6 @@
#include <rte_branch_prediction.h>
#include <rte_mempool.h>
#include <rte_interrupts.h>
#include <rte_pci.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_string_fns.h>

View File

@ -28,7 +28,6 @@
#include <rte_mempool.h>
#include <rte_mbuf.h>
#include <rte_interrupts.h>
#include <rte_pci.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_string_fns.h>

View File

@ -42,7 +42,6 @@
#include <rte_mbuf.h>
#include <rte_mbuf_pool_ops.h>
#include <rte_interrupts.h>
#include <rte_pci.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_dev.h>

View File

@ -7,8 +7,6 @@
#include <stdbool.h>
#include <rte_pci.h>
#include <rte_bus_pci.h>
#ifdef RTE_LIB_GRO
#include <rte_gro.h>
#endif
@ -267,7 +265,7 @@ struct port_txqueue {
* The data structure associated with each port.
*/
struct rte_port {
struct rte_eth_dev_info dev_info; /**< PCI info + driver name */
struct rte_eth_dev_info dev_info; /**< Device info + driver name */
struct rte_eth_conf dev_conf; /**< Port configuration. */
struct rte_ether_addr eth_addr; /**< Port ethernet address */
struct rte_eth_stats stats; /**< Last port statistics */
@ -801,65 +799,6 @@ mbuf_pool_find(unsigned int sock_id, uint16_t idx)
return rte_mempool_lookup((const char *)pool_name);
}
/**
* Read/Write operations on a PCI register of a port.
*/
static inline uint32_t
port_pci_reg_read(struct rte_port *port, uint32_t reg_off)
{
const struct rte_pci_device *pci_dev;
const struct rte_bus *bus;
void *reg_addr;
uint32_t reg_v;
if (!port->dev_info.device) {
fprintf(stderr, "Invalid device\n");
return 0;
}
bus = rte_bus_find_by_device(port->dev_info.device);
if (bus && !strcmp(bus->name, "pci")) {
pci_dev = RTE_DEV_TO_PCI(port->dev_info.device);
} else {
fprintf(stderr, "Not a PCI device\n");
return 0;
}
reg_addr = ((char *)pci_dev->mem_resource[0].addr + reg_off);
reg_v = *((volatile uint32_t *)reg_addr);
return rte_le_to_cpu_32(reg_v);
}
#define port_id_pci_reg_read(pt_id, reg_off) \
port_pci_reg_read(&ports[(pt_id)], (reg_off))
static inline void
port_pci_reg_write(struct rte_port *port, uint32_t reg_off, uint32_t reg_v)
{
const struct rte_pci_device *pci_dev;
const struct rte_bus *bus;
void *reg_addr;
if (!port->dev_info.device) {
fprintf(stderr, "Invalid device\n");
return;
}
bus = rte_bus_find_by_device(port->dev_info.device);
if (bus && !strcmp(bus->name, "pci")) {
pci_dev = RTE_DEV_TO_PCI(port->dev_info.device);
} else {
fprintf(stderr, "Not a PCI device\n");
return;
}
reg_addr = ((char *)pci_dev->mem_resource[0].addr + reg_off);
*((volatile uint32_t *)reg_addr) = rte_cpu_to_le_32(reg_v);
}
#define port_id_pci_reg_write(pt_id, reg_off, reg_value) \
port_pci_reg_write(&ports[(pt_id)], (reg_off), (reg_value))
static inline void
get_start_cycles(uint64_t *start_tsc)
{
@ -922,15 +861,6 @@ void update_fwd_ports(portid_t new_pid);
void set_fwd_eth_peer(portid_t port_id, char *peer_addr);
void port_mtu_set(portid_t port_id, uint16_t mtu);
void port_reg_bit_display(portid_t port_id, uint32_t reg_off, uint8_t bit_pos);
void port_reg_bit_set(portid_t port_id, uint32_t reg_off, uint8_t bit_pos,
uint8_t bit_v);
void port_reg_bit_field_display(portid_t port_id, uint32_t reg_off,
uint8_t bit1_pos, uint8_t bit2_pos);
void port_reg_bit_field_set(portid_t port_id, uint32_t reg_off,
uint8_t bit1_pos, uint8_t bit2_pos, uint32_t value);
void port_reg_display(portid_t port_id, uint32_t reg_off);
void port_reg_set(portid_t port_id, uint32_t reg_off, uint32_t value);
int port_action_handle_create(portid_t port_id, uint32_t id,
const struct rte_flow_indir_action_conf *conf,
const struct rte_flow_action *action);

View File

@ -28,7 +28,6 @@
#include <rte_mempool.h>
#include <rte_mbuf.h>
#include <rte_interrupts.h>
#include <rte_pci.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_ip.h>

View File

@ -55,7 +55,6 @@ These are divided into sections and can be accessed using help, help section or
help display : Displaying port, stats and config information.
help config : Configuration information.
help ports : Configuring ports.
help registers : Reading and setting port registers.
help filters : Filters configuration help.
help traffic_management : Traffic Management commands.
help devices : Device related commands.
@ -2356,86 +2355,6 @@ manage link bonding devices from within testpmd interactive prompt.
See :doc:`../prog_guide/link_bonding_poll_mode_drv_lib` for more information.
Register Functions
------------------
The Register Functions can be used to read from and write to registers on the network card referenced by a port number.
This is mainly useful for debugging purposes.
Reference should be made to the appropriate datasheet for the network card for details on the register addresses
and fields that can be accessed.
read reg
~~~~~~~~
Display the value of a port register::
testpmd> read reg (port_id) (address)
For example, to examine the Flow Director control register (FDIRCTL, 0x0000EE000) on an Intel 82599 10 GbE Controller::
testpmd> read reg 0 0xEE00
port 0 PCI register at offset 0xEE00: 0x4A060029 (1241907241)
read regfield
~~~~~~~~~~~~~
Display a port register bit field::
testpmd> read regfield (port_id) (address) (bit_x) (bit_y)
For example, reading the lowest two bits from the register in the example above::
testpmd> read regfield 0 0xEE00 0 1
port 0 PCI register at offset 0xEE00: bits[0, 1]=0x1 (1)
read regbit
~~~~~~~~~~~
Display a single port register bit::
testpmd> read regbit (port_id) (address) (bit_x)
For example, reading the lowest bit from the register in the example above::
testpmd> read regbit 0 0xEE00 0
port 0 PCI register at offset 0xEE00: bit 0=1
write reg
~~~~~~~~~
Set the value of a port register::
testpmd> write reg (port_id) (address) (value)
For example, to clear a register::
testpmd> write reg 0 0xEE00 0x0
port 0 PCI register at offset 0xEE00: 0x00000000 (0)
write regfield
~~~~~~~~~~~~~~
Set bit field of a port register::
testpmd> write regfield (port_id) (address) (bit_x) (bit_y) (value)
For example, writing to the register cleared in the example above::
testpmd> write regfield 0 0xEE00 0 1 2
port 0 PCI register at offset 0xEE00: 0x00000002 (2)
write regbit
~~~~~~~~~~~~
Set single bit value of a port register::
testpmd> write regbit (port_id) (address) (bit_x) (value)
For example, to set the high bit in the register from the example above::
testpmd> write regbit 0 0xEE00 31 1
port 0 PCI register at offset 0xEE00: 0x8000000A (2147483658)
Traffic Metering and Policing
-----------------------------

View File

@ -1,6 +1,9 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2010-2016 Intel Corporation.
*/
#include <stdlib.h>
#include <rte_pmd_i40e.h>
#include <cmdline_parse_num.h>

View File

@ -2,6 +2,8 @@
* Copyright(c) 2022 Intel Corporation.
*/
#include <stdlib.h>
#include <rte_pmd_ice.h>
#include <cmdline_parse_num.h>