Skip to contentSkip to conversation

include/public: add command result definitions to vscsiif.h

PATCH Superseded Juergen Gross 2 participants 6 messages Feb 28, 2022 – Mar 16, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 include/public: add command result definitions to vscsiif.h

The result field of struct vscsiif_response is lacking a detailed definition. Today the Linux kernel internal scsi definitions are being used, which is not a sane interface for a PV device driver.

Add macros to change that by using today's values in the XEN namespace.

---
 xen/include/public/io/vscsiif.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
xen/include/public/io/vscsiif.h +27 -0
index c9ceb1884d..17a9033b43 100644
@@ -315,6 +315,33 @@ struct vscsiif_response {
 };
 typedef struct vscsiif_response vscsiif_response_t;
 
+/* SCSI I/O status from vscsiif_response->rslt */
+#define XEN_VSCSIIF_RSLT_STATUS(x)  (x & 0x00ff)
+
+/* Host I/O status from vscsiif_response->rslt */
+#define XEN_VSCSIIF_RSLT_HOST(x)    ((unsigned)x >> 16)
+#define XEN_VSCSIIF_RSLT_HOST_OK         0
+#define XEN_VSCSIIF_RSLT_HOST_NO_CONN    1 /* Couldn't connect before timeout */
+#define XEN_VSCSIIF_RSLT_HOST_BUS_BUSY   2 /* BUS busy through timeout */
+#define XEN_VSCSIIF_RSLT_HOST_TIME_OUT   3 /* TIMED OUT for other reason */
+#define XEN_VSCSIIF_RSLT_HOST_BAD_TARG   4 /* BAD target */
+#define XEN_VSCSIIF_RSLT_HOST_ABORT      5 /* Abort for some other reason */
+#define XEN_VSCSIIF_RSLT_HOST_PARITY     6 /* Parity error */
+#define XEN_VSCSIIF_RSLT_HOST_ERROR      7 /* Internal error */
+#define XEN_VSCSIIF_RSLT_HOST_RESET      8 /* Reset by somebody */
+#define XEN_VSCSIIF_RSLT_HOST_BAD_INTR   9 /* Unexpected interrupt */
+#define XEN_VSCSIIF_RSLT_HOST_PASSTHR   10 /* Force command past mid-layer */
+#define XEN_VSCSIIF_RSLT_HOST_SOFT_ERR  11 /* Retry requested */
+#define XEN_VSCSIIF_RSLT_HOST_IMM_RETR  12 /* Hidden retry requested */
+#define XEN_VSCSIIF_RSLT_HOST_REQUEUE   13 /* Requeue command requested */
+#define XEN_VSCSIIF_RSLT_HOST_DISRUPT   14 /* Transport error disrupted I/O */
+#define XEN_VSCSIIF_RSLT_HOST_FAILFAST  15 /* Transport class fastfailed */
+#define XEN_VSCSIIF_RSLT_HOST_TARG_FAIL 16 /* Permanent target failure */
+#define XEN_VSCSIIF_RSLT_HOST_NEX_FAIL  17 /* Permanent nexus failure on path */
+#define XEN_VSCSIIF_RSLT_HOST_NOMEM     18 /* Space allocation failed */
+#define XEN_VSCSIIF_RSLT_HOST_MED_ERR   19 /* Medium error */
+#define XEN_VSCSIIF_RSLT_HOST_MARGINAL  20 /* Transport marginal errors */
+
 DEFINE_RING_TYPES(vscsiif, struct vscsiif_request, struct vscsiif_response);
 
 
Signature · 1 line
2.34.1
#1 lore raw

Ping?

Quoted 49 lines · Juergen Gross

The result field of struct vscsiif_response is lacking a detailed definition. Today the Linux kernel internal scsi definitions are being used, which is not a sane interface for a PV device driver.

Add macros to change that by using today's values in the XEN namespace.

---
  xen/include/public/io/vscsiif.h | 27 +++++++++++++++++++++++++++
  1 file changed, 27 insertions(+)
