public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Yang Xiuwei <yangxiuwei@kylinos.cn>,
	axboe@kernel.dk, fujita.tomonori@lab.ntt.co.jp,
	James.Bottomley@HansenPartnership.com,
	martin.petersen@oracle.com
Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [PATCH v7 1/3] bsg: add bsg_uring_cmd uapi structure
Date: Thu, 12 Mar 2026 12:29:48 -0700	[thread overview]
Message-ID: <574620fd-903b-4fd3-8cbb-22a3cefda645@acm.org> (raw)
In-Reply-To: <20260312092237.2464560-2-yangxiuwei@kylinos.cn>

On 3/12/26 2:22 AM, Yang Xiuwei wrote:
> +struct bsg_uring_cmd {
> +	__u64 request;		/* [i], [*i] command descriptor address */
> +	__u32 request_len;	/* [i] command descriptor length in bytes */
> +	__u32 protocol;		/* [i] protocol type (BSG_PROTOCOL_*) */
> +	__u32 subprotocol;	/* [i] subprotocol type (BSG_SUB_PROTOCOL_*) */
> +	__u32 max_response_len;	/* [i] response buffer size in bytes */
> +
> +	__u64 response;		/* [i], [*o] response data address */
> +	__u64 dout_xferp;	/* [i], [*i] */
> +	__u32 dout_xfer_len;	/* [i] bytes to be transferred to device */
> +	__u32 dout_iovec_count;	/* [i] 0 -> "flat" dout transfer else
> +				 * dout_xferp points to array of iovec
> +				 */
> +	__u64 din_xferp;	/* [i], [*o] */
> +	__u32 din_xfer_len;	/* [i] bytes to be transferred from device */
> +	__u32 din_iovec_count;	/* [i] 0 -> "flat" din transfer */
> +
> +	__u32 timeout_ms;	/* [i] timeout in milliseconds */
> +	__u8  reserved[12];	/* reserved for future extension */
> +};

Please consider adding a static_assert() statement that verifies the
size of this data structure at compile time. Such a statement is useful
to document the size of the data structure, helps with verifying that
the size is the same on all architectures and helps with verifying that
the size doesn't change if a reserved byte is taken in use.

> +#define BSG_SCSI_RES2_DEVICE_STATUS(res2)   ((__u8)((__u64)(res2) & 0xff))
> +#define BSG_SCSI_RES2_DRIVER_STATUS(res2)   ((__u8)((__u64)(res2) >> 8))
> +#define BSG_SCSI_RES2_HOST_STATUS(res2)     ((__u8)((__u64)(res2) >> 16))
> +#define BSG_SCSI_RES2_SENSE_LEN(res2)       ((__u8)((__u64)(res2) >> 24))
> +#define BSG_SCSI_RES2_RESID_LEN(res2)       ((__u32)((__u64)(res2) >> 32))
> +
> +#define BSG_SCSI_RES2_BUILD(device_status, driver_status, host_status,   \
> +			    sense_len_wr, resid_len)			\
> +	(((__u64)(__u32)(resid_len) << 32) |				\
> +	 ((__u64)(__u8)(sense_len_wr) << 24) |				\
> +	 ((__u64)(__u8)(host_status) << 16) |				\
> +	 ((__u64)(__u8)(driver_status) << 8) |				\
> +	 ((__u64)(__u8)(device_status)))

Please convert all the above macros into inline functions because that
will result in removal of most of the typecasts. I think that inline
functions are allowed in uapi headers:

$ git grep 'static.*inline' include/uapi | wc -l
354

Thanks,

Bart.

  reply	other threads:[~2026-03-12 19:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-12  9:22 [PATCH v7 0/3] bsg: add io_uring command support for SCSI passthrough Yang Xiuwei
2026-03-12  9:22 ` [PATCH v7 1/3] bsg: add bsg_uring_cmd uapi structure Yang Xiuwei
2026-03-12 19:29   ` Bart Van Assche [this message]
2026-03-13  7:34     ` Yang Xiuwei
2026-03-13 15:34       ` Bart Van Assche
2026-03-12  9:22 ` [PATCH v7 2/3] bsg: add io_uring command support to generic layer Yang Xiuwei
2026-03-12 19:33   ` Bart Van Assche
2026-03-13  7:34     ` Yang Xiuwei
2026-03-13 15:35       ` Bart Van Assche
2026-03-12  9:22 ` [PATCH v7 3/3] scsi: bsg: add io_uring passthrough handler Yang Xiuwei
2026-03-12 19:41   ` Bart Van Assche
2026-03-13  7:34     ` Yang Xiuwei
2026-03-13 15:37       ` Bart Van Assche

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=574620fd-903b-4fd3-8cbb-22a3cefda645@acm.org \
    --to=bvanassche@acm.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=axboe@kernel.dk \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=yangxiuwei@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox