Skip to contentSkip to conversation

endian question about struct srp_direct_buf

DISCUSSION Dan Carpenter 2 participants 2 messages Jan 12, 2012 1 message not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

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 [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 18 lines · Dan Carpenter

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;
Quoted 1 line

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 [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html