scsi_transport_fc.c 51 KB

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