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

Function rte_cryptodev_add_enq_callback

dpdk/lib/cryptodev/rte_cryptodev.c:1486–1554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1484}
1485
1486struct rte_cryptodev_cb *
1487rte_cryptodev_add_enq_callback(uint8_t dev_id,
1488 uint16_t qp_id,
1489 rte_cryptodev_callback_fn cb_fn,
1490 void *cb_arg)
1491{
1492#ifndef RTE_CRYPTO_CALLBACKS
1493 rte_errno = ENOTSUP;
1494 return NULL;
1495#endif
1496 struct rte_cryptodev *dev;
1497 struct rte_cryptodev_cb_rcu *list;
1498 struct rte_cryptodev_cb *cb, *tail;
1499
1500 if (!cb_fn) {
1501 CDEV_LOG_ERR("Callback is NULL on dev_id=%d", dev_id);
1502 rte_errno = EINVAL;
1503 return NULL;
1504 }
1505
1506 if (!rte_cryptodev_is_valid_dev(dev_id)) {
1507 CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
1508 rte_errno = ENODEV;
1509 return NULL;
1510 }
1511
1512 dev = &rte_crypto_devices[dev_id];
1513 if (qp_id >= dev->data->nb_queue_pairs) {
1514 CDEV_LOG_ERR("Invalid queue_pair_id=%d", qp_id);
1515 rte_errno = ENODEV;
1516 return NULL;
1517 }
1518
1519 cb = rte_zmalloc(NULL, sizeof(*cb), 0);
1520 if (cb == NULL) {
1521 CDEV_LOG_ERR("Failed to allocate memory for callback on "
1522 "dev=%d, queue_pair_id=%d", dev_id, qp_id);
1523 rte_errno = ENOMEM;
1524 return NULL;
1525 }
1526
1527 rte_spinlock_lock(&rte_cryptodev_callback_lock);
1528
1529 cb->fn = cb_fn;
1530 cb->arg = cb_arg;
1531
1532 /* Add the callbacks in fifo order. */
1533 list = &dev->enq_cbs[qp_id];
1534 tail = list->next;
1535
1536 if (tail) {
1537 while (tail->next)
1538 tail = tail->next;
1539 /* Stores to cb->fn and cb->param should complete before
1540 * cb is visible to data plane.
1541 */
1542 rte_atomic_store_explicit(&tail->next, cb, rte_memory_order_release);
1543 } else {

Callers 1

test_enq_callback_setupFunction · 0.85

Calls 4

rte_zmallocFunction · 0.85
rte_spinlock_lockFunction · 0.50
rte_spinlock_unlockFunction · 0.50

Tested by 1

test_enq_callback_setupFunction · 0.68