net/tap: fix icc build
[dpdk.git] / drivers / net / tap / rte_eth_tap.c
index 915d937..ef33aac 100644 (file)
@@ -526,8 +526,8 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
                 */
                char *buff_data = rte_pktmbuf_mtod(seg, void *);
                j = (*buff_data & 0xf0);
-               if (j & (0x40 | 0x60))
-                       pi.proto = (j == 0x40) ? 0x0008 : 0xdd86;
+               pi.proto = (j == 0x40) ? 0x0008 :
+                               (j == 0x60) ? 0xdd86 : 0x00;
 
                iovecs[0].iov_base = π
                iovecs[0].iov_len = sizeof(pi);
@@ -621,7 +621,9 @@ apply:
        case SIOCSIFMTU:
                break;
        default:
-               RTE_ASSERT(!"unsupported request type: must not happen");
+               RTE_LOG(WARNING, PMD, "%s: ioctl() called with wrong arg\n",
+                       pmd->name);
+               return -EINVAL;
        }
        if (ioctl(pmd->ioctl_sock, request, ifr) < 0)
                goto error;
@@ -1386,12 +1388,6 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
        RTE_LOG(DEBUG, PMD, "%s device on numa %u\n",
                        tuntap_name, rte_socket_id());
 
-       data = rte_zmalloc_socket(tap_name, sizeof(*data), 0, numa_node);
-       if (!data) {
-               RTE_LOG(ERR, PMD, "%s Failed to allocate data\n", tuntap_name);
-               goto error_exit_nodev;
-       }
-
        dev = rte_eth_vdev_allocate(vdev, sizeof(*pmd));
        if (!dev) {
                RTE_LOG(ERR, PMD, "%s Unable to allocate device struct\n",
@@ -1412,7 +1408,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
        }
 
        /* Setup some default values */
-       rte_memcpy(data, dev->data, sizeof(*data));
+       data = dev->data;
        data->dev_private = pmd;
        data->dev_flags = RTE_ETH_DEV_INTR_LSC;
        data->numa_node = numa_node;
@@ -1423,7 +1419,6 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
        data->nb_rx_queues = 0;
        data->nb_tx_queues = 0;
 
-       dev->data = data;
        dev->dev_ops = &ops;
        dev->rx_pkt_burst = pmd_rx_burst;
        dev->tx_pkt_burst = pmd_tx_burst;
@@ -1574,7 +1569,6 @@ error_exit_nodev:
        RTE_LOG(ERR, PMD, "%s Unable to initialize %s\n",
                tuntap_name, rte_vdev_device_name(vdev));
 
-       rte_free(data);
        return -EINVAL;
 }
 
@@ -1729,6 +1723,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
        char tap_name[RTE_ETH_NAME_MAX_LEN];
        char remote_iface[RTE_ETH_NAME_MAX_LEN];
        struct ether_addr user_mac = { .addr_bytes = {0} };
+       struct rte_eth_dev *eth_dev;
 
        tap_type = 1;
        strcpy(tuntap_name, "TAP");
@@ -1736,6 +1731,18 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
        name = rte_vdev_device_name(dev);
        params = rte_vdev_device_args(dev);
 
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
+           strlen(params) == 0) {
+               eth_dev = rte_eth_dev_attach_secondary(name);
+               if (!eth_dev) {
+                       RTE_LOG(ERR, PMD, "Failed to probe %s\n", name);
+                       return -1;
+               }
+               /* TODO: request info from primary to set up Rx and Tx */
+               eth_dev->dev_ops = &ops;
+               return 0;
+       }
+
        speed = ETH_SPEED_NUM_10G;
        snprintf(tap_name, sizeof(tap_name), "%s%d",
                 DEFAULT_TAP_NAME, tap_unit++);
@@ -1828,7 +1835,6 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)
 
        close(internals->ioctl_sock);
        rte_free(eth_dev->data->dev_private);
-       rte_free(eth_dev->data);
 
        rte_eth_dev_release_port(eth_dev);