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 A9135A034F; Mon, 19 Jul 2021 16:03:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 52A56411A5; Mon, 19 Jul 2021 16:02:42 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20046.outbound.protection.outlook.com [40.107.2.46]) by mails.dpdk.org (Postfix) with ESMTP id D110F411A5 for ; Mon, 19 Jul 2021 16:02:38 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P5f9qZ1XnuSI0+Hp6Q19hgQdYGVNbLHVHaEvS9j9T9ksEy4VxL0tOayl4pN34Y3swFFvsCne903XjG4TaNEQ6sG390cdTed5lHKXNh6ft8JmObUc3uZgfWFK/1UK0X5WUhD59hFds25mYVPRHR8uBUy2JdvKJC7QFiR9f15SdJySToH5yMC8L4wwo+e/0LZrnue5i52w04dS8yXS3wr0/iep8eMSS38wsYk2m2sXHu1X10YGlA+L7nNdby38Xw2D1dZ0MaqgGLVavgIwZ+mKRZyWODBTWESv3QC8Tr9D2HDPu0qUTjRLyQGQuRUkDmVOaLug6kqPbz2T3+Cv5INJqQ== 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-SenderADCheck; bh=UVu06kTWYfE5QXohBSFrIC8CEeYPBfrHa3YsNHBXwxI=; b=l1zczs+NyCahWUmpoAdfq7Im9bHXht/urTiaVbQIAe3DZPgmAgrbH+K2xJRFAc/r6H15jKBoPY9jXIfyIug76BT94RpAPSz3J1mU5zhm4+1COIvSLcrCqe4armUS4f5nj0WTTWSpfowQaZF74X6zPp82CvJlSTejjzk2PEVxrCLfEvRb2YHy+VRJ6dEM0su336evOh6FDq2GuemxTWs6BeyCAph6ymm4SWugX0oGa0QgU9OtxOeuZUOdsmOCDETOdCGemQhw31+Y22OMerddKBlMHLihQbGHW6H7bEAB1lMOteebw5WNfogHhwSXlClv5Pj86BCJiS1FARdRGDKb2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UVu06kTWYfE5QXohBSFrIC8CEeYPBfrHa3YsNHBXwxI=; b=GwNjoLycRSKUb0yz/U0hzKvU42G2dgVE+XkYWxy74nwBTu/R7dCAO52KGmmBmvBMXrRcmXCOY1dDOsr1xYEigrlBB4Iuhpt2coHzlr2h7pOT3u567aJVZMcsBhrYWCVAAuLlv4GUiGKcDmHRMk5OJJuHGT3HGlUVRzcSlqlQ9IU= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) by DU2PR04MB8520.eurprd04.prod.outlook.com (2603:10a6:10:2d3::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.23; Mon, 19 Jul 2021 14:02:38 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::f483:9bb1:cde3:8a28]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::f483:9bb1:cde3:8a28%6]) with mapi id 15.20.4331.032; Mon, 19 Jul 2021 14:02:38 +0000 From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Vanshika Shukla Date: Mon, 19 Jul 2021 19:29:16 +0530 Message-Id: <20210719135917.26241-7-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210719135917.26241-1-hemant.agrawal@nxp.com> References: <20210719135917.26241-1-hemant.agrawal@nxp.com> Content-Type: text/plain X-ClientProxiedBy: SG2PR02CA0038.apcprd02.prod.outlook.com (2603:1096:3:18::26) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from dpdk-xeon.ap.freescale.net (92.120.0.67) by SG2PR02CA0038.apcprd02.prod.outlook.com (2603:1096:3:18::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Mon, 19 Jul 2021 14:02:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2885497f-58d2-4ecc-3118-08d94abdddca X-MS-TrafficTypeDiagnostic: DU2PR04MB8520: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2582; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KkF7KsYQd6/ZR89EiTyCcigFVKMn7EVI4FqazVHNoWsGiyvoUL4Prjy/c7+sGYY49FiO1Pz/0dTn7O59zX2xTyrWDrDuvUIfL8IbStrWzlniuSZOlIlIL7fvL6bHB63xooG/oGYWcH+Pp60tCj8pOg8h2mS8D+T4nahBkht+7XWH5gcZKYvwKp19Qz/ziOi/Ov8ZawdIWDicwd3AWEoE+Wlqx3HG66iep8MItO/hbon7TLHaN1+9dczFJvr4dLvxD9sr7b19RcNlQxh6yOaW02agMOJhFgHkG0wAWwDHDfEh6BwuPKYHX+TfJ93KCzkCfeKDi+OgdwXzfIe81s8C6wVH+kgGhRtvd3rvH6+wW2OgY9YOnLAze4SniU6AcJPnBG/ctEG5RIOWSDOJpc5NiGMuFMRyEIge7nemGxJJ2DaXv34SiuLdWbzdXaVh3h5CqIqy3nzU3g26wjo9GgETOhGneDFxBFnnjACckxBc0maqz3ln1U0uOo0cR3t+lCTta2wD4ESkmlHgokSmdcDHOmKdmegK4bj7fNzDYS40a0NU3QoZOXOy08MftyfTqOFdLOtxwt0yZSSg8zrEixYNUO8PRUpEdiHuYLFmd18D2PDvBdV/MC9wbWfCD3tVXwPqo6vo8kZ/qwyJnXGGB2+75SWcwZlyuWt4UNuPcGzsL/tHSnybJdbCGVvu6q3M9lJm2wD7aLHiC2Q/DOuh9QGDog== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU2PR04MB8630.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(366004)(136003)(376002)(346002)(396003)(6486002)(8936002)(38350700002)(38100700002)(956004)(8676002)(66946007)(44832011)(2906002)(66556008)(66476007)(5660300002)(6512007)(1076003)(2616005)(316002)(186003)(36756003)(6916009)(4326008)(83380400001)(6666004)(26005)(6506007)(52116002)(478600001)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?7v4F23xKw4d54mVceLOMCeEIl0nerDg8fgQ0W2fXAJ68/G0yGbPgvVN4NJKz?= =?us-ascii?Q?b/T7psnKTktLG+ylGGNbhijrBaxK8rAuLhsrfE7dD1zNKPIqVvD679CHl3Zt?= =?us-ascii?Q?DS5OrlXHelRIYi5CjOWbzzjSgu5/6vdAGR+1PQ1pW0EaiHBl2E5jabwBy0uF?= =?us-ascii?Q?lJhGh2tYF2wdhvQj4YdLho9vZkJWAgJSheOpSqW1vasvy4EQUtQOVLsDb2wG?= =?us-ascii?Q?oLCcEQp++ExGF1U/X/ZVXw1ORwaR1NREE7G/tIk8kudSLrYyDC1eEiyZiiDZ?= =?us-ascii?Q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miAJwA3O?= =?us-ascii?Q?Hx139N5Gl7gP8YqTmmp0GZ3Vi1sX8kE/1qYKymefX/8hu/yRSHj1Fuug2GZm?= =?us-ascii?Q?mZNOvbYLyV9hMH1eox69U2pbzi0IBhgJcbqZboYIXwIaQ5eaTu63JujuIKnC?= =?us-ascii?Q?QOqwMEpCvtsdKCujttgyk5gr?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2885497f-58d2-4ecc-3118-08d94abdddca X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2021 14:02:38.1857 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UjmCQXbB+V5W+R+rwTosJRazNpxCGoan3+rVrMoi7YC0qrF03O9DQN/EADrPJFk7OuvOTBmn7omGwXEGz4oEJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8520 Subject: [dpdk-dev] [PATCH 6/7] net/dpaa2: add input validation 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" From: Vanshika Shukla This patch adds validation of the port id for rte_pmd_dpaa2_set_custom_hash API to check if the port is a valid DPAA2 port. Also handles some edge cases in the rte_pmd_dpaa2_mux_flow_create API. Signed-off-by: Vanshika Shukla Acked-by: Hemant Agrawal --- drivers/net/dpaa2/base/dpaa2_hw_dpni.c | 11 +++++++++++ drivers/net/dpaa2/dpaa2_ethdev.c | 4 ++-- drivers/net/dpaa2/dpaa2_ethdev.h | 1 + drivers/net/dpaa2/dpaa2_mux.c | 3 +++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c index b901b4342f..641e7027f1 100644 --- a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c +++ b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c @@ -41,6 +41,17 @@ rte_pmd_dpaa2_set_custom_hash(uint16_t port_id, void *p_params; int ret, tc_index = 0; + if (!rte_eth_dev_is_valid_port(port_id)) { + DPAA2_PMD_WARN("Invalid port id %u", port_id); + return -EINVAL; + } + + if (strcmp(eth_dev->device->driver->name, + RTE_STR(NET_DPAA2_PMD_DRIVER_NAME))) { + DPAA2_PMD_WARN("Not a valid dpaa2 port"); + return -EINVAL; + } + p_params = rte_zmalloc( NULL, DIST_PARAM_IOVA_SIZE, RTE_CACHE_LINE_SIZE); if (!p_params) { diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index d892819a7e..c12169578e 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -2905,8 +2905,8 @@ static struct rte_dpaa2_driver rte_dpaa2_pmd = { .remove = rte_dpaa2_remove, }; -RTE_PMD_REGISTER_DPAA2(net_dpaa2, rte_dpaa2_pmd); -RTE_PMD_REGISTER_PARAM_STRING(net_dpaa2, +RTE_PMD_REGISTER_DPAA2(NET_DPAA2_PMD_DRIVER_NAME, rte_dpaa2_pmd); +RTE_PMD_REGISTER_PARAM_STRING(NET_DPAA2_PMD_DRIVER_NAME, DRIVER_LOOPBACK_MODE "= " DRIVER_NO_PREFETCH_MODE "=" DRIVER_TX_CONF "=" diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h index 7b76ca7b2d..b9c729f6cd 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.h +++ b/drivers/net/dpaa2/dpaa2_ethdev.h @@ -19,6 +19,7 @@ #define DPAA2_MIN_RX_BUF_SIZE 512 #define DPAA2_MAX_RX_PKT_LEN 10240 /*WRIOP support*/ +#define NET_DPAA2_PMD_DRIVER_NAME net_dpaa2 #define MAX_TCS DPNI_MAX_TC #define MAX_RX_QUEUES 128 diff --git a/drivers/net/dpaa2/dpaa2_mux.c b/drivers/net/dpaa2/dpaa2_mux.c index 811f417491..d347f4df51 100644 --- a/drivers/net/dpaa2/dpaa2_mux.c +++ b/drivers/net/dpaa2/dpaa2_mux.c @@ -68,6 +68,9 @@ rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id, int ret; static int i; + if (!pattern || !actions || !pattern[0] || !actions[0]) + return NULL; + /* Find the DPDMUX from dpdmux_id in our list */ dpdmux_dev = get_dpdmux_from_id(dpdmux_id); if (!dpdmux_dev) { -- 2.17.1