# FreeBSD 10 as FC target



## Maed (May 25, 2014)

Hello!
Tried to use FreeBSD 10 as Fibre channel target for my home lab with no luck! I already googled alot for some "guide" or "tutorial", but no luck. 
The hardware:
1. The server: It is an old ProLiant 385 with PICe 4GB Qlogic 2460 single channel FC card (QLA2432 in FreeBSD);
2. The client: It is an old IBM desktop with some PCI-X 2GB Qlogic 2312 single channel FC card;
3. HP OM3 LC-LC fiber cable.

My server's `uname`:

```
#uname -a
FreeBSD FreeBSDTest 10.0-RELEASE FreeBSD 10.0-RELEASE #0: Wed May 21 21:27:40 EEST 2014     maed@FreeBSDTest:/usr/obj/usr/src/sys/FCSTORAGE  amd64
```
Step-by-step actions:
Options I added to GENERIC kernel (renamed it as FCSTORAGE):

```
device isp
device ispfw
options         ISP_TARGET_MODE
options         ISP_DEFAULT_ROLES=1
```
I do not modify /boot/loader.conf.
Next, I built and installed the new kernel successfully. Rebooted the server and checked for FC port in `ctladm` output:

```
# ctladm port -l
Port Online Type     Name         pp vp WWNN               WWPN
0    NO     IOCTL    CTL ioctl    0  0  0                  0
1    NO     INTERNAL CTL internal 0  0  0                  0
2    NO     ISCSI    iscsi        0  0  0                  0
3    NO     INTERNAL ctl2cam      0  0  0x5000000f7ee16700 0x5000000f7ee16704
4    NO     FC       isp0         0  0  0                  0
```
FC port is here. Now try to create LUN using file as block device:

```
#ctladm create -b block -o file=/storage/lun0 -s 30000000000
LUN created successfully
backend:       block
device type:   0
LUN size:      30000000000 bytes
blocksize      512 bytes
LUN ID:        0
Serial Number: MYSERIAL   0
Device ID;     MYDEVID   0
```
Also, I checked the `devlist` output:

```
#ctladm devlist
LUN Backend       Size (Blocks)   BS Serial Number    Device ID
  0 block              58593750  512 MYSERIAL   0     MYDEVID   0
```
Next, I enabled all ports

```
# ctladm port -o on
Front End Ports enabled
```
The info about hew SCSI device appeared at console :

```
May 25 10:42:33 FreeBSDTest kernel: (7:1:0:0): <FREEBSD CTLDISK 0001> Fixed Direct Access SCSI-5 device
May 25 10:42:33 FreeBSDTest kernel: (7:1:0:0):  58593750 blocks, blocksize 512
May 25 10:42:33 FreeBSDTest kernel: da1 at ctl2cam0 bus 0 scbus5 target 1 lun 0
May 25 10:42:33 FreeBSDTest kernel: da1: <FREEBSD CTLDISK 0001> Fixed Direct Access SCSI-5 device
May 25 10:42:33 FreeBSDTest kernel: da1: Serial Number MYSERIAL   0
May 25 10:42:33 FreeBSDTest kernel: da1: 800.000MB/s transfers WWNN 0x5000000f7ee16700 WWPN 0x5000000f7ee16704 PortID 0x3
May 25 10:42:33 FreeBSDTest kernel: da1: Command Queueing enabled
May 25 10:42:33 FreeBSDTest kernel: da1: 28610MB (58593750 512 byte sectors: 255H 63S/T 3647C)
May 25 10:42:33 FreeBSDTest kernel: ctlfe_onoffline: isp0 current WWNN 0x2000001b320199de
May 25 10:42:33 FreeBSDTest kernel: ctlfe_onoffline: isp0 current WWPN 0x2100001b320199de
May 25 10:42:33 FreeBSDTest kernel: ctlfe_onoffline: SIM isp0 (path id 2) target enable succeeded
```
Check `ctladm port -l` for enabled ports:

```
# ctladm port -l                                Port Online Type     Name         pp vp WWNN               WWPN
0    YES    IOCTL    CTL ioctl    0  0  0                  0
1    YES    INTERNAL CTL internal 0  0  0                  0
2    YES    ISCSI    iscsi        0  0  0                  0
3    YES    INTERNAL ctl2cam      0  0  0x5000000f7ee16700 0x5000000f7ee16704
4    YES    FC       isp0         0  0  0x2000001b320199de 0x2100001b320199de
```
And gain, I checked `ctladm devlist` output:

```
# ctladm devlist
LUN Backend       Size (Blocks)   BS Serial Number    Device ID
  0 block              58593750  512 MYSERIAL   0     MYDEVID   0
```
Everything seems to be OK on server-side. 
I connected my server and client with cable and reboted my client. Next, I entered Qlogic BIOS and tried to `scan for FC devices`...got the HBA on server, but *no LUNs*!!!
During 'scan for FC devices' FreeBSD console shows errors:

