0

I am very new to AIX, I found a command in AIX, lsattr, which is helpful to get the SCSI id and LUN id of a device. I can not understand how to interpret the value of SCSI id and LUN id. Here is a sample output:


bash-4.2# lsattr -El hdisk693
.......
lun_id        0x25f000000000000             Logical Unit Number ID           False
scsi_id       0x21300                       SCSI ID                          False
.......

I have skipped the lines that are not relevant.

1) The LUN id is 0x25f000000000000 which is huge, read in some blogs that we have to right shift this by 48 bits to get the actual value, where is this documented?

2) Also what about the SCSI id, even this value looks huge, 0x21300

Can someone please help me on this?

Thanks & Regards,

Arun Vijapur

arun_vj
  • 123
  • 1
  • 3
  • 13

2 Answers2

0

The LUN is 8 bytes. There are 4 forms and those forms are given in the high order 2 bits of the LUN. When people say to shift it right 48 bits that is because they are assuming the "Single Level LUN Structure" which is what your LUN is.

It gets relatively complex. See sam5r14.pdf, section 4.7. You can get all the the SCSI specs here: http://www.t10.org/drafts.htm.

eddyq
  • 879
  • 1
  • 13
  • 25
  • First of all thank you for the reply. Now I understand why we should shift 48 bits. But shifting 48 bits is true only in case of "Single level LUN structure using peripheral device addressing method". How do I know which LUN structure is being used, Single Level or Complex, and which addressing method is being used, peripheral device, flat space, extended flat space or long extended flat space? – arun_vj Aug 27 '13 at 08:31
  • It is a bit complex but I will try to reduce it: – eddyq Sep 02 '13 at 18:55
  • Below are some snips from my SCSI target that may help. I had to use several comments due to the length ` struct { // Method 1 - Flat Space Addressing Method (14 bit LUN) // | 7-6 | 5-0 | // +-------------------+---------------------------+ // |Address Method(01b)| High Flat Space LUN | // +-----------------------------------------------+ // | Flat Space LUN (0000h to 3FFFh) | // +-------------------+---------------------------+ byte MethodAndHighLun; byte LowLun; byte Reserved[6]; } Method1; ` – eddyq Sep 02 '13 at 19:25
  • ` struct { // Method 2 - Logical Unit Addressing Method // | 7-6 | 5-0 | // +-------------------+---------------------------+ // |Address Method(10b)| Target | // +-----------------------------------------------+ // | Bus (7-5) | LUN (4-0) | // +-------------------+---------------------------+ byte MethodAndTarget; byte BusAndLun[7]; } Method2; ` – eddyq Sep 02 '13 at 19:32
  • ` struct { // Method 3 - Extended Logical Unit Addressing // | 7-6 | 5-4 | 3-0 | // +-------------------+----------------------------+ // |Address Method(11b)| Length |Extended Addr Meth| // +------------------------------------------------+ // | Extended address method specific (7 bytes) | // +------------------------------------------------+ byte MethodEtc; byte MethodSpecific[7]; } Method3; ` – eddyq Sep 02 '13 at 19:34
  • ' struct { // Method 0 - Peripheral Device Addressing Method (8 bit LUN) // | 7-6 | 5-0 | // +-------------------+---------------------------+ // |Address Method(00b)| Bus Identifier (00h) | // +-----------------------------------------------+ // | Single Level LUN (00h to FFh) | // +-------------------+---------------------------+ byte MethodAndBus; byte Lun8; byte Reserved[6]; } Method0; ' – eddyq Sep 02 '13 at 19:35
  • The last one (method 0) is the one that most targets use. Usually you don't need to worry about the format because the acceptable form is given in the REPORT LUNS CDB. Then you just use the 64 bits that the target gives you in that CDB. (sorry about the format of my answers but I could not figure out how to format it as code). Just copy/paste these snips to a text editor and add a LF before each //. Then it will make more sense. – eddyq Sep 02 '13 at 19:37
  • oops, "LF" dates me ... I mean "NL". – eddyq Sep 02 '13 at 19:40
  • So if you are used to the old 8 bit LUNs then that is just the 2nd byte when the 1st byte is 00. – eddyq Sep 02 '13 at 19:43
  • Thanks a lot user215779, I don't know your name :) I understand the code that you have pasted. I have to figure out a couple of things. What I understand from Method 0 structure is that a LUN is represented by 1 byte, so the max value a LUN can have is 0XFF or decimal 255, but my host shows me LUN ID more than that. I will confirm it tomorrow. Thank you once again for the detailed explanation. – arun_vj Sep 04 '13 at 14:06
0

Here is my answer in a readable form. Please see my comment above for more information.

typedef struct scsi_long_lun_t

{

   union
   {

      struct
      {

         // Method 0 - Peripheral Device Addressing Method (8 bit LUN)

         // |        7-6        |            5-0            |
         // +-------------------+---------------------------+
         // |Address Method(00b)|    Bus Identifier (00h)   |
         // +-----------------------------------------------+
         // |       Single Level LUN (00h to FFh)           |
         // +-------------------+---------------------------+
         byte   MethodAndBus;
         byte   Lun8;
         byte   Reserved[6];
      } Method0;

      struct
      {
         //  Method 1 - Flat Space Addressing Method (14 bit LUN)

         // |        7-6        |            5-0            |
         // +-------------------+---------------------------+
         // |Address Method(01b)|   High Flat Space LUN     |
         // +-----------------------------------------------+
         // |      Flat Space LUN (0000h to 3FFFh)          |
         // +-------------------+---------------------------+
         byte   MethodAndHighLun;
         byte   LowLun;
         byte   Reserved[6];
      } Method1;

      struct
      {
         //  Method 2 - Logical Unit Addressing Method

         // |        7-6        |            5-0            |
         // +-------------------+---------------------------+
         // |Address Method(10b)|          Target           |
         // +-----------------------------------------------+
         // |     Bus (7-5)        |       LUN (4-0)        |
         // +-------------------+---------------------------+
         byte   MethodAndTarget;
         byte   BusAndLun[7];
      } Method2;

      struct
      {

         //  Method 3 - Extended Logical Unit Addressing

         // |        7-6        |  5-4    |      3-0         |
         // +-------------------+----------------------------+
         // |Address Method(11b)| Length  |Extended Addr Meth|
         // +------------------------------------------------+
         // |  Extended address method specific (7 bytes)    |
         // +------------------------------------------------+
         byte  MethodEtc;
         byte  MethodSpecific[7];
      } Method3;

   } u;

} scsi_long_lun_t;
bummi
  • 27,123
  • 14
  • 62
  • 101
eddyq
  • 879
  • 1
  • 13
  • 25