History log of /linux-master/drivers/scsi/qedf/qedf_main.c
Revision Date Author Comments
# ade4fb94 02-Oct-2023 Hannes Reinecke <hare@suse.de>

scsi: qedf: Use FC rport as argument for qedf_initiate_tmf()

When sending a TMF we're only concerned with the rport and the LUN ID, so
use struct fc_rport as argument for qedf_initiate_tmf().

Signed-off-by: Hannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/20231002154328.43718-5-hare@suse.de
Cc: Saurav Kashyap <skashyap@marvell.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 7df0b260 01-Sep-2023 Javed Hasan <jhasan@marvell.com>

scsi: qedf: Add synchronization between I/O completions and abort

Avoid race condition between I/O completion and abort processing by
protecting the cmd_type with the rport lock.

Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Link: https://lore.kernel.org/r/20230901060646.27885-1-skashyap@marvell.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# ef222f55 07-Aug-2023 Nilesh Javali <njavali@marvell.com>

scsi: qedf: Fix firmware halt over suspend and resume

While performing certain power-off sequences, PCI drivers are called to
suspend and resume their underlying devices through PCI PM (power
management) interface. However the hardware does not support PCI PM
suspend/resume operations so system wide suspend/resume leads to bad MFW
(management firmware) state which causes various follow-up errors in driver
when communicating with the device/firmware.

To fix this driver implements PCI PM suspend handler to indicate
unsupported operation to the PCI subsystem explicitly, thus avoiding system
to go into suspended/standby mode.

Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.")
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Link: https://lore.kernel.org/r/20230807093725.46829-1-njavali@marvell.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# f025312b 02-May-2023 Jinhong Zhu <jinhongzhu@hust.edu.cn>

scsi: qedf: Fix NULL dereference in error handling

Smatch reported:

drivers/scsi/qedf/qedf_main.c:3056 qedf_alloc_global_queues()
warn: missing unwind goto?

At this point in the function, nothing has been allocated so we can return
directly. In particular the "qedf->global_queues" have not been allocated
so calling qedf_free_global_queues() will lead to a NULL dereference when
we check if (!gl[i]) and "gl" is NULL.

Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.")
Signed-off-by: Jinhong Zhu <jinhongzhu@hust.edu.cn>
Link: https://lore.kernel.org/r/20230502140022.2852-1-jinhongzhu@hust.edu.cn
Reviewed-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 7866e03b 30-Mar-2023 Tom Rix <trix@redhat.com>

scsi: qedf: Remove unused 'num_handled' variable

clang with W=1 reports:

drivers/scsi/qedf/qedf_main.c:2227:6: error: variable
'num_handled' set but not used [-Werror,-Wunused-but-set-variable]
int num_handled = 0;
^
This variable is not used so remove it.

Signed-off-by: Tom Rix <trix@redhat.com>
Link: https://lore.kernel.org/r/20230330203444.1842425-1-trix@redhat.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# be8532d1 22-Mar-2023 Bart Van Assche <bvanassche@acm.org>

scsi: qedf: Declare host template const

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

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


# e6f8a22f 09-Oct-2022 Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

scsi: qedf: Remove set but unused variable 'page'

The variable page is not used in the function, so delete it.

Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=2348
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Link: https://lore.kernel.org/r/20221009060249.40178-1-jiapeng.chong@linux.alibaba.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 592642e6 19-Sep-2022 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Populate sysfs attributes for vport

Few vport parameters were displayed by systool as 'Unknown' or 'NULL'.
Copy speed, supported_speed, frame_size and update port_type for NPIV port.

Link: https://lore.kernel.org/r/20220919134434.3513-1-njavali@marvell.com
Cc: stable@vger.kernel.org
Tested-by: Guangwu Zhang <guazhang@redhat.com>
Reviewed-by: John Meneghini <jmeneghi@redhat.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# fbfe9686 12-Nov-2021 Letu Ren <fantasquex@gmail.com>

scsi: qedf: Fix a UAF bug in __qedf_probe()

In __qedf_probe(), if qedf->cdev is NULL which means
qed_ops->common->probe() failed, then the program will goto label err1, and
scsi_host_put() will free lport->host pointer. Because the memory qedf
points to is allocated by libfc_host_alloc(), it will be freed by
scsi_host_put(). However, the if statement below label err0 only checks
whether qedf is NULL but doesn't check whether the memory has been freed.
So a UAF bug can occur.

There are two ways to reach the statements below err0. The first one is
described as before, "qedf" should be set to NULL. The second one is goto
"err0" directly. In the latter scenario qedf hasn't been changed and it has
the initial value NULL. As a result the if statement is not reachable in
any situation.

The KASAN logs are as follows:

[ 2.312969] BUG: KASAN: use-after-free in __qedf_probe+0x5dcf/0x6bc0
[ 2.312969]
[ 2.312969] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014
[ 2.312969] Call Trace:
[ 2.312969] dump_stack_lvl+0x59/0x7b
[ 2.312969] print_address_description+0x7c/0x3b0
[ 2.312969] ? __qedf_probe+0x5dcf/0x6bc0
[ 2.312969] __kasan_report+0x160/0x1c0
[ 2.312969] ? __qedf_probe+0x5dcf/0x6bc0
[ 2.312969] kasan_report+0x4b/0x70
[ 2.312969] ? kobject_put+0x25d/0x290
[ 2.312969] kasan_check_range+0x2ca/0x310
[ 2.312969] __qedf_probe+0x5dcf/0x6bc0
[ 2.312969] ? selinux_kernfs_init_security+0xdc/0x5f0
[ 2.312969] ? trace_rpm_return_int_rcuidle+0x18/0x120
[ 2.312969] ? rpm_resume+0xa5c/0x16e0
[ 2.312969] ? qedf_get_generic_tlv_data+0x160/0x160
[ 2.312969] local_pci_probe+0x13c/0x1f0
[ 2.312969] pci_device_probe+0x37e/0x6c0

Link: https://lore.kernel.org/r/20211112120641.16073-1-fantasquex@gmail.com
Reported-by: Zheyu Ma <zheyuma97@gmail.com>
Acked-by: Saurav Kashyap <skashyap@marvell.com>
Co-developed-by: Wende Tan <twd2.me@gmail.com>
Signed-off-by: Wende Tan <twd2.me@gmail.com>
Signed-off-by: Letu Ren <fantasquex@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# a912460e 05-May-2022 Sebastian Andrzej Siewior <bigeasy@linutronix.de>

scsi: fcoe: Use per-CPU API to update per-CPU statistics

The per-CPU statistics (struct fc_stats) is updated by getting a stable
per-CPU pointer via get_cpu() + per_cpu_ptr() and then performing the
increment. This can be optimized by using this_cpu_*() which will do
whatever is needed on the architecture to perform the update safe and
efficient. The read out of the individual value (fc_get_host_stats())
should be done by using READ_ONCE() instead of a plain-C access. The
difference is that READ_ONCE() will always perform a single access while
the plain-C access can be split by the compiler into two loads if it
appears beneficial. The usage of u64 has the side-effect that it is also
64bit wide on 32bit architectures and the read is always split into two
loads. The can lead to strange values if the read happens during an update
which alters both 32bit parts of the 64bit value. This can be circumvented
by either using a 32bit variables on 32bit architecures or extending the
statistics with a sequence counter.

Use this_cpu_*() API to update the statistics and READ_ONCE() to read it.

Link: https://lore.kernel.org/r/20220506105758.283887-3-bigeasy@linutronix.de
Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 505420bd 04-Apr-2022 Xiaomeng Tong <xiam0nd.tong@gmail.com>

scsi: qedf: Remove an unneeded NULL check on list iterator

The list iterator 'fcport' is always non-NULL so it doesn't need to be
checked. Thus just remove the unnecessary NULL check. Also remove the
unnecessary initializer because the list iterator is always initialized.
And adjust the position of blank lines.

Link: https://lore.kernel.org/r/20220405004055.24312-1-xiam0nd.tong@gmail.com
Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


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

scsi: qedf: Stop using the SCSI pointer

