From patchwork Tue Oct 26 15:20:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Etelson X-Patchwork-Id: 102938 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C1656A0547; Tue, 26 Oct 2021 17:20:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8F19840E0F; Tue, 26 Oct 2021 17:20:23 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08on2056.outbound.protection.outlook.com [40.107.101.56]) by mails.dpdk.org (Postfix) with ESMTP id 0F654407FF for ; Tue, 26 Oct 2021 17:20:22 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MX1PP08DOhNnCQ8StxrxzlWjnAIL7lm8dR+iH+MLj5J37EYusS9yBU5zEMksebJMjQ1Y1iHxRQx44RgVxxQnhvbzmiXEFnlM1TgBWxMkcUj0PNLH2PKIhs5dSeKVO/5gbuUXQm7I6H5cmRht8dILG2Dw4UeqiRICJStWF2vWZ7TwtVy8/XF+meIS9etCwXmfxYoj3H2SVcidauw/D/N/MK1MFd4TKwXGErgXe8hH+w+qWqIIoMlU8LWa3YeeICSTTyeQiqSjexCW3jSfSq3PApT17NMdsOsEzmWjFII8vJPs4/EtIU5cUgX/IUjWAcHBY8PabUM6IonqZld2sfEAQg== 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=QIbsqngtACYynsdCaJCrdc0NPD8OQxSVqnBzAgiRhys=; b=a6Cr/LMrGM6LWPoxUfKk26/xrznN6vtnENYy43aNROV6GzuPd3CDZMCFm28I9uhUituCaTa6M7pJSFv2L48eXqE530uPws6vCes/IuP9s05uK7Cr2+7mmrlodNOQ6bTxwlovVFK1Xz+rxIfWNODOqNAqCIe6EJHGetx8jjFEzxH4g0uguOR/PraF8iNKPTmTE6X8sd6JvRbfhiVpHdEad3UmXKvTkgqWCGz6/kkMicbJlRv7OAWF4xr35AunfNMTqzfdGPMsPoPKDKTtcdgXd/fnRo77lFW09gZJ9BoXZOI2CDyKy0LACKeS1Xv95vL3fQWSP0KwA3EPkVPdii6rNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QIbsqngtACYynsdCaJCrdc0NPD8OQxSVqnBzAgiRhys=; b=HtikHOriVUcxhJgz0cdvGleBAmscn5dljAOBH63tcr7m1rOeWNJ4j9XVepfestf8TC+vyK7kFCNaFRdD4NzqZ9NO/VsKWfznGZBmEsigFTKlsf+A17K61JnqsVCyWIK/YWNb8q/0OvDCLiDUq/Af0L5HOlEH02VSVC1cPjSKv/pBF9SnEZ0mo3Ta2DNqnIM6GMFGhM4zCtXs6vfyhPviFqIZgtO3TKabrN6g4jZMiNt1QYx3yOZpp5bCR0qjZOapoEA1h9i5W5wvsqm3l9T5imd1qvwGqeUzH8TkgYx15Yd8Iy5uyRyo108NboNCD30tHDdF25YRX8LMldjua8jxzA== Received: from MW4PR03CA0333.namprd03.prod.outlook.com (2603:10b6:303:dc::8) by MN2PR12MB3710.namprd12.prod.outlook.com (2603:10b6:208:16d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Tue, 26 Oct 2021 15:20:19 +0000 Received: from CO1NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::7b) by MW4PR03CA0333.outlook.office365.com (2603:10b6:303:dc::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18 via Frontend Transport; Tue, 26 Oct 2021 15:20:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT050.mail.protection.outlook.com (10.13.174.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4628.16 via Frontend Transport; Tue, 26 Oct 2021 15:20:18 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 26 Oct 2021 15:20:16 +0000 From: Gregory Etelson To: , CC: , , Xiaoyun Li , Viacheslav Ovsiienko Date: Tue, 26 Oct 2021 18:20:00 +0300 Message-ID: <20211026152000.11665-1-getelson@nvidia.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 76a7f41d-5f3c-4351-6a86-08d998941eac X-MS-TrafficTypeDiagnostic: MN2PR12MB3710: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KCkT2p3FNjzmZLJNm4vZH77AZSN6mIuqddFkwoucbrhpVYAVpZuPn/EsmJFrxcp2Ji8MUpUuXJJGv6pfidlnZanZEcVNi7QLrscmNPTJPVLxx3gMdlxFo4BdKHoYvC6hmdD5g/Cb1KpPPCqUDYK+t/FFYe8aT6sU3sKI9ZvwBj9IZAkwAjLEsVcKZZQtBBMRiBcaDSShwYCpLK5soaocOW48e9fRbY+fSK6mZytQQ3z7VfixR4T/f6Z3AAXeBK696OgG9o6SVkrmkJxNvU1wB3Cu0ONaMA6RnjKTZj3YhoNx2tNNuJTW2HG4k/gmvcTCDLeM1gGAOSnzNMeXe4XARkDagxITq7WnevP/IvvQd1ZpEhLo0Ox0ngmB+kGv53kbe2xqHFQeFGhW6qsaRjOf0wkpUqyFhe/X2b7KRTZmaJUEl8ipxKKnq/isKKIMjxEsw6mxf/p93j7AACo6uHdgdiAQYLYBOMDOc16FT98lQ02T9YrIM4wum0jgAckN/zNMlZx+I8XgA8QIerDmX7nhKIrkGf5ewdE2uwEN2eaMG5Q9S3CQG6AUxUfJRjISVS4KgKd9cizrR8CVYSX2S81Ldk+Tr3uTWCzXfa5yAKrBMWMWtLtDA52kvG7RUYoKwRS3p+zFjjCnt0iF3g2B1/SNpb/WnjStfGqga9n83hWN8w4h0S7j4uAJaSZIwMo2cYxoJwtrtOROgfVXr2fyDAI07w== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(70206006)(6666004)(70586007)(426003)(47076005)(86362001)(110136005)(6286002)(2906002)(16526019)(186003)(2616005)(54906003)(36756003)(36906005)(82310400003)(26005)(7696005)(316002)(7049001)(7636003)(5660300002)(4326008)(55016002)(8676002)(107886003)(1076003)(336012)(508600001)(83380400001)(36860700001)(8936002)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2021 15:20:18.5704 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 76a7f41d-5f3c-4351-6a86-08d998941eac X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3710 Subject: [dpdk-dev] [PATCH] app/testpmd: fix flex item flush 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" Testpmd provides 2 sets of flex item create and destroy functions One for hosts with JSON library. These functions parse flex item configuration stored in JSON file and create or destroy flex item object. The second functions set is for hosts without JSON library for compilation compatibility. On hosts without JSON library, current implementation issues "no JSON library" notification on port close. The notification was triggered by port destructors that include flex items flush routine. The patch introduces single implementation for testpmd flex item destroy. Fixes: 59f3a8acbcdb ("app/testpmd: add flex item commands") Signed-off-by: Gregory Etelson Reviewed-by: Viacheslav Ovsiienko --- app/test-pmd/cmd_flex_item.c | 72 ++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/app/test-pmd/cmd_flex_item.c b/app/test-pmd/cmd_flex_item.c index 45103e45a8..908bcb3f47 100644 --- a/app/test-pmd/cmd_flex_item.c +++ b/app/test-pmd/cmd_flex_item.c @@ -20,13 +20,6 @@ struct flex_item *flex_items[RTE_MAX_ETHPORTS][FLEX_MAX_PARSERS_NUM]; struct flex_pattern flex_patterns[FLEX_MAX_PATTERNS_NUM]; -#ifdef RTE_HAS_JANSSON -static __rte_always_inline bool -match_strkey(const char *key, const char *pattern) -{ - return strncmp(key, pattern, strlen(key)) == 0; -} - static struct flex_item * flex_parser_fetch(uint16_t port_id, uint16_t flex_id) { @@ -41,30 +34,11 @@ flex_parser_fetch(uint16_t port_id, uint16_t flex_id) return flex_items[port_id][flex_id]; } -void -flex_item_destroy(portid_t port_id, uint16_t flex_id) +#ifdef RTE_HAS_JANSSON +static __rte_always_inline bool +match_strkey(const char *key, const char *pattern) { - int ret; - struct rte_flow_error error; - struct flex_item *fp = flex_parser_fetch(port_id, flex_id); - if (fp == FLEX_PARSER_ERR) { - printf("Bad parameters: port_id=%u flex_id=%u\n", - port_id, flex_id); - return; - } - if (!fp) - return; - ret = rte_flow_flex_item_release(port_id, fp->flex_handle, &error); - if (!ret) { - free(fp); - flex_items[port_id][flex_id] = NULL; - printf("port-%u: released flex item #%u\n", - port_id, flex_id); - - } else { - printf("port-%u: cannot release flex item #%u: %s\n", - port_id, flex_id, error.message); - } + return strncmp(key, pattern, strlen(key)) == 0; } static int @@ -399,15 +373,37 @@ 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"); + printf("cannot create flex item - no JSON library configured\n"); } +#endif /* RTE_HAS_JANSSON */ -void flex_item_destroy(__rte_unused portid_t port_id, - __rte_unused uint16_t flex_id) +void +flex_item_destroy(portid_t port_id, uint16_t flex_id) { - printf("no JSON library\n"); + int ret; + struct rte_flow_error error; + struct flex_item *fp = flex_parser_fetch(port_id, flex_id); + if (!flex_id) + return; + if (fp == FLEX_PARSER_ERR) { + printf("Bad parameters: port_id=%u flex_id=%u\n", + port_id, flex_id); + return; + } + if (!fp) + return; + ret = rte_flow_flex_item_release(port_id, fp->flex_handle, &error); + if (!ret) { + free(fp); + flex_items[port_id][flex_id] = NULL; + printf("port-%u: released flex item #%u\n", + port_id, flex_id); + + } else { + printf("port-%u: cannot release flex item #%u: %s\n", + port_id, flex_id, error.message); + } } -#endif /* RTE_HAS_JANSSON */ void port_flex_item_flush(portid_t port_id) @@ -415,8 +411,10 @@ port_flex_item_flush(portid_t port_id) uint16_t i; for (i = 0; i < FLEX_MAX_PARSERS_NUM; i++) { - flex_item_destroy(port_id, i); - flex_items[port_id][i] = NULL; + if (flex_items[port_id][i] != NULL) { + flex_item_destroy(port_id, i); + flex_items[port_id][i] = NULL; + } } }