| 972 | } |
| 973 | |
| 974 | static inline int |
| 975 | rte_cryptodev_data_alloc(uint8_t dev_id, struct rte_cryptodev_data **data, |
| 976 | int socket_id) |
| 977 | { |
| 978 | char mz_name[RTE_MEMZONE_NAMESIZE]; |
| 979 | const struct rte_memzone *mz; |
| 980 | int n; |
| 981 | |
| 982 | /* generate memzone name */ |
| 983 | n = snprintf(mz_name, sizeof(mz_name), "rte_cryptodev_data_%u", dev_id); |
| 984 | if (n >= (int)sizeof(mz_name)) |
| 985 | return -EINVAL; |
| 986 | |
| 987 | if (rte_eal_process_type() == RTE_PROC_PRIMARY) { |
| 988 | mz = rte_memzone_reserve(mz_name, |
| 989 | sizeof(struct rte_cryptodev_data), |
| 990 | socket_id, 0); |
| 991 | CDEV_LOG_DEBUG("PRIMARY:reserved memzone for %s (%p)", |
| 992 | mz_name, mz); |
| 993 | } else { |
| 994 | mz = rte_memzone_lookup(mz_name); |
| 995 | CDEV_LOG_DEBUG("SECONDARY:looked up memzone for %s (%p)", |
| 996 | mz_name, mz); |
| 997 | } |
| 998 | |
| 999 | if (mz == NULL) |
| 1000 | return -ENOMEM; |
| 1001 | |
| 1002 | *data = mz->addr; |
| 1003 | if (rte_eal_process_type() == RTE_PROC_PRIMARY) |
| 1004 | memset(*data, 0, sizeof(struct rte_cryptodev_data)); |
| 1005 | |
| 1006 | return 0; |
| 1007 | } |
| 1008 | |
| 1009 | static inline int |
| 1010 | rte_cryptodev_data_free(uint8_t dev_id, struct rte_cryptodev_data **data) |
no test coverage detected