X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Ftap%2Frte_eth_tap.c;h=2f8abb12c5c68421d7cca45c1faebca78e774827;hb=be797cbf4582f3c474f208aeb3d1baa4001a6156;hp=df16aa4ea7de73bdccd236c5bb62170c07298eb9;hpb=05a8e4a35d3ca9c1e5271917ad081ba78cd73fce;p=dpdk.git diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index df16aa4ea7..2f8abb12c5 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -72,6 +72,10 @@ static int tap_devices_count; +static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = { + "UNKNOWN", "TUN", "TAP" +}; + static const char *valid_arguments[] = { ETH_TAP_IFACE_ARG, ETH_TAP_REMOTE_ARG, @@ -312,8 +316,7 @@ tap_verify_csum(struct rte_mbuf *mbuf) if (l3 == RTE_PTYPE_L3_IPV4 || l3 == RTE_PTYPE_L3_IPV4_EXT) { struct rte_ipv4_hdr *iph = l3_hdr; - /* ihl contains the number of 4-byte words in the header */ - l3_len = 4 * (iph->version_ihl & 0xf); + l3_len = rte_ipv4_hdr_len(iph); if (unlikely(l2_len + l3_len > rte_pktmbuf_data_len(mbuf))) return; /* check that the total length reported by header is not @@ -748,8 +751,16 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) if (num_tso_mbufs < 0) break; - mbuf = gso_mbufs; - num_mbufs = num_tso_mbufs; + if (num_tso_mbufs >= 1) { + mbuf = gso_mbufs; + num_mbufs = num_tso_mbufs; + } else { + /* 0 means it can be transmitted directly + * without gso. + */ + mbuf = &mbuf_in; + num_mbufs = 1; + } } else { /* stats.errs will be incremented */ if (rte_pktmbuf_pkt_len(mbuf_in) > max_size) @@ -897,7 +908,7 @@ tap_dev_start(struct rte_eth_dev *dev) /* This function gets called when the current port gets stopped. */ -static void +static int tap_dev_stop(struct rte_eth_dev *dev) { int i; @@ -909,6 +920,8 @@ tap_dev_stop(struct rte_eth_dev *dev) tap_intr_handle_set(dev, 0); tap_link_set_down(dev); + + return 0; } static int @@ -1067,7 +1080,7 @@ tap_stats_reset(struct rte_eth_dev *dev) return 0; } -static void +static int tap_dev_close(struct rte_eth_dev *dev) { int i; @@ -1075,6 +1088,11 @@ tap_dev_close(struct rte_eth_dev *dev) struct pmd_process_private *process_private = dev->process_private; struct rx_queue *rxq; + if (rte_eal_process_type() != RTE_PROC_PRIMARY) { + rte_free(dev->process_private); + return 0; + } + tap_link_set_down(dev); if (internals->nlsk_fd != -1) { tap_flow_flush(dev, NULL); @@ -1112,10 +1130,28 @@ tap_dev_close(struct rte_eth_dev *dev) close(internals->ka_fd); internals->ka_fd = -1; } + + /* mac_addrs must not be freed alone because part of dev_private */ + dev->data->mac_addrs = NULL; + + internals = dev->data->dev_private; + TAP_LOG(DEBUG, "Closing %s Ethernet device on numa %u", + tuntap_types[internals->type], rte_socket_id()); + + if (internals->ioctl_sock != -1) { + close(internals->ioctl_sock); + internals->ioctl_sock = -1; + } + rte_free(dev->process_private); + if (tap_devices_count == 1) + rte_mp_action_unregister(TAP_MP_KEY); + tap_devices_count--; /* * Since TUN device has no more opened file descriptors * it will be removed from kernel */ + + return 0; } static void @@ -1843,10 +1879,6 @@ static const struct eth_dev_ops ops = { .filter_ctrl = tap_dev_filter_ctrl, }; -static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = { - "UNKNOWN", "TUN", "TAP" -}; - static int eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name, char *remote_iface, struct rte_ether_addr *mac_addr, @@ -1898,7 +1930,8 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name, /* Setup some default values */ data = dev->data; data->dev_private = pmd; - data->dev_flags = RTE_ETH_DEV_INTR_LSC; + data->dev_flags = RTE_ETH_DEV_INTR_LSC | + RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; data->numa_node = numa_node; data->dev_link = pmd_link; @@ -2490,30 +2523,13 @@ static int rte_pmd_tap_remove(struct rte_vdev_device *dev) { struct rte_eth_dev *eth_dev = NULL; - struct pmd_internals *internals; /* find the ethdev entry */ eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev)); if (!eth_dev) - return -ENODEV; - - /* mac_addrs must not be freed alone because part of dev_private */ - eth_dev->data->mac_addrs = NULL; - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return rte_eth_dev_release_port(eth_dev); + return 0; tap_dev_close(eth_dev); - - internals = eth_dev->data->dev_private; - TAP_LOG(DEBUG, "Closing %s Ethernet device on numa %u", - tuntap_types[internals->type], rte_socket_id()); - - close(internals->ioctl_sock); - rte_free(eth_dev->process_private); - if (tap_devices_count == 1) - rte_mp_action_unregister(TAP_MP_KEY); - tap_devices_count--; rte_eth_dev_release_port(eth_dev); return 0;