You are on page 1of 22

UFS Ring Buffer Specification 1.0.

1G CONFIDENTIAL

SAMSUNG

UFS
RING BUFFER
SPECIFICATION

Version 1.0.1G
UFS Ring Buffer Specification 1.0.1G [텍스트 입력] CONFIDENTIAL
Revision History
Version Date Amendment

1.0.0G 2019.08.21 - Initial Writing

1.0.1G 2019.12.09 - The way to configure RTC changed


- The way to read Command History separated into Volatile and
Non-Volatile
- The size of Command History Parameter List changed
- The size and field of Command History Block Descriptor added
- The length of Device Descriptor changed
- The field of Attributes added
: dRingBufferRTCA and dRingBufferRTCB
UFS Ring Buffer Specification 1.0.1G [텍스트 입력] CONFIDENTIAL
CONTENTS

1 SCOPE 4
2 NORMATIVE REFERENCE 4
3 TERMS AND DEFINITIONS 4
4 INTRODUCTION 4
4.1 Overview 4
5 FUNCTIONAL DESCRIPTION 6
5.1 Command History Record 6
5.2 Checking Ring Buffer Supportability 8
5.3 Configuring Command History Record 8
5.4 Vendor Command 8
5.5 Initialization Condition 9
5.6 Store for Preserve Command History Data 10
5.7 Configuring RTC 11
6 COMMAND AND RESPONSE FOR RING BUFFER 12
6.1 READ BUFFER Command 12
6.1.1 Ring Buffer Mode (MODE = 1Dh) 12
6.1.1.1 COMMAND HISTORY parameter list 15
6.1.1.2 COMMAND HISTORY block descriptor 15
6.1.1.3 Retrieving command history with the READ BUFFER command 16
6.1.1.4 Read Buffer Command Status Response 17
7 UFS DESCRIPTORS, FLAGS AND ATTRIBUTES 18
7.1 DEVICE DESCRIPTOR for Ring Buffer 18
7.2 GEOMETRY DESCRIPTOR for Ring Buffer 19
7.3 FLAGS for Ring Buffer 19
7.4 ATTRIBUTES for Ring Buffer 20
UFS Ring Buffer Specification 1.0.1G [텍스트 입력] CONFIDENTIAL
FIGURES
Figure 4.1.1 Concept of Command History Record ..................................................................................... 5
Figure 5.1.1 Command History Record Sequence Diagram ......................................................................... 7
Figure 5.5.1 Initialize Command History Data ............................................................................................. 9
Figure 5.6.1 Store Command History Data................................................................................................. 10
Figure 5.7 Configuring RTC ....................................................................................................................... 11

TABLES
Table 5.4.1 Vendor Command Operation Code............................................................................................ 8
Table 6.1.1 READ BUFFER command ...................................................................................................... 12
Table 6.1.2 Read Buffer Command Mode Field Values ............................................................................. 12
Table 6.1.3 Buffer ID Field for Ring Buffer Mode..................................................................................... 13
UFS Ring Buffer Specification 1.0.1G [텍스트 입력] CONFIDENTIAL

1 SCOPE

This document describes the Samsung UFS’s additional feature called Ring Buffer that is based on an
Universal Flash Storage interface. In detail, it deals with the method to receive command information
required for protocol analysis between UFS device and Device.

2 NORMATIVE REFERENCE

The following normative documents contain provisions that, through reference in this text, constitute
provisions of this standard. For dated references, subsequent amendments to, or revisions of, any of these
publications do not apply. However, parties to agreements based on this standard are encouraged to
investigate the possibility of applying the most recent editions of the normative documents listed. For
undated references, the latest edition of the normative document referred to applies.

[JESD220D], JEDEC standard for Universal Flash Storage (UFS), Version 3.0

3 TERMS AND DEFINITIONS

For the purposes of this standard, the terms and definitions given in the document included in clause 2,
Normative Reference.

4 INTRODUCTION

