qlcnic: fix sparse check endian warnings

Signed-off-by: Shahed Shaikh <shahed.shaikh@qlogic.com>
Signed-off-by: Sony Chacko <sony.chacko@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Shahed Shaikh 2012-11-23 23:56:52 +00:00 коммит произвёл David S. Miller
Родитель 82167cb8c6
Коммит 63507592e3
6 изменённых файлов: 300 добавлений и 221 удалений

Просмотреть файл

@ -280,16 +280,16 @@ struct status_desc {
#define QLCNIC_UNI_FIRMWARE_IDX_OFF 29
struct uni_table_desc{
u32 findex;
u32 num_entries;
u32 entry_size;
u32 reserved[5];
__le32 findex;
__le32 num_entries;
__le32 entry_size;
__le32 reserved[5];
};
struct uni_data_desc{
u32 findex;
u32 size;
u32 reserved[5];
__le32 findex;
__le32 size;
__le32 reserved[5];
};
/* Flash Defines and Structures */
@ -416,19 +416,19 @@ struct qlcnic_nic_intr_coalesce {
};
struct qlcnic_dump_template_hdr {
__le32 type;
__le32 offset;
__le32 size;
__le32 cap_mask;
__le32 num_entries;
__le32 version;
__le32 timestamp;
__le32 checksum;
__le32 drv_cap_mask;
__le32 sys_info[3];
__le32 saved_state[16];
__le32 cap_sizes[8];
__le32 rsvd[0];
u32 type;
u32 offset;
u32 size;
u32 cap_mask;
u32 num_entries;
u32 version;
u32 timestamp;
u32 checksum;
u32 drv_cap_mask;
u32 sys_info[3];
u32 saved_state[16];
u32 cap_sizes[8];
u32 rsvd[0];
};
struct qlcnic_fw_dump {
@ -1065,16 +1065,16 @@ struct qlcnic_adapter {
spinlock_t tx_clean_lock;
spinlock_t mac_learn_lock;
__le32 file_prd_off; /*File fw product offset*/
u32 file_prd_off; /*File fw product offset*/
u32 fw_version;
const struct firmware *fw;
};
struct qlcnic_info {
struct qlcnic_info_le {
__le16 pci_func;
__le16 op_mode; /* 1 = Priv, 2 = NP, 3 = NP passthru */
__le16 op_mode; /* 1 = Priv, 2 = NP, 3 = NP passthru */
__le16 phys_port;
__le16 switch_mode; /* 0 = disabled, 1 = int, 2 = ext */
__le16 switch_mode; /* 0 = disabled, 1 = int, 2 = ext */
__le32 capabilities;
u8 max_mac_filters;
@ -1088,13 +1088,28 @@ struct qlcnic_info {
u8 reserved2[104];
} __packed;
struct qlcnic_pci_info {
__le16 id; /* pci function id */
__le16 active; /* 1 = Enabled */
__le16 type; /* 1 = NIC, 2 = FCoE, 3 = iSCSI */
__le16 default_port; /* default port number */
struct qlcnic_info {
u16 pci_func;
u16 op_mode;
u16 phys_port;
u16 switch_mode;
u32 capabilities;
u8 max_mac_filters;
u8 reserved1;
u16 max_mtu;
u16 max_tx_ques;
u16 max_rx_ques;
u16 min_tx_bw;
u16 max_tx_bw;
};
__le16 tx_min_bw; /* Multiple of 100mbpc */
struct qlcnic_pci_info_le {
__le16 id; /* pci function id */
__le16 active; /* 1 = Enabled */
__le16 type; /* 1 = NIC, 2 = FCoE, 3 = iSCSI */
__le16 default_port; /* default port number */
__le16 tx_min_bw; /* Multiple of 100mbpc */
__le16 tx_max_bw;
__le16 reserved1[2];
@ -1102,6 +1117,16 @@ struct qlcnic_pci_info {
u8 reserved2[106];
} __packed;
struct qlcnic_pci_info {
u16 id;
u16 active;
u16 type;
u16 default_port;
u16 tx_min_bw;
u16 tx_max_bw;
u8 mac[ETH_ALEN];
};
struct qlcnic_npar_info {
u16 pvid;
u16 min_bw;
@ -1208,7 +1233,7 @@ do { \
(VAL1) += (VAL2); \
} while (0)
struct qlcnic_mac_statistics{
struct qlcnic_mac_statistics_le {
__le64 mac_tx_frames;
__le64 mac_tx_bytes;
__le64 mac_tx_mcast_pkts;
@ -1248,7 +1273,45 @@ struct qlcnic_mac_statistics{
__le64 mac_align_error;
} __packed;
struct __qlcnic_esw_statistics {
struct qlcnic_mac_statistics {
u64 mac_tx_frames;
u64 mac_tx_bytes;
u64 mac_tx_mcast_pkts;
u64 mac_tx_bcast_pkts;
u64 mac_tx_pause_cnt;
u64 mac_tx_ctrl_pkt;
u64 mac_tx_lt_64b_pkts;
u64 mac_tx_lt_127b_pkts;
u64 mac_tx_lt_255b_pkts;
u64 mac_tx_lt_511b_pkts;
u64 mac_tx_lt_1023b_pkts;
u64 mac_tx_lt_1518b_pkts;
u64 mac_tx_gt_1518b_pkts;
u64 rsvd1[3];
u64 mac_rx_frames;
u64 mac_rx_bytes;
u64 mac_rx_mcast_pkts;
u64 mac_rx_bcast_pkts;
u64 mac_rx_pause_cnt;
u64 mac_rx_ctrl_pkt;
u64 mac_rx_lt_64b_pkts;
u64 mac_rx_lt_127b_pkts;
u64 mac_rx_lt_255b_pkts;
u64 mac_rx_lt_511b_pkts;
u64 mac_rx_lt_1023b_pkts;
u64 mac_rx_lt_1518b_pkts;
u64 mac_rx_gt_1518b_pkts;
u64 rsvd2[3];
u64 mac_rx_length_error;
u64 mac_rx_length_small;
u64 mac_rx_length_large;
u64 mac_rx_jabber;
u64 mac_rx_dropped;
u64 mac_rx_crc_error;
u64 mac_align_error;
};
struct qlcnic_esw_stats_le {
__le16 context_id;
__le16 version;
__le16 size;
@ -1263,54 +1326,69 @@ struct __qlcnic_esw_statistics {
__le64 rsvd[3];
} __packed;
struct __qlcnic_esw_statistics {
u16 context_id;
u16 version;
u16 size;
u16 unused;
u64 unicast_frames;
u64 multicast_frames;
u64 broadcast_frames;
u64 dropped_frames;
u64 errors;
u64 local_frames;
u64 numbytes;
u64 rsvd[3];
};
struct qlcnic_esw_statistics {
struct __qlcnic_esw_statistics rx;
struct __qlcnic_esw_statistics tx;
};
struct qlcnic_common_entry_hdr {
__le32 type;
__le32 offset;
__le32 cap_size;
u32 type;
u32 offset;
u32 cap_size;
u8 mask;
u8 rsvd[2];
u8 flags;
} __packed;
struct __crb {
__le32 addr;
u32 addr;
u8 stride;
u8 rsvd1[3];
__le32 data_size;
__le32 no_ops;
__le32 rsvd2[4];
u32 data_size;
u32 no_ops;
u32 rsvd2[4];
} __packed;
struct __ctrl {
__le32 addr;
u32 addr;
u8 stride;
u8 index_a;
__le16 timeout;
__le32 data_size;
__le32 no_ops;
u16 timeout;
u32 data_size;
u32 no_ops;
u8 opcode;
u8 index_v;
u8 shl_val;
u8 shr_val;
__le32 val1;
__le32 val2;
__le32 val3;
u32 val1;
u32 val2;
u32 val3;
} __packed;
struct __cache {
__le32 addr;
__le16 stride;
__le16 init_tag_val;
__le32 size;
__le32 no_ops;
__le32 ctrl_addr;
__le32 ctrl_val;
__le32 read_addr;
u32 addr;
u16 stride;
u16 init_tag_val;
u32 size;
u32 no_ops;
u32 ctrl_addr;
u32 ctrl_val;
u32 read_addr;
u8 read_addr_stride;
u8 read_addr_num;
u8 rsvd1[2];
@ -1318,38 +1396,38 @@ struct __cache {
struct __ocm {
u8 rsvd[8];
__le32 size;
__le32 no_ops;
u32 size;
u32 no_ops;
u8 rsvd1[8];
__le32 read_addr;
__le32 read_addr_stride;
u32 read_addr;
u32 read_addr_stride;
} __packed;
struct __mem {
u8 rsvd[24];
__le32 addr;
__le32 size;
u32 addr;
u32 size;
} __packed;
struct __mux {
__le32 addr;
u32 addr;
u8 rsvd[4];
__le32 size;
__le32 no_ops;
__le32 val;
__le32 val_stride;
__le32 read_addr;
u32 size;
u32 no_ops;
u32 val;
u32 val_stride;
u32 read_addr;
u8 rsvd2[4];
} __packed;
struct __queue {
__le32 sel_addr;
__le16 stride;
u32 sel_addr;
u16 stride;
u8 rsvd[2];
__le32 size;
__le32 no_ops;
u32 size;
u32 no_ops;
u8 rsvd2[8];
__le32 read_addr;
u32 read_addr;
u8 read_addr_stride;
u8 read_addr_cnt;
u8 rsvd3[2];
@ -1413,8 +1491,8 @@ enum op_codes {
struct qlcnic_dump_operations {
enum op_codes opcode;
u32 (*handler)(struct qlcnic_adapter *,
struct qlcnic_dump_entry *, u32 *);
u32 (*handler)(struct qlcnic_adapter *, struct qlcnic_dump_entry *,
__le32 *);
};
struct _cdrp_cmd {

Просмотреть файл

@ -103,7 +103,7 @@ qlcnic_issue_cmd(struct qlcnic_adapter *adapter, struct qlcnic_cmd_args *cmd)
}
static uint32_t qlcnic_temp_checksum(uint32_t *temp_buffer, u16 temp_size)
static uint32_t qlcnic_temp_checksum(uint32_t *temp_buffer, u32 temp_size)
{
uint64_t sum = 0;
int count = temp_size / sizeof(uint32_t);
@ -117,9 +117,9 @@ static uint32_t qlcnic_temp_checksum(uint32_t *temp_buffer, u16 temp_size)
int qlcnic_fw_cmd_get_minidump_temp(struct qlcnic_adapter *adapter)
{
int err, i;
u16 temp_size;
void *tmp_addr;
u32 version, csum, *template, *tmp_buf;
u32 temp_size, version, csum, *template;
__le32 *tmp_buf;
struct qlcnic_cmd_args cmd;
struct qlcnic_hardware_context *ahw;
struct qlcnic_dump_template_hdr *tmpl_hdr, *tmp_tmpl;
@ -163,13 +163,6 @@ int qlcnic_fw_cmd_get_minidump_temp(struct qlcnic_adapter *adapter)
goto error;
}
tmp_tmpl = tmp_addr;
csum = qlcnic_temp_checksum((uint32_t *) tmp_addr, temp_size);
if (csum) {
dev_err(&adapter->pdev->dev,
"Template header checksum validation failed\n");
err = -EIO;
goto error;
}
ahw->fw_dump.tmpl_hdr = vzalloc(temp_size);
if (!ahw->fw_dump.tmpl_hdr) {
err = -EIO;
@ -180,6 +173,14 @@ int qlcnic_fw_cmd_get_minidump_temp(struct qlcnic_adapter *adapter)
for (i = 0; i < temp_size/sizeof(u32); i++)
*template++ = __le32_to_cpu(*tmp_buf++);
csum = qlcnic_temp_checksum((u32 *)ahw->fw_dump.tmpl_hdr, temp_size);
if (csum) {
dev_err(&adapter->pdev->dev,
"Template header checksum validation failed\n");
err = -EIO;
goto error;
}
tmpl_hdr = ahw->fw_dump.tmpl_hdr;
tmpl_hdr->drv_cap_mask = QLCNIC_DUMP_MASK_DEF;
ahw->fw_dump.enable = 1;
@ -231,6 +232,7 @@ qlcnic_fw_cmd_create_rx_ctx(struct qlcnic_adapter *adapter)
size_t rq_size, rsp_size;
u32 cap, reg, val, reg2;
int err;
u16 temp;
struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx;
@ -267,8 +269,8 @@ qlcnic_fw_cmd_create_rx_ctx(struct qlcnic_adapter *adapter)
if (adapter->flags & QLCNIC_FW_LRO_MSS_CAP)
cap |= QLCNIC_CAP0_LRO_MSS;
prq->valid_field_offset = offsetof(struct qlcnic_hostrq_rx_ctx,
msix_handler);
temp = offsetof(struct qlcnic_hostrq_rx_ctx, msix_handler);
prq->valid_field_offset = cpu_to_le16(temp);
prq->txrx_sds_binding = nsds_rings - 1;
prq->capabilities[0] = cpu_to_le32(cap);
@ -687,10 +689,10 @@ int qlcnic_get_nic_info(struct qlcnic_adapter *adapter,
{
int err;
dma_addr_t nic_dma_t;
struct qlcnic_info *nic_info;
struct qlcnic_info_le *nic_info;
void *nic_info_addr;
struct qlcnic_cmd_args cmd;
size_t nic_size = sizeof(struct qlcnic_info);
size_t nic_size = sizeof(struct qlcnic_info_le);
nic_info_addr = dma_alloc_coherent(&adapter->pdev->dev, nic_size,
&nic_dma_t, GFP_KERNEL);
@ -745,8 +747,8 @@ int qlcnic_set_nic_info(struct qlcnic_adapter *adapter, struct qlcnic_info *nic)
dma_addr_t nic_dma_t;
void *nic_info_addr;
struct qlcnic_cmd_args cmd;
struct qlcnic_info *nic_info;
size_t nic_size = sizeof(struct qlcnic_info);
struct qlcnic_info_le *nic_info;
size_t nic_size = sizeof(struct qlcnic_info_le);
if (adapter->op_mode != QLCNIC_MGMT_FUNC)
return err;
@ -796,9 +798,9 @@ int qlcnic_get_pci_info(struct qlcnic_adapter *adapter,
int err = 0, i;
struct qlcnic_cmd_args cmd;
dma_addr_t pci_info_dma_t;
struct qlcnic_pci_info *npar;
struct qlcnic_pci_info_le *npar;
void *pci_info_addr;
size_t npar_size = sizeof(struct qlcnic_pci_info);
size_t npar_size = sizeof(struct qlcnic_pci_info_le);
size_t pci_size = npar_size * QLCNIC_MAX_PCI_FUNC;
pci_info_addr = dma_alloc_coherent(&adapter->pdev->dev, pci_size,
@ -877,8 +879,8 @@ int qlcnic_config_port_mirroring(struct qlcnic_adapter *adapter, u8 id,
int qlcnic_get_port_stats(struct qlcnic_adapter *adapter, const u8 func,
const u8 rx_tx, struct __qlcnic_esw_statistics *esw_stats) {
size_t stats_size = sizeof(struct __qlcnic_esw_statistics);
struct __qlcnic_esw_statistics *stats;
size_t stats_size = sizeof(struct qlcnic_esw_stats_le);
struct qlcnic_esw_stats_le *stats;
dma_addr_t stats_dma_t;
void *stats_addr;
u32 arg1;
@ -939,9 +941,9 @@ int qlcnic_get_port_stats(struct qlcnic_adapter *adapter, const u8 func,
int qlcnic_get_mac_stats(struct qlcnic_adapter *adapter,
struct qlcnic_mac_statistics *mac_stats)
{
struct qlcnic_mac_statistics *stats;
struct qlcnic_mac_statistics_le *stats;
struct qlcnic_cmd_args cmd;
size_t stats_size = sizeof(struct qlcnic_mac_statistics);
size_t stats_size = sizeof(struct qlcnic_mac_statistics_le);
dma_addr_t stats_dma_t;
void *stats_addr;
int err;

Просмотреть файл

@ -1247,7 +1247,8 @@ qlcnic_get_dump_data(struct net_device *netdev, struct ethtool_dump *dump,
void *buffer)
{
int i, copy_sz;
u32 *hdr_ptr, *data;
u32 *hdr_ptr;
__le32 *data;
struct qlcnic_adapter *adapter = netdev_priv(netdev);
struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;

Просмотреть файл

@ -1349,9 +1349,8 @@ int qlcnic_config_led(struct qlcnic_adapter *adapter, u32 state, u32 rate)
}
/* FW dump related functions */
static u32
qlcnic_dump_crb(struct qlcnic_adapter *adapter, struct qlcnic_dump_entry *entry,
u32 *buffer)
static u32 qlcnic_dump_crb(struct qlcnic_adapter *adapter,
struct qlcnic_dump_entry *entry, __le32 *buffer)
{
int i;
u32 addr, data;
@ -1369,9 +1368,8 @@ qlcnic_dump_crb(struct qlcnic_adapter *adapter, struct qlcnic_dump_entry *entry,
return crb->no_ops * 2 * sizeof(u32);
}
static u32
qlcnic_dump_ctrl(struct qlcnic_adapter *adapter,
struct qlcnic_dump_entry *entry, u32 *buffer)
static u32 qlcnic_dump_ctrl(struct qlcnic_adapter *adapter,
struct qlcnic_dump_entry *entry, __le32 *buffer)
{
int i, k, timeout = 0;
void __iomem *base = adapter->ahw->pci_base0;
@ -1457,9 +1455,8 @@ qlcnic_dump_ctrl(struct qlcnic_adapter *adapter,
return 0;
}
static u32
qlcnic_dump_mux(struct qlcnic_adapter *adapter, struct qlcnic_dump_entry *entry,
u32 *buffer)
static u32 qlcnic_dump_mux(struct qlcnic_adapter *adapter,
struct qlcnic_dump_entry *entry, __le32 *buffer)
{
int loop;
u32 val, data = 0;
@ -1477,9 +1474,8 @@ qlcnic_dump_mux(struct qlcnic_adapter *adapter, struct qlcnic_dump_entry *entry,
return 2 * mux->no_ops * sizeof(u32);
}
static u32
qlcnic_dump_que(struct qlcnic_adapter *adapter, struct qlcnic_dump_entry *entry,
u32 *buffer)
static u32 qlcnic_dump_que(struct qlcnic_adapter *adapter,
struct qlcnic_dump_entry *entry, __le32 *buffer)
{
int i, loop;
u32 cnt, addr, data, que_id = 0;
@ -1502,9 +1498,8 @@ qlcnic_dump_que(struct qlcnic_adapter *adapter, struct qlcnic_dump_entry *entry,
return que->no_ops * cnt * sizeof(u32);
}
static u32
qlcnic_dump_ocm(struct qlcnic_adapter *adapter, struct qlcnic_dump_entry *entry,
u32 *buffer)
static u32 qlcnic_dump_ocm(struct qlcnic_adapter *adapter,
struct qlcnic_dump_entry *entry, __le32 *buffer)
{
int i;
u32 data;
@ -1520,9 +1515,8 @@ qlcnic_dump_ocm(struct qlcnic_adapter *adapter, struct qlcnic_dump_entry *entry,
return ocm->no_ops * sizeof(u32);
}
static u32
qlcnic_read_rom(struct qlcnic_adapter *adapter, struct qlcnic_dump_entry *entry,
u32 *buffer)
static u32 qlcnic_read_rom(struct qlcnic_adapter *adapter,
struct qlcnic_dump_entry *entry, __le32 *buffer)
{
int i, count = 0;
u32 fl_addr, size, val, lck_val, addr;
@ -1551,9 +1545,8 @@ lock_try:
return rom->size;
}
static u32
qlcnic_dump_l1_cache(struct qlcnic_adapter *adapter,
struct qlcnic_dump_entry *entry, u32 *buffer)
static u32 qlcnic_dump_l1_cache(struct qlcnic_adapter *adapter,
struct qlcnic_dump_entry *entry, __le32 *buffer)
{
int i;
u32 cnt, val, data, addr;
@ -1578,9 +1571,8 @@ qlcnic_dump_l1_cache(struct qlcnic_adapter *adapter,
return l1->no_ops * l1->read_addr_num * sizeof(u32);
}
static u32
qlcnic_dump_l2_cache(struct qlcnic_adapter *adapter,
struct qlcnic_dump_entry *entry, u32 *buffer)
static u32 qlcnic_dump_l2_cache(struct qlcnic_adapter *adapter,
struct qlcnic_dump_entry *entry, __le32 *buffer)
{
int i;
u32 cnt, val, data, addr;
@ -1627,9 +1619,8 @@ skip_poll:
return l2->no_ops * l2->read_addr_num * sizeof(u32);
}
static u32
qlcnic_read_memory(struct qlcnic_adapter *adapter,
struct qlcnic_dump_entry *entry, u32 *buffer)
static u32 qlcnic_read_memory(struct qlcnic_adapter *adapter,
struct qlcnic_dump_entry *entry, __le32 *buffer)
{
u32 addr, data, test, ret = 0;
int i, reg_read;
@ -1681,9 +1672,8 @@ out:
return mem->size;
}
static u32
qlcnic_dump_nop(struct qlcnic_adapter *adapter,
struct qlcnic_dump_entry *entry, u32 *buffer)
static u32 qlcnic_dump_nop(struct qlcnic_adapter *adapter,
struct qlcnic_dump_entry *entry, __le32 *buffer)
{
entry->hdr.flags |= QLCNIC_DUMP_SKIP;
return 0;
@ -1730,7 +1720,7 @@ qlcnic_valid_dump_entry(struct device *dev, struct qlcnic_dump_entry *entry,
int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
{
u32 *buffer;
__le32 *buffer;
char mesg[64];
char *msg[] = {mesg, NULL};
int i, k, ops_cnt, ops_index, dump_size = 0;

Просмотреть файл

@ -778,15 +778,15 @@ qlcnic_has_mn(struct qlcnic_adapter *adapter)
static
struct uni_table_desc *qlcnic_get_table_desc(const u8 *unirom, int section)
{
u32 i;
u32 i, entries;
struct uni_table_desc *directory = (struct uni_table_desc *) &unirom[0];
__le32 entries = cpu_to_le32(directory->num_entries);
entries = le32_to_cpu(directory->num_entries);
for (i = 0; i < entries; i++) {
__le32 offs = cpu_to_le32(directory->findex) +
(i * cpu_to_le32(directory->entry_size));
__le32 tab_type = cpu_to_le32(*((u32 *)&unirom[offs] + 8));
u32 offs = le32_to_cpu(directory->findex) +
i * le32_to_cpu(directory->entry_size);
u32 tab_type = le32_to_cpu(*((__le32 *)&unirom[offs] + 8));
if (tab_type == section)
return (struct uni_table_desc *) &unirom[offs];
@ -802,17 +802,16 @@ qlcnic_validate_header(struct qlcnic_adapter *adapter)
{
const u8 *unirom = adapter->fw->data;
struct uni_table_desc *directory = (struct uni_table_desc *) &unirom[0];
__le32 fw_file_size = adapter->fw->size;
__le32 entries;
__le32 entry_size;
__le32 tab_size;
u32 entries, entry_size, tab_size, fw_file_size;
fw_file_size = adapter->fw->size;
if (fw_file_size < FILEHEADER_SIZE)
return -EINVAL;
entries = cpu_to_le32(directory->num_entries);
entry_size = cpu_to_le32(directory->entry_size);
tab_size = cpu_to_le32(directory->findex) + (entries * entry_size);
entries = le32_to_cpu(directory->num_entries);
entry_size = le32_to_cpu(directory->entry_size);
tab_size = le32_to_cpu(directory->findex) + (entries * entry_size);
if (fw_file_size < tab_size)
return -EINVAL;
@ -825,29 +824,29 @@ qlcnic_validate_bootld(struct qlcnic_adapter *adapter)
{
struct uni_table_desc *tab_desc;
struct uni_data_desc *descr;
u32 offs, tab_size, data_size, idx;
const u8 *unirom = adapter->fw->data;
int idx = cpu_to_le32(*((int *)&unirom[adapter->file_prd_off] +
QLCNIC_UNI_BOOTLD_IDX_OFF));
__le32 offs;
__le32 tab_size;
__le32 data_size;
__le32 temp;
temp = *((__le32 *)&unirom[adapter->file_prd_off] +
QLCNIC_UNI_BOOTLD_IDX_OFF);
idx = le32_to_cpu(temp);
tab_desc = qlcnic_get_table_desc(unirom, QLCNIC_UNI_DIR_SECT_BOOTLD);
if (!tab_desc)
return -EINVAL;
tab_size = cpu_to_le32(tab_desc->findex) +
(cpu_to_le32(tab_desc->entry_size) * (idx + 1));
tab_size = le32_to_cpu(tab_desc->findex) +
le32_to_cpu(tab_desc->entry_size) * (idx + 1);
if (adapter->fw->size < tab_size)
return -EINVAL;
offs = cpu_to_le32(tab_desc->findex) +
(cpu_to_le32(tab_desc->entry_size) * (idx));
offs = le32_to_cpu(tab_desc->findex) +
le32_to_cpu(tab_desc->entry_size) * idx;
descr = (struct uni_data_desc *)&unirom[offs];
data_size = cpu_to_le32(descr->findex) + cpu_to_le32(descr->size);
data_size = le32_to_cpu(descr->findex) + le32_to_cpu(descr->size);
if (adapter->fw->size < data_size)
return -EINVAL;
@ -861,27 +860,27 @@ qlcnic_validate_fw(struct qlcnic_adapter *adapter)
struct uni_table_desc *tab_desc;
struct uni_data_desc *descr;
const u8 *unirom = adapter->fw->data;
int idx = cpu_to_le32(*((int *)&unirom[adapter->file_prd_off] +
QLCNIC_UNI_FIRMWARE_IDX_OFF));
__le32 offs;
__le32 tab_size;
__le32 data_size;
u32 offs, tab_size, data_size, idx;
__le32 temp;
temp = *((__le32 *)&unirom[adapter->file_prd_off] +
QLCNIC_UNI_FIRMWARE_IDX_OFF);
idx = le32_to_cpu(temp);
tab_desc = qlcnic_get_table_desc(unirom, QLCNIC_UNI_DIR_SECT_FW);
if (!tab_desc)
return -EINVAL;
tab_size = cpu_to_le32(tab_desc->findex) +
(cpu_to_le32(tab_desc->entry_size) * (idx + 1));
tab_size = le32_to_cpu(tab_desc->findex) +
le32_to_cpu(tab_desc->entry_size) * (idx + 1);
if (adapter->fw->size < tab_size)
return -EINVAL;
offs = cpu_to_le32(tab_desc->findex) +
(cpu_to_le32(tab_desc->entry_size) * (idx));
offs = le32_to_cpu(tab_desc->findex) +
le32_to_cpu(tab_desc->entry_size) * idx;
descr = (struct uni_data_desc *)&unirom[offs];
data_size = cpu_to_le32(descr->findex) + cpu_to_le32(descr->size);
data_size = le32_to_cpu(descr->findex) + le32_to_cpu(descr->size);
if (adapter->fw->size < data_size)
return -EINVAL;
@ -895,19 +894,17 @@ qlcnic_validate_product_offs(struct qlcnic_adapter *adapter)
struct uni_table_desc *ptab_descr;
const u8 *unirom = adapter->fw->data;
int mn_present = qlcnic_has_mn(adapter);
__le32 entries;
__le32 entry_size;
__le32 tab_size;
u32 i;
u32 entries, entry_size, tab_size, i;
__le32 temp;
ptab_descr = qlcnic_get_table_desc(unirom,
QLCNIC_UNI_DIR_SECT_PRODUCT_TBL);
if (!ptab_descr)
return -EINVAL;
entries = cpu_to_le32(ptab_descr->num_entries);
entry_size = cpu_to_le32(ptab_descr->entry_size);
tab_size = cpu_to_le32(ptab_descr->findex) + (entries * entry_size);
entries = le32_to_cpu(ptab_descr->num_entries);
entry_size = le32_to_cpu(ptab_descr->entry_size);
tab_size = le32_to_cpu(ptab_descr->findex) + (entries * entry_size);
if (adapter->fw->size < tab_size)
return -EINVAL;
@ -915,16 +912,16 @@ qlcnic_validate_product_offs(struct qlcnic_adapter *adapter)
nomn:
for (i = 0; i < entries; i++) {
__le32 flags, file_chiprev, offs;
u32 flags, file_chiprev, offs;
u8 chiprev = adapter->ahw->revision_id;
u32 flagbit;
offs = cpu_to_le32(ptab_descr->findex) +
(i * cpu_to_le32(ptab_descr->entry_size));
flags = cpu_to_le32(*((int *)&unirom[offs] +
QLCNIC_UNI_FLAGS_OFF));
file_chiprev = cpu_to_le32(*((int *)&unirom[offs] +
QLCNIC_UNI_CHIP_REV_OFF));
offs = le32_to_cpu(ptab_descr->findex) +
i * le32_to_cpu(ptab_descr->entry_size);
temp = *((__le32 *)&unirom[offs] + QLCNIC_UNI_FLAGS_OFF);
flags = le32_to_cpu(temp);
temp = *((__le32 *)&unirom[offs] + QLCNIC_UNI_CHIP_REV_OFF);
file_chiprev = le32_to_cpu(temp);
flagbit = mn_present ? 1 : 2;
@ -976,18 +973,20 @@ struct uni_data_desc *qlcnic_get_data_desc(struct qlcnic_adapter *adapter,
u32 section, u32 idx_offset)
{
const u8 *unirom = adapter->fw->data;
int idx = cpu_to_le32(*((int *)&unirom[adapter->file_prd_off] +
idx_offset));
struct uni_table_desc *tab_desc;
__le32 offs;
u32 offs, idx;
__le32 temp;
temp = *((__le32 *)&unirom[adapter->file_prd_off] + idx_offset);
idx = le32_to_cpu(temp);
tab_desc = qlcnic_get_table_desc(unirom, section);
if (tab_desc == NULL)
return NULL;
offs = cpu_to_le32(tab_desc->findex) +
(cpu_to_le32(tab_desc->entry_size) * idx);
offs = le32_to_cpu(tab_desc->findex) +
le32_to_cpu(tab_desc->entry_size) * idx;
return (struct uni_data_desc *)&unirom[offs];
}
@ -996,11 +995,13 @@ static u8 *
qlcnic_get_bootld_offs(struct qlcnic_adapter *adapter)
{
u32 offs = QLCNIC_BOOTLD_START;
struct uni_data_desc *data_desc;
data_desc = qlcnic_get_data_desc(adapter, QLCNIC_UNI_DIR_SECT_BOOTLD,
QLCNIC_UNI_BOOTLD_IDX_OFF);
if (adapter->fw_type == QLCNIC_UNIFIED_ROMIMAGE)
offs = cpu_to_le32((qlcnic_get_data_desc(adapter,
QLCNIC_UNI_DIR_SECT_BOOTLD,
QLCNIC_UNI_BOOTLD_IDX_OFF))->findex);
offs = le32_to_cpu(data_desc->findex);
return (u8 *)&adapter->fw->data[offs];
}
@ -1009,43 +1010,48 @@ static u8 *
qlcnic_get_fw_offs(struct qlcnic_adapter *adapter)
{
u32 offs = QLCNIC_IMAGE_START;
struct uni_data_desc *data_desc;
data_desc = qlcnic_get_data_desc(adapter, QLCNIC_UNI_DIR_SECT_FW,
QLCNIC_UNI_FIRMWARE_IDX_OFF);
if (adapter->fw_type == QLCNIC_UNIFIED_ROMIMAGE)
offs = cpu_to_le32((qlcnic_get_data_desc(adapter,
QLCNIC_UNI_DIR_SECT_FW,
QLCNIC_UNI_FIRMWARE_IDX_OFF))->findex);
offs = le32_to_cpu(data_desc->findex);
return (u8 *)&adapter->fw->data[offs];
}
static __le32
qlcnic_get_fw_size(struct qlcnic_adapter *adapter)
static u32 qlcnic_get_fw_size(struct qlcnic_adapter *adapter)
{
struct uni_data_desc *data_desc;
const u8 *unirom = adapter->fw->data;
data_desc = qlcnic_get_data_desc(adapter, QLCNIC_UNI_DIR_SECT_FW,
QLCNIC_UNI_FIRMWARE_IDX_OFF);
if (adapter->fw_type == QLCNIC_UNIFIED_ROMIMAGE)
return cpu_to_le32((qlcnic_get_data_desc(adapter,
QLCNIC_UNI_DIR_SECT_FW,
QLCNIC_UNI_FIRMWARE_IDX_OFF))->size);
return le32_to_cpu(data_desc->size);
else
return cpu_to_le32(
*(u32 *)&adapter->fw->data[QLCNIC_FW_SIZE_OFFSET]);
return le32_to_cpu(*(__le32 *)&unirom[QLCNIC_FW_SIZE_OFFSET]);
}
static __le32
qlcnic_get_fw_version(struct qlcnic_adapter *adapter)
static u32 qlcnic_get_fw_version(struct qlcnic_adapter *adapter)
{
struct uni_data_desc *fw_data_desc;
const struct firmware *fw = adapter->fw;
__le32 major, minor, sub;
u32 major, minor, sub;
__le32 version_offset;
const u8 *ver_str;
int i, ret;
if (adapter->fw_type != QLCNIC_UNIFIED_ROMIMAGE)
return cpu_to_le32(*(u32 *)&fw->data[QLCNIC_FW_VERSION_OFFSET]);
if (adapter->fw_type != QLCNIC_UNIFIED_ROMIMAGE) {
version_offset = *(__le32 *)&fw->data[QLCNIC_FW_VERSION_OFFSET];
return le32_to_cpu(version_offset);
}
fw_data_desc = qlcnic_get_data_desc(adapter, QLCNIC_UNI_DIR_SECT_FW,
QLCNIC_UNI_FIRMWARE_IDX_OFF);
ver_str = fw->data + cpu_to_le32(fw_data_desc->findex) +
cpu_to_le32(fw_data_desc->size) - 17;
ver_str = fw->data + le32_to_cpu(fw_data_desc->findex) +
le32_to_cpu(fw_data_desc->size) - 17;
for (i = 0; i < 12; i++) {
if (!strncmp(&ver_str[i], "REV=", 4)) {
@ -1061,18 +1067,20 @@ qlcnic_get_fw_version(struct qlcnic_adapter *adapter)
return 0;
}
static __le32
qlcnic_get_bios_version(struct qlcnic_adapter *adapter)
static u32 qlcnic_get_bios_version(struct qlcnic_adapter *adapter)
{
const struct firmware *fw = adapter->fw;
__le32 bios_ver, prd_off = adapter->file_prd_off;
u32 bios_ver, prd_off = adapter->file_prd_off;
u8 *version_offset;
__le32 temp;
if (adapter->fw_type != QLCNIC_UNIFIED_ROMIMAGE)
return cpu_to_le32(
*(u32 *)&fw->data[QLCNIC_BIOS_VERSION_OFFSET]);
if (adapter->fw_type != QLCNIC_UNIFIED_ROMIMAGE) {
version_offset = (u8 *)&fw->data[QLCNIC_BIOS_VERSION_OFFSET];
return le32_to_cpu(*(__le32 *)version_offset);
}
bios_ver = cpu_to_le32(*((u32 *) (&fw->data[prd_off])
+ QLCNIC_UNI_BIOS_VERSION_OFF));
temp = *((__le32 *)(&fw->data[prd_off]) + QLCNIC_UNI_BIOS_VERSION_OFF);
bios_ver = le32_to_cpu(temp);
return (bios_ver << 16) + ((bios_ver >> 8) & 0xff00) + (bios_ver >> 24);
}
@ -1131,7 +1139,7 @@ static const char *fw_name[] = {
int
qlcnic_load_firmware(struct qlcnic_adapter *adapter)
{
u64 *ptr64;
__le64 *ptr64;
u32 i, flashaddr, size;
const struct firmware *fw = adapter->fw;
struct pci_dev *pdev = adapter->pdev;
@ -1140,15 +1148,15 @@ qlcnic_load_firmware(struct qlcnic_adapter *adapter)
fw_name[adapter->fw_type]);
if (fw) {
__le64 data;
u64 data;
size = (QLCNIC_IMAGE_START - QLCNIC_BOOTLD_START) / 8;
ptr64 = (u64 *)qlcnic_get_bootld_offs(adapter);
ptr64 = (__le64 *)qlcnic_get_bootld_offs(adapter);
flashaddr = QLCNIC_BOOTLD_START;
for (i = 0; i < size; i++) {
data = cpu_to_le64(ptr64[i]);
data = le64_to_cpu(ptr64[i]);
if (qlcnic_pci_mem_write_2M(adapter, flashaddr, data))
return -EIO;
@ -1156,13 +1164,13 @@ qlcnic_load_firmware(struct qlcnic_adapter *adapter)
flashaddr += 8;
}
size = (__force u32)qlcnic_get_fw_size(adapter) / 8;
size = qlcnic_get_fw_size(adapter) / 8;
ptr64 = (u64 *)qlcnic_get_fw_offs(adapter);
ptr64 = (__le64 *)qlcnic_get_fw_offs(adapter);
flashaddr = QLCNIC_IMAGE_START;
for (i = 0; i < size; i++) {
data = cpu_to_le64(ptr64[i]);
data = le64_to_cpu(ptr64[i]);
if (qlcnic_pci_mem_write_2M(adapter,
flashaddr, data))
@ -1171,9 +1179,9 @@ qlcnic_load_firmware(struct qlcnic_adapter *adapter)
flashaddr += 8;
}
size = (__force u32)qlcnic_get_fw_size(adapter) % 8;
size = qlcnic_get_fw_size(adapter) % 8;
if (size) {
data = cpu_to_le64(ptr64[i]);
data = le64_to_cpu(ptr64[i]);
if (qlcnic_pci_mem_write_2M(adapter,
flashaddr, data))
@ -1225,7 +1233,7 @@ qlcnic_load_firmware(struct qlcnic_adapter *adapter)
static int
qlcnic_validate_firmware(struct qlcnic_adapter *adapter)
{
__le32 val;
u32 val;
u32 ver, bios, min_size;
struct pci_dev *pdev = adapter->pdev;
const struct firmware *fw = adapter->fw;
@ -1237,8 +1245,8 @@ qlcnic_validate_firmware(struct qlcnic_adapter *adapter)
min_size = QLCNIC_UNI_FW_MIN_SIZE;
} else {
val = cpu_to_le32(*(u32 *)&fw->data[QLCNIC_FW_MAGIC_OFFSET]);
if ((__force u32)val != QLCNIC_BDINFO_MAGIC)
val = le32_to_cpu(*(__le32 *)&fw->data[QLCNIC_FW_MAGIC_OFFSET]);
if (val != QLCNIC_BDINFO_MAGIC)
return -EINVAL;
min_size = QLCNIC_FW_MIN_SIZE;
@ -1259,7 +1267,7 @@ qlcnic_validate_firmware(struct qlcnic_adapter *adapter)
val = qlcnic_get_bios_version(adapter);
qlcnic_rom_fast_read(adapter, QLCNIC_BIOS_VERSION_OFFSET, (int *)&bios);
if ((__force u32)val != bios) {
if (val != bios) {
dev_err(&pdev->dev, "%s: firmware bios is incompatible\n",
fw_name[fw_type]);
return -EINVAL;

Просмотреть файл

@ -2030,7 +2030,7 @@ qlcnic_tx_pkt(struct qlcnic_adapter *adapter,
if (protocol == ETH_P_8021Q) {
vh = (struct vlan_ethhdr *)skb->data;
flags = FLAGS_VLAN_TAGGED;
vlan_tci = vh->h_vlan_TCI;
vlan_tci = ntohs(vh->h_vlan_TCI);
protocol = ntohs(vh->h_vlan_encapsulated_proto);
} else if (vlan_tx_tag_present(skb)) {
flags = FLAGS_VLAN_OOB;
@ -4520,7 +4520,7 @@ static void
qlcnic_restore_indev_addr(struct net_device *dev, unsigned long event)
{ }
#endif
static const struct pci_error_handlers qlcnic_err_handler = {
static struct pci_error_handlers qlcnic_err_handler = {
.error_detected = qlcnic_io_error_detected,
.slot_reset = qlcnic_io_slot_reset,
.resume = qlcnic_io_resume,