X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fxenvirt%2Frte_eth_xenvirt.c;h=e404b775546fb60b09b469922b18cf02ca5a6765;hb=bce6c42c4ad5;hp=e83c08c3835ab43f6a1c815958013d22dc6b58a0;hpb=4c02e453cc6272e20c3a901b7afb6f49ec08f1b3;p=dpdk.git diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c b/drivers/net/xenvirt/rte_eth_xenvirt.c index e83c08c383..e404b77554 100644 --- a/drivers/net/xenvirt/rte_eth_xenvirt.c +++ b/drivers/net/xenvirt/rte_eth_xenvirt.c @@ -39,6 +39,9 @@ #include #include #include +#ifndef PAGE_SIZE +#define PAGE_SIZE sysconf(_SC_PAGE_SIZE) +#endif #include #include #if __XEN_LATEST_INTERFACE_VERSION__ < 0x00040200 @@ -53,7 +56,7 @@ #include #include #include -#include +#include #include #include @@ -67,29 +70,16 @@ /* virtio_idx is increased after new device is created.*/ static int virtio_idx = 0; -static const char *drivername = "xen virtio 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_FIXED }; static void eth_xenvirt_free_queues(struct rte_eth_dev *dev); -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 uint16_t eth_xenvirt_rx(void *q, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) { @@ -121,7 +111,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))) { - new_mbuf = rte_rxmbuf_alloc(rxvq->mpool); + new_mbuf = rte_mbuf_raw_alloc(rxvq->mpool); if (unlikely(new_mbuf == NULL)) { break; } @@ -290,9 +280,9 @@ 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); + m = rte_mbuf_raw_alloc(rxvq->mpool); if (m == NULL) break; /* Enqueue allocated buffers. */ @@ -318,7 +308,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); } @@ -339,13 +329,11 @@ eth_dev_info(struct rte_eth_dev *dev, struct pmd_internals *internals = dev->data->dev_private; RTE_SET_USED(internals); - dev_info->driver_name = drivername; dev_info->max_mac_addrs = 1; dev_info->max_rx_pktlen = (uint32_t)2048; dev_info->max_rx_queues = (uint16_t)1; dev_info->max_tx_queues = (uint16_t)1; dev_info->min_rx_bufsize = 0; - dev_info->pci_dev = NULL; } static void @@ -431,10 +419,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; } @@ -630,6 +616,7 @@ enum dev_action { DEV_ATTACH }; +static struct rte_vdev_driver pmd_xenvirt_drv; static int eth_dev_xenvirt_create(const char *name, const char *params, @@ -640,7 +627,8 @@ eth_dev_xenvirt_create(const char *name, const char *params, 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); @@ -663,7 +651,7 @@ eth_dev_xenvirt_create(const char *name, const char *params, 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; @@ -682,10 +670,8 @@ eth_dev_xenvirt_create(const char *name, const char *params, eth_dev->data = data; eth_dev->dev_ops = &ops; - eth_dev->data->dev_flags = RTE_PCI_DRV_DETACHABLE; + eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE; 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; @@ -738,7 +724,7 @@ eth_dev_xenvirt_free(const char *name, const unsigned numa_node) /*TODO: Support multiple process model */ static int -rte_pmd_xenvirt_devinit(const char *name, const char *params) +rte_pmd_xenvirt_probe(struct rte_vdev_device *dev) { if (virtio_idx == 0) { if (xenstore_init() != 0) { @@ -750,14 +736,15 @@ rte_pmd_xenvirt_devinit(const char *name, const char *params) return -1; } } - eth_dev_xenvirt_create(name, params, rte_socket_id(), DEV_CREATE); + eth_dev_xenvirt_create(rte_vdev_device_name(dev), + rte_vdev_device_args(dev), rte_socket_id(), DEV_CREATE); return 0; } static int -rte_pmd_xenvirt_devuninit(const char *name) +rte_pmd_xenvirt_remove(struct rte_vdev_device *dev) { - eth_dev_xenvirt_free(name, rte_socket_id()); + eth_dev_xenvirt_free(rte_vdev_device_name(dev), rte_socket_id()); if (virtio_idx == 0) { if (xenstore_uninit() != 0) @@ -768,11 +755,12 @@ rte_pmd_xenvirt_devuninit(const char *name) return 0; } -static struct rte_driver pmd_xenvirt_drv = { - .name = "eth_xenvirt", - .type = PMD_VDEV, - .init = rte_pmd_xenvirt_devinit, - .uninit = rte_pmd_xenvirt_devuninit, +static struct rte_vdev_driver pmd_xenvirt_drv = { + .probe = rte_pmd_xenvirt_probe, + .remove = rte_pmd_xenvirt_remove, }; -PMD_REGISTER_DRIVER(pmd_xenvirt_drv); +RTE_PMD_REGISTER_VDEV(net_xenvirt, pmd_xenvirt_drv); +RTE_PMD_REGISTER_ALIAS(net_xenvirt, eth_xenvirt); +RTE_PMD_REGISTER_PARAM_STRING(net_xenvirt, + "mac=");