| 1701 | } |
| 1702 | |
| 1703 | int |
| 1704 | rte_cryptodev_remove_deq_callback(uint8_t dev_id, |
| 1705 | uint16_t qp_id, |
| 1706 | struct rte_cryptodev_cb *cb) |
| 1707 | { |
| 1708 | #ifndef RTE_CRYPTO_CALLBACKS |
| 1709 | return -ENOTSUP; |
| 1710 | #endif |
| 1711 | struct rte_cryptodev *dev; |
| 1712 | RTE_ATOMIC(struct rte_cryptodev_cb *) *prev_cb; |
| 1713 | struct rte_cryptodev_cb *curr_cb; |
| 1714 | struct rte_cryptodev_cb_rcu *list; |
| 1715 | int ret; |
| 1716 | |
| 1717 | ret = -EINVAL; |
| 1718 | |
| 1719 | if (!cb) { |
| 1720 | CDEV_LOG_ERR("Callback is NULL"); |
| 1721 | return -EINVAL; |
| 1722 | } |
| 1723 | |
| 1724 | if (!rte_cryptodev_is_valid_dev(dev_id)) { |
| 1725 | CDEV_LOG_ERR("Invalid dev_id=%d", dev_id); |
| 1726 | return -ENODEV; |
| 1727 | } |
| 1728 | |
| 1729 | rte_cryptodev_trace_remove_deq_callback(dev_id, qp_id, cb->fn); |
| 1730 | |
| 1731 | dev = &rte_crypto_devices[dev_id]; |
| 1732 | if (qp_id >= dev->data->nb_queue_pairs) { |
| 1733 | CDEV_LOG_ERR("Invalid queue_pair_id=%d", qp_id); |
| 1734 | return -ENODEV; |
| 1735 | } |
| 1736 | |
| 1737 | rte_spinlock_lock(&rte_cryptodev_callback_lock); |
| 1738 | if (dev->enq_cbs == NULL) { |
| 1739 | CDEV_LOG_ERR("Callback not initialized"); |
| 1740 | goto cb_err; |
| 1741 | } |
| 1742 | |
| 1743 | list = &dev->deq_cbs[qp_id]; |
| 1744 | if (list == NULL) { |
| 1745 | CDEV_LOG_ERR("Callback list is NULL"); |
| 1746 | goto cb_err; |
| 1747 | } |
| 1748 | |
| 1749 | if (list->qsbr == NULL) { |
| 1750 | CDEV_LOG_ERR("Rcu qsbr is NULL"); |
| 1751 | goto cb_err; |
| 1752 | } |
| 1753 | |
| 1754 | prev_cb = &list->next; |
| 1755 | for (; *prev_cb != NULL; prev_cb = &curr_cb->next) { |
| 1756 | curr_cb = *prev_cb; |
| 1757 | if (curr_cb == cb) { |
| 1758 | /* Remove the user cb from the callback list. */ |
| 1759 | rte_atomic_store_explicit(prev_cb, curr_cb->next, |
| 1760 | rte_memory_order_relaxed); |