/*
-// Copyright (c) 2010-2017 Intel Corporation
+// Copyright (c) 2010-2020 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
static inline void start_l3(struct task_args *targ)
{
if (!task_is_master(targ)) {
- if ((targ->nb_txrings != 0) || (targ->nb_txports != 0)) {
- if (targ->flags & TASK_ARG_L3)
+ if ((targ->nb_txports != 0)) {
+ if (targ->flags & (TASK_ARG_L3|TASK_ARG_NDP))
task_start_l3(targ->tbase, targ);
}
}
targ = &lconf->targs[tid];
start_l3(targ);
}
- } else {
+ } else if (task_id < lconf->n_tasks_all) {
targ = &lconf->targs[task_id];
start_l3(targ);
+ } else {
+ plog_warn("Invalid task id %d on core %u\n", task_id, cores[i]);
+ continue;
}
+ if (wait_command_handled(lconf) == -1) return;
lconf->msg.type = LCONF_MSG_START;
lconf->msg.task_id = task_id;
lconf_set_req(lconf);
for (int i = 0; i < count; ++i) {
struct lcore_cfg *lconf = &lcore_cfg[cores[i]];
+ if (task_id >= lconf->n_tasks_all) {
+ plog_warn("Trying to stop invalid task id %d on core %u\n", task_id, cores[i]);
+ continue;
+ }
if (lconf->n_tasks_run) {
if (wait_command_handled(lconf) == -1) return;
return ret;
}
+static int add_multicast_addr(uint8_t port_id, prox_rte_ether_addr *addr)
+{
+ unsigned int i;
+ int rc = 0;
+
+ struct prox_port_cfg* port_cfg = &prox_port_cfg[port_id];
+
+ if (port_cfg->nb_mc_addr >= NB_MCAST_ADDR) {
+ plog_err("Already reached maximum number (%d) of mcast addr on port %u\n", NB_MCAST_ADDR, port_id);
+ return -1;
+ }
+ for (i = 0; i < port_cfg->nb_mc_addr; i++) {
+ if (prox_rte_is_same_ether_addr(addr, &port_cfg->mc_addr[i])) {
+ plog_info("multicast address already added to port\n");
+ return -1;
+ }
+ }
+
+ prox_rte_ether_addr_copy(addr, &port_cfg->mc_addr[port_cfg->nb_mc_addr]);
+ if ((rc = rte_eth_dev_set_mc_addr_list(port_id, port_cfg->mc_addr, port_cfg->nb_mc_addr + 1)) != 0) {
+ plog_err("rte_eth_dev_set_mc_addr_list returns %d on port %u\n", rc, port_id);
+ return rc;
+ }
+
+ port_cfg->nb_mc_addr++;
+ plog_info("rte_eth_dev_set_mc_addr_list(%d addr) on port %u\n", port_cfg->nb_mc_addr, port_id);
+ return rc;
+}
+
+static int del_multicast_addr(uint8_t port_id, prox_rte_ether_addr *addr)
+{
+ unsigned int i;
+ int rc = 0;
+
+ struct prox_port_cfg* port_cfg = &prox_port_cfg[port_id];
+
+ for (i = 0; i < port_cfg->nb_mc_addr; i++) {
+ if (prox_rte_is_same_ether_addr(addr, &port_cfg->mc_addr[i])) {
+ // Copy last address to the slot to be deleted
+ prox_rte_ether_addr_copy(&port_cfg->mc_addr[port_cfg->nb_mc_addr-1], &port_cfg->mc_addr[i]);
+
+ if ((rc = rte_eth_dev_set_mc_addr_list(port_id, port_cfg->mc_addr, port_cfg->nb_mc_addr - 1)) != 0) {
+ plog_err("rte_eth_dev_set_mc_addr_list returns %d on port %u\n", rc, port_id);
+ // When set failed, let restore the situation we were before calling the function...
+ prox_rte_ether_addr_copy(addr, &port_cfg->mc_addr[i]);
+ return rc;
+ }
+ port_cfg->nb_mc_addr--;
+ plog_info("rte_eth_dev_set_mc_addr_list(%d addr) on port %u\n", port_cfg->nb_mc_addr, port_id);
+ return 0;
+ }
+ }
+ plog_err("multicast address not found on port %u\n", port_id);
+ return -1;
+}
void cmd_mem_stats(void)
{
struct rte_malloc_socket_stats sock_stats;
// Unused for now, keep for reference
static int print_all_segments(const struct rte_memseg_list *memseg_list, const struct rte_memseg *memseg, void *arg)
{
- struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
- int memseg_list_idx, memseg_idx;
+ int memseg_list_idx = 0, memseg_idx;
int n = (*(int *)arg)++;
+#if RTE_VERSION < RTE_VERSION_NUM(19,8,0,0)
+ struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
memseg_list_idx = memseg_list - mcfg->memsegs;
if ((memseg_list_idx < 0) || (memseg_list_idx >= RTE_MAX_MEMSEG_LISTS)) {
plog_err("Invalid memseg_list_idx = %d; memseg_list = %p, mcfg->memsegs = %p\n", memseg_list_idx, memseg_list, mcfg->memsegs);
return -1;
}
+#endif
memseg_idx = rte_fbarray_find_idx(&memseg_list->memseg_arr, memseg);
if (memseg_idx < 0) {
plog_err("Invalid memseg_idx = %d; memseg_list = %p, memseg = %p\n", memseg_idx, memseg_list, memseg);
// Contiguous segments are shown as 1 big segment
static int print_segments(const struct rte_memseg_list *memseg_list, const struct rte_memseg *memseg, size_t len, void *arg)
{
- struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
- int memseg_list_idx, memseg_idx;
+ int memseg_list_idx = 0, memseg_idx;
static int n = 0;
+#if RTE_VERSION < RTE_VERSION_NUM(19,8,0,0)
+ struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
memseg_list_idx = memseg_list - mcfg->memsegs;
if ((memseg_list_idx < 0) || (memseg_list_idx >= RTE_MAX_MEMSEG_LISTS)) {
plog_err("Invalid memseg_list_idx = %d; memseg_list = %p, mcfg->memsegs = %p\n", memseg_list_idx, memseg_list, mcfg->memsegs);
return -1;
}
+#endif
memseg_idx = rte_fbarray_find_idx(&memseg_list->memseg_arr, memseg);
if (memseg_idx < 0) {
plog_err("Invalid memseg_idx = %d; memseg_list = %p, memseg = %p\n", memseg_idx, memseg_list, memseg);
}
#endif
+
void cmd_mem_layout(void)
{
#if RTE_VERSION < RTE_VERSION_NUM(18,5,0,0)
dst += snprintf(dst, end - dst,
"%2d:%10s; "MAC_BYTES_FMT"; %s\n",
port_id,
- port_cfg->name,
+ port_cfg->names[0],
MAC_BYTES(port_cfg->eth_addr.addr_bytes),
port_cfg->pci_addr);
}
struct prox_port_cfg* port_cfg = &prox_port_cfg[port_id];
dst += snprintf(dst, end - dst, "Port info for port %u\n", port_id);
- dst += snprintf(dst, end - dst, "\tName: %s\n", port_cfg->name);
+ dst += snprintf(dst, end - dst, "\tName: %s\n", port_cfg->names[0]);
dst += snprintf(dst, end - dst, "\tDriver: %s\n", port_cfg->driver_name);
dst += snprintf(dst, end - dst, "\tMac address: "MAC_BYTES_FMT"\n", MAC_BYTES(port_cfg->eth_addr.addr_bytes));
dst += snprintf(dst, end - dst, "\tLink speed: %u Mbps\n", port_cfg->link_speed);
+ dst += snprintf(dst, end - dst, "\tLink max speed: %u Mbps\n", port_cfg->max_link_speed);
dst += snprintf(dst, end - dst, "\tLink status: %s\n", port_cfg->link_up? "up" : "down");
dst += snprintf(dst, end - dst, "\tSocket: %u\n", port_cfg->socket);
dst += snprintf(dst, end - dst, "\tPCI address: %s\n", port_cfg->pci_addr);
dst += snprintf(dst, end - dst, "\tPromiscuous: %s\n", port_cfg->promiscuous? "yes" : "no");
+ for (unsigned int i = 0; i < port_cfg->nb_mc_addr; i++) {
+ dst += snprintf(dst, end - dst, "\tmcast address: "MAC_BYTES_FMT"\n", MAC_BYTES(port_cfg->mc_addr[i].addr_bytes));
+ }
dst += snprintf(dst, end - dst, "\tNumber of RX/TX descriptors: %u/%u\n", port_cfg->n_rxd, port_cfg->n_txd);
dst += snprintf(dst, end - dst, "\tNumber of RX/TX queues: %u/%u (max: %u/%u)\n", port_cfg->n_rxq, port_cfg->n_txq, port_cfg->max_rxq, port_cfg->max_txq);
dst += snprintf(dst, end - dst, "\tMemory pools:\n");
plog_warn("Failed to restart port %d\n", portid);
}
}
+
+void cmd_multicast(uint8_t port_id, unsigned int val, prox_rte_ether_addr *mac)
+{
+ if (!port_is_active(port_id)) {
+ return;
+ }
+ struct prox_port_cfg* port_cfg = &prox_port_cfg[port_id];
+ if (val == 1) {
+ if (port_cfg->nb_mc_addr == 0) {
+ rte_eth_allmulticast_enable(port_id);
+ }
+ if (add_multicast_addr(port_id, mac) != 0) {
+ if (port_cfg->nb_mc_addr == 0)
+ rte_eth_allmulticast_disable(port_id);
+ }
+ } else if (val == 0) {
+ if (del_multicast_addr(port_id, mac) == 0) {
+ if (port_cfg->nb_mc_addr == 0) {
+ rte_eth_allmulticast_disable(port_id);
+ }
+ }
+ } else {
+ plog_err("Unexpected value in cmd_multicast on port %d\n", port_id);
+ }
+}
+
void cmd_write_reg(uint8_t port_id, unsigned int id, unsigned int val)
{
if (!port_is_active(port_id)) {
}
plog_info("setting vlan offload to %d\n", val);
- if (val & ~(ETH_VLAN_STRIP_OFFLOAD | ETH_VLAN_FILTER_OFFLOAD | ETH_VLAN_EXTEND_OFFLOAD)) {
+ if (val & ~(RTE_ETH_VLAN_STRIP_OFFLOAD | RTE_ETH_VLAN_FILTER_OFFLOAD | RTE_ETH_VLAN_EXTEND_OFFLOAD)) {
plog_info("wrong vlan offload value\n");
}
int ret = rte_eth_dev_set_vlan_offload(port_id, val);