Re: [PATCH 2/2] libata-scsi: do not response with "invalid field" for FORMAT UNIT

2016-07-04 Thread Sergei Shtylyov

On 07/05/2016 12:27 AM, Sergei Shtylyov wrote:


From: Tom Yan 

It does not make sense and is confusing to response with "Invalid


   Respond here and in the subject.


field in cbd" while we have no support at all implemented for


   CDB.


FORMAT UNIT. It is decent to let it go to the default, which
will response with "Invalid command operation code" instead.

>>

   Respond again.


Signed-off-by: Tom Yan 


[...]

MBR, Sergei

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


Re: [PATCH 2/2] libata-scsi: do not response with "invalid field" for FORMAT UNIT

2016-07-04 Thread Sergei Shtylyov

On 07/04/2016 11:53 PM, tom.t...@gmail.com wrote:


From: Tom Yan 

It does not make sense and is confusing to response with "Invalid


   Respond here and in the subject.


field in cbd" while we have no support at all implemented for
FORMAT UNIT. It is decent to let it go to the default, which
will response with "Invalid command operation code" instead.

Signed-off-by: Tom Yan 


MBR, Sergei

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


Re: [PATCH 1/2] libata-scsi: improve TRIM translation

2016-07-04 Thread Sergei Shtylyov

On 07/04/2016 11:53 PM, tom.t...@gmail.com wrote:


From: Tom Yan 

Define TRIM_RANGE_SIZE and TRIM_RANGE_NUM so that the corresponding
functions can be more generalized. Also, conform SBC by rejecting


   Conform to SBC, perhaps?


WRITE SAME (16) commands with number of blocks that exceeds the limit
that is defined in the SATL.

Signed-off-by: Tom Yan 

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index bfec66f..80d732c 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c

[...]

@@ -3305,7 +3308,10 @@ static unsigned int ata_scsi_write_same_xlat(struct 
ata_queued_cmd *qc)
goto invalid_param_len;

buf = page_address(sg_page(scsi_sglist(scmd)));
-   size = ata_set_lba_range_entries(buf, 512, block, n_block);
+   if (n_block <= TRIM_RANGE_SIZE * TRIM_RANGE_NUM)
+ size = ata_set_lba_range_entries(buf, TRIM_RANGE_NUM, block, n_block);
+   else
+ goto invalid_fld;


   CodingStyle: indent with a tab, not spaces.

[...]

MBR, Sergei

--
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] libata-scsi: improve TRIM translation

2016-07-04 Thread tom . ty89
From: Tom Yan 

Define TRIM_RANGE_SIZE and TRIM_RANGE_NUM so that the corresponding
functions can be more generalized. Also, conform SBC by rejecting
WRITE SAME (16) commands with number of blocks that exceeds the limit
that is defined in the SATL.

