ethdev: use constants for link state
[dpdk.git] / drivers / net / xenvirt / rte_eth_xenvirt.c
index ab0e27a..9453a06 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -72,7 +72,7 @@ static const char *drivername = "xen virtio PMD";
 static struct rte_eth_link pmd_link = {
                .link_speed = 10000,
                .link_duplex = ETH_LINK_FULL_DUPLEX,
-               .link_status = 0
+               .link_status = ETH_LINK_DOWN,
 };
 
 static void
@@ -102,7 +102,7 @@ eth_xenvirt_rx(void *q, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 
        nb_used = VIRTQUEUE_NUSED(rxvq);
 
-       rte_compiler_barrier(); /* rmb */
+       rte_smp_rmb();
        num = (uint16_t)(likely(nb_used <= nb_pkts) ? nb_used : nb_pkts);
        num = (uint16_t)(likely(num <= VIRTIO_MBUF_BURST_SZ) ? num : VIRTIO_MBUF_BURST_SZ);
        if (unlikely(num == 0)) return 0;
@@ -153,7 +153,7 @@ eth_xenvirt_tx(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
        PMD_TX_LOG(DEBUG, "%d packets to xmit", nb_pkts);
        nb_used = VIRTQUEUE_NUSED(txvq);
 
-       rte_compiler_barrier();   /* rmb */
+       rte_smp_rmb();
 
        num = (uint16_t)(likely(nb_used <= VIRTIO_MBUF_BURST_SZ) ? nb_used : VIRTIO_MBUF_BURST_SZ);
        num = virtqueue_dequeue_burst(txvq, snd_pkts, len, num);
@@ -290,7 +290,7 @@ eth_dev_start(struct rte_eth_dev *dev)
        struct pmd_internals *pi = (struct pmd_internals *)dev->data->dev_private;
        int rv;
 
-       dev->data->dev_link.link_status = 1;
+       dev->data->dev_link.link_status = ETH_LINK_UP;
        while (!virtqueue_full(rxvq)) {
                m = rte_rxmbuf_alloc(rxvq->mpool);
                if (m == NULL)
@@ -318,7 +318,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
 {
        struct pmd_internals *pi = (struct pmd_internals *)dev->data->dev_private;
 
-       dev->data->dev_link.link_status = 0;
+       dev->data->dev_link.link_status = ETH_LINK_DOWN;
        dev_stop_notify(pi->virtio_idx);
 }
 
@@ -431,10 +431,8 @@ gntalloc_vring_create(int queue_type, uint32_t size, int vtidx)
                va = NULL;
        }
 out:
-       if (pa_arr)
-               free(pa_arr);
-       if (gref_arr)
-               free(gref_arr);
+       free(pa_arr);
+       free(gref_arr);
 
        return va;
 }
@@ -637,11 +635,11 @@ eth_dev_xenvirt_create(const char *name, const char *params,
                 enum dev_action action)
 {
        struct rte_eth_dev_data *data = NULL;
-       struct rte_pci_device *pci_dev = NULL;
        struct pmd_internals *internals = NULL;
        struct rte_eth_dev *eth_dev = NULL;
        struct xenvirt_dict dict;
-       bzero(&dict, sizeof(struct xenvirt_dict));
+
+       memset(&dict, 0, sizeof(struct xenvirt_dict));
 
        RTE_LOG(INFO, PMD, "Creating virtio rings backed ethdev on numa socket %u\n",
                        numa_node);
@@ -659,10 +657,6 @@ eth_dev_xenvirt_create(const char *name, const char *params,
        if (data == NULL)
                goto err;
 
-       pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, numa_node);
-       if (pci_dev == NULL)
-               goto err;
-
        internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node);
        if (internals == NULL)
                goto err;
@@ -672,8 +666,6 @@ eth_dev_xenvirt_create(const char *name, const char *params,
        if (eth_dev == NULL)
                goto err;
 
-       pci_dev->numa_node = numa_node;
-
        data->dev_private = internals;
        data->port_id = eth_dev->data->port_id;
        data->nb_rx_queues = (uint16_t)1;
@@ -690,7 +682,6 @@ eth_dev_xenvirt_create(const char *name, const char *params,
        eth_dev->dev_ops = &ops;
 
        eth_dev->data->dev_flags = RTE_PCI_DRV_DETACHABLE;
-       eth_dev->pci_dev = pci_dev;
        eth_dev->data->kdrv = RTE_KDRV_NONE;
        eth_dev->data->drv_name = drivername;
        eth_dev->driver = NULL;
@@ -706,7 +697,6 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 
 err:
        rte_free(data);
-       rte_free(pci_dev);
        rte_free(internals);
 
        return -1;