18c2ecf20Sopenharmony_ci========================================= 28c2ecf20Sopenharmony_ciThe TCM v4 fabric module script generator 38c2ecf20Sopenharmony_ci========================================= 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ciGreetings all, 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ciThis document is intended to be a mini-HOWTO for using the tcm_mod_builder.py 88c2ecf20Sopenharmony_ciscript to generate a brand new functional TCM v4 fabric .ko module of your very own, 98c2ecf20Sopenharmony_cithat once built can be immediately be loaded to start access the new TCM/ConfigFS 108c2ecf20Sopenharmony_cifabric skeleton, by simply using:: 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci modprobe $TCM_NEW_MOD 138c2ecf20Sopenharmony_ci mkdir -p /sys/kernel/config/target/$TCM_NEW_MOD 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciThis script will create a new drivers/target/$TCM_NEW_MOD/, and will do the following 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci 1) Generate new API callers for drivers/target/target_core_fabric_configs.c logic 188c2ecf20Sopenharmony_ci ->make_tpg(), ->drop_tpg(), ->make_wwn(), ->drop_wwn(). These are created 198c2ecf20Sopenharmony_ci into $TCM_NEW_MOD/$TCM_NEW_MOD_configfs.c 208c2ecf20Sopenharmony_ci 2) Generate basic infrastructure for loading/unloading LKMs and TCM/ConfigFS fabric module 218c2ecf20Sopenharmony_ci using a skeleton struct target_core_fabric_ops API template. 228c2ecf20Sopenharmony_ci 3) Based on user defined T10 Proto_Ident for the new fabric module being built, 238c2ecf20Sopenharmony_ci the TransportID / Initiator and Target WWPN related handlers for 248c2ecf20Sopenharmony_ci SPC-3 persistent reservation are automatically generated in $TCM_NEW_MOD/$TCM_NEW_MOD_fabric.c 258c2ecf20Sopenharmony_ci using drivers/target/target_core_fabric_lib.c logic. 268c2ecf20Sopenharmony_ci 4) NOP API calls for all other Data I/O path and fabric dependent attribute logic 278c2ecf20Sopenharmony_ci in $TCM_NEW_MOD/$TCM_NEW_MOD_fabric.c 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_citcm_mod_builder.py depends upon the mandatory '-p $PROTO_IDENT' and '-m 308c2ecf20Sopenharmony_ci$FABRIC_MOD_name' parameters, and actually running the script looks like:: 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci target:/mnt/sdb/lio-core-2.6.git/Documentation/target# python tcm_mod_builder.py -p iSCSI -m tcm_nab5000 338c2ecf20Sopenharmony_ci tcm_dir: /mnt/sdb/lio-core-2.6.git/Documentation/target/../../ 348c2ecf20Sopenharmony_ci Set fabric_mod_name: tcm_nab5000 358c2ecf20Sopenharmony_ci Set fabric_mod_dir: 368c2ecf20Sopenharmony_ci /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000 378c2ecf20Sopenharmony_ci Using proto_ident: iSCSI 388c2ecf20Sopenharmony_ci Creating fabric_mod_dir: 398c2ecf20Sopenharmony_ci /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000 408c2ecf20Sopenharmony_ci Writing file: 418c2ecf20Sopenharmony_ci /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_base.h 428c2ecf20Sopenharmony_ci Using tcm_mod_scan_fabric_ops: 438c2ecf20Sopenharmony_ci /mnt/sdb/lio-core-2.6.git/Documentation/target/../../include/target/target_core_fabric_ops.h 448c2ecf20Sopenharmony_ci Writing file: 458c2ecf20Sopenharmony_ci /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_fabric.c 468c2ecf20Sopenharmony_ci Writing file: 478c2ecf20Sopenharmony_ci /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_fabric.h 488c2ecf20Sopenharmony_ci Writing file: 498c2ecf20Sopenharmony_ci /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_configfs.c 508c2ecf20Sopenharmony_ci Writing file: 518c2ecf20Sopenharmony_ci /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/Kbuild 528c2ecf20Sopenharmony_ci Writing file: 538c2ecf20Sopenharmony_ci /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/Kconfig 548c2ecf20Sopenharmony_ci Would you like to add tcm_nab5000to drivers/target/Kbuild..? [yes,no]: yes 558c2ecf20Sopenharmony_ci Would you like to add tcm_nab5000to drivers/target/Kconfig..? [yes,no]: yes 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ciAt the end of tcm_mod_builder.py. the script will ask to add the following 588c2ecf20Sopenharmony_ciline to drivers/target/Kbuild:: 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci obj-$(CONFIG_TCM_NAB5000) += tcm_nab5000/ 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ciand the same for drivers/target/Kconfig:: 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci source "drivers/target/tcm_nab5000/Kconfig" 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#) Run 'make menuconfig' and select the new CONFIG_TCM_NAB5000 item:: 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci <M> TCM_NAB5000 fabric module 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#) Build using 'make modules', once completed you will have:: 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci target:/mnt/sdb/lio-core-2.6.git# ls -la drivers/target/tcm_nab5000/ 738c2ecf20Sopenharmony_ci total 1348 748c2ecf20Sopenharmony_ci drwxr-xr-x 2 root root 4096 2010-10-05 03:23 . 758c2ecf20Sopenharmony_ci drwxr-xr-x 9 root root 4096 2010-10-05 03:22 .. 768c2ecf20Sopenharmony_ci -rw-r--r-- 1 root root 282 2010-10-05 03:22 Kbuild 778c2ecf20Sopenharmony_ci -rw-r--r-- 1 root root 171 2010-10-05 03:22 Kconfig 788c2ecf20Sopenharmony_ci -rw-r--r-- 1 root root 49 2010-10-05 03:23 modules.order 798c2ecf20Sopenharmony_ci -rw-r--r-- 1 root root 738 2010-10-05 03:22 tcm_nab5000_base.h 808c2ecf20Sopenharmony_ci -rw-r--r-- 1 root root 9096 2010-10-05 03:22 tcm_nab5000_configfs.c 818c2ecf20Sopenharmony_ci -rw-r--r-- 1 root root 191200 2010-10-05 03:23 tcm_nab5000_configfs.o 828c2ecf20Sopenharmony_ci -rw-r--r-- 1 root root 40504 2010-10-05 03:23 .tcm_nab5000_configfs.o.cmd 838c2ecf20Sopenharmony_ci -rw-r--r-- 1 root root 5414 2010-10-05 03:22 tcm_nab5000_fabric.c 848c2ecf20Sopenharmony_ci -rw-r--r-- 1 root root 2016 2010-10-05 03:22 tcm_nab5000_fabric.h 858c2ecf20Sopenharmony_ci -rw-r--r-- 1 root root 190932 2010-10-05 03:23 tcm_nab5000_fabric.o 868c2ecf20Sopenharmony_ci -rw-r--r-- 1 root root 40713 2010-10-05 03:23 .tcm_nab5000_fabric.o.cmd 878c2ecf20Sopenharmony_ci -rw-r--r-- 1 root root 401861 2010-10-05 03:23 tcm_nab5000.ko 888c2ecf20Sopenharmony_ci -rw-r--r-- 1 root root 265 2010-10-05 03:23 .tcm_nab5000.ko.cmd 898c2ecf20Sopenharmony_ci -rw-r--r-- 1 root root 459 2010-10-05 03:23 tcm_nab5000.mod.c 908c2ecf20Sopenharmony_ci -rw-r--r-- 1 root root 23896 2010-10-05 03:23 tcm_nab5000.mod.o 918c2ecf20Sopenharmony_ci -rw-r--r-- 1 root root 22655 2010-10-05 03:23 .tcm_nab5000.mod.o.cmd 928c2ecf20Sopenharmony_ci -rw-r--r-- 1 root root 379022 2010-10-05 03:23 tcm_nab5000.o 938c2ecf20Sopenharmony_ci -rw-r--r-- 1 root root 211 2010-10-05 03:23 .tcm_nab5000.o.cmd 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci#) Load the new module, create a lun_0 configfs group, and add new TCM Core 968c2ecf20Sopenharmony_ci IBLOCK backstore symlink to port:: 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci target:/mnt/sdb/lio-core-2.6.git# insmod drivers/target/tcm_nab5000.ko 998c2ecf20Sopenharmony_ci target:/mnt/sdb/lio-core-2.6.git# mkdir -p /sys/kernel/config/target/nab5000/iqn.foo/tpgt_1/lun/lun_0 1008c2ecf20Sopenharmony_ci target:/mnt/sdb/lio-core-2.6.git# cd /sys/kernel/config/target/nab5000/iqn.foo/tpgt_1/lun/lun_0/ 1018c2ecf20Sopenharmony_ci 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 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci target:/sys/kernel/config/target/nab5000/iqn.foo/tpgt_1/lun/lun_0# cd - 1048c2ecf20Sopenharmony_ci target:/mnt/sdb/lio-core-2.6.git# tree /sys/kernel/config/target/nab5000/ 1058c2ecf20Sopenharmony_ci /sys/kernel/config/target/nab5000/ 1068c2ecf20Sopenharmony_ci |-- discovery_auth 1078c2ecf20Sopenharmony_ci |-- iqn.foo 1088c2ecf20Sopenharmony_ci | `-- tpgt_1 1098c2ecf20Sopenharmony_ci | |-- acls 1108c2ecf20Sopenharmony_ci | |-- attrib 1118c2ecf20Sopenharmony_ci | |-- lun 1128c2ecf20Sopenharmony_ci | | `-- lun_0 1138c2ecf20Sopenharmony_ci | | |-- alua_tg_pt_gp 1148c2ecf20Sopenharmony_ci | | |-- alua_tg_pt_offline 1158c2ecf20Sopenharmony_ci | | |-- alua_tg_pt_status 1168c2ecf20Sopenharmony_ci | | |-- alua_tg_pt_write_md 1178c2ecf20Sopenharmony_ci | | `-- nab5000_port -> ../../../../../../target/core/iblock_0/lvm_test0 1188c2ecf20Sopenharmony_ci | |-- np 1198c2ecf20Sopenharmony_ci | `-- param 1208c2ecf20Sopenharmony_ci `-- version 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci target:/mnt/sdb/lio-core-2.6.git# lsmod 1238c2ecf20Sopenharmony_ci Module Size Used by 1248c2ecf20Sopenharmony_ci tcm_nab5000 3935 4 1258c2ecf20Sopenharmony_ci iscsi_target_mod 193211 0 1268c2ecf20Sopenharmony_ci target_core_stgt 8090 0 1278c2ecf20Sopenharmony_ci target_core_pscsi 11122 1 1288c2ecf20Sopenharmony_ci target_core_file 9172 2 1298c2ecf20Sopenharmony_ci target_core_iblock 9280 1 1308c2ecf20Sopenharmony_ci target_core_mod 228575 31 1318c2ecf20Sopenharmony_ci tcm_nab5000,iscsi_target_mod,target_core_stgt,target_core_pscsi,target_core_file,target_core_iblock 1328c2ecf20Sopenharmony_ci libfc 73681 0 1338c2ecf20Sopenharmony_ci scsi_debug 56265 0 1348c2ecf20Sopenharmony_ci scsi_tgt 8666 1 target_core_stgt 1358c2ecf20Sopenharmony_ci configfs 20644 2 target_core_mod 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci---------------------------------------------------------------------- 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ciFuture TODO items 1408c2ecf20Sopenharmony_ci================= 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci 1) Add more T10 proto_idents 1438c2ecf20Sopenharmony_ci 2) Make tcm_mod_dump_fabric_ops() smarter and generate function pointer 1448c2ecf20Sopenharmony_ci defs directly from include/target/target_core_fabric_ops.h:struct target_core_fabric_ops 1458c2ecf20Sopenharmony_ci structure members. 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ciOctober 5th, 2010 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ciNicholas A. Bellinger <nab@linux-iscsi.org> 150