```
May 25 10:54:29 FreeBSDTest kernel: ctlfeasync: WWPN 0x210000e08b11df5a port 0x0000ef path 2 target 0 arrived
May 25 10:54:39 FreeBSDTest kernel: (0:4:0:0): TEST UNIT READY. CDB: 00 00 00 00 00 00
May 25 10:54:39 FreeBSDTest kernel: (0:4:0:0): Tag: 0x1141dc, Type: 0
May 25 10:54:39 FreeBSDTest kernel: (0:4:0:0): CTL Status: SCSI Error
May 25 10:54:39 FreeBSDTest kernel: (0:4:0:0): SCSI Status: Check Condition
May 25 10:54:39 FreeBSDTest kernel: (0:4:0:0): SCSI sense: ILLEGAL REQUEST asc:4e,0 (Overlapped commands attempted)
```

Is it FreeBSD issue, of I misconfigured something? I can`t get any info about this issue!
My /var/run/dmesg.boot (I'm worring about the Unretryable error - maybe it affect the FC target in some way):

```
Copyright (c) 1992-2014 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 10.0-RELEASE #0: Wed May 21 21:27:40 EEST 2014
    maed@FreeBSDTest:/usr/obj/usr/src/sys/FCSTORAGE amd64
FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610
CPU: Dual-Core AMD Opteron(tm) Processor 2212 (2000.11-MHz K8-class CPU)
  Origin = "AuthenticAMD"  Id = 0x40f13  Family = 0xf  Model = 0x41  Stepping = 3
  Features=0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>
  Features2=0x2001<SSE3,CX16>
  AMD Features=0xea500800<SYSCALL,NX,MMX+,FFXSR,RDTSCP,LM,3DNow!+,3DNow!>
  AMD Features2=0x1f<LAHF,CMP,SVM,ExtAPIC,CR8>
real memory  = 4294967296 (4096 MB)
avail memory = 4106358784 (3916 MB)
Event timer "LAPIC" quality 400
ACPI APIC Table: <HP     ProLiant>
FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
FreeBSD/SMP: 1 package(s) x 2 core(s)
 cpu0 (BSP): APIC ID:  0
 cpu1 (AP): APIC ID:  1
