net/ice/base: add get/set functions for shared parameters
[dpdk.git] / drivers / common / cpt / cpt_ucode.h
index ee6d49a..006411c 100644 (file)
@@ -561,8 +561,7 @@ cpt_digest_gen_prep(uint32_t flags,
        i = 0;
 
        if (ctx->hmac) {
-               uint64_t k_dma = params->ctx_buf.dma_addr +
-                       offsetof(struct cpt_ctx, auth_key);
+               uint64_t k_dma = ctx->auth_key_iova;
                /* Key */
                i = fill_sg_comp(gather_comp, i, k_dma,
                                 RTE_ALIGN_CEIL(key_len, 8));
@@ -1001,6 +1000,16 @@ cpt_enc_hmac_prep(uint32_t flags,
                req->ist.ei2 = rptr_dma;
        }
 
+       if (unlikely((encr_offset >> 16) ||
+                    (iv_offset >> 8) ||
+                    (auth_offset >> 8))) {
+               CPT_LOG_DP_ERR("Offset not supported");
+               CPT_LOG_DP_ERR("enc_offset: %d", encr_offset);
+               CPT_LOG_DP_ERR("iv_offset : %d", iv_offset);
+               CPT_LOG_DP_ERR("auth_offset: %d", auth_offset);
+               return;
+       }
+
        /* 16 byte aligned cpt res address */
        req->completion_addr = (uint64_t *)((uint8_t *)c_vaddr);
        *req->completion_addr = COMPLETION_CODE_INIT;
@@ -1184,6 +1193,16 @@ cpt_dec_hmac_prep(uint32_t flags,
                        dest[1] = src[1];
                }
 
+               if (unlikely((encr_offset >> 16) ||
+                            (iv_offset >> 8) ||
+                            (auth_offset >> 8))) {
+                       CPT_LOG_DP_ERR("Offset not supported");
+                       CPT_LOG_DP_ERR("enc_offset: %d", encr_offset);
+                       CPT_LOG_DP_ERR("iv_offset : %d", iv_offset);
+                       CPT_LOG_DP_ERR("auth_offset: %d", auth_offset);
+                       return;
+               }
+
                *(uint64_t *)offset_vaddr =
                        rte_cpu_to_be_64(((uint64_t)encr_offset << 16) |
                                ((uint64_t)iv_offset << 8) |
@@ -1215,6 +1234,16 @@ cpt_dec_hmac_prep(uint32_t flags,
                        dest[1] = src[1];
                }
 
+               if (unlikely((encr_offset >> 16) ||
+                            (iv_offset >> 8) ||
+                            (auth_offset >> 8))) {
+                       CPT_LOG_DP_ERR("Offset not supported");
+                       CPT_LOG_DP_ERR("enc_offset: %d", encr_offset);
+                       CPT_LOG_DP_ERR("iv_offset : %d", iv_offset);
+                       CPT_LOG_DP_ERR("auth_offset: %d", auth_offset);
+                       return;
+               }
+
                *(uint64_t *)offset_vaddr =
                        rte_cpu_to_be_64(((uint64_t)encr_offset << 16) |
                                ((uint64_t)iv_offset << 8) |
@@ -1492,6 +1521,14 @@ cpt_zuc_snow3g_enc_prep(uint32_t req_flags,
                offset_ctrl = rte_cpu_to_be_64((uint64_t)encr_offset << 16);
        }
 
+       if (unlikely((encr_offset >> 16) ||
+                    (auth_offset >> 8))) {
+               CPT_LOG_DP_ERR("Offset not supported");
+               CPT_LOG_DP_ERR("enc_offset: %d", encr_offset);
+               CPT_LOG_DP_ERR("auth_offset: %d", auth_offset);
+               return;
+       }
+
        /* IV */
        iv_s = (flags == 0x1) ? params->auth_iv_buf :
                params->iv_buf;
@@ -1934,6 +1971,12 @@ cpt_zuc_snow3g_dec_prep(uint32_t req_flags,
                req->ist.ei2 = rptr_dma;
        }
 
+       if (unlikely((encr_offset >> 16))) {
+               CPT_LOG_DP_ERR("Offset not supported");
+               CPT_LOG_DP_ERR("enc_offset: %d", encr_offset);
+               return;
+       }
+
        /* 16 byte aligned cpt res address */
        req->completion_addr = (uint64_t *)((uint8_t *)c_vaddr);
        *req->completion_addr = COMPLETION_CODE_INIT;
@@ -2068,11 +2111,21 @@ cpt_kasumi_enc_prep(uint32_t req_flags,
                outputlen = inputlen;
                /* iv offset is 0 */
                *offset_vaddr = rte_cpu_to_be_64((uint64_t)encr_offset << 16);
+               if (unlikely((encr_offset >> 16))) {
+                       CPT_LOG_DP_ERR("Offset not supported");
+                       CPT_LOG_DP_ERR("enc_offset: %d", encr_offset);
+                       return;
+               }
        } else {
                inputlen = auth_offset + (RTE_ALIGN(auth_data_len, 8) / 8);
                outputlen = mac_len;
                /* iv offset is 0 */
                *offset_vaddr = rte_cpu_to_be_64((uint64_t)auth_offset);
+               if (unlikely((auth_offset >> 8))) {
+                       CPT_LOG_DP_ERR("Offset not supported");
+                       CPT_LOG_DP_ERR("auth_offset: %d", auth_offset);
+                       return;
+               }
        }
 
        i = fill_sg_comp(gather_comp, i, offset_dma, OFF_CTRL_LEN + iv_len);
@@ -2285,6 +2338,11 @@ cpt_kasumi_dec_prep(uint64_t d_offs,
 
        /* Offset control word followed by iv */
        *offset_vaddr = rte_cpu_to_be_64((uint64_t)encr_offset << 16);
+       if (unlikely((encr_offset >> 16))) {
+               CPT_LOG_DP_ERR("Offset not supported");
+               CPT_LOG_DP_ERR("enc_offset: %d", encr_offset);
+               return;
+       }
 
        i = fill_sg_comp(gather_comp, i, offset_dma, OFF_CTRL_LEN + iv_len);
 
@@ -2492,7 +2550,12 @@ cpt_fc_auth_set_key(struct cpt_ctx *cpt_ctx, auth_type_t type,
 
        if (key_len) {
                cpt_ctx->hmac = 1;
-               memset(cpt_ctx->auth_key, 0, sizeof(cpt_ctx->auth_key));
+
+               cpt_ctx->auth_key = rte_zmalloc(NULL, key_len, 8);
+               if (cpt_ctx->auth_key == NULL)
+                       return -1;
+
+               cpt_ctx->auth_key_iova = rte_mem_virt2iova(cpt_ctx->auth_key);
                memcpy(cpt_ctx->auth_key, key, key_len);
                cpt_ctx->auth_key_len = key_len;
                memset(fctx->hmac.ipad, 0, sizeof(fctx->hmac.ipad));