History log of /linux-master/drivers/scsi/bnx2i/bnx2i_iscsi.c
Revision Date Author Comments
# 80602aca 22-Mar-2023 Bart Van Assche <bvanassche@acm.org>

scsi: iscsi: Declare SCSI host template const

Make it explicit that the SCSI host template is not modified.

Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20230322195515.1267197-50-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 31500e90 16-Jun-2022 Mike Christie <michael.christie@oracle.com>

scsi: iscsi: Fix session removal on shutdown

When the system is shutting down, iscsid is not running so we will not get
a response to the ISCSI_ERR_INVALID_HOST error event. The system shutdown
will then hang waiting on userspace to remove the session.

This has libiscsi force the destruction of the session from the kernel when
iscsi_host_remove() is called from a driver's shutdown callout.

This fixes a regression added in qedi boot with commit d1f2ce77638d ("scsi:
qedi: Fix host removal with running sessions") which made qedi use the
common session removal function that waits on userspace instead of rolling
its own kernel based removal.

Link: https://lore.kernel.org/r/20220616222738.5722-7-michael.christie@oracle.com
Fixes: d1f2ce77638d ("scsi: qedi: Fix host removal with running sessions")
Tested-by: Nilesh Javali <njavali@marvell.com>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Reviewed-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 5bd85625 07-Apr-2022 Mike Christie <michael.christie@oracle.com>

scsi: iscsi: Merge suspend fields

Move the tx and rx suspend fields into one flags field.

Link: https://lore.kernel.org/r/20220408001314.5014-8-michael.christie@oracle.com
Tested-by: Manish Rangankar <mrangankar@marvell.com>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Reviewed-by: Chris Leech <cleech@redhat.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# db22de3e 18-Feb-2022 Bart Van Assche <bvanassche@acm.org>

scsi: iscsi: Stop using the SCSI pointer

Instead of storing the iSCSI task pointer and the session age in the SCSI
pointer, use command-private variables. This patch prepares for removal of
the SCSI pointer from struct scsi_cmnd.

The list of iSCSI drivers has been obtained as follows:
$ git grep -lw iscsi_host_alloc
drivers/infiniband/ulp/iser/iscsi_iser.c
drivers/scsi/be2iscsi/be_main.c
drivers/scsi/bnx2i/bnx2i_iscsi.c
drivers/scsi/cxgbi/libcxgbi.c
drivers/scsi/iscsi_tcp.c
drivers/scsi/libiscsi.c
drivers/scsi/qedi/qedi_main.c
drivers/scsi/qla4xxx/ql4_os.c
include/scsi/libiscsi.h

Note: it is not clear to me how the qla4xxx driver can work without this
patch since it uses the scsi_cmnd::SCp.ptr member for two different
purposes:
- The qla4xxx driver uses this member to store a struct srb pointer.
- libiscsi uses this member to store a struct iscsi_task pointer.

Reviewed-by: Lee Duncan <lduncan@suse.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Cc: Chris Leech <cleech@redhat.com>
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Nilesh Javali <njavali@marvell.com>
Cc: Manish Rangankar <mrangankar@marvell.com>
Cc: Karen Xie <kxie@chelsio.com>
Cc: Ketan Mukadam <ketan.mukadam@broadcom.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>

iscsi

Link: https://lore.kernel.org/r/20220218195117.25689-26-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# eb78ac7a 12-Oct-2021 Bart Van Assche <bvanassche@acm.org>

scsi: bnx2i: Switch to attribute groups

struct device supports attribute groups directly but does not support
struct device_attribute directly. Hence switch to attribute groups.

Link: https://lore.kernel.org/r/20211012233558.4066756-17-bvanassche@acm.org
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# bdd4aad7 25-May-2021 Mike Christie <michael.christie@oracle.com>

scsi: iscsi: Fix shost->max_id use

The iscsi offload drivers are setting the shost->max_id to the max number
of sessions they support. The problem is that max_id is not the max number
of targets but the highest identifier the targets can have. To use it to
limit the number of targets we need to set it to max sessions - 1, or we
can end up with a session we might not have preallocated resources for.

Link: https://lore.kernel.org/r/20210525181821.7617-15-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 9e5fe170 25-May-2021 Mike Christie <michael.christie@oracle.com>

scsi: iscsi: Rel ref after iscsi_lookup_endpoint()

Subsequent commits allow the kernel to do ep_disconnect. In that case we
will have to get a proper refcount on the ep so one thread does not delete
it from under another.

Link: https://lore.kernel.org/r/20210525181821.7617-7-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 27e98628 25-May-2021 Mike Christie <michael.christie@oracle.com>

scsi: iscsi: Drop suspend calls from ep_disconnect

libiscsi will now suspend the send/tx queue for the drivers so we can drop
it from the drivers ep_disconnect.

Link: https://lore.kernel.org/r/20210525181821.7617-4-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 891e2639 25-May-2021 Mike Christie <michael.christie@oracle.com>

scsi: iscsi: Stop queueing during ep_disconnect

During ep_disconnect we have been doing iscsi_suspend_tx/queue to block new
I/O but every driver except cxgbi and iscsi_tcp can still get I/O from
__iscsi_conn_send_pdu() if we haven't called iscsi_conn_failure() before
ep_disconnect. This could happen if we were terminating the session, and
the logout timed out before it was even sent to libiscsi.

Fix the issue by adding a helper which reverses the bind_conn call that
allows new I/O to be queued. Drivers implementing ep_disconnect can use this
to make sure new I/O is not queued to them when handling the disconnect.

Link: https://lore.kernel.org/r/20210525181821.7617-3-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 14936b1e 06-Feb-2021 Mike Christie <michael.christie@oracle.com>

scsi: libiscsi: Fix iscsi_task use after free()

The following bug was reported and debugged by wubo40@huawei.com:

When testing kernel 4.18 version, NULL pointer dereference problem occurs
in iscsi_eh_cmd_timed_out() function.

I think this bug in the upstream is still exists.

The analysis reasons are as follows:

1) For some reason, I/O command did not complete within the timeout
period. The block layer timer works, call scsi_times_out() to handle I/O
timeout logic. At the same time the command just completes.

