git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
drivers: use vdev registration
[dpdk.git]
/
drivers
/
net
/
xenvirt
/
rte_eth_xenvirt.c
diff --git
a/drivers/net/xenvirt/rte_eth_xenvirt.c
b/drivers/net/xenvirt/rte_eth_xenvirt.c
index
191a91c
..
605aba9
100644
(file)
--- a/
drivers/net/xenvirt/rte_eth_xenvirt.c
+++ b/
drivers/net/xenvirt/rte_eth_xenvirt.c
@@
-1,7
+1,7
@@
/*-
* BSD LICENSE
*
/*-
* BSD LICENSE
*
- * Copyright(c) 2010-201
4
Intel Corporation. All rights reserved.
+ * Copyright(c) 2010-201
5
Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@
-39,6
+39,9
@@
#include <sys/mman.h>
#include <errno.h>
#include <sys/user.h>
#include <sys/mman.h>
#include <errno.h>
#include <sys/user.h>
+#ifndef PAGE_SIZE
+#define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
+#endif
#include <linux/binfmts.h>
#include <xen/xen-compat.h>
#if __XEN_LATEST_INTERFACE_VERSION__ < 0x00040200
#include <linux/binfmts.h>
#include <xen/xen-compat.h>
#if __XEN_LATEST_INTERFACE_VERSION__ < 0x00040200
@@
-53,7
+56,7
@@
#include <rte_malloc.h>
#include <rte_memcpy.h>
#include <rte_string_fns.h>
#include <rte_malloc.h>
#include <rte_memcpy.h>
#include <rte_string_fns.h>
-#include <rte_dev.h>
+#include <rte_
v
dev.h>
#include <cmdline_parse.h>
#include <cmdline_parse_etheraddr.h>
#include <cmdline_parse.h>
#include <cmdline_parse_etheraddr.h>
@@
-67,25
+70,17
@@
/* virtio_idx is increased after new device is created.*/
static int virtio_idx = 0;
/* virtio_idx is increased after new device is created.*/
static int virtio_idx = 0;
-static const char *drivername = "xen
dummy
virtio PMD";
+static const char *drivername = "xen virtio PMD";
static struct rte_eth_link pmd_link = {
static struct rte_eth_link pmd_link = {
- .link_speed =
10000
,
+ .link_speed =
ETH_SPEED_NUM_10G
,
.link_duplex = ETH_LINK_FULL_DUPLEX,
.link_duplex = ETH_LINK_FULL_DUPLEX,
- .link_status = 0
+ .link_status = ETH_LINK_DOWN,
+ .link_autoneg = ETH_LINK_SPEED_FIXED
};
};
-static inline struct rte_mbuf *
-rte_rxmbuf_alloc(struct rte_mempool *mp)
-{
- struct rte_mbuf *m;
-
- m = __rte_mbuf_raw_alloc(mp);
- __rte_mbuf_sanity_check_raw(m, 0);
-
- return m;
-}
-
+static void
+eth_xenvirt_free_queues(struct rte_eth_dev *dev);
static uint16_t
eth_xenvirt_rx(void *q, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
static uint16_t
eth_xenvirt_rx(void *q, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
@@
-99,7
+94,7
@@
eth_xenvirt_rx(void *q, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
nb_used = VIRTQUEUE_NUSED(rxvq);
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;
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;
@@
-118,7
+113,7
@@
eth_xenvirt_rx(void *q, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
}
/* allocate new mbuf for the used descriptor */
while (likely(!virtqueue_full(rxvq))) {
}
/* allocate new mbuf for the used descriptor */
while (likely(!virtqueue_full(rxvq))) {
- new_mbuf = rte_
rxmbuf
_alloc(rxvq->mpool);
+ new_mbuf = rte_
mbuf_raw
_alloc(rxvq->mpool);
if (unlikely(new_mbuf == NULL)) {
break;
}
if (unlikely(new_mbuf == NULL)) {
break;
}
@@
-150,7
+145,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);
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);
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);
@@
-287,9
+282,9
@@
eth_dev_start(struct rte_eth_dev *dev)
struct pmd_internals *pi = (struct pmd_internals *)dev->data->dev_private;
int rv;
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)) {
while (!virtqueue_full(rxvq)) {
- m = rte_
rxmbuf
_alloc(rxvq->mpool);
+ m = rte_
mbuf_raw
_alloc(rxvq->mpool);
if (m == NULL)
break;
/* Enqueue allocated buffers. */
if (m == NULL)
break;
/* Enqueue allocated buffers. */
@@
-315,7
+310,7
@@
eth_dev_stop(struct rte_eth_dev *dev)
{
struct pmd_internals *pi = (struct pmd_internals *)dev->data->dev_private;
{
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);
}
dev_stop_notify(pi->virtio_idx);
}
@@
-326,7
+321,7
@@
eth_dev_stop(struct rte_eth_dev *dev)
static void
eth_dev_close(struct rte_eth_dev *dev)
{
static void
eth_dev_close(struct rte_eth_dev *dev)
{
-
RTE_SET_USED
(dev);
+
eth_xenvirt_free_queues
(dev);
}
static void
}
static void
@@
-362,8
+357,9
@@
eth_stats_reset(struct rte_eth_dev *dev)
}
static void
}
static void
-eth_queue_release(void *q
__rte_unused
)
+eth_queue_release(void *q)
{
{
+ rte_free(q);
}
static int
}
static int
@@
-427,10
+423,8
@@
gntalloc_vring_create(int queue_type, uint32_t size, int vtidx)
va = NULL;
}
out:
va = NULL;
}
out:
- if (pa_arr)
- free(pa_arr);
- if (gref_arr)
- free(gref_arr);
+ free(pa_arr);
+ free(gref_arr);
return va;
}
return va;
}
@@
-524,7
+518,23
@@
eth_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
return 0;
}
return 0;
}
+static void
+eth_xenvirt_free_queues(struct rte_eth_dev *dev)
+{
+ int i;
+
+ for (i = 0; i < dev->data->nb_rx_queues; i++) {
+ eth_queue_release(dev->data->rx_queues[i]);
+ dev->data->rx_queues[i] = NULL;
+ }
+ dev->data->nb_rx_queues = 0;
+ for (i = 0; i < dev->data->nb_tx_queues; i++) {
+ eth_queue_release(dev->data->tx_queues[i]);
+ dev->data->tx_queues[i] = NULL;
+ }
+ dev->data->nb_tx_queues = 0;
+}
static const struct eth_dev_ops ops = {
.dev_start = eth_dev_start,
static const struct eth_dev_ops ops = {
.dev_start = eth_dev_start,
@@
-617,11
+627,11
@@
eth_dev_xenvirt_create(const char *name, const char *params,
enum dev_action action)
{
struct rte_eth_dev_data *data = NULL;
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;
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);
RTE_LOG(INFO, PMD, "Creating virtio rings backed ethdev on numa socket %u\n",
numa_node);
@@
-639,21
+649,15
@@
eth_dev_xenvirt_create(const char *name, const char *params,
if (data == NULL)
goto err;
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;
/* reserve an ethdev entry */
internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node);
if (internals == NULL)
goto err;
/* 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 err;
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;
data->dev_private = internals;
data->port_id = eth_dev->data->port_id;
data->nb_rx_queues = (uint16_t)1;
@@
-668,8
+672,12
@@
eth_dev_xenvirt_create(const char *name, const char *params,
eth_dev->data = data;
eth_dev->dev_ops = &ops;
eth_dev->data = data;
eth_dev->dev_ops = &ops;
+
eth_dev->data->dev_flags = RTE_PCI_DRV_DETACHABLE;
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;
+ eth_dev->data->numa_node = numa_node;
eth_dev->rx_pkt_burst = eth_xenvirt_rx;
eth_dev->tx_pkt_burst = eth_xenvirt_tx;
eth_dev->rx_pkt_burst = eth_xenvirt_rx;
eth_dev->tx_pkt_burst = eth_xenvirt_tx;
@@
-681,7
+689,6
@@
eth_dev_xenvirt_create(const char *name, const char *params,
err:
rte_free(data);
err:
rte_free(data);
- rte_free(pci_dev);
rte_free(internals);
return -1;
rte_free(internals);
return -1;
@@
-752,11
+759,14
@@
rte_pmd_xenvirt_devuninit(const char *name)
return 0;
}
return 0;
}
-static struct rte_driver pmd_xenvirt_drv = {
- .name = "eth_xenvirt",
- .type = PMD_VDEV,
+static struct rte_vdev_driver pmd_xenvirt_drv = {
+ .driver = {
+ .type = PMD_VDEV,
+ },
.init = rte_pmd_xenvirt_devinit,
.uninit = rte_pmd_xenvirt_devuninit,
};
.init = rte_pmd_xenvirt_devinit,
.uninit = rte_pmd_xenvirt_devuninit,
};
-PMD_REGISTER_DRIVER(pmd_xenvirt_drv);
+DRIVER_REGISTER_VDEV(net_xenvirt, pmd_xenvirt_drv);
+DRIVER_REGISTER_PARAM_STRING(net_xenvirt,
+ "mac=<mac addr>");