Skip to content

Commit

Permalink
event/cnxk: fix return values for capability API
Browse files Browse the repository at this point in the history
[ upstream commit bccb1d4f10e12c396058c06c3ba9e3565633390e ]

When event_cnxk or crypto_cnxk PMDs are not available,
return -ENOTSUP instead of -EINVAL.
This would allow unit test to be skipped when
the devices are not available.

Fixes: 19f81cb ("event/cnxk: add crypto adapter operations")

Signed-off-by: Aakash Sasidharan <asasidharan@marvell.com>
Acked-by: Anoob Joseph <anoobj@marvell.com>
  • Loading branch information
asasidharan authored and kevintraynor committed Oct 31, 2023
1 parent d31f9b2 commit 107d68a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions drivers/event/cnxk/cn10k_eventdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,8 @@ static int
cn10k_crypto_adapter_caps_get(const struct rte_eventdev *event_dev,
const struct rte_cryptodev *cdev, uint32_t *caps)
{
CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k");
CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn10k");
CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", ENOTSUP);
CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn10k", ENOTSUP);

*caps = RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD |
RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA;
Expand All @@ -767,8 +767,8 @@ cn10k_crypto_adapter_qp_add(const struct rte_eventdev *event_dev,

RTE_SET_USED(event);

CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k");
CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn10k");
CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", EINVAL);
CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn10k", EINVAL);

dev->is_ca_internal_port = 1;
cn10k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
Expand All @@ -781,8 +781,8 @@ cn10k_crypto_adapter_qp_del(const struct rte_eventdev *event_dev,
const struct rte_cryptodev *cdev,
int32_t queue_pair_id)
{
CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k");
CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn10k");
CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", EINVAL);
CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn10k", EINVAL);

return cnxk_crypto_adapter_qp_del(cdev, queue_pair_id);
}
Expand Down
16 changes: 8 additions & 8 deletions drivers/event/cnxk/cn9k_eventdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,11 +996,11 @@ cn9k_sso_tx_adapter_queue_del(uint8_t id, const struct rte_eventdev *event_dev,
}

static int
cn9k_crypto_adapter_caps_get(const struct rte_eventdev *event_dev,
const struct rte_cryptodev *cdev, uint32_t *caps)
cn9k_crypto_adapter_caps_get(const struct rte_eventdev *event_dev, const struct rte_cryptodev *cdev,
uint32_t *caps)
{
CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn9k");
CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn9k");
CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn9k", ENOTSUP);
CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn9k", ENOTSUP);

*caps = RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD |
RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA;
Expand All @@ -1017,8 +1017,8 @@ cn9k_crypto_adapter_qp_add(const struct rte_eventdev *event_dev,

RTE_SET_USED(event);

CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn9k");
CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn9k");
CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn9k", EINVAL);
CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn9k", EINVAL);

dev->is_ca_internal_port = 1;
cn9k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
Expand All @@ -1031,8 +1031,8 @@ cn9k_crypto_adapter_qp_del(const struct rte_eventdev *event_dev,
const struct rte_cryptodev *cdev,
int32_t queue_pair_id)
{
CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn9k");
CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn9k");
CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn9k", EINVAL);
CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn9k", EINVAL);

return cnxk_crypto_adapter_qp_del(cdev, queue_pair_id);
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/event/cnxk/cnxk_eventdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
#define CN10K_GW_MODE_PREF 1
#define CN10K_GW_MODE_PREF_WFE 2

#define CNXK_VALID_DEV_OR_ERR_RET(dev, drv_name) \
#define CNXK_VALID_DEV_OR_ERR_RET(dev, drv_name, err_val) \
do { \
if (strncmp(dev->driver->name, drv_name, strlen(drv_name))) \
return -EINVAL; \
return -err_val; \
} while (0)

typedef void *(*cnxk_sso_init_hws_mem_t)(void *dev, uint8_t port_id);
Expand Down

0 comments on commit 107d68a

Please sign in to comment.