2) scsi_times_out() call iscsi_eh_cmd_timed_out() to process timeout logic.
Although there is an NULL judgment for the task, the task has not been
released yet now.

3) iscsi_complete_task() calls __iscsi_put_task(). The task reference count
reaches zero, the conditions for free task is met, then
iscsi_free_task() frees the task, and sets sc->SCp.ptr = NULL. After
iscsi_eh_cmd_timed_out() passes the task judgment check, there can still
be NULL dereference scenarios.

CPU0 CPU3

|- scsi_times_out() |-
iscsi_complete_task()
| |
|- iscsi_eh_cmd_timed_out() |-
__iscsi_put_task()
| |
|- task=sc->SCp.ptr, task is not NUL, check passed |-
iscsi_free_task(task)
| |
| |-> sc->SCp.ptr
= NULL
| |
|- task is NULL now, NULL pointer dereference |
| |
\|/ \|/

Calltrace:
[380751.840862] BUG: unable to handle kernel NULL pointer dereference at
0000000000000138
[380751.843709] PGD 0 P4D 0
[380751.844770] Oops: 0000 [#1] SMP PTI
[380751.846283] CPU: 0 PID: 403 Comm: kworker/0:1H Kdump: loaded
Tainted: G
[380751.851467] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996)
[380751.856521] Workqueue: kblockd blk_mq_timeout_work
[380751.858527] RIP: 0010:iscsi_eh_cmd_timed_out+0x15e/0x2e0 [libiscsi]
[380751.861129] Code: 83 ea 01 48 8d 74 d0 08 48 8b 10 48 8b 4a 50 48 85
c9 74 2c 48 39 d5 74
[380751.868811] RSP: 0018:ffffc1e280a5fd58 EFLAGS: 00010246
[380751.870978] RAX: ffff9fd1e84e15e0 RBX: ffff9fd1e84e6dd0 RCX:
0000000116acc580
[380751.873791] RDX: ffff9fd1f97a9400 RSI: ffff9fd1e84e1800 RDI:
ffff9fd1e4d6d420
[380751.876059] RBP: ffff9fd1e4d49000 R08: 0000000116acc580 R09:
0000000116acc580
[380751.878284] R10: 0000000000000000 R11: 0000000000000000 R12:
ffff9fd1e6e931e8
[380751.880500] R13: ffff9fd1e84e6ee0 R14: 0000000000000010 R15:
0000000000000003
[380751.882687] FS: 0000000000000000(0000) GS:ffff9fd1fac00000(0000)
knlGS:0000000000000000
[380751.885236] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[380751.887059] CR2: 0000000000000138 CR3: 000000011860a001 CR4:
00000000003606f0
[380751.889308] DR0: 0000000000000000 DR1: 0000000000000000 DR2:
0000000000000000
[380751.891523] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7:
0000000000000400
[380751.893738] Call Trace:
[380751.894639] scsi_times_out+0x60/0x1c0
[380751.895861] blk_mq_check_expired+0x144/0x200
[380751.897302] ? __switch_to_asm+0x35/0x70
[380751.898551] blk_mq_queue_tag_busy_iter+0x195/0x2e0
[380751.900091] ? __blk_mq_requeue_request+0x100/0x100
[380751.901611] ? __switch_to_asm+0x41/0x70
[380751.902853] ? __blk_mq_requeue_request+0x100/0x100
[380751.904398] blk_mq_timeout_work+0x54/0x130
[380751.905740] process_one_work+0x195/0x390
[380751.907228] worker_thread+0x30/0x390
[380751.908713] ? process_one_work+0x390/0x390
[380751.910350] kthread+0x10d/0x130
[380751.911470] ? kthread_flush_work_fn+0x10/0x10
[380751.913007] ret_from_fork+0x35/0x40

