X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fnet%2Ftap%2Frte_eth_tap.c;h=922371c2955884b9bbe3e53b270be4a3b234e215;hb=fcba820d9b9e34007223590d4c75417ed42563c1;hp=4a42bbeb13434d174e637406f0ba442de73f3075;hpb=35b2d13fd6fdcbd191f2a30d74648faeb1186c65;p=dpdk.git diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 4a42bbeb13..922371c295 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -71,8 +71,6 @@ #define TAP_IOV_DEFAULT_MAX 1024 static int tap_devices_count; -static struct rte_vdev_driver pmd_tap_drv; -static struct rte_vdev_driver pmd_tun_drv; static const char *valid_arguments[] = { ETH_TAP_IFACE_ARG, @@ -272,12 +270,12 @@ tap_verify_csum(struct rte_mbuf *mbuf) else if (l2 == RTE_PTYPE_L2_ETHER_QINQ) l2_len += 8; /* Don't verify checksum for packets with discontinuous L2 header */ - if (unlikely(l2_len + sizeof(struct ipv4_hdr) > + if (unlikely(l2_len + sizeof(struct rte_ipv4_hdr) > rte_pktmbuf_data_len(mbuf))) return; l3_hdr = rte_pktmbuf_mtod_offset(mbuf, void *, l2_len); if (l3 == RTE_PTYPE_L3_IPV4 || l3 == RTE_PTYPE_L3_IPV4_EXT) { - struct ipv4_hdr *iph = l3_hdr; + 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); @@ -295,9 +293,9 @@ tap_verify_csum(struct rte_mbuf *mbuf) PKT_RX_IP_CKSUM_BAD : PKT_RX_IP_CKSUM_GOOD; } else if (l3 == RTE_PTYPE_L3_IPV6) { - struct ipv6_hdr *iph = l3_hdr; + struct rte_ipv6_hdr *iph = l3_hdr; - l3_len = sizeof(struct ipv6_hdr); + l3_len = sizeof(struct rte_ipv6_hdr); /* check that the total length reported by header is not * greater than the total received size */ @@ -496,7 +494,7 @@ tap_tx_l3_cksum(char *packet, uint64_t ol_flags, unsigned int l2_len, void *l3_hdr = packet + l2_len; if (ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_IPV4)) { - struct ipv4_hdr *iph = l3_hdr; + struct rte_ipv4_hdr *iph = l3_hdr; uint16_t cksum; iph->hdr_checksum = 0; @@ -508,9 +506,9 @@ tap_tx_l3_cksum(char *packet, uint64_t ol_flags, unsigned int l2_len, l4_hdr = packet + l2_len + l3_len; if ((ol_flags & PKT_TX_L4_MASK) == PKT_TX_UDP_CKSUM) - *l4_cksum = &((struct udp_hdr *)l4_hdr)->dgram_cksum; + *l4_cksum = &((struct rte_udp_hdr *)l4_hdr)->dgram_cksum; else if ((ol_flags & PKT_TX_L4_MASK) == PKT_TX_TCP_CKSUM) - *l4_cksum = &((struct tcp_hdr *)l4_hdr)->cksum; + *l4_cksum = &((struct rte_tcp_hdr *)l4_hdr)->cksum; else return; **l4_cksum = 0; @@ -565,9 +563,9 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs, char *buff_data = rte_pktmbuf_mtod(seg, void *); proto = (*buff_data & 0xf0); pi.proto = (proto == 0x40) ? - rte_cpu_to_be_16(RTE_ETHER_TYPE_IPv4) : + rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4) : ((proto == 0x60) ? - rte_cpu_to_be_16(RTE_ETHER_TYPE_IPv6) : + rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6) : 0x00); } @@ -917,7 +915,7 @@ tap_dev_speed_capa(void) return capa; } -static void +static int tap_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) { struct pmd_internals *internals = dev->data->dev_private; @@ -941,6 +939,8 @@ tap_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) * functions together and not in partial combinations */ dev_info->flow_type_rss_offloads = ~TAP_RSS_HF_MASK; + + return 0; } static int @@ -970,10 +970,9 @@ tap_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *tap_stats) for (i = 0; i < imax; i++) { tap_stats->q_opackets[i] = pmd->txq[i].stats.opackets; - tap_stats->q_errors[i] = pmd->txq[i].stats.errs; tap_stats->q_obytes[i] = pmd->txq[i].stats.obytes; tx_total += tap_stats->q_opackets[i]; - tx_err_total += tap_stats->q_errors[i]; + tx_err_total += pmd->txq[i].stats.errs; tx_bytes_total += tap_stats->q_obytes[i]; } @@ -987,7 +986,7 @@ tap_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *tap_stats) return 0; } -static void +static int tap_stats_reset(struct rte_eth_dev *dev) { int i; @@ -1003,6 +1002,8 @@ tap_stats_reset(struct rte_eth_dev *dev) pmd->txq[i].stats.errs = 0; pmd->txq[i].stats.obytes = 0; } + + return 0; } static void @@ -1101,52 +1102,116 @@ tap_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused) return 0; } -static void +static int tap_promisc_enable(struct rte_eth_dev *dev) { struct pmd_internals *pmd = dev->data->dev_private; struct ifreq ifr = { .ifr_flags = IFF_PROMISC }; + int ret; + + ret = tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 1, LOCAL_AND_REMOTE); + if (ret != 0) + return ret; - dev->data->promiscuous = 1; - tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 1, LOCAL_AND_REMOTE); - if (pmd->remote_if_index && !pmd->flow_isolate) - tap_flow_implicit_create(pmd, TAP_REMOTE_PROMISC); + if (pmd->remote_if_index && !pmd->flow_isolate) { + dev->data->promiscuous = 1; + ret = tap_flow_implicit_create(pmd, TAP_REMOTE_PROMISC); + if (ret != 0) { + /* Rollback promisc flag */ + tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 0, LOCAL_AND_REMOTE); + /* + * rte_eth_dev_promiscuous_enable() rollback + * dev->data->promiscuous in the case of failure. + */ + return ret; + } + } + + return 0; } -static void +static int tap_promisc_disable(struct rte_eth_dev *dev) { struct pmd_internals *pmd = dev->data->dev_private; struct ifreq ifr = { .ifr_flags = IFF_PROMISC }; + int ret; - dev->data->promiscuous = 0; - tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 0, LOCAL_AND_REMOTE); - if (pmd->remote_if_index && !pmd->flow_isolate) - tap_flow_implicit_destroy(pmd, TAP_REMOTE_PROMISC); + ret = tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 0, LOCAL_AND_REMOTE); + if (ret != 0) + return ret; + + if (pmd->remote_if_index && !pmd->flow_isolate) { + dev->data->promiscuous = 0; + ret = tap_flow_implicit_destroy(pmd, TAP_REMOTE_PROMISC); + if (ret != 0) { + /* Rollback promisc flag */ + tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 1, LOCAL_AND_REMOTE); + /* + * rte_eth_dev_promiscuous_disable() rollback + * dev->data->promiscuous in the case of failure. + */ + return ret; + } + } + + return 0; } -static void +static int tap_allmulti_enable(struct rte_eth_dev *dev) { struct pmd_internals *pmd = dev->data->dev_private; struct ifreq ifr = { .ifr_flags = IFF_ALLMULTI }; + int ret; + + ret = tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 1, LOCAL_AND_REMOTE); + if (ret != 0) + return ret; + + if (pmd->remote_if_index && !pmd->flow_isolate) { + dev->data->all_multicast = 1; + ret = tap_flow_implicit_create(pmd, TAP_REMOTE_ALLMULTI); + if (ret != 0) { + /* Rollback allmulti flag */ + tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 0, LOCAL_AND_REMOTE); + /* + * rte_eth_dev_allmulticast_enable() rollback + * dev->data->all_multicast in the case of failure. + */ + return ret; + } + } - dev->data->all_multicast = 1; - tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 1, LOCAL_AND_REMOTE); - if (pmd->remote_if_index && !pmd->flow_isolate) - tap_flow_implicit_create(pmd, TAP_REMOTE_ALLMULTI); + return 0; } -static void +static int tap_allmulti_disable(struct rte_eth_dev *dev) { struct pmd_internals *pmd = dev->data->dev_private; struct ifreq ifr = { .ifr_flags = IFF_ALLMULTI }; + int ret; - dev->data->all_multicast = 0; - tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 0, LOCAL_AND_REMOTE); - if (pmd->remote_if_index && !pmd->flow_isolate) - tap_flow_implicit_destroy(pmd, TAP_REMOTE_ALLMULTI); + ret = tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 0, LOCAL_AND_REMOTE); + if (ret != 0) + return ret; + + if (pmd->remote_if_index && !pmd->flow_isolate) { + dev->data->all_multicast = 0; + ret = tap_flow_implicit_destroy(pmd, TAP_REMOTE_ALLMULTI); + if (ret != 0) { + /* Rollback allmulti flag */ + tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 1, LOCAL_AND_REMOTE); + /* + * rte_eth_dev_allmulticast_disable() rollback + * dev->data->all_multicast in the case of failure. + */ + return ret; + } + } + + return 0; } static int @@ -2287,7 +2352,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev) /* Register IPC feed callback */ if (!tap_devices_count) { ret = rte_mp_action_register(TAP_MP_KEY, tap_mp_sync_queues); - if (ret < 0) { + if (ret < 0 && rte_errno != ENOTSUP) { TAP_LOG(ERR, "tap: Failed to register IPC callback: %s", strerror(rte_errno)); goto leave;