net: align ethdev and eal driver names
[dpdk.git] / drivers / net / af_packet / rte_eth_af_packet.c
index 5544528..f670165 100644 (file)
@@ -40,7 +40,7 @@
 #include <rte_ethdev.h>
 #include <rte_malloc.h>
 #include <rte_kvargs.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 
 #include <linux/if_ether.h>
 #include <linux/if_packet.h>
@@ -78,6 +78,7 @@ struct pkt_rx_queue {
 
        volatile unsigned long rx_pkts;
        volatile unsigned long err_pkts;
+       volatile unsigned long rx_bytes;
 };
 
 struct pkt_tx_queue {
@@ -90,6 +91,7 @@ struct pkt_tx_queue {
 
        volatile unsigned long tx_pkts;
        volatile unsigned long err_pkts;
+       volatile unsigned long tx_bytes;
 };
 
 struct pmd_internals {
@@ -113,12 +115,11 @@ static const char *valid_arguments[] = {
        NULL
 };
 
-static const char *drivername = "AF_PACKET PMD";
-
 static struct rte_eth_link pmd_link = {
-       .link_speed = 10000,
+       .link_speed = ETH_SPEED_NUM_10G,
        .link_duplex = ETH_LINK_FULL_DUPLEX,
-       .link_status = 0
+       .link_status = ETH_LINK_DOWN,
+       .link_autoneg = ETH_LINK_SPEED_AUTONEG
 };
 
 static uint16_t
@@ -130,6 +131,7 @@ eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
        uint8_t *pbuf;
        struct pkt_rx_queue *pkt_q = queue;
        uint16_t num_rx = 0;
+       unsigned long num_rx_bytes = 0;
        unsigned int framecount, framenum;
 
        if (unlikely(nb_pkts == 0))
@@ -166,9 +168,11 @@ eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
                /* account for the receive frame */
                bufs[i] = mbuf;
                num_rx++;
+               num_rx_bytes += mbuf->pkt_len;
        }
        pkt_q->framenum = framenum;
        pkt_q->rx_pkts += num_rx;
+       pkt_q->rx_bytes += num_rx_bytes;
        return num_rx;
 }
 
@@ -185,6 +189,7 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
        struct pollfd pfd;
        struct pkt_tx_queue *pkt_q = queue;
        uint16_t num_tx = 0;
+       unsigned long num_tx_bytes = 0;
        int i;
 
        if (unlikely(nb_pkts == 0))
@@ -218,6 +223,7 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
                ppd = (struct tpacket2_hdr *) pkt_q->rd[framenum].iov_base;
 
                num_tx++;
+               num_tx_bytes += mbuf->pkt_len;
                rte_pktmbuf_free(mbuf);
        }
 
@@ -228,13 +234,14 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
        pkt_q->framenum = framenum;
        pkt_q->tx_pkts += num_tx;
        pkt_q->err_pkts += nb_pkts - num_tx;
+       pkt_q->tx_bytes += num_tx_bytes;
        return num_tx;
 }
 
 static int
 eth_dev_start(struct rte_eth_dev *dev)
 {
-       dev->data->dev_link.link_status = 1;
+       dev->data->dev_link.link_status = ETH_LINK_UP;
        return 0;
 }
 
@@ -257,7 +264,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
                        close(sockfd);
        }
 
-       dev->data->dev_link.link_status = 0;
+       dev->data->dev_link.link_status = ETH_LINK_DOWN;
 }
 
 static int
@@ -271,14 +278,12 @@ eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
        struct pmd_internals *internals = dev->data->dev_private;
 
-       dev_info->driver_name = drivername;
        dev_info->if_index = internals->if_index;
        dev_info->max_mac_addrs = 1;
        dev_info->max_rx_pktlen = (uint32_t)ETH_FRAME_LEN;
        dev_info->max_rx_queues = (uint16_t)internals->nb_queues;
        dev_info->max_tx_queues = (uint16_t)internals->nb_queues;
        dev_info->min_rx_bufsize = 0;
-       dev_info->pci_dev = NULL;
 }
 
 static void
