From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2F28FA0526; Wed, 8 Jul 2020 14:29:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0BD711DBBC; Wed, 8 Jul 2020 14:29:54 +0200 (CEST) Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) by dpdk.org (Postfix) with ESMTP id 0468F1DE6E for ; Tue, 7 Jul 2020 17:25:50 +0200 (CEST) Received: by mail-io1-f66.google.com with SMTP id i4so43519633iov.11 for ; Tue, 07 Jul 2020 08:25:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7bOPNTOjfzDr2v6VYvED9lZFWH3Dz8i+lKvp4LTZa+U=; b=I7uCO4HEk5lSJRnt3RYUOvX06Ff2I1jw6iCixmqYBm7wjaDNtDg4nRyRYRNMifxagF zOfJYyHLHC01Yckr0rTd6RwRDJ3fGOK9xDcm2RXmag8CzL2ytM7GeWyuUF4ER4Hhhlk1 M8WiWrR7qV/zELMEUO7VazOppuFuRcbRmaySA82TOcW1ZDX5lFcNbOzPr9ykQozlhjbU xdHKSS7QWgYhdclV2wWHMD1EvoAOVweFHleV4I3L2n286mQ0bpBHDT/IjAVPN7V/LVEB BQbM6o97JO0COSOsAA3u53ZpCVXl1UTR+RyAKDglMXGqGPzveRpIOGuSCNcG9CZ22Z28 mEgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7bOPNTOjfzDr2v6VYvED9lZFWH3Dz8i+lKvp4LTZa+U=; b=M0Sls2ilor66U/S16W4MQLDsfZ3OguIhvEDPQHSQPNEGaBg7geOvfnnNIZ7QenWs4f 2C4gWM+nuhyOwqqosPzGHgW+MkzFETHiW6JR1GTLPAYwxvEUgnSAlVPPfzgOBNPQNBlh 6gUDCHd0Ghg/ICHVZWCguSJM8jKzHoqixyiskVwmUFD7b6iixQwuFaw9Zf/iwjlfoLZJ ZtWFPQiNgghPK7pdRpUIAACHFsnfXHuxbFGiMrm2v4xqTp7p/CzWB6RnmYw/wZBMuoTR 3RxKwKVB4BKrU2m7VJ54oJRbVAaA0rHAx6Uui9FvkljlSOpjxD8pEJfmDmghn87DtLRC vPyw== X-Gm-Message-State: AOAM530LH6POxgKtvJ7YdBP1IeDHuo6cjCdta3T7JAyqMH9zvbOAiLIl fBcQH6lxpvq7ONDVhQN7od3+rFxS6UnfUCInTEk= X-Google-Smtp-Source: ABdhPJwM968V7mH3Nfefo808iCjotxnuyZnNr2PwrIm8jTFJDIRoGoDXnYXphbYj0C46TJ+U7OWTT0ZMYB8gcXskVJU= X-Received: by 2002:a05:6638:2a9:: with SMTP id d9mr54600640jaq.111.1594135549266; Tue, 07 Jul 2020 08:25:49 -0700 (PDT) MIME-Version: 1.0 References: <20200707122643.29222-1-levendsayar@gmail.com> In-Reply-To: From: Levend Sayar Date: Tue, 7 Jul 2020 18:25:13 +0300 Message-ID: To: "Ananyev, Konstantin" Cc: "dev@dpdk.org" X-Mailman-Approved-At: Wed, 08 Jul 2020 14:29:52 +0200 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH] acl: Fix RTE_ACL_RULE_SZ macro definition X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Sure. I am really sorry for not being verbose enough. >From lib/librte_acl/rte_acl.h #define RTE_ACL_RULE_DEF(name, fld_num) struct name {\ struct rte_acl_rule_data data; \ struct rte_acl_field field[fld_num]; \ } RTE_ACL_RULE_DEF(rte_acl_rule,); When you put the definition in-place, above line means : struct rte_acl_rule { struct rte_acl_rule_data data; struct rte_acl_field field[]; } There is another define to get the size of an acl rule such as #define RTE_ACL_RULE_SZ(fld_num) \ (sizeof(struct rte_acl_rule) + sizeof(struct rte_acl_field) * (fld_num)) So the above definition gets the size of a "struct rte_acl_rule" which has fld_num fields. which must be *sizeof (struct rte_acl_rule_data) *+ (sizeof(struct rte_acl_field) * fld_num) Because it adds up the sizes of struct components; But according to the current RTE_ACL_RULE_SZ, it is *sizeof (struct rte_acl_rule)* + (sizeof(struct rte_acl_field) * fld_num) So my patch only changes the part that I underlined. sizeof (struct rte_acl_rule) = 16; sizeof (struct rte_acl_rule_data) = 12; Best, Levend On Tue, Jul 7, 2020 at 3:42 PM Ananyev, Konstantin < konstantin.ananyev@intel.com> wrote: > > > From: Levend Sayar > > Could you provide some explanation: > What do you think is wrong with current version and why, > and what your fix does. > > > > > Signed-off-by: Levend Sayar > > --- > > lib/librte_acl/rte_acl.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/lib/librte_acl/rte_acl.h b/lib/librte_acl/rte_acl.h > > index aa22e70c6..d34fdbc0e 100644 > > --- a/lib/librte_acl/rte_acl.h > > +++ b/lib/librte_acl/rte_acl.h > > @@ -116,7 +116,7 @@ struct rte_acl_rule_data { > > RTE_ACL_RULE_DEF(rte_acl_rule,); > > > > #define RTE_ACL_RULE_SZ(fld_num) \ > > - (sizeof(struct rte_acl_rule) + sizeof(struct rte_acl_field) * > (fld_num)) > > + (sizeof(struct rte_acl_rule_data) + sizeof(struct rte_acl_field) * > (fld_num)) > > > > > > /** Max number of characters in name.*/ > > -- > > 2.27.0 > >