#include <rte_debug.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
-#include <rte_ring.h>
#include <rte_mempool.h>
#include <rte_mbuf.h>
#include <rte_ip.h>
static int l3fwd_em_on;
static int numa_on = 1; /**< NUMA is enabled by default. */
+static int parse_ptype; /**< Parse packet type using rx callback, and */
+ /**< disabled by default */
/* Global variables. */
uint64_t dest_eth_addr[RTE_MAX_ETHPORTS];
struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
-__m128i val_eth[RTE_MAX_ETHPORTS];
+xmm_t val_eth[RTE_MAX_ETHPORTS];
/* mask of enabled ports */
uint32_t enabled_port_mask;
struct l3fwd_lkp_mode {
void (*setup)(int);
+ int (*check_ptype)(int);
+ rte_rx_callback_fn cb_parse_ptype;
int (*main_loop)(void *);
void* (*get_ipv4_lookup_struct)(int);
void* (*get_ipv6_lookup_struct)(int);
static struct l3fwd_lkp_mode l3fwd_em_lkp = {
.setup = setup_hash,
+ .check_ptype = em_check_ptype,
+ .cb_parse_ptype = em_cb_parse_ptype,
.main_loop = em_main_loop,
.get_ipv4_lookup_struct = em_get_ipv4_l3fwd_lookup_struct,
.get_ipv6_lookup_struct = em_get_ipv6_l3fwd_lookup_struct,
static struct l3fwd_lkp_mode l3fwd_lpm_lkp = {
.setup = setup_lpm,
+ .check_ptype = lpm_check_ptype,
+ .cb_parse_ptype = lpm_cb_parse_ptype,
.main_loop = lpm_main_loop,
.get_ipv4_lookup_struct = lpm_get_ipv4_l3fwd_lookup_struct,
.get_ipv6_lookup_struct = lpm_get_ipv6_l3fwd_lookup_struct,
uint16_t i;
for (i = 0; i < nb_lcore_params; ++i) {
- if (lcore_params[i].port_id == port &&
- lcore_params[i].queue_id > queue)
- queue = lcore_params[i].queue_id;
+ if (lcore_params[i].port_id == port) {
+ if (lcore_params[i].queue_id == queue+1)
+ queue = lcore_params[i].queue_id;
+ else
+ rte_exit(EXIT_FAILURE, "queue ids of the port %d must be"
+ " in sequence and must start with 0\n",
+ lcore_params[i].port_id);
+ }
}
return (uint8_t)(++queue);
}
static void
print_usage(const char *prgname)
{
- printf ("%s [EAL options] -- -p PORTMASK -P"
- " [--config (port,queue,lcore)[,(port,queue,lcore]]"
- " [--enable-jumbo [--max-pkt-len PKTLEN]]\n"
- " -p PORTMASK: hexadecimal bitmask of ports to configure\n"
- " -P : enable promiscuous mode\n"
- " -E : enable exact match\n"
- " -L : enable longest prefix match\n"
- " --config (port,queue,lcore): rx queues configuration\n"
- " --eth-dest=X,MM:MM:MM:MM:MM:MM: optional, ethernet destination for port X\n"
- " --no-numa: optional, disable numa awareness\n"
- " --ipv6: optional, specify it if running ipv6 packets\n"
- " --enable-jumbo: enable jumbo frame"
- " which max packet len is PKTLEN in decimal (64-9600)\n"
- " --hash-entry-num: specify the hash entry number in hexadecimal to be setup\n",
+ printf("%s [EAL options] --"
+ " -p PORTMASK"
+ " [-P]"
+ " [-E]"
+ " [-L]"
+ " --config (port,queue,lcore)[,(port,queue,lcore)]"
+ " [--eth-dest=X,MM:MM:MM:MM:MM:MM]"
+ " [--enable-jumbo [--max-pkt-len PKTLEN]]"
+ " [--no-numa]"
+ " [--hash-entry-num]"
+ " [--ipv6]"
+ " [--parse-ptype]\n\n"
+
+ " -p PORTMASK: Hexadecimal bitmask of ports to configure\n"
+ " -P : Enable promiscuous mode\n"
+ " -E : Enable exact match\n"
+ " -L : Enable longest prefix match (default)\n"
+ " --config (port,queue,lcore): Rx queue configuration\n"
+ " --eth-dest=X,MM:MM:MM:MM:MM:MM: Ethernet destination for port X\n"
+ " --enable-jumbo: Enable jumbo frames\n"
+ " --max-pkt-len: Under the premise of enabling jumbo,\n"
+ " maximum packet length in decimal (64-9600)\n"
+ " --no-numa: Disable numa awareness\n"
+ " --hash-entry-num: Specify the hash entry number in hexadecimal to be setup\n"
+ " --ipv6: Set if running ipv6 packets\n"
+ " --parse-ptype: Set to use software to analyze packet type\n\n",
prgname);
}
#define CMD_LINE_OPT_IPV6 "ipv6"
#define CMD_LINE_OPT_ENABLE_JUMBO "enable-jumbo"
#define CMD_LINE_OPT_HASH_ENTRY_NUM "hash-entry-num"
+#define CMD_LINE_OPT_PARSE_PTYPE "parse-ptype"
/*
* This expression is used to calculate the number of mbufs needed
{CMD_LINE_OPT_IPV6, 0, 0, 0},
{CMD_LINE_OPT_ENABLE_JUMBO, 0, 0, 0},
{CMD_LINE_OPT_HASH_ENTRY_NUM, 1, 0, 0},
+ {CMD_LINE_OPT_PARSE_PTYPE, 0, 0, 0},
{NULL, 0, 0, 0}
};
return -1;
}
}
+
+ if (!strncmp(lgopts[option_index].name,
+ CMD_LINE_OPT_PARSE_PTYPE,
+ sizeof(CMD_LINE_OPT_PARSE_PTYPE))) {
+ printf("soft parse-ptype is enabled\n");
+ parse_ptype = 1;
+ }
+
break;
default:
continue;
}
/* clear all_ports_up flag if any link down */
- if (link.link_status == 0) {
+ if (link.link_status == ETH_LINK_DOWN) {
all_ports_up = 0;
break;
}
}
}
+static int
+prepare_ptype_parser(uint8_t portid, uint16_t queueid)
+{
+ if (parse_ptype) {
+ printf("Port %d: softly parse packet type info\n", portid);
+ if (rte_eth_add_rx_callback(portid, queueid,
+ l3fwd_lkp.cb_parse_ptype,
+ NULL))
+ return 1;
+
+ printf("Failed to add rx callback: port=%d\n", portid);
+ return 0;
+ }
+
+ if (l3fwd_lkp.check_ptype(portid))
+ return 1;
+
+ printf("port %d cannot parse packet type, please add --%s\n",
+ portid, CMD_LINE_OPT_PARSE_PTYPE);
+ return 0;
+}
+
int
main(int argc, char **argv)
{
rte_exit(EXIT_FAILURE, "init_lcore_rx_queues failed\n");
nb_ports = rte_eth_dev_count();
- if (nb_ports > RTE_MAX_ETHPORTS)
- nb_ports = RTE_MAX_ETHPORTS;
if (check_port_config(nb_ports) < 0)
rte_exit(EXIT_FAILURE, "check_port_config failed\n");
qconf = &lcore_conf[lcore_id];
qconf->tx_queue_id[portid] = queueid;
queueid++;
+
+ qconf->tx_port_id[qconf->n_tx_port] = portid;
+ qconf->n_tx_port++;
}
printf("\n");
}
rte_eth_promiscuous_enable(portid);
}
+ printf("\n");
+
+ for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
+ if (rte_lcore_is_enabled(lcore_id) == 0)
+ continue;
+ qconf = &lcore_conf[lcore_id];
+ for (queue = 0; queue < qconf->n_rx_queue; ++queue) {
+ portid = qconf->rx_queue_list[queue].port_id;
+ queueid = qconf->rx_queue_list[queue].queue_id;
+ if (prepare_ptype_parser(portid, queueid) == 0)
+ rte_exit(EXIT_FAILURE, "ptype check fails\n");
+ }
+ }
+
+
check_all_ports_link_status((uint8_t)nb_ports, enabled_port_mask);
ret = 0;