[v12,05/18] net/idpf: add support for device start and stop
Commit Message
Add dev ops dev_start, dev_stop and link_update.
Signed-off-by: Beilei Xing <beilei.xing@intel.com>
Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Signed-off-by: Junfeng Guo <junfeng.guo@intel.com>
---
drivers/net/idpf/idpf_ethdev.c | 51 ++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
@@ -30,17 +30,38 @@ static const char * const idpf_valid_args[] = {
};
static int idpf_dev_configure(struct rte_eth_dev *dev);
+static int idpf_dev_start(struct rte_eth_dev *dev);
+static int idpf_dev_stop(struct rte_eth_dev *dev);
static int idpf_dev_close(struct rte_eth_dev *dev);
static int idpf_dev_info_get(struct rte_eth_dev *dev,
struct rte_eth_dev_info *dev_info);
static void idpf_adapter_rel(struct idpf_adapter *adapter);
+static int
+idpf_dev_link_update(struct rte_eth_dev *dev,
+ __rte_unused int wait_to_complete)
+{
+ struct rte_eth_link new_link;
+
+ memset(&new_link, 0, sizeof(new_link));
+
+ new_link.link_speed = RTE_ETH_SPEED_NUM_NONE;
+ new_link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
+ new_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
+ RTE_ETH_LINK_SPEED_FIXED);
+
+ return rte_eth_linkstatus_set(dev, &new_link);
+}
+
static const struct eth_dev_ops idpf_eth_dev_ops = {
.dev_configure = idpf_dev_configure,
+ .dev_start = idpf_dev_start,
+ .dev_stop = idpf_dev_stop,
.dev_close = idpf_dev_close,
.rx_queue_setup = idpf_rx_queue_setup,
.tx_queue_setup = idpf_tx_queue_setup,
.dev_infos_get = idpf_dev_info_get,
+ .link_update = idpf_dev_link_update,
};
static int
@@ -284,6 +305,36 @@ idpf_dev_configure(struct rte_eth_dev *dev)
return 0;
}
+static int
+idpf_dev_start(struct rte_eth_dev *dev)
+{
+ struct idpf_vport *vport = dev->data->dev_private;
+
+ if (dev->data->mtu > vport->max_mtu) {
+ PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
+ return -1;
+ }
+
+ vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
+
+ if (idpf_vc_ena_dis_vport(vport, true) != 0) {
+ PMD_DRV_LOG(ERR, "Failed to enable vport");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int
+idpf_dev_stop(struct rte_eth_dev *dev)
+{
+ struct idpf_vport *vport = dev->data->dev_private;
+
+ idpf_vc_ena_dis_vport(vport, false);
+
+ return 0;
+}
+
static int
idpf_dev_close(struct rte_eth_dev *dev)
{