MCPcopy Create free account
hub / github.com/F-Stack/f-stack / swtim_init

Function swtim_init

dpdk/lib/eventdev/rte_event_timer_adapter.c:906–1009  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

904}
905
906static int
907swtim_init(struct rte_event_timer_adapter *adapter)
908{
909 int i, ret;
910 struct swtim *sw;
911 unsigned int flags;
912 struct rte_service_spec service;
913
914 /* Allocate storage for private data area */
915#define SWTIM_NAMESIZE 32
916 char swtim_name[SWTIM_NAMESIZE];
917 snprintf(swtim_name, SWTIM_NAMESIZE, "swtim_%"PRIu8,
918 adapter->data->id);
919 sw = rte_zmalloc_socket(swtim_name, sizeof(*sw), RTE_CACHE_LINE_SIZE,
920 adapter->data->socket_id);
921 if (sw == NULL) {
922 EVTIM_LOG_ERR("failed to allocate space for private data");
923 rte_errno = ENOMEM;
924 return -1;
925 }
926
927 /* Connect storage to adapter instance */
928 adapter->data->adapter_priv = sw;
929 sw->adapter = adapter;
930
931 sw->timer_tick_ns = adapter->data->conf.timer_tick_ns;
932 sw->max_tmo_ns = adapter->data->conf.max_tmo_ns;
933
934 /* Create a timer pool */
935 char pool_name[SWTIM_NAMESIZE];
936 snprintf(pool_name, SWTIM_NAMESIZE, "swtim_pool_%"PRIu8,
937 adapter->data->id);
938 /* Optimal mempool size is a power of 2 minus one */
939 uint64_t nb_timers = rte_align64pow2(adapter->data->conf.nb_timers);
940 int pool_size = nb_timers - 1;
941 int cache_size = compute_msg_mempool_cache_size(
942 adapter->data->conf.nb_timers, nb_timers);
943 flags = 0; /* pool is multi-producer, multi-consumer */
944 sw->tim_pool = rte_mempool_create(pool_name, pool_size,
945 sizeof(struct rte_timer), cache_size, 0, NULL, NULL,
946 NULL, NULL, adapter->data->socket_id, flags);
947 if (sw->tim_pool == NULL) {
948 EVTIM_LOG_ERR("failed to create timer object mempool");
949 rte_errno = ENOMEM;
950 goto free_alloc;
951 }
952
953 /* Initialize the variables that track in-use timer lists */
954 for (i = 0; i < RTE_MAX_LCORE; i++)
955 sw->in_use[i].v = 0;
956
957 /* Initialize the timer subsystem and allocate timer data instance */
958 ret = rte_timer_subsystem_init();
959 if (ret < 0) {
960 if (ret != -EALREADY) {
961 EVTIM_LOG_ERR("failed to initialize timer subsystem");
962 rte_errno = -ret;
963 goto free_mempool;

Callers

nothing calls this directly

Calls 12

snprintfFunction · 0.85
rte_zmalloc_socketFunction · 0.85
rte_mempool_createFunction · 0.85
rte_timer_subsystem_initFunction · 0.85
rte_timer_data_allocFunction · 0.85
event_buffer_initFunction · 0.85
memsetFunction · 0.85
rte_mempool_freeFunction · 0.85
rte_freeFunction · 0.85
rte_align64pow2Function · 0.50

Tested by

no test coverage detected