src/dpdk/drivers/net/failsafe/failsafe_intr.c
static int
fs_rx_event_proxy_service_install(struct fs_priv *priv)
{
	struct rte_service_spec service;
	int32_t num_service_cores;
	int ret = 0;

	num_service_cores = rte_service_lcore_count();
	if (num_service_cores <= 0) {
		ERROR("Failed to install Rx interrupts, "
		      "no service core found");
		return -ENOTSUP;
	}
	/* prepare service info */
	memset(&service, 0, sizeof(struct rte_service_spec));
	snprintf(service.name, sizeof(service.name), "%s_Rx_service",
		 priv->data->name);
	service.socket_id = priv->data->numa_node;
	service.callback = fs_rx_event_proxy_routine;
	service.callback_userdata = priv;

	if (priv->rxp.sstate == SS_NO_SERVICE) {
		uint32_t service_core_list[num_service_cores];

		/* get a service core to work with */
		ret = rte_service_lcore_list(service_core_list,
					     num_service_cores);
		if (ret <= 0) {
			ERROR("Failed to install Rx interrupts, "
			      "service core list empty or corrupted");
			return -ENOTSUP;
		}
		priv->rxp.scid = service_core_list[0];
		ret = rte_service_lcore_add(priv->rxp.scid);
		if (ret && ret != -EALREADY) {
			ERROR("Failed adding service core");
			return ret;
		}
		/* service core may be in "stopped" state, start it */
		ret = rte_service_lcore_start(priv->rxp.scid);
		if (ret && (ret != -EALREADY)) {
			ERROR("Failed to install Rx interrupts, "
			      "service core not started");
			return ret;
		}
		/* register our service */
		int32_t ret = rte_service_component_register(&service,
							     &priv->rxp.sid);
		if (ret) {
			ERROR("service register() failed");
			return -ENOEXEC;
		}
		priv->rxp.sstate = SS_REGISTERED;
		/* run the service */
		ret = rte_service_component_runstate_set(priv->rxp.sid, 1);
		if (ret < 0) {
			ERROR("Failed Setting component runstate\n");
			return ret;
		}
		ret = rte_service_set_stats_enable(priv->rxp.sid, 1);
		if (ret < 0) {
			ERROR("Failed enabling stats\n");
			return ret;
		}
		ret = rte_service_runstate_set(priv->rxp.sid, 1);
		if (ret < 0) {
			ERROR("Failed to run service\n");
			return ret;
		}
		priv->rxp.sstate = SS_READY;
		/* map the service with the service core */
		ret = rte_service_map_lcore_set(priv->rxp.sid,
						priv->rxp.scid, 1);
		if (ret) {
			ERROR("Failed to install Rx interrupts, "
			      "could not map service core");
			return ret;
		}
		priv->rxp.sstate = SS_RUNNING;
	}
	return 0;
}
/**
 * Install the failsafe Rx event proxy service.
 *
 * @param priv
 *   Pointer to failsafe private structure.
 * @return
 *   0 on success, negative errno value otherwise.
 */
