Skip to content

Commit

Permalink
[SCSI] csiostor: Fix sparse warnings.
Browse files Browse the repository at this point in the history
This patch fixes sparse warnings related to endian-ness, which were
reported by the 0-day kernel build and testing tool.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Naresh Kumar Inna <naresh@chelsio.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
  • Loading branch information
Naresh Kumar Inna authored and James Bottomley committed Nov 30, 2012
1 parent 68d91cb commit 5036f0a
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 128 deletions.
34 changes: 17 additions & 17 deletions drivers/scsi/csiostor/csio_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ csio_reg_rnode(struct csio_rnode *rn)
spin_unlock_irq(shost->host_lock);

sp = &rn->rn_sparm;
rport->maxframe_size = sp->csp.sp_bb_data;
rport->maxframe_size = ntohs(sp->csp.sp_bb_data);
if (ntohs(sp->clsp[2].cp_class) & FC_CPC_VALID)
rport->supported_classes = FC_COS_CLASS3;
else
Expand Down Expand Up @@ -192,7 +192,7 @@ csio_fchost_attr_init(struct csio_lnode *ln)
fc_host_supported_speeds(shost) = FC_PORTSPEED_10GBIT |
FC_PORTSPEED_1GBIT;

fc_host_maxframe_size(shost) = ln->ln_sparm.csp.sp_bb_data;
fc_host_maxframe_size(shost) = ntohs(ln->ln_sparm.csp.sp_bb_data);
memset(fc_host_supported_fc4s(shost), 0,
sizeof(fc_host_supported_fc4s(shost)));
fc_host_supported_fc4s(shost)[7] = 1;
Expand Down Expand Up @@ -325,23 +325,23 @@ csio_get_stats(struct Scsi_Host *shost)
memset(&fcoe_port_stats, 0, sizeof(struct fw_fcoe_port_stats));
csio_get_phy_port_stats(hw, ln->portid, &fcoe_port_stats);

