From patchwork Sun Feb 7 08:44:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parav Pandit X-Patchwork-Id: 12072691 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.3 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 C1660C433DB for ; Sun, 7 Feb 2021 08:45:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 865A864E72 for ; Sun, 7 Feb 2021 08:45:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229570AbhBGIpH (ORCPT ); Sun, 7 Feb 2021 03:45:07 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:2836 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhBGIpG (ORCPT ); Sun, 7 Feb 2021 03:45:06 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Sun, 07 Feb 2021 00:44:26 -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; Sun, 7 Feb 2021 08:44:25 +0000 From: Parav Pandit To: , , CC: Parav Pandit Subject: [PATCH net-next v2 0/7] netdevsim port add, delete support Date: Sun, 7 Feb 2021 10:44:05 +0200 Message-ID: <20210207084412.252259-1-parav@nvidia.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210206125551.8616-1-parav@nvidia.com> References: <20210206125551.8616-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=1612687466; bh=I3Yf9LWlaB7vvJandXXNlBmJSrW5OtmZ5Nihm9hFXKg=; 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=jhgJeLuyAZDxDXLjdMnEQCQdZPksMyzvlOTgxa/7VnFPmIC2mKBhUt3+PEkjZqhGH mH0eUlEwkgiokfoeqf9KEb0yWZCUlmZFHlGvGtC21bhOiXAhXgdK3OhzOLABrFqskN zhpXXxpFYaSyILARZPMVrUTW9sYUEHRzCA8zre6ndwnVwR8q7zj2ASPSEjrFyTZbPk rBRt3urjY7aDRbiOOACDIdPeRPti7NtHF+daNPGi6Of6/Q+nvplpRS2/jC4jHu9aTR qHotS2BpeBLpJ2lpViMvM+pXNCN1yY2+HgAqvHNubf30g7IEDw2amfm6ayCi/Yrxrp CkYenlLNR7Rgg== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This series simulates one or more PCI PF and SF port addition and function configuration functionality. Example sequence: Create a device with ID=10 and one physical port. $ echo "10 1" > /sys/bus/netdevsim/new_device Add PCI PF port: $ devlink port add netdevsim/netdevsim10 flavour pcipf pfnum 2 netdevsim/netdevsim10/1: type eth netdev eth1 flavour pcipf controller 0 pfnum 2 external false splittable false function: hw_addr 00:00:00:00:00:00 $ devlink port add netdevsim/netdevsim10 flavour pcisf pfnum 2 netdevsim/netdevsim10/2: type eth netdev eth2 flavour pcisf controller 0 pfnum 2 sfnum 0 splittable false function: hw_addr 00:00:00:00:00:00 Show devlink port: $ devlink port show netdevsim/netdevsim10/2 netdevsim/netdevsim10/2: type eth netdev eth2 flavour pcisf controller 0 pfnum 2 sfnum 0 splittable false function: hw_addr 00:00:00:00:00:00 state inactive opstate detached Set the MAC address and activate the function: $ devlink port function set netdevsim/netdevsim10/2 hw_addr 00:11:22:33:44:55 state active Show the port and function attributes in JSON format: $ devlink port show netdevsim/netdevsim10/2 -jp { "port": { "netdevsim/netdevsim10/2": { "type": "eth", "netdev": "eth2", "flavour": "pcisf", "controller": 0, "pfnum": 2, "sfnum": 0, "splittable": false, "function": { "hw_addr": "00:11:22:33:44:55", "state": "active", "opstate": "attached" } } } } Delete PCI SF and PF ports: $ devlink port del netdevsim/netdevsim10/2 Patch summary: patch-1 adds support for adding/remove PCI PF port patch-2 adds support for adding/remove PCI SF port patch-3 simulates MAC address query patch-4 simulates setting MAC address patch-5 simulates state query patch-6 simulates setting state patch-7 adds tests Parav Pandit (7): netdevsim: Add support for add and delete of a PCI PF port netdevsim: Add support for add and delete PCI SF port netdevsim: Simulate get hardware address of a PCI port netdevsim: Simulate set hardware address of a PCI port netdevsim: Simulate port function state for a PCI port netdevsim: Simulate port function set state for a PCI port netdevsim: Add netdevsim port add test cases drivers/net/netdevsim/Makefile | 2 +- drivers/net/netdevsim/dev.c | 14 + drivers/net/netdevsim/netdevsim.h | 38 ++ drivers/net/netdevsim/port_function.c | 521 ++++++++++++++++++ .../drivers/net/netdevsim/devlink.sh | 72 ++- 5 files changed, 645 insertions(+), 2 deletions(-) create mode 100644 drivers/net/netdevsim/port_function.c