public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* endian question about struct srp_direct_buf
@ 2012-01-12 11:41 Dan Carpenter
       [not found] ` <20120112114122.GA29021-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2012-01-12 11:41 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA

Sparse complains because len in struct srp_direct_buf is declared as
big endian but it's used throughout as CPU endian.  struct
srp_indirect_buf has the same thing.  It's declared one way but used the
other way.

$ grep -w len drivers/scsi -R | grep -w md
drivers/scsi/ibmvscsi/ibmvfc.c:         md[i].len = sg_dma_len(sg);
drivers/scsi/ibmvscsi/ibmvstgt.c:               mlen = min(rest, md[i].len);
drivers/scsi/libsrp.c:                  md->len, scsi_sg_count(sc));
drivers/scsi/libsrp.c:          len = min(scsi_bufflen(sc), md->len);
drivers/scsi/libsrp.c:          len = md->len;
drivers/scsi/libsrp.c:  err = rdma_io(sc, sg, nsg, md, 1, dir, len);
drivers/scsi/libsrp.c:          md = dma_alloc_coherent(iue->target->dev, id->table_desc.len,
drivers/scsi/libsrp.c:          sg_init_one(&dummy, md, id->table_desc.len);
drivers/scsi/libsrp.c:  err = rdma_io(sc, sg, nsg, md, nmd, dir, len);
drivers/scsi/libsrp.c:          dma_free_coherent(iue->target->dev, id->table_desc.len, md, token);
drivers/scsi/libsrp.c:          len = md->len;

Probably we should just change the declaration to u32?

regards,
dan carpenter
--
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

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

* Re: endian question about struct srp_direct_buf
       [not found] ` <20120112114122.GA29021-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
@ 2012-01-12 11:52   ` Bart Van Assche
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Van Assche @ 2012-01-12 11:52 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

On Thu, Jan 12, 2012 at 12:41 PM, Dan Carpenter
<dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> wrote:
> Sparse complains because len in struct srp_direct_buf is declared as
> big endian but it's used throughout as CPU endian.  struct
> srp_indirect_buf has the same thing.  It's declared one way but used the
> other way.
>
> $ grep -w len drivers/scsi -R | grep -w md
> drivers/scsi/ibmvscsi/ibmvfc.c:         md[i].len = sg_dma_len(sg);
> drivers/scsi/ibmvscsi/ibmvstgt.c:               mlen = min(rest, md[i].len);
> drivers/scsi/libsrp.c:                  md->len, scsi_sg_count(sc));
> drivers/scsi/libsrp.c:          len = min(scsi_bufflen(sc), md->len);
> drivers/scsi/libsrp.c:          len = md->len;
> drivers/scsi/libsrp.c:  err = rdma_io(sc, sg, nsg, md, 1, dir, len);
> drivers/scsi/libsrp.c:          md = dma_alloc_coherent(iue->target->dev, id->table_desc.len,
> drivers/scsi/libsrp.c:          sg_init_one(&dummy, md, id->table_desc.len);
> drivers/scsi/libsrp.c:  err = rdma_io(sc, sg, nsg, md, nmd, dir, len);
> drivers/scsi/libsrp.c:          dma_free_coherent(iue->target->dev, id->table_desc.len, md, token);
> drivers/scsi/libsrp.c:          len = md->len;
>
> Probably we should just change the declaration to u32?

(resending as plain text)

No. The SRP spec says that that field is big endian and the ib_srp
driver uses that field as a big endian field. The output above (libsrp
+ ibmvstgt) is code that is used by the ibmvstgt driver only, and the
reason that driver works fine without endianness conversion is because
it is only used on PowerPC systems.

Bart.
--
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

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

end of thread, other threads:[~2012-01-12 11:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-12 11:41 endian question about struct srp_direct_buf Dan Carpenter
     [not found] ` <20120112114122.GA29021-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
2012-01-12 11:52   ` Bart Van Assche

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