Back to home page

OSCL-LXR

 
 

    


0001 =========================================
0002 The TCM v4 fabric module script generator
0003 =========================================
0004 
0005 Greetings all,
0006 
0007 This document is intended to be a mini-HOWTO for using the tcm_mod_builder.py
0008 script to generate a brand new functional TCM v4 fabric .ko module of your very own,
0009 that once built can be immediately be loaded to start access the new TCM/ConfigFS
0010 fabric skeleton, by simply using::
0011 
0012         modprobe $TCM_NEW_MOD
0013         mkdir -p /sys/kernel/config/target/$TCM_NEW_MOD
0014 
0015 This script will create a new drivers/target/$TCM_NEW_MOD/, and will do the following
0016 
0017         1) Generate new API callers for drivers/target/target_core_fabric_configs.c logic
0018            ->make_tpg(), ->drop_tpg(), ->make_wwn(), ->drop_wwn().  These are created
0019            into $TCM_NEW_MOD/$TCM_NEW_MOD_configfs.c
0020         2) Generate basic infrastructure for loading/unloading LKMs and TCM/ConfigFS fabric module
0021            using a skeleton struct target_core_fabric_ops API template.
0022         3) Based on user defined T10 Proto_Ident for the new fabric module being built,
0023            the TransportID / Initiator and Target WWPN related handlers for
0024            SPC-3 persistent reservation are automatically generated in $TCM_NEW_MOD/$TCM_NEW_MOD_fabric.c
0025            using drivers/target/target_core_fabric_lib.c logic.
0026         4) NOP API calls for all other Data I/O path and fabric dependent attribute logic
0027            in $TCM_NEW_MOD/$TCM_NEW_MOD_fabric.c
0028 
0029 tcm_mod_builder.py depends upon the mandatory '-p $PROTO_IDENT' and '-m
0030 $FABRIC_MOD_name' parameters, and actually running the script looks like::
0031 
0032   target:/mnt/sdb/lio-core-2.6.git/Documentation/target# python tcm_mod_builder.py -p iSCSI -m tcm_nab5000
0033   tcm_dir: /mnt/sdb/lio-core-2.6.git/Documentation/target/../../
0034   Set fabric_mod_name: tcm_nab5000
0035   Set fabric_mod_dir:
0036   /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000
0037   Using proto_ident: iSCSI
0038   Creating fabric_mod_dir:
0039   /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000
0040   Writing file:
0041   /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_base.h
0042   Using tcm_mod_scan_fabric_ops:
0043   /mnt/sdb/lio-core-2.6.git/Documentation/target/../../include/target/target_core_fabric_ops.h
0044   Writing file:
0045   /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_fabric.c
0046   Writing file:
0047   /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_fabric.h
0048   Writing file:
0049   /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_configfs.c
0050   Writing file:
0051   /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/Kbuild
0052   Writing file:
0053   /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/Kconfig
0054   Would you like to add tcm_nab5000to drivers/target/Kbuild..? [yes,no]: yes
0055   Would you like to add tcm_nab5000to drivers/target/Kconfig..? [yes,no]: yes
0056 
0057 At the end of tcm_mod_builder.py. the script will ask to add the following
0058 line to drivers/target/Kbuild::
0059 
0060         obj-$(CONFIG_TCM_NAB5000)       += tcm_nab5000/
0061 
0062 and the same for drivers/target/Kconfig::
0063 
0064         source "drivers/target/tcm_nab5000/Kconfig"
0065 
0066 #) Run 'make menuconfig' and select the new CONFIG_TCM_NAB5000 item::
0067 
0068         <M>   TCM_NAB5000 fabric module
0069 
0070 #) Build using 'make modules', once completed you will have::
0071 
0072     target:/mnt/sdb/lio-core-2.6.git# ls -la drivers/target/tcm_nab5000/
0073     total 1348
0074     drwxr-xr-x 2 root root   4096 2010-10-05 03:23 .
0075     drwxr-xr-x 9 root root   4096 2010-10-05 03:22 ..
0076     -rw-r--r-- 1 root root    282 2010-10-05 03:22 Kbuild
0077     -rw-r--r-- 1 root root    171 2010-10-05 03:22 Kconfig
0078     -rw-r--r-- 1 root root     49 2010-10-05 03:23 modules.order
0079     -rw-r--r-- 1 root root    738 2010-10-05 03:22 tcm_nab5000_base.h
0080     -rw-r--r-- 1 root root   9096 2010-10-05 03:22 tcm_nab5000_configfs.c
0081     -rw-r--r-- 1 root root 191200 2010-10-05 03:23 tcm_nab5000_configfs.o
0082     -rw-r--r-- 1 root root  40504 2010-10-05 03:23 .tcm_nab5000_configfs.o.cmd
0083     -rw-r--r-- 1 root root   5414 2010-10-05 03:22 tcm_nab5000_fabric.c
0084     -rw-r--r-- 1 root root   2016 2010-10-05 03:22 tcm_nab5000_fabric.h
0085     -rw-r--r-- 1 root root 190932 2010-10-05 03:23 tcm_nab5000_fabric.o
0086     -rw-r--r-- 1 root root  40713 2010-10-05 03:23 .tcm_nab5000_fabric.o.cmd
0087     -rw-r--r-- 1 root root 401861 2010-10-05 03:23 tcm_nab5000.ko
0088     -rw-r--r-- 1 root root    265 2010-10-05 03:23 .tcm_nab5000.ko.cmd
0089     -rw-r--r-- 1 root root    459 2010-10-05 03:23 tcm_nab5000.mod.c
0090     -rw-r--r-- 1 root root  23896 2010-10-05 03:23 tcm_nab5000.mod.o
0091     -rw-r--r-- 1 root root  22655 2010-10-05 03:23 .tcm_nab5000.mod.o.cmd
0092     -rw-r--r-- 1 root root 379022 2010-10-05 03:23 tcm_nab5000.o
0093     -rw-r--r-- 1 root root    211 2010-10-05 03:23 .tcm_nab5000.o.cmd
0094 
0095 #) Load the new module, create a lun_0 configfs group, and add new TCM Core
0096    IBLOCK backstore symlink to port::
0097 
0098     target:/mnt/sdb/lio-core-2.6.git# insmod drivers/target/tcm_nab5000.ko
0099     target:/mnt/sdb/lio-core-2.6.git# mkdir -p /sys/kernel/config/target/nab5000/iqn.foo/tpgt_1/lun/lun_0
0100     target:/mnt/sdb/lio-core-2.6.git# cd /sys/kernel/config/target/nab5000/iqn.foo/tpgt_1/lun/lun_0/
0101     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
0102 
0103     target:/sys/kernel/config/target/nab5000/iqn.foo/tpgt_1/lun/lun_0# cd -
0104     target:/mnt/sdb/lio-core-2.6.git# tree /sys/kernel/config/target/nab5000/
0105     /sys/kernel/config/target/nab5000/
0106     |-- discovery_auth
0107     |-- iqn.foo
0108     |   `-- tpgt_1
0109     |       |-- acls
0110     |       |-- attrib
0111     |       |-- lun
0112     |       |   `-- lun_0
0113     |       |       |-- alua_tg_pt_gp
0114     |       |       |-- alua_tg_pt_offline
0115     |       |       |-- alua_tg_pt_status
0116     |       |       |-- alua_tg_pt_write_md
0117     |   |       `-- nab5000_port -> ../../../../../../target/core/iblock_0/lvm_test0
0118     |       |-- np
0119     |       `-- param
0120     `-- version
0121 
0122     target:/mnt/sdb/lio-core-2.6.git# lsmod
0123     Module                  Size  Used by
0124     tcm_nab5000             3935  4
0125     iscsi_target_mod      193211  0
0126     target_core_stgt        8090  0
0127     target_core_pscsi      11122  1
0128     target_core_file        9172  2
0129     target_core_iblock      9280  1
0130     target_core_mod       228575  31
0131     tcm_nab5000,iscsi_target_mod,target_core_stgt,target_core_pscsi,target_core_file,target_core_iblock
0132     libfc                  73681  0
0133     scsi_debug             56265  0
0134     scsi_tgt                8666  1 target_core_stgt
0135     configfs               20644  2 target_core_mod
0136 
0137 ----------------------------------------------------------------------
0138 
0139 Future TODO items
0140 =================
0141 
0142         1) Add more T10 proto_idents
0143         2) Make tcm_mod_dump_fabric_ops() smarter and generate function pointer
0144            defs directly from include/target/target_core_fabric_ops.h:struct target_core_fabric_ops
0145            structure members.
0146 
0147 October 5th, 2010
0148 
0149 Nicholas A. Bellinger <nab@linux-iscsi.org>