4.1 Overview
In UFS device, if the command response result is not success, there were various causes. They can be
originated with an invalid request of the host or an abnormal operation of the UFS device. However, since
the UFS host typically requests commands expected to be processed normally, it is highly likely that the
UFS device will not be able to process the host request if a failure occurs. In UFS devices, command
processing procedures or results may affect the cause of these abnormal operations. In other words,
processing of one command may affect other commands. Therefore, in the event of UFS failure, the host
will analyze the history of all commands processed by the UFS device for debugging. However, the
interface for delivering commands history is not defined in the UFS specification. Because of this
problem, protocol analyzer that can capture data transmitted between the UFS device and the UFS device
is used, but it cannot be utilized in all situations due to equipment and environment constraints.

The Ring Buffer feature enables the host to retrieve the command execution history from the UFS device.
Thus, the Ring Buffer may be utilized instead of using protocol analyzer or command log on the host side.
This specification describes the transaction protocol between an UFS host and a UFS device for activating
command logging and getting the stored command history. In detail, this protocol includes an interface,
such as identifying functionality support and host user authentication for using Ring Buffer.
UFS Ring Buffer Specification 1.0.1G11 [텍스트 입력] CONFIDENTIAL

Figure 4.1.1 Concept of Command History Record


UFS Ring Buffer Specification 1.0.1G [텍스트 입력] CONFIDENTIAL

5 FUNCTIONAL DESCRIPTION

5.1 Command History Record


Command History Record is a function provided by Ring Buffer, which records and provides command
execution information. A data is recorded from the time the host requests, and the host can request a
command history when it wants to read the information. The overall behavior of Command History
Record is depicted in Figure 5.1.1 Command History Record Sequence Diagram. The host may check
whether the UFS device is supporting the Ring Buffer feature or not. If the UFS device supports it, then
the host must enter Vendor Mode for user authentication to enable that feature. After the user
authentication is completed, the host may initiate the command record through a query request. Upon
receiving the host's request, the UFS device may allocate memory for command logging. Thereafter, the
UFS device logs the received command into an allocated memory. The READ BUFFER command may
be used for the host to read the command history stored in UFS device. When Command History Record
function is being enabled, it should be noted that the performance and lifetime of the UFS device may be
affected. So, after reading all the command history, the host shall stop recording to return allocated
memory. And exiting Vendor Mode disables other users from using Ring Buffer.
UFS Ring Buffer Specification 1.0.1G11 [텍스트 입력] CONFIDENTIAL

Figure 5.1.1 Command History Record Sequence Diagram


UFS Ring Buffer Specification 1.0.1G [텍스트 입력] CONFIDENTIAL
5.2 Checking Ring Buffer Supportability
The host can check bExtendedUFSFeaturesSupport of Device Descriptor whether Ring Buffer Feature is
supported. It is described in the bit[11] of bExtendedUFSFeaturesSupport. Also, it is recommended to
check wRingBufferVersion of Device Descriptor, as features related Ring Buffer and the data format can
be different for each version. And the UFS device can see how much memory should be allocated for
reading the command history through the wMaxCommandHistorySize of Geometry Descriptor. All of
these fields can be retrieved only when Selector is set to 01h.

5.3 Configuring Command History Record


The host shall perform requests related to setting recording and reading command history in Vendor
Mode. When entering Vendor Mode, a configured password which allows only a specific user is required.
The host can activate or deactivate the feature by setting fCommandHistoryRecordEn in Vendor Mode.
Write access property of this flag is Volatile that it is set to the default value after power cycle or any type
of reset event. If a QUERY REQUEST to access the fCommanmdHistoryRecordEn is sent when the host
does not enter the Vendor Mode, the Query Response is set to FDh (Invalid IDN). Also the UFS device
sets the query response field to FFh (General failure) when the command queue of all logical units are not
empty. After setting the flag, the host shall exit Vendor Mode.
If the host wants to check the command history, the host may enter Vendor Mode and request the READ
BUFFER command with MODE = 1Dh (Ring Buffer) and BUFFER ID = 00h (Return Volatile Command
History) or 01h (Return Non-Volatile Command History). The UFS device returns Status = CHECK
CONDITION with SENSE KEY = ILLEGAL REQUEST when the host sends READ BUFFER without
entering Vendor Mode. After all operations associated with the Command History Record have been
completed, the host sets fCommandHistoryRecordEn disabled to stop logging commands and exits
Vendor Mode.