Set .cmd_size in the SCSI host template instead of using the SCSI pointer
from struct scsi_cmnd. Remove the CMD_SCSI_STATUS() assignment because the
assigned value is not used.

This patch prepares for removal of the SCSI pointer from struct scsi_cmnd.

Link: https://lore.kernel.org/r/20220218195117.25689-30-bvanassche@acm.org
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 64fd4af6 17-Jan-2022 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Change context reset messages to ratelimited

If FCoE is not configured, libfc/libfcoe keeps on retrying FLOGI and after
3 retries driver does a context reset and tries fipvlan again. This leads
to context reset message flooding the logs. Hence ratelimit the message to
prevent flooding the logs.

Link: https://lore.kernel.org/r/20220117135311.6256-4-njavali@marvell.com
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# b70a99fd 17-Jan-2022 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Add stag_work to all the vports

Call trace seen when creating NPIV ports, only 32 out of 64 show online.
stag work was not initialized for vport, hence initialize the stag work.

WARNING: CPU: 8 PID: 645 at kernel/workqueue.c:1635 __queue_delayed_work+0x68/0x80
CPU: 8 PID: 645 Comm: kworker/8:1 Kdump: loaded Tainted: G IOE --------- --
4.18.0-348.el8.x86_64 #1
Hardware name: Dell Inc. PowerEdge MX740c/0177V9, BIOS 2.12.2 07/09/2021
Workqueue: events fc_lport_timeout [libfc]
RIP: 0010:__queue_delayed_work+0x68/0x80
Code: 89 b2 88 00 00 00 44 89 82 90 00 00 00 48 01 c8 48 89 42 50 41 81
f8 00 20 00 00 75 1d e9 60 24 07 00 44 89 c7 e9 98 f6 ff ff <0f> 0b eb
c5 0f 0b eb a1 0f 0b eb a7 0f 0b eb ac 44 89 c6 e9 40 23
RSP: 0018:ffffae514bc3be40 EFLAGS: 00010006
RAX: ffff8d25d6143750 RBX: 0000000000000202 RCX: 0000000000000002
RDX: ffff8d2e31383748 RSI: ffff8d25c000d600 RDI: ffff8d2e31383788
RBP: ffff8d2e31380de0 R08: 0000000000002000 R09: ffff8d2e31383750
R10: ffffffffc0c957e0 R11: ffff8d2624800000 R12: ffff8d2e31380a58
R13: ffff8d2d915eb000 R14: ffff8d25c499b5c0 R15: ffff8d2e31380e18
FS: 0000000000000000(0000) GS:ffff8d2d1fb00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055fd0484b8b8 CR3: 00000008ffc10006 CR4: 00000000007706e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
Call Trace:
queue_delayed_work_on+0x36/0x40
qedf_elsct_send+0x57/0x60 [qedf]
fc_lport_enter_flogi+0x90/0xc0 [libfc]
fc_lport_timeout+0xb7/0x140 [libfc]
process_one_work+0x1a7/0x360
? create_worker+0x1a0/0x1a0
worker_thread+0x30/0x390
? create_worker+0x1a0/0x1a0
kthread+0x116/0x130
? kthread_flush_work_fn+0x10/0x10
ret_from_fork+0x35/0x40
---[ end trace 008f00f722f2c2ff ]--

Initialize stag work for all the vports.

Link: https://lore.kernel.org/r/20220117135311.6256-2-njavali@marvell.com
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# aa7069d8 16-Dec-2021 Jiasheng Jiang <jiasheng@iscas.ac.cn>

scsi: qedf: Fix potential dereference of NULL pointer

The return value of dma_alloc_coherent() needs to be checked to avoid use
of NULL pointer in case of an allocation failure.

Link: https://lore.kernel.org/r/20211216101449.375953-1-jiasheng@iscas.ac.cn
Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.")
Acked-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


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

scsi: qedf: 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-38-bvanassche@acm.org
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# fb09a1ed 04-Oct-2021 Shai Malin <smalin@marvell.com>

qed: Remove e4_ and _e4 from FW HSI

The existing qed/qede/qedr/qedi/qedf code uses chip-specific naming in
structures, functions, variables and defines in FW HSI (Hardware
Software Interface).

The new FW version introduced a generic naming convention in HSI
in-which the same code will be used across different versions
for simpler maintainability. It also eases in providing support for
new features.

With this patch every "_e4" or "e4_" prefix or suffix is not needed
anymore and it will be removed.

Reviewed-by: Manish Rangankar <mrangankar@marvell.com>
Reviewed-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Ariel Elior <aelior@marvell.com>
Signed-off-by: Omkar Kulkarni <okulkarni@marvell.com>
Signed-off-by: Shai Malin <smalin@marvell.com>
Signed-off-by: Prabhakar Kushwaha <pkushwaha@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


# e6a54d6f 23-Sep-2021 Leon Romanovsky <leon@kernel.org>

qed: Don't ignore devlink allocation failures

devlink is a software interface that doesn't depend on any hardware
capabilities. The failure in SW means memory issues, wrong parameters,
programmer error e.t.c.

Like any other such interface in the kernel, the returned status of
devlink APIs should be checked and propagated further and not ignored.

Fixes: 755f982bb1ff ("qed/qede: make devlink survive recovery")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


# ccc89737 10-Aug-2021 Dan Carpenter <dan.carpenter@oracle.com>

scsi: qedf: Fix error codes in qedf_alloc_global_queues()

This driver has some left over "return 1" on failure style code mixed with
"return negative error codes" style code. The caller doesn't care so we
should just convert everything to return negative error codes.

Then there was a problem that there were two variables used to store error
codes which just resulted in confusion. If qedf_alloc_bdq() returned a
negative error code, we accidentally returned success instead of
propagating the error code. So get rid of the "rc" variable and use
"status" every where.

Also remove the "status = 0" initialization so that these sorts of bugs
will be detected by the compiler in the future.

Link: https://lore.kernel.org/r/20210810085023.GA23998@kili
Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.")
Acked-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# adb98ec7 03-Jun-2021 Javed Hasan <jhasan@marvell.com>

scsi: qedf: Add vendor identifier attribute

Link: https://lore.kernel.org/r/20210603121623.10084-3-jhasan@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 1b67f3d7 02-Jun-2021 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Update the max_id value in host structure

host->max_id defines the maximum target id that the SCSI midlayer will
attempt to manually scan. The default is 8. Update the value to the max
sessions the driver supports.

[mkp: applied by hand]

Link: https://lore.kernel.org/r/20210602104653.17278-1-jhasan@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 09c65383 09-May-2021 Guenter Roeck <linux@roeck-us.net>

scsi: qedf: Drop unnecessary NULL checks after container_of()

The result of container_of() operations is never NULL unless the embedded
element is the first element of the structure, which is not the case here.
The NULL checks are therefore unnecessary and misleading. Remove them.

The changes in this patch were made automatically using the following
Coccinelle script.

@@
type t;
identifier v;
statement s;
@@

<+...
(
t v = container_of(...);
|
v = container_of(...);
)
...
when != v
- if (\( !v \| v == NULL \) ) s
...+>

Link: https://lore.kernel.org/r/20210510041211.2051325-1-linux@roeck-us.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 79c932cd 21-May-2021 Daniel Wagner <dwagner@suse.de>

scsi: qedf: Do not put host in qedf_vport_create() unconditionally

Do not drop reference count on vn_port->host in qedf_vport_create()
unconditionally. Instead drop the reference count in qedf_vport_destroy().

Link: https://lore.kernel.org/r/20210521143440.84816-1-dwagner@suse.de
Reported-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 73578af9 12-May-2021 Javed Hasan <jhasan@marvell.com>

scsi: qedf: Add pointer checks in qedf_update_link_speed()

The following trace was observed:

