Re: [PATCH] scsi: csiostor: add support for Chelsio T6 adapters

2017-05-18 Thread Johannes Thumshirn
On 05/17/2017 05:00 PM, Varun Prakash wrote:
> Signed-off-by: Varun Prakash 
> ---

Please be a bit more verbose with the changelog.

Thanks,
Johannes
-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


[PATCH] scsi: csiostor: add support for Chelsio T6 adapters

2017-05-17 Thread Varun Prakash
Signed-off-by: Varun Prakash 
---
 drivers/scsi/csiostor/csio_hw.c  | 79 ++--
 drivers/scsi/csiostor/csio_hw_chip.h | 14 +++
 drivers/scsi/csiostor/csio_hw_t5.c   | 29 +
 drivers/scsi/csiostor/csio_init.c|  6 ++-
 drivers/scsi/csiostor/csio_wr.c  |  4 +-
 5 files changed, 88 insertions(+), 44 deletions(-)

diff --git a/drivers/scsi/csiostor/csio_hw.c b/drivers/scsi/csiostor/csio_hw.c
index 622bdab..5ca4099 100644
--- a/drivers/scsi/csiostor/csio_hw.c
+++ b/drivers/scsi/csiostor/csio_hw.c
@@ -794,18 +794,24 @@ csio_hw_dev_ready(struct csio_hw *hw)
 {
uint32_t reg;
int cnt = 6;
+   int src_pf;
 
while (((reg = csio_rd_reg32(hw, PL_WHOAMI_A)) == 0x) &&
   (--cnt != 0))
mdelay(100);
 
-   if ((cnt == 0) && (((int32_t)(SOURCEPF_G(reg)) < 0) ||
-  (SOURCEPF_G(reg) >= CSIO_MAX_PFN))) {
+   if (csio_is_t5(hw->pdev->device & CSIO_HW_CHIP_MASK))
+   src_pf = SOURCEPF_G(reg);
+   else
+   src_pf = T6_SOURCEPF_G(reg);
+
+   if ((cnt == 0) && (((int32_t)(src_pf) < 0) ||
+  (src_pf >= CSIO_MAX_PFN))) {
csio_err(hw, "PL_WHOAMI returned 0x%x, cnt:%d\n", reg, cnt);
return -EIO;
}
 
-   hw->pfn = SOURCEPF_G(reg);
+   hw->pfn = src_pf;
 
return 0;
 }
@@ -1581,10 +1587,16 @@ csio_hw_flash_config(struct csio_hw *hw, u32 
*fw_cfg_param, char *path)
unsigned int mtype = 0, maddr = 0;
uint32_t *cfg_data;
int value_to_add = 0;
+   const char *fw_cfg_file;
+
+   if (csio_is_t5(pci_dev->device & CSIO_HW_CHIP_MASK))
+   fw_cfg_file = FW_CFG_NAME_T5;
+   else
+   fw_cfg_file = FW_CFG_NAME_T6;
 
-   if (request_firmware(, FW_CFG_NAME_T5, dev) < 0) {
+   if (request_firmware(, fw_cfg_file, dev) < 0) {
csio_err(hw, "could not find config file %s, err: %d\n",
-FW_CFG_NAME_T5, ret);
+fw_cfg_file, ret);
return -ENOENT;
}
 
@@ -1623,9 +1635,8 @@ csio_hw_flash_config(struct csio_hw *hw, u32 
*fw_cfg_param, char *path)
ret = csio_memory_write(hw, mtype, maddr + size, 4, );
}
if (ret == 0) {
-   csio_info(hw, "config file upgraded to %s\n",
- FW_CFG_NAME_T5);
-   snprintf(path, 64, "%s%s", "/lib/firmware/", FW_CFG_NAME_T5);
+   csio_info(hw, "config file upgraded to %s\n", fw_cfg_file);
+   snprintf(path, 64, "%s%s", "/lib/firmware/", fw_cfg_file);
}
 
 leave:
@@ -1883,6 +1894,19 @@ static struct fw_info fw_info_array[] = {
.intfver_iscsi = FW_INTFVER(T5, ISCSI),
.intfver_fcoe = FW_INTFVER(T5, FCOE),
},
+   }, {
+   .chip = CHELSIO_T6,
+   .fs_name = FW_CFG_NAME_T6,
+   .fw_mod_name = FW_FNAME_T6,
+   .fw_hdr = {
+   .chip = FW_HDR_CHIP_T6,
+   .fw_ver = __cpu_to_be32(FW_VERSION(T6)),
+   .intfver_nic = FW_INTFVER(T6, NIC),
+   .intfver_vnic = FW_INTFVER(T6, VNIC),
+   .intfver_ri = FW_INTFVER(T6, RI),
+   .intfver_iscsi = FW_INTFVER(T6, ISCSI),
+   .intfver_fcoe = FW_INTFVER(T6, FCOE),
+   },
}
 };
 
@@ -1999,6 +2023,7 @@ csio_hw_flash_fw(struct csio_hw *hw, int *reset)
struct device *dev = _dev->dev ;
const u8 *fw_data = NULL;
unsigned int fw_size = 0;
+   const char *fw_bin_file;
 
/* This is the firmware whose headers the driver was compiled
 * against
@@ -2011,9 +2036,14 @@ csio_hw_flash_fw(struct csio_hw *hw, int *reset)
return -EINVAL;
}
 
-   if (request_firmware(, FW_FNAME_T5, dev) < 0) {
+   if (csio_is_t5(pci_dev->device & CSIO_HW_CHIP_MASK))
+   fw_bin_file = FW_FNAME_T5;
+   else
+   fw_bin_file = FW_FNAME_T6;
+
+   if (request_firmware(, fw_bin_file, dev) < 0) {
csio_err(hw, "could not find firmware image %s, err: %d\n",
-FW_FNAME_T5, ret);
+fw_bin_file, ret);
} else {
fw_data = fw->data;
fw_size = fw->size;
@@ -2238,9 +2268,14 @@ static void
 csio_hw_intr_enable(struct csio_hw *hw)
 {
uint16_t vec = (uint16_t)csio_get_mb_intr_idx(csio_hw_to_mbm(hw));
-   uint32_t pf = SOURCEPF_G(csio_rd_reg32(hw, PL_WHOAMI_A));
+   u32 pf = 0;
uint32_t pl = csio_rd_reg32(hw, PL_INT_ENABLE_A);
 
+   if (csio_is_t5(hw->pdev->device & CSIO_HW_CHIP_MASK))
+   pf = SOURCEPF_G(csio_rd_reg32(hw, PL_WHOAMI_A));
+   else
+   pf = T6_SOURCEPF_G(csio_rd_reg32(hw, PL_WHOAMI_A));