Add XEN pvSCSI support
Subsystems (3)
[email protected]
maintainerv5 cover Add XEN pvSCSI support
This series adds XEN pvSCSI support. With pvSCSI it is possible to use physical SCSI devices from a XEN domain.
The support consists of a backend in the privileged Domain-0 doing the real I/O and a frontend in the unprivileged domU passing I/O-requests to the backend.
The code is taken (and adapted) from the original pvSCSI implementation done for Linux 2.6 in 2008 by Fujitsu.
[PATCH V5 1/5] xen/events: support threaded irqs for interdomain event channels [PATCH V5 2/5] Add XEN pvSCSI protocol description
[PATCH V5 3/5] Introduce xen-scsifront module
[PATCH V5 4/5] Introduce XEN scsiback module
[PATCH V5 5/5] add xen pvscsi maintainer
Changes in V5:
- Added patch to support threaded irqs for interdomain event channels
- several changes in xen-scsifront after comments from Christoph Hellwig
- several changes in xen-scsiback after comments from Christoph Hellwig
- several changes in xen-scsiback after comments from James Bottomley
Changes in V4:
- Re-add define for VSCSIIF_ACT_SCSI_SG_PRESET to vscsiif.h to indicate this action value should not be used in future enhancements
Changes in V3:
- added some comments to the protocol header file
- removed the CDB emulation from xen-scsiback, handled by core target infrastructure
- several changes in xen-scsifront after comments from Christoph Hellwig
Changes in V2:
- use core target infrastructure by backend instead of pure SCSI passthrough
- add support for larger SG lists by putting them in grant page(s)
- add command abort capability
[email protected]
maintainerPATCH v5 1/5 xen/events: support threaded irqs for interdomain event channels
From: Juergen Gross <[email protected]>
Export bind_interdomain_evtchn_to_irq() so drivers can use threaded interrupt handlers with:
irq = bind_interdomain_evtchn_to_irq(remote_dom, remote_port); if (irq < 0)
/* error */
ret = request_threaded_irq(...);
--- drivers/xen/events/events_base.c | 5 +++-- include/xen/events.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/xen/events/events_base.c +3 -2
@@ -900,8 +900,8 @@ static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)return irq; } -static int bind_interdomain_evtchn_to_irq (unsigned int remote_domain, -unsigned int remote_port) +int bind_interdomain_evtchn_to_irq (unsigned int remote_domain, +unsigned int remote_port) {struct evtchn_bind_interdomain bind_interdomain;int err;
@@ -914,6 +914,7 @@ static int bind_interdomain_evtchn_to_irq(unsigned int remote_domain,return err ? :bind_evtchn_to_irq (bind_interdomain.local_port); } +EXPORT_SYMBOL_GPL (bind_interdomain_evtchn_to_irq);static int find_virq (unsigned int virq,unsigned int cpu) {
include/xen/events.h +2 -0
@@ -28,6 +28,8 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,unsigned long irqflags, const char *devname, void *dev_id); +int bind_interdomain_evtchn_to_irq (unsigned int remote_domain, +unsigned int remote_port); int bind_interdomain_evtchn_to_irqhandler(unsigned int remote_domain, unsigned int remote_port, irq_handler_t handler,
Signature · 1 line
1.8.4.5
Re: [PATCH V5 1/5] xen/events: support threaded irqs for interdomain event channels
Quoted 5 lines · On Mon, Aug 18, 2014 at 11:31:46AM +0200, [email protected] wrote:
From: Juergen Gross <[email protected]>
Export
bind_interdomain_evtchn_to_irq()so drivers can use threaded interrupt handlers with:
Quoted 7 lines
irq =
bind_interdomain_evtchn_to_irq(remote_dom, remote_port); if (irq < 0)/* error */ret =
request_threaded_irq(...);Signed-off-by Juergen Gross <[email protected]>Acked-by David Vrabel <[email protected]>
Quoted 49 lines
--- drivers/xen/events/events_base.c | 5 +++-- include/xen/events.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-)drivers/xen/events/events_base.c +3
-2@@ -900,8 +900,8 @@ static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)return irq; } -static int bind_interdomain_evtchn_to_irq (unsigned int remote_domain, -unsigned int remote_port) +int bind_interdomain_evtchn_to_irq (unsigned int remote_domain, +unsigned int remote_port) {struct evtchn_bind_interdomain bind_interdomain;int err;@@ -914,6 +914,7 @@ static int bind_interdomain_evtchn_to_irq(unsigned int remote_domain,return err ? :bind_evtchn_to_irq (bind_interdomain.local_port); } +EXPORT_SYMBOL_GPL (bind_interdomain_evtchn_to_irq);static int find_virq (unsigned int virq,unsigned int cpu) {include/xen/events.h +2
-0@@ -28,6 +28,8 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,unsigned long irqflags, const char *devname, void *dev_id); +int bind_interdomain_evtchn_to_irq (unsigned int remote_domain, +unsigned int remote_port); int bind_interdomain_evtchn_to_irqhandler(unsigned int remote_domain, unsigned int remote_port, irq_handler_t handler,Signature · 7 lines
1.8.4.5 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH V5 1/5] xen/events: support threaded irqs for interdomain event channels
In reply to [email protected]Quoted 5 lines · On Mon, Aug 18, 2014 at 11:31:46AM +0200, [email protected] wrote:
From: Juergen Gross <[email protected]>
Export
bind_interdomain_evtchn_to_irq()so drivers can use threaded interrupt handlers with:
Quoted 7 lines
irq =
bind_interdomain_evtchn_to_irq(remote_dom, remote_port); if (irq < 0)/* error */ret =
request_threaded_irq(...);Signed-off-by Juergen Gross <[email protected]>Acked-by David Vrabel <[email protected]>
Quoted 49 lines
--- drivers/xen/events/events_base.c | 5 +++-- include/xen/events.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-)drivers/xen/events/events_base.c +3
-2@@ -900,8 +900,8 @@ static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)return irq; } -static int bind_interdomain_evtchn_to_irq (unsigned int remote_domain, -unsigned int remote_port) +int bind_interdomain_evtchn_to_irq (unsigned int remote_domain, +unsigned int remote_port) {struct evtchn_bind_interdomain bind_interdomain;int err;@@ -914,6 +914,7 @@ static int bind_interdomain_evtchn_to_irq(unsigned int remote_domain,return err ? :bind_evtchn_to_irq (bind_interdomain.local_port); } +EXPORT_SYMBOL_GPL (bind_interdomain_evtchn_to_irq);static int find_virq (unsigned int virq,unsigned int cpu) {include/xen/events.h +2
-0@@ -28,6 +28,8 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,unsigned long irqflags, const char *devname, void *dev_id); +int bind_interdomain_evtchn_to_irq (unsigned int remote_domain, +unsigned int remote_port); int bind_interdomain_evtchn_to_irqhandler(unsigned int remote_domain, unsigned int remote_port, irq_handler_t handler,Signature · 7 lines
1.8.4.5 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
[email protected]
maintainerPATCH v5 1/5 xen/events: support threaded irqs for interdomain event channels
In reply to [email protected]From: Juergen Gross <[email protected]>
Export bind_interdomain_evtchn_to_irq() so drivers can use threaded interrupt handlers with:
irq = bind_interdomain_evtchn_to_irq(remote_dom, remote_port); if (irq < 0)
/* error */
ret = request_threaded_irq(...);
--- drivers/xen/events/events_base.c | 5 +++-- include/xen/events.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/xen/events/events_base.c +3 -2
@@ -900,8 +900,8 @@ static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)return irq; } -static int bind_interdomain_evtchn_to_irq (unsigned int remote_domain, -unsigned int remote_port) +int bind_interdomain_evtchn_to_irq (unsigned int remote_domain, +unsigned int remote_port) {struct evtchn_bind_interdomain bind_interdomain;int err;
@@ -914,6 +914,7 @@ static int bind_interdomain_evtchn_to_irq(unsigned int remote_domain,return err ? :bind_evtchn_to_irq (bind_interdomain.local_port); } +EXPORT_SYMBOL_GPL (bind_interdomain_evtchn_to_irq);static int find_virq (unsigned int virq,unsigned int cpu) {
include/xen/events.h +2 -0
@@ -28,6 +28,8 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,unsigned long irqflags, const char *devname, void *dev_id); +int bind_interdomain_evtchn_to_irq (unsigned int remote_domain, +unsigned int remote_port); int bind_interdomain_evtchn_to_irqhandler(unsigned int remote_domain, unsigned int remote_port, irq_handler_t handler,
Signature · 1 line
1.8.4.5
[email protected]
maintainerPATCH v5 2/5 Add XEN pvSCSI protocol description
In reply to [email protected]From: Juergen Gross <[email protected]>
Add the definition of pvSCSI protocol used between the pvSCSI frontend in a XEN domU and the pvSCSI backend in a XEN driver domain (usually Dom0).
This header was originally provided by Fujitsu for XEN based on Linux 2.6.18. Changes are:
- added comment
- adapt to Linux style guide
- add support for larger SG-lists by putting them in an own granted page
- remove stale definitions
--- include/xen/interface/io/vscsiif.h | 214 +++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 include/xen/interface/io/vscsiif.h
include/xen/interface/io/vscsiif.h new file +214 -0
@@ -0,0 +1,214 @@ +/****************************************************************************** +* vscsiif.h +* +* Based on the blkif.h code. +* +* This interface is to be regarded as a stable API between XEN domains +* running potentially different Linux kernel versions. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +* Copyright(c) FUJITSU Limited 2008. +*/ + +#ifndef __XEN__PUBLIC_IO_SCSI_H__ +#define __XEN__PUBLIC_IO_SCSI_H__ + +#include "ring.h" +#include "../grant_table.h" + +/* +* Front->back notifications: When enqueuing a new request, sending a +* notification can be made conditional on req_event (i.e., the generic +* hold-off mechanism provided by the ring macros). Backends must set +* req_event appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()). +* +* Back->front notifications: When enqueuing a new response, sending a +* notification can be made conditional on rsp_event (i.e., the generic +* hold-off mechanism provided by the ring macros). Frontends must set +* rsp_event appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()). +*/ + +/* +* Feature and Parameter Negotiation +* ================================= +* The two halves of a Xen pvSCSI driver utilize nodes within the XenStore to +* communicate capabilities and to negotiate operating parameters. This +* section enumerates these nodes which reside in the respective front and +* backend portions of the XenStore, following the XenBus convention. +* +* All data in the XenStore is stored as strings. Nodes specifying numeric +* values are encoded in decimal. Integer value ranges listed below are +* expressed as fixed sized integer types capable of storing the conversion +* of a properly formated node string, without loss of information. +* +* Any specified default value is in effect if the corresponding XenBus node +* is not present in the XenStore. +* +* XenStore nodes in sections marked "PRIVATE" are solely for use by the +* driver side whose XenBus tree contains them. +* +***************************************************************************** +* Backend XenBus Nodes +***************************************************************************** +* +*------------------ Backend Device Identification (PRIVATE) ------------------ +* +* p-devname +* Values: string +* +* A free string used to identify the physical device (e.g. a disk name). +* +* p-dev +* Values: string +* +* A string specifying the backend device: either a 4-tuple "h:c:t:l" +* (host, controller, target, lun, all integers), or a WWN (e.g. +* "naa.60014054ac780582"). +* +* v-dev +* Values: string +* +* A string specifying the frontend device in form of a 4-tuple "h:c:t:l" +* (host, controller, target, lun, all integers). +* +*--------------------------------- Features --------------------------------- +* +* feature-sg-grant +* Values: <uint16_t> +* Default Value: 0 +* +* Specifies the maximum number of scatter/gather elements in grant pages +* supported. If not set, the backend supports up to VSCSIIF_SG_TABLESIZE +* SG elements specified directly in the request. +* +***************************************************************************** +* Frontend XenBus Nodes +***************************************************************************** +* +*----------------------- Request Transport Parameters ----------------------- +* +* event-channel +* Values: <uint32_t> +* +* The identifier of the Xen event channel used to signal activity +* in the ring buffer. +* +* ring-ref +* Values: <uint32_t> +* +* protocol +* Values: string (XEN_IO_PROTO_ABI_*) +* Default Value: XEN_IO_PROTO_ABI_NATIVE +* +* The machine ABI rules governing the format of all ring request and +* response structures. +*/ + +/* Requests from the frontend to the backend */ + +/* +* Request a SCSI operation specified via a CDB in vscsiif_request.cmnd. +* The target is specified via channel, id and lun. +*/ +#define VSCSIIF_ACT_SCSI_CDB 1 + +/* +* Request abort of a running operation for the specified target given by +* channel, id, lun and the operation's rqid in ref_rqid. +*/ +#define VSCSIIF_ACT_SCSI_ABORT 2 + +/* +* Request a device reset of the specified target (channel and id). +*/ +#define VSCSIIF_ACT_SCSI_RESET 3 + +/* +* Preset scatter/gather elements for a following request. Deprecated. +* Keeping the define only to avoid usage of the value "4" for other actions. +*/ +#define VSCSIIF_ACT_SCSI_SG_PRESET 4 + +/* +* Maximum scatter/gather segments per request. +* +* Considering balance between allocating at least 16 "vscsiif_request" +* structures on one page (4096 bytes) and the number of scatter/gather +* elements needed, we decided to use 26 as a magic number. +* +* If "feature-sg-grant" is set, more scatter/gather elements can be specified +* by placing them in one or more (up to VSCSIIF_SG_TABLESIZE) granted pages. +* In this case the vscsiif_request seg elements don't contain references to +* the user data, but to the SG elements referencing the user data. +*/ +#define VSCSIIF_SG_TABLESIZE 26 + +/* +* based on Linux kernel 2.6.18, still valid +* Changing these values requires support of multiple protocols via the rings +* as "old clients" will blindly use these values and the resulting structure +* sizes. +*/ +#define VSCSIIF_MAX_COMMAND_SIZE 16 +#define VSCSIIF_SENSE_BUFFERSIZE 96 + +struct scsiif_request_segment { +grant_ref_t gref; +uint16_t offset; +uint16_t length; +}; + +/* Size of one request is 252 bytes */ +struct vscsiif_request { +uint16_t rqid;/* private guest value, echoed in resp */ +uint8_t act;/* command between backend and frontend */ +uint8_t cmd_len;/* valid CDB bytes */ + +uint8_t cmnd[VSCSIIF_MAX_COMMAND_SIZE ];/* the CDB */ +uint16_t timeout_per_command; +uint16_t channel, id, lun;/* (virtual) device specification */ +uint16_t ref_rqid;/* command abort reference */ +uint8_t sc_data_direction;/* for DMA_TO_DEVICE(1) +DMA_FROM_DEVICE(2) +DMA_NONE(3) requests */ +uint8_t nr_segments;/* Number of pieces of scatter-gather */ +#define VSCSIIF_SG_GRANT 0x80/* flag: SG elements via grant page */ +/* nr_segments counts grant pages with +SG elements +usable if "feature-sg-grant" set */ + +struct scsiif_request_segment seg[VSCSIIF_SG_TABLESIZE ]; +uint32_t reserved[3 ]; +}; + +struct vscsiif_response { +uint16_t rqid;/* identifies request */ +uint8_t padding; +uint8_t sense_len; +uint8_t sense_buffer[VSCSIIF_SENSE_BUFFERSIZE ]; +int32_t rslt; +uint32_t residual_len;/* request bufflen - +return the value from physical device */ +uint32_t reserved[36 ]; +}; + +DEFINE_RING_TYPES(vscsiif, struct vscsiif_request, struct vscsiif_response); + +#endif /*__XEN__PUBLIC_IO_SCSI_H__*/
Signature · 1 line
1.8.4.5
[email protected]
maintainerPATCH v5 2/5 Add XEN pvSCSI protocol description
In reply to [email protected]From: Juergen Gross <[email protected]>
Add the definition of pvSCSI protocol used between the pvSCSI frontend in a XEN domU and the pvSCSI backend in a XEN driver domain (usually Dom0).
This header was originally provided by Fujitsu for XEN based on Linux 2.6.18. Changes are:
- added comment
- adapt to Linux style guide
- add support for larger SG-lists by putting them in an own granted page
- remove stale definitions
--- include/xen/interface/io/vscsiif.h | 214 +++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 include/xen/interface/io/vscsiif.h
include/xen/interface/io/vscsiif.h new file +214 -0
@@ -0,0 +1,214 @@ +/****************************************************************************** +* vscsiif.h +* +* Based on the blkif.h code. +* +* This interface is to be regarded as a stable API between XEN domains +* running potentially different Linux kernel versions. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +* Copyright(c) FUJITSU Limited 2008. +*/ + +#ifndef __XEN__PUBLIC_IO_SCSI_H__ +#define __XEN__PUBLIC_IO_SCSI_H__ + +#include "ring.h" +#include "../grant_table.h" + +/* +* Front->back notifications: When enqueuing a new request, sending a +* notification can be made conditional on req_event (i.e., the generic +* hold-off mechanism provided by the ring macros). Backends must set +* req_event appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()). +* +* Back->front notifications: When enqueuing a new response, sending a +* notification can be made conditional on rsp_event (i.e., the generic +* hold-off mechanism provided by the ring macros). Frontends must set +* rsp_event appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()). +*/ + +/* +* Feature and Parameter Negotiation +* ================================= +* The two halves of a Xen pvSCSI driver utilize nodes within the XenStore to +* communicate capabilities and to negotiate operating parameters. This +* section enumerates these nodes which reside in the respective front and +* backend portions of the XenStore, following the XenBus convention. +* +* All data in the XenStore is stored as strings. Nodes specifying numeric +* values are encoded in decimal. Integer value ranges listed below are +* expressed as fixed sized integer types capable of storing the conversion +* of a properly formated node string, without loss of information. +* +* Any specified default value is in effect if the corresponding XenBus node +* is not present in the XenStore. +* +* XenStore nodes in sections marked "PRIVATE" are solely for use by the +* driver side whose XenBus tree contains them. +* +***************************************************************************** +* Backend XenBus Nodes +***************************************************************************** +* +*------------------ Backend Device Identification (PRIVATE) ------------------ +* +* p-devname +* Values: string +* +* A free string used to identify the physical device (e.g. a disk name). +* +* p-dev +* Values: string +* +* A string specifying the backend device: either a 4-tuple "h:c:t:l" +* (host, controller, target, lun, all integers), or a WWN (e.g. +* "naa.60014054ac780582"). +* +* v-dev +* Values: string +* +* A string specifying the frontend device in form of a 4-tuple "h:c:t:l" +* (host, controller, target, lun, all integers). +* +*--------------------------------- Features --------------------------------- +* +* feature-sg-grant +* Values: <uint16_t> +* Default Value: 0 +* +* Specifies the maximum number of scatter/gather elements in grant pages +* supported. If not set, the backend supports up to VSCSIIF_SG_TABLESIZE +* SG elements specified directly in the request. +* +***************************************************************************** +* Frontend XenBus Nodes +***************************************************************************** +* +*----------------------- Request Transport Parameters ----------------------- +* +* event-channel +* Values: <uint32_t> +* +* The identifier of the Xen event channel used to signal activity +* in the ring buffer. +* +* ring-ref +* Values: <uint32_t> +* +* protocol +* Values: string (XEN_IO_PROTO_ABI_*) +* Default Value: XEN_IO_PROTO_ABI_NATIVE +* +* The machine ABI rules governing the format of all ring request and +* response structures. +*/ + +/* Requests from the frontend to the backend */ + +/* +* Request a SCSI operation specified via a CDB in vscsiif_request.cmnd. +* The target is specified via channel, id and lun. +*/ +#define VSCSIIF_ACT_SCSI_CDB 1 + +/* +* Request abort of a running operation for the specified target given by +* channel, id, lun and the operation's rqid in ref_rqid. +*/ +#define VSCSIIF_ACT_SCSI_ABORT 2 + +/* +* Request a device reset of the specified target (channel and id). +*/ +#define VSCSIIF_ACT_SCSI_RESET 3 + +/* +* Preset scatter/gather elements for a following request. Deprecated. +* Keeping the define only to avoid usage of the value "4" for other actions. +*/ +#define VSCSIIF_ACT_SCSI_SG_PRESET 4 + +/* +* Maximum scatter/gather segments per request. +* +* Considering balance between allocating at least 16 "vscsiif_request" +* structures on one page (4096 bytes) and the number of scatter/gather +* elements needed, we decided to use 26 as a magic number. +* +* If "feature-sg-grant" is set, more scatter/gather elements can be specified +* by placing them in one or more (up to VSCSIIF_SG_TABLESIZE) granted pages. +* In this case the vscsiif_request seg elements don't contain references to +* the user data, but to the SG elements referencing the user data. +*/ +#define VSCSIIF_SG_TABLESIZE 26 + +/* +* based on Linux kernel 2.6.18, still valid +* Changing these values requires support of multiple protocols via the rings +* as "old clients" will blindly use these values and the resulting structure +* sizes. +*/ +#define VSCSIIF_MAX_COMMAND_SIZE 16 +#define VSCSIIF_SENSE_BUFFERSIZE 96 + +struct scsiif_request_segment { +grant_ref_t gref; +uint16_t offset; +uint16_t length; +}; + +/* Size of one request is 252 bytes */ +struct vscsiif_request { +uint16_t rqid;/* private guest value, echoed in resp */ +uint8_t act;/* command between backend and frontend */ +uint8_t cmd_len;/* valid CDB bytes */ + +uint8_t cmnd[VSCSIIF_MAX_COMMAND_SIZE ];/* the CDB */ +uint16_t timeout_per_command; +uint16_t channel, id, lun;/* (virtual) device specification */ +uint16_t ref_rqid;/* command abort reference */ +uint8_t sc_data_direction;/* for DMA_TO_DEVICE(1) +DMA_FROM_DEVICE(2) +DMA_NONE(3) requests */ +uint8_t nr_segments;/* Number of pieces of scatter-gather */ +#define VSCSIIF_SG_GRANT 0x80/* flag: SG elements via grant page */ +/* nr_segments counts grant pages with +SG elements +usable if "feature-sg-grant" set */ + +struct scsiif_request_segment seg[VSCSIIF_SG_TABLESIZE ]; +uint32_t reserved[3 ]; +}; + +struct vscsiif_response { +uint16_t rqid;/* identifies request */ +uint8_t padding; +uint8_t sense_len; +uint8_t sense_buffer[VSCSIIF_SENSE_BUFFERSIZE ]; +int32_t rslt; +uint32_t residual_len;/* request bufflen - +return the value from physical device */ +uint32_t reserved[36 ]; +}; + +DEFINE_RING_TYPES(vscsiif, struct vscsiif_request, struct vscsiif_response); + +#endif /*__XEN__PUBLIC_IO_SCSI_H__*/
Signature · 1 line
1.8.4.5
Re: [PATCH V5 2/5] Add XEN pvSCSI protocol description
Quoted 128 lines · On Mon, Aug 18, 2014 at 11:31:47AM +0200, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add the definition of pvSCSI protocol used between the pvSCSI frontend in a XEN domU and the pvSCSI backend in a XEN driver domain (usually Dom0).
This header was originally provided by Fujitsu for XEN based on Linux 2.6.18. Changes are:
- added comment
- adapt to Linux style guide
- add support for larger SG-lists by putting them in an own granted page
- remove stale definitionsSigned-off-by Juergen Gross <[email protected]>--- include/xen/interface/io/vscsiif.h | 214 +++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 include/xen/interface/io/vscsiif.hinclude/xen/interface/io/vscsiif.h new file +104
-0@@ -0,0 +1,214 @@ +/****************************************************************************** +* vscsiif.h +* +* Based on the blkif.h code. +* +* This interface is to be regarded as a stable API between XEN domains +* running potentially different Linux kernel versions. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +* Copyright(c) FUJITSU Limited 2008. +*/ + +#ifndef __XEN__PUBLIC_IO_SCSI_H__ +#define __XEN__PUBLIC_IO_SCSI_H__ + +#include "ring.h" +#include "../grant_table.h" + +/* +* Front->back notifications: When enqueuing a new request, sending a +* notification can be made conditional on req_event (i.e., the generic +* hold-off mechanism provided by the ring macros). Backends must set +* req_event appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()). +* +* Back->front notifications: When enqueuing a new response, sending a +* notification can be made conditional on rsp_event (i.e., the generic +* hold-off mechanism provided by the ring macros). Frontends must set +* rsp_event appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()). +*/ + +/* +* Feature and Parameter Negotiation +* ================================= +* The two halves of a Xen pvSCSI driver utilize nodes within the XenStore to +* communicate capabilities and to negotiate operating parameters. This +* section enumerates these nodes which reside in the respective front and +* backend portions of the XenStore, following the XenBus convention. +* +* All data in the XenStore is stored as strings. Nodes specifying numeric +* values are encoded in decimal. Integer value ranges listed below are +* expressed as fixed sized integer types capable of storing the conversion +* of a properly formated node string, without loss of information. +* +* Any specified default value is in effect if the corresponding XenBus node +* is not present in the XenStore. +* +* XenStore nodes in sections marked "PRIVATE" are solely for use by the +* driver side whose XenBus tree contains them. +* +***************************************************************************** +* Backend XenBus Nodes +***************************************************************************** +* +*------------------ Backend Device Identification (PRIVATE) ------------------ +* +* p-devname +* Values: string +* +* A free string used to identify the physical device (e.g. a disk name). +* +* p-dev +* Values: string +* +* A string specifying the backend device: either a 4-tuple "h:c:t:l" +* (host, controller, target, lun, all integers), or a WWN (e.g. +* "naa.60014054ac780582"). +* +* v-dev +* Values: string +* +* A string specifying the frontend device in form of a 4-tuple "h:c:t:l" +* (host, controller, target, lun, all integers). +* +*--------------------------------- Features --------------------------------- +* +* feature-sg-grant +* Values: <uint16_t> +* Default Value: 0 +* +* Specifies the maximum number of scatter/gather elements in grant pages +* supported. If not set, the backend supports up to VSCSIIF_SG_TABLESIZE +* SG elements specified directly in the request. +* +***************************************************************************** +* Frontend XenBus Nodes +***************************************************************************** +*
include/xen/interface/io/vscsiif.h line 114
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+ *----------------------- Request Transport Parameters ----------------------- + * + * event-channel + * Values: <uint32_t> + * + * The identifier of the Xen event channel used to signal activity + * in the ring buffer. + * + * ring-ref + * Values: <uint32_t>
Should there a bit of explanation here about what 'ring ref' is?
Quoted 35 lines
include/xen/interface/io/vscsiif.h new file +35
-0+* +* protocol +* Values: string (XEN_IO_PROTO_ABI_*) +* Default Value: XEN_IO_PROTO_ABI_NATIVE +* +* The machine ABI rules governing the format of all ring request and +* response structures. +*/ + +/* Requests from the frontend to the backend */ + +/* +* Request a SCSI operation specified via a CDB in vscsiif_request.cmnd. +* The target is specified via channel, id and lun. +*/ +#define VSCSIIF_ACT_SCSI_CDB 1 + +/* +* Request abort of a running operation for the specified target given by +* channel, id, lun and the operation's rqid in ref_rqid. +*/ +#define VSCSIIF_ACT_SCSI_ABORT 2 + +/* +* Request a device reset of the specified target (channel and id). +*/ +#define VSCSIIF_ACT_SCSI_RESET 3 + +/* +* Preset scatter/gather elements for a following request. Deprecated. +* Keeping the define only to avoid usage of the value "4" for other actions. +*/ +#define VSCSIIF_ACT_SCSI_SG_PRESET 4 + +/*
include/xen/interface/io/vscsiif.h line 159
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+* Maximum scatter/gather segments per request. +* +* Considering balance between allocating at least 16 "vscsiif_request" +* structures on one page (4096 bytes) and the number of scatter/gather +* elements needed, we decided to use 26 as a magic number. +* +* If "feature-sg-grant" is set, more scatter/gather elements can be specified +* by placing them in one or more (up to VSCSIIF_SG_TABLESIZE) granted pages. +* In this case the vscsiif_request seg elements don't contain references to +* the user data, but to the SG elements referencing the user data.
That sounds like the indirect descriptors that virtio and xen-block has. More questions about that below.
Quoted 7 lines
include/xen/interface/io/vscsiif.h new file +7
-0+*/ +#define VSCSIIF_SG_TABLESIZE 26 + +/* +* based on Linux kernel 2.6.18, still valid +* Changing these values requires support of multiple protocols via the rings +* as "old clients" will blindly use these values and the resulting structure
include/xen/interface/io/vscsiif.h line 176
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+* sizes. +*/ +#define VSCSIIF_MAX_COMMAND_SIZE 16 +#define VSCSIIF_SENSE_BUFFERSIZE 96 + +struct scsiif_request_segment { +grant_ref_t gref; +uint16_t offset; +uint16_t length; +};
Yeey, 8 byte data structure!
Quoted 8 lines
include/xen/interface/io/vscsiif.h new file +8
-0+ +/* Size of one request is 252 bytes */ +struct vscsiif_request { +uint16_t rqid;/* private guest value, echoed in resp */ +uint8_t act;/* command between backend and frontend */ +uint8_t cmd_len;/* valid CDB bytes */ + +uint8_t cmnd[VSCSIIF_MAX_COMMAND_SIZE ];/* the CDB */
include/xen/interface/io/vscsiif.h line 194
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+uint16_t timeout_per_command; +uint16_t channel, id, lun;/* (virtual) device specification */ +uint16_t ref_rqid;/* command abort reference */ +uint8_t sc_data_direction;/* for DMA_TO_DEVICE(1) +DMA_FROM_DEVICE(2) +DMA_NONE(3) requests */ +uint8_t nr_segments;/* Number of pieces of scatter-gather */ +#define VSCSIIF_SG_GRANT 0x80/* flag: SG elements via grant page */ +/* nr_segments counts grant pages with +SG elements
Stop missing. However I am a bit lost. It says that the 'nr_segments' will have the count of grant pages with SG elements. Does that mean the req.seg[0].gref points to an page which will have an array of grant references? And each grant reference will point to a data page? What about the 'offset' and 'length' of them?
Or does it mean that the 'reg.seg[0].gref' points an page that is filled with 'struct scsiif_request_segment' ? If so, where would the could of those segments be in? In 'nr_segments'? If that is so where does the VSCSIIF_SG_GRANT go? Won't we collide?
include/xen/interface/io/vscsiif.h line 198
Quoted 4 lines
include/xen/interface/io/vscsiif.h new file +4
-0+usable if "feature-sg-grant" set */ + +struct scsiif_request_segment seg[VSCSIIF_SG_TABLESIZE ]; +uint32_t reserved[3 ];
Or is the flag suppose to show up here?
include/xen/interface/io/vscsiif.h line 200
Quoted 2 lines
include/xen/interface/io/vscsiif.h new file +2
-0+}; +
The previous structure had an comment about the size of the structure. Should it be here as well?
Quoted 22 lines
include/xen/interface/io/vscsiif.h new file +14
-0+struct vscsiif_response { +uint16_t rqid;/* identifies request */ +uint8_t padding; +uint8_t sense_len; +uint8_t sense_buffer[VSCSIIF_SENSE_BUFFERSIZE ]; +int32_t rslt; +uint32_t residual_len;/* request bufflen - +return the value from physical device */ +uint32_t reserved[36 ]; +}; + +DEFINE_RING_TYPES(vscsiif, struct vscsiif_request, struct vscsiif_response); + +#endif /*__XEN__PUBLIC_IO_SCSI_H__*/ Signature · 7 lines
1.8.4.5 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH V5 2/5] Add XEN pvSCSI protocol description
In reply to [email protected]Quoted 128 lines · On Mon, Aug 18, 2014 at 11:31:47AM +0200, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add the definition of pvSCSI protocol used between the pvSCSI frontend in a XEN domU and the pvSCSI backend in a XEN driver domain (usually Dom0).
This header was originally provided by Fujitsu for XEN based on Linux 2.6.18. Changes are:
- added comment
- adapt to Linux style guide
- add support for larger SG-lists by putting them in an own granted page
- remove stale definitionsSigned-off-by Juergen Gross <[email protected]>--- include/xen/interface/io/vscsiif.h | 214 +++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 include/xen/interface/io/vscsiif.hinclude/xen/interface/io/vscsiif.h new file +104
-0@@ -0,0 +1,214 @@ +/****************************************************************************** +* vscsiif.h +* +* Based on the blkif.h code. +* +* This interface is to be regarded as a stable API between XEN domains +* running potentially different Linux kernel versions. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +* Copyright(c) FUJITSU Limited 2008. +*/ + +#ifndef __XEN__PUBLIC_IO_SCSI_H__ +#define __XEN__PUBLIC_IO_SCSI_H__ + +#include "ring.h" +#include "../grant_table.h" + +/* +* Front->back notifications: When enqueuing a new request, sending a +* notification can be made conditional on req_event (i.e., the generic +* hold-off mechanism provided by the ring macros). Backends must set +* req_event appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()). +* +* Back->front notifications: When enqueuing a new response, sending a +* notification can be made conditional on rsp_event (i.e., the generic +* hold-off mechanism provided by the ring macros). Frontends must set +* rsp_event appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()). +*/ + +/* +* Feature and Parameter Negotiation +* ================================= +* The two halves of a Xen pvSCSI driver utilize nodes within the XenStore to +* communicate capabilities and to negotiate operating parameters. This +* section enumerates these nodes which reside in the respective front and +* backend portions of the XenStore, following the XenBus convention. +* +* All data in the XenStore is stored as strings. Nodes specifying numeric +* values are encoded in decimal. Integer value ranges listed below are +* expressed as fixed sized integer types capable of storing the conversion +* of a properly formated node string, without loss of information. +* +* Any specified default value is in effect if the corresponding XenBus node +* is not present in the XenStore. +* +* XenStore nodes in sections marked "PRIVATE" are solely for use by the +* driver side whose XenBus tree contains them. +* +***************************************************************************** +* Backend XenBus Nodes +***************************************************************************** +* +*------------------ Backend Device Identification (PRIVATE) ------------------ +* +* p-devname +* Values: string +* +* A free string used to identify the physical device (e.g. a disk name). +* +* p-dev +* Values: string +* +* A string specifying the backend device: either a 4-tuple "h:c:t:l" +* (host, controller, target, lun, all integers), or a WWN (e.g. +* "naa.60014054ac780582"). +* +* v-dev +* Values: string +* +* A string specifying the frontend device in form of a 4-tuple "h:c:t:l" +* (host, controller, target, lun, all integers). +* +*--------------------------------- Features --------------------------------- +* +* feature-sg-grant +* Values: <uint16_t> +* Default Value: 0 +* +* Specifies the maximum number of scatter/gather elements in grant pages +* supported. If not set, the backend supports up to VSCSIIF_SG_TABLESIZE +* SG elements specified directly in the request. +* +***************************************************************************** +* Frontend XenBus Nodes +***************************************************************************** +*
include/xen/interface/io/vscsiif.h line 114
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+ *----------------------- Request Transport Parameters ----------------------- + * + * event-channel + * Values: <uint32_t> + * + * The identifier of the Xen event channel used to signal activity + * in the ring buffer. + * + * ring-ref + * Values: <uint32_t>
Should there a bit of explanation here about what 'ring ref' is?
Quoted 35 lines
include/xen/interface/io/vscsiif.h new file +35
-0+* +* protocol +* Values: string (XEN_IO_PROTO_ABI_*) +* Default Value: XEN_IO_PROTO_ABI_NATIVE +* +* The machine ABI rules governing the format of all ring request and +* response structures. +*/ + +/* Requests from the frontend to the backend */ + +/* +* Request a SCSI operation specified via a CDB in vscsiif_request.cmnd. +* The target is specified via channel, id and lun. +*/ +#define VSCSIIF_ACT_SCSI_CDB 1 + +/* +* Request abort of a running operation for the specified target given by +* channel, id, lun and the operation's rqid in ref_rqid. +*/ +#define VSCSIIF_ACT_SCSI_ABORT 2 + +/* +* Request a device reset of the specified target (channel and id). +*/ +#define VSCSIIF_ACT_SCSI_RESET 3 + +/* +* Preset scatter/gather elements for a following request. Deprecated. +* Keeping the define only to avoid usage of the value "4" for other actions. +*/ +#define VSCSIIF_ACT_SCSI_SG_PRESET 4 + +/*
include/xen/interface/io/vscsiif.h line 159
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+* Maximum scatter/gather segments per request. +* +* Considering balance between allocating at least 16 "vscsiif_request" +* structures on one page (4096 bytes) and the number of scatter/gather +* elements needed, we decided to use 26 as a magic number. +* +* If "feature-sg-grant" is set, more scatter/gather elements can be specified +* by placing them in one or more (up to VSCSIIF_SG_TABLESIZE) granted pages. +* In this case the vscsiif_request seg elements don't contain references to +* the user data, but to the SG elements referencing the user data.
That sounds like the indirect descriptors that virtio and xen-block has. More questions about that below.
Quoted 7 lines
include/xen/interface/io/vscsiif.h new file +7
-0+*/ +#define VSCSIIF_SG_TABLESIZE 26 + +/* +* based on Linux kernel 2.6.18, still valid +* Changing these values requires support of multiple protocols via the rings +* as "old clients" will blindly use these values and the resulting structure
include/xen/interface/io/vscsiif.h line 176
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+* sizes. +*/ +#define VSCSIIF_MAX_COMMAND_SIZE 16 +#define VSCSIIF_SENSE_BUFFERSIZE 96 + +struct scsiif_request_segment { +grant_ref_t gref; +uint16_t offset; +uint16_t length; +};
Yeey, 8 byte data structure!
Quoted 8 lines
include/xen/interface/io/vscsiif.h new file +8
-0+ +/* Size of one request is 252 bytes */ +struct vscsiif_request { +uint16_t rqid;/* private guest value, echoed in resp */ +uint8_t act;/* command between backend and frontend */ +uint8_t cmd_len;/* valid CDB bytes */ + +uint8_t cmnd[VSCSIIF_MAX_COMMAND_SIZE ];/* the CDB */
include/xen/interface/io/vscsiif.h line 194
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+uint16_t timeout_per_command; +uint16_t channel, id, lun;/* (virtual) device specification */ +uint16_t ref_rqid;/* command abort reference */ +uint8_t sc_data_direction;/* for DMA_TO_DEVICE(1) +DMA_FROM_DEVICE(2) +DMA_NONE(3) requests */ +uint8_t nr_segments;/* Number of pieces of scatter-gather */ +#define VSCSIIF_SG_GRANT 0x80/* flag: SG elements via grant page */ +/* nr_segments counts grant pages with +SG elements
Stop missing. However I am a bit lost. It says that the 'nr_segments' will have the count of grant pages with SG elements. Does that mean the req.seg[0].gref points to an page which will have an array of grant references? And each grant reference will point to a data page? What about the 'offset' and 'length' of them?
Or does it mean that the 'reg.seg[0].gref' points an page that is filled with 'struct scsiif_request_segment' ? If so, where would the could of those segments be in? In 'nr_segments'? If that is so where does the VSCSIIF_SG_GRANT go? Won't we collide?
include/xen/interface/io/vscsiif.h line 198
Quoted 4 lines
include/xen/interface/io/vscsiif.h new file +4
-0+usable if "feature-sg-grant" set */ + +struct scsiif_request_segment seg[VSCSIIF_SG_TABLESIZE ]; +uint32_t reserved[3 ];
Or is the flag suppose to show up here?
include/xen/interface/io/vscsiif.h line 200
Quoted 2 lines
include/xen/interface/io/vscsiif.h new file +2
-0+}; +
The previous structure had an comment about the size of the structure. Should it be here as well?
Quoted 22 lines
include/xen/interface/io/vscsiif.h new file +14
-0+struct vscsiif_response { +uint16_t rqid;/* identifies request */ +uint8_t padding; +uint8_t sense_len; +uint8_t sense_buffer[VSCSIIF_SENSE_BUFFERSIZE ]; +int32_t rslt; +uint32_t residual_len;/* request bufflen - +return the value from physical device */ +uint32_t reserved[36 ]; +}; + +DEFINE_RING_TYPES(vscsiif, struct vscsiif_request, struct vscsiif_response); + +#endif /*__XEN__PUBLIC_IO_SCSI_H__*/ Signature · 7 lines
1.8.4.5 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Juergen Gross
maintainerRe: [Xen-devel] [PATCH V5 2/5] Add XEN pvSCSI protocol description
Quoted 133 lines · Konrad Rzeszutek Wilk
Quoted 132 lines · On Mon, Aug 18, 2014 at 11:31:47AM +0200, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add the definition of pvSCSI protocol used between the pvSCSI frontend in a XEN domU and the pvSCSI backend in a XEN driver domain (usually Dom0).
This header was originally provided by Fujitsu for XEN based on Linux 2.6.18. Changes are:
- added comment
- adapt to Linux style guide
- add support for larger SG-lists by putting them in an own granted page
- remove stale definitionsSigned-off-by Juergen Gross <[email protected]>--- include/xen/interface/io/vscsiif.h | 214 +++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+)create mode 100644
include/xen/interface/io/vscsiif.hinclude/xen/interface/io/vscsiif.h new file +108
-0@@ -0,0 +1,214 @@ +/****************************************************************************** +* vscsiif.h +* +* Based on the blkif.h code. +* +* This interface is to be regarded as a stable API between XEN domains +* running potentially different Linux kernel versions. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +* Copyright(c) FUJITSU Limited 2008. +*/ + +#ifndef __XEN__PUBLIC_IO_SCSI_H__ +#define __XEN__PUBLIC_IO_SCSI_H__ + +#include "ring.h" +#include "../grant_table.h" + +/* +* Front->back notifications: When enqueuing a new request, sending a +* notification can be made conditional on req_event (i.e., the generic +* hold-off mechanism provided by the ring macros). Backends must set +* req_event appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()). +* +* Back->front notifications: When enqueuing a new response, sending a +* notification can be made conditional on rsp_event (i.e., the generic +* hold-off mechanism provided by the ring macros). Frontends must set +* rsp_event appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()). +*/ + +/* +* Feature and Parameter Negotiation +* ================================= +* The two halves of a Xen pvSCSI driver utilize nodes within the XenStore to +* communicate capabilities and to negotiate operating parameters. This +* section enumerates these nodes which reside in the respective front and +* backend portions of the XenStore, following the XenBus convention. +* +* All data in the XenStore is stored as strings. Nodes specifying numeric +* values are encoded in decimal. Integer value ranges listed below are +* expressed as fixed sized integer types capable of storing the conversion +* of a properly formated node string, without loss of information. +* +* Any specified default value is in effect if the corresponding XenBus node +* is not present in the XenStore. +* +* XenStore nodes in sections marked "PRIVATE" are solely for use by the +* driver side whose XenBus tree contains them. +* +***************************************************************************** +* Backend XenBus Nodes +***************************************************************************** +* +*------------------ Backend Device Identification (PRIVATE) ------------------ +* +* p-devname +* Values: string +* +* A free string used to identify the physical device (e.g. a disk name). +* +* p-dev +* Values: string +* +* A string specifying the backend device: either a 4-tuple "h:c:t:l" +* (host, controller, target, lun, all integers), or a WWN (e.g. +* "naa.60014054ac780582"). +* +* v-dev +* Values: string +* +* A string specifying the frontend device in form of a 4-tuple "h:c:t:l" +* (host, controller, target, lun, all integers). +* +*--------------------------------- Features --------------------------------- +* +* feature-sg-grant +* Values: <uint16_t> +* Default Value: 0 +* +* Specifies the maximum number of scatter/gather elements in grant pages +* supported. If not set, the backend supports up to VSCSIIF_SG_TABLESIZE +* SG elements specified directly in the request. +* +***************************************************************************** +* Frontend XenBus Nodes +***************************************************************************** +* +*----------------------- Request Transport Parameters ----------------------- +* +* event-channel +* Values: <uint32_t>
Quoted 8 lines
include/xen/interface/io/vscsiif.h line 114
Quoted 6 lines
include/xen/interface/io/vscsiif.h new file +6
-0+* +* The identifier of the Xen event channel used to signal activity +* in the ring buffer. +* +* ring-ref +* Values: <uint32_t> Should there a bit of explanation here about what 'ring ref' is?
Uuh, yes. I'll add it.
Quoted 92 lines
Quoted 36 lines
include/xen/interface/io/vscsiif.h new file +35
-0+* +* protocol +* Values: string (XEN_IO_PROTO_ABI_*) +* Default Value: XEN_IO_PROTO_ABI_NATIVE +* +* The machine ABI rules governing the format of all ring request and +* response structures. +*/ + +/* Requests from the frontend to the backend */ + +/* +* Request a SCSI operation specified via a CDB in vscsiif_request.cmnd. +* The target is specified via channel, id and lun. +*/ +#define VSCSIIF_ACT_SCSI_CDB 1 + +/* +* Request abort of a running operation for the specified target given by +* channel, id, lun and the operation's rqid in ref_rqid. +*/ +#define VSCSIIF_ACT_SCSI_ABORT 2 + +/* +* Request a device reset of the specified target (channel and id). +*/ +#define VSCSIIF_ACT_SCSI_RESET 3 + +/* +* Preset scatter/gather elements for a following request. Deprecated. +* Keeping the define only to avoid usage of the value "4" for other actions. +*/ +#define VSCSIIF_ACT_SCSI_SG_PRESET 4 + +/* include/xen/interface/io/vscsiif.h line 159
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+* Maximum scatter/gather segments per request. +* +* Considering balance between allocating at least 16 "vscsiif_request" +* structures on one page (4096 bytes) and the number of scatter/gather +* elements needed, we decided to use 26 as a magic number. +* +* If "feature-sg-grant" is set, more scatter/gather elements can be specified +* by placing them in one or more (up to VSCSIIF_SG_TABLESIZE) granted pages. +* In this case the vscsiif_request seg elements don't contain references to +* the user data, but to the SG elements referencing the user data. That sounds like the indirect descriptors that virtio and xen-block has. More questions about that below.
Quoted 7 lines
include/xen/interface/io/vscsiif.h new file +7
-0+*/ +#define VSCSIIF_SG_TABLESIZE 26 + +/* +* based on Linux kernel 2.6.18, still valid +* Changing these values requires support of multiple protocols via the rings +* as "old clients" will blindly use these values and the resulting structure include/xen/interface/io/vscsiif.h line 176
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+* sizes. +*/ +#define VSCSIIF_MAX_COMMAND_SIZE 16 +#define VSCSIIF_SENSE_BUFFERSIZE 96 + +struct scsiif_request_segment { +grant_ref_t gref; +uint16_t offset; +uint16_t length; +};Yeey, 8 byte data structure!
Quoted 8 lines
include/xen/interface/io/vscsiif.h new file +8
-0+ +/* Size of one request is 252 bytes */ +struct vscsiif_request { +uint16_t rqid;/* private guest value, echoed in resp */ +uint8_t act;/* command between backend and frontend */ +uint8_t cmd_len;/* valid CDB bytes */ + +uint8_t cmnd[VSCSIIF_MAX_COMMAND_SIZE ];/* the CDB */ include/xen/interface/io/vscsiif.h line 194
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+uint16_t timeout_per_command; +uint16_t channel, id, lun;/* (virtual) device specification */ +uint16_t ref_rqid;/* command abort reference */ +uint8_t sc_data_direction;/* for DMA_TO_DEVICE(1) +DMA_FROM_DEVICE(2) +DMA_NONE(3) requests */ +uint8_t nr_segments;/* Number of pieces of scatter-gather */ +#define VSCSIIF_SG_GRANT 0x80/* flag: SG elements via grant page */ +/* nr_segments counts grant pages with +SG elements Stop missing. However I am a bit lost. It says that the '
nr_segments' will have the count of grant pages with SG elements. Does that mean the req.seg[0].gref points to an page which will have an array of grant references? And each grant reference will point to a data page? What about the 'offset' and 'length' of them?
Quoted 4 lines
Or does it mean that the 'reg.seg[0].gref' points an page that is filled with 'struct
scsiif_request_segment' ? If so, where would the could of those segments be in? In 'nr_segments'? If that is so where does theVSCSIIF_SG_GRANTgo? Won't we collide?
nr_segments (without the VSCSIIF_SG_GRANT bit) always counts the number of populated seg[] entries. If VSCSIIF_SG_GRANT is set, each seg[] entry references another array of struct scsiif_request_segment using a grant ref, offset into the granted page and a length of the array in bytes.
The resulting number of struct scsiif_request_segment is the sum of seg[0..nr_segments-1].length / sizeof(struct scsiif_request_segment).
Quoted 8 lines
include/xen/interface/io/vscsiif.h line 198
Quoted 6 lines
include/xen/interface/io/vscsiif.h new file +4
-0+usable if "feature-sg-grant" set */ + +struct scsiif_request_segment seg[VSCSIIF_SG_TABLESIZE ]; +uint32_t reserved[3 ];Or is the flag suppose to show up here?
No. There is no guarantee an "old" domU not aware of "feature-sg-grant" will have set reserved[] to zero.
Quoted 5 lines
include/xen/interface/io/vscsiif.h line 200
Quoted 2 lines
include/xen/interface/io/vscsiif.h new file +2
-0+}; +The previous structure had an comment about the size of the structure. Should it be here as well?
I can add one.
Quoted 15 lines
Quoted 15 lines
include/xen/interface/io/vscsiif.h new file +14
-0+struct vscsiif_response { +uint16_t rqid;/* identifies request */ +uint8_t padding; +uint8_t sense_len; +uint8_t sense_buffer[VSCSIIF_SENSE_BUFFERSIZE ]; +int32_t rslt; +uint32_t residual_len;/* request bufflen - +return the value from physical device */ +uint32_t reserved[36 ]; +}; + +DEFINE_RING_TYPES(vscsiif, struct vscsiif_request, struct vscsiif_response); + +#endif /*__XEN__PUBLIC_IO_SCSI_H__*/
Re: [PATCH V5 2/5] Add XEN pvSCSI protocol description
Quoted 242 lines · Juergen Gross
Quoted 133 lines · Konrad Rzeszutek Wilk
Quoted 132 lines · On Mon, Aug 18, 2014 at 11:31:47AM +0200, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add the definition of pvSCSI protocol used between the pvSCSI frontend in a XEN domU and the pvSCSI backend in a XEN driver domain (usually Dom0).
This header was originally provided by Fujitsu for XEN based on Linux 2.6.18. Changes are:
- added comment
- adapt to Linux style guide
- add support for larger SG-lists by putting them in an own granted page
- remove stale definitionsSigned-off-by Juergen Gross <[email protected]>--- include/xen/interface/io/vscsiif.h | 214 +++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 include/xen/interface/io/vscsiif.hinclude/xen/interface/io/vscsiif.h new file +108
-0@@ -0,0 +1,214 @@ +/****************************************************************************** +* vscsiif.h +* +* Based on the blkif.h code. +* +* This interface is to be regarded as a stable API between XEN domains +* running potentially different Linux kernel versions. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +* Copyright(c) FUJITSU Limited 2008. +*/ + +#ifndef __XEN__PUBLIC_IO_SCSI_H__ +#define __XEN__PUBLIC_IO_SCSI_H__ + +#include "ring.h" +#include "../grant_table.h" + +/* +* Front->back notifications: When enqueuing a new request, sending a +* notification can be made conditional on req_event (i.e., the generic +* hold-off mechanism provided by the ring macros). Backends must set +* req_event appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()). +* +* Back->front notifications: When enqueuing a new response, sending a +* notification can be made conditional on rsp_event (i.e., the generic +* hold-off mechanism provided by the ring macros). Frontends must set +* rsp_event appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()). +*/ + +/* +* Feature and Parameter Negotiation +* ================================= +* The two halves of a Xen pvSCSI driver utilize nodes within the XenStore to +* communicate capabilities and to negotiate operating parameters. This +* section enumerates these nodes which reside in the respective front and +* backend portions of the XenStore, following the XenBus convention. +* +* All data in the XenStore is stored as strings. Nodes specifying numeric +* values are encoded in decimal. Integer value ranges listed below are +* expressed as fixed sized integer types capable of storing the conversion +* of a properly formated node string, without loss of information. +* +* Any specified default value is in effect if the corresponding XenBus node +* is not present in the XenStore. +* +* XenStore nodes in sections marked "PRIVATE" are solely for use by the +* driver side whose XenBus tree contains them. +* +***************************************************************************** +* Backend XenBus Nodes +***************************************************************************** +* +*------------------ Backend Device Identification (PRIVATE) ------------------ +* +* p-devname +* Values: string +* +* A free string used to identify the physical device (e.g. a disk name). +* +* p-dev +* Values: string +* +* A string specifying the backend device: either a 4-tuple "h:c:t:l" +* (host, controller, target, lun, all integers), or a WWN (e.g. +* "naa.60014054ac780582"). +* +* v-dev +* Values: string +* +* A string specifying the frontend device in form of a 4-tuple "h:c:t:l" +* (host, controller, target, lun, all integers). +* +*--------------------------------- Features --------------------------------- +* +* feature-sg-grant +* Values: <uint16_t> +* Default Value: 0 +* +* Specifies the maximum number of scatter/gather elements in grant pages +* supported. If not set, the backend supports up to VSCSIIF_SG_TABLESIZE +* SG elements specified directly in the request. +* +***************************************************************************** +* Frontend XenBus Nodes +***************************************************************************** +* +*----------------------- Request Transport Parameters ----------------------- +* +* event-channel +* Values: <uint32_t> Quoted 8 lines
include/xen/interface/io/vscsiif.h line 114
Quoted 6 lines
include/xen/interface/io/vscsiif.h new file +6
-0+* +* The identifier of the Xen event channel used to signal activity +* in the ring buffer. +* +* ring-ref +* Values: <uint32_t> Should there a bit of explanation here about what 'ring ref' is?
Uuh, yes. I'll add it.
Quoted 92 lines
Quoted 36 lines
include/xen/interface/io/vscsiif.h new file +35
-0+* +* protocol +* Values: string (XEN_IO_PROTO_ABI_*) +* Default Value: XEN_IO_PROTO_ABI_NATIVE +* +* The machine ABI rules governing the format of all ring request and +* response structures. +*/ + +/* Requests from the frontend to the backend */ + +/* +* Request a SCSI operation specified via a CDB in vscsiif_request.cmnd. +* The target is specified via channel, id and lun. +*/ +#define VSCSIIF_ACT_SCSI_CDB 1 + +/* +* Request abort of a running operation for the specified target given by +* channel, id, lun and the operation's rqid in ref_rqid. +*/ +#define VSCSIIF_ACT_SCSI_ABORT 2 + +/* +* Request a device reset of the specified target (channel and id). +*/ +#define VSCSIIF_ACT_SCSI_RESET 3 + +/* +* Preset scatter/gather elements for a following request. Deprecated. +* Keeping the define only to avoid usage of the value "4" for other actions. +*/ +#define VSCSIIF_ACT_SCSI_SG_PRESET 4 + +/* include/xen/interface/io/vscsiif.h line 159
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+* Maximum scatter/gather segments per request. +* +* Considering balance between allocating at least 16 "vscsiif_request" +* structures on one page (4096 bytes) and the number of scatter/gather +* elements needed, we decided to use 26 as a magic number. +* +* If "feature-sg-grant" is set, more scatter/gather elements can be specified +* by placing them in one or more (up to VSCSIIF_SG_TABLESIZE) granted pages. +* In this case the vscsiif_request seg elements don't contain references to +* the user data, but to the SG elements referencing the user data. That sounds like the indirect descriptors that virtio and xen-block has. More questions about that below.
Quoted 7 lines
include/xen/interface/io/vscsiif.h new file +7
-0+*/ +#define VSCSIIF_SG_TABLESIZE 26 + +/* +* based on Linux kernel 2.6.18, still valid +* Changing these values requires support of multiple protocols via the rings +* as "old clients" will blindly use these values and the resulting structure include/xen/interface/io/vscsiif.h line 176
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+* sizes. +*/ +#define VSCSIIF_MAX_COMMAND_SIZE 16 +#define VSCSIIF_SENSE_BUFFERSIZE 96 + +struct scsiif_request_segment { +grant_ref_t gref; +uint16_t offset; +uint16_t length; +};Yeey, 8 byte data structure!
Quoted 8 lines
include/xen/interface/io/vscsiif.h new file +8
-0+ +/* Size of one request is 252 bytes */ +struct vscsiif_request { +uint16_t rqid;/* private guest value, echoed in resp */ +uint8_t act;/* command between backend and frontend */ +uint8_t cmd_len;/* valid CDB bytes */ + +uint8_t cmnd[VSCSIIF_MAX_COMMAND_SIZE ];/* the CDB */ include/xen/interface/io/vscsiif.h line 194
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+uint16_t timeout_per_command; +uint16_t channel, id, lun;/* (virtual) device specification */ +uint16_t ref_rqid;/* command abort reference */ +uint8_t sc_data_direction;/* for DMA_TO_DEVICE(1) +DMA_FROM_DEVICE(2) +DMA_NONE(3) requests */ +uint8_t nr_segments;/* Number of pieces of scatter-gather */ +#define VSCSIIF_SG_GRANT 0x80/* flag: SG elements via grant page */ +/* nr_segments counts grant pages with +SG elements Stop missing. However I am a bit lost. It says that the '
nr_segments' will have the count of grant pages with SG elements. Does that mean the req.seg[0].gref points to an page which will have an array of grant references? And each grant reference will point to a data page? What about the 'offset' and 'length' of them?Quoted 4 lines
Or does it mean that the 'reg.seg[0].gref' points an page that is filled with 'struct
scsiif_request_segment' ? If so, where would the could of those segments be in? In 'nr_segments'? If that is so where does theVSCSIIF_SG_GRANTgo? Won't we collide?
Quoted 4 lines
nr_segments(without theVSCSIIF_SG_GRANTbit) always counts the number of populated seg[] entries. IfVSCSIIF_SG_GRANTis set, each seg[] entry references another array of structscsiif_request_segmentusing a grant ref, offset into the granted page and a length of the array in bytes.
Shouldn't there be a comment about that? The blkif.h has a pretty lengthy one when it comes to indirect descriptors that could be copied as it sounds exactly like the same thing.
Quoted 4 lines
The resulting number of struct
scsiif_request_segmentis the sum of seg[0..nr_segments-1].length /sizeof(struct scsiif_request_segment).
Where the nr_segments can only go Up to VSCSIIF_SG_TABLESIZE, so the max total SG entries you can is 13312 ( 4096 / 8 = 512 max per page, times 26).
Quoted 11 lines
Quoted 8 lines
include/xen/interface/io/vscsiif.h line 198
Quoted 6 lines
include/xen/interface/io/vscsiif.h new file +4
-0+usable if "feature-sg-grant" set */ + +struct scsiif_request_segment seg[VSCSIIF_SG_TABLESIZE ]; +uint32_t reserved[3 ];Or is the flag suppose to show up here?
No. There is no guarantee an "old" domU not aware of "feature-sg-grant" will have set reserved[] to zero.
<nods>
Quoted 8 lines
Quoted 6 lines
include/xen/interface/io/vscsiif.h line 200
Quoted 3 lines
include/xen/interface/io/vscsiif.h new file +2
-0+}; +The previous structure had an comment about the size of the structure. Should it be here as well?
I can add one.
Thank you!
Quoted 17 lines
Quoted 16 lines
Quoted 16 lines
include/xen/interface/io/vscsiif.h new file +14
-0+struct vscsiif_response { +uint16_t rqid;/* identifies request */ +uint8_t padding; +uint8_t sense_len; +uint8_t sense_buffer[VSCSIIF_SENSE_BUFFERSIZE ]; +int32_t rslt; +uint32_t residual_len;/* request bufflen - +return the value from physical device */ +uint32_t reserved[36 ]; +}; + +DEFINE_RING_TYPES(vscsiif, struct vscsiif_request, struct vscsiif_response); + +#endif /*__XEN__PUBLIC_IO_SCSI_H__*/
Re: [Xen-devel] [PATCH V5 2/5] Add XEN pvSCSI protocol description
In reply to Juergen GrossQuoted 242 lines · Juergen Gross
Quoted 133 lines · Konrad Rzeszutek Wilk
Quoted 132 lines · On Mon, Aug 18, 2014 at 11:31:47AM +0200, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add the definition of pvSCSI protocol used between the pvSCSI frontend in a XEN domU and the pvSCSI backend in a XEN driver domain (usually Dom0).
This header was originally provided by Fujitsu for XEN based on Linux 2.6.18. Changes are:
- added comment
- adapt to Linux style guide
- add support for larger SG-lists by putting them in an own granted page
- remove stale definitionsSigned-off-by Juergen Gross <[email protected]>--- include/xen/interface/io/vscsiif.h | 214 +++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 include/xen/interface/io/vscsiif.hinclude/xen/interface/io/vscsiif.h new file +108
-0@@ -0,0 +1,214 @@ +/****************************************************************************** +* vscsiif.h +* +* Based on the blkif.h code. +* +* This interface is to be regarded as a stable API between XEN domains +* running potentially different Linux kernel versions. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +* Copyright(c) FUJITSU Limited 2008. +*/ + +#ifndef __XEN__PUBLIC_IO_SCSI_H__ +#define __XEN__PUBLIC_IO_SCSI_H__ + +#include "ring.h" +#include "../grant_table.h" + +/* +* Front->back notifications: When enqueuing a new request, sending a +* notification can be made conditional on req_event (i.e., the generic +* hold-off mechanism provided by the ring macros). Backends must set +* req_event appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()). +* +* Back->front notifications: When enqueuing a new response, sending a +* notification can be made conditional on rsp_event (i.e., the generic +* hold-off mechanism provided by the ring macros). Frontends must set +* rsp_event appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()). +*/ + +/* +* Feature and Parameter Negotiation +* ================================= +* The two halves of a Xen pvSCSI driver utilize nodes within the XenStore to +* communicate capabilities and to negotiate operating parameters. This +* section enumerates these nodes which reside in the respective front and +* backend portions of the XenStore, following the XenBus convention. +* +* All data in the XenStore is stored as strings. Nodes specifying numeric +* values are encoded in decimal. Integer value ranges listed below are +* expressed as fixed sized integer types capable of storing the conversion +* of a properly formated node string, without loss of information. +* +* Any specified default value is in effect if the corresponding XenBus node +* is not present in the XenStore. +* +* XenStore nodes in sections marked "PRIVATE" are solely for use by the +* driver side whose XenBus tree contains them. +* +***************************************************************************** +* Backend XenBus Nodes +***************************************************************************** +* +*------------------ Backend Device Identification (PRIVATE) ------------------ +* +* p-devname +* Values: string +* +* A free string used to identify the physical device (e.g. a disk name). +* +* p-dev +* Values: string +* +* A string specifying the backend device: either a 4-tuple "h:c:t:l" +* (host, controller, target, lun, all integers), or a WWN (e.g. +* "naa.60014054ac780582"). +* +* v-dev +* Values: string +* +* A string specifying the frontend device in form of a 4-tuple "h:c:t:l" +* (host, controller, target, lun, all integers). +* +*--------------------------------- Features --------------------------------- +* +* feature-sg-grant +* Values: <uint16_t> +* Default Value: 0 +* +* Specifies the maximum number of scatter/gather elements in grant pages +* supported. If not set, the backend supports up to VSCSIIF_SG_TABLESIZE +* SG elements specified directly in the request. +* +***************************************************************************** +* Frontend XenBus Nodes +***************************************************************************** +* +*----------------------- Request Transport Parameters ----------------------- +* +* event-channel +* Values: <uint32_t> Quoted 8 lines
include/xen/interface/io/vscsiif.h line 114
Quoted 6 lines
include/xen/interface/io/vscsiif.h new file +6
-0+* +* The identifier of the Xen event channel used to signal activity +* in the ring buffer. +* +* ring-ref +* Values: <uint32_t> Should there a bit of explanation here about what 'ring ref' is?
Uuh, yes. I'll add it.
Quoted 92 lines
Quoted 36 lines
include/xen/interface/io/vscsiif.h new file +35
-0+* +* protocol +* Values: string (XEN_IO_PROTO_ABI_*) +* Default Value: XEN_IO_PROTO_ABI_NATIVE +* +* The machine ABI rules governing the format of all ring request and +* response structures. +*/ + +/* Requests from the frontend to the backend */ + +/* +* Request a SCSI operation specified via a CDB in vscsiif_request.cmnd. +* The target is specified via channel, id and lun. +*/ +#define VSCSIIF_ACT_SCSI_CDB 1 + +/* +* Request abort of a running operation for the specified target given by +* channel, id, lun and the operation's rqid in ref_rqid. +*/ +#define VSCSIIF_ACT_SCSI_ABORT 2 + +/* +* Request a device reset of the specified target (channel and id). +*/ +#define VSCSIIF_ACT_SCSI_RESET 3 + +/* +* Preset scatter/gather elements for a following request. Deprecated. +* Keeping the define only to avoid usage of the value "4" for other actions. +*/ +#define VSCSIIF_ACT_SCSI_SG_PRESET 4 + +/* include/xen/interface/io/vscsiif.h line 159
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+* Maximum scatter/gather segments per request. +* +* Considering balance between allocating at least 16 "vscsiif_request" +* structures on one page (4096 bytes) and the number of scatter/gather +* elements needed, we decided to use 26 as a magic number. +* +* If "feature-sg-grant" is set, more scatter/gather elements can be specified +* by placing them in one or more (up to VSCSIIF_SG_TABLESIZE) granted pages. +* In this case the vscsiif_request seg elements don't contain references to +* the user data, but to the SG elements referencing the user data. That sounds like the indirect descriptors that virtio and xen-block has. More questions about that below.
Quoted 7 lines
include/xen/interface/io/vscsiif.h new file +7
-0+*/ +#define VSCSIIF_SG_TABLESIZE 26 + +/* +* based on Linux kernel 2.6.18, still valid +* Changing these values requires support of multiple protocols via the rings +* as "old clients" will blindly use these values and the resulting structure include/xen/interface/io/vscsiif.h line 176
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+* sizes. +*/ +#define VSCSIIF_MAX_COMMAND_SIZE 16 +#define VSCSIIF_SENSE_BUFFERSIZE 96 + +struct scsiif_request_segment { +grant_ref_t gref; +uint16_t offset; +uint16_t length; +};Yeey, 8 byte data structure!
Quoted 8 lines
include/xen/interface/io/vscsiif.h new file +8
-0+ +/* Size of one request is 252 bytes */ +struct vscsiif_request { +uint16_t rqid;/* private guest value, echoed in resp */ +uint8_t act;/* command between backend and frontend */ +uint8_t cmd_len;/* valid CDB bytes */ + +uint8_t cmnd[VSCSIIF_MAX_COMMAND_SIZE ];/* the CDB */ include/xen/interface/io/vscsiif.h line 194
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+uint16_t timeout_per_command; +uint16_t channel, id, lun;/* (virtual) device specification */ +uint16_t ref_rqid;/* command abort reference */ +uint8_t sc_data_direction;/* for DMA_TO_DEVICE(1) +DMA_FROM_DEVICE(2) +DMA_NONE(3) requests */ +uint8_t nr_segments;/* Number of pieces of scatter-gather */ +#define VSCSIIF_SG_GRANT 0x80/* flag: SG elements via grant page */ +/* nr_segments counts grant pages with +SG elements Stop missing. However I am a bit lost. It says that the '
nr_segments' will have the count of grant pages with SG elements. Does that mean the req.seg[0].gref points to an page which will have an array of grant references? And each grant reference will point to a data page? What about the 'offset' and 'length' of them?Quoted 4 lines
Or does it mean that the 'reg.seg[0].gref' points an page that is filled with 'struct
scsiif_request_segment' ? If so, where would the could of those segments be in? In 'nr_segments'? If that is so where does theVSCSIIF_SG_GRANTgo? Won't we collide?
Quoted 4 lines
nr_segments(without theVSCSIIF_SG_GRANTbit) always counts the number of populated seg[] entries. IfVSCSIIF_SG_GRANTis set, each seg[] entry references another array of structscsiif_request_segmentusing a grant ref, offset into the granted page and a length of the array in bytes.
Shouldn't there be a comment about that? The blkif.h has a pretty lengthy one when it comes to indirect descriptors that could be copied as it sounds exactly like the same thing.
Quoted 4 lines
The resulting number of struct
scsiif_request_segmentis the sum of seg[0..nr_segments-1].length /sizeof(struct scsiif_request_segment).
Where the nr_segments can only go Up to VSCSIIF_SG_TABLESIZE, so the max total SG entries you can is 13312 ( 4096 / 8 = 512 max per page, times 26).
Quoted 11 lines
Quoted 8 lines
include/xen/interface/io/vscsiif.h line 198
Quoted 6 lines
include/xen/interface/io/vscsiif.h new file +4
-0+usable if "feature-sg-grant" set */ + +struct scsiif_request_segment seg[VSCSIIF_SG_TABLESIZE ]; +uint32_t reserved[3 ];Or is the flag suppose to show up here?
No. There is no guarantee an "old" domU not aware of "feature-sg-grant" will have set reserved[] to zero.
<nods>
Quoted 8 lines
Quoted 6 lines
include/xen/interface/io/vscsiif.h line 200
Quoted 3 lines
include/xen/interface/io/vscsiif.h new file +2
-0+}; +The previous structure had an comment about the size of the structure. Should it be here as well?
I can add one.
Thank you!
Quoted 17 lines
Quoted 16 lines
Quoted 16 lines
include/xen/interface/io/vscsiif.h new file +14
-0+struct vscsiif_response { +uint16_t rqid;/* identifies request */ +uint8_t padding; +uint8_t sense_len; +uint8_t sense_buffer[VSCSIIF_SENSE_BUFFERSIZE ]; +int32_t rslt; +uint32_t residual_len;/* request bufflen - +return the value from physical device */ +uint32_t reserved[36 ]; +}; + +DEFINE_RING_TYPES(vscsiif, struct vscsiif_request, struct vscsiif_response); + +#endif /*__XEN__PUBLIC_IO_SCSI_H__*/
Juergen Gross
maintainerRe: [Xen-devel] [PATCH V5 2/5] Add XEN pvSCSI protocol description
Quoted 3 lines · Konrad Rzeszutek Wilk
Quoted 2 lines · Juergen Gross
Quoted 1 line · Konrad Rzeszutek Wilk
On Mon, Aug 18, 2014 at 11:31:47AM +0200, [email protected] wrote:
...
Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
Quoted 6 lines
include/xen/interface/io/vscsiif.h new file +6
-0+struct vscsiif_request { +uint16_t rqid;/* private guest value, echoed in resp */ +uint8_t act;/* command between backend and frontend */ +uint8_t cmd_len;/* valid CDB bytes */ + +uint8_t cmnd[VSCSIIF_MAX_COMMAND_SIZE ];/* the CDB */ include/xen/interface/io/vscsiif.h line 194
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+uint16_t timeout_per_command; +uint16_t channel, id, lun;/* (virtual) device specification */ +uint16_t ref_rqid;/* command abort reference */ +uint8_t sc_data_direction;/* for DMA_TO_DEVICE(1) +DMA_FROM_DEVICE(2) +DMA_NONE(3) requests */ +uint8_t nr_segments;/* Number of pieces of scatter-gather */ +#define VSCSIIF_SG_GRANT 0x80/* flag: SG elements via grant page */ +/* nr_segments counts grant pages with +SG elements Stop missing. However I am a bit lost. It says that the '
nr_segments' will have the count of grant pages with SG elements. Does that mean the req.seg[0].gref points to an page which will have an array of grant references? And each grant reference will point to a data page? What about the 'offset' and 'length' of them?Or does it mean that the 'reg.seg[0].gref' points an page that is filled with 'struct
scsiif_request_segment' ? If so, where would the could of those segments be in? In 'nr_segments'? If that is so where does theVSCSIIF_SG_GRANTgo? Won't we collide?
Quoted 8 lines
Quoted 4 lines
nr_segments(without theVSCSIIF_SG_GRANTbit) always counts the number of populated seg[] entries. IfVSCSIIF_SG_GRANTis set, each seg[] entry references another array of structscsiif_request_segmentusing a grant ref, offset into the granted page and a length of the array in bytes.Shouldn't there be a comment about that? The
blkif.hhas a pretty lengthy one when it comes to indirect descriptors that could be copied as it sounds exactly like the same thing.
I already added the following:
/*
* Request a SCSI operation specified via a CDB in vscsiif_request.cmnd.
* The target is specified via channel, id and lun.
* The operation to be performed is specified via a CDB in cmnd[], the
length
* of the CDB is in cmd_len. sc_data_direction specifies the direction
of data
* (to the device, from the device, or none at all).
* If data is to be transferred to or from the device the buffer(s) in the
* guest memory is/are specified via one or multiple scsiif_request_segment
* descriptors each specifying a memory page via a grant_ref_t, a
offset into
* the page and the length of the area in that page. Allscsiif_request_segment
* areas concatenated form the resulting data buffer used by the operation.
* If the number of scsiif_request_segment areas is not too large (less
than
* or equal VSCSIIF_SG_TABLESIZE) the areas can be specified directly
in the
* seg[] array and the number of valid scsiif_request_segment elements
is to be
* set in nr_segments.
* If "feature-sg-grant" in the Xenstore is set it is possible to
specify more
* than VSCSIIF_SG_TABLESIZE scsiif_request_segment elements via
indirection.
* The maximum number of allowed scsiif_request_segment elements is the
value
* of the "feature-sg-grant" entry from Xenstore. When using
indirection the
* seg[] array doesn't contain specifications of the data buffers, but
* references to scsiif_request_segment arrays, which in turn reference the
* data buffers. While nr_segments holds the number of populated seg[]
entries
* (plus the set VSCSIIF_SG_GRANT bit), the number ofscsiif_request_segment
* elements referencing the target data buffers is calculated from the
lengths
* of the seg[] elements (the sum of all valid seg[].length divided by the
* size of one scsiif_request_segment structure).
*/
#define VSCSIIF_ACT_SCSI_CDB 1
Quoted 8 lines
Quoted 4 lines
The resulting number of struct
scsiif_request_segmentis the sum of seg[0..nr_segments-1].length /sizeof(struct scsiif_request_segment).Where the
nr_segmentscan only go Up toVSCSIIF_SG_TABLESIZE, so the max total SG entries you can is 13312 ( 4096 / 8 = 512 max per page, times 26).
In theory, yes. SG_ALL (being 128 today) is limiting this value.
Juergen
Re: [Xen-devel] [PATCH V5 2/5] Add XEN pvSCSI protocol description
Quoted 9 lines · Juergen Gross
Quoted 7 lines
Quoted 3 lines
The resulting number of struct
scsiif_request_segmentis the sum of seg[0..nr_segments-1].length /sizeof(struct scsiif_request_segment).Where the
nr_segmentscan only go Up toVSCSIIF_SG_TABLESIZE, so the max total SG entries you can is 13312 ( 4096 / 8 = 512 max per page, times 26).In theory, yes.
SG_ALL(being 128 today) is limiting this value.
Note that SG_ALL (or SCSI_MAX_SG_SEGMENTS which is a better name for it) is only the maximum if your driver doesn't support S/G chaining. Given that it and the Xen infrastructure seems to use the proper s/g list helpers it should support SCSI_MAX_SG_CHAIN_SEGMENTS easily.
Re: [PATCH V5 2/5] Add XEN pvSCSI protocol description
In reply to Juergen GrossQuoted 9 lines · Juergen Gross
Quoted 7 lines
Quoted 3 lines
The resulting number of struct
scsiif_request_segmentis the sum of seg[0..nr_segments-1].length /sizeof(struct scsiif_request_segment).Where the
nr_segmentscan only go Up toVSCSIIF_SG_TABLESIZE, so the max total SG entries you can is 13312 ( 4096 / 8 = 512 max per page, times 26).In theory, yes.
SG_ALL(being 128 today) is limiting this value.
Note that SG_ALL (or SCSI_MAX_SG_SEGMENTS which is a better name for it) is only the maximum if your driver doesn't support S/G chaining. Given that it and the Xen infrastructure seems to use the proper s/g list helpers it should support SCSI_MAX_SG_CHAIN_SEGMENTS easily.
Juergen Gross
maintainerRe: [PATCH V5 2/5] Add XEN pvSCSI protocol description
In reply to Konrad Rzeszutek WilkQuoted 3 lines · Konrad Rzeszutek Wilk
Quoted 2 lines · Juergen Gross
Quoted 1 line · Konrad Rzeszutek Wilk
On Mon, Aug 18, 2014 at 11:31:47AM +0200, [email protected] wrote:
...
Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
Quoted 6 lines
include/xen/interface/io/vscsiif.h new file +6
-0+struct vscsiif_request { +uint16_t rqid;/* private guest value, echoed in resp */ +uint8_t act;/* command between backend and frontend */ +uint8_t cmd_len;/* valid CDB bytes */ + +uint8_t cmnd[VSCSIIF_MAX_COMMAND_SIZE ];/* the CDB */ include/xen/interface/io/vscsiif.h line 194
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+uint16_t timeout_per_command; +uint16_t channel, id, lun;/* (virtual) device specification */ +uint16_t ref_rqid;/* command abort reference */ +uint8_t sc_data_direction;/* for DMA_TO_DEVICE(1) +DMA_FROM_DEVICE(2) +DMA_NONE(3) requests */ +uint8_t nr_segments;/* Number of pieces of scatter-gather */ +#define VSCSIIF_SG_GRANT 0x80/* flag: SG elements via grant page */ +/* nr_segments counts grant pages with +SG elements Stop missing. However I am a bit lost. It says that the '
nr_segments' will have the count of grant pages with SG elements. Does that mean the req.seg[0].gref points to an page which will have an array of grant references? And each grant reference will point to a data page? What about the 'offset' and 'length' of them?Or does it mean that the 'reg.seg[0].gref' points an page that is filled with 'struct
scsiif_request_segment' ? If so, where would the could of those segments be in? In 'nr_segments'? If that is so where does theVSCSIIF_SG_GRANTgo? Won't we collide?
Quoted 8 lines
Quoted 4 lines
nr_segments(without theVSCSIIF_SG_GRANTbit) always counts the number of populated seg[] entries. IfVSCSIIF_SG_GRANTis set, each seg[] entry references another array of structscsiif_request_segmentusing a grant ref, offset into the granted page and a length of the array in bytes.Shouldn't there be a comment about that? The
blkif.hhas a pretty lengthy one when it comes to indirect descriptors that could be copied as it sounds exactly like the same thing.
I already added the following:
/*
* Request a SCSI operation specified via a CDB in vscsiif_request.cmnd.
* The target is specified via channel, id and lun.
* The operation to be performed is specified via a CDB in cmnd[], the
length
* of the CDB is in cmd_len. sc_data_direction specifies the direction
of data
* (to the device, from the device, or none at all).
* If data is to be transferred to or from the device the buffer(s) in the
* guest memory is/are specified via one or multiple scsiif_request_segment
* descriptors each specifying a memory page via a grant_ref_t, a
offset into
* the page and the length of the area in that page. Allscsiif_request_segment
* areas concatenated form the resulting data buffer used by the operation.
* If the number of scsiif_request_segment areas is not too large (less
than
* or equal VSCSIIF_SG_TABLESIZE) the areas can be specified directly
in the
* seg[] array and the number of valid scsiif_request_segment elements
is to be
* set in nr_segments.
* If "feature-sg-grant" in the Xenstore is set it is possible to
specify more
* than VSCSIIF_SG_TABLESIZE scsiif_request_segment elements via
indirection.
* The maximum number of allowed scsiif_request_segment elements is the
value
* of the "feature-sg-grant" entry from Xenstore. When using
indirection the
* seg[] array doesn't contain specifications of the data buffers, but
* references to scsiif_request_segment arrays, which in turn reference the
* data buffers. While nr_segments holds the number of populated seg[]
entries
* (plus the set VSCSIIF_SG_GRANT bit), the number ofscsiif_request_segment
* elements referencing the target data buffers is calculated from the
lengths
* of the seg[] elements (the sum of all valid seg[].length divided by the
* size of one scsiif_request_segment structure).
*/
#define VSCSIIF_ACT_SCSI_CDB 1
Quoted 8 lines
Quoted 4 lines
The resulting number of struct
scsiif_request_segmentis the sum of seg[0..nr_segments-1].length /sizeof(struct scsiif_request_segment).Where the
nr_segmentscan only go Up toVSCSIIF_SG_TABLESIZE, so the max total SG entries you can is 13312 ( 4096 / 8 = 512 max per page, times 26).
In theory, yes. SG_ALL (being 128 today) is limiting this value.
Juergen
Juergen Gross
maintainerRe: [PATCH V5 2/5] Add XEN pvSCSI protocol description
In reply to Konrad Rzeszutek WilkQuoted 133 lines · Konrad Rzeszutek Wilk
Quoted 132 lines · On Mon, Aug 18, 2014 at 11:31:47AM +0200, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add the definition of pvSCSI protocol used between the pvSCSI frontend in a XEN domU and the pvSCSI backend in a XEN driver domain (usually Dom0).
This header was originally provided by Fujitsu for XEN based on Linux 2.6.18. Changes are:
- added comment
- adapt to Linux style guide
- add support for larger SG-lists by putting them in an own granted page
- remove stale definitionsSigned-off-by Juergen Gross <[email protected]>--- include/xen/interface/io/vscsiif.h | 214 +++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+)create mode 100644
include/xen/interface/io/vscsiif.hinclude/xen/interface/io/vscsiif.h new file +108
-0@@ -0,0 +1,214 @@ +/****************************************************************************** +* vscsiif.h +* +* Based on the blkif.h code. +* +* This interface is to be regarded as a stable API between XEN domains +* running potentially different Linux kernel versions. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +* Copyright(c) FUJITSU Limited 2008. +*/ + +#ifndef __XEN__PUBLIC_IO_SCSI_H__ +#define __XEN__PUBLIC_IO_SCSI_H__ + +#include "ring.h" +#include "../grant_table.h" + +/* +* Front->back notifications: When enqueuing a new request, sending a +* notification can be made conditional on req_event (i.e., the generic +* hold-off mechanism provided by the ring macros). Backends must set +* req_event appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()). +* +* Back->front notifications: When enqueuing a new response, sending a +* notification can be made conditional on rsp_event (i.e., the generic +* hold-off mechanism provided by the ring macros). Frontends must set +* rsp_event appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()). +*/ + +/* +* Feature and Parameter Negotiation +* ================================= +* The two halves of a Xen pvSCSI driver utilize nodes within the XenStore to +* communicate capabilities and to negotiate operating parameters. This +* section enumerates these nodes which reside in the respective front and +* backend portions of the XenStore, following the XenBus convention. +* +* All data in the XenStore is stored as strings. Nodes specifying numeric +* values are encoded in decimal. Integer value ranges listed below are +* expressed as fixed sized integer types capable of storing the conversion +* of a properly formated node string, without loss of information. +* +* Any specified default value is in effect if the corresponding XenBus node +* is not present in the XenStore. +* +* XenStore nodes in sections marked "PRIVATE" are solely for use by the +* driver side whose XenBus tree contains them. +* +***************************************************************************** +* Backend XenBus Nodes +***************************************************************************** +* +*------------------ Backend Device Identification (PRIVATE) ------------------ +* +* p-devname +* Values: string +* +* A free string used to identify the physical device (e.g. a disk name). +* +* p-dev +* Values: string +* +* A string specifying the backend device: either a 4-tuple "h:c:t:l" +* (host, controller, target, lun, all integers), or a WWN (e.g. +* "naa.60014054ac780582"). +* +* v-dev +* Values: string +* +* A string specifying the frontend device in form of a 4-tuple "h:c:t:l" +* (host, controller, target, lun, all integers). +* +*--------------------------------- Features --------------------------------- +* +* feature-sg-grant +* Values: <uint16_t> +* Default Value: 0 +* +* Specifies the maximum number of scatter/gather elements in grant pages +* supported. If not set, the backend supports up to VSCSIIF_SG_TABLESIZE +* SG elements specified directly in the request. +* +***************************************************************************** +* Frontend XenBus Nodes +***************************************************************************** +* +*----------------------- Request Transport Parameters ----------------------- +* +* event-channel +* Values: <uint32_t>
Quoted 8 lines
include/xen/interface/io/vscsiif.h line 114
Quoted 6 lines
include/xen/interface/io/vscsiif.h new file +6
-0+* +* The identifier of the Xen event channel used to signal activity +* in the ring buffer. +* +* ring-ref +* Values: <uint32_t> Should there a bit of explanation here about what 'ring ref' is?
Uuh, yes. I'll add it.
Quoted 92 lines
Quoted 36 lines
include/xen/interface/io/vscsiif.h new file +35
-0+* +* protocol +* Values: string (XEN_IO_PROTO_ABI_*) +* Default Value: XEN_IO_PROTO_ABI_NATIVE +* +* The machine ABI rules governing the format of all ring request and +* response structures. +*/ + +/* Requests from the frontend to the backend */ + +/* +* Request a SCSI operation specified via a CDB in vscsiif_request.cmnd. +* The target is specified via channel, id and lun. +*/ +#define VSCSIIF_ACT_SCSI_CDB 1 + +/* +* Request abort of a running operation for the specified target given by +* channel, id, lun and the operation's rqid in ref_rqid. +*/ +#define VSCSIIF_ACT_SCSI_ABORT 2 + +/* +* Request a device reset of the specified target (channel and id). +*/ +#define VSCSIIF_ACT_SCSI_RESET 3 + +/* +* Preset scatter/gather elements for a following request. Deprecated. +* Keeping the define only to avoid usage of the value "4" for other actions. +*/ +#define VSCSIIF_ACT_SCSI_SG_PRESET 4 + +/* include/xen/interface/io/vscsiif.h line 159
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+* Maximum scatter/gather segments per request. +* +* Considering balance between allocating at least 16 "vscsiif_request" +* structures on one page (4096 bytes) and the number of scatter/gather +* elements needed, we decided to use 26 as a magic number. +* +* If "feature-sg-grant" is set, more scatter/gather elements can be specified +* by placing them in one or more (up to VSCSIIF_SG_TABLESIZE) granted pages. +* In this case the vscsiif_request seg elements don't contain references to +* the user data, but to the SG elements referencing the user data. That sounds like the indirect descriptors that virtio and xen-block has. More questions about that below.
Quoted 7 lines
include/xen/interface/io/vscsiif.h new file +7
-0+*/ +#define VSCSIIF_SG_TABLESIZE 26 + +/* +* based on Linux kernel 2.6.18, still valid +* Changing these values requires support of multiple protocols via the rings +* as "old clients" will blindly use these values and the resulting structure include/xen/interface/io/vscsiif.h line 176
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+* sizes. +*/ +#define VSCSIIF_MAX_COMMAND_SIZE 16 +#define VSCSIIF_SENSE_BUFFERSIZE 96 + +struct scsiif_request_segment { +grant_ref_t gref; +uint16_t offset; +uint16_t length; +};Yeey, 8 byte data structure!
Quoted 8 lines
include/xen/interface/io/vscsiif.h new file +8
-0+ +/* Size of one request is 252 bytes */ +struct vscsiif_request { +uint16_t rqid;/* private guest value, echoed in resp */ +uint8_t act;/* command between backend and frontend */ +uint8_t cmd_len;/* valid CDB bytes */ + +uint8_t cmnd[VSCSIIF_MAX_COMMAND_SIZE ];/* the CDB */ include/xen/interface/io/vscsiif.h line 194
Quoted 10 lines
include/xen/interface/io/vscsiif.h new file +10
-0+uint16_t timeout_per_command; +uint16_t channel, id, lun;/* (virtual) device specification */ +uint16_t ref_rqid;/* command abort reference */ +uint8_t sc_data_direction;/* for DMA_TO_DEVICE(1) +DMA_FROM_DEVICE(2) +DMA_NONE(3) requests */ +uint8_t nr_segments;/* Number of pieces of scatter-gather */ +#define VSCSIIF_SG_GRANT 0x80/* flag: SG elements via grant page */ +/* nr_segments counts grant pages with +SG elements Stop missing. However I am a bit lost. It says that the '
nr_segments' will have the count of grant pages with SG elements. Does that mean the req.seg[0].gref points to an page which will have an array of grant references? And each grant reference will point to a data page? What about the 'offset' and 'length' of them?
Quoted 4 lines
Or does it mean that the 'reg.seg[0].gref' points an page that is filled with 'struct
scsiif_request_segment' ? If so, where would the could of those segments be in? In 'nr_segments'? If that is so where does theVSCSIIF_SG_GRANTgo? Won't we collide?
nr_segments (without the VSCSIIF_SG_GRANT bit) always counts the number of populated seg[] entries. If VSCSIIF_SG_GRANT is set, each seg[] entry references another array of struct scsiif_request_segment using a grant ref, offset into the granted page and a length of the array in bytes.
The resulting number of struct scsiif_request_segment is the sum of seg[0..nr_segments-1].length / sizeof(struct scsiif_request_segment).
Quoted 8 lines
include/xen/interface/io/vscsiif.h line 198
Quoted 6 lines
include/xen/interface/io/vscsiif.h new file +4
-0+usable if "feature-sg-grant" set */ + +struct scsiif_request_segment seg[VSCSIIF_SG_TABLESIZE ]; +uint32_t reserved[3 ];Or is the flag suppose to show up here?
No. There is no guarantee an "old" domU not aware of "feature-sg-grant" will have set reserved[] to zero.
Quoted 5 lines
include/xen/interface/io/vscsiif.h line 200
Quoted 2 lines
include/xen/interface/io/vscsiif.h new file +2
-0+}; +The previous structure had an comment about the size of the structure. Should it be here as well?
I can add one.
Quoted 15 lines
Quoted 15 lines
include/xen/interface/io/vscsiif.h new file +14
-0+struct vscsiif_response { +uint16_t rqid;/* identifies request */ +uint8_t padding; +uint8_t sense_len; +uint8_t sense_buffer[VSCSIIF_SENSE_BUFFERSIZE ]; +int32_t rslt; +uint32_t residual_len;/* request bufflen - +return the value from physical device */ +uint32_t reserved[36 ]; +}; + +DEFINE_RING_TYPES(vscsiif, struct vscsiif_request, struct vscsiif_response); + +#endif /*__XEN__PUBLIC_IO_SCSI_H__*/
Re: [PATCH V5 2/5] Add XEN pvSCSI protocol description
In reply to [email protected]Quoted 1 line · On 18/08/14 10:31, [email protected] wrote:
- add support for larger SG-lists by putting them in an own granted page
As a reminder, this can't be acked until this protocol change has been applied to Xen copy of this header.
David
Re: [PATCH V5 2/5] Add XEN pvSCSI protocol description
In reply to [email protected]Quoted 1 line · On 18/08/14 10:31, [email protected] wrote:
- add support for larger SG-lists by putting them in an own granted page
As a reminder, this can't be acked until this protocol change has been applied to Xen copy of this header.
David
[email protected]
maintainerPATCH v5 3/5 Introduce xen-scsifront module
In reply to [email protected]From: Juergen Gross <[email protected]>
Introduces the XEN pvSCSI frontend. With pvSCSI it is possible for a XEN domU to issue SCSI commands to a SCSI LUN assigned to that domU. The SCSI commands are passed to the pvSCSI backend in a driver domain (usually Dom0) which is owner of the physical device. This allows e.g. to use SCSI tape drives in a XEN domU.
The code is taken from the pvSCSI implementation in XEN done by Fujitsu based on Linux kernel 2.6.18.
Changes from the original version are:
- port to upstream kernel
- put all code in just one source file
- move module to appropriate location in kernel tree
- adapt to Linux style guide
- some minor code simplifications
- replace constants with defines
- remove not used defines
- add support for larger SG lists by putting them in a granted page
Xen related parts
--- drivers/scsi/Kconfig | 9 + drivers/scsi/Makefile | 1 + drivers/scsi/xen-scsifront.c | 1017 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1027 insertions(+) create mode 100644 drivers/scsi/xen-scsifront.c
drivers/scsi/Kconfig +9 -0
@@ -576,6 +576,15 @@ config VMWARE_PVSCSI To compile this driver as a module, choose M here: the module will be called vmw_pvscsi. +config XEN_SCSI_FRONTEND + tristate "XEN SCSI frontend driver" + depends on SCSI && XEN + help + The XEN SCSI frontend driver allows the kernel to access SCSI Devices + within another guest OS (usually Dom0). + Only needed if the kernel is running in a XEN guest and generic + SCSI access to a device is needed. + config HYPERV_STORAGE tristate "Microsoft Hyper-V virtual storage driver" depends on SCSI && HYPERV
drivers/scsi/Makefile +1 -0
@@ -141,6 +141,7 @@ obj-$(CONFIG_SCSI_ESAS2R) += esas2r/ obj-$(CONFIG_SCSI_PMCRAID) += pmcraid.o obj-$(CONFIG_SCSI_VIRTIO) += virtio_scsi.o obj-$(CONFIG_VMWARE_PVSCSI) += vmw_pvscsi.o +obj-$(CONFIG_XEN_SCSI_FRONTEND) += xen-scsifront.o obj-$(CONFIG_HYPERV_STORAGE) += hv_storvsc.o obj-$(CONFIG_ARM) += arm/
drivers/scsi/xen-scsifront.c new file +1017 -0
1,017 lines not on this page · raw message
Signature · 1 line
1.8.4.5
Re: [Xen-devel] [PATCH V5 3/5] Introduce xen-scsifront module
Quoted 24 lines
drivers/scsi/xen-scsifront.c new file +21
-0@@ -0,0 +1,1017 @@ +/* +* Xen SCSI frontend driver +* +* Copyright (c) 2008, FUJITSU Limited +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation; or, when distributed +* separately from the Linux kernel or incorporated into other +* software packages, subject to the following license: +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this source file (the "Software"), to deal in the Software without +* restriction, including without limitation the rights to use, copy, modify, +* merge, publish, distribute, sublicense, and/or sell copies of the Software, +* and to permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +*
drivers/scsi/xen-scsifront.c line 31
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +#define DEBUG
:-) I think you don't want that in the driver.
Quoted 24 lines
drivers/scsi/xen-scsifront.c new file +24
-0+ +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/device.h> +#include <linux/wait.h> +#include <linux/interrupt.h> +#include <linux/spinlock.h> +#include <linux/sched.h> +#include <linux/blkdev.h> +#include <linux/pfn.h> +#include <linux/slab.h> + +#include <scsi/scsi_cmnd.h> +#include <scsi/scsi_device.h> +#include <scsi/scsi.h> +#include <scsi/scsi_host.h> + +#include <xen/xen.h> +#include <xen/xenbus.h> +#include <xen/grant_table.h> +#include <xen/events.h> +#include <xen/page.h> + +#include <xen/interface/grant_table.h>
drivers/scsi/xen-scsifront.c line 65
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+#include <xen/interface/io/vscsiif.h> +#include <xen/interface/io/protocols.h> + +#include <asm/xen/hypervisor.h> + + +#define GRANT_INVALID_REF 0 + +#define VSCSIFRONT_OP_ADD_LUN 1 +#define VSCSIFRONT_OP_DEL_LUN 2
Shouldn't those be defined in the vscsiff.h file?
drivers/scsi/xen-scsifront.c line 67
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +#define DEFAULT_TASK_COMM_LEN TASK_COMM_LEN
Not sure why you need the DEFAULT_ ? Could you use TASK_COMM_LEN?
drivers/scsi/xen-scsifront.c line 69
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +/* tuning point*/
Missing stop and a space after the 't':
/* Tuning point. */
drivers/scsi/xen-scsifront.c line 82
Quoted 13 lines
drivers/scsi/xen-scsifront.c new file +13
-0+#define VSCSIIF_DEFAULT_CMD_PER_LUN 10 +#define VSCSIIF_MAX_TARGET 64 +#define VSCSIIF_MAX_LUN 255 + +#define VSCSIIF_RING_SIZE __CONST_RING_SIZE(vscsiif, PAGE_SIZE) +#define VSCSIIF_MAX_REQS VSCSIIF_RING_SIZE + +#define vscsiif_grants_sg (_sg) (PFN_UP((_sg) * \ + sizeof(struct scsiif_request_segment))) + +struct vscsifrnt_shadow { +/* command between backend and frontend */ +unsigned char act;
act? How about 'op' ? Or 'cmd_op'?
drivers/scsi/xen-scsifront.c line 83
Quoted 1 line
drivers/scsi/xen-scsifront.c new file +1
-0+uint16_t rqid;
rqid? Could you have a comment explaining what that acronym is? Oh wait - request id? How about just req_id?
drivers/scsi/xen-scsifront.c line 86
Quoted 3 lines
drivers/scsi/xen-scsifront.c new file +3
-0+ +/* Number of pieces of scatter-gather */ +unsigned int nr_grants;
s/nr_grants/nr_sg/ ?
drivers/scsi/xen-scsifront.c line 89
Quoted 3 lines
drivers/scsi/xen-scsifront.c new file +3
-0+struct scsiif_request_segment *sg; + +/* do reset or abort function */
Full stop missing.
drivers/scsi/xen-scsifront.c line 93
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +4
-0+wait_queue_head_t wq_reset;/* reset work queue */ +int wait_reset;/* reset work queue condition */ +int32_t rslt_reset;/* reset response status */ +/* (SUCESS or FAILED) */
Full stop missing. s/SUCESS/SUCCESS/
drivers/scsi/xen-scsifront.c line 95
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +/* requested struct scsi_cmnd is stored from kernel */
Full stop missing.
drivers/scsi/xen-scsifront.c line 104
Quoted 9 lines
drivers/scsi/xen-scsifront.c new file +9
-0+struct scsi_cmnd *sc; +int gref[vscsiif_grants_sg (SG_ALL ) +SG_ALL ]; +}; + +struct vscsifrnt_info { +struct xenbus_device *dev; + +struct Scsi_Host *host; +int host_active;
This 'host_active' seems to be a guard to call 'scsi_host_remove' through either the disconnect (so backend told us to disconnect) or the .remove (so XenStore keys are moved). Either way I think it is possible to run _both_ of them and this being just an 'int' is not sufficient.
I would recommend you change this to an ref_count.
drivers/scsi/xen-scsifront.c line 106
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +spinlock_t shadow_lock;
Could you move this spinlock below - to where
you have tons of of 'shadow' values please?
drivers/scsi/xen-scsifront.c line 114
Quoted 8 lines
drivers/scsi/xen-scsifront.c new file +8
-0+unsigned int evtchn; +unsigned int irq; + +grant_ref_t ring_ref; +struct vscsiif_front_ring ring; +struct vscsiif_response ring_res; + +unsigned long shadow_free;
A comment would help in explainig this. 'shadow_free' sounds a bit cryptic. Oh, and xen-blkfront has it as 'shadow_free' too! Argh, 'shadow_free_bitmask' could be a better name? Oh, what if we converted to an bitmask type?
Either way - if you think the existing one should be this way then lets leave it as is. But if you think a better name is suited I can change in xen-blkfront too.
drivers/scsi/xen-scsifront.c line 118
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +4
-0+struct vscsifrnt_shadow *shadow[VSCSIIF_MAX_REQS ]; + +wait_queue_head_t wq_sync; + unsigned int waiting_sync:1;
That sounds like it needs a spinlock to protect it?
Could you also explain a bit of what its purpose is? What is it suppose to wait for? It looks like it is tied to the error handler, perhaps then it ought to be called:
err_handler_done
drivers/scsi/xen-scsifront.c line 125
Quoted 7 lines
drivers/scsi/xen-scsifront.c new file +7
-0+ +char dev_state_path[64 ]; +struct task_struct *curr; +}; + +#define DPRINTK(_f, _a...) \ + pr_debug("(file=%s, line=%d) " _f, __FILE__ , __LINE__ , ## _a)
Could all the DPRINTK be converted to pr_debug right away?
drivers/scsi/xen-scsifront.c line 127
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +#define PREFIX (lvl) KERN_##lvl "scsifront: "
Perhaps you want?
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
Quoted 27 lines
drivers/scsi/xen-scsifront.c new file +27
-0+ +static void scsifront_wake_up (struct vscsifrnt_info *info) +{ + info->waiting_sync =0 ; +wake_up (&info->wq_sync); +} + +static int scsifront_get_rqid (struct vscsifrnt_info *info) +{ +unsigned long flags; +int free; + +spin_lock_irqsave (&info->shadow_lock, flags); + + free =find_first_bit (&info->shadow_free,VSCSIIF_MAX_REQS ); + info->shadow_free &= ~(1UL << free); + +spin_unlock_irqrestore (&info->shadow_lock, flags); + +return free; +} + +static int _scsifront_put_rqid (struct vscsifrnt_info *info,uint32_t id) +{ + info->shadow_free |=1UL << id; + info->shadow[id] =NULL ; +
drivers/scsi/xen-scsifront.c line 164
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+return (info->shadow_free ==1UL << id || info->waiting_sync); +} + +static void scsifront_put_rqid (struct vscsifrnt_info *info,uint32_t id) +{ +unsigned long flags; +int was_empty; + +spin_lock_irqsave (&info->shadow_lock, flags); + was_empty =_scsifront_put_rqid (info, id);
I wouldn't call this 'was_empty' as it will also be true if the 'waiting_sync' is turned on. Perhaps this should be called: 'kick' or 'wake_wq' ?
drivers/scsi/xen-scsifront.c line 177
Quoted 13 lines
drivers/scsi/xen-scsifront.c new file +13
-0+spin_unlock_irqrestore (&info->shadow_lock, flags); + +if (was_empty) +scsifront_wake_up (info); +} + +static struct vscsiif_request *scsifront_pre_req (struct vscsifrnt_info *info) +{ +struct vscsiif_front_ring *ring = &(info->ring); +struct vscsiif_request *ring_req; +uint32_t id; + + id =scsifront_get_rqid (info);/* use id by response */
s/by/in/
Quoted 34 lines
drivers/scsi/xen-scsifront.c new file +34
-0+if (id >=VSCSIIF_MAX_REQS ) +return NULL ; + + ring_req =RING_GET_REQUEST (&(info->ring), ring->req_prod_pvt); + + ring->req_prod_pvt++; + + ring_req->rqid = (uint16_t )id; + +return ring_req; +} + +static void scsifront_do_request (struct vscsifrnt_info *info) +{ +struct vscsiif_front_ring *ring = &(info->ring); +int notify; + +RING_PUSH_REQUESTS_AND_CHECK_NOTIFY (ring, notify); +if (notify) +notify_remote_via_irq (info->irq); +} + +static void scsifront_gnttab_done (struct vscsifrnt_info *info,uint32_t id) +{ +struct vscsifrnt_shadow *s = info->shadow[id]; +int i; + +if (s->sc->sc_data_direction ==DMA_NONE ) +return ; + +for (i =0 ; i < s->nr_grants; i++) { +if (unlikely (gnttab_query_foreign_access (s->gref[i]) !=0 )) { +shost_printk (PREFIX (ALERT ), info->host, +"grant still in use by backend\n" );
drivers/scsi/xen-scsifront.c line 221
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+BUG (); + } +gnttab_end_foreign_access (s->gref[i],0 ,0UL ); + } + +kfree (s->sg); +} + +static void scsifront_cdb_cmd_done (struct vscsifrnt_info *info, +struct vscsiif_response *ring_res)
s/ring_res/ring_rsp/ ?
Quoted 30 lines
drivers/scsi/xen-scsifront.c new file +30
-0+{ +struct scsi_cmnd *sc; +uint32_t id; +uint8_t sense_len; + + id = ring_res->rqid; + sc = info->shadow[id]->sc; + +BUG_ON (sc ==NULL ); + +scsifront_gnttab_done (info, id); +scsifront_put_rqid (info, id); + + sc->result = ring_res->rslt; +scsi_set_resid (sc, ring_res->residual_len); + + sense_len =min_t (uint8_t,VSCSIIF_SENSE_BUFFERSIZE , + ring_res->sense_len); + +if (sense_len) +memcpy (sc->sense_buffer, ring_res->sense_buffer, sense_len); + + sc->scsi_done (sc); +} + +static void scsifront_sync_cmd_done (struct vscsifrnt_info *info, +struct vscsiif_response *ring_res) +{ +uint16_t id = ring_res->rqid; +unsigned long flags;
drivers/scsi/xen-scsifront.c line 261
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+struct vscsifrnt_shadow *shadow = info->shadow[id]; +int was_empty; + +spin_lock_irqsave (&info->shadow_lock, flags); + shadow->wait_reset =1 ; +switch (shadow->rslt_reset) { +case 0 : + shadow->rslt_reset = ring_res->rslt; +break ; +case -1 :
Is there an #define for this? The comment at the top mentioned SUCCESS and FAILED ?
drivers/scsi/xen-scsifront.c line 262
Quoted 1 line
drivers/scsi/xen-scsifront.c new file +1
-0+ was_empty =_scsifront_put_rqid (info, id);
Perhaps call it 'kick' or 'wake_wq' ?
Quoted 20 lines
drivers/scsi/xen-scsifront.c new file +20
-0+spin_unlock_irqrestore (&info->shadow_lock, flags); +kfree (shadow); +if (was_empty) +scsifront_wake_up (info); +return ; +default : +shost_printk (PREFIX (ERR ), info->host, +"bad reset state %d, possibly leaking %u\n" , + shadow->rslt_reset, id); +break ; + } +spin_unlock_irqrestore (&info->shadow_lock, flags); + +wake_up (&shadow->wq_reset); +} + +static int scsifront_cmd_done (struct vscsifrnt_info *info) +{ +struct vscsiif_response *ring_res; +RING_IDX i, rp;
drivers/scsi/xen-scsifront.c line 292
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+int more_to_do =0 ; +unsigned long flags; + +spin_lock_irqsave (info->host->host_lock, flags); + + rp = info->ring.sring->rsp_prod; +rmb ();/* ordering required respective to dom0 */ +for (i = info->ring.rsp_cons; i != rp; i++) { + + ring_res =RING_GET_RESPONSE (&info->ring, i);
I would recommend you look at git commit 6878c32e5cc0e40980abe51d1f02fb453e27493e
As the 'rqid' value - might be corrupted by the backend. Which means that the 'info->shadow[rubbish_val]->act' could blow up.
I would just add a check to make sure that the 'rqid' value is within the expected values.
Quoted 33 lines
drivers/scsi/xen-scsifront.c new file +33
-0+ +if (info->shadow[ring_res->rqid]->act ==VSCSIIF_ACT_SCSI_CDB ) +scsifront_cdb_cmd_done (info, ring_res); +else +scsifront_sync_cmd_done (info, ring_res); + } + + info->ring.rsp_cons = i; + +if (i != info->ring.req_prod_pvt) +RING_FINAL_CHECK_FOR_RESPONSES (&info->ring, more_to_do); +else + info->ring.sring->rsp_event = i +1 ; + + info->waiting_sync =0 ; + +spin_unlock_irqrestore (info->host->host_lock, flags); + +wake_up (&info->wq_sync); + +return more_to_do; +} + +static irqreturn_t scsifront_irq_fn (int irq,void *dev_id) +{ +struct vscsifrnt_info *info = dev_id; + +while (scsifront_cmd_done (info)) +/* Yield point for this unbounded loop. */ +cond_resched (); + +return IRQ_HANDLED ; +}
drivers/scsi/xen-scsifront.c line 335
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ +static int map_data_for_request (struct vscsifrnt_info *info, +struct scsi_cmnd *sc, +struct vscsiif_request *ring_req, +struct vscsifrnt_shadow *shadow) +{ +grant_ref_t gref_head; +struct page *page; +int err, ref, ref_cnt =0 ; +int write = (sc->sc_data_direction ==DMA_TO_DEVICE );
What if it is DMA_BIDIRECTIONAL ?
Quoted 64 lines
drivers/scsi/xen-scsifront.c new file +64
-0+unsigned int i, off, len, bytes; +unsigned int data_len =scsi_bufflen (sc); +unsigned int data_grants =0 , seg_grants =0 ; +struct scatterlist *sg; +unsigned long mfn; +struct scsiif_request_segment *seg; + + ring_req->nr_segments =0 ; +if (sc->sc_data_direction ==DMA_NONE || !data_len) +return 0 ; + +scsi_for_each_sg (sc, sg,scsi_sg_count (sc), i) + data_grants +=PFN_UP (sg->offset + sg->length); + +if (data_grants >VSCSIIF_SG_TABLESIZE ) { +if (data_grants > info->host->sg_tablesize) { +shost_printk (PREFIX (ERR ), info->host, +"Unable to map request_buffer for command!\n" ); +return -E2BIG ; + } + seg_grants =vscsiif_grants_sg (data_grants); + shadow->sg =kcalloc (data_grants, +sizeof (struct scsiif_request_segment ),GFP_NOIO ); +if (!shadow->sg) +return -ENOMEM ; + } + seg = shadow->sg ? : ring_req->seg; + + err =gnttab_alloc_grant_references (seg_grants + data_grants, + &gref_head); +if (err) { +kfree (shadow->sg); +shost_printk (PREFIX (ERR ), info->host, +"gnttab_alloc_grant_references() error\n" ); +return -ENOMEM ; + } + +if (seg_grants) { + page =virt_to_page (seg); + off = (unsigned long )seg & ~PAGE_MASK ; + len =sizeof (struct scsiif_request_segment ) * data_grants; +while (len >0 ) { + bytes = min_t(unsigned int, len, PAGE_SIZE - off); + + ref =gnttab_claim_grant_reference (&gref_head); +BUG_ON (ref == -ENOSPC ); + + mfn =pfn_to_mfn (page_to_pfn (page)); +gnttab_grant_foreign_access_ref (ref, + info->dev->otherend_id, mfn,1 ); + shadow->gref[ref_cnt] = ref; + ring_req->seg[ref_cnt].gref = ref; + ring_req->seg[ref_cnt].offset = (uint16_t )off; + ring_req->seg[ref_cnt].length = (uint16_t )bytes; + + page++; + len -= bytes; + off =0 ; + ref_cnt++; + } +BUG_ON (seg_grants < ref_cnt); + seg_grants = ref_cnt; + } +
drivers/scsi/xen-scsifront.c line 409
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+scsi_for_each_sg (sc, sg,scsi_sg_count (sc), i) { + page =sg_page (sg); + off = sg->offset; + len = sg->length; + +while (len >0 && data_len >0 ) { +/* +* sg sends a scatterlist that is larger than +* the data_len it wants transferred for certain +* IO sizes
Full stop missing.
Quoted 64 lines
drivers/scsi/xen-scsifront.c new file +64
-0+*/ + bytes = min_t(unsigned int, len, PAGE_SIZE - off); + bytes =min (bytes, data_len); + + ref =gnttab_claim_grant_reference (&gref_head); +BUG_ON (ref == -ENOSPC ); + + mfn =pfn_to_mfn (page_to_pfn (page)); +gnttab_grant_foreign_access_ref (ref, + info->dev->otherend_id, mfn, write); + + shadow->gref[ref_cnt] = ref; + seg->gref = ref; + seg->offset = (uint16_t )off; + seg->length = (uint16_t )bytes; + + page++; + seg++; + len -= bytes; + data_len -= bytes; + off =0 ; + ref_cnt++; + } + } + +if (seg_grants) + ring_req->nr_segments =VSCSIIF_SG_GRANT | seg_grants; +else + ring_req->nr_segments = (uint8_t )ref_cnt; + shadow->nr_grants = ref_cnt; + +return 0 ; +} + +static struct vscsiif_request *scsifront_command2ring ( +struct vscsifrnt_info *info,struct scsi_cmnd *sc, +struct vscsifrnt_shadow *shadow) +{ +struct vscsiif_request *ring_req; + +memset (shadow,0 ,sizeof (*shadow)); + + ring_req =scsifront_pre_req (info); +if (!ring_req) +return NULL ; + + info->shadow[ring_req->rqid] = shadow; + shadow->rqid = ring_req->rqid; + + ring_req->id = sc->device->id; + ring_req->lun = sc->device->lun; + ring_req->channel = sc->device->channel; + ring_req->cmd_len = sc->cmd_len; + +BUG_ON (sc->cmd_len >VSCSIIF_MAX_COMMAND_SIZE ); + +memcpy (ring_req->cmnd, sc->cmnd, sc->cmd_len); + + ring_req->sc_data_direction = (uint8_t )sc->sc_data_direction; + ring_req->timeout_per_command = sc->request->timeout /HZ ; + +return ring_req; +} +
drivers/scsi/xen-scsifront.c line 483
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+static int scsifront_queuecommand (struct Scsi_Host *shost, +struct scsi_cmnd *sc) +{ +struct vscsifrnt_info *info =shost_priv (shost); +struct vscsiif_request *ring_req; +struct vscsifrnt_shadow *shadow =scsi_cmd_priv (sc); +unsigned long flags; +int err; +uint16_t rqid; +
BUG_ON(sc->sc_data_direction == DMA_BIDIRECTIONAL); ?
drivers/scsi/xen-scsifront.c line 492
Quoted 9 lines
drivers/scsi/xen-scsifront.c new file +9
-0+spin_lock_irqsave (shost->host_lock, flags); +if (RING_FULL (&info->ring)) + goto busy; + + ring_req =scsifront_command2ring (info, sc, shadow); +if (!ring_req) + goto busy; + + sc->result =0 ;
This has some odd spacing? Is it suppose to be at the same aligment as the ones below? Maybe it is my editor having issues.
Quoted 64 lines
drivers/scsi/xen-scsifront.c new file +64
-0+ + rqid = ring_req->rqid; + ring_req->act =VSCSIIF_ACT_SCSI_CDB ; + + shadow->sc = sc; + shadow->act =VSCSIIF_ACT_SCSI_CDB ; + + err =map_data_for_request (info, sc, ring_req, shadow); +if (err <0 ) { +DPRINTK ("%s: err %d\n" , __func__, err); +scsifront_put_rqid (info, rqid); +spin_unlock_irqrestore (shost->host_lock, flags); +if (err == -ENOMEM ) +return SCSI_MLQUEUE_HOST_BUSY ; + sc->result =DID_ERROR <<16 ; + sc->scsi_done (sc); +return 0 ; + } + +scsifront_do_request (info); +spin_unlock_irqrestore (shost->host_lock, flags); + +return 0 ; + +busy: +spin_unlock_irqrestore (shost->host_lock, flags); +DPRINTK ("%s: busy\n" , __func__); +return SCSI_MLQUEUE_HOST_BUSY ; +} + +/* +* Any exception handling (reset or abort) must be forwarded to the backend. +* We have to wait until an answer is returned. This answer contains the +* result to be returned to the requestor. +*/ +static int scsifront_action_handler (struct scsi_cmnd *sc,uint8_t act) +{ +struct Scsi_Host *host = sc->device->host; +struct vscsifrnt_info *info =shost_priv (host); +struct vscsifrnt_shadow *shadow, *s =scsi_cmd_priv (sc); +struct vscsiif_request *ring_req; +int err =0 ; + + shadow =kmalloc (sizeof (*shadow),GFP_NOIO ); +if (!shadow) +return FAILED ; + +for (;;) { +spin_lock_irq (host->host_lock); +if (!RING_FULL (&info->ring)) { + ring_req =scsifront_command2ring (info, sc, shadow); +if (ring_req) +break ; + } +if (err) { +spin_unlock_irq (host->host_lock); +kfree (shadow); +return FAILED ; + } + info->waiting_sync =1 ; +spin_unlock_irq (host->host_lock); + err =wait_event_interruptible (info->wq_sync, + !info->waiting_sync); +spin_lock_irq (host->host_lock);
drivers/scsi/xen-scsifront.c line 566
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ } + + ring_req->act = act; + ring_req->ref_rqid = s->rqid; + + shadow->act = act; + shadow->rslt_reset =0 ; +init_waitqueue_head (&shadow->wq_reset); + + ring_req->nr_segments =0 ;
Something odd with the spaces here.
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +4
-0+ +scsifront_do_request (info); + +spin_unlock_irq (host->host_lock);
drivers/scsi/xen-scsifront.c line 580
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ err =wait_event_interruptible (shadow->wq_reset, shadow->wait_reset); +spin_lock_irq (host->host_lock); + +if (!err) { + err = shadow->rslt_reset; +scsifront_put_rqid (info, shadow->rqid); +kfree (shadow); + }else { +spin_lock (&info->shadow_lock); + shadow->rslt_reset =-1 ;
#define for -1?
Quoted 66 lines
drivers/scsi/xen-scsifront.c new file +66
-0+spin_unlock (&info->shadow_lock); + err =FAILED ; + } + +spin_unlock_irq (host->host_lock); +return err; +} + +static int scsifront_eh_abort_handler (struct scsi_cmnd *sc) +{ +DPRINTK ("%s\n" , __func__); +return scsifront_action_handler (sc,VSCSIIF_ACT_SCSI_ABORT ); +} + +static int scsifront_dev_reset_handler (struct scsi_cmnd *sc) +{ +DPRINTK ("%s\n" , __func__); +return scsifront_action_handler (sc,VSCSIIF_ACT_SCSI_RESET ); +} + +static int scsifront_sdev_configure (struct scsi_device *sdev) +{ +struct vscsifrnt_info *info =shost_priv (sdev->host); + +if (info && current == info->curr) +xenbus_printf (XBT_NIL , info->dev->nodename, + info->dev_state_path,"%d" , XenbusStateConnected); + +return 0 ; +} + +static void scsifront_sdev_destroy (struct scsi_device *sdev) +{ +struct vscsifrnt_info *info =shost_priv (sdev->host); + +if (info && current == info->curr) +xenbus_printf (XBT_NIL , info->dev->nodename, + info->dev_state_path,"%d" , XenbusStateClosed); +} + +static struct scsi_host_template scsifront_sht = { + .module =THIS_MODULE , + .name ="Xen SCSI frontend driver" , + .queuecommand = scsifront_queuecommand, + .eh_abort_handler = scsifront_eh_abort_handler, + .eh_device_reset_handler = scsifront_dev_reset_handler, + .slave_configure = scsifront_sdev_configure, + .slave_destroy = scsifront_sdev_destroy, + .cmd_per_lun =VSCSIIF_DEFAULT_CMD_PER_LUN , + .can_queue =VSCSIIF_MAX_REQS , + .this_id =-1 , + .cmd_size =sizeof (struct vscsifrnt_shadow ), + .sg_tablesize =VSCSIIF_SG_TABLESIZE , + .use_clustering =DISABLE_CLUSTERING , + .proc_name ="scsifront" , +}; + +static int scsifront_alloc_ring (struct vscsifrnt_info *info) +{ +struct xenbus_device *dev = info->dev; +struct vscsiif_sring *sring; +int err = -ENOMEM ; + +/***** Frontend to Backend ring start *****/ + sring = (struct vscsiif_sring *)__get_free_page (GFP_KERNEL ); +if (!sring) {
drivers/scsi/xen-scsifront.c line 656
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+xenbus_dev_fatal (dev, err, +"fail to allocate shared ring (Front to Back)" ); +return err; + } +SHARED_RING_INIT (sring); +FRONT_RING_INIT (&info->ring, sring,PAGE_SIZE ); + + err =xenbus_grant_ring (dev,virt_to_mfn (sring)); +if (err <0 ) { +free_page ((unsigned long ) sring);
You can remove the space there.
Quoted 26 lines
drivers/scsi/xen-scsifront.c new file +26
-0+xenbus_dev_fatal (dev, err, +"fail to grant shared ring (Front to Back)" ); +return err; + } + info->ring_ref = err; + + err =xenbus_alloc_evtchn (dev, &info->evtchn); +if (err) { +xenbus_dev_fatal (dev, err,"xenbus_alloc_evtchn" ); + goto free_gnttab; + } + + err =bind_evtchn_to_irq (info->evtchn); +if (err <=0 ) { +xenbus_dev_fatal (dev, err,"bind_evtchn_to_irq" ); + goto free_gnttab; + } + + info->irq = err; + + err =request_threaded_irq (info->irq,NULL , scsifront_irq_fn, +IRQF_ONESHOT ,"scsifront" , info); +if (err) { +xenbus_dev_fatal (dev, err,"request_threaded_irq" ); + goto free_irq; + }
drivers/scsi/xen-scsifront.c line 692
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ +return 0 ; + +/* free resource */ +free_irq: +unbind_from_irqhandler (info->irq, info); +free_gnttab: +gnttab_end_foreign_access (info->ring_ref,0 , + (unsigned long )info->ring.sring); +
free_page((unsigned long)sring);
Quoted 43 lines
drivers/scsi/xen-scsifront.c new file +43
-0+return err; +} + +static int scsifront_init_ring (struct vscsifrnt_info *info) +{ +struct xenbus_device *dev = info->dev; +struct xenbus_transaction xbt; +int err; + +DPRINTK ("%s\n" , __func__); + + err =scsifront_alloc_ring (info); +if (err) +return err; +DPRINTK ("%u %u\n" , info->ring_ref, info->evtchn); + +again: + err =xenbus_transaction_start (&xbt); +if (err) +xenbus_dev_fatal (dev, err,"starting transaction" ); + + err =xenbus_printf (xbt, dev->nodename,"ring-ref" ,"%u" , + info->ring_ref); +if (err) { +xenbus_dev_fatal (dev, err,"%s" ,"writing ring-ref" ); + goto fail; + } + + err =xenbus_printf (xbt, dev->nodename,"event-channel" ,"%u" , + info->evtchn); + +if (err) { +xenbus_dev_fatal (dev, err,"%s" ,"writing event-channel" ); + goto fail; + } + + err =xenbus_transaction_end (xbt,0 ); +if (err) { +if (err == -EAGAIN ) + goto again; +xenbus_dev_fatal (dev, err,"completing transaction" ); + goto free_sring; + }
drivers/scsi/xen-scsifront.c line 745
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ +return 0 ; + +fail: +xenbus_transaction_end (xbt,1 ); +free_sring: +unbind_from_irqhandler (info->irq, info); +gnttab_end_foreign_access (info->ring_ref,0 , + (unsigned long )info->ring.sring); +
The label says 'free_sring' but I am not seeing it being freed?
Quoted 11 lines
drivers/scsi/xen-scsifront.c new file +11
-0+return err; +} + + +static int scsifront_probe (struct xenbus_device *dev, +const struct xenbus_device_id *id) +{ +struct vscsifrnt_info *info; +struct Scsi_Host *host; +int err = -ENOMEM ; +char name[DEFAULT_TASK_COMM_LEN ];
drivers/scsi/xen-scsifront.c line 766
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ + host =scsi_host_alloc (&scsifront_sht,sizeof (*info)); +if (!host) { +xenbus_dev_fatal (dev, err,"fail to allocate scsi host" ); +return err; + } + info = (struct vscsifrnt_info *)host->hostdata; + +dev_set_drvdata (&dev->dev, info); + info->dev = dev;
Extra space.
Quoted 27 lines
drivers/scsi/xen-scsifront.c new file +27
-0+ + info->shadow_free = (1UL <<VSCSIIF_MAX_REQS ) -1 ; + + err =scsifront_init_ring (info); +if (err) { +scsi_host_put (host); +return err; + } + +init_waitqueue_head (&info->wq_sync); +spin_lock_init (&info->shadow_lock); + +snprintf (name,DEFAULT_TASK_COMM_LEN ,"vscsiif.%d" , host->host_no); + + host->max_id =VSCSIIF_MAX_TARGET ; + host->max_channel =0 ; + host->max_lun =VSCSIIF_MAX_LUN ; + host->max_sectors = (host->sg_tablesize -1 ) *PAGE_SIZE /512 ; + host->max_cmd_len =VSCSIIF_MAX_COMMAND_SIZE ; + + err =scsi_add_host (host, &dev->dev); +if (err) { +dev_err (&dev->dev,"fail to add scsi host %d\n" , err); + goto free_sring; + } + info->host = host; + info->host_active =1 ;
drivers/scsi/xen-scsifront.c line 803
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ +xenbus_switch_state (dev, XenbusStateInitialised); + +return 0 ; + +free_sring: +unbind_from_irqhandler (info->irq, info); +gnttab_end_foreign_access (info->ring_ref,0 , + (unsigned long )info->ring.sring); +scsi_host_put (host);
The label says 'free_sring' but I am not seeing it being freed?
Hm, could those operations - unbind_from_irqhandler, gnttab_end_foreign_access and free_page be moved to a seperate function to call?
Quoted 9 lines
drivers/scsi/xen-scsifront.c new file +9
-0+return err; +} + +static int scsifront_remove (struct xenbus_device *dev) +{ +struct vscsifrnt_info *info =dev_get_drvdata (&dev->dev); + +DPRINTK ("%s: %s removed\n" , __func__, dev->nodename); +
drivers/scsi/xen-scsifront.c line 822
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+if (info->host_active) { +/* Scsi_host not yet removed */ +scsi_remove_host (info->host); + info->host_active =0 ; + } + +gnttab_end_foreign_access (info->ring_ref,0 , + (unsigned long )info->ring.sring); +unbind_from_irqhandler (info->irq, info); +
Should you free the ring?
Quoted 60 lines
drivers/scsi/xen-scsifront.c new file +60
-0+scsi_host_put (info->host); + +return 0 ; +} + +static void scsifront_disconnect (struct vscsifrnt_info *info) +{ +struct xenbus_device *dev = info->dev; +struct Scsi_Host *host = info->host; + +DPRINTK ("%s: %s disconnect\n" , __func__, dev->nodename); + +/* +* When this function is executed, all devices of +* Frontend have been deleted. +* Therefore, it need not block I/O before remove_host. +*/ + +if (info->host_active) +scsi_remove_host (host); + info->host_active =0 ; + +xenbus_frontend_closed (dev); +} + +static void scsifront_do_lun_hotplug (struct vscsifrnt_info *info,int op) +{ +struct xenbus_device *dev = info->dev; +int i, err =0 ; +char str[64 ]; +char **dir; +unsigned int dir_n =0 ; +unsigned int device_state; +unsigned int hst, chn, tgt, lun; +struct scsi_device *sdev; + + dir =xenbus_directory (XBT_NIL , dev->otherend,"vscsi-devs" , &dir_n); +if (IS_ERR (dir)) +return ; + +/* mark current task as the one allowed to modify device states */ +BUG_ON (info->curr); + info->curr = current; + +for (i =0 ; i < dir_n; i++) { +/* read status */ +snprintf (str,sizeof (str),"vscsi-devs/%s/state" , dir[i]); + err =xenbus_scanf (XBT_NIL , dev->otherend, str,"%u" , + &device_state); +if (XENBUS_EXIST_ERR (err)) +continue ; + +/* virtual SCSI device */ +snprintf (str,sizeof (str),"vscsi-devs/%s/v-dev" , dir[i]); + err =xenbus_scanf (XBT_NIL , dev->otherend, str, +"%u:%u:%u:%u" , &hst, &chn, &tgt, &lun); +if (XENBUS_EXIST_ERR (err)) +continue ; + +/*
drivers/scsi/xen-scsifront.c line 892
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+* Front device state path, used in slave_configure called +* on successfull scsi_add_device, and in slave_destroy called +* on remove of a device. +*/ +snprintf (info->dev_state_path,sizeof (info->dev_state_path), +"vscsi-devs/%s/state" , dir[i]); + +switch (op) { +case VSCSIFRONT_OP_ADD_LUN : +if (device_state == XenbusStateInitialised) {
You could convert to make this a bit easier to read to do:
if (device_state != XenbusStateInitialised) break; .. and then with the rest of the code.
drivers/scsi/xen-scsifront.c line 894
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ err =scsi_add_device (info->host, chn, tgt, + lun);
You can make that more than 80 characters long.
drivers/scsi/xen-scsifront.c line 905
Quoted 11 lines
drivers/scsi/xen-scsifront.c new file +11
-0+ +if (err) { +dev_err (&dev->dev,"scsi_add_device\n" ); +xenbus_printf (XBT_NIL , dev->nodename, + info->dev_state_path, +"%d" , XenbusStateClosed); + } + } +break ; +case VSCSIFRONT_OP_DEL_LUN : +if (device_state == XenbusStateClosing) {
Ditto.
Quoted 24 lines
drivers/scsi/xen-scsifront.c new file +24
-0+ sdev =scsi_device_lookup (info->host, chn, tgt, + lun); +if (sdev) { +scsi_remove_device (sdev); +scsi_device_put (sdev); + } + } +break ; +default : +break ; + } + } + + info->curr =NULL ; + +kfree (dir); +} + +static void scsifront_read_backend_params (struct xenbus_device *dev, +struct vscsifrnt_info *info) +{ +unsigned int sg_grant; +int ret; +struct Scsi_Host *host = info->host;
drivers/scsi/xen-scsifront.c line 939
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ + ret =xenbus_scanf (XBT_NIL , dev->otherend,"feature-sg-grant" ,"%u" , + &sg_grant); +if (ret ==1 && sg_grant) { + sg_grant = min_t(unsigned int, sg_grant, SG_ALL); + host->sg_tablesize = min_t(unsigned int, sg_grant, +VSCSIIF_SG_TABLESIZE *PAGE_SIZE / +sizeof (struct scsiif_request_segment )); +dev_info (&dev->dev,"using up to %d SG entries\n" , + host->sg_tablesize);
Perhaps this dev_info can be printed regardless of whether the backend has advertised an value? Isn't this information also visible in the SysFS? If so, should it be just removed?
drivers/scsi/xen-scsifront.c line 940
Quoted 1 line
drivers/scsi/xen-scsifront.c new file +1
-0+ host->max_sectors = (host->sg_tablesize -1 ) *PAGE_SIZE /512 ;
If the backend decides to give us an value less than optimal - say '2' should we just ignore it? Perhaps have
if (sg_grant < VSCSIIF_SG_TABLESIZE)
/* Pfffff. */ return;
Quoted 11 lines
drivers/scsi/xen-scsifront.c new file +11
-0+ } +} + +static void scsifront_backend_changed (struct xenbus_device *dev, +enum xenbus_state backend_state) +{ +struct vscsifrnt_info *info =dev_get_drvdata (&dev->dev); + +DPRINTK ("%p %u %u\n" , dev, dev->state, backend_state); + +switch (backend_state) {
drivers/scsi/xen-scsifront.c line 961
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+case XenbusStateUnknown: +case XenbusStateInitialising: +case XenbusStateInitWait: +case XenbusStateInitialised: +break ; + +case XenbusStateConnected: +scsifront_read_backend_params (dev, info); +if (xenbus_read_driver_state (dev->nodename) == + XenbusStateInitialised) {
You can make this more than 80 characters. And also remove the '{' and '}'
Quoted 46 lines
drivers/scsi/xen-scsifront.c new file +46
-0+scsifront_do_lun_hotplug (info,VSCSIFRONT_OP_ADD_LUN ); + } + +if (dev->state != XenbusStateConnected) +xenbus_switch_state (dev, XenbusStateConnected); +break ; + +case XenbusStateClosed: +if (dev->state == XenbusStateClosed) +break ; +/* Missed the backend's Closing state -- fallthrough */ +case XenbusStateClosing: +scsifront_disconnect (info); +break ; + +case XenbusStateReconfiguring: +scsifront_do_lun_hotplug (info,VSCSIFRONT_OP_DEL_LUN ); +xenbus_switch_state (dev, XenbusStateReconfiguring); +break ; + +case XenbusStateReconfigured: +scsifront_do_lun_hotplug (info,VSCSIFRONT_OP_ADD_LUN ); +xenbus_switch_state (dev, XenbusStateConnected); +break ; + } +} + +static const struct xenbus_device_id scsifront_ids[] = { + {"vscsi" }, + {"" } +}; + +static DEFINE_XENBUS_DRIVER(scsifront, , + .probe = scsifront_probe, + .remove = scsifront_remove, + .otherend_changed = scsifront_backend_changed, +); + +static int __init scsifront_init (void ) +{ +if (!xen_domain ()) +return -ENODEV ; + +return xenbus_register_frontend (&scsifront_driver); +} +module_init (scsifront_init);
drivers/scsi/xen-scsifront.c line 1017
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ +static void __exit scsifront_exit(void) +{ +xenbus_unregister_driver (&scsifront_driver); +} +module_exit (scsifront_exit); + +MODULE_DESCRIPTION ("Xen SCSI frontend driver" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("xen:vscsi" );
MODULE_AUTHOR?
Juergen Gross
maintainerRe: [PATCH V5 3/5] Introduce xen-scsifront module
Quoted 28 lines · Konrad Rzeszutek Wilk
Quoted 28 lines
drivers/scsi/xen-scsifront.c new file +25
-0@@ -0,0 +1,1017 @@ +/* +* Xen SCSI frontend driver +* +* Copyright (c) 2008, FUJITSU Limited +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation; or, when distributed +* separately from the Linux kernel or incorporated into other +* software packages, subject to the following license: +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this source file (the "Software"), to deal in the Software without +* restriction, including without limitation the rights to use, copy, modify, +* merge, publish, distribute, sublicense, and/or sell copies of the Software, +* and to permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 31
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +#define DEBUG :-) I think you don't want that in the driver.
Correct. :-)
Quoted 29 lines
Quoted 29 lines
drivers/scsi/xen-scsifront.c new file +28
-0+ +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/device.h> +#include <linux/wait.h> +#include <linux/interrupt.h> +#include <linux/spinlock.h> +#include <linux/sched.h> +#include <linux/blkdev.h> +#include <linux/pfn.h> +#include <linux/slab.h> + +#include <scsi/scsi_cmnd.h> +#include <scsi/scsi_device.h> +#include <scsi/scsi.h> +#include <scsi/scsi_host.h> + +#include <xen/xen.h> +#include <xen/xenbus.h> +#include <xen/grant_table.h> +#include <xen/events.h> +#include <xen/page.h> + +#include <xen/interface/grant_table.h> +#include <xen/interface/io/vscsiif.h> +#include <xen/interface/io/protocols.h> + +#include <asm/xen/hypervisor.h>
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 65
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+ + +#define GRANT_INVALID_REF 0 + +#define VSCSIFRONT_OP_ADD_LUN 1 +#define VSCSIFRONT_OP_DEL_LUN 2Shouldn't those be defined in the
vscsiff.hfile?
No, they are private for the frontend.
Quoted 5 lines
drivers/scsi/xen-scsifront.c line 67
Quoted 3 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +#define DEFAULT_TASK_COMM_LEN TASK_COMM_LENNot sure why you need the
DEFAULT_? Could you useTASK_COMM_LEN?
Sure.
Quoted 7 lines
drivers/scsi/xen-scsifront.c line 69
Quoted 3 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +/* tuning point*/ Missing stop and a space after the 't':
/* Tuning point. */
Okay.
Quoted 16 lines
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +3
-0+#define VSCSIIF_DEFAULT_CMD_PER_LUN 10 +#define VSCSIIF_MAX_TARGET 64 +#define VSCSIIF_MAX_LUN 255drivers/scsi/xen-scsifront.c line 82
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ +#define VSCSIIF_RING_SIZE __CONST_RING_SIZE(vscsiif, PAGE_SIZE) +#define VSCSIIF_MAX_REQS VSCSIIF_RING_SIZE + +#define vscsiif_grants_sg (_sg) (PFN_UP((_sg) * \ + sizeof(struct scsiif_request_segment))) + +struct vscsifrnt_shadow { +/* command between backend and frontend */ +unsigned char act;act? How about 'op' ? Or '
cmd_op'?
I wanted to use the same name as the related element in vscsiif.h
Quoted 5 lines
drivers/scsi/xen-scsifront.c line 83
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +1
-0+uint16_t rqid;rqid? Could you have a comment explaining what that acronym is? Oh wait - request id? How about just
req_id?
Same again. It's called rqid in vscsiiif.h
Quoted 6 lines
drivers/scsi/xen-scsifront.c line 86
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +3
-0+ +/* Number of pieces of scatter-gather */ +unsigned int nr_grants;s/nr_grants/nr_sg/ ?
I'll update the comment, as this is really the number of grants.
Quoted 6 lines
drivers/scsi/xen-scsifront.c line 89
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +3
-0+struct scsiif_request_segment *sg; + +/* do reset or abort function */ Full stop missing.
Quoted 6 lines
drivers/scsi/xen-scsifront.c line 93
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +4
-0+wait_queue_head_t wq_reset;/* reset work queue */ +int wait_reset;/* reset work queue condition */ +int32_t rslt_reset;/* reset response status */ +/* (SUCESS or FAILED) */ Full stop missing. s/SUCESS/SUCCESS/
Okay.
Quoted 4 lines
drivers/scsi/xen-scsifront.c line 95
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +/* requested struct scsi_cmnd is stored from kernel */ Full stop missing.
Okay.
Quoted 16 lines
drivers/scsi/xen-scsifront.c line 104
Quoted 9 lines
drivers/scsi/xen-scsifront.c new file +9
-0+struct scsi_cmnd *sc; +int gref[vscsiif_grants_sg (SG_ALL ) +SG_ALL ]; +}; + +struct vscsifrnt_info { +struct xenbus_device *dev; + +struct Scsi_Host *host; +int host_active;This '
host_active' seems to be a guard to call 'scsi_host_remove' through either the disconnect (so backend told us to disconnect) or the .remove (so XenStore keys are moved). Either way I think it is possible to run _both_ of them and this being just an 'int' is not sufficient.
Quoted 1 line
I would recommend you change this to an
ref_count.
Hmm, I think a lock is required here.
Quoted 5 lines
drivers/scsi/xen-scsifront.c line 106
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +spinlock_t shadow_lock;Could you move this spinlock below - to where
you have tons of of 'shadow' values please?
Okay.
Quoted 15 lines
drivers/scsi/xen-scsifront.c line 114
Quoted 9 lines
drivers/scsi/xen-scsifront.c new file +8
-0+unsigned int evtchn; +unsigned int irq; + +grant_ref_t ring_ref; +struct vscsiif_front_ring ring; +struct vscsiif_response ring_res; + +unsigned long shadow_free;A comment would help in explainig this. '
shadow_free' sounds a bit cryptic. Oh, and xen-blkfront has it as 'shadow_free' too! Argh, 'shadow_free_bitmask' could be a better name? Oh, what if we converted to an bitmask type?
Quoted 3 lines
Either way - if you think the existing one should be this way then lets leave it as is. But if you think a better name is suited I can change in xen-blkfront too.
I'll use the bitmap operations and call it shadow_free_bitmap.
Quoted 7 lines
drivers/scsi/xen-scsifront.c line 118
Quoted 5 lines
drivers/scsi/xen-scsifront.c new file +4
-0+struct vscsifrnt_shadow *shadow[VSCSIIF_MAX_REQS ]; + +wait_queue_head_t wq_sync; + unsigned int waiting_sync:1;That sounds like it needs a spinlock to protect it?
It is protected by info->host->host_lock.
Quoted 5 lines
Could you also explain a bit of what its purpose is? What is it suppose to wait for? It looks like it is tied to the error handler, perhaps then it ought to be called:
err_handler_done
It is used by the error handler, yes. But this is only due to the fact that the error handler can't return with SCSI_MLQUEUE_HOST_BUSY.
I think I rename it to wait_ring_available, because this is the real
meaning: someone is waiting until a request can be allocated in the ring.
Quoted 11 lines
drivers/scsi/xen-scsifront.c line 125
Quoted 9 lines
drivers/scsi/xen-scsifront.c new file +7
-0+ +char dev_state_path[64 ]; +struct task_struct *curr; +}; + +#define DPRINTK(_f, _a...) \ + pr_debug("(file=%s, line=%d) " _f, __FILE__ , __LINE__ , ## _a)Could all the DPRINTK be converted to
pr_debugright away?
Yes, I'll do it.
Quoted 6 lines
drivers/scsi/xen-scsifront.c line 127
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +#define PREFIX (lvl) KERN_##lvl "scsifront: "Perhaps you want?
#define
pr_fmt(fmt)KBUILD_MODNAME": " fmt
Not quite, but I'll remove the PREFIX define.
Quoted 32 lines
Quoted 32 lines
drivers/scsi/xen-scsifront.c new file +32
-0+ +static void scsifront_wake_up (struct vscsifrnt_info *info) +{ + info->waiting_sync =0 ; +wake_up (&info->wq_sync); +} + +static int scsifront_get_rqid (struct vscsifrnt_info *info) +{ +unsigned long flags; +int free; + +spin_lock_irqsave (&info->shadow_lock, flags); + + free =find_first_bit (&info->shadow_free,VSCSIIF_MAX_REQS ); + info->shadow_free &= ~(1UL << free); + +spin_unlock_irqrestore (&info->shadow_lock, flags); + +return free; +} + +static int _scsifront_put_rqid (struct vscsifrnt_info *info,uint32_t id) +{ + info->shadow_free |=1UL << id; + info->shadow[id] =NULL ; + +return (info->shadow_free ==1UL << id || info->waiting_sync); +} + +static void scsifront_put_rqid (struct vscsifrnt_info *info,uint32_t id) +{
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 164
Quoted 5 lines
drivers/scsi/xen-scsifront.c new file +5
-0+unsigned long flags; +int was_empty; + +spin_lock_irqsave (&info->shadow_lock, flags); + was_empty =_scsifront_put_rqid (info, id);I wouldn't call this '
was_empty' as it will also be true if the 'waiting_sync' is turned on. Perhaps this should be called: 'kick' or 'wake_wq' ?
kick is okay, I think.
Quoted 16 lines
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +3
-0+spin_unlock_irqrestore (&info->shadow_lock, flags); + +if (was_empty)drivers/scsi/xen-scsifront.c line 177
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+scsifront_wake_up (info); +} + +static struct vscsiif_request *scsifront_pre_req (struct vscsifrnt_info *info) +{ +struct vscsiif_front_ring *ring = &(info->ring); +struct vscsiif_request *ring_req; +uint32_t id; + + id =scsifront_get_rqid (info);/* use id by response */ s/by/in/
Okay.
Quoted 39 lines
Quoted 39 lines
drivers/scsi/xen-scsifront.c new file +38
-0+if (id >=VSCSIIF_MAX_REQS ) +return NULL ; + + ring_req =RING_GET_REQUEST (&(info->ring), ring->req_prod_pvt); + + ring->req_prod_pvt++; + + ring_req->rqid = (uint16_t )id; + +return ring_req; +} + +static void scsifront_do_request (struct vscsifrnt_info *info) +{ +struct vscsiif_front_ring *ring = &(info->ring); +int notify; + +RING_PUSH_REQUESTS_AND_CHECK_NOTIFY (ring, notify); +if (notify) +notify_remote_via_irq (info->irq); +} + +static void scsifront_gnttab_done (struct vscsifrnt_info *info,uint32_t id) +{ +struct vscsifrnt_shadow *s = info->shadow[id]; +int i; + +if (s->sc->sc_data_direction ==DMA_NONE ) +return ; + +for (i =0 ; i < s->nr_grants; i++) { +if (unlikely (gnttab_query_foreign_access (s->gref[i]) !=0 )) { +shost_printk (PREFIX (ALERT ), info->host, +"grant still in use by backend\n" ); +BUG (); + } +gnttab_end_foreign_access (s->gref[i],0 ,0UL ); + }
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 221
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+ +kfree (s->sg); +} + +static void scsifront_cdb_cmd_done (struct vscsifrnt_info *info, +struct vscsiif_response *ring_res)s/ring_res/ring_rsp/ ?
Yes, that's better.
Quoted 36 lines
Quoted 36 lines
drivers/scsi/xen-scsifront.c new file +35
-0+{ +struct scsi_cmnd *sc; +uint32_t id; +uint8_t sense_len; + + id = ring_res->rqid; + sc = info->shadow[id]->sc; + +BUG_ON (sc ==NULL ); + +scsifront_gnttab_done (info, id); +scsifront_put_rqid (info, id); + + sc->result = ring_res->rslt; +scsi_set_resid (sc, ring_res->residual_len); + + sense_len =min_t (uint8_t,VSCSIIF_SENSE_BUFFERSIZE , + ring_res->sense_len); + +if (sense_len) +memcpy (sc->sense_buffer, ring_res->sense_buffer, sense_len); + + sc->scsi_done (sc); +} + +static void scsifront_sync_cmd_done (struct vscsifrnt_info *info, +struct vscsiif_response *ring_res) +{ +uint16_t id = ring_res->rqid; +unsigned long flags; +struct vscsifrnt_shadow *shadow = info->shadow[id]; +int was_empty; + +spin_lock_irqsave (&info->shadow_lock, flags); + shadow->wait_reset =1 ;
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 261
Quoted 5 lines
drivers/scsi/xen-scsifront.c new file +5
-0+switch (shadow->rslt_reset) { +case 0 : + shadow->rslt_reset = ring_res->rslt; +break ; +case -1 :Is there an #define for this? The comment at the top mentioned SUCCESS and FAILED ?
Adding defines.
Quoted 4 lines
drivers/scsi/xen-scsifront.c line 262
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +1
-0+ was_empty =_scsifront_put_rqid (info, id);Perhaps call it 'kick' or '
wake_wq' ?
kick, again.
Quoted 34 lines
Quoted 21 lines
drivers/scsi/xen-scsifront.c new file +20
-0+spin_unlock_irqrestore (&info->shadow_lock, flags); +kfree (shadow); +if (was_empty) +scsifront_wake_up (info); +return ; +default : +shost_printk (PREFIX (ERR ), info->host, +"bad reset state %d, possibly leaking %u\n" , + shadow->rslt_reset, id); +break ; + } +spin_unlock_irqrestore (&info->shadow_lock, flags); + +wake_up (&shadow->wq_reset); +} + +static int scsifront_cmd_done (struct vscsifrnt_info *info) +{ +struct vscsiif_response *ring_res; +RING_IDX i, rp;drivers/scsi/xen-scsifront.c line 292
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+int more_to_do =0 ; +unsigned long flags; + +spin_lock_irqsave (info->host->host_lock, flags); + + rp = info->ring.sring->rsp_prod; +rmb ();/* ordering required respective to dom0 */ +for (i = info->ring.rsp_cons; i != rp; i++) { + + ring_res =RING_GET_RESPONSE (&info->ring, i);I would recommend you look at git commit
6878c32e5cc0e40980abe51d1f02fb453e27493e
Quoted 5 lines
As the 'rqid' value - might be corrupted by the backend. Which means that the 'info->shadow[rubbish_val]->act' could blow up.
I would just add a check to make sure that the 'rqid' value is within the expected values.
I'll add a check (the rqid should be in use as well).
Quoted 38 lines
Quoted 38 lines
drivers/scsi/xen-scsifront.c new file +37
-0+ +if (info->shadow[ring_res->rqid]->act ==VSCSIIF_ACT_SCSI_CDB ) +scsifront_cdb_cmd_done (info, ring_res); +else +scsifront_sync_cmd_done (info, ring_res); + } + + info->ring.rsp_cons = i; + +if (i != info->ring.req_prod_pvt) +RING_FINAL_CHECK_FOR_RESPONSES (&info->ring, more_to_do); +else + info->ring.sring->rsp_event = i +1 ; + + info->waiting_sync =0 ; + +spin_unlock_irqrestore (info->host->host_lock, flags); + +wake_up (&info->wq_sync); + +return more_to_do; +} + +static irqreturn_t scsifront_irq_fn (int irq,void *dev_id) +{ +struct vscsifrnt_info *info = dev_id; + +while (scsifront_cmd_done (info)) +/* Yield point for this unbounded loop. */ +cond_resched (); + +return IRQ_HANDLED ; +} + +static int map_data_for_request(struct vscsifrnt_info *info, + struct scsi_cmnd *sc, + struct vscsiif_request *ring_req,
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 335
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+ struct vscsifrnt_shadow *shadow) +{ +grant_ref_t gref_head; +struct page *page; +int err, ref, ref_cnt =0 ; +int write = (sc->sc_data_direction ==DMA_TO_DEVICE );What if it is
DMA_BIDIRECTIONAL?
That's okay. DMA_TO_DEVICE is the only case where a grant is flagged as read only. Perhaps I should rename 'write' to 'grant_ro'.
Quoted 69 lines
Quoted 69 lines
drivers/scsi/xen-scsifront.c new file +68
-0+unsigned int i, off, len, bytes; +unsigned int data_len =scsi_bufflen (sc); +unsigned int data_grants =0 , seg_grants =0 ; +struct scatterlist *sg; +unsigned long mfn; +struct scsiif_request_segment *seg; + + ring_req->nr_segments =0 ; +if (sc->sc_data_direction ==DMA_NONE || !data_len) +return 0 ; + +scsi_for_each_sg (sc, sg,scsi_sg_count (sc), i) + data_grants +=PFN_UP (sg->offset + sg->length); + +if (data_grants >VSCSIIF_SG_TABLESIZE ) { +if (data_grants > info->host->sg_tablesize) { +shost_printk (PREFIX (ERR ), info->host, +"Unable to map request_buffer for command!\n" ); +return -E2BIG ; + } + seg_grants =vscsiif_grants_sg (data_grants); + shadow->sg =kcalloc (data_grants, +sizeof (struct scsiif_request_segment ),GFP_NOIO ); +if (!shadow->sg) +return -ENOMEM ; + } + seg = shadow->sg ? : ring_req->seg; + + err =gnttab_alloc_grant_references (seg_grants + data_grants, + &gref_head); +if (err) { +kfree (shadow->sg); +shost_printk (PREFIX (ERR ), info->host, +"gnttab_alloc_grant_references() error\n" ); +return -ENOMEM ; + } + +if (seg_grants) { + page =virt_to_page (seg); + off = (unsigned long )seg & ~PAGE_MASK ; + len =sizeof (struct scsiif_request_segment ) * data_grants; +while (len >0 ) { + bytes = min_t(unsigned int, len, PAGE_SIZE - off); + + ref =gnttab_claim_grant_reference (&gref_head); +BUG_ON (ref == -ENOSPC ); + + mfn =pfn_to_mfn (page_to_pfn (page)); +gnttab_grant_foreign_access_ref (ref, + info->dev->otherend_id, mfn,1 ); + shadow->gref[ref_cnt] = ref; + ring_req->seg[ref_cnt].gref = ref; + ring_req->seg[ref_cnt].offset = (uint16_t )off; + ring_req->seg[ref_cnt].length = (uint16_t )bytes; + + page++; + len -= bytes; + off =0 ; + ref_cnt++; + } +BUG_ON (seg_grants < ref_cnt); + seg_grants = ref_cnt; + } + +scsi_for_each_sg (sc, sg,scsi_sg_count (sc), i) { + page =sg_page (sg); + off = sg->offset; + len = sg->length;
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 409
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+ +while (len >0 && data_len >0 ) { +/* +* sg sends a scatterlist that is larger than +* the data_len it wants transferred for certain +* IO sizes Full stop missing.
Yep.
Quoted 68 lines
Quoted 68 lines
drivers/scsi/xen-scsifront.c new file +68
-0+*/ + bytes = min_t(unsigned int, len, PAGE_SIZE - off); + bytes =min (bytes, data_len); + + ref =gnttab_claim_grant_reference (&gref_head); +BUG_ON (ref == -ENOSPC ); + + mfn =pfn_to_mfn (page_to_pfn (page)); +gnttab_grant_foreign_access_ref (ref, + info->dev->otherend_id, mfn, write); + + shadow->gref[ref_cnt] = ref; + seg->gref = ref; + seg->offset = (uint16_t )off; + seg->length = (uint16_t )bytes; + + page++; + seg++; + len -= bytes; + data_len -= bytes; + off =0 ; + ref_cnt++; + } + } + +if (seg_grants) + ring_req->nr_segments =VSCSIIF_SG_GRANT | seg_grants; +else + ring_req->nr_segments = (uint8_t )ref_cnt; + shadow->nr_grants = ref_cnt; + +return 0 ; +} + +static struct vscsiif_request *scsifront_command2ring ( +struct vscsifrnt_info *info,struct scsi_cmnd *sc, +struct vscsifrnt_shadow *shadow) +{ +struct vscsiif_request *ring_req; + +memset (shadow,0 ,sizeof (*shadow)); + + ring_req =scsifront_pre_req (info); +if (!ring_req) +return NULL ; + + info->shadow[ring_req->rqid] = shadow; + shadow->rqid = ring_req->rqid; + + ring_req->id = sc->device->id; + ring_req->lun = sc->device->lun; + ring_req->channel = sc->device->channel; + ring_req->cmd_len = sc->cmd_len; + +BUG_ON (sc->cmd_len >VSCSIIF_MAX_COMMAND_SIZE ); + +memcpy (ring_req->cmnd, sc->cmnd, sc->cmd_len); + + ring_req->sc_data_direction = (uint8_t )sc->sc_data_direction; + ring_req->timeout_per_command = sc->request->timeout /HZ ; + +return ring_req; +} + +static int scsifront_queuecommand (struct Scsi_Host *shost, +struct scsi_cmnd *sc) +{ +struct vscsifrnt_info *info =shost_priv (shost);
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 483
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+struct vscsiif_request *ring_req; +struct vscsifrnt_shadow *shadow =scsi_cmd_priv (sc); +unsigned long flags; +int err; +uint16_t rqid; +
BUG_ON(sc->sc_data_direction == DMA_BIDIRECTIONAL); ?
No.
Quoted 15 lines
drivers/scsi/xen-scsifront.c line 492
Quoted 11 lines
drivers/scsi/xen-scsifront.c new file +9
-0+spin_lock_irqsave (shost->host_lock, flags); +if (RING_FULL (&info->ring)) + goto busy; + + ring_req =scsifront_command2ring (info, sc, shadow); +if (!ring_req) + goto busy; + + sc->result =0 ;This has some odd spacing? Is it suppose to be at the same aligment as the ones below? Maybe it is my editor having issues.
Historical reasons. :-)
I'll change it.
Quoted 69 lines
Quoted 69 lines
drivers/scsi/xen-scsifront.c new file +68
-0+ + rqid = ring_req->rqid; + ring_req->act =VSCSIIF_ACT_SCSI_CDB ; + + shadow->sc = sc; + shadow->act =VSCSIIF_ACT_SCSI_CDB ; + + err =map_data_for_request (info, sc, ring_req, shadow); +if (err <0 ) { +DPRINTK ("%s: err %d\n" , __func__, err); +scsifront_put_rqid (info, rqid); +spin_unlock_irqrestore (shost->host_lock, flags); +if (err == -ENOMEM ) +return SCSI_MLQUEUE_HOST_BUSY ; + sc->result =DID_ERROR <<16 ; + sc->scsi_done (sc); +return 0 ; + } + +scsifront_do_request (info); +spin_unlock_irqrestore (shost->host_lock, flags); + +return 0 ; + +busy: +spin_unlock_irqrestore (shost->host_lock, flags); +DPRINTK ("%s: busy\n" , __func__); +return SCSI_MLQUEUE_HOST_BUSY ; +} + +/* +* Any exception handling (reset or abort) must be forwarded to the backend. +* We have to wait until an answer is returned. This answer contains the +* result to be returned to the requestor. +*/ +static int scsifront_action_handler (struct scsi_cmnd *sc,uint8_t act) +{ +struct Scsi_Host *host = sc->device->host; +struct vscsifrnt_info *info =shost_priv (host); +struct vscsifrnt_shadow *shadow, *s =scsi_cmd_priv (sc); +struct vscsiif_request *ring_req; +int err =0 ; + + shadow =kmalloc (sizeof (*shadow),GFP_NOIO ); +if (!shadow) +return FAILED ; + +for (;;) { +spin_lock_irq (host->host_lock); +if (!RING_FULL (&info->ring)) { + ring_req =scsifront_command2ring (info, sc, shadow); +if (ring_req) +break ; + } +if (err) { +spin_unlock_irq (host->host_lock); +kfree (shadow); +return FAILED ; + } + info->waiting_sync =1 ; +spin_unlock_irq (host->host_lock); + err =wait_event_interruptible (info->wq_sync, + !info->waiting_sync); +spin_lock_irq (host->host_lock); + } + + ring_req->act = act; + ring_req->ref_rqid = s->rqid;
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 566
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+ + shadow->act = act; + shadow->rslt_reset =0 ; +init_waitqueue_head (&shadow->wq_reset); + + ring_req->nr_segments =0 ;Something odd with the spaces here.
Okay.
Quoted 17 lines
Quoted 5 lines
drivers/scsi/xen-scsifront.c new file +4
-0+ +scsifront_do_request (info); + +spin_unlock_irq (host->host_lock);drivers/scsi/xen-scsifront.c line 580
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ err =wait_event_interruptible (shadow->wq_reset, shadow->wait_reset); +spin_lock_irq (host->host_lock); + +if (!err) { + err = shadow->rslt_reset; +scsifront_put_rqid (info, shadow->rqid); +kfree (shadow); + }else { +spin_lock (&info->shadow_lock); + shadow->rslt_reset =-1 ;#define for -1?
Done.
Quoted 71 lines
Quoted 71 lines
drivers/scsi/xen-scsifront.c new file +70
-0+spin_unlock (&info->shadow_lock); + err =FAILED ; + } + +spin_unlock_irq (host->host_lock); +return err; +} + +static int scsifront_eh_abort_handler (struct scsi_cmnd *sc) +{ +DPRINTK ("%s\n" , __func__); +return scsifront_action_handler (sc,VSCSIIF_ACT_SCSI_ABORT ); +} + +static int scsifront_dev_reset_handler (struct scsi_cmnd *sc) +{ +DPRINTK ("%s\n" , __func__); +return scsifront_action_handler (sc,VSCSIIF_ACT_SCSI_RESET ); +} + +static int scsifront_sdev_configure (struct scsi_device *sdev) +{ +struct vscsifrnt_info *info =shost_priv (sdev->host); + +if (info && current == info->curr) +xenbus_printf (XBT_NIL , info->dev->nodename, + info->dev_state_path,"%d" , XenbusStateConnected); + +return 0 ; +} + +static void scsifront_sdev_destroy (struct scsi_device *sdev) +{ +struct vscsifrnt_info *info =shost_priv (sdev->host); + +if (info && current == info->curr) +xenbus_printf (XBT_NIL , info->dev->nodename, + info->dev_state_path,"%d" , XenbusStateClosed); +} + +static struct scsi_host_template scsifront_sht = { + .module =THIS_MODULE , + .name ="Xen SCSI frontend driver" , + .queuecommand = scsifront_queuecommand, + .eh_abort_handler = scsifront_eh_abort_handler, + .eh_device_reset_handler = scsifront_dev_reset_handler, + .slave_configure = scsifront_sdev_configure, + .slave_destroy = scsifront_sdev_destroy, + .cmd_per_lun =VSCSIIF_DEFAULT_CMD_PER_LUN , + .can_queue =VSCSIIF_MAX_REQS , + .this_id =-1 , + .cmd_size =sizeof (struct vscsifrnt_shadow ), + .sg_tablesize =VSCSIIF_SG_TABLESIZE , + .use_clustering =DISABLE_CLUSTERING , + .proc_name ="scsifront" , +}; + +static int scsifront_alloc_ring (struct vscsifrnt_info *info) +{ +struct xenbus_device *dev = info->dev; +struct vscsiif_sring *sring; +int err = -ENOMEM ; + +/***** Frontend to Backend ring start *****/ + sring = (struct vscsiif_sring *)__get_free_page (GFP_KERNEL ); +if (!sring) { +xenbus_dev_fatal (dev, err, +"fail to allocate shared ring (Front to Back)" ); +return err; + }
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 656
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+SHARED_RING_INIT (sring); +FRONT_RING_INIT (&info->ring, sring,PAGE_SIZE ); + + err =xenbus_grant_ring (dev,virt_to_mfn (sring)); +if (err <0 ) { +free_page ((unsigned long ) sring);You can remove the space there.
Indeed.
Quoted 31 lines
Quoted 31 lines
drivers/scsi/xen-scsifront.c new file +30
-0+xenbus_dev_fatal (dev, err, +"fail to grant shared ring (Front to Back)" ); +return err; + } + info->ring_ref = err; + + err =xenbus_alloc_evtchn (dev, &info->evtchn); +if (err) { +xenbus_dev_fatal (dev, err,"xenbus_alloc_evtchn" ); + goto free_gnttab; + } + + err =bind_evtchn_to_irq (info->evtchn); +if (err <=0 ) { +xenbus_dev_fatal (dev, err,"bind_evtchn_to_irq" ); + goto free_gnttab; + } + + info->irq = err; + + err =request_threaded_irq (info->irq,NULL , scsifront_irq_fn, +IRQF_ONESHOT ,"scsifront" , info); +if (err) { +xenbus_dev_fatal (dev, err,"request_threaded_irq" ); + goto free_irq; + } + +return 0 ; + +/* free resource */
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 692
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+free_irq: +unbind_from_irqhandler (info->irq, info); +free_gnttab: +gnttab_end_foreign_access (info->ring_ref,0 , + (unsigned long )info->ring.sring); +
free_page((unsigned long)sring);
No, gnttab_end_foreign_access() is doing it.
Quoted 48 lines
Quoted 48 lines
drivers/scsi/xen-scsifront.c new file +47
-0+return err; +} + +static int scsifront_init_ring (struct vscsifrnt_info *info) +{ +struct xenbus_device *dev = info->dev; +struct xenbus_transaction xbt; +int err; + +DPRINTK ("%s\n" , __func__); + + err =scsifront_alloc_ring (info); +if (err) +return err; +DPRINTK ("%u %u\n" , info->ring_ref, info->evtchn); + +again: + err =xenbus_transaction_start (&xbt); +if (err) +xenbus_dev_fatal (dev, err,"starting transaction" ); + + err =xenbus_printf (xbt, dev->nodename,"ring-ref" ,"%u" , + info->ring_ref); +if (err) { +xenbus_dev_fatal (dev, err,"%s" ,"writing ring-ref" ); + goto fail; + } + + err =xenbus_printf (xbt, dev->nodename,"event-channel" ,"%u" , + info->evtchn); + +if (err) { +xenbus_dev_fatal (dev, err,"%s" ,"writing event-channel" ); + goto fail; + } + + err =xenbus_transaction_end (xbt,0 ); +if (err) { +if (err == -EAGAIN ) + goto again; +xenbus_dev_fatal (dev, err,"completing transaction" ); + goto free_sring; + } + +return 0 ; + +fail:
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 745
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+xenbus_transaction_end (xbt,1 ); +free_sring: +unbind_from_irqhandler (info->irq, info); +gnttab_end_foreign_access (info->ring_ref,0 , + (unsigned long )info->ring.sring); +The label says '
free_sring' but I am not seeing it being freed?
gnttab_end_foreign_access() is doing magic things. :-)
Quoted 16 lines
Quoted 16 lines
drivers/scsi/xen-scsifront.c new file +15
-0+return err; +} + + +static int scsifront_probe (struct xenbus_device *dev, +const struct xenbus_device_id *id) +{ +struct vscsifrnt_info *info; +struct Scsi_Host *host; +int err = -ENOMEM ; +char name[DEFAULT_TASK_COMM_LEN ]; + + host =scsi_host_alloc (&scsifront_sht,sizeof (*info)); +if (!host) { +xenbus_dev_fatal (dev, err,"fail to allocate scsi host" );
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 766
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+return err; + } + info = (struct vscsifrnt_info *)host->hostdata; + +dev_set_drvdata (&dev->dev, info); + info->dev = dev;Extra space.
They pile up already. :-)
Quoted 32 lines
Quoted 32 lines
drivers/scsi/xen-scsifront.c new file +31
-0+ + info->shadow_free = (1UL <<VSCSIIF_MAX_REQS ) -1 ; + + err =scsifront_init_ring (info); +if (err) { +scsi_host_put (host); +return err; + } + +init_waitqueue_head (&info->wq_sync); +spin_lock_init (&info->shadow_lock); + +snprintf (name,DEFAULT_TASK_COMM_LEN ,"vscsiif.%d" , host->host_no); + + host->max_id =VSCSIIF_MAX_TARGET ; + host->max_channel =0 ; + host->max_lun =VSCSIIF_MAX_LUN ; + host->max_sectors = (host->sg_tablesize -1 ) *PAGE_SIZE /512 ; + host->max_cmd_len =VSCSIIF_MAX_COMMAND_SIZE ; + + err =scsi_add_host (host, &dev->dev); +if (err) { +dev_err (&dev->dev,"fail to add scsi host %d\n" , err); + goto free_sring; + } + info->host = host; + info->host_active =1 ; + +xenbus_switch_state (dev, XenbusStateInitialised); + +return 0 ;
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 772
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+ +free_sring: +unbind_from_irqhandler (info->irq, info); +gnttab_end_foreign_access (info->ring_ref,0 , + (unsigned long )info->ring.sring); +scsi_host_put (host);The label says '
free_sring' but I am not seeing it being freed?
As above.
Quoted 3 lines
Hm, could those operations -
unbind_from_irqhandler,gnttab_end_foreign_accessandfree_pagebe moved to a seperate function to call?
I don't think it's necessary, those are only _two_ function calls.
Quoted 14 lines
Quoted 14 lines
drivers/scsi/xen-scsifront.c new file +13
-0+return err; +} + +static int scsifront_remove (struct xenbus_device *dev) +{ +struct vscsifrnt_info *info =dev_get_drvdata (&dev->dev); + +DPRINTK ("%s: %s removed\n" , __func__, dev->nodename); + +if (info->host_active) { +/* Scsi_host not yet removed */ +scsi_remove_host (info->host); + info->host_active =0 ;
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 745
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+ } + +gnttab_end_foreign_access (info->ring_ref,0 , + (unsigned long )info->ring.sring); +unbind_from_irqhandler (info->irq, info); +Should you free the ring?
I did.
Quoted 74 lines
Quoted 61 lines
drivers/scsi/xen-scsifront.c new file +60
-0+scsi_host_put (info->host); + +return 0 ; +} + +static void scsifront_disconnect (struct vscsifrnt_info *info) +{ +struct xenbus_device *dev = info->dev; +struct Scsi_Host *host = info->host; + +DPRINTK ("%s: %s disconnect\n" , __func__, dev->nodename); + +/* +* When this function is executed, all devices of +* Frontend have been deleted. +* Therefore, it need not block I/O before remove_host. +*/ + +if (info->host_active) +scsi_remove_host (host); + info->host_active =0 ; + +xenbus_frontend_closed (dev); +} + +static void scsifront_do_lun_hotplug (struct vscsifrnt_info *info,int op) +{ +struct xenbus_device *dev = info->dev; +int i, err =0 ; +char str[64 ]; +char **dir; +unsigned int dir_n =0 ; +unsigned int device_state; +unsigned int hst, chn, tgt, lun; +struct scsi_device *sdev; + + dir =xenbus_directory (XBT_NIL , dev->otherend,"vscsi-devs" , &dir_n); +if (IS_ERR (dir)) +return ; + +/* mark current task as the one allowed to modify device states */ +BUG_ON (info->curr); + info->curr = current; + +for (i =0 ; i < dir_n; i++) { +/* read status */ +snprintf (str,sizeof (str),"vscsi-devs/%s/state" , dir[i]); + err =xenbus_scanf (XBT_NIL , dev->otherend, str,"%u" , + &device_state); +if (XENBUS_EXIST_ERR (err)) +continue ; + +/* virtual SCSI device */ +snprintf (str,sizeof (str),"vscsi-devs/%s/v-dev" , dir[i]); + err =xenbus_scanf (XBT_NIL , dev->otherend, str, +"%u:%u:%u:%u" , &hst, &chn, &tgt, &lun); +if (XENBUS_EXIST_ERR (err)) +continue ; + +/* drivers/scsi/xen-scsifront.c line 892
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+* Front device state path, used in slave_configure called +* on successfull scsi_add_device, and in slave_destroy called +* on remove of a device. +*/ +snprintf (info->dev_state_path,sizeof (info->dev_state_path), +"vscsi-devs/%s/state" , dir[i]); + +switch (op) { +case VSCSIFRONT_OP_ADD_LUN : +if (device_state == XenbusStateInitialised) {You could convert to make this a bit easier to read to do:
Quoted 3 lines
if (device_state != XenbusStateInitialised) break; .. and then with the rest of the code.
Yes, that's better.
Quoted 5 lines
drivers/scsi/xen-scsifront.c line 894
Quoted 3 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ err =scsi_add_device (info->host, chn, tgt, + lun);You can make that more than 80 characters long.
It's shorter now.
Quoted 5 lines
Quoted 5 lines
drivers/scsi/xen-scsifront.c new file +5
-0+ +if (err) { +dev_err (&dev->dev,"scsi_add_device\n" ); + xenbus_printf(XBT_NIL, dev->nodename, + info->dev_state_path,
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 905
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+ "%d", XenbusStateClosed); + } + } +break ; +case VSCSIFRONT_OP_DEL_LUN : +if (device_state == XenbusStateClosing) {Ditto.
Yep.
Quoted 30 lines
Quoted 30 lines
drivers/scsi/xen-scsifront.c new file +30
-0+ sdev =scsi_device_lookup (info->host, chn, tgt, + lun); +if (sdev) { +scsi_remove_device (sdev); +scsi_device_put (sdev); + } + } +break ; +default : +break ; + } + } + + info->curr =NULL ; + +kfree (dir); +} + +static void scsifront_read_backend_params (struct xenbus_device *dev, +struct vscsifrnt_info *info) +{ +unsigned int sg_grant; +int ret; +struct Scsi_Host *host = info->host; + + ret =xenbus_scanf (XBT_NIL , dev->otherend,"feature-sg-grant" ,"%u" , + &sg_grant); +if (ret ==1 && sg_grant) { + sg_grant = min_t(unsigned int, sg_grant, SG_ALL); + host->sg_tablesize = min_t(unsigned int, sg_grant,
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 939
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +4
-0+VSCSIIF_SG_TABLESIZE *PAGE_SIZE / + sizeof(struct scsiif_request_segment)); +dev_info (&dev->dev,"using up to %d SG entries\n" , + host->sg_tablesize);Perhaps this
dev_infocan be printed regardless of whether the backend has advertised an value? Isn't this information also visible in the SysFS? If so, should it be just removed?
I don't know any entry in SysFS covering this information.
Always printing the information is possible, yes.
Quoted 9 lines
drivers/scsi/xen-scsifront.c line 940
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +1
-0+ host->max_sectors = (host->sg_tablesize -1 ) *PAGE_SIZE /512 ;If the backend decides to give us an value less than optimal - say '2' should we just ignore it? Perhaps have
if (
sg_grant<VSCSIIF_SG_TABLESIZE)/* Pfffff. */ return;
Something like that, yes.
Quoted 15 lines
Quoted 15 lines
drivers/scsi/xen-scsifront.c new file +15
-0+ } +} + +static void scsifront_backend_changed (struct xenbus_device *dev, +enum xenbus_state backend_state) +{ +struct vscsifrnt_info *info =dev_get_drvdata (&dev->dev); + +DPRINTK ("%p %u %u\n" , dev, dev->state, backend_state); + +switch (backend_state) { +case XenbusStateUnknown: +case XenbusStateInitialising: +case XenbusStateInitWait: +case XenbusStateInitialised:
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 961
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+break ; + +case XenbusStateConnected: +scsifront_read_backend_params (dev, info); +if (xenbus_read_driver_state (dev->nodename) == + XenbusStateInitialised) {You can make this more than 80 characters. And also remove the '{' and '}'
Okay.
Quoted 52 lines
Quoted 52 lines
drivers/scsi/xen-scsifront.c new file +50
-0+scsifront_do_lun_hotplug (info,VSCSIFRONT_OP_ADD_LUN ); + } + +if (dev->state != XenbusStateConnected) +xenbus_switch_state (dev, XenbusStateConnected); +break ; + +case XenbusStateClosed: +if (dev->state == XenbusStateClosed) +break ; +/* Missed the backend's Closing state -- fallthrough */ +case XenbusStateClosing: +scsifront_disconnect (info); +break ; + +case XenbusStateReconfiguring: +scsifront_do_lun_hotplug (info,VSCSIFRONT_OP_DEL_LUN ); +xenbus_switch_state (dev, XenbusStateReconfiguring); +break ; + +case XenbusStateReconfigured: +scsifront_do_lun_hotplug (info,VSCSIFRONT_OP_ADD_LUN ); +xenbus_switch_state (dev, XenbusStateConnected); +break ; + } +} + +static const struct xenbus_device_id scsifront_ids[] = { + {"vscsi" }, + {"" } +}; + +static DEFINE_XENBUS_DRIVER(scsifront, , + .probe = scsifront_probe, + .remove = scsifront_remove, + .otherend_changed = scsifront_backend_changed, +); + +static int __init scsifront_init (void ) +{ +if (!xen_domain ()) +return -ENODEV ; + +return xenbus_register_frontend (&scsifront_driver); +} +module_init (scsifront_init); + +static void __exit scsifront_exit(void) +{ +xenbus_unregister_driver (&scsifront_driver);
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 1017
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+} +module_exit (scsifront_exit); + +MODULE_DESCRIPTION ("Xen SCSI frontend driver" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("xen:vscsi" );
MODULE_AUTHOR?
I don't mind putting myself in there, but I'm not the original author...
Juergen
Juergen Gross
maintainerRe: [Xen-devel] [PATCH V5 3/5] Introduce xen-scsifront module
In reply to Konrad Rzeszutek WilkQuoted 28 lines · Konrad Rzeszutek Wilk
Quoted 28 lines
drivers/scsi/xen-scsifront.c new file +25
-0@@ -0,0 +1,1017 @@ +/* +* Xen SCSI frontend driver +* +* Copyright (c) 2008, FUJITSU Limited +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation; or, when distributed +* separately from the Linux kernel or incorporated into other +* software packages, subject to the following license: +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this source file (the "Software"), to deal in the Software without +* restriction, including without limitation the rights to use, copy, modify, +* merge, publish, distribute, sublicense, and/or sell copies of the Software, +* and to permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 31
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +#define DEBUG :-) I think you don't want that in the driver.
Correct. :-)
Quoted 29 lines
Quoted 29 lines
drivers/scsi/xen-scsifront.c new file +28
-0+ +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/device.h> +#include <linux/wait.h> +#include <linux/interrupt.h> +#include <linux/spinlock.h> +#include <linux/sched.h> +#include <linux/blkdev.h> +#include <linux/pfn.h> +#include <linux/slab.h> + +#include <scsi/scsi_cmnd.h> +#include <scsi/scsi_device.h> +#include <scsi/scsi.h> +#include <scsi/scsi_host.h> + +#include <xen/xen.h> +#include <xen/xenbus.h> +#include <xen/grant_table.h> +#include <xen/events.h> +#include <xen/page.h> + +#include <xen/interface/grant_table.h> +#include <xen/interface/io/vscsiif.h> +#include <xen/interface/io/protocols.h> + +#include <asm/xen/hypervisor.h>
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 65
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+ + +#define GRANT_INVALID_REF 0 + +#define VSCSIFRONT_OP_ADD_LUN 1 +#define VSCSIFRONT_OP_DEL_LUN 2Shouldn't those be defined in the
vscsiff.hfile?
No, they are private for the frontend.
Quoted 5 lines
drivers/scsi/xen-scsifront.c line 67
Quoted 3 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +#define DEFAULT_TASK_COMM_LEN TASK_COMM_LENNot sure why you need the
DEFAULT_? Could you useTASK_COMM_LEN?
Sure.
Quoted 7 lines
drivers/scsi/xen-scsifront.c line 69
Quoted 3 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +/* tuning point*/ Missing stop and a space after the 't':
/* Tuning point. */
Okay.
Quoted 16 lines
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +3
-0+#define VSCSIIF_DEFAULT_CMD_PER_LUN 10 +#define VSCSIIF_MAX_TARGET 64 +#define VSCSIIF_MAX_LUN 255drivers/scsi/xen-scsifront.c line 82
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ +#define VSCSIIF_RING_SIZE __CONST_RING_SIZE(vscsiif, PAGE_SIZE) +#define VSCSIIF_MAX_REQS VSCSIIF_RING_SIZE + +#define vscsiif_grants_sg (_sg) (PFN_UP((_sg) * \ + sizeof(struct scsiif_request_segment))) + +struct vscsifrnt_shadow { +/* command between backend and frontend */ +unsigned char act;act? How about 'op' ? Or '
cmd_op'?
I wanted to use the same name as the related element in vscsiif.h
Quoted 5 lines
drivers/scsi/xen-scsifront.c line 83
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +1
-0+uint16_t rqid;rqid? Could you have a comment explaining what that acronym is? Oh wait - request id? How about just
req_id?
Same again. It's called rqid in vscsiiif.h
Quoted 6 lines
drivers/scsi/xen-scsifront.c line 86
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +3
-0+ +/* Number of pieces of scatter-gather */ +unsigned int nr_grants;s/nr_grants/nr_sg/ ?
I'll update the comment, as this is really the number of grants.
Quoted 6 lines
drivers/scsi/xen-scsifront.c line 89
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +3
-0+struct scsiif_request_segment *sg; + +/* do reset or abort function */ Full stop missing.
Quoted 6 lines
drivers/scsi/xen-scsifront.c line 93
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +4
-0+wait_queue_head_t wq_reset;/* reset work queue */ +int wait_reset;/* reset work queue condition */ +int32_t rslt_reset;/* reset response status */ +/* (SUCESS or FAILED) */ Full stop missing. s/SUCESS/SUCCESS/
Okay.
Quoted 4 lines
drivers/scsi/xen-scsifront.c line 95
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +/* requested struct scsi_cmnd is stored from kernel */ Full stop missing.
Okay.
Quoted 16 lines
drivers/scsi/xen-scsifront.c line 104
Quoted 9 lines
drivers/scsi/xen-scsifront.c new file +9
-0+struct scsi_cmnd *sc; +int gref[vscsiif_grants_sg (SG_ALL ) +SG_ALL ]; +}; + +struct vscsifrnt_info { +struct xenbus_device *dev; + +struct Scsi_Host *host; +int host_active;This '
host_active' seems to be a guard to call 'scsi_host_remove' through either the disconnect (so backend told us to disconnect) or the .remove (so XenStore keys are moved). Either way I think it is possible to run _both_ of them and this being just an 'int' is not sufficient.
Quoted 1 line
I would recommend you change this to an
ref_count.
Hmm, I think a lock is required here.
Quoted 5 lines
drivers/scsi/xen-scsifront.c line 106
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +spinlock_t shadow_lock;Could you move this spinlock below - to where
you have tons of of 'shadow' values please?
Okay.
Quoted 15 lines
drivers/scsi/xen-scsifront.c line 114
Quoted 9 lines
drivers/scsi/xen-scsifront.c new file +8
-0+unsigned int evtchn; +unsigned int irq; + +grant_ref_t ring_ref; +struct vscsiif_front_ring ring; +struct vscsiif_response ring_res; + +unsigned long shadow_free;A comment would help in explainig this. '
shadow_free' sounds a bit cryptic. Oh, and xen-blkfront has it as 'shadow_free' too! Argh, 'shadow_free_bitmask' could be a better name? Oh, what if we converted to an bitmask type?
Quoted 3 lines
Either way - if you think the existing one should be this way then lets leave it as is. But if you think a better name is suited I can change in xen-blkfront too.
I'll use the bitmap operations and call it shadow_free_bitmap.
Quoted 7 lines
drivers/scsi/xen-scsifront.c line 118
Quoted 5 lines
drivers/scsi/xen-scsifront.c new file +4
-0+struct vscsifrnt_shadow *shadow[VSCSIIF_MAX_REQS ]; + +wait_queue_head_t wq_sync; + unsigned int waiting_sync:1;That sounds like it needs a spinlock to protect it?
It is protected by info->host->host_lock.
Quoted 5 lines
Could you also explain a bit of what its purpose is? What is it suppose to wait for? It looks like it is tied to the error handler, perhaps then it ought to be called:
err_handler_done
It is used by the error handler, yes. But this is only due to the fact that the error handler can't return with SCSI_MLQUEUE_HOST_BUSY.
I think I rename it to wait_ring_available, because this is the real
meaning: someone is waiting until a request can be allocated in the ring.
Quoted 11 lines
drivers/scsi/xen-scsifront.c line 125
Quoted 9 lines
drivers/scsi/xen-scsifront.c new file +7
-0+ +char dev_state_path[64 ]; +struct task_struct *curr; +}; + +#define DPRINTK(_f, _a...) \ + pr_debug("(file=%s, line=%d) " _f, __FILE__ , __LINE__ , ## _a)Could all the DPRINTK be converted to
pr_debugright away?
Yes, I'll do it.
Quoted 6 lines
drivers/scsi/xen-scsifront.c line 127
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +#define PREFIX (lvl) KERN_##lvl "scsifront: "Perhaps you want?
#define
pr_fmt(fmt)KBUILD_MODNAME": " fmt
Not quite, but I'll remove the PREFIX define.
Quoted 32 lines
Quoted 32 lines
drivers/scsi/xen-scsifront.c new file +32
-0+ +static void scsifront_wake_up (struct vscsifrnt_info *info) +{ + info->waiting_sync =0 ; +wake_up (&info->wq_sync); +} + +static int scsifront_get_rqid (struct vscsifrnt_info *info) +{ +unsigned long flags; +int free; + +spin_lock_irqsave (&info->shadow_lock, flags); + + free =find_first_bit (&info->shadow_free,VSCSIIF_MAX_REQS ); + info->shadow_free &= ~(1UL << free); + +spin_unlock_irqrestore (&info->shadow_lock, flags); + +return free; +} + +static int _scsifront_put_rqid (struct vscsifrnt_info *info,uint32_t id) +{ + info->shadow_free |=1UL << id; + info->shadow[id] =NULL ; + +return (info->shadow_free ==1UL << id || info->waiting_sync); +} + +static void scsifront_put_rqid (struct vscsifrnt_info *info,uint32_t id) +{
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 164
Quoted 5 lines
drivers/scsi/xen-scsifront.c new file +5
-0+unsigned long flags; +int was_empty; + +spin_lock_irqsave (&info->shadow_lock, flags); + was_empty =_scsifront_put_rqid (info, id);I wouldn't call this '
was_empty' as it will also be true if the 'waiting_sync' is turned on. Perhaps this should be called: 'kick' or 'wake_wq' ?
kick is okay, I think.
Quoted 16 lines
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +3
-0+spin_unlock_irqrestore (&info->shadow_lock, flags); + +if (was_empty)drivers/scsi/xen-scsifront.c line 177
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+scsifront_wake_up (info); +} + +static struct vscsiif_request *scsifront_pre_req (struct vscsifrnt_info *info) +{ +struct vscsiif_front_ring *ring = &(info->ring); +struct vscsiif_request *ring_req; +uint32_t id; + + id =scsifront_get_rqid (info);/* use id by response */ s/by/in/
Okay.
Quoted 39 lines
Quoted 39 lines
drivers/scsi/xen-scsifront.c new file +38
-0+if (id >=VSCSIIF_MAX_REQS ) +return NULL ; + + ring_req =RING_GET_REQUEST (&(info->ring), ring->req_prod_pvt); + + ring->req_prod_pvt++; + + ring_req->rqid = (uint16_t )id; + +return ring_req; +} + +static void scsifront_do_request (struct vscsifrnt_info *info) +{ +struct vscsiif_front_ring *ring = &(info->ring); +int notify; + +RING_PUSH_REQUESTS_AND_CHECK_NOTIFY (ring, notify); +if (notify) +notify_remote_via_irq (info->irq); +} + +static void scsifront_gnttab_done (struct vscsifrnt_info *info,uint32_t id) +{ +struct vscsifrnt_shadow *s = info->shadow[id]; +int i; + +if (s->sc->sc_data_direction ==DMA_NONE ) +return ; + +for (i =0 ; i < s->nr_grants; i++) { +if (unlikely (gnttab_query_foreign_access (s->gref[i]) !=0 )) { +shost_printk (PREFIX (ALERT ), info->host, +"grant still in use by backend\n" ); +BUG (); + } +gnttab_end_foreign_access (s->gref[i],0 ,0UL ); + }
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 221
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+ +kfree (s->sg); +} + +static void scsifront_cdb_cmd_done (struct vscsifrnt_info *info, +struct vscsiif_response *ring_res)s/ring_res/ring_rsp/ ?
Yes, that's better.
Quoted 36 lines
Quoted 36 lines
drivers/scsi/xen-scsifront.c new file +35
-0+{ +struct scsi_cmnd *sc; +uint32_t id; +uint8_t sense_len; + + id = ring_res->rqid; + sc = info->shadow[id]->sc; + +BUG_ON (sc ==NULL ); + +scsifront_gnttab_done (info, id); +scsifront_put_rqid (info, id); + + sc->result = ring_res->rslt; +scsi_set_resid (sc, ring_res->residual_len); + + sense_len =min_t (uint8_t,VSCSIIF_SENSE_BUFFERSIZE , + ring_res->sense_len); + +if (sense_len) +memcpy (sc->sense_buffer, ring_res->sense_buffer, sense_len); + + sc->scsi_done (sc); +} + +static void scsifront_sync_cmd_done (struct vscsifrnt_info *info, +struct vscsiif_response *ring_res) +{ +uint16_t id = ring_res->rqid; +unsigned long flags; +struct vscsifrnt_shadow *shadow = info->shadow[id]; +int was_empty; + +spin_lock_irqsave (&info->shadow_lock, flags); + shadow->wait_reset =1 ;
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 261
Quoted 5 lines
drivers/scsi/xen-scsifront.c new file +5
-0+switch (shadow->rslt_reset) { +case 0 : + shadow->rslt_reset = ring_res->rslt; +break ; +case -1 :Is there an #define for this? The comment at the top mentioned SUCCESS and FAILED ?
Adding defines.
Quoted 4 lines
drivers/scsi/xen-scsifront.c line 262
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +1
-0+ was_empty =_scsifront_put_rqid (info, id);Perhaps call it 'kick' or '
wake_wq' ?
kick, again.
Quoted 34 lines
Quoted 21 lines
drivers/scsi/xen-scsifront.c new file +20
-0+spin_unlock_irqrestore (&info->shadow_lock, flags); +kfree (shadow); +if (was_empty) +scsifront_wake_up (info); +return ; +default : +shost_printk (PREFIX (ERR ), info->host, +"bad reset state %d, possibly leaking %u\n" , + shadow->rslt_reset, id); +break ; + } +spin_unlock_irqrestore (&info->shadow_lock, flags); + +wake_up (&shadow->wq_reset); +} + +static int scsifront_cmd_done (struct vscsifrnt_info *info) +{ +struct vscsiif_response *ring_res; +RING_IDX i, rp;drivers/scsi/xen-scsifront.c line 292
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+int more_to_do =0 ; +unsigned long flags; + +spin_lock_irqsave (info->host->host_lock, flags); + + rp = info->ring.sring->rsp_prod; +rmb ();/* ordering required respective to dom0 */ +for (i = info->ring.rsp_cons; i != rp; i++) { + + ring_res =RING_GET_RESPONSE (&info->ring, i);I would recommend you look at git commit
6878c32e5cc0e40980abe51d1f02fb453e27493e
Quoted 5 lines
As the 'rqid' value - might be corrupted by the backend. Which means that the 'info->shadow[rubbish_val]->act' could blow up.
I would just add a check to make sure that the 'rqid' value is within the expected values.
I'll add a check (the rqid should be in use as well).
Quoted 38 lines
Quoted 38 lines
drivers/scsi/xen-scsifront.c new file +37
-0+ +if (info->shadow[ring_res->rqid]->act ==VSCSIIF_ACT_SCSI_CDB ) +scsifront_cdb_cmd_done (info, ring_res); +else +scsifront_sync_cmd_done (info, ring_res); + } + + info->ring.rsp_cons = i; + +if (i != info->ring.req_prod_pvt) +RING_FINAL_CHECK_FOR_RESPONSES (&info->ring, more_to_do); +else + info->ring.sring->rsp_event = i +1 ; + + info->waiting_sync =0 ; + +spin_unlock_irqrestore (info->host->host_lock, flags); + +wake_up (&info->wq_sync); + +return more_to_do; +} + +static irqreturn_t scsifront_irq_fn (int irq,void *dev_id) +{ +struct vscsifrnt_info *info = dev_id; + +while (scsifront_cmd_done (info)) +/* Yield point for this unbounded loop. */ +cond_resched (); + +return IRQ_HANDLED ; +} + +static int map_data_for_request(struct vscsifrnt_info *info, + struct scsi_cmnd *sc, + struct vscsiif_request *ring_req,
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 335
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+ struct vscsifrnt_shadow *shadow) +{ +grant_ref_t gref_head; +struct page *page; +int err, ref, ref_cnt =0 ; +int write = (sc->sc_data_direction ==DMA_TO_DEVICE );What if it is
DMA_BIDIRECTIONAL?
That's okay. DMA_TO_DEVICE is the only case where a grant is flagged as read only. Perhaps I should rename 'write' to 'grant_ro'.
Quoted 69 lines
Quoted 69 lines
drivers/scsi/xen-scsifront.c new file +68
-0+unsigned int i, off, len, bytes; +unsigned int data_len =scsi_bufflen (sc); +unsigned int data_grants =0 , seg_grants =0 ; +struct scatterlist *sg; +unsigned long mfn; +struct scsiif_request_segment *seg; + + ring_req->nr_segments =0 ; +if (sc->sc_data_direction ==DMA_NONE || !data_len) +return 0 ; + +scsi_for_each_sg (sc, sg,scsi_sg_count (sc), i) + data_grants +=PFN_UP (sg->offset + sg->length); + +if (data_grants >VSCSIIF_SG_TABLESIZE ) { +if (data_grants > info->host->sg_tablesize) { +shost_printk (PREFIX (ERR ), info->host, +"Unable to map request_buffer for command!\n" ); +return -E2BIG ; + } + seg_grants =vscsiif_grants_sg (data_grants); + shadow->sg =kcalloc (data_grants, +sizeof (struct scsiif_request_segment ),GFP_NOIO ); +if (!shadow->sg) +return -ENOMEM ; + } + seg = shadow->sg ? : ring_req->seg; + + err =gnttab_alloc_grant_references (seg_grants + data_grants, + &gref_head); +if (err) { +kfree (shadow->sg); +shost_printk (PREFIX (ERR ), info->host, +"gnttab_alloc_grant_references() error\n" ); +return -ENOMEM ; + } + +if (seg_grants) { + page =virt_to_page (seg); + off = (unsigned long )seg & ~PAGE_MASK ; + len =sizeof (struct scsiif_request_segment ) * data_grants; +while (len >0 ) { + bytes = min_t(unsigned int, len, PAGE_SIZE - off); + + ref =gnttab_claim_grant_reference (&gref_head); +BUG_ON (ref == -ENOSPC ); + + mfn =pfn_to_mfn (page_to_pfn (page)); +gnttab_grant_foreign_access_ref (ref, + info->dev->otherend_id, mfn,1 ); + shadow->gref[ref_cnt] = ref; + ring_req->seg[ref_cnt].gref = ref; + ring_req->seg[ref_cnt].offset = (uint16_t )off; + ring_req->seg[ref_cnt].length = (uint16_t )bytes; + + page++; + len -= bytes; + off =0 ; + ref_cnt++; + } +BUG_ON (seg_grants < ref_cnt); + seg_grants = ref_cnt; + } + +scsi_for_each_sg (sc, sg,scsi_sg_count (sc), i) { + page =sg_page (sg); + off = sg->offset; + len = sg->length;
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 409
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+ +while (len >0 && data_len >0 ) { +/* +* sg sends a scatterlist that is larger than +* the data_len it wants transferred for certain +* IO sizes Full stop missing.
Yep.
Quoted 68 lines
Quoted 68 lines
drivers/scsi/xen-scsifront.c new file +68
-0+*/ + bytes = min_t(unsigned int, len, PAGE_SIZE - off); + bytes =min (bytes, data_len); + + ref =gnttab_claim_grant_reference (&gref_head); +BUG_ON (ref == -ENOSPC ); + + mfn =pfn_to_mfn (page_to_pfn (page)); +gnttab_grant_foreign_access_ref (ref, + info->dev->otherend_id, mfn, write); + + shadow->gref[ref_cnt] = ref; + seg->gref = ref; + seg->offset = (uint16_t )off; + seg->length = (uint16_t )bytes; + + page++; + seg++; + len -= bytes; + data_len -= bytes; + off =0 ; + ref_cnt++; + } + } + +if (seg_grants) + ring_req->nr_segments =VSCSIIF_SG_GRANT | seg_grants; +else + ring_req->nr_segments = (uint8_t )ref_cnt; + shadow->nr_grants = ref_cnt; + +return 0 ; +} + +static struct vscsiif_request *scsifront_command2ring ( +struct vscsifrnt_info *info,struct scsi_cmnd *sc, +struct vscsifrnt_shadow *shadow) +{ +struct vscsiif_request *ring_req; + +memset (shadow,0 ,sizeof (*shadow)); + + ring_req =scsifront_pre_req (info); +if (!ring_req) +return NULL ; + + info->shadow[ring_req->rqid] = shadow; + shadow->rqid = ring_req->rqid; + + ring_req->id = sc->device->id; + ring_req->lun = sc->device->lun; + ring_req->channel = sc->device->channel; + ring_req->cmd_len = sc->cmd_len; + +BUG_ON (sc->cmd_len >VSCSIIF_MAX_COMMAND_SIZE ); + +memcpy (ring_req->cmnd, sc->cmnd, sc->cmd_len); + + ring_req->sc_data_direction = (uint8_t )sc->sc_data_direction; + ring_req->timeout_per_command = sc->request->timeout /HZ ; + +return ring_req; +} + +static int scsifront_queuecommand (struct Scsi_Host *shost, +struct scsi_cmnd *sc) +{ +struct vscsifrnt_info *info =shost_priv (shost);
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 483
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+struct vscsiif_request *ring_req; +struct vscsifrnt_shadow *shadow =scsi_cmd_priv (sc); +unsigned long flags; +int err; +uint16_t rqid; +
BUG_ON(sc->sc_data_direction == DMA_BIDIRECTIONAL); ?
No.
Quoted 15 lines
drivers/scsi/xen-scsifront.c line 492
Quoted 11 lines
drivers/scsi/xen-scsifront.c new file +9
-0+spin_lock_irqsave (shost->host_lock, flags); +if (RING_FULL (&info->ring)) + goto busy; + + ring_req =scsifront_command2ring (info, sc, shadow); +if (!ring_req) + goto busy; + + sc->result =0 ;This has some odd spacing? Is it suppose to be at the same aligment as the ones below? Maybe it is my editor having issues.
Historical reasons. :-)
I'll change it.
Quoted 69 lines
Quoted 69 lines
drivers/scsi/xen-scsifront.c new file +68
-0+ + rqid = ring_req->rqid; + ring_req->act =VSCSIIF_ACT_SCSI_CDB ; + + shadow->sc = sc; + shadow->act =VSCSIIF_ACT_SCSI_CDB ; + + err =map_data_for_request (info, sc, ring_req, shadow); +if (err <0 ) { +DPRINTK ("%s: err %d\n" , __func__, err); +scsifront_put_rqid (info, rqid); +spin_unlock_irqrestore (shost->host_lock, flags); +if (err == -ENOMEM ) +return SCSI_MLQUEUE_HOST_BUSY ; + sc->result =DID_ERROR <<16 ; + sc->scsi_done (sc); +return 0 ; + } + +scsifront_do_request (info); +spin_unlock_irqrestore (shost->host_lock, flags); + +return 0 ; + +busy: +spin_unlock_irqrestore (shost->host_lock, flags); +DPRINTK ("%s: busy\n" , __func__); +return SCSI_MLQUEUE_HOST_BUSY ; +} + +/* +* Any exception handling (reset or abort) must be forwarded to the backend. +* We have to wait until an answer is returned. This answer contains the +* result to be returned to the requestor. +*/ +static int scsifront_action_handler (struct scsi_cmnd *sc,uint8_t act) +{ +struct Scsi_Host *host = sc->device->host; +struct vscsifrnt_info *info =shost_priv (host); +struct vscsifrnt_shadow *shadow, *s =scsi_cmd_priv (sc); +struct vscsiif_request *ring_req; +int err =0 ; + + shadow =kmalloc (sizeof (*shadow),GFP_NOIO ); +if (!shadow) +return FAILED ; + +for (;;) { +spin_lock_irq (host->host_lock); +if (!RING_FULL (&info->ring)) { + ring_req =scsifront_command2ring (info, sc, shadow); +if (ring_req) +break ; + } +if (err) { +spin_unlock_irq (host->host_lock); +kfree (shadow); +return FAILED ; + } + info->waiting_sync =1 ; +spin_unlock_irq (host->host_lock); + err =wait_event_interruptible (info->wq_sync, + !info->waiting_sync); +spin_lock_irq (host->host_lock); + } + + ring_req->act = act; + ring_req->ref_rqid = s->rqid;
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 566
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+ + shadow->act = act; + shadow->rslt_reset =0 ; +init_waitqueue_head (&shadow->wq_reset); + + ring_req->nr_segments =0 ;Something odd with the spaces here.
Okay.
Quoted 17 lines
Quoted 5 lines
drivers/scsi/xen-scsifront.c new file +4
-0+ +scsifront_do_request (info); + +spin_unlock_irq (host->host_lock);drivers/scsi/xen-scsifront.c line 580
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ err =wait_event_interruptible (shadow->wq_reset, shadow->wait_reset); +spin_lock_irq (host->host_lock); + +if (!err) { + err = shadow->rslt_reset; +scsifront_put_rqid (info, shadow->rqid); +kfree (shadow); + }else { +spin_lock (&info->shadow_lock); + shadow->rslt_reset =-1 ;#define for -1?
Done.
Quoted 71 lines
Quoted 71 lines
drivers/scsi/xen-scsifront.c new file +70
-0+spin_unlock (&info->shadow_lock); + err =FAILED ; + } + +spin_unlock_irq (host->host_lock); +return err; +} + +static int scsifront_eh_abort_handler (struct scsi_cmnd *sc) +{ +DPRINTK ("%s\n" , __func__); +return scsifront_action_handler (sc,VSCSIIF_ACT_SCSI_ABORT ); +} + +static int scsifront_dev_reset_handler (struct scsi_cmnd *sc) +{ +DPRINTK ("%s\n" , __func__); +return scsifront_action_handler (sc,VSCSIIF_ACT_SCSI_RESET ); +} + +static int scsifront_sdev_configure (struct scsi_device *sdev) +{ +struct vscsifrnt_info *info =shost_priv (sdev->host); + +if (info && current == info->curr) +xenbus_printf (XBT_NIL , info->dev->nodename, + info->dev_state_path,"%d" , XenbusStateConnected); + +return 0 ; +} + +static void scsifront_sdev_destroy (struct scsi_device *sdev) +{ +struct vscsifrnt_info *info =shost_priv (sdev->host); + +if (info && current == info->curr) +xenbus_printf (XBT_NIL , info->dev->nodename, + info->dev_state_path,"%d" , XenbusStateClosed); +} + +static struct scsi_host_template scsifront_sht = { + .module =THIS_MODULE , + .name ="Xen SCSI frontend driver" , + .queuecommand = scsifront_queuecommand, + .eh_abort_handler = scsifront_eh_abort_handler, + .eh_device_reset_handler = scsifront_dev_reset_handler, + .slave_configure = scsifront_sdev_configure, + .slave_destroy = scsifront_sdev_destroy, + .cmd_per_lun =VSCSIIF_DEFAULT_CMD_PER_LUN , + .can_queue =VSCSIIF_MAX_REQS , + .this_id =-1 , + .cmd_size =sizeof (struct vscsifrnt_shadow ), + .sg_tablesize =VSCSIIF_SG_TABLESIZE , + .use_clustering =DISABLE_CLUSTERING , + .proc_name ="scsifront" , +}; + +static int scsifront_alloc_ring (struct vscsifrnt_info *info) +{ +struct xenbus_device *dev = info->dev; +struct vscsiif_sring *sring; +int err = -ENOMEM ; + +/***** Frontend to Backend ring start *****/ + sring = (struct vscsiif_sring *)__get_free_page (GFP_KERNEL ); +if (!sring) { +xenbus_dev_fatal (dev, err, +"fail to allocate shared ring (Front to Back)" ); +return err; + }
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 656
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+SHARED_RING_INIT (sring); +FRONT_RING_INIT (&info->ring, sring,PAGE_SIZE ); + + err =xenbus_grant_ring (dev,virt_to_mfn (sring)); +if (err <0 ) { +free_page ((unsigned long ) sring);You can remove the space there.
Indeed.
Quoted 31 lines
Quoted 31 lines
drivers/scsi/xen-scsifront.c new file +30
-0+xenbus_dev_fatal (dev, err, +"fail to grant shared ring (Front to Back)" ); +return err; + } + info->ring_ref = err; + + err =xenbus_alloc_evtchn (dev, &info->evtchn); +if (err) { +xenbus_dev_fatal (dev, err,"xenbus_alloc_evtchn" ); + goto free_gnttab; + } + + err =bind_evtchn_to_irq (info->evtchn); +if (err <=0 ) { +xenbus_dev_fatal (dev, err,"bind_evtchn_to_irq" ); + goto free_gnttab; + } + + info->irq = err; + + err =request_threaded_irq (info->irq,NULL , scsifront_irq_fn, +IRQF_ONESHOT ,"scsifront" , info); +if (err) { +xenbus_dev_fatal (dev, err,"request_threaded_irq" ); + goto free_irq; + } + +return 0 ; + +/* free resource */
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 692
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+free_irq: +unbind_from_irqhandler (info->irq, info); +free_gnttab: +gnttab_end_foreign_access (info->ring_ref,0 , + (unsigned long )info->ring.sring); +
free_page((unsigned long)sring);
No, gnttab_end_foreign_access() is doing it.
Quoted 48 lines
Quoted 48 lines
drivers/scsi/xen-scsifront.c new file +47
-0+return err; +} + +static int scsifront_init_ring (struct vscsifrnt_info *info) +{ +struct xenbus_device *dev = info->dev; +struct xenbus_transaction xbt; +int err; + +DPRINTK ("%s\n" , __func__); + + err =scsifront_alloc_ring (info); +if (err) +return err; +DPRINTK ("%u %u\n" , info->ring_ref, info->evtchn); + +again: + err =xenbus_transaction_start (&xbt); +if (err) +xenbus_dev_fatal (dev, err,"starting transaction" ); + + err =xenbus_printf (xbt, dev->nodename,"ring-ref" ,"%u" , + info->ring_ref); +if (err) { +xenbus_dev_fatal (dev, err,"%s" ,"writing ring-ref" ); + goto fail; + } + + err =xenbus_printf (xbt, dev->nodename,"event-channel" ,"%u" , + info->evtchn); + +if (err) { +xenbus_dev_fatal (dev, err,"%s" ,"writing event-channel" ); + goto fail; + } + + err =xenbus_transaction_end (xbt,0 ); +if (err) { +if (err == -EAGAIN ) + goto again; +xenbus_dev_fatal (dev, err,"completing transaction" ); + goto free_sring; + } + +return 0 ; + +fail:
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 745
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+xenbus_transaction_end (xbt,1 ); +free_sring: +unbind_from_irqhandler (info->irq, info); +gnttab_end_foreign_access (info->ring_ref,0 , + (unsigned long )info->ring.sring); +The label says '
free_sring' but I am not seeing it being freed?
gnttab_end_foreign_access() is doing magic things. :-)
Quoted 16 lines
Quoted 16 lines
drivers/scsi/xen-scsifront.c new file +15
-0+return err; +} + + +static int scsifront_probe (struct xenbus_device *dev, +const struct xenbus_device_id *id) +{ +struct vscsifrnt_info *info; +struct Scsi_Host *host; +int err = -ENOMEM ; +char name[DEFAULT_TASK_COMM_LEN ]; + + host =scsi_host_alloc (&scsifront_sht,sizeof (*info)); +if (!host) { +xenbus_dev_fatal (dev, err,"fail to allocate scsi host" );
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 766
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+return err; + } + info = (struct vscsifrnt_info *)host->hostdata; + +dev_set_drvdata (&dev->dev, info); + info->dev = dev;Extra space.
They pile up already. :-)
Quoted 32 lines
Quoted 32 lines
drivers/scsi/xen-scsifront.c new file +31
-0+ + info->shadow_free = (1UL <<VSCSIIF_MAX_REQS ) -1 ; + + err =scsifront_init_ring (info); +if (err) { +scsi_host_put (host); +return err; + } + +init_waitqueue_head (&info->wq_sync); +spin_lock_init (&info->shadow_lock); + +snprintf (name,DEFAULT_TASK_COMM_LEN ,"vscsiif.%d" , host->host_no); + + host->max_id =VSCSIIF_MAX_TARGET ; + host->max_channel =0 ; + host->max_lun =VSCSIIF_MAX_LUN ; + host->max_sectors = (host->sg_tablesize -1 ) *PAGE_SIZE /512 ; + host->max_cmd_len =VSCSIIF_MAX_COMMAND_SIZE ; + + err =scsi_add_host (host, &dev->dev); +if (err) { +dev_err (&dev->dev,"fail to add scsi host %d\n" , err); + goto free_sring; + } + info->host = host; + info->host_active =1 ; + +xenbus_switch_state (dev, XenbusStateInitialised); + +return 0 ;
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 772
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+ +free_sring: +unbind_from_irqhandler (info->irq, info); +gnttab_end_foreign_access (info->ring_ref,0 , + (unsigned long )info->ring.sring); +scsi_host_put (host);The label says '
free_sring' but I am not seeing it being freed?
As above.
Quoted 3 lines
Hm, could those operations -
unbind_from_irqhandler,gnttab_end_foreign_accessandfree_pagebe moved to a seperate function to call?
I don't think it's necessary, those are only _two_ function calls.
Quoted 14 lines
Quoted 14 lines
drivers/scsi/xen-scsifront.c new file +13
-0+return err; +} + +static int scsifront_remove (struct xenbus_device *dev) +{ +struct vscsifrnt_info *info =dev_get_drvdata (&dev->dev); + +DPRINTK ("%s: %s removed\n" , __func__, dev->nodename); + +if (info->host_active) { +/* Scsi_host not yet removed */ +scsi_remove_host (info->host); + info->host_active =0 ;
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 745
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+ } + +gnttab_end_foreign_access (info->ring_ref,0 , + (unsigned long )info->ring.sring); +unbind_from_irqhandler (info->irq, info); +Should you free the ring?
I did.
Quoted 74 lines
Quoted 61 lines
drivers/scsi/xen-scsifront.c new file +60
-0+scsi_host_put (info->host); + +return 0 ; +} + +static void scsifront_disconnect (struct vscsifrnt_info *info) +{ +struct xenbus_device *dev = info->dev; +struct Scsi_Host *host = info->host; + +DPRINTK ("%s: %s disconnect\n" , __func__, dev->nodename); + +/* +* When this function is executed, all devices of +* Frontend have been deleted. +* Therefore, it need not block I/O before remove_host. +*/ + +if (info->host_active) +scsi_remove_host (host); + info->host_active =0 ; + +xenbus_frontend_closed (dev); +} + +static void scsifront_do_lun_hotplug (struct vscsifrnt_info *info,int op) +{ +struct xenbus_device *dev = info->dev; +int i, err =0 ; +char str[64 ]; +char **dir; +unsigned int dir_n =0 ; +unsigned int device_state; +unsigned int hst, chn, tgt, lun; +struct scsi_device *sdev; + + dir =xenbus_directory (XBT_NIL , dev->otherend,"vscsi-devs" , &dir_n); +if (IS_ERR (dir)) +return ; + +/* mark current task as the one allowed to modify device states */ +BUG_ON (info->curr); + info->curr = current; + +for (i =0 ; i < dir_n; i++) { +/* read status */ +snprintf (str,sizeof (str),"vscsi-devs/%s/state" , dir[i]); + err =xenbus_scanf (XBT_NIL , dev->otherend, str,"%u" , + &device_state); +if (XENBUS_EXIST_ERR (err)) +continue ; + +/* virtual SCSI device */ +snprintf (str,sizeof (str),"vscsi-devs/%s/v-dev" , dir[i]); + err =xenbus_scanf (XBT_NIL , dev->otherend, str, +"%u:%u:%u:%u" , &hst, &chn, &tgt, &lun); +if (XENBUS_EXIST_ERR (err)) +continue ; + +/* drivers/scsi/xen-scsifront.c line 892
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+* Front device state path, used in slave_configure called +* on successfull scsi_add_device, and in slave_destroy called +* on remove of a device. +*/ +snprintf (info->dev_state_path,sizeof (info->dev_state_path), +"vscsi-devs/%s/state" , dir[i]); + +switch (op) { +case VSCSIFRONT_OP_ADD_LUN : +if (device_state == XenbusStateInitialised) {You could convert to make this a bit easier to read to do:
Quoted 3 lines
if (device_state != XenbusStateInitialised) break; .. and then with the rest of the code.
Yes, that's better.
Quoted 5 lines
drivers/scsi/xen-scsifront.c line 894
Quoted 3 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ err =scsi_add_device (info->host, chn, tgt, + lun);You can make that more than 80 characters long.
It's shorter now.
Quoted 5 lines
Quoted 5 lines
drivers/scsi/xen-scsifront.c new file +5
-0+ +if (err) { +dev_err (&dev->dev,"scsi_add_device\n" ); + xenbus_printf(XBT_NIL, dev->nodename, + info->dev_state_path,
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 905
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+ "%d", XenbusStateClosed); + } + } +break ; +case VSCSIFRONT_OP_DEL_LUN : +if (device_state == XenbusStateClosing) {Ditto.
Yep.
Quoted 30 lines
Quoted 30 lines
drivers/scsi/xen-scsifront.c new file +30
-0+ sdev =scsi_device_lookup (info->host, chn, tgt, + lun); +if (sdev) { +scsi_remove_device (sdev); +scsi_device_put (sdev); + } + } +break ; +default : +break ; + } + } + + info->curr =NULL ; + +kfree (dir); +} + +static void scsifront_read_backend_params (struct xenbus_device *dev, +struct vscsifrnt_info *info) +{ +unsigned int sg_grant; +int ret; +struct Scsi_Host *host = info->host; + + ret =xenbus_scanf (XBT_NIL , dev->otherend,"feature-sg-grant" ,"%u" , + &sg_grant); +if (ret ==1 && sg_grant) { + sg_grant = min_t(unsigned int, sg_grant, SG_ALL); + host->sg_tablesize = min_t(unsigned int, sg_grant,
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 939
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +4
-0+VSCSIIF_SG_TABLESIZE *PAGE_SIZE / + sizeof(struct scsiif_request_segment)); +dev_info (&dev->dev,"using up to %d SG entries\n" , + host->sg_tablesize);Perhaps this
dev_infocan be printed regardless of whether the backend has advertised an value? Isn't this information also visible in the SysFS? If so, should it be just removed?
I don't know any entry in SysFS covering this information.
Always printing the information is possible, yes.
Quoted 9 lines
drivers/scsi/xen-scsifront.c line 940
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +1
-0+ host->max_sectors = (host->sg_tablesize -1 ) *PAGE_SIZE /512 ;If the backend decides to give us an value less than optimal - say '2' should we just ignore it? Perhaps have
if (
sg_grant<VSCSIIF_SG_TABLESIZE)/* Pfffff. */ return;
Something like that, yes.
Quoted 15 lines
Quoted 15 lines
drivers/scsi/xen-scsifront.c new file +15
-0+ } +} + +static void scsifront_backend_changed (struct xenbus_device *dev, +enum xenbus_state backend_state) +{ +struct vscsifrnt_info *info =dev_get_drvdata (&dev->dev); + +DPRINTK ("%p %u %u\n" , dev, dev->state, backend_state); + +switch (backend_state) { +case XenbusStateUnknown: +case XenbusStateInitialising: +case XenbusStateInitWait: +case XenbusStateInitialised:
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 961
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+break ; + +case XenbusStateConnected: +scsifront_read_backend_params (dev, info); +if (xenbus_read_driver_state (dev->nodename) == + XenbusStateInitialised) {You can make this more than 80 characters. And also remove the '{' and '}'
Okay.
Quoted 52 lines
Quoted 52 lines
drivers/scsi/xen-scsifront.c new file +50
-0+scsifront_do_lun_hotplug (info,VSCSIFRONT_OP_ADD_LUN ); + } + +if (dev->state != XenbusStateConnected) +xenbus_switch_state (dev, XenbusStateConnected); +break ; + +case XenbusStateClosed: +if (dev->state == XenbusStateClosed) +break ; +/* Missed the backend's Closing state -- fallthrough */ +case XenbusStateClosing: +scsifront_disconnect (info); +break ; + +case XenbusStateReconfiguring: +scsifront_do_lun_hotplug (info,VSCSIFRONT_OP_DEL_LUN ); +xenbus_switch_state (dev, XenbusStateReconfiguring); +break ; + +case XenbusStateReconfigured: +scsifront_do_lun_hotplug (info,VSCSIFRONT_OP_ADD_LUN ); +xenbus_switch_state (dev, XenbusStateConnected); +break ; + } +} + +static const struct xenbus_device_id scsifront_ids[] = { + {"vscsi" }, + {"" } +}; + +static DEFINE_XENBUS_DRIVER(scsifront, , + .probe = scsifront_probe, + .remove = scsifront_remove, + .otherend_changed = scsifront_backend_changed, +); + +static int __init scsifront_init (void ) +{ +if (!xen_domain ()) +return -ENODEV ; + +return xenbus_register_frontend (&scsifront_driver); +} +module_init (scsifront_init); + +static void __exit scsifront_exit(void) +{ +xenbus_unregister_driver (&scsifront_driver);
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 1017
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+} +module_exit (scsifront_exit); + +MODULE_DESCRIPTION ("Xen SCSI frontend driver" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("xen:vscsi" );
MODULE_AUTHOR?
I don't mind putting myself in there, but I'm not the original author...
Juergen
Re: [PATCH V5 3/5] Introduce xen-scsifront module
In reply to [email protected]Quoted 24 lines
drivers/scsi/xen-scsifront.c new file +21
-0@@ -0,0 +1,1017 @@ +/* +* Xen SCSI frontend driver +* +* Copyright (c) 2008, FUJITSU Limited +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation; or, when distributed +* separately from the Linux kernel or incorporated into other +* software packages, subject to the following license: +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this source file (the "Software"), to deal in the Software without +* restriction, including without limitation the rights to use, copy, modify, +* merge, publish, distribute, sublicense, and/or sell copies of the Software, +* and to permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +*
drivers/scsi/xen-scsifront.c line 31
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +#define DEBUG
:-) I think you don't want that in the driver.
Quoted 24 lines
drivers/scsi/xen-scsifront.c new file +24
-0+ +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/device.h> +#include <linux/wait.h> +#include <linux/interrupt.h> +#include <linux/spinlock.h> +#include <linux/sched.h> +#include <linux/blkdev.h> +#include <linux/pfn.h> +#include <linux/slab.h> + +#include <scsi/scsi_cmnd.h> +#include <scsi/scsi_device.h> +#include <scsi/scsi.h> +#include <scsi/scsi_host.h> + +#include <xen/xen.h> +#include <xen/xenbus.h> +#include <xen/grant_table.h> +#include <xen/events.h> +#include <xen/page.h> + +#include <xen/interface/grant_table.h>
drivers/scsi/xen-scsifront.c line 65
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+#include <xen/interface/io/vscsiif.h> +#include <xen/interface/io/protocols.h> + +#include <asm/xen/hypervisor.h> + + +#define GRANT_INVALID_REF 0 + +#define VSCSIFRONT_OP_ADD_LUN 1 +#define VSCSIFRONT_OP_DEL_LUN 2
Shouldn't those be defined in the vscsiff.h file?
drivers/scsi/xen-scsifront.c line 67
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +#define DEFAULT_TASK_COMM_LEN TASK_COMM_LEN
Not sure why you need the DEFAULT_ ? Could you use TASK_COMM_LEN?
drivers/scsi/xen-scsifront.c line 69
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +/* tuning point*/
Missing stop and a space after the 't':
/* Tuning point. */
drivers/scsi/xen-scsifront.c line 82
Quoted 13 lines
drivers/scsi/xen-scsifront.c new file +13
-0+#define VSCSIIF_DEFAULT_CMD_PER_LUN 10 +#define VSCSIIF_MAX_TARGET 64 +#define VSCSIIF_MAX_LUN 255 + +#define VSCSIIF_RING_SIZE __CONST_RING_SIZE(vscsiif, PAGE_SIZE) +#define VSCSIIF_MAX_REQS VSCSIIF_RING_SIZE + +#define vscsiif_grants_sg (_sg) (PFN_UP((_sg) * \ + sizeof(struct scsiif_request_segment))) + +struct vscsifrnt_shadow { +/* command between backend and frontend */ +unsigned char act;
act? How about 'op' ? Or 'cmd_op'?
drivers/scsi/xen-scsifront.c line 83
Quoted 1 line
drivers/scsi/xen-scsifront.c new file +1
-0+uint16_t rqid;
rqid? Could you have a comment explaining what that acronym is? Oh wait - request id? How about just req_id?
drivers/scsi/xen-scsifront.c line 86
Quoted 3 lines
drivers/scsi/xen-scsifront.c new file +3
-0+ +/* Number of pieces of scatter-gather */ +unsigned int nr_grants;
s/nr_grants/nr_sg/ ?
drivers/scsi/xen-scsifront.c line 89
Quoted 3 lines
drivers/scsi/xen-scsifront.c new file +3
-0+struct scsiif_request_segment *sg; + +/* do reset or abort function */
Full stop missing.
drivers/scsi/xen-scsifront.c line 93
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +4
-0+wait_queue_head_t wq_reset;/* reset work queue */ +int wait_reset;/* reset work queue condition */ +int32_t rslt_reset;/* reset response status */ +/* (SUCESS or FAILED) */
Full stop missing. s/SUCESS/SUCCESS/
drivers/scsi/xen-scsifront.c line 95
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +/* requested struct scsi_cmnd is stored from kernel */
Full stop missing.
drivers/scsi/xen-scsifront.c line 104
Quoted 9 lines
drivers/scsi/xen-scsifront.c new file +9
-0+struct scsi_cmnd *sc; +int gref[vscsiif_grants_sg (SG_ALL ) +SG_ALL ]; +}; + +struct vscsifrnt_info { +struct xenbus_device *dev; + +struct Scsi_Host *host; +int host_active;
This 'host_active' seems to be a guard to call 'scsi_host_remove' through either the disconnect (so backend told us to disconnect) or the .remove (so XenStore keys are moved). Either way I think it is possible to run _both_ of them and this being just an 'int' is not sufficient.
I would recommend you change this to an ref_count.
drivers/scsi/xen-scsifront.c line 106
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +spinlock_t shadow_lock;
Could you move this spinlock below - to where
you have tons of of 'shadow' values please?
drivers/scsi/xen-scsifront.c line 114
Quoted 8 lines
drivers/scsi/xen-scsifront.c new file +8
-0+unsigned int evtchn; +unsigned int irq; + +grant_ref_t ring_ref; +struct vscsiif_front_ring ring; +struct vscsiif_response ring_res; + +unsigned long shadow_free;
A comment would help in explainig this. 'shadow_free' sounds a bit cryptic. Oh, and xen-blkfront has it as 'shadow_free' too! Argh, 'shadow_free_bitmask' could be a better name? Oh, what if we converted to an bitmask type?
Either way - if you think the existing one should be this way then lets leave it as is. But if you think a better name is suited I can change in xen-blkfront too.
drivers/scsi/xen-scsifront.c line 118
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +4
-0+struct vscsifrnt_shadow *shadow[VSCSIIF_MAX_REQS ]; + +wait_queue_head_t wq_sync; + unsigned int waiting_sync:1;
That sounds like it needs a spinlock to protect it?
Could you also explain a bit of what its purpose is? What is it suppose to wait for? It looks like it is tied to the error handler, perhaps then it ought to be called:
err_handler_done
drivers/scsi/xen-scsifront.c line 125
Quoted 7 lines
drivers/scsi/xen-scsifront.c new file +7
-0+ +char dev_state_path[64 ]; +struct task_struct *curr; +}; + +#define DPRINTK(_f, _a...) \ + pr_debug("(file=%s, line=%d) " _f, __FILE__ , __LINE__ , ## _a)
Could all the DPRINTK be converted to pr_debug right away?
drivers/scsi/xen-scsifront.c line 127
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ +#define PREFIX (lvl) KERN_##lvl "scsifront: "
Perhaps you want?
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
Quoted 27 lines
drivers/scsi/xen-scsifront.c new file +27
-0+ +static void scsifront_wake_up (struct vscsifrnt_info *info) +{ + info->waiting_sync =0 ; +wake_up (&info->wq_sync); +} + +static int scsifront_get_rqid (struct vscsifrnt_info *info) +{ +unsigned long flags; +int free; + +spin_lock_irqsave (&info->shadow_lock, flags); + + free =find_first_bit (&info->shadow_free,VSCSIIF_MAX_REQS ); + info->shadow_free &= ~(1UL << free); + +spin_unlock_irqrestore (&info->shadow_lock, flags); + +return free; +} + +static int _scsifront_put_rqid (struct vscsifrnt_info *info,uint32_t id) +{ + info->shadow_free |=1UL << id; + info->shadow[id] =NULL ; +
drivers/scsi/xen-scsifront.c line 164
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+return (info->shadow_free ==1UL << id || info->waiting_sync); +} + +static void scsifront_put_rqid (struct vscsifrnt_info *info,uint32_t id) +{ +unsigned long flags; +int was_empty; + +spin_lock_irqsave (&info->shadow_lock, flags); + was_empty =_scsifront_put_rqid (info, id);
I wouldn't call this 'was_empty' as it will also be true if the 'waiting_sync' is turned on. Perhaps this should be called: 'kick' or 'wake_wq' ?
drivers/scsi/xen-scsifront.c line 177
Quoted 13 lines
drivers/scsi/xen-scsifront.c new file +13
-0+spin_unlock_irqrestore (&info->shadow_lock, flags); + +if (was_empty) +scsifront_wake_up (info); +} + +static struct vscsiif_request *scsifront_pre_req (struct vscsifrnt_info *info) +{ +struct vscsiif_front_ring *ring = &(info->ring); +struct vscsiif_request *ring_req; +uint32_t id; + + id =scsifront_get_rqid (info);/* use id by response */
s/by/in/
Quoted 34 lines
drivers/scsi/xen-scsifront.c new file +34
-0+if (id >=VSCSIIF_MAX_REQS ) +return NULL ; + + ring_req =RING_GET_REQUEST (&(info->ring), ring->req_prod_pvt); + + ring->req_prod_pvt++; + + ring_req->rqid = (uint16_t )id; + +return ring_req; +} + +static void scsifront_do_request (struct vscsifrnt_info *info) +{ +struct vscsiif_front_ring *ring = &(info->ring); +int notify; + +RING_PUSH_REQUESTS_AND_CHECK_NOTIFY (ring, notify); +if (notify) +notify_remote_via_irq (info->irq); +} + +static void scsifront_gnttab_done (struct vscsifrnt_info *info,uint32_t id) +{ +struct vscsifrnt_shadow *s = info->shadow[id]; +int i; + +if (s->sc->sc_data_direction ==DMA_NONE ) +return ; + +for (i =0 ; i < s->nr_grants; i++) { +if (unlikely (gnttab_query_foreign_access (s->gref[i]) !=0 )) { +shost_printk (PREFIX (ALERT ), info->host, +"grant still in use by backend\n" );
drivers/scsi/xen-scsifront.c line 221
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+BUG (); + } +gnttab_end_foreign_access (s->gref[i],0 ,0UL ); + } + +kfree (s->sg); +} + +static void scsifront_cdb_cmd_done (struct vscsifrnt_info *info, +struct vscsiif_response *ring_res)
s/ring_res/ring_rsp/ ?
Quoted 30 lines
drivers/scsi/xen-scsifront.c new file +30
-0+{ +struct scsi_cmnd *sc; +uint32_t id; +uint8_t sense_len; + + id = ring_res->rqid; + sc = info->shadow[id]->sc; + +BUG_ON (sc ==NULL ); + +scsifront_gnttab_done (info, id); +scsifront_put_rqid (info, id); + + sc->result = ring_res->rslt; +scsi_set_resid (sc, ring_res->residual_len); + + sense_len =min_t (uint8_t,VSCSIIF_SENSE_BUFFERSIZE , + ring_res->sense_len); + +if (sense_len) +memcpy (sc->sense_buffer, ring_res->sense_buffer, sense_len); + + sc->scsi_done (sc); +} + +static void scsifront_sync_cmd_done (struct vscsifrnt_info *info, +struct vscsiif_response *ring_res) +{ +uint16_t id = ring_res->rqid; +unsigned long flags;
drivers/scsi/xen-scsifront.c line 261
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+struct vscsifrnt_shadow *shadow = info->shadow[id]; +int was_empty; + +spin_lock_irqsave (&info->shadow_lock, flags); + shadow->wait_reset =1 ; +switch (shadow->rslt_reset) { +case 0 : + shadow->rslt_reset = ring_res->rslt; +break ; +case -1 :
Is there an #define for this? The comment at the top mentioned SUCCESS and FAILED ?
drivers/scsi/xen-scsifront.c line 262
Quoted 1 line
drivers/scsi/xen-scsifront.c new file +1
-0+ was_empty =_scsifront_put_rqid (info, id);
Perhaps call it 'kick' or 'wake_wq' ?
Quoted 20 lines
drivers/scsi/xen-scsifront.c new file +20
-0+spin_unlock_irqrestore (&info->shadow_lock, flags); +kfree (shadow); +if (was_empty) +scsifront_wake_up (info); +return ; +default : +shost_printk (PREFIX (ERR ), info->host, +"bad reset state %d, possibly leaking %u\n" , + shadow->rslt_reset, id); +break ; + } +spin_unlock_irqrestore (&info->shadow_lock, flags); + +wake_up (&shadow->wq_reset); +} + +static int scsifront_cmd_done (struct vscsifrnt_info *info) +{ +struct vscsiif_response *ring_res; +RING_IDX i, rp;
drivers/scsi/xen-scsifront.c line 292
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+int more_to_do =0 ; +unsigned long flags; + +spin_lock_irqsave (info->host->host_lock, flags); + + rp = info->ring.sring->rsp_prod; +rmb ();/* ordering required respective to dom0 */ +for (i = info->ring.rsp_cons; i != rp; i++) { + + ring_res =RING_GET_RESPONSE (&info->ring, i);
I would recommend you look at git commit 6878c32e5cc0e40980abe51d1f02fb453e27493e
As the 'rqid' value - might be corrupted by the backend. Which means that the 'info->shadow[rubbish_val]->act' could blow up.
I would just add a check to make sure that the 'rqid' value is within the expected values.
Quoted 33 lines
drivers/scsi/xen-scsifront.c new file +33
-0+ +if (info->shadow[ring_res->rqid]->act ==VSCSIIF_ACT_SCSI_CDB ) +scsifront_cdb_cmd_done (info, ring_res); +else +scsifront_sync_cmd_done (info, ring_res); + } + + info->ring.rsp_cons = i; + +if (i != info->ring.req_prod_pvt) +RING_FINAL_CHECK_FOR_RESPONSES (&info->ring, more_to_do); +else + info->ring.sring->rsp_event = i +1 ; + + info->waiting_sync =0 ; + +spin_unlock_irqrestore (info->host->host_lock, flags); + +wake_up (&info->wq_sync); + +return more_to_do; +} + +static irqreturn_t scsifront_irq_fn (int irq,void *dev_id) +{ +struct vscsifrnt_info *info = dev_id; + +while (scsifront_cmd_done (info)) +/* Yield point for this unbounded loop. */ +cond_resched (); + +return IRQ_HANDLED ; +}
drivers/scsi/xen-scsifront.c line 335
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ +static int map_data_for_request (struct vscsifrnt_info *info, +struct scsi_cmnd *sc, +struct vscsiif_request *ring_req, +struct vscsifrnt_shadow *shadow) +{ +grant_ref_t gref_head; +struct page *page; +int err, ref, ref_cnt =0 ; +int write = (sc->sc_data_direction ==DMA_TO_DEVICE );
What if it is DMA_BIDIRECTIONAL ?
Quoted 64 lines
drivers/scsi/xen-scsifront.c new file +64
-0+unsigned int i, off, len, bytes; +unsigned int data_len =scsi_bufflen (sc); +unsigned int data_grants =0 , seg_grants =0 ; +struct scatterlist *sg; +unsigned long mfn; +struct scsiif_request_segment *seg; + + ring_req->nr_segments =0 ; +if (sc->sc_data_direction ==DMA_NONE || !data_len) +return 0 ; + +scsi_for_each_sg (sc, sg,scsi_sg_count (sc), i) + data_grants +=PFN_UP (sg->offset + sg->length); + +if (data_grants >VSCSIIF_SG_TABLESIZE ) { +if (data_grants > info->host->sg_tablesize) { +shost_printk (PREFIX (ERR ), info->host, +"Unable to map request_buffer for command!\n" ); +return -E2BIG ; + } + seg_grants =vscsiif_grants_sg (data_grants); + shadow->sg =kcalloc (data_grants, +sizeof (struct scsiif_request_segment ),GFP_NOIO ); +if (!shadow->sg) +return -ENOMEM ; + } + seg = shadow->sg ? : ring_req->seg; + + err =gnttab_alloc_grant_references (seg_grants + data_grants, + &gref_head); +if (err) { +kfree (shadow->sg); +shost_printk (PREFIX (ERR ), info->host, +"gnttab_alloc_grant_references() error\n" ); +return -ENOMEM ; + } + +if (seg_grants) { + page =virt_to_page (seg); + off = (unsigned long )seg & ~PAGE_MASK ; + len =sizeof (struct scsiif_request_segment ) * data_grants; +while (len >0 ) { + bytes = min_t(unsigned int, len, PAGE_SIZE - off); + + ref =gnttab_claim_grant_reference (&gref_head); +BUG_ON (ref == -ENOSPC ); + + mfn =pfn_to_mfn (page_to_pfn (page)); +gnttab_grant_foreign_access_ref (ref, + info->dev->otherend_id, mfn,1 ); + shadow->gref[ref_cnt] = ref; + ring_req->seg[ref_cnt].gref = ref; + ring_req->seg[ref_cnt].offset = (uint16_t )off; + ring_req->seg[ref_cnt].length = (uint16_t )bytes; + + page++; + len -= bytes; + off =0 ; + ref_cnt++; + } +BUG_ON (seg_grants < ref_cnt); + seg_grants = ref_cnt; + } +
drivers/scsi/xen-scsifront.c line 409
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+scsi_for_each_sg (sc, sg,scsi_sg_count (sc), i) { + page =sg_page (sg); + off = sg->offset; + len = sg->length; + +while (len >0 && data_len >0 ) { +/* +* sg sends a scatterlist that is larger than +* the data_len it wants transferred for certain +* IO sizes
Full stop missing.
Quoted 64 lines
drivers/scsi/xen-scsifront.c new file +64
-0+*/ + bytes = min_t(unsigned int, len, PAGE_SIZE - off); + bytes =min (bytes, data_len); + + ref =gnttab_claim_grant_reference (&gref_head); +BUG_ON (ref == -ENOSPC ); + + mfn =pfn_to_mfn (page_to_pfn (page)); +gnttab_grant_foreign_access_ref (ref, + info->dev->otherend_id, mfn, write); + + shadow->gref[ref_cnt] = ref; + seg->gref = ref; + seg->offset = (uint16_t )off; + seg->length = (uint16_t )bytes; + + page++; + seg++; + len -= bytes; + data_len -= bytes; + off =0 ; + ref_cnt++; + } + } + +if (seg_grants) + ring_req->nr_segments =VSCSIIF_SG_GRANT | seg_grants; +else + ring_req->nr_segments = (uint8_t )ref_cnt; + shadow->nr_grants = ref_cnt; + +return 0 ; +} + +static struct vscsiif_request *scsifront_command2ring ( +struct vscsifrnt_info *info,struct scsi_cmnd *sc, +struct vscsifrnt_shadow *shadow) +{ +struct vscsiif_request *ring_req; + +memset (shadow,0 ,sizeof (*shadow)); + + ring_req =scsifront_pre_req (info); +if (!ring_req) +return NULL ; + + info->shadow[ring_req->rqid] = shadow; + shadow->rqid = ring_req->rqid; + + ring_req->id = sc->device->id; + ring_req->lun = sc->device->lun; + ring_req->channel = sc->device->channel; + ring_req->cmd_len = sc->cmd_len; + +BUG_ON (sc->cmd_len >VSCSIIF_MAX_COMMAND_SIZE ); + +memcpy (ring_req->cmnd, sc->cmnd, sc->cmd_len); + + ring_req->sc_data_direction = (uint8_t )sc->sc_data_direction; + ring_req->timeout_per_command = sc->request->timeout /HZ ; + +return ring_req; +} +
drivers/scsi/xen-scsifront.c line 483
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+static int scsifront_queuecommand (struct Scsi_Host *shost, +struct scsi_cmnd *sc) +{ +struct vscsifrnt_info *info =shost_priv (shost); +struct vscsiif_request *ring_req; +struct vscsifrnt_shadow *shadow =scsi_cmd_priv (sc); +unsigned long flags; +int err; +uint16_t rqid; +
BUG_ON(sc->sc_data_direction == DMA_BIDIRECTIONAL); ?
drivers/scsi/xen-scsifront.c line 492
Quoted 9 lines
drivers/scsi/xen-scsifront.c new file +9
-0+spin_lock_irqsave (shost->host_lock, flags); +if (RING_FULL (&info->ring)) + goto busy; + + ring_req =scsifront_command2ring (info, sc, shadow); +if (!ring_req) + goto busy; + + sc->result =0 ;
This has some odd spacing? Is it suppose to be at the same aligment as the ones below? Maybe it is my editor having issues.
Quoted 64 lines
drivers/scsi/xen-scsifront.c new file +64
-0+ + rqid = ring_req->rqid; + ring_req->act =VSCSIIF_ACT_SCSI_CDB ; + + shadow->sc = sc; + shadow->act =VSCSIIF_ACT_SCSI_CDB ; + + err =map_data_for_request (info, sc, ring_req, shadow); +if (err <0 ) { +DPRINTK ("%s: err %d\n" , __func__, err); +scsifront_put_rqid (info, rqid); +spin_unlock_irqrestore (shost->host_lock, flags); +if (err == -ENOMEM ) +return SCSI_MLQUEUE_HOST_BUSY ; + sc->result =DID_ERROR <<16 ; + sc->scsi_done (sc); +return 0 ; + } + +scsifront_do_request (info); +spin_unlock_irqrestore (shost->host_lock, flags); + +return 0 ; + +busy: +spin_unlock_irqrestore (shost->host_lock, flags); +DPRINTK ("%s: busy\n" , __func__); +return SCSI_MLQUEUE_HOST_BUSY ; +} + +/* +* Any exception handling (reset or abort) must be forwarded to the backend. +* We have to wait until an answer is returned. This answer contains the +* result to be returned to the requestor. +*/ +static int scsifront_action_handler (struct scsi_cmnd *sc,uint8_t act) +{ +struct Scsi_Host *host = sc->device->host; +struct vscsifrnt_info *info =shost_priv (host); +struct vscsifrnt_shadow *shadow, *s =scsi_cmd_priv (sc); +struct vscsiif_request *ring_req; +int err =0 ; + + shadow =kmalloc (sizeof (*shadow),GFP_NOIO ); +if (!shadow) +return FAILED ; + +for (;;) { +spin_lock_irq (host->host_lock); +if (!RING_FULL (&info->ring)) { + ring_req =scsifront_command2ring (info, sc, shadow); +if (ring_req) +break ; + } +if (err) { +spin_unlock_irq (host->host_lock); +kfree (shadow); +return FAILED ; + } + info->waiting_sync =1 ; +spin_unlock_irq (host->host_lock); + err =wait_event_interruptible (info->wq_sync, + !info->waiting_sync); +spin_lock_irq (host->host_lock);
drivers/scsi/xen-scsifront.c line 566
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ } + + ring_req->act = act; + ring_req->ref_rqid = s->rqid; + + shadow->act = act; + shadow->rslt_reset =0 ; +init_waitqueue_head (&shadow->wq_reset); + + ring_req->nr_segments =0 ;
Something odd with the spaces here.
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +4
-0+ +scsifront_do_request (info); + +spin_unlock_irq (host->host_lock);
drivers/scsi/xen-scsifront.c line 580
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ err =wait_event_interruptible (shadow->wq_reset, shadow->wait_reset); +spin_lock_irq (host->host_lock); + +if (!err) { + err = shadow->rslt_reset; +scsifront_put_rqid (info, shadow->rqid); +kfree (shadow); + }else { +spin_lock (&info->shadow_lock); + shadow->rslt_reset =-1 ;
#define for -1?
Quoted 66 lines
drivers/scsi/xen-scsifront.c new file +66
-0+spin_unlock (&info->shadow_lock); + err =FAILED ; + } + +spin_unlock_irq (host->host_lock); +return err; +} + +static int scsifront_eh_abort_handler (struct scsi_cmnd *sc) +{ +DPRINTK ("%s\n" , __func__); +return scsifront_action_handler (sc,VSCSIIF_ACT_SCSI_ABORT ); +} + +static int scsifront_dev_reset_handler (struct scsi_cmnd *sc) +{ +DPRINTK ("%s\n" , __func__); +return scsifront_action_handler (sc,VSCSIIF_ACT_SCSI_RESET ); +} + +static int scsifront_sdev_configure (struct scsi_device *sdev) +{ +struct vscsifrnt_info *info =shost_priv (sdev->host); + +if (info && current == info->curr) +xenbus_printf (XBT_NIL , info->dev->nodename, + info->dev_state_path,"%d" , XenbusStateConnected); + +return 0 ; +} + +static void scsifront_sdev_destroy (struct scsi_device *sdev) +{ +struct vscsifrnt_info *info =shost_priv (sdev->host); + +if (info && current == info->curr) +xenbus_printf (XBT_NIL , info->dev->nodename, + info->dev_state_path,"%d" , XenbusStateClosed); +} + +static struct scsi_host_template scsifront_sht = { + .module =THIS_MODULE , + .name ="Xen SCSI frontend driver" , + .queuecommand = scsifront_queuecommand, + .eh_abort_handler = scsifront_eh_abort_handler, + .eh_device_reset_handler = scsifront_dev_reset_handler, + .slave_configure = scsifront_sdev_configure, + .slave_destroy = scsifront_sdev_destroy, + .cmd_per_lun =VSCSIIF_DEFAULT_CMD_PER_LUN , + .can_queue =VSCSIIF_MAX_REQS , + .this_id =-1 , + .cmd_size =sizeof (struct vscsifrnt_shadow ), + .sg_tablesize =VSCSIIF_SG_TABLESIZE , + .use_clustering =DISABLE_CLUSTERING , + .proc_name ="scsifront" , +}; + +static int scsifront_alloc_ring (struct vscsifrnt_info *info) +{ +struct xenbus_device *dev = info->dev; +struct vscsiif_sring *sring; +int err = -ENOMEM ; + +/***** Frontend to Backend ring start *****/ + sring = (struct vscsiif_sring *)__get_free_page (GFP_KERNEL ); +if (!sring) {
drivers/scsi/xen-scsifront.c line 656
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+xenbus_dev_fatal (dev, err, +"fail to allocate shared ring (Front to Back)" ); +return err; + } +SHARED_RING_INIT (sring); +FRONT_RING_INIT (&info->ring, sring,PAGE_SIZE ); + + err =xenbus_grant_ring (dev,virt_to_mfn (sring)); +if (err <0 ) { +free_page ((unsigned long ) sring);
You can remove the space there.
Quoted 26 lines
drivers/scsi/xen-scsifront.c new file +26
-0+xenbus_dev_fatal (dev, err, +"fail to grant shared ring (Front to Back)" ); +return err; + } + info->ring_ref = err; + + err =xenbus_alloc_evtchn (dev, &info->evtchn); +if (err) { +xenbus_dev_fatal (dev, err,"xenbus_alloc_evtchn" ); + goto free_gnttab; + } + + err =bind_evtchn_to_irq (info->evtchn); +if (err <=0 ) { +xenbus_dev_fatal (dev, err,"bind_evtchn_to_irq" ); + goto free_gnttab; + } + + info->irq = err; + + err =request_threaded_irq (info->irq,NULL , scsifront_irq_fn, +IRQF_ONESHOT ,"scsifront" , info); +if (err) { +xenbus_dev_fatal (dev, err,"request_threaded_irq" ); + goto free_irq; + }
drivers/scsi/xen-scsifront.c line 692
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ +return 0 ; + +/* free resource */ +free_irq: +unbind_from_irqhandler (info->irq, info); +free_gnttab: +gnttab_end_foreign_access (info->ring_ref,0 , + (unsigned long )info->ring.sring); +
free_page((unsigned long)sring);
Quoted 43 lines
drivers/scsi/xen-scsifront.c new file +43
-0+return err; +} + +static int scsifront_init_ring (struct vscsifrnt_info *info) +{ +struct xenbus_device *dev = info->dev; +struct xenbus_transaction xbt; +int err; + +DPRINTK ("%s\n" , __func__); + + err =scsifront_alloc_ring (info); +if (err) +return err; +DPRINTK ("%u %u\n" , info->ring_ref, info->evtchn); + +again: + err =xenbus_transaction_start (&xbt); +if (err) +xenbus_dev_fatal (dev, err,"starting transaction" ); + + err =xenbus_printf (xbt, dev->nodename,"ring-ref" ,"%u" , + info->ring_ref); +if (err) { +xenbus_dev_fatal (dev, err,"%s" ,"writing ring-ref" ); + goto fail; + } + + err =xenbus_printf (xbt, dev->nodename,"event-channel" ,"%u" , + info->evtchn); + +if (err) { +xenbus_dev_fatal (dev, err,"%s" ,"writing event-channel" ); + goto fail; + } + + err =xenbus_transaction_end (xbt,0 ); +if (err) { +if (err == -EAGAIN ) + goto again; +xenbus_dev_fatal (dev, err,"completing transaction" ); + goto free_sring; + }
drivers/scsi/xen-scsifront.c line 745
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ +return 0 ; + +fail: +xenbus_transaction_end (xbt,1 ); +free_sring: +unbind_from_irqhandler (info->irq, info); +gnttab_end_foreign_access (info->ring_ref,0 , + (unsigned long )info->ring.sring); +
The label says 'free_sring' but I am not seeing it being freed?
Quoted 11 lines
drivers/scsi/xen-scsifront.c new file +11
-0+return err; +} + + +static int scsifront_probe (struct xenbus_device *dev, +const struct xenbus_device_id *id) +{ +struct vscsifrnt_info *info; +struct Scsi_Host *host; +int err = -ENOMEM ; +char name[DEFAULT_TASK_COMM_LEN ];
drivers/scsi/xen-scsifront.c line 766
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ + host =scsi_host_alloc (&scsifront_sht,sizeof (*info)); +if (!host) { +xenbus_dev_fatal (dev, err,"fail to allocate scsi host" ); +return err; + } + info = (struct vscsifrnt_info *)host->hostdata; + +dev_set_drvdata (&dev->dev, info); + info->dev = dev;
Extra space.
Quoted 27 lines
drivers/scsi/xen-scsifront.c new file +27
-0+ + info->shadow_free = (1UL <<VSCSIIF_MAX_REQS ) -1 ; + + err =scsifront_init_ring (info); +if (err) { +scsi_host_put (host); +return err; + } + +init_waitqueue_head (&info->wq_sync); +spin_lock_init (&info->shadow_lock); + +snprintf (name,DEFAULT_TASK_COMM_LEN ,"vscsiif.%d" , host->host_no); + + host->max_id =VSCSIIF_MAX_TARGET ; + host->max_channel =0 ; + host->max_lun =VSCSIIF_MAX_LUN ; + host->max_sectors = (host->sg_tablesize -1 ) *PAGE_SIZE /512 ; + host->max_cmd_len =VSCSIIF_MAX_COMMAND_SIZE ; + + err =scsi_add_host (host, &dev->dev); +if (err) { +dev_err (&dev->dev,"fail to add scsi host %d\n" , err); + goto free_sring; + } + info->host = host; + info->host_active =1 ;
drivers/scsi/xen-scsifront.c line 803
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ +xenbus_switch_state (dev, XenbusStateInitialised); + +return 0 ; + +free_sring: +unbind_from_irqhandler (info->irq, info); +gnttab_end_foreign_access (info->ring_ref,0 , + (unsigned long )info->ring.sring); +scsi_host_put (host);
The label says 'free_sring' but I am not seeing it being freed?
Hm, could those operations - unbind_from_irqhandler, gnttab_end_foreign_access and free_page be moved to a seperate function to call?
Quoted 9 lines
drivers/scsi/xen-scsifront.c new file +9
-0+return err; +} + +static int scsifront_remove (struct xenbus_device *dev) +{ +struct vscsifrnt_info *info =dev_get_drvdata (&dev->dev); + +DPRINTK ("%s: %s removed\n" , __func__, dev->nodename); +
drivers/scsi/xen-scsifront.c line 822
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+if (info->host_active) { +/* Scsi_host not yet removed */ +scsi_remove_host (info->host); + info->host_active =0 ; + } + +gnttab_end_foreign_access (info->ring_ref,0 , + (unsigned long )info->ring.sring); +unbind_from_irqhandler (info->irq, info); +
Should you free the ring?
Quoted 60 lines
drivers/scsi/xen-scsifront.c new file +60
-0+scsi_host_put (info->host); + +return 0 ; +} + +static void scsifront_disconnect (struct vscsifrnt_info *info) +{ +struct xenbus_device *dev = info->dev; +struct Scsi_Host *host = info->host; + +DPRINTK ("%s: %s disconnect\n" , __func__, dev->nodename); + +/* +* When this function is executed, all devices of +* Frontend have been deleted. +* Therefore, it need not block I/O before remove_host. +*/ + +if (info->host_active) +scsi_remove_host (host); + info->host_active =0 ; + +xenbus_frontend_closed (dev); +} + +static void scsifront_do_lun_hotplug (struct vscsifrnt_info *info,int op) +{ +struct xenbus_device *dev = info->dev; +int i, err =0 ; +char str[64 ]; +char **dir; +unsigned int dir_n =0 ; +unsigned int device_state; +unsigned int hst, chn, tgt, lun; +struct scsi_device *sdev; + + dir =xenbus_directory (XBT_NIL , dev->otherend,"vscsi-devs" , &dir_n); +if (IS_ERR (dir)) +return ; + +/* mark current task as the one allowed to modify device states */ +BUG_ON (info->curr); + info->curr = current; + +for (i =0 ; i < dir_n; i++) { +/* read status */ +snprintf (str,sizeof (str),"vscsi-devs/%s/state" , dir[i]); + err =xenbus_scanf (XBT_NIL , dev->otherend, str,"%u" , + &device_state); +if (XENBUS_EXIST_ERR (err)) +continue ; + +/* virtual SCSI device */ +snprintf (str,sizeof (str),"vscsi-devs/%s/v-dev" , dir[i]); + err =xenbus_scanf (XBT_NIL , dev->otherend, str, +"%u:%u:%u:%u" , &hst, &chn, &tgt, &lun); +if (XENBUS_EXIST_ERR (err)) +continue ; + +/*
drivers/scsi/xen-scsifront.c line 892
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+* Front device state path, used in slave_configure called +* on successfull scsi_add_device, and in slave_destroy called +* on remove of a device. +*/ +snprintf (info->dev_state_path,sizeof (info->dev_state_path), +"vscsi-devs/%s/state" , dir[i]); + +switch (op) { +case VSCSIFRONT_OP_ADD_LUN : +if (device_state == XenbusStateInitialised) {
You could convert to make this a bit easier to read to do:
if (device_state != XenbusStateInitialised) break; .. and then with the rest of the code.
drivers/scsi/xen-scsifront.c line 894
Quoted 2 lines
drivers/scsi/xen-scsifront.c new file +2
-0+ err =scsi_add_device (info->host, chn, tgt, + lun);
You can make that more than 80 characters long.
drivers/scsi/xen-scsifront.c line 905
Quoted 11 lines
drivers/scsi/xen-scsifront.c new file +11
-0+ +if (err) { +dev_err (&dev->dev,"scsi_add_device\n" ); +xenbus_printf (XBT_NIL , dev->nodename, + info->dev_state_path, +"%d" , XenbusStateClosed); + } + } +break ; +case VSCSIFRONT_OP_DEL_LUN : +if (device_state == XenbusStateClosing) {
Ditto.
Quoted 24 lines
drivers/scsi/xen-scsifront.c new file +24
-0+ sdev =scsi_device_lookup (info->host, chn, tgt, + lun); +if (sdev) { +scsi_remove_device (sdev); +scsi_device_put (sdev); + } + } +break ; +default : +break ; + } + } + + info->curr =NULL ; + +kfree (dir); +} + +static void scsifront_read_backend_params (struct xenbus_device *dev, +struct vscsifrnt_info *info) +{ +unsigned int sg_grant; +int ret; +struct Scsi_Host *host = info->host;
drivers/scsi/xen-scsifront.c line 939
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ + ret =xenbus_scanf (XBT_NIL , dev->otherend,"feature-sg-grant" ,"%u" , + &sg_grant); +if (ret ==1 && sg_grant) { + sg_grant = min_t(unsigned int, sg_grant, SG_ALL); + host->sg_tablesize = min_t(unsigned int, sg_grant, +VSCSIIF_SG_TABLESIZE *PAGE_SIZE / +sizeof (struct scsiif_request_segment )); +dev_info (&dev->dev,"using up to %d SG entries\n" , + host->sg_tablesize);
Perhaps this dev_info can be printed regardless of whether the backend has advertised an value? Isn't this information also visible in the SysFS? If so, should it be just removed?
drivers/scsi/xen-scsifront.c line 940
Quoted 1 line
drivers/scsi/xen-scsifront.c new file +1
-0+ host->max_sectors = (host->sg_tablesize -1 ) *PAGE_SIZE /512 ;
If the backend decides to give us an value less than optimal - say '2' should we just ignore it? Perhaps have
if (sg_grant < VSCSIIF_SG_TABLESIZE)
/* Pfffff. */ return;
Quoted 11 lines
drivers/scsi/xen-scsifront.c new file +11
-0+ } +} + +static void scsifront_backend_changed (struct xenbus_device *dev, +enum xenbus_state backend_state) +{ +struct vscsifrnt_info *info =dev_get_drvdata (&dev->dev); + +DPRINTK ("%p %u %u\n" , dev, dev->state, backend_state); + +switch (backend_state) {
drivers/scsi/xen-scsifront.c line 961
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+case XenbusStateUnknown: +case XenbusStateInitialising: +case XenbusStateInitWait: +case XenbusStateInitialised: +break ; + +case XenbusStateConnected: +scsifront_read_backend_params (dev, info); +if (xenbus_read_driver_state (dev->nodename) == + XenbusStateInitialised) {
You can make this more than 80 characters. And also remove the '{' and '}'
Quoted 46 lines
drivers/scsi/xen-scsifront.c new file +46
-0+scsifront_do_lun_hotplug (info,VSCSIFRONT_OP_ADD_LUN ); + } + +if (dev->state != XenbusStateConnected) +xenbus_switch_state (dev, XenbusStateConnected); +break ; + +case XenbusStateClosed: +if (dev->state == XenbusStateClosed) +break ; +/* Missed the backend's Closing state -- fallthrough */ +case XenbusStateClosing: +scsifront_disconnect (info); +break ; + +case XenbusStateReconfiguring: +scsifront_do_lun_hotplug (info,VSCSIFRONT_OP_DEL_LUN ); +xenbus_switch_state (dev, XenbusStateReconfiguring); +break ; + +case XenbusStateReconfigured: +scsifront_do_lun_hotplug (info,VSCSIFRONT_OP_ADD_LUN ); +xenbus_switch_state (dev, XenbusStateConnected); +break ; + } +} + +static const struct xenbus_device_id scsifront_ids[] = { + {"vscsi" }, + {"" } +}; + +static DEFINE_XENBUS_DRIVER(scsifront, , + .probe = scsifront_probe, + .remove = scsifront_remove, + .otherend_changed = scsifront_backend_changed, +); + +static int __init scsifront_init (void ) +{ +if (!xen_domain ()) +return -ENODEV ; + +return xenbus_register_frontend (&scsifront_driver); +} +module_init (scsifront_init);
drivers/scsi/xen-scsifront.c line 1017
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ +static void __exit scsifront_exit(void) +{ +xenbus_unregister_driver (&scsifront_driver); +} +module_exit (scsifront_exit); + +MODULE_DESCRIPTION ("Xen SCSI frontend driver" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("xen:vscsi" );
MODULE_AUTHOR?
[email protected]
maintainerPATCH v5 3/5 Introduce xen-scsifront module
In reply to [email protected]From: Juergen Gross <[email protected]>
Introduces the XEN pvSCSI frontend. With pvSCSI it is possible for a XEN domU to issue SCSI commands to a SCSI LUN assigned to that domU. The SCSI commands are passed to the pvSCSI backend in a driver domain (usually Dom0) which is owner of the physical device. This allows e.g. to use SCSI tape drives in a XEN domU.
The code is taken from the pvSCSI implementation in XEN done by Fujitsu based on Linux kernel 2.6.18.
Changes from the original version are:
- port to upstream kernel
- put all code in just one source file
- move module to appropriate location in kernel tree
- adapt to Linux style guide
- some minor code simplifications
- replace constants with defines
- remove not used defines
- add support for larger SG lists by putting them in a granted page
Xen related parts
--- drivers/scsi/Kconfig | 9 + drivers/scsi/Makefile | 1 + drivers/scsi/xen-scsifront.c | 1017 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1027 insertions(+) create mode 100644 drivers/scsi/xen-scsifront.c
drivers/scsi/Kconfig +9 -0
@@ -576,6 +576,15 @@ config VMWARE_PVSCSI To compile this driver as a module, choose M here: the module will be called vmw_pvscsi. +config XEN_SCSI_FRONTEND + tristate "XEN SCSI frontend driver" + depends on SCSI && XEN + help + The XEN SCSI frontend driver allows the kernel to access SCSI Devices + within another guest OS (usually Dom0). + Only needed if the kernel is running in a XEN guest and generic + SCSI access to a device is needed. + config HYPERV_STORAGE tristate "Microsoft Hyper-V virtual storage driver" depends on SCSI && HYPERV
drivers/scsi/Makefile +1 -0
@@ -141,6 +141,7 @@ obj-$(CONFIG_SCSI_ESAS2R) += esas2r/ obj-$(CONFIG_SCSI_PMCRAID) += pmcraid.o obj-$(CONFIG_SCSI_VIRTIO) += virtio_scsi.o obj-$(CONFIG_VMWARE_PVSCSI) += vmw_pvscsi.o +obj-$(CONFIG_XEN_SCSI_FRONTEND) += xen-scsifront.o obj-$(CONFIG_HYPERV_STORAGE) += hv_storvsc.o obj-$(CONFIG_ARM) += arm/
drivers/scsi/xen-scsifront.c new file +1017 -0
1,017 lines not on this page · raw message
Signature · 1 line
1.8.4.5
[email protected]
maintainerPATCH v5 4/5 Introduce XEN scsiback module
In reply to [email protected]From: Juergen Gross <[email protected]>
Introduces the XEN pvSCSI backend. With pvSCSI it is possible for a XEN domU to issue SCSI commands to a SCSI LUN assigned to that domU. The SCSI commands are passed to the pvSCSI backend in a driver domain (usually Dom0) which is owner of the physical device. This allows e.g. to use SCSI tape drives in a XEN domU.
The code is taken from the pvSCSI implementation in XEN done by Fujitsu based on Linux kernel 2.6.18.
Changes from the original version are:
- port to upstream kernel
- put all code in just one source file
- adapt to Linux style guide
- use target core infrastructure instead doing pure pass-through
- enable module unloading
- support SG-list in grant page(s)
- support task abort
- remove redundant struct backend
- allocate resources dynamically
- correct minor error in scsiback_fast_flush_area
- free allocated resources in case of error during I/O preparation
- remove CDB emulation, now handled by target core infrastructure
Xen related parts
--- drivers/xen/Kconfig | 9 + drivers/xen/Makefile | 1 + drivers/xen/xen-scsiback.c | 2124 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2134 insertions(+) create mode 100644 drivers/xen/xen-scsiback.c
drivers/xen/Kconfig +9 -0
@@ -172,6 +172,15 @@ config XEN_PCIDEV_BACKEND If in doubt, say m. +config XEN_SCSI_BACKEND + tristate "XEN SCSI backend driver" + depends on XEN && XEN_BACKEND && TARGET_CORE + help + The SCSI backend driver allows the kernel to export its SCSI Devices + to other guests via a high-performance shared-memory interface. + Only needed for systems running as XEN driver domains (e.g. Dom0) and + if guests need generic access to SCSI devices. + config XEN_PRIVCMD tristate depends on XEN
drivers/xen/Makefile +1 -0
@@ -36,6 +36,7 @@ obj-$(CONFIG_XEN_ACPI_HOTPLUG_MEMORY) += xen-acpi-memhotplug.o obj-$(CONFIG_XEN_ACPI_HOTPLUG_CPU) += xen-acpi-cpuhotplug.o obj-$(CONFIG_XEN_ACPI_PROCESSOR) += xen-acpi-processor.o obj-$(CONFIG_XEN_EFI) += efi.o +obj-$(CONFIG_XEN_SCSI_BACKEND) += xen-scsiback.o xen-evtchn-y := evtchn.o xen-gntdev-y := gntdev.o xen-gntalloc-y := gntalloc.o
drivers/xen/xen-scsiback.c new file +2124 -0
2,124 lines not on this page · raw message
Signature · 1 line
1.8.4.5
[email protected]
maintainerPATCH v5 4/5 Introduce XEN scsiback module
In reply to [email protected]From: Juergen Gross <[email protected]>
Introduces the XEN pvSCSI backend. With pvSCSI it is possible for a XEN domU to issue SCSI commands to a SCSI LUN assigned to that domU. The SCSI commands are passed to the pvSCSI backend in a driver domain (usually Dom0) which is owner of the physical device. This allows e.g. to use SCSI tape drives in a XEN domU.
The code is taken from the pvSCSI implementation in XEN done by Fujitsu based on Linux kernel 2.6.18.
Changes from the original version are:
- port to upstream kernel
- put all code in just one source file
- adapt to Linux style guide
- use target core infrastructure instead doing pure pass-through
- enable module unloading
- support SG-list in grant page(s)
- support task abort
- remove redundant struct backend
- allocate resources dynamically
- correct minor error in scsiback_fast_flush_area
- free allocated resources in case of error during I/O preparation
- remove CDB emulation, now handled by target core infrastructure
Xen related parts
--- drivers/xen/Kconfig | 9 + drivers/xen/Makefile | 1 + drivers/xen/xen-scsiback.c | 2124 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2134 insertions(+) create mode 100644 drivers/xen/xen-scsiback.c
drivers/xen/Kconfig +9 -0
@@ -172,6 +172,15 @@ config XEN_PCIDEV_BACKEND If in doubt, say m. +config XEN_SCSI_BACKEND + tristate "XEN SCSI backend driver" + depends on XEN && XEN_BACKEND && TARGET_CORE + help + The SCSI backend driver allows the kernel to export its SCSI Devices + to other guests via a high-performance shared-memory interface. + Only needed for systems running as XEN driver domains (e.g. Dom0) and + if guests need generic access to SCSI devices. + config XEN_PRIVCMD tristate depends on XEN
drivers/xen/Makefile +1 -0
@@ -36,6 +36,7 @@ obj-$(CONFIG_XEN_ACPI_HOTPLUG_MEMORY) += xen-acpi-memhotplug.o obj-$(CONFIG_XEN_ACPI_HOTPLUG_CPU) += xen-acpi-cpuhotplug.o obj-$(CONFIG_XEN_ACPI_PROCESSOR) += xen-acpi-processor.o obj-$(CONFIG_XEN_EFI) += efi.o +obj-$(CONFIG_XEN_SCSI_BACKEND) += xen-scsiback.o xen-evtchn-y := evtchn.o xen-gntdev-y := gntdev.o xen-gntalloc-y := gntalloc.o
drivers/xen/xen-scsiback.c new file +2124 -0
2,124 lines not on this page · raw message
Signature · 1 line
1.8.4.5
[email protected]
maintainerPATCH v5 5/5 add xen pvscsi maintainer
In reply to [email protected]From: Juergen Gross <[email protected]>
Add myself as maintainer for the Xen pvSCSI stuff.
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -10086,6 +10086,14 @@ S: Supported F: drivers/block/xen-blkback/* F: drivers/block/xen* +XEN PVSCSI DRIVERS +M: Juergen Gross <[email protected]> +L: [email protected] (moderated for non-subscribers) +S: Supported +F: drivers/scsi/xen-scsifront.c +F: drivers/xen/xen-scsiback.c +F: include/xen/interface/io/vscsiif.h + XEN SWIOTLB SUBSYSTEM M: Konrad Rzeszutek Wilk <[email protected]> L: [email protected] (moderated for non-subscribers)
Signature · 1 line
1.8.4.5
[email protected]
maintainerPATCH v5 5/5 add xen pvscsi maintainer
In reply to [email protected]From: Juergen Gross <[email protected]>
Add myself as maintainer for the Xen pvSCSI stuff.
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -10086,6 +10086,14 @@ S: Supported F: drivers/block/xen-blkback/* F: drivers/block/xen* +XEN PVSCSI DRIVERS +M: Juergen Gross <[email protected]> +L: [email protected] (moderated for non-subscribers) +S: Supported +F: drivers/scsi/xen-scsifront.c +F: drivers/xen/xen-scsiback.c +F: include/xen/interface/io/vscsiif.h + XEN SWIOTLB SUBSYSTEM M: Konrad Rzeszutek Wilk <[email protected]> L: [email protected] (moderated for non-subscribers)
Signature · 1 line
1.8.4.5
Re: [PATCH V5 5/5] add xen pvscsi maintainer
Quoted 5 lines · On Mon, Aug 18, 2014 at 11:31:50AM +0200, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add myself as maintainer for the Xen pvSCSI stuff.
Signed-off-by Juergen Gross <[email protected]>
Quoted 31 lines
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)MAINTAINERS +8
-0@@ -10086,6 +10086,14 @@ S: Supported F: drivers/block/xen-blkback/* F: drivers/block/xen* +XEN PVSCSI DRIVERS +M: Juergen Gross <[email protected]> +L: [email protected] (moderated for non-subscribers) +S: Supported +F: drivers/scsi/xen-scsifront.c +F: drivers/xen/xen-scsiback.c +F: include/xen/interface/io/vscsiif.h + XEN SWIOTLB SUBSYSTEM M: Konrad Rzeszutek Wilk <[email protected]> L: [email protected] (moderated for non-subscribers)Signature · 7 lines
1.8.4.5 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH V5 5/5] add xen pvscsi maintainer
In reply to [email protected]Quoted 5 lines · On Mon, Aug 18, 2014 at 11:31:50AM +0200, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add myself as maintainer for the Xen pvSCSI stuff.
Signed-off-by Juergen Gross <[email protected]>
Quoted 31 lines
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)MAINTAINERS +8
-0@@ -10086,6 +10086,14 @@ S: Supported F: drivers/block/xen-blkback/* F: drivers/block/xen* +XEN PVSCSI DRIVERS +M: Juergen Gross <[email protected]> +L: [email protected] (moderated for non-subscribers) +S: Supported +F: drivers/scsi/xen-scsifront.c +F: drivers/xen/xen-scsiback.c +F: include/xen/interface/io/vscsiif.h + XEN SWIOTLB SUBSYSTEM M: Konrad Rzeszutek Wilk <[email protected]> L: [email protected] (moderated for non-subscribers)Signature · 7 lines
1.8.4.5 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH V5 5/5] add xen pvscsi maintainer
In reply to [email protected]Quoted 14 lines · On 18/08/14 10:31, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add myself as maintainer for the Xen pvSCSI stuff.
Signed-off-by Juergen Gross <[email protected]>--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)MAINTAINERS +0
-0
MAINTAINERS S: Supported · line 10091
Quoted 6 lines
MAINTAINERS +3
-0@@ -10086,6 +10086,14 @@ S: Supported F: drivers/block/xen-blkback/* F: drivers/block/xen* +XEN PVSCSI DRIVERS +M: Juergen Gross <[email protected]> +L: [email protected] (moderated for non-subscribers)
You should add the appropriate scsi list here
([email protected] I presume?)
David
Quoted 9 lines
MAINTAINERS +5
-0+S: Supported +F: drivers/scsi/xen-scsifront.c +F: drivers/xen/xen-scsiback.c +F: include/xen/interface/io/vscsiif.h + XEN SWIOTLB SUBSYSTEM M: Konrad Rzeszutek Wilk <[email protected]> L: [email protected] (moderated for non-subscribers)
Juergen Gross
maintainerRe: [PATCH V5 5/5] add xen pvscsi maintainer
Quoted 18 lines · David Vrabel
Quoted 17 lines · On 18/08/14 10:31, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add myself as maintainer for the Xen pvSCSI stuff.
Signed-off-by Juergen Gross <[email protected]>--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)MAINTAINERS +0
-0@@ -10086,6 +10086,14 @@ S: Supported F: drivers/block/xen-blkback/* F: drivers/block/xen*
Quoted 6 lines
MAINTAINERS S: Supported · line 10091
Quoted 3 lines
MAINTAINERS +3
-0+XEN PVSCSI DRIVERS +M: Juergen Gross <[email protected]> +L: [email protected] (moderated for non-subscribers)You should add the appropriate scsi list here
([email protected] I presume?)
Really? Xen PCI and Xen Block susbsystems don't have an according entry. James, do you have an opinion here? I don't mind adding linux-scsi, but I think the Xen list is the appropriate one for pvSCSI.
Quoted 5 lines
MAINTAINERS S: Supported · line 10096
Quoted 5 lines
MAINTAINERS +5
-0+S: Supported +F: drivers/scsi/xen-scsifront.c +F: drivers/xen/xen-scsiback.c +F: include/xen/interface/io/vscsiif.h +
Juergen
Juergen Gross
maintainerRe: [Xen-devel] [PATCH V5 5/5] add xen pvscsi maintainer
In reply to David VrabelQuoted 18 lines · David Vrabel
Quoted 17 lines · On 18/08/14 10:31, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add myself as maintainer for the Xen pvSCSI stuff.
Signed-off-by Juergen Gross <[email protected]>--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)MAINTAINERS +0
-0@@ -10086,6 +10086,14 @@ S: Supported F: drivers/block/xen-blkback/* F: drivers/block/xen*
Quoted 6 lines
MAINTAINERS S: Supported · line 10091
Quoted 3 lines
MAINTAINERS +3
-0+XEN PVSCSI DRIVERS +M: Juergen Gross <[email protected]> +L: [email protected] (moderated for non-subscribers)You should add the appropriate scsi list here
([email protected] I presume?)
Really? Xen PCI and Xen Block susbsystems don't have an according entry. James, do you have an opinion here? I don't mind adding linux-scsi, but I think the Xen list is the appropriate one for pvSCSI.
Quoted 5 lines
MAINTAINERS S: Supported · line 10096
Quoted 5 lines
MAINTAINERS +5
-0+S: Supported +F: drivers/scsi/xen-scsifront.c +F: drivers/xen/xen-scsiback.c +F: include/xen/interface/io/vscsiif.h +
Juergen
James Bottomley
maintainerRe: [Xen-devel] [PATCH V5 5/5] add xen pvscsi maintainer
Quoted 26 lines · Juergen Gross
Quoted 18 lines · David Vrabel
Quoted 17 lines · On 18/08/14 10:31, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add myself as maintainer for the Xen pvSCSI stuff.
Signed-off-by Juergen Gross <[email protected]>--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)MAINTAINERS +0
-0@@ -10086,6 +10086,14 @@ S: Supported F: drivers/block/xen-blkback/* F: drivers/block/xen*Quoted 6 lines
MAINTAINERS S: Supported · line 10091
Quoted 3 lines
MAINTAINERS +3
-0+XEN PVSCSI DRIVERS +M: Juergen Gross <[email protected]> +L: [email protected] (moderated for non-subscribers)You should add the appropriate scsi list here
([email protected] I presume?)
Quoted 3 lines
Really? Xen PCI and Xen Block susbsystems don't have an according entry. James, do you have an opinion here? I don't mind adding linux-scsi, but I think the Xen list is the appropriate one for pvSCSI.
It depends how you want to handle this, but the patches have to come on to the SCSI list somehow. You can have them directly posted by adding the list, or you can repost them yourselves. It's a question of workflow.
James
Re: [PATCH V5 5/5] add xen pvscsi maintainer
Quoted 27 lines · James Bottomley
Quoted 26 lines · Juergen Gross
Quoted 24 lines · David Vrabel
Quoted 14 lines · On 18/08/14 10:31, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add myself as maintainer for the Xen pvSCSI stuff.
Signed-off-by Juergen Gross <[email protected]>--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)MAINTAINERS +0
-0MAINTAINERS S: Supported · line 10091
Quoted 6 lines
MAINTAINERS +3
-0@@ -10086,6 +10086,14 @@ S: Supported F: drivers/block/xen-blkback/* F: drivers/block/xen* +XEN PVSCSI DRIVERS +M: Juergen Gross <[email protected]> +L: [email protected] (moderated for non-subscribers)You should add the appropriate scsi list here
([email protected] I presume?)
Quoted 8 lines
Quoted 3 lines
Really? Xen PCI and Xen Block susbsystems don't have an according entry. James, do you have an opinion here? I don't mind adding linux-scsi, but I think the Xen list is the appropriate one for pvSCSI.
It depends how you want to handle this, but the patches have to come on to the SCSI list somehow. You can have them directly posted by adding the list, or you can repost them yourselves. It's a question of workflow.
I think these drivers have had (and will continue to have) the most useful review from scsi people. I think posting directly (hence earlier) to linux-scsi will ensure the best quality.
This is the workflow used for the Xen network drivers and I think it works well.
David
Re: [Xen-devel] [PATCH V5 5/5] add xen pvscsi maintainer
In reply to James BottomleyQuoted 27 lines · James Bottomley
Quoted 26 lines · Juergen Gross
Quoted 24 lines · David Vrabel
Quoted 14 lines · On 18/08/14 10:31, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add myself as maintainer for the Xen pvSCSI stuff.
Signed-off-by Juergen Gross <[email protected]>--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)MAINTAINERS +0
-0MAINTAINERS S: Supported · line 10091
Quoted 6 lines
MAINTAINERS +3
-0@@ -10086,6 +10086,14 @@ S: Supported F: drivers/block/xen-blkback/* F: drivers/block/xen* +XEN PVSCSI DRIVERS +M: Juergen Gross <[email protected]> +L: [email protected] (moderated for non-subscribers)You should add the appropriate scsi list here
([email protected] I presume?)
Quoted 8 lines
Quoted 3 lines
Really? Xen PCI and Xen Block susbsystems don't have an according entry. James, do you have an opinion here? I don't mind adding linux-scsi, but I think the Xen list is the appropriate one for pvSCSI.
It depends how you want to handle this, but the patches have to come on to the SCSI list somehow. You can have them directly posted by adding the list, or you can repost them yourselves. It's a question of workflow.
I think these drivers have had (and will continue to have) the most useful review from scsi people. I think posting directly (hence earlier) to linux-scsi will ensure the best quality.
This is the workflow used for the Xen network drivers and I think it works well.
David
Juergen Gross
maintainerRe: [Xen-devel] [PATCH V5 5/5] add xen pvscsi maintainer
Quoted 37 lines · David Vrabel
Quoted 27 lines · James Bottomley
Quoted 26 lines · Juergen Gross
Quoted 24 lines · David Vrabel
Quoted 14 lines · On 18/08/14 10:31, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add myself as maintainer for the Xen pvSCSI stuff.
Signed-off-by Juergen Gross <[email protected]>--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)MAINTAINERS +0
-0MAINTAINERS S: Supported · line 10091
Quoted 6 lines
MAINTAINERS +3
-0@@ -10086,6 +10086,14 @@ S: Supported F: drivers/block/xen-blkback/* F: drivers/block/xen* +XEN PVSCSI DRIVERS +M: Juergen Gross <[email protected]> +L: [email protected] (moderated for non-subscribers)You should add the appropriate scsi list here
([email protected] I presume?)Quoted 8 lines
Quoted 3 lines
Really? Xen PCI and Xen Block susbsystems don't have an according entry. James, do you have an opinion here? I don't mind adding linux-scsi, but I think the Xen list is the appropriate one for pvSCSI.
It depends how you want to handle this, but the patches have to come on to the SCSI list somehow. You can have them directly posted by adding the list, or you can repost them yourselves. It's a question of workflow.
Quoted 6 lines
I think these drivers have had (and will continue to have) the most useful review from scsi people. I think posting directly (hence earlier) to linux-scsi will ensure the best quality.
This is the workflow used for the Xen network drivers and I think it works well.
Okay, I'll add the scsi list.
Juergen
Juergen Gross
maintainerRe: [PATCH V5 5/5] add xen pvscsi maintainer
In reply to David VrabelQuoted 37 lines · David Vrabel
Quoted 27 lines · James Bottomley
Quoted 26 lines · Juergen Gross
Quoted 24 lines · David Vrabel
Quoted 14 lines · On 18/08/14 10:31, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add myself as maintainer for the Xen pvSCSI stuff.
Signed-off-by Juergen Gross <[email protected]>--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)MAINTAINERS +0
-0MAINTAINERS S: Supported · line 10091
Quoted 6 lines
MAINTAINERS +3
-0@@ -10086,6 +10086,14 @@ S: Supported F: drivers/block/xen-blkback/* F: drivers/block/xen* +XEN PVSCSI DRIVERS +M: Juergen Gross <[email protected]> +L: [email protected] (moderated for non-subscribers)You should add the appropriate scsi list here
([email protected] I presume?)Quoted 8 lines
Quoted 3 lines
Really? Xen PCI and Xen Block susbsystems don't have an according entry. James, do you have an opinion here? I don't mind adding linux-scsi, but I think the Xen list is the appropriate one for pvSCSI.
It depends how you want to handle this, but the patches have to come on to the SCSI list somehow. You can have them directly posted by adding the list, or you can repost them yourselves. It's a question of workflow.
Quoted 6 lines
I think these drivers have had (and will continue to have) the most useful review from scsi people. I think posting directly (hence earlier) to linux-scsi will ensure the best quality.
This is the workflow used for the Xen network drivers and I think it works well.
Okay, I'll add the scsi list.
Juergen
James Bottomley
maintainerRe: [PATCH V5 5/5] add xen pvscsi maintainer
In reply to Juergen GrossQuoted 26 lines · Juergen Gross
Quoted 18 lines · David Vrabel
Quoted 17 lines · On 18/08/14 10:31, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add myself as maintainer for the Xen pvSCSI stuff.
Signed-off-by Juergen Gross <[email protected]>--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)MAINTAINERS +0
-0@@ -10086,6 +10086,14 @@ S: Supported F: drivers/block/xen-blkback/* F: drivers/block/xen*Quoted 6 lines
MAINTAINERS S: Supported · line 10091
Quoted 3 lines
MAINTAINERS +3
-0+XEN PVSCSI DRIVERS +M: Juergen Gross <[email protected]> +L: [email protected] (moderated for non-subscribers)You should add the appropriate scsi list here
([email protected] I presume?)
Quoted 3 lines
Really? Xen PCI and Xen Block susbsystems don't have an according entry. James, do you have an opinion here? I don't mind adding linux-scsi, but I think the Xen list is the appropriate one for pvSCSI.
It depends how you want to handle this, but the patches have to come on to the SCSI list somehow. You can have them directly posted by adding the list, or you can repost them yourselves. It's a question of workflow.
James
Re: [PATCH V5 5/5] add xen pvscsi maintainer
In reply to [email protected]Quoted 14 lines · On 18/08/14 10:31, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add myself as maintainer for the Xen pvSCSI stuff.
Signed-off-by Juergen Gross <[email protected]>--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)MAINTAINERS +0
-0
MAINTAINERS S: Supported · line 10091
Quoted 6 lines
MAINTAINERS +3
-0@@ -10086,6 +10086,14 @@ S: Supported F: drivers/block/xen-blkback/* F: drivers/block/xen* +XEN PVSCSI DRIVERS +M: Juergen Gross <[email protected]> +L: [email protected] (moderated for non-subscribers)
You should add the appropriate scsi list here
([email protected] I presume?)
David
Quoted 9 lines
MAINTAINERS +5
-0+S: Supported +F: drivers/scsi/xen-scsifront.c +F: drivers/xen/xen-scsiback.c +F: include/xen/interface/io/vscsiif.h + XEN SWIOTLB SUBSYSTEM M: Konrad Rzeszutek Wilk <[email protected]> L: [email protected] (moderated for non-subscribers)
Hi Juergen & Co,
Quoted 31 lines · On Mon, 2014-08-18 at 11:31 +0200, [email protected] wrote:
This series adds XEN pvSCSI support. With pvSCSI it is possible to use physical SCSI devices from a XEN domain.
The support consists of a backend in the privileged Domain-0 doing the real I/O and a frontend in the unprivileged domU passing I/O-requests to the backend.
The code is taken (and adapted) from the original pvSCSI implementation done for Linux 2.6 in 2008 by Fujitsu.
[PATCH V5 1/5] xen/events: support threaded irqs for interdomain event channels [PATCH V5 2/5] Add XEN pvSCSI protocol description
[PATCH V5 3/5] Introduce xen-scsifront module
[PATCH V5 4/5] Introduce XEN scsiback module
[PATCH V5 5/5] add xen pvscsi maintainerChanges in V5:
- Added patch to support threaded irqs for interdomain event channels
- several changes in xen-scsifront after comments from Christoph Hellwig
- several changes in xen-scsiback after comments from Christoph Hellwig
- several changes in xen-scsiback after comments from James BottomleyChanges in V4:
- Re-add define forVSCSIIF_ACT_SCSI_SG_PRESETtovscsiif.hto indicate this action value should not be used in future enhancementsChanges in V3:
- added some comments to the protocol header file
- removed the CDB emulation from xen-scsiback, handled by core target infrastructure
- several changes in xen-scsifront after comments from Christoph Hellwig
Quoted 5 lines
Changes in V2:
- use core target infrastructure by backend instead of pure SCSI passthrough
- add support for larger SG lists by putting them in grant page(s)
- add command abort capability
For the XEN scsiback parts as a new target fabric driver, feel free to add my:
So I assume this will be merged for v3.18 via the xen.git tree, yes..?
--nab
Quoted 40 lines · Nicholas A. Bellinger
Hi Juergen & Co,
Quoted 31 lines · On Mon, 2014-08-18 at 11:31 +0200, [email protected] wrote:
This series adds XEN pvSCSI support. With pvSCSI it is possible to use physical SCSI devices from a XEN domain.
The support consists of a backend in the privileged Domain-0 doing the real I/O and a frontend in the unprivileged domU passing I/O-requests to the backend.
The code is taken (and adapted) from the original pvSCSI implementation done for Linux 2.6 in 2008 by Fujitsu.
[PATCH V5 1/5] xen/events: support threaded irqs for interdomain event channels [PATCH V5 2/5] Add XEN pvSCSI protocol description
[PATCH V5 3/5] Introduce xen-scsifront module
[PATCH V5 4/5] Introduce XEN scsiback module
[PATCH V5 5/5] add xen pvscsi maintainerChanges in V5:
- Added patch to support threaded irqs for interdomain event channels
- several changes in xen-scsifront after comments from Christoph Hellwig
- several changes in xen-scsiback after comments from Christoph Hellwig
- several changes in xen-scsiback after comments from James BottomleyChanges in V4:
- Re-add define forVSCSIIF_ACT_SCSI_SG_PRESETtovscsiif.hto indicate this action value should not be used in future enhancementsChanges in V3:
- added some comments to the protocol header file
- removed the CDB emulation from xen-scsiback, handled by core target infrastructure
- several changes in xen-scsifront after comments from Christoph HellwigQuoted 5 lines
Changes in V2:
- use core target infrastructure by backend instead of pure SCSI passthrough
- add support for larger SG lists by putting them in grant page(s)
- add command abort capability
Quoted 6 lines
For the XEN scsiback parts as a new target fabric driver, feel free to add my:
Reviewed-by Nicholas Bellinger <[email protected]>So I assume this will be merged for v3.18 via the xen.git tree, yes..?
<nods>
When I chatted with Christopher Hellwig he recommended it be done that way.
I am almost done with the Xen bits.
Quoted 8 lines
--nab
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 9 lines · Konrad Rzeszutek Wilk
Quoted 8 lines · Nicholas A. Bellinger
For the XEN scsiback parts as a new target fabric driver, feel free to add my:
Reviewed-by Nicholas Bellinger <[email protected]>So I assume this will be merged for v3.18 via the xen.git tree, yes..?
My preference is for drivers outside of drivers/xen/ to be merged via their relevant subsystem tree. This is how all the other Xen PV drivers are handled (net, block, console, etc.).
Quoted 2 lines
<nods>
When I chatted with Christopher Hellwig he recommended it be done that way.
Did he give a reason? The driver has more scsi bits in it than Xen bits really.
David
Quoted 9 lines · Konrad Rzeszutek Wilk
Quoted 8 lines · Nicholas A. Bellinger
For the XEN scsiback parts as a new target fabric driver, feel free to add my:
Reviewed-by Nicholas Bellinger <[email protected]>So I assume this will be merged for v3.18 via the xen.git tree, yes..?
My preference is for drivers outside of drivers/xen/ to be merged via their relevant subsystem tree. This is how all the other Xen PV drivers are handled (net, block, console, etc.).
Quoted 2 lines
<nods>
When I chatted with Christopher Hellwig he recommended it be done that way.
Did he give a reason? The driver has more scsi bits in it than Xen bits really.
David
Quoted 5 lines · David Vrabel
Quoted 2 lines
<nods>
When I chatted with Christopher Hellwig he recommended it be done that way.Did he give a reason? The driver has more scsi bits in it than Xen bits really.
There's Xen core changes and a scsi initiator driver and a target driver both depending on the core changes. If we want to get all these in in the same merge window without pre-merging trees the Xen tree is the most sensible way to get it in. I'll hapilly take patches for the initiator driver for the following merge windows once it is in.
Quoted 5 lines · David Vrabel
Quoted 2 lines
<nods>
When I chatted with Christopher Hellwig he recommended it be done that way.Did he give a reason? The driver has more scsi bits in it than Xen bits really.
There's Xen core changes and a scsi initiator driver and a target driver both depending on the core changes. If we want to get all these in in the same merge window without pre-merging trees the Xen tree is the most sensible way to get it in. I'll hapilly take patches for the initiator driver for the following merge windows once it is in.
Quoted 40 lines · Nicholas A. Bellinger
Hi Juergen & Co,
Quoted 31 lines · On Mon, 2014-08-18 at 11:31 +0200, [email protected] wrote:
This series adds XEN pvSCSI support. With pvSCSI it is possible to use physical SCSI devices from a XEN domain.
The support consists of a backend in the privileged Domain-0 doing the real I/O and a frontend in the unprivileged domU passing I/O-requests to the backend.
The code is taken (and adapted) from the original pvSCSI implementation done for Linux 2.6 in 2008 by Fujitsu.
[PATCH V5 1/5] xen/events: support threaded irqs for interdomain event channels [PATCH V5 2/5] Add XEN pvSCSI protocol description
[PATCH V5 3/5] Introduce xen-scsifront module
[PATCH V5 4/5] Introduce XEN scsiback module
[PATCH V5 5/5] add xen pvscsi maintainerChanges in V5:
- Added patch to support threaded irqs for interdomain event channels
- several changes in xen-scsifront after comments from Christoph Hellwig
- several changes in xen-scsiback after comments from Christoph Hellwig
- several changes in xen-scsiback after comments from James BottomleyChanges in V4:
- Re-add define forVSCSIIF_ACT_SCSI_SG_PRESETtovscsiif.hto indicate this action value should not be used in future enhancementsChanges in V3:
- added some comments to the protocol header file
- removed the CDB emulation from xen-scsiback, handled by core target infrastructure
- several changes in xen-scsifront after comments from Christoph HellwigQuoted 5 lines
Changes in V2:
- use core target infrastructure by backend instead of pure SCSI passthrough
- add support for larger SG lists by putting them in grant page(s)
- add command abort capability
Quoted 6 lines
For the XEN scsiback parts as a new target fabric driver, feel free to add my:
Reviewed-by Nicholas Bellinger <[email protected]>So I assume this will be merged for v3.18 via the xen.git tree, yes..?
<nods>
When I chatted with Christopher Hellwig he recommended it be done that way.
I am almost done with the Xen bits.
Quoted 8 lines
--nab
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Hi Juergen & Co,
Quoted 31 lines · On Mon, 2014-08-18 at 11:31 +0200, [email protected] wrote:
This series adds XEN pvSCSI support. With pvSCSI it is possible to use physical SCSI devices from a XEN domain.
The support consists of a backend in the privileged Domain-0 doing the real I/O and a frontend in the unprivileged domU passing I/O-requests to the backend.
The code is taken (and adapted) from the original pvSCSI implementation done for Linux 2.6 in 2008 by Fujitsu.
[PATCH V5 1/5] xen/events: support threaded irqs for interdomain event channels [PATCH V5 2/5] Add XEN pvSCSI protocol description
[PATCH V5 3/5] Introduce xen-scsifront module
[PATCH V5 4/5] Introduce XEN scsiback module
[PATCH V5 5/5] add xen pvscsi maintainerChanges in V5:
- Added patch to support threaded irqs for interdomain event channels
- several changes in xen-scsifront after comments from Christoph Hellwig
- several changes in xen-scsiback after comments from Christoph Hellwig
- several changes in xen-scsiback after comments from James BottomleyChanges in V4:
- Re-add define forVSCSIIF_ACT_SCSI_SG_PRESETtovscsiif.hto indicate this action value should not be used in future enhancementsChanges in V3:
- added some comments to the protocol header file
- removed the CDB emulation from xen-scsiback, handled by core target infrastructure
- several changes in xen-scsifront after comments from Christoph Hellwig
Quoted 5 lines
Changes in V2:
- use core target infrastructure by backend instead of pure SCSI passthrough
- add support for larger SG lists by putting them in grant page(s)
- add command abort capability
For the XEN scsiback parts as a new target fabric driver, feel free to add my:
So I assume this will be merged for v3.18 via the xen.git tree, yes..?
--nab