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

Function ff_create_so_memzone

adapter/syscall/ff_so_zone.c:55–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55int
56ff_create_so_memzone()
57{
58 if (ff_so_zone) {
59 ERR_LOG("Can not create memzone: memzone has inited\n");
60 return -1;
61 }
62
63 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
64 uint16_t i, proc_id;
65 for (proc_id = 0; proc_id < ff_global_cfg.dpdk.nb_procs; proc_id++) {
66 struct ff_socket_ops_zone *so_zone_tmp;
67 const struct rte_memzone *mz;
68 char zn[64];
69
70 size_t zone_size = sizeof(struct ff_socket_ops_zone) +
71 sizeof(struct ff_so_context) * ff_max_so_context;
72 snprintf(zn, sizeof(zn), SOCKET_OPS_ZONE_NAME, proc_id);
73 ERR_LOG("To create memzone:%s\n", zn);
74
75 mz = rte_memzone_reserve(zn, zone_size, rte_socket_id(), 0);
76 if (mz == NULL) {
77 ERR_LOG("Cannot reserve memory zone:%s\n", zn);
78 return -1;
79 }
80
81 memset(mz->addr, 0, zone_size);
82 so_zone_tmp = mz->addr;
83
84 rte_spinlock_init(&so_zone_tmp->lock);
85 so_zone_tmp->count = ff_max_so_context;
86 so_zone_tmp->mask = so_zone_tmp->count - 1;
87 so_zone_tmp->free = so_zone_tmp->count;
88 so_zone_tmp->idx = 0;
89 memset(so_zone_tmp->inuse, 0, SOCKET_OPS_CONTEXT_MAX_NUM);
90 so_zone_tmp->sc = (struct ff_so_context *)(so_zone_tmp + 1);
91
92 for (i = 0; i < ff_max_so_context; i++) {
93 struct ff_so_context *sc = &so_zone_tmp->sc[i];
94 rte_spinlock_init(&sc->lock);
95 sc->status = FF_SC_IDLE;
96 sc->idx = i;
97 sc->refcount = 0;
98 sc->ff_thread_handle = NULL;
99 //so_zone_tmp->inuse[i] = 0;
100
101 if (sem_init(&sc->wait_sem, 1, 0) == -1) {
102 ERR_LOG("Initialize semaphore failed:%d\n", errno);
103 return -1;
104 }
105 }
106
107 if (proc_id == 0) {
108 ff_so_zone = so_zone_tmp;
109 }
110 }
111 }else {
112 const struct rte_memzone *mz;

Callers 1

mainFunction · 0.85

Calls 7

rte_eal_process_typeFunction · 0.85
snprintfFunction · 0.85
rte_memzone_reserveFunction · 0.85
rte_socket_idFunction · 0.85
memsetFunction · 0.85
rte_spinlock_initFunction · 0.85
rte_memzone_lookupFunction · 0.85

Tested by

no test coverage detected