From patchwork Tue May 13 00:06:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mhkelley58@gmail.com X-Patchwork-Id: 890837 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F34C9367; Tue, 13 May 2025 00:06:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747094784; cv=none; b=Ka9YCWqqmb5IWAq8paqUVSlllR8VFpLrLLEC7mKyNLjNXs2N9GC8CM5JaI8QeqNE3UAk1hQe9GuVcWEBlL6S+57c6xAtWUrN77B+AMr700VNptQGgYkOenQlOKYDUiDO+Y+64ZIXxaUrcX7wcrlpHIzOfoYGrNcqEiOkSH8kY3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747094784; c=relaxed/simple; bh=FqKM+4QL0Ww31oOptKrxbmEN83vTXpCtq/sYWBVjerc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KkSO/pmRYnsPe5pSkNw3s5CAhl9EdhqXYgnwMJ05KqeSBcRjbMzCUel+UQ7QND3uZGv0F6ayXI1ElLh1U9iAHA5lo5fKcKXtb7htCARrsPcO33ITtvm/HYY2HSqoe0YivhKDFCzK7GCo58z8v17yoHmKmtXOyOJ2AAO5NkliWCk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=S8ka0XCE; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S8ka0XCE" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-22e4d235811so72608925ad.2; Mon, 12 May 2025 17:06:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747094782; x=1747699582; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=K+wz2fZe6II1B8M7LCEZ+1BKnQs3N11wYkIiB94tlgk=; b=S8ka0XCEqmC4Ys2FDA+kV3i0WXoiN/zC/8IxQlQmTgw1Pr/AX3H/KOGcBMQyrdu3lR ROM9Jqo1dNPua2pWBXteHjTh3R1b8gPnKFzrMp1m1MenOWDBx3d2yt5ebASJUNKCBEmR yKdkNJDJADRaQOM1zeOdT9xSSb+rhnSCmRmRlg8d03F996Cn4RQVtuQlxG9eXw09FaNr 6ETLd4SbTCWmjJ/27ka/fzobDs7apqC8POCkHjAFA7uW3HcYiKVweoARvuRzhafe//CI Ku2ZFXzSEfRx5f3mlqzcD9lv49waJGmBi2LaCqOyWVYL8bacE0zIaszqE3l5DEgT+3sb L9Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747094782; x=1747699582; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=K+wz2fZe6II1B8M7LCEZ+1BKnQs3N11wYkIiB94tlgk=; b=nEpahuvhTKFMYwp0n2c2Q9w8C+ThjNh+xrF8q8nafK+rnVvQECtqiP8DU/7djJLh1q IVlaicm0hNK2VGOLVSm5XXHA7eOrZYCweI89WiVIqOpP1PD5mmnGHhTeHTEKZq3lKduX kSwYMP12sFnysjTqT3VhBYVKwF2Jh7JzEKh79l39rF3KUrnfIOlBvvRKexYMRagjjm/6 Hlf1apTk4LAiiqa7Wuo2zyfQKev7BDWbELaZkoWbsr+78fvM87/4fskfFki9FUo99dsC QEbkLLJ+xffbi2lzkZOmAUlM7dyGwObhbqUOEJ0wkuHaC3iJ+hUFKY2nmyP9DUsqmLzp JYjg== X-Forwarded-Encrypted: i=1; AJvYcCU0r+SCpqnh2n5/TUljLZp2c53QZDp34VjfVN5fQKF5cwVoaht9Dd/CQJ+LZi4U0oq+oaGMCcGL@vger.kernel.org, AJvYcCV6GUzxBrQ7EjbuyZzpbj60TzT4BaWJPjFaobVhbd4nAzScRulXQVHaTTL18Wc/Hzl/UObkSz33KVfZEg==@vger.kernel.org, AJvYcCVkCPKPVd1zXLFUElstktQ8iGdv1Fb/aVGmSSD8GWaAGWWXw4akvRcewdBZMOIVJbCCzm5JZr+/dXMbK7s=@vger.kernel.org, AJvYcCWzoAE3MYSqyQDuwJnBeicwg0DGzsizNEgezO2nQOmgLHG8BJseJednACSHSeOTlOmOUgKZ3iow@vger.kernel.org X-Gm-Message-State: AOJu0YyX+2KDHcUrFaya+i3HBHPpXjFV+6WrOzwhZPm9DdQ0OhYl+kVk 2qHg1igMBl/te2D3+cCqU2z7CqVErV3GDFmF7iUwwelpN6OviRMe X-Gm-Gg: ASbGncsoCD7KkOBNPgqHgtFVyg8AwlepFZZOaXPmnN1je4qtpcVTcQngX8PK+sl3uZC /+2Lmwosz0/IXPDT7d6kdqihwr2f+OzzjBydRDvA/ScJKUNeSfA5v6ljFAWLaBdl3PWwRfxS5o3 qBExxAL9UEwlt9a3E6kHmlbaRRlVvzLbpL5tn90ojg01ROgeHCYoajHMnjdCn4ARdBPHoyoqpE2 gNdBbwTge5vbSdIvMSScxSRpF/sgrOqZ2Ejqe/jOHx9ztl3Ub5cE5P5OwbXtCRs6j58eF2lt8eV NJ5ggn+/uYoXjitkBrr7vndidPp4myiQxm6Wzc6CFp4xOLMje69XpIC4H1yvkod3Ns5jpL16kdI VU1EdqblFgSuDlGF71Bnp5pEebWP7ccNbUKeO9Q5U X-Google-Smtp-Source: AGHT+IHIWe95ox3zt/ZzG1SW9KG/4OtiRl2M/Zxq8XMDH7/fn4wU67Qk37R3LtB/fXEZes0qT3Tkkw== X-Received: by 2002:a17:902:ce83:b0:227:ac2a:2472 with SMTP id d9443c01a7336-22fc8c83d38mr230587205ad.28.1747094782102; Mon, 12 May 2025 17:06:22 -0700 (PDT) Received: from localhost.localdomain (c-67-160-120-253.hsd1.wa.comcast.net. [67.160.120.253]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22fc828b491sm68470665ad.184.2025.05.12.17.06.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 May 2025 17:06:21 -0700 (PDT) From: mhkelley58@gmail.com X-Google-Original-From: mhklinux@outlook.com To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net 1/5] Drivers: hv: Allow vmbus_sendpacket_mpb_desc() to create multiple ranges Date: Mon, 12 May 2025 17:06:00 -0700 Message-Id: <20250513000604.1396-2-mhklinux@outlook.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250513000604.1396-1-mhklinux@outlook.com> References: <20250513000604.1396-1-mhklinux@outlook.com> Reply-To: mhklinux@outlook.com Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Michael Kelley vmbus_sendpacket_mpb_desc() is currently used only by the storvsc driver and is hardcoded to create a single GPA range. To allow it to also be used by the netvsc driver to create multiple GPA ranges, no longer hardcode as having a single GPA range. Allow the calling driver to specify the rangecount in the supplied descriptor. Update the storvsc driver to reflect this new approach. Cc: # 6.1.x Signed-off-by: Michael Kelley --- drivers/hv/channel.c | 6 +++--- drivers/scsi/storvsc_drv.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c index fb8cd8469328..4ffd5eaa7817 100644 --- a/drivers/hv/channel.c +++ b/drivers/hv/channel.c @@ -1136,9 +1136,10 @@ int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel, EXPORT_SYMBOL_GPL(vmbus_sendpacket_pagebuffer); /* - * vmbus_sendpacket_multipagebuffer - Send a multi-page buffer packet + * vmbus_sendpacket_mpb_desc - Send one or more multi-page buffer packets * using a GPADL Direct packet type. - * The buffer includes the vmbus descriptor. + * The desc argument must include space for the VMBus descriptor. The + * rangecount field must already be set. */ int vmbus_sendpacket_mpb_desc(struct vmbus_channel *channel, struct vmbus_packet_mpb_array *desc, @@ -1160,7 +1161,6 @@ int vmbus_sendpacket_mpb_desc(struct vmbus_channel *channel, desc->length8 = (u16)(packetlen_aligned >> 3); desc->transactionid = VMBUS_RQST_ERROR; /* will be updated in hv_ringbuffer_write() */ desc->reserved = 0; - desc->rangecount = 1; bufferlist[0].iov_base = desc; bufferlist[0].iov_len = desc_size; diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 35db061ae3ec..2e6b2412d2c9 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -1819,6 +1819,7 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd) return SCSI_MLQUEUE_DEVICE_BUSY; } + payload->rangecount = 1; payload->range.len = length; payload->range.offset = offset_in_hvpg; From patchwork Tue May 13 00:06:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mhkelley58@gmail.com X-Patchwork-Id: 890836 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D492628F3; Tue, 13 May 2025 00:06:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747094785; cv=none; b=twCqwatI0M/VfHs4OEuxQAJ8K8JZ6Oof36AcEec6M99ZedH3pfXCYyv0EWDa0IMEgFeSwvtx+WERhOVok4Ceu0XtN+qGuiAPeCjBB3hSLphBfQNpu/wPV4cAwkSTe2rZg3EnGpLrxvL4SUPfLc5yd8JdKFXr1+2qDBgxbZQCH3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747094785; c=relaxed/simple; bh=8/xVulW2CSRK1+XsSobzHokLcQO2lTn+ZWudBCT/UHg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BDoaqV3tnWlo0kVeiQy69W3LX7eeDwxrFQI/zjCI/9qd3JVutx19nGl2uSkQegY+xSqj2qNwx8Az/so3bFhGI32QD84bAWwdk3kaDqBu7mBpin6Ipu0+e+RGPEt/XN8BUXlaTYYUqecL1ZVDO6DjjqVGufyrr2KnMyjxFA9BYug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HpL1VPWO; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HpL1VPWO" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-22c33e4fdb8so43109895ad.2; Mon, 12 May 2025 17:06:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747094783; x=1747699583; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=FXCvU2Vs7s7mGjO2bzsEOujhMs8/vRhZqhlIuLlVupA=; b=HpL1VPWOJdw8g8GUaauvwRP18hIw4UO1VIG9TxegZTRzmzNRtkbrMmMM4lJaV6MbRF YRXaEn/eW5ZjdzpisSU2FkTCpq+Nsr4tlh955iI1J8Br0JLvSMWdPVMjg8gJwc6a4J3S UsAJW4a/xVAIgzWD+UMT26veKm3MbzYMpgsBDC1qlP69gDD1+a4JWHCkjcr3pUPKqKH+ sp9Pd+Clq2ruHCWUwF0iYOb321KKj+AbP+HGGI8Bv9Um2ufew05EIb78HZ0z7U9fn6NC wKlcq6pmsYX3KS7TotU1j2LqifWfEd0YguSu1pkE7oykXtnHPDxA6roFC+7kNA+dDwhw +6Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747094783; x=1747699583; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=FXCvU2Vs7s7mGjO2bzsEOujhMs8/vRhZqhlIuLlVupA=; b=CsfY1HMZHSVzMrUzx3Apb5Eo+7+DVtHkgGWe87Qsx8lCTILdVnxvykuf5nM7uhernb iFgo4UiO3gDjVNvCAUYujXpkDqQEbYmbdWwXx22oq5B9JCHFQLxQvgZ1JqmsRaUIeaE2 Vn+MasGUYjfUMUeGBqJS491Qc1gpDmCk6UWf5mOUWu7rlOIk5M7fIN4d3pThqLYazhEB hTPYUqe2VGKxdJ+HPzb8oqjSxv/aQ3YFO5NzceixHwyA1KHLL1DZh9hZ6/G786M3eoJr ZT7i6c5PPvtro6qg5827f2Bvog2uJB7kz4kk9mEd3GWGoSQ6qaojqdJEwE74nGlKieSs OMoA== X-Forwarded-Encrypted: i=1; AJvYcCULnwTw1iaFVAHarT70A3vjMB/SS4gm78C1eZ9zJjrcWbWTu+HC9ixZhxTqZvCauvpEhHfpekHCks2cwMA=@vger.kernel.org, AJvYcCUT9IoK61b+d8Y6P83X56qUn41Ttg8CTTqseNP1KRZ2PV89+/smN0/vMkbKydrD0k9auZmgYEvD@vger.kernel.org, AJvYcCUrHiiLdlVorzZBg7i/Zivd9S9/8KS4oreqmTW2VTEYfzoT+5zWMdxClsyz57nz9uxUVrxwBQfT@vger.kernel.org, AJvYcCWeQX4g/M5O1qEKDBf3lYs5B/C7XDDybRugLF01W0rOneMm9bQFok/jbEWe8MWqgUObYixZ0yFvo0XOog==@vger.kernel.org X-Gm-Message-State: AOJu0Yy2fcA5t5N1Uq0MZVPqaXzAKAAZxJL7avPj8nuAIKO6G0QdUbeQ aI/PwgnwfQ6ZyMoHEEjGHdiUDPW6RVLN8Uvgk6rm3OQZvFlDtFNR X-Gm-Gg: ASbGnctsfLAt4EVF8pTSYlPJw2Zpyc850clLW2v/55bImxlgYeeUQqlU436/RZiL/dP +oPhW2UnFStJfE9n46CX8xPLyday5uvFlpWI2orTpTqbRXxA1vktunIJXrnc9Iknz1oqCAJvMC7 eBowNpHqxOSNS3uM+IPGzecIcgehPpcV48Sdz9S4yA+h9HNwtMe8hQboqEdhSA1IvKdlNEQxCVV y+ATzwJ6LlVV/7EdXTx2cYWvsnMkZFrfaKtvrmlxMNhkIiHqjEvAzwLwUoJbCphjBi/Ozgr/Zzl GLRNIRyinyaFp8WTDNCNb6+mdIifKngN8F/4cbhwYfscANPRavuHoLm6oh3cgoEvQ71tDdcc3Ga herLXRv4KKae1woepsKumH9UzjoKhZw== X-Google-Smtp-Source: AGHT+IFziuIqABFOvhkhgN/xuoHGmIstOjH0r6ljTVAroISwtMFpsIg6e5wHjzk4TIlhWturAbynGA== X-Received: by 2002:a17:902:f70b:b0:224:1af1:87ed with SMTP id d9443c01a7336-22fc8b7bddfmr203927655ad.27.1747094783134; Mon, 12 May 2025 17:06:23 -0700 (PDT) Received: from localhost.localdomain (c-67-160-120-253.hsd1.wa.comcast.net. [67.160.120.253]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22fc828b491sm68470665ad.184.2025.05.12.17.06.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 May 2025 17:06:22 -0700 (PDT) From: mhkelley58@gmail.com X-Google-Original-From: mhklinux@outlook.com To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net 2/5] hv_netvsc: Use vmbus_sendpacket_mpb_desc() to send VMBus messages Date: Mon, 12 May 2025 17:06:01 -0700 Message-Id: <20250513000604.1396-3-mhklinux@outlook.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250513000604.1396-1-mhklinux@outlook.com> References: <20250513000604.1396-1-mhklinux@outlook.com> Reply-To: mhklinux@outlook.com Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Michael Kelley netvsc currently uses vmbus_sendpacket_pagebuffer() to send VMBus messages. This function creates a series of GPA ranges, each of which contains a single PFN. However, if the rndis header in the VMBus message crosses a page boundary, the netvsc protocol with the host requires that both PFNs for the rndis header must be in a single "GPA range" data structure, which isn't possible with vmbus_sendpacket_pagebuffer(). As the first step in fixing this, add a new function netvsc_build_mpb_array() to build a VMBus message with multiple GPA ranges, each of which may contain multiple PFNs. Use vmbus_sendpacket_mpb_desc() to send this VMBus message to the host. There's no functional change since higher levels of netvsc don't maintain or propagate knowledge of contiguous PFNs. Based on its input, netvsc_build_mpb_array() still produces a separate GPA range for each PFN and the behavior is the same as with vmbus_sendpacket_pagebuffer(). But the groundwork is laid for a subsequent patch to provide the necessary grouping. Cc: # 6.1.x Signed-off-by: Michael Kelley --- drivers/net/hyperv/netvsc.c | 50 +++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index d6f5b9ea3109..6d1705f87682 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -1055,6 +1055,42 @@ static int netvsc_dma_map(struct hv_device *hv_dev, return 0; } +/* Build an "array" of mpb entries describing the data to be transferred + * over VMBus. After the desc header fields, each "array" entry is variable + * size, and each entry starts after the end of the previous entry. The + * "offset" and "len" fields for each entry imply the size of the entry. + * + * The pfns are in HV_HYP_PAGE_SIZE, because all communication with Hyper-V + * uses that granularity, even if the system page size of the guest is larger. + * Each entry in the input "pb" array must describe a contiguous range of + * guest physical memory so that the pfns are sequential if the range crosses + * a page boundary. The offset field must be < HV_HYP_PAGE_SIZE. + */ +static inline void netvsc_build_mpb_array(struct hv_page_buffer *pb, + u32 page_buffer_count, + struct vmbus_packet_mpb_array *desc, + u32 *desc_size) +{ + struct hv_mpb_array *mpb_entry = &desc->range; + int i, j; + + for (i = 0; i < page_buffer_count; i++) { + u32 offset = pb[i].offset; + u32 len = pb[i].len; + + mpb_entry->offset = offset; + mpb_entry->len = len; + + for (j = 0; j < HVPFN_UP(offset + len); j++) + mpb_entry->pfn_array[j] = pb[i].pfn + j; + + mpb_entry = (struct hv_mpb_array *)&mpb_entry->pfn_array[j]; + } + + desc->rangecount = page_buffer_count; + *desc_size = (char *)mpb_entry - (char *)desc; +} + static inline int netvsc_send_pkt( struct hv_device *device, struct hv_netvsc_packet *packet, @@ -1097,6 +1133,9 @@ static inline int netvsc_send_pkt( packet->dma_range = NULL; if (packet->page_buf_cnt) { + struct vmbus_channel_packet_page_buffer desc; + u32 desc_size; + if (packet->cp_partial) pb += packet->rmsg_pgcnt; @@ -1106,11 +1145,12 @@ static inline int netvsc_send_pkt( goto exit; } - ret = vmbus_sendpacket_pagebuffer(out_channel, - pb, packet->page_buf_cnt, - &nvmsg, sizeof(nvmsg), - req_id); - + netvsc_build_mpb_array(pb, packet->page_buf_cnt, + (struct vmbus_packet_mpb_array *)&desc, + &desc_size); + ret = vmbus_sendpacket_mpb_desc(out_channel, + (struct vmbus_packet_mpb_array *)&desc, + desc_size, &nvmsg, sizeof(nvmsg), req_id); if (ret) netvsc_dma_unmap(ndev_ctx->device_ctx, packet); } else { From patchwork Tue May 13 00:06:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mhkelley58@gmail.com X-Patchwork-Id: 889601 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43DE78F58; Tue, 13 May 2025 00:06:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747094787; cv=none; b=L58J1LyaJPev2pS5ELgFbhekaEE5lJlMZgsU/vh85cLWaq8yEmM7pc+W8lEmcxZrWyj/RQHhHJ1HoEaVdkAHm5rROaM4EwmhzuZ3AmPBLqAkTUWmGomZEYXuuaZenx/I+Q8WzofnN2e3YeC9BU9WroOre/Mcmt4RXPCITO9zlH8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747094787; c=relaxed/simple; bh=vZfS0plRbyqQQIcbaNY4ymvGlAp3r4D8TzDQwLuOOLg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DyRAJybRkdtHZ1PxSwcvB5qww3X5orsNahgTzR9rmzbUqC0yIAKPhL7a+w8OEHlAZ/VTtJs54thQ28/Sb8qlIcozjzrwCsxMUcyVFInmECTYqRQTCoVS+gkCogKhUCicHfo3bCoRmgBURkTEFQlFYH2N1JB1/CShdwUR5RTwkgc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TqfnYomk; arc=none smtp.client-ip=209.85.215.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TqfnYomk" Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-b2093aef78dso5019827a12.0; Mon, 12 May 2025 17:06:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747094784; x=1747699584; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=swNi1/At9M9lQUHOHslqUPRL9lajtucPO8KagwNe5wo=; b=TqfnYomk0xcnv5ODlZvA3Ffdd6fbfs0sZPwui6n0rP3QDmGmoF2QhfjxuU2T0zfHNB Ix4xGaGeQY4K2dLh5lwtle8E9kfRUqjw4X49Qld3clPhN8Z4+d3SMsrOzHoqVnh0Bv22 inlptGX+53wR4fQ/8sSuwK5lA3s7UkM8CY1nIbDGH655xUg38BytZYlkuWsl5FKhxYNN A8fV7n42LjVAWbSPWZztEgK5uYc4S6TIpeumuMTt+vX/Ff9FlSkB45ScGlm1Dq529RdT kHO8Qb4YriAnljGasRtEs0dR0wKysPaGWBMBedULDZ3W4KRKJi4JXvSig0Kt9lUoXXQ5 F32Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747094784; x=1747699584; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=swNi1/At9M9lQUHOHslqUPRL9lajtucPO8KagwNe5wo=; b=jfxyCwC0Ev529IMP73/0aHwT+n+MyLD7YPEs+OvsuhXGOp12wYyn9PwttNUIGah8mW 1O79lT1vP9SiuIx623+O2+5fh937IIxGuzSvRywHNpiSL6/jyNdZQEJG26iwy9fFNj9j bjB+F486S/ZfNc9D4Pfgu+fq/Gz3eCdkIYORxiwKJOeGAZR2i3qMQ/ol1duHj4aFogJm vYXtqCO+ZqwPOCK5SgWgFuo1lx3XlNhd4gJqoccVeFGRwXdmbWvxqSMKLxvNZ3SxwJVm /QRSMt8Clqeo7Ay3sW/lnuaOV0LMMvilDN9LSHR5yUQkLFLBAW8xgb+hj+QdknjyhtcZ lHZw== X-Forwarded-Encrypted: i=1; AJvYcCU3Aln2y58E3PguTcDu+0bb+Jaxze6IBvep/pppcRntVLDTr7995kmLeFKKFZK6gjB2yNkHK1EmuL53Nlk=@vger.kernel.org, AJvYcCVYoxHwD9A+5BbXLPFScLOyuINmrYAIb0muZ9fIYtnQzRLsjLID8rZalxI64MqZ04Sm9xSYeZet@vger.kernel.org, AJvYcCVvMzAbgeGvxukhoVars3UM4NtgDuD/tbqAbQZ+SdpvcSnx1bavWIc1CCAoiStzGbIQL7fGUcj2@vger.kernel.org, AJvYcCXaI8HbU8COXi2gFTvnZiLetV066/OaZZf9FNuVr0XxdgOd4bBoXEjJKJIY5qUr5aajJV79UgVtldW51A==@vger.kernel.org X-Gm-Message-State: AOJu0Yy4hCTm5XCgk87crVE3bjdYptlUUlxQJuoKfnvZrtpVXBTpAt0W dyWTokRll/bVuPVS7sOg33vbMBD4fu28zdMet7t5ug69/8ex533x X-Gm-Gg: ASbGnct+SyFakKXLedOKLqWexJ8QqQhWPQbgci6jZd2WA3TggzH3UT3hWULDrb62AfU E7LTfef7rK6ibIrescl6KiF6SuHYsVRpKlCt6rZ1udpYDJPkC7i0gdOQfEhudf1AAeDsyWVeNC1 uwEYRxEoCDRCoe8vcSkIJ0JcjGgfPR6fWywyooLZKJsXSCTYP3oQN8obx8ao43ovE3rmvIKCLSL bZABVXoMMO6axrGUID3s+aLBEOhtg2BfyFkpHpR19kc5FRjPbDynzx90jVrQL5k3PJiQCxEkiZp gLnWoqYZdKBtFpAxwAoBEwddAa/anUUwIYxpho7DrSN+JMj/70XuG3RheymiCTLdVxYHTFhxqk3 rTQQtKbIY4NQgOAs2otc6i9T2RWAtBdIkWs9m/zvH X-Google-Smtp-Source: AGHT+IGygUT5aBPmu8NtYjKXJ3844FFa6d/oNU1vUY9zpQwVV+VqCV/8ZJq4SXeGrG+0EV2XtDTspQ== X-Received: by 2002:a17:902:e54f:b0:22e:3b65:9286 with SMTP id d9443c01a7336-22fc91a84edmr234399455ad.49.1747094784178; Mon, 12 May 2025 17:06:24 -0700 (PDT) Received: from localhost.localdomain (c-67-160-120-253.hsd1.wa.comcast.net. [67.160.120.253]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22fc828b491sm68470665ad.184.2025.05.12.17.06.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 May 2025 17:06:23 -0700 (PDT) From: mhkelley58@gmail.com X-Google-Original-From: mhklinux@outlook.com To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net 3/5] hv_netvsc: Preserve contiguous PFN grouping in the page buffer array Date: Mon, 12 May 2025 17:06:02 -0700 Message-Id: <20250513000604.1396-4-mhklinux@outlook.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250513000604.1396-1-mhklinux@outlook.com> References: <20250513000604.1396-1-mhklinux@outlook.com> Reply-To: mhklinux@outlook.com Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Michael Kelley Starting with commit dca5161f9bd0 ("hv_netvsc: Check status in SEND_RNDIS_PKT completion message") in the 6.3 kernel, the Linux driver for Hyper-V synthetic networking (netvsc) occasionally reports "nvsp_rndis_pkt_complete error status: 2".[1] This error indicates that Hyper-V has rejected a network packet transmit request from the guest, and the outgoing network packet is dropped. Higher level network protocols presumably recover and resend the packet so there is no functional error, but performance is slightly impacted. Commit dca5161f9bd0 is not the cause of the error -- it only added reporting of an error that was already happening without any notice. The error has presumably been present since the netvsc driver was originally introduced into Linux. The root cause of the problem is that the netvsc driver in Linux may send an incorrectly formatted VMBus message to Hyper-V when transmitting the network packet. The incorrect formatting occurs when the rndis header of the VMBus message crosses a page boundary due to how the Linux skb head memory is aligned. In such a case, two PFNs are required to describe the location of the rndis header, even though they are contiguous in guest physical address (GPA) space. Hyper-V requires that two rndis header PFNs be in a single "GPA range" data struture, but current netvsc code puts each PFN in its own GPA range, which Hyper-V rejects as an error. The incorrect formatting occurs only for larger packets that netvsc must transmit via a VMBus "GPA Direct" message. There's no problem when netvsc transmits a smaller packet by copying it into a pre- allocated send buffer slot because the pre-allocated slots don't have page crossing issues. After commit 14ad6ed30a10 ("net: allow small head cache usage with large MAX_SKB_FRAGS values") in the 6.14-rc4 kernel, the error occurs much more frequently in VMs with 16 or more vCPUs. It may occur every few seconds, or even more frequently, in an ssh session that outputs a lot of text. Commit 14ad6ed30a10 subtly changes how skb head memory is allocated, making it much more likely that the rndis header will cross a page boundary when the vCPU count is 16 or more. The changes in commit 14ad6ed30a10 are perfectly valid -- they just had the side effect of making the netvsc bug more prominent. Current code in init_page_array() creates a separate page buffer array entry for each PFN required to identify the data to be transmitted. Contiguous PFNs get separate entries in the page buffer array, and any information about contiguity is lost. Fix the core issue by having init_page_array() construct the page buffer array to represent contiguous ranges rather than individual pages. When these ranges are subsequently passed to netvsc_build_mpb_array(), it can build GPA ranges that contain multiple PFNs, as required to avoid the error "nvsp_rndis_pkt_complete error status: 2". If instead the network packet is sent by copying into a pre-allocated send buffer slot, the copy proceeds using the contiguous ranges rather than individual pages, but the result of the copying is the same. Also fix rndis_filter_send_request() to construct a contiguous range, since it has its own page buffer array. This change has a side benefit in CoCo VMs in that netvsc_dma_map() calls dma_map_single() on each contiguous range instead of on each page. This results in fewer calls to dma_map_single() but on larger chunks of memory, which should reduce contention on the swiotlb. Since the page buffer array now contains one entry for each contiguous range instead of for each individual page, the number of entries in the array can be reduced, saving 208 bytes of stack space in netvsc_xmit() when MAX_SKG_FRAGS has the default value of 17. [1] https://bugzilla.kernel.org/show_bug.cgi?id=217503 Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217503 Cc: # 6.1.x Signed-off-by: Michael Kelley Reviewed-by: Simon Horman --- drivers/net/hyperv/hyperv_net.h | 12 ++++++ drivers/net/hyperv/netvsc_drv.c | 63 ++++++++----------------------- drivers/net/hyperv/rndis_filter.c | 24 +++--------- 3 files changed, 32 insertions(+), 67 deletions(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index 70f7cb383228..76725f25abd5 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -893,6 +893,18 @@ struct nvsp_message { sizeof(struct nvsp_message)) #define NETVSC_MIN_IN_MSG_SIZE sizeof(struct vmpacket_descriptor) +/* Maximum # of contiguous data ranges that can make up a trasmitted packet. + * Typically it's the max SKB fragments plus 2 for the rndis packet and the + * linear portion of the SKB. But if MAX_SKB_FRAGS is large, the value may + * need to be limited to MAX_PAGE_BUFFER_COUNT, which is the max # of entries + * in a GPA direct packet sent to netvsp over VMBus. + */ +#if MAX_SKB_FRAGS + 2 < MAX_PAGE_BUFFER_COUNT +#define MAX_DATA_RANGES (MAX_SKB_FRAGS + 2) +#else +#define MAX_DATA_RANGES MAX_PAGE_BUFFER_COUNT +#endif + /* Estimated requestor size: * out_ring_size/min_out_msg_size + in_ring_size/min_in_msg_size */ diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index c51b318b8a72..929f6b3de768 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -326,43 +326,10 @@ static u16 netvsc_select_queue(struct net_device *ndev, struct sk_buff *skb, return txq; } -static u32 fill_pg_buf(unsigned long hvpfn, u32 offset, u32 len, - struct hv_page_buffer *pb) -{ - int j = 0; - - hvpfn += offset >> HV_HYP_PAGE_SHIFT; - offset = offset & ~HV_HYP_PAGE_MASK; - - while (len > 0) { - unsigned long bytes; - - bytes = HV_HYP_PAGE_SIZE - offset; - if (bytes > len) - bytes = len; - pb[j].pfn = hvpfn; - pb[j].offset = offset; - pb[j].len = bytes; - - offset += bytes; - len -= bytes; - - if (offset == HV_HYP_PAGE_SIZE && len) { - hvpfn++; - offset = 0; - j++; - } - } - - return j + 1; -} - static u32 init_page_array(void *hdr, u32 len, struct sk_buff *skb, struct hv_netvsc_packet *packet, struct hv_page_buffer *pb) { - u32 slots_used = 0; - char *data = skb->data; int frags = skb_shinfo(skb)->nr_frags; int i; @@ -371,28 +338,28 @@ static u32 init_page_array(void *hdr, u32 len, struct sk_buff *skb, * 2. skb linear data * 3. skb fragment data */ - slots_used += fill_pg_buf(virt_to_hvpfn(hdr), - offset_in_hvpage(hdr), - len, - &pb[slots_used]); + pb[0].offset = offset_in_hvpage(hdr); + pb[0].len = len; + pb[0].pfn = virt_to_hvpfn(hdr); packet->rmsg_size = len; - packet->rmsg_pgcnt = slots_used; + packet->rmsg_pgcnt = 1; - slots_used += fill_pg_buf(virt_to_hvpfn(data), - offset_in_hvpage(data), - skb_headlen(skb), - &pb[slots_used]); + pb[1].offset = offset_in_hvpage(skb->data); + pb[1].len = skb_headlen(skb); + pb[1].pfn = virt_to_hvpfn(skb->data); for (i = 0; i < frags; i++) { skb_frag_t *frag = skb_shinfo(skb)->frags + i; + struct hv_page_buffer *cur_pb = &pb[i + 2]; + u64 pfn = page_to_hvpfn(skb_frag_page(frag)); + u32 offset = skb_frag_off(frag); - slots_used += fill_pg_buf(page_to_hvpfn(skb_frag_page(frag)), - skb_frag_off(frag), - skb_frag_size(frag), - &pb[slots_used]); + cur_pb->offset = offset_in_hvpage(offset); + cur_pb->len = skb_frag_size(frag); + cur_pb->pfn = pfn + (offset >> HV_HYP_PAGE_SHIFT); } - return slots_used; + return frags + 2; } static int count_skb_frag_slots(struct sk_buff *skb) @@ -483,7 +450,7 @@ static int netvsc_xmit(struct sk_buff *skb, struct net_device *net, bool xdp_tx) struct net_device *vf_netdev; u32 rndis_msg_size; u32 hash; - struct hv_page_buffer pb[MAX_PAGE_BUFFER_COUNT]; + struct hv_page_buffer pb[MAX_DATA_RANGES]; /* If VF is present and up then redirect packets to it. * Skip the VF if it is marked down or has no carrier. diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index 82747dfacd70..9e73959e61ee 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -225,8 +225,7 @@ static int rndis_filter_send_request(struct rndis_device *dev, struct rndis_request *req) { struct hv_netvsc_packet *packet; - struct hv_page_buffer page_buf[2]; - struct hv_page_buffer *pb = page_buf; + struct hv_page_buffer pb; int ret; /* Setup the packet to send it */ @@ -235,27 +234,14 @@ static int rndis_filter_send_request(struct rndis_device *dev, packet->total_data_buflen = req->request_msg.msg_len; packet->page_buf_cnt = 1; - pb[0].pfn = virt_to_phys(&req->request_msg) >> - HV_HYP_PAGE_SHIFT; - pb[0].len = req->request_msg.msg_len; - pb[0].offset = offset_in_hvpage(&req->request_msg); - - /* Add one page_buf when request_msg crossing page boundary */ - if (pb[0].offset + pb[0].len > HV_HYP_PAGE_SIZE) { - packet->page_buf_cnt++; - pb[0].len = HV_HYP_PAGE_SIZE - - pb[0].offset; - pb[1].pfn = virt_to_phys((void *)&req->request_msg - + pb[0].len) >> HV_HYP_PAGE_SHIFT; - pb[1].offset = 0; - pb[1].len = req->request_msg.msg_len - - pb[0].len; - } + pb.pfn = virt_to_phys(&req->request_msg) >> HV_HYP_PAGE_SHIFT; + pb.len = req->request_msg.msg_len; + pb.offset = offset_in_hvpage(&req->request_msg); trace_rndis_send(dev->ndev, 0, &req->request_msg); rcu_read_lock_bh(); - ret = netvsc_send(dev->ndev, packet, NULL, pb, NULL, false); + ret = netvsc_send(dev->ndev, packet, NULL, &pb, NULL, false); rcu_read_unlock_bh(); return ret; From patchwork Tue May 13 00:06:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mhkelley58@gmail.com X-Patchwork-Id: 890835 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 248271CD0C; Tue, 13 May 2025 00:06:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747094787; cv=none; b=m9Pf3F4qEYZNHzief8r6zJma/2O1nAoL2eXFqTNzkh/iP2NTjZ3c8vew4mOEbs4O9h14sKQQwcUNed7E0KRVSuOb8JqGqhVoVsYaE0J084RWqtA1a+NF0NG7W2AxqJGBd2sNr6ZJ3VtEbsY6oxfI78qNKKdGQJpFCfjqxL8OJYM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747094787; c=relaxed/simple; bh=VmgqKKYqwuDqT8GL2s3Gll3zTEUf6vjQUTkvOgII1zU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=knKzlHEu7YahoOdij3r/U0dIZwD687i8CmR3TGFwP2qc/NY+YUiMCciQRtpL2/4vKdYZyyaXP6yOEOe2DfV7wptPqDeouW8vB8Hp58toXyFBpPHdgu/sJS350vpTDfOrC12MBLwrq+ppv8zUX9S2M5SvZtE07eDGN7ppnrbHVd0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OwtEr5YB; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OwtEr5YB" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-22e730c05ddso45739205ad.2; Mon, 12 May 2025 17:06:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747094785; x=1747699585; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=1/dEAWJwnzGJroYQuZwyw96GLa+9EYPpLfplVYwHAUM=; b=OwtEr5YBtvfQ5UO7HDD5B7cJcOKxkBSTpi/P5d48HdE/WiMltx7KG9huaWzCCIiWi9 aaZGf9SCcBVba3JJOWGa9n8x20sFur3DXVwqLhpE3ht9P2PnJP0Pgll3Ix71SZ2/2Em2 X5YV1BMw04xGunsVMyUav+xp1Bx1w3pDJuKg8zouS/Nadl9JUlpRlk819sv7RkPaKy8o RKEPVaiUvk23Ky/xTaNNSIKRz+G4TvMhVtfUMm157Bsp9KaluqBkha0Hq2zcMVjSa35W IffQPvWEn2WOpwrnWIkD5IgHyL5I8bMMO3JnNT+TTJ/L8sYud9wSJOPRUztuCGmmvlF3 MtrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747094785; x=1747699585; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=1/dEAWJwnzGJroYQuZwyw96GLa+9EYPpLfplVYwHAUM=; b=RpzqKzwCiY9mnrwENCxgrsH6tlKJnHzltpzOc8xL2QJ1V3HAFVF0fhWRtTXDdfrBPq CEWYNG714zmygBKK5I9w4vAFOKDspRcoFk4W5boVMG5ZGt375DEh7HDIuGGvzod2n20d mWJALf6mSDzCf+gvSGuQlRteyJpNllyzwwR2odRgCWNu22ve7XgYdNHBpoEEz026WS2F 85Wc4HNaR0NCvgXyjj0Qst+S82RzjilQK01Wisal/1mQVYYuEElhhlGKx/ut+ycIicND LO2O40hUXMB7rcLWmvmDhgPvHuBmC17IqF6nZz8Rhm33lnZ13meLK83ksNdl9GnPONEB /X3w== X-Forwarded-Encrypted: i=1; AJvYcCWJhlVfeFhCY+k4Ujm8TvO1mZ+0YP/ZlkPBNGTdOcfAtZDGPBceY6bySG3Z3ehAeiLo+K2460XTmD/PFnM=@vger.kernel.org, AJvYcCXDx1OtZuuDNLSia3RXySMphQArP6fBCo0UsdJAShuTyW0PB5GncneCaDbL4KW6ScF0wXszGZtm@vger.kernel.org, AJvYcCXZ/bBp6lEKF8ptwq8GCjsvCJT/kzCZbv34OdRK7F6GI/4DTxFCMF8RdfpNSAcablC7tMnrJk+9@vger.kernel.org, AJvYcCXpnevbKY8y+dkuUv1Iw6a8+TiqzE3Yw4iLlNEFRh2jPKChgRv140b5TWjAlxRt3uLsk8fchiZw1483Dg==@vger.kernel.org X-Gm-Message-State: AOJu0YzGKBNO24nm5E0h1pauQzo3/zzT1SDB3m+Xn4Vpw26MhwYtdoZl 6wwrskd10MofWRlyZq/tJ0T1OLGobCLJY3ebsQ7nIHJJ90v+McuM X-Gm-Gg: ASbGncvXmJ/GPWkuyQe3+lNNv5olepJ654x7Ts5WULlX1KmSTFJSPVfgF9UjE84ve81 OqLFDJeXFzpUxaajpu6W8+DGlO6nQcCKQ9K9JKiJuaVQCFoHd5TKOPCOBcL8LlZ/GAEsqJtrlh5 s9U1DkZhtzday+RxjPSItgxgnnBRKzXfjMoHsdOjxzp+6abztQaM7RLK4iYz1TANxwTKpiL7guh cwdr8FlkqfcCpLVtHtsY4CPKLTIprx69bmf+ltEK14yGMhp0B6q30Ffz4waGFOPTTgZ/sG63IRH ecpiayXVrfNzpc/dBkTagtU341uwc7C3sqrmcFLX2/FXNnknfAV5+cW/UNydCtPk/whOP+BADps cmYvPRYwNtGxqE+77LPOO+DSSE3VuKg== X-Google-Smtp-Source: AGHT+IHTotbGNpWEp+9dh8Q2BnZLuywz176C9RGAHPZaKRManN25KNn7wGf4VUMAP5Icy6sXzPhtbw== X-Received: by 2002:a17:903:988:b0:22e:5abd:7133 with SMTP id d9443c01a7336-22fc917f836mr191850515ad.45.1747094785305; Mon, 12 May 2025 17:06:25 -0700 (PDT) Received: from localhost.localdomain (c-67-160-120-253.hsd1.wa.comcast.net. [67.160.120.253]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22fc828b491sm68470665ad.184.2025.05.12.17.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 May 2025 17:06:25 -0700 (PDT) From: mhkelley58@gmail.com X-Google-Original-From: mhklinux@outlook.com To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net 4/5] hv_netvsc: Remove rmsg_pgcnt Date: Mon, 12 May 2025 17:06:03 -0700 Message-Id: <20250513000604.1396-5-mhklinux@outlook.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250513000604.1396-1-mhklinux@outlook.com> References: <20250513000604.1396-1-mhklinux@outlook.com> Reply-To: mhklinux@outlook.com Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Michael Kelley init_page_array() now always creates a single page buffer array entry for the rndis message, even if the rndis message crosses a page boundary. As such, the number of page buffer array entries used for the rndis message must no longer be tracked -- it is always just 1. Remove the rmsg_pgcnt field and use "1" where the value is needed. Cc: # 6.1.x Signed-off-by: Michael Kelley --- drivers/net/hyperv/hyperv_net.h | 1 - drivers/net/hyperv/netvsc.c | 7 +++---- drivers/net/hyperv/netvsc_drv.c | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index 76725f25abd5..cb6f5482d203 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -158,7 +158,6 @@ struct hv_netvsc_packet { u8 cp_partial; /* partial copy into send buffer */ u8 rmsg_size; /* RNDIS header and PPI size */ - u8 rmsg_pgcnt; /* page count of RNDIS header and PPI */ u8 page_buf_cnt; u16 q_idx; diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 6d1705f87682..41661d5c61ab 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -953,8 +953,7 @@ static void netvsc_copy_to_send_buf(struct netvsc_device *net_device, + pend_size; int i; u32 padding = 0; - u32 page_count = packet->cp_partial ? packet->rmsg_pgcnt : - packet->page_buf_cnt; + u32 page_count = packet->cp_partial ? 1 : packet->page_buf_cnt; u32 remain; /* Add padding */ @@ -1137,7 +1136,7 @@ static inline int netvsc_send_pkt( u32 desc_size; if (packet->cp_partial) - pb += packet->rmsg_pgcnt; + pb++; ret = netvsc_dma_map(ndev_ctx->device_ctx, packet, pb); if (ret) { @@ -1299,7 +1298,7 @@ int netvsc_send(struct net_device *ndev, packet->send_buf_index = section_index; if (packet->cp_partial) { - packet->page_buf_cnt -= packet->rmsg_pgcnt; + packet->page_buf_cnt--; packet->total_data_buflen = msd_len + packet->rmsg_size; } else { packet->page_buf_cnt = 0; diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 929f6b3de768..d8b169ac0343 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -343,7 +343,6 @@ static u32 init_page_array(void *hdr, u32 len, struct sk_buff *skb, pb[0].len = len; pb[0].pfn = virt_to_hvpfn(hdr); packet->rmsg_size = len; - packet->rmsg_pgcnt = 1; pb[1].offset = offset_in_hvpage(skb->data); pb[1].len = skb_headlen(skb); From patchwork Tue May 13 00:06:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mhkelley58@gmail.com X-Patchwork-Id: 889600 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3776632C8B; Tue, 13 May 2025 00:06:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747094788; cv=none; b=XFd4rjZF3NNaJn7H0XfwkFdHUPnJarYZlW9hvuiNNnJuUpCojlZIH64ACPndR551/IrYzM5R5e3YMlyez0JUY05bsI4DRVyKVmof3ihH6Mr00s5j+TopxbWPguTCB3Ibzm0yb6Km1fpHiWBrIj0PNxmO/+yaC4HsMmK6Zd0ea7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747094788; c=relaxed/simple; bh=/3/6voPULjYvpgG6Nnc+zAtZr66zlGPAla6ugxce3l4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=e5N99biuNJy4YJlrnolLY1f4FR+mahvrlXpyKe0bVxS67vjgVhomcNnrdi7xWmbmVgIXZGnzyq7qPzKNMy9LGh/D00wlTTMKjNf0rN7PxV8r4i5Zqg9ORDIn/9SzfpthTsnJr/ECpMXt3auSzyvMevCl5k9Tb6rx5APE83OXRGw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Fg7peFFw; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Fg7peFFw" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-22e16234307so53407175ad.0; Mon, 12 May 2025 17:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747094786; x=1747699586; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=nB0R2WkOeQvPRFxPtqwr6m021by5PVJe9qR5v1cbNws=; b=Fg7peFFwmYvaeyhB0M6uVUetz9ad98+dY/FOYNSdaKQGhR1QSD+5OVs+BlxV6JgE4n 6U6t/sjjJVgphZT2xvcmJ/SxYiXwQxhSZp0td8t3oqGppjuJ93a6yzYr06usnAChJCqp ic9qjygN/5eCWVPSvR3UVttTLn2nS5Ex1NNSbs9qj0FiCuoRx07cOuawC5nWt+Ft8w0+ VfYA/6ZmPkeA6+RGP2aQbb7xfrTZ1Z8oDs6O/X8zBc/nQgCjKBRlJEF04ueBXNetG8MH jWc27i6OTaH9cAXDnOVocLbBWojROzeyR6yTvi7jJkF+Ql7oQ7BgP9NqahUMN9Xq8ee4 spuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747094786; x=1747699586; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=nB0R2WkOeQvPRFxPtqwr6m021by5PVJe9qR5v1cbNws=; b=Lu38cYCJUnx/26MGS69LKA+dfQS6XByE8JPZsiMHAlaWCP1VP5IlE+Ce8pcLU3/g9o EOT5y+B1P7Sq1t1fJxN26BgvyJPhMqF0IClSayCSW+dDBbBuQeCJ4Zkiy26Qyho+dk1f t60H5BERLMEfapHLYjAjnQFqWWgPTk+WZtdwS7uH9amFHbpew4i7zY4X360RL4zsc5M7 HnhM9wU6g5pOIAupN0thvjZgq+VK3IJVOw1Kr7nPk8KU152pu0UWsbvYG5AIRzO2JBZa AAXH/GZIeqxbc6WPCxdu0AaZHCVhmyAZLOHxOVxNMUfBiCVkEm7OxDguzfPaOyEMKRii vamQ== X-Forwarded-Encrypted: i=1; AJvYcCV+MG+GmtGFPeHgFmp3qMtvWwESJu4e4GhKiqTnC9Pgv+9U+R2E7cj/fJSmPL4sahsNRRF+cMPw@vger.kernel.org, AJvYcCVZgPWOALjR0Ti1uA95INX1wvsdWqcrSsFdmD5QamDIKuCErY/tmkBT0PdYfiKSVDkbXLpKR4cnNYTDbmA=@vger.kernel.org, AJvYcCWwxIKU/UvHNvt91qqeTCJge2fR/6TTgWpRtWMwhNXb3lOfHL9UGrvSduZ0S5quBP5TQf7AGMQQ@vger.kernel.org, AJvYcCXDCAAT4vy7Xj66rjl3QHkgLhwNLL4+WerppIHvnAV0HozizCGTeHUM4/CbmiUGfwDrCblmY8IoWfGgJw==@vger.kernel.org X-Gm-Message-State: AOJu0YzQTHwBJCU4ratFWBKgfDkLDDkvXE4+bW8r2+yxaf+V/vdTzboJ jrs0ZmyCJSLg+7pfVi/GonnISxqVE8WsuFpKDvEXIbEW7iIoMTbI X-Gm-Gg: ASbGnct5OGHPX54DVzwn5hh1aO4GXmoXVCZoBNmLLU+gBp4oU0BodbQQEkRRXffbtHW 05Bo5I1NnLRN2jJyTjdJX8wVdfwycEDvKiDtPqaB5I0VUbcZvC1ASKlF8YmAkB2GgXN00eOaaaM 5lN2sUJ69yCBLnP9aERIk0rXGIZZ2RzWAglHWQbeHO79pLOxahJyWbTd9st/qsaDd7rAdhFB4bO 825+xtvbP+C5Az2wtXTwSb4aIVpzJS/C2EZq+y/hPYy/95KncBqOXg/FrHnqW+/6INMV8yCrRhL Wg34ol/YtE2/ulboAWZw4m9lx29dtnGsOkWfpghQxJJVue+ihvf7APYFuEMcJcEt7lWWyykMxJk 6q+6BWiKboZL0O9SWP1MrgkO2D1xm8g== X-Google-Smtp-Source: AGHT+IFLg2j6NqWasFKsMRIuMsAX6kcU4vbM8vVlA7iOsqIK1jE+GZgWt0et1u12KP0vgp5Tktg5eg== X-Received: by 2002:a17:902:ce8a:b0:215:ba2b:cd55 with SMTP id d9443c01a7336-2317cac7646mr19127295ad.2.1747094786386; Mon, 12 May 2025 17:06:26 -0700 (PDT) Received: from localhost.localdomain (c-67-160-120-253.hsd1.wa.comcast.net. [67.160.120.253]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22fc828b491sm68470665ad.184.2025.05.12.17.06.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 May 2025 17:06:26 -0700 (PDT) From: mhkelley58@gmail.com X-Google-Original-From: mhklinux@outlook.com To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net 5/5] Drivers: hv: vmbus: Remove vmbus_sendpacket_pagebuffer() Date: Mon, 12 May 2025 17:06:04 -0700 Message-Id: <20250513000604.1396-6-mhklinux@outlook.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250513000604.1396-1-mhklinux@outlook.com> References: <20250513000604.1396-1-mhklinux@outlook.com> Reply-To: mhklinux@outlook.com Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Michael Kelley With the netvsc driver changed to use vmbus_sendpacket_mpb_desc() instead of vmbus_sendpacket_pagebuffer(), the latter has no remaining callers. Remove it. Cc: # 6.1.x Signed-off-by: Michael Kelley --- drivers/hv/channel.c | 59 ------------------------------------------ include/linux/hyperv.h | 7 ----- 2 files changed, 66 deletions(-) diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c index 4ffd5eaa7817..35f26fa1ffe7 100644 --- a/drivers/hv/channel.c +++ b/drivers/hv/channel.c @@ -1076,65 +1076,6 @@ int vmbus_sendpacket(struct vmbus_channel *channel, void *buffer, } EXPORT_SYMBOL(vmbus_sendpacket); -/* - * vmbus_sendpacket_pagebuffer - Send a range of single-page buffer - * packets using a GPADL Direct packet type. This interface allows you - * to control notifying the host. This will be useful for sending - * batched data. Also the sender can control the send flags - * explicitly. - */ -int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel, - struct hv_page_buffer pagebuffers[], - u32 pagecount, void *buffer, u32 bufferlen, - u64 requestid) -{ - int i; - struct vmbus_channel_packet_page_buffer desc; - u32 descsize; - u32 packetlen; - u32 packetlen_aligned; - struct kvec bufferlist[3]; - u64 aligned_data = 0; - - if (pagecount > MAX_PAGE_BUFFER_COUNT) - return -EINVAL; - - /* - * Adjust the size down since vmbus_channel_packet_page_buffer is the - * largest size we support - */ - descsize = sizeof(struct vmbus_channel_packet_page_buffer) - - ((MAX_PAGE_BUFFER_COUNT - pagecount) * - sizeof(struct hv_page_buffer)); - packetlen = descsize + bufferlen; - packetlen_aligned = ALIGN(packetlen, sizeof(u64)); - - /* Setup the descriptor */ - desc.type = VM_PKT_DATA_USING_GPA_DIRECT; - desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; - desc.dataoffset8 = descsize >> 3; /* in 8-bytes granularity */ - desc.length8 = (u16)(packetlen_aligned >> 3); - desc.transactionid = VMBUS_RQST_ERROR; /* will be updated in hv_ringbuffer_write() */ - desc.reserved = 0; - desc.rangecount = pagecount; - - for (i = 0; i < pagecount; i++) { - desc.range[i].len = pagebuffers[i].len; - desc.range[i].offset = pagebuffers[i].offset; - desc.range[i].pfn = pagebuffers[i].pfn; - } - - bufferlist[0].iov_base = &desc; - bufferlist[0].iov_len = descsize; - bufferlist[1].iov_base = buffer; - bufferlist[1].iov_len = bufferlen; - bufferlist[2].iov_base = &aligned_data; - bufferlist[2].iov_len = (packetlen_aligned - packetlen); - - return hv_ringbuffer_write(channel, bufferlist, 3, requestid, NULL); -} -EXPORT_SYMBOL_GPL(vmbus_sendpacket_pagebuffer); - /* * vmbus_sendpacket_mpb_desc - Send one or more multi-page buffer packets * using a GPADL Direct packet type. diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index d6ffe01962c2..b52ac40d5830 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -1167,13 +1167,6 @@ extern int vmbus_sendpacket(struct vmbus_channel *channel, enum vmbus_packet_type type, u32 flags); -extern int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel, - struct hv_page_buffer pagebuffers[], - u32 pagecount, - void *buffer, - u32 bufferlen, - u64 requestid); - extern int vmbus_sendpacket_mpb_desc(struct vmbus_channel *channel, struct vmbus_packet_mpb_array *mpb, u32 desc_size,