150 lines · plain
1=========================================2The TCM v4 fabric module script generator3=========================================4 5Greetings all,6 7This document is intended to be a mini-HOWTO for using the tcm_mod_builder.py8script to generate a brand new functional TCM v4 fabric .ko module of your very own,9that once built can be immediately be loaded to start access the new TCM/ConfigFS10fabric skeleton, by simply using::11 12 modprobe $TCM_NEW_MOD13 mkdir -p /sys/kernel/config/target/$TCM_NEW_MOD14 15This script will create a new drivers/target/$TCM_NEW_MOD/, and will do the following16 17 1) Generate new API callers for drivers/target/target_core_fabric_configs.c logic18 ->make_tpg(), ->drop_tpg(), ->make_wwn(), ->drop_wwn(). These are created19 into $TCM_NEW_MOD/$TCM_NEW_MOD_configfs.c20 2) Generate basic infrastructure for loading/unloading LKMs and TCM/ConfigFS fabric module21 using a skeleton struct target_core_fabric_ops API template.22 3) Based on user defined T10 Proto_Ident for the new fabric module being built,23 the TransportID / Initiator and Target WWPN related handlers for24 SPC-3 persistent reservation are automatically generated in $TCM_NEW_MOD/$TCM_NEW_MOD_fabric.c25 using drivers/target/target_core_fabric_lib.c logic.26 4) NOP API calls for all other Data I/O path and fabric dependent attribute logic27 in $TCM_NEW_MOD/$TCM_NEW_MOD_fabric.c28 29tcm_mod_builder.py depends upon the mandatory '-p $PROTO_IDENT' and '-m30$FABRIC_MOD_name' parameters, and actually running the script looks like::31 32 target:/mnt/sdb/lio-core-2.6.git/Documentation/target# python tcm_mod_builder.py -p iSCSI -m tcm_nab500033 tcm_dir: /mnt/sdb/lio-core-2.6.git/Documentation/target/../../34 Set fabric_mod_name: tcm_nab500035 Set fabric_mod_dir:36 /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab500037 Using proto_ident: iSCSI38 Creating fabric_mod_dir:39 /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab500040 Writing file:41 /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_base.h42 Using tcm_mod_scan_fabric_ops:43 /mnt/sdb/lio-core-2.6.git/Documentation/target/../../include/target/target_core_fabric_ops.h44 Writing file:45 /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_fabric.c46 Writing file:47 /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_fabric.h48 Writing file:49 /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_configfs.c50 Writing file:51 /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/Kbuild52 Writing file:53 /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/Kconfig54 Would you like to add tcm_nab5000to drivers/target/Kbuild..? [yes,no]: yes55 Would you like to add tcm_nab5000to drivers/target/Kconfig..? [yes,no]: yes56 57At the end of tcm_mod_builder.py. the script will ask to add the following58line to drivers/target/Kbuild::59 60 obj-$(CONFIG_TCM_NAB5000) += tcm_nab5000/61 62and the same for drivers/target/Kconfig::63 64 source "drivers/target/tcm_nab5000/Kconfig"65 66#) Run 'make menuconfig' and select the new CONFIG_TCM_NAB5000 item::67 68 <M> TCM_NAB5000 fabric module69 70#) Build using 'make modules', once completed you will have::71 72 target:/mnt/sdb/lio-core-2.6.git# ls -la drivers/target/tcm_nab5000/73 total 134874 drwxr-xr-x 2 root root 4096 2010-10-05 03:23 .75 drwxr-xr-x 9 root root 4096 2010-10-05 03:22 ..76 -rw-r--r-- 1 root root 282 2010-10-05 03:22 Kbuild77 -rw-r--r-- 1 root root 171 2010-10-05 03:22 Kconfig78 -rw-r--r-- 1 root root 49 2010-10-05 03:23 modules.order79 -rw-r--r-- 1 root root 738 2010-10-05 03:22 tcm_nab5000_base.h80 -rw-r--r-- 1 root root 9096 2010-10-05 03:22 tcm_nab5000_configfs.c81 -rw-r--r-- 1 root root 191200 2010-10-05 03:23 tcm_nab5000_configfs.o82 -rw-r--r-- 1 root root 40504 2010-10-05 03:23 .tcm_nab5000_configfs.o.cmd83 -rw-r--r-- 1 root root 5414 2010-10-05 03:22 tcm_nab5000_fabric.c84 -rw-r--r-- 1 root root 2016 2010-10-05 03:22 tcm_nab5000_fabric.h85 -rw-r--r-- 1 root root 190932 2010-10-05 03:23 tcm_nab5000_fabric.o86 -rw-r--r-- 1 root root 40713 2010-10-05 03:23 .tcm_nab5000_fabric.o.cmd87 -rw-r--r-- 1 root root 401861 2010-10-05 03:23 tcm_nab5000.ko88 -rw-r--r-- 1 root root 265 2010-10-05 03:23 .tcm_nab5000.ko.cmd89 -rw-r--r-- 1 root root 459 2010-10-05 03:23 tcm_nab5000.mod.c90 -rw-r--r-- 1 root root 23896 2010-10-05 03:23 tcm_nab5000.mod.o91 -rw-r--r-- 1 root root 22655 2010-10-05 03:23 .tcm_nab5000.mod.o.cmd92 -rw-r--r-- 1 root root 379022 2010-10-05 03:23 tcm_nab5000.o93 -rw-r--r-- 1 root root 211 2010-10-05 03:23 .tcm_nab5000.o.cmd94 95#) Load the new module, create a lun_0 configfs group, and add new TCM Core96 IBLOCK backstore symlink to port::97 98 target:/mnt/sdb/lio-core-2.6.git# insmod drivers/target/tcm_nab5000.ko99 target:/mnt/sdb/lio-core-2.6.git# mkdir -p /sys/kernel/config/target/nab5000/iqn.foo/tpgt_1/lun/lun_0100 target:/mnt/sdb/lio-core-2.6.git# cd /sys/kernel/config/target/nab5000/iqn.foo/tpgt_1/lun/lun_0/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_port102 103 target:/sys/kernel/config/target/nab5000/iqn.foo/tpgt_1/lun/lun_0# cd -104 target:/mnt/sdb/lio-core-2.6.git# tree /sys/kernel/config/target/nab5000/105 /sys/kernel/config/target/nab5000/106 |-- discovery_auth107 |-- iqn.foo108 | `-- tpgt_1109 | |-- acls110 | |-- attrib111 | |-- lun112 | | `-- lun_0113 | | |-- alua_tg_pt_gp114 | | |-- alua_tg_pt_offline115 | | |-- alua_tg_pt_status116 | | |-- alua_tg_pt_write_md117 | | `-- nab5000_port -> ../../../../../../target/core/iblock_0/lvm_test0118 | |-- np119 | `-- param120 `-- version121 122 target:/mnt/sdb/lio-core-2.6.git# lsmod123 Module Size Used by124 tcm_nab5000 3935 4125 iscsi_target_mod 193211 0126 target_core_stgt 8090 0127 target_core_pscsi 11122 1128 target_core_file 9172 2129 target_core_iblock 9280 1130 target_core_mod 228575 31131 tcm_nab5000,iscsi_target_mod,target_core_stgt,target_core_pscsi,target_core_file,target_core_iblock132 libfc 73681 0133 scsi_debug 56265 0134 scsi_tgt 8666 1 target_core_stgt135 configfs 20644 2 target_core_mod136 137----------------------------------------------------------------------138 139Future TODO items140=================141 142 1) Add more T10 proto_idents143 2) Make tcm_mod_dump_fabric_ops() smarter and generate function pointer144 defs directly from include/target/target_core_fabric_ops.h:struct target_core_fabric_ops145 structure members.146 147October 5th, 2010148 149Nicholas A. Bellinger <nab@linux-iscsi.org>150