RE: Observing Softlockup's while running heavy IOs

2016-08-19 Thread Elliott, Robert (Persistent Memory)


> -Original Message-
> From: Sreekanth Reddy [mailto:sreekanth.re...@broadcom.com]
> Sent: Friday, August 19, 2016 6:45 AM
> To: Elliott, Robert (Persistent Memory) 
> Subject: Re: Observing Softlockup's while running heavy IOs
> 
...
> Yes I am also observing that all the interrupts are routed to one
> CPU.  But still I observing softlockups (sometime hardlockups)
> even when I set rq_affinity to 2.

That'll ensure the block layer's completion handling is done there,
but not your driver's interrupt handler (which precedes the block
layer completion handling).

 
> Is their any way to route the interrupts the same CPUs which has
> submitted the corresponding IOs?
> or
> Is their any way/option in the irqbalance/kernel which can route
> interrupts to CPUs (enabled in affinity_hint) in round robin manner
> after specific time period.

Ensure your driver creates one MSIX interrupt per CPU core, uses
that interrupt for all submissions from that core, and reports
that it would like that interrupt to be serviced by that core
in /proc/irq/nnn/affinity_hint.  

Even with hyperthreading, this needs to be based on the logical
CPU cores, not just the physical core or the physical socket.
You can swamp a logical CPU core as easily as a physical CPU core.

Then, provide an irqbalance policy script that honors the
affinity_hint for your driver, or turn off irqbalance and
manually set /proc/irq/nnn/smp_affinity to match the
affinity_hint.  

Some versions of irqbalance honor the hints; some purposely
don't and need to be overridden with a policy script.


---
Robert Elliott, HPE Persistent Memory




Re: [PATCH v2] fcoe: provide translation table between Ethernet and FC port speeds

2016-08-19 Thread Lee Duncan
On 08/19/2016 06:33 AM, Johannes Thumshirn wrote:
> Provide a translation table between Ethernet and FC port speeds so odd
> speeds (from a Ethernet POV) like 8 Gbit are correctly mapped to sysfs
> and open-fcoe's fcoeadm.
> 
> Before:
> Description:  BCM57840 NetXtreme II 10/20-Gigabit Ethernet
> Revision: 11
> Manufacturer: Broadcom Corporation
> Serial Number:6CC2173EA1D0
> 
> Driver:   bnx2x 1.712.30-0
> Number of Ports:  1
> 
> Symbolic Name: bnx2fc (QLogic BCM57840) v2.10.3 over eth2
> OS Device Name:host1
> Node Name: 0x20006cc2173ea1d1
> Port Name: 0x10006cc2173ea1d1
> FabricName:0x10c0dd0ce717
> Speed: unknown
> Supported Speed:   1 Gbit, 10 Gbit
> MaxFrameSize:  2048 bytes
> FC-ID (Port ID):   0x660702
> State: Online
> 
> After:
> Description:  BCM57840 NetXtreme II 10/20-Gigabit Ethernet
> Revision: 11
> Manufacturer: Broadcom Corporation
> Serial Number:6CC2173EA1D0
> 
> Driver:   bnx2x 1.712.30-0
> Number of Ports:  1
> 
> Symbolic Name: bnx2fc (QLogic BCM57840) v2.10.3 over eth2
> OS Device Name:host1
> Node Name: 0x20006cc2173ea1d1
> Port Name: 0x10006cc2173ea1d1
> FabricName:0x10c0dd0ce717
> Speed: 8 Gbit
> Supported Speed:   1 Gbit, 10 Gbit
> MaxFrameSize:  2048 bytes
> FC-ID (Port ID):   0x660701
> State: Online
> 
> Signed-off-by: Johannes Thumshirn 
> ---
> 
> Changes to v1:
> * Add definitions for non-native Ethernet speeds
> 
>  drivers/scsi/fcoe/fcoe_transport.c | 53 
> ++
>  1 file changed, 36 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/scsi/fcoe/fcoe_transport.c 
> b/drivers/scsi/fcoe/fcoe_transport.c
> index 7028dd3..c164eec 100644
> --- a/drivers/scsi/fcoe/fcoe_transport.c
> +++ b/drivers/scsi/fcoe/fcoe_transport.c
> @@ -83,6 +83,41 @@ static struct notifier_block libfcoe_notifier = {
>   .notifier_call = libfcoe_device_notification,
>  };
>  
> +static const struct {
> + u32 fc_port_speed;
> +#define SPEED_2000   2000
> +#define SPEED_4000   4000
> +#define SPEED_8000   8000
> +#define SPEED_16000  16000
> +#define SPEED_32000  32000
> + u32 eth_port_speed;
> +} fcoe_port_speed_mapping[] = {
> + { FC_PORTSPEED_1GBIT,   SPEED_1000   },
> + { FC_PORTSPEED_2GBIT,   SPEED_2000   },
> + { FC_PORTSPEED_4GBIT,   SPEED_4000   },
> + { FC_PORTSPEED_8GBIT,   SPEED_8000   },
> + { FC_PORTSPEED_10GBIT,  SPEED_1  },
> + { FC_PORTSPEED_16GBIT,  SPEED_16000  },
> + { FC_PORTSPEED_20GBIT,  SPEED_2  },
> + { FC_PORTSPEED_25GBIT,  SPEED_25000  },
> + { FC_PORTSPEED_32GBIT,  SPEED_32000  },
> + { FC_PORTSPEED_40GBIT,  SPEED_4  },
> + { FC_PORTSPEED_50GBIT,  SPEED_5  },
> + { FC_PORTSPEED_100GBIT, SPEED_10 },
> +};
> +
> +static inline u32 eth2fc_speed(u32 eth_port_speed)
> +{
> + int i;
> +
> + for (i = 0; i <= ARRAY_SIZE(fcoe_port_speed_mapping); i++) {
> + if (fcoe_port_speed_mapping[i].eth_port_speed == eth_port_speed)
> + return fcoe_port_speed_mapping[i].fc_port_speed;
> + }
> +
> + return FC_PORTSPEED_UNKNOWN;
> +}
> +
>  /**
>   * fcoe_link_speed_update() - Update the supported and actual link speeds
>   * @lport: The local port to update speeds for
> @@ -126,23 +161,7 @@ int fcoe_link_speed_update(struct fc_lport *lport)
>   SUPPORTED_4baseLR4_Full))
>   lport->link_supported_speeds |= FC_PORTSPEED_40GBIT;
>  
> - switch (ecmd.base.speed) {
> - case SPEED_1000:
> - lport->link_speed = FC_PORTSPEED_1GBIT;
> - break;
> - case SPEED_1:
> - lport->link_speed = FC_PORTSPEED_10GBIT;
> - break;
> - case SPEED_2:
> - lport->link_speed = FC_PORTSPEED_20GBIT;
> - break;
> - case SPEED_4:
> - lport->link_speed = FC_PORTSPEED_40GBIT;
> - break;
> - default:
> - lport->link_speed = FC_PORTSPEED_UNKNOWN;
> - break;
> - }Reviewed-by: Lee Duncan 
> + lport->link_speed = eth2fc_speed(ecmd.base.speed);
>   return 0;
>   }
>   return -1;
> 

Reviewed-by: Lee Duncan 

-- 
Lee Duncan

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


[PATCH 2/2] scsi: sg: Use mult_frac, drop MULDIV macro

2016-08-19 Thread Paul Burton
The MULDIV macro is essentially a duplicate of the more standard
mult_frac macro. Replace use of MULDIV with mult_frac & drop the
duplication.

Signed-off-by: Paul Burton 
---
 drivers/scsi/sg.c | 19 ---
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index bb5ec2d..070332e 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -79,18 +79,7 @@ static void sg_proc_cleanup(void);
  */
 #define SG_MAX_CDB_SIZE 252
 
-/*
- * Suppose you want to calculate the formula muldiv(x,m,d)=int(x * m / d)
- * Then when using 32 bit integers x * m may overflow during the calculation.
- * Replacing muldiv(x) by muldiv(x)=((x % d) * m) / d + int(x / d) * m
- * calculates the same, but prevents the overflow when both m and d
- * are "small" numbers (like HZ and USER_HZ).
- * Of course an overflow is inavoidable if the result of muldiv doesn't fit
- * in 32 bits.
- */
-#define MULDIV(X,MUL,DIV) X % DIV) * MUL) / DIV) + ((X / DIV) * MUL))
-
-#define SG_DEFAULT_TIMEOUT MULDIV(SG_DEFAULT_TIMEOUT_USER, HZ, USER_HZ)
+#define SG_DEFAULT_TIMEOUT mult_frac(SG_DEFAULT_TIMEOUT_USER, HZ, USER_HZ)
 
 int sg_big_buff = SG_DEF_RESERVED_SIZE;
 /* N.B. This variable is readable and writeable via
@@ -884,11 +873,11 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned 
long arg)
return result;
if (val < 0)
return -EIO;
-   if (val >= MULDIV((s64)INT_MAX, USER_HZ, HZ))
-   val = min_t(s64, MULDIV((s64)INT_MAX, USER_HZ, HZ),
+   if (val >= mult_frac((s64)INT_MAX, USER_HZ, HZ))
+   val = min_t(s64, mult_frac((s64)INT_MAX, USER_HZ, HZ),
INT_MAX);
sfp->timeout_user = val;
-   sfp->timeout = MULDIV (val, HZ, USER_HZ);
+   sfp->timeout = mult_frac(val, HZ, USER_HZ);
 
return 0;
case SG_GET_TIMEOUT:/* N.B. User receives timeout as return value */
-- 
2.9.3

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


[PATCH 1/2] scsi: sg: Avoid overflow when USER_HZ > HZ

2016-08-19 Thread Paul Burton
Calculating the maximum timeout that a user can set via the
SG_SET_TIMEOUT ioctl involves multiplying INT_MAX by USER_HZ/HZ. If
USER_HZ is larger than HZ then this results in an overflow when
performed as a 32 bit integer calculation, resulting in compiler
warnings such as the following:

  drivers/scsi/sg.c: In function 'sg_ioctl':
  drivers/scsi/sg.c:91:67: warning: integer overflow in expression [-Woverflow]
   #define MULDIV(X,MUL,DIV) X % DIV) * MUL) / DIV) + ((X / DIV) * MUL))
 ^
  drivers/scsi/sg.c:887:14: note: in expansion of macro 'MULDIV'
 if (val >= MULDIV (INT_MAX, USER_HZ, HZ))
^
  drivers/scsi/sg.c:91:67: warning: integer overflow in expression [-Woverflow]
   #define MULDIV(X,MUL,DIV) X % DIV) * MUL) / DIV) + ((X / DIV) * MUL))
 ^
  drivers/scsi/sg.c:888:13: note: in expansion of macro 'MULDIV'
 val = MULDIV (INT_MAX, USER_HZ, HZ);
   ^

Avoid this overflow by performing the (constant) arithmetic on 64 bit
integers, which ensures that overflow from multiplying the 32 bit values
cannot occur. When converting the result back to a 32 bit integer use
min_t to ensure that we don't simply truncate a value beyond INT_MAX to
a 32 bit integer, but instead use INT_MAX where the result was larger
than it. As the values are all compile time constant the 64 bit
arithmetic should have no runtime cost.

Signed-off-by: Paul Burton 
---
 drivers/scsi/sg.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index ae7d9bd..bb5ec2d 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -884,8 +884,9 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned 
long arg)
return result;
if (val < 0)
return -EIO;
-   if (val >= MULDIV (INT_MAX, USER_HZ, HZ))
-   val = MULDIV (INT_MAX, USER_HZ, HZ);
+   if (val >= MULDIV((s64)INT_MAX, USER_HZ, HZ))
+   val = min_t(s64, MULDIV((s64)INT_MAX, USER_HZ, HZ),
+   INT_MAX);
sfp->timeout_user = val;
sfp->timeout = MULDIV (val, HZ, USER_HZ);
 
-- 
2.9.3

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


Re: Oops when completing request on the wrong queue

2016-08-19 Thread Gabriel Krisman Bertazi
Jens Axboe  writes:

>> Some good detective work so far! I agree, this looks like a blk-mq core
>> bug. Do you have a trace of a BUG() triggering in nvme_queue_rq(), when
>> req->tag != nvmeq->tags? I don't immediately see how this could happen,
>> the freezing should protect us from this, unless it's broken somehow.
>> I'll take a look at this.

Nothing much on the BUG() stack trace, at least to me.  We are coming
from an async execution of __blk_mq_run_hw_queue:

This is from 4.7. I'll give another run on 4.8-rc1.

[ 1953.910860] kernel BUG at ../drivers/nvme/host/pci.c:602!
cpu 0x48: Vector: 700 (Program Check) at [c07870d3b7a0]
pc: d00035aa2e88: nvme_queue_rq+0x1a8/0x7a0 [nvme]
lr: d00035aa2e78: nvme_queue_rq+0x198/0x7a0 [nvme]
sp: c07870d3ba20
   msr: 90010282b033
  current = 0xc07870d9e400
  paca= 0xc2bd8800   softe: 0irq_happened: 0x01
pid   = 9205, comm = kworker/72:1H
kernel BUG at ../drivers/nvme/host/pci.c:602!
Linux version 4.7.0.mainline+ (root@iod76) (gcc version 5.3.1 20160413 
(Ubuntu/IBM 5.3.1-14ubuntu2.
1) ) #150 SMP Wed Aug 17 14:53:47 CDT 2016
enter ? for help
[c07870d3bb10] c05697b4 __blk_mq_run_hw_queue+0x384/0x640
[c07870d3bc50] c00e8cf0 process_one_work+0x1e0/0x590
[c07870d3bce0] c00e9148 worker_thread+0xa8/0x660
[c07870d3bd80] c00f2090 kthread+0x110/0x130
[c07870d3be30] c00095f0 ret_from_kernel_thread+0x5c/0x6c
48:mon>


Another interesting data point is that we always reach the WARN_ON in
__blk_mq_run_hw_queue immediately before submitting the bad request.

Maybe we are touching some percpu variable from the wrong cpu?

See the WARN_ON trace below.


[  369.953825] [ cut here ]
[  369.954011] WARNING: CPU: 142 PID: 9475 at ../block/blk-mq.c:840 
__blk_mq_run_hw_queue+0x338/0x6
40
[  369.954139] Modules linked in: rpcsec_gss_krb5 auth_rpcgss nfsv4 nfs lockd 
grace fscache binfmt_
misc xfs ofpart cmdlinepart powernv_flash mtd ipmi_powernv ipmi_msghandler at24 
opal_prd ibmpowernv
 nvmem_core powernv_rng input_leds joydev uio_pdrv_genirq mac_hid uio ib_iser 
rdma_cm sunrpc iw_cm
ib_cm ib_core configfs iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi 
autofs4 btrfs raid10 ra
id456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq 
libcrc32c raid1 raid0
 multipath linear ast i2c_algo_bit ttm drm_kms_helper syscopyarea sysfillrect 
sysimgblt fb_sys_fops
 drm hid_generic uas usb_storage usbhid hid nvme ahci libahci nvme_core drbg 
ansi_cprng
[  369.955011] CPU: 142 PID: 9475 Comm: kworker/142:1H Not tainted 
4.7.0.mainline+ #150
[  369.955085] Workqueue: kblockd blk_mq_run_work_fn
[  369.955153] task: c078cbb89a00 ti: c078cb024000 task.ti: 
c078cb024000
[  369.955253] NIP: c0569768 LR: c0569668 CTR: 
[  369.955314] REGS: c078cb027890 TRAP: 0700   Not tainted  
(4.7.0.mainline+)
[  369.955372] MSR: 90010282b033  
 CR: 28002224  XER:
 2000
[  369.955579] CFAR: c0569a18 SOFTE: 1
GPR00: c05695b0 c078cb027b10 c13d0b00 0008
GPR04: 0008 0040  0001
GPR08: c078c345d800 0001 0170 900102803003
GPR12: 2200 c2bffe00 c078bb96b000 
GPR16: 0008 c078bb93 c07954aafd00 c078bb961800
GPR20: c07954aafd08 c0da3728 c078bea8 c078cb027b88
GPR24:  c078bea8 c078bb961808 fffb
GPR28:  c078cb027b98  c078bd299700
[  369.956334] NIP [c0569768] __blk_mq_run_hw_queue+0x338/0x640
[  369.956383] LR [c0569668] __blk_mq_run_hw_queue+0x238/0x640
[  369.956433] Call Trace:
[  369.956454] [c078cb027b10] [c05695b0] 
__blk_mq_run_hw_queue+0x180/0x640 (unreliable)
[  369.956535] [c078cb027c50] [c00e8cf0] 
process_one_work+0x1e0/0x590
[  369.956605] [c078cb027ce0] [c00e9148] worker_thread+0xa8/0x660
[  369.956664] [c078cb027d80] [c00f2090] kthread+0x110/0x130
[  369.956723] [c078cb027e30] [c00095f0] 
ret_from_kernel_thread+0x5c/0x6c
[  369.956791] Instruction dump:
[  369.956821] 815f0108 e91302d8 8128 7f895040 409d01e8 e9280060 794a1f24 
7d29502a
[  369.956920] 7d2afa78 312a 7d295110 7d2907b4 <0b09> e9210088 e95f0058 
38810060
[  369.957020] ---[ end trace 1398dd60e3057065 ]---
[  369.957094] [ cut here ]


> Can you share what you ran to online/offline CPUs? I can't reproduce
> this here.

I was using the ppc64_cpu tool, which shouldn't do nothing more than
write to sysfs.  but I just reproduced it with the script below.

Note that this is ppc64le.  I don't have a x86 in hand to attempt to
reproduce right now, but I'll look for one and see how it 

Re: Observing Softlockup's while running heavy IOs

2016-08-19 Thread Bart Van Assche

On 08/19/2016 04:44 AM, Sreekanth Reddy wrote:

[  +0.000439] __blk_mq_run_hw_queue() finished after 10058 ms
[ ... ]
[  +0.05]  [] ? finish_task_switch+0x6b/0x200
[  +0.06]  [] __schedule+0x36c/0x950
[  +0.02]  [] schedule+0x37/0x80
[  +0.06]  [] futex_wait_queue_me+0xbc/0x120
[  +0.04]  [] futex_wait+0x119/0x270
[  +0.04]  [] ? futex_wake+0x90/0x180
[  +0.03]  [] do_futex+0x12b/0xb00
[  +0.05]  [] ? set_next_entity+0x23e/0x440
[  +0.07]  [] ? __switch_to+0x261/0x4b0
[  +0.04]  [] SyS_futex+0x81/0x180
[  +0.02]  [] ? schedule+0x37/0x80
[  +0.04]  [] entry_SYSCALL_64_fastpath+0x12/0x71


Hello Sreekanth,

If a "soft lockup" is reported that often means that kernel code is 
iterating too long in a loop without giving up the CPU. Inserting a 
cond_resched() call in such loops usually resolves these soft lockup 
complaints. However, your latest e-mail shows that the soft lockup 
complaint was reported on other code than __blk_mq_run_hw_queue(). I'm 
afraid this means that the CPU on which the soft lockup was reported is 
hammered so hard with interrupts that hardly any time remains for the 
scheduler to run code on that CPU. You will have to follow Robert 
Elliott's advice and reduce the time that is spent per CPU in interrupt 
context.


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


Re: Oops when completing request on the wrong queue

2016-08-19 Thread Jens Axboe

On 08/19/2016 08:13 AM, Jens Axboe wrote:

On 08/19/2016 07:28 AM, Gabriel Krisman Bertazi wrote:

Gabriel Krisman Bertazi  writes:


We, IBM, have been experiencing eventual Oops when stressing IO at the
same time we add/remove processors.  The Oops happens in the IRQ path,
when we try to complete a request that was apparently meant for another
queue.

In __nvme_process_cq, the driver will use the cqe.command_id and the
nvmeq->tags to find out, via blk_mq_tag_to_rq, the request that
initiated the IO.  Eventually, it happens that the request returned by
that function is not initialized, and we crash inside
__blk_mq_complete_request, as shown below.

