static int mvneta_dev_num;
-static void mvneta_stats_reset(struct rte_eth_dev *dev);
+static int mvneta_stats_reset(struct rte_eth_dev *dev);
+static int rte_pmd_mvneta_remove(struct rte_vdev_device *vdev);
+
/**
* Deinitialize packet processor.
* @param info
* Info structure output buffer.
*/
-static void
+static int
mvneta_dev_infos_get(struct rte_eth_dev *dev __rte_unused,
struct rte_eth_dev_info *info)
{
info->default_txconf.offloads = 0;
info->max_rx_pktlen = MVNETA_PKT_SIZE_MAX;
+
+ return 0;
}
/**
mvneta_tx_queue_release(dev->data->tx_queues[i]);
dev->data->tx_queues[i] = NULL;
}
+
+ mvneta_dev_num--;
+
+ if (mvneta_dev_num == 0) {
+ MVNETA_LOG(INFO, "Perform MUSDK deinit");
+ mvneta_neta_deinit();
+ rte_mvep_deinit(MVEP_MOD_T_NETA);
+ }
}
/**
*
* @param dev
* Pointer to Ethernet device structure.
+ *
+ * @return
+ * always 0
*/
-static void
+static int
mvneta_promiscuous_enable(struct rte_eth_dev *dev)
{
struct mvneta_priv *priv = dev->data->dev_private;
int ret, en;
if (!priv->ppio)
- return;
+ return 0;
neta_ppio_get_promisc(priv->ppio, &en);
if (en) {
MVNETA_LOG(INFO, "Promiscuous already enabled");
- return;
+ return 0;
}
ret = neta_ppio_set_promisc(priv->ppio, 1);
if (ret)
MVNETA_LOG(ERR, "Failed to enable promiscuous mode");
+
+ return 0;
}
/**
*
* @param dev
* Pointer to Ethernet device structure.
+ *
+ * @return
+ * always 0
*/
-static void
+static int
mvneta_promiscuous_disable(struct rte_eth_dev *dev)
{
struct mvneta_priv *priv = dev->data->dev_private;
int ret, en;
if (!priv->ppio)
- return;
+ return 0;
neta_ppio_get_promisc(priv->ppio, &en);
if (!en) {
MVNETA_LOG(INFO, "Promiscuous already disabled");
- return;
+ return 0;
}
ret = neta_ppio_set_promisc(priv->ppio, 0);
if (ret)
MVNETA_LOG(ERR, "Failed to disable promiscuous mode");
+
+ return 0;
}
/**
*
* @param dev
* Pointer to Ethernet device structure.
+ *
+ * @return
+ * 0 on success, negative error value otherwise.
*/
-static void
+static int
mvneta_stats_reset(struct rte_eth_dev *dev)
{
struct mvneta_priv *priv = dev->data->dev_private;
unsigned int ret;
if (!priv->ppio)
- return;
+ return 0;
ret = mvneta_stats_get(dev, &priv->prev_stats);
if (unlikely(ret))
- RTE_LOG(ERR, PMD, "Failed to reset port statistics");
+ MVNETA_LOG(ERR, "Failed to reset port statistics");
+
+ return ret;
}
mvneta_set_tx_function(eth_dev);
eth_dev->dev_ops = &mvneta_ops;
+ /* Flag to call rte_eth_dev_release_port() in rte_eth_dev_close(). */
+ eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
+
rte_eth_dev_probing_finish(eth_dev);
return 0;
out_free:
ret = mvneta_eth_dev_create(vdev, ifnames.names[i]);
if (ret)
goto out_cleanup;
+
+ mvneta_dev_num++;
}
- mvneta_dev_num += ifnum;
rte_kvargs_free(kvlist);
return 0;
out_cleanup:
- for (; i > 0; i--)
- mvneta_eth_dev_destroy_name(ifnames.names[i]);
+ rte_pmd_mvneta_remove(vdev);
- if (mvneta_dev_num == 0) {
- mvneta_neta_deinit();
- rte_mvep_deinit(MVEP_MOD_T_NETA);
- }
out_free_kvlist:
rte_kvargs_free(kvlist);
static int
rte_pmd_mvneta_remove(struct rte_vdev_device *vdev)
{
- int i;
- const char *name;
-
- name = rte_vdev_device_name(vdev);
- if (!name)
- return -EINVAL;
-
- MVNETA_LOG(INFO, "Removing %s", name);
+ uint16_t port_id;
- RTE_ETH_FOREACH_DEV(i) {
- if (rte_eth_devices[i].device != &vdev->device)
+ RTE_ETH_FOREACH_DEV(port_id) {
+ if (rte_eth_devices[port_id].device != &vdev->device)
continue;
-
- mvneta_eth_dev_destroy(&rte_eth_devices[i]);
- mvneta_dev_num--;
- }
-
- if (mvneta_dev_num == 0) {
- MVNETA_LOG(INFO, "Perform MUSDK deinit");
- mvneta_neta_deinit();
- rte_mvep_deinit(MVEP_MOD_T_NETA);
+ rte_eth_dev_close(port_id);
}
return 0;