Signed-off-by: Tom Yan 

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index bfec66f..80d732c 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -75,6 +75,9 @@ static struct ata_device *ata_scsi_find_dev(struct ata_port 
*ap,
 #define ALL_MPAGES 0x3f
 #define ALL_SUB_MPAGES 0xff
 
+#define TRIM_RANGE_SIZE 0x
+#define TRIM_RANGE_NUM 64 /* 512-byte payload / (6-byte LBA + 2-byte range per 
entry) */
+
 
 static const u8 def_rw_recovery_mpage[RW_RECOVERY_MPAGE_LEN] = {
RW_RECOVERY_MPAGE,
@@ -2314,7 +2317,7 @@ static unsigned int ata_scsiop_inq_b0(struct 
ata_scsi_args *args, u8 *rbuf)
 * with the unmap bit set.
 */
if (ata_id_has_trim(args->id)) {
-   put_unaligned_be64(65535 * 512 / 8, [36]);
+   put_unaligned_be64(TRIM_RANGE_SIZE * TRIM_RANGE_NUM, [36]);
put_unaligned_be32(1, [28]);
}
 
@@ -3305,7 +3308,10 @@ static unsigned int ata_scsi_write_same_xlat(struct 
ata_queued_cmd *qc)
goto invalid_param_len;
 
buf = page_address(sg_page(scsi_sglist(scmd)));
-   size = ata_set_lba_range_entries(buf, 512, block, n_block);
+   if (n_block <= TRIM_RANGE_SIZE * TRIM_RANGE_NUM)
+ size = ata_set_lba_range_entries(buf, TRIM_RANGE_NUM, block, n_block);
+   else
+ goto invalid_fld;
 
if (ata_ncq_enabled(dev) && ata_fpdma_dsm_supported(dev)) {
/* Newer devices support queued TRIM commands */
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 99346be..0971c3f 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -1071,7 +1071,7 @@ static inline unsigned ata_set_lba_range_entries(void 
*_buffer,
__le64 *buffer = _buffer;
unsigned i = 0, used_bytes;
 
-   while (i < buf_size / 8 ) { /* 6-byte LBA + 2-byte range per entry */
+   while (i < buf_size) {
u64 entry = sector |
((u64)(count > 0x ? 0x : count) << 48);
buffer[i++] = __cpu_to_le64(entry);
-- 
2.9.0

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


Re: [PATCH 1/6] lib: string: add function strtolower()

2016-07-04 Thread Markus Mayer
On 1 July 2016 at 14:08, Rasmus Villemoes  wrote:

> A few suggestions:
>
> - Make the function take separate src and dst parameters, making it explicitly
>   allowed to pass the same value (but not other kinds of overlap, of
>   course). That way one can avoid "strcpy(dst, src); strtolower(dst);".
>
> - Drop the NULL check. If someone does "foo->bar = something;
>   strtolower(foo->bar); put foo in a global data structure...", the
>   dereference of foo->bar may happen much later. Doing the NULL deref
>   sooner means it's much easier to find and fix the bug. (Also, other
>   str* and mem* functions don't usually check for NULL).
>
> - While it's true that strcpy and memcpy by definition return dst, that's
>   mostly useless. If you want it to return anything, please make it
>   something that might be used - for example, having stpcpy semantics
>   (returning a pointer to dst's terminating \0) means a caller might avoid
>   a strlen call.
>
> - Maybe do strtoupper while you're at it. Quick grepping didn't find any
>   use for the copy-while-lowercasing, but copy-while-uppercasing can at
>   least be used in drivers/acpi/acpica/nsrepair2.c,
>   drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c,
>   drivers/power/power_supply_sysfs.c along with a bunch of inplace
>   uppercasing.
>
>
> Rasmus

Thanks for the suggestions to you and Jani. Based on the feedback I
received, I am reworking the series now and will post v2 probably
tomorrow.

Regards,
-Markus
--
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] scsi: bnx2i: convert to kworker

2016-07-04 Thread Sebastian Andrzej Siewior
The driver creates its own per-CPU threads which are updated based on CPU
hotplug events. It is also possible to use kworkers and remove some of the
infrastructure get the same job done while saving a few lines of code.

The DECLARE_PER_CPU() definition is moved into the header file where it
belongs. bnx2i_percpu_io_thread() becomes bnx2i_percpu_io_work() which is
mostly the same code. The outer loop (kthread_should_stop()) gets removed and
the remaining code is shifted to the left.
bnx2i_queue_scsi_cmd_resp() is mostly the same. The code checked ->iothread to
decide if there is an active per-CPU thread. With the kworkers this is no
longer possible nor required.
The allocation of struct bnx2i_work does not happen with ->p_work_lock held
which is not required. I am unsure about the call-stack so I can't say
if this qualifies it for the allocation with GFP_KERNEL instead of
GFP_ATOMIC (it is not _bh lock but as I said, I don't know the context).
The allocation case has been reversed so the inner if case is called on
!bnx2i_work and is just the invocation one function since the lock is not
held during allocation. The init of the new bnx2i_work struct is now
done also without the ->p_work_lock held: it is a new object, nobody
knows about it yet. It should be enough to hold the lock while adding
this item to the list. I am unsure about that atomic_inc() so I keep
things as they were.

The remaining part is the removal CPU hotplug notifier since it is taken
care by the kworker code.

This patch was only compile-tested due to -ENODEV.

Cc: qlogic-storage-upstr...@qlogic.com
Cc: Christoph Hellwig 
Signed-off-by: Sebastian Andrzej Siewior 
---
 drivers/scsi/bnx2i/bnx2i.h  |  11 +---
 drivers/scsi/bnx2i/bnx2i_hwi.c  | 101 ++---
 drivers/scsi/bnx2i/bnx2i_init.c | 121 +++-
 3 files changed, 53 insertions(+), 180 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index ed7f3228e234..78cdc493bab5 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -31,7 +31,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -775,12 +774,11 @@ struct bnx2i_work {
 };
 
 struct bnx2i_percpu_s {
-   struct task_struct *iothread;
+   struct work_struct work;
struct list_head work_list;
spinlock_t p_work_lock;
 };
 
-
 /* Global variables */
 extern unsigned int error_mask1, error_mask2;
 extern u64 iscsi_error_mask;
@@ -797,7 +795,7 @@ extern unsigned int rq_size;
 
 extern struct device_attribute *bnx2i_dev_attributes[];
 
-
+DECLARE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu);
 
 /*
  * Function Prototypes
@@ -875,8 +873,5 @@ extern void bnx2i_print_active_cmd_queue(struct bnx2i_conn 
*conn);
 extern void bnx2i_print_xmit_pdu_queue(struct bnx2i_conn *conn);
 extern void bnx2i_print_recv_state(struct bnx2i_conn *conn);
 
-extern int bnx2i_percpu_io_thread(void *arg);
-extern int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session,
-  struct bnx2i_conn *bnx2i_conn,
-  struct cqe *cqe);
+extern void bnx2i_percpu_io_work(struct work_struct *work);
 #endif
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 42921dbba927..9be58f6523b3 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -19,8 +19,6 @@
 #include 
 #include "bnx2i.h"
 
-DECLARE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu);
-
 /**
  * bnx2i_get_cid_num - get cid from ep
  * @ep:endpoint pointer
@@ -1350,9 +1348,9 @@ int bnx2i_send_fw_iscsi_init_msg(struct bnx2i_hba *hba)
  *
  * process SCSI CMD Response CQE & complete the request to SCSI-ML
  */
-int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session,
-   struct bnx2i_conn *bnx2i_conn,
-   struct cqe *cqe)
+static int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session,
+  struct bnx2i_conn *bnx2i_conn,
+  struct cqe *cqe)
 {
struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data;
struct bnx2i_hba *hba = bnx2i_conn->hba;
@@ -1862,45 +1860,37 @@ static void bnx2i_process_cmd_cleanup_resp(struct 
iscsi_session *session,
 
 
 /**
- * bnx2i_percpu_io_thread - thread per cpu for ios
+ * bnx2i_percpu_io_work - thread per cpu for ios
  *
- * @arg:   ptr to bnx2i_percpu_info structure
+ * @work_s:The work struct
  */
-int bnx2i_percpu_io_thread(void *arg)
+void bnx2i_percpu_io_work(struct work_struct *work_s)
 {
-   struct bnx2i_percpu_s *p = arg;
+   struct bnx2i_percpu_s *p;
struct bnx2i_work *work, *tmp;
LIST_HEAD(work_list);
 
-   set_user_nice(current, MIN_NICE);
+   p = container_of(work_s, struct bnx2i_percpu_s, work);
 
-   while (!kthread_should_stop()) {
-   

Re: how to test pscsi with vhost

2016-07-04 Thread Zhu Lingshan

Hi Zhangfei,

I am also interested in pscsi, you can try kvm, seems you can create a 
virtualized pscsi device in kvm / virt-manager. I haven't tried that 
yet, hope this can help.


Thanks,
BR
Zhu Lingshan
在 2016/7/4 15:32, Zhangfei Gao 写道:

I am testing with pscsi, but fail to find any block device under /dev to mount.
The scsi_probe_lun seems can not return correctly, scsi scan: INQUIRY failes.

Is this usage correct?

/backstores/pscsi> create name=pscsi_backend dev=/dev/sdb
Note: block backstore recommended for SCSI block devices
Created pscsi storage object pscsi_backend using /dev/sdb

/backstores/pscsi> cd /vhost
/vhost> create wwn=naa.60014052cc816bf4
/vhost> cd naa.60014052cc816bf4/tpg1/luns
/vhost/naa.60...bf4/tpg1/luns> create /backstores/pscsi/pscsi_backend
Selected LUN 0.
Created LUN 0.

/vhost/naa.60...bf4/tpg1/luns> cd /
/> ls
o- / . [...]
   o- backstores .. 
[...]
   | o- fileio ... [0 Storage 
Object]
   | o- iblock ... [0 Storage 
Object]
   | o- pscsi  [1 Storage 
Object]
   | | o- pscsi_backend  [/dev/sdb 
activated]
   | o- rd_mcp ... [0 Storage 
Object]
   o- iscsi . [0 
Targets]
   o- loopback .. [0 
Targets]
   o- vhost .. [1 
Target]
 o- naa.60014052cc816bf4  [1 
TPG]
   o- tpg1 ... 
[naa.6001405030badd8a]
 o- luns  [1 
LUN]
   o- lun0 . [pscsi/pscsi_backend 
(/dev/sdb)]
/>

/> saveconfig


qemu.git/aarch64-softmmu/qemu-system-aarch64 \
 -enable-kvm -nographic -kernel Image \
 -device vhost-scsi-pci,wwpn=naa.60014052cc816bf4 \
 -m 512 -M virt -cpu host \
 -append "earlyprintk console=ttyAMA0 mem=512M"


root@(none)$ ls /dev
autofs  ptyp8   tty30   tty62
console ptyp9   tty31   tty63
cpu_dma_latency ptypa   tty32   tty7
cuseptypb   tty33   tty8
fullptypc   tty34   tty9
fuseptypd   tty35   ttyAMA0
input   ptype   tty36   ttyS0
kmemptypf   tty37   ttyS1
kmsgrandom  tty38   ttyS2
loop-controlsnd tty39   ttyS3
loop0   tty tty4ttyp0
loop1   tty0tty40   ttyp1
loop2   tty1tty41   ttyp2
loop3   tty10   tty42   ttyp3
loop4   tty11   tty43   ttyp4
loop5   tty12   tty44   ttyp5
loop6   tty13   tty45   ttyp6
loop7   tty14   tty46   ttyp7
mem tty15   tty47   ttyp8
memory_bandwidthtty16   tty48   ttyp9
net tty17   tty49   ttypa
network_latency tty18   tty5ttypb
network_throughput  tty19   tty50   ttypc
nulltty2tty51   ttypd
porttty20   tty52   ttype
psaux   tty21   tty53   ttypf
ptmxtty22   tty54   urandom
ptyp0   tty23   tty55   vcs
ptyp1   tty24   tty56   vcs1
ptyp2   tty25   tty57   vcsa
ptyp3   tty26   tty58   vcsa1
ptyp4   tty27   tty59   vga_arbiter
ptyp5   tty28   tty6vhost-scsi
ptyp6   tty29   tty60   zero
ptyp7   tty3tty61

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



--
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] cxl: remove dead Kconfig options

2016-07-04 Thread Ian Munsie
Acked-by: Ian Munsie 

--
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 5/6] fcoe: implement FIP VLAN responder

2016-07-04 Thread Hannes Reinecke
On 07/04/2016 12:05 PM, Johannes Thumshirn wrote:
> On Mon, Jul 04, 2016 at 10:29:22AM +0200, Hannes Reinecke wrote:
>> When running in VN2VN mode there is no central instance which
>> would send out any FIP VLAN discovery notifications. So this
>> patch adds a new sysfs attribute 'fip_vlan_responder' which
>> will activate a FIP VLAN discovery responder.
>>
>> Signed-off-by: Hannes Reinecke 
>> ---
> 
> [...]
> 
>> +/**
>> + * fcoe_ctlr_vlan_send() - Send a FIP VLAN Notification
>> + * @fip: The FCoE controller
>> + * @sub: sub-opcode for vlan notification or vn2vn vlan notification
>> + * @dest: The destination Ethernet MAC address
>> + * @min_len: minimum size of the Ethernet payload to be sent
>> + */
>> +static void fcoe_ctlr_vlan_send(struct fcoe_ctlr *fip,
>> +  enum fip_vlan_subcode sub,
>> +  const u8 *dest)
>> +{
>> +struct sk_buff *skb;
>> +struct fip_frame {
>> +struct ethhdr eth;
>> +struct fip_header fip;
>> +struct fip_mac_desc mac;
>> +struct fip_vlan_desc vlan;
>> +} __packed * frame;
> 
> Hmmm this is the 2nd time fip_frame is defined in  fcoe_ctlr.c. I'd prefere
> having the type definition somewhere else in this file and then use it in
> fcoe_ctlr_vlan_send() and fcoe_ctlr_vn_send().
> 
This appears to be the convention in the file; every function which is
sending a frame on the wire defines a local variable 'struct fip_frame'
which contains the actual frame definition.

Might be that the style can be improved, but that should be a separate
patch.

>> +size_t len;
>> +size_t dlen;
>> +
>> +len = sizeof(*frame);
>> +dlen = sizeof(frame->mac) + sizeof(frame->vlan);
>> +len = max(len, sizeof(struct ethhdr));
>> +
>> +skb = dev_alloc_skb(len);
>> +if (!skb)
>> +return;
> 
> dev_alloc_skb() uses GFP_ATOMIC so it's actually not unlikely to fail
> so please return -ENOMEM here, just so the caller knows what happened.
> 
Again, the calling convention of fcoe_ctlr_send_vlan() insists on using
a void return.
Yes, this should be improved, but again with another patch.

So do I need to send two additional patches for updating the infrastructure?

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


Re: [PATCH 6/6] fcoe: Use default VLAN for FIP VLAN discovery

2016-07-04 Thread Johannes Thumshirn
On Mon, Jul 04, 2016 at 10:29:23AM +0200, Hannes Reinecke wrote:
> FC-BB-6 states:
> FIP protocols shall be performed on a per-VLAN basis. It is
> recommended to use the FIP VLAN discovery protocol on the
> default VLAN.
> 
> Signed-off-by: Hannes Reinecke 

Given the removal of the duplicate fip_frame struct defition:
Acked-by: Johannes Thumshirn 

-- 
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: [PATCH 4/6] fcoe: Update multicast addresses on FIP mode change

2016-07-04 Thread Johannes Thumshirn
On Mon, Jul 04, 2016 at 10:29:21AM +0200, Hannes Reinecke wrote:
> When the FIP mode is changed we need to update the multicast
> addresses to ensure we get the correct frames.
> 
> Signed-off-by: Hannes Reinecke 

Acked-by: Johannes Thumshirn 

-- 
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: [PATCH 3/6] fcoe: fcoe->realdev is always set

2016-07-04 Thread Johannes Thumshirn
On Mon, Jul 04, 2016 at 10:29:20AM +0200, Hannes Reinecke wrote:
> '->realdev' is always set, so this check is pointless.
> 
> Signed-off-by: Hannes Reinecke 

Acked-by: Johannes Thumshirn 

-- 
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: [PATCH 2/6] fcoe: use enum for fip_mode

2016-07-04 Thread Johannes Thumshirn
On Mon, Jul 04, 2016 at 10:29:19AM +0200, Hannes Reinecke wrote:
> The FIP mode is independent on the FIP state machine, so use a
> separate enum for that instead of overloading it with state
> machine values.
> 
> Signed-off-by: Hannes Reinecke 

Acked-by: Johannes Thumshirn 

-- 
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: [PATCH 1/6] fc_fip: Update to latest FC-BB-6 draft

2016-07-04 Thread Johannes Thumshirn
On Mon, Jul 04, 2016 at 10:29:18AM +0200, Hannes Reinecke wrote:
> Update to latest FC-BB-6 draft to include FIP VN2VN VLAN notifications
> and additional flags.
> 
> Signed-off-by: Hannes Reinecke 

Acked-by: Johannes Thumshirn 

-- 
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: [PATCH 5/6] fcoe: implement FIP VLAN responder

2016-07-04 Thread Johannes Thumshirn
On Mon, Jul 04, 2016 at 10:29:22AM +0200, Hannes Reinecke wrote:
> When running in VN2VN mode there is no central instance which
> would send out any FIP VLAN discovery notifications. So this
> patch adds a new sysfs attribute 'fip_vlan_responder' which
> will activate a FIP VLAN discovery responder.
> 
> Signed-off-by: Hannes Reinecke 
> ---

[...]

> +/**
> + * fcoe_ctlr_vlan_send() - Send a FIP VLAN Notification
> + * @fip: The FCoE controller
> + * @sub: sub-opcode for vlan notification or vn2vn vlan notification
> + * @dest: The destination Ethernet MAC address
> + * @min_len: minimum size of the Ethernet payload to be sent
> + */
> +static void fcoe_ctlr_vlan_send(struct fcoe_ctlr *fip,
> +   enum fip_vlan_subcode sub,
> +   const u8 *dest)
> +{
> + struct sk_buff *skb;
> + struct fip_frame {
> + struct ethhdr eth;
> + struct fip_header fip;
> + struct fip_mac_desc mac;
> + struct fip_vlan_desc vlan;
> + } __packed * frame;

Hmmm this is the 2nd time fip_frame is defined in  fcoe_ctlr.c. I'd prefere
having the type definition somewhere else in this file and then use it in
fcoe_ctlr_vlan_send() and fcoe_ctlr_vn_send().

> + size_t len;
> + size_t dlen;
> +
> + len = sizeof(*frame);
> + dlen = sizeof(frame->mac) + sizeof(frame->vlan);
> + len = max(len, sizeof(struct ethhdr));
> +
> + skb = dev_alloc_skb(len);
> + if (!skb)
> + return;

dev_alloc_skb() uses GFP_ATOMIC so it's actually not unlikely to fail
so please return -ENOMEM here, just so the caller knows what happened.

> +
> + LIBFCOE_FIP_DBG(fip, "fip %s vlan notification, vlan %d\n",
> + fip->mode == FIP_MODE_VN2VN ? "vn2vn" : "fcf",
> + fip->lp->vlan);
> +
> + frame = (struct fip_frame *)skb->data;
> + memset(frame, 0, len);
> + memcpy(frame->eth.h_dest, dest, ETH_ALEN);
> +
> + memcpy(frame->eth.h_source, fip->ctl_src_addr, ETH_ALEN);
> + frame->eth.h_proto = htons(ETH_P_FIP);
> +
> + frame->fip.fip_ver = FIP_VER_ENCAPS(FIP_VER);
> + frame->fip.fip_op = htons(FIP_OP_VLAN);
> + frame->fip.fip_subcode = sub;
> + frame->fip.fip_dl_len = htons(dlen / FIP_BPW);
> +
> + frame->mac.fd_desc.fip_dtype = FIP_DT_MAC;
> + frame->mac.fd_desc.fip_dlen = sizeof(frame->mac) / FIP_BPW;
> + memcpy(frame->mac.fd_mac, fip->ctl_src_addr, ETH_ALEN);
> +
> + frame->vlan.fd_desc.fip_dtype = FIP_DT_VLAN;
> + frame->vlan.fd_desc.fip_dlen = sizeof(frame->vlan) / FIP_BPW;
> + put_unaligned_be16(fip->lp->vlan, >vlan.fd_vlan);
> +
> + skb_put(skb, len);
> + skb->protocol = htons(ETH_P_FIP);
> + skb->priority = fip->priority;
> + skb_reset_mac_header(skb);
> + skb_reset_network_header(skb);
> +
> + fip->send(fip, skb);
> +}

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


[PATCH 4/6] fcoe: Update multicast addresses on FIP mode change

2016-07-04 Thread Hannes Reinecke
When the FIP mode is changed we need to update the multicast
addresses to ensure we get the correct frames.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/fcoe/fcoe.c | 31 +--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 41c67e5..61eda74 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -115,7 +115,7 @@ static int fcoe_disable(struct net_device *netdev);
 /* fcoe_syfs control interface handlers */
 static int fcoe_ctlr_alloc(struct net_device *netdev);
 static int fcoe_ctlr_enabled(struct fcoe_ctlr_device *cdev);
-
+static void fcoe_ctlr_mode(struct fcoe_ctlr_device *ctlr_dev);
 
 static struct fc_seq *fcoe_elsct_send(struct fc_lport *,
  u32 did, struct fc_frame *,
@@ -146,8 +146,9 @@ static void fcoe_set_vport_symbolic_name(struct fc_vport *);
 static void fcoe_set_port_id(struct fc_lport *, u32, struct fc_frame *);
 static void fcoe_fcf_get_vlan_id(struct fcoe_fcf_device *);
 
+
 static struct fcoe_sysfs_function_template fcoe_sysfs_templ = {
-   .set_fcoe_ctlr_mode = fcoe_ctlr_set_fip_mode,
+   .set_fcoe_ctlr_mode = fcoe_ctlr_mode,
.set_fcoe_ctlr_enabled = fcoe_ctlr_enabled,
.get_fcoe_ctlr_link_fail = fcoe_ctlr_get_lesb,
.get_fcoe_ctlr_vlink_fail = fcoe_ctlr_get_lesb,
@@ -1976,6 +1977,32 @@ static int fcoe_ctlr_enabled(struct fcoe_ctlr_device 
*cdev)
 }
 
 /**
+ * fcoe_ctlr_mode() - Switch FIP mode
+ * @cdev: The FCoE Controller that is being modified
+ *
+ * When the FIP mode has been changed we need to update
+ * the multicast addresses to ensure we get the correct
+ * frames.
+ */
+static void fcoe_ctlr_mode(struct fcoe_ctlr_device *ctlr_dev)
+{
+   struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(ctlr_dev);
+   struct fcoe_interface *fcoe = fcoe_ctlr_priv(ctlr);
+
+   if (ctlr_dev->mode == FIP_CONN_TYPE_VN2VN &&
+   ctlr->mode != FIP_MODE_VN2VN) {
+   dev_mc_del(fcoe->netdev, FIP_ALL_ENODE_MACS);
+   dev_mc_add(fcoe->netdev, FIP_ALL_VN2VN_MACS);
+   dev_mc_add(fcoe->netdev, FIP_ALL_P2P_MACS);
+   } else if (ctlr->mode != FIP_MODE_FABRIC) {
+   dev_mc_del(fcoe->netdev, FIP_ALL_VN2VN_MACS);
+   dev_mc_del(fcoe->netdev, FIP_ALL_P2P_MACS);
+   dev_mc_add(fcoe->netdev, FIP_ALL_ENODE_MACS);
+   }
+   fcoe_ctlr_set_fip_mode(ctlr_dev);
+}
+
+/**
  * fcoe_destroy() - Destroy a FCoE interface
  * @netdev  : The net_device object the Ethernet interface to create on
  *
-- 
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


[PATCH 5/6] fcoe: implement FIP VLAN responder

2016-07-04 Thread Hannes Reinecke
When running in VN2VN mode there is no central instance which
would send out any FIP VLAN discovery notifications. So this
patch adds a new sysfs attribute 'fip_vlan_responder' which
will activate a FIP VLAN discovery responder.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/fcoe/fcoe.c   |   6 ++
 drivers/scsi/fcoe/fcoe_ctlr.c  | 224 +
 drivers/scsi/fcoe/fcoe_sysfs.c |  39 +++
 include/scsi/libfc.h   |   1 +
 include/scsi/libfcoe.h |   5 +-
 5 files changed, 274 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 61eda74..c8a4305 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -673,6 +673,12 @@ static int fcoe_netdev_config(struct fc_lport *lport, 
struct net_device *netdev)
fcoe = port->priv;
ctlr = fcoe_to_ctlr(fcoe);
 
+   /* Figure out the VLAN ID, if any */
+   if (netdev->priv_flags & IFF_802_1Q_VLAN)
+   lport->vlan = vlan_dev_vlan_id(netdev);
+   else
+   lport->vlan = 0;
+
/*
 * Determine max frame size based on underlying device and optional
 * user-configured limit.  If the MFS is too low, fcoe_link_ok()
diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index 26a0685..32988e6 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -59,6 +59,8 @@ static int fcoe_ctlr_vn_recv(struct fcoe_ctlr *, struct 
sk_buff *);
 static void fcoe_ctlr_vn_timeout(struct fcoe_ctlr *);
 static int fcoe_ctlr_vn_lookup(struct fcoe_ctlr *, u32, u8 *);
 
+static int fcoe_ctlr_vlan_recv(struct fcoe_ctlr *, struct sk_buff *);
+
 static u8 fcoe_all_fcfs[ETH_ALEN] = FIP_ALL_FCF_MACS;
 static u8 fcoe_all_enode[ETH_ALEN] = FIP_ALL_ENODE_MACS;
 static u8 fcoe_all_vn2vn[ETH_ALEN] = FIP_ALL_VN2VN_MACS;
@@ -149,6 +151,7 @@ void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_state 
mode)
 {
fcoe_ctlr_set_state(fip, FIP_ST_LINK_WAIT);
fip->mode = mode;
+   fip->fip_resp = false;
INIT_LIST_HEAD(>fcfs);
mutex_init(>ctlr_mutex);
spin_lock_init(>ctlr_lock);
@@ -1513,6 +1516,7 @@ static int fcoe_ctlr_recv_handler(struct fcoe_ctlr *fip, 
struct sk_buff *skb)
struct fip_header *fiph;
struct ethhdr *eh;
enum fip_state state;
+   bool fip_vlan_resp = false;
u16 op;
u8 sub;
 
@@ -1546,11 +1550,17 @@ static int fcoe_ctlr_recv_handler(struct fcoe_ctlr 
*fip, struct sk_buff *skb)
state = FIP_ST_ENABLED;
LIBFCOE_FIP_DBG(fip, "Using FIP mode\n");
}
+   fip_vlan_resp = fip->fip_resp;
mutex_unlock(>ctlr_mutex);
 
if (fip->mode == FIP_MODE_VN2VN && op == FIP_OP_VN2VN)
return fcoe_ctlr_vn_recv(fip, skb);
 
+   if (fip_vlan_resp && op == FIP_OP_VLAN) {
+   LIBFCOE_FIP_DBG(fip, "fip vlan discovery\n");
+   return fcoe_ctlr_vlan_recv(fip, skb);
+   }
+
if (state != FIP_ST_ENABLED && state != FIP_ST_VNMP_UP &&
state != FIP_ST_VNMP_CLAIM)
goto drop;
@@ -2704,6 +2714,220 @@ drop:
 }
 
 /**
+ * fcoe_ctlr_vlan_parse - parse vlan discovery request or response
+ * @fip: The FCoE controller
+ * @skb: incoming packet
+ * @rdata: buffer for resulting parsed VLAN entry plus fcoe_rport
+ *
+ * Returns non-zero error number on error.
+ * Does not consume the packet.
+ */
+static int fcoe_ctlr_vlan_parse(struct fcoe_ctlr *fip,
+ struct sk_buff *skb,
+ struct fc_rport_priv *rdata)
+{
+   struct fip_header *fiph;
+   struct fip_desc *desc = NULL;
+   struct fip_mac_desc *macd = NULL;
+   struct fip_wwn_desc *wwn = NULL;
+   struct fcoe_rport *frport;
+   size_t rlen;
+   size_t dlen;
+   u32 desc_mask = 0;
+   u32 dtype;
+   u8 sub;
+
+   memset(rdata, 0, sizeof(*rdata) + sizeof(*frport));
+   frport = fcoe_ctlr_rport(rdata);
+
+   fiph = (struct fip_header *)skb->data;
+   frport->flags = ntohs(fiph->fip_flags);
+
+   sub = fiph->fip_subcode;
+   switch (sub) {
+   case FIP_SC_VL_REQ:
+   desc_mask = BIT(FIP_DT_MAC) | BIT(FIP_DT_NAME);
+   break;
+   default:
+   LIBFCOE_FIP_DBG(fip, "vn_parse unknown subcode %u\n", sub);
+   return -EINVAL;
+   }
+
+   rlen = ntohs(fiph->fip_dl_len) * 4;
+   if (rlen + sizeof(*fiph) > skb->len)
+   return -EINVAL;
+
+   desc = (struct fip_desc *)(fiph + 1);
+   while (rlen > 0) {
+   dlen = desc->fip_dlen * FIP_BPW;
+   if (dlen < sizeof(*desc) || dlen > rlen)
+   return -EINVAL;
+
+   dtype = desc->fip_dtype;
+   if (dtype < 32) {
+   if (!(desc_mask & BIT(dtype))) {
+   LIBFCOE_FIP_DBG(fip,
+  

[PATCH 0/6] fcoe: VN2VN target mode fixes

2016-07-04 Thread Hannes Reinecke
Hi all,

When setting up a VN2VN FCoE target there is no real need to
run fcoeadm, especially if DCB is disabled.
So this patchset implements a VIP VLAN responder which can be
enabled by writing to the sysfs attribute 'fip_vlan_responder'.
Additionally there are some fixes for VN2VN mode, most notably
the multicast address update when changing modes.

As usual, comments and reviews are welcome.

Hannes Reinecke (6):
  fc_fip: Update to latest FC-BB-6 draft
  fcoe: use enum for fip_mode
  fcoe: fcoe->realdev is always set
  fcoe: Update multicast addresses on FIP mode change
  fcoe: implement FIP VLAN responder
  fcoe: Use default VLAN for FIP VLAN discovery

 drivers/scsi/bnx2fc/bnx2fc_fcoe.c |   6 +-
 drivers/scsi/fcoe/fcoe.c  |  95 ++--
 drivers/scsi/fcoe/fcoe.h  |   1 +
 drivers/scsi/fcoe/fcoe_ctlr.c | 234 +-
 drivers/scsi/fcoe/fcoe_sysfs.c|  39 +++
 drivers/scsi/fnic/fnic_fcs.c  |   6 +-
 drivers/scsi/fnic/fnic_fip.h  |   8 --
 include/scsi/fc/fc_fip.h  |  21 +++-
 include/scsi/libfc.h  |   1 +
 include/scsi/libfcoe.h|  19 ++--
 10 files changed, 391 insertions(+), 39 deletions(-)

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


[PATCH 6/6] fcoe: Use default VLAN for FIP VLAN discovery

2016-07-04 Thread Hannes Reinecke
FC-BB-6 states:
FIP protocols shall be performed on a per-VLAN basis. It is
recommended to use the FIP VLAN discovery protocol on the
default VLAN.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/fcoe/fcoe.c | 49 +++-
 drivers/scsi/fcoe/fcoe.h |  1 +
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index c8a4305..197dc62 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -92,6 +92,8 @@ static struct fcoe_interface
 
 static int fcoe_fip_recv(struct sk_buff *, struct net_device *,
 struct packet_type *, struct net_device *);
+static int fcoe_fip_vlan_recv(struct sk_buff *, struct net_device *,
+ struct packet_type *, struct net_device *);
 
 static void fcoe_fip_send(struct fcoe_ctlr *, struct sk_buff *);
 static void fcoe_update_src_mac(struct fc_lport *, u8 *);
@@ -363,6 +365,12 @@ static int fcoe_interface_setup(struct fcoe_interface 
*fcoe,
fcoe->fip_packet_type.dev = netdev;
dev_add_pack(>fip_packet_type);
 
+   if (netdev != real_dev) {
+   fcoe->fip_vlan_packet_type.func = fcoe_fip_vlan_recv;
+   fcoe->fip_vlan_packet_type.type = htons(ETH_P_FIP);
+   fcoe->fip_vlan_packet_type.dev = real_dev;
+   dev_add_pack(>fip_vlan_packet_type);
+   }
return 0;
 }
 
@@ -450,6 +458,8 @@ static void fcoe_interface_remove(struct fcoe_interface 
*fcoe)
 */
__dev_remove_pack(>fcoe_packet_type);
__dev_remove_pack(>fip_packet_type);
+   if (netdev != fcoe->realdev)
+   __dev_remove_pack(>fip_vlan_packet_type);
synchronize_net();
 
/* Delete secondary MAC addresses */
@@ -520,6 +530,29 @@ static int fcoe_fip_recv(struct sk_buff *skb, struct 
net_device *netdev,
 }
 
 /**
+ * fcoe_fip_vlan_recv() - Handler for received FIP VLAN discovery frames
+ * @skb:  The receive skb
+ * @netdev:   The associated net device
+ * @ptype:The packet_type structure which was used to register this handler
+ * @orig_dev: The original net_device the the skb was received on.
+ *   (in case dev is a bond)
+ *
+ * Returns: 0 for success
+ */
+static int fcoe_fip_vlan_recv(struct sk_buff *skb, struct net_device *netdev,
+ struct packet_type *ptype,
+ struct net_device *orig_dev)
+{
+   struct fcoe_interface *fcoe;
+   struct fcoe_ctlr *ctlr;
+
+   fcoe = container_of(ptype, struct fcoe_interface, fip_vlan_packet_type);
+   ctlr = fcoe_to_ctlr(fcoe);
+   fcoe_ctlr_recv(ctlr, skb);
+   return 0;
+}
+
+/**
  * fcoe_port_send() - Send an Ethernet-encapsulated FIP/FCoE frame
  * @port: The FCoE port
  * @skb: The FIP/FCoE packet to be sent
@@ -539,7 +572,21 @@ static void fcoe_port_send(struct fcoe_port *port, struct 
sk_buff *skb)
  */
 static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb)
 {
-   skb->dev = fcoe_from_ctlr(fip)->netdev;
+   struct fcoe_interface *fcoe = fcoe_from_ctlr(fip);
+   struct fip_frame {
+   struct ethhdr eth;
+   struct fip_header fip;
+   } __packed *frame;
+
+   /*
+* Use default VLAN for FIP VLAN discovery protocol
+*/
+   frame = (struct fip_frame *)skb->data;
+   if (frame->fip.fip_op == ntohs(FIP_OP_VLAN) &&
+   fcoe->realdev != fcoe->netdev)
+   skb->dev = fcoe->realdev;
+   else
+   skb->dev = fcoe->netdev;
fcoe_port_send(lport_priv(fip->lp), skb);
 }
 
diff --git a/drivers/scsi/fcoe/fcoe.h b/drivers/scsi/fcoe/fcoe.h
index 2b53672..6aa4820 100644
--- a/drivers/scsi/fcoe/fcoe.h
+++ b/drivers/scsi/fcoe/fcoe.h
@@ -80,6 +80,7 @@ struct fcoe_interface {
struct net_device  *realdev;
struct packet_type fcoe_packet_type;
struct packet_type fip_packet_type;
+   struct packet_type fip_vlan_packet_type;
struct fc_exch_mgr *oem;
u8  removed;
u8  priority;
-- 
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


[PATCH 2/6] fcoe: use enum for fip_mode

2016-07-04 Thread Hannes Reinecke
The FIP mode is independent on the FIP state machine, so use a
separate enum for that instead of overloading it with state
machine values.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c |  6 +++---
 drivers/scsi/fcoe/fcoe.c  |  6 +++---
 drivers/scsi/fcoe/fcoe_ctlr.c |  2 +-
 drivers/scsi/fnic/fnic_fcs.c  |  2 +-
 include/scsi/libfcoe.h| 14 --
 5 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index d6800af..a5052dd 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -57,7 +57,7 @@ static struct scsi_host_template bnx2fc_shost_template;
 static struct fc_function_template bnx2fc_transport_function;
 static struct fcoe_sysfs_function_template bnx2fc_fcoe_sysfs_templ;
 static struct fc_function_template bnx2fc_vport_xport_function;
-static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode);
+static int bnx2fc_create(struct net_device *netdev, enum fip_mode fip_mode);
 static void __bnx2fc_destroy(struct bnx2fc_interface *interface);
 static int bnx2fc_destroy(struct net_device *net_device);
 static int bnx2fc_enable(struct net_device *netdev);
@@ -2260,7 +2260,7 @@ enum bnx2fc_create_link_state {
  * Returns: 0 for success
  */
 static int _bnx2fc_create(struct net_device *netdev,
- enum fip_state fip_mode,
+ enum fip_mode fip_mode,
  enum bnx2fc_create_link_state link_state)
 {
struct fcoe_ctlr_device *cdev;
@@ -2412,7 +2412,7 @@ mod_err:
  *
  * Returns: 0 for success
  */
-static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode)
+static int bnx2fc_create(struct net_device *netdev, enum fip_mode fip_mode)
 {
return _bnx2fc_create(netdev, fip_mode, BNX2FC_CREATE_LINK_UP);
 }
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index f7c7ccc..9c3742d 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -107,7 +107,7 @@ static int fcoe_dcb_app_notification(struct notifier_block 
*notifier,
 ulong event, void *ptr);
 
 static bool fcoe_match(struct net_device *netdev);
-static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode);
+static int fcoe_create(struct net_device *netdev, enum fip_mode fip_mode);
 static int fcoe_destroy(struct net_device *netdev);
 static int fcoe_enable(struct net_device *netdev);
 static int fcoe_disable(struct net_device *netdev);
@@ -2133,7 +2133,7 @@ enum fcoe_create_link_state {
  * consolidation of code can be done when that interface is
  * removed.
  */
-static int _fcoe_create(struct net_device *netdev, enum fip_state fip_mode,
+static int _fcoe_create(struct net_device *netdev, enum fip_mode fip_mode,
enum fcoe_create_link_state link_state)
 {
int rc = 0;
@@ -,7 +,7 @@ out:
  *
  * Returns: 0 for success
  */
-static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode)
+static int fcoe_create(struct net_device *netdev, enum fip_mode fip_mode)
 {
return _fcoe_create(netdev, fip_mode, FCOE_CREATE_LINK_UP);
 }
diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index 34b2b43..26a0685 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -2864,7 +2864,7 @@ unlock:
  * when nothing is happening.
  */
 static void fcoe_ctlr_mode_set(struct fc_lport *lport, struct fcoe_ctlr *fip,
-  enum fip_state fip_mode)
+  enum fip_mode fip_mode)
 {
void *priv;
 
diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c
index fe402d0..0d532ae 100644
--- a/drivers/scsi/fnic/fnic_fcs.c
+++ b/drivers/scsi/fnic/fnic_fcs.c
@@ -1308,7 +1308,7 @@ void fnic_handle_fip_timer(struct fnic *fnic)
}
spin_unlock_irqrestore(>fnic_lock, flags);
 
-   if (fnic->ctlr.mode == FIP_ST_NON_FIP)
+   if (fnic->ctlr.mode == FIP_MODE_NON_FIP)
return;
 
spin_lock_irqsave(>vlans_lock, flags);
diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h
index c6fbbb6..bcc5c3e 100644
--- a/include/scsi/libfcoe.h
+++ b/include/scsi/libfcoe.h
@@ -78,10 +78,12 @@ enum fip_state {
  * The mode is the state that is to be entered after link up.
  * It must not change after fcoe_ctlr_init() sets it.
  */
-#define FIP_MODE_AUTO  FIP_ST_AUTO
-#define FIP_MODE_NON_FIP   FIP_ST_NON_FIP
-#define FIP_MODE_FABRICFIP_ST_ENABLED
-#define FIP_MODE_VN2VN FIP_ST_VNMP_START
+enum fip_mode {
+   FIP_MODE_AUTO = FIP_ST_AUTO,
+   FIP_MODE_NON_FIP,
+   FIP_MODE_FABRIC,
+   FIP_MODE_VN2VN,
+};
 
 /**
  * struct fcoe_ctlr - FCoE Controller and FIP state
@@ -124,7 +126,7 @@ enum fip_state {
  */
 struct fcoe_ctlr {
enum fip_state state;
-   

[PATCH 1/6] fc_fip: Update to latest FC-BB-6 draft

2016-07-04 Thread Hannes Reinecke
Update to latest FC-BB-6 draft to include FIP VN2VN VLAN notifications
and additional flags.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/fcoe/fcoe_ctlr.c |  8 
 drivers/scsi/fnic/fnic_fcs.c  |  4 ++--
 drivers/scsi/fnic/fnic_fip.h  |  8 
 include/scsi/fc/fc_fip.h  | 21 +
 4 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index ada4bde..34b2b43 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -991,7 +991,7 @@ static int fcoe_ctlr_parse_adv(struct fcoe_ctlr *fip,
LIBFCOE_FIP_DBG(fip, "unexpected descriptor type %x "
"in FIP adv\n", desc->fip_dtype);
/* standard says ignore unknown descriptors >= 128 */
-   if (desc->fip_dtype < FIP_DT_VENDOR_BASE)
+   if (desc->fip_dtype < FIP_DT_NON_CRITICAL)
return -EINVAL;
break;
}
@@ -1232,7 +1232,7 @@ static void fcoe_ctlr_recv_els(struct fcoe_ctlr *fip, 
struct sk_buff *skb)
LIBFCOE_FIP_DBG(fip, "unexpected descriptor type %x "
"in FIP adv\n", desc->fip_dtype);
/* standard says ignore unknown descriptors >= 128 */
-   if (desc->fip_dtype < FIP_DT_VENDOR_BASE)
+   if (desc->fip_dtype < FIP_DT_NON_CRITICAL)
goto drop;
if (desc_cnt <= 2) {
LIBFCOE_FIP_DBG(fip, "FIP descriptors "
@@ -1410,7 +1410,7 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr 
*fip,
break;
default:
/* standard says ignore unknown descriptors >= 128 */
-   if (desc->fip_dtype < FIP_DT_VENDOR_BASE)
+   if (desc->fip_dtype < FIP_DT_NON_CRITICAL)
goto err;
break;
}
@@ -2338,7 +2338,7 @@ static int fcoe_ctlr_vn_parse(struct fcoe_ctlr *fip,
LIBFCOE_FIP_DBG(fip, "unexpected descriptor type %x "
"in FIP probe\n", dtype);
/* standard says ignore unknown descriptors >= 128 */
-   if (dtype < FIP_DT_VENDOR_BASE)
+   if (dtype < FIP_DT_NON_CRITICAL)
return -EINVAL;
break;
}
diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c
index 67669a9..fe402d0 100644
--- a/drivers/scsi/fnic/fnic_fcs.c
+++ b/drivers/scsi/fnic/fnic_fcs.c
@@ -359,7 +359,7 @@ static void fnic_fcoe_send_vlan_req(struct fnic *fnic)
 
vlan->fip.fip_ver = FIP_VER_ENCAPS(FIP_VER);
vlan->fip.fip_op = htons(FIP_OP_VLAN);
-   vlan->fip.fip_subcode = FIP_SC_VL_REQ;
+   vlan->fip.fip_subcode = FIP_SC_VL_NOTE;
vlan->fip.fip_dl_len = htons(sizeof(vlan->desc) / FIP_BPW);
 
vlan->desc.mac.fd_desc.fip_dtype = FIP_DT_MAC;
@@ -551,7 +551,7 @@ static int fnic_fcoe_handle_fip_frame(struct fnic *fnic, 
struct sk_buff *skb)
goto drop;
/* pass it on to fcoe */
ret = 1;
-   } else if (op == FIP_OP_VLAN && sub == FIP_SC_VL_REP) {
+   } else if (op == FIP_OP_VLAN && sub == FIP_SC_VL_NOTE) {
/* set the vlan as used */
fnic_fcoe_process_vlan_resp(fnic, skb);
ret = 0;
diff --git a/drivers/scsi/fnic/fnic_fip.h b/drivers/scsi/fnic/fnic_fip.h
index 87e74c2..7761f33 100644
--- a/drivers/scsi/fnic/fnic_fip.h
+++ b/drivers/scsi/fnic/fnic_fip.h
@@ -26,14 +26,6 @@
 
 #define FINC_MAX_FLOGI_REJECTS   8
 
-/*
- * FIP_DT_VLAN descriptor.
- */
-struct fip_vlan_desc {
-   struct fip_desc fd_desc;
-   __be16 fd_vlan;
-} __attribute__((packed));
-
 struct vlan {
__be16 vid;
__be16 type;
diff --git a/include/scsi/fc/fc_fip.h b/include/scsi/fc/fc_fip.h
index ae25d4a..9710254 100644
--- a/include/scsi/fc/fc_fip.h
+++ b/include/scsi/fc/fc_fip.h
@@ -22,7 +22,7 @@
 /*
  * This version is based on:
  * http://www.t11.org/ftp/t11/pub/fc/bb-5/08-543v1.pdf
- * and T11 FC-BB-6 10-019v4.pdf (June 2010 VN2VN proposal)
+ * and T11 FC-BB-6 13-091v5.pdf (December 2013 VN2VN proposal)
  */
 
 #define FIP_DEF_PRI128 /* default selection priority */
@@ -109,8 +109,9 @@ enum fip_reset_subcode {
  * Subcodes for FIP_OP_VLAN.
  */
 enum fip_vlan_subcode {
-   FIP_SC_VL_REQ = 1,  /* request */
-   FIP_SC_VL_REP = 2,  /* reply */
+   FIP_SC_VL_REQ = 1,  /* vlan request */
+   FIP_SC_VL_NOTE = 2, /* vlan notification */
+   FIP_SC_VL_VN2VN_NOTE = 3,   /* VN2VN vlan notification */
 };
 
 

[PATCH 3/6] fcoe: fcoe->realdev is always set

2016-07-04 Thread Hannes Reinecke
'->realdev' is always set, so this check is pointless.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/fcoe/fcoe.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 9c3742d..41c67e5 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -770,9 +770,6 @@ static void fcoe_fdmi_info(struct fc_lport *lport, struct 
net_device *netdev)
fcoe = port->priv;
realdev = fcoe->realdev;
 
-   if (!realdev)
-   return;
-
/* No FDMI state m/c for NPIV ports */
if (lport->vport)
return;
-- 
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: [PATCH v2] scsi/fcoe: convert to kworker

2016-07-04 Thread Sebastian Andrzej Siewior
On 06/10/2016 12:38 PM, Johannes Thumshirn wrote:
…

> 
> Tested in a Boot from FCoE scenario using a BCM57840.

This got merged over the weekend. Thanks for that. I will try to look
into the other two (bnx2i, bnx2fc) and convert them as well within this
week.

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


how to test pscsi with vhost

2016-07-04 Thread Zhangfei Gao
I am testing with pscsi, but fail to find any block device under /dev to mount.
The scsi_probe_lun seems can not return correctly, scsi scan: INQUIRY failes.

Is this usage correct?

/backstores/pscsi> create name=pscsi_backend dev=/dev/sdb
Note: block backstore recommended for SCSI block devices
Created pscsi storage object pscsi_backend using /dev/sdb

/backstores/pscsi> cd /vhost
/vhost> create wwn=naa.60014052cc816bf4
/vhost> cd naa.60014052cc816bf4/tpg1/luns
/vhost/naa.60...bf4/tpg1/luns> create /backstores/pscsi/pscsi_backend
Selected LUN 0.
Created LUN 0.

/vhost/naa.60...bf4/tpg1/luns> cd /
/> ls
o- / . [...]
  o- backstores .. [...]
  | o- fileio ... [0 Storage Object]
  | o- iblock ... [0 Storage Object]
  | o- pscsi  [1 Storage Object]
  | | o- pscsi_backend  [/dev/sdb activated]
  | o- rd_mcp ... [0 Storage Object]
  o- iscsi . [0 Targets]
  o- loopback .. [0 Targets]
  o- vhost .. [1 Target]
o- naa.60014052cc816bf4  [1 TPG]
  o- tpg1 ... [naa.6001405030badd8a]
o- luns  [1 LUN]
  o- lun0 . [pscsi/pscsi_backend (/dev/sdb)]
/>

/> saveconfig


qemu.git/aarch64-softmmu/qemu-system-aarch64 \
-enable-kvm -nographic -kernel Image \
-device vhost-scsi-pci,wwpn=naa.60014052cc816bf4 \
-m 512 -M virt -cpu host \
-append "earlyprintk console=ttyAMA0 mem=512M"


root@(none)$ ls /dev
autofs  ptyp8   tty30   tty62
console ptyp9   tty31   tty63
cpu_dma_latency ptypa   tty32   tty7
cuseptypb   tty33   tty8
fullptypc   tty34   tty9
fuseptypd   tty35   ttyAMA0
input   ptype   tty36   ttyS0
kmemptypf   tty37   ttyS1
kmsgrandom  tty38   ttyS2
loop-controlsnd tty39   ttyS3
loop0   tty tty4ttyp0
loop1   tty0tty40   ttyp1
loop2   tty1tty41   ttyp2
loop3   tty10   tty42   ttyp3
loop4   tty11   tty43   ttyp4
loop5   tty12   tty44   ttyp5
loop6   tty13   tty45   ttyp6
loop7   tty14   tty46   ttyp7
mem tty15   tty47   ttyp8
memory_bandwidthtty16   tty48   ttyp9
net tty17   tty49   ttypa
network_latency tty18   tty5ttypb
network_throughput  tty19   tty50   ttypc
nulltty2tty51   ttypd
porttty20   tty52   ttype
psaux   tty21   tty53   ttypf
ptmxtty22   tty54   urandom
ptyp0   tty23   tty55   vcs
ptyp1   tty24   tty56   vcs1
ptyp2   tty25   tty57   vcsa
ptyp3   tty26   tty58   vcsa1
ptyp4   tty27   tty59   vga_arbiter
ptyp5   tty28   tty6vhost-scsi
ptyp6   tty29   tty60   zero
ptyp7   tty3tty61

Thanks
--
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] cxl: remove dead Kconfig options

2016-07-04 Thread Andrew Donnellan
Remove the CXL_KERNEL_API and CXL_EEH Kconfig options, as they were only
needed to coordinate the merging of the cxlflash driver. Also remove the
stub implementation of cxl_perst_reloads_same_image() in cxlflash which is
only used if CXL_EEH isn't defined (i.e. never).

Suggested-by: Ian Munsie 
Signed-off-by: Andrew Donnellan 

---

Applies on top of powerpc#next
---
 drivers/misc/cxl/Kconfig | 10 --
 drivers/scsi/cxlflash/main.h |  4 
 2 files changed, 14 deletions(-)

diff --git a/drivers/misc/cxl/Kconfig b/drivers/misc/cxl/Kconfig
index 560412c..0cb10cf 100644
--- a/drivers/misc/cxl/Kconfig
+++ b/drivers/misc/cxl/Kconfig
@@ -7,14 +7,6 @@ config CXL_BASE
default n
select PPC_COPRO_BASE
 
-config CXL_KERNEL_API
-   bool
-   default n
-
-config CXL_EEH
-   bool
-   default n
-
 config CXL_AFU_DRIVER_OPS
bool
default n
@@ -23,8 +15,6 @@ config CXL
tristate "Support for IBM Coherent Accelerators (CXL)"
depends on PPC_POWERNV && PCI_MSI && EEH
select CXL_BASE
-   select CXL_KERNEL_API
-   select CXL_EEH
select CXL_AFU_DRIVER_OPS
default m
help
diff --git a/drivers/scsi/cxlflash/main.h b/drivers/scsi/cxlflash/main.h
index eb9d8f7..a893408 100644
--- a/drivers/scsi/cxlflash/main.h
+++ b/drivers/scsi/cxlflash/main.h
@@ -100,8 +100,4 @@ struct asyc_intr_info {
 #define SCAN_HOST  0x04
 };
 
-#ifndef CONFIG_CXL_EEH
-#define cxl_perst_reloads_same_image(_a, _b) do { } while (0)
-#endif
-
 #endif /* _CXLFLASH_MAIN_H */
-- 
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited

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