From patchwork Sat Feb 6 12:55:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parav Pandit X-Patchwork-Id: 377928 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, 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 C49CFC433E0 for ; Sat, 6 Feb 2021 12:57:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8456A64E51 for ; Sat, 6 Feb 2021 12:57:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229777AbhBFM4t (ORCPT ); Sat, 6 Feb 2021 07:56:49 -0500 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:16280 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhBFM4r (ORCPT ); Sat, 6 Feb 2021 07:56:47 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Sat, 06 Feb 2021 04:56:05 -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; Sat, 6 Feb 2021 12:56:04 +0000 From: Parav Pandit To: , , CC: Parav Pandit Subject: [PATCH net-next 0/7] netdevsim port add, delete support Date: Sat, 6 Feb 2021 14:55:44 +0200 Message-ID: <20210206125551.8616-1-parav@nvidia.com> X-Mailer: git-send-email 2.26.2 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=1612616165; bh=I3Yf9LWlaB7vvJandXXNlBmJSrW5OtmZ5Nihm9hFXKg=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy; b=PIKR6YtqGQNpZ+MJsfnmRW4kiCZ/MQtJwI2cZBs9ODGaDUv3TwFU2CE16kkLvuiYa cq6N8UBdpJd6vrcCjMcbe62xC8WYv675ATkEtLhf+zU8YidnBitxQlSN0tsT6+eYR9 RsP3gXfGARHt7FBHqrdGkwXOlp1HjmOed9fu0AccIyXD3jYPit4V0mOlitqmuYlxRX RSF2vPxzLF+59ex8Vf2EmrgKfqNVDONb85/zdM8qiwm73cd+NIqJ+bjR0+RePL4ZiI J0nXqQRlCINWdAz65/RlNLMA5k67PDvYAg5D73oOX8Qmq6eFEFH8NWutgQ8TbZ92s1 sV0CzY6yvZ8Ug== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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