ioapic0 <Version 1.1> irqs 0-15 on motherboard
ioapic1 <Version 1.1> irqs 16-31 on motherboard
ioapic2 <Version 1.1> irqs 32-47 on motherboard
random: <Software, Yarrow> initialized
kbd1 at kbdmux0
acpi0: <HP ProLiant> on motherboard
acpi0: Power Button (fixed)
cpu0: <ACPI CPU> on acpi0
cpu1: <ACPI CPU> on acpi0
attimer0: <AT timer> port 0x40-0x43 irq 0 on acpi0
Timecounter "i8254" frequency 1193182 Hz quality 0
Event timer "i8254" frequency 1193182 Hz quality 100
hpet0: <High Precision Event Timer> iomem 0xfed00000-0xfed003ff on acpi0
Timecounter "HPET" frequency 14318180 Hz quality 950
atrtc0: <AT realtime clock> port 0x70-0x71 on acpi0
Event timer "RTC" frequency 32768 Hz quality 0
Timecounter "ACPI-safe" frequency 3579545 Hz quality 850
acpi_timer0: <32-bit timer at 3.579545MHz> port 0x920-0x923 on acpi0
pcib0: <ACPI Host-PCI bridge> on acpi0
pcib0: Length mismatch for 4 range: 918 vs 917
pci0: <ACPI PCI bus> on pcib0
vgapci0: <VGA-compatible display> port 0x1000-0x10ff mem 0xe8000000-0xefffffff,0xf5ff0000-0xf5ffffff irq 44 at device 3.0 on pci0
vgapci0: Boot video device
pci0: <base peripheral> at device 4.0 (no driver attached)
pci0: <base peripheral> at device 4.2 (no driver attached)
uhci0: <UHCI (generic) USB controller> port 0x1800-0x181f irq 45 at device 4.4 on pci0
usbus0 on uhci0
pci0: <serial bus> at device 4.6 (no driver attached)
pcib1: <ACPI PCI-PCI bridge> at device 5.0 on pci0
pci1: <ACPI PCI bus> on pcib1
pcib2: <ACPI PCI-PCI bridge> at device 13.0 on pci1
pci2: <ACPI PCI bus> on pcib2
atapci0: <ServerWorks HT1000 UDMA100 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0x500-0x50f at device 6.1 on pci0
ata0: <ATA channel> at channel 0 on atapci0
ata1: <ATA channel> at channel 1 on atapci0
isab0: <PCI-ISA bridge> at device 6.2 on pci0
isa0: <ISA bus> on isab0
ohci0: <OHCI (generic) USB controller> port 0x1c00-0x1cff mem 0xf5ee0000-0xf5ee0fff irq 5 at device 7.0 on pci0
usbus1 on ohci0
ohci1: <OHCI (generic) USB controller> port 0x3000-0x30ff mem 0xf5ed0000-0xf5ed0fff irq 5 at device 7.1 on pci0
usbus2 on ohci1
ehci0: <EHCI (generic) USB 2.0 controller> port 0x3400-0x34ff mem 0xf5ec0000-0xf5ec0fff irq 5 at device 7.2 on pci0
usbus3: EHCI version 1.0
usbus3: EHCI version 1.0
usbus3 on ehci0
pcib3: <ACPI PCI-PCI bridge> irq 42 at device 15.0 on pci0
pci5: <ACPI PCI bus> on pcib3
pcib4: <ACPI PCI-PCI bridge> irq 38 at device 16.0 on pci0
pci8: <ACPI PCI bus> on pcib4
pcib5: <PCI-PCI bridge> irq 39 at device 17.0 on pci0
pci14: <PCI bus> on pcib5
pcib6: <ACPI PCI-PCI bridge> irq 40 at device 18.0 on pci0
pci11: <ACPI PCI bus> on pcib6
isp0: <Qlogic ISP 2432 PCI FC-AL Adapter> port 0x4000-0x40ff mem 0xf9ff0000-0xf9ff3fff irq 40 at device 0.0 on pci11
isp0: setting role to 0x1
pcib7: <ACPI PCI-PCI bridge> irq 41 at device 19.0 on pci0
pci3: <ACPI PCI bus> on pcib7
pcib8: <PCI-PCI bridge> at device 0.0 on pci3
pci4: <PCI bus> on pcib8
bce0: <HP NC373i Multifunction Gigabit Server Adapter (B2)> mem 0xf6000000-0xf7ffffff irq 41 at device 0.0 on pci4
bce0: /usr/src/sys/dev/bce/if_bce.c(1251): Management firmware enabled but not running!
miibus0: <MII bus> on bce0
brgphy0: <BCM5708C 1000BASE-T media interface> PHY 1 on miibus0
brgphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-master, 1000baseT-FDX, 1000baseT-FDX-master, auto, auto-flow
bce0: Ethernet address: 00:1c:c4:e2:71:b2
bce0: ASIC (0x57081020); Rev (B2); Bus (PCI-X, 64-bit, 133MHz); B/C (1.9.6); Bufs (RX:2;TX:2;PG:8); Flags (SPLT|MSI|MFW); MFW (NOT RUNNING!)
Coal (RX:6,6,18,18; TX:20,20,80,80)
pcib9: <ACPI Host-PCI bridge> on acpi0
pci64: <ACPI PCI bus> on pcib9
pcib10: <ACPI PCI-PCI bridge> irq 36 at device 15.0 on pci64
pci67: <ACPI PCI bus> on pcib10
pcib11: <ACPI PCI-PCI bridge> irq 32 at device 16.0 on pci64
pci70: <ACPI PCI bus> on pcib11
ciss0: <HP Smart Array P400> port 0x5000-0x50ff mem 0xfdf00000-0xfdffffff,0xfdef0000-0xfdef0fff irq 32 at device 0.0 on pci70
ciss0: PERFORMANT Transport
pcib12: <PCI-PCI bridge> irq 33 at device 17.0 on pci64
pci73: <PCI bus> on pcib12
pcib13: <ACPI PCI-PCI bridge> irq 34 at device 18.0 on pci64
pci65: <ACPI PCI bus> on pcib13
pcib14: <PCI-PCI bridge> at device 0.0 on pci65
pci66: <PCI bus> on pcib14
bce1: <HP NC373i Multifunction Gigabit Server Adapter (B2)> mem 0xfa000000-0xfbffffff irq 34 at device 0.0 on pci66
bce1: /usr/src/sys/dev/bce/if_bce.c(1251): Management firmware enabled but not running!
miibus1: <MII bus> on bce1
brgphy1: <BCM5708C 1000BASE-T media interface> PHY 1 on miibus1
brgphy1:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-master, 1000baseT-FDX, 1000baseT-FDX-master, auto, auto-flow
bce1: Ethernet address: 00:1c:c4:e2:71:b0
bce1: ASIC (0x57081020); Rev (B2); Bus (PCI-X, 64-bit, 133MHz); B/C (1.9.6); Bufs (RX:2;TX:2;PG:8); Flags (SPLT|MSI|MFW); MFW (NOT RUNNING!)
Coal (RX:6,6,18,18; TX:20,20,80,80)
pcib15: <PCI-PCI bridge> irq 35 at device 19.0 on pci64
pci74: <PCI bus> on pcib15
atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0
atkbd0: <AT Keyboard> irq 1 on atkbdc0
kbd0 at atkbd0
atkbd0: [GIANT-LOCKED]
uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0
orm0: <ISA Option ROMs> at iomem 0xc0000-0xcafff,0xcb000-0xcefff,0xe5000-0xe6fff on isa0
sc0: <System console> at flags 0x100 on isa0
sc0: VGA <16 virtual consoles, flags=0x300>
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
ppc0: cannot reserve I/O port range
uart1: <Non-standard ns8250 class UART with FIFOs> at port 0x2f8-0x2ff irq 3 on isa0
powernow0: <PowerNow! K8> on cpu0
powernow1: <PowerNow! K8> on cpu1
ZFS NOTICE: Prefetch is disabled by default if less than 4GB of RAM is present;
            to enable, add "vfs.zfs.prefetch_disable=0" to /boot/loader.conf.
