From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web09.681.1583365523514587595 for ; Wed, 04 Mar 2020 15:45:23 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=F5tP6Fja; spf=pass (domain: oracle.com, ip: 141.146.126.78, mailfrom: liran.alon@oracle.com) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 024Ncum7018148; Wed, 4 Mar 2020 23:45:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=F5MErOYLdiQhhPgmFAsFxJjPBs98cfZXh8R3aiT2Gw0=; b=F5tP6FjaW5CtaLq4hEPspQY+an6xRzebRgtIdjBbu286NljK5J6zgVt0H1wrjCXFkgN2 1VBfAyGUR6qAztFz2tMDv5MxBl/dcjo3rUSPRx8p8JrALxbnNGfXG8ArttKFiYWxMLFW n6jB6i/ywjvtmht0mNLvO4yXJw01gCDzAXtA8zBofboJUQHbLZ9Hv9N0q8kUB3mySQmi jZdDftM8RmetESj+jMEzecdeaPPAeChRiwG6NzJ+11PBDRsOjCPazAaC/BWMe9x3YriI P90S+9DBnJxoG8hEkD+VxRAkvq8P6KFm9Sv9/o5wV/7TUVmmDHve5I/lqYiLIFdDFZT1 gg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2yffwr1kwf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Mar 2020 23:45:22 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 024NhEXR112164; Wed, 4 Mar 2020 23:45:22 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2yg1h1yjxt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Mar 2020 23:45:22 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 024NjM7q032718; Wed, 4 Mar 2020 23:45:22 GMT Received: from [192.168.14.112] (/79.177.218.220) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 04 Mar 2020 15:45:21 -0800 Subject: Re: [PATCH v3 06/13] OvmfPkg/MptScsiDxe: Report one Target and one LUN To: Nikita Leshenko , devel@edk2.groups.io Cc: aaron.young@oracle.com, jordan.l.justen@intel.com, lersek@redhat.com, ard.biesheuvel@linaro.org References: <20200304192257.96736-1-nikita.leshchenko@oracle.com> <20200304192257.96736-7-nikita.leshchenko@oracle.com> From: Liran Alon Message-ID: <5a6ffe1b-5af4-8ddf-3733-fb7db70782d3@oracle.com> Date: Thu, 5 Mar 2020 01:45:17 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200304192257.96736-7-nikita.leshchenko@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9550 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003040150 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9550 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 spamscore=0 impostorscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 phishscore=0 clxscore=1015 bulkscore=0 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003040150 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US On 04/03/2020 21:22, Nikita Leshenko wrote: > Support for multiple targets will be implemented in a later commit in > this series. > > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2390 > Signed-off-by: Nikita Leshenko > Reviewed-by: Laszlo Ersek > --- > OvmfPkg/MptScsiDxe/MptScsi.c | 38 +++++++++++++++++++++++++++++-- > OvmfPkg/MptScsiDxe/MptScsiDxe.inf | 1 + > 2 files changed, 37 insertions(+), 2 deletions(-) > > diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c > index 9598b82fda53..e898a6024f73 100644 > --- a/OvmfPkg/MptScsiDxe/MptScsi.c > +++ b/OvmfPkg/MptScsiDxe/MptScsi.c > @@ -17,6 +17,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -62,6 +63,22 @@ MptScsiPassThru ( > return EFI_UNSUPPORTED; > } > > +STATIC > +BOOLEAN > +IsTargetInitialized ( > + IN UINT8 *Target > + ) > +{ > + UINTN Idx; > + > + for (Idx = 0; Idx < TARGET_MAX_BYTES; ++Idx) { > + if (Target[Idx] != 0xFF) { > + return TRUE; > + } > + } > + return FALSE; > +} > + > STATIC > EFI_STATUS > EFIAPI > @@ -71,7 +88,16 @@ MptScsiGetNextTargetLun ( > IN OUT UINT64 *Lun > ) > { > - return EFI_UNSUPPORTED; > + // > + // Currently support only target 0 LUN 0, so hardcode it > + // > + if (!IsTargetInitialized (*Target)) { > + ZeroMem (*Target, TARGET_MAX_BYTES); > + *Lun = 0; > + return EFI_SUCCESS; > + } else { > + return EFI_NOT_FOUND; > + } Nit: I prefer to remove the "else" clause and just write afterwards return EFI_NOT_FOUND. To make it clear that all code-flows have return statements. In addition, the comment should be above "return EFI_NOT_FOUND;". > } > > STATIC > @@ -82,7 +108,15 @@ MptScsiGetNextTarget ( > IN OUT UINT8 **Target > ) > { > - return EFI_UNSUPPORTED; > + // > + // Currently support only target 0 LUN 0, so hardcode it > + // > + if (!IsTargetInitialized (*Target)) { > + ZeroMem (*Target, TARGET_MAX_BYTES); > + return EFI_SUCCESS; > + } else { > + return EFI_NOT_FOUND; > + } Same as above. > } > > STATIC > diff --git a/OvmfPkg/MptScsiDxe/MptScsiDxe.inf b/OvmfPkg/MptScsiDxe/MptScsiDxe.inf > index a253c5d96916..8f366b92eb72 100644 > --- a/OvmfPkg/MptScsiDxe/MptScsiDxe.inf > +++ b/OvmfPkg/MptScsiDxe/MptScsiDxe.inf > @@ -30,6 +30,7 @@ [Packages] > OvmfPkg/OvmfPkg.dec > > [LibraryClasses] > + BaseMemoryLib > DebugLib > MemoryAllocationLib > UefiBootServicesTableLib