From patchwork Mon Feb 1 21:35:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parav Pandit X-Patchwork-Id: 12060105 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=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 5F58EC433DB for ; Mon, 1 Feb 2021 21:37:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21C6A64EBF for ; Mon, 1 Feb 2021 21:37:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230273AbhBAVgw (ORCPT ); Mon, 1 Feb 2021 16:36:52 -0500 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:4873 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229567AbhBAVgu (ORCPT ); Mon, 1 Feb 2021 16:36:50 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Mon, 01 Feb 2021 13:36:10 -0800 Received: from sw-mtx-036.mtx.labs.mlnx (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 1 Feb 2021 21:36:09 +0000 From: Parav Pandit To: , , CC: Parav Pandit Subject: [PATCH iproute2-next v2 0/6] Support devlink port add delete Date: Mon, 1 Feb 2021 23:35:45 +0200 Message-ID: <20210201213551.8503-1-parav@nvidia.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210129165608.134965-1-parav@nvidia.com> References: <20210129165608.134965-1-parav@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1612215370; bh=P9zszs5TZirFxZ9JKx6knJ2dGHzYiEETHJB41nwZdnA=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:Content-Type: X-Originating-IP:X-ClientProxiedBy; b=K8jS5vKgAagnDWqMayTqER1ntDx8u4dCNVcliAOyV4o2+XdW/lWBOqXkVdpFccK6G mAlE0aw9pXScTnKhCWk6pmHs7rY/9+TF/PXRO5gIRztg7xKITauKW1856cC3R6yTWO jHqDzzfxWYgJ6xJ7VntDSq6QGEKEEHp+B+mmodtMZIbVu9+WL3P3TT7d/RU4nt97Kt IciELyvCVwxB9Qnqst6t6+rtCnc3gYDGnilo5EpKAI3bA5zbaVsOM7XhjrqBJ+O+FE 7ymuLhEv8Zrc0erdihhJUj+L0gEPSW/+oh8dOEhRo3dt2aCXiwRE4yjKGjaaa3vgBs 4ktfu0xS1tU1g== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com This patchset implements devlink port add, delete and function state management commands. An example sequence for a PCI SF: Set the device in switchdev mode: $ devlink dev eswitch set pci/0000:06:00.0 mode switchdev View ports in switchdev mode: $ devlink port show pci/0000:06:00.0/65535: type eth netdev ens2f0np0 flavour physical port 0 splittable false Add a subfunction port for PCI PF 0 with sfnumber 88: $ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88 pci/0000:08:00.0/32768: type eth netdev eth6 flavour pcisf controller 0 pfnum 0 sfnum 88 splittable false function: hw_addr 00:00:00:00:00:00 state inactive opstate detached Show a newly added port: $ devlink port show pci/0000:06:00.0/32768 pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 splittable false function: hw_addr 00:00:00:00:00:00 state inactive opstate detached Set the function state to active: $ devlink port function set pci/0000:06:00.0/32768 hw_addr 00:00:00:00:88:88 state active Show the port in JSON format: $ devlink port show pci/0000:06:00.0/32768 -jp { "port": { "pci/0000:06:00.0/32768": { "type": "eth", "netdev": "ens2f0npf0sf88", "flavour": "pcisf", "controller": 0, "pfnum": 0, "sfnum": 88, "splittable": false, "function": { "hw_addr": "00:00:00:00:88:88", "state": "active", "opstate": "attached" } } } } Set the function state to active: $ devlink port function set pci/0000:06:00.0/32768 state inactive Delete the port after use: $ devlink port del pci/0000:06:00.0/32768 Patch summary: Patch-1 updates kernel headers Patch-2 introduces string to number map helper and uses it for port flavour Patch-3 shows PCI SF port attributes Patch-4 adds devlink commands to add and delete a port along with man page Patch-5 shows function state and operational state to user Patch-6 enables user to set function state and adds man page documentation Parav Pandit (6): devlink: Update kernel headers devlink: Introduce and use string to number mapper devlink: Introduce PCI SF port flavour and attribute devlink: Supporting add and delete of devlink port devlink: Support get port function state devlink: Support set of port function state devlink/devlink.c | 260 ++++++++++++++++++++++++++++++----- include/uapi/linux/devlink.h | 25 ++++ include/utils.h | 9 ++ lib/utils.c | 41 ++++++ man/man8/devlink-port.8 | 127 +++++++++++++++++ 5 files changed, 429 insertions(+), 33 deletions(-)