crash> dis -l iscsi_eh_cmd_timed_out+0x15e
xxxxx/drivers/scsi/libiscsi.c: 2062

1970 enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd
*sc)
{
...
1984 spin_lock_bh(&session->frwd_lock);
1985 task = (struct iscsi_task *)sc->SCp.ptr;
1986 if (!task) {
1987 /*
1988 * Raced with completion. Blk layer has taken
ownership
1989 * so let timeout code complete it now.
1990 */
1991 rc = BLK_EH_DONE;
1992 goto done;
1993 }

...

2052 for (i = 0; i < conn->session->cmds_max; i++) {
2053 running_task = conn->session->cmds[i];
2054 if (!running_task->sc || running_task == task ||
2055 running_task->state != ISCSI_TASK_RUNNING)
2056 continue;
2057
2058 /*
2059 * Only check if cmds started before this one have
made
2060 * progress, or this could never fail
2061 */
2062 if (time_after(running_task->sc->jiffies_at_alloc,
2063 task->sc->jiffies_at_alloc)) <---
2064 continue;
2065
...
}

carsh> struct scsi_cmnd ffff9fd1e6e931e8
struct scsi_cmnd {
...
SCp = {
ptr = 0x0, <--- iscsi_task
this_residual = 0,
...
},
}

To prevent this, we take a ref to the cmd under the back (completion) lock
so if the completion side were to call iscsi_complete_task() on the task
while the timer/eh paths are not holding the back_lock it will not be freed
from under us.

Note that this requires the previous patch, "scsi: libiscsi: Drop
taskqueuelock" because bnx2i sleeps in its cleanup_task callout if the cmd
is aborted. If the EH/timer and completion path are racing we don't know
which path will do the last put. The previous patch moved the operations we
needed to do under the forward lock to cleanup_queued_task. Once that has
run we can drop the forward lock for the cmd and bnx2i no longer has to
worry about if the EH, timer or completion path did the ast put and if the
forward lock is held or not since it won't be.

Link: https://lore.kernel.org/r/20210207044608.27585-4-michael.christie@oracle.com
Reported-by: Wu Bo <wubo40@huawei.com>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# a8b6d0ee 23-Jul-2020 Lee Jones <lee.jones@linaro.org>

scsi: bnx2i: Add parameter description and rename another

Fixes the following W=1 kernel build warning(s):

drivers/scsi/bnx2i/bnx2i_iscsi.c:1288: warning: Function parameter or member 'cmds_max' not described in 'bnx2i_session_create'
drivers/scsi/bnx2i/bnx2i_iscsi.c:2176: warning: Function parameter or member 'params' not described in 'bnx2i_nl_set_path'
drivers/scsi/bnx2i/bnx2i_iscsi.c:2176: warning: Excess function parameter 'buf' description in 'bnx2i_nl_set_path'

Link: https://lore.kernel.org/r/20200723122446.1329773-40-lee.jones@linaro.org
Cc: QLogic-Storage-Upstream@qlogic.com
Cc: Anil Veerabhadrappa <anilgv@broadcom.com>
Cc: Eddie Wai <eddie.wai@broadcom.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 89c19a8e 23-Jul-2020 Lee Jones <lee.jones@linaro.org>

scsi: bnx2i: Add, remove and edit some function parameter descriptions

Fixes the following W=1 kernel build warning(s):

drivers/scsi/bnx2i/bnx2i_iscsi.c:241: warning: Function parameter or member 'bnx2i_conn' not described in 'bnx2i_bind_conn_to_iscsi_cid'
drivers/scsi/bnx2i/bnx2i_iscsi.c:241: warning: Excess function parameter 'conn' description in 'bnx2i_bind_conn_to_iscsi_cid'
drivers/scsi/bnx2i/bnx2i_iscsi.c:470: warning: Excess function parameter 'cmd' description in 'bnx2i_destroy_cmd_pool'
drivers/scsi/bnx2i/bnx2i_iscsi.c:595: warning: Function parameter or member 'cls_session' not described in 'bnx2i_drop_session'
drivers/scsi/bnx2i/bnx2i_iscsi.c:595: warning: Excess function parameter 'hba' description in 'bnx2i_drop_session'
drivers/scsi/bnx2i/bnx2i_iscsi.c:595: warning: Excess function parameter 'session' description in 'bnx2i_drop_session'
drivers/scsi/bnx2i/bnx2i_iscsi.c:1290: warning: Function parameter or member 'ep' not described in 'bnx2i_session_create'
drivers/scsi/bnx2i/bnx2i_iscsi.c:1979: warning: Function parameter or member 'bnx2i_ep' not described in 'bnx2i_ep_tcp_conn_active'
drivers/scsi/bnx2i/bnx2i_iscsi.c:1979: warning: Excess function parameter 'ep' description in 'bnx2i_ep_tcp_conn_active'
drivers/scsi/bnx2i/bnx2i_iscsi.c:2178: warning: Function parameter or member 'shost' not described in 'bnx2i_nl_set_path'
drivers/scsi/bnx2i/bnx2i_iscsi.c:2178: warning: Function parameter or member 'params' not described in 'bnx2i_nl_set_path'
drivers/scsi/bnx2i/bnx2i_iscsi.c:2178: warning: Excess function parameter 'buf' description in 'bnx2i_nl_set_path'

Link: https://lore.kernel.org/r/20200723122446.1329773-30-lee.jones@linaro.org
Cc: QLogic-Storage-Upstream@qlogic.com
Cc: Anil Veerabhadrappa <anilgv@broadcom.com>
Cc: Eddie Wai <eddie.wai@broadcom.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 29d28f2b 06-Nov-2019 Pan Bian <bianpan2016@163.com>

scsi: bnx2i: fix potential use after free

The member hba->pcidev may be used after its reference is dropped. Move the
put function to where it is never used to avoid potential use after free
issues.

Fixes: a77171806515 ("[SCSI] bnx2i: Removed the reference to the netdev->base_addr")
Link: https://lore.kernel.org/r/1573043541-19126-1-git-send-email-bianpan2016@163.com
Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 7b8f32ee 04-Jan-2019 Colin Ian King <colin.king@canonical.com>

scsi: bnx2i: fix indentation issue, remove a tab

The return statement is indented incorrectly, fix this by removing a single
tab.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 2a3d4eb8 13-Dec-2018 Christoph Hellwig <hch@lst.de>

scsi: flip the default on use_clustering

Most SCSI drivers want to enable "clustering", that is merging of
segments so that they might span more than a single page. Remove the
ENABLE_CLUSTERING define, and require drivers to explicitly set
DISABLE_CLUSTERING to disable this feature.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# abef7510 22-Aug-2017 Kees Cook <keescook@chromium.org>

scsi: bnx2i: Convert timers to use timer_setup()

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

There was a seemingly missing call to initialize the timer in one handler,
so this was added to remove the open-coded initialization.

Cc: QLogic-Storage-Upstream@qlogic.com
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>


# 1d32a62c 23-Jun-2017 Dan Carpenter <dan.carpenter@oracle.com>

scsi: bnx2i: missing error code in bnx2i_ep_connect()

If bnx2i_map_ep_dbell_regs() then we accidentally return NULL instead of
an error pointer. It results in a NULL dereference in
iscsi_if_ep_connect().

Fixes: cf4e6363859d ("[SCSI] bnx2i: Add bnx2i iSCSI driver.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# b6a05c82 30-Jan-2017 Christoph Hellwig <hch@lst.de>

scsi: remove eh_timed_out methods in the transport template

Instead define the timeout behavior purely based on the host_template
eh_timed_out method and wire up the existing transport implementations
in the host templates. This also clears up the confusion that the
transport template method overrides the host template one, so some
drivers have to re-override the transport template one.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 9c8a76d5 13-Apr-2016 Dan Carpenter <dan.carpenter@oracle.com>

bnx2i: silence uninitialized variable warnings

Presumably it isn't possible to have empty lists here, but my static
checker doesn't know that and complains that "ep" can be used
uninitialized.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Nilesh Javali <nilesh.javali@qlogic.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 35843048 19-May-2015 Nilesh Javali <nilesh.javali@qlogic.com>

bnx2i: Fix call trace while device reset

The driver waits for command completion event while cleanup of task
within the frwd lock and back locks. The frwd lock was still held
which caused the call trace while issuing a device reset.
Release the frwd lock along with the back lock
to avoid waiting in the lock context.

Signed-off-by: Nilesh Javali <nilesh.javali@qlogic.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Odin.com>


# 5fc956c2 19-May-2015 Tej Parkash <tej.parkash@qlogic.com>

bnx2i: Fixed firmware assert, during target logout.

Fix the firmware assert, during target logout in
case driver received FIN from target before waiting for
asyncronous response.

Signed-off-by: Tej Parkash <tej.parkash@qlogic.com>
Signed-off-by: Nilesh Javali <nilesh.javali@qlogic.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Odin.com>


# db5ed4df 13-Nov-2014 Christoph Hellwig <hch@lst.de>

scsi: drop reason argument from ->change_queue_depth

Drop the now unused reason argument from the ->change_queue_depth method.
Also add a return value to scsi_adjust_queue_depth, and rename it to
scsi_change_queue_depth now that it can be used as the default
->change_queue_depth implementation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Reviewed-by: Hannes Reinecke <hare@suse.de>


# c40ecc12 13-Nov-2014 Christoph Hellwig <hch@lst.de>

scsi: avoid ->change_queue_depth indirection for queue full tracking

All drivers use the implementation for ramping the queue up and down, so
instead of overloading the change_queue_depth method call the
implementation diretly if the driver opts into it by setting the
track_queue_depth flag in the host template.

Note that a few drivers validated the new queue depth in their
change_queue_depth method, but as we never go over the queue depth
set during slave_configure or the sysfs file this isn't nessecary
and can safely be removed.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Venkatesh Srinivas <venkateshs@google.com>


# 7c160fac 19-May-2014 Tej Parkash <tej.parkash@qlogic.com>

bnx2i: Make boot_nic entry visible in the sysfs session objects

Signed-off-by: Tej Parkash <tej.parkash@qlogic.com>
Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Acked-by: Eddie Wai <eddie.wai@broadcom.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>


# f39a7757 03-Jul-2014 Vikas Chaudhary <vikas.chaudhary@qlogic.com>

bnx2i: Rebranding bnx2i driver

QLogic has acquired the NetXtremeII products and drivers from Broadcom.
This patch re-brands bnx2i driver as a QLogic driver

Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
Acked-by: Eddie Wai <eddie.wai@broadcom.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>


# 915aafd8 01-Jul-2014 Mike Christie <michaelc@cs.wisc.edu>

bnx2i, be2iscsi: fix custom stats length

The custom stats is an array with custom_length indicating the length
of the array. This patch fixes bnx2i and be2iscsi's setting of the
custom stats length. They both just have the one, eh_abort_cnt, so that should
be in the first entry of the custom array and custom_length should then
be one.

Reported-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Acked-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
Acked-by: Eddie Wai <eddie.wai@broadcom.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>


# be1fefc2 17-Mar-2014 Michael Chan <mchan@broadcom.com>

cnic,bnx2i,bnx2fc: Fix inconsistent use of page size

The bnx2/bnx2x rings are made up of linked pages. However there is an
upper limit on the page size as some the page size settings are 16-bit
in the hardware/firmware interface. In the current code, some parts
use BNX2_PAGE_SIZE which has a 16K upper limit and some parts use
PAGE_SIZE. On archs with >= 64K PAGE_SIZE, it generates some compile
warnings. Define a new CNIC_PAGE_SZIE which has an upper limit of
16K and use it consistently in all relevant parts.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


# 659743b0 06-Feb-2014 Shlomo Pongratz <shlomop@mellanox.com>

[SCSI] libiscsi: Reduce locking contention in fast path

Replace the session lock with two locks, a forward lock and
a backwards lock named frwd_lock and back_lock respectively.

The forward lock protects resources that change while sending a
request to the target, such as cmdsn, queued_cmdsn, and allocating
task from the commands' pool with kfifo_out.

The backward lock protects resources that change while processing
a response or in error path, such as cmdsn_exp, cmdsn_max, and
returning tasks to the commands' pool with kfifo_in.

Under a steady state fast-path situation, that is when one
or more processes/threads submit IO to an iscsi device and
a single kernel upcall (e.g softirq) is dealing with processing
of responses without errors, this patch eliminates the contention
between the queuecommand()/request response/scsi_done() flows
associated with iscsi sessions.

Between the forward and the backward locks exists a strict locking
hierarchy. The mutual exclusion zone protected by the forward lock can
enclose the mutual exclusion zone protected by the backward lock but not
vice versa.

For example, in iscsi_conn_teardown or in iscsi_xmit_data when there is
a failure and __iscsi_put_task is called, the backward lock is taken while
the forward lock is still taken. On the other hand, if in the RX path a nop
is to be sent, for example in iscsi_handle_reject or __iscsi_complete_pdu
than the forward lock is released and the backward lock is taken for the
duration of iscsi_send_nopout, later the backward lock is released and the
forward lock is retaken.

libiscsi_tcp uses two kernel fifos the r2t pool and the r2t queue.

The insertion and deletion from these queues didn't corespond to the
assumption taken by the new forward/backwards session locking paradigm.

That is, in iscsi_tcp_clenup_task which belongs to the RX (backwards)
path, r2t is taken out from r2t queue and inserted to the r2t pool.
In iscsi_tcp_get_curr_r2t which belong to the TX (forward) path, r2t
is also inserted to the r2t pool and another r2t is pulled from r2t
queue.

Only in iscsi_tcp_r2t_rsp which is called in the RX path but can requeue
to the TX path, r2t is taken from the r2t pool and inserted to the r2t
queue.

In order to cope with this situation, two spin locks were added,
pool2queue and queue2pool. The former protects extracting from the
r2t pool and inserting to the r2t queue, and the later protects the
extracing from the r2t queue and inserting to the r2t pool.

Signed-off-by: Shlomo Pongratz <shlomop@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
[minor fix up to apply cleanly and compile fix]
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 3f79410c 11-Oct-2013 Maxime Jayat <maxime@artisandeveloppeur.fr>

treewide: Fix common typo in "identify"

Correct common misspelling of "identify" as "indentify" throughout
the kernel

Signed-off-by: Maxime Jayat <maxime@artisandeveloppeur.fr>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 0b3bf387 11-Jul-2013 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Update version and copyright year 2013

Old version: 2.7.2.2
New version: 2.7.6.2

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# b83908ce 15-Oct-2012 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: removed the individual PCI DEVICE ID checking

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# a7717180 29-Jun-2012 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Removed the reference to the netdev->base_addr

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.

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.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 2e499d3c 25-Jun-2012 Barak Witkowski <barak@broadcom.com>

bnx2x, bnx2fc, bnx2i, cnic: Add statistics support and FCoE capabilities advertisement

1. When FCoE offload driver is registered, copy its capabilities to the chip
scratchpad.
2. Copy FCoE/iSCSI MAC addresses in aligned manner to chip scratchpad.
3. Add FCoE/iSCSI statistics collection support

Signed-off-by: Barak Witkowski <barak@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: Bhanu Prakash Gollapudi <bprakash@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


# 9ebd99c5 25-Apr-2012 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Updated version and copyright year

Old version: 2.7.0.3
New version: 2.7.2.2

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 6f9c04ff 25-Apr-2012 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Added the setting of target can_queue via target_alloc

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 587a1f16 23-Jul-2011 Al Viro <viro@zeniv.linux.org.uk>

switch ->is_visible() to returning umode_t

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# f27fb2ef 25-Jul-2011 Mike Christie <michaelc@cs.wisc.edu>

[SCSI] iscsi class: sysfs group is_visible callout for iscsi host attrs

The iscsi class currently does not support writable sysfs
attrs for LLD sysfs settings. This patch converts the
iscsi class and driver's host attrs to use the attribute
container sysfs group and the sysfs group's is_visible callout
to be able to support readable or writable sysfs attrs.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 1d063c17 25-Jul-2011 Mike Christie <michaelc@cs.wisc.edu>

[SCSI] iscsi class: sysfs group is_visible callout for session attrs

The iscsi class currently does not support writable sysfs
attrs for LLD sysfs settings. This patch converts the
iscsi class and driver's session attrs to use the attribute
container sysfs group and the sysfs group's is_visible callout
to be able to support readable or writable sysfs attrs.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 3128c6c7 25-Jul-2011 Mike Christie <michaelc@cs.wisc.edu>

[SCSI] iscsi cls: sysfs group is_visible callout for conn attrs

The iscsi class currently does not support writable sysfs
attrs for LLD sysfs settings. This patch converts the
iscsi class and drivers to use the attribute container
sysfs group and the sysfs group's is_visible callout
to be able to support readable or writable sysfs attrs.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 12352183 27-May-2011 Nicholas Bellinger <nab@linux-iscsi.org>

iscsi: Resolve iscsi_proto.h naming conflicts with drivers/target/iscsi

This patch renames the following iscsi_proto.h structures to avoid
namespace issues with drivers/target/iscsi/iscsi_target_core.h:

*) struct iscsi_cmd -> struct iscsi_scsi_req
*) struct iscsi_cmd_rsp -> struct iscsi_scsi_rsp
*) struct iscsi_login -> struct iscsi_login_req