[ 14.042059] Call Trace:
[ 14.042061] <IRQ>
[ 14.042068] qedf_link_update+0x144/0x1f0 [qedf]
[ 14.042117] qed_link_update+0x5c/0x80 [qed]
[ 14.042135] qed_mcp_handle_link_change+0x2d2/0x410 [qed]
[ 14.042155] ? qed_set_ptt+0x70/0x80 [qed]
[ 14.042170] ? qed_set_ptt+0x70/0x80 [qed]
[ 14.042186] ? qed_rd+0x13/0x40 [qed]
[ 14.042205] qed_mcp_handle_events+0x437/0x690 [qed]
[ 14.042221] ? qed_set_ptt+0x70/0x80 [qed]
[ 14.042239] qed_int_sp_dpc+0x3a6/0x3e0 [qed]
[ 14.042245] tasklet_action_common.isra.14+0x5a/0x100
[ 14.042250] __do_softirq+0xe4/0x2f8
[ 14.042253] irq_exit+0xf7/0x100
[ 14.042255] do_IRQ+0x7f/0xd0
[ 14.042257] common_interrupt+0xf/0xf
[ 14.042259] </IRQ>

API qedf_link_update() is getting called from QED but by that time
shost_data is not initialised. This results in a NULL pointer dereference
when we try to dereference shost_data while updating supported_speeds.

Add a NULL pointer check before dereferencing shost_data.

Link: https://lore.kernel.org/r/20210512072533.23618-1-jhasan@marvell.com
Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.")
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 9d6f87c2 31-Mar-2021 Javed Hasan <jhasan@marvell.com>

scsi: qedf: Use devlink to report errors and recovery

Use devlink_health_report() to push error indications.

Implement this in qede via a callback function to make it possible to reuse
it for other drivers sitting on top of qed in future. Also remove forcible
recovery trigger and put it as a normal devlink callback in qed module.

This allows user to enable/disable it via:

devlink health set pci/xxxx:xx:xx.x reporter fw_fatal auto_recover false

Link: https://lore.kernel.org/r/20210331164917.24662-3-jhasan@marvell.com
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 4aab946f 31-Mar-2021 Javed Hasan <jhasan@marvell.com>

scsi: qedf: Enable devlink support

Devlink instance lifetime was linked to qed_dev object. That caused devlink
to be recreated on each recovery.

Change it by making higher level driver (qede) responsible for lifetime
management. This way devlink survives recoveries.

qede now stores devlink structure pointer as a part of its device object,
devlink private data contains a linkage structure, qed_devlink.

Link: https://lore.kernel.org/r/20210331164917.24662-2-jhasan@marvell.com
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# ac341c2d 11-Jan-2021 YANG LI <abaci-bugfix@linux.alibaba.com>

scsi: qedf: Simplify bool comparison

Fix the following coccicheck warning:

./drivers/scsi/qedf/qedf_main.c:3716:5-31: WARNING: Comparison to bool

Link: https://lore.kernel.org/r/1610357368-62866-1-git-send-email-abaci-bugfix@linux.alibaba.com
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Acked-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: YANG LI <abaci-bugfix@linux.alibaba.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 988100a7 07-Sep-2020 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Retry qed->probe during recovery

During recovery due to FCoE fn ramrod failure we wait for 2 sec and then
call qed->probe. If probe fails then retry max 10 times.

Link: https://lore.kernel.org/r/20200907121443.5150-8-jhasan@marvell.com
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 55e04991 07-Sep-2020 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Add schedule_hw_err_handler callback for fan failure

On fan failure, disable the PCI function and initiate recovery for ramrod
failure.

Link: https://lore.kernel.org/r/20200907121443.5150-7-jhasan@marvell.com
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 10aff62f 07-Sep-2020 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Return SUCCESS if stale rport is encountered

If SUCCESS is not returned, error handling will escalate. Return SUCCESS
similar to other conditions in this function.

Link: https://lore.kernel.org/r/20200907121443.5150-6-jhasan@marvell.com
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 41715c62 07-Sep-2020 Javed Hasan <jhasan@marvell.com>

scsi: qedf: FDMI attributes correction

Correction in the FDMI attributes required for RHBA and RPA registration.

Link: https://lore.kernel.org/r/20200907121443.5150-5-jhasan@marvell.com
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# f78f8126 07-Sep-2020 Javed Hasan <jhasan@marvell.com>

scsi: qedf: Fix for the session’s E_D_TOV value

Firmware expects E_D_TOV field in connection offload parameters as “msec”.
Earlier incorrect value (100ms), was leading to abort from driver in the
case when data frames for read take more than 100ms from target side,
resulting in firmware reporting E_D_TOV expiration.

Link: https://lore.kernel.org/r/20200907121443.5150-4-jhasan@marvell.com
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 06666464 07-Sep-2020 Javed Hasan <jhasan@marvell.com>

scsi: qedf: Change the debug parameter permission to read & write

Change the debug parameter permission to read & write. Gives flexibility
to change the debug verbosity dynamically.

Link: https://lore.kernel.org/r/20200907121443.5150-2-jhasan@marvell.com
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# f308a35f 23-Aug-2020 Ye Bin <yebin10@huawei.com>

scsi: qedf: Fix null ptr reference in qedf_stag_change_work

Link: https://lore.kernel.org/r/20200824033436.45570-1-yebin10@huawei.com
Acked-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Ye Bin <yebin10@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# a521bbc3 07-Aug-2020 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Check for port type and role before processing an event

The rport lock gets initialized during offload. If a non-FCP or non-target
rport got logout then this rport will be uninitialized. KASAN was
complaining because of it.

=========
[ 14.384434] the code is fine but needs lockdep annotation.
[ 14.384482] turning off the locking correctness validator.
========

Link: https://lore.kernel.org/r/20200807110656.19965-2-jhasan@marvell.com
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# bdb5d8ec 20-Jul-2020 Alexander Lobakin <alobakin@pm.me>

qed, qede, qedf: convert link mode from u32 to ETHTOOL_LINK_MODE

Currently qed driver already ran out of 32 bits to store link modes,
and this doesn't allow to add and support more speeds.
Convert custom link mode to generic Ethtool bitmap and definitions
(convenient Phylink shorthands are used for elegance and readability).
This allowed us to drop all conversions/mappings between the driver
and Ethtool.

This involves changes in qede and qedf as well, as they used definitions
from shared "qed_if.h".

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Alexander Lobakin <alobakin@marvell.com>
Signed-off-by: Igor Russkikh <irusskikh@marvell.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>


# c6e2f4bd 13-Jul-2020 Lee Jones <lee.jones@linaro.org>

scsi: qedf: Remove set but not checked variable 'tmp'

Looks like the return value of readw() has never been checked.

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

drivers/scsi/qedf/qedf_main.c: In function ‘__qedf_probe’:
drivers/scsi/qedf/qedf_main.c:3203:6: warning: variable ‘tmp’ set but not used [-Wunused-but-set-variable]

Link: https://lore.kernel.org/r/20200713074645.126138-10-lee.jones@linaro.org
Cc: QLogic-Storage-Upstream@cavium.com
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# a9d4aece 13-Jul-2020 Lee Jones <lee.jones@linaro.org>

scsi: qedf: Demote obvious misuse of kerneldoc to standard comment blocks

No attempt has been made to document either of the demoted functions here.

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

drivers/scsi/qedf/qedf_main.c:1027: warning: Function parameter or member 'lport' not described in 'qedf_xmit'
drivers/scsi/qedf/qedf_main.c:1027: warning: Function parameter or member 'fp' not described in 'qedf_xmit'
drivers/scsi/qedf/qedf_main.c:1426: warning: Function parameter or member 'lport' not described in 'qedf_rport_event_handler'
drivers/scsi/qedf/qedf_main.c:1426: warning: Function parameter or member 'rdata' not described in 'qedf_rport_event_handler'
drivers/scsi/qedf/qedf_main.c:1426: warning: Function parameter or member 'event' not described in 'qedf_rport_event_handler'

Link: https://lore.kernel.org/r/20200713074645.126138-9-lee.jones@linaro.org
Cc: QLogic-Storage-Upstream@cavium.com
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 7109cb51 16-Apr-2020 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Get dev info after updating the params

An update to pf params can change the devinfo. Get updated device
information.

[mkp: updated error message spotted by Sergei Shtylyov]

Link: https://lore.kernel.org/r/20200416084314.18851-10-skashyap@marvell.com
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# ad40f525 16-Apr-2020 Chad Dupuis <cdupuis@marvell.com>

