All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] BNX2I: Patch set to fix various disconnect conditions
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
@ 2010-06-26  1:39 ` Eddie Wai
  2010-06-26  1:39 ` [PATCH 1/7] BNX2I: Separated the hardware's cleanup procedure from ep_disconnect Eddie Wai
                   ` (108 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-06-26  1:39 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Hello,

This patch set contains various code fixes and optimization which mostly
deals with disconnect and clean up issues.

Your comments are grealy appreciated.  Please review, thanks.

Eddie

Eddie Wai (7):
  BNX2I: Separated the hardware's cleanup procedure from ep_disconnect
  BNX2I: Created an active linklist which holds bnx2i endpoints
  BNX2I: Optimized the bnx2i_stop connection clean up procedure
  BNX2I: Fine tuned conn destroy and context destroy timeout values
  BNX2I: Fixed the TCP graceful termination initiation
  BNX2I: Added host param ISCSI_HOST_PARAM_IPADDRESS
  BNX2I: Updated version from 2.1.1 to 2.1.2

 drivers/scsi/bnx2i/bnx2i.h       |   14 +++
 drivers/scsi/bnx2i/bnx2i_hwi.c   |    4 +
 drivers/scsi/bnx2i/bnx2i_init.c  |   39 ++++++-
 drivers/scsi/bnx2i/bnx2i_iscsi.c |  229 +++++++++++++++++++++++++++++---------
 4 files changed, 226 insertions(+), 60 deletions(-)



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 1/7] BNX2I: Separated the hardware's cleanup procedure from ep_disconnect
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
  2010-06-26  1:39 ` [PATCH 0/7] BNX2I: Patch set to fix various disconnect conditions Eddie Wai
@ 2010-06-26  1:39 ` Eddie Wai
  2010-06-30  5:53   ` Mike Christie
  2010-06-26  1:39 ` [PATCH 2/7] BNX2I: Created an active linklist which holds bnx2i endpoints Eddie Wai
                   ` (107 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-06-26  1:39 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

This patch introduces a new bnx2i_hw_ep_disconnect routine which
contains all chip related disconnect and clean up procedure of
iSCSI offload connections.  This separation is intended as a
preparation for the subsequent bnx2i_stop patch.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |  122 ++++++++++++++++++++++++-------------
 1 files changed, 79 insertions(+), 43 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index fa68ab3..3276555 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1866,54 +1866,35 @@ static int bnx2i_ep_tcp_conn_active(struct bnx2i_endpoint *bnx2i_ep)
 }
 
 
-/**
- * bnx2i_ep_disconnect - executes TCP connection teardown process
- * @ep:		TCP connection (endpoint) handle
+/*
+ * bnx2i_hw_ep_disconnect - executes TCP connection teardown process in the hw
+ * @ep:		TCP connection (bnx2i endpoint) handle
  *
  * executes  TCP connection teardown process
  */
-static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
+int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 {
-	struct bnx2i_endpoint *bnx2i_ep;
-	struct bnx2i_conn *bnx2i_conn = NULL;
-	struct iscsi_session *session = NULL;
-	struct iscsi_conn *conn;
+	struct bnx2i_hba *hba = bnx2i_ep->hba;
 	struct cnic_dev *cnic;
-	struct bnx2i_hba *hba;
+	struct iscsi_session *session = NULL;
+	struct iscsi_conn *conn = NULL;
+	int ret = 0;
 
-	bnx2i_ep = ep->dd_data;
+	if (!hba)
+		return 0;
 
-	/* driver should not attempt connection cleanup until TCP_CONNECT
-	 * completes either successfully or fails. Timeout is 9-secs, so
-	 * wait for it to complete
-	 */
-	while ((bnx2i_ep->state == EP_STATE_CONNECT_START) &&
-		!time_after(jiffies, bnx2i_ep->timestamp + (12 * HZ)))
-		msleep(250);
+	cnic = hba->cnic;
+	if (!cnic)
+		return 0;
+
+	if (!bnx2i_ep_tcp_conn_active(bnx2i_ep))
+		goto destroy_conn;
 
 	if (bnx2i_ep->conn) {
-		bnx2i_conn = bnx2i_ep->conn;
-		conn = bnx2i_conn->cls_conn->dd_data;
+		conn = bnx2i_ep->conn->cls_conn->dd_data;
 		session = conn->session;
-
-		iscsi_suspend_queue(conn);
 	}
 
-	hba = bnx2i_ep->hba;
-	if (bnx2i_ep->state == EP_STATE_IDLE)
-		goto return_bnx2i_ep;
-	cnic = hba->cnic;
-
-	mutex_lock(&hba->net_dev_lock);
-
-	if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state))
-		goto free_resc;
-	if (bnx2i_ep->hba_age != hba->age)
-		goto free_resc;
-
-	if (!bnx2i_ep_tcp_conn_active(bnx2i_ep))
-		goto destory_conn;
-
 	bnx2i_ep->state = EP_STATE_DISCONN_START;
 
 	init_timer(&bnx2i_ep->ofld_timer);
@@ -1924,6 +1905,7 @@ static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
 
 	if (test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic)) {
 		int close = 0;
+		int close_ret = 0;
 
 		if (session) {
 			spin_lock_bh(&session->lock);
@@ -1932,11 +1914,13 @@ static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
 			spin_unlock_bh(&session->lock);
 		}
 		if (close)
-			cnic->cm_close(bnx2i_ep->cm_sk);
+			close_ret = cnic->cm_close(bnx2i_ep->cm_sk);
 		else
-			cnic->cm_abort(bnx2i_ep->cm_sk);
+			close_ret = cnic->cm_abort(bnx2i_ep->cm_sk);
+		if (close_ret)
+			bnx2i_ep->state = EP_STATE_DISCONN_COMPL;
 	} else
-		goto free_resc;
+		goto out;
 
 	/* wait for option-2 conn teardown */
 	wait_event_interruptible(bnx2i_ep->ofld_wait,
@@ -1946,20 +1930,72 @@ static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
 		flush_signals(current);
 	del_timer_sync(&bnx2i_ep->ofld_timer);
 
-destory_conn:
-	if (bnx2i_tear_down_conn(hba, bnx2i_ep)) {
+destroy_conn:
+	if (bnx2i_tear_down_conn(hba, bnx2i_ep))
+		ret = -EINVAL;
+out:
+	bnx2i_ep->state = EP_STATE_IDLE;
+	return ret;
+}
+
+
+/**
+ * bnx2i_ep_disconnect - executes TCP connection teardown process
+ * @ep:		TCP connection (iscsi endpoint) handle
+ *
+ * executes  TCP connection teardown process
+ */
+static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
+{
+	struct bnx2i_endpoint *bnx2i_ep;
+	struct bnx2i_conn *bnx2i_conn = NULL;
+	struct iscsi_conn *conn = NULL;
+	struct bnx2i_hba *hba;
+
+	bnx2i_ep = ep->dd_data;
+
+	/* driver should not attempt connection cleanup until TCP_CONNECT
+	 * completes either successfully or fails. Timeout is 9-secs, so
+	 * wait for it to complete
+	 */
+	while ((bnx2i_ep->state == EP_STATE_CONNECT_START) &&
+		!time_after(jiffies, bnx2i_ep->timestamp + (12 * HZ)))
+		msleep(250);
+
+	if (bnx2i_ep->conn) {
+		bnx2i_conn = bnx2i_ep->conn;
+		conn = bnx2i_conn->cls_conn->dd_data;
+		iscsi_suspend_queue(conn);
+	}
+	hba = bnx2i_ep->hba;
+	if (!hba)
+		goto out;
+
+	mutex_lock(&hba->net_dev_lock);
+
+	if (bnx2i_ep->state == EP_STATE_IDLE)
+		goto return_bnx2i_ep;
+
+	if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state))
+		goto free_resc;
+
+	if (bnx2i_ep->hba_age != hba->age)
+		goto free_resc;
+
+	/* Do all chip cleanup here */
+	if (bnx2i_hw_ep_disconnect(bnx2i_ep)) {
 		mutex_unlock(&hba->net_dev_lock);
 		return;
 	}
 free_resc:
-	mutex_unlock(&hba->net_dev_lock);
 	bnx2i_free_qp_resc(hba, bnx2i_ep);
 return_bnx2i_ep:
 	if (bnx2i_conn)
 		bnx2i_conn->ep = NULL;
 
 	bnx2i_free_ep(ep);
-
+	mutex_unlock(&hba->net_dev_lock);
+out:
 	if (!hba->ofld_conns_active)
 		bnx2i_unreg_dev_all();
 
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 2/7] BNX2I: Created an active linklist which holds bnx2i endpoints
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
  2010-06-26  1:39 ` [PATCH 0/7] BNX2I: Patch set to fix various disconnect conditions Eddie Wai
  2010-06-26  1:39 ` [PATCH 1/7] BNX2I: Separated the hardware's cleanup procedure from ep_disconnect Eddie Wai
@ 2010-06-26  1:39 ` Eddie Wai
       [not found]   ` <1277516372-469-3-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
  2010-06-26  1:39 ` [PATCH 3/7] BNX2I: Optimized the bnx2i_stop connection clean up procedure Eddie Wai
                   ` (106 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-06-26  1:39 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

This introduces a new active linklist which would link up all active
bnx2i_endpoints.  This will be used by subsequent patches that
follows.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |    4 +++
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   43 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 46 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 6b624e7..c17c3a3 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -299,6 +299,7 @@ struct iscsi_cid_queue {
  * @cid_que:               iscsi cid queue
  * @ep_rdwr_lock:          read / write lock to synchronize various ep lists
  * @ep_ofld_list:          connection list for pending offload completion
+ * @ep_active_list:        connection list for active offload endpoints
  * @ep_destroy_list:       connection list for pending offload completion
  * @mp_bd_tbl:             BD table to be used with middle path requests
  * @mp_bd_dma:             DMA address of 'mp_bd_tbl' memory buffer
@@ -369,6 +370,7 @@ struct bnx2i_hba {
 
 	rwlock_t ep_rdwr_lock;
 	struct list_head ep_ofld_list;
+	struct list_head ep_active_list;
 	struct list_head ep_destroy_list;
 
 	/*
@@ -645,6 +647,7 @@ enum {
  * @link:               list head to link elements
  * @hba:                adapter to which this connection belongs
  * @conn:               iscsi connection this EP is linked to
+ * @cls_ep:             associated iSCSI endpoint pointer
  * @sess:               iscsi session this EP is linked to
  * @cm_sk:              cnic sock struct
  * @hba_age:            age to detect if 'iscsid' issues ep_disconnect()
@@ -664,6 +667,7 @@ struct bnx2i_endpoint {
 	struct list_head link;
 	struct bnx2i_hba *hba;
 	struct bnx2i_conn *conn;
+	struct iscsi_endpoint *cls_ep;
 	struct cnic_sock *cm_sk;
 	u32 hba_age;
 	u32 state;
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 3276555..2179296 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -386,6 +386,7 @@ static struct iscsi_endpoint *bnx2i_alloc_ep(struct bnx2i_hba *hba)
 	}
 
 	bnx2i_ep = ep->dd_data;
+	bnx2i_ep->cls_ep = ep;
 	INIT_LIST_HEAD(&bnx2i_ep->link);
 	bnx2i_ep->state = EP_STATE_IDLE;
 	bnx2i_ep->ep_iscsi_cid = (u16) -1;
@@ -678,7 +679,6 @@ bnx2i_find_ep_in_ofld_list(struct bnx2i_hba *hba, u32 iscsi_cid)
 	return ep;
 }
 
-
 /**
  * bnx2i_find_ep_in_destroy_list - find iscsi_cid in destroy list
  * @hba: 		pointer to adapter instance
@@ -708,6 +708,41 @@ bnx2i_find_ep_in_destroy_list(struct bnx2i_hba *hba, u32 iscsi_cid)
 	return ep;
 }
 
+
+/**
+ * bnx2i_ep_active_list_add - add an entry to ep active list
+ * @hba:	pointer to adapter instance
+ * @ep:		pointer to endpoint (transport indentifier) structure
+ *
+ * current active conn queue manager
+ */
+static int bnx2i_ep_active_list_add(struct bnx2i_hba *hba,
+				    struct bnx2i_endpoint *ep)
+{
+	write_lock_bh(&hba->ep_rdwr_lock);
+	list_add_tail(&ep->link, &hba->ep_active_list);
+	write_unlock_bh(&hba->ep_rdwr_lock);
+	return 0;
+}
+
+
+/**
+ * bnx2i_ep_active_list_del - deletes an entry to ep active list
+ * @hba:	pointer to adapter instance
+ * @ep:		pointer to endpoint (transport indentifier) structure
+ *
+ * current active conn queue manager
+ */
+static int bnx2i_ep_active_list_del(struct bnx2i_hba *hba,
+				    struct bnx2i_endpoint *ep)
+{
+	write_lock_bh(&hba->ep_rdwr_lock);
+	list_del_init(&ep->link);
+	write_unlock_bh(&hba->ep_rdwr_lock);
+	return 0;
+}
+
+
 /**
  * bnx2i_setup_host_queue_size - assigns shost->can_queue param
  * @hba:	pointer to adapter instance
@@ -784,6 +819,7 @@ struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic)
 		goto mp_bdt_mem_err;
 
 	INIT_LIST_HEAD(&hba->ep_ofld_list);
+	INIT_LIST_HEAD(&hba->ep_active_list);
 	INIT_LIST_HEAD(&hba->ep_destroy_list);
 	rwlock_init(&hba->ep_rdwr_lock);
 
@@ -857,6 +893,7 @@ void bnx2i_free_hba(struct bnx2i_hba *hba)
 
 	iscsi_host_remove(shost);
 	INIT_LIST_HEAD(&hba->ep_ofld_list);
+	INIT_LIST_HEAD(&hba->ep_active_list);
 	INIT_LIST_HEAD(&hba->ep_destroy_list);
 	pci_dev_put(hba->pcidev);
 
@@ -1755,6 +1792,8 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	} else
 		rc = cnic->cm_connect(bnx2i_ep->cm_sk, &saddr);
 
+	bnx2i_ep_active_list_add(hba, bnx2i_ep);
+
 	if (rc)
 		goto release_ep;
 
@@ -1764,6 +1803,7 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	return ep;
 
 release_ep:
+	bnx2i_ep_active_list_del(hba, bnx2i_ep);
 	if (bnx2i_tear_down_conn(hba, bnx2i_ep)) {
 		mutex_unlock(&hba->net_dev_lock);
 		return ERR_PTR(rc);
@@ -1931,6 +1971,7 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 	del_timer_sync(&bnx2i_ep->ofld_timer);
 
 destroy_conn:
+	bnx2i_ep_active_list_del(hba, bnx2i_ep);
 	if (bnx2i_tear_down_conn(hba, bnx2i_ep))
 		ret = -EINVAL;
 out:
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 3/7] BNX2I: Optimized the bnx2i_stop connection clean up procedure
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (2 preceding siblings ...)
  2010-06-26  1:39 ` [PATCH 2/7] BNX2I: Created an active linklist which holds bnx2i endpoints Eddie Wai
@ 2010-06-26  1:39 ` Eddie Wai
  2010-06-30  6:11   ` Mike Christie
  2010-06-26  1:39 ` [PATCH 4/7] BNX2I: Fine tuned conn destroy and context destroy timeout values Eddie Wai
                   ` (105 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-06-26  1:39 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

For cases where the iSCSI disconnection procedure times out due to
the iSCSI daemon being slow or unresponsive, the bnx2i_stop routine
will now perform hardware cleanup via bnx2i_hw_ep_disconnect on all
active endpoints so that subsequent operations will perform properly.
Also moved the mutex locks inside ep_connect and ep_disconnect so
that proper exclusivity can resolve simultaneous calls to the
ep_disconnect routine.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |    4 ++++
 drivers/scsi/bnx2i/bnx2i_init.c  |   35 ++++++++++++++++++++++++++++++++---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   11 ++++++-----
 3 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index c17c3a3..fed1a68 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -295,6 +295,7 @@ struct iscsi_cid_queue {
  * @max_cqes:              CQ size
  * @num_ccell:             number of command cells per connection
  * @ofld_conns_active:     active connection list
+ * @eh_wait:               wait queue for the endpoint to shutdown
  * @max_active_conns:      max offload connections supported by this device
  * @cid_que:               iscsi cid queue
  * @ep_rdwr_lock:          read / write lock to synchronize various ep lists
@@ -306,6 +307,7 @@ struct iscsi_cid_queue {
  * @dummy_buffer:          Dummy buffer to be used with zero length scsicmd reqs
  * @dummy_buf_dma:         DMA address of 'dummy_buffer' memory buffer
  * @lock:              	   lock to synchonize access to hba structure
+ * @hba_shutdown_tmo:      Timeout value to shutdown each connection
  * @pci_did:               PCI device ID
  * @pci_vid:               PCI vendor ID
  * @pci_sdid:              PCI subsystem device ID
@@ -770,6 +772,8 @@ extern struct bnx2i_endpoint *bnx2i_find_ep_in_destroy_list(
 extern int bnx2i_map_ep_dbell_regs(struct bnx2i_endpoint *ep);
 extern void bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action);
 
+extern int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep);
+
 /* Debug related function prototypes */
 extern void bnx2i_print_pend_cmd_queue(struct bnx2i_conn *conn);
 extern void bnx2i_print_active_cmd_queue(struct bnx2i_conn *conn);
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index af6a00a..fa4fb75 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -176,6 +176,9 @@ void bnx2i_start(void *handle)
 void bnx2i_stop(void *handle)
 {
 	struct bnx2i_hba *hba = handle;
+	struct list_head *pos, *tmp;
+	struct bnx2i_endpoint *bnx2i_ep;
+	int conns_active;
 
 	/* check if cleanup happened in GOING_DOWN context */
 	if (!test_and_clear_bit(ADAPTER_STATE_GOING_DOWN,
@@ -187,9 +190,35 @@ void bnx2i_stop(void *handle)
 	 *  control returns to network driver. So it is required to cleanup and
 	 * release all connection resources before returning from this routine.
 	 */
-	wait_event_interruptible_timeout(hba->eh_wait,
-					 (hba->ofld_conns_active == 0),
-					 hba->hba_shutdown_tmo);
+	while (hba->ofld_conns_active) {
+		conns_active = hba->ofld_conns_active;
+		wait_event_interruptible_timeout(hba->eh_wait,
+				(hba->ofld_conns_active != conns_active),
+				hba->hba_shutdown_tmo);
+		if (hba->ofld_conns_active == conns_active)
+			break;
+	}
+	if (hba->ofld_conns_active) {
+		/* Stage to force the disconnection
+		 * This is the case where the daemon is either slow or
+		 * not present
+		 */
+		printk(KERN_ALERT "bnx2i: Wait timeout, force all eps "
+			"to disconnect (%d)\n", hba->ofld_conns_active);
+		mutex_lock(&hba->net_dev_lock);
+		read_lock_bh(&hba->ep_rdwr_lock);
+		list_for_each_safe(pos, tmp, &hba->ep_active_list) {
+			bnx2i_ep = list_entry(pos, struct bnx2i_endpoint, link);
+			/* Clean up the chip only */
+			bnx2i_hw_ep_disconnect(bnx2i_ep);
+		}
+		read_unlock_bh(&hba->ep_rdwr_lock);
+		mutex_unlock(&hba->net_dev_lock);
+		if (hba->ofld_conns_active)
+			printk(KERN_ERR "bnx2i: EP disconnect timeout (%d)!\n",
+				hba->ofld_conns_active);
+	}
+
 	/* This flag should be cleared last so that ep_disconnect() gracefully
 	 * cleans up connection context
 	 */
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 2179296..a6ee72e 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -858,9 +858,9 @@ struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic)
 	mutex_init(&hba->net_dev_lock);
 	init_waitqueue_head(&hba->eh_wait);
 	if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type))
-		hba->hba_shutdown_tmo = 240 * HZ;
+		hba->hba_shutdown_tmo = 20 * HZ;
 	else	/* 5706/5708/5709 */
-		hba->hba_shutdown_tmo = 30 * HZ;
+		hba->hba_shutdown_tmo = 20 * HZ;
 
 	if (iscsi_host_add(shost, &hba->pcidev->dev))
 		goto free_dump_mem;
@@ -1702,10 +1702,11 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 
 	if (!hba || test_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state)) {
 		rc = -EINVAL;
-		goto check_busy;
+		goto nohba;
 	}
 
 	cnic = hba->cnic;
+	mutex_lock(&hba->net_dev_lock);
 	ep = bnx2i_alloc_ep(hba);
 	if (!ep) {
 		rc = -ENOMEM;
@@ -1713,7 +1714,6 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	}
 	bnx2i_ep = ep->dd_data;
 
-	mutex_lock(&hba->net_dev_lock);
 	if (bnx2i_adapter_ready(hba)) {
 		rc = -EPERM;
 		goto net_if_down;
@@ -1814,8 +1814,9 @@ iscsi_cid_err:
 	bnx2i_free_qp_resc(hba, bnx2i_ep);
 qp_resc_err:
 	bnx2i_free_ep(ep);
-	mutex_unlock(&hba->net_dev_lock);
 check_busy:
+	mutex_unlock(&hba->net_dev_lock);
+nohba:
 	bnx2i_unreg_dev_all();
 	return ERR_PTR(rc);
 }
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 4/7] BNX2I: Fine tuned conn destroy and context destroy timeout values
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (3 preceding siblings ...)
  2010-06-26  1:39 ` [PATCH 3/7] BNX2I: Optimized the bnx2i_stop connection clean up procedure Eddie Wai
@ 2010-06-26  1:39 ` Eddie Wai
  2010-06-26  1:39 ` [PATCH 5/7] BNX2I: Fixed the TCP graceful termination initiation Eddie Wai
                   ` (104 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-06-26  1:39 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Added variables to separate the fine tuned timeout values for
connection destroy and context destroy for both 1g and 10g devices.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |    4 ++++
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   13 +++++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index fed1a68..69febb6 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -308,6 +308,8 @@ struct iscsi_cid_queue {
  * @dummy_buf_dma:         DMA address of 'dummy_buffer' memory buffer
  * @lock:              	   lock to synchonize access to hba structure
  * @hba_shutdown_tmo:      Timeout value to shutdown each connection
+ * @conn_teardown_tmo:     Timeout value to tear down each connection
+ * @conn_ctx_destroy_tmo:  Timeout value to destroy context of each connection
  * @pci_did:               PCI device ID
  * @pci_vid:               PCI vendor ID
  * @pci_sdid:              PCI subsystem device ID
@@ -387,6 +389,8 @@ struct bnx2i_hba {
 	struct mutex net_dev_lock;/* sync net device access */
 
 	int hba_shutdown_tmo;
+	int conn_teardown_tmo;
+	int conn_ctx_destroy_tmo;
 	/*
 	 * PCI related info.
 	 */
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index a6ee72e..f8394d4 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -857,10 +857,15 @@ struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic)
 	spin_lock_init(&hba->lock);
 	mutex_init(&hba->net_dev_lock);
 	init_waitqueue_head(&hba->eh_wait);
-	if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type))
+	if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type)) {
 		hba->hba_shutdown_tmo = 20 * HZ;
-	else	/* 5706/5708/5709 */
+		hba->conn_teardown_tmo = 10 * HZ;
+		hba->conn_ctx_destroy_tmo = 6 * HZ;
+	} else {	/* 5706/5708/5709 */
 		hba->hba_shutdown_tmo = 20 * HZ;
+		hba->conn_teardown_tmo = 10 * HZ;
+		hba->conn_ctx_destroy_tmo = 2 * HZ;
+	}
 
 	if (iscsi_host_add(shost, &hba->pcidev->dev))
 		goto free_dump_mem;
@@ -1636,7 +1641,7 @@ static int bnx2i_tear_down_conn(struct bnx2i_hba *hba,
 
 	ep->state = EP_STATE_CLEANUP_START;
 	init_timer(&ep->ofld_timer);
-	ep->ofld_timer.expires = 10*HZ + jiffies;
+	ep->ofld_timer.expires = hba->conn_ctx_destroy_tmo + jiffies;
 	ep->ofld_timer.function = bnx2i_ep_ofld_timer;
 	ep->ofld_timer.data = (unsigned long) ep;
 	add_timer(&ep->ofld_timer);
@@ -1939,7 +1944,7 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 	bnx2i_ep->state = EP_STATE_DISCONN_START;
 
 	init_timer(&bnx2i_ep->ofld_timer);
-	bnx2i_ep->ofld_timer.expires = 10*HZ + jiffies;
+	bnx2i_ep->ofld_timer.expires = hba->conn_teardown_tmo + jiffies;
 	bnx2i_ep->ofld_timer.function = bnx2i_ep_ofld_timer;
 	bnx2i_ep->ofld_timer.data = (unsigned long) bnx2i_ep;
 	add_timer(&bnx2i_ep->ofld_timer);
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 5/7] BNX2I: Fixed the TCP graceful termination initiation
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (4 preceding siblings ...)
  2010-06-26  1:39 ` [PATCH 4/7] BNX2I: Fine tuned conn destroy and context destroy timeout values Eddie Wai
@ 2010-06-26  1:39 ` Eddie Wai
  2010-06-30  6:20   ` Mike Christie
  2010-06-26  1:39 ` [PATCH 6/7] BNX2I: Added host param ISCSI_HOST_PARAM_IPADDRESS Eddie Wai
                   ` (103 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-06-26  1:39 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

In compliance to RFC793, a TCP graceful termination will be used
instead of an abortive termination for the case where the remote
has initiated the close of the connection.
Additionally, a TCP abortive termination will be used to close the
connection when a logout response is not received in time after a
logout request has been initiated.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |    2 ++
 drivers/scsi/bnx2i/bnx2i_hwi.c   |    4 ++++
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   21 ++++++++++++++++++---
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 69febb6..00c0335 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -639,6 +639,8 @@ enum {
 	EP_STATE_CLEANUP_CMPL           = 0x800,
 	EP_STATE_TCP_FIN_RCVD           = 0x1000,
 	EP_STATE_TCP_RST_RCVD           = 0x2000,
+	EP_STATE_LOGOUT_SENT            = 0x4000,
+	EP_STATE_LOGOUT_RESP_RCVD       = 0x8000,
 	EP_STATE_PG_OFLD_FAILED         = 0x1000000,
 	EP_STATE_ULP_UPDATE_FAILED      = 0x2000000,
 	EP_STATE_CLEANUP_FAILED         = 0x4000000,
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 3a66ca2..d23fc25 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -562,6 +562,8 @@ int bnx2i_send_iscsi_logout(struct bnx2i_conn *bnx2i_conn,
 	logout_wqe->num_bds = 1;
 	logout_wqe->cq_index = 0; /* CQ# used for completion, 5771x only */
 
+	bnx2i_conn->ep->state = EP_STATE_LOGOUT_SENT;
+
 	bnx2i_ring_dbell_update_sq_params(bnx2i_conn, 1);
 	return 0;
 }
@@ -1482,6 +1484,8 @@ static int bnx2i_process_logout_resp(struct iscsi_session *session,
 	resp_hdr->t2retain = cpu_to_be32(logout->time_to_retain);
 
 	__iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, NULL, 0);
+
+	bnx2i_conn->ep->state = EP_STATE_LOGOUT_RESP_RCVD;
 done:
 	spin_unlock(&session->lock);
 	return 0;
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index f8394d4..29dbb96 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1892,6 +1892,8 @@ static int bnx2i_ep_tcp_conn_active(struct bnx2i_endpoint *bnx2i_ep)
 	case EP_STATE_ULP_UPDATE_START:
 	case EP_STATE_ULP_UPDATE_COMPL:
 	case EP_STATE_TCP_FIN_RCVD:
+	case EP_STATE_LOGOUT_SENT:
+	case EP_STATE_LOGOUT_RESP_RCVD:
 	case EP_STATE_ULP_UPDATE_FAILED:
 		ret = 1;
 		break;
@@ -1941,8 +1943,6 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 		session = conn->session;
 	}
 
-	bnx2i_ep->state = EP_STATE_DISCONN_START;
-
 	init_timer(&bnx2i_ep->ofld_timer);
 	bnx2i_ep->ofld_timer.expires = hba->conn_teardown_tmo + jiffies;
 	bnx2i_ep->ofld_timer.function = bnx2i_ep_ofld_timer;
@@ -1955,10 +1955,25 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 
 		if (session) {
 			spin_lock_bh(&session->lock);
-			if (session->state == ISCSI_STATE_LOGGING_OUT)
+			if (bnx2i_ep->state != EP_STATE_TCP_FIN_RCVD) {
+				if (session->state == ISCSI_STATE_LOGGING_OUT) {
+					if (bnx2i_ep->state ==
+					    EP_STATE_LOGOUT_SENT) {
+						/* Logout sent, but no resp */
+						printk(KERN_ALERT "bnx2i - "
+						"WARNING logout response"
+						" was not received!\n");
+					} else if (bnx2i_ep->state ==
+						   EP_STATE_LOGOUT_RESP_RCVD)
+						close = 1;
+				}
+			} else
 				close = 1;
+
 			spin_unlock_bh(&session->lock);
 		}
+		bnx2i_ep->state = EP_STATE_DISCONN_START;
+
 		if (close)
 			close_ret = cnic->cm_close(bnx2i_ep->cm_sk);
 		else
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 6/7] BNX2I: Added host param ISCSI_HOST_PARAM_IPADDRESS
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (5 preceding siblings ...)
  2010-06-26  1:39 ` [PATCH 5/7] BNX2I: Fixed the TCP graceful termination initiation Eddie Wai
@ 2010-06-26  1:39 ` Eddie Wai
  2010-06-26  1:39 ` [PATCH 7/7] BNX2I: Updated version from 2.1.1 to 2.1.2 Eddie Wai
                   ` (102 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-06-26  1:39 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

From: Michael Chan <mchan@broadcom.com>

This sysfs attribute is proven to be useful during pivot_root.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 29dbb96..db93015 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1503,6 +1503,26 @@ static int bnx2i_host_get_param(struct Scsi_Host *shost,
 	case ISCSI_HOST_PARAM_NETDEV_NAME:
 		len = sprintf(buf, "%s\n", hba->netdev->name);
 		break;
+	case ISCSI_HOST_PARAM_IPADDRESS: {
+		struct list_head *active_list = &hba->ep_active_list;
+
+		read_lock_bh(&hba->ep_rdwr_lock);
+		if (!list_empty(&hba->ep_active_list)) {
+			struct bnx2i_endpoint *bnx2i_ep;
+			struct cnic_sock *csk;
+
+			bnx2i_ep = list_first_entry(active_list,
+						    struct bnx2i_endpoint,
+						    link);
+			csk = bnx2i_ep->cm_sk;
+			if (test_bit(SK_F_IPV6, &csk->flags))
+				len = sprintf(buf, "%pI6\n", csk->src_ip);
+			else
+				len = sprintf(buf, "%pI4\n", csk->src_ip);
+		}
+		read_unlock_bh(&hba->ep_rdwr_lock);
+		break;
+	}
 	default:
 		return iscsi_host_get_param(shost, param, buf);
 	}
@@ -2136,7 +2156,8 @@ struct iscsi_transport bnx2i_iscsi_transport = {
 				  ISCSI_LU_RESET_TMO | ISCSI_TGT_RESET_TMO |
 				  ISCSI_PING_TMO | ISCSI_RECV_TMO |
 				  ISCSI_IFACE_NAME | ISCSI_INITIATOR_NAME,
-	.host_param_mask	= ISCSI_HOST_HWADDRESS | ISCSI_HOST_NETDEV_NAME,
+	.host_param_mask	= ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS |
+				  ISCSI_HOST_NETDEV_NAME,
 	.create_session		= bnx2i_session_create,
 	.destroy_session	= bnx2i_session_destroy,
 	.create_conn		= bnx2i_conn_create,
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 7/7] BNX2I: Updated version from 2.1.1 to 2.1.2
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (6 preceding siblings ...)
  2010-06-26  1:39 ` [PATCH 6/7] BNX2I: Added host param ISCSI_HOST_PARAM_IPADDRESS Eddie Wai
@ 2010-06-26  1:39 ` Eddie Wai
  2010-07-01 22:34 ` [PATCH 0/7 v2] BNX2I: Patch set to fix various disconnect conditions Eddie Wai
                   ` (101 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-06-26  1:39 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_init.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index fa4fb75..e7d2396 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -17,8 +17,8 @@ static struct list_head adapter_list = LIST_HEAD_INIT(adapter_list);
 static u32 adapter_count;
 
 #define DRV_MODULE_NAME		"bnx2i"
-#define DRV_MODULE_VERSION	"2.1.1"
-#define DRV_MODULE_RELDATE	"Mar 24, 2010"
+#define DRV_MODULE_VERSION	"2.1.2"
+#define DRV_MODULE_RELDATE	"Jun 24, 2010"
 
 static char version[] __devinitdata =
 		"Broadcom NetXtreme II iSCSI Driver " DRV_MODULE_NAME \
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH 1/7] BNX2I: Separated the hardware's cleanup procedure from ep_disconnect
  2010-06-26  1:39 ` [PATCH 1/7] BNX2I: Separated the hardware's cleanup procedure from ep_disconnect Eddie Wai
@ 2010-06-30  5:53   ` Mike Christie
  2010-06-30  6:07     ` Eddie Wai
  0 siblings, 1 reply; 189+ messages in thread
From: Mike Christie @ 2010-06-30  5:53 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 06/25/2010 08:39 PM, Eddie Wai wrote:
> +/**
> + * bnx2i_ep_disconnect - executes TCP connection teardown process
> + * @ep:		TCP connection (iscsi endpoint) handle
> + *
> + * executes  TCP connection teardown process
> + */
> +static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
> +{
> +	struct bnx2i_endpoint *bnx2i_ep;
> +	struct bnx2i_conn *bnx2i_conn = NULL;
> +	struct iscsi_conn *conn = NULL;
> +	struct bnx2i_hba *hba;
> +
> +	bnx2i_ep = ep->dd_data;
> +
> +	/* driver should not attempt connection cleanup until TCP_CONNECT
> +	 * completes either successfully or fails. Timeout is 9-secs, so
> +	 * wait for it to complete
> +	 */
> +	while ((bnx2i_ep->state == EP_STATE_CONNECT_START)&&
> +		!time_after(jiffies, bnx2i_ep->timestamp + (12 * HZ)))
> +		msleep(250);
> +
> +	if (bnx2i_ep->conn) {
> +		bnx2i_conn = bnx2i_ep->conn;
> +		conn = bnx2i_conn->cls_conn->dd_data;
> +		iscsi_suspend_queue(conn);
> +	}
> +	hba = bnx2i_ep->hba;
> +	if (!hba)
> +		goto out;


Here you have a ep, so if you goto out you will not release it. Need to 
call iscsi_destroy_endpoint at least. Can you hit this "if" even?

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 2/7] BNX2I: Created an active linklist which holds bnx2i endpoints
       [not found]   ` <1277516372-469-3-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
@ 2010-06-30  5:59     ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2010-06-30  5:59 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 06/25/2010 08:39 PM, Eddie Wai wrote:
> +/**
> + * bnx2i_ep_active_list_add - add an entry to ep active list
> + * @hba:	pointer to adapter instance
> + * @ep:		pointer to endpoint (transport indentifier) structure
> + *
> + * current active conn queue manager
> + */
> +static int bnx2i_ep_active_list_add(struct bnx2i_hba *hba,
> +				    struct bnx2i_endpoint *ep)
> +{
> +	write_lock_bh(&hba->ep_rdwr_lock);
> +	list_add_tail(&ep->link,&hba->ep_active_list);
> +	write_unlock_bh(&hba->ep_rdwr_lock);
> +	return 0;
> +}

I do not think you need the return here. It is always zero and no one 
ever checks it.


> +
> +
> +/**
> + * bnx2i_ep_active_list_del - deletes an entry to ep active list
> + * @hba:	pointer to adapter instance
> + * @ep:		pointer to endpoint (transport indentifier) structure
> + *
> + * current active conn queue manager
> + */
> +static int bnx2i_ep_active_list_del(struct bnx2i_hba *hba,
> +				    struct bnx2i_endpoint *ep)
> +{
> +	write_lock_bh(&hba->ep_rdwr_lock);
> +	list_del_init(&ep->link);
> +	write_unlock_bh(&hba->ep_rdwr_lock);
> +	return 0;
> +}

Same as above.

> @@ -1755,6 +1792,8 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
>   	} else
>   		rc = cnic->cm_connect(bnx2i_ep->cm_sk,&saddr);
>
> +	bnx2i_ep_active_list_add(hba, bnx2i_ep);
> +
>   	if (rc)
>   		goto release_ep;

This is a little strange. It seems cleaner to just do:

         if (bnx2i_map_ep_dbell_regs(bnx2i_ep))
                 goto del_active_ep:

del_active_ep:
	bnx2i_ep_active_list_del(hba, bnx2i_ep);
release_ep:
         if (bnx2i_tear_down_conn(hba, bnx2i_ep)) {
                 mutex_unlock(&hba->net_dev_lock);
                 return ERR_PTR(rc);


>
> @@ -1764,6 +1803,7 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
>   	return ep;
>
>   release_ep:
> +	bnx2i_ep_active_list_del(hba, bnx2i_ep);
>   	if (bnx2i_tear_down_conn(hba, bnx2i_ep)) {
>   		mutex_unlock(&hba->net_dev_lock);
>   		return ERR_PTR(rc);
> @@ -1931,6 +1971,7 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
>   	del_timer_sync(&bnx2i_ep->ofld_timer);
>
>   destroy_conn:
> +	bnx2i_ep_active_list_del(hba, bnx2i_ep);
>   	if (bnx2i_tear_down_conn(hba, bnx2i_ep))
>   		ret = -EINVAL;
>   out:

-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 1/7] BNX2I: Separated the hardware's cleanup procedure from ep_disconnect
  2010-06-30  5:53   ` Mike Christie
@ 2010-06-30  6:07     ` Eddie Wai
  0 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-06-30  6:07 UTC (permalink / raw)
  To: Mike Christie
  Cc: Eddie Wai, James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Benjamin Li

Hello Mike,

You're right. That extra checking for !hba was added recently as
defensive programming and it should never hit.  I'll remove it in v2.

Thanks,
Eddie

On Tue, 2010-06-29 at 22:53 -0700, Mike Christie wrote:
> On 06/25/2010 08:39 PM, Eddie Wai wrote:
> > +/**
> > + * bnx2i_ep_disconnect - executes TCP connection teardown process
> > + * @ep:		TCP connection (iscsi endpoint) handle
> > + *
> > + * executes  TCP connection teardown process
> > + */
> > +static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
> > +{
> > +	struct bnx2i_endpoint *bnx2i_ep;
> > +	struct bnx2i_conn *bnx2i_conn = NULL;
> > +	struct iscsi_conn *conn = NULL;
> > +	struct bnx2i_hba *hba;
> > +
> > +	bnx2i_ep = ep->dd_data;
> > +
> > +	/* driver should not attempt connection cleanup until TCP_CONNECT
> > +	 * completes either successfully or fails. Timeout is 9-secs, so
> > +	 * wait for it to complete
> > +	 */
> > +	while ((bnx2i_ep->state == EP_STATE_CONNECT_START)&&
> > +		!time_after(jiffies, bnx2i_ep->timestamp + (12 * HZ)))
> > +		msleep(250);
> > +
> > +	if (bnx2i_ep->conn) {
> > +		bnx2i_conn = bnx2i_ep->conn;
> > +		conn = bnx2i_conn->cls_conn->dd_data;
> > +		iscsi_suspend_queue(conn);
> > +	}
> > +	hba = bnx2i_ep->hba;
> > +	if (!hba)
> > +		goto out;
> 
> 
> Here you have a ep, so if you goto out you will not release it. Need to 
> call iscsi_destroy_endpoint at least. Can you hit this "if" even?
> 



^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 3/7] BNX2I: Optimized the bnx2i_stop connection clean up procedure
  2010-06-26  1:39 ` [PATCH 3/7] BNX2I: Optimized the bnx2i_stop connection clean up procedure Eddie Wai
@ 2010-06-30  6:11   ` Mike Christie
  2010-06-30  6:56     ` Eddie Wai
  0 siblings, 1 reply; 189+ messages in thread
From: Mike Christie @ 2010-06-30  6:11 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 06/25/2010 08:39 PM, Eddie Wai wrote:
> For cases where the iSCSI disconnection procedure times out due to
> the iSCSI daemon being slow or unresponsive, the bnx2i_stop routine

Could you describe when iscsid is slow a little more? The unresponsive 
case sounds like if iscsid is not running, right? For the slow case, it 
sounds like you are trying to work around a bug in there.

I am also not sure how it helps exactly. iscsid still has to cleanup the 
iscsi resources like the scsi commands running on the connection (conn 
stop is called after ep disconnect), so I am not sure how this helps. 
Does doing it this way skip some steps?

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 5/7] BNX2I: Fixed the TCP graceful termination initiation
  2010-06-26  1:39 ` [PATCH 5/7] BNX2I: Fixed the TCP graceful termination initiation Eddie Wai
@ 2010-06-30  6:20   ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2010-06-30  6:20 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 06/25/2010 08:39 PM, Eddie Wai wrote:
>   		if (session) {
>   			spin_lock_bh(&session->lock);
> -			if (session->state == ISCSI_STATE_LOGGING_OUT)
> +			if (bnx2i_ep->state != EP_STATE_TCP_FIN_RCVD) {
> +				if (session->state == ISCSI_STATE_LOGGING_OUT) {
> +					if (bnx2i_ep->state ==
> +					    EP_STATE_LOGOUT_SENT) {
> +						/* Logout sent, but no resp */
> +						printk(KERN_ALERT "bnx2i - "
> +						"WARNING logout response"
> +						" was not received!\n");
> +					} else if (bnx2i_ep->state ==
> +						   EP_STATE_LOGOUT_RESP_RCVD)
> +						close = 1;
> +				}
> +			} else
>   				close = 1;
> +

I think you can make this chunk easier to read if you did

If (!test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic))
	goto out;

then do the:

if (session) {
	........

It gives you an extra tab so you do not have break up some lines, the 
tabbing/spacing will be right on the printk text, and and your eyes do 
not get crammed looking at the far right corner so much.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 3/7] BNX2I: Optimized the bnx2i_stop connection clean up procedure
  2010-06-30  6:11   ` Mike Christie
@ 2010-06-30  6:56     ` Eddie Wai
  0 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-06-30  6:56 UTC (permalink / raw)
  To: Mike Christie
  Cc: Eddie Wai, James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Benjamin Li

Our test group has generated a case where a MTU change or an ifdown was
performed while having active sessions outstanding.  While the
disconnection effort works normally, but for the case where iscsid is
forced to stop, our driver was previously designed to dead wait for 240s
before resuming operation.  Once the wait is over, any leftover chip
resources allocated + previously active iscsi_endpoints would be
forfeited.  For this kind of destructive testing, we decided that it is
best to clean up our chip so that other operations such as L2 or FCoE
would not get affected.  

The 'slow' case mentioned is just a hypothetical case which we have not
encountered first hand.  But the code has been worked so that if iscsid
were to come back up and continue to call ep_disconnect again, only the
endpoints would get cleanup and will no longer attempt to clean up the
hardware.  We're not trying to work around a bug here...

For the case presented, bnx2i_stop was actually called from cnic's
ulp_stop due to the different test case described.  The hard 240s
timeout was there to wait for iscsid to cleanup all the active
connections.  If it were to be exceeded somehow, the same lost resource
+ endpoint condition would happen.

Eddie

On Tue, 2010-06-29 at 23:11 -0700, Mike Christie wrote:
> On 06/25/2010 08:39 PM, Eddie Wai wrote:
> > For cases where the iSCSI disconnection procedure times out due to
> > the iSCSI daemon being slow or unresponsive, the bnx2i_stop routine
> 
> Could you describe when iscsid is slow a little more? The unresponsive 
> case sounds like if iscsid is not running, right? For the slow case, it 
> sounds like you are trying to work around a bug in there.
> 
> I am also not sure how it helps exactly. iscsid still has to cleanup the 
> iscsi resources like the scsi commands running on the connection (conn 
> stop is called after ep disconnect), so I am not sure how this helps. 
> Does doing it this way skip some steps?
> 



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 0/7 v2] BNX2I: Patch set to fix various disconnect conditions
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (7 preceding siblings ...)
  2010-06-26  1:39 ` [PATCH 7/7] BNX2I: Updated version from 2.1.1 to 2.1.2 Eddie Wai
@ 2010-07-01 22:34 ` Eddie Wai
  2010-07-08  0:49   ` Mike Christie
  2010-07-01 22:34 ` [PATCH 1/7 v2] BNX2I: Separated the hardware's cleanup procedure from ep_disconnect Eddie Wai
                   ` (100 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-07-01 22:34 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Hello,

This patch set contains various code fixes and optimization which mostly
deals with disconnect and clean up issues.

The following is a list of changes for v2:
1)  Extended the disconnect timeout from 10s to 20s as the 10g firmware
has a FIN retransmission timeout of 16s.  This fixes one of the
iscsi_endpoint leak issues when the target is slow or non-responsive to
our TCP FIN sent.

2)  Removed the unnecessary read lock in the bnx2i_stop.

3)  Optimized various code paths based on Mike Christie's comments.

Your comments are greatly appreciated.  Please review, thanks.

Eddie

Eddie Wai (7):
  BNX2I: Separated the hardware's cleanup procedure from ep_disconnect
  BNX2I: Created an active linklist which holds bnx2i endpoints
  BNX2I: Optimized the bnx2i_stop connection clean up procedure
  BNX2I: Fine tuned conn destroy and context destroy timeout values
  BNX2I: Fixed the TCP graceful termination initiation
  BNX2I: Added host param ISCSI_HOST_PARAM_IPADDRESS
  BNX2I: Updated version from 2.1.1 to 2.1.2

 drivers/scsi/bnx2i/bnx2i.h       |   14 +++
 drivers/scsi/bnx2i/bnx2i_hwi.c   |    4 +
 drivers/scsi/bnx2i/bnx2i_init.c  |   39 ++++++-
 drivers/scsi/bnx2i/bnx2i_iscsi.c |  229 +++++++++++++++++++++++++++++---------
 4 files changed, 226 insertions(+), 60 deletions(-)



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 1/7 v2] BNX2I: Separated the hardware's cleanup procedure from ep_disconnect
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (8 preceding siblings ...)
  2010-07-01 22:34 ` [PATCH 0/7 v2] BNX2I: Patch set to fix various disconnect conditions Eddie Wai
@ 2010-07-01 22:34 ` Eddie Wai
  2010-07-01 22:34 ` [PATCH 3/7 v2] BNX2I: Optimized the bnx2i_stop connection clean up procedure Eddie Wai
                   ` (99 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-07-01 22:34 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

This patch introduces a new bnx2i_hw_ep_disconnect routine which
contains all chip related disconnect and clean up procedure of
iSCSI offload connections.  This separation is intended as a
preparation for the subsequent bnx2i_stop patch.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |  119 ++++++++++++++++++++++++--------------
 1 files changed, 76 insertions(+), 43 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index fa68ab3..6edfde5 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1866,54 +1866,35 @@ static int bnx2i_ep_tcp_conn_active(struct bnx2i_endpoint *bnx2i_ep)
 }
 
 
-/**
- * bnx2i_ep_disconnect - executes TCP connection teardown process
- * @ep:		TCP connection (endpoint) handle
+/*
+ * bnx2i_hw_ep_disconnect - executes TCP connection teardown process in the hw
+ * @ep:		TCP connection (bnx2i endpoint) handle
  *
  * executes  TCP connection teardown process
  */
-static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
+int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 {
-	struct bnx2i_endpoint *bnx2i_ep;
-	struct bnx2i_conn *bnx2i_conn = NULL;
-	struct iscsi_session *session = NULL;
-	struct iscsi_conn *conn;
+	struct bnx2i_hba *hba = bnx2i_ep->hba;
 	struct cnic_dev *cnic;
-	struct bnx2i_hba *hba;
+	struct iscsi_session *session = NULL;
+	struct iscsi_conn *conn = NULL;
+	int ret = 0;
 
-	bnx2i_ep = ep->dd_data;
+	if (!hba)
+		return 0;
 
-	/* driver should not attempt connection cleanup until TCP_CONNECT
-	 * completes either successfully or fails. Timeout is 9-secs, so
-	 * wait for it to complete
-	 */
-	while ((bnx2i_ep->state == EP_STATE_CONNECT_START) &&
-		!time_after(jiffies, bnx2i_ep->timestamp + (12 * HZ)))
-		msleep(250);
+	cnic = hba->cnic;
+	if (!cnic)
+		return 0;
+
+	if (!bnx2i_ep_tcp_conn_active(bnx2i_ep))
+		goto destroy_conn;
 
 	if (bnx2i_ep->conn) {
-		bnx2i_conn = bnx2i_ep->conn;
-		conn = bnx2i_conn->cls_conn->dd_data;
+		conn = bnx2i_ep->conn->cls_conn->dd_data;
 		session = conn->session;
-
-		iscsi_suspend_queue(conn);
 	}
 
-	hba = bnx2i_ep->hba;
-	if (bnx2i_ep->state == EP_STATE_IDLE)
-		goto return_bnx2i_ep;
-	cnic = hba->cnic;
-
-	mutex_lock(&hba->net_dev_lock);
-
-	if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state))
-		goto free_resc;
-	if (bnx2i_ep->hba_age != hba->age)
-		goto free_resc;
-
-	if (!bnx2i_ep_tcp_conn_active(bnx2i_ep))
-		goto destory_conn;
-
 	bnx2i_ep->state = EP_STATE_DISCONN_START;
 
 	init_timer(&bnx2i_ep->ofld_timer);
@@ -1924,6 +1905,7 @@ static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
 
 	if (test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic)) {
 		int close = 0;
+		int close_ret = 0;
 
 		if (session) {
 			spin_lock_bh(&session->lock);
@@ -1932,11 +1914,13 @@ static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
 			spin_unlock_bh(&session->lock);
 		}
 		if (close)
-			cnic->cm_close(bnx2i_ep->cm_sk);
+			close_ret = cnic->cm_close(bnx2i_ep->cm_sk);
 		else
-			cnic->cm_abort(bnx2i_ep->cm_sk);
+			close_ret = cnic->cm_abort(bnx2i_ep->cm_sk);
+		if (close_ret)
+			bnx2i_ep->state = EP_STATE_DISCONN_COMPL;
 	} else
-		goto free_resc;
+		goto out;
 
 	/* wait for option-2 conn teardown */
 	wait_event_interruptible(bnx2i_ep->ofld_wait,
@@ -1946,20 +1930,69 @@ static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
 		flush_signals(current);
 	del_timer_sync(&bnx2i_ep->ofld_timer);
 
-destory_conn:
-	if (bnx2i_tear_down_conn(hba, bnx2i_ep)) {
+destroy_conn:
+	if (bnx2i_tear_down_conn(hba, bnx2i_ep))
+		ret = -EINVAL;
+out:
+	bnx2i_ep->state = EP_STATE_IDLE;
+	return ret;
+}
+
+
+/**
+ * bnx2i_ep_disconnect - executes TCP connection teardown process
+ * @ep:		TCP connection (iscsi endpoint) handle
+ *
+ * executes  TCP connection teardown process
+ */
+static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
+{
+	struct bnx2i_endpoint *bnx2i_ep;
+	struct bnx2i_conn *bnx2i_conn = NULL;
+	struct iscsi_conn *conn = NULL;
+	struct bnx2i_hba *hba;
+
+	bnx2i_ep = ep->dd_data;
+
+	/* driver should not attempt connection cleanup until TCP_CONNECT
+	 * completes either successfully or fails. Timeout is 9-secs, so
+	 * wait for it to complete
+	 */
+	while ((bnx2i_ep->state == EP_STATE_CONNECT_START) &&
+		!time_after(jiffies, bnx2i_ep->timestamp + (12 * HZ)))
+		msleep(250);
+
+	if (bnx2i_ep->conn) {
+		bnx2i_conn = bnx2i_ep->conn;
+		conn = bnx2i_conn->cls_conn->dd_data;
+		iscsi_suspend_queue(conn);
+	}
+	hba = bnx2i_ep->hba;
+
+	mutex_lock(&hba->net_dev_lock);
+
+	if (bnx2i_ep->state == EP_STATE_IDLE)
+		goto return_bnx2i_ep;
+
+	if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state))
+		goto free_resc;
+
+	if (bnx2i_ep->hba_age != hba->age)
+		goto free_resc;
+
+	/* Do all chip cleanup here */
+	if (bnx2i_hw_ep_disconnect(bnx2i_ep)) {
 		mutex_unlock(&hba->net_dev_lock);
 		return;
 	}
 free_resc:
-	mutex_unlock(&hba->net_dev_lock);
 	bnx2i_free_qp_resc(hba, bnx2i_ep);
 return_bnx2i_ep:
 	if (bnx2i_conn)
 		bnx2i_conn->ep = NULL;
 
 	bnx2i_free_ep(ep);
-
+	mutex_unlock(&hba->net_dev_lock);
 	if (!hba->ofld_conns_active)
 		bnx2i_unreg_dev_all();
 
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 2/7 v2] BNX2I: Created an active linklist which holds bnx2i endpoints
       [not found] ` <Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
@ 2010-07-01 22:34   ` Eddie Wai
  2010-07-01 22:34   ` [PATCH 4/7 v2] BNX2I: Fine tuned conn destroy and context destroy timeout values Eddie Wai
                     ` (10 subsequent siblings)
  11 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-07-01 22:34 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

This introduces a new active linklist which would link up all active
bnx2i_endpoints.  This will be used by subsequent patches that
follows.

Signed-off-by: Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Reviewed-by: Michael Chan <mchan-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Reviewed-by: Benjamin Li <benli-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Acked-by: Anil Veerabhadrappa <anilgv-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
---
 drivers/scsi/bnx2i/bnx2i.h       |    4 +++
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   46 +++++++++++++++++++++++++++++++++++--
 2 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 6b624e7..c17c3a3 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -299,6 +299,7 @@ struct iscsi_cid_queue {
  * @cid_que:               iscsi cid queue
  * @ep_rdwr_lock:          read / write lock to synchronize various ep lists
  * @ep_ofld_list:          connection list for pending offload completion
+ * @ep_active_list:        connection list for active offload endpoints
  * @ep_destroy_list:       connection list for pending offload completion
  * @mp_bd_tbl:             BD table to be used with middle path requests
  * @mp_bd_dma:             DMA address of 'mp_bd_tbl' memory buffer
@@ -369,6 +370,7 @@ struct bnx2i_hba {
 
 	rwlock_t ep_rdwr_lock;
 	struct list_head ep_ofld_list;
+	struct list_head ep_active_list;
 	struct list_head ep_destroy_list;
 
 	/*
@@ -645,6 +647,7 @@ enum {
  * @link:               list head to link elements
  * @hba:                adapter to which this connection belongs
  * @conn:               iscsi connection this EP is linked to
+ * @cls_ep:             associated iSCSI endpoint pointer
  * @sess:               iscsi session this EP is linked to
  * @cm_sk:              cnic sock struct
  * @hba_age:            age to detect if 'iscsid' issues ep_disconnect()
@@ -664,6 +667,7 @@ struct bnx2i_endpoint {
 	struct list_head link;
 	struct bnx2i_hba *hba;
 	struct bnx2i_conn *conn;
+	struct iscsi_endpoint *cls_ep;
 	struct cnic_sock *cm_sk;
 	u32 hba_age;
 	u32 state;
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 6edfde5..fb5fe88 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -386,6 +386,7 @@ static struct iscsi_endpoint *bnx2i_alloc_ep(struct bnx2i_hba *hba)
 	}
 
 	bnx2i_ep = ep->dd_data;
+	bnx2i_ep->cls_ep = ep;
 	INIT_LIST_HEAD(&bnx2i_ep->link);
 	bnx2i_ep->state = EP_STATE_IDLE;
 	bnx2i_ep->ep_iscsi_cid = (u16) -1;
@@ -678,7 +679,6 @@ bnx2i_find_ep_in_ofld_list(struct bnx2i_hba *hba, u32 iscsi_cid)
 	return ep;
 }
 
-
 /**
  * bnx2i_find_ep_in_destroy_list - find iscsi_cid in destroy list
  * @hba: 		pointer to adapter instance
@@ -708,6 +708,39 @@ bnx2i_find_ep_in_destroy_list(struct bnx2i_hba *hba, u32 iscsi_cid)
 	return ep;
 }
 
+
+/**
+ * bnx2i_ep_active_list_add - add an entry to ep active list
+ * @hba:	pointer to adapter instance
+ * @ep:		pointer to endpoint (transport indentifier) structure
+ *
+ * current active conn queue manager
+ */
+static void bnx2i_ep_active_list_add(struct bnx2i_hba *hba,
+				     struct bnx2i_endpoint *ep)
+{
+	write_lock_bh(&hba->ep_rdwr_lock);
+	list_add_tail(&ep->link, &hba->ep_active_list);
+	write_unlock_bh(&hba->ep_rdwr_lock);
+}
+
+
+/**
+ * bnx2i_ep_active_list_del - deletes an entry to ep active list
+ * @hba:	pointer to adapter instance
+ * @ep:		pointer to endpoint (transport indentifier) structure
+ *
+ * current active conn queue manager
+ */
+static void bnx2i_ep_active_list_del(struct bnx2i_hba *hba,
+				     struct bnx2i_endpoint *ep)
+{
+	write_lock_bh(&hba->ep_rdwr_lock);
+	list_del_init(&ep->link);
+	write_unlock_bh(&hba->ep_rdwr_lock);
+}
+
+
 /**
  * bnx2i_setup_host_queue_size - assigns shost->can_queue param
  * @hba:	pointer to adapter instance
@@ -784,6 +817,7 @@ struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic)
 		goto mp_bdt_mem_err;
 
 	INIT_LIST_HEAD(&hba->ep_ofld_list);
+	INIT_LIST_HEAD(&hba->ep_active_list);
 	INIT_LIST_HEAD(&hba->ep_destroy_list);
 	rwlock_init(&hba->ep_rdwr_lock);
 
@@ -857,6 +891,7 @@ void bnx2i_free_hba(struct bnx2i_hba *hba)
 
 	iscsi_host_remove(shost);
 	INIT_LIST_HEAD(&hba->ep_ofld_list);
+	INIT_LIST_HEAD(&hba->ep_active_list);
 	INIT_LIST_HEAD(&hba->ep_destroy_list);
 	pci_dev_put(hba->pcidev);
 
@@ -1754,15 +1789,19 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 		goto conn_failed;
 	} else
 		rc = cnic->cm_connect(bnx2i_ep->cm_sk, &saddr);
-
 	if (rc)
 		goto release_ep;
 
+	bnx2i_ep_active_list_add(hba, bnx2i_ep);
+
 	if (bnx2i_map_ep_dbell_regs(bnx2i_ep))
-		goto release_ep;
+		goto del_active_ep;
+
 	mutex_unlock(&hba->net_dev_lock);
 	return ep;
 
+del_active_ep:
+	bnx2i_ep_active_list_del(hba, bnx2i_ep);
 release_ep:
 	if (bnx2i_tear_down_conn(hba, bnx2i_ep)) {
 		mutex_unlock(&hba->net_dev_lock);
@@ -1931,6 +1970,7 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 	del_timer_sync(&bnx2i_ep->ofld_timer);
 
 destroy_conn:
+	bnx2i_ep_active_list_del(hba, bnx2i_ep);
 	if (bnx2i_tear_down_conn(hba, bnx2i_ep))
 		ret = -EINVAL;
 out:
-- 
1.7.0.5


-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 3/7 v2] BNX2I: Optimized the bnx2i_stop connection clean up procedure
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (9 preceding siblings ...)
  2010-07-01 22:34 ` [PATCH 1/7 v2] BNX2I: Separated the hardware's cleanup procedure from ep_disconnect Eddie Wai
@ 2010-07-01 22:34 ` Eddie Wai
  2010-07-01 22:34 ` [PATCH 5/7 v2] BNX2I: Fixed the TCP graceful termination initiation Eddie Wai
                   ` (98 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-07-01 22:34 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

For cases where the iSCSI disconnection procedure times out due to
the iSCSI daemon being slow or unresponsive, the bnx2i_stop routine
will now perform hardware cleanup via bnx2i_hw_ep_disconnect on all
active endpoints so that subsequent operations will perform properly.
Also moved the mutex locks inside ep_connect and ep_disconnect so
that proper exclusivity can resolve simultaneous calls to the
ep_disconnect routine.

v2: Removed the unnecessary read lock in the bnx2i_stop

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |    4 ++++
 drivers/scsi/bnx2i/bnx2i_init.c  |   33 ++++++++++++++++++++++++++++++---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   12 ++++++------
 3 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index c17c3a3..fed1a68 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -295,6 +295,7 @@ struct iscsi_cid_queue {
  * @max_cqes:              CQ size
  * @num_ccell:             number of command cells per connection
  * @ofld_conns_active:     active connection list
+ * @eh_wait:               wait queue for the endpoint to shutdown
  * @max_active_conns:      max offload connections supported by this device
  * @cid_que:               iscsi cid queue
  * @ep_rdwr_lock:          read / write lock to synchronize various ep lists
@@ -306,6 +307,7 @@ struct iscsi_cid_queue {
  * @dummy_buffer:          Dummy buffer to be used with zero length scsicmd reqs
  * @dummy_buf_dma:         DMA address of 'dummy_buffer' memory buffer
  * @lock:              	   lock to synchonize access to hba structure
+ * @hba_shutdown_tmo:      Timeout value to shutdown each connection
  * @pci_did:               PCI device ID
  * @pci_vid:               PCI vendor ID
  * @pci_sdid:              PCI subsystem device ID
@@ -770,6 +772,8 @@ extern struct bnx2i_endpoint *bnx2i_find_ep_in_destroy_list(
 extern int bnx2i_map_ep_dbell_regs(struct bnx2i_endpoint *ep);
 extern void bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action);
 
+extern int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep);
+
 /* Debug related function prototypes */
 extern void bnx2i_print_pend_cmd_queue(struct bnx2i_conn *conn);
 extern void bnx2i_print_active_cmd_queue(struct bnx2i_conn *conn);
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index af6a00a..f0f8361 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -176,6 +176,9 @@ void bnx2i_start(void *handle)
 void bnx2i_stop(void *handle)
 {
 	struct bnx2i_hba *hba = handle;
+	struct list_head *pos, *tmp;
+	struct bnx2i_endpoint *bnx2i_ep;
+	int conns_active;
 
 	/* check if cleanup happened in GOING_DOWN context */
 	if (!test_and_clear_bit(ADAPTER_STATE_GOING_DOWN,
@@ -187,9 +190,33 @@ void bnx2i_stop(void *handle)
 	 *  control returns to network driver. So it is required to cleanup and
 	 * release all connection resources before returning from this routine.
 	 */
-	wait_event_interruptible_timeout(hba->eh_wait,
-					 (hba->ofld_conns_active == 0),
-					 hba->hba_shutdown_tmo);
+	while (hba->ofld_conns_active) {
+		conns_active = hba->ofld_conns_active;
+		wait_event_interruptible_timeout(hba->eh_wait,
+				(hba->ofld_conns_active != conns_active),
+				hba->hba_shutdown_tmo);
+		if (hba->ofld_conns_active == conns_active)
+			break;
+	}
+	if (hba->ofld_conns_active) {
+		/* Stage to force the disconnection
+		 * This is the case where the daemon is either slow or
+		 * not present
+		 */
+		printk(KERN_ALERT "bnx2i: Wait timeout, force all eps "
+			"to disconnect (%d)\n", hba->ofld_conns_active);
+		mutex_lock(&hba->net_dev_lock);
+		list_for_each_safe(pos, tmp, &hba->ep_active_list) {
+			bnx2i_ep = list_entry(pos, struct bnx2i_endpoint, link);
+			/* Clean up the chip only */
+			bnx2i_hw_ep_disconnect(bnx2i_ep);
+		}
+		mutex_unlock(&hba->net_dev_lock);
+		if (hba->ofld_conns_active)
+			printk(KERN_ERR "bnx2i: EP disconnect timeout (%d)!\n",
+				hba->ofld_conns_active);
+	}
+
 	/* This flag should be cleared last so that ep_disconnect() gracefully
 	 * cleans up connection context
 	 */
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index fb5fe88..1600e7c 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -708,7 +708,6 @@ bnx2i_find_ep_in_destroy_list(struct bnx2i_hba *hba, u32 iscsi_cid)
 	return ep;
 }
 
-
 /**
  * bnx2i_ep_active_list_add - add an entry to ep active list
  * @hba:	pointer to adapter instance
@@ -856,9 +855,9 @@ struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic)
 	mutex_init(&hba->net_dev_lock);
 	init_waitqueue_head(&hba->eh_wait);
 	if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type))
-		hba->hba_shutdown_tmo = 240 * HZ;
+		hba->hba_shutdown_tmo = 20 * HZ;
 	else	/* 5706/5708/5709 */
-		hba->hba_shutdown_tmo = 30 * HZ;
+		hba->hba_shutdown_tmo = 20 * HZ;
 
 	if (iscsi_host_add(shost, &hba->pcidev->dev))
 		goto free_dump_mem;
@@ -1700,10 +1699,11 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 
 	if (!hba || test_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state)) {
 		rc = -EINVAL;
-		goto check_busy;
+		goto nohba;
 	}
 
 	cnic = hba->cnic;
+	mutex_lock(&hba->net_dev_lock);
 	ep = bnx2i_alloc_ep(hba);
 	if (!ep) {
 		rc = -ENOMEM;
@@ -1711,7 +1711,6 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	}
 	bnx2i_ep = ep->dd_data;
 
-	mutex_lock(&hba->net_dev_lock);
 	if (bnx2i_adapter_ready(hba)) {
 		rc = -EPERM;
 		goto net_if_down;
@@ -1813,8 +1812,9 @@ iscsi_cid_err:
 	bnx2i_free_qp_resc(hba, bnx2i_ep);
 qp_resc_err:
 	bnx2i_free_ep(ep);
-	mutex_unlock(&hba->net_dev_lock);
 check_busy:
+	mutex_unlock(&hba->net_dev_lock);
+nohba:
 	bnx2i_unreg_dev_all();
 	return ERR_PTR(rc);
 }
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 4/7 v2] BNX2I: Fine tuned conn destroy and context destroy timeout values
       [not found] ` <Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
  2010-07-01 22:34   ` [PATCH 2/7 v2] BNX2I: Created an active linklist which holds bnx2i endpoints Eddie Wai
@ 2010-07-01 22:34   ` Eddie Wai
  2010-08-10 19:09   ` [PATCH 1/5] BNX2I: Fixed a protocol violation on nopout responses Eddie Wai
                     ` (9 subsequent siblings)
  11 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-07-01 22:34 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Added variables to separate the fine tuned timeout values for
connection destroy and context destroy for both 1g and 10g devices.

v2: Extended the 5771X disconnect timeout from 10s to 20s as the firmware
has a retransmission timeout of 16s.  This fixes one of the iscsi_endpoint
leak issues when the target is slow or non-responsive to our TCP FIN.

Signed-off-by: Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Reviewed-by: Michael Chan <mchan-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Reviewed-by: Benjamin Li <benli-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Acked-by: Anil Veerabhadrappa <anilgv-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
---
 drivers/scsi/bnx2i/bnx2i.h       |    4 ++++
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   13 +++++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index fed1a68..69febb6 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -308,6 +308,8 @@ struct iscsi_cid_queue {
  * @dummy_buf_dma:         DMA address of 'dummy_buffer' memory buffer
  * @lock:              	   lock to synchonize access to hba structure
  * @hba_shutdown_tmo:      Timeout value to shutdown each connection
+ * @conn_teardown_tmo:     Timeout value to tear down each connection
+ * @conn_ctx_destroy_tmo:  Timeout value to destroy context of each connection
  * @pci_did:               PCI device ID
  * @pci_vid:               PCI vendor ID
  * @pci_sdid:              PCI subsystem device ID
@@ -387,6 +389,8 @@ struct bnx2i_hba {
 	struct mutex net_dev_lock;/* sync net device access */
 
 	int hba_shutdown_tmo;
+	int conn_teardown_tmo;
+	int conn_ctx_destroy_tmo;
 	/*
 	 * PCI related info.
 	 */
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 1600e7c..f6eebb3 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -854,10 +854,15 @@ struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic)
 	spin_lock_init(&hba->lock);
 	mutex_init(&hba->net_dev_lock);
 	init_waitqueue_head(&hba->eh_wait);
-	if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type))
+	if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type)) {
 		hba->hba_shutdown_tmo = 20 * HZ;
-	else	/* 5706/5708/5709 */
+		hba->conn_teardown_tmo = 20 * HZ;
+		hba->conn_ctx_destroy_tmo = 6 * HZ;
+	} else {	/* 5706/5708/5709 */
 		hba->hba_shutdown_tmo = 20 * HZ;
+		hba->conn_teardown_tmo = 10 * HZ;
+		hba->conn_ctx_destroy_tmo = 2 * HZ;
+	}
 
 	if (iscsi_host_add(shost, &hba->pcidev->dev))
 		goto free_dump_mem;
@@ -1633,7 +1638,7 @@ static int bnx2i_tear_down_conn(struct bnx2i_hba *hba,
 
 	ep->state = EP_STATE_CLEANUP_START;
 	init_timer(&ep->ofld_timer);
-	ep->ofld_timer.expires = 10*HZ + jiffies;
+	ep->ofld_timer.expires = hba->conn_ctx_destroy_tmo + jiffies;
 	ep->ofld_timer.function = bnx2i_ep_ofld_timer;
 	ep->ofld_timer.data = (unsigned long) ep;
 	add_timer(&ep->ofld_timer);
@@ -1937,7 +1942,7 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 	bnx2i_ep->state = EP_STATE_DISCONN_START;
 
 	init_timer(&bnx2i_ep->ofld_timer);
-	bnx2i_ep->ofld_timer.expires = 10*HZ + jiffies;
+	bnx2i_ep->ofld_timer.expires = hba->conn_teardown_tmo + jiffies;
 	bnx2i_ep->ofld_timer.function = bnx2i_ep_ofld_timer;
 	bnx2i_ep->ofld_timer.data = (unsigned long) bnx2i_ep;
 	add_timer(&bnx2i_ep->ofld_timer);
-- 
1.7.0.5


-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 5/7 v2] BNX2I: Fixed the TCP graceful termination initiation
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (10 preceding siblings ...)
  2010-07-01 22:34 ` [PATCH 3/7 v2] BNX2I: Optimized the bnx2i_stop connection clean up procedure Eddie Wai
@ 2010-07-01 22:34 ` Eddie Wai
  2010-07-01 22:34 ` [PATCH 6/7 v2] BNX2I: Added host param ISCSI_HOST_PARAM_IPADDRESS Eddie Wai
                   ` (97 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-07-01 22:34 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

In compliance to RFC793, a TCP graceful termination will be used
instead of an abortive termination for the case where the remote
has initiated the close of the connection.
Additionally, a TCP abortive termination will be used to close the
connection when a logout response is not received in time after a
logout request has been initiated.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |    2 +
 drivers/scsi/bnx2i/bnx2i_hwi.c   |    4 +++
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   53 ++++++++++++++++++++++++-------------
 3 files changed, 40 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 69febb6..00c0335 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -639,6 +639,8 @@ enum {
 	EP_STATE_CLEANUP_CMPL           = 0x800,
 	EP_STATE_TCP_FIN_RCVD           = 0x1000,
 	EP_STATE_TCP_RST_RCVD           = 0x2000,
+	EP_STATE_LOGOUT_SENT            = 0x4000,
+	EP_STATE_LOGOUT_RESP_RCVD       = 0x8000,
 	EP_STATE_PG_OFLD_FAILED         = 0x1000000,
 	EP_STATE_ULP_UPDATE_FAILED      = 0x2000000,
 	EP_STATE_CLEANUP_FAILED         = 0x4000000,
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 3a66ca2..d23fc25 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -562,6 +562,8 @@ int bnx2i_send_iscsi_logout(struct bnx2i_conn *bnx2i_conn,
 	logout_wqe->num_bds = 1;
 	logout_wqe->cq_index = 0; /* CQ# used for completion, 5771x only */
 
+	bnx2i_conn->ep->state = EP_STATE_LOGOUT_SENT;
+
 	bnx2i_ring_dbell_update_sq_params(bnx2i_conn, 1);
 	return 0;
 }
@@ -1482,6 +1484,8 @@ static int bnx2i_process_logout_resp(struct iscsi_session *session,
 	resp_hdr->t2retain = cpu_to_be32(logout->time_to_retain);
 
 	__iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, NULL, 0);
+
+	bnx2i_conn->ep->state = EP_STATE_LOGOUT_RESP_RCVD;
 done:
 	spin_unlock(&session->lock);
 	return 0;
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index f6eebb3..0b4a59e 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1890,6 +1890,8 @@ static int bnx2i_ep_tcp_conn_active(struct bnx2i_endpoint *bnx2i_ep)
 	case EP_STATE_ULP_UPDATE_START:
 	case EP_STATE_ULP_UPDATE_COMPL:
 	case EP_STATE_TCP_FIN_RCVD:
+	case EP_STATE_LOGOUT_SENT:
+	case EP_STATE_LOGOUT_RESP_RCVD:
 	case EP_STATE_ULP_UPDATE_FAILED:
 		ret = 1;
 		break;
@@ -1923,6 +1925,8 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 	struct iscsi_session *session = NULL;
 	struct iscsi_conn *conn = NULL;
 	int ret = 0;
+	int close = 0;
+	int close_ret = 0;
 
 	if (!hba)
 		return 0;
@@ -1939,33 +1943,44 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 		session = conn->session;
 	}
 
-	bnx2i_ep->state = EP_STATE_DISCONN_START;
-
 	init_timer(&bnx2i_ep->ofld_timer);
 	bnx2i_ep->ofld_timer.expires = hba->conn_teardown_tmo + jiffies;
 	bnx2i_ep->ofld_timer.function = bnx2i_ep_ofld_timer;
 	bnx2i_ep->ofld_timer.data = (unsigned long) bnx2i_ep;
 	add_timer(&bnx2i_ep->ofld_timer);
 
-	if (test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic)) {
-		int close = 0;
-		int close_ret = 0;
-
-		if (session) {
-			spin_lock_bh(&session->lock);
-			if (session->state == ISCSI_STATE_LOGGING_OUT)
-				close = 1;
-			spin_unlock_bh(&session->lock);
-		}
-		if (close)
-			close_ret = cnic->cm_close(bnx2i_ep->cm_sk);
-		else
-			close_ret = cnic->cm_abort(bnx2i_ep->cm_sk);
-		if (close_ret)
-			bnx2i_ep->state = EP_STATE_DISCONN_COMPL;
-	} else
+	if (!test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic))
 		goto out;
 
+	if (session) {
+		spin_lock_bh(&session->lock);
+		if (bnx2i_ep->state != EP_STATE_TCP_FIN_RCVD) {
+			if (session->state == ISCSI_STATE_LOGGING_OUT) {
+				if (bnx2i_ep->state == EP_STATE_LOGOUT_SENT) {
+					/* Logout sent, but no resp */
+					printk(KERN_ALERT "bnx2i - WARNING "
+						"logout response was not "
+						"received!\n");
+				} else if (bnx2i_ep->state ==
+					   EP_STATE_LOGOUT_RESP_RCVD)
+					close = 1;
+			}
+		} else
+			close = 1;
+
+		spin_unlock_bh(&session->lock);
+	}
+
+	bnx2i_ep->state = EP_STATE_DISCONN_START;
+
+	if (close)
+		close_ret = cnic->cm_close(bnx2i_ep->cm_sk);
+	else
+		close_ret = cnic->cm_abort(bnx2i_ep->cm_sk);
+
+	if (close_ret)
+		bnx2i_ep->state = EP_STATE_DISCONN_COMPL;
+
 	/* wait for option-2 conn teardown */
 	wait_event_interruptible(bnx2i_ep->ofld_wait,
 				 bnx2i_ep->state != EP_STATE_DISCONN_START);
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 6/7 v2] BNX2I: Added host param ISCSI_HOST_PARAM_IPADDRESS
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (11 preceding siblings ...)
  2010-07-01 22:34 ` [PATCH 5/7 v2] BNX2I: Fixed the TCP graceful termination initiation Eddie Wai
@ 2010-07-01 22:34 ` Eddie Wai
  2010-07-01 22:34 ` [PATCH 7/7 v2] BNX2I: Updated version from 2.1.1 to 2.1.2 Eddie Wai
                   ` (96 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-07-01 22:34 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

From: Michael Chan <mchan@broadcom.com>

This sysfs attribute is proven to be useful during pivot_root.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 0b4a59e..c079975 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1500,6 +1500,26 @@ static int bnx2i_host_get_param(struct Scsi_Host *shost,
 	case ISCSI_HOST_PARAM_NETDEV_NAME:
 		len = sprintf(buf, "%s\n", hba->netdev->name);
 		break;
+	case ISCSI_HOST_PARAM_IPADDRESS: {
+		struct list_head *active_list = &hba->ep_active_list;
+
+		read_lock_bh(&hba->ep_rdwr_lock);
+		if (!list_empty(&hba->ep_active_list)) {
+			struct bnx2i_endpoint *bnx2i_ep;
+			struct cnic_sock *csk;
+
+			bnx2i_ep = list_first_entry(active_list,
+						    struct bnx2i_endpoint,
+						    link);
+			csk = bnx2i_ep->cm_sk;
+			if (test_bit(SK_F_IPV6, &csk->flags))
+				len = sprintf(buf, "%pI6\n", csk->src_ip);
+			else
+				len = sprintf(buf, "%pI4\n", csk->src_ip);
+		}
+		read_unlock_bh(&hba->ep_rdwr_lock);
+		break;
+	}
 	default:
 		return iscsi_host_get_param(shost, param, buf);
 	}
@@ -2131,7 +2151,8 @@ struct iscsi_transport bnx2i_iscsi_transport = {
 				  ISCSI_LU_RESET_TMO | ISCSI_TGT_RESET_TMO |
 				  ISCSI_PING_TMO | ISCSI_RECV_TMO |
 				  ISCSI_IFACE_NAME | ISCSI_INITIATOR_NAME,
-	.host_param_mask	= ISCSI_HOST_HWADDRESS | ISCSI_HOST_NETDEV_NAME,
+	.host_param_mask	= ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS |
+				  ISCSI_HOST_NETDEV_NAME,
 	.create_session		= bnx2i_session_create,
 	.destroy_session	= bnx2i_session_destroy,
 	.create_conn		= bnx2i_conn_create,
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 7/7 v2] BNX2I: Updated version from 2.1.1 to 2.1.2
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (12 preceding siblings ...)
  2010-07-01 22:34 ` [PATCH 6/7 v2] BNX2I: Added host param ISCSI_HOST_PARAM_IPADDRESS Eddie Wai
@ 2010-07-01 22:34 ` Eddie Wai
  2010-07-21 18:51 ` [PATCH] Added fix for unsolicited NOP-In handling Eddie Wai
                   ` (95 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-07-01 22:34 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_init.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index f0f8361..a796f56 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -17,8 +17,8 @@ static struct list_head adapter_list = LIST_HEAD_INIT(adapter_list);
 static u32 adapter_count;
 
 #define DRV_MODULE_NAME		"bnx2i"
-#define DRV_MODULE_VERSION	"2.1.1"
-#define DRV_MODULE_RELDATE	"Mar 24, 2010"
+#define DRV_MODULE_VERSION	"2.1.2"
+#define DRV_MODULE_RELDATE	"Jun 28, 2010"
 
 static char version[] __devinitdata =
 		"Broadcom NetXtreme II iSCSI Driver " DRV_MODULE_NAME \
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH 0/7 v2] BNX2I: Patch set to fix various disconnect conditions
  2010-07-01 22:34 ` [PATCH 0/7 v2] BNX2I: Patch set to fix various disconnect conditions Eddie Wai
@ 2010-07-08  0:49   ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2010-07-08  0:49 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 07/01/2010 05:34 PM, Eddie Wai wrote:
> Hello,
>
> This patch set contains various code fixes and optimization which mostly
> deals with disconnect and clean up issues.
>
> The following is a list of changes for v2:
> 1)  Extended the disconnect timeout from 10s to 20s as the 10g firmware
> has a FIN retransmission timeout of 16s.  This fixes one of the
> iscsi_endpoint leak issues when the target is slow or non-responsive to
> our TCP FIN sent.
>
> 2)  Removed the unnecessary read lock in the bnx2i_stop.
>
> 3)  Optimized various code paths based on Mike Christie's comments.
>
> Your comments are greatly appreciated.  Please review, thanks.
>
> Eddie
>
> Eddie Wai (7):
>    BNX2I: Separated the hardware's cleanup procedure from ep_disconnect
>    BNX2I: Created an active linklist which holds bnx2i endpoints
>    BNX2I: Optimized the bnx2i_stop connection clean up procedure
>    BNX2I: Fine tuned conn destroy and context destroy timeout values
>    BNX2I: Fixed the TCP graceful termination initiation
>    BNX2I: Added host param ISCSI_HOST_PARAM_IPADDRESS
>    BNX2I: Updated version from 2.1.1 to 2.1.2
>
>   drivers/scsi/bnx2i/bnx2i.h       |   14 +++
>   drivers/scsi/bnx2i/bnx2i_hwi.c   |    4 +
>   drivers/scsi/bnx2i/bnx2i_init.c  |   39 ++++++-
>   drivers/scsi/bnx2i/bnx2i_iscsi.c |  229 +++++++++++++++++++++++++++++---------
>   4 files changed, 226 insertions(+), 60 deletions(-)
>
>

Thanks for the update. Updated patches look ok to me.

Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH] Added fix for unsolicited NOP-In handling
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (13 preceding siblings ...)
  2010-07-01 22:34 ` [PATCH 7/7 v2] BNX2I: Updated version from 2.1.1 to 2.1.2 Eddie Wai
@ 2010-07-21 18:51 ` Eddie Wai
  2010-07-21 18:51 ` [PATCH] BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins Eddie Wai
                   ` (94 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-07-21 18:51 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Hello,

Two unsolicited NOP-In fixes are included in this patch set:
1 - ITT bug fix for the unsolicited NOP-In handling
2 - added the RQE extraction even when the rx pipe is suspended

Your comments are greatly appreciated.  Please review, thanks.
Eddie

Eddie Wai (1):
  BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins

 drivers/scsi/bnx2i/bnx2i_hwi.c |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH] BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (14 preceding siblings ...)
  2010-07-21 18:51 ` [PATCH] Added fix for unsolicited NOP-In handling Eddie Wai
@ 2010-07-21 18:51 ` Eddie Wai
       [not found]   ` <1279738270-21911-2-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
  2010-07-27 16:12 ` [PATCH] BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In Eddie Wai
                   ` (93 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-07-21 18:51 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Unsolicited NOP-Ins are placed in the receive queue of the hardware
which requires to be read out regardless if the receive pipe is suspended
or not.  This patch adds the disposal of this RQ element under this
condition.
Also fixed the bug in the unsolicited NOP-In handling routine which
checks for the RESERVED_ITT.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 3a66ca2..69741cf 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1544,11 +1544,9 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session,
 	struct iscsi_task *task;
 	struct bnx2i_nop_in_msg *nop_in;
 	struct iscsi_nopin *hdr;
-	u32 itt;
 	int tgt_async_nop = 0;
 
 	nop_in = (struct bnx2i_nop_in_msg *)cqe;
-	itt = nop_in->itt & ISCSI_NOP_IN_MSG_INDEX;
 
 	spin_lock(&session->lock);
 	hdr = (struct iscsi_nopin *)&bnx2i_conn->gen_pdu.resp_hdr;
@@ -1558,7 +1556,7 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session,
 	hdr->exp_cmdsn = cpu_to_be32(nop_in->exp_cmd_sn);
 	hdr->ttt = cpu_to_be32(nop_in->ttt);
 
-	if (itt == (u16) RESERVED_ITT) {
+	if (nop_in->itt == (u16) RESERVED_ITT) {
 		bnx2i_unsol_pdu_adjust_rq(bnx2i_conn);
 		hdr->itt = RESERVED_ITT;
 		tgt_async_nop = 1;
@@ -1566,7 +1564,8 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session,
 	}
 
 	/* this is a response to one of our nop-outs */
-	task = iscsi_itt_to_task(conn, itt);
+	task = iscsi_itt_to_task(conn,
+				 (u32) (nop_in->itt & ISCSI_NOP_IN_MSG_INDEX));
 	if (task) {
 		hdr->flags = ISCSI_FLAG_CMD_FINAL;
 		hdr->itt = task->hdr->itt;
@@ -1716,9 +1715,17 @@ static void bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
 		if (nopin->cq_req_sn != qp->cqe_exp_seq_sn)
 			break;
 
-		if (unlikely(test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx)))
+		if (unlikely(test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx))) {
+			if (nopin->op_code == ISCSI_OP_NOOP_IN) {
+				printk(KERN_ALERT "bnx2i: Unsolicited "
+					"NOP-In detected for suspended "
+					"connection dev=%s!\n",
+					bnx2i_conn->hba->netdev->name);
+				bnx2i_unsol_pdu_adjust_rq(bnx2i_conn);
+				goto cqe_out;
+			}
 			break;
-
+		}
 		tgt_async_msg = 0;
 
 		switch (nopin->op_code) {
@@ -1765,10 +1772,9 @@ static void bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
 			printk(KERN_ALERT "bnx2i: unknown opcode 0x%x\n",
 					  nopin->op_code);
 		}
-
 		if (!tgt_async_msg)
 			bnx2i_conn->ep->num_active_cmds--;
-
+cqe_out:
 		/* clear out in production version only, till beta keep opcode
 		 * field intact, will be helpful in debugging (context dump)
 		 * nopin->op_code = 0;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH] BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins
       [not found]   ` <1279738270-21911-2-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
@ 2010-07-23  4:50     ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2010-07-23  4:50 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 07/21/2010 01:51 PM, Eddie Wai wrote:
> Unsolicited NOP-Ins are placed in the receive queue of the hardware
> which requires to be read out regardless if the receive pipe is suspended
> or not.  This patch adds the disposal of this RQ element under this
> condition.
> Also fixed the bug in the unsolicited NOP-In handling routine which
> checks for the RESERVED_ITT.
>

Looks ok.


Reviewed-by: Mike Christie <michaelc-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>

-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH] BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (15 preceding siblings ...)
  2010-07-21 18:51 ` [PATCH] BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins Eddie Wai
@ 2010-07-27 16:12 ` Eddie Wai
  2010-07-27 17:27   ` Mike Christie
  2010-08-10 19:09 ` [PATCH 0/5] Patch set to fix various bugs in bnx2i Eddie Wai
                   ` (92 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-07-27 16:12 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The patch fixes the following situations where NOP-Out pkt is called for:
- local unsolicited NOP-Out requests (requesting no NOP-In response)
- local NOP-Out responses to unsolicited NOP-In requests
 
kernel panic is observed due to double session spin_lock requests; one in the
bnx2i_process_nopin_local_cmpl routine in bnx2i_hwi.c and the other in the
iscsi_put_task routine in libiscsi.c

The proposed fix is to export the currently static __iscsi_put_task() routine
and have bnx2i call it directly instead of the iscsi_put_task() routine which
holds the session spin lock.


Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Acked-by: Benjamin Li <benli@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |    2 +-
 drivers/scsi/libiscsi.c        |    3 ++-
 include/scsi/libiscsi.h        |    1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index d23fc25..58cd7fc 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1512,7 +1512,7 @@ static void bnx2i_process_nopin_local_cmpl(struct iscsi_session *session,
 	task = iscsi_itt_to_task(conn,
 				 nop_in->itt & ISCSI_NOP_IN_MSG_INDEX);
 	if (task)
-		iscsi_put_task(task);
+		__iscsi_put_task(task);
 	spin_unlock(&session->lock);
 }
 
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 633e090..b63e2a4 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -539,11 +539,12 @@ void __iscsi_get_task(struct iscsi_task *task)
 }
 EXPORT_SYMBOL_GPL(__iscsi_get_task);
 
-static void __iscsi_put_task(struct iscsi_task *task)
+void __iscsi_put_task(struct iscsi_task *task)
 {
 	if (atomic_dec_and_test(&task->refcount))
 		iscsi_free_task(task);
 }
+EXPORT_SYMBOL_GPL(__iscsi_put_task);
 
 void iscsi_put_task(struct iscsi_task *task)
 {
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index ae5196a..2ea9aec 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -420,6 +420,7 @@ extern struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *, itt_t);
 extern struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *, itt_t);
 extern void iscsi_requeue_task(struct iscsi_task *task);
 extern void iscsi_put_task(struct iscsi_task *task);
+extern void __iscsi_put_task(struct iscsi_task *task);
 extern void __iscsi_get_task(struct iscsi_task *task);
 extern void iscsi_complete_scsi_task(struct iscsi_task *task,
 				     uint32_t exp_cmdsn, uint32_t max_cmdsn);
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH] BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In
  2010-07-27 16:12 ` [PATCH] BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In Eddie Wai
@ 2010-07-27 17:27   ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2010-07-27 17:27 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 07/27/2010 11:12 AM, Eddie Wai wrote:
> The patch fixes the following situations where NOP-Out pkt is called for:
> - local unsolicited NOP-Out requests (requesting no NOP-In response)
> - local NOP-Out responses to unsolicited NOP-In requests
>
> kernel panic is observed due to double session spin_lock requests; one in the
> bnx2i_process_nopin_local_cmpl routine in bnx2i_hwi.c and the other in the
> iscsi_put_task routine in libiscsi.c
>
> The proposed fix is to export the currently static __iscsi_put_task() routine
> and have bnx2i call it directly instead of the iscsi_put_task() routine which
> holds the session spin lock.
>
>
> Signed-off-by: Eddie Wai<eddie.wai@broadcom.com>
> Reviewed-by: Michael Chan<mchan@broadcom.com>
> Reviewed-by: Anil Veerabhadrappa<anilgv@broadcom.com>
> Acked-by: Benjamin Li<benli@broadcom.com>
> ---
>   drivers/scsi/bnx2i/bnx2i_hwi.c |    2 +-
>   drivers/scsi/libiscsi.c        |    3 ++-
>   include/scsi/libiscsi.h        |    1 +
>   3 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
> index d23fc25..58cd7fc 100644
> --- a/drivers/scsi/bnx2i/bnx2i_hwi.c
> +++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
> @@ -1512,7 +1512,7 @@ static void bnx2i_process_nopin_local_cmpl(struct iscsi_session *session,
>   	task = iscsi_itt_to_task(conn,
>   				 nop_in->itt&  ISCSI_NOP_IN_MSG_INDEX);
>   	if (task)
> -		iscsi_put_task(task);
> +		__iscsi_put_task(task);
>   	spin_unlock(&session->lock);
>   }
>
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index 633e090..b63e2a4 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -539,11 +539,12 @@ void __iscsi_get_task(struct iscsi_task *task)
>   }
>   EXPORT_SYMBOL_GPL(__iscsi_get_task);
>
> -static void __iscsi_put_task(struct iscsi_task *task)
> +void __iscsi_put_task(struct iscsi_task *task)
>   {
>   	if (atomic_dec_and_test(&task->refcount))
>   		iscsi_free_task(task);
>   }
> +EXPORT_SYMBOL_GPL(__iscsi_put_task);
>
>   void iscsi_put_task(struct iscsi_task *task)
>   {
> diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
> index ae5196a..2ea9aec 100644
> --- a/include/scsi/libiscsi.h
> +++ b/include/scsi/libiscsi.h
> @@ -420,6 +420,7 @@ extern struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *, itt_t);
>   extern struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *, itt_t);
>   extern void iscsi_requeue_task(struct iscsi_task *task);
>   extern void iscsi_put_task(struct iscsi_task *task);
> +extern void __iscsi_put_task(struct iscsi_task *task);
>   extern void __iscsi_get_task(struct iscsi_task *task);
>   extern void iscsi_complete_scsi_task(struct iscsi_task *task,
>   				     uint32_t exp_cmdsn, uint32_t max_cmdsn);

Patch is correct.

Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 0/5] Patch set to fix various bugs in bnx2i
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (16 preceding siblings ...)
  2010-07-27 16:12 ` [PATCH] BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In Eddie Wai
@ 2010-08-10 19:09 ` Eddie Wai
  2010-08-10 19:09 ` [PATCH 2/5] BNX2I: Added support for other TMFs besides ABORT_TASK Eddie Wai
                   ` (91 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-08-10 19:09 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The first 2 patches fix issues related to rfc3720 for nopout and TMF.
The last 2 patches fix issues related to Broadcom specific cleanup
under different situations.

Please review, thanks.
Eddie

Eddie Wai (5):
  BNX2I: Fixed a protocol violation on nopout responses
  BNX2I: Added support for other TMFs besides ABORT_TASK
  BNX2I: Recouple the CFC delete cleanup with cm_abort/close completion
  BNX2I: Added chip cleanup for the remove module path
  BNX2I: Updated version to bnx2i-2.1.3

 drivers/scsi/bnx2i/bnx2i.h       |    2 +-
 drivers/scsi/bnx2i/bnx2i_hwi.c   |   69 +++++++++++++++++++++----------------
 drivers/scsi/bnx2i/bnx2i_init.c  |   61 +++++++++++++++++++++------------
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   15 +++++---
 4 files changed, 87 insertions(+), 60 deletions(-)



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 1/5] BNX2I: Fixed a protocol violation on nopout responses
       [not found] ` <Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
  2010-07-01 22:34   ` [PATCH 2/7 v2] BNX2I: Created an active linklist which holds bnx2i endpoints Eddie Wai
  2010-07-01 22:34   ` [PATCH 4/7 v2] BNX2I: Fine tuned conn destroy and context destroy timeout values Eddie Wai
@ 2010-08-10 19:09   ` Eddie Wai
  2010-08-10 19:09   ` [PATCH 3/5] BNX2I: Recouple the CFC delete cleanup with cm_abort/close completion Eddie Wai
                     ` (8 subsequent siblings)
  11 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-08-10 19:09 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

According to RFC3720, nopout packet sent in response to unsolicited
nopin packet requesting a response must retain the TTT of the requester.

Signed-off-by: Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Reviewed-by: Anil Veerabhadrappa <anilgv-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Acked-by: Benjamin Li <benli-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
---
 drivers/scsi/bnx2i/bnx2i.h       |    2 +-
 drivers/scsi/bnx2i/bnx2i_hwi.c   |    5 ++---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    2 --
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 00c0335..b6345d9 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -753,7 +753,7 @@ extern int bnx2i_send_iscsi_tmf(struct bnx2i_conn *conn,
 extern int bnx2i_send_iscsi_scsicmd(struct bnx2i_conn *conn,
 				    struct bnx2i_cmd *cmnd);
 extern int bnx2i_send_iscsi_nopout(struct bnx2i_conn *conn,
-				   struct iscsi_task *mtask, u32 ttt,
+				   struct iscsi_task *mtask,
 				   char *datap, int data_len, int unsol);
 extern int bnx2i_send_iscsi_logout(struct bnx2i_conn *conn,
 				   struct iscsi_task *mtask);
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 58cd7fc..ece2b62 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -464,7 +464,6 @@ int bnx2i_send_iscsi_scsicmd(struct bnx2i_conn *bnx2i_conn,
  * @conn:		iscsi connection
  * @cmd:		driver command structure which is requesting
  *			a WQE to sent to chip for further processing
- * @ttt:		TTT to be used when building pdu header
  * @datap:		payload buffer pointer
  * @data_len:		payload data length
  * @unsol:		indicated whether nopout pdu is unsolicited pdu or
@@ -473,7 +472,7 @@ int bnx2i_send_iscsi_scsicmd(struct bnx2i_conn *bnx2i_conn,
  * prepare and post a nopout request WQE to CNIC firmware
  */
 int bnx2i_send_iscsi_nopout(struct bnx2i_conn *bnx2i_conn,
-			    struct iscsi_task *task, u32 ttt,
+			    struct iscsi_task *task,
 			    char *datap, int data_len, int unsol)
 {
 	struct bnx2i_endpoint *ep = bnx2i_conn->ep;
@@ -498,7 +497,7 @@ int bnx2i_send_iscsi_nopout(struct bnx2i_conn *bnx2i_conn,
 	nopout_wqe->itt = ((u16)task->itt |
 			   (ISCSI_TASK_TYPE_MPATH <<
 			    ISCSI_TMF_REQUEST_TYPE_SHIFT));
-	nopout_wqe->ttt = ttt;
+	nopout_wqe->ttt = nopout_hdr->ttt;
 	nopout_wqe->flags = 0;
 	if (!unsol)
 		nopout_wqe->flags = ISCSI_NOP_OUT_REQUEST_LOCAL_COMPLETION;
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index c079975..02743d0 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1078,11 +1078,9 @@ static int bnx2i_iscsi_send_generic_request(struct iscsi_task *task)
 		buf = bnx2i_conn->gen_pdu.req_buf;
 		if (data_len)
 			rc = bnx2i_send_iscsi_nopout(bnx2i_conn, task,
-						     RESERVED_ITT,
 						     buf, data_len, 1);
 		else
 			rc = bnx2i_send_iscsi_nopout(bnx2i_conn, task,
-						     RESERVED_ITT,
 						     NULL, 0, 1);
 		break;
 	case ISCSI_OP_LOGOUT:
-- 
1.7.0.5


-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 2/5] BNX2I: Added support for other TMFs besides ABORT_TASK
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (17 preceding siblings ...)
  2010-08-10 19:09 ` [PATCH 0/5] Patch set to fix various bugs in bnx2i Eddie Wai
@ 2010-08-10 19:09 ` Eddie Wai
       [not found]   ` <1281467374-6182-3-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
  2010-08-10 19:09 ` [PATCH 4/5] BNX2I: Added chip cleanup for the remove module path Eddie Wai
                   ` (90 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-08-10 19:09 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Expanded the TMF request routine to support other TMFs such as LUN
RESET, etc.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |   64 +++++++++++++++++++++++-----------------
 1 files changed, 37 insertions(+), 27 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index ece2b62..2667b11 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -393,38 +393,48 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn,
 						bnx2i_conn->ep->qp.sq_prod_qe;
 
 	tmfabort_wqe->op_code = tmfabort_hdr->opcode;
-	tmfabort_wqe->op_attr = 0;
-	tmfabort_wqe->op_attr =
-		ISCSI_TMF_REQUEST_ALWAYS_ONE | ISCSI_TM_FUNC_ABORT_TASK;
+	tmfabort_wqe->op_attr = tmfabort_hdr->flags;
 
 	tmfabort_wqe->itt = (mtask->itt | (ISCSI_TASK_TYPE_MPATH << 14));
 	tmfabort_wqe->reserved2 = 0;
 	tmfabort_wqe->cmd_sn = be32_to_cpu(tmfabort_hdr->cmdsn);
 
-	ctask = iscsi_itt_to_task(conn, tmfabort_hdr->rtt);
-	if (!ctask || !ctask->sc)
-		/*
-		 * the iscsi layer must have completed the cmd while this
-		 * was starting up.
-		 *
-		 * Note: In the case of a SCSI cmd timeout, the task's sc
-		 *       is still active; hence ctask->sc != 0
-		 *       In this case, the task must be aborted
-		 */
-		return 0;
-
-	ref_sc = ctask->sc;
-
-	/* Retrieve LUN directly from the ref_sc */
-	int_to_scsilun(ref_sc->device->lun, (struct scsi_lun *) scsi_lun);
-	tmfabort_wqe->lun[0] = be32_to_cpu(scsi_lun[0]);
-	tmfabort_wqe->lun[1] = be32_to_cpu(scsi_lun[1]);
-
-	if (ref_sc->sc_data_direction == DMA_TO_DEVICE)
-		dword = (ISCSI_TASK_TYPE_WRITE << ISCSI_CMD_REQUEST_TYPE_SHIFT);
-	else
-		dword = (ISCSI_TASK_TYPE_READ << ISCSI_CMD_REQUEST_TYPE_SHIFT);
-	tmfabort_wqe->ref_itt = (dword | (tmfabort_hdr->rtt & ISCSI_ITT_MASK));
+	switch (tmfabort_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) {
+	case ISCSI_TM_FUNC_ABORT_TASK:
+	case ISCSI_TM_FUNC_TASK_REASSIGN:
+		ctask = iscsi_itt_to_task(conn, tmfabort_hdr->rtt);
+		if (!ctask || !ctask->sc)
+			/*
+			 * the iscsi layer must have completed the cmd while
+			 * was starting up.
+			 *
+			 * Note: In the case of a SCSI cmd timeout, the task's
+			 *       sc is still active; hence ctask->sc != 0
+			 *       In this case, the task must be aborted
+			 */
+			return 0;
+
+		ref_sc = ctask->sc;
+
+		/* Retrieve LUN directly from the ref_sc */
+		int_to_scsilun(ref_sc->device->lun,
+			       (struct scsi_lun *) scsi_lun);
+		tmfabort_wqe->lun[0] = be32_to_cpu(scsi_lun[0]);
+		tmfabort_wqe->lun[1] = be32_to_cpu(scsi_lun[1]);
+
+		if (ref_sc->sc_data_direction == DMA_TO_DEVICE)
+			dword = (ISCSI_TASK_TYPE_WRITE <<
+				 ISCSI_CMD_REQUEST_TYPE_SHIFT);
+		else
+			dword = (ISCSI_TASK_TYPE_READ <<
+				 ISCSI_CMD_REQUEST_TYPE_SHIFT);
+		tmfabort_wqe->ref_itt = (dword |
+					(tmfabort_hdr->rtt & ISCSI_ITT_MASK));
+		break;
+	default:
+		memcpy(tmfabort_wqe->lun, tmfabort_hdr->lun, 8);
+		tmfabort_wqe->ref_itt = RESERVED_ITT;
+	}
 	tmfabort_wqe->ref_cmd_sn = be32_to_cpu(tmfabort_hdr->refcmdsn);
 
 	tmfabort_wqe->bd_list_addr_lo = (u32) bnx2i_conn->hba->mp_bd_dma;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 3/5] BNX2I: Recouple the CFC delete cleanup with cm_abort/close completion
       [not found] ` <Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
                     ` (2 preceding siblings ...)
  2010-08-10 19:09   ` [PATCH 1/5] BNX2I: Fixed a protocol violation on nopout responses Eddie Wai
@ 2010-08-10 19:09   ` Eddie Wai
  2010-11-10 23:04   ` [PATCH 08/16] BNX2I: Added mutex lock protection to conn_get_param Eddie Wai
                     ` (7 subsequent siblings)
  11 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-08-10 19:09 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Specific to the Broadcom 10g chipset, the CFC delete operation must be
coupled with the cm_abort/close with does the SRC delete/terminate offload
operation prior.

Signed-off-by: Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Reviewed-by: Michael Chan <mchan-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Acked-by: Benjamin Li <benli-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 02743d0..40f3758 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1996,11 +1996,13 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 	else
 		close_ret = cnic->cm_abort(bnx2i_ep->cm_sk);
 
+	/* No longer allow CFC delete if cm_close/abort fails the request */
 	if (close_ret)
-		bnx2i_ep->state = EP_STATE_DISCONN_COMPL;
-
-	/* wait for option-2 conn teardown */
-	wait_event_interruptible(bnx2i_ep->ofld_wait,
+		printk(KERN_ALERT "bnx2i: %s close/abort(%d) returned %d\n",
+			bnx2i_ep->hba->netdev->name, close, close_ret);
+	else
+		/* wait for option-2 conn teardown */
+		wait_event_interruptible(bnx2i_ep->ofld_wait,
 				 bnx2i_ep->state != EP_STATE_DISCONN_START);
 
 	if (signal_pending(current))
-- 
1.7.0.5


-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 4/5] BNX2I: Added chip cleanup for the remove module path
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (18 preceding siblings ...)
  2010-08-10 19:09 ` [PATCH 2/5] BNX2I: Added support for other TMFs besides ABORT_TASK Eddie Wai
@ 2010-08-10 19:09 ` Eddie Wai
  2010-08-11 19:09   ` Mike Christie
  2010-08-10 19:09 ` [PATCH 5/5] BNX2I: Updated version to bnx2i-2.1.3 Eddie Wai
                   ` (89 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-08-10 19:09 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

In the case when an ep_connect request is interrupted due to route
request stall, if the iSCSI daemon is terminated by the user, the chip
will be left in a state which will not get cleaned up upon module
removal.  Upon module reload, when the same context id is used for a
new connection, chip panic would occur.

This patch adds chip cleanup in the module removal path.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Benjamin Li <benli@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_init.c  |   53 +++++++++++++++++++++++--------------
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    3 ++
 2 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index a796f56..99b861b 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -167,6 +167,37 @@ void bnx2i_start(void *handle)
 
 
 /**
+ * bnx2i_chip_cleanup - local routine to handle chip cleanup
+ *
+ * Driver checks if adapter still has any active connections before
+ *	executing the cleanup process
+ */
+static void bnx2i_chip_cleanup(struct bnx2i_hba *hba)
+{
+	struct bnx2i_endpoint *bnx2i_ep;
+	struct list_head *pos, *tmp;
+
+	if (hba->ofld_conns_active) {
+		/* Stage to force the disconnection
+		 * This is the case where the daemon is either slow or
+		 * not present
+		 */
+		printk(KERN_ALERT "bnx2i: (%s) chip cleanup for %d active "
+			"connections\n", hba->netdev->name,
+			hba->ofld_conns_active);
+		mutex_lock(&hba->net_dev_lock);
+		list_for_each_safe(pos, tmp, &hba->ep_active_list) {
+			bnx2i_ep = list_entry(pos, struct bnx2i_endpoint, link);
+			/* Clean up the chip only */
+			bnx2i_hw_ep_disconnect(bnx2i_ep);
+			bnx2i_ep->cm_sk = NULL;
+		}
+		mutex_unlock(&hba->net_dev_lock);
+	}
+}
+
+
+/**
  * bnx2i_stop - cnic callback to shutdown adapter instance
  * @handle:	transparent handle pointing to adapter structure
  *
@@ -176,8 +207,6 @@ void bnx2i_start(void *handle)
 void bnx2i_stop(void *handle)
 {
 	struct bnx2i_hba *hba = handle;
-	struct list_head *pos, *tmp;
-	struct bnx2i_endpoint *bnx2i_ep;
 	int conns_active;
 
 	/* check if cleanup happened in GOING_DOWN context */
@@ -198,24 +227,7 @@ void bnx2i_stop(void *handle)
 		if (hba->ofld_conns_active == conns_active)
 			break;
 	}
-	if (hba->ofld_conns_active) {
-		/* Stage to force the disconnection
-		 * This is the case where the daemon is either slow or
-		 * not present
-		 */
-		printk(KERN_ALERT "bnx2i: Wait timeout, force all eps "
-			"to disconnect (%d)\n", hba->ofld_conns_active);
-		mutex_lock(&hba->net_dev_lock);
-		list_for_each_safe(pos, tmp, &hba->ep_active_list) {
-			bnx2i_ep = list_entry(pos, struct bnx2i_endpoint, link);
-			/* Clean up the chip only */
-			bnx2i_hw_ep_disconnect(bnx2i_ep);
-		}
-		mutex_unlock(&hba->net_dev_lock);
-		if (hba->ofld_conns_active)
-			printk(KERN_ERR "bnx2i: EP disconnect timeout (%d)!\n",
-				hba->ofld_conns_active);
-	}
+	bnx2i_chip_cleanup(hba);
 
 	/* This flag should be cleared last so that ep_disconnect() gracefully
 	 * cleans up connection context
@@ -457,6 +469,7 @@ static void __exit bnx2i_mod_exit(void)
 		adapter_count--;
 
 		if (test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic)) {
+			bnx2i_chip_cleanup(hba);
 			hba->cnic->unregister_device(hba->cnic, CNIC_ULP_ISCSI);
 			clear_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic);
 		}
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 40f3758..abe73b9 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1953,6 +1953,9 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 	if (!cnic)
 		return 0;
 
+	if (bnx2i_ep->state == EP_STATE_IDLE)
+		return 0;
+
 	if (!bnx2i_ep_tcp_conn_active(bnx2i_ep))
 		goto destroy_conn;
 
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 5/5] BNX2I: Updated version to bnx2i-2.1.3
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (19 preceding siblings ...)
  2010-08-10 19:09 ` [PATCH 4/5] BNX2I: Added chip cleanup for the remove module path Eddie Wai
@ 2010-08-10 19:09 ` Eddie Wai
  2010-08-12 23:44 ` [PATCH 0/5 v2] Patch set to fix various bugs in bnx2i Eddie Wai
                   ` (88 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-08-10 19:09 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Also updated maintainer info.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_init.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 99b861b..b551592 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -17,15 +17,17 @@ static struct list_head adapter_list = LIST_HEAD_INIT(adapter_list);
 static u32 adapter_count;
 
 #define DRV_MODULE_NAME		"bnx2i"
-#define DRV_MODULE_VERSION	"2.1.2"
-#define DRV_MODULE_RELDATE	"Jun 28, 2010"
+#define DRV_MODULE_VERSION	"2.1.3"
+#define DRV_MODULE_RELDATE	"Aug 10, 2010"
 
 static char version[] __devinitdata =
 		"Broadcom NetXtreme II iSCSI Driver " DRV_MODULE_NAME \
 		" v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
 
 
-MODULE_AUTHOR("Anil Veerabhadrappa <anilgv@broadcom.com>");
+MODULE_AUTHOR("Anil Veerabhadrappa <anilgv@broadcom.com> and "
+	      "Eddie Wai <eddie.wai@broadcom.com>");
+
 MODULE_DESCRIPTION("Broadcom NetXtreme II BCM5706/5708/5709/57710/57711"
 		   " iSCSI Driver");
 MODULE_LICENSE("GPL");
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH 2/5] BNX2I: Added support for other TMFs besides ABORT_TASK
       [not found]   ` <1281467374-6182-3-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
@ 2010-08-11 19:07     ` Mike Christie
  2010-08-11 19:26       ` Eddie Wai
  0 siblings, 1 reply; 189+ messages in thread
From: Mike Christie @ 2010-08-11 19:07 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 08/10/2010 02:09 PM, Eddie Wai wrote:
> +		/* Retrieve LUN directly from the ref_sc */
> +		int_to_scsilun(ref_sc->device->lun,
> +			       (struct scsi_lun *) scsi_lun);
> +		tmfabort_wqe->lun[0] = be32_to_cpu(scsi_lun[0]);
> +		tmfabort_wqe->lun[1] = be32_to_cpu(scsi_lun[1]);
> +



> +	default:
> +		memcpy(tmfabort_wqe->lun, tmfabort_hdr->lun, 8);

Why do you copy the lun differently?

-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 4/5] BNX2I: Added chip cleanup for the remove module path
  2010-08-10 19:09 ` [PATCH 4/5] BNX2I: Added chip cleanup for the remove module path Eddie Wai
@ 2010-08-11 19:09   ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2010-08-11 19:09 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 08/10/2010 02:09 PM, Eddie Wai wrote:
> In the case when an ep_connect request is interrupted due to route
> request stall, if the iSCSI daemon is terminated by the user, the chip
> will be left in a state which will not get cleaned up upon module
> removal.  Upon module reload, when the same context id is used for a
> new connection, chip panic would occur.
>
> This patch adds chip cleanup in the module removal path.
>
> Signed-off-by: Eddie Wai<eddie.wai@broadcom.com>
> Acked-by: Benjamin Li<benli@broadcom.com>
> ---
>   drivers/scsi/bnx2i/bnx2i_init.c  |   53 +++++++++++++++++++++++--------------
>   drivers/scsi/bnx2i/bnx2i_iscsi.c |    3 ++
>   2 files changed, 36 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
> index a796f56..99b861b 100644
> --- a/drivers/scsi/bnx2i/bnx2i_init.c
> +++ b/drivers/scsi/bnx2i/bnx2i_init.c
> @@ -167,6 +167,37 @@ void bnx2i_start(void *handle)
>
>
>   /**
> + * bnx2i_chip_cleanup - local routine to handle chip cleanup

For docbook comments you need the argument info
@hba: driver's hba struct

^ permalink raw reply	[flat|nested] 189+ messages in thread

* RE: [PATCH 2/5] BNX2I: Added support for other TMFs besides ABORT_TASK
  2010-08-11 19:07     ` Mike Christie
@ 2010-08-11 19:26       ` Eddie Wai
  2010-08-11 19:38         ` Mike Christie
  0 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-08-11 19:26 UTC (permalink / raw)
  To: 'Mike Christie'
  Cc: 'James Bottomley', 'open-iscsi',
	'linux-scsi',
	Michael Chan, Anil Veerabhadrappa, Benjamin Li

Hello Mike,

Thanks for reviewing.  Since both scsi_device->lun and the local scsi_lun array variable are defined as u32 so we're using a direct u32 manipulation.  It's also consistent to the old code.  

We chose to use memcpy for the default case as both tmfabort_wqe->lun and tmfabort_hdr->lun are defined to be u8.  This u8 copying is also consistent to the other code paths in the existing bnx2i like nopout_wqe, etc.

Thanks,
Eddie

-----Original Message-----
From: Mike Christie [mailto:michaelc@cs.wisc.edu] 
Sent: Wednesday, August 11, 2010 12:07 PM
To: Eddie Wai
Cc: James Bottomley; open-iscsi; linux-scsi; Michael Chan; Anil Veerabhadrappa; Benjamin Li
Subject: Re: [PATCH 2/5] BNX2I: Added support for other TMFs besides ABORT_TASK

On 08/10/2010 02:09 PM, Eddie Wai wrote:
> +		/* Retrieve LUN directly from the ref_sc */
> +		int_to_scsilun(ref_sc->device->lun,
> +			       (struct scsi_lun *) scsi_lun);
> +		tmfabort_wqe->lun[0] = be32_to_cpu(scsi_lun[0]);
> +		tmfabort_wqe->lun[1] = be32_to_cpu(scsi_lun[1]);
> +



> +	default:
> +		memcpy(tmfabort_wqe->lun, tmfabort_hdr->lun, 8);

Why do you copy the lun differently?



^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 2/5] BNX2I: Added support for other TMFs besides ABORT_TASK
  2010-08-11 19:26       ` Eddie Wai
@ 2010-08-11 19:38         ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2010-08-11 19:38 UTC (permalink / raw)
  To: Eddie Wai
  Cc: 'James Bottomley', 'open-iscsi',
	'linux-scsi',
	Michael Chan, Anil Veerabhadrappa, Benjamin Li

On 08/11/2010 02:26 PM, Eddie Wai wrote:
> Hello Mike,
>
> Thanks for reviewing.  Since both scsi_device->lun and the local scsi_lun array variable are defined as u32 so we're using a direct u32 manipulation.  It's also consistent to the old code.
>
> We chose to use memcpy for the default case as both tmfabort_wqe->lun and tmfabort_hdr->lun are defined to be u8.  This u8 copying is also consistent to the other code paths in the existing bnx2i like nopout_wqe, etc.
>

You can do the same for the abort case. For aborts the tmfabort_hdr->lun 
has already been converted from a int to a scsi_lun for you so you 
should be able to copy it too.


> Thanks,
> Eddie
>
> -----Original Message-----
> From: Mike Christie [mailto:michaelc@cs.wisc.edu]
> Sent: Wednesday, August 11, 2010 12:07 PM
> To: Eddie Wai
> Cc: James Bottomley; open-iscsi; linux-scsi; Michael Chan; Anil Veerabhadrappa; Benjamin Li
> Subject: Re: [PATCH 2/5] BNX2I: Added support for other TMFs besides ABORT_TASK
>
> On 08/10/2010 02:09 PM, Eddie Wai wrote:
>> +		/* Retrieve LUN directly from the ref_sc */
>> +		int_to_scsilun(ref_sc->device->lun,
>> +			       (struct scsi_lun *) scsi_lun);
>> +		tmfabort_wqe->lun[0] = be32_to_cpu(scsi_lun[0]);
>> +		tmfabort_wqe->lun[1] = be32_to_cpu(scsi_lun[1]);
>> +
>
>
>
>> +	default:
>> +		memcpy(tmfabort_wqe->lun, tmfabort_hdr->lun, 8);
>
> Why do you copy the lun differently?
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 0/5 v2] Patch set to fix various bugs in bnx2i
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (20 preceding siblings ...)
  2010-08-10 19:09 ` [PATCH 5/5] BNX2I: Updated version to bnx2i-2.1.3 Eddie Wai
@ 2010-08-12 23:44 ` Eddie Wai
  2010-08-12 23:44 ` [PATCH 1/5 v2] BNX2I: Fixed a protocol violation on nopout responses Eddie Wai
                   ` (87 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-08-12 23:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The first 2 patches fix issues related to rfc3720 for nopout and TMF.
The last 2 patches fix issues related to Broadcom specific cleanup
under different situations.

Please review, thanks.
Eddie

Eddie Wai (5):
  BNX2I: Fixed a protocol violation on nopout responses
  BNX2I: Added support for other TMFs besides ABORT_TASK
  BNX2I: Recouple the CFC delete cleanup with cm_abort/close completion
  BNX2I: Added chip cleanup for the remove module path
  BNX2I: Updated version to bnx2i-2.1.3

 drivers/scsi/bnx2i/bnx2i.h       |    2 +-
 drivers/scsi/bnx2i/bnx2i_hwi.c   |   64 +++++++++++++++++++------------------
 drivers/scsi/bnx2i/bnx2i_init.c  |   62 +++++++++++++++++++++++-------------
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   15 +++++---
 4 files changed, 82 insertions(+), 61 deletions(-)



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 1/5 v2] BNX2I: Fixed a protocol violation on nopout responses
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (21 preceding siblings ...)
  2010-08-12 23:44 ` [PATCH 0/5 v2] Patch set to fix various bugs in bnx2i Eddie Wai
@ 2010-08-12 23:44 ` Eddie Wai
  2010-08-12 23:44 ` [PATCH 2/5 v2] BNX2I: Added support for other TMFs besides ABORT_TASK Eddie Wai
                   ` (86 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-08-12 23:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

According to RFC3720, nopout packet sent in response to unsolicited
nopin packet requesting a response must retain the TTT of the requester.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |    2 +-
 drivers/scsi/bnx2i/bnx2i_hwi.c   |    5 ++---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    2 --
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 00c0335..b6345d9 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -753,7 +753,7 @@ extern int bnx2i_send_iscsi_tmf(struct bnx2i_conn *conn,
 extern int bnx2i_send_iscsi_scsicmd(struct bnx2i_conn *conn,
 				    struct bnx2i_cmd *cmnd);
 extern int bnx2i_send_iscsi_nopout(struct bnx2i_conn *conn,
-				   struct iscsi_task *mtask, u32 ttt,
+				   struct iscsi_task *mtask,
 				   char *datap, int data_len, int unsol);
 extern int bnx2i_send_iscsi_logout(struct bnx2i_conn *conn,
 				   struct iscsi_task *mtask);
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 58cd7fc..ece2b62 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -464,7 +464,6 @@ int bnx2i_send_iscsi_scsicmd(struct bnx2i_conn *bnx2i_conn,
  * @conn:		iscsi connection
  * @cmd:		driver command structure which is requesting
  *			a WQE to sent to chip for further processing
- * @ttt:		TTT to be used when building pdu header
  * @datap:		payload buffer pointer
  * @data_len:		payload data length
  * @unsol:		indicated whether nopout pdu is unsolicited pdu or
@@ -473,7 +472,7 @@ int bnx2i_send_iscsi_scsicmd(struct bnx2i_conn *bnx2i_conn,
  * prepare and post a nopout request WQE to CNIC firmware
  */
 int bnx2i_send_iscsi_nopout(struct bnx2i_conn *bnx2i_conn,
-			    struct iscsi_task *task, u32 ttt,
+			    struct iscsi_task *task,
 			    char *datap, int data_len, int unsol)
 {
 	struct bnx2i_endpoint *ep = bnx2i_conn->ep;
@@ -498,7 +497,7 @@ int bnx2i_send_iscsi_nopout(struct bnx2i_conn *bnx2i_conn,
 	nopout_wqe->itt = ((u16)task->itt |
 			   (ISCSI_TASK_TYPE_MPATH <<
 			    ISCSI_TMF_REQUEST_TYPE_SHIFT));
-	nopout_wqe->ttt = ttt;
+	nopout_wqe->ttt = nopout_hdr->ttt;
 	nopout_wqe->flags = 0;
 	if (!unsol)
 		nopout_wqe->flags = ISCSI_NOP_OUT_REQUEST_LOCAL_COMPLETION;
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index c079975..02743d0 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1078,11 +1078,9 @@ static int bnx2i_iscsi_send_generic_request(struct iscsi_task *task)
 		buf = bnx2i_conn->gen_pdu.req_buf;
 		if (data_len)
 			rc = bnx2i_send_iscsi_nopout(bnx2i_conn, task,
-						     RESERVED_ITT,
 						     buf, data_len, 1);
 		else
 			rc = bnx2i_send_iscsi_nopout(bnx2i_conn, task,
-						     RESERVED_ITT,
 						     NULL, 0, 1);
 		break;
 	case ISCSI_OP_LOGOUT:
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 2/5 v2] BNX2I: Added support for other TMFs besides ABORT_TASK
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (22 preceding siblings ...)
  2010-08-12 23:44 ` [PATCH 1/5 v2] BNX2I: Fixed a protocol violation on nopout responses Eddie Wai
@ 2010-08-12 23:44 ` Eddie Wai
  2010-08-13  1:38   ` Mike Christie
  2010-08-12 23:44 ` [PATCH 3/5 v2] BNX2I: Recouple the CFC delete cleanup with cm_abort/close completion Eddie Wai
                   ` (85 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-08-12 23:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Expanded the TMF request routine to support other TMFs such as LUN
RESET, etc.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |   59 +++++++++++++++++++++-------------------
 1 files changed, 31 insertions(+), 28 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index ece2b62..7db18e8 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -385,7 +385,6 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn,
 	struct bnx2i_cmd *bnx2i_cmd;
 	struct bnx2i_tmf_request *tmfabort_wqe;
 	u32 dword;
-	u32 scsi_lun[2];
 
 	bnx2i_cmd = (struct bnx2i_cmd *)mtask->dd_data;
 	tmfabort_hdr = (struct iscsi_tm *)mtask->hdr;
@@ -393,38 +392,42 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn,
 						bnx2i_conn->ep->qp.sq_prod_qe;
 
 	tmfabort_wqe->op_code = tmfabort_hdr->opcode;
-	tmfabort_wqe->op_attr = 0;
-	tmfabort_wqe->op_attr =
-		ISCSI_TMF_REQUEST_ALWAYS_ONE | ISCSI_TM_FUNC_ABORT_TASK;
+	tmfabort_wqe->op_attr = tmfabort_hdr->flags;
 
 	tmfabort_wqe->itt = (mtask->itt | (ISCSI_TASK_TYPE_MPATH << 14));
 	tmfabort_wqe->reserved2 = 0;
 	tmfabort_wqe->cmd_sn = be32_to_cpu(tmfabort_hdr->cmdsn);
 
-	ctask = iscsi_itt_to_task(conn, tmfabort_hdr->rtt);
-	if (!ctask || !ctask->sc)
-		/*
-		 * the iscsi layer must have completed the cmd while this
-		 * was starting up.
-		 *
-		 * Note: In the case of a SCSI cmd timeout, the task's sc
-		 *       is still active; hence ctask->sc != 0
-		 *       In this case, the task must be aborted
-		 */
-		return 0;
-
-	ref_sc = ctask->sc;
-
-	/* Retrieve LUN directly from the ref_sc */
-	int_to_scsilun(ref_sc->device->lun, (struct scsi_lun *) scsi_lun);
-	tmfabort_wqe->lun[0] = be32_to_cpu(scsi_lun[0]);
-	tmfabort_wqe->lun[1] = be32_to_cpu(scsi_lun[1]);
-
-	if (ref_sc->sc_data_direction == DMA_TO_DEVICE)
-		dword = (ISCSI_TASK_TYPE_WRITE << ISCSI_CMD_REQUEST_TYPE_SHIFT);
-	else
-		dword = (ISCSI_TASK_TYPE_READ << ISCSI_CMD_REQUEST_TYPE_SHIFT);
-	tmfabort_wqe->ref_itt = (dword | (tmfabort_hdr->rtt & ISCSI_ITT_MASK));
+	switch (tmfabort_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) {
+	case ISCSI_TM_FUNC_ABORT_TASK:
+	case ISCSI_TM_FUNC_TASK_REASSIGN:
+		memcpy(tmfabort_wqe->lun, tmfabort_hdr->lun, 8);
+		ctask = iscsi_itt_to_task(conn, tmfabort_hdr->rtt);
+		if (!ctask || !ctask->sc)
+			/*
+			 * the iscsi layer must have completed the cmd while
+			 * was starting up.
+			 *
+			 * Note: In the case of a SCSI cmd timeout, the task's
+			 *       sc is still active; hence ctask->sc != 0
+			 *       In this case, the task must be aborted
+			 */
+			return 0;
+
+		ref_sc = ctask->sc;
+		if (ref_sc->sc_data_direction == DMA_TO_DEVICE)
+			dword = (ISCSI_TASK_TYPE_WRITE <<
+				 ISCSI_CMD_REQUEST_TYPE_SHIFT);
+		else
+			dword = (ISCSI_TASK_TYPE_READ <<
+				 ISCSI_CMD_REQUEST_TYPE_SHIFT);
+		tmfabort_wqe->ref_itt = (dword |
+					(tmfabort_hdr->rtt & ISCSI_ITT_MASK));
+		break;
+	default:
+		memcpy(tmfabort_wqe->lun, tmfabort_hdr->lun, 8);
+		tmfabort_wqe->ref_itt = RESERVED_ITT;
+	}
 	tmfabort_wqe->ref_cmd_sn = be32_to_cpu(tmfabort_hdr->refcmdsn);
 
 	tmfabort_wqe->bd_list_addr_lo = (u32) bnx2i_conn->hba->mp_bd_dma;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 3/5 v2] BNX2I: Recouple the CFC delete cleanup with cm_abort/close completion
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (23 preceding siblings ...)
  2010-08-12 23:44 ` [PATCH 2/5 v2] BNX2I: Added support for other TMFs besides ABORT_TASK Eddie Wai
@ 2010-08-12 23:44 ` Eddie Wai
  2010-08-12 23:44 ` [PATCH 4/5 v2] BNX2I: Added chip cleanup for the remove module path Eddie Wai
                   ` (84 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-08-12 23:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Specific to the Broadcom 10g chipset, the CFC delete operation must be
coupled with the cm_abort/close with does the SRC delete/terminate offload
operation prior.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Acked-by: Benjamin Li <benli@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 02743d0..40f3758 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1996,11 +1996,13 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 	else
 		close_ret = cnic->cm_abort(bnx2i_ep->cm_sk);
 
+	/* No longer allow CFC delete if cm_close/abort fails the request */
 	if (close_ret)
-		bnx2i_ep->state = EP_STATE_DISCONN_COMPL;
-
-	/* wait for option-2 conn teardown */
-	wait_event_interruptible(bnx2i_ep->ofld_wait,
+		printk(KERN_ALERT "bnx2i: %s close/abort(%d) returned %d\n",
+			bnx2i_ep->hba->netdev->name, close, close_ret);
+	else
+		/* wait for option-2 conn teardown */
+		wait_event_interruptible(bnx2i_ep->ofld_wait,
 				 bnx2i_ep->state != EP_STATE_DISCONN_START);
 
 	if (signal_pending(current))
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 4/5 v2] BNX2I: Added chip cleanup for the remove module path
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (24 preceding siblings ...)
  2010-08-12 23:44 ` [PATCH 3/5 v2] BNX2I: Recouple the CFC delete cleanup with cm_abort/close completion Eddie Wai
@ 2010-08-12 23:44 ` Eddie Wai
  2010-08-12 23:44 ` [PATCH 5/5 v2] BNX2I: Updated version to bnx2i-2.1.3 Eddie Wai
                   ` (83 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-08-12 23:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

In the case when an ep_connect request is interrupted due to route
request stall, if the iSCSI daemon is terminated by the user, the chip
will be left in a state which will not get cleaned up upon module
removal.  Upon module reload, when the same context id is used for a
new connection, chip panic would occur.

This patch adds chip cleanup in the module removal path.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Benjamin Li <benli@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_init.c  |   54 ++++++++++++++++++++++++--------------
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    3 ++
 2 files changed, 37 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index a796f56..1294936 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -167,6 +167,38 @@ void bnx2i_start(void *handle)
 
 
 /**
+ * bnx2i_chip_cleanup - local routine to handle chip cleanup
+ * @hba:	Adapter instance to register
+ *
+ * Driver checks if adapter still has any active connections before
+ *	executing the cleanup process
+ */
+static void bnx2i_chip_cleanup(struct bnx2i_hba *hba)
+{
+	struct bnx2i_endpoint *bnx2i_ep;
+	struct list_head *pos, *tmp;
+
+	if (hba->ofld_conns_active) {
+		/* Stage to force the disconnection
+		 * This is the case where the daemon is either slow or
+		 * not present
+		 */
+		printk(KERN_ALERT "bnx2i: (%s) chip cleanup for %d active "
+			"connections\n", hba->netdev->name,
+			hba->ofld_conns_active);
+		mutex_lock(&hba->net_dev_lock);
+		list_for_each_safe(pos, tmp, &hba->ep_active_list) {
+			bnx2i_ep = list_entry(pos, struct bnx2i_endpoint, link);
+			/* Clean up the chip only */
+			bnx2i_hw_ep_disconnect(bnx2i_ep);
+			bnx2i_ep->cm_sk = NULL;
+		}
+		mutex_unlock(&hba->net_dev_lock);
+	}
+}
+
+
+/**
  * bnx2i_stop - cnic callback to shutdown adapter instance
  * @handle:	transparent handle pointing to adapter structure
  *
@@ -176,8 +208,6 @@ void bnx2i_start(void *handle)
 void bnx2i_stop(void *handle)
 {
 	struct bnx2i_hba *hba = handle;
-	struct list_head *pos, *tmp;
-	struct bnx2i_endpoint *bnx2i_ep;
 	int conns_active;
 
 	/* check if cleanup happened in GOING_DOWN context */
@@ -198,24 +228,7 @@ void bnx2i_stop(void *handle)
 		if (hba->ofld_conns_active == conns_active)
 			break;
 	}
-	if (hba->ofld_conns_active) {
-		/* Stage to force the disconnection
-		 * This is the case where the daemon is either slow or
-		 * not present
-		 */
-		printk(KERN_ALERT "bnx2i: Wait timeout, force all eps "
-			"to disconnect (%d)\n", hba->ofld_conns_active);
-		mutex_lock(&hba->net_dev_lock);
-		list_for_each_safe(pos, tmp, &hba->ep_active_list) {
-			bnx2i_ep = list_entry(pos, struct bnx2i_endpoint, link);
-			/* Clean up the chip only */
-			bnx2i_hw_ep_disconnect(bnx2i_ep);
-		}
-		mutex_unlock(&hba->net_dev_lock);
-		if (hba->ofld_conns_active)
-			printk(KERN_ERR "bnx2i: EP disconnect timeout (%d)!\n",
-				hba->ofld_conns_active);
-	}
+	bnx2i_chip_cleanup(hba);
 
 	/* This flag should be cleared last so that ep_disconnect() gracefully
 	 * cleans up connection context
@@ -457,6 +470,7 @@ static void __exit bnx2i_mod_exit(void)
 		adapter_count--;
 
 		if (test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic)) {
+			bnx2i_chip_cleanup(hba);
 			hba->cnic->unregister_device(hba->cnic, CNIC_ULP_ISCSI);
 			clear_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic);
 		}
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 40f3758..abe73b9 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1953,6 +1953,9 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 	if (!cnic)
 		return 0;
 
+	if (bnx2i_ep->state == EP_STATE_IDLE)
+		return 0;
+
 	if (!bnx2i_ep_tcp_conn_active(bnx2i_ep))
 		goto destroy_conn;
 
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 5/5 v2] BNX2I: Updated version to bnx2i-2.1.3
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (25 preceding siblings ...)
  2010-08-12 23:44 ` [PATCH 4/5 v2] BNX2I: Added chip cleanup for the remove module path Eddie Wai
@ 2010-08-12 23:44 ` Eddie Wai
  2010-08-13 16:33 ` [PATCH 2/5 v3] BNX2I: Added support for other TMFs besides ABORT_TASK Eddie Wai
                   ` (82 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-08-12 23:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Also updated maintainer info.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_init.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 1294936..50c2aa3 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -17,15 +17,17 @@ static struct list_head adapter_list = LIST_HEAD_INIT(adapter_list);
 static u32 adapter_count;
 
 #define DRV_MODULE_NAME		"bnx2i"
-#define DRV_MODULE_VERSION	"2.1.2"
-#define DRV_MODULE_RELDATE	"Jun 28, 2010"
+#define DRV_MODULE_VERSION	"2.1.3"
+#define DRV_MODULE_RELDATE	"Aug 10, 2010"
 
 static char version[] __devinitdata =
 		"Broadcom NetXtreme II iSCSI Driver " DRV_MODULE_NAME \
 		" v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
 
 
-MODULE_AUTHOR("Anil Veerabhadrappa <anilgv@broadcom.com>");
+MODULE_AUTHOR("Anil Veerabhadrappa <anilgv@broadcom.com> and "
+	      "Eddie Wai <eddie.wai@broadcom.com>");
+
 MODULE_DESCRIPTION("Broadcom NetXtreme II BCM5706/5708/5709/57710/57711"
 		   " iSCSI Driver");
 MODULE_LICENSE("GPL");
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH 2/5 v2] BNX2I: Added support for other TMFs besides ABORT_TASK
  2010-08-12 23:44 ` [PATCH 2/5 v2] BNX2I: Added support for other TMFs besides ABORT_TASK Eddie Wai
@ 2010-08-13  1:38   ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2010-08-13  1:38 UTC (permalink / raw)
  To: open-iscsi
  Cc: Eddie Wai, James Bottomley, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 08/12/2010 06:44 PM, Eddie Wai wrote:
> -	tmfabort_wqe->ref_itt = (dword | (tmfabort_hdr->rtt&  ISCSI_ITT_MASK));
> +	switch (tmfabort_hdr->flags&  ISCSI_FLAG_TM_FUNC_MASK) {
> +	case ISCSI_TM_FUNC_ABORT_TASK:
> +	case ISCSI_TM_FUNC_TASK_REASSIGN:
> +		memcpy(tmfabort_wqe->lun, tmfabort_hdr->lun, 8);

....

> +	default:
> +		memcpy(tmfabort_wqe->lun, tmfabort_hdr->lun, 8);
> +		tmfabort_wqe->ref_itt = RESERVED_ITT;
> +	}
>   	tmfabort_wqe->ref_cmd_sn = be32_to_cpu(tmfabort_hdr->refcmdsn);

The 2 memcpys are exactly the same so just do it once right here:

	memcpy(tmfabort_wqe->lun, tmfabort_hdr->lun, 8);

>
>   	tmfabort_wqe->bd_list_addr_lo = (u32) bnx2i_conn->hba->mp_bd_dma;


^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 2/5 v3] BNX2I: Added support for other TMFs besides ABORT_TASK
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (26 preceding siblings ...)
  2010-08-12 23:44 ` [PATCH 5/5 v2] BNX2I: Updated version to bnx2i-2.1.3 Eddie Wai
@ 2010-08-13 16:33 ` Eddie Wai
  2010-08-13 16:42   ` Mike Christie
  2010-11-10 23:04 ` [PATCH 00/16] BNX2I: Patch set to fix various bug fixes Eddie Wai
                   ` (81 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-08-13 16:33 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Expanded the TMF request routine to support other TMFs such as LUN
RESET, etc.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |   58 ++++++++++++++++++++-------------------
 1 files changed, 30 insertions(+), 28 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index ece2b62..9296f63 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -385,7 +385,6 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn,
 	struct bnx2i_cmd *bnx2i_cmd;
 	struct bnx2i_tmf_request *tmfabort_wqe;
 	u32 dword;
-	u32 scsi_lun[2];
 
 	bnx2i_cmd = (struct bnx2i_cmd *)mtask->dd_data;
 	tmfabort_hdr = (struct iscsi_tm *)mtask->hdr;
@@ -393,38 +392,41 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn,
 						bnx2i_conn->ep->qp.sq_prod_qe;
 
 	tmfabort_wqe->op_code = tmfabort_hdr->opcode;
-	tmfabort_wqe->op_attr = 0;
-	tmfabort_wqe->op_attr =
-		ISCSI_TMF_REQUEST_ALWAYS_ONE | ISCSI_TM_FUNC_ABORT_TASK;
+	tmfabort_wqe->op_attr = tmfabort_hdr->flags;
 
 	tmfabort_wqe->itt = (mtask->itt | (ISCSI_TASK_TYPE_MPATH << 14));
 	tmfabort_wqe->reserved2 = 0;
 	tmfabort_wqe->cmd_sn = be32_to_cpu(tmfabort_hdr->cmdsn);
 
-	ctask = iscsi_itt_to_task(conn, tmfabort_hdr->rtt);
-	if (!ctask || !ctask->sc)
-		/*
-		 * the iscsi layer must have completed the cmd while this
-		 * was starting up.
-		 *
-		 * Note: In the case of a SCSI cmd timeout, the task's sc
-		 *       is still active; hence ctask->sc != 0
-		 *       In this case, the task must be aborted
-		 */
-		return 0;
-
-	ref_sc = ctask->sc;
-
-	/* Retrieve LUN directly from the ref_sc */
-	int_to_scsilun(ref_sc->device->lun, (struct scsi_lun *) scsi_lun);
-	tmfabort_wqe->lun[0] = be32_to_cpu(scsi_lun[0]);
-	tmfabort_wqe->lun[1] = be32_to_cpu(scsi_lun[1]);
-
-	if (ref_sc->sc_data_direction == DMA_TO_DEVICE)
-		dword = (ISCSI_TASK_TYPE_WRITE << ISCSI_CMD_REQUEST_TYPE_SHIFT);
-	else
-		dword = (ISCSI_TASK_TYPE_READ << ISCSI_CMD_REQUEST_TYPE_SHIFT);
-	tmfabort_wqe->ref_itt = (dword | (tmfabort_hdr->rtt & ISCSI_ITT_MASK));
+	switch (tmfabort_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) {
+	case ISCSI_TM_FUNC_ABORT_TASK:
+	case ISCSI_TM_FUNC_TASK_REASSIGN:
+		ctask = iscsi_itt_to_task(conn, tmfabort_hdr->rtt);
+		if (!ctask || !ctask->sc)
+			/*
+			 * the iscsi layer must have completed the cmd while
+			 * was starting up.
+			 *
+			 * Note: In the case of a SCSI cmd timeout, the task's
+			 *       sc is still active; hence ctask->sc != 0
+			 *       In this case, the task must be aborted
+			 */
+			return 0;
+
+		ref_sc = ctask->sc;
+		if (ref_sc->sc_data_direction == DMA_TO_DEVICE)
+			dword = (ISCSI_TASK_TYPE_WRITE <<
+				 ISCSI_CMD_REQUEST_TYPE_SHIFT);
+		else
+			dword = (ISCSI_TASK_TYPE_READ <<
+				 ISCSI_CMD_REQUEST_TYPE_SHIFT);
+		tmfabort_wqe->ref_itt = (dword |
+					(tmfabort_hdr->rtt & ISCSI_ITT_MASK));
+		break;
+	default:
+		tmfabort_wqe->ref_itt = RESERVED_ITT;
+	}
+	memcpy(tmfabort_wqe->lun, tmfabort_hdr->lun, sizeof(struct scsi_lun));
 	tmfabort_wqe->ref_cmd_sn = be32_to_cpu(tmfabort_hdr->refcmdsn);
 
 	tmfabort_wqe->bd_list_addr_lo = (u32) bnx2i_conn->hba->mp_bd_dma;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH 2/5 v3] BNX2I: Added support for other TMFs besides ABORT_TASK
  2010-08-13 16:33 ` [PATCH 2/5 v3] BNX2I: Added support for other TMFs besides ABORT_TASK Eddie Wai
@ 2010-08-13 16:42   ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2010-08-13 16:42 UTC (permalink / raw)
  To: open-iscsi
  Cc: Eddie Wai, James Bottomley, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 08/13/2010 11:33 AM, Eddie Wai wrote:
> Expanded the TMF request routine to support other TMFs such as LUN
> RESET, etc.
>


All the patches look ok to me. Thanks.

Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 00/16] BNX2I: Patch set to fix various bug fixes
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (27 preceding siblings ...)
  2010-08-13 16:33 ` [PATCH 2/5 v3] BNX2I: Added support for other TMFs besides ABORT_TASK Eddie Wai
@ 2010-11-10 23:04 ` Eddie Wai
  2010-11-10 23:04 ` [PATCH 01/16] BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins Eddie Wai
                   ` (80 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-10 23:04 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Hello,

This patch set contains various bug fixes as categorized in the following:
- scsi command handling (nop-ins, tmfs)
- various connection clean up bug fixes

Your comments are grealy appreciated.  Please review, thanks.

Eddie

Eddie Wai (16):
  BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins
  BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In
  BNX2I: Fixed the endian bug in the TMF LUN cmd send
  BNX2I: Updated the handling of NETEVENTs to alleviate recovery
  BNX2I: Modified the bnx2i stop path to compensate for in progress ops
  BNX2I: Added code to handle the binding of an existing connection
  BNX2I: Fixed the remote TCP RST handling for the 570X (1g)
  BNX2I: Added mutex lock protection to conn_get_param
  BNX2I: Removed the dynamic registration of CNIC
  BNX2I: Fixed a cid leak issue for 5771X (10g)
  BNX2I: Added return code check for chip kwqe submission request
  BNX2I: Added feature to silently drop NOPOUT request
  BNX2I: Cleaned up various error conditions in ep_connect/disconnect
  BNX2I: Allow to abort the connection if connect request times out
  BNX2I: Updated copyright and maintainer info
  BNX2I: Updated version to 2.6.2.2

 drivers/scsi/bnx2i/57xx_iscsi_constants.h |    3 +-
 drivers/scsi/bnx2i/57xx_iscsi_hsi.h       |    3 +-
 drivers/scsi/bnx2i/bnx2i.h                |   18 ++--
 drivers/scsi/bnx2i/bnx2i_hwi.c            |  152 ++++++++++++++++++++-----
 drivers/scsi/bnx2i/bnx2i_init.c           |  108 ++++--------------
 drivers/scsi/bnx2i/bnx2i_iscsi.c          |  177 +++++++++++++++++++---------
 drivers/scsi/bnx2i/bnx2i_sysfs.c          |    3 +-
 drivers/scsi/libiscsi.c                   |    3 +-
 include/scsi/libiscsi.h                   |    1 +
 9 files changed, 280 insertions(+), 188 deletions(-)



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 01/16] BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (28 preceding siblings ...)
  2010-11-10 23:04 ` [PATCH 00/16] BNX2I: Patch set to fix various bug fixes Eddie Wai
@ 2010-11-10 23:04 ` Eddie Wai
  2010-11-10 23:04 ` [PATCH 02/16] BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In Eddie Wai
                   ` (79 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-10 23:04 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Unsolicited NOP-Ins are placed in the receive queue of the hardware
which requires to be read out regardless if the receive pipe is suspended
or not.  This patch adds the disposal of this RQ element under this
condition.
Also fixed the bug in the unsolicited NOP-In handling routine which
checks for the RESERVED_ITT.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 8d9dbb3..16c76e0 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1549,11 +1549,9 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session,
 	struct iscsi_task *task;
 	struct bnx2i_nop_in_msg *nop_in;
 	struct iscsi_nopin *hdr;
-	u32 itt;
 	int tgt_async_nop = 0;
 
 	nop_in = (struct bnx2i_nop_in_msg *)cqe;
-	itt = nop_in->itt & ISCSI_NOP_IN_MSG_INDEX;
 
 	spin_lock(&session->lock);
 	hdr = (struct iscsi_nopin *)&bnx2i_conn->gen_pdu.resp_hdr;
@@ -1563,7 +1561,7 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session,
 	hdr->exp_cmdsn = cpu_to_be32(nop_in->exp_cmd_sn);
 	hdr->ttt = cpu_to_be32(nop_in->ttt);
 
-	if (itt == (u16) RESERVED_ITT) {
+	if (nop_in->itt == (u16) RESERVED_ITT) {
 		bnx2i_unsol_pdu_adjust_rq(bnx2i_conn);
 		hdr->itt = RESERVED_ITT;
 		tgt_async_nop = 1;
@@ -1571,7 +1569,8 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session,
 	}
 
 	/* this is a response to one of our nop-outs */
-	task = iscsi_itt_to_task(conn, itt);
+	task = iscsi_itt_to_task(conn,
+			 (itt_t) (nop_in->itt & ISCSI_NOP_IN_MSG_INDEX));
 	if (task) {
 		hdr->flags = ISCSI_FLAG_CMD_FINAL;
 		hdr->itt = task->hdr->itt;
@@ -1721,9 +1720,18 @@ static void bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
 		if (nopin->cq_req_sn != qp->cqe_exp_seq_sn)
 			break;
 
-		if (unlikely(test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx)))
+		if (unlikely(test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx))) {
+			if (nopin->op_code == ISCSI_OP_NOOP_IN &&
+			    nopin->itt == (u16) RESERVED_ITT) {
+				printk(KERN_ALERT "bnx2i: Unsolicited "
+					"NOP-In detected for suspended "
+					"connection dev=%s!\n",
+					bnx2i_conn->hba->netdev->name);
+				bnx2i_unsol_pdu_adjust_rq(bnx2i_conn);
+				goto cqe_out;
+			}
 			break;
-
+		}
 		tgt_async_msg = 0;
 
 		switch (nopin->op_code) {
@@ -1770,10 +1778,9 @@ static void bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
 			printk(KERN_ALERT "bnx2i: unknown opcode 0x%x\n",
 					  nopin->op_code);
 		}
-
 		if (!tgt_async_msg)
 			bnx2i_conn->ep->num_active_cmds--;
-
+cqe_out:
 		/* clear out in production version only, till beta keep opcode
 		 * field intact, will be helpful in debugging (context dump)
 		 * nopin->op_code = 0;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 02/16] BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (29 preceding siblings ...)
  2010-11-10 23:04 ` [PATCH 01/16] BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins Eddie Wai
@ 2010-11-10 23:04 ` Eddie Wai
  2010-11-10 23:04 ` [PATCH 03/16] BNX2I: Fixed the endian bug in the TMF LUN cmd send Eddie Wai
                   ` (78 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-10 23:04 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The patch fixes the following situations where NOP-Out pkt is called for:
- local unsolicited NOP-Out requests (requesting no NOP-In response)
- local NOP-Out responses to unsolicited NOP-In requests

kernel panic is observed due to double session spin_lock requests; one in the
bnx2i_process_nopin_local_cmpl routine in bnx2i_hwi.c and the other in the
iscsi_put_task routine in libiscsi.c

The proposed fix is to export the currently static __iscsi_put_task() routine
and have bnx2i call it directly instead of the iscsi_put_task() routine which
holds the session spin lock.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Acked-by: Benjamin Li <benli@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |    2 +-
 drivers/scsi/libiscsi.c        |    3 ++-
 include/scsi/libiscsi.h        |    1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 16c76e0..32cf930 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1513,7 +1513,7 @@ static void bnx2i_process_nopin_local_cmpl(struct iscsi_session *session,
 	task = iscsi_itt_to_task(conn,
 				 nop_in->itt & ISCSI_NOP_IN_MSG_INDEX);
 	if (task)
-		iscsi_put_task(task);
+		__iscsi_put_task(task);
 	spin_unlock(&session->lock);
 }
 
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 633e090..b63e2a4 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -539,11 +539,12 @@ void __iscsi_get_task(struct iscsi_task *task)
 }
 EXPORT_SYMBOL_GPL(__iscsi_get_task);
 
-static void __iscsi_put_task(struct iscsi_task *task)
+void __iscsi_put_task(struct iscsi_task *task)
 {
 	if (atomic_dec_and_test(&task->refcount))
 		iscsi_free_task(task);
 }
+EXPORT_SYMBOL_GPL(__iscsi_put_task);
 
 void iscsi_put_task(struct iscsi_task *task)
 {
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index ae5196a..2ea9aec 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -420,6 +420,7 @@ extern struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *, itt_t);
 extern struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *, itt_t);
 extern void iscsi_requeue_task(struct iscsi_task *task);
 extern void iscsi_put_task(struct iscsi_task *task);
+extern void __iscsi_put_task(struct iscsi_task *task);
 extern void __iscsi_get_task(struct iscsi_task *task);
 extern void iscsi_complete_scsi_task(struct iscsi_task *task,
 				     uint32_t exp_cmdsn, uint32_t max_cmdsn);
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 03/16] BNX2I: Fixed the endian bug in the TMF LUN cmd send
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (30 preceding siblings ...)
  2010-11-10 23:04 ` [PATCH 02/16] BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In Eddie Wai
@ 2010-11-10 23:04 ` Eddie Wai
  2010-11-10 23:04 ` [PATCH 04/16] BNX2I: Updated the handling of NETEVENTs to alleviate recovery Eddie Wai
                   ` (77 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-10 23:04 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Added a be32_to_cpu call for the TMF LUN wqe.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 32cf930..c9a3c0f 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -385,6 +385,7 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn,
 	struct bnx2i_cmd *bnx2i_cmd;
 	struct bnx2i_tmf_request *tmfabort_wqe;
 	u32 dword;
+	__be32 scsi_lun[2];
 
 	bnx2i_cmd = (struct bnx2i_cmd *)mtask->dd_data;
 	tmfabort_hdr = (struct iscsi_tm *)mtask->hdr;
@@ -426,7 +427,10 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn,
 	default:
 		tmfabort_wqe->ref_itt = RESERVED_ITT;
 	}
-	memcpy(tmfabort_wqe->lun, tmfabort_hdr->lun, sizeof(struct scsi_lun));
+	memcpy(scsi_lun, tmfabort_hdr->lun, sizeof(struct scsi_lun));
+	tmfabort_wqe->lun[0] = be32_to_cpu(scsi_lun[0]);
+	tmfabort_wqe->lun[1] = be32_to_cpu(scsi_lun[1]);
+
 	tmfabort_wqe->ref_cmd_sn = be32_to_cpu(tmfabort_hdr->refcmdsn);
 
 	tmfabort_wqe->bd_list_addr_lo = (u32) bnx2i_conn->hba->mp_bd_dma;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 04/16] BNX2I: Updated the handling of NETEVENTs to alleviate recovery
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (31 preceding siblings ...)
  2010-11-10 23:04 ` [PATCH 03/16] BNX2I: Fixed the endian bug in the TMF LUN cmd send Eddie Wai
@ 2010-11-10 23:04 ` Eddie Wai
  2010-11-18  3:14   ` Mike Christie
  2010-11-10 23:04 ` [PATCH 05/16] BNX2I: Modified the bnx2i stop path to compensate for in progress ops Eddie Wai
                   ` (76 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-11-10 23:04 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The NETDEV_GOING_DOWN handling will no longer request to put all
active sessions into recovery mode until the NETDEV_DOWN event.
This will eliminate the unnecessary recovery request to iscsid in the
NETDEV_GOING_DOWN->NETDEV_UNREGISTER path which will remove the host
anyway.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h     |    3 ++
 drivers/scsi/bnx2i/bnx2i_hwi.c |   53 +++++++++++++++++++++++++++++++++++++--
 2 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index a44b1b3..1aeb9f0 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -227,6 +227,7 @@ struct bnx2i_cmd {
  * @gen_pdu:               login/nopout/logout pdu resources
  * @violation_notified:    bit mask used to track iscsi error/warning messages
  *                         already printed out
+ * @prev_sess_state:       tracks the previous connection state
  *
  * iSCSI connection structure
  */
@@ -250,6 +251,8 @@ struct bnx2i_conn {
 	 */
 	struct generic_pdu_resc gen_pdu;
 	u64 violation_notified;
+
+	int prev_sess_state;
 };
 
 
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index c9a3c0f..7eeb673 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -2244,6 +2244,11 @@ static void bnx2i_indicate_kcqe(void *context, struct kcqe *kcqe[],
 static void bnx2i_indicate_netevent(void *context, unsigned long event)
 {
 	struct bnx2i_hba *hba = context;
+	struct bnx2i_conn *bnx2i_conn;
+	struct iscsi_conn *conn;
+	struct iscsi_session *session;
+	int conns_active, i;
+	unsigned long flags;
 
 	switch (event) {
 	case NETDEV_UP:
@@ -2251,13 +2256,55 @@ static void bnx2i_indicate_netevent(void *context, unsigned long event)
 			bnx2i_send_fw_iscsi_init_msg(hba);
 		break;
 	case NETDEV_DOWN:
+		for (i = 0; i < hba->max_active_conns; i++) {
+			bnx2i_conn = bnx2i_get_conn_from_id(hba, i);
+			if (bnx2i_conn) {
+				conn = bnx2i_conn->cls_conn->dd_data;
+				session = conn->session;
+				spin_lock_irqsave(&session->lock, flags);
+				if (session->state == ISCSI_STATE_FAILED)
+					session->state =
+						bnx2i_conn->prev_sess_state;
+				spin_unlock_irqrestore(&session->lock, flags);
+			}
+		}
+		iscsi_host_for_each_session(hba->shost,
+					    bnx2i_drop_session);
+		while (hba->ofld_conns_active) {
+			conns_active = hba->ofld_conns_active;
+
+			wait_event_interruptible_timeout(hba->eh_wait,
+				(hba->ofld_conns_active != conns_active),
+				hba->hba_shutdown_tmo);
+			if (hba->ofld_conns_active == conns_active)
+				break;
+		}
+		/* This flag should be cleared last so that ep_disconnect()
+		 * gracefully cleans up connection context
+		 */
 		clear_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state);
 		clear_bit(ADAPTER_STATE_UP, &hba->adapter_state);
+		if (hba->ofld_conns_active)
+			printk(KERN_ERR "bnx2i (%s): NETDEV_DOWN with %d "
+				"active conns\n", hba->netdev->name,
+				hba->ofld_conns_active);
 		break;
 	case NETDEV_GOING_DOWN:
-		set_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state);
-		iscsi_host_for_each_session(hba->shost,
-					    bnx2i_drop_session);
+		/* Suspend all data transmissions */
+		for (i = 0; i < hba->max_active_conns; i++) {
+			bnx2i_conn = bnx2i_get_conn_from_id(hba, i);
+			if (bnx2i_conn) {
+				conn = bnx2i_conn->cls_conn->dd_data;
+				session = conn->session;
+				spin_lock_irqsave(&session->lock, flags);
+				bnx2i_conn->prev_sess_state = session->state;
+				if (conn->stop_stage == 0)
+					session->state = ISCSI_STATE_FAILED;
+				spin_unlock_irqrestore(&session->lock, flags);
+				iscsi_suspend_queue(conn);
+				set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
+			}
+		}
 		break;
 	case NETDEV_CHANGE:
 		bnx2i_get_link_state(hba);
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 05/16] BNX2I: Modified the bnx2i stop path to compensate for in progress ops
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (32 preceding siblings ...)
  2010-11-10 23:04 ` [PATCH 04/16] BNX2I: Updated the handling of NETEVENTs to alleviate recovery Eddie Wai
@ 2010-11-10 23:04 ` Eddie Wai
  2010-11-10 23:04 ` [PATCH 06/16] BNX2I: Added code to handle the binding of an existing connection Eddie Wai
                   ` (75 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-10 23:04 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The stop path has been augmented to wait a max of 10s for all in
progress offload and destroy activities to complete before proceeding
to terminate all active connections (via iscsid or forcefully).

Note that any new offload and destroy requests are now blocked and
return to the caller immediately.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_init.c  |   21 +++++++++++++++++----
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    7 ++++++-
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 50c2aa3..c8e929d 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -211,13 +211,24 @@ void bnx2i_stop(void *handle)
 {
 	struct bnx2i_hba *hba = handle;
 	int conns_active;
+	int wait_delay = 1 * HZ;
 
 	/* check if cleanup happened in GOING_DOWN context */
-	if (!test_and_clear_bit(ADAPTER_STATE_GOING_DOWN,
-				&hba->adapter_state))
+	if (!test_and_set_bit(ADAPTER_STATE_GOING_DOWN,
+			      &hba->adapter_state)) {
 		iscsi_host_for_each_session(hba->shost,
 					    bnx2i_drop_session);
-
+		wait_delay = hba->hba_shutdown_tmo;
+	}
+	/* Wait for inflight offload connection tasks to complete before
+	 * proceeding. Forcefully terminate all connection recovery in
+	 * progress at the earliest, either in bind(), send_pdu(LOGIN),
+	 * or conn_start()
+	 */
+	wait_event_interruptible_timeout(hba->eh_wait,
+					 (list_empty(&hba->ep_ofld_list) &&
+					 list_empty(&hba->ep_destroy_list)),
+					 10 * HZ);
 	/* Wait for all endpoints to be torn down, Chip will be reset once
 	 *  control returns to network driver. So it is required to cleanup and
 	 * release all connection resources before returning from this routine.
@@ -226,7 +237,7 @@ void bnx2i_stop(void *handle)
 		conns_active = hba->ofld_conns_active;
 		wait_event_interruptible_timeout(hba->eh_wait,
 				(hba->ofld_conns_active != conns_active),
-				hba->hba_shutdown_tmo);
+				wait_delay);
 		if (hba->ofld_conns_active == conns_active)
 			break;
 	}
@@ -235,9 +246,11 @@ void bnx2i_stop(void *handle)
 	/* This flag should be cleared last so that ep_disconnect() gracefully
 	 * cleans up connection context
 	 */
+	clear_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state);
 	clear_bit(ADAPTER_STATE_UP, &hba->adapter_state);
 }
 
+
 /**
  * bnx2i_register_device - register bnx2i adapter instance with the cnic driver
  * @hba:	Adapter instance to register
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index fb50efb..823e4fa 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1383,6 +1383,12 @@ static int bnx2i_conn_bind(struct iscsi_cls_session *cls_session,
 	ep = iscsi_lookup_endpoint(transport_fd);
 	if (!ep)
 		return -EINVAL;
+	/*
+	 * Forcefully terminate all in progress connection recovery at the
+	 * earliest, either in bind(), send_pdu(LOGIN), or conn_start()
+	 */
+	if (bnx2i_adapter_ready(hba))
+		return -EIO;
 
 	bnx2i_ep = ep->dd_data;
 	if ((bnx2i_ep->state == EP_STATE_TCP_FIN_RCVD) ||
@@ -1404,7 +1410,6 @@ static int bnx2i_conn_bind(struct iscsi_cls_session *cls_session,
 				  hba->netdev->name);
 		return -EEXIST;
 	}
-
 	bnx2i_ep->conn = bnx2i_conn;
 	bnx2i_conn->ep = bnx2i_ep;
 	bnx2i_conn->iscsi_conn_cid = bnx2i_ep->ep_iscsi_cid;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 06/16] BNX2I: Added code to handle the binding of an existing connection
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (33 preceding siblings ...)
  2010-11-10 23:04 ` [PATCH 05/16] BNX2I: Modified the bnx2i stop path to compensate for in progress ops Eddie Wai
@ 2010-11-10 23:04 ` Eddie Wai
  2010-11-18  3:24   ` Mike Christie
  2010-11-10 23:04 ` [PATCH 07/16] BNX2I: Fixed the remote TCP RST handling for the 570X (1g) Eddie Wai
                   ` (74 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-11-10 23:04 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

This is the case when iscsid gets re-launched due to features like
iSCSI boot which requires the daemon to re-launch due to
pivot root.  If the code detected the connection had an existing
endpoint, the old endpoint must get cleaned up.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 823e4fa..3b65c64 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1410,6 +1410,13 @@ static int bnx2i_conn_bind(struct iscsi_cls_session *cls_session,
 				  hba->netdev->name);
 		return -EEXIST;
 	}
+	if (bnx2i_conn->ep) {
+		printk(KERN_ALERT "bnx2i: Binding to an existing endpoint "
+			"detected.  Disconnecting the old...\n");
+		mutex_lock(&hba->net_dev_lock);
+		bnx2i_hw_ep_disconnect(bnx2i_conn->ep);
+		mutex_unlock(&hba->net_dev_lock);
+	}
 	bnx2i_ep->conn = bnx2i_conn;
 	bnx2i_conn->ep = bnx2i_ep;
 	bnx2i_conn->iscsi_conn_cid = bnx2i_ep->ep_iscsi_cid;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 07/16] BNX2I: Fixed the remote TCP RST handling for the 570X (1g)
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (34 preceding siblings ...)
  2010-11-10 23:04 ` [PATCH 06/16] BNX2I: Added code to handle the binding of an existing connection Eddie Wai
@ 2010-11-10 23:04 ` Eddie Wai
  2010-11-10 23:04 ` [PATCH 09/16] BNX2I: Removed the dynamic registration of CNIC Eddie Wai
                   ` (73 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-10 23:04 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Modified the handling of the remote TCP RST code so the chip can now
flush the tx pipe accordingly upon a remote TCP RST reception.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c   |   11 ++++++++---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    8 +++-----
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 7eeb673..4609ef5 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -2380,12 +2380,17 @@ static void bnx2i_cm_abort_cmpl(struct cnic_sock *cm_sk)
 static void bnx2i_cm_remote_close(struct cnic_sock *cm_sk)
 {
 	struct bnx2i_endpoint *ep = (struct bnx2i_endpoint *) cm_sk->context;
+	u32 old_state = ep->state;
 
-	ep->state = EP_STATE_TCP_FIN_RCVD;
-	if (ep->conn)
-		bnx2i_recovery_que_add_conn(ep->hba, ep->conn);
+	ep->state = EP_STATE_TCP_RST_RCVD;
+	if (old_state == EP_STATE_DISCONN_START)
+		wake_up_interruptible(&ep->ofld_wait);
+	else
+		if (ep->conn)
+			bnx2i_recovery_que_add_conn(ep->hba, ep->conn);
 }
 
+
 /**
  * bnx2i_cm_remote_abort - process TCP RST and start conn cleanup
  * @hba:		adapter structure pointer
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 3b65c64..6a87a83 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1911,6 +1911,7 @@ static int bnx2i_ep_tcp_conn_active(struct bnx2i_endpoint *bnx2i_ep)
 
 	switch (bnx2i_ep->state) {
 	case EP_STATE_CONNECT_START:
+	case EP_STATE_CONNECT_FAILED:
 	case EP_STATE_CLEANUP_FAILED:
 	case EP_STATE_OFLD_FAILED:
 	case EP_STATE_DISCONN_TIMEDOUT:
@@ -1926,13 +1927,10 @@ static int bnx2i_ep_tcp_conn_active(struct bnx2i_endpoint *bnx2i_ep)
 		ret = 1;
 		break;
 	case EP_STATE_TCP_RST_RCVD:
-		ret = 0;
-		break;
-	case EP_STATE_CONNECT_FAILED:
 		if (cnic_dev_10g)
-			ret = 1;
-		else
 			ret = 0;
+		else
+			ret = 1;
 		break;
 	default:
 		ret = 0;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 08/16] BNX2I: Added mutex lock protection to conn_get_param
       [not found] ` <Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
                     ` (3 preceding siblings ...)
  2010-08-10 19:09   ` [PATCH 3/5] BNX2I: Recouple the CFC delete cleanup with cm_abort/close completion Eddie Wai
@ 2010-11-10 23:04   ` Eddie Wai
  2010-11-18  3:27     ` Mike Christie
  2010-11-10 23:04   ` [PATCH 10/16] BNX2I: Fixed a cid leak issue for 5771X (10g) Eddie Wai
                     ` (6 subsequent siblings)
  11 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-11-10 23:04 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Added net_dev mutex lock protection before accessing the csk
parameters.

Signed-off-by: Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Reviewed-by: Benjamin Li <benli-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 6a87a83..6951969 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1473,21 +1473,30 @@ static int bnx2i_conn_get_param(struct iscsi_cls_conn *cls_conn,
 	struct bnx2i_conn *bnx2i_conn = conn->dd_data;
 	int len = 0;
 
+	if (!(bnx2i_conn && bnx2i_conn->ep && bnx2i_conn->ep->hba))
+		goto out;
+
 	switch (param) {
 	case ISCSI_PARAM_CONN_PORT:
-		if (bnx2i_conn->ep)
+		mutex_lock(&bnx2i_conn->ep->hba->net_dev_lock);
+		if (bnx2i_conn->ep->cm_sk)
 			len = sprintf(buf, "%hu\n",
 				      bnx2i_conn->ep->cm_sk->dst_port);
+		mutex_unlock(&bnx2i_conn->ep->hba->net_dev_lock);
 		break;
 	case ISCSI_PARAM_CONN_ADDRESS:
-		if (bnx2i_conn->ep)
+		mutex_lock(&bnx2i_conn->ep->hba->net_dev_lock);
+		if (bnx2i_conn->ep->cm_sk)
 			len = sprintf(buf, "%pI4\n",
 				      &bnx2i_conn->ep->cm_sk->dst_ip);
+		mutex_unlock(&bnx2i_conn->ep->hba->net_dev_lock);
 		break;
 	default:
-		return iscsi_conn_get_param(cls_conn, param, buf);
+		len = iscsi_conn_get_param(cls_conn, param, buf);
+		if (len == -ENOSYS)
+			len = 0;
 	}
-
+out:
 	return len;
 }
 
-- 
1.7.0.5


-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 09/16] BNX2I: Removed the dynamic registration of CNIC
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (35 preceding siblings ...)
  2010-11-10 23:04 ` [PATCH 07/16] BNX2I: Fixed the remote TCP RST handling for the 570X (1g) Eddie Wai
@ 2010-11-10 23:04 ` Eddie Wai
  2010-11-18  3:29   ` Mike Christie
  2010-11-10 23:04 ` [PATCH 11/16] BNX2I: Added return code check for chip kwqe submission request Eddie Wai
                   ` (72 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-11-10 23:04 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The code no longer needs to dynamically register and unregister
the CNIC device.  The CNIC device will be kept registered until
module unload.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |    3 -
 drivers/scsi/bnx2i/bnx2i_init.c  |   82 --------------------------------------
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    9 +----
 3 files changed, 1 insertions(+), 93 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 1aeb9f0..d153607 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -720,14 +720,11 @@ extern struct device_attribute *bnx2i_dev_attributes[];
  * Function Prototypes
  */
 extern void bnx2i_identify_device(struct bnx2i_hba *hba);
-extern void bnx2i_register_device(struct bnx2i_hba *hba);
 
 extern void bnx2i_ulp_init(struct cnic_dev *dev);
 extern void bnx2i_ulp_exit(struct cnic_dev *dev);
 extern void bnx2i_start(void *handle);
 extern void bnx2i_stop(void *handle);
-extern void bnx2i_reg_dev_all(void);
-extern void bnx2i_unreg_dev_all(void);
 extern struct bnx2i_hba *get_adapter_list_head(void);
 
 struct bnx2i_conn *bnx2i_get_conn_from_id(struct bnx2i_hba *hba,
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index c8e929d..338caac 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -65,8 +65,6 @@ MODULE_PARM_DESC(rq_size, "Configure RQ size");
 
 u64 iscsi_error_mask = 0x00;
 
-static void bnx2i_unreg_one_device(struct bnx2i_hba *hba) ;
-
 
 /**
  * bnx2i_identify_device - identifies NetXtreme II device type
@@ -252,86 +250,6 @@ void bnx2i_stop(void *handle)
 
 
 /**
- * bnx2i_register_device - register bnx2i adapter instance with the cnic driver
- * @hba:	Adapter instance to register
- *
- * registers bnx2i adapter instance with the cnic driver while holding the
- *	adapter structure lock
- */
-void bnx2i_register_device(struct bnx2i_hba *hba)
-{
-	int rc;
-
-	if (test_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state) ||
-	    test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic)) {
-		return;
-	}
-
-	rc = hba->cnic->register_device(hba->cnic, CNIC_ULP_ISCSI, hba);
-
-	if (!rc)
-		set_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic);
-}
-
-
-/**
- * bnx2i_reg_dev_all - registers all adapter instances with the cnic driver
- *
- * registers all bnx2i adapter instances with the cnic driver while holding
- *	the global resource lock
- */
-void bnx2i_reg_dev_all(void)
-{
-	struct bnx2i_hba *hba, *temp;
-
-	mutex_lock(&bnx2i_dev_lock);
-	list_for_each_entry_safe(hba, temp, &adapter_list, link)
-		bnx2i_register_device(hba);
-	mutex_unlock(&bnx2i_dev_lock);
-}
-
-
-/**
- * bnx2i_unreg_one_device - unregister adapter instance with the cnic driver
- * @hba:	Adapter instance to unregister
- *
- * registers bnx2i adapter instance with the cnic driver while holding
- *	the adapter structure lock
- */
-static void bnx2i_unreg_one_device(struct bnx2i_hba *hba)
-{
-	if (hba->ofld_conns_active ||
-	    !test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic) ||
-	    test_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state))
-		return;
-
-	hba->cnic->unregister_device(hba->cnic, CNIC_ULP_ISCSI);
-
-	/* ep_disconnect could come before NETDEV_DOWN, driver won't
-	 * see NETDEV_DOWN as it already unregistered itself.
-	 */
-	hba->adapter_state = 0;
-	clear_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic);
-}
-
-/**
- * bnx2i_unreg_dev_all - unregisters all bnx2i instances with the cnic driver
- *
- * unregisters all bnx2i adapter instances with the cnic driver while holding
- *	the global resource lock
- */
-void bnx2i_unreg_dev_all(void)
-{
-	struct bnx2i_hba *hba, *temp;
-
-	mutex_lock(&bnx2i_dev_lock);
-	list_for_each_entry_safe(hba, temp, &adapter_list, link)
-		bnx2i_unreg_one_device(hba);
-	mutex_unlock(&bnx2i_dev_lock);
-}
-
-
-/**
  * bnx2i_init_one - initialize an adapter instance and allocate memory resources
  * @hba:	bnx2i adapter instance
  * @cnic:	cnic device handle
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 6951969..58515ee 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1620,8 +1620,6 @@ static struct bnx2i_hba *bnx2i_check_route(struct sockaddr *dst_addr)
 	struct bnx2i_hba *hba;
 	struct cnic_dev *cnic = NULL;
 
-	bnx2i_reg_dev_all();
-
 	hba = get_adapter_list_head();
 	if (hba && hba->cnic)
 		cnic = hba->cnic->cm_select_dev(desti, CNIC_ULP_ISCSI);
@@ -1732,8 +1730,6 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	if (shost) {
 		/* driver is given scsi host to work with */
 		hba = iscsi_host_priv(shost);
-		/* Register the device with cnic if not already done so */
-		bnx2i_register_device(hba);
 	} else
 		/*
 		 * check if the given destination can be reached through
@@ -1859,7 +1855,6 @@ qp_resc_err:
 check_busy:
 	mutex_unlock(&hba->net_dev_lock);
 nohba:
-	bnx2i_unreg_dev_all();
 	return ERR_PTR(rc);
 }
 
@@ -2095,9 +2090,7 @@ return_bnx2i_ep:
 
 	bnx2i_free_ep(ep);
 	mutex_unlock(&hba->net_dev_lock);
-	if (!hba->ofld_conns_active)
-		bnx2i_unreg_dev_all();
-
+	
 	wake_up_interruptible(&hba->eh_wait);
 }
 
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 10/16] BNX2I: Fixed a cid leak issue for 5771X (10g)
       [not found] ` <Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
                     ` (4 preceding siblings ...)
  2010-11-10 23:04   ` [PATCH 08/16] BNX2I: Added mutex lock protection to conn_get_param Eddie Wai
@ 2010-11-10 23:04   ` Eddie Wai
  2010-11-23 23:29   ` [PATCH v3 07/13] BNX2I: Added mutex lock protection to conn_get_param Eddie Wai
                     ` (5 subsequent siblings)
  11 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-10 23:04 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

A cid leak issue was found when the connect destroy request exceeded
the driver's disconnection timeout.  This will lead to a cid resource
leak issue.
The fix is to allow the cid cleanup even when this happens.

Signed-off-by: Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Acked-by: Anil Veerabhadrappa <anilgv-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Reviewed-by: Michael Chan <mchan-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 58515ee..dd18717 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1659,18 +1659,26 @@ no_nx2_route:
 static int bnx2i_tear_down_conn(struct bnx2i_hba *hba,
 				 struct bnx2i_endpoint *ep)
 {
-	if (test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic))
+	if (test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic) && ep->cm_sk)
 		hba->cnic->cm_destroy(ep->cm_sk);
 
-	if (test_bit(ADAPTER_STATE_GOING_DOWN, &ep->hba->adapter_state))
-		ep->state = EP_STATE_DISCONN_COMPL;
-
 	if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type) &&
 	    ep->state == EP_STATE_DISCONN_TIMEDOUT) {
-		printk(KERN_ALERT "bnx2i - ERROR - please submit GRC Dump,"
-				  " NW/PCIe trace, driver msgs to developers"
-				  " for analysis\n");
-		return 1;
+		if (ep->conn && ep->conn->cls_conn &&
+		    ep->conn->cls_conn->dd_data) {
+			struct iscsi_conn *conn = ep->conn->cls_conn->dd_data;
+
+			/* Must suspend all rx queue activity for this ep */
+			set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
+		}
+		/* CONN_DISCONNECT timeout may or may not be an issue depending
+		 * on what transcribed in TCP layer, different targets behave
+		 * differently
+		 */
+		printk(KERN_ALERT "bnx2i (%s): - WARN - CONN_DISCON timed out, "
+				  "please submit GRC Dump, NW/PCIe trace, "
+				  "driver msgs to developers for analysis\n",
+				  hba->netdev->name);
 	}
 
 	ep->state = EP_STATE_CLEANUP_START;
-- 
1.7.0.5


-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 11/16] BNX2I: Added return code check for chip kwqe submission request
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (36 preceding siblings ...)
  2010-11-10 23:04 ` [PATCH 09/16] BNX2I: Removed the dynamic registration of CNIC Eddie Wai
@ 2010-11-10 23:04 ` Eddie Wai
  2010-11-10 23:04 ` [PATCH 12/16] BNX2I: Added feature to silently drop NOPOUT request Eddie Wai
                   ` (71 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-10 23:04 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Added the handling for cases when a chip request is made to the
CNIC module but the hardware is not ready to accept.  This would
lead to many unnecessary wait timeouts.
This code adds check in the connect establishment and destruction
path.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |    9 +++---
 drivers/scsi/bnx2i/bnx2i_hwi.c   |   54 ++++++++++++++++++++++++++++----------
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   17 ++++++++++-
 3 files changed, 60 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index d153607..72feb6c 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -652,6 +652,7 @@ enum {
 	EP_STATE_OFLD_FAILED            = 0x8000000,
 	EP_STATE_CONNECT_FAILED         = 0x10000000,
 	EP_STATE_DISCONN_TIMEDOUT       = 0x20000000,
+	EP_STATE_OFLD_FAILED_CID_BUSY   = 0x80000000,
 };
 
 /**
@@ -761,11 +762,11 @@ extern int bnx2i_send_iscsi_logout(struct bnx2i_conn *conn,
 				   struct iscsi_task *mtask);
 extern void bnx2i_send_cmd_cleanup_req(struct bnx2i_hba *hba,
 				       struct bnx2i_cmd *cmd);
-extern void bnx2i_send_conn_ofld_req(struct bnx2i_hba *hba,
-				     struct bnx2i_endpoint *ep);
-extern void bnx2i_update_iscsi_conn(struct iscsi_conn *conn);
-extern void bnx2i_send_conn_destroy(struct bnx2i_hba *hba,
+extern int bnx2i_send_conn_ofld_req(struct bnx2i_hba *hba,
 				    struct bnx2i_endpoint *ep);
+extern void bnx2i_update_iscsi_conn(struct iscsi_conn *conn);
+extern int bnx2i_send_conn_destroy(struct bnx2i_hba *hba,
+				   struct bnx2i_endpoint *ep);
 
 extern int bnx2i_alloc_qp_resc(struct bnx2i_hba *hba,
 			       struct bnx2i_endpoint *ep);
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 4609ef5..c577da6 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -701,10 +701,11 @@ void bnx2i_send_cmd_cleanup_req(struct bnx2i_hba *hba, struct bnx2i_cmd *cmd)
  * this routine prepares and posts CONN_OFLD_REQ1/2 KWQE to initiate
  * 	iscsi connection context clean-up process
  */
-void bnx2i_send_conn_destroy(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep)
+int bnx2i_send_conn_destroy(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep)
 {
 	struct kwqe *kwqe_arr[2];
 	struct iscsi_kwqe_conn_destroy conn_cleanup;
+	int rc = -EINVAL;
 
 	memset(&conn_cleanup, 0x00, sizeof(struct iscsi_kwqe_conn_destroy));
 
@@ -721,7 +722,9 @@ void bnx2i_send_conn_destroy(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep)
 
 	kwqe_arr[0] = (struct kwqe *) &conn_cleanup;
 	if (hba->cnic && hba->cnic->submit_kwqes)
-		hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, 1);
+		rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, 1);
+
+	return rc;
 }
 
 
@@ -732,8 +735,8 @@ void bnx2i_send_conn_destroy(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep)
  *
  * 5706/5708/5709 specific - prepares and posts CONN_OFLD_REQ1/2 KWQE
  */
-static void bnx2i_570x_send_conn_ofld_req(struct bnx2i_hba *hba,
-					  struct bnx2i_endpoint *ep)
+static int bnx2i_570x_send_conn_ofld_req(struct bnx2i_hba *hba,
+					 struct bnx2i_endpoint *ep)
 {
 	struct kwqe *kwqe_arr[2];
 	struct iscsi_kwqe_conn_offload1 ofld_req1;
@@ -741,6 +744,7 @@ static void bnx2i_570x_send_conn_ofld_req(struct bnx2i_hba *hba,
 	dma_addr_t dma_addr;
 	int num_kwqes = 2;
 	u32 *ptbl;
+	int rc = -EINVAL;
 
 	ofld_req1.hdr.op_code = ISCSI_KWQE_OPCODE_OFFLOAD_CONN1;
 	ofld_req1.hdr.flags =
@@ -778,7 +782,9 @@ static void bnx2i_570x_send_conn_ofld_req(struct bnx2i_hba *hba,
 	ofld_req2.num_additional_wqes = 0;
 
 	if (hba->cnic && hba->cnic->submit_kwqes)
-		hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes);
+		rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes);
+
+	return rc;
 }
 
 
@@ -789,8 +795,8 @@ static void bnx2i_570x_send_conn_ofld_req(struct bnx2i_hba *hba,
  *
  * 57710 specific - prepares and posts CONN_OFLD_REQ1/2 KWQE
  */
-static void bnx2i_5771x_send_conn_ofld_req(struct bnx2i_hba *hba,
-					   struct bnx2i_endpoint *ep)
+static int bnx2i_5771x_send_conn_ofld_req(struct bnx2i_hba *hba,
+					  struct bnx2i_endpoint *ep)
 {
 	struct kwqe *kwqe_arr[5];
 	struct iscsi_kwqe_conn_offload1 ofld_req1;
@@ -799,6 +805,7 @@ static void bnx2i_5771x_send_conn_ofld_req(struct bnx2i_hba *hba,
 	dma_addr_t dma_addr;
 	int num_kwqes = 2;
 	u32 *ptbl;
+	int rc = -EINVAL;
 
 	ofld_req1.hdr.op_code = ISCSI_KWQE_OPCODE_OFFLOAD_CONN1;
 	ofld_req1.hdr.flags =
@@ -844,7 +851,9 @@ static void bnx2i_5771x_send_conn_ofld_req(struct bnx2i_hba *hba,
 	num_kwqes += 1;
 
 	if (hba->cnic && hba->cnic->submit_kwqes)
-		hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes);
+		rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes);
+
+	return rc;
 }
 
 /**
@@ -855,12 +864,16 @@ static void bnx2i_5771x_send_conn_ofld_req(struct bnx2i_hba *hba,
  *
  * this routine prepares and posts CONN_OFLD_REQ1/2 KWQE
  */
-void bnx2i_send_conn_ofld_req(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep)
+int bnx2i_send_conn_ofld_req(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep)
 {
+	int rc;
+
 	if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type))
-		bnx2i_5771x_send_conn_ofld_req(hba, ep);
+		rc = bnx2i_5771x_send_conn_ofld_req(hba, ep);
 	else
-		bnx2i_570x_send_conn_ofld_req(hba, ep);
+		rc = bnx2i_570x_send_conn_ofld_req(hba, ep);
+
+	return rc;
 }
 
 
@@ -2165,11 +2178,24 @@ static void bnx2i_process_ofld_cmpl(struct bnx2i_hba *hba,
 	}
 
 	if (ofld_kcqe->completion_status) {
+		ep->state = EP_STATE_OFLD_FAILED;
 		if (ofld_kcqe->completion_status ==
 		    ISCSI_KCQE_COMPLETION_STATUS_CTX_ALLOC_FAILURE)
-			printk(KERN_ALERT "bnx2i: unable to allocate"
-					  " iSCSI context resources\n");
-		ep->state = EP_STATE_OFLD_FAILED;
+			printk(KERN_ALERT "bnx2i (%s): ofld1 cmpl - unable "
+				"to allocate iSCSI context resources\n",
+				hba->netdev->name);
+		else if (ofld_kcqe->completion_status ==
+			 ISCSI_KCQE_COMPLETION_STATUS_INVALID_OPCODE)
+			printk(KERN_ALERT "bnx2i (%s): ofld1 cmpl - invalid "
+				"opcode\n", hba->netdev->name);
+		else if (ofld_kcqe->completion_status ==
+			ISCSI_KCQE_COMPLETION_STATUS_CID_BUSY)
+			/* error status code valid only for 5771x chipset */
+			ep->state = EP_STATE_OFLD_FAILED_CID_BUSY;
+		else
+			printk(KERN_ALERT "bnx2i (%s): ofld1 cmpl - invalid "
+				"error code %d\n", hba->netdev->name,
+				ofld_kcqe->completion_status);
 	} else {
 		ep->state = EP_STATE_OFLD_COMPL;
 		cid_addr = ofld_kcqe->iscsi_conn_context_id;
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index dd18717..b32baf8 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1691,7 +1691,9 @@ static int bnx2i_tear_down_conn(struct bnx2i_hba *hba,
 	bnx2i_ep_destroy_list_add(hba, ep);
 
 	/* destroy iSCSI context, wait for it to complete */
-	bnx2i_send_conn_destroy(hba, ep);
+	if (bnx2i_send_conn_destroy(hba, ep))
+		ep->state = EP_STATE_CLEANUP_CMPL;
+
 	wait_event_interruptible(ep->ofld_wait,
 				 (ep->state != EP_STATE_CLEANUP_START));
 
@@ -1790,7 +1792,18 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	bnx2i_ep->ofld_timer.data = (unsigned long) bnx2i_ep;
 	add_timer(&bnx2i_ep->ofld_timer);
 
-	bnx2i_send_conn_ofld_req(hba, bnx2i_ep);
+	if (bnx2i_send_conn_ofld_req(hba, bnx2i_ep)) {
+		if (bnx2i_ep->state == EP_STATE_OFLD_FAILED_CID_BUSY) {
+			printk(KERN_ALERT "bnx2i (%s): iscsi cid %d is busy\n",
+				hba->netdev->name, bnx2i_ep->ep_iscsi_cid);
+			rc = -EBUSY;
+		} else
+			rc = -ENOSPC;
+		printk(KERN_ALERT "bnx2i (%s): unable to send conn offld kwqe"
+			"\n", hba->netdev->name);
+		bnx2i_ep_ofld_list_del(hba, bnx2i_ep);
+		goto conn_failed;
+	}
 
 	/* Wait for CNIC hardware to setup conn context and return 'cid' */
 	wait_event_interruptible(bnx2i_ep->ofld_wait,
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 12/16] BNX2I: Added feature to silently drop NOPOUT request
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (37 preceding siblings ...)
  2010-11-10 23:04 ` [PATCH 11/16] BNX2I: Added return code check for chip kwqe submission request Eddie Wai
@ 2010-11-10 23:04 ` Eddie Wai
  2010-11-18  3:40   ` Mike Christie
  2010-11-10 23:04 ` [PATCH 13/16] BNX2I: Cleaned up various error conditions in ep_connect/disconnect Eddie Wai
                   ` (70 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-11-10 23:04 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

In the case the chip is undergoing different invasive operation
which requires a chip reset, all NOPOUT request during this period
must be silently dropped from queuing to the hardware.  This patch
will respond to libiscsi immediately with sent success.  Since the
request was not actually sent, the NOPIN wait timeout will get
triggered and another NOPOUT request will commence through the
proper channel.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index b32baf8..507cd25 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1068,6 +1068,22 @@ static int bnx2i_iscsi_send_generic_request(struct iscsi_task *task)
 	char *buf;
 	int data_len;
 
+	/*
+	 * Forcefully terminate all in progress connection recovery at the
+	 * earliest, either in bind(), send_pdu(LOGIN), or conn_start()
+	 */
+	if (bnx2i_adapter_ready(bnx2i_conn->ep->hba)) {
+		if ((task->hdr->opcode & ISCSI_OPCODE_MASK) ==
+		    ISCSI_OP_NOOP_OUT)
+			/* This is a WA to indicate to libiscsi that the nopout
+			 * request was sent successfully without actually
+			 * submitting to the hardware.
+			 * Just silently drop the nopout request
+			 */
+			return 0;
+		else
+			return -EIO;
+	}
 	bnx2i_iscsi_prep_generic_pdu_bd(bnx2i_conn);
 	switch (task->hdr->opcode & ISCSI_OPCODE_MASK) {
 	case ISCSI_OP_LOGIN:
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 13/16] BNX2I: Cleaned up various error conditions in ep_connect/disconnect
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (38 preceding siblings ...)
  2010-11-10 23:04 ` [PATCH 12/16] BNX2I: Added feature to silently drop NOPOUT request Eddie Wai
@ 2010-11-10 23:04 ` Eddie Wai
  2010-11-10 23:04 ` [PATCH 14/16] BNX2I: Allow to abort the connection if connect request times out Eddie Wai
                   ` (69 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-10 23:04 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Various error conditions inside ep_connect and ep_disconnect were
either not being handled or not being handled correctly.  This patch
fixes all those issues.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   67 ++++++++++++++++++++++---------------
 1 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 507cd25..b3925c7 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -411,7 +411,9 @@ static void bnx2i_free_ep(struct iscsi_endpoint *ep)
 	bnx2i_ep->state = EP_STATE_IDLE;
 	bnx2i_ep->hba->ofld_conns_active--;
 
-	bnx2i_free_iscsi_cid(bnx2i_ep->hba, bnx2i_ep->ep_iscsi_cid);
+	if (bnx2i_ep->ep_iscsi_cid != (u16) -1)
+		bnx2i_free_iscsi_cid(bnx2i_ep->hba, bnx2i_ep->ep_iscsi_cid);
+
 	if (bnx2i_ep->conn) {
 		bnx2i_ep->conn->ep = NULL;
 		bnx2i_ep->conn = NULL;
@@ -1763,13 +1765,17 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 		 */
 		hba = bnx2i_check_route(dst_addr);
 
-	if (!hba || test_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state)) {
+	if (!hba) {
 		rc = -EINVAL;
 		goto nohba;
 	}
+	mutex_lock(&hba->net_dev_lock);
 
+	if (bnx2i_adapter_ready(hba) || !hba->cid_que.cid_free_cnt) {
+		rc = -EPERM;
+		goto check_busy;
+	}
 	cnic = hba->cnic;
-	mutex_lock(&hba->net_dev_lock);
 	ep = bnx2i_alloc_ep(hba);
 	if (!ep) {
 		rc = -ENOMEM;
@@ -1777,23 +1783,21 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	}
 	bnx2i_ep = ep->dd_data;
 
-	if (bnx2i_adapter_ready(hba)) {
-		rc = -EPERM;
-		goto net_if_down;
-	}
-
 	bnx2i_ep->num_active_cmds = 0;
 	iscsi_cid = bnx2i_alloc_iscsi_cid(hba);
 	if (iscsi_cid == -1) {
-		printk(KERN_ALERT "alloc_ep: unable to allocate iscsi cid\n");
+		printk(KERN_ALERT "bnx2i (%s): alloc_ep - unable to allocate "
+			"iscsi cid\n", hba->netdev->name);
 		rc = -ENOMEM;
-		goto iscsi_cid_err;
+		bnx2i_free_ep(ep);
+		goto check_busy;
 	}
 	bnx2i_ep->hba_age = hba->age;
 
 	rc = bnx2i_alloc_qp_resc(hba, bnx2i_ep);
 	if (rc != 0) {
-		printk(KERN_ALERT "bnx2i: ep_conn, alloc QP resc error\n");
+		printk(KERN_ALERT "bnx2i (%s): ep_conn - alloc QP resc error"
+			"\n", hba->netdev->name);
 		rc = -ENOMEM;
 		goto qp_resc_err;
 	}
@@ -1832,7 +1836,12 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	bnx2i_ep_ofld_list_del(hba, bnx2i_ep);
 
 	if (bnx2i_ep->state != EP_STATE_OFLD_COMPL) {
-		rc = -ENOSPC;
+		if (bnx2i_ep->state == EP_STATE_OFLD_FAILED_CID_BUSY) {
+			printk(KERN_ALERT "bnx2i (%s): iscsi cid %d is busy\n",
+				hba->netdev->name, bnx2i_ep->ep_iscsi_cid);
+			rc = -EBUSY;
+		} else
+			rc = -ENOSPC;
 		goto conn_failed;
 	}
 
@@ -1840,7 +1849,8 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 			     iscsi_cid, &bnx2i_ep->cm_sk, bnx2i_ep);
 	if (rc) {
 		rc = -EINVAL;
-		goto conn_failed;
+		/* Need to terminate and cleanup the connection */
+		goto release_ep;
 	}
 
 	bnx2i_ep->cm_sk->rcv_buf = 256 * 1024;
@@ -1884,8 +1894,6 @@ release_ep:
 		return ERR_PTR(rc);
 	}
 conn_failed:
-net_if_down:
-iscsi_cid_err:
 	bnx2i_free_qp_resc(hba, bnx2i_ep);
 qp_resc_err:
 	bnx2i_free_ep(ep);
@@ -2004,7 +2012,8 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 	if (!cnic)
 		return 0;
 
-	if (bnx2i_ep->state == EP_STATE_IDLE)
+	if (bnx2i_ep->state == EP_STATE_IDLE ||
+	    bnx2i_ep->state == EP_STATE_DISCONN_TIMEDOUT)
 		return 0;
 
 	if (!bnx2i_ep_tcp_conn_active(bnx2i_ep))
@@ -2030,9 +2039,10 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 			if (session->state == ISCSI_STATE_LOGGING_OUT) {
 				if (bnx2i_ep->state == EP_STATE_LOGOUT_SENT) {
 					/* Logout sent, but no resp */
-					printk(KERN_ALERT "bnx2i - WARNING "
-						"logout response was not "
-						"received!\n");
+					printk(KERN_ALERT "bnx2i (%s): WARNING"
+						" logout response was not "
+						"received!\n",
+						bnx2i_ep->hba->netdev->name);
 				} else if (bnx2i_ep->state ==
 					   EP_STATE_LOGOUT_RESP_RCVD)
 					close = 1;
@@ -2050,9 +2060,8 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 	else
 		close_ret = cnic->cm_abort(bnx2i_ep->cm_sk);
 
-	/* No longer allow CFC delete if cm_close/abort fails the request */
 	if (close_ret)
-		printk(KERN_ALERT "bnx2i: %s close/abort(%d) returned %d\n",
+		printk(KERN_ALERT "bnx2i (%s): close/abort(%d) returned %d\n",
 			bnx2i_ep->hba->netdev->name, close, close_ret);
 	else
 		/* wait for option-2 conn teardown */
@@ -2066,7 +2075,7 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 destroy_conn:
 	bnx2i_ep_active_list_del(hba, bnx2i_ep);
 	if (bnx2i_tear_down_conn(hba, bnx2i_ep))
-		ret = -EINVAL;
+		return -EINVAL;
 out:
 	bnx2i_ep->state = EP_STATE_IDLE;
 	return ret;
@@ -2105,14 +2114,17 @@ static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
 
 	mutex_lock(&hba->net_dev_lock);
 
-	if (bnx2i_ep->state == EP_STATE_IDLE)
-		goto return_bnx2i_ep;
+	if (bnx2i_ep->state == EP_STATE_DISCONN_TIMEDOUT)
+		goto out;
 
-	if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state))
+	if (bnx2i_ep->state == EP_STATE_IDLE)
 		goto free_resc;
 
-	if (bnx2i_ep->hba_age != hba->age)
+	if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state) ||
+	    (bnx2i_ep->hba_age != hba->age)) {
+		bnx2i_ep_active_list_del(hba, bnx2i_ep);
 		goto free_resc;
+	}
 
 	/* Do all chip cleanup here */
 	if (bnx2i_hw_ep_disconnect(bnx2i_ep)) {
@@ -2121,11 +2133,12 @@ static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
 	}
 free_resc:
 	bnx2i_free_qp_resc(hba, bnx2i_ep);
-return_bnx2i_ep:
+
 	if (bnx2i_conn)
 		bnx2i_conn->ep = NULL;
 
 	bnx2i_free_ep(ep);
+out:
 	mutex_unlock(&hba->net_dev_lock);
 	
 	wake_up_interruptible(&hba->eh_wait);
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 14/16] BNX2I: Allow to abort the connection if connect request times out
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (39 preceding siblings ...)
  2010-11-10 23:04 ` [PATCH 13/16] BNX2I: Cleaned up various error conditions in ep_connect/disconnect Eddie Wai
@ 2010-11-10 23:04 ` Eddie Wai
  2010-11-10 23:04 ` [PATCH 15/16] BNX2I: Updated copyright and maintainer info Eddie Wai
                   ` (68 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-10 23:04 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

In the situation where the connect completion response arrives after
the connect request has already timed out, the connection was not being
aborted but only the resource was being freed.  This creates a problem
for 5771X (10g) as the chip flags this with an assertion.

This change will properly aborts the connection before freeing the
resource.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index b3925c7..99af8ca 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1959,13 +1959,13 @@ static int bnx2i_ep_tcp_conn_active(struct bnx2i_endpoint *bnx2i_ep)
 		cnic_dev_10g = 1;
 
 	switch (bnx2i_ep->state) {
-	case EP_STATE_CONNECT_START:
 	case EP_STATE_CONNECT_FAILED:
 	case EP_STATE_CLEANUP_FAILED:
 	case EP_STATE_OFLD_FAILED:
 	case EP_STATE_DISCONN_TIMEDOUT:
 		ret = 0;
 		break;
+	case EP_STATE_CONNECT_START:
 	case EP_STATE_CONNECT_COMPL:
 	case EP_STATE_ULP_UPDATE_START:
 	case EP_STATE_ULP_UPDATE_COMPL:
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 15/16] BNX2I: Updated copyright and maintainer info
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (40 preceding siblings ...)
  2010-11-10 23:04 ` [PATCH 14/16] BNX2I: Allow to abort the connection if connect request times out Eddie Wai
@ 2010-11-10 23:04 ` Eddie Wai
  2010-11-10 23:04 ` [PATCH 16/16] BNX2I: Updated version to 2.6.2.2 Eddie Wai
                   ` (67 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-10 23:04 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/57xx_iscsi_constants.h |    3 ++-
 drivers/scsi/bnx2i/57xx_iscsi_hsi.h       |    3 ++-
 drivers/scsi/bnx2i/bnx2i.h                |    3 ++-
 drivers/scsi/bnx2i/bnx2i_hwi.c            |    3 ++-
 drivers/scsi/bnx2i/bnx2i_init.c           |    3 ++-
 drivers/scsi/bnx2i/bnx2i_iscsi.c          |    3 ++-
 drivers/scsi/bnx2i/bnx2i_sysfs.c          |    3 ++-
 7 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/bnx2i/57xx_iscsi_constants.h b/drivers/scsi/bnx2i/57xx_iscsi_constants.h
index 1b6f86b..30e6bdb 100644
--- a/drivers/scsi/bnx2i/57xx_iscsi_constants.h
+++ b/drivers/scsi/bnx2i/57xx_iscsi_constants.h
@@ -1,12 +1,13 @@
 /* 57xx_iscsi_constants.h: Broadcom NetXtreme II iSCSI HSI
  *
- * Copyright (c) 2006 - 2009 Broadcom Corporation
+ * Copyright (c) 2006 - 2010 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 #ifndef __57XX_ISCSI_CONSTANTS_H_
 #define __57XX_ISCSI_CONSTANTS_H_
diff --git a/drivers/scsi/bnx2i/57xx_iscsi_hsi.h b/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
index 36af1af..dad6c8a 100644
--- a/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
+++ b/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
@@ -1,12 +1,13 @@
 /* 57xx_iscsi_hsi.h: Broadcom NetXtreme II iSCSI HSI.
  *
- * Copyright (c) 2006 - 2009 Broadcom Corporation
+ * Copyright (c) 2006 - 2010 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 #ifndef __57XX_ISCSI_HSI_LINUX_LE__
 #define __57XX_ISCSI_HSI_LINUX_LE__
diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 72feb6c..f9719d4 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -1,6 +1,6 @@
 /* bnx2i.h: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2009 Broadcom Corporation
+ * Copyright (c) 2006 - 2010 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
@@ -9,6 +9,7 @@
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 
 #ifndef _BNX2I_H_
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index c577da6..b38d193 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1,6 +1,6 @@
 /* bnx2i_hwi.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2009 Broadcom Corporation
+ * Copyright (c) 2006 - 2010 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
@@ -9,6 +9,7 @@
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 
 #include <linux/gfp.h>
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 338caac..131ef80 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -1,6 +1,6 @@
 /* bnx2i.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2009 Broadcom Corporation
+ * Copyright (c) 2006 - 2010 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
@@ -9,6 +9,7 @@
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 
 #include "bnx2i.h"
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 99af8ca..b4856ad 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1,7 +1,7 @@
 /*
  * bnx2i_iscsi.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2009 Broadcom Corporation
+ * Copyright (c) 2006 - 2010 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
@@ -10,6 +10,7 @@
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 
 #include <linux/slab.h>
diff --git a/drivers/scsi/bnx2i/bnx2i_sysfs.c b/drivers/scsi/bnx2i/bnx2i_sysfs.c
index 96426b7..9174196 100644
--- a/drivers/scsi/bnx2i/bnx2i_sysfs.c
+++ b/drivers/scsi/bnx2i/bnx2i_sysfs.c
@@ -1,12 +1,13 @@
 /* bnx2i_sysfs.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2004 - 2009 Broadcom Corporation
+ * Copyright (c) 2004 - 2010 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 
 #include "bnx2i.h"
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 16/16] BNX2I: Updated version to 2.6.2.2
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (41 preceding siblings ...)
  2010-11-10 23:04 ` [PATCH 15/16] BNX2I: Updated copyright and maintainer info Eddie Wai
@ 2010-11-10 23:04 ` Eddie Wai
  2010-11-19  1:29 ` [PATCH 00/14] BNX2I: Patch set to fix various bug fixes Eddie Wai
                   ` (66 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-10 23:04 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_init.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 131ef80..99ca605 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -18,8 +18,8 @@ static struct list_head adapter_list = LIST_HEAD_INIT(adapter_list);
 static u32 adapter_count;
 
 #define DRV_MODULE_NAME		"bnx2i"
-#define DRV_MODULE_VERSION	"2.1.3"
-#define DRV_MODULE_RELDATE	"Aug 10, 2010"
+#define DRV_MODULE_VERSION	"2.6.2.2"
+#define DRV_MODULE_RELDATE	"Oct 28, 2010"
 
 static char version[] __devinitdata =
 		"Broadcom NetXtreme II iSCSI Driver " DRV_MODULE_NAME \
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH 04/16] BNX2I: Updated the handling of NETEVENTs to alleviate recovery
  2010-11-10 23:04 ` [PATCH 04/16] BNX2I: Updated the handling of NETEVENTs to alleviate recovery Eddie Wai
@ 2010-11-18  3:14   ` Mike Christie
  2010-11-18 18:25     ` Eddie Wai
  2010-11-18 18:28     ` Michael Chan
  0 siblings, 2 replies; 189+ messages in thread
From: Mike Christie @ 2010-11-18  3:14 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 11/10/2010 05:04 PM, Eddie Wai wrote:
>   	case NETDEV_GOING_DOWN:
> -		set_bit(ADAPTER_STATE_GOING_DOWN,&hba->adapter_state);
> -		iscsi_host_for_each_session(hba->shost,
> -					    bnx2i_drop_session);
> +		/* Suspend all data transmissions */
> +		for (i = 0; i<  hba->max_active_conns; i++) {
> +			bnx2i_conn = bnx2i_get_conn_from_id(hba, i);
> +			if (bnx2i_conn) {
> +				conn = bnx2i_conn->cls_conn->dd_data;
> +				session = conn->session;
> +				spin_lock_irqsave(&session->lock, flags);
> +				bnx2i_conn->prev_sess_state = session->state;
> +				if (conn->stop_stage == 0)
> +					session->state = ISCSI_STATE_FAILED;
> +				spin_unlock_irqrestore(&session->lock, flags);
> +				iscsi_suspend_queue(conn);
> +				set_bit(ISCSI_SUSPEND_BIT,&conn->suspend_rx);


How do you go from going down to down? What happens (does net layer 
shutdown connections running and have the net driver clean something 
up)? How long does it take?

You should not be digging into the session state and conn stop_stage and 
probably the suspend_rx bit.

Add some libiscsi function that just calls something like 
iscsi_conn_failure that does not initiate recovery. So basically just mv 
everything but the iscsi_conn_error_event call in iscsi_conn_failure to 
some new function iscsi_conn_suspend. Have iscsi_conn_failure call 
iscsi_conn_suspend and iscsi_conn_error_event, and then have your driver 
call iscsi_conn_suspend.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 06/16] BNX2I: Added code to handle the binding of an existing connection
  2010-11-10 23:04 ` [PATCH 06/16] BNX2I: Added code to handle the binding of an existing connection Eddie Wai
@ 2010-11-18  3:24   ` Mike Christie
  2011-01-02  4:11     ` Mike Christie
  0 siblings, 1 reply; 189+ messages in thread
From: Mike Christie @ 2010-11-18  3:24 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 11/10/2010 05:04 PM, Eddie Wai wrote:
> This is the case when iscsid gets re-launched due to features like
> iSCSI boot which requires the daemon to re-launch due to
> pivot root.  If the code detected the connection had an existing
> endpoint, the old endpoint must get cleaned up.
>
> Signed-off-by: Eddie Wai<eddie.wai@broadcom.com>
> Acked-by: Anil Veerabhadrappa<anilgv@broadcom.com>
> ---
>   drivers/scsi/bnx2i/bnx2i_iscsi.c |    7 +++++++
>   1 files changed, 7 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
> index 823e4fa..3b65c64 100644
> --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
> +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
> @@ -1410,6 +1410,13 @@ static int bnx2i_conn_bind(struct iscsi_cls_session *cls_session,
>   				  hba->netdev->name);
>   		return -EEXIST;
>   	}
> +	if (bnx2i_conn->ep) {
> +		printk(KERN_ALERT "bnx2i: Binding to an existing endpoint "
> +			"detected.  Disconnecting the old...\n");
> +		mutex_lock(&hba->net_dev_lock);
> +		bnx2i_hw_ep_disconnect(bnx2i_conn->ep);
> +		mutex_unlock(&hba->net_dev_lock);
> +	}
>   	bnx2i_ep->conn = bnx2i_conn;
>   	bnx2i_conn->ep = bnx2i_ep;
>   	bnx2i_conn->iscsi_conn_cid = bnx2i_ep->ep_iscsi_cid;

Don't you still leak what bnx2i_free_ep frees?

In userspace you should have iscsid/iscsi_sync_session match the iscsi 
endpoint with the iscsi conn and set transport_ep_handle. ep_disconnect 
will then get called like normal to clean up the old connection.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 08/16] BNX2I: Added mutex lock protection to conn_get_param
  2010-11-10 23:04   ` [PATCH 08/16] BNX2I: Added mutex lock protection to conn_get_param Eddie Wai
@ 2010-11-18  3:27     ` Mike Christie
  2010-11-18 19:08       ` Eddie Wai
  0 siblings, 1 reply; 189+ messages in thread
From: Mike Christie @ 2010-11-18  3:27 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 11/10/2010 05:04 PM, Eddie Wai wrote:
> -		return iscsi_conn_get_param(cls_conn, param, buf);
> +		len = iscsi_conn_get_param(cls_conn, param, buf);
> +		if (len == -ENOSYS)
> +			len = 0;

Why are you returning 0 here?


^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 09/16] BNX2I: Removed the dynamic registration of CNIC
  2010-11-10 23:04 ` [PATCH 09/16] BNX2I: Removed the dynamic registration of CNIC Eddie Wai
@ 2010-11-18  3:29   ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2010-11-18  3:29 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 11/10/2010 05:04 PM, Eddie Wai wrote:
> The code no longer needs to dynamically register and unregister
> the CNIC device.  The CNIC device will be kept registered until
> module unload.
>

trailing whitespace in the patch.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 12/16] BNX2I: Added feature to silently drop NOPOUT request
  2010-11-10 23:04 ` [PATCH 12/16] BNX2I: Added feature to silently drop NOPOUT request Eddie Wai
@ 2010-11-18  3:40   ` Mike Christie
  2010-11-18 19:25     ` Eddie Wai
  0 siblings, 1 reply; 189+ messages in thread
From: Mike Christie @ 2010-11-18  3:40 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 11/10/2010 05:04 PM, Eddie Wai wrote:
> In the case the chip is undergoing different invasive operation
> which requires a chip reset, all NOPOUT request during this period

For these invasive operations that reset the chip, do we always end up 
having to relogin the connection/session or once the reset is done are 
we able to just go on happily like nothing ever happened?

> must be silently dropped from queuing to the hardware.  This patch
> will respond to libiscsi immediately with sent success.  Since the
> request was not actually sent, the NOPIN wait timeout will get
> triggered and another NOPOUT request will commence through the
> proper channel.
>
> Signed-off-by: Eddie Wai<eddie.wai@broadcom.com>
> Acked-by: Anil Veerabhadrappa<anilgv@broadcom.com>
> ---
>   drivers/scsi/bnx2i/bnx2i_iscsi.c |   16 ++++++++++++++++
>   1 files changed, 16 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
> index b32baf8..507cd25 100644
> --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
> +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
> @@ -1068,6 +1068,22 @@ static int bnx2i_iscsi_send_generic_request(struct iscsi_task *task)
>   	char *buf;
>   	int data_len;
>
> +	/*
> +	 * Forcefully terminate all in progress connection recovery at the
> +	 * earliest, either in bind(), send_pdu(LOGIN), or conn_start()
> +	 */
> +	if (bnx2i_adapter_ready(bnx2i_conn->ep->hba)) {
> +		if ((task->hdr->opcode&  ISCSI_OPCODE_MASK) ==
> +		    ISCSI_OP_NOOP_OUT)
> +			/* This is a WA to indicate to libiscsi that the nopout
> +			 * request was sent successfully without actually
> +			 * submitting to the hardware.
> +			 * Just silently drop the nopout request
> +			 */
> +			return 0;
> +		else
> +			return -EIO;
> +	}
>   	bnx2i_iscsi_prep_generic_pdu_bd(bnx2i_conn);
>   	switch (task->hdr->opcode&  ISCSI_OPCODE_MASK) {
>   	case ISCSI_OP_LOGIN:


^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 04/16] BNX2I: Updated the handling of NETEVENTs to alleviate recovery
  2010-11-18  3:14   ` Mike Christie
@ 2010-11-18 18:25     ` Eddie Wai
  2010-11-18 18:28     ` Michael Chan
  1 sibling, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-18 18:25 UTC (permalink / raw)
  To: Mike Christie
  Cc: Eddie Wai, James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Benjamin Li

On Wed, 2010-11-17 at 19:14 -0800, Mike Christie wrote:
> On 11/10/2010 05:04 PM, Eddie Wai wrote:
> >   	case NETDEV_GOING_DOWN:
> > -		set_bit(ADAPTER_STATE_GOING_DOWN,&hba->adapter_state);
> > -		iscsi_host_for_each_session(hba->shost,
> > -					    bnx2i_drop_session);
> > +		/* Suspend all data transmissions */
> > +		for (i = 0; i<  hba->max_active_conns; i++) {
> > +			bnx2i_conn = bnx2i_get_conn_from_id(hba, i);
> > +			if (bnx2i_conn) {
> > +				conn = bnx2i_conn->cls_conn->dd_data;
> > +				session = conn->session;
> > +				spin_lock_irqsave(&session->lock, flags);
> > +				bnx2i_conn->prev_sess_state = session->state;
> > +				if (conn->stop_stage == 0)
> > +					session->state = ISCSI_STATE_FAILED;
> > +				spin_unlock_irqrestore(&session->lock, flags);
> > +				iscsi_suspend_queue(conn);
> > +				set_bit(ISCSI_SUSPEND_BIT,&conn->suspend_rx);
> 
> 
> How do you go from going down to down? What happens (does net layer 
> shutdown connections running and have the net driver clean something 
> up)? How long does it take?
All upper layer clean up will be conducted in another code path from the net layer via cnic.
This will do the actual iSCSI connection cleanup.
> You should not be digging into the session state and conn stop_stage and 
> probably the suspend_rx bit.
> 
> Add some libiscsi function that just calls something like 
> iscsi_conn_failure that does not initiate recovery. So basically just mv 
> everything but the iscsi_conn_error_event call in iscsi_conn_failure to 
> some new function iscsi_conn_suspend. Have iscsi_conn_failure call 
> iscsi_conn_suspend and iscsi_conn_error_event, and then have your driver 
> call iscsi_conn_suspend.
> 
Agreed.  Modifying the iscsi_conn_failure is a better solution.  We'll
defer this change for now.

Thanks,
Eddie



^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 04/16] BNX2I: Updated the handling of NETEVENTs to alleviate recovery
  2010-11-18  3:14   ` Mike Christie
  2010-11-18 18:25     ` Eddie Wai
@ 2010-11-18 18:28     ` Michael Chan
  1 sibling, 0 replies; 189+ messages in thread
From: Michael Chan @ 2010-11-18 18:28 UTC (permalink / raw)
  To: Mike Christie
  Cc: Eddie Wai, James Bottomley, open-iscsi, linux-scsi,
	Anil Veerabhadrappa, Benjamin Li


On Wed, 2010-11-17 at 19:14 -0800, Mike Christie wrote:
> On 11/10/2010 05:04 PM, Eddie Wai wrote:
> >   	case NETDEV_GOING_DOWN:
> > -		set_bit(ADAPTER_STATE_GOING_DOWN,&hba->adapter_state);
> > -		iscsi_host_for_each_session(hba->shost,
> > -					    bnx2i_drop_session);
> > +		/* Suspend all data transmissions */
> > +		for (i = 0; i<  hba->max_active_conns; i++) {
> > +			bnx2i_conn = bnx2i_get_conn_from_id(hba, i);
> > +			if (bnx2i_conn) {
> > +				conn = bnx2i_conn->cls_conn->dd_data;
> > +				session = conn->session;
> > +				spin_lock_irqsave(&session->lock, flags);
> > +				bnx2i_conn->prev_sess_state = session->state;
> > +				if (conn->stop_stage == 0)
> > +					session->state = ISCSI_STATE_FAILED;
> > +				spin_unlock_irqrestore(&session->lock, flags);
> > +				iscsi_suspend_queue(conn);
> > +				set_bit(ISCSI_SUSPEND_BIT,&conn->suspend_rx);
> 
> 
> How do you go from going down to down? What happens (does net layer 
> shutdown connections running and have the net driver clean something 
> up)? How long does it take?

net layer will just stop transmitting on devices that are down.  But
with iSCSI connections offloaded to our chips, these connections must be
terminated and deleted before the net driver resets the chip.
Otherwise, the chip won't come up correctly after reset.

> 
> You should not be digging into the session state and conn stop_stage and 
> probably the suspend_rx bit.
> 
> Add some libiscsi function that just calls something like 
> iscsi_conn_failure that does not initiate recovery. So basically just mv 
> everything but the iscsi_conn_error_event call in iscsi_conn_failure to 
> some new function iscsi_conn_suspend. Have iscsi_conn_failure call 
> iscsi_conn_suspend and iscsi_conn_error_event, and then have your driver 
> call iscsi_conn_suspend.
> 



^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 08/16] BNX2I: Added mutex lock protection to conn_get_param
  2010-11-18  3:27     ` Mike Christie
@ 2010-11-18 19:08       ` Eddie Wai
  0 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-18 19:08 UTC (permalink / raw)
  To: Mike Christie
  Cc: Eddie Wai, James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Benjamin Li


On Wed, 2010-11-17 at 19:27 -0800, Mike Christie wrote:
> On 11/10/2010 05:04 PM, Eddie Wai wrote:
> > -		return iscsi_conn_get_param(cls_conn, param, buf);
> > +		len = iscsi_conn_get_param(cls_conn, param, buf);
> > +		if (len == -ENOSYS)
> > +			len = 0;
> 
> Why are you returning 0 here?
> 
Looks like returning -ENOSYS as-is is the expected behavior as cross
referenced to iscsi_tcp.  I'll remove this.  Thanks.  
> 



^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 12/16] BNX2I: Added feature to silently drop NOPOUT request
  2010-11-18  3:40   ` Mike Christie
@ 2010-11-18 19:25     ` Eddie Wai
  2010-11-18 19:55       ` Mike Christie
  0 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-11-18 19:25 UTC (permalink / raw)
  To: Mike Christie
  Cc: Eddie Wai, James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Benjamin Li


On Wed, 2010-11-17 at 19:40 -0800, Mike Christie wrote:
> On 11/10/2010 05:04 PM, Eddie Wai wrote:
> > In the case the chip is undergoing different invasive operation
> > which requires a chip reset, all NOPOUT request during this period
> 
> For these invasive operations that reset the chip, do we always end up 
> having to relogin the connection/session or once the reset is done are 
> we able to just go on happily like nothing ever happened?
Operations like mtu change/ifupdown/etc will require the chip to undergo
reset.  Prior to this, the connections will be cleaned up via the
conn_failure->ep_disconnect path and eventually put into the reopen
recovery path.  During this period, we must disallow any send pdu
requests to be queued to the chip for a more immediately connection tear
down time (so we don't have to wait for the pdu's completion).

We had to treat NOPOUT requests differently as the routine in libiscsi
would continuously loop until the NOPOUT send request returns with
success.  This is the why we added the NOPOUT workaround.

Once the chip reset is completed, the ep_connect requests from the
recovery path will be honored and the pre-existed connections will get
re-established.  
> 
> > must be silently dropped from queuing to the hardware.  This patch
> > will respond to libiscsi immediately with sent success.  Since the
> > request was not actually sent, the NOPIN wait timeout will get
> > triggered and another NOPOUT request will commence through the
> > proper channel.
> >
> > Signed-off-by: Eddie Wai<eddie.wai@broadcom.com>
> > Acked-by: Anil Veerabhadrappa<anilgv@broadcom.com>
> > ---
> >   drivers/scsi/bnx2i/bnx2i_iscsi.c |   16 ++++++++++++++++
> >   1 files changed, 16 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
> > index b32baf8..507cd25 100644
> > --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
> > +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
> > @@ -1068,6 +1068,22 @@ static int bnx2i_iscsi_send_generic_request(struct iscsi_task *task)
> >   	char *buf;
> >   	int data_len;
> >
> > +	/*
> > +	 * Forcefully terminate all in progress connection recovery at the
> > +	 * earliest, either in bind(), send_pdu(LOGIN), or conn_start()
> > +	 */
> > +	if (bnx2i_adapter_ready(bnx2i_conn->ep->hba)) {
> > +		if ((task->hdr->opcode&  ISCSI_OPCODE_MASK) ==
> > +		    ISCSI_OP_NOOP_OUT)
> > +			/* This is a WA to indicate to libiscsi that the nopout
> > +			 * request was sent successfully without actually
> > +			 * submitting to the hardware.
> > +			 * Just silently drop the nopout request
> > +			 */
> > +			return 0;
> > +		else
> > +			return -EIO;
> > +	}
> >   	bnx2i_iscsi_prep_generic_pdu_bd(bnx2i_conn);
> >   	switch (task->hdr->opcode&  ISCSI_OPCODE_MASK) {
> >   	case ISCSI_OP_LOGIN:
> 
> 



^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 12/16] BNX2I: Added feature to silently drop NOPOUT request
  2010-11-18 19:25     ` Eddie Wai
@ 2010-11-18 19:55       ` Mike Christie
       [not found]         ` <4CE584C6.7070300-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>
  0 siblings, 1 reply; 189+ messages in thread
From: Mike Christie @ 2010-11-18 19:55 UTC (permalink / raw)
  To: open-iscsi
  Cc: Eddie Wai, Eddie Wai, James Bottomley, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Benjamin Li

On 11/18/2010 01:25 PM, Eddie Wai wrote:
>
> On Wed, 2010-11-17 at 19:40 -0800, Mike Christie wrote:
>> On 11/10/2010 05:04 PM, Eddie Wai wrote:
>>> In the case the chip is undergoing different invasive operation
>>> which requires a chip reset, all NOPOUT request during this period
>>
>> For these invasive operations that reset the chip, do we always end up
>> having to relogin the connection/session or once the reset is done are
>> we able to just go on happily like nothing ever happened?
> Operations like mtu change/ifupdown/etc will require the chip to undergo
> reset.  Prior to this, the connections will be cleaned up via the
> conn_failure->ep_disconnect path and eventually put into the reopen
> recovery path.  During this period, we must disallow any send pdu
> requests to be queued to the chip for a more immediately connection tear
> down time (so we don't have to wait for the pdu's completion).
>
> We had to treat NOPOUT requests differently as the routine in libiscsi
> would continuously loop until the NOPOUT send request returns with
> success.  This is the why we added the NOPOUT workaround.

At this time, have you already called iscsi_conn or session failure? If 
so then I think it sounds like there is bug in iscsi_send_nopout or 
__iscsi_conn_send_pdu. If the conn/session has been failed, I think we 
want to add a check in __iscsi_conn_send_pdu where if the conn/session 
is down then we do not send NOPs. There is no point iSCSI RFC wise and 
it screws up drivers.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 12/16] BNX2I: Added feature to silently drop NOPOUT request
       [not found]         ` <4CE584C6.7070300-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>
@ 2010-11-18 20:04           ` Mike Christie
  2010-11-18 21:59             ` Eddie Wai
  0 siblings, 1 reply; 189+ messages in thread
From: Mike Christie @ 2010-11-18 20:04 UTC (permalink / raw)
  To: open-iscsi-/JYPxA39Uh5TLH3MbocFFw
  Cc: Eddie Wai, Eddie Wai, James Bottomley, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Benjamin Li

On 11/18/2010 01:55 PM, Mike Christie wrote:
> On 11/18/2010 01:25 PM, Eddie Wai wrote:
>>
>> On Wed, 2010-11-17 at 19:40 -0800, Mike Christie wrote:
>>> On 11/10/2010 05:04 PM, Eddie Wai wrote:
>>>> In the case the chip is undergoing different invasive operation
>>>> which requires a chip reset, all NOPOUT request during this period
>>>
>>> For these invasive operations that reset the chip, do we always end up
>>> having to relogin the connection/session or once the reset is done are
>>> we able to just go on happily like nothing ever happened?
>> Operations like mtu change/ifupdown/etc will require the chip to undergo
>> reset. Prior to this, the connections will be cleaned up via the
>> conn_failure->ep_disconnect path and eventually put into the reopen
>> recovery path. During this period, we must disallow any send pdu
>> requests to be queued to the chip for a more immediately connection tear
>> down time (so we don't have to wait for the pdu's completion).
>>
>> We had to treat NOPOUT requests differently as the routine in libiscsi
>> would continuously loop until the NOPOUT send request returns with
>> success. This is the why we added the NOPOUT workaround.
>
> At this time, have you already called iscsi_conn or session failure? If
> so then I think it sounds like there is bug in iscsi_send_nopout or
> __iscsi_conn_send_pdu. If the conn/session has been failed, I think we
> want to add a check in __iscsi_conn_send_pdu where if the conn/session
> is down then we do not send NOPs. There is no point iSCSI RFC wise and
> it screws up drivers.

We actually have a check in __iscsi_conn_send_pdu. There is the 
session->state == ISCSI_STATE_LOGGED_IN, so I guess you have not called 
one of the iscsi failure functions.

At this time, is just the apdater_state getting changed? What code path 
is that?

Maybe related... For bnx2i_get_link_state ADAPTER_STATE_LINK_DOWN, I 
think you will want to call the iscsi_suspend_queue function discussed 
in the other mail. When the link state comes back up though, do we 
always have to reconnect and relogin to the target or are their cases 
where we can just restart the queues?

-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 12/16] BNX2I: Added feature to silently drop NOPOUT request
  2010-11-18 20:04           ` Mike Christie
@ 2010-11-18 21:59             ` Eddie Wai
  2010-11-20  5:07               ` Mike Christie
  0 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-11-18 21:59 UTC (permalink / raw)
  To: Mike Christie
  Cc: open-iscsi, Eddie Wai, James Bottomley, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Benjamin Li


On Thu, 2010-11-18 at 12:04 -0800, Mike Christie wrote:
> On 11/18/2010 01:55 PM, Mike Christie wrote:
> > On 11/18/2010 01:25 PM, Eddie Wai wrote:
> >>
> >> On Wed, 2010-11-17 at 19:40 -0800, Mike Christie wrote:
> >>> On 11/10/2010 05:04 PM, Eddie Wai wrote:
> >>>> In the case the chip is undergoing different invasive operation
> >>>> which requires a chip reset, all NOPOUT request during this period
> >>>
> >>> For these invasive operations that reset the chip, do we always end up
> >>> having to relogin the connection/session or once the reset is done are
> >>> we able to just go on happily like nothing ever happened?
> >> Operations like mtu change/ifupdown/etc will require the chip to undergo
> >> reset. Prior to this, the connections will be cleaned up via the
> >> conn_failure->ep_disconnect path and eventually put into the reopen
> >> recovery path. During this period, we must disallow any send pdu
> >> requests to be queued to the chip for a more immediately connection tear
> >> down time (so we don't have to wait for the pdu's completion).
> >>
> >> We had to treat NOPOUT requests differently as the routine in libiscsi
> >> would continuously loop until the NOPOUT send request returns with
> >> success. This is the why we added the NOPOUT workaround.
> >
> > At this time, have you already called iscsi_conn or session failure? If
> > so then I think it sounds like there is bug in iscsi_send_nopout or
> > __iscsi_conn_send_pdu. If the conn/session has been failed, I think we
> > want to add a check in __iscsi_conn_send_pdu where if the conn/session
> > is down then we do not send NOPs. There is no point iSCSI RFC wise and
> > it screws up drivers.
> 
> We actually have a check in __iscsi_conn_send_pdu. There is the 
> session->state == ISCSI_STATE_LOGGED_IN, so I guess you have not called 
> one of the iscsi failure functions.
> 
The check is correct, but its just that the conn failures were not being
called prior to these inflight send_pdu calls.  We want to terminate
these calls immediately before they get queued up to the chip.

As for the NOPOUT requests, since the NOPOUT send request failed, the
last_ping jiffies count would not get updated.  Then the
iscsi_check_transport_timeouts callback will just keeps getting called
and stalling the system.

Perhaps a better way to do this is to allow the last_ping jiffies to be
updated but use a different ping_timeout value for failed nopout ping
conditions.

> At this time, is just the apdater_state getting changed? What code path 
> is that?
> 
> Maybe related... For bnx2i_get_link_state ADAPTER_STATE_LINK_DOWN, I 
> think you will want to call the iscsi_suspend_queue function discussed 
> in the other mail. When the link state comes back up though, do we 
> always have to reconnect and relogin to the target or are their cases 
> where we can just restart the queues?
> 



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 00/14] BNX2I: Patch set to fix various bug fixes
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (42 preceding siblings ...)
  2010-11-10 23:04 ` [PATCH 16/16] BNX2I: Updated version to 2.6.2.2 Eddie Wai
@ 2010-11-19  1:29 ` Eddie Wai
  2010-11-19  1:29 ` [PATCH v2 01/14] BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins Eddie Wai
                   ` (65 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-19  1:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Hello,

>This patch set contains various bug fixes as categorized in the following:
>- scsi command handling (nop-ins, tmfs)
>- various connection clean up bug fixes
In v2, the following patches are modified based on Mike Christie's comments:
  BNX2I: Added mutex lock protection to conn_get_param (rm ret 0)
  BNX2I: Removed the dynamic registration of CNIC (trailing space)

These patches were removed pending better resolution:
  BNX2I: Updated the handling of NETEVENTs to alleviate recovery
  BNX2I: Added code to handle the binding of an existing connection

Your comments are grealy appreciated.  Please review, thanks.

Eddie

Eddie Wai (14):
  BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins
  BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In
  BNX2I: Fixed the endian bug in the TMF LUN cmd send
  BNX2I: Fixed a cid leak issue for 5771X (10g)
  BNX2I: Fixed the remote TCP RST handling for the 570X (1g)
  BNX2I: Allow to abort the connection if connect request times out
  BNX2I: Added mutex lock protection to conn_get_param
  BNX2I: Removed the dynamic registration of CNIC
  BNX2I: Modified the bnx2i stop path to compensate for in progress ops
  BNX2I: Added return code check for chip kwqe submission request
  BNX2I: Added feature to silently drop NOPOUT request
  BNX2I: Cleaned up various error conditions in ep_connect/disconnect
  BNX2I: Updated copyright and maintainer info
  BNX2I: Updated version to 2.6.2.1

 drivers/scsi/bnx2i/57xx_iscsi_constants.h |    3 +-
 drivers/scsi/bnx2i/57xx_iscsi_hsi.h       |    3 +-
 drivers/scsi/bnx2i/bnx2i.h                |   15 ++--
 drivers/scsi/bnx2i/bnx2i_hwi.c            |   99 +++++++++++++-----
 drivers/scsi/bnx2i/bnx2i_init.c           |  108 ++++---------------
 drivers/scsi/bnx2i/bnx2i_iscsi.c          |  164 +++++++++++++++++++----------
 drivers/scsi/bnx2i/bnx2i_sysfs.c          |    3 +-
 drivers/scsi/libiscsi.c                   |    3 +-
 include/scsi/libiscsi.h                   |    1 +
 9 files changed, 216 insertions(+), 183 deletions(-)



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH v2 01/14] BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (43 preceding siblings ...)
  2010-11-19  1:29 ` [PATCH 00/14] BNX2I: Patch set to fix various bug fixes Eddie Wai
@ 2010-11-19  1:29 ` Eddie Wai
  2010-11-19  1:29 ` [PATCH v2 02/14] BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In Eddie Wai
                   ` (64 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-19  1:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Unsolicited NOP-Ins are placed in the receive queue of the hardware
which requires to be read out regardless if the receive pipe is suspended
or not.  This patch adds the disposal of this RQ element under this
condition.
Also fixed the bug in the unsolicited NOP-In handling routine which
checks for the RESERVED_ITT.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 8d9dbb3..16c76e0 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1549,11 +1549,9 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session,
 	struct iscsi_task *task;
 	struct bnx2i_nop_in_msg *nop_in;
 	struct iscsi_nopin *hdr;
-	u32 itt;
 	int tgt_async_nop = 0;
 
 	nop_in = (struct bnx2i_nop_in_msg *)cqe;
-	itt = nop_in->itt & ISCSI_NOP_IN_MSG_INDEX;
 
 	spin_lock(&session->lock);
 	hdr = (struct iscsi_nopin *)&bnx2i_conn->gen_pdu.resp_hdr;
@@ -1563,7 +1561,7 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session,
 	hdr->exp_cmdsn = cpu_to_be32(nop_in->exp_cmd_sn);
 	hdr->ttt = cpu_to_be32(nop_in->ttt);
 
-	if (itt == (u16) RESERVED_ITT) {
+	if (nop_in->itt == (u16) RESERVED_ITT) {
 		bnx2i_unsol_pdu_adjust_rq(bnx2i_conn);
 		hdr->itt = RESERVED_ITT;
 		tgt_async_nop = 1;
@@ -1571,7 +1569,8 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session,
 	}
 
 	/* this is a response to one of our nop-outs */
-	task = iscsi_itt_to_task(conn, itt);
+	task = iscsi_itt_to_task(conn,
+			 (itt_t) (nop_in->itt & ISCSI_NOP_IN_MSG_INDEX));
 	if (task) {
 		hdr->flags = ISCSI_FLAG_CMD_FINAL;
 		hdr->itt = task->hdr->itt;
@@ -1721,9 +1720,18 @@ static void bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
 		if (nopin->cq_req_sn != qp->cqe_exp_seq_sn)
 			break;
 
-		if (unlikely(test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx)))
+		if (unlikely(test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx))) {
+			if (nopin->op_code == ISCSI_OP_NOOP_IN &&
+			    nopin->itt == (u16) RESERVED_ITT) {
+				printk(KERN_ALERT "bnx2i: Unsolicited "
+					"NOP-In detected for suspended "
+					"connection dev=%s!\n",
+					bnx2i_conn->hba->netdev->name);
+				bnx2i_unsol_pdu_adjust_rq(bnx2i_conn);
+				goto cqe_out;
+			}
 			break;
-
+		}
 		tgt_async_msg = 0;
 
 		switch (nopin->op_code) {
@@ -1770,10 +1778,9 @@ static void bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
 			printk(KERN_ALERT "bnx2i: unknown opcode 0x%x\n",
 					  nopin->op_code);
 		}
-
 		if (!tgt_async_msg)
 			bnx2i_conn->ep->num_active_cmds--;
-
+cqe_out:
 		/* clear out in production version only, till beta keep opcode
 		 * field intact, will be helpful in debugging (context dump)
 		 * nopin->op_code = 0;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v2 02/14] BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (44 preceding siblings ...)
  2010-11-19  1:29 ` [PATCH v2 01/14] BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins Eddie Wai
@ 2010-11-19  1:29 ` Eddie Wai
  2010-11-19  1:29 ` [PATCH v2 03/14] BNX2I: Fixed the endian bug in the TMF LUN cmd send Eddie Wai
                   ` (63 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-19  1:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The patch fixes the following situations where NOP-Out pkt is called for:
- local unsolicited NOP-Out requests (requesting no NOP-In response)
- local NOP-Out responses to unsolicited NOP-In requests

kernel panic is observed due to double session spin_lock requests; one in the
bnx2i_process_nopin_local_cmpl routine in bnx2i_hwi.c and the other in the
iscsi_put_task routine in libiscsi.c

The proposed fix is to export the currently static __iscsi_put_task() routine
and have bnx2i call it directly instead of the iscsi_put_task() routine which
holds the session spin lock.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Acked-by: Benjamin Li <benli@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |    2 +-
 drivers/scsi/libiscsi.c        |    3 ++-
 include/scsi/libiscsi.h        |    1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 16c76e0..32cf930 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1513,7 +1513,7 @@ static void bnx2i_process_nopin_local_cmpl(struct iscsi_session *session,
 	task = iscsi_itt_to_task(conn,
 				 nop_in->itt & ISCSI_NOP_IN_MSG_INDEX);
 	if (task)
-		iscsi_put_task(task);
+		__iscsi_put_task(task);
 	spin_unlock(&session->lock);
 }
 
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 633e090..b63e2a4 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -539,11 +539,12 @@ void __iscsi_get_task(struct iscsi_task *task)
 }
 EXPORT_SYMBOL_GPL(__iscsi_get_task);
 
-static void __iscsi_put_task(struct iscsi_task *task)
+void __iscsi_put_task(struct iscsi_task *task)
 {
 	if (atomic_dec_and_test(&task->refcount))
 		iscsi_free_task(task);
 }
+EXPORT_SYMBOL_GPL(__iscsi_put_task);
 
 void iscsi_put_task(struct iscsi_task *task)
 {
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index ae5196a..2ea9aec 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -420,6 +420,7 @@ extern struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *, itt_t);
 extern struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *, itt_t);
 extern void iscsi_requeue_task(struct iscsi_task *task);
 extern void iscsi_put_task(struct iscsi_task *task);
+extern void __iscsi_put_task(struct iscsi_task *task);
 extern void __iscsi_get_task(struct iscsi_task *task);
 extern void iscsi_complete_scsi_task(struct iscsi_task *task,
 				     uint32_t exp_cmdsn, uint32_t max_cmdsn);
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v2 03/14] BNX2I: Fixed the endian bug in the TMF LUN cmd send
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (45 preceding siblings ...)
  2010-11-19  1:29 ` [PATCH v2 02/14] BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In Eddie Wai
@ 2010-11-19  1:29 ` Eddie Wai
  2010-11-19  1:29 ` [PATCH v2 04/14] BNX2I: Fixed a cid leak issue for 5771X (10g) Eddie Wai
                   ` (62 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-19  1:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Added a be32_to_cpu call for the TMF LUN wqe.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 32cf930..c9a3c0f 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -385,6 +385,7 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn,
 	struct bnx2i_cmd *bnx2i_cmd;
 	struct bnx2i_tmf_request *tmfabort_wqe;
 	u32 dword;
+	u32 scsi_lun[2];
 
 	bnx2i_cmd = (struct bnx2i_cmd *)mtask->dd_data;
 	tmfabort_hdr = (struct iscsi_tm *)mtask->hdr;
@@ -426,7 +427,10 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn,
 	default:
 		tmfabort_wqe->ref_itt = RESERVED_ITT;
 	}
-	memcpy(tmfabort_wqe->lun, tmfabort_hdr->lun, sizeof(struct scsi_lun));
+	memcpy(scsi_lun, tmfabort_hdr->lun, sizeof(struct scsi_lun));
+	tmfabort_wqe->lun[0] = be32_to_cpu(scsi_lun[0]);
+	tmfabort_wqe->lun[1] = be32_to_cpu(scsi_lun[1]);
+
 	tmfabort_wqe->ref_cmd_sn = be32_to_cpu(tmfabort_hdr->refcmdsn);
 
 	tmfabort_wqe->bd_list_addr_lo = (u32) bnx2i_conn->hba->mp_bd_dma;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v2 04/14] BNX2I: Fixed a cid leak issue for 5771X (10g)
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (46 preceding siblings ...)
  2010-11-19  1:29 ` [PATCH v2 03/14] BNX2I: Fixed the endian bug in the TMF LUN cmd send Eddie Wai
@ 2010-11-19  1:29 ` Eddie Wai
  2010-11-19  1:30 ` [PATCH v2 05/14] BNX2I: Fixed the remote TCP RST handling for the 570X (1g) Eddie Wai
                   ` (61 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-19  1:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

A cid leak issue was found when the connect destroy request exceeded
the driver's disconnection timeout.  This will lead to a cid resource
leak issue.
The fix is to allow the cid cleanup even when this happens.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index fb50efb..b766812 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1640,18 +1640,26 @@ no_nx2_route:
 static int bnx2i_tear_down_conn(struct bnx2i_hba *hba,
 				 struct bnx2i_endpoint *ep)
 {
-	if (test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic))
+	if (test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic) && ep->cm_sk)
 		hba->cnic->cm_destroy(ep->cm_sk);
 
-	if (test_bit(ADAPTER_STATE_GOING_DOWN, &ep->hba->adapter_state))
-		ep->state = EP_STATE_DISCONN_COMPL;
-
 	if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type) &&
 	    ep->state == EP_STATE_DISCONN_TIMEDOUT) {
-		printk(KERN_ALERT "bnx2i - ERROR - please submit GRC Dump,"
-				  " NW/PCIe trace, driver msgs to developers"
-				  " for analysis\n");
-		return 1;
+		if (ep->conn && ep->conn->cls_conn &&
+		    ep->conn->cls_conn->dd_data) {
+			struct iscsi_conn *conn = ep->conn->cls_conn->dd_data;
+
+			/* Must suspend all rx queue activity for this ep */
+			set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
+		}
+		/* CONN_DISCONNECT timeout may or may not be an issue depending
+		 * on what transcribed in TCP layer, different targets behave
+		 * differently
+		 */
+		printk(KERN_ALERT "bnx2i (%s): - WARN - CONN_DISCON timed out, "
+				  "please submit GRC Dump, NW/PCIe trace, "
+				  "driver msgs to developers for analysis\n",
+				  hba->netdev->name);
 	}
 
 	ep->state = EP_STATE_CLEANUP_START;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v2 05/14] BNX2I: Fixed the remote TCP RST handling for the 570X (1g)
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (47 preceding siblings ...)
  2010-11-19  1:29 ` [PATCH v2 04/14] BNX2I: Fixed a cid leak issue for 5771X (10g) Eddie Wai
@ 2010-11-19  1:30 ` Eddie Wai
  2010-11-19  1:30 ` [PATCH v2 06/14] BNX2I: Allow to abort the connection if connect request times out Eddie Wai
                   ` (60 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-19  1:30 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Modified the handling of the remote TCP RST code so the chip can now
flush the tx pipe accordingly upon a remote TCP RST reception.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c   |   11 ++++++++---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    8 +++-----
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index c9a3c0f..859882c 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -2333,12 +2333,17 @@ static void bnx2i_cm_abort_cmpl(struct cnic_sock *cm_sk)
 static void bnx2i_cm_remote_close(struct cnic_sock *cm_sk)
 {
 	struct bnx2i_endpoint *ep = (struct bnx2i_endpoint *) cm_sk->context;
+	u32 old_state = ep->state;
 
-	ep->state = EP_STATE_TCP_FIN_RCVD;
-	if (ep->conn)
-		bnx2i_recovery_que_add_conn(ep->hba, ep->conn);
+	ep->state = EP_STATE_TCP_RST_RCVD;
+	if (old_state == EP_STATE_DISCONN_START)
+		wake_up_interruptible(&ep->ofld_wait);
+	else
+		if (ep->conn)
+			bnx2i_recovery_que_add_conn(ep->hba, ep->conn);
 }
 
+
 /**
  * bnx2i_cm_remote_abort - process TCP RST and start conn cleanup
  * @hba:		adapter structure pointer
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index b766812..4882b00 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1907,6 +1907,7 @@ static int bnx2i_ep_tcp_conn_active(struct bnx2i_endpoint *bnx2i_ep)
 
 	switch (bnx2i_ep->state) {
 	case EP_STATE_CONNECT_START:
+	case EP_STATE_CONNECT_FAILED:
 	case EP_STATE_CLEANUP_FAILED:
 	case EP_STATE_OFLD_FAILED:
 	case EP_STATE_DISCONN_TIMEDOUT:
@@ -1922,13 +1923,10 @@ static int bnx2i_ep_tcp_conn_active(struct bnx2i_endpoint *bnx2i_ep)
 		ret = 1;
 		break;
 	case EP_STATE_TCP_RST_RCVD:
-		ret = 0;
-		break;
-	case EP_STATE_CONNECT_FAILED:
 		if (cnic_dev_10g)
-			ret = 1;
-		else
 			ret = 0;
+		else
+			ret = 1;
 		break;
 	default:
 		ret = 0;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v2 06/14] BNX2I: Allow to abort the connection if connect request times out
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (48 preceding siblings ...)
  2010-11-19  1:30 ` [PATCH v2 05/14] BNX2I: Fixed the remote TCP RST handling for the 570X (1g) Eddie Wai
@ 2010-11-19  1:30 ` Eddie Wai
  2010-11-19  1:30 ` [PATCH v2 07/14] BNX2I: Added mutex lock protection to conn_get_param Eddie Wai
                   ` (59 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-19  1:30 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

In the situation where the connect completion response arrives after
the connect request has already timed out, the connection was not being
aborted but only the resource was being freed.  This creates a problem
for 5771X (10g) as the chip flags this with an assertion.

This change will properly aborts the connection before freeing the
resource.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 4882b00..a2c9b1f 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1906,13 +1906,13 @@ static int bnx2i_ep_tcp_conn_active(struct bnx2i_endpoint *bnx2i_ep)
 		cnic_dev_10g = 1;
 
 	switch (bnx2i_ep->state) {
-	case EP_STATE_CONNECT_START:
 	case EP_STATE_CONNECT_FAILED:
 	case EP_STATE_CLEANUP_FAILED:
 	case EP_STATE_OFLD_FAILED:
 	case EP_STATE_DISCONN_TIMEDOUT:
 		ret = 0;
 		break;
+	case EP_STATE_CONNECT_START:
 	case EP_STATE_CONNECT_COMPL:
 	case EP_STATE_ULP_UPDATE_START:
 	case EP_STATE_ULP_UPDATE_COMPL:
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v2 07/14] BNX2I: Added mutex lock protection to conn_get_param
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (49 preceding siblings ...)
  2010-11-19  1:30 ` [PATCH v2 06/14] BNX2I: Allow to abort the connection if connect request times out Eddie Wai
@ 2010-11-19  1:30 ` Eddie Wai
  2010-11-19  1:30 ` [PATCH v2 08/14] BNX2I: Removed the dynamic registration of CNIC Eddie Wai
                   ` (58 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-19  1:30 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Added net_dev mutex lock protection before accessing the csk
parameters.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index a2c9b1f..07dd4f9 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1461,21 +1461,28 @@ static int bnx2i_conn_get_param(struct iscsi_cls_conn *cls_conn,
 	struct bnx2i_conn *bnx2i_conn = conn->dd_data;
 	int len = 0;
 
+	if (!(bnx2i_conn && bnx2i_conn->ep && bnx2i_conn->ep->hba))
+		goto out;
+
 	switch (param) {
 	case ISCSI_PARAM_CONN_PORT:
-		if (bnx2i_conn->ep)
+		mutex_lock(&bnx2i_conn->ep->hba->net_dev_lock);
+		if (bnx2i_conn->ep->cm_sk)
 			len = sprintf(buf, "%hu\n",
 				      bnx2i_conn->ep->cm_sk->dst_port);
+		mutex_unlock(&bnx2i_conn->ep->hba->net_dev_lock);
 		break;
 	case ISCSI_PARAM_CONN_ADDRESS:
-		if (bnx2i_conn->ep)
+		mutex_lock(&bnx2i_conn->ep->hba->net_dev_lock);
+		if (bnx2i_conn->ep->cm_sk)
 			len = sprintf(buf, "%pI4\n",
 				      &bnx2i_conn->ep->cm_sk->dst_ip);
+		mutex_unlock(&bnx2i_conn->ep->hba->net_dev_lock);
 		break;
 	default:
 		return iscsi_conn_get_param(cls_conn, param, buf);
 	}
-
+out:
 	return len;
 }
 
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v2 08/14] BNX2I: Removed the dynamic registration of CNIC
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (50 preceding siblings ...)
  2010-11-19  1:30 ` [PATCH v2 07/14] BNX2I: Added mutex lock protection to conn_get_param Eddie Wai
@ 2010-11-19  1:30 ` Eddie Wai
  2010-11-19  1:30 ` [PATCH v2 09/14] BNX2I: Modified the bnx2i stop path to compensate for in progress ops Eddie Wai
                   ` (57 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-19  1:30 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The code no longer needs to dynamically register and unregister
the CNIC device.  The CNIC device will be kept registered until
module unload.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |    3 -
 drivers/scsi/bnx2i/bnx2i_init.c  |   82 --------------------------------------
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    7 ---
 3 files changed, 0 insertions(+), 92 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index a44b1b3..2c34e22 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -717,14 +717,11 @@ extern struct device_attribute *bnx2i_dev_attributes[];
  * Function Prototypes
  */
 extern void bnx2i_identify_device(struct bnx2i_hba *hba);
-extern void bnx2i_register_device(struct bnx2i_hba *hba);
 
 extern void bnx2i_ulp_init(struct cnic_dev *dev);
 extern void bnx2i_ulp_exit(struct cnic_dev *dev);
 extern void bnx2i_start(void *handle);
 extern void bnx2i_stop(void *handle);
-extern void bnx2i_reg_dev_all(void);
-extern void bnx2i_unreg_dev_all(void);
 extern struct bnx2i_hba *get_adapter_list_head(void);
 
 struct bnx2i_conn *bnx2i_get_conn_from_id(struct bnx2i_hba *hba,
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 50c2aa3..769311f 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -65,8 +65,6 @@ MODULE_PARM_DESC(rq_size, "Configure RQ size");
 
 u64 iscsi_error_mask = 0x00;
 
-static void bnx2i_unreg_one_device(struct bnx2i_hba *hba) ;
-
 
 /**
  * bnx2i_identify_device - identifies NetXtreme II device type
@@ -239,86 +237,6 @@ void bnx2i_stop(void *handle)
 }
 
 /**
- * bnx2i_register_device - register bnx2i adapter instance with the cnic driver
- * @hba:	Adapter instance to register
- *
- * registers bnx2i adapter instance with the cnic driver while holding the
- *	adapter structure lock
- */
-void bnx2i_register_device(struct bnx2i_hba *hba)
-{
-	int rc;
-
-	if (test_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state) ||
-	    test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic)) {
-		return;
-	}
-
-	rc = hba->cnic->register_device(hba->cnic, CNIC_ULP_ISCSI, hba);
-
-	if (!rc)
-		set_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic);
-}
-
-
-/**
- * bnx2i_reg_dev_all - registers all adapter instances with the cnic driver
- *
- * registers all bnx2i adapter instances with the cnic driver while holding
- *	the global resource lock
- */
-void bnx2i_reg_dev_all(void)
-{
-	struct bnx2i_hba *hba, *temp;
-
-	mutex_lock(&bnx2i_dev_lock);
-	list_for_each_entry_safe(hba, temp, &adapter_list, link)
-		bnx2i_register_device(hba);
-	mutex_unlock(&bnx2i_dev_lock);
-}
-
-
-/**
- * bnx2i_unreg_one_device - unregister adapter instance with the cnic driver
- * @hba:	Adapter instance to unregister
- *
- * registers bnx2i adapter instance with the cnic driver while holding
- *	the adapter structure lock
- */
-static void bnx2i_unreg_one_device(struct bnx2i_hba *hba)
-{
-	if (hba->ofld_conns_active ||
-	    !test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic) ||
-	    test_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state))
-		return;
-
-	hba->cnic->unregister_device(hba->cnic, CNIC_ULP_ISCSI);
-
-	/* ep_disconnect could come before NETDEV_DOWN, driver won't
-	 * see NETDEV_DOWN as it already unregistered itself.
-	 */
-	hba->adapter_state = 0;
-	clear_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic);
-}
-
-/**
- * bnx2i_unreg_dev_all - unregisters all bnx2i instances with the cnic driver
- *
- * unregisters all bnx2i adapter instances with the cnic driver while holding
- *	the global resource lock
- */
-void bnx2i_unreg_dev_all(void)
-{
-	struct bnx2i_hba *hba, *temp;
-
-	mutex_lock(&bnx2i_dev_lock);
-	list_for_each_entry_safe(hba, temp, &adapter_list, link)
-		bnx2i_unreg_one_device(hba);
-	mutex_unlock(&bnx2i_dev_lock);
-}
-
-
-/**
  * bnx2i_init_one - initialize an adapter instance and allocate memory resources
  * @hba:	bnx2i adapter instance
  * @cnic:	cnic device handle
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 07dd4f9..43b7dad 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1606,8 +1606,6 @@ static struct bnx2i_hba *bnx2i_check_route(struct sockaddr *dst_addr)
 	struct bnx2i_hba *hba;
 	struct cnic_dev *cnic = NULL;
 
-	bnx2i_reg_dev_all();
-
 	hba = get_adapter_list_head();
 	if (hba && hba->cnic)
 		cnic = hba->cnic->cm_select_dev(desti, CNIC_ULP_ISCSI);
@@ -1726,8 +1724,6 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	if (shost) {
 		/* driver is given scsi host to work with */
 		hba = iscsi_host_priv(shost);
-		/* Register the device with cnic if not already done so */
-		bnx2i_register_device(hba);
 	} else
 		/*
 		 * check if the given destination can be reached through
@@ -1853,7 +1849,6 @@ qp_resc_err:
 check_busy:
 	mutex_unlock(&hba->net_dev_lock);
 nohba:
-	bnx2i_unreg_dev_all();
 	return ERR_PTR(rc);
 }
 
@@ -2089,8 +2084,6 @@ return_bnx2i_ep:
 
 	bnx2i_free_ep(ep);
 	mutex_unlock(&hba->net_dev_lock);
-	if (!hba->ofld_conns_active)
-		bnx2i_unreg_dev_all();
 
 	wake_up_interruptible(&hba->eh_wait);
 }
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v2 09/14] BNX2I: Modified the bnx2i stop path to compensate for in progress ops
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (51 preceding siblings ...)
  2010-11-19  1:30 ` [PATCH v2 08/14] BNX2I: Removed the dynamic registration of CNIC Eddie Wai
@ 2010-11-19  1:30 ` Eddie Wai
  2010-11-19  1:30 ` [PATCH v2 10/14] BNX2I: Added return code check for chip kwqe submission request Eddie Wai
                   ` (56 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-19  1:30 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The stop path has been augmented to wait a max of 10s for all in
progress offload and destroy activities to complete before proceeding
to terminate all active connections (via iscsid or forcefully).

Note that any new offload and destroy requests are now blocked and
return to the caller immediately.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_init.c  |   21 +++++++++++++++++----
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    7 ++++++-
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 769311f..338caac 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -209,13 +209,24 @@ void bnx2i_stop(void *handle)
 {
 	struct bnx2i_hba *hba = handle;
 	int conns_active;
+	int wait_delay = 1 * HZ;
 
 	/* check if cleanup happened in GOING_DOWN context */
-	if (!test_and_clear_bit(ADAPTER_STATE_GOING_DOWN,
-				&hba->adapter_state))
+	if (!test_and_set_bit(ADAPTER_STATE_GOING_DOWN,
+			      &hba->adapter_state)) {
 		iscsi_host_for_each_session(hba->shost,
 					    bnx2i_drop_session);
-
+		wait_delay = hba->hba_shutdown_tmo;
+	}
+	/* Wait for inflight offload connection tasks to complete before
+	 * proceeding. Forcefully terminate all connection recovery in
+	 * progress at the earliest, either in bind(), send_pdu(LOGIN),
+	 * or conn_start()
+	 */
+	wait_event_interruptible_timeout(hba->eh_wait,
+					 (list_empty(&hba->ep_ofld_list) &&
+					 list_empty(&hba->ep_destroy_list)),
+					 10 * HZ);
 	/* Wait for all endpoints to be torn down, Chip will be reset once
 	 *  control returns to network driver. So it is required to cleanup and
 	 * release all connection resources before returning from this routine.
@@ -224,7 +235,7 @@ void bnx2i_stop(void *handle)
 		conns_active = hba->ofld_conns_active;
 		wait_event_interruptible_timeout(hba->eh_wait,
 				(hba->ofld_conns_active != conns_active),
-				hba->hba_shutdown_tmo);
+				wait_delay);
 		if (hba->ofld_conns_active == conns_active)
 			break;
 	}
@@ -233,9 +244,11 @@ void bnx2i_stop(void *handle)
 	/* This flag should be cleared last so that ep_disconnect() gracefully
 	 * cleans up connection context
 	 */
+	clear_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state);
 	clear_bit(ADAPTER_STATE_UP, &hba->adapter_state);
 }
 
+
 /**
  * bnx2i_init_one - initialize an adapter instance and allocate memory resources
  * @hba:	bnx2i adapter instance
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 43b7dad..ac60c4c 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1383,6 +1383,12 @@ static int bnx2i_conn_bind(struct iscsi_cls_session *cls_session,
 	ep = iscsi_lookup_endpoint(transport_fd);
 	if (!ep)
 		return -EINVAL;
+	/*
+	 * Forcefully terminate all in progress connection recovery at the
+	 * earliest, either in bind(), send_pdu(LOGIN), or conn_start()
+	 */
+	if (bnx2i_adapter_ready(hba))
+		return -EIO;
 
 	bnx2i_ep = ep->dd_data;
 	if ((bnx2i_ep->state == EP_STATE_TCP_FIN_RCVD) ||
@@ -1404,7 +1410,6 @@ static int bnx2i_conn_bind(struct iscsi_cls_session *cls_session,
 				  hba->netdev->name);
 		return -EEXIST;
 	}
-
 	bnx2i_ep->conn = bnx2i_conn;
 	bnx2i_conn->ep = bnx2i_ep;
 	bnx2i_conn->iscsi_conn_cid = bnx2i_ep->ep_iscsi_cid;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v2 10/14] BNX2I: Added return code check for chip kwqe submission request
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (52 preceding siblings ...)
  2010-11-19  1:30 ` [PATCH v2 09/14] BNX2I: Modified the bnx2i stop path to compensate for in progress ops Eddie Wai
@ 2010-11-19  1:30 ` Eddie Wai
  2010-11-19  1:30 ` [PATCH v2 11/14] BNX2I: Added feature to silently drop NOPOUT request Eddie Wai
                   ` (55 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-19  1:30 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Added the handling for cases when a chip request is made to the
CNIC module but the hardware is not ready to accept.  This would
lead to many unnecessary wait timeouts.
This code adds check in the connect establishment and destruction
path.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |    9 +++---
 drivers/scsi/bnx2i/bnx2i_hwi.c   |   54 ++++++++++++++++++++++++++++----------
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   17 ++++++++++-
 3 files changed, 60 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 2c34e22..866a22c 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -649,6 +649,7 @@ enum {
 	EP_STATE_OFLD_FAILED            = 0x8000000,
 	EP_STATE_CONNECT_FAILED         = 0x10000000,
 	EP_STATE_DISCONN_TIMEDOUT       = 0x20000000,
+	EP_STATE_OFLD_FAILED_CID_BUSY   = 0x80000000,
 };
 
 /**
@@ -758,11 +759,11 @@ extern int bnx2i_send_iscsi_logout(struct bnx2i_conn *conn,
 				   struct iscsi_task *mtask);
 extern void bnx2i_send_cmd_cleanup_req(struct bnx2i_hba *hba,
 				       struct bnx2i_cmd *cmd);
-extern void bnx2i_send_conn_ofld_req(struct bnx2i_hba *hba,
-				     struct bnx2i_endpoint *ep);
-extern void bnx2i_update_iscsi_conn(struct iscsi_conn *conn);
-extern void bnx2i_send_conn_destroy(struct bnx2i_hba *hba,
+extern int bnx2i_send_conn_ofld_req(struct bnx2i_hba *hba,
 				    struct bnx2i_endpoint *ep);
+extern void bnx2i_update_iscsi_conn(struct iscsi_conn *conn);
+extern int bnx2i_send_conn_destroy(struct bnx2i_hba *hba,
+				   struct bnx2i_endpoint *ep);
 
 extern int bnx2i_alloc_qp_resc(struct bnx2i_hba *hba,
 			       struct bnx2i_endpoint *ep);
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 859882c..b3c264d 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -701,10 +701,11 @@ void bnx2i_send_cmd_cleanup_req(struct bnx2i_hba *hba, struct bnx2i_cmd *cmd)
  * this routine prepares and posts CONN_OFLD_REQ1/2 KWQE to initiate
  * 	iscsi connection context clean-up process
  */
-void bnx2i_send_conn_destroy(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep)
+int bnx2i_send_conn_destroy(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep)
 {
 	struct kwqe *kwqe_arr[2];
 	struct iscsi_kwqe_conn_destroy conn_cleanup;
+	int rc = -EINVAL;
 
 	memset(&conn_cleanup, 0x00, sizeof(struct iscsi_kwqe_conn_destroy));
 
@@ -721,7 +722,9 @@ void bnx2i_send_conn_destroy(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep)
 
 	kwqe_arr[0] = (struct kwqe *) &conn_cleanup;
 	if (hba->cnic && hba->cnic->submit_kwqes)
-		hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, 1);
+		rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, 1);
+
+	return rc;
 }
 
 
@@ -732,8 +735,8 @@ void bnx2i_send_conn_destroy(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep)
  *
  * 5706/5708/5709 specific - prepares and posts CONN_OFLD_REQ1/2 KWQE
  */
-static void bnx2i_570x_send_conn_ofld_req(struct bnx2i_hba *hba,
-					  struct bnx2i_endpoint *ep)
+static int bnx2i_570x_send_conn_ofld_req(struct bnx2i_hba *hba,
+					 struct bnx2i_endpoint *ep)
 {
 	struct kwqe *kwqe_arr[2];
 	struct iscsi_kwqe_conn_offload1 ofld_req1;
@@ -741,6 +744,7 @@ static void bnx2i_570x_send_conn_ofld_req(struct bnx2i_hba *hba,
 	dma_addr_t dma_addr;
 	int num_kwqes = 2;
 	u32 *ptbl;
+	int rc = -EINVAL;
 
 	ofld_req1.hdr.op_code = ISCSI_KWQE_OPCODE_OFFLOAD_CONN1;
 	ofld_req1.hdr.flags =
@@ -778,7 +782,9 @@ static void bnx2i_570x_send_conn_ofld_req(struct bnx2i_hba *hba,
 	ofld_req2.num_additional_wqes = 0;
 
 	if (hba->cnic && hba->cnic->submit_kwqes)
-		hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes);
+		rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes);
+
+	return rc;
 }
 
 
@@ -789,8 +795,8 @@ static void bnx2i_570x_send_conn_ofld_req(struct bnx2i_hba *hba,
  *
  * 57710 specific - prepares and posts CONN_OFLD_REQ1/2 KWQE
  */
-static void bnx2i_5771x_send_conn_ofld_req(struct bnx2i_hba *hba,
-					   struct bnx2i_endpoint *ep)
+static int bnx2i_5771x_send_conn_ofld_req(struct bnx2i_hba *hba,
+					  struct bnx2i_endpoint *ep)
 {
 	struct kwqe *kwqe_arr[5];
 	struct iscsi_kwqe_conn_offload1 ofld_req1;
@@ -799,6 +805,7 @@ static void bnx2i_5771x_send_conn_ofld_req(struct bnx2i_hba *hba,
 	dma_addr_t dma_addr;
 	int num_kwqes = 2;
 	u32 *ptbl;
+	int rc = -EINVAL;
 
 	ofld_req1.hdr.op_code = ISCSI_KWQE_OPCODE_OFFLOAD_CONN1;
 	ofld_req1.hdr.flags =
@@ -844,7 +851,9 @@ static void bnx2i_5771x_send_conn_ofld_req(struct bnx2i_hba *hba,
 	num_kwqes += 1;
 
 	if (hba->cnic && hba->cnic->submit_kwqes)
-		hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes);
+		rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes);
+
+	return rc;
 }
 
 /**
@@ -855,12 +864,16 @@ static void bnx2i_5771x_send_conn_ofld_req(struct bnx2i_hba *hba,
  *
  * this routine prepares and posts CONN_OFLD_REQ1/2 KWQE
  */
-void bnx2i_send_conn_ofld_req(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep)
+int bnx2i_send_conn_ofld_req(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep)
 {
+	int rc;
+
 	if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type))
-		bnx2i_5771x_send_conn_ofld_req(hba, ep);
+		rc = bnx2i_5771x_send_conn_ofld_req(hba, ep);
 	else
-		bnx2i_570x_send_conn_ofld_req(hba, ep);
+		rc = bnx2i_570x_send_conn_ofld_req(hba, ep);
+
+	return rc;
 }
 
 
@@ -2165,11 +2178,24 @@ static void bnx2i_process_ofld_cmpl(struct bnx2i_hba *hba,
 	}
 
 	if (ofld_kcqe->completion_status) {
+		ep->state = EP_STATE_OFLD_FAILED;
 		if (ofld_kcqe->completion_status ==
 		    ISCSI_KCQE_COMPLETION_STATUS_CTX_ALLOC_FAILURE)
-			printk(KERN_ALERT "bnx2i: unable to allocate"
-					  " iSCSI context resources\n");
-		ep->state = EP_STATE_OFLD_FAILED;
+			printk(KERN_ALERT "bnx2i (%s): ofld1 cmpl - unable "
+				"to allocate iSCSI context resources\n",
+				hba->netdev->name);
+		else if (ofld_kcqe->completion_status ==
+			 ISCSI_KCQE_COMPLETION_STATUS_INVALID_OPCODE)
+			printk(KERN_ALERT "bnx2i (%s): ofld1 cmpl - invalid "
+				"opcode\n", hba->netdev->name);
+		else if (ofld_kcqe->completion_status ==
+			ISCSI_KCQE_COMPLETION_STATUS_CID_BUSY)
+			/* error status code valid only for 5771x chipset */
+			ep->state = EP_STATE_OFLD_FAILED_CID_BUSY;
+		else
+			printk(KERN_ALERT "bnx2i (%s): ofld1 cmpl - invalid "
+				"error code %d\n", hba->netdev->name,
+				ofld_kcqe->completion_status);
 	} else {
 		ep->state = EP_STATE_OFLD_COMPL;
 		cid_addr = ofld_kcqe->iscsi_conn_context_id;
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index ac60c4c..f622e89 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1682,7 +1682,9 @@ static int bnx2i_tear_down_conn(struct bnx2i_hba *hba,
 	bnx2i_ep_destroy_list_add(hba, ep);
 
 	/* destroy iSCSI context, wait for it to complete */
-	bnx2i_send_conn_destroy(hba, ep);
+	if (bnx2i_send_conn_destroy(hba, ep))
+		ep->state = EP_STATE_CLEANUP_CMPL;
+
 	wait_event_interruptible(ep->ofld_wait,
 				 (ep->state != EP_STATE_CLEANUP_START));
 
@@ -1781,7 +1783,18 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	bnx2i_ep->ofld_timer.data = (unsigned long) bnx2i_ep;
 	add_timer(&bnx2i_ep->ofld_timer);
 
-	bnx2i_send_conn_ofld_req(hba, bnx2i_ep);
+	if (bnx2i_send_conn_ofld_req(hba, bnx2i_ep)) {
+		if (bnx2i_ep->state == EP_STATE_OFLD_FAILED_CID_BUSY) {
+			printk(KERN_ALERT "bnx2i (%s): iscsi cid %d is busy\n",
+				hba->netdev->name, bnx2i_ep->ep_iscsi_cid);
+			rc = -EBUSY;
+		} else
+			rc = -ENOSPC;
+		printk(KERN_ALERT "bnx2i (%s): unable to send conn offld kwqe"
+			"\n", hba->netdev->name);
+		bnx2i_ep_ofld_list_del(hba, bnx2i_ep);
+		goto conn_failed;
+	}
 
 	/* Wait for CNIC hardware to setup conn context and return 'cid' */
 	wait_event_interruptible(bnx2i_ep->ofld_wait,
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v2 11/14] BNX2I: Added feature to silently drop NOPOUT request
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (53 preceding siblings ...)
  2010-11-19  1:30 ` [PATCH v2 10/14] BNX2I: Added return code check for chip kwqe submission request Eddie Wai
@ 2010-11-19  1:30 ` Eddie Wai
       [not found]   ` <1290130209-32133-12-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
  2010-11-19  1:30 ` [PATCH v2 12/14] BNX2I: Cleaned up various error conditions in ep_connect/disconnect Eddie Wai
                   ` (54 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-11-19  1:30 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

In the case the chip is undergoing different invasive operation
which requires a chip reset, all NOPOUT request during this period
must be silently dropped from queuing to the hardware.  This patch
will respond to libiscsi immediately with sent success.  Since the
request was not actually sent, the NOPIN wait timeout will get
triggered and another NOPOUT request will commence through the
proper channel.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index f622e89..5e8dff9 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1068,6 +1068,22 @@ static int bnx2i_iscsi_send_generic_request(struct iscsi_task *task)
 	char *buf;
 	int data_len;
 
+	/*
+	 * Forcefully terminate all in progress connection recovery at the
+	 * earliest, either in bind(), send_pdu(LOGIN), or conn_start()
+	 */
+	if (bnx2i_adapter_ready(bnx2i_conn->ep->hba)) {
+		if ((task->hdr->opcode & ISCSI_OPCODE_MASK) ==
+		    ISCSI_OP_NOOP_OUT)
+			/* This is a WA to indicate to libiscsi that the nopout
+			 * request was sent successfully without actually
+			 * submitting to the hardware.
+			 * Just silently drop the nopout request
+			 */
+			return 0;
+		else
+			return -EIO;
+	}
 	bnx2i_iscsi_prep_generic_pdu_bd(bnx2i_conn);
 	switch (task->hdr->opcode & ISCSI_OPCODE_MASK) {
 	case ISCSI_OP_LOGIN:
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v2 12/14] BNX2I: Cleaned up various error conditions in ep_connect/disconnect
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (54 preceding siblings ...)
  2010-11-19  1:30 ` [PATCH v2 11/14] BNX2I: Added feature to silently drop NOPOUT request Eddie Wai
@ 2010-11-19  1:30 ` Eddie Wai
  2010-11-19  1:30 ` [PATCH v2 13/14] BNX2I: Updated copyright and maintainer info Eddie Wai
                   ` (53 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-19  1:30 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Various error conditions inside ep_connect and ep_disconnect were
either not being handled or not being handled correctly.  This patch
fixes all those issues.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   67 ++++++++++++++++++++++---------------
 1 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 5e8dff9..f60a525 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -411,7 +411,9 @@ static void bnx2i_free_ep(struct iscsi_endpoint *ep)
 	bnx2i_ep->state = EP_STATE_IDLE;
 	bnx2i_ep->hba->ofld_conns_active--;
 
-	bnx2i_free_iscsi_cid(bnx2i_ep->hba, bnx2i_ep->ep_iscsi_cid);
+	if (bnx2i_ep->ep_iscsi_cid != (u16) -1)
+		bnx2i_free_iscsi_cid(bnx2i_ep->hba, bnx2i_ep->ep_iscsi_cid);
+
 	if (bnx2i_ep->conn) {
 		bnx2i_ep->conn->ep = NULL;
 		bnx2i_ep->conn = NULL;
@@ -1754,13 +1756,17 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 		 */
 		hba = bnx2i_check_route(dst_addr);
 
-	if (!hba || test_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state)) {
+	if (!hba) {
 		rc = -EINVAL;
 		goto nohba;
 	}
+	mutex_lock(&hba->net_dev_lock);
 
+	if (bnx2i_adapter_ready(hba) || !hba->cid_que.cid_free_cnt) {
+		rc = -EPERM;
+		goto check_busy;
+	}
 	cnic = hba->cnic;
-	mutex_lock(&hba->net_dev_lock);
 	ep = bnx2i_alloc_ep(hba);
 	if (!ep) {
 		rc = -ENOMEM;
@@ -1768,23 +1774,21 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	}
 	bnx2i_ep = ep->dd_data;
 
-	if (bnx2i_adapter_ready(hba)) {
-		rc = -EPERM;
-		goto net_if_down;
-	}
-
 	bnx2i_ep->num_active_cmds = 0;
 	iscsi_cid = bnx2i_alloc_iscsi_cid(hba);
 	if (iscsi_cid == -1) {
-		printk(KERN_ALERT "alloc_ep: unable to allocate iscsi cid\n");
+		printk(KERN_ALERT "bnx2i (%s): alloc_ep - unable to allocate "
+			"iscsi cid\n", hba->netdev->name);
 		rc = -ENOMEM;
-		goto iscsi_cid_err;
+		bnx2i_free_ep(ep);
+		goto check_busy;
 	}
 	bnx2i_ep->hba_age = hba->age;
 
 	rc = bnx2i_alloc_qp_resc(hba, bnx2i_ep);
 	if (rc != 0) {
-		printk(KERN_ALERT "bnx2i: ep_conn, alloc QP resc error\n");
+		printk(KERN_ALERT "bnx2i (%s): ep_conn - alloc QP resc error"
+			"\n", hba->netdev->name);
 		rc = -ENOMEM;
 		goto qp_resc_err;
 	}
@@ -1823,7 +1827,12 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	bnx2i_ep_ofld_list_del(hba, bnx2i_ep);
 
 	if (bnx2i_ep->state != EP_STATE_OFLD_COMPL) {
-		rc = -ENOSPC;
+		if (bnx2i_ep->state == EP_STATE_OFLD_FAILED_CID_BUSY) {
+			printk(KERN_ALERT "bnx2i (%s): iscsi cid %d is busy\n",
+				hba->netdev->name, bnx2i_ep->ep_iscsi_cid);
+			rc = -EBUSY;
+		} else
+			rc = -ENOSPC;
 		goto conn_failed;
 	}
 
@@ -1831,7 +1840,8 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 			     iscsi_cid, &bnx2i_ep->cm_sk, bnx2i_ep);
 	if (rc) {
 		rc = -EINVAL;
-		goto conn_failed;
+		/* Need to terminate and cleanup the connection */
+		goto release_ep;
 	}
 
 	bnx2i_ep->cm_sk->rcv_buf = 256 * 1024;
@@ -1875,8 +1885,6 @@ release_ep:
 		return ERR_PTR(rc);
 	}
 conn_failed:
-net_if_down:
-iscsi_cid_err:
 	bnx2i_free_qp_resc(hba, bnx2i_ep);
 qp_resc_err:
 	bnx2i_free_ep(ep);
@@ -1995,7 +2003,8 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 	if (!cnic)
 		return 0;
 
-	if (bnx2i_ep->state == EP_STATE_IDLE)
+	if (bnx2i_ep->state == EP_STATE_IDLE ||
+	    bnx2i_ep->state == EP_STATE_DISCONN_TIMEDOUT)
 		return 0;
 
 	if (!bnx2i_ep_tcp_conn_active(bnx2i_ep))
@@ -2021,9 +2030,10 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 			if (session->state == ISCSI_STATE_LOGGING_OUT) {
 				if (bnx2i_ep->state == EP_STATE_LOGOUT_SENT) {
 					/* Logout sent, but no resp */
-					printk(KERN_ALERT "bnx2i - WARNING "
-						"logout response was not "
-						"received!\n");
+					printk(KERN_ALERT "bnx2i (%s): WARNING"
+						" logout response was not "
+						"received!\n",
+						bnx2i_ep->hba->netdev->name);
 				} else if (bnx2i_ep->state ==
 					   EP_STATE_LOGOUT_RESP_RCVD)
 					close = 1;
@@ -2041,9 +2051,8 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 	else
 		close_ret = cnic->cm_abort(bnx2i_ep->cm_sk);
 
-	/* No longer allow CFC delete if cm_close/abort fails the request */
 	if (close_ret)
-		printk(KERN_ALERT "bnx2i: %s close/abort(%d) returned %d\n",
+		printk(KERN_ALERT "bnx2i (%s): close/abort(%d) returned %d\n",
 			bnx2i_ep->hba->netdev->name, close, close_ret);
 	else
 		/* wait for option-2 conn teardown */
@@ -2057,7 +2066,7 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 destroy_conn:
 	bnx2i_ep_active_list_del(hba, bnx2i_ep);
 	if (bnx2i_tear_down_conn(hba, bnx2i_ep))
-		ret = -EINVAL;
+		return -EINVAL;
 out:
 	bnx2i_ep->state = EP_STATE_IDLE;
 	return ret;
@@ -2096,14 +2105,17 @@ static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
 
 	mutex_lock(&hba->net_dev_lock);
 
-	if (bnx2i_ep->state == EP_STATE_IDLE)
-		goto return_bnx2i_ep;
+	if (bnx2i_ep->state == EP_STATE_DISCONN_TIMEDOUT)
+		goto out;
 
-	if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state))
+	if (bnx2i_ep->state == EP_STATE_IDLE)
 		goto free_resc;
 
-	if (bnx2i_ep->hba_age != hba->age)
+	if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state) ||
+	    (bnx2i_ep->hba_age != hba->age)) {
+		bnx2i_ep_active_list_del(hba, bnx2i_ep);
 		goto free_resc;
+	}
 
 	/* Do all chip cleanup here */
 	if (bnx2i_hw_ep_disconnect(bnx2i_ep)) {
@@ -2112,11 +2124,12 @@ static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
 	}
 free_resc:
 	bnx2i_free_qp_resc(hba, bnx2i_ep);
-return_bnx2i_ep:
+
 	if (bnx2i_conn)
 		bnx2i_conn->ep = NULL;
 
 	bnx2i_free_ep(ep);
+out:
 	mutex_unlock(&hba->net_dev_lock);
 
 	wake_up_interruptible(&hba->eh_wait);
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v2 13/14] BNX2I: Updated copyright and maintainer info
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (55 preceding siblings ...)
  2010-11-19  1:30 ` [PATCH v2 12/14] BNX2I: Cleaned up various error conditions in ep_connect/disconnect Eddie Wai
@ 2010-11-19  1:30 ` Eddie Wai
  2010-11-19  1:30 ` [PATCH v2 14/14] BNX2I: Updated version to 2.6.2.1 Eddie Wai
                   ` (52 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-19  1:30 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/57xx_iscsi_constants.h |    3 ++-
 drivers/scsi/bnx2i/57xx_iscsi_hsi.h       |    3 ++-
 drivers/scsi/bnx2i/bnx2i.h                |    3 ++-
 drivers/scsi/bnx2i/bnx2i_hwi.c            |    3 ++-
 drivers/scsi/bnx2i/bnx2i_init.c           |    3 ++-
 drivers/scsi/bnx2i/bnx2i_iscsi.c          |    3 ++-
 drivers/scsi/bnx2i/bnx2i_sysfs.c          |    3 ++-
 7 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/bnx2i/57xx_iscsi_constants.h b/drivers/scsi/bnx2i/57xx_iscsi_constants.h
index 1b6f86b..30e6bdb 100644
--- a/drivers/scsi/bnx2i/57xx_iscsi_constants.h
+++ b/drivers/scsi/bnx2i/57xx_iscsi_constants.h
@@ -1,12 +1,13 @@
 /* 57xx_iscsi_constants.h: Broadcom NetXtreme II iSCSI HSI
  *
- * Copyright (c) 2006 - 2009 Broadcom Corporation
+ * Copyright (c) 2006 - 2010 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 #ifndef __57XX_ISCSI_CONSTANTS_H_
 #define __57XX_ISCSI_CONSTANTS_H_
diff --git a/drivers/scsi/bnx2i/57xx_iscsi_hsi.h b/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
index 36af1af..dad6c8a 100644
--- a/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
+++ b/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
@@ -1,12 +1,13 @@
 /* 57xx_iscsi_hsi.h: Broadcom NetXtreme II iSCSI HSI.
  *
- * Copyright (c) 2006 - 2009 Broadcom Corporation
+ * Copyright (c) 2006 - 2010 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 #ifndef __57XX_ISCSI_HSI_LINUX_LE__
 #define __57XX_ISCSI_HSI_LINUX_LE__
diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 866a22c..e1ca5fe 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -1,6 +1,6 @@
 /* bnx2i.h: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2009 Broadcom Corporation
+ * Copyright (c) 2006 - 2010 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
@@ -9,6 +9,7 @@
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 
 #ifndef _BNX2I_H_
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index b3c264d..48463df 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1,6 +1,6 @@
 /* bnx2i_hwi.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2009 Broadcom Corporation
+ * Copyright (c) 2006 - 2010 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
@@ -9,6 +9,7 @@
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 
 #include <linux/gfp.h>
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 338caac..131ef80 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -1,6 +1,6 @@
 /* bnx2i.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2009 Broadcom Corporation
+ * Copyright (c) 2006 - 2010 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
@@ -9,6 +9,7 @@
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 
 #include "bnx2i.h"
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index f60a525..fc18ee2 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1,7 +1,7 @@
 /*
  * bnx2i_iscsi.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2009 Broadcom Corporation
+ * Copyright (c) 2006 - 2010 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
@@ -10,6 +10,7 @@
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 
 #include <linux/slab.h>
diff --git a/drivers/scsi/bnx2i/bnx2i_sysfs.c b/drivers/scsi/bnx2i/bnx2i_sysfs.c
index 96426b7..9174196 100644
--- a/drivers/scsi/bnx2i/bnx2i_sysfs.c
+++ b/drivers/scsi/bnx2i/bnx2i_sysfs.c
@@ -1,12 +1,13 @@
 /* bnx2i_sysfs.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2004 - 2009 Broadcom Corporation
+ * Copyright (c) 2004 - 2010 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 
 #include "bnx2i.h"
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v2 14/14] BNX2I: Updated version to 2.6.2.1
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (56 preceding siblings ...)
  2010-11-19  1:30 ` [PATCH v2 13/14] BNX2I: Updated copyright and maintainer info Eddie Wai
@ 2010-11-19  1:30 ` Eddie Wai
  2010-11-23 23:29 ` PATCH 00/13] BNX2I: Patch set to fix various bug fixes Eddie Wai
                   ` (51 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-19  1:30 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_init.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 131ef80..58ad4d7 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -18,8 +18,8 @@ static struct list_head adapter_list = LIST_HEAD_INIT(adapter_list);
 static u32 adapter_count;
 
 #define DRV_MODULE_NAME		"bnx2i"
-#define DRV_MODULE_VERSION	"2.1.3"
-#define DRV_MODULE_RELDATE	"Aug 10, 2010"
+#define DRV_MODULE_VERSION	"2.6.2.1"
+#define DRV_MODULE_RELDATE	"Nov 18, 2010"
 
 static char version[] __devinitdata =
 		"Broadcom NetXtreme II iSCSI Driver " DRV_MODULE_NAME \
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH 12/16] BNX2I: Added feature to silently drop NOPOUT request
  2010-11-18 21:59             ` Eddie Wai
@ 2010-11-20  5:07               ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2010-11-20  5:07 UTC (permalink / raw)
  To: open-iscsi
  Cc: Eddie Wai, Eddie Wai, James Bottomley, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Benjamin Li

On 11/18/2010 03:59 PM, Eddie Wai wrote:
> As for the NOPOUT requests, since the NOPOUT send request failed, the
> last_ping jiffies count would not get updated.  Then the
> iscsi_check_transport_timeouts callback will just keeps getting called
> and stalling the system.
>
> Perhaps a better way to do this is to allow the last_ping jiffies to be
> updated but use a different ping_timeout value for failed nopout ping
> conditions.
>

If this is a hard error then we can just have xmit_task return a error, 
and then have iscsi_send_nopout call iscsi_conn_failure for the driver.

Is there any issue with starting the eh process at this time? Would the 
quicker swing around to ep_disconnect and ep_connect cause problems?

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH v2 11/14] BNX2I: Added feature to silently drop NOPOUT request
       [not found]   ` <1290130209-32133-12-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
@ 2010-11-22 17:42     ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2010-11-22 17:42 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 11/18/2010 07:30 PM, Eddie Wai wrote:
> In the case the chip is undergoing different invasive operation
> which requires a chip reset, all NOPOUT request during this period
> must be silently dropped from queuing to the hardware.  This patch
> will respond to libiscsi immediately with sent success.  Since the
> request was not actually sent, the NOPIN wait timeout will get
> triggered and another NOPOUT request will commence through the
> proper channel.
>
> Signed-off-by: Eddie Wai<eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
> Acked-by: Anil Veerabhadrappa<anilgv-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
> ---
>   drivers/scsi/bnx2i/bnx2i_iscsi.c |   16 ++++++++++++++++
>   1 files changed, 16 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
> index f622e89..5e8dff9 100644
> --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
> +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
> @@ -1068,6 +1068,22 @@ static int bnx2i_iscsi_send_generic_request(struct iscsi_task *task)
>   	char *buf;
>   	int data_len;
>
> +	/*
> +	 * Forcefully terminate all in progress connection recovery at the
> +	 * earliest, either in bind(), send_pdu(LOGIN), or conn_start()
> +	 */
> +	if (bnx2i_adapter_ready(bnx2i_conn->ep->hba)) {
> +		if ((task->hdr->opcode&  ISCSI_OPCODE_MASK) ==
> +		    ISCSI_OP_NOOP_OUT)
> +			/* This is a WA to indicate to libiscsi that the nopout
> +			 * request was sent successfully without actually
> +			 * submitting to the hardware.
> +			 * Just silently drop the nopout request
> +			 */
> +			return 0;

I'd like to just have libiscsi handle a error code here instead of 
hacking around its lack of eh handling.


> +		else
> +			return -EIO;
> +	}
>   	bnx2i_iscsi_prep_generic_pdu_bd(bnx2i_conn);
>   	switch (task->hdr->opcode&  ISCSI_OPCODE_MASK) {
>   	case ISCSI_OP_LOGIN:

-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* PATCH 00/13] BNX2I: Patch set to fix various bug fixes
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (57 preceding siblings ...)
  2010-11-19  1:30 ` [PATCH v2 14/14] BNX2I: Updated version to 2.6.2.1 Eddie Wai
@ 2010-11-23 23:29 ` Eddie Wai
  2010-11-24  0:16   ` Mike Christie
  2010-11-23 23:29 ` [PATCH v3 01/13] BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins Eddie Wai
                   ` (50 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2010-11-23 23:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Hello,

This patch set contains various bug fixes as categorized in the following:
- scsi command handling (nop-ins, tmfs)
- various connection clean up bug fixes
In v3, the following patches are updated:
  BNX2I: Fixed the remote TCP RST handling for the 570X (1g)

>In v2, the following patches are modified based on Mike Christie's comments:
>  BNX2I: Added mutex lock protection to conn_get_param (rm ret 0)
>  BNX2I: Removed the dynamic registration of CNIC (trailing space)
>

In v3, these patches were removed pending better resolution:
  BNX2I: Added feature to silently drop NOPOUT request
>  BNX2I: Updated the handling of NETEVENTs to alleviate recovery
>  BNX2I: Added code to handle the binding of an existing connection

Your comments are grealy appreciated.  Please review, thanks.

Eddie

Eddie Wai (13):
  BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins
  BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In
  BNX2I: Fixed the endian bug in the TMF LUN cmd send
  BNX2I: Fixed a cid leak issue for 5771X (10g)
  BNX2I: Fixed the remote TCP RST handling for the 570X (1g)
  BNX2I: Allow to abort the connection if connect request times out
  BNX2I: Added mutex lock protection to conn_get_param
  BNX2I: Removed the dynamic registration of CNIC
  BNX2I: Modified the bnx2i stop path to compensate for in progress ops
  BNX2I: Added return code check for chip kwqe submission request
  BNX2I: Cleaned up various error conditions in ep_connect/disconnect
  BNX2I: Updated copyright and maintainer info
  BNX2I: Updated version to 2.6.2.2

 drivers/scsi/bnx2i/57xx_iscsi_constants.h |    3 +-
 drivers/scsi/bnx2i/57xx_iscsi_hsi.h       |    3 +-
 drivers/scsi/bnx2i/bnx2i.h                |   15 ++--
 drivers/scsi/bnx2i/bnx2i_hwi.c            |   96 +++++++++++++-----
 drivers/scsi/bnx2i/bnx2i_init.c           |  108 ++++-----------------
 drivers/scsi/bnx2i/bnx2i_iscsi.c          |  148 ++++++++++++++++++-----------
 drivers/scsi/bnx2i/bnx2i_sysfs.c          |    3 +-
 drivers/scsi/libiscsi.c                   |    3 +-
 include/scsi/libiscsi.h                   |    1 +
 9 files changed, 198 insertions(+), 182 deletions(-)



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH v3 01/13] BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (58 preceding siblings ...)
  2010-11-23 23:29 ` PATCH 00/13] BNX2I: Patch set to fix various bug fixes Eddie Wai
@ 2010-11-23 23:29 ` Eddie Wai
  2010-11-23 23:29 ` [PATCH v3 02/13] BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In Eddie Wai
                   ` (49 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-23 23:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Unsolicited NOP-Ins are placed in the receive queue of the hardware
which requires to be read out regardless if the receive pipe is suspended
or not.  This patch adds the disposal of this RQ element under this
condition.
Also fixed the bug in the unsolicited NOP-In handling routine which
checks for the RESERVED_ITT.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 8d9dbb3..16c76e0 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1549,11 +1549,9 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session,
 	struct iscsi_task *task;
 	struct bnx2i_nop_in_msg *nop_in;
 	struct iscsi_nopin *hdr;
-	u32 itt;
 	int tgt_async_nop = 0;
 
 	nop_in = (struct bnx2i_nop_in_msg *)cqe;
-	itt = nop_in->itt & ISCSI_NOP_IN_MSG_INDEX;
 
 	spin_lock(&session->lock);
 	hdr = (struct iscsi_nopin *)&bnx2i_conn->gen_pdu.resp_hdr;
@@ -1563,7 +1561,7 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session,
 	hdr->exp_cmdsn = cpu_to_be32(nop_in->exp_cmd_sn);
 	hdr->ttt = cpu_to_be32(nop_in->ttt);
 
-	if (itt == (u16) RESERVED_ITT) {
+	if (nop_in->itt == (u16) RESERVED_ITT) {
 		bnx2i_unsol_pdu_adjust_rq(bnx2i_conn);
 		hdr->itt = RESERVED_ITT;
 		tgt_async_nop = 1;
@@ -1571,7 +1569,8 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session,
 	}
 
 	/* this is a response to one of our nop-outs */
-	task = iscsi_itt_to_task(conn, itt);
+	task = iscsi_itt_to_task(conn,
+			 (itt_t) (nop_in->itt & ISCSI_NOP_IN_MSG_INDEX));
 	if (task) {
 		hdr->flags = ISCSI_FLAG_CMD_FINAL;
 		hdr->itt = task->hdr->itt;
@@ -1721,9 +1720,18 @@ static void bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
 		if (nopin->cq_req_sn != qp->cqe_exp_seq_sn)
 			break;
 
-		if (unlikely(test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx)))
+		if (unlikely(test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx))) {
+			if (nopin->op_code == ISCSI_OP_NOOP_IN &&
+			    nopin->itt == (u16) RESERVED_ITT) {
+				printk(KERN_ALERT "bnx2i: Unsolicited "
+					"NOP-In detected for suspended "
+					"connection dev=%s!\n",
+					bnx2i_conn->hba->netdev->name);
+				bnx2i_unsol_pdu_adjust_rq(bnx2i_conn);
+				goto cqe_out;
+			}
 			break;
-
+		}
 		tgt_async_msg = 0;
 
 		switch (nopin->op_code) {
@@ -1770,10 +1778,9 @@ static void bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
 			printk(KERN_ALERT "bnx2i: unknown opcode 0x%x\n",
 					  nopin->op_code);
 		}
-
 		if (!tgt_async_msg)
 			bnx2i_conn->ep->num_active_cmds--;
-
+cqe_out:
 		/* clear out in production version only, till beta keep opcode
 		 * field intact, will be helpful in debugging (context dump)
 		 * nopin->op_code = 0;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v3 02/13] BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (59 preceding siblings ...)
  2010-11-23 23:29 ` [PATCH v3 01/13] BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins Eddie Wai
@ 2010-11-23 23:29 ` Eddie Wai
  2010-11-23 23:29 ` [PATCH v3 03/13] BNX2I: Fixed the endian bug in the TMF LUN cmd send Eddie Wai
                   ` (48 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-23 23:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The patch fixes the following situations where NOP-Out pkt is called for:
- local unsolicited NOP-Out requests (requesting no NOP-In response)
- local NOP-Out responses to unsolicited NOP-In requests

kernel panic is observed due to double session spin_lock requests; one in the
bnx2i_process_nopin_local_cmpl routine in bnx2i_hwi.c and the other in the
iscsi_put_task routine in libiscsi.c

The proposed fix is to export the currently static __iscsi_put_task() routine
and have bnx2i call it directly instead of the iscsi_put_task() routine which
holds the session spin lock.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Acked-by: Benjamin Li <benli@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |    2 +-
 drivers/scsi/libiscsi.c        |    3 ++-
 include/scsi/libiscsi.h        |    1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 16c76e0..32cf930 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1513,7 +1513,7 @@ static void bnx2i_process_nopin_local_cmpl(struct iscsi_session *session,
 	task = iscsi_itt_to_task(conn,
 				 nop_in->itt & ISCSI_NOP_IN_MSG_INDEX);
 	if (task)
-		iscsi_put_task(task);
+		__iscsi_put_task(task);
 	spin_unlock(&session->lock);
 }
 
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 633e090..b63e2a4 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -539,11 +539,12 @@ void __iscsi_get_task(struct iscsi_task *task)
 }
 EXPORT_SYMBOL_GPL(__iscsi_get_task);
 
-static void __iscsi_put_task(struct iscsi_task *task)
+void __iscsi_put_task(struct iscsi_task *task)
 {
 	if (atomic_dec_and_test(&task->refcount))
 		iscsi_free_task(task);
 }
+EXPORT_SYMBOL_GPL(__iscsi_put_task);
 
 void iscsi_put_task(struct iscsi_task *task)
 {
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index ae5196a..2ea9aec 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -420,6 +420,7 @@ extern struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *, itt_t);
 extern struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *, itt_t);
 extern void iscsi_requeue_task(struct iscsi_task *task);
 extern void iscsi_put_task(struct iscsi_task *task);
+extern void __iscsi_put_task(struct iscsi_task *task);
 extern void __iscsi_get_task(struct iscsi_task *task);
 extern void iscsi_complete_scsi_task(struct iscsi_task *task,
 				     uint32_t exp_cmdsn, uint32_t max_cmdsn);
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v3 03/13] BNX2I: Fixed the endian bug in the TMF LUN cmd send
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (60 preceding siblings ...)
  2010-11-23 23:29 ` [PATCH v3 02/13] BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In Eddie Wai
@ 2010-11-23 23:29 ` Eddie Wai
  2010-11-23 23:29 ` [PATCH v3 04/13] BNX2I: Fixed a cid leak issue for 5771X (10g) Eddie Wai
                   ` (47 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-23 23:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Added a be32_to_cpu call for the TMF LUN wqe.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 32cf930..c9a3c0f 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -385,6 +385,7 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn,
 	struct bnx2i_cmd *bnx2i_cmd;
 	struct bnx2i_tmf_request *tmfabort_wqe;
 	u32 dword;
+	u32 scsi_lun[2];
 
 	bnx2i_cmd = (struct bnx2i_cmd *)mtask->dd_data;
 	tmfabort_hdr = (struct iscsi_tm *)mtask->hdr;
@@ -426,7 +427,10 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn,
 	default:
 		tmfabort_wqe->ref_itt = RESERVED_ITT;
 	}
-	memcpy(tmfabort_wqe->lun, tmfabort_hdr->lun, sizeof(struct scsi_lun));
+	memcpy(scsi_lun, tmfabort_hdr->lun, sizeof(struct scsi_lun));
+	tmfabort_wqe->lun[0] = be32_to_cpu(scsi_lun[0]);
+	tmfabort_wqe->lun[1] = be32_to_cpu(scsi_lun[1]);
+
 	tmfabort_wqe->ref_cmd_sn = be32_to_cpu(tmfabort_hdr->refcmdsn);
 
 	tmfabort_wqe->bd_list_addr_lo = (u32) bnx2i_conn->hba->mp_bd_dma;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v3 04/13] BNX2I: Fixed a cid leak issue for 5771X (10g)
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (61 preceding siblings ...)
  2010-11-23 23:29 ` [PATCH v3 03/13] BNX2I: Fixed the endian bug in the TMF LUN cmd send Eddie Wai
@ 2010-11-23 23:29 ` Eddie Wai
  2010-11-23 23:29 ` [PATCH v3 05/13] BNX2I: Fixed the remote TCP RST handling for the 570X (1g) Eddie Wai
                   ` (46 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-23 23:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

A cid leak issue was found when the connect destroy request exceeded
the driver's disconnection timeout.  This will lead to a cid resource
leak issue.
The fix is to allow the cid cleanup even when this happens.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index fb50efb..b766812 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1640,18 +1640,26 @@ no_nx2_route:
 static int bnx2i_tear_down_conn(struct bnx2i_hba *hba,
 				 struct bnx2i_endpoint *ep)
 {
-	if (test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic))
+	if (test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic) && ep->cm_sk)
 		hba->cnic->cm_destroy(ep->cm_sk);
 
-	if (test_bit(ADAPTER_STATE_GOING_DOWN, &ep->hba->adapter_state))
-		ep->state = EP_STATE_DISCONN_COMPL;
-
 	if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type) &&
 	    ep->state == EP_STATE_DISCONN_TIMEDOUT) {
-		printk(KERN_ALERT "bnx2i - ERROR - please submit GRC Dump,"
-				  " NW/PCIe trace, driver msgs to developers"
-				  " for analysis\n");
-		return 1;
+		if (ep->conn && ep->conn->cls_conn &&
+		    ep->conn->cls_conn->dd_data) {
+			struct iscsi_conn *conn = ep->conn->cls_conn->dd_data;
+
+			/* Must suspend all rx queue activity for this ep */
+			set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
+		}
+		/* CONN_DISCONNECT timeout may or may not be an issue depending
+		 * on what transcribed in TCP layer, different targets behave
+		 * differently
+		 */
+		printk(KERN_ALERT "bnx2i (%s): - WARN - CONN_DISCON timed out, "
+				  "please submit GRC Dump, NW/PCIe trace, "
+				  "driver msgs to developers for analysis\n",
+				  hba->netdev->name);
 	}
 
 	ep->state = EP_STATE_CLEANUP_START;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v3 05/13] BNX2I: Fixed the remote TCP RST handling for the 570X (1g)
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (62 preceding siblings ...)
  2010-11-23 23:29 ` [PATCH v3 04/13] BNX2I: Fixed a cid leak issue for 5771X (10g) Eddie Wai
@ 2010-11-23 23:29 ` Eddie Wai
  2010-11-23 23:29 ` [PATCH v3 06/13] BNX2I: Allow to abort the connection if connect request times out Eddie Wai
                   ` (45 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-23 23:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Modified the handling of the remote TCP RST code so the chip can now
flush the tx pipe accordingly upon a remote TCP RST reception.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c   |    8 ++++++--
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    8 +++-----
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index c9a3c0f..0d40dae 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -2350,10 +2350,14 @@ static void bnx2i_cm_remote_close(struct cnic_sock *cm_sk)
 static void bnx2i_cm_remote_abort(struct cnic_sock *cm_sk)
 {
 	struct bnx2i_endpoint *ep = (struct bnx2i_endpoint *) cm_sk->context;
+	u32 old_state = ep->state;
 
 	ep->state = EP_STATE_TCP_RST_RCVD;
-	if (ep->conn)
-		bnx2i_recovery_que_add_conn(ep->hba, ep->conn);
+	if (old_state == EP_STATE_DISCONN_START)
+		wake_up_interruptible(&ep->ofld_wait);
+	else
+		if (ep->conn)
+			bnx2i_recovery_que_add_conn(ep->hba, ep->conn);
 }
 
 
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index b766812..4882b00 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1907,6 +1907,7 @@ static int bnx2i_ep_tcp_conn_active(struct bnx2i_endpoint *bnx2i_ep)
 
 	switch (bnx2i_ep->state) {
 	case EP_STATE_CONNECT_START:
+	case EP_STATE_CONNECT_FAILED:
 	case EP_STATE_CLEANUP_FAILED:
 	case EP_STATE_OFLD_FAILED:
 	case EP_STATE_DISCONN_TIMEDOUT:
@@ -1922,13 +1923,10 @@ static int bnx2i_ep_tcp_conn_active(struct bnx2i_endpoint *bnx2i_ep)
 		ret = 1;
 		break;
 	case EP_STATE_TCP_RST_RCVD:
-		ret = 0;
-		break;
-	case EP_STATE_CONNECT_FAILED:
 		if (cnic_dev_10g)
-			ret = 1;
-		else
 			ret = 0;
+		else
+			ret = 1;
 		break;
 	default:
 		ret = 0;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v3 06/13] BNX2I: Allow to abort the connection if connect request times out
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (63 preceding siblings ...)
  2010-11-23 23:29 ` [PATCH v3 05/13] BNX2I: Fixed the remote TCP RST handling for the 570X (1g) Eddie Wai
@ 2010-11-23 23:29 ` Eddie Wai
  2010-11-23 23:29 ` [PATCH v3 08/13] BNX2I: Removed the dynamic registration of CNIC Eddie Wai
                   ` (44 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-23 23:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

In the situation where the connect completion response arrives after
the connect request has already timed out, the connection was not being
aborted but only the resource was being freed.  This creates a problem
for 5771X (10g) as the chip flags this with an assertion.

This change will properly aborts the connection before freeing the
resource.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 4882b00..a2c9b1f 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1906,13 +1906,13 @@ static int bnx2i_ep_tcp_conn_active(struct bnx2i_endpoint *bnx2i_ep)
 		cnic_dev_10g = 1;
 
 	switch (bnx2i_ep->state) {
-	case EP_STATE_CONNECT_START:
 	case EP_STATE_CONNECT_FAILED:
 	case EP_STATE_CLEANUP_FAILED:
 	case EP_STATE_OFLD_FAILED:
 	case EP_STATE_DISCONN_TIMEDOUT:
 		ret = 0;
 		break;
+	case EP_STATE_CONNECT_START:
 	case EP_STATE_CONNECT_COMPL:
 	case EP_STATE_ULP_UPDATE_START:
 	case EP_STATE_ULP_UPDATE_COMPL:
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v3 07/13] BNX2I: Added mutex lock protection to conn_get_param
       [not found] ` <Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
                     ` (5 preceding siblings ...)
  2010-11-10 23:04   ` [PATCH 10/16] BNX2I: Fixed a cid leak issue for 5771X (10g) Eddie Wai
@ 2010-11-23 23:29   ` Eddie Wai
  2012-02-02 23:22   ` [PATCH] BNX2I: Fixed the override of the error_mask module param Eddie Wai
                     ` (4 subsequent siblings)
  11 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-23 23:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Added net_dev mutex lock protection before accessing the csk
parameters.

Signed-off-by: Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Reviewed-by: Benjamin Li <benli-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index a2c9b1f..07dd4f9 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1461,21 +1461,28 @@ static int bnx2i_conn_get_param(struct iscsi_cls_conn *cls_conn,
 	struct bnx2i_conn *bnx2i_conn = conn->dd_data;
 	int len = 0;
 
+	if (!(bnx2i_conn && bnx2i_conn->ep && bnx2i_conn->ep->hba))
+		goto out;
+
 	switch (param) {
 	case ISCSI_PARAM_CONN_PORT:
-		if (bnx2i_conn->ep)
+		mutex_lock(&bnx2i_conn->ep->hba->net_dev_lock);
+		if (bnx2i_conn->ep->cm_sk)
 			len = sprintf(buf, "%hu\n",
 				      bnx2i_conn->ep->cm_sk->dst_port);
+		mutex_unlock(&bnx2i_conn->ep->hba->net_dev_lock);
 		break;
 	case ISCSI_PARAM_CONN_ADDRESS:
-		if (bnx2i_conn->ep)
+		mutex_lock(&bnx2i_conn->ep->hba->net_dev_lock);
+		if (bnx2i_conn->ep->cm_sk)
 			len = sprintf(buf, "%pI4\n",
 				      &bnx2i_conn->ep->cm_sk->dst_ip);
+		mutex_unlock(&bnx2i_conn->ep->hba->net_dev_lock);
 		break;
 	default:
 		return iscsi_conn_get_param(cls_conn, param, buf);
 	}
-
+out:
 	return len;
 }
 
-- 
1.7.0.5


-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v3 08/13] BNX2I: Removed the dynamic registration of CNIC
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (64 preceding siblings ...)
  2010-11-23 23:29 ` [PATCH v3 06/13] BNX2I: Allow to abort the connection if connect request times out Eddie Wai
@ 2010-11-23 23:29 ` Eddie Wai
  2010-11-23 23:29 ` [PATCH v3 09/13] BNX2I: Modified the bnx2i stop path to compensate for in progress ops Eddie Wai
                   ` (43 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-23 23:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The code no longer needs to dynamically register and unregister
the CNIC device.  The CNIC device will be kept registered until
module unload.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |    3 -
 drivers/scsi/bnx2i/bnx2i_init.c  |   82 --------------------------------------
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    7 ---
 3 files changed, 0 insertions(+), 92 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index a44b1b3..2c34e22 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -717,14 +717,11 @@ extern struct device_attribute *bnx2i_dev_attributes[];
  * Function Prototypes
  */
 extern void bnx2i_identify_device(struct bnx2i_hba *hba);
-extern void bnx2i_register_device(struct bnx2i_hba *hba);
 
 extern void bnx2i_ulp_init(struct cnic_dev *dev);
 extern void bnx2i_ulp_exit(struct cnic_dev *dev);
 extern void bnx2i_start(void *handle);
 extern void bnx2i_stop(void *handle);
-extern void bnx2i_reg_dev_all(void);
-extern void bnx2i_unreg_dev_all(void);
 extern struct bnx2i_hba *get_adapter_list_head(void);
 
 struct bnx2i_conn *bnx2i_get_conn_from_id(struct bnx2i_hba *hba,
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 50c2aa3..769311f 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -65,8 +65,6 @@ MODULE_PARM_DESC(rq_size, "Configure RQ size");
 
 u64 iscsi_error_mask = 0x00;
 
-static void bnx2i_unreg_one_device(struct bnx2i_hba *hba) ;
-
 
 /**
  * bnx2i_identify_device - identifies NetXtreme II device type
@@ -239,86 +237,6 @@ void bnx2i_stop(void *handle)
 }
 
 /**
- * bnx2i_register_device - register bnx2i adapter instance with the cnic driver
- * @hba:	Adapter instance to register
- *
- * registers bnx2i adapter instance with the cnic driver while holding the
- *	adapter structure lock
- */
-void bnx2i_register_device(struct bnx2i_hba *hba)
-{
-	int rc;
-
-	if (test_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state) ||
-	    test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic)) {
-		return;
-	}
-
-	rc = hba->cnic->register_device(hba->cnic, CNIC_ULP_ISCSI, hba);
-
-	if (!rc)
-		set_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic);
-}
-
-
-/**
- * bnx2i_reg_dev_all - registers all adapter instances with the cnic driver
- *
- * registers all bnx2i adapter instances with the cnic driver while holding
- *	the global resource lock
- */
-void bnx2i_reg_dev_all(void)
-{
-	struct bnx2i_hba *hba, *temp;
-
-	mutex_lock(&bnx2i_dev_lock);
-	list_for_each_entry_safe(hba, temp, &adapter_list, link)
-		bnx2i_register_device(hba);
-	mutex_unlock(&bnx2i_dev_lock);
-}
-
-
-/**
- * bnx2i_unreg_one_device - unregister adapter instance with the cnic driver
- * @hba:	Adapter instance to unregister
- *
- * registers bnx2i adapter instance with the cnic driver while holding
- *	the adapter structure lock
- */
-static void bnx2i_unreg_one_device(struct bnx2i_hba *hba)
-{
-	if (hba->ofld_conns_active ||
-	    !test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic) ||
-	    test_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state))
-		return;
-
-	hba->cnic->unregister_device(hba->cnic, CNIC_ULP_ISCSI);
-
-	/* ep_disconnect could come before NETDEV_DOWN, driver won't
-	 * see NETDEV_DOWN as it already unregistered itself.
-	 */
-	hba->adapter_state = 0;
-	clear_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic);
-}
-
-/**
- * bnx2i_unreg_dev_all - unregisters all bnx2i instances with the cnic driver
- *
- * unregisters all bnx2i adapter instances with the cnic driver while holding
- *	the global resource lock
- */
-void bnx2i_unreg_dev_all(void)
-{
-	struct bnx2i_hba *hba, *temp;
-
-	mutex_lock(&bnx2i_dev_lock);
-	list_for_each_entry_safe(hba, temp, &adapter_list, link)
-		bnx2i_unreg_one_device(hba);
-	mutex_unlock(&bnx2i_dev_lock);
-}
-
-
-/**
  * bnx2i_init_one - initialize an adapter instance and allocate memory resources
  * @hba:	bnx2i adapter instance
  * @cnic:	cnic device handle
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 07dd4f9..43b7dad 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1606,8 +1606,6 @@ static struct bnx2i_hba *bnx2i_check_route(struct sockaddr *dst_addr)
 	struct bnx2i_hba *hba;
 	struct cnic_dev *cnic = NULL;
 
-	bnx2i_reg_dev_all();
-
 	hba = get_adapter_list_head();
 	if (hba && hba->cnic)
 		cnic = hba->cnic->cm_select_dev(desti, CNIC_ULP_ISCSI);
@@ -1726,8 +1724,6 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	if (shost) {
 		/* driver is given scsi host to work with */
 		hba = iscsi_host_priv(shost);
-		/* Register the device with cnic if not already done so */
-		bnx2i_register_device(hba);
 	} else
 		/*
 		 * check if the given destination can be reached through
@@ -1853,7 +1849,6 @@ qp_resc_err:
 check_busy:
 	mutex_unlock(&hba->net_dev_lock);
 nohba:
-	bnx2i_unreg_dev_all();
 	return ERR_PTR(rc);
 }
 
@@ -2089,8 +2084,6 @@ return_bnx2i_ep:
 
 	bnx2i_free_ep(ep);
 	mutex_unlock(&hba->net_dev_lock);
-	if (!hba->ofld_conns_active)
-		bnx2i_unreg_dev_all();
 
 	wake_up_interruptible(&hba->eh_wait);
 }
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v3 09/13] BNX2I: Modified the bnx2i stop path to compensate for in progress ops
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (65 preceding siblings ...)
  2010-11-23 23:29 ` [PATCH v3 08/13] BNX2I: Removed the dynamic registration of CNIC Eddie Wai
@ 2010-11-23 23:29 ` Eddie Wai
  2010-11-23 23:29 ` [PATCH v3 10/13] BNX2I: Added return code check for chip kwqe submission request Eddie Wai
                   ` (42 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-23 23:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The stop path has been augmented to wait a max of 10s for all in
progress offload and destroy activities to complete before proceeding
to terminate all active connections (via iscsid or forcefully).

Note that any new offload and destroy requests are now blocked and
return to the caller immediately.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_init.c  |   21 +++++++++++++++++----
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    7 ++++++-
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 769311f..338caac 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -209,13 +209,24 @@ void bnx2i_stop(void *handle)
 {
 	struct bnx2i_hba *hba = handle;
 	int conns_active;
+	int wait_delay = 1 * HZ;
 
 	/* check if cleanup happened in GOING_DOWN context */
-	if (!test_and_clear_bit(ADAPTER_STATE_GOING_DOWN,
-				&hba->adapter_state))
+	if (!test_and_set_bit(ADAPTER_STATE_GOING_DOWN,
+			      &hba->adapter_state)) {
 		iscsi_host_for_each_session(hba->shost,
 					    bnx2i_drop_session);
-
+		wait_delay = hba->hba_shutdown_tmo;
+	}
+	/* Wait for inflight offload connection tasks to complete before
+	 * proceeding. Forcefully terminate all connection recovery in
+	 * progress at the earliest, either in bind(), send_pdu(LOGIN),
+	 * or conn_start()
+	 */
+	wait_event_interruptible_timeout(hba->eh_wait,
+					 (list_empty(&hba->ep_ofld_list) &&
+					 list_empty(&hba->ep_destroy_list)),
+					 10 * HZ);
 	/* Wait for all endpoints to be torn down, Chip will be reset once
 	 *  control returns to network driver. So it is required to cleanup and
 	 * release all connection resources before returning from this routine.
@@ -224,7 +235,7 @@ void bnx2i_stop(void *handle)
 		conns_active = hba->ofld_conns_active;
 		wait_event_interruptible_timeout(hba->eh_wait,
 				(hba->ofld_conns_active != conns_active),
-				hba->hba_shutdown_tmo);
+				wait_delay);
 		if (hba->ofld_conns_active == conns_active)
 			break;
 	}
@@ -233,9 +244,11 @@ void bnx2i_stop(void *handle)
 	/* This flag should be cleared last so that ep_disconnect() gracefully
 	 * cleans up connection context
 	 */
+	clear_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state);
 	clear_bit(ADAPTER_STATE_UP, &hba->adapter_state);
 }
 
+
 /**
  * bnx2i_init_one - initialize an adapter instance and allocate memory resources
  * @hba:	bnx2i adapter instance
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 43b7dad..ac60c4c 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1383,6 +1383,12 @@ static int bnx2i_conn_bind(struct iscsi_cls_session *cls_session,
 	ep = iscsi_lookup_endpoint(transport_fd);
 	if (!ep)
 		return -EINVAL;
+	/*
+	 * Forcefully terminate all in progress connection recovery at the
+	 * earliest, either in bind(), send_pdu(LOGIN), or conn_start()
+	 */
+	if (bnx2i_adapter_ready(hba))
+		return -EIO;
 
 	bnx2i_ep = ep->dd_data;
 	if ((bnx2i_ep->state == EP_STATE_TCP_FIN_RCVD) ||
@@ -1404,7 +1410,6 @@ static int bnx2i_conn_bind(struct iscsi_cls_session *cls_session,
 				  hba->netdev->name);
 		return -EEXIST;
 	}
-
 	bnx2i_ep->conn = bnx2i_conn;
 	bnx2i_conn->ep = bnx2i_ep;
 	bnx2i_conn->iscsi_conn_cid = bnx2i_ep->ep_iscsi_cid;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v3 10/13] BNX2I: Added return code check for chip kwqe submission request
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (66 preceding siblings ...)
  2010-11-23 23:29 ` [PATCH v3 09/13] BNX2I: Modified the bnx2i stop path to compensate for in progress ops Eddie Wai
@ 2010-11-23 23:29 ` Eddie Wai
  2010-11-23 23:29 ` [PATCH v3 11/13] BNX2I: Cleaned up various error conditions in ep_connect/disconnect Eddie Wai
                   ` (41 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-23 23:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Added the handling for cases when a chip request is made to the
CNIC module but the hardware is not ready to accept.  This would
lead to many unnecessary wait timeouts.
This code adds check in the connect establishment and destruction
path.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |    9 +++---
 drivers/scsi/bnx2i/bnx2i_hwi.c   |   54 ++++++++++++++++++++++++++++----------
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   17 ++++++++++-
 3 files changed, 60 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 2c34e22..866a22c 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -649,6 +649,7 @@ enum {
 	EP_STATE_OFLD_FAILED            = 0x8000000,
 	EP_STATE_CONNECT_FAILED         = 0x10000000,
 	EP_STATE_DISCONN_TIMEDOUT       = 0x20000000,
+	EP_STATE_OFLD_FAILED_CID_BUSY   = 0x80000000,
 };
 
 /**
@@ -758,11 +759,11 @@ extern int bnx2i_send_iscsi_logout(struct bnx2i_conn *conn,
 				   struct iscsi_task *mtask);
 extern void bnx2i_send_cmd_cleanup_req(struct bnx2i_hba *hba,
 				       struct bnx2i_cmd *cmd);
-extern void bnx2i_send_conn_ofld_req(struct bnx2i_hba *hba,
-				     struct bnx2i_endpoint *ep);
-extern void bnx2i_update_iscsi_conn(struct iscsi_conn *conn);
-extern void bnx2i_send_conn_destroy(struct bnx2i_hba *hba,
+extern int bnx2i_send_conn_ofld_req(struct bnx2i_hba *hba,
 				    struct bnx2i_endpoint *ep);
+extern void bnx2i_update_iscsi_conn(struct iscsi_conn *conn);
+extern int bnx2i_send_conn_destroy(struct bnx2i_hba *hba,
+				   struct bnx2i_endpoint *ep);
 
 extern int bnx2i_alloc_qp_resc(struct bnx2i_hba *hba,
 			       struct bnx2i_endpoint *ep);
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 0d40dae..6d99040 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -701,10 +701,11 @@ void bnx2i_send_cmd_cleanup_req(struct bnx2i_hba *hba, struct bnx2i_cmd *cmd)
  * this routine prepares and posts CONN_OFLD_REQ1/2 KWQE to initiate
  * 	iscsi connection context clean-up process
  */
-void bnx2i_send_conn_destroy(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep)
+int bnx2i_send_conn_destroy(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep)
 {
 	struct kwqe *kwqe_arr[2];
 	struct iscsi_kwqe_conn_destroy conn_cleanup;
+	int rc = -EINVAL;
 
 	memset(&conn_cleanup, 0x00, sizeof(struct iscsi_kwqe_conn_destroy));
 
@@ -721,7 +722,9 @@ void bnx2i_send_conn_destroy(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep)
 
 	kwqe_arr[0] = (struct kwqe *) &conn_cleanup;
 	if (hba->cnic && hba->cnic->submit_kwqes)
-		hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, 1);
+		rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, 1);
+
+	return rc;
 }
 
 
@@ -732,8 +735,8 @@ void bnx2i_send_conn_destroy(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep)
  *
  * 5706/5708/5709 specific - prepares and posts CONN_OFLD_REQ1/2 KWQE
  */
-static void bnx2i_570x_send_conn_ofld_req(struct bnx2i_hba *hba,
-					  struct bnx2i_endpoint *ep)
+static int bnx2i_570x_send_conn_ofld_req(struct bnx2i_hba *hba,
+					 struct bnx2i_endpoint *ep)
 {
 	struct kwqe *kwqe_arr[2];
 	struct iscsi_kwqe_conn_offload1 ofld_req1;
@@ -741,6 +744,7 @@ static void bnx2i_570x_send_conn_ofld_req(struct bnx2i_hba *hba,
 	dma_addr_t dma_addr;
 	int num_kwqes = 2;
 	u32 *ptbl;
+	int rc = -EINVAL;
 
 	ofld_req1.hdr.op_code = ISCSI_KWQE_OPCODE_OFFLOAD_CONN1;
 	ofld_req1.hdr.flags =
@@ -778,7 +782,9 @@ static void bnx2i_570x_send_conn_ofld_req(struct bnx2i_hba *hba,
 	ofld_req2.num_additional_wqes = 0;
 
 	if (hba->cnic && hba->cnic->submit_kwqes)
-		hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes);
+		rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes);
+
+	return rc;
 }
 
 
@@ -789,8 +795,8 @@ static void bnx2i_570x_send_conn_ofld_req(struct bnx2i_hba *hba,
  *
  * 57710 specific - prepares and posts CONN_OFLD_REQ1/2 KWQE
  */
-static void bnx2i_5771x_send_conn_ofld_req(struct bnx2i_hba *hba,
-					   struct bnx2i_endpoint *ep)
+static int bnx2i_5771x_send_conn_ofld_req(struct bnx2i_hba *hba,
+					  struct bnx2i_endpoint *ep)
 {
 	struct kwqe *kwqe_arr[5];
 	struct iscsi_kwqe_conn_offload1 ofld_req1;
@@ -799,6 +805,7 @@ static void bnx2i_5771x_send_conn_ofld_req(struct bnx2i_hba *hba,
 	dma_addr_t dma_addr;
 	int num_kwqes = 2;
 	u32 *ptbl;
+	int rc = -EINVAL;
 
 	ofld_req1.hdr.op_code = ISCSI_KWQE_OPCODE_OFFLOAD_CONN1;
 	ofld_req1.hdr.flags =
@@ -844,7 +851,9 @@ static void bnx2i_5771x_send_conn_ofld_req(struct bnx2i_hba *hba,
 	num_kwqes += 1;
 
 	if (hba->cnic && hba->cnic->submit_kwqes)
-		hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes);
+		rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes);
+
+	return rc;
 }
 
 /**
@@ -855,12 +864,16 @@ static void bnx2i_5771x_send_conn_ofld_req(struct bnx2i_hba *hba,
  *
  * this routine prepares and posts CONN_OFLD_REQ1/2 KWQE
  */
-void bnx2i_send_conn_ofld_req(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep)
+int bnx2i_send_conn_ofld_req(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep)
 {
+	int rc;
+
 	if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type))
-		bnx2i_5771x_send_conn_ofld_req(hba, ep);
+		rc = bnx2i_5771x_send_conn_ofld_req(hba, ep);
 	else
-		bnx2i_570x_send_conn_ofld_req(hba, ep);
+		rc = bnx2i_570x_send_conn_ofld_req(hba, ep);
+
+	return rc;
 }
 
 
@@ -2165,11 +2178,24 @@ static void bnx2i_process_ofld_cmpl(struct bnx2i_hba *hba,
 	}
 
 	if (ofld_kcqe->completion_status) {
+		ep->state = EP_STATE_OFLD_FAILED;
 		if (ofld_kcqe->completion_status ==
 		    ISCSI_KCQE_COMPLETION_STATUS_CTX_ALLOC_FAILURE)
-			printk(KERN_ALERT "bnx2i: unable to allocate"
-					  " iSCSI context resources\n");
-		ep->state = EP_STATE_OFLD_FAILED;
+			printk(KERN_ALERT "bnx2i (%s): ofld1 cmpl - unable "
+				"to allocate iSCSI context resources\n",
+				hba->netdev->name);
+		else if (ofld_kcqe->completion_status ==
+			 ISCSI_KCQE_COMPLETION_STATUS_INVALID_OPCODE)
+			printk(KERN_ALERT "bnx2i (%s): ofld1 cmpl - invalid "
+				"opcode\n", hba->netdev->name);
+		else if (ofld_kcqe->completion_status ==
+			ISCSI_KCQE_COMPLETION_STATUS_CID_BUSY)
+			/* error status code valid only for 5771x chipset */
+			ep->state = EP_STATE_OFLD_FAILED_CID_BUSY;
+		else
+			printk(KERN_ALERT "bnx2i (%s): ofld1 cmpl - invalid "
+				"error code %d\n", hba->netdev->name,
+				ofld_kcqe->completion_status);
 	} else {
 		ep->state = EP_STATE_OFLD_COMPL;
 		cid_addr = ofld_kcqe->iscsi_conn_context_id;
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index ac60c4c..f622e89 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1682,7 +1682,9 @@ static int bnx2i_tear_down_conn(struct bnx2i_hba *hba,
 	bnx2i_ep_destroy_list_add(hba, ep);
 
 	/* destroy iSCSI context, wait for it to complete */
-	bnx2i_send_conn_destroy(hba, ep);
+	if (bnx2i_send_conn_destroy(hba, ep))
+		ep->state = EP_STATE_CLEANUP_CMPL;
+
 	wait_event_interruptible(ep->ofld_wait,
 				 (ep->state != EP_STATE_CLEANUP_START));
 
@@ -1781,7 +1783,18 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	bnx2i_ep->ofld_timer.data = (unsigned long) bnx2i_ep;
 	add_timer(&bnx2i_ep->ofld_timer);
 
-	bnx2i_send_conn_ofld_req(hba, bnx2i_ep);
+	if (bnx2i_send_conn_ofld_req(hba, bnx2i_ep)) {
+		if (bnx2i_ep->state == EP_STATE_OFLD_FAILED_CID_BUSY) {
+			printk(KERN_ALERT "bnx2i (%s): iscsi cid %d is busy\n",
+				hba->netdev->name, bnx2i_ep->ep_iscsi_cid);
+			rc = -EBUSY;
+		} else
+			rc = -ENOSPC;
+		printk(KERN_ALERT "bnx2i (%s): unable to send conn offld kwqe"
+			"\n", hba->netdev->name);
+		bnx2i_ep_ofld_list_del(hba, bnx2i_ep);
+		goto conn_failed;
+	}
 
 	/* Wait for CNIC hardware to setup conn context and return 'cid' */
 	wait_event_interruptible(bnx2i_ep->ofld_wait,
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v3 11/13] BNX2I: Cleaned up various error conditions in ep_connect/disconnect
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (67 preceding siblings ...)
  2010-11-23 23:29 ` [PATCH v3 10/13] BNX2I: Added return code check for chip kwqe submission request Eddie Wai
@ 2010-11-23 23:29 ` Eddie Wai
  2010-11-23 23:29 ` [PATCH v3 12/13] BNX2I: Updated copyright and maintainer info Eddie Wai
                   ` (40 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-23 23:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Various error conditions inside ep_connect and ep_disconnect were
either not being handled or not being handled correctly.  This patch
fixes all those issues.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   67 ++++++++++++++++++++++---------------
 1 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index f622e89..24997c6 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -411,7 +411,9 @@ static void bnx2i_free_ep(struct iscsi_endpoint *ep)
 	bnx2i_ep->state = EP_STATE_IDLE;
 	bnx2i_ep->hba->ofld_conns_active--;
 
-	bnx2i_free_iscsi_cid(bnx2i_ep->hba, bnx2i_ep->ep_iscsi_cid);
+	if (bnx2i_ep->ep_iscsi_cid != (u16) -1)
+		bnx2i_free_iscsi_cid(bnx2i_ep->hba, bnx2i_ep->ep_iscsi_cid);
+
 	if (bnx2i_ep->conn) {
 		bnx2i_ep->conn->ep = NULL;
 		bnx2i_ep->conn = NULL;
@@ -1738,13 +1740,17 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 		 */
 		hba = bnx2i_check_route(dst_addr);
 
-	if (!hba || test_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state)) {
+	if (!hba) {
 		rc = -EINVAL;
 		goto nohba;
 	}
+	mutex_lock(&hba->net_dev_lock);
 
+	if (bnx2i_adapter_ready(hba) || !hba->cid_que.cid_free_cnt) {
+		rc = -EPERM;
+		goto check_busy;
+	}
 	cnic = hba->cnic;
-	mutex_lock(&hba->net_dev_lock);
 	ep = bnx2i_alloc_ep(hba);
 	if (!ep) {
 		rc = -ENOMEM;
@@ -1752,23 +1758,21 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	}
 	bnx2i_ep = ep->dd_data;
 
-	if (bnx2i_adapter_ready(hba)) {
-		rc = -EPERM;
-		goto net_if_down;
-	}
-
 	bnx2i_ep->num_active_cmds = 0;
 	iscsi_cid = bnx2i_alloc_iscsi_cid(hba);
 	if (iscsi_cid == -1) {
-		printk(KERN_ALERT "alloc_ep: unable to allocate iscsi cid\n");
+		printk(KERN_ALERT "bnx2i (%s): alloc_ep - unable to allocate "
+			"iscsi cid\n", hba->netdev->name);
 		rc = -ENOMEM;
-		goto iscsi_cid_err;
+		bnx2i_free_ep(ep);
+		goto check_busy;
 	}
 	bnx2i_ep->hba_age = hba->age;
 
 	rc = bnx2i_alloc_qp_resc(hba, bnx2i_ep);
 	if (rc != 0) {
-		printk(KERN_ALERT "bnx2i: ep_conn, alloc QP resc error\n");
+		printk(KERN_ALERT "bnx2i (%s): ep_conn - alloc QP resc error"
+			"\n", hba->netdev->name);
 		rc = -ENOMEM;
 		goto qp_resc_err;
 	}
@@ -1807,7 +1811,12 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	bnx2i_ep_ofld_list_del(hba, bnx2i_ep);
 
 	if (bnx2i_ep->state != EP_STATE_OFLD_COMPL) {
-		rc = -ENOSPC;
+		if (bnx2i_ep->state == EP_STATE_OFLD_FAILED_CID_BUSY) {
+			printk(KERN_ALERT "bnx2i (%s): iscsi cid %d is busy\n",
+				hba->netdev->name, bnx2i_ep->ep_iscsi_cid);
+			rc = -EBUSY;
+		} else
+			rc = -ENOSPC;
 		goto conn_failed;
 	}
 
@@ -1815,7 +1824,8 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 			     iscsi_cid, &bnx2i_ep->cm_sk, bnx2i_ep);
 	if (rc) {
 		rc = -EINVAL;
-		goto conn_failed;
+		/* Need to terminate and cleanup the connection */
+		goto release_ep;
 	}
 
 	bnx2i_ep->cm_sk->rcv_buf = 256 * 1024;
@@ -1859,8 +1869,6 @@ release_ep:
 		return ERR_PTR(rc);
 	}
 conn_failed:
-net_if_down:
-iscsi_cid_err:
 	bnx2i_free_qp_resc(hba, bnx2i_ep);
 qp_resc_err:
 	bnx2i_free_ep(ep);
@@ -1979,7 +1987,8 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 	if (!cnic)
 		return 0;
 
-	if (bnx2i_ep->state == EP_STATE_IDLE)
+	if (bnx2i_ep->state == EP_STATE_IDLE ||
+	    bnx2i_ep->state == EP_STATE_DISCONN_TIMEDOUT)
 		return 0;
 
 	if (!bnx2i_ep_tcp_conn_active(bnx2i_ep))
@@ -2005,9 +2014,10 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 			if (session->state == ISCSI_STATE_LOGGING_OUT) {
 				if (bnx2i_ep->state == EP_STATE_LOGOUT_SENT) {
 					/* Logout sent, but no resp */
-					printk(KERN_ALERT "bnx2i - WARNING "
-						"logout response was not "
-						"received!\n");
+					printk(KERN_ALERT "bnx2i (%s): WARNING"
+						" logout response was not "
+						"received!\n",
+						bnx2i_ep->hba->netdev->name);
 				} else if (bnx2i_ep->state ==
 					   EP_STATE_LOGOUT_RESP_RCVD)
 					close = 1;
@@ -2025,9 +2035,8 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 	else
 		close_ret = cnic->cm_abort(bnx2i_ep->cm_sk);
 
-	/* No longer allow CFC delete if cm_close/abort fails the request */
 	if (close_ret)
-		printk(KERN_ALERT "bnx2i: %s close/abort(%d) returned %d\n",
+		printk(KERN_ALERT "bnx2i (%s): close/abort(%d) returned %d\n",
 			bnx2i_ep->hba->netdev->name, close, close_ret);
 	else
 		/* wait for option-2 conn teardown */
@@ -2041,7 +2050,7 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
 destroy_conn:
 	bnx2i_ep_active_list_del(hba, bnx2i_ep);
 	if (bnx2i_tear_down_conn(hba, bnx2i_ep))
-		ret = -EINVAL;
+		return -EINVAL;
 out:
 	bnx2i_ep->state = EP_STATE_IDLE;
 	return ret;
@@ -2080,14 +2089,17 @@ static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
 
 	mutex_lock(&hba->net_dev_lock);
 
-	if (bnx2i_ep->state == EP_STATE_IDLE)
-		goto return_bnx2i_ep;
+	if (bnx2i_ep->state == EP_STATE_DISCONN_TIMEDOUT)
+		goto out;
 
-	if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state))
+	if (bnx2i_ep->state == EP_STATE_IDLE)
 		goto free_resc;
 
-	if (bnx2i_ep->hba_age != hba->age)
+	if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state) ||
+	    (bnx2i_ep->hba_age != hba->age)) {
+		bnx2i_ep_active_list_del(hba, bnx2i_ep);
 		goto free_resc;
+	}
 
 	/* Do all chip cleanup here */
 	if (bnx2i_hw_ep_disconnect(bnx2i_ep)) {
@@ -2096,11 +2108,12 @@ static void bnx2i_ep_disconnect(struct iscsi_endpoint *ep)
 	}
 free_resc:
 	bnx2i_free_qp_resc(hba, bnx2i_ep);
-return_bnx2i_ep:
+
 	if (bnx2i_conn)
 		bnx2i_conn->ep = NULL;
 
 	bnx2i_free_ep(ep);
+out:
 	mutex_unlock(&hba->net_dev_lock);
 
 	wake_up_interruptible(&hba->eh_wait);
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v3 12/13] BNX2I: Updated copyright and maintainer info
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (68 preceding siblings ...)
  2010-11-23 23:29 ` [PATCH v3 11/13] BNX2I: Cleaned up various error conditions in ep_connect/disconnect Eddie Wai
@ 2010-11-23 23:29 ` Eddie Wai
  2010-11-23 23:29 ` [PATCH v3 13/13] BNX2I: Updated version to 2.6.2.2 Eddie Wai
                   ` (39 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-23 23:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/57xx_iscsi_constants.h |    3 ++-
 drivers/scsi/bnx2i/57xx_iscsi_hsi.h       |    3 ++-
 drivers/scsi/bnx2i/bnx2i.h                |    3 ++-
 drivers/scsi/bnx2i/bnx2i_hwi.c            |    3 ++-
 drivers/scsi/bnx2i/bnx2i_init.c           |    3 ++-
 drivers/scsi/bnx2i/bnx2i_iscsi.c          |    3 ++-
 drivers/scsi/bnx2i/bnx2i_sysfs.c          |    3 ++-
 7 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/bnx2i/57xx_iscsi_constants.h b/drivers/scsi/bnx2i/57xx_iscsi_constants.h
index 1b6f86b..30e6bdb 100644
--- a/drivers/scsi/bnx2i/57xx_iscsi_constants.h
+++ b/drivers/scsi/bnx2i/57xx_iscsi_constants.h
@@ -1,12 +1,13 @@
 /* 57xx_iscsi_constants.h: Broadcom NetXtreme II iSCSI HSI
  *
- * Copyright (c) 2006 - 2009 Broadcom Corporation
+ * Copyright (c) 2006 - 2010 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 #ifndef __57XX_ISCSI_CONSTANTS_H_
 #define __57XX_ISCSI_CONSTANTS_H_
diff --git a/drivers/scsi/bnx2i/57xx_iscsi_hsi.h b/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
index 36af1af..dad6c8a 100644
--- a/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
+++ b/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
@@ -1,12 +1,13 @@
 /* 57xx_iscsi_hsi.h: Broadcom NetXtreme II iSCSI HSI.
  *
- * Copyright (c) 2006 - 2009 Broadcom Corporation
+ * Copyright (c) 2006 - 2010 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 #ifndef __57XX_ISCSI_HSI_LINUX_LE__
 #define __57XX_ISCSI_HSI_LINUX_LE__
diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 866a22c..e1ca5fe 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -1,6 +1,6 @@
 /* bnx2i.h: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2009 Broadcom Corporation
+ * Copyright (c) 2006 - 2010 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
@@ -9,6 +9,7 @@
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 
 #ifndef _BNX2I_H_
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 6d99040..9375369 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1,6 +1,6 @@
 /* bnx2i_hwi.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2009 Broadcom Corporation
+ * Copyright (c) 2006 - 2010 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
@@ -9,6 +9,7 @@
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 
 #include <linux/gfp.h>
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 338caac..131ef80 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -1,6 +1,6 @@
 /* bnx2i.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2009 Broadcom Corporation
+ * Copyright (c) 2006 - 2010 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
@@ -9,6 +9,7 @@
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 
 #include "bnx2i.h"
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 24997c6..f0dce26 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1,7 +1,7 @@
 /*
  * bnx2i_iscsi.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2009 Broadcom Corporation
+ * Copyright (c) 2006 - 2010 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
@@ -10,6 +10,7 @@
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 
 #include <linux/slab.h>
diff --git a/drivers/scsi/bnx2i/bnx2i_sysfs.c b/drivers/scsi/bnx2i/bnx2i_sysfs.c
index 96426b7..9174196 100644
--- a/drivers/scsi/bnx2i/bnx2i_sysfs.c
+++ b/drivers/scsi/bnx2i/bnx2i_sysfs.c
@@ -1,12 +1,13 @@
 /* bnx2i_sysfs.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2004 - 2009 Broadcom Corporation
+ * Copyright (c) 2004 - 2010 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation.
  *
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
+ * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
  */
 
 #include "bnx2i.h"
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v3 13/13] BNX2I: Updated version to 2.6.2.2
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (69 preceding siblings ...)
  2010-11-23 23:29 ` [PATCH v3 12/13] BNX2I: Updated copyright and maintainer info Eddie Wai
@ 2010-11-23 23:29 ` Eddie Wai
  2011-01-05 20:44 ` [PATCH 0/8] Added bug fixes and several features for BNX2I Eddie Wai
                   ` (38 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2010-11-23 23:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_init.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 131ef80..72a7b2d 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -18,8 +18,8 @@ static struct list_head adapter_list = LIST_HEAD_INIT(adapter_list);
 static u32 adapter_count;
 
 #define DRV_MODULE_NAME		"bnx2i"
-#define DRV_MODULE_VERSION	"2.1.3"
-#define DRV_MODULE_RELDATE	"Aug 10, 2010"
+#define DRV_MODULE_VERSION	"2.6.2.2"
+#define DRV_MODULE_RELDATE	"Nov 23, 2010"
 
 static char version[] __devinitdata =
 		"Broadcom NetXtreme II iSCSI Driver " DRV_MODULE_NAME \
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: PATCH 00/13] BNX2I: Patch set to fix various bug fixes
  2010-11-23 23:29 ` PATCH 00/13] BNX2I: Patch set to fix various bug fixes Eddie Wai
@ 2010-11-24  0:16   ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2010-11-24  0:16 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 11/23/2010 05:29 PM, Eddie Wai wrote:
> Hello,
>
> This patch set contains various bug fixes as categorized in the following:
> - scsi command handling (nop-ins, tmfs)
> - various connection clean up bug fixes
> In v3, the following patches are updated:
>    BNX2I: Fixed the remote TCP RST handling for the 570X (1g)
>
>> In v2, the following patches are modified based on Mike Christie's comments:
>>   BNX2I: Added mutex lock protection to conn_get_param (rm ret 0)
>>   BNX2I: Removed the dynamic registration of CNIC (trailing space)
>>
>
> In v3, these patches were removed pending better resolution:
>    BNX2I: Added feature to silently drop NOPOUT request
>>   BNX2I: Updated the handling of NETEVENTs to alleviate recovery
>>   BNX2I: Added code to handle the binding of an existing connection
>
> Your comments are grealy appreciated.  Please review, thanks.
>

Looks ok. Thanks

Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 06/16] BNX2I: Added code to handle the binding of an existing connection
  2010-11-18  3:24   ` Mike Christie
@ 2011-01-02  4:11     ` Mike Christie
  2011-01-06  6:54       ` Or Gerlitz
  0 siblings, 1 reply; 189+ messages in thread
From: Mike Christie @ 2011-01-02  4:11 UTC (permalink / raw)
  To: open-iscsi
  Cc: Eddie Wai, James Bottomley, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

[-- Attachment #1: Type: text/plain, Size: 1734 bytes --]

On 11/17/2010 09:24 PM, Mike Christie wrote:
> On 11/10/2010 05:04 PM, Eddie Wai wrote:
>> This is the case when iscsid gets re-launched due to features like
>> iSCSI boot which requires the daemon to re-launch due to
>> pivot root. If the code detected the connection had an existing
>> endpoint, the old endpoint must get cleaned up.
>>
>> Signed-off-by: Eddie Wai<eddie.wai@broadcom.com>
>> Acked-by: Anil Veerabhadrappa<anilgv@broadcom.com>
>> ---
>> drivers/scsi/bnx2i/bnx2i_iscsi.c | 7 +++++++
>> 1 files changed, 7 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c
>> b/drivers/scsi/bnx2i/bnx2i_iscsi.c
>> index 823e4fa..3b65c64 100644
>> --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
>> +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
>> @@ -1410,6 +1410,13 @@ static int bnx2i_conn_bind(struct
>> iscsi_cls_session *cls_session,
>> hba->netdev->name);
>> return -EEXIST;
>> }
>> + if (bnx2i_conn->ep) {
>> + printk(KERN_ALERT "bnx2i: Binding to an existing endpoint "
>> + "detected. Disconnecting the old...\n");
>> + mutex_lock(&hba->net_dev_lock);
>> + bnx2i_hw_ep_disconnect(bnx2i_conn->ep);
>> + mutex_unlock(&hba->net_dev_lock);
>> + }
>> bnx2i_ep->conn = bnx2i_conn;
>> bnx2i_conn->ep = bnx2i_ep;
>> bnx2i_conn->iscsi_conn_cid = bnx2i_ep->ep_iscsi_cid;
>
> Don't you still leak what bnx2i_free_ep frees?
>
> In userspace you should have iscsid/iscsi_sync_session match the iscsi
> endpoint with the iscsi conn and set transport_ep_handle. ep_disconnect
> will then get called like normal to clean up the old connection.
>

I went a different way. In the attached patch we detect the problem when 
binding and will force a disconnect of the old ep before binding a new one.

Try it out and let me know.

[-- Attachment #2: iscsi-fix-ep-boot-leak.patch --]
[-- Type: text/plain, Size: 10619 bytes --]

diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index 7b2fc98..921c2cb 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -331,8 +331,7 @@ iscsi_iser_conn_destroy(struct iscsi_cls_conn *cls_conn)
 
 static int
 iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session,
-		     struct iscsi_cls_conn *cls_conn, uint64_t transport_eph,
-		     int is_leading)
+		     struct iscsi_cls_conn *cls_conn, uint64_t transport_eph)
 {
 	struct iscsi_conn *conn = cls_conn->dd_data;
 	struct iscsi_iser_conn *iser_conn;
@@ -340,10 +339,6 @@ iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session,
 	struct iscsi_endpoint *ep;
 	int error;
 
-	error = iscsi_conn_bind(cls_session, cls_conn, is_leading);
-	if (error)
-		return error;
-
 	/* the transport ep handle comes from user space so it must be
 	 * verified against the global ib connections list */
 	ep = iscsi_lookup_endpoint(transport_eph);
@@ -352,6 +347,11 @@ iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session,
 			 (unsigned long long)transport_eph);
 		return -EINVAL;
 	}
+
+	error = iscsi_conn_bind(cls_session, cls_conn, ep);
+	if (error)
+		return error;
+
 	ib_conn = ep->dd_data;
 
 	/* binds the iSER connection retrieved from the previously
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index eaaa881..97533e7 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -174,7 +174,7 @@ static int beiscsi_bindconn_cid(struct beiscsi_hba *phba,
  */
 int beiscsi_conn_bind(struct iscsi_cls_session *cls_session,
 		      struct iscsi_cls_conn *cls_conn,
-		      u64 transport_fd, int is_leading)
+		      u64 transport_fd)
 {
 	struct iscsi_conn *conn = cls_conn->dd_data;
 	struct beiscsi_conn *beiscsi_conn = conn->dd_data;
@@ -191,7 +191,7 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session,
 
 	beiscsi_ep = ep->dd_data;
 
-	if (iscsi_conn_bind(cls_session, cls_conn, is_leading))
+	if (iscsi_conn_bind(cls_session, cls_conn, ep))
 		return -EINVAL;
 
 	if (beiscsi_ep->phba != phba) {
diff --git a/drivers/scsi/be2iscsi/be_iscsi.h b/drivers/scsi/be2iscsi/be_iscsi.h
index 8950a70..4047ec1 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.h
+++ b/drivers/scsi/be2iscsi/be_iscsi.h
@@ -46,7 +46,7 @@ struct iscsi_cls_conn *beiscsi_conn_create(struct iscsi_cls_session
 
 int beiscsi_conn_bind(struct iscsi_cls_session *cls_session,
 		      struct iscsi_cls_conn *cls_conn,
-		      uint64_t transport_fd, int is_leading);
+		      uint64_t transport_fd);
 
 int beiscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
 			   enum iscsi_param param, char *buf);
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index f0dce26..7c5c1d9 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1373,7 +1373,7 @@ free_conn:
  */
 static int bnx2i_conn_bind(struct iscsi_cls_session *cls_session,
 			   struct iscsi_cls_conn *cls_conn,
-			   uint64_t transport_fd, int is_leading)
+			   uint64_t transport_fd)
 {
 	struct iscsi_conn *conn = cls_conn->dd_data;
 	struct bnx2i_conn *bnx2i_conn = conn->dd_data;
@@ -1399,7 +1399,7 @@ static int bnx2i_conn_bind(struct iscsi_cls_session *cls_session,
 		/* Peer disconnect via' FIN or RST */
 		return -EINVAL;
 
-	if (iscsi_conn_bind(cls_session, cls_conn, is_leading))
+	if (iscsi_conn_bind(cls_session, cls_conn, ep))
 		return -EINVAL;
 
 	if (bnx2i_ep->hba != hba) {
diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index be56617..84125e9 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -2264,7 +2264,7 @@ EXPORT_SYMBOL_GPL(cxgbi_create_conn);
 
 int cxgbi_bind_conn(struct iscsi_cls_session *cls_session,
 				struct iscsi_cls_conn *cls_conn,
-				u64 transport_eph, int is_leading)
+				u64 transport_eph)
 {
 	struct iscsi_conn *conn = cls_conn->dd_data;
 	struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
@@ -2285,7 +2285,7 @@ int cxgbi_bind_conn(struct iscsi_cls_session *cls_session,
 	if (err < 0)
 		return err;
 
-	err = iscsi_conn_bind(cls_session, cls_conn, is_leading);
+	err = iscsi_conn_bind(cls_session, cls_conn, ep);
 	if (err)
 		return -EINVAL;
 
diff --git a/drivers/scsi/cxgbi/libcxgbi.h b/drivers/scsi/cxgbi/libcxgbi.h
index c57d59d..1bd50e3 100644
--- a/drivers/scsi/cxgbi/libcxgbi.h
+++ b/drivers/scsi/cxgbi/libcxgbi.h
@@ -718,7 +718,7 @@ int cxgbi_set_conn_param(struct iscsi_cls_conn *,
 int cxgbi_get_conn_param(struct iscsi_cls_conn *, enum iscsi_param, char *);
 struct iscsi_cls_conn *cxgbi_create_conn(struct iscsi_cls_session *, u32);
 int cxgbi_bind_conn(struct iscsi_cls_session *,
-			struct iscsi_cls_conn *, u64, int);
+			struct iscsi_cls_conn *, u64);
 void cxgbi_destroy_session(struct iscsi_cls_session *);
 struct iscsi_cls_session *cxgbi_create_session(struct iscsi_endpoint *,
 			u16, u16, u32);
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index fec47de..9961c22 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -651,8 +651,7 @@ free_addr:
 
 static int
 iscsi_sw_tcp_conn_bind(struct iscsi_cls_session *cls_session,
-		       struct iscsi_cls_conn *cls_conn, uint64_t transport_eph,
-		       int is_leading)
+		       struct iscsi_cls_conn *cls_conn, uint64_t transport_eph)
 {
 	struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
 	struct iscsi_host *ihost = shost_priv(shost);
@@ -685,7 +684,7 @@ iscsi_sw_tcp_conn_bind(struct iscsi_cls_session *cls_session,
 	if (err)
 		goto free_socket;
 
-	err = iscsi_conn_bind(cls_session, cls_conn, is_leading);
+	err = iscsi_conn_bind(cls_session, cls_conn, NULL);
 	if (err)
 		goto free_socket;
 
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index da8b615..76960fb 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -3137,16 +3137,18 @@ void iscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
 EXPORT_SYMBOL_GPL(iscsi_conn_stop);
 
 int iscsi_conn_bind(struct iscsi_cls_session *cls_session,
-		    struct iscsi_cls_conn *cls_conn, int is_leading)
+		    struct iscsi_cls_conn *cls_conn,
+		    struct iscsi_endpoint *ep)
 {
 	struct iscsi_session *session = cls_session->dd_data;
 	struct iscsi_conn *conn = cls_conn->dd_data;
 
 	spin_lock_bh(&session->lock);
-	if (is_leading)
-		session->leadconn = conn;
+	session->leadconn = conn;
 	spin_unlock_bh(&session->lock);
 
+	ep->conn = cls_conn;
+	cls_conn->ep = ep;
 	/*
 	 * Unblock xmitworker(), Login Phase will pass through.
 	 */
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index f905ecb..035c8bd 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -975,7 +975,6 @@ iscsi_create_conn(struct iscsi_cls_session *session, int dd_size, uint32_t cid)
 
 	spin_lock_irqsave(&connlock, flags);
 	list_add(&conn->conn_list, &connlist);
-	conn->active = 1;
 	spin_unlock_irqrestore(&connlock, flags);
 
 	ISCSI_DBG_TRANS_CONN(conn, "Completed conn creation\n");
@@ -1001,7 +1000,6 @@ int iscsi_destroy_conn(struct iscsi_cls_conn *conn)
 	unsigned long flags;
 
 	spin_lock_irqsave(&connlock, flags);
-	conn->active = 0;
 	list_del(&conn->conn_list);
 	spin_unlock_irqrestore(&connlock, flags);
 
@@ -1430,6 +1428,26 @@ release_host:
 	return err;
 }
 
+static int iscsi_if_ep_disconnect(struct iscsi_transport *transport,
+				  u64 ep_handle)
+{
+	struct iscsi_cls_conn *conn;
+	struct iscsi_endpoint *ep;
+
+	if (!transport->ep_disconnect)
+		return -EINVAL;
+
+	ep = iscsi_lookup_endpoint(ep_handle);
+	if (!ep)
+		return -EINVAL;
+	conn = ep->conn;
+
+	transport->ep_disconnect(ep);
+	if (conn)
+		conn->ep = NULL;
+	return 0;
+}
+
 static int
 iscsi_if_transport_ep(struct iscsi_transport *transport,
 		      struct iscsi_uevent *ev, int msg_type)
@@ -1454,14 +1472,8 @@ iscsi_if_transport_ep(struct iscsi_transport *transport,
 						   ev->u.ep_poll.timeout_ms);
 		break;
 	case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT:
-		if (!transport->ep_disconnect)
-			return -EINVAL;
-
-		ep = iscsi_lookup_endpoint(ev->u.ep_disconnect.ep_handle);
-		if (!ep)
-			return -EINVAL;
-
-		transport->ep_disconnect(ep);
+		rc = iscsi_if_ep_disconnect(transport,
+					    ev->u.ep_disconnect.ep_handle);
 		break;
 	}
 	return rc;
@@ -1609,10 +1621,12 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
 		session = iscsi_session_lookup(ev->u.b_conn.sid);
 		conn = iscsi_conn_lookup(ev->u.b_conn.sid, ev->u.b_conn.cid);
 
+		if (conn && conn->ep)
+			iscsi_if_ep_disconnect(transport, conn->ep->id);
+
 		if (session && conn)
 			ev->r.retcode =	transport->bind_conn(session, conn,
-					ev->u.b_conn.transport_eph,
-					ev->u.b_conn.is_leading);
+					ev->u.b_conn.transport_eph);
 		else
 			err = -EINVAL;
 		break;
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 748382b..006148e 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -388,7 +388,7 @@ extern void iscsi_conn_teardown(struct iscsi_cls_conn *);
 extern int iscsi_conn_start(struct iscsi_cls_conn *);
 extern void iscsi_conn_stop(struct iscsi_cls_conn *, int);
 extern int iscsi_conn_bind(struct iscsi_cls_session *, struct iscsi_cls_conn *,
-			   int);
+			   struct iscsi_endpoint *);
 extern void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err);
 extern void iscsi_session_failure(struct iscsi_session *session,
 				  enum iscsi_err err);
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 7fff94b..225fe57 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -95,7 +95,7 @@ struct iscsi_transport {
 				uint32_t cid);
 	int (*bind_conn) (struct iscsi_cls_session *session,
 			  struct iscsi_cls_conn *cls_conn,
-			  uint64_t transport_eph, int is_leading);
+			  uint64_t transport_eph);
 	int (*start_conn) (struct iscsi_cls_conn *conn);
 	void (*stop_conn) (struct iscsi_cls_conn *conn, int flag);
 	void (*destroy_conn) (struct iscsi_cls_conn *conn);
@@ -160,8 +160,8 @@ struct iscsi_cls_conn {
 	void *dd_data;			/* LLD private data */
 	struct iscsi_transport *transport;
 	uint32_t cid;			/* connection id */
+	struct iscsi_endpoint *ep;
 
-	int active;			/* must be accessed with the connlock */
 	struct device dev;		/* sysfs transport/container device */
 };
 
@@ -222,6 +222,7 @@ struct iscsi_endpoint {
 	void *dd_data;			/* LLD private data */
 	struct device dev;
 	uint64_t id;
+	struct iscsi_cls_conn *conn;
 };
 
 /*

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 0/8] Added bug fixes and several features for BNX2I
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (70 preceding siblings ...)
  2010-11-23 23:29 ` [PATCH v3 13/13] BNX2I: Updated version to 2.6.2.2 Eddie Wai
@ 2011-01-05 20:44 ` Eddie Wai
  2011-01-05 20:52   ` James Bottomley
  2011-01-06 20:43   ` Mike Christie
  2011-01-05 20:44 ` [PATCH 1/8] BNX2I: Allow ep CONNECT_FAILED condition to go through proper cleanup Eddie Wai
                   ` (37 subsequent siblings)
  109 siblings, 2 replies; 189+ messages in thread
From: Eddie Wai @ 2011-01-05 20:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Hello,
    
This patch set contains two fixes and added various features as titled.
The two fixes are:
1 - connection cleanup fix which fixes a chip panic issue
2 - nopout LUN field fix which fixes nopout timeouts

The features added includes TCP timestamp, jumbo MTU, text pdu support
for discovery offload, and 57712(E) support.

Please review.  Thanks.
Eddie

Eddie Wai (8):
  BNX2I: Allow ep CONNECT_FAILED condition to go through proper cleanup
  BNX2I: Fixed the 32-bit swapping of the LUN field for nopouts for
    5771X
  BNX2I: Added handling for unsupported iSCSI offload hba
  BNX2I: Added support for the 57712(E) devices
  BNX2I: Added TCP timestamps option support
  BNX2I: Added jumbo MTU support for the no shost case
  BNX2I: Added iSCSI text pdu support for iSCSI offload
  BNX2I: Updated to version 2.6.2.3

 drivers/net/bnx2x/bnx2x_main.c   |    7 --
 drivers/scsi/bnx2i/bnx2i.h       |    5 +-
 drivers/scsi/bnx2i/bnx2i_hwi.c   |  122 +++++++++++++++++++++++++++++++++++++-
 drivers/scsi/bnx2i/bnx2i_init.c  |   33 ++++++++--
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   10 +++-
 include/linux/pci_ids.h          |    2 +
 6 files changed, 160 insertions(+), 19 deletions(-)



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 1/8] BNX2I: Allow ep CONNECT_FAILED condition to go through proper cleanup
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (71 preceding siblings ...)
  2011-01-05 20:44 ` [PATCH 0/8] Added bug fixes and several features for BNX2I Eddie Wai
@ 2011-01-05 20:44 ` Eddie Wai
  2011-01-05 20:44 ` [PATCH 2/8] BNX2I: Fixed the 32-bit swapping of the LUN field for nopouts for 5771X Eddie Wai
                   ` (36 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-01-05 20:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Allow CNIC to go through the proper cleanup procedure for an endpoint
which failed to connect.  Proper cleanup is necessary for the chip
to reset back to the initial state for the offloaded endpoint.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index f0dce26..f9415aa 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1935,13 +1935,13 @@ static int bnx2i_ep_tcp_conn_active(struct bnx2i_endpoint *bnx2i_ep)
 		cnic_dev_10g = 1;
 
 	switch (bnx2i_ep->state) {
-	case EP_STATE_CONNECT_FAILED:
 	case EP_STATE_CLEANUP_FAILED:
 	case EP_STATE_OFLD_FAILED:
 	case EP_STATE_DISCONN_TIMEDOUT:
 		ret = 0;
 		break;
 	case EP_STATE_CONNECT_START:
+	case EP_STATE_CONNECT_FAILED:
 	case EP_STATE_CONNECT_COMPL:
 	case EP_STATE_ULP_UPDATE_START:
 	case EP_STATE_ULP_UPDATE_COMPL:
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 2/8] BNX2I: Fixed the 32-bit swapping of the LUN field for nopouts for 5771X
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (72 preceding siblings ...)
  2011-01-05 20:44 ` [PATCH 1/8] BNX2I: Allow ep CONNECT_FAILED condition to go through proper cleanup Eddie Wai
@ 2011-01-05 20:44 ` Eddie Wai
  2011-01-05 20:44 ` [PATCH 3/8] BNX2I: Added handling for unsupported iSCSI offload hba Eddie Wai
                   ` (35 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-01-05 20:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Fixed a bug where the 64-bit LUN field for nopouts were 32-bit swapped.
This only pertains to 5771X devices.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 5442f1a..f2200f5 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -498,10 +498,10 @@ int bnx2i_send_iscsi_nopout(struct bnx2i_conn *bnx2i_conn,
 	memcpy(nopout_wqe->lun, nopout_hdr->lun, 8);
 
 	if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) {
-		u32 tmp = nopout_hdr->lun[0];
+		u32 tmp = nopout_wqe->lun[0];
 		/* 57710 requires LUN field to be swapped */
-		nopout_hdr->lun[0] = nopout_hdr->lun[1];
-		nopout_hdr->lun[1] = tmp;
+		nopout_wqe->lun[0] = nopout_wqe->lun[1];
+		nopout_wqe->lun[1] = tmp;
 	}
 
 	nopout_wqe->itt = ((u16)task->itt |
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 3/8] BNX2I: Added handling for unsupported iSCSI offload hba
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (73 preceding siblings ...)
  2011-01-05 20:44 ` [PATCH 2/8] BNX2I: Fixed the 32-bit swapping of the LUN field for nopouts for 5771X Eddie Wai
@ 2011-01-05 20:44 ` Eddie Wai
  2011-01-05 20:44 ` [PATCH 4/8] BNX2I: Added support for the 57712(E) devices Eddie Wai
                   ` (34 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-01-05 20:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The hba will now be unregistered and freed when iSCSI offload
is not supported by the NIC.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_init.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 72a7b2d..6afaa34 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -161,6 +161,21 @@ void bnx2i_start(void *handle)
 	struct bnx2i_hba *hba = handle;
 	int i = HZ;
 
+	if (!hba->cnic->max_iscsi_conn) {
+		printk(KERN_ALERT "bnx2i: dev %s does not support "
+			"iSCSI\n", hba->netdev->name);
+
+		if (test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic)) {
+			mutex_lock(&bnx2i_dev_lock);
+			list_del_init(&hba->link);
+			adapter_count--;
+			hba->cnic->unregister_device(hba->cnic, CNIC_ULP_ISCSI);
+			clear_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic);
+			mutex_unlock(&bnx2i_dev_lock);
+			bnx2i_free_hba(hba);
+		}
+		return;
+	}
 	bnx2i_send_fw_iscsi_init_msg(hba);
 	while (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state) && i--)
 		msleep(BNX2I_INIT_POLL_TIME);
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 4/8] BNX2I: Added support for the 57712(E) devices
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (74 preceding siblings ...)
  2011-01-05 20:44 ` [PATCH 3/8] BNX2I: Added handling for unsupported iSCSI offload hba Eddie Wai
@ 2011-01-05 20:44 ` Eddie Wai
  2011-01-05 20:44 ` [PATCH 5/8] BNX2I: Added TCP timestamps option support Eddie Wai
                   ` (33 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-01-05 20:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Moved all PCI_DEVICE_ID_NX2_57712(E) definitions to pci_ids.h

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Michael Chan <mchan@broadcom.com>
Acked-by: Eilon Greenstein <eilong@broadcom.com>
---
 drivers/net/bnx2x/bnx2x_main.c  |    7 -------
 drivers/scsi/bnx2i/bnx2i_init.c |   10 ++++++----
 include/linux/pci_ids.h         |    2 ++
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c
index ff99a2f..3efacfa 100644
--- a/drivers/net/bnx2x/bnx2x_main.c
+++ b/drivers/net/bnx2x/bnx2x_main.c
@@ -140,13 +140,6 @@ static struct {
 	{ "Broadcom NetXtreme II BCM57712E XGb" }
 };
 
-#ifndef PCI_DEVICE_ID_NX2_57712
-#define PCI_DEVICE_ID_NX2_57712		0x1662
-#endif
-#ifndef PCI_DEVICE_ID_NX2_57712E
-#define PCI_DEVICE_ID_NX2_57712E	0x1663
-#endif
-
 static DEFINE_PCI_DEVICE_TABLE(bnx2x_pci_tbl) = {
 	{ PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57710), BCM57710 },
 	{ PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57711), BCM57711 },
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 6afaa34..5ef01c9 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -29,7 +29,7 @@ static char version[] __devinitdata =
 MODULE_AUTHOR("Anil Veerabhadrappa <anilgv@broadcom.com> and "
 	      "Eddie Wai <eddie.wai@broadcom.com>");
 
-MODULE_DESCRIPTION("Broadcom NetXtreme II BCM5706/5708/5709/57710/57711"
+MODULE_DESCRIPTION("Broadcom NetXtreme II BCM5706/5708/5709/57710/57711/57712"
 		   " iSCSI Driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_MODULE_VERSION);
@@ -88,9 +88,11 @@ void bnx2i_identify_device(struct bnx2i_hba *hba)
 	    (hba->pci_did == PCI_DEVICE_ID_NX2_5709S)) {
 		set_bit(BNX2I_NX2_DEV_5709, &hba->cnic_dev_type);
 		hba->mail_queue_access = BNX2I_MQ_BIN_MODE;
-	} else if (hba->pci_did == PCI_DEVICE_ID_NX2_57710 ||
-		   hba->pci_did == PCI_DEVICE_ID_NX2_57711 ||
-		   hba->pci_did == PCI_DEVICE_ID_NX2_57711E)
+	} else if (hba->pci_did == PCI_DEVICE_ID_NX2_57710  ||
+		   hba->pci_did == PCI_DEVICE_ID_NX2_57711  ||
+		   hba->pci_did == PCI_DEVICE_ID_NX2_57711E ||
+		   hba->pci_did == PCI_DEVICE_ID_NX2_57712  ||
+		   hba->pci_did == PCI_DEVICE_ID_NX2_57712E)
 		set_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type);
 	else
 		printk(KERN_ALERT "bnx2i: unknown device, 0x%x\n",
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index d278dd9..6487382 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2067,6 +2067,8 @@
 #define PCI_DEVICE_ID_TIGON3_5723	0x165b
 #define PCI_DEVICE_ID_TIGON3_5705M	0x165d
 #define PCI_DEVICE_ID_TIGON3_5705M_2	0x165e
+#define PCI_DEVICE_ID_NX2_57712		0x1662
+#define PCI_DEVICE_ID_NX2_57712E	0x1663
 #define PCI_DEVICE_ID_TIGON3_5714	0x1668
 #define PCI_DEVICE_ID_TIGON3_5714S	0x1669
 #define PCI_DEVICE_ID_TIGON3_5780	0x166a
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 5/8] BNX2I: Added TCP timestamps option support
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (75 preceding siblings ...)
  2011-01-05 20:44 ` [PATCH 4/8] BNX2I: Added support for the 57712(E) devices Eddie Wai
@ 2011-01-05 20:44 ` Eddie Wai
  2011-01-05 20:52   ` Mike Christie
  2011-01-05 20:44 ` [PATCH 6/8] BNX2I: Added jumbo MTU support for the no shost case Eddie Wai
                   ` (32 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2011-01-05 20:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

This TCP timestamps option is a module wise feature which can be
enabled via the module param (time_stamps).  Once enabled, the TCP
connection will advertise timestamps as an option to get negotiated.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Benjamin Li <benli@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |    1 +
 drivers/scsi/bnx2i/bnx2i_init.c  |    4 ++++
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    2 ++
 3 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index e1ca5fe..cc7ebc1 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -701,6 +701,7 @@ struct bnx2i_endpoint {
 extern unsigned int error_mask1, error_mask2;
 extern u64 iscsi_error_mask;
 extern unsigned int en_tcp_dack;
+extern unsigned int time_stamps;
 extern unsigned int event_coal_div;
 extern unsigned int event_coal_min;
 
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 5ef01c9..c053764 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -48,6 +48,10 @@ unsigned int en_tcp_dack = 1;
 module_param(en_tcp_dack, int, 0664);
 MODULE_PARM_DESC(en_tcp_dack, "Enable TCP Delayed ACK");
 
+unsigned int time_stamps = 0x00;
+module_param(time_stamps, int, 0664);
+MODULE_PARM_DESC(time_stamps, "Enable TCP TimeStamps [1 = Enable]");
+
 unsigned int error_mask1 = 0x00;
 module_param(error_mask1, int, 0664);
 MODULE_PARM_DESC(error_mask1, "Config FW iSCSI Error Mask #1");
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index f9415aa..86ddc08 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1832,6 +1832,8 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	bnx2i_ep->cm_sk->rcv_buf = 256 * 1024;
 	bnx2i_ep->cm_sk->snd_buf = 256 * 1024;
 	clear_bit(SK_TCP_TIMESTAMP, &bnx2i_ep->cm_sk->tcp_flags);
+	if (time_stamps)
+		set_bit(SK_TCP_TIMESTAMP, &bnx2i_ep->cm_sk->tcp_flags);
 
 	memset(&saddr, 0, sizeof(saddr));
 	if (dst_addr->sa_family == AF_INET) {
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 6/8] BNX2I: Added jumbo MTU support for the no shost case
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (76 preceding siblings ...)
  2011-01-05 20:44 ` [PATCH 5/8] BNX2I: Added TCP timestamps option support Eddie Wai
@ 2011-01-05 20:44 ` Eddie Wai
  2011-01-05 20:50   ` Mike Christie
  2011-01-05 20:44 ` [PATCH 7/8] BNX2I: Added iSCSI text pdu support for iSCSI offload Eddie Wai
                   ` (31 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2011-01-05 20:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

For scenarios where the shost is not being passed to bnx2i for the
iSCSI offload connection request, the code would consult the routing
table to select the CNIC device.
This code path will erroneously error out if the corresponding L2
interface's MTU has been setup to > 1500.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index cc7ebc1..bd64ba3 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -360,7 +360,7 @@ struct bnx2i_hba {
 		#define ADAPTER_STATE_LINK_DOWN		2
 		#define ADAPTER_STATE_INIT_FAILED	31
 	unsigned int mtu_supported;
-		#define BNX2I_MAX_MTU_SUPPORTED		1500
+		#define BNX2I_MAX_MTU_SUPPORTED		9000
 
 	struct Scsi_Host *shost;
 
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 7/8] BNX2I: Added iSCSI text pdu support for iSCSI offload
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (77 preceding siblings ...)
  2011-01-05 20:44 ` [PATCH 6/8] BNX2I: Added jumbo MTU support for the no shost case Eddie Wai
@ 2011-01-05 20:44 ` Eddie Wai
  2011-01-05 20:44 ` [PATCH 8/8] BNX2I: Updated to version 2.6.2.3 Eddie Wai
                   ` (30 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-01-05 20:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

This is part of an effort to support send target discovery via
the iSCSI offload path.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |    2 +
 drivers/scsi/bnx2i/bnx2i_hwi.c   |  116 ++++++++++++++++++++++++++++++++++++++
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    6 ++-
 3 files changed, 123 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index bd64ba3..268156e 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -752,6 +752,8 @@ extern int bnx2i_send_iscsi_login(struct bnx2i_conn *conn,
 				  struct iscsi_task *mtask);
 extern int bnx2i_send_iscsi_tmf(struct bnx2i_conn *conn,
 				  struct iscsi_task *mtask);
+extern int bnx2i_send_iscsi_text(struct bnx2i_conn *conn,
+				 struct iscsi_task *mtask);
 extern int bnx2i_send_iscsi_scsicmd(struct bnx2i_conn *conn,
 				    struct bnx2i_cmd *cmnd);
 extern int bnx2i_send_iscsi_nopout(struct bnx2i_conn *conn,
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index f2200f5..952de46 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -445,6 +445,56 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn,
 }
 
 /**
+ * bnx2i_send_iscsi_text - post iSCSI text WQE to hardware
+ * @conn:	iscsi connection
+ * @mtask:	driver command structure which is requesting
+ *		a WQE to sent to chip for further processing
+ *
+ * prepare and post an iSCSI Text request WQE to CNIC firmware
+ */
+int bnx2i_send_iscsi_text(struct bnx2i_conn *bnx2i_conn,
+			  struct iscsi_task *mtask)
+{
+	struct bnx2i_cmd *bnx2i_cmd;
+	struct bnx2i_text_request *text_wqe;
+	struct iscsi_text *text_hdr;
+	u32 dword;
+
+	bnx2i_cmd = (struct bnx2i_cmd *)mtask->dd_data;
+	text_hdr = (struct iscsi_text *)mtask->hdr;
+	text_wqe = (struct bnx2i_text_request *) bnx2i_conn->ep->qp.sq_prod_qe;
+
+	memset(text_wqe, 0, sizeof(struct bnx2i_text_request));
+
+	text_wqe->op_code = text_hdr->opcode;
+	text_wqe->op_attr = text_hdr->flags;
+	text_wqe->data_length = ntoh24(text_hdr->dlength);
+	text_wqe->itt = mtask->itt |
+		(ISCSI_TASK_TYPE_MPATH << ISCSI_TEXT_REQUEST_TYPE_SHIFT);
+	text_wqe->ttt = be32_to_cpu(text_hdr->ttt);
+
+	text_wqe->cmd_sn = be32_to_cpu(text_hdr->cmdsn);
+
+	text_wqe->resp_bd_list_addr_lo = (u32) bnx2i_conn->gen_pdu.resp_bd_dma;
+	text_wqe->resp_bd_list_addr_hi =
+			(u32) ((u64) bnx2i_conn->gen_pdu.resp_bd_dma >> 32);
+
+	dword = ((1 << ISCSI_TEXT_REQUEST_NUM_RESP_BDS_SHIFT) |
+		 (bnx2i_conn->gen_pdu.resp_buf_size <<
+		  ISCSI_TEXT_REQUEST_RESP_BUFFER_LENGTH_SHIFT));
+	text_wqe->resp_buffer = dword;
+	text_wqe->bd_list_addr_lo = (u32) bnx2i_conn->gen_pdu.req_bd_dma;
+	text_wqe->bd_list_addr_hi =
+			(u32) ((u64) bnx2i_conn->gen_pdu.req_bd_dma >> 32);
+	text_wqe->num_bds = 1;
+	text_wqe->cq_index = 0; /* CQ# used for completion, 5771x only */
+
+	bnx2i_ring_dbell_update_sq_params(bnx2i_conn, 1);
+	return 0;
+}
+
+
+/**
  * bnx2i_send_iscsi_scsicmd - post iSCSI scsicmd request WQE to hardware
  * @conn:	iscsi connection
  * @cmd:	driver command structure which is requesting
@@ -1428,6 +1478,68 @@ done:
 	return 0;
 }
 
+
+/**
+ * bnx2i_process_text_resp - this function handles iscsi text response
+ * @session:	iscsi session pointer
+ * @bnx2i_conn:	iscsi connection pointer
+ * @cqe:	pointer to newly DMA'ed CQE entry for processing
+ *
+ * process iSCSI Text Response CQE&  complete it to open-iscsi user daemon
+ */
+static int bnx2i_process_text_resp(struct iscsi_session *session,
+				   struct bnx2i_conn *bnx2i_conn,
+				   struct cqe *cqe)
+{
+	struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data;
+	struct iscsi_task *task;
+	struct bnx2i_text_response *text;
+	struct iscsi_text_rsp *resp_hdr;
+	int pld_len;
+	int pad_len;
+
+	text = (struct bnx2i_text_response *) cqe;
+	spin_lock(&session->lock);
+	task = iscsi_itt_to_task(conn, text->itt & ISCSI_LOGIN_RESPONSE_INDEX);
+	if (!task)
+		goto done;
+
+	resp_hdr = (struct iscsi_text_rsp *)&bnx2i_conn->gen_pdu.resp_hdr;
+	memset(resp_hdr, 0, sizeof(struct iscsi_hdr));
+	resp_hdr->opcode = text->op_code;
+	resp_hdr->flags = text->response_flags;
+	resp_hdr->hlength = 0;
+
+	hton24(resp_hdr->dlength, text->data_length);
+	resp_hdr->itt = task->hdr->itt;
+	resp_hdr->ttt = cpu_to_be32(text->ttt);
+	resp_hdr->statsn = task->hdr->exp_statsn;
+	resp_hdr->exp_cmdsn = cpu_to_be32(text->exp_cmd_sn);
+	resp_hdr->max_cmdsn = cpu_to_be32(text->max_cmd_sn);
+	pld_len = text->data_length;
+	bnx2i_conn->gen_pdu.resp_wr_ptr = bnx2i_conn->gen_pdu.resp_buf +
+					  pld_len;
+	pad_len = 0;
+	if (pld_len & 0x3)
+		pad_len = 4 - (pld_len % 4);
+
+	if (pad_len) {
+		int i = 0;
+		for (i = 0; i < pad_len; i++) {
+			bnx2i_conn->gen_pdu.resp_wr_ptr[0] = 0;
+			bnx2i_conn->gen_pdu.resp_wr_ptr++;
+		}
+	}
+	__iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr,
+			     bnx2i_conn->gen_pdu.resp_buf,
+			     bnx2i_conn->gen_pdu.resp_wr_ptr -
+			     bnx2i_conn->gen_pdu.resp_buf);
+done:
+	spin_unlock(&session->lock);
+	return 0;
+}
+
+
 /**
  * bnx2i_process_tmf_resp - this function handles iscsi TMF response
  * @session:		iscsi session pointer
@@ -1769,6 +1881,10 @@ static void bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
 			bnx2i_process_tmf_resp(session, bnx2i_conn,
 					       qp->cq_cons_qe);
 			break;
+		case ISCSI_OP_TEXT_RSP:
+			bnx2i_process_text_resp(session, bnx2i_conn,
+						qp->cq_cons_qe);
+			break;
 		case ISCSI_OP_LOGOUT_RSP:
 			bnx2i_process_logout_resp(session, bnx2i_conn,
 						  qp->cq_cons_qe);
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 86ddc08..7621887 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1092,6 +1092,9 @@ static int bnx2i_iscsi_send_generic_request(struct iscsi_task *task)
 	case ISCSI_OP_SCSI_TMFUNC:
 		rc = bnx2i_send_iscsi_tmf(bnx2i_conn, task);
 		break;
+	case ISCSI_OP_TEXT:
+		rc = bnx2i_send_iscsi_text(bnx2i_conn, task);
+		break;
 	default:
 		iscsi_conn_printk(KERN_ALERT, bnx2i_conn->cls_conn->dd_data,
 				  "send_gen: unsupported op 0x%x\n",
@@ -2169,7 +2172,8 @@ struct iscsi_transport bnx2i_iscsi_transport = {
 	.name			= "bnx2i",
 	.caps			= CAP_RECOVERY_L0 | CAP_HDRDGST |
 				  CAP_MULTI_R2T | CAP_DATADGST |
-				  CAP_DATA_PATH_OFFLOAD,
+				  CAP_DATA_PATH_OFFLOAD |
+				  CAP_TEXT_NEGO,
 	.param_mask		= ISCSI_MAX_RECV_DLENGTH |
 				  ISCSI_MAX_XMIT_DLENGTH |
 				  ISCSI_HDRDGST_EN |
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 8/8] BNX2I: Updated to version 2.6.2.3
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (78 preceding siblings ...)
  2011-01-05 20:44 ` [PATCH 7/8] BNX2I: Added iSCSI text pdu support for iSCSI offload Eddie Wai
@ 2011-01-05 20:44 ` Eddie Wai
  2011-01-09  2:00 ` [PATCH] BNX2I: Added reconnect fix connecting against Lefthand targets Eddie Wai
                   ` (29 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-01-05 20:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_init.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index c053764..cbce328 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -18,8 +18,8 @@ static struct list_head adapter_list = LIST_HEAD_INIT(adapter_list);
 static u32 adapter_count;
 
 #define DRV_MODULE_NAME		"bnx2i"
-#define DRV_MODULE_VERSION	"2.6.2.2"
-#define DRV_MODULE_RELDATE	"Nov 23, 2010"
+#define DRV_MODULE_VERSION	"2.6.2.3"
+#define DRV_MODULE_RELDATE	"Dec 31, 2010"
 
 static char version[] __devinitdata =
 		"Broadcom NetXtreme II iSCSI Driver " DRV_MODULE_NAME \
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH 6/8] BNX2I: Added jumbo MTU support for the no shost case
  2011-01-05 20:44 ` [PATCH 6/8] BNX2I: Added jumbo MTU support for the no shost case Eddie Wai
@ 2011-01-05 20:50   ` Mike Christie
  2011-01-05 22:58     ` Eddie Wai
  0 siblings, 1 reply; 189+ messages in thread
From: Mike Christie @ 2011-01-05 20:50 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 01/05/2011 02:44 PM, Eddie Wai wrote:
> For scenarios where the shost is not being passed to bnx2i for the
> iSCSI offload connection request, the code would consult the routing
> table to select the CNIC device.
> This code path will erroneously error out if the corresponding L2
> interface's MTU has been setup to>  1500.
>

When have you guys actually hit this? What tools and what version does this?

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 0/8] Added bug fixes and several features for BNX2I
  2011-01-05 20:44 ` [PATCH 0/8] Added bug fixes and several features for BNX2I Eddie Wai
@ 2011-01-05 20:52   ` James Bottomley
       [not found]     ` <1294260724.16957.29.camel-0iu6Cu4xQGLYCGPCin2YbQ@public.gmane.org>
  2011-01-06 20:43   ` Mike Christie
  1 sibling, 1 reply; 189+ messages in thread
From: James Bottomley @ 2011-01-05 20:52 UTC (permalink / raw)
  To: Eddie Wai
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On Wed, 2011-01-05 at 12:44 -0800, Eddie Wai wrote:
> Hello,
>     
> This patch set contains two fixes and added various features as titled.
> The two fixes are:
> 1 - connection cleanup fix which fixes a chip panic issue
> 2 - nopout LUN field fix which fixes nopout timeouts

So the immediate question is do these need backporting to earlier
kernels via the stable tree (in which case a cc: stable@kernel.org tag
would be needed)?

James


> The features added includes TCP timestamp, jumbo MTU, text pdu support
> for discovery offload, and 57712(E) support.
> 
> Please review.  Thanks.
> Eddie
> 
> Eddie Wai (8):
>   BNX2I: Allow ep CONNECT_FAILED condition to go through proper cleanup
>   BNX2I: Fixed the 32-bit swapping of the LUN field for nopouts for
>     5771X
>   BNX2I: Added handling for unsupported iSCSI offload hba
>   BNX2I: Added support for the 57712(E) devices
>   BNX2I: Added TCP timestamps option support
>   BNX2I: Added jumbo MTU support for the no shost case
>   BNX2I: Added iSCSI text pdu support for iSCSI offload
>   BNX2I: Updated to version 2.6.2.3
> 
>  drivers/net/bnx2x/bnx2x_main.c   |    7 --
>  drivers/scsi/bnx2i/bnx2i.h       |    5 +-
>  drivers/scsi/bnx2i/bnx2i_hwi.c   |  122 +++++++++++++++++++++++++++++++++++++-
>  drivers/scsi/bnx2i/bnx2i_init.c  |   33 ++++++++--
>  drivers/scsi/bnx2i/bnx2i_iscsi.c |   10 +++-
>  include/linux/pci_ids.h          |    2 +
>  6 files changed, 160 insertions(+), 19 deletions(-)
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 5/8] BNX2I: Added TCP timestamps option support
  2011-01-05 20:44 ` [PATCH 5/8] BNX2I: Added TCP timestamps option support Eddie Wai
@ 2011-01-05 20:52   ` Mike Christie
  2011-01-05 21:06     ` Mike Christie
  0 siblings, 1 reply; 189+ messages in thread
From: Mike Christie @ 2011-01-05 20:52 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 01/05/2011 02:44 PM, Eddie Wai wrote:
> This TCP timestamps option is a module wise feature which can be
> enabled via the module param (time_stamps).  Once enabled, the TCP
> connection will advertise timestamps as an option to get negotiated.
>

Is there any reason this has to be module wide? Can the hw support 
having it per connection?

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 5/8] BNX2I: Added TCP timestamps option support
  2011-01-05 20:52   ` Mike Christie
@ 2011-01-05 21:06     ` Mike Christie
       [not found]       ` <4D24DD45.8060701-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>
  0 siblings, 1 reply; 189+ messages in thread
From: Mike Christie @ 2011-01-05 21:06 UTC (permalink / raw)
  To: open-iscsi
  Cc: Eddie Wai, James Bottomley, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 01/05/2011 02:52 PM, Mike Christie wrote:
> On 01/05/2011 02:44 PM, Eddie Wai wrote:
>> This TCP timestamps option is a module wise feature which can be
>> enabled via the module param (time_stamps). Once enabled, the TCP
>> connection will advertise timestamps as an option to get negotiated.
>>
>
> Is there any reason this has to be module wide? Can the hw support
> having it per connection?
>

Oh yeah, what other tcp settings do you guys have? And do you have 
something like a send/recv window setting?



^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 6/8] BNX2I: Added jumbo MTU support for the no shost case
  2011-01-05 20:50   ` Mike Christie
@ 2011-01-05 22:58     ` Eddie Wai
  0 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-01-05 22:58 UTC (permalink / raw)
  To: Mike Christie
  Cc: Eddie Wai, James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Benjamin Li


On Wed, 2011-01-05 at 12:50 -0800, Mike Christie wrote:
> On 01/05/2011 02:44 PM, Eddie Wai wrote:
> > For scenarios where the shost is not being passed to bnx2i for the
> > iSCSI offload connection request, the code would consult the routing
> > table to select the CNIC device.
> > This code path will erroneously error out if the corresponding L2
> > interface's MTU has been setup to>  1500.
> >
> 
> When have you guys actually hit this? What tools and what version does this?
I believe we had run into this case in the past by not specifying the
ifacename parameter in a static node but use transport of bnx2i.  I
would have to go back and revisit that for verification.  But its a
scenario our driver has supports for in the past.  The jumbo MTU support
was added to the shost case a while back.  Adding this is more for
completeness.
> 



^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 5/8] BNX2I: Added TCP timestamps option support
       [not found]       ` <4D24DD45.8060701-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>
@ 2011-01-06  0:39         ` Eddie Wai
  0 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-01-06  0:39 UTC (permalink / raw)
  To: Mike Christie
  Cc: open-iscsi-/JYPxA39Uh5TLH3MbocFFw, Eddie Wai, James Bottomley,
	linux-scsi, Michael Chan, Anil Veerabhadrappa, Benjamin Li


On Wed, 2011-01-05 at 13:06 -0800, Mike Christie wrote:
> On 01/05/2011 02:52 PM, Mike Christie wrote:
> > On 01/05/2011 02:44 PM, Eddie Wai wrote:
> >> This TCP timestamps option is a module wise feature which can be
> >> enabled via the module param (time_stamps). Once enabled, the TCP
> >> connection will advertise timestamps as an option to get negotiated.
> >>
> >
> > Is there any reason this has to be module wide? Can the hw support
> > having it per connection?
> >
> 
Ya, the hw can indeed support TCP time stamp on a per connection based.
It would be great if perhaps we can support this via open-iscsi and have
a tcp option's parameter in the nodes?

> Oh yeah, what other tcp settings do you guys have? And do you have 
> something like a send/recv window setting?
At this time, the TCP windows/scale setting is not an option we can
alter from the driver.  But some of the other options like delay ACK,
nagle, sack are supported (depends on individual chipset as well).
> 



-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 0/8] Added bug fixes and several features for BNX2I
       [not found]     ` <1294260724.16957.29.camel-0iu6Cu4xQGLYCGPCin2YbQ@public.gmane.org>
@ 2011-01-06  0:42       ` Eddie Wai
  0 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-01-06  0:42 UTC (permalink / raw)
  To: James Bottomley
  Cc: Eddie Wai, Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Benjamin Li


On Wed, 2011-01-05 at 12:52 -0800, James Bottomley wrote:
> On Wed, 2011-01-05 at 12:44 -0800, Eddie Wai wrote:
> > Hello,
> >     
> > This patch set contains two fixes and added various features as titled.
> > The two fixes are:
> > 1 - connection cleanup fix which fixes a chip panic issue
> > 2 - nopout LUN field fix which fixes nopout timeouts
> 
> So the immediate question is do these need backporting to earlier
> kernels via the stable tree (in which case a cc: stable-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org tag
> would be needed)?
Both bugs have been present in the code for quite a while.  I think its
just recently that they got exposed.  The severity of the chip panic is
higher as the chip will need to be reset to recover.  But it's not easy
to trigger this and was found only by our PQA doing extraordinary tests.
The nopout LUN bug is more common and will hamper I/O performance if the
nopout LUN field is not 32-bit symmetric.  But the result is not
catastrophic.

I would recommend having these be backported to the stable tree if
possible.  Let me know if you want to move forward with the stable tree
patch.  Thanks.
> 
> James
> 
> 
> > The features added includes TCP timestamp, jumbo MTU, text pdu support
> > for discovery offload, and 57712(E) support.
> > 
> > Please review.  Thanks.
> > Eddie
> > 
> > Eddie Wai (8):
> >   BNX2I: Allow ep CONNECT_FAILED condition to go through proper cleanup
> >   BNX2I: Fixed the 32-bit swapping of the LUN field for nopouts for
> >     5771X
> >   BNX2I: Added handling for unsupported iSCSI offload hba
> >   BNX2I: Added support for the 57712(E) devices
> >   BNX2I: Added TCP timestamps option support
> >   BNX2I: Added jumbo MTU support for the no shost case
> >   BNX2I: Added iSCSI text pdu support for iSCSI offload
> >   BNX2I: Updated to version 2.6.2.3
> > 
> >  drivers/net/bnx2x/bnx2x_main.c   |    7 --
> >  drivers/scsi/bnx2i/bnx2i.h       |    5 +-
> >  drivers/scsi/bnx2i/bnx2i_hwi.c   |  122 +++++++++++++++++++++++++++++++++++++-
> >  drivers/scsi/bnx2i/bnx2i_init.c  |   33 ++++++++--
> >  drivers/scsi/bnx2i/bnx2i_iscsi.c |   10 +++-
> >  include/linux/pci_ids.h          |    2 +
> >  6 files changed, 160 insertions(+), 19 deletions(-)
> > 
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
> 


-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 06/16] BNX2I: Added code to handle the binding of an existing connection
  2011-01-02  4:11     ` Mike Christie
@ 2011-01-06  6:54       ` Or Gerlitz
  2011-01-06 20:38         ` Mike Christie
  0 siblings, 1 reply; 189+ messages in thread
From: Or Gerlitz @ 2011-01-06  6:54 UTC (permalink / raw)
  To: open-iscsi
  Cc: Eddie Wai, James Bottomley, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

Mike Christie wrote:
> I went a different way. In the attached patch we detect the problem when
> binding and will force a disconnect of the old ep before binding a new one.
> Try it out and let me know.

> --- a/drivers/scsi/iscsi_tcp.c
> +++ b/drivers/scsi/iscsi_tcp.c
> @@ -651,8 +651,7 @@ free_addr:
>  
>  static int
>  iscsi_sw_tcp_conn_bind(struct iscsi_cls_session *cls_session,
> -		       struct iscsi_cls_conn *cls_conn, uint64_t transport_eph,
> -		       int is_leading)
> +		       struct iscsi_cls_conn *cls_conn, uint64_t transport_eph)
>  {
>  	struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
>  	struct iscsi_host *ihost = shost_priv(shost);
> @@ -685,7 +684,7 @@ iscsi_sw_tcp_conn_bind(struct iscsi_cls_session *cls_session,
>  	if (err)
>  		goto free_socket;
>  
> -	err = iscsi_conn_bind(cls_session, cls_conn, is_leading);
> +	err = iscsi_conn_bind(cls_session, cls_conn, NULL);

should this be transport_eph instead of NULL?

> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -3137,16 +3137,18 @@ void iscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
>  EXPORT_SYMBOL_GPL(iscsi_conn_stop);
>  
>  int iscsi_conn_bind(struct iscsi_cls_session *cls_session,
> -		    struct iscsi_cls_conn *cls_conn, int is_leading)
> +		    struct iscsi_cls_conn *cls_conn,
> +		    struct iscsi_endpoint *ep)
>  {
>  	struct iscsi_session *session = cls_session->dd_data;
>  	struct iscsi_conn *conn = cls_conn->dd_data;
>  
>  	spin_lock_bh(&session->lock);
> -	if (is_leading)
> -		session->leadconn = conn;
> +	session->leadconn = conn;
>  	spin_unlock_bh(&session->lock);
>  
> +	ep->conn = cls_conn;
> +	cls_conn->ep = ep;

if not, it doesn't look like ep can be null here...


> --- a/include/scsi/libiscsi.h
> +++ b/include/scsi/libiscsi.h
> @@ -388,7 +388,7 @@ extern void iscsi_conn_teardown(struct iscsi_cls_conn *);
>  extern int iscsi_conn_bind(struct iscsi_cls_session *, struct iscsi_cls_conn *,
> -			   int);
> +			   struct iscsi_endpoint *);

> --- a/include/scsi/scsi_transport_iscsi.h
> +++ b/include/scsi/scsi_transport_iscsi.h
> @@ -95,7 +95,7 @@ struct iscsi_transport {
>  				uint32_t cid);
>  	int (*bind_conn) (struct iscsi_cls_session *session,
>  			  struct iscsi_cls_conn *cls_conn,
> -			  uint64_t transport_eph, int is_leading);
> +			  uint64_t transport_eph);

so we're implicitly casting from u64 to ep pointer? I guess this should be fine.

Or.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 06/16] BNX2I: Added code to handle the binding of an existing connection
  2011-01-06  6:54       ` Or Gerlitz
@ 2011-01-06 20:38         ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2011-01-06 20:38 UTC (permalink / raw)
  To: open-iscsi
  Cc: Or Gerlitz, Eddie Wai, James Bottomley, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 01/06/2011 12:54 AM, Or Gerlitz wrote:
> Mike Christie wrote:
>> I went a different way. In the attached patch we detect the problem when
>> binding and will force a disconnect of the old ep before binding a new one.
>> Try it out and let me know.
>
>> --- a/drivers/scsi/iscsi_tcp.c
>> +++ b/drivers/scsi/iscsi_tcp.c
>> @@ -651,8 +651,7 @@ free_addr:
>>
>>   static int
>>   iscsi_sw_tcp_conn_bind(struct iscsi_cls_session *cls_session,
>> -		       struct iscsi_cls_conn *cls_conn, uint64_t transport_eph,
>> -		       int is_leading)
>> +		       struct iscsi_cls_conn *cls_conn, uint64_t transport_eph)
>>   {
>>   	struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
>>   	struct iscsi_host *ihost = shost_priv(shost);
>> @@ -685,7 +684,7 @@ iscsi_sw_tcp_conn_bind(struct iscsi_cls_session *cls_session,
>>   	if (err)
>>   		goto free_socket;
>>
>> -	err = iscsi_conn_bind(cls_session, cls_conn, is_leading);
>> +	err = iscsi_conn_bind(cls_session, cls_conn, NULL);
>
> should this be transport_eph instead of NULL?


No. iscsi_tcp does not use the iscsi_endpoint abstraction becuase it 
actually uses normal old sockets that are created in userspace.

>
>> --- a/drivers/scsi/libiscsi.c
>> +++ b/drivers/scsi/libiscsi.c
>> @@ -3137,16 +3137,18 @@ void iscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
>>   EXPORT_SYMBOL_GPL(iscsi_conn_stop);
>>
>>   int iscsi_conn_bind(struct iscsi_cls_session *cls_session,
>> -		    struct iscsi_cls_conn *cls_conn, int is_leading)
>> +		    struct iscsi_cls_conn *cls_conn,
>> +		    struct iscsi_endpoint *ep)
>>   {
>>   	struct iscsi_session *session = cls_session->dd_data;
>>   	struct iscsi_conn *conn = cls_conn->dd_data;
>>
>>   	spin_lock_bh(&session->lock);
>> -	if (is_leading)
>> -		session->leadconn = conn;
>> +	session->leadconn = conn;
>>   	spin_unlock_bh(&session->lock);
>>
>> +	ep->conn = cls_conn;
>> +	cls_conn->ep = ep;
>
> if not, it doesn't look like ep can be null here...

Will fix. Tested offload and did not test software iscsi.

>
>
>> --- a/include/scsi/libiscsi.h
>> +++ b/include/scsi/libiscsi.h
>> @@ -388,7 +388,7 @@ extern void iscsi_conn_teardown(struct iscsi_cls_conn *);
>>   extern int iscsi_conn_bind(struct iscsi_cls_session *, struct iscsi_cls_conn *,
>> -			   int);
>> +			   struct iscsi_endpoint *);
>
>> --- a/include/scsi/scsi_transport_iscsi.h
>> +++ b/include/scsi/scsi_transport_iscsi.h
>> @@ -95,7 +95,7 @@ struct iscsi_transport {
>>   				uint32_t cid);
>>   	int (*bind_conn) (struct iscsi_cls_session *session,
>>   			  struct iscsi_cls_conn *cls_conn,
>> -			  uint64_t transport_eph, int is_leading);
>> +			  uint64_t transport_eph);
>
> so we're implicitly casting from u64 to ep pointer? I guess this should be fine.
>

No. The transport->bind_conn takes the u64 id. The driver then looks 
that up and passes iscsi_bind_conn a pointer to the ep struct.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 0/8] Added bug fixes and several features for BNX2I
  2011-01-05 20:44 ` [PATCH 0/8] Added bug fixes and several features for BNX2I Eddie Wai
  2011-01-05 20:52   ` James Bottomley
@ 2011-01-06 20:43   ` Mike Christie
  2011-01-26 21:55     ` Mike Christie
  1 sibling, 1 reply; 189+ messages in thread
From: Mike Christie @ 2011-01-06 20:43 UTC (permalink / raw)
  To: open-iscsi
  Cc: Eddie Wai, James Bottomley, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 01/05/2011 02:44 PM, Eddie Wai wrote:
> Hello,
>
> This patch set contains two fixes and added various features as titled.
> The two fixes are:
> 1 - connection cleanup fix which fixes a chip panic issue
> 2 - nopout LUN field fix which fixes nopout timeouts
>
> The features added includes TCP timestamp, jumbo MTU, text pdu support
> for discovery offload, and 57712(E) support.

All patches but "[PATCH 5/8] BNX2I: Added TCP timestamps option support" 
look ok. I am working on a common way to set tcp settings for 2.6.39, so 
lets wait on that.


>    BNX2I: Added TCP timestamps option support



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH] BNX2I: Added reconnect fix connecting against Lefthand targets
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (79 preceding siblings ...)
  2011-01-05 20:44 ` [PATCH 8/8] BNX2I: Updated to version 2.6.2.3 Eddie Wai
@ 2011-01-09  2:00 ` Eddie Wai
  2011-01-09  5:44   ` Mike Christie
  2011-05-16 18:13 ` [PATCH 0/3] BNX2I: Bug fixes and Performance Optimization Eddie Wai
                   ` (28 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2011-01-09  2:00 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The nopout's reserved field was not being initialized to zero
before being reused.  Stale CDB values from previous SCSI cmds
of the same BHS offset was the cause of the disconnection
initiated by the Lefthand target.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 9375369..5442f1a 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -490,6 +490,9 @@ int bnx2i_send_iscsi_nopout(struct bnx2i_conn *bnx2i_conn,
 	bnx2i_cmd = (struct bnx2i_cmd *)task->dd_data;
 	nopout_hdr = (struct iscsi_nopout *)task->hdr;
 	nopout_wqe = (struct bnx2i_nop_out_request *)ep->qp.sq_prod_qe;
+
+	memset(nopout_wqe, 0x00, sizeof(struct bnx2i_nop_out_request));
+
 	nopout_wqe->op_code = nopout_hdr->opcode;
 	nopout_wqe->op_attr = ISCSI_FLAG_CMD_FINAL;
 	memcpy(nopout_wqe->lun, nopout_hdr->lun, 8);
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH] BNX2I: Added reconnect fix connecting against Lefthand targets
  2011-01-09  2:00 ` [PATCH] BNX2I: Added reconnect fix connecting against Lefthand targets Eddie Wai
@ 2011-01-09  5:44   ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2011-01-09  5:44 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 01/08/2011 08:00 PM, Eddie Wai wrote:
> The nopout's reserved field was not being initialized to zero
> before being reused.  Stale CDB values from previous SCSI cmds
> of the same BHS offset was the cause of the disconnection
> initiated by the Lefthand target.
>
> Signed-off-by: Eddie Wai<eddie.wai@broadcom.com>
> ---
>   drivers/scsi/bnx2i/bnx2i_hwi.c |    3 +++
>   1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
> index 9375369..5442f1a 100644
> --- a/drivers/scsi/bnx2i/bnx2i_hwi.c
> +++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
> @@ -490,6 +490,9 @@ int bnx2i_send_iscsi_nopout(struct bnx2i_conn *bnx2i_conn,
>   	bnx2i_cmd = (struct bnx2i_cmd *)task->dd_data;
>   	nopout_hdr = (struct iscsi_nopout *)task->hdr;
>   	nopout_wqe = (struct bnx2i_nop_out_request *)ep->qp.sq_prod_qe;
> +
> +	memset(nopout_wqe, 0x00, sizeof(struct bnx2i_nop_out_request));
> +
>   	nopout_wqe->op_code = nopout_hdr->opcode;
>   	nopout_wqe->op_attr = ISCSI_FLAG_CMD_FINAL;
>   	memcpy(nopout_wqe->lun, nopout_hdr->lun, 8);

Looks ok.

Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 0/8] Added bug fixes and several features for BNX2I
  2011-01-06 20:43   ` Mike Christie
@ 2011-01-26 21:55     ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2011-01-26 21:55 UTC (permalink / raw)
  To: open-iscsi
  Cc: Eddie Wai, James Bottomley, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 01/06/2011 02:43 PM, Mike Christie wrote:
> On 01/05/2011 02:44 PM, Eddie Wai wrote:
>> Hello,
>>
>> This patch set contains two fixes and added various features as titled.
>> The two fixes are:
>> 1 - connection cleanup fix which fixes a chip panic issue
>> 2 - nopout LUN field fix which fixes nopout timeouts
>>
>> The features added includes TCP timestamp, jumbo MTU, text pdu support
>> for discovery offload, and 57712(E) support.
>
> All patches but "[PATCH 5/8] BNX2I: Added TCP timestamps option support"
> look ok. I am working on a common way to set tcp settings for 2.6.39, so
> lets wait on that.
>

I think I miswrote that. I meant to write all patches except "[PATCH 
5/8] BNX2I: Added TCP timestamps option support" are ok so:

Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>

on them.



This patch
"[PATCH 5/8] BNX2I: Added TCP timestamps option support"
should be done generically so just drop this patch.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 0/3] BNX2I: Bug fixes and Performance Optimization
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (80 preceding siblings ...)
  2011-01-09  2:00 ` [PATCH] BNX2I: Added reconnect fix connecting against Lefthand targets Eddie Wai
@ 2011-05-16 18:13 ` Eddie Wai
  2011-05-18 19:52   ` Mike Christie
  2011-05-16 18:13 ` [PATCH 1/3] BNX2I: Fixed packet error created when the sq_size is set to 16 Eddie Wai
                   ` (27 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2011-05-16 18:13 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Hello,

This patch set contains a bug fix and some performance optimization
for iSCSI offload connection cleanup/recovery and throughput.

Please review, thanks.

Eddie Wai (3):
  BNX2I: Fixed packet error created when the sq_size is set to 16
  BNX2I: Updated the connection shutdown/cleanup timeout
  BNX2I: Optimized the iSCSI offload performance

 drivers/scsi/bnx2i/bnx2i.h       |   16 ++++++++++------
 drivers/scsi/bnx2i/bnx2i_hwi.c   |   27 +++++++++++++++------------
 drivers/scsi/bnx2i/bnx2i_init.c  |    2 +-
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   13 +++++++++++--
 4 files changed, 37 insertions(+), 21 deletions(-)



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 1/3] BNX2I: Fixed packet error created when the sq_size is set to 16
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (81 preceding siblings ...)
  2011-05-16 18:13 ` [PATCH 0/3] BNX2I: Bug fixes and Performance Optimization Eddie Wai
@ 2011-05-16 18:13 ` Eddie Wai
  2011-05-16 18:13 ` [PATCH 2/3] BNX2I: Updated the connection shutdown/cleanup timeout Eddie Wai
                   ` (26 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-05-16 18:13 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The number of chip's internal command cell, which is use to generate
SCSI cmd packets to the target, was not initialized correctly by
the driver when the sq_size is changed from the default 128.
This, in turn, will create a problem where the chip's transmit pipe
will erroneously reuse an old command cell that is no longer valid.
The fix is to correctly initialize the chip's command cell upon setup.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c   |    1 +
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    3 +++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index f0b8951..a8a2b6b 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1274,6 +1274,7 @@ int bnx2i_send_fw_iscsi_init_msg(struct bnx2i_hba *hba)
 	iscsi_init.dummy_buffer_addr_hi =
 		(u32) ((u64) hba->dummy_buf_dma >> 32);
 
+	hba->num_ccell = hba->max_sqes >> 1;
 	hba->ctx_ccell_tasks =
 			((hba->num_ccell & 0xFFFF) | (hba->max_sqes << 16));
 	iscsi_init.num_ccells_per_conn = hba->num_ccell;
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 1809f9c..7b4d1d0 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1208,6 +1208,9 @@ static int bnx2i_task_xmit(struct iscsi_task *task)
 	struct bnx2i_cmd *cmd = task->dd_data;
 	struct iscsi_cmd *hdr = (struct iscsi_cmd *) task->hdr;
 
+	if (bnx2i_conn->ep->num_active_cmds + 1 > hba->max_sqes)
+		return -ENOMEM;
+
 	/*
 	 * If there is no scsi_cmnd this must be a mgmt task
 	 */
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 2/3] BNX2I: Updated the connection shutdown/cleanup timeout
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (82 preceding siblings ...)
  2011-05-16 18:13 ` [PATCH 1/3] BNX2I: Fixed packet error created when the sq_size is set to 16 Eddie Wai
@ 2011-05-16 18:13 ` Eddie Wai
  2011-05-16 18:13 ` [PATCH 3/3] BNX2I: Optimized the iSCSI offload performance Eddie Wai
                   ` (25 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-05-16 18:13 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Modified the 10s wait time for inflight offload connections to
advance to the next state to 2s based on test result.
Modified the 20s shutdown timeout to 30s based on test result.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_init.c  |    2 +-
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 1d24a28..6adbdc3 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -244,7 +244,7 @@ void bnx2i_stop(void *handle)
 	wait_event_interruptible_timeout(hba->eh_wait,
 					 (list_empty(&hba->ep_ofld_list) &&
 					 list_empty(&hba->ep_destroy_list)),
-					 10 * HZ);
+					 2 * HZ);
 	/* Wait for all endpoints to be torn down, Chip will be reset once
 	 *  control returns to network driver. So it is required to cleanup and
 	 * release all connection resources before returning from this routine.
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 7b4d1d0..51a970f 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -858,7 +858,7 @@ struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic)
 	mutex_init(&hba->net_dev_lock);
 	init_waitqueue_head(&hba->eh_wait);
 	if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type)) {
-		hba->hba_shutdown_tmo = 20 * HZ;
+		hba->hba_shutdown_tmo = 30 * HZ;
 		hba->conn_teardown_tmo = 20 * HZ;
 		hba->conn_ctx_destroy_tmo = 6 * HZ;
 	} else {	/* 5706/5708/5709 */
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 3/3] BNX2I: Optimized the iSCSI offload performance
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (83 preceding siblings ...)
  2011-05-16 18:13 ` [PATCH 2/3] BNX2I: Updated the connection shutdown/cleanup timeout Eddie Wai
@ 2011-05-16 18:13 ` Eddie Wai
  2011-05-16 19:13   ` Mike Christie
  2011-06-21 16:49 ` [PATCH 0/4] BNX2I: Code and performance optimization Eddie Wai
                   ` (24 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2011-05-16 18:13 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Modified the event coalescing code for iSCSI offload to combat both
corner cases and optimize performance as follows:

1. Added mechanism to loop back a second time to process any leftover
CQEs that was generated by the hardware during the time the driver is
busy processing previous CQEs in the bh.  This not only helps the
performance but also fixes the corner case when no more CQEs are
being generated in the pipeline; so those leftover CQEs will get a
a chance to be processed.

2. Added ARM_CQE_FP to distinguish between fast path arming versus
slow path arming.  This change will guarantee that the CQEs will always
get a chance to be re-armed during fast path completions.

3. Removed the inline event coalescing division for perf optimization.
Also fixed a division-by-zero error when the event_coal_div module param
was set to 0.

4. Changed the default SQ WQEs size from 256 to 128 to match chip default.

5. Changed the cmd_per_lun from 32 to 24.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |   16 ++++++++++------
 drivers/scsi/bnx2i/bnx2i_hwi.c   |   26 ++++++++++++++------------
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    8 +++++++-
 3 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index cfd5902..6bdd25a 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -66,11 +66,11 @@
 #define BD_SPLIT_SIZE			32768
 
 /* min, max & default values for SQ/RQ/CQ size, configurable via' modparam */
-#define BNX2I_SQ_WQES_MIN 		16
-#define BNX2I_570X_SQ_WQES_MAX 		128
-#define BNX2I_5770X_SQ_WQES_MAX 	512
-#define BNX2I_570X_SQ_WQES_DEFAULT 	128
-#define BNX2I_5770X_SQ_WQES_DEFAULT 	256
+#define BNX2I_SQ_WQES_MIN		16
+#define BNX2I_570X_SQ_WQES_MAX		128
+#define BNX2I_5770X_SQ_WQES_MAX		512
+#define BNX2I_570X_SQ_WQES_DEFAULT	128
+#define BNX2I_5770X_SQ_WQES_DEFAULT	128
 
 #define BNX2I_570X_CQ_WQES_MAX 		128
 #define BNX2I_5770X_CQ_WQES_MAX 	512
@@ -115,6 +115,7 @@
 #define BNX2X_MAX_CQS			8
 
 #define CNIC_ARM_CQE			1
+#define CNIC_ARM_CQE_FP			2
 #define CNIC_DISARM_CQE			0
 
 #define REG_RD(__hba, offset)				\
@@ -666,7 +667,9 @@ enum {
  *                      after HBA reset is completed by bnx2i/cnic/bnx2
  *                      modules
  * @state:              tracks offload connection state machine
- * @teardown_mode:      indicates if conn teardown is abortive or orderly
+ * @timestamp:          tracks the start time when the ep begins to connect
+ * @num_active_cmds:    tracks the number of outstanding commands for this ep
+ * @ec_shift:           the amount of shift as part of the event coal calc
  * @qp:                 QP information
  * @ids:                contains chip allocated *context id* & driver assigned
  *                      *iscsi cid*
@@ -685,6 +688,7 @@ struct bnx2i_endpoint {
 	u32 state;
 	unsigned long timestamp;
 	int num_active_cmds;
+	u32 ec_shift;
 
 	struct qp_info qp;
 	struct ep_handles ids;
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index a8a2b6b..5c54a2d 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -138,7 +138,6 @@ void bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action)
 	u16 next_index;
 	u32 num_active_cmds;
 
-
 	/* Coalesce CQ entries only on 10G devices */
 	if (!test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type))
 		return;
@@ -148,16 +147,19 @@ void bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action)
 	 * interrupts and other unwanted results
 	 */
 	cq_db = (struct bnx2i_5771x_cq_db *) ep->qp.cq_pgtbl_virt;
-	if (cq_db->sqn[0] && cq_db->sqn[0] != 0xFFFF)
-		return;
 
-	if (action == CNIC_ARM_CQE) {
+	if (action != CNIC_ARM_CQE_FP)
+		if (cq_db->sqn[0] && cq_db->sqn[0] != 0xFFFF)
+			return;
+
+	if (action == CNIC_ARM_CQE || action == CNIC_ARM_CQE_FP) {
 		num_active_cmds = ep->num_active_cmds;
 		if (num_active_cmds <= event_coal_min)
 			next_index = 1;
 		else
 			next_index = event_coal_min +
-				(num_active_cmds - event_coal_min) / event_coal_div;
+				     ((num_active_cmds - event_coal_min) >>
+				     ep->ec_shift);
 		if (!next_index)
 			next_index = 1;
 		cq_index = ep->qp.cqe_exp_seq_sn + next_index - 1;
@@ -1935,7 +1937,6 @@ cqe_out:
 			qp->cq_cons_idx++;
 		}
 	}
-	bnx2i_arm_cq_event_coalescing(bnx2i_conn->ep, CNIC_ARM_CQE);
 }
 
 /**
@@ -1949,22 +1950,23 @@ cqe_out:
 static void bnx2i_fastpath_notification(struct bnx2i_hba *hba,
 					struct iscsi_kcqe *new_cqe_kcqe)
 {
-	struct bnx2i_conn *conn;
+	struct bnx2i_conn *bnx2i_conn;
 	u32 iscsi_cid;
 
 	iscsi_cid = new_cqe_kcqe->iscsi_conn_id;
-	conn = bnx2i_get_conn_from_id(hba, iscsi_cid);
+	bnx2i_conn = bnx2i_get_conn_from_id(hba, iscsi_cid);
 
-	if (!conn) {
+	if (!bnx2i_conn) {
 		printk(KERN_ALERT "cid #%x not valid\n", iscsi_cid);
 		return;
 	}
-	if (!conn->ep) {
+	if (!bnx2i_conn->ep) {
 		printk(KERN_ALERT "cid #%x - ep not bound\n", iscsi_cid);
 		return;
 	}
-
-	bnx2i_process_new_cqes(conn);
+	bnx2i_process_new_cqes(bnx2i_conn);
+	bnx2i_arm_cq_event_coalescing(bnx2i_conn->ep, CNIC_ARM_CQE_FP);
+	bnx2i_process_new_cqes(bnx2i_conn);
 }
 
 
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 51a970f..041928b 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -379,6 +379,7 @@ static struct iscsi_endpoint *bnx2i_alloc_ep(struct bnx2i_hba *hba)
 {
 	struct iscsi_endpoint *ep;
 	struct bnx2i_endpoint *bnx2i_ep;
+	u32 ec_div;
 
 	ep = iscsi_create_endpoint(sizeof(*bnx2i_ep));
 	if (!ep) {
@@ -393,6 +394,11 @@ static struct iscsi_endpoint *bnx2i_alloc_ep(struct bnx2i_hba *hba)
 	bnx2i_ep->ep_iscsi_cid = (u16) -1;
 	bnx2i_ep->hba = hba;
 	bnx2i_ep->hba_age = hba->age;
+
+	ec_div = event_coal_div;
+	while (ec_div >>= 1)
+		bnx2i_ep->ec_shift += 1;
+
 	hba->ofld_conns_active++;
 	init_waitqueue_head(&bnx2i_ep->ofld_wait);
 	return ep;
@@ -2159,7 +2165,7 @@ static struct scsi_host_template bnx2i_host_template = {
 	.change_queue_depth	= iscsi_change_queue_depth,
 	.can_queue		= 1024,
 	.max_sectors		= 127,
-	.cmd_per_lun		= 32,
+	.cmd_per_lun		= 24,
 	.this_id		= -1,
 	.use_clustering		= ENABLE_CLUSTERING,
 	.sg_tablesize		= ISCSI_MAX_BDS_PER_CMD,
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH 3/3] BNX2I: Optimized the iSCSI offload performance
  2011-05-16 18:13 ` [PATCH 3/3] BNX2I: Optimized the iSCSI offload performance Eddie Wai
@ 2011-05-16 19:13   ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2011-05-16 19:13 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 05/16/2011 01:13 PM, Eddie Wai wrote:
> 5. Changed the cmd_per_lun from 32 to 24.
>

What was the reason for this?

> @@ -2159,7 +2165,7 @@ static struct scsi_host_template bnx2i_host_template = {
>   	.change_queue_depth	= iscsi_change_queue_depth,
>   	.can_queue		= 1024,
>   	.max_sectors		= 127,
> -	.cmd_per_lun		= 32,
> +	.cmd_per_lun		= 24,
>   	.this_id		= -1,
>   	.use_clustering		= ENABLE_CLUSTERING,
>   	.sg_tablesize		= ISCSI_MAX_BDS_PER_CMD,


^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 0/3] BNX2I: Bug fixes and Performance Optimization
  2011-05-16 18:13 ` [PATCH 0/3] BNX2I: Bug fixes and Performance Optimization Eddie Wai
@ 2011-05-18 19:52   ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2011-05-18 19:52 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 05/16/2011 01:13 PM, Eddie Wai wrote:
> Hello,
>
> This patch set contains a bug fix and some performance optimization
> for iSCSI offload connection cleanup/recovery and throughput.
>
> Please review, thanks.
>
> Eddie Wai (3):
>    BNX2I: Fixed packet error created when the sq_size is set to 16
>    BNX2I: Updated the connection shutdown/cleanup timeout
>    BNX2I: Optimized the iSCSI offload performance
>
>   drivers/scsi/bnx2i/bnx2i.h       |   16 ++++++++++------
>   drivers/scsi/bnx2i/bnx2i_hwi.c   |   27 +++++++++++++++------------
>   drivers/scsi/bnx2i/bnx2i_init.c  |    2 +-
>   drivers/scsi/bnx2i/bnx2i_iscsi.c |   13 +++++++++++--
>   4 files changed, 37 insertions(+), 21 deletions(-)
>

Got my question in the other mail answered.

Patches look ok.

Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 0/4] BNX2I: Code and performance optimization
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (84 preceding siblings ...)
  2011-05-16 18:13 ` [PATCH 3/3] BNX2I: Optimized the iSCSI offload performance Eddie Wai
@ 2011-06-21 16:49 ` Eddie Wai
  2011-06-21 16:49 ` [PATCH 1/4] BNX2I: Added the use of kthreads to handle SCSI cmd completion Eddie Wai
                   ` (23 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-06-21 16:49 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

This patch set contains a collection of code and performance optimization
changes.

Your comments are welcome.  Please review.

Eddie

Eddie Wai (4):
  BNX2I: Added the use of kthreads to handle SCSI cmd completion
  BNX2I: Modified to skip CNIC registration if iSCSI is not supported
  BNX2I: Changed the nopout_wqe->lun memcpy to use sizeof instead
  BNX2I: Updated copyright and bump version

 drivers/scsi/bnx2i/57xx_iscsi_constants.h |    2 +-
 drivers/scsi/bnx2i/57xx_iscsi_hsi.h       |    2 +-
 drivers/scsi/bnx2i/bnx2i.h                |   35 +++++-
 drivers/scsi/bnx2i/bnx2i_hwi.c            |  188 ++++++++++++++++++++++++-----
 drivers/scsi/bnx2i/bnx2i_init.c           |  153 +++++++++++++++++++++---
 drivers/scsi/bnx2i/bnx2i_iscsi.c          |   43 ++++++-
 drivers/scsi/bnx2i/bnx2i_sysfs.c          |    2 +-
 7 files changed, 366 insertions(+), 59 deletions(-)



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 1/4] BNX2I: Added the use of kthreads to handle SCSI cmd completion
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (85 preceding siblings ...)
  2011-06-21 16:49 ` [PATCH 0/4] BNX2I: Code and performance optimization Eddie Wai
@ 2011-06-21 16:49 ` Eddie Wai
  2011-06-22  2:54   ` Mike Christie
  2011-06-21 16:49 ` [PATCH 2/4] BNX2I: Modified to skip CNIC registration if iSCSI is not supported Eddie Wai
                   ` (22 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2011-06-21 16:49 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

This patch breaks the SCSI cmd completion into two parts:
1. The bh will allocate and queued work to the cmd specific CPU IO
completion kthread.  The CPU for the cmd is recorded in task_xmit.

2. The CPU specific IO completion kthread will call the scsi_cmd_resp
routine to do the actual cmd completion.

In the normal case, these IO completion kthreads should complete before
the blk IO times out at 60s.  However, in the case when these kthreads
are blocked for whatever reason and exceeded the timeout, the call
to conn_destroy will have to iterate and exhaust all related work in the
percpu work list for all online CPUs.  This will guarantee the protection
of the work->session and conn pointers before they get freed.

Also modified the event coalescing formula to have at least the
event_coal_min outstanding cmds in the pipeline so the SCSI producer
would not get underrun.

Also changed the following SCSI parameters:
- can_queue from 1024 to 2048
- cmds_per_lun from 24 to 128

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Benjamin Li <benli@broadcom.com>
Acked-by: Michael Chan <mchan@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |   33 ++++++-
 drivers/scsi/bnx2i/bnx2i_hwi.c   |  184 ++++++++++++++++++++++++++++++++------
 drivers/scsi/bnx2i/bnx2i_init.c  |  118 ++++++++++++++++++++++++-
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   41 ++++++++-
 4 files changed, 341 insertions(+), 35 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 6bdd25a..4e5c002 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -22,11 +22,14 @@
 #include <linux/pci.h>
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
+#include <linux/delay.h>
 #include <linux/sched.h>
 #include <linux/in.h>
 #include <linux/kfifo.h>
 #include <linux/netdevice.h>
 #include <linux/completion.h>
+#include <linux/kthread.h>
+#include <linux/cpu.h>
 
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_device.h>
@@ -202,10 +205,14 @@ struct io_bdt {
 /**
  * bnx2i_cmd - iscsi command structure
  *
+ * @hdr:                iSCSI header
+ * @conn:               iscsi_conn pointer
  * @scsi_cmd:           SCSI-ML task pointer corresponding to this iscsi cmd
  * @sg:                 SG list
  * @io_tbl:             buffer descriptor (BD) table
  * @bd_tbl_dma:         buffer descriptor (BD) table's dma address
+ * @req:                bnx2i specific command request struct
+ * @cpu:                CPU number of the specific cmd; for completion purposes
  */
 struct bnx2i_cmd {
 	struct iscsi_hdr hdr;
@@ -215,6 +222,7 @@ struct bnx2i_cmd {
 	struct io_bdt io_tbl;
 	dma_addr_t bd_tbl_dma;
 	struct bnx2i_cmd_request req;
+	u32 cpu;
 };
 
 
@@ -229,6 +237,7 @@ struct bnx2i_cmd {
  * @gen_pdu:               login/nopout/logout pdu resources
  * @violation_notified:    bit mask used to track iscsi error/warning messages
  *                         already printed out
+ * @work_cnt:              keeps track of the number of outstanding work
  *
  * iSCSI connection structure
  */
@@ -252,6 +261,8 @@ struct bnx2i_conn {
 	 */
 	struct generic_pdu_resc gen_pdu;
 	u64 violation_notified;
+
+	atomic_t work_cnt;
 };
 
 
@@ -661,7 +672,6 @@ enum {
  * @hba:                adapter to which this connection belongs
  * @conn:               iscsi connection this EP is linked to
  * @cls_ep:             associated iSCSI endpoint pointer
- * @sess:               iscsi session this EP is linked to
  * @cm_sk:              cnic sock struct
  * @hba_age:            age to detect if 'iscsid' issues ep_disconnect()
  *                      after HBA reset is completed by bnx2i/cnic/bnx2
@@ -687,7 +697,7 @@ struct bnx2i_endpoint {
 	u32 hba_age;
 	u32 state;
 	unsigned long timestamp;
-	int num_active_cmds;
+	atomic_t num_active_cmds;
 	u32 ec_shift;
 
 	struct qp_info qp;
@@ -700,6 +710,19 @@ struct bnx2i_endpoint {
 };
 
 
+struct bnx2i_work {
+	struct list_head list;
+	struct iscsi_session *session;
+	struct bnx2i_conn *bnx2i_conn;
+	struct cqe cqe;
+};
+
+struct bnx2i_percpu_s {
+	struct task_struct *iothread;
+	struct list_head work_list;
+	spinlock_t p_work_lock;
+};
+
 
 /* Global variables */
 extern unsigned int error_mask1, error_mask2;
@@ -783,7 +806,7 @@ extern struct bnx2i_endpoint *bnx2i_find_ep_in_destroy_list(
 		struct bnx2i_hba *hba, u32 iscsi_cid);
 
 extern int bnx2i_map_ep_dbell_regs(struct bnx2i_endpoint *ep);
-extern void bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action);
+extern int bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action);
 
 extern int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep);
 
@@ -793,4 +816,8 @@ extern void bnx2i_print_active_cmd_queue(struct bnx2i_conn *conn);
 extern void bnx2i_print_xmit_pdu_queue(struct bnx2i_conn *conn);
 extern void bnx2i_print_recv_state(struct bnx2i_conn *conn);
 
+extern int bnx2i_percpu_io_thread(void *arg);
+extern int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session,
+				       struct bnx2i_conn *bnx2i_conn,
+				       struct cqe *cqe);
 #endif
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 5c54a2d..64089e2 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -17,6 +17,8 @@
 #include <scsi/libiscsi.h>
 #include "bnx2i.h"
 
+DECLARE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu);
+
 /**
  * bnx2i_get_cid_num - get cid from ep
  * @ep: 	endpoint pointer
@@ -131,16 +133,16 @@ static void bnx2i_iscsi_license_error(struct bnx2i_hba *hba, u32 error_code)
  *	the driver. EQ event is generated CQ index is hit or at least 1 CQ is
  *	outstanding and on chip timer expires
  */
-void bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action)
+int bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action)
 {
 	struct bnx2i_5771x_cq_db *cq_db;
 	u16 cq_index;
-	u16 next_index;
+	u16 next_index = 0;
 	u32 num_active_cmds;
 
 	/* Coalesce CQ entries only on 10G devices */
 	if (!test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type))
-		return;
+		return 0;
 
 	/* Do not update CQ DB multiple times before firmware writes
 	 * '0xFFFF' to CQDB->SQN field. Deviation may cause spurious
@@ -150,16 +152,17 @@ void bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action)
 
 	if (action != CNIC_ARM_CQE_FP)
 		if (cq_db->sqn[0] && cq_db->sqn[0] != 0xFFFF)
-			return;
+			return 0;
 
 	if (action == CNIC_ARM_CQE || action == CNIC_ARM_CQE_FP) {
-		num_active_cmds = ep->num_active_cmds;
+		num_active_cmds = atomic_read(&ep->num_active_cmds);
 		if (num_active_cmds <= event_coal_min)
 			next_index = 1;
-		else
-			next_index = event_coal_min +
-				     ((num_active_cmds - event_coal_min) >>
-				     ep->ec_shift);
+		else {
+			next_index = num_active_cmds >> ep->ec_shift;
+			if (next_index > num_active_cmds - event_coal_min)
+				next_index = num_active_cmds - event_coal_min;
+		}
 		if (!next_index)
 			next_index = 1;
 		cq_index = ep->qp.cqe_exp_seq_sn + next_index - 1;
@@ -170,6 +173,7 @@ void bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action)
 
 		cq_db->sqn[0] = cq_index;
 	}
+	return next_index;
 }
 
 
@@ -265,7 +269,7 @@ static void bnx2i_ring_sq_dbell(struct bnx2i_conn *bnx2i_conn, int count)
 	struct bnx2i_5771x_sq_rq_db *sq_db;
 	struct bnx2i_endpoint *ep = bnx2i_conn->ep;
 
-	ep->num_active_cmds++;
+	atomic_inc(&ep->num_active_cmds);
 	wmb();	/* flush SQ WQE memory before the doorbell is rung */
 	if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) {
 		sq_db = (struct bnx2i_5771x_sq_rq_db *) ep->qp.sq_pgtbl_virt;
@@ -1331,14 +1335,15 @@ int bnx2i_send_fw_iscsi_init_msg(struct bnx2i_hba *hba)
 
 /**
  * bnx2i_process_scsi_cmd_resp - this function handles scsi cmd completion.
- * @conn:	iscsi connection
+ * @session:	iscsi session
+ * @bnx2i_conn:	bnx2i connection
  * @cqe:	pointer to newly DMA'ed CQE entry for processing
  *
  * process SCSI CMD Response CQE & complete the request to SCSI-ML
  */
-static int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session,
-				       struct bnx2i_conn *bnx2i_conn,
-				       struct cqe *cqe)
+int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session,
+				struct bnx2i_conn *bnx2i_conn,
+				struct cqe *cqe)
 {
 	struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data;
 	struct bnx2i_cmd_response *resp_cqe;
@@ -1348,7 +1353,7 @@ static int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session,
 	u32 datalen = 0;
 
 	resp_cqe = (struct bnx2i_cmd_response *)cqe;
-	spin_lock(&session->lock);
+	spin_lock_bh(&session->lock);
 	task = iscsi_itt_to_task(conn,
 				 resp_cqe->itt & ISCSI_CMD_RESPONSE_INDEX);
 	if (!task)
@@ -1409,7 +1414,7 @@ done:
 	__iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr,
 			     conn->data, datalen);
 fail:
-	spin_unlock(&session->lock);
+	spin_unlock_bh(&session->lock);
 	return 0;
 }
 
@@ -1836,21 +1841,131 @@ static void bnx2i_process_cmd_cleanup_resp(struct iscsi_session *session,
 }
 
 
+/**
+ * bnx2i_percpu_io_thread - thread per cpu for ios
+ *
+ * @arg:	ptr to bnx2i_percpu_info structure
+ */
+int bnx2i_percpu_io_thread(void *arg)
+{
+	struct bnx2i_percpu_s *p = arg;
+	struct bnx2i_work *work, *tmp;
+	LIST_HEAD(work_list);
+
+	set_user_nice(current, -20);
+
+	set_current_state(TASK_INTERRUPTIBLE);
+	while (!kthread_should_stop()) {
+		schedule();
+		spin_lock_bh(&p->p_work_lock);
+		while (!list_empty(&p->work_list)) {
+			list_splice_init(&p->work_list, &work_list);
+			spin_unlock_bh(&p->p_work_lock);
+
+			list_for_each_entry_safe(work, tmp, &work_list, list) {
+				list_del_init(&work->list);
+				/* work allocated in the bh, freed here */
+				bnx2i_process_scsi_cmd_resp(work->session,
+							    work->bnx2i_conn,
+							    &work->cqe);
+				atomic_dec(&work->bnx2i_conn->work_cnt);
+				kfree(work);
+			}
+			spin_lock_bh(&p->p_work_lock);
+		}
+		set_current_state(TASK_INTERRUPTIBLE);
+		spin_unlock_bh(&p->p_work_lock);
+	}
+	__set_current_state(TASK_RUNNING);
+
+	return 0;
+}
+
+
+/**
+ * bnx2i_queue_scsi_cmd_resp - queue cmd completion to the percpu thread
+ * @bnx2i_conn:		bnx2i connection
+ *
+ * this function is called by generic KCQ handler to queue all pending cmd
+ * completion CQEs
+ *
+ * The implementation is to queue the cmd response based on the
+ * last recorded command for the given connection.  The
+ * cpu_id gets recorded upon task_xmit.  No out-of-order completion!
+ */
+static int bnx2i_queue_scsi_cmd_resp(struct iscsi_session *session,
+				     struct bnx2i_conn *bnx2i_conn,
+				     struct bnx2i_nop_in_msg *cqe)
+{
+	struct bnx2i_work *bnx2i_work = NULL;
+	struct bnx2i_percpu_s *p = NULL;
+	struct bnx2i_cmd *bnx2i_cmd;
+	struct iscsi_task *task;
+	int rc = 0;
+
+	spin_lock(&session->lock);
+	task = iscsi_itt_to_task(bnx2i_conn->cls_conn->dd_data,
+				 cqe->itt & ISCSI_CMD_RESPONSE_INDEX);
+	if (!task) {
+		spin_unlock(&session->lock);
+		return -EINVAL;
+	}
+	bnx2i_cmd = task->dd_data;
+	spin_unlock(&session->lock);
+
+	p = &per_cpu(bnx2i_percpu, bnx2i_cmd->cpu);
+	spin_lock(&p->p_work_lock);
+	if (unlikely(!p->iothread)) {
+		rc = -EINVAL;
+		goto err;
+	}
+	/* Alloc and copy to the cqe */
+	bnx2i_work = kzalloc(sizeof(struct bnx2i_work), GFP_ATOMIC);
+	if (bnx2i_work) {
+		INIT_LIST_HEAD(&bnx2i_work->list);
+		bnx2i_work->session = session;
+		bnx2i_work->bnx2i_conn = bnx2i_conn;
+		memcpy(&bnx2i_work->cqe, cqe, sizeof(struct cqe));
+		list_add_tail(&bnx2i_work->list, &p->work_list);
+		atomic_inc(&bnx2i_conn->work_cnt);
+		wake_up_process(p->iothread);
+		spin_unlock(&p->p_work_lock);
+		goto done;
+	} else
+		rc = -ENOMEM;
+err:
+	spin_unlock(&p->p_work_lock);
+	bnx2i_process_scsi_cmd_resp(session, bnx2i_conn, (struct cqe *)cqe);
+done:
+	return rc;
+}
+
 
 /**
  * bnx2i_process_new_cqes - process newly DMA'ed CQE's
- * @bnx2i_conn:		iscsi connection
+ * @bnx2i_conn:		bnx2i connection
  *
  * this function is called by generic KCQ handler to process all pending CQE's
  */
-static void bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
+static int bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
 {
 	struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data;
 	struct iscsi_session *session = conn->session;
-	struct qp_info *qp = &bnx2i_conn->ep->qp;
+	struct qp_info *qp;
 	struct bnx2i_nop_in_msg *nopin;
 	int tgt_async_msg;
+	int cqe_cnt = 0;
 
+	if (bnx2i_conn->ep == NULL)
+		return 0;
+
+	qp = &bnx2i_conn->ep->qp;
+
+	if (!qp->cq_virt) {
+		printk(KERN_ALERT "bnx2i (%s): cq resr freed in bh execution!",
+			bnx2i_conn->hba->netdev->name);
+		goto out;
+	}
 	while (1) {
 		nopin = (struct bnx2i_nop_in_msg *) qp->cq_cons_qe;
 		if (nopin->cq_req_sn != qp->cqe_exp_seq_sn)
@@ -1873,8 +1988,9 @@ static void bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
 		switch (nopin->op_code) {
 		case ISCSI_OP_SCSI_CMD_RSP:
 		case ISCSI_OP_SCSI_DATA_IN:
-			bnx2i_process_scsi_cmd_resp(session, bnx2i_conn,
-						    qp->cq_cons_qe);
+			/* Run the kthread engine only for data cmds
+			   All other cmds will be completed in this bh! */
+			bnx2i_queue_scsi_cmd_resp(session, bnx2i_conn, nopin);
 			break;
 		case ISCSI_OP_LOGIN_RSP:
 			bnx2i_process_login_resp(session, bnx2i_conn,
@@ -1918,13 +2034,21 @@ static void bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
 			printk(KERN_ALERT "bnx2i: unknown opcode 0x%x\n",
 					  nopin->op_code);
 		}
-		if (!tgt_async_msg)
-			bnx2i_conn->ep->num_active_cmds--;
+		if (!tgt_async_msg) {
+			if (!atomic_read(&bnx2i_conn->ep->num_active_cmds))
+				printk(KERN_ALERT "bnx2i (%s): no active cmd! "
+				       "op 0x%x\n",
+				       bnx2i_conn->hba->netdev->name,
+				       nopin->op_code);
+			else
+				atomic_dec(&bnx2i_conn->ep->num_active_cmds);
+		}
 cqe_out:
 		/* clear out in production version only, till beta keep opcode
 		 * field intact, will be helpful in debugging (context dump)
 		 * nopin->op_code = 0;
 		 */
+		cqe_cnt++;
 		qp->cqe_exp_seq_sn++;
 		if (qp->cqe_exp_seq_sn == (qp->cqe_size * 2 + 1))
 			qp->cqe_exp_seq_sn = ISCSI_INITIAL_SN;
@@ -1937,6 +2061,8 @@ cqe_out:
 			qp->cq_cons_idx++;
 		}
 	}
+out:
+	return cqe_cnt;
 }
 
 /**
@@ -1952,6 +2078,7 @@ static void bnx2i_fastpath_notification(struct bnx2i_hba *hba,
 {
 	struct bnx2i_conn *bnx2i_conn;
 	u32 iscsi_cid;
+	int nxt_idx;
 
 	iscsi_cid = new_cqe_kcqe->iscsi_conn_id;
 	bnx2i_conn = bnx2i_get_conn_from_id(hba, iscsi_cid);
@@ -1964,9 +2091,12 @@ static void bnx2i_fastpath_notification(struct bnx2i_hba *hba,
 		printk(KERN_ALERT "cid #%x - ep not bound\n", iscsi_cid);
 		return;
 	}
+
 	bnx2i_process_new_cqes(bnx2i_conn);
-	bnx2i_arm_cq_event_coalescing(bnx2i_conn->ep, CNIC_ARM_CQE_FP);
-	bnx2i_process_new_cqes(bnx2i_conn);
+	nxt_idx = bnx2i_arm_cq_event_coalescing(bnx2i_conn->ep,
+						CNIC_ARM_CQE_FP);
+	if (nxt_idx && nxt_idx == bnx2i_process_new_cqes(bnx2i_conn))
+		bnx2i_arm_cq_event_coalescing(bnx2i_conn->ep, CNIC_ARM_CQE_FP);
 }
 
 
@@ -2312,7 +2442,7 @@ static void bnx2i_process_ofld_cmpl(struct bnx2i_hba *hba,
 			printk(KERN_ALERT "bnx2i (%s): ofld1 cmpl - invalid "
 				"opcode\n", hba->netdev->name);
 		else if (ofld_kcqe->completion_status ==
-			ISCSI_KCQE_COMPLETION_STATUS_CID_BUSY)
+			 ISCSI_KCQE_COMPLETION_STATUS_CID_BUSY)
 			/* error status code valid only for 5771x chipset */
 			ep->state = EP_STATE_OFLD_FAILED_CID_BUSY;
 		else
@@ -2511,7 +2641,7 @@ static void bnx2i_cm_remote_abort(struct cnic_sock *cm_sk)
 
 
 static int bnx2i_send_nl_mesg(void *context, u32 msg_type,
-			       char *buf, u16 buflen)
+			      char *buf, u16 buflen)
 {
 	struct bnx2i_hba *hba = context;
 	int rc;
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 6adbdc3..0f7fb14 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -40,7 +40,7 @@ unsigned int event_coal_min = 24;
 module_param(event_coal_min, int, 0664);
 MODULE_PARM_DESC(event_coal_min, "Event Coalescing Minimum Commands");
 
-unsigned int event_coal_div = 1;
+unsigned int event_coal_div = 2;
 module_param(event_coal_div, int, 0664);
 MODULE_PARM_DESC(event_coal_div, "Event Coalescing Divide Factor");
 
@@ -66,6 +66,15 @@ MODULE_PARM_DESC(rq_size, "Configure RQ size");
 
 u64 iscsi_error_mask = 0x00;
 
+DEFINE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu);
+
+static int bnx2i_cpu_callback(struct notifier_block *nfb,
+			      unsigned long action, void *hcpu);
+/* notification function for CPU hotplug events */
+static struct notifier_block bnx2i_cpu_notifier = {
+	.notifier_call = bnx2i_cpu_callback,
+};
+
 
 /**
  * bnx2i_identify_device - identifies NetXtreme II device type
@@ -362,6 +371,91 @@ void bnx2i_ulp_exit(struct cnic_dev *dev)
 
 
 /**
+ * bnx2i_percpu_thread_create - Create a receive thread for an
+ *				online CPU
+ *
+ * @cpu:	cpu index for the online cpu
+ */
+static void bnx2i_percpu_thread_create(unsigned int cpu)
+{
+	struct bnx2i_percpu_s *p;
+	struct task_struct *thread;
+
+	p = &per_cpu(bnx2i_percpu, cpu);
+
+	thread = kthread_create(bnx2i_percpu_io_thread, (void *)p,
+				"bnx2i_thread/%d", cpu);
+	/* bind thread to the cpu */
+	if (likely(!IS_ERR(thread))) {
+		kthread_bind(thread, cpu);
+		p->iothread = thread;
+		wake_up_process(thread);
+	}
+}
+
+
+static void bnx2i_percpu_thread_destroy(unsigned int cpu)
+{
+	struct bnx2i_percpu_s *p;
+	struct task_struct *thread;
+	struct bnx2i_work *work, *tmp;
+
+	/* Prevent any new work from being queued for this CPU */
+	p = &per_cpu(bnx2i_percpu, cpu);
+	spin_lock_bh(&p->p_work_lock);
+	thread = p->iothread;
+	p->iothread = NULL;
+
+	/* Free all work in the list */
+	list_for_each_entry_safe(work, tmp, &p->work_list, list) {
+		list_del_init(&work->list);
+		bnx2i_process_scsi_cmd_resp(work->session,
+					    work->bnx2i_conn, &work->cqe);
+		kfree(work);
+	}
+
+	spin_unlock_bh(&p->p_work_lock);
+	if (thread)
+		kthread_stop(thread);
+}
+
+
+/**
+ * bnx2i_cpu_callback - Handler for CPU hotplug events
+ *
+ * @nfb:	The callback data block
+ * @action:	The event triggering the callback
+ * @hcpu:	The index of the CPU that the event is for
+ *
+ * This creates or destroys per-CPU data for iSCSI
+ *
+ * Returns NOTIFY_OK always.
+ */
+static int bnx2i_cpu_callback(struct notifier_block *nfb,
+			      unsigned long action, void *hcpu)
+{
+	unsigned cpu = (unsigned long)hcpu;
+
+	switch (action) {
+	case CPU_ONLINE:
+	case CPU_ONLINE_FROZEN:
+		printk(KERN_INFO "bnx2i: CPU %x online: Create Rx thread\n",
+			cpu);
+		bnx2i_percpu_thread_create(cpu);
+		break;
+	case CPU_DEAD:
+	case CPU_DEAD_FROZEN:
+		printk(KERN_INFO "CPU %x offline: Remove Rx thread\n", cpu);
+		bnx2i_percpu_thread_destroy(cpu);
+		break;
+	default:
+		break;
+	}
+	return NOTIFY_OK;
+}
+
+
+/**
  * bnx2i_mod_init - module init entry point
  *
  * initialize any driver wide global data structures such as endpoint pool,
@@ -371,6 +465,8 @@ void bnx2i_ulp_exit(struct cnic_dev *dev)
 static int __init bnx2i_mod_init(void)
 {
 	int err;
+	unsigned cpu = 0;
+	struct bnx2i_percpu_s *p;
 
 	printk(KERN_INFO "%s", version);
 
@@ -393,6 +489,20 @@ static int __init bnx2i_mod_init(void)
 		goto unreg_xport;
 	}
 
+	/* Create percpu kernel threads to handle iSCSI I/O completions */
+	for_each_possible_cpu(cpu) {
+		p = &per_cpu(bnx2i_percpu, cpu);
+		INIT_LIST_HEAD(&p->work_list);
+		spin_lock_init(&p->p_work_lock);
+		p->iothread = NULL;
+	}
+
+	for_each_online_cpu(cpu)
+		bnx2i_percpu_thread_create(cpu);
+
+	/* Initialize per CPU interrupt thread */
+	register_hotcpu_notifier(&bnx2i_cpu_notifier);
+
 	return 0;
 
 unreg_xport:
@@ -413,6 +523,7 @@ out:
 static void __exit bnx2i_mod_exit(void)
 {
 	struct bnx2i_hba *hba;
+	unsigned cpu = 0;
 
 	mutex_lock(&bnx2i_dev_lock);
 	while (!list_empty(&adapter_list)) {
@@ -430,6 +541,11 @@ static void __exit bnx2i_mod_exit(void)
 	}
 	mutex_unlock(&bnx2i_dev_lock);
 
+	unregister_hotcpu_notifier(&bnx2i_cpu_notifier);
+
+	for_each_online_cpu(cpu)
+		bnx2i_percpu_thread_destroy(cpu);
+
 	iscsi_unregister_transport(&bnx2i_iscsi_transport);
 	cnic_unregister_driver(CNIC_ULP_ISCSI);
 }
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 041928b..c095c32 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -27,6 +27,7 @@ static struct scsi_host_template bnx2i_host_template;
  */
 static DEFINE_SPINLOCK(bnx2i_resc_lock); /* protects global resources */
 
+DECLARE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu);
 
 static int bnx2i_adapter_ready(struct bnx2i_hba *hba)
 {
@@ -1213,10 +1214,16 @@ static int bnx2i_task_xmit(struct iscsi_task *task)
 	struct scsi_cmnd *sc = task->sc;
 	struct bnx2i_cmd *cmd = task->dd_data;
 	struct iscsi_cmd *hdr = (struct iscsi_cmd *) task->hdr;
+	u32 cpu;
 
-	if (bnx2i_conn->ep->num_active_cmds + 1 > hba->max_sqes)
+	if (atomic_read(&bnx2i_conn->ep->num_active_cmds) + 1  >
+	    hba->max_sqes)
 		return -ENOMEM;
 
+	cpu = get_cpu();
+	put_cpu();
+	cmd->cpu = cpu;
+
 	/*
 	 * If there is no scsi_cmnd this must be a mgmt task
 	 */
@@ -1354,6 +1361,9 @@ bnx2i_conn_create(struct iscsi_cls_session *cls_session, uint32_t cid)
 	bnx2i_conn = conn->dd_data;
 	bnx2i_conn->cls_conn = cls_conn;
 	bnx2i_conn->hba = hba;
+
+	atomic_set(&bnx2i_conn->work_cnt, 0);
+
 	/* 'ep' ptr will be assigned in bind() call */
 	bnx2i_conn->ep = NULL;
 	init_completion(&bnx2i_conn->cmd_cleanup_cmpl);
@@ -1457,11 +1467,34 @@ static void bnx2i_conn_destroy(struct iscsi_cls_conn *cls_conn)
 	struct bnx2i_conn *bnx2i_conn = conn->dd_data;
 	struct Scsi_Host *shost;
 	struct bnx2i_hba *hba;
+	struct bnx2i_work *work, *tmp;
+	unsigned cpu = 0;
+	struct bnx2i_percpu_s *p;
 
 	shost = iscsi_session_to_shost(iscsi_conn_to_session(cls_conn));
 	hba = iscsi_host_priv(shost);
 
 	bnx2i_conn_free_login_resources(hba, bnx2i_conn);
+
+	if (atomic_read(&bnx2i_conn->work_cnt)) {
+		for_each_online_cpu(cpu) {
+			p = &per_cpu(bnx2i_percpu, cpu);
+			spin_lock_bh(&p->p_work_lock);
+			list_for_each_entry_safe(work, tmp,
+						 &p->work_list, list) {
+				if (work->session == conn->session &&
+				    work->bnx2i_conn == bnx2i_conn) {
+					list_del_init(&work->list);
+					kfree(work);
+					if (!atomic_dec_and_test(
+							&bnx2i_conn->work_cnt))
+						break;
+				}
+			}
+			spin_unlock_bh(&p->p_work_lock);
+		}
+	}
+
 	iscsi_conn_teardown(cls_conn);
 }
 
@@ -1769,7 +1802,7 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	}
 	bnx2i_ep = ep->dd_data;
 
-	bnx2i_ep->num_active_cmds = 0;
+	atomic_set(&bnx2i_ep->num_active_cmds, 0);
 	iscsi_cid = bnx2i_alloc_iscsi_cid(hba);
 	if (iscsi_cid == -1) {
 		printk(KERN_ALERT "bnx2i (%s): alloc_ep - unable to allocate "
@@ -2163,9 +2196,9 @@ static struct scsi_host_template bnx2i_host_template = {
 	.eh_device_reset_handler = iscsi_eh_device_reset,
 	.eh_target_reset_handler = iscsi_eh_recover_target,
 	.change_queue_depth	= iscsi_change_queue_depth,
-	.can_queue		= 1024,
+	.can_queue		= 2048,
 	.max_sectors		= 127,
-	.cmd_per_lun		= 24,
+	.cmd_per_lun		= 128,
 	.this_id		= -1,
 	.use_clustering		= ENABLE_CLUSTERING,
 	.sg_tablesize		= ISCSI_MAX_BDS_PER_CMD,
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 2/4] BNX2I: Modified to skip CNIC registration if iSCSI is not supported
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (86 preceding siblings ...)
  2011-06-21 16:49 ` [PATCH 1/4] BNX2I: Added the use of kthreads to handle SCSI cmd completion Eddie Wai
@ 2011-06-21 16:49 ` Eddie Wai
  2011-06-21 16:49 ` [PATCH 3/4] BNX2I: Changed the nopout_wqe->lun memcpy to use sizeof instead Eddie Wai
                   ` (21 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-06-21 16:49 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The init routine will now examine the cnic->max_iscsi_conn variable
before registering to CNIC during ulp_init.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Michael Chan <mchan@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_init.c |   29 +++++++++++++++--------------
 1 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 0f7fb14..28bfa9e 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -172,21 +172,14 @@ void bnx2i_start(void *handle)
 	struct bnx2i_hba *hba = handle;
 	int i = HZ;
 
-	if (!hba->cnic->max_iscsi_conn) {
-		printk(KERN_ALERT "bnx2i: dev %s does not support "
-			"iSCSI\n", hba->netdev->name);
+	/*
+	 * We should never register devices that don't support iSCSI
+	 * (see bnx2i_init_one), so something is wrong if we try to
+	 * start a iSCSI adapter on hardware with 0 supported iSCSI
+	 * connections
+	 */
+	BUG_ON(!hba->cnic->max_iscsi_conn);
 
-		if (test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic)) {
-			mutex_lock(&bnx2i_dev_lock);
-			list_del_init(&hba->link);
-			adapter_count--;
-			hba->cnic->unregister_device(hba->cnic, CNIC_ULP_ISCSI);
-			clear_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic);
-			mutex_unlock(&bnx2i_dev_lock);
-			bnx2i_free_hba(hba);
-		}
-		return;
-	}
 	bnx2i_send_fw_iscsi_init_msg(hba);
 	while (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state) && i--)
 		msleep(BNX2I_INIT_POLL_TIME);
@@ -290,6 +283,13 @@ static int bnx2i_init_one(struct bnx2i_hba *hba, struct cnic_dev *cnic)
 	int rc;
 
 	mutex_lock(&bnx2i_dev_lock);
+	if (!cnic->max_iscsi_conn) {
+		printk(KERN_ALERT "bnx2i: dev %s does not support "
+			"iSCSI\n", hba->netdev->name);
+		rc = -EOPNOTSUPP;
+		goto out;
+	}
+
 	hba->cnic = cnic;
 	rc = cnic->register_device(cnic, CNIC_ULP_ISCSI, hba);
 	if (!rc) {
@@ -307,6 +307,7 @@ static int bnx2i_init_one(struct bnx2i_hba *hba, struct cnic_dev *cnic)
 	else
 		printk(KERN_ERR "bnx2i dev reg, unknown error, %d\n", rc);
 
+out:
 	mutex_unlock(&bnx2i_dev_lock);
 
 	return rc;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 3/4] BNX2I: Changed the nopout_wqe->lun memcpy to use sizeof instead
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (87 preceding siblings ...)
  2011-06-21 16:49 ` [PATCH 2/4] BNX2I: Modified to skip CNIC registration if iSCSI is not supported Eddie Wai
@ 2011-06-21 16:49 ` Eddie Wai
  2011-06-22  8:00   ` Rolf Eike Beer
  2011-06-21 16:49 ` [PATCH 4/4] BNX2I: Updated copyright and bump version Eddie Wai
                   ` (20 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2011-06-21 16:49 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Modified the memcpy of nopout_wqe->lun to use sizeof(struct scsi_lun)
instead of the hardcoded value 8 as noted by review comments.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 64089e2..d5f3bf6 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -551,7 +551,7 @@ int bnx2i_send_iscsi_nopout(struct bnx2i_conn *bnx2i_conn,
 
 	nopout_wqe->op_code = nopout_hdr->opcode;
 	nopout_wqe->op_attr = ISCSI_FLAG_CMD_FINAL;
-	memcpy(nopout_wqe->lun, nopout_hdr->lun, 8);
+	memcpy(nopout_wqe->lun, nopout_hdr->lun, sizeof(struct scsi_lun));
 
 	if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) {
 		u32 tmp = nopout_wqe->lun[0];
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 4/4] BNX2I: Updated copyright and bump version
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (88 preceding siblings ...)
  2011-06-21 16:49 ` [PATCH 3/4] BNX2I: Changed the nopout_wqe->lun memcpy to use sizeof instead Eddie Wai
@ 2011-06-21 16:49 ` Eddie Wai
  2011-06-23 22:51 ` [PATCH 0/4 v2] BNX2I: Code and performance optimization Eddie Wai
                   ` (19 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-06-21 16:49 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Bumped version from 2.6.2.3 to 2.7.0.3

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/57xx_iscsi_constants.h |    2 +-
 drivers/scsi/bnx2i/57xx_iscsi_hsi.h       |    2 +-
 drivers/scsi/bnx2i/bnx2i.h                |    2 +-
 drivers/scsi/bnx2i/bnx2i_hwi.c            |    2 +-
 drivers/scsi/bnx2i/bnx2i_init.c           |    6 +++---
 drivers/scsi/bnx2i/bnx2i_iscsi.c          |    2 +-
 drivers/scsi/bnx2i/bnx2i_sysfs.c          |    2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/bnx2i/57xx_iscsi_constants.h b/drivers/scsi/bnx2i/57xx_iscsi_constants.h
index 30e6bdb..aca593d 100644
--- a/drivers/scsi/bnx2i/57xx_iscsi_constants.h
+++ b/drivers/scsi/bnx2i/57xx_iscsi_constants.h
@@ -1,6 +1,6 @@
 /* 57xx_iscsi_constants.h: Broadcom NetXtreme II iSCSI HSI
  *
- * Copyright (c) 2006 - 2010 Broadcom Corporation
+ * Copyright (c) 2006 - 2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/bnx2i/57xx_iscsi_hsi.h b/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
index dad6c8a..1c39177 100644
--- a/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
+++ b/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
@@ -1,6 +1,6 @@
 /* 57xx_iscsi_hsi.h: Broadcom NetXtreme II iSCSI HSI.
  *
- * Copyright (c) 2006 - 2010 Broadcom Corporation
+ * Copyright (c) 2006 - 2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 4e5c002..bb21450 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -1,6 +1,6 @@
 /* bnx2i.h: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2010 Broadcom Corporation
+ * Copyright (c) 2006 - 2011 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index d5f3bf6..a031704 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1,6 +1,6 @@
 /* bnx2i_hwi.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2010 Broadcom Corporation
+ * Copyright (c) 2006 - 2011 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 28bfa9e..4f252a9 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -1,6 +1,6 @@
 /* bnx2i.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2010 Broadcom Corporation
+ * Copyright (c) 2006 - 2011 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
@@ -18,8 +18,8 @@ static struct list_head adapter_list = LIST_HEAD_INIT(adapter_list);
 static u32 adapter_count;
 
 #define DRV_MODULE_NAME		"bnx2i"
-#define DRV_MODULE_VERSION	"2.6.2.3"
-#define DRV_MODULE_RELDATE	"Dec 31, 2010"
+#define DRV_MODULE_VERSION	"2.7.0.3"
+#define DRV_MODULE_RELDATE	"Jun 15, 2011"
 
 static char version[] __devinitdata =
 		"Broadcom NetXtreme II iSCSI Driver " DRV_MODULE_NAME \
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index c095c32..f92ec95 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1,7 +1,7 @@
 /*
  * bnx2i_iscsi.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2010 Broadcom Corporation
+ * Copyright (c) 2006 - 2011 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
diff --git a/drivers/scsi/bnx2i/bnx2i_sysfs.c b/drivers/scsi/bnx2i/bnx2i_sysfs.c
index 9174196..83a77f7 100644
--- a/drivers/scsi/bnx2i/bnx2i_sysfs.c
+++ b/drivers/scsi/bnx2i/bnx2i_sysfs.c
@@ -1,6 +1,6 @@
 /* bnx2i_sysfs.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2004 - 2010 Broadcom Corporation
+ * Copyright (c) 2004 - 2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH 1/4] BNX2I: Added the use of kthreads to handle SCSI cmd completion
  2011-06-21 16:49 ` [PATCH 1/4] BNX2I: Added the use of kthreads to handle SCSI cmd completion Eddie Wai
@ 2011-06-22  2:54   ` Mike Christie
  2011-06-22  6:46     ` Eddie Wai
  0 siblings, 1 reply; 189+ messages in thread
From: Mike Christie @ 2011-06-22  2:54 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 06/21/2011 11:49 AM, Eddie Wai wrote:
> This patch breaks the SCSI cmd completion into two parts:
> 1. The bh will allocate and queued work to the cmd specific CPU IO
> completion kthread.  The CPU for the cmd is recorded in task_xmit.
> 
> 2. The CPU specific IO completion kthread will call the scsi_cmd_resp
> routine to do the actual cmd completion.


I think you should use blkio poll. Modify it so it does what you want.
But I think since other drivers are getting in without converting then
that can wait.


>  struct bnx2i_cmd {
>  	struct iscsi_hdr hdr;
> @@ -215,6 +222,7 @@ struct bnx2i_cmd {
>  	struct io_bdt io_tbl;
>  	dma_addr_t bd_tbl_dma;
>  	struct bnx2i_cmd_request req;
> +	u32 cpu;


You can just use scsi_cmnd->request->cpu

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 1/4] BNX2I: Added the use of kthreads to handle SCSI cmd completion
  2011-06-22  2:54   ` Mike Christie
@ 2011-06-22  6:46     ` Eddie Wai
  0 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-06-22  6:46 UTC (permalink / raw)
  To: open-iscsi
  Cc: James Bottomley, linux-scsi, Michael Chan, Anil Veerabhadrappa,
	Benjamin Li


On Tue, 2011-06-21 at 19:54 -0700, Mike Christie wrote:
> On 06/21/2011 11:49 AM, Eddie Wai wrote:
> > This patch breaks the SCSI cmd completion into two parts:
> > 1. The bh will allocate and queued work to the cmd specific CPU IO
> > completion kthread.  The CPU for the cmd is recorded in task_xmit.
> > 
> > 2. The CPU specific IO completion kthread will call the scsi_cmd_resp
> > routine to do the actual cmd completion.
> 
> 
> I think you should use blkio poll. Modify it so it does what you want.
> But I think since other drivers are getting in without converting then
> that can wait.
Noted.  I will revisit this later then.
> 
> 
> >  struct bnx2i_cmd {
> >  	struct iscsi_hdr hdr;
> > @@ -215,6 +222,7 @@ struct bnx2i_cmd {
> >  	struct io_bdt io_tbl;
> >  	dma_addr_t bd_tbl_dma;
> >  	struct bnx2i_cmd_request req;
> > +	u32 cpu;
> 
> 
> You can just use scsi_cmnd->request->cpu
Ok, I'll make the change to use this instead of grabbing the cpu
explicitly in our driver.
> 



^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 3/4] BNX2I: Changed the nopout_wqe->lun memcpy to use sizeof instead
  2011-06-21 16:49 ` [PATCH 3/4] BNX2I: Changed the nopout_wqe->lun memcpy to use sizeof instead Eddie Wai
@ 2011-06-22  8:00   ` Rolf Eike Beer
  0 siblings, 0 replies; 189+ messages in thread
From: Rolf Eike Beer @ 2011-06-22  8:00 UTC (permalink / raw)
  Cc: James Bottomley, Mike Christie, open-iscsi, linux-scsi,
	Michael Chan, Anil Veerabhadrappa, Ben Li, Eddie Wai

> Modified the memcpy of nopout_wqe->lun to use sizeof(struct scsi_lun)
> instead of the hardcoded value 8 as noted by review comments.
>
> Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
> ---
>  drivers/scsi/bnx2i/bnx2i_hwi.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c
> b/drivers/scsi/bnx2i/bnx2i_hwi.c
> index 64089e2..d5f3bf6 100644
> --- a/drivers/scsi/bnx2i/bnx2i_hwi.c
> +++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
> @@ -551,7 +551,7 @@ int bnx2i_send_iscsi_nopout(struct bnx2i_conn
> *bnx2i_conn,
>
>  	nopout_wqe->op_code = nopout_hdr->opcode;
>  	nopout_wqe->op_attr = ISCSI_FLAG_CMD_FINAL;
> -	memcpy(nopout_wqe->lun, nopout_hdr->lun, 8);
> +	memcpy(nopout_wqe->lun, nopout_hdr->lun, sizeof(struct scsi_lun));
>
>  	if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) {
>  		u32 tmp = nopout_wqe->lun[0];

Why not just use sizeof(*nopout_wqe->lun)?

Eike

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 0/4 v2] BNX2I: Code and performance optimization
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (89 preceding siblings ...)
  2011-06-21 16:49 ` [PATCH 4/4] BNX2I: Updated copyright and bump version Eddie Wai
@ 2011-06-23 22:51 ` Eddie Wai
  2011-06-23 22:51 ` [PATCH 1/4 v2] BNX2I: Added the use of kthreads to handle SCSI cmd completion Eddie Wai
                   ` (18 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-06-23 22:51 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

This patch set contains a collection of code and performance optimization
changes.

Changes from v2:
- Comments from Mike Christie to use sc->request->cpu instead of the newly
defined bnx2i_cmd->cpu
- Comments from Fubo Chen to process the work in the percpu io completion
kthread before calling schedule() to avoid potential race condition.

Your comments are welcome.  Please review.

Thanks,
Eddie

Eddie Wai (4):
  BNX2I: Added the use of kthreads to handle SCSI cmd completion
  BNX2I: Modified to skip CNIC registration if iSCSI is not supported
  BNX2I: Changed the nopout_wqe->lun memcpy to use sizeof instead
  BNX2I: Updated copyright and bump version

 drivers/scsi/bnx2i/57xx_iscsi_constants.h |    2 +-
 drivers/scsi/bnx2i/57xx_iscsi_hsi.h       |    2 +-
 drivers/scsi/bnx2i/bnx2i.h                |   33 +++++-
 drivers/scsi/bnx2i/bnx2i_hwi.c            |  187 ++++++++++++++++++++++++-----
 drivers/scsi/bnx2i/bnx2i_init.c           |  153 +++++++++++++++++++++---
 drivers/scsi/bnx2i/bnx2i_iscsi.c          |   38 +++++-
 drivers/scsi/bnx2i/bnx2i_sysfs.c          |    2 +-
 7 files changed, 358 insertions(+), 59 deletions(-)



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 1/4 v2] BNX2I: Added the use of kthreads to handle SCSI cmd completion
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (90 preceding siblings ...)
  2011-06-23 22:51 ` [PATCH 0/4 v2] BNX2I: Code and performance optimization Eddie Wai
@ 2011-06-23 22:51 ` Eddie Wai
  2011-06-23 22:51 ` [PATCH 2/4 v2] BNX2I: Modified to skip CNIC registration if iSCSI is not supported Eddie Wai
                   ` (17 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-06-23 22:51 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

This patch breaks the SCSI cmd completion into two parts:
1. The bh will allocate and queued work to the cmd specific CPU IO
completion kthread.  The CPU for the cmd is from the sc->request->cpu.

2. The CPU specific IO completion kthread will call the scsi_cmd_resp
routine to do the actual cmd completion.

In the normal case, these IO completion kthreads should complete before
the blk IO times out at 60s.  However, in the case when these kthreads
are blocked for whatever reason and exceeded the timeout, the call
to conn_destroy will have to iterate and exhaust all related work in the
percpu work list for all online CPUs.  This will guarantee the protection
of the work->session and conn pointers before they get freed.

Also modified the event coalescing formula to have at least the
event_coal_min outstanding cmds in the pipeline so the SCSI producer
would not get underrun.

Also changed the following SCSI parameters:
- can_queue from 1024 to 2048
- cmds_per_lun from 24 to 128

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Benjamin Li <benli@broadcom.com>
Acked-by: Michael Chan <mchan@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |   31 ++++++-
 drivers/scsi/bnx2i/bnx2i_hwi.c   |  183 ++++++++++++++++++++++++++++++++------
 drivers/scsi/bnx2i/bnx2i_init.c  |  118 ++++++++++++++++++++++++-
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   36 +++++++-
 4 files changed, 333 insertions(+), 35 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 6bdd25a..239bc4e 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -22,11 +22,14 @@
 #include <linux/pci.h>
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
+#include <linux/delay.h>
 #include <linux/sched.h>
 #include <linux/in.h>
 #include <linux/kfifo.h>
 #include <linux/netdevice.h>
 #include <linux/completion.h>
+#include <linux/kthread.h>
+#include <linux/cpu.h>
 
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_device.h>
@@ -202,10 +205,13 @@ struct io_bdt {
 /**
  * bnx2i_cmd - iscsi command structure
  *
+ * @hdr:                iSCSI header
+ * @conn:               iscsi_conn pointer
  * @scsi_cmd:           SCSI-ML task pointer corresponding to this iscsi cmd
  * @sg:                 SG list
  * @io_tbl:             buffer descriptor (BD) table
  * @bd_tbl_dma:         buffer descriptor (BD) table's dma address
+ * @req:                bnx2i specific command request struct
  */
 struct bnx2i_cmd {
 	struct iscsi_hdr hdr;
@@ -229,6 +235,7 @@ struct bnx2i_cmd {
  * @gen_pdu:               login/nopout/logout pdu resources
  * @violation_notified:    bit mask used to track iscsi error/warning messages
  *                         already printed out
+ * @work_cnt:              keeps track of the number of outstanding work
  *
  * iSCSI connection structure
  */
@@ -252,6 +259,8 @@ struct bnx2i_conn {
 	 */
 	struct generic_pdu_resc gen_pdu;
 	u64 violation_notified;
+
+	atomic_t work_cnt;
 };
 
 
@@ -661,7 +670,6 @@ enum {
  * @hba:                adapter to which this connection belongs
  * @conn:               iscsi connection this EP is linked to
  * @cls_ep:             associated iSCSI endpoint pointer
- * @sess:               iscsi session this EP is linked to
  * @cm_sk:              cnic sock struct
  * @hba_age:            age to detect if 'iscsid' issues ep_disconnect()
  *                      after HBA reset is completed by bnx2i/cnic/bnx2
@@ -687,7 +695,7 @@ struct bnx2i_endpoint {
 	u32 hba_age;
 	u32 state;
 	unsigned long timestamp;
-	int num_active_cmds;
+	atomic_t num_active_cmds;
 	u32 ec_shift;
 
 	struct qp_info qp;
@@ -700,6 +708,19 @@ struct bnx2i_endpoint {
 };
 
 
+struct bnx2i_work {
+	struct list_head list;
+	struct iscsi_session *session;
+	struct bnx2i_conn *bnx2i_conn;
+	struct cqe cqe;
+};
+
+struct bnx2i_percpu_s {
+	struct task_struct *iothread;
+	struct list_head work_list;
+	spinlock_t p_work_lock;
+};
+
 
 /* Global variables */
 extern unsigned int error_mask1, error_mask2;
@@ -783,7 +804,7 @@ extern struct bnx2i_endpoint *bnx2i_find_ep_in_destroy_list(
 		struct bnx2i_hba *hba, u32 iscsi_cid);
 
 extern int bnx2i_map_ep_dbell_regs(struct bnx2i_endpoint *ep);
-extern void bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action);
+extern int bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action);
 
 extern int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep);
 
@@ -793,4 +814,8 @@ extern void bnx2i_print_active_cmd_queue(struct bnx2i_conn *conn);
 extern void bnx2i_print_xmit_pdu_queue(struct bnx2i_conn *conn);
 extern void bnx2i_print_recv_state(struct bnx2i_conn *conn);
 
+extern int bnx2i_percpu_io_thread(void *arg);
+extern int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session,
+				       struct bnx2i_conn *bnx2i_conn,
+				       struct cqe *cqe);
 #endif
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 5c54a2d..2a1bb9f 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -17,6 +17,8 @@
 #include <scsi/libiscsi.h>
 #include "bnx2i.h"
 
+DECLARE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu);
+
 /**
  * bnx2i_get_cid_num - get cid from ep
  * @ep: 	endpoint pointer
@@ -131,16 +133,16 @@ static void bnx2i_iscsi_license_error(struct bnx2i_hba *hba, u32 error_code)
  *	the driver. EQ event is generated CQ index is hit or at least 1 CQ is
  *	outstanding and on chip timer expires
  */
-void bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action)
+int bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action)
 {
 	struct bnx2i_5771x_cq_db *cq_db;
 	u16 cq_index;
-	u16 next_index;
+	u16 next_index = 0;
 	u32 num_active_cmds;
 
 	/* Coalesce CQ entries only on 10G devices */
 	if (!test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type))
-		return;
+		return 0;
 
 	/* Do not update CQ DB multiple times before firmware writes
 	 * '0xFFFF' to CQDB->SQN field. Deviation may cause spurious
@@ -150,16 +152,17 @@ void bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action)
 
 	if (action != CNIC_ARM_CQE_FP)
 		if (cq_db->sqn[0] && cq_db->sqn[0] != 0xFFFF)
-			return;
+			return 0;
 
 	if (action == CNIC_ARM_CQE || action == CNIC_ARM_CQE_FP) {
-		num_active_cmds = ep->num_active_cmds;
+		num_active_cmds = atomic_read(&ep->num_active_cmds);
 		if (num_active_cmds <= event_coal_min)
 			next_index = 1;
-		else
-			next_index = event_coal_min +
-				     ((num_active_cmds - event_coal_min) >>
-				     ep->ec_shift);
+		else {
+			next_index = num_active_cmds >> ep->ec_shift;
+			if (next_index > num_active_cmds - event_coal_min)
+				next_index = num_active_cmds - event_coal_min;
+		}
 		if (!next_index)
 			next_index = 1;
 		cq_index = ep->qp.cqe_exp_seq_sn + next_index - 1;
@@ -170,6 +173,7 @@ void bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action)
 
 		cq_db->sqn[0] = cq_index;
 	}
+	return next_index;
 }
 
 
@@ -265,7 +269,7 @@ static void bnx2i_ring_sq_dbell(struct bnx2i_conn *bnx2i_conn, int count)
 	struct bnx2i_5771x_sq_rq_db *sq_db;
 	struct bnx2i_endpoint *ep = bnx2i_conn->ep;
 
-	ep->num_active_cmds++;
+	atomic_inc(&ep->num_active_cmds);
 	wmb();	/* flush SQ WQE memory before the doorbell is rung */
 	if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) {
 		sq_db = (struct bnx2i_5771x_sq_rq_db *) ep->qp.sq_pgtbl_virt;
@@ -1331,14 +1335,15 @@ int bnx2i_send_fw_iscsi_init_msg(struct bnx2i_hba *hba)
 
 /**
  * bnx2i_process_scsi_cmd_resp - this function handles scsi cmd completion.
- * @conn:	iscsi connection
+ * @session:	iscsi session
+ * @bnx2i_conn:	bnx2i connection
  * @cqe:	pointer to newly DMA'ed CQE entry for processing
  *
  * process SCSI CMD Response CQE & complete the request to SCSI-ML
  */
-static int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session,
-				       struct bnx2i_conn *bnx2i_conn,
-				       struct cqe *cqe)
+int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session,
+				struct bnx2i_conn *bnx2i_conn,
+				struct cqe *cqe)
 {
 	struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data;
 	struct bnx2i_cmd_response *resp_cqe;
@@ -1348,7 +1353,7 @@ static int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session,
 	u32 datalen = 0;
 
 	resp_cqe = (struct bnx2i_cmd_response *)cqe;
-	spin_lock(&session->lock);
+	spin_lock_bh(&session->lock);
 	task = iscsi_itt_to_task(conn,
 				 resp_cqe->itt & ISCSI_CMD_RESPONSE_INDEX);
 	if (!task)
@@ -1409,7 +1414,7 @@ done:
 	__iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr,
 			     conn->data, datalen);
 fail:
-	spin_unlock(&session->lock);
+	spin_unlock_bh(&session->lock);
 	return 0;
 }
 
@@ -1836,21 +1841,130 @@ static void bnx2i_process_cmd_cleanup_resp(struct iscsi_session *session,
 }
 
 
+/**
+ * bnx2i_percpu_io_thread - thread per cpu for ios
+ *
+ * @arg:	ptr to bnx2i_percpu_info structure
+ */
+int bnx2i_percpu_io_thread(void *arg)
+{
+	struct bnx2i_percpu_s *p = arg;
+	struct bnx2i_work *work, *tmp;
+	LIST_HEAD(work_list);
+
+	set_user_nice(current, -20);
+
+	while (!kthread_should_stop()) {
+		spin_lock_bh(&p->p_work_lock);
+		while (!list_empty(&p->work_list)) {
+			list_splice_init(&p->work_list, &work_list);
+			spin_unlock_bh(&p->p_work_lock);
+
+			list_for_each_entry_safe(work, tmp, &work_list, list) {
+				list_del_init(&work->list);
+				/* work allocated in the bh, freed here */
+				bnx2i_process_scsi_cmd_resp(work->session,
+							    work->bnx2i_conn,
+							    &work->cqe);
+				atomic_dec(&work->bnx2i_conn->work_cnt);
+				kfree(work);
+			}
+			spin_lock_bh(&p->p_work_lock);
+		}
+		set_current_state(TASK_INTERRUPTIBLE);
+		spin_unlock_bh(&p->p_work_lock);
+		schedule();
+	}
+	__set_current_state(TASK_RUNNING);
+
+	return 0;
+}
+
+
+/**
+ * bnx2i_queue_scsi_cmd_resp - queue cmd completion to the percpu thread
+ * @bnx2i_conn:		bnx2i connection
+ *
+ * this function is called by generic KCQ handler to queue all pending cmd
+ * completion CQEs
+ *
+ * The implementation is to queue the cmd response based on the
+ * last recorded command for the given connection.  The
+ * cpu_id gets recorded upon task_xmit.  No out-of-order completion!
+ */
+static int bnx2i_queue_scsi_cmd_resp(struct iscsi_session *session,
+				     struct bnx2i_conn *bnx2i_conn,
+				     struct bnx2i_nop_in_msg *cqe)
+{
+	struct bnx2i_work *bnx2i_work = NULL;
+	struct bnx2i_percpu_s *p = NULL;
+	struct iscsi_task *task;
+	struct scsi_cmnd *sc;
+	int rc = 0;
+
+	spin_lock(&session->lock);
+	task = iscsi_itt_to_task(bnx2i_conn->cls_conn->dd_data,
+				 cqe->itt & ISCSI_CMD_RESPONSE_INDEX);
+	if (!task) {
+		spin_unlock(&session->lock);
+		return -EINVAL;
+	}
+	sc = task->sc;
+	spin_unlock(&session->lock);
+
+	p = &per_cpu(bnx2i_percpu, sc->request->cpu);
+	spin_lock(&p->p_work_lock);
+	if (unlikely(!p->iothread)) {
+		rc = -EINVAL;
+		goto err;
+	}
+	/* Alloc and copy to the cqe */
+	bnx2i_work = kzalloc(sizeof(struct bnx2i_work), GFP_ATOMIC);
+	if (bnx2i_work) {
+		INIT_LIST_HEAD(&bnx2i_work->list);
+		bnx2i_work->session = session;
+		bnx2i_work->bnx2i_conn = bnx2i_conn;
+		memcpy(&bnx2i_work->cqe, cqe, sizeof(struct cqe));
+		list_add_tail(&bnx2i_work->list, &p->work_list);
+		atomic_inc(&bnx2i_conn->work_cnt);
+		wake_up_process(p->iothread);
+		spin_unlock(&p->p_work_lock);
+		goto done;
+	} else
+		rc = -ENOMEM;
+err:
+	spin_unlock(&p->p_work_lock);
+	bnx2i_process_scsi_cmd_resp(session, bnx2i_conn, (struct cqe *)cqe);
+done:
+	return rc;
+}
+
 
 /**
  * bnx2i_process_new_cqes - process newly DMA'ed CQE's
- * @bnx2i_conn:		iscsi connection
+ * @bnx2i_conn:		bnx2i connection
  *
  * this function is called by generic KCQ handler to process all pending CQE's
  */
-static void bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
+static int bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
 {
 	struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data;
 	struct iscsi_session *session = conn->session;
-	struct qp_info *qp = &bnx2i_conn->ep->qp;
+	struct qp_info *qp;
 	struct bnx2i_nop_in_msg *nopin;
 	int tgt_async_msg;
+	int cqe_cnt = 0;
 
+	if (bnx2i_conn->ep == NULL)
+		return 0;
+
+	qp = &bnx2i_conn->ep->qp;
+
+	if (!qp->cq_virt) {
+		printk(KERN_ALERT "bnx2i (%s): cq resr freed in bh execution!",
+			bnx2i_conn->hba->netdev->name);
+		goto out;
+	}
 	while (1) {
 		nopin = (struct bnx2i_nop_in_msg *) qp->cq_cons_qe;
 		if (nopin->cq_req_sn != qp->cqe_exp_seq_sn)
@@ -1873,8 +1987,9 @@ static void bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
 		switch (nopin->op_code) {
 		case ISCSI_OP_SCSI_CMD_RSP:
 		case ISCSI_OP_SCSI_DATA_IN:
-			bnx2i_process_scsi_cmd_resp(session, bnx2i_conn,
-						    qp->cq_cons_qe);
+			/* Run the kthread engine only for data cmds
+			   All other cmds will be completed in this bh! */
+			bnx2i_queue_scsi_cmd_resp(session, bnx2i_conn, nopin);
 			break;
 		case ISCSI_OP_LOGIN_RSP:
 			bnx2i_process_login_resp(session, bnx2i_conn,
@@ -1918,13 +2033,21 @@ static void bnx2i_process_new_cqes(struct bnx2i_conn *bnx2i_conn)
 			printk(KERN_ALERT "bnx2i: unknown opcode 0x%x\n",
 					  nopin->op_code);
 		}
-		if (!tgt_async_msg)
-			bnx2i_conn->ep->num_active_cmds--;
+		if (!tgt_async_msg) {
+			if (!atomic_read(&bnx2i_conn->ep->num_active_cmds))
+				printk(KERN_ALERT "bnx2i (%s): no active cmd! "
+				       "op 0x%x\n",
+				       bnx2i_conn->hba->netdev->name,
+				       nopin->op_code);
+			else
+				atomic_dec(&bnx2i_conn->ep->num_active_cmds);
+		}
 cqe_out:
 		/* clear out in production version only, till beta keep opcode
 		 * field intact, will be helpful in debugging (context dump)
 		 * nopin->op_code = 0;
 		 */
+		cqe_cnt++;
 		qp->cqe_exp_seq_sn++;
 		if (qp->cqe_exp_seq_sn == (qp->cqe_size * 2 + 1))
 			qp->cqe_exp_seq_sn = ISCSI_INITIAL_SN;
@@ -1937,6 +2060,8 @@ cqe_out:
 			qp->cq_cons_idx++;
 		}
 	}
+out:
+	return cqe_cnt;
 }
 
 /**
@@ -1952,6 +2077,7 @@ static void bnx2i_fastpath_notification(struct bnx2i_hba *hba,
 {
 	struct bnx2i_conn *bnx2i_conn;
 	u32 iscsi_cid;
+	int nxt_idx;
 
 	iscsi_cid = new_cqe_kcqe->iscsi_conn_id;
 	bnx2i_conn = bnx2i_get_conn_from_id(hba, iscsi_cid);
@@ -1964,9 +2090,12 @@ static void bnx2i_fastpath_notification(struct bnx2i_hba *hba,
 		printk(KERN_ALERT "cid #%x - ep not bound\n", iscsi_cid);
 		return;
 	}
+
 	bnx2i_process_new_cqes(bnx2i_conn);
-	bnx2i_arm_cq_event_coalescing(bnx2i_conn->ep, CNIC_ARM_CQE_FP);
-	bnx2i_process_new_cqes(bnx2i_conn);
+	nxt_idx = bnx2i_arm_cq_event_coalescing(bnx2i_conn->ep,
+						CNIC_ARM_CQE_FP);
+	if (nxt_idx && nxt_idx == bnx2i_process_new_cqes(bnx2i_conn))
+		bnx2i_arm_cq_event_coalescing(bnx2i_conn->ep, CNIC_ARM_CQE_FP);
 }
 
 
@@ -2312,7 +2441,7 @@ static void bnx2i_process_ofld_cmpl(struct bnx2i_hba *hba,
 			printk(KERN_ALERT "bnx2i (%s): ofld1 cmpl - invalid "
 				"opcode\n", hba->netdev->name);
 		else if (ofld_kcqe->completion_status ==
-			ISCSI_KCQE_COMPLETION_STATUS_CID_BUSY)
+			 ISCSI_KCQE_COMPLETION_STATUS_CID_BUSY)
 			/* error status code valid only for 5771x chipset */
 			ep->state = EP_STATE_OFLD_FAILED_CID_BUSY;
 		else
@@ -2511,7 +2640,7 @@ static void bnx2i_cm_remote_abort(struct cnic_sock *cm_sk)
 
 
 static int bnx2i_send_nl_mesg(void *context, u32 msg_type,
-			       char *buf, u16 buflen)
+			      char *buf, u16 buflen)
 {
 	struct bnx2i_hba *hba = context;
 	int rc;
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 6adbdc3..0f7fb14 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -40,7 +40,7 @@ unsigned int event_coal_min = 24;
 module_param(event_coal_min, int, 0664);
 MODULE_PARM_DESC(event_coal_min, "Event Coalescing Minimum Commands");
 
-unsigned int event_coal_div = 1;
+unsigned int event_coal_div = 2;
 module_param(event_coal_div, int, 0664);
 MODULE_PARM_DESC(event_coal_div, "Event Coalescing Divide Factor");
 
@@ -66,6 +66,15 @@ MODULE_PARM_DESC(rq_size, "Configure RQ size");
 
 u64 iscsi_error_mask = 0x00;
 
+DEFINE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu);
+
+static int bnx2i_cpu_callback(struct notifier_block *nfb,
+			      unsigned long action, void *hcpu);
+/* notification function for CPU hotplug events */
+static struct notifier_block bnx2i_cpu_notifier = {
+	.notifier_call = bnx2i_cpu_callback,
+};
+
 
 /**
  * bnx2i_identify_device - identifies NetXtreme II device type
@@ -362,6 +371,91 @@ void bnx2i_ulp_exit(struct cnic_dev *dev)
 
 
 /**
+ * bnx2i_percpu_thread_create - Create a receive thread for an
+ *				online CPU
+ *
+ * @cpu:	cpu index for the online cpu
+ */
+static void bnx2i_percpu_thread_create(unsigned int cpu)
+{
+	struct bnx2i_percpu_s *p;
+	struct task_struct *thread;
+
+	p = &per_cpu(bnx2i_percpu, cpu);
+
+	thread = kthread_create(bnx2i_percpu_io_thread, (void *)p,
+				"bnx2i_thread/%d", cpu);
+	/* bind thread to the cpu */
+	if (likely(!IS_ERR(thread))) {
+		kthread_bind(thread, cpu);
+		p->iothread = thread;
+		wake_up_process(thread);
+	}
+}
+
+
+static void bnx2i_percpu_thread_destroy(unsigned int cpu)
+{
+	struct bnx2i_percpu_s *p;
+	struct task_struct *thread;
+	struct bnx2i_work *work, *tmp;
+
+	/* Prevent any new work from being queued for this CPU */
+	p = &per_cpu(bnx2i_percpu, cpu);
+	spin_lock_bh(&p->p_work_lock);
+	thread = p->iothread;
+	p->iothread = NULL;
+
+	/* Free all work in the list */
+	list_for_each_entry_safe(work, tmp, &p->work_list, list) {
+		list_del_init(&work->list);
+		bnx2i_process_scsi_cmd_resp(work->session,
+					    work->bnx2i_conn, &work->cqe);
+		kfree(work);
+	}
+
+	spin_unlock_bh(&p->p_work_lock);
+	if (thread)
+		kthread_stop(thread);
+}
+
+
+/**
+ * bnx2i_cpu_callback - Handler for CPU hotplug events
+ *
+ * @nfb:	The callback data block
+ * @action:	The event triggering the callback
+ * @hcpu:	The index of the CPU that the event is for
+ *
+ * This creates or destroys per-CPU data for iSCSI
+ *
+ * Returns NOTIFY_OK always.
+ */
+static int bnx2i_cpu_callback(struct notifier_block *nfb,
+			      unsigned long action, void *hcpu)
+{
+	unsigned cpu = (unsigned long)hcpu;
+
+	switch (action) {
+	case CPU_ONLINE:
+	case CPU_ONLINE_FROZEN:
+		printk(KERN_INFO "bnx2i: CPU %x online: Create Rx thread\n",
+			cpu);
+		bnx2i_percpu_thread_create(cpu);
+		break;
+	case CPU_DEAD:
+	case CPU_DEAD_FROZEN:
+		printk(KERN_INFO "CPU %x offline: Remove Rx thread\n", cpu);
+		bnx2i_percpu_thread_destroy(cpu);
+		break;
+	default:
+		break;
+	}
+	return NOTIFY_OK;
+}
+
+
+/**
  * bnx2i_mod_init - module init entry point
  *
  * initialize any driver wide global data structures such as endpoint pool,
@@ -371,6 +465,8 @@ void bnx2i_ulp_exit(struct cnic_dev *dev)
 static int __init bnx2i_mod_init(void)
 {
 	int err;
+	unsigned cpu = 0;
+	struct bnx2i_percpu_s *p;
 
 	printk(KERN_INFO "%s", version);
 
@@ -393,6 +489,20 @@ static int __init bnx2i_mod_init(void)
 		goto unreg_xport;
 	}
 
+	/* Create percpu kernel threads to handle iSCSI I/O completions */
+	for_each_possible_cpu(cpu) {
+		p = &per_cpu(bnx2i_percpu, cpu);
+		INIT_LIST_HEAD(&p->work_list);
+		spin_lock_init(&p->p_work_lock);
+		p->iothread = NULL;
+	}
+
+	for_each_online_cpu(cpu)
+		bnx2i_percpu_thread_create(cpu);
+
+	/* Initialize per CPU interrupt thread */
+	register_hotcpu_notifier(&bnx2i_cpu_notifier);
+
 	return 0;
 
 unreg_xport:
@@ -413,6 +523,7 @@ out:
 static void __exit bnx2i_mod_exit(void)
 {
 	struct bnx2i_hba *hba;
+	unsigned cpu = 0;
 
 	mutex_lock(&bnx2i_dev_lock);
 	while (!list_empty(&adapter_list)) {
@@ -430,6 +541,11 @@ static void __exit bnx2i_mod_exit(void)
 	}
 	mutex_unlock(&bnx2i_dev_lock);
 
+	unregister_hotcpu_notifier(&bnx2i_cpu_notifier);
+
+	for_each_online_cpu(cpu)
+		bnx2i_percpu_thread_destroy(cpu);
+
 	iscsi_unregister_transport(&bnx2i_iscsi_transport);
 	cnic_unregister_driver(CNIC_ULP_ISCSI);
 }
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 041928b..9d40f32 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -27,6 +27,7 @@ static struct scsi_host_template bnx2i_host_template;
  */
 static DEFINE_SPINLOCK(bnx2i_resc_lock); /* protects global resources */
 
+DECLARE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu);
 
 static int bnx2i_adapter_ready(struct bnx2i_hba *hba)
 {
@@ -1214,7 +1215,8 @@ static int bnx2i_task_xmit(struct iscsi_task *task)
 	struct bnx2i_cmd *cmd = task->dd_data;
 	struct iscsi_cmd *hdr = (struct iscsi_cmd *) task->hdr;
 
-	if (bnx2i_conn->ep->num_active_cmds + 1 > hba->max_sqes)
+	if (atomic_read(&bnx2i_conn->ep->num_active_cmds) + 1  >
+	    hba->max_sqes)
 		return -ENOMEM;
 
 	/*
@@ -1354,6 +1356,9 @@ bnx2i_conn_create(struct iscsi_cls_session *cls_session, uint32_t cid)
 	bnx2i_conn = conn->dd_data;
 	bnx2i_conn->cls_conn = cls_conn;
 	bnx2i_conn->hba = hba;
+
+	atomic_set(&bnx2i_conn->work_cnt, 0);
+
 	/* 'ep' ptr will be assigned in bind() call */
 	bnx2i_conn->ep = NULL;
 	init_completion(&bnx2i_conn->cmd_cleanup_cmpl);
@@ -1457,11 +1462,34 @@ static void bnx2i_conn_destroy(struct iscsi_cls_conn *cls_conn)
 	struct bnx2i_conn *bnx2i_conn = conn->dd_data;
 	struct Scsi_Host *shost;
 	struct bnx2i_hba *hba;
+	struct bnx2i_work *work, *tmp;
+	unsigned cpu = 0;
+	struct bnx2i_percpu_s *p;
 
 	shost = iscsi_session_to_shost(iscsi_conn_to_session(cls_conn));
 	hba = iscsi_host_priv(shost);
 
 	bnx2i_conn_free_login_resources(hba, bnx2i_conn);
+
+	if (atomic_read(&bnx2i_conn->work_cnt)) {
+		for_each_online_cpu(cpu) {
+			p = &per_cpu(bnx2i_percpu, cpu);
+			spin_lock_bh(&p->p_work_lock);
+			list_for_each_entry_safe(work, tmp,
+						 &p->work_list, list) {
+				if (work->session == conn->session &&
+				    work->bnx2i_conn == bnx2i_conn) {
+					list_del_init(&work->list);
+					kfree(work);
+					if (!atomic_dec_and_test(
+							&bnx2i_conn->work_cnt))
+						break;
+				}
+			}
+			spin_unlock_bh(&p->p_work_lock);
+		}
+	}
+
 	iscsi_conn_teardown(cls_conn);
 }
 
@@ -1769,7 +1797,7 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
 	}
 	bnx2i_ep = ep->dd_data;
 
-	bnx2i_ep->num_active_cmds = 0;
+	atomic_set(&bnx2i_ep->num_active_cmds, 0);
 	iscsi_cid = bnx2i_alloc_iscsi_cid(hba);
 	if (iscsi_cid == -1) {
 		printk(KERN_ALERT "bnx2i (%s): alloc_ep - unable to allocate "
@@ -2163,9 +2191,9 @@ static struct scsi_host_template bnx2i_host_template = {
 	.eh_device_reset_handler = iscsi_eh_device_reset,
 	.eh_target_reset_handler = iscsi_eh_recover_target,
 	.change_queue_depth	= iscsi_change_queue_depth,
-	.can_queue		= 1024,
+	.can_queue		= 2048,
 	.max_sectors		= 127,
-	.cmd_per_lun		= 24,
+	.cmd_per_lun		= 128,
 	.this_id		= -1,
 	.use_clustering		= ENABLE_CLUSTERING,
 	.sg_tablesize		= ISCSI_MAX_BDS_PER_CMD,
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 2/4 v2] BNX2I: Modified to skip CNIC registration if iSCSI is not supported
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (91 preceding siblings ...)
  2011-06-23 22:51 ` [PATCH 1/4 v2] BNX2I: Added the use of kthreads to handle SCSI cmd completion Eddie Wai
@ 2011-06-23 22:51 ` Eddie Wai
  2011-06-23 22:51 ` [PATCH 3/4 v2] BNX2I: Changed the nopout_wqe->lun memcpy to use sizeof instead Eddie Wai
                   ` (16 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-06-23 22:51 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The init routine will now examine the cnic->max_iscsi_conn variable
before registering to CNIC during ulp_init.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Michael Chan <mchan@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_init.c |   29 +++++++++++++++--------------
 1 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 0f7fb14..28bfa9e 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -172,21 +172,14 @@ void bnx2i_start(void *handle)
 	struct bnx2i_hba *hba = handle;
 	int i = HZ;
 
-	if (!hba->cnic->max_iscsi_conn) {
-		printk(KERN_ALERT "bnx2i: dev %s does not support "
-			"iSCSI\n", hba->netdev->name);
+	/*
+	 * We should never register devices that don't support iSCSI
+	 * (see bnx2i_init_one), so something is wrong if we try to
+	 * start a iSCSI adapter on hardware with 0 supported iSCSI
+	 * connections
+	 */
+	BUG_ON(!hba->cnic->max_iscsi_conn);
 
-		if (test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic)) {
-			mutex_lock(&bnx2i_dev_lock);
-			list_del_init(&hba->link);
-			adapter_count--;
-			hba->cnic->unregister_device(hba->cnic, CNIC_ULP_ISCSI);
-			clear_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic);
-			mutex_unlock(&bnx2i_dev_lock);
-			bnx2i_free_hba(hba);
-		}
-		return;
-	}
 	bnx2i_send_fw_iscsi_init_msg(hba);
 	while (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state) && i--)
 		msleep(BNX2I_INIT_POLL_TIME);
@@ -290,6 +283,13 @@ static int bnx2i_init_one(struct bnx2i_hba *hba, struct cnic_dev *cnic)
 	int rc;
 
 	mutex_lock(&bnx2i_dev_lock);
+	if (!cnic->max_iscsi_conn) {
+		printk(KERN_ALERT "bnx2i: dev %s does not support "
+			"iSCSI\n", hba->netdev->name);
+		rc = -EOPNOTSUPP;
+		goto out;
+	}
+
 	hba->cnic = cnic;
 	rc = cnic->register_device(cnic, CNIC_ULP_ISCSI, hba);
 	if (!rc) {
@@ -307,6 +307,7 @@ static int bnx2i_init_one(struct bnx2i_hba *hba, struct cnic_dev *cnic)
 	else
 		printk(KERN_ERR "bnx2i dev reg, unknown error, %d\n", rc);
 
+out:
 	mutex_unlock(&bnx2i_dev_lock);
 
 	return rc;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 3/4 v2] BNX2I: Changed the nopout_wqe->lun memcpy to use sizeof instead
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (92 preceding siblings ...)
  2011-06-23 22:51 ` [PATCH 2/4 v2] BNX2I: Modified to skip CNIC registration if iSCSI is not supported Eddie Wai
@ 2011-06-23 22:51 ` Eddie Wai
  2011-06-24 20:20   ` Mike Christie
  2011-06-23 22:51 ` [PATCH 4/4 v2] BNX2I: Updated copyright and bump version Eddie Wai
                   ` (15 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2011-06-23 22:51 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Modified the memcpy of nopout_wqe->lun to use sizeof(struct scsi_lun)
instead of the hardcoded value 8 as noted by review comments.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 2a1bb9f..ba2f96e 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -551,7 +551,7 @@ int bnx2i_send_iscsi_nopout(struct bnx2i_conn *bnx2i_conn,
 
 	nopout_wqe->op_code = nopout_hdr->opcode;
 	nopout_wqe->op_attr = ISCSI_FLAG_CMD_FINAL;
-	memcpy(nopout_wqe->lun, nopout_hdr->lun, 8);
+	memcpy(nopout_wqe->lun, nopout_hdr->lun, sizeof(struct scsi_lun));
 
 	if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) {
 		u32 tmp = nopout_wqe->lun[0];
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 4/4 v2] BNX2I: Updated copyright and bump version
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (93 preceding siblings ...)
  2011-06-23 22:51 ` [PATCH 3/4 v2] BNX2I: Changed the nopout_wqe->lun memcpy to use sizeof instead Eddie Wai
@ 2011-06-23 22:51 ` Eddie Wai
  2011-07-11 18:14 ` [PATCH] BNX2I: Fixed kernel panic due to illegal usage of sc->request->cpu Eddie Wai
                   ` (14 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-06-23 22:51 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Bumped version from 2.6.2.3 to 2.7.0.3

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/57xx_iscsi_constants.h |    2 +-
 drivers/scsi/bnx2i/57xx_iscsi_hsi.h       |    2 +-
 drivers/scsi/bnx2i/bnx2i.h                |    2 +-
 drivers/scsi/bnx2i/bnx2i_hwi.c            |    2 +-
 drivers/scsi/bnx2i/bnx2i_init.c           |    6 +++---
 drivers/scsi/bnx2i/bnx2i_iscsi.c          |    2 +-
 drivers/scsi/bnx2i/bnx2i_sysfs.c          |    2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/bnx2i/57xx_iscsi_constants.h b/drivers/scsi/bnx2i/57xx_iscsi_constants.h
index 30e6bdb..aca593d 100644
--- a/drivers/scsi/bnx2i/57xx_iscsi_constants.h
+++ b/drivers/scsi/bnx2i/57xx_iscsi_constants.h
@@ -1,6 +1,6 @@
 /* 57xx_iscsi_constants.h: Broadcom NetXtreme II iSCSI HSI
  *
- * Copyright (c) 2006 - 2010 Broadcom Corporation
+ * Copyright (c) 2006 - 2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/bnx2i/57xx_iscsi_hsi.h b/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
index dad6c8a..1c39177 100644
--- a/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
+++ b/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
@@ -1,6 +1,6 @@
 /* 57xx_iscsi_hsi.h: Broadcom NetXtreme II iSCSI HSI.
  *
- * Copyright (c) 2006 - 2010 Broadcom Corporation
+ * Copyright (c) 2006 - 2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 239bc4e..54e2e03 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -1,6 +1,6 @@
 /* bnx2i.h: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2010 Broadcom Corporation
+ * Copyright (c) 2006 - 2011 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index ba2f96e..ff5e872 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1,6 +1,6 @@
 /* bnx2i_hwi.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2010 Broadcom Corporation
+ * Copyright (c) 2006 - 2011 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 28bfa9e..4f252a9 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -1,6 +1,6 @@
 /* bnx2i.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2010 Broadcom Corporation
+ * Copyright (c) 2006 - 2011 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
@@ -18,8 +18,8 @@ static struct list_head adapter_list = LIST_HEAD_INIT(adapter_list);
 static u32 adapter_count;
 
 #define DRV_MODULE_NAME		"bnx2i"
-#define DRV_MODULE_VERSION	"2.6.2.3"
-#define DRV_MODULE_RELDATE	"Dec 31, 2010"
+#define DRV_MODULE_VERSION	"2.7.0.3"
+#define DRV_MODULE_RELDATE	"Jun 15, 2011"
 
 static char version[] __devinitdata =
 		"Broadcom NetXtreme II iSCSI Driver " DRV_MODULE_NAME \
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 9d40f32..5c55a75 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1,7 +1,7 @@
 /*
  * bnx2i_iscsi.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2010 Broadcom Corporation
+ * Copyright (c) 2006 - 2011 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
diff --git a/drivers/scsi/bnx2i/bnx2i_sysfs.c b/drivers/scsi/bnx2i/bnx2i_sysfs.c
index 9174196..83a77f7 100644
--- a/drivers/scsi/bnx2i/bnx2i_sysfs.c
+++ b/drivers/scsi/bnx2i/bnx2i_sysfs.c
@@ -1,6 +1,6 @@
 /* bnx2i_sysfs.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2004 - 2010 Broadcom Corporation
+ * Copyright (c) 2004 - 2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH 3/4 v2] BNX2I: Changed the nopout_wqe->lun memcpy to use sizeof instead
  2011-06-23 22:51 ` [PATCH 3/4 v2] BNX2I: Changed the nopout_wqe->lun memcpy to use sizeof instead Eddie Wai
@ 2011-06-24 20:20   ` Mike Christie
  2011-06-29 21:53     ` James Bottomley
  0 siblings, 1 reply; 189+ messages in thread
From: Mike Christie @ 2011-06-24 20:20 UTC (permalink / raw)
  To: open-iscsi
  Cc: Eddie Wai, James Bottomley, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Andy Grover

On 06/23/2011 05:51 PM, Eddie Wai wrote:
> Modified the memcpy of nopout_wqe->lun to use sizeof(struct scsi_lun)
> instead of the hardcoded value 8 as noted by review comments.
> 
> Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
> ---
>  drivers/scsi/bnx2i/bnx2i_hwi.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
> index 2a1bb9f..ba2f96e 100644
> --- a/drivers/scsi/bnx2i/bnx2i_hwi.c
> +++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
> @@ -551,7 +551,7 @@ int bnx2i_send_iscsi_nopout(struct bnx2i_conn *bnx2i_conn,
>  
>  	nopout_wqe->op_code = nopout_hdr->opcode;
>  	nopout_wqe->op_attr = ISCSI_FLAG_CMD_FINAL;
> -	memcpy(nopout_wqe->lun, nopout_hdr->lun, 8);
> +	memcpy(nopout_wqe->lun, nopout_hdr->lun, sizeof(struct scsi_lun));
>  
>  	if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) {
>  		u32 tmp = nopout_wqe->lun[0];

This patch and Andy your patch "[PATCH] iscsi: Use struct scsi_lun in
iscsi structs instead of u8[8]" are going to conflict with each other.

And Eddie, I think you missed some other instances where 8 is hardcoded.


^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 3/4 v2] BNX2I: Changed the nopout_wqe->lun memcpy to use sizeof instead
  2011-06-24 20:20   ` Mike Christie
@ 2011-06-29 21:53     ` James Bottomley
  0 siblings, 0 replies; 189+ messages in thread
From: James Bottomley @ 2011-06-29 21:53 UTC (permalink / raw)
  To: Mike Christie
  Cc: open-iscsi, Eddie Wai, James Bottomley, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Andy Grover

On Fri, 2011-06-24 at 15:20 -0500, Mike Christie wrote:
> On 06/23/2011 05:51 PM, Eddie Wai wrote:
> > Modified the memcpy of nopout_wqe->lun to use sizeof(struct scsi_lun)
> > instead of the hardcoded value 8 as noted by review comments.
> > 
> > Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
> > ---
> >  drivers/scsi/bnx2i/bnx2i_hwi.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
> > index 2a1bb9f..ba2f96e 100644
> > --- a/drivers/scsi/bnx2i/bnx2i_hwi.c
> > +++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
> > @@ -551,7 +551,7 @@ int bnx2i_send_iscsi_nopout(struct bnx2i_conn *bnx2i_conn,
> >  
> >  	nopout_wqe->op_code = nopout_hdr->opcode;
> >  	nopout_wqe->op_attr = ISCSI_FLAG_CMD_FINAL;
> > -	memcpy(nopout_wqe->lun, nopout_hdr->lun, 8);
> > +	memcpy(nopout_wqe->lun, nopout_hdr->lun, sizeof(struct scsi_lun));
> >  
> >  	if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) {
> >  		u32 tmp = nopout_wqe->lun[0];
> 
> This patch and Andy your patch "[PATCH] iscsi: Use struct scsi_lun in
> iscsi structs instead of u8[8]" are going to conflict with each other.
> 
> And Eddie, I think you missed some other instances where 8 is hardcoded.

Agreed, I skipped this one for now ... please resubmit against scsi-misc
if more work is needed.

Thanks,

James



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH] BNX2I: Fixed kernel panic due to illegal usage of sc->request->cpu
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (94 preceding siblings ...)
  2011-06-23 22:51 ` [PATCH 4/4 v2] BNX2I: Updated copyright and bump version Eddie Wai
@ 2011-07-11 18:14 ` Eddie Wai
       [not found]   ` <1310408095-11882-1-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
  2011-07-14 23:42 ` [PATCH v2] " Eddie Wai
                   ` (13 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2011-07-11 18:14 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

A kernel panic was observed when passing the sc->request->cpu = -1 to
retrieve the per_cpu variable pointer:
 #0 [ffff880011203960] machine_kexec at ffffffff81022bc3
 #1 [ffff8800112039b0] crash_kexec at ffffffff81088630
 #2 [ffff880011203a80] __die at ffffffff8139ea20
 #3 [ffff880011203aa0] no_context at ffffffff8102f3a7
 #4 [ffff880011203ae0] __bad_area_nosemaphore at ffffffff8102f665
 #5 [ffff880011203ba0] retint_signal at ffffffff8139dd1f
 #6 [ffff880011203cc8] bnx2i_indicate_kcqe at ffffffffa03dc4f2
 #7 [ffff880011203da8] service_kcqes at ffffffffa03cb04f
 #8 [ffff880011203e68] cnic_service_bnx2x_kcq at ffffffffa03cb14a
 #9 [ffff880011203e88] cnic_service_bnx2x_bh at ffffffffa03cb1b3

The problem lies in the sg_io (and perhaps sg_scsi_ioctl) call to
blk_get_request->get_request/wait->blk_alloc_request->blk_rq_init which
re-initializes the request->cpu to -1.  There is no assignment for cpu from
that to the request_fn call to low level drivers.

When this happens, the sc->request->cpu will be using the init value of
-1.  This will create a kernel panic when it hits bnx2i because the code
refers it to get the per_cpu variables ptr.

This change is to put in a guard against that and also for cases when
CONFIG_SMP/BIO_CPU_AFFINE is not enabled.  In those cases, the cpu
affinitization code would not get run in __make_request either; hence
the request->cpu will remain a -1 also.

This bug was created from commit:  b5cf6b63f73abdc051035f0050b367beeb2ef94c

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 5c55a75..622383d 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1225,6 +1225,10 @@ static int bnx2i_task_xmit(struct iscsi_task *task)
 	if (!sc)
 		return bnx2i_mtask_xmit(conn, task);
 
+	if (!blk_rq_cpu_valid(sc->request)) {
+		sc->request->cpu = get_cpu();
+		put_cpu();
+	}
 	bnx2i_setup_cmd_wqe_template(cmd);
 	cmd->req.op_code = ISCSI_OP_SCSI_CMD;
 	cmd->conn = bnx2i_conn;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH] BNX2I: Fixed kernel panic due to illegal usage of sc->request->cpu
       [not found]   ` <1310408095-11882-1-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
@ 2011-07-11 20:02     ` Mike Christie
  2011-07-14  6:33       ` Eddie Wai
  0 siblings, 1 reply; 189+ messages in thread
From: Mike Christie @ 2011-07-11 20:02 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 07/11/2011 01:14 PM, Eddie Wai wrote:
> A kernel panic was observed when passing the sc->request->cpu = -1 to
> retrieve the per_cpu variable pointer:
>  #0 [ffff880011203960] machine_kexec at ffffffff81022bc3
>  #1 [ffff8800112039b0] crash_kexec at ffffffff81088630
>  #2 [ffff880011203a80] __die at ffffffff8139ea20
>  #3 [ffff880011203aa0] no_context at ffffffff8102f3a7
>  #4 [ffff880011203ae0] __bad_area_nosemaphore at ffffffff8102f665
>  #5 [ffff880011203ba0] retint_signal at ffffffff8139dd1f
>  #6 [ffff880011203cc8] bnx2i_indicate_kcqe at ffffffffa03dc4f2
>  #7 [ffff880011203da8] service_kcqes at ffffffffa03cb04f
>  #8 [ffff880011203e68] cnic_service_bnx2x_kcq at ffffffffa03cb14a
>  #9 [ffff880011203e88] cnic_service_bnx2x_bh at ffffffffa03cb1b3
> 
> The problem lies in the sg_io (and perhaps sg_scsi_ioctl) call to
> blk_get_request->get_request/wait->blk_alloc_request->blk_rq_init which
> re-initializes the request->cpu to -1.  There is no assignment for cpu from
> that to the request_fn call to low level drivers.
> 
> When this happens, the sc->request->cpu will be using the init value of
> -1.  This will create a kernel panic when it hits bnx2i because the code
> refers it to get the per_cpu variables ptr.
> 
> This change is to put in a guard against that and also for cases when
> CONFIG_SMP/BIO_CPU_AFFINE is not enabled.  In those cases, the cpu
> affinitization code would not get run in __make_request either; hence
> the request->cpu will remain a -1 also.
> 


> 
> diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
> index 5c55a75..622383d 100644
> --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
> +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
> @@ -1225,6 +1225,10 @@ static int bnx2i_task_xmit(struct iscsi_task *task)
>  	if (!sc)
>  		return bnx2i_mtask_xmit(conn, task);
>  
> +	if (!blk_rq_cpu_valid(sc->request)) {
> +		sc->request->cpu = get_cpu();
> +		put_cpu();
> +	}


If I understand you right, then I think this needs to get fixed in the
block or scsi layer instead of each LLD.

-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH] BNX2I: Fixed kernel panic due to illegal usage of sc->request->cpu
  2011-07-11 20:02     ` Mike Christie
@ 2011-07-14  6:33       ` Eddie Wai
  2011-07-14  7:20         ` Mike Christie
  2011-07-14  7:41         ` Mike Christie
  0 siblings, 2 replies; 189+ messages in thread
From: Eddie Wai @ 2011-07-14  6:33 UTC (permalink / raw)
  To: Mike Christie
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Benjamin Li


On Mon, 2011-07-11 at 13:02 -0700, Mike Christie wrote:
> On 07/11/2011 01:14 PM, Eddie Wai wrote:
> > A kernel panic was observed when passing the sc->request->cpu = -1 to
> > retrieve the per_cpu variable pointer:
> >  #0 [ffff880011203960] machine_kexec at ffffffff81022bc3
> >  #1 [ffff8800112039b0] crash_kexec at ffffffff81088630
> >  #2 [ffff880011203a80] __die at ffffffff8139ea20
> >  #3 [ffff880011203aa0] no_context at ffffffff8102f3a7
> >  #4 [ffff880011203ae0] __bad_area_nosemaphore at ffffffff8102f665
> >  #5 [ffff880011203ba0] retint_signal at ffffffff8139dd1f
> >  #6 [ffff880011203cc8] bnx2i_indicate_kcqe at ffffffffa03dc4f2
> >  #7 [ffff880011203da8] service_kcqes at ffffffffa03cb04f
> >  #8 [ffff880011203e68] cnic_service_bnx2x_kcq at ffffffffa03cb14a
> >  #9 [ffff880011203e88] cnic_service_bnx2x_bh at ffffffffa03cb1b3
> > 
> > The problem lies in the sg_io (and perhaps sg_scsi_ioctl) call to
> > blk_get_request->get_request/wait->blk_alloc_request->blk_rq_init which
> > re-initializes the request->cpu to -1.  There is no assignment for cpu from
> > that to the request_fn call to low level drivers.
> > 
> > When this happens, the sc->request->cpu will be using the init value of
> > -1.  This will create a kernel panic when it hits bnx2i because the code
> > refers it to get the per_cpu variables ptr.
> > 
> > This change is to put in a guard against that and also for cases when
> > CONFIG_SMP/BIO_CPU_AFFINE is not enabled.  In those cases, the cpu
> > affinitization code would not get run in __make_request either; hence
> > the request->cpu will remain a -1 also.
> > 
> 
> 
> > 
> > diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
> > index 5c55a75..622383d 100644
> > --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
> > +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
> > @@ -1225,6 +1225,10 @@ static int bnx2i_task_xmit(struct iscsi_task *task)
> >  	if (!sc)
> >  		return bnx2i_mtask_xmit(conn, task);
> >  
> > +	if (!blk_rq_cpu_valid(sc->request)) {
> > +		sc->request->cpu = get_cpu();
> > +		put_cpu();
> > +	}
> 
> 
> If I understand you right, then I think this needs to get fixed in the
> block or scsi layer instead of each LLD.

Absolutely, but this bnx2i fix is still applicable alongside the fixes I'm
proposing in the block layer below.

I think the whole idea behind the tracking of the blk req->cpu is so that the blk completion
can be fired off from the same CPU to take advantage of the CPU's llc.  However, this is only being
done when the queue is defined with the QUEUE_FLAG_SAME_COMP queue_flag enabled.  In the case
when the queue is defined without this enforced, it would then be up to the blk completion
code to complete the blk request with the current CPU of the thread.

The same analogy should apply to the iSCSI LLD for cmd completion as well.  So if the
sc->request->cpu is left at -1, the LLD should then decide how it wants the cmd completion
to take place.  For all the other cases, the request->cpu id should be used instead.  
For bnx2i, if the blk layer didn't set the request->cpu, we would want to align and complete
the cmd against the task_xmit issuer's CPU id unconditionally; hence the explicit get_cpu call.

In the current block code, this CPU affinity code is only being called in the __make_request
code path. I believe the same code needs to be executed in all the other code paths where
the blk request is being added to the queue for execution.  This change will then properly
place the desired CPU to the request->cpu when the queue is defined with QUEUE_FLAG_SAME_COMP.
Otherwise, the request->cpu will assume the init value of -1.

Please throw in your 2 cents if anyone thinks otherwise.  I should have
the blk layer patches submitted soon.  Thanks.



^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH] BNX2I: Fixed kernel panic due to illegal usage of sc->request->cpu
  2011-07-14  6:33       ` Eddie Wai
@ 2011-07-14  7:20         ` Mike Christie
  2011-07-14  7:41         ` Mike Christie
  1 sibling, 0 replies; 189+ messages in thread
From: Mike Christie @ 2011-07-14  7:20 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Benjamin Li

On 07/14/2011 01:33 AM, Eddie Wai wrote:
> 
> On Mon, 2011-07-11 at 13:02 -0700, Mike Christie wrote:
>> On 07/11/2011 01:14 PM, Eddie Wai wrote:
>>> A kernel panic was observed when passing the sc->request->cpu = -1 to
>>> retrieve the per_cpu variable pointer:
>>>  #0 [ffff880011203960] machine_kexec at ffffffff81022bc3
>>>  #1 [ffff8800112039b0] crash_kexec at ffffffff81088630
>>>  #2 [ffff880011203a80] __die at ffffffff8139ea20
>>>  #3 [ffff880011203aa0] no_context at ffffffff8102f3a7
>>>  #4 [ffff880011203ae0] __bad_area_nosemaphore at ffffffff8102f665
>>>  #5 [ffff880011203ba0] retint_signal at ffffffff8139dd1f
>>>  #6 [ffff880011203cc8] bnx2i_indicate_kcqe at ffffffffa03dc4f2
>>>  #7 [ffff880011203da8] service_kcqes at ffffffffa03cb04f
>>>  #8 [ffff880011203e68] cnic_service_bnx2x_kcq at ffffffffa03cb14a
>>>  #9 [ffff880011203e88] cnic_service_bnx2x_bh at ffffffffa03cb1b3
>>>
>>> The problem lies in the sg_io (and perhaps sg_scsi_ioctl) call to
>>> blk_get_request->get_request/wait->blk_alloc_request->blk_rq_init which
>>> re-initializes the request->cpu to -1.  There is no assignment for cpu from
>>> that to the request_fn call to low level drivers.
>>>
>>> When this happens, the sc->request->cpu will be using the init value of
>>> -1.  This will create a kernel panic when it hits bnx2i because the code
>>> refers it to get the per_cpu variables ptr.
>>>
>>> This change is to put in a guard against that and also for cases when
>>> CONFIG_SMP/BIO_CPU_AFFINE is not enabled.  In those cases, the cpu
>>> affinitization code would not get run in __make_request either; hence
>>> the request->cpu will remain a -1 also.
>>>
>>
>>
>>>
>>> diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
>>> index 5c55a75..622383d 100644
>>> --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
>>> +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
>>> @@ -1225,6 +1225,10 @@ static int bnx2i_task_xmit(struct iscsi_task *task)
>>>  	if (!sc)
>>>  		return bnx2i_mtask_xmit(conn, task);
>>>  
>>> +	if (!blk_rq_cpu_valid(sc->request)) {
>>> +		sc->request->cpu = get_cpu();
>>> +		put_cpu();
>>> +	}
>>
>>
>> If I understand you right, then I think this needs to get fixed in the
>> block or scsi layer instead of each LLD.
> 
> Absolutely, but this bnx2i fix is still applicable alongside the fixes I'm
> proposing in the block layer below.
> 
> I think the whole idea behind the tracking of the blk req->cpu is so that the blk completion
> can be fired off from the same CPU to take advantage of the CPU's llc.  However, this is only being
> done when the queue is defined with the QUEUE_FLAG_SAME_COMP queue_flag enabled.  In the case
> when the queue is defined without this enforced, it would then be up to the blk completion
> code to complete the blk request with the current CPU of the thread.
> 
> The same analogy should apply to the iSCSI LLD for cmd completion as well.  So if the
> sc->request->cpu is left at -1, the LLD should then decide how it wants the cmd completion
> to take place.  For all the other cases, the request->cpu id should be used instead.  
> For bnx2i, if the blk layer didn't set the request->cpu, we would want to align and complete
> the cmd against the task_xmit issuer's CPU id unconditionally; hence the explicit get_cpu call.

I actually think all this should go in the block layer. We should not
have driver specific setting/interfaces for this. The driver should be
able to just have the block layer complete all the IO on some soft
irq/thread and do the right thing. Then we can have one interface in the
block layer too.

We do not want to end up with every driver adding some sysfs/modparm
interfaces to control if we are going to complete the IO on the same
cpu, round robin cpus, etc.

I think we need to change the blkio poll code so it is usefull to
everyone. It does not make sense for every driver to want to do some
completion processing in a thread/softirq then have every driver create
their own threading and completing code/policies. From there we can have
a common interface to control the cpu completion polciy.

It will be really strange to tell users that in one case we use the
block layer policy but in another case we use the LLD policy interface.

I think right now we are ending up with a mess where someone can set the
rq_affinity, the LLD will ignore this and do round robin completion on
its own threads, then when the block layer soft irq completion code runs
it will complete on the cpu set by the rq_affinity code.

> 
> In the current block code, this CPU affinity code is only being called in the __make_request
> code path. I believe the same code needs to be executed in all the other code paths where
> the blk request is being added to the queue for execution.  This change will then properly
> place the desired CPU to the request->cpu when the queue is defined with QUEUE_FLAG_SAME_COMP.
> Otherwise, the request->cpu will assume the init value of -1.
> 

I am not disagreeing with that.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH] BNX2I: Fixed kernel panic due to illegal usage of sc->request->cpu
  2011-07-14  6:33       ` Eddie Wai
  2011-07-14  7:20         ` Mike Christie
@ 2011-07-14  7:41         ` Mike Christie
  2011-07-14 17:13           ` Eddie Wai
  1 sibling, 1 reply; 189+ messages in thread
From: Mike Christie @ 2011-07-14  7:41 UTC (permalink / raw)
  To: open-iscsi
  Cc: Eddie Wai, James Bottomley, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Benjamin Li

On 07/14/2011 01:33 AM, Eddie Wai wrote:
> 
> On Mon, 2011-07-11 at 13:02 -0700, Mike Christie wrote:
>> On 07/11/2011 01:14 PM, Eddie Wai wrote:
>>> A kernel panic was observed when passing the sc->request->cpu = -1 to
>>> retrieve the per_cpu variable pointer:
>>>  #0 [ffff880011203960] machine_kexec at ffffffff81022bc3
>>>  #1 [ffff8800112039b0] crash_kexec at ffffffff81088630
>>>  #2 [ffff880011203a80] __die at ffffffff8139ea20
>>>  #3 [ffff880011203aa0] no_context at ffffffff8102f3a7
>>>  #4 [ffff880011203ae0] __bad_area_nosemaphore at ffffffff8102f665
>>>  #5 [ffff880011203ba0] retint_signal at ffffffff8139dd1f
>>>  #6 [ffff880011203cc8] bnx2i_indicate_kcqe at ffffffffa03dc4f2
>>>  #7 [ffff880011203da8] service_kcqes at ffffffffa03cb04f
>>>  #8 [ffff880011203e68] cnic_service_bnx2x_kcq at ffffffffa03cb14a
>>>  #9 [ffff880011203e88] cnic_service_bnx2x_bh at ffffffffa03cb1b3
>>>
>>> The problem lies in the sg_io (and perhaps sg_scsi_ioctl) call to
>>> blk_get_request->get_request/wait->blk_alloc_request->blk_rq_init which
>>> re-initializes the request->cpu to -1.  There is no assignment for cpu from
>>> that to the request_fn call to low level drivers.
>>>
>>> When this happens, the sc->request->cpu will be using the init value of
>>> -1.  This will create a kernel panic when it hits bnx2i because the code
>>> refers it to get the per_cpu variables ptr.
>>>
>>> This change is to put in a guard against that and also for cases when
>>> CONFIG_SMP/BIO_CPU_AFFINE is not enabled.  In those cases, the cpu
>>> affinitization code would not get run in __make_request either; hence
>>> the request->cpu will remain a -1 also.
>>>
>>
>>
>>>
>>> diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
>>> index 5c55a75..622383d 100644
>>> --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
>>> +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
>>> @@ -1225,6 +1225,10 @@ static int bnx2i_task_xmit(struct iscsi_task *task)
>>>  	if (!sc)
>>>  		return bnx2i_mtask_xmit(conn, task);
>>>  
>>> +	if (!blk_rq_cpu_valid(sc->request)) {
>>> +		sc->request->cpu = get_cpu();
>>> +		put_cpu();
>>> +	}
>>
>>
>> If I understand you right, then I think this needs to get fixed in the
>> block or scsi layer instead of each LLD.
> 
> Absolutely, but this bnx2i fix is still applicable alongside the fixes I'm
> proposing in the block layer below.
> 
> I think the whole idea behind the tracking of the blk req->cpu is so that the blk completion
> can be fired off from the same CPU to take advantage of the CPU's llc.  However, this is only being
> done when the queue is defined with the QUEUE_FLAG_SAME_COMP queue_flag enabled.  In the case
> when the queue is defined without this enforced, it would then be up to the blk completion
> code to complete the blk request with the current CPU of the thread.
> 
> The same analogy should apply to the iSCSI LLD for cmd completion as well.  So if the
> sc->request->cpu is left at -1, the LLD should then decide how it wants the cmd completion
> to take place.  For all the other cases, the request->cpu id should be used instead.  
> For bnx2i, if the blk layer didn't set the request->cpu, we would want to align and complete
> the cmd against the task_xmit issuer's CPU id unconditionally; hence the explicit get_cpu call.

Oh yeah, wrt the code we have today (so I mean ignoring my rant in the
other mail :)), I think what you are doing in your patch is sort of ok.
I am not sure if we want to be touching the request->cpu field in a LLD
though. I do not think LLDs should be modifying a block layer struct
like that probably.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH] BNX2I: Fixed kernel panic due to illegal usage of sc->request->cpu
  2011-07-14  7:41         ` Mike Christie
@ 2011-07-14 17:13           ` Eddie Wai
  0 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-07-14 17:13 UTC (permalink / raw)
  To: Mike Christie
  Cc: open-iscsi, James Bottomley, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Benjamin Li


On Thu, 2011-07-14 at 00:41 -0700, Mike Christie wrote:
> On 07/14/2011 01:33 AM, Eddie Wai wrote:
> > 
> > On Mon, 2011-07-11 at 13:02 -0700, Mike Christie wrote:
> >> On 07/11/2011 01:14 PM, Eddie Wai wrote:
> >>> A kernel panic was observed when passing the sc->request->cpu = -1 to
> >>> retrieve the per_cpu variable pointer:
> >>>  #0 [ffff880011203960] machine_kexec at ffffffff81022bc3
> >>>  #1 [ffff8800112039b0] crash_kexec at ffffffff81088630
> >>>  #2 [ffff880011203a80] __die at ffffffff8139ea20
> >>>  #3 [ffff880011203aa0] no_context at ffffffff8102f3a7
> >>>  #4 [ffff880011203ae0] __bad_area_nosemaphore at ffffffff8102f665
> >>>  #5 [ffff880011203ba0] retint_signal at ffffffff8139dd1f
> >>>  #6 [ffff880011203cc8] bnx2i_indicate_kcqe at ffffffffa03dc4f2
> >>>  #7 [ffff880011203da8] service_kcqes at ffffffffa03cb04f
> >>>  #8 [ffff880011203e68] cnic_service_bnx2x_kcq at ffffffffa03cb14a
> >>>  #9 [ffff880011203e88] cnic_service_bnx2x_bh at ffffffffa03cb1b3
> >>>
> >>> The problem lies in the sg_io (and perhaps sg_scsi_ioctl) call to
> >>> blk_get_request->get_request/wait->blk_alloc_request->blk_rq_init which
> >>> re-initializes the request->cpu to -1.  There is no assignment for cpu from
> >>> that to the request_fn call to low level drivers.
> >>>
> >>> When this happens, the sc->request->cpu will be using the init value of
> >>> -1.  This will create a kernel panic when it hits bnx2i because the code
> >>> refers it to get the per_cpu variables ptr.
> >>>
> >>> This change is to put in a guard against that and also for cases when
> >>> CONFIG_SMP/BIO_CPU_AFFINE is not enabled.  In those cases, the cpu
> >>> affinitization code would not get run in __make_request either; hence
> >>> the request->cpu will remain a -1 also.
> >>>
> >>
> >>
> >>>
> >>> diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
> >>> index 5c55a75..622383d 100644
> >>> --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
> >>> +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
> >>> @@ -1225,6 +1225,10 @@ static int bnx2i_task_xmit(struct iscsi_task *task)
> >>>  	if (!sc)
> >>>  		return bnx2i_mtask_xmit(conn, task);
> >>>  
> >>> +	if (!blk_rq_cpu_valid(sc->request)) {
> >>> +		sc->request->cpu = get_cpu();
> >>> +		put_cpu();
> >>> +	}
> >>
> >>
> >> If I understand you right, then I think this needs to get fixed in the
> >> block or scsi layer instead of each LLD.
> > 
> > Absolutely, but this bnx2i fix is still applicable alongside the fixes I'm
> > proposing in the block layer below.
> > 
> > I think the whole idea behind the tracking of the blk req->cpu is so that the blk completion
> > can be fired off from the same CPU to take advantage of the CPU's llc.  However, this is only being
> > done when the queue is defined with the QUEUE_FLAG_SAME_COMP queue_flag enabled.  In the case
> > when the queue is defined without this enforced, it would then be up to the blk completion
> > code to complete the blk request with the current CPU of the thread.
> > 
> > The same analogy should apply to the iSCSI LLD for cmd completion as well.  So if the
> > sc->request->cpu is left at -1, the LLD should then decide how it wants the cmd completion
> > to take place.  For all the other cases, the request->cpu id should be used instead.  
> > For bnx2i, if the blk layer didn't set the request->cpu, we would want to align and complete
> > the cmd against the task_xmit issuer's CPU id unconditionally; hence the explicit get_cpu call.
> 
> Oh yeah, wrt the code we have today (so I mean ignoring my rant in the
> other mail :)), I think what you are doing in your patch is sort of ok.
> I am not sure if we want to be touching the request->cpu field in a LLD
> though. I do not think LLDs should be modifying a block layer struct
> like that probably.
> 
Agreed.  sc->request->cpu should be left to -1 in this case.  I'll go
ahead and defined a local variable to keep track of it.  Thanks.




^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH v2] BNX2I: Fixed kernel panic due to illegal usage of sc->request->cpu
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (95 preceding siblings ...)
  2011-07-11 18:14 ` [PATCH] BNX2I: Fixed kernel panic due to illegal usage of sc->request->cpu Eddie Wai
@ 2011-07-14 23:42 ` Eddie Wai
  2011-07-15  0:29   ` Michael Chan
  2011-07-15 18:17 ` [PATCH v3] " Eddie Wai
                   ` (12 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2011-07-14 23:42 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

A kernel panic was observed when passing the sc->request->cpu = -1 to
retrieve the per_cpu variable pointer:
 #0 [ffff880011203960] machine_kexec at ffffffff81022bc3
 #1 [ffff8800112039b0] crash_kexec at ffffffff81088630
 #2 [ffff880011203a80] __die at ffffffff8139ea20
 #3 [ffff880011203aa0] no_context at ffffffff8102f3a7
 #4 [ffff880011203ae0] __bad_area_nosemaphore at ffffffff8102f665
 #5 [ffff880011203ba0] retint_signal at ffffffff8139dd1f
 #6 [ffff880011203cc8] bnx2i_indicate_kcqe at ffffffffa03dc4f2
 #7 [ffff880011203da8] service_kcqes at ffffffffa03cb04f
 #8 [ffff880011203e68] cnic_service_bnx2x_kcq at ffffffffa03cb14a
 #9 [ffff880011203e88] cnic_service_bnx2x_bh at ffffffffa03cb1b3

The problem lies in the sg_io (and perhaps sg_scsi_ioctl) call to
blk_get_request->get_request/wait->blk_alloc_request->blk_rq_init which
re-initializes the request->cpu to -1.  There is no assignment for cpu from
that to the request_fn call to low level drivers.

When this happens, the sc->request->cpu will be using the init value of
-1.  This will create a kernel panic when it hits bnx2i because the code
refers it to get the per_cpu variables ptr.

This change is to put in a guard against that and also for cases when
bio affinity/queue completion to the same cpu is not enabled.  In those
cases, the request->cpu will remain a -1 also.

This bug was created from commit:  b5cf6b63f73abdc051035f0050b367beeb2ef94c

For the case when the blk layer did not setup the request->cpu, bnx2i
will complete the sc with the current CPU of the thread.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 54978c1..0e71615 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1901,6 +1901,7 @@ static int bnx2i_queue_scsi_cmd_resp(struct iscsi_session *session,
 	struct iscsi_task *task;
 	struct scsi_cmnd *sc;
 	int rc = 0;
+	int cpu;
 
 	spin_lock(&session->lock);
 	task = iscsi_itt_to_task(bnx2i_conn->cls_conn->dd_data,
@@ -1912,7 +1913,13 @@ static int bnx2i_queue_scsi_cmd_resp(struct iscsi_session *session,
 	sc = task->sc;
 	spin_unlock(&session->lock);
 
-	p = &per_cpu(bnx2i_percpu, sc->request->cpu);
+	if (!blk_rq_cpu_valid(sc->request)) {
+		cpu = get_cpu();
+		put_cpu();
+	} else
+		cpu = sc->request->cpu;
+
+	p = &per_cpu(bnx2i_percpu, cpu);
 	spin_lock(&p->p_work_lock);
 	if (unlikely(!p->iothread)) {
 		rc = -EINVAL;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH v2] BNX2I: Fixed kernel panic due to illegal usage of sc->request->cpu
  2011-07-14 23:42 ` [PATCH v2] " Eddie Wai
@ 2011-07-15  0:29   ` Michael Chan
  2011-07-15  1:11     ` Eddie Wai
  0 siblings, 1 reply; 189+ messages in thread
From: Michael Chan @ 2011-07-15  0:29 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, Mike Christie, open-iscsi, linux-scsi,
	Anil Veerabhadrappa, Benjamin Li


On Thu, 2011-07-14 at 16:42 -0700, Eddie Wai wrote:
> A kernel panic was observed when passing the sc->request->cpu = -1 to
> retrieve the per_cpu variable pointer:
>  #0 [ffff880011203960] machine_kexec at ffffffff81022bc3
>  #1 [ffff8800112039b0] crash_kexec at ffffffff81088630
>  #2 [ffff880011203a80] __die at ffffffff8139ea20
>  #3 [ffff880011203aa0] no_context at ffffffff8102f3a7
>  #4 [ffff880011203ae0] __bad_area_nosemaphore at ffffffff8102f665
>  #5 [ffff880011203ba0] retint_signal at ffffffff8139dd1f
>  #6 [ffff880011203cc8] bnx2i_indicate_kcqe at ffffffffa03dc4f2
>  #7 [ffff880011203da8] service_kcqes at ffffffffa03cb04f
>  #8 [ffff880011203e68] cnic_service_bnx2x_kcq at ffffffffa03cb14a
>  #9 [ffff880011203e88] cnic_service_bnx2x_bh at ffffffffa03cb1b3
> 
> The problem lies in the sg_io (and perhaps sg_scsi_ioctl) call to
> blk_get_request->get_request/wait->blk_alloc_request->blk_rq_init which
> re-initializes the request->cpu to -1.  There is no assignment for cpu from
> that to the request_fn call to low level drivers.
> 
> When this happens, the sc->request->cpu will be using the init value of
> -1.  This will create a kernel panic when it hits bnx2i because the code
> refers it to get the per_cpu variables ptr.
> 
> This change is to put in a guard against that and also for cases when
> bio affinity/queue completion to the same cpu is not enabled.  In those
> cases, the request->cpu will remain a -1 also.
> 
> This bug was created from commit:  b5cf6b63f73abdc051035f0050b367beeb2ef94c
> 
> For the case when the blk layer did not setup the request->cpu, bnx2i
> will complete the sc with the current CPU of the thread.
> 
> Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
> ---
>  drivers/scsi/bnx2i/bnx2i_hwi.c |    9 ++++++++-
>  1 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
> index 54978c1..0e71615 100644
> --- a/drivers/scsi/bnx2i/bnx2i_hwi.c
> +++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
> @@ -1901,6 +1901,7 @@ static int bnx2i_queue_scsi_cmd_resp(struct iscsi_session *session,
>  	struct iscsi_task *task;
>  	struct scsi_cmnd *sc;
>  	int rc = 0;
> +	int cpu;
>  
>  	spin_lock(&session->lock);
>  	task = iscsi_itt_to_task(bnx2i_conn->cls_conn->dd_data,
> @@ -1912,7 +1913,13 @@ static int bnx2i_queue_scsi_cmd_resp(struct iscsi_session *session,
>  	sc = task->sc;
>  	spin_unlock(&session->lock);
>  
> -	p = &per_cpu(bnx2i_percpu, sc->request->cpu);
> +	if (!blk_rq_cpu_valid(sc->request)) {
> +		cpu = get_cpu();
> +		put_cpu();

Why not just use smp_processor_id()?

> +	} else
> +		cpu = sc->request->cpu;
> +
> +	p = &per_cpu(bnx2i_percpu, cpu);
>  	spin_lock(&p->p_work_lock);
>  	if (unlikely(!p->iothread)) {
>  		rc = -EINVAL;



^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH v2] BNX2I: Fixed kernel panic due to illegal usage of sc->request->cpu
  2011-07-15  0:29   ` Michael Chan
@ 2011-07-15  1:11     ` Eddie Wai
  0 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-07-15  1:11 UTC (permalink / raw)
  To: Michael Chan
  Cc: James Bottomley, Mike Christie, open-iscsi, linux-scsi,
	Anil Veerabhadrappa, Benjamin Li


On Thu, 2011-07-14 at 17:29 -0700, Michael Chan wrote:
> On Thu, 2011-07-14 at 16:42 -0700, Eddie Wai wrote:
> > A kernel panic was observed when passing the sc->request->cpu = -1 to
> > retrieve the per_cpu variable pointer:
> >  #0 [ffff880011203960] machine_kexec at ffffffff81022bc3
> >  #1 [ffff8800112039b0] crash_kexec at ffffffff81088630
> >  #2 [ffff880011203a80] __die at ffffffff8139ea20
> >  #3 [ffff880011203aa0] no_context at ffffffff8102f3a7
> >  #4 [ffff880011203ae0] __bad_area_nosemaphore at ffffffff8102f665
> >  #5 [ffff880011203ba0] retint_signal at ffffffff8139dd1f
> >  #6 [ffff880011203cc8] bnx2i_indicate_kcqe at ffffffffa03dc4f2
> >  #7 [ffff880011203da8] service_kcqes at ffffffffa03cb04f
> >  #8 [ffff880011203e68] cnic_service_bnx2x_kcq at ffffffffa03cb14a
> >  #9 [ffff880011203e88] cnic_service_bnx2x_bh at ffffffffa03cb1b3
> > 
> > The problem lies in the sg_io (and perhaps sg_scsi_ioctl) call to
> > blk_get_request->get_request/wait->blk_alloc_request->blk_rq_init which
> > re-initializes the request->cpu to -1.  There is no assignment for cpu from
> > that to the request_fn call to low level drivers.
> > 
> > When this happens, the sc->request->cpu will be using the init value of
> > -1.  This will create a kernel panic when it hits bnx2i because the code
> > refers it to get the per_cpu variables ptr.
> > 
> > This change is to put in a guard against that and also for cases when
> > bio affinity/queue completion to the same cpu is not enabled.  In those
> > cases, the request->cpu will remain a -1 also.
> > 
> > This bug was created from commit:  b5cf6b63f73abdc051035f0050b367beeb2ef94c
> > 
> > For the case when the blk layer did not setup the request->cpu, bnx2i
> > will complete the sc with the current CPU of the thread.
> > 
> > Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
> > ---
> >  drivers/scsi/bnx2i/bnx2i_hwi.c |    9 ++++++++-
> >  1 files changed, 8 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
> > index 54978c1..0e71615 100644
> > --- a/drivers/scsi/bnx2i/bnx2i_hwi.c
> > +++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
> > @@ -1901,6 +1901,7 @@ static int bnx2i_queue_scsi_cmd_resp(struct iscsi_session *session,
> >  	struct iscsi_task *task;
> >  	struct scsi_cmnd *sc;
> >  	int rc = 0;
> > +	int cpu;
> >  
> >  	spin_lock(&session->lock);
> >  	task = iscsi_itt_to_task(bnx2i_conn->cls_conn->dd_data,
> > @@ -1912,7 +1913,13 @@ static int bnx2i_queue_scsi_cmd_resp(struct iscsi_session *session,
> >  	sc = task->sc;
> >  	spin_unlock(&session->lock);
> >  
> > -	p = &per_cpu(bnx2i_percpu, sc->request->cpu);
> > +	if (!blk_rq_cpu_valid(sc->request)) {
> > +		cpu = get_cpu();
> > +		put_cpu();
> 
> Why not just use smp_processor_id()?
Good point.  This is run inside a tasklet which preemption is already
disabled.  I'll make the change, thanks.
> 
> > +	} else
> > +		cpu = sc->request->cpu;
> > +
> > +	p = &per_cpu(bnx2i_percpu, cpu);
> >  	spin_lock(&p->p_work_lock);
> >  	if (unlikely(!p->iothread)) {
> >  		rc = -EINVAL;
> 



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH v3] BNX2I: Fixed kernel panic due to illegal usage of sc->request->cpu
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (96 preceding siblings ...)
  2011-07-14 23:42 ` [PATCH v2] " Eddie Wai
@ 2011-07-15 18:17 ` Eddie Wai
  2012-04-25 22:03 ` [PATCH 1/2] BNX2I: Added the setting of target can_queue via target_alloc Eddie Wai
                   ` (11 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2011-07-15 18:17 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

A kernel panic was observed when passing the sc->request->cpu = -1 to
retrieve the per_cpu variable pointer:
 #0 [ffff880011203960] machine_kexec at ffffffff81022bc3
 #1 [ffff8800112039b0] crash_kexec at ffffffff81088630
 #2 [ffff880011203a80] __die at ffffffff8139ea20
 #3 [ffff880011203aa0] no_context at ffffffff8102f3a7
 #4 [ffff880011203ae0] __bad_area_nosemaphore at ffffffff8102f665
 #5 [ffff880011203ba0] retint_signal at ffffffff8139dd1f
 #6 [ffff880011203cc8] bnx2i_indicate_kcqe at ffffffffa03dc4f2
 #7 [ffff880011203da8] service_kcqes at ffffffffa03cb04f
 #8 [ffff880011203e68] cnic_service_bnx2x_kcq at ffffffffa03cb14a
 #9 [ffff880011203e88] cnic_service_bnx2x_bh at ffffffffa03cb1b3

The problem lies in the slow path sg_io (and perhaps sg_scsi_ioctl) call to
blk_get_request->get_request/wait->blk_alloc_request->blk_rq_init which
re-initializes the request->cpu to -1.  There is no assignment for cpu from
that to the request_fn call to low level drivers.

When this happens, the sc->request->cpu will be using the init value of
-1.  This will create a kernel panic when it hits bnx2i because the code
refers it to get the per_cpu variables ptr.

This change is to put in a guard against that and also for cases when
bio affinity/queue completion to the same cpu is not enabled.  In those
cases, the request->cpu will remain a -1 also.

This bug was created from commit:  b5cf6b63f73abdc051035f0050b367beeb2ef94c

For the case when the blk layer did not setup the request->cpu, bnx2i
will complete the sc with the current CPU of the thread.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 54978c1..28c6693 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1901,6 +1901,7 @@ static int bnx2i_queue_scsi_cmd_resp(struct iscsi_session *session,
 	struct iscsi_task *task;
 	struct scsi_cmnd *sc;
 	int rc = 0;
+	int cpu;
 
 	spin_lock(&session->lock);
 	task = iscsi_itt_to_task(bnx2i_conn->cls_conn->dd_data,
@@ -1912,7 +1913,12 @@ static int bnx2i_queue_scsi_cmd_resp(struct iscsi_session *session,
 	sc = task->sc;
 	spin_unlock(&session->lock);
 
-	p = &per_cpu(bnx2i_percpu, sc->request->cpu);
+	if (!blk_rq_cpu_valid(sc->request))
+		cpu = smp_processor_id();
+	else
+		cpu = sc->request->cpu;
+
+	p = &per_cpu(bnx2i_percpu, cpu);
 	spin_lock(&p->p_work_lock);
 	if (unlikely(!p->iothread)) {
 		rc = -EINVAL;
-- 
1.7.0.5



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH] BNX2I: Fixed the override of the error_mask module param
       [not found] ` <Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
                     ` (6 preceding siblings ...)
  2010-11-23 23:29   ` [PATCH v3 07/13] BNX2I: Added mutex lock protection to conn_get_param Eddie Wai
@ 2012-02-02 23:22   ` Eddie Wai
  2012-08-21 17:35   ` [PATCH] BNX2I: Fixed NULL ptr deference for 1G bnx2 Linux iSCSI offload Eddie Wai
                     ` (3 subsequent siblings)
  11 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2012-02-02 23:22 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The error_mask module param overrides has a bug which prevented
the new module param values to take effect.

Also changed the type attribute of the error_mask1/2 module params
from int to uint to allow the MSB to be set.

Signed-off-by: Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Acked-by: Anil Veerabhadrappa <anilgv-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>

---
 drivers/scsi/bnx2i/bnx2i_hwi.c  |   12 ++++++++----
 drivers/scsi/bnx2i/bnx2i_init.c |    4 ++--
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 1ad0b82..f9d6f41 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1312,14 +1312,18 @@ int bnx2i_send_fw_iscsi_init_msg(struct bnx2i_hba *hba)
 		  ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_EXP_DATASN) |
 		/* EMC */
 		(1ULL << ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_LUN));
-	if (error_mask1)
+	if (error_mask1) {
 		iscsi_init2.error_bit_map[0] = error_mask1;
-	else
+		mask64 &= (u32)(~mask64);
+		mask64 |= error_mask1;
+	} else
 		iscsi_init2.error_bit_map[0] = (u32) mask64;
 
-	if (error_mask2)
+	if (error_mask2) {
 		iscsi_init2.error_bit_map[1] = error_mask2;
-	else
+		mask64 &= 0xffffffff;
+		mask64 |= ((u64)error_mask2 << 32);
+	} else
 		iscsi_init2.error_bit_map[1] = (u32) (mask64 >> 32);
 
 	iscsi_error_mask = mask64;
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 1a947f1..cc5a6c1 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -49,11 +49,11 @@ module_param(en_tcp_dack, int, 0664);
 MODULE_PARM_DESC(en_tcp_dack, "Enable TCP Delayed ACK");
 
 unsigned int error_mask1 = 0x00;
-module_param(error_mask1, int, 0664);
+module_param(error_mask1, uint, 0664);
 MODULE_PARM_DESC(error_mask1, "Config FW iSCSI Error Mask #1");
 
 unsigned int error_mask2 = 0x00;
-module_param(error_mask2, int, 0664);
+module_param(error_mask2, uint, 0664);
 MODULE_PARM_DESC(error_mask2, "Config FW iSCSI Error Mask #2");
 
 unsigned int sq_size;
-- 
1.7.7.4


-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 1/2] BNX2I: Added the setting of target can_queue via target_alloc
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (97 preceding siblings ...)
  2011-07-15 18:17 ` [PATCH v3] " Eddie Wai
@ 2012-04-25 22:03 ` Eddie Wai
       [not found]   ` <1335391425-30410-1-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
  2012-04-25 22:08 ` [PATCH 2/2] BNX2I: Updated version and copyright year Eddie Wai
                   ` (10 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2012-04-25 22:03 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

This will set the target can_queue limit to the number of preallocated
session tasks set during creation.

"Could not send nopout" messages were observed without this when the
iSCSI connection experiences dropped frames under heavy I/O stress.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 1a44b45..e4029327 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -2244,6 +2244,7 @@ static struct scsi_host_template bnx2i_host_template = {
 	.eh_device_reset_handler = iscsi_eh_device_reset,
 	.eh_target_reset_handler = iscsi_eh_recover_target,
 	.change_queue_depth	= iscsi_change_queue_depth,
+	.target_alloc		= iscsi_target_alloc,
 	.can_queue		= 2048,
 	.max_sectors		= 127,
 	.cmd_per_lun		= 128,
-- 
1.7.7.4



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 2/2] BNX2I: Updated version and copyright year
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (98 preceding siblings ...)
  2012-04-25 22:03 ` [PATCH 1/2] BNX2I: Added the setting of target can_queue via target_alloc Eddie Wai
@ 2012-04-25 22:08 ` Eddie Wai
  2012-06-29 23:37 ` [PATCH] BNX2I: Removed the reference to the netdev->base_addr Eddie Wai
                   ` (9 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2012-04-25 22:08 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Old version: 2.7.0.3
New version: 2.7.2.2

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/57xx_iscsi_constants.h |    2 +-
 drivers/scsi/bnx2i/57xx_iscsi_hsi.h       |    2 +-
 drivers/scsi/bnx2i/bnx2i.h                |    2 +-
 drivers/scsi/bnx2i/bnx2i_hwi.c            |    2 +-
 drivers/scsi/bnx2i/bnx2i_init.c           |    6 +++---
 drivers/scsi/bnx2i/bnx2i_iscsi.c          |    2 +-
 drivers/scsi/bnx2i/bnx2i_sysfs.c          |    2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/bnx2i/57xx_iscsi_constants.h b/drivers/scsi/bnx2i/57xx_iscsi_constants.h
index 495a841..25093a0 100644
--- a/drivers/scsi/bnx2i/57xx_iscsi_constants.h
+++ b/drivers/scsi/bnx2i/57xx_iscsi_constants.h
@@ -1,6 +1,6 @@
 /* 57xx_iscsi_constants.h: Broadcom NetXtreme II iSCSI HSI
  *
- * Copyright (c) 2006 - 2011 Broadcom Corporation
+ * Copyright (c) 2006 - 2012 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/bnx2i/57xx_iscsi_hsi.h b/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
index 72118db..dc0a08e 100644
--- a/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
+++ b/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
@@ -1,6 +1,6 @@
 /* 57xx_iscsi_hsi.h: Broadcom NetXtreme II iSCSI HSI.
  *
- * Copyright (c) 2006 - 2011 Broadcom Corporation
+ * Copyright (c) 2006 - 2012 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 0bd70e8..0c53c28 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -1,6 +1,6 @@
 /* bnx2i.h: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2011 Broadcom Corporation
+ * Copyright (c) 2006 - 2012 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index f9d6f41..ece47e5 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1,6 +1,6 @@
 /* bnx2i_hwi.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2011 Broadcom Corporation
+ * Copyright (c) 2006 - 2012 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 4927cca..8b68167 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -1,6 +1,6 @@
 /* bnx2i.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2011 Broadcom Corporation
+ * Copyright (c) 2006 - 2012 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
@@ -18,8 +18,8 @@ static struct list_head adapter_list = LIST_HEAD_INIT(adapter_list);
 static u32 adapter_count;
 
 #define DRV_MODULE_NAME		"bnx2i"
-#define DRV_MODULE_VERSION	"2.7.0.3"
-#define DRV_MODULE_RELDATE	"Jun 15, 2011"
+#define DRV_MODULE_VERSION	"2.7.2.2"
+#define DRV_MODULE_RELDATE	"Apr 25, 2012"
 
 static char version[] __devinitdata =
 		"Broadcom NetXtreme II iSCSI Driver " DRV_MODULE_NAME \
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index e4029327..f8d516b 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1,7 +1,7 @@
 /*
  * bnx2i_iscsi.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2011 Broadcom Corporation
+ * Copyright (c) 2006 - 2012 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
diff --git a/drivers/scsi/bnx2i/bnx2i_sysfs.c b/drivers/scsi/bnx2i/bnx2i_sysfs.c
index 83a77f7..c61cf7a 100644
--- a/drivers/scsi/bnx2i/bnx2i_sysfs.c
+++ b/drivers/scsi/bnx2i/bnx2i_sysfs.c
@@ -1,6 +1,6 @@
 /* bnx2i_sysfs.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2004 - 2011 Broadcom Corporation
+ * Copyright (c) 2004 - 2012 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
-- 
1.7.7.4



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH 1/2] BNX2I: Added the setting of target can_queue via target_alloc
       [not found]   ` <1335391425-30410-1-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
@ 2012-04-26  3:48     ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2012-04-26  3:48 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 04/25/2012 05:03 PM, Eddie Wai wrote:
> This will set the target can_queue limit to the number of preallocated
> session tasks set during creation.
> 
> "Could not send nopout" messages were observed without this when the
> iSCSI connection experiences dropped frames under heavy I/O stress.
> 
> Signed-off-by: Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>


Both patches look ok to me.

Reviewed-by: Mike Christie <michaelc-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>

-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH] BNX2I: Removed the reference to the netdev->base_addr
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (99 preceding siblings ...)
  2012-04-25 22:08 ` [PATCH 2/2] BNX2I: Updated version and copyright year Eddie Wai
@ 2012-06-29 23:37 ` Eddie Wai
       [not found]   ` <1341013055-16339-1-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
  2012-10-23  0:53 ` [PATCH] LIBISCSI: Added the new boot_nic entry in the session sysfs Eddie Wai
                   ` (8 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2012-06-29 23:37 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

The netdev->base_addr parameter has been deprecated in the L2 bnx2
driver.  This is used by bnx2i for the BARn iomapping.

This patch will directly reference the pci_resource_start instead
of using the deprecated netdev->base_addr.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/bnx2i.h       |    1 +
 drivers/scsi/bnx2i/bnx2i_hwi.c   |    3 +--
 drivers/scsi/bnx2i/bnx2i_iscsi.c |   10 +++++-----
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 0c53c28..7e77cf6 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -350,6 +350,7 @@ struct bnx2i_hba {
 	struct pci_dev *pcidev;
 	struct net_device *netdev;
 	void __iomem *regview;
+	resource_size_t reg_base;
 
 	u32 age;
 	unsigned long cnic_dev_type;
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index ece47e5..86a12b4 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -2724,7 +2724,6 @@ int bnx2i_map_ep_dbell_regs(struct bnx2i_endpoint *ep)
 		goto arm_cq;
 	}
 
-	reg_base = ep->hba->netdev->base_addr;
 	if ((test_bit(BNX2I_NX2_DEV_5709, &ep->hba->cnic_dev_type)) &&
 	    (ep->hba->mail_queue_access == BNX2I_MQ_BIN_MODE)) {
 		config2 = REG_RD(ep->hba, BNX2_MQ_CONFIG2);
@@ -2740,7 +2739,7 @@ int bnx2i_map_ep_dbell_regs(struct bnx2i_endpoint *ep)
 		/* 5709 device in normal node and 5706/5708 devices */
 		reg_off = CTX_OFFSET + (MB_KERNEL_CTX_SIZE * cid_num);
 
-	ep->qp.ctx_base = ioremap_nocache(reg_base + reg_off,
+	ep->qp.ctx_base = ioremap_nocache(ep->hba->reg_base + reg_off,
 					  MB_KERNEL_CTX_SIZE);
 	if (!ep->qp.ctx_base)
 		return -ENOMEM;
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index f8d516b..621538b 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -811,13 +811,13 @@ struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic)
 	bnx2i_identify_device(hba);
 	bnx2i_setup_host_queue_size(hba, shost);
 
+	hba->reg_base = pci_resource_start(hba->pcidev, 0);
 	if (test_bit(BNX2I_NX2_DEV_5709, &hba->cnic_dev_type)) {
-		hba->regview = ioremap_nocache(hba->netdev->base_addr,
-					       BNX2_MQ_CONFIG2);
+		hba->regview = pci_iomap(hba->pcidev, 0, BNX2_MQ_CONFIG2);
 		if (!hba->regview)
 			goto ioreg_map_err;
 	} else if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type)) {
-		hba->regview = ioremap_nocache(hba->netdev->base_addr, 4096);
+		hba->regview = pci_iomap(hba->pcidev, 0, 4096);
 		if (!hba->regview)
 			goto ioreg_map_err;
 	}
@@ -884,7 +884,7 @@ cid_que_err:
 	bnx2i_free_mp_bdt(hba);
 mp_bdt_mem_err:
 	if (hba->regview) {
-		iounmap(hba->regview);
+		pci_iounmap(hba->pcidev, hba->regview);
 		hba->regview = NULL;
 	}
 ioreg_map_err:
@@ -910,7 +910,7 @@ void bnx2i_free_hba(struct bnx2i_hba *hba)
 	pci_dev_put(hba->pcidev);
 
 	if (hba->regview) {
-		iounmap(hba->regview);
+		pci_iounmap(hba->pcidev, hba->regview);
 		hba->regview = NULL;
 	}
 	bnx2i_free_mp_bdt(hba);
-- 
1.7.7.4



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH] BNX2I: Removed the reference to the netdev->base_addr
       [not found]   ` <1341013055-16339-1-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
@ 2012-06-30  2:41     ` Mike Christie
  2012-07-03 22:06       ` Eddie Wai
  0 siblings, 1 reply; 189+ messages in thread
From: Mike Christie @ 2012-06-30  2:41 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 06/29/2012 06:37 PM, Eddie Wai wrote:
> The netdev->base_addr parameter has been deprecated in the L2 bnx2
> driver.  This is used by bnx2i for the BARn iomapping.
>
> This patch will directly reference the pci_resource_start instead
> of using the deprecated netdev->base_addr.
>
> Signed-off-by: Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>


Looks ok to me

Reviewed-by: Mike Christie <michaelc-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>

-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH] BNX2I: Removed the reference to the netdev->base_addr
  2012-06-30  2:41     ` Mike Christie
@ 2012-07-03 22:06       ` Eddie Wai
  0 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2012-07-03 22:06 UTC (permalink / raw)
  To: Mike Christie
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

Thanks, Mike.

Hello James,

This patch is actually a critical bug fix as the 1G bnx2 driver no
longer supports the netdev->base_addr in the current kernel of the scsi
tree.  This means that Broadcom's 1G Linux iSCSI offload solution would
not work at all without this patch.  If at all possible, please consider
including this patch into the fixes branch.

Thanks,
Eddie

On Fri, 2012-06-29 at 21:41 -0500, Mike Christie wrote:
> On 06/29/2012 06:37 PM, Eddie Wai wrote:
> > The netdev->base_addr parameter has been deprecated in the L2 bnx2
> > driver.  This is used by bnx2i for the BARn iomapping.
> >
> > This patch will directly reference the pci_resource_start instead
> > of using the deprecated netdev->base_addr.
> >
> > Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
> 
> 
> Looks ok to me
> 
> Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
> 



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH] BNX2I: Fixed NULL ptr deference for 1G bnx2 Linux iSCSI offload
       [not found] ` <Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
                     ` (7 preceding siblings ...)
  2012-02-02 23:22   ` [PATCH] BNX2I: Fixed the override of the error_mask module param Eddie Wai
@ 2012-08-21 17:35   ` Eddie Wai
       [not found]     ` <1345570553-23067-1-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
  2012-10-16  0:31   ` [PATCH] BNX2I: Removed the individual PCI DEVICE ID checking Eddie Wai
                     ` (2 subsequent siblings)
  11 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2012-08-21 17:35 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai,
	stable-DgEjT+Ai2ygdnm+yROfE0A

This patch fixes the following kernel panic invoked by uninitialized fields
in the chip initialization for the 1G bnx2 iSCSI offload.

One of the bits in the chip initialization is being used by the latest
firmware to control overflow packets.  When this control bit gets enabled
erroneously, it would ultimately result in a bad packet placement which would
cause the bnx2 driver to dereference a NULL ptr in the placement handler.

This can happen under certain stress I/O environment under the Linux
iSCSI offload operation.

This change only affects Broadcom's 5709 chipset.

Unable to handle kernel NULL pointer dereference at 0000000000000008 RIP:
 [<ffffffff881f0e7d>] :bnx2:bnx2_poll_work+0xd0d/0x13c5
Pid: 0, comm: swapper Tainted: G     ---- 2.6.18-333.el5debug #2
RIP: 0010:[<ffffffff881f0e7d>]  [<ffffffff881f0e7d>] :bnx2:bnx2_poll_work+0xd0d/0x13c5
RSP: 0018:ffff8101b575bd50  EFLAGS: 00010216
RAX: 0000000000000005 RBX: ffff81007c5fb180 RCX: 0000000000000000
RDX: 0000000000000ffc RSI: 00000000817e8000 RDI: 0000000000000220
RBP: ffff81015bbd7ec0 R08: ffff8100817e9000 R09: 0000000000000000
R10: ffff81007c5fb180 R11: 00000000000000c8 R12: 000000007a25a010
R13: 0000000000000000 R14: 0000000000000005 R15: ffff810159f80558
FS:  0000000000000000(0000) GS:ffff8101afebc240(0000) knlGS:0000000000000000
CS:  0010 DS: 0018 ES: 0018 CR0: 000000008005003b
CR2: 0000000000000008 CR3: 0000000000201000 CR4: 00000000000006a0
Process swapper (pid: 0, threadinfo ffff8101b5754000, task ffff8101afebd820)
Stack:  000000000000000b ffff810159f80000 0000000000000040 ffff810159f80520
 ffff810159f80500 00cf00cf8008e84b ffffc200100939e0 ffff810009035b20
 0000502900000000 000000be00000001 ffff8100817e7810 00d08101b575bea8
Call Trace:
 <IRQ>  [<ffffffff8008e0d0>] show_schedstat+0x1c2/0x25b
 [<ffffffff881f1886>] :bnx2:bnx2_poll+0xf6/0x231
 [<ffffffff8000c9b9>] net_rx_action+0xac/0x1b1
 [<ffffffff800125a0>] __do_softirq+0x89/0x133
 [<ffffffff8005e30c>] call_softirq+0x1c/0x28
 [<ffffffff8006d5de>] do_softirq+0x2c/0x7d
 [<ffffffff8006d46e>] do_IRQ+0xee/0xf7
 [<ffffffff8005d625>] ret_from_intr+0x0/0xa
 <EOI>  [<ffffffff801a5780>] acpi_processor_idle_simple+0x1c5/0x341
 [<ffffffff801a573d>] acpi_processor_idle_simple+0x182/0x341
 [<ffffffff801a55bb>] acpi_processor_idle_simple+0x0/0x341
 [<ffffffff80049560>] cpu_idle+0x95/0xb8
 [<ffffffff80078b1c>] start_secondary+0x479/0x488

Signed-off-by: Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Cc: stable-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
---
 drivers/scsi/bnx2i/bnx2i_hwi.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 86a12b4..3878e62 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1264,6 +1264,9 @@ int bnx2i_send_fw_iscsi_init_msg(struct bnx2i_hba *hba)
 	int rc = 0;
 	u64 mask64;
 
+	memset(&iscsi_init, 0x00, sizeof(struct iscsi_kwqe_init1));
+	memset(&iscsi_init2, 0x00, sizeof(struct iscsi_kwqe_init2));
+
 	bnx2i_adjust_qp_size(hba);
 
 	iscsi_init.flags =
-- 
1.7.7.4


-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH] BNX2I: Fixed NULL ptr deference for 1G bnx2 Linux iSCSI offload
       [not found]     ` <1345570553-23067-1-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
@ 2012-08-21 17:41       ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2012-08-21 17:41 UTC (permalink / raw)
  To: Eddie Wai
  Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, stable-DgEjT+Ai2ygdnm+yROfE0A

On 08/21/2012 12:35 PM, Eddie Wai wrote:
> This patch fixes the following kernel panic invoked by uninitialized fields
> in the chip initialization for the 1G bnx2 iSCSI offload.
> 
> One of the bits in the chip initialization is being used by the latest
> firmware to control overflow packets.  When this control bit gets enabled
> erroneously, it would ultimately result in a bad packet placement which would
> cause the bnx2 driver to dereference a NULL ptr in the placement handler.
> 
> This can happen under certain stress I/O environment under the Linux
> iSCSI offload operation.
> 
> This change only affects Broadcom's 5709 chipset.
> 
> Unable to handle kernel NULL pointer dereference at 0000000000000008 RIP:
>  [<ffffffff881f0e7d>] :bnx2:bnx2_poll_work+0xd0d/0x13c5
> Pid: 0, comm: swapper Tainted: G     ---- 2.6.18-333.el5debug #2
> RIP: 0010:[<ffffffff881f0e7d>]  [<ffffffff881f0e7d>] :bnx2:bnx2_poll_work+0xd0d/0x13c5
> RSP: 0018:ffff8101b575bd50  EFLAGS: 00010216
> RAX: 0000000000000005 RBX: ffff81007c5fb180 RCX: 0000000000000000
> RDX: 0000000000000ffc RSI: 00000000817e8000 RDI: 0000000000000220
> RBP: ffff81015bbd7ec0 R08: ffff8100817e9000 R09: 0000000000000000
> R10: ffff81007c5fb180 R11: 00000000000000c8 R12: 000000007a25a010
> R13: 0000000000000000 R14: 0000000000000005 R15: ffff810159f80558
> FS:  0000000000000000(0000) GS:ffff8101afebc240(0000) knlGS:0000000000000000
> CS:  0010 DS: 0018 ES: 0018 CR0: 000000008005003b
> CR2: 0000000000000008 CR3: 0000000000201000 CR4: 00000000000006a0
> Process swapper (pid: 0, threadinfo ffff8101b5754000, task ffff8101afebd820)
> Stack:  000000000000000b ffff810159f80000 0000000000000040 ffff810159f80520
>  ffff810159f80500 00cf00cf8008e84b ffffc200100939e0 ffff810009035b20
>  0000502900000000 000000be00000001 ffff8100817e7810 00d08101b575bea8
> Call Trace:
>  <IRQ>  [<ffffffff8008e0d0>] show_schedstat+0x1c2/0x25b
>  [<ffffffff881f1886>] :bnx2:bnx2_poll+0xf6/0x231
>  [<ffffffff8000c9b9>] net_rx_action+0xac/0x1b1
>  [<ffffffff800125a0>] __do_softirq+0x89/0x133
>  [<ffffffff8005e30c>] call_softirq+0x1c/0x28
>  [<ffffffff8006d5de>] do_softirq+0x2c/0x7d
>  [<ffffffff8006d46e>] do_IRQ+0xee/0xf7
>  [<ffffffff8005d625>] ret_from_intr+0x0/0xa
>  <EOI>  [<ffffffff801a5780>] acpi_processor_idle_simple+0x1c5/0x341
>  [<ffffffff801a573d>] acpi_processor_idle_simple+0x182/0x341
>  [<ffffffff801a55bb>] acpi_processor_idle_simple+0x0/0x341
>  [<ffffffff80049560>] cpu_idle+0x95/0xb8
>  [<ffffffff80078b1c>] start_secondary+0x479/0x488
> 
> Signed-off-by: Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
> Cc: stable-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
> ---
>  drivers/scsi/bnx2i/bnx2i_hwi.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
> index 86a12b4..3878e62 100644
> --- a/drivers/scsi/bnx2i/bnx2i_hwi.c
> +++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
> @@ -1264,6 +1264,9 @@ int bnx2i_send_fw_iscsi_init_msg(struct bnx2i_hba *hba)
>  	int rc = 0;
>  	u64 mask64;
>  
> +	memset(&iscsi_init, 0x00, sizeof(struct iscsi_kwqe_init1));
> +	memset(&iscsi_init2, 0x00, sizeof(struct iscsi_kwqe_init2));
> +
>  	bnx2i_adjust_qp_size(hba);
>  
>  	iscsi_init.flags =
> 

Seems ok to me.

Reviewed-by: Mike Christie <michaelc-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>

-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH] BNX2I: Removed the individual PCI DEVICE ID checking
       [not found] ` <Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
                     ` (8 preceding siblings ...)
  2012-08-21 17:35   ` [PATCH] BNX2I: Fixed NULL ptr deference for 1G bnx2 Linux iSCSI offload Eddie Wai
@ 2012-10-16  0:31   ` Eddie Wai
  2012-10-24  7:02     ` Mike Christie
  2013-02-20  2:30   ` [PATCH] SCSI: amd_iommu dma_boundary overflow Eddie Wai
  2013-09-18  5:30   ` [PATCH 0/4] Fixed a race condition and a rtnl_lock deadlock for bnx2fc Eddie Wai
  11 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2012-10-16  0:31 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

Removed the individual PCI DEVICE ID checking inside bnx2i.  The device
type can easily be read from the corresponding cnic->flags.  This will
free bnx2i from having to get updated for every new device ID that gets
added.

Signed-off-by: Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Acked-by: Michael Chan <mchan-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
---
 drivers/scsi/bnx2i/bnx2i.h       |    2 +-
 drivers/scsi/bnx2i/bnx2i_init.c  |   43 +++++++++++++++-----------------------
 drivers/scsi/bnx2i/bnx2i_iscsi.c |    2 +-
 3 files changed, 19 insertions(+), 28 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 3f9e706..b44d04e 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -800,7 +800,7 @@ extern struct device_attribute *bnx2i_dev_attributes[];
 /*
  * Function Prototypes
  */
-extern void bnx2i_identify_device(struct bnx2i_hba *hba);
+extern void bnx2i_identify_device(struct bnx2i_hba *hba, struct cnic_dev *dev);
 
 extern void bnx2i_ulp_init(struct cnic_dev *dev);
 extern void bnx2i_ulp_exit(struct cnic_dev *dev);
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index b17637a..ee009e4ad 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -79,42 +79,33 @@ static struct notifier_block bnx2i_cpu_notifier = {
 /**
  * bnx2i_identify_device - identifies NetXtreme II device type
  * @hba: 		Adapter structure pointer
+ * @cnic:		Corresponding cnic device
  *
  * This function identifies the NX2 device type and sets appropriate
  *	queue mailbox register access method, 5709 requires driver to
  *	access MBOX regs using *bin* mode
  */
-void bnx2i_identify_device(struct bnx2i_hba *hba)
+void bnx2i_identify_device(struct bnx2i_hba *hba, struct cnic_dev *dev)
 {
 	hba->cnic_dev_type = 0;
-	if ((hba->pci_did == PCI_DEVICE_ID_NX2_5706) ||
-	    (hba->pci_did == PCI_DEVICE_ID_NX2_5706S))
-		set_bit(BNX2I_NX2_DEV_5706, &hba->cnic_dev_type);
-	else if ((hba->pci_did == PCI_DEVICE_ID_NX2_5708) ||
-	    (hba->pci_did == PCI_DEVICE_ID_NX2_5708S))
-		set_bit(BNX2I_NX2_DEV_5708, &hba->cnic_dev_type);
-	else if ((hba->pci_did == PCI_DEVICE_ID_NX2_5709) ||
-	    (hba->pci_did == PCI_DEVICE_ID_NX2_5709S)) {
-		set_bit(BNX2I_NX2_DEV_5709, &hba->cnic_dev_type);
-		hba->mail_queue_access = BNX2I_MQ_BIN_MODE;
-	} else if (hba->pci_did == PCI_DEVICE_ID_NX2_57710    ||
-		   hba->pci_did == PCI_DEVICE_ID_NX2_57711    ||
-		   hba->pci_did == PCI_DEVICE_ID_NX2_57711E   ||
-		   hba->pci_did == PCI_DEVICE_ID_NX2_57712    ||
-		   hba->pci_did == PCI_DEVICE_ID_NX2_57712E   ||
-		   hba->pci_did == PCI_DEVICE_ID_NX2_57800    ||
-		   hba->pci_did == PCI_DEVICE_ID_NX2_57800_MF ||
-		   hba->pci_did == PCI_DEVICE_ID_NX2_57800_VF ||
-		   hba->pci_did == PCI_DEVICE_ID_NX2_57810    ||
-		   hba->pci_did == PCI_DEVICE_ID_NX2_57810_MF ||
-		   hba->pci_did == PCI_DEVICE_ID_NX2_57810_VF ||
-		   hba->pci_did == PCI_DEVICE_ID_NX2_57840    ||
-		   hba->pci_did == PCI_DEVICE_ID_NX2_57840_MF ||
-		   hba->pci_did == PCI_DEVICE_ID_NX2_57840_VF)
+	if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) {
+		if (hba->pci_did == PCI_DEVICE_ID_NX2_5706 ||
+		    hba->pci_did == PCI_DEVICE_ID_NX2_5706S) {
+			set_bit(BNX2I_NX2_DEV_5706, &hba->cnic_dev_type);
+		} else if (hba->pci_did == PCI_DEVICE_ID_NX2_5708 ||
+		    hba->pci_did == PCI_DEVICE_ID_NX2_5708S) {
+			set_bit(BNX2I_NX2_DEV_5708, &hba->cnic_dev_type);
+		} else if (hba->pci_did == PCI_DEVICE_ID_NX2_5709 ||
+		    hba->pci_did == PCI_DEVICE_ID_NX2_5709S) {
+			set_bit(BNX2I_NX2_DEV_5709, &hba->cnic_dev_type);
+			hba->mail_queue_access = BNX2I_MQ_BIN_MODE;
+		}
+	} else if (test_bit(CNIC_F_BNX2X_CLASS, &dev->flags)) {
 		set_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type);
-	else
+	} else {
 		printk(KERN_ALERT "bnx2i: unknown device, 0x%x\n",
 				  hba->pci_did);
+	}
 }
 
 
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 3b34c13..0056e47 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -808,7 +808,7 @@ struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic)
 	hba->pci_func = PCI_FUNC(hba->pcidev->devfn);
 	hba->pci_devno = PCI_SLOT(hba->pcidev->devfn);
 
-	bnx2i_identify_device(hba);
+	bnx2i_identify_device(hba, cnic);
 	bnx2i_setup_host_queue_size(hba, shost);
 
 	hba->reg_base = pci_resource_start(hba->pcidev, 0);
-- 
1.7.7.4


-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH] LIBISCSI: Added the new boot_nic entry in the session sysfs
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (100 preceding siblings ...)
  2012-06-29 23:37 ` [PATCH] BNX2I: Removed the reference to the netdev->base_addr Eddie Wai
@ 2012-10-23  0:53 ` Eddie Wai
  2013-06-20 17:21 ` [PATCH v2] LIBISCSI: Added new boot entries " Eddie Wai
                   ` (7 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2012-10-23  0:53 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li, Eddie Wai

This is the kernel part of the modification to extract the net params
from the ibft sysfs to the iface struct used for the connection
request upon sync_session in the open-iscsi util.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/libiscsi.c             |    6 ++++++
 drivers/scsi/scsi_transport_iscsi.c |    4 ++++
 include/scsi/iscsi_if.h             |    2 ++
 include/scsi/libiscsi.h             |    2 ++
 4 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 82c3fd4..4f4c154 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -2809,6 +2809,7 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
 	kfree(session->targetname);
 	kfree(session->targetalias);
 	kfree(session->initiatorname);
+	kfree(session->boot_nic);
 	kfree(session->ifacename);
 
 	iscsi_destroy_session(cls_session);
@@ -3248,6 +3249,8 @@ int iscsi_set_param(struct iscsi_cls_conn *cls_conn,
 		return iscsi_switch_str_param(&session->ifacename, buf);
 	case ISCSI_PARAM_INITIATOR_NAME:
 		return iscsi_switch_str_param(&session->initiatorname, buf);
+	case ISCSI_PARAM_BOOT_NIC:
+		return iscsi_switch_str_param(&session->boot_nic, buf);
 	default:
 		return -ENOSYS;
 	}
@@ -3326,6 +3329,9 @@ int iscsi_session_get_param(struct iscsi_cls_session *cls_session,
 	case ISCSI_PARAM_INITIATOR_NAME:
 		len = sprintf(buf, "%s\n", session->initiatorname);
 		break;
+	case ISCSI_PARAM_BOOT_NIC:
+		len = sprintf(buf, "%s\n", session->boot_nic);
+		break;
 	default:
 		return -ENOSYS;
 	}
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 31969f2..2cc28fe 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -2484,6 +2484,7 @@ iscsi_session_attr(tgt_reset_tmo, ISCSI_PARAM_TGT_RESET_TMO, 0);
 iscsi_session_attr(ifacename, ISCSI_PARAM_IFACE_NAME, 0);
 iscsi_session_attr(initiatorname, ISCSI_PARAM_INITIATOR_NAME, 0);
 iscsi_session_attr(targetalias, ISCSI_PARAM_TARGET_ALIAS, 0);
+iscsi_session_attr(boot_nic, ISCSI_PARAM_BOOT_NIC, 0);
 
 static ssize_t
 show_priv_session_state(struct device *dev, struct device_attribute *attr,
@@ -2570,6 +2571,7 @@ static struct attribute *iscsi_session_attrs[] = {
 	&dev_attr_sess_ifacename.attr,
 	&dev_attr_sess_initiatorname.attr,
 	&dev_attr_sess_targetalias.attr,
+	&dev_attr_sess_boot_nic.attr,
 	&dev_attr_priv_sess_recovery_tmo.attr,
 	&dev_attr_priv_sess_state.attr,
 	&dev_attr_priv_sess_creator.attr,
@@ -2632,6 +2634,8 @@ static umode_t iscsi_session_attr_is_visible(struct kobject *kobj,
 		param = ISCSI_PARAM_INITIATOR_NAME;
 	else if (attr == &dev_attr_sess_targetalias.attr)
 		param = ISCSI_PARAM_TARGET_ALIAS;
+	else if (attr == &dev_attr_sess_boot_nic.attr)
+		param = ISCSI_PARAM_BOOT_NIC;
 	else if (attr == &dev_attr_priv_sess_recovery_tmo.attr)
 		return S_IRUGO | S_IWUSR;
 	else if (attr == &dev_attr_priv_sess_state.attr)
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index 917741b..874c8f3 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -452,6 +452,8 @@ enum iscsi_param {
 	ISCSI_PARAM_TGT_RESET_TMO,
 	ISCSI_PARAM_TARGET_ALIAS,
 
+	ISCSI_PARAM_BOOT_NIC,
+
 	ISCSI_PARAM_CHAP_IN_IDX,
 	ISCSI_PARAM_CHAP_OUT_IDX,
 	/* must always be last */
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 6e33386..7ba5cc8 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -287,6 +287,8 @@ struct iscsi_session {
 	char			*targetalias;
 	char			*ifacename;
 	char			*initiatorname;
+	char			*boot_nic;
+
 	/* control data */
 	struct iscsi_transport	*tt;
 	struct Scsi_Host	*host;
-- 
1.7.7.4



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH] BNX2I: Removed the individual PCI DEVICE ID checking
  2012-10-16  0:31   ` [PATCH] BNX2I: Removed the individual PCI DEVICE ID checking Eddie Wai
@ 2012-10-24  7:02     ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2012-10-24  7:02 UTC (permalink / raw)
  To: open-iscsi
  Cc: Eddie Wai, James Bottomley, linux-scsi, Michael Chan,
	Anil Veerabhadrappa, Ben Li

On 10/15/2012 07:31 PM, Eddie Wai wrote:
> Removed the individual PCI DEVICE ID checking inside bnx2i.  The device
> type can easily be read from the corresponding cnic->flags.  This will
> free bnx2i from having to get updated for every new device ID that gets
> added.
> 
> Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
> Acked-by: Michael Chan <mchan@broadcom.com>

Looks ok.

Reviewd-by: Mike Christie <michaelc@cs.wisc.edu>

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH] SCSI: amd_iommu dma_boundary overflow
       [not found] ` <Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
                     ` (9 preceding siblings ...)
  2012-10-16  0:31   ` [PATCH] BNX2I: Removed the individual PCI DEVICE ID checking Eddie Wai
@ 2013-02-20  2:30   ` Eddie Wai
  2013-02-20  9:37     ` James Bottomley
  2013-09-18  5:30   ` [PATCH 0/4] Fixed a race condition and a rtnl_lock deadlock for bnx2fc Eddie Wai
  11 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2013-02-20  2:30 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan, Eddie Wai

Hello,

For a 64-bit DMA capable PCIe storage HBA running under the 64-bit
AMD-VI IOMMU environment, the amd_iommu code was observed to hit an
overflow when it tries to page align the dma_parms->segment_boundary_mask.
This overflow would eventually trigger the BUG_ON in the iommu-helper's
iommu_is_span_boundary is_power_of_2 check.

A little back tracking shows that since the device is 64-bit DMA capable,
the pcidev->dma_mask was correctly set to DMA_BIT_MASK(64).  This dma_mask
was then transferred to the SCSI host's dma_boundary param (by the iSCSI
driver) and was eventually used to populate the q->limits.seg_boundary_mask
(via blk_queue_segment_boundary) and the dma_parms->segment_boundary_mask
(via dma_set_seg_boundary) during the scsi queue allocation.

The code seems correct as it make sense to impose the same hardware
segment boundary limit on both the blk queue and the DMA code.  It would
be an easy alternative to simply prevent the shost->dma_boundary from
being set to DMA_BIT_MASK(64), but it seems more correct to fix the
amd_iommu code itself to detect and handle this max 64-bit mask condition.

Please let me know your comments.

Thanks,
Eddie

Signed-off-by: Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
---
 drivers/iommu/amd_iommu.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index d90a421..63185a1 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1526,11 +1526,14 @@ static unsigned long dma_ops_area_alloc(struct device *dev,
 	unsigned long boundary_size;
 	unsigned long address = -1;
 	unsigned long limit;
+	unsigned long mask;
 
 	next_bit >>= PAGE_SHIFT;
 
-	boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1,
-			PAGE_SIZE) >> PAGE_SHIFT;
+	mask = dma_get_seg_boundary(dev);
+	boundary_size = mask + 1 ?
+			ALIGN(mask + 1, PAGE_SIZE) >> PAGE_SHIFT :
+			1UL << (BITS_PER_LONG - PAGE_SHIFT);
 
 	for (;i < max_index; ++i) {
 		unsigned long offset = dom->aperture[i]->offset >> PAGE_SHIFT;
-- 
1.7.7.4


-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
Visit this group at http://groups.google.com/group/open-iscsi?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH] SCSI: amd_iommu dma_boundary overflow
  2013-02-20  2:30   ` [PATCH] SCSI: amd_iommu dma_boundary overflow Eddie Wai
@ 2013-02-20  9:37     ` James Bottomley
  2013-02-21 10:19       ` Joerg Roedel
  0 siblings, 1 reply; 189+ messages in thread
From: James Bottomley @ 2013-02-20  9:37 UTC (permalink / raw)
  To: Eddie Wai
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan, Joerg Roedel

This is a bit tricky, since AMD laid off the team who were maintaining
this, but I added to the cc' one of the original maintainers in the
hopes they can take a look.

James


On Tue, 2013-02-19 at 18:30 -0800, Eddie Wai wrote:
> Hello,
> 
> For a 64-bit DMA capable PCIe storage HBA running under the 64-bit
> AMD-VI IOMMU environment, the amd_iommu code was observed to hit an
> overflow when it tries to page align the dma_parms->segment_boundary_mask.
> This overflow would eventually trigger the BUG_ON in the iommu-helper's
> iommu_is_span_boundary is_power_of_2 check.
> 
> A little back tracking shows that since the device is 64-bit DMA capable,
> the pcidev->dma_mask was correctly set to DMA_BIT_MASK(64).  This dma_mask
> was then transferred to the SCSI host's dma_boundary param (by the iSCSI
> driver) and was eventually used to populate the q->limits.seg_boundary_mask
> (via blk_queue_segment_boundary) and the dma_parms->segment_boundary_mask
> (via dma_set_seg_boundary) during the scsi queue allocation.
> 
> The code seems correct as it make sense to impose the same hardware
> segment boundary limit on both the blk queue and the DMA code.  It would
> be an easy alternative to simply prevent the shost->dma_boundary from
> being set to DMA_BIT_MASK(64), but it seems more correct to fix the
> amd_iommu code itself to detect and handle this max 64-bit mask condition.
> 
> Please let me know your comments.
> 
> Thanks,
> Eddie
> 
> Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
> ---
>  drivers/iommu/amd_iommu.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
> index d90a421..63185a1 100644
> --- a/drivers/iommu/amd_iommu.c
> +++ b/drivers/iommu/amd_iommu.c
> @@ -1526,11 +1526,14 @@ static unsigned long dma_ops_area_alloc(struct device *dev,
>  	unsigned long boundary_size;
>  	unsigned long address = -1;
>  	unsigned long limit;
> +	unsigned long mask;
>  
>  	next_bit >>= PAGE_SHIFT;
>  
> -	boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1,
> -			PAGE_SIZE) >> PAGE_SHIFT;
> +	mask = dma_get_seg_boundary(dev);
> +	boundary_size = mask + 1 ?
> +			ALIGN(mask + 1, PAGE_SIZE) >> PAGE_SHIFT :
> +			1UL << (BITS_PER_LONG - PAGE_SHIFT);
>  
>  	for (;i < max_index; ++i) {
>  		unsigned long offset = dom->aperture[i]->offset >> PAGE_SHIFT;


^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH] SCSI: amd_iommu dma_boundary overflow
  2013-02-20  9:37     ` James Bottomley
@ 2013-02-21 10:19       ` Joerg Roedel
  0 siblings, 0 replies; 189+ messages in thread
From: Joerg Roedel @ 2013-02-21 10:19 UTC (permalink / raw)
  To: James Bottomley
  Cc: Eddie Wai, Mike Christie, open-iscsi, linux-scsi, Michael Chan

Hi Eddie,

> On Tue, 2013-02-19 at 18:30 -0800, Eddie Wai wrote:
> > The code seems correct as it make sense to impose the same hardware
> > segment boundary limit on both the blk queue and the DMA code.  It would
> > be an easy alternative to simply prevent the shost->dma_boundary from
> > being set to DMA_BIT_MASK(64), but it seems more correct to fix the
> > amd_iommu code itself to detect and handle this max 64-bit mask condition.

Thanks for tracking this problem down. It turns out that this code does
not only exist in the AMD IOMMU driver but also in other ones (Calgary
and GART at least, havn't checked all).

> > --- a/drivers/iommu/amd_iommu.c
> > +++ b/drivers/iommu/amd_iommu.c
> > @@ -1526,11 +1526,14 @@ static unsigned long dma_ops_area_alloc(struct device *dev,
> >  	unsigned long boundary_size;
> >  	unsigned long address = -1;
> >  	unsigned long limit;
> > +	unsigned long mask;
> >  
> >  	next_bit >>= PAGE_SHIFT;
> >  
> > -	boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1,
> > -			PAGE_SIZE) >> PAGE_SHIFT;

Given that there is a BUG_ON() in the iommu-helpers which checks for
!is_power_of_2(boundary_size) I think we can simplify the this macro and
avoid the overflow in a more clever way:

	boundary_size = (dma_get_seg_boundary(dev) >> PAGE_SHIFT) + 1;

This should work because dma_get_seg_boundary(dev) really needs to be a
bitmask which becomes a power_of_2 on incrementing.


Regards,

	Joerg



^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH v2] LIBISCSI: Added new boot entries in the session sysfs
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (101 preceding siblings ...)
  2012-10-23  0:53 ` [PATCH] LIBISCSI: Added the new boot_nic entry in the session sysfs Eddie Wai
@ 2013-06-20 17:21 ` Eddie Wai
       [not found]   ` <1371748886-5018-1-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
  2013-07-12  0:15 ` [PATCH 1/2] BNX2I: Update version and copyright year 2013 Eddie Wai
                   ` (6 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2013-06-20 17:21 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan, Eddie Wai

v2: Moved the new BOOT params to the end of the iscsi_param enum

This is the kernel part of the modification to extract the net params
from the ibft sysfs to the iface struct used for the connection
request upon sync_session in the open-iscsi util.

Three new session sysfs params are defined:
boot_root - holds the name of the /sys/firmware/ibft or iscsi_rootN
boot_nic  - holds the ethernetN name
boot_target - holds the targetN name

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/libiscsi.c             |   18 ++++++++++++++++++
 drivers/scsi/scsi_transport_iscsi.c |   12 ++++++++++++
 include/scsi/iscsi_if.h             |    5 +++++
 include/scsi/libiscsi.h             |    4 ++++
 4 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 5de9469..ae69dfc 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -2808,6 +2808,9 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
 	kfree(session->targetname);
 	kfree(session->targetalias);
 	kfree(session->initiatorname);
+	kfree(session->boot_root);
+	kfree(session->boot_nic);
+	kfree(session->boot_target);
 	kfree(session->ifacename);
 
 	iscsi_destroy_session(cls_session);
@@ -3248,6 +3251,12 @@ int iscsi_set_param(struct iscsi_cls_conn *cls_conn,
 		return iscsi_switch_str_param(&session->ifacename, buf);
 	case ISCSI_PARAM_INITIATOR_NAME:
 		return iscsi_switch_str_param(&session->initiatorname, buf);
+	case ISCSI_PARAM_BOOT_ROOT:
+		return iscsi_switch_str_param(&session->boot_root, buf);
+	case ISCSI_PARAM_BOOT_NIC:
+		return iscsi_switch_str_param(&session->boot_nic, buf);
+	case ISCSI_PARAM_BOOT_TARGET:
+		return iscsi_switch_str_param(&session->boot_target, buf);
 	default:
 		return -ENOSYS;
 	}
@@ -3326,6 +3335,15 @@ int iscsi_session_get_param(struct iscsi_cls_session *cls_session,
 	case ISCSI_PARAM_INITIATOR_NAME:
 		len = sprintf(buf, "%s\n", session->initiatorname);
 		break;
+	case ISCSI_PARAM_BOOT_ROOT:
+		len = sprintf(buf, "%s\n", session->boot_root);
+		break;
+	case ISCSI_PARAM_BOOT_NIC:
+		len = sprintf(buf, "%s\n", session->boot_nic);
+		break;
+	case ISCSI_PARAM_BOOT_TARGET:
+		len = sprintf(buf, "%s\n", session->boot_target);
+		break;
 	default:
 		return -ENOSYS;
 	}
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 133926b..abf7c40 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -3473,6 +3473,9 @@ iscsi_session_attr(tgt_reset_tmo, ISCSI_PARAM_TGT_RESET_TMO, 0);
 iscsi_session_attr(ifacename, ISCSI_PARAM_IFACE_NAME, 0);
 iscsi_session_attr(initiatorname, ISCSI_PARAM_INITIATOR_NAME, 0);
 iscsi_session_attr(targetalias, ISCSI_PARAM_TARGET_ALIAS, 0);
+iscsi_session_attr(boot_root, ISCSI_PARAM_BOOT_ROOT, 0);
+iscsi_session_attr(boot_nic, ISCSI_PARAM_BOOT_NIC, 0);
+iscsi_session_attr(boot_target, ISCSI_PARAM_BOOT_TARGET, 0);
 
 static ssize_t
 show_priv_session_state(struct device *dev, struct device_attribute *attr,
@@ -3568,6 +3571,9 @@ static struct attribute *iscsi_session_attrs[] = {
 	&dev_attr_sess_ifacename.attr,
 	&dev_attr_sess_initiatorname.attr,
 	&dev_attr_sess_targetalias.attr,
+	&dev_attr_sess_boot_root.attr,
+	&dev_attr_sess_boot_nic.attr,
+	&dev_attr_sess_boot_target.attr,
 	&dev_attr_priv_sess_recovery_tmo.attr,
 	&dev_attr_priv_sess_state.attr,
 	&dev_attr_priv_sess_creator.attr,
@@ -3631,6 +3637,12 @@ static umode_t iscsi_session_attr_is_visible(struct kobject *kobj,
 		param = ISCSI_PARAM_INITIATOR_NAME;
 	else if (attr == &dev_attr_sess_targetalias.attr)
 		param = ISCSI_PARAM_TARGET_ALIAS;
+	else if (attr == &dev_attr_sess_boot_root.attr)
+		param = ISCSI_PARAM_BOOT_ROOT;
+	else if (attr == &dev_attr_sess_boot_nic.attr)
+		param = ISCSI_PARAM_BOOT_NIC;
+	else if (attr == &dev_attr_sess_boot_target.attr)
+		param = ISCSI_PARAM_BOOT_TARGET;
 	else if (attr == &dev_attr_priv_sess_recovery_tmo.attr)
 		return S_IRUGO | S_IWUSR;
 	else if (attr == &dev_attr_priv_sess_state.attr)
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index fe7f06c..9d28ded 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -489,6 +489,11 @@ enum iscsi_param {
 
 	ISCSI_PARAM_CHAP_IN_IDX,
 	ISCSI_PARAM_CHAP_OUT_IDX,
+
+	ISCSI_PARAM_BOOT_ROOT,
+	ISCSI_PARAM_BOOT_NIC,
+	ISCSI_PARAM_BOOT_TARGET,
+
 	/* must always be last */
 	ISCSI_PARAM_MAX,
 };
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 09c041e..4265a4b 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -287,6 +287,10 @@ struct iscsi_session {
 	char			*targetalias;
 	char			*ifacename;
 	char			*initiatorname;
+	char			*boot_root;
+	char			*boot_nic;
+	char			*boot_target;
+
 	/* control data */
 	struct iscsi_transport	*tt;
 	struct Scsi_Host	*host;
-- 
1.7.7.4



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH v2] LIBISCSI: Added new boot entries in the session sysfs
       [not found]   ` <1371748886-5018-1-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
@ 2013-06-20 17:24     ` Mike Christie
  0 siblings, 0 replies; 189+ messages in thread
From: Mike Christie @ 2013-06-20 17:24 UTC (permalink / raw)
  To: Eddie Wai; +Cc: James Bottomley, open-iscsi, linux-scsi, Michael Chan

On 06/20/2013 12:21 PM, Eddie Wai wrote:
> v2: Moved the new BOOT params to the end of the iscsi_param enum
> 
> This is the kernel part of the modification to extract the net params
> from the ibft sysfs to the iface struct used for the connection
> request upon sync_session in the open-iscsi util.
> 
> Three new session sysfs params are defined:
> boot_root - holds the name of the /sys/firmware/ibft or iscsi_rootN
> boot_nic  - holds the ethernetN name
> boot_target - holds the targetN name
> 
> Signed-off-by: Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>


Ok.

Reviewed-by: Mike Christie <michaelc-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>

-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
Visit this group at http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 1/2] BNX2I: Update version and copyright year 2013
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (102 preceding siblings ...)
  2013-06-20 17:21 ` [PATCH v2] LIBISCSI: Added new boot entries " Eddie Wai
@ 2013-07-12  0:15 ` Eddie Wai
  2013-07-12  0:15   ` [PATCH 2/2] MAINTAINER: Added maintainer info for bnx2i Eddie Wai
       [not found] ` <Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
                   ` (5 subsequent siblings)
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2013-07-12  0:15 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan, Eddie Wai

Old version: 2.7.2.2
New version: 2.7.6.2

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2i/57xx_iscsi_constants.h |    2 +-
 drivers/scsi/bnx2i/57xx_iscsi_hsi.h       |    2 +-
 drivers/scsi/bnx2i/bnx2i.h                |    2 +-
 drivers/scsi/bnx2i/bnx2i_hwi.c            |    2 +-
 drivers/scsi/bnx2i/bnx2i_init.c           |    6 +++---
 drivers/scsi/bnx2i/bnx2i_iscsi.c          |    2 +-
 drivers/scsi/bnx2i/bnx2i_sysfs.c          |    2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/bnx2i/57xx_iscsi_constants.h b/drivers/scsi/bnx2i/57xx_iscsi_constants.h
index 25093a0..3d33767 100644
--- a/drivers/scsi/bnx2i/57xx_iscsi_constants.h
+++ b/drivers/scsi/bnx2i/57xx_iscsi_constants.h
@@ -1,6 +1,6 @@
 /* 57xx_iscsi_constants.h: Broadcom NetXtreme II iSCSI HSI
  *
- * Copyright (c) 2006 - 2012 Broadcom Corporation
+ * Copyright (c) 2006 - 2013 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/bnx2i/57xx_iscsi_hsi.h b/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
index f2db5fe..37049e4 100644
--- a/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
+++ b/drivers/scsi/bnx2i/57xx_iscsi_hsi.h
@@ -1,6 +1,6 @@
 /* 57xx_iscsi_hsi.h: Broadcom NetXtreme II iSCSI HSI.
  *
- * Copyright (c) 2006 - 2012 Broadcom Corporation
+ * Copyright (c) 2006 - 2013 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index f109e3b..6940f09 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -1,6 +1,6 @@
 /* bnx2i.h: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2012 Broadcom Corporation
+ * Copyright (c) 2006 - 2013 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index a28b03e..af3e675 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1,6 +1,6 @@
 /* bnx2i_hwi.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2012 Broadcom Corporation
+ * Copyright (c) 2006 - 2013 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 50fef69..b6f6f43 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -1,6 +1,6 @@
 /* bnx2i.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2012 Broadcom Corporation
+ * Copyright (c) 2006 - 2013 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
@@ -18,8 +18,8 @@ static struct list_head adapter_list = LIST_HEAD_INIT(adapter_list);
 static u32 adapter_count;
 
 #define DRV_MODULE_NAME		"bnx2i"
-#define DRV_MODULE_VERSION	"2.7.2.2"
-#define DRV_MODULE_RELDATE	"Apr 25, 2012"
+#define DRV_MODULE_VERSION	"2.7.6.2"
+#define DRV_MODULE_RELDATE	"Jun 06, 2013"
 
 static char version[] =
 		"Broadcom NetXtreme II iSCSI Driver " DRV_MODULE_NAME \
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 0056e47..fabeb88 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1,7 +1,7 @@
 /*
  * bnx2i_iscsi.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2006 - 2012 Broadcom Corporation
+ * Copyright (c) 2006 - 2013 Broadcom Corporation
  * Copyright (c) 2007, 2008 Red Hat, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008 Mike Christie
  *
diff --git a/drivers/scsi/bnx2i/bnx2i_sysfs.c b/drivers/scsi/bnx2i/bnx2i_sysfs.c
index c61cf7a..a0a3d9f 100644
--- a/drivers/scsi/bnx2i/bnx2i_sysfs.c
+++ b/drivers/scsi/bnx2i/bnx2i_sysfs.c
@@ -1,6 +1,6 @@
 /* bnx2i_sysfs.c: Broadcom NetXtreme II iSCSI driver.
  *
- * Copyright (c) 2004 - 2012 Broadcom Corporation
+ * Copyright (c) 2004 - 2013 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
-- 
1.7.7.4



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 2/2] MAINTAINER: Added maintainer info for bnx2i
  2013-07-12  0:15 ` [PATCH 1/2] BNX2I: Update version and copyright year 2013 Eddie Wai
@ 2013-07-12  0:15   ` Eddie Wai
  0 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2013-07-12  0:15 UTC (permalink / raw)
  To: James Bottomley
  Cc: Mike Christie, open-iscsi, linux-scsi, Michael Chan, Eddie Wai

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 MAINTAINERS |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 50105f9..e297cb0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1816,6 +1816,12 @@ L:	linux-scsi@vger.kernel.org
 S:	Supported
 F:	drivers/scsi/bnx2fc/
 
+BROADCOM BNX2I 1/10 GIGABIT iSCSI DRIVER
+M:	Eddie Wai <eddie.wai@broadcom.com>
+L:	linux-scsi@vger.kernel.org
+S:	Supported
+F:	drivers/scsi/bnx2i/
+
 BROADCOM SPECIFIC AMBA DRIVER (BCMA)
 M:	Rafał Miłecki <zajec5@gmail.com>
 L:	linux-wireless@vger.kernel.org
-- 
1.7.7.4


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

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 0/4] Fixed a race condition and a rtnl_lock deadlock for bnx2fc
       [not found] ` <Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
                     ` (10 preceding siblings ...)
  2013-02-20  2:30   ` [PATCH] SCSI: amd_iommu dma_boundary overflow Eddie Wai
@ 2013-09-18  5:30   ` Eddie Wai
  11 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2013-09-18  5:30 UTC (permalink / raw)
  To: James Bottomley; +Cc: fcoe-devel, linux-scsi

Hello Robert and all,

My name is Eddie and I'm taking over for Bhanu as the new maintainer
for bnx2fc (I'm also the current maintainer for bnx2i).  Please include
me in all bnx2fc related discussions moving forward.  Thanks!

The following is a set of patches which fixes a race condition and a
rtnl_lock in bnx2fc as described.

The first patch fixes the race condition between bnx2fc's SCSI_CMD timeout
handling and the SCSI layer's task abort handling.  There is a situation
where the corresponding scsi_done for the timed out SCSI_CMD would never
get called.

The second patch fixes a rtnl_lock deadlock in the rmmod bnx2x path where
the fcoemon's write to the ctlr->enabled sysfs control param made the call
to bnx2fc_disable which contented for the rtnl_lock.  In this path of
operation, there is no need to lock the netdev nor the interface
as the ctlr is directly passed from the store_ctlr_enabled routine and
the interface cannot be released until the this sysfs write is finished
anyway.  The __bnx2fc_enable/disable routine can continue to persist
even after the bnx2fc_enable/disable are deprecated.

I've also bumped the version to 2.4.1 in an effort to align the upstream
and the out-of-tree releases of bnx2fc.

Comments are welcome.  Thanks.

Eddie

Eddie Wai (4):
  BNX2FC:  Fixed a SCSI CMD cmpl race condition between ABTS and
    CLEANUP
  BNX2FC: hung task timeout warning observed when rmmod bnx2x with
    active FCoE targets
  BNX2FC: Bump version from 1.0.14 to 2.4.1
  MAINTAINER: Updated maintainer info for bnx2fc

 MAINTAINERS                       |    2 +-
 drivers/scsi/bnx2fc/bnx2fc.h      |    2 +-
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c |   62 +++++++++++++++++++++++++++---------
 drivers/scsi/bnx2fc/bnx2fc_io.c   |    6 +++
 4 files changed, 54 insertions(+), 18 deletions(-)

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 1/4] BNX2FC: Fixed a SCSI CMD cmpl race condition between ABTS and CLEANUP
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (104 preceding siblings ...)
       [not found] ` <Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
@ 2013-09-18  5:33 ` Eddie Wai
  2013-09-18  5:33 ` [PATCH 2/4] BNX2FC: hung task timeout warning observed when rmmod bnx2x with active FCoE targets Eddie Wai
                   ` (3 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2013-09-18  5:33 UTC (permalink / raw)
  To: James Bottomley
  Cc: Robert Love, fcoe-devel, linux-scsi, Michael Chan, Eddie Wai

In the case when a SCSI_CMD times out, bnx2fc will initiate the sending of the
ABTS.  However, if the SCSI layer's SCSI command timer also times out, it'll
instantiate a task abort of the same xid.

The race condition this patch tries to fix is as follows:

SCSI_CMD timeout (20s)
thread 1                   thread 2
send ABTS
rx ABTS cmpl
                           task abort_eh
                           explicit LOGO since ABTS was engaged
                           CLEANUP cmpl
SCSI_CMD cmpl (ABTS cmpl)
instantiate RRQ
wait 10s
attempt to send RRQ (because of LOGO, it wouldn't continue)

Note that there is no call to scsi_done for this SCSI_CMD cmpletion
in this path.

The patch changes the path of execution to call scsi_done immediately
instead of instantiating the RRQ.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2fc/bnx2fc_io.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 575142e..ed88089 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -1246,6 +1246,12 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd)
 			kref_put(&io_req->refcount,
 				 bnx2fc_cmd_release); /* drop timer hold */
 		rc = bnx2fc_expl_logo(lport, io_req);
+		/* This only occurs when an task abort was requested while ABTS
+		   is in progress.  Setting the IO_CLEANUP flag will skip the
+		   RRQ process in the case when the fw generated SCSI_CMD cmpl
+		   was a result from the ABTS request rather than the CLEANUP
+		   request */
+		set_bit(BNX2FC_FLAG_IO_CLEANUP,	&io_req->req_flags);
 		goto out;
 	}
 
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 2/4] BNX2FC: hung task timeout warning observed when rmmod bnx2x with active FCoE targets
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (105 preceding siblings ...)
  2013-09-18  5:33 ` [PATCH 1/4] BNX2FC: Fixed a SCSI CMD cmpl race condition between ABTS and CLEANUP Eddie Wai
@ 2013-09-18  5:33 ` Eddie Wai
  2013-09-18  5:33 ` [PATCH 3/4] BNX2FC: Bump version from 1.0.14 to 2.4.1 Eddie Wai
                   ` (2 subsequent siblings)
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2013-09-18  5:33 UTC (permalink / raw)
  To: James Bottomley
  Cc: Robert Love, fcoe-devel, linux-scsi, Michael Chan, Eddie Wai

A rtnl_lock deadlock was observed from the rmmod thread where it
tries to unregister the fcoe_ctlr device.  This unregistration
triggered a flush of the sysfs queue of the associated ctlr and led to
a call to the set_fcoe_ctlr_enabled routine.  This will eventually propagate
down to call the bnx2fc_disable routine and contented for the rtnl_lock
in the same context.

This patch creates a subset of the bnx2fc_enable/disable routine which
removes the unnecesary rtnl_lock and the bnx2fc_dev_lock acquisition from
the set_fcoe_ctlr_enabled path.

 kernel: INFO: task rmmod:7874 blocked for more than 120 seconds.
 kernel:      Tainted: G        W  ---------------    2.6.32-415.0.1.el6.x86_64 #1
 kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
 kernel: rmmod         D 000000000000000f     0  7874   6518 0x00000080
 kernel: ffff88022158f7d8 0000000000000086 0000000000000000 0000000000000000
 kernel: ffff88023fe72600 ffff88043c74d410 ffff88043c74d400 ffff88043c74d000
 kernel: ffff88021ecbe5f8 ffff88022158ffd8 000000000000fbc8 ffff88021ecbe5f8
 kernel: Call Trace:
 kernel: [<ffffffff81525985>] schedule_timeout+0x215/0x2e0
 kernel: [<ffffffff810680c0>] ? pick_next_task_fair+0xd0/0x130
 kernel: [<ffffffff81524858>] ? schedule+0x178/0x3b2
 kernel: [<ffffffff81525603>] wait_for_common+0x123/0x180
 kernel: [<ffffffff81066b40>] ? default_wake_function+0x0/0x20
 kernel: [<ffffffff811a486e>] ? ifind_fast+0x5e/0xb0
 kernel: [<ffffffff8152571d>] wait_for_completion+0x1d/0x20
 kernel: [<ffffffff81203868>] sysfs_addrm_finish+0x228/0x270
 kernel: [<ffffffff812014ab>] sysfs_hash_and_remove+0x5b/0x90
 kernel: [<ffffffff812056af>] sysfs_remove_group+0x5f/0x100
 kernel: [<ffffffff81367e8b>] device_remove_groups+0x3b/0x60
 kernel: [<ffffffff8136811d>] device_remove_attrs+0x3d/0x90
 kernel: [<ffffffff81368295>] device_del+0x125/0x1e0
 kernel: [<ffffffff81368372>] device_unregister+0x22/0x60
 kernel: [<ffffffffa038ead2>] fcoe_ctlr_device_delete+0xe2/0xf4 [libfcoe]
 kernel: [<ffffffffa03c43cb>] bnx2fc_interface_release+0x5b/0x90 [bnx2fc]
 kernel: [<ffffffffa03c4370>] ? bnx2fc_interface_release+0x0/0x90 [bnx2fc]
 kernel: [<ffffffff812835e7>] kref_put+0x37/0x70
 kernel: [<ffffffffa03c4192>] __bnx2fc_destroy+0x72/0xa0 [bnx2fc]
 kernel: [<ffffffffa03c5265>] bnx2fc_ulp_exit+0xf5/0x160 [bnx2fc]    <- got bnx2fc_dev_lock mutex_lock
 kernel: [<ffffffffa03b03c6>] cnic_ulp_exit+0xb6/0xc0 [cnic]
 kernel: [<ffffffffa03b5418>] cnic_netdev_event+0x368/0x370 [cnic]
 kernel: [<ffffffffa038c56c>] ? fcoe_del_netdev_mapping+0x8c/0xa0 [libfcoe]
 kernel: [<ffffffff8152a6e5>] notifier_call_chain+0x55/0x80
 kernel: [<ffffffff810a0a46>] raw_notifier_call_chain+0x16/0x20
 kernel: [<ffffffff81459beb>] call_netdevice_notifiers+0x1b/0x20
 kernel: [<ffffffff8145ab34>] rollback_registered_many+0x154/0x280
 kernel: [<ffffffff8145ad08>] rollback_registered+0x38/0x50
 kernel: [<ffffffff8145ad78>] unregister_netdevice_queue+0x58/0xa0
 kernel: [<ffffffff8145add0>] unregister_netdevice+0x10/0x20
 kernel: [<ffffffff8145adfe>] unregister_netdev+0x1e/0x30                  <- got rtnl_lock!!!!!!!!!
 kernel: [<ffffffffa0122278>] __bnx2x_remove+0x48/0x270 [bnx2x] <- got & rel rtnl_lock
 kernel: [<ffffffffa0122554>] bnx2x_remove_one+0x44/0x80 [bnx2x]
 kernel: [<ffffffff812a3af7>] pci_device_remove+0x37/0x70
 kernel: [<ffffffff8136b2ef>] __device_release_driver+0x6f/0xe0
 kernel: [<ffffffff8136b428>] driver_detach+0xc8/0xd0
 kernel: [<ffffffff8136a22e>] bus_remove_driver+0x8e/0x110
 kernel: [<ffffffff8136bc12>] driver_unregister+0x62/0xa0
 kernel: [<ffffffff812a3e04>] pci_unregister_driver+0x44/0xb0
 kernel: [<ffffffffa0191954>] bnx2x_cleanup+0x18/0x73 [bnx2x]
 kernel: [<ffffffff810b8be4>] sys_delete_module+0x194/0x260
 kernel: [<ffffffff810e1347>] ? audit_syscall_entry+0x1d7/0x200
 kernel: [<ffffffff8100b072>] system_call_fastpath+0x16/0x1b

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c |   60 +++++++++++++++++++++++++++---------
 1 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 69ac554..5d059cb 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -1809,6 +1809,7 @@ static void bnx2fc_stop(struct bnx2fc_interface *interface)
 					FC_PORTTYPE_UNKNOWN;
 	mutex_unlock(&lport->lp_mutex);
 	fc_host_port_type(lport->host) = FC_PORTTYPE_UNKNOWN;
+	interface->enabled = false;
 	fcoe_ctlr_link_down(ctlr);
 	fcoe_clean_pending_queue(lport);
 }
@@ -2004,6 +2005,24 @@ static void bnx2fc_ulp_init(struct cnic_dev *dev)
 		set_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic);
 }
 
+/* Assumes rtnl_lock and the bnx2fc_dev_lock are already taken */
+static int __bnx2fc_disable(struct fcoe_ctlr *ctlr)
+{
+	struct bnx2fc_interface *interface = fcoe_ctlr_priv(ctlr);
+
+	if (interface->enabled == true) {
+		if (!ctlr->lp) {
+			pr_err(PFX "__bnx2fc_disable: lport not found\n");
+			return -ENODEV;
+		} else {
+			interface->enabled = false;
+			fcoe_ctlr_link_down(ctlr);
+			fcoe_clean_pending_queue(ctlr->lp);
+		}
+	}
+	return 0;
+}
+
 /**
  * Deperecated: Use bnx2fc_enabled()
  */
@@ -2018,20 +2037,34 @@ static int bnx2fc_disable(struct net_device *netdev)
 
 	interface = bnx2fc_interface_lookup(netdev);
 	ctlr = bnx2fc_to_ctlr(interface);
-	if (!interface || !ctlr->lp) {
+
+	if (!interface) {
 		rc = -ENODEV;
-		printk(KERN_ERR PFX "bnx2fc_disable: interface or lport not found\n");
+		pr_err(PFX "bnx2fc_disable: interface not found\n");
 	} else {
-		interface->enabled = false;
-		fcoe_ctlr_link_down(ctlr);
-		fcoe_clean_pending_queue(ctlr->lp);
+		rc = __bnx2fc_disable(ctlr);
 	}
-
 	mutex_unlock(&bnx2fc_dev_lock);
 	rtnl_unlock();
 	return rc;
 }
 
+static int __bnx2fc_enable(struct fcoe_ctlr *ctlr)
+{
+	struct bnx2fc_interface *interface = fcoe_ctlr_priv(ctlr);
+
+	if (interface->enabled == false) {
+		if (!ctlr->lp) {
+			pr_err(PFX "__bnx2fc_enable: lport not found\n");
+			return -ENODEV;
+		} else if (!bnx2fc_link_ok(ctlr->lp)) {
+			fcoe_ctlr_link_up(ctlr);
+			interface->enabled = true;
+		}
+	}
+	return 0;
+}
+
 /**
  * Deprecated: Use bnx2fc_enabled()
  */
@@ -2046,12 +2079,11 @@ static int bnx2fc_enable(struct net_device *netdev)
 
 	interface = bnx2fc_interface_lookup(netdev);
 	ctlr = bnx2fc_to_ctlr(interface);
-	if (!interface || !ctlr->lp) {
+	if (!interface) {
 		rc = -ENODEV;
-		printk(KERN_ERR PFX "bnx2fc_enable: interface or lport not found\n");
-	} else if (!bnx2fc_link_ok(ctlr->lp)) {
-		fcoe_ctlr_link_up(ctlr);
-		interface->enabled = true;
+		pr_err(PFX "bnx2fc_enable: interface not found\n");
+	} else {
+		rc = __bnx2fc_enable(ctlr);
 	}
 
 	mutex_unlock(&bnx2fc_dev_lock);
@@ -2072,14 +2104,12 @@ static int bnx2fc_enable(struct net_device *netdev)
 static int bnx2fc_ctlr_enabled(struct fcoe_ctlr_device *cdev)
 {
 	struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(cdev);
-	struct fc_lport *lport = ctlr->lp;
-	struct net_device *netdev = bnx2fc_netdev(lport);
 
 	switch (cdev->enabled) {
 	case FCOE_CTLR_ENABLED:
-		return bnx2fc_enable(netdev);
+		return __bnx2fc_enable(ctlr);
 	case FCOE_CTLR_DISABLED:
-		return bnx2fc_disable(netdev);
+		return __bnx2fc_disable(ctlr);
 	case FCOE_CTLR_UNUSED:
 	default:
 		return -ENOTSUPP;
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 3/4] BNX2FC: Bump version from 1.0.14 to 2.4.1
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (106 preceding siblings ...)
  2013-09-18  5:33 ` [PATCH 2/4] BNX2FC: hung task timeout warning observed when rmmod bnx2x with active FCoE targets Eddie Wai
@ 2013-09-18  5:33 ` Eddie Wai
  2013-09-18  5:33 ` [PATCH 4/4] MAINTAINER: Updated maintainer info for bnx2fc Eddie Wai
  2013-09-26  5:01 ` [PATCH v2 2/4] BNX2FC: hung task timeout warning observed when rmmod bnx2x with active FCoE targets Eddie Wai
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2013-09-18  5:33 UTC (permalink / raw)
  To: James Bottomley
  Cc: Robert Love, fcoe-devel, linux-scsi, Michael Chan, Eddie Wai

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2fc/bnx2fc.h      |    2 +-
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h
index 08b22a9..6991027 100644
--- a/drivers/scsi/bnx2fc/bnx2fc.h
+++ b/drivers/scsi/bnx2fc/bnx2fc.h
@@ -64,7 +64,7 @@
 #include "bnx2fc_constants.h"
 
 #define BNX2FC_NAME		"bnx2fc"
-#define BNX2FC_VERSION		"1.0.14"
+#define BNX2FC_VERSION		"2.4.1"
 
 #define PFX			"bnx2fc: "
 
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 5d059cb..ae5220e 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -22,7 +22,7 @@ DEFINE_PER_CPU(struct bnx2fc_percpu_s, bnx2fc_percpu);
 
 #define DRV_MODULE_NAME		"bnx2fc"
 #define DRV_MODULE_VERSION	BNX2FC_VERSION
-#define DRV_MODULE_RELDATE	"Mar 08, 2013"
+#define DRV_MODULE_RELDATE	"Sep 17, 2013"
 
 
 static char version[] =
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 4/4] MAINTAINER: Updated maintainer info for bnx2fc
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (107 preceding siblings ...)
  2013-09-18  5:33 ` [PATCH 3/4] BNX2FC: Bump version from 1.0.14 to 2.4.1 Eddie Wai
@ 2013-09-18  5:33 ` Eddie Wai
  2013-09-26  5:01 ` [PATCH v2 2/4] BNX2FC: hung task timeout warning observed when rmmod bnx2x with active FCoE targets Eddie Wai
  109 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2013-09-18  5:33 UTC (permalink / raw)
  To: James Bottomley
  Cc: Robert Love, fcoe-devel, linux-scsi, Michael Chan, Eddie Wai

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 MAINTAINERS |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index e5e2518..26bc416 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1825,7 +1825,7 @@ S:	Supported
 F:	drivers/net/wireless/brcm80211/
 
 BROADCOM BNX2FC 10 GIGABIT FCOE DRIVER
-M:	Bhanu Prakash Gollapudi <bprakash@broadcom.com>
+M:	Eddie Wai <eddie.wai@broadcom.com>
 L:	linux-scsi@vger.kernel.org
 S:	Supported
 F:	drivers/scsi/bnx2fc/
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH v2 2/4] BNX2FC: hung task timeout warning observed when rmmod bnx2x with active FCoE targets
       [not found] <Eddie Wai <eddie.wai@broadcom.com>
                   ` (108 preceding siblings ...)
  2013-09-18  5:33 ` [PATCH 4/4] MAINTAINER: Updated maintainer info for bnx2fc Eddie Wai
@ 2013-09-26  5:01 ` Eddie Wai
       [not found]   ` <1380171680-4905-1-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
  109 siblings, 1 reply; 189+ messages in thread
From: Eddie Wai @ 2013-09-26  5:01 UTC (permalink / raw)
  To: James Bottomley
  Cc: Robert Love, fcoe-devel, linux-scsi, Michael Chan, Eddie Wai

[v2] - removed the interface->enabled flag setting which prevented the
       fcoe ctlr link from being brought back up after a MTU change

A rtnl_lock deadlock was observed from the rmmod thread where it
tries to unregister the fcoe_ctlr device.  This unregistration
triggered a flush of the sysfs queue of the associated ctlr and led to
a call to the set_fcoe_ctlr_enabled routine.  This will eventually propagate
down to call the bnx2fc_disable routine and contented for the rtnl_lock
in the same context.

This patch creates a subset of the bnx2fc_enable/disable routine which
removes the unnecesary rtnl_lock and the bnx2fc_dev_lock acquisition from
the set_fcoe_ctlr_enabled path.

 kernel: INFO: task rmmod:7874 blocked for more than 120 seconds.
 kernel:      Tainted: G        W  ---------------    2.6.32-415.0.1.el6.x86_64 #1
 kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
 kernel: rmmod         D 000000000000000f     0  7874   6518 0x00000080
 kernel: ffff88022158f7d8 0000000000000086 0000000000000000 0000000000000000
 kernel: ffff88023fe72600 ffff88043c74d410 ffff88043c74d400 ffff88043c74d000
 kernel: ffff88021ecbe5f8 ffff88022158ffd8 000000000000fbc8 ffff88021ecbe5f8
 kernel: Call Trace:
 kernel: [<ffffffff81525985>] schedule_timeout+0x215/0x2e0
 kernel: [<ffffffff810680c0>] ? pick_next_task_fair+0xd0/0x130
 kernel: [<ffffffff81524858>] ? schedule+0x178/0x3b2
 kernel: [<ffffffff81525603>] wait_for_common+0x123/0x180
 kernel: [<ffffffff81066b40>] ? default_wake_function+0x0/0x20
 kernel: [<ffffffff811a486e>] ? ifind_fast+0x5e/0xb0
 kernel: [<ffffffff8152571d>] wait_for_completion+0x1d/0x20
 kernel: [<ffffffff81203868>] sysfs_addrm_finish+0x228/0x270
 kernel: [<ffffffff812014ab>] sysfs_hash_and_remove+0x5b/0x90
 kernel: [<ffffffff812056af>] sysfs_remove_group+0x5f/0x100
 kernel: [<ffffffff81367e8b>] device_remove_groups+0x3b/0x60
 kernel: [<ffffffff8136811d>] device_remove_attrs+0x3d/0x90
 kernel: [<ffffffff81368295>] device_del+0x125/0x1e0
 kernel: [<ffffffff81368372>] device_unregister+0x22/0x60
 kernel: [<ffffffffa038ead2>] fcoe_ctlr_device_delete+0xe2/0xf4 [libfcoe]
 kernel: [<ffffffffa03c43cb>] bnx2fc_interface_release+0x5b/0x90 [bnx2fc]
 kernel: [<ffffffffa03c4370>] ? bnx2fc_interface_release+0x0/0x90 [bnx2fc]
 kernel: [<ffffffff812835e7>] kref_put+0x37/0x70
 kernel: [<ffffffffa03c4192>] __bnx2fc_destroy+0x72/0xa0 [bnx2fc]
 kernel: [<ffffffffa03c5265>] bnx2fc_ulp_exit+0xf5/0x160 [bnx2fc]    <- got bnx2fc_dev_lock mutex_lock
 kernel: [<ffffffffa03b03c6>] cnic_ulp_exit+0xb6/0xc0 [cnic]
 kernel: [<ffffffffa03b5418>] cnic_netdev_event+0x368/0x370 [cnic]
 kernel: [<ffffffffa038c56c>] ? fcoe_del_netdev_mapping+0x8c/0xa0 [libfcoe]
 kernel: [<ffffffff8152a6e5>] notifier_call_chain+0x55/0x80
 kernel: [<ffffffff810a0a46>] raw_notifier_call_chain+0x16/0x20
 kernel: [<ffffffff81459beb>] call_netdevice_notifiers+0x1b/0x20
 kernel: [<ffffffff8145ab34>] rollback_registered_many+0x154/0x280
 kernel: [<ffffffff8145ad08>] rollback_registered+0x38/0x50
 kernel: [<ffffffff8145ad78>] unregister_netdevice_queue+0x58/0xa0
 kernel: [<ffffffff8145add0>] unregister_netdevice+0x10/0x20
 kernel: [<ffffffff8145adfe>] unregister_netdev+0x1e/0x30                  <- got rtnl_lock!!!!!!!!!
 kernel: [<ffffffffa0122278>] __bnx2x_remove+0x48/0x270 [bnx2x] <- got & rel rtnl_lock
 kernel: [<ffffffffa0122554>] bnx2x_remove_one+0x44/0x80 [bnx2x]
 kernel: [<ffffffff812a3af7>] pci_device_remove+0x37/0x70
 kernel: [<ffffffff8136b2ef>] __device_release_driver+0x6f/0xe0
 kernel: [<ffffffff8136b428>] driver_detach+0xc8/0xd0
 kernel: [<ffffffff8136a22e>] bus_remove_driver+0x8e/0x110
 kernel: [<ffffffff8136bc12>] driver_unregister+0x62/0xa0
 kernel: [<ffffffff812a3e04>] pci_unregister_driver+0x44/0xb0
 kernel: [<ffffffffa0191954>] bnx2x_cleanup+0x18/0x73 [bnx2x]
 kernel: [<ffffffff810b8be4>] sys_delete_module+0x194/0x260
 kernel: [<ffffffff810e1347>] ? audit_syscall_entry+0x1d7/0x200
 kernel: [<ffffffff8100b072>] system_call_fastpath+0x16/0x1b

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c |   59 +++++++++++++++++++++++++++---------
 1 files changed, 44 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 69ac554..7a25766 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -2004,6 +2004,24 @@ static void bnx2fc_ulp_init(struct cnic_dev *dev)
 		set_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic);
 }
 
+/* Assumes rtnl_lock and the bnx2fc_dev_lock are already taken */
+static int __bnx2fc_disable(struct fcoe_ctlr *ctlr)
+{
+	struct bnx2fc_interface *interface = fcoe_ctlr_priv(ctlr);
+
+	if (interface->enabled == true) {
+		if (!ctlr->lp) {
+			pr_err(PFX "__bnx2fc_disable: lport not found\n");
+			return -ENODEV;
+		} else {
+			interface->enabled = false;
+			fcoe_ctlr_link_down(ctlr);
+			fcoe_clean_pending_queue(ctlr->lp);
+		}
+	}
+	return 0;
+}
+
 /**
  * Deperecated: Use bnx2fc_enabled()
  */
@@ -2018,20 +2036,34 @@ static int bnx2fc_disable(struct net_device *netdev)
 
 	interface = bnx2fc_interface_lookup(netdev);
 	ctlr = bnx2fc_to_ctlr(interface);
-	if (!interface || !ctlr->lp) {
+
+	if (!interface) {
 		rc = -ENODEV;
-		printk(KERN_ERR PFX "bnx2fc_disable: interface or lport not found\n");
+		pr_err(PFX "bnx2fc_disable: interface not found\n");
 	} else {
-		interface->enabled = false;
-		fcoe_ctlr_link_down(ctlr);
-		fcoe_clean_pending_queue(ctlr->lp);
+		rc = __bnx2fc_disable(ctlr);
 	}
-
 	mutex_unlock(&bnx2fc_dev_lock);
 	rtnl_unlock();
 	return rc;
 }
 
+static int __bnx2fc_enable(struct fcoe_ctlr *ctlr)
+{
+	struct bnx2fc_interface *interface = fcoe_ctlr_priv(ctlr);
+
+	if (interface->enabled == false) {
+		if (!ctlr->lp) {
+			pr_err(PFX "__bnx2fc_enable: lport not found\n");
+			return -ENODEV;
+		} else if (!bnx2fc_link_ok(ctlr->lp)) {
+			fcoe_ctlr_link_up(ctlr);
+			interface->enabled = true;
+		}
+	}
+	return 0;
+}
+
 /**
  * Deprecated: Use bnx2fc_enabled()
  */
@@ -2046,12 +2078,11 @@ static int bnx2fc_enable(struct net_device *netdev)
 
 	interface = bnx2fc_interface_lookup(netdev);
 	ctlr = bnx2fc_to_ctlr(interface);
-	if (!interface || !ctlr->lp) {
+	if (!interface) {
 		rc = -ENODEV;
-		printk(KERN_ERR PFX "bnx2fc_enable: interface or lport not found\n");
-	} else if (!bnx2fc_link_ok(ctlr->lp)) {
-		fcoe_ctlr_link_up(ctlr);
-		interface->enabled = true;
+		pr_err(PFX "bnx2fc_enable: interface not found\n");
+	} else {
+		rc = __bnx2fc_enable(ctlr);
 	}
 
 	mutex_unlock(&bnx2fc_dev_lock);
@@ -2072,14 +2103,12 @@ static int bnx2fc_enable(struct net_device *netdev)
 static int bnx2fc_ctlr_enabled(struct fcoe_ctlr_device *cdev)
 {
 	struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(cdev);
-	struct fc_lport *lport = ctlr->lp;
-	struct net_device *netdev = bnx2fc_netdev(lport);
 
 	switch (cdev->enabled) {
 	case FCOE_CTLR_ENABLED:
-		return bnx2fc_enable(netdev);
+		return __bnx2fc_enable(ctlr);
 	case FCOE_CTLR_DISABLED:
-		return bnx2fc_disable(netdev);
+		return __bnx2fc_disable(ctlr);
 	case FCOE_CTLR_UNUSED:
 	default:
 		return -ENOTSUPP;
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH v2 2/4] BNX2FC: hung task timeout warning observed when rmmod bnx2x with active FCoE targets
       [not found]   ` <1380171680-4905-1-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
@ 2013-10-18 13:49     ` Tomas Henzl
  2013-10-18 14:54       ` Eddie Wai
  0 siblings, 1 reply; 189+ messages in thread
From: Tomas Henzl @ 2013-10-18 13:49 UTC (permalink / raw)
  To: Eddie Wai, James Bottomley; +Cc: fcoe-devel, linux-scsi

On 09/26/2013 07:01 AM, Eddie Wai wrote:
> [v2] - removed the interface->enabled flag setting which prevented the
>        fcoe ctlr link from being brought back up after a MTU change

Maybe I miss something but it seems to me that the previous version
has been taken into the for-next branch - 881e188ec7078f6850170ca72cc60621fe0672e1

If it is so, and the V2 is the right one, post a V1-V2 diff

Thanks, Tomas

>
> A rtnl_lock deadlock was observed from the rmmod thread where it
> tries to unregister the fcoe_ctlr device.  This unregistration
> triggered a flush of the sysfs queue of the associated ctlr and led to
> a call to the set_fcoe_ctlr_enabled routine.  This will eventually propagate
> down to call the bnx2fc_disable routine and contented for the rtnl_lock
> in the same context.
>
> This patch creates a subset of the bnx2fc_enable/disable routine which
> removes the unnecesary rtnl_lock and the bnx2fc_dev_lock acquisition from
> the set_fcoe_ctlr_enabled path.
>
>  kernel: INFO: task rmmod:7874 blocked for more than 120 seconds.
>  kernel:      Tainted: G        W  ---------------    2.6.32-415.0.1.el6.x86_64 #1
>  kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
>  kernel: rmmod         D 000000000000000f     0  7874   6518 0x00000080
>  kernel: ffff88022158f7d8 0000000000000086 0000000000000000 0000000000000000
>  kernel: ffff88023fe72600 ffff88043c74d410 ffff88043c74d400 ffff88043c74d000
>  kernel: ffff88021ecbe5f8 ffff88022158ffd8 000000000000fbc8 ffff88021ecbe5f8
>  kernel: Call Trace:
>  kernel: [<ffffffff81525985>] schedule_timeout+0x215/0x2e0
>  kernel: [<ffffffff810680c0>] ? pick_next_task_fair+0xd0/0x130
>  kernel: [<ffffffff81524858>] ? schedule+0x178/0x3b2
>  kernel: [<ffffffff81525603>] wait_for_common+0x123/0x180
>  kernel: [<ffffffff81066b40>] ? default_wake_function+0x0/0x20
>  kernel: [<ffffffff811a486e>] ? ifind_fast+0x5e/0xb0
>  kernel: [<ffffffff8152571d>] wait_for_completion+0x1d/0x20
>  kernel: [<ffffffff81203868>] sysfs_addrm_finish+0x228/0x270
>  kernel: [<ffffffff812014ab>] sysfs_hash_and_remove+0x5b/0x90
>  kernel: [<ffffffff812056af>] sysfs_remove_group+0x5f/0x100
>  kernel: [<ffffffff81367e8b>] device_remove_groups+0x3b/0x60
>  kernel: [<ffffffff8136811d>] device_remove_attrs+0x3d/0x90
>  kernel: [<ffffffff81368295>] device_del+0x125/0x1e0
>  kernel: [<ffffffff81368372>] device_unregister+0x22/0x60
>  kernel: [<ffffffffa038ead2>] fcoe_ctlr_device_delete+0xe2/0xf4 [libfcoe]
>  kernel: [<ffffffffa03c43cb>] bnx2fc_interface_release+0x5b/0x90 [bnx2fc]
>  kernel: [<ffffffffa03c4370>] ? bnx2fc_interface_release+0x0/0x90 [bnx2fc]
>  kernel: [<ffffffff812835e7>] kref_put+0x37/0x70
>  kernel: [<ffffffffa03c4192>] __bnx2fc_destroy+0x72/0xa0 [bnx2fc]
>  kernel: [<ffffffffa03c5265>] bnx2fc_ulp_exit+0xf5/0x160 [bnx2fc]    <- got bnx2fc_dev_lock mutex_lock
>  kernel: [<ffffffffa03b03c6>] cnic_ulp_exit+0xb6/0xc0 [cnic]
>  kernel: [<ffffffffa03b5418>] cnic_netdev_event+0x368/0x370 [cnic]
>  kernel: [<ffffffffa038c56c>] ? fcoe_del_netdev_mapping+0x8c/0xa0 [libfcoe]
>  kernel: [<ffffffff8152a6e5>] notifier_call_chain+0x55/0x80
>  kernel: [<ffffffff810a0a46>] raw_notifier_call_chain+0x16/0x20
>  kernel: [<ffffffff81459beb>] call_netdevice_notifiers+0x1b/0x20
>  kernel: [<ffffffff8145ab34>] rollback_registered_many+0x154/0x280
>  kernel: [<ffffffff8145ad08>] rollback_registered+0x38/0x50
>  kernel: [<ffffffff8145ad78>] unregister_netdevice_queue+0x58/0xa0
>  kernel: [<ffffffff8145add0>] unregister_netdevice+0x10/0x20
>  kernel: [<ffffffff8145adfe>] unregister_netdev+0x1e/0x30                  <- got rtnl_lock!!!!!!!!!
>  kernel: [<ffffffffa0122278>] __bnx2x_remove+0x48/0x270 [bnx2x] <- got & rel rtnl_lock
>  kernel: [<ffffffffa0122554>] bnx2x_remove_one+0x44/0x80 [bnx2x]
>  kernel: [<ffffffff812a3af7>] pci_device_remove+0x37/0x70
>  kernel: [<ffffffff8136b2ef>] __device_release_driver+0x6f/0xe0
>  kernel: [<ffffffff8136b428>] driver_detach+0xc8/0xd0
>  kernel: [<ffffffff8136a22e>] bus_remove_driver+0x8e/0x110
>  kernel: [<ffffffff8136bc12>] driver_unregister+0x62/0xa0
>  kernel: [<ffffffff812a3e04>] pci_unregister_driver+0x44/0xb0
>  kernel: [<ffffffffa0191954>] bnx2x_cleanup+0x18/0x73 [bnx2x]
>  kernel: [<ffffffff810b8be4>] sys_delete_module+0x194/0x260
>  kernel: [<ffffffff810e1347>] ? audit_syscall_entry+0x1d7/0x200
>  kernel: [<ffffffff8100b072>] system_call_fastpath+0x16/0x1b
>
> Signed-off-by: Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
> ---
>  drivers/scsi/bnx2fc/bnx2fc_fcoe.c |   59 +++++++++++++++++++++++++++---------
>  1 files changed, 44 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> index 69ac554..7a25766 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> @@ -2004,6 +2004,24 @@ static void bnx2fc_ulp_init(struct cnic_dev *dev)
>  		set_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic);
>  }
>  
> +/* Assumes rtnl_lock and the bnx2fc_dev_lock are already taken */
> +static int __bnx2fc_disable(struct fcoe_ctlr *ctlr)
> +{
> +	struct bnx2fc_interface *interface = fcoe_ctlr_priv(ctlr);
> +
> +	if (interface->enabled == true) {
> +		if (!ctlr->lp) {
> +			pr_err(PFX "__bnx2fc_disable: lport not found\n");
> +			return -ENODEV;
> +		} else {
> +			interface->enabled = false;
> +			fcoe_ctlr_link_down(ctlr);
> +			fcoe_clean_pending_queue(ctlr->lp);
> +		}
> +	}
> +	return 0;
> +}
> +
>  /**
>   * Deperecated: Use bnx2fc_enabled()
>   */
> @@ -2018,20 +2036,34 @@ static int bnx2fc_disable(struct net_device *netdev)
>  
>  	interface = bnx2fc_interface_lookup(netdev);
>  	ctlr = bnx2fc_to_ctlr(interface);
> -	if (!interface || !ctlr->lp) {
> +
> +	if (!interface) {
>  		rc = -ENODEV;
> -		printk(KERN_ERR PFX "bnx2fc_disable: interface or lport not found\n");
> +		pr_err(PFX "bnx2fc_disable: interface not found\n");
>  	} else {
> -		interface->enabled = false;
> -		fcoe_ctlr_link_down(ctlr);
> -		fcoe_clean_pending_queue(ctlr->lp);
> +		rc = __bnx2fc_disable(ctlr);
>  	}
> -
>  	mutex_unlock(&bnx2fc_dev_lock);
>  	rtnl_unlock();
>  	return rc;
>  }
>  
> +static int __bnx2fc_enable(struct fcoe_ctlr *ctlr)
> +{
> +	struct bnx2fc_interface *interface = fcoe_ctlr_priv(ctlr);
> +
> +	if (interface->enabled == false) {
> +		if (!ctlr->lp) {
> +			pr_err(PFX "__bnx2fc_enable: lport not found\n");
> +			return -ENODEV;
> +		} else if (!bnx2fc_link_ok(ctlr->lp)) {
> +			fcoe_ctlr_link_up(ctlr);
> +			interface->enabled = true;
> +		}
> +	}
> +	return 0;
> +}
> +
>  /**
>   * Deprecated: Use bnx2fc_enabled()
>   */
> @@ -2046,12 +2078,11 @@ static int bnx2fc_enable(struct net_device *netdev)
>  
>  	interface = bnx2fc_interface_lookup(netdev);
>  	ctlr = bnx2fc_to_ctlr(interface);
> -	if (!interface || !ctlr->lp) {
> +	if (!interface) {
>  		rc = -ENODEV;
> -		printk(KERN_ERR PFX "bnx2fc_enable: interface or lport not found\n");
> -	} else if (!bnx2fc_link_ok(ctlr->lp)) {
> -		fcoe_ctlr_link_up(ctlr);
> -		interface->enabled = true;
> +		pr_err(PFX "bnx2fc_enable: interface not found\n");
> +	} else {
> +		rc = __bnx2fc_enable(ctlr);
>  	}
>  
>  	mutex_unlock(&bnx2fc_dev_lock);
> @@ -2072,14 +2103,12 @@ static int bnx2fc_enable(struct net_device *netdev)
>  static int bnx2fc_ctlr_enabled(struct fcoe_ctlr_device *cdev)
>  {
>  	struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(cdev);
> -	struct fc_lport *lport = ctlr->lp;
> -	struct net_device *netdev = bnx2fc_netdev(lport);
>  
>  	switch (cdev->enabled) {
>  	case FCOE_CTLR_ENABLED:
> -		return bnx2fc_enable(netdev);
> +		return __bnx2fc_enable(ctlr);
>  	case FCOE_CTLR_DISABLED:
> -		return bnx2fc_disable(netdev);
> +		return __bnx2fc_disable(ctlr);
>  	case FCOE_CTLR_UNUSED:
>  	default:
>  		return -ENOTSUPP;

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH v2 2/4] BNX2FC: hung task timeout warning observed when rmmod bnx2x with active FCoE targets
  2013-10-18 13:49     ` Tomas Henzl
@ 2013-10-18 14:54       ` Eddie Wai
  0 siblings, 0 replies; 189+ messages in thread
From: Eddie Wai @ 2013-10-18 14:54 UTC (permalink / raw)
  To: Tomas Henzl
  Cc: Eddie Wai, James Bottomley, Robert Love, fcoe-devel, linux-scsi,
	Michael Chan

Tomas,

I have already took this up to James  yesterday and he said he will be fixing it over the weekend.

Thanks,
Eddie

On Oct 18, 2013, at 6:49 AM, "Tomas Henzl" <thenzl@redhat.com> wrote:

> On 09/26/2013 07:01 AM, Eddie Wai wrote:
>> [v2] - removed the interface->enabled flag setting which prevented the
>>       fcoe ctlr link from being brought back up after a MTU change
> 
> Maybe I miss something but it seems to me that the previous version
> has been taken into the for-next branch - 881e188ec7078f6850170ca72cc60621fe0672e1
> 
> If it is so, and the V2 is the right one, post a V1-V2 diff
> 
> Thanks, Tomas
> 
>> 
>> A rtnl_lock deadlock was observed from the rmmod thread where it
>> tries to unregister the fcoe_ctlr device.  This unregistration
>> triggered a flush of the sysfs queue of the associated ctlr and led to
>> a call to the set_fcoe_ctlr_enabled routine.  This will eventually propagate
>> down to call the bnx2fc_disable routine and contented for the rtnl_lock
>> in the same context.
>> 
>> This patch creates a subset of the bnx2fc_enable/disable routine which
>> removes the unnecesary rtnl_lock and the bnx2fc_dev_lock acquisition from
>> the set_fcoe_ctlr_enabled path.
>> 
>> kernel: INFO: task rmmod:7874 blocked for more than 120 seconds.
>> kernel:      Tainted: G        W  ---------------    2.6.32-415.0.1.el6.x86_64 #1
>> kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
>> kernel: rmmod         D 000000000000000f     0  7874   6518 0x00000080
>> kernel: ffff88022158f7d8 0000000000000086 0000000000000000 0000000000000000
>> kernel: ffff88023fe72600 ffff88043c74d410 ffff88043c74d400 ffff88043c74d000
>> kernel: ffff88021ecbe5f8 ffff88022158ffd8 000000000000fbc8 ffff88021ecbe5f8
>> kernel: Call Trace:
>> kernel: [<ffffffff81525985>] schedule_timeout+0x215/0x2e0
>> kernel: [<ffffffff810680c0>] ? pick_next_task_fair+0xd0/0x130
>> kernel: [<ffffffff81524858>] ? schedule+0x178/0x3b2
>> kernel: [<ffffffff81525603>] wait_for_common+0x123/0x180
>> kernel: [<ffffffff81066b40>] ? default_wake_function+0x0/0x20
>> kernel: [<ffffffff811a486e>] ? ifind_fast+0x5e/0xb0
>> kernel: [<ffffffff8152571d>] wait_for_completion+0x1d/0x20
>> kernel: [<ffffffff81203868>] sysfs_addrm_finish+0x228/0x270
>> kernel: [<ffffffff812014ab>] sysfs_hash_and_remove+0x5b/0x90
>> kernel: [<ffffffff812056af>] sysfs_remove_group+0x5f/0x100
>> kernel: [<ffffffff81367e8b>] device_remove_groups+0x3b/0x60
>> kernel: [<ffffffff8136811d>] device_remove_attrs+0x3d/0x90
>> kernel: [<ffffffff81368295>] device_del+0x125/0x1e0
>> kernel: [<ffffffff81368372>] device_unregister+0x22/0x60
>> kernel: [<ffffffffa038ead2>] fcoe_ctlr_device_delete+0xe2/0xf4 [libfcoe]
>> kernel: [<ffffffffa03c43cb>] bnx2fc_interface_release+0x5b/0x90 [bnx2fc]
>> kernel: [<ffffffffa03c4370>] ? bnx2fc_interface_release+0x0/0x90 [bnx2fc]
>> kernel: [<ffffffff812835e7>] kref_put+0x37/0x70
>> kernel: [<ffffffffa03c4192>] __bnx2fc_destroy+0x72/0xa0 [bnx2fc]
>> kernel: [<ffffffffa03c5265>] bnx2fc_ulp_exit+0xf5/0x160 [bnx2fc]    <- got bnx2fc_dev_lock mutex_lock
>> kernel: [<ffffffffa03b03c6>] cnic_ulp_exit+0xb6/0xc0 [cnic]
>> kernel: [<ffffffffa03b5418>] cnic_netdev_event+0x368/0x370 [cnic]
>> kernel: [<ffffffffa038c56c>] ? fcoe_del_netdev_mapping+0x8c/0xa0 [libfcoe]
>> kernel: [<ffffffff8152a6e5>] notifier_call_chain+0x55/0x80
>> kernel: [<ffffffff810a0a46>] raw_notifier_call_chain+0x16/0x20
>> kernel: [<ffffffff81459beb>] call_netdevice_notifiers+0x1b/0x20
>> kernel: [<ffffffff8145ab34>] rollback_registered_many+0x154/0x280
>> kernel: [<ffffffff8145ad08>] rollback_registered+0x38/0x50
>> kernel: [<ffffffff8145ad78>] unregister_netdevice_queue+0x58/0xa0
>> kernel: [<ffffffff8145add0>] unregister_netdevice+0x10/0x20
>> kernel: [<ffffffff8145adfe>] unregister_netdev+0x1e/0x30                  <- got rtnl_lock!!!!!!!!!
>> kernel: [<ffffffffa0122278>] __bnx2x_remove+0x48/0x270 [bnx2x] <- got & rel rtnl_lock
>> kernel: [<ffffffffa0122554>] bnx2x_remove_one+0x44/0x80 [bnx2x]
>> kernel: [<ffffffff812a3af7>] pci_device_remove+0x37/0x70
>> kernel: [<ffffffff8136b2ef>] __device_release_driver+0x6f/0xe0
>> kernel: [<ffffffff8136b428>] driver_detach+0xc8/0xd0
>> kernel: [<ffffffff8136a22e>] bus_remove_driver+0x8e/0x110
>> kernel: [<ffffffff8136bc12>] driver_unregister+0x62/0xa0
>> kernel: [<ffffffff812a3e04>] pci_unregister_driver+0x44/0xb0
>> kernel: [<ffffffffa0191954>] bnx2x_cleanup+0x18/0x73 [bnx2x]
>> kernel: [<ffffffff810b8be4>] sys_delete_module+0x194/0x260
>> kernel: [<ffffffff810e1347>] ? audit_syscall_entry+0x1d7/0x200
>> kernel: [<ffffffff8100b072>] system_call_fastpath+0x16/0x1b
>> 
>> Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
>> ---
>> drivers/scsi/bnx2fc/bnx2fc_fcoe.c |   59 +++++++++++++++++++++++++++---------
>> 1 files changed, 44 insertions(+), 15 deletions(-)
>> 
>> diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
>> index 69ac554..7a25766 100644
>> --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
>> +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
>> @@ -2004,6 +2004,24 @@ static void bnx2fc_ulp_init(struct cnic_dev *dev)
>>        set_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic);
>> }
>> 
>> +/* Assumes rtnl_lock and the bnx2fc_dev_lock are already taken */
>> +static int __bnx2fc_disable(struct fcoe_ctlr *ctlr)
>> +{
>> +    struct bnx2fc_interface *interface = fcoe_ctlr_priv(ctlr);
>> +
>> +    if (interface->enabled == true) {
>> +        if (!ctlr->lp) {
>> +            pr_err(PFX "__bnx2fc_disable: lport not found\n");
>> +            return -ENODEV;
>> +        } else {
>> +            interface->enabled = false;
>> +            fcoe_ctlr_link_down(ctlr);
>> +            fcoe_clean_pending_queue(ctlr->lp);
>> +        }
>> +    }
>> +    return 0;
>> +}
>> +
>> /**
>>  * Deperecated: Use bnx2fc_enabled()
>>  */
>> @@ -2018,20 +2036,34 @@ static int bnx2fc_disable(struct net_device *netdev)
>> 
>>    interface = bnx2fc_interface_lookup(netdev);
>>    ctlr = bnx2fc_to_ctlr(interface);
>> -    if (!interface || !ctlr->lp) {
>> +
>> +    if (!interface) {
>>        rc = -ENODEV;
>> -        printk(KERN_ERR PFX "bnx2fc_disable: interface or lport not found\n");
>> +        pr_err(PFX "bnx2fc_disable: interface not found\n");
>>    } else {
>> -        interface->enabled = false;
>> -        fcoe_ctlr_link_down(ctlr);
>> -        fcoe_clean_pending_queue(ctlr->lp);
>> +        rc = __bnx2fc_disable(ctlr);
>>    }
>> -
>>    mutex_unlock(&bnx2fc_dev_lock);
>>    rtnl_unlock();
>>    return rc;
>> }
>> 
>> +static int __bnx2fc_enable(struct fcoe_ctlr *ctlr)
>> +{
>> +    struct bnx2fc_interface *interface = fcoe_ctlr_priv(ctlr);
>> +
>> +    if (interface->enabled == false) {
>> +        if (!ctlr->lp) {
>> +            pr_err(PFX "__bnx2fc_enable: lport not found\n");
>> +            return -ENODEV;
>> +        } else if (!bnx2fc_link_ok(ctlr->lp)) {
>> +            fcoe_ctlr_link_up(ctlr);
>> +            interface->enabled = true;
>> +        }
>> +    }
>> +    return 0;
>> +}
>> +
>> /**
>>  * Deprecated: Use bnx2fc_enabled()
>>  */
>> @@ -2046,12 +2078,11 @@ static int bnx2fc_enable(struct net_device *netdev)
>> 
>>    interface = bnx2fc_interface_lookup(netdev);
>>    ctlr = bnx2fc_to_ctlr(interface);
>> -    if (!interface || !ctlr->lp) {
>> +    if (!interface) {
>>        rc = -ENODEV;
>> -        printk(KERN_ERR PFX "bnx2fc_enable: interface or lport not found\n");
>> -    } else if (!bnx2fc_link_ok(ctlr->lp)) {
>> -        fcoe_ctlr_link_up(ctlr);
>> -        interface->enabled = true;
>> +        pr_err(PFX "bnx2fc_enable: interface not found\n");
>> +    } else {
>> +        rc = __bnx2fc_enable(ctlr);
>>    }
>> 
>>    mutex_unlock(&bnx2fc_dev_lock);
>> @@ -2072,14 +2103,12 @@ static int bnx2fc_enable(struct net_device *netdev)
>> static int bnx2fc_ctlr_enabled(struct fcoe_ctlr_device *cdev)
>> {
>>    struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(cdev);
>> -    struct fc_lport *lport = ctlr->lp;
>> -    struct net_device *netdev = bnx2fc_netdev(lport);
>> 
>>    switch (cdev->enabled) {
>>    case FCOE_CTLR_ENABLED:
>> -        return bnx2fc_enable(netdev);
>> +        return __bnx2fc_enable(ctlr);
>>    case FCOE_CTLR_DISABLED:
>> -        return bnx2fc_disable(netdev);
>> +        return __bnx2fc_disable(ctlr);
>>    case FCOE_CTLR_UNUSED:
>>    default:
>>        return -ENOTSUPP;
> 
> 


^ permalink raw reply	[flat|nested] 189+ messages in thread

end of thread, other threads:[~2013-10-18 14:54 UTC | newest]

Thread overview: 189+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <Eddie Wai <eddie.wai@broadcom.com>
2010-06-26  1:39 ` [PATCH 0/7] BNX2I: Patch set to fix various disconnect conditions Eddie Wai
2010-06-26  1:39 ` [PATCH 1/7] BNX2I: Separated the hardware's cleanup procedure from ep_disconnect Eddie Wai
2010-06-30  5:53   ` Mike Christie
2010-06-30  6:07     ` Eddie Wai
2010-06-26  1:39 ` [PATCH 2/7] BNX2I: Created an active linklist which holds bnx2i endpoints Eddie Wai
     [not found]   ` <1277516372-469-3-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2010-06-30  5:59     ` Mike Christie
2010-06-26  1:39 ` [PATCH 3/7] BNX2I: Optimized the bnx2i_stop connection clean up procedure Eddie Wai
2010-06-30  6:11   ` Mike Christie
2010-06-30  6:56     ` Eddie Wai
2010-06-26  1:39 ` [PATCH 4/7] BNX2I: Fine tuned conn destroy and context destroy timeout values Eddie Wai
2010-06-26  1:39 ` [PATCH 5/7] BNX2I: Fixed the TCP graceful termination initiation Eddie Wai
2010-06-30  6:20   ` Mike Christie
2010-06-26  1:39 ` [PATCH 6/7] BNX2I: Added host param ISCSI_HOST_PARAM_IPADDRESS Eddie Wai
2010-06-26  1:39 ` [PATCH 7/7] BNX2I: Updated version from 2.1.1 to 2.1.2 Eddie Wai
2010-07-01 22:34 ` [PATCH 0/7 v2] BNX2I: Patch set to fix various disconnect conditions Eddie Wai
2010-07-08  0:49   ` Mike Christie
2010-07-01 22:34 ` [PATCH 1/7 v2] BNX2I: Separated the hardware's cleanup procedure from ep_disconnect Eddie Wai
2010-07-01 22:34 ` [PATCH 3/7 v2] BNX2I: Optimized the bnx2i_stop connection clean up procedure Eddie Wai
2010-07-01 22:34 ` [PATCH 5/7 v2] BNX2I: Fixed the TCP graceful termination initiation Eddie Wai
2010-07-01 22:34 ` [PATCH 6/7 v2] BNX2I: Added host param ISCSI_HOST_PARAM_IPADDRESS Eddie Wai
2010-07-01 22:34 ` [PATCH 7/7 v2] BNX2I: Updated version from 2.1.1 to 2.1.2 Eddie Wai
2010-07-21 18:51 ` [PATCH] Added fix for unsolicited NOP-In handling Eddie Wai
2010-07-21 18:51 ` [PATCH] BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins Eddie Wai
     [not found]   ` <1279738270-21911-2-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2010-07-23  4:50     ` Mike Christie
2010-07-27 16:12 ` [PATCH] BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In Eddie Wai
2010-07-27 17:27   ` Mike Christie
2010-08-10 19:09 ` [PATCH 0/5] Patch set to fix various bugs in bnx2i Eddie Wai
2010-08-10 19:09 ` [PATCH 2/5] BNX2I: Added support for other TMFs besides ABORT_TASK Eddie Wai
     [not found]   ` <1281467374-6182-3-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2010-08-11 19:07     ` Mike Christie
2010-08-11 19:26       ` Eddie Wai
2010-08-11 19:38         ` Mike Christie
2010-08-10 19:09 ` [PATCH 4/5] BNX2I: Added chip cleanup for the remove module path Eddie Wai
2010-08-11 19:09   ` Mike Christie
2010-08-10 19:09 ` [PATCH 5/5] BNX2I: Updated version to bnx2i-2.1.3 Eddie Wai
2010-08-12 23:44 ` [PATCH 0/5 v2] Patch set to fix various bugs in bnx2i Eddie Wai
2010-08-12 23:44 ` [PATCH 1/5 v2] BNX2I: Fixed a protocol violation on nopout responses Eddie Wai
2010-08-12 23:44 ` [PATCH 2/5 v2] BNX2I: Added support for other TMFs besides ABORT_TASK Eddie Wai
2010-08-13  1:38   ` Mike Christie
2010-08-12 23:44 ` [PATCH 3/5 v2] BNX2I: Recouple the CFC delete cleanup with cm_abort/close completion Eddie Wai
2010-08-12 23:44 ` [PATCH 4/5 v2] BNX2I: Added chip cleanup for the remove module path Eddie Wai
2010-08-12 23:44 ` [PATCH 5/5 v2] BNX2I: Updated version to bnx2i-2.1.3 Eddie Wai
2010-08-13 16:33 ` [PATCH 2/5 v3] BNX2I: Added support for other TMFs besides ABORT_TASK Eddie Wai
2010-08-13 16:42   ` Mike Christie
2010-11-10 23:04 ` [PATCH 00/16] BNX2I: Patch set to fix various bug fixes Eddie Wai
2010-11-10 23:04 ` [PATCH 01/16] BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins Eddie Wai
2010-11-10 23:04 ` [PATCH 02/16] BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In Eddie Wai
2010-11-10 23:04 ` [PATCH 03/16] BNX2I: Fixed the endian bug in the TMF LUN cmd send Eddie Wai
2010-11-10 23:04 ` [PATCH 04/16] BNX2I: Updated the handling of NETEVENTs to alleviate recovery Eddie Wai
2010-11-18  3:14   ` Mike Christie
2010-11-18 18:25     ` Eddie Wai
2010-11-18 18:28     ` Michael Chan
2010-11-10 23:04 ` [PATCH 05/16] BNX2I: Modified the bnx2i stop path to compensate for in progress ops Eddie Wai
2010-11-10 23:04 ` [PATCH 06/16] BNX2I: Added code to handle the binding of an existing connection Eddie Wai
2010-11-18  3:24   ` Mike Christie
2011-01-02  4:11     ` Mike Christie
2011-01-06  6:54       ` Or Gerlitz
2011-01-06 20:38         ` Mike Christie
2010-11-10 23:04 ` [PATCH 07/16] BNX2I: Fixed the remote TCP RST handling for the 570X (1g) Eddie Wai
2010-11-10 23:04 ` [PATCH 09/16] BNX2I: Removed the dynamic registration of CNIC Eddie Wai
2010-11-18  3:29   ` Mike Christie
2010-11-10 23:04 ` [PATCH 11/16] BNX2I: Added return code check for chip kwqe submission request Eddie Wai
2010-11-10 23:04 ` [PATCH 12/16] BNX2I: Added feature to silently drop NOPOUT request Eddie Wai
2010-11-18  3:40   ` Mike Christie
2010-11-18 19:25     ` Eddie Wai
2010-11-18 19:55       ` Mike Christie
     [not found]         ` <4CE584C6.7070300-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>
2010-11-18 20:04           ` Mike Christie
2010-11-18 21:59             ` Eddie Wai
2010-11-20  5:07               ` Mike Christie
2010-11-10 23:04 ` [PATCH 13/16] BNX2I: Cleaned up various error conditions in ep_connect/disconnect Eddie Wai
2010-11-10 23:04 ` [PATCH 14/16] BNX2I: Allow to abort the connection if connect request times out Eddie Wai
2010-11-10 23:04 ` [PATCH 15/16] BNX2I: Updated copyright and maintainer info Eddie Wai
2010-11-10 23:04 ` [PATCH 16/16] BNX2I: Updated version to 2.6.2.2 Eddie Wai
2010-11-19  1:29 ` [PATCH 00/14] BNX2I: Patch set to fix various bug fixes Eddie Wai
2010-11-19  1:29 ` [PATCH v2 01/14] BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins Eddie Wai
2010-11-19  1:29 ` [PATCH v2 02/14] BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In Eddie Wai
2010-11-19  1:29 ` [PATCH v2 03/14] BNX2I: Fixed the endian bug in the TMF LUN cmd send Eddie Wai
2010-11-19  1:29 ` [PATCH v2 04/14] BNX2I: Fixed a cid leak issue for 5771X (10g) Eddie Wai
2010-11-19  1:30 ` [PATCH v2 05/14] BNX2I: Fixed the remote TCP RST handling for the 570X (1g) Eddie Wai
2010-11-19  1:30 ` [PATCH v2 06/14] BNX2I: Allow to abort the connection if connect request times out Eddie Wai
2010-11-19  1:30 ` [PATCH v2 07/14] BNX2I: Added mutex lock protection to conn_get_param Eddie Wai
2010-11-19  1:30 ` [PATCH v2 08/14] BNX2I: Removed the dynamic registration of CNIC Eddie Wai
2010-11-19  1:30 ` [PATCH v2 09/14] BNX2I: Modified the bnx2i stop path to compensate for in progress ops Eddie Wai
2010-11-19  1:30 ` [PATCH v2 10/14] BNX2I: Added return code check for chip kwqe submission request Eddie Wai
2010-11-19  1:30 ` [PATCH v2 11/14] BNX2I: Added feature to silently drop NOPOUT request Eddie Wai
     [not found]   ` <1290130209-32133-12-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2010-11-22 17:42     ` Mike Christie
2010-11-19  1:30 ` [PATCH v2 12/14] BNX2I: Cleaned up various error conditions in ep_connect/disconnect Eddie Wai
2010-11-19  1:30 ` [PATCH v2 13/14] BNX2I: Updated copyright and maintainer info Eddie Wai
2010-11-19  1:30 ` [PATCH v2 14/14] BNX2I: Updated version to 2.6.2.1 Eddie Wai
2010-11-23 23:29 ` PATCH 00/13] BNX2I: Patch set to fix various bug fixes Eddie Wai
2010-11-24  0:16   ` Mike Christie
2010-11-23 23:29 ` [PATCH v3 01/13] BNX2I: Fixed bugs in the handling of unsolicited NOP-Ins Eddie Wai
2010-11-23 23:29 ` [PATCH v3 02/13] BNX2I: Added fix for NOP-Out response panic from unsolicited NOP-In Eddie Wai
2010-11-23 23:29 ` [PATCH v3 03/13] BNX2I: Fixed the endian bug in the TMF LUN cmd send Eddie Wai
2010-11-23 23:29 ` [PATCH v3 04/13] BNX2I: Fixed a cid leak issue for 5771X (10g) Eddie Wai
2010-11-23 23:29 ` [PATCH v3 05/13] BNX2I: Fixed the remote TCP RST handling for the 570X (1g) Eddie Wai
2010-11-23 23:29 ` [PATCH v3 06/13] BNX2I: Allow to abort the connection if connect request times out Eddie Wai
2010-11-23 23:29 ` [PATCH v3 08/13] BNX2I: Removed the dynamic registration of CNIC Eddie Wai
2010-11-23 23:29 ` [PATCH v3 09/13] BNX2I: Modified the bnx2i stop path to compensate for in progress ops Eddie Wai
2010-11-23 23:29 ` [PATCH v3 10/13] BNX2I: Added return code check for chip kwqe submission request Eddie Wai
2010-11-23 23:29 ` [PATCH v3 11/13] BNX2I: Cleaned up various error conditions in ep_connect/disconnect Eddie Wai
2010-11-23 23:29 ` [PATCH v3 12/13] BNX2I: Updated copyright and maintainer info Eddie Wai
2010-11-23 23:29 ` [PATCH v3 13/13] BNX2I: Updated version to 2.6.2.2 Eddie Wai
2011-01-05 20:44 ` [PATCH 0/8] Added bug fixes and several features for BNX2I Eddie Wai
2011-01-05 20:52   ` James Bottomley
     [not found]     ` <1294260724.16957.29.camel-0iu6Cu4xQGLYCGPCin2YbQ@public.gmane.org>
2011-01-06  0:42       ` Eddie Wai
2011-01-06 20:43   ` Mike Christie
2011-01-26 21:55     ` Mike Christie
2011-01-05 20:44 ` [PATCH 1/8] BNX2I: Allow ep CONNECT_FAILED condition to go through proper cleanup Eddie Wai
2011-01-05 20:44 ` [PATCH 2/8] BNX2I: Fixed the 32-bit swapping of the LUN field for nopouts for 5771X Eddie Wai
2011-01-05 20:44 ` [PATCH 3/8] BNX2I: Added handling for unsupported iSCSI offload hba Eddie Wai
2011-01-05 20:44 ` [PATCH 4/8] BNX2I: Added support for the 57712(E) devices Eddie Wai
2011-01-05 20:44 ` [PATCH 5/8] BNX2I: Added TCP timestamps option support Eddie Wai
2011-01-05 20:52   ` Mike Christie
2011-01-05 21:06     ` Mike Christie
     [not found]       ` <4D24DD45.8060701-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>
2011-01-06  0:39         ` Eddie Wai
2011-01-05 20:44 ` [PATCH 6/8] BNX2I: Added jumbo MTU support for the no shost case Eddie Wai
2011-01-05 20:50   ` Mike Christie
2011-01-05 22:58     ` Eddie Wai
2011-01-05 20:44 ` [PATCH 7/8] BNX2I: Added iSCSI text pdu support for iSCSI offload Eddie Wai
2011-01-05 20:44 ` [PATCH 8/8] BNX2I: Updated to version 2.6.2.3 Eddie Wai
2011-01-09  2:00 ` [PATCH] BNX2I: Added reconnect fix connecting against Lefthand targets Eddie Wai
2011-01-09  5:44   ` Mike Christie
2011-05-16 18:13 ` [PATCH 0/3] BNX2I: Bug fixes and Performance Optimization Eddie Wai
2011-05-18 19:52   ` Mike Christie
2011-05-16 18:13 ` [PATCH 1/3] BNX2I: Fixed packet error created when the sq_size is set to 16 Eddie Wai
2011-05-16 18:13 ` [PATCH 2/3] BNX2I: Updated the connection shutdown/cleanup timeout Eddie Wai
2011-05-16 18:13 ` [PATCH 3/3] BNX2I: Optimized the iSCSI offload performance Eddie Wai
2011-05-16 19:13   ` Mike Christie
2011-06-21 16:49 ` [PATCH 0/4] BNX2I: Code and performance optimization Eddie Wai
2011-06-21 16:49 ` [PATCH 1/4] BNX2I: Added the use of kthreads to handle SCSI cmd completion Eddie Wai
2011-06-22  2:54   ` Mike Christie
2011-06-22  6:46     ` Eddie Wai
2011-06-21 16:49 ` [PATCH 2/4] BNX2I: Modified to skip CNIC registration if iSCSI is not supported Eddie Wai
2011-06-21 16:49 ` [PATCH 3/4] BNX2I: Changed the nopout_wqe->lun memcpy to use sizeof instead Eddie Wai
2011-06-22  8:00   ` Rolf Eike Beer
2011-06-21 16:49 ` [PATCH 4/4] BNX2I: Updated copyright and bump version Eddie Wai
2011-06-23 22:51 ` [PATCH 0/4 v2] BNX2I: Code and performance optimization Eddie Wai
2011-06-23 22:51 ` [PATCH 1/4 v2] BNX2I: Added the use of kthreads to handle SCSI cmd completion Eddie Wai
2011-06-23 22:51 ` [PATCH 2/4 v2] BNX2I: Modified to skip CNIC registration if iSCSI is not supported Eddie Wai
2011-06-23 22:51 ` [PATCH 3/4 v2] BNX2I: Changed the nopout_wqe->lun memcpy to use sizeof instead Eddie Wai
2011-06-24 20:20   ` Mike Christie
2011-06-29 21:53     ` James Bottomley
2011-06-23 22:51 ` [PATCH 4/4 v2] BNX2I: Updated copyright and bump version Eddie Wai
2011-07-11 18:14 ` [PATCH] BNX2I: Fixed kernel panic due to illegal usage of sc->request->cpu Eddie Wai
     [not found]   ` <1310408095-11882-1-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2011-07-11 20:02     ` Mike Christie
2011-07-14  6:33       ` Eddie Wai
2011-07-14  7:20         ` Mike Christie
2011-07-14  7:41         ` Mike Christie
2011-07-14 17:13           ` Eddie Wai
2011-07-14 23:42 ` [PATCH v2] " Eddie Wai
2011-07-15  0:29   ` Michael Chan
2011-07-15  1:11     ` Eddie Wai
2011-07-15 18:17 ` [PATCH v3] " Eddie Wai
2012-04-25 22:03 ` [PATCH 1/2] BNX2I: Added the setting of target can_queue via target_alloc Eddie Wai
     [not found]   ` <1335391425-30410-1-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2012-04-26  3:48     ` Mike Christie
2012-04-25 22:08 ` [PATCH 2/2] BNX2I: Updated version and copyright year Eddie Wai
2012-06-29 23:37 ` [PATCH] BNX2I: Removed the reference to the netdev->base_addr Eddie Wai
     [not found]   ` <1341013055-16339-1-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2012-06-30  2:41     ` Mike Christie
2012-07-03 22:06       ` Eddie Wai
2012-10-23  0:53 ` [PATCH] LIBISCSI: Added the new boot_nic entry in the session sysfs Eddie Wai
2013-06-20 17:21 ` [PATCH v2] LIBISCSI: Added new boot entries " Eddie Wai
     [not found]   ` <1371748886-5018-1-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2013-06-20 17:24     ` Mike Christie
2013-07-12  0:15 ` [PATCH 1/2] BNX2I: Update version and copyright year 2013 Eddie Wai
2013-07-12  0:15   ` [PATCH 2/2] MAINTAINER: Added maintainer info for bnx2i Eddie Wai
     [not found] ` <Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2010-07-01 22:34   ` [PATCH 2/7 v2] BNX2I: Created an active linklist which holds bnx2i endpoints Eddie Wai
2010-07-01 22:34   ` [PATCH 4/7 v2] BNX2I: Fine tuned conn destroy and context destroy timeout values Eddie Wai
2010-08-10 19:09   ` [PATCH 1/5] BNX2I: Fixed a protocol violation on nopout responses Eddie Wai
2010-08-10 19:09   ` [PATCH 3/5] BNX2I: Recouple the CFC delete cleanup with cm_abort/close completion Eddie Wai
2010-11-10 23:04   ` [PATCH 08/16] BNX2I: Added mutex lock protection to conn_get_param Eddie Wai
2010-11-18  3:27     ` Mike Christie
2010-11-18 19:08       ` Eddie Wai
2010-11-10 23:04   ` [PATCH 10/16] BNX2I: Fixed a cid leak issue for 5771X (10g) Eddie Wai
2010-11-23 23:29   ` [PATCH v3 07/13] BNX2I: Added mutex lock protection to conn_get_param Eddie Wai
2012-02-02 23:22   ` [PATCH] BNX2I: Fixed the override of the error_mask module param Eddie Wai
2012-08-21 17:35   ` [PATCH] BNX2I: Fixed NULL ptr deference for 1G bnx2 Linux iSCSI offload Eddie Wai
     [not found]     ` <1345570553-23067-1-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2012-08-21 17:41       ` Mike Christie
2012-10-16  0:31   ` [PATCH] BNX2I: Removed the individual PCI DEVICE ID checking Eddie Wai
2012-10-24  7:02     ` Mike Christie
2013-02-20  2:30   ` [PATCH] SCSI: amd_iommu dma_boundary overflow Eddie Wai
2013-02-20  9:37     ` James Bottomley
2013-02-21 10:19       ` Joerg Roedel
2013-09-18  5:30   ` [PATCH 0/4] Fixed a race condition and a rtnl_lock deadlock for bnx2fc Eddie Wai
2013-09-18  5:33 ` [PATCH 1/4] BNX2FC: Fixed a SCSI CMD cmpl race condition between ABTS and CLEANUP Eddie Wai
2013-09-18  5:33 ` [PATCH 2/4] BNX2FC: hung task timeout warning observed when rmmod bnx2x with active FCoE targets Eddie Wai
2013-09-18  5:33 ` [PATCH 3/4] BNX2FC: Bump version from 1.0.14 to 2.4.1 Eddie Wai
2013-09-18  5:33 ` [PATCH 4/4] MAINTAINER: Updated maintainer info for bnx2fc Eddie Wai
2013-09-26  5:01 ` [PATCH v2 2/4] BNX2FC: hung task timeout warning observed when rmmod bnx2x with active FCoE targets Eddie Wai
     [not found]   ` <1380171680-4905-1-git-send-email-eddie.wai-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2013-10-18 13:49     ` Tomas Henzl
2013-10-18 14:54       ` Eddie Wai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.