public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v4 0/3] bsg: add io_uring command support for SCSI passthrough
@ 2026-01-22  1:56 Yang Xiuwei
  2026-01-22  1:56 ` [RFC PATCH v4 1/3] bsg: add bsg_uring_cmd uapi structure Yang Xiuwei
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yang Xiuwei @ 2026-01-22  1:56 UTC (permalink / raw)
  To: linux-scsi, linux-block, io-uring
  Cc: fujita.tomonori, axboe, James.Bottomley, martin.petersen,
	bvanassche, Yang Xiuwei

Hi all,

This RFC series adds io_uring command support to the BSG (Block layer
SCSI Generic) driver, enabling asynchronous SCSI passthrough operations
with zero-copy support via fixed buffers.

The implementation follows the io_uring uring_cmd pattern used by other
drivers (e.g., nvme). A new bsg_uring_cmd structure fits within the 80-byte
cmd field of a 128-byte SQE, with 8 bytes reserved for future extensions.
The structure uses protocol-agnostic field names and follows the sg_io_v4
design with separate din_xferp/dout_xferp fields. SCSI status information
is returned in the CQE res2 field using a compact 64-bit encoding.

Currently only BSG_SUB_PROTOCOL_SCSI_CMD is implemented. Scatter/gather
I/O and bidirectional transfers are not yet supported.

The implementation has been tested with a user-space test program covering
basic SCSI commands (INQUIRY, READ CAPACITY, READ, WRITE), zero-copy mode,
and error handling.

The v4 implementation uses a callback function pointer pattern to maintain
independence of the generic BSG layer from specific protocol implementations,
avoiding build-time dependencies on SCSI-specific code.

Previous versions:
- v1: https://lore.kernel.org/all/20260112084606.570887-1-yangxiuwei@kylinos.cn/
- v3: https://lore.kernel.org/r/cover.1768536312.git.yangxiuwei@kylinos.cn

Changes since v1:
-----------------
- Protocol-agnostic field names (request/request_len instead of cdb_addr/cdb_len)
- Removed __packed attribute for better code generation

Why v2 was superseded:
----------------------
v2 unified din_xferp/dout_xferp into a single xfer_addr field, which
diverged from the established sg_io_v4 interface. v3 reverts to separate
din_xferp/dout_xferp fields to maintain consistency with the existing
BSG interface.

Changes since v3:
- Fixed undefined symbol error by using callback function pointer pattern
  instead of direct function calls
- Removed protocol-specific validation from generic layer (moved to
  scsi_bsg_uring_cmd)


Yang Xiuwei (3):
  bsg: add bsg_uring_cmd uapi structure
  bsg: add uring_cmd support to BSG generic layer
  bsg: implement SCSI BSG uring_cmd handler

 block/bsg-lib.c          |   2 +-
 block/bsg.c              |  35 ++++++-
 drivers/scsi/scsi_bsg.c  | 210 ++++++++++++++++++++++++++++++++++++++-
 include/linux/bsg.h      |   6 +-
 include/uapi/linux/bsg.h |  21 ++++
 5 files changed, 270 insertions(+), 4 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-22  1:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-22  1:56 [RFC PATCH v4 0/3] bsg: add io_uring command support for SCSI passthrough Yang Xiuwei
2026-01-22  1:56 ` [RFC PATCH v4 1/3] bsg: add bsg_uring_cmd uapi structure Yang Xiuwei
2026-01-22  1:56 ` [RFC PATCH v4 2/3] bsg: add uring_cmd support to BSG generic layer Yang Xiuwei
2026-01-22  1:56 ` [RFC PATCH v4 3/3] bsg: implement SCSI BSG uring_cmd handler Yang Xiuwei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox