From: "Martin K. Petersen" <martin.petersen-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: Sagi Grimberg <sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: michaelc-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org,
martin.petersen-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org,
nab-IzHhD5pYlfBP7FQvKIMDCQ@public.gmane.org,
roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
target-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v1 1/3] scsi_cmnd: Introduce scsi_transfer_length helper
Date: Tue, 10 Jun 2014 15:02:56 -0400 [thread overview]
Message-ID: <yq1fvjcvb8f.fsf@sermon.lab.mkp.net> (raw)
In-Reply-To: <1402223228-23768-2-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org> (Sagi Grimberg's message of "Sun, 8 Jun 2014 13:27:06 +0300")
>>>>> "Sagi" == Sagi Grimberg <sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org> writes:
+static inline unsigned scsi_prot_length(unsigned data_length,
+ unsigned sector_size)
+{
+ switch (sector_size) {
+ case 512:
+ return (data_length >> 9) * 8;
+ case 1024:
+ return (data_length >> 10) * 8;
+ case 2048:
+ return (data_length >> 11) * 8;
+ case 4096:
+ return (data_length >> 12) * 8;
+ default:
+ return (data_length >> ilog2(sector_size)) * 8;
+ }
+}
+
+static inline unsigned scsi_transfer_length(struct scsi_cmnd *cmd)
+{
+ unsigned data_length;
+
+ if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
+ data_length = scsi_in(cmd)->length;
+ if (scsi_get_prot_op(cmd) == SCSI_PROT_NORMAL ||
+ scsi_get_prot_op(cmd) == SCSI_PROT_READ_INSERT)
+ return data_length;
+ } else {
+ data_length = scsi_out(cmd)->length;
+ if (scsi_get_prot_op(cmd) == SCSI_PROT_NORMAL ||
+ scsi_get_prot_op(cmd) == SCSI_PROT_WRITE_STRIP)
+ return data_length;
+ }
+
+ /* Protection information exists on the wire */
+ return data_length + scsi_prot_length(data_length,
+ cmd->device->sector_size);
+}
Let's do this for 3.16:
static inline unsigned int scsi_transfer_length(struct scsi_cmnd *scmd)
{
unsigned int xfer_len = blk_rq_bytes(scmd->request);
unsigned int prot_op = scsi_get_prot_op(scmd);
switch (prot_op) {
case SCSI_PROT_NORMAL:
case SCSI_PROT_WRITE_STRIP:
case SCSI_PROT_READ_INSERT:
return xfer_len;
}
return xfer_len + (xfer_len >> ilog2(sector_size)) * 8;
}
And then in 3.17 we'll have:
static inline unsigned int scsi_transfer_length(struct scsi_cmnd *scmd)
{
unsigned int xfer_len = blk_rq_bytes(scmd->request);
if (scsi_prot_flagged(SCSI_PROT_TRANSFER_PI))
xfer_len += (xfer_len >> ilog2(scsi_prot_interval(scmd))) * 8;
return xfer_len;
}
--
Martin K. Petersen Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-06-10 19:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-08 10:27 [PATCH v1 0/3] Include protection information in iscsi header Sagi Grimberg
2014-06-08 10:27 ` [PATCH v1 1/3] scsi_cmnd: Introduce scsi_transfer_length helper Sagi Grimberg
[not found] ` <1402223228-23768-2-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-06-10 19:02 ` Martin K. Petersen [this message]
2014-06-10 19:16 ` Sagi Grimberg
[not found] ` <yq1fvjcvb8f.fsf-+q57XtR/GgMb6DWv4sQWN6xOck334EZe@public.gmane.org>
2014-06-10 20:19 ` Or Gerlitz
2014-06-10 20:21 ` Martin K. Petersen
[not found] ` <1402223228-23768-1-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-06-08 10:27 ` [PATCH v1 2/3] libiscsi, iser: Adjust data_length to include protection information Sagi Grimberg
2014-06-10 18:19 ` Mike Christie
2014-06-10 8:10 ` [PATCH v1 0/3] Include protection information in iscsi header Nicholas A. Bellinger
2014-06-08 10:27 ` [PATCH v1 3/3] TARGET/sbc,loopback: Adjust command data length in case pi exists on the wire Sagi Grimberg
2014-06-10 8:04 ` Nicholas A. Bellinger
2014-06-10 8:12 ` Paolo Bonzini
2014-06-10 21:17 ` Quinn Tran
2014-06-11 7:24 ` Sagi Grimberg
2014-06-11 21:30 ` Nicholas A. Bellinger
2014-06-11 22:32 ` Quinn Tran
[not found] ` <504EB66DAC8D234EB8E8560985C2D7AD46D1D8C7-vcA9p2Eq0686wu3ARrlbmA@public.gmane.org>
2014-06-12 4:01 ` Nicholas A. Bellinger
[not found] ` <1402522215.17740.29.camel-XoQW25Eq2zviZyQQd+hFbcojREIfoBdhmpATvIKMPHk@public.gmane.org>
2014-06-11 23:20 ` Martin K. Petersen
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=yq1fvjcvb8f.fsf@sermon.lab.mkp.net \
--to=martin.petersen-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=michaelc-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org \
--cc=nab-IzHhD5pYlfBP7FQvKIMDCQ@public.gmane.org \
--cc=roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=target-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.