+/**
+ * DPDK callback to close the device.
+ *
+ * @param dev
+ * Pointer to Ethernet device structure.
+ */
+static int hinic_dev_close(struct rte_eth_dev *dev)
+{
+ struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
+ int ret;
+
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return 0;
+
+ if (rte_bit_relaxed_test_and_set32(HINIC_DEV_CLOSE,
+ &nic_dev->dev_status)) {
+ PMD_DRV_LOG(WARNING, "Device %s already closed",
+ dev->data->name);
+ return 0;
+ }
+
+ /* stop device first */
+ ret = hinic_dev_stop(dev);
+
+ /* rx_cqe, rx_info */
+ hinic_free_all_rx_resources(dev);
+
+ /* tx_info */
+ hinic_free_all_tx_resources(dev);
+
+ /* free wq, pi_dma_addr */
+ hinic_free_all_rq(nic_dev);
+
+ /* free wq, db_addr */
+ hinic_free_all_sq(nic_dev);
+
+ /* deinit mac vlan tbl */
+ hinic_deinit_mac_addr(dev);
+ hinic_remove_all_vlanid(dev);
+
+ /* disable hardware and uio interrupt */
+ hinic_disable_interrupt(dev);
+
+ /* destroy rx mode mutex */
+ hinic_mutex_destroy(&nic_dev->rx_mode_mutex);
+
+ /* deinit nic hardware device */
+ hinic_nic_dev_destroy(dev);
+
+ return ret;
+}
+
+static const struct eth_dev_ops hinic_pmd_ops = {
+ .dev_configure = hinic_dev_configure,
+ .dev_infos_get = hinic_dev_infos_get,
+ .fw_version_get = hinic_fw_version_get,
+ .rx_queue_setup = hinic_rx_queue_setup,
+ .tx_queue_setup = hinic_tx_queue_setup,
+ .dev_start = hinic_dev_start,
+ .dev_set_link_up = hinic_dev_set_link_up,
+ .dev_set_link_down = hinic_dev_set_link_down,
+ .link_update = hinic_link_update,
+ .rx_queue_release = hinic_rx_queue_release,
+ .tx_queue_release = hinic_tx_queue_release,
+ .dev_stop = hinic_dev_stop,
+ .dev_close = hinic_dev_close,
+ .mtu_set = hinic_dev_set_mtu,
+ .vlan_filter_set = hinic_vlan_filter_set,
+ .vlan_offload_set = hinic_vlan_offload_set,
+ .allmulticast_enable = hinic_dev_allmulticast_enable,
+ .allmulticast_disable = hinic_dev_allmulticast_disable,
+ .promiscuous_enable = hinic_dev_promiscuous_enable,
+ .promiscuous_disable = hinic_dev_promiscuous_disable,
+ .flow_ctrl_get = hinic_flow_ctrl_get,
+ .flow_ctrl_set = hinic_flow_ctrl_set,
+ .rss_hash_update = hinic_rss_hash_update,
+ .rss_hash_conf_get = hinic_rss_conf_get,
+ .reta_update = hinic_rss_indirtbl_update,
+ .reta_query = hinic_rss_indirtbl_query,
+ .stats_get = hinic_dev_stats_get,
+ .stats_reset = hinic_dev_stats_reset,
+ .xstats_get = hinic_dev_xstats_get,
+ .xstats_reset = hinic_dev_xstats_reset,
+ .xstats_get_names = hinic_dev_xstats_get_names,
+ .rxq_info_get = hinic_rxq_info_get,
+ .txq_info_get = hinic_txq_info_get,
+ .mac_addr_set = hinic_set_mac_addr,
+ .mac_addr_remove = hinic_mac_addr_remove,
+ .mac_addr_add = hinic_mac_addr_add,
+ .set_mc_addr_list = hinic_set_mc_addr_list,
+ .filter_ctrl = hinic_dev_filter_ctrl,
+};
+
+static const struct eth_dev_ops hinic_pmd_vf_ops = {
+ .dev_configure = hinic_dev_configure,
+ .dev_infos_get = hinic_dev_infos_get,
+ .fw_version_get = hinic_fw_version_get,
+ .rx_queue_setup = hinic_rx_queue_setup,
+ .tx_queue_setup = hinic_tx_queue_setup,
+ .dev_start = hinic_dev_start,
+ .link_update = hinic_link_update,
+ .rx_queue_release = hinic_rx_queue_release,
+ .tx_queue_release = hinic_tx_queue_release,
+ .dev_stop = hinic_dev_stop,
+ .dev_close = hinic_dev_close,
+ .mtu_set = hinic_dev_set_mtu,
+ .vlan_filter_set = hinic_vlan_filter_set,
+ .vlan_offload_set = hinic_vlan_offload_set,
+ .allmulticast_enable = hinic_dev_allmulticast_enable,
+ .allmulticast_disable = hinic_dev_allmulticast_disable,
+ .rss_hash_update = hinic_rss_hash_update,
+ .rss_hash_conf_get = hinic_rss_conf_get,
+ .reta_update = hinic_rss_indirtbl_update,
+ .reta_query = hinic_rss_indirtbl_query,
+ .stats_get = hinic_dev_stats_get,
+ .stats_reset = hinic_dev_stats_reset,
+ .xstats_get = hinic_dev_xstats_get,
+ .xstats_reset = hinic_dev_xstats_reset,
+ .xstats_get_names = hinic_dev_xstats_get_names,
+ .rxq_info_get = hinic_rxq_info_get,
+ .txq_info_get = hinic_txq_info_get,
+ .mac_addr_set = hinic_set_mac_addr,
+ .mac_addr_remove = hinic_mac_addr_remove,
+ .mac_addr_add = hinic_mac_addr_add,
+ .set_mc_addr_list = hinic_set_mc_addr_list,
+ .filter_ctrl = hinic_dev_filter_ctrl,
+};
+