SAS学习笔记 您所在的位置:网站首页 SAS011G23J SAS学习笔记

SAS学习笔记

2023-12-04 00:54| 来源: 网络整理| 查看: 265

术语解释 Phy:The term Phy is used in the standard with respect to the interface between a device and the service delivery subsystem(e.g.: cable, backplane, etc.). SAS概述 Expander

Expander相当于是SAS domain里的路由表。 有两种Expander:Fanout Expander和Edge Expander。在一个SAS domain里最多只能有一个fanout expander,它一定处于整个domain的根部。SAS domain整个是一个树状的结构,所以位于根部的fanout expander它需要建立一个最大的路由表,包含整个domain的终端设备的SAS地址的路由表,这样它才知道应该把一个特定的请求路由到哪个Phy上。 另外还有一种expander叫edge expander,这种expander在一个domain里可以有多个。每个edge expander有一个subtractive port,这个port的作用是当遇到无法解析目的地的请求时,就从这个port路由出去。所以edge expander不需要维护所有终端设备的SAS地址的路由表,相比fanout expander它需要维护的路由表更小。一般edge expander的价格比fanout expander更便宜。

SAS层次架构(Layered Device Architecture)

下图是一个最简单的,只有一个窄口的SAS HBA的层次示意图,可以一目了然地看出个层次之间的关系。

Layers In a Device with One Narrow Port Application Layer

Application Layer包含三种协议:SSP(Serial SCSI Protocol),SMP(Serial Management Protocol)和STP(SATA Tunneled Protocol)。SAS initiator必须支持SMP,因为Discovery流程需要用到。 对于一个SAS target设备,可以仅实现SSP,因为SMP所需要的数据在mode pages里也有。 如果initiator支持SATA,那么三种协议都需要支持,因为它需要SMP来发现设备,需要STP来访问设备。

对于一个SAS HBA来说,Application Layer通常是主机上的驱动程序。

SSP(Serial SCSI Protocol)

SSP是Initiator和Target之间传输SCSI指令的传输协议。SSP会保障SCSI指令和数据以及对指令的响应成功地被传送和接收。SSP的帧类型,包含COMMAND、TASK、XFER_RDY、DATA、RESPONSE五种类型。

STP(SATA Tunneled Protocol)

STP是一套用于在Initiator和Target之间传送SATA指令的传输保障协议。由于SATA协议与SCSI协议是完全两套上层协议,不仅指令描述方式和结构不同,而且在底层传输的控制上也不同,所以STP就是将SATA协议的底层传输逻辑拿了过来,并将其承载于SAS底层进行传输。

SMP(SCSI Management Protocol)

SMP的目标之一是简化discovery的流程,使得initiators可以比较容易的获取设备和expanders的信息,例如设备类型、Phy的数量等等。

Port

A Port is a collection of one or more Phys, as well as the upper layers(Port Layer and Transport Layer) associated with that group of Phys. 可以看出Port是Phys的集合。每个Phy除了拥有SAS address之外,还拥有一个attached address,这个address是由Phy所连接的设备上报的。一个Port就包含了一个或若干个拥有同样SAS address和attached address的Phy。

Transport Layer

The main job of the Transport Layer is to construct the frames that will be sent over a connection.

Frame的格式如下:

Frame Construction Port Layer

Port Layer的主要功能是:

把Transport Layer的数据(Frames),按目标地址(destination address)放到不同的队列中。 如果到目标地址的连接(connection)还没有建立,向Link Layer请求建立连接,并负责失败后的重试。 如果到目标地址的连接已经建立,那么就从该连接将数据发送出去。 Phy

Phy指的是设备和传输系统之间的接口。SAS Phy必须支持SSP和SMP,可以选择性的支持STP。Phy可以是initiator Phy或者target Phy或者同时是。每个Phy拥有一个64位的SAS address,是出厂的时候设备供应商设置的,还有一个Phy identifier(从0开始,最大到127)。显然Phy identifier是设备内唯一的。

Link Layer

Link Layer的主要功能是建立和维护设备之间的连接。具体的:

Sending address frames to request connection establishment. Adding a CRC value to each packet for reliable detection of transmission errors. Genneration primitives as needed(for example, ACK and NAK for confirming reception of a frame) and adding them to the outbound flow of dwords. Checking and removing primitives from the incoming flow. Scrambling the transmitted bytes to reduce EMI. Handling the identification and hard reset protocols. Managing clock skew and rate matching.