[ 2679.050701] Faulting instruction address: 0xc0549500
[ 2679.050711] Oops: Kernel access of bad area, sig: 11 [#1]
[ 2679.050716] SMP NR_CPUS=2048 NUMA pSeries
[ 2679.050727] Modules linked in: minix nls_iso8859_1 xfs libcrc32c
rpcsec_gss_krb5 auth_rpcgss
nfsv4 nfs lockd grace fscache binfmt_misc pseries_rng rtc_generic sunrpc
autofs4 btrfs xor
raid6_pq ibmvscsi ibmveth nvme
[ 2679.050771] CPU: 21 PID: 45045 Comm: ppc64_cpu Not tainted
4.4.0-22-generic #40-Ubuntu
[ 2679.050780] task: c00497b07e60 ti: c004fff2c000 task.ti:
c00451bc
[ 2679.050786] NIP: c0549500 LR: d46b5e84 CTR:
c0549680
[ 2679.050803] REGS: c004fff2fa80 TRAP: 0300   Not tainted
(4.4.0-22-generic)
[ 2679.050807] MSR: 80019033   CR:
28022428  XER: 
[ 2679.050824] CFAR: c0008468 DAR: 00b0 DSISR:
4000 SOFTE: 0
GPR00: d46b5e84 c004fff2fd00 c15b4300
c002799a0a00
GPR04:  0105 0004
0001
GPR08: c002799a0a50  
d46bdc68
GPR12: c0549680 c7b1c780 0008
0001
GPR16:   
10005b50
GPR20: 10005dc8 c15eaa60 0001
0002
GPR24: 01e3  

GPR28:   c004f8cd5180
c002799a0a00
[ 2679.050908] NIP [c0549500]
__blk_mq_complete_request+0x30/0x1b0
[ 2679.050924] LR [d46b5e84] __nvme_process_cq+0xf4/0x2c0 [nvme]
[ 2679.050930] Call Trace:
[ 2679.050941] [c004fff2fd00] [c004fff2fd40]
0xc004fff2fd40 (unreliable)
[ 2679.050952] [c004fff2fd40] [d46b5e84]
__nvme_process_cq+0xf4/0x2c0 [nvme]
[ 2679.050961] [c004fff2fde0] [d46b613c]
nvme_irq+0x3c/0xb0 [nvme]
[ 2679.050972] [c004fff2fe10] [c0130660]
handle_irq_event_percpu+0xa0/0x320
[ 2679.050981] [c004fff2fed0] [c0130948]
handle_irq_event+0x68/0xc0
[ 2679.050989] [c004fff2ff00] [c0135c2c]
handle_fasteoi_irq+0xec/0x2b0
[ 2679.050997] [c004fff2ff30] [c012f844]
generic_handle_irq+0x54/0x80
[ 2679.051007] [c004fff2ff60] [c0011320] __do_irq+0x80/0x1d0
[ 2679.051020] [c004fff2ff90] [c0024800]
call_do_irq+0x14/0x24
[ 2679.051037] [c00451bc3350] [c0011508] do_IRQ+0x98/0x140
[ 2679.051054] [c00451bc33a0] [c0002594]
hardware_interrupt_common+0x114/0x180

I added some debugging which skipped the Oops and made me think that we
are fetching the wrong request because we are actually looking at the
wrong set of tags.

The log below exemplifies what I am saying.  Instead of crashing in the
Oops, I made the execution skip the request completion and simply
consider that odd CQE as handled.  The first line of the log does that.


 nvme nvme0: Skip completion of I/O 309 on queue 35 due to missing q
 nvme nvme0: I/O 309 QID 63 timeout, aborting
 nvme nvme0: Abort status: 0x0
 nvme nvme0: I/O 309 QID 63 timeout, reset controller
 nvme nvme0: completing aborted command with status: fffc
 nvme 0003:03:00.0: Using 64-bit DMA iommu bypass
 blk_update_request: I/O error, dev nvme0n1, sector 2105537536


In the first line, we found the request 309 for queue 35, which would
have crashed the execution.  My debug patch just ignores it.

Then, we can see that eventually, the same IO, 309, will timeout in
another QID, which was actually expecting for it.  The Abort request
gets sent and completed, but we never receive the completion of the
aborted request, thus we timeout again and restart the device.

This only happens when we are changing the SMT settings very
frequently, which points back to the way we correlate the hctx->tags to
the nvmeq structure, but I failed to find the exact code spot were
things get messed up.

I've put a some effort on this code lately, but I definitely need some
assistance on this one.  Since, as far as I understand, this issue is
much more likely to reproduce on boxes with a lot of hotpluggable
processors, I'm willing to test any patches you may find suitable in our
systems.



Hi,

[Adding linux-block, linux-scsi and Jens in CC for blk-mq input]


[GIT PULL] SCSI fixes for 4.8-rc2

2016-08-19 Thread James Bottomley
Six fairly small fixes.  The ipr, mpt3sas and ses ones all trigger
oopses.  The megaraid one fixes an attach failure on io mapped only
cards, the fcoe one is an obvious problem in the error path and the
aacraid one is a theoretical security issue (ability to trick the
kernel into a buffer overrun).

The patch is available here:

git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git scsi-fixes

The short changelog is:

Brian King (1):
  ipr: Fix sync scsi scan

Calvin Owens (1):
  ses: Fix racy cleanup of /sys in remove_dev()

Dave Carroll (1):
  aacraid: Check size values after double-fetch from user

Greg Edwards (1):
  mpt3sas: Fix resume on WarpDrive flash cards

Wei Yongjun (1):
  fcoe: Use kfree_skb() instead of kfree()

Yinghai Lu (1):
  megaraid_sas: Fix probing cards without io port

And the diffstat:

 drivers/scsi/aacraid/commctrl.c | 13 +++--
 drivers/scsi/fcoe/fcoe_ctlr.c   |  2 +-
 drivers/scsi/ipr.c  | 11 ++-
 drivers/scsi/megaraid/megaraid_sas_base.c   |  6 +++---
 drivers/scsi/megaraid/megaraid_sas_fusion.c |  2 +-
 drivers/scsi/mpt3sas/mpt3sas_base.c | 22 +++---
 drivers/scsi/ses.c  |  3 ++-
 7 files changed, 35 insertions(+), 24 deletions(-)

With full diff below.

James

---

diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index b381b37..5648b71 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -63,7 +63,7 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user 
*arg)
struct fib *fibptr;
struct hw_fib * hw_fib = (struct hw_fib *)0;
dma_addr_t hw_fib_pa = (dma_addr_t)0LL;
-   unsigned size;
+   unsigned int size, osize;
int retval;
 
if (dev->in_reset) {
@@ -87,7 +87,8 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user 
*arg)
 *  will not overrun the buffer when we copy the memory. Return
 *  an error if we would.
 */
-   size = le16_to_cpu(kfib->header.Size) + sizeof(struct aac_fibhdr);
+   osize = size = le16_to_cpu(kfib->header.Size) +
+   sizeof(struct aac_fibhdr);
if (size < le16_to_cpu(kfib->header.SenderSize))
size = le16_to_cpu(kfib->header.SenderSize);
if (size > dev->max_fib_size) {
@@ -118,6 +119,14 @@ static int ioctl_send_fib(struct aac_dev * dev, void 
__user *arg)
goto cleanup;
}
 