xen/include/public/io/vscsiif.h +27 -0
index c9ceb1884d..17a9033b43 100644
@@ -315,6 +315,33 @@ struct vscsiif_response {
  };
  typedef struct vscsiif_response vscsiif_response_t;
 
+/* SCSI I/O status from vscsiif_response->rslt */
+#define XEN_VSCSIIF_RSLT_STATUS(x)  (x & 0x00ff)
+
+/* Host I/O status from vscsiif_response->rslt */
+#define XEN_VSCSIIF_RSLT_HOST(x)    ((unsigned)x >> 16)
+#define XEN_VSCSIIF_RSLT_HOST_OK         0
+#define XEN_VSCSIIF_RSLT_HOST_NO_CONN    1 /* Couldn't connect before timeout */
+#define XEN_VSCSIIF_RSLT_HOST_BUS_BUSY   2 /* BUS busy through timeout */
+#define XEN_VSCSIIF_RSLT_HOST_TIME_OUT   3 /* TIMED OUT for other reason */
+#define XEN_VSCSIIF_RSLT_HOST_BAD_TARG   4 /* BAD target */
+#define XEN_VSCSIIF_RSLT_HOST_ABORT      5 /* Abort for some other reason */
+#define XEN_VSCSIIF_RSLT_HOST_PARITY     6 /* Parity error */
+#define XEN_VSCSIIF_RSLT_HOST_ERROR      7 /* Internal error */
+#define XEN_VSCSIIF_RSLT_HOST_RESET      8 /* Reset by somebody */
+#define XEN_VSCSIIF_RSLT_HOST_BAD_INTR   9 /* Unexpected interrupt */
+#define XEN_VSCSIIF_RSLT_HOST_PASSTHR   10 /* Force command past mid-layer */
+#define XEN_VSCSIIF_RSLT_HOST_SOFT_ERR  11 /* Retry requested */
+#define XEN_VSCSIIF_RSLT_HOST_IMM_RETR  12 /* Hidden retry requested */
+#define XEN_VSCSIIF_RSLT_HOST_REQUEUE   13 /* Requeue command requested */
+#define XEN_VSCSIIF_RSLT_HOST_DISRUPT   14 /* Transport error disrupted I/O */
+#define XEN_VSCSIIF_RSLT_HOST_FAILFAST  15 /* Transport class fastfailed */
+#define XEN_VSCSIIF_RSLT_HOST_TARG_FAIL 16 /* Permanent target failure */
+#define XEN_VSCSIIF_RSLT_HOST_NEX_FAIL  17 /* Permanent nexus failure on path */
+#define XEN_VSCSIIF_RSLT_HOST_NOMEM     18 /* Space allocation failed */
+#define XEN_VSCSIIF_RSLT_HOST_MED_ERR   19 /* Medium error */
+#define XEN_VSCSIIF_RSLT_HOST_MARGINAL  20 /* Transport marginal errors */
+
  DEFINE_RING_TYPES(vscsiif, struct vscsiif_request, struct vscsiif_response);
 
 
#2 lore raw
In reply to Juergen Gross