scsi: qedf: Fix crash when MFW calls for protocol stats while function is still probing

The MFW may make a call to qed and then to qedf for protocol statistics
while the function is still probing. If this happens it's possible that
some members of the struct qedf_ctx may not be fully initialized which can
result in a NULL pointer dereference or general protection fault.

To prevent this, add a new flag call QEDF_PROBING and set it when the
__qedf_probe() function is active. Then in the qedf_get_protocol_tlv_data()
function we can check if the function is still probing and return
immediantely before any uninitialized structures can be touched.

Link: https://lore.kernel.org/r/20200416084314.18851-9-skashyap@marvell.com
Signed-off-by: Chad Dupuis <cdupuis@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# f6b172f2 16-Apr-2020 Chad Dupuis <cdupuis@marvell.com>

scsi: qedf: Add schedule recovery handler

Implement recovery handler to be used by QED to signal the need for
recovery to come out of an error condition like ramrod struck and firmware
context reset.

Link: https://lore.kernel.org/r/20200416084314.18851-8-skashyap@marvell.com
Signed-off-by: Chad Dupuis <cdupuis@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 6e7c8eea 16-Apr-2020 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Implement callback for bw_update

Add support for the common qed bw_update callback to qedf. This function
is called whenever there is a reported change in the bandwidth and updates
corresponding values in sysfs.

Link: https://lore.kernel.org/r/20200416084314.18851-7-skashyap@marvell.com
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# ab0a8299 16-Apr-2020 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Keep track of num of pending flogi

If a port is brought down for an extended period of time, the fipvlan
counter gets exhausted and the driver will fall back to default VLAN 1002
and call fcoe_ctlr_link_up to log in. However, the switch will discard the
FLOGI attempt because the VLAN is now different.

Keep track of the number of FLOGI attempts and if a threshold of
QEDF_FLOGI_RETRY_CNT is exceeded, perform a context soft reset.

Link: https://lore.kernel.org/r/20200416084314.18851-2-skashyap@marvell.com
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# dbce64cb 02-Mar-2020 Jacob Keller <jacob.e.keller@intel.com>

scsi: qedf: Use pci_get_dsn()

Replace the open-coded implementation for reading the PCIe DSN with
pci_get_dsn().

The original code used a for-loop that looped over each of the 8 bytes
and copied them into a temporary buffer. pci_get_dsn() uses two calls to
pci_read_config_dword, and correctly bitwise ORs them into a u64. Thus,
we can simplify the snprintf significantly using %016llX on a u64 value.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


# c3dde2f3 24-Sep-2019 Daniel Wagner <dwagner@suse.de>

scsi: qedf: Add port_id getter

Add qedf_get_host_port_id() to the transport template.

The fc_transport_template initializes the port_id member to the default
value of -1. The new getter ensures that the sysfs entry shows the current
value and not the default one, e.g by using 'lsscsi -H -t'

Link: https://lore.kernel.org/r/20190924072906.23737-1-dwagner@suse.de
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Acked-by: Saurav Kashyap <skashyap@marvell.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 4b062e7c 19-Sep-2019 Austin Kim <austindh.kim@gmail.com>

scsi: qedf: Remove always false 'tmp_prio < 0' statement

Since tmp_prio is declared as u8, the following statement is always false.
tmp_prio < 0

So remove 'always false' statement.

Link: https://lore.kernel.org/r/20190919075548.GA112801@LGEARND20B15
Signed-off-by: Austin Kim <austindh.kim@gmail.com>
Acked-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 3480e7a8 23-Aug-2019 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Fix race betwen fipvlan request and response path

There is a race b/w fipvlan request and response path:

=====
qedf_fcoe_process_vlan_resp:113]:2: VLAN response, vid=0xffd.
qedf_initiate_fipvlan_req:165]:2: vlan = 0x6ffd already set.
qedf_set_vlan_id:139]:2: Setting vlan_id=0ffd prio=3.
======

The request thread sees that vlan is already set and fails to call
ctrl_link_up.

Fix:

- While setting vlan_id use local variable and before setting vlan_id.

- Call fcoe_ctlr_link_up in next iteration of fipvlan request.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 5797bcc8 23-Aug-2019 Hannes Reinecke <hare@suse.com>

scsi: qedf: Use discovery list to traverse rports

The list of rports might become stale so we should rather traverse the
discovery list when trying relogin.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# f6d63678 23-Aug-2019 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Decrease the LL2 MTU size to 2500

Decrease the LL2 MTU size to 2500.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 04822626 23-Aug-2019 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Check for module unloading bit before processing link update AEN

Prevent race where we're removing the module and we get link update

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 931285e0 23-Aug-2019 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Add support for 20 Gbps speed

The current code doeesn't support 20Gbps speed for current and supported
speed. Add support for it.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# fa74f5e3 23-Aug-2019 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Interpret supported caps value correctly

Driver was wrongly interpreting the supported cap value returned by qed.

Solution: Use QED define macros instead of OS defined for interpreting
supporting speeds.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 31696204 23-Aug-2019 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Add shutdown callback handler

Add shutdown callback handler.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# ec6350b8 23-Aug-2019 Nilesh Javali <njavali@marvell.com>

scsi: qedf: Update module description string

Update module description.

Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 4909e153 23-Aug-2019 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Stop sending fipvlan request on unload

- On some setups fipvlan can be retried for long duration and the
connection to switch was not there so it was not getting any reply.

- During unload this thread was hanging.

Problem Resolution:

Check if unload is in progress, then quit from fipvlan thread.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# e82e6ff7 23-Aug-2019 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Print message during bailout conditions

Print messages during exiting condition to help debugging.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# b54c9d5b 30-Jul-2019 Jonathan Lemon <jonathan.lemon@gmail.com>

net: Use skb_frag_off accessors

Use accessor functions for skb fragment's page_offset instead
of direct references, in preparation for bvec conversion.

Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


# 3287e96a 01-Jun-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 440

Based on 1 normalized pattern(s):

this software is available under the terms of the gnu general public
license gpl version 2 available from the file copying in the main
directory of this source tree

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference in 35 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190531190115.411886531@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a9b02c61 26-May-2019 Chad Dupuis <cdupuis@marvell.com>

qedf: Use hwfns and affin_hwfn_idx to get MSI-X vector index to use

MSI-X vector index is determined using qed device information and
affinity to use.

Signed-off-by: Chad Dupuis <cdupuis@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Michal Kalderon <michal.kalderon@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


# 1e1ff604 21-Apr-2019 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Add return value to log message if scsi_add_host fails

Print return value of scsi_add_host on failure.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 7fa4142d 21-Apr-2019 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Print fcport information on wait for upload timeout

Log fcport for which upload failed.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 19c2b6d8 21-Apr-2019 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Check the return value of start_xmit

Log the reason for start xmit failure.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Chad Dupuis <cdupuis@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 249b148f 21-Apr-2019 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Log message if scsi_add_host fails

Print message on scsi_add_host failure.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Chad Dupuis <cdupuis@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# f4eecabe7 21-Apr-2019 Saurav Kashyap <saurav.kashyap@cavium.com>

scsi: qedf: Check for fcoe_libfc_config failure

Print the fcoe_libfc_config failure and return proper failure.

Signed-off-by: Saurav Kashyap <saurav.kashyap@cavium.com>
Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 078d7199 21-Apr-2019 Chad Dupuis <cdupuis@marvell.com>

scsi: qedf: Change MSI-X load error message

Change the message to display load failure.

Signed-off-by: Chad Dupuis <cdupuis@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 56efc304 26-Mar-2019 Hannes Reinecke <hare@suse.com>

scsi: qedf: fc_rport_priv reference counting fixes

The fc_rport_priv structure is reference counted, so we need to ensure that
the reference is increased before accessing the structure.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# a66c6cd2 26-Mar-2019 Chad Dupuis <cdupuis@marvell.com>

scsi: qedf: Wait for upload and link down processing during soft ctx reset

- Wait for all the connections to get uploaded.

Signed-off-by: Chad Dupuis <cdupuis@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 78a8ab3c 26-Mar-2019 Hannes Reinecke <hare@suse.com>

