[RFC] UASP gadget using target framework

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

 



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.

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

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