From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nbfkord-smmo03.seg.att.com (nbfkord-smmo03.seg.att.com [209.65.160.84]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 00C638204E for ; Mon, 6 Feb 2017 06:58:41 -0800 (PST) Received: from unknown [12.187.104.26] (EHLO webmail.solarflare.com) by nbfkord-smmo03.seg.att.com(mxl_mta-7.2.4-7) with ESMTP id 22f88985.2b62f9e02940.4027472.00-2492.8387096.nbfkord-smmo03.seg.att.com (envelope-from ); Mon, 06 Feb 2017 14:58:42 +0000 (UTC) X-MXL-Hash: 58988f223e8bba4c-f9ba3220c3b7ba0977d2aabc093515e3d534947e Received: from unknown [12.187.104.26] (EHLO webmail.solarflare.com) by nbfkord-smmo03.seg.att.com(mxl_mta-7.2.4-7) over TLS secured channel with ESMTP id f1f88985.0.4027469.00-2339.8387091.nbfkord-smmo03.seg.att.com (envelope-from ); Mon, 06 Feb 2017 14:58:40 +0000 (UTC) X-MXL-Hash: 58988f207f9ad38e-0678bf88f41b3e5b911a3cd6f60ac202279941cf Received: from tp-desktop.uk.solarflarecom.com (10.17.20.51) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Mon, 6 Feb 2017 06:58:36 -0800 To: "Ye, Ting" , Laszlo Ersek , "edk2-devel@lists.01.org" References: From: "Tomas Pilar (tpilar)" Message-ID: <2775048a-f988-0e65-4ef7-7fea5c8cc255@solarflare.com> Date: Mon, 6 Feb 2017 14:58:34 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [10.17.20.51] X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To ocex03.SolarFlarecom.com (10.20.40.36) X-AnalysisOut: [v=2.1 cv=HuVwbhnS c=1 sm=1 tr=0 a=8BlWFWvVlq5taO8ncb8nKg==] X-AnalysisOut: [:17 a=uKoR9wHPcrcA:10 a=N659UExz7-8A:10 a=n2v9WMKugxEA:10 ] X-AnalysisOut: [a=i3X5FwGiAAAA:8 a=zRKbQ67AAAAA:8 a=X4n-5Pv0PzfTUuMq7YYA:9] X-AnalysisOut: [ a=aqJ-pgKETMfvqL9q:21 a=aEExAjhZ8xo20wmt:21 a=pILNOxqGKmI] X-AnalysisOut: [A:10 a=mmqRlSCDY2ywfjPLJ4af:22 a=PA03WX8tBzeizutn5_OT:22] X-Spam: [F=0.2000000000; CM=0.500; S=0.200(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [12.187.104.26] Subject: Re: SNP_INIT while in TPL_NOTIFY X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Feb 2017 14:58:42 -0000 Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: quoted-printable This is the specific implementation of SNP for our driver. We expose this implementation which is then consumed by MNP so that our NIC can be used as a NIC. The specific problem is that some functionality that SNP needs to implement (initializing queues, changing MAC, resetting) are asynchronous, but MNP can call our SNP implementation in raised TPL where one is not allowed to wait. So the only solution seems to be to use a busy poll and actually hang the execution until the asynchronous call to the MC on the NIC is completed, even though we've been called in TPL_CALLBACK or TPL_NOTIFY. Cheers, Tom On 06/02/17 06:10, Ye, Ting wrote: > May I ask which SNP module are we discussing here? Is it the common SnpD= xe driver under MdeModulePkg/Universal/Network, or a specific driver implem= ented for your network device? > > Best Regards, > Ye Ting > > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of La= szlo Ersek > Sent: Saturday, January 28, 2017 2:12 AM > To: Tomas Pilar (tpilar) ; edk2-devel@lists.01.org= > Subject: Re: [edk2] SNP_INIT while in TPL_NOTIFY > > On 01/27/17 17:51, Tomas Pilar (tpilar) wrote: >> Hi, >> >> I am currently maintaining our network driver written using the EDKII >> framework. Our network device implements a MCDI (mc-driver interface) >> which is (in theory) asynchronous (DMA doorbell-messagebox >> communication), although the majority of the calls take less than a >> jiffy. So for example, the setting up of TX and RX queues on the NIC >> requires some MCDI calls which the driver then has to wait for. I've >> implemented this using the gSB->SetTimer event system. >> >> My problem is that the SimpleNetworkInitialize() method is called by >> the UEFI platform network core (network core finds a new NIC with SNP >> -> tries to open -> not initialised, so it tries to INIT) using a >> TPL_NOTIFY context, > This looks like a bug, in the code that calls SimpleNetworkInitialize(). > According to "Table 24. TPL Restrictions", for Simple Network Protocol me= thods, the TPL must be <=3D TPL_CALLBACK. Meaning, an SNP implementation mu= stn't raise the TPL above TPL_CALLBACK, but also that any client can't call= SNP methods while executing on a TPL > TPL_CALLBACK. > > Worse, even staying at TPL_CALLBACK wouldn't be good enough for calling > gBS->SetTimer(). SetTimer is < TPL_HIGH_LEVEL, so that'd be fine, but > gBS->WaitForEvent() is strictly =3D TPL_APPLICATION. So WaitForEvent() > can't be called when running on TPL_CALLBACK level. > >> where the code is not allowed to sleep (I assume that this is the MNP >> generic one second network poll timer). I could in theory initialise >> the NIC earlier, during probe, but the SNP allows for specification of >> extra buffer space for TX and RX during init. The network core might >> conceivable use that. Or the MNP might want to change station address >> using SNP or call for a reset which again requires asynchronous NIC >> operation. >> >> Has anyone encountered something similar? Is there a canonical >> solution to this issue? > I think you can poll the NIC in a busy loop, or if that's excessive, use > gBS->Stall() between polls. Stall() is <=3D TPL_HIGH_LEVEL, so it should > be safe. OTOH, "Execution of the processor is not yielded for the duratio= n of the stall". > > Thanks > Laszlo > >> Cheers, >> Tomas Pilar >> >> >> The information contained in this message is confidential and is >> intended for the addressee(s) only. If you have received this message >> in error, please notify the sender immediately and delete the message. >> Unless you are an addressee (or authorized to receive for an >> addressee), you may not use, copy or disclose to anyone this message >> or any information contained in this message. The unauthorized use, >> disclosure, copying or alteration of this message is strictly prohibited= . >> _______________________________________________ >> edk2-devel mailing list >> edk2-devel@lists.01.org >> https://lists.01.org/mailman/listinfo/edk2-devel > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel The information contained in this message is confidential and is intended f= or the addressee(s) only. If you have received this message in error, pleas= e notify the sender immediately and delete the message. Unless you are an a= ddressee (or authorized to receive for an addressee), you may not use, copy= or disclose to anyone this message or any information contained in this me= ssage. The unauthorized use, disclosure, copying or alteration of this mess= age is strictly prohibited.