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 AB93243AC8; Fri, 9 Feb 2024 17:20:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5021542E64; Fri, 9 Feb 2024 17:20:13 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mails.dpdk.org (Postfix) with ESMTP id 0C55E40697 for ; Fri, 9 Feb 2024 17:20:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707495612; x=1739031612; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=fr4dFK57j5dIRuXDjFB4WpXvIHFRyq9aGA1gHrp3lf0=; b=bs89wSrFKoXROKo1b3P+XoB5y6+Za/CgJjE53eSU7qLIQOliI9v6s2yC BLiKdEMZxm/DI33RLbkF5cXTRrjfIUfT6PL8+DJD4Md0ll8DYi5fxn7pK J2uC/PmDA/rD5iUKz7fXPKqnobfjnFUChvld9zuPRru07V9aHA+ZJZXOq roc6x0EpuXVGM9YQi2/ig7HKs0HJqoLT4ENtoedRY1xfns8UjtULS1Y5l eybMAc7i89b0DIsFf0tmXIjKXJle0jTvrz2gZH0y6nSsZSxfnMztP0r75 WxRygvYSdqiWhV1xGCse/MSoU+HrKg3C57wupcZFxAMCXfo4gtcCYqvHA g==; X-IronPort-AV: E=McAfee;i="6600,9927,10979"; a="23934706" X-IronPort-AV: E=Sophos;i="6.05,257,1701158400"; d="scan'208";a="23934706" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2024 08:20:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,257,1701158400"; d="scan'208";a="33052258" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmviesa001.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 09 Feb 2024 08:20:09 -0800 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 9 Feb 2024 08:20:09 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 9 Feb 2024 08:20:08 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Fri, 9 Feb 2024 08:20:08 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.168) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 9 Feb 2024 08:20:08 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jVGNQycTSMQTXsTiNOw8JRF8BxOZ9S0+eZcLfP7+4GS2TGqvK+wEI2k4CbTn/SeV8XmWW+CbYXBt6R0vExGK+VpSewemCu9E54S0paVCu7K/VVjBcyNh3mYmmZ6fZm0iH5nbFsGrOgBdmTZA59y93/hWALk8A5L8Cu59BnV0nSIizOKCV7MfqlIW3MAfSfdKZee6UpWVbGyj9SeiQWp0K7MX4zHBqGzseABu85NVyRbhr1CQfMICKhhW7j6QQUBXrJdWwgHZ/zyzh3H6ICVSxzxv6rGL1wHldJ6mR9N6UJZDxzLkBazNOpm7iN2e60WTkrI9Br3LGLqfWruBnwS/mg== 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=oL6KCKjU2mweEbJsKfA6O+2wxfQ3HG8jVPMGpkSnQW8=; b=hbeFydbUKCgpLf5X+qeqBHV04lzl/gX7FV7F0yTpnqeS1pfk4sbkGU8sGco6mgo3xkMTSNyTrfh4O52zX76O5wgiiJLVxGFNQJsAMIAeG+WGaFwU+6gkTsTMEGp200C5yuMvYUoVBxp/NmDIyV68CKIceEf4x0yQpuSinW08KRpXgb1zeLN+LWbVK5v7tX98HGWehZM+l2+dglccqBqeOW19dEb+QW6JvlCG386kHuyq5tSOI4fWsuVFSUtseTNlJeJvMYyKcAb1MZv74MHLaACyVvcOAqDsqj1Py0NOYkH/R2IUsRr9cL5oYT67DaNz3yMggZejfv/eGCa3jwrO4Q== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from SJ0PR11MB5772.namprd11.prod.outlook.com (2603:10b6:a03:422::8) by CY5PR11MB6536.namprd11.prod.outlook.com (2603:10b6:930:40::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.36; Fri, 9 Feb 2024 16:20:06 +0000 Received: from SJ0PR11MB5772.namprd11.prod.outlook.com ([fe80::fc4:cc9e:c910:f4b9]) by SJ0PR11MB5772.namprd11.prod.outlook.com ([fe80::fc4:cc9e:c910:f4b9%2]) with mapi id 15.20.7249.041; Fri, 9 Feb 2024 16:20:06 +0000 Message-ID: <2ebb4e92-3f1d-4e27-a7c7-7ea05607661b@intel.com> Date: Fri, 9 Feb 2024 16:20:02 +0000 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/2] net/cpfl: parse flow offloading hint from P4 context file To: , , , CC: References: <20231222100837.260493-2-wenjing.qiao@intel.com> <20240105081649.530384-2-wenjing.qiao@intel.com> Content-Language: en-US From: "Medvedkin, Vladimir" In-Reply-To: <20240105081649.530384-2-wenjing.qiao@intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: DUZPR01CA0186.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b3::15) To SJ0PR11MB5772.namprd11.prod.outlook.com (2603:10b6:a03:422::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR11MB5772:EE_|CY5PR11MB6536:EE_ X-MS-Office365-Filtering-Correlation-Id: 51397e63-c1de-4a03-a4ce-08dc298afa57 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1JA3Cdg7t0xGi21uA5PQHXVbpH1z2eDjn302/2o/GTIwfH9kHBel/IlvxYLA3d2snHGphBLs7sVT00CIhWKZoZE7NW4/WCmVrAWIe+6VvSEolMw4UaWmKJ+FSWgHoxxGvH1PX4JlGfJd8y0GV/mLZMPyzjYliXOaiBCvQqcDxJGWDpBe+Izd1bIYdbgng4sRFkF2cX1YJogCYTdi8a/v3OK+BSXq/w4LxJLSq6XHgsopOoYCJHVbdVu8yNFdNUXKrMZDiisc2/huJzHBmHuvOueqD16DGC6HtiiXa/+GPiPRXrq5g0vnmOZxYrTFM/ku5Gmn+W8g+V7if+GW6yKLPWzM7VelYYaFfSFn/GFGYX2ZpXr6fSj3WdEENeewtp3tK3B3jmWENJgkPk75yIwdgJ7CyRGg56LHjoyeu0Q4oxYIJehwf8gmcQSKib+KeeNEdxLNDekB68Yen4dTkkYMW9YKYKasKPpyvUKpUHpD8ihT41tcEwI0y+m0Gw45YxZOAfXPTjAFRtOlBafBNZ2BILgKxAUNDSFDJYRxahH+PU9dIEP4srZh/fRurDqvvHxf X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR11MB5772.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39860400002)(396003)(346002)(366004)(376002)(136003)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(41300700001)(8676002)(31696002)(6506007)(86362001)(4326008)(66574015)(36756003)(478600001)(2616005)(5660300002)(6486002)(6512007)(6666004)(53546011)(66556008)(66476007)(66946007)(316002)(6636002)(26005)(8936002)(82960400001)(83380400001)(31686004)(2906002)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?OVhwQWRrK3FqSmM4WUY1dFdiOXZtV1ptUFRhb1VSdFB5dUxQU1VETGVNYzYv?= =?utf-8?B?bWpXeTJjdkZzNkNYU2J1OG51SDNKMGJxS1EvZGNIKzRObkUxTWFrOW9qMDh1?= =?utf-8?B?Q3o5Uklxb0U5S2Z1SWNxYlYwUlNWVTA3dGdJZ24reWZvdWxSaDR1Rkx5c3No?= =?utf-8?B?enptYVIwbmF3Kzlva0VaRnRQNlhJdjFhRG53NDhTRWJSMGY1YTN1ZlNjQjdD?= =?utf-8?B?UmJKRzdJbkpzRDVTei9aVVpGSVpvLzk2Q2tsRjExcTExUklXNHRBU21Id0Y3?= =?utf-8?B?b3NrVWZlRUdERVBycjVUellGcXFTQVQ1YThxaVN1YXpTL1UrQ0RSL0ticlBm?= =?utf-8?B?NnEwS3dMQUhYK1lKM3AvM0d3SGdNMElhbEFzY2VEQjJGU0dTeTl6K0ZOYVR5?= =?utf-8?B?K1U0cVVv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ce-08dc298afa57 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB5772.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2024 16:20:06.4470 (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: 1cSt2unMgHtqmenfzw+XM4uTsnt/9Zg8VwG1B0v2pVZVk/DQQ4DywdGuUVyaFRDh4ljEle1z245wr9BOLOmlILssxzy8LEXhhFkoPHiwSjg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR11MB6536 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 Hi Wenjing, Please find comments inlined On 05/01/2024 08:16, wenjing.qiao@intel.com wrote: > From: Wenjing Qiao > > To supporting P4-programmed network controller, reuse devargs > "flow_parser" to specify the path of a p4 context JSON configure > file. The cpfl PMD use the JSON configuration file to translate > rte_flow tokens into low level hardware representation. > > Note, the p4 context JSON file is generated by the P4 compiler > and is intended to work exclusively with a specific P4 pipeline > configuration, which must be compiled and programmed into the hardware. > > Signed-off-by: Wenjing Qiao > --- > + if (cpfl_check_is_p4_mode(root)) { > + PMD_DRV_LOG(NOTICE, "flow parser mode is p4 mode."); > + prog = rte_zmalloc("tdi_parser", sizeof(struct cpfl_tdi_program), 0); > + if (prog == NULL) { > + PMD_DRV_LOG(ERR, "Failed to create program object."); > + return -ENOMEM; > + } > + ret = cpfl_tdi_program_create(root, prog); > + if (ret != 0) { > + PMD_INIT_LOG(ERR, "Failed to create tdi program from file %s", filename); > + rte_free(prog); This looks like doublefree to me because cpfl_tdi_program_create() on fail calls cpfl_tdi_program_destroy() which in turn does rte_free for program. On a separate note maybe cpfl_tdi_program_create() function should not call cpfl_tdi_program_destroy() and maybe it should be responsibility of whoever calls _create(). > +static int > +cpfl_tdi_parse_match_key_field_obj(json_t *root, struct cpfl_tdi_match_key_field *mkf) > +{ > + int ret, val = 0; > + char last3char[4]; > + > + ret = cpfl_tdi_get_string_obj(root, "name", mkf->name); > + if (ret != 0) > + return ret; > + > + ret = cpfl_tdi_get_string_obj(root, "instance_name", mkf->instance_name); > + if (ret != 0) > + return ret; > + > + ret = cpfl_tdi_get_string_obj(root, "field_name", mkf->field_name); > + if (ret != 0) > + return ret; > + strncpy(last3char, mkf->field_name + strlen(mkf->field_name) - 3, 3); > + last3char[3] = '\0'; > + if (!strcmp(last3char, "VSI") || !strcmp(last3char, "vsi")) If this is now case sensitive then I'd suggest to make contents of the last3char lower case to handle all variations of "VSi". > + mkf->is_vsi = true; > + else > + mkf->is_vsi = false; > + > + ret = cpfl_tdi_parse_match_type(root, mkf); > + if (ret != 0) > + return ret; > + > + ret = cpfl_tdi_get_integer_obj(root, "bit_width", &val); > + if (ret != 0) > + return ret; > + > + mkf->bit_width = (uint16_t)val; Here and several places below, does it need to be range checked? > + > + ret = cpfl_tdi_get_integer_obj(root, "index", &val); > + if (ret != 0) > + return ret; > + > + mkf->index = (uint32_t)val; > + > + ret = cpfl_tdi_get_integer_obj(root, "position", &val); > + if (ret != 0) > + return ret; > + > + mkf->position = (uint32_t)val; > + > + return 0; > +} > + > +static int > +cpfl_tdi_parse_match_key_fields(json_t *root, struct cpfl_tdi_table *table) > +{ > + int ret; > + int array_len = json_array_size(root); > + > + if (array_len == 0) > + return 0; > + > + table->match_key_field_num = (uint16_t)array_len; > + table->match_key_fields = > + rte_zmalloc(NULL, sizeof(struct cpfl_tdi_match_key_field) * array_len, 0); > + if (table->match_key_fields == NULL) { > + PMD_DRV_LOG(ERR, "Failed to create match key field array."); > + return -ENOMEM; > + } > + > + for (int i = 0; i < array_len; i++) { > + json_t *mkf_object = json_array_get(root, i); > + > + ret = cpfl_tdi_parse_match_key_field_obj(mkf_object, &table->match_key_fields[i]); > + if (ret != 0) Possible memory leak due to earlier rte_zmalloc(). There are several places below with the same problem. > + return ret; > + } > + > + return 0; > +} > + > +static int > +cpfl_tdi_parse_byte_order(json_t *root, struct cpfl_tdi_match_key_format *mkf) > +{ > + char bo[CPFL_TDI_JSON_STR_SIZE_MAX]; > + int ret; > + > + ret = cpfl_tdi_get_string_obj(root, "byte_order", bo); > + if (ret != 0) > + return -EINVAL; > + > + if (!strcmp(bo, "HOST")) { Is it expected to be upper case always? > + mkf->byte_order = CPFL_TDI_BYTE_ORDER_HOST; > + } else if (!strcmp(bo, "NETWORK")) { > + mkf->byte_order = CPFL_TDI_BYTE_ORDER_NETWORK; > + } else { > + PMD_DRV_LOG(ERR, "Unknown byte order type %s", bo); > + return -EINVAL; > + } > + > + return 0; > +} > + > +static int > +cpfl_tdi_pparse_action_code(json_t *root, struct cpfl_tdi_hw_action *ha) double "p" > +static int > +cpfl_tdi_parse_table_obj(json_t *root, struct cpfl_tdi_table *table) > +{ > + int ret, val = 0; > + struct json_t *jobj = NULL; > + > + ret = cpfl_tdi_parse_table_type(root, table); > + if (ret != 0) > + return ret; > + > + ret = cpfl_tdi_get_integer_obj(root, "handle", &val); > + if (ret != 0) > + return ret; > + table->handle = (uint32_t)val; > + > + ret = cpfl_tdi_get_string_obj(root, "name", table->name); > + if (ret != 0) > + return ret; > + > + if (table->table_type == CPFL_TDI_TABLE_TYPE_POLICER_METER) { > + /* TODO */ It looks like not implemented yet, should this return 0? Does it need to have some kind of logging? > + return 0; > + } > +static int > +cpfl_tdi_parse_global_configs(json_t *root, struct cpfl_tdi_global_configs *gc) > +{ > + json_t *jobj = NULL; > + int ret; > + > + ret = cpfl_tdi_get_array_obj(root, "hardware_blocks", &jobj); > + if (ret != 0) > + return ret; > + > + return cpfl_tdi_parse_gc_hardware_blocks(jobj, gc); > +} > + > +int > +cpfl_tdi_program_create(json_t *root, struct cpfl_tdi_program *prog) Should input parameters be checked against NULL? > +{ > + json_t *jobj = NULL; > + int ret; > + > + ret = cpfl_tdi_get_string_obj(root, "program_name", prog->program_name); > + if (ret != 0) > + goto err; > + > + ret = cpfl_tdi_get_string_obj(root, "build_date", prog->build_date); > + if (ret != 0) > + goto err; > + > + ret = cpfl_tdi_get_string_obj(root, "compile_command", prog->compile_command); > + if (ret != 0) > + goto err; > + > + ret = cpfl_tdi_get_string_obj(root, "compiler_version", prog->compiler_version); > + if (ret != 0) > + goto err; > + > + ret = cpfl_tdi_get_string_obj(root, "schema_version", prog->schema_version); > + if (ret != 0) > + goto err; > + > + ret = cpfl_tdi_get_string_obj(root, "target", prog->target); > + if (ret != 0) > + goto err; > + > + ret = cpfl_tdi_get_object_obj(root, "global_configs", &jobj); > + if (ret != 0) > + goto err; > + > + ret = cpfl_tdi_parse_global_configs(jobj, &prog->global_configs); > + if (ret != 0) > + goto err; > + > + ret = cpfl_tdi_get_array_obj(root, "tables", &jobj); > + if (ret != 0) > + goto err; > + > + ret = cpfl_tdi_parse_tables(jobj, prog); > + if (ret != 0) > + goto err; > + > + json_decref(root); is this json_decref() needed? This function is called from cpfl_parser_create() which already does json_decref(). > + > + return 0; > + > +err: > + cpfl_tdi_program_destroy(prog); > + return ret; > +} > + -- Regards, Vladimir