From patchwork Tue Jul 11 04:24:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13308104 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9EBE523A for ; Tue, 11 Jul 2023 04:25:06 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2062d.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9D3D1BB for ; Mon, 10 Jul 2023 21:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fvWh3E2q3xUOxTen0mTH/Ey1v7KbCbzFG23/3o4RPXTJXFVQxtix6rxobmijD7E30w5TZZm+rhqjJE3pVAJiqIO7fEBdj7bWvkpDAxlzm9y4/0VNfFW7HoAuCCFQHX2MIpT43XjVsdPmCTqNiyfPWekrno/dz7xfXfFmAj6fDnUmECKJhuDAhkLnUR+u4ZJoQtNaeRDOsj40RZ+sc0I24nz+Xy2mB6e2VrHGYWWzXxUWDImWZ5bI0WEvuhq2dNUz9BqDtmjDVbCla2imD06YlR/xrK2+EEKriBrntlkyrcfbTatsBguWQdriqr6VKQxPpoH9vGrcbi/Z/a4SGd0MKg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DpvMCpMkjeIu2CCN75zHIRXSdRlC8h7luEfMSf6jTpk=; b=EGbHY0uD4UYS6p6Cj5GPKdj2P9IGMrVtoJen9vl3F0JKQHbn8iG9ciERNYUFe60ipIzWmaJNDZXyRDygwBCJncuAjxGkIXUV4v0+SGWXmDzZwsVJj8FhAgALWEYZZCjh9zzZHuzYRpbzLbfyCDhAgrNKSck5mSO0eYRK55GbIVC8PLAgt/gy7/4GDf5rBJwrOWoh+8qJ0Nj8jw3saW9vvurb5N+DDIPFXhzQfKJ8zh7NWGOa0RK/V+TZAnazyduvLYxwXNoRGITzEhJjq1g3PuyFzCPpfWlNXu2VInf3JcADI+es/UVqD8iXU5p5Fqg53wC932LybMfFODhh/56HdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DpvMCpMkjeIu2CCN75zHIRXSdRlC8h7luEfMSf6jTpk=; b=v8lVW8Mm/1ZiMiqoirSp/AXqUwmL4s0jTQeopBd4fC1yJKrYF9IxrKF+ukLuU5TCe3Lu2aDxRSq0ixT7O0L+WMl+DhCBZiTFoR/riBcfY9E9U8IAez3Ux507WRWKT3Qi5LKmVVeQYy/+YTyx0HqhycIibJJ2Z0LxCKl4JIXe3Co= Received: from BN8PR15CA0059.namprd15.prod.outlook.com (2603:10b6:408:80::36) by DM8PR12MB5430.namprd12.prod.outlook.com (2603:10b6:8:28::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.26; Tue, 11 Jul 2023 04:25:01 +0000 Received: from BN8NAM11FT095.eop-nam11.prod.protection.outlook.com (2603:10b6:408:80:cafe::9) by BN8PR15CA0059.outlook.office365.com (2603:10b6:408:80::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31 via Frontend Transport; Tue, 11 Jul 2023 04:25:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT095.mail.protection.outlook.com (10.13.176.206) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.19 via Frontend Transport; Tue, 11 Jul 2023 04:25:01 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 10 Jul 2023 23:25:00 -0500 From: Shannon Nelson To: , , , , , CC: , Allen Hubbe Subject: [PATCH v2 virtio 1/5] pds_vdpa: reset to vdpa specified mac Date: Mon, 10 Jul 2023 21:24:33 -0700 Message-ID: <20230711042437.69381-2-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230711042437.69381-1-shannon.nelson@amd.com> References: <20230711042437.69381-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT095:EE_|DM8PR12MB5430:EE_ X-MS-Office365-Filtering-Correlation-Id: 2506b104-7eca-4b45-614e-08db81c6cb36 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kBTvrFuN8yetllyQZI3gvNbmZOnNz4wYpe97tvpozgx2QIUghXdLaEcnPA7lxx4JWeDHTSimAyGSeV0fX4oEp1yKAKzMVFrKdbzJ7R+kvIZey1fn+I5mBH9OGwwKQqrGxmvWauVS6kUtqEnIG7Abc6S9QxwNBf8LvL/2sg/+1d+5aI8c5w2LsZrAm2Zgq1IkjwS9E5F2rRbMYnBnbdfcrWV7fPqeupzriuT0YrFwZBl+copv2MhUSn3v/f+NIII2uMWOBOXSUXzSqtOvUdkVvwkvFrzuRFj6vWuZy0OloZOQCMzsiZ8hezHhIPUTgW1caRnXsi/Fo3ZFdtYPilaRw5hXrHxwoqGfVfE1M1qKIhnIdCqwiA8ntDhVrVOQLpnGn4//gZvgDDpzTX+j1aArFq0Gs2mWzNvKL1RI+UvhCG1QYfrcD934xwZPabYVLqSIf4W5GMV8u3+bMvdt5dIA/OHnn+7undRio8se4sSD+IFd4mLR70e7y056/YUZPnu2T9BYCTUctPcGiYwJbz8Ww6bsU03SBRy8YT1skaMNwhB5GhyLloQQolD3CH5/oFb3IIX7tCHsTmaRKVffOlQ/nE2CgXWkYKnqARQqqhoqGM6TvpxRK4wlH6eJGeVK8EMH+nJ3RaATCPUmcXeR78TdDTRcTthK8rKMLu+ioyEgsOluKvcxP3CfXoxSfOoRfTCigDIhvNUMAIeWJz3RmqJvJ5bA1HbH1ObWVQKqcCTupMDaI47gYD+wzObd+F6wnI1zVSNf5Y5DMG5BLb2lOX3/KQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(136003)(39860400002)(346002)(396003)(451199021)(46966006)(36840700001)(40470700004)(81166007)(356005)(82740400003)(26005)(1076003)(5660300002)(426003)(16526019)(2616005)(336012)(47076005)(36860700001)(83380400001)(2906002)(40460700003)(36756003)(8936002)(41300700001)(86362001)(186003)(44832011)(478600001)(8676002)(110136005)(316002)(82310400005)(6666004)(4326008)(70586007)(54906003)(70206006)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2023 04:25:01.5434 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2506b104-7eca-4b45-614e-08db81c6cb36 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT095.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5430 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net From: Allen Hubbe When the vdpa device is reset, also reinitialize it with the mac address that was assigned when the device was added. Fixes: 151cc834f3dd ("pds_vdpa: add support for vdpa and vdpamgmt interfaces") Signed-off-by: Allen Hubbe Signed-off-by: Shannon Nelson Acked-by: Jason Wang --- drivers/vdpa/pds/vdpa_dev.c | 16 ++++++++-------- drivers/vdpa/pds/vdpa_dev.h | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/vdpa/pds/vdpa_dev.c b/drivers/vdpa/pds/vdpa_dev.c index 5071a4d58f8d..e2e99bb0be2b 100644 --- a/drivers/vdpa/pds/vdpa_dev.c +++ b/drivers/vdpa/pds/vdpa_dev.c @@ -409,6 +409,8 @@ static void pds_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status) pdsv->vqs[i].avail_idx = 0; pdsv->vqs[i].used_idx = 0; } + + pds_vdpa_cmd_set_mac(pdsv, pdsv->mac); } if (status & ~old_status & VIRTIO_CONFIG_S_FEATURES_OK) { @@ -532,7 +534,6 @@ static int pds_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, struct device *dma_dev; struct pci_dev *pdev; struct device *dev; - u8 mac[ETH_ALEN]; int err; int i; @@ -617,19 +618,18 @@ static int pds_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, * or set a random mac if default is 00:..:00 */ if (add_config->mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MACADDR)) { - ether_addr_copy(mac, add_config->net.mac); - pds_vdpa_cmd_set_mac(pdsv, mac); + ether_addr_copy(pdsv->mac, add_config->net.mac); } else { struct virtio_net_config __iomem *vc; vc = pdsv->vdpa_aux->vd_mdev.device; - memcpy_fromio(mac, vc->mac, sizeof(mac)); - if (is_zero_ether_addr(mac)) { - eth_random_addr(mac); - dev_info(dev, "setting random mac %pM\n", mac); - pds_vdpa_cmd_set_mac(pdsv, mac); + memcpy_fromio(pdsv->mac, vc->mac, sizeof(pdsv->mac)); + if (is_zero_ether_addr(pdsv->mac)) { + eth_random_addr(pdsv->mac); + dev_info(dev, "setting random mac %pM\n", pdsv->mac); } } + pds_vdpa_cmd_set_mac(pdsv, pdsv->mac); for (i = 0; i < pdsv->num_vqs; i++) { pdsv->vqs[i].qid = i; diff --git a/drivers/vdpa/pds/vdpa_dev.h b/drivers/vdpa/pds/vdpa_dev.h index a1bc37de9537..cf02df287fc4 100644 --- a/drivers/vdpa/pds/vdpa_dev.h +++ b/drivers/vdpa/pds/vdpa_dev.h @@ -39,6 +39,7 @@ struct pds_vdpa_device { u64 req_features; /* features requested by vdpa */ u8 vdpa_index; /* rsvd for future subdevice use */ u8 num_vqs; /* num vqs in use */ + u8 mac[ETH_ALEN]; /* mac selected when the device was added */ struct vdpa_callback config_cb; struct notifier_block nb; }; From patchwork Tue Jul 11 04:24:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13308105 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52E6846BE for ; Tue, 11 Jul 2023 04:25:07 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2047.outbound.protection.outlook.com [40.107.244.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EB591BC for ; Mon, 10 Jul 2023 21:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ev5N62qwZvl/VKhrK4PvVns3VL9Obm1wY19MMYmJx+VoRgcYS99u4a7BaPpcItiUpiVi7FAxGCiX/qnooDLWpEBgInbSAlUsTBRzb5qM4UwKr5GqNZwei9blMWFktjgbueYsbDeo2WeM1Ph5bLlakJzHgP/IzDA5Q1sq53trSkaoTvFNZxzIyu+Af/++RZu0jh3CcYkh1uEhF4BwtjMVo5LjGAIRH+Wrfq4mdZhk1Fdqf/iBfHv2Eli8CLmDiXRsJJmLv7ZRPGgXXMD+JoMjxsEt87Ggbt9vLiI0r3QiZ8iIec2wALEG5WrvZyTpwWO32PlQRP20l9Q9Vd8YoLyCGQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0+3TQlmrXJU2KeTxVrzsXAsRY5pVZhPvVe2EI3Sm5Ko=; b=dIEkrVapWfWBD3zUHkXez00sqypv2gvkOzsAPuzDsD7rAWNCHIvrtTDxlllTuYHiHG6bNlKNj9ZTyjpZ7CnESz05KhYMtfmWRBoL69xrnoJpSxQYvN9besYeJWNfbgD4QYO3EtijelXwWYzvruzZtKjgQRhdvlSgAdAy9PTbEAKBMGtfENyxoWlV6eQt/k4fxBpHzmzHDC3eCE5FZVqdRx/1gdk+XIDnEa+Q5WMUPX9zP4QKBWvTw1BPhPUQkTjdKhQrdhjZlcHysSinUYLfTSULNH66eYpncVR/dSYG1rPLJz5/TJRt8qkoyN1DWv5zOmUWAOYcC9lsalILS+51Ww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0+3TQlmrXJU2KeTxVrzsXAsRY5pVZhPvVe2EI3Sm5Ko=; b=lNmvs/YiRiZLW9IDklQvLCkum0M1Z1W/2pUu9LMIPgEApJ2Us8WEidYFzm/jIuKaJ61G96srciW6C/Hd2uLeD0FC9utWCgIWP+OXMiK/cbTT3i3+qD+gyvYskifY65cF4IvcJHupXFYZXF3O9EpwPNd7UDIztcwW/WDKoQsr1nE= Received: from BN9PR03CA0926.namprd03.prod.outlook.com (2603:10b6:408:107::31) by PH7PR12MB8014.namprd12.prod.outlook.com (2603:10b6:510:27c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30; Tue, 11 Jul 2023 04:25:03 +0000 Received: from BN8NAM11FT067.eop-nam11.prod.protection.outlook.com (2603:10b6:408:107:cafe::35) by BN9PR03CA0926.outlook.office365.com (2603:10b6:408:107::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31 via Frontend Transport; Tue, 11 Jul 2023 04:25:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT067.mail.protection.outlook.com (10.13.177.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.18 via Frontend Transport; Tue, 11 Jul 2023 04:25:02 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 10 Jul 2023 23:25:01 -0500 From: Shannon Nelson To: , , , , , CC: Subject: [PATCH v2 virtio 2/5] pds_vdpa: always allow offering VIRTIO_NET_F_MAC Date: Mon, 10 Jul 2023 21:24:34 -0700 Message-ID: <20230711042437.69381-3-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230711042437.69381-1-shannon.nelson@amd.com> References: <20230711042437.69381-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT067:EE_|PH7PR12MB8014:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e081e2c-cf82-49e9-a620-08db81c6cbcc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 41NtDlbdqMkQlbYSBR5Bx+bD76MIdsqw/90qddXPAtMthPalzjx/Q7lYluvJ63euDf9tvZpLc7bpaWjzLx7A5ZAJn8y/OAI2dJVavagOTOCaB4eAI4lruV2OSRZiqds854I4KBYrvhG89jFO/VYcHzqvWpT9H18Deg2rjC12ZD9ZtGxvk5Xxrxe7UzUm3xh5bZhDGieLUirDVkYHVSF5x2moYXXJNWT+uG/jjkEALDVSHz8KQLmGztlqDXL/66aPAJW9b/ElGSxU4Hhui0kOW39pKsqxIqR+/id6vd3Hw0+b3fvCLr7Iau1TRPWMYb75eaAIgeBgyTobjxOp5yJkrS/JnbjwSSngcdVFJHiTAm2r1zTqCLRcwROAjB9GU0YQ0e85ic0Yniagz7r27LzLZXTcJQcKBK6QFBapXDP8EUAEvmOHhRoQWbCKUNOXQUa+z03D9wnbPHRYBeGAk0Wq3Sih+gEisq1lmNvO4Hl1w7yIeuAy0tyPKB0P2mfZc7IQp4x4KLQK/O279CpR0kkIqXzXQL8Kie/SOrvfmCzcAb28mkhFHB3kyTJzTwhrYA1GSPW90myaYPlfJwsPKedZWZ8ZdCPW2Tga0q4OvjfgXP2ON6TdX80uI8ZCA2c9zaWq2foTWNgOyWRSMfhryCTTqVyRIPU9Sw+dQLLtwW3x1LqImkgM9QOkuLl7IyRrsmpjEBu0DOmnthwcc7fJ0VaCahI+i2b/1AmkZCDf+nOO26a6PpcHhdyNFvbs4gW/AJke3a4Q+RAtXgZ3HE/3HJYdaQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(396003)(136003)(39860400002)(451199021)(36840700001)(40470700004)(46966006)(6666004)(478600001)(110136005)(26005)(1076003)(336012)(16526019)(70586007)(186003)(70206006)(2906002)(82310400005)(41300700001)(4326008)(5660300002)(316002)(44832011)(8936002)(81166007)(8676002)(82740400003)(356005)(40460700003)(86362001)(36756003)(47076005)(36860700001)(83380400001)(426003)(40480700001)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2023 04:25:02.5439 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e081e2c-cf82-49e9-a620-08db81c6cbcc X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT067.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8014 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Our driver sets a mac if the HW is 00:..:00 so we need to be sure to advertise VIRTIO_NET_F_MAC even if the HW doesn't. We also need to be sure that virtio_net sees the VIRTIO_NET_F_MAC and doesn't rewrite the mac address that a user may have set with the vdpa utility. After reading the hw_feature bits, add the VIRTIO_NET_F_MAC to the driver's supported_features and use that for reporting what is available. If the HW is not advertising it, be sure to strip the VIRTIO_NET_F_MAC before finishing the feature negotiation. If the user specifies a device_features bitpattern in the vdpa utility without the VIRTIO_NET_F_MAC set, then don't set the mac. Fixes: 151cc834f3dd ("pds_vdpa: add support for vdpa and vdpamgmt interfaces") Signed-off-by: Shannon Nelson Acked-by: Jason Wang --- drivers/vdpa/pds/debugfs.c | 2 -- drivers/vdpa/pds/vdpa_dev.c | 30 +++++++++++++++++++++--------- drivers/vdpa/pds/vdpa_dev.h | 4 ++-- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/vdpa/pds/debugfs.c b/drivers/vdpa/pds/debugfs.c index 21a0dc0cb607..754ccb7a6666 100644 --- a/drivers/vdpa/pds/debugfs.c +++ b/drivers/vdpa/pds/debugfs.c @@ -224,8 +224,6 @@ static int config_show(struct seq_file *seq, void *v) seq_printf(seq, "dev_status: %#x\n", status); print_status_bits(seq, status); - seq_printf(seq, "req_features: %#llx\n", pdsv->req_features); - print_feature_bits_all(seq, pdsv->req_features); driver_features = vp_modern_get_driver_features(&pdsv->vdpa_aux->vd_mdev); seq_printf(seq, "driver_features: %#llx\n", driver_features); print_feature_bits_all(seq, driver_features); diff --git a/drivers/vdpa/pds/vdpa_dev.c b/drivers/vdpa/pds/vdpa_dev.c index e2e99bb0be2b..5b566e0eef0a 100644 --- a/drivers/vdpa/pds/vdpa_dev.c +++ b/drivers/vdpa/pds/vdpa_dev.c @@ -318,6 +318,7 @@ static int pds_vdpa_set_driver_features(struct vdpa_device *vdpa_dev, u64 featur struct device *dev = &pdsv->vdpa_dev.dev; u64 driver_features; u64 nego_features; + u64 hw_features; u64 missing; if (!(features & BIT_ULL(VIRTIO_F_ACCESS_PLATFORM)) && features) { @@ -325,21 +326,26 @@ static int pds_vdpa_set_driver_features(struct vdpa_device *vdpa_dev, u64 featur return -EOPNOTSUPP; } - pdsv->req_features = features; - /* Check for valid feature bits */ - nego_features = features & le64_to_cpu(pdsv->vdpa_aux->ident.hw_features); - missing = pdsv->req_features & ~nego_features; + nego_features = features & pdsv->supported_features; + missing = features & ~nego_features; if (missing) { dev_err(dev, "Can't support all requested features in %#llx, missing %#llx features\n", - pdsv->req_features, missing); + features, missing); return -EOPNOTSUPP; } + pdsv->negotiated_features = nego_features; + driver_features = pds_vdpa_get_driver_features(vdpa_dev); dev_dbg(dev, "%s: %#llx => %#llx\n", __func__, driver_features, nego_features); + /* if we're faking the F_MAC, strip it before writing to device */ + hw_features = le64_to_cpu(pdsv->vdpa_aux->ident.hw_features); + if (!(hw_features & BIT_ULL(VIRTIO_NET_F_MAC))) + nego_features &= ~BIT_ULL(VIRTIO_NET_F_MAC); + if (driver_features == nego_features) return 0; @@ -352,7 +358,7 @@ static u64 pds_vdpa_get_driver_features(struct vdpa_device *vdpa_dev) { struct pds_vdpa_device *pdsv = vdpa_to_pdsv(vdpa_dev); - return vp_modern_get_driver_features(&pdsv->vdpa_aux->vd_mdev); + return pdsv->negotiated_features; } static void pds_vdpa_set_config_cb(struct vdpa_device *vdpa_dev, @@ -564,7 +570,7 @@ static int pds_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, if (add_config->mask & BIT_ULL(VDPA_ATTR_DEV_FEATURES)) { u64 unsupp_features = - add_config->device_features & ~mgmt->supported_features; + add_config->device_features & ~pdsv->supported_features; if (unsupp_features) { dev_err(dev, "Unsupported features: %#llx\n", unsupp_features); @@ -615,7 +621,8 @@ static int pds_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, } /* Set a mac, either from the user config if provided - * or set a random mac if default is 00:..:00 + * or use the device's mac if not 00:..:00 + * or set a random mac */ if (add_config->mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MACADDR)) { ether_addr_copy(pdsv->mac, add_config->net.mac); @@ -624,7 +631,8 @@ static int pds_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, vc = pdsv->vdpa_aux->vd_mdev.device; memcpy_fromio(pdsv->mac, vc->mac, sizeof(pdsv->mac)); - if (is_zero_ether_addr(pdsv->mac)) { + if (is_zero_ether_addr(pdsv->mac) && + (pdsv->supported_features & BIT_ULL(VIRTIO_NET_F_MAC))) { eth_random_addr(pdsv->mac); dev_info(dev, "setting random mac %pM\n", pdsv->mac); } @@ -752,6 +760,10 @@ int pds_vdpa_get_mgmt_info(struct pds_vdpa_aux *vdpa_aux) mgmt->id_table = pds_vdpa_id_table; mgmt->device = dev; mgmt->supported_features = le64_to_cpu(vdpa_aux->ident.hw_features); + + /* advertise F_MAC even if the device doesn't */ + mgmt->supported_features |= BIT_ULL(VIRTIO_NET_F_MAC); + mgmt->config_attr_mask = BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MACADDR); mgmt->config_attr_mask |= BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP); mgmt->config_attr_mask |= BIT_ULL(VDPA_ATTR_DEV_FEATURES); diff --git a/drivers/vdpa/pds/vdpa_dev.h b/drivers/vdpa/pds/vdpa_dev.h index cf02df287fc4..d984ba24a7da 100644 --- a/drivers/vdpa/pds/vdpa_dev.h +++ b/drivers/vdpa/pds/vdpa_dev.h @@ -35,8 +35,8 @@ struct pds_vdpa_device { struct pds_vdpa_aux *vdpa_aux; struct pds_vdpa_vq_info vqs[PDS_VDPA_MAX_QUEUES]; - u64 supported_features; /* specified device features */ - u64 req_features; /* features requested by vdpa */ + u64 supported_features; /* supported device features */ + u64 negotiated_features; /* negotiated features */ u8 vdpa_index; /* rsvd for future subdevice use */ u8 num_vqs; /* num vqs in use */ u8 mac[ETH_ALEN]; /* mac selected when the device was added */ From patchwork Tue Jul 11 04:24:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13308106 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52EAF523A for ; Tue, 11 Jul 2023 04:25:07 +0000 (UTC) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28E251A8 for ; Mon, 10 Jul 2023 21:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZrAAOiU9/OXKbSTHKpVv1tsn+sC/2ktSmFKDbFJYk2QAQSm9daRjgMK2IO4AI339mHjtmBP/sSCAW69aBtANz2fUuxd0os3XFNWMwVCJKXJ8YI+iIT2mGxM1kVjtiyDsrWpHnPPqFpqOJqXs3LBBT3bqiOi4KQiWaVVkTN2THqd+NOxzlCPSOMqQuD5Ry4gU1+JR/yDf0+wA39W1ypkFwmKACF5CsNsLIxCZj+Ms9PxBFCn2zAF6bR6PWbUbnHVEeVrtPXiyzPvbym4cWH+IL4Rec8i1iDRQQIHYrwP7uJq/VUlJtvr/wY1bWyISvclthGnZ8h42kaLYqJAgvMrYeA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QJi0nGEWwdtEfopKnzujq1SPuSE6XqRyKpb3WeiZAr4=; b=M7pcFcrhvaNxqzrhrn0peCysjqbjm1gbt1yJTP9JwHdjwkY35uD7anajrztkJJlI4RKdFlmORFhP3tOS5zUf5FZe/Os1GsTzV0HnS1ug0ehy1g40hs3rD6GerlOIVxBxoL4zBRYoL3bNHMe7GcSWPyxRB2v2ueUsf/fxYhn8z9HO5mAjSPMDWQgJCv5NfQOFiahY/LKcrch+5gF7ZsCyg055VjhOzQBeSN5Spl+LI7oKejHUrvT85++zt/R3ykmfb1idunUkvrsZHkH0YXqNEgRw+hCLH7QiKFYjURuRTETQE3L7R385576gORJp0d6cDo2FrfwtSpkoC8aLddTasg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QJi0nGEWwdtEfopKnzujq1SPuSE6XqRyKpb3WeiZAr4=; b=XELNd/gpJYJXu5f87tTxutyyMDV7Y7Wg6ZPxi7jtOo3Uk3WX4iHNR38YLfCt6yCH0WRBFJrUis6MiAh7CWrBiuTFxmkzeCqbeiG4tfS0a+SERpMFs8BETjUOe4VUvk6BJg9d+lTEJM0jwVQATRzhSbby+g8iawzoEaUBGc/lnrk= Received: from BN9PR03CA0885.namprd03.prod.outlook.com (2603:10b6:408:13c::20) by SN7PR12MB6929.namprd12.prod.outlook.com (2603:10b6:806:263::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31; Tue, 11 Jul 2023 04:25:03 +0000 Received: from BN8NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13c:cafe::22) by BN9PR03CA0885.outlook.office365.com (2603:10b6:408:13c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31 via Frontend Transport; Tue, 11 Jul 2023 04:25:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT025.mail.protection.outlook.com (10.13.177.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.19 via Frontend Transport; Tue, 11 Jul 2023 04:25:03 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 10 Jul 2023 23:25:02 -0500 From: Shannon Nelson To: , , , , , CC: Subject: [PATCH v2 virtio 3/5] pds_vdpa: clean and reset vqs entries Date: Mon, 10 Jul 2023 21:24:35 -0700 Message-ID: <20230711042437.69381-4-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230711042437.69381-1-shannon.nelson@amd.com> References: <20230711042437.69381-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT025:EE_|SN7PR12MB6929:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f899cea-7edb-49b0-be6b-08db81c6cc58 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9W2zJzRYw5bNe5CSzhipFWjp+cXOz8gNniwgNcf6em6lRB0yzelDJuWa5yLJx4FN6tlYaYcRdVtbpEBdSEI1iPXAntbtOou1QifeGHGYFigwWq2qgFnjvSo9CTi2PHr7lz8GQ1C6WsqtvjL+6ZPe6fnxX6D9o1/v+4Z505xQelCzlzPqQOLPv7IRAD1Y2vzjLDlWgRC6ZSsP/q1hATPe/Xu9KD/JmB8lnjsRn3AWOOtwNVn0XiyXfGF3Z9bIveVaTx9OcnHFRLyZubozQ4/9RO3G8gQ1w+EDy6t/Fdyod5B5xacE+/FS04Mjbb6MUUZ3yzk/y9N24gVcGxEp5mbTvoA6vY0Tco8ABpV0TfU8aDWTvPHRCSMvhHT7LrYLEcGCpeWEUW3awsxqULjfRrXiKRzpM+tIbmdN9bgP+HK3yro1q5GnjHU4VxS5RcnBLcMMLjlkHQ0wZH0ToYD+upVmE6hI/axiSjmXZpsHZm2Re7LWQbzAWy27JnOrD+CCZu1MyCKqNzwXhY4V6NdquGv8GgDKHoHjnKYH1kadYcXjcIUIfRfAXzBA3wgUf2zj/qY1g1fj0YLsRmKuh78vw70zuDCSAxzJ1oK035vrD2RZkMRpjkxK3xkBwpqDchIcebu2fwVP4+WvDTKZEPDCC1pB9xknbfHWut8KVO2XRSjmBqR+OajckuKUlGBuZQxYSPXqHYOsRSmnDoJrB499NNbA/ML0QzQQat+lKTB+XXAsG3XG4cehwqT1k+YlJlo8PpQkFVd0nPasXZCmeE5gA2Q7PQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(396003)(376002)(39860400002)(346002)(451199021)(36840700001)(46966006)(40470700004)(36860700001)(82310400005)(36756003)(86362001)(40480700001)(110136005)(40460700003)(81166007)(356005)(82740400003)(478600001)(6666004)(8676002)(316002)(44832011)(5660300002)(2906002)(4326008)(70586007)(70206006)(41300700001)(8936002)(2616005)(426003)(336012)(26005)(1076003)(47076005)(16526019)(186003)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2023 04:25:03.4464 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f899cea-7edb-49b0-be6b-08db81c6cc58 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6929 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Make sure that we initialize the vqs[] entries the same way both for initial setup and after a vq reset. Fixes: 151cc834f3dd ("pds_vdpa: add support for vdpa and vdpamgmt interfaces") Signed-off-by: Shannon Nelson Acked-by: Jason Wang --- drivers/vdpa/pds/vdpa_dev.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/vdpa/pds/vdpa_dev.c b/drivers/vdpa/pds/vdpa_dev.c index 5b566e0eef0a..04a362648b02 100644 --- a/drivers/vdpa/pds/vdpa_dev.c +++ b/drivers/vdpa/pds/vdpa_dev.c @@ -428,6 +428,17 @@ static void pds_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status) } } +static void pds_vdpa_init_vqs_entry(struct pds_vdpa_device *pdsv, int qid, + void __iomem *notify) +{ + memset(&pdsv->vqs[qid], 0, sizeof(pdsv->vqs[0])); + pdsv->vqs[qid].qid = qid; + pdsv->vqs[qid].pdsv = pdsv; + pdsv->vqs[qid].ready = false; + pdsv->vqs[qid].irq = VIRTIO_MSI_NO_VECTOR; + pdsv->vqs[qid].notify = notify; +} + static int pds_vdpa_reset(struct vdpa_device *vdpa_dev) { struct pds_vdpa_device *pdsv = vdpa_to_pdsv(vdpa_dev); @@ -450,8 +461,7 @@ static int pds_vdpa_reset(struct vdpa_device *vdpa_dev) dev_err(dev, "%s: reset_vq failed qid %d: %pe\n", __func__, i, ERR_PTR(err)); pds_vdpa_release_irq(pdsv, i); - memset(&pdsv->vqs[i], 0, sizeof(pdsv->vqs[0])); - pdsv->vqs[i].ready = false; + pds_vdpa_init_vqs_entry(pdsv, i, pdsv->vqs[i].notify); } } @@ -640,11 +650,11 @@ static int pds_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, pds_vdpa_cmd_set_mac(pdsv, pdsv->mac); for (i = 0; i < pdsv->num_vqs; i++) { - pdsv->vqs[i].qid = i; - pdsv->vqs[i].pdsv = pdsv; - pdsv->vqs[i].irq = VIRTIO_MSI_NO_VECTOR; - pdsv->vqs[i].notify = vp_modern_map_vq_notify(&pdsv->vdpa_aux->vd_mdev, - i, &pdsv->vqs[i].notify_pa); + void __iomem *notify; + + notify = vp_modern_map_vq_notify(&pdsv->vdpa_aux->vd_mdev, + i, &pdsv->vqs[i].notify_pa); + pds_vdpa_init_vqs_entry(pdsv, i, notify); } pdsv->vdpa_dev.mdev = &vdpa_aux->vdpa_mdev; From patchwork Tue Jul 11 04:24:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13308108 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA9FC168C3 for ; Tue, 11 Jul 2023 04:25:12 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20623.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::623]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19F1B1A8 for ; Mon, 10 Jul 2023 21:25:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TvHt5oyUx3GWKlZMOn95MaM9F6WuQd7ZMkjcwS2E8obca++dh8VMaVHd6Qtp3F7ZkDuyiBKy5/oj3Goswc0KlvB+cJquO9zVGDB/P5GZPltjEhU8u8nh/oRMMpD/ApJDy/J5Znv1imMkNQV2HR8C11Ebvm7QRaFx0v8RmnTY8KOo3Ym0zc1whEYQGKv8t6sREaFRMAVWNkfAvBOQI0hz5aQq9VUyL4C641uIyjOgED1YjF9OBxVwOaRduGY+mnLwDZNoo5dqg5Gwe8hClT1DzwV1gdigk7fwxEaFLqJ0lF72QezuBTn0wJQ4xgVkZTLGw5pa7kh8OwOTzt7z/p6iSQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6KfeQ0mClrYFoBmUsMjH58geAMUegCcUmIhAiM8H/bw=; b=Bm0PEcXO6EsisQDQXpW/38wFq/0chvOetsN7+ZUZeQunWqso2WY3leEmr10WwrxAus1cpHmljedSiQIMWPH195ovaIgQhdEjLHAunsyoZhe3wJ6o81MnnmWYL157bpBejSONOVfgNjoM0+KYgV8MTov6B8jJGGb/AOwNgDyeRVyfpZVUjRLrO5QIRFJe+tzJ32Qp+kLCIyELCGecOpEJtpEyye5lpXEIRNWxPOlT/zf0IadxJyatm3KWJrhpiwDyQg+04JyY8XlAIV6ia1RWH/qXSObq127UmmTvcFEiLV8/NJCVLWO97MdSSEMvC6nwWbgzlF0OZrS/QEsrj/1bbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6KfeQ0mClrYFoBmUsMjH58geAMUegCcUmIhAiM8H/bw=; b=jzp9V0IwqNgG9zprr3V9V84h2JHkPqtvSRI1rWVAU5RbjvSCZ0OFhWL1Sm67Q0PBzKqVTEp9YAdm0NTKTy7GMKL6CkTbLKbAGQedGrOuVkUPjrpawxp1wbtESQfYklwThzrYK7iXm84/P6Y4Vch4/pBD/+RFs/3lGtYgJ98tjrI= Received: from BN9PR03CA0755.namprd03.prod.outlook.com (2603:10b6:408:13a::10) by DM6PR12MB4281.namprd12.prod.outlook.com (2603:10b6:5:21e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30; Tue, 11 Jul 2023 04:25:04 +0000 Received: from BN8NAM11FT075.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13a:cafe::78) by BN9PR03CA0755.outlook.office365.com (2603:10b6:408:13a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31 via Frontend Transport; Tue, 11 Jul 2023 04:25:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT075.mail.protection.outlook.com (10.13.176.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.20 via Frontend Transport; Tue, 11 Jul 2023 04:25:04 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 10 Jul 2023 23:25:03 -0500 From: Shannon Nelson To: , , , , , CC: , Allen Hubbe Subject: [PATCH v2 virtio 4/5] pds_vdpa: alloc irq vectors on DRIVER_OK Date: Mon, 10 Jul 2023 21:24:36 -0700 Message-ID: <20230711042437.69381-5-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230711042437.69381-1-shannon.nelson@amd.com> References: <20230711042437.69381-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT075:EE_|DM6PR12MB4281:EE_ X-MS-Office365-Filtering-Correlation-Id: 4927cd47-b51a-4c65-2461-08db81c6ccf0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f34f9WTtHl34nX0astK/ME+b1csa2zLmZmGPhwKaO7XYMmgcs8r7n4ugsw7bnGAh1awISvdVe7GwsAxM5BgV0JYutbeGDkthnuODBT08HrmV6ceZZYFWElRsYo6mLoKnMhPN0rzMmwLenOyREShRFHteJJmC1IY0GU9guW83fN61Iekn2YmsPytFNGAQ3OQ7zLkfHEKz+kmZVLh9qvrrljKMKDZHaFyFT6XhPa7zQzK3dhVmrAT0Ulqi7ZrKtmc1q5prsVaSi/8JL4G9Evq+Ic/eqtGVQExBZ/Mr/qOccOh79+yVRedRgIcCc5yAA7+hM65RYqhDI62PsnO2EbxgKo5P1BfPVwAoInMAHJT001fuHsJhten/cfoWBjVbNHYITCN4r+txI1A2fgtyXF8FwAzs0tHUa7SwM+9f6irzlfcn3Y+FDRC8FNrsb1OsbpAwWkdHJQQ5UkhEBHTkEI/dk8wspcvd54lePN8yGMFMDzMznIieJIGJSjfCa8bOmE9erJlXbPJXOCCnV//KIUepBdiiFfRCWQEsLnhwBw9vlVdOQlNatflFV7uO+PwHMnbMUtqoTewDCYgfepd9CCmjqZdMWVq10pBarVbu3bmMeOXdbfiOuAubCkpXa+7CgDKcVQnbubMlTb2P8nF4yhWOyLoSNJLLm7fqfX8Mni0qRYzMszq7YlHAXMW9REzo3CN5GOtrcD7o3TIrawyuyy5JSBfYo+nrjQ9ZuVXowFImN9k+/QFSmef7HTej8IjGvkxXGCTUyfCRsH9kHwaElVxeZQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(396003)(136003)(39860400002)(451199021)(36840700001)(40470700004)(46966006)(54906003)(6666004)(478600001)(110136005)(26005)(1076003)(336012)(16526019)(70586007)(186003)(70206006)(2906002)(82310400005)(41300700001)(4326008)(5660300002)(316002)(44832011)(8936002)(81166007)(8676002)(82740400003)(356005)(40460700003)(86362001)(36756003)(47076005)(36860700001)(83380400001)(426003)(40480700001)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2023 04:25:04.4386 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4927cd47-b51a-4c65-2461-08db81c6ccf0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT075.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4281 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net From: Allen Hubbe We were allocating irq vectors at the time the aux dev was probed, but that is before the PCI VF is assigned to a separate iommu domain by vhost_vdpa. Because vhost_vdpa later changes the iommu domain the interrupts do not work. Instead, we can allocate the irq vectors later when we see DRIVER_OK and know that the reassignment of the PCI VF to an iommu domain has already happened. Fixes: 151cc834f3dd ("pds_vdpa: add support for vdpa and vdpamgmt interfaces") Signed-off-by: Allen Hubbe Signed-off-by: Shannon Nelson Acked-by: Jason Wang --- drivers/vdpa/pds/vdpa_dev.c | 110 ++++++++++++++++++++++++++---------- 1 file changed, 81 insertions(+), 29 deletions(-) diff --git a/drivers/vdpa/pds/vdpa_dev.c b/drivers/vdpa/pds/vdpa_dev.c index 04a362648b02..52b2449182ad 100644 --- a/drivers/vdpa/pds/vdpa_dev.c +++ b/drivers/vdpa/pds/vdpa_dev.c @@ -126,11 +126,9 @@ static void pds_vdpa_release_irq(struct pds_vdpa_device *pdsv, int qid) static void pds_vdpa_set_vq_ready(struct vdpa_device *vdpa_dev, u16 qid, bool ready) { struct pds_vdpa_device *pdsv = vdpa_to_pdsv(vdpa_dev); - struct pci_dev *pdev = pdsv->vdpa_aux->padev->vf_pdev; struct device *dev = &pdsv->vdpa_dev.dev; u64 driver_features; u16 invert_idx = 0; - int irq; int err; dev_dbg(dev, "%s: qid %d ready %d => %d\n", @@ -143,19 +141,6 @@ static void pds_vdpa_set_vq_ready(struct vdpa_device *vdpa_dev, u16 qid, bool re invert_idx = PDS_VDPA_PACKED_INVERT_IDX; if (ready) { - irq = pci_irq_vector(pdev, qid); - snprintf(pdsv->vqs[qid].irq_name, sizeof(pdsv->vqs[qid].irq_name), - "vdpa-%s-%d", dev_name(dev), qid); - - err = request_irq(irq, pds_vdpa_isr, 0, - pdsv->vqs[qid].irq_name, &pdsv->vqs[qid]); - if (err) { - dev_err(dev, "%s: no irq for qid %d: %pe\n", - __func__, qid, ERR_PTR(err)); - return; - } - pdsv->vqs[qid].irq = irq; - /* Pass vq setup info to DSC using adminq to gather up and * send all info at once so FW can do its full set up in * one easy operation @@ -164,7 +149,6 @@ static void pds_vdpa_set_vq_ready(struct vdpa_device *vdpa_dev, u16 qid, bool re if (err) { dev_err(dev, "Failed to init vq %d: %pe\n", qid, ERR_PTR(err)); - pds_vdpa_release_irq(pdsv, qid); ready = false; } } else { @@ -172,7 +156,6 @@ static void pds_vdpa_set_vq_ready(struct vdpa_device *vdpa_dev, u16 qid, bool re if (err) dev_err(dev, "%s: reset_vq failed qid %d: %pe\n", __func__, qid, ERR_PTR(err)); - pds_vdpa_release_irq(pdsv, qid); } pdsv->vqs[qid].ready = ready; @@ -395,6 +378,72 @@ static u8 pds_vdpa_get_status(struct vdpa_device *vdpa_dev) return vp_modern_get_status(&pdsv->vdpa_aux->vd_mdev); } +static int pds_vdpa_request_irqs(struct pds_vdpa_device *pdsv) +{ + struct pci_dev *pdev = pdsv->vdpa_aux->padev->vf_pdev; + struct pds_vdpa_aux *vdpa_aux = pdsv->vdpa_aux; + struct device *dev = &pdsv->vdpa_dev.dev; + int max_vq, nintrs, qid, err; + + max_vq = vdpa_aux->vdpa_mdev.max_supported_vqs; + + nintrs = pci_alloc_irq_vectors(pdev, max_vq, max_vq, PCI_IRQ_MSIX); + if (nintrs < 0) { + dev_err(dev, "Couldn't get %d msix vectors: %pe\n", + max_vq, ERR_PTR(nintrs)); + return nintrs; + } + + for (qid = 0; qid < pdsv->num_vqs; ++qid) { + int irq = pci_irq_vector(pdev, qid); + + snprintf(pdsv->vqs[qid].irq_name, sizeof(pdsv->vqs[qid].irq_name), + "vdpa-%s-%d", dev_name(dev), qid); + + err = request_irq(irq, pds_vdpa_isr, 0, + pdsv->vqs[qid].irq_name, + &pdsv->vqs[qid]); + if (err) { + dev_err(dev, "%s: no irq for qid %d: %pe\n", + __func__, qid, ERR_PTR(err)); + goto err_release; + } + + pdsv->vqs[qid].irq = irq; + } + + vdpa_aux->nintrs = nintrs; + + return 0; + +err_release: + while (qid--) + pds_vdpa_release_irq(pdsv, qid); + + pci_free_irq_vectors(pdev); + + vdpa_aux->nintrs = 0; + + return err; +} + +static void pds_vdpa_release_irqs(struct pds_vdpa_device *pdsv) +{ + struct pci_dev *pdev = pdsv->vdpa_aux->padev->vf_pdev; + struct pds_vdpa_aux *vdpa_aux = pdsv->vdpa_aux; + int qid; + + if (!vdpa_aux->nintrs) + return; + + for (qid = 0; qid < pdsv->num_vqs; qid++) + pds_vdpa_release_irq(pdsv, qid); + + pci_free_irq_vectors(pdev); + + vdpa_aux->nintrs = 0; +} + static void pds_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status) { struct pds_vdpa_device *pdsv = vdpa_to_pdsv(vdpa_dev); @@ -405,6 +454,11 @@ static void pds_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status) old_status = pds_vdpa_get_status(vdpa_dev); dev_dbg(dev, "%s: old %#x new %#x\n", __func__, old_status, status); + if (status & ~old_status & VIRTIO_CONFIG_S_DRIVER_OK) { + if (pds_vdpa_request_irqs(pdsv)) + status = old_status | VIRTIO_CONFIG_S_FAILED; + } + pds_vdpa_cmd_set_status(pdsv, status); /* Note: still working with FW on the need for this reset cmd */ @@ -426,6 +480,9 @@ static void pds_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status) i, &pdsv->vqs[i].notify_pa); } } + + if (old_status & ~status & VIRTIO_CONFIG_S_DRIVER_OK) + pds_vdpa_release_irqs(pdsv); } static void pds_vdpa_init_vqs_entry(struct pds_vdpa_device *pdsv, int qid, @@ -460,13 +517,17 @@ static int pds_vdpa_reset(struct vdpa_device *vdpa_dev) if (err) dev_err(dev, "%s: reset_vq failed qid %d: %pe\n", __func__, i, ERR_PTR(err)); - pds_vdpa_release_irq(pdsv, i); - pds_vdpa_init_vqs_entry(pdsv, i, pdsv->vqs[i].notify); } } pds_vdpa_set_status(vdpa_dev, 0); + if (status & VIRTIO_CONFIG_S_DRIVER_OK) { + /* Reset the vq info */ + for (i = 0; i < pdsv->num_vqs && !err; i++) + pds_vdpa_init_vqs_entry(pdsv, i, pdsv->vqs[i].notify); + } + return 0; } @@ -764,7 +825,7 @@ int pds_vdpa_get_mgmt_info(struct pds_vdpa_aux *vdpa_aux) max_vqs = min_t(u16, dev_intrs, max_vqs); mgmt->max_supported_vqs = min_t(u16, PDS_VDPA_MAX_QUEUES, max_vqs); - vdpa_aux->nintrs = mgmt->max_supported_vqs; + vdpa_aux->nintrs = 0; mgmt->ops = &pds_vdpa_mgmt_dev_ops; mgmt->id_table = pds_vdpa_id_table; @@ -778,14 +839,5 @@ int pds_vdpa_get_mgmt_info(struct pds_vdpa_aux *vdpa_aux) mgmt->config_attr_mask |= BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP); mgmt->config_attr_mask |= BIT_ULL(VDPA_ATTR_DEV_FEATURES); - err = pci_alloc_irq_vectors(pdev, vdpa_aux->nintrs, vdpa_aux->nintrs, - PCI_IRQ_MSIX); - if (err < 0) { - dev_err(dev, "Couldn't get %d msix vectors: %pe\n", - vdpa_aux->nintrs, ERR_PTR(err)); - return err; - } - vdpa_aux->nintrs = err; - return 0; } From patchwork Tue Jul 11 04:24:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13308107 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0AE9C1643C for ; Tue, 11 Jul 2023 04:25:09 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2041.outbound.protection.outlook.com [40.107.92.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD6D41A8 for ; Mon, 10 Jul 2023 21:25:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mqXnTsivt600zs7iVigM1QLt0CtOWyLqrl6GDkSaJiJf4Z8bN9u4QtoSD6Nu7JSxpP6GKPlTpdA/dgQf/3nUjF/MmaBeIf89PyYSo97P9V+KSb/Y4JJnMsrh5kMrnci+MqRQHj4Qbsj7HQvc6Mbwgvq8SjF/seVtxl0YmEKOlIW1s45VksU6/umUYNu98/16Tgocl8vf0CXJ7reATxWAsQ55eJ2avTtVZWxfl0UtdceOb7tN+6GxOUMmzFDTJAtlzivFBQYUvdrwdJl9fs8PlMHAVMixEIDFcYux0No7pRnvkmfJvs+8T6wKwmC8+u6cIB3k1SHvbc/8L8mluX7IcQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xc7DwsT5JZsYvOCCaj6MLWMlzR8wchjiILzAIdoyUPc=; b=gDNANIDWI3yWLLvrU4UqAPeDgkbqesR+NrBfD2f1LmvcHQRXls0G++06n+J21Z9DaBmJj9ZFnvWxMYllp4jVYbIg/LmMh8qF4NHr+Cj/hkU9YNQ54+11UefQLe+vjCF5pUvcmOezJBB1ramc+M/Ptnyhv5ClUJ1jFk5YgcIPTz4/WNx1/F/7HkATJhel76EHt7NAcbE55JK3diTSEB+DRuJ4nI/GnBLfOuO/LyRxIqRLFtVhLWGVcfYDQ9cW7pS+ZqDWfKQb+yt6nkoX2Yvwq0rAIK07kHgYNlPCJY2VyUzny21oIiiCq95YFghHE3E4rY6LUotgCR2GIMKr8kG1lw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xc7DwsT5JZsYvOCCaj6MLWMlzR8wchjiILzAIdoyUPc=; b=lU/aPgYgfjqgAsVPaPOltksRuAuWOz8fL+AUXfVwop9OXmmgAWNcsh7zmX6oXSUVQhE35awiEkGBLvWRNFYV2WB1+vq1jXSsDul5ReYVHJwIeoxcz/xcQV/3NSuBVI9Jj2MhO7oVG5/D+t2F4VQOJ8kCeNRzJix0zHra6MOcnGo= Received: from BN6PR17CA0039.namprd17.prod.outlook.com (2603:10b6:405:75::28) by SN7PR12MB7105.namprd12.prod.outlook.com (2603:10b6:806:2a0::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.32; Tue, 11 Jul 2023 04:25:05 +0000 Received: from BN8NAM11FT073.eop-nam11.prod.protection.outlook.com (2603:10b6:405:75:cafe::ae) by BN6PR17CA0039.outlook.office365.com (2603:10b6:405:75::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31 via Frontend Transport; Tue, 11 Jul 2023 04:25:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT073.mail.protection.outlook.com (10.13.177.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.18 via Frontend Transport; Tue, 11 Jul 2023 04:25:05 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 10 Jul 2023 23:25:04 -0500 From: Shannon Nelson To: , , , , , CC: Subject: [PATCH v2 virtio 5/5] pds_vdpa: fix up debugfs feature bit printing Date: Mon, 10 Jul 2023 21:24:37 -0700 Message-ID: <20230711042437.69381-6-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230711042437.69381-1-shannon.nelson@amd.com> References: <20230711042437.69381-1-shannon.nelson@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT073:EE_|SN7PR12MB7105:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a6b28b2-7ced-4807-a2c8-08db81c6cd6f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DRiiQ+pu3D/W++Kd9mByNjhfIXFV0kh5uxkCiGftY4Wb6s8L8jOj1x81RoH6mNEBCdiVnCLFNmdzffGOcH3dRQStTZXfM7ykAg/5Wks4H4VmD+rhkihQDXhSw1AHTvaRJgyLaWQ87tOBKOlG5PmBRv451n/Y//tAZxTTWO9V3CF8oVbt/s9DDtFWLwmM3I5UhZtVkp98KN8CxYz70RUX6kANfFkV4tCoTiJccnOX2ZSjtxAtdbEnASEb06Qw6PgCjZ9Ccmz6o33DJ1w/yWw90ZdMK8zbjDtkk6q0GPwvJ85FlpBkIAO+yI+ZAEVVGLij6g1BeMEkDYgiCUJW57EfcARgMEbNMtWvj/TVGLBVI3dMCsrJNv/aHnJSmrkkoHrPUvIKXwaDQxgaknnvk6nE8xPwhCAE+NYZvTKQKSv5Tt52qUof6jz/znsYB27GeYdNBz6l7Q/zxp3FQKppqypc/EFvuNIyd4CWXpjJ8Jqox7RzwoEQ3U4fbYItSCbKfTNmor4WqKR78Pek52y3ZGeUiI5Ii0d24uRijGXJSYJLgOyLZ2XIYWNCpWadY8DE+KKWkBhpNTp9wUvONENmFc3UZwBtMJwaNxVqxu48QHD9Py2QuVq6H7bVZioWh2eq/sVSaUY+bz8JtH8fOpM/lBlIAoRBTu5YHWb+8WJWLgQK9JIiI1b3vENY6zMt1YUqw6qBfDCQx7HbXEYya0wZRckiLZwuhgXoCGCsjGzbT/uCu9h9CxH781078gcP3F2SEuLmJbqVBYeqVrLZfQmexHz00g== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(396003)(376002)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(47076005)(36860700001)(83380400001)(186003)(82310400005)(86362001)(336012)(16526019)(478600001)(110136005)(316002)(41300700001)(70206006)(70586007)(4326008)(40480700001)(26005)(1076003)(6666004)(82740400003)(81166007)(356005)(40460700003)(36756003)(2906002)(5660300002)(8936002)(8676002)(426003)(44832011)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2023 04:25:05.2741 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a6b28b2-7ced-4807-a2c8-08db81c6cd6f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT073.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7105 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Make clearer in debugfs output the difference between the hw feature bits, the features supported through the driver, and the features that have been negotiated. Signed-off-by: Shannon Nelson Acked-by: Jason Wang --- drivers/vdpa/pds/debugfs.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/vdpa/pds/debugfs.c b/drivers/vdpa/pds/debugfs.c index 754ccb7a6666..9b04aad6ec35 100644 --- a/drivers/vdpa/pds/debugfs.c +++ b/drivers/vdpa/pds/debugfs.c @@ -176,6 +176,7 @@ static int identity_show(struct seq_file *seq, void *v) { struct pds_vdpa_aux *vdpa_aux = seq->private; struct vdpa_mgmt_dev *mgmt; + u64 hw_features; seq_printf(seq, "aux_dev: %s\n", dev_name(&vdpa_aux->padev->aux_dev.dev)); @@ -183,8 +184,9 @@ static int identity_show(struct seq_file *seq, void *v) mgmt = &vdpa_aux->vdpa_mdev; seq_printf(seq, "max_vqs: %d\n", mgmt->max_supported_vqs); seq_printf(seq, "config_attr_mask: %#llx\n", mgmt->config_attr_mask); - seq_printf(seq, "supported_features: %#llx\n", mgmt->supported_features); - print_feature_bits_all(seq, mgmt->supported_features); + hw_features = le64_to_cpu(vdpa_aux->ident.hw_features); + seq_printf(seq, "hw_features: %#llx\n", hw_features); + print_feature_bits_all(seq, hw_features); return 0; } @@ -200,7 +202,6 @@ static int config_show(struct seq_file *seq, void *v) { struct pds_vdpa_device *pdsv = seq->private; struct virtio_net_config vc; - u64 driver_features; u8 status; memcpy_fromio(&vc, pdsv->vdpa_aux->vd_mdev.device, @@ -223,10 +224,8 @@ static int config_show(struct seq_file *seq, void *v) status = vp_modern_get_status(&pdsv->vdpa_aux->vd_mdev); seq_printf(seq, "dev_status: %#x\n", status); print_status_bits(seq, status); - - driver_features = vp_modern_get_driver_features(&pdsv->vdpa_aux->vd_mdev); - seq_printf(seq, "driver_features: %#llx\n", driver_features); - print_feature_bits_all(seq, driver_features); + seq_printf(seq, "negotiated_features: %#llx\n", pdsv->negotiated_features); + print_feature_bits_all(seq, pdsv->negotiated_features); seq_printf(seq, "vdpa_index: %d\n", pdsv->vdpa_index); seq_printf(seq, "num_vqs: %d\n", pdsv->num_vqs);