ethdev: clear data when allocating device
[dpdk.git] / drivers / net / mpipe / mpipe_tilegx.c
index aef7600..792ab56 100644 (file)
@@ -33,7 +33,7 @@
 #include <unistd.h>
 
 #include <rte_eal.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_eal_memconfig.h>
 #include <rte_ethdev.h>
 #include <rte_malloc.h>
@@ -394,14 +394,16 @@ mpipe_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 
                speed = state & GXIO_MPIPE_LINK_SPEED_MASK;
 
+               new.link_autoneg = (dev->data->dev_conf.link_speeds &
+                               ETH_LINK_SPEED_AUTONEG);
                if (speed == GXIO_MPIPE_LINK_1G) {
-                       new.link_speed = ETH_LINK_SPEED_1000;
+                       new.link_speed = ETH_SPEED_NUM_1G;
                        new.link_duplex = ETH_LINK_FULL_DUPLEX;
-                       new.link_status = 1;
+                       new.link_status = ETH_LINK_UP;
                } else if (speed == GXIO_MPIPE_LINK_10G) {
-                       new.link_speed = ETH_LINK_SPEED_10000;
+                       new.link_speed = ETH_SPEED_NUM_10G;
                        new.link_duplex = ETH_LINK_FULL_DUPLEX;
-                       new.link_status = 1;
+                       new.link_status = ETH_LINK_UP;
                }
 
                rc = mpipe_link_compare(&old, &new);
@@ -514,7 +516,7 @@ mpipe_recv_fill_stack(struct mpipe_dev_priv *priv, int count)
        int i;
 
        for (i = 0; i < count; i++) {
-               mbuf = __rte_mbuf_raw_alloc(priv->rx_mpool);
+               mbuf = rte_mbuf_raw_alloc(priv->rx_mpool);
                if (!mbuf)
                        break;
                mpipe_recv_push(priv, mbuf);
@@ -848,9 +850,9 @@ mpipe_start(struct rte_eth_dev *dev)
 
        /* Start xmit/recv on queues. */
        for (queue = 0; queue < priv->nb_tx_queues; queue++)
-               mpipe_tx_queue(priv, queue)->q.link_status = 1;
+               mpipe_tx_queue(priv, queue)->q.link_status = ETH_LINK_UP;
        for (queue = 0; queue < priv->nb_rx_queues; queue++)
-               mpipe_rx_queue(priv, queue)->q.link_status = 1;
+               mpipe_rx_queue(priv, queue)->q.link_status = ETH_LINK_UP;
        priv->running = 1;
 
        return 0;
@@ -865,9 +867,9 @@ mpipe_stop(struct rte_eth_dev *dev)
        int rc;
 
        for (queue = 0; queue < priv->nb_tx_queues; queue++)
-               mpipe_tx_queue(priv, queue)->q.link_status = 0;
+               mpipe_tx_queue(priv, queue)->q.link_status = ETH_LINK_DOWN;
        for (queue = 0; queue < priv->nb_rx_queues; queue++)
-               mpipe_rx_queue(priv, queue)->q.link_status = 0;
+               mpipe_rx_queue(priv, queue)->q.link_status = ETH_LINK_DOWN;
 
        /* Make sure the link_status writes land. */
        rte_wmb();
@@ -1165,7 +1167,7 @@ mpipe_promiscuous_disable(struct rte_eth_dev *dev)
        }
 }
 
-static struct eth_dev_ops mpipe_dev_ops = {
+static const struct eth_dev_ops mpipe_dev_ops = {
        .dev_infos_get           = mpipe_infos_get,
        .dev_configure           = mpipe_configure,
        .dev_start               = mpipe_start,
@@ -1450,7 +1452,7 @@ mpipe_do_recv(struct mpipe_rx_queue *rx_queue, struct rte_mbuf **rx_pkts,
                                        MPIPE_BUF_DEBT_THRESHOLD)
                                mpipe_local.mbuf_push_debt[in_port]++;
                        else {
-                               mbuf = __rte_mbuf_raw_alloc(priv->rx_mpool);
+                               mbuf = rte_mbuf_raw_alloc(priv->rx_mpool);
                                if (unlikely(!mbuf)) {
                                        nb_nomem++;
                                        gxio_mpipe_iqueue_drop(iqueue, idesc);
@@ -1547,7 +1549,7 @@ mpipe_link_mac(const char *ifname, uint8_t *mac)
 }
 
 static int
-rte_pmd_mpipe_devinit(const char *ifname,
+rte_pmd_mpipe_probe(const char *ifname,
                      const char *params __rte_unused)
 {
        gxio_mpipe_context_t *context;
@@ -1585,7 +1587,7 @@ rte_pmd_mpipe_devinit(const char *ifname,
                return -ENODEV;
        }
 
-       eth_dev = rte_eth_dev_allocate(ifname, RTE_ETH_DEV_VIRTUAL);
+       eth_dev = rte_eth_dev_allocate(ifname);
        if (!eth_dev) {
                RTE_LOG(ERR, PMD, "%s: Failed to allocate device.\n", ifname);
                rte_free(priv);
@@ -1601,7 +1603,6 @@ rte_pmd_mpipe_devinit(const char *ifname,
        eth_dev->data->dev_private = priv;
        eth_dev->data->mac_addrs = &priv->mac_addr;
 
-       eth_dev->data->dev_flags = 0;
        eth_dev->data->kdrv = RTE_KDRV_NONE;
        eth_dev->driver = NULL;
        eth_dev->data->drv_name = drivername;
@@ -1621,20 +1622,18 @@ rte_pmd_mpipe_devinit(const char *ifname,
        return 0;
 }
 
-static struct rte_driver pmd_mpipe_xgbe_drv = {
-       .name = "xgbe",
-       .type = PMD_VDEV,
-       .init = rte_pmd_mpipe_devinit,
+static struct rte_vdev_driver pmd_mpipe_xgbe_drv = {
+       .probe = rte_pmd_mpipe_probe,
 };
 
-static struct rte_driver pmd_mpipe_gbe_drv = {
-       .name = "gbe",
-       .type = PMD_VDEV,
-       .init = rte_pmd_mpipe_devinit,
+static struct rte_vdev_driver pmd_mpipe_gbe_drv = {
+       .probe = rte_pmd_mpipe_probe,
 };
 
-PMD_REGISTER_DRIVER(pmd_mpipe_xgbe_drv);
-PMD_REGISTER_DRIVER(pmd_mpipe_gbe_drv);
+RTE_PMD_REGISTER_VDEV(net_mpipe_xgbe, pmd_mpipe_xgbe_drv);
+RTE_PMD_REGISTER_ALIAS(net_mpipe_xgbe, xgbe);
+RTE_PMD_REGISTER_VDEV(net_mpipe_gbe, pmd_mpipe_gbe_drv);
+RTE_PMD_REGISTER_ALIAS(net_mpipe_gbe, gbe);
 
 static void __attribute__((constructor, used))
 mpipe_init_contexts(void)