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.web12.699.1586885868643837306 for ; Tue, 14 Apr 2020 10:37:48 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=dquwq7xd; 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 03EH9ate154780; Tue, 14 Apr 2020 17:37:45 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=qLlro2+80iYsR4vCn38ZvMpS4pHpRrX4VVnu7N07kXU=; b=dquwq7xdJ1j0EsOjqSAF+UxxcXomSpOnwB7kG5U7ooWShAIgF2ShpvwkwXjOivRm+pUe NOCATVRAl4EenAwpR4TQghgjw60X+sTLOLlNJ6yJlhqxwLUjySKtCjnR+LeM29gZ1XHm b2+ZmPvCl8PMrfWk5OYkhMrZECQ+CSjF2I6ig426XpUEVnVQJsuxdJYENzsDpLC5mLxg Xci8HaK8A4GNVcNAAc4YTTBm7XvIcSRbW9zenpXrPR337F9xevthT4FSOq95FntwqJqF X/du2hlRPBniPniPgcTalsFYu8kf1Epr6ql0GACHqrZoV6h0yt7sSaxn6z1aEYSfQmVb hg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 30b6hpp8kd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Apr 2020 17:37:45 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03EH7PY2130522; Tue, 14 Apr 2020 17:35:45 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 30bqm2e1wd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Apr 2020 17:35:45 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03EHZhQ3026770; Tue, 14 Apr 2020 17:35:43 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 14 Apr 2020 10:35:43 -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 v4 07/13] OvmfPkg/MptScsiDxe: Build and decode DevicePath Date: Tue, 14 Apr 2020 20:38:07 +0300 Message-Id: <20200414173813.7715-8-nikita.leshchenko@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414173813.7715-1-nikita.leshchenko@oracle.com> References: <20200414173813.7715-1-nikita.leshchenko@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9591 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=929 adultscore=0 mlxscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004140131 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9591 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 mlxlogscore=998 clxscore=1015 mlxscore=0 phishscore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004140131 Content-Transfer-Encoding: 8bit Used to identify the individual disks in the hardware tree. Currently we accept only Pun=0 and Lun=0, but we will relax this in a later patch. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2390 Signed-off-by: Nikita Leshenko Reviewed-by: Liran Alon --- OvmfPkg/MptScsiDxe/MptScsi.c | 57 ++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c index 30fb084379db..69ab947c0da2 100644 --- a/OvmfPkg/MptScsiDxe/MptScsi.c +++ b/OvmfPkg/MptScsiDxe/MptScsi.c @@ -126,7 +126,34 @@ MptScsiBuildDevicePath ( IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath ) { - return EFI_UNSUPPORTED; + 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. + // + if (*Target > 0 || 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 @@ -139,7 +166,33 @@ MptScsiGetTargetLun ( OUT UINT64 *Lun ) { - return EFI_UNSUPPORTED; + 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; + } + + ScsiDevicePath = (SCSI_DEVICE_PATH *)DevicePath; + if (ScsiDevicePath->Pun > 0 || + 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