MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rte_cryptodev_queue_pairs_config

Function rte_cryptodev_queue_pairs_config

dpdk/lib/cryptodev/rte_cryptodev.c:1159–1221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1157}
1158
1159static int
1160rte_cryptodev_queue_pairs_config(struct rte_cryptodev *dev, uint16_t nb_qpairs,
1161 int socket_id)
1162{
1163 struct rte_cryptodev_info dev_info;
1164 void **qp;
1165 unsigned i;
1166
1167 if ((dev == NULL) || (nb_qpairs < 1)) {
1168 CDEV_LOG_ERR("invalid param: dev %p, nb_queues %u",
1169 dev, nb_qpairs);
1170 return -EINVAL;
1171 }
1172
1173 CDEV_LOG_DEBUG("Setup %d queues pairs on device %u",
1174 nb_qpairs, dev->data->dev_id);
1175
1176 memset(&dev_info, 0, sizeof(struct rte_cryptodev_info));
1177
1178 if (*dev->dev_ops->dev_infos_get == NULL)
1179 return -ENOTSUP;
1180 (*dev->dev_ops->dev_infos_get)(dev, &dev_info);
1181
1182 if (nb_qpairs > (dev_info.max_nb_queue_pairs)) {
1183 CDEV_LOG_ERR("Invalid num queue_pairs (%u) for dev %u",
1184 nb_qpairs, dev->data->dev_id);
1185 return -EINVAL;
1186 }
1187
1188 if (dev->data->queue_pairs == NULL) { /* first time configuration */
1189 dev->data->queue_pairs = rte_zmalloc_socket(
1190 "cryptodev->queue_pairs",
1191 sizeof(dev->data->queue_pairs[0]) *
1192 dev_info.max_nb_queue_pairs,
1193 RTE_CACHE_LINE_SIZE, socket_id);
1194
1195 if (dev->data->queue_pairs == NULL) {
1196 dev->data->nb_queue_pairs = 0;
1197 CDEV_LOG_ERR("failed to get memory for qp meta data, "
1198 "nb_queues %u",
1199 nb_qpairs);
1200 return -(ENOMEM);
1201 }
1202 } else { /* re-configure */
1203 int ret;
1204 uint16_t old_nb_queues = dev->data->nb_queue_pairs;
1205
1206 qp = dev->data->queue_pairs;
1207
1208 if (*dev->dev_ops->queue_pair_release == NULL)
1209 return -ENOTSUP;
1210
1211 for (i = nb_qpairs; i < old_nb_queues; i++) {
1212 ret = (*dev->dev_ops->queue_pair_release)(dev, i);
1213 if (ret < 0)
1214 return ret;
1215 qp[i] = NULL;
1216 }

Callers 1

rte_cryptodev_configureFunction · 0.85

Calls 2

memsetFunction · 0.85
rte_zmalloc_socketFunction · 0.85

Tested by

no test coverage detected