5.4 Vendor Command


Samsung UFS provides Vendor Command for vendor-specific purposes. Among the functions supported
by the Vendor Command Specification, the following table shows the functions used with Ring Buffer.

Classification Vendor Command Vendor Operation SCSI Operation Code


Name Code
ENTER VENDOR
00h
Vendor Mode MODE
C0h
Management EXIT VENDOR
01h
MODE
Table 5.4.1 Vendor Command Operation Code
UFS Ring Buffer Specification 1.0.1G11 [텍스트 입력] CONFIDENTIAL

5.5 Initialization Condition


When the Command History Record is enabled, the UFS device will log the command history in the
allocated internal memory. The memory area for recording command history should be initialized when
the host sets fCommandHistoryRecordEn from 0b to 1b. Then UFS device starts logging from the
command received after that query request. If the host sets the flag to 1b when the
fCommandHistoryRecordEn is already 1b, the initialization is omitted and the command logging is
continued. The command history is not initialized, even if the host clears the fCommandHistoryRecordEn
to 0b. It can be still read through the Read Buffer command.

Figure 5.5.1 Initialize Command History Data


UFS Ring Buffer Specification 1.0.1G [텍스트 입력] CONFIDENTIAL
5.6 Store for Preserve Command History Data
All commands received through the UFS host, including the device manager and the task manager, are
logged into the UFS device's internal memory after the Command History Record is activated. There are
two types of memory in the UFS device: one is volatile memory and the other is non-volatile memory. If
the UFS device logs commands only in volatile memory, the data will be lost after any power mode
change or Hibernation. However, logging into non-volatile memory whenever a command is received has
a bad effect on the UFS device's performance and lifespan. Therefore, the UFS device should move the
command history logged in the volatile memory to the non-volatile memory at the time of the command
failure(Response is not Target Success(00h)) or the host's Task Management Request for Abort Task(01h)
and Abort Task Set(02h). If the above conditions do not occur, the command history is recorded only in
volatile memory. Since the UFS device uses the ring buffer data structure when logging the command
history in volatile memory, if the buffer size is full, the oldest command history record is replaced with
the most recent command history record. When the UFS host requests volatile or non-volatile command
history using the Read Buffer command, the UFS device may check whether there is the command
history stored in specified memory. Then the UFS device transmits all the command history recorded in
requested type of memory.

Figure 5.6.1 Store Command History Data


UFS Ring Buffer Specification 1.0.1G11 [텍스트 입력] CONFIDENTIAL
5.7 Configuring RTC
In an error occurred during the test for a long time, it was difficult to estimate the time when the error
happened. However, if the host sets the RTC, the time information can be included in the command
history and the host can find out when it failed. To use the time information, the host is required to set the
dRingBufferRTCA and dRingBufferRTCB of Attribute after setting fCommandHistoryRecordEn to 1b. If
the host sets dRingBufferRTCA, this value is set to Host Time A of COMMAND HISTORY block
descriptor. The Host Time B is also set to the same. If the value is not set, the Host Time A, B included in
COMMAND HISTORY block descriptor can be set to Invalid Value (FFFF FFFFh). It is recommended
to set dRingBufferRTCA and dRingBufferRTCB when the command queue of all logical units are empty.

Figure 2.7 Configuring RTC


UFS Ring Buffer Specification 1.0.1G [텍스트 입력] CONFIDENTIAL

6 COMMAND AND RESPONSE FOR RING BUFFER

6.1 READ BUFFER Command


Table 6.1.1 READ BUFFER command shows detailed CDB format of Read Buffer command

Bit
7 6 5 4 3 2 1 0
Byte

0 OPERATION CODE (3Ch)

1 Reserved MODE

2 BUFFER ID

3 (MSB)

4 BUFFER OFFSET

5 (LSB)

6 (MSB)

7 ALLOCATION LENGTH