+   /* Sanity check the second copy */
+   if ((osize != le16_to_cpu(kfib->header.Size) +
+   sizeof(struct aac_fibhdr))
+   || (size < le16_to_cpu(kfib->header.SenderSize))) {
+   retval = -EINVAL;
+   goto cleanup;
+   }
+
if (kfib->header.Command == cpu_to_le16(TakeABreakPt)) {
aac_adapter_interrupt(dev);
/*
diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index a569c65..dcf3653 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -2923,7 +2923,7 @@ static int fcoe_ctlr_vlan_recv(struct fcoe_ctlr *fip, 
struct sk_buff *skb)
mutex_unlock(>ctlr_mutex);
 
 drop:
-   kfree(skb);
+   kfree_skb(skb);
return rc;
 }
 
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index bf85974..17d04c7 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -10410,8 +10410,11 @@ static int ipr_probe(struct pci_dev *pdev, const 
struct pci_device_id *dev_id)
__ipr_remove(pdev);
return rc;
}
+   spin_lock_irqsave(ioa_cfg->host->host_lock, flags);
+   ioa_cfg->scan_enabled = 1;
+   schedule_work(_cfg->work_q);
+   spin_unlock_irqrestore(ioa_cfg->host->host_lock, flags);
 
-   scsi_scan_host(ioa_cfg->host);
ioa_cfg->iopoll_weight = ioa_cfg->chip_cfg->iopoll_weight;
 
if (ioa_cfg->iopoll_weight && ioa_cfg->sis64 && ioa_cfg->nvectors > 1) {
@@ -10421,10 +10424,8 @@ static int ipr_probe(struct pci_dev *pdev, const 
struct pci_device_id *dev_id)
}
}
 
-   spin_lock_irqsave(ioa_cfg->host->host_lock, flags);
-   ioa_cfg->scan_enabled = 1;
-   schedule_work(_cfg->work_q);
-   spin_unlock_irqrestore(ioa_cfg->host->host_lock, flags);
+   scsi_scan_host(ioa_cfg->host);
+
return 0;
 }
 
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 2dab3dc..c1ed25a 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -5037,7 +5037,7 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
/* Find first memory bar */
bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM);
instance->bar = find_first_bit(_list, sizeof(unsigned long));
-   if (pci_request_selected_regions(instance->pdev, instance->bar,
+   if 

Re: Oops when completing request on the wrong queue

2016-08-19 Thread Jens Axboe

On 08/19/2016 07:28 AM, Gabriel Krisman Bertazi wrote:

Gabriel Krisman Bertazi  writes:


We, IBM, have been experiencing eventual Oops when stressing IO at the
same time we add/remove processors.  The Oops happens in the IRQ path,
when we try to complete a request that was apparently meant for another
queue.

In __nvme_process_cq, the driver will use the cqe.command_id and the
nvmeq->tags to find out, via blk_mq_tag_to_rq, the request that
initiated the IO.  Eventually, it happens that the request returned by
that function is not initialized, and we crash inside
__blk_mq_complete_request, as shown below.

[ 2679.050701] Faulting instruction address: 0xc0549500
[ 2679.050711] Oops: Kernel access of bad area, sig: 11 [#1]
[ 2679.050716] SMP NR_CPUS=2048 NUMA pSeries
[ 2679.050727] Modules linked in: minix nls_iso8859_1 xfs libcrc32c
rpcsec_gss_krb5 auth_rpcgss
nfsv4 nfs lockd grace fscache binfmt_misc pseries_rng rtc_generic sunrpc
autofs4 btrfs xor
raid6_pq ibmvscsi ibmveth nvme
[ 2679.050771] CPU: 21 PID: 45045 Comm: ppc64_cpu Not tainted 4.4.0-22-generic 
#40-Ubuntu
[ 2679.050780] task: c00497b07e60 ti: c004fff2c000 task.ti: 
c00451bc
[ 2679.050786] NIP: c0549500 LR: d46b5e84 CTR: c0549680
[ 2679.050803] REGS: c004fff2fa80 TRAP: 0300   Not tainted  
(4.4.0-22-generic)
[ 2679.050807] MSR: 80019033   CR: 28022428  XER: 

[ 2679.050824] CFAR: c0008468 DAR: 00b0 DSISR: 4000 
SOFTE: 0
GPR00: d46b5e84 c004fff2fd00 c15b4300 c002799a0a00
GPR04:  0105 0004 0001
GPR08: c002799a0a50   d46bdc68
GPR12: c0549680 c7b1c780 0008 0001
GPR16:    10005b50
GPR20: 10005dc8 c15eaa60 0001 0002
GPR24: 01e3   
GPR28:   c004f8cd5180 c002799a0a00
[ 2679.050908] NIP [c0549500] __blk_mq_complete_request+0x30/0x1b0
[ 2679.050924] LR [d46b5e84] __nvme_process_cq+0xf4/0x2c0 [nvme]
[ 2679.050930] Call Trace:
[ 2679.050941] [c004fff2fd00] [c004fff2fd40] 0xc004fff2fd40 
(unreliable)
[ 2679.050952] [c004fff2fd40] [d46b5e84] 
__nvme_process_cq+0xf4/0x2c0 [nvme]
[ 2679.050961] [c004fff2fde0] [d46b613c] nvme_irq+0x3c/0xb0 [nvme]
[ 2679.050972] [c004fff2fe10] [c0130660] 
handle_irq_event_percpu+0xa0/0x320
[ 2679.050981] [c004fff2fed0] [c0130948] handle_irq_event+0x68/0xc0
[ 2679.050989] [c004fff2ff00] [c0135c2c] 
handle_fasteoi_irq+0xec/0x2b0
[ 2679.050997] [c004fff2ff30] [c012f844] 
generic_handle_irq+0x54/0x80
[ 2679.051007] [c004fff2ff60] [c0011320] __do_irq+0x80/0x1d0
[ 2679.051020] [c004fff2ff90] [c0024800] call_do_irq+0x14/0x24
[ 2679.051037] [c00451bc3350] [c0011508] do_IRQ+0x98/0x140
[ 2679.051054] [c00451bc33a0] [c0002594]
hardware_interrupt_common+0x114/0x180

I added some debugging which skipped the Oops and made me think that we
are fetching the wrong request because we are actually looking at the
wrong set of tags.

The log below exemplifies what I am saying.  Instead of crashing in the
Oops, I made the execution skip the request completion and simply
consider that odd CQE as handled.  The first line of the log does that.


 nvme nvme0: Skip completion of I/O 309 on queue 35 due to missing q
 nvme nvme0: I/O 309 QID 63 timeout, aborting
 nvme nvme0: Abort status: 0x0
 nvme nvme0: I/O 309 QID 63 timeout, reset controller
 nvme nvme0: completing aborted command with status: fffc
 nvme 0003:03:00.0: Using 64-bit DMA iommu bypass
 blk_update_request: I/O error, dev nvme0n1, sector 2105537536


In the first line, we found the request 309 for queue 35, which would
have crashed the execution.  My debug patch just ignores it.

Then, we can see that eventually, the same IO, 309, will timeout in
another QID, which was actually expecting for it.  The Abort request
gets sent and completed, but we never receive the completion of the
aborted request, thus we timeout again and restart the device.

This only happens when we are changing the SMT settings very
frequently, which points back to the way we correlate the hctx->tags to
the nvmeq structure, but I failed to find the exact code spot were
things get messed up.

I've put a some effort on this code lately, but I definitely need some
assistance on this one.  Since, as far as I understand, this issue is
much more likely to reproduce on boxes with a lot of hotpluggable
processors, I'm willing to test any patches you may find suitable in our
systems.



Hi,

[Adding linux-block, linux-scsi and Jens in CC for blk-mq input]

Made some progress on tracking 

[PATCH v2] fcoe: provide translation table between Ethernet and FC port speeds

2016-08-19 Thread Johannes Thumshirn
Provide a translation table between Ethernet and FC port speeds so odd
speeds (from a Ethernet POV) like 8 Gbit are correctly mapped to sysfs
and open-fcoe's fcoeadm.

Before:
Description:  BCM57840 NetXtreme II 10/20-Gigabit Ethernet
Revision: 11
Manufacturer: Broadcom Corporation
Serial Number:6CC2173EA1D0

Driver:   bnx2x 1.712.30-0
Number of Ports:  1

Symbolic Name: bnx2fc (QLogic BCM57840) v2.10.3 over eth2
OS Device Name:host1
Node Name: 0x20006cc2173ea1d1
Port Name: 0x10006cc2173ea1d1
FabricName:0x10c0dd0ce717
Speed: unknown
Supported Speed:   1 Gbit, 10 Gbit
MaxFrameSize:  2048 bytes
FC-ID (Port ID):   0x660702
State: Online

After:
Description:  BCM57840 NetXtreme II 10/20-Gigabit Ethernet
Revision: 11
Manufacturer: Broadcom Corporation
Serial Number:6CC2173EA1D0

Driver:   bnx2x 1.712.30-0
Number of Ports:  1

Symbolic Name: bnx2fc (QLogic BCM57840) v2.10.3 over eth2
OS Device Name:host1
Node Name: 0x20006cc2173ea1d1
Port Name: 0x10006cc2173ea1d1
FabricName:0x10c0dd0ce717
Speed: 8 Gbit
Supported Speed:   1 Gbit, 10 Gbit
MaxFrameSize:  2048 bytes
FC-ID (Port ID):   0x660701
State: Online

Signed-off-by: Johannes Thumshirn 
---

Changes to v1:
* Add definitions for non-native Ethernet speeds

 drivers/scsi/fcoe/fcoe_transport.c | 53 ++
 1 file changed, 36 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/fcoe/fcoe_transport.c 
b/drivers/scsi/fcoe/fcoe_transport.c
index 7028dd3..c164eec 100644
--- a/drivers/scsi/fcoe/fcoe_transport.c
+++ b/drivers/scsi/fcoe/fcoe_transport.c
@@ -83,6 +83,41 @@ static struct notifier_block libfcoe_notifier = {
.notifier_call = libfcoe_device_notification,
 };
 
+static const struct {
+   u32 fc_port_speed;
+#define SPEED_2000 2000
+#define SPEED_4000 4000
+#define SPEED_8000 8000
+#define SPEED_1600016000
+#define SPEED_3200032000
+   u32 eth_port_speed;
+} fcoe_port_speed_mapping[] = {
+   { FC_PORTSPEED_1GBIT,   SPEED_1000   },
+   { FC_PORTSPEED_2GBIT,   SPEED_2000   },
+   { FC_PORTSPEED_4GBIT,   SPEED_4000   },
+   { FC_PORTSPEED_8GBIT,   SPEED_8000   },
+   { FC_PORTSPEED_10GBIT,  SPEED_1  },
+   { FC_PORTSPEED_16GBIT,  SPEED_16000  },
+   { FC_PORTSPEED_20GBIT,  SPEED_2  },
+   { FC_PORTSPEED_25GBIT,  SPEED_25000  },
+   { FC_PORTSPEED_32GBIT,  SPEED_32000  },
+   { FC_PORTSPEED_40GBIT,  SPEED_4  },
+   { FC_PORTSPEED_50GBIT,  SPEED_5  },
+   { FC_PORTSPEED_100GBIT, SPEED_10 },
+};
+
+static inline u32 eth2fc_speed(u32 eth_port_speed)
+{
+   int i;
+
+   for (i = 0; i <= ARRAY_SIZE(fcoe_port_speed_mapping); i++) {
+   if (fcoe_port_speed_mapping[i].eth_port_speed == eth_port_speed)
+   return fcoe_port_speed_mapping[i].fc_port_speed;
+   }
+
+   return FC_PORTSPEED_UNKNOWN;
+}
+
 /**
  * fcoe_link_speed_update() - Update the supported and actual link speeds
  * @lport: The local port to update speeds for
@@ -126,23 +161,7 @@ int fcoe_link_speed_update(struct fc_lport *lport)
SUPPORTED_4baseLR4_Full))
lport->link_supported_speeds |= FC_PORTSPEED_40GBIT;
 
-   switch (ecmd.base.speed) {
-   case SPEED_1000:
-   lport->link_speed = FC_PORTSPEED_1GBIT;
-   break;
-   case SPEED_1:
-   lport->link_speed = FC_PORTSPEED_10GBIT;
-   break;
-   case SPEED_2:
-   lport->link_speed = FC_PORTSPEED_20GBIT;
-   break;
-   case SPEED_4:
-   lport->link_speed = FC_PORTSPEED_40GBIT;
-   break;
-   default:
-   lport->link_speed = FC_PORTSPEED_UNKNOWN;
-   break;
-   }
+   lport->link_speed = eth2fc_speed(ecmd.base.speed);
return 0;
}
return -1;
-- 
1.8.5.6

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


Re: Oops when completing request on the wrong queue

2016-08-19 Thread Gabriel Krisman Bertazi
Gabriel Krisman Bertazi  writes:

> We, IBM, have been experiencing eventual Oops when stressing IO at the
> same time we add/remove processors.  The Oops happens in the IRQ path,
> when we try to complete a request that was apparently meant for another
> queue.
>
> In __nvme_process_cq, the driver will use the cqe.command_id and the
> nvmeq->tags to find out, via blk_mq_tag_to_rq, the request that
> initiated the IO.  Eventually, it happens that the request returned by
> that function is not initialized, and we crash inside
> __blk_mq_complete_request, as shown below.
>
> [ 2679.050701] Faulting instruction address: 0xc0549500
> [ 2679.050711] Oops: Kernel access of bad area, sig: 11 [#1]
> [ 2679.050716] SMP NR_CPUS=2048 NUMA pSeries
> [ 2679.050727] Modules linked in: minix nls_iso8859_1 xfs libcrc32c
> rpcsec_gss_krb5 auth_rpcgss
> nfsv4 nfs lockd grace fscache binfmt_misc pseries_rng rtc_generic sunrpc
> autofs4 btrfs xor
> raid6_pq ibmvscsi ibmveth nvme
> [ 2679.050771] CPU: 21 PID: 45045 Comm: ppc64_cpu Not tainted 
> 4.4.0-22-generic #40-Ubuntu
> [ 2679.050780] task: c00497b07e60 ti: c004fff2c000 task.ti: 
> c00451bc
> [ 2679.050786] NIP: c0549500 LR: d46b5e84 CTR: 
> c0549680
> [ 2679.050803] REGS: c004fff2fa80 TRAP: 0300   Not tainted  
> (4.4.0-22-generic)
> [ 2679.050807] MSR: 80019033   CR: 28022428  
> XER: 
> [ 2679.050824] CFAR: c0008468 DAR: 00b0 DSISR: 4000 
> SOFTE: 0 
> GPR00: d46b5e84 c004fff2fd00 c15b4300 c002799a0a00 
> GPR04:  0105 0004 0001 
> GPR08: c002799a0a50   d46bdc68 
> GPR12: c0549680 c7b1c780 0008 0001 
> GPR16:    10005b50 
> GPR20: 10005dc8 c15eaa60 0001 0002 
> GPR24: 01e3    
> GPR28:   c004f8cd5180 c002799a0a00 
> [ 2679.050908] NIP [c0549500] __blk_mq_complete_request+0x30/0x1b0
> [ 2679.050924] LR [d46b5e84] __nvme_process_cq+0xf4/0x2c0 [nvme]
> [ 2679.050930] Call Trace:
> [ 2679.050941] [c004fff2fd00] [c004fff2fd40] 0xc004fff2fd40 
> (unreliable)
> [ 2679.050952] [c004fff2fd40] [d46b5e84] 
> __nvme_process_cq+0xf4/0x2c0 [nvme]
> [ 2679.050961] [c004fff2fde0] [d46b613c] nvme_irq+0x3c/0xb0 [nvme]
> [ 2679.050972] [c004fff2fe10] [c0130660] 
> handle_irq_event_percpu+0xa0/0x320
> [ 2679.050981] [c004fff2fed0] [c0130948] 
> handle_irq_event+0x68/0xc0
> [ 2679.050989] [c004fff2ff00] [c0135c2c] 
> handle_fasteoi_irq+0xec/0x2b0
> [ 2679.050997] [c004fff2ff30] [c012f844] 
> generic_handle_irq+0x54/0x80
> [ 2679.051007] [c004fff2ff60] [c0011320] __do_irq+0x80/0x1d0
> [ 2679.051020] [c004fff2ff90] [c0024800] call_do_irq+0x14/0x24
> [ 2679.051037] [c00451bc3350] [c0011508] do_IRQ+0x98/0x140
> [ 2679.051054] [c00451bc33a0] [c0002594]
> hardware_interrupt_common+0x114/0x180
>
> I added some debugging which skipped the Oops and made me think that we
> are fetching the wrong request because we are actually looking at the
> wrong set of tags.
>
> The log below exemplifies what I am saying.  Instead of crashing in the
> Oops, I made the execution skip the request completion and simply
> consider that odd CQE as handled.  The first line of the log does that.
>
>>  nvme nvme0: Skip completion of I/O 309 on queue 35 due to missing q
>>  nvme nvme0: I/O 309 QID 63 timeout, aborting
>>  nvme nvme0: Abort status: 0x0
>>  nvme nvme0: I/O 309 QID 63 timeout, reset controller
>>  nvme nvme0: completing aborted command with status: fffc
>>  nvme 0003:03:00.0: Using 64-bit DMA iommu bypass
>>  blk_update_request: I/O error, dev nvme0n1, sector 2105537536
>
> In the first line, we found the request 309 for queue 35, which would
> have crashed the execution.  My debug patch just ignores it.
>
> Then, we can see that eventually, the same IO, 309, will timeout in
> another QID, which was actually expecting for it.  The Abort request
> gets sent and completed, but we never receive the completion of the
> aborted request, thus we timeout again and restart the device.
>
> This only happens when we are changing the SMT settings very
> frequently, which points back to the way we correlate the hctx->tags to
> the nvmeq structure, but I failed to find the exact code spot were
> things get messed up.
>
> I've put a some effort on this code lately, but I definitely need some
> assistance on this one.  Since, as far as I understand, this issue is
> much more likely to reproduce on boxes with a lot of hotpluggable
> processors, I'm willing to test any patches you may 

Re: [PATCH 5/6] cxlflash: Remove adapter file descriptor cache

2016-08-19 Thread Manoj Kumar

Acked-by: Manoj N. Kumar 


On 8/9/2016 6:40 PM, Matthew R. Ochs wrote:

The adapter file descriptor was previously cached within the kernel
for a given context in order to support performing a close on behalf
of an application. This is no longer needed as applications are now
required to perform a close on the adapter file descriptor.

Inspired-by: Al Viro 
Signed-off-by: Matthew R. Ochs 


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


Re: [PATCH 6/6] cxlflash: Update documentation

2016-08-19 Thread Manoj Kumar

Acked-by: Manoj N. Kumar 


On 8/9/2016 6:40 PM, Matthew R. Ochs wrote:

Update the block library link in the API documentation.

Signed-off-by: Matthew R. Ochs 
---
 Documentation/powerpc/cxlflash.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/powerpc/cxlflash.txt 
b/Documentation/powerpc/cxlflash.txt
index f4c1190..6d9a2ed 100644
--- a/Documentation/powerpc/cxlflash.txt
+++ b/Documentation/powerpc/cxlflash.txt
@@ -121,7 +121,7 @@ Block library API
 below.

 The block library can be found on GitHub:
-http://www.github.com/mikehollinger/ibmcapikv
+http://github.com/open-power/capiflash


 CXL Flash Driver IOCTLs



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


Re: [PATCH] fcoe: provide translation table between Ethernet and FC port speeds

2016-08-19 Thread Johannes Thumshirn
On Fri, Aug 19, 2016 at 10:37:04AM +0200, Hannes Reinecke wrote:
> On 08/15/2016 05:24 PM, Johannes Thumshirn wrote:

[...]

> >  
> > +static const struct {
> > +   u32 fc_port_speed;
> > +   u32 eth_port_speed;
> > +} fcoe_port_speed_mapping[] = {
> > +   { FC_PORTSPEED_1GBIT, SPEED_1000 },
> > +   { FC_PORTSPEED_2GBIT, 2000 },
> > +   { FC_PORTSPEED_4GBIT, 4000 },
> > +   { FC_PORTSPEED_8GBIT, 8000 },
> > +   { FC_PORTSPEED_10GBIT, SPEED_1 },
> > +   { FC_PORTSPEED_16GBIT, 16000 },
> > +   { FC_PORTSPEED_20GBIT, SPEED_2  },
> > +   { FC_PORTSPEED_25GBIT, SPEED_25000  },
> > +   { FC_PORTSPEED_32GBIT, 32000 },
> > +   { FC_PORTSPEED_40GBIT, SPEED_4  },
> > +   { FC_PORTSPEED_50GBIT, SPEED_5  },
> > +   { FC_PORTSPEED_100GBIT, SPEED_10 },
> > +};
> > +
> Hmm. Why not 'SPEED_2000' etc?
> 
> This looks a bit weird, mixing values with defines ...

I'll add defines for the non Ethernet native speeds privately to this file.

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Observing Softlockup's while running heavy IOs

2016-08-19 Thread Sreekanth Reddy
First of all thanks for Robert and Bart for reply.

Robert,
Thanks for the URL, I have gone though this URL.
Yes I am also observing that all the interrupts are routed to one CPU.
But still I observing softlockups (sometime hardlockups) even when I
set rq_affinity to 2.

Is their any way to route the interrupts the same CPUs which has
submitted the corresponding IOs?
or
Is their any way/option in the irqbalance/kernel which can route
interrupts to CPUs (enabled in affinity_hint) in round robin manner
after specific time period.


Bart,
I have tried with your path and here is logs,

[Aug19 13:48] __blk_mq_run_hw_queue() finished after 1 ms
[  +1.196454] __blk_mq_run_hw_queue() finished after 11 ms
[Aug19 13:49] __blk_mq_run_hw_queue() finished after 20 ms
[ +14.173018] __blk_mq_run_hw_queue() finished after 278 ms
[ +14.066448] __blk_mq_run_hw_queue() finished after 588 ms
[  +5.394698] __blk_mq_run_hw_queue() finished after 1360 ms
[Aug19 13:51] __blk_mq_run_hw_queue() finished after 1539 ms
[Aug19 13:54] __blk_mq_run_hw_queue() finished after 1762 ms
[Aug19 13:55] __blk_mq_run_hw_queue() finished after 2087 ms
[Aug19 13:57] __blk_mq_run_hw_queue() finished after 2915 ms
[Aug19 14:06] perf interrupt took too long (2509 > 2500), lowering
kernel.perf_event_max_sample_rate to 5
[Aug19 14:10] __blk_mq_run_hw_queue() finished after 3266 ms
[Aug19 14:15] __blk_mq_run_hw_queue() finished after 3953 ms
[Aug19 14:22] NMI watchdog: BUG: soft lockup - CPU#6 stuck for 22s!
[llvmpipe-9:3152]
[  +0.000439] __blk_mq_run_hw_queue() finished after 10058 ms
[  +0.007206] Modules linked in: mpt3sas(OE) xt_CHECKSUM
iptable_mangle ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat
nf_nat_ipv4 nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack
nf_conntrack tun bridge stp llc ebtable_filter ebtables
ip6table_filter ip6_tables raid456 async_raid6_recov async_memcpy
async_pq async_xor xor intel_rapl async_tx iosf_mbi
x86_pkg_temp_thermal raid6_pq coretemp kvm crct10dif_pclmul
crc32_pclmul ghash_clmulni_intel mei_me joydev pcspkr sb_edac i2c_i801
mei iTCO_wdt iTCO_vendor_support edac_core lpc_ich ipmi_ssif ipmi_si
ipmi_msghandler shpchp tpm_tis ioatdma acpi_power_meter tpm wmi
acpi_pad nfsd auth_rpcgss nfs_acl lockd grace sunrpc xfs libcrc32c ast
i2c_algo_bit drm_kms_helper ttm ixgbe drm mdio vxlan ip6_udp_tunnel
udp_tunnel crc32c_intel raid_class ptp scsi_transport_sas
[  +0.63]  pps_core nvme dca [last unloaded: mpt3sas]
[  +0.07] CPU: 6 PID: 3152 Comm: llvmpipe-9 Tainted: GW
OE   4.2.0 #1
[  +0.02] Hardware name: Supermicro SYS-2028U-TNRT+/X10DRU-i+,
BIOS 1.1 07/22/2015
[  +0.03] task: 883f5cf557c0 ti: 883f5afd8000 task.ti:
883f5afd8000
[  +0.02] RIP: 0010:[]  []
__do_softirq+0x7b/0x290
[  +0.08] RSP: :883f7f183f08  EFLAGS: 0206
[  +0.02] RAX: 883f5afdc000 RBX: 883f7f190080 RCX: 06e0
[  +0.02] RDX: 3508 RSI: 71c139c0 RDI: 883f5cf557c0
[  +0.02] RBP: 883f7f183f68 R08: 3508717f8da4 R09: 883f7f183d80
[  +0.02] R10:  R11: 0004 R12: 883f7f183e78
[  +0.01] R13: 8177304b R14: 883f7f183f68 R15: 
[  +0.03] FS:  7fa76b7f6700() GS:883f7f18()
knlGS:

Message from syslogd@dhcp-135-24-192-127 at Aug 19 14:22:42 ...
 kernel:NMI watchdog: BUG: soft lockup - CPU#6 stuck for 22s! [llvmpipe-9:3152]
[  +0.02] CS:  0010 DS:  ES:  CR0: 80050033
[  +0.02] CR2: 7fa03a2d90c0 CR3: 003f61fe4000 CR4: 001406e0
[  +0.02] Stack:
[  +0.01]  883f7f18fc40 404040407f18fce8 883f5afdc000
000100aecc1a
[  +0.04]  0ab1000a 02027f18fc58 883f7f183f48

[  +0.03]  883f7f1967c0 883f448d57c0 
0001
[  +0.03] Call Trace:
[  +0.02]  
[  +0.05]  [] irq_exit+0x116/0x120
[  +0.05]  [] smp_apic_timer_interrupt+0x46/0x60
[  +0.05]  [] apic_timer_interrupt+0x6b/0x70
[  +0.02]  
[  +0.05]  [] ? finish_task_switch+0x6b/0x200
[  +0.06]  [] __schedule+0x36c/0x950
[  +0.02]  [] schedule+0x37/0x80
[  +0.06]  [] futex_wait_queue_me+0xbc/0x120
[  +0.04]  [] futex_wait+0x119/0x270
[  +0.04]  [] ? futex_wake+0x90/0x180
[  +0.03]  [] do_futex+0x12b/0xb00
[  +0.05]  [] ? set_next_entity+0x23e/0x440
[  +0.07]  [] ? __switch_to+0x261/0x4b0
[  +0.04]  [] SyS_futex+0x81/0x180
[  +0.02]  [] ? schedule+0x37/0x80
[  +0.04]  [] entry_SYSCALL_64_fastpath+0x12/0x71
[  +0.01] Code: 7e 00 01 00 00 65 48 8b 04 25 c4 3c 01 00 c7 45 c0
0a 00 00 00 48 89 45 b0 65 c7 05 6c 26 f7 7e 00 00 00 00 fb 66 0f 1f
44 00 00  ff ff ff ff 49 c7 c4 c0 a0 c0 81 0f bc 45 cc 83 c0 01 89
45

and here is the 'sar -u ALL 1 -P ALL 1'
02:22:43 PM CPU  %usr %nice  %sys   %iowait%steal
%irq %soft%guest%gnice %idle
02:22:44 PM all  5.73  0.60 

[PATCH] scsi:Prevent deletion of SCSI block device in use

2016-08-19 Thread Vasundhara Gurunath
SCSI block device can be removed, using write to sysfs delete file as below:
echo 1 > /sys/block/sdX/device/delete
If the device is in use by applications, or part of system configuration
such as boot device, removal can result in application disruptions or
system down time.

An additional write option ? is added to SCSI sysfs interface as below,
in order to prevent accidental deletion of devices in use.
echo ? > /sys/block/sdX/device/delete

In the absence of any usage, this option proceeds with device deletion.
If the device is open, deletion is prevented, and active Open and IO
counts at the time of deletion is logged. Information logged during latest
delete attempt can be obtained by issuing a read to the delete file as below:
cat  /sys/block/sdX/device/delete

Signed-off-by: Vasundhara Gurunath 
---
 drivers/scsi/scsi_sysfs.c  | 51 +-
 drivers/scsi/sd.c  |  5 -
 include/scsi/scsi_device.h |  2 ++
 3 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 0734927..716b22a 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -12,6 +12,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+
 
 #include 
 #include 
@@ -457,6 +460,9 @@ static void scsi_device_dev_release_usercontext(struct 
work_struct *work)
kfree(sdev->vpd_pg83);
kfree(sdev->vpd_pg80);
kfree(sdev->inquiry);
+   if (sdev->delete_msg_buf != NULL)
+   kfree(sdev->delete_msg_buf);
+
kfree(sdev);
 
if (parent)
@@ -709,11 +715,54 @@ static ssize_t
 sdev_store_delete(struct device *dev, struct device_attribute *attr,
  const char *buf, size_t count)
 {
+   struct scsi_device *sdev = to_scsi_device(dev);
+   struct timeval tv;
+   struct tm tms;
+
+   if (buf[0] == '?')  {
+   if (sdev->usage_count) {
+   /*
+* Buffer to hold I/O statistics on delete attempt.
+*/
+   if (sdev->delete_msg_buf == NULL) {
+   sdev->delete_msg_buf =
+   kmalloc(128, GFP_KERNEL);
+   memset(sdev->delete_msg_buf, 0, 128);
+   }
+   do_gettimeofday();
+   time_to_tm(tv.tv_sec, 0, );
+   sprintf(sdev->delete_msg_buf,
+   "Last delete attempt: %d:%d:%d %02d:%02d\n"
+   "Open Count : %d\n"
+   "IO Active Count : %d\n"
+   "IO Done Count : %d\n",
+   tms.tm_mday, tms.tm_mon + 1,
+   tms.tm_year + 1900,
+   tms.tm_hour, tms.tm_min,
+   sdev->usage_count,
+   sdev->iorequest_cnt.counter,
+   sdev->iodone_cnt.counter);
+
+   return count;
+   }
+   }
+
if (device_remove_file_self(dev, attr))
scsi_remove_device(to_scsi_device(dev));
return count;
 };
-static DEVICE_ATTR(delete, S_IWUSR, NULL, sdev_store_delete);
+
+static ssize_t sdev_show_delete(struct device *dev,
+   struct device_attribute *attr, char *buf) {
+
+   struct scsi_device *sdev = to_scsi_device(dev);
+   if (sdev->delete_msg_buf != NULL)
+   return sprintf(buf, "%s", sdev->delete_msg_buf);
+   else
+   return 0;
+}
+static DEVICE_ATTR(delete, S_IRUGO | S_IWUSR, sdev_show_delete,
+sdev_store_delete);
 
 static ssize_t
 store_state_field(struct device *dev, struct device_attribute *attr,
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index d3e852a..d5cf25c 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1235,6 +1235,7 @@ static int sd_open(struct block_device *bdev, fmode_t 
mode)
if (scsi_block_when_processing_errors(sdev))
scsi_set_medium_removal(sdev, SCSI_REMOVAL_PREVENT);
}
+   sdev->usage_count = sdkp->openers.counter;
 
return 0;
 
