return 0;
err:
- RTE_LOG(ERR, EAL, "Driver, cannot attach the device\n");
return -1;
}
struct rte_pci_addr freed_addr;
struct rte_pci_addr vp;
- /* check whether the driver supports detach feature, or not */
- if (rte_eth_dev_is_detachable(port_id))
- goto err;
-
/* get pci address by port id */
if (rte_eth_dev_get_addr_by_port(port_id, &freed_addr))
goto err;
*addr = freed_addr;
return 0;
err:
- RTE_LOG(ERR, EAL, "Driver, cannot detach the device\n");
return -1;
}
free(name);
free(args);
- if (ret < 0)
- RTE_LOG(ERR, EAL, "Driver, cannot attach the device\n");
return ret;
}
{
char name[RTE_ETH_NAME_MAX_LEN];
- /* check whether the driver supports detach feature, or not */
- if (rte_eth_dev_is_detachable(port_id))
- goto err;
-
/* get device name by port id */
if (rte_eth_dev_get_name_by_port(port_id, name))
goto err;
strncpy(vdevname, name, sizeof(name));
return 0;
err:
- RTE_LOG(ERR, EAL, "Driver, cannot detach the device\n");
return -1;
}
rte_eth_dev_attach(const char *devargs, uint8_t *port_id)
{
struct rte_pci_addr addr;
+ int ret = -1;
- if ((devargs == NULL) || (port_id == NULL))
- return -EINVAL;
+ if ((devargs == NULL) || (port_id == NULL)) {
+ ret = -EINVAL;
+ goto err;
+ }
- if (eal_parse_pci_DomBDF(devargs, &addr) == 0)
- return rte_eth_dev_attach_pdev(&addr, port_id);
- else
- return rte_eth_dev_attach_vdev(devargs, port_id);
+ if (eal_parse_pci_DomBDF(devargs, &addr) == 0) {
+ ret = rte_eth_dev_attach_pdev(&addr, port_id);
+ if (ret < 0)
+ goto err;
+ } else {
+ ret = rte_eth_dev_attach_vdev(devargs, port_id);
+ if (ret < 0)
+ goto err;
+ }
+
+ return 0;
+err:
+ RTE_LOG(ERR, EAL, "Driver, cannot attach the device\n");
+ return ret;
}
/* detach the device, then store the name of the device */
rte_eth_dev_detach(uint8_t port_id, char *name)
{
struct rte_pci_addr addr;
- int ret;
+ int ret = -1;
- if (name == NULL)
- return -EINVAL;
+ if (name == NULL) {
+ ret = -EINVAL;
+ goto err;
+ }
+
+ /* check whether the driver supports detach feature, or not */
+ if (rte_eth_dev_is_detachable(port_id))
+ goto err;
if (rte_eth_dev_get_device_type(port_id) == RTE_ETH_DEV_PCI) {
ret = rte_eth_dev_get_addr_by_port(port_id, &addr);
if (ret < 0)
- return ret;
+ goto err;
ret = rte_eth_dev_detach_pdev(port_id, &addr);
- if (ret == 0)
- snprintf(name, RTE_ETH_NAME_MAX_LEN,
- "%04x:%02x:%02x.%d",
- addr.domain, addr.bus,
- addr.devid, addr.function);
+ if (ret < 0)
+ goto err;
- return ret;
- } else
- return rte_eth_dev_detach_vdev(port_id, name);
+ snprintf(name, RTE_ETH_NAME_MAX_LEN,
+ "%04x:%02x:%02x.%d",
+ addr.domain, addr.bus,
+ addr.devid, addr.function);
+ } else {
+ ret = rte_eth_dev_detach_vdev(port_id, name);
+ if (ret < 0)
+ goto err;
+ }
+
+ return 0;
+
+err:
+ RTE_LOG(ERR, EAL, "Driver, cannot detach the device\n");
+ return ret;
}
static int
void **rxq;
unsigned i;
- if (dev->data->rx_queues == NULL) { /* first time configuration */
+ if (dev->data->rx_queues == NULL && nb_queues != 0) { /* first time configuration */
dev->data->rx_queues = rte_zmalloc("ethdev->rx_queues",
sizeof(dev->data->rx_queues[0]) * nb_queues,
RTE_CACHE_LINE_SIZE);
dev->data->nb_rx_queues = 0;
return -(ENOMEM);
}
- } else { /* re-configure */
+ } else if (dev->data->rx_queues != NULL && nb_queues != 0) { /* re-configure */
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, -ENOTSUP);
rxq = dev->data->rx_queues;
dev->data->rx_queues = rxq;
+ } else if (dev->data->rx_queues != NULL && nb_queues == 0) {
+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, -ENOTSUP);
+
+ rxq = dev->data->rx_queues;
+
+ for (i = nb_queues; i < old_nb_queues; i++)
+ (*dev->dev_ops->rx_queue_release)(rxq[i]);
}
dev->data->nb_rx_queues = nb_queues;
return 0;
{
struct rte_eth_dev *dev;
- /* This function is only safe when called from the primary process
- * in a multi-process setup*/
- RTE_PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
-
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
dev = &rte_eth_devices[port_id];
{
struct rte_eth_dev *dev;
- /* This function is only safe when called from the primary process
- * in a multi-process setup*/
- RTE_PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
-
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
dev = &rte_eth_devices[port_id];
{
struct rte_eth_dev *dev;
- /* This function is only safe when called from the primary process
- * in a multi-process setup*/
- RTE_PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
-
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
dev = &rte_eth_devices[port_id];
{
struct rte_eth_dev *dev;
- /* This function is only safe when called from the primary process
- * in a multi-process setup*/
- RTE_PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
-
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
dev = &rte_eth_devices[port_id];
void **txq;
unsigned i;
- if (dev->data->tx_queues == NULL) { /* first time configuration */
+ if (dev->data->tx_queues == NULL && nb_queues != 0) { /* first time configuration */
dev->data->tx_queues = rte_zmalloc("ethdev->tx_queues",
sizeof(dev->data->tx_queues[0]) * nb_queues,
RTE_CACHE_LINE_SIZE);
dev->data->nb_tx_queues = 0;
return -(ENOMEM);
}
- } else { /* re-configure */
+ } else if (dev->data->tx_queues != NULL && nb_queues != 0) { /* re-configure */
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release, -ENOTSUP);
txq = dev->data->tx_queues;
dev->data->tx_queues = txq;
+ } else if (dev->data->tx_queues != NULL && nb_queues == 0) {
+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release, -ENOTSUP);
+
+ txq = dev->data->tx_queues;
+
+ for (i = nb_queues; i < old_nb_queues; i++)
+ (*dev->dev_ops->tx_queue_release)(txq[i]);
}
dev->data->nb_tx_queues = nb_queues;
return 0;
struct rte_eth_dev_info dev_info;
int diag;
- /* This function is only safe when called from the primary process
- * in a multi-process setup*/
- RTE_PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
-
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
if (nb_rx_q > RTE_MAX_QUEUES_PER_PORT) {
* configured device.
*/
(*dev->dev_ops->dev_infos_get)(dev, &dev_info);
+
+ if (nb_rx_q == 0 && nb_tx_q == 0) {
+ RTE_PMD_DEBUG_TRACE("ethdev port_id=%d both rx and tx queue cannot be 0\n", port_id);
+ return -EINVAL;
+ }
+
if (nb_rx_q > dev_info.max_rx_queues) {
RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_queues=%d > %d\n",
port_id, nb_rx_q, dev_info.max_rx_queues);
return -EINVAL;
}
- if (nb_rx_q == 0) {
- RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_q == 0\n", port_id);
- return -EINVAL;
- }
if (nb_tx_q > dev_info.max_tx_queues) {
RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_queues=%d > %d\n",
port_id, nb_tx_q, dev_info.max_tx_queues);
return -EINVAL;
}
- if (nb_tx_q == 0) {
- RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_q == 0\n", port_id);
- return -EINVAL;
- }
/* Copy the dev_conf parameter into the dev structure */
memcpy(&dev->data->dev_conf, dev_conf, sizeof(dev->data->dev_conf));
struct rte_eth_dev *dev;
int diag;
- /* This function is only safe when called from the primary process
- * in a multi-process setup*/
- RTE_PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
-
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
dev = &rte_eth_devices[port_id];
{
struct rte_eth_dev *dev;
- /* This function is only safe when called from the primary process
- * in a multi-process setup*/
- RTE_PROC_PRIMARY_OR_RET();
-
RTE_ETH_VALID_PORTID_OR_RET(port_id);
dev = &rte_eth_devices[port_id];
{
struct rte_eth_dev *dev;
- /* This function is only safe when called from the primary process
- * in a multi-process setup*/
- RTE_PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
-
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
dev = &rte_eth_devices[port_id];
{
struct rte_eth_dev *dev;
- /* This function is only safe when called from the primary process
- * in a multi-process setup*/
- RTE_PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
-
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
dev = &rte_eth_devices[port_id];
{
struct rte_eth_dev *dev;
- /* This function is only safe when called from the primary process
- * in a multi-process setup*/
- RTE_PROC_PRIMARY_OR_RET();
-
RTE_ETH_VALID_PORTID_OR_RET(port_id);
dev = &rte_eth_devices[port_id];
struct rte_eth_dev *dev;
struct rte_eth_dev_info dev_info;
- /* This function is only safe when called from the primary process
- * in a multi-process setup*/
- RTE_PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
-
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
dev = &rte_eth_devices[port_id];
struct rte_eth_dev *dev;
struct rte_eth_dev_info dev_info;
- /* This function is only safe when called from the primary process
- * in a multi-process setup*/
- RTE_PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
-
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
dev = &rte_eth_devices[port_id];
socket_id, tx_conf);
}
+void
+rte_eth_tx_buffer_drop_callback(struct rte_mbuf **pkts, uint16_t unsent,
+ void *userdata __rte_unused)
+{
+ unsigned i;
+
+ for (i = 0; i < unsent; i++)
+ rte_pktmbuf_free(pkts[i]);
+}
+
+void
+rte_eth_tx_buffer_count_callback(struct rte_mbuf **pkts, uint16_t unsent,
+ void *userdata)
+{
+ uint64_t *count = userdata;
+ unsigned i;
+
+ for (i = 0; i < unsent; i++)
+ rte_pktmbuf_free(pkts[i]);
+
+ *count += unsent;
+}
+
+int
+rte_eth_tx_buffer_set_err_callback(struct rte_eth_dev_tx_buffer *buffer,
+ buffer_tx_error_fn cbfn, void *userdata)
+{
+ buffer->error_callback = cbfn;
+ buffer->error_userdata = userdata;
+ return 0;
+}
+
+int
+rte_eth_tx_buffer_init(struct rte_eth_dev_tx_buffer *buffer, uint16_t size)
+{
+ if (buffer == NULL)
+ return -EINVAL;
+
+ buffer->size = size;
+ if (buffer->error_callback == NULL)
+ rte_eth_tx_buffer_set_err_callback(buffer,
+ rte_eth_tx_buffer_drop_callback, NULL);
+
+ return 0;
+}
+
void
rte_eth_promiscuous_enable(uint8_t port_id)
{
}
int
-rte_eth_dev_set_vlan_ether_type(uint8_t port_id, uint16_t tpid)
+rte_eth_dev_set_vlan_ether_type(uint8_t port_id,
+ enum rte_vlan_type vlan_type,
+ uint16_t tpid)
{
struct rte_eth_dev *dev;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
dev = &rte_eth_devices[port_id];
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_tpid_set, -ENOTSUP);
- (*dev->dev_ops->vlan_tpid_set)(dev, tpid);
- return 0;
+ return (*dev->dev_ops->vlan_tpid_set)(dev, vlan_type, tpid);
}
int
static int
rte_eth_check_reta_entry(struct rte_eth_rss_reta_entry64 *reta_conf,
uint16_t reta_size,
- uint8_t max_rxq)
+ uint16_t max_rxq)
{
uint16_t i, idx, shift;
/* create a new callback. */
if (user_cb == NULL)
user_cb = rte_zmalloc("INTR_USER_CALLBACK",
- sizeof(struct rte_eth_dev_callback), 0);
+ sizeof(struct rte_eth_dev_callback), 0);
if (user_cb != NULL) {
user_cb->cb_fn = cb_fn;
user_cb->cb_arg = cb_arg;