This patch includes useful ISCSI_FLAG_LOGIN_[CURRENT,NEXT]_STAGE*,
and ISCSI_FLAG_SNACK_TYPE_* definitions used by iscsi_target_mod, and
fixes the incorrect definition of struct iscsi_snack to following
RFC-3720 Section 10.16. SNACK Request.

Also, this patch updates libiscsi, iSER, be2iscsi, and bn2xi to
use the updated structure definitions in a handful of locations.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>


# ea9582d7 23-Jun-2011 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Updated copyright and bump version

Bumped version from 2.6.2.3 to 2.7.0.3

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# b5cf6b63 23-Jun-2011 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Added the use of kthreads to handle SCSI cmd completion

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>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 9ae58e14 16-May-2011 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Optimized the iSCSI offload performance

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <jbottomley@parallels.com>


# d5307a07 16-May-2011 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Updated the connection shutdown/cleanup timeout

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Cc: stable@kernel.org
Signed-off-by: James Bottomley <jbottomley@parallels.com>


# 7287c63e 16-May-2011 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Fixed packet error created when the sq_size is set to 16

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Cc: stable@kernel.org
Signed-off-by: James Bottomley <jbottomley@parallels.com>


# d8585bcd 16-Feb-2011 Mike Christie <michaelc@cs.wisc.edu>

