scsi_transport_sas.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191
  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 < ARRAY_SIZE(table); 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 < ARRAY_SIZE(table); 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_rphy_initialize - common rphy intialization
  632. * @rphy: rphy to initialise
  633. *
  634. * Used by both sas_end_device_alloc() and sas_expander_alloc() to
  635. * initialise the common rphy component of each.
  636. */
  637. static void sas_rphy_initialize(struct sas_rphy *rphy)
  638. {
  639. INIT_LIST_HEAD(&rphy->list);
  640. }
  641. /**
  642. * sas_end_device_alloc - allocate an rphy for an end device
  643. *
  644. * Allocates an SAS remote PHY structure, connected to @parent.
  645. *
  646. * Returns:
  647. * SAS PHY allocated or %NULL if the allocation failed.
  648. */
  649. struct sas_rphy *sas_end_device_alloc(struct sas_phy *parent)
  650. {
  651. struct Scsi_Host *shost = dev_to_shost(&parent->dev);
  652. struct sas_end_device *rdev;
  653. rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
  654. if (!rdev) {
  655. return NULL;
  656. }
  657. device_initialize(&rdev->rphy.dev);
  658. rdev->rphy.dev.parent = get_device(&parent->dev);
  659. rdev->rphy.dev.release = sas_end_device_release;
  660. sprintf(rdev->rphy.dev.bus_id, "end_device-%d:%d-%d",
  661. shost->host_no, parent->port_identifier, parent->number);
  662. rdev->rphy.identify.device_type = SAS_END_DEVICE;
  663. sas_rphy_initialize(&rdev->rphy);
  664. transport_setup_device(&rdev->rphy.dev);
  665. return &rdev->rphy;
  666. }
  667. EXPORT_SYMBOL(sas_end_device_alloc);
  668. /**
  669. * sas_expander_alloc - allocate an rphy for an end device
  670. *
  671. * Allocates an SAS remote PHY structure, connected to @parent.
  672. *
  673. * Returns:
  674. * SAS PHY allocated or %NULL if the allocation failed.
  675. */
  676. struct sas_rphy *sas_expander_alloc(struct sas_phy *parent,
  677. enum sas_device_type type)
  678. {
  679. struct Scsi_Host *shost = dev_to_shost(&parent->dev);
  680. struct sas_expander_device *rdev;
  681. struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
  682. BUG_ON(type != SAS_EDGE_EXPANDER_DEVICE &&
  683. type != SAS_FANOUT_EXPANDER_DEVICE);
  684. rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
  685. if (!rdev) {
  686. return NULL;
  687. }
  688. device_initialize(&rdev->rphy.dev);
  689. rdev->rphy.dev.parent = get_device(&parent->dev);
  690. rdev->rphy.dev.release = sas_expander_release;
  691. mutex_lock(&sas_host->lock);
  692. rdev->rphy.scsi_target_id = sas_host->next_expander_id++;
  693. mutex_unlock(&sas_host->lock);
  694. sprintf(rdev->rphy.dev.bus_id, "expander-%d:%d",
  695. shost->host_no, rdev->rphy.scsi_target_id);
  696. rdev->rphy.identify.device_type = type;
  697. sas_rphy_initialize(&rdev->rphy);
  698. transport_setup_device(&rdev->rphy.dev);
  699. return &rdev->rphy;
  700. }
  701. EXPORT_SYMBOL(sas_expander_alloc);
  702. /**
  703. * sas_rphy_add -- add a SAS remote PHY to the device hierachy
  704. * @rphy: The remote PHY to be added
  705. *
  706. * Publishes a SAS remote PHY to the rest of the system.
  707. */
  708. int sas_rphy_add(struct sas_rphy *rphy)
  709. {
  710. struct sas_phy *parent = dev_to_phy(rphy->dev.parent);
  711. struct Scsi_Host *shost = dev_to_shost(parent->dev.parent);
  712. struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
  713. struct sas_identify *identify = &rphy->identify;
  714. int error;
  715. if (parent->rphy)
  716. return -ENXIO;
  717. parent->rphy = rphy;
  718. error = device_add(&rphy->dev);
  719. if (error)
  720. return error;
  721. transport_add_device(&rphy->dev);
  722. transport_configure_device(&rphy->dev);
  723. mutex_lock(&sas_host->lock);
  724. list_add_tail(&rphy->list, &sas_host->rphy_list);
  725. if (identify->device_type == SAS_END_DEVICE &&
  726. (identify->target_port_protocols &
  727. (SAS_PROTOCOL_SSP|SAS_PROTOCOL_STP|SAS_PROTOCOL_SATA)))
  728. rphy->scsi_target_id = sas_host->next_target_id++;
  729. else if (identify->device_type == SAS_END_DEVICE)
  730. rphy->scsi_target_id = -1;
  731. mutex_unlock(&sas_host->lock);
  732. if (identify->device_type == SAS_END_DEVICE &&
  733. rphy->scsi_target_id != -1) {
  734. scsi_scan_target(&rphy->dev, parent->port_identifier,
  735. rphy->scsi_target_id, ~0, 0);
  736. }
  737. return 0;
  738. }
  739. EXPORT_SYMBOL(sas_rphy_add);
  740. /**
  741. * sas_rphy_free -- free a SAS remote PHY
  742. * @rphy SAS remote PHY to free
  743. *
  744. * Frees the specified SAS remote PHY.
  745. *
  746. * Note:
  747. * This function must only be called on a remote
  748. * PHY that has not sucessfully been added using
  749. * sas_rphy_add().
  750. */
  751. void sas_rphy_free(struct sas_rphy *rphy)
  752. {
  753. struct device *dev = &rphy->dev;
  754. struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent->parent);
  755. struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
  756. mutex_lock(&sas_host->lock);
  757. list_del(&rphy->list);
  758. mutex_unlock(&sas_host->lock);
  759. transport_destroy_device(dev);
  760. put_device(dev);
  761. }
  762. EXPORT_SYMBOL(sas_rphy_free);
  763. /**
  764. * sas_rphy_delete -- remove SAS remote PHY
  765. * @rphy: SAS remote PHY to remove
  766. *
  767. * Removes the specified SAS remote PHY.
  768. */
  769. void
  770. sas_rphy_delete(struct sas_rphy *rphy)
  771. {
  772. struct device *dev = &rphy->dev;
  773. struct sas_phy *parent = dev_to_phy(dev->parent);
  774. struct Scsi_Host *shost = dev_to_shost(parent->dev.parent);
  775. struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
  776. switch (rphy->identify.device_type) {
  777. case SAS_END_DEVICE:
  778. scsi_remove_target(dev);
  779. break;
  780. case SAS_EDGE_EXPANDER_DEVICE:
  781. case SAS_FANOUT_EXPANDER_DEVICE:
  782. device_for_each_child(dev, NULL, do_sas_phy_delete);
  783. break;
  784. default:
  785. break;
  786. }
  787. transport_remove_device(dev);
  788. device_del(dev);
  789. transport_destroy_device(dev);
  790. mutex_lock(&sas_host->lock);
  791. list_del(&rphy->list);
  792. mutex_unlock(&sas_host->lock);
  793. parent->rphy = NULL;
  794. put_device(dev);
  795. }
  796. EXPORT_SYMBOL(sas_rphy_delete);
  797. /**
  798. * scsi_is_sas_rphy -- check if a struct device represents a SAS remote PHY
  799. * @dev: device to check
  800. *
  801. * Returns:
  802. * %1 if the device represents a SAS remote PHY, %0 else
  803. */
  804. int scsi_is_sas_rphy(const struct device *dev)
  805. {
  806. return dev->release == sas_end_device_release ||
  807. dev->release == sas_expander_release;
  808. }
  809. EXPORT_SYMBOL(scsi_is_sas_rphy);
  810. /*
  811. * SCSI scan helper
  812. */
  813. static int sas_user_scan(struct Scsi_Host *shost, uint channel,
  814. uint id, uint lun)
  815. {
  816. struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
  817. struct sas_rphy *rphy;
  818. mutex_lock(&sas_host->lock);
  819. list_for_each_entry(rphy, &sas_host->rphy_list, list) {
  820. struct sas_phy *parent = dev_to_phy(rphy->dev.parent);
  821. if (rphy->identify.device_type != SAS_END_DEVICE ||
  822. rphy->scsi_target_id == -1)
  823. continue;
  824. if ((channel == SCAN_WILD_CARD || channel == parent->port_identifier) &&
  825. (id == SCAN_WILD_CARD || id == rphy->scsi_target_id)) {
  826. scsi_scan_target(&rphy->dev, parent->port_identifier,
  827. rphy->scsi_target_id, lun, 1);
  828. }
  829. }
  830. mutex_unlock(&sas_host->lock);
  831. return 0;
  832. }
  833. /*
  834. * Setup / Teardown code
  835. */
  836. #define SETUP_TEMPLATE(attrb, field, perm, test) \
  837. i->private_##attrb[count] = class_device_attr_##field; \
  838. i->private_##attrb[count].attr.mode = perm; \
  839. i->attrb[count] = &i->private_##attrb[count]; \
  840. if (test) \
  841. count++
  842. #define SETUP_RPORT_ATTRIBUTE(field) \
  843. SETUP_TEMPLATE(rphy_attrs, field, S_IRUGO, 1)
  844. #define SETUP_OPTIONAL_RPORT_ATTRIBUTE(field, func) \
  845. SETUP_TEMPLATE(rphy_attrs, field, S_IRUGO, i->f->func)
  846. #define SETUP_PORT_ATTRIBUTE(field) \
  847. SETUP_TEMPLATE(phy_attrs, field, S_IRUGO, 1)
  848. #define SETUP_OPTIONAL_PORT_ATTRIBUTE(field, func) \
  849. SETUP_TEMPLATE(phy_attrs, field, S_IRUGO, i->f->func)
  850. #define SETUP_PORT_ATTRIBUTE_WRONLY(field) \
  851. SETUP_TEMPLATE(phy_attrs, field, S_IWUGO, 1)
  852. #define SETUP_OPTIONAL_PORT_ATTRIBUTE_WRONLY(field, func) \
  853. SETUP_TEMPLATE(phy_attrs, field, S_IWUGO, i->f->func)
  854. #define SETUP_END_DEV_ATTRIBUTE(field) \
  855. SETUP_TEMPLATE(end_dev_attrs, field, S_IRUGO, 1)
  856. #define SETUP_EXPANDER_ATTRIBUTE(field) \
  857. SETUP_TEMPLATE(expander_attrs, expander_##field, S_IRUGO, 1)
  858. /**
  859. * sas_attach_transport -- instantiate SAS transport template
  860. * @ft: SAS transport class function template
  861. */
  862. struct scsi_transport_template *
  863. sas_attach_transport(struct sas_function_template *ft)
  864. {
  865. struct sas_internal *i;
  866. int count;
  867. i = kzalloc(sizeof(struct sas_internal), GFP_KERNEL);
  868. if (!i)
  869. return NULL;
  870. i->t.user_scan = sas_user_scan;
  871. i->t.host_attrs.ac.attrs = &i->host_attrs[0];
  872. i->t.host_attrs.ac.class = &sas_host_class.class;
  873. i->t.host_attrs.ac.match = sas_host_match;
  874. transport_container_register(&i->t.host_attrs);
  875. i->t.host_size = sizeof(struct sas_host_attrs);
  876. i->phy_attr_cont.ac.class = &sas_phy_class.class;
  877. i->phy_attr_cont.ac.attrs = &i->phy_attrs[0];
  878. i->phy_attr_cont.ac.match = sas_phy_match;
  879. transport_container_register(&i->phy_attr_cont);
  880. i->rphy_attr_cont.ac.class = &sas_rphy_class.class;
  881. i->rphy_attr_cont.ac.attrs = &i->rphy_attrs[0];
  882. i->rphy_attr_cont.ac.match = sas_rphy_match;
  883. transport_container_register(&i->rphy_attr_cont);
  884. i->end_dev_attr_cont.ac.class = &sas_end_dev_class.class;
  885. i->end_dev_attr_cont.ac.attrs = &i->end_dev_attrs[0];
  886. i->end_dev_attr_cont.ac.match = sas_end_dev_match;
  887. transport_container_register(&i->end_dev_attr_cont);
  888. i->expander_attr_cont.ac.class = &sas_expander_class.class;
  889. i->expander_attr_cont.ac.attrs = &i->expander_attrs[0];
  890. i->expander_attr_cont.ac.match = sas_expander_match;
  891. transport_container_register(&i->expander_attr_cont);
  892. i->f = ft;
  893. count = 0;
  894. i->host_attrs[count] = NULL;
  895. count = 0;
  896. SETUP_PORT_ATTRIBUTE(initiator_port_protocols);
  897. SETUP_PORT_ATTRIBUTE(target_port_protocols);
  898. SETUP_PORT_ATTRIBUTE(device_type);
  899. SETUP_PORT_ATTRIBUTE(sas_address);
  900. SETUP_PORT_ATTRIBUTE(phy_identifier);
  901. SETUP_PORT_ATTRIBUTE(port_identifier);
  902. SETUP_PORT_ATTRIBUTE(negotiated_linkrate);
  903. SETUP_PORT_ATTRIBUTE(minimum_linkrate_hw);
  904. SETUP_PORT_ATTRIBUTE(minimum_linkrate);
  905. SETUP_PORT_ATTRIBUTE(maximum_linkrate_hw);
  906. SETUP_PORT_ATTRIBUTE(maximum_linkrate);
  907. SETUP_PORT_ATTRIBUTE(invalid_dword_count);
  908. SETUP_PORT_ATTRIBUTE(running_disparity_error_count);
  909. SETUP_PORT_ATTRIBUTE(loss_of_dword_sync_count);
  910. SETUP_PORT_ATTRIBUTE(phy_reset_problem_count);
  911. SETUP_OPTIONAL_PORT_ATTRIBUTE_WRONLY(link_reset, phy_reset);
  912. SETUP_OPTIONAL_PORT_ATTRIBUTE_WRONLY(hard_reset, phy_reset);
  913. i->phy_attrs[count] = NULL;
  914. count = 0;
  915. SETUP_RPORT_ATTRIBUTE(rphy_initiator_port_protocols);
  916. SETUP_RPORT_ATTRIBUTE(rphy_target_port_protocols);
  917. SETUP_RPORT_ATTRIBUTE(rphy_device_type);
  918. SETUP_RPORT_ATTRIBUTE(rphy_sas_address);
  919. SETUP_RPORT_ATTRIBUTE(rphy_phy_identifier);
  920. SETUP_OPTIONAL_RPORT_ATTRIBUTE(rphy_enclosure_identifier,
  921. get_enclosure_identifier);
  922. SETUP_OPTIONAL_RPORT_ATTRIBUTE(rphy_bay_identifier,
  923. get_bay_identifier);
  924. i->rphy_attrs[count] = NULL;
  925. count = 0;
  926. SETUP_END_DEV_ATTRIBUTE(end_dev_ready_led_meaning);
  927. SETUP_END_DEV_ATTRIBUTE(end_dev_I_T_nexus_loss_timeout);
  928. SETUP_END_DEV_ATTRIBUTE(end_dev_initiator_response_timeout);
  929. i->end_dev_attrs[count] = NULL;
  930. count = 0;
  931. SETUP_EXPANDER_ATTRIBUTE(vendor_id);
  932. SETUP_EXPANDER_ATTRIBUTE(product_id);
  933. SETUP_EXPANDER_ATTRIBUTE(product_rev);
  934. SETUP_EXPANDER_ATTRIBUTE(component_vendor_id);
  935. SETUP_EXPANDER_ATTRIBUTE(component_id);
  936. SETUP_EXPANDER_ATTRIBUTE(component_revision_id);
  937. SETUP_EXPANDER_ATTRIBUTE(level);
  938. i->expander_attrs[count] = NULL;
  939. return &i->t;
  940. }
  941. EXPORT_SYMBOL(sas_attach_transport);
  942. /**
  943. * sas_release_transport -- release SAS transport template instance
  944. * @t: transport template instance
  945. */
  946. void sas_release_transport(struct scsi_transport_template *t)
  947. {
  948. struct sas_internal *i = to_sas_internal(t);
  949. transport_container_unregister(&i->t.host_attrs);
  950. transport_container_unregister(&i->phy_attr_cont);
  951. transport_container_unregister(&i->rphy_attr_cont);
  952. transport_container_unregister(&i->end_dev_attr_cont);
  953. transport_container_unregister(&i->expander_attr_cont);
  954. kfree(i);
  955. }
  956. EXPORT_SYMBOL(sas_release_transport);
  957. static __init int sas_transport_init(void)
  958. {
  959. int error;
  960. error = transport_class_register(&sas_host_class);
  961. if (error)
  962. goto out;
  963. error = transport_class_register(&sas_phy_class);
  964. if (error)
  965. goto out_unregister_transport;
  966. error = transport_class_register(&sas_rphy_class);
  967. if (error)
  968. goto out_unregister_phy;
  969. error = transport_class_register(&sas_end_dev_class);
  970. if (error)
  971. goto out_unregister_rphy;
  972. error = transport_class_register(&sas_expander_class);
  973. if (error)
  974. goto out_unregister_end_dev;
  975. return 0;
  976. out_unregister_end_dev:
  977. transport_class_unregister(&sas_end_dev_class);
  978. out_unregister_rphy:
  979. transport_class_unregister(&sas_rphy_class);
  980. out_unregister_phy:
  981. transport_class_unregister(&sas_phy_class);
  982. out_unregister_transport:
  983. transport_class_unregister(&sas_host_class);
  984. out:
  985. return error;
  986. }
  987. static void __exit sas_transport_exit(void)
  988. {
  989. transport_class_unregister(&sas_host_class);
  990. transport_class_unregister(&sas_phy_class);
  991. transport_class_unregister(&sas_rphy_class);
  992. transport_class_unregister(&sas_end_dev_class);
  993. transport_class_unregister(&sas_expander_class);
  994. }
  995. MODULE_AUTHOR("Christoph Hellwig");
  996. MODULE_DESCRIPTION("SAS Transphy Attributes");
  997. MODULE_LICENSE("GPL");
  998. module_init(sas_transport_init);
  999. module_exit(sas_transport_exit);