对于SSP、STP和SMP来说,上面的任务处理起来不尽相同。例如对于SMP连接来说,连接建立好后,就只发送一次请求,接收一次数据,然后就连接就关闭了,所以也不需要什么流量控制或者ACK确认。

Phy Layer

The Phy Layer performs the following basic functions:

When the Link Layer provides the serial byte stream representing a fram to the Phy Layer, the Phy Layer's 8b/10b Encoder encodes each 8-bit byte into a 10-bit character. The resulting stream of 10-bit characters are supplied to a Serializer that generates a serial bit stream that is supplied to the differential transmitter in the Physical Layer. When the Physical Layer receives an inbound bit stream from the cables, its differential receiver receiver converts the differential signals into a digital bit stream and feeds it to the Deserializer in the Phy Layer. The 10-bit character stream produced by the Phy Layer's Deserializer is in turn fed to the 10-bit/8-bit Decoder which decodes the 10-bit characters back intto 8-bit bytes. The Phy Layer then feeds resulting byte stream to the Link Layer for further processing. The Phy Layer is also responsible for the generation of the special bit patterns used to initialize the two ends of the link immediately after a reset.

PHY层定义了8b10b编码和解码方式、组成dwords、OOB信号、PHY reset以及速率协商等过程。PHY层的主要作用是实现phy reset系列以及dword的同步。

8b10b编解码:目的是”直流平衡”,为的是不出现大量连续的0和1。8b10b编码的具体介绍可以看这里。

Dwords: 由4个字符组成。

Initialization

在数据可以在link上传输之前,link必须被初始化双方通信的速率、协议。这是通过一种称为OOB(Out Of Band) signaling的机制。 当设备reset之后,开始正式工作之前,只能处理OOB信号。OOB信号是一系列的脉冲信号,以信号之间的inactive的时间长短不同,来表示不同的信号,有点类似于Morse code。下图是一个OOB信号的示意图:

OOB Example Physical Layer

The Physical Layer is described in two parts:

The differential transmitter/receiver. For outgoing traffic, this handles the bit stream supplied by the Phy Layer and drives it out as a high-speed differential signal over the cable. When the bit stream representing a frame is received, the Physical Layer's differential receiver accepts the incoming bit stream and sources it to the Phy Layer for processing. The external, passive portion of a link, meaning the service delivery subsystem(e.g.: cables and connectors). It borrows elements from other serial transport designs and has been specifically designed to be phsically compatible with the SATA cable interface for the internal signaling environment. Unlike SATA, however, SAS cables are often designed with two sets of signals to support dual-ported drives. SAS初始化

There are two parts to initializing a SAS device. The first is hardware based and happens after a reset. Devices on either end of a link will automatically begin the process of detecting whether another device is present, whether it is a SAS or SATA device, and at what speeds the interface may be run. There are some steps that have to take place before a receiver can recognize dwords as information from the transmitter, and those are accomplished by the hardware initialization process. The second part is software initialization, and this optional step is under the control of the application software. It consists of reading configuration information from the device and writing values into that space to set up the desired parameters for the device.

SAS初始化包括了两个部分,一个是硬件初始化,一个是软件初始化。硬件初始化的主要目标是发现对端的设备的类型、速率等等,为接下来的传输做好准备。软件初始化是在应用程序的控制下进行的。

Hardware Initialization

The goal of hardware initiazation is to accomplish the following steps:

Detect the presence of an attached device and determine whether it is a SAS or SATA device. Negotiate the highest common transmission rate supported by both devices, using the proper method for a SAS or SATA device type. Identify information about the attached device, including its SAS address.

硬件初始化的流程,发生在SAS设备之间,理论上设备之间是对等的。但是实际上不同类型的设备的确是有些不一样。例如对于终端设备来说,它只需要在reset之后进行一次硬件初始化流程,如果没有成功,可以等待上层的重试。

OOB(Out of Band Signaling)

After a reset, receivers need a regular stream of incoming data so they can lock onto the embedded clock within it and recover meaningful symbols.

OOB是一种不出现在数据帧中的低速信号,如下图所示:

OOB Signaling

