| 179 | } |
| 180 | |
| 181 | static inline int |
| 182 | rte_compressdev_data_alloc(uint8_t dev_id, struct rte_compressdev_data **data, |
| 183 | int socket_id) |
| 184 | { |
| 185 | char mz_name[RTE_COMPRESSDEV_NAME_MAX_LEN]; |
| 186 | const struct rte_memzone *mz; |
| 187 | int n; |
| 188 | |
| 189 | /* generate memzone name */ |
| 190 | n = snprintf(mz_name, sizeof(mz_name), |
| 191 | "rte_compressdev_data_%u", dev_id); |
| 192 | if (n >= (int)sizeof(mz_name)) |
| 193 | return -EINVAL; |
| 194 | |
| 195 | if (rte_eal_process_type() == RTE_PROC_PRIMARY) { |
| 196 | mz = rte_memzone_reserve(mz_name, |
| 197 | sizeof(struct rte_compressdev_data), |
| 198 | socket_id, 0); |
| 199 | } else |
| 200 | mz = rte_memzone_lookup(mz_name); |
| 201 | |
| 202 | if (mz == NULL) |
| 203 | return -ENOMEM; |
| 204 | |
| 205 | *data = mz->addr; |
| 206 | if (rte_eal_process_type() == RTE_PROC_PRIMARY) |
| 207 | memset(*data, 0, sizeof(struct rte_compressdev_data)); |
| 208 | |
| 209 | return 0; |
| 210 | } |
| 211 | |
| 212 | static uint8_t |
| 213 | rte_compressdev_find_free_device_index(void) |
no test coverage detected