+
+int
+hns3_mp_init(struct rte_eth_dev *dev)
+{
+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ int ret;
+
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+ ret = hns3_mp_init_secondary();
+ if (ret) {
+ PMD_INIT_LOG(ERR, "Failed to init for secondary process, ret = %d",
+ ret);
+ return ret;
+ }
+ __atomic_fetch_add(&hw->secondary_cnt, 1, __ATOMIC_RELAXED);
+ } else {
+ ret = hns3_mp_init_primary();
+ if (ret) {
+ PMD_INIT_LOG(ERR, "Failed to init for primary process, ret = %d",
+ ret);
+ return ret;
+ }
+ }
+
+ process_data.eth_dev_cnt++;
+
+ return 0;
+}
+
+void hns3_mp_uninit(struct rte_eth_dev *dev)
+{
+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED);
+
+ process_data.eth_dev_cnt--;
+ if (process_data.eth_dev_cnt == 0) {
+ rte_mp_action_unregister(HNS3_MP_NAME);
+ process_data.init_done = false;
+ }
+}