8 (LSB)

9 CONTROL = 00h
Table 6.1.1 READ BUFFER command

6.1.1 Ring Buffer Mode (MODE = 1Dh)


 READ BUFFER Command MODE Field Values.

MODE DESCRIPTION
00h Not used in UFS
01h Vendor Specific
02h Data
03h-1Bh Not used in UFS
1Ch Error history
1Dh Ring Buffer
1Eh-1Fh Reserved
Table 6.1.2 Read Buffer Command Mode Field Values

 The UFS device shall support the MODE value of 1Dh, indicating Ring Buffer Mode. The
device operation of this mode depends on BUFFER ID field.
UFS Ring Buffer Specification 1.0.1G11 [텍스트 입력] CONFIDENTIAL
 The BUFFER ID field specifies the action that the UFS device shall perform, and the parameter
data, if any, that the UFS device shall return.

BUFFER ID DESCRIPTION BUFFER OFFSET


00h Return Volatile Command History 𝑍𝑒𝑟𝑜1 to 𝑀𝑎𝑥𝑖𝑚𝑢𝑚2
01h Return Non-Volatile Command History 𝑍𝑒𝑟𝑜1 to 𝑀𝑎𝑥𝑖𝑚𝑢𝑚2
02h - FFh Reserved
NOTE 1 Zero is 000000h for the READ BUFFER (10) command.
NOTE 2 Maximum is FFFFFFh for the READ BUFFER (10) command.
Table 6.1.3 Buffer ID Field for Ring Buffer Mode

 The returned command history may be real time contents or may be the contents captured at
a vendor specific point in time.

 The BUFFER OFFSET field specifies the byte offset from the start of the buffer specified
by the BUFFER ID field from which the UFS device shall return data.

 The UFS device will read up to Allocation Length number of data bytes from the specified
Buffer Offset in Command History Record Buffer and transfer them to a buffer in the UFS
host.

 Less than Allocation Length will be transferred if UFS device contains less byte.

 Data will be transferred from the UFS device to the UFS host via a series of DATA IN
UPIU’s.

 The data transferred from the UFS device will be contained within the Data Segment of
the DATA IN UPIU.

 Zero or an incomplete number of DATA IN UPIU’s will be transferred if an error occurs


before the entire data transfer is complete.
UFS Ring Buffer Specification 1.0.1G [텍스트 입력] CONFIDENTIAL
6.1.1.1 COMMAND HISTORY parameter list
The COMMAND HISTORY parameter list contains the data sent by a UFS device along with an READ
BUFFER command in MODE = 1Dh and BUFFER ID = 00h or 01h. Included in the data are
COMMAND HISTORY parameter list header and block descriptor for command information to be
processed by the UFS device. The COMMAND HISTORY parameter list header contains the
COMMAND HISTORY DATA LENGTH field and reserved 13bytes. The descriptor blocks shall be in
order of executing in the UFS device.

Bit
7 6 5 4 3 2 1 0
Byte

0 (MSB)

… COMMAND HISTORY DATA LENGTH (n-16)

2 (LSB)

… Reserved

15

COMMAND HISTORY block descriptors

16

… COMMAND HISTORY block descriptor (first)

65

n-49

… COMMAND HISTORY block descriptor (last)

n
Table 6.1.4 1 COMMAND HISTORY parameter list
UFS Ring Buffer Specification 1.0.1G11 [텍스트 입력] CONFIDENTIAL
 The COMMAND HISTORY DATA LENGTH field specifies the length in bytes of the
following data that is available to be transferred from the data-in buffer. The command history
data length does not include the number of bytes in the COMMAND HISTORY DATA
LENGTH field. The command history data length shall be a multiple of COMMAND HISTORY
block descriptor size. If the COMMAND HISTORY DATA LENGTH is set to zero, then no
command history block descriptors are included in the COMMAND HISTORY parameter data.
This condition shall not be considered an error.

6.1.1.2 COMMAND HISTORY block descriptor

Bit
7 6 5 4 3 2 1 0
Byte

0 (MSB)

… HOST TIME A

3 (LSB)

