aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c')
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c278
1 files changed, 142 insertions, 136 deletions
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 8b929eeecd2d..d6b12e035a7d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -276,9 +276,9 @@ static DEFINE_PCI_DEVICE_TABLE(cxgb4_pci_tbl) = {
276 { 0, } 276 { 0, }
277}; 277};
278 278
279#define FW_FNAME "cxgb4/t4fw.bin" 279#define FW4_FNAME "cxgb4/t4fw.bin"
280#define FW5_FNAME "cxgb4/t5fw.bin" 280#define FW5_FNAME "cxgb4/t5fw.bin"
281#define FW_CFNAME "cxgb4/t4-config.txt" 281#define FW4_CFNAME "cxgb4/t4-config.txt"
282#define FW5_CFNAME "cxgb4/t5-config.txt" 282#define FW5_CFNAME "cxgb4/t5-config.txt"
283 283
284MODULE_DESCRIPTION(DRV_DESC); 284MODULE_DESCRIPTION(DRV_DESC);
@@ -286,7 +286,7 @@ MODULE_AUTHOR("Chelsio Communications");
286MODULE_LICENSE("Dual BSD/GPL"); 286MODULE_LICENSE("Dual BSD/GPL");
287MODULE_VERSION(DRV_VERSION); 287MODULE_VERSION(DRV_VERSION);
288MODULE_DEVICE_TABLE(pci, cxgb4_pci_tbl); 288MODULE_DEVICE_TABLE(pci, cxgb4_pci_tbl);
289MODULE_FIRMWARE(FW_FNAME); 289MODULE_FIRMWARE(FW4_FNAME);
290MODULE_FIRMWARE(FW5_FNAME); 290MODULE_FIRMWARE(FW5_FNAME);
291 291
292/* 292/*
@@ -1071,72 +1071,6 @@ freeout: t4_free_sge_resources(adap);
1071} 1071}
1072 1072
1073/* 1073/*
1074 * Returns 0 if new FW was successfully loaded, a positive errno if a load was
1075 * started but failed, and a negative errno if flash load couldn't start.
1076 */
1077static int upgrade_fw(struct adapter *adap)
1078{
1079 int ret;
1080 u32 vers, exp_major;
1081 const struct fw_hdr *hdr;
1082 const struct firmware *fw;
1083 struct device *dev = adap->pdev_dev;
1084 char *fw_file_name;
1085
1086 switch (CHELSIO_CHIP_VERSION(adap->chip)) {
1087 case CHELSIO_T4:
1088 fw_file_name = FW_FNAME;
1089 exp_major = FW_VERSION_MAJOR;
1090 break;
1091 case CHELSIO_T5:
1092 fw_file_name = FW5_FNAME;
1093 exp_major = FW_VERSION_MAJOR_T5;
1094 break;
1095 default:
1096 dev_err(dev, "Unsupported chip type, %x\n", adap->chip);
1097 return -EINVAL;
1098 }
1099
1100 ret = request_firmware(&fw, fw_file_name, dev);
1101 if (ret < 0) {
1102 dev_err(dev, "unable to load firmware image %s, error %d\n",
1103 fw_file_name, ret);
1104 return ret;
1105 }
1106
1107 hdr = (const struct fw_hdr *)fw->data;
1108 vers = ntohl(hdr->fw_ver);
1109 if (FW_HDR_FW_VER_MAJOR_GET(vers) != exp_major) {
1110 ret = -EINVAL; /* wrong major version, won't do */
1111 goto out;
1112 }
1113
1114 /*
1115 * If the flash FW is unusable or we found something newer, load it.
1116 */
1117 if (FW_HDR_FW_VER_MAJOR_GET(adap->params.fw_vers) != exp_major ||
1118 vers > adap->params.fw_vers) {
1119 dev_info(dev, "upgrading firmware ...\n");
1120 ret = t4_fw_upgrade(adap, adap->mbox, fw->data, fw->size,
1121 /*force=*/false);
1122 if (!ret)
1123 dev_info(dev,
1124 "firmware upgraded to version %pI4 from %s\n",
1125 &hdr->fw_ver, fw_file_name);
1126 else
1127 dev_err(dev, "firmware upgrade failed! err=%d\n", -ret);
1128 } else {
1129 /*
1130 * Tell our caller that we didn't upgrade the firmware.
1131 */
1132 ret = -EINVAL;
1133 }
1134
1135out: release_firmware(fw);
1136 return ret;
1137}
1138
1139/*
1140 * Allocate a chunk of memory using kmalloc or, if that fails, vmalloc. 1074 * Allocate a chunk of memory using kmalloc or, if that fails, vmalloc.
1141 * The allocated memory is cleared. 1075 * The allocated memory is cleared.
1142 */ 1076 */
@@ -1415,7 +1349,7 @@ static int get_sset_count(struct net_device *dev, int sset)
1415static int get_regs_len(struct net_device *dev) 1349static int get_regs_len(struct net_device *dev)
1416{ 1350{
1417 struct adapter *adap = netdev2adap(dev); 1351 struct adapter *adap = netdev2adap(dev);
1418 if (is_t4(adap->chip)) 1352 if (is_t4(adap->params.chip))
1419 return T4_REGMAP_SIZE; 1353 return T4_REGMAP_SIZE;
1420 else 1354 else
1421 return T5_REGMAP_SIZE; 1355 return T5_REGMAP_SIZE;
@@ -1499,7 +1433,7 @@ static void get_stats(struct net_device *dev, struct ethtool_stats *stats,
1499 data += sizeof(struct port_stats) / sizeof(u64); 1433 data += sizeof(struct port_stats) / sizeof(u64);
1500 collect_sge_port_stats(adapter, pi, (struct queue_port_stats *)data); 1434 collect_sge_port_stats(adapter, pi, (struct queue_port_stats *)data);
1501 data += sizeof(struct queue_port_stats) / sizeof(u64); 1435 data += sizeof(struct queue_port_stats) / sizeof(u64);
1502 if (!is_t4(adapter->chip)) { 1436 if (!is_t4(adapter->params.chip)) {
1503 t4_write_reg(adapter, SGE_STAT_CFG, STATSOURCE_T5(7)); 1437 t4_write_reg(adapter, SGE_STAT_CFG, STATSOURCE_T5(7));
1504 val1 = t4_read_reg(adapter, SGE_STAT_TOTAL); 1438 val1 = t4_read_reg(adapter, SGE_STAT_TOTAL);
1505 val2 = t4_read_reg(adapter, SGE_STAT_MATCH); 1439 val2 = t4_read_reg(adapter, SGE_STAT_MATCH);
@@ -1521,8 +1455,8 @@ static void get_stats(struct net_device *dev, struct ethtool_stats *stats,
1521 */ 1455 */
1522static inline unsigned int mk_adap_vers(const struct adapter *ap) 1456static inline unsigned int mk_adap_vers(const struct adapter *ap)
1523{ 1457{
1524 return CHELSIO_CHIP_VERSION(ap->chip) | 1458 return CHELSIO_CHIP_VERSION(ap->params.chip) |
1525 (CHELSIO_CHIP_RELEASE(ap->chip) << 10) | (1 << 16); 1459 (CHELSIO_CHIP_RELEASE(ap->params.chip) << 10) | (1 << 16);
1526} 1460}
1527 1461
1528static void reg_block_dump(struct adapter *ap, void *buf, unsigned int start, 1462static void reg_block_dump(struct adapter *ap, void *buf, unsigned int start,
@@ -2189,7 +2123,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
2189 static const unsigned int *reg_ranges; 2123 static const unsigned int *reg_ranges;
2190 int arr_size = 0, buf_size = 0; 2124 int arr_size = 0, buf_size = 0;
2191 2125
2192 if (is_t4(ap->chip)) { 2126 if (is_t4(ap->params.chip)) {
2193 reg_ranges = &t4_reg_ranges[0]; 2127 reg_ranges = &t4_reg_ranges[0];
2194 arr_size = ARRAY_SIZE(t4_reg_ranges); 2128 arr_size = ARRAY_SIZE(t4_reg_ranges);
2195 buf_size = T4_REGMAP_SIZE; 2129 buf_size = T4_REGMAP_SIZE;
@@ -2967,7 +2901,7 @@ static int setup_debugfs(struct adapter *adap)
2967 size = t4_read_reg(adap, MA_EDRAM1_BAR); 2901 size = t4_read_reg(adap, MA_EDRAM1_BAR);
2968 add_debugfs_mem(adap, "edc1", MEM_EDC1, EDRAM_SIZE_GET(size)); 2902 add_debugfs_mem(adap, "edc1", MEM_EDC1, EDRAM_SIZE_GET(size));
2969 } 2903 }
2970 if (is_t4(adap->chip)) { 2904 if (is_t4(adap->params.chip)) {
2971 size = t4_read_reg(adap, MA_EXT_MEMORY_BAR); 2905 size = t4_read_reg(adap, MA_EXT_MEMORY_BAR);
2972 if (i & EXT_MEM_ENABLE) 2906 if (i & EXT_MEM_ENABLE)
2973 add_debugfs_mem(adap, "mc", MEM_MC, 2907 add_debugfs_mem(adap, "mc", MEM_MC,
@@ -3419,7 +3353,7 @@ unsigned int cxgb4_dbfifo_count(const struct net_device *dev, int lpfifo)
3419 3353
3420 v1 = t4_read_reg(adap, A_SGE_DBFIFO_STATUS); 3354 v1 = t4_read_reg(adap, A_SGE_DBFIFO_STATUS);
3421 v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2); 3355 v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2);
3422 if (is_t4(adap->chip)) { 3356 if (is_t4(adap->params.chip)) {
3423 lp_count = G_LP_COUNT(v1); 3357 lp_count = G_LP_COUNT(v1);
3424 hp_count = G_HP_COUNT(v1); 3358 hp_count = G_HP_COUNT(v1);
3425 } else { 3359 } else {
@@ -3588,7 +3522,7 @@ static void drain_db_fifo(struct adapter *adap, int usecs)
3588 do { 3522 do {
3589 v1 = t4_read_reg(adap, A_SGE_DBFIFO_STATUS); 3523 v1 = t4_read_reg(adap, A_SGE_DBFIFO_STATUS);
3590 v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2); 3524 v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2);
3591 if (is_t4(adap->chip)) { 3525 if (is_t4(adap->params.chip)) {
3592 lp_count = G_LP_COUNT(v1); 3526 lp_count = G_LP_COUNT(v1);
3593 hp_count = G_HP_COUNT(v1); 3527 hp_count = G_HP_COUNT(v1);
3594 } else { 3528 } else {
@@ -3708,7 +3642,7 @@ static void process_db_drop(struct work_struct *work)
3708 3642
3709 adap = container_of(work, struct adapter, db_drop_task); 3643 adap = container_of(work, struct adapter, db_drop_task);
3710 3644
3711 if (is_t4(adap->chip)) { 3645 if (is_t4(adap->params.chip)) {
3712 disable_dbs(adap); 3646 disable_dbs(adap);
3713 notify_rdma_uld(adap, CXGB4_CONTROL_DB_DROP); 3647 notify_rdma_uld(adap, CXGB4_CONTROL_DB_DROP);
3714 drain_db_fifo(adap, 1); 3648 drain_db_fifo(adap, 1);
@@ -3753,7 +3687,7 @@ static void process_db_drop(struct work_struct *work)
3753 3687
3754void t4_db_full(struct adapter *adap) 3688void t4_db_full(struct adapter *adap)
3755{ 3689{
3756 if (is_t4(adap->chip)) { 3690 if (is_t4(adap->params.chip)) {
3757 t4_set_reg_field(adap, SGE_INT_ENABLE3, 3691 t4_set_reg_field(adap, SGE_INT_ENABLE3,
3758 DBFIFO_HP_INT | DBFIFO_LP_INT, 0); 3692 DBFIFO_HP_INT | DBFIFO_LP_INT, 0);
3759 queue_work(workq, &adap->db_full_task); 3693 queue_work(workq, &adap->db_full_task);
@@ -3762,7 +3696,7 @@ void t4_db_full(struct adapter *adap)
3762 3696
3763void t4_db_dropped(struct adapter *adap) 3697void t4_db_dropped(struct adapter *adap)
3764{ 3698{
3765 if (is_t4(adap->chip)) 3699 if (is_t4(adap->params.chip))
3766 queue_work(workq, &adap->db_drop_task); 3700 queue_work(workq, &adap->db_drop_task);
3767} 3701}
3768 3702
@@ -3789,7 +3723,7 @@ static void uld_attach(struct adapter *adap, unsigned int uld)
3789 lli.nchan = adap->params.nports; 3723 lli.nchan = adap->params.nports;
3790 lli.nports = adap->params.nports; 3724 lli.nports = adap->params.nports;
3791 lli.wr_cred = adap->params.ofldq_wr_cred; 3725 lli.wr_cred = adap->params.ofldq_wr_cred;
3792 lli.adapter_type = adap->params.rev; 3726 lli.adapter_type = adap->params.chip;
3793 lli.iscsi_iolen = MAXRXDATA_GET(t4_read_reg(adap, TP_PARA_REG2)); 3727 lli.iscsi_iolen = MAXRXDATA_GET(t4_read_reg(adap, TP_PARA_REG2));
3794 lli.udb_density = 1 << QUEUESPERPAGEPF0_GET( 3728 lli.udb_density = 1 << QUEUESPERPAGEPF0_GET(
3795 t4_read_reg(adap, SGE_EGRESS_QUEUES_PER_PAGE_PF) >> 3729 t4_read_reg(adap, SGE_EGRESS_QUEUES_PER_PAGE_PF) >>
@@ -4483,7 +4417,7 @@ static void setup_memwin(struct adapter *adap)
4483 u32 bar0, mem_win0_base, mem_win1_base, mem_win2_base; 4417 u32 bar0, mem_win0_base, mem_win1_base, mem_win2_base;
4484 4418
4485 bar0 = pci_resource_start(adap->pdev, 0); /* truncation intentional */ 4419 bar0 = pci_resource_start(adap->pdev, 0); /* truncation intentional */
4486 if (is_t4(adap->chip)) { 4420 if (is_t4(adap->params.chip)) {
4487 mem_win0_base = bar0 + MEMWIN0_BASE; 4421 mem_win0_base = bar0 + MEMWIN0_BASE;
4488 mem_win1_base = bar0 + MEMWIN1_BASE; 4422 mem_win1_base = bar0 + MEMWIN1_BASE;
4489 mem_win2_base = bar0 + MEMWIN2_BASE; 4423 mem_win2_base = bar0 + MEMWIN2_BASE;
@@ -4668,8 +4602,10 @@ static int adap_init0_config(struct adapter *adapter, int reset)
4668 const struct firmware *cf; 4602 const struct firmware *cf;
4669 unsigned long mtype = 0, maddr = 0; 4603 unsigned long mtype = 0, maddr = 0;
4670 u32 finiver, finicsum, cfcsum; 4604 u32 finiver, finicsum, cfcsum;
4671 int ret, using_flash; 4605 int ret;
4606 int config_issued = 0;
4672 char *fw_config_file, fw_config_file_path[256]; 4607 char *fw_config_file, fw_config_file_path[256];
4608 char *config_name = NULL;
4673 4609
4674 /* 4610 /*
4675 * Reset device if necessary. 4611 * Reset device if necessary.
@@ -4686,9 +4622,9 @@ static int adap_init0_config(struct adapter *adapter, int reset)
4686 * then use that. Otherwise, use the configuration file stored 4622 * then use that. Otherwise, use the configuration file stored
4687 * in the adapter flash ... 4623 * in the adapter flash ...
4688 */ 4624 */
4689 switch (CHELSIO_CHIP_VERSION(adapter->chip)) { 4625 switch (CHELSIO_CHIP_VERSION(adapter->params.chip)) {
4690 case CHELSIO_T4: 4626 case CHELSIO_T4:
4691 fw_config_file = FW_CFNAME; 4627 fw_config_file = FW4_CFNAME;
4692 break; 4628 break;
4693 case CHELSIO_T5: 4629 case CHELSIO_T5:
4694 fw_config_file = FW5_CFNAME; 4630 fw_config_file = FW5_CFNAME;
@@ -4702,13 +4638,16 @@ static int adap_init0_config(struct adapter *adapter, int reset)
4702 4638
4703 ret = request_firmware(&cf, fw_config_file, adapter->pdev_dev); 4639 ret = request_firmware(&cf, fw_config_file, adapter->pdev_dev);
4704 if (ret < 0) { 4640 if (ret < 0) {
4705 using_flash = 1; 4641 config_name = "On FLASH";
4706 mtype = FW_MEMTYPE_CF_FLASH; 4642 mtype = FW_MEMTYPE_CF_FLASH;
4707 maddr = t4_flash_cfg_addr(adapter); 4643 maddr = t4_flash_cfg_addr(adapter);
4708 } else { 4644 } else {
4709 u32 params[7], val[7]; 4645 u32 params[7], val[7];
4710 4646
4711 using_flash = 0; 4647 sprintf(fw_config_file_path,
4648 "/lib/firmware/%s", fw_config_file);
4649 config_name = fw_config_file_path;
4650
4712 if (cf->size >= FLASH_CFG_MAX_SIZE) 4651 if (cf->size >= FLASH_CFG_MAX_SIZE)
4713 ret = -ENOMEM; 4652 ret = -ENOMEM;
4714 else { 4653 else {
@@ -4776,6 +4715,26 @@ static int adap_init0_config(struct adapter *adapter, int reset)
4776 FW_LEN16(caps_cmd)); 4715 FW_LEN16(caps_cmd));
4777 ret = t4_wr_mbox(adapter, adapter->mbox, &caps_cmd, sizeof(caps_cmd), 4716 ret = t4_wr_mbox(adapter, adapter->mbox, &caps_cmd, sizeof(caps_cmd),
4778 &caps_cmd); 4717 &caps_cmd);
4718
4719 /* If the CAPS_CONFIG failed with an ENOENT (for a Firmware
4720 * Configuration File in FLASH), our last gasp effort is to use the
4721 * Firmware Configuration File which is embedded in the firmware. A
4722 * very few early versions of the firmware didn't have one embedded
4723 * but we can ignore those.
4724 */
4725 if (ret == -ENOENT) {
4726 memset(&caps_cmd, 0, sizeof(caps_cmd));
4727 caps_cmd.op_to_write =
4728 htonl(FW_CMD_OP(FW_CAPS_CONFIG_CMD) |
4729 FW_CMD_REQUEST |
4730 FW_CMD_READ);
4731 caps_cmd.cfvalid_to_len16 = htonl(FW_LEN16(caps_cmd));
4732 ret = t4_wr_mbox(adapter, adapter->mbox, &caps_cmd,
4733 sizeof(caps_cmd), &caps_cmd);
4734 config_name = "Firmware Default";
4735 }
4736
4737 config_issued = 1;
4779 if (ret < 0) 4738 if (ret < 0)
4780 goto bye; 4739 goto bye;
4781 4740
@@ -4816,7 +4775,6 @@ static int adap_init0_config(struct adapter *adapter, int reset)
4816 if (ret < 0) 4775 if (ret < 0)
4817 goto bye; 4776 goto bye;
4818 4777
4819 sprintf(fw_config_file_path, "/lib/firmware/%s", fw_config_file);
4820 /* 4778 /*
4821 * Return successfully and note that we're operating with parameters 4779 * Return successfully and note that we're operating with parameters
4822 * not supplied by the driver, rather than from hard-wired 4780 * not supplied by the driver, rather than from hard-wired
@@ -4824,11 +4782,8 @@ static int adap_init0_config(struct adapter *adapter, int reset)
4824 */ 4782 */
4825 adapter->flags |= USING_SOFT_PARAMS; 4783 adapter->flags |= USING_SOFT_PARAMS;
4826 dev_info(adapter->pdev_dev, "Successfully configured using Firmware "\ 4784 dev_info(adapter->pdev_dev, "Successfully configured using Firmware "\
4827 "Configuration File %s, version %#x, computed checksum %#x\n", 4785 "Configuration File \"%s\", version %#x, computed checksum %#x\n",
4828 (using_flash 4786 config_name, finiver, cfcsum);
4829 ? "in device FLASH"
4830 : fw_config_file_path),
4831 finiver, cfcsum);
4832 return 0; 4787 return 0;
4833 4788
4834 /* 4789 /*
@@ -4837,9 +4792,9 @@ static int adap_init0_config(struct adapter *adapter, int reset)
4837 * want to issue a warning since this is fairly common.) 4792 * want to issue a warning since this is fairly common.)
4838 */ 4793 */
4839bye: 4794bye:
4840 if (ret != -ENOENT) 4795 if (config_issued && ret != -ENOENT)
4841 dev_warn(adapter->pdev_dev, "Configuration file error %d\n", 4796 dev_warn(adapter->pdev_dev, "\"%s\" configuration file error %d\n",
4842 -ret); 4797 config_name, -ret);
4843 return ret; 4798 return ret;
4844} 4799}
4845 4800
@@ -5086,6 +5041,47 @@ bye:
5086 return ret; 5041 return ret;
5087} 5042}
5088 5043
5044static struct fw_info fw_info_array[] = {
5045 {
5046 .chip = CHELSIO_T4,
5047 .fs_name = FW4_CFNAME,
5048 .fw_mod_name = FW4_FNAME,
5049 .fw_hdr = {
5050 .chip = FW_HDR_CHIP_T4,
5051 .fw_ver = __cpu_to_be32(FW_VERSION(T4)),
5052 .intfver_nic = FW_INTFVER(T4, NIC),
5053 .intfver_vnic = FW_INTFVER(T4, VNIC),
5054 .intfver_ri = FW_INTFVER(T4, RI),
5055 .intfver_iscsi = FW_INTFVER(T4, ISCSI),
5056 .intfver_fcoe = FW_INTFVER(T4, FCOE),
5057 },
5058 }, {
5059 .chip = CHELSIO_T5,
5060 .fs_name = FW5_CFNAME,
5061 .fw_mod_name = FW5_FNAME,
5062 .fw_hdr = {
5063 .chip = FW_HDR_CHIP_T5,
5064 .fw_ver = __cpu_to_be32(FW_VERSION(T5)),
5065 .intfver_nic = FW_INTFVER(T5, NIC),
5066 .intfver_vnic = FW_INTFVER(T5, VNIC),
5067 .intfver_ri = FW_INTFVER(T5, RI),
5068 .intfver_iscsi = FW_INTFVER(T5, ISCSI),
5069 .intfver_fcoe = FW_INTFVER(T5, FCOE),
5070 },
5071 }
5072};
5073
5074static struct fw_info *find_fw_info(int chip)
5075{
5076 int i;
5077
5078 for (i = 0; i < ARRAY_SIZE(fw_info_array); i++) {
5079 if (fw_info_array[i].chip == chip)
5080 return &fw_info_array[i];
5081 }
5082 return NULL;
5083}
5084
5089/* 5085/*
5090 * Phase 0 of initialization: contact FW, obtain config, perform basic init. 5086 * Phase 0 of initialization: contact FW, obtain config, perform basic init.
5091 */ 5087 */
@@ -5123,44 +5119,54 @@ static int adap_init0(struct adapter *adap)
5123 * later reporting and B. to warn if the currently loaded firmware 5119 * later reporting and B. to warn if the currently loaded firmware
5124 * is excessively mismatched relative to the driver.) 5120 * is excessively mismatched relative to the driver.)
5125 */ 5121 */
5126 ret = t4_check_fw_version(adap); 5122 t4_get_fw_version(adap, &adap->params.fw_vers);
5127 5123 t4_get_tp_version(adap, &adap->params.tp_vers);
5128 /* The error code -EFAULT is returned by t4_check_fw_version() if
5129 * firmware on adapter < supported firmware. If firmware on adapter
5130 * is too old (not supported by driver) and we're the MASTER_PF set
5131 * adapter state to DEV_STATE_UNINIT to force firmware upgrade
5132 * and reinitialization.
5133 */
5134 if ((adap->flags & MASTER_PF) && ret == -EFAULT)
5135 state = DEV_STATE_UNINIT;
5136 if ((adap->flags & MASTER_PF) && state != DEV_STATE_INIT) { 5124 if ((adap->flags & MASTER_PF) && state != DEV_STATE_INIT) {
5137 if (ret == -EINVAL || ret == -EFAULT || ret > 0) { 5125 struct fw_info *fw_info;
5138 if (upgrade_fw(adap) >= 0) { 5126 struct fw_hdr *card_fw;
5139 /* 5127 const struct firmware *fw;
5140 * Note that the chip was reset as part of the 5128 const u8 *fw_data = NULL;
5141 * firmware upgrade so we don't reset it again 5129 unsigned int fw_size = 0;
5142 * below and grab the new firmware version. 5130
5143 */ 5131 /* This is the firmware whose headers the driver was compiled
5144 reset = 0; 5132 * against
5145 ret = t4_check_fw_version(adap); 5133 */
5146 } else 5134 fw_info = find_fw_info(CHELSIO_CHIP_VERSION(adap->params.chip));
5147 if (ret == -EFAULT) { 5135 if (fw_info == NULL) {
5148 /* 5136 dev_err(adap->pdev_dev,
5149 * Firmware is old but still might 5137 "unable to get firmware info for chip %d.\n",
5150 * work if we force reinitialization 5138 CHELSIO_CHIP_VERSION(adap->params.chip));
5151 * of the adapter. Ignoring FW upgrade 5139 return -EINVAL;
5152 * failure.
5153 */
5154 dev_warn(adap->pdev_dev,
5155 "Ignoring firmware upgrade "
5156 "failure, and forcing driver "
5157 "to reinitialize the "
5158 "adapter.\n");
5159 ret = 0;
5160 }
5161 } 5140 }
5141
5142 /* allocate memory to read the header of the firmware on the
5143 * card
5144 */
5145 card_fw = t4_alloc_mem(sizeof(*card_fw));
5146
5147 /* Get FW from from /lib/firmware/ */
5148 ret = request_firmware(&fw, fw_info->fw_mod_name,
5149 adap->pdev_dev);
5150 if (ret < 0) {
5151 dev_err(adap->pdev_dev,
5152 "unable to load firmware image %s, error %d\n",
5153 fw_info->fw_mod_name, ret);
5154 } else {
5155 fw_data = fw->data;
5156 fw_size = fw->size;
5157 }
5158
5159 /* upgrade FW logic */
5160 ret = t4_prep_fw(adap, fw_info, fw_data, fw_size, card_fw,
5161 state, &reset);
5162
5163 /* Cleaning up */
5164 if (fw != NULL)
5165 release_firmware(fw);
5166 t4_free_mem(card_fw);
5167
5162 if (ret < 0) 5168 if (ret < 0)
5163 return ret; 5169 goto bye;
5164 } 5170 }
5165 5171
5166 /* 5172 /*
@@ -5245,7 +5251,7 @@ static int adap_init0(struct adapter *adap)
5245 if (ret == -ENOENT) { 5251 if (ret == -ENOENT) {
5246 dev_info(adap->pdev_dev, 5252 dev_info(adap->pdev_dev,
5247 "No Configuration File present " 5253 "No Configuration File present "
5248 "on adapter. Using hard-wired " 5254 "on adapter. Using hard-wired "
5249 "configuration parameters.\n"); 5255 "configuration parameters.\n");
5250 ret = adap_init0_no_config(adap, reset); 5256 ret = adap_init0_no_config(adap, reset);
5251 } 5257 }
@@ -5787,7 +5793,7 @@ static void print_port_info(const struct net_device *dev)
5787 5793
5788 netdev_info(dev, "Chelsio %s rev %d %s %sNIC PCIe x%d%s%s\n", 5794 netdev_info(dev, "Chelsio %s rev %d %s %sNIC PCIe x%d%s%s\n",
5789 adap->params.vpd.id, 5795 adap->params.vpd.id,
5790 CHELSIO_CHIP_RELEASE(adap->params.rev), buf, 5796 CHELSIO_CHIP_RELEASE(adap->params.chip), buf,
5791 is_offload(adap) ? "R" : "", adap->params.pci.width, spd, 5797 is_offload(adap) ? "R" : "", adap->params.pci.width, spd,
5792 (adap->flags & USING_MSIX) ? " MSI-X" : 5798 (adap->flags & USING_MSIX) ? " MSI-X" :
5793 (adap->flags & USING_MSI) ? " MSI" : ""); 5799 (adap->flags & USING_MSI) ? " MSI" : "");
@@ -5910,7 +5916,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
5910 if (err) 5916 if (err)
5911 goto out_unmap_bar0; 5917 goto out_unmap_bar0;
5912 5918
5913 if (!is_t4(adapter->chip)) { 5919 if (!is_t4(adapter->params.chip)) {
5914 s_qpp = QUEUESPERPAGEPF1 * adapter->fn; 5920 s_qpp = QUEUESPERPAGEPF1 * adapter->fn;
5915 qpp = 1 << QUEUESPERPAGEPF0_GET(t4_read_reg(adapter, 5921 qpp = 1 << QUEUESPERPAGEPF0_GET(t4_read_reg(adapter,
5916 SGE_EGRESS_QUEUES_PER_PAGE_PF) >> s_qpp); 5922 SGE_EGRESS_QUEUES_PER_PAGE_PF) >> s_qpp);
@@ -6064,7 +6070,7 @@ sriov:
6064 out_free_dev: 6070 out_free_dev:
6065 free_some_resources(adapter); 6071 free_some_resources(adapter);
6066 out_unmap_bar: 6072 out_unmap_bar:
6067 if (!is_t4(adapter->chip)) 6073 if (!is_t4(adapter->params.chip))
6068 iounmap(adapter->bar2); 6074 iounmap(adapter->bar2);
6069 out_unmap_bar0: 6075 out_unmap_bar0:
6070 iounmap(adapter->regs); 6076 iounmap(adapter->regs);
@@ -6116,7 +6122,7 @@ static void remove_one(struct pci_dev *pdev)
6116 6122
6117 free_some_resources(adapter); 6123 free_some_resources(adapter);
6118 iounmap(adapter->regs); 6124 iounmap(adapter->regs);
6119 if (!is_t4(adapter->chip)) 6125 if (!is_t4(adapter->params.chip))
6120 iounmap(adapter->bar2); 6126 iounmap(adapter->bar2);
6121 kfree(adapter); 6127 kfree(adapter);
6122 pci_disable_pcie_error_reporting(pdev); 6128 pci_disable_pcie_error_reporting(pdev);