From patchwork Wed Apr 21 15:59:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmytro Linkin X-Patchwork-Id: 425746 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BBBBC433ED for ; Wed, 21 Apr 2021 15:59:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B7106144E for ; Wed, 21 Apr 2021 15:59:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241527AbhDUQAI (ORCPT ); Wed, 21 Apr 2021 12:00:08 -0400 Received: from mail-dm3nam07on2064.outbound.protection.outlook.com ([40.107.95.64]:54817 "EHLO NAM02-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241397AbhDUQAG (ORCPT ); Wed, 21 Apr 2021 12:00:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SiaJh7EZ87NzlEiDb+5uXyMlxjmJbSeh7uaS22Hxn8HIgVBKQz6YL4XEE2yVL5rrx0DHIE47f8aPIiypRky6xcQA0adQpZVwkQTOKqmkBWp3kgjIqhMxHTAP/RHpO5gvzSyS19515eNKbqvOddqqJl93v2gAmWAxOuqQqZn68XPYkqvxx+/j2xEzqkbqB0u55vDrmGQB4U0RWFFDXaklotDw5nfKqau5bVAzFTng3BSaLUxBvuSErc5ESCHPgXzvt9UvRuA01gDQ9TCIM8SSiiqv0J0JiG7nyhP8yu0xi24ywkm3bfNWrCd3Z3PelWs8/EKMnZuEQTELFbsA/nyqLA== 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=olVyyWd5jy/nH075ilXHUd2fS1DbS4/x3flsA+f/DKw=; b=GZuYmoz5KkXjfl96nbGLsoEh/tji0VgunBToE5UKO+ihc3f5QbPjy7ntoWfQWRY5VwL7e0NT3//nzFmnh2PRRw/EJ2M805Thq90n+hmAWm/u0i//S/0+2IusWHxYD5sSyAgGYFDoG8NIg7N6PNWB8aGwuszbILFGBGR4Qc/NEnqbTcN6gAi5waujiHM5NX4FZogo8Oca306IqFF7x5UXpg54MtIMSNW2fE4S1fHeVeGdPjM8js8mFbL36SkU3jvdPX8P2R4tHA9SLE81kTZBwABzxrOT5rGFMXFsk66kCyhFG+1N/zYnp6afrhELavEANJyLY9Npd3Vh3FDj5GMAfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.36) smtp.rcpttodomain=networkplumber.org smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none 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=olVyyWd5jy/nH075ilXHUd2fS1DbS4/x3flsA+f/DKw=; b=GqiCyeWg5iGOIvmnjFZ8kqfbPvHiKciCD7NgBECnVysJURsvasQk8NAFlo0oJ1V2KBZ5ItJnPsrMVsh78Bnkj5/kLCARDg9db/IjbBX0GE/5a3rI42kCknlL0dOxJP7LSCwUAS3gFU6DAXGf9bePSniceutR10LaYiMz2TT++kXvlnKIMK5If5gHxeKJ+/RxSg2mrT6ERqHPyc1MyI82ArPBBR/JZgA4xfxhdmo6hpETTB9m0+5gZkGzTSfi6SbQd5b4eNRJDXpnnMLwvJ82kURxudMGSRcexJCEsoNDwtSU7GKybaGSHeqhyhQaC8wqcDB2za9/qHST3xEwt+WVhg== Received: from MWHPR01CA0028.prod.exchangelabs.com (2603:10b6:300:101::14) by BN6PR12MB1635.namprd12.prod.outlook.com (2603:10b6:405:3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.18; Wed, 21 Apr 2021 15:59:32 +0000 Received: from CO1NAM11FT021.eop-nam11.prod.protection.outlook.com (2603:10b6:300:101:cafe::ea) by MWHPR01CA0028.outlook.office365.com (2603:10b6:300:101::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22 via Frontend Transport; Wed, 21 Apr 2021 15:59:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.36) smtp.mailfrom=nvidia.com; networkplumber.org; dkim=none (message not signed) header.d=none;networkplumber.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.36 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.36; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.36) by CO1NAM11FT021.mail.protection.outlook.com (10.13.175.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4065.21 via Frontend Transport; Wed, 21 Apr 2021 15:59:31 +0000 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Apr 2021 15:59:31 +0000 Received: from vdi.nvidia.com (172.20.145.6) by mail.nvidia.com (172.20.187.13) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 21 Apr 2021 15:59:28 +0000 From: To: CC: , , , , , , Dmytro Linkin Subject: [PATCH RESEND RFC iproute2 net-next 1/4] uapi: update devlink kernel header Date: Wed, 21 Apr 2021 18:59:22 +0300 Message-ID: <1619020765-20823-2-git-send-email-dlinkin@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1619020765-20823-1-git-send-email-dlinkin@nvidia.com> References: <1619020765-20823-1-git-send-email-dlinkin@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9cf29243-16d1-4b47-c679-08d904de7388 X-MS-TrafficTypeDiagnostic: BN6PR12MB1635: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1169; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gOyIL5q90WZpxeEm3rI0CLd7soBjZZM0WWpV9OskXukFaCHTNoTCAe9QJzANURer1OosgYiTiRNK3iEWzyotCZIEg0SoXd7E/ENcl39e2VcEnS+eQG1ylyz2jtjLKQ0O44EQmP7ZbHqnwW7BtAU4E2UmTGURXwG5RtzHg+XtWmDBJnhNJVqFDmoKXwa5CsMEjnamnVXZSlTKAGlbwtWF+qUSaJLwfDNl38BI7OV6d97v1Uc8HV4Q/cW+D9lzWcHg9+MpqpLxJ/bvFsbxTx6O3NPphKw0v3cUtUeJcjJreo/ab08xRXjLxJXqGUXxwKJWdh6+wSvumaU7VIvblj+wPDSoFzU3TDvxzsUt+OCixh2RVTDkjjmZFMLDkN0aN7QvtEawSuDxZtF2s1qqENXskzzvHaqiZdGxb5zz2tyhV0wB4OnrsGhYtsXgdlsP7HW5sMKId0jeXe2u6dhdQa9pQca8/v/ITfKUMyHzEo3TxQAKTFb9j3B1OLjASaIMlKPnTTkhUgnTAUUkSbRxzST8Lftt0C+gBv6fivE3XjkaE6+d6iVJWhfKvwGlvRhpPkXlUYbwk5loiox4ebhINjhaG6Ws4enHvvMK6egU8BoXi1HY5nAXuICxHYqGIzTTQabho2f+4BcsbWZy/TsZ0ssr2Rf9tDxyk4KPpzJGxQdy1Tw= X-Forefront-Antispam-Report: CIP:216.228.112.36; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid05.nvidia.com; CAT:NONE; SFS:(4636009)(39860400002)(396003)(136003)(376002)(346002)(46966006)(36840700001)(2616005)(54906003)(36860700001)(336012)(8676002)(47076005)(316002)(36906005)(4326008)(70586007)(86362001)(6916009)(6666004)(82310400003)(36756003)(70206006)(426003)(8936002)(2906002)(7696005)(2876002)(7636003)(26005)(186003)(82740400003)(478600001)(107886003)(5660300002)(15650500001)(83380400001)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2021 15:59:31.6060 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9cf29243-16d1-4b47-c679-08d904de7388 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.36]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT021.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1635 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Dmytro Linkin Signed-off-by: Dmytro Linkin --- include/uapi/linux/devlink.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h index a430775..6408b40 100644 --- a/include/uapi/linux/devlink.h +++ b/include/uapi/linux/devlink.h @@ -126,6 +126,11 @@ enum devlink_command { DEVLINK_CMD_HEALTH_REPORTER_TEST, + DEVLINK_CMD_RATE_GET, /* can dump */ + DEVLINK_CMD_RATE_SET, + DEVLINK_CMD_RATE_NEW, + DEVLINK_CMD_RATE_DEL, + /* add new commands above here */ __DEVLINK_CMD_MAX, DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1 @@ -206,6 +211,11 @@ enum devlink_port_flavour { */ }; +enum devlink_rate_type { + DEVLINK_RATE_TYPE_LEAF, + DEVLINK_RATE_TYPE_NODE, +}; + enum devlink_param_cmode { DEVLINK_PARAM_CMODE_RUNTIME, DEVLINK_PARAM_CMODE_DRIVERINIT, @@ -534,6 +544,13 @@ enum devlink_attr { DEVLINK_ATTR_RELOAD_ACTION_STATS, /* nested */ DEVLINK_ATTR_PORT_PCI_SF_NUMBER, /* u32 */ + + DEVLINK_ATTR_RATE_TYPE, /* u16 */ + DEVLINK_ATTR_RATE_TX_SHARE, /* u64 */ + DEVLINK_ATTR_RATE_TX_MAX, /* u64 */ + DEVLINK_ATTR_RATE_NODE_NAME, /* string */ + DEVLINK_ATTR_RATE_PARENT_NODE_NAME, /* string */ + /* add new attributes above here, update the policy in devlink.c */ __DEVLINK_ATTR_MAX, From patchwork Wed Apr 21 15:59:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmytro Linkin X-Patchwork-Id: 425745 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A254FC433B4 for ; Wed, 21 Apr 2021 15:59:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7813061455 for ; Wed, 21 Apr 2021 15:59:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243805AbhDUQAL (ORCPT ); Wed, 21 Apr 2021 12:00:11 -0400 Received: from mail-bn7nam10on2047.outbound.protection.outlook.com ([40.107.92.47]:23264 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241397AbhDUQAI (ORCPT ); Wed, 21 Apr 2021 12:00:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NNvLaFelRSsqsXP5ZK5vounOgaxlJnujr4EkUpOFFCg5DSZV+cy2oW+AhwRIuBY9D6lcK2e7ndoP6/VyjvcXMQ2BFwnLqMXlXPD/VnasAx9hRzgpzIFznMFYvf2lRM7vyuQwFdmuJo8Z0e6/WO0RLT0fh40zMW+H9DgDsN7y1B2biNwNH8dwd+e5nZh1L9d1cc2e+aTJOLAJzj19cJLmOZAeWWwzt6llvSaRY2YYcCkbRiVsdz3Vq0SDlIRtCKntbFPiaYm7OWJSrocqv3a4kwOKaeoxzXjFPzqlHzY1cxrMzOefGEsMhc0Knaz5pxcmn+n7y8vi6SIFM7IcjH2QTg== 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=kEgfrUfrD0aOk4soCLjfzfRxraMpfGFu2+d8qZHTJK4=; b=jatBhqI26acf2XKG9aJQLJy5VaaGADtonZc8g3asewWvAdFrc08ioqGxrLu0CbuXeztOqjAYGah+s7WpRr9jSM5s8e6nEzYgTEoiRXjsIk+8Q2Aav/g3zImYsfr2olXTTjRwZpiahsotZfmbgfMed/DH+qtoECv+nToKzUFTmtgepuLQj7uU9Luds9FQmpYaDL558X9Z+96Sh4HeiudTh2M8pL2ebqzIZf/uVhCOU085csfazzOHyIERx/8HisVAB2a8+C8/BkYesZiexOIfPhcEu5VRNkJg/DL9MZ4rF6T3W/xKiwkKplQd4oGjxbViQs72Cc7ZUJRmKhjo1E2OUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.36) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none 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=kEgfrUfrD0aOk4soCLjfzfRxraMpfGFu2+d8qZHTJK4=; b=Rway+IIdTkbJL5vTLdkSAP4AFQNPFE+Oj65JF2JpYLa0v/y6Ad7DvDo6D1pCb8eWChkbrW2sgLPCZsAzj8QcSsqcL2NPhAlpG/R7PX3zvpE0NJUqsH8cJYdm1r2fY8WBzWrC6MTYtpzS3SfWRaNrbF2OPBe8AXz1GIM+UT8VCMPPyhFZ7xXMRwLxxs+SV6F67F493v8Wi2NH/+F7+dxC5Fla5pAKEbRsMUF8pKp6BLn4jbcz1NT+3JGw/U1QJcNvE63Fd7H93DPnc0WFMIz2xOf/qKvKL/eCZ3vi2alIp8bLzrh90FpzYW93kFinD9bEmI08pZweRoDla2E1/2fjkA== Received: from CO1PR15CA0113.namprd15.prod.outlook.com (2603:10b6:101:21::33) by DM6PR12MB2603.namprd12.prod.outlook.com (2603:10b6:5:49::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.18; Wed, 21 Apr 2021 15:59:34 +0000 Received: from CO1NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:101:21:cafe::a) by CO1PR15CA0113.outlook.office365.com (2603:10b6:101:21::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Wed, 21 Apr 2021 15:59:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.36) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.36 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.36; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.36) by CO1NAM11FT052.mail.protection.outlook.com (10.13.174.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4065.21 via Frontend Transport; Wed, 21 Apr 2021 15:59:34 +0000 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Apr 2021 15:59:33 +0000 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Apr 2021 15:59:33 +0000 Received: from vdi.nvidia.com (172.20.145.6) by mail.nvidia.com (172.20.187.13) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 21 Apr 2021 15:59:31 +0000 From: To: CC: , , , , , , Dmytro Linkin Subject: [PATCH RESEND RFC iproute2 net-next 2/4] devlink: Add helper function to validate object handler Date: Wed, 21 Apr 2021 18:59:23 +0300 Message-ID: <1619020765-20823-3-git-send-email-dlinkin@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1619020765-20823-1-git-send-email-dlinkin@nvidia.com> References: <1619020765-20823-1-git-send-email-dlinkin@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0d7174d7-9ed5-4af8-f281-08d904de7511 X-MS-TrafficTypeDiagnostic: DM6PR12MB2603: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1923; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MBxsu63BMWB7QZhbJreXDdCt3kGSonFMdhy2o2hzZ+YdZpCwHF8J98s5dJ8xPLB/LQMLqf8K42ppG+s5nERtu26HNEjTohNT7VTV0lRm4ArmFQq/f5waQK7FxCfCo+BfOEm31/FJ+JCZ8rFzK97po7sycxIC5gMuSoJvPEyR9KEQEII/1PaSbiGQSgfaMpba48hgBnyfZdGNx6xOBJx/D4MMxUE8dY8/fMEjvEJ6OHrPzu4pscUfBz66SNte8tsu6/1pKC9CC/jPKQj8mfra+M4P67LFF1KORahugdRl4EoonHdLPeyOlYIDrUjY0dGjOhiLgrKmubcfxyqhBXMiShmuHzu2vbATTfbdrEZmdmjuFJZHCus5BbDlBzY520/tLJJ7aZevuzWwL6JLcFjnGiXj05vpBnbcKBADlKpm85+6IdIWU8AbcROFj/Gq+ykic10e6g4ydEyI777xvve3JIqNjiUjUvNTDFSfTqTKy9hxHh/lEGasQR58p1Qx3JjgqSr8309pWuDfEihrbr5gkC9kevyGj59EmmygFGGAeUoKccUor/C8LMxXcFp7UU9L6qt6YCl3ls8OLLUw/EQnUJpmE1QMVBlRctjh0Lji7KbieR7WqiPCnsHdcMLgGBZLZ1RD8iuyM1HSIncL81m/b4HAAW61wVmNJ3SEuL+EDNE= X-Forefront-Antispam-Report: CIP:216.228.112.36; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid05.nvidia.com; CAT:NONE; SFS:(4636009)(346002)(39860400002)(136003)(376002)(396003)(36840700001)(46966006)(82310400003)(26005)(7636003)(8676002)(83380400001)(86362001)(15650500001)(70586007)(6666004)(6916009)(356005)(36860700001)(8936002)(36906005)(4326008)(478600001)(36756003)(316002)(186003)(107886003)(82740400003)(54906003)(2906002)(2876002)(2616005)(7696005)(336012)(426003)(5660300002)(47076005)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2021 15:59:34.1907 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0d7174d7-9ed5-4af8-f281-08d904de7511 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.36]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2603 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Dmytro Linkin Every handler argument validated in two steps, first of which, form checking, expects identifier is few words separated by slashes. For device and region handlers just checked if identifier have expected number of slashes. Add generic function to do that and make code cleaner & consistent. Change-Id: Ib44aa2adc2b287c879cebfae82071ed56f3f011b Signed-off-by: Dmytro Linkin Reviewed-by: Jiri Pirko --- devlink/devlink.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index 16eca4f..f435fc8 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -915,6 +915,19 @@ static int strtobool(const char *str, bool *p_val) return 0; } +static int ident_str_validate(char *str, unsigned int expected) +{ + if (!str) + return -EINVAL; + + if (get_str_char_count(str, '/') != expected) { + pr_err("Wrong identification string format.\n"); + return -EINVAL; + } + + return 0; +} + static int __dl_argv_handle(char *str, char **p_bus_name, char **p_dev_name) { str_split_by_char(str, p_bus_name, p_dev_name, '/'); @@ -924,15 +937,12 @@ static int __dl_argv_handle(char *str, char **p_bus_name, char **p_dev_name) static int dl_argv_handle(struct dl *dl, char **p_bus_name, char **p_dev_name) { char *str = dl_argv_next(dl); + int err; - if (!str) { + err = ident_str_validate(str, 1); + if (err) { pr_err("Devlink identification (\"bus_name/dev_name\") expected\n"); - return -EINVAL; - } - if (get_str_char_count(str, '/') != 1) { - pr_err("Wrong devlink identification string format.\n"); - pr_err("Expected \"bus_name/dev_name\".\n"); - return -EINVAL; + return err; } return __dl_argv_handle(str, p_bus_name, p_dev_name); } @@ -1067,18 +1077,12 @@ static int dl_argv_handle_region(struct dl *dl, char **p_bus_name, char **p_dev_name, char **p_region) { char *str = dl_argv_next(dl); - unsigned int slash_count; + int err; - if (!str) { - pr_err("Expected \"bus_name/dev_name/region\" identification.\n"); - return -EINVAL; - } - - slash_count = get_str_char_count(str, '/'); - if (slash_count != 2) { - pr_err("Wrong region identification string format.\n"); + err = ident_str_validate(str, 2); + if (err) { pr_err("Expected \"bus_name/dev_name/region\" identification.\n"".\n"); - return -EINVAL; + return err; } return __dl_argv_handle_region(str, p_bus_name, p_dev_name, p_region); From patchwork Wed Apr 21 15:59:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmytro Linkin X-Patchwork-Id: 425744 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60583C433ED for ; Wed, 21 Apr 2021 15:59:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D8AA61453 for ; Wed, 21 Apr 2021 15:59:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241397AbhDUQAP (ORCPT ); Wed, 21 Apr 2021 12:00:15 -0400 Received: from mail-bn7nam10on2086.outbound.protection.outlook.com ([40.107.92.86]:62222 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S243847AbhDUQAN (ORCPT ); Wed, 21 Apr 2021 12:00:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YI8uowoOuOMS4H0goOqDX1TW+rCDVvscwjns/Fzr5qtCoCQKpYe0oZp5OyGOZ8HhaJg0QfKRdroY+34KDW00PeeymO7MQBfw8ZaJY4K3QMr7cYlAl/LpSb8puW1lVLARisTTpNHQWDBOsP+JaCBc/zQqz2/MI7hhMJ8R1ihWmOBwRN41N7rJFp+/EYXOLxamm21VDj/J1JGo8dcR3YC9v00s19kVw/iCpNstdlWQmvxh2HRZExWe0757kISqduqGAz44mSD+SUEjFd3YdwT/+YM1tB1Ouc4dG789L4XMvovEU0n4GpdL0w2wem8yPRVfHwnBe4ZWzHwSE+6aIKQVUg== 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=EMrT72f/Uy5FQZnyloqR9i1zAXAy/ZbU44I/1nk/bYo=; b=mmbsV5m0TLeyNFLoDW0wtoa4GZsNPpZkJoj89VG+ryPYrOcEoZbsso2Vm/L7aetH0gTZAgEC+RmkEMwylD4fnQCbS1GxOkaP+fJDPNbVXKflN+/WPfi//PiTowKUI1YCj3053nR9dTGo3Br3CQxAIhOQVQq24hYUfkQ4SFTxsZDOZ6pS7uAQa7/4iGHhymkBExJZ3IiOAYYxCO9ximWHB9x4BoebpwYxk4qN0/RiW2AydfqE4tad9DG7N+X46TiAT7MAn+idjkopkIOBvC0iAuXWUMrWVbXLxmUECxLbI03jYWm33Bk8Uk1KjfJHszCZjcUHUWN7mCwRD9/EcLjHDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none 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=EMrT72f/Uy5FQZnyloqR9i1zAXAy/ZbU44I/1nk/bYo=; b=eirJ3bNzGYO+GTcYnGzM4d8PZeNVsaec2691gGjP/iiJEG9d/yKspnLe7J0c3RTlm24AG1J04k33VS7fAxZL9N7CV459wq/vO0G0DQsltfpakFtIM14GqQIYma4fwWJzZAcT6PMhfBKI+drw9bbzow1lvmi/lmkZqak6711CEBXa0ZKu/vU8VewHtqkUPYAvbwCSLtaWYGy94IHnEEPNbJMaQcuMvC/5tGv3B6qTp1W+2+y5hRqtiphPaLQ02h/siNQimvY9mm8zWDeD6IiPE0rnz8m41wEZj6z16cdJ5zWh4yinwK6gLyiOGHHr/Beha6iyggb/XrKl77kXnbwiqw== Received: from MW4PR02CA0018.namprd02.prod.outlook.com (2603:10b6:303:80::16) by BY5PR12MB4323.namprd12.prod.outlook.com (2603:10b6:a03:211::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16; Wed, 21 Apr 2021 15:59:39 +0000 Received: from CO1NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:303:80:cafe::46) by MW4PR02CA0018.outlook.office365.com (2603:10b6:303:80::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Wed, 21 Apr 2021 15:59:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; 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 CO1NAM11FT018.mail.protection.outlook.com (10.13.175.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4065.21 via Frontend Transport; Wed, 21 Apr 2021 15:59:39 +0000 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Apr 2021 15:59:38 +0000 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Apr 2021 15:59:38 +0000 Received: from vdi.nvidia.com (172.20.145.6) by mail.nvidia.com (172.20.187.13) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 21 Apr 2021 15:59:36 +0000 From: To: CC: , , , , , , Dmytro Linkin Subject: [PATCH RESEND RFC iproute2 net-next 4/4] devlink: Add ISO/IEC switch Date: Wed, 21 Apr 2021 18:59:25 +0300 Message-ID: <1619020765-20823-5-git-send-email-dlinkin@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1619020765-20823-1-git-send-email-dlinkin@nvidia.com> References: <1619020765-20823-1-git-send-email-dlinkin@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 97673759-aaa2-4c17-63e3-08d904de7805 X-MS-TrafficTypeDiagnostic: BY5PR12MB4323: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:626; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mZJ7hNZoq+j4iClNHXtRC1nqEq719n+/v+rkuI6kcHFArkhsYmSnD/9nbJdan1iQoEQqECTBqTcGp2nheOvV0QA4IPEOnfHRGDQWNxG/6H25COg1WX84OHby4apofHxkI8IPQ4pWUN0jU46H5zawdBBrV4/05PQ62Z+u2AMe3+sP4dzUXXOBBtDn2hQXqal82kWBoCTmdmYSbh+FEDGfVKrwqJLpBNFpDY6jovZo/PY87dwjEZXcKKQrP5Bm3jJg10q6nN8geOxGicLzEF6YwU9U+hgRibDoDOLV2YsBYA0234VAn/HwP2wn8s3kvHA5mILsMD4X8lYwQ96LZe1CGlMO+Szhidv+CrVAqwMrgHg/h75AUlgUoP9vKz2rmYKKsJ4RBrg68aGlHnORJ9e9mKZianr7YFuR3MJmqNJiT737eu9QYZRnsAf6DcOqhOsHCiFLqmuIoGHhjgttPfC0Fbm3ZMXicDAm5d2rkRrk29Z6tcLt3dGxlvBOogBBzR7nIaQzTx659g3SS/GH6nryNoy+VAMtr0YzIzJV4ipkkAWclZcVfIPVuGXzFKlYN8CWO4LhgZq7KIVSWXZkbXhIAGBEZq53T5+6zlcXy8lI+TfbWVB9Rjsg4S/WKxYHl+95vpaFBo7kUGrZ4Yn87YKKIA== 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)(136003)(396003)(39860400002)(376002)(346002)(46966006)(36840700001)(316002)(426003)(6666004)(7636003)(36906005)(54906003)(82740400003)(70586007)(86362001)(7696005)(47076005)(2876002)(2906002)(83380400001)(107886003)(356005)(70206006)(6916009)(2616005)(5660300002)(4326008)(336012)(26005)(36860700001)(36756003)(478600001)(8676002)(8936002)(82310400003)(186003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2021 15:59:39.1406 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 97673759-aaa2-4c17-63e3-08d904de7805 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: CO1NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4323 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Dmytro Linkin Add -i/--iec switch to print rate values using binary prefixes. Update devlink(8) and devlink-rate(8) pages. Change-Id: I8b1896ed087273d96f6cd74eae7b2a3adc5fb846 Signed-off-by: Dmytro Linkin Reviewed-by: Jiri Pirko --- devlink/devlink.c | 12 +++++++++--- man/man8/devlink-rate.8 | 24 +++++++++++++++++++----- man/man8/devlink.8 | 4 ++++ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index 202359e..0347ac8 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -71,6 +71,8 @@ static bool g_indent_newline; #define INDENT_STR_MAXLEN 32 static char g_indent_str[INDENT_STR_MAXLEN + 1] = ""; +static bool use_iec = false; + static void __attribute__((format(printf, 1, 2))) pr_err(const char *fmt, ...) { @@ -4537,7 +4539,7 @@ static void pr_out_port_fn_rate(struct dl *dl, struct nlattr **tb) mnl_attr_get_u64(tb[DEVLINK_ATTR_RATE_TX_SHARE]); if (rate) - print_rate(false, PRINT_ANY, "tx_share", + print_rate(use_iec, PRINT_ANY, "tx_share", " tx_share %s", rate); } if (tb[DEVLINK_ATTR_RATE_TX_MAX]) { @@ -4545,7 +4547,7 @@ static void pr_out_port_fn_rate(struct dl *dl, struct nlattr **tb) mnl_attr_get_u64(tb[DEVLINK_ATTR_RATE_TX_MAX]); if (rate) - print_rate(false, PRINT_ANY, "tx_max", + print_rate(use_iec, PRINT_ANY, "tx_max", " tx_max %s", rate); } if (tb[DEVLINK_ATTR_RATE_PARENT_NODE_NAME]) { @@ -9066,6 +9068,7 @@ int main(int argc, char **argv) { "verbose", no_argument, NULL, 'v' }, { "statistics", no_argument, NULL, 's' }, { "Netns", required_argument, NULL, 'N' }, + { "iec", no_argument, NULL, 'i' }, { NULL, 0, NULL, 0 } }; const char *batch_file = NULL; @@ -9081,7 +9084,7 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - while ((opt = getopt_long(argc, argv, "Vfb:njpvsN:", + while ((opt = getopt_long(argc, argv, "Vfb:njpvsN:i", long_options, NULL)) >= 0) { switch (opt) { @@ -9116,6 +9119,9 @@ int main(int argc, char **argv) goto dl_free; } break; + case 'i': + use_iec = true; + break; default: pr_err("Unknown option.\n"); help(); diff --git a/man/man8/devlink-rate.8 b/man/man8/devlink-rate.8 index a6e28ac..76c65a3 100644 --- a/man/man8/devlink-rate.8 +++ b/man/man8/devlink-rate.8 @@ -15,7 +15,7 @@ devlink-rate \- devlink rate management .ti -8 .IR OPTIONS " := { " -.BR -j [ \fIson "] | " -p [ \fIretty "] }" +.BR -j [ \fIson "] | " -p [ \fIretty "] | " -i [ \fIec "] }" .ti -8 .B devlink port function rate show @@ -61,9 +61,10 @@ except decimal number, to avoid collisions with leafs. .PP Command output show rate object identifier, it's type and rate values along with parent node name. Rate values printed in SI units which are more suitable to -represent specific value. JSON (\fB-j\fR) output always print rate values in -bytes per second. Zero rate values means "unlimited" rates and ommited in -output, as well as parent node name. +represent specific value. To print values in IEC units \fB-i\fR switch is +used. JSON (\fB-j\fR) output always print rate values in bytes per second. Zero +rate values means "unlimited" rates and ommited in output, as well as parent +node name. .SS devlink port function rate set - set rate object parameters. Allows set rate object's parameters. If any parameter specified multiple times @@ -85,7 +86,7 @@ rate group. .TP 8 .I VALUE These parameter accept a floating point number, possibly followed by either a -unit. +unit (both SI and IEC units supported). .RS .TP bit or a bare number @@ -117,6 +118,9 @@ Gigabytes per second .TP tbps Terabytes per second +.P +To specify in IEC units, replace the SI prefix (k-, m-, g-, t-) with IEC prefix +(ki-, mi-, gi- and ti-) respectively. Input is case-insensitive. .RE .PP .BI parent " NODE_NAME \fR| " noparent @@ -169,6 +173,16 @@ pci/0000:03:00.0/1 type leaf .RE .PP +\fB*\fR Display leaf rate object rate values using IEC units: +.RS 4 +.PP +# devlink -i port function rate show pci/0000:03:00.0/2 +.br +pci/0000:03:00.0/2 type leaf 11718Kibit +.br +.RE + +.PP \fB*\fR Display node rate object with name some_group of the pci/0000:03:00.0 device: .RS 4 .PP diff --git a/man/man8/devlink.8 b/man/man8/devlink.8 index 866fda5..840cf44 100644 --- a/man/man8/devlink.8 +++ b/man/man8/devlink.8 @@ -59,6 +59,10 @@ Output statistics. .BR "\-N", " \-Netns " Switches to the specified network namespace. +.TP +.BR "\-i", " --iec" +Print human readable rates in IEC units (e.g. 1Ki = 1024). + .SS .I OBJECT