net/mvpp2: remove resources when port is closed
Since 18.11, it is suggested that driver should release all its private resources at the dev_close routine. So all resources previously released in remove routine are now released at the dev_close routine, and the dev_close routine will be called in driver remove routine in order to support removing a device without closing its ports. Above behavior changes are supported by setting RTE_ETH_DEV_CLOSE_REMOVE flag during probe stage. Signed-off-by: Liron Himi <lironh@marvell.com> Reviewed-by: Yuri Chipchev <yuric@marvell.com>
This commit is contained in:
parent
230dce6461
commit
696202ca53
@ -144,6 +144,9 @@ static uint16_t mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts,
|
||||
uint16_t nb_pkts);
|
||||
static uint16_t mrvl_tx_sg_pkt_burst(void *txq, struct rte_mbuf **tx_pkts,
|
||||
uint16_t nb_pkts);
|
||||
static int rte_pmd_mrvl_remove(struct rte_vdev_device *vdev);
|
||||
static void mrvl_deinit_pp2(void);
|
||||
static void mrvl_deinit_hifs(void);
|
||||
|
||||
|
||||
#define MRVL_XSTATS_TBL_ENTRY(name) { \
|
||||
@ -898,6 +901,22 @@ mrvl_dev_close(struct rte_eth_dev *dev)
|
||||
pp2_cls_plcr_deinit(priv->default_policer);
|
||||
priv->default_policer = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (priv->bpool) {
|
||||
pp2_bpool_deinit(priv->bpool);
|
||||
used_bpools[priv->pp_id] &= ~(1 << priv->bpool_bit);
|
||||
priv->bpool = NULL;
|
||||
}
|
||||
|
||||
mrvl_dev_num--;
|
||||
|
||||
if (mrvl_dev_num == 0) {
|
||||
MRVL_LOG(INFO, "Perform MUSDK deinit");
|
||||
mrvl_deinit_hifs();
|
||||
mrvl_deinit_pp2();
|
||||
rte_mvep_deinit(MVEP_MOD_T_PP2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2809,6 +2828,9 @@ mrvl_eth_dev_create(struct rte_vdev_device *vdev, const char *name)
|
||||
mrvl_set_tx_function(eth_dev);
|
||||
eth_dev->dev_ops = &mrvl_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:
|
||||
@ -2817,28 +2839,6 @@ mrvl_eth_dev_create(struct rte_vdev_device *vdev, const char *name)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup previously created device representing Ethernet port.
|
||||
*
|
||||
* @param name
|
||||
* Pointer to the port name.
|
||||
*/
|
||||
static void
|
||||
mrvl_eth_dev_destroy(const char *name)
|
||||
{
|
||||
struct rte_eth_dev *eth_dev;
|
||||
struct mrvl_priv *priv;
|
||||
|
||||
eth_dev = rte_eth_dev_allocated(name);
|
||||
if (!eth_dev)
|
||||
return;
|
||||
|
||||
priv = eth_dev->data->dev_private;
|
||||
pp2_bpool_deinit(priv->bpool);
|
||||
used_bpools[priv->pp_id] &= ~(1 << priv->bpool_bit);
|
||||
rte_eth_dev_release_port(eth_dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback used by rte_kvargs_process() during argument parsing.
|
||||
*
|
||||
@ -2959,20 +2959,15 @@ rte_pmd_mrvl_probe(struct rte_vdev_device *vdev)
|
||||
ret = mrvl_eth_dev_create(vdev, ifnames.names[i]);
|
||||
if (ret)
|
||||
goto out_cleanup;
|
||||
mrvl_dev_num++;
|
||||
}
|
||||
mrvl_dev_num += ifnum;
|
||||
|
||||
rte_kvargs_free(kvlist);
|
||||
|
||||
return 0;
|
||||
out_cleanup:
|
||||
for (; i > 0; i--)
|
||||
mrvl_eth_dev_destroy(ifnames.names[i]);
|
||||
rte_pmd_mrvl_remove(vdev);
|
||||
|
||||
if (mrvl_dev_num == 0) {
|
||||
mrvl_deinit_pp2();
|
||||
rte_mvep_deinit(MVEP_MOD_T_PP2);
|
||||
}
|
||||
out_free_kvlist:
|
||||
rte_kvargs_free(kvlist);
|
||||
|
||||
@ -2991,28 +2986,12 @@ rte_pmd_mrvl_probe(struct rte_vdev_device *vdev)
|
||||
static int
|
||||
rte_pmd_mrvl_remove(struct rte_vdev_device *vdev)
|
||||
{
|
||||
int i;
|
||||
const char *name;
|
||||
uint16_t port_id;
|
||||
|
||||
name = rte_vdev_device_name(vdev);
|
||||
if (!name)
|
||||
return -EINVAL;
|
||||
|
||||
MRVL_LOG(INFO, "Removing %s", name);
|
||||
|
||||
RTE_ETH_FOREACH_DEV(i) { /* FIXME: removing all devices! */
|
||||
char ifname[RTE_ETH_NAME_MAX_LEN];
|
||||
|
||||
rte_eth_dev_get_name_by_port(i, ifname);
|
||||
mrvl_eth_dev_destroy(ifname);
|
||||
mrvl_dev_num--;
|
||||
}
|
||||
|
||||
if (mrvl_dev_num == 0) {
|
||||
MRVL_LOG(INFO, "Perform MUSDK deinit");
|
||||
mrvl_deinit_hifs();
|
||||
mrvl_deinit_pp2();
|
||||
rte_mvep_deinit(MVEP_MOD_T_PP2);
|
||||
RTE_ETH_FOREACH_DEV(port_id) {
|
||||
if (rte_eth_devices[port_id].device != &vdev->device)
|
||||
continue;
|
||||
rte_eth_dev_close(port_id);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user