net/bnxt: ignore VLAN priority mask
[dpdk.git] / lib / librte_vhost / vhost_crypto.c
index 8652a77..0f9df40 100644 (file)
@@ -40,7 +40,8 @@
                (1 << VIRTIO_RING_F_EVENT_IDX) |                        \
                (1 << VIRTIO_CRYPTO_SERVICE_CIPHER) |                   \
                (1 << VIRTIO_CRYPTO_SERVICE_MAC) |                      \
-               (1 << VIRTIO_NET_F_CTRL_VQ))
+               (1 << VIRTIO_NET_F_CTRL_VQ) |                           \
+               (1 << VHOST_USER_PROTOCOL_F_CONFIG))
 
 #define IOVA_TO_VVA(t, r, a, l, p)                                     \
        ((t)(uintptr_t)vhost_iova_to_vva(r->dev, r->vq, a, l, p))
@@ -237,6 +238,11 @@ transform_cipher_param(struct rte_crypto_sym_xform *xform,
        if (unlikely(ret < 0))
                return ret;
 
+       if (param->cipher_key_len > VHOST_USER_CRYPTO_MAX_CIPHER_KEY_LENGTH) {
+               VC_LOG_DBG("Invalid cipher key length\n");
+               return -VIRTIO_CRYPTO_BADMSG;
+       }
+
        xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
        xform->cipher.key.length = param->cipher_key_len;
        if (xform->cipher.key.length > 0)
@@ -287,6 +293,12 @@ transform_chain_param(struct rte_crypto_sym_xform *xforms,
                        &xform_cipher->cipher.algo);
        if (unlikely(ret < 0))
                return ret;
+
+       if (param->cipher_key_len > VHOST_USER_CRYPTO_MAX_CIPHER_KEY_LENGTH) {
+               VC_LOG_DBG("Invalid cipher key length\n");
+               return -VIRTIO_CRYPTO_BADMSG;
+       }
+
        xform_cipher->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
        xform_cipher->cipher.key.length = param->cipher_key_len;
        xform_cipher->cipher.key.data = param->cipher_key_buf;
@@ -301,6 +313,12 @@ transform_chain_param(struct rte_crypto_sym_xform *xforms,
        ret = auth_algo_transform(param->hash_algo, &xform_auth->auth.algo);
        if (unlikely(ret < 0))
                return ret;
+
+       if (param->auth_key_len > VHOST_USER_CRYPTO_MAX_HMAC_KEY_LENGTH) {
+               VC_LOG_DBG("Invalid auth key length\n");
+               return -VIRTIO_CRYPTO_BADMSG;
+       }
+
        xform_auth->auth.digest_length = param->digest_len;
        xform_auth->auth.key.length = param->auth_key_len;
        xform_auth->auth.key.data = param->auth_key_buf;
@@ -1347,7 +1365,7 @@ vhost_crypto_complete_one_vm_requests(struct rte_crypto_op **ops,
        return processed;
 }
 
-int __rte_experimental
+int
 rte_vhost_crypto_create(int vid, uint8_t cryptodev_id,
                struct rte_mempool *sess_pool,
                struct rte_mempool *sess_priv_pool,
@@ -1440,7 +1458,7 @@ error_exit:
        return ret;
 }
 
-int __rte_experimental
+int
 rte_vhost_crypto_free(int vid)
 {
        struct virtio_net *dev = get_device(vid);
@@ -1469,7 +1487,7 @@ rte_vhost_crypto_free(int vid)
        return 0;
 }
 
-int __rte_experimental
+int
 rte_vhost_crypto_set_zero_copy(int vid, enum rte_vhost_crypto_zero_copy option)
 {
        struct virtio_net *dev = get_device(vid);
@@ -1524,7 +1542,7 @@ rte_vhost_crypto_set_zero_copy(int vid, enum rte_vhost_crypto_zero_copy option)
        return 0;
 }
 
-uint16_t __rte_experimental
+uint16_t
 rte_vhost_crypto_fetch_requests(int vid, uint32_t qid,
                struct rte_crypto_op **ops, uint16_t nb_ops)
 {
@@ -1539,18 +1557,18 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid,
 
        if (unlikely(dev == NULL)) {
                VC_LOG_ERR("Invalid vid %i", vid);
-               return -EINVAL;
+               return 0;
        }
 
        if (unlikely(qid >= VHOST_MAX_QUEUE_PAIRS)) {
                VC_LOG_ERR("Invalid qid %u", qid);
-               return -EINVAL;
+               return 0;
        }
 
        vcrypto = (struct vhost_crypto *)dev->extern_data;
        if (unlikely(vcrypto == NULL)) {
                VC_LOG_ERR("Cannot find required data, is it initialized?");
-               return -ENOENT;
+               return 0;
        }
 
        vq = dev->virtqueue[qid];
@@ -1572,7 +1590,7 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid,
                if (unlikely(rte_mempool_get_bulk(vcrypto->mbuf_pool,
                                (void **)mbufs, count * 2) < 0)) {
                        VC_LOG_ERR("Insufficient memory");
-                       return -ENOMEM;
+                       return 0;
                }
 
                for (i = 0; i < count; i++) {
@@ -1602,7 +1620,7 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid,
                if (unlikely(rte_mempool_get_bulk(vcrypto->mbuf_pool,
                                (void **)mbufs, count) < 0)) {
                        VC_LOG_ERR("Insufficient memory");
-                       return -ENOMEM;
+                       return 0;
                }
 
                for (i = 0; i < count; i++) {
@@ -1634,7 +1652,7 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid,
        return i;
 }
 
-uint16_t __rte_experimental
+uint16_t
 rte_vhost_crypto_finalize_requests(struct rte_crypto_op **ops,
                uint16_t nb_ops, int *callfds, uint16_t *nb_callfds)
 {