X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_ether%2Frte_ethdev.c;h=5208badf679dc70f0c6ccbbd465ea5b68bbf7b9f;hb=ef7d28668505a04afe0f93f097f58614679c0f9f;hp=7a546005f96490d7744f8b0feb151253fe73e80d;hpb=92d94d3744d7760d8d5e490be810612cf4a9cfb0;p=dpdk.git diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 7a546005f9..5208badf67 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -52,7 +52,6 @@ #include #include #include -#include #include #include #include @@ -324,7 +323,7 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv, eth_dev->data->mtu = ETHER_MTU; /* Invoke PMD device initialization function */ - diag = (*eth_drv->eth_dev_init)(eth_drv, eth_dev); + diag = (*eth_drv->eth_dev_init)(eth_dev); if (diag == 0) return (0); @@ -362,7 +361,7 @@ rte_eth_dev_uninit(struct rte_pci_device *pci_dev) /* Invoke PMD device uninit function */ if (*eth_drv->eth_dev_uninit) { - ret = (*eth_drv->eth_dev_uninit)(eth_drv, eth_dev); + ret = (*eth_drv->eth_dev_uninit)(eth_dev); if (ret) return ret; } @@ -426,11 +425,14 @@ rte_eth_dev_count(void) return (nb_ports); } +/* So far, DPDK hotplug function only supports linux */ +#ifdef RTE_LIBRTE_EAL_HOTPLUG + static enum rte_eth_dev_type rte_eth_dev_get_device_type(uint8_t port_id) { if (!rte_eth_dev_is_valid_port(port_id)) - return -1; + return RTE_ETH_DEV_UNKNOWN; return rte_eth_devices[port_id].dev_type; } @@ -524,8 +526,6 @@ rte_eth_dev_is_detachable(uint8_t port_id) return !(drv_flags & RTE_PCI_DRV_DETACHABLE); } -/* So far, DPDK hotplug function only supports linux */ -#ifdef RTE_LIBRTE_EAL_HOTPLUG /* attach the new physical device, then store port_id of the device */ static int rte_eth_dev_attach_pdev(struct rte_pci_addr *addr, uint8_t *port_id) @@ -741,19 +741,6 @@ rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues) dev->data->nb_rx_queues = 0; return -(ENOMEM); } -#ifdef RTE_ETHDEV_RXTX_CALLBACKS - dev->post_rx_burst_cbs = rte_zmalloc( - "ethdev->post_rx_burst_cbs", - sizeof(*dev->post_rx_burst_cbs) * nb_queues, - RTE_CACHE_LINE_SIZE); - if (dev->post_rx_burst_cbs == NULL) { - rte_free(dev->data->rx_queues); - dev->data->rx_queues = NULL; - dev->data->nb_rx_queues = 0; - return -ENOMEM; - } -#endif - } else { /* re-configure */ FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, -ENOTSUP); @@ -765,22 +752,10 @@ rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues) RTE_CACHE_LINE_SIZE); if (rxq == NULL) return -(ENOMEM); -#ifdef RTE_ETHDEV_RXTX_CALLBACKS - dev->post_rx_burst_cbs = rte_realloc( - dev->post_rx_burst_cbs, - sizeof(*dev->post_rx_burst_cbs) * - nb_queues, RTE_CACHE_LINE_SIZE); - if (dev->post_rx_burst_cbs == NULL) - return -ENOMEM; -#endif if (nb_queues > old_nb_queues) { uint16_t new_qs = nb_queues - old_nb_queues; memset(rxq + old_nb_queues, 0, sizeof(rxq[0]) * new_qs); -#ifdef RTE_ETHDEV_RXTX_CALLBACKS - memset(dev->post_rx_burst_cbs + old_nb_queues, 0, - sizeof(dev->post_rx_burst_cbs[0]) * new_qs); -#endif } dev->data->rx_queues = rxq; @@ -909,19 +884,6 @@ rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues) dev->data->nb_tx_queues = 0; return -(ENOMEM); } -#ifdef RTE_ETHDEV_RXTX_CALLBACKS - dev->pre_tx_burst_cbs = rte_zmalloc( - "ethdev->pre_tx_burst_cbs", - sizeof(*dev->pre_tx_burst_cbs) * nb_queues, - RTE_CACHE_LINE_SIZE); - if (dev->pre_tx_burst_cbs == NULL) { - rte_free(dev->data->tx_queues); - dev->data->tx_queues = NULL; - dev->data->nb_tx_queues = 0; - return -ENOMEM; - } -#endif - } else { /* re-configure */ FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release, -ENOTSUP); @@ -933,22 +895,10 @@ rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues) RTE_CACHE_LINE_SIZE); if (txq == NULL) return -ENOMEM; -#ifdef RTE_ETHDEV_RXTX_CALLBACKS - dev->pre_tx_burst_cbs = rte_realloc( - dev->pre_tx_burst_cbs, - sizeof(*dev->pre_tx_burst_cbs) * - nb_queues, RTE_CACHE_LINE_SIZE); - if (dev->pre_tx_burst_cbs == NULL) - return -ENOMEM; -#endif if (nb_queues > old_nb_queues) { uint16_t new_qs = nb_queues - old_nb_queues; memset(txq + old_nb_queues, 0, sizeof(txq[0]) * new_qs); -#ifdef RTE_ETHDEV_RXTX_CALLBACKS - memset(dev->pre_tx_burst_cbs + old_nb_queues, 0, - sizeof(dev->pre_tx_burst_cbs[0]) * new_qs); -#endif } dev->data->tx_queues = txq; @@ -1164,6 +1114,20 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, return (-EINVAL); } + if (nb_rx_q > RTE_MAX_QUEUES_PER_PORT) { + PMD_DEBUG_TRACE( + "Number of RX queues requested (%u) is greater than max supported(%d)\n", + nb_rx_q, RTE_MAX_QUEUES_PER_PORT); + return (-EINVAL); + } + + if (nb_tx_q > RTE_MAX_QUEUES_PER_PORT) { + PMD_DEBUG_TRACE( + "Number of TX queues requested (%u) is greater than max supported(%d)\n", + nb_tx_q, RTE_MAX_QUEUES_PER_PORT); + return (-EINVAL); + } + dev = &rte_eth_devices[port_id]; FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP); @@ -2001,8 +1965,8 @@ rte_eth_dev_vlan_filter(uint8_t port_id, uint16_t vlan_id, int on) return (-EINVAL); } FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_filter_set, -ENOTSUP); - (*dev->dev_ops->vlan_filter_set)(dev, vlan_id, on); - return (0); + + return (*dev->dev_ops->vlan_filter_set)(dev, vlan_id, on); } int @@ -3533,14 +3497,14 @@ rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type, void * rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id, - rte_rxtx_callback_fn fn, void *user_param) + rte_rx_callback_fn fn, void *user_param) { #ifndef RTE_ETHDEV_RXTX_CALLBACKS rte_errno = ENOTSUP; return NULL; #endif /* check input parameters */ - if (port_id >= nb_ports || fn == NULL || + if (!rte_eth_dev_is_valid_port(port_id) || fn == NULL || queue_id >= rte_eth_devices[port_id].data->nb_rx_queues) { rte_errno = EINVAL; return NULL; @@ -3553,7 +3517,7 @@ rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id, return NULL; } - cb->fn = fn; + cb->fn.rx = fn; cb->param = user_param; cb->next = rte_eth_devices[port_id].post_rx_burst_cbs[queue_id]; rte_eth_devices[port_id].post_rx_burst_cbs[queue_id] = cb; @@ -3562,14 +3526,14 @@ rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id, void * rte_eth_add_tx_callback(uint8_t port_id, uint16_t queue_id, - rte_rxtx_callback_fn fn, void *user_param) + rte_tx_callback_fn fn, void *user_param) { #ifndef RTE_ETHDEV_RXTX_CALLBACKS rte_errno = ENOTSUP; return NULL; #endif /* check input parameters */ - if (port_id >= nb_ports || fn == NULL || + if (!rte_eth_dev_is_valid_port(port_id) || fn == NULL || queue_id >= rte_eth_devices[port_id].data->nb_tx_queues) { rte_errno = EINVAL; return NULL; @@ -3582,7 +3546,7 @@ rte_eth_add_tx_callback(uint8_t port_id, uint16_t queue_id, return NULL; } - cb->fn = fn; + cb->fn.tx = fn; cb->param = user_param; cb->next = rte_eth_devices[port_id].pre_tx_burst_cbs[queue_id]; rte_eth_devices[port_id].pre_tx_burst_cbs[queue_id] = cb; @@ -3597,7 +3561,7 @@ rte_eth_remove_rx_callback(uint8_t port_id, uint16_t queue_id, return (-ENOTSUP); #endif /* Check input parameters. */ - if (port_id >= nb_ports || user_cb == NULL || + if (!rte_eth_dev_is_valid_port(port_id) || user_cb == NULL || queue_id >= rte_eth_devices[port_id].data->nb_rx_queues) { return (-EINVAL); } @@ -3636,7 +3600,7 @@ rte_eth_remove_tx_callback(uint8_t port_id, uint16_t queue_id, return (-ENOTSUP); #endif /* Check input parameters. */ - if (port_id >= nb_ports || user_cb == NULL || + if (!rte_eth_dev_is_valid_port(port_id) || user_cb == NULL || queue_id >= rte_eth_devices[port_id].data->nb_tx_queues) { return (-EINVAL); }