[SCSI] bnx2i: fix null ptr ref in conn get param

bnx2i has some checks to try and make sure the ep
is not destroyed while the addr/port is getting
read. However, if after this check:

if (!(bnx2i_conn && bnx2i_conn->ep && bnx2i_conn->ep->hba))
goto out;

bnx2i_conn->ep is cleared by ep_disconnect then we will
oops.

This patches fixes the problem by having the driver
use the get_ep_param callback instead of get_conn_param.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 09813ba5 16-Feb-2011 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Added iSCSI text pdu support for iSCSI offload

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>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# ec8933b4 16-Feb-2011 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Allow ep CONNECT_FAILED condition to go through proper cleanup

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>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 11cec1e2 23-Nov-2010 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Updated copyright and maintainer info

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# a91031a6 23-Nov-2010 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Cleaned up various error conditions in ep_connect/disconnect

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# bee34877 23-Nov-2010 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Added return code check for chip kwqe submission request

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 842158d7 23-Nov-2010 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Modified the bnx2i stop path to compensate for in progress ops

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 016ef690 23-Nov-2010 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Removed the dynamic registration of CNIC

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 7a2962c7 23-Nov-2010 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Added mutex lock protection to conn_get_param

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 252e4480 23-Nov-2010 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Allow to abort the connection if connect request times out

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 94810e82 23-Nov-2010 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Fixed the remote TCP RST handling for the 570X (1g)

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 5bf3f39f 23-Nov-2010 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Fixed a cid leak issue for 5771X (10g)

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 250ae982 12-Aug-2010 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Added chip cleanup for the remove module path

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 2c2255e0 12-Aug-2010 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Recouple the CFC delete cleanup with cm_abort/close completion

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 39304072 12-Aug-2010 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Fixed a protocol violation on nopout responses

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 625986c2 01-Jul-2010 Michael Chan <mchan@broadcom.com>

