SAS学习笔记

2023-05-16

术语解释

  • 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.).
  • ref:https://www.jianshu.com/p/0f4333a5f1af

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的层次示意图,可以一目了然地看出个层次之间的关系。
在这里插入图片描述

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的格式如下:
在这里插入图片描述

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信号的示意图:

在这里插入图片描述

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信号包括一系列的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.

在这里插入图片描述
设备上电或者被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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

SAS学习笔记 的相关文章

随机推荐

  • 嵌入式Linux系统开发笔记(十六)

    根文件系统rootfs启动验证测试 接下来我们使用测试一下前面创建好的根文件系统 rootfs xff0c 测试方法使用 NFS 挂载 6 1 检查是否在Ubuntu主机中安装和开启了NFS服务 xff08 特别注意 xff1a nfs 配
  • 安卓5.0以上7.0以下使用Termux

    参考 xff1a https zhuanlan zhihu com p 400507701 说明 xff1a Termux支持5 0以上的安卓系统 Termux7 3版本之后 xff0c 仅支持7 0以上的安卓系统 1 安装Termux 设
  • 关于DSP的CCS6.0平台下的工程搭建(完全可移植)

    本工程以CCS6 0下新建TMS320F28335工程为例 xff0c 其他系列处理器工程搭建类似 xff0c 参考本例即可 工程搭建用到的F2833x TI官方库文件 下载链接 也可直接参考笔者搭建好CCS6 0的工程 下载链接 所建工程
  • STM32Fxx JTAG/SWD复用功能重映射

    问题描述 xff1a 在实验室调车过程中 xff0c 遇到的一个问题 xff1a 为了每次下载程序方便 xff0c 队员们往往会把 Jlink 插在板子上 xff0c 可是在调车过程中发现 xff0c 有时程序会莫名死掉 xff0c 而同样
  • VS2012编译RTKLIB——GNSS定位开源库

    RTKLIB 开源库 有着强大的 GPS 数据实时和后处理功能 xff0c 由于 笔者的毕业设计中需要对GPS 载波相位观测量进行 RTK 解算 xff0c 故而 xff0c 对 RTKLIB 开源库进行了学习与研究 RTKLIB 提供了很
  • 51单片机串行口波特率计算

    1 工作方式介绍 xff1a 方式 0 xff1a 这种工作方式比较特殊 xff0c 与常见的微型计算机的串行口不同 xff0c 它又叫 同步移位寄存器输出方式 在这种方式下 xff0c 数据从 RXD 端串行输出或输入 xff0c 同步信
  • 解决HTTPS证书安全检测时提示 PCI DSS 不合规问题

    解决HTTPS证书安全检测时提示 PCI DSS 不合规问题 今天在进行HTTPS证书安全检测时 xff0c 提示PCI DSS不合规 经查询得知是因为SSL配置时启用了TLS1 0导致的 关于 PCI DSS 自2018年6月30日起 x
  • 数码管显示问题总结

    1 数码管显示原理 我们最常用的是七段式和八段式 LED 数码管 xff0c 八段比七段多了一个小数点 xff0c 其他的基本相同 所谓的八段就是指数码管里有八个小 LED 发光二极管 xff0c 通过控制不同的 LED 的亮灭来显示出不同
  • 多种方式登陆模块设计

    多种方式登陆模块设计 目录 多种方式登陆模块设计 目录参考了一些资料总结一下 1 使用 用户名邮箱手机号 密码 登陆2 第三方登陆 mob文档中还有以下描述 思考 参考了一些资料 知乎 第三方一键登录如何保证产品的唯一ID xff1f 开源
  • P1233 木棍加工

    题目描述 一堆木头棍子共有n根 xff0c 每根棍子的长度和宽度都是已知的 棍子可以被一台机器一个接一个地加工 机器处理一根棍子之前需要准备时间 准备时间是这样定义的 xff1a 第一根棍子的准备时间为1分钟 xff1b 如果刚处理完长度为
  • RUST 是 JavaScript 基建的未来

    这里写自定义目录标题 1 RUST 是 JavaScript 基建的未来1 1 Rust 是什么 1 2 Adoption1 3 从 JavaScript 到 Rust1 4 SWC1 5 Deno1 6 esbuild1 7 Rome1
  • VNC XRDP

    2个可以远程到linux上的远程桌面 xff0c 我都在我的raspi2上实现了 xff0c 这2个软件在我看来都差不多 xff0c 都可以满足我的要求 xff0c 只不过一个需要在windows上安装客户端VNC VIEWER xff0c
  • [Python学习]基础一: 循环

    34 if 语句可以嵌套 xff0c 但是不推荐 2 xff09 python 没有switch语句 3 xff09 循环语句 重复的执行某一个固定的动作或者任务 分类for while 4 xff09 for循环 for 变量 in 序列
  • springboot配置mysql数据库spring.datasource.url报错处理

    spring datasource url 61 jdbc mysql abc 3306 abcd useUnicode 61 true amp characterEncoding 61 utf8 很常规地配置了这个mysql的url后发现
  • 从jar包中读取文件的几种方式

    写在前面 本文会用到这篇文章 1 xff1a 从自身读取文件 1 1 xff1a 定义读取的文件 1 2 xff1a 读取代码 span class token annotation punctuation 64 SpringBootApp
  • Win10环境安装Anaconda(3-2021.05)+Tensorflow(2.6)

    Win10环境安装Anaconda 3 2021 05 43 Tensorflow 2 6 在学习机器学习的过程中会用到许多Python库 xff0c 例如tensorflow pandas等 xff0c 用到的时候单独去安装十分不方便 x
  • VIM中字符串的替换

    VIM中字符串的替换 字符串的替换 span class token number 1 span span class token function vim span 中可用 s 命令来替换字符串 xff0c 具体如下 xff1a s st
  • Golang依赖管理工具之go module(go1.11)

    大多数语言都会有包管理工具 xff0c 像Node有npm xff0c PHP有composer xff0c Java有Maven和Gradle 可是 xff0c Go语言一直缺乏一个官方的包管理 Dep被称为官方试验品official e
  • 一个linux驱动链表例子

    Free list初始化 span class token keyword struct span span class token class name list head span free list span class token
  • SAS学习笔记

    术语解释 Phy xff1a The term Phy is used in the standard with respect to the interface between a device and the service deliv