X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest-pmd%2Ftestpmd.c;h=f61f31344b9dfd497bced788c615e37a077e34b7;hb=3c1a5444d47c6c3e34c5c1a991c4a80835ba4f43;hp=28d9b26da02721fcefbd41ec72aac462ceec886f;hpb=76ad4a2d82d4d72c3a7ed4675d77268b5fae3cc9;p=dpdk.git diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 28d9b26da0..f61f31344b 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -59,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -83,7 +84,6 @@ #ifdef RTE_LIBRTE_BITRATE #include #endif -#include #ifdef RTE_LIBRTE_LATENCY_STATS #include #endif @@ -103,7 +103,7 @@ uint8_t auto_start = 0; * probed ports among the CPU sockets 0 and 1. * Otherwise, all memory is allocated from CPU socket 0. */ -uint8_t numa_support = 0; /**< No numa support by default */ +uint8_t numa_support = 1; /**< numa enabled by default */ /* * In UMA mode,all memory is allocated from socket 0 if --socket-num is @@ -270,6 +270,16 @@ uint8_t no_flush_rx = 0; /* flush by default */ */ uint8_t no_link_check = 0; /* check by default */ +/* + * Enable link status change notification + */ +uint8_t lsc_interrupt = 1; /* enabled by default */ + +/* + * Enable device removal notification. + */ +uint8_t rmv_interrupt = 1; /* enabled by default */ + /* * NIC bypass mode configuration options. */ @@ -587,7 +597,7 @@ init_config(void) uint8_t i; unsigned int nb_mbuf; - if (param_total_num_mbufs) + if (param_total_num_mbufs && nb_ports != 0) nb_mbuf_per_pool = nb_mbuf_per_pool/nb_ports; for (i = 0; i < max_socket; i++) { @@ -1746,9 +1756,35 @@ check_all_ports_link_status(uint32_t port_mask) if (all_ports_up == 1 || count == (MAX_CHECK_TIME - 1)) { print_flag = 1; } + + if (lsc_interrupt) + break; } } +static void +rmv_event_callback(void *arg) +{ + struct rte_eth_dev *dev; + struct rte_devargs *da; + char name[32] = ""; + uint8_t port_id = (intptr_t)arg; + + RTE_ETH_VALID_PORTID_OR_RET(port_id); + dev = &rte_eth_devices[port_id]; + da = dev->device->devargs; + + stop_port(port_id); + close_port(port_id); + if (da->type == RTE_DEVTYPE_VIRTUAL) + snprintf(name, sizeof(name), "%s", da->virt.drv_name); + else if (da->type == RTE_DEVTYPE_WHITELISTED_PCI) + rte_eal_pci_device_name(&da->pci.addr, name, sizeof(name)); + printf("removing device %s\n", name); + rte_eal_dev_detach(name); + dev->state = RTE_ETH_DEV_UNUSED; +} + /* This function is used by the interrupt thread */ static void eth_event_callback(uint8_t port_id, enum rte_eth_event_type type, void *param) @@ -1775,6 +1811,16 @@ eth_event_callback(uint8_t port_id, enum rte_eth_event_type type, void *param) event_desc[type]); fflush(stdout); } + + switch (type) { + case RTE_ETH_EVENT_INTR_RMV: + if (rte_eal_alarm_set(100000, + rmv_event_callback, (void *)(intptr_t)port_id)) + fprintf(stderr, "Could not set up deferred device removal\n"); + break; + default: + break; + } } static int @@ -1929,6 +1975,15 @@ init_port_config(void) #ifdef RTE_NIC_BYPASS rte_eth_dev_bypass_init(pid); #endif + + if (lsc_interrupt && + (rte_eth_devices[pid].data->dev_flags & + RTE_ETH_DEV_INTR_LSC)) + port->dev_conf.intr_conf.lsc = 1; + if (rmv_interrupt && + (rte_eth_devices[pid].data->dev_flags & + RTE_ETH_DEV_INTR_RMV)) + port->dev_conf.intr_conf.rmv = 1; } }