All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sagi Grimberg <sagig@dev.mellanox.co.il>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: michaelc@cs.wisc.edu, nab@linux-iscsi.org, roland@kernel.org,
	linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	linux-rdma@vger.kernel.org
Subject: Re: [PATCH v1 1/3] scsi_cmnd: Introduce scsi_transfer_length helper
Date: Tue, 10 Jun 2014 22:16:45 +0300	[thread overview]
Message-ID: <5397599D.5060009@dev.mellanox.co.il> (raw)
In-Reply-To: <yq1fvjcvb8f.fsf@sermon.lab.mkp.net>

On 6/10/2014 10:02 PM, Martin K. Petersen wrote:
>>>>>> "Sagi" == Sagi Grimberg <sagig@mellanox.com> 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;
> }
>

No problem,

I'll send out v2 tomorrow (your tonight...)

Thanks,
Sagi.

  reply	other threads:[~2014-06-10 19:16 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
2014-06-10 19:16       ` Sagi Grimberg [this message]
     [not found]       ` <yq1fvjcvb8f.fsf-+q57XtR/GgMb6DWv4sQWN6xOck334EZe@public.gmane.org>
2014-06-10 20:19         ` Or Gerlitz
2014-06-10 20:21           ` Martin K. Petersen
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
     [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

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=5397599D.5060009@dev.mellanox.co.il \
    --to=sagig@dev.mellanox.co.il \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=michaelc@cs.wisc.edu \
    --cc=nab@linux-iscsi.org \
    --cc=roland@kernel.org \
    --cc=target-devel@vger.kernel.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.