@@ -1267,7 +1268,7 @@ static void sd_release(struct gendisk *disk, fmode_t mode)
if (scsi_block_when_processing_errors(sdev))
scsi_set_medium_removal(sdev, SCSI_REMOVAL_ALLOW);
}
-
+   sdev->usage_count = sdkp->openers.counter;
/*
 * XXX and what if there are packets in flight and this close()
 * XXX is followed by a "rmmod sd_mod"?
@@ -3082,6 +3083,8 @@ static int sd_probe(struct device *dev)
atomic_set(>openers, 0);
atomic_set(>device->ioerr_cnt, 0);
 
+   sdp->usage_count = sdkp->openers.counter;
+
if (!sdp->request_queue->rq_timeout) {

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

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

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

iscsi_session_failure needs process context hence this work.

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

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

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


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

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

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

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

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


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

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

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

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

[PATCH v2 27/29] be2iscsi: Update copyright information

2016-08-19 Thread Jitendra Bhivare
Change the copyright to:
Copyright ©  - 2016 Broadcom

Update email.ids:
@avagotech.com - @broadcom.com

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be.h   | 4 ++--
 drivers/scsi/be2iscsi/be_cmds.c  | 4 ++--
 drivers/scsi/be2iscsi/be_cmds.h  | 4 ++--
 drivers/scsi/be2iscsi/be_iscsi.c | 6 +++---
 drivers/scsi/be2iscsi/be_iscsi.h | 6 +++---
 drivers/scsi/be2iscsi/be_main.c  | 6 +++---
 drivers/scsi/be2iscsi/be_main.h  | 6 +++---
 drivers/scsi/be2iscsi/be_mgmt.c  | 6 +++---
 drivers/scsi/be2iscsi/be_mgmt.h  | 6 +++---
 9 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index bb4042c..b1d0fdc 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2005 - 2015 Emulex
+ * Copyright (C) 2005 - 2016 Broadcom
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
@@ -8,7 +8,7 @@
  * Public License is included in this distribution in the file called COPYING.
  *
  * Contact Information:
- * linux-driv...@avagotech.com
+ * linux-driv...@broadcom.com
  *
  * Emulex
  *  Susan Street
diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 5fe1610..be65da2 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2005 - 2015 Emulex
+ * Copyright (C) 2005 - 2016 Broadcom
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
@@ -8,7 +8,7 @@
  * Public License is included in this distribution in the file called COPYING.
  *
  * Contact Information:
- * linux-driv...@avagotech.com
+ * linux-driv...@broadcom.com
  *
  * Emulex
  *  Susan Street
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 8283344..328fb5b 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2005 - 2015 Emulex
+ * Copyright (C) 2005 - 2016 Broadcom
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
@@ -8,7 +8,7 @@
  * Public License is included in this distribution in the file called COPYING.
  *
  * Contact Information:
- * linux-driv...@avagotech.com
+ * linux-driv...@broadcom.com
  *
  * Emulex
  *  Susan Street
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 35f7d3a..ba25821 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2005 - 2015 Emulex
+ * Copyright (C) 2005 - 2016 Broadcom
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
@@ -7,10 +7,10 @@
  * as published by the Free Software Foundation.  The full GNU General
  * Public License is included in this distribution in the file called COPYING.
  *
- * Written by: Jayamohan Kallickal (jayamohan.kallic...@avagotech.com)
+ * Written by: Jayamohan Kallickal (jayamohan.kallic...@broadcom.com)
  *
  * Contact Information:
- * linux-driv...@avagotech.com
+ * linux-driv...@broadcom.com
  *
  * Emulex
  *  Susan Street
diff --git a/drivers/scsi/be2iscsi/be_iscsi.h b/drivers/scsi/be2iscsi/be_iscsi.h
index 2a4097a..e4d67df 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.h
+++ b/drivers/scsi/be2iscsi/be_iscsi.h
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2005 - 2015 Avago Technologies
+ * Copyright (C) 2005 - 2016 Broadcom
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
@@ -7,10 +7,10 @@
  * as published by the Free Software Foundation.  The full GNU General
  * Public License is included in this distribution in the file called COPYING.
  *
- * Written by: Jayamohan Kallickal (jayamohan.kallic...@avagotech.com)
+ * Written by: Jayamohan Kallickal (jayamohan.kallic...@broadcom.com)
  *
  * Contact Information:
- * linux-driv...@avagotech.com
+ * linux-driv...@broadcom.com
  *
  * Avago Technologies
  *  Susan Street
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 7c372b8..222edfc 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2005 - 2015 Emulex
+ * Copyright (C) 2005 - 2016 Broadcom
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
@@ -7,10 +7,10 @@
  * as published by the Free Software Foundation.  The full GNU General
  * Public License is included in this distribution in the file called COPYING.
  *
- * Written by: Jayamohan Kallickal (jayamohan.kallic...@avagotech.com)
+ * Written by: Jayamohan Kallickal (jayamohan.kallic...@broadcom.com)
  *
  * Contact Information:
- * linux-driv...@avagotech.com
+ * linux-driv...@broadcom.com
  *
  * Emulex
  *  Susan Street
diff --git 

[PATCH v2 06/29] be2iscsi: Fix release of DHCP IP in static mode

2016-08-19 Thread Jitendra Bhivare
If BOOTPROTO is changed to static, the DHCP IP address should be released.
All cases are being handled mgmt_set_ip and mgmt_static_ip_modify.

Rearrange IFACE APIs to:
beiscsi_if_clr_ip
beiscsi_if_set_ip
beiscsi_if_en_static
beiscsi_if_en_dhcp

This simplifies release of DHCP IP when BOOTPROTO is set to static.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_iscsi.c | 125 ++---
 drivers/scsi/be2iscsi/be_mgmt.c  | 292 ---
 drivers/scsi/be2iscsi/be_mgmt.h  |   8 +-
 3 files changed, 201 insertions(+), 224 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 3ebfeff..7e17a8d 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -302,58 +302,6 @@ void beiscsi_destroy_def_ifaces(struct beiscsi_hba *phba)
}
 }
 
-static int
-beiscsi_set_static_ip(struct Scsi_Host *shost,
-   struct iscsi_iface_param_info *iface_param,
-   void *data, uint32_t dt_len)
-{
-   struct beiscsi_hba *phba = iscsi_host_priv(shost);
-   struct iscsi_iface_param_info *iface_ip = NULL;
-   struct iscsi_iface_param_info *iface_subnet = NULL;
-   struct nlattr *nla;
-   int ret;
-
-
-   switch (iface_param->param) {
-   case ISCSI_NET_PARAM_IPV4_BOOTPROTO:
-   nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_ADDR);
-   if (nla)
-   iface_ip = nla_data(nla);
-
-   nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_SUBNET);
-   if (nla)
-   iface_subnet = nla_data(nla);
-   break;
-   case ISCSI_NET_PARAM_IPV4_ADDR:
-   iface_ip = iface_param;
-   nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_SUBNET);
-   if (nla)
-   iface_subnet = nla_data(nla);
-   break;
-   case ISCSI_NET_PARAM_IPV4_SUBNET:
-   iface_subnet = iface_param;
-   nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_ADDR);
-   if (nla)
-   iface_ip = nla_data(nla);
-   break;
-   default:
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
-   "BS_%d : Unsupported param %d\n",
-   iface_param->param);
-   }
-
-   if (!iface_ip || !iface_subnet) {
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
-   "BS_%d : IP and Subnet Mask required\n");
-   return -EINVAL;
-   }
-
-   ret = mgmt_set_ip(phba, iface_ip, iface_subnet,
-   ISCSI_BOOTPROTO_STATIC);
-
-   return ret;
-}
-
 /**
  * beiscsi_set_vlan_tag()- Set the VLAN TAG
  * @shost: Scsi Host for the driver instance
@@ -401,17 +349,19 @@ beiscsi_set_vlan_tag(struct Scsi_Host *shost,
 
 
 static int
-beiscsi_set_ipv4(struct Scsi_Host *shost,
-   struct iscsi_iface_param_info *iface_param,
-   void *data, uint32_t dt_len)
+beiscsi_iface_config_ipv4(struct Scsi_Host *shost,
+ struct iscsi_iface_param_info *info,
+ void *data, uint32_t dt_len)
 {
struct beiscsi_hba *phba = iscsi_host_priv(shost);
+   u8 *ip = NULL, *subnet = NULL, *gw;
+   struct nlattr *nla;
int ret = 0;
 
/* Check the param */
-   switch (iface_param->param) {
+   switch (info->param) {
case ISCSI_NET_PARAM_IFACE_ENABLE:
-   if (iface_param->value[0] == ISCSI_IFACE_ENABLE)
+   if (info->value[0] == ISCSI_IFACE_ENABLE)
ret = beiscsi_create_ipv4_iface(phba);
else {
iscsi_destroy_iface(phba->ipv4_iface);
@@ -419,42 +369,59 @@ beiscsi_set_ipv4(struct Scsi_Host *shost,
}
break;
case ISCSI_NET_PARAM_IPV4_GW:
-   ret = beiscsi_if_set_gw(phba, BE2_IPV4, iface_param->value);
+   gw = info->value;
+   ret = beiscsi_if_set_gw(phba, BE2_IPV4, gw);
break;
case ISCSI_NET_PARAM_IPV4_BOOTPROTO:
-   if (iface_param->value[0] == ISCSI_BOOTPROTO_DHCP)
-   ret = mgmt_set_ip(phba, iface_param,
-   NULL, ISCSI_BOOTPROTO_DHCP);
-   else if (iface_param->value[0] == ISCSI_BOOTPROTO_STATIC)
-   ret = beiscsi_set_static_ip(shost, iface_param,
-   data, dt_len);
+   if (info->value[0] == ISCSI_BOOTPROTO_DHCP)
+   ret = beiscsi_if_en_dhcp(phba, BE2_IPV4);
+   else if (info->value[0] == ISCSI_BOOTPROTO_STATIC)
+   /* release DHCP IP address */
+   ret = beiscsi_if_en_static(phba, BE2_IPV4, 

[PATCH v2 28/29] be2iscsi: Update the driver version

2016-08-19 Thread Jitendra Bhivare
Driver version: 11.2.0.0

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_main.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 7173c03..6376657 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -36,7 +36,7 @@
 #include 
 
 #define DRV_NAME   "be2iscsi"
-#define BUILD_STR  "11.0.0.0"
+#define BUILD_STR  "11.2.0.0"
 #define BE_NAME"Emulex OneConnect" \
"Open-iSCSI Driver version" BUILD_STR
 #define DRV_DESC   BE_NAME " " "Driver"
-- 
1.9.1

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


[PATCH v2 26/29] be2iscsi: Fix queue and connection parameters

2016-08-19 Thread Jitendra Bhivare
Current EQ delay is set to 0 to receive very high max interrupt per sec.
Set EQ delay to 32 - reducing max interrupt rate from 65K to 20K per sec.

Set TCP connection window size to 64K with scale shift count 2.

Signed-off-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be_main.c | 2 +-
 drivers/scsi/be2iscsi/be_mgmt.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 50d865e..7c372b8 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -3729,7 +3729,7 @@ static int hwi_init_port(struct beiscsi_hba *phba)
phwi_context = phwi_ctrlr->phwi_ctxt;
phwi_context->max_eqd = 128;
phwi_context->min_eqd = 0;
-   phwi_context->cur_eqd = 0;
+   phwi_context->cur_eqd = 32;
/* set port optic state to unknown */
phba->optic_state = 0xff;
 
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 736eca3..adc827b 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -338,7 +338,7 @@ int mgmt_open_connection(struct beiscsi_hba *phba,
 
if (!is_chip_be2_be3r(phba)) {
req->hdr.version = MBX_CMD_VER1;
-   req->tcp_window_size = 0;
+   req->tcp_window_size = 0x8000;
req->tcp_window_scale_count = 2;
}
 
-- 
1.9.1

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


[PATCH v2 16/29] be2iscsi: Fix to add timer for UE detection

2016-08-19 Thread Jitendra Bhivare
UE detection in health check is done in a work scheduled in global wq.
UE caused due to transient parity errors are recoverable and reported
within 1s. If this check for TPE gets delayed, PF0 might initiate
soft-reset and then status of UE recoverable is lost.

Handle UE detection in timer routine. Move out EQ delay update work
from health check. Make the IOCTL for EQ delay update non-blocking
as the completion status is ignored.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be.h  |  9 +++--
 drivers/scsi/be2iscsi/be_cmds.c |  7 
 drivers/scsi/be2iscsi/be_cmds.h |  2 +-
 drivers/scsi/be2iscsi/be_main.c | 90 ++---
 drivers/scsi/be2iscsi/be_main.h |  7 +++-
 drivers/scsi/be2iscsi/be_mgmt.c | 11 +++--
 6 files changed, 75 insertions(+), 51 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index 454002d..bb4042c 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -89,7 +89,7 @@ struct be_aic_obj {   /* Adaptive interrupt 
coalescing (AIC) info */
u32 max_eqd;/* in usecs */
u32 prev_eqd;   /* in usecs */
u32 et_eqd; /* configured val when aic is off */
-   ulong jiffs;
+   ulong jiffies;
u64 eq_prev;/* Used to calculate eqe */
 };
 
@@ -111,9 +111,10 @@ struct be_mcc_obj {
 
 struct beiscsi_mcc_tag_state {
unsigned long tag_state;
-#define MCC_TAG_STATE_RUNNING  1
-#define MCC_TAG_STATE_TIMEOUT  2
-#define MCC_TAG_STATE_ASYNC3
+#define MCC_TAG_STATE_RUNNING  0
+#define MCC_TAG_STATE_TIMEOUT  1
+#define MCC_TAG_STATE_ASYNC2
+#define MCC_TAG_STATE_IGNORE   3
void (*cbfn)(struct beiscsi_hba *, unsigned int);
struct be_dma_mem tag_mem_state;
 };
diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 27d10ce..7cb009e 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -515,6 +515,13 @@ int beiscsi_process_mcc_compl(struct be_ctrl_info *ctrl,
return 0;
}
 
+   if (test_bit(MCC_TAG_STATE_IGNORE, >ptag_state[tag].tag_state)) {
+   /* just check completion status and free wrb */
+   __beiscsi_mcc_compl_status(phba, tag, NULL, NULL);
+   free_mcc_wrb(ctrl, tag);
+   return 0;
+   }
+
wake_up_interruptible(>mcc_wait[tag]);
return 0;
 }
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 0510b67..6fb9673 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -743,7 +743,7 @@ unsigned int be_cmd_get_initname(struct beiscsi_hba *phba);
 
 void free_mcc_wrb(struct be_ctrl_info *ctrl, unsigned int tag);
 
-int be_cmd_modify_eq_delay(struct beiscsi_hba *phba, struct be_set_eqd *,
+int beiscsi_modify_eq_delay(struct beiscsi_hba *phba, struct be_set_eqd *,
int num);
 int beiscsi_mccq_compl_wait(struct beiscsi_hba *phba,
unsigned int tag,
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index eb4ce17..3dd4f9d 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -4999,8 +4999,9 @@ static void beiscsi_quiesce(struct beiscsi_hba *phba)
if (phba->pcidev->irq)
free_irq(phba->pcidev->irq, phba);
pci_disable_msix(phba->pcidev);
-   cancel_delayed_work_sync(>beiscsi_hw_check_task);
+   cancel_delayed_work_sync(>eqd_update);
cancel_work_sync(>boot_work);
+   del_timer_sync(>hw_check);
 
for (i = 0; i < phba->num_cpus; i++) {
pbe_eq = _context->be_eq[i];
@@ -5339,18 +5340,32 @@ static void beiscsi_boot_work(struct work_struct *work)
}
 }
 
-static void be_eqd_update(struct beiscsi_hba *phba)
+static void beiscsi_hw_health_check(unsigned long ptr)
 {
+   struct beiscsi_hba *phba;
+
+   phba = (struct beiscsi_hba *)ptr;
+   beiscsi_ue_detect(phba);
+   if (test_bit(BEISCSI_HBA_IN_UE, >state))
+   return;
+
+   mod_timer(>hw_check,
+ jiffies + msecs_to_jiffies(BEISCSI_UE_DETECT_INTERVAL));
+}
+
+static void beiscsi_eqd_update_work(struct work_struct *work)
+{
+   struct hwi_context_memory *phwi_context;
struct be_set_eqd set_eqd[MAX_CPUS];
-   struct be_aic_obj *aic;
-   struct be_eq_obj *pbe_eq;
struct hwi_controller *phwi_ctrlr;
-   struct hwi_context_memory *phwi_context;
+   struct be_eq_obj *pbe_eq;
+   struct beiscsi_hba *phba;
+   unsigned int pps, delta;
+   struct be_aic_obj *aic;
int eqd, i, num = 0;
-   ulong now;
-   u32 pps, delta;
-   unsigned int tag;
+   unsigned long now;
 
+   phba = container_of(work, struct beiscsi_hba, eqd_update.work);
if 

[PATCH v2 20/29] be2iscsi: Add V1 of EPFW cleanup IOCTL

2016-08-19 Thread Jitendra Bhivare
mgmt_epfw_cleanup does not implement v1 of OPCODE_COMMON_ISCSI_CLEANUP
IOCTL for SkyHawk.

Replace use of MCCQ with BMBX for issuing the IOCTL.
Remove be_mcc_compl_poll which is no longer needed.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_cmds.c | 96 +
 drivers/scsi/be2iscsi/be_cmds.h | 15 +--
 drivers/scsi/be2iscsi/be_main.c | 27 ++--
 drivers/scsi/be2iscsi/be_mgmt.c | 42 --
 drivers/scsi/be2iscsi/be_mgmt.h |  1 -
 5 files changed, 73 insertions(+), 108 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 771670c..6f3cd82 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -478,53 +478,6 @@ int beiscsi_process_mcc_compl(struct be_ctrl_info *ctrl,
return 0;
 }
 
-/*
- * be_mcc_compl_poll()- Wait for MBX completion
- * @phba: driver private structure
- *
- * Wait till no more pending mcc requests are present
- *
- * return
- * Success: 0
- * Failure: Non-Zero
- *
- **/
-int be_mcc_compl_poll(struct beiscsi_hba *phba, unsigned int tag)
-{
-   struct be_ctrl_info *ctrl = >ctrl;
-   int i;
-
-   if (!test_bit(MCC_TAG_STATE_RUNNING,
- >ptag_state[tag].tag_state)) {
-   beiscsi_log(phba, KERN_ERR,
-   BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
-   "BC_%d: tag %u state not running\n", tag);
-   return 0;
-   }
-   for (i = 0; i < mcc_timeout; i++) {
-   if (beiscsi_hba_in_error(phba))
-   return -EIO;
-
-   beiscsi_process_mcc_cq(phba);
-   /* after polling, wrb and tag need to be released */
-   if (!test_bit(MCC_TAG_STATE_RUNNING,
- >ptag_state[tag].tag_state)) {
-   free_mcc_wrb(ctrl, tag);
-   break;
-   }
-   udelay(100);
-   }
-
-   if (i < mcc_timeout)
-   return 0;
-
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
-   "BC_%d : FW Timed Out\n");
-   set_bit(BEISCSI_HBA_FW_TIMEOUT, >state);
-   beiscsi_ue_detect(phba);
-   return -EBUSY;
-}
-
 void be_mcc_notify(struct beiscsi_hba *phba, unsigned int tag)
 {
struct be_queue_info *mccq = >ctrl.mcc_obj.q;
@@ -1645,3 +1598,52 @@ int beiscsi_init_sliport(struct beiscsi_hba *phba)
/* indicate driver is loading */
return beiscsi_cmd_special_wrb(>ctrl, 1);
 }
+
+/**
+ * beiscsi_cmd_iscsi_cleanup()- Inform FW to cleanup EP data structures.
+ * @phba: pointer to dev priv structure
+ * @ulp: ULP number.
+ *
+ * return
+ * Success: 0
+ * Failure: Non-Zero Value
+ **/
+int beiscsi_cmd_iscsi_cleanup(struct beiscsi_hba *phba, unsigned short ulp)
+{
+   struct be_ctrl_info *ctrl = >ctrl;
+   struct iscsi_cleanup_req_v1 *req_v1;
+   struct iscsi_cleanup_req *req;
+   struct be_mcc_wrb *wrb;
+   int status;
+
+   mutex_lock(>mbox_lock);
+   wrb = wrb_from_mbox(>mbox_mem);
+   req = embedded_payload(wrb);
+   be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
+   be_cmd_hdr_prepare(>hdr, CMD_SUBSYSTEM_ISCSI,
+  OPCODE_COMMON_ISCSI_CLEANUP, sizeof(*req));
+
+   /**
+   * TODO: Check with FW folks the chute value to be set.
+   * For now, use the ULP_MASK as the chute value.
+   */
+   if (is_chip_be2_be3r(phba)) {
+   req->chute = (1 << ulp);
+   req->hdr_ring_id = HWI_GET_DEF_HDRQ_ID(phba, ulp);
+   req->data_ring_id = HWI_GET_DEF_BUFQ_ID(phba, ulp);
+   } else {
+   req_v1 = (struct iscsi_cleanup_req_v1 *)req;
+   req_v1->hdr.version = 1;
+   req_v1->hdr_ring_id = cpu_to_le16(HWI_GET_DEF_HDRQ_ID(phba,
+ ulp));
+   req_v1->data_ring_id = cpu_to_le16(HWI_GET_DEF_BUFQ_ID(phba,
+  ulp));
+   }
+
+   status = be_mbox_notify(ctrl);
+   if (status)
+   beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT,
+   "BG_%d : %s failed %d\n", __func__, ulp);
+   mutex_unlock(>mbox_lock);
+   return status;
+}
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 47b7197..cf42399 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -768,6 +768,8 @@ int beiscsi_check_fw_rdy(struct beiscsi_hba *phba);
 
 int beiscsi_init_sliport(struct beiscsi_hba *phba);
 
+int beiscsi_cmd_iscsi_cleanup(struct beiscsi_hba *phba, unsigned short 
ulp_num);
+
 int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
  struct be_queue_info *eq, int eq_delay);
 

[PATCH v2 19/29] be2iscsi: Fix POST check and reset sequence

2016-08-19 Thread Jitendra Bhivare
SLIPORT FUNCTION_RESET does not reset the chip.
So POST status needs to be checked before issuing FUNCTION_RESET.
The completion of FUNCTION_RESET is indicated in BMBX Rdy bit.

be_cmd_fw_initialize too needs to be done before issuing any cmd to FW.
be_cmd_fw_initialize is renamed as beiscsi_cmd_special_wrb.
Rearrange and rename few functions in init and cleanup path.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_cmds.c | 250 +++-
 drivers/scsi/be2iscsi/be_cmds.h |  38 +++---
 drivers/scsi/be2iscsi/be_main.c |  64 --
 drivers/scsi/be2iscsi/be_main.h |   8 --
 4 files changed, 164 insertions(+), 196 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 1ebb6ce..771670c 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -21,35 +21,6 @@
 #include "be.h"
 #include "be_mgmt.h"
 
-int be_chk_reset_complete(struct beiscsi_hba *phba)
-{
-   unsigned int num_loop;
-   u8 *mpu_sem = 0;
-   u32 status;
-
-   num_loop = 1000;
-   mpu_sem = (u8 *)phba->csr_va + MPU_EP_SEMAPHORE;
-   msleep(5000);
-
-   while (num_loop) {
-   status = readl((void *)mpu_sem);
-
-   if ((status & 0x8000) || (status & 0x) == 0xC000)
-   break;
-   msleep(60);
-   num_loop--;
-   }
-
-   if ((status & 0x8000) || (!num_loop)) {
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
-   "BC_%d : Failed in be_chk_reset_complete"
-   "status = 0x%x\n", status);
-   return -EIO;
-   }
-
-   return 0;
-}
-
 struct be_mcc_wrb *alloc_mcc_wrb(struct beiscsi_hba *phba,
 unsigned int *ref_tag)
 {
@@ -769,87 +740,6 @@ int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
return status;
 }
 
-/**
- * be_cmd_fw_initialize()- Initialize FW
- * @ctrl: Pointer to function control structure
- *
- * Send FW initialize pattern for the function.
- *
- * return
- * Success: 0
- * Failure: Non-Zero value
- **/
-int be_cmd_fw_initialize(struct be_ctrl_info *ctrl)
-{
-   struct be_mcc_wrb *wrb = wrb_from_mbox(>mbox_mem);
-   struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev);
-   int status;
-   u8 *endian_check;
-
-   mutex_lock(>mbox_lock);
-   memset(wrb, 0, sizeof(*wrb));
-
-   endian_check = (u8 *) wrb;
-   *endian_check++ = 0xFF;
-   *endian_check++ = 0x12;
-   *endian_check++ = 0x34;
-   *endian_check++ = 0xFF;
-   *endian_check++ = 0xFF;
-   *endian_check++ = 0x56;
-   *endian_check++ = 0x78;
-   *endian_check++ = 0xFF;
-   be_dws_cpu_to_le(wrb, sizeof(*wrb));
-
-   status = be_mbox_notify(ctrl);
-   if (status)
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
-   "BC_%d : be_cmd_fw_initialize Failed\n");
-
-   mutex_unlock(>mbox_lock);
-   return status;
-}
-
-/**
- * be_cmd_fw_uninit()- Uinitialize FW
- * @ctrl: Pointer to function control structure
- *
- * Send FW uninitialize pattern for the function
- *
- * return
- * Success: 0
- * Failure: Non-Zero value
- **/
-int be_cmd_fw_uninit(struct be_ctrl_info *ctrl)
-{
-   struct be_mcc_wrb *wrb = wrb_from_mbox(>mbox_mem);
-   struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev);
-   int status;
-   u8 *endian_check;
-
-   mutex_lock(>mbox_lock);
-   memset(wrb, 0, sizeof(*wrb));
-
-   endian_check = (u8 *) wrb;
-   *endian_check++ = 0xFF;
-   *endian_check++ = 0xAA;
-   *endian_check++ = 0xBB;
-   *endian_check++ = 0xFF;
-   *endian_check++ = 0xFF;
-   *endian_check++ = 0xCC;
-   *endian_check++ = 0xDD;
-   *endian_check = 0xFF;
-
-   be_dws_cpu_to_le(wrb, sizeof(*wrb));
-
-   status = be_mbox_notify(ctrl);
-   if (status)
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
-   "BC_%d : be_cmd_fw_uninit Failed\n");
-
-   mutex_unlock(>mbox_lock);
-   return status;
-}
-
 int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
  struct be_queue_info *cq, struct be_queue_info *eq,
  bool sol_evts, bool no_delay, int coalesce_wm)
