From patchwork Mon Feb 1 21:35:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parav Pandit X-Patchwork-Id: 12060113 X-Patchwork-Delegate: dsahern@gmail.com 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=-19.1 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 B9B45C43381 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 8776A64ED2 for ; Mon, 1 Feb 2021 21:37:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232377AbhBAVhE (ORCPT ); Mon, 1 Feb 2021 16:37:04 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:16086 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231945AbhBAVgx (ORCPT ); Mon, 1 Feb 2021 16:36:53 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Mon, 01 Feb 2021 13:36:12 -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:11 +0000 From: Parav Pandit To: , , CC: Parav Pandit , Jiri Pirko Subject: [PATCH iproute2-next v2 3/6] devlink: Introduce PCI SF port flavour and attribute Date: Mon, 1 Feb 2021 23:35:48 +0200 Message-ID: <20210201213551.8503-4-parav@nvidia.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210201213551.8503-1-parav@nvidia.com> References: <20210129165608.134965-1-parav@nvidia.com> <20210201213551.8503-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=1612215372; bh=r4zp+qYy7Dwqsu2g0+0IFjqX9rx8uIYw8s4zTu4kLXo=; 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=Dz/cxcK4dHhkDrsVMTR87PDU3hTmyQwsmk0TCdBJKFXe8vxrCQZC+VYBARXxcYiUZ yh8HZJ8g/1o8RswBrH9HjpsfKFqXGoOLzPqGBBkQM1Ldgi6D7oEJ3+0gYj6pw3sJn/ 5BsKnHY/ZFFi8/ZLtmE5167bPt5h+S2ohvX3JHHVJ60JTq23dWuT3PqmkVHMsV0h15 5oALjwhNqclr1nExrb5VvaBFCl0M54rxQPPVSKSQc8Wy9CYMFB115avVCef9vwFBCA uH+169ry2hJ/BqAeeSTA2kh82sYPq3uEVr8AoCdgn8y8iQYql1AbSVxozu71R+zNjy ViGu/INMuOohQ== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Introduce PCI SF port flavour and port attributes such as PF number and SF number. $ devlink dev eswitch set pci/0000:06:00.0 mode switchdev $ devlink port show pci/0000:06:00.0/65535: type eth netdev ens2f0np0 flavour physical port 0 splittable false $ 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 $ 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 $ devlink port function set pci/0000:06:00.0/32768 hw_addr 00:00:00:00:88:88 state active $ 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" } } } } Signed-off-by: Parav Pandit Reviewed-by: Jiri Pirko --- devlink/devlink.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index d21a7c4d..338cb035 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -1389,6 +1389,7 @@ static struct str_num_map port_flavour_map[] = { { .str = "dsa", .num = DEVLINK_PORT_FLAVOUR_DSA }, { .str = "pcipf", .num = DEVLINK_PORT_FLAVOUR_PCI_PF }, { .str = "pcivf", .num = DEVLINK_PORT_FLAVOUR_PCI_VF }, + { .str = "pcisf", .num = DEVLINK_PORT_FLAVOUR_PCI_SF }, { .str = "virtual", .num = DEVLINK_PORT_FLAVOUR_VIRTUAL}, { .str = NULL, }, }; @@ -3733,7 +3734,7 @@ static const char *port_flavour_name(uint16_t flavour) return str ? str : ""; } -static void pr_out_port_pfvf_num(struct dl *dl, struct nlattr **tb) +static void pr_out_port_pfvfsf_num(struct dl *dl, struct nlattr **tb) { uint16_t fn_num; @@ -3748,6 +3749,10 @@ static void pr_out_port_pfvf_num(struct dl *dl, struct nlattr **tb) fn_num = mnl_attr_get_u16(tb[DEVLINK_ATTR_PORT_PCI_VF_NUMBER]); print_uint(PRINT_ANY, "vfnum", " vfnum %u", fn_num); } + if (tb[DEVLINK_ATTR_PORT_PCI_SF_NUMBER]) { + fn_num = mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_PCI_SF_NUMBER]); + print_uint(PRINT_ANY, "sfnum", " sfnum %u", fn_num); + } if (tb[DEVLINK_ATTR_PORT_EXTERNAL]) { uint8_t external; @@ -3825,7 +3830,8 @@ static void pr_out_port(struct dl *dl, struct nlattr **tb) switch (port_flavour) { case DEVLINK_PORT_FLAVOUR_PCI_PF: case DEVLINK_PORT_FLAVOUR_PCI_VF: - pr_out_port_pfvf_num(dl, tb); + case DEVLINK_PORT_FLAVOUR_PCI_SF: + pr_out_port_pfvfsf_num(dl, tb); break; default: break;