[PATCH 0/3] scsi: be2iscsi: Deprecate BE3 family adapters

2018-06-07 Thread Jitendra Bhivare
This patch is generated against for-next branch.

Jitendra Bhivare (1):
  scsi: be2iscsi: Include null char in SET_HOST_DATA

Ketan Mukadam (2):
  scsi: be2iscsi: Add warnings for unsupported adapters
  scsi: be2iscsi: Update copyright

 drivers/scsi/be2iscsi/be_cmds.c  |  2 +-
 drivers/scsi/be2iscsi/be_iscsi.c | 15 +--
 drivers/scsi/be2iscsi/be_main.c  | 25 +++--
 drivers/scsi/be2iscsi/be_mgmt.c  | 26 +++---
 4 files changed, 48 insertions(+), 20 deletions(-)

-- 
2.7.4



[PATCH 1/3] scsi: be2iscsi: Include null char in SET_HOST_DATA

2018-06-07 Thread Jitendra Bhivare
FW needs NULL terminated driver version string.

Signed-off-by: Ketan Mukadam 
Reviewed-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be_cmds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 2eb66df..c10aac4 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -1545,7 +1545,7 @@ int beiscsi_set_host_data(struct beiscsi_hba *phba)
snprintf((char *)ioctl->param.req.param_data,
 sizeof(ioctl->param.req.param_data),
 "Linux iSCSI v%s", BUILD_STR);
-   ioctl->param.req.param_len = ALIGN(ioctl->param.req.param_len, 4);
+   ioctl->param.req.param_len = ALIGN(ioctl->param.req.param_len + 1, 4);
if (ioctl->param.req.param_len > BE_CMD_MAX_DRV_VERSION)
ioctl->param.req.param_len = BE_CMD_MAX_DRV_VERSION;
ret = be_mbox_notify(ctrl);
-- 
2.7.4



[PATCH 3/3] scsi: be2iscsi: Update copyright

2018-06-07 Thread Jitendra Bhivare
From: Ketan Mukadam 

Update Broadcom copyright markings in all modified files.

Signed-off-by: Ketan Mukadam 
Reviewed-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be_iscsi.c | 15 +--
 drivers/scsi/be2iscsi/be_main.c  | 23 +--
 drivers/scsi/be2iscsi/be_mgmt.c  | 23 +--
 3 files changed, 43 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index a398c54..c8f0a21 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -1,11 +1,14 @@
 /*
- * Copyright 2017 Broadcom. All Rights Reserved.
- * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
+ * This file is part of the Emulex Linux Device Driver for Enterprise iSCSI
+ * Host Bus Adapters. Refer to the README file included with this package
+ * for driver version and adapter compatibility.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation. The full GNU General
- * Public License is included in this distribution in the file called COPYING.
+ * Copyright (c) 2018 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
  *
  * Contact Information:
  * linux-driv...@broadcom.com
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 2b4f524..84c3287 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1,11 +1,22 @@
 /*
- * Copyright 2017 Broadcom. All Rights Reserved.
- * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
+ * This file is part of the Emulex Linux Device Driver for Enterprise iSCSI
+ * Host Bus Adapters. Refer to the README file included with this package
+ * for driver version and adapter compatibility.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation. The full GNU General
- * Public License is included in this distribution in the file called COPYING.
+ * Copyright (c) 2018 Broadcom. All Rights Reserved.
+ * The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful. ALL EXPRESS
+ * OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
+ * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH
+ * DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.
+ * See the GNU General Public License for more details, a copy of which
+ * can be found in the file COPYING included with this package.
  *
  * Contact Information:
  * linux-driv...@broadcom.com
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index dff6cdf..13c7dea 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1,11 +1,22 @@
 /*
- * Copyright 2017 Broadcom. All Rights Reserved.
- * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
+ * This file is part of the Emulex Linux Device Driver for Enterprise iSCSI
+ * Host Bus Adapters. Refer to the README file included with this package
+ * for driver version and adapter compatibility.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation. The full GNU General
- * Public License is included in this distribution in the file called COPYING.
+ * Copyright (c) 2018 Broadcom. All Rights Reserved.
+ * The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful. ALL EXPRESS
+ * OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
+ * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ * OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH
+ * DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.
+ * See the GNU General Public License for more details, a copy of which
+ * can be found in the file COPYING included with this package.
  *

[PATCH 2/3] scsi: be2iscsi: Add warnings for unsupported adapters

2018-06-07 Thread Jitendra Bhivare
From: Ketan Mukadam 

Add a warning message to indicate obsolete/unsupported
BE3 Adapter Family devices.

Signed-off-by: Ketan Mukadam 
Reviewed-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be_main.c | 2 ++
 drivers/scsi/be2iscsi/be_mgmt.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index b3cfdd5..2b4f524 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -5583,6 +5583,8 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
case OC_DEVICE_ID3:
phba->generation = BE_GEN3;
phba->iotask_fn = beiscsi_iotask;
+   dev_warn(>dev,
+"Obsolete/Unsupported BE3 Adapter Family\n");
break;
case OC_SKH_ID1:
phba->generation = BE_GEN4;
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 66ca967..dff6cdf 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1233,7 +1233,8 @@ beiscsi_adap_family_disp(struct device *dev, struct 
device_attribute *attr,
break;
case BE_DEVICE_ID2:
case OC_DEVICE_ID3:
-   return snprintf(buf, PAGE_SIZE, "BE3-R Adapter Family\n");
+   return snprintf(buf, PAGE_SIZE,
+   "Obsolete/Unsupported BE3-R Adapter Family\n");
break;
case OC_SKH_ID1:
return snprintf(buf, PAGE_SIZE, "Skyhawk-R Adapter Family\n");
-- 
2.7.4



RE: [PATCH v2] scsi: be2iscsi: Use kasprintf

2017-11-05 Thread Jitendra Bhivare
> -Original Message-
> From: Himanshu Jha [mailto:himanshujha199...@gmail.com]
> Sent: Wednesday, October 11, 2017 9:06 PM
> To: j...@linux.vnet.ibm.com
> Cc: martin.peter...@oracle.com; linux-scsi@vger.kernel.org; linux-
> ker...@vger.kernel.org; subbu.seethara...@broadcom.com;
> ketan.muka...@broadcom.com; jitendra.bhiv...@broadcom.com;
> Himanshu Jha <himanshujha199...@gmail.com>
> Subject: [PATCH v2] scsi: be2iscsi: Use kasprintf
>
> Use kasprintf instead of combination of kmalloc and sprintf.
> Also, remove BEISCSI_MSI_NAME macro used to specify size of string as
> kasprintf handles size computations.
>
> Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com>
> ---
> v2:
>-remove the unnecessary macro BEISCSI_MSI_NAME.
>
>  drivers/scsi/be2iscsi/be_main.c | 12 +---
> drivers/scsi/be2iscsi/be_main.h |  2 --
>  2 files changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/scsi/be2iscsi/be_main.c
b/drivers/scsi/be2iscsi/be_main.c
> index b4542e7..6a9ee0e 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -803,15 +803,14 @@ static int beiscsi_init_irqs(struct beiscsi_hba
*phba)
>
>   if (pcidev->msix_enabled) {
>   for (i = 0; i < phba->num_cpus; i++) {
> - phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME,
> - GFP_KERNEL);
> + phba->msi_name[i] = kasprintf(GFP_KERNEL,
> +   "beiscsi_%02x_%02x",
> +
phba->shost->host_no, i);
>   if (!phba->msi_name[i]) {
>   ret = -ENOMEM;
>   goto free_msix_irqs;
>   }
>
> - sprintf(phba->msi_name[i], "beiscsi_%02x_%02x",
> - phba->shost->host_no, i);
>   ret = request_irq(pci_irq_vector(pcidev, i),
> be_isr_msix, 0,
phba->msi_name[i],
> _context->be_eq[i]);
> @@ -824,13 +823,12 @@ static int beiscsi_init_irqs(struct beiscsi_hba
*phba)
>   goto free_msix_irqs;
>   }
>   }
> - phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME,
> GFP_KERNEL);
> + phba->msi_name[i] = kasprintf(GFP_KERNEL,
> "beiscsi_mcc_%02x",
> +   phba->shost->host_no);
>   if (!phba->msi_name[i]) {
>   ret = -ENOMEM;
>   goto free_msix_irqs;
>   }
> - sprintf(phba->msi_name[i], "beiscsi_mcc_%02x",
> - phba->shost->host_no);
>   ret = request_irq(pci_irq_vector(pcidev, i), be_isr_mcc,
0,
> phba->msi_name[i], _context-
> >be_eq[i]);
>   if (ret) {
> diff --git a/drivers/scsi/be2iscsi/be_main.h
b/drivers/scsi/be2iscsi/be_main.h
> index 81ce3ff..8166de5 100644
> --- a/drivers/scsi/be2iscsi/be_main.h
> +++ b/drivers/scsi/be2iscsi/be_main.h
> @@ -155,8 +155,6 @@
>  #define PAGES_REQUIRED(x) \
>   ((x < PAGE_SIZE) ? 1 :  ((x + PAGE_SIZE - 1) / PAGE_SIZE))
>
> -#define BEISCSI_MSI_NAME 20 /* size of msi_name string */
> -
>  #define MEM_DESCR_OFFSET 8
>  #define BEISCSI_DEFQ_HDR 1
>  #define BEISCSI_DEFQ_DATA 0
> --
> 2.7.4

Looks good.

- Thanks.

Reviewed-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>


[PATCH 08/10] be2iscsi: Fix misc static analysis errors

2017-10-10 Thread Jitendra Bhivare
The patch fixes errors reported by tools like smatch:
 - removes unused structure fields
 - removes dead code
 - fixes code identation

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be.h  | 17 
 drivers/scsi/be2iscsi/be_cmds.c |  1 -
 drivers/scsi/be2iscsi/be_cmds.h | 14 ++---
 drivers/scsi/be2iscsi/be_main.c | 40 
 drivers/scsi/be2iscsi/be_main.h | 45 ++---
 drivers/scsi/be2iscsi/be_mgmt.h |  6 --
 6 files changed, 29 insertions(+), 94 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index 55e3f8b..1310fbf 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -81,12 +81,12 @@ static inline void queue_tail_inc(struct be_queue_info *q)
 /*ISCSI */
 
 struct be_aic_obj {/* Adaptive interrupt coalescing (AIC) info */
-   u32 min_eqd;/* in usecs */
-   u32 max_eqd;/* in usecs */
-   u32 prev_eqd;   /* in usecs */
-   u32 et_eqd; /* configured val when aic is off */
-   ulong jiffies;
-   u64 eq_prev;/* Used to calculate eqe */
+   unsigned long jiffies;
+   u32 eq_prev;/* Used to calculate eqe */
+   u32 prev_eqd;
+#define BEISCSI_EQ_DELAY_MIN   0
+#define BEISCSI_EQ_DELAY_DEF   32
+#define BEISCSI_EQ_DELAY_MAX   128
 };
 
 struct be_eq_obj {
@@ -148,9 +148,8 @@ struct be_ctrl_info {
 /* TAG is from 1...MAX_MCC_CMD, MASK includes MAX_MCC_CMD */
 #define MCC_Q_CMD_TAG_MASK ((MAX_MCC_CMD << 1) - 1)
 
-#define PAGE_SHIFT_4K 12
-#define PAGE_SIZE_4K (1 << PAGE_SHIFT_4K)
-#define mcc_timeout12 /* 12s timeout */
+#define PAGE_SHIFT_4K  12
+#define PAGE_SIZE_4K   (1 << PAGE_SHIFT_4K)
 
 /* Returns number of pages spanned by the data starting at the given addr */
 #define PAGES_4K_SPANNED(_address, size)   \
diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 0499666..7d633dd 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -947,7 +947,6 @@ int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct 
be_queue_info *q,
default:
mutex_unlock(>mbox_lock);
BUG();
-   return -ENXIO;
}
be_cmd_hdr_prepare(>hdr, subsys, opcode, sizeof(*req));
if (queue_type != QTYPE_SGL)
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 5d5e8fb..fc252de 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -1298,19 +1298,9 @@ struct be_cmd_get_port_name {
 * a read command
 */
 #define TGT_CTX_UPDT_CMD   7   /* Target context update */
-#define TGT_STS_CMD8   /* Target R2T and other BHS
-* where only the status number
-* need to be updated
-*/
-#define TGT_DATAIN_CMD 9   /* Target Data-Ins in response
-* to read command
-*/
-#define TGT_SOS_PDU10  /* Target:standalone status
-* response
-*/
 #define TGT_DM_CMD 11  /* Indicates that the bhs
-*  preparedby
-* driver should not be touched
+* prepared by driver should not
+* be touched.
 */
 
 /* Returns the number of items in the field array. */
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 02144c5..f8123ad5 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -455,14 +455,12 @@ static int beiscsi_map_pci_bars(struct beiscsi_hba *phba,
return -ENOMEM;
phba->ctrl.csr = addr;
phba->csr_va = addr;
-   phba->csr_pa.u.a64.address = pci_resource_start(pcidev, 2);
 
addr = ioremap_nocache(pci_resource_start(pcidev, 4), 128 * 1024);
if (addr == NULL)
goto pci_map_err;
phba->ctrl.db = addr;
phba->db_va = addr;
-   phba->db_pa.u.a64.address =  pci_resource_start(pcidev, 4);
 
if (phba->generation == BE_GEN2)
pcicfg_reg = 1;
@@ -476,7 +474,6 @@ static int beiscsi_map_pci_bars(struct beiscsi_hba *phba,
   

[PATCH 10/10] scsi: be2iscsi: Update driver version

2017-10-10 Thread Jitendra Bhivare
Version 11.4.0.1

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 3d21849..9bc7ef9 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -31,7 +31,7 @@
 #include 
 
 #define DRV_NAME   "be2iscsi"
-#define BUILD_STR  "11.4.0.0"
+#define BUILD_STR  "11.4.0.1"
 #define BE_NAME"Emulex OneConnect" \
"Open-iSCSI Driver version" BUILD_STR
 #define DRV_DESC   BE_NAME " " "Driver"
-- 
2.7.4



[PATCH 07/10] be2iscsi: Add cmd to set host data

2017-10-10 Thread Jitendra Bhivare
Provide driver version in host data to FW.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_cmds.c | 46 +
 drivers/scsi/be2iscsi/be_cmds.h | 26 +++
 drivers/scsi/be2iscsi/be_main.c |  2 ++
 3 files changed, 74 insertions(+)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 6af448d..0499666 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -1522,6 +1522,52 @@ int beiscsi_get_port_name(struct be_ctrl_info *ctrl, 
struct beiscsi_hba *phba)
return ret;
 }
 
+int beiscsi_set_host_data(struct beiscsi_hba *phba)
+{
+   struct be_ctrl_info *ctrl = >ctrl;
+   struct be_cmd_set_host_data *ioctl;
+   struct be_mcc_wrb *wrb;
+   int ret = 0;
+
+   if (is_chip_be2_be3r(phba))
+   return ret;
+
+   mutex_lock(>mbox_lock);
+   wrb = wrb_from_mbox(>mbox_mem);
+   memset(wrb, 0, sizeof(*wrb));
+   ioctl = embedded_payload(wrb);
+
+   be_wrb_hdr_prepare(wrb, sizeof(*ioctl), true, 0);
+   be_cmd_hdr_prepare(>h.req_hdr, CMD_SUBSYSTEM_COMMON,
+  OPCODE_COMMON_SET_HOST_DATA,
+  EMBED_MBX_MAX_PAYLOAD_SIZE);
+   ioctl->param.req.param_id = BE_CMD_SET_HOST_PARAM_ID;
+   ioctl->param.req.param_len =
+   snprintf((char *)ioctl->param.req.param_data,
+sizeof(ioctl->param.req.param_data),
+"Linux iSCSI v%s", BUILD_STR);
+   ioctl->param.req.param_len = ALIGN(ioctl->param.req.param_len, 4);
+   if (ioctl->param.req.param_len > BE_CMD_MAX_DRV_VERSION)
+   ioctl->param.req.param_len = BE_CMD_MAX_DRV_VERSION;
+   ret = be_mbox_notify(ctrl);
+   if (!ret) {
+   beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
+   "BG_%d : HBA set host driver version\n");
+   } else {
+   /**
+* Check "MCC_STATUS_INVALID_LENGTH" for SKH.
+* Older FW versions return this error.
+*/
+   if (ret == MCC_STATUS_ILLEGAL_REQUEST ||
+   ret == MCC_STATUS_INVALID_LENGTH)
+   __beiscsi_log(phba, KERN_INFO,
+ "BG_%d : HBA failed to set host driver 
version\n");
+   }
+
+   mutex_unlock(>mbox_lock);
+   return ret;
+}
+
 int beiscsi_set_uer_feature(struct beiscsi_hba *phba)
 {
struct be_ctrl_info *ctrl = >ctrl;
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 4f1ac97..5d5e8fb 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -230,6 +230,7 @@ struct be_mcc_mailbox {
 #define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG58
 #define OPCODE_COMMON_FUNCTION_RESET   61
 #define OPCODE_COMMON_GET_PORT_NAME77
+#define OPCODE_COMMON_SET_HOST_DATA93
 #define OPCODE_COMMON_SET_FEATURES 191
 
 /**
@@ -737,6 +738,30 @@ struct be_cmd_hba_name {
u8 initiator_alias[BE_INI_ALIAS_LEN];
 } __packed;
 
+/ COMMON SET HOST DATA ***/
+#define BE_CMD_SET_HOST_PARAM_ID   0x2
+#define BE_CMD_MAX_DRV_VERSION 0x30
+struct be_sethost_req {
+   u32 param_id;
+   u32 param_len;
+   u32 param_data[32];
+};
+
+struct be_sethost_resp {
+   u32 rsvd0;
+};
+
+struct be_cmd_set_host_data {
+   union {
+   struct be_cmd_req_hdr req_hdr;
+   struct be_cmd_resp_hdr resp_hdr;
+   } h;
+   union {
+   struct be_sethost_req req;
+   struct be_sethost_resp resp;
+   } param;
+} __packed;
+
 / COMMON SET Features ***/
 #define BE_CMD_SET_FEATURE_UER 0x10
 #define BE_CMD_UER_SUPP_BIT0x1
@@ -845,6 +870,7 @@ int beiscsi_get_fw_config(struct be_ctrl_info *ctrl, struct 
beiscsi_hba *phba);
 int beiscsi_get_port_name(struct be_ctrl_info *ctrl, struct beiscsi_hba *phba);
 
 int beiscsi_set_uer_feature(struct beiscsi_hba *phba);
+int beiscsi_set_host_data(struct beiscsi_hba *phba);
 
 struct be_default_pdu_context {
u32 dw[4];
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 8f7e394..02144c5 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -5325,6 +5325,7 @@ static int beiscsi_enable_port(struct beiscsi_hba *phba)
be2iscsi_enable_msix(phba);
 
beiscsi_get_params(phba);
+   beiscsi_set_host_data(phba);
/* Re-enable UER. If different TPE occurs then it is recoverable. */
beiscsi_set_uer_feature(phba);
 
@@ -5623,6 +5624,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
}
beiscsi_get_p

[PATCH 09/10] be2iscsi: Remove A-circumflex character in copyright marking

2017-10-10 Thread Jitendra Bhivare
Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be.h   | 2 +-
 drivers/scsi/be2iscsi/be_cmds.c  | 2 +-
 drivers/scsi/be2iscsi/be_cmds.h  | 2 +-
 drivers/scsi/be2iscsi/be_iscsi.c | 2 +-
 drivers/scsi/be2iscsi/be_iscsi.h | 2 +-
 drivers/scsi/be2iscsi/be_main.c  | 2 +-
 drivers/scsi/be2iscsi/be_main.h  | 2 +-
 drivers/scsi/be2iscsi/be_mgmt.c  | 2 +-
 drivers/scsi/be2iscsi/be_mgmt.h  | 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index 1310fbf..e035acf 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 Broadcom. All Rights Reserved.
+ * Copyright 2017 Broadcom. All Rights Reserved.
  * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 7d633dd..2eb66df 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 Broadcom. All Rights Reserved.
+ * Copyright 2017 Broadcom. All Rights Reserved.
  * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index fc252de..6f05d1d 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 Broadcom. All Rights Reserved.
+ * Copyright 2017 Broadcom. All Rights Reserved.
  * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index aef9764..a398c54 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 Broadcom. All Rights Reserved.
+ * Copyright 2017 Broadcom. All Rights Reserved.
  * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/be2iscsi/be_iscsi.h b/drivers/scsi/be2iscsi/be_iscsi.h
index b9d459a..f41dfda 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.h
+++ b/drivers/scsi/be2iscsi/be_iscsi.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 Broadcom. All Rights Reserved.
+ * Copyright 2017 Broadcom. All Rights Reserved.
  * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index f8123ad5..7561e13 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 Broadcom. All Rights Reserved.
+ * Copyright 2017 Broadcom. All Rights Reserved.
  * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 6d8f819..3d21849 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 Broadcom. All Rights Reserved.
+ * Copyright 2017 Broadcom. All Rights Reserved.
  * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 713c7de..66ca967 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 Broadcom. All Rights Reserved.
+ * Copyright 2017 Broadcom. All Rights Reserved.
  * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/be2iscsi/be_mgmt.h b/drivers/scsi/be2iscsi/be_mgmt.h
index b310c24..0b22c99 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.h
+++ b/drivers/scsi/be2iscsi/be_mgmt.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 Broadcom. All Rights Reserved.
+ * Copyright 2017 Broadcom. All Rights Reserved.
  * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
-- 
2.7.4



[PATCH 06/10] be2iscsi: Modify IOCTL to fetch user configured IQN

2017-10-10 Thread Jitendra Bhivare
Add version 1 of GET_HBA_NAME to fetch port specific IQN first.
If it fails use version 0 to get the IQN.

To use this old IQN names of interfaces needs to be cleared from
the iscsiadm database.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_iscsi.c | 12 
 drivers/scsi/be2iscsi/be_mgmt.c  |  7 ++-
 drivers/scsi/be2iscsi/be_mgmt.h  |  2 +-
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 512c52a..aef9764 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -762,11 +762,15 @@ int beiscsi_get_host_param(struct Scsi_Host *shost,
}
break;
case ISCSI_HOST_PARAM_INITIATOR_NAME:
-   status = beiscsi_get_initiator_name(phba, buf);
+   /* try fetching user configured name first */
+   status = beiscsi_get_initiator_name(phba, buf, true);
if (status < 0) {
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
-   "BS_%d : Retreiving Initiator Name 
Failed\n");
-   return 0;
+   status = beiscsi_get_initiator_name(phba, buf, false);
+   if (status < 0) {
+   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
+   "BS_%d : Retreiving Initiator Name 
Failed\n");
+   status = 0;
+   }
}
break;
case ISCSI_HOST_PARAM_PORT_STATE:
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 0c25c10..713c7de 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -339,12 +339,14 @@ int beiscsi_modify_eq_delay(struct beiscsi_hba *phba,
  * beiscsi_get_initiator_name - read initiator name from flash
  * @phba: device priv structure
  * @name: buffer pointer
+ * @cfg: fetch user configured
  *
  */
-int beiscsi_get_initiator_name(struct beiscsi_hba *phba, char *name)
+int beiscsi_get_initiator_name(struct beiscsi_hba *phba, char *name, bool cfg)
 {
struct be_dma_mem nonemb_cmd;
struct be_cmd_hba_name resp;
+   struct be_cmd_hba_name *req;
int rc;
 
rc = beiscsi_prep_nemb_cmd(phba, _cmd, CMD_SUBSYSTEM_ISCSI_INI,
@@ -352,6 +354,9 @@ int beiscsi_get_initiator_name(struct beiscsi_hba *phba, 
char *name)
if (rc)
return rc;
 
+   req = nonemb_cmd.va;
+   if (cfg)
+   req->hdr.version = 1;
rc = beiscsi_exec_nemb_cmd(phba, _cmd, NULL,
   , sizeof(resp));
if (rc) {
diff --git a/drivers/scsi/be2iscsi/be_mgmt.h b/drivers/scsi/be2iscsi/be_mgmt.h
index 665fd89..8d886f8 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.h
+++ b/drivers/scsi/be2iscsi/be_mgmt.h
@@ -178,7 +178,7 @@ int beiscsi_mgmt_invalidate_icds(struct beiscsi_hba *phba,
 struct invldt_cmd_tbl *inv_tbl,
 unsigned int nents);
 
-int beiscsi_get_initiator_name(struct beiscsi_hba *phba, char *name);
+int beiscsi_get_initiator_name(struct beiscsi_hba *phba, char *name, bool cfg);
 
 int beiscsi_if_en_dhcp(struct beiscsi_hba *phba, u32 ip_type);
 
-- 
2.7.4



[PATCH 02/10] be2iscsi: Fix return value in mgmt_open_connection

2017-10-10 Thread Jitendra Bhivare
mgmt_open_connection is expected to return tag not errno.

In error case, just return invalid tag 0.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_mgmt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index c737753..af6ee43 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -156,7 +156,7 @@ int mgmt_open_connection(struct beiscsi_hba *phba,
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BG_%d : unknown addr family %d\n",
dst_addr->sa_family);
-   return -EINVAL;
+   return 0;
}
 
phwi_ctrlr = phba->phwi_ctrlr;
-- 
2.7.4



[PATCH 01/10] be2iscsi: Fix boot flags in sysfs

2017-10-10 Thread Jitendra Bhivare
The boot flags exported through sysfs was wrongly reverted to 2.
Use boot flag 3 required per spec.
Bit 0 Block valid flag
Bit 1 Firmware booting selected

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index b4542e7..56ae0f4 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -4917,6 +4917,13 @@ void beiscsi_start_boot_work(struct beiscsi_hba *phba, 
unsigned int s_handle)
schedule_work(>boot_work);
 }
 
+/**
+ * Boot flag info for iscsi-utilities
+ * Bit 0 Block valid flag
+ * Bit 1 Firmware booting selected
+ */
+#define BEISCSI_SYSFS_ISCSI_BOOT_FLAGS 3
+
 static ssize_t beiscsi_show_boot_tgt_info(void *data, int type, char *buf)
 {
struct beiscsi_hba *phba = data;
@@ -4972,7 +4979,7 @@ static ssize_t beiscsi_show_boot_tgt_info(void *data, int 
type, char *buf)
 auth_data.chap.intr_secret);
break;
case ISCSI_BOOT_TGT_FLAGS:
-   rc = sprintf(str, "2\n");
+   rc = sprintf(str, "%d\n", BEISCSI_SYSFS_ISCSI_BOOT_FLAGS);
break;
case ISCSI_BOOT_TGT_NIC_ASSOC:
rc = sprintf(str, "0\n");
@@ -5004,7 +5011,7 @@ static ssize_t beiscsi_show_boot_eth_info(void *data, int 
type, char *buf)
 
switch (type) {
case ISCSI_BOOT_ETH_FLAGS:
-   rc = sprintf(str, "2\n");
+   rc = sprintf(str, "%d\n", BEISCSI_SYSFS_ISCSI_BOOT_FLAGS);
break;
case ISCSI_BOOT_ETH_INDEX:
rc = sprintf(str, "0\n");
-- 
2.7.4



[PATCH 04/10] be2iscsi: Fix _modify_eq_delay buffer overflow

2017-10-10 Thread Jitendra Bhivare
beiscsi_modify_eq_delay is using embedded command to send request of
788 bytes in 236 bytes buffer. Non-embedded command needs to be used
in such cases.

Use mgmt_alloc_cmd_data fn modified to allow passing of subsystem.
Use mgmt_exec_nonemb_cmd fn modified to allow setting of callback.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_cmds.c |   6 +-
 drivers/scsi/be2iscsi/be_cmds.h |   4 +-
 drivers/scsi/be2iscsi/be_mgmt.c | 212 ++--
 3 files changed, 124 insertions(+), 98 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index a79a5e7..6af448d 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -675,8 +675,8 @@ static int be_mbox_notify(struct be_ctrl_info *ctrl)
return status;
 }
 
-void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
-   bool embedded, u8 sge_cnt)
+void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, u32 payload_len,
+   bool embedded, u8 sge_cnt)
 {
if (embedded)
wrb->emb_sgecnt_special |= MCC_WRB_EMBEDDED_MASK;
@@ -688,7 +688,7 @@ void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int 
payload_len,
 }
 
 void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
-   u8 subsystem, u8 opcode, int cmd_len)
+   u8 subsystem, u8 opcode, u32 cmd_len)
 {
req_hdr->opcode = opcode;
req_hdr->subsystem = subsystem;
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index d9b6773..22ddfe9 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -1444,9 +1444,9 @@ struct be_cmd_get_port_name {
 * the cxn
 */
 
-void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
+void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, u32 payload_len,
bool embedded, u8 sge_cnt);
 
 void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
-   u8 subsystem, u8 opcode, int cmd_len);
+   u8 subsystem, u8 opcode, u32 cmd_len);
 #endif /* !BEISCSI_CMDS_H */
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index af6ee43..2117ac0 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -19,43 +19,6 @@
 #include "be_iscsi.h"
 #include "be_main.h"
 
-int beiscsi_modify_eq_delay(struct beiscsi_hba *phba,
-   struct be_set_eqd *set_eqd,
-   int num)
-{
-   struct be_ctrl_info *ctrl = >ctrl;
-   struct be_mcc_wrb *wrb;
-   struct be_cmd_req_modify_eq_delay *req;
-   unsigned int tag;
-   int i;
-
-   mutex_lock(>mbox_lock);
-   wrb = alloc_mcc_wrb(phba, );
-   if (!wrb) {
-   mutex_unlock(>mbox_lock);
-   return 0;
-   }
-
-   req = embedded_payload(wrb);
-   be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
-   be_cmd_hdr_prepare(>hdr, CMD_SUBSYSTEM_COMMON,
-  OPCODE_COMMON_MODIFY_EQ_DELAY, sizeof(*req));
-
-   req->num_eq = cpu_to_le32(num);
-   for (i = 0; i < num; i++) {
-   req->delay[i].eq_id = cpu_to_le32(set_eqd[i].eq_id);
-   req->delay[i].phase = 0;
-   req->delay[i].delay_multiplier =
-   cpu_to_le32(set_eqd[i].delay_multiplier);
-   }
-
-   /* ignore the completion of this mbox command */
-   set_bit(MCC_TAG_STATE_IGNORE, >ptag_state[tag].tag_state);
-   be_mcc_notify(phba, tag);
-   mutex_unlock(>mbox_lock);
-   return tag;
-}
-
 unsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info *ctrl,
 struct beiscsi_hba *phba,
 struct bsg_job *job,
@@ -236,16 +199,19 @@ int mgmt_open_connection(struct beiscsi_hba *phba,
 }
 
 /*
- * mgmt_exec_nonemb_cmd()- Execute Non Embedded MBX Cmd
- * @phba: Driver priv structure
- * @nonemb_cmd: Address of the MBX command issued
- * @resp_buf: Buffer to copy the MBX cmd response
- * @resp_buf_len: respone lenght to be copied
+ * beiscsi_exec_nemb_cmd()- execute non-embedded MBX cmd
+ * @phba: driver priv structure
+ * @nonemb_cmd: DMA address of the MBX command to be issued
+ * @cbfn: callback func on MCC completion
+ * @resp_buf: buffer to copy the MBX cmd response
+ * @resp_buf_len: response length to be copied
  *
  **/
-static int mgmt_exec_nonemb_cmd(struct beiscsi_hba *phba,
-   struct be_dma_mem *nonemb_cmd, void *resp_buf,
-   int resp_buf_len)
+static int beiscsi_exec_nemb_cmd(struct beiscsi_hba *phba,
+struct be_dma_mem *nonemb_c

[PATCH 05/10] be2iscsi: Fix _get_initname buffer overflow

2017-10-10 Thread Jitendra Bhivare
be_cmd_get_initname pulls GET_HBA_NAME response of 276 bytes in embedded
WRB buffer of 236 bytes.

Use non-embedded functions to issue the IOCTL.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_cmds.h  |  2 --
 drivers/scsi/be2iscsi/be_iscsi.c | 44 +++
 drivers/scsi/be2iscsi/be_mgmt.c  | 57 
 drivers/scsi/be2iscsi/be_mgmt.h  |  2 ++
 4 files changed, 35 insertions(+), 70 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 22ddfe9..4f1ac97 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -793,8 +793,6 @@ int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
struct be_queue_info *mccq,
struct be_queue_info *cq);
 
-unsigned int be_cmd_get_initname(struct beiscsi_hba *phba);
-
 void free_mcc_wrb(struct be_ctrl_info *ctrl, unsigned int tag);
 
 int beiscsi_modify_eq_delay(struct beiscsi_hba *phba, struct be_set_eqd *,
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 43a80ce..512c52a 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -684,41 +684,6 @@ int beiscsi_set_param(struct iscsi_cls_conn *cls_conn,
 }
 
 /**
- * beiscsi_get_initname - Read Initiator Name from flash
- * @buf: buffer bointer
- * @phba: The device priv structure instance
- *
- * returns number of bytes
- */
-static int beiscsi_get_initname(char *buf, struct beiscsi_hba *phba)
-{
-   int rc;
-   unsigned int tag;
-   struct be_mcc_wrb *wrb;
-   struct be_cmd_hba_name *resp;
-
-   tag = be_cmd_get_initname(phba);
-   if (!tag) {
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
-   "BS_%d : Getting Initiator Name Failed\n");
-
-   return -EBUSY;
-   }
-
-   rc = beiscsi_mccq_compl_wait(phba, tag, , NULL);
-   if (rc) {
-   beiscsi_log(phba, KERN_ERR,
-   BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
-   "BS_%d : Initiator Name MBX Failed\n");
-   return rc;
-   }
-
-   resp = embedded_payload(wrb);
-   rc = sprintf(buf, "%s\n", resp->initiator_name);
-   return rc;
-}
-
-/**
  * beiscsi_get_port_state - Get the Port State
  * @shost : pointer to scsi_host structure
  *
@@ -772,7 +737,6 @@ static void beiscsi_get_port_speed(struct Scsi_Host *shost)
  * @param: parameter type identifier
  * @buf: buffer pointer
  *
- * returns host parameter
  */
 int beiscsi_get_host_param(struct Scsi_Host *shost,
   enum iscsi_host_param param, char *buf)
@@ -783,7 +747,7 @@ int beiscsi_get_host_param(struct Scsi_Host *shost,
if (!beiscsi_hba_is_online(phba)) {
beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
"BS_%d : HBA in error 0x%lx\n", phba->state);
-   return -EBUSY;
+   return 0;
}
beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
"BS_%d : In beiscsi_get_host_param, param = %d\n", param);
@@ -794,15 +758,15 @@ int beiscsi_get_host_param(struct Scsi_Host *shost,
if (status < 0) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BS_%d : beiscsi_get_macaddr Failed\n");
-   return status;
+   return 0;
}
break;
case ISCSI_HOST_PARAM_INITIATOR_NAME:
-   status = beiscsi_get_initname(buf, phba);
+   status = beiscsi_get_initiator_name(phba, buf);
if (status < 0) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BS_%d : Retreiving Initiator Name 
Failed\n");
-   return status;
+   return 0;
}
break;
case ISCSI_HOST_PARAM_PORT_STATE:
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 2117ac0..0c25c10 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -335,6 +335,35 @@ int beiscsi_modify_eq_delay(struct beiscsi_hba *phba,
 __beiscsi_eq_delay_compl, NULL, 0);
 }
 
+/**
+ * beiscsi_get_initiator_name - read initiator name from flash
+ * @phba: device priv structure
+ * @name: buffer pointer
+ *
+ */
+int beiscsi_get_initiator_name(struct beiscsi_hba *phba, char *name)
+{
+   struct be_dma_mem nonemb_cmd;
+   struct be_cmd_hba_name resp;
+   int rc;
+
+   rc = beiscsi_prep_nemb_cmd(phba, _cmd, CMD_SUBSYSTEM_ISCSI_INI,
+   OPCODE_ISCSI_INI_CFG_GET_HBA_NAME, sizeof(resp));
+   

[PATCH 00/10] be2iscsi: driver update 11.4.0.1

2017-10-10 Thread Jitendra Bhivare
This patch is generated against for-next branch.

Jitendra Bhivare (10):
  be2iscsi: Fix boot flags in sysfs
  be2iscsi: Fix return value in mgmt_open_connection
  be2iscsi: Free msi_name and disable HW intr
  be2iscsi: Fix _modify_eq_delay buffer overflow
  be2iscsi: Fix _get_initname buffer overflow
  be2iscsi: Modify IOCTL to fetch user configured IQN
  be2iscsi: Add cmd to set host data
  be2iscsi: Fix misc static analysis errors
  be2iscsi: Remove A-circumflex character in copyright marking
  scsi: be2iscsi: Update driver version

 drivers/scsi/be2iscsi/be.h   |  19 ++-
 drivers/scsi/be2iscsi/be_cmds.c  |  55 +++-
 drivers/scsi/be2iscsi/be_cmds.h  |  48 ---
 drivers/scsi/be2iscsi/be_iscsi.c |  54 ++--
 drivers/scsi/be2iscsi/be_iscsi.h |   2 +-
 drivers/scsi/be2iscsi/be_main.c  | 102 --
 drivers/scsi/be2iscsi/be_main.h  |  49 +--
 drivers/scsi/be2iscsi/be_mgmt.c  | 278 ++-
 drivers/scsi/be2iscsi/be_mgmt.h  |  10 +-
 9 files changed, 323 insertions(+), 294 deletions(-)

-- 
2.7.4



[PATCH 03/10] be2iscsi: Free msi_name and disable HW intr

2017-10-10 Thread Jitendra Bhivare
In beiscsi_dev_probe, allocated msi_name does not get freed and enabled
HW interrupts are not disabled in iscsi_host_add error case.

Add beiscsi_free_irqs fn to handle the cleanup in probe and disable port.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 47 ++---
 1 file changed, 30 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 56ae0f4..8f7e394 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -790,6 +790,24 @@ static irqreturn_t be_isr(int irq, void *dev_id)
return IRQ_HANDLED;
 }
 
+static void beiscsi_free_irqs(struct beiscsi_hba *phba)
+{
+   struct hwi_context_memory *phwi_context;
+   int i;
+
+   if (!phba->pcidev->msix_enabled) {
+   if (phba->pcidev->irq)
+   free_irq(phba->pcidev->irq, phba);
+   return;
+   }
+
+   phwi_context = phba->phwi_ctrlr->phwi_ctxt;
+   for (i = 0; i <= phba->num_cpus; i++) {
+   free_irq(pci_irq_vector(phba->pcidev, i),
+_context->be_eq[i]);
+   kfree(phba->msi_name[i]);
+   }
+}
 
 static int beiscsi_init_irqs(struct beiscsi_hba *phba)
 {
@@ -5396,15 +5414,7 @@ static void beiscsi_disable_port(struct beiscsi_hba 
*phba, int unload)
phwi_ctrlr = phba->phwi_ctrlr;
phwi_context = phwi_ctrlr->phwi_ctxt;
hwi_disable_intr(phba);
-   if (phba->pcidev->msix_enabled) {
-   for (i = 0; i <= phba->num_cpus; i++) {
-   free_irq(pci_irq_vector(phba->pcidev, i),
-   _context->be_eq[i]);
-   kfree(phba->msi_name[i]);
-   }
-   } else
-   if (phba->pcidev->irq)
-   free_irq(phba->pcidev->irq, phba);
+   beiscsi_free_irqs(phba);
pci_free_irq_vectors(phba->pcidev);
 
for (i = 0; i < phba->num_cpus; i++) {
@@ -5595,12 +5605,12 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
if (ret) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
"BM_%d : be_ctrl_init failed\n");
-   goto hba_free;
+   goto free_hba;
}
 
ret = beiscsi_init_sliport(phba);
if (ret)
-   goto hba_free;
+   goto free_hba;
 
spin_lock_init(>io_sgl_lock);
spin_lock_init(>mgmt_sgl_lock);
@@ -5680,13 +5690,13 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
"BM_%d : beiscsi_dev_probe-"
"Failed to beiscsi_init_irqs\n");
-   goto free_blkenbld;
+   goto disable_iopoll;
}
hwi_enable_intr(phba);
 
ret = iscsi_host_add(phba->shost, >pcidev->dev);
if (ret)
-   goto free_blkenbld;
+   goto free_irqs;
 
/* set online bit after port is operational */
set_bit(BEISCSI_HBA_ONLINE, >state);
@@ -5724,12 +5734,15 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
"\n\n\n BM_%d : SUCCESS - DRIVER LOADED\n\n\n");
return 0;
 
-free_blkenbld:
-   destroy_workqueue(phba->wq);
+free_irqs:
+   hwi_disable_intr(phba);
+   beiscsi_free_irqs(phba);
+disable_iopoll:
for (i = 0; i < phba->num_cpus; i++) {
pbe_eq = _context->be_eq[i];
irq_poll_disable(_eq->iopoll);
}
+   destroy_workqueue(phba->wq);
 free_twq:
hwi_cleanup_port(phba);
beiscsi_cleanup_port(phba);
@@ -5738,9 +5751,9 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
pci_free_consistent(phba->pcidev,
phba->ctrl.mbox_mem_alloced.size,
phba->ctrl.mbox_mem_alloced.va,
-  phba->ctrl.mbox_mem_alloced.dma);
+   phba->ctrl.mbox_mem_alloced.dma);
beiscsi_unmap_pci_function(phba);
-hba_free:
+free_hba:
pci_disable_msix(phba->pcidev);
pci_dev_put(phba->pcidev);
iscsi_host_free(phba->shost);
-- 
2.7.4



RE: [PATCH] be2iscsi: switch to pci_alloc_irq_vectors

2017-03-30 Thread Jitendra Bhivare
>  }
>
> @@ -5453,7 +5420,7 @@ static void beiscsi_disable_port(struct
beiscsi_hba
> *phba, int unload)
>   struct hwi_context_memory *phwi_context;
>   struct hwi_controller *phwi_ctrlr;
>   struct be_eq_obj *pbe_eq;
> - unsigned int i, msix_vec;
> + unsigned int i;
>
>   if (!test_and_clear_bit(BEISCSI_HBA_ONLINE, >state))
>   return;
> @@ -5461,16 +5428,16 @@ static void beiscsi_disable_port(struct
> beiscsi_hba *phba, int unload)
>   phwi_ctrlr = phba->phwi_ctrlr;
>   phwi_context = phwi_ctrlr->phwi_ctxt;
>   hwi_disable_intr(phba);
> - if (phba->msix_enabled) {
> + if (phba->pcidev->msix_enabled) {
>   for (i = 0; i <= phba->num_cpus; i++) {
> - msix_vec = phba->msix_entries[i].vector;
> - free_irq(msix_vec, _context->be_eq[i]);
> + free_irq(pci_irq_vector(phba->pcidev, i),
> + _context->be_eq[i]);
>   kfree(phba->msi_name[i]);
>   }
>   } else
>   if (phba->pcidev->irq)
>   free_irq(phba->pcidev->irq, phba);
> - pci_disable_msix(phba->pcidev);
> + pci_free_irq_vectors(phba->pcidev);
>
>   for (i = 0; i < phba->num_cpus; i++) {
>   pbe_eq = _context->be_eq[i];
> @@ -5680,21 +5647,12 @@ static int beiscsi_dev_probe(struct pci_dev
> *pcidev,
>   beiscsi_get_params(phba);
>   beiscsi_set_uer_feature(phba);
>
> - if (enable_msix)
> - find_num_cpus(phba);
> - else
> - phba->num_cpus = 1;
> + be2iscsi_enable_msix(phba);
>
>   beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
>   "BM_%d : num_cpus = %d\n",
>   phba->num_cpus);
>
> - if (enable_msix) {
> - beiscsi_msix_enable(phba);
> - if (!phba->msix_enabled)
> - phba->num_cpus = 1;
> - }
> -
>   phba->shost->max_id = phba->params.cxns_per_ctrl;
>   phba->shost->can_queue = phba->params.ios_per_ctrl;
>   ret = beiscsi_get_memory(phba);
> @@ -5744,7 +5702,7 @@ static int beiscsi_dev_probe(struct pci_dev
> *pcidev,
>   irq_poll_init(_eq->iopoll, be_iopoll_budget,
be_iopoll);
>   }
>
> - i = (phba->msix_enabled) ? i : 0;
> + i = (phba->pcidev->msix_enabled) ? i : 0;
>   /* Work item for MCC handling */
>   pbe_eq = _context->be_eq[i];
>   INIT_WORK(_eq->mcc_work, beiscsi_mcc_work); @@ -5815,8
> +5773,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
>  phba->ctrl.mbox_mem_alloced.dma);
>   beiscsi_unmap_pci_function(phba);
>  hba_free:
> - if (phba->msix_enabled)
> - pci_disable_msix(phba->pcidev);
> + pci_disable_msix(phba->pcidev);
>   pci_dev_put(phba->pcidev);
>   iscsi_host_free(phba->shost);
>   pci_set_drvdata(pcidev, NULL);
> diff --git a/drivers/scsi/be2iscsi/be_main.h
b/drivers/scsi/be2iscsi/be_main.h
> index 2188579..d1d03ee 100644
> --- a/drivers/scsi/be2iscsi/be_main.h
> +++ b/drivers/scsi/be2iscsi/be_main.h
> @@ -323,9 +323,7 @@ struct beiscsi_hba {
>   struct pci_dev *pcidev;
>   unsigned int num_cpus;
>   unsigned int nxt_cqid;
> - struct msix_entry msix_entries[MAX_CPUS];
>   char *msi_name[MAX_CPUS];
> - bool msix_enabled;
>   struct be_mem_descriptor *init_mem;
>
>   unsigned short io_sgl_alloc_index;
> --
> 2.1.4

Reviewed-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>


[PATCH v3 10/10] be2iscsi: Update driver version

2017-03-24 Thread Jitendra Bhivare
Version 11.4.0.0

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index c6b95dc..ee18a95 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -31,7 +31,7 @@
 #include 
 
 #define DRV_NAME   "be2iscsi"
-#define BUILD_STR  "11.2.1.0"
+#define BUILD_STR  "11.4.0.0"
 #define BE_NAME"Emulex OneConnect" \
"Open-iSCSI Driver version" BUILD_STR
 #define DRV_DESC   BE_NAME " " "Driver"
-- 
2.7.4



[PATCH v3 09/10] be2iscsi: Update Copyright

2017-03-24 Thread Jitendra Bhivare
Update Broadcom Copyright markings in all files.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be.h   | 11 ---
 drivers/scsi/be2iscsi/be_cmds.c  | 11 ---
 drivers/scsi/be2iscsi/be_cmds.h  | 11 ---
 drivers/scsi/be2iscsi/be_iscsi.c | 13 -
 drivers/scsi/be2iscsi/be_iscsi.h | 13 -
 drivers/scsi/be2iscsi/be_main.c  | 13 -
 drivers/scsi/be2iscsi/be_main.h  | 13 -
 drivers/scsi/be2iscsi/be_mgmt.c  | 13 -
 drivers/scsi/be2iscsi/be_mgmt.h  | 13 -
 9 files changed, 36 insertions(+), 75 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index 4dd8de4..55e3f8b 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -1,18 +1,15 @@
-/**
- * Copyright (C) 2005 - 2016 Broadcom
- * All rights reserved.
+/*
+ * Copyright 2017 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.  The full GNU General
+ * as published by the Free Software Foundation. The full GNU General
  * Public License is included in this distribution in the file called COPYING.
  *
  * Contact Information:
  * linux-driv...@broadcom.com
  *
- * Emulex
- *  Susan Street
- * Costa Mesa, CA 92626
  */
 
 #ifndef BEISCSI_H
diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index d14ddb2..a79a5e7 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -1,18 +1,15 @@
-/**
- * Copyright (C) 2005 - 2016 Broadcom
- * All rights reserved.
+/*
+ * Copyright 2017 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.  The full GNU General
+ * as published by the Free Software Foundation. The full GNU General
  * Public License is included in this distribution in the file called COPYING.
  *
  * Contact Information:
  * linux-driv...@broadcom.com
  *
- * Emulex
- *  Susan Street
- * Costa Mesa, CA 92626
  */
 
 #include 
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 88fe731..d9b6773 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -1,18 +1,15 @@
-/**
- * Copyright (C) 2005 - 2016 Broadcom
- * All rights reserved.
+/*
+ * Copyright 2017 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.  The full GNU General
+ * as published by the Free Software Foundation. The full GNU General
  * Public License is included in this distribution in the file called COPYING.
  *
  * Contact Information:
  * linux-driv...@broadcom.com
  *
- * Emulex
- *  Susan Street
- * Costa Mesa, CA 92626
  */
 
 #ifndef BEISCSI_CMDS_H
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index bad6b5e..97dca46 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -1,20 +1,15 @@
-/**
- * Copyright (C) 2005 - 2016 Broadcom
- * All rights reserved.
+/*
+ * Copyright 2017 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.  The full GNU General
+ * as published by the Free Software Foundation. The full GNU General
  * Public License is included in this distribution in the file called COPYING.
  *
- * Written by: Jayamohan Kallickal (jayamohan.kallic...@broadcom.com)
- *
  * Contact Information:
  * linux-driv...@broadcom.com
  *
- * Emulex
- *  Susan Street
- * Costa Mesa, CA 92626
  */
 
 #include 
diff --git a/drivers/scsi/be2iscsi/be_iscsi.h b/drivers/scsi/be2iscsi/be_iscsi.h
index e4d67df..b9d459a 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.h
+++ b/drivers/scsi/be2iscsi/be_iscsi.h
@@ -1,20 +1,15 @@
-/**
- * Copyright (C) 2005 - 2016 Broadcom
- * All rights reserved.
+/*
+ * Copyright 2017 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License version 2
- * as published by the Free Sof

[PATCH v3 07/10] be2iscsi: Remove free_list for ASYNC handles

2017-03-24 Thread Jitendra Bhivare
With previous patch adding ASYNC Rx buffers to free_list is not required.
Remove all free_list related operations.

Add in_use to track if buffer posted is being processed by driver and
purge all buffers received for connection if found so.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 99 +
 drivers/scsi/be2iscsi/be_main.h |  8 +---
 2 files changed, 43 insertions(+), 64 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 1cd9c2d..ee1f1c4 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1453,15 +1453,28 @@ static inline void
 beiscsi_hdl_put_handle(struct hd_async_context *pasync_ctx,
 struct hd_async_handle *pasync_handle)
 {
-   if (pasync_handle->is_header) {
-   list_add_tail(_handle->link,
-   _ctx->async_header.free_list);
-   pasync_ctx->async_header.free_entries++;
-   } else {
-   list_add_tail(_handle->link,
-   _ctx->async_data.free_list);
-   pasync_ctx->async_data.free_entries++;
-   }
+   pasync_handle->is_final = 0;
+   pasync_handle->buffer_len = 0;
+   pasync_handle->in_use = 0;
+   list_del_init(_handle->link);
+}
+
+static void
+beiscsi_hdl_purge_handles(struct beiscsi_hba *phba,
+ struct hd_async_context *pasync_ctx,
+ u16 cri)
+{
+   struct hd_async_handle *pasync_handle, *tmp_handle;
+   struct list_head *plist;
+
+   plist  = _ctx->async_entry[cri].wq.list;
+   list_for_each_entry_safe(pasync_handle, tmp_handle, plist, link)
+   beiscsi_hdl_put_handle(pasync_ctx, pasync_handle);
+
+   INIT_LIST_HEAD(_ctx->async_entry[cri].wq.list);
+   pasync_ctx->async_entry[cri].wq.hdr_len = 0;
+   pasync_ctx->async_entry[cri].wq.bytes_received = 0;
+   pasync_ctx->async_entry[cri].wq.bytes_needed = 0;
 }
 
 static struct hd_async_handle *
@@ -1473,11 +1486,12 @@ beiscsi_hdl_get_handle(struct beiscsi_conn 
*beiscsi_conn,
struct beiscsi_hba *phba = beiscsi_conn->phba;
struct hd_async_handle *pasync_handle;
struct be_bus_address phys_addr;
+   u16 cid, code, ci, cri;
u8 final, error = 0;
-   u16 cid, code, ci;
u32 dpl;
 
cid = beiscsi_conn->beiscsi_conn_cid;
+   cri = BE_GET_ASYNC_CRI_FROM_CID(cid);
/**
 * This function is invoked to get the right async_handle structure
 * from a given DEF PDU CQ entry.
@@ -1525,15 +1539,7 @@ beiscsi_hdl_get_handle(struct beiscsi_conn *beiscsi_conn,
break;
/* called only for above codes */
default:
-   pasync_handle = NULL;
-   break;
-   }
-
-   if (!pasync_handle) {
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_ISCSI,
-   "BM_%d : cid %d async PDU handle not found - code 
%d ci %d addr %llx\n",
-   cid, code, ci, phys_addr.u.a64.address);
-   return pasync_handle;
+   return NULL;
}
 
if (pasync_handle->pa.u.a64.address != phys_addr.u.a64.address ||
@@ -1549,44 +1555,33 @@ beiscsi_hdl_get_handle(struct beiscsi_conn 
*beiscsi_conn,
/* FW has stale address - attempt continuing by dropping */
}
 
-   list_del_init(_handle->link);
-   /**
-* Each CID is associated with unique CRI.
-* ASYNC_CRI_FROM_CID mapping and CRI_FROM_CID are totaly different.
-**/
-   pasync_handle->cri = BE_GET_ASYNC_CRI_FROM_CID(cid);
-   pasync_handle->is_final = final;
-   pasync_handle->buffer_len = dpl;
-
/**
 * DEF PDU header and data buffers with errors should be simply
 * dropped as there are no consumers for it.
 */
if (error) {
beiscsi_hdl_put_handle(pasync_ctx, pasync_handle);
-   pasync_handle = NULL;
+   return NULL;
}
-   return pasync_handle;
-}
-
-static void
-beiscsi_hdl_purge_handles(struct beiscsi_hba *phba,
- struct hd_async_context *pasync_ctx,
- u16 cri)
-{
-   struct hd_async_handle *pasync_handle, *tmp_handle;
-   struct list_head *plist;
 
-   plist  = _ctx->async_entry[cri].wq.list;
-   list_for_each_entry_safe(pasync_handle, tmp_handle, plist, link) {
-   list_del(_handle->link);
-   beiscsi_hdl_put_handle(pasync_ctx, pasync_handle);
+   if (pasync_handle->in_use || !list_empty(_handle->link)) {
+   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_ISCSI,
+   "BM_%d : cid %d async PDU handle in

[PATCH v3 05/10] be2iscsi: Increase HDQ default queue size

2017-03-24 Thread Jitendra Bhivare
Currently, ASYNC PDU default queue size is set to max connections.
This leaves only one buffer per connection for any ASYNC PDUs from
targets.

Double the size of the default queue.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 29 ++---
 drivers/scsi/be2iscsi/be_main.h |  4 +++-
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index ff48573..b76fd26 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -636,7 +636,6 @@ static void beiscsi_get_params(struct beiscsi_hba *phba)
(total_cid_count +
 BE2_TMFS + BE2_NOPOUT_REQ));
phba->params.cxns_per_ctrl = total_cid_count;
-   phba->params.asyncpdus_per_ctrl = total_cid_count;
phba->params.icds_per_ctrl = total_icd_count;
phba->params.num_sge_per_io = BE2_SGE;
phba->params.defpdu_hdr_sz = BE2_DEFPDU_HDR_SZ;
@@ -2407,22 +2406,22 @@ static void beiscsi_find_mem_req(struct beiscsi_hba 
*phba)
if (test_bit(ulp_num, >fw_config.ulp_supported)) {
 
num_async_pdu_buf_sgl_pages =
-   PAGES_REQUIRED(BEISCSI_GET_CID_COUNT(
+   PAGES_REQUIRED(BEISCSI_ASYNC_HDQ_SIZE(
   phba, ulp_num) *
   sizeof(struct phys_addr));
 
num_async_pdu_buf_pages =
-   PAGES_REQUIRED(BEISCSI_GET_CID_COUNT(
+   PAGES_REQUIRED(BEISCSI_ASYNC_HDQ_SIZE(
   phba, ulp_num) *
   phba->params.defpdu_hdr_sz);
 
num_async_pdu_data_pages =
-   PAGES_REQUIRED(BEISCSI_GET_CID_COUNT(
+   PAGES_REQUIRED(BEISCSI_ASYNC_HDQ_SIZE(
   phba, ulp_num) *
   phba->params.defpdu_data_sz);
 
num_async_pdu_data_sgl_pages =
-   PAGES_REQUIRED(BEISCSI_GET_CID_COUNT(
+   PAGES_REQUIRED(BEISCSI_ASYNC_HDQ_SIZE(
   phba, ulp_num) *
   sizeof(struct phys_addr));
 
@@ -2459,21 +2458,21 @@ static void beiscsi_find_mem_req(struct beiscsi_hba 
*phba)
mem_descr_index = (HWI_MEM_ASYNC_HEADER_HANDLE_ULP0 +
  (ulp_num * MEM_DESCR_OFFSET));
phba->mem_req[mem_descr_index] =
- BEISCSI_GET_CID_COUNT(phba, ulp_num) *
- sizeof(struct hd_async_handle);
+   BEISCSI_ASYNC_HDQ_SIZE(phba, ulp_num) *
+   sizeof(struct hd_async_handle);
 
mem_descr_index = (HWI_MEM_ASYNC_DATA_HANDLE_ULP0 +
  (ulp_num * MEM_DESCR_OFFSET));
phba->mem_req[mem_descr_index] =
- BEISCSI_GET_CID_COUNT(phba, ulp_num) *
- sizeof(struct hd_async_handle);
+   BEISCSI_ASYNC_HDQ_SIZE(phba, ulp_num) *
+   sizeof(struct hd_async_handle);
 
mem_descr_index = (HWI_MEM_ASYNC_PDU_CONTEXT_ULP0 +
  (ulp_num * MEM_DESCR_OFFSET));
phba->mem_req[mem_descr_index] =
- sizeof(struct hd_async_context) +
-(BEISCSI_GET_CID_COUNT(phba, ulp_num) *
- sizeof(struct hd_async_entry));
+   sizeof(struct hd_async_context) +
+   (BEISCSI_ASYNC_HDQ_SIZE(phba, ulp_num) *
+sizeof(struct hd_async_entry));
}
}
 }
@@ -2757,7 +2756,7 @@ static int hwi_init_async_pdu_ctx(struct beiscsi_hba 
*phba)
((long unsigned int)pasync_ctx +
sizeof(struct hd_async_context));
 
-   pasync_ctx->num_entries = BEISCSI_GET_CID_COUNT(phba,
+   pasync_ctx->num_entries = BEISCSI_ASYNC_HDQ_SIZE(phba,
  ulp_num);
/* setup header buffers */
mem_descr = (struct be_mem_descriptor *)phba->init_mem;
@@ -2895,7 +2894,7 @@ static int 

[PATCH v3 02/10] be2iscsi: Fix closing of connection

2017-03-24 Thread Jitendra Bhivare
CID needs to be freed even when invalidate or upload connection fails.
Attempt to close connection 3 times before freeing CID.

Set cleanup_type to INVALIDATE instead of force TCP_RST.
This unnecessarily is terminating connection with reset instead of
gracefully closing it.

Set save_cfg to 0 - session not to be saved on flash.

Add delay and process CQ before uploading connection.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be.h   |   1 -
 drivers/scsi/be2iscsi/be_cmds.h  |  63 +--
 drivers/scsi/be2iscsi/be_iscsi.c |  98 +-
 drivers/scsi/be2iscsi/be_mgmt.c  | 127 ---
 drivers/scsi/be2iscsi/be_mgmt.h  |  30 ++---
 5 files changed, 159 insertions(+), 160 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index ca9440f..4dd8de4 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -154,7 +154,6 @@ struct be_ctrl_info {
 #define PAGE_SHIFT_4K 12
 #define PAGE_SIZE_4K (1 << PAGE_SHIFT_4K)
 #define mcc_timeout12 /* 12s timeout */
-#define BEISCSI_LOGOUT_SYNC_DELAY  250
 
 /* Returns number of pages spanned by the data starting at the given addr */
 #define PAGES_4K_SPANNED(_address, size)   \
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 1d40e83..88fe731 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -1145,24 +1145,49 @@ struct tcp_connect_and_offload_out {
 #define DB_DEF_PDU_EVENT_SHIFT 15
 #define DB_DEF_PDU_CQPROC_SHIFT16
 
-struct dmsg_cqe {
-   u32 dw[4];
+struct be_invalidate_connection_params_in {
+   struct be_cmd_req_hdr hdr;
+   u32 session_handle;
+   u16 cid;
+   u16 unused;
+#define BE_CLEANUP_TYPE_INVALIDATE 0x8001
+#define BE_CLEANUP_TYPE_ISSUE_TCP_RST  0x8002
+   u16 cleanup_type;
+   u16 save_cfg;
+} __packed;
+
+struct be_invalidate_connection_params_out {
+   u32 session_handle;
+   u16 cid;
+   u16 unused;
 } __packed;
 
-struct tcp_upload_params_in {
+union be_invalidate_connection_params {
+   struct be_invalidate_connection_params_in req;
+   struct be_invalidate_connection_params_out resp;
+} __packed;
+
+struct be_tcp_upload_params_in {
struct be_cmd_req_hdr hdr;
u16 id;
+#define BE_UPLOAD_TYPE_GRACEFUL1
+/* abortive upload with reset */
+#define BE_UPLOAD_TYPE_ABORT_RESET 2
+/* abortive upload without reset */
+#define BE_UPLOAD_TYPE_ABORT   3
+/* abortive upload with reset, sequence number by driver */
+#define BE_UPLOAD_TYPE_ABORT_WITH_SEQ  4
u16 upload_type;
u32 reset_seq;
 } __packed;
 
-struct tcp_upload_params_out {
+struct be_tcp_upload_params_out {
u32 dw[32];
 } __packed;
 
-union tcp_upload_params {
-   struct tcp_upload_params_in request;
-   struct tcp_upload_params_out response;
+union be_tcp_upload_params {
+   struct be_tcp_upload_params_in request;
+   struct be_tcp_upload_params_out response;
 } __packed;
 
 struct be_ulp_fw_cfg {
@@ -1243,10 +1268,7 @@ struct be_cmd_get_port_name {
 #define OPCODE_COMMON_WRITE_FLASH  96
 #define OPCODE_COMMON_READ_FLASH   97
 
-/* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
 #define CMD_ISCSI_COMMAND_INVALIDATE   1
-#define CMD_ISCSI_CONNECTION_INVALIDATE0x8001
-#define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST 0x8002
 
 #define INI_WR_CMD 1   /* Initiator write command */
 #define INI_TMF_CMD2   /* Initiator TMF command */
@@ -1269,27 +1291,6 @@ struct be_cmd_get_port_name {
 *  preparedby
 * driver should not be touched
 */
-/* --- CMD_CHUTE_TYPE --- */
-#define CMD_CONNECTION_CHUTE_0 1
-#define CMD_CONNECTION_CHUTE_1 2
-#define CMD_CONNECTION_CHUTE_2 3
-
-#define EQ_MAJOR_CODE_COMPLETION   0
-
-#define CMD_ISCSI_SESSION_DEL_CFG_FROM_FLASH 0
-#define CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH 1
-
-/* --- CONNECTION_UPLOAD_PARAMS --- */
-/* These parameters are used to define the type of upload desired.  */
-#define CONNECTION_UPLOAD_GRACEFUL  1  /* Graceful upload  */
-#define CONNECTION_UPLOAD_ABORT_RESET   2  /* Abortive upload with
-* reset
-*/
-#define CONNECTION_UPLOAD_ABORT3   /* Abortive upload 
without
-* reset
-*/
-#define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset,
-* sequence numb

[PATCH v3 06/10] be2iscsi: Use num_cons field in Rx CQE

2017-03-24 Thread Jitendra Bhivare
FW runs out of buffer if buffers are not posted back soon.
ASYNC Rx CQE indicates that FW has consumed 8 RQEs.
Use it to post back buffers instead of waiting for buffers
to be processed and freed by driver.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 124 
 drivers/scsi/be2iscsi/be_main.h |   1 +
 2 files changed, 51 insertions(+), 74 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index b76fd26..1cd9c2d 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1467,7 +1467,8 @@ beiscsi_hdl_put_handle(struct hd_async_context 
*pasync_ctx,
 static struct hd_async_handle *
 beiscsi_hdl_get_handle(struct beiscsi_conn *beiscsi_conn,
   struct hd_async_context *pasync_ctx,
-  struct i_t_dpdu_cqe *pdpdu_cqe)
+  struct i_t_dpdu_cqe *pdpdu_cqe,
+  u8 *header)
 {
struct beiscsi_hba *phba = beiscsi_conn->phba;
struct hd_async_handle *pasync_handle;
@@ -1515,6 +1516,7 @@ beiscsi_hdl_get_handle(struct beiscsi_conn *beiscsi_conn,
switch (code) {
case UNSOL_HDR_NOTIFY:
pasync_handle = pasync_ctx->async_entry[ci].header;
+   *header = 1;
break;
case UNSOL_DATA_DIGEST_ERROR_NOTIFY:
error = 1;
@@ -1547,6 +1549,7 @@ beiscsi_hdl_get_handle(struct beiscsi_conn *beiscsi_conn,
/* FW has stale address - attempt continuing by dropping */
}
 
+   list_del_init(_handle->link);
/**
 * Each CID is associated with unique CRI.
 * ASYNC_CRI_FROM_CID mapping and CRI_FROM_CID are totaly different.
@@ -1554,11 +1557,6 @@ beiscsi_hdl_get_handle(struct beiscsi_conn *beiscsi_conn,
pasync_handle->cri = BE_GET_ASYNC_CRI_FROM_CID(cid);
pasync_handle->is_final = final;
pasync_handle->buffer_len = dpl;
-   /* empty the slot */
-   if (pasync_handle->is_header)
-   pasync_ctx->async_entry[ci].header = NULL;
-   else
-   pasync_ctx->async_entry[ci].data = NULL;
 
/**
 * DEF PDU header and data buffers with errors should be simply
@@ -1708,85 +1706,53 @@ beiscsi_hdl_gather_pdu(struct beiscsi_conn 
*beiscsi_conn,
 
 static void
 beiscsi_hdq_post_handles(struct beiscsi_hba *phba,
-u8 header, u8 ulp_num)
+u8 header, u8 ulp_num, u16 nbuf)
 {
-   struct hd_async_handle *pasync_handle, *tmp, **slot;
+   struct hd_async_handle *pasync_handle;
struct hd_async_context *pasync_ctx;
struct hwi_controller *phwi_ctrlr;
-   struct list_head *hfree_list;
struct phys_addr *pasync_sge;
u32 ring_id, doorbell = 0;
u32 doorbell_offset;
-   u16 prod = 0, cons;
-   u16 index;
+   u16 prod, pi;
 
phwi_ctrlr = phba->phwi_ctrlr;
pasync_ctx = HWI_GET_ASYNC_PDU_CTX(phwi_ctrlr, ulp_num);
if (header) {
-   cons = pasync_ctx->async_header.free_entries;
-   hfree_list = _ctx->async_header.free_list;
+   pasync_sge = pasync_ctx->async_header.ring_base;
+   pi = pasync_ctx->async_header.pi;
ring_id = phwi_ctrlr->default_pdu_hdr[ulp_num].id;
doorbell_offset = phwi_ctrlr->default_pdu_hdr[ulp_num].
doorbell_offset;
} else {
-   cons = pasync_ctx->async_data.free_entries;
-   hfree_list = _ctx->async_data.free_list;
+   pasync_sge = pasync_ctx->async_data.ring_base;
+   pi = pasync_ctx->async_data.pi;
ring_id = phwi_ctrlr->default_pdu_data[ulp_num].id;
doorbell_offset = phwi_ctrlr->default_pdu_data[ulp_num].
doorbell_offset;
}
-   /* number of entries posted must be in multiples of 8 */
-   if (cons % 8)
-   return;
 
-   list_for_each_entry_safe(pasync_handle, tmp, hfree_list, link) {
-   list_del_init(_handle->link);
-   pasync_handle->is_final = 0;
-   pasync_handle->buffer_len = 0;
-
-   /* handles can be consumed out of order, use index in handle */
-   index = pasync_handle->index;
-   WARN_ON(pasync_handle->is_header != header);
+   for (prod = 0; prod < nbuf; prod++) {
if (header)
-   slot = _ctx->async_entry[index].header;
+   pasync_handle = pasync_ctx->async_entry[pi].header;
else
-   slot = _ctx->async_entry[index].data;
-   /**
-* The slot just tracks handle's hold and release, so
-

[PATCH v3 00/10] be2iscsi: driver update 11.4.0.0

2017-03-24 Thread Jitendra Bhivare
This patch is generated against for-next branch.

v3 changes:
 be2iscsi: Fix closing of connection
- Fixed per Tomas's review comments.

v2 changes:
 +be2iscsi: Update Copyright

Jitendra Bhivare (10):
  be2iscsi: Check tag in beiscsi_mccq_compl_wait
  be2iscsi: Fix closing of connection
  be2iscsi: Replace spin_unlock_bh with spin_lock
  scsi_transport_iscsi: Use flush_work in iscsi_remove_session
  be2iscsi: Increase HDQ default queue size
  be2iscsi: Use num_cons field in Rx CQE
  be2iscsi: Remove free_list for ASYNC handles
  be2iscsi: Check size before copying ASYNC handle
  be2iscsi: Update Copyright
  be2iscsi: Update driver version

 drivers/scsi/be2iscsi/be.h  |  12 +-
 drivers/scsi/be2iscsi/be_cmds.c |  17 ++-
 drivers/scsi/be2iscsi/be_cmds.h |  74 +-
 drivers/scsi/be2iscsi/be_iscsi.c| 111 ---
 drivers/scsi/be2iscsi/be_iscsi.h|  13 +-
 drivers/scsi/be2iscsi/be_main.c | 270 +++-
 drivers/scsi/be2iscsi/be_main.h |  28 ++--
 drivers/scsi/be2iscsi/be_mgmt.c | 140 +--
 drivers/scsi/be2iscsi/be_mgmt.h |  43 ++
 drivers/scsi/scsi_transport_iscsi.c |   3 +-
 10 files changed, 319 insertions(+), 392 deletions(-)

-- 
2.7.4



[PATCH v3 08/10] be2iscsi: Check size before copying ASYNC handle

2017-03-24 Thread Jitendra Bhivare
Data in buffers are gathered into a single buffer before giving to
iSCSI layer. Though less likely to have payload more than 8K in
ASYNC PDU, the data length is provide by FW and check is missing
for overrun.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index ee1f1c4..4b668c4 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1611,6 +1611,10 @@ beiscsi_hdl_fwd_pdu(struct beiscsi_conn *beiscsi_conn,
dlen = pasync_handle->buffer_len;
continue;
}
+   if (!pasync_handle->buffer_len ||
+   (dlen + pasync_handle->buffer_len) >
+   pasync_ctx->async_data.buffer_size)
+   break;
memcpy(pdata + dlen, pasync_handle->pbuffer,
   pasync_handle->buffer_len);
dlen += pasync_handle->buffer_len;
@@ -1619,8 +1623,9 @@ beiscsi_hdl_fwd_pdu(struct beiscsi_conn *beiscsi_conn,
if (!plast_handle->is_final) {
/* last handle should have final PDU notification from FW */
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_ISCSI,
-   "BM_%d : cid %u %p fwd async PDU with last handle 
missing - HL%u:DN%u:DR%u\n",
+   "BM_%d : cid %u %p fwd async PDU opcode %x with 
last handle missing - HL%u:DN%u:DR%u\n",
beiscsi_conn->beiscsi_conn_cid, plast_handle,
+   AMAP_GET_BITS(struct amap_pdu_base, opcode, phdr),
pasync_ctx->async_entry[cri].wq.hdr_len,
pasync_ctx->async_entry[cri].wq.bytes_needed,
pasync_ctx->async_entry[cri].wq.bytes_received);
-- 
2.7.4



[PATCH v3 03/10] be2iscsi: Replace spin_unlock_bh with spin_lock

2017-03-24 Thread Jitendra Bhivare
spin_unlock_bh back_lock is used in beiscsi_eh_device_reset instead of
spin_lock.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
Reviewed-by: Tomas Henzl <the...@redhat.com> tomash
---
 drivers/scsi/be2iscsi/be_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 32b2713..ff48573 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -337,7 +337,7 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
inv_tbl->task[nents] = task;
nents++;
}
-   spin_unlock_bh(>back_lock);
+   spin_unlock(>back_lock);
spin_unlock_bh(>frwd_lock);
 
rc = SUCCESS;
-- 
2.7.4



[PATCH v3 01/10] be2iscsi: Check tag in beiscsi_mccq_compl_wait

2017-03-24 Thread Jitendra Bhivare
scsi host12: BS_1377 : mgmt_invalidate_connection Failed for cid=256
BUG: unable to handle kernel NULL pointer dereference at 0008
IP: [] __list_add+0xf/0xc0
PGD 0
Oops:  [#1] SMP
Modules linked in:
...
CPU: 9 PID: 1542 Comm: iscsid Tainted: G    T 
3.10.0-514.el7.x86_64 #1
Hardware name: HP ProLiant DL360 Gen9/ProLiant DL360 Gen9, BIOS P89 09/12/2016
task: 88076f310fb0 ti: 88076bba8000 task.ti: 88076bba8000
RIP: 0010:[]  [] __list_add+0xf/0xc0
RSP: 0018:88076bbab8e8  EFLAGS: 00010046
RAX: 0246 RBX: 88076bbab990 RCX: 
RDX:  RSI: 880468badf58 RDI: 88076bbab990
RBP: 88076bbab900 R08: 0246 R09: 20de
R10:  R11: 88076bbab5be R12: 
R13: 880468badf58 R14: 0001adb0 R15: 88076f310fb0
FS:  7f377124a880() GS:88046fa4() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 0008 CR3: 000771318000 CR4: 001407e0
DR0:  DR1:  DR2: 
DR3:  DR6: 0ff0 DR7: 0400
Stack:
88076bbab990 880468badf50 0001 88076bbab938
810b128b 0246 cf9b7040 880468bac7a0
 880468bac7a0 88076bbab9d0 a05a6ea3

Call Trace:
[] prepare_to_wait+0x7b/0x90
[] beiscsi_mccq_compl_wait+0x153/0x330 [be2iscsi]
[] ? wake_up_atomic_t+0x30/0x30
[] beiscsi_ep_disconnect+0x91/0x2d0 [be2iscsi]
[] iscsi_if_ep_disconnect.isra.14+0x5a/0x70 
[scsi_transport_iscsi]
[] iscsi_if_recv_msg+0x113b/0x14a0 [scsi_transport_iscsi]
[] ? __kmalloc_node_track_caller+0x58/0x290
[] iscsi_if_rx+0x8e/0x1f0 [scsi_transport_iscsi]
[] netlink_unicast+0xed/0x1b0
[] netlink_sendmsg+0x31e/0x690
[] ? netlink_rcv_wake+0x44/0x60
[] ? netlink_recvmsg+0x1e3/0x450

beiscsi_mccq_compl_wait gets called even when MCC tag allocation failed
for mgmt_invalidate_connection.
mcc_wait is not initialized for tag 0 so causes crash in prepare_to_wait.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
Reviewed-by: Tomas Henzl <the...@redhat.com> tomash
---
 drivers/scsi/be2iscsi/be_cmds.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 5d59e263..d14ddb2 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -246,6 +246,12 @@ int beiscsi_mccq_compl_wait(struct beiscsi_hba *phba,
 {
int rc = 0;
 
+   if (!tag || tag > MAX_MCC_CMD) {
+   __beiscsi_log(phba, KERN_ERR,
+ "BC_%d : invalid tag %u\n", tag);
+   return -EINVAL;
+   }
+
if (beiscsi_hba_in_error(phba)) {
clear_bit(MCC_TAG_STATE_RUNNING,
  >ctrl.ptag_state[tag].tag_state);
-- 
2.7.4



[PATCH v3 04/10] scsi_transport_iscsi: Use flush_work in iscsi_remove_session

2017-03-24 Thread Jitendra Bhivare
scsi_flush_work flushes workqueue for the Scsi_Host.
In iSCSI offload enabled host, this would wait for all other
sessions under the host.

Use flush_work for the session being removed instead.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/scsi_transport_iscsi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c 
b/drivers/scsi/scsi_transport_iscsi.c
index 568c9f2..a424eae 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -2158,7 +2158,6 @@ static int iscsi_iter_destroy_conn_fn(struct device *dev, 
void *data)
 
 void iscsi_remove_session(struct iscsi_cls_session *session)
 {
-   struct Scsi_Host *shost = iscsi_session_to_shost(session);
unsigned long flags;
int err;
 
@@ -2185,7 +2184,7 @@ void iscsi_remove_session(struct iscsi_cls_session 
*session)
 
scsi_target_unblock(>dev, SDEV_TRANSPORT_OFFLINE);
/* flush running scans then delete devices */
-   scsi_flush_work(shost);
+   flush_work(>scan_work);
__iscsi_unbind_session(>unbind_work);
 
/* hw iscsi may not have removed all connections from session */
-- 
2.7.4



RE: [PATCH v2 02/10] be2iscsi: Fix closing of connection

2017-03-24 Thread Jitendra Bhivare
> > +   attempts = 0;
> > +   while (attempts++ < 3) {
> > +   tag = beiscsi_invalidate_cxn(phba, beiscsi_ep);
> > +   if (tag) {
> > +   ret = beiscsi_mccq_compl_wait(phba, tag, NULL,
> NULL);
> > +   if (!ret)
> > +   break;
> > +   beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
> > +   "BS_%d : invalidate conn failed cid
%d\n",
> > +   beiscsi_ep->ep_cid);
> > +   }
> > }
> >
> > -   ret = beiscsi_mccq_compl_wait(phba, tag, NULL, NULL);
> > -
> > -   /* Flush the CQ entries */
> > +   /* wait for all completions to arrive, then process them */
> > +   msleep(250);
> > +   /* flush CQ entries */
> > beiscsi_flush_cq(phba);
> >
> > -   return ret;
> > +   if (attempts == 3)
>
> Hi Jitendra,
> when attempts is updated after a '< 3' test, then I think that the test
here
> should be changed to 'if (attempts > 3)'
> tomash
>
[JB] Thanks for reviewing Tomas.
My bad, made some last minute changes to it. Will re-send the series.


[PATCH v2 02/10] be2iscsi: Fix closing of connection

2017-03-15 Thread Jitendra Bhivare
CID needs to be freed even when invalidate or upload connection fails.
Attempt to close connection 3 times before freeing CID.

Set cleanup_type to INVALIDATE instead of force TCP_RST.
This unnecessarily is terminating connection with reset instead of
gracefully closing it.

Set save_cfg to 0 - session not to be saved on flash.

Add delay and process CQ before uploading connection.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be.h   |   1 -
 drivers/scsi/be2iscsi/be_cmds.h  |  63 +--
 drivers/scsi/be2iscsi/be_iscsi.c |  98 +-
 drivers/scsi/be2iscsi/be_mgmt.c  | 127 ---
 drivers/scsi/be2iscsi/be_mgmt.h  |  30 ++---
 5 files changed, 159 insertions(+), 160 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index ca9440f..4dd8de4 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -154,7 +154,6 @@ struct be_ctrl_info {
 #define PAGE_SHIFT_4K 12
 #define PAGE_SIZE_4K (1 << PAGE_SHIFT_4K)
 #define mcc_timeout12 /* 12s timeout */
-#define BEISCSI_LOGOUT_SYNC_DELAY  250
 
 /* Returns number of pages spanned by the data starting at the given addr */
 #define PAGES_4K_SPANNED(_address, size)   \
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 1d40e83..88fe731 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -1145,24 +1145,49 @@ struct tcp_connect_and_offload_out {
 #define DB_DEF_PDU_EVENT_SHIFT 15
 #define DB_DEF_PDU_CQPROC_SHIFT16
 
-struct dmsg_cqe {
-   u32 dw[4];
+struct be_invalidate_connection_params_in {
+   struct be_cmd_req_hdr hdr;
+   u32 session_handle;
+   u16 cid;
+   u16 unused;
+#define BE_CLEANUP_TYPE_INVALIDATE 0x8001
+#define BE_CLEANUP_TYPE_ISSUE_TCP_RST  0x8002
+   u16 cleanup_type;
+   u16 save_cfg;
+} __packed;
+
+struct be_invalidate_connection_params_out {
+   u32 session_handle;
+   u16 cid;
+   u16 unused;
 } __packed;
 
-struct tcp_upload_params_in {
+union be_invalidate_connection_params {
+   struct be_invalidate_connection_params_in req;
+   struct be_invalidate_connection_params_out resp;
+} __packed;
+
+struct be_tcp_upload_params_in {
struct be_cmd_req_hdr hdr;
u16 id;
+#define BE_UPLOAD_TYPE_GRACEFUL1
+/* abortive upload with reset */
+#define BE_UPLOAD_TYPE_ABORT_RESET 2
+/* abortive upload without reset */
+#define BE_UPLOAD_TYPE_ABORT   3
+/* abortive upload with reset, sequence number by driver */
+#define BE_UPLOAD_TYPE_ABORT_WITH_SEQ  4
u16 upload_type;
u32 reset_seq;
 } __packed;
 
-struct tcp_upload_params_out {
+struct be_tcp_upload_params_out {
u32 dw[32];
 } __packed;
 
-union tcp_upload_params {
-   struct tcp_upload_params_in request;
-   struct tcp_upload_params_out response;
+union be_tcp_upload_params {
+   struct be_tcp_upload_params_in request;
+   struct be_tcp_upload_params_out response;
 } __packed;
 
 struct be_ulp_fw_cfg {
@@ -1243,10 +1268,7 @@ struct be_cmd_get_port_name {
 #define OPCODE_COMMON_WRITE_FLASH  96
 #define OPCODE_COMMON_READ_FLASH   97
 
-/* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
 #define CMD_ISCSI_COMMAND_INVALIDATE   1
-#define CMD_ISCSI_CONNECTION_INVALIDATE0x8001
-#define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST 0x8002
 
 #define INI_WR_CMD 1   /* Initiator write command */
 #define INI_TMF_CMD2   /* Initiator TMF command */
@@ -1269,27 +1291,6 @@ struct be_cmd_get_port_name {
 *  preparedby
 * driver should not be touched
 */
-/* --- CMD_CHUTE_TYPE --- */
-#define CMD_CONNECTION_CHUTE_0 1
-#define CMD_CONNECTION_CHUTE_1 2
-#define CMD_CONNECTION_CHUTE_2 3
-
-#define EQ_MAJOR_CODE_COMPLETION   0
-
-#define CMD_ISCSI_SESSION_DEL_CFG_FROM_FLASH 0
-#define CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH 1
-
-/* --- CONNECTION_UPLOAD_PARAMS --- */
-/* These parameters are used to define the type of upload desired.  */
-#define CONNECTION_UPLOAD_GRACEFUL  1  /* Graceful upload  */
-#define CONNECTION_UPLOAD_ABORT_RESET   2  /* Abortive upload with
-* reset
-*/
-#define CONNECTION_UPLOAD_ABORT3   /* Abortive upload 
without
-* reset
-*/
-#define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset,
-* sequence numb

[PATCH v2 07/10] be2iscsi: Remove free_list for ASYNC handles

2017-03-15 Thread Jitendra Bhivare
With previous patch adding ASYNC Rx buffers to free_list is not required.
Remove all free_list related operations.

Add in_use to track if buffer posted is being processed by driver and
purge all buffers received for connection if found so.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 99 +
 drivers/scsi/be2iscsi/be_main.h |  8 +---
 2 files changed, 43 insertions(+), 64 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 1cd9c2d..ee1f1c4 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1453,15 +1453,28 @@ static inline void
 beiscsi_hdl_put_handle(struct hd_async_context *pasync_ctx,
 struct hd_async_handle *pasync_handle)
 {
-   if (pasync_handle->is_header) {
-   list_add_tail(_handle->link,
-   _ctx->async_header.free_list);
-   pasync_ctx->async_header.free_entries++;
-   } else {
-   list_add_tail(_handle->link,
-   _ctx->async_data.free_list);
-   pasync_ctx->async_data.free_entries++;
-   }
+   pasync_handle->is_final = 0;
+   pasync_handle->buffer_len = 0;
+   pasync_handle->in_use = 0;
+   list_del_init(_handle->link);
+}
+
+static void
+beiscsi_hdl_purge_handles(struct beiscsi_hba *phba,
+ struct hd_async_context *pasync_ctx,
+ u16 cri)
+{
+   struct hd_async_handle *pasync_handle, *tmp_handle;
+   struct list_head *plist;
+
+   plist  = _ctx->async_entry[cri].wq.list;
+   list_for_each_entry_safe(pasync_handle, tmp_handle, plist, link)
+   beiscsi_hdl_put_handle(pasync_ctx, pasync_handle);
+
+   INIT_LIST_HEAD(_ctx->async_entry[cri].wq.list);
+   pasync_ctx->async_entry[cri].wq.hdr_len = 0;
+   pasync_ctx->async_entry[cri].wq.bytes_received = 0;
+   pasync_ctx->async_entry[cri].wq.bytes_needed = 0;
 }
 
 static struct hd_async_handle *
@@ -1473,11 +1486,12 @@ beiscsi_hdl_get_handle(struct beiscsi_conn 
*beiscsi_conn,
struct beiscsi_hba *phba = beiscsi_conn->phba;
struct hd_async_handle *pasync_handle;
struct be_bus_address phys_addr;
+   u16 cid, code, ci, cri;
u8 final, error = 0;
-   u16 cid, code, ci;
u32 dpl;
 
cid = beiscsi_conn->beiscsi_conn_cid;
+   cri = BE_GET_ASYNC_CRI_FROM_CID(cid);
/**
 * This function is invoked to get the right async_handle structure
 * from a given DEF PDU CQ entry.
@@ -1525,15 +1539,7 @@ beiscsi_hdl_get_handle(struct beiscsi_conn *beiscsi_conn,
break;
/* called only for above codes */
default:
-   pasync_handle = NULL;
-   break;
-   }
-
-   if (!pasync_handle) {
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_ISCSI,
-   "BM_%d : cid %d async PDU handle not found - code 
%d ci %d addr %llx\n",
-   cid, code, ci, phys_addr.u.a64.address);
-   return pasync_handle;
+   return NULL;
}
 
if (pasync_handle->pa.u.a64.address != phys_addr.u.a64.address ||
@@ -1549,44 +1555,33 @@ beiscsi_hdl_get_handle(struct beiscsi_conn 
*beiscsi_conn,
/* FW has stale address - attempt continuing by dropping */
}
 
-   list_del_init(_handle->link);
-   /**
-* Each CID is associated with unique CRI.
-* ASYNC_CRI_FROM_CID mapping and CRI_FROM_CID are totaly different.
-**/
-   pasync_handle->cri = BE_GET_ASYNC_CRI_FROM_CID(cid);
-   pasync_handle->is_final = final;
-   pasync_handle->buffer_len = dpl;
-
/**
 * DEF PDU header and data buffers with errors should be simply
 * dropped as there are no consumers for it.
 */
if (error) {
beiscsi_hdl_put_handle(pasync_ctx, pasync_handle);
-   pasync_handle = NULL;
+   return NULL;
}
-   return pasync_handle;
-}
-
-static void
-beiscsi_hdl_purge_handles(struct beiscsi_hba *phba,
- struct hd_async_context *pasync_ctx,
- u16 cri)
-{
-   struct hd_async_handle *pasync_handle, *tmp_handle;
-   struct list_head *plist;
 
-   plist  = _ctx->async_entry[cri].wq.list;
-   list_for_each_entry_safe(pasync_handle, tmp_handle, plist, link) {
-   list_del(_handle->link);
-   beiscsi_hdl_put_handle(pasync_ctx, pasync_handle);
+   if (pasync_handle->in_use || !list_empty(_handle->link)) {
+   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_ISCSI,
+   "BM_%d : cid %d async PDU handle in

[PATCH v2 06/10] be2iscsi: Use num_cons field in Rx CQE

2017-03-15 Thread Jitendra Bhivare
FW runs out of buffer if buffers are not posted back soon.
ASYNC Rx CQE indicates that FW has consumed 8 RQEs.
Use it to post back buffers instead of waiting for buffers
to be processed and freed by driver.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 124 
 drivers/scsi/be2iscsi/be_main.h |   1 +
 2 files changed, 51 insertions(+), 74 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index b76fd26..1cd9c2d 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1467,7 +1467,8 @@ beiscsi_hdl_put_handle(struct hd_async_context 
*pasync_ctx,
 static struct hd_async_handle *
 beiscsi_hdl_get_handle(struct beiscsi_conn *beiscsi_conn,
   struct hd_async_context *pasync_ctx,
-  struct i_t_dpdu_cqe *pdpdu_cqe)
+  struct i_t_dpdu_cqe *pdpdu_cqe,
+  u8 *header)
 {
struct beiscsi_hba *phba = beiscsi_conn->phba;
struct hd_async_handle *pasync_handle;
@@ -1515,6 +1516,7 @@ beiscsi_hdl_get_handle(struct beiscsi_conn *beiscsi_conn,
switch (code) {
case UNSOL_HDR_NOTIFY:
pasync_handle = pasync_ctx->async_entry[ci].header;
+   *header = 1;
break;
case UNSOL_DATA_DIGEST_ERROR_NOTIFY:
error = 1;
@@ -1547,6 +1549,7 @@ beiscsi_hdl_get_handle(struct beiscsi_conn *beiscsi_conn,
/* FW has stale address - attempt continuing by dropping */
}
 
+   list_del_init(_handle->link);
/**
 * Each CID is associated with unique CRI.
 * ASYNC_CRI_FROM_CID mapping and CRI_FROM_CID are totaly different.
@@ -1554,11 +1557,6 @@ beiscsi_hdl_get_handle(struct beiscsi_conn *beiscsi_conn,
pasync_handle->cri = BE_GET_ASYNC_CRI_FROM_CID(cid);
pasync_handle->is_final = final;
pasync_handle->buffer_len = dpl;
-   /* empty the slot */
-   if (pasync_handle->is_header)
-   pasync_ctx->async_entry[ci].header = NULL;
-   else
-   pasync_ctx->async_entry[ci].data = NULL;
 
/**
 * DEF PDU header and data buffers with errors should be simply
@@ -1708,85 +1706,53 @@ beiscsi_hdl_gather_pdu(struct beiscsi_conn 
*beiscsi_conn,
 
 static void
 beiscsi_hdq_post_handles(struct beiscsi_hba *phba,
-u8 header, u8 ulp_num)
+u8 header, u8 ulp_num, u16 nbuf)
 {
-   struct hd_async_handle *pasync_handle, *tmp, **slot;
+   struct hd_async_handle *pasync_handle;
struct hd_async_context *pasync_ctx;
struct hwi_controller *phwi_ctrlr;
-   struct list_head *hfree_list;
struct phys_addr *pasync_sge;
u32 ring_id, doorbell = 0;
u32 doorbell_offset;
-   u16 prod = 0, cons;
-   u16 index;
+   u16 prod, pi;
 
phwi_ctrlr = phba->phwi_ctrlr;
pasync_ctx = HWI_GET_ASYNC_PDU_CTX(phwi_ctrlr, ulp_num);
if (header) {
-   cons = pasync_ctx->async_header.free_entries;
-   hfree_list = _ctx->async_header.free_list;
+   pasync_sge = pasync_ctx->async_header.ring_base;
+   pi = pasync_ctx->async_header.pi;
ring_id = phwi_ctrlr->default_pdu_hdr[ulp_num].id;
doorbell_offset = phwi_ctrlr->default_pdu_hdr[ulp_num].
doorbell_offset;
} else {
-   cons = pasync_ctx->async_data.free_entries;
-   hfree_list = _ctx->async_data.free_list;
+   pasync_sge = pasync_ctx->async_data.ring_base;
+   pi = pasync_ctx->async_data.pi;
ring_id = phwi_ctrlr->default_pdu_data[ulp_num].id;
doorbell_offset = phwi_ctrlr->default_pdu_data[ulp_num].
doorbell_offset;
}
-   /* number of entries posted must be in multiples of 8 */
-   if (cons % 8)
-   return;
 
-   list_for_each_entry_safe(pasync_handle, tmp, hfree_list, link) {
-   list_del_init(_handle->link);
-   pasync_handle->is_final = 0;
-   pasync_handle->buffer_len = 0;
-
-   /* handles can be consumed out of order, use index in handle */
-   index = pasync_handle->index;
-   WARN_ON(pasync_handle->is_header != header);
+   for (prod = 0; prod < nbuf; prod++) {
if (header)
-   slot = _ctx->async_entry[index].header;
+   pasync_handle = pasync_ctx->async_entry[pi].header;
else
-   slot = _ctx->async_entry[index].data;
-   /**
-* The slot just tracks handle's hold and release, so
-

[PATCH v2 09/10] be2iscsi: Update Copyright

2017-03-15 Thread Jitendra Bhivare
Update Broadcom Copyright markings in all files.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be.h   | 11 ---
 drivers/scsi/be2iscsi/be_cmds.c  | 11 ---
 drivers/scsi/be2iscsi/be_cmds.h  | 11 ---
 drivers/scsi/be2iscsi/be_iscsi.c | 13 -
 drivers/scsi/be2iscsi/be_iscsi.h | 13 -
 drivers/scsi/be2iscsi/be_main.c  | 13 -
 drivers/scsi/be2iscsi/be_main.h  | 13 -
 drivers/scsi/be2iscsi/be_mgmt.c  | 13 -
 drivers/scsi/be2iscsi/be_mgmt.h  | 13 -
 9 files changed, 36 insertions(+), 75 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index 4dd8de4..55e3f8b 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -1,18 +1,15 @@
-/**
- * Copyright (C) 2005 - 2016 Broadcom
- * All rights reserved.
+/*
+ * Copyright??2017 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.  The full GNU General
+ * as published by the Free Software Foundation. The full GNU General
  * Public License is included in this distribution in the file called COPYING.
  *
  * Contact Information:
  * linux-driv...@broadcom.com
  *
- * Emulex
- *  Susan Street
- * Costa Mesa, CA 92626
  */
 
 #ifndef BEISCSI_H
diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index d14ddb2..a79a5e7 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -1,18 +1,15 @@
-/**
- * Copyright (C) 2005 - 2016 Broadcom
- * All rights reserved.
+/*
+ * Copyright??2017 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.  The full GNU General
+ * as published by the Free Software Foundation. The full GNU General
  * Public License is included in this distribution in the file called COPYING.
  *
  * Contact Information:
  * linux-driv...@broadcom.com
  *
- * Emulex
- *  Susan Street
- * Costa Mesa, CA 92626
  */
 
 #include 
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 88fe731..d9b6773 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -1,18 +1,15 @@
-/**
- * Copyright (C) 2005 - 2016 Broadcom
- * All rights reserved.
+/*
+ * Copyright??2017 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.  The full GNU General
+ * as published by the Free Software Foundation. The full GNU General
  * Public License is included in this distribution in the file called COPYING.
  *
  * Contact Information:
  * linux-driv...@broadcom.com
  *
- * Emulex
- *  Susan Street
- * Costa Mesa, CA 92626
  */
 
 #ifndef BEISCSI_CMDS_H
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 2af714f..2e47b49 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -1,20 +1,15 @@
-/**
- * Copyright (C) 2005 - 2016 Broadcom
- * All rights reserved.
+/*
+ * Copyright??2017 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.  The full GNU General
+ * as published by the Free Software Foundation. The full GNU General
  * Public License is included in this distribution in the file called COPYING.
  *
- * Written by: Jayamohan Kallickal (jayamohan.kallic...@broadcom.com)
- *
  * Contact Information:
  * linux-driv...@broadcom.com
  *
- * Emulex
- *  Susan Street
- * Costa Mesa, CA 92626
  */
 
 #include 
diff --git a/drivers/scsi/be2iscsi/be_iscsi.h b/drivers/scsi/be2iscsi/be_iscsi.h
index e4d67df..b9d459a 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.h
+++ b/drivers/scsi/be2iscsi/be_iscsi.h
@@ -1,20 +1,15 @@
-/**
- * Copyright (C) 2005 - 2016 Broadcom
- * All rights reserved.
+/*
+ * Copyright??2017 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License version 2
- * as publishe

[PATCH v2 03/10] be2iscsi: Replace spin_unlock_bh with spin_lock

2017-03-15 Thread Jitendra Bhivare
spin_unlock_bh back_lock is used in beiscsi_eh_device_reset instead of
spin_lock.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 32b2713..ff48573 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -337,7 +337,7 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
inv_tbl->task[nents] = task;
nents++;
}
-   spin_unlock_bh(>back_lock);
+   spin_unlock(>back_lock);
spin_unlock_bh(>frwd_lock);
 
rc = SUCCESS;
-- 
2.7.4



[PATCH v2 05/10] be2iscsi: Increase HDQ default queue size

2017-03-15 Thread Jitendra Bhivare
Currently, ASYNC PDU default queue size is set to max connections.
This leaves only one buffer per connection for any ASYNC PDUs from
targets.

Double the size of the default queue.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 29 ++---
 drivers/scsi/be2iscsi/be_main.h |  4 +++-
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index ff48573..b76fd26 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -636,7 +636,6 @@ static void beiscsi_get_params(struct beiscsi_hba *phba)
(total_cid_count +
 BE2_TMFS + BE2_NOPOUT_REQ));
phba->params.cxns_per_ctrl = total_cid_count;
-   phba->params.asyncpdus_per_ctrl = total_cid_count;
phba->params.icds_per_ctrl = total_icd_count;
phba->params.num_sge_per_io = BE2_SGE;
phba->params.defpdu_hdr_sz = BE2_DEFPDU_HDR_SZ;
@@ -2407,22 +2406,22 @@ static void beiscsi_find_mem_req(struct beiscsi_hba 
*phba)
if (test_bit(ulp_num, >fw_config.ulp_supported)) {
 
num_async_pdu_buf_sgl_pages =
-   PAGES_REQUIRED(BEISCSI_GET_CID_COUNT(
+   PAGES_REQUIRED(BEISCSI_ASYNC_HDQ_SIZE(
   phba, ulp_num) *
   sizeof(struct phys_addr));
 
num_async_pdu_buf_pages =
-   PAGES_REQUIRED(BEISCSI_GET_CID_COUNT(
+   PAGES_REQUIRED(BEISCSI_ASYNC_HDQ_SIZE(
   phba, ulp_num) *
   phba->params.defpdu_hdr_sz);
 
num_async_pdu_data_pages =
-   PAGES_REQUIRED(BEISCSI_GET_CID_COUNT(
+   PAGES_REQUIRED(BEISCSI_ASYNC_HDQ_SIZE(
   phba, ulp_num) *
   phba->params.defpdu_data_sz);
 
num_async_pdu_data_sgl_pages =
-   PAGES_REQUIRED(BEISCSI_GET_CID_COUNT(
+   PAGES_REQUIRED(BEISCSI_ASYNC_HDQ_SIZE(
   phba, ulp_num) *
   sizeof(struct phys_addr));
 
@@ -2459,21 +2458,21 @@ static void beiscsi_find_mem_req(struct beiscsi_hba 
*phba)
mem_descr_index = (HWI_MEM_ASYNC_HEADER_HANDLE_ULP0 +
  (ulp_num * MEM_DESCR_OFFSET));
phba->mem_req[mem_descr_index] =
- BEISCSI_GET_CID_COUNT(phba, ulp_num) *
- sizeof(struct hd_async_handle);
+   BEISCSI_ASYNC_HDQ_SIZE(phba, ulp_num) *
+   sizeof(struct hd_async_handle);
 
mem_descr_index = (HWI_MEM_ASYNC_DATA_HANDLE_ULP0 +
  (ulp_num * MEM_DESCR_OFFSET));
phba->mem_req[mem_descr_index] =
- BEISCSI_GET_CID_COUNT(phba, ulp_num) *
- sizeof(struct hd_async_handle);
+   BEISCSI_ASYNC_HDQ_SIZE(phba, ulp_num) *
+   sizeof(struct hd_async_handle);
 
mem_descr_index = (HWI_MEM_ASYNC_PDU_CONTEXT_ULP0 +
  (ulp_num * MEM_DESCR_OFFSET));
phba->mem_req[mem_descr_index] =
- sizeof(struct hd_async_context) +
-(BEISCSI_GET_CID_COUNT(phba, ulp_num) *
- sizeof(struct hd_async_entry));
+   sizeof(struct hd_async_context) +
+   (BEISCSI_ASYNC_HDQ_SIZE(phba, ulp_num) *
+sizeof(struct hd_async_entry));
}
}
 }
@@ -2757,7 +2756,7 @@ static int hwi_init_async_pdu_ctx(struct beiscsi_hba 
*phba)
((long unsigned int)pasync_ctx +
sizeof(struct hd_async_context));
 
-   pasync_ctx->num_entries = BEISCSI_GET_CID_COUNT(phba,
+   pasync_ctx->num_entries = BEISCSI_ASYNC_HDQ_SIZE(phba,
  ulp_num);
/* setup header buffers */
mem_descr = (struct be_mem_descriptor *)phba->init_mem;
@@ -2895,7 +2894,7 @@ static int 

[PATCH v2 04/10] scsi_transport_iscsi: Use flush_work in iscsi_remove_session

2017-03-15 Thread Jitendra Bhivare
scsi_flush_work flushes workqueue for the Scsi_Host.
In iSCSI offload enabled host, this would wait for all other
sessions under the host.

Use flush_work for the session being removed instead.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/scsi_transport_iscsi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c 
b/drivers/scsi/scsi_transport_iscsi.c
index 568c9f2..a424eae 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -2158,7 +2158,6 @@ static int iscsi_iter_destroy_conn_fn(struct device *dev, 
void *data)
 
 void iscsi_remove_session(struct iscsi_cls_session *session)
 {
-   struct Scsi_Host *shost = iscsi_session_to_shost(session);
unsigned long flags;
int err;
 
@@ -2185,7 +2184,7 @@ void iscsi_remove_session(struct iscsi_cls_session 
*session)
 
scsi_target_unblock(>dev, SDEV_TRANSPORT_OFFLINE);
/* flush running scans then delete devices */
-   scsi_flush_work(shost);
+   flush_work(>scan_work);
__iscsi_unbind_session(>unbind_work);
 
/* hw iscsi may not have removed all connections from session */
-- 
2.7.4



[PATCH v2 10/10] be2iscsi: Update driver version

2017-03-15 Thread Jitendra Bhivare
Version 11.4.0.0

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index c6b95dc..ee18a95 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -31,7 +31,7 @@
 #include 
 
 #define DRV_NAME   "be2iscsi"
-#define BUILD_STR  "11.2.1.0"
+#define BUILD_STR  "11.4.0.0"
 #define BE_NAME"Emulex OneConnect" \
"Open-iSCSI Driver version" BUILD_STR
 #define DRV_DESC   BE_NAME " " "Driver"
-- 
2.7.4



[PATCH v2 00/10] be2iscsi: driver update 11.4.0.0

2017-03-15 Thread Jitendra Bhivare
This patch is generated against for-next branch.

v2 changes:
 +be2iscsi: Update Copyright

Jitendra Bhivare (10):
  be2iscsi: Check tag in beiscsi_mccq_compl_wait
  be2iscsi: Fix closing of connection
  be2iscsi: Replace spin_unlock_bh with spin_lock
  scsi_transport_iscsi: Use flush_work in iscsi_remove_session
  be2iscsi: Increase HDQ default queue size
  be2iscsi: Use num_cons field in Rx CQE
  be2iscsi: Remove free_list for ASYNC handles
  be2iscsi: Check size before copying ASYNC handle
  be2iscsi: Update Copyright
  be2iscsi: Update driver version

 drivers/scsi/be2iscsi/be.h  |  12 +-
 drivers/scsi/be2iscsi/be_cmds.c |  17 ++-
 drivers/scsi/be2iscsi/be_cmds.h |  74 +-
 drivers/scsi/be2iscsi/be_iscsi.c| 111 ---
 drivers/scsi/be2iscsi/be_iscsi.h|  13 +-
 drivers/scsi/be2iscsi/be_main.c | 270 +++-
 drivers/scsi/be2iscsi/be_main.h |  28 ++--
 drivers/scsi/be2iscsi/be_mgmt.c | 140 +--
 drivers/scsi/be2iscsi/be_mgmt.h |  43 ++
 drivers/scsi/scsi_transport_iscsi.c |   3 +-
 10 files changed, 319 insertions(+), 392 deletions(-)

-- 
2.7.4



[PATCH v2 01/10] be2iscsi: Check tag in beiscsi_mccq_compl_wait

2017-03-15 Thread Jitendra Bhivare
scsi host12: BS_1377 : mgmt_invalidate_connection Failed for cid=256
BUG: unable to handle kernel NULL pointer dereference at 0008
IP: [] __list_add+0xf/0xc0
PGD 0
Oops:  [#1] SMP
Modules linked in:
...
CPU: 9 PID: 1542 Comm: iscsid Tainted: G    T 
3.10.0-514.el7.x86_64 #1
Hardware name: HP ProLiant DL360 Gen9/ProLiant DL360 Gen9, BIOS P89 09/12/2016
task: 88076f310fb0 ti: 88076bba8000 task.ti: 88076bba8000
RIP: 0010:[]  [] __list_add+0xf/0xc0
RSP: 0018:88076bbab8e8  EFLAGS: 00010046
RAX: 0246 RBX: 88076bbab990 RCX: 
RDX:  RSI: 880468badf58 RDI: 88076bbab990
RBP: 88076bbab900 R08: 0246 R09: 20de
R10:  R11: 88076bbab5be R12: 
R13: 880468badf58 R14: 0001adb0 R15: 88076f310fb0
FS:  7f377124a880() GS:88046fa4() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 0008 CR3: 000771318000 CR4: 001407e0
DR0:  DR1:  DR2: 
DR3:  DR6: 0ff0 DR7: 0400
Stack:
88076bbab990 880468badf50 0001 88076bbab938
810b128b 0246 cf9b7040 880468bac7a0
 880468bac7a0 88076bbab9d0 a05a6ea3

Call Trace:
[] prepare_to_wait+0x7b/0x90
[] beiscsi_mccq_compl_wait+0x153/0x330 [be2iscsi]
[] ? wake_up_atomic_t+0x30/0x30
[] beiscsi_ep_disconnect+0x91/0x2d0 [be2iscsi]
[] iscsi_if_ep_disconnect.isra.14+0x5a/0x70 
[scsi_transport_iscsi]
[] iscsi_if_recv_msg+0x113b/0x14a0 [scsi_transport_iscsi]
[] ? __kmalloc_node_track_caller+0x58/0x290
[] iscsi_if_rx+0x8e/0x1f0 [scsi_transport_iscsi]
[] netlink_unicast+0xed/0x1b0
[] netlink_sendmsg+0x31e/0x690
[] ? netlink_rcv_wake+0x44/0x60
[] ? netlink_recvmsg+0x1e3/0x450

beiscsi_mccq_compl_wait gets called even when MCC tag allocation failed
for mgmt_invalidate_connection.
mcc_wait is not initialized for tag 0 so causes crash in prepare_to_wait.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_cmds.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 5d59e263..d14ddb2 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -246,6 +246,12 @@ int beiscsi_mccq_compl_wait(struct beiscsi_hba *phba,
 {
int rc = 0;
 
+   if (!tag || tag > MAX_MCC_CMD) {
+   __beiscsi_log(phba, KERN_ERR,
+ "BC_%d : invalid tag %u\n", tag);
+   return -EINVAL;
+   }
+
if (beiscsi_hba_in_error(phba)) {
clear_bit(MCC_TAG_STATE_RUNNING,
  >ctrl.ptag_state[tag].tag_state);
-- 
2.7.4



[PATCH v2 08/10] be2iscsi: Check size before copying ASYNC handle

2017-03-15 Thread Jitendra Bhivare
Data in buffers are gathered into a single buffer before giving to
iSCSI layer. Though less likely to have payload more than 8K in
ASYNC PDU, the data length is provide by FW and check is missing
for overrun.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index ee1f1c4..4b668c4 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1611,6 +1611,10 @@ beiscsi_hdl_fwd_pdu(struct beiscsi_conn *beiscsi_conn,
dlen = pasync_handle->buffer_len;
continue;
}
+   if (!pasync_handle->buffer_len ||
+   (dlen + pasync_handle->buffer_len) >
+   pasync_ctx->async_data.buffer_size)
+   break;
memcpy(pdata + dlen, pasync_handle->pbuffer,
   pasync_handle->buffer_len);
dlen += pasync_handle->buffer_len;
@@ -1619,8 +1623,9 @@ beiscsi_hdl_fwd_pdu(struct beiscsi_conn *beiscsi_conn,
if (!plast_handle->is_final) {
/* last handle should have final PDU notification from FW */
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_ISCSI,
-   "BM_%d : cid %u %p fwd async PDU with last handle 
missing - HL%u:DN%u:DR%u\n",
+   "BM_%d : cid %u %p fwd async PDU opcode %x with 
last handle missing - HL%u:DN%u:DR%u\n",
beiscsi_conn->beiscsi_conn_cid, plast_handle,
+   AMAP_GET_BITS(struct amap_pdu_base, opcode, phdr),
pasync_ctx->async_entry[cri].wq.hdr_len,
pasync_ctx->async_entry[cri].wq.bytes_needed,
pasync_ctx->async_entry[cri].wq.bytes_received);
-- 
2.7.4



[PATCH 8/9] be2iscsi: Check size before copying ASYNC handle

2017-03-14 Thread Jitendra Bhivare
Data in buffers are gathered into a single buffer before giving to
iSCSI layer. Though less likely to have payload more than 8K in
ASYNC PDU, the data length is provide by FW and check is missing
for overrun.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index ee1f1c4..4b668c4 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1611,6 +1611,10 @@ beiscsi_hdl_fwd_pdu(struct beiscsi_conn *beiscsi_conn,
dlen = pasync_handle->buffer_len;
continue;
}
+   if (!pasync_handle->buffer_len ||
+   (dlen + pasync_handle->buffer_len) >
+   pasync_ctx->async_data.buffer_size)
+   break;
memcpy(pdata + dlen, pasync_handle->pbuffer,
   pasync_handle->buffer_len);
dlen += pasync_handle->buffer_len;
@@ -1619,8 +1623,9 @@ beiscsi_hdl_fwd_pdu(struct beiscsi_conn *beiscsi_conn,
if (!plast_handle->is_final) {
/* last handle should have final PDU notification from FW */
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_ISCSI,
-   "BM_%d : cid %u %p fwd async PDU with last handle 
missing - HL%u:DN%u:DR%u\n",
+   "BM_%d : cid %u %p fwd async PDU opcode %x with 
last handle missing - HL%u:DN%u:DR%u\n",
beiscsi_conn->beiscsi_conn_cid, plast_handle,
+   AMAP_GET_BITS(struct amap_pdu_base, opcode, phdr),
pasync_ctx->async_entry[cri].wq.hdr_len,
pasync_ctx->async_entry[cri].wq.bytes_needed,
pasync_ctx->async_entry[cri].wq.bytes_received);
-- 
2.7.4



[PATCH 2/9] be2iscsi: Fix closing of connection

2017-03-14 Thread Jitendra Bhivare
CID needs to be freed even when invalidate or upload connection fails.
Attempt to close connection 3 times before freeing CID.

Set cleanup_type to INVALIDATE instead of force TCP_RST.
This unnecessarily is terminating connection with reset instead of
gracefully closing it.

Set save_cfg to 0 - session not to be saved on flash.

Add delay and process CQ before uploading connection.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be.h   |   1 -
 drivers/scsi/be2iscsi/be_cmds.h  |  63 +--
 drivers/scsi/be2iscsi/be_iscsi.c |  98 +-
 drivers/scsi/be2iscsi/be_mgmt.c  | 127 ---
 drivers/scsi/be2iscsi/be_mgmt.h  |  30 ++---
 5 files changed, 159 insertions(+), 160 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index ca9440f..4dd8de4 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -154,7 +154,6 @@ struct be_ctrl_info {
 #define PAGE_SHIFT_4K 12
 #define PAGE_SIZE_4K (1 << PAGE_SHIFT_4K)
 #define mcc_timeout12 /* 12s timeout */
-#define BEISCSI_LOGOUT_SYNC_DELAY  250
 
 /* Returns number of pages spanned by the data starting at the given addr */
 #define PAGES_4K_SPANNED(_address, size)   \
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 1d40e83..88fe731 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -1145,24 +1145,49 @@ struct tcp_connect_and_offload_out {
 #define DB_DEF_PDU_EVENT_SHIFT 15
 #define DB_DEF_PDU_CQPROC_SHIFT16
 
-struct dmsg_cqe {
-   u32 dw[4];
+struct be_invalidate_connection_params_in {
+   struct be_cmd_req_hdr hdr;
+   u32 session_handle;
+   u16 cid;
+   u16 unused;
+#define BE_CLEANUP_TYPE_INVALIDATE 0x8001
+#define BE_CLEANUP_TYPE_ISSUE_TCP_RST  0x8002
+   u16 cleanup_type;
+   u16 save_cfg;
+} __packed;
+
+struct be_invalidate_connection_params_out {
+   u32 session_handle;
+   u16 cid;
+   u16 unused;
 } __packed;
 
-struct tcp_upload_params_in {
+union be_invalidate_connection_params {
+   struct be_invalidate_connection_params_in req;
+   struct be_invalidate_connection_params_out resp;
+} __packed;
+
+struct be_tcp_upload_params_in {
struct be_cmd_req_hdr hdr;
u16 id;
+#define BE_UPLOAD_TYPE_GRACEFUL1
+/* abortive upload with reset */
+#define BE_UPLOAD_TYPE_ABORT_RESET 2
+/* abortive upload without reset */
+#define BE_UPLOAD_TYPE_ABORT   3
+/* abortive upload with reset, sequence number by driver */
+#define BE_UPLOAD_TYPE_ABORT_WITH_SEQ  4
u16 upload_type;
u32 reset_seq;
 } __packed;
 
-struct tcp_upload_params_out {
+struct be_tcp_upload_params_out {
u32 dw[32];
 } __packed;
 
-union tcp_upload_params {
-   struct tcp_upload_params_in request;
-   struct tcp_upload_params_out response;
+union be_tcp_upload_params {
+   struct be_tcp_upload_params_in request;
+   struct be_tcp_upload_params_out response;
 } __packed;
 
 struct be_ulp_fw_cfg {
@@ -1243,10 +1268,7 @@ struct be_cmd_get_port_name {
 #define OPCODE_COMMON_WRITE_FLASH  96
 #define OPCODE_COMMON_READ_FLASH   97
 
-/* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
 #define CMD_ISCSI_COMMAND_INVALIDATE   1
-#define CMD_ISCSI_CONNECTION_INVALIDATE0x8001
-#define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST 0x8002
 
 #define INI_WR_CMD 1   /* Initiator write command */
 #define INI_TMF_CMD2   /* Initiator TMF command */
@@ -1269,27 +1291,6 @@ struct be_cmd_get_port_name {
 *  preparedby
 * driver should not be touched
 */
-/* --- CMD_CHUTE_TYPE --- */
-#define CMD_CONNECTION_CHUTE_0 1
-#define CMD_CONNECTION_CHUTE_1 2
-#define CMD_CONNECTION_CHUTE_2 3
-
-#define EQ_MAJOR_CODE_COMPLETION   0
-
-#define CMD_ISCSI_SESSION_DEL_CFG_FROM_FLASH 0
-#define CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH 1
-
-/* --- CONNECTION_UPLOAD_PARAMS --- */
-/* These parameters are used to define the type of upload desired.  */
-#define CONNECTION_UPLOAD_GRACEFUL  1  /* Graceful upload  */
-#define CONNECTION_UPLOAD_ABORT_RESET   2  /* Abortive upload with
-* reset
-*/
-#define CONNECTION_UPLOAD_ABORT3   /* Abortive upload 
without
-* reset
-*/
-#define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset,
-* sequence numb

[PATCH 1/9] be2iscsi: Check tag in beiscsi_mccq_compl_wait

2017-03-14 Thread Jitendra Bhivare
scsi host12: BS_1377 : mgmt_invalidate_connection Failed for cid=256
BUG: unable to handle kernel NULL pointer dereference at 0008
IP: [] __list_add+0xf/0xc0
PGD 0
Oops:  [#1] SMP
Modules linked in:
...
CPU: 9 PID: 1542 Comm: iscsid Tainted: G    T 
3.10.0-514.el7.x86_64 #1
Hardware name: HP ProLiant DL360 Gen9/ProLiant DL360 Gen9, BIOS P89 09/12/2016
task: 88076f310fb0 ti: 88076bba8000 task.ti: 88076bba8000
RIP: 0010:[]  [] __list_add+0xf/0xc0
RSP: 0018:88076bbab8e8  EFLAGS: 00010046
RAX: 0246 RBX: 88076bbab990 RCX: 
RDX:  RSI: 880468badf58 RDI: 88076bbab990
RBP: 88076bbab900 R08: 0246 R09: 20de
R10:  R11: 88076bbab5be R12: 
R13: 880468badf58 R14: 0001adb0 R15: 88076f310fb0
FS:  7f377124a880() GS:88046fa4() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 0008 CR3: 000771318000 CR4: 001407e0
DR0:  DR1:  DR2: 
DR3:  DR6: 0ff0 DR7: 0400
Stack:
88076bbab990 880468badf50 0001 88076bbab938
810b128b 0246 cf9b7040 880468bac7a0
 880468bac7a0 88076bbab9d0 a05a6ea3

Call Trace:
[] prepare_to_wait+0x7b/0x90
[] beiscsi_mccq_compl_wait+0x153/0x330 [be2iscsi]
[] ? wake_up_atomic_t+0x30/0x30
[] beiscsi_ep_disconnect+0x91/0x2d0 [be2iscsi]
[] iscsi_if_ep_disconnect.isra.14+0x5a/0x70 
[scsi_transport_iscsi]
[] iscsi_if_recv_msg+0x113b/0x14a0 [scsi_transport_iscsi]
[] ? __kmalloc_node_track_caller+0x58/0x290
[] iscsi_if_rx+0x8e/0x1f0 [scsi_transport_iscsi]
[] netlink_unicast+0xed/0x1b0
[] netlink_sendmsg+0x31e/0x690
[] ? netlink_rcv_wake+0x44/0x60
[] ? netlink_recvmsg+0x1e3/0x450

beiscsi_mccq_compl_wait gets called even when MCC tag allocation failed
for mgmt_invalidate_connection.
mcc_wait is not initialized for tag 0 so causes crash in prepare_to_wait.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_cmds.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 5d59e263..d14ddb2 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -246,6 +246,12 @@ int beiscsi_mccq_compl_wait(struct beiscsi_hba *phba,
 {
int rc = 0;
 
+   if (!tag || tag > MAX_MCC_CMD) {
+   __beiscsi_log(phba, KERN_ERR,
+ "BC_%d : invalid tag %u\n", tag);
+   return -EINVAL;
+   }
+
if (beiscsi_hba_in_error(phba)) {
clear_bit(MCC_TAG_STATE_RUNNING,
  >ctrl.ptag_state[tag].tag_state);
-- 
2.7.4



[PATCH 7/9] be2iscsi: Remove free_list for ASYNC handles

2017-03-14 Thread Jitendra Bhivare
With previous patch adding ASYNC Rx buffers to free_list is not required.
Remove all free_list related operations.

Add in_use to track if buffer posted is being processed by driver and
purge all buffers received for connection if found so.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 99 +
 drivers/scsi/be2iscsi/be_main.h |  8 +---
 2 files changed, 43 insertions(+), 64 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 1cd9c2d..ee1f1c4 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1453,15 +1453,28 @@ static inline void
 beiscsi_hdl_put_handle(struct hd_async_context *pasync_ctx,
 struct hd_async_handle *pasync_handle)
 {
-   if (pasync_handle->is_header) {
-   list_add_tail(_handle->link,
-   _ctx->async_header.free_list);
-   pasync_ctx->async_header.free_entries++;
-   } else {
-   list_add_tail(_handle->link,
-   _ctx->async_data.free_list);
-   pasync_ctx->async_data.free_entries++;
-   }
+   pasync_handle->is_final = 0;
+   pasync_handle->buffer_len = 0;
+   pasync_handle->in_use = 0;
+   list_del_init(_handle->link);
+}
+
+static void
+beiscsi_hdl_purge_handles(struct beiscsi_hba *phba,
+ struct hd_async_context *pasync_ctx,
+ u16 cri)
+{
+   struct hd_async_handle *pasync_handle, *tmp_handle;
+   struct list_head *plist;
+
+   plist  = _ctx->async_entry[cri].wq.list;
+   list_for_each_entry_safe(pasync_handle, tmp_handle, plist, link)
+   beiscsi_hdl_put_handle(pasync_ctx, pasync_handle);
+
+   INIT_LIST_HEAD(_ctx->async_entry[cri].wq.list);
+   pasync_ctx->async_entry[cri].wq.hdr_len = 0;
+   pasync_ctx->async_entry[cri].wq.bytes_received = 0;
+   pasync_ctx->async_entry[cri].wq.bytes_needed = 0;
 }
 
 static struct hd_async_handle *
@@ -1473,11 +1486,12 @@ beiscsi_hdl_get_handle(struct beiscsi_conn 
*beiscsi_conn,
struct beiscsi_hba *phba = beiscsi_conn->phba;
struct hd_async_handle *pasync_handle;
struct be_bus_address phys_addr;
+   u16 cid, code, ci, cri;
u8 final, error = 0;
-   u16 cid, code, ci;
u32 dpl;
 
cid = beiscsi_conn->beiscsi_conn_cid;
+   cri = BE_GET_ASYNC_CRI_FROM_CID(cid);
/**
 * This function is invoked to get the right async_handle structure
 * from a given DEF PDU CQ entry.
@@ -1525,15 +1539,7 @@ beiscsi_hdl_get_handle(struct beiscsi_conn *beiscsi_conn,
break;
/* called only for above codes */
default:
-   pasync_handle = NULL;
-   break;
-   }
-
-   if (!pasync_handle) {
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_ISCSI,
-   "BM_%d : cid %d async PDU handle not found - code 
%d ci %d addr %llx\n",
-   cid, code, ci, phys_addr.u.a64.address);
-   return pasync_handle;
+   return NULL;
}
 
if (pasync_handle->pa.u.a64.address != phys_addr.u.a64.address ||
@@ -1549,44 +1555,33 @@ beiscsi_hdl_get_handle(struct beiscsi_conn 
*beiscsi_conn,
/* FW has stale address - attempt continuing by dropping */
}
 
-   list_del_init(_handle->link);
-   /**
-* Each CID is associated with unique CRI.
-* ASYNC_CRI_FROM_CID mapping and CRI_FROM_CID are totaly different.
-**/
-   pasync_handle->cri = BE_GET_ASYNC_CRI_FROM_CID(cid);
-   pasync_handle->is_final = final;
-   pasync_handle->buffer_len = dpl;
-
/**
 * DEF PDU header and data buffers with errors should be simply
 * dropped as there are no consumers for it.
 */
if (error) {
beiscsi_hdl_put_handle(pasync_ctx, pasync_handle);
-   pasync_handle = NULL;
+   return NULL;
}
-   return pasync_handle;
-}
-
-static void
-beiscsi_hdl_purge_handles(struct beiscsi_hba *phba,
- struct hd_async_context *pasync_ctx,
- u16 cri)
-{
-   struct hd_async_handle *pasync_handle, *tmp_handle;
-   struct list_head *plist;
 
-   plist  = _ctx->async_entry[cri].wq.list;
-   list_for_each_entry_safe(pasync_handle, tmp_handle, plist, link) {
-   list_del(_handle->link);
-   beiscsi_hdl_put_handle(pasync_ctx, pasync_handle);
+   if (pasync_handle->in_use || !list_empty(_handle->link)) {
+   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_ISCSI,
+   "BM_%d : cid %d async PDU handle in

[PATCH 9/9] be2iscsi: Update driver version

2017-03-14 Thread Jitendra Bhivare
Version 11.4.0.0

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 9883a85..0f826fe 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -36,7 +36,7 @@
 #include 
 
 #define DRV_NAME   "be2iscsi"
-#define BUILD_STR  "11.2.1.0"
+#define BUILD_STR  "11.4.0.0"
 #define BE_NAME"Emulex OneConnect" \
"Open-iSCSI Driver version" BUILD_STR
 #define DRV_DESC   BE_NAME " " "Driver"
-- 
2.7.4



[PATCH 0/9] be2iscsi: driver update 11.4.0.0

2017-03-14 Thread Jitendra Bhivare
This patch is generated against for-next branch.

Jitendra Bhivare (9):
  be2iscsi: Check tag in beiscsi_mccq_compl_wait
  be2iscsi: Fix closing of connection
  be2iscsi: Replace spin_unlock_bh with spin_lock
  scsi_transport_iscsi: Use flush_work in iscsi_remove_session
  be2iscsi: Increase HDQ default queue size
  be2iscsi: Use num_cons field in Rx CQE
  be2iscsi: Remove free_list for ASYNC handles
  be2iscsi: Check size before copying ASYNC handle
  be2iscsi: Update driver version

 drivers/scsi/be2iscsi/be.h  |   1 -
 drivers/scsi/be2iscsi/be_cmds.c |   6 +
 drivers/scsi/be2iscsi/be_cmds.h |  63 -
 drivers/scsi/be2iscsi/be_iscsi.c|  98 --
 drivers/scsi/be2iscsi/be_main.c | 257 
 drivers/scsi/be2iscsi/be_main.h |  15 +--
 drivers/scsi/be2iscsi/be_mgmt.c | 127 +-
 drivers/scsi/be2iscsi/be_mgmt.h |  30 +
 drivers/scsi/scsi_transport_iscsi.c |   3 +-
 9 files changed, 283 insertions(+), 317 deletions(-)

-- 
2.7.4



[PATCH 6/9] be2iscsi: Use num_cons field in Rx CQE

2017-03-14 Thread Jitendra Bhivare
FW runs out of buffer if buffers are not posted back soon.
ASYNC Rx CQE indicates that FW has consumed 8 RQEs.
Use it to post back buffers instead of waiting for buffers
to be processed and freed by driver.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 124 
 drivers/scsi/be2iscsi/be_main.h |   1 +
 2 files changed, 51 insertions(+), 74 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index b76fd26..1cd9c2d 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1467,7 +1467,8 @@ beiscsi_hdl_put_handle(struct hd_async_context 
*pasync_ctx,
 static struct hd_async_handle *
 beiscsi_hdl_get_handle(struct beiscsi_conn *beiscsi_conn,
   struct hd_async_context *pasync_ctx,
-  struct i_t_dpdu_cqe *pdpdu_cqe)
+  struct i_t_dpdu_cqe *pdpdu_cqe,
+  u8 *header)
 {
struct beiscsi_hba *phba = beiscsi_conn->phba;
struct hd_async_handle *pasync_handle;
@@ -1515,6 +1516,7 @@ beiscsi_hdl_get_handle(struct beiscsi_conn *beiscsi_conn,
switch (code) {
case UNSOL_HDR_NOTIFY:
pasync_handle = pasync_ctx->async_entry[ci].header;
+   *header = 1;
break;
case UNSOL_DATA_DIGEST_ERROR_NOTIFY:
error = 1;
@@ -1547,6 +1549,7 @@ beiscsi_hdl_get_handle(struct beiscsi_conn *beiscsi_conn,
/* FW has stale address - attempt continuing by dropping */
}
 
+   list_del_init(_handle->link);
/**
 * Each CID is associated with unique CRI.
 * ASYNC_CRI_FROM_CID mapping and CRI_FROM_CID are totaly different.
@@ -1554,11 +1557,6 @@ beiscsi_hdl_get_handle(struct beiscsi_conn *beiscsi_conn,
pasync_handle->cri = BE_GET_ASYNC_CRI_FROM_CID(cid);
pasync_handle->is_final = final;
pasync_handle->buffer_len = dpl;
-   /* empty the slot */
-   if (pasync_handle->is_header)
-   pasync_ctx->async_entry[ci].header = NULL;
-   else
-   pasync_ctx->async_entry[ci].data = NULL;
 
/**
 * DEF PDU header and data buffers with errors should be simply
@@ -1708,85 +1706,53 @@ beiscsi_hdl_gather_pdu(struct beiscsi_conn 
*beiscsi_conn,
 
 static void
 beiscsi_hdq_post_handles(struct beiscsi_hba *phba,
-u8 header, u8 ulp_num)
+u8 header, u8 ulp_num, u16 nbuf)
 {
-   struct hd_async_handle *pasync_handle, *tmp, **slot;
+   struct hd_async_handle *pasync_handle;
struct hd_async_context *pasync_ctx;
struct hwi_controller *phwi_ctrlr;
-   struct list_head *hfree_list;
struct phys_addr *pasync_sge;
u32 ring_id, doorbell = 0;
u32 doorbell_offset;
-   u16 prod = 0, cons;
-   u16 index;
+   u16 prod, pi;
 
phwi_ctrlr = phba->phwi_ctrlr;
pasync_ctx = HWI_GET_ASYNC_PDU_CTX(phwi_ctrlr, ulp_num);
if (header) {
-   cons = pasync_ctx->async_header.free_entries;
-   hfree_list = _ctx->async_header.free_list;
+   pasync_sge = pasync_ctx->async_header.ring_base;
+   pi = pasync_ctx->async_header.pi;
ring_id = phwi_ctrlr->default_pdu_hdr[ulp_num].id;
doorbell_offset = phwi_ctrlr->default_pdu_hdr[ulp_num].
doorbell_offset;
} else {
-   cons = pasync_ctx->async_data.free_entries;
-   hfree_list = _ctx->async_data.free_list;
+   pasync_sge = pasync_ctx->async_data.ring_base;
+   pi = pasync_ctx->async_data.pi;
ring_id = phwi_ctrlr->default_pdu_data[ulp_num].id;
doorbell_offset = phwi_ctrlr->default_pdu_data[ulp_num].
doorbell_offset;
}
-   /* number of entries posted must be in multiples of 8 */
-   if (cons % 8)
-   return;
 
-   list_for_each_entry_safe(pasync_handle, tmp, hfree_list, link) {
-   list_del_init(_handle->link);
-   pasync_handle->is_final = 0;
-   pasync_handle->buffer_len = 0;
-
-   /* handles can be consumed out of order, use index in handle */
-   index = pasync_handle->index;
-   WARN_ON(pasync_handle->is_header != header);
+   for (prod = 0; prod < nbuf; prod++) {
if (header)
-   slot = _ctx->async_entry[index].header;
+   pasync_handle = pasync_ctx->async_entry[pi].header;
else
-   slot = _ctx->async_entry[index].data;
-   /**
-* The slot just tracks handle's hold and release, so
-

[PATCH 4/9] scsi_transport_iscsi: Use flush_work in iscsi_remove_session

2017-03-14 Thread Jitendra Bhivare
scsi_flush_work flushes workqueue for the Scsi_Host.
In iSCSI offload enabled host, this would wait for all other
sessions under the host.

Use flush_work for the session being removed instead.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/scsi_transport_iscsi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c 
b/drivers/scsi/scsi_transport_iscsi.c
index 568c9f2..a424eae 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -2158,7 +2158,6 @@ static int iscsi_iter_destroy_conn_fn(struct device *dev, 
void *data)
 
 void iscsi_remove_session(struct iscsi_cls_session *session)
 {
-   struct Scsi_Host *shost = iscsi_session_to_shost(session);
unsigned long flags;
int err;
 
@@ -2185,7 +2184,7 @@ void iscsi_remove_session(struct iscsi_cls_session 
*session)
 
scsi_target_unblock(>dev, SDEV_TRANSPORT_OFFLINE);
/* flush running scans then delete devices */
-   scsi_flush_work(shost);
+   flush_work(>scan_work);
__iscsi_unbind_session(>unbind_work);
 
/* hw iscsi may not have removed all connections from session */
-- 
2.7.4



[PATCH 5/9] be2iscsi: Increase HDQ default queue size

2017-03-14 Thread Jitendra Bhivare
Currently, ASYNC PDU default queue size is set to max connections.
This leaves only one buffer per connection for any ASYNC PDUs from
targets.

Double the size of the default queue.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 29 ++---
 drivers/scsi/be2iscsi/be_main.h |  4 +++-
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index ff48573..b76fd26 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -636,7 +636,6 @@ static void beiscsi_get_params(struct beiscsi_hba *phba)
(total_cid_count +
 BE2_TMFS + BE2_NOPOUT_REQ));
phba->params.cxns_per_ctrl = total_cid_count;
-   phba->params.asyncpdus_per_ctrl = total_cid_count;
phba->params.icds_per_ctrl = total_icd_count;
phba->params.num_sge_per_io = BE2_SGE;
phba->params.defpdu_hdr_sz = BE2_DEFPDU_HDR_SZ;
@@ -2407,22 +2406,22 @@ static void beiscsi_find_mem_req(struct beiscsi_hba 
*phba)
if (test_bit(ulp_num, >fw_config.ulp_supported)) {
 
num_async_pdu_buf_sgl_pages =
-   PAGES_REQUIRED(BEISCSI_GET_CID_COUNT(
+   PAGES_REQUIRED(BEISCSI_ASYNC_HDQ_SIZE(
   phba, ulp_num) *
   sizeof(struct phys_addr));
 
num_async_pdu_buf_pages =
-   PAGES_REQUIRED(BEISCSI_GET_CID_COUNT(
+   PAGES_REQUIRED(BEISCSI_ASYNC_HDQ_SIZE(
   phba, ulp_num) *
   phba->params.defpdu_hdr_sz);
 
num_async_pdu_data_pages =
-   PAGES_REQUIRED(BEISCSI_GET_CID_COUNT(
+   PAGES_REQUIRED(BEISCSI_ASYNC_HDQ_SIZE(
   phba, ulp_num) *
   phba->params.defpdu_data_sz);
 
num_async_pdu_data_sgl_pages =
-   PAGES_REQUIRED(BEISCSI_GET_CID_COUNT(
+   PAGES_REQUIRED(BEISCSI_ASYNC_HDQ_SIZE(
   phba, ulp_num) *
   sizeof(struct phys_addr));
 
@@ -2459,21 +2458,21 @@ static void beiscsi_find_mem_req(struct beiscsi_hba 
*phba)
mem_descr_index = (HWI_MEM_ASYNC_HEADER_HANDLE_ULP0 +
  (ulp_num * MEM_DESCR_OFFSET));
phba->mem_req[mem_descr_index] =
- BEISCSI_GET_CID_COUNT(phba, ulp_num) *
- sizeof(struct hd_async_handle);
+   BEISCSI_ASYNC_HDQ_SIZE(phba, ulp_num) *
+   sizeof(struct hd_async_handle);
 
mem_descr_index = (HWI_MEM_ASYNC_DATA_HANDLE_ULP0 +
  (ulp_num * MEM_DESCR_OFFSET));
phba->mem_req[mem_descr_index] =
- BEISCSI_GET_CID_COUNT(phba, ulp_num) *
- sizeof(struct hd_async_handle);
+   BEISCSI_ASYNC_HDQ_SIZE(phba, ulp_num) *
+   sizeof(struct hd_async_handle);
 
mem_descr_index = (HWI_MEM_ASYNC_PDU_CONTEXT_ULP0 +
  (ulp_num * MEM_DESCR_OFFSET));
phba->mem_req[mem_descr_index] =
- sizeof(struct hd_async_context) +
-(BEISCSI_GET_CID_COUNT(phba, ulp_num) *
- sizeof(struct hd_async_entry));
+   sizeof(struct hd_async_context) +
+   (BEISCSI_ASYNC_HDQ_SIZE(phba, ulp_num) *
+sizeof(struct hd_async_entry));
}
}
 }
@@ -2757,7 +2756,7 @@ static int hwi_init_async_pdu_ctx(struct beiscsi_hba 
*phba)
((long unsigned int)pasync_ctx +
sizeof(struct hd_async_context));
 
-   pasync_ctx->num_entries = BEISCSI_GET_CID_COUNT(phba,
+   pasync_ctx->num_entries = BEISCSI_ASYNC_HDQ_SIZE(phba,
  ulp_num);
/* setup header buffers */
mem_descr = (struct be_mem_descriptor *)phba->init_mem;
@@ -2895,7 +2894,7 @@ static int 

[PATCH 3/9] be2iscsi: Replace spin_unlock_bh with spin_lock

2017-03-14 Thread Jitendra Bhivare
spin_unlock_bh back_lock is used in beiscsi_eh_device_reset instead of
spin_lock.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 32b2713..ff48573 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -337,7 +337,7 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
inv_tbl->task[nents] = task;
nents++;
}
-   spin_unlock_bh(>back_lock);
+   spin_unlock(>back_lock);
spin_unlock_bh(>frwd_lock);
 
rc = SUCCESS;
-- 
2.7.4



RE: [PATCH] be2iscsi: switch to pci_alloc_irq_vectors

2017-01-22 Thread Jitendra Bhivare
> -Original Message-
> From: Martin K. Petersen [mailto:martin.peter...@oracle.com]
> Sent: Saturday, January 21, 2017 5:56 AM
> To: Christoph Hellwig
> Cc: subbu.seethara...@broadcom.com; ketan.muka...@broadcom.com;
> jitendra.bhiv...@broadcom.com; linux-scsi@vger.kernel.org
> Subject: Re: [PATCH] be2iscsi: switch to pci_alloc_irq_vectors
>
> > "Christoph" == Christoph Hellwig  writes:
>
> Christoph> And get automatic MSI-X affinity for free.
>
> Jitendra?
>
We will be taking this up along with some other changes in the same area.

Regards,

JB
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH -next] scsi: be2iscsi: Use GFP_ATOMIC under spin lock

2017-01-17 Thread Jitendra Bhivare
> -Original Message-
> From: Wei Yongjun [mailto:weiyj...@gmail.com]
> Sent: Thursday, January 12, 2017 7:52 PM
> To: Subbu Seetharaman; Ketan Mukadam; Jitendra Bhivare; James E.J.
> Bottomley; Martin K. Petersen
> Cc: Wei Yongjun; linux-scsi@vger.kernel.org
> Subject: [PATCH -next] scsi: be2iscsi: Use GFP_ATOMIC under spin lock
>
> From: Wei Yongjun <weiyongj...@huawei.com>
>
> A spin lock is taken here so we should use GFP_ATOMIC.
>
> Fixes: 987132167f4b ("scsi: be2iscsi: Fix for crash in
beiscsi_eh_device_reset")
> Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
> ---
>  drivers/scsi/be2iscsi/be_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/be2iscsi/be_main.c
b/drivers/scsi/be2iscsi/be_main.c
> index 6372613..c9b9daa 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -294,7 +294,7 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd
> *sc)
>   beiscsi_conn = conn->dd_data;
>   phba = beiscsi_conn->phba;
>
> - inv_tbl = kzalloc(sizeof(*inv_tbl), GFP_KERNEL);
> + inv_tbl = kzalloc(sizeof(*inv_tbl), GFP_ATOMIC);
>   if (!inv_tbl) {
>       spin_unlock_bh(>frwd_lock);
>   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH,

Reviewed-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 12/13] be2iscsi: Add warning message for unsupported adapter

2016-12-13 Thread Jitendra Bhivare
From: Ketan Mukadam <ketan.muka...@avagotech.com>

Add a warning message to indicate obsolete/unsupported
BE2 Adapter Family devices

Signed-off-by: Ketan Mukadam <ketan.muka...@avagotech.com>
Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 2 ++
 drivers/scsi/be2iscsi/be_mgmt.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index d96f7068..6372613 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -5640,6 +5640,8 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
case OC_DEVICE_ID2:
phba->generation = BE_GEN2;
phba->iotask_fn = beiscsi_iotask;
+   dev_warn(>dev,
+"Obsolete/Unsupported BE2 Adapter Family\n");
break;
case BE_DEVICE_ID2:
case OC_DEVICE_ID3:
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 8acacd5e..2f6d5c2 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1262,7 +1262,8 @@ beiscsi_adap_family_disp(struct device *dev, struct 
device_attribute *attr,
case BE_DEVICE_ID1:
case OC_DEVICE_ID1:
case OC_DEVICE_ID2:
-   return snprintf(buf, PAGE_SIZE, "BE2 Adapter Family\n");
+   return snprintf(buf, PAGE_SIZE,
+   "Obsolete/Unsupported BE2 Adapter Family\n");
break;
case BE_DEVICE_ID2:
case OC_DEVICE_ID3:
-- 
2.7.4

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


[PATCH v2 13/13] be2iscsi: Update driver version

2016-12-13 Thread Jitendra Bhivare
Version 11.2.1.0

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 02a9b2d..2188579 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -36,7 +36,7 @@
 #include 
 
 #define DRV_NAME   "be2iscsi"
-#define BUILD_STR  "11.2.0.0"
+#define BUILD_STR  "11.2.1.0"
 #define BE_NAME"Emulex OneConnect" \
"Open-iSCSI Driver version" BUILD_STR
 #define DRV_DESC   BE_NAME " " "Driver"
-- 
2.7.4

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


[PATCH v2 11/13] be2iscsi: Reinit SGL handle, CID tables after TPE

2016-12-13 Thread Jitendra Bhivare
After TPE recovery, CID table needs to be repopulated as per CIDs in
WRBQ creation responses.

SGL handles table needs to be recreated for posting and its indices need
to be resetted.

This is achieved by calling beiscsi_cleanup_port when disabling and
beiscsi_init_port in enabling port.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 61 ++---
 1 file changed, 20 insertions(+), 41 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index a8a23d6..d96f7068 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -3919,31 +3919,6 @@ static void beiscsi_free_mem(struct beiscsi_hba *phba)
kfree(phba->phwi_ctrlr);
 }
 
-static int beiscsi_init_controller(struct beiscsi_hba *phba)
-{
-   int ret;
-
-   ret = beiscsi_get_memory(phba);
-   if (ret < 0) {
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
-   "BM_%d : beiscsi_dev_probe -"
-   "Failed in beiscsi_alloc_memory\n");
-   return ret;
-   }
-
-   ret = hwi_init_controller(phba);
-   if (ret)
-   goto free_init;
-   beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
-   "BM_%d : Return success from beiscsi_init_controller");
-
-   return 0;
-
-free_init:
-   beiscsi_free_mem(phba);
-   return ret;
-}
-
 static int beiscsi_init_sgl_handle(struct beiscsi_hba *phba)
 {
struct be_mem_descriptor *mem_descr_sglh, *mem_descr_sg;
@@ -4217,33 +4192,30 @@ static int beiscsi_init_port(struct beiscsi_hba *phba)
 {
int ret;
 
-   ret = beiscsi_init_controller(phba);
+   ret = hwi_init_controller(phba);
if (ret < 0) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
-   "BM_%d : beiscsi_dev_probe - Failed in"
-   "beiscsi_init_controller\n");
+   "BM_%d : init controller failed\n");
return ret;
}
ret = beiscsi_init_sgl_handle(phba);
if (ret < 0) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
-   "BM_%d : beiscsi_dev_probe - Failed in"
-   "beiscsi_init_sgl_handle\n");
-   goto do_cleanup_ctrlr;
+   "BM_%d : init sgl handles failed\n");
+   goto cleanup_port;
}
 
ret = hba_setup_cid_tbls(phba);
if (ret < 0) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
-   "BM_%d : Failed in hba_setup_cid_tbls\n");
+   "BM_%d : setup CID table failed\n");
kfree(phba->io_sgl_hndl_base);
kfree(phba->eh_sgl_hndl_base);
-   goto do_cleanup_ctrlr;
+   goto cleanup_port;
}
-
return ret;
 
-do_cleanup_ctrlr:
+cleanup_port:
hwi_cleanup_port(phba);
return ret;
 }
@@ -5403,10 +5375,10 @@ static int beiscsi_enable_port(struct beiscsi_hba *phba)
 
phba->shost->max_id = phba->params.cxns_per_ctrl;
phba->shost->can_queue = phba->params.ios_per_ctrl;
-   ret = hwi_init_controller(phba);
-   if (ret) {
+   ret = beiscsi_init_port(phba);
+   if (ret < 0) {
__beiscsi_log(phba, KERN_ERR,
- "BM_%d : init controller failed %d\n", ret);
+ "BM_%d : init port failed\n");
goto disable_msix;
}
 
@@ -5512,6 +5484,7 @@ static void beiscsi_disable_port(struct beiscsi_hba 
*phba, int unload)
cancel_work_sync(_eq->mcc_work);
}
hwi_cleanup_port(phba);
+   beiscsi_cleanup_port(phba);
 }
 
 static void beiscsi_sess_work(struct work_struct *work)
@@ -5722,11 +5695,18 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
 
phba->shost->max_id = phba->params.cxns_per_ctrl;
phba->shost->can_queue = phba->params.ios_per_ctrl;
+   ret = beiscsi_get_memory(phba);
+   if (ret < 0) {
+   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
+   "BM_%d : alloc host mem failed\n");
+   goto free_port;
+   }
+
ret = beiscsi_init_port(phba);
if (ret < 0) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
-   "BM_%d : beiscsi_dev_probe-"
-   "Failed in beiscsi_init_port\n");
+   "BM_%d : init port failed\n");
+   beiscsi_free_mem(phba);
goto free_port;
}
 
@@ -5868,7 +5848,6 @@ static 

[PATCH v2 06/13] be2iscsi: Fix iSCSI cmd cleanup IOCTL

2016-12-13 Thread Jitendra Bhivare
Prepare the IOCTL with appropriate sizes of buffers of V0 and V1.
Set missing chute number in V1 IOCTL.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_cmds.c | 33 ++---
 drivers/scsi/be2iscsi/be_main.c |  3 +--
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index be65da2..94aae45 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -1700,31 +1700,34 @@ int beiscsi_cmd_iscsi_cleanup(struct beiscsi_hba *phba, 
unsigned short ulp)
struct be_ctrl_info *ctrl = >ctrl;
struct iscsi_cleanup_req_v1 *req_v1;
struct iscsi_cleanup_req *req;
+   u16 hdr_ring_id, data_ring_id;
struct be_mcc_wrb *wrb;
int status;
 
mutex_lock(>mbox_lock);
wrb = wrb_from_mbox(>mbox_mem);
-   req = embedded_payload(wrb);
-   be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
-   be_cmd_hdr_prepare(>hdr, CMD_SUBSYSTEM_ISCSI,
-  OPCODE_COMMON_ISCSI_CLEANUP, sizeof(*req));
 
-   /**
-   * TODO: Check with FW folks the chute value to be set.
-   * For now, use the ULP_MASK as the chute value.
-   */
+   hdr_ring_id = HWI_GET_DEF_HDRQ_ID(phba, ulp);
+   data_ring_id = HWI_GET_DEF_BUFQ_ID(phba, ulp);
if (is_chip_be2_be3r(phba)) {
+   req = embedded_payload(wrb);
+   be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
+   be_cmd_hdr_prepare(>hdr, CMD_SUBSYSTEM_ISCSI,
+  OPCODE_COMMON_ISCSI_CLEANUP, sizeof(*req));
req->chute = (1 << ulp);
-   req->hdr_ring_id = HWI_GET_DEF_HDRQ_ID(phba, ulp);
-   req->data_ring_id = HWI_GET_DEF_BUFQ_ID(phba, ulp);
+   /* BE2/BE3 FW creates 8-bit ring id */
+   req->hdr_ring_id = hdr_ring_id;
+   req->data_ring_id = data_ring_id;
} else {
-   req_v1 = (struct iscsi_cleanup_req_v1 *)req;
+   req_v1 = embedded_payload(wrb);
+   be_wrb_hdr_prepare(wrb, sizeof(*req_v1), true, 0);
+   be_cmd_hdr_prepare(_v1->hdr, CMD_SUBSYSTEM_ISCSI,
+  OPCODE_COMMON_ISCSI_CLEANUP,
+  sizeof(*req_v1));
req_v1->hdr.version = 1;
-   req_v1->hdr_ring_id = cpu_to_le16(HWI_GET_DEF_HDRQ_ID(phba,
- ulp));
-   req_v1->data_ring_id = cpu_to_le16(HWI_GET_DEF_BUFQ_ID(phba,
-  ulp));
+   req_v1->chute = (1 << ulp);
+   req_v1->hdr_ring_id = cpu_to_le16(hdr_ring_id);
+   req_v1->data_ring_id = cpu_to_le16(data_ring_id);
}
 
status = be_mbox_notify(ctrl);
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 832d4f0..1b5a07f 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -2747,7 +2747,7 @@ static int hwi_init_async_pdu_ctx(struct beiscsi_hba 
*phba)
 
for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
if (test_bit(ulp_num, >fw_config.ulp_supported)) {
-/* get async_ctx for each ULP */
+   /* get async_ctx for each ULP */
mem_descr = (struct be_mem_descriptor *)phba->init_mem;
mem_descr += (HWI_MEM_ASYNC_PDU_CONTEXT_ULP0 +
 (ulp_num * MEM_DESCR_OFFSET));
@@ -3814,7 +3814,6 @@ static int hwi_init_port(struct beiscsi_hba *phba)
/**
 * Now that the default PDU rings have been created,
 * let EP know about it.
-* Call beiscsi_cmd_iscsi_cleanup before posting?
 */
beiscsi_hdq_post_handles(phba, BEISCSI_DEFQ_HDR,
 ulp_num);
-- 
2.7.4

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


[PATCH v2 10/13] be2iscsi: Add checks to validate CID alloc/free

2016-12-13 Thread Jitendra Bhivare
Set CID slot to 0x to indicate empty.
Check if connection already exists in conn_table before binding.
Check if endpoint already NULL before putting back CID.
Break ep->conn link in free_ep to ignore completions after freeing.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_iscsi.c | 163 ---
 drivers/scsi/be2iscsi/be_main.c  |   7 +-
 drivers/scsi/be2iscsi/be_main.h  |   1 +
 3 files changed, 87 insertions(+), 84 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 0ec0625..a484457 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -166,33 +166,6 @@ beiscsi_conn_create(struct iscsi_cls_session *cls_session, 
u32 cid)
 }
 
 /**
- * beiscsi_bindconn_cid - Bind the beiscsi_conn with phba connection table
- * @beiscsi_conn: The pointer to  beiscsi_conn structure
- * @phba: The phba instance
- * @cid: The cid to free
- */
-static int beiscsi_bindconn_cid(struct beiscsi_hba *phba,
-   struct beiscsi_conn *beiscsi_conn,
-   unsigned int cid)
-{
-   uint16_t cri_index = BE_GET_CRI_FROM_CID(cid);
-
-   if (phba->conn_table[cri_index]) {
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
-   "BS_%d : Connection table already occupied. 
Detected clash\n");
-
-   return -EINVAL;
-   } else {
-   beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
-   "BS_%d : phba->conn_table[%d]=%p(beiscsi_conn)\n",
-   cri_index, beiscsi_conn);
-
-   phba->conn_table[cri_index] = beiscsi_conn;
-   }
-   return 0;
-}
-
-/**
  * beiscsi_conn_bind - Binds iscsi session/connection with TCP connection
  * @cls_session: pointer to iscsi cls session
  * @cls_conn: pointer to iscsi cls conn
@@ -212,6 +185,7 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session,
struct hwi_wrb_context *pwrb_context;
struct beiscsi_endpoint *beiscsi_ep;
struct iscsi_endpoint *ep;
+   uint16_t cri_index;
 
ep = iscsi_lookup_endpoint(transport_fd);
if (!ep)
@@ -229,20 +203,34 @@ int beiscsi_conn_bind(struct iscsi_cls_session 
*cls_session,
 
return -EEXIST;
}
-
-   pwrb_context = _ctrlr->wrb_context[BE_GET_CRI_FROM_CID(
-   beiscsi_ep->ep_cid)];
+   cri_index = BE_GET_CRI_FROM_CID(beiscsi_ep->ep_cid);
+   if (phba->conn_table[cri_index]) {
+   if (beiscsi_conn != phba->conn_table[cri_index] ||
+   beiscsi_ep != phba->conn_table[cri_index]->ep) {
+   __beiscsi_log(phba, KERN_ERR,
+ "BS_%d : conn_table not empty at %u: cid 
%u conn %p:%p\n",
+ cri_index,
+ beiscsi_ep->ep_cid,
+ beiscsi_conn,
+ phba->conn_table[cri_index]);
+   return -EINVAL;
+   }
+   }
 
beiscsi_conn->beiscsi_conn_cid = beiscsi_ep->ep_cid;
beiscsi_conn->ep = beiscsi_ep;
beiscsi_ep->conn = beiscsi_conn;
+   /**
+* Each connection is associated with a WRBQ kept in wrb_context.
+* Store doorbell offset for transmit path.
+*/
+   pwrb_context = _ctrlr->wrb_context[cri_index];
beiscsi_conn->doorbell_offset = pwrb_context->doorbell_offset;
-
beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
-   "BS_%d : beiscsi_conn=%p conn=%p ep_cid=%d\n",
-   beiscsi_conn, conn, beiscsi_ep->ep_cid);
-
-   return beiscsi_bindconn_cid(phba, beiscsi_conn, beiscsi_ep->ep_cid);
+   "BS_%d : cid %d phba->conn_table[%u]=%p\n",
+   beiscsi_ep->ep_cid, cri_index, beiscsi_conn);
+   phba->conn_table[cri_index] = beiscsi_conn;
+   return 0;
 }
 
 static int beiscsi_iface_create_ipv4(struct beiscsi_hba *phba)
@@ -973,9 +961,9 @@ int beiscsi_conn_start(struct iscsi_cls_conn *cls_conn)
  */
 static int beiscsi_get_cid(struct beiscsi_hba *phba)
 {
-   unsigned short cid = 0x, cid_from_ulp;
-   struct ulp_cid_info *cid_info = NULL;
uint16_t cid_avlbl_ulp0, cid_avlbl_ulp1;
+   unsigned short cid, cid_from_ulp;
+   struct ulp_cid_info *cid_info;
 
/* Find the ULP which has more CID available */
cid_avlbl_ulp0 = (phba->cid_array_info[BEISCSI_ULP0]) ?
@@ -984,20 +972,27 @@ static int beiscsi_get_cid(struct beiscsi_hba *phba)
  BEISCSI_ULP1_AVLBL_CID(phba) : 0;
cid_from_ulp = (cid_avlbl_ulp0 > cid_avlbl_ulp1) ?
 

[PATCH v2 08/13] be2iscsi: Remove unused struct members

2016-12-13 Thread Jitendra Bhivare
Fix errors reported in static analysis.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be.h   |  3 --
 drivers/scsi/be2iscsi/be_cmds.c  |  8 +++---
 drivers/scsi/be2iscsi/be_cmds.h  | 17 ++--
 drivers/scsi/be2iscsi/be_iscsi.c |  2 +-
 drivers/scsi/be2iscsi/be_main.c  | 24 +++-
 drivers/scsi/be2iscsi/be_main.h  | 22 ---
 drivers/scsi/be2iscsi/be_mgmt.c  |  9 ++
 drivers/scsi/be2iscsi/be_mgmt.h  | 60 
 8 files changed, 21 insertions(+), 124 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index b1d0fdc..ca9440f 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -84,7 +84,6 @@ static inline void queue_tail_inc(struct be_queue_info *q)
 /*ISCSI */
 
 struct be_aic_obj {/* Adaptive interrupt coalescing (AIC) info */
-   bool enable;
u32 min_eqd;/* in usecs */
u32 max_eqd;/* in usecs */
u32 prev_eqd;   /* in usecs */
@@ -94,8 +93,6 @@ struct be_aic_obj {   /* Adaptive interrupt 
coalescing (AIC) info */
 };
 
 struct be_eq_obj {
-   bool todo_mcc_cq;
-   bool todo_cq;
u32 cq_count;
struct be_queue_info q;
struct beiscsi_hba *phba;
diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 94aae45..5d59e263 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -676,10 +676,10 @@ void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int 
payload_len,
bool embedded, u8 sge_cnt)
 {
if (embedded)
-   wrb->embedded |= MCC_WRB_EMBEDDED_MASK;
+   wrb->emb_sgecnt_special |= MCC_WRB_EMBEDDED_MASK;
else
-   wrb->embedded |= (sge_cnt & MCC_WRB_SGE_CNT_MASK) <<
-   MCC_WRB_SGE_CNT_SHIFT;
+   wrb->emb_sgecnt_special |= (sge_cnt & MCC_WRB_SGE_CNT_MASK) <<
+  MCC_WRB_SGE_CNT_SHIFT;
wrb->payload_length = payload_len;
be_dws_cpu_to_le(wrb, 8);
 }
@@ -1599,7 +1599,7 @@ int beiscsi_cmd_function_reset(struct beiscsi_hba *phba)
 {
struct be_ctrl_info *ctrl = >ctrl;
struct be_mcc_wrb *wrb = wrb_from_mbox(>mbox_mem);
-   struct be_post_sgl_pages_req *req = embedded_payload(wrb);
+   struct be_post_sgl_pages_req *req;
int status;
 
mutex_lock(>mbox_lock);
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 328fb5b..1d40e83 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -31,10 +31,16 @@ struct be_sge {
__le32 len;
 };
 
-#define MCC_WRB_SGE_CNT_SHIFT 3/* bits 3 - 7 of dword 0 */
-#define MCC_WRB_SGE_CNT_MASK 0x1F  /* bits 3 - 7 of dword 0 */
 struct be_mcc_wrb {
-   u32 embedded;   /* dword 0 */
+   u32 emb_sgecnt_special; /* dword 0 */
+   /* bits 0 - embedded*/
+   /* bits 1 - 2 reserved  */
+   /* bits 3 - 7 sge count */
+   /* bits 8 - 23 reserved */
+   /* bits 24 - 31 special */
+#define MCC_WRB_EMBEDDED_MASK 1
+#define MCC_WRB_SGE_CNT_SHIFT 3
+#define MCC_WRB_SGE_CNT_MASK 0x1F
u32 payload_length; /* dword 1 */
u32 tag0;   /* dword 2 */
u32 tag1;   /* dword 3 */
@@ -1133,11 +1139,6 @@ struct tcp_connect_and_offload_out {
 
 } __packed;
 
-struct be_mcc_wrb_context {
-   struct MCC_WRB *wrb;
-   int *users_final_status;
-} __packed;
-
 #define DB_DEF_PDU_RING_ID_MASK0x3FFF  /* bits 0 - 13 */
 #define DB_DEF_PDU_CQPROC_MASK 0x3FFF  /* bits 16 - 29 */
 #define DB_DEF_PDU_REARM_SHIFT 14
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index ba25821..0ec0625 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -1114,7 +1114,7 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep,
nonemb_cmd.size = req_memsize;
memset(nonemb_cmd.va, 0, nonemb_cmd.size);
tag = mgmt_open_connection(phba, dst_addr, beiscsi_ep, _cmd);
-   if (tag <= 0) {
+   if (!tag) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BS_%d : mgmt_open_connection Failed for cid=%d\n",
beiscsi_ep->ep_cid);
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index c6af6e5..a8e67c6 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -67,8 +67,6 @@ beiscsi_##_name##_disp(struct device *dev,\
 {  \
struct Scsi_Host *shost = class_to_shost(dev);\
struct beiscsi_hba *phba = iscsi_host_priv(shost); \
-   uint32_t param_val = 0; \
-   param_val = 

[PATCH v2 07/13] be2iscsi: Remove redundant receive buffers posting

2016-12-13 Thread Jitendra Bhivare
This duplicate code got added during manual merging.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 1b5a07f..c6af6e5 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -3859,14 +3859,6 @@ static int hwi_init_port(struct beiscsi_hba *phba)
phwi_ctrlr->wrb_context[cri].cid] =
async_arr_idx++;
}
-   /**
-* Now that the default PDU rings have been created,
-* let EP know about it.
-*/
-   beiscsi_hdq_post_handles(phba, BEISCSI_DEFQ_HDR,
-ulp_num);
-   beiscsi_hdq_post_handles(phba, BEISCSI_DEFQ_DATA,
-ulp_num);
}
}
 
-- 
2.7.4

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


[PATCH v2 09/13] be2iscsi: Remove wq_name from beiscsi_hba

2016-12-13 Thread Jitendra Bhivare
wq_name is used only to set WQ name when its being allocated.
Remove it from beiscsi_hba structure and define locally.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 9 +
 drivers/scsi/be2iscsi/be_main.h | 1 -
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index a8e67c6..a68f1be 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -5623,11 +5623,12 @@ static void beiscsi_eeh_resume(struct pci_dev *pdev)
 static int beiscsi_dev_probe(struct pci_dev *pcidev,
 const struct pci_device_id *id)
 {
-   struct beiscsi_hba *phba = NULL;
-   struct hwi_controller *phwi_ctrlr;
struct hwi_context_memory *phwi_context;
+   struct hwi_controller *phwi_ctrlr;
+   struct beiscsi_hba *phba = NULL;
struct be_eq_obj *pbe_eq;
unsigned int s_handle;
+   char wq_name[20];
int ret, i;
 
ret = beiscsi_enable_pci(pcidev);
@@ -5739,9 +5740,9 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
 
phba->ctrl.mcc_alloc_index = phba->ctrl.mcc_free_index = 0;
 
-   snprintf(phba->wq_name, sizeof(phba->wq_name), "beiscsi_%02x_wq",
+   snprintf(wq_name, sizeof(wq_name), "beiscsi_%02x_wq",
 phba->shost->host_no);
-   phba->wq = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, phba->wq_name);
+   phba->wq = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, wq_name);
if (!phba->wq) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
"BM_%d : beiscsi_dev_probe-"
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 73cc2f7..30379de 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -410,7 +410,6 @@ struct beiscsi_hba {
u8 port_name;
u8 port_speed;
char fw_ver_str[BEISCSI_VER_STRLEN];
-   char wq_name[20];
struct workqueue_struct *wq;/* The actuak work queue */
struct be_ctrl_info ctrl;
unsigned int generation;
-- 
2.7.4

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


[PATCH v2 04/13] be2iscsi: Set WRB invalid bit for SkyHawk

2016-12-13 Thread Jitendra Bhivare
invalid bit in WRB indicates to FW that IO was invalidated before WRB
was fetched from host memory.

For SkyHawk, this invalid bit in WRB is at a different offset.
Use amap_iscsi_wrb_v2 to mark invalid bit for SkyHawk.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 19 ++-
 drivers/scsi/be2iscsi/be_main.h |  2 +-
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 260842a..b509acd 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -244,8 +244,13 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
beiscsi_conn = conn->dd_data;
phba = beiscsi_conn->phba;
/* mark WRB invalid which have been not processed by FW yet */
-   AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
- abrt_io_task->pwrb_handle->pwrb, 1);
+   if (is_chip_be2_be3r(phba)) {
+   AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
+ abrt_io_task->pwrb_handle->pwrb, 1);
+   } else {
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2, invld,
+ abrt_io_task->pwrb_handle->pwrb, 1);
+   }
inv_tbl.cid = beiscsi_conn->beiscsi_conn_cid;
inv_tbl.icd = abrt_io_task->psgl_handle->sgl_index;
spin_unlock_bh(>back_lock);
@@ -321,9 +326,13 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
__iscsi_get_task(task);
io_task = task->dd_data;
/* mark WRB invalid which have been not processed by FW yet */
-   AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
- io_task->pwrb_handle->pwrb,
- 1);
+   if (is_chip_be2_be3r(phba)) {
+   AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
+ io_task->pwrb_handle->pwrb, 1);
+   } else {
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2, invld,
+ io_task->pwrb_handle->pwrb, 1);
+   }
 
inv_tbl->tbl[nents].cid = beiscsi_conn->beiscsi_conn_cid;
inv_tbl->tbl[nents].icd = io_task->psgl_handle->sgl_index;
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index f869e37..8ba8c12 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -840,7 +840,7 @@ struct amap_iscsi_wrb_v2 {
u8 diff_enbl;   /* DWORD 11 */
u8 u_run;   /* DWORD 11 */
u8 o_run;   /* DWORD 11 */
-   u8 invalid; /* DWORD 11 */
+   u8 invld; /* DWORD 11 */
u8 dsp; /* DWORD 11 */
u8 dmsg;/* DWORD 11 */
u8 rsvd4;   /* DWORD 11 */
-- 
2.7.4

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


[PATCH v2 01/13] be2iscsi: Fix use of invalidate command table req

2016-12-13 Thread Jitendra Bhivare
Remove shared structure inv_tbl in phba for all sessions to post
invalidation IOCTL.
Always allocate and then free the table after use in reset handler.
Abort handler needs just one instance so define it on stack.
Add checks for BE_INVLDT_CMD_TBL_SZ to not exceed invalidation
command table size in IOCTL.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 85 -
 drivers/scsi/be2iscsi/be_main.h | 16 
 drivers/scsi/be2iscsi/be_mgmt.c | 12 +++---
 drivers/scsi/be2iscsi/be_mgmt.h | 40 +--
 4 files changed, 83 insertions(+), 70 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index b5112d6..3811a0d 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -225,9 +225,9 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
struct beiscsi_conn *beiscsi_conn;
struct beiscsi_hba *phba;
struct iscsi_session *session;
-   struct invalidate_command_table *inv_tbl;
+   struct invldt_cmd_tbl inv_tbl;
struct be_dma_mem nonemb_cmd;
-   unsigned int cid, tag, num_invalidate;
+   unsigned int cid, tag;
int rc;
 
cls_session = starget_to_session(scsi_target(sc->device));
@@ -247,35 +247,30 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
return SUCCESS;
}
spin_unlock_bh(>frwd_lock);
-   /* Invalidate WRB Posted for this Task */
-   AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
- aborted_io_task->pwrb_handle->pwrb,
- 1);
 
conn = aborted_task->conn;
beiscsi_conn = conn->dd_data;
phba = beiscsi_conn->phba;
-
+   /* Invalidate WRB Posted for this Task */
+   AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
+ aborted_io_task->pwrb_handle->pwrb,
+ 1);
/* invalidate iocb */
cid = beiscsi_conn->beiscsi_conn_cid;
-   inv_tbl = phba->inv_tbl;
-   memset(inv_tbl, 0x0, sizeof(*inv_tbl));
-   inv_tbl->cid = cid;
-   inv_tbl->icd = aborted_io_task->psgl_handle->sgl_index;
-   num_invalidate = 1;
-   nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev,
-   sizeof(struct invalidate_commands_params_in),
-   _cmd.dma);
+   inv_tbl.cid = cid;
+   inv_tbl.icd = aborted_io_task->psgl_handle->sgl_index;
+   nonemb_cmd.size = sizeof(union be_invldt_cmds_params);
+   nonemb_cmd.va = pci_zalloc_consistent(phba->ctrl.pdev,
+ nonemb_cmd.size,
+ _cmd.dma);
if (nonemb_cmd.va == NULL) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH,
"BM_%d : Failed to allocate memory for"
"mgmt_invalidate_icds\n");
return FAILED;
}
-   nonemb_cmd.size = sizeof(struct invalidate_commands_params_in);
 
-   tag = mgmt_invalidate_icds(phba, inv_tbl, num_invalidate,
-  cid, _cmd);
+   tag = mgmt_invalidate_icds(phba, _tbl, 1, cid, _cmd);
if (!tag) {
beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_EH,
"BM_%d : mgmt_invalidate_icds could not be"
@@ -303,10 +298,10 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
struct beiscsi_hba *phba;
struct iscsi_session *session;
struct iscsi_cls_session *cls_session;
-   struct invalidate_command_table *inv_tbl;
+   struct invldt_cmd_tbl *inv_tbl;
struct be_dma_mem nonemb_cmd;
-   unsigned int cid, tag, i, num_invalidate;
-   int rc;
+   unsigned int cid, tag, i, nents;
+   int rc, more = 0;
 
/* invalidate iocbs */
cls_session = starget_to_session(scsi_target(sc->device));
@@ -320,9 +315,15 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
beiscsi_conn = conn->dd_data;
phba = beiscsi_conn->phba;
cid = beiscsi_conn->beiscsi_conn_cid;
-   inv_tbl = phba->inv_tbl;
-   memset(inv_tbl, 0x0, sizeof(*inv_tbl) * BE2_CMDS_PER_CXN);
-   num_invalidate = 0;
+
+   inv_tbl = kcalloc(BE_INVLDT_CMD_TBL_SZ, sizeof(*inv_tbl), GFP_KERNEL);
+   if (!inv_tbl) {
+   spin_unlock_bh(>frwd_lock);
+   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH,
+   "BM_%d : invldt_cmd_tbl alloc failed\n");
+   return FAILED;
+   }
+   nents = 0;
for (i = 0; i < conn->session->cmds_max; i++) {
abrt_task = conn->session->cmds[i];
abrt_io_task = abrt_task->dd_data;
@@ -331,33 +332,47 @@ static int beiscsi_

[PATCH v2 05/13] be2iscsi: Add checks to validate completions

2016-12-13 Thread Jitendra Bhivare
Added check in beiscsi_process_cq for pio_handle.
pio_handle is cleared in beiscsi_put_wrb_handle.
This catches any case where task gets cleaned up just before completion.

Use back_lock before accessing pio_handle.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 28 +---
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index b509acd..832d4f0 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -960,6 +960,10 @@ beiscsi_get_wrb_handle(struct hwi_wrb_context 
*pwrb_context,
unsigned long flags;
 
spin_lock_irqsave(_context->wrb_lock, flags);
+   if (!pwrb_context->wrb_handles_available) {
+   spin_unlock_irqrestore(_context->wrb_lock, flags);
+   return NULL;
+   }
pwrb_handle = pwrb_context->pwrb_handle_base[pwrb_context->alloc_index];
pwrb_context->wrb_handles_available--;
if (pwrb_context->alloc_index == (wrbs_per_cxn - 1))
@@ -1010,6 +1014,7 @@ beiscsi_put_wrb_handle(struct hwi_wrb_context 
*pwrb_context,
pwrb_context->free_index = 0;
else
pwrb_context->free_index++;
+   pwrb_handle->pio_handle = NULL;
spin_unlock_irqrestore(_context->wrb_lock, flags);
 }
 
@@ -1220,6 +1225,7 @@ hwi_complete_drvr_msgs(struct beiscsi_conn *beiscsi_conn,
uint16_t wrb_index, cid, cri_index;
struct hwi_controller *phwi_ctrlr;
struct wrb_handle *pwrb_handle;
+   struct iscsi_session *session;
struct iscsi_task *task;
 
phwi_ctrlr = phba->phwi_ctrlr;
@@ -1238,8 +1244,12 @@ hwi_complete_drvr_msgs(struct beiscsi_conn *beiscsi_conn,
cri_index = BE_GET_CRI_FROM_CID(cid);
pwrb_context = _ctrlr->wrb_context[cri_index];
pwrb_handle = pwrb_context->pwrb_handle_basestd[wrb_index];
+   session = beiscsi_conn->conn->session;
+   spin_lock_bh(>back_lock);
task = pwrb_handle->pio_handle;
-   iscsi_put_task(task);
+   if (task)
+   __iscsi_put_task(task);
+   spin_unlock_bh(>back_lock);
 }
 
 static void
@@ -1319,16 +1329,16 @@ static void adapter_get_sol_cqe(struct beiscsi_hba 
*phba,
 static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn,
 struct beiscsi_hba *phba, struct sol_cqe *psol)
 {
+   struct iscsi_conn *conn = beiscsi_conn->conn;
+   struct iscsi_session *session = conn->session;
+   struct common_sol_cqe csol_cqe = {0};
struct hwi_wrb_context *pwrb_context;
+   struct hwi_controller *phwi_ctrlr;
struct wrb_handle *pwrb_handle;
struct iscsi_wrb *pwrb = NULL;
-   struct hwi_controller *phwi_ctrlr;
struct iscsi_task *task;
-   unsigned int type;
-   struct iscsi_conn *conn = beiscsi_conn->conn;
-   struct iscsi_session *session = conn->session;
-   struct common_sol_cqe csol_cqe = {0};
uint16_t cri_index = 0;
+   uint8_t type;
 
phwi_ctrlr = phba->phwi_ctrlr;
 
@@ -1341,11 +1351,15 @@ static void hwi_complete_cmd(struct beiscsi_conn 
*beiscsi_conn,
pwrb_handle = pwrb_context->pwrb_handle_basestd[
  csol_cqe.wrb_index];
 
+   spin_lock_bh(>back_lock);
task = pwrb_handle->pio_handle;
+   if (!task) {
+   spin_unlock_bh(>back_lock);
+   return;
+   }
pwrb = pwrb_handle->pwrb;
type = ((struct beiscsi_io_task *)task->dd_data)->wrb_type;
 
-   spin_lock_bh(>back_lock);
switch (type) {
case HWH_TYPE_IO:
case HWH_TYPE_IO_RD:
-- 
2.7.4

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


[PATCH v2 03/13] be2iscsi: Take iscsi_task ref in abort handler

2016-12-13 Thread Jitendra Bhivare
Hold the reference of iscsi_task till invalidation completes.
This prevents use of ICD when invalidation of that ICD is being processed.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 45 +
 1 file changed, 19 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 7feecc0..260842a 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -218,47 +218,40 @@ static int beiscsi_slave_configure(struct scsi_device 
*sdev)
 
 static int beiscsi_eh_abort(struct scsi_cmnd *sc)
 {
+   struct iscsi_task *abrt_task = (struct iscsi_task *)sc->SCp.ptr;
struct iscsi_cls_session *cls_session;
-   struct iscsi_task *aborted_task = (struct iscsi_task *)sc->SCp.ptr;
-   struct beiscsi_io_task *aborted_io_task;
-   struct iscsi_conn *conn;
+   struct beiscsi_io_task *abrt_io_task;
struct beiscsi_conn *beiscsi_conn;
-   struct beiscsi_hba *phba;
struct iscsi_session *session;
struct invldt_cmd_tbl inv_tbl;
-   unsigned int cid;
+   struct beiscsi_hba *phba;
+   struct iscsi_conn *conn;
int rc;
 
cls_session = starget_to_session(scsi_target(sc->device));
session = cls_session->dd_data;
 
-   spin_lock_bh(>frwd_lock);
-   if (!aborted_task || !aborted_task->sc) {
-   /* we raced */
-   spin_unlock_bh(>frwd_lock);
-   return SUCCESS;
-   }
-
-   aborted_io_task = aborted_task->dd_data;
-   if (!aborted_io_task->scsi_cmnd) {
-   /* raced or invalid command */
-   spin_unlock_bh(>frwd_lock);
+   /* check if we raced, task just got cleaned up under us */
+   spin_lock_bh(>back_lock);
+   if (!abrt_task || !abrt_task->sc) {
+   spin_unlock_bh(>back_lock);
return SUCCESS;
}
-   spin_unlock_bh(>frwd_lock);
-
-   conn = aborted_task->conn;
+   /* get a task ref till FW processes the req for the ICD used */
+   __iscsi_get_task(abrt_task);
+   abrt_io_task = abrt_task->dd_data;
+   conn = abrt_task->conn;
beiscsi_conn = conn->dd_data;
phba = beiscsi_conn->phba;
-   /* Invalidate WRB Posted for this Task */
+   /* mark WRB invalid which have been not processed by FW yet */
AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
- aborted_io_task->pwrb_handle->pwrb,
- 1);
-   /* invalidate iocb */
-   cid = beiscsi_conn->beiscsi_conn_cid;
-   inv_tbl.cid = cid;
-   inv_tbl.icd = aborted_io_task->psgl_handle->sgl_index;
+ abrt_io_task->pwrb_handle->pwrb, 1);
+   inv_tbl.cid = beiscsi_conn->beiscsi_conn_cid;
+   inv_tbl.icd = abrt_io_task->psgl_handle->sgl_index;
+   spin_unlock_bh(>back_lock);
+
rc = beiscsi_mgmt_invalidate_icds(phba, _tbl, 1);
+   iscsi_put_task(abrt_task);
if (rc) {
beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_EH,
"BM_%d : sc %p invalidation failed %d\n",
-- 
2.7.4

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


[PATCH v2 00/13] be2iscsi: driver update 11.2.1.0

2016-12-13 Thread Jitendra Bhivare
This patch is generated against for-next branch.

v2 changes:
  +be2iscsi: Reinit SGL handle, CID tables after TPE

Jitendra Bhivare (12):
  be2iscsi: Fix use of invalidate command table req
  be2iscsi: Fix for crash in beiscsi_eh_device_reset
  be2iscsi: Take iscsi_task ref in abort handler
  be2iscsi: Set WRB invalid bit for SkyHawk
  be2iscsi: Add checks to validate completions
  be2iscsi: Fix iSCSI cmd cleanup IOCTL
  be2iscsi: Remove redundant receive buffers posting
  be2iscsi: Remove unused struct members
  be2iscsi: Remove wq_name from beiscsi_hba
  be2iscsi: Add checks to validate CID alloc/free
  be2iscsi: Reinit SGL handle, CID tables after TPE
  be2iscsi: Update driver version

Ketan Mukadam (1):
  be2iscsi: Add warning message for unsupported adapter

 drivers/scsi/be2iscsi/be.h   |   3 -
 drivers/scsi/be2iscsi/be_cmds.c  |  41 ++---
 drivers/scsi/be2iscsi/be_cmds.h  |  17 +-
 drivers/scsi/be2iscsi/be_iscsi.c | 165 +--
 drivers/scsi/be2iscsi/be_main.c  | 344 ++-
 drivers/scsi/be2iscsi/be_main.h  |  44 ++---
 drivers/scsi/be2iscsi/be_mgmt.c  | 117 +++--
 drivers/scsi/be2iscsi/be_mgmt.h  |  98 ++-
 8 files changed, 363 insertions(+), 466 deletions(-)

-- 
2.7.4

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


[PATCH v2 02/13] be2iscsi: Fix for crash in beiscsi_eh_device_reset

2016-12-13 Thread Jitendra Bhivare
System crashes when sg_reset is executed in a loop.
CPU: 13 PID: 7073 Comm: sg_reset Tainted: GE   4.8.0-rc1+ #4
RIP: 0010:[]  []
beiscsi_eh_device_reset+0x160/0x520 [be2iscsi]
Call Trace:
[] ? scsi_host_alloc_command+0x47/0xc0
[] scsi_try_bus_device_reset+0x2a/0x50
[] scsi_ioctl_reset+0x13e/0x260
[] scsi_ioctl+0x137/0x3d0
[] sg_ioctl+0x572/0xc20 [sg]
[] do_vfs_ioctl+0xa7/0x5d0

The accesses to beiscsi_io_task is being protected in device reset handler
with frwd_lock but the freeing of task can happen under back_lock.

Hold the reference of iscsi_task till invalidation completes.
This prevents use of ICD when invalidation of that ICD is being processed.
Use frwd_lock for iscsi_tasks looping and back_lock to access
beiscsi_io_task structures.

Rewrite mgmt_invalidation_icds to handle allocation and freeing of IOCTL
buffer in one place.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 121 +---
 drivers/scsi/be2iscsi/be_mgmt.c | 107 ---
 drivers/scsi/be2iscsi/be_mgmt.h |   8 +--
 3 files changed, 114 insertions(+), 122 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 3811a0d..7feecc0 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -226,8 +226,7 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
struct beiscsi_hba *phba;
struct iscsi_session *session;
struct invldt_cmd_tbl inv_tbl;
-   struct be_dma_mem nonemb_cmd;
-   unsigned int cid, tag;
+   unsigned int cid;
int rc;
 
cls_session = starget_to_session(scsi_target(sc->device));
@@ -259,64 +258,47 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
cid = beiscsi_conn->beiscsi_conn_cid;
inv_tbl.cid = cid;
inv_tbl.icd = aborted_io_task->psgl_handle->sgl_index;
-   nonemb_cmd.size = sizeof(union be_invldt_cmds_params);
-   nonemb_cmd.va = pci_zalloc_consistent(phba->ctrl.pdev,
- nonemb_cmd.size,
- _cmd.dma);
-   if (nonemb_cmd.va == NULL) {
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH,
-   "BM_%d : Failed to allocate memory for"
-   "mgmt_invalidate_icds\n");
-   return FAILED;
-   }
-
-   tag = mgmt_invalidate_icds(phba, _tbl, 1, cid, _cmd);
-   if (!tag) {
+   rc = beiscsi_mgmt_invalidate_icds(phba, _tbl, 1);
+   if (rc) {
beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_EH,
-   "BM_%d : mgmt_invalidate_icds could not be"
-   "submitted\n");
-   pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
-   nonemb_cmd.va, nonemb_cmd.dma);
-
+   "BM_%d : sc %p invalidation failed %d\n",
+   sc, rc);
return FAILED;
}
 
-   rc = beiscsi_mccq_compl_wait(phba, tag, NULL, _cmd);
-   if (rc != -EBUSY)
-   pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
-   nonemb_cmd.va, nonemb_cmd.dma);
-
return iscsi_eh_abort(sc);
 }
 
 static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
 {
-   struct iscsi_task *abrt_task;
-   struct beiscsi_io_task *abrt_io_task;
-   struct iscsi_conn *conn;
+   struct beiscsi_invldt_cmd_tbl {
+   struct invldt_cmd_tbl tbl[BE_INVLDT_CMD_TBL_SZ];
+   struct iscsi_task *task[BE_INVLDT_CMD_TBL_SZ];
+   } *inv_tbl;
+   struct iscsi_cls_session *cls_session;
struct beiscsi_conn *beiscsi_conn;
-   struct beiscsi_hba *phba;
+   struct beiscsi_io_task *io_task;
struct iscsi_session *session;
-   struct iscsi_cls_session *cls_session;
-   struct invldt_cmd_tbl *inv_tbl;
-   struct be_dma_mem nonemb_cmd;
-   unsigned int cid, tag, i, nents;
+   struct beiscsi_hba *phba;
+   struct iscsi_conn *conn;
+   struct iscsi_task *task;
+   unsigned int i, nents;
int rc, more = 0;
 
-   /* invalidate iocbs */
cls_session = starget_to_session(scsi_target(sc->device));
session = cls_session->dd_data;
+
spin_lock_bh(>frwd_lock);
if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN) {
spin_unlock_bh(>frwd_lock);
return FAILED;
}
+
conn = session->leadconn;
beiscsi_conn = conn->dd_data;
phba = beiscsi_conn->phba;
-   cid = beiscsi_conn->beiscsi_conn_cid;
 
-   inv_tbl = kcalloc(BE_INVLDT_CMD_TBL_SZ, sizeof(*inv_tbl), GFP_KERNEL);
+   inv_tbl = kzalloc(sizeof(*inv_tbl), GFP_KERNEL);
if (!inv_tb

[PATCH 09/12] be2iscsi: Remove wq_name from beiscsi_hba

2016-12-05 Thread Jitendra Bhivare
wq_name is used only to set WQ name when its being allocated.
Remove it from beiscsi_hba structure and define locally.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 9 +
 drivers/scsi/be2iscsi/be_main.h | 1 -
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 723869d..c04080f 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -5619,11 +5619,12 @@ static void beiscsi_eeh_resume(struct pci_dev *pdev)
 static int beiscsi_dev_probe(struct pci_dev *pcidev,
 const struct pci_device_id *id)
 {
-   struct beiscsi_hba *phba = NULL;
-   struct hwi_controller *phwi_ctrlr;
struct hwi_context_memory *phwi_context;
+   struct hwi_controller *phwi_ctrlr;
+   struct beiscsi_hba *phba = NULL;
struct be_eq_obj *pbe_eq;
unsigned int s_handle;
+   char wq_name[20];
int ret, i;
 
ret = beiscsi_enable_pci(pcidev);
@@ -5735,9 +5736,9 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
 
phba->ctrl.mcc_alloc_index = phba->ctrl.mcc_free_index = 0;
 
-   snprintf(phba->wq_name, sizeof(phba->wq_name), "beiscsi_%02x_wq",
+   snprintf(wq_name, sizeof(wq_name), "beiscsi_%02x_wq",
 phba->shost->host_no);
-   phba->wq = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, phba->wq_name);
+   phba->wq = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, wq_name);
if (!phba->wq) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
"BM_%d : beiscsi_dev_probe-"
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 73cc2f7..30379de 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -410,7 +410,6 @@ struct beiscsi_hba {
u8 port_name;
u8 port_speed;
char fw_ver_str[BEISCSI_VER_STRLEN];
-   char wq_name[20];
struct workqueue_struct *wq;/* The actuak work queue */
struct be_ctrl_info ctrl;
unsigned int generation;
-- 
1.8.3.1

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


[PATCH 11/12] be2iscsi: Add warning message for unsupported adapter

2016-12-05 Thread Jitendra Bhivare
From: Ketan Mukadam <ketan.muka...@avagotech.com>

Add a warning message to indicate obsolete/unsupported
BE2 Adapter Family devices

Signed-off-by: Ketan Mukadam <ketan.muka...@avagotech.com>
Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 2 ++
 drivers/scsi/be2iscsi/be_mgmt.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 3f3a138..08d0855 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -5663,6 +5663,8 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
case OC_DEVICE_ID2:
phba->generation = BE_GEN2;
phba->iotask_fn = beiscsi_iotask;
+   dev_warn(>dev,
+"Obsolete/Unsupported BE2 Adapter Family\n");
break;
case BE_DEVICE_ID2:
case OC_DEVICE_ID3:
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 8acacd5e..2f6d5c2 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1262,7 +1262,8 @@ int beiscsi_boot_get_shandle(struct beiscsi_hba *phba, 
unsigned int *s_handle)
case BE_DEVICE_ID1:
case OC_DEVICE_ID1:
case OC_DEVICE_ID2:
-   return snprintf(buf, PAGE_SIZE, "BE2 Adapter Family\n");
+   return snprintf(buf, PAGE_SIZE,
+   "Obsolete/Unsupported BE2 Adapter Family\n");
break;
case BE_DEVICE_ID2:
case OC_DEVICE_ID3:
-- 
1.8.3.1

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


[PATCH 12/12] be2iscsi: Update driver version

2016-12-05 Thread Jitendra Bhivare
Version 11.2.1.0

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 02a9b2d..2188579 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -36,7 +36,7 @@
 #include 
 
 #define DRV_NAME   "be2iscsi"
-#define BUILD_STR  "11.2.0.0"
+#define BUILD_STR  "11.2.1.0"
 #define BE_NAME"Emulex OneConnect" \
"Open-iSCSI Driver version" BUILD_STR
 #define DRV_DESC   BE_NAME " " "Driver"
-- 
1.8.3.1

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


[PATCH 08/12] be2iscsi: Remove unused struct members

2016-12-05 Thread Jitendra Bhivare
Fix errors reported in static analysis.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be.h   |  3 --
 drivers/scsi/be2iscsi/be_cmds.c  |  8 +++---
 drivers/scsi/be2iscsi/be_cmds.h  | 17 ++--
 drivers/scsi/be2iscsi/be_iscsi.c |  2 +-
 drivers/scsi/be2iscsi/be_main.c  | 24 +++-
 drivers/scsi/be2iscsi/be_main.h  | 22 ---
 drivers/scsi/be2iscsi/be_mgmt.c  |  9 ++
 drivers/scsi/be2iscsi/be_mgmt.h  | 60 
 8 files changed, 21 insertions(+), 124 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index b1d0fdc..ca9440f 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -84,7 +84,6 @@ static inline void queue_tail_inc(struct be_queue_info *q)
 /*ISCSI */
 
 struct be_aic_obj {/* Adaptive interrupt coalescing (AIC) info */
-   bool enable;
u32 min_eqd;/* in usecs */
u32 max_eqd;/* in usecs */
u32 prev_eqd;   /* in usecs */
@@ -94,8 +93,6 @@ struct be_aic_obj {   /* Adaptive interrupt 
coalescing (AIC) info */
 };
 
 struct be_eq_obj {
-   bool todo_mcc_cq;
-   bool todo_cq;
u32 cq_count;
struct be_queue_info q;
struct beiscsi_hba *phba;
diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 94aae45..5d59e263 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -676,10 +676,10 @@ void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int 
payload_len,
bool embedded, u8 sge_cnt)
 {
if (embedded)
-   wrb->embedded |= MCC_WRB_EMBEDDED_MASK;
+   wrb->emb_sgecnt_special |= MCC_WRB_EMBEDDED_MASK;
else
-   wrb->embedded |= (sge_cnt & MCC_WRB_SGE_CNT_MASK) <<
-   MCC_WRB_SGE_CNT_SHIFT;
+   wrb->emb_sgecnt_special |= (sge_cnt & MCC_WRB_SGE_CNT_MASK) <<
+  MCC_WRB_SGE_CNT_SHIFT;
wrb->payload_length = payload_len;
be_dws_cpu_to_le(wrb, 8);
 }
@@ -1599,7 +1599,7 @@ int beiscsi_cmd_function_reset(struct beiscsi_hba *phba)
 {
struct be_ctrl_info *ctrl = >ctrl;
struct be_mcc_wrb *wrb = wrb_from_mbox(>mbox_mem);
-   struct be_post_sgl_pages_req *req = embedded_payload(wrb);
+   struct be_post_sgl_pages_req *req;
int status;
 
mutex_lock(>mbox_lock);
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 328fb5b..1d40e83 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -31,10 +31,16 @@ struct be_sge {
__le32 len;
 };
 
-#define MCC_WRB_SGE_CNT_SHIFT 3/* bits 3 - 7 of dword 0 */
-#define MCC_WRB_SGE_CNT_MASK 0x1F  /* bits 3 - 7 of dword 0 */
 struct be_mcc_wrb {
-   u32 embedded;   /* dword 0 */
+   u32 emb_sgecnt_special; /* dword 0 */
+   /* bits 0 - embedded*/
+   /* bits 1 - 2 reserved  */
+   /* bits 3 - 7 sge count */
+   /* bits 8 - 23 reserved */
+   /* bits 24 - 31 special */
+#define MCC_WRB_EMBEDDED_MASK 1
+#define MCC_WRB_SGE_CNT_SHIFT 3
+#define MCC_WRB_SGE_CNT_MASK 0x1F
u32 payload_length; /* dword 1 */
u32 tag0;   /* dword 2 */
u32 tag1;   /* dword 3 */
@@ -1133,11 +1139,6 @@ struct tcp_connect_and_offload_out {
 
 } __packed;
 
-struct be_mcc_wrb_context {
-   struct MCC_WRB *wrb;
-   int *users_final_status;
-} __packed;
-
 #define DB_DEF_PDU_RING_ID_MASK0x3FFF  /* bits 0 - 13 */
 #define DB_DEF_PDU_CQPROC_MASK 0x3FFF  /* bits 16 - 29 */
 #define DB_DEF_PDU_REARM_SHIFT 14
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index ba25821..0ec0625 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -1114,7 +1114,7 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep,
nonemb_cmd.size = req_memsize;
memset(nonemb_cmd.va, 0, nonemb_cmd.size);
tag = mgmt_open_connection(phba, dst_addr, beiscsi_ep, _cmd);
-   if (tag <= 0) {
+   if (!tag) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BS_%d : mgmt_open_connection Failed for cid=%d\n",
beiscsi_ep->ep_cid);
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 9b8b79f..723869d 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -67,8 +67,6 @@
 {  \
struct Scsi_Host *shost = class_to_shost(dev);\
struct beiscsi_hba *phba = iscsi_host_priv(shost); \
-   uint32_t param_val = 0; \
-   param_val = phba->attr_##_name;\
return snprintf(buf, PAGE_SIZE, "

[PATCH 10/12] be2iscsi: Add checks to validate CID alloc/free

2016-12-05 Thread Jitendra Bhivare
Set CID slot to 0x to indicate empty.
Check if connection already exists in conn_table before binding.
Check if endpoint already NULL before putting back CID.
Break ep->conn link in free_ep to ignore completions after freeing.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_iscsi.c | 163 ---
 drivers/scsi/be2iscsi/be_main.c  |   7 +-
 drivers/scsi/be2iscsi/be_main.h  |   1 +
 3 files changed, 87 insertions(+), 84 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 0ec0625..a484457 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -166,33 +166,6 @@ struct iscsi_cls_conn *
 }
 
 /**
- * beiscsi_bindconn_cid - Bind the beiscsi_conn with phba connection table
- * @beiscsi_conn: The pointer to  beiscsi_conn structure
- * @phba: The phba instance
- * @cid: The cid to free
- */
-static int beiscsi_bindconn_cid(struct beiscsi_hba *phba,
-   struct beiscsi_conn *beiscsi_conn,
-   unsigned int cid)
-{
-   uint16_t cri_index = BE_GET_CRI_FROM_CID(cid);
-
-   if (phba->conn_table[cri_index]) {
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
-   "BS_%d : Connection table already occupied. 
Detected clash\n");
-
-   return -EINVAL;
-   } else {
-   beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
-   "BS_%d : phba->conn_table[%d]=%p(beiscsi_conn)\n",
-   cri_index, beiscsi_conn);
-
-   phba->conn_table[cri_index] = beiscsi_conn;
-   }
-   return 0;
-}
-
-/**
  * beiscsi_conn_bind - Binds iscsi session/connection with TCP connection
  * @cls_session: pointer to iscsi cls session
  * @cls_conn: pointer to iscsi cls conn
@@ -212,6 +185,7 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session,
struct hwi_wrb_context *pwrb_context;
struct beiscsi_endpoint *beiscsi_ep;
struct iscsi_endpoint *ep;
+   uint16_t cri_index;
 
ep = iscsi_lookup_endpoint(transport_fd);
if (!ep)
@@ -229,20 +203,34 @@ int beiscsi_conn_bind(struct iscsi_cls_session 
*cls_session,
 
return -EEXIST;
}
-
-   pwrb_context = _ctrlr->wrb_context[BE_GET_CRI_FROM_CID(
-   beiscsi_ep->ep_cid)];
+   cri_index = BE_GET_CRI_FROM_CID(beiscsi_ep->ep_cid);
+   if (phba->conn_table[cri_index]) {
+   if (beiscsi_conn != phba->conn_table[cri_index] ||
+   beiscsi_ep != phba->conn_table[cri_index]->ep) {
+   __beiscsi_log(phba, KERN_ERR,
+ "BS_%d : conn_table not empty at %u: cid 
%u conn %p:%p\n",
+ cri_index,
+ beiscsi_ep->ep_cid,
+ beiscsi_conn,
+ phba->conn_table[cri_index]);
+   return -EINVAL;
+   }
+   }
 
beiscsi_conn->beiscsi_conn_cid = beiscsi_ep->ep_cid;
beiscsi_conn->ep = beiscsi_ep;
beiscsi_ep->conn = beiscsi_conn;
+   /**
+* Each connection is associated with a WRBQ kept in wrb_context.
+* Store doorbell offset for transmit path.
+*/
+   pwrb_context = _ctrlr->wrb_context[cri_index];
beiscsi_conn->doorbell_offset = pwrb_context->doorbell_offset;
-
beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
-   "BS_%d : beiscsi_conn=%p conn=%p ep_cid=%d\n",
-   beiscsi_conn, conn, beiscsi_ep->ep_cid);
-
-   return beiscsi_bindconn_cid(phba, beiscsi_conn, beiscsi_ep->ep_cid);
+   "BS_%d : cid %d phba->conn_table[%u]=%p\n",
+   beiscsi_ep->ep_cid, cri_index, beiscsi_conn);
+   phba->conn_table[cri_index] = beiscsi_conn;
+   return 0;
 }
 
 static int beiscsi_iface_create_ipv4(struct beiscsi_hba *phba)
@@ -973,9 +961,9 @@ int beiscsi_conn_start(struct iscsi_cls_conn *cls_conn)
  */
 static int beiscsi_get_cid(struct beiscsi_hba *phba)
 {
-   unsigned short cid = 0x, cid_from_ulp;
-   struct ulp_cid_info *cid_info = NULL;
uint16_t cid_avlbl_ulp0, cid_avlbl_ulp1;
+   unsigned short cid, cid_from_ulp;
+   struct ulp_cid_info *cid_info;
 
/* Find the ULP which has more CID available */
cid_avlbl_ulp0 = (phba->cid_array_info[BEISCSI_ULP0]) ?
@@ -984,20 +972,27 @@ static int beiscsi_get_cid(struct beiscsi_hba *phba)
  BEISCSI_ULP1_AVLBL_CID(phba) : 0;
cid_from_ulp = (cid_avlbl_ulp0 > cid_avlbl_ulp1) ?
BEISCSI_ULP0 : BEISCSI_ULP

[PATCH 07/12] be2iscsi: Remove redundant receive buffers posting

2016-12-05 Thread Jitendra Bhivare
This duplicate code got added during manual merging.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 0fa24a3..9b8b79f 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -3855,14 +3855,6 @@ static int hwi_init_port(struct beiscsi_hba *phba)
phwi_ctrlr->wrb_context[cri].cid] =
async_arr_idx++;
}
-   /**
-* Now that the default PDU rings have been created,
-* let EP know about it.
-*/
-   beiscsi_hdq_post_handles(phba, BEISCSI_DEFQ_HDR,
-ulp_num);
-   beiscsi_hdq_post_handles(phba, BEISCSI_DEFQ_DATA,
-ulp_num);
}
}
 
-- 
1.8.3.1

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


[PATCH 04/12] be2iscsi: Set WRB invalid bit for SkyHawk

2016-12-05 Thread Jitendra Bhivare
invalid bit in WRB indicates to FW that IO was invalidated before WRB
was fetched from host memory.

For SkyHawk, this invalid bit in WRB is at a different offset.
Use amap_iscsi_wrb_v2 to mark invalid bit for SkyHawk.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 19 ++-
 drivers/scsi/be2iscsi/be_main.h |  2 +-
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 6eaa78bd..948384c 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -244,8 +244,13 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
beiscsi_conn = conn->dd_data;
phba = beiscsi_conn->phba;
/* mark WRB invalid which have been not processed by FW yet */
-   AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
- abrt_io_task->pwrb_handle->pwrb, 1);
+   if (is_chip_be2_be3r(phba)) {
+   AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
+ abrt_io_task->pwrb_handle->pwrb, 1);
+   } else {
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2, invld,
+ abrt_io_task->pwrb_handle->pwrb, 1);
+   }
inv_tbl.cid = beiscsi_conn->beiscsi_conn_cid;
inv_tbl.icd = abrt_io_task->psgl_handle->sgl_index;
spin_unlock_bh(>back_lock);
@@ -321,9 +326,13 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
__iscsi_get_task(task);
io_task = task->dd_data;
/* mark WRB invalid which have been not processed by FW yet */
-   AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
- io_task->pwrb_handle->pwrb,
- 1);
+   if (is_chip_be2_be3r(phba)) {
+   AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
+ io_task->pwrb_handle->pwrb, 1);
+   } else {
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2, invld,
+ io_task->pwrb_handle->pwrb, 1);
+   }
 
inv_tbl->tbl[nents].cid = beiscsi_conn->beiscsi_conn_cid;
inv_tbl->tbl[nents].icd = io_task->psgl_handle->sgl_index;
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index f869e37..8ba8c12 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -840,7 +840,7 @@ struct amap_iscsi_wrb_v2 {
u8 diff_enbl;   /* DWORD 11 */
u8 u_run;   /* DWORD 11 */
u8 o_run;   /* DWORD 11 */
-   u8 invalid; /* DWORD 11 */
+   u8 invld; /* DWORD 11 */
u8 dsp; /* DWORD 11 */
u8 dmsg;/* DWORD 11 */
u8 rsvd4;   /* DWORD 11 */
-- 
1.8.3.1

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


[PATCH 01/12] be2iscsi: Fix use of invalidate command table req

2016-12-05 Thread Jitendra Bhivare
Remove shared structure inv_tbl in phba for all sessions to post
invalidation IOCTL.
Always allocate and then free the table after use in reset handler.
Abort handler needs just one instance so define it on stack.
Add checks for BE_INVLDT_CMD_TBL_SZ to not exceed invalidation
command table size in IOCTL.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 85 -
 drivers/scsi/be2iscsi/be_main.h | 16 
 drivers/scsi/be2iscsi/be_mgmt.c | 12 +++---
 drivers/scsi/be2iscsi/be_mgmt.h | 40 +--
 4 files changed, 83 insertions(+), 70 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index d9239c2..df78c10 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -225,9 +225,9 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
struct beiscsi_conn *beiscsi_conn;
struct beiscsi_hba *phba;
struct iscsi_session *session;
-   struct invalidate_command_table *inv_tbl;
+   struct invldt_cmd_tbl inv_tbl;
struct be_dma_mem nonemb_cmd;
-   unsigned int cid, tag, num_invalidate;
+   unsigned int cid, tag;
int rc;
 
cls_session = starget_to_session(scsi_target(sc->device));
@@ -247,35 +247,30 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
return SUCCESS;
}
spin_unlock_bh(>frwd_lock);
-   /* Invalidate WRB Posted for this Task */
-   AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
- aborted_io_task->pwrb_handle->pwrb,
- 1);
 
conn = aborted_task->conn;
beiscsi_conn = conn->dd_data;
phba = beiscsi_conn->phba;
-
+   /* Invalidate WRB Posted for this Task */
+   AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
+ aborted_io_task->pwrb_handle->pwrb,
+ 1);
/* invalidate iocb */
cid = beiscsi_conn->beiscsi_conn_cid;
-   inv_tbl = phba->inv_tbl;
-   memset(inv_tbl, 0x0, sizeof(*inv_tbl));
-   inv_tbl->cid = cid;
-   inv_tbl->icd = aborted_io_task->psgl_handle->sgl_index;
-   num_invalidate = 1;
-   nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev,
-   sizeof(struct invalidate_commands_params_in),
-   _cmd.dma);
+   inv_tbl.cid = cid;
+   inv_tbl.icd = aborted_io_task->psgl_handle->sgl_index;
+   nonemb_cmd.size = sizeof(union be_invldt_cmds_params);
+   nonemb_cmd.va = pci_zalloc_consistent(phba->ctrl.pdev,
+ nonemb_cmd.size,
+ _cmd.dma);
if (nonemb_cmd.va == NULL) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH,
"BM_%d : Failed to allocate memory for"
"mgmt_invalidate_icds\n");
return FAILED;
}
-   nonemb_cmd.size = sizeof(struct invalidate_commands_params_in);
 
-   tag = mgmt_invalidate_icds(phba, inv_tbl, num_invalidate,
-  cid, _cmd);
+   tag = mgmt_invalidate_icds(phba, _tbl, 1, cid, _cmd);
if (!tag) {
beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_EH,
"BM_%d : mgmt_invalidate_icds could not be"
@@ -303,10 +298,10 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
struct beiscsi_hba *phba;
struct iscsi_session *session;
struct iscsi_cls_session *cls_session;
-   struct invalidate_command_table *inv_tbl;
+   struct invldt_cmd_tbl *inv_tbl;
struct be_dma_mem nonemb_cmd;
-   unsigned int cid, tag, i, num_invalidate;
-   int rc;
+   unsigned int cid, tag, i, nents;
+   int rc, more = 0;
 
/* invalidate iocbs */
cls_session = starget_to_session(scsi_target(sc->device));
@@ -320,9 +315,15 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
beiscsi_conn = conn->dd_data;
phba = beiscsi_conn->phba;
cid = beiscsi_conn->beiscsi_conn_cid;
-   inv_tbl = phba->inv_tbl;
-   memset(inv_tbl, 0x0, sizeof(*inv_tbl) * BE2_CMDS_PER_CXN);
-   num_invalidate = 0;
+
+   inv_tbl = kcalloc(BE_INVLDT_CMD_TBL_SZ, sizeof(*inv_tbl), GFP_KERNEL);
+   if (!inv_tbl) {
+   spin_unlock_bh(>frwd_lock);
+   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH,
+   "BM_%d : invldt_cmd_tbl alloc failed\n");
+   return FAILED;
+   }
+   nents = 0;
for (i = 0; i < conn->session->cmds_max; i++) {
abrt_task = conn->session->cmds[i];
abrt_io_task = abrt_task->dd_data;
@@ -331,33 +332,47 @@ static int beiscsi_

[PATCH 05/12] be2iscsi: Add checks to validate completions

2016-12-05 Thread Jitendra Bhivare
Added check in beiscsi_process_cq for pio_handle.
pio_handle is cleared in beiscsi_put_wrb_handle.
This catches any case where task gets cleaned up just before completion.

Use back_lock before accessing pio_handle.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 28 +---
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 948384c..bd5e10e 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -960,6 +960,10 @@ static struct sgl_handle *alloc_io_sgl_handle(struct 
beiscsi_hba *phba)
unsigned long flags;
 
spin_lock_irqsave(_context->wrb_lock, flags);
+   if (!pwrb_context->wrb_handles_available) {
+   spin_unlock_irqrestore(_context->wrb_lock, flags);
+   return NULL;
+   }
pwrb_handle = pwrb_context->pwrb_handle_base[pwrb_context->alloc_index];
pwrb_context->wrb_handles_available--;
if (pwrb_context->alloc_index == (wrbs_per_cxn - 1))
@@ -1010,6 +1014,7 @@ struct wrb_handle *alloc_wrb_handle(struct beiscsi_hba 
*phba, unsigned int cid,
pwrb_context->free_index = 0;
else
pwrb_context->free_index++;
+   pwrb_handle->pio_handle = NULL;
spin_unlock_irqrestore(_context->wrb_lock, flags);
 }
 
@@ -1220,6 +1225,7 @@ static struct sgl_handle *alloc_mgmt_sgl_handle(struct 
beiscsi_hba *phba)
uint16_t wrb_index, cid, cri_index;
struct hwi_controller *phwi_ctrlr;
struct wrb_handle *pwrb_handle;
+   struct iscsi_session *session;
struct iscsi_task *task;
 
phwi_ctrlr = phba->phwi_ctrlr;
@@ -1238,8 +1244,12 @@ static struct sgl_handle *alloc_mgmt_sgl_handle(struct 
beiscsi_hba *phba)
cri_index = BE_GET_CRI_FROM_CID(cid);
pwrb_context = _ctrlr->wrb_context[cri_index];
pwrb_handle = pwrb_context->pwrb_handle_basestd[wrb_index];
+   session = beiscsi_conn->conn->session;
+   spin_lock_bh(>back_lock);
task = pwrb_handle->pio_handle;
-   iscsi_put_task(task);
+   if (task)
+   __iscsi_put_task(task);
+   spin_unlock_bh(>back_lock);
 }
 
 static void
@@ -1319,16 +1329,16 @@ static void adapter_get_sol_cqe(struct beiscsi_hba 
*phba,
 static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn,
 struct beiscsi_hba *phba, struct sol_cqe *psol)
 {
+   struct iscsi_conn *conn = beiscsi_conn->conn;
+   struct iscsi_session *session = conn->session;
+   struct common_sol_cqe csol_cqe = {0};
struct hwi_wrb_context *pwrb_context;
+   struct hwi_controller *phwi_ctrlr;
struct wrb_handle *pwrb_handle;
struct iscsi_wrb *pwrb = NULL;
-   struct hwi_controller *phwi_ctrlr;
struct iscsi_task *task;
-   unsigned int type;
-   struct iscsi_conn *conn = beiscsi_conn->conn;
-   struct iscsi_session *session = conn->session;
-   struct common_sol_cqe csol_cqe = {0};
uint16_t cri_index = 0;
+   uint8_t type;
 
phwi_ctrlr = phba->phwi_ctrlr;
 
@@ -1341,11 +1351,15 @@ static void hwi_complete_cmd(struct beiscsi_conn 
*beiscsi_conn,
pwrb_handle = pwrb_context->pwrb_handle_basestd[
  csol_cqe.wrb_index];
 
+   spin_lock_bh(>back_lock);
task = pwrb_handle->pio_handle;
+   if (!task) {
+   spin_unlock_bh(>back_lock);
+   return;
+   }
pwrb = pwrb_handle->pwrb;
type = ((struct beiscsi_io_task *)task->dd_data)->wrb_type;
 
-   spin_lock_bh(>back_lock);
switch (type) {
case HWH_TYPE_IO:
case HWH_TYPE_IO_RD:
-- 
1.8.3.1

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


[PATCH 02/12] be2iscsi: Fix for crash in beiscsi_eh_device_reset

2016-12-05 Thread Jitendra Bhivare
System crashes when sg_reset is executed in a loop.
CPU: 13 PID: 7073 Comm: sg_reset Tainted: GE   4.8.0-rc1+ #4
RIP: 0010:[]  []
beiscsi_eh_device_reset+0x160/0x520 [be2iscsi]
Call Trace:
[] ? scsi_host_alloc_command+0x47/0xc0
[] scsi_try_bus_device_reset+0x2a/0x50
[] scsi_ioctl_reset+0x13e/0x260
[] scsi_ioctl+0x137/0x3d0
[] sg_ioctl+0x572/0xc20 [sg]
[] do_vfs_ioctl+0xa7/0x5d0

The accesses to beiscsi_io_task is being protected in device reset handler
with frwd_lock but the freeing of task can happen under back_lock.

Hold the reference of iscsi_task till invalidation completes.
This prevents use of ICD when invalidation of that ICD is being processed.
Use frwd_lock for iscsi_tasks looping and back_lock to access
beiscsi_io_task structures.

Rewrite mgmt_invalidation_icds to handle allocation and freeing of IOCTL
buffer in one place.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 121 +---
 drivers/scsi/be2iscsi/be_mgmt.c | 107 ---
 drivers/scsi/be2iscsi/be_mgmt.h |   8 +--
 3 files changed, 114 insertions(+), 122 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index df78c10..d86de5d 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -226,8 +226,7 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
struct beiscsi_hba *phba;
struct iscsi_session *session;
struct invldt_cmd_tbl inv_tbl;
-   struct be_dma_mem nonemb_cmd;
-   unsigned int cid, tag;
+   unsigned int cid;
int rc;
 
cls_session = starget_to_session(scsi_target(sc->device));
@@ -259,64 +258,47 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
cid = beiscsi_conn->beiscsi_conn_cid;
inv_tbl.cid = cid;
inv_tbl.icd = aborted_io_task->psgl_handle->sgl_index;
-   nonemb_cmd.size = sizeof(union be_invldt_cmds_params);
-   nonemb_cmd.va = pci_zalloc_consistent(phba->ctrl.pdev,
- nonemb_cmd.size,
- _cmd.dma);
-   if (nonemb_cmd.va == NULL) {
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH,
-   "BM_%d : Failed to allocate memory for"
-   "mgmt_invalidate_icds\n");
-   return FAILED;
-   }
-
-   tag = mgmt_invalidate_icds(phba, _tbl, 1, cid, _cmd);
-   if (!tag) {
+   rc = beiscsi_mgmt_invalidate_icds(phba, _tbl, 1);
+   if (rc) {
beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_EH,
-   "BM_%d : mgmt_invalidate_icds could not be"
-   "submitted\n");
-   pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
-   nonemb_cmd.va, nonemb_cmd.dma);
-
+   "BM_%d : sc %p invalidation failed %d\n",
+   sc, rc);
return FAILED;
}
 
-   rc = beiscsi_mccq_compl_wait(phba, tag, NULL, _cmd);
-   if (rc != -EBUSY)
-   pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
-   nonemb_cmd.va, nonemb_cmd.dma);
-
return iscsi_eh_abort(sc);
 }
 
 static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
 {
-   struct iscsi_task *abrt_task;
-   struct beiscsi_io_task *abrt_io_task;
-   struct iscsi_conn *conn;
+   struct beiscsi_invldt_cmd_tbl {
+   struct invldt_cmd_tbl tbl[BE_INVLDT_CMD_TBL_SZ];
+   struct iscsi_task *task[BE_INVLDT_CMD_TBL_SZ];
+   } *inv_tbl;
+   struct iscsi_cls_session *cls_session;
struct beiscsi_conn *beiscsi_conn;
-   struct beiscsi_hba *phba;
+   struct beiscsi_io_task *io_task;
struct iscsi_session *session;
-   struct iscsi_cls_session *cls_session;
-   struct invldt_cmd_tbl *inv_tbl;
-   struct be_dma_mem nonemb_cmd;
-   unsigned int cid, tag, i, nents;
+   struct beiscsi_hba *phba;
+   struct iscsi_conn *conn;
+   struct iscsi_task *task;
+   unsigned int i, nents;
int rc, more = 0;
 
-   /* invalidate iocbs */
cls_session = starget_to_session(scsi_target(sc->device));
session = cls_session->dd_data;
+
spin_lock_bh(>frwd_lock);
if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN) {
spin_unlock_bh(>frwd_lock);
return FAILED;
}
+
conn = session->leadconn;
beiscsi_conn = conn->dd_data;
phba = beiscsi_conn->phba;
-   cid = beiscsi_conn->beiscsi_conn_cid;
 
-   inv_tbl = kcalloc(BE_INVLDT_CMD_TBL_SZ, sizeof(*inv_tbl), GFP_KERNEL);
+   inv_tbl = kzalloc(sizeof(*inv_tbl), GFP_KERNEL);
if (!inv_tb

[PATCH 00/12] be2iscsi: driver update 11.2.1.0

2016-12-05 Thread Jitendra Bhivare
This patch is generated against for-next branch.

Jitendra Bhivare (11):
  be2iscsi: Fix use of invalidate command table req
  be2iscsi: Fix for crash in beiscsi_eh_device_reset
  be2iscsi: Take iscsi_task ref in abort handler
  be2iscsi: Set WRB invalid bit for SkyHawk
  be2iscsi: Add checks to validate completions
  be2iscsi: Fix iSCSI cmd cleanup IOCTL
  be2iscsi: Remove redundant receive buffers posting
  be2iscsi: Remove unused struct members
  be2iscsi: Remove wq_name from beiscsi_hba
  be2iscsi: Add checks to validate CID alloc/free
  be2iscsi: Update driver version

Ketan Mukadam (1):
  be2iscsi: Add warning message for unsupported adapter

 drivers/scsi/be2iscsi/be.h   |   3 -
 drivers/scsi/be2iscsi/be_cmds.c  |  41 +++---
 drivers/scsi/be2iscsi/be_cmds.h  |  17 +--
 drivers/scsi/be2iscsi/be_iscsi.c | 165 ---
 drivers/scsi/be2iscsi/be_main.c  | 285 +++
 drivers/scsi/be2iscsi/be_main.h  |  44 ++
 drivers/scsi/be2iscsi/be_mgmt.c  | 117 +---
 drivers/scsi/be2iscsi/be_mgmt.h  |  98 +++---
 8 files changed, 344 insertions(+), 426 deletions(-)

-- 
1.8.3.1

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


[PATCH 03/12] be2iscsi: Take iscsi_task ref in abort handler

2016-12-05 Thread Jitendra Bhivare
Hold the reference of iscsi_task till invalidation completes.
This prevents use of ICD when invalidation of that ICD is being processed.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 45 +
 1 file changed, 19 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index d86de5d..6eaa78bd 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -218,47 +218,40 @@ static int beiscsi_slave_configure(struct scsi_device 
*sdev)
 
 static int beiscsi_eh_abort(struct scsi_cmnd *sc)
 {
+   struct iscsi_task *abrt_task = (struct iscsi_task *)sc->SCp.ptr;
struct iscsi_cls_session *cls_session;
-   struct iscsi_task *aborted_task = (struct iscsi_task *)sc->SCp.ptr;
-   struct beiscsi_io_task *aborted_io_task;
-   struct iscsi_conn *conn;
+   struct beiscsi_io_task *abrt_io_task;
struct beiscsi_conn *beiscsi_conn;
-   struct beiscsi_hba *phba;
struct iscsi_session *session;
struct invldt_cmd_tbl inv_tbl;
-   unsigned int cid;
+   struct beiscsi_hba *phba;
+   struct iscsi_conn *conn;
int rc;
 
cls_session = starget_to_session(scsi_target(sc->device));
session = cls_session->dd_data;
 
-   spin_lock_bh(>frwd_lock);
-   if (!aborted_task || !aborted_task->sc) {
-   /* we raced */
-   spin_unlock_bh(>frwd_lock);
-   return SUCCESS;
-   }
-
-   aborted_io_task = aborted_task->dd_data;
-   if (!aborted_io_task->scsi_cmnd) {
-   /* raced or invalid command */
-   spin_unlock_bh(>frwd_lock);
+   /* check if we raced, task just got cleaned up under us */
+   spin_lock_bh(>back_lock);
+   if (!abrt_task || !abrt_task->sc) {
+   spin_unlock_bh(>back_lock);
return SUCCESS;
}
-   spin_unlock_bh(>frwd_lock);
-
-   conn = aborted_task->conn;
+   /* get a task ref till FW processes the req for the ICD used */
+   __iscsi_get_task(abrt_task);
+   abrt_io_task = abrt_task->dd_data;
+   conn = abrt_task->conn;
beiscsi_conn = conn->dd_data;
phba = beiscsi_conn->phba;
-   /* Invalidate WRB Posted for this Task */
+   /* mark WRB invalid which have been not processed by FW yet */
AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
- aborted_io_task->pwrb_handle->pwrb,
- 1);
-   /* invalidate iocb */
-   cid = beiscsi_conn->beiscsi_conn_cid;
-   inv_tbl.cid = cid;
-   inv_tbl.icd = aborted_io_task->psgl_handle->sgl_index;
+ abrt_io_task->pwrb_handle->pwrb, 1);
+   inv_tbl.cid = beiscsi_conn->beiscsi_conn_cid;
+   inv_tbl.icd = abrt_io_task->psgl_handle->sgl_index;
+   spin_unlock_bh(>back_lock);
+
rc = beiscsi_mgmt_invalidate_icds(phba, _tbl, 1);
+   iscsi_put_task(abrt_task);
if (rc) {
beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_EH,
"BM_%d : sc %p invalidation failed %d\n",
-- 
1.8.3.1

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


[PATCH 06/12] be2iscsi: Fix iSCSI cmd cleanup IOCTL

2016-12-05 Thread Jitendra Bhivare
Prepare the IOCTL with appropriate sizes of buffers of V0 and V1.
Set missing chute number in V1 IOCTL.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_cmds.c | 33 ++---
 drivers/scsi/be2iscsi/be_main.c |  3 +--
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index be65da2..94aae45 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -1700,31 +1700,34 @@ int beiscsi_cmd_iscsi_cleanup(struct beiscsi_hba *phba, 
unsigned short ulp)
struct be_ctrl_info *ctrl = >ctrl;
struct iscsi_cleanup_req_v1 *req_v1;
struct iscsi_cleanup_req *req;
+   u16 hdr_ring_id, data_ring_id;
struct be_mcc_wrb *wrb;
int status;
 
mutex_lock(>mbox_lock);
wrb = wrb_from_mbox(>mbox_mem);
-   req = embedded_payload(wrb);
-   be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
-   be_cmd_hdr_prepare(>hdr, CMD_SUBSYSTEM_ISCSI,
-  OPCODE_COMMON_ISCSI_CLEANUP, sizeof(*req));
 
-   /**
-   * TODO: Check with FW folks the chute value to be set.
-   * For now, use the ULP_MASK as the chute value.
-   */
+   hdr_ring_id = HWI_GET_DEF_HDRQ_ID(phba, ulp);
+   data_ring_id = HWI_GET_DEF_BUFQ_ID(phba, ulp);
if (is_chip_be2_be3r(phba)) {
+   req = embedded_payload(wrb);
+   be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
+   be_cmd_hdr_prepare(>hdr, CMD_SUBSYSTEM_ISCSI,
+  OPCODE_COMMON_ISCSI_CLEANUP, sizeof(*req));
req->chute = (1 << ulp);
-   req->hdr_ring_id = HWI_GET_DEF_HDRQ_ID(phba, ulp);
-   req->data_ring_id = HWI_GET_DEF_BUFQ_ID(phba, ulp);
+   /* BE2/BE3 FW creates 8-bit ring id */
+   req->hdr_ring_id = hdr_ring_id;
+   req->data_ring_id = data_ring_id;
} else {
-   req_v1 = (struct iscsi_cleanup_req_v1 *)req;
+   req_v1 = embedded_payload(wrb);
+   be_wrb_hdr_prepare(wrb, sizeof(*req_v1), true, 0);
+   be_cmd_hdr_prepare(_v1->hdr, CMD_SUBSYSTEM_ISCSI,
+  OPCODE_COMMON_ISCSI_CLEANUP,
+  sizeof(*req_v1));
req_v1->hdr.version = 1;
-   req_v1->hdr_ring_id = cpu_to_le16(HWI_GET_DEF_HDRQ_ID(phba,
- ulp));
-   req_v1->data_ring_id = cpu_to_le16(HWI_GET_DEF_BUFQ_ID(phba,
-  ulp));
+   req_v1->chute = (1 << ulp);
+   req_v1->hdr_ring_id = cpu_to_le16(hdr_ring_id);
+   req_v1->data_ring_id = cpu_to_le16(data_ring_id);
}
 
status = be_mbox_notify(ctrl);
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index bd5e10e..0fa24a3 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -2747,7 +2747,7 @@ static int hwi_init_async_pdu_ctx(struct beiscsi_hba 
*phba)
 
for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
if (test_bit(ulp_num, >fw_config.ulp_supported)) {
-/* get async_ctx for each ULP */
+   /* get async_ctx for each ULP */
mem_descr = (struct be_mem_descriptor *)phba->init_mem;
mem_descr += (HWI_MEM_ASYNC_PDU_CONTEXT_ULP0 +
 (ulp_num * MEM_DESCR_OFFSET));
@@ -3810,7 +3810,6 @@ static int hwi_init_port(struct beiscsi_hba *phba)
/**
 * Now that the default PDU rings have been created,
 * let EP know about it.
-* Call beiscsi_cmd_iscsi_cleanup before posting?
 */
beiscsi_hdq_post_handles(phba, BEISCSI_DEFQ_HDR,
 ulp_num);
-- 
1.8.3.1

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


RE: [PATCH 2/2] scsi: be2iscsi: set errno on error path

2016-12-04 Thread Jitendra Bhivare
> -Original Message-
> From: Pan Bian [mailto:bianpan201...@163.com]
> Sent: Sunday, December 04, 2016 10:53 AM
> To: Subbu Seetharaman; Ketan Mukadam; Jitendra Bhivare; James E.J.
> Bottomley; Martin K. Petersen; linux-scsi@vger.kernel.org
> Cc: linux-ker...@vger.kernel.org; Pan Bian
> Subject: [PATCH 2/2] scsi: be2iscsi: set errno on error path
>
> From: Pan Bian <bianpan2...@163.com>
>
> Variable ret is reset in the loop, and its value will be 0 during the
second and
> after repeat of the loop. If pci_alloc_consistent() returns a NULL
pointer then, it
> will leaves with return value 0. 0 means no error, which is contrary to
the fact.
> This patches fixes the bug, explicitly assigning "-ENOMEM" to return
variable ret
> on the path that the call to
> pci_alloc_consistent() fails.
>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188951
>
> Signed-off-by: Pan Bian <bianpan2...@163.com>
> ---
>  drivers/scsi/be2iscsi/be_main.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/be2iscsi/be_main.c
b/drivers/scsi/be2iscsi/be_main.c
> index b6c5791..b5112d6 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -3049,8 +3049,10 @@ static int beiscsi_create_eqs(struct beiscsi_hba
> *phba,
>   eq_vaddress = pci_alloc_consistent(phba->pcidev,
>  num_eq_pages *
PAGE_SIZE,
>  );
> - if (!eq_vaddress)
> + if (!eq_vaddress) {
> + ret = -ENOMEM;
>   goto create_eq_error;
> + }
>
>   mem->va = eq_vaddress;
>   ret = be_fill_queue(eq, phba->params.num_eq_entries,
> --
> 1.9.1
>
[JB] Thanks.

Reviewed-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 1/2] scsi: be2iscsi: set errno on error path

2016-12-04 Thread Jitendra Bhivare
> -Original Message-
> From: Pan Bian [mailto:bianpan201...@163.com]
> Sent: Sunday, December 04, 2016 10:52 AM
> To: Subbu Seetharaman; Ketan Mukadam; Jitendra Bhivare; James E.J.
> Bottomley; Martin K. Petersen; linux-scsi@vger.kernel.org
> Cc: linux-ker...@vger.kernel.org; Pan Bian
> Subject: [PATCH 1/2] scsi: be2iscsi: set errno on error path
>
> From: Pan Bian <bianpan2...@163.com>
>
> Variable ret is reset in the loop, and its value will be 0 during the
second and
> after repeat of the loop. If pci_alloc_consistent() returns a NULL
pointer then, it
> will leaves with return value 0. 0 means no error, which is contrary to
the fact.
> This patches fixes the bug, explicitly assigning "-ENOMEM" to return
variable ret
> on the path that the call to
> pci_alloc_consistent() fails.
>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188941
>
> Signed-off-by: Pan Bian <bianpan2...@163.com>
> ---
>  drivers/scsi/be2iscsi/be_main.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/be2iscsi/be_main.c
b/drivers/scsi/be2iscsi/be_main.c
> index d9239c2..b6c5791 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -3113,8 +3113,10 @@ static int beiscsi_create_cqs(struct beiscsi_hba
> *phba,
>   cq_vaddress = pci_alloc_consistent(phba->pcidev,
>  num_cq_pages *
PAGE_SIZE,
>  );
> - if (!cq_vaddress)
> + if (!cq_vaddress) {
> + ret = -ENOMEM;
>   goto create_cq_error;
> + }
>
>   ret = be_fill_queue(cq, phba->params.num_cq_entries,
>   sizeof(struct sol_cqe), cq_vaddress);
> --
> 1.9.1

[JB] Thanks.

Reviewed-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [patch] scsi: be2iscsi: allocate enough memory in beiscsi_boot_get_sinfo()

2016-11-20 Thread Jitendra Bhivare
> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> Sent: Friday, November 18, 2016 5:24 PM
> To: Subbu Seetharaman; Jitendra Bhivare
> Cc: Ketan Mukadam; James E.J. Bottomley; Martin K. Petersen; linux-
> s...@vger.kernel.org; kernel-janit...@vger.kernel.org
> Subject: [patch] scsi: be2iscsi: allocate enough memory in
> beiscsi_boot_get_sinfo()
>
> We accidentally allocate sizeof(u32) instead of sizeof(struct
> be_cmd_get_session_resp).
>
> Fixes: 50a4b824be9e ("scsi: be2iscsi: Fix to make boot discovery
non-blocking")
> Signed-off-by: Dan Carpenter <dan.carpen...@oracle.com>
>
> diff --git a/drivers/scsi/be2iscsi/be_mgmt.c
b/drivers/scsi/be2iscsi/be_mgmt.c
> index aebc4dd..ac05317b 100644
> --- a/drivers/scsi/be2iscsi/be_mgmt.c
> +++ b/drivers/scsi/be2iscsi/be_mgmt.c
> @@ -1083,7 +1083,7 @@ unsigned int beiscsi_boot_get_sinfo(struct
> beiscsi_hba *phba)
>   nonemb_cmd = >boot_struct.nonemb_cmd;
>   nonemb_cmd->size = sizeof(*resp);
>   nonemb_cmd->va = pci_alloc_consistent(phba->ctrl.pdev,
> -   sizeof(nonemb_cmd->size),
> +   nonemb_cmd->size,
>     _cmd->dma);
>   if (!nonemb_cmd->va) {
>   mutex_unlock(>mbox_lock);

Reviewed by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>

Thanks,

JB
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] libiscsi: Fix locking in __iscsi_conn_send_pdu

2016-10-13 Thread Jitendra Bhivare
The code at free_task label in __iscsi_conn_send_pdu can get executed
from blk_timeout_work which takes queue_lock using spin_lock_irq.
back_lock taken with spin_unlock_bh will cause WARN_ON_ONCE.
The code gets executed either with bottom half or IRQ disabled hence
using spin_lock/spin_unlock for back_lock is safe.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/libiscsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index c051694..f9b6fba 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -791,9 +791,9 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct 
iscsi_hdr *hdr,
 
 free_task:
/* regular RX path uses back_lock */
-   spin_lock_bh(>back_lock);
+   spin_lock(>back_lock);
__iscsi_put_task(task);
-   spin_unlock_bh(>back_lock);
+   spin_unlock(>back_lock);
return NULL;
 }
 
-- 
2.7.4

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


[PATCH 2/2] be2iscsi: Replace _bh with _irqsave/irqrestore

2016-10-13 Thread Jitendra Bhivare
[ 3843.132217] WARNING: CPU: 20 PID: 1227 at kernel/softirq.c:150 
__local_bh_enable_ip+0x6b/0x90
[ 3843.142815] Modules linked in:
...
[ 3843.294328] CPU: 20 PID: 1227 Comm: kworker/20:1H Tainted: GE   
4.8.0-rc1+ #3
[ 3843.304944] Hardware name: Dell Inc. PowerEdge R720/0X6H47, BIOS 1.4.8 
10/25/2012
[ 3843.314798] Workqueue: kblockd blk_timeout_work
[ 3843.321350]  0086 a32f4533 8802216d7bd8 
8135c3cf
[ 3843.331146]    8802216d7c18 
8108d661
[ 3843.340918]  0096216d7c50 0200 8802d07cc828 
8801b3632550
[ 3843.350687] Call Trace:
[ 3843.354866]  [] dump_stack+0x63/0x84
[ 3843.362061]  [] __warn+0xd1/0xf0
[ 3843.368851]  [] warn_slowpath_null+0x1d/0x20
[ 3843.376791]  [] __local_bh_enable_ip+0x6b/0x90
[ 3843.384903]  [] _raw_spin_unlock_bh+0x1e/0x20
[ 3843.392940]  [] beiscsi_alloc_pdu+0x2f0/0x6e0 [be2iscsi]
[ 3843.402076]  [] __iscsi_conn_send_pdu+0xf8/0x370 [libiscsi]
[ 3843.411549]  [] iscsi_send_nopout+0xbe/0x110 [libiscsi]
[ 3843.420639]  [] iscsi_eh_cmd_timed_out+0x29b/0x2b0 
[libiscsi]
[ 3843.430339]  [] scsi_times_out+0x5e/0x250
[ 3843.438119]  [] blk_rq_timed_out+0x1f/0x60
[ 3843.446009]  [] blk_timeout_work+0xad/0x150
[ 3843.454010]  [] process_one_work+0x152/0x400
[ 3843.462114]  [] worker_thread+0x125/0x4b0
[ 3843.469961]  [] ? rescuer_thread+0x380/0x380
[ 3843.478116]  [] kthread+0xd8/0xf0
[ 3843.485212]  [] ret_from_fork+0x1f/0x40
[ 3843.492908]  [] ? kthread_park+0x60/0x60
[ 3843.500715] ---[ end trace 57ec0a1d8f0dd3a0 ]---
[ 3852.328667] NMI watchdog: Watchdog detected hard LOCKUP on cpu 1Kernel panic 
- not syncing: Hard LOCKUP

blk_timeout_work takes queue_lock spin_lock with interrupts disabled
before invoking iscsi_eh_cmd_timed_out. This causes a WARN_ON_ONCE in
spin_unlock_bh for wrb_lock/io_sgl_lock/mgmt_sgl_lock.

CPU was kept busy in lot of bottom half work with interrupts disabled
thus causing hard lock up.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 37 +++--
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 68138a6..d9239c2 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -900,8 +900,9 @@ void hwi_ring_cq_db(struct beiscsi_hba *phba,
 static struct sgl_handle *alloc_io_sgl_handle(struct beiscsi_hba *phba)
 {
struct sgl_handle *psgl_handle;
+   unsigned long flags;
 
-   spin_lock_bh(>io_sgl_lock);
+   spin_lock_irqsave(>io_sgl_lock, flags);
if (phba->io_sgl_hndl_avbl) {
beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO,
"BM_%d : In alloc_io_sgl_handle,"
@@ -919,14 +920,16 @@ static struct sgl_handle *alloc_io_sgl_handle(struct 
beiscsi_hba *phba)
phba->io_sgl_alloc_index++;
} else
psgl_handle = NULL;
-   spin_unlock_bh(>io_sgl_lock);
+   spin_unlock_irqrestore(>io_sgl_lock, flags);
return psgl_handle;
 }
 
 static void
 free_io_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle)
 {
-   spin_lock_bh(>io_sgl_lock);
+   unsigned long flags;
+
+   spin_lock_irqsave(>io_sgl_lock, flags);
beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO,
"BM_%d : In free_,io_sgl_free_index=%d\n",
phba->io_sgl_free_index);
@@ -941,7 +944,7 @@ free_io_sgl_handle(struct beiscsi_hba *phba, struct 
sgl_handle *psgl_handle)
 "value there=%p\n", phba->io_sgl_free_index,
 phba->io_sgl_hndl_base
 [phba->io_sgl_free_index]);
-spin_unlock_bh(>io_sgl_lock);
+spin_unlock_irqrestore(>io_sgl_lock, flags);
return;
}
phba->io_sgl_hndl_base[phba->io_sgl_free_index] = psgl_handle;
@@ -950,7 +953,7 @@ free_io_sgl_handle(struct beiscsi_hba *phba, struct 
sgl_handle *psgl_handle)
phba->io_sgl_free_index = 0;
else
phba->io_sgl_free_index++;
-   spin_unlock_bh(>io_sgl_lock);
+   spin_unlock_irqrestore(>io_sgl_lock, flags);
 }
 
 static inline struct wrb_handle *
@@ -958,15 +961,16 @@ beiscsi_get_wrb_handle(struct hwi_wrb_context 
*pwrb_context,
   unsigned int wrbs_per_cxn)
 {
struct wrb_handle *pwrb_handle;
+   unsigned long flags;
 
-   spin_lock_bh(_context->wrb_lock);
+   spin_lock_irqsave(_context->wrb_lock, flags);
pwrb_handle = pwrb_context->pwrb_handle_base[pwrb_context->alloc_index];
pwrb_context->wrb_handles_available--;
if (pwrb_context->alloc_index == (wrbs_per_cxn - 1))
pwrb_context->

[PATCH 0/2] Locking issue in libiscsi and be2iscsi

2016-10-13 Thread Jitendra Bhivare
These patches are being resent with required changes as per comments
for [PATCH 02/28] be2iscsi: Replace _bh with _irqsave/irqrestore

In IO handling path, there is no spin_lock taken with IRQs disabled
when calling into libiscsi, so no issues were found with use of
spin_lock_bh/spin_unlock_bh except for one in iscsi_eh_cmd_timeout.

This needs to be applied on top 11.2.0.0 of be2iscsi committed in
4.9/scsi-queue.

Jitendra Bhivare (2):
  libiscsi: Fix locking in __iscsi_conn_send_pdu
  be2iscsi: Replace _bh with _irqsave/irqrestore

 drivers/scsi/be2iscsi/be_main.c | 37 +++--
 drivers/scsi/libiscsi.c |  4 ++--
 2 files changed, 25 insertions(+), 16 deletions(-)

-- 
2.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 02/28] be2iscsi: Replace _bh with _irqsave/irqrestore

2016-09-27 Thread Jitendra Bhivare
> -Original Message-
> From: Jitendra Bhivare [mailto:jitendra.bhiv...@broadcom.com]
> Sent: Friday, September 23, 2016 8:38 PM
> To: 'Mike Christie'; 'Martin K. Petersen'
> Cc: 'linux-scsi@vger.kernel.org'
> Subject: RE: [PATCH 02/28] be2iscsi: Replace _bh with _irqsave/irqrestore
>
> Hi Mike,
>
> I could reproduce hard lockup using for-next kernel only in
> iscsi_eh_cmd_timeout path due to spin_lock_irqsave taken in
> blk_timeout_work
> Please refer stack trace below.
>
> The _bh version used for frwd_lock and back_lock does not seem to be
> causing
> any issue similar to seen with be2iscsi after replacing _bh versions in
> be2iscsi.
>
> I am testing it further, to confirm in all possible scenarios... NOPs,
> error
> recovery, resets and reconnects.
> On my setup, I affined all EQ interrupts on a single CPU.
> Along with heavy IO, few of the invocations of fio were pinned to run on
> same
> CPU.
>
> Any call to unlock_bh with another spin_lock already held, invoking
> do_softirq,
> might cause deadlock if bottom half used by driver calls function which
> needs
> that another spin_lock.
> Is there a code which prevents this issue?
>
The only place, I think, libiscsi can have issues is__iscsi_complete_pdu
which should be protected under _bh version for frwd and back locks.
If the function is executed in process context there is a good chance the
base version of spin_lock used for frwd/back locks could cause deadlocks
when lld uses _bh version in alloc_pdu path
(__iscsi_complete_pdu->iscsi_send_nopout... alloc_pdu).

Thanks,

JB
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH] scsi: be2iscsi: mark symbols static where possible

2016-09-26 Thread Jitendra Bhivare
> -Original Message-
> From: Baoyou Xie [mailto:baoyou@linaro.org]
> Sent: Monday, September 26, 2016 5:31 PM
> To: subbu.seethara...@broadcom.com; ketan.muka...@broadcom.com;
> jitendra.bhiv...@broadcom.com; j...@linux.vnet.ibm.com;
> martin.peter...@oracle.com
> Cc: linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org;
a...@arndb.de;
> baoyou@linaro.org; xie.bao...@zte.com.cn; han@zte.com.cn;
> tang.qiang...@zte.com.cn
> Subject: [PATCH] scsi: be2iscsi: mark symbols static where possible
>
> We get 6 warnings when building kernel with W=1:
> drivers/scsi/be2iscsi/be_main.c:65:1: warning: no previous prototype for
> 'beiscsi_log_enable_disp' [-Wmissing-prototypes]
> drivers/scsi/be2iscsi/be_main.c:78:1: warning: no previous prototype for
> 'beiscsi_log_enable_change' [-Wmissing-prototypes]
> drivers/scsi/be2iscsi/be_main.c:97:1: warning: no previous prototype for
> 'beiscsi_log_enable_store' [-Wmissing-prototypes]
> drivers/scsi/be2iscsi/be_main.c:116:1: warning: no previous prototype
for
> 'beiscsi_log_enable_init' [-Wmissing-prototypes]
> drivers/scsi/be2iscsi/be_main.c:4587:5: warning: no previous prototype
for
> 'beiscsi_iotask_v2' [-Wmissing-prototypes]
> drivers/scsi/be2iscsi/be_main.c:4976:6: warning: no previous prototype
for
> 'beiscsi_hba_attrs_init' [-Wmissing-prototypes]
>
> In fact, these functions are only used in the file in which they are
declared and
> don't need a declaration, but can be made static.
>
> So this patch marks these functions with 'static'.
>
> Signed-off-by: Baoyou Xie <baoyou@linaro.org>
> ---
[JB] Looks good.
Reviewed by: Jitendra Bhivare <Jitendra.bhivare@broadcom>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 02/28] be2iscsi: Replace _bh with _irqsave/irqrestore

2016-09-23 Thread Jitendra Bhivare
Hi Mike,

I could reproduce hard lockup using for-next kernel only in
iscsi_eh_cmd_timeout path due to spin_lock_irqsave taken in blk_timeout_work
Please refer stack trace below.

The _bh version used for frwd_lock and back_lock does not seem to be causing
any issue similar to seen with be2iscsi after replacing
_bh versions in be2iscsi.

I am testing it further, to confirm in all possible scenarios... NOPs, error
recovery, resets and reconnects.
On my setup, I affined all EQ interrupts on a single CPU.
Along with heavy IO, few of the invocations of fio were pinned to run on
same CPU.

Any call to unlock_bh with another spin_lock already held, invoking
do_softirq, might cause deadlock if bottom half used by driver
calls function which needs that another spin_lock.
Is there a code which prevents this issue?

Thanks,

JB

[ 3843.125976] [ cut here ]
[ 3843.132217] WARNING: CPU: 20 PID: 1227 at kernel/softirq.c:150
__local_bh_enable_ip+0x6b/0x90
[ 3843.142815] Modules linked in: dm_service_time be2iscsi(E)
iscsi_boot_sysfs xt_CHECKSUM ipt_MASQUERADE nf_nat_masquerade_ipv4 tun
ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 ipt_REJECT nf_reject_ipv4
xt_conntrack ebtable_nat ebtable_broute rpcrdma bridge ib_isert stp
iscsi_target_mod llc ebtable_filter ebtables ip6table_nat nf_conntrack_ipv6
nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw
ib_iser ip6table_filter ip6_tables iptable_nat nf_conntrack_ipv4
nf_defrag_ipv4 nf_nat_ipv4 libiscsi nf_nat scsi_transport_iscsi ib_srpt
nf_conntrack target_core_mod iptable_mangle iptable_security iptable_raw
iptable_filter ib_srp scsi_transport_srp ib_ipoib rdma_ucm ib_ucm ib_uverbs
ib_umad rdma_cm ib_cm iw_cm ocrdma ib_core dm_mirror dm_region_hash dm_log
intel_rapl sb_edac edac_core x86_pkg_temp_thermal
[ 3843.231162]  intel_powerclamp coretemp kvm_intel kvm irqbypass
crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel iTCO_wdt
iTCO_vendor_support ipmi_devintf lrw dcdbas mei_me ipmi_ssif gf128mul sg mei
glue_helper ablk_helper ioatdma cryptd ipmi_si shpchp nfsd wmi
acpi_power_meter ipmi_msghandler pcspkr dca lpc_ich acpi_pad auth_rpcgss
nfs_acl lockd grace sunrpc dm_multipath dm_mod ip_tables ext4 jbd2 mbcache
sd_mod mgag200 i2c_algo_bit drm_kms_helper syscopyarea sysfillrect sysimgblt
fb_sys_fops ttm drm tg3 crc32c_intel ptp i2c_core be2net megaraid_sas fjes
pps_core
[ 3843.294328] CPU: 20 PID: 1227 Comm: kworker/20:1H Tainted: GE
4.8.0-rc1+ #3
[ 3843.304944] Hardware name: Dell Inc. PowerEdge R720/0X6H47, BIOS 1.4.8
10/25/2012
[ 3843.314798] Workqueue: kblockd blk_timeout_work
[ 3843.321350]  0086 a32f4533 8802216d7bd8
8135c3cf
[ 3843.331146]    8802216d7c18
8108d661
[ 3843.340918]  0096216d7c50 0200 8802d07cc828
8801b3632550
[ 3843.350687] Call Trace:
[ 3843.354866]  [] dump_stack+0x63/0x84
[ 3843.362061]  [] __warn+0xd1/0xf0
[ 3843.368851]  [] warn_slowpath_null+0x1d/0x20
[ 3843.376791]  [] __local_bh_enable_ip+0x6b/0x90
[ 3843.384903]  [] _raw_spin_unlock_bh+0x1e/0x20
[ 3843.392940]  [] beiscsi_alloc_pdu+0x2f0/0x6e0
[be2iscsi]
[ 3843.402076]  [] __iscsi_conn_send_pdu+0xf8/0x370
[libiscsi]
[ 3843.411549]  [] iscsi_send_nopout+0xbe/0x110 [libiscsi]
[ 3843.420639]  [] iscsi_eh_cmd_timed_out+0x29b/0x2b0
[libiscsi]
[ 3843.430339]  [] scsi_times_out+0x5e/0x250
[ 3843.438119]  [] blk_rq_timed_out+0x1f/0x60
[ 3843.446009]  [] blk_timeout_work+0xad/0x150
[ 3843.454010]  [] process_one_work+0x152/0x400
[ 3843.462114]  [] worker_thread+0x125/0x4b0
[ 3843.469961]  [] ? rescuer_thread+0x380/0x380
[ 3843.478116]  [] kthread+0xd8/0xf0
[ 3843.485212]  [] ret_from_fork+0x1f/0x40
[ 3843.492908]  [] ? kthread_park+0x60/0x60
[ 3843.500715] ---[ end trace 57ec0a1d8f0dd3a0 ]---
[ 3852.328667] NMI watchdog: Watchdog detected hard LOCKUP on cpu 1Kernel
panic - not syncing: Hard LOCKUP
[ 3852.341357] Modules linked in: dm_service_time be2iscsi(E)
iscsi_boot_sysfs xt_CHECKSUM ipt_MASQUERADE nf_nat_masquerade_ipv4 tun
ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 ipt_REJECT nf_reject_ipv4
xt_conntrack ebtable_nat ebtable_broute rpcrdma bridge ib_isert stp
iscsi_target_mod llc ebtable_filter ebtables ip6table_nat nf_conntrack_ipv6
nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw
ib_iser ip6table_filter ip6_tables iptable_nat nf_conntrack_ipv4
nf_defrag_ipv4 nf_nat_ipv4 libiscsi nf_nat scsi_transport_iscsi ib_srpt
nf_conntrack target_core_mod iptable_mangle iptable_security iptable_raw
iptable_filter ib_srp scsi_transport_srp ib_ipoib rdma_ucm ib_ucm ib_uverbs
ib_umad rdma_cm ib_cm iw_cm ocrdma ib_core dm_mirror dm_region_hash dm_log
intel_rapl sb_edac edac_core x86_pkg_temp_thermal intel_powerclamp coretemp
kvm_intel kvm irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel
aesni_intel iTCO_wdt iTCO_vendor_support ipmi_devintf lrw dcdbas mei_me ipm
[ 3852.341358] CPU: 1 PID: 1129 Comm: kworker/1:1H Tainted: 

[PATCH v2 0/3] be2iscsi: cleanup of 11.2 in 4.9/scsi-queue

2016-08-26 Thread Jitendra Bhivare
These patches address some auto built issues of 11.2.0.0 be2iscsi
committed in 4.9/scsi-queue.

v2 changes:
Added NULL check for pwrb_handle in PATCH v2 2/3

Christophe JAILLET (1):
  be2iscsi: Fix error return code

Jitendra Bhivare (2):
  be2iscsi: Remove redundant iscsi_wrb desc memset
  be2iscsi: Add missing unlock for mbox_lock

 drivers/scsi/be2iscsi/be_main.c | 27 ---
 drivers/scsi/be2iscsi/be_mgmt.c |  7 +++
 2 files changed, 19 insertions(+), 15 deletions(-)

-- 
2.7.4

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


[PATCH v2 2/3] be2iscsi: Remove redundant iscsi_wrb desc memset

2016-08-26 Thread Jitendra Bhivare
alloc_wrb_handle already does memset zero of iscsi_wrb descriptor so
remove redundant memset in WRB submission paths.

Add pwrb_handle NULL check before memsett'ing pwrb.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 5 +++--
 drivers/scsi/be2iscsi/be_mgmt.c | 3 ---
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index b30db87..6a6906f 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -967,7 +967,9 @@ beiscsi_get_wrb_handle(struct hwi_wrb_context *pwrb_context,
else
pwrb_context->alloc_index++;
spin_unlock_bh(_context->wrb_lock);
-   memset(pwrb_handle->pwrb, 0, sizeof(*pwrb_handle->pwrb));
+
+   if (pwrb_handle)
+   memset(pwrb_handle->pwrb, 0, sizeof(*pwrb_handle->pwrb));
 
return pwrb_handle;
 }
@@ -4718,7 +4720,6 @@ static int beiscsi_mtask(struct iscsi_task *task)
 
cid = beiscsi_conn->beiscsi_conn_cid;
pwrb = io_task->pwrb_handle->pwrb;
-   memset(pwrb, 0, sizeof(*pwrb));
 
if (is_chip_be2_be3r(phba)) {
AMAP_SET_BITS(struct amap_iscsi_wrb, cmdsn_itt, pwrb,
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 3ac7b88..b9ff939 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1350,7 +1350,6 @@ void beiscsi_offload_cxn_v0(struct beiscsi_offload_params 
*params,
 {
struct iscsi_wrb *pwrb = pwrb_handle->pwrb;
 
-   memset(pwrb, 0, sizeof(*pwrb));
AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
  max_send_data_segment_length, pwrb,
  params->dw[offsetof(struct amap_beiscsi_offload_params,
@@ -1422,8 +1421,6 @@ void beiscsi_offload_cxn_v2(struct beiscsi_offload_params 
*params,
 {
struct iscsi_wrb *pwrb = pwrb_handle->pwrb;
 
-   memset(pwrb, 0, sizeof(*pwrb));
-
AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
  max_burst_length, pwrb, params->dw[offsetof
  (struct amap_beiscsi_offload_params,
-- 
2.7.4

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


[PATCH v2 1/3] be2iscsi: Fix error return code

2016-08-26 Thread Jitendra Bhivare
From: Christophe JAILLET <christophe.jail...@wanadoo.fr>

We know that 'ret' is not an error code because it has been tested a few
lines above.
So, if one of these function fails, 0 will be returned instead of an error
code.
Return -ENOMEM instead.

Signed-off-by: Christophe JAILLET <christophe.jail...@wanadoo.fr>

'ret' needs to be set with error code if hba_setup_cid_tbls fails.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 222edfc..b30db87 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -3017,8 +3017,8 @@ static int be_fill_queue(struct be_queue_info *q,
 static int beiscsi_create_eqs(struct beiscsi_hba *phba,
 struct hwi_context_memory *phwi_context)
 {
+   int ret = -ENOMEM, eq_for_mcc;
unsigned int i, num_eq_pages;
-   int ret = 0, eq_for_mcc;
struct be_queue_info *eq;
struct be_dma_mem *mem;
void *eq_vaddress;
@@ -3036,8 +3036,8 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba,
mem = >dma_mem;
phwi_context->be_eq[i].phba = phba;
eq_vaddress = pci_alloc_consistent(phba->pcidev,
-num_eq_pages * PAGE_SIZE,
-);
+  num_eq_pages * PAGE_SIZE,
+  );
if (!eq_vaddress)
goto create_eq_error;
 
@@ -3065,6 +3065,7 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba,
phwi_context->be_eq[i].q.id);
}
return 0;
+
 create_eq_error:
for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) {
eq = _context->be_eq[i].q;
@@ -3081,11 +3082,11 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba,
 struct hwi_context_memory *phwi_context)
 {
unsigned int i, num_cq_pages;
-   int ret = 0;
struct be_queue_info *cq, *eq;
struct be_dma_mem *mem;
struct be_eq_obj *pbe_eq;
void *cq_vaddress;
+   int ret = -ENOMEM;
dma_addr_t paddr;
 
num_cq_pages = PAGES_REQUIRED(phba->params.num_cq_entries * \
@@ -3099,10 +3100,11 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba,
pbe_eq->phba = phba;
mem = >dma_mem;
cq_vaddress = pci_alloc_consistent(phba->pcidev,
-num_cq_pages * PAGE_SIZE,
-);
+  num_cq_pages * PAGE_SIZE,
+  );
if (!cq_vaddress)
goto create_cq_error;
+
ret = be_fill_queue(cq, phba->params.num_cq_entries,
sizeof(struct sol_cqe), cq_vaddress);
if (ret) {
@@ -3137,7 +3139,6 @@ create_cq_error:
mem->va, mem->dma);
}
return ret;
-
 }
 
 static int
@@ -4230,7 +4231,8 @@ static int beiscsi_init_port(struct beiscsi_hba *phba)
goto do_cleanup_ctrlr;
}
 
-   if (hba_setup_cid_tbls(phba)) {
+   ret = hba_setup_cid_tbls(phba);
+   if (ret < 0) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
"BM_%d : Failed in hba_setup_cid_tbls\n");
kfree(phba->io_sgl_hndl_base);
@@ -5627,7 +5629,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
struct hwi_context_memory *phwi_context;
struct be_eq_obj *pbe_eq;
unsigned int s_handle;
-   int ret = 0, i;
+   int ret, i;
 
ret = beiscsi_enable_pci(pcidev);
if (ret < 0) {
@@ -5640,6 +5642,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
if (!phba) {
dev_err(>dev,
"beiscsi_dev_probe - Failed in beiscsi_hba_alloc\n");
+   ret = -ENOMEM;
goto disable_pci;
}
 
@@ -5744,6 +5747,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
"BM_%d : beiscsi_dev_probe-"
"Failed to allocate work queue\n");
+   ret = -ENOMEM;
goto free_twq;
}
 
-- 
2.7.4

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


[PATCH v2 3/3] be2iscsi: Add missing unlock for mbox_lock

2016-08-26 Thread Jitendra Bhivare
Julia pointed out beiscsi_boot_get_sinfo does not unlock
mbox_lock on nonemb_cmd memory allocation failure.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_mgmt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index b9ff939..aebc4dd 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1085,8 +1085,10 @@ unsigned int beiscsi_boot_get_sinfo(struct beiscsi_hba 
*phba)
nonemb_cmd->va = pci_alloc_consistent(phba->ctrl.pdev,
  sizeof(nonemb_cmd->size),
  _cmd->dma);
-   if (!nonemb_cmd->va)
+   if (!nonemb_cmd->va) {
+   mutex_unlock(>mbox_lock);
return 0;
+   }
 
req = nonemb_cmd->va;
memset(req, 0, sizeof(*req));
-- 
2.7.4

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


[PATCH 0/3] be2iscsi: cleanup of 11.2 in 4.9/scsi-queue

2016-08-24 Thread Jitendra Bhivare
These patches address some auto built issues of 11.2.0.0 be2iscsi
committed in 4.9/scsi-queue.

Christophe JAILLET (1):
  be2iscsi: Fix error return code

Jitendra Bhivare (2):
  be2iscsi: Remove redundant iscsi_wrb desc memset
  be2iscsi: Add missing unlock for mbox_lock

 drivers/scsi/be2iscsi/be_main.c | 23 +--
 drivers/scsi/be2iscsi/be_mgmt.c |  7 +++
 2 files changed, 16 insertions(+), 14 deletions(-)

-- 
1.9.1

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


[PATCH 0/3] be2iscsi: cleanup of 11.2 in 4.9/scsi-queue

2016-08-24 Thread Jitendra Bhivare
These patches address some auto built issues of 11.2.0.0 be2iscsi
committed in 4.9/scsi-queue.

Christophe JAILLET (1):
  be2iscsi: Fix error return code

Jitendra Bhivare (2):
  be2iscsi: Remove redundant iscsi_wrb desc memset
  be2iscsi: Add missing unlock for mbox_lock

 drivers/scsi/be2iscsi/be_main.c | 23 +--
 drivers/scsi/be2iscsi/be_mgmt.c |  7 +++
 2 files changed, 16 insertions(+), 14 deletions(-)

-- 
1.9.1

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


[PATCH 3/3] be2iscsi: Add missing unlock for mbox_lock

2016-08-24 Thread Jitendra Bhivare
Julia pointed out beiscsi_boot_get_sinfo does not unlock
mbox_lock on nonemb_cmd memory allocation failure.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_mgmt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index b9ff939..aebc4dd 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1085,8 +1085,10 @@ unsigned int beiscsi_boot_get_sinfo(struct beiscsi_hba 
*phba)
nonemb_cmd->va = pci_alloc_consistent(phba->ctrl.pdev,
  sizeof(nonemb_cmd->size),
  _cmd->dma);
-   if (!nonemb_cmd->va)
+   if (!nonemb_cmd->va) {
+   mutex_unlock(>mbox_lock);
return 0;
+   }
 
req = nonemb_cmd->va;
memset(req, 0, sizeof(*req));
-- 
1.9.1

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


[PATCH 1/3] be2iscsi: Fix error return code

2016-08-24 Thread Jitendra Bhivare
From: Christophe JAILLET <christophe.jail...@wanadoo.fr>

We know that 'ret' is not an error code because it has been tested a few
lines above.
So, if one of these function fails, 0 will be returned instead of an error
code.
Return -ENOMEM instead.

Signed-off-by: Christophe JAILLET <christophe.jail...@wanadoo.fr>

'ret' needs to be set with error code if hba_setup_cid_tbls fails.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 222edfc..b30db87 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -3017,8 +3017,8 @@ static int be_fill_queue(struct be_queue_info *q,
 static int beiscsi_create_eqs(struct beiscsi_hba *phba,
 struct hwi_context_memory *phwi_context)
 {
+   int ret = -ENOMEM, eq_for_mcc;
unsigned int i, num_eq_pages;
-   int ret = 0, eq_for_mcc;
struct be_queue_info *eq;
struct be_dma_mem *mem;
void *eq_vaddress;
@@ -3036,8 +3036,8 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba,
mem = >dma_mem;
phwi_context->be_eq[i].phba = phba;
eq_vaddress = pci_alloc_consistent(phba->pcidev,
-num_eq_pages * PAGE_SIZE,
-);
+  num_eq_pages * PAGE_SIZE,
+  );
if (!eq_vaddress)
goto create_eq_error;
 
@@ -3065,6 +3065,7 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba,
phwi_context->be_eq[i].q.id);
}
return 0;
+
 create_eq_error:
for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) {
eq = _context->be_eq[i].q;
@@ -3081,11 +3082,11 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba,
 struct hwi_context_memory *phwi_context)
 {
unsigned int i, num_cq_pages;
-   int ret = 0;
struct be_queue_info *cq, *eq;
struct be_dma_mem *mem;
struct be_eq_obj *pbe_eq;
void *cq_vaddress;
+   int ret = -ENOMEM;
dma_addr_t paddr;
 
num_cq_pages = PAGES_REQUIRED(phba->params.num_cq_entries * \
@@ -3099,10 +3100,11 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba,
pbe_eq->phba = phba;
mem = >dma_mem;
cq_vaddress = pci_alloc_consistent(phba->pcidev,
-num_cq_pages * PAGE_SIZE,
-);
+  num_cq_pages * PAGE_SIZE,
+  );
if (!cq_vaddress)
goto create_cq_error;
+
ret = be_fill_queue(cq, phba->params.num_cq_entries,
sizeof(struct sol_cqe), cq_vaddress);
if (ret) {
@@ -3137,7 +3139,6 @@ create_cq_error:
mem->va, mem->dma);
}
return ret;
-
 }
 
 static int
@@ -4230,7 +4231,8 @@ static int beiscsi_init_port(struct beiscsi_hba *phba)
goto do_cleanup_ctrlr;
}
 
-   if (hba_setup_cid_tbls(phba)) {
+   ret = hba_setup_cid_tbls(phba);
+   if (ret < 0) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
"BM_%d : Failed in hba_setup_cid_tbls\n");
kfree(phba->io_sgl_hndl_base);
@@ -5627,7 +5629,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
struct hwi_context_memory *phwi_context;
struct be_eq_obj *pbe_eq;
unsigned int s_handle;
-   int ret = 0, i;
+   int ret, i;
 
ret = beiscsi_enable_pci(pcidev);
if (ret < 0) {
@@ -5640,6 +5642,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
if (!phba) {
dev_err(>dev,
"beiscsi_dev_probe - Failed in beiscsi_hba_alloc\n");
+   ret = -ENOMEM;
goto disable_pci;
}
 
@@ -5744,6 +5747,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
"BM_%d : beiscsi_dev_probe-"
"Failed to allocate work queue\n");
+   ret = -ENOMEM;
goto free_twq;
}
 
-- 
1.9.1

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


[PATCH 2/3] be2iscsi: Remove redundant iscsi_wrb desc memset

2016-08-24 Thread Jitendra Bhivare
alloc_wrb_handle already does memset zero of iscsi_wrb descriptor so
remove redundant memset in WRB submission paths.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
---
 drivers/scsi/be2iscsi/be_main.c | 1 -
 drivers/scsi/be2iscsi/be_mgmt.c | 3 ---
 2 files changed, 4 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index b30db87..edea89f 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -4718,7 +4718,6 @@ static int beiscsi_mtask(struct iscsi_task *task)
 
cid = beiscsi_conn->beiscsi_conn_cid;
pwrb = io_task->pwrb_handle->pwrb;
-   memset(pwrb, 0, sizeof(*pwrb));
 
if (is_chip_be2_be3r(phba)) {
AMAP_SET_BITS(struct amap_iscsi_wrb, cmdsn_itt, pwrb,
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 3ac7b88..b9ff939 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1350,7 +1350,6 @@ void beiscsi_offload_cxn_v0(struct beiscsi_offload_params 
*params,
 {
struct iscsi_wrb *pwrb = pwrb_handle->pwrb;
 
-   memset(pwrb, 0, sizeof(*pwrb));
AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
  max_send_data_segment_length, pwrb,
  params->dw[offsetof(struct amap_beiscsi_offload_params,
@@ -1422,8 +1421,6 @@ void beiscsi_offload_cxn_v2(struct beiscsi_offload_params 
*params,
 {
struct iscsi_wrb *pwrb = pwrb_handle->pwrb;
 
-   memset(pwrb, 0, sizeof(*pwrb));
-
AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
  max_burst_length, pwrb, params->dw[offsetof
  (struct amap_beiscsi_offload_params,
-- 
1.9.1

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


[PATCH v2 22/29] be2iscsi: Fail the sessions immediately after TPE

2016-08-19 Thread Jitendra Bhivare
Sessions are no longer valid, so schedule sess_work to fail the sessions
immediately when error is detected. This is done to avoid iSCSI transport
layer to keep sending NOP-Out which driver any ways fail.

Schedule sess_work immediately in case of HBA error. Old sessions are gone
for good and need to be re-established.

iscsi_session_failure needs process context hence this work.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
Reviewed-by: Hannes Reinecke <h...@suse.com>
---
 drivers/scsi/be2iscsi/be_main.c | 24 +---
 drivers/scsi/be2iscsi/be_main.h |  1 +
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 0625bd0..cf82973 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -5398,7 +5398,10 @@ static void beiscsi_hw_health_check(unsigned long ptr)
if (beiscsi_detect_ue(phba)) {
__beiscsi_log(phba, KERN_ERR,
  "BM_%d : port in error: %lx\n", phba->state);
-   /* detect TPE if UER supported */
+   /* sessions are no longer valid, so first fail the sessions */
+   queue_work(phba->wq, >sess_work);
+
+   /* detect UER supported */
if (!test_bit(BEISCSI_HBA_UER_SUPP, >state))
return;
/* modify this timer to check TPE */
@@ -5562,12 +5565,24 @@ static void beiscsi_disable_port(struct beiscsi_hba 
*phba, int unload)
hwi_cleanup_port(phba);
 }
 
+static void beiscsi_sess_work(struct work_struct *work)
+{
+   struct beiscsi_hba *phba;
+
+   phba = container_of(work, struct beiscsi_hba, sess_work);
+   /*
+* This work gets scheduled only in case of HBA error.
+* Old sessions are gone so need to be re-established.
+* iscsi_session_failure needs process context hence this work.
+*/
+   iscsi_host_for_each_session(phba->shost, beiscsi_session_fail);
+}
+
 static void beiscsi_recover_port(struct work_struct *work)
 {
struct beiscsi_hba *phba;
 
phba = container_of(work, struct beiscsi_hba, recover_port.work);
-   iscsi_host_for_each_session(phba->shost, beiscsi_session_fail);
beiscsi_disable_port(phba, 0);
beiscsi_enable_port(phba);
 }
@@ -5587,6 +5602,8 @@ static pci_ers_result_t beiscsi_eeh_err_detected(struct 
pci_dev *pdev,
del_timer_sync(>hw_check);
cancel_delayed_work_sync(>recover_port);
 
+   /* sessions are no longer valid, so first fail the sessions */
+   iscsi_host_for_each_session(phba->shost, beiscsi_session_fail);
beiscsi_disable_port(phba, 0);
 
if (state == pci_channel_io_perm_failure) {
@@ -5832,6 +5849,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
schedule_delayed_work(>eqd_update,
  msecs_to_jiffies(BEISCSI_EQD_UPDATE_INTERVAL));
 
+   INIT_WORK(>sess_work, beiscsi_sess_work);
INIT_DELAYED_WORK(>recover_port, beiscsi_recover_port);
/**
 * Start UE detection here. UE before this will cause stall in probe
@@ -5842,7 +5860,6 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
phba->hw_check.data = (unsigned long)phba;
mod_timer(>hw_check,
  jiffies + msecs_to_jiffies(BEISCSI_UE_DETECT_INTERVAL));
-
beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
"\n\n\n BM_%d : SUCCESS - DRIVER LOADED\n\n\n");
return 0;
@@ -5888,6 +5905,7 @@ static void beiscsi_remove(struct pci_dev *pcidev)
/* first stop UE detection before unloading */
del_timer_sync(>hw_check);
cancel_delayed_work_sync(>recover_port);
+   cancel_work_sync(>sess_work);
 
beiscsi_iface_destroy_default(phba);
iscsi_host_remove(phba->shost);
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 1fd6c18..953d94a 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -418,6 +418,7 @@ struct beiscsi_hba {
 #define BEISCSI_UE_DETECT_INTERVAL 1000
u32 ue2rp;
struct delayed_work recover_port;
+   struct work_struct sess_work;
 
bool mac_addr_set;
u8 mac_address[ETH_ALEN];
-- 
1.9.1

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


[PATCH v2 23/29] be2iscsi: Add FUNCTION_RESET during driver unload

2016-08-19 Thread Jitendra Bhivare
Driver unload should call COMMON_FUNCTION_RESET. For TPE feature, this
ensures that FW has knowledge about driver getting unloaded and can
reset its bit vector.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
Reviewed-by: Hannes Reinecke <h...@suse.com>
---
 drivers/scsi/be2iscsi/be_cmds.c | 2 +-
 drivers/scsi/be2iscsi/be_cmds.h | 2 ++
 drivers/scsi/be2iscsi/be_main.c | 3 +++
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index ad7405d..5fe1610 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -1595,7 +1595,7 @@ int beiscsi_check_fw_rdy(struct beiscsi_hba *phba)
return rdy;
 }
 
-static int beiscsi_cmd_function_reset(struct beiscsi_hba  *phba)
+int beiscsi_cmd_function_reset(struct beiscsi_hba *phba)
 {
struct be_ctrl_info *ctrl = >ctrl;
struct be_mcc_wrb *wrb = wrb_from_mbox(>mbox_mem);
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 26d7921..8283344 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -762,6 +762,8 @@ struct be_cmd_set_features {
} param;
 } __packed;
 
+int beiscsi_cmd_function_reset(struct beiscsi_hba *phba);
+
 int beiscsi_cmd_special_wrb(struct be_ctrl_info *ctrl, u32 load);
 
 int beiscsi_check_fw_rdy(struct beiscsi_hba *phba);
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index cf82973..3aa2f04 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -3771,9 +3771,12 @@ static void hwi_cleanup_port(struct beiscsi_hba *phba)
beiscsi_cmd_q_destroy(ctrl, q, QTYPE_EQ);
}
}
+   /* this ensures complete FW cleanup */
+   beiscsi_cmd_function_reset(phba);
/* last communication, indicate driver is unloading */
beiscsi_cmd_special_wrb(>ctrl, 0);
 }
+
 static int hwi_init_port(struct beiscsi_hba *phba)
 {
struct hwi_controller *phwi_ctrlr;
-- 
1.9.1

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


[PATCH v2 09/29] be2iscsi: Rename iface get/set/create/destroy APIs

2016-08-19 Thread Jitendra Bhivare
Rename mgmt_get_if_info to be consistent with APIs name.
Rename create/destroy APIs to indicate IFACE operations.
Remove legacy be2iscsi and use beiscsi.

Signed-off-by: Jitendra Bhivare <jitendra.bhiv...@broadcom.com>
Reviewed-by: Hannes Reinecke <h...@suse.com>
---
 drivers/scsi/be2iscsi/be_iscsi.c | 42 
 drivers/scsi/be2iscsi/be_iscsi.h | 10 +-
 drivers/scsi/be2iscsi/be_main.c  | 10 +-
 drivers/scsi/be2iscsi/be_mgmt.c  |  8 
 drivers/scsi/be2iscsi/be_mgmt.h  |  4 ++--
 5 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 1418d6b..1fe273d 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -237,7 +237,7 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session,
return beiscsi_bindconn_cid(phba, beiscsi_conn, beiscsi_ep->ep_cid);
 }
 
-static int beiscsi_create_ipv4_iface(struct beiscsi_hba *phba)
+static int beiscsi_iface_create_ipv4(struct beiscsi_hba *phba)
 {
if (phba->ipv4_iface)
return 0;
@@ -256,7 +256,7 @@ static int beiscsi_create_ipv4_iface(struct beiscsi_hba 
*phba)
return 0;
 }
 
-static int beiscsi_create_ipv6_iface(struct beiscsi_hba *phba)
+static int beiscsi_iface_create_ipv6(struct beiscsi_hba *phba)
 {
if (phba->ipv6_iface)
return 0;
@@ -275,22 +275,22 @@ static int beiscsi_create_ipv6_iface(struct beiscsi_hba 
*phba)
return 0;
 }
 
-void beiscsi_create_def_ifaces(struct beiscsi_hba *phba)
+void beiscsi_iface_create_default(struct beiscsi_hba *phba)
 {
struct be_cmd_get_if_info_resp *if_info;
 
-   if (!mgmt_get_if_info(phba, BE2_IPV4, _info)) {
-   beiscsi_create_ipv4_iface(phba);
+   if (!beiscsi_if_get_info(phba, BE2_IPV4, _info)) {
+   beiscsi_iface_create_ipv4(phba);
kfree(if_info);
}
 
-   if (!mgmt_get_if_info(phba, BE2_IPV6, _info)) {
-   beiscsi_create_ipv6_iface(phba);
+   if (!beiscsi_if_get_info(phba, BE2_IPV6, _info)) {
+   beiscsi_iface_create_ipv6(phba);
kfree(if_info);
}
 }
 
-void beiscsi_destroy_def_ifaces(struct beiscsi_hba *phba)
+void beiscsi_iface_destroy_default(struct beiscsi_hba *phba)
 {
if (phba->ipv6_iface) {
iscsi_destroy_iface(phba->ipv6_iface);
@@ -350,7 +350,7 @@ beiscsi_iface_config_ipv4(struct Scsi_Host *shost,
switch (info->param) {
case ISCSI_NET_PARAM_IFACE_ENABLE:
if (info->value[0] == ISCSI_IFACE_ENABLE)
-   ret = beiscsi_create_ipv4_iface(phba);
+   ret = beiscsi_iface_create_ipv4(phba);
else {
iscsi_destroy_iface(phba->ipv4_iface);
phba->ipv4_iface = NULL;
@@ -409,7 +409,7 @@ beiscsi_iface_config_ipv6(struct Scsi_Host *shost,
switch (iface_param->param) {
case ISCSI_NET_PARAM_IFACE_ENABLE:
if (iface_param->value[0] == ISCSI_IFACE_ENABLE)
-   ret = beiscsi_create_ipv6_iface(phba);
+   ret = beiscsi_iface_create_ipv6(phba);
else {
iscsi_destroy_iface(phba->ipv6_iface);
phba->ipv6_iface = NULL;
@@ -424,8 +424,8 @@ beiscsi_iface_config_ipv6(struct Scsi_Host *shost,
return ret;
 }
 
-int be2iscsi_iface_set_param(struct Scsi_Host *shost,
-   void *data, uint32_t dt_len)
+int beiscsi_iface_set_param(struct Scsi_Host *shost,
+   void *data, uint32_t dt_len)
 {
struct iscsi_iface_param_info *iface_param = NULL;
struct beiscsi_hba *phba = iscsi_host_priv(shost);
@@ -506,9 +506,9 @@ int be2iscsi_iface_set_param(struct Scsi_Host *shost,
return ret;
 }
 
-static int be2iscsi_get_if_param(struct beiscsi_hba *phba,
-   struct iscsi_iface *iface, int param,
-   char *buf)
+static int __beiscsi_iface_get_param(struct beiscsi_hba *phba,
+struct iscsi_iface *iface,
+int param, char *buf)
 {
struct be_cmd_get_if_info_resp *if_info;
int len, ip_type = BE2_IPV4;
@@ -516,7 +516,7 @@ static int be2iscsi_get_if_param(struct beiscsi_hba *phba,
if (iface->iface_type == ISCSI_IFACE_TYPE_IPV6)
ip_type = BE2_IPV6;
 
-   len = mgmt_get_if_info(phba, ip_type, _info);
+   len = beiscsi_if_get_info(phba, ip_type, _info);
if (len)
return len;
 
@@ -565,9 +565,9 @@ static int be2iscsi_get_if_param(struct beiscsi_hba *phba,
return len;
 }
 
-int be2iscsi_iface_get_param(struct iscsi_iface *iface,
-   enum iscsi_param_type param_type,
-   int param, char *buf)
+int beiscsi_iface_get_param(struc

  1   2   3   >