| 984 | } |
| 985 | |
| 986 | int |
| 987 | rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event, |
| 988 | rte_bbdev_cb_fn cb_fn, void *cb_arg) |
| 989 | { |
| 990 | int ret = 0; |
| 991 | struct rte_bbdev_callback *cb, *next; |
| 992 | struct rte_bbdev *dev = get_dev(dev_id); |
| 993 | VALID_DEV_OR_RET_ERR(dev, dev_id); |
| 994 | |
| 995 | if (event >= RTE_BBDEV_EVENT_MAX) { |
| 996 | rte_bbdev_log(ERR, |
| 997 | "Invalid event type (%u), should be less than %u", |
| 998 | event, RTE_BBDEV_EVENT_MAX); |
| 999 | return -EINVAL; |
| 1000 | } |
| 1001 | |
| 1002 | if (cb_fn == NULL) { |
| 1003 | rte_bbdev_log(ERR, |
| 1004 | "NULL callback function cannot be unregistered"); |
| 1005 | return -EINVAL; |
| 1006 | } |
| 1007 | |
| 1008 | dev = &rte_bbdev_devices[dev_id]; |
| 1009 | rte_spinlock_lock(&rte_bbdev_cb_lock); |
| 1010 | |
| 1011 | for (cb = TAILQ_FIRST(&dev->list_cbs); cb != NULL; cb = next) { |
| 1012 | |
| 1013 | next = TAILQ_NEXT(cb, next); |
| 1014 | |
| 1015 | if (cb->cb_fn != cb_fn || cb->event != event || |
| 1016 | (cb_arg != (void *)-1 && cb->cb_arg != cb_arg)) |
| 1017 | continue; |
| 1018 | |
| 1019 | /* If this callback is not executing right now, remove it. */ |
| 1020 | if (cb->active == 0) { |
| 1021 | TAILQ_REMOVE(&(dev->list_cbs), cb, next); |
| 1022 | rte_free(cb); |
| 1023 | } else |
| 1024 | ret = -EAGAIN; |
| 1025 | } |
| 1026 | |
| 1027 | rte_spinlock_unlock(&rte_bbdev_cb_lock); |
| 1028 | return ret; |
| 1029 | } |
| 1030 | |
| 1031 | void |
| 1032 | rte_bbdev_pmd_callback_process(struct rte_bbdev *dev, |