Skip to content

Commit

Permalink
eventdev/crypto: fix multi-process
Browse files Browse the repository at this point in the history
[ upstream commit 8f4ff7d ]

Secondary process is not able to call the crypto adapter
APIs stats get/reset as crypto adapter memzone memory
is not accessible by secondary process.

Added memzone lookup so that secondary process can call the
crypto adapter APIs(stats_get etc)

Fixes: 7901eac ("eventdev: add crypto adapter implementation")

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
Acked-by: Abhinandan Gujjar <abhinandan.gujjar@intel.com>
  • Loading branch information
gkundap authored and kevintraynor committed Nov 1, 2022
1 parent 050edd6 commit 11b702a
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions lib/eventdev/rte_event_crypto_adapter.c
Expand Up @@ -30,6 +30,8 @@
*/
#define CRYPTO_ENQ_FLUSH_THRESHOLD 1024

#define ECA_ADAPTER_ARRAY "crypto_adapter_array"

struct event_crypto_adapter {
/* Event device identifier */
uint8_t eventdev_id;
Expand Down Expand Up @@ -118,17 +120,17 @@ eca_valid_id(uint8_t id)
static int
eca_init(void)
{
const char *name = "crypto_adapter_array";
const struct rte_memzone *mz;
unsigned int sz;

sz = sizeof(*event_crypto_adapter) *
RTE_EVENT_CRYPTO_ADAPTER_MAX_INSTANCE;
sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);

mz = rte_memzone_lookup(name);
mz = rte_memzone_lookup(ECA_ADAPTER_ARRAY);
if (mz == NULL) {
mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
mz = rte_memzone_reserve_aligned(ECA_ADAPTER_ARRAY, sz,
rte_socket_id(), 0,
RTE_CACHE_LINE_SIZE);
if (mz == NULL) {
RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
Expand All @@ -141,6 +143,22 @@ eca_init(void)
return 0;
}

static int
eca_memzone_lookup(void)
{
const struct rte_memzone *mz;

if (event_crypto_adapter == NULL) {
mz = rte_memzone_lookup(ECA_ADAPTER_ARRAY);
if (mz == NULL)
return -ENOMEM;

event_crypto_adapter = mz->addr;
}

return 0;
}

static inline struct event_crypto_adapter *
eca_id_to_adapter(uint8_t id)
{
Expand Down Expand Up @@ -1051,6 +1069,9 @@ rte_event_crypto_adapter_stats_get(uint8_t id,
uint32_t i;
int ret;

if (eca_memzone_lookup())
return -ENOMEM;

EVENT_CRYPTO_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);

adapter = eca_id_to_adapter(id);
Expand Down Expand Up @@ -1092,6 +1113,9 @@ rte_event_crypto_adapter_stats_reset(uint8_t id)
struct rte_eventdev *dev;
uint32_t i;

if (eca_memzone_lookup())
return -ENOMEM;

EVENT_CRYPTO_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);

adapter = eca_id_to_adapter(id);
Expand Down

0 comments on commit 11b702a

Please sign in to comment.