scsi_transport_fc.c 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684
  1. /*
  2. * FiberChannel transport specific attributes exported to sysfs.
  3. *
  4. * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. * ========
  21. *
  22. * Copyright (C) 2004-2005 James Smart, Emulex Corporation
  23. * Rewrite for host, target, device, and remote port attributes,
  24. * statistics, and service functions...
  25. *
  26. */
  27. #include <linux/module.h>
  28. #include <linux/init.h>
  29. #include <scsi/scsi_device.h>
  30. #include <scsi/scsi_host.h>
  31. #include <scsi/scsi_transport.h>
  32. #include <scsi/scsi_transport_fc.h>
  33. #include "scsi_priv.h"
  34. #define FC_PRINTK(x, l, f, a...) printk(l "scsi(%d:%d:%d:%d): " f, (x)->host->host_no, (x)->channel, (x)->id, (x)->lun , ##a)
  35. /*
  36. * Redefine so that we can have same named attributes in the
  37. * sdev/starget/host objects.
  38. */
  39. #define FC_CLASS_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \
  40. struct class_device_attribute class_device_attr_##_prefix##_##_name = \
  41. __ATTR(_name,_mode,_show,_store)
  42. #define fc_enum_name_search(title, table_type, table) \
  43. static const char *get_fc_##title##_name(enum table_type table_key) \
  44. { \
  45. int i; \
  46. char *name = NULL; \
  47. \
  48. for (i = 0; i < sizeof(table)/sizeof(table[0]); i++) { \
  49. if (table[i].value == table_key) { \
  50. name = table[i].name; \
  51. break; \
  52. } \
  53. } \
  54. return name; \
  55. }
  56. #define fc_enum_name_match(title, table_type, table) \
  57. static int get_fc_##title##_match(const char *table_key, \
  58. enum table_type *value) \
  59. { \
  60. int i; \
  61. \
  62. for (i = 0; i < sizeof(table)/sizeof(table[0]); i++) { \
  63. if (strncmp(table_key, table[i].name, \
  64. table[i].matchlen) == 0) { \
  65. *value = table[i].value; \
  66. return 0; /* success */ \
  67. } \
  68. } \
  69. return 1; /* failure */ \
  70. }
  71. /* Convert fc_port_type values to ascii string name */
  72. static struct {
  73. enum fc_port_type value;
  74. char *name;
  75. } fc_port_type_names[] = {
  76. { FC_PORTTYPE_UNKNOWN, "Unknown" },
  77. { FC_PORTTYPE_OTHER, "Other" },
  78. { FC_PORTTYPE_NOTPRESENT, "Not Present" },
  79. { FC_PORTTYPE_NPORT, "NPort (fabric via point-to-point)" },
  80. { FC_PORTTYPE_NLPORT, "NLPort (fabric via loop)" },
  81. { FC_PORTTYPE_LPORT, "LPort (private loop)" },
  82. { FC_PORTTYPE_PTP, "Point-To-Point (direct nport connection" },
  83. };
  84. fc_enum_name_search(port_type, fc_port_type, fc_port_type_names)
  85. #define FC_PORTTYPE_MAX_NAMELEN 50
  86. /* Convert fc_port_state values to ascii string name */
  87. static struct {
  88. enum fc_port_state value;
  89. char *name;
  90. } fc_port_state_names[] = {
  91. { FC_PORTSTATE_UNKNOWN, "Unknown" },
  92. { FC_PORTSTATE_NOTPRESENT, "Not Present" },
  93. { FC_PORTSTATE_ONLINE, "Online" },
  94. { FC_PORTSTATE_OFFLINE, "Offline" },
  95. { FC_PORTSTATE_BLOCKED, "Blocked" },
  96. { FC_PORTSTATE_BYPASSED, "Bypassed" },
  97. { FC_PORTSTATE_DIAGNOSTICS, "Diagnostics" },
  98. { FC_PORTSTATE_LINKDOWN, "Linkdown" },
  99. { FC_PORTSTATE_ERROR, "Error" },
  100. { FC_PORTSTATE_LOOPBACK, "Loopback" },
  101. };
  102. fc_enum_name_search(port_state, fc_port_state, fc_port_state_names)
  103. #define FC_PORTSTATE_MAX_NAMELEN 20
  104. /* Convert fc_tgtid_binding_type values to ascii string name */
  105. static struct {
  106. enum fc_tgtid_binding_type value;
  107. char *name;
  108. int matchlen;
  109. } fc_tgtid_binding_type_names[] = {
  110. { FC_TGTID_BIND_NONE, "none", 4 },
  111. { FC_TGTID_BIND_BY_WWPN, "wwpn (World Wide Port Name)", 4 },
  112. { FC_TGTID_BIND_BY_WWNN, "wwnn (World Wide Node Name)", 4 },
  113. { FC_TGTID_BIND_BY_ID, "port_id (FC Address)", 7 },
  114. };
  115. fc_enum_name_search(tgtid_bind_type, fc_tgtid_binding_type,
  116. fc_tgtid_binding_type_names)
  117. fc_enum_name_match(tgtid_bind_type, fc_tgtid_binding_type,
  118. fc_tgtid_binding_type_names)
  119. #define FC_BINDTYPE_MAX_NAMELEN 30
  120. #define fc_bitfield_name_search(title, table) \
  121. static ssize_t \
  122. get_fc_##title##_names(u32 table_key, char *buf) \
  123. { \
  124. char *prefix = ""; \
  125. ssize_t len = 0; \
  126. int i; \
  127. \
  128. for (i = 0; i < sizeof(table)/sizeof(table[0]); i++) { \
  129. if (table[i].value & table_key) { \
  130. len += sprintf(buf + len, "%s%s", \
  131. prefix, table[i].name); \
  132. prefix = ", "; \
  133. } \
  134. } \
  135. len += sprintf(buf + len, "\n"); \
  136. return len; \
  137. }
  138. /* Convert FC_COS bit values to ascii string name */
  139. static struct {
  140. u32 value;
  141. char *name;
  142. } fc_cos_names[] = {
  143. { FC_COS_CLASS1, "Class 1" },
  144. { FC_COS_CLASS2, "Class 2" },
  145. { FC_COS_CLASS3, "Class 3" },
  146. { FC_COS_CLASS4, "Class 4" },
  147. { FC_COS_CLASS6, "Class 6" },
  148. };
  149. fc_bitfield_name_search(cos, fc_cos_names)
  150. /* Convert FC_PORTSPEED bit values to ascii string name */
  151. static struct {
  152. u32 value;
  153. char *name;
  154. } fc_port_speed_names[] = {
  155. { FC_PORTSPEED_1GBIT, "1 Gbit" },
  156. { FC_PORTSPEED_2GBIT, "2 Gbit" },
  157. { FC_PORTSPEED_4GBIT, "4 Gbit" },
  158. { FC_PORTSPEED_10GBIT, "10 Gbit" },
  159. { FC_PORTSPEED_NOT_NEGOTIATED, "Not Negotiated" },
  160. };
  161. fc_bitfield_name_search(port_speed, fc_port_speed_names)
  162. static int
  163. show_fc_fc4s (char *buf, u8 *fc4_list)
  164. {
  165. int i, len=0;
  166. for (i = 0; i < FC_FC4_LIST_SIZE; i++, fc4_list++)
  167. len += sprintf(buf + len , "0x%02x ", *fc4_list);
  168. len += sprintf(buf + len, "\n");
  169. return len;
  170. }
  171. /* Convert FC_RPORT_ROLE bit values to ascii string name */
  172. static struct {
  173. u32 value;
  174. char *name;
  175. } fc_remote_port_role_names[] = {
  176. { FC_RPORT_ROLE_FCP_TARGET, "FCP Target" },
  177. { FC_RPORT_ROLE_FCP_INITIATOR, "FCP Initiator" },
  178. { FC_RPORT_ROLE_IP_PORT, "IP Port" },
  179. };
  180. fc_bitfield_name_search(remote_port_roles, fc_remote_port_role_names)
  181. /*
  182. * Define roles that are specific to port_id. Values are relative to ROLE_MASK.
  183. */
  184. #define FC_WELLKNOWN_PORTID_MASK 0xfffff0
  185. #define FC_WELLKNOWN_ROLE_MASK 0x00000f
  186. #define FC_FPORT_PORTID 0x00000e
  187. #define FC_FABCTLR_PORTID 0x00000d
  188. #define FC_DIRSRVR_PORTID 0x00000c
  189. #define FC_TIMESRVR_PORTID 0x00000b
  190. #define FC_MGMTSRVR_PORTID 0x00000a
  191. static void fc_timeout_blocked_rport(void *data);
  192. static void fc_scsi_scan_rport(void *data);
  193. static void fc_rport_terminate(struct fc_rport *rport);
  194. /*
  195. * Attribute counts pre object type...
  196. * Increase these values if you add attributes
  197. */
  198. #define FC_STARGET_NUM_ATTRS 3
  199. #define FC_RPORT_NUM_ATTRS 9
  200. #define FC_HOST_NUM_ATTRS 15
  201. struct fc_internal {
  202. struct scsi_transport_template t;
  203. struct fc_function_template *f;
  204. /*
  205. * For attributes : each object has :
  206. * An array of the actual attributes structures
  207. * An array of null-terminated pointers to the attribute
  208. * structures - used for mid-layer interaction.
  209. *
  210. * The attribute containers for the starget and host are are
  211. * part of the midlayer. As the remote port is specific to the
  212. * fc transport, we must provide the attribute container.
  213. */
  214. struct class_device_attribute private_starget_attrs[
  215. FC_STARGET_NUM_ATTRS];
  216. struct class_device_attribute *starget_attrs[FC_STARGET_NUM_ATTRS + 1];
  217. struct class_device_attribute private_host_attrs[FC_HOST_NUM_ATTRS];
  218. struct class_device_attribute *host_attrs[FC_HOST_NUM_ATTRS + 1];
  219. struct transport_container rport_attr_cont;
  220. struct class_device_attribute private_rport_attrs[FC_RPORT_NUM_ATTRS];
  221. struct class_device_attribute *rport_attrs[FC_RPORT_NUM_ATTRS + 1];
  222. };
  223. #define to_fc_internal(tmpl) container_of(tmpl, struct fc_internal, t)
  224. static int fc_target_setup(struct device *dev)
  225. {
  226. struct scsi_target *starget = to_scsi_target(dev);
  227. struct fc_rport *rport = starget_to_rport(starget);
  228. /*
  229. * if parent is remote port, use values from remote port.
  230. * Otherwise, this host uses the fc_transport, but not the
  231. * remote port interface. As such, initialize to known non-values.
  232. */
  233. if (rport) {
  234. fc_starget_node_name(starget) = rport->node_name;
  235. fc_starget_port_name(starget) = rport->port_name;
  236. fc_starget_port_id(starget) = rport->port_id;
  237. } else {
  238. fc_starget_node_name(starget) = -1;
  239. fc_starget_port_name(starget) = -1;
  240. fc_starget_port_id(starget) = -1;
  241. }
  242. return 0;
  243. }
  244. static DECLARE_TRANSPORT_CLASS(fc_transport_class,
  245. "fc_transport",
  246. fc_target_setup,
  247. NULL,
  248. NULL);
  249. static int fc_host_setup(struct device *dev)
  250. {
  251. struct Scsi_Host *shost = dev_to_shost(dev);
  252. /*
  253. * Set default values easily detected by the midlayer as
  254. * failure cases. The scsi lldd is responsible for initializing
  255. * all transport attributes to valid values per host.
  256. */
  257. fc_host_node_name(shost) = -1;
  258. fc_host_port_name(shost) = -1;
  259. fc_host_supported_classes(shost) = FC_COS_UNSPECIFIED;
  260. memset(fc_host_supported_fc4s(shost), 0,
  261. sizeof(fc_host_supported_fc4s(shost)));
  262. memset(fc_host_symbolic_name(shost), 0,
  263. sizeof(fc_host_symbolic_name(shost)));
  264. fc_host_supported_speeds(shost) = FC_PORTSPEED_UNKNOWN;
  265. fc_host_maxframe_size(shost) = -1;
  266. memset(fc_host_serial_number(shost), 0,
  267. sizeof(fc_host_serial_number(shost)));
  268. fc_host_port_id(shost) = -1;
  269. fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
  270. fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
  271. memset(fc_host_active_fc4s(shost), 0,
  272. sizeof(fc_host_active_fc4s(shost)));
  273. fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
  274. fc_host_fabric_name(shost) = -1;
  275. fc_host_tgtid_bind_type(shost) = FC_TGTID_BIND_BY_WWPN;
  276. INIT_LIST_HEAD(&fc_host_rports(shost));
  277. INIT_LIST_HEAD(&fc_host_rport_bindings(shost));
  278. fc_host_next_rport_number(shost) = 0;
  279. fc_host_next_target_id(shost) = 0;
  280. return 0;
  281. }
  282. static DECLARE_TRANSPORT_CLASS(fc_host_class,
  283. "fc_host",
  284. fc_host_setup,
  285. NULL,
  286. NULL);
  287. /*
  288. * Setup and Remove actions for remote ports are handled
  289. * in the service functions below.
  290. */
  291. static DECLARE_TRANSPORT_CLASS(fc_rport_class,
  292. "fc_remote_ports",
  293. NULL,
  294. NULL,
  295. NULL);
  296. /*
  297. * Module Parameters
  298. */
  299. /*
  300. * dev_loss_tmo: the default number of seconds that the FC transport
  301. * should insulate the loss of a remote port.
  302. * The maximum will be capped by the value of SCSI_DEVICE_BLOCK_MAX_TIMEOUT.
  303. */
  304. static unsigned int fc_dev_loss_tmo = SCSI_DEVICE_BLOCK_MAX_TIMEOUT;
  305. module_param_named(dev_loss_tmo, fc_dev_loss_tmo, int, S_IRUGO|S_IWUSR);
  306. MODULE_PARM_DESC(dev_loss_tmo,
  307. "Maximum number of seconds that the FC transport should"
  308. " insulate the loss of a remote port. Once this value is"
  309. " exceeded, the scsi target is removed. Value should be"
  310. " between 1 and SCSI_DEVICE_BLOCK_MAX_TIMEOUT.");
  311. static __init int fc_transport_init(void)
  312. {
  313. int error = transport_class_register(&fc_host_class);
  314. if (error)
  315. return error;
  316. error = transport_class_register(&fc_rport_class);
  317. if (error)
  318. return error;
  319. return transport_class_register(&fc_transport_class);
  320. }
  321. static void __exit fc_transport_exit(void)
  322. {
  323. transport_class_unregister(&fc_transport_class);
  324. transport_class_unregister(&fc_rport_class);
  325. transport_class_unregister(&fc_host_class);
  326. }
  327. /*
  328. * FC Remote Port Attribute Management
  329. */
  330. #define fc_rport_show_function(field, format_string, sz, cast) \
  331. static ssize_t \
  332. show_fc_rport_##field (struct class_device *cdev, char *buf) \
  333. { \
  334. struct fc_rport *rport = transport_class_to_rport(cdev); \
  335. struct Scsi_Host *shost = rport_to_shost(rport); \
  336. struct fc_internal *i = to_fc_internal(shost->transportt); \
  337. if (i->f->get_rport_##field) \
  338. i->f->get_rport_##field(rport); \
  339. return snprintf(buf, sz, format_string, cast rport->field); \
  340. }
  341. #define fc_rport_store_function(field) \
  342. static ssize_t \
  343. store_fc_rport_##field(struct class_device *cdev, const char *buf, \
  344. size_t count) \
  345. { \
  346. int val; \
  347. struct fc_rport *rport = transport_class_to_rport(cdev); \
  348. struct Scsi_Host *shost = rport_to_shost(rport); \
  349. struct fc_internal *i = to_fc_internal(shost->transportt); \
  350. val = simple_strtoul(buf, NULL, 0); \
  351. i->f->set_rport_##field(rport, val); \
  352. return count; \
  353. }
  354. #define fc_rport_rd_attr(field, format_string, sz) \
  355. fc_rport_show_function(field, format_string, sz, ) \
  356. static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \
  357. show_fc_rport_##field, NULL)
  358. #define fc_rport_rd_attr_cast(field, format_string, sz, cast) \
  359. fc_rport_show_function(field, format_string, sz, (cast)) \
  360. static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \
  361. show_fc_rport_##field, NULL)
  362. #define fc_rport_rw_attr(field, format_string, sz) \
  363. fc_rport_show_function(field, format_string, sz, ) \
  364. fc_rport_store_function(field) \
  365. static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO | S_IWUSR, \
  366. show_fc_rport_##field, \
  367. store_fc_rport_##field)
  368. #define fc_private_rport_show_function(field, format_string, sz, cast) \
  369. static ssize_t \
  370. show_fc_rport_##field (struct class_device *cdev, char *buf) \
  371. { \
  372. struct fc_rport *rport = transport_class_to_rport(cdev); \
  373. return snprintf(buf, sz, format_string, cast rport->field); \
  374. }
  375. #define fc_private_rport_rd_attr(field, format_string, sz) \
  376. fc_private_rport_show_function(field, format_string, sz, ) \
  377. static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \
  378. show_fc_rport_##field, NULL)
  379. #define fc_private_rport_rd_attr_cast(field, format_string, sz, cast) \
  380. fc_private_rport_show_function(field, format_string, sz, (cast)) \
  381. static FC_CLASS_DEVICE_ATTR(rport, field, S_IRUGO, \
  382. show_fc_rport_##field, NULL)
  383. #define fc_private_rport_rd_enum_attr(title, maxlen) \
  384. static ssize_t \
  385. show_fc_rport_##title (struct class_device *cdev, char *buf) \
  386. { \
  387. struct fc_rport *rport = transport_class_to_rport(cdev); \
  388. const char *name; \
  389. name = get_fc_##title##_name(rport->title); \
  390. if (!name) \
  391. return -EINVAL; \
  392. return snprintf(buf, maxlen, "%s\n", name); \
  393. } \
  394. static FC_CLASS_DEVICE_ATTR(rport, title, S_IRUGO, \
  395. show_fc_rport_##title, NULL)
  396. #define SETUP_RPORT_ATTRIBUTE_RD(field) \
  397. i->private_rport_attrs[count] = class_device_attr_rport_##field; \
  398. i->private_rport_attrs[count].attr.mode = S_IRUGO; \
  399. i->private_rport_attrs[count].store = NULL; \
  400. i->rport_attrs[count] = &i->private_rport_attrs[count]; \
  401. if (i->f->show_rport_##field) \
  402. count++
  403. #define SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(field) \
  404. i->private_rport_attrs[count] = class_device_attr_rport_##field; \
  405. i->private_rport_attrs[count].attr.mode = S_IRUGO; \
  406. i->private_rport_attrs[count].store = NULL; \
  407. i->rport_attrs[count] = &i->private_rport_attrs[count]; \
  408. count++
  409. #define SETUP_RPORT_ATTRIBUTE_RW(field) \
  410. i->private_rport_attrs[count] = class_device_attr_rport_##field; \
  411. if (!i->f->set_rport_##field) { \
  412. i->private_rport_attrs[count].attr.mode = S_IRUGO; \
  413. i->private_rport_attrs[count].store = NULL; \
  414. } \
  415. i->rport_attrs[count] = &i->private_rport_attrs[count]; \
  416. if (i->f->show_rport_##field) \
  417. count++
  418. /* The FC Transport Remote Port Attributes: */
  419. /* Fixed Remote Port Attributes */
  420. fc_private_rport_rd_attr(maxframe_size, "%u bytes\n", 20);
  421. static ssize_t
  422. show_fc_rport_supported_classes (struct class_device *cdev, char *buf)
  423. {
  424. struct fc_rport *rport = transport_class_to_rport(cdev);
  425. if (rport->supported_classes == FC_COS_UNSPECIFIED)
  426. return snprintf(buf, 20, "unspecified\n");
  427. return get_fc_cos_names(rport->supported_classes, buf);
  428. }
  429. static FC_CLASS_DEVICE_ATTR(rport, supported_classes, S_IRUGO,
  430. show_fc_rport_supported_classes, NULL);
  431. /* Dynamic Remote Port Attributes */
  432. fc_rport_rw_attr(dev_loss_tmo, "%d\n", 20);
  433. /* Private Remote Port Attributes */
  434. fc_private_rport_rd_attr_cast(node_name, "0x%llx\n", 20, unsigned long long);
  435. fc_private_rport_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long);
  436. fc_private_rport_rd_attr(port_id, "0x%06x\n", 20);
  437. static ssize_t
  438. show_fc_rport_roles (struct class_device *cdev, char *buf)
  439. {
  440. struct fc_rport *rport = transport_class_to_rport(cdev);
  441. /* identify any roles that are port_id specific */
  442. if ((rport->port_id != -1) &&
  443. (rport->port_id & FC_WELLKNOWN_PORTID_MASK) ==
  444. FC_WELLKNOWN_PORTID_MASK) {
  445. switch (rport->port_id & FC_WELLKNOWN_ROLE_MASK) {
  446. case FC_FPORT_PORTID:
  447. return snprintf(buf, 30, "Fabric Port\n");
  448. case FC_FABCTLR_PORTID:
  449. return snprintf(buf, 30, "Fabric Controller\n");
  450. case FC_DIRSRVR_PORTID:
  451. return snprintf(buf, 30, "Directory Server\n");
  452. case FC_TIMESRVR_PORTID:
  453. return snprintf(buf, 30, "Time Server\n");
  454. case FC_MGMTSRVR_PORTID:
  455. return snprintf(buf, 30, "Management Server\n");
  456. default:
  457. return snprintf(buf, 30, "Unknown Fabric Entity\n");
  458. }
  459. } else {
  460. if (rport->roles == FC_RPORT_ROLE_UNKNOWN)
  461. return snprintf(buf, 20, "unknown\n");
  462. return get_fc_remote_port_roles_names(rport->roles, buf);
  463. }
  464. }
  465. static FC_CLASS_DEVICE_ATTR(rport, roles, S_IRUGO,
  466. show_fc_rport_roles, NULL);
  467. fc_private_rport_rd_enum_attr(port_state, FC_PORTSTATE_MAX_NAMELEN);
  468. fc_private_rport_rd_attr(scsi_target_id, "%d\n", 20);
  469. /*
  470. * FC SCSI Target Attribute Management
  471. */
  472. /*
  473. * Note: in the target show function we recognize when the remote
  474. * port is in the heirarchy and do not allow the driver to get
  475. * involved in sysfs functions. The driver only gets involved if
  476. * it's the "old" style that doesn't use rports.
  477. */
  478. #define fc_starget_show_function(field, format_string, sz, cast) \
  479. static ssize_t \
  480. show_fc_starget_##field (struct class_device *cdev, char *buf) \
  481. { \
  482. struct scsi_target *starget = transport_class_to_starget(cdev); \
  483. struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \
  484. struct fc_internal *i = to_fc_internal(shost->transportt); \
  485. struct fc_rport *rport = starget_to_rport(starget); \
  486. if (rport) \
  487. fc_starget_##field(starget) = rport->field; \
  488. else if (i->f->get_starget_##field) \
  489. i->f->get_starget_##field(starget); \
  490. return snprintf(buf, sz, format_string, \
  491. cast fc_starget_##field(starget)); \
  492. }
  493. #define fc_starget_rd_attr(field, format_string, sz) \
  494. fc_starget_show_function(field, format_string, sz, ) \
  495. static FC_CLASS_DEVICE_ATTR(starget, field, S_IRUGO, \
  496. show_fc_starget_##field, NULL)
  497. #define fc_starget_rd_attr_cast(field, format_string, sz, cast) \
  498. fc_starget_show_function(field, format_string, sz, (cast)) \
  499. static FC_CLASS_DEVICE_ATTR(starget, field, S_IRUGO, \
  500. show_fc_starget_##field, NULL)
  501. #define SETUP_STARGET_ATTRIBUTE_RD(field) \
  502. i->private_starget_attrs[count] = class_device_attr_starget_##field; \
  503. i->private_starget_attrs[count].attr.mode = S_IRUGO; \
  504. i->private_starget_attrs[count].store = NULL; \
  505. i->starget_attrs[count] = &i->private_starget_attrs[count]; \
  506. if (i->f->show_starget_##field) \
  507. count++
  508. #define SETUP_STARGET_ATTRIBUTE_RW(field) \
  509. i->private_starget_attrs[count] = class_device_attr_starget_##field; \
  510. if (!i->f->set_starget_##field) { \
  511. i->private_starget_attrs[count].attr.mode = S_IRUGO; \
  512. i->private_starget_attrs[count].store = NULL; \
  513. } \
  514. i->starget_attrs[count] = &i->private_starget_attrs[count]; \
  515. if (i->f->show_starget_##field) \
  516. count++
  517. /* The FC Transport SCSI Target Attributes: */
  518. fc_starget_rd_attr_cast(node_name, "0x%llx\n", 20, unsigned long long);
  519. fc_starget_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long);
  520. fc_starget_rd_attr(port_id, "0x%06x\n", 20);
  521. /*
  522. * Host Attribute Management
  523. */
  524. #define fc_host_show_function(field, format_string, sz, cast) \
  525. static ssize_t \
  526. show_fc_host_##field (struct class_device *cdev, char *buf) \
  527. { \
  528. struct Scsi_Host *shost = transport_class_to_shost(cdev); \
  529. struct fc_internal *i = to_fc_internal(shost->transportt); \
  530. if (i->f->get_host_##field) \
  531. i->f->get_host_##field(shost); \
  532. return snprintf(buf, sz, format_string, cast fc_host_##field(shost)); \
  533. }
  534. #define fc_host_store_function(field) \
  535. static ssize_t \
  536. store_fc_host_##field(struct class_device *cdev, const char *buf, \
  537. size_t count) \
  538. { \
  539. int val; \
  540. struct Scsi_Host *shost = transport_class_to_shost(cdev); \
  541. struct fc_internal *i = to_fc_internal(shost->transportt); \
  542. \
  543. val = simple_strtoul(buf, NULL, 0); \
  544. i->f->set_host_##field(shost, val); \
  545. return count; \
  546. }
  547. #define fc_host_rd_attr(field, format_string, sz) \
  548. fc_host_show_function(field, format_string, sz, ) \
  549. static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \
  550. show_fc_host_##field, NULL)
  551. #define fc_host_rd_attr_cast(field, format_string, sz, cast) \
  552. fc_host_show_function(field, format_string, sz, (cast)) \
  553. static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \
  554. show_fc_host_##field, NULL)
  555. #define fc_host_rw_attr(field, format_string, sz) \
  556. fc_host_show_function(field, format_string, sz, ) \
  557. fc_host_store_function(field) \
  558. static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO | S_IWUSR, \
  559. show_fc_host_##field, \
  560. store_fc_host_##field)
  561. #define fc_host_rd_enum_attr(title, maxlen) \
  562. static ssize_t \
  563. show_fc_host_##title (struct class_device *cdev, char *buf) \
  564. { \
  565. struct Scsi_Host *shost = transport_class_to_shost(cdev); \
  566. struct fc_internal *i = to_fc_internal(shost->transportt); \
  567. const char *name; \
  568. if (i->f->get_host_##title) \
  569. i->f->get_host_##title(shost); \
  570. name = get_fc_##title##_name(fc_host_##title(shost)); \
  571. if (!name) \
  572. return -EINVAL; \
  573. return snprintf(buf, maxlen, "%s\n", name); \
  574. } \
  575. static FC_CLASS_DEVICE_ATTR(host, title, S_IRUGO, show_fc_host_##title, NULL)
  576. #define SETUP_HOST_ATTRIBUTE_RD(field) \
  577. i->private_host_attrs[count] = class_device_attr_host_##field; \
  578. i->private_host_attrs[count].attr.mode = S_IRUGO; \
  579. i->private_host_attrs[count].store = NULL; \
  580. i->host_attrs[count] = &i->private_host_attrs[count]; \
  581. if (i->f->show_host_##field) \
  582. count++
  583. #define SETUP_HOST_ATTRIBUTE_RW(field) \
  584. i->private_host_attrs[count] = class_device_attr_host_##field; \
  585. if (!i->f->set_host_##field) { \
  586. i->private_host_attrs[count].attr.mode = S_IRUGO; \
  587. i->private_host_attrs[count].store = NULL; \
  588. } \
  589. i->host_attrs[count] = &i->private_host_attrs[count]; \
  590. if (i->f->show_host_##field) \
  591. count++
  592. #define fc_private_host_show_function(field, format_string, sz, cast) \
  593. static ssize_t \
  594. show_fc_host_##field (struct class_device *cdev, char *buf) \
  595. { \
  596. struct Scsi_Host *shost = transport_class_to_shost(cdev); \
  597. return snprintf(buf, sz, format_string, cast fc_host_##field(shost)); \
  598. }
  599. #define fc_private_host_rd_attr(field, format_string, sz) \
  600. fc_private_host_show_function(field, format_string, sz, ) \
  601. static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \
  602. show_fc_host_##field, NULL)
  603. #define fc_private_host_rd_attr_cast(field, format_string, sz, cast) \
  604. fc_private_host_show_function(field, format_string, sz, (cast)) \
  605. static FC_CLASS_DEVICE_ATTR(host, field, S_IRUGO, \
  606. show_fc_host_##field, NULL)
  607. #define SETUP_PRIVATE_HOST_ATTRIBUTE_RD(field) \
  608. i->private_host_attrs[count] = class_device_attr_host_##field; \
  609. i->private_host_attrs[count].attr.mode = S_IRUGO; \
  610. i->private_host_attrs[count].store = NULL; \
  611. i->host_attrs[count] = &i->private_host_attrs[count]; \
  612. count++
  613. #define SETUP_PRIVATE_HOST_ATTRIBUTE_RW(field) \
  614. i->private_host_attrs[count] = class_device_attr_host_##field; \
  615. i->host_attrs[count] = &i->private_host_attrs[count]; \
  616. count++
  617. /* Fixed Host Attributes */
  618. static ssize_t
  619. show_fc_host_supported_classes (struct class_device *cdev, char *buf)
  620. {
  621. struct Scsi_Host *shost = transport_class_to_shost(cdev);
  622. if (fc_host_supported_classes(shost) == FC_COS_UNSPECIFIED)
  623. return snprintf(buf, 20, "unspecified\n");
  624. return get_fc_cos_names(fc_host_supported_classes(shost), buf);
  625. }
  626. static FC_CLASS_DEVICE_ATTR(host, supported_classes, S_IRUGO,
  627. show_fc_host_supported_classes, NULL);
  628. static ssize_t
  629. show_fc_host_supported_fc4s (struct class_device *cdev, char *buf)
  630. {
  631. struct Scsi_Host *shost = transport_class_to_shost(cdev);
  632. return (ssize_t)show_fc_fc4s(buf, fc_host_supported_fc4s(shost));
  633. }
  634. static FC_CLASS_DEVICE_ATTR(host, supported_fc4s, S_IRUGO,
  635. show_fc_host_supported_fc4s, NULL);
  636. static ssize_t
  637. show_fc_host_supported_speeds (struct class_device *cdev, char *buf)
  638. {
  639. struct Scsi_Host *shost = transport_class_to_shost(cdev);
  640. if (fc_host_supported_speeds(shost) == FC_PORTSPEED_UNKNOWN)
  641. return snprintf(buf, 20, "unknown\n");
  642. return get_fc_port_speed_names(fc_host_supported_speeds(shost), buf);
  643. }
  644. static FC_CLASS_DEVICE_ATTR(host, supported_speeds, S_IRUGO,
  645. show_fc_host_supported_speeds, NULL);
  646. fc_private_host_rd_attr_cast(node_name, "0x%llx\n", 20, unsigned long long);
  647. fc_private_host_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long);
  648. fc_private_host_rd_attr(symbolic_name, "%s\n", (FC_SYMBOLIC_NAME_SIZE +1));
  649. fc_private_host_rd_attr(maxframe_size, "%u bytes\n", 20);
  650. fc_private_host_rd_attr(serial_number, "%s\n", (FC_SERIAL_NUMBER_SIZE +1));
  651. /* Dynamic Host Attributes */
  652. static ssize_t
  653. show_fc_host_active_fc4s (struct class_device *cdev, char *buf)
  654. {
  655. struct Scsi_Host *shost = transport_class_to_shost(cdev);
  656. struct fc_internal *i = to_fc_internal(shost->transportt);
  657. if (i->f->get_host_active_fc4s)
  658. i->f->get_host_active_fc4s(shost);
  659. return (ssize_t)show_fc_fc4s(buf, fc_host_active_fc4s(shost));
  660. }
  661. static FC_CLASS_DEVICE_ATTR(host, active_fc4s, S_IRUGO,
  662. show_fc_host_active_fc4s, NULL);
  663. static ssize_t
  664. show_fc_host_speed (struct class_device *cdev, char *buf)
  665. {
  666. struct Scsi_Host *shost = transport_class_to_shost(cdev);
  667. struct fc_internal *i = to_fc_internal(shost->transportt);
  668. if (i->f->get_host_speed)
  669. i->f->get_host_speed(shost);
  670. if (fc_host_speed(shost) == FC_PORTSPEED_UNKNOWN)
  671. return snprintf(buf, 20, "unknown\n");
  672. return get_fc_port_speed_names(fc_host_speed(shost), buf);
  673. }
  674. static FC_CLASS_DEVICE_ATTR(host, speed, S_IRUGO,
  675. show_fc_host_speed, NULL);
  676. fc_host_rd_attr(port_id, "0x%06x\n", 20);
  677. fc_host_rd_enum_attr(port_type, FC_PORTTYPE_MAX_NAMELEN);
  678. fc_host_rd_enum_attr(port_state, FC_PORTSTATE_MAX_NAMELEN);
  679. fc_host_rd_attr_cast(fabric_name, "0x%llx\n", 20, unsigned long long);
  680. /* Private Host Attributes */
  681. static ssize_t
  682. show_fc_private_host_tgtid_bind_type(struct class_device *cdev, char *buf)
  683. {
  684. struct Scsi_Host *shost = transport_class_to_shost(cdev);
  685. const char *name;
  686. name = get_fc_tgtid_bind_type_name(fc_host_tgtid_bind_type(shost));
  687. if (!name)
  688. return -EINVAL;
  689. return snprintf(buf, FC_BINDTYPE_MAX_NAMELEN, "%s\n", name);
  690. }
  691. static ssize_t
  692. store_fc_private_host_tgtid_bind_type(struct class_device *cdev,
  693. const char *buf, size_t count)
  694. {
  695. struct Scsi_Host *shost = transport_class_to_shost(cdev);
  696. struct fc_rport *rport, *next_rport;
  697. enum fc_tgtid_binding_type val;
  698. unsigned long flags;
  699. if (get_fc_tgtid_bind_type_match(buf, &val))
  700. return -EINVAL;
  701. /* if changing bind type, purge all unused consistent bindings */
  702. if (val != fc_host_tgtid_bind_type(shost)) {
  703. spin_lock_irqsave(shost->host_lock, flags);
  704. list_for_each_entry_safe(rport, next_rport,
  705. &fc_host_rport_bindings(shost), peers)
  706. fc_rport_terminate(rport);
  707. spin_unlock_irqrestore(shost->host_lock, flags);
  708. }
  709. fc_host_tgtid_bind_type(shost) = val;
  710. return count;
  711. }
  712. static FC_CLASS_DEVICE_ATTR(host, tgtid_bind_type, S_IRUGO | S_IWUSR,
  713. show_fc_private_host_tgtid_bind_type,
  714. store_fc_private_host_tgtid_bind_type);
  715. /*
  716. * Host Statistics Management
  717. */
  718. /* Show a given an attribute in the statistics group */
  719. static ssize_t
  720. fc_stat_show(const struct class_device *cdev, char *buf, unsigned long offset)
  721. {
  722. struct Scsi_Host *shost = transport_class_to_shost(cdev);
  723. struct fc_internal *i = to_fc_internal(shost->transportt);
  724. struct fc_host_statistics *stats;
  725. ssize_t ret = -ENOENT;
  726. if (offset > sizeof(struct fc_host_statistics) ||
  727. offset % sizeof(u64) != 0)
  728. WARN_ON(1);
  729. if (i->f->get_fc_host_stats) {
  730. stats = (i->f->get_fc_host_stats)(shost);
  731. if (stats)
  732. ret = snprintf(buf, 20, "0x%llx\n",
  733. (unsigned long long)*(u64 *)(((u8 *) stats) + offset));
  734. }
  735. return ret;
  736. }
  737. /* generate a read-only statistics attribute */
  738. #define fc_host_statistic(name) \
  739. static ssize_t show_fcstat_##name(struct class_device *cd, char *buf) \
  740. { \
  741. return fc_stat_show(cd, buf, \
  742. offsetof(struct fc_host_statistics, name)); \
  743. } \
  744. static FC_CLASS_DEVICE_ATTR(host, name, S_IRUGO, show_fcstat_##name, NULL)
  745. fc_host_statistic(seconds_since_last_reset);
  746. fc_host_statistic(tx_frames);
  747. fc_host_statistic(tx_words);
  748. fc_host_statistic(rx_frames);
  749. fc_host_statistic(rx_words);
  750. fc_host_statistic(lip_count);
  751. fc_host_statistic(nos_count);
  752. fc_host_statistic(error_frames);
  753. fc_host_statistic(dumped_frames);
  754. fc_host_statistic(link_failure_count);
  755. fc_host_statistic(loss_of_sync_count);
  756. fc_host_statistic(loss_of_signal_count);
  757. fc_host_statistic(prim_seq_protocol_err_count);
  758. fc_host_statistic(invalid_tx_word_count);
  759. fc_host_statistic(invalid_crc_count);
  760. fc_host_statistic(fcp_input_requests);
  761. fc_host_statistic(fcp_output_requests);
  762. fc_host_statistic(fcp_control_requests);
  763. fc_host_statistic(fcp_input_megabytes);
  764. fc_host_statistic(fcp_output_megabytes);
  765. static ssize_t
  766. fc_reset_statistics(struct class_device *cdev, const char *buf,
  767. size_t count)
  768. {
  769. struct Scsi_Host *shost = transport_class_to_shost(cdev);
  770. struct fc_internal *i = to_fc_internal(shost->transportt);
  771. /* ignore any data value written to the attribute */
  772. if (i->f->reset_fc_host_stats) {
  773. i->f->reset_fc_host_stats(shost);
  774. return count;
  775. }
  776. return -ENOENT;
  777. }
  778. static FC_CLASS_DEVICE_ATTR(host, reset_statistics, S_IWUSR, NULL,
  779. fc_reset_statistics);
  780. static struct attribute *fc_statistics_attrs[] = {
  781. &class_device_attr_host_seconds_since_last_reset.attr,
  782. &class_device_attr_host_tx_frames.attr,
  783. &class_device_attr_host_tx_words.attr,
  784. &class_device_attr_host_rx_frames.attr,
  785. &class_device_attr_host_rx_words.attr,
  786. &class_device_attr_host_lip_count.attr,
  787. &class_device_attr_host_nos_count.attr,
  788. &class_device_attr_host_error_frames.attr,
  789. &class_device_attr_host_dumped_frames.attr,
  790. &class_device_attr_host_link_failure_count.attr,
  791. &class_device_attr_host_loss_of_sync_count.attr,
  792. &class_device_attr_host_loss_of_signal_count.attr,
  793. &class_device_attr_host_prim_seq_protocol_err_count.attr,
  794. &class_device_attr_host_invalid_tx_word_count.attr,
  795. &class_device_attr_host_invalid_crc_count.attr,
  796. &class_device_attr_host_fcp_input_requests.attr,
  797. &class_device_attr_host_fcp_output_requests.attr,
  798. &class_device_attr_host_fcp_control_requests.attr,
  799. &class_device_attr_host_fcp_input_megabytes.attr,
  800. &class_device_attr_host_fcp_output_megabytes.attr,
  801. &class_device_attr_host_reset_statistics.attr,
  802. NULL
  803. };
  804. static struct attribute_group fc_statistics_group = {
  805. .name = "statistics",
  806. .attrs = fc_statistics_attrs,
  807. };
  808. static int fc_host_match(struct attribute_container *cont,
  809. struct device *dev)
  810. {
  811. struct Scsi_Host *shost;
  812. struct fc_internal *i;
  813. if (!scsi_is_host_device(dev))
  814. return 0;
  815. shost = dev_to_shost(dev);
  816. if (!shost->transportt || shost->transportt->host_attrs.ac.class
  817. != &fc_host_class.class)
  818. return 0;
  819. i = to_fc_internal(shost->transportt);
  820. return &i->t.host_attrs.ac == cont;
  821. }
  822. static int fc_target_match(struct attribute_container *cont,
  823. struct device *dev)
  824. {
  825. struct Scsi_Host *shost;
  826. struct fc_internal *i;
  827. if (!scsi_is_target_device(dev))
  828. return 0;
  829. shost = dev_to_shost(dev->parent);
  830. if (!shost->transportt || shost->transportt->host_attrs.ac.class
  831. != &fc_host_class.class)
  832. return 0;
  833. i = to_fc_internal(shost->transportt);
  834. return &i->t.target_attrs.ac == cont;
  835. }
  836. static void fc_rport_dev_release(struct device *dev)
  837. {
  838. struct fc_rport *rport = dev_to_rport(dev);
  839. put_device(dev->parent);
  840. kfree(rport);
  841. }
  842. int scsi_is_fc_rport(const struct device *dev)
  843. {
  844. return dev->release == fc_rport_dev_release;
  845. }
  846. EXPORT_SYMBOL(scsi_is_fc_rport);
  847. static int fc_rport_match(struct attribute_container *cont,
  848. struct device *dev)
  849. {
  850. struct Scsi_Host *shost;
  851. struct fc_internal *i;
  852. if (!scsi_is_fc_rport(dev))
  853. return 0;
  854. shost = dev_to_shost(dev->parent);
  855. if (!shost->transportt || shost->transportt->host_attrs.ac.class
  856. != &fc_host_class.class)
  857. return 0;
  858. i = to_fc_internal(shost->transportt);
  859. return &i->rport_attr_cont.ac == cont;
  860. }
  861. /*
  862. * Must be called with shost->host_lock held
  863. */
  864. static struct device *fc_target_parent(struct Scsi_Host *shost,
  865. int channel, uint id)
  866. {
  867. struct fc_rport *rport;
  868. list_for_each_entry(rport, &fc_host_rports(shost), peers)
  869. if ((rport->channel == channel) &&
  870. (rport->scsi_target_id == id))
  871. return &rport->dev;
  872. return NULL;
  873. }
  874. struct scsi_transport_template *
  875. fc_attach_transport(struct fc_function_template *ft)
  876. {
  877. struct fc_internal *i = kmalloc(sizeof(struct fc_internal),
  878. GFP_KERNEL);
  879. int count;
  880. if (unlikely(!i))
  881. return NULL;
  882. memset(i, 0, sizeof(struct fc_internal));
  883. i->t.target_attrs.ac.attrs = &i->starget_attrs[0];
  884. i->t.target_attrs.ac.class = &fc_transport_class.class;
  885. i->t.target_attrs.ac.match = fc_target_match;
  886. i->t.target_size = sizeof(struct fc_starget_attrs);
  887. transport_container_register(&i->t.target_attrs);
  888. i->t.host_attrs.ac.attrs = &i->host_attrs[0];
  889. i->t.host_attrs.ac.class = &fc_host_class.class;
  890. i->t.host_attrs.ac.match = fc_host_match;
  891. i->t.host_size = sizeof(struct fc_host_attrs);
  892. if (ft->get_fc_host_stats)
  893. i->t.host_attrs.statistics = &fc_statistics_group;
  894. transport_container_register(&i->t.host_attrs);
  895. i->rport_attr_cont.ac.attrs = &i->rport_attrs[0];
  896. i->rport_attr_cont.ac.class = &fc_rport_class.class;
  897. i->rport_attr_cont.ac.match = fc_rport_match;
  898. transport_container_register(&i->rport_attr_cont);
  899. i->f = ft;
  900. /* Transport uses the shost workq for scsi scanning */
  901. i->t.create_work_queue = 1;
  902. i->t.target_parent = fc_target_parent;
  903. /*
  904. * Setup SCSI Target Attributes.
  905. */
  906. count = 0;
  907. SETUP_STARGET_ATTRIBUTE_RD(node_name);
  908. SETUP_STARGET_ATTRIBUTE_RD(port_name);
  909. SETUP_STARGET_ATTRIBUTE_RD(port_id);
  910. BUG_ON(count > FC_STARGET_NUM_ATTRS);
  911. i->starget_attrs[count] = NULL;
  912. /*
  913. * Setup SCSI Host Attributes.
  914. */
  915. count=0;
  916. SETUP_HOST_ATTRIBUTE_RD(node_name);
  917. SETUP_HOST_ATTRIBUTE_RD(port_name);
  918. SETUP_HOST_ATTRIBUTE_RD(supported_classes);
  919. SETUP_HOST_ATTRIBUTE_RD(supported_fc4s);
  920. SETUP_HOST_ATTRIBUTE_RD(symbolic_name);
  921. SETUP_HOST_ATTRIBUTE_RD(supported_speeds);
  922. SETUP_HOST_ATTRIBUTE_RD(maxframe_size);
  923. SETUP_HOST_ATTRIBUTE_RD(serial_number);
  924. SETUP_HOST_ATTRIBUTE_RD(port_id);
  925. SETUP_HOST_ATTRIBUTE_RD(port_type);
  926. SETUP_HOST_ATTRIBUTE_RD(port_state);
  927. SETUP_HOST_ATTRIBUTE_RD(active_fc4s);
  928. SETUP_HOST_ATTRIBUTE_RD(speed);
  929. SETUP_HOST_ATTRIBUTE_RD(fabric_name);
  930. /* Transport-managed attributes */
  931. SETUP_PRIVATE_HOST_ATTRIBUTE_RW(tgtid_bind_type);
  932. BUG_ON(count > FC_HOST_NUM_ATTRS);
  933. i->host_attrs[count] = NULL;
  934. /*
  935. * Setup Remote Port Attributes.
  936. */
  937. count=0;
  938. SETUP_RPORT_ATTRIBUTE_RD(maxframe_size);
  939. SETUP_RPORT_ATTRIBUTE_RD(supported_classes);
  940. SETUP_RPORT_ATTRIBUTE_RW(dev_loss_tmo);
  941. SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(node_name);
  942. SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_name);
  943. SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_id);
  944. SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(roles);
  945. SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_state);
  946. SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(scsi_target_id);
  947. BUG_ON(count > FC_RPORT_NUM_ATTRS);
  948. i->rport_attrs[count] = NULL;
  949. return &i->t;
  950. }
  951. EXPORT_SYMBOL(fc_attach_transport);
  952. void fc_release_transport(struct scsi_transport_template *t)
  953. {
  954. struct fc_internal *i = to_fc_internal(t);
  955. transport_container_unregister(&i->t.target_attrs);
  956. transport_container_unregister(&i->t.host_attrs);
  957. transport_container_unregister(&i->rport_attr_cont);
  958. kfree(i);
  959. }
  960. EXPORT_SYMBOL(fc_release_transport);
  961. /**
  962. * fc_remove_host - called to terminate any fc_transport-related elements
  963. * for a scsi host.
  964. * @rport: remote port to be unblocked.
  965. *
  966. * This routine is expected to be called immediately preceeding the
  967. * a driver's call to scsi_remove_host().
  968. *
  969. * WARNING: A driver utilizing the fc_transport, which fails to call
  970. * this routine prior to scsi_remote_host(), will leave dangling
  971. * objects in /sys/class/fc_remote_ports. Access to any of these
  972. * objects can result in a system crash !!!
  973. *
  974. * Notes:
  975. * This routine assumes no locks are held on entry.
  976. **/
  977. void
  978. fc_remove_host(struct Scsi_Host *shost)
  979. {
  980. struct fc_rport *rport, *next_rport;
  981. /* Remove any remote ports */
  982. list_for_each_entry_safe(rport, next_rport,
  983. &fc_host_rports(shost), peers)
  984. fc_rport_terminate(rport);
  985. list_for_each_entry_safe(rport, next_rport,
  986. &fc_host_rport_bindings(shost), peers)
  987. fc_rport_terminate(rport);
  988. }
  989. EXPORT_SYMBOL(fc_remove_host);
  990. /**
  991. * fc_rport_create - allocates and creates a remote FC port.
  992. * @shost: scsi host the remote port is connected to.
  993. * @channel: Channel on shost port connected to.
  994. * @ids: The world wide names, fc address, and FC4 port
  995. * roles for the remote port.
  996. *
  997. * Allocates and creates the remoter port structure, including the
  998. * class and sysfs creation.
  999. *
  1000. * Notes:
  1001. * This routine assumes no locks are held on entry.
  1002. **/
  1003. struct fc_rport *
  1004. fc_rport_create(struct Scsi_Host *shost, int channel,
  1005. struct fc_rport_identifiers *ids)
  1006. {
  1007. struct fc_host_attrs *fc_host =
  1008. (struct fc_host_attrs *)shost->shost_data;
  1009. struct fc_internal *fci = to_fc_internal(shost->transportt);
  1010. struct fc_rport *rport;
  1011. struct device *dev;
  1012. unsigned long flags;
  1013. int error;
  1014. size_t size;
  1015. size = (sizeof(struct fc_rport) + fci->f->dd_fcrport_size);
  1016. rport = kmalloc(size, GFP_KERNEL);
  1017. if (unlikely(!rport)) {
  1018. printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__);
  1019. return NULL;
  1020. }
  1021. memset(rport, 0, size);
  1022. rport->maxframe_size = -1;
  1023. rport->supported_classes = FC_COS_UNSPECIFIED;
  1024. rport->dev_loss_tmo = fc_dev_loss_tmo;
  1025. memcpy(&rport->node_name, &ids->node_name, sizeof(rport->node_name));
  1026. memcpy(&rport->port_name, &ids->port_name, sizeof(rport->port_name));
  1027. rport->port_id = ids->port_id;
  1028. rport->roles = ids->roles;
  1029. rport->port_state = FC_PORTSTATE_ONLINE;
  1030. if (fci->f->dd_fcrport_size)
  1031. rport->dd_data = &rport[1];
  1032. rport->channel = channel;
  1033. INIT_WORK(&rport->dev_loss_work, fc_timeout_blocked_rport, rport);
  1034. INIT_WORK(&rport->scan_work, fc_scsi_scan_rport, rport);
  1035. spin_lock_irqsave(shost->host_lock, flags);
  1036. rport->number = fc_host->next_rport_number++;
  1037. if (rport->roles & FC_RPORT_ROLE_FCP_TARGET)
  1038. rport->scsi_target_id = fc_host->next_target_id++;
  1039. else
  1040. rport->scsi_target_id = -1;
  1041. list_add_tail(&rport->peers, &fc_host_rports(shost));
  1042. get_device(&shost->shost_gendev);
  1043. spin_unlock_irqrestore(shost->host_lock, flags);
  1044. dev = &rport->dev;
  1045. device_initialize(dev);
  1046. dev->parent = get_device(&shost->shost_gendev);
  1047. dev->release = fc_rport_dev_release;
  1048. sprintf(dev->bus_id, "rport-%d:%d-%d",
  1049. shost->host_no, channel, rport->number);
  1050. transport_setup_device(dev);
  1051. error = device_add(dev);
  1052. if (error) {
  1053. printk(KERN_ERR "FC Remote Port device_add failed\n");
  1054. goto delete_rport;
  1055. }
  1056. transport_add_device(dev);
  1057. transport_configure_device(dev);
  1058. if (rport->roles & FC_RPORT_ROLE_FCP_TARGET)
  1059. /* initiate a scan of the target */
  1060. scsi_queue_work(shost, &rport->scan_work);
  1061. return rport;
  1062. delete_rport:
  1063. transport_destroy_device(dev);
  1064. put_device(dev->parent);
  1065. spin_lock_irqsave(shost->host_lock, flags);
  1066. list_del(&rport->peers);
  1067. put_device(&shost->shost_gendev);
  1068. spin_unlock_irqrestore(shost->host_lock, flags);
  1069. put_device(dev->parent);
  1070. kfree(rport);
  1071. return NULL;
  1072. }
  1073. /**
  1074. * fc_remote_port_add - notifies the fc transport of the existence
  1075. * of a remote FC port.
  1076. * @shost: scsi host the remote port is connected to.
  1077. * @channel: Channel on shost port connected to.
  1078. * @ids: The world wide names, fc address, and FC4 port
  1079. * roles for the remote port.
  1080. *
  1081. * The LLDD calls this routine to notify the transport of the existence
  1082. * of a remote port. The LLDD provides the unique identifiers (wwpn,wwn)
  1083. * of the port, it's FC address (port_id), and the FC4 roles that are
  1084. * active for the port.
  1085. *
  1086. * For ports that are FCP targets (aka scsi targets), the FC transport
  1087. * maintains consistent target id bindings on behalf of the LLDD.
  1088. * A consistent target id binding is an assignment of a target id to
  1089. * a remote port identifier, which persists while the scsi host is
  1090. * attached. The remote port can disappear, then later reappear, and
  1091. * it's target id assignment remains the same. This allows for shifts
  1092. * in FC addressing (if binding by wwpn or wwnn) with no apparent
  1093. * changes to the scsi subsystem which is based on scsi host number and
  1094. * target id values. Bindings are only valid during the attachment of
  1095. * the scsi host. If the host detaches, then later re-attaches, target
  1096. * id bindings may change.
  1097. *
  1098. * This routine is responsible for returning a remote port structure.
  1099. * The routine will search the list of remote ports it maintains
  1100. * internally on behalf of consistent target id mappings. If found, the
  1101. * remote port structure will be reused. Otherwise, a new remote port
  1102. * structure will be allocated.
  1103. *
  1104. * Whenever a remote port is allocated, a new fc_remote_port class
  1105. * device is created.
  1106. *
  1107. * Should not be called from interrupt context.
  1108. *
  1109. * Notes:
  1110. * This routine assumes no locks are held on entry.
  1111. **/
  1112. struct fc_rport *
  1113. fc_remote_port_add(struct Scsi_Host *shost, int channel,
  1114. struct fc_rport_identifiers *ids)
  1115. {
  1116. struct fc_rport *rport;
  1117. unsigned long flags;
  1118. int match = 0;
  1119. if (likely((ids->roles & FC_RPORT_ROLE_FCP_TARGET) &&
  1120. (fc_host_tgtid_bind_type(shost) != FC_TGTID_BIND_NONE))) {
  1121. /* search for a matching consistent binding */
  1122. spin_lock_irqsave(shost->host_lock, flags);
  1123. list_for_each_entry(rport, &fc_host_rport_bindings(shost),
  1124. peers) {
  1125. if (rport->channel != channel)
  1126. continue;
  1127. switch (fc_host_tgtid_bind_type(shost)) {
  1128. case FC_TGTID_BIND_BY_WWPN:
  1129. if (rport->port_name == ids->port_name)
  1130. match = 1;
  1131. break;
  1132. case FC_TGTID_BIND_BY_WWNN:
  1133. if (rport->node_name == ids->node_name)
  1134. match = 1;
  1135. break;
  1136. case FC_TGTID_BIND_BY_ID:
  1137. if (rport->port_id == ids->port_id)
  1138. match = 1;
  1139. break;
  1140. case FC_TGTID_BIND_NONE: /* to keep compiler happy */
  1141. break;
  1142. }
  1143. if (match) {
  1144. list_move_tail(&rport->peers,
  1145. &fc_host_rports(shost));
  1146. break;
  1147. }
  1148. }
  1149. spin_unlock_irqrestore(shost->host_lock, flags);
  1150. if (match) {
  1151. memcpy(&rport->node_name, &ids->node_name,
  1152. sizeof(rport->node_name));
  1153. memcpy(&rport->port_name, &ids->port_name,
  1154. sizeof(rport->port_name));
  1155. rport->port_id = ids->port_id;
  1156. rport->roles = ids->roles;
  1157. rport->port_state = FC_PORTSTATE_ONLINE;
  1158. if (rport->roles & FC_RPORT_ROLE_FCP_TARGET)
  1159. /* initiate a scan of the target */
  1160. scsi_queue_work(shost, &rport->scan_work);
  1161. return rport;
  1162. }
  1163. }
  1164. /* No consistent binding found - create new remote port entry */
  1165. rport = fc_rport_create(shost, channel, ids);
  1166. return rport;
  1167. }
  1168. EXPORT_SYMBOL(fc_remote_port_add);
  1169. /*
  1170. * fc_rport_tgt_remove - Removes the scsi target on the remote port
  1171. * @rport: The remote port to be operated on
  1172. */
  1173. static void
  1174. fc_rport_tgt_remove(struct fc_rport *rport)
  1175. {
  1176. struct Scsi_Host *shost = rport_to_shost(rport);
  1177. scsi_target_unblock(&rport->dev);
  1178. /* Stop anything on the workq */
  1179. if (!cancel_delayed_work(&rport->dev_loss_work))
  1180. flush_scheduled_work();
  1181. scsi_flush_work(shost);
  1182. scsi_remove_target(&rport->dev);
  1183. }
  1184. /*
  1185. * fc_rport_terminate - this routine tears down and deallocates a remote port.
  1186. * @rport: The remote port to be terminated
  1187. *
  1188. * Notes:
  1189. * This routine assumes no locks are held on entry.
  1190. */
  1191. static void
  1192. fc_rport_terminate(struct fc_rport *rport)
  1193. {
  1194. struct Scsi_Host *shost = rport_to_shost(rport);
  1195. struct device *dev = &rport->dev;
  1196. unsigned long flags;
  1197. fc_rport_tgt_remove(rport);
  1198. transport_remove_device(dev);
  1199. device_del(dev);
  1200. transport_destroy_device(dev);
  1201. spin_lock_irqsave(shost->host_lock, flags);
  1202. list_del(&rport->peers);
  1203. spin_unlock_irqrestore(shost->host_lock, flags);
  1204. put_device(&shost->shost_gendev);
  1205. }
  1206. /**
  1207. * fc_remote_port_delete - notifies the fc transport that a remote
  1208. * port is no longer in existence.
  1209. * @rport: The remote port that no longer exists
  1210. *
  1211. * The LLDD calls this routine to notify the transport that a remote
  1212. * port is no longer part of the topology. Note: Although a port
  1213. * may no longer be part of the topology, it may persist in the remote
  1214. * ports displayed by the fc_host. This is done so that target id
  1215. * mappings (managed via the remote port structures), are always visible
  1216. * as long as the mapping is valid, regardless of port state,
  1217. *
  1218. * If the remote port is not an FCP Target, it will be fully torn down
  1219. * and deallocated, including the fc_remote_port class device.
  1220. *
  1221. * If the remote port is an FCP Target, the port structure will be
  1222. * marked as Not Present, but will remain as long as there is a valid
  1223. * SCSI target id mapping associated with the port structure. Validity
  1224. * is determined by the binding type. If binding by wwpn, then the port
  1225. * structure is always valid and will not be deallocated until the host
  1226. * is removed. If binding by wwnn, then the port structure is valid
  1227. * until another port with the same node name is found in the topology.
  1228. * If binding by port id (fc address), then the port structure is valid
  1229. * valid until another port with the same address is identified.
  1230. *
  1231. * Called from interrupt or normal process context.
  1232. *
  1233. * Notes:
  1234. * This routine assumes no locks are held on entry.
  1235. **/
  1236. void
  1237. fc_remote_port_delete(struct fc_rport *rport)
  1238. {
  1239. struct Scsi_Host *shost = rport_to_shost(rport);
  1240. unsigned long flags;
  1241. /* If no scsi target id mapping or consistent binding type, delete it */
  1242. if ((rport->scsi_target_id == -1) ||
  1243. (fc_host_tgtid_bind_type(shost) == FC_TGTID_BIND_NONE)) {
  1244. fc_rport_terminate(rport);
  1245. return;
  1246. }
  1247. fc_rport_tgt_remove(rport);
  1248. spin_lock_irqsave(shost->host_lock, flags);
  1249. list_move_tail(&rport->peers, &fc_host_rport_bindings(shost));
  1250. spin_unlock_irqrestore(shost->host_lock, flags);
  1251. /*
  1252. * Note: We do not remove or clear the hostdata area. This allows
  1253. * host-specific target data to persist along with the
  1254. * scsi_target_id. It's up to the host to manage it's hostdata area.
  1255. */
  1256. /*
  1257. * Reinitialize port attributes that may change if the port comes back.
  1258. */
  1259. rport->maxframe_size = -1;
  1260. rport->supported_classes = FC_COS_UNSPECIFIED;
  1261. rport->roles = FC_RPORT_ROLE_UNKNOWN;
  1262. rport->port_state = FC_PORTSTATE_NOTPRESENT;
  1263. /* remove the identifiers that aren't used in the consisting binding */
  1264. switch (fc_host_tgtid_bind_type(shost)) {
  1265. case FC_TGTID_BIND_BY_WWPN:
  1266. rport->node_name = -1;
  1267. rport->port_id = -1;
  1268. break;
  1269. case FC_TGTID_BIND_BY_WWNN:
  1270. rport->port_name = -1;
  1271. rport->port_id = -1;
  1272. break;
  1273. case FC_TGTID_BIND_BY_ID:
  1274. rport->node_name = -1;
  1275. rport->port_name = -1;
  1276. break;
  1277. case FC_TGTID_BIND_NONE: /* to keep compiler happy */
  1278. break;
  1279. }
  1280. }
  1281. EXPORT_SYMBOL(fc_remote_port_delete);
  1282. /**
  1283. * fc_remote_port_rolechg - notifies the fc transport that the roles
  1284. * on a remote may have changed.
  1285. * @rport: The remote port that changed.
  1286. *
  1287. * The LLDD calls this routine to notify the transport that the roles
  1288. * on a remote port may have changed. The largest effect of this is
  1289. * if a port now becomes a FCP Target, it must be allocated a
  1290. * scsi target id. If the port is no longer a FCP target, any
  1291. * scsi target id value assigned to it will persist in case the
  1292. * role changes back to include FCP Target. No changes in the scsi
  1293. * midlayer will be invoked if the role changes (in the expectation
  1294. * that the role will be resumed. If it doesn't normal error processing
  1295. * will take place).
  1296. *
  1297. * Should not be called from interrupt context.
  1298. *
  1299. * Notes:
  1300. * This routine assumes no locks are held on entry.
  1301. **/
  1302. void
  1303. fc_remote_port_rolechg(struct fc_rport *rport, u32 roles)
  1304. {
  1305. struct Scsi_Host *shost = rport_to_shost(rport);
  1306. struct fc_host_attrs *fc_host =
  1307. (struct fc_host_attrs *)shost->shost_data;
  1308. unsigned long flags;
  1309. int create = 0;
  1310. rport->roles = roles;
  1311. spin_lock_irqsave(shost->host_lock, flags);
  1312. if ((rport->scsi_target_id == -1) &&
  1313. (rport->roles & FC_RPORT_ROLE_FCP_TARGET)) {
  1314. rport->scsi_target_id = fc_host->next_target_id++;
  1315. create = 1;
  1316. }
  1317. spin_unlock_irqrestore(shost->host_lock, flags);
  1318. if (create)
  1319. /* initiate a scan of the target */
  1320. scsi_queue_work(shost, &rport->scan_work);
  1321. }
  1322. EXPORT_SYMBOL(fc_remote_port_rolechg);
  1323. /**
  1324. * fc_timeout_blocked_rport - Timeout handler for blocked remote port
  1325. * that fails to return in the alloted time.
  1326. * @data: scsi target that failed to reappear in the alloted time.
  1327. **/
  1328. static void
  1329. fc_timeout_blocked_rport(void *data)
  1330. {
  1331. struct fc_rport *rport = (struct fc_rport *)data;
  1332. rport->port_state = FC_PORTSTATE_OFFLINE;
  1333. dev_printk(KERN_ERR, &rport->dev,
  1334. "blocked FC remote port time out: removing target\n");
  1335. /*
  1336. * As this only occurs if the remote port (scsi target)
  1337. * went away and didn't come back - we'll remove
  1338. * all attached scsi devices.
  1339. */
  1340. scsi_target_unblock(&rport->dev);
  1341. scsi_remove_target(&rport->dev);
  1342. }
  1343. /**
  1344. * fc_remote_port_block - temporarily block any scsi traffic to a remote port.
  1345. * @rport: remote port to be blocked.
  1346. *
  1347. * scsi lldd's with a FC transport call this routine to temporarily stop
  1348. * all scsi traffic to a remote port. If the port is not a SCSI target,
  1349. * no action is taken. If the port is a SCSI target, all attached devices
  1350. * are placed into a SDEV_BLOCK state and a timer is started. The timer is
  1351. * represents the maximum amount of time the port may be blocked. If the
  1352. * timer expires, the port is considered non-existent and the attached
  1353. * scsi devices will be removed.
  1354. *
  1355. * Called from interrupt or normal process context.
  1356. *
  1357. * Returns zero if successful or error if not
  1358. *
  1359. * Notes:
  1360. * This routine assumes no locks are held on entry.
  1361. *
  1362. * The timeout and timer types are extracted from the fc transport
  1363. * attributes from the caller's rport pointer.
  1364. **/
  1365. int
  1366. fc_remote_port_block(struct fc_rport *rport)
  1367. {
  1368. int timeout = rport->dev_loss_tmo;
  1369. struct work_struct *work = &rport->dev_loss_work;
  1370. if (timeout < 0 || timeout > SCSI_DEVICE_BLOCK_MAX_TIMEOUT)
  1371. return -EINVAL;
  1372. scsi_target_block(&rport->dev);
  1373. /* cap the length the devices can be blocked */
  1374. schedule_delayed_work(work, timeout * HZ);
  1375. rport->port_state = FC_PORTSTATE_BLOCKED;
  1376. return 0;
  1377. }
  1378. EXPORT_SYMBOL(fc_remote_port_block);
  1379. /**
  1380. * fc_remote_port_unblock - restart any blocked scsi traffic to a remote port.
  1381. * @rport: remote port to be unblocked.
  1382. *
  1383. * scsi lld's with a FC transport call this routine to restart IO to all
  1384. * devices associated with the caller's scsi target following a fc_target_block
  1385. * request. Called from interrupt or normal process context.
  1386. *
  1387. * Notes:
  1388. * This routine assumes no locks are held on entry.
  1389. **/
  1390. void
  1391. fc_remote_port_unblock(struct fc_rport *rport)
  1392. {
  1393. struct work_struct *work = &rport->dev_loss_work;
  1394. struct Scsi_Host *shost = rport_to_shost(rport);
  1395. /*
  1396. * Stop the target timer first. Take no action on the del_timer
  1397. * failure as the state machine state change will validate the
  1398. * transaction.
  1399. */
  1400. if (!cancel_delayed_work(work))
  1401. flush_scheduled_work();
  1402. if (rport->port_state == FC_PORTSTATE_OFFLINE)
  1403. /*
  1404. * initiate a scan of the target as the target has
  1405. * been torn down.
  1406. */
  1407. scsi_queue_work(shost, &rport->scan_work);
  1408. else
  1409. scsi_target_unblock(&rport->dev);
  1410. rport->port_state = FC_PORTSTATE_ONLINE;
  1411. }
  1412. EXPORT_SYMBOL(fc_remote_port_unblock);
  1413. /**
  1414. * fc_scsi_scan_rport - called to perform a scsi scan on a remote port.
  1415. * @data: remote port to be scanned.
  1416. **/
  1417. static void
  1418. fc_scsi_scan_rport(void *data)
  1419. {
  1420. struct fc_rport *rport = (struct fc_rport *)data;
  1421. scsi_scan_target(&rport->dev, rport->channel, rport->scsi_target_id,
  1422. SCAN_WILD_CARD, 1);
  1423. }
  1424. MODULE_AUTHOR("Martin Hicks");
  1425. MODULE_DESCRIPTION("FC Transport Attributes");
  1426. MODULE_LICENSE("GPL");
  1427. module_init(fc_transport_init);
  1428. module_exit(fc_transport_exit);