@@ -1293,25 +1183,6 @@ error:
return status;
 }
 
-int beiscsi_cmd_reset_function(struct beiscsi_hba  *phba)
-{
-   struct be_ctrl_info *ctrl = >ctrl;
-   struct be_mcc_wrb *wrb = wrb_from_mbox(>mbox_mem);
-   struct be_post_sgl_pages_req *req = embedded_payload(wrb);
-   int status;
-
-   mutex_lock(>mbox_lock);
-
-   req = embedded_payload(wrb);
-   be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
-   be_cmd_hdr_prepare(>hdr, CMD_SUBSYSTEM_COMMON,
-  OPCODE_COMMON_FUNCTION_RESET, sizeof(*req));
- 

[PATCH v2 15/29] be2iscsi: Fix to make boot discovery non-blocking

2016-08-19 Thread Jitendra Bhivare
Boot work involves:
1. Find and fetch configured boot session and its handle.
2. Attempt to open the session if its not.
3. Get the session details for boot kset creation.
4. Logout of that session owned by FW.
5. Create boot kset for session details.

All these actions were done in blocking call with retries in global wq.
Other works in wq suffered if the IOCTLs stalled or timed out.

This change moves all the boot work to make it non-blocking.
The work queued in global wq just issues the IOCTL depending on the action
to be taken and mcc wq schedules work depending on status of the IOCTL.
Initial boot_work is started on link and ASYNC event.

The other code changes move all boot related functions in one place and
follow naming conventions.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be.h  |   2 +
 drivers/scsi/be2iscsi/be_cmds.c | 161 ++-
 drivers/scsi/be2iscsi/be_cmds.h |  18 +-
 drivers/scsi/be2iscsi/be_main.c | 608 +++-
 drivers/scsi/be2iscsi/be_main.h |  33 ++-
 drivers/scsi/be2iscsi/be_mgmt.c | 537 +++
 drivers/scsi/be2iscsi/be_mgmt.h |  23 +-
 7 files changed, 725 insertions(+), 657 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index 621291a..454002d 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -113,6 +113,8 @@ struct beiscsi_mcc_tag_state {
unsigned long tag_state;
 #define MCC_TAG_STATE_RUNNING  1
 #define MCC_TAG_STATE_TIMEOUT  2
+#define MCC_TAG_STATE_ASYNC3
+   void (*cbfn)(struct beiscsi_hba *, unsigned int);
struct be_dma_mem tag_mem_state;
 };
 
diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index f16de6c..27d10ce 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -84,6 +84,7 @@ struct be_mcc_wrb *alloc_mcc_wrb(struct beiscsi_hba *phba,
phba->ctrl.mcc_tag[phba->ctrl.mcc_alloc_index] = 0;
phba->ctrl.mcc_tag_status[tag] = 0;
phba->ctrl.ptag_state[tag].tag_state = 0;
+   phba->ctrl.ptag_state[tag].cbfn = NULL;
phba->ctrl.mcc_tag_available--;
if (phba->ctrl.mcc_alloc_index == (MAX_MCC_CMD - 1))
phba->ctrl.mcc_alloc_index = 0;
@@ -128,6 +129,70 @@ void beiscsi_fail_session(struct iscsi_cls_session 
*cls_session)
 }
 
 /*
+ * beiscsi_mcc_compl_status - Return the status of MCC completion
+ * @phba: Driver private structure
+ * @tag: Tag for the MBX Command
+ * @wrb: the WRB used for the MBX Command
+ * @mbx_cmd_mem: ptr to memory allocated for MBX Cmd
+ *
+ * return
+ * Success: 0
+ * Failure: Non-Zero
+ */
+int __beiscsi_mcc_compl_status(struct beiscsi_hba *phba,
+  unsigned int tag,
+  struct be_mcc_wrb **wrb,
+  struct be_dma_mem *mbx_cmd_mem)
+{
+   struct be_queue_info *mccq = >ctrl.mcc_obj.q;
+   uint16_t status = 0, addl_status = 0, wrb_num = 0;
+   struct be_cmd_resp_hdr *mbx_resp_hdr;
+   struct be_cmd_req_hdr *mbx_hdr;
+   struct be_mcc_wrb *temp_wrb;
+   uint32_t mcc_tag_status;
+   int rc = 0;
+
+   mcc_tag_status = phba->ctrl.mcc_tag_status[tag];
+   status = (mcc_tag_status & CQE_STATUS_MASK);
+   addl_status = ((mcc_tag_status & CQE_STATUS_ADDL_MASK) >>
+   CQE_STATUS_ADDL_SHIFT);
+
+   if (mbx_cmd_mem) {
+   mbx_hdr = (struct be_cmd_req_hdr *)mbx_cmd_mem->va;
+   } else {
+   wrb_num = (mcc_tag_status & CQE_STATUS_WRB_MASK) >>
+ CQE_STATUS_WRB_SHIFT;
+   temp_wrb = (struct be_mcc_wrb *)queue_get_wrb(mccq, wrb_num);
+   mbx_hdr = embedded_payload(temp_wrb);
+
+   if (wrb)
+   *wrb = temp_wrb;
+   }
+
+   if (status || addl_status) {
+   beiscsi_log(phba, KERN_WARNING,
+   BEISCSI_LOG_INIT | BEISCSI_LOG_EH |
+   BEISCSI_LOG_CONFIG,
+   "BC_%d : MBX Cmd Failed for Subsys : %d Opcode : %d 
with Status : %d and Extd_Status : %d\n",
+   mbx_hdr->subsystem, mbx_hdr->opcode,
+   status, addl_status);
+   rc = -EIO;
+   if (status == MCC_STATUS_INSUFFICIENT_BUFFER) {
+   mbx_resp_hdr = (struct be_cmd_resp_hdr *)mbx_hdr;
+   beiscsi_log(phba, KERN_WARNING,
+   BEISCSI_LOG_INIT | BEISCSI_LOG_EH |
+   BEISCSI_LOG_CONFIG,
+   "BC_%d : Insufficient Buffer Error Resp_Len 
: %d Actual_Resp_Len : %d\n",
+   mbx_resp_hdr->response_length,
+   mbx_resp_hdr->actual_resp_len);
+   rc = 

[PATCH v2 25/29] be2iscsi: Fix bad WRB index error

2016-08-19 Thread Jitendra Bhivare
In very rare scenario, connection gets killed after throwing this error:
scsi host0: BM_2312 : Event CXN_KILLED_BAD_WRB_INDEX_ERROR[15]... CID : 4
connection1:0: detected conn error (1011)

memset ISCSI_WRB descriptor to zero for all allocations of WRB handle.

Signed-off-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be_main.c | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 5024651..50d865e 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -967,6 +967,7 @@ beiscsi_get_wrb_handle(struct hwi_wrb_context *pwrb_context,
else
pwrb_context->alloc_index++;
spin_unlock_bh(_context->wrb_lock);
+   memset(pwrb_handle->pwrb, 0, sizeof(*pwrb_handle->pwrb));
 
return pwrb_handle;
 }
@@ -1209,11 +1210,10 @@ hwi_complete_drvr_msgs(struct beiscsi_conn 
*beiscsi_conn,
   struct beiscsi_hba *phba, struct sol_cqe *psol)
 {
struct hwi_wrb_context *pwrb_context;
-   struct wrb_handle *pwrb_handle = NULL;
+   uint16_t wrb_index, cid, cri_index;
struct hwi_controller *phwi_ctrlr;
+   struct wrb_handle *pwrb_handle;
struct iscsi_task *task;
-   struct beiscsi_io_task *io_task;
-   uint16_t wrb_index, cid, cri_index;
 
phwi_ctrlr = phba->phwi_ctrlr;
if (is_chip_be2_be3r(phba)) {
@@ -1232,9 +1232,6 @@ hwi_complete_drvr_msgs(struct beiscsi_conn *beiscsi_conn,
pwrb_context = _ctrlr->wrb_context[cri_index];
pwrb_handle = pwrb_context->pwrb_handle_basestd[wrb_index];
task = pwrb_handle->pio_handle;
-
-   io_task = task->dd_data;
-   memset(io_task->pwrb_handle->pwrb, 0, sizeof(struct iscsi_wrb));
iscsi_put_task(task);
 }
 
@@ -4295,16 +4292,12 @@ beiscsi_free_mgmt_task_handles(struct beiscsi_conn 
*beiscsi_conn,
io_task = task->dd_data;
 
if (io_task->pwrb_handle) {
-   memset(io_task->pwrb_handle->pwrb, 0,
-  sizeof(struct iscsi_wrb));
-   free_wrb_handle(phba, pwrb_context,
-   io_task->pwrb_handle);
+   free_wrb_handle(phba, pwrb_context, io_task->pwrb_handle);
io_task->pwrb_handle = NULL;
}
 
if (io_task->psgl_handle) {
-   free_mgmt_sgl_handle(phba,
-io_task->psgl_handle);
+   free_mgmt_sgl_handle(phba, io_task->psgl_handle);
io_task->psgl_handle = NULL;
}
 
@@ -4341,6 +4334,7 @@ static void beiscsi_cleanup_task(struct iscsi_task *task)
pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs,
  io_task->bhs_pa.u.a64.address);
io_task->cmd_bhs = NULL;
+   task->hdr = NULL;
}
 
if (task->sc) {
-- 
1.9.1

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


[PATCH v2 08/29] be2iscsi: Update iface handle before any set param

2016-08-19 Thread Jitendra Bhivare
Move mgmt_get_all_if_id before any set param operation.
Rename mgmt_get_all_if_id to beiscsi_if_get_handle.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_iscsi.c | 29 +++---
 drivers/scsi/be2iscsi/be_main.c  | 30 +++
 drivers/scsi/be2iscsi/be_mgmt.c  | 81 
 drivers/scsi/be2iscsi/be_mgmt.h  |  2 +-
 4 files changed, 61 insertions(+), 81 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index b725536..1418d6b 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -319,17 +319,8 @@ beiscsi_iface_config_vlan(struct Scsi_Host *shost,
  struct iscsi_iface_param_info *iface_param)
 {
struct beiscsi_hba *phba = iscsi_host_priv(shost);
-   int ret;
-
-   /* Get the Interface Handle */
-   ret = mgmt_get_all_if_id(phba);
-   if (ret) {
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
-   "BS_%d : Getting Interface Handle Failed\n");
-   return ret;
-   }
+   int ret = -EPERM;
 
-   ret = -EPERM;
switch (iface_param->param) {
case ISCSI_NET_PARAM_VLAN_ENABLED:
ret = 0;
@@ -440,7 +431,7 @@ int be2iscsi_iface_set_param(struct Scsi_Host *shost,
struct beiscsi_hba *phba = iscsi_host_priv(shost);
struct nlattr *attrib;
uint32_t rm_len = dt_len;
-   int ret = 0 ;
+   int ret;
 
if (phba->state & BE_ADAPTER_PCI_ERR) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
@@ -448,6 +439,14 @@ int be2iscsi_iface_set_param(struct Scsi_Host *shost,
return -EBUSY;
}
 
+   /* update interface_handle */
+   ret = beiscsi_if_get_handle(phba);
+   if (ret) {
+   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
+   "BS_%d : Getting Interface Handle Failed\n");
+   return ret;
+   }
+
nla_for_each_attr(attrib, data, dt_len, rm_len) {
iface_param = nla_data(attrib);
 
@@ -573,7 +572,7 @@ int be2iscsi_iface_get_param(struct iscsi_iface *iface,
struct Scsi_Host *shost = iscsi_iface_to_shost(iface);
struct beiscsi_hba *phba = iscsi_host_priv(shost);
struct be_cmd_get_def_gateway_resp gateway;
-   int len = -ENOSYS;
+   int len = -EPERM;
 
if (phba->state & BE_ADAPTER_PCI_ERR) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
@@ -605,8 +604,6 @@ int be2iscsi_iface_get_param(struct iscsi_iface *iface,
if (!len)
len = sprintf(buf, "%pI4\n", _addr.addr);
break;
-   default:
-   len = -ENOSYS;
}
 
return len;
@@ -624,7 +621,7 @@ int beiscsi_ep_get_param(struct iscsi_endpoint *ep,
   enum iscsi_param param, char *buf)
 {
struct beiscsi_endpoint *beiscsi_ep = ep->dd_data;
-   int len = 0;
+   int len;
 
beiscsi_log(beiscsi_ep->phba, KERN_INFO,
BEISCSI_LOG_CONFIG,
@@ -642,7 +639,7 @@ int beiscsi_ep_get_param(struct iscsi_endpoint *ep,
len = sprintf(buf, "%pI6\n", _ep->dst6_addr);
break;
default:
-   return -ENOSYS;
+   len = -EPERM;
}
return len;
 }
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index f05e773..01052d3 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -380,7 +380,7 @@ static ssize_t beiscsi_show_boot_tgt_info(void *data, int 
type, char *buf)
struct mgmt_session_info *boot_sess = >boot_sess;
struct mgmt_conn_info *boot_conn = _sess->conn_list[0];
char *str = buf;
-   int rc;
+   int rc = -EPERM;
 
switch (type) {
case ISCSI_BOOT_TGT_NAME:
@@ -434,9 +434,6 @@ static ssize_t beiscsi_show_boot_tgt_info(void *data, int 
type, char *buf)
case ISCSI_BOOT_TGT_NIC_ASSOC:
rc = sprintf(str, "0\n");
break;
-   default:
-   rc = -ENOSYS;
-   break;
}
return rc;
 }
@@ -445,15 +442,12 @@ static ssize_t beiscsi_show_boot_ini_info(void *data, int 
type, char *buf)
 {
struct beiscsi_hba *phba = data;
char *str = buf;
-   int rc;
+   int rc = -EPERM;
 
switch (type) {
case ISCSI_BOOT_INI_INITIATOR_NAME:
rc = sprintf(str, "%s\n", phba->boot_sess.initiator_iscsiname);
break;
-   default:
-   rc = -ENOSYS;
-   break;
}
return rc;
 }
@@ -462,7 +456,7 @@ static ssize_t beiscsi_show_boot_eth_info(void *data, int 
type, char *buf)
 {
struct beiscsi_hba *phba = data;
char *str = buf;
-   int rc;
+   

[PATCH v2 29/29] MAINTAINERS: Update be2iscsi contact info

2016-08-19 Thread Jitendra Bhivare
Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 MAINTAINERS | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 5f50224..fec431c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10562,12 +10562,12 @@ S:Maintained
 F: drivers/misc/phantom.c
 F: include/uapi/linux/phantom.h
 
-SERVER ENGINES 10Gbps iSCSI - BladeEngine 2 DRIVER
-M: Jayamohan Kallickal 
-M: Ketan Mukadam 
-M: John Soni Jose 
+Emulex 10Gbps iSCSI - OneConnect DRIVER
+M: Subbu Seetharaman 
+M: Ketan Mukadam 
+M: Jitendra Bhivare 
 L: linux-scsi@vger.kernel.org
-W: http://www.avagotech.com
+W: http://www.broadcom.com
 S: Supported
 F: drivers/scsi/be2iscsi/
 
-- 
1.9.1

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


[PATCH v2 18/29] be2iscsi: Move functions to right files

2016-08-19 Thread Jitendra Bhivare
beiscsi_fail_session is defined in be_cmds.c: move it to be_iscsi.c
Move card configuration commands to be_cmds.c.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_cmds.c  | 274 +--
 drivers/scsi/be2iscsi/be_cmds.h  |  20 +--
 drivers/scsi/be2iscsi/be_iscsi.c |  10 ++
 drivers/scsi/be2iscsi/be_iscsi.h |   2 +
 drivers/scsi/be2iscsi/be_main.c  |   6 +-
 drivers/scsi/be2iscsi/be_mgmt.c  | 261 -
 drivers/scsi/be2iscsi/be_mgmt.h  |  15 +--
 7 files changed, 293 insertions(+), 295 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index a246abe..1ebb6ce 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -119,15 +119,6 @@ void free_mcc_wrb(struct be_ctrl_info *ctrl, unsigned int 
tag)
spin_unlock(>mcc_lock);
 }
 
-/**
- * beiscsi_fail_session(): Closing session with appropriate error
- * @cls_session: ptr to session
- **/
-void beiscsi_fail_session(struct iscsi_cls_session *cls_session)
-{
-   iscsi_session_failure(cls_session->dd_data, ISCSI_ERR_CONN_FAILED);
-}
-
 /*
  * beiscsi_mcc_compl_status - Return the status of MCC completion
  * @phba: Driver private structure
@@ -342,7 +333,7 @@ static void beiscsi_process_async_link(struct beiscsi_hba 
*phba,
  "BC_%d : Link Down on Port %d tag 0x%x\n",
  evt->physical_port, evt->event_tag);
iscsi_host_for_each_session(phba->shost,
-   beiscsi_fail_session);
+   beiscsi_session_fail);
}
 }
 
@@ -638,7 +629,7 @@ static int be_mbox_db_ready_poll(struct be_ctrl_info *ctrl)
  * Success: 0
  * Failure: Non-Zero
  **/
-int be_mbox_notify(struct be_ctrl_info *ctrl)
+static int be_mbox_notify(struct be_ctrl_info *ctrl)
 {
int status;
u32 val = 0;
@@ -1362,6 +1353,267 @@ int be_cmd_set_vlan(struct beiscsi_hba *phba,
return tag;
 }
 
+int beiscsi_check_supported_fw(struct be_ctrl_info *ctrl,
+  struct beiscsi_hba *phba)
+{
+   struct be_dma_mem nonemb_cmd;
+   struct be_mcc_wrb *wrb = wrb_from_mbox(>mbox_mem);
+   struct be_mgmt_controller_attributes *req;
+   struct be_sge *sge = nonembedded_sgl(wrb);
+   int status = 0;
+
+   nonemb_cmd.va = pci_alloc_consistent(ctrl->pdev,
+   sizeof(struct be_mgmt_controller_attributes),
+   _cmd.dma);
+   if (nonemb_cmd.va == NULL) {
+   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
+   "BG_%d : pci_alloc_consistent failed in %s\n",
+   __func__);
+   return -ENOMEM;
+   }
+   nonemb_cmd.size = sizeof(struct be_mgmt_controller_attributes);
+   req = nonemb_cmd.va;
+   memset(req, 0, sizeof(*req));
+   mutex_lock(>mbox_lock);
+   memset(wrb, 0, sizeof(*wrb));
+   be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1);
+   be_cmd_hdr_prepare(>hdr, CMD_SUBSYSTEM_COMMON,
+  OPCODE_COMMON_GET_CNTL_ATTRIBUTES, sizeof(*req));
+   sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd.dma));
+   sge->pa_lo = cpu_to_le32(nonemb_cmd.dma & 0x);
+   sge->len = cpu_to_le32(nonemb_cmd.size);
+   status = be_mbox_notify(ctrl);
+   if (!status) {
+   struct be_mgmt_controller_attributes_resp *resp = nonemb_cmd.va;
+
+   beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
+   "BG_%d : Firmware Version of CMD : %s\n"
+   "Firmware Version is : %s\n"
+   "Developer Build, not performing version 
check...\n",
+   resp->params.hba_attribs
+   .flashrom_version_string,
+   resp->params.hba_attribs.
+   firmware_version_string);
+
+   phba->fw_config.iscsi_features =
+   resp->params.hba_attribs.iscsi_features;
+   beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
+   "BM_%d : phba->fw_config.iscsi_features = %d\n",
+   phba->fw_config.iscsi_features);
+   memcpy(phba->fw_ver_str, resp->params.hba_attribs.
+  firmware_version_string, BEISCSI_VER_STRLEN);
+   } else
+   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
+   "BG_%d :  Failed in beiscsi_check_supported_fw\n");
+   mutex_unlock(>mbox_lock);
+   if (nonemb_cmd.va)
+   pci_free_consistent(ctrl->pdev, nonemb_cmd.size,
+   nonemb_cmd.va, nonemb_cmd.dma);
+
+   return status;
+}
+
+/**
+ * beiscsi_get_fw_config()- Get the FW 

[PATCH v2 24/29] be2iscsi: Fix async PDU handling path

2016-08-19 Thread Jitendra Bhivare
BUG: unable to handle kernel NULL pointer dereference at 015e
IP: []
hwi_get_async_handle.isra.23.constprop.39+0x90/0x1d0 [be2iscsi]
PGD 0
Oops:  [#1] SMP
...
Call Trace:
 
 [] hwi_process_default_pdu_ring+0x7c/0x280 [be2iscsi]
 [] beiscsi_process_cq+0x321/0xb90 [be2iscsi]
 [] ? __wake_up_common+0x58/0x90
 [] ? __wake_up+0x44/0x50
 [] be_iopoll+0x1d/0xb0 [be2iscsi]
 [] blk_iopoll_softirq+0xc1/0x100
 [] __do_softirq+0xef/0x280

The symptom observed is multiple async handles get queued for same index
thus causing leak in buffers posted to FW.

The root cause is:
- async handle is continued to be used even if it does not match the
completion.
- list_move operation done on already filled index.

1. Remove use of writables, host_write_ptr and ep_read_ptr.
2. Remove consumed logic to update writables. Instead, use only
free_entries to do the accounting of handles to be posted back.
3. Remove busy_list, instead use simple slot to index handles.
4. Added check no data, header less and overflow to make sure
all async_handles are flushed in error cases.
5. Added code to verify gathering of handles to form PDU by
checking final bit before forwarding PDU.
6. Added code to catch mismatch with CQE and handle gracefully.
7. Use AMAP, traverse cri_wait_queue list to post buffers, log
"async PDU" related errors.
8. Rearranged few data structures and added comments in init &
processing path.
9. Added WARN_ONs to catch any HD ring corruption.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_main.c | 842 +++-
 drivers/scsi/be2iscsi/be_main.h | 124 +++---
 2 files changed, 461 insertions(+), 505 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 3aa2f04..5024651 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -897,57 +897,6 @@ void hwi_ring_cq_db(struct beiscsi_hba *phba,
iowrite32(val, phba->db_va + DB_CQ_OFFSET);
 }
 
-static unsigned int
-beiscsi_process_async_pdu(struct beiscsi_conn *beiscsi_conn,
- struct beiscsi_hba *phba,
- struct pdu_base *ppdu,
- unsigned long pdu_len,
- void *pbuffer, unsigned long buf_len)
-{
-   struct iscsi_conn *conn = beiscsi_conn->conn;
-   struct iscsi_session *session = conn->session;
-   struct iscsi_task *task;
-   struct beiscsi_io_task *io_task;
-   struct iscsi_hdr *login_hdr;
-
-   switch (ppdu->dw[offsetof(struct amap_pdu_base, opcode) / 32] &
-   PDUBASE_OPCODE_MASK) {
-   case ISCSI_OP_NOOP_IN:
-   pbuffer = NULL;
-   buf_len = 0;
-   break;
-   case ISCSI_OP_ASYNC_EVENT:
-   break;
-   case ISCSI_OP_REJECT:
-   WARN_ON(!pbuffer);
-   WARN_ON(!(buf_len == 48));
-   beiscsi_log(phba, KERN_ERR,
-   BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO,
-   "BM_%d : In ISCSI_OP_REJECT\n");
-   break;
-   case ISCSI_OP_LOGIN_RSP:
-   case ISCSI_OP_TEXT_RSP:
-   task = conn->login_task;
-   io_task = task->dd_data;
-   login_hdr = (struct iscsi_hdr *)ppdu;
-   login_hdr->itt = io_task->libiscsi_itt;
-   break;
-   default:
-   beiscsi_log(phba, KERN_WARNING,
-   BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG,
-   "BM_%d : Unrecognized opcode 0x%x in async msg\n",
-   (ppdu->
-dw[offsetof(struct amap_pdu_base, opcode) / 32]
-& PDUBASE_OPCODE_MASK));
-   return 1;
-   }
-
-   spin_lock_bh(>back_lock);
-   __iscsi_complete_pdu(conn, (struct iscsi_hdr *)ppdu, pbuffer, buf_len);
-   spin_unlock_bh(>back_lock);
-   return 0;
-}
-
 static struct sgl_handle *alloc_io_sgl_handle(struct beiscsi_hba *phba)
 {
struct sgl_handle *psgl_handle;
@@ -1434,431 +1383,428 @@ static void hwi_complete_cmd(struct beiscsi_conn 
*beiscsi_conn,
spin_unlock_bh(>back_lock);
 }
 
-static struct list_head *hwi_get_async_busy_list(struct hwi_async_pdu_context
- *pasync_ctx, unsigned int is_header,
- unsigned int host_write_ptr)
+/**
+ * ASYNC PDUs include
+ * a. Unsolicited NOP-In (target initiated NOP-In)
+ * b. ASYNC Messages
+ * c. Reject PDU
+ * d. Login response
+ * These headers arrive unprocessed by the EP firmware.
+ * iSCSI layer processes them.
+ */
+static unsigned int
+beiscsi_complete_pdu(struct beiscsi_conn *beiscsi_conn,
+   struct pdu_base *phdr, void *pdata, unsigned int dlen)
 {
-   if (is_header)
-   return 

[PATCH v2 21/29] be2iscsi: Add TPE recovery feature

2016-08-19 Thread Jitendra Bhivare
After UE is detected, check for recoverable error by reading
SLIPORT SEMAPHORE register. If transient parity error i.e. 0xExxx
then schedule recovery work on driver wq.

FLag this error to prevent any transactions for the duration of ue2rp to
restart polling. After that, if FW becomes ready then recover port.

Wake up processes in wq before going offline.
Wait for process to execute before cleaning up.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_cmds.c  | 173 -
 drivers/scsi/be2iscsi/be_cmds.h  |   4 +
 drivers/scsi/be2iscsi/be_iscsi.c |  14 +-
 drivers/scsi/be2iscsi/be_main.c  | 739 +++
 drivers/scsi/be2iscsi/be_main.h  |   6 +-
 drivers/scsi/be2iscsi/be_mgmt.c  | 128 ---
 drivers/scsi/be2iscsi/be_mgmt.h  |   1 -
 7 files changed, 632 insertions(+), 433 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 6f3cd82..ad7405d 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -21,6 +21,78 @@
 #include "be.h"
 #include "be_mgmt.h"
 
+/* UE Status Low CSR */
+static const char * const desc_ue_status_low[] = {
+   "CEV",
+   "CTX",
+   "DBUF",
+   "ERX",
+   "Host",
+   "MPU",
+   "NDMA",
+   "PTC ",
+   "RDMA ",
+   "RXF ",
+   "RXIPS ",
+   "RXULP0 ",
+   "RXULP1 ",
+   "RXULP2 ",
+   "TIM ",
+   "TPOST ",
+   "TPRE ",
+   "TXIPS ",
+   "TXULP0 ",
+   "TXULP1 ",
+   "UC ",
+   "WDMA ",
+   "TXULP2 ",
+   "HOST1 ",
+   "P0_OB_LINK ",
+   "P1_OB_LINK ",
+   "HOST_GPIO ",
+   "MBOX ",
+   "AXGMAC0",
+   "AXGMAC1",
+   "JTAG",
+   "MPU_INTPEND"
+};
+
+/* UE Status High CSR */
+static const char * const desc_ue_status_hi[] = {
+   "LPCMEMHOST",
+   "MGMT_MAC",
+   "PCS0ONLINE",
+   "MPU_IRAM",
+   "PCS1ONLINE",
+   "PCTL0",
+   "PCTL1",
+   "PMEM",
+   "RR",
+   "TXPB",
+   "RXPP",
+   "XAUI",
+   "TXP",
+   "ARM",
+   "IPC",
+   "HOST2",
+   "HOST3",
+   "HOST4",
+   "HOST5",
+   "HOST6",
+   "HOST7",
+   "HOST8",
+   "HOST9",
+   "NETC",
+   "Unknown",
+   "Unknown",
+   "Unknown",
+   "Unknown",
+   "Unknown",
+   "Unknown",
+   "Unknown",
+   "Unknown"
+};
+
 struct be_mcc_wrb *alloc_mcc_wrb(struct beiscsi_hba *phba,
 unsigned int *ref_tag)
 {
@@ -185,6 +257,16 @@ int beiscsi_mccq_compl_wait(struct beiscsi_hba *phba,
  phba->ctrl.mcc_tag_status[tag],
  msecs_to_jiffies(
BEISCSI_HOST_MBX_TIMEOUT));
+   /**
+* Return EIO if port is being disabled. Associated DMA memory, if any,
+* is freed by the caller. When port goes offline, MCCQ is cleaned up
+* so does WRB.
+*/
+   if (!test_bit(BEISCSI_HBA_ONLINE, >state)) {
+   clear_bit(MCC_TAG_STATE_RUNNING,
+ >ctrl.ptag_state[tag].tag_state);
+   return -EIO;
+   }
 
/**
 * If MBOX cmd timeout expired, tag and resource allocated
@@ -538,7 +620,6 @@ static int be_mbox_db_ready_poll(struct be_ctrl_info *ctrl)
BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
"BC_%d : FW Timed Out\n");
set_bit(BEISCSI_HBA_FW_TIMEOUT, >state);
-   beiscsi_ue_detect(phba);
return -EBUSY;
 }
 
@@ -1584,6 +1665,12 @@ int beiscsi_init_sliport(struct beiscsi_hba *phba)
if (!status)
return -EIO;
 
+   /* clear all error states after checking FW rdy */
+   phba->state &= ~BEISCSI_HBA_IN_ERR;
+
+   /* check again UER support */
+   phba->state &= ~BEISCSI_HBA_UER_SUPP;
+
/*
 * SLI COMMON_FUNCTION_RESET completion is indicated by BMBX RDY bit.
 * It should clean up any stale info in FW for this fn.
@@ -1647,3 +1734,87 @@ int beiscsi_cmd_iscsi_cleanup(struct beiscsi_hba *phba, 
unsigned short ulp)
mutex_unlock(>mbox_lock);
return status;
 }
+
+/*
+ * beiscsi_detect_ue()- Detect Unrecoverable Error on adapter
+ * @phba: Driver priv structure
+ *
+ * Read registers linked to UE and check for the UE status
+ **/
+int beiscsi_detect_ue(struct beiscsi_hba *phba)
+{
+   uint32_t ue_mask_hi = 0, ue_mask_lo = 0;
+   uint32_t ue_hi = 0, ue_lo = 0;
+   uint8_t i = 0;
+   int ret = 0;
+
+   pci_read_config_dword(phba->pcidev,
+ PCICFG_UE_STATUS_LOW, _lo);
+   pci_read_config_dword(phba->pcidev,
+ PCICFG_UE_STATUS_MASK_LOW,
+ _mask_lo);
+   pci_read_config_dword(phba->pcidev,
+ 

[PATCH v2 17/29] be2iscsi: Add IOCTL to check UER supported

2016-08-19 Thread Jitendra Bhivare
BE3 and SH cards can recover from transient parity errors treated
earlier as unrecoverable errors.

Add IOCTL to query FW support for this feature.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_cmds.c | 58 +++--
 drivers/scsi/be2iscsi/be_cmds.h | 34 
 drivers/scsi/be2iscsi/be_main.c |  1 +
 drivers/scsi/be2iscsi/be_main.h | 13 ++---
 drivers/scsi/be2iscsi/be_mgmt.c |  2 +-
 5 files changed, 89 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 7cb009e..a246abe 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -277,11 +277,10 @@ int beiscsi_mccq_compl_wait(struct beiscsi_hba *phba,
 static int beiscsi_process_mbox_compl(struct be_ctrl_info *ctrl,
  struct be_mcc_compl *compl)
 {
-   u16 compl_status, extd_status;
struct be_mcc_wrb *wrb = wrb_from_mbox(>mbox_mem);
struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev);
struct be_cmd_req_hdr *hdr = embedded_payload(wrb);
-   struct be_cmd_resp_hdr *resp_hdr;
+   u16 compl_status, extd_status;
 
/**
 * To check if valid bit is set, check the entire word as we don't know
@@ -315,14 +314,7 @@ static int beiscsi_process_mbox_compl(struct be_ctrl_info 
*ctrl,
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
"BC_%d : error in cmd completion: Subsystem : %d Opcode : 
%d status(compl/extd)=%d/%d\n",
hdr->subsystem, hdr->opcode, compl_status, extd_status);
-
-   if (compl_status == MCC_STATUS_INSUFFICIENT_BUFFER) {
-   /* if status is insufficient buffer, check the length */
-   resp_hdr = (struct be_cmd_resp_hdr *) hdr;
-   if (resp_hdr->response_length)
-   return 0;
-   }
-   return -EINVAL;
+   return compl_status;
 }
 
 static void beiscsi_process_async_link(struct beiscsi_hba *phba,
@@ -507,10 +499,8 @@ int beiscsi_process_mcc_compl(struct be_ctrl_info *ctrl,
if (ctrl->ptag_state[tag].cbfn)
ctrl->ptag_state[tag].cbfn(phba, tag);
else
-   beiscsi_log(phba, KERN_ERR,
-   BEISCSI_LOG_MBOX | BEISCSI_LOG_INIT |
-   BEISCSI_LOG_CONFIG,
-   "BC_%d : MBX ASYNC command with no 
callback\n");
+   __beiscsi_log(phba, KERN_ERR,
+ "BC_%d : MBX ASYNC command with no 
callback\n");
free_mcc_wrb(ctrl, tag);
return 0;
}
@@ -1371,3 +1361,43 @@ int be_cmd_set_vlan(struct beiscsi_hba *phba,
 
return tag;
 }
+
+int beiscsi_set_uer_feature(struct beiscsi_hba *phba)
+{
+   struct be_ctrl_info *ctrl = >ctrl;
+   struct be_cmd_set_features *ioctl;
+   struct be_mcc_wrb *wrb;
+   int ret = 0;
+
+   mutex_lock(>mbox_lock);
+   wrb = wrb_from_mbox(>mbox_mem);
+   memset(wrb, 0, sizeof(*wrb));
+   ioctl = embedded_payload(wrb);
+
+   be_wrb_hdr_prepare(wrb, sizeof(*ioctl), true, 0);
+   be_cmd_hdr_prepare(>h.req_hdr, CMD_SUBSYSTEM_COMMON,
+  OPCODE_COMMON_SET_FEATURES,
+  EMBED_MBX_MAX_PAYLOAD_SIZE);
+   ioctl->feature = BE_CMD_SET_FEATURE_UER;
+   ioctl->param_len = sizeof(ioctl->param.req);
+   ioctl->param.req.uer = BE_CMD_UER_SUPP_BIT;
+   ret = be_mbox_notify(ctrl);
+   if (!ret) {
+   phba->ue2rp = ioctl->param.resp.ue2rp;
+   set_bit(BEISCSI_HBA_UER_SUPP, >state);
+   beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
+   "BG_%d : HBA error recovery supported\n");
+   } else {
+   /**
+* Check "MCC_STATUS_INVALID_LENGTH" for SKH.
+* Older FW versions return this error.
+*/
+   if (ret == MCC_STATUS_ILLEGAL_REQUEST ||
+   ret == MCC_STATUS_INVALID_LENGTH)
+   __beiscsi_log(phba, KERN_INFO,
+ "BG_%d : HBA error recovery not 
supported\n");
+   }
+
+   mutex_unlock(>mbox_lock);
+   return ret;
+}
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 6fb9673..f1356c9 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -57,6 +57,7 @@ struct be_mcc_wrb {
 #define MCC_STATUS_ILLEGAL_REQUEST 0x2
 #define MCC_STATUS_ILLEGAL_FIELD 0x3
 #define MCC_STATUS_INSUFFICIENT_BUFFER 0x4
+#define MCC_STATUS_INVALID_LENGTH 0x74
 
 #define CQE_STATUS_COMPL_MASK  0x
 #define CQE_STATUS_COMPL_SHIFT 0   /* bits 0 - 15 */
@@ -217,6 +218,7 @@ struct be_mcc_mailbox 

[PATCH v2 11/29] be2iscsi: Check all zeroes IP before issuing IOCTL

2016-08-19 Thread Jitendra Bhivare
Redefine FW IP types.
Before issuing IOCTL to clear IP, check if IP is all zeroes.
All zeroes IP implies IP is not set in FW so FW fails that IOCTL.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_cmds.h  |  8 +
 drivers/scsi/be2iscsi/be_iscsi.c | 27 ---
 drivers/scsi/be2iscsi/be_iscsi.h |  7 
 drivers/scsi/be2iscsi/be_main.c  |  2 +-
 drivers/scsi/be2iscsi/be_mgmt.c  | 72 +---
 5 files changed, 69 insertions(+), 47 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index deeb951..a4bc83c 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -365,6 +365,14 @@ struct ip_addr_format {
u16 size_of_structure;
u8 reserved;
u8 ip_type;
+#define BEISCSI_IP_TYPE_V4 0x1
+#define BEISCSI_IP_TYPE_STATIC_V4  0x3
+#define BEISCSI_IP_TYPE_DHCP_V40x5
+/* type v4 values < type v6 values */
+#define BEISCSI_IP_TYPE_V6 0x10
+#define BEISCSI_IP_TYPE_ROUTABLE_V60x30
+#define BEISCSI_IP_TYPE_LINK_LOCAL_V6  0x50
+#define BEISCSI_IP_TYPE_AUTO_V60x90
u8 addr[16];
u32 rsvd0;
 } __packed;
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index fa415c4..faa37f6 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -279,12 +279,12 @@ void beiscsi_iface_create_default(struct beiscsi_hba 
*phba)
 {
struct be_cmd_get_if_info_resp *if_info;
 
-   if (!beiscsi_if_get_info(phba, BE2_IPV4, _info)) {
+   if (!beiscsi_if_get_info(phba, BEISCSI_IP_TYPE_V4, _info)) {
beiscsi_iface_create_ipv4(phba);
kfree(if_info);
}
 
-   if (!beiscsi_if_get_info(phba, BE2_IPV6, _info)) {
+   if (!beiscsi_if_get_info(phba, BEISCSI_IP_TYPE_V6, _info)) {
beiscsi_iface_create_ipv6(phba);
kfree(if_info);
}
@@ -358,14 +358,15 @@ beiscsi_iface_config_ipv4(struct Scsi_Host *shost,
break;
case ISCSI_NET_PARAM_IPV4_GW:
gw = info->value;
-   ret = beiscsi_if_set_gw(phba, BE2_IPV4, gw);
+   ret = beiscsi_if_set_gw(phba, BEISCSI_IP_TYPE_V4, gw);
break;
case ISCSI_NET_PARAM_IPV4_BOOTPROTO:
if (info->value[0] == ISCSI_BOOTPROTO_DHCP)
-   ret = beiscsi_if_en_dhcp(phba, BE2_IPV4);
+   ret = beiscsi_if_en_dhcp(phba, BEISCSI_IP_TYPE_V4);
else if (info->value[0] == ISCSI_BOOTPROTO_STATIC)
/* release DHCP IP address */
-   ret = beiscsi_if_en_static(phba, BE2_IPV4, NULL, NULL);
+   ret = beiscsi_if_en_static(phba, BEISCSI_IP_TYPE_V4,
+  NULL, NULL);
else
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BS_%d : Invalid BOOTPROTO: %d\n",
@@ -378,7 +379,8 @@ beiscsi_iface_config_ipv4(struct Scsi_Host *shost,
info = nla_data(nla);
subnet = info->value;
}
-   ret = beiscsi_if_en_static(phba, BE2_IPV4, ip, subnet);
+   ret = beiscsi_if_en_static(phba, BEISCSI_IP_TYPE_V4,
+  ip, subnet);
break;
case ISCSI_NET_PARAM_IPV4_SUBNET:
/*
@@ -391,7 +393,8 @@ beiscsi_iface_config_ipv4(struct Scsi_Host *shost,
info = nla_data(nla);
ip = info->value;
}
-   ret = beiscsi_if_en_static(phba, BE2_IPV4, ip, subnet);
+   ret = beiscsi_if_en_static(phba, BEISCSI_IP_TYPE_V4,
+  ip, subnet);
break;
}
 
@@ -416,7 +419,7 @@ beiscsi_iface_config_ipv6(struct Scsi_Host *shost,
}
break;
case ISCSI_NET_PARAM_IPV6_ADDR:
-   ret = beiscsi_if_en_static(phba, BE2_IPV6,
+   ret = beiscsi_if_en_static(phba, BEISCSI_IP_TYPE_V6,
   iface_param->value, NULL);
break;
}
@@ -511,10 +514,10 @@ static int __beiscsi_iface_get_param(struct beiscsi_hba 
*phba,
 int param, char *buf)
 {
struct be_cmd_get_if_info_resp *if_info;
-   int len, ip_type = BE2_IPV4;
+   int len, ip_type = BEISCSI_IP_TYPE_V4;
 
if (iface->iface_type == ISCSI_IFACE_TYPE_IPV6)
-   ip_type = BE2_IPV6;
+   ip_type = BEISCSI_IP_TYPE_V6;
 
len = beiscsi_if_get_info(phba, ip_type, _info);
if (len)
@@ -602,7 +605,7 @@ int beiscsi_iface_get_param(struct iscsi_iface *iface,
break;

[PATCH v2 07/29] be2iscsi: Move VLAN code to common iface_set_param

2016-08-19 Thread Jitendra Bhivare
VLAN tag is L2 construct, move VLAN code out from configuring IP.
Rearrange and rename the APIs to make it consistent.
Replace ENOSYS with EPERM.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_iscsi.c | 89 
 drivers/scsi/be2iscsi/be_mgmt.c  | 75 +
 drivers/scsi/be2iscsi/be_mgmt.h  |  2 +-
 3 files changed, 84 insertions(+), 82 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 7e17a8d..b725536 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -315,8 +315,8 @@ void beiscsi_destroy_def_ifaces(struct beiscsi_hba *phba)
  * Failure: Non-Zero Value
  **/
 static int
-beiscsi_set_vlan_tag(struct Scsi_Host *shost,
- struct iscsi_iface_param_info *iface_param)
+beiscsi_iface_config_vlan(struct Scsi_Host *shost,
+ struct iscsi_iface_param_info *iface_param)
 {
struct beiscsi_hba *phba = iscsi_host_priv(shost);
int ret;
@@ -329,20 +329,17 @@ beiscsi_set_vlan_tag(struct Scsi_Host *shost,
return ret;
}
 
+   ret = -EPERM;
switch (iface_param->param) {
case ISCSI_NET_PARAM_VLAN_ENABLED:
+   ret = 0;
if (iface_param->value[0] != ISCSI_VLAN_ENABLE)
-   ret = mgmt_set_vlan(phba, BEISCSI_VLAN_DISABLE);
+   ret = beiscsi_if_set_vlan(phba, BEISCSI_VLAN_DISABLE);
break;
case ISCSI_NET_PARAM_VLAN_TAG:
-   ret = mgmt_set_vlan(phba,
-   *((uint16_t *)iface_param->value));
+   ret = beiscsi_if_set_vlan(phba,
+ *((uint16_t *)iface_param->value));
break;
-   default:
-   beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
-   "BS_%d : Unknown Param Type : %d\n",
-   iface_param->param);
-   return -ENOSYS;
}
return ret;
 }
@@ -356,7 +353,7 @@ beiscsi_iface_config_ipv4(struct Scsi_Host *shost,
struct beiscsi_hba *phba = iscsi_host_priv(shost);
u8 *ip = NULL, *subnet = NULL, *gw;
struct nlattr *nla;
-   int ret = 0;
+   int ret = -EPERM;
 
/* Check the param */
switch (info->param) {
@@ -405,14 +402,6 @@ beiscsi_iface_config_ipv4(struct Scsi_Host *shost,
}
ret = beiscsi_if_en_static(phba, BE2_IPV4, ip, subnet);
break;
-   case ISCSI_NET_PARAM_VLAN_ENABLED:
-   case ISCSI_NET_PARAM_VLAN_TAG:
-   ret = beiscsi_set_vlan_tag(shost, info);
-   break;
-   default:
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
-   "BS_%d : Param %d not supported\n",
-   info->param);
}
 
return ret;
@@ -424,7 +413,7 @@ beiscsi_iface_config_ipv6(struct Scsi_Host *shost,
  void *data, uint32_t dt_len)
 {
struct beiscsi_hba *phba = iscsi_host_priv(shost);
-   int ret = 0;
+   int ret = -EPERM;
 
switch (iface_param->param) {
case ISCSI_NET_PARAM_IFACE_ENABLE:
@@ -439,14 +428,6 @@ beiscsi_iface_config_ipv6(struct Scsi_Host *shost,
ret = beiscsi_if_en_static(phba, BE2_IPV6,
   iface_param->value, NULL);
break;
-   case ISCSI_NET_PARAM_VLAN_ENABLED:
-   case ISCSI_NET_PARAM_VLAN_TAG:
-   ret = beiscsi_set_vlan_tag(shost, iface_param);
-   break;
-   default:
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
-   "BS_%d : Param %d not supported\n",
-   iface_param->param);
}
 
return ret;
@@ -485,24 +466,42 @@ int be2iscsi_iface_set_param(struct Scsi_Host *shost,
return -EINVAL;
}
 
-   switch (iface_param->iface_type) {
-   case ISCSI_IFACE_TYPE_IPV4:
-   ret = beiscsi_iface_config_ipv4(shost, iface_param,
-   data, dt_len);
-   break;
-   case ISCSI_IFACE_TYPE_IPV6:
-   ret = beiscsi_iface_config_ipv6(shost, iface_param,
-   data, dt_len);
+   beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
+   "BS_%d : %s.0 set param %d",
+   (iface_param->iface_type == ISCSI_IFACE_TYPE_IPV4) ?
+   "ipv4" : "ipv6", iface_param->param);
+
+   ret = -EPERM;
+   switch (iface_param->param) {
+   case ISCSI_NET_PARAM_VLAN_ENABLED:
+ 

[PATCH v2 10/29] be2iscsi: Handle only NET_PARAM in iface_get_param

2016-08-19 Thread Jitendra Bhivare
Wrong settings displayed for iface:
iface.header_digest = 192.168.197.22
iface.data_digest = 255.255.255.0
iface.immediate_data = 192.168.197.1

Process ISCSI_NET_PARAM only in beiscsi_iface_get_param.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_iscsi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 1fe273d..fa415c4 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -574,6 +574,8 @@ int beiscsi_iface_get_param(struct iscsi_iface *iface,
struct be_cmd_get_def_gateway_resp gateway;
int len = -EPERM;
 
+   if (param_type != ISCSI_NET_PARAM)
+   return 0;
if (phba->state & BE_ADAPTER_PCI_ERR) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BS_%d : In PCI_ERROR Recovery\n");
-- 
1.9.1

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


[PATCH v2 03/29] be2iscsi: Reduce driver load/unload time

2016-08-19 Thread Jitendra Bhivare
Driver takes significant time to load 1m:20s and unload 40s.

Checkpatch script threw warning:
WARNING: msleep < 20ms can sleep for up to 20ms; see
Documentation/timers/timers-howto.txt

To eliminate this warning msleep(1) was replaced with msleep(20) before
submitting.

msleep(20) in init and uninit path for creation and destroying of number
of WRBQs, CQs, and EQs is adding to load/unload time.

Replace msleep with schedule_timeout_uninterruptible of 1ms as its
enough in most cases.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_cmds.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 0ef3d5a..59b8e2d 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -655,7 +655,8 @@ static int be_mbox_db_ready_poll(struct be_ctrl_info *ctrl)
 
if (time_after(jiffies, timeout))
break;
-   msleep(20);
+   /* 1ms sleep is enough in most cases */
+   schedule_timeout_uninterruptible(msecs_to_jiffies(1));
} while (!ready);
 
beiscsi_log(phba, KERN_ERR,
-- 
1.9.1

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


[PATCH v2 12/29] be2iscsi: Remove alloc_mcc_tag & beiscsi_pci_soft_reset

2016-08-19 Thread Jitendra Bhivare
alloc_mcc_tag was replaced with alloc_mcc_wrb and is no more used.
beiscsi_pci_soft_reset is not used at all and won't be needed.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_cmds.c | 76 -
 drivers/scsi/be2iscsi/be_cmds.h |  1 -
 2 files changed, 77 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 59b8e2d..4032962 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -21,60 +21,6 @@
 #include "be.h"
 #include "be_mgmt.h"
 
-int beiscsi_pci_soft_reset(struct beiscsi_hba *phba)
-{
-   u32 sreset;
-   u8 *pci_reset_offset = 0;
-   u8 *pci_online0_offset = 0;
-   u8 *pci_online1_offset = 0;
-   u32 pconline0 = 0;
-   u32 pconline1 = 0;
-   u32 i;
-
-   pci_reset_offset = (u8 *)phba->pci_va + BE2_SOFT_RESET;
-   pci_online0_offset = (u8 *)phba->pci_va + BE2_PCI_ONLINE0;
-   pci_online1_offset = (u8 *)phba->pci_va + BE2_PCI_ONLINE1;
-   sreset = readl((void *)pci_reset_offset);
-   sreset |= BE2_SET_RESET;
-   writel(sreset, (void *)pci_reset_offset);
-
-   i = 0;
-   while (sreset & BE2_SET_RESET) {
-   if (i > 64)
-   break;
-   msleep(100);
-   sreset = readl((void *)pci_reset_offset);
-   i++;
-   }
-
-   if (sreset & BE2_SET_RESET) {
-   printk(KERN_ERR DRV_NAME
-  " Soft Reset  did not deassert\n");
-   return -EIO;
-   }
-   pconline1 = BE2_MPU_IRAM_ONLINE;
-   writel(pconline0, (void *)pci_online0_offset);
-   writel(pconline1, (void *)pci_online1_offset);
-
-   sreset |= BE2_SET_RESET;
-   writel(sreset, (void *)pci_reset_offset);
-
-   i = 0;
-   while (sreset & BE2_SET_RESET) {
-   if (i > 64)
-   break;
-   msleep(1);
-   sreset = readl((void *)pci_reset_offset);
-   i++;
-   }
-   if (sreset & BE2_SET_RESET) {
-   printk(KERN_ERR DRV_NAME
-  " MPU Online Soft Reset did not deassert\n");
-   return -EIO;
-   }
-   return 0;
-}
-
 int be_chk_reset_complete(struct beiscsi_hba *phba)
 {
unsigned int num_loop;
@@ -104,28 +50,6 @@ int be_chk_reset_complete(struct beiscsi_hba *phba)
return 0;
 }
 
-unsigned int alloc_mcc_tag(struct beiscsi_hba *phba)
-{
-   unsigned int tag = 0;
-
-   spin_lock(>ctrl.mcc_lock);
-   if (phba->ctrl.mcc_tag_available) {
-   tag = phba->ctrl.mcc_tag[phba->ctrl.mcc_alloc_index];
-   phba->ctrl.mcc_tag[phba->ctrl.mcc_alloc_index] = 0;
-   phba->ctrl.mcc_tag_status[tag] = 0;
-   phba->ctrl.ptag_state[tag].tag_state = 0;
-   }
-   if (tag) {
-   phba->ctrl.mcc_tag_available--;
-   if (phba->ctrl.mcc_alloc_index == (MAX_MCC_CMD - 1))
-   phba->ctrl.mcc_alloc_index = 0;
-   else
-   phba->ctrl.mcc_alloc_index++;
-   }
-   spin_unlock(>ctrl.mcc_lock);
-   return tag;
-}
-
 struct be_mcc_wrb *alloc_mcc_wrb(struct beiscsi_hba *phba,
 unsigned int *ref_tag)
 {
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index a4bc83c..c50b74a 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -1376,7 +1376,6 @@ struct be_cmd_get_port_name {
 * the cxn
 */
 
-int beiscsi_pci_soft_reset(struct beiscsi_hba *phba);
 int be_chk_reset_complete(struct beiscsi_hba *phba);
 
 void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
-- 
1.9.1

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


[PATCH v2 14/29] be2iscsi: Fix checks for HBA in error state

2016-08-19 Thread Jitendra Bhivare
Save ue_detected and fw_timeout errors in state field of beiscsi_hba.
BEISCSI_HBA_RUNNING
BEISCSI_HBA_LINK_UP
BEISCSI_HBA_BOOT_FOUND
BEISCSI_HBA_PCI_ERR
BEISCSI_HBA_FW_TIMEOUT
BEISCSI_HBA_IN_UE

Make sure no PCI transaction happens once in error state.
Add checks in IO path to detect HBA in error.

Skip hwi_purge_eq step which can't be done in error state.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_cmds.c  | 28 +++-
 drivers/scsi/be2iscsi/be_iscsi.c | 81 ++---
 drivers/scsi/be2iscsi/be_main.c  | 97 +++-
 drivers/scsi/be2iscsi/be_main.h  | 36 +++
 drivers/scsi/be2iscsi/be_mgmt.c  |  5 +--
 5 files changed, 134 insertions(+), 113 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 4032962..f16de6c 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -152,8 +152,11 @@ int beiscsi_mccq_compl_wait(struct beiscsi_hba *phba,
struct be_cmd_resp_hdr *mbx_resp_hdr;
struct be_queue_info *mccq = >ctrl.mcc_obj.q;
 
-   if (beiscsi_error(phba))
-   return -EPERM;
+   if (beiscsi_hba_in_error(phba)) {
+   clear_bit(MCC_TAG_STATE_RUNNING,
+ >ctrl.ptag_state[tag].tag_state);
+   return -EIO;
+   }
 
/* wait for the mccq completion */
rc = wait_event_interruptible_timeout(
@@ -315,13 +318,16 @@ static void beiscsi_process_async_link(struct beiscsi_hba 
*phba,
 * This has been newly introduced in SKH-R Firmware 10.0.338.45.
 **/
if (evt->port_link_status & BE_ASYNC_LINK_UP_MASK) {
-   phba->state = BE_ADAPTER_LINK_UP | BE_ADAPTER_CHECK_BOOT;
phba->get_boot = BE_GET_BOOT_RETRIES;
+   /* first this needs to be visible to worker thread */
+   wmb();
+   set_bit(BEISCSI_HBA_LINK_UP | BEISCSI_HBA_BOOT_FOUND,
+   >state);
__beiscsi_log(phba, KERN_ERR,
  "BC_%d : Link Up on Port %d tag 0x%x\n",
  evt->physical_port, evt->event_tag);
} else {
-   phba->state = BE_ADAPTER_LINK_DOWN;
+   clear_bit(BEISCSI_HBA_LINK_UP, >state);
__beiscsi_log(phba, KERN_ERR,
  "BC_%d : Link Down on Port %d tag 0x%x\n",
  evt->physical_port, evt->event_tag);
@@ -406,8 +412,10 @@ void beiscsi_process_async_event(struct beiscsi_hba *phba,
beiscsi_process_async_link(phba, compl);
break;
case ASYNC_EVENT_CODE_ISCSI:
-   phba->state |= BE_ADAPTER_CHECK_BOOT;
phba->get_boot = BE_GET_BOOT_RETRIES;
+   /* first this needs to be visible to worker thread */
+   wmb();
+   set_bit(BEISCSI_HBA_BOOT_FOUND, >state);
sev = KERN_ERR;
break;
case ASYNC_EVENT_CODE_SLI:
@@ -504,7 +512,7 @@ int be_mcc_compl_poll(struct beiscsi_hba *phba, unsigned 
int tag)
return 0;
}
for (i = 0; i < mcc_timeout; i++) {
-   if (beiscsi_error(phba))
+   if (beiscsi_hba_in_error(phba))
return -EIO;
 
beiscsi_process_mcc_cq(phba);
@@ -522,7 +530,7 @@ int be_mcc_compl_poll(struct beiscsi_hba *phba, unsigned 
int tag)
 
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
"BC_%d : FW Timed Out\n");
-   phba->fw_timeout = true;
+   set_bit(BEISCSI_HBA_FW_TIMEOUT, >state);
beiscsi_ue_detect(phba);
return -EBUSY;
 }
@@ -566,7 +574,7 @@ static int be_mbox_db_ready_poll(struct be_ctrl_info *ctrl)
 */
timeout = jiffies + msecs_to_jiffies(BEISCSI_MBX_RDY_BIT_TIMEOUT);
do {
-   if (beiscsi_error(phba))
+   if (beiscsi_hba_in_error(phba))
return -EIO;
 
ready = ioread32(db);
@@ -586,10 +594,8 @@ static int be_mbox_db_ready_poll(struct be_ctrl_info *ctrl)
beiscsi_log(phba, KERN_ERR,
BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
"BC_%d : FW Timed Out\n");
-
-   phba->fw_timeout = true;
+   set_bit(BEISCSI_HBA_FW_TIMEOUT, >state);
beiscsi_ue_detect(phba);
-
return -EBUSY;
 }
 
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index faa37f6..ddb458ab 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -52,22 +52,20 @@ struct iscsi_cls_session *beiscsi_session_create(struct 
iscsi_endpoint *ep,
 
 
if (!ep) {
-   printk(KERN_ERR
-  "beiscsi_session_create: invalid ep\n");
+   

[PATCH v2 05/29] be2iscsi: Fix gateway APIs to support IPv4 & IPv6

2016-08-19 Thread Jitendra Bhivare
Gateway APIs assume IP type as IPv4. Modify it to be generic to allow
clearing of IPv6 gateway set using BIOS.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_iscsi.c |   4 +-
 drivers/scsi/be2iscsi/be_mgmt.c  | 124 ++-
 drivers/scsi/be2iscsi/be_mgmt.h  |   7 +--
 3 files changed, 62 insertions(+), 73 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index eab0f4f..3ebfeff 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -419,7 +419,7 @@ beiscsi_set_ipv4(struct Scsi_Host *shost,
}
break;
case ISCSI_NET_PARAM_IPV4_GW:
-   ret = mgmt_set_gateway(phba, iface_param);
+   ret = beiscsi_if_set_gw(phba, BE2_IPV4, iface_param->value);
break;
case ISCSI_NET_PARAM_IPV4_BOOTPROTO:
if (iface_param->value[0] == ISCSI_BOOTPROTO_DHCP)
@@ -635,7 +635,7 @@ int be2iscsi_iface_get_param(struct iscsi_iface *iface,
break;
case ISCSI_NET_PARAM_IPV4_GW:
memset(, 0, sizeof(gateway));
-   len = mgmt_get_gateway(phba, BE2_IPV4, );
+   len = beiscsi_if_get_gw(phba, BE2_IPV4, );
if (!len)
len = sprintf(buf, "%pI4\n", _addr.addr);
break;
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 83926e2..9ef9f76 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1059,14 +1059,13 @@ mgmt_static_ip_modify(struct beiscsi_hba *phba,
return rc;
 }
 
-static int mgmt_modify_gateway(struct beiscsi_hba *phba, uint8_t *gt_addr,
-  uint32_t gtway_action, uint32_t param_len)
+static int beiscsi_if_mod_gw(struct beiscsi_hba *phba,
+u32 action, u32 ip_type, u8 *gw)
 {
struct be_cmd_set_def_gateway_req *req;
struct be_dma_mem nonemb_cmd;
int rt_val;
 
-
rt_val = mgmt_alloc_cmd_data(phba, _cmd,
OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY,
sizeof(*req));
@@ -1074,12 +1073,60 @@ static int mgmt_modify_gateway(struct beiscsi_hba 
*phba, uint8_t *gt_addr,
return rt_val;
 
req = nonemb_cmd.va;
-   req->action = gtway_action;
-   req->ip_addr.ip_type = BE2_IPV4;
+   req->action = action;
+   req->ip_addr.ip_type = ip_type;
+   memcpy(req->ip_addr.addr, gw,
+  (ip_type == BE2_IPV4) ? IP_V4_LEN : IP_V6_LEN);
+   return mgmt_exec_nonemb_cmd(phba, _cmd, NULL, 0);
+}
 
-   memcpy(req->ip_addr.addr, gt_addr, sizeof(req->ip_addr.addr));
+int beiscsi_if_set_gw(struct beiscsi_hba *phba, u32 ip_type, u8 *gw)
+{
+   struct be_cmd_get_def_gateway_resp gw_resp;
+   int rt_val;
 
-   return mgmt_exec_nonemb_cmd(phba, _cmd, NULL, 0);
+   memset(_resp, 0, sizeof(gw_resp));
+   rt_val = beiscsi_if_get_gw(phba, ip_type, _resp);
+   if (rt_val) {
+   beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
+   "BG_%d : Failed to Get Gateway Addr\n");
+   return rt_val;
+   }
+
+   rt_val = beiscsi_if_mod_gw(phba, IP_ACTION_DEL, ip_type,
+  gw_resp.ip_addr.addr);
+   if (rt_val) {
+   beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
+   "BG_%d : Failed to clear Gateway Addr Set\n");
+   return rt_val;
+   }
+
+   rt_val = beiscsi_if_mod_gw(phba, IP_ACTION_ADD, ip_type, gw);
+   if (rt_val)
+   beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
+   "BG_%d : Failed to Set Gateway Addr\n");
+
+   return rt_val;
+}
+
+int beiscsi_if_get_gw(struct beiscsi_hba *phba, u32 ip_type,
+ struct be_cmd_get_def_gateway_resp *resp)
+{
+   struct be_cmd_get_def_gateway_req *req;
+   struct be_dma_mem nonemb_cmd;
+   int rc;
+
+   rc = mgmt_alloc_cmd_data(phba, _cmd,
+OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY,
+sizeof(*resp));
+   if (rc)
+   return rc;
+
+   req = nonemb_cmd.va;
+   req->ip_type = ip_type;
+
+   return mgmt_exec_nonemb_cmd(phba, _cmd, resp,
+   sizeof(*resp));
 }
 
 int mgmt_set_ip(struct beiscsi_hba *phba,
@@ -1156,7 +1203,7 @@ int mgmt_set_ip(struct beiscsi_hba *phba,
/* Delete the Gateway settings if mode change is to DHCP */
if (boot_proto == ISCSI_BOOTPROTO_DHCP) {
memset(_addr_set, 0, sizeof(gtway_addr_set));
-   rc = mgmt_get_gateway(phba, BE2_IPV4, _addr_set);
+   rc = beiscsi_if_get_gw(phba, BE2_IPV4, _addr_set);
  

[PATCH v2 01/29] be2iscsi: Fix to use correct configuration values

2016-08-19 Thread Jitendra Bhivare
Following configuration is created with what driver exports:
iface.vlan_id = 65535
iface.vlan_priority = 255
iface.vlan_state = 

vlan_state is empty as iscsiadm doesn't process "Disabled".
When applying this configuration, iscsiadm checks for if vlan_state is
"disable" if not it enables with value in vlan_id. 65535 not being valid
value, 0 is applied.

Use "enable" or "disable" for ISCSI_NET_PARAM.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_iscsi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 09f89a3..ab696ec 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -567,8 +567,8 @@ static int be2iscsi_get_if_param(struct beiscsi_hba *phba,
break;
case ISCSI_NET_PARAM_VLAN_ENABLED:
len = sprintf(buf, "%s\n",
-(if_info->vlan_priority == BEISCSI_VLAN_DISABLE)
-? "Disabled\n" : "Enabled\n");
+ (if_info->vlan_priority == BEISCSI_VLAN_DISABLE) ?
+ "disable" : "enable");
break;
case ISCSI_NET_PARAM_VLAN_ID:
if (if_info->vlan_priority == BEISCSI_VLAN_DISABLE)
@@ -620,7 +620,7 @@ int be2iscsi_iface_get_param(struct iscsi_iface *iface,
len = be2iscsi_get_if_param(phba, iface, param, buf);
break;
case ISCSI_NET_PARAM_IFACE_ENABLE:
-   len = sprintf(buf, "enabled\n");
+   len = sprintf(buf, "enable\n");
break;
case ISCSI_NET_PARAM_IPV4_GW:
memset(, 0, sizeof(gateway));
-- 
1.9.1

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


[PATCH v2 02/29] be2iscsi: Replace _bh version for mcc_lock spinlock

2016-08-19 Thread Jitendra Bhivare
This got unnecessarily introduced with other changes in previous
commits. mcc_lock is taken only in process contexts.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_cmds.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index a55eaee..0ef3d5a 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -133,7 +133,7 @@ struct be_mcc_wrb *alloc_mcc_wrb(struct beiscsi_hba *phba,
struct be_mcc_wrb *wrb = NULL;
unsigned int tag;
 
-   spin_lock_bh(>ctrl.mcc_lock);
+   spin_lock(>ctrl.mcc_lock);
if (mccq->used == mccq->len) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT |
BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
@@ -174,7 +174,7 @@ struct be_mcc_wrb *alloc_mcc_wrb(struct beiscsi_hba *phba,
mccq->used++;
 
 alloc_failed:
-   spin_unlock_bh(>ctrl.mcc_lock);
+   spin_unlock(>ctrl.mcc_lock);
return wrb;
 }
 
@@ -182,7 +182,7 @@ void free_mcc_wrb(struct be_ctrl_info *ctrl, unsigned int 
tag)
 {
struct be_queue_info *mccq = >mcc_obj.q;
 
-   spin_lock_bh(>mcc_lock);
+   spin_lock(>mcc_lock);
tag = tag & MCC_Q_CMD_TAG_MASK;
ctrl->mcc_tag[ctrl->mcc_free_index] = tag;
if (ctrl->mcc_free_index == (MAX_MCC_CMD - 1))
@@ -191,7 +191,7 @@ void free_mcc_wrb(struct be_ctrl_info *ctrl, unsigned int 
tag)
ctrl->mcc_free_index++;
ctrl->mcc_tag_available++;
mccq->used--;
-   spin_unlock_bh(>mcc_lock);
+   spin_unlock(>mcc_lock);
 }
 
 /**
-- 
1.9.1

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


[PATCH v2 13/29] be2iscsi: Remove isr_lock and dead code

2016-08-19 Thread Jitendra Bhivare
todo_mcc_cq is not needed as only MCC work is queued.
todo_cq is not used at all.
Rename functions to be consistent.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be.h  |   2 +-
 drivers/scsi/be2iscsi/be_main.c | 132 +++-
 drivers/scsi/be2iscsi/be_main.h |   2 -
 3 files changed, 49 insertions(+), 87 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index ee5ace8..621291a 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -100,7 +100,7 @@ struct be_eq_obj {
struct be_queue_info q;
struct beiscsi_hba *phba;
struct be_queue_info *cq;
-   struct work_struct work_cqs; /* Work Item */
+   struct work_struct mcc_work; /* Work Item */
struct irq_poll iopoll;
 };
 
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 0fbb80d..6179c4e 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -832,12 +832,11 @@ static void hwi_ring_eq_db(struct beiscsi_hba *phba,
 static irqreturn_t be_isr_mcc(int irq, void *dev_id)
 {
struct beiscsi_hba *phba;
-   struct be_eq_entry *eqe = NULL;
+   struct be_eq_entry *eqe;
struct be_queue_info *eq;
struct be_queue_info *mcc;
-   unsigned int num_eq_processed;
+   unsigned int mcc_events;
struct be_eq_obj *pbe_eq;
-   unsigned long flags;
 
pbe_eq = dev_id;
eq = _eq->q;
@@ -845,27 +844,23 @@ static irqreturn_t be_isr_mcc(int irq, void *dev_id)
mcc = >ctrl.mcc_obj.cq;
eqe = queue_tail_node(eq);
 
-   num_eq_processed = 0;
-
+   mcc_events = 0;
while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32]
& EQE_VALID_MASK) {
if (((eqe->dw[offsetof(struct amap_eq_entry,
 resource_id) / 32] &
 EQE_RESID_MASK) >> 16) == mcc->id) {
-   spin_lock_irqsave(>isr_lock, flags);
-   pbe_eq->todo_mcc_cq = true;
-   spin_unlock_irqrestore(>isr_lock, flags);
+   mcc_events++;
}
AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0);
queue_tail_inc(eq);
eqe = queue_tail_node(eq);
-   num_eq_processed++;
}
-   if (pbe_eq->todo_mcc_cq)
-   queue_work(phba->wq, _eq->work_cqs);
-   if (num_eq_processed)
-   hwi_ring_eq_db(phba, eq->id, 1, num_eq_processed, 1, 1);
 
+   if (mcc_events) {
+   queue_work(phba->wq, _eq->mcc_work);
+   hwi_ring_eq_db(phba, eq->id, 1, mcc_events, 1, 1);
+   }
return IRQ_HANDLED;
 }
 
@@ -884,7 +879,6 @@ static irqreturn_t be_isr_msix(int irq, void *dev_id)
eq = _eq->q;
 
phba = pbe_eq->phba;
-
/* disable interrupt till iopoll completes */
hwi_ring_eq_db(phba, eq->id, 1, 0, 0, 1);
irq_poll_sched(_eq->iopoll);
@@ -902,14 +896,13 @@ static irqreturn_t be_isr(int irq, void *dev_id)
struct beiscsi_hba *phba;
struct hwi_controller *phwi_ctrlr;
struct hwi_context_memory *phwi_context;
-   struct be_eq_entry *eqe = NULL;
+   struct be_eq_entry *eqe;
struct be_queue_info *eq;
struct be_queue_info *mcc;
-   unsigned long flags, index;
-   unsigned int num_mcceq_processed, num_ioeq_processed;
+   unsigned int mcc_events, io_events;
struct be_ctrl_info *ctrl;
struct be_eq_obj *pbe_eq;
-   int isr;
+   int isr, rearm;
 
phba = dev_id;
ctrl = >ctrl;
@@ -924,44 +917,35 @@ static irqreturn_t be_isr(int irq, void *dev_id)
 
eq = _context->be_eq[0].q;
mcc = >ctrl.mcc_obj.cq;
-   index = 0;
eqe = queue_tail_node(eq);
 
-   num_ioeq_processed = 0;
-   num_mcceq_processed = 0;
+   io_events = 0;
+   mcc_events = 0;
while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32]
& EQE_VALID_MASK) {
if (((eqe->dw[offsetof(struct amap_eq_entry,
-resource_id) / 32] &
-EQE_RESID_MASK) >> 16) == mcc->id) {
-   spin_lock_irqsave(>isr_lock, flags);
-   pbe_eq->todo_mcc_cq = true;
-   spin_unlock_irqrestore(>isr_lock, flags);
-   num_mcceq_processed++;
-   } else {
-   irq_poll_sched(_eq->iopoll);
-   num_ioeq_processed++;
-   }
+ resource_id) / 32] & EQE_RESID_MASK) >> 16) == mcc->id)
+   mcc_events++;
+   else
+   io_events++;
AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0);

[PATCH v2 00/29] be2iscsi: driver update 11.2.0.0

2016-08-19 Thread Jitendra Bhivare
This patch is generated against for-next branch.

v2 changes:
 Removed
- be2iscsi: Replace _bh with _irqsave/irqrestore
  This will be sent in separate patch-set.
 Added
- be2iscsi: Fix bad WRB index error
- be2iscsi: Fix queue and connection parameters

Jitendra Bhivare (29):
  be2iscsi: Fix to use correct configuration values
  be2iscsi: Replace _bh version for mcc_lock spinlock
  be2iscsi: Reduce driver load/unload time
  be2iscsi: Set and return right iface v4/v6 states
  be2iscsi: Fix gateway APIs to support IPv4 & IPv6
  be2iscsi: Fix release of DHCP IP in static mode
  be2iscsi: Move VLAN code to common iface_set_param
  be2iscsi: Update iface handle before any set param
  be2iscsi: Rename iface get/set/create/destroy APIs
  be2iscsi: Handle only NET_PARAM in iface_get_param
  be2iscsi: Check all zeroes IP before issuing IOCTL
  be2iscsi: Remove alloc_mcc_tag & beiscsi_pci_soft_reset
  be2iscsi: Remove isr_lock and dead code
  be2iscsi: Fix checks for HBA in error state
  be2iscsi: Fix to make boot discovery non-blocking
  be2iscsi: Fix to add timer for UE detection
  be2iscsi: Add IOCTL to check UER supported
  be2iscsi: Move functions to right files
  be2iscsi: Fix POST check and reset sequence
  be2iscsi: Add V1 of EPFW cleanup IOCTL
  be2iscsi: Add TPE recovery feature
  be2iscsi: Fail the sessions immediately after TPE
  be2iscsi: Add FUNCTION_RESET during driver unload
  be2iscsi: Fix async PDU handling path
  be2iscsi: Fix bad WRB index error
  be2iscsi: Fix queue and connection parameters
  be2iscsi: Update copyright information
  be2iscsi: Update the driver version
  MAINTAINERS: Update be2iscsi contact info

 MAINTAINERS  |   10 +-
 drivers/scsi/be2iscsi/be.h   |   15 +-
 drivers/scsi/be2iscsi/be_cmds.c  | 1096 +++--
 drivers/scsi/be2iscsi/be_cmds.h  |  142 ++-
 drivers/scsi/be2iscsi/be_iscsi.c |  408 +++
 drivers/scsi/be2iscsi/be_iscsi.h |   25 +-
 drivers/scsi/be2iscsi/be_main.c  | 2467 +++---
 drivers/scsi/be2iscsi/be_main.h  |  220 ++--
 drivers/scsi/be2iscsi/be_mgmt.c  | 1492 +--
 drivers/scsi/be2iscsi/be_mgmt.h  |   51 +-
 10 files changed, 3041 insertions(+), 2885 deletions(-)

-- 
1.9.1

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


[PATCH v2 04/29] be2iscsi: Set and return right iface v4/v6 states

2016-08-19 Thread Jitendra Bhivare
ipv4_iface and ipv6_iface fields need to be set to NULL when destroyed.
Before creation these are checked. Use these to report correct states.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
---
 drivers/scsi/be2iscsi/be_iscsi.c | 31 +--
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index ab696ec..eab0f4f 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -292,10 +292,14 @@ void beiscsi_create_def_ifaces(struct beiscsi_hba *phba)
 
 void beiscsi_destroy_def_ifaces(struct beiscsi_hba *phba)
 {
-   if (phba->ipv6_iface)
+   if (phba->ipv6_iface) {
iscsi_destroy_iface(phba->ipv6_iface);
-   if (phba->ipv4_iface)
+   phba->ipv6_iface = NULL;
+   }
+   if (phba->ipv4_iface) {
iscsi_destroy_iface(phba->ipv4_iface);
+   phba->ipv4_iface = NULL;
+   }
 }
 
 static int
@@ -406,6 +410,14 @@ beiscsi_set_ipv4(struct Scsi_Host *shost,
 
/* Check the param */
switch (iface_param->param) {
+   case ISCSI_NET_PARAM_IFACE_ENABLE:
+   if (iface_param->value[0] == ISCSI_IFACE_ENABLE)
+   ret = beiscsi_create_ipv4_iface(phba);
+   else {
+   iscsi_destroy_iface(phba->ipv4_iface);
+   phba->ipv4_iface = NULL;
+   }
+   break;
case ISCSI_NET_PARAM_IPV4_GW:
ret = mgmt_set_gateway(phba, iface_param);
break;
@@ -421,12 +433,6 @@ beiscsi_set_ipv4(struct Scsi_Host *shost,
"BS_%d : Invalid BOOTPROTO: %d\n",
iface_param->value[0]);
break;
-   case ISCSI_NET_PARAM_IFACE_ENABLE:
-   if (iface_param->value[0] == ISCSI_IFACE_ENABLE)
-   ret = beiscsi_create_ipv4_iface(phba);
-   else
-   iscsi_destroy_iface(phba->ipv4_iface);
-   break;
case ISCSI_NET_PARAM_IPV4_SUBNET:
case ISCSI_NET_PARAM_IPV4_ADDR:
ret = beiscsi_set_static_ip(shost, iface_param,
@@ -459,7 +465,7 @@ beiscsi_set_ipv6(struct Scsi_Host *shost,
ret = beiscsi_create_ipv6_iface(phba);
else {
iscsi_destroy_iface(phba->ipv6_iface);
-   ret = 0;
+   phba->ipv6_iface = NULL;
}
break;
case ISCSI_NET_PARAM_IPV6_ADDR:
@@ -620,7 +626,12 @@ int be2iscsi_iface_get_param(struct iscsi_iface *iface,
len = be2iscsi_get_if_param(phba, iface, param, buf);
break;
case ISCSI_NET_PARAM_IFACE_ENABLE:
-   len = sprintf(buf, "enable\n");
+   if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4)
+   len = sprintf(buf, "%s\n",
+ phba->ipv4_iface ? "enable" : "disable");
+   else if (iface->iface_type == ISCSI_IFACE_TYPE_IPV6)
+   len = sprintf(buf, "%s\n",
+ phba->ipv6_iface ? "enable" : "disable");
break;
case ISCSI_NET_PARAM_IPV4_GW:
memset(, 0, sizeof(gateway));
-- 
1.9.1

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


Re: [PATCH] fcoe: provide translation table between Ethernet and FC port speeds

2016-08-19 Thread Hannes Reinecke
On 08/15/2016 05:24 PM, Johannes Thumshirn wrote:
> Provide a translation table between Ethernet and FC port speeds so odd
> speeds (from a Ethernet POV) like 8 Gbit are correctly mapped to sysfs
> and open-fcoe's fcoeadm.
> 
> Before:
> Description:  BCM57840 NetXtreme II 10/20-Gigabit Ethernet
> Revision: 11
> Manufacturer: Broadcom Corporation
> Serial Number:6CC2173EA1D0
> 
> Driver:   bnx2x 1.712.30-0
> Number of Ports:  1
> 
> Symbolic Name: bnx2fc (QLogic BCM57840) v2.10.3 over eth2
> OS Device Name:host1
> Node Name: 0x20006cc2173ea1d1
> Port Name: 0x10006cc2173ea1d1
> FabricName:0x10c0dd0ce717
> Speed: unknown
> Supported Speed:   1 Gbit, 10 Gbit
> MaxFrameSize:  2048 bytes
> FC-ID (Port ID):   0x660702
> State: Online
> 
> After:
> Description:  BCM57840 NetXtreme II 10/20-Gigabit Ethernet
> Revision: 11
> Manufacturer: Broadcom Corporation
> Serial Number:6CC2173EA1D0
> 
> Driver:   bnx2x 1.712.30-0
> Number of Ports:  1
> 
> Symbolic Name: bnx2fc (QLogic BCM57840) v2.10.3 over eth2
> OS Device Name:host1
> Node Name: 0x20006cc2173ea1d1
> Port Name: 0x10006cc2173ea1d1
> FabricName:0x10c0dd0ce717
> Speed: 8 Gbit
> Supported Speed:   1 Gbit, 10 Gbit
> MaxFrameSize:  2048 bytes
> FC-ID (Port ID):   0x660701
> State: Online
> 
> Signed-off-by: Johannes Thumshirn 
> ---
>  drivers/scsi/fcoe/fcoe_transport.c | 48 
> --
>  1 file changed, 31 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/scsi/fcoe/fcoe_transport.c 
> b/drivers/scsi/fcoe/fcoe_transport.c
> index 7028dd3..3e7f0e7 100644
> --- a/drivers/scsi/fcoe/fcoe_transport.c
> +++ b/drivers/scsi/fcoe/fcoe_transport.c
> @@ -83,6 +83,36 @@ static struct notifier_block libfcoe_notifier = {
>   .notifier_call = libfcoe_device_notification,
>  };
>  
> +static const struct {
> + u32 fc_port_speed;
> + u32 eth_port_speed;
> +} fcoe_port_speed_mapping[] = {
> + { FC_PORTSPEED_1GBIT, SPEED_1000 },
> + { FC_PORTSPEED_2GBIT, 2000 },
> + { FC_PORTSPEED_4GBIT, 4000 },
> + { FC_PORTSPEED_8GBIT, 8000 },
> + { FC_PORTSPEED_10GBIT, SPEED_1 },
> + { FC_PORTSPEED_16GBIT, 16000 },
> + { FC_PORTSPEED_20GBIT, SPEED_2  },
> + { FC_PORTSPEED_25GBIT, SPEED_25000  },
> + { FC_PORTSPEED_32GBIT, 32000 },
> + { FC_PORTSPEED_40GBIT, SPEED_4  },
> + { FC_PORTSPEED_50GBIT, SPEED_5  },
> + { FC_PORTSPEED_100GBIT, SPEED_10 },
> +};
> +
Hmm. Why not 'SPEED_2000' etc?

This looks a bit weird, mixing values with defines ...

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Remove the unnecessary semicolons

2016-08-19 Thread Chao Fan
From: Vidos Fan 

At the end of funcions, semicolons are unnecessary. So drop them.

Signed-off-by: Vidos Fan 
---
 drivers/scsi/virtio_scsi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 7dbbb29..9632a0c 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -241,7 +241,7 @@ static void virtscsi_req_done(struct virtqueue *vq)
struct virtio_scsi_vq *req_vq = >req_vqs[index];
 
virtscsi_vq_done(vscsi, req_vq, virtscsi_complete_cmd);
-};
+}
 
 static void virtscsi_poll_requests(struct virtio_scsi *vscsi)
 {
@@ -267,7 +267,7 @@ static void virtscsi_ctrl_done(struct virtqueue *vq)
struct virtio_scsi *vscsi = shost_priv(sh);
 
virtscsi_vq_done(vscsi, >ctrl_vq, virtscsi_complete_free);
-};
+}
 
 static void virtscsi_handle_event(struct work_struct *work);
 
@@ -413,7 +413,7 @@ static void virtscsi_event_done(struct virtqueue *vq)
struct virtio_scsi *vscsi = shost_priv(sh);
 
virtscsi_vq_done(vscsi, >event_vq, virtscsi_complete_event);
-};
+}
 
 /**
  * virtscsi_add_cmd - add a virtio_scsi_cmd to a virtqueue
-- 
2.7.4

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


Re: [PATCH v4 2/3] ses: use scsi_is_sas_rphy instead of is_sas_attached

2016-08-19 Thread Johannes Thumshirn
On Thu, Aug 18, 2016 at 09:08:42AM -0700, James Bottomley wrote:
> And please fix your scripts or just use the standard ones:

Hmmm, I'm not using a script at all but pure git send-email. I'll have
a look into it.

> 
> Cc: sta...@vger.kernel.org, #@suse.de, v4...@suse.de,
>   
> I'm tired of getting two bounces every time I reply to this thread.
> 
> James
> 

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html