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 77507A0C4B; Thu, 14 Oct 2021 18:42:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1931340041; Thu, 14 Oct 2021 18:42:13 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id A43D84003C for ; Thu, 14 Oct 2021 18:42:10 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10137"; a="251161425" X-IronPort-AV: E=Sophos;i="5.85,372,1624345200"; d="scan'208";a="251161425" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2021 09:42:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,372,1624345200"; d="scan'208";a="563962574" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by FMSMGA003.fm.intel.com with ESMTP; 14 Oct 2021 09:42:09 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Thu, 14 Oct 2021 09:42:09 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) 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.2242.12 via Frontend Transport; Thu, 14 Oct 2021 09:42:09 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.104) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Thu, 14 Oct 2021 09:42:08 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jZQrt0eThUoRbIJzeEwTVbruaFkld5LG/jUMpOfgjIeu3cnavrptbCsXkc9dHn8obmKrO1eLbzOP55xLZ6dVMEwAfdoCr02v0wV6ysm/d3H6HbOT78AFcVM/M0Kw6kS/kiS9/uAardmjnMCLDm/ETT9jwZwkbIRg2SzHXJPZwlekj0K/HVihN9aRLPaSPVKdwVjXW208a8ls/4n6abnBhT2UeJT/hAktDu+Hf83ICdorcSGeXv+k/7rQeMRubfwtHojf4S+cb0La5Pa4UoAI6+iXI9SP3FNpzz+1ne7LR337rvAQt+hG+s6dFBFCTkufL1jF90zanfQsTEKE3rUStw== 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=0/WHmOHJ+pgcTDzLXnTLV6I5hszQHuEZDvI08N3N9sc=; b=bzxcVRKz3nHrlxqosHoXzha0UqtTlLlYYAlOdhh8HcYCxJAn60vlbqzf784lSMoNRhG5bN1pv8k+1BrSbIg7EHSrtyxZbrQHvGnc/Ejw9SWY4MTW/tp2p+u4KuVaO7SjdtvUaenY3pMY67yaH9aO77P2ZWaySpPgwuizEo9wAN4XZWFdmQeu1NptGsAIP7XiSAqPIA9+Hfa5giqPLdagZxBzMGerNjEng6xYys1d6P4sanbAGQdWhlIZuPfGKYmji67Lo7LASA/Egc2htqRBTeqMsMc/70DuTTvcweFY6EQl81aBwkcxlRRnzN81aJm/T4Zsovf5/u7kkW3oZPgNww== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0/WHmOHJ+pgcTDzLXnTLV6I5hszQHuEZDvI08N3N9sc=; b=Z5NrXJdrwF1lsq/hymdXOS/A7+DHxS0oZYHQst89yxjSCVedh2JFa1gfdmnQ1ffsqUiXQ/bUdCGbwkcpSkV4wcRpoa4/TcRAa+JddfJV+Non1moUbvIRjHm05CJymCNRJ4mPZs+qYPdEBx8PFdvgUlOJwCLRuFT04OmIREeq6IQ= Authentication-Results: nvidia.com; dkim=none (message not signed) header.d=none;nvidia.com; dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) by PH0PR11MB4823.namprd11.prod.outlook.com (2603:10b6:510:43::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.14; Thu, 14 Oct 2021 16:42:07 +0000 Received: from PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::bd7d:29be:3342:632c]) by PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::bd7d:29be:3342:632c%5]) with mapi id 15.20.4608.017; Thu, 14 Oct 2021 16:42:07 +0000 Message-ID: Date: Thu, 14 Oct 2021 17:42:01 +0100 Content-Language: en-US To: Viacheslav Ovsiienko , CC: , , , , , References: <20210922180418.20663-1-viacheslavo@nvidia.com> <20211012125433.31647-1-viacheslavo@nvidia.com> <20211012125433.31647-6-viacheslavo@nvidia.com> From: Ferruh Yigit X-User: ferruhy In-Reply-To: <20211012125433.31647-6-viacheslavo@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: DU2PR04CA0318.eurprd04.prod.outlook.com (2603:10a6:10:2b5::23) To PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) MIME-Version: 1.0 Received: from [192.168.0.206] (37.228.236.146) by DU2PR04CA0318.eurprd04.prod.outlook.com (2603:10a6:10:2b5::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16 via Frontend Transport; Thu, 14 Oct 2021 16:42:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 40123083-c48a-4d00-8455-08d98f318f6b X-MS-TrafficTypeDiagnostic: PH0PR11MB4823: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:529; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jvhwI5z0WD0hmAAwvEqRWpUGgRsYnjJe6cDBwBk+1asCdd7WbavIFyHXsTsgHJKNrq2pZ3ZtafztPlME+0HcSiEARNvonccCjcgSZb51JJKFoLk82iEezz4/WHdMyNa6/IoCeHR3sLnCCGwMSr/GQo/RCcb4Zo3FKJLzNYle8lZ9fRu43V1ee7pO+V+z1+i7NInqSDGIGthBttRThqKY9Cd0zaeWQ3XTTOsmJPwU3DoAoFuvLiolKUSR8OpnYYyo+gIhJoqqzgDmMhtZX1+0mzqYo13/YTBl25N1FDh2zjuTZNhpzuMtXqSKetoQtunVzeJjV2fYAYKabUSz0HJPp2bM9OpIIqZw9y+LZKszTWMmMye7qjQRV/iE9Pjd2U0tDpE7H1p/2DhEM2sc92eO0sfZ0CX8V+7IUtUoC+gdosg7UAbgeXt6scASGS4cYTgGCzqN0/hVIJQiGNhl478fFHAQKkN6G8A/icTUBxaxUOwwUmgLLcXEpLrRYkBzmj0ehTUy0dpW1AGyBDdcqq5PQC7Na6RkVIbPiTTMs75IWEkpFuOLEEtgd29RlkrDKhWE2iCDxfBGunVvaTDBR8pAeAGG3OSoCpjUj3pGekaQZXgbxDLsZBw4qIfQcHMTYTgVDNVsk3e6sltG4p3pWYR8vNqC1pRpYMTfY8aC0CIOHvP0poxosFrsyx5au1vYPelewZS3e5kglmr0fdqU32AwrQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5000.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(508600001)(2906002)(44832011)(6666004)(956004)(2616005)(83380400001)(31686004)(316002)(31696002)(5660300002)(16576012)(66476007)(26005)(8936002)(186003)(82960400001)(6486002)(86362001)(4326008)(8676002)(53546011)(66946007)(38100700002)(36756003)(66556008)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RTlnLzd0dWo2RTNCQ1o3NUVabzRyTnlOUnY0cnYwK010WnZXWER5K3F1Ritn?= =?utf-8?B?MG9uVFpGUXVzUytUZlZndTFvWVhCWGJVUjlHdU1NQk1IQkRybkQzYWgwNVp5?= =?utf-8?B?eGpBM1J4cXJHckZpeTVJQkxld0pmYjNvSzV1OWthSmVIUWxnMVAxeU4rMkN2?= =?utf-8?B?ejBWSGhhamJ5azhQY3E5VGRHejMxSDl2SUJrRTFRMnRpUi9kWkRvQkJsSEdC?= =?utf-8?B?OG9kVXNxNU55SlR0Wk5DSXB1OEpjTXRCSEhlRHpua0hVN3hHQTJwTkNrMy8x?= =?utf-8?B?MDZqcFFZU0NSMjI4M0crSUtnVUkvQllvS1hwWmx2blcvbXVkSXZNcXIvNTZm?= =?utf-8?B?RTZQTTJvSnVmQTZibldtWjNQamY4NjE3NVV2UVgxbUhFTnJGT2NLdkFzOHRt?= =?utf-8?B?VkMwSU5Ec0d5ZDR6Z0E3eUc1czFIWWl2K3hiSUc2cjRyTENsWHFvcGRCZ01R?= =?utf-8?B?cjVUbFM4UTJzd0VydDBmSElWeVNQNGdXVVZlLzlxNXdTeGhWaXh2cWNR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hnay9LN3Z4WUJUVlFp?= =?utf-8?B?RGcvb1EvUSt6ai84Sk02ZkZlZGhyUHpWV2hUU2w4ajY2bDBOb2JiNEN5N2Nv?= =?utf-8?B?ODgwOU1RamFGcUk4TytNSTg5RWl2SytxcThyWU5wNnpEZjJHVytLOE12MkFh?= =?utf-8?B?K0tRblNmSzhicisvbUNiUjlWay9VcWNOckMvYVV6bXJFNk9QSGp6dU5aU2M0?= =?utf-8?B?bGJQY2t3VVUwMlY0TnRMSVpNelJIOU1Lek5rcWVLZW1JZm94dzFpeUlyT0tH?= =?utf-8?B?Tlo4OVJ6L2Fkb2JER3NSQVFIbUMrVjN2ZEF0WDNiY0IyS0tvSmMzU2pBZDBm?= =?utf-8?Q?jEZq2sMiuZs0cvT0DclP4LhVwMNZY0/uSP0G7E7?= X-MS-Exchange-CrossTenant-Network-Message-Id: 40123083-c48a-4d00-8455-08d98f318f6b X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5000.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2021 16:42:07.4512 (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: jXOF2NhEM4dq9DAxOS5nBQIcB7MXkWJcAxmFRyWXqio7WzcR/NW87JUqxStICGAP7kyZItTu28zQXaPvFrwiXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB4823 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v5 5/5] app/testpmd: add flex item CLI commands 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 Sender: "dev" On 10/12/2021 1:54 PM, Viacheslav Ovsiienko wrote: > From: Gregory Etelson > > Network port hardware is shipped with fixed number of > supported network protocols. If application must work with a > protocol that is not included in the port hardware by default, it > can try to add the new protocol to port hardware. > > Flex item or flex parser is port infrastructure that allows > application to add support for a custom network header and > offload flows to match the header elements. > > Application must complete the following tasks to create a flow > rule that matches custom header: > > 1. Create flow item object in port hardware. > Application must provide custom header configuration to PMD. > PMD will use that configuration to create flex item object in > port hardware. > > 2. Create flex patterns to match. Flex pattern has a spec and a mask > components, like a regular flow item. Combined together, spec and mask > can target unique data sequence or a number of data sequences in the > custom header. > Flex patterns of the same flex item can have different lengths. > Flex pattern is identified by unique handler value. > > 3. Create a flow rule with a flex flow item that references > flow pattern. > > Testpmd flex CLI commands are: > > testpmd> flow flex_item create > The file here is .json file, right? What do you think to provide some sample .json file? I am not quite sure though where can be a place for them, perhaps a sub-folder under testpmd? > testpmd> set flex_pattern \ > spec mask > > testpmd> set flex_pattern is > > testpmd> flow create ... \ > / flex item is pattern is / ... > > The patch works with the jansson library API. > Jansson development files must be present: > jansson.pc, jansson.h libjansson.[a,so] > > Signed-off-by: Gregory Etelson > Reviewed-by: Viacheslav Ovsiienko <...> > +static void > +flex_item_create(portid_t port_id, uint16_t flex_id, const char *filename) > +{ > + struct rte_flow_error flow_error; > + json_error_t json_error; > + json_t *jroot = NULL; > + struct flex_item *fp = flex_parser_fetch(port_id, flex_id); > + int ret; > + > + if (fp == FLEX_PARSER_ERR) { > + printf("Bad parameters: port_id=%u flex_id=%u\n", > + port_id, flex_id); > + return; > + } > + if (fp) { > + printf("port-%u: flex item #%u is already in use\n", > + port_id, flex_id); > + return; > + } > + jroot = json_load_file(filename, 0, &json_error)> + if (!jroot) { > + printf("Bad JSON file \"%s\": %s\n", filename, json_error.text); > + return; > + } > + fp = flex_item_init(); > + if (!fp) { > + printf("Could not allocate flex item\n"); > + goto out; > + } > + ret = flex_item_config(jroot, &fp->flex_conf); What do you think to decouple json & flex item support a little more? Like: flex_item_config(&fp->flex_conf); flex_item_config_json(&fp->flex_conf); jroot = json_load_file() parse json & fill flex_conf json_decref(jroot); > + if (ret) > + goto out; > + fp->flex_handle = rte_flow_flex_item_create(port_id, > + &fp->flex_conf, > + &flow_error); > + if (fp->flex_handle) { > + flex_items[port_id][flex_id] = fp; > + printf("port-%u: created flex item #%u\n", port_id, flex_id); > + fp = NULL; > + } else { > + printf("port-%u: flex item #%u creation failed: %s\n", > + port_id, flex_id, > + flow_error.message ? flow_error.message : ""); > + } > +out: > + if (fp) > + free(fp); > + if (jroot) > + json_decref(jroot); > +} > + > +#else /* RTE_HAS_JANSSON */ > +static void flex_item_create(__rte_unused portid_t port_id, > + __rte_unused uint16_t flex_id, > + __rte_unused const char *filename) > +{ > + printf("no JSON library\n"); > +} > + > +static void flex_item_destroy(__rte_unused portid_t port_id, > + __rte_unused uint16_t flex_id) > +{ > + printf("no JSON library\n"); > +} > +#endif /* RTE_HAS_JANSSON */ Does it make sense to move all above code (ifdef block) to a separate file? Just because 'cmdline_flow.c' is getting bigger, I want to get your comment, no strong opinion.