app/testpmd: list forwarding engines
[dpdk.git] / app / test-pmd / config.c
index 0816227..41326fe 100644 (file)
@@ -100,12 +100,12 @@ static void
 print_ethaddr(const char *name, struct ether_addr *eth_addr)
 {
        printf("%s%02X:%02X:%02X:%02X:%02X:%02X", name,
-              eth_addr->addr_bytes[0],
-              eth_addr->addr_bytes[1],
-              eth_addr->addr_bytes[2],
-              eth_addr->addr_bytes[3],
-              eth_addr->addr_bytes[4],
-              eth_addr->addr_bytes[5]);
+              (unsigned int)eth_addr->addr_bytes[0],
+              (unsigned int)eth_addr->addr_bytes[1],
+              (unsigned int)eth_addr->addr_bytes[2],
+              (unsigned int)eth_addr->addr_bytes[3],
+              (unsigned int)eth_addr->addr_bytes[4],
+              (unsigned int)eth_addr->addr_bytes[5]);
 }
 
 void
@@ -244,7 +244,6 @@ port_infos_display(portid_t port_id)
        struct rte_port *port;
        struct rte_eth_link link;
        int vlan_offload;
-       int socket_id;
        struct rte_mempool * mp;
        static const char *info_border = "*********************";
 
@@ -254,11 +253,10 @@ port_infos_display(portid_t port_id)
        }
        port = &ports[port_id];
        rte_eth_link_get_nowait(port_id, &link);
-       socket_id = rte_eth_dev_socket_id(port_id);
        printf("\n%s Infos for port %-2d %s\n",
               info_border, port_id, info_border);
        print_ethaddr("MAC address: ", &port->eth_addr);
-       printf("\nConnect to socket: %d",socket_id);
+       printf("\nConnect to socket: %u", port->socket_id);
 
        if (port_numa[port_id] != NUMA_NO_CONFIG) {
                mp = mbuf_pool_find(port_numa[port_id]);
@@ -266,7 +264,7 @@ port_infos_display(portid_t port_id)
                        printf("\nmemory allocation on the socket: %d",
                                                        port_numa[port_id]);
        } else
-               printf("\nmemory allocation on the socket: %d",socket_id);
+               printf("\nmemory allocation on the socket: %u",port->socket_id);
 
        printf("\nLink status: %s\n", (link.link_status) ? ("up") : ("down"));
        printf("Link speed: %u Mbps\n", (unsigned) link.link_speed);
@@ -733,7 +731,8 @@ simple_fwd_config_setup(void)
        portid_t j;
        portid_t inc = 2;
 
-       if (port_topology == PORT_TOPOLOGY_CHAINED) {
+       if (port_topology == PORT_TOPOLOGY_CHAINED ||
+           port_topology == PORT_TOPOLOGY_LOOP) {
                inc = 1;
        } else if (nb_fwd_ports % 2) {
                printf("\nWarning! Cannot handle an odd number of ports "
@@ -761,7 +760,10 @@ simple_fwd_config_setup(void)
        setup_fwd_config_of_each_lcore(&cur_fwd_config);
 
        for (i = 0; i < cur_fwd_config.nb_fwd_ports; i = (portid_t) (i + inc)) {
-               j = (portid_t) ((i + 1) % cur_fwd_config.nb_fwd_ports);
+               if (port_topology != PORT_TOPOLOGY_LOOP)
+                       j = (portid_t) ((i + 1) % cur_fwd_config.nb_fwd_ports);
+               else
+                       j = i;
                fwd_streams[i]->rx_port   = fwd_ports_ids[i];
                fwd_streams[i]->rx_queue  = 0;
                fwd_streams[i]->tx_port   = fwd_ports_ids[j];
@@ -825,10 +827,18 @@ rss_fwd_config_setup(void)
                struct fwd_stream *fs;
 
                fs = fwd_streams[lc_id];
+
                if ((rxp & 0x1) == 0)
                        txp = (portid_t) (rxp + 1);
                else
                        txp = (portid_t) (rxp - 1);
+               /*
+                * if we are in loopback, simply send stuff out through the
+                * ingress port
+                */
+               if (port_topology == PORT_TOPOLOGY_LOOP)
+                       txp = rxp;
+
                fs->rx_port = fwd_ports_ids[rxp];
                fs->rx_queue = rxq;
                fs->tx_port = fwd_ports_ids[txp];
@@ -1221,6 +1231,25 @@ set_tx_pkt_segments(unsigned *seg_lengths, unsigned nb_segs)
        tx_pkt_nb_segs = (uint8_t) nb_segs;
 }
 
+char*
+list_pkt_forwarding_modes(void)
+{
+       static char fwd_modes[128] = "";
+       const char *separator = "|";
+       struct fwd_engine *fwd_eng;
+       unsigned i = 0;
+
+       if (strlen (fwd_modes) == 0) {
+               while ((fwd_eng = fwd_engines[i++]) != NULL) {
+                       strcat(fwd_modes, fwd_eng->fwd_mode_name);
+                       strcat(fwd_modes, separator);
+               }
+               fwd_modes[strlen(fwd_modes) - strlen(separator)] = '\0';
+       }
+
+       return fwd_modes;
+}
+
 void
 set_pkt_forwarding_mode(const char *fwd_mode_name)
 {