[SCSI] bnx2i: Added host param ISCSI_HOST_PARAM_IPADDRESS

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 2eefb20d 01-Jul-2010 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Fixed the TCP graceful termination initiation

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# e37d2c47 01-Jul-2010 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Fine tuned conn destroy and context destroy timeout values

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@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 55e15c97 01-Jul-2010 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Optimized the bnx2i_stop connection clean up procedure

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 46012e8b 01-Jul-2010 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Created an active linklist which holds bnx2i endpoints

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 6447f286 01-Jul-2010 Eddie Wai <eddie.wai@broadcom.com>

[SCSI] bnx2i: Separated the hardware's cleanup procedure from ep_disconnect

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>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 490475a9 08-Apr-2010 Anil Veerabhadrappa <anilgv@broadcom.com>

[SCSI] bnx2i: Bug fixes related to MTU change issue when there are active iscsi sessions

bnx2i driver has to wait and cleanup all iscsi endpoints before
returning from bnx2i_stop(). This is to make sure all chip resources
are freed before chip is reset.

As the requirements for 1G and 10G chipsets is different, added
per-device 'hba_shutdown_tmo' parameter to adapter structure

If the connections are not torn down by the daemon within this timeout
period, 'cid's will be leaked in 10G device. 1G devices are more
flexible and do not leak any resources because the whole chip ports
gets reset when MTU is changed or ethtool selftest is run

