ethdev: add access to EEPROM
[dpdk.git] / drivers / net / pcap / rte_eth_pcap.c
index c1571e1..932cf3c 100644 (file)
@@ -96,7 +96,7 @@ static struct rte_eth_link pmd_link = {
                .link_speed = ETH_SPEED_NUM_10G,
                .link_duplex = ETH_LINK_FULL_DUPLEX,
                .link_status = ETH_LINK_DOWN,
-               .link_autoneg = ETH_LINK_AUTONEG,
+               .link_autoneg = ETH_LINK_FIXED,
 };
 
 static int
@@ -773,27 +773,16 @@ pmd_init_internals(struct rte_vdev_device *vdev,
                struct pmd_internals **internals,
                struct rte_eth_dev **eth_dev)
 {
-       struct rte_eth_dev_data *data = NULL;
+       struct rte_eth_dev_data *data;
        unsigned int numa_node = vdev->device.numa_node;
-       const char *name;
 
-       name = rte_vdev_device_name(vdev);
        RTE_LOG(INFO, PMD, "Creating pcap-backed ethdev on numa socket %d\n",
                numa_node);
 
-       /* now do all data allocation - for eth_dev structure
-        * and internal (private) data
-        */
-       data = rte_zmalloc_socket(name, sizeof(*data), 0, numa_node);
-       if (data == NULL)
-               return -1;
-
        /* reserve an ethdev entry */
        *eth_dev = rte_eth_vdev_allocate(vdev, sizeof(**internals));
-       if (*eth_dev == NULL) {
-               rte_free(data);
+       if (!(*eth_dev))
                return -1;
-       }
 
        /* now put it all together
         * - store queue data in internals,
@@ -802,7 +791,7 @@ pmd_init_internals(struct rte_vdev_device *vdev,
         * - and point eth_dev structure to new eth_dev_data structure
         */
        *internals = (*eth_dev)->data->dev_private;
-       rte_memcpy(data, (*eth_dev)->data, sizeof(*data));
+       data = (*eth_dev)->data;
        data->nb_rx_queues = (uint16_t)nb_rx_queues;
        data->nb_tx_queues = (uint16_t)nb_tx_queues;
        data->dev_link = pmd_link;
@@ -812,7 +801,6 @@ pmd_init_internals(struct rte_vdev_device *vdev,
         * NOTE: we'll replace the data element, of originally allocated
         * eth_dev so the rings are local per-process
         */
-       (*eth_dev)->data = data;
        (*eth_dev)->dev_ops = &ops;
 
        return 0;
@@ -910,6 +898,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
        struct rte_kvargs *kvlist;
        struct pmd_devargs pcaps = {0};
        struct pmd_devargs dumpers = {0};
+       struct rte_eth_dev *eth_dev;
        int single_iface = 0;
        int ret;
 
@@ -920,6 +909,18 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
        start_cycles = rte_get_timer_cycles();
        hz = rte_get_timer_hz();
 
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
+           strlen(rte_vdev_device_args(dev)) == 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;
+       }
+
        kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments);
        if (kvlist == NULL)
                return -1;
@@ -1020,7 +1021,6 @@ pmd_pcap_remove(struct rte_vdev_device *dev)
                return -1;
 
        rte_free(eth_dev->data->dev_private);
-       rte_free(eth_dev->data);
 
        rte_eth_dev_release_port(eth_dev);