}
}
+static inline uint32_t
+link_rxq_used(struct app_link_params *link, uint32_t q_id)
+{
+ uint32_t i;
+
+ if ((link->arp_q == q_id) ||
+ (link->tcp_syn_q == q_id) ||
+ (link->ip_local_q == q_id) ||
+ (link->tcp_local_q == q_id) ||
+ (link->udp_local_q == q_id) ||
+ (link->sctp_local_q == q_id))
+ return 1;
+
+ for (i = 0; i < link->n_rss_qs; i++)
+ if (link->rss_qs[i] == q_id)
+ return 1;
+
+ return 0;
+}
+
static void
check_links(struct app_params *app)
{
rxq_max = link->udp_local_q;
if (link->sctp_local_q > rxq_max)
rxq_max = link->sctp_local_q;
+ for (i = 0; i < link->n_rss_qs; i++)
+ if (link->rss_qs[i] > rxq_max)
+ rxq_max = link->rss_qs[i];
for (i = 1; i <= rxq_max; i++)
- APP_CHECK(((link->arp_q == i) ||
- (link->tcp_syn_q == i) ||
- (link->ip_local_q == i) ||
- (link->tcp_local_q == i) ||
- (link->udp_local_q == i) ||
- (link->sctp_local_q == i)),
+ APP_CHECK((link_rxq_used(link, i)),
"%s RXQs are not contiguous (A)\n", link->name);
n_rxq = app_link_get_n_rxq(app, link);
"%s RXQs are not contiguous (C)\n", link->name);
}
- /* Check that link RXQs are contiguous */
+ /* Check that link TXQs are contiguous */
n_txq = app_link_get_n_txq(app, link);
APP_CHECK((n_txq), "%s does not have any TXQ\n", link->name);
.tcp_local_q = 0,
.udp_local_q = 0,
.sctp_local_q = 0,
+ .rss_qs = {0},
+ .n_rss_qs = 0,
+ .rss_proto_ipv4 = ETH_RSS_IPV4,
+ .rss_proto_ipv6 = ETH_RSS_IPV6,
+ .rss_proto_l2 = 0,
.state = 0,
.ip = 0,
.depth = 0,
.max_rx_pkt_len = 9000, /* Jumbo frame max packet len */
.split_hdr_size = 0, /* Header split buffer size */
},
+ .rx_adv_conf = {
+ .rss_conf = {
+ .rss_key = NULL,
+ .rss_key_len = 40,
+ .rss_hf = 0,
+ },
+ },
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
},
free(entries);
}
+static int
+parse_link_rss_qs(struct app_link_params *p,
+ char *value)
+{
+ p->n_rss_qs = 0;
+
+ while (1) {
+ char *token = strtok_r(value, PARSE_DELIMITER, &value);
+
+ if (token == NULL)
+ break;
+
+ if (p->n_rss_qs == RTE_DIM(p->rss_qs))
+ return -ENOMEM;
+
+ if (parser_read_uint32(&p->rss_qs[p->n_rss_qs++], token))
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int
+parse_link_rss_proto_ipv4(struct app_link_params *p,
+ char *value)
+{
+ uint64_t mask = 0;
+
+ while (1) {
+ char *token = strtok_r(value, PARSE_DELIMITER, &value);
+
+ if (token == NULL)
+ break;
+
+ if (strcmp(token, "IP") == 0) {
+ mask |= ETH_RSS_IPV4;
+ continue;
+ }
+ if (strcmp(token, "FRAG") == 0) {
+ mask |= ETH_RSS_FRAG_IPV4;
+ continue;
+ }
+ if (strcmp(token, "TCP") == 0) {
+ mask |= ETH_RSS_NONFRAG_IPV4_TCP;
+ continue;
+ }
+ if (strcmp(token, "UDP") == 0) {
+ mask |= ETH_RSS_NONFRAG_IPV4_UDP;
+ continue;
+ }
+ if (strcmp(token, "SCTP") == 0) {
+ mask |= ETH_RSS_NONFRAG_IPV4_SCTP;
+ continue;
+ }
+ if (strcmp(token, "OTHER") == 0) {
+ mask |= ETH_RSS_NONFRAG_IPV4_OTHER;
+ continue;
+ }
+ return -EINVAL;
+ }
+
+ p->rss_proto_ipv4 = mask;
+ return 0;
+}
+
+static int
+parse_link_rss_proto_ipv6(struct app_link_params *p,
+ char *value)
+{
+ uint64_t mask = 0;
+
+ while (1) {
+ char *token = strtok_r(value, PARSE_DELIMITER, &value);
+
+ if (token == NULL)
+ break;
+
+ if (strcmp(token, "IP") == 0) {
+ mask |= ETH_RSS_IPV6;
+ continue;
+ }
+ if (strcmp(token, "FRAG") == 0) {
+ mask |= ETH_RSS_FRAG_IPV6;
+ continue;
+ }
+ if (strcmp(token, "TCP") == 0) {
+ mask |= ETH_RSS_NONFRAG_IPV6_TCP;
+ continue;
+ }
+ if (strcmp(token, "UDP") == 0) {
+ mask |= ETH_RSS_NONFRAG_IPV6_UDP;
+ continue;
+ }
+ if (strcmp(token, "SCTP") == 0) {
+ mask |= ETH_RSS_NONFRAG_IPV6_SCTP;
+ continue;
+ }
+ if (strcmp(token, "OTHER") == 0) {
+ mask |= ETH_RSS_NONFRAG_IPV6_OTHER;
+ continue;
+ }
+ if (strcmp(token, "IP_EX") == 0) {
+ mask |= ETH_RSS_IPV6_EX;
+ continue;
+ }
+ if (strcmp(token, "TCP_EX") == 0) {
+ mask |= ETH_RSS_IPV6_TCP_EX;
+ continue;
+ }
+ if (strcmp(token, "UDP_EX") == 0) {
+ mask |= ETH_RSS_IPV6_UDP_EX;
+ continue;
+ }
+ return -EINVAL;
+ }
+
+ p->rss_proto_ipv6 = mask;
+ return 0;
+}
+
+static int
+parse_link_rss_proto_l2(struct app_link_params *p,
+ char *value)
+{
+ uint64_t mask = 0;
+
+ while (1) {
+ char *token = strtok_r(value, PARSE_DELIMITER, &value);
+
+ if (token == NULL)
+ break;
+
+ if (strcmp(token, "L2") == 0) {
+ mask |= ETH_RSS_L2_PAYLOAD;
+ continue;
+ }
+ return -EINVAL;
+ }
+
+ p->rss_proto_l2 = mask;
+ return 0;
+}
+
static void
parse_link(struct app_params *app,
const char *section_name,
struct app_link_params *param;
struct rte_cfgfile_entry *entries;
int n_entries, i;
+ int rss_qs_present = 0;
+ int rss_proto_ipv4_present = 0;
+ int rss_proto_ipv6_present = 0;
+ int rss_proto_l2_present = 0;
int pci_bdf_present = 0;
ssize_t param_idx;
continue;
}
-
if (strcmp(ent->name, "tcp_local_q") == 0) {
int status = parser_read_uint32(
¶m->tcp_local_q, ent->value);
continue;
}
+ if (strcmp(ent->name, "rss_qs") == 0) {
+ int status = parse_link_rss_qs(param, ent->value);
+
+ PARSE_ERROR((status == 0), section_name,
+ ent->name);
+ rss_qs_present = 1;
+ continue;
+ }
+
+ if (strcmp(ent->name, "rss_proto_ipv4") == 0) {
+ int status =
+ parse_link_rss_proto_ipv4(param, ent->value);
+
+ PARSE_ERROR((status != -EINVAL), section_name,
+ ent->name);
+ rss_proto_ipv4_present = 1;
+ continue;
+ }
+
+ if (strcmp(ent->name, "rss_proto_ipv6") == 0) {
+ int status =
+ parse_link_rss_proto_ipv6(param, ent->value);
+
+ PARSE_ERROR((status != -EINVAL), section_name,
+ ent->name);
+ rss_proto_ipv6_present = 1;
+ continue;
+ }
+
+ if (strcmp(ent->name, "rss_proto_l2") == 0) {
+ int status = parse_link_rss_proto_l2(param, ent->value);
+
+ PARSE_ERROR((status != -EINVAL), section_name,
+ ent->name);
+ rss_proto_l2_present = 1;
+ continue;
+ }
+
if (strcmp(ent->name, "pci_bdf") == 0) {
PARSE_ERROR_DUPLICATE((pci_bdf_present == 0),
section_name, ent->name);
"this entry is mandatory (port_mask is not "
"provided)");
+ if (rss_proto_ipv4_present)
+ PARSE_ERROR_MESSAGE((rss_qs_present),
+ section_name, "rss_proto_ipv4",
+ "entry not allowed (rss_qs entry is not provided)");
+ if (rss_proto_ipv6_present)
+ PARSE_ERROR_MESSAGE((rss_qs_present),
+ section_name, "rss_proto_ipv6",
+ "entry not allowed (rss_qs entry is not provided)");
+ if (rss_proto_l2_present)
+ PARSE_ERROR_MESSAGE((rss_qs_present),
+ section_name, "rss_proto_l2",
+ "entry not allowed (rss_qs entry is not provided)");
+ if (rss_proto_ipv4_present |
+ rss_proto_ipv6_present |
+ rss_proto_l2_present){
+ if (rss_proto_ipv4_present == 0)
+ param->rss_proto_ipv4 = 0;
+ if (rss_proto_ipv6_present == 0)
+ param->rss_proto_ipv6 = 0;
+ if (rss_proto_l2_present == 0)
+ param->rss_proto_l2 = 0;
+ }
+
free(entries);
}
fprintf(f, "%s = %" PRIu32 "\n", "sctp_local_q",
p->sctp_local_q);
+ if (p->n_rss_qs) {
+ uint32_t j;
+
+ /* rss_qs */
+ fprintf(f, "rss_qs = ");
+ for (j = 0; j < p->n_rss_qs; j++)
+ fprintf(f, "%" PRIu32 " ", p->rss_qs[j]);
+ fputc('\n', f);
+
+ /* rss_proto_ipv4 */
+ if (p->rss_proto_ipv4) {
+ fprintf(f, "rss_proto_ipv4 = ");
+ if (p->rss_proto_ipv4 & ETH_RSS_IPV4)
+ fprintf(f, "IP ");
+ if (p->rss_proto_ipv4 & ETH_RSS_FRAG_IPV4)
+ fprintf(f, "FRAG ");
+ if (p->rss_proto_ipv4 &
+ ETH_RSS_NONFRAG_IPV4_TCP)
+ fprintf(f, "TCP ");
+ if (p->rss_proto_ipv4 &
+ ETH_RSS_NONFRAG_IPV4_UDP)
+ fprintf(f, "UDP ");
+ if (p->rss_proto_ipv4 &
+ ETH_RSS_NONFRAG_IPV4_SCTP)
+ fprintf(f, "SCTP ");
+ if (p->rss_proto_ipv4 &
+ ETH_RSS_NONFRAG_IPV4_OTHER)
+ fprintf(f, "OTHER ");
+ fprintf(f, "\n");
+ } else
+ fprintf(f, "; rss_proto_ipv4 = <NONE>\n");
+
+ /* rss_proto_ipv6 */
+ if (p->rss_proto_ipv6) {
+ fprintf(f, "rss_proto_ipv6 = ");
+ if (p->rss_proto_ipv6 & ETH_RSS_IPV6)
+ fprintf(f, "IP ");
+ if (p->rss_proto_ipv6 & ETH_RSS_FRAG_IPV6)
+ fprintf(f, "FRAG ");
+ if (p->rss_proto_ipv6 &
+ ETH_RSS_NONFRAG_IPV6_TCP)
+ fprintf(f, "TCP ");
+ if (p->rss_proto_ipv6 &
+ ETH_RSS_NONFRAG_IPV6_UDP)
+ fprintf(f, "UDP ");
+ if (p->rss_proto_ipv6 &
+ ETH_RSS_NONFRAG_IPV6_SCTP)
+ fprintf(f, "SCTP ");
+ if (p->rss_proto_ipv6 &
+ ETH_RSS_NONFRAG_IPV6_OTHER)
+ fprintf(f, "OTHER ");
+ if (p->rss_proto_ipv6 & ETH_RSS_IPV6_EX)
+ fprintf(f, "IP_EX ");
+ if (p->rss_proto_ipv6 &
+ ETH_RSS_IPV6_TCP_EX)
+ fprintf(f, "TCP_EX ");
+ if (p->rss_proto_ipv6 &
+ ETH_RSS_IPV6_UDP_EX)
+ fprintf(f, "UDP_EX ");
+ fprintf(f, "\n");
+ } else
+ fprintf(f, "; rss_proto_ipv6 = <NONE>\n");
+
+ /* rss_proto_l2 */
+ if (p->rss_proto_l2) {
+ fprintf(f, "rss_proto_l2 = ");
+ if (p->rss_proto_l2 & ETH_RSS_L2_PAYLOAD)
+ fprintf(f, "L2 ");
+ fprintf(f, "\n");
+ } else
+ fprintf(f, "; rss_proto_l2 = <NONE>\n");
+ } else {
+ fprintf(f, "; rss_qs = <NONE>\n");
+ fprintf(f, "; rss_proto_ipv4 = <NONE>\n");
+ fprintf(f, "; rss_proto_ipv6 = <NONE>\n");
+ fprintf(f, "; rss_proto_l2 = <NONE>\n");
+ }
+
if (strlen(p->pci_bdf))
fprintf(f, "%s = %s\n", "pci_bdf", p->pci_bdf);
#define APP_NAME_SIZE 32
+#define APP_RETA_SIZE_MAX (ETH_RSS_RETA_SIZE_512 / RTE_RETA_GROUP_SIZE)
+
static void
app_init_core_map(struct app_params *app)
{
return (status != SOCKET_ID_ANY) ? status : 0;
}
+static inline int
+app_link_rss_enabled(struct app_link_params *cp)
+{
+ return (cp->n_rss_qs) ? 1 : 0;
+}
+
+static void
+app_link_rss_setup(struct app_link_params *cp)
+{
+ struct rte_eth_dev_info dev_info;
+ struct rte_eth_rss_reta_entry64 reta_conf[APP_RETA_SIZE_MAX];
+ uint32_t i;
+ int status;
+
+ /* Get RETA size */
+ memset(&dev_info, 0, sizeof(dev_info));
+ rte_eth_dev_info_get(cp->pmd_id, &dev_info);
+
+ if (dev_info.reta_size == 0)
+ rte_panic("%s (%u): RSS setup error (null RETA size)\n",
+ cp->name, cp->pmd_id);
+
+ if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512)
+ rte_panic("%s (%u): RSS setup error (RETA size too big)\n",
+ cp->name, cp->pmd_id);
+
+ /* Setup RETA contents */
+ memset(reta_conf, 0, sizeof(reta_conf));
+
+ for (i = 0; i < dev_info.reta_size; i++)
+ reta_conf[i / RTE_RETA_GROUP_SIZE].mask = UINT64_MAX;
+
+ for (i = 0; i < dev_info.reta_size; i++) {
+ uint32_t reta_id = i / RTE_RETA_GROUP_SIZE;
+ uint32_t reta_pos = i % RTE_RETA_GROUP_SIZE;
+ uint32_t rss_qs_pos = i % cp->n_rss_qs;
+
+ reta_conf[reta_id].reta[reta_pos] =
+ (uint16_t) cp->rss_qs[rss_qs_pos];
+ }
+
+ /* RETA update */
+ status = rte_eth_dev_rss_reta_update(cp->pmd_id,
+ reta_conf,
+ dev_info.reta_size);
+ if (status != 0)
+ rte_panic("%s (%u): RSS setup error (RETA update failed)\n",
+ cp->name, cp->pmd_id);
+}
+
+static void
+app_init_link_set_config(struct app_link_params *p)
+{
+ if (p->n_rss_qs) {
+ p->conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
+ p->conf.rx_adv_conf.rss_conf.rss_hf = p->rss_proto_ipv4 |
+ p->rss_proto_ipv6 |
+ p->rss_proto_l2;
+ }
+}
+
static void
app_init_link(struct app_params *app)
{
sscanf(p_link->name, "LINK%" PRIu32, &link_id);
n_hwq_in = app_link_get_n_rxq(app, p_link);
n_hwq_out = app_link_get_n_txq(app, p_link);
+ app_init_link_set_config(p_link);
APP_LOG(app, HIGH, "Initializing %s (%" PRIu32") "
"(%" PRIu32 " RXQ, %" PRIu32 " TXQ) ...",
rte_panic("Cannot start %s (error %" PRId32 ")\n",
p_link->name, status);
- /* LINK UP */
+ /* LINK FILTERS */
app_link_set_arp_filter(app, p_link);
app_link_set_tcp_syn_filter(app, p_link);
+ if (app_link_rss_enabled(p_link))
+ app_link_rss_setup(p_link);
+
+ /* LINK UP */
app_link_up_internal(app, p_link);
}