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 E801F430A9; Fri, 25 Aug 2023 11:16:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 886D140695; Fri, 25 Aug 2023 11:16:03 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id D7522400D5 for ; Fri, 25 Aug 2023 11:16:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692954962; x=1724490962; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=LL5p9EzU48M8Jyy596j82QVq/kKmODs7Q54oDFrDIkI=; b=J7uarZfX1bvijLDns6jAnvpnm9dHZCgKbOzmXDHWUa6Pi5G+gV/gPLMh aqbc6f3EDNS2hfq2pI30jDVtOuAcLue//Dts4i8/8tp+bDxEZj3ZLgU+A lRv5Tu1bE/AUhUSdx9mNajanq7kxq4PEoKIwv/mujhJi2EXw2S/Fe+koI XRcAn+hw/7RfyvKvC4vCzcZSsGMnlM2pngCBWjkXW6JM4zN4root2GtTT wEgkwKL8OGbaah1Y63CJ0etIPzhTz6K41D6hj/goVPObZ3/DMHDWuC91/ r4OcMBoLuddFjWkRVkOJrR+ho7xqMVxOF/WIBdKNOg5pQ5fLBkuXeQhwb Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10812"; a="372069317" X-IronPort-AV: E=Sophos;i="6.02,195,1688454000"; d="scan'208";a="372069317" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2023 02:15:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10812"; a="861009923" X-IronPort-AV: E=Sophos;i="6.02,195,1688454000"; d="scan'208";a="861009923" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga004.jf.intel.com with ESMTP; 25 Aug 2023 02:15:54 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 25 Aug 2023 02:15:53 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 25 Aug 2023 02:15:53 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27 via Frontend Transport; Fri, 25 Aug 2023 02:15:53 -0700 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.41) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.27; Fri, 25 Aug 2023 02:15:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ihi6PCyheymEfAN4at/IaPkk4d2ESVRlmj7Grg0YvjJajxTe2AOWBdmSCXPySkpzIFX95YbQWPJg0h5CJC6bpaEpHs4buVVhHFxV908W7vy6r+qUHfgHAHRe0kj0iQH2j7L/o0MeJDVsBy7mY5/3ox04wz1B+jE1GMeUBWW7rQa1f0RcU39ntU8psRuzN/W2oubDBd75+sUaJ9DXXI4rx+Kt9gU+rkze5WH5Kw2pM5haSWLKGoDPNnVdgEHJnrBMzK0C68vUUiAuX7/UjuNBX/xJTWf0Qf3uEo+P8LCDdectkW1rcjtPrO7SmNYVBsbZBQ2LUK+GoR/Ido2IA5gcwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cX9hs/TIgv6WX59nwvhIf7VeI/gpDpK6uCsIdLMBnnI=; b=cUU9HoVEKpNwVPQ/vZlknVcnh1DY3NJLuHv9+hFn8UhexJBy5VLaAaGtYu4e+DGNJ9KozHDTtSKezfti99ubyz9IzSQ5j9yUxlp3NQLWmlOtQprh+9AEYhSxNRetMrhqgr/vTii4FHP4SQ6vSFkqI6PxtiE+L7bVeuLitoAxqvQOYlAmWQlm90yNoEF2/xkZdy8mmDmm5q7TXIk1Xlod8tXA5DC+ub3dwzpOBijh3C9u/7OkKUk4SKfcPgS0IIiAY1WWakra5NN1GHHVKm13+oDhxCj056EBG1HqE7kIctHeDoa8xpSS4SVqg/2CpCSuO8/gcS69uu15PD5g7Zim+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from LV2PR11MB5997.namprd11.prod.outlook.com (2603:10b6:408:17f::10) by SJ2PR11MB7716.namprd11.prod.outlook.com (2603:10b6:a03:4f2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.29; Fri, 25 Aug 2023 09:15:50 +0000 Received: from LV2PR11MB5997.namprd11.prod.outlook.com ([fe80::7423:9a2e:7dd5:e56]) by LV2PR11MB5997.namprd11.prod.outlook.com ([fe80::7423:9a2e:7dd5:e56%3]) with mapi id 15.20.6699.027; Fri, 25 Aug 2023 09:15:50 +0000 From: "Xing, Beilei" To: "Zhang, Yuying" , "dev@dpdk.org" , "Zhang, Qi Z" , "Wu, Jingjing" Subject: RE: [PATCH v1 5/5] net/cpfl: add fxp flow engine Thread-Topic: [PATCH v1 5/5] net/cpfl: add fxp flow engine Thread-Index: AQHZzO8tyXgF/h5xU0iz5eFGa/pirq/6tB0g Date: Fri, 25 Aug 2023 09:15:50 +0000 Message-ID: References: <20230812075506.361769-1-yuying.zhang@intel.com> <20230812075506.361769-6-yuying.zhang@intel.com> In-Reply-To: <20230812075506.361769-6-yuying.zhang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: LV2PR11MB5997:EE_|SJ2PR11MB7716:EE_ x-ms-office365-filtering-correlation-id: 7da55375-927d-49cf-7d45-08dba54bdfea x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 5ivi8XFUuc7QTbHSC7bTsBh5oJYU+aNtaOYr/EYACGEFZxWCSryAkz9Uz5U6d1t3ezrCOagGAsNf6JhBgVnDGN6Sk0NDFO/EFKR0n3/nJnuXVIFwTGNrpSJk8ny24R2oc4houkgsA+KnaMqMmd6t/dicANgPB0lwg5uK/WNE/RZGEVzEuhwpZOsVl3+M17X6fOXo99k+jKayO++i+ESB4dkKYr/3p5DbF7C5D89J2FrXarTsfM9J0MLwr8yjiTVCGDr93ooTXhDZAbRhUsYacIhW2iERkBSbHItiBflcde+cncbcfRDe2DAkUpirTMmI48PIWci/hhQi/RuELGThxsu2yb8kpY0kjTlu5AoL+QTOzWUzlcxJGW6pAVs6A8+EvDzwVEuBTFBqDHGxa/naWFVbrO+XDhUIKUSXVm9D2lj5JHeBJ+alej7Y7Yq3CtH4S5KVKkAKas3vRPX1g1x5MDPRlglF6BaKoJt2DmKjxk7iDvKEeaEUdbtquop431/dcuW5vLKoLU+Brxmr4NvBhwE+P5M2kNLPrmu48lahAVcyFYdDp+uvhgqsTLX4mxX7Njn2X+Ga5lUINqdHFcmsL0w60Th9SRuH2BXS4bYpWOBFVT8s5Rky3Uh2pM+c8cR7 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:LV2PR11MB5997.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39860400002)(136003)(376002)(396003)(346002)(366004)(451199024)(1800799009)(186009)(82960400001)(122000001)(38100700002)(38070700005)(8676002)(8936002)(64756008)(41300700001)(6506007)(53546011)(33656002)(316002)(66446008)(7696005)(6636002)(66476007)(66556008)(110136005)(66946007)(76116006)(86362001)(71200400001)(9686003)(55016003)(26005)(478600001)(83380400001)(2906002)(30864003)(52536014)(5660300002)(579004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?WkNvAlisfZD1HYtTYQ/Ox22k0KVDKzBuNxk6EOyaD2UqKiTlJ0cSur2TT1N6?= =?us-ascii?Q?Uxx9D5vv6816lDr0BkKorCWXKGbWp5bNdUgbHrx1pEXeFGmtGdvuXaRKucdM?= =?us-ascii?Q?DAgnxLd2Q6r+8/u9kFkftPkkhCmv5pUWK+E5qLy/K1vqSNIfWgJaGsaoF0cO?= =?us-ascii?Q?ubMk605WOXpw+Cj3NqfRk1XP1c+eEhDJWMD+5OdhU3MGZLJbG1x+Z5owdsk2?= =?us-ascii?Q?tiXlQLUi1hqS4ZkYWPxvwy78AglOtkg0bFqFOcC/e/8V6PHHaWwbpZ/gvbvW?= =?us-ascii?Q?DgmwMS2zYZkf1ZpOT2wxdDUy1wz13djIMUzk3uI76fins40q6+Id3QrJnbGV?= =?us-ascii?Q?Q8jritZvsKV8ef8tRvM3MhxpKZY4AnLVfylvcQ0ZcwuU7n9+TPajBVwC1Rtq?= =?us-ascii?Q?BmZoZKVZLKo2frjIEGAENQWgFTX89dHC+zoS/JdU6mQ3W08aiGXOFU+qXupC?= =?us-ascii?Q?YwJ87DDThIIDuCQBJ1AylovymbV+MSJXx5niJ/RqVOo7YD4rviAgB3ycD9oR?= =?us-ascii?Q?sGbBHm/os0bJ5LU71+KbuqFMdIdyUGTKY2IQD/USMdkS6WOE2wjdrLuQMMqA?= =?us-ascii?Q?X4yhkQi7pi2/XU05D8EVehLp437xkb0b5uvElb/cdMndQ7kjTvnDwh6jfQ8z?= =?us-ascii?Q?s8DjjuyZEhXwmvRiSM+fsGHBQWsC0I0BctgDATeBCeY60WLOPdplxou2f6vq?= =?us-ascii?Q?+umkLThfR9aaaABCzRz7YMFJovvmix0IkKaq4OlBTLp7PdnINqYAUEBm8d5A?= =?us-ascii?Q?ugc2Q2+JvPnQbZzjjEVS3KT/mZiXZMjVC9rZxTLwkI0Ek5YgTSE3sgETFbCH?= =?us-ascii?Q?LDcVQG0YhouYGNFrAe+KaoonEsA+jBl/SKV2OAGEMxmhPB9WkxSqnxZht6/j?= =?us-ascii?Q?7p7PWL9uRlB/qMeXxF1CrUQz8zL9cbcO3uTr/gTz0qcZCj+zUu1K4tLfCM32?= =?us-ascii?Q?AdZMDDN+3RIn3rGOBXB9nqlyJ+01vdeasSD1cA5VeaxcWmcaoGPEoX+gzyvX?= =?us-ascii?Q?Qo55h0v6prVe8Pl4agMnUdkTuobyoPNdgmX4wdt55insLg3HWaY5ut/E6uqB?= =?us-ascii?Q?RgCHc9skHgGWDbWedR47rQx6tTjK5tKfwD9fI1oTTuP9ED0DNAMroKronjmc?= =?us-ascii?Q?Ikb0DjAAK6eD9zXlf9ECPh/Ch0iZjDKnUuajl3OhmZugPPu+W1sWRUllXsvy?= =?us-ascii?Q?D20uZvrKdJnLkdmi1cRqO18/b9ZGyOcF1ybL9VGr2b6OIowtN2DeJj9M5Jp1?= =?us-ascii?Q?jp6Ydtw412Len4nXoHSKMSFGep6bGQSMg9bQ41JTePXadefuiH8fE688frL6?= =?us-ascii?Q?3ruTj7knBtWMjrtuKacd1DM+amp1s6n4VjAGCUtINXe1lafzrXfn6jLLLjjn?= =?us-ascii?Q?btDNNFfR9VQh7xysp/8HvvK15/BLvp76lXw4VWxAO7uMYb5evJhqqBcYEF+v?= =?us-ascii?Q?1B7jrnjRL08ZPTC0u8ryIVx4y1D3gbNB7qVBmLVbmZiDPShCMD2qer4SOqvU?= =?us-ascii?Q?h2bfvayoF6ScYuyETq8OWj/MlPD4LZ6Si7ijmkjpwcla83fEMCc9AavhU5Dw?= =?us-ascii?Q?5knGxDM7ckYZW8he8CHQIb381eqe7p7MA+54v8bS?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: LV2PR11MB5997.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7da55375-927d-49cf-7d45-08dba54bdfea X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Aug 2023 09:15:50.0484 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: QSRW6jg7kspuSWmpQ0AWeaG6d6CvpKGOvK1vyNHsYq9yq1Ur6hlqoGFhmo1on3enzDD0QyYlaLnR9oLSYcBaCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR11MB7716 X-OriginatorOrg: intel.com 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 > -----Original Message----- > From: Zhang, Yuying > Sent: Saturday, August 12, 2023 3:55 PM > To: dev@dpdk.org; Xing, Beilei ; Zhang, Qi Z > ; Wu, Jingjing > Cc: Zhang, Yuying > Subject: [PATCH v1 5/5] net/cpfl: add fxp flow engine >=20 > Adapt fxp low level as a flow engine. >=20 > Signed-off-by: Yuying Zhang > Signed-off-by: Qi Zhang > --- > drivers/net/cpfl/cpfl_ethdev.h | 85 ++++ > drivers/net/cpfl/cpfl_flow_engine_fxp.c | 610 ++++++++++++++++++++++++ > drivers/net/cpfl/meson.build | 1 + > 3 files changed, 696 insertions(+) > create mode 100644 drivers/net/cpfl/cpfl_flow_engine_fxp.c >=20 > diff --git a/drivers/net/cpfl/cpfl_ethdev.h b/drivers/net/cpfl/cpfl_ethde= v.h > index 63bcc5551f..d7e9ea1a74 100644 > --- a/drivers/net/cpfl/cpfl_ethdev.h > +++ b/drivers/net/cpfl/cpfl_ethdev.h > @@ -92,6 +92,8 @@ <...> > +static inline uint16_t > +cpfl_get_vsi_id(struct cpfl_itf *itf) > +{ > + struct cpfl_adapter_ext *adapter =3D itf->adapter; > + struct cpfl_vport_info *info; > + uint32_t vport_id; > + int ret; > + struct cpfl_vport_id vport_identity; > + > + if (!itf) > + return CPFL_INVALID_HW_ID; > + > + if (itf->type =3D=3D CPFL_ITF_TYPE_REPRESENTOR) { > + struct cpfl_repr *repr =3D (void *)itf; > + > + return repr->vport_info->vport_info.vsi_id; > + } else if (itf->type =3D=3D CPFL_ITF_TYPE_VPORT) { > + vport_id =3D ((struct cpfl_vport *)itf)->base.vport_id; > + vport_identity.func_type =3D CPCHNL2_FUNC_TYPE_PF; > + /* host: HOST0_CPF_ID, acc: ACC_CPF_ID */ > + vport_identity.pf_id =3D ACC_CPF_ID; > + vport_identity.vf_id =3D 0; > + vport_identity.vport_id =3D vport_id; > + > + ret =3D rte_hash_lookup_data(adapter->vport_map_hash, > &vport_identity, > + (void **)&info); > + if (ret < 0) { > + PMD_DRV_LOG(ERR, "vport id not exist"); > + goto err; > + } > + > + /* rte_spinlock_unlock(&adapter->vport_map_lock); */ =20 So do we need lock in the function? > + return info->vport_info.vsi_id; > + } > + > +err: > + /* rte_spinlock_unlock(&adapter->vport_map_lock); */ > + return CPFL_INVALID_HW_ID; > +} > + <...> >=20 > #endif /* _CPFL_ETHDEV_H_ */ > diff --git a/drivers/net/cpfl/cpfl_flow_engine_fxp.c > b/drivers/net/cpfl/cpfl_flow_engine_fxp.c > new file mode 100644 > index 0000000000..e10639c842 > --- /dev/null > +++ b/drivers/net/cpfl/cpfl_flow_engine_fxp.c > @@ -0,0 +1,610 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2023 Intel Corporation > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include "cpfl_rules.h" > +#include "cpfl_logs.h" > +#include "cpfl_ethdev.h" > +#include "cpfl_flow.h" > +#include "cpfl_fxp_rule.h" > +#include "cpfl_flow_parser.h" > +#include "rte_memcpy.h" #include and move above? > + > +#define COOKIE_DEF 0x1000 > +#define PREC_MAX 7 > +#define PREC_DEF 1 > +#define PREC_SET 5 > +#define TYPE_ID 3 > +#define OFFSET 0x0a > +#define HOST_ID_DEF 0 > +#define PF_NUM_DEF 0 > +#define PORT_NUM_DEF 0 > +#define RESP_REQ_DEF 2 > +#define PIN_TO_CACHE_DEF 0 > +#define CLEAR_MIRROR_1ST_STATE_DEF 0 > +#define FIXED_FETCH_DEF 0 > +#define PTI_DEF 0 > +#define MOD_OBJ_SIZE_DEF 0 > +#define PIN_MOD_CONTENT_DEF 0 > + > +#define MAX_MOD_CONTENT_INDEX 256 > +#define MAX_MR_ACTION_NUM 8 For the new defined macros in PMD, better to use CPFL_ prefix.=20 > + > +struct rule_info_meta { cpfl_rule_info_meta. Please check all other macros, global variables, structures and functions, = etc. I will not comment for those. BTW, Could you add some comments for the new structures and the members? Th= en it will be more readable. > + struct cpfl_flow_pr_action pr_action; > + uint32_t pr_num; > + uint32_t mr_num; > + uint32_t rule_num; > + struct cpfl_rule_info rules[0]; > +}; > + > +static uint32_t fxp_mod_idx_alloc(struct cpfl_adapter_ext *ad); static > +void fxp_mod_idx_free(struct cpfl_adapter_ext *ad, uint32_t idx); > +uint64_t rule_cookie =3D COOKIE_DEF; > + > +static int > +cpfl_fxp_create(struct rte_eth_dev *dev, > + struct rte_flow *flow, > + void *meta, > + struct rte_flow_error *error) > +{ > + int ret =3D 0; > + uint32_t cpq_id =3D 0; > + struct cpfl_itf *itf =3D CPFL_DEV_TO_ITF(dev); > + struct cpfl_adapter_ext *ad =3D itf->adapter; > + struct rule_info_meta *rim =3D meta; > + struct cpfl_vport *vport; > + > + if (!rim) > + return ret; > + > + if (itf->type =3D=3D CPFL_ITF_TYPE_VPORT) { > + vport =3D (struct cpfl_vport *)itf; > + cpq_id =3D vport->base.devarg_id * 2; Why is vport->base.devarg_id * 2 here? Could you add some comments? > + } else if (itf->type =3D=3D CPFL_ITF_TYPE_REPRESENTOR) { So is the patch support both representor rule and represented port action? It's better to split VPORT and REPRESENTOR support. > + cpq_id =3D CPFL_FPCP_CFGQ_TX; > + } else { > + rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_HANDLE, NULL, > + "fail to find correct control queue"); > + return -rte_errno; > + } > + > + ret =3D cpfl_rule_update(itf, ad->ctlqp[cpq_id], ad->ctlqp[cpq_id + 1], > + rim->rules, rim->rule_num, true); OK, I understand the function is to process the rule, right? So how about cplf_rule_process? > + if (ret < 0) { > + rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_HANDLE, NULL, > + "cpfl filter create flow fail"); > + rte_free(rim); > + return ret; > + } > + > + flow->rule =3D rim; > + > + return ret; > +} > + > +static inline void > +cpfl_fxp_rule_free(struct rte_flow *flow) { > + rte_free(flow->rule); > + flow->rule =3D NULL; > +} > + > +static int > +cpfl_fxp_destroy(struct rte_eth_dev *dev, > + struct rte_flow *flow, > + struct rte_flow_error *error) > +{ > + int ret =3D 0; > + uint32_t cpq_id =3D 0; > + struct cpfl_itf *itf =3D CPFL_DEV_TO_ITF(dev); > + struct cpfl_adapter_ext *ad =3D itf->adapter; > + struct rule_info_meta *rim; > + uint32_t i; > + struct cpfl_vport *vport; > + > + rim =3D flow->rule; > + if (!rim) { > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_HANDLE, NULL, > + "no such flow create by cpfl filter"); > + > + cpfl_fxp_rule_free(flow); flow->rule is NULL, so no need to call the function. > + > + return -rte_errno; > + } > + > + if (itf->type =3D=3D CPFL_ITF_TYPE_VPORT) { > + vport =3D (struct cpfl_vport *)itf; > + cpq_id =3D vport->base.devarg_id * 2; > + } else if (itf->type =3D=3D CPFL_ITF_TYPE_REPRESENTOR) { > + cpq_id =3D CPFL_FPCP_CFGQ_TX; > + } else { > + rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_HANDLE, NULL, > + "fail to find correct control queue"); Need to goto err here? > + return -rte_errno; > + } > + > + ret =3D cpfl_rule_update(itf, ad->ctlqp[cpq_id], ad->ctlqp[cpq_id + 1], > rim->rules, > + rim->rule_num, false); > + if (ret < 0) { > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_HANDLE, NULL, > + "fail to destroy cpfl filter rule"); > + goto err; > + } > + > + /* free mod index */ > + for (i =3D rim->pr_num; i < rim->rule_num; i++) > + fxp_mod_idx_free(ad, rim->rules[i].mod.mod_index); > +err: > + cpfl_fxp_rule_free(flow); > + return ret; > +} > + <...> > + > +static int > +cpfl_parse_mod_content(struct cpfl_adapter_ext *adapter, > + struct cpfl_rule_info *match_rinfo, > + struct cpfl_rule_info *mod_rinfo, > + const struct cpfl_flow_mr_action *mr_action) { > + struct cpfl_mod_rule_info *minfo =3D &mod_rinfo->mod; > + uint32_t mod_idx; > + int i; > + int next =3D match_rinfo->act_byte_len / (sizeof(union cpfl_action_set)= ); > + union cpfl_action_set *act_set =3D > + &((union cpfl_action_set *)match_rinfo->act_bytes)[next]; > + > + if (!mr_action || mr_action->type !=3D CPFL_JS_MR_ACTION_TYPE_MOD) > + return -EINVAL; > + > + *act_set =3D cpfl_act_mod_profile(PREC_DEF, > + mr_action->mod.prof, > + PTI_DEF, > + 0, /* append */ > + 0, /* prepend */ > + > CPFL_ACT_MOD_PROFILE_PREFETCH_256B); > + > + act_set++; > + match_rinfo->act_byte_len +=3D sizeof(union cpfl_action_set); > + > + mod_idx =3D fxp_mod_idx_alloc(adapter); > + if (mod_idx =3D=3D MAX_MOD_CONTENT_INDEX) { > + PMD_DRV_LOG(ERR, "Out of Mod Index."); > + return -ENOMEM; > + } > + > + *act_set =3D cpfl_act_mod_addr(PREC_DEF, mod_idx); > + > + act_set++; > + match_rinfo->act_byte_len +=3D sizeof(union cpfl_action_set); > + > + mod_rinfo->type =3D CPFL_RULE_TYPE_MOD; > + minfo->mod_obj_size =3D MOD_OBJ_SIZE_DEF; > + minfo->pin_mod_content =3D PIN_MOD_CONTENT_DEF; > + minfo->mod_index =3D mod_idx; > + mod_rinfo->cookie =3D 0x1237561; How about add a macro for 0x1237561? > + mod_rinfo->port_num =3D PORT_NUM_DEF; > + mod_rinfo->resp_req =3D RESP_REQ_DEF; > + > + minfo->mod_content_byte_len =3D mr_action->mod.byte_len + 2; > + for (i =3D 0; i < minfo->mod_content_byte_len; i++) > + minfo->mod_content[i] =3D mr_action->mod.data[i]; > + > + return 0; > +} > + > +static int > +cpfl_fxp_parse_action(struct cpfl_itf *itf, > + const struct rte_flow_action *actions, > + const struct cpfl_flow_mr_action *mr_action, > + struct rule_info_meta *rim, > + int priority, > + int index, > + bool is_vport_rule) > +{ > + const struct rte_flow_action_ethdev *act_ethdev; > + const struct rte_flow_action *action; > + const struct rte_flow_action_queue *act_q; > + const struct rte_flow_action_rss *rss; > + struct rte_eth_dev_data *data; > + enum rte_flow_action_type action_type; > + struct cpfl_vport *vport; > + /* used when action is REPRESENTED_PORT or REPRESENTED_PORT > type */ Represented port or port representor? Also, can we split the VPORT and REPRESENTOR flow support? > + struct cpfl_itf *dst_itf; > + uint16_t dev_id; /*vsi_id or phyical port id*/ > + bool is_vsi; > + bool set_meta_valid =3D false; > + int queue_id =3D -1; > + bool fwd_vsi =3D false; > + bool fwd_q =3D false; > + bool fwd_jump =3D false; > + uint32_t i; > + struct cpfl_rule_info *rinfo =3D &rim->rules[index]; > + union cpfl_action_set *act_set =3D (void *)rinfo->act_bytes; > + > + priority =3D PREC_MAX - priority; > + for (action =3D actions; action->type !=3D > + RTE_FLOW_ACTION_TYPE_END; action++) { > + action_type =3D action->type; > + switch (action_type) { > + case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT: > + case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR: > + if (!fwd_vsi && !fwd_jump) > + fwd_vsi =3D true; > + else > + goto err; > + if (is_vport_rule) { > + dst_itf =3D itf; > + } else { > + act_ethdev =3D action->conf; > + dst_itf =3D cpfl_get_itf_by_port_id(act_ethdev- > >port_id); > + } > + > + if (!dst_itf) > + goto err; > + > + if (dst_itf->type =3D=3D CPFL_ITF_TYPE_VPORT) { > + vport =3D (struct cpfl_vport *)dst_itf; > + queue_id =3D vport- > >base.chunks_info.rx_start_qid; > + } else { > + queue_id =3D -2; Why's -2 here? > + } > + > + is_vsi =3D (action_type =3D=3D > RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR || > + dst_itf->type =3D=3D > CPFL_ITF_TYPE_REPRESENTOR); > + if (is_vsi || is_vport_rule) > + dev_id =3D cpfl_get_vsi_id(dst_itf); > + else > + dev_id =3D cpfl_get_port_id(dst_itf); > + > + if (dev_id =3D=3D CPFL_INVALID_HW_ID) > + goto err; > + > + if (is_vsi || is_vport_rule) > + *act_set =3D cpfl_act_fwd_vsi(0, priority, 0, > dev_id); > + else > + *act_set =3D cpfl_act_fwd_port(0, priority, 0, > dev_id); > + act_set++; > + rinfo->act_byte_len +=3D sizeof(union cpfl_action_set); > + break; > + case RTE_FLOW_ACTION_TYPE_QUEUE: > + if (!fwd_q && !fwd_jump) > + fwd_q =3D true; > + else > + goto err; > + if (queue_id =3D=3D -2) > + goto err; > + act_q =3D action->conf; > + data =3D itf->data; > + if (act_q->index >=3D data->nb_rx_queues) > + goto err; > + > + vport =3D (struct cpfl_vport *)itf; > + if (queue_id < 0) > + queue_id =3D vport- > >base.chunks_info.rx_start_qid; > + queue_id +=3D act_q->index; > + *act_set =3D cpfl_act_set_hash_queue(priority, 0, > queue_id, 0); > + act_set++; > + rinfo->act_byte_len +=3D sizeof(union cpfl_action_set); > + break; > + case RTE_FLOW_ACTION_TYPE_RSS: > + rss =3D action->conf; > + if (rss->queue_num <=3D 1) > + goto err; > + for (i =3D 0; i < rss->queue_num - 1; i++) { > + if (rss->queue[i + 1] !=3D rss->queue[i] + 1) > + goto err; > + } > + data =3D itf->data; > + if (rss->queue[rss->queue_num - 1] >=3D data- > >nb_rx_queues) > + goto err; > +#define FXP_MAX_QREGION_SIZE 128 > + if (!(rte_is_power_of_2(rss->queue_num) && > + rss->queue_num <=3D FXP_MAX_QREGION_SIZE)) > + goto err; > + > + if (!fwd_q && !fwd_jump) > + fwd_q =3D true; > + else > + goto err; > + if (queue_id =3D=3D -2) > + goto err; > + vport =3D (struct cpfl_vport *)itf; > + if (queue_id < 0) > + queue_id =3D vport- > >base.chunks_info.rx_start_qid; > + queue_id +=3D rss->queue[0]; > + *act_set =3D cpfl_act_set_hash_queue_region(priority, 0, > queue_id, > + log(rss- > >queue_num) / log(2), 0); > + act_set++; > + rinfo->act_byte_len +=3D sizeof(union cpfl_action_set); > + break; > + case RTE_FLOW_ACTION_TYPE_DROP: > + (*act_set).data =3D cpfl_act_drop(priority).data; > + act_set++; > + rinfo->act_byte_len +=3D sizeof(union cpfl_action_set); > + (*act_set).data =3D cpfl_act_set_commit_mode(priority, > 0).data; > + act_set++; > + rinfo->act_byte_len +=3D sizeof(union cpfl_action_set); > + break; > + case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP: > + case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP: > + break; > + case RTE_FLOW_ACTION_TYPE_VOID: > + break; > + default: > + goto err; > + } > + } > + > + if (mr_action !=3D NULL && !set_meta_valid) { > + uint32_t i; > + > + for (i =3D 0; i < rim->mr_num; i++) > + if (cpfl_parse_mod_content(itf->adapter, rinfo, > + &rim->rules[rim->pr_num + > i], > + &mr_action[i])) > + goto err; > + } > + > + return 0; > + > +err: > + PMD_DRV_LOG(ERR, "Invalid action type"); > + return -EINVAL; > +} > + > [] <...> > + > +static int > +cpfl_fxp_parse_pattern_action(struct rte_eth_dev *dev, > + const struct rte_flow_attr *attr, > + const struct rte_flow_item pattern[], > + const struct rte_flow_action actions[], > + void **meta) > +{ > + struct cpfl_itf *itf =3D CPFL_DEV_TO_ITF(dev); > + struct cpfl_flow_pr_action pr_action =3D { 0 }; > + struct cpfl_adapter_ext *adapter =3D itf->adapter; > + struct cpfl_flow_mr_action mr_action[MAX_MR_ACTION_NUM] =3D { 0 }; > + uint32_t pr_num =3D 0, mr_num =3D 0; > + struct cpfl_vport *vport; > + struct rule_info_meta *rim; > + bool set_meta_valid =3D false; > + int ret; > + > + if (itf->type =3D=3D CPFL_ITF_TYPE_VPORT) { > + vport =3D (struct cpfl_vport *)itf; > + if (vport->exceptional) { Exception vport won't be in this release, so remove it. > + PMD_DRV_LOG(ERR, "Can't create rte_flow with > exceptional vport."); > + return -EINVAL; > + } > + } > + > + ret =3D cpfl_flow_parse_items(adapter->flow_parser, pattern, attr, > &pr_action); > + if (ret) { > + PMD_DRV_LOG(ERR, "No Match pattern support."); > + return -EINVAL; > + } > + > + if (is_mod_action(actions, &set_meta_valid)) { > + ret =3D cpfl_flow_parse_actions(adapter->flow_parser, actions, > mr_action); > + if (ret) { > + PMD_DRV_LOG(ERR, "action parse fails."); > + return -EINVAL; > + } > + if (!set_meta_valid) > + mr_num++; > + } > + > + pr_num =3D 1; > + rim =3D rte_zmalloc(NULL, > + sizeof(struct rule_info_meta) + > + (pr_num + mr_num) * sizeof(struct cpfl_rule_info), > + 0); > + if (!rim) > + return -ENOMEM; > + > + rim->pr_action =3D pr_action; > + rim->pr_num =3D pr_num; > + rim->mr_num =3D mr_num; > + rim->rule_num =3D pr_num + mr_num; > + > + if (!cpfl_fxp_parse_pattern(&pr_action, rim, 0)) { > + PMD_DRV_LOG(ERR, "Invalid input set"); Invalid pattern? > + rte_free(rim); > + return -rte_errno; > + } > + > + if (cpfl_fxp_parse_action(itf, actions, mr_action, rim, attr->priority, > + 0, false)) { > + PMD_DRV_LOG(ERR, "Invalid input set"); Invalid action? > + rte_free(rim); > + return -rte_errno; > + } > + > + cpfl_fill_rinfo_default_value(&rim->rules[0]); > + > + if (!meta) > + rte_free(rim); > + else > + *meta =3D rim; > + > + return 0; > +} > + > +static int fxp_mod_init(struct cpfl_adapter_ext *ad) { Check and refine the functions' coding style. > + uint32_t size =3D > +rte_bitmap_get_memory_footprint(MAX_MOD_CONTENT_INDEX); > + > + void *mem =3D rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE); > + > + if (!mem) > + return -ENOMEM; > + > + /* a set bit represent a free slot */ > + ad->mod_bm =3D > rte_bitmap_init_with_all_set(MAX_MOD_CONTENT_INDEX, mem, size); > + if (!ad->mod_bm) { > + rte_free(mem); > + return -EINVAL; > + } > + > + ad->mod_bm_mem =3D mem; > + > + return 0; > +} > + > +static void fxp_mod_uninit(struct cpfl_adapter_ext *ad) { > + rte_free(ad->mod_bm_mem); > + ad->mod_bm_mem =3D NULL; > + ad->mod_bm =3D NULL; > +} > + > +static uint32_t fxp_mod_idx_alloc(struct cpfl_adapter_ext *ad) { > + uint64_t slab =3D 0; > + uint32_t pos =3D 0; > + > + if (!rte_bitmap_scan(ad->mod_bm, &pos, &slab)) > + return MAX_MOD_CONTENT_INDEX; > + > + pos +=3D __builtin_ffsll(slab) - 1; > + rte_bitmap_clear(ad->mod_bm, pos); > + > + return pos; > +} > + > +static void fxp_mod_idx_free(struct cpfl_adapter_ext *ad, uint32_t idx) > +{ > + rte_bitmap_set(ad->mod_bm, idx); > +} =20 What's the benefit of the function? Can we call rte_bitmap_set directly? > + > +static int > +cpfl_fxp_query(struct rte_eth_dev *dev __rte_unused, > + struct rte_flow *flow __rte_unused, > + struct rte_flow_query_count *count __rte_unused, > + struct rte_flow_error *error) > +{ > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_HANDLE, > + NULL, > + "count action not supported by this module"); > + > + return -rte_errno; > +} > + > +static void > +cpfl_fxp_uninit(struct cpfl_adapter_ext *ad) { > + fxp_mod_uninit(ad); > +} Why do we need the function wrapper? > + > +static int > +cpfl_fxp_init(struct cpfl_adapter_ext *ad) { > + int ret =3D 0; > + > + ret =3D fxp_mod_init(ad); > + if (ret) { > + PMD_DRV_LOG(ERR, "Failed to init mod content bitmap."); > + return ret; > + } > + > + return ret; > +} > + > +static struct > +cpfl_flow_engine cpfl_fxp_engine =3D { > + .type =3D CPFL_FLOW_ENGINE_FXP, > + .init =3D cpfl_fxp_init, > + .uninit =3D cpfl_fxp_uninit, > + .create =3D cpfl_fxp_create, > + .destroy =3D cpfl_fxp_destroy, > + .query_count =3D cpfl_fxp_query, > + .parse_pattern_action =3D cpfl_fxp_parse_pattern_action, }; > + > +RTE_INIT(cpfl_sw_engine_init) > +{ > + struct cpfl_flow_engine *engine =3D &cpfl_fxp_engine; > + > + cpfl_flow_engine_register(engine); > +} > diff --git a/drivers/net/cpfl/meson.build b/drivers/net/cpfl/meson.build = index > 4061123034..ce46d7e76e 100644 > --- a/drivers/net/cpfl/meson.build > +++ b/drivers/net/cpfl/meson.build > @@ -43,6 +43,7 @@ js_dep =3D dependency('json-c', required: false, method= : > 'pkg-config') if js_dep.found() > sources +=3D files( > 'cpfl_flow.c', > + 'cpfl_flow_engine_fxp.c', > 'cpfl_flow_parser.c', > 'cpfl_rules.c', > 'cpfl_controlq.c', > -- > 2.25.1