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

Function opae_adapter_mutex_open

dpdk/drivers/raw/ifpga/base/opae_hw_api.c:361–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359}
360
361static pthread_mutex_t *opae_adapter_mutex_open(struct opae_adapter *adapter)
362{
363 char shm_name[32];
364 void *ptr;
365 int shm_id;
366 int new_shm = 0;
367
368 if (!adapter->data)
369 return NULL;
370 adapter->lock = NULL;
371
372 snprintf(shm_name, sizeof(shm_name), "/mutex.IFPGA:%s", adapter->name);
373 shm_id = opae_shm_open(shm_name, sizeof(pthread_mutex_t), &new_shm);
374 if (shm_id == -1) {
375 dev_err(NULL, "failed to open shared memory %s\n", shm_name);
376 } else {
377 dev_info(NULL, "shared memory %s id is %d\n",
378 shm_name, shm_id);
379 ptr = mmap(NULL, sizeof(pthread_mutex_t),
380 PROT_READ | PROT_WRITE, MAP_SHARED,
381 shm_id, 0);
382 adapter->lock = (pthread_mutex_t *)ptr;
383 if (ptr != MAP_FAILED) {
384 dev_info(NULL,
385 "shared memory %s address is %p\n",
386 shm_name, ptr);
387 if (new_shm)
388 opae_mutex_init(adapter->lock);
389 } else {
390 dev_err(NULL, "failed to map shared memory %s\n",
391 shm_name);
392 }
393 }
394
395 return adapter->lock;
396}
397
398static void opae_adapter_mutex_close(struct opae_adapter *adapter)
399{

Callers 1

opae_adapter_initFunction · 0.85

Calls 3

snprintfFunction · 0.85
opae_shm_openFunction · 0.85
opae_mutex_initFunction · 0.85

Tested by

no test coverage detected