ZFS filesystem version: 5
ZFS storage pool version: features support (5000)
Timecounters tick every 1.000 msec
random: unblocking device.
usbus0: 12Mbps Full Speed USB v1.0
usbus1: 12Mbps Full Speed USB v1.0
usbus2: 12Mbps Full Speed USB v1.0
usbus3: 480Mbps High Speed USB v2.0
ugen0.1: <0x103c> at usbus0
uhub0: <0x103c UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus0
ugen1.1: <0x1166> at usbus1
uhub1: <0x1166 OHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus1
ugen3.1: <0x1166> at usbus3
uhub2: <0x1166 EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus3
ugen2.1: <0x1166> at usbus2
uhub3: <0x1166 OHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus2
da0 at ciss0 bus 0 scbus3 target 0 lun 0
da0: <HP RAID 0 OK> Fixed Direct Access SCSI-5 device
da0: Serial Number PAFGK0M9VWJ3PT
da0: 135.168MB/s transfers
da0: Command Queueing enabled
da0: 69970MB (143299800 512 byte sectors: 255H 63S/T 8920C)
cd0 at ata0 bus 0 scbus0 target 0 lun 0
cd0: <TEAC CD-224E-R C.CA> Removable CD-ROM SCSI-0 device
cd0: 33.300MB/s transfers (UDMA2, ATAPI 12bytes, PIO 65534bytes)
cd0: Attempt to query device size failed: NOT READY, Medium not present - tray closed
uhub1: 2 ports with 2 removable, self powered
uhub3: 2 ports with 2 removable, self powered
Netvsc initializing... SMP: AP CPU #1 Launched!
Root mount waiting for: usbus3 usbus0
uhub0: 2 ports with 2 removable, self powered
Root mount waiting for: usbus3 usbus0
ugen0.2: <HP> at usbus0
ukbd0: <Virtual Keyboard> on usbus0
kbd2 at ukbd0
uhub2: 4 ports with 4 removable, self powered
Root mount waiting for: usbus3 usbus0
ugen0.3: <HP> at usbus0
uhub4: <Virtual Hub> on usbus0
ugen3.2: <vendor 0x04b4> at usbus3
uhub5: <vendor 0x04b4 product 0x6560, class 9/0, rev 2.00/0.0b, addr 2> on usbus3
uhub5: MTT enabled
Root mount waiting for: usbus3 usbus0
uhub5: 4 ports with 4 removable, self powered
uhub4: 7 ports with 7 removable, self powered
Trying to mount root from zfs:zroot/ROOT/default []...
(da0:ciss0:0:0:0): SYNCHRONIZE CACHE(10). CDB: 35 00 00 00 00 00 00 00 00 00
(da0:ciss0:0:0:0): CAM status: SCSI Status Error
(da0:ciss0:0:0:0): SCSI status: Check Condition
(da0:ciss0:0:0:0): SCSI sense: ILLEGAL REQUEST asc:20,0 (Invalid command operation code)
(da0:ciss0:0:0:0): Error 22, Unretryable error
```


----------



## mav@ (Jun 5, 2014)

SYNCHRONIZE CACHE error probably tells only that your HP RAID does not implement respective command. It should not be a problem, though depending on RAID write cache behavior may or may not be a source of data corruption on power loss.

Can you try to boot FreeBSD on the client and check what will it see? Just a guess: may be LUN scanner in QLogic BIOS does something odd about request tags, triggering this error.

PS: With FreeBSD head I've successfully tested FC just few weeks ago.


----------



## HermesGroup (May 23, 2017)

I have the same problem with LUN disappearing after reboot. How did you solve this?
Thanks

Johnny R.
- - -
Hermes Group


----------

