+static int32_t
+rte_pmd_softnic_run_internal(void *arg);
+
+static inline int
+thread_sc_service_up(struct pmd_internals *softnic, uint32_t thread_id)
+{
+ struct rte_service_spec service_params;
+ struct softnic_thread *t = &softnic->thread[thread_id];
+ struct rte_eth_dev *dev;
+ int status;
+
+ /* service params */
+ dev = rte_eth_dev_get_by_name(softnic->params.name);
+ if (!dev)
+ return -EINVAL;
+
+ snprintf(service_params.name, sizeof(service_params.name), "%s_%u",
+ softnic->params.name,
+ thread_id);
+ service_params.callback = rte_pmd_softnic_run_internal;
+ service_params.callback_userdata = dev;
+ service_params.capabilities = 0;
+ service_params.socket_id = (int)softnic->params.cpu_id;
+
+ /* service register */
+ status = rte_service_component_register(&service_params, &t->service_id);
+ if (status)
+ return status;
+
+ status = rte_service_component_runstate_set(t->service_id, 1);
+ if (status) {
+ rte_service_component_unregister(t->service_id);
+ t->service_id = UINT32_MAX;
+ return status;
+ }
+
+ status = rte_service_runstate_set(t->service_id, 1);
+ if (status) {
+ rte_service_component_runstate_set(t->service_id, 0);
+ rte_service_component_unregister(t->service_id);
+ t->service_id = UINT32_MAX;
+ return status;
+ }
+
+ /* service map to thread */
+ status = rte_service_map_lcore_set(t->service_id, thread_id, 1);
+ if (status) {
+ rte_service_runstate_set(t->service_id, 0);
+ rte_service_component_runstate_set(t->service_id, 0);
+ rte_service_component_unregister(t->service_id);
+ t->service_id = UINT32_MAX;
+ return status;
+ }
+
+ return 0;
+}
+
+static inline void
+thread_sc_service_down(struct pmd_internals *softnic, uint32_t thread_id)
+{
+ struct softnic_thread *t = &softnic->thread[thread_id];
+
+ /* service unmap from thread */
+ rte_service_map_lcore_set(t->service_id, thread_id, 0);
+
+ /* service unregister */
+ rte_service_runstate_set(t->service_id, 0);
+ rte_service_component_runstate_set(t->service_id, 0);
+ rte_service_component_unregister(t->service_id);
+
+ t->service_id = UINT32_MAX;
+}
+