可以看出一个OOB信号包括一系列的burst、idle time和negation。接收端通过识别OOB信号的idle、negation时间的长短,来识别这些信号。OOB有几种信号:COMRESET/COMINIT、COMWAKE、COMSAS。COMRESET是由host发给device的,用于reset设备,COMINIT是由device发给host的。

OOB的主要目的就是识别设备的类型。另外OOB也可以让设备从省电状态唤醒。

Speed Negotiation

OOB完成后,我们就知道设备的类型了,接下来是协调传输速率。这里根据不同的设备类型,会有不同的流程。大体的流程就是双方用不同的速率进行通信,直到无法完成通信,这样双方就知道可以支持的速率有哪些了。

Identify Sequence

硬件初始化的最后一步是收集信息,包括设备的address和支持的协议。

OOB、Speed Negotiation共同组成 了Phy Reset Sequence。无论什么时候,当Phy被reset的时候,这个流程都会执行一遍。

Reset Sequences

SAS devices have more than one level of device reset, as listed here:

Hard Reset- restes the entire device ,including all the layers. Link Reset - resets only the link and Phy Layers of a device. This includes a Phy reset and sending of the Identification Sequence. Phy Reset - resets only the Phy Layer of a device and includes only OOB and speed negotiation. SAS Link Reset Sequence

设备上电或者被reset之后,就会执行SAS link reset流程,然后发现自己所连接的另外一端的设备的信息。通过这种设备之间两两互相连接、互相探测的机制,来组成整个SAS拓扑的信息。

Software Initialization

软件初始化主要就是initiator获取target/LUN的信息的过程,这些信息主要在各种mode page里,通过SCSI命令可以查询到。

Parameter Storage

LUN会保存3份参数:

Current:当前的参数,保存在RAM中。 Default:默认参数,保存在ROM中。 Saved:保存在非易失性内存中。初始化为Default,随着用户的修改而变化。可以用SCSI命令恢复。 Mode page Protocol-Specific Mode Page- Long Page Format

一些LUN会提供Protocol-Specific Mode Page, 这个page可以提供一些用于discovery流程的信息,这样LUN就不需要再支持SMP协议,减少一些成本。 这个Page提供了设备上所有phy的信息。

Discovery流程

The process by which initiators in a SAS network find out which devices are accessible in the system is called the Discovery Process.

The expanders themselves may or may not take an active role in the discovery process, depending on whether they were designed to be self-configuring. The reason for this option is that expanders are intended to be as simple and inexpensive as possible.

当各个phy都完成各自的link reset sequence后,每个设备都应该清楚自己所连接的其它设备的信息,包括设备类型、速率、SAS地址等等。这样我们初步的拓扑信息就有了,至少每个设备知道自己连接了什么别的设备。接下来initiator就可以通过这个初步的拓扑信息,一步步建立更完整的拓扑信息。拓扑信息主要就是expander上的路由表信息,路由表是SAS address到phy的映射关系,也就是给定一个SAS地址,expander知道这个SAS地址需要从哪个phy发送出去。

有些expander可以支持self-configuring,那么initiator就可以省点工作量。self-configuring相当于expander有能力可以建立自己的路由表。initiator通过向expander发送SMP REPORT GENERAL请求,来查询expander是否支持自配置。REPORT GENERAL请求的返回结果中,有一个Configurable bit,如果是1,表示上层可配置,如果是0,表示上层不可配置,也就是expander是自配置。REPORT GENERAL的返回结果不仅包括了是否自配置这样的信息,还包括了expander的Phy的最大数目。

如果expander支持自配置,说明它会自动建立它上面的路由表,initiator只需要等路由表建立完成后,向expander发送REPORT ROUTE INFORMATION请求来获取expander上的路由表。如果expander不支持自配置,那么initiator就需要逐步来建立expander上的路由表。Initiator通过向expander发送DISCOVERY请求,向expander获取某个Phy上的连接信息,然后按广度优先的方式不断重复这个过程,最终建立起expander上的路由表。Initiator通过发送SMP CONFIGURE ROUTE INFORMATION请求来设置路由表。最终为所有的expander设置好路由表,discovery的流程也就结束了

可以看出discovery的流程要求expander一定要支持SMP协议,而终端设备则不一定需要。

参考资料

《SAS Storage Architecture》 by Mike Jackson



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

      专题文章
        CopyRight 2018-2019 实验室设备网 版权所有