Re: [PATCH] ibmvfc: fix little endian issues

2014-07-07 Thread Brian King
On 06/26/2014 07:03 PM, Tyrel Datwyler wrote:
> Added big endian annotations to relevant data structure fields, and necessary
> byte swappings to support little endian builds.

Acked-by: Brian King 

Thanks,

Brian

-- 
Brian King
Power Linux I/O
IBM Linux Technology Center


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ibmvfc: fix little endian issues

2014-07-07 Thread Brian King
On 06/26/2014 07:03 PM, Tyrel Datwyler wrote:
 Added big endian annotations to relevant data structure fields, and necessary
 byte swappings to support little endian builds.

Acked-by: Brian King brk...@linux.vnet.ibm.com

Thanks,

Brian

-- 
Brian King
Power Linux I/O
IBM Linux Technology Center


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ibmvfc: fix little endian issues

2014-06-26 Thread Tyrel Datwyler
Added big endian annotations to relevant data structure fields, and necessary
byte swappings to support little endian builds.

Signed-off-by: Brian King 
Signed-off-by: Tyrel Datwyler 
---
 drivers/scsi/ibmvscsi/ibmvfc.c | 473 +
 drivers/scsi/ibmvscsi/ibmvfc.h | 268 +++
 2 files changed, 374 insertions(+), 367 deletions(-)

diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 8dd4768..aaee066 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -166,13 +166,13 @@ static void ibmvfc_trc_start(struct ibmvfc_event *evt)
switch (entry->fmt) {
case IBMVFC_CMD_FORMAT:
entry->op_code = vfc_cmd->iu.cdb[0];
-   entry->scsi_id = vfc_cmd->tgt_scsi_id;
+   entry->scsi_id = be64_to_cpu(vfc_cmd->tgt_scsi_id);
entry->lun = scsilun_to_int(_cmd->iu.lun);
entry->tmf_flags = vfc_cmd->iu.tmf_flags;
-   entry->u.start.xfer_len = vfc_cmd->iu.xfer_len;
+   entry->u.start.xfer_len = be32_to_cpu(vfc_cmd->iu.xfer_len);
break;
case IBMVFC_MAD_FORMAT:
-   entry->op_code = mad->opcode;
+   entry->op_code = be32_to_cpu(mad->opcode);
break;
default:
break;
@@ -199,18 +199,18 @@ static void ibmvfc_trc_end(struct ibmvfc_event *evt)
switch (entry->fmt) {
case IBMVFC_CMD_FORMAT:
entry->op_code = vfc_cmd->iu.cdb[0];
-   entry->scsi_id = vfc_cmd->tgt_scsi_id;
+   entry->scsi_id = be64_to_cpu(vfc_cmd->tgt_scsi_id);
entry->lun = scsilun_to_int(_cmd->iu.lun);
entry->tmf_flags = vfc_cmd->iu.tmf_flags;
-   entry->u.end.status = vfc_cmd->status;
-   entry->u.end.error = vfc_cmd->error;
+   entry->u.end.status = be16_to_cpu(vfc_cmd->status);
+   entry->u.end.error = be16_to_cpu(vfc_cmd->error);
entry->u.end.fcp_rsp_flags = vfc_cmd->rsp.flags;
entry->u.end.rsp_code = vfc_cmd->rsp.data.info.rsp_code;
entry->u.end.scsi_status = vfc_cmd->rsp.scsi_status;
break;
case IBMVFC_MAD_FORMAT:
-   entry->op_code = mad->opcode;
-   entry->u.end.status = mad->status;
+   entry->op_code = be32_to_cpu(mad->opcode);
+   entry->u.end.status = be16_to_cpu(mad->status);
break;
default:
break;
@@ -270,14 +270,14 @@ static int ibmvfc_get_err_result(struct ibmvfc_cmd 
*vfc_cmd)
 {
int err;
struct ibmvfc_fcp_rsp *rsp = _cmd->rsp;
-   int fc_rsp_len = rsp->fcp_rsp_len;
+   int fc_rsp_len = be32_to_cpu(rsp->fcp_rsp_len);
 
if ((rsp->flags & FCP_RSP_LEN_VALID) &&
((fc_rsp_len && fc_rsp_len != 4 && fc_rsp_len != 8) ||
 rsp->data.info.rsp_code))
return DID_ERROR << 16;
 
-   err = ibmvfc_get_err_index(vfc_cmd->status, vfc_cmd->error);
+   err = ibmvfc_get_err_index(be16_to_cpu(vfc_cmd->status), 
be16_to_cpu(vfc_cmd->error));
if (err >= 0)
return rsp->scsi_status | (cmd_status[err].result << 16);
return rsp->scsi_status | (DID_ERROR << 16);
@@ -807,7 +807,7 @@ static void ibmvfc_fail_request(struct ibmvfc_event *evt, 
int error_code)
evt->cmnd->result = (error_code << 16);
evt->done = ibmvfc_scsi_eh_done;
} else
-   evt->xfer_iu->mad_common.status = IBMVFC_MAD_DRIVER_FAILED;
+   evt->xfer_iu->mad_common.status = 
cpu_to_be16(IBMVFC_MAD_DRIVER_FAILED);
 
list_del(>queue);
del_timer(>timer);
@@ -955,7 +955,7 @@ static void ibmvfc_get_host_speed(struct Scsi_Host *shost)
 
spin_lock_irqsave(shost->host_lock, flags);
if (vhost->state == IBMVFC_ACTIVE) {
-   switch (vhost->login_buf->resp.link_speed / 100) {
+   switch (be64_to_cpu(vhost->login_buf->resp.link_speed) / 100) {
case 1:
fc_host_speed(shost) = FC_PORTSPEED_1GBIT;
break;
@@ -976,7 +976,7 @@ static void ibmvfc_get_host_speed(struct Scsi_Host *shost)
break;
default:
ibmvfc_log(vhost, 3, "Unknown port speed: %lld Gbit\n",
-  vhost->login_buf->resp.link_speed / 100);
+  
be64_to_cpu(vhost->login_buf->resp.link_speed) / 100);
fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
break;
}
@@ -1171,21 +1171,21 @@ static void ibmvfc_set_login_info(struct ibmvfc_host 
*vhost)
 
memset(login_info, 0, sizeof(*login_info));
 
-   login_info->ostype = IBMVFC_OS_LINUX;
-   login_info->max_dma_len = IBMVFC_MAX_SECTORS << 9;
-   

[PATCH] ibmvfc: fix little endian issues

2014-06-26 Thread Tyrel Datwyler
Added big endian annotations to relevant data structure fields, and necessary
byte swappings to support little endian builds.

Signed-off-by: Brian King brk...@linux.vnet.ibm.com
Signed-off-by: Tyrel Datwyler tyr...@linux.vnet.ibm.com
---
 drivers/scsi/ibmvscsi/ibmvfc.c | 473 +
 drivers/scsi/ibmvscsi/ibmvfc.h | 268 +++
 2 files changed, 374 insertions(+), 367 deletions(-)

diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 8dd4768..aaee066 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -166,13 +166,13 @@ static void ibmvfc_trc_start(struct ibmvfc_event *evt)
switch (entry-fmt) {
case IBMVFC_CMD_FORMAT:
entry-op_code = vfc_cmd-iu.cdb[0];
-   entry-scsi_id = vfc_cmd-tgt_scsi_id;
+   entry-scsi_id = be64_to_cpu(vfc_cmd-tgt_scsi_id);
entry-lun = scsilun_to_int(vfc_cmd-iu.lun);
entry-tmf_flags = vfc_cmd-iu.tmf_flags;
-   entry-u.start.xfer_len = vfc_cmd-iu.xfer_len;
+   entry-u.start.xfer_len = be32_to_cpu(vfc_cmd-iu.xfer_len);
break;
case IBMVFC_MAD_FORMAT:
-   entry-op_code = mad-opcode;
+   entry-op_code = be32_to_cpu(mad-opcode);
break;
default:
break;
@@ -199,18 +199,18 @@ static void ibmvfc_trc_end(struct ibmvfc_event *evt)
switch (entry-fmt) {
case IBMVFC_CMD_FORMAT:
entry-op_code = vfc_cmd-iu.cdb[0];
-   entry-scsi_id = vfc_cmd-tgt_scsi_id;
+   entry-scsi_id = be64_to_cpu(vfc_cmd-tgt_scsi_id);
entry-lun = scsilun_to_int(vfc_cmd-iu.lun);
entry-tmf_flags = vfc_cmd-iu.tmf_flags;
-   entry-u.end.status = vfc_cmd-status;
-   entry-u.end.error = vfc_cmd-error;
+   entry-u.end.status = be16_to_cpu(vfc_cmd-status);
+   entry-u.end.error = be16_to_cpu(vfc_cmd-error);
entry-u.end.fcp_rsp_flags = vfc_cmd-rsp.flags;
entry-u.end.rsp_code = vfc_cmd-rsp.data.info.rsp_code;
entry-u.end.scsi_status = vfc_cmd-rsp.scsi_status;
break;
case IBMVFC_MAD_FORMAT:
-   entry-op_code = mad-opcode;
-   entry-u.end.status = mad-status;
+   entry-op_code = be32_to_cpu(mad-opcode);
+   entry-u.end.status = be16_to_cpu(mad-status);
break;
default:
break;
@@ -270,14 +270,14 @@ static int ibmvfc_get_err_result(struct ibmvfc_cmd 
*vfc_cmd)
 {
int err;
struct ibmvfc_fcp_rsp *rsp = vfc_cmd-rsp;
-   int fc_rsp_len = rsp-fcp_rsp_len;
+   int fc_rsp_len = be32_to_cpu(rsp-fcp_rsp_len);
 
if ((rsp-flags  FCP_RSP_LEN_VALID) 
((fc_rsp_len  fc_rsp_len != 4  fc_rsp_len != 8) ||
 rsp-data.info.rsp_code))
return DID_ERROR  16;
 
-   err = ibmvfc_get_err_index(vfc_cmd-status, vfc_cmd-error);
+   err = ibmvfc_get_err_index(be16_to_cpu(vfc_cmd-status), 
be16_to_cpu(vfc_cmd-error));
if (err = 0)
return rsp-scsi_status | (cmd_status[err].result  16);
return rsp-scsi_status | (DID_ERROR  16);
@@ -807,7 +807,7 @@ static void ibmvfc_fail_request(struct ibmvfc_event *evt, 
int error_code)
evt-cmnd-result = (error_code  16);
evt-done = ibmvfc_scsi_eh_done;
} else
-   evt-xfer_iu-mad_common.status = IBMVFC_MAD_DRIVER_FAILED;
+   evt-xfer_iu-mad_common.status = 
cpu_to_be16(IBMVFC_MAD_DRIVER_FAILED);
 
list_del(evt-queue);
del_timer(evt-timer);
@@ -955,7 +955,7 @@ static void ibmvfc_get_host_speed(struct Scsi_Host *shost)
 
spin_lock_irqsave(shost-host_lock, flags);
if (vhost-state == IBMVFC_ACTIVE) {
-   switch (vhost-login_buf-resp.link_speed / 100) {
+   switch (be64_to_cpu(vhost-login_buf-resp.link_speed) / 100) {
case 1:
fc_host_speed(shost) = FC_PORTSPEED_1GBIT;
break;
@@ -976,7 +976,7 @@ static void ibmvfc_get_host_speed(struct Scsi_Host *shost)
break;
default:
ibmvfc_log(vhost, 3, Unknown port speed: %lld Gbit\n,
-  vhost-login_buf-resp.link_speed / 100);
+  
be64_to_cpu(vhost-login_buf-resp.link_speed) / 100);
fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
break;
}
@@ -1171,21 +1171,21 @@ static void ibmvfc_set_login_info(struct ibmvfc_host 
*vhost)
 
memset(login_info, 0, sizeof(*login_info));
 
-   login_info-ostype = IBMVFC_OS_LINUX;
-   login_info-max_dma_len = IBMVFC_MAX_SECTORS  9;
-   login_info-max_payload = sizeof(struct