ethdev: reset device and interrupt pointers on release
[dpdk.git] / drivers / net / ipn3ke / ipn3ke_representor.c
index 8300cc3..b673c49 100644 (file)
@@ -40,7 +40,7 @@ static rte_spinlock_t ipn3ke_link_notify_list_lk = RTE_SPINLOCK_INITIALIZER;
 static int
 ipn3ke_rpst_link_check(struct ipn3ke_rpst *rpst);
 
-static void
+static int
 ipn3ke_rpst_dev_infos_get(struct rte_eth_dev *ethdev,
        struct rte_eth_dev_info *dev_info)
 {
@@ -101,6 +101,8 @@ ipn3ke_rpst_dev_infos_get(struct rte_eth_dev *ethdev,
        dev_info->switch_info.name = ethdev->device->name;
        dev_info->switch_info.domain_id = rpst->switch_domain_id;
        dev_info->switch_info.port_id = rpst->port_id;
+
+       return 0;
 }
 
 static int
@@ -699,7 +701,7 @@ struct ipn3ke_rpst_hw_port_stats *hw_stats)
                &tmp,
                IPN3KE_25G_TX_STATISTICS_STATUS,
                port_id,
-               1);
+               0);
        if (tmp & IPN3KE_25G_TX_STATISTICS_STATUS_SHADOW_REQUEST_MASK) {
                tmp = 0x00000000;
                (*hw->f_mac_read)(hw,
@@ -2045,7 +2047,7 @@ uint16_t port_id)
                0);
 }
 
-static void
+static int
 ipn3ke_rpst_stats_reset(struct rte_eth_dev *ethdev)
 {
        uint16_t port_id = 0;
@@ -2056,18 +2058,18 @@ ipn3ke_rpst_stats_reset(struct rte_eth_dev *ethdev)
 
        if (!ethdev) {
                IPN3KE_AFU_PMD_ERR("ethernet device to reset is NULL!");
-               return;
+               return -EINVAL;
        }
 
        afu_dev = RTE_ETH_DEV_TO_AFU(ethdev);
        if (!afu_dev) {
                IPN3KE_AFU_PMD_ERR("afu device to reset is NULL!");
-               return;
+               return -EINVAL;
        }
 
        if (!afu_dev->shared.data) {
                IPN3KE_AFU_PMD_ERR("hardware data to reset is NULL!");
-               return;
+               return -EINVAL;
        }
 
        hw = afu_dev->shared.data;
@@ -2075,7 +2077,7 @@ ipn3ke_rpst_stats_reset(struct rte_eth_dev *ethdev)
        ch = ethdev->data->name;
        if (!ch) {
                IPN3KE_AFU_PMD_ERR("ethdev name is NULL!");
-               return;
+               return -EINVAL;
        }
        while (ch) {
                if (*ch == '_')
@@ -2086,7 +2088,7 @@ ipn3ke_rpst_stats_reset(struct rte_eth_dev *ethdev)
        }
        if (!ch) {
                IPN3KE_AFU_PMD_ERR("Can not get port_id from ethdev name!");
-               return;
+               return -EINVAL;
        }
        port_id = atoi(ch);
 
@@ -2102,6 +2104,8 @@ ipn3ke_rpst_stats_reset(struct rte_eth_dev *ethdev)
                ipn3ke_rpst_10g_lineside_tx_stats_reset(hw, port_id);
                ipn3ke_rpst_10g_lineside_rx_stats_reset(hw, port_id);
        }
+
+       return 0;
 }
 
 static int
@@ -2594,7 +2598,8 @@ ipn3ke_rpst_scan_check(void)
        int ret;
 
        if (ipn3ke_rpst_scan_num == 1) {
-               ret = pthread_create(&ipn3ke_rpst_scan_thread,
+               ret = rte_ctrl_thread_create(&ipn3ke_rpst_scan_thread,
+                       "ipn3ke scanner",
                        NULL,
                        ipn3ke_rpst_scan_handle_request, NULL);
                if (ret) {
@@ -2616,7 +2621,7 @@ ipn3ke_rpst_scan_check(void)
        return 0;
 }
 
-void
+int
 ipn3ke_rpst_promiscuous_enable(struct rte_eth_dev *ethdev)
 {
        struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
@@ -2639,9 +2644,11 @@ ipn3ke_rpst_promiscuous_enable(struct rte_eth_dev *ethdev)
                                rpst->port_id,
                                0);
        }
+
+       return 0;
 }
 
-void
+int
 ipn3ke_rpst_promiscuous_disable(struct rte_eth_dev *ethdev)
 {
        struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
@@ -2664,9 +2671,11 @@ ipn3ke_rpst_promiscuous_disable(struct rte_eth_dev *ethdev)
                                rpst->port_id,
                                0);
        }
+
+       return 0;
 }
 
-void
+int
 ipn3ke_rpst_allmulticast_enable(struct rte_eth_dev *ethdev)
 {
        struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
@@ -2690,9 +2699,11 @@ ipn3ke_rpst_allmulticast_enable(struct rte_eth_dev *ethdev)
                                rpst->port_id,
                                0);
        }
+
+       return 0;
 }
 
-void
+int
 ipn3ke_rpst_allmulticast_disable(struct rte_eth_dev *ethdev)
 {
        struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(ethdev);
@@ -2716,6 +2727,8 @@ ipn3ke_rpst_allmulticast_disable(struct rte_eth_dev *ethdev)
                                rpst->port_id,
                                0);
        }
+
+       return 0;
 }
 
 int
@@ -2902,12 +2915,18 @@ ipn3ke_rpst_init(struct rte_eth_dev *ethdev, void *init_params)
        if (representor_param->port_id >= representor_param->hw->port_num)
                return -ENODEV;
 
+       if (ipn3ke_bridge_func.set_i40e_sw_dev == NULL)
+               return -ENOMEM;
+
        rpst->ethdev = ethdev;
        rpst->switch_domain_id = representor_param->switch_domain_id;
        rpst->port_id = representor_param->port_id;
        rpst->hw = representor_param->hw;
-       rpst->i40e_pf_eth = NULL;
-       rpst->i40e_pf_eth_port_id = 0xFFFF;
+       rpst->i40e_pf_eth = representor_param->i40e_pf_eth;
+       rpst->i40e_pf_eth_port_id = representor_param->i40e_pf_eth_port_id;
+       if (rpst->i40e_pf_eth)
+               ipn3ke_bridge_func.set_i40e_sw_dev(rpst->i40e_pf_eth_port_id,
+                                           rpst->ethdev);
 
        ethdev->data->mac_addrs = rte_zmalloc("ipn3ke", RTE_ETHER_ADDR_LEN, 0);
        if (!ethdev->data->mac_addrs) {