scsi: qedf: fixup bit operations

test_bit() is atomic, test_bit() || test_bit() is not. So protect
consecutive bit tests with a lock to avoid races.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 4262d35c 26-Mar-2019 Hannes Reinecke <hare@suse.com>

scsi: qedf: missing kref_put in qedf_xmit()

qedf_xmit() calls fc_rport_lookup(), but discards the returned rdata
structure almost immediately without decreasing the refcount. This leads
to a refcount leak and the rdata never to be freed.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 76dbf4ff 26-Mar-2019 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Check for link state before processing LL2 packets and send fipvlan retries

- Check if link is UP before sending and processing any packets on wire.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 0cbd0075 26-Mar-2019 Chad Dupuis <cdupuis@marvell.com>

scsi: qedf: Add missing fc_disc_init call after allocating lport

When receiving an unsolicited frame we could crash on a list traversal in
fc_rport_lookup while searching the rport which is associated with our
lport.

Initialize the lport's discovery node after allocating the lport in
__qedf_probe().

Signed-off-by: Chad Dupuis <cdupuis@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 69ef2c69 26-Mar-2019 Saurav Kashyap <skashyap@marvell.com>

scsi: qedf: Modify abort and tmf handler to handle edge condition and flush

An I/O can be in any state when flush is called, it can be in abort,
waiting for abort, RRQ send and waiting or TMF send.

- HZ can be different on different architecture, correctly set abort
timeout value.

- Flush can complete the I/Os prematurely, handle refcount for aborted
I/Os and for which RRQ is pending.

- Differentiate LUN/TARGET reset, as cleanup needs to be send to firmware
accordingly.

- Add flush mutex to sync cleanup call from abort and flush routine.

- Clear abort/outstanding bit on timeout.

Signed-off-by: Shyam Sundar <shyam.sundar@marvell.com>
Signed-off-by: Chad Dupuis <cdupuis@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 5d5e5565 26-Mar-2019 Shyam Sundar <ssundar@marvell.com>

scsi: qedf: Modify flush routine to handle all I/Os and TMF

The purpose of flush routine is to cleanup I/Os to the firmware and
complete them to scsi middle layer. This routine is invoked before
connection is uploaded because of rport going away.

- Don't process any I/Os, aborts, TMFs coming when flush in progress.

- Add flags to handle cleanup and release of I/Os because flush can
prematurely complete I/Os.

- Original command can get completed to driver when cleanup for same is
posted to firmware, handle this condition.

- Modify flush to handle I/Os in all the states like abort, TMF, RRQ and
timeouts.

Signed-off-by: Shyam Sundar <ssundar@marvell.com>
Signed-off-by: Chad Dupuis <cdupuis@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 650ce64c 26-Mar-2019 Chad Dupuis <cdupuis@marvell.com>

scsi: qedf: Correct xid range overlap between offloaded requests and libfc requests

There is currently an overlap where exchange IDs between what is used for
offloaded commands and by libfc for ELS commands. Correct this so that
exchange ID range is:

Offloaded requests: 0 to 0xfff
libfc requests: 0x1000 to 0xfffe

Signed-off-by: Chad Dupuis <cdupuis@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 8beb90aa 15-Feb-2019 Sedat Dilek <sedat.dilek@gmail.com>

scsi: fcoe: make use of fip_mode enum complete

commit 1917d42d14b7 ("fcoe: use enum for fip_mode") introduces a separate
enum for the fip_mode that shall be used during initialisation handling
until it is passed to fcoe_ctrl_link_up to set the initial fip_state. That
change was incomplete and gcc quietly converted in various places between
the fip_mode and the fip_state enum values with implicit enum conversions,
which fortunately cannot cause any issues in the actual code's execution.

clang however warns about these implicit enum conversions in the scsi
drivers. This commit consolidates the use of the two enums, guided by
clang's enum-conversion warnings.

This commit now completes the use of the fip_mode: It expects and uses
fip_mode in {bnx2fc,fcoe}_interface_create and fcoe_ctlr_init, and it calls
fcoe_ctrl_set_set() with the correct values in fcoe_ctlr_link_up(). It
also breaks the association between FIP_MODE_AUTO and FIP_ST_AUTO to
indicate these two enums are distinct.

Link: https://github.com/ClangBuiltLinux/linux/issues/151
Fixes: 1917d42d14b7 ("fcoe: use enum for fip_mode")
Reported-by: Dmitry Golovin <dima@golovin.in>
Original-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
CC: Lukas Bulwahn <lukas.bulwahn@gmail.com>
CC: Nick Desaulniers <ndesaulniers@google.com>
CC: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Suggested-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 750afb08 04-Jan-2019 Luis Chamberlain <mcgrof@kernel.org>

cross-tree: phase out dma_zalloc_coherent()

We already need to zero out memory for dma_alloc_coherent(), as such
using dma_zalloc_coherent() is superflous. Phase it out.

This change was generated with the following Coccinelle SmPL patch:

@ replace_dma_zalloc_coherent @
expression dev, size, data, handle, flags;
@@

-dma_zalloc_coherent(dev, size, handle, flags)
+dma_alloc_coherent(dev, size, handle, flags)

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
[hch: re-ran the script on the latest tree]
Signed-off-by: Christoph Hellwig <hch@lst.de>


# 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>


# f3e46ac4 02-Dec-2018 Thomas Meyer <thomas@m3y3r.de>

scsi: qedf: NULL check before some freeing functions is not needed

NULL check before some freeing functions is not needed.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Acked-by: Manish Rangankar <Manish.Rangankar@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 332d84f7 10-Oct-2018 Christoph Hellwig <hch@lst.de>

scsi: qedf: fully convert to the generic DMA API

The driver is currently using an odd mix of legacy PCI DMA API and
generic DMA API calls, switch it over to the generic API entirely.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Chad Dupuis <chad.dupuis@cavium.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 6ac17475 05-Jul-2018 Saurav Kashyap <saurav.kashyap@cavium.com>

scsi: qedf: Send the driver state to MFW

Need to notify firmware when driver is loaded and unloaded.

Signed-off-by: Saurav Kashyap <saurav.kashyap@cavium.com>
Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 8673daf4 22-May-2018 Chad Dupuis <chad.dupuis@cavium.com>

qedf: Add get_generic_tlv_data handler.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


# 642a0b37 22-May-2018 Chad Dupuis <chad.dupuis@cavium.com>

qedf: Add support for populating ethernet TLVs.

This patch adds callbacks for providing the ethernet protocol driver TLVs.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


# 5d1c8b5b 25-Apr-2018 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Update copyright for 2018

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# f3690a89 25-Apr-2018 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Add more defensive checks for concurrent error conditions

During an uplink toggle test all error handling is done via timeout and
firmware error conditions which can occur concurrently:

- SCSI layer timeouts
- Error detect CQEs
- Firmware detected underruns
- ABTS timeouts

All these concurrent events require more defensive checks in the driver
including:

- Check both internally and externally generated aborts to make sure the
xid is not already been aborted in another context or in cleanup.

- Check back pointers in qedf_cmd_timeout to verify the context of the
io_req, fcport and qedf_ctx

- Check rport state in host reset handler to not reset the whole host
if the rport is already uploaded or in the process of relogin

- Check to state for an fcport before initiating a middle path ELS
request

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 4f4616ce 25-Apr-2018 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Set the UNLOADING flag when removing a vport

Similar to what we do when we remove a PCI function, set the
QEDF_UNLOADING flag to prevent any requests from being queued while a
vport is being deleted. This prevents any requests from getting stuck
in limbo when the vport is unloaded or deleted.

Fixes the crash:

PID: 106676 TASK: ffff9a436aa90000 CPU: 12 COMMAND: "multipathd"
#0 [ffff9a43567d3550] machine_kexec+522 at ffffffffaca60b2a
#1 [ffff9a43567d35b0] __crash_kexec+114 at ffffffffacb13512
#2 [ffff9a43567d3680] crash_kexec+48 at ffffffffacb13600
#3 [ffff9a43567d3698] oops_end+168 at ffffffffad117768
#4 [ffff9a43567d36c0] no_context+645 at ffffffffad106f52
#5 [ffff9a43567d3710] __bad_area_nosemaphore+116 at ffffffffad106fe9
#6 [ffff9a43567d3760] bad_area+70 at ffffffffad107379
#7 [ffff9a43567d3788] __do_page_fault+1247 at ffffffffad11a8cf
#8 [ffff9a43567d37f0] do_page_fault+53 at ffffffffad11a915
#9 [ffff9a43567d3820] page_fault+40 at ffffffffad116768
[exception RIP: qedf_init_task+61]
RIP: ffffffffc0e13c2d RSP: ffff9a43567d38d0 RFLAGS: 00010046
RAX: 0000000000000000 RBX: ffffbe920472c738 RCX: ffff9a434fa0e3e8
RDX: ffff9a434f695280 RSI: ffffbe920472c738 RDI: ffff9a43aa359c80
RBP: ffff9a43567d3950 R8: 0000000000000c15 R9: ffff9a3fb09b9880
R10: ffff9a434fa0e3e8 R11: ffff9a43567d35ce R12: 0000000000000000
R13: ffff9a434f695280 R14: ffff9a43aa359c80 R15: ffff9a3fb9e005c0
ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 96673e1e 25-Apr-2018 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: If qed fails to enable MSI-X fail PCI probe

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 65b7beca 25-Apr-2018 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Honor default_prio module parameter even if DCBX does not converge

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 4b9b7fab 25-Apr-2018 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Improve firmware debug dump handling

Get all firmware debug data instead of just a grc dump.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# f9a4a7f2 25-Apr-2018 Saurav Kashyap <saurav.kashyap@cavium.com>

scsi: qedf: Remove setting DCBX pending during soft context reset

PROBLEM DESCRIPTION:

According to the logs, STAG was changing and it was triggering soft
reset. In soft reset we used to virtual link down and up and also we
were disabling DCBx flag. Since this was virtual link flap, DCBx never
used to converge again.

SOLUTION:

Code change is to remove disabling DCBx flag from soft reset.

Signed-off-by: Saurav Kashyap <saurav.kashyap@cavium.com>
Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 3f9de7f0 25-Apr-2018 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Check if link is already up when receiving a link up event from qed

[mkp: typo]

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 84b2ba6e 25-Apr-2018 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Honor priority from DCBX FCoE App tag

We currently hard code the priority in the 8021q tag to 3 for FCoE
traffic. The vast majority of the time this is fine but if the priority
is something else besides 3, any VLAN ID comparison either in the
non-offload path or offload path will fail and cause dropped frames
where none are expected.

Change the behavior so that the driver default is 3 if we do not get any
DCBX convergence.

If DCBX does converge, then set the FIP/FCoE priority in the following
manner:

1. If the qedf_default_prio modparam is set use that
2. If the DCBX FCoE priority is not in range (0..7) use 3
3. Use the DCBX FCoE priority we get in the driver's DCBX handler

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# ba17d379 25-Apr-2018 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Add dcbx_not_wait module parameter so we won't wait for DCBX convergence to start discovery

This module parameter is to work around cases where we do not receive
the DCBX handler notification from qed but discovery is still possible
if we send out a FIP VLAN request irregardless of the DCBX state.

[mkp: zeroday warning]

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# a93755cf 25-Apr-2018 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Sanity check FCoE/FIP priority value to make sure it's between 0 and 7

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# f32803bb 25-Apr-2018 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Add missing skb frees in error path

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# c3ef86f3 25-Apr-2018 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Increase the number of default FIP VLAN request retries to 60

Some configurations need more than 30 seconds to respond to a FIP VLAN
request so increase the default to 60 seconds.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# cac6f691 05-May-2018 Sudarsana Reddy Kalluru <sudarsana.kalluru@cavium.com>

qed: Add support for Unified Fabric Port.

This patch adds driver changes for supporting the Unified Fabric Port
(UFP). This is a new paritioning mode wherein MFW provides the set of
parameters to be used by the device such as traffic class, outer-vlan
tag value, priority type etc. Drivers receives this info via notifications
from mfw and configures the hardware accordingly.

Signed-off-by: Sudarsana Reddy Kalluru <Sudarsana.Kalluru@cavium.com>
Signed-off-by: Ariel Elior <ariel.elior@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


# d9ea463a 02-Feb-2018 Arnd Bergmann <arnd@arndb.de>

scsi: qedf: fix LTO-enabled build

The prototype for qedf_dbg_fops/qedf_debugfs_ops doesn't match the definition,
which causes the final link to fail with link-time optimizations:

drivers/scsi/qedf/qedf_main.c:34: error: type of 'qedf_dbg_fops' does not match original declaration [-Werror=lto-type-mismatch]
extern struct file_operations qedf_dbg_fops;

