From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by mx.groups.io with SMTP id smtpd.web10.2056.1587751110418948418 for ; Fri, 24 Apr 2020 10:58:30 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=eayky61V; spf=pass (domain: oracle.com, ip: 156.151.31.85, mailfrom: nikita.leshchenko@oracle.com) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03OHr2iA032957; Fri, 24 Apr 2020 17:58:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=WlGRyCBUlk88O2SVfm7pcM8hjEBkOWxjvuGzxSZTS74=; b=eayky61VIV5EMTdS9xLVYUYiZ71G5nTG/rKO4tdgHspx4rQf+fXiz7SSw5Ed7iKO97Km 9uu9TucNW5Izm3ihj5tKXVxnTonvRoLUlfCnKQBrxqxCl5Ch1haFE1RwUU7F9+6UsiEf 2fgeoOY184W7dzqIzcpCRG0jINfiR8vS7uy50D4B/cdQ51XdPflH57vBozI3rQTcewyD QMJ3iLv5XO8tAzRekWCMh18pc9Cq9KKIuH6dwB3XjB9UkCFifcnJ0Mbh6sfV4HkhfQvg AaiewDk8JqBMwlvDts+SQaKjZeMlvMcE+UHA5ECmPbzINB8liayDp3YDDUJCw1+jKYqq ig== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 30k7qe87xw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Apr 2020 17:58:27 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03OHmPmL126824; Fri, 24 Apr 2020 17:56:27 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 30gb1q7pke-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Apr 2020 17:56:27 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03OHuQI5007807; Fri, 24 Apr 2020 17:56:26 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 24 Apr 2020 10:56:25 -0700 From: "Nikita Leshenko" To: devel@edk2.groups.io Cc: Nikita Leshenko , liran.alon@oracle.com, aaron.young@oracle.com, Jordan Justen , Laszlo Ersek , Ard Biesheuvel Subject: [PATCH v5 07/12] OvmfPkg/MptScsiDxe: Build and decode DevicePath Date: Fri, 24 Apr 2020 20:59:22 +0300 Message-Id: <20200424175927.41210-8-nikita.leshchenko@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424175927.41210-1-nikita.leshchenko@oracle.com> References: <20200424175927.41210-1-nikita.leshchenko@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9601 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004240136 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9601 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 phishscore=0 impostorscore=0 mlxscore=0 clxscore=1015 malwarescore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004240136 Content-Transfer-Encoding: 8bit Used to identify the individual disks in the hardware tree. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2390 Signed-off-by: Nikita Leshenko Reviewed-by: Liran Alon Reviewed-by: Laszlo Ersek --- OvmfPkg/MptScsiDxe/MptScsi.c | 61 ++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c index 5e0544c8d9d2..dc4b854659f9 100644 --- a/OvmfPkg/MptScsiDxe/MptScsi.c +++ b/OvmfPkg/MptScsiDxe/MptScsi.c @@ -146,7 +146,36 @@ MptScsiBuildDevicePath ( IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath ) { - return EFI_UNSUPPORTED; + MPT_SCSI_DEV *Dev; + SCSI_DEVICE_PATH *ScsiDevicePath; + + if (DevicePath == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // This device support 256 targets only, so it's enough to dereference + // the LSB of Target. + // + Dev = MPT_SCSI_FROM_PASS_THRU (This); + if (*Target > Dev->MaxTarget || Lun > 0) { + return EFI_NOT_FOUND; + } + + ScsiDevicePath = AllocateZeroPool (sizeof (*ScsiDevicePath)); + if (ScsiDevicePath == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + ScsiDevicePath->Header.Type = MESSAGING_DEVICE_PATH; + ScsiDevicePath->Header.SubType = MSG_SCSI_DP; + ScsiDevicePath->Header.Length[0] = (UINT8)sizeof (*ScsiDevicePath); + ScsiDevicePath->Header.Length[1] = (UINT8)(sizeof (*ScsiDevicePath) >> 8); + ScsiDevicePath->Pun = *Target; + ScsiDevicePath->Lun = (UINT16)Lun; + + *DevicePath = &ScsiDevicePath->Header; + return EFI_SUCCESS; } STATIC @@ -159,7 +188,35 @@ MptScsiGetTargetLun ( OUT UINT64 *Lun ) { - return EFI_UNSUPPORTED; + MPT_SCSI_DEV *Dev; + SCSI_DEVICE_PATH *ScsiDevicePath; + + if (DevicePath == NULL || + Target == NULL || *Target == NULL || Lun == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (DevicePath->Type != MESSAGING_DEVICE_PATH || + DevicePath->SubType != MSG_SCSI_DP) { + return EFI_UNSUPPORTED; + } + + Dev = MPT_SCSI_FROM_PASS_THRU (This); + ScsiDevicePath = (SCSI_DEVICE_PATH *)DevicePath; + if (ScsiDevicePath->Pun > Dev->MaxTarget || + ScsiDevicePath->Lun > 0) { + return EFI_NOT_FOUND; + } + + ZeroMem (*Target, TARGET_MAX_BYTES); + // + // This device support 256 targets only, so it's enough to set the LSB + // of Target. + // + **Target = (UINT8)ScsiDevicePath->Pun; + *Lun = ScsiDevicePath->Lun; + + return EFI_SUCCESS; } STATIC -- 2.20.1