Skip to content

Commit

Permalink
app/testpmd: rework softnic forward mode
Browse files Browse the repository at this point in the history
Modied the testpmd softnic forwarding mode as per the
changes in softnic PMD.

To run testpmd application with softnic fwd mode, following
command is used;

$ ./testpmd -c 0xc -n 4 --vdev 'net_softnic0,firmware=script.cli'
  -- -i --forward-mode=softnic

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
  • Loading branch information
JasvinderD authored and cristian-dumitrescu committed Jul 12, 2018
1 parent d16eaa3 commit 0ad778b
Show file tree
Hide file tree
Showing 7 changed files with 249 additions and 346 deletions.
4 changes: 2 additions & 2 deletions app/test-pmd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ SRCS-y += icmpecho.c
SRCS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ieee1588fwd.c
SRCS-$(CONFIG_RTE_LIBRTE_BPF) += bpf_cmd.c

ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC)$(CONFIG_RTE_LIBRTE_SCHED),yy)
SRCS-y += tm.c
ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC), y)
SRCS-y += softnicfwd.c
endif

ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
Expand Down
54 changes: 43 additions & 11 deletions app/test-pmd/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
#ifdef RTE_LIBRTE_I40E_PMD
#include <rte_pmd_i40e.h>
#endif
#ifdef RTE_LIBRTE_PMD_SOFTNIC
#include <rte_eth_softnic.h>
#endif
#ifdef RTE_LIBRTE_BNXT_PMD
#include <rte_pmd_bnxt.h>
#endif
Expand Down Expand Up @@ -14817,20 +14820,14 @@ static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,

p = &ports[port_id];

/* Port tm flag */
if (p->softport.tm_flag == 0) {
printf(" tm not enabled on port %u (error)\n", port_id);
return;
}

/* Forward mode: tm */
if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
printf(" tm mode not enabled(error)\n");
if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
printf(" softnicfwd mode not enabled(error)\n");
return;
}

/* Set the default tm hierarchy */
p->softport.tm.default_hierarchy_enable = 1;
p->softport.default_tm_hierarchy_enable = 1;
}

cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
Expand Down Expand Up @@ -17554,15 +17551,50 @@ cmdline_read_from_file(const char *filename)
void
prompt(void)
{
int status;

/* initialize non-constant commands */
cmd_set_fwd_mode_init();
cmd_set_fwd_retry_mode_init();

#if defined RTE_LIBRTE_PMD_SOFTNIC
portid_t softnic_portid, pid;
uint8_t softnic_enable = 0;

if (strcmp(cur_fwd_eng->fwd_mode_name, "softnic") == 0) {
RTE_ETH_FOREACH_DEV(pid) {
struct rte_port *port = &ports[pid];
const char *driver = port->dev_info.driver_name;

if (strcmp(driver, "net_softnic") == 0) {
softnic_portid = pid;
softnic_enable = 1;
break;
}
}
}
#endif

testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
if (testpmd_cl == NULL)
return;
cmdline_interact(testpmd_cl);
cmdline_stdin_exit(testpmd_cl);

for (;;) {
status = cmdline_poll(testpmd_cl);
if (status < 0)
rte_panic("CLI poll error (%" PRId32 ")\n", status);
else if (status == RDLINE_EXITED) {
cmdline_stdin_exit(testpmd_cl);
rte_exit(0, "\n");
}

#if defined RTE_LIBRTE_PMD_SOFTNIC

if ((softnic_enable == 1) &&
(strcmp(cur_fwd_eng->fwd_mode_name, "softnic") == 0))
rte_pmd_softnic_manage(softnic_portid);
#endif
}
}

void
Expand Down
57 changes: 57 additions & 0 deletions app/test-pmd/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -2332,6 +2332,55 @@ icmp_echo_config_setup(void)
}
}

#if defined RTE_LIBRTE_PMD_SOFTNIC
static void
softnic_fwd_config_setup(void)
{
struct rte_port *port;
portid_t pid, softnic_portid;
queueid_t i;
uint8_t softnic_enable = 0;

RTE_ETH_FOREACH_DEV(pid) {
port = &ports[pid];
const char *driver = port->dev_info.driver_name;

if (strcmp(driver, "net_softnic") == 0) {
softnic_portid = pid;
softnic_enable = 1;
break;
}
}

if (softnic_enable == 0) {
printf("Softnic mode not configured(%s)!\n", __func__);
return;
}

cur_fwd_config.nb_fwd_ports = 1;
cur_fwd_config.nb_fwd_streams = (streamid_t) nb_rxq;

/* Re-initialize forwarding streams */
init_fwd_streams();

/*
* In the softnic forwarding test, the number of forwarding cores
* is set to one and remaining are used for softnic packet processing.
*/
cur_fwd_config.nb_fwd_lcores = 1;
setup_fwd_config_of_each_lcore(&cur_fwd_config);

for (i = 0; i < cur_fwd_config.nb_fwd_streams; i++) {
fwd_streams[i]->rx_port = softnic_portid;
fwd_streams[i]->rx_queue = i;
fwd_streams[i]->tx_port = softnic_portid;
fwd_streams[i]->tx_queue = i;
fwd_streams[i]->peer_addr = fwd_streams[i]->tx_port;
fwd_streams[i]->retry_enabled = retry_enabled;
}
}
#endif

void
fwd_config_setup(void)
{
Expand All @@ -2340,6 +2389,14 @@ fwd_config_setup(void)
icmp_echo_config_setup();
return;
}

#if defined RTE_LIBRTE_PMD_SOFTNIC
if (strcmp(cur_fwd_eng->fwd_mode_name, "softnic") == 0) {
softnic_fwd_config_setup();
return;
}
#endif

if ((nb_rxq > 1) && (nb_txq > 1)){
if (dcb_config)
dcb_fwd_config_setup();
Expand Down
2 changes: 1 addition & 1 deletion app/test-pmd/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if dpdk_conf.has('RTE_LIBRTE_IXGBE_PMD')
deps += 'pmd_ixgbe'
endif
if dpdk_conf.has('RTE_LIBRTE_SOFTNIC_PMD')
sources += files('tm.c')
sources += files('softnicfwd.c')
deps += 'pmd_softnic'
endif
if dpdk_conf.has('RTE_LIBRTE_DPAA_PMD')
Expand Down
Loading

0 comments on commit 0ad778b

Please sign in to comment.