From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E218D433F5; Wed, 29 Nov 2023 03:43:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5325942E59; Wed, 29 Nov 2023 03:42:47 +0100 (CET) Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) by mails.dpdk.org (Postfix) with ESMTP id 3C78442E35 for ; Wed, 29 Nov 2023 03:42:43 +0100 (CET) Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-3b85dcecc62so2307271b6e.2 for ; Tue, 28 Nov 2023 18:42:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1701225762; x=1701830562; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5PaHYNcOwezwar+iyevsLsJ0uFN1l62vmsHlZdUG6s4=; b=Gz3UZudUpYznjqxPpi2h24GuRoQs+1fvmhpmLhvJs9NRwIKRbEpdcpX5dGPf2RuM6k /z584bK6mi2aOlQrwnw5CYu8MsiDtQ9pSGjSSA914I+PXYk4sx1+HftcUmPsxaZGNW5K uqaOIX7gPEf+GjUmDx8b3qxQEVxuP6ydLQoL3Mvo/Ef/JWrlgAENMRQEzGZgVuSL2Rfb d/QpQkxPwMNZj4RFErWqt0NlxzS7ze6ZTEbiUSwZd67pp8wSkJiMTlzVpaGZfp+qzu7l JR84q1ItquGdYvpibatgzpW73t41ZehH92YAEgZWBWGEv5j7kixWpybII6ZivE4rf5Dt 9ESw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701225762; x=1701830562; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5PaHYNcOwezwar+iyevsLsJ0uFN1l62vmsHlZdUG6s4=; b=TzZQA6TrZ+hBhH1uE81HFTA9SV4P5MlIBIS7LJ5F0WIStv8aBZ8nleRauzWVKv0l5/ 8tZAbI/LLb81zYy0m6kU3WCkR2kgGQQ6iD54mAgCQfqg57OUsyDA2T1s4qWTTMbxzdl4 i6jNpQMcxrVEg4ubpDwFalXpR6IVof6rAPTdIQsX8z5w/rn8l+O72vKh9jpR95xOYsfE OlAe0bmRQGd0IEJ57K/Wc8XIQCf9Mkq8WH+DcNqy+e4HzHbhRIhKwUcW98wNyqlgJt6i hkVZ+HLzFDX9B4CegvB0DCnWB5DPFdIWm/BbFkqPN/orL1B4hPoT2V9x0b34N7/6PDMk 46jw== X-Gm-Message-State: AOJu0YxsSMTIuABv9HnI3jwbRod+AMqoUZpl/GE1lkZROAXa4UetkhSO dCvQW/dwUDTDLl3NXAgzugAt4wA1jDGygjpdV7M= X-Google-Smtp-Source: AGHT+IGXMVXIGkaMqSO/tvzRcAUaNoDu/9hVcIWcjXiVLcB5oWhrG2jP3u7DKVpcpC5QOzTvqqbgzw== X-Received: by 2002:a05:6808:320d:b0:3b8:93dd:18a4 with SMTP id cb13-20020a056808320d00b003b893dd18a4mr2109117oib.19.1701225762332; Tue, 28 Nov 2023 18:42:42 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id j17-20020aa78011000000b006cb95f6aa0fsm9674900pfi.150.2023.11.28.18.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 18:42:41 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Hemant Agrawal , Sachin Saxena Subject: [PATCH v5 10/10] common/dpaxx: replace zero length array Date: Tue, 28 Nov 2023 18:39:17 -0800 Message-ID: <20231129024221.57653-11-stephen@networkplumber.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231129024221.57653-1-stephen@networkplumber.org> References: <20230113215205.125767-1-stephen@networkplumber.org> <20231129024221.57653-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The zero length ip_header is used as an overlay to the encap IP header. Since the code is already assuming the layout of the structure, replace the array with direct access. Signed-off-by: Stephen Hemminger Acked-by: Hemant Agrawal --- drivers/common/dpaax/caamflib/desc/ipsec.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/common/dpaax/caamflib/desc/ipsec.h b/drivers/common/dpaax/caamflib/desc/ipsec.h index 95fc3ea5ba3b..d1411cc6aab4 100644 --- a/drivers/common/dpaax/caamflib/desc/ipsec.h +++ b/drivers/common/dpaax/caamflib/desc/ipsec.h @@ -334,9 +334,7 @@ struct ipsec_encap_gcm { * @seq_num: IPsec sequence number * @spi: IPsec SPI (Security Parameters Index) * @ip_hdr_len: optional IP Header length (in bytes) - * reserved - 16b - * Opt. IP Hdr Len - 16b - * @ip_hdr: optional IP Header content (only for IPsec legacy mode) + * Ip header must follow directly after ipsec_encap_pdb */ struct ipsec_encap_pdb { uint32_t options; @@ -350,7 +348,6 @@ struct ipsec_encap_pdb { }; uint32_t spi; uint32_t ip_hdr_len; - uint8_t ip_hdr[0]; }; static inline unsigned int @@ -776,7 +773,12 @@ cnstr_shdsc_ipsec_encap(uint32_t *descbuf, bool ps, bool swap, PROGRAM_SET_36BIT_ADDR(p); phdr = SHR_HDR(p, share, hdr, 0); __rta_copy_ipsec_encap_pdb(p, pdb, cipherdata->algtype); - COPY_DATA(p, pdb->ip_hdr, pdb->ip_hdr_len); + + /* ip header if any follows the encap_pdb */ + if (pdb->ip_hdr_len > 0) { + void *ip_hdr = pdb + 1; + COPY_DATA(p, ip_hdr, pdb->ip_hdr_len); + } SET_LABEL(p, hdr); pkeyjmp = JUMP(p, keyjmp, LOCAL_JUMP, ALL_TRUE, BOTH|SHRD); if (authdata->keylen) @@ -913,7 +915,13 @@ cnstr_shdsc_ipsec_encap_des_aes_xcbc(uint32_t *descbuf, PROGRAM_CNTXT_INIT(p, descbuf, 0); phdr = SHR_HDR(p, share, hdr, 0); __rta_copy_ipsec_encap_pdb(p, pdb, cipherdata->algtype); - COPY_DATA(p, pdb->ip_hdr, pdb->ip_hdr_len); + + /* ip header if any follows the encap_pdb */ + if (pdb->ip_hdr_len > 0) { + void *ip_hdr = pdb + 1; + COPY_DATA(p, ip_hdr, pdb->ip_hdr_len); + } + SET_LABEL(p, hdr); pkeyjump = JUMP(p, keyjump, LOCAL_JUMP, ALL_TRUE, SHRD | SELF); /* -- 2.42.0