scsi_transport_sas.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178
  1. /*
  2. * Copyright (C) 2005-2006 Dell Inc.
  3. * Released under GPL v2.
  4. *
  5. * Serial Attached SCSI (SAS) transport class.
  6. *
  7. * The SAS transport class contains common code to deal with SAS HBAs,
  8. * an aproximated representation of SAS topologies in the driver model,
  9. * and various sysfs attributes to expose these topologies and managment
  10. * interfaces to userspace.
  11. *
  12. * In addition to the basic SCSI core objects this transport class
  13. * introduces two additional intermediate objects: The SAS PHY
  14. * as represented by struct sas_phy defines an "outgoing" PHY on
  15. * a SAS HBA or Expander, and the SAS remote PHY represented by
  16. * struct sas_rphy defines an "incoming" PHY on a SAS Expander or
  17. * end device. Note that this is purely a software concept, the
  18. * underlying hardware for a PHY and a remote PHY is the exactly
  19. * the same.
  20. *
  21. * There is no concept of a SAS port in this code, users can see
  22. * what PHYs form a wide port based on the port_identifier attribute,
  23. * which is the same for all PHYs in a port.
  24. */
  25. #include <linux/init.h>
  26. #include <linux/module.h>
  27. #include <linux/err.h>
  28. #include <linux/slab.h>
  29. #include <linux/string.h>
  30. #include <scsi/scsi.h>
  31. #include <scsi/scsi_device.h>
  32. #include <scsi/scsi_host.h>
  33. #include <scsi/scsi_transport.h>
  34. #include <scsi/scsi_transport_sas.h>
  35. #include "scsi_sas_internal.h"
  36. struct sas_host_attrs {
  37. struct list_head rphy_list;
  38. struct mutex lock;
  39. u32 next_target_id;
  40. u32 next_expander_id;
  41. };
  42. #define to_sas_host_attrs(host) ((struct sas_host_attrs *)(host)->shost_data)
  43. /*
  44. * Hack to allow attributes of the same name in different objects.
  45. */
  46. #define SAS_CLASS_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \
  47. struct class_device_attribute class_device_attr_##_prefix##_##_name = \
  48. __ATTR(_name,_mode,_show,_store)
  49. /*
  50. * Pretty printing helpers
  51. */
  52. #define sas_bitfield_name_match(title, table) \
  53. static ssize_t \
  54. get_sas_##title##_names(u32 table_key, char *buf) \
  55. { \
  56. char *prefix = ""; \
  57. ssize_t len = 0; \
  58. int i; \
  59. \
  60. for (i = 0; i < sizeof(table)/sizeof(table[0]); i++) { \
  61. if (table[i].value & table_key) { \
  62. len += sprintf(buf + len, "%s%s", \
  63. prefix, table[i].name); \
  64. prefix = ", "; \
  65. } \
  66. } \
  67. len += sprintf(buf + len, "\n"); \
  68. return len; \
  69. }
  70. #define sas_bitfield_name_search(title, table) \
  71. static ssize_t \
  72. get_sas_##title##_names(u32 table_key, char *buf) \
  73. { \
  74. ssize_t len = 0; \
  75. int i; \
  76. \
  77. for (i = 0; i < sizeof(table)/sizeof(table[0]); i++) { \
  78. if (table[i].value == table_key) { \
  79. len += sprintf(buf + len, "%s", \
  80. table[i].name); \
  81. break; \
  82. } \
  83. } \
  84. len += sprintf(buf + len, "\n"); \
  85. return len; \
  86. }
  87. static struct {
  88. u32 value;
  89. char *name;
  90. } sas_device_type_names[] = {
  91. { SAS_PHY_UNUSED, "unused" },
  92. { SAS_END_DEVICE, "end device" },
  93. { SAS_EDGE_EXPANDER_DEVICE, "edge expander" },
  94. { SAS_FANOUT_EXPANDER_DEVICE, "fanout expander" },
  95. };
  96. sas_bitfield_name_search(device_type, sas_device_type_names)
  97. static struct {
  98. u32 value;
  99. char *name;
  100. } sas_protocol_names[] = {
  101. { SAS_PROTOCOL_SATA, "sata" },
  102. { SAS_PROTOCOL_SMP, "smp" },
  103. { SAS_PROTOCOL_STP, "stp" },
  104. { SAS_PROTOCOL_SSP, "ssp" },
  105. };
  106. sas_bitfield_name_match(protocol, sas_protocol_names)
  107. static struct {
  108. u32 value;
  109. char *name;
  110. } sas_linkspeed_names[] = {
  111. { SAS_LINK_RATE_UNKNOWN, "Unknown" },
  112. { SAS_PHY_DISABLED, "Phy disabled" },
  113. { SAS_LINK_RATE_FAILED, "Link Rate failed" },
  114. { SAS_SATA_SPINUP_HOLD, "Spin-up hold" },
  115. { SAS_LINK_RATE_1_5_GBPS, "1.5 Gbit" },
  116. { SAS_LINK_RATE_3_0_GBPS, "3.0 Gbit" },
  117. { SAS_LINK_RATE_6_0_GBPS, "6.0 Gbit" },
  118. };
  119. sas_bitfield_name_search(linkspeed, sas_linkspeed_names)
  120. /*
  121. * SAS host attributes
  122. */
  123. static int sas_host_setup(struct transport_container *tc, struct device *dev,
  124. struct class_device *cdev)
  125. {
  126. struct Scsi_Host *shost = dev_to_shost(dev);
  127. struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
  128. INIT_LIST_HEAD(&sas_host->rphy_list);
  129. mutex_init(&sas_host->lock);
  130. sas_host->next_target_id = 0;
  131. sas_host->next_expander_id = 0;
  132. return 0;
  133. }
  134. static DECLARE_TRANSPORT_CLASS(sas_host_class,
  135. "sas_host", sas_host_setup, NULL, NULL);
  136. static int sas_host_match(struct attribute_container *cont,
  137. struct device *dev)
  138. {
  139. struct Scsi_Host *shost;
  140. struct sas_internal *i;
  141. if (!scsi_is_host_device(dev))
  142. return 0;
  143. shost = dev_to_shost(dev);
  144. if (!shost->transportt)
  145. return 0;
  146. if (shost->transportt->host_attrs.ac.class !=
  147. &sas_host_class.class)
  148. return 0;
  149. i = to_sas_internal(shost->transportt);
  150. return &i->t.host_attrs.ac == cont;
  151. }
  152. static int do_sas_phy_delete(struct device *dev, void *data)
  153. {
  154. if (scsi_is_sas_phy(dev))
  155. sas_phy_delete(dev_to_phy(dev));
  156. return 0;
  157. }
  158. /**
  159. * sas_remove_host -- tear down a Scsi_Host's SAS data structures
  160. * @shost: Scsi Host that is torn down
  161. *
  162. * Removes all SAS PHYs and remote PHYs for a given Scsi_Host.
  163. * Must be called just before scsi_remove_host for SAS HBAs.
  164. */
  165. void sas_remove_host(struct Scsi_Host *shost)
  166. {
  167. device_for_each_child(&shost->shost_gendev, NULL, do_sas_phy_delete);
  168. }
  169. EXPORT_SYMBOL(sas_remove_host);
  170. /*
  171. * SAS Port attributes
  172. */
  173. #define sas_phy_show_simple(field, name, format_string, cast) \
  174. static ssize_t \
  175. show_sas_phy_##name(struct class_device *cdev, char *buf) \
  176. { \
  177. struct sas_phy *phy = transport_class_to_phy(cdev); \
  178. \
  179. return snprintf(buf, 20, format_string, cast phy->field); \
  180. }
  181. #define sas_phy_simple_attr(field, name, format_string, type) \
  182. sas_phy_show_simple(field, name, format_string, (type)) \
  183. static CLASS_DEVICE_ATTR(name, S_IRUGO, show_sas_phy_##name, NULL)
  184. #define sas_phy_show_protocol(field, name) \
  185. static ssize_t \
  186. show_sas_phy_##name(struct class_device *cdev, char *buf) \
  187. { \
  188. struct sas_phy *phy = transport_class_to_phy(cdev); \
  189. \
  190. if (!phy->field) \
  191. return snprintf(buf, 20, "none\n"); \
  192. return get_sas_protocol_names(phy->field, buf); \
  193. }
  194. #define sas_phy_protocol_attr(field, name) \
  195. sas_phy_show_protocol(field, name) \
  196. static CLASS_DEVICE_ATTR(name, S_IRUGO, show_sas_phy_##name, NULL)
  197. #define sas_phy_show_linkspeed(field) \
  198. static ssize_t \
  199. show_sas_phy_##field(struct class_device *cdev, char *buf) \
  200. { \
  201. struct sas_phy *phy = transport_class_to_phy(cdev); \
  202. \
  203. return get_sas_linkspeed_names(phy->field, buf); \
  204. }
  205. #define sas_phy_linkspeed_attr(field) \
  206. sas_phy_show_linkspeed(field) \
  207. static CLASS_DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL)
  208. #define sas_phy_show_linkerror(field) \
  209. static ssize_t \
  210. show_sas_phy_##field(struct class_device *cdev, char *buf) \
  211. { \
  212. struct sas_phy *phy = transport_class_to_phy(cdev); \
  213. struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); \
  214. struct sas_internal *i = to_sas_internal(shost->transportt); \
  215. int error; \
  216. \
  217. if (!phy->local_attached) \
  218. return -EINVAL; \
  219. \
  220. error = i->f->get_linkerrors ? i->f->get_linkerrors(phy) : 0; \
  221. if (error) \
  222. return error; \
  223. return snprintf(buf, 20, "%u\n", phy->field); \
  224. }
  225. #define sas_phy_linkerror_attr(field) \
  226. sas_phy_show_linkerror(field) \
  227. static CLASS_DEVICE_ATTR(field, S_IRUGO, show_sas_phy_##field, NULL)
  228. static ssize_t
  229. show_sas_device_type(struct class_device *cdev, char *buf)
  230. {
  231. struct sas_phy *phy = transport_class_to_phy(cdev);
  232. if (!phy->identify.device_type)
  233. return snprintf(buf, 20, "none\n");
  234. return get_sas_device_type_names(phy->identify.device_type, buf);
  235. }
  236. static CLASS_DEVICE_ATTR(device_type, S_IRUGO, show_sas_device_type, NULL);
  237. static ssize_t do_sas_phy_reset(struct class_device *cdev,
  238. size_t count, int hard_reset)
  239. {
  240. struct sas_phy *phy = transport_class_to_phy(cdev);
  241. struct Scsi_Host *shost = dev_to_shost(phy->dev.parent);
  242. struct sas_internal *i = to_sas_internal(shost->transportt);
  243. int error;
  244. if (!phy->local_attached)
  245. return -EINVAL;
  246. error = i->f->phy_reset(phy, hard_reset);
  247. if (error)
  248. return error;
  249. return count;
  250. };
  251. static ssize_t store_sas_link_reset(struct class_device *cdev,
  252. const char *buf, size_t count)
  253. {
  254. return do_sas_phy_reset(cdev, count, 0);
  255. }
  256. static CLASS_DEVICE_ATTR(link_reset, S_IWUSR, NULL, store_sas_link_reset);
  257. static ssize_t store_sas_hard_reset(struct class_device *cdev,
  258. const char *buf, size_t count)
  259. {
  260. return do_sas_phy_reset(cdev, count, 1);
  261. }
  262. static CLASS_DEVICE_ATTR(hard_reset, S_IWUSR, NULL, store_sas_hard_reset);
  263. sas_phy_protocol_attr(identify.initiator_port_protocols,
  264. initiator_port_protocols);
  265. sas_phy_protocol_attr(identify.target_port_protocols,
  266. target_port_protocols);
  267. sas_phy_simple_attr(identify.sas_address, sas_address, "0x%016llx\n",
  268. unsigned long long);
  269. sas_phy_simple_attr(identify.phy_identifier, phy_identifier, "%d\n", u8);
  270. sas_phy_simple_attr(port_identifier, port_identifier, "%d\n", u8);
  271. sas_phy_linkspeed_attr(negotiated_linkrate);
  272. sas_phy_linkspeed_attr(minimum_linkrate_hw);
  273. sas_phy_linkspeed_attr(minimum_linkrate);
  274. sas_phy_linkspeed_attr(maximum_linkrate_hw);
  275. sas_phy_linkspeed_attr(maximum_linkrate);
  276. sas_phy_linkerror_attr(invalid_dword_count);
  277. sas_phy_linkerror_attr(running_disparity_error_count);
  278. sas_phy_linkerror_attr(loss_of_dword_sync_count);
  279. sas_phy_linkerror_attr(phy_reset_problem_count);
  280. static DECLARE_TRANSPORT_CLASS(sas_phy_class,
  281. "sas_phy", NULL, NULL, NULL);
  282. static int sas_phy_match(struct attribute_container *cont, struct device *dev)
  283. {
  284. struct Scsi_Host *shost;
  285. struct sas_internal *i;
  286. if (!scsi_is_sas_phy(dev))
  287. return 0;
  288. shost = dev_to_shost(dev->parent);
  289. if (!shost->transportt)
  290. return 0;
  291. if (shost->transportt->host_attrs.ac.class !=
  292. &sas_host_class.class)
  293. return 0;
  294. i = to_sas_internal(shost->transportt);
  295. return &i->phy_attr_cont.ac == cont;
  296. }
  297. static void sas_phy_release(struct device *dev)
  298. {
  299. struct sas_phy *phy = dev_to_phy(dev);
  300. put_device(dev->parent);
  301. kfree(phy);
  302. }
  303. /**
  304. * sas_phy_alloc -- allocates and initialize a SAS PHY structure
  305. * @parent: Parent device
  306. * @number: Phy index
  307. *
  308. * Allocates an SAS PHY structure. It will be added in the device tree
  309. * below the device specified by @parent, which has to be either a Scsi_Host
  310. * or sas_rphy.
  311. *
  312. * Returns:
  313. * SAS PHY allocated or %NULL if the allocation failed.
  314. */
  315. struct sas_phy *sas_phy_alloc(struct device *parent, int number)
  316. {
  317. struct Scsi_Host *shost = dev_to_shost(parent);
  318. struct sas_phy *phy;
  319. phy = kzalloc(sizeof(*phy), GFP_KERNEL);
  320. if (!phy)
  321. return NULL;
  322. phy->number = number;
  323. device_initialize(&phy->dev);
  324. phy->dev.parent = get_device(parent);
  325. phy->dev.release = sas_phy_release;
  326. if (scsi_is_sas_expander_device(parent)) {
  327. struct sas_rphy *rphy = dev_to_rphy(parent);
  328. sprintf(phy->dev.bus_id, "phy-%d-%d:%d", shost->host_no,
  329. rphy->scsi_target_id, number);
  330. } else
  331. sprintf(phy->dev.bus_id, "phy-%d:%d", shost->host_no, number);
  332. transport_setup_device(&phy->dev);
  333. return phy;
  334. }
  335. EXPORT_SYMBOL(sas_phy_alloc);
  336. /**
  337. * sas_phy_add -- add a SAS PHY to the device hierachy
  338. * @phy: The PHY to be added
  339. *
  340. * Publishes a SAS PHY to the rest of the system.
  341. */
  342. int sas_phy_add(struct sas_phy *phy)
  343. {
  344. int error;
  345. error = device_add(&phy->dev);
  346. if (!error) {
  347. transport_add_device(&phy->dev);
  348. transport_configure_device(&phy->dev);
  349. }
  350. return error;
  351. }
  352. EXPORT_SYMBOL(sas_phy_add);
  353. /**
  354. * sas_phy_free -- free a SAS PHY
  355. * @phy: SAS PHY to free
  356. *
  357. * Frees the specified SAS PHY.
  358. *
  359. * Note:
  360. * This function must only be called on a PHY that has not
  361. * sucessfully been added using sas_phy_add().
  362. */
  363. void sas_phy_free(struct sas_phy *phy)
  364. {
  365. transport_destroy_device(&phy->dev);
  366. put_device(&phy->dev);
  367. }
  368. EXPORT_SYMBOL(sas_phy_free);
  369. /**
  370. * sas_phy_delete -- remove SAS PHY
  371. * @phy: SAS PHY to remove
  372. *
  373. * Removes the specified SAS PHY. If the SAS PHY has an
  374. * associated remote PHY it is removed before.
  375. */
  376. void
  377. sas_phy_delete(struct sas_phy *phy)
  378. {
  379. struct device *dev = &phy->dev;
  380. if (phy->rphy)
  381. sas_rphy_delete(phy->rphy);
  382. transport_remove_device(dev);
  383. device_del(dev);
  384. transport_destroy_device(dev);
  385. put_device(dev);
  386. }
  387. EXPORT_SYMBOL(sas_phy_delete);
  388. /**
  389. * scsi_is_sas_phy -- check if a struct device represents a SAS PHY
  390. * @dev: device to check
  391. *
  392. * Returns:
  393. * %1 if the device represents a SAS PHY, %0 else
  394. */
  395. int scsi_is_sas_phy(const struct device *dev)
  396. {
  397. return dev->release == sas_phy_release;
  398. }
  399. EXPORT_SYMBOL(scsi_is_sas_phy);
  400. /*
  401. * SAS remote PHY attributes.
  402. */
  403. #define sas_rphy_show_simple(field, name, format_string, cast) \
  404. static ssize_t \
  405. show_sas_rphy_##name(struct class_device *cdev, char *buf) \
  406. { \
  407. struct sas_rphy *rphy = transport_class_to_rphy(cdev); \
  408. \
  409. return snprintf(buf, 20, format_string, cast rphy->field); \
  410. }
  411. #define sas_rphy_simple_attr(field, name, format_string, type) \
  412. sas_rphy_show_simple(field, name, format_string, (type)) \
  413. static SAS_CLASS_DEVICE_ATTR(rphy, name, S_IRUGO, \
  414. show_sas_rphy_##name, NULL)
  415. #define sas_rphy_show_protocol(field, name) \
  416. static ssize_t \
  417. show_sas_rphy_##name(struct class_device *cdev, char *buf) \
  418. { \
  419. struct sas_rphy *rphy = transport_class_to_rphy(cdev); \
  420. \
  421. if (!rphy->field) \
  422. return snprintf(buf, 20, "none\n"); \
  423. return get_sas_protocol_names(rphy->field, buf); \
  424. }
  425. #define sas_rphy_protocol_attr(field, name) \
  426. sas_rphy_show_protocol(field, name) \
  427. static SAS_CLASS_DEVICE_ATTR(rphy, name, S_IRUGO, \
  428. show_sas_rphy_##name, NULL)
  429. static ssize_t
  430. show_sas_rphy_device_type(struct class_device *cdev, char *buf)
  431. {
  432. struct sas_rphy *rphy = transport_class_to_rphy(cdev);
  433. if (!rphy->identify.device_type)
  434. return snprintf(buf, 20, "none\n");
  435. return get_sas_device_type_names(
  436. rphy->identify.device_type, buf);
  437. }
  438. static SAS_CLASS_DEVICE_ATTR(rphy, device_type, S_IRUGO,
  439. show_sas_rphy_device_type, NULL);
  440. static ssize_t
  441. show_sas_rphy_enclosure_identifier(struct class_device *cdev, char *buf)
  442. {
  443. struct sas_rphy *rphy = transport_class_to_rphy(cdev);
  444. struct sas_phy *phy = dev_to_phy(rphy->dev.parent);
  445. struct Scsi_Host *shost = dev_to_shost(phy->dev.parent);
  446. struct sas_internal *i = to_sas_internal(shost->transportt);
  447. u64 identifier;
  448. int error;
  449. /*
  450. * Only devices behind an expander are supported, because the
  451. * enclosure identifier is a SMP feature.
  452. */
  453. if (phy->local_attached)
  454. return -EINVAL;
  455. error = i->f->get_enclosure_identifier(rphy, &identifier);
  456. if (error)
  457. return error;
  458. return sprintf(buf, "0x%llx\n", (unsigned long long)identifier);
  459. }
  460. static SAS_CLASS_DEVICE_ATTR(rphy, enclosure_identifier, S_IRUGO,
  461. show_sas_rphy_enclosure_identifier, NULL);
  462. static ssize_t
  463. show_sas_rphy_bay_identifier(struct class_device *cdev, char *buf)
  464. {
  465. struct sas_rphy *rphy = transport_class_to_rphy(cdev);
  466. struct sas_phy *phy = dev_to_phy(rphy->dev.parent);
  467. struct Scsi_Host *shost = dev_to_shost(phy->dev.parent);
  468. struct sas_internal *i = to_sas_internal(shost->transportt);
  469. int val;
  470. if (phy->local_attached)
  471. return -EINVAL;
  472. val = i->f->get_bay_identifier(rphy);
  473. if (val < 0)
  474. return val;
  475. return sprintf(buf, "%d\n", val);
  476. }
  477. static SAS_CLASS_DEVICE_ATTR(rphy, bay_identifier, S_IRUGO,
  478. show_sas_rphy_bay_identifier, NULL);
  479. sas_rphy_protocol_attr(identify.initiator_port_protocols,
  480. initiator_port_protocols);
  481. sas_rphy_protocol_attr(identify.target_port_protocols, target_port_protocols);
  482. sas_rphy_simple_attr(identify.sas_address, sas_address, "0x%016llx\n",
  483. unsigned long long);
  484. sas_rphy_simple_attr(identify.phy_identifier, phy_identifier, "%d\n", u8);
  485. /* only need 8 bytes of data plus header (4 or 8) */
  486. #define BUF_SIZE 64
  487. int sas_read_port_mode_page(struct scsi_device *sdev)
  488. {
  489. char *buffer = kzalloc(BUF_SIZE, GFP_KERNEL), *msdata;
  490. struct sas_rphy *rphy = target_to_rphy(sdev->sdev_target);
  491. struct sas_end_device *rdev;
  492. struct scsi_mode_data mode_data;
  493. int res, error;
  494. BUG_ON(rphy->identify.device_type != SAS_END_DEVICE);
  495. rdev = rphy_to_end_device(rphy);
  496. if (!buffer)
  497. return -ENOMEM;
  498. res = scsi_mode_sense(sdev, 1, 0x19, buffer, BUF_SIZE, 30*HZ, 3,
  499. &mode_data, NULL);
  500. error = -EINVAL;
  501. if (!scsi_status_is_good(res))
  502. goto out;
  503. msdata = buffer + mode_data.header_length +
  504. mode_data.block_descriptor_length;
  505. if (msdata - buffer > BUF_SIZE - 8)
  506. goto out;
  507. error = 0;
  508. rdev->ready_led_meaning = msdata[2] & 0x10 ? 1 : 0;
  509. rdev->I_T_nexus_loss_timeout = (msdata[4] << 8) + msdata[5];
  510. rdev->initiator_response_timeout = (msdata[6] << 8) + msdata[7];
  511. out:
  512. kfree(buffer);
  513. return error;
  514. }
  515. EXPORT_SYMBOL(sas_read_port_mode_page);
  516. static DECLARE_TRANSPORT_CLASS(sas_end_dev_class,
  517. "sas_end_device", NULL, NULL, NULL);
  518. #define sas_end_dev_show_simple(field, name, format_string, cast) \
  519. static ssize_t \
  520. show_sas_end_dev_##name(struct class_device *cdev, char *buf) \
  521. { \
  522. struct sas_rphy *rphy = transport_class_to_rphy(cdev); \
  523. struct sas_end_device *rdev = rphy_to_end_device(rphy); \
  524. \
  525. return snprintf(buf, 20, format_string, cast rdev->field); \
  526. }
  527. #define sas_end_dev_simple_attr(field, name, format_string, type) \
  528. sas_end_dev_show_simple(field, name, format_string, (type)) \
  529. static SAS_CLASS_DEVICE_ATTR(end_dev, name, S_IRUGO, \
  530. show_sas_end_dev_##name, NULL)
  531. sas_end_dev_simple_attr(ready_led_meaning, ready_led_meaning, "%d\n", int);
  532. sas_end_dev_simple_attr(I_T_nexus_loss_timeout, I_T_nexus_loss_timeout,
  533. "%d\n", int);
  534. sas_end_dev_simple_attr(initiator_response_timeout, initiator_response_timeout,
  535. "%d\n", int);
  536. static DECLARE_TRANSPORT_CLASS(sas_expander_class,
  537. "sas_expander", NULL, NULL, NULL);
  538. #define sas_expander_show_simple(field, name, format_string, cast) \
  539. static ssize_t \
  540. show_sas_expander_##name(struct class_device *cdev, char *buf) \
  541. { \
  542. struct sas_rphy *rphy = transport_class_to_rphy(cdev); \
  543. struct sas_expander_device *edev = rphy_to_expander_device(rphy); \
  544. \
  545. return snprintf(buf, 20, format_string, cast edev->field); \
  546. }
  547. #define sas_expander_simple_attr(field, name, format_string, type) \
  548. sas_expander_show_simple(field, name, format_string, (type)) \
  549. static SAS_CLASS_DEVICE_ATTR(expander, name, S_IRUGO, \
  550. show_sas_expander_##name, NULL)
  551. sas_expander_simple_attr(vendor_id, vendor_id, "%s\n", char *);
  552. sas_expander_simple_attr(product_id, product_id, "%s\n", char *);
  553. sas_expander_simple_attr(product_rev, product_rev, "%s\n", char *);
  554. sas_expander_simple_attr(component_vendor_id, component_vendor_id,
  555. "%s\n", char *);
  556. sas_expander_simple_attr(component_id, component_id, "%u\n", unsigned int);
  557. sas_expander_simple_attr(component_revision_id, component_revision_id, "%u\n",
  558. unsigned int);
  559. sas_expander_simple_attr(level, level, "%d\n", int);
  560. static DECLARE_TRANSPORT_CLASS(sas_rphy_class,
  561. "sas_device", NULL, NULL, NULL);
  562. static int sas_rphy_match(struct attribute_container *cont, struct device *dev)
  563. {
  564. struct Scsi_Host *shost;
  565. struct sas_internal *i;
  566. if (!scsi_is_sas_rphy(dev))
  567. return 0;
  568. shost = dev_to_shost(dev->parent->parent);
  569. if (!shost->transportt)
  570. return 0;
  571. if (shost->transportt->host_attrs.ac.class !=
  572. &sas_host_class.class)
  573. return 0;
  574. i = to_sas_internal(shost->transportt);
  575. return &i->rphy_attr_cont.ac == cont;
  576. }
  577. static int sas_end_dev_match(struct attribute_container *cont,
  578. struct device *dev)
  579. {
  580. struct Scsi_Host *shost;
  581. struct sas_internal *i;
  582. struct sas_rphy *rphy;
  583. if (!scsi_is_sas_rphy(dev))
  584. return 0;
  585. shost = dev_to_shost(dev->parent->parent);
  586. rphy = dev_to_rphy(dev);
  587. if (!shost->transportt)
  588. return 0;
  589. if (shost->transportt->host_attrs.ac.class !=
  590. &sas_host_class.class)
  591. return 0;
  592. i = to_sas_internal(shost->transportt);
  593. return &i->end_dev_attr_cont.ac == cont &&
  594. rphy->identify.device_type == SAS_END_DEVICE;
  595. }
  596. static int sas_expander_match(struct attribute_container *cont,
  597. struct device *dev)
  598. {
  599. struct Scsi_Host *shost;
  600. struct sas_internal *i;
  601. struct sas_rphy *rphy;
  602. if (!scsi_is_sas_rphy(dev))
  603. return 0;
  604. shost = dev_to_shost(dev->parent->parent);
  605. rphy = dev_to_rphy(dev);
  606. if (!shost->transportt)
  607. return 0;
  608. if (shost->transportt->host_attrs.ac.class !=
  609. &sas_host_class.class)
  610. return 0;
  611. i = to_sas_internal(shost->transportt);
  612. return &i->expander_attr_cont.ac == cont &&
  613. (rphy->identify.device_type == SAS_EDGE_EXPANDER_DEVICE ||
  614. rphy->identify.device_type == SAS_FANOUT_EXPANDER_DEVICE);
  615. }
  616. static void sas_expander_release(struct device *dev)
  617. {
  618. struct sas_rphy *rphy = dev_to_rphy(dev);
  619. struct sas_expander_device *edev = rphy_to_expander_device(rphy);
  620. put_device(dev->parent);
  621. kfree(edev);
  622. }
  623. static void sas_end_device_release(struct device *dev)
  624. {
  625. struct sas_rphy *rphy = dev_to_rphy(dev);
  626. struct sas_end_device *edev = rphy_to_end_device(rphy);
  627. put_device(dev->parent);
  628. kfree(edev);
  629. }
  630. /**
  631. * sas_end_device_alloc - allocate an rphy for an end device
  632. *
  633. * Allocates an SAS remote PHY structure, connected to @parent.
  634. *
  635. * Returns:
  636. * SAS PHY allocated or %NULL if the allocation failed.
  637. */
  638. struct sas_rphy *sas_end_device_alloc(struct sas_phy *parent)
  639. {
  640. struct Scsi_Host *shost = dev_to_shost(&parent->dev);
  641. struct sas_end_device *rdev;
  642. rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
  643. if (!rdev) {
  644. return NULL;
  645. }
  646. device_initialize(&rdev->rphy.dev);
  647. rdev->rphy.dev.parent = get_device(&parent->dev);
  648. rdev->rphy.dev.release = sas_end_device_release;
  649. sprintf(rdev->rphy.dev.bus_id, "end_device-%d:%d-%d",
  650. shost->host_no, parent->port_identifier, parent->number);
  651. rdev->rphy.identify.device_type = SAS_END_DEVICE;
  652. transport_setup_device(&rdev->rphy.dev);
  653. return &rdev->rphy;
  654. }
  655. EXPORT_SYMBOL(sas_end_device_alloc);
  656. /**
  657. * sas_expander_alloc - allocate an rphy for an end device
  658. *
  659. * Allocates an SAS remote PHY structure, connected to @parent.
  660. *
  661. * Returns:
  662. * SAS PHY allocated or %NULL if the allocation failed.
  663. */
  664. struct sas_rphy *sas_expander_alloc(struct sas_phy *parent,
  665. enum sas_device_type type)
  666. {
  667. struct Scsi_Host *shost = dev_to_shost(&parent->dev);
  668. struct sas_expander_device *rdev;
  669. struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
  670. BUG_ON(type != SAS_EDGE_EXPANDER_DEVICE &&
  671. type != SAS_FANOUT_EXPANDER_DEVICE);
  672. rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
  673. if (!rdev) {
  674. return NULL;
  675. }
  676. device_initialize(&rdev->rphy.dev);
  677. rdev->rphy.dev.parent = get_device(&parent->dev);
  678. rdev->rphy.dev.release = sas_expander_release;
  679. mutex_lock(&sas_host->lock);
  680. rdev->rphy.scsi_target_id = sas_host->next_expander_id++;
  681. mutex_unlock(&sas_host->lock);
  682. sprintf(rdev->rphy.dev.bus_id, "expander-%d:%d",
  683. shost->host_no, rdev->rphy.scsi_target_id);
  684. rdev->rphy.identify.device_type = type;
  685. transport_setup_device(&rdev->rphy.dev);
  686. return &rdev->rphy;
  687. }
  688. EXPORT_SYMBOL(sas_expander_alloc);
  689. /**
  690. * sas_rphy_add -- add a SAS remote PHY to the device hierachy
  691. * @rphy: The remote PHY to be added
  692. *
  693. * Publishes a SAS remote PHY to the rest of the system.
  694. */
  695. int sas_rphy_add(struct sas_rphy *rphy)
  696. {
  697. struct sas_phy *parent = dev_to_phy(rphy->dev.parent);
  698. struct Scsi_Host *shost = dev_to_shost(parent->dev.parent);
  699. struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
  700. struct sas_identify *identify = &rphy->identify;
  701. int error;
  702. if (parent->rphy)
  703. return -ENXIO;
  704. parent->rphy = rphy;
  705. error = device_add(&rphy->dev);
  706. if (error)
  707. return error;
  708. transport_add_device(&rphy->dev);
  709. transport_configure_device(&rphy->dev);
  710. mutex_lock(&sas_host->lock);
  711. list_add_tail(&rphy->list, &sas_host->rphy_list);
  712. if (identify->device_type == SAS_END_DEVICE &&
  713. (identify->target_port_protocols &
  714. (SAS_PROTOCOL_SSP|SAS_PROTOCOL_STP|SAS_PROTOCOL_SATA)))
  715. rphy->scsi_target_id = sas_host->next_target_id++;
  716. else if (identify->device_type == SAS_END_DEVICE)
  717. rphy->scsi_target_id = -1;
  718. mutex_unlock(&sas_host->lock);
  719. if (identify->device_type == SAS_END_DEVICE &&
  720. rphy->scsi_target_id != -1) {
  721. scsi_scan_target(&rphy->dev, parent->port_identifier,
  722. rphy->scsi_target_id, ~0, 0);
  723. }
  724. return 0;
  725. }
  726. EXPORT_SYMBOL(sas_rphy_add);
  727. /**
  728. * sas_rphy_free -- free a SAS remote PHY
  729. * @rphy SAS remote PHY to free
  730. *
  731. * Frees the specified SAS remote PHY.
  732. *
  733. * Note:
  734. * This function must only be called on a remote
  735. * PHY that has not sucessfully been added using
  736. * sas_rphy_add().
  737. */
  738. void sas_rphy_free(struct sas_rphy *rphy)
  739. {
  740. struct device *dev = &rphy->dev;
  741. struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent->parent);
  742. struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
  743. mutex_lock(&sas_host->lock);
  744. list_del(&rphy->list);
  745. mutex_unlock(&sas_host->lock);
  746. transport_destroy_device(dev);
  747. put_device(dev);
  748. }
  749. EXPORT_SYMBOL(sas_rphy_free);
  750. /**
  751. * sas_rphy_delete -- remove SAS remote PHY
  752. * @rphy: SAS remote PHY to remove
  753. *
  754. * Removes the specified SAS remote PHY.
  755. */
  756. void
  757. sas_rphy_delete(struct sas_rphy *rphy)
  758. {
  759. struct device *dev = &rphy->dev;
  760. struct sas_phy *parent = dev_to_phy(dev->parent);
  761. struct Scsi_Host *shost = dev_to_shost(parent->dev.parent);
  762. struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
  763. switch (rphy->identify.device_type) {
  764. case SAS_END_DEVICE:
  765. scsi_remove_target(dev);
  766. break;
  767. case SAS_EDGE_EXPANDER_DEVICE:
  768. case SAS_FANOUT_EXPANDER_DEVICE:
  769. device_for_each_child(dev, NULL, do_sas_phy_delete);
  770. break;
  771. default:
  772. break;
  773. }
  774. transport_remove_device(dev);
  775. device_del(dev);
  776. transport_destroy_device(dev);
  777. mutex_lock(&sas_host->lock);
  778. list_del(&rphy->list);
  779. mutex_unlock(&sas_host->lock);
  780. parent->rphy = NULL;
  781. put_device(dev);
  782. }
  783. EXPORT_SYMBOL(sas_rphy_delete);
  784. /**
  785. * scsi_is_sas_rphy -- check if a struct device represents a SAS remote PHY
  786. * @dev: device to check
  787. *
  788. * Returns:
  789. * %1 if the device represents a SAS remote PHY, %0 else
  790. */
  791. int scsi_is_sas_rphy(const struct device *dev)
  792. {
  793. return dev->release == sas_end_device_release ||
  794. dev->release == sas_expander_release;
  795. }
  796. EXPORT_SYMBOL(scsi_is_sas_rphy);
  797. /*
  798. * SCSI scan helper
  799. */
  800. static int sas_user_scan(struct Scsi_Host *shost, uint channel,
  801. uint id, uint lun)
  802. {
  803. struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
  804. struct sas_rphy *rphy;
  805. mutex_lock(&sas_host->lock);
  806. list_for_each_entry(rphy, &sas_host->rphy_list, list) {
  807. struct sas_phy *parent = dev_to_phy(rphy->dev.parent);
  808. if (rphy->identify.device_type != SAS_END_DEVICE ||
  809. rphy->scsi_target_id == -1)
  810. continue;
  811. if ((channel == SCAN_WILD_CARD || channel == parent->port_identifier) &&
  812. (id == SCAN_WILD_CARD || id == rphy->scsi_target_id)) {
  813. scsi_scan_target(&rphy->dev, parent->port_identifier,
  814. rphy->scsi_target_id, lun, 1);
  815. }
  816. }
  817. mutex_unlock(&sas_host->lock);
  818. return 0;
  819. }
  820. /*
  821. * Setup / Teardown code
  822. */
  823. #define SETUP_TEMPLATE(attrb, field, perm, test) \
  824. i->private_##attrb[count] = class_device_attr_##field; \
  825. i->private_##attrb[count].attr.mode = perm; \
  826. i->private_##attrb[count].store = NULL; \
  827. i->attrb[count] = &i->private_##attrb[count]; \
  828. if (test) \
  829. count++
  830. #define SETUP_RPORT_ATTRIBUTE(field) \
  831. SETUP_TEMPLATE(rphy_attrs, field, S_IRUGO, 1)
  832. #define SETUP_OPTIONAL_RPORT_ATTRIBUTE(field, func) \
  833. SETUP_TEMPLATE(rphy_attrs, field, S_IRUGO, i->f->func)
  834. #define SETUP_PORT_ATTRIBUTE(field) \
  835. SETUP_TEMPLATE(phy_attrs, field, S_IRUGO, 1)
  836. #define SETUP_OPTIONAL_PORT_ATTRIBUTE(field, func) \
  837. SETUP_TEMPLATE(phy_attrs, field, S_IRUGO, i->f->func)
  838. #define SETUP_PORT_ATTRIBUTE_WRONLY(field) \
  839. SETUP_TEMPLATE(phy_attrs, field, S_IWUGO, 1)
  840. #define SETUP_OPTIONAL_PORT_ATTRIBUTE_WRONLY(field, func) \
  841. SETUP_TEMPLATE(phy_attrs, field, S_IWUGO, i->f->func)
  842. #define SETUP_END_DEV_ATTRIBUTE(field) \
  843. SETUP_TEMPLATE(end_dev_attrs, field, S_IRUGO, 1)
  844. #define SETUP_EXPANDER_ATTRIBUTE(field) \
  845. SETUP_TEMPLATE(expander_attrs, expander_##field, S_IRUGO, 1)
  846. /**
  847. * sas_attach_transport -- instantiate SAS transport template
  848. * @ft: SAS transport class function template
  849. */
  850. struct scsi_transport_template *
  851. sas_attach_transport(struct sas_function_template *ft)
  852. {
  853. struct sas_internal *i;
  854. int count;
  855. i = kzalloc(sizeof(struct sas_internal), GFP_KERNEL);
  856. if (!i)
  857. return NULL;
  858. i->t.user_scan = sas_user_scan;
  859. i->t.host_attrs.ac.attrs = &i->host_attrs[0];
  860. i->t.host_attrs.ac.class = &sas_host_class.class;
  861. i->t.host_attrs.ac.match = sas_host_match;
  862. transport_container_register(&i->t.host_attrs);
  863. i->t.host_size = sizeof(struct sas_host_attrs);
  864. i->phy_attr_cont.ac.class = &sas_phy_class.class;
  865. i->phy_attr_cont.ac.attrs = &i->phy_attrs[0];
  866. i->phy_attr_cont.ac.match = sas_phy_match;
  867. transport_container_register(&i->phy_attr_cont);
  868. i->rphy_attr_cont.ac.class = &sas_rphy_class.class;
  869. i->rphy_attr_cont.ac.attrs = &i->rphy_attrs[0];
  870. i->rphy_attr_cont.ac.match = sas_rphy_match;
  871. transport_container_register(&i->rphy_attr_cont);
  872. i->end_dev_attr_cont.ac.class = &sas_end_dev_class.class;
  873. i->end_dev_attr_cont.ac.attrs = &i->end_dev_attrs[0];
  874. i->end_dev_attr_cont.ac.match = sas_end_dev_match;
  875. transport_container_register(&i->end_dev_attr_cont);
  876. i->expander_attr_cont.ac.class = &sas_expander_class.class;
  877. i->expander_attr_cont.ac.attrs = &i->expander_attrs[0];
  878. i->expander_attr_cont.ac.match = sas_expander_match;
  879. transport_container_register(&i->expander_attr_cont);
  880. i->f = ft;
  881. count = 0;
  882. i->host_attrs[count] = NULL;
  883. count = 0;
  884. SETUP_PORT_ATTRIBUTE(initiator_port_protocols);
  885. SETUP_PORT_ATTRIBUTE(target_port_protocols);
  886. SETUP_PORT_ATTRIBUTE(device_type);
  887. SETUP_PORT_ATTRIBUTE(sas_address);
  888. SETUP_PORT_ATTRIBUTE(phy_identifier);
  889. SETUP_PORT_ATTRIBUTE(port_identifier);
  890. SETUP_PORT_ATTRIBUTE(negotiated_linkrate);
  891. SETUP_PORT_ATTRIBUTE(minimum_linkrate_hw);
  892. SETUP_PORT_ATTRIBUTE(minimum_linkrate);
  893. SETUP_PORT_ATTRIBUTE(maximum_linkrate_hw);
  894. SETUP_PORT_ATTRIBUTE(maximum_linkrate);
  895. SETUP_PORT_ATTRIBUTE(invalid_dword_count);
  896. SETUP_PORT_ATTRIBUTE(running_disparity_error_count);
  897. SETUP_PORT_ATTRIBUTE(loss_of_dword_sync_count);
  898. SETUP_PORT_ATTRIBUTE(phy_reset_problem_count);
  899. SETUP_OPTIONAL_PORT_ATTRIBUTE_WRONLY(link_reset, phy_reset);
  900. SETUP_OPTIONAL_PORT_ATTRIBUTE_WRONLY(hard_reset, phy_reset);
  901. i->phy_attrs[count] = NULL;
  902. count = 0;
  903. SETUP_RPORT_ATTRIBUTE(rphy_initiator_port_protocols);
  904. SETUP_RPORT_ATTRIBUTE(rphy_target_port_protocols);
  905. SETUP_RPORT_ATTRIBUTE(rphy_device_type);
  906. SETUP_RPORT_ATTRIBUTE(rphy_sas_address);
  907. SETUP_RPORT_ATTRIBUTE(rphy_phy_identifier);
  908. SETUP_OPTIONAL_RPORT_ATTRIBUTE(rphy_enclosure_identifier,
  909. get_enclosure_identifier);
  910. SETUP_OPTIONAL_RPORT_ATTRIBUTE(rphy_bay_identifier,
  911. get_bay_identifier);
  912. i->rphy_attrs[count] = NULL;
  913. count = 0;
  914. SETUP_END_DEV_ATTRIBUTE(end_dev_ready_led_meaning);
  915. SETUP_END_DEV_ATTRIBUTE(end_dev_I_T_nexus_loss_timeout);
  916. SETUP_END_DEV_ATTRIBUTE(end_dev_initiator_response_timeout);
  917. i->end_dev_attrs[count] = NULL;
  918. count = 0;
  919. SETUP_EXPANDER_ATTRIBUTE(vendor_id);
  920. SETUP_EXPANDER_ATTRIBUTE(product_id);
  921. SETUP_EXPANDER_ATTRIBUTE(product_rev);
  922. SETUP_EXPANDER_ATTRIBUTE(component_vendor_id);
  923. SETUP_EXPANDER_ATTRIBUTE(component_id);
  924. SETUP_EXPANDER_ATTRIBUTE(component_revision_id);
  925. SETUP_EXPANDER_ATTRIBUTE(level);
  926. i->expander_attrs[count] = NULL;
  927. return &i->t;
  928. }
  929. EXPORT_SYMBOL(sas_attach_transport);
  930. /**
  931. * sas_release_transport -- release SAS transport template instance
  932. * @t: transport template instance
  933. */
  934. void sas_release_transport(struct scsi_transport_template *t)
  935. {
  936. struct sas_internal *i = to_sas_internal(t);
  937. transport_container_unregister(&i->t.host_attrs);
  938. transport_container_unregister(&i->phy_attr_cont);
  939. transport_container_unregister(&i->rphy_attr_cont);
  940. transport_container_unregister(&i->end_dev_attr_cont);
  941. transport_container_unregister(&i->expander_attr_cont);
  942. kfree(i);
  943. }
  944. EXPORT_SYMBOL(sas_release_transport);
  945. static __init int sas_transport_init(void)
  946. {
  947. int error;
  948. error = transport_class_register(&sas_host_class);
  949. if (error)
  950. goto out;
  951. error = transport_class_register(&sas_phy_class);
  952. if (error)
  953. goto out_unregister_transport;
  954. error = transport_class_register(&sas_rphy_class);
  955. if (error)
  956. goto out_unregister_phy;
  957. error = transport_class_register(&sas_end_dev_class);
  958. if (error)
  959. goto out_unregister_rphy;
  960. error = transport_class_register(&sas_expander_class);
  961. if (error)
  962. goto out_unregister_end_dev;
  963. return 0;
  964. out_unregister_end_dev:
  965. transport_class_unregister(&sas_end_dev_class);
  966. out_unregister_rphy:
  967. transport_class_unregister(&sas_rphy_class);
  968. out_unregister_phy:
  969. transport_class_unregister(&sas_phy_class);
  970. out_unregister_transport:
  971. transport_class_unregister(&sas_host_class);
  972. out:
  973. return error;
  974. }
  975. static void __exit sas_transport_exit(void)
  976. {
  977. transport_class_unregister(&sas_host_class);
  978. transport_class_unregister(&sas_phy_class);
  979. transport_class_unregister(&sas_rphy_class);
  980. transport_class_unregister(&sas_end_dev_class);
  981. transport_class_unregister(&sas_expander_class);
  982. }
  983. MODULE_AUTHOR("Christoph Hellwig");
  984. MODULE_DESCRIPTION("SAS Transphy Attributes");
  985. MODULE_LICENSE("GPL");
  986. module_init(sas_transport_init);
  987. module_exit(sas_transport_exit);