X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_cryptodev%2Frte_cryptodev.c;h=6f5080c0c0eb08df0f830a0a7fae2efea77ce5da;hb=c3b047be7328c70e0542d40db15f847181208a22;hp=f15f65ba2a8020016d315bf5f509ef61d34ecf9a;hpb=afe605006075cc0c56db489b625d82b3a4bcde10;p=dpdk.git diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c index f15f65ba2a..6f5080c0c0 100644 --- a/lib/librte_cryptodev/rte_cryptodev.c +++ b/lib/librte_cryptodev/rte_cryptodev.c @@ -126,6 +126,7 @@ rte_crypto_cipher_algorithm_strings[] = { [RTE_CRYPTO_CIPHER_AES_CBC] = "aes-cbc", [RTE_CRYPTO_CIPHER_AES_CCM] = "aes-ccm", [RTE_CRYPTO_CIPHER_AES_CTR] = "aes-ctr", + [RTE_CRYPTO_CIPHER_AES_DOCSISBPI] = "aes-docsisbpi", [RTE_CRYPTO_CIPHER_AES_ECB] = "aes-ecb", [RTE_CRYPTO_CIPHER_AES_GCM] = "aes-gcm", [RTE_CRYPTO_CIPHER_AES_F8] = "aes-f8", @@ -134,6 +135,7 @@ rte_crypto_cipher_algorithm_strings[] = { [RTE_CRYPTO_CIPHER_ARC4] = "arc4", [RTE_CRYPTO_CIPHER_DES_CBC] = "des-cbc", + [RTE_CRYPTO_CIPHER_DES_DOCSISBPI] = "des-docsisbpi", [RTE_CRYPTO_CIPHER_NULL] = "null", @@ -252,7 +254,7 @@ static int parse_integer_arg(const char *key __rte_unused, const char *value, void *extra_args) { - int *i = (int *) extra_args; + int *i = extra_args; *i = atoi(value); if (*i < 0) { @@ -955,6 +957,8 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config) return -EBUSY; } + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP); + /* Setup new number of queue pairs and reconfigure device. */ diag = rte_cryptodev_queue_pairs_config(dev, config->nb_queue_pairs, config->socket_id); @@ -965,10 +969,14 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config) } /* Setup Session mempool for device */ - return rte_cryptodev_sym_session_pool_create(dev, + diag = rte_cryptodev_sym_session_pool_create(dev, config->session_mp.nb_objs, config->session_mp.cache_size, config->socket_id); + if (diag != 0) + return diag; + + return (*dev->dev_ops->dev_configure)(dev, config); } @@ -1375,7 +1383,7 @@ rte_cryptodev_sym_session_create(uint8_t dev_id, return NULL; } - sess = (struct rte_cryptodev_sym_session *)_sess; + sess = _sess; RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_configure, NULL); if (dev->dev_ops->session_configure(dev, xform, sess->_private) == @@ -1391,6 +1399,53 @@ rte_cryptodev_sym_session_create(uint8_t dev_id, return sess; } +int +rte_cryptodev_queue_pair_attach_sym_session(uint16_t qp_id, + struct rte_cryptodev_sym_session *sess) +{ + struct rte_cryptodev *dev; + + if (!rte_cryptodev_pmd_is_valid_dev(sess->dev_id)) { + CDEV_LOG_ERR("Invalid dev_id=%d", sess->dev_id); + return -EINVAL; + } + + dev = &rte_crypto_devices[sess->dev_id]; + + /* The API is optional, not returning error if driver do not suuport */ + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->qp_attach_session, 0); + if (dev->dev_ops->qp_attach_session(dev, qp_id, sess->_private)) { + CDEV_LOG_ERR("dev_id %d failed to attach qp: %d with session", + sess->dev_id, qp_id); + return -EPERM; + } + + return 0; +} + +int +rte_cryptodev_queue_pair_detach_sym_session(uint16_t qp_id, + struct rte_cryptodev_sym_session *sess) +{ + struct rte_cryptodev *dev; + + if (!rte_cryptodev_pmd_is_valid_dev(sess->dev_id)) { + CDEV_LOG_ERR("Invalid dev_id=%d", sess->dev_id); + return -EINVAL; + } + + dev = &rte_crypto_devices[sess->dev_id]; + + /* The API is optional, not returning error if driver do not suuport */ + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->qp_detach_session, 0); + if (dev->dev_ops->qp_detach_session(dev, qp_id, sess->_private)) { + CDEV_LOG_ERR("dev_id %d failed to detach qp: %d from session", + sess->dev_id, qp_id); + return -EPERM; + } + + return 0; +} struct rte_cryptodev_sym_session * rte_cryptodev_sym_session_free(uint8_t dev_id, struct rte_cryptodev_sym_session *sess)