| 3034 | } |
| 3035 | |
| 3036 | int |
| 3037 | ff_adapter_init() |
| 3038 | //int __attribute__((constructor)) |
| 3039 | //ff_adapter_init(int argc, char * const argv[]) |
| 3040 | { |
| 3041 | int ret; |
| 3042 | |
| 3043 | ERR_LOG("inited:%d, proc_inited:%d\n", inited, proc_inited); |
| 3044 | |
| 3045 | #ifndef FF_MULTI_SC |
| 3046 | if (inited) { |
| 3047 | return 0; |
| 3048 | } |
| 3049 | #endif |
| 3050 | |
| 3051 | if (proc_inited == 0) { |
| 3052 | /* May conflict */ |
| 3053 | rte_spinlock_init(&worker_id_lock); |
| 3054 | rte_spinlock_lock(&worker_id_lock); |
| 3055 | |
| 3056 | pthread_key_create(&key, thread_destructor); |
| 3057 | DEBUG_LOG("pthread key:%d\n", key); |
| 3058 | |
| 3059 | //atexit(ff_adapter_exit); |
| 3060 | //on_exit(ff_adapter_exit, NULL); |
| 3061 | |
| 3062 | /* |
| 3063 | * get ulimit -n to distinguish fd between kernel and F-Stack |
| 3064 | */ |
| 3065 | struct rlimit rlmt; |
| 3066 | ret = getrlimit(RLIMIT_NOFILE, &rlmt); |
| 3067 | if (ret < 0) { |
| 3068 | ERR_LOG("getrlimit(RLIMIT_NOFILE) failed, use default ff_kernel_max_fd:%d\n", ff_kernel_max_fd); |
| 3069 | return -1; |
| 3070 | } else { |
| 3071 | #if !defined(FF_PRELOAD_SUPPORT_SELECT) |
| 3072 | ff_kernel_max_fd = (int)rlmt.rlim_cur; |
| 3073 | #endif |
| 3074 | } |
| 3075 | ERR_LOG("getrlimit(RLIMIT_NOFILE) successed, sed ff_kernel_max_fd:%d, and rlim_max is %ld\n", |
| 3076 | ff_kernel_max_fd, rlmt.rlim_max); |
| 3077 | |
| 3078 | /* |
| 3079 | * Get environment variable FF_INITIAL_LCORE_ID to set initial_lcore_id |
| 3080 | * |
| 3081 | * If need later, modify to get config from config file, |
| 3082 | * it can consider multiplex F-Stack config.ini |
| 3083 | */ |
| 3084 | char *ff_init_lcore_id = getenv(FF_INITIAL_LCORE_ID_STR); |
| 3085 | if (ff_init_lcore_id != NULL) { |
| 3086 | initial_lcore_id = (uint64_t)strtoull(ff_init_lcore_id, NULL, 16); |
| 3087 | if (initial_lcore_id > ((uint64_t)INITIAL_LCORE_ID_MAX) /*== UINT64_MAX*/) { |
| 3088 | initial_lcore_id = INITIAL_LCORE_ID_DEFAULT; |
| 3089 | ERR_LOG("get invalid FF_INITIAL_LCORE_ID=%s, to use default value 0x%0lx\n", |
| 3090 | ff_init_lcore_id, initial_lcore_id); |
| 3091 | } |
| 3092 | ERR_LOG("get FF_INITIAL_LCORE_ID=%s, use 0x%0lx\n", |
| 3093 | ff_init_lcore_id, initial_lcore_id); |
no test coverage detected