From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0085.outbound.protection.outlook.com [104.47.33.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7C48F21DFE900 for ; Mon, 7 Aug 2017 04:57:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=OysvvNApQbVbtXntT2/zVZ7IrSS5FxJkMd7jjasGnA8=; b=0UFoBaqf3zRDsxLFJOxpFxSYdyAxMB91CV1zPfV61YCDGi5vNrVSiMwQp62fTEl1tEE0Ukf1YGw/m07UN7EHWPC/5s2hNmQlE+ivP/Yz16SUkIdjs11aeO0HWuWuCZienZ89k1uOmrCrUd0fou6hhhPB4kGn80A8VYS9inn5MMo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1320.16; Mon, 7 Aug 2017 11:59:30 +0000 From: Brijesh Singh To: edk2-devel@lists.01.org Cc: Brijesh Singh , Ard Biesheuvel , Jordan Justen , Tom Lendacky , Laszlo Ersek Date: Mon, 7 Aug 2017 07:58:58 -0400 Message-Id: <1502107139-412-14-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> References: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR04CA0033.namprd04.prod.outlook.com (10.172.133.19) To SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9077e851-7c08-4399-1591-08d4dd8bc312 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:SN1PR12MB0159; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 3:4/DK4j1ZMd5yXQX8I1krlHhLT/pyjn0GqAEOm/RHkPTxbRX6TlLXDelJiGKMZCD7IB49CSSkGn7n/6Zhv3lwXbMH9YLokt7y+mmexWpsU5LjBexEuTtZ++z3fSZHhqMyK3uxMJK/ryBDtBn1BL7GarbXEBYaZYapPfNRTw/LAzpZwKP+cmu44XzP1u3BReWIuVU9NhsBlWsGk9UMt+byEwbiPJvJ11ekg7p7Y+W+6N5IwH7t5uA2dqCUkYlmcaBx; 25:nNGvBKCIdpIz7P1SIGq5dDW2uUY4S1XFK6M9dpYReiKPlcvCvaW+xhSRRrLdyRC/ofdDx/Dba5t9exINNysvTyARzgWJ/xA+PUqb62NUkj9BoIYs1BAGKT9WWwINTCWOLXppBtOTiQPuV7j9gbGASO51wIa02BNOzo1TQSFTSWjV6mlGdGWB2O+SHvDVZIP+dPEAuMeHKLjSqL1L4fBFtKixXnNq8r/wAFGjti6dRYWzi1nCGVyhaqGSxtzj4FUpWKoylHjtiYprmMRLr9jRnpawxJuTL+ATMGJfkX6aHpXYp95liR/c2Dkb/vL06RPGroTr1XtOR5hJWmu0YdrqwQ==; 31:bxDIh7SgdU0J0BI1F4i9KUtaXsi9lAmbU0uzRYiPC31z3Un4oG4dqclq2eJJOGtzN6ZJfgHkKxiEsSpzFv06iHKPKehPiwfIa7ALXpFYEDCjxW5IcdkW56pecFWiNz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riScan:(20558992708506)(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0159; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0159; X-Forefront-PRVS: 0392679D18 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39400400002)(39850400002)(39450400003)(39410400002)(39840400002)(39860400002)(199003)(189002)(3846002)(6116002)(5660300001)(81156014)(81166006)(54906002)(8676002)(68736007)(50466002)(53936002)(53416004)(106356001)(2950100002)(105586002)(2351001)(42186005)(86362001)(6666003)(5003940100001)(36756003)(189998001)(33646002)(6916009)(97736004)(25786009)(2906002)(478600001)(110136004)(47776003)(38730400002)(76176999)(50986999)(66066001)(4326008)(2361001)(305945005)(50226002)(48376002)(7350300001)(101416001)(6486002)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0159; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR12MB0159; 23:J8YsHVCp7SBUXlSBPcxQvSGm9/qIFiq4QoC38rieX?= =?us-ascii?Q?h8Hw7OJsTutUSnmjbE+oCPrVuU4ib47ZSHOok9RFcBXx0FYlVrpM5NDFXwAn?= =?us-ascii?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FTK/jhVbWYArwRdTEyVpSRFTMW9PEFZTFa4gIlMwJ194Jx0oD9SH2xVXroq8bBZKzv0nlqNqjgbKNHuxbLmsVY2XF+vLLrgBbGiisihN4DbtNlqCABCfiq4xmSYRHpOlKkOCtYZIzIubOj4374wM5OPxxWZD0r9vT93cSWPWgXcYh900jOgSCPCiGkZVq+v8051UgtDo9Z7fl8EZyzeb6ZRtSo0Umhm+Yejih0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:WPMyGvy0+YkFcXQNk/Iww9v+8ODWRxTkkqtpyNwoiWVCla7b652HxYLQpLmUTNkz5DXc4J7EQsi7FhJI8n9it1zrimYcDKvmvufNHzxJC9Wgj19l0kq7FiXMKCvZHRzLToM/9T5smpcypvlTIsMY8P0F9RC6z1iDpB5AxmWlGs/BCCSpavF+YXqBmb+qsz91FiesfE9yzMKwmKm9gauplvLfpJ8vb0a3oMdFrkQ7vrR5TtgHWiFVQ7scrb9UqRvK X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2017 11:59:30.4800 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0159 Subject: [PATCH v1 13/14] OvmfPkg/VirtioNetDxe: Use DeviceAddress in transmit vring descriptors X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 11:57:16 -0000 Content-Type: text/plain Update VirtioNetTransmit() to map the callers transmit buffer to a device DMA address and use the DeviceAddress in vring descriptors. Since the transmit buffers are returned back to caller in VirtioNetGetStatus() hence we maintain a list to map DeviceAddress to HostAddress. The list is consulted to find the correct HostAddress upon transmit completion interruption. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh --- OvmfPkg/VirtioNetDxe/VirtioNet.h | 17 ++++ OvmfPkg/VirtioNetDxe/SnpGetStatus.c | 19 +++- OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c | 100 ++++++++++++++++++++ OvmfPkg/VirtioNetDxe/SnpTransmit.c | 22 +++-- 4 files changed, 149 insertions(+), 9 deletions(-) diff --git a/OvmfPkg/VirtioNetDxe/VirtioNet.h b/OvmfPkg/VirtioNetDxe/VirtioNet.h index 873069e9de82..6c5129f178cd 100644 --- a/OvmfPkg/VirtioNetDxe/VirtioNet.h +++ b/OvmfPkg/VirtioNetDxe/VirtioNet.h @@ -269,6 +269,23 @@ VirtioNetShutdownTx ( IN OUT VNET_DEV *Dev ); +EFI_STATUS +EFIAPI +VirtioMapTxBuf ( + IN VNET_DEV *Dev, + IN EFI_PHYSICAL_ADDRESS HostAddress, + IN UINTN NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress + ); + +EFI_STATUS +EFIAPI +VirtioUnmapTxBuf ( + IN VNET_DEV *Dev, + OUT EFI_PHYSICAL_ADDRESS *HostAddress, + IN EFI_PHYSICAL_ADDRESS DeviceAddress + ); + // // event callbacks // diff --git a/OvmfPkg/VirtioNetDxe/SnpGetStatus.c b/OvmfPkg/VirtioNetDxe/SnpGetStatus.c index 694940ea1d97..ddea29e65d57 100644 --- a/OvmfPkg/VirtioNetDxe/SnpGetStatus.c +++ b/OvmfPkg/VirtioNetDxe/SnpGetStatus.c @@ -5,6 +5,7 @@ Copyright (C) 2013, Red Hat, Inc. Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, AMD Inc, All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this @@ -126,8 +127,10 @@ VirtioNetGetStatus ( *TxBuf = NULL; } else { - UINT16 UsedElemIdx; - UINT32 DescIdx; + UINT16 UsedElemIdx; + UINT32 DescIdx; + EFI_PHYSICAL_ADDRESS DeviceAddress; + EFI_PHYSICAL_ADDRESS HostAddress; // // fetch the first descriptor among those that the hypervisor reports @@ -141,9 +144,19 @@ VirtioNetGetStatus ( ASSERT (DescIdx < (UINT32) (2 * Dev->TxMaxPending - 1)); // + // Unmap the DeviceAddress + // + DeviceAddress = Dev->TxRing.Desc[DescIdx + 1].Addr; + Status = VirtioUnmapTxBuf (Dev, &HostAddress, DeviceAddress); + if (EFI_ERROR (Status)) { + goto Exit; + } + + // + // // report buffer address to caller that has been enqueued by caller // - *TxBuf = (VOID *)(UINTN) Dev->TxRing.Desc[DescIdx + 1].Addr; + *TxBuf = (VOID *)(UINTN) HostAddress; // // now this descriptor can be used again to enqueue a transmit buffer diff --git a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c b/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c index 3ed7132be531..6a6866e65b5f 100644 --- a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c +++ b/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c @@ -14,10 +14,25 @@ **/ +#include #include #include "VirtioNet.h" +#define PRIVATE_TXBUF_SIGNATURE SIGNATURE_32 ('t', 'x', 'b', 'f') +typedef struct { + UINT32 Signature; + LIST_ENTRY Link; + EFI_PHYSICAL_ADDRESS HostAddress; + EFI_PHYSICAL_ADDRESS DeviceAddress; + VOID *Mapping; +} PRIVATE_TXBUF_ENTRY; +#define PRIVATE_TXBUF_FROM_LINK(a) CR (a, PRIVATE_TXBUF_ENTRY, Link, \ + PRIVATE_TXBUF_SIGNATURE) + +STATIC LIST_ENTRY mTxBufMapList = INITIALIZE_LIST_HEAD_VARIABLE (mTxBufMapList); + + /** Release RX and TX resources on the boundary of the EfiSimpleNetworkInitialized state. @@ -68,3 +83,88 @@ VirtioNetShutdownTx ( FreePool (Dev->TxFreeStack); } + +EFI_STATUS +EFIAPI +VirtioMapTxBuf ( + IN VNET_DEV *Dev, + IN EFI_PHYSICAL_ADDRESS HostAddress, + IN UINTN NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress + ) +{ + EFI_STATUS Status; + PRIVATE_TXBUF_ENTRY *Private; + + Private = AllocatePool (sizeof (*Private)); + if (Private == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Private->Signature = PRIVATE_TXBUF_SIGNATURE; + Private->HostAddress = HostAddress; + + Status = VirtioMapSharedBufferRead (Dev->VirtIo, + (VOID *) (UINTN) Private->HostAddress, NumberOfBytes, + &Private->DeviceAddress, &Private->Mapping); + if (EFI_ERROR (Status)) { + FreePool (Private); + return Status; + } + + *DeviceAddress = Private->DeviceAddress; + + // + // Add the mapping information into internal list so that we can retrieve + // the HostAddress upon Unmap(). + // + InsertTailList (&mTxBufMapList, &Private->Link); + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +VirtioUnmapTxBuf ( + IN VNET_DEV *Dev, + OUT EFI_PHYSICAL_ADDRESS *HostAddress, + IN EFI_PHYSICAL_ADDRESS DeviceAddress + ) +{ + EFI_STATUS Status; + PRIVATE_TXBUF_ENTRY *Private; + LIST_ENTRY *Link; + BOOLEAN Found; + + Found = FALSE; + + // + // Iterate through internal txbuf list to find mapping for a given + // DeviceAddress. + // + for (Link = GetFirstNode (&mTxBufMapList) + ; !IsNull (&mTxBufMapList, Link) + ; Link = GetNextNode (&mTxBufMapList, Link) + ) { + Private = PRIVATE_TXBUF_FROM_LINK (Link); + if (Private->DeviceAddress == DeviceAddress) { + Found = TRUE; + break; + } + } + + // + // We failed to find mapping for the given DeviceAddress + // (this should never happen) + // + ASSERT (Found); + + Status = VirtioUnmapSharedBuffer (Dev->VirtIo, Private->Mapping); + if (EFI_ERROR (Status)) { + return Status; + } + + *HostAddress = Private->HostAddress; + + return EFI_SUCCESS; +} diff --git a/OvmfPkg/VirtioNetDxe/SnpTransmit.c b/OvmfPkg/VirtioNetDxe/SnpTransmit.c index 7ca40d5d0650..20c56c12df04 100644 --- a/OvmfPkg/VirtioNetDxe/SnpTransmit.c +++ b/OvmfPkg/VirtioNetDxe/SnpTransmit.c @@ -73,11 +73,12 @@ VirtioNetTransmit ( IN UINT16 *Protocol OPTIONAL ) { - VNET_DEV *Dev; - EFI_TPL OldTpl; - EFI_STATUS Status; - UINT16 DescIdx; - UINT16 AvailIdx; + VNET_DEV *Dev; + EFI_TPL OldTpl; + EFI_STATUS Status; + UINT16 DescIdx; + UINT16 AvailIdx; + EFI_PHYSICAL_ADDRESS DeviceAddress; if (This == NULL || BufferSize == 0 || Buffer == NULL) { return EFI_INVALID_PARAMETER; @@ -144,10 +145,19 @@ VirtioNetTransmit ( } // + // Map the transmit buffer HostAddress to a DeviceAddress + // + Status = VirtioMapTxBuf (Dev, (EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, + BufferSize, &DeviceAddress); + if (EFI_ERROR (Status)) { + goto Exit; + } + + // // virtio-0.9.5, 2.4.1 Supplying Buffers to The Device // DescIdx = Dev->TxFreeStack[Dev->TxCurPending++]; - Dev->TxRing.Desc[DescIdx + 1].Addr = (UINTN) Buffer; + Dev->TxRing.Desc[DescIdx + 1].Addr = (UINTN) DeviceAddress; Dev->TxRing.Desc[DescIdx + 1].Len = (UINT32) BufferSize; // -- 2.7.4