fhs->tx_frames += (fcoe_port_stats.tx_bcast_frames +
fcoe_port_stats.tx_mcast_frames +
fcoe_port_stats.tx_ucast_frames +
fcoe_port_stats.tx_offload_frames);
fhs->tx_words += (fcoe_port_stats.tx_bcast_bytes +
fcoe_port_stats.tx_mcast_bytes +
fcoe_port_stats.tx_ucast_bytes +
fcoe_port_stats.tx_offload_bytes) /
fhs->tx_frames += (be64_to_cpu(fcoe_port_stats.tx_bcast_frames) +
be64_to_cpu(fcoe_port_stats.tx_mcast_frames) +
be64_to_cpu(fcoe_port_stats.tx_ucast_frames) +
be64_to_cpu(fcoe_port_stats.tx_offload_frames));
fhs->tx_words += (be64_to_cpu(fcoe_port_stats.tx_bcast_bytes) +
be64_to_cpu(fcoe_port_stats.tx_mcast_bytes) +
be64_to_cpu(fcoe_port_stats.tx_ucast_bytes) +
be64_to_cpu(fcoe_port_stats.tx_offload_bytes)) /
CSIO_WORD_TO_BYTE;
fhs->rx_frames += (fcoe_port_stats.rx_bcast_frames +
fcoe_port_stats.rx_mcast_frames +
fcoe_port_stats.rx_ucast_frames);
fhs->rx_words += (fcoe_port_stats.rx_bcast_bytes +
fcoe_port_stats.rx_mcast_bytes +
fcoe_port_stats.rx_ucast_bytes) /
fhs->rx_frames += (be64_to_cpu(fcoe_port_stats.rx_bcast_frames) +
be64_to_cpu(fcoe_port_stats.rx_mcast_frames) +
be64_to_cpu(fcoe_port_stats.rx_ucast_frames));
fhs->rx_words += (be64_to_cpu(fcoe_port_stats.rx_bcast_bytes) +
be64_to_cpu(fcoe_port_stats.rx_mcast_bytes) +
be64_to_cpu(fcoe_port_stats.rx_ucast_bytes)) /
CSIO_WORD_TO_BYTE;
fhs->error_frames += fcoe_port_stats.rx_err_frames;
fhs->error_frames += be64_to_cpu(fcoe_port_stats.rx_err_frames);
fhs->fcp_input_requests += ln->stats.n_input_requests;
fhs->fcp_output_requests += ln->stats.n_output_requests;
fhs->fcp_control_requests += ln->stats.n_control_requests;
Expand Down
14 changes: 7 additions & 7 deletions drivers/scsi/csiostor/csio_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ csio_set_reg_field(struct csio_hw *hw, uint32_t reg, uint32_t mask,
* is assigned the 64-bit ECC word for the read data.
*/
int
csio_hw_mc_read(struct csio_hw *hw, uint32_t addr, uint32_t *data,
csio_hw_mc_read(struct csio_hw *hw, uint32_t addr, __be32 *data,
uint64_t *ecc)
{
int i;
Expand Down Expand Up @@ -209,7 +209,7 @@ csio_hw_mc_read(struct csio_hw *hw, uint32_t addr, uint32_t *data,
* is assigned the 64-bit ECC word for the read data.
*/
int
csio_hw_edc_read(struct csio_hw *hw, int idx, uint32_t addr, uint32_t *data,
csio_hw_edc_read(struct csio_hw *hw, int idx, uint32_t addr, __be32 *data,
uint64_t *ecc)
{
int i;
Expand Down Expand Up @@ -249,7 +249,7 @@ csio_hw_edc_read(struct csio_hw *hw, int idx, uint32_t addr, uint32_t *data,
* address @addr.
*/
static int
csio_mem_win_rw(struct csio_hw *hw, u32 addr, __be32 *data, int dir)
csio_mem_win_rw(struct csio_hw *hw, u32 addr, u32 *data, int dir)
{
int i;

Expand Down Expand Up @@ -296,7 +296,7 @@ csio_memory_rw(struct csio_hw *hw, int mtype, u32 addr, u32 len,
{
uint32_t pos, start, end, offset, memoffset;
int ret;
__be32 *data;
uint32_t *data;

/*
* Argument sanity checks ...
Expand Down Expand Up @@ -379,7 +379,7 @@ csio_memory_rw(struct csio_hw *hw, int mtype, u32 addr, u32 len,
}

static int
csio_memory_write(struct csio_hw *hw, int mtype, u32 addr, u32 len, __be32 *buf)
csio_memory_write(struct csio_hw *hw, int mtype, u32 addr, u32 len, u32 *buf)
{
return csio_memory_rw(hw, mtype, addr, len, buf, 0);
}
Expand Down Expand Up @@ -429,6 +429,7 @@ csio_hw_seeprom_read(struct csio_hw *hw, uint32_t addr, uint32_t *data)

pci_read_config_dword(hw->pdev, base + PCI_VPD_DATA, data);
*data = le32_to_cpu(*data);

return 0;
}

Expand Down Expand Up @@ -926,7 +927,7 @@ csio_hw_fw_dload(struct csio_hw *hw, uint8_t *fw_data, uint32_t size)
int ret;
uint32_t i;
uint8_t first_page[SF_PAGE_SIZE];
const uint32_t *p = (const uint32_t *)fw_data;
const __be32 *p = (const __be32 *)fw_data;
struct fw_hdr *hdr = (struct fw_hdr *)fw_data;
uint32_t sf_sec_size;

Expand Down Expand Up @@ -2116,7 +2117,6 @@ csio_hw_flash_config(struct csio_hw *hw, u32 *fw_cfg_param, char *path)
const struct firmware *cf;
struct pci_dev *pci_dev = hw->pdev;
struct device *dev = &pci_dev->dev;

unsigned int mtype = 0, maddr = 0;
uint32_t *cfg_data;
int value_to_add = 0;
Expand Down
6 changes: 2 additions & 4 deletions drivers/scsi/csiostor/csio_hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -658,10 +658,8 @@ void csio_intr_disable(struct csio_hw *, bool);
struct csio_lnode *csio_lnode_alloc(struct csio_hw *);
int csio_config_queues(struct csio_hw *);

int csio_hw_mc_read(struct csio_hw *, uint32_t,
uint32_t *, uint64_t *);
int csio_hw_edc_read(struct csio_hw *, int, uint32_t, uint32_t *,
uint64_t *);
int csio_hw_mc_read(struct csio_hw *, uint32_t, __be32 *, uint64_t *);
int csio_hw_edc_read(struct csio_hw *, int, uint32_t, __be32 *, uint64_t *);
int csio_hw_init(struct csio_hw *);
void csio_hw_exit(struct csio_hw *);
#endif /* ifndef __CSIO_HW_H__ */
91 changes: 47 additions & 44 deletions drivers/scsi/csiostor/csio_lnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ csio_fill_ct_iu(void *buf, uint8_t type, uint8_t sub_type, uint16_t op)
cmd->ct_rev = FC_CT_REV;
cmd->ct_fs_type = type;
cmd->ct_fs_subtype = sub_type;
cmd->ct_cmd = op;
cmd->ct_cmd = htons(op);
}

static int
Expand Down Expand Up @@ -285,11 +285,13 @@ csio_ln_fdmi_rhba_cbfn(struct csio_hw *hw, struct csio_ioreq *fdmi_req)
void *cmd;
uint8_t *pld;
uint32_t len = 0;
__be32 val;
__be16 mfs;
uint32_t numattrs = 0;
struct csio_lnode *ln = fdmi_req->lnode;
struct fs_fdmi_attrs *attrib_blk;
struct fc_fdmi_port_name *port_name;
uint8_t buf[64];
uint32_t val;
uint8_t *fc4_type;

if (fdmi_req->wr_status != FW_SUCCESS) {
Expand All @@ -311,7 +313,7 @@ csio_ln_fdmi_rhba_cbfn(struct csio_hw *hw, struct csio_ioreq *fdmi_req)

/* Prepare CT hdr for RPA cmd */
memset(cmd, 0, FC_CT_HDR_LEN);
csio_fill_ct_iu(cmd, FC_FST_MGMT, FC_FDMI_SUBTYPE, htons(FC_FDMI_RPA));
csio_fill_ct_iu(cmd, FC_FST_MGMT, FC_FDMI_SUBTYPE, FC_FDMI_RPA);

/* Prepare RPA payload */
pld = (uint8_t *)csio_ct_get_pld(cmd);
Expand All @@ -331,12 +333,12 @@ csio_ln_fdmi_rhba_cbfn(struct csio_hw *hw, struct csio_ioreq *fdmi_req)
fc4_type[7] = 1;
csio_append_attrib(&pld, FC_FDMI_PORT_ATTR_FC4TYPES,
fc4_type, FC_FDMI_PORT_ATTR_FC4TYPES_LEN);
attrib_blk->numattrs++;
numattrs++;
val = htonl(FC_PORTSPEED_1GBIT | FC_PORTSPEED_10GBIT);
csio_append_attrib(&pld, FC_FDMI_PORT_ATTR_SUPPORTEDSPEED,
(uint8_t *)&val,
FC_FDMI_PORT_ATTR_SUPPORTEDSPEED_LEN);
attrib_blk->numattrs++;
numattrs++;

if (hw->pport[ln->portid].link_speed == FW_PORT_CAP_SPEED_1G)
val = htonl(FC_PORTSPEED_1GBIT);
Expand All @@ -347,24 +349,24 @@ csio_ln_fdmi_rhba_cbfn(struct csio_hw *hw, struct csio_ioreq *fdmi_req)
csio_append_attrib(&pld, FC_FDMI_PORT_ATTR_CURRENTPORTSPEED,
(uint8_t *)&val,
FC_FDMI_PORT_ATTR_CURRENTPORTSPEED_LEN);
attrib_blk->numattrs++;
numattrs++;

val = htonl(ln->ln_sparm.csp.sp_bb_data);
mfs = ln->ln_sparm.csp.sp_bb_data;
csio_append_attrib(&pld, FC_FDMI_PORT_ATTR_MAXFRAMESIZE,
(uint8_t *)&val, FC_FDMI_PORT_ATTR_MAXFRAMESIZE_LEN);
attrib_blk->numattrs++;
(uint8_t *)&mfs, FC_FDMI_PORT_ATTR_MAXFRAMESIZE_LEN);
numattrs++;

strcpy(buf, "csiostor");
csio_append_attrib(&pld, FC_FDMI_PORT_ATTR_OSDEVICENAME, buf,
(uint16_t)strlen(buf));
attrib_blk->numattrs++;
numattrs++;

if (!csio_hostname(buf, sizeof(buf))) {
csio_append_attrib(&pld, FC_FDMI_PORT_ATTR_HOSTNAME,
buf, (uint16_t)strlen(buf));
attrib_blk->numattrs++;
numattrs++;
}
attrib_blk->numattrs = ntohl(attrib_blk->numattrs);
attrib_blk->numattrs = htonl(numattrs);
len = (uint32_t)(pld - (uint8_t *)cmd);

/* Submit FDMI RPA request */
Expand All @@ -388,7 +390,8 @@ csio_ln_fdmi_dprt_cbfn(struct csio_hw *hw, struct csio_ioreq *fdmi_req)
void *cmd;
uint8_t *pld;
uint32_t len = 0;
uint32_t maxpayload = htonl(65536);
uint32_t numattrs = 0;
__be32 maxpayload = htonl(65536);
struct fc_fdmi_hba_identifier *hbaid;
struct csio_lnode *ln = fdmi_req->lnode;
struct fc_fdmi_rpl *reg_pl;
Expand All @@ -413,7 +416,7 @@ csio_ln_fdmi_dprt_cbfn(struct csio_hw *hw, struct csio_ioreq *fdmi_req)

/* Prepare CT hdr for RHBA cmd */
memset(cmd, 0, FC_CT_HDR_LEN);
csio_fill_ct_iu(cmd, FC_FST_MGMT, FC_FDMI_SUBTYPE, htons(FC_FDMI_RHBA));
csio_fill_ct_iu(cmd, FC_FST_MGMT, FC_FDMI_SUBTYPE, FC_FDMI_RHBA);
len = FC_CT_HDR_LEN;

/* Prepare RHBA payload */
Expand All @@ -424,7 +427,7 @@ csio_ln_fdmi_dprt_cbfn(struct csio_hw *hw, struct csio_ioreq *fdmi_req)

/* Register one port per hba */
reg_pl = (struct fc_fdmi_rpl *)pld;
reg_pl->numport = ntohl(1);
reg_pl->numport = htonl(1);
memcpy(&reg_pl->port[0].portname, csio_ln_wwpn(ln), 8);
pld += sizeof(*reg_pl);

Expand All @@ -436,42 +439,42 @@ csio_ln_fdmi_dprt_cbfn(struct csio_hw *hw, struct csio_ioreq *fdmi_req)

csio_append_attrib(&pld, FC_FDMI_HBA_ATTR_NODENAME, csio_ln_wwnn(ln),
FC_FDMI_HBA_ATTR_NODENAME_LEN);
attrib_blk->numattrs++;
numattrs++;

memset(buf, 0, sizeof(buf));

strcpy(buf, "Chelsio Communications");
csio_append_attrib(&pld, FC_FDMI_HBA_ATTR_MANUFACTURER, buf,
(uint16_t)strlen(buf));
attrib_blk->numattrs++;
numattrs++;
csio_append_attrib(&pld, FC_FDMI_HBA_ATTR_SERIALNUMBER,
hw->vpd.sn, (uint16_t)sizeof(hw->vpd.sn));
attrib_blk->numattrs++;
numattrs++;
csio_append_attrib(&pld, FC_FDMI_HBA_ATTR_MODEL, hw->vpd.id,
(uint16_t)sizeof(hw->vpd.id));
attrib_blk->numattrs++;
numattrs++;
csio_append_attrib(&pld, FC_FDMI_HBA_ATTR_MODELDESCRIPTION,
hw->model_desc, (uint16_t)strlen(hw->model_desc));
attrib_blk->numattrs++;
numattrs++;
csio_append_attrib(&pld, FC_FDMI_HBA_ATTR_HARDWAREVERSION,
hw->hw_ver, (uint16_t)sizeof(hw->hw_ver));
attrib_blk->numattrs++;
numattrs++;
csio_append_attrib(&pld, FC_FDMI_HBA_ATTR_FIRMWAREVERSION,
hw->fwrev_str, (uint16_t)strlen(hw->fwrev_str));
attrib_blk->numattrs++;
numattrs++;

if (!csio_osname(buf, sizeof(buf))) {
csio_append_attrib(&pld, FC_FDMI_HBA_ATTR_OSNAMEVERSION,
buf, (uint16_t)strlen(buf));
attrib_blk->numattrs++;
numattrs++;
}

csio_append_attrib(&pld, FC_FDMI_HBA_ATTR_MAXCTPAYLOAD,
(uint8_t *)&maxpayload,
FC_FDMI_HBA_ATTR_MAXCTPAYLOAD_LEN);
len = (uint32_t)(pld - (uint8_t *)cmd);
attrib_blk->numattrs++;
attrib_blk->numattrs = ntohl(attrib_blk->numattrs);
numattrs++;
attrib_blk->numattrs = htonl(numattrs);

/* Submit FDMI RHBA request */
spin_lock_irq(&hw->lock);
Expand Down Expand Up @@ -518,7 +521,7 @@ csio_ln_fdmi_dhba_cbfn(struct csio_hw *hw, struct csio_ioreq *fdmi_req)

/* Prepare FDMI DPRT cmd */
memset(cmd, 0, FC_CT_HDR_LEN);
csio_fill_ct_iu(cmd, FC_FST_MGMT, FC_FDMI_SUBTYPE, htons(FC_FDMI_DPRT));
csio_fill_ct_iu(cmd, FC_FST_MGMT, FC_FDMI_SUBTYPE, FC_FDMI_DPRT);
len = FC_CT_HDR_LEN;
port_name = (struct fc_fdmi_port_name *)csio_ct_get_pld(cmd);
memcpy(&port_name->portname, csio_ln_wwpn(ln), 8);
Expand Down Expand Up @@ -567,7 +570,7 @@ csio_ln_fdmi_start(struct csio_lnode *ln, void *context)
/* Prepare FDMI DHBA cmd */
cmd = fdmi_req->dma_buf.vaddr;
memset(cmd, 0, FC_CT_HDR_LEN);
csio_fill_ct_iu(cmd, FC_FST_MGMT, FC_FDMI_SUBTYPE, htons(FC_FDMI_DHBA));
csio_fill_ct_iu(cmd, FC_FST_MGMT, FC_FDMI_SUBTYPE, FC_FDMI_DHBA);
len = FC_CT_HDR_LEN;

hbaid = (struct fc_fdmi_hba_identifier *)csio_ct_get_pld(cmd);
Expand Down Expand Up @@ -599,6 +602,7 @@ csio_ln_vnp_read_cbfn(struct csio_hw *hw, struct csio_mb *mbp)
struct fc_els_csp *csp;
struct fc_els_cssp *clsp;
enum fw_retval retval;
__be32 nport_id;

retval = FW_CMD_RETVAL_GET(ntohl(rsp->alloc_to_len16));
if (retval != FW_SUCCESS) {
Expand All @@ -610,10 +614,9 @@ csio_ln_vnp_read_cbfn(struct csio_hw *hw, struct csio_mb *mbp)
spin_lock_irq(&hw->lock);

memcpy(ln->mac, rsp->vnport_mac, sizeof(ln->mac));
memcpy(&ln->nport_id, &rsp->vnport_mac[3],
sizeof(uint8_t)*3);
ln->nport_id = ntohl(ln->nport_id);
ln->nport_id = ln->nport_id>>8;
memcpy(&nport_id, &rsp->vnport_mac[3], sizeof(uint8_t)*3);
ln->nport_id = ntohl(nport_id);
ln->nport_id = ln->nport_id >> 8;

/* Update WWNs */
/*
Expand All @@ -628,18 +631,18 @@ csio_ln_vnp_read_cbfn(struct csio_hw *hw, struct csio_mb *mbp)
csp = (struct fc_els_csp *)rsp->cmn_srv_parms;
ln->ln_sparm.csp.sp_hi_ver = csp->sp_hi_ver;
ln->ln_sparm.csp.sp_lo_ver = csp->sp_lo_ver;
ln->ln_sparm.csp.sp_bb_cred = ntohs(csp->sp_bb_cred);
ln->ln_sparm.csp.sp_features = ntohs(csp->sp_features);
ln->ln_sparm.csp.sp_bb_data = ntohs(csp->sp_bb_data);
ln->ln_sparm.csp.sp_r_a_tov = ntohl(csp->sp_r_a_tov);
ln->ln_sparm.csp.sp_e_d_tov = ntohl(csp->sp_e_d_tov);
ln->ln_sparm.csp.sp_bb_cred = csp->sp_bb_cred;
ln->ln_sparm.csp.sp_features = csp->sp_features;
ln->ln_sparm.csp.sp_bb_data = csp->sp_bb_data;
ln->ln_sparm.csp.sp_r_a_tov = csp->sp_r_a_tov;
ln->ln_sparm.csp.sp_e_d_tov = csp->sp_e_d_tov;

/* Copy word 0 & word 1 of class sparam */
clsp = (struct fc_els_cssp *)rsp->clsp_word_0_1;
ln->ln_sparm.clsp[2].cp_class = ntohs(clsp->cp_class);
ln->ln_sparm.clsp[2].cp_init = ntohs(clsp->cp_init);
ln->ln_sparm.clsp[2].cp_recip = ntohs(clsp->cp_recip);
ln->ln_sparm.clsp[2].cp_rdfs = ntohs(clsp->cp_rdfs);
ln->ln_sparm.clsp[2].cp_class = clsp->cp_class;
ln->ln_sparm.clsp[2].cp_init = clsp->cp_init;
ln->ln_sparm.clsp[2].cp_recip = clsp->cp_recip;
ln->ln_sparm.clsp[2].cp_rdfs = clsp->cp_rdfs;

spin_unlock_irq(&hw->lock);

Expand Down Expand Up @@ -1499,7 +1502,7 @@ csio_fcoe_fwevt_handler(struct csio_hw *hw, __u8 cpl_op, __be64 *cmd)
/* HW un lock here */
} else {
csio_warn(hw, "Unexpected FCOE LINK status:0x%x\n",
ntohl(lcmd->lstatus));
lcmd->lstatus);
CSIO_INC_STATS(hw, n_cpl_unexp);
}
} else if (cpl_op == CPL_FW6_PLD) {
Expand Down Expand Up @@ -1663,7 +1666,7 @@ csio_ln_prep_ecwr(struct csio_ioreq *io_req, uint32_t wr_len,
uint32_t did, uint32_t flow_id, uint8_t *fw_wr)
{
struct fw_fcoe_els_ct_wr *wr;
uint32_t port_id;
__be32 port_id;

wr = (struct fw_fcoe_els_ct_wr *)fw_wr;
wr->op_immdlen = cpu_to_be32(FW_WR_OP(FW_FCOE_ELS_CT_WR) |
Expand All @@ -1676,8 +1679,8 @@ csio_ln_prep_ecwr(struct csio_ioreq *io_req, uint32_t wr_len,
wr->ctl_pri = 0;
wr->cp_en_class = 0;
wr->cookie = io_req->fw_handle;
wr->iqid = (uint16_t)cpu_to_be16(csio_q_physiqid(
io_req->lnode->hwp, io_req->iq_idx));
wr->iqid = cpu_to_be16(csio_q_physiqid(
io_req->lnode->hwp, io_req->iq_idx));
wr->fl_to_sp = FW_FCOE_ELS_CT_WR_SP(1);
wr->tmo_val = (uint8_t) io_req->tmo;
port_id = htonl(sid);
Expand Down
Loading

0 comments on commit 5036f0a

Please sign in to comment.