@@ -286,13 +291,16 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats)
 {
        unsigned i, imax;
        unsigned long rx_total = 0, tx_total = 0, tx_err_total = 0;
+       unsigned long rx_bytes_total = 0, tx_bytes_total = 0;
        const struct pmd_internals *internal = dev->data->dev_private;
 
        imax = (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ?
                internal->nb_queues : RTE_ETHDEV_QUEUE_STAT_CNTRS);
        for (i = 0; i < imax; i++) {
                igb_stats->q_ipackets[i] = internal->rx_queue[i].rx_pkts;
+               igb_stats->q_ibytes[i] = internal->rx_queue[i].rx_bytes;
                rx_total += igb_stats->q_ipackets[i];
+               rx_bytes_total += igb_stats->q_ibytes[i];
        }
 
        imax = (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ?
@@ -300,13 +308,17 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats)
        for (i = 0; i < imax; i++) {
                igb_stats->q_opackets[i] = internal->tx_queue[i].tx_pkts;
                igb_stats->q_errors[i] = internal->tx_queue[i].err_pkts;
+               igb_stats->q_obytes[i] = internal->tx_queue[i].tx_bytes;
                tx_total += igb_stats->q_opackets[i];
                tx_err_total += igb_stats->q_errors[i];
+               tx_bytes_total += igb_stats->q_obytes[i];
        }
 
        igb_stats->ipackets = rx_total;
+       igb_stats->ibytes = rx_bytes_total;
        igb_stats->opackets = tx_total;
        igb_stats->oerrors = tx_err_total;
+       igb_stats->obytes = tx_bytes_total;
 }
 
 static void
@@ -315,12 +327,15 @@ eth_stats_reset(struct rte_eth_dev *dev)
        unsigned i;
        struct pmd_internals *internal = dev->data->dev_private;
 
-       for (i = 0; i < internal->nb_queues; i++)
+       for (i = 0; i < internal->nb_queues; i++) {
                internal->rx_queue[i].rx_pkts = 0;
+               internal->rx_queue[i].rx_bytes = 0;
+       }
 
        for (i = 0; i < internal->nb_queues; i++) {
                internal->tx_queue[i].tx_pkts = 0;
                internal->tx_queue[i].err_pkts = 0;
+               internal->tx_queue[i].tx_bytes = 0;
        }
 }
 
@@ -421,6 +436,8 @@ open_packet_iface(const char *key __rte_unused,
        return 0;
 }
 
+static struct rte_vdev_driver pmd_af_packet_drv;
+
 static int
 rte_pmd_init_internals(const char *name,
                        const int sockfd,
@@ -647,7 +664,7 @@ rte_pmd_init_internals(const char *name,
        }
 
        /* reserve an ethdev entry */
-       *eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+       *eth_dev = rte_eth_dev_allocate(name);
        if (*eth_dev == NULL)
                goto error;
 
@@ -674,7 +691,7 @@ rte_pmd_init_internals(const char *name,
        (*eth_dev)->dev_ops = &ops;
        (*eth_dev)->driver = NULL;
        (*eth_dev)->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
-       (*eth_dev)->data->drv_name = drivername;
+       (*eth_dev)->data->drv_name = pmd_af_packet_drv.driver.name;
        (*eth_dev)->data->kdrv = RTE_KDRV_NONE;
        (*eth_dev)->data->numa_node = numa_node;
 
@@ -801,7 +818,7 @@ rte_eth_from_packet(const char *name,
 }
 
 static int
-rte_pmd_af_packet_devinit(const char *name, const char *params)
+rte_pmd_af_packet_probe(const char *name, const char *params)
 {
        unsigned numa_node;
        int ret = 0;
@@ -839,7 +856,7 @@ exit:
 }
 
 static int
-rte_pmd_af_packet_devuninit(const char *name)
+rte_pmd_af_packet_remove(const char *name)
 {
        struct rte_eth_dev *eth_dev = NULL;
        struct pmd_internals *internals;
@@ -870,11 +887,16 @@ rte_pmd_af_packet_devuninit(const char *name)
        return 0;
 }
 
-static struct rte_driver pmd_af_packet_drv = {
-       .name = "eth_af_packet",
-       .type = PMD_VDEV,
-       .init = rte_pmd_af_packet_devinit,
-       .uninit = rte_pmd_af_packet_devuninit,
+static struct rte_vdev_driver pmd_af_packet_drv = {
+       .probe = rte_pmd_af_packet_probe,
+       .remove = rte_pmd_af_packet_remove,
 };
 
-PMD_REGISTER_DRIVER(pmd_af_packet_drv);
+RTE_PMD_REGISTER_VDEV(net_af_packet, pmd_af_packet_drv);
+RTE_PMD_REGISTER_ALIAS(net_af_packet, eth_af_packet);
+RTE_PMD_REGISTER_PARAM_STRING(net_af_packet,
+       "iface=<string> "
+       "qpairs=<int> "
+       "blocksz=<int> "
+       "framesz=<int> "
+       "framecnt=<int>");