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

Function rte_cryptodev_add_deq_callback

dpdk/lib/cryptodev/rte_cryptodev.c:1632–1701  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1630}
1631
1632struct rte_cryptodev_cb *
1633rte_cryptodev_add_deq_callback(uint8_t dev_id,
1634 uint16_t qp_id,
1635 rte_cryptodev_callback_fn cb_fn,
1636 void *cb_arg)
1637{
1638#ifndef RTE_CRYPTO_CALLBACKS
1639 rte_errno = ENOTSUP;
1640 return NULL;
1641#endif
1642 struct rte_cryptodev *dev;
1643 struct rte_cryptodev_cb_rcu *list;
1644 struct rte_cryptodev_cb *cb, *tail;
1645
1646 if (!cb_fn) {
1647 CDEV_LOG_ERR("Callback is NULL on dev_id=%d", dev_id);
1648 rte_errno = EINVAL;
1649 return NULL;
1650 }
1651
1652 if (!rte_cryptodev_is_valid_dev(dev_id)) {
1653 CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
1654 rte_errno = ENODEV;
1655 return NULL;
1656 }
1657
1658 dev = &rte_crypto_devices[dev_id];
1659 if (qp_id >= dev->data->nb_queue_pairs) {
1660 CDEV_LOG_ERR("Invalid queue_pair_id=%d", qp_id);
1661 rte_errno = ENODEV;
1662 return NULL;
1663 }
1664
1665 cb = rte_zmalloc(NULL, sizeof(*cb), 0);
1666 if (cb == NULL) {
1667 CDEV_LOG_ERR("Failed to allocate memory for callback on "
1668 "dev=%d, queue_pair_id=%d", dev_id, qp_id);
1669 rte_errno = ENOMEM;
1670 return NULL;
1671 }
1672
1673 rte_spinlock_lock(&rte_cryptodev_callback_lock);
1674
1675 cb->fn = cb_fn;
1676 cb->arg = cb_arg;
1677
1678 /* Add the callbacks in fifo order. */
1679 list = &dev->deq_cbs[qp_id];
1680 tail = list->next;
1681
1682 if (tail) {
1683 while (tail->next)
1684 tail = tail->next;
1685 /* Stores to cb->fn and cb->param should complete before
1686 * cb is visible to data plane.
1687 */
1688 rte_atomic_store_explicit(&tail->next, cb, rte_memory_order_release);
1689 } else {

Callers 1

test_deq_callback_setupFunction · 0.85

Calls 4

rte_zmallocFunction · 0.85
rte_spinlock_lockFunction · 0.50
rte_spinlock_unlockFunction · 0.50

Tested by 1

test_deq_callback_setupFunction · 0.68