4 (MSB)

… HOST TIME B

7 (LSB)

8 (MSB)

… DEVICE TIME

11 (LSB)

12 COMMAND STATE

13 RESPONSE

14 STATUS

15 Reserved Sense Key

16 ASC

17 ASCQ

18
UPIU

UFS Ring Buffer Specification 1.0.1G [텍스트 입력] CONFIDENTIAL

49
Table 6.1.4 2 COMMNAD HISTORY block descriptor

 The HOST TIME A field contains a value of dRingBufferRTCA and The HOST TIME B field
contains a value of dRingBufferRTCB. See [5.7] for details.

 The DEVICE TIME field contains the time set based on the UFS device’s internal timer when
command received. Due to internal operations of the UFS device, there is a possibility of
inaccurate time information. In the case of a UFS device without an internal timer, the value
shall be set to an Invalid Value (FFFF FFFFh).

 The COMMAND STATE field contains the status of command processing.

 This field can be set to one of the following values:


- 00h (DORMANT) : Command is received but not yet started
- 01h (ENABLED) : Command is being executed
- 02h (ABORTING) : Command is being aborted
- 03h (ERROR) : I/O error occurs during command execution
- FFh (END) : Command is completed

 The RESPONSE field contains response value in COMMAND UPIU, QUERY REQUEST
UPIU, TASK MANAGEMENT UPIU.

 The STATUS field contains status value in COMMAND UPIU.

 The RESPONSE, STATUS fields are valid only when COMMAND STATE is END (FFh).

 The SENSE KEY field contains a particular type of error.

 The ASC(ADDITIONAL SENSE CODE) field contains more specific error code.

 The ASCQ(ADDITIONAL SENSE CODE QUALIFIER) field qualifies the Additional Sense
Code.

 The STATUS, SENSE KEY, ASC, ASCQ fields are valid only when the transaction code of
UPIU is COMMAND.

 The SENSE KEY, ASC, ASCQ fields are valid only when the STATUS is CHECK
CONDITION (02h).

 The UPIU field contains the UPIU which is transferred by the host.

6.1.1.3 Retrieving command history with the READ BUFFER command


Command history retrieve operation uses the following mechanism.
1) Device failure is detected while the COMMAND HISTORY RECORD is enabled. Host may nee
d to enter Vendor Mode to retrieve the command history.

2) Host retrieves the command history by sending a READ BUFFER command as follow: MODE =
UFS Ring Buffer Specification 1.0.1G11 [텍스트 입력] CONFIDENTIAL
1Dh, BUFFER ID = 00h or 01h, BUFFER OFFSET = Start offset in byte, ALLOCATION LEN
GTH = Transferred Data length.

3) Host sends one or more READ BUFFER commands with BUFFER OFFSET set to the start byte
offset. During the command history retrieval, it is recommended that host does not send any nor
mal request other than READ BUFFER command because the other normal request could change
the command history information which is being retrieved.

4) I f t h e r e i s n o c o m ma n d history a t t h e t i me o f R E A D B U F F E R r e q u e s t , t h e
COMMAND HISTORY DATA LENGTH shall be set zero.

6.1.1.4 Read Buffer Command Status Response


 If all requested data is successfully read and transferred, the READ BUFFER command will
terminate with a STATUS response of GOOD
 Failure can occur for numerous reasons. When the READ BUFFER command fails a STATUS
response of CHECK CONDITION will be returned along with an appropriate SENSE KEY, see
follow for further details.
o ILLEGAL REQUEST
 INVALID FIELD IN CDB : Invalid MODE, BUFFER ID(Not 00h or 01h), BUFFER
OFFSET(Larger than wMaxCommandHistorySize in geometry descriptor), ALLOCATION
LENGTH(Equals to zero).
o VENDOR SPECIFIC
 The UFS host requests Non-Volatile Command History, but UFS device can no longer store
it, so there is no data to transfer.
UFS Ring Buffer Specification 1.0.1G [텍스트 입력] CONFIDENTIAL

7 UFS DESCRIPTORS, FLAGS AND ATTRIBUTES

