goto err_mp_init_secondary;
}
__atomic_fetch_add(&hw->secondary_cnt, 1, __ATOMIC_RELAXED);
+ process_data.eth_dev_cnt++;
hns3_tx_push_init(eth_dev);
return 0;
}
ret);
goto err_mp_init_primary;
}
+ process_data.eth_dev_cnt++;
hw->adapter_state = HNS3_NIC_UNINITIALIZED;
hns->is_vf = false;
goto err_mp_init_secondary;
}
__atomic_fetch_add(&hw->secondary_cnt, 1, __ATOMIC_RELAXED);
+ process_data.eth_dev_cnt++;
hns3_tx_push_init(eth_dev);
return 0;
}
ret);
goto err_mp_init_primary;
}
+ process_data.eth_dev_cnt++;
hw->adapter_state = HNS3_NIC_UNINITIALIZED;
hns->is_vf = true;
#include "hns3_rxtx.h"
#include "hns3_mp.h"
-static bool hns3_inited;
+/* local data for primary or secondary process. */
+struct hns3_process_local_data process_data;
/*
* Initialize IPC message.
{
int ret;
- if (!hns3_inited) {
- /* primary is allowed to not support IPC */
- ret = rte_mp_action_register(HNS3_MP_NAME, mp_primary_handle);
- if (ret && rte_errno != ENOTSUP)
- return ret;
+ if (process_data.init_done)
+ return 0;
- hns3_inited = true;
- }
+ /* primary is allowed to not support IPC */
+ ret = rte_mp_action_register(HNS3_MP_NAME, mp_primary_handle);
+ if (ret && rte_errno != ENOTSUP)
+ return ret;
+
+ process_data.init_done = true;
return 0;
}
*/
void hns3_mp_uninit_primary(void)
{
- if (hns3_inited)
+ process_data.eth_dev_cnt--;
+
+ if (process_data.eth_dev_cnt == 0) {
rte_mp_action_unregister(HNS3_MP_NAME);
+ process_data.init_done = false;
+ }
}
/*
{
int ret;
- if (!hns3_inited) {
- ret = rte_mp_action_register(HNS3_MP_NAME, mp_secondary_handle);
- if (ret)
- return ret;
+ if (process_data.init_done)
+ return 0;
- hns3_inited = true;
- }
+ ret = rte_mp_action_register(HNS3_MP_NAME, mp_secondary_handle);
+ if (ret)
+ return ret;
+
+ process_data.init_done = true;
return 0;
}
#ifndef _HNS3_MP_H_
#define _HNS3_MP_H_
+/* Local data for primary or secondary process. */
+struct hns3_process_local_data {
+ bool init_done; /* Process action register completed flag. */
+ int eth_dev_cnt; /* Ethdev count under the current process. */
+};
+extern struct hns3_process_local_data process_data;
+
void hns3_mp_req_start_rxtx(struct rte_eth_dev *dev);
void hns3_mp_req_stop_rxtx(struct rte_eth_dev *dev);
void hns3_mp_req_start_tx(struct rte_eth_dev *dev);