^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) =========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) The TCM v4 fabric module script generator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) =========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) Greetings all,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) This document is intended to be a mini-HOWTO for using the tcm_mod_builder.py
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) script to generate a brand new functional TCM v4 fabric .ko module of your very own,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) that once built can be immediately be loaded to start access the new TCM/ConfigFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) fabric skeleton, by simply using::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) modprobe $TCM_NEW_MOD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) mkdir -p /sys/kernel/config/target/$TCM_NEW_MOD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) This script will create a new drivers/target/$TCM_NEW_MOD/, and will do the following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 1) Generate new API callers for drivers/target/target_core_fabric_configs.c logic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) ->make_tpg(), ->drop_tpg(), ->make_wwn(), ->drop_wwn(). These are created
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) into $TCM_NEW_MOD/$TCM_NEW_MOD_configfs.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 2) Generate basic infrastructure for loading/unloading LKMs and TCM/ConfigFS fabric module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) using a skeleton struct target_core_fabric_ops API template.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 3) Based on user defined T10 Proto_Ident for the new fabric module being built,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) the TransportID / Initiator and Target WWPN related handlers for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) SPC-3 persistent reservation are automatically generated in $TCM_NEW_MOD/$TCM_NEW_MOD_fabric.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) using drivers/target/target_core_fabric_lib.c logic.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 4) NOP API calls for all other Data I/O path and fabric dependent attribute logic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) in $TCM_NEW_MOD/$TCM_NEW_MOD_fabric.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) tcm_mod_builder.py depends upon the mandatory '-p $PROTO_IDENT' and '-m
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) $FABRIC_MOD_name' parameters, and actually running the script looks like::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) target:/mnt/sdb/lio-core-2.6.git/Documentation/target# python tcm_mod_builder.py -p iSCSI -m tcm_nab5000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) tcm_dir: /mnt/sdb/lio-core-2.6.git/Documentation/target/../../
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) Set fabric_mod_name: tcm_nab5000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) Set fabric_mod_dir:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) Using proto_ident: iSCSI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) Creating fabric_mod_dir:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) Writing file:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_base.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) Using tcm_mod_scan_fabric_ops:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /mnt/sdb/lio-core-2.6.git/Documentation/target/../../include/target/target_core_fabric_ops.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) Writing file:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_fabric.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) Writing file:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_fabric.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) Writing file:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_configfs.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) Writing file:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/Kbuild
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) Writing file:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/Kconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) Would you like to add tcm_nab5000to drivers/target/Kbuild..? [yes,no]: yes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) Would you like to add tcm_nab5000to drivers/target/Kconfig..? [yes,no]: yes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) At the end of tcm_mod_builder.py. the script will ask to add the following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) line to drivers/target/Kbuild::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) obj-$(CONFIG_TCM_NAB5000) += tcm_nab5000/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) and the same for drivers/target/Kconfig::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) source "drivers/target/tcm_nab5000/Kconfig"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #) Run 'make menuconfig' and select the new CONFIG_TCM_NAB5000 item::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) <M> TCM_NAB5000 fabric module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #) Build using 'make modules', once completed you will have::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) target:/mnt/sdb/lio-core-2.6.git# ls -la drivers/target/tcm_nab5000/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) total 1348
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) drwxr-xr-x 2 root root 4096 2010-10-05 03:23 .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) drwxr-xr-x 9 root root 4096 2010-10-05 03:22 ..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) -rw-r--r-- 1 root root 282 2010-10-05 03:22 Kbuild
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) -rw-r--r-- 1 root root 171 2010-10-05 03:22 Kconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) -rw-r--r-- 1 root root 49 2010-10-05 03:23 modules.order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) -rw-r--r-- 1 root root 738 2010-10-05 03:22 tcm_nab5000_base.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) -rw-r--r-- 1 root root 9096 2010-10-05 03:22 tcm_nab5000_configfs.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) -rw-r--r-- 1 root root 191200 2010-10-05 03:23 tcm_nab5000_configfs.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) -rw-r--r-- 1 root root 40504 2010-10-05 03:23 .tcm_nab5000_configfs.o.cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) -rw-r--r-- 1 root root 5414 2010-10-05 03:22 tcm_nab5000_fabric.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) -rw-r--r-- 1 root root 2016 2010-10-05 03:22 tcm_nab5000_fabric.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) -rw-r--r-- 1 root root 190932 2010-10-05 03:23 tcm_nab5000_fabric.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) -rw-r--r-- 1 root root 40713 2010-10-05 03:23 .tcm_nab5000_fabric.o.cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) -rw-r--r-- 1 root root 401861 2010-10-05 03:23 tcm_nab5000.ko
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) -rw-r--r-- 1 root root 265 2010-10-05 03:23 .tcm_nab5000.ko.cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) -rw-r--r-- 1 root root 459 2010-10-05 03:23 tcm_nab5000.mod.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) -rw-r--r-- 1 root root 23896 2010-10-05 03:23 tcm_nab5000.mod.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) -rw-r--r-- 1 root root 22655 2010-10-05 03:23 .tcm_nab5000.mod.o.cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) -rw-r--r-- 1 root root 379022 2010-10-05 03:23 tcm_nab5000.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) -rw-r--r-- 1 root root 211 2010-10-05 03:23 .tcm_nab5000.o.cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) #) Load the new module, create a lun_0 configfs group, and add new TCM Core
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) IBLOCK backstore symlink to port::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) target:/mnt/sdb/lio-core-2.6.git# insmod drivers/target/tcm_nab5000.ko
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) target:/mnt/sdb/lio-core-2.6.git# mkdir -p /sys/kernel/config/target/nab5000/iqn.foo/tpgt_1/lun/lun_0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) target:/mnt/sdb/lio-core-2.6.git# cd /sys/kernel/config/target/nab5000/iqn.foo/tpgt_1/lun/lun_0/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) target:/sys/kernel/config/target/nab5000/iqn.foo/tpgt_1/lun/lun_0# ln -s /sys/kernel/config/target/core/iblock_0/lvm_test0 nab5000_port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) target:/sys/kernel/config/target/nab5000/iqn.foo/tpgt_1/lun/lun_0# cd -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) target:/mnt/sdb/lio-core-2.6.git# tree /sys/kernel/config/target/nab5000/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) /sys/kernel/config/target/nab5000/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) |-- discovery_auth
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) |-- iqn.foo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) | `-- tpgt_1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) | |-- acls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) | |-- attrib
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) | |-- lun
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) | | `-- lun_0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) | | |-- alua_tg_pt_gp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) | | |-- alua_tg_pt_offline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) | | |-- alua_tg_pt_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) | | |-- alua_tg_pt_write_md
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) | | `-- nab5000_port -> ../../../../../../target/core/iblock_0/lvm_test0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) | |-- np
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) | `-- param
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) `-- version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) target:/mnt/sdb/lio-core-2.6.git# lsmod
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) Module Size Used by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) tcm_nab5000 3935 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) iscsi_target_mod 193211 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) target_core_stgt 8090 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) target_core_pscsi 11122 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) target_core_file 9172 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) target_core_iblock 9280 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) target_core_mod 228575 31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) tcm_nab5000,iscsi_target_mod,target_core_stgt,target_core_pscsi,target_core_file,target_core_iblock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) libfc 73681 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) scsi_debug 56265 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) scsi_tgt 8666 1 target_core_stgt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) configfs 20644 2 target_core_mod
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) ----------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) Future TODO items
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) =================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 1) Add more T10 proto_idents
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 2) Make tcm_mod_dump_fabric_ops() smarter and generate function pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) defs directly from include/target/target_core_fabric_ops.h:struct target_core_fabric_ops
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) structure members.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) October 5th, 2010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) Nicholas A. Bellinger <nab@linux-iscsi.org>