开场白:
个人觉得整个SAS协议族比较庞大,有很多概念比较难以理解,只能在工作中一边研究实际的代码,一边详读协议。这样才能更好的理解SAS协议。
根据代码来理解协议是最好的方法,想想所有的协议都是为了传输数据,通信而从在的,理解了双方之间的通信格式,就能理解通信的内容。
1:Transport layer overview
The transport layer defines frame formats and how frames are
processed by this layer. Transport layer state machines interface to the
application layer and port layer and
construct and parse frame contents. For SSP, the transport
layer only receives frames from the port layer for which an ACK is going
to be transmitted by the link layer.
SAS中的此层主要用来定义帧数据格式及帧是如何传输解析的。
在此层主要分为三种帧格式:SSP,STP,SMP。这三个数据帧很重要,来进行数据控制和状态信息获取。
2:SSP transport layer
SSP帧格式有以下几种:
上面定义了5种帧格式,上面的定义可知道数据的传输方向,initiator到target还是target到initiator,及每种帧的作用。
其中重要的有 command data ,task 任务帧,因为在initiator和target进行数据传输不可缺少。
在LSI的代码中帧格式定义如下:
-
-
-
- typedef union _SAS_IU
- {
- COMMAND_IU CommandIU;
- TASK_IU TaskIU;
- XFER_RDY_IU XferRdyIU;
- DATA_IU DataIU;
- RESPONSE_IU ResponseIU;
- } SAS_IU, *PTR_SAS_IU;
2.1 command帧
命令帧的定义:A COMMAND frame is sent by an SSP initiator port to request
that a command be processed by the device server in a logical unit .
即command帧有SSPinitiator端口发送来请求服务端的命令处理。
上面帧格式中重要的就是CDB数据段,CDB包含了SPC中定义的命令,如send diagnostic,receivediagnostic等。
一个完整的SSP数据包格式定义如下:代码表示更形象。
- typedef struct _SSP_FRAME
- {
- U8 FrameType;
- HASHED_SAS_ADDRESS HashedDestinationSASAddress;
- U8 Reserved04;
- HASHED_SAS_ADDRESS HashedSourceSASAddress;
- U8 Reserved08;
- U8 Reserved09;
- #ifdef PPC /* PowerPC (SAS1078) */
- U8 Reserved0ABits2to7 :6;
- U8 Retransmit :1;
- U8 Reserved0ABit0 :1;
- U8 Reserved0BBits2to7 :6;
- U8 NumberOfFillBytes :2;
- #else /* ARM (SAS1064/1068) */
- U32 Reserved0ABit0 :1;
- U32 Retransmit :1;
- U32 Reserved0ABits2to7 :6;
- U32 NumberOfFillBytes :2;
- U32 Reserved0BBits2to7 :6;
- #endif
- U32 Reserved0Cto0F;
- U16 Tag;
- U16 TargetPortTransferTag;
- U32 DataOffset;
- SAS_IU InformationUnit;
- } SSP_FRAME, *PTR_SSP_FRAME;
-
- 其中SAS_IU定有如下:
- typedef union _SAS_IU
- {
- COMMAND_IU CommandIU;
- TASK_IU TaskIU;
- XFER_RDY_IU XferRdyIU;
- DATA_IU DataIU;
- RESPONSE_IU ResponseIU;
- } SAS_IU, *PTR_SAS_IU;
- 下载以命令帧为列:
- COMMAND_IU定有如下:
- typedef struct _COMMAND_IU
- {
- SAS_LOGICAL_UNIT LogicalUnitNumber;
- U8 Reserved08;
- #ifdef PPC /* PowerPC (SAS1078) */
-
- U8 EnableFirstBurst :1;
- U8 TaskPriority :4;
- U8 TaskAttribute :3;
- U8 Reserved0A;
- U8 AdditionalCDBLength :6;
- U8 Reserved0BBits0to1 :2;
- #else /* ARM (SAS1064/1068) */
- U32 TaskAttribute :3;
- U8 TaskPriority :4;
- U8 EnableFirstBurst :1;
-
- U8 Reserved0A;
- U32 Reserved0BBits0to1 :2;
- U32 AdditionalCDBLength :6;
- #endif
- U8 CDB[SAS_COMMAND_IU_CDB_LENGTH];
- U32 AdditionalCDBBytes[1];
-
- } COMMAND_IU, *PTR_COMMAND_IU;
- COMMAND_IU中的CDB格式定义,以SPC中的INQUIRY command和receive diagnostic为例。
- INQUIRY command 定义如下:
- typedef struct
- {
- U8 OpCode;
- U8 LUN_EVPD;
- U8 EVPDPageCode;
- U16 AllocationLength;
- U8 ControlByte;
- } SCSI3_InquiryCDB_t;
- 上面定义的EVPDPageCode指的vital product data(VPD).定义及包括的VPD数据内容如下:
- The vital product data (VPD) page structure and the VPD pages (see table 517) that are applicable to all SCSI devices. The VPD pages are returned by an INQUIRY command with the EVPD bit set to
- one (see 6.4) and contain vendor specific product information about a logical unit and SCSI target device. The vital
- product data may include vendor identification, product identification, unit serial numbers, device operating definitions,
- manufacturing data, field replaceable unit information, and other vendor specific information.
-
- receive diagnostic 定义如下:
- typedef __packed struct _RECEIVE_DIAG_RESLT_COMMAND
- {
-
- U8 Cmd;
-
- U8 PCV:1;
- U8 Rsvd:7;
-
- U8 PageCode;
-
- U16 AllocLen;
-
- U8 Cntrl;
- }RECEIVE_DIAG_RESLT_COMMAND,*PTR_RECEIVE_DIAG_RESLT_COMMAND;
- RECEIVE_DIAG_RESLT_COMMAND中定义的:PageCode,常用就是SES中的pagecode,
- 如:
- 01h Configuration diagnostic page 就用此page code来获取SES中enclosure的配置信息
- 02h Enclosure Control diagnostic page.控制SES中的elements.如:fan,power。
- 上面的数据包分层机制与TCP/IP的类似,不同的层有不同的数据包头。
2.2 DATA frame 数据帧
During a write command or a
bidirectional command (see 8.2.3.4 and 8.2.3.6), one or more write DATA
frames are sent by an SSP initiator port to deliver write data.
During a read command or a bidirectional command (see 8.2.3.5 and
8.2.3.6), one or more read DATA frames are sent by an SSP target port to
deliver read data.
这个命令我没有搞清楚,如果哪位朋友知道的话,可以联系我给我讲讲万分感激。个人觉得,可能有错:主要就是用来读写数据,此些格式的数据读写磁盘来用的,使用
的命令定义在SBC中。
明天再继续
阅读(965) | 评论(0) | 转发(0) |