7.1 DEVICE DESCRIPTOR for Ring Buffer


To get the parameter related with Ring Buffer, the host must set the SELECTOR = 01h when reading the
device descriptor.

DEVICE DESCRIPTOR
User
Offset Size Name MDV Description
Conf.
00h 1 bLength 5Fh No Size of this descriptor
Extended UFS Features Support
This field indicates which features are
supported by the device. A feature is
supported if the related bit is set to one.
bit[0]: Field Firmware Update (FFU)
bit[1]: Production State Awareness (PSA)
bit[2]: Device Life Span
bit[3]: Refresh Operation
bit[4]: TOO_HIGH_TEMPERATURE
dExtendedUFS Device
4Fh 4 No bit[5]: TOO_LOW_TEMPERATURE
FeaturesSupport specific
bit[6]: Extended Temperature
bit[7]: Host-aware Performance Booster
(HPB)
bit[8]: Turbo Write
bit[9]: Performance Throttling
bit[10]: Host Initiated Defrag
bit[11]: Ring Buffer
bit[12]: Chip Crack Detection
bit[13~31] : reserved
Ring Buffer Specification Version
bits[15:8] = Major Version in BCD format
wRingBuffer Device
5Bh 2 No bits[7:4] = Minor Version in BCD format
Version specific
bits[3:0] = Version suffix in BCD format
Example: version 1.00 = 0100h
5Dh 2 Reserved Reserved for Samsung Extended Features
UFS Ring Buffer Specification 1.0.1G11 [텍스트 입력] CONFIDENTIAL
7.2 GEOMETRY DESCRIPTOR for Ring Buffer
To get the parameter related with Ring Buffer, the host must set the SELECTOR = 01h when reading the
geometry descriptor.

GEOMETRY DESCRIPTOR

Offset Size Name Value Description

00h 1 bLength 59h Size of this descriptor

wMaxCommandHistory Device Max. Command History Record buffer size


57h 2
BufferSize specific Value expressed in unit of 512 bytes.

7.3 FLAGS for Ring Buffer

FLAGS
Type1
IDN Name Type # Ind.2 Default Description Notes
3
# Sel.
Command History Record
Enable.
This flag shall only be set when
the command queue of all logical
units are empty. The UFS device
shall set
fCommandHistoryRecordEn to
fCommand History Read / zero in the event of power cycle
12h D 0 or hardware reset. 𝑁𝑜𝑡𝑒 2
RecordEn Volatile
0b: The UFS device shall not
record command log for the
host during executing
command.
1b: The UFS device shall recor
d command log for the host du
ring executing command.
NOTE 1 The type “D” identifies a device level flag, while the type “A” identifies an array of flags. If Type = “D”, the flag is
addressed setting INDEX = 00h and SELECTOR = 00h.
NOTE 2 Operations to access this field shall request with Selector = 01h in Query Request
UFS Ring Buffer Specification 1.0.1G [텍스트 입력] CONFIDENTIAL

7.4 ATTRIBUTES for Ring Buffer

ATTRIBUTES
Access
IDN Name Size Type1 MDV2 Description Notes
Property
RTC set by Host
dRingBuffer Write only / 4 This value is set to Host Time
22h D 0000h 𝑁𝑜𝑡𝑒 3
RTCA Volatile bytes A in COMMAND HISTORY
block descriptor
RTC set by Host
dRingBuffer Write only / 4 This value is set to Host Time
23h D 0000h 𝑁𝑜𝑡𝑒 3
RTCB Volatile bytes B in COMMAND HISTORY
block descriptor
NOTE 1 The type “D” identifies a device level attribute, while the type “A” identifies an array of attributes. If Type = “D”, the
attribute is addressed setting INDEX = 00h and SELECTOR = 00h.
NOTE 2 The column “MDV” (Manufacturer Default Value) specifies attribute values after device manufacturing.
NOTE 3 Operations to access this field shall request with Selector = 01h in Query Request.
UFS Ring Buffer Specification 1.0.1G11 [텍스트 입력] CONFIDENTIAL

SAMSUNG

You might also like