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