Chinaunix首页 | 论坛 | 博客
  • 博客访问: 136180
  • 博文数量: 79
  • 博客积分: 11
  • 博客等级: 民兵
  • 技术积分: 200
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-19 22:16
文章分类
文章存档

2015年(1)

2014年(9)

2013年(43)

2012年(26)

我的朋友

分类: LINUX

2013-10-31 23:22:53

开场白:

个人觉得整个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的代码中帧格式定义如下:

  1. /* 
  2.  * Union of all IUs 
  3.  */  
  4. typedef union _SAS_IU  
  5. {  
  6.     COMMAND_IU          CommandIU;  
  7.     TASK_IU             TaskIU;  
  8.     XFER_RDY_IU         XferRdyIU;  
  9.     DATA_IU             DataIU;  
  10.     RESPONSE_IU         ResponseIU;  
  11. } 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数据包格式定义如下:代码表示更形象。

  1. typedef struct _SSP_FRAME  
  2. {  
  3.     U8                      FrameType;                          /* 0x00 */  
  4.     HASHED_SAS_ADDRESS      HashedDestinationSASAddress;        /* 0x01 */  
  5.     U8                      Reserved04;                         /* 0x04 */  
  6.     HASHED_SAS_ADDRESS      HashedSourceSASAddress;             /* 0x05 */  
  7.     U8                      Reserved08;                         /* 0x08 */  
  8.     U8                      Reserved09;                         /* 0x09 */  
  9. #ifdef PPC         /* PowerPC (SAS1078) */  
  10.     U8                      Reserved0ABits2to7              :6; /* 0x0A */  
  11.     U8                      Retransmit                      :1;  
  12.     U8                      Reserved0ABit0                  :1;  
  13.     U8                      Reserved0BBits2to7              :6; /* 0x0B */  
  14.     U8                      NumberOfFillBytes               :2;  
  15. #else              /* ARM (SAS1064/1068) */  
  16.     U32                     Reserved0ABit0                  :1; /* 0x0A */  
  17.     U32                     Retransmit                      :1;  
  18.     U32                     Reserved0ABits2to7              :6;  
  19.     U32                     NumberOfFillBytes               :2; /* 0x0B */  
  20.     U32                     Reserved0BBits2to7              :6;  
  21. #endif  
  22.     U32                     Reserved0Cto0F;                     /* 0x0C */  
  23.     U16                     Tag;                                /* 0x10 */  
  24.     U16                     TargetPortTransferTag;              /* 0x12 */  
  25.     U32                     DataOffset;                         /* 0x14 */  
  26.     SAS_IU                  InformationUnit;                    /* 0x18 */  
  27. } SSP_FRAME, *PTR_SSP_FRAME; //格式可以参考:SPL中Table 117 — SSP frame format.  
  28.   
  29. 其中SAS_IU定有如下:  
  30. typedef union _SAS_IU  
  31. {  
  32.     COMMAND_IU          CommandIU;  
  33.     TASK_IU             TaskIU;  
  34.     XFER_RDY_IU         XferRdyIU;  
  35.     DATA_IU             DataIU;  
  36.     RESPONSE_IU         ResponseIU;  
  37. } SAS_IU, *PTR_SAS_IU;  
  38. 下载以命令帧为列:  
  39. COMMAND_IU定有如下:  
  40. typedef struct _COMMAND_IU  
  41. {  
  42.     SAS_LOGICAL_UNIT        LogicalUnitNumber;                  /* 0x00 */  
  43.     U8                      Reserved08;                         /* 0x08 */  
  44. #ifdef PPC         /* PowerPC (SAS1078) */  
  45.     //U8                    Reserved09Bits3to7              :5; /* 0x09 */  //Added EFB bit  
  46.     U8                      EnableFirstBurst                :1; /* 0x09 */  
  47.     U8                      TaskPriority                    :4;  
  48.     U8                      TaskAttribute                   :3;  
  49.     U8                      Reserved0A;                         /* 0x0A */  
  50.     U8                      AdditionalCDBLength             :6; /* 0x0B */  
  51.     U8                      Reserved0BBits0to1              :2;  
  52. #else              /* ARM (SAS1064/1068) */  
  53.     U32                     TaskAttribute                   :3; /* 0x09 */  
  54.     U8                      TaskPriority                    :4;  
  55.     U8                      EnableFirstBurst                :1;  
  56.     //U32                   Reserved09Bits3to7              :5;  
  57.     U8                      Reserved0A;                         /* 0x0A */  
  58.     U32                     Reserved0BBits0to1              :2; /* 0x0B */  
  59.     U32                     AdditionalCDBLength             :6;  
  60. #endif  
  61.     U8                      CDB[SAS_COMMAND_IU_CDB_LENGTH];     /* 0x0C */  
  62.     U32                     AdditionalCDBBytes[1];              /* 0x1C */  
  63.     /* Note: AdditionalCDBBytes is variable and may really be 0 to 0x3F dwords */  
  64. } COMMAND_IU, *PTR_COMMAND_IU;//格式定义可参考:SPCL中8.2.2.1 COMMAND frame  
  65. COMMAND_IU中的CDB格式定义,以SPC中的INQUIRY command和receive diagnostic为例。  
  66. INQUIRY command 定义如下:  
  67. typedef struct  
  68. {  
  69.     U8  OpCode;  
  70.     U8  LUN_EVPD;  
  71.     U8  EVPDPageCode;  
  72.     U16 AllocationLength;  
  73.     U8  ControlByte;  
  74. } SCSI3_InquiryCDB_t;  
  75. 上面定义的EVPDPageCode指的vital product data(VPD).定义及包括的VPD数据内容如下:  
  76. 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  
  77. one (see 6.4) and contain vendor specific product information about a logical unit and SCSI target device. The vital  
  78. product data may include vendor identification, product identification, unit serial numbers, device operating definitions,  
  79. manufacturing data, field replaceable unit information, and other vendor specific information.  
  80.   
  81. receive diagnostic 定义如下:  
  82. typedef __packed struct _RECEIVE_DIAG_RESLT_COMMAND  
  83. {  
  84.     /*Byte0*/  
  85.     U8 Cmd;  
  86.     /*Byte1*/  
  87.     U8 PCV:1;  
  88.     U8 Rsvd:7;  
  89.     /*Byte2*/  
  90.     U8 PageCode;    
  91.     /*Byte3&4*/  
  92.     U16 AllocLen;  
  93.     /*Byte5*/  
  94.     U8 Cntrl;  
  95. }RECEIVE_DIAG_RESLT_COMMAND,*PTR_RECEIVE_DIAG_RESLT_COMMAND;  
  96. RECEIVE_DIAG_RESLT_COMMAND中定义的:PageCode,常用就是SES中的pagecode,  
  97. 如:  
  98. 01h Configuration diagnostic page 就用此page code来获取SES中enclosure的配置信息  
  99. 02h Enclosure Control diagnostic page.控制SES中的elements.如:fan,power。  
  100. 上面的数据包分层机制与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中。

 明天再继续

阅读(877) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~