Re: [RFC] UASP gadget using target framework

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2011-12-08 at 18:30 +0100, Sebastian Andrzej Siewior wrote:
> This seem to work now and needs some further hacking. This was tested with
> dummy_hcd on a local machine on top of target/master. HS works, SS +
> stream support are most likely my next steps.
> 

Good work !

I have a few comments on the two target patches that I'll put inline.

Also, I'd like to include some examples with targetcli/rtslib+uasp.spec
for fun for folks to follow along.  :)

> This is a new gadget serving the UASP and using the target framework for
> scsi command processing, storage etc. It is like scsi_add_host() but for
> the other side :)
> 
> If there is anything one does not like please let me know. Here and there
> are a few hacks which I need to get rid of. Patch 3 is a good example :)
> 
> The gadget is configured via configfs like the remaining part of the
> target framework. Hope you like it.
> 
> Everyone who wants to give it a shot, here is a brief howto:
> 
> 1. Load the required drivers & setup environment
>   modprobe dummy_hcd
>   modprobe target_core_mod
>   modprobe tcm_uasp
>   mount a -t configfs /sys/kernel/config
>   
>   CONFIGFS=/sys/kernel/config/;
>   TARGET=$CONFIGFS/target/core/
>   FABRIC=$CONFIGFS/target/uasp/
> 
> 2. Create / setup storage.
> You can choose whatever target offers you. That is ramdisk, file, block
> device or a pure a scsi device. Here are two examples:
> 
>   # ramdisk with 32768 pages (~128 MiB)
>   mkdir -p $TARGET/rd_mcp_0/ramdisk
>   echo rd_pages=32768 > $TARGET/rd_mcp_0/ramdisk/control
>   echo 1 > $TARGET/rd_mcp_0/ramdisk/enable
>   
>   # file backend with 30 MiB storage. Created on demand.
>   mkdir -p $TARGET/fileio_0/fileio
>   echo "fd_dev_name=/root/file.bin,fd_dev_size=31457280" > $TARGET/fileio_0/fileio/control
>   echo 1 > $TARGET/fileio_0/fileio/enable
> 
> 3. Create a new target / device with one LUN
> 
>    mkdir -p $FABRIC/naa.6001405c3214b06a/tpgt_1
>    mkdir $FABRIC/naa.6001405c3214b06a/tpgt_1/lun/lun_0
>    echo naa.6001405c3214b06b > $FABRIC/naa.6001405c3214b06a/tpgt_1/nexus
> 
>    ln -s $TARGET/rd_mcp_0/ramdisk $FABRIC/naa.6001405c3214b06a/tpgt_1/lun/lun_0/virtual_scsi_port
> 
> 4. Connect the gadget
> Other gadgets do this from the very beginning during modprobe. I avoided
> it so I don't expose an "unconfigured" gadget. If this is "okay" and there
> is a way to detect the new LUNs later on then I think it can be dropped.
> 
>    echo 1 > /sys/kernel/config/target/uasp/naa.6001405c3214b06a/tpgt_1/gadget_connect
> 

So for /sys/kernel/config/target/uasp to work transparently with
existing fabric independent aspects for targetcli shell and rtslib
python object library, the extra per endpoint target 'gadget_connect'
attribute usage needs to change slightly..

For example, we currently have fabrics like iscsi-target and tcm_qla2xxx
that use a per Target endpoint '$FABRIC/$TARGET_WWPN/$TPGT/enable' flag
to control respectively when iSCSI initiators may or may-not perform new
login or when per qla_hw_data FC port enables or disables target-mode
operation.  We also have fabrics like tcm_loop and tcm_vhost that don't
use 'enabled', but expect 'echo $NAA_WWN >  ../nexus' to be set when
when adding/removing fabric LUNs symlinks.

I think uasp is currently unique in the sense that it does not support
dynamic LUNs and needs both types of usage to set the nexus attribute ->
configure LUNs -> set gadget connect,   For existing target userspace,
performing using 'enabled' for gadget_connect would mean to:

* Run 'echo 1 > ../enable' only after saved LUN configuration re-init
during individual target endpoint restart bringup.
* Run 'echo 0 > ../enable' for gadget disconnected before attempting
unlink and rmdir during target fabric endpoint shutdown of active uasp
LUNs.

