Blame SOURCES/sg_ses-1.45-page_control_data_args.patch

62c4c2
From a00692315686c7bc061010aa215bcb381181758f Mon Sep 17 00:00:00 2001
62c4c2
From: Douglas Gilbert <dgilbert@interlog.com>
62c4c2
Date: Wed, 10 Oct 2018 06:50:03 +0000
62c4c2
Subject: [PATCH] sg_ses: bug: --page= being overridden when --control and
62c4c2
 --data= also given; fix; sg_opcodes: expand MLU (18-102r0)
62c4c2
62c4c2
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@793 6180dd3e-e324-4e3e-922d-17de1ae2f315
62c4c2
62c4c2
diff --git a/src/sg_ses.c b/src/sg_ses.c
62c4c2
index abb1feac..0cce8bd1 100644
62c4c2
--- a/src/sg_ses.c
62c4c2
+++ b/src/sg_ses.c
62c4c2
@@ -70,7 +70,7 @@ static const char * version_str = "2.43 20180810";    /* ses4r02 */
62c4c2
 #define ELEM_DESC_DPC 0x7
62c4c2
 #define SHORT_ENC_STATUS_DPC 0x8
62c4c2
 #define ENC_BUSY_DPC 0x9
62c4c2
-#define ADD_ELEM_STATUS_DPC 0xa
62c4c2
+#define ADD_ELEM_STATUS_DPC 0xa /* Additional Element Status dpage code */
62c4c2
 #define SUBENC_HELP_TEXT_DPC 0xb
62c4c2
 #define SUBENC_STRING_DPC 0xc
62c4c2
 #define SUPPORTED_SES_DPC 0xd   /* should be 0x1 <= dpc <= 0x2f */
62c4c2
@@ -108,6 +108,7 @@ static const char * version_str = "2.43 20180810";    /* ses4r02 */
62c4c2
 #define SAS_CONNECTOR_ETC 0x19
62c4c2
 #define LAST_ETC SAS_CONNECTOR_ETC      /* adjust as necessary */
62c4c2
 
62c4c2
+#define TPROTO_PCIE_PS_NVME 1   /* NVMe regarded as subset of PCIe */
62c4c2
 #define NUM_ETC (LAST_ETC + 1)
62c4c2
 
62c4c2
 #define DEF_CLEAR_VAL 0
62c4c2
@@ -1378,7 +1379,8 @@ parse_cmd_line(struct opts_t *op, int argc, char *argv[])
62c4c2
             return SG_LIB_SYNTAX_ERROR;
62c4c2
         }
62c4c2
         op->do_raw = 0;
62c4c2
-        if (op->arr_len > 3) {
62c4c2
+	/* struct data_in_desc_t stuff does not apply when --control */
62c4c2
+        if (op->do_status && (op->arr_len > 3)) {
62c4c2
             int off;
62c4c2
             int pc = 0;
62c4c2
             const uint8_t * bp = op->data_arr + DATA_IN_OFF;
62c4c2
@@ -3476,9 +3478,9 @@ additional_elem_helper(const char * pad, const uint8_t * ae_bp,
62c4c2
         if (len < 6)
62c4c2
             break;
62c4c2
         pcie_pt = (ae_bp[5] >> 5) & 0x7;
62c4c2
-        if (1 == pcie_pt)
62c4c2
+        if (TPROTO_PCIE_PS_NVME == pcie_pt)
62c4c2
             printf("%sPCIe protocol type: NVMe\n", pad);
62c4c2
-        else {
62c4c2
+        else {  /* no others currently defined */
62c4c2
             printf("%sTransport protocol: PCIe subprotocol=0x%x not "
62c4c2
                    "decoded\n", pad, pcie_pt);
62c4c2
             if (op->verbose)
62c4c2
@@ -3490,7 +3492,7 @@ additional_elem_helper(const char * pad, const uint8_t * ae_bp,
62c4c2
                ae_bp[5] & 1);
62c4c2
         printf(", device slot number: %d\n", ae_bp[7]);
62c4c2
 
62c4c2
-        pcie_vid = sg_get_unaligned_le16(ae_bp + 10);
62c4c2
+        pcie_vid = sg_get_unaligned_le16(ae_bp + 10);   /* N.B. LE */
62c4c2
         printf("%sPCIe vendor id: 0x%" PRIx16 "%s\n", pad, pcie_vid,
62c4c2
                (0xffff == pcie_vid) ? " (not reported)" : "");
62c4c2
         printf("%sserial number: %.20s\n", pad, ae_bp + 12);
62c4c2
@@ -3505,14 +3507,14 @@ additional_elem_helper(const char * pad, const uint8_t * ae_bp,
62c4c2
                    (int)psn_valid, (int)bdf_valid, (int)cid_valid);
62c4c2
             if (cid_valid)      /* N.B. little endian */
62c4c2
                 printf("%s  controller id: 0x%" PRIx16 "\n", pad,
62c4c2
-                       sg_get_unaligned_le16(aep + 1));
62c4c2
+                       sg_get_unaligned_le16(aep + 1)); /* N.B. LEndian */
62c4c2
             if (bdf_valid)
62c4c2
                 printf("%s  bus number: 0x%x, device number: 0x%x, "
62c4c2
                        "function number: 0x%x\n", pad, aep[4],
62c4c2
                        (aep[5] >> 3) & 0x1f, 0x7 & aep[5]);
62c4c2
             if (psn_valid)      /* little endian, top 3 bits assumed zero */
62c4c2
                 printf("%s  physical slot number: 0x%" PRIx16 "\n", pad,
62c4c2
-                       0x1fff & sg_get_unaligned_le16(aep + 6));
62c4c2
+                       0x1fff & sg_get_unaligned_le16(aep + 6)); /* N.B. LE */
62c4c2
         }
62c4c2
         break;
62c4c2
     default:
62c4c2
@@ -3524,7 +3526,7 @@ additional_elem_helper(const char * pad, const uint8_t * ae_bp,
62c4c2
     }
62c4c2
 }
62c4c2
 
62c4c2
-/* ADD_ELEM_STATUS_DPC [0xa]
62c4c2
+/* ADD_ELEM_STATUS_DPC [0xa] Additional Element Status dpage
62c4c2
  * Previously called "Device element status descriptor". Changed "device"
62c4c2
  * to "additional" to allow for SAS expander and SATA devices */
62c4c2
 static void
62c4c2
@@ -5704,7 +5706,7 @@ main(int argc, char * argv[])
62c4c2
             uint16_t oacs;
62c4c2
 
62c4c2
             nvmsr = enc_stat_rsp[253];
62c4c2
-            oacs = sg_get_unaligned_le16(enc_stat_rsp + 256);
62c4c2
+            oacs = sg_get_unaligned_le16(enc_stat_rsp + 256);   /* N.B. LE */
62c4c2
             if (vb > 3)
62c4c2
                 pr2serr("NVMe Identify ctl response: nvmsr=%u, oacs=0x%x\n",
62c4c2
                         nvmsr, oacs);