fixed a minor issue in bnx2i_ep_poll() which unnecessarily forced
error return code when driver timed out waiting for TCP connect
request to complete

Signed-off-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 5a0e3ad6 24-Mar-2010 Tejun Heo <tj@kernel.org>

include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h

percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.

2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).

* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>


# 309ce156 19-Feb-2010 Jayamohan Kallickal <jayamohank@serverengines.com>

[SCSI] libiscsi: Make iscsi_eh_target_reset start with session reset

The iscsi_eh_target_reset has been modified to attempt
target reset only. If it fails, then iscsi_eh_session_reset
will be called.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: Jayamohan Kallickal <jayamohank@serverengines.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 9f9127fd 10-Feb-2010 Mike Christie <michaelc@cs.wisc.edu>

[SCSI] bnx2i: set change_queue_depth function

No reason that we cannot set the change_queue_depth
function for bnx2i. We just forgot to when the
driver was created.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# d9573e7a 10-Feb-2010 Joe Perches <joe@perches.com>

[SCSI] cxgb3i, bnx2i: remove uses of nipquad use %pi4

Remove uses of NIPQUAD, use %pI4

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 45ca38e7 07-Dec-2009 Anil Veerabhadrappa <anilgv@broadcom.com>

[SCSI] bnx2i: minor code cleanup and update driver version