xen/include/public/io/vscsiif.h struct vscsiif_response { · line 319

Quoted 8 lines · Juergen Gross
xen/include/public/io/vscsiif.h +2 -0
@@ -315,6 +315,33 @@ struct vscsiif_response {
 };
 typedef struct vscsiif_response vscsiif_response_t;
 
+/* SCSI I/O status from vscsiif_response->rslt */
+#define XEN_VSCSIIF_RSLT_STATUS(x)  (x & 0x00ff)

No #define-s for individual values for this? I see the backend use e.g. SUCCESS and FAILED, wherever these come from ...

Also please parenthesize x here and ...

xen/include/public/io/vscsiif.h struct vscsiif_response { · line 322

Quoted 2 lines
xen/include/public/io/vscsiif.h +2 -0
+/* Host I/O status from vscsiif_response->rslt */
+#define XEN_VSCSIIF_RSLT_HOST(x)    ((unsigned)x >> 16)

... here.

You cast to unsigned here, but rslt is a signed field. Is it really the entire upper 16 bits that are the host I/O status?

xen/include/public/io/vscsiif.h struct vscsiif_response { · line 327

Quoted 5 lines
xen/include/public/io/vscsiif.h +5 -0
+#define XEN_VSCSIIF_RSLT_HOST_OK         0
+#define XEN_VSCSIIF_RSLT_HOST_NO_CONN    1 /* Couldn't connect before timeout */
+#define XEN_VSCSIIF_RSLT_HOST_BUS_BUSY   2 /* BUS busy through timeout */
+#define XEN_VSCSIIF_RSLT_HOST_TIME_OUT   3 /* TIMED OUT for other reason */
+#define XEN_VSCSIIF_RSLT_HOST_BAD_TARG   4 /* BAD target */

Are the all-upper-case words really in need of mirroring this aspect from Linux? To me it gives the impression of this being acronyms of some sort at the first glance.

Quoted 6 lines
xen/include/public/io/vscsiif.h +6 -0
+#define XEN_VSCSIIF_RSLT_HOST_ABORT      5 /* Abort for some other reason */
+#define XEN_VSCSIIF_RSLT_HOST_PARITY     6 /* Parity error */
+#define XEN_VSCSIIF_RSLT_HOST_ERROR      7 /* Internal error */
+#define XEN_VSCSIIF_RSLT_HOST_RESET      8 /* Reset by somebody */
+#define XEN_VSCSIIF_RSLT_HOST_BAD_INTR   9 /* Unexpected interrupt */
+#define XEN_VSCSIIF_RSLT_HOST_PASSTHR   10 /* Force command past mid-layer */

xen/include/public/io/vscsiif.h struct vscsiif_response { · line 343

Quoted 10 lines
xen/include/public/io/vscsiif.h +10 -0
+#define XEN_VSCSIIF_RSLT_HOST_SOFT_ERR  11 /* Retry requested */
+#define XEN_VSCSIIF_RSLT_HOST_IMM_RETR  12 /* Hidden retry requested */
+#define XEN_VSCSIIF_RSLT_HOST_REQUEUE   13 /* Requeue command requested */
+#define XEN_VSCSIIF_RSLT_HOST_DISRUPT   14 /* Transport error disrupted I/O */
+#define XEN_VSCSIIF_RSLT_HOST_FAILFAST  15 /* Transport class fastfailed */
+#define XEN_VSCSIIF_RSLT_HOST_TARG_FAIL 16 /* Permanent target failure */
+#define XEN_VSCSIIF_RSLT_HOST_NEX_FAIL  17 /* Permanent nexus failure on path */
+#define XEN_VSCSIIF_RSLT_HOST_NOMEM     18 /* Space allocation failed */
+#define XEN_VSCSIIF_RSLT_HOST_MED_ERR   19 /* Medium error */
+#define XEN_VSCSIIF_RSLT_HOST_MARGINAL  20 /* Transport marginal errors */

Some of the name shortening that you did, comparing with the Linux names, has gone a little too far for my taste. But you're the maintainer ...

Jan

#3 lore raw
Quoted 7 lines · Jan Beulich
Quoted 6 lines · Juergen Gross
xen/include/public/io/vscsiif.h +0 -0
@@ -315,6 +315,33 @@ struct vscsiif_response {
  };
  typedef struct vscsiif_response vscsiif_response_t;
 
Quoted 5 lines

xen/include/public/io/vscsiif.h struct vscsiif_response { · line 319

Quoted 2 lines
xen/include/public/io/vscsiif.h +2 -0
+/* SCSI I/O status from vscsiif_response->rslt */
+#define XEN_VSCSIIF_RSLT_STATUS(x)  (x & 0x00ff)

No #define-s for individual values for this? I see the backend use e.g. SUCCESS and FAILED, wherever these come from ...

Oh, right, those are being used for the reset actions. Thanks for spotting.

The "normal" request result values are defined at the SCSI layer.

Quoted 6 lines

Also please parenthesize x here and ...

xen/include/public/io/vscsiif.h struct vscsiif_response { · line 322

Quoted 2 lines
xen/include/public/io/vscsiif.h +2 -0
+/* Host I/O status from vscsiif_response->rslt */
+#define XEN_VSCSIIF_RSLT_HOST(x)    ((unsigned)x >> 16)

... here.

Okay.

Quoted 2 lines

You cast to unsigned here, but rslt is a signed field. Is it really the entire upper 16 bits that are the host I/O status?

I thought I have seen it being used this way, but now I've found the definition of "host_byte()" indicating it is only 8 bits wide. Will change that.

Quoted 10 lines

xen/include/public/io/vscsiif.h struct vscsiif_response { · line 327

Quoted 6 lines
xen/include/public/io/vscsiif.h +5 -0
+#define XEN_VSCSIIF_RSLT_HOST_OK         0
+#define XEN_VSCSIIF_RSLT_HOST_NO_CONN    1 /* Couldn't connect before timeout */
+#define XEN_VSCSIIF_RSLT_HOST_BUS_BUSY   2 /* BUS busy through timeout */
+#define XEN_VSCSIIF_RSLT_HOST_TIME_OUT   3 /* TIMED OUT for other reason */
+#define XEN_VSCSIIF_RSLT_HOST_BAD_TARG   4 /* BAD target */

Are the all-upper-case words really in need of mirroring this aspect from Linux? To me it gives the impression of this being acronyms of some sort at the first glance.

The backend can return all these values, so I think I need to define them here.

Quoted 13 lines
Quoted 13 lines
xen/include/public/io/vscsiif.h +12 -0
+#define XEN_VSCSIIF_RSLT_HOST_ABORT      5 /* Abort for some other reason */
+#define XEN_VSCSIIF_RSLT_HOST_PARITY     6 /* Parity error */
+#define XEN_VSCSIIF_RSLT_HOST_ERROR      7 /* Internal error */
+#define XEN_VSCSIIF_RSLT_HOST_RESET      8 /* Reset by somebody */
+#define XEN_VSCSIIF_RSLT_HOST_BAD_INTR   9 /* Unexpected interrupt */
+#define XEN_VSCSIIF_RSLT_HOST_PASSTHR   10 /* Force command past mid-layer */
+#define XEN_VSCSIIF_RSLT_HOST_SOFT_ERR  11 /* Retry requested */
+#define XEN_VSCSIIF_RSLT_HOST_IMM_RETR  12 /* Hidden retry requested */
+#define XEN_VSCSIIF_RSLT_HOST_REQUEUE   13 /* Requeue command requested */
+#define XEN_VSCSIIF_RSLT_HOST_DISRUPT   14 /* Transport error disrupted I/O */
+#define XEN_VSCSIIF_RSLT_HOST_FAILFAST  15 /* Transport class fastfailed */
+#define XEN_VSCSIIF_RSLT_HOST_TARG_FAIL 16 /* Permanent target failure */
Quoted 8 lines

xen/include/public/io/vscsiif.h struct vscsiif_response { · line 343

Quoted 4 lines
xen/include/public/io/vscsiif.h +4 -0
+#define XEN_VSCSIIF_RSLT_HOST_NEX_FAIL  17 /* Permanent nexus failure on path */
+#define XEN_VSCSIIF_RSLT_HOST_NOMEM     18 /* Space allocation failed */
+#define XEN_VSCSIIF_RSLT_HOST_MED_ERR   19 /* Medium error */
+#define XEN_VSCSIIF_RSLT_HOST_MARGINAL  20 /* Transport marginal errors */

Some of the name shortening that you did, comparing with the Linux names, has gone a little too far for my taste. But you're the maintainer ...

There are basically the following alternatives:

- use longer names (using the Linux names would end up in e.g. XEN_VSCSIIF_RSLT_HOST_TRANSPORT_DISRUPTED, making it 10 chars longer
- drop some part of the common prefix, e.g. the "RSLT_HOST_" part
- keep it as is

I'm basically fine with any of those.

Juergen

#4 lore raw
Quoted 12 lines · Juergen Gross
Quoted 10 lines · Jan Beulich

xen/include/public/io/vscsiif.h struct vscsiif_response { · line 327

Quoted 5 lines · Juergen Gross
xen/include/public/io/vscsiif.h +5 -0
+#define XEN_VSCSIIF_RSLT_HOST_OK         0
+#define XEN_VSCSIIF_RSLT_HOST_NO_CONN    1 /* Couldn't connect before timeout */
+#define XEN_VSCSIIF_RSLT_HOST_BUS_BUSY   2 /* BUS busy through timeout */
+#define XEN_VSCSIIF_RSLT_HOST_TIME_OUT   3 /* TIMED OUT for other reason */
+#define XEN_VSCSIIF_RSLT_HOST_BAD_TARG   4 /* BAD target */

Are the all-upper-case words really in need of mirroring this aspect from Linux? To me it gives the impression of this being acronyms of some sort at the first glance.

Quoted 2 lines

The backend can return all these values, so I think I need to define them here.

Oh, I realize I didn't say so explicitly and hence what I said ended up being ambiguous: The remark was only about the all- upper-case words in the comments. I would think they can be spelled normally.

Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
xen/include/public/io/vscsiif.h +12 -0
+#define XEN_VSCSIIF_RSLT_HOST_ABORT      5 /* Abort for some other reason */
+#define XEN_VSCSIIF_RSLT_HOST_PARITY     6 /* Parity error */
+#define XEN_VSCSIIF_RSLT_HOST_ERROR      7 /* Internal error */
+#define XEN_VSCSIIF_RSLT_HOST_RESET      8 /* Reset by somebody */
+#define XEN_VSCSIIF_RSLT_HOST_BAD_INTR   9 /* Unexpected interrupt */
+#define XEN_VSCSIIF_RSLT_HOST_PASSTHR   10 /* Force command past mid-layer */
+#define XEN_VSCSIIF_RSLT_HOST_SOFT_ERR  11 /* Retry requested */
+#define XEN_VSCSIIF_RSLT_HOST_IMM_RETR  12 /* Hidden retry requested */
+#define XEN_VSCSIIF_RSLT_HOST_REQUEUE   13 /* Requeue command requested */
+#define XEN_VSCSIIF_RSLT_HOST_DISRUPT   14 /* Transport error disrupted I/O */
+#define XEN_VSCSIIF_RSLT_HOST_FAILFAST  15 /* Transport class fastfailed */
+#define XEN_VSCSIIF_RSLT_HOST_TARG_FAIL 16 /* Permanent target failure */
Quoted 8 lines

xen/include/public/io/vscsiif.h struct vscsiif_response { · line 343

Quoted 4 lines
xen/include/public/io/vscsiif.h +4 -0
+#define XEN_VSCSIIF_RSLT_HOST_NEX_FAIL  17 /* Permanent nexus failure on path */
+#define XEN_VSCSIIF_RSLT_HOST_NOMEM     18 /* Space allocation failed */
+#define XEN_VSCSIIF_RSLT_HOST_MED_ERR   19 /* Medium error */
+#define XEN_VSCSIIF_RSLT_HOST_MARGINAL  20 /* Transport marginal errors */

Some of the name shortening that you did, comparing with the Linux names, has gone a little too far for my taste. But you're the maintainer ...

Quoted 8 lines

There are basically the following alternatives:

- use longer names (using the Linux names would end up in e.g. XEN_VSCSIIF_RSLT_HOST_TRANSPORT_DISRUPTED, making it 10 chars longer
- drop some part of the common prefix, e.g. the "RSLT_HOST_" part
- keep it as is

I'm basically fine with any of those.

My personal preference would be in the order you named the alternatives, perhaps with prepending them by "use longer names, but in extreme cases not quite as long as Linux'es".

Jan

#5 lore raw
Quoted 13 lines · Jan Beulich
Quoted 12 lines · Juergen Gross
Quoted 10 lines · Jan Beulich

xen/include/public/io/vscsiif.h struct vscsiif_response { · line 327

Quoted 5 lines · Juergen Gross
xen/include/public/io/vscsiif.h +5 -0
+#define XEN_VSCSIIF_RSLT_HOST_OK         0
+#define XEN_VSCSIIF_RSLT_HOST_NO_CONN    1 /* Couldn't connect before timeout */
+#define XEN_VSCSIIF_RSLT_HOST_BUS_BUSY   2 /* BUS busy through timeout */
+#define XEN_VSCSIIF_RSLT_HOST_TIME_OUT   3 /* TIMED OUT for other reason */
+#define XEN_VSCSIIF_RSLT_HOST_BAD_TARG   4 /* BAD target */

Are the all-upper-case words really in need of mirroring this aspect from Linux? To me it gives the impression of this being acronyms of some sort at the first glance.

Quoted 7 lines
Quoted 2 lines

The backend can return all these values, so I think I need to define them here.

Oh, I realize I didn't say so explicitly and hence what I said ended up being ambiguous: The remark was only about the all- upper-case words in the comments. I would think they can be spelled normally.

Ah, okay. :-)

Will change that.

Quoted 29 lines
Quoted 29 lines
Quoted 13 lines
Quoted 13 lines
xen/include/public/io/vscsiif.h +12 -0
+#define XEN_VSCSIIF_RSLT_HOST_ABORT      5 /* Abort for some other reason */
+#define XEN_VSCSIIF_RSLT_HOST_PARITY     6 /* Parity error */
+#define XEN_VSCSIIF_RSLT_HOST_ERROR      7 /* Internal error */
+#define XEN_VSCSIIF_RSLT_HOST_RESET      8 /* Reset by somebody */
+#define XEN_VSCSIIF_RSLT_HOST_BAD_INTR   9 /* Unexpected interrupt */
+#define XEN_VSCSIIF_RSLT_HOST_PASSTHR   10 /* Force command past mid-layer */
+#define XEN_VSCSIIF_RSLT_HOST_SOFT_ERR  11 /* Retry requested */
+#define XEN_VSCSIIF_RSLT_HOST_IMM_RETR  12 /* Hidden retry requested */
+#define XEN_VSCSIIF_RSLT_HOST_REQUEUE   13 /* Requeue command requested */
+#define XEN_VSCSIIF_RSLT_HOST_DISRUPT   14 /* Transport error disrupted I/O */
+#define XEN_VSCSIIF_RSLT_HOST_FAILFAST  15 /* Transport class fastfailed */
+#define XEN_VSCSIIF_RSLT_HOST_TARG_FAIL 16 /* Permanent target failure */
Quoted 8 lines

xen/include/public/io/vscsiif.h struct vscsiif_response { · line 343

Quoted 4 lines
xen/include/public/io/vscsiif.h +4 -0
+#define XEN_VSCSIIF_RSLT_HOST_NEX_FAIL  17 /* Permanent nexus failure on path */
+#define XEN_VSCSIIF_RSLT_HOST_NOMEM     18 /* Space allocation failed */
+#define XEN_VSCSIIF_RSLT_HOST_MED_ERR   19 /* Medium error */
+#define XEN_VSCSIIF_RSLT_HOST_MARGINAL  20 /* Transport marginal errors */

Some of the name shortening that you did, comparing with the Linux names, has gone a little too far for my taste. But you're the maintainer ...

There are basically the following alternatives:

- use longer names (using the Linux names would end up in e.g. XEN_VSCSIIF_RSLT_HOST_TRANSPORT_DISRUPTED, making it 10 chars longer
- drop some part of the common prefix, e.g. the "RSLT_HOST_" part
- keep it as is

Quoted 5 lines
Quoted 1 line

I'm basically fine with any of those.

My personal preference would be in the order you named the alternatives, perhaps with prepending them by "use longer names, but in extreme cases not quite as long as Linux'es".

Okay, fine with me.

Juergen