Install the failsafe Rx event proxy service.
@param priv
Pointer to failsafe private structure.
@return
0 on success, negative errno value otherwise.
Install the failsafe Rx event proxy service . @param priv Pointer to failsafe private structure . @return 0 on success negative errno value otherwise .
static int
fs_rx_event_proxy_service_install(struct fs_priv *priv)
{
	struct rte_service_spec service;
	int32_t num_service_cores;
	int ret = 0;
	num_service_cores = rte_service_lcore_count();
	if (num_service_cores <= 0) {
		ERROR("Failed to install Rx interrupts, "
		      "no service core found");
		return -ENOTSUP;
	}
	memset(&service, 0, sizeof(struct rte_service_spec));
	snprintf(service.name, sizeof(service.name), "%s_Rx_service",
		 priv->data->name);
	service.socket_id = priv->data->numa_node;
	service.callback = fs_rx_event_proxy_routine;
	service.callback_userdata = priv;
	if (priv->rxp.sstate == SS_NO_SERVICE) {
		uint32_t service_core_list[num_service_cores];
		ret = rte_service_lcore_list(service_core_list,
					     num_service_cores);
		if (ret <= 0) {
			ERROR("Failed to install Rx interrupts, "
			      "service core list empty or corrupted");
			return -ENOTSUP;
		}
		priv->rxp.scid = service_core_list[0];
		ret = rte_service_lcore_add(priv->rxp.scid);
		if (ret && ret != -EALREADY) {
			ERROR("Failed adding service core");
			return ret;
		}
		ret = rte_service_lcore_start(priv->rxp.scid);
		if (ret && (ret != -EALREADY)) {
			ERROR("Failed to install Rx interrupts, "
			      "service core not started");
			return ret;
		}
		int32_t ret = rte_service_component_register(&service,
							     &priv->rxp.sid);
		if (ret) {
			ERROR("service register() failed");
			return -ENOEXEC;
		}
		priv->rxp.sstate = SS_REGISTERED;
		ret = rte_service_component_runstate_set(priv->rxp.sid, 1);
		if (ret < 0) {
			ERROR("Failed Setting component runstate\n");
			return ret;
		}
		ret = rte_service_set_stats_enable(priv->rxp.sid, 1);
		if (ret < 0) {
			ERROR("Failed enabling stats\n");
			return ret;
		}
		ret = rte_service_runstate_set(priv->rxp.sid, 1);
		if (ret < 0) {
			ERROR("Failed to run service\n");
			return ret;
		}
		priv->rxp.sstate = SS_READY;
		ret = rte_service_map_lcore_set(priv->rxp.sid,
						priv->rxp.scid, 1);
		if (ret) {
			ERROR("Failed to install Rx interrupts, "
			      "could not map service core");
			return ret;
		}
		priv->rxp.sstate = SS_RUNNING;
	}
	return 0;
}
static int fs_rx_event_proxy_service_install ( struct fs_priv * priv ) { struct rte_service_spec service ; int32_t num_service_cores ; int ret = 0 ; num_service_cores = rte_service_lcore_count ( ) ; if ( num_service_cores <= 0 ) { ERROR ( " " " " ) ; return - ENOTSUP ; } memset ( & service , 0 , sizeof ( struct rte_service_spec ) ) ; snprintf ( service . name , sizeof ( service . name ) , " " , priv -> data -> name ) ; service . socket_id = priv -> data -> numa_node ; service . callback = fs_rx_event_proxy_routine ; service . callback_userdata = priv ; if ( priv -> rxp . sstate == SS_NO_SERVICE ) { uint32_t service_core_list [ num_service_cores ] ; ret = rte_service_lcore_list ( service_core_list , num_service_cores ) ; if ( ret <= 0 ) { ERROR ( " " " " ) ; return - ENOTSUP ; } priv -> rxp . scid = service_core_list [ 0 ] ; ret = rte_service_lcore_add ( priv -> rxp . scid ) ; if ( ret && ret != - EALREADY ) { ERROR ( " " ) ; return ret ; } ret = rte_service_lcore_start ( priv -> rxp . scid ) ; if ( ret && ( ret != - EALREADY ) ) { ERROR ( " " " " ) ; return ret ; } int32_t ret = rte_service_component_register ( & service , & priv -> rxp . sid ) ; if ( ret ) { ERROR ( " " ) ; return - ENOEXEC ; } priv -> rxp . sstate = SS_REGISTERED ; ret = rte_service_component_runstate_set ( priv -> rxp . sid , 1 ) ; if ( ret < 0 ) { ERROR ( " \n " ) ; return ret ; } ret = rte_service_set_stats_enable ( priv -> rxp . sid , 1 ) ; if ( ret < 0 ) { ERROR ( " \n " ) ; return ret ; } ret = rte_service_runstate_set ( priv -> rxp . sid , 1 ) ; if ( ret < 0 ) { ERROR ( " \n " ) ; return ret ; } priv -> rxp . sstate = SS_READY ; ret = rte_service_map_lcore_set ( priv -> rxp . sid , priv -> rxp . scid , 1 ) ; if ( ret ) { ERROR ( " " " " ) ; return ret ; } priv -> rxp . sstate = SS_RUNNING ; } return 0 ; }
Install the failsafe Rx event proxy service.
Install the failsafe Rx event proxy service .
/* prepare service info */ /* get a service core to work with */ /* service core may be in "stopped" state, start it */ /* register our service */ /* run the service */ /* map the service with the service core */