From patchwork Fri Jun 30 00:36:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13297470 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 20B0E15BE for ; Fri, 30 Jun 2023 00:36:49 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2073.outbound.protection.outlook.com [40.107.92.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6E931FCB for ; Thu, 29 Jun 2023 17:36:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XTgV6s1t+Oeuzlfy6x1qIuhZlTkRLGyeQuMvA6QxKPG7hXHpkiMC0O3o4Cct28wLsnpvceH/qc7aaMIBLK91A47mbQ5ZPVwWIVz3G5YnQ7CCS4knPVnIKqDkhig9KVI5/ITUltPd8T8SLfhXpc1wgmUmJsme0E7+9RR9KeqXI2nTvrf2yBdF+1S9vLuRJ4p/BeCdtdseDH00fCWNR/RXYUDGbV/2v822k5sNvGHUGbSG9DLGqs8GNgEDgNuczj7Zb641/ZKPa9gPwyDQFsWbT7E44QYp5bpgl3f/yQq+ZtsM7TOa6HPDcLjZ6H8TOk/+47EK7G6zJ4+QJveimtmGSg== 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=h9I5jrwUis/YC3PN2qOEaCCoTlcM/eS+vKQqW1LCYxI=; b=feuisYyVUDQRmOt9iGJXE9IeB7r+0ZRlQ1xc1/MEkoV+OeFmMwNVAGIUzv6Q+4Xt4yUovnsiTPskwbf2CPTFkWg2LqebHIFraovM0+NCfPR+MzruVfhRPLL3W1OJmJpRetipbdgr+TQ2hJZesi0W+bju+z6jas816/Zcut+9XfP6b6Y+9LLWr38qUKlmS1cxtYTprmoBAIz4H1caqgFyTBflKvUUHfxYnEpQn9DoXg/fiv5o3absLSw1K4JPeN/OWOroBMWxsJAe0x3RGKe0ZM3KlxqukJ9vhokAkXr31XY2YDoDYa4ZmeXMn76RdctaYvZPFyfIoTsYpp5i2lFcsA== 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=h9I5jrwUis/YC3PN2qOEaCCoTlcM/eS+vKQqW1LCYxI=; b=Ew2+S6uHmiQ6SU+igAOWWSIkTcWN4Kd+SQDhiWE9sOIgg/tApB85SaUEIVVtYciK7aaNbKA/af4HA8vWytOOz3dO5zZzJfIVVGx98qRrsMUyYRIa7qaYd3cuUwkdfNgFxr/dplbho+jd8FJCeSFSgWCpjmRVozsKdQQDpRiR8RY= Received: from MW4PR03CA0266.namprd03.prod.outlook.com (2603:10b6:303:b4::31) by BL1PR12MB5349.namprd12.prod.outlook.com (2603:10b6:208:31f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.15; Fri, 30 Jun 2023 00:36:41 +0000 Received: from CO1NAM11FT040.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b4:cafe::e9) by MW4PR03CA0266.outlook.office365.com (2603:10b6:303:b4::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 00:36:41 +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 CO1NAM11FT040.mail.protection.outlook.com (10.13.174.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.33 via Frontend Transport; Fri, 30 Jun 2023 00:36:40 +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; Thu, 29 Jun 2023 19:36:38 -0500 From: Shannon Nelson To: , , , , , CC: , Allen Hubbe Subject: [PATCH virtio 1/4] pds_vdpa: reset to vdpa specified mac Date: Thu, 29 Jun 2023 17:36:06 -0700 Message-ID: <20230630003609.28527-2-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230630003609.28527-1-shannon.nelson@amd.com> References: <20230630003609.28527-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: CO1NAM11FT040:EE_|BL1PR12MB5349:EE_ X-MS-Office365-Filtering-Correlation-Id: 9846b489-6f7b-4480-7193-08db7902128e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qs1ykkHHuy04WrzfX/0c2ZGK5IK+z8CmkeFKu8HPJoHI6jvxlPmH62SqBA/amTN2RusqNLzjKJAa1zo3olHXGCSBaIRZS6S/O7ZXdli9C9oS0qJgeTc4KplG1xCET8Eb6JiifxdbdRL/Pxk/O8BNtOEKIi+ikY3gsfiFu2p+ifOwanRPQeOGyCBSufLQ7zIBNn1XltenC7GUNeQosQ9TK3V12/DpVgIxgoDTcYup62KiLXqD3HlYAQYFvWE6qiMTkivSJwmeTU062dKGwL7rnJLRfhBYVuBMAa2n9GBU7tj+RRul7s6unbSLBLRoH1Mia8lDmP471zYza3oTlu94BvgYy/G0Yun9EP6+SEbE+MLj/4Vu3AQK35i85XBTQJ5XdBI6K03xwwtm/kxv2kVv+YIYzUtRvjMcNPbaZH24yAnOvYPpfMHfWlJL8QCStjOH9kKdD8ZVSOh6xWe5xMHZUN89wq/hrZkWi5Mqh4kGC1wq5jvc/kg1Kfjm5Bco2iDw/JY1Su4QTM/+3qWTa1xraCxNffBxvgftdyIIPnzagERiqtclSR0hjw8Tef6fAko2KWoQCw9X2xGUWLHYXnHd2a4ry8PhYBJNLlBZ5XaQ7l9yIifYZrTN2TCWNpCutuEX4O78bRhiQUv759fRhOANVCvpy97LVQxqnKskSecTP6r0Vw24wi7dfu7G4t+1nSaW4GJ8ucLrappf8vwpsiDGh+jsls65+T9/nvcOboaqbwfhYWOUqFfDen4h2A/MLKc0aAAHUJiHDyj9JC1eqtkpZg== 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)(39860400002)(376002)(346002)(451199021)(36840700001)(46966006)(40470700004)(70206006)(70586007)(40480700001)(40460700003)(4326008)(426003)(2906002)(336012)(47076005)(186003)(2616005)(16526019)(83380400001)(316002)(36860700001)(54906003)(110136005)(6666004)(1076003)(44832011)(5660300002)(478600001)(26005)(8936002)(8676002)(41300700001)(356005)(82740400003)(82310400005)(36756003)(86362001)(81166007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 00:36:40.9715 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9846b489-6f7b-4480-7193-08db7902128e 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: CO1NAM11FT040.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5349 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 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 Reviewed-by: Brett Creeley --- 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 Fri Jun 30 00:36:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13297471 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 C43E417FA for ; Fri, 30 Jun 2023 00:36:51 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2060f.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::60f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 972D21FF9 for ; Thu, 29 Jun 2023 17:36:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a/2bIBUQib5OTtW74C+WZ0rIkgoLMSf5QHR7Ltp5O5Bz5VIaDlUbxEUVyU82Kp99wrr30NtKlfAhjnsnwp5vVmBOe8qBsOpaZ7+pFRJUoXDMwqP6So0iU/Ux0pt8DpW/h5QT0wjHczCBsnQotDAXhQqZddAVdFPMsQw4MBwOUy7EIPstopshE0jYTNnTpquGXxtMLBx28sq4IBH5lH2k4rtfttMCRNUH3e9UCYmv3Rb1THIN9CEjM1kkmQQKdWaeqamDPnp4HStpUYFjOXCv5v1xbDccZgoJX6THGX4hT/O0NkIdjetV3vjbQcgJpKGhQ3f8goz1Ug4gLsVXfTmpMA== 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=gt5gynslWs1EVfWnc+SaQynIl+rLUBbPJozpWajxZeA=; b=IuGquVieX9TnRe4ZSle1ORVK8rXjVhCBRvgCOqQicW/CPh1FiGNURFDMExW6xorTcmftjbH7I5K6VG78b0NzAndYGNzB1tgQQyMC7IJAgNniCsKlFsh2riF5rawyeMM4faD4qQeQpQ7xDBMkK/MNNGUjO71mRpihewAbKnMhU94ARHtE3hDZrmwpnNIjmeOVFYgAAEml9rt5dFQ6NpDsTkr/38NHD+KFP7evxvI9ospImr4z+Erlu8NP3Du6Z5V7epflzQwo+Y5PVIcAm13J8Y4k1Nry/udbXGXXwak8g9BmtshN2BJMHj3EkvQoovagewofhYP83Z7fUTOR9vSsCg== 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=gt5gynslWs1EVfWnc+SaQynIl+rLUBbPJozpWajxZeA=; b=WXxiWA1JO0xBc8AfCix9YwvQS3qQTgA1lXVb9kerRz5FVoz4KG4X/VcRz8y/kFYUpEuGRqoEu/BFzjR6LZeKE+VlU6KyrPZV6MuQzBhGIau/IClA9BCEbs4NUf3KVS7CLAOssmJ/spVLLPLc3GbYkPXsdhJbc76bU3Q5+7G78AU= Received: from MW4PR03CA0259.namprd03.prod.outlook.com (2603:10b6:303:b4::24) by BL1PR12MB5921.namprd12.prod.outlook.com (2603:10b6:208:398::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Fri, 30 Jun 2023 00:36:42 +0000 Received: from CO1NAM11FT040.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b4:cafe::1e) by MW4PR03CA0259.outlook.office365.com (2603:10b6:303:b4::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 00:36:41 +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 CO1NAM11FT040.mail.protection.outlook.com (10.13.174.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.33 via Frontend Transport; Fri, 30 Jun 2023 00:36:41 +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; Thu, 29 Jun 2023 19:36:39 -0500 From: Shannon Nelson To: , , , , , CC: Subject: [PATCH virtio 2/4] pds_vdpa: always allow offering VIRTIO_NET_F_MAC Date: Thu, 29 Jun 2023 17:36:07 -0700 Message-ID: <20230630003609.28527-3-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230630003609.28527-1-shannon.nelson@amd.com> References: <20230630003609.28527-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: CO1NAM11FT040:EE_|BL1PR12MB5921:EE_ X-MS-Office365-Filtering-Correlation-Id: 03cda1fb-3c60-47b0-f4f2-08db790212f4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PyjQhUnqgFNrYK6/pqsUOiZJ7mK4fcKJLTBaEYLwJTGKEZzpvJPJEvhJzSLyPQ50dJdzI1U1OXibQ7xD9kdaabBa82pamLfsPSHYfHTMeyTmuK6xBRS2z7J4UQxM2bmeDu1dyqhCjXQldaxK/2ibpfdE95waB2t0KMvCaFLAVC9LIpR3B0pwXzwQX28jmk0Br8vX82SbloPm+s6uRTk6s8KMUtNPpq/wOEeenpS6uyhDu+oA0pxQ9vlJq6TTlcvyBiNLbjdcDp+ztc6qAow6Eqol/g1TVJjApwoROBb5aQWgk4rsNk8IDHdbfwPaFLQ6/vGNRsylFl8VmB2GgaAiH055K8RmgoUFswcZEb30tAyIktQ2naFv2ePt12HhU4y2B4wVFBMpBjmM1KghbQo69kwMxWYDq2be6g+ZUSVKJSSNLaiBRTydNpEprLYvFPcIUGgXdTd4oYnxaLablgOeIIPb0atkbxpf/KnOvPKhTCvYo8/17CNreJUQAQv2+Me4IPJyH6sYJoKfMBEVUqbPmYDjJbLV6vbRhmPXY986t9TpWiYhCHq4vmR9ws2+i6KddbvrzMPevR0RElqre3Ku2fLJbrlb3JXsbCLV/adpxz5PBb11MO8XnQmm9u0yFZSIPPq9zULEwefUAJrX8mRUuJvm22k/lxjiq0ZzqfsClyFBqh8eM/qHXk1VEtRgA6GETYBOQsA44EKysqADcA/se/Vfcm7WTTVD9bL/NOGyGJ74t2IerpxQHm6DD9BEwIHiaeRxvFrcMaQt6vYUx7SdPg== 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)(396003)(39860400002)(346002)(376002)(136003)(451199021)(40470700004)(36840700001)(46966006)(8676002)(316002)(70206006)(426003)(16526019)(186003)(4326008)(26005)(1076003)(336012)(8936002)(110136005)(41300700001)(6666004)(40460700003)(70586007)(82310400005)(44832011)(5660300002)(2906002)(40480700001)(478600001)(2616005)(81166007)(356005)(82740400003)(36860700001)(86362001)(36756003)(83380400001)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 00:36:41.6589 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 03cda1fb-3c60-47b0-f4f2-08db790212f4 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: CO1NAM11FT040.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5921 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,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 Reviewed-by: Brett Creeley --- drivers/vdpa/pds/vdpa_dev.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/vdpa/pds/vdpa_dev.c b/drivers/vdpa/pds/vdpa_dev.c index e2e99bb0be2b..5e761d625ef3 100644 --- a/drivers/vdpa/pds/vdpa_dev.c +++ b/drivers/vdpa/pds/vdpa_dev.c @@ -316,6 +316,7 @@ static int pds_vdpa_set_driver_features(struct vdpa_device *vdpa_dev, u64 featur { struct pds_vdpa_device *pdsv = vdpa_to_pdsv(vdpa_dev); struct device *dev = &pdsv->vdpa_dev.dev; + u64 requested_features; u64 driver_features; u64 nego_features; u64 missing; @@ -325,18 +326,24 @@ static int pds_vdpa_set_driver_features(struct vdpa_device *vdpa_dev, u64 featur return -EOPNOTSUPP; } + /* save original request for debugfs */ pdsv->req_features = features; + requested_features = features; + + /* if we're faking the F_MAC, strip it from features to be negotiated */ + driver_features = pds_vdpa_get_driver_features(vdpa_dev); + if (!(driver_features & BIT_ULL(VIRTIO_NET_F_MAC))) + requested_features &= ~BIT_ULL(VIRTIO_NET_F_MAC); /* 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 = requested_features & le64_to_cpu(pdsv->vdpa_aux->ident.hw_features); + missing = requested_features & ~nego_features; if (missing) { dev_err(dev, "Can't support all requested features in %#llx, missing %#llx features\n", pdsv->req_features, missing); return -EOPNOTSUPP; } - driver_features = pds_vdpa_get_driver_features(vdpa_dev); dev_dbg(dev, "%s: %#llx => %#llx\n", __func__, driver_features, nego_features); @@ -564,7 +571,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 +622,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 +632,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 +761,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); From patchwork Fri Jun 30 00:36:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13297473 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 80DFF1FA0 for ; Fri, 30 Jun 2023 00:37:59 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2081.outbound.protection.outlook.com [40.107.92.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C40F1FDF for ; Thu, 29 Jun 2023 17:37:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nOKwovmS0+xD6x8XhSZPE8ZfDbY1xYI/lIU05Sx7aQG95lPSq4nS0DOb2yf7mxkGzD7AT0VohV0cMzbZPVWcfvJJK5XsT1TLZha2VMEUuqEOOEsDIycOxWhsswGNVkMmeANVOg3Yr0DBpi9+zXC3imGjg5NLErRlH88f8629h2+rvpWMQyBbGejyMvME5OAUGO6ufDgqPTHmpaGCR1w6QymhHjOPIYrZ5hOaynhzUeZD31mSJxHnyPBBxPqzhqt9WPvfv4y0/MJ9DBlGWYu1jJUPGxI1u8GxROnLO0f4BSlRJ1rAyUhYvLF9KzT/NeK1tHcp679cerm98hSU8aj2sg== 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=J1T/q9YLCa0OJtcBUtJudBMIdx/2qVqHul7jew9IK3I=; b=DpnlzO6Tw+M4Qpj4QbdaXFVEWRQRixnMrmQR1/m15bz0fKA3qNrRIbfAFyk50Sus7Cl8bn7lk85GDt4aTPNVKwrguE3pqtyHtnSjvMHX1BYybl+fbYPjdGK+d4cCR81lOVDqKfgIoQb5EhzUplAj+yMju/eBDIK6WU1C8Ug4sEqPriPERlTLgpfpII91yYcSBL752M1zY2p5ZMPo+XwZ3tfwRliNgtF4gekG1UypbEbeVD2UBa9Du94gq6bq4ia3eW999Zbn8yjEgbJ2ZUAsWBZfR8x2fDUPgOJkQJI8Ka/OELnr0j6OXAlw2YJ8UltJk35fggDxYiHFpTHxhrolSA== 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=J1T/q9YLCa0OJtcBUtJudBMIdx/2qVqHul7jew9IK3I=; b=3WV0ZJoW/Co5pkKKPYY2Xo/J3y2gocHtTzYD0+LvCGUglpCfevSQZbcffPxBuKMMJEdq5vNegfDLLuoQZG5xgVn5jJazBCPERZyIDrZtLLAaO6EEry7Q+6TKb40JJgqdEciChJ1d5Xu9u8i8J92rC0XsN14SHUA3WJAUCq6IiTQ= Received: from MW4PR03CA0265.namprd03.prod.outlook.com (2603:10b6:303:b4::30) by MW6PR12MB8834.namprd12.prod.outlook.com (2603:10b6:303:23c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Fri, 30 Jun 2023 00:36:42 +0000 Received: from CO1NAM11FT040.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b4:cafe::86) by MW4PR03CA0265.outlook.office365.com (2603:10b6:303:b4::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 00:36:42 +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 CO1NAM11FT040.mail.protection.outlook.com (10.13.174.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.33 via Frontend Transport; Fri, 30 Jun 2023 00:36:42 +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; Thu, 29 Jun 2023 19:36:40 -0500 From: Shannon Nelson To: , , , , , CC: Subject: [PATCH virtio 3/4] pds_vdpa: clean and reset vqs entries Date: Thu, 29 Jun 2023 17:36:08 -0700 Message-ID: <20230630003609.28527-4-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230630003609.28527-1-shannon.nelson@amd.com> References: <20230630003609.28527-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: CO1NAM11FT040:EE_|MW6PR12MB8834:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c10d7ba-11ea-4fe9-746f-08db79021399 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i7GluMEOWoLhkYda+vh+TuUkKY8huYALYOyIdXt7U6hSUlNtnsF+RUL3tzM//1Rm+I9ZfHrjT6+nWVRIaJ2fa3vTSNaFs/s6630JKfEgTa9WXwiKwPBtG810fioRhviNuqF5WLXgnPgwbO253o1dBRba9s0yuJNZej5RkVwKc+nEWQp9umU3x56tlS/XS4sk8VsCwLH84U6W7GJAv6cOHWH+/TjlcEAWHhz+qZv3bux22Z+cb4w4e8KP/2rI80VV/zmHimU1n4vAi8geOqLKAS8Pd1Gww5rSRd1EeNqoi5dT44KrrQzgXCj2QnFc4D82/p+vABcaeS+pQmM6RJZrYYpmJHfMxa31E0VqbH9hSjzj4VMFyRj4kTTC0EQL2D5Jt4ktX39Hm4GylDcqTLQNvMM+g2AFB69phBI34XuazpUl95rFKDez+L+3qvwfYCbapsabeCfQM+tqK/Mg7XSVNW3sYJ4fLf8ZYYQrMWvjaj8Rs3IV6XBu2PRMymSCClapiiOd+iV2mADF3AtHcx0czkxSftAWpmtb24dY4C4SnVAiHK4clFvNlEgdToRNbkcMDTu3f0XNwed3Ws8UFh8golhfl9OLDyf0eTGEOjXBTved8sTYnB+RXDmp+/R2jb2MFc9vCXlFm3bkYsKUW50LP0VlLZ9MzVJ6JKgGpyVHpSwPlJN3Z/JIoDJ3yqyDGc4jdCsR+AS0dsCERZkpeb5c9Nahd7JXXMcDqcvva8PgVcOeH19DLktcGkgy+mQadY6dXUzrt3oJsFc3h3/VsvIo0g== 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)(136003)(396003)(39860400002)(451199021)(40470700004)(46966006)(36840700001)(16526019)(82310400005)(4326008)(36860700001)(47076005)(478600001)(336012)(6666004)(110136005)(83380400001)(26005)(356005)(186003)(1076003)(426003)(2906002)(2616005)(44832011)(70206006)(36756003)(82740400003)(81166007)(40480700001)(8676002)(70586007)(5660300002)(86362001)(8936002)(40460700003)(41300700001)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 00:36:42.7214 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7c10d7ba-11ea-4fe9-746f-08db79021399 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: CO1NAM11FT040.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8834 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 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 Reviewed-by: Brett Creeley --- drivers/vdpa/pds/vdpa_dev.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/vdpa/pds/vdpa_dev.c b/drivers/vdpa/pds/vdpa_dev.c index 5e761d625ef3..5e1046c9af3d 100644 --- a/drivers/vdpa/pds/vdpa_dev.c +++ b/drivers/vdpa/pds/vdpa_dev.c @@ -429,6 +429,18 @@ 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) +{ + 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 = + vp_modern_map_vq_notify(&pdsv->vdpa_aux->vd_mdev, + qid, &pdsv->vqs[qid].notify_pa); +} + static int pds_vdpa_reset(struct vdpa_device *vdpa_dev) { struct pds_vdpa_device *pdsv = vdpa_to_pdsv(vdpa_dev); @@ -451,8 +463,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); } } @@ -640,13 +651,8 @@ 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); - } + for (i = 0; i < pdsv->num_vqs; i++) + pds_vdpa_init_vqs_entry(pdsv, i); pdsv->vdpa_dev.mdev = &vdpa_aux->vdpa_mdev; From patchwork Fri Jun 30 00:36:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13297472 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 1D5FA1C27 for ; Fri, 30 Jun 2023 00:36:52 +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 E87A4183 for ; Thu, 29 Jun 2023 17:36:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SNGZyONClVY67CI6aiXaCaGGGSCJU9sdcfad+kVc0GqopRigp42/zXgjGC+W+qTbQ7tS+LyS0vCwm/f0mjhv16MFpk3cLCluUtZuiyen4ug12WU1WgDfNk2llXRrsixhy+3yi6ZkGinkJJ00g+ivavyq1IQI2m4dnhVfHor2RBGHxMfGbSexwMn7F7c98Ro0V6S5gJ07U7OhdQs62NgqW2dEHjGG+eMUbZzYxv9itUZWRd1EzCcxloltAKGVSB+ZsnxGGNCF3MARWnZ2Wn5WIJMQtXWZMsRFJkheFY9G5BsPORQUz27H69Y7zjwmDN9GQQnklXIq2fV3rI139Gk3sQ== 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=kLekv9iUTh4QHuNZdGx32XzBN7KDA7YlrtIEG02xfmE=; b=KgLxXJZDcRYWKi4XTnnoJ9sgrkKmE+wXqRcI9GeFaF7GrgaNPoHS9YWOXacT41Z/cq2u+ZnTjxv9c2O7Coki/RxgvByBvk5SLjs2PjDuVOOmr/dA0N14UC/LO+GfpR5U4y3sUHztOXJwFHLLNkDhCTzaD1z7dxezHcn8JMFFSAZPVs+UKgZZawyA0Dy3uFkEAdG9SphT7LOEwt7ZcaYEkFBsRLBoh4fw4DR+WJ4Of5U383nSiILQ38Zhsm2nTBgfUm3ln5aWaNiTYK4KP5vlXGD6WhkHbuDEcmpAA1zEmN3Zh5R6czayBclqvOUK3/5msRCqkvWgQVvCwMVozAIxMg== 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=kLekv9iUTh4QHuNZdGx32XzBN7KDA7YlrtIEG02xfmE=; b=5csq5/3EYqPFyY94oVs3qRfE/gbDwydnA80FwoGcwVuNpFtA7znlT5+PkJrjJ0TWsXLtJpJFPO1G44cN2Czlh1+looJEa3kK9a1EoMwItS1jupLd5ATk4MNqNjOOUGhFaeFaLiP9Yn3Ll1Q80GTSSeaylDeY9oIctRKSLcrX07M= Received: from MW4PR03CA0252.namprd03.prod.outlook.com (2603:10b6:303:b4::17) by CH0PR12MB5043.namprd12.prod.outlook.com (2603:10b6:610:e2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Fri, 30 Jun 2023 00:36:44 +0000 Received: from CO1NAM11FT040.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b4:cafe::8c) by MW4PR03CA0252.outlook.office365.com (2603:10b6:303:b4::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Fri, 30 Jun 2023 00:36:43 +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 CO1NAM11FT040.mail.protection.outlook.com (10.13.174.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.33 via Frontend Transport; Fri, 30 Jun 2023 00:36:43 +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; Thu, 29 Jun 2023 19:36:41 -0500 From: Shannon Nelson To: , , , , , CC: , Allen Hubbe Subject: [PATCH virtio 4/4] pds_vdpa: alloc irq vectors on DRIVER_OK Date: Thu, 29 Jun 2023 17:36:09 -0700 Message-ID: <20230630003609.28527-5-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230630003609.28527-1-shannon.nelson@amd.com> References: <20230630003609.28527-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: CO1NAM11FT040:EE_|CH0PR12MB5043:EE_ X-MS-Office365-Filtering-Correlation-Id: 96dd5afb-b53d-4fd6-d2dd-08db790213d9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SeYNblKLLZL7QYPJvpG72gk/rb4fugMNrDYXTah6W7GDwfLF3LbLZEJrgaAMU5E7+nMOCrdun3XJMZvxQscW9HLZhoSJ6OZ4flRr1A00uPkFR3Q4s6UgLCmRA77WwVKRg7n0Ib6KfO36nDHn6S6Qt4a6cQHiTQifkjkcIeWbubfavDZxpnXvCLnNi7Sj4hB0BPMIfgAEfhP6JPaj8us9GYuh3oMnQjfab2tJtKpmLsv2O/7tcS+TH6CkkOIAPhP3Ev0k45/4F58g9+qvLQrY9M6l+q9sqYeYzd4rSYdmy69m9/cQRR81F5utrYZrQUbmU+HwO9GnKAFZ8gEGeCALYZuaMUlzdAmra2rFfxIzdFm3fz/+ABuCMvVkK3p7Tt1Ah4hKTadCCYYWR1QSQCZwyxV0dm/naoxDfSLf25ZpTdOTq8mYpashG8WlUT4l2fNJw/DjE9nZSzD9obbL+OwhNpTVzrg+6LCMGuWMKvnCFlXLfjOH6rhngB3FwfonRWchXQxrsWQyFRbz0bbeGY3p6Scef6g27kOtH2rRBWa1JtPOgUQftluEURNtm5mlLMnQdTYmDzyvY91Bmh7rk7msS+MSKDfOVRPh9Di1LCNedHqq9I2HT9R6krq10rxHWkG8PcYANzIrjD56dv9B04NG/scMSONptvxFHQtXOj4aHl7fMTSCUrG9nd/tHWfHM/PQaMjHV6FNyy2Y2PQ8AmwVpdj5scl98ROX3apftYXdZcrXXWpFiclVXo9eDHTUpfoOCSG78T+S8yTd3d79NfCx6A== 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)(396003)(376002)(346002)(136003)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(8676002)(316002)(70206006)(8936002)(70586007)(186003)(426003)(41300700001)(16526019)(336012)(4326008)(1076003)(26005)(6666004)(2616005)(54906003)(110136005)(40460700003)(82310400005)(44832011)(5660300002)(2906002)(40480700001)(81166007)(478600001)(356005)(36756003)(86362001)(36860700001)(82740400003)(83380400001)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 00:36:43.1432 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 96dd5afb-b53d-4fd6-d2dd-08db790213d9 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: CO1NAM11FT040.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5043 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 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 Reviewed-by: Brett Creeley 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 5e1046c9af3d..6c337f7a0f06 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; @@ -396,6 +379,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); @@ -406,6 +455,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 */ @@ -427,6 +481,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) @@ -462,13 +519,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); } } 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); + } + return 0; } @@ -761,7 +822,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; @@ -775,14 +836,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; }