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 EB9AF430FB; Fri, 25 Aug 2023 05:55:39 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CE98B40A7A; Fri, 25 Aug 2023 05:55:39 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 4639540695 for ; Fri, 25 Aug 2023 05:55:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692935737; x=1724471737; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=Ho4MkgXtFps2LWu25ecdbn9Q1xcHogx+U+mf46mDc1Q=; b=U/atBsk1Tzp9ro/b20j6+dC4cZtnMGtnZ13gNgE98GBfnYCJyhwDx7ni CNHpIjEVHzeXQ5MtAt9B0EEKT0u3ESKl5aEmYvm/EnypiCt5ZA74cjGau +J9J2DoA/kyMHPaEpxbjqXOOSUSm6m872k/jzOu8wjhqGxxcQ96oemcob 4RDxWO0UL1V2iQrtmbsT0EJTZu+cQ0hPyDG4L3ryKZTRUDA0AbW+3w7tB csslT7l7GYViCPs5EctRlNp3TNS/4/jYHeSNA4mbT7KQqVrCfR/EBQUqq JivaLbaJeKbduSSdUdqGkjeKwTCI0PWfxUjFwNwux/2vdxLz2HREW67xP A==; X-IronPort-AV: E=McAfee;i="6600,9927,10812"; a="373495815" X-IronPort-AV: E=Sophos;i="6.02,195,1688454000"; d="scan'208";a="373495815" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2023 20:55:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10812"; a="772358942" X-IronPort-AV: E=Sophos;i="6.02,195,1688454000"; d="scan'208";a="772358942" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga001.jf.intel.com with ESMTP; 24 Aug 2023 20:55:35 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 24 Aug 2023 20:55:34 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) 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; Thu, 24 Aug 2023 20:55:34 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.174) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.27; Thu, 24 Aug 2023 20:55:34 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=idAW/Nrkj+gPNw2v7r5HTPS2C0HB4GiFec1UCbDnaWhBT/TBSIOYI5xDVacYh1zFMKLBYk2CaFo9SzPHDhXLLTQt9YcEeHA4gSRfFW5ZcJX0Xx1AiCqaEArnmG4OjsWkCwVjQlWvQfBbs8LT9L/GhNn42EjfUxprEcY3/vAq0xcnY6sSlklFXbwwBC3tmngOx9ahirKkqxRNu6nSqRkPQGmD4oXjzKqTpK4qROMz2J/68/Zv1y2UonWX0s3zinrbGdSg3qPK/AFrKsY7X+2H53dd/irtLK8y0SKL7CxxdP2D4FvOv+fu7NhrCLO8X7ZxVMjG6fsDcha69Ig+RpDYPA== 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=auMmPyHsPwvgiuelroh8ynVb6UWpYurcGy+WjGQnBCg=; b=V42eR/Ke0q+rsqPt19tOI33nqlKFAx0isw7zPcaEvfUY+uaNWe4UQqZGcSpNdwVYXhUYlX/UaBscJXgMFfgrRUuyvOOrxUndeG+Bc2wMY5khxMatQjw5FqmHFn2d26EbsZCTEfrmkw4fL66UOblJ7c1SSyB51D+1xmsEgDUtHftjQNlz0rN24h2UJnQ0dnHJi4X85KLp9lj6q9iXyZ2REF1Zq8PS8WImgzipDwXO/JKmrIxkzIyxmwKUqURGqE6IZOZI9U5HaWa93Wj73XjqGFxuBHrYLJv5iAaNsvGPli5h9ZXI0vVzEolgiCK4ulL3qaHMyPZc8aGxdKbfpDu7OA== 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 DM4PR11MB8129.namprd11.prod.outlook.com (2603:10b6:8:183::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Fri, 25 Aug 2023 03:55:32 +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 03:55:32 +0000 From: "Xing, Beilei" To: "Zhang, Yuying" , "dev@dpdk.org" , "Zhang, Qi Z" , "Wu, Jingjing" Subject: RE: [PATCH v1 1/5] net/cpfl: setup rte flow skeleton Thread-Topic: [PATCH v1 1/5] net/cpfl: setup rte flow skeleton Thread-Index: AQHZzO8gUqxuURczlEeaxhaCjB8TZ6/6QuyA Date: Fri, 25 Aug 2023 03:55:31 +0000 Message-ID: References: <20230812075506.361769-1-yuying.zhang@intel.com> <20230812075506.361769-2-yuying.zhang@intel.com> In-Reply-To: <20230812075506.361769-2-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_|DM4PR11MB8129:EE_ x-ms-office365-filtering-correlation-id: 40b123a8-295b-46f8-9440-08dba51f20f5 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 7CJDIpnCV5l2kQWHk5tbXbZw+l71aznmLCxTLgObGmoXV3F+qC0J2AzAdYJ/ekl0+OskAk8pPOJo0yXk4Cdvwl5CQOgcpDDP7cBx1fUQzVHae39TgGgzfA1A5PC3wF4+vSRfX7f0wmz/NpZZnZySI/PNGLqO2CfvFK4UV4PkUks0/C29DfhhGdqitcRKtI5FMxstHq6R5iiqlYt7IrUMWOFzhZOJ7a6kyDpl7OueuCVFNvZ5DBprqda7xuxxFN6Tt7Wp1ehAvAjnxgqU5GjjfLgXDQgMhZ3RPijYIJ5Xv4zi8FdGLq/PW4jFYUQVpagkAaHR7235YDSSVd++WBIk6wd5MK2OQ5ApzAOXjJYKKCdlbspNV0jU/ol2Um5G7hjvLB+MW3Y3OeNUhIFkPIHDoXZoORD8YysioSCHJeiXy38CQNA2QqDiXwGZfQN5Kljd+t3a2+WnjCTOPJ6s8J//fxjY0mLW+lzHf+KeKCiASvZC6HWMD6CzZKg7EKwxcHPSKJJNSkpJA32a8snuYl17OaF8iwT+kLv7mdf0dXPHR6B18kY5XYczTZz7ksVvmtVAquRYtbz+Kxr669PvsF3OR2A+8zkOhNkeX6Rr/fdqcJbCptinXr6SU5kWRCDAE6q5 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)(366004)(376002)(39860400002)(396003)(136003)(346002)(186009)(1800799009)(451199024)(52536014)(5660300002)(8676002)(8936002)(83380400001)(33656002)(7696005)(55016003)(26005)(71200400001)(38100700002)(38070700005)(82960400001)(122000001)(76116006)(66556008)(66946007)(66476007)(66446008)(64756008)(6636002)(316002)(110136005)(478600001)(53546011)(41300700001)(9686003)(6506007)(2906002)(86362001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?On/FP0vacRW+vxssaxOfsx4KR5I8X2lhPp0pClYXWktpkY5ZYA/8sklarij+?= =?us-ascii?Q?hJCFJKKJemZ6mR+Fin2W040f4ypplWcHoIRoSCPQ82SUUG3+Vu//5Z/dcDk9?= =?us-ascii?Q?pXlq6XzZ2i/uPJSGkdPdZ2LoUiInc4jUqPc7CejfP2gPIenEM4aJdQy0JzlI?= =?us-ascii?Q?Dl5AqSfMaKfUW1vsGn3Lv8xeoNDhZGFNmpQlLOfs15srvEzaqUeRHMD9R9gm?= =?us-ascii?Q?/eXvWu9PYF1K6JNcVRcsURXJEPykbCynohIfia3VWLnMIynq6ouBvagty4p6?= =?us-ascii?Q?dEUPusF40AcKqh/6UpZDpgh/OSKFWedSetvMLM5CjItV4u49PU7zU4bL0MWO?= =?us-ascii?Q?pKR0h30unjdXy4n4GTD6lDKXdW1gVVPMErut93pz1h4dZ69j3eFr8UNYg4bP?= =?us-ascii?Q?fHEfFKvwNK4/tjOPvhN3aWAMpZ1xhH6cMs3tqRbsRma4qS6TsP0mfgcTNT4/?= =?us-ascii?Q?UnSthVCNkkHBoLzUDw+F/0NDLAxhtV8bnemuY9M2w1xQP9PE+cQPP5bECKjV?= =?us-ascii?Q?HWAl6jQIVnTWNQR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w5+O?= =?us-ascii?Q?smvk1OZzGykFIMmQNvbhA4bhO5ntEfpgYDJoyjhDShTeS+sS7MwGNY7rDitN?= =?us-ascii?Q?2q5VYgKBzUJxur4ma06Ig2bE2LNHi8GuL9+z5D+ejTgxp4UgzKHwy7mfWKSf?= =?us-ascii?Q?w0WYCGkc5vJiDAXXGkDRhHriqeQPHOLqmijCJJxD?= 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: 40b123a8-295b-46f8-9440-08dba51f20f5 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Aug 2023 03:55:31.8171 (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: tawlj+KLmufU3nURylZWiwib3U5+cr0kq2iusToKUbu2IDZMh626x0GN+VoFEyK5ThDhM62Bwc5MbYa+uoJ7jg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB8129 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 1/5] net/cpfl: setup rte flow skeleton >=20 > Setup the rte_flow backend skeleton. Introduce the framework to support > different engines as rte_flow backend. Bridge rte_flow driver API to flow > engines. >=20 > Signed-off-by: Yuying Zhang > Signed-off-by: Qi Zhang > --- > drivers/net/cpfl/cpfl_ethdev.c | 54 ++++++ > drivers/net/cpfl/cpfl_ethdev.h | 5 + > drivers/net/cpfl/cpfl_flow.c | 331 +++++++++++++++++++++++++++++++++ > drivers/net/cpfl/cpfl_flow.h | 88 +++++++++ > drivers/net/cpfl/meson.build | 3 +- > 5 files changed, 480 insertions(+), 1 deletion(-) create mode 100644 > drivers/net/cpfl/cpfl_flow.c create mode 100644 drivers/net/cpfl/cpfl_fl= ow.h >=20 <...> >=20 > +static int > +cpfl_dev_flow_ops_get(struct rte_eth_dev *dev, > + const struct rte_flow_ops **ops) { > + struct cpfl_itf *itf; > + > + if (!dev) > + return -EINVAL; > + > + itf =3D CPFL_DEV_TO_ITF(dev); > + > + /* only vport support rte_flow */ > + if (itf->type !=3D CPFL_ITF_TYPE_VPORT) > + return -ENOTSUP; Do we need this check? Seems this function is only for vport but not repres= entor. > +#ifdef CPFL_FLOW_JSON_SUPPORT > + *ops =3D &cpfl_flow_ops; > +#else > + *ops =3D NULL; > + PMD_DRV_LOG(NOTICE, "not support rte_flow, please install json-c > +library."); #endif > + return 0; > +} > + <...> > + > +static int > +cpfl_flow_valid_attr(const struct rte_flow_attr *attr, > + struct rte_flow_error *error) Better to use cpfl_flow_attr_valid to align with cpfl_flow_param_valid. > +{ > + if (attr->priority > 6) { What's 6's meaning? Better to define macro to describe it. > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, > + attr, "Only support priority 0-6."); > + return -rte_errno; > + } > + > + return 0; > +} > + <...> > +struct rte_flow * > +cpfl_flow_create(struct rte_eth_dev *dev __rte_unused, > + const struct rte_flow_attr *attr __rte_unused, > + const struct rte_flow_item pattern[] __rte_unused, > + const struct rte_flow_action actions[] __rte_unused, > + struct rte_flow_error *error __rte_unused) { > + struct cpfl_itf *itf =3D CPFL_DEV_TO_ITF(dev); > + struct cpfl_flow_engine *engine; > + struct rte_flow *flow; > + void *meta; > + int ret; > + > + flow =3D rte_malloc(NULL, sizeof(struct rte_flow), 0); > + if (!flow) { > + rte_flow_error_set(error, ENOMEM, > + RTE_FLOW_ERROR_TYPE_HANDLE, NULL, > + "Failed to allocate memory"); > + return NULL; > + } > + > + ret =3D cpfl_flow_param_valid(attr, pattern, actions, error); > + if (ret) { > + rte_free(flow); > + return NULL; > + } > + > + engine =3D cpfl_flow_engine_match(dev, attr, pattern, actions, &meta); > + if (!engine) { > + rte_flow_error_set(error, ENOTSUP, > RTE_FLOW_ERROR_TYPE_UNSPECIFIED, > + NULL, "No matched engine"); > + rte_free(flow); > + return NULL; > + } cpfl_flow_param_valid and cpfl_flow_engine_match can be replaced with cpfl_= flow_validate function. > + > + if (!engine->create) { > + rte_flow_error_set(error, ENOTSUP, > RTE_FLOW_ERROR_TYPE_UNSPECIFIED, > + NULL, "No matched flow creation function"); > + rte_free(flow); > + return NULL; > + } > + > + ret =3D engine->create(dev, flow, meta, error); > + if (ret) { > + rte_free(flow); > + return NULL; > + } > + > + flow->engine =3D engine; > + TAILQ_INSERT_TAIL(&itf->flow_list, flow, next); > + > + return flow; > +} > + <...> > + > +int > +cpfl_flow_query(struct rte_eth_dev *dev __rte_unused, > + struct rte_flow *flow __rte_unused, > + const struct rte_flow_action *actions __rte_unused, > + void *data __rte_unused, > + struct rte_flow_error *error __rte_unused) { Why is __rte_unused used here? > + struct rte_flow_query_count *count =3D data; > + int ret =3D -EINVAL; > + > + if (!flow || !flow->engine || !flow->engine->query_count) { > + rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_HANDLE, > + NULL, "Invalid flow"); > + return -rte_errno; > + } > + > + for (; actions->type !=3D RTE_FLOW_ACTION_TYPE_END; actions++) { > + switch (actions->type) { > + case RTE_FLOW_ACTION_TYPE_VOID: > + break; > + case RTE_FLOW_ACTION_TYPE_COUNT: > + ret =3D flow->engine->query_count(dev, flow, count, > error); > + break; > + default: > + ret =3D rte_flow_error_set(error, ENOTSUP, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + actions, > + "action not supported"); > + break; > + } > + } > + > + return ret; > +} > + <...> > +void cpfl_flow_engine_register(struct cpfl_flow_engine *engine); > + > +struct cpfl_flow_engine * > +cpfl_flow_engine_match(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); > +int > +cpfl_flow_engine_init(struct cpfl_adapter_ext *adapter); void > +cpfl_flow_engine_uninit(struct cpfl_adapter_ext *adapter); > + > +int cpfl_flow_init(struct cpfl_adapter_ext *ad); void > +cpfl_flow_uninit(struct cpfl_adapter_ext *ad); struct rte_flow > +*cpfl_flow_create(struct rte_eth_dev *dev, > + const struct rte_flow_attr *attr, > + const struct rte_flow_item pattern[], > + const struct rte_flow_action actions[], > + struct rte_flow_error *error); > +int cpfl_flow_validate(struct rte_eth_dev *dev, > + const struct rte_flow_attr *attr, > + const struct rte_flow_item pattern[], > + const struct rte_flow_action actions[], > + struct rte_flow_error *error); int cpfl_flow_destroy(struct > +rte_eth_dev *dev, struct rte_flow *flow, struct rte_flow_error *error); > +int cpfl_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error > +*error); int cpfl_flow_query(struct rte_eth_dev *dev, > + struct rte_flow *flow, > + const struct rte_flow_action *actions, > + void *data, > + struct rte_flow_error *error); Please check all functions' declaration, no need new line. > +#endif > diff --git a/drivers/net/cpfl/meson.build b/drivers/net/cpfl/meson.build = index > 84ba994469..222497f7c2 100644 > --- a/drivers/net/cpfl/meson.build > +++ b/drivers/net/cpfl/meson.build > @@ -42,10 +42,11 @@ endif > js_dep =3D dependency('json-c', required: false, method : 'pkg-config') = if > js_dep.found() > sources +=3D files( > + 'cpfl_flow.c', > 'cpfl_flow_parser.c', > 'cpfl_rules.c', > 'cpfl_controlq.c', > ) > dpdk_conf.set('CPFL_FLOW_JSON_SUPPORT', true) > ext_deps +=3D js_dep > -endif > \ No newline at end of file > +endif > -- > 2.25.1