We will need to double check is which cases targetcli/rtslib may already
automatically perform 'echo 1 > ../enable', but if this presents an
issue we can consider a new rtslib fabric feature to signal the special
case with uasp.  (jxm CC'ed)

Thanks!

--nab

> 5. Look at dmesg
> You should see something like:
> | usbcore: registered new interface driver usbfs
> | usbcore: registered new interface driver hub
> | usbcore: registered new device driver usb
> | dummy_hcd dummy_hcd: USB Host+Gadget Emulator, driver 02 May 2005
> | dummy_hcd dummy_hcd: Dummy host controller
> | dummy_hcd dummy_hcd: new USB bus registered, assigned bus number 1
> | usb usb1: default language 0x0409
> | usb usb1: udev 1, busnum 1, minor = 0
> | usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
> | usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
> | usb usb1: Product: Dummy host controller
> | usb usb1: Manufacturer: Linux 3.2.0-rc4+ dummy_hcd
> | usb usb1: SerialNumber: dummy_hcd
> | usb usb1: usb_probe_device
> | usb usb1: configuration #1 chosen from 1 choice
> | usb usb1: adding 1-0:1.0 (config #1, interface 0)
> | hub 1-0:1.0: usb_probe_interface
> | hub 1-0:1.0: usb_probe_interface - got id
> | hub 1-0:1.0: USB hub found
> | hub 1-0:1.0: 1 port detected
> | hub 1-0:1.0: standalone hub
> | hub 1-0:1.0: individual port power switching
> | hub 1-0:1.0: global over-current protection
> | hub 1-0:1.0: Single TT
> | hub 1-0:1.0: TT requires at most 8 FS bit times (666 ns)
> | hub 1-0:1.0: power on to power good time: 0ms
> | hub 1-0:1.0: local power source is good
> | hub 1-0:1.0: no over-current condition exists
> | hub 1-0:1.0: enabling power on all ports
> | UASP fabric module v0.1 on Linux/i686 on 3.2.0-rc4+
> | UASP[0] - Set fabric -> uasp_fabric_configfs
> |  gadget: g_uas ready
> | hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0002
> | hub 1-0:1.0: port 1, status 0101, change 0001, 12 Mb/s
> | hub 1-0:1.0: debounce: port 1: total 100ms stable 100ms status 0x101
> | usb 1-1: new high-speed USB device number 2 using dummy_hcd
> | usb 1-1: skipped 1 descriptor after endpoint
> | usb 1-1: skipped 1 descriptor after endpoint
> | usb 1-1: skipped 1 descriptor after endpoint
> | usb 1-1: skipped 1 descriptor after endpoint
> | usb 1-1: default language 0x0409
> | usb 1-1: udev 2, busnum 1, minor = 1
> | usb 1-1: New USB device found, idVendor=0525, idProduct=a4a5
> | usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> | usb 1-1: Product: UAS Product
> | usb 1-1: Manufacturer: UAS Manufactor
> | usb 1-1: SerialNumber: UAS Serial
> | usb 1-1: usb_probe_device
> | usb 1-1: configuration #1 chosen from 1 choice
> |  gadget: high-speed config #1: Linux UASP Storage
> | usb 1-1: adding 1-1:1.0 (config #1, interface 0)
> | hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0002
> | uas 1-1:1.0: usb_probe_interface
> | uas 1-1:1.0: usb_probe_interface - got id
> | scsi0 : uas
> | usbcore: registered new interface driver uas
> | scsi 0:0:0:0: Direct-Access     LIO-ORG  RAMDISK-MCP      4.0  PQ: 0 ANSI: 5
> | sd 0:0:0:0: [sda] 262144 512-byte logical blocks: (134 MB/128 MiB)
> | sd 0:0:0:0: [sda] Write Protect is off
> | sd 0:0:0:0: [sda] Mode Sense: 2f 00 00 00
> | sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
> |  sda: unknown partition table
> | sd 0:0:0:0: [sda] Attached SCSI disk
> 
> Sebastian
> 
> --
> To unsubscribe from this list: send the line "unsubscribe target-devel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux