Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F157896136
D53919.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D53919.diff
View Options
diff --git a/sys/dev/ufshci/ufshci.h b/sys/dev/ufshci/ufshci.h
--- a/sys/dev/ufshci/ufshci.h
+++ b/sys/dev/ufshci/ufshci.h
@@ -335,6 +335,8 @@
uint8_t flags;
};
uint8_t lun;
+#define UFSHCI_UPIU_UNIT_NUMBER_ID_MASK 0x7f
+#define UFSHCI_UPIU_WLUN_ID_MASK 0x80
uint8_t task_tag;
/* dword 1 */
diff --git a/sys/dev/ufshci/ufshci_sim.c b/sys/dev/ufshci/ufshci_sim.c
--- a/sys/dev/ufshci/ufshci_sim.c
+++ b/sys/dev/ufshci/ufshci_sim.c
@@ -72,6 +72,28 @@
xpt_done(ccb);
}
+/*
+ * The SCSI LUN format and the UFS UPIU LUN format are different.
+ * This function converts the SCSI LUN format to the UFS UPIU LUN format.
+ */
+static uint8_t
+ufshci_sim_translate_scsi_to_ufs_lun(lun_id_t scsi_lun)
+{
+ const int address_format_offset = 8;
+ uint8_t address_format = scsi_lun >> address_format_offset;
+
+ /* Well known logical unit */
+ if (((address_format & RPL_LUNDATA_ATYP_MASK) ==
+ RPL_LUNDATA_ATYP_EXTLUN) &&
+ ((address_format & RPL_LUNDATA_EXT_EAM_MASK) ==
+ RPL_LUNDATA_EXT_EAM_WK))
+ return ((scsi_lun & UFSHCI_UPIU_UNIT_NUMBER_ID_MASK) |
+ UFSHCI_UPIU_WLUN_ID_MASK);
+
+ /* Logical unit */
+ return (scsi_lun & UFSHCI_UPIU_UNIT_NUMBER_ID_MASK);
+}
+
static void
ufshchi_sim_scsiio(struct cam_sim *sim, union ccb *ccb)
{
@@ -129,7 +151,8 @@
upiu->header.trans_type = UFSHCI_UPIU_TRANSACTION_CODE_COMMAND;
upiu->header.operational_flags = is_write ? UFSHCI_OPERATIONAL_FLAG_W :
UFSHCI_OPERATIONAL_FLAG_R;
- upiu->header.lun = csio->ccb_h.target_lun;
+ upiu->header.lun = ufshci_sim_translate_scsi_to_ufs_lun(
+ csio->ccb_h.target_lun);
upiu->header.cmd_set_type = UFSHCI_COMMAND_SET_TYPE_SCSI;
upiu->expected_data_transfer_length = htobe32(payload_len);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, May 27, 6:52 AM (8 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33549115
Default Alt Text
D53919.diff (1 KB)
Attached To
Mode
D53919: ufshci: add helper to convert SCSI LUN to UPIU LUN formats
Attached
Detach File
Event Timeline
Log In to Comment