drivers/scsi/qedf/qedf_debugfs.c:443: note: 'qedf_dbg_fops' was previously declared here
const struct file_operations qedf_dbg_fops[] = {

drivers/scsi/qedf/qedf_main.c:33: error: type of 'qedf_debugfs_ops' does not match original declaration [-Werror=lto-type-mismatch]
extern struct qedf_debugfs_ops qedf_debugfs_ops;

drivers/scsi/qedf/qedf_debugfs.c:102: note: 'qedf_debugfs_ops' was previously declared here
struct qedf_debugfs_ops qedf_debugfs_ops[] = {

This corrects the prototype and moves it into a shared header file where it
belongs. The file operations can also be marked 'const' like the
qedf_debugfs_ops.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# e89cabf2 16-Jan-2018 Wei Yongjun <weiyongjun1@huawei.com>

scsi: qedf: Fix error return code in __qedf_probe()

Fix to return error code -ENOMEM from the error handling case instead of
0, as done elsewhere in this function.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Acked-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# da090917 27-Dec-2017 Tomer Tayar <Tomer.Tayar@cavium.com>

qed*: Utilize FW 8.33.1.0

Advance the qed* drivers to use firmware 8.33.1.0:
Modify core driver (qed) to utilize the new FW and initialize the device
with it. This is the lion's share of the patch, and includes changes to FW
interface files, device initialization flows, FW interaction flows, and
debug collection flows.
Modify Ethernet driver (qede) to make use of new FW in fastpath.
Modify RoCE/iWARP driver (qedr) to make use of new FW in fastpath.
Modify FCoE driver (qedf) to make use of new FW in fastpath.
Modify iSCSI driver (qedi) to make use of new FW in fastpath.

Signed-off-by: Ariel Elior <Ariel.Elior@cavium.com>
Signed-off-by: Michal Kalderon <Michal.Kalderon@cavium.com>
Signed-off-by: Yuval Bason <Yuval.Bason@cavium.com>
Signed-off-by: Ram Amrani <Ram.Amrani@cavium.com>
Signed-off-by: Manish Chopra <Manish.Chopra@cavium.com>
Signed-off-by: Chad Dupuis <Chad.Dupuis@cavium.com>
Signed-off-by: Manish Rangankar <Manish.Rangankar@cavium.com>
Signed-off-by: Tomer Tayar <Tomer.Tayar@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


# 21dd79e8 27-Dec-2017 Tomer Tayar <Tomer.Tayar@cavium.com>

qed*: HSI renaming for different types of HW

This patch renames defines and structures in the FW HSI files to allow a
distinction between different types of HW.

Signed-off-by: Ariel Elior <Ariel.Elior@cavium.com>
Signed-off-by: Michal Kalderon <Michal.Kalderon@cavium.com>
Signed-off-by: Chad Dupuis <Chad.Dupuis@cavium.com>
Signed-off-by: Manish Rangankar <Manish.Rangankar@cavium.com>
Signed-off-by: Tomer Tayar <Tomer.Tayar@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


# a81ac3b0 25-Aug-2017 Hannes Reinecke <hare@suse.de>

scsi: qedf: drop bus reset handler

qedf has a host reset handler, but as the bus reset handler is a stub
always returning SUCCESS the host reset is never invoked. So drop the
bus reset handler.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Tested-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 0516abdf 15-Aug-2017 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Fix up modinfo parameter name for 'debug' in modinfo output.

Because we were passing 'qedf_debug' instead of 'debug' to the
MODULE_PARM_DESC() macro, modinfo listed the parameter name as 'qedf_debug'
instead of it's proper name 'debug'. Correct the parameter name.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 428ca642 15-Aug-2017 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Covert single-threaded workqueues to regular workqueues.

There is no ordering required for the various workqueues the driver uses
so they can be converted to regular workqueues.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# cf291163 15-Aug-2017 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Corrent VLAN tag insertion in fallback VLAN case.

Currently in the driver the qedf_ctx attribute vlan_hw_insert is used to
which whether to insert a VLAN tag in FIP frames (except for FIP VLAN
request which is explicitly sent out untagged at least from the driver's
point of view).

When we receive a FIP VLAN response, we set qedf->vlan_hw_insert to 0 which
makes the qedf_fip_send function insert the VLAN. However when we exhaust
our FIP VLAN retries, we do not set qedf->vlan_hw_insert to 0 which means
that the driver will not tag the FIP frame with the correct VLAN ID. The
result that was observed on the wire is that some entity either in the LL2
or L2 firmware is adding a NULL VLAN tag which can cause FIP solicitation
to fail.

The offload FCoE frame function, qedf_xmit, does not use the vlan_hw_insert
attribute to decide whether to tag frames with the FIP/FCoE VLAN. Instead
it unilaterially tags the offload frames with the VLAN ID stored in
qedf->vlan_id. This is the correct behavior so the driver can guarantee
that non-offload FIP frames go out with the correct VLAN ID.

Also use the Linux network layer helpers instead of doing the VLAN insert
manually.

Also fix setting the fallback VLAN so that it used the module parameter and
is not hardcoded to 1002 (though 1002 is the default).

[mkp: fixed typo]

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# a3cd42a9 15-Aug-2017 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Use granted MAC from the FCF for the FCoE source address if it is available.

Currently in the driver we've been using the fc_fcoe_set_mac() function to
set the source MAC for FCoE traffic. This works well in most cases as it
uses the spec. default FCF-MAC. However, if the administrator changes the
FCF-MAC switch, then any FCoE traffic we send will be dropped by the
switch.

Instead we should check the granted MAC from the FLOGI payload and use that
address if it is present. Otherwise, fall back to using the the default
FCF-MAC and the fabric ID of the port as the FCoE MAC address.

Once this address is known we need to set it when doing non-offload
traffic, offload traffic and setting the data_src_address libfcoe uses for
FIP keep alive messages.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 01fd76a7 15-Aug-2017 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Set WWNN and WWPN based on values from qed.

If dev_info.wwpn and dev_info.wwnn are set by qed use these values to set
the WWNs of the port. Otherwise fall back to the old method using
fcoe_wwn_from_mac().

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 722477c4 25-Jul-2017 Thomas Bogendoerfer <tbogendoerfer@suse.de>

scsi: qedf: Limit number of CQs

FCOE offloading failed with:

[qed_sp_fcoe_func_start:150(sp-0-3b:00.02)]Cannot satisfy CQ amount. CQs
requested 8, CQs available 6. Aborting function start
[qed_fcoe_start:821()]Failed to start fcoe
[__qedf_probe:3041]:6: Cannot start FCoE function.

The reason is a newly introduced check in the qed main part. This change
also provides the information about how many CQs are available, so we
simply limit the number of requested CQs..

Fixes: 3c5da9427802 ("qed: Share additional information with qedf")
Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Acked-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# acef2690 03-Jul-2017 Colin Ian King <colin.king@canonical.com>

scsi: qedf: fix spelling mistake: "offlading" -> "offloading"

Trivial fix to spelling mistake in QEDF_INFO message and remove
duplicated "since" (thanks to Tyrel Datwyler for spotting the latter
issue).

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Chad Dupuis <chad.dupuis@cavium.com>
Reviewed-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# af72868b 16-Jun-2017 Johannes Berg <johannes.berg@intel.com>

networking: make skb_pull & friends return void pointers

It seems like a historic accident that these return unsigned char *,
and in many places that means casts are required, more often than not.

Make these functions return void * and remove all the casts across
the tree, adding a (u8 *) cast only where the unsigned char pointer
was used directly, all done with the following spatch:

@@
expression SKB, LEN;
typedef u8;
identifier fn = {
skb_pull,
__skb_pull,
skb_pull_inline,
__pskb_pull_tail,
__pskb_pull,
pskb_pull
};
@@
- *(fn(SKB, LEN))
+ *(u8 *)fn(SKB, LEN)

@@
expression E, SKB, LEN;
identifier fn = {
skb_pull,
__skb_pull,
skb_pull_inline,
__pskb_pull_tail,
__pskb_pull,
pskb_pull
};
type T;
@@
- E = ((T *)(fn(SKB, LEN)))
+ E = fn(SKB, LEN)

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


# 4df864c1 16-Jun-2017 Johannes Berg <johannes.berg@intel.com>

networking: make skb_put & friends return void pointers

It seems like a historic accident that these return unsigned char *,
and in many places that means casts are required, more often than not.

Make these functions (skb_put, __skb_put and pskb_put) return void *
and remove all the casts across the tree, adding a (u8 *) cast only
where the unsigned char pointer was used directly, all done with the
following spatch:

@@
expression SKB, LEN;
typedef u8;
identifier fn = { skb_put, __skb_put };
@@
- *(fn(SKB, LEN))
+ *(u8 *)fn(SKB, LEN)

@@
expression E, SKB, LEN;
identifier fn = { skb_put, __skb_put };
type T;
@@
- E = ((T *)(fn(SKB, LEN)))
+ E = fn(SKB, LEN)

which actually doesn't cover pskb_put since there are only three
users overall.

A handful of stragglers were converted manually, notably a macro in
drivers/isdn/i4l/isdn_bsdcomp.c and, oddly enough, one of the many
instances in net/bluetooth/hci_sock.c. In the former file, I also
had to fix one whitespace problem spatch introduced.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


# 32eebb31 11-Jun-2017 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

scsi: qedf: Merge a few quoted strings split across lines

Merge some quoted strings to improve readability and to save some lines
of code.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# c4d6ffc8 11-Jun-2017 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

scsi: qedf: Use 'dma_zalloc_coherent' to reduce code verbosity.

Replace some 'dma_alloc_coherent+memset' by some quivalent
'dma_zalloc_coherent' in order to reduce code verbosity

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 3a240b21 11-Jun-2017 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

scsi: qedf: Fix a return value in case of error in 'qedf_alloc_global_queues'

We should return -ENOMEM in case of memory allocation error, as done
elsewhere in this function.

[mkp: fixed typo]

Fixes: 61d8658b4a435 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 6088cfaa 31-May-2017 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Add change_queue_depth member to scsi_host_template().

Add the change_queue_depth member to our SCSI host template so the queue
depth of devices attached to qedf can be changed dynamically.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# a7746f1e 31-May-2017 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Change cmd_per_lun in scsi_host_template to 32 to increase performance.

Increase the default number of commands that the driver tells the
SCSI mid-layer it can do to increase the default performance of the
driver.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# f7e8d57b 31-May-2017 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Move some prints to a debug level so they do not print when no debugging is enabled.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 384d5a9b 31-May-2017 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Add non-offload receive filters.

Drop invalid or unexpected FCoE frames that come into the non-offload path
since the FCoE firmware would not do the filtering for us.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# b09fdc3a 31-May-2017 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Add bus_reset No-op.

We need to add a bus reset no-op as without it some of the LUNs attached to a
vport may go offline when the error handler escalates to host reset due to not
having a bus reset handler in the driver. What happens is we escalate to host
reset which does a soft link down/link up to reset the adapter. However with
multiple vports attached it's been observed that if the vports do log back into
the target within 5 seconds, the SCSI layer offlines the devices most likely
due to a TUR timing out to verify that the device is online. Adding a bus
reset handler will cause the TUR to be sent after the bus reset handler where
the devices will still be online if the bus reset is initiated by sg_reset
(which is the case in the test that was failing). The bus reset will succeed
and not needlessly bring the device offline/online.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 5cf446d2 31-May-2017 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Use same logic for SCSI host reset and FC lip_reset.

We should be using the same logic to do a soft reset of the FCoE function
whether it is initiated via sg_reset or the fc_host issue_lip attribute.
Refactor the host reset and fcoe reset handlers to use the preferred logic
which is currently contained in qedf_eh_host_reset().

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 2b82a62f 31-May-2017 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Set qed logging level to QED_LEVEL_NOTICE.

Reduce the logging level we set for qed messages pertaining to this PCI
function so that unnecessary messages are not printed in the kernel
message log.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 914fff10 31-May-2017 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Honor qed_ops->common->set_fp_int() return code.

We need to check the return code the set_fp_int() callback in case we were
not allocated any fastpath interrupts or there was an error setting up the
fastpath interrupts from the qed perspective.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 12d0b12c 31-May-2017 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Update copyright to 2017.

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 5185b328 31-May-2017 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Enable basic FDMI information.

For libfc to register FDMI attributes we need to do two things:

- Set the appropriate fc_host attributes that libfc will use to form the
FDMI registration commands
- Set lport->fdmi_enabled to 1

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 712c3cbf 23-May-2017 Mintz, Yuval <Yuval.Mintz@cavium.com>

qed: Replace set_id() api with set_name()

Current API between qed and protocol modules allows passing an
additional private string - but it doesn't get utilized by qed
anywhere.

Clarify the API by removing it and renaming it 'set_name'.

CC: Manish Rangankar <Manish.Rangankar@cavium.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


# cd22874f 05-May-2017 Kees Cook <keescook@chromium.org>

scsi: qedf: Avoid reading past end of buffer

Using memcpy() from a string that is shorter than the length copied
means the destination buffer is being filled with arbitrary data from
the kernel rodata segment. Instead, use strncpy() which will fill the
trailing bytes with zeros.

This was found with the future CONFIG_FORTIFY_SOURCE feature.

Cc: Daniel Micay <danielmicay@gmail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 8eaf7dfc 23-Mar-2017 Chad Dupuis <chad.dupuis@cavium.com>

scsi: qedf: Fix crash due to unsolicited FIP VLAN response.

We need to initialize qedf->fipvlan_compl in __qedf_probe so that if we
receive an unsolicited FIP VLAN response, the system doesn't crash due
to trying to complete an uninitialized completion.

Also add a check to see if there are any waiters on the completion so we
don't inadvertantly kick start the discovery process due to the
unsolicited frame.

Fixed the crash:

<1>BUG: unable to handle kernel NULL pointer dereference at (null)
<1>IP: [<ffffffff8105ed71>] __wake_up_common+0x31/0x90
<4>PGD 0
<4>Oops: 0000 [#1] SMP
<4>last sysfs file: /sys/devices/system/cpu/online
<4>CPU 7
<4>Modules linked in: autofs4 nfs lockd fscache auth_rpcgss nfs_acl sunrpc target_core_iblock target_core_file target_core_pscsi target_core_mod configfs bnx2fc cnic fcoe 8021q garp stp llc ipt_REJECT nf_conntrack_ipv4 nf_defrag_ipv4 iptable_filter ip_tables ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 xt_state nf_conntrack ip6table_filter ip6_tables ipv6 vfat fat uinput ipmi_devintf microcode power_meter acpi_ipmi ipmi_si ipmi_msghandler iTCO_wdt iTCO_vendor_support dcdbas sg joydev sb_edac edac_core lpc_ich mfd_core shpchp tg3 ptp pps_core ext4 jbd2 mbcache sr_mod cdrom sd_mod crc_t10dif qedi(U) iscsi_boot_sysfs libiscsi scsi_transport_iscsi uio qedf(U) libfcoe libfc scsi_transport_fc scsi_tgt qede(U) qed(U) ahci megaraid_sas wmi dm_mirror dm_region_hash dm_log dm_mod [last unloaded: speedstep_lib]
<4>
<4>Pid: 1485, comm: qedf_11_ll2 Not tainted 2.6.32-642.el6.x86_64 #1 Dell Inc. PowerEdge R730/0599V5
<4>RIP: 0010:[<ffffffff8105ed71>] [<ffffffff8105ed71>] __wake_up_common+0x31/0x90
<4>RSP: 0018:ffff881068a83d50 EFLAGS: 00010086
<4>RAX: ffffffffffffffe8 RBX: ffff88106bf42de0 RCX: 0000000000000000
<4>RDX: 0000000000000000 RSI: 0000000000000003 RDI: ffff88106bf42de0
<4>RBP: ffff881068a83d90 R08: 0000000000000000 R09: 00000000fffffffe
<4>R10: 0000000000000000 R11: 000000000000000b R12: 0000000000000286
<4>R13: ffff88106bf42de8 R14: 0000000000000000 R15: 0000000000000000
<4>FS: 0000000000000000(0000) GS:ffff88089c460000(0000) knlGS:0000000000000000
<4>CS: 0010 DS: 0018 ES: 0018 CR0: 000000008005003b
<4>CR2: 0000000000000000 CR3: 0000000001a8d000 CR4: 00000000001407e0
<4>DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
<4>DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
<4>Process qedf_11_ll2 (pid: 1485, threadinfo ffff881068a80000, task ffff881068a70040)
<4>Stack:
<4> ffff88106ef00090 0000000300000001 ffff881068a83d90 ffff88106bf42de0
<4><d> 0000000000000286 ffff88106bf42dd8 ffff88106bf40a50 0000000000000002
<4><d> ffff881068a83dc0 ffffffff810634c7 ffff881000000003 000000000000000b
<4>Call Trace:
<4> [<ffffffff810634c7>] complete+0x47/0x60
<4> [<ffffffffa01d37e7>] qedf_fip_recv+0x1c7/0x450 [qedf]
<4> [<ffffffffa01cb3cb>] qedf_ll2_recv_thread+0x33b/0x510 [qedf]
<4> [<ffffffffa01cb090>] ? qedf_ll2_recv_thread+0x0/0x510 [qedf]
<4> [<ffffffff810a662e>] kthread+0x9e/0xc0
<4> [<ffffffff8100c28a>] child_rip+0xa/0x20
<4> [<ffffffff810a6590>] ? kthread+0x0/0xc0
<4> [<ffffffff8100c280>] ? child_rip+0x0/0x20
<4>Code: 41 56 41 55 41 54 53 48 83 ec 18 0f 1f 44 00 00 89 75 cc 89 55 c8 4c 8d 6f 08 48 8b 57 08 41 89 cf 4d 89 c6 48 8d 42 e8 49 39 d5 <48> 8b 58 18 74 3f 48 83 eb 18 eb 0a 0f 1f 00 48 89 d8 48 8d 5a
<1>RIP [<ffffffff8105ed71>] __wake_up_common+0x31/0x90
<4> RSP <ffff881068a83d50>
<4>CR2: 0000000000000000

Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# fd2b18b4 06-Mar-2017 Joe Perches <joe@perches.com>

scsi: qedf: Use vsprintf extension %pad

Using %llx for a dma_addr_t can lead to format/argument mismatches. Use
%pad and the address of the dma_addr_t instead.

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 61d8658b 15-Feb-2017 Dupuis, Chad <chad.dupuis@cavium.com>

scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.

The QLogic FastLinQ Driver for FCoE (qedf) is the FCoE specific module
for 41000 Series Converged Network Adapters by QLogic. This patch
consists of following changes:

- MAINTAINERS Makefile and Kconfig changes for qedf
- PCI driver registration
- libfc/fcoe host level initialization
- SCSI host template initialization and callbacks
- Debugfs and log level infrastructure
- Link handling
- Firmware interface structures
- QED core module initialization
- Light L2 interface callbacks
- I/O request initialization
- Firmware I/O completion handling
- Firmware ELS request/response handling
- FIP request/response handled by the driver itself

Signed-off-by: Nilesh Javali <nilesh.javali@cavium.com>
Signed-off-by: Manish Rangankar <manish.rangankar@cavium.com>
Signed-off-by: Saurav Kashyap <saurav.kashyap@cavium.com>
Signed-off-by: Arun Easi <arun.easi@cavium.com>
Signed-off-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>