From patchwork Fri Apr 12 19:53:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Jurgens X-Patchwork-Id: 13628296 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2047.outbound.protection.outlook.com [40.107.94.47]) (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 039B93D547 for ; Fri, 12 Apr 2024 19:53:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712951620; cv=fail; b=CnUVfta6m7uf+I6mtpdTbwoaLRUyWwUfZnzquhFKfGVNMDKXTKCrsdsskoN7bA14YGTCrvpZBtMsPx2dMfJwGsTjnXnDhIoTEVlElxQqGLO6ZQYjIAfGKkazGRJ5H9SywGCK13hLaBR31hh8WnuD8Zbo1DQHl4eN1KFQC1R1p9A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712951620; c=relaxed/simple; bh=UfEdyCz3LlS1WzdrAvGxjzUnAqARglaVKhC+FvqA3oE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uu1IOILnc6lL+bMwkva8CKFdnqTdlzAg9yOtUU4jPwDZ2pVjHMaZ1nar2qxudhDrrejHaGjuFSOMD2caGWv3LWSzMcBiOIZ50/4dspdXYMvjVrVYX0C9i+Ow1AdA9MUkFIDcDGMw6wbVbk37h0P4zJ1+yQph6aWVPYCTPCq+plY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=g7dD+v5H; arc=fail smtp.client-ip=40.107.94.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="g7dD+v5H" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hnHz+Vyd71C0d9761183rUvtM+/VT9HEcsfYzeLef7IyJyDgJ8JZ7Smp2spL0NjfJICcwMjSAV7dT/RhjpJa7p/aBUoEX5D0VgZ00KlQKBIxlSRS/hJ4VN31EcDDeRacas5U/3J7y8nTu61FdwDTdh7SHQgR28FoaHr8o0cfxLdICpFNquF/vYmgQuVNxmk6X2wohNsCP/vg6fV78bZOEuLJtcTDf/hIUvDXRQhP09ZZFcSY9iqOIhG2AX6GEc8IJSoNCSIeZZtthGsjGh8ylLBa8A+Ns3079p2ekoY9stLMF3hU/UIftwvQryN3glhfKQk/iO2ltk9clzxBUhiQWg== 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=3gjjb+VLytpV1AWnJFcsVnfyfTN62MVNj/uuDrcOQQs=; b=i+pX9iqzQZc/pvAubLif6uH/5a0quiGyM2Sp746p0AGKB7wCSN2Wrr1fOVwOeW5xIw7EH/sIWzdJjG4lMvQUdaK1fL+bcusUibvqzQmHus6zHlB7go+i93sQQETIFzMZydy92vjPUbfbRkhPLfRewa/Mt+yosGvh/BS+DzIlhjkC4UQyWfh0tf3TDaxdoso67ocaFckJmFh7ET1VTtIVo8Ud5ARYbSQo7VoRwyyU2Af/54sIxLl5qYPxsKqZoSj8ocvjkSVLk+7PQLPFodGh0/zFRHj4hyaZSOZzNRgi9Ql2nP2XGRpzlBDbxk+JgAGHZOkAAXkNN7AqbuLohU57XQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3gjjb+VLytpV1AWnJFcsVnfyfTN62MVNj/uuDrcOQQs=; b=g7dD+v5HyppUoWZnfLOWW+re/6X6w6FfOzJO8HPQHAX4prIRSIYHCq4OZ9Fq/LGT06VmWLx4PohUOgeCzgNFEFnMx+NhIvouu3PuvtKZSoycZfAm9lf9hRO1eVfdNrppGQEyWq1PKkc5ALfF5JQPwwmbTs80qavL5jMO1wOveOA4Wq8atuOStPTaobQXlShUb5irVsyHRkPLI9EiqhC7jgP2HTQCJf/0edR/KzLVbCfP/VzYweISS5YftiWBx2UXaCLlTKLwtUfiF3THyA/rSfPMSZ4godsSRyf4zS8uMEBxZGR8TSPPU2YLUGElHkFu7SMU/r0mDG8WW3WXA0RigQ== Received: from DS7PR03CA0343.namprd03.prod.outlook.com (2603:10b6:8:55::17) by DS7PR12MB6191.namprd12.prod.outlook.com (2603:10b6:8:98::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 12 Apr 2024 19:53:36 +0000 Received: from DS1PEPF0001709D.namprd05.prod.outlook.com (2603:10b6:8:55:cafe::20) by DS7PR03CA0343.outlook.office365.com (2603:10b6:8:55::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.21 via Frontend Transport; Fri, 12 Apr 2024 19:53:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS1PEPF0001709D.mail.protection.outlook.com (10.167.18.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 19:53:35 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 12 Apr 2024 12:53:22 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 12 Apr 2024 12:53:21 -0700 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Fri, 12 Apr 2024 12:53:21 -0700 From: Daniel Jurgens To: CC: , , , , , , , , , Daniel Jurgens Subject: [PATCH net-next v3 1/6] virtio_net: Store RSS setting in virtnet_info Date: Fri, 12 Apr 2024 14:53:04 -0500 Message-ID: <20240412195309.737781-2-danielj@nvidia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240412195309.737781-1-danielj@nvidia.com> References: <20240412195309.737781-1-danielj@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709D:EE_|DS7PR12MB6191:EE_ X-MS-Office365-Filtering-Correlation-Id: 31b4120f-18cc-43b5-9756-08dc5b2a3d9d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UbVTsoJcsaZAQ1m39MvNbyXaFiUAeKQwxDHo5L+kh5fPD5CVpIybWuoo2T+0uIv4okQnWngcxYXys4KOBxBPTuUNNjkQXSF5WhpX55rIFBk6QyZ3cMYtBCJpoGkVXewtTmk7kpb2Jfo1J3aGHqKdURiyai5pAzGisRoA+BpahESCLA0iyTXo9lXFivdI6oiGrOvRlA8Z4HiScH1/PYzDrF7SZwKdTjFNy21jO/FCLSd3Z2CDu8JDkHXmESOb2AwFkjm7yekwQ3wL2yBY4K3mYlVitpa1aowYofMIzWqduhAZ1TA9em70FKuZl9Fxo7dN7Bcz839LCjDxvjfcBEnruO4iIGX+W9DgjWtItd6zM4q08hzn5LvaMkdPUWQzWGZ+czuUKvoQSuas2T78OiOGMCJE1/BbI/WUd1T8D4HkZQX1+LikSWhMkaRN4M2Oa4VDDIg2FdT3/N3XmHktWtFPIYLuz2sR1q8n/mk0Co8njwwoC+zVJxoIgzspUnwCSXfexTpEANHbfyPGTP9nXZhqGApW6R7behJi+Y4K8jZg56liOl+bCOIbSANuho1+k8SOnMoSz68uX+J8rM+NkYotvQDljDW8njR0tqGZnKrTSMXJ1aXNMviLrUedmzfBka9UuCPk23dbH5/5smdWTINPAqjQ85gV1M2j0gH2z6jGQzoWcHNe5KgXBk8Is4obnMkunLBA1mwJHX98sx9q9U7vA2vvBQlFwRXMB8XkN63qDy1KVNVMBEMHm1v467AcYB3g X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(376005)(82310400014)(1800799015)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 19:53:35.8697 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 31b4120f-18cc-43b5-9756-08dc5b2a3d9d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0001709D.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6191 X-Patchwork-Delegate: kuba@kernel.org Stop storing RSS setting in the control buffer. This is prep work for removing RTNL lock protection of the control buffer. Signed-off-by: Daniel Jurgens Reviewed-by: Jiri Pirko --- drivers/net/virtio_net.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 115c3c5414f2..7248dae54e1c 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -245,7 +245,6 @@ struct control_buf { u8 allmulti; __virtio16 vid; __virtio64 offloads; - struct virtio_net_ctrl_rss rss; struct virtio_net_ctrl_coal_tx coal_tx; struct virtio_net_ctrl_coal_rx coal_rx; struct virtio_net_ctrl_coal_vq coal_vq; @@ -287,6 +286,7 @@ struct virtnet_info { u16 rss_indir_table_size; u32 rss_hash_types_supported; u32 rss_hash_types_saved; + struct virtio_net_ctrl_rss rss; /* Has control virtqueue */ bool has_cvq; @@ -3087,17 +3087,17 @@ static bool virtnet_commit_rss_command(struct virtnet_info *vi) sg_init_table(sgs, 4); sg_buf_size = offsetof(struct virtio_net_ctrl_rss, indirection_table); - sg_set_buf(&sgs[0], &vi->ctrl->rss, sg_buf_size); + sg_set_buf(&sgs[0], &vi->rss, sg_buf_size); - sg_buf_size = sizeof(uint16_t) * (vi->ctrl->rss.indirection_table_mask + 1); - sg_set_buf(&sgs[1], vi->ctrl->rss.indirection_table, sg_buf_size); + sg_buf_size = sizeof(uint16_t) * (vi->rss.indirection_table_mask + 1); + sg_set_buf(&sgs[1], vi->rss.indirection_table, sg_buf_size); sg_buf_size = offsetof(struct virtio_net_ctrl_rss, key) - offsetof(struct virtio_net_ctrl_rss, max_tx_vq); - sg_set_buf(&sgs[2], &vi->ctrl->rss.max_tx_vq, sg_buf_size); + sg_set_buf(&sgs[2], &vi->rss.max_tx_vq, sg_buf_size); sg_buf_size = vi->rss_key_size; - sg_set_buf(&sgs[3], vi->ctrl->rss.key, sg_buf_size); + sg_set_buf(&sgs[3], vi->rss.key, sg_buf_size); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_MQ, vi->has_rss ? VIRTIO_NET_CTRL_MQ_RSS_CONFIG @@ -3113,21 +3113,21 @@ static void virtnet_init_default_rss(struct virtnet_info *vi) u32 indir_val = 0; int i = 0; - vi->ctrl->rss.hash_types = vi->rss_hash_types_supported; + vi->rss.hash_types = vi->rss_hash_types_supported; vi->rss_hash_types_saved = vi->rss_hash_types_supported; - vi->ctrl->rss.indirection_table_mask = vi->rss_indir_table_size + vi->rss.indirection_table_mask = vi->rss_indir_table_size ? vi->rss_indir_table_size - 1 : 0; - vi->ctrl->rss.unclassified_queue = 0; + vi->rss.unclassified_queue = 0; for (; i < vi->rss_indir_table_size; ++i) { indir_val = ethtool_rxfh_indir_default(i, vi->curr_queue_pairs); - vi->ctrl->rss.indirection_table[i] = indir_val; + vi->rss.indirection_table[i] = indir_val; } - vi->ctrl->rss.max_tx_vq = vi->has_rss ? vi->curr_queue_pairs : 0; - vi->ctrl->rss.hash_key_length = vi->rss_key_size; + vi->rss.max_tx_vq = vi->has_rss ? vi->curr_queue_pairs : 0; + vi->rss.hash_key_length = vi->rss_key_size; - netdev_rss_key_fill(vi->ctrl->rss.key, vi->rss_key_size); + netdev_rss_key_fill(vi->rss.key, vi->rss_key_size); } static void virtnet_get_hashflow(const struct virtnet_info *vi, struct ethtool_rxnfc *info) @@ -3238,7 +3238,7 @@ static bool virtnet_set_hashflow(struct virtnet_info *vi, struct ethtool_rxnfc * if (new_hashtypes != vi->rss_hash_types_saved) { vi->rss_hash_types_saved = new_hashtypes; - vi->ctrl->rss.hash_types = vi->rss_hash_types_saved; + vi->rss.hash_types = vi->rss_hash_types_saved; if (vi->dev->features & NETIF_F_RXHASH) return virtnet_commit_rss_command(vi); } @@ -3791,11 +3791,11 @@ static int virtnet_get_rxfh(struct net_device *dev, if (rxfh->indir) { for (i = 0; i < vi->rss_indir_table_size; ++i) - rxfh->indir[i] = vi->ctrl->rss.indirection_table[i]; + rxfh->indir[i] = vi->rss.indirection_table[i]; } if (rxfh->key) - memcpy(rxfh->key, vi->ctrl->rss.key, vi->rss_key_size); + memcpy(rxfh->key, vi->rss.key, vi->rss_key_size); rxfh->hfunc = ETH_RSS_HASH_TOP; @@ -3819,7 +3819,7 @@ static int virtnet_set_rxfh(struct net_device *dev, return -EOPNOTSUPP; for (i = 0; i < vi->rss_indir_table_size; ++i) - vi->ctrl->rss.indirection_table[i] = rxfh->indir[i]; + vi->rss.indirection_table[i] = rxfh->indir[i]; update = true; } @@ -3831,7 +3831,7 @@ static int virtnet_set_rxfh(struct net_device *dev, if (!vi->has_rss && !vi->has_rss_hash_report) return -EOPNOTSUPP; - memcpy(vi->ctrl->rss.key, rxfh->key, vi->rss_key_size); + memcpy(vi->rss.key, rxfh->key, vi->rss_key_size); update = true; } @@ -4156,9 +4156,9 @@ static int virtnet_set_features(struct net_device *dev, if ((dev->features ^ features) & NETIF_F_RXHASH) { if (features & NETIF_F_RXHASH) - vi->ctrl->rss.hash_types = vi->rss_hash_types_saved; + vi->rss.hash_types = vi->rss_hash_types_saved; else - vi->ctrl->rss.hash_types = VIRTIO_NET_HASH_REPORT_NONE; + vi->rss.hash_types = VIRTIO_NET_HASH_REPORT_NONE; if (!virtnet_commit_rss_command(vi)) return -EINVAL;