tcm_mod_builder.txt 6.5 KB

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