Removed duplicate function call and not-so-useful comment line

Signed-off-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 3fe5ae8b 11-Nov-2009 Mike Christie <michaelc@cs.wisc.edu>

[SCSI] libiscsi: add warm target reset tmf support

This implements warm target reset tmf support for
the scsi-ml target reset callback. Previously we would
just drop the session in that callback. This patch will
now try a target reset and if that fails drop the session.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 24246de7 11-Nov-2009 Mike Christie <michaelc@cs.wisc.edu>

[SCSI] bnx2i: use common iscsi suspend queue

This just has bnx2i use the iscsi_suspend_queue helper.

The suspend works as follows:

When ep_poll has succeeed iscsid will call conn_bind, the LLD will
then call iscsi_conn_bind which will clear the suspend bit.
When ep_disconnect is called (or if there is a conn error) we set
the suspend bit. For the ep_disconnect case I added a helper
in the previous kernel that will take the session lock to make sure
iscsi_queuecommand/xmit_task is not running and it will set
the suspend bit.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Acked-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 94e2bd68 16-Oct-2009 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>

tree-wide: fix some typos and punctuation in comments

fix some typos and punctuation in comments

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# b8b9e1b8 21-Sep-2009 Jayamohan Kallickal <jayamohank@serverengines.com>

[SCSI] libiscsi: iscsi_session_setup to allow for private space

This patch contains changes that allow iscsi_session_setup
to allocate private space for LLD's

Signed-off-by: Jayamohan Kallickal <jayamohank@serverengines.com>
Acked-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# c19dcd01 29-Jul-2009 Anil Veerabhadrappa <anilgv@broadcom.com>

[SCSI] bnx2i : Fix "cid #n not valid" issue

When bnx2i_adapter_ready() fails, connection handle(cid) = 0 is wrongly freed
because 'cid' is not yet allocated for the endpoint. Fix is to initialize
bnx2i_ep->ep_iscsi_cid to '-1' in bnx2i_alloc_ep() and not in
bnx2i_ep_connect() to avoid releasing invalid 'cid'. There is already a check
in bnx2i_free_iscsi_cid() not to free invalid iscsi connection handle (-1)

Signed-off-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 534cc9c1 29-Jul-2009 Anil Veerabhadrappa <anilgv@broadcom.com>

[SCSI] bnx2i : Fix command session number jump issue seen during cable pull test

Without the fix bnx2i would fail tt->xmit_task() when link is down and
libiscsi would have already incremented session->cmdsn before calling bnx2i's
xmit_task() entry point and will just return the command to SCSI-ML when
xmit_task() fails. libiscsi does not retract the session->cmdsn as the command
was never sent on wire. It is generally good idea for LLD, bnx2i to accept
the scsi cmnd/nopout and let upper layer timeout and go though normal session
recovery process. When link is down, unsolicited nopout will not be accepted
by bnx2i and connection will never enter recovery state. This fix is required
for MPIO to work corectly

Signed-off-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# fac3cc45 08-Jul-2009 Anil Veerabhadrappa <anilgv@broadcom.com>

[SCSI] bnx2i: register given device with cnic if shost != NULL in ep_connect()

When using iface, bnx2i was unable to offload further connections after all
active sessions are logged out. bnx2i will unregister the device from cnic
when the last connection is torn down. Next call to ep_connect() will fail
because the device is not registered. This issue is not seen if shost == NULL
is passed to ep_connect() call because in that case bnx2i will registers all
known devices with cnic before doing a route look-up. When shost != NULL,
bnx2i knows the device on which to offload the connection and has to register
this device before attempting to offload the connection

Signed-off-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# cf4e6363 08-Jun-2009 Michael Chan <mchan@broadcom.com>

[SCSI] bnx2i: Add bnx2i iSCSI driver.

New iSCSI driver for Broadcom BNX2 devices. The driver interfaces with
the CNIC driver to access the hardware.

Signed-off-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>