scsi_transport_fc.c 51 KB

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