fw-sbp2.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200
  1. /*
  2. * SBP2 driver (SCSI over IEEE1394)
  3. *
  4. * Copyright (C) 2005-2007 Kristian Hoegsberg <krh@bitplanet.net>
  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 Foundation,
  18. * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. */
  20. /*
  21. * The basic structure of this driver is based on the old storage driver,
  22. * drivers/ieee1394/sbp2.c, originally written by
  23. * James Goodwin <jamesg@filanet.com>
  24. * with later contributions and ongoing maintenance from
  25. * Ben Collins <bcollins@debian.org>,
  26. * Stefan Richter <stefanr@s5r6.in-berlin.de>
  27. * and many others.
  28. */
  29. #include <linux/kernel.h>
  30. #include <linux/module.h>
  31. #include <linux/moduleparam.h>
  32. #include <linux/mod_devicetable.h>
  33. #include <linux/device.h>
  34. #include <linux/scatterlist.h>
  35. #include <linux/dma-mapping.h>
  36. #include <linux/blkdev.h>
  37. #include <linux/string.h>
  38. #include <linux/timer.h>
  39. #include <scsi/scsi.h>
  40. #include <scsi/scsi_cmnd.h>
  41. #include <scsi/scsi_dbg.h>
  42. #include <scsi/scsi_device.h>
  43. #include <scsi/scsi_host.h>
  44. #include "fw-transaction.h"
  45. #include "fw-topology.h"
  46. #include "fw-device.h"
  47. /*
  48. * So far only bridges from Oxford Semiconductor are known to support
  49. * concurrent logins. Depending on firmware, four or two concurrent logins
  50. * are possible on OXFW911 and newer Oxsemi bridges.
  51. *
  52. * Concurrent logins are useful together with cluster filesystems.
  53. */
  54. static int sbp2_param_exclusive_login = 1;
  55. module_param_named(exclusive_login, sbp2_param_exclusive_login, bool, 0644);
  56. MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device "
  57. "(default = Y, use N for concurrent initiators)");
  58. /* I don't know why the SCSI stack doesn't define something like this... */
  59. typedef void (*scsi_done_fn_t)(struct scsi_cmnd *);
  60. static const char sbp2_driver_name[] = "sbp2";
  61. struct sbp2_device {
  62. struct kref kref;
  63. struct fw_unit *unit;
  64. struct fw_address_handler address_handler;
  65. struct list_head orb_list;
  66. u64 management_agent_address;
  67. u64 command_block_agent_address;
  68. u32 workarounds;
  69. int login_id;
  70. /*
  71. * We cache these addresses and only update them once we've
  72. * logged in or reconnected to the sbp2 device. That way, any
  73. * IO to the device will automatically fail and get retried if
  74. * it happens in a window where the device is not ready to
  75. * handle it (e.g. after a bus reset but before we reconnect).
  76. */
  77. int node_id;
  78. int address_high;
  79. int generation;
  80. int retries;
  81. struct delayed_work work;
  82. };
  83. #define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000
  84. #define SBP2_MAX_SECTORS 255 /* Max sectors supported */
  85. #define SBP2_ORB_TIMEOUT 2000 /* Timeout in ms */
  86. #define SBP2_ORB_NULL 0x80000000
  87. #define SBP2_DIRECTION_TO_MEDIA 0x0
  88. #define SBP2_DIRECTION_FROM_MEDIA 0x1
  89. /* Unit directory keys */
  90. #define SBP2_COMMAND_SET_SPECIFIER 0x38
  91. #define SBP2_COMMAND_SET 0x39
  92. #define SBP2_COMMAND_SET_REVISION 0x3b
  93. #define SBP2_FIRMWARE_REVISION 0x3c
  94. /* Flags for detected oddities and brokeness */
  95. #define SBP2_WORKAROUND_128K_MAX_TRANS 0x1
  96. #define SBP2_WORKAROUND_INQUIRY_36 0x2
  97. #define SBP2_WORKAROUND_MODE_SENSE_8 0x4
  98. #define SBP2_WORKAROUND_FIX_CAPACITY 0x8
  99. #define SBP2_WORKAROUND_OVERRIDE 0x100
  100. /* Management orb opcodes */
  101. #define SBP2_LOGIN_REQUEST 0x0
  102. #define SBP2_QUERY_LOGINS_REQUEST 0x1
  103. #define SBP2_RECONNECT_REQUEST 0x3
  104. #define SBP2_SET_PASSWORD_REQUEST 0x4
  105. #define SBP2_LOGOUT_REQUEST 0x7
  106. #define SBP2_ABORT_TASK_REQUEST 0xb
  107. #define SBP2_ABORT_TASK_SET 0xc
  108. #define SBP2_LOGICAL_UNIT_RESET 0xe
  109. #define SBP2_TARGET_RESET_REQUEST 0xf
  110. /* Offsets for command block agent registers */
  111. #define SBP2_AGENT_STATE 0x00
  112. #define SBP2_AGENT_RESET 0x04
  113. #define SBP2_ORB_POINTER 0x08
  114. #define SBP2_DOORBELL 0x10
  115. #define SBP2_UNSOLICITED_STATUS_ENABLE 0x14
  116. /* Status write response codes */
  117. #define SBP2_STATUS_REQUEST_COMPLETE 0x0
  118. #define SBP2_STATUS_TRANSPORT_FAILURE 0x1
  119. #define SBP2_STATUS_ILLEGAL_REQUEST 0x2
  120. #define SBP2_STATUS_VENDOR_DEPENDENT 0x3
  121. #define STATUS_GET_ORB_HIGH(v) ((v).status & 0xffff)
  122. #define STATUS_GET_SBP_STATUS(v) (((v).status >> 16) & 0xff)
  123. #define STATUS_GET_LEN(v) (((v).status >> 24) & 0x07)
  124. #define STATUS_GET_DEAD(v) (((v).status >> 27) & 0x01)
  125. #define STATUS_GET_RESPONSE(v) (((v).status >> 28) & 0x03)
  126. #define STATUS_GET_SOURCE(v) (((v).status >> 30) & 0x03)
  127. #define STATUS_GET_ORB_LOW(v) ((v).orb_low)
  128. #define STATUS_GET_DATA(v) ((v).data)
  129. struct sbp2_status {
  130. u32 status;
  131. u32 orb_low;
  132. u8 data[24];
  133. };
  134. struct sbp2_pointer {
  135. u32 high;
  136. u32 low;
  137. };
  138. struct sbp2_orb {
  139. struct fw_transaction t;
  140. dma_addr_t request_bus;
  141. int rcode;
  142. struct sbp2_pointer pointer;
  143. void (*callback)(struct sbp2_orb * orb, struct sbp2_status * status);
  144. struct list_head link;
  145. };
  146. #define MANAGEMENT_ORB_LUN(v) ((v))
  147. #define MANAGEMENT_ORB_FUNCTION(v) ((v) << 16)
  148. #define MANAGEMENT_ORB_RECONNECT(v) ((v) << 20)
  149. #define MANAGEMENT_ORB_EXCLUSIVE(v) ((v) ? 1 << 28 : 0)
  150. #define MANAGEMENT_ORB_REQUEST_FORMAT(v) ((v) << 29)
  151. #define MANAGEMENT_ORB_NOTIFY ((1) << 31)
  152. #define MANAGEMENT_ORB_RESPONSE_LENGTH(v) ((v))
  153. #define MANAGEMENT_ORB_PASSWORD_LENGTH(v) ((v) << 16)
  154. struct sbp2_management_orb {
  155. struct sbp2_orb base;
  156. struct {
  157. struct sbp2_pointer password;
  158. struct sbp2_pointer response;
  159. u32 misc;
  160. u32 length;
  161. struct sbp2_pointer status_fifo;
  162. } request;
  163. __be32 response[4];
  164. dma_addr_t response_bus;
  165. struct completion done;
  166. struct sbp2_status status;
  167. };
  168. #define LOGIN_RESPONSE_GET_LOGIN_ID(v) ((v).misc & 0xffff)
  169. #define LOGIN_RESPONSE_GET_LENGTH(v) (((v).misc >> 16) & 0xffff)
  170. struct sbp2_login_response {
  171. u32 misc;
  172. struct sbp2_pointer command_block_agent;
  173. u32 reconnect_hold;
  174. };
  175. #define COMMAND_ORB_DATA_SIZE(v) ((v))
  176. #define COMMAND_ORB_PAGE_SIZE(v) ((v) << 16)
  177. #define COMMAND_ORB_PAGE_TABLE_PRESENT ((1) << 19)
  178. #define COMMAND_ORB_MAX_PAYLOAD(v) ((v) << 20)
  179. #define COMMAND_ORB_SPEED(v) ((v) << 24)
  180. #define COMMAND_ORB_DIRECTION(v) ((v) << 27)
  181. #define COMMAND_ORB_REQUEST_FORMAT(v) ((v) << 29)
  182. #define COMMAND_ORB_NOTIFY ((1) << 31)
  183. struct sbp2_command_orb {
  184. struct sbp2_orb base;
  185. struct {
  186. struct sbp2_pointer next;
  187. struct sbp2_pointer data_descriptor;
  188. u32 misc;
  189. u8 command_block[12];
  190. } request;
  191. struct scsi_cmnd *cmd;
  192. scsi_done_fn_t done;
  193. struct fw_unit *unit;
  194. struct sbp2_pointer page_table[SG_ALL] __attribute__((aligned(8)));
  195. dma_addr_t page_table_bus;
  196. };
  197. /*
  198. * List of devices with known bugs.
  199. *
  200. * The firmware_revision field, masked with 0xffff00, is the best
  201. * indicator for the type of bridge chip of a device. It yields a few
  202. * false positives but this did not break correctly behaving devices
  203. * so far. We use ~0 as a wildcard, since the 24 bit values we get
  204. * from the config rom can never match that.
  205. */
  206. static const struct {
  207. u32 firmware_revision;
  208. u32 model;
  209. unsigned workarounds;
  210. } sbp2_workarounds_table[] = {
  211. /* DViCO Momobay CX-1 with TSB42AA9 bridge */ {
  212. .firmware_revision = 0x002800,
  213. .model = 0x001010,
  214. .workarounds = SBP2_WORKAROUND_INQUIRY_36 |
  215. SBP2_WORKAROUND_MODE_SENSE_8,
  216. },
  217. /* Initio bridges, actually only needed for some older ones */ {
  218. .firmware_revision = 0x000200,
  219. .model = ~0,
  220. .workarounds = SBP2_WORKAROUND_INQUIRY_36,
  221. },
  222. /* Symbios bridge */ {
  223. .firmware_revision = 0xa0b800,
  224. .model = ~0,
  225. .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS,
  226. },
  227. /*
  228. * There are iPods (2nd gen, 3rd gen) with model_id == 0, but
  229. * these iPods do not feature the read_capacity bug according
  230. * to one report. Read_capacity behaviour as well as model_id
  231. * could change due to Apple-supplied firmware updates though.
  232. */
  233. /* iPod 4th generation. */ {
  234. .firmware_revision = 0x0a2700,
  235. .model = 0x000021,
  236. .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
  237. },
  238. /* iPod mini */ {
  239. .firmware_revision = 0x0a2700,
  240. .model = 0x000023,
  241. .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
  242. },
  243. /* iPod Photo */ {
  244. .firmware_revision = 0x0a2700,
  245. .model = 0x00007e,
  246. .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
  247. }
  248. };
  249. static void
  250. sbp2_status_write(struct fw_card *card, struct fw_request *request,
  251. int tcode, int destination, int source,
  252. int generation, int speed,
  253. unsigned long long offset,
  254. void *payload, size_t length, void *callback_data)
  255. {
  256. struct sbp2_device *sd = callback_data;
  257. struct sbp2_orb *orb;
  258. struct sbp2_status status;
  259. size_t header_size;
  260. unsigned long flags;
  261. if (tcode != TCODE_WRITE_BLOCK_REQUEST ||
  262. length == 0 || length > sizeof(status)) {
  263. fw_send_response(card, request, RCODE_TYPE_ERROR);
  264. return;
  265. }
  266. header_size = min(length, 2 * sizeof(u32));
  267. fw_memcpy_from_be32(&status, payload, header_size);
  268. if (length > header_size)
  269. memcpy(status.data, payload + 8, length - header_size);
  270. if (STATUS_GET_SOURCE(status) == 2 || STATUS_GET_SOURCE(status) == 3) {
  271. fw_notify("non-orb related status write, not handled\n");
  272. fw_send_response(card, request, RCODE_COMPLETE);
  273. return;
  274. }
  275. /* Lookup the orb corresponding to this status write. */
  276. spin_lock_irqsave(&card->lock, flags);
  277. list_for_each_entry(orb, &sd->orb_list, link) {
  278. if (STATUS_GET_ORB_HIGH(status) == 0 &&
  279. STATUS_GET_ORB_LOW(status) == orb->request_bus &&
  280. orb->rcode == RCODE_COMPLETE) {
  281. list_del(&orb->link);
  282. break;
  283. }
  284. }
  285. spin_unlock_irqrestore(&card->lock, flags);
  286. if (&orb->link != &sd->orb_list)
  287. orb->callback(orb, &status);
  288. else
  289. fw_error("status write for unknown orb\n");
  290. fw_send_response(card, request, RCODE_COMPLETE);
  291. }
  292. static void
  293. complete_transaction(struct fw_card *card, int rcode,
  294. void *payload, size_t length, void *data)
  295. {
  296. struct sbp2_orb *orb = data;
  297. unsigned long flags;
  298. orb->rcode = rcode;
  299. if (rcode != RCODE_COMPLETE) {
  300. spin_lock_irqsave(&card->lock, flags);
  301. list_del(&orb->link);
  302. spin_unlock_irqrestore(&card->lock, flags);
  303. orb->callback(orb, NULL);
  304. }
  305. }
  306. static void
  307. sbp2_send_orb(struct sbp2_orb *orb, struct fw_unit *unit,
  308. int node_id, int generation, u64 offset)
  309. {
  310. struct fw_device *device = fw_device(unit->device.parent);
  311. struct sbp2_device *sd = unit->device.driver_data;
  312. unsigned long flags;
  313. orb->pointer.high = 0;
  314. orb->pointer.low = orb->request_bus;
  315. fw_memcpy_to_be32(&orb->pointer, &orb->pointer, sizeof(orb->pointer));
  316. spin_lock_irqsave(&device->card->lock, flags);
  317. list_add_tail(&orb->link, &sd->orb_list);
  318. spin_unlock_irqrestore(&device->card->lock, flags);
  319. fw_send_request(device->card, &orb->t, TCODE_WRITE_BLOCK_REQUEST,
  320. node_id, generation, device->max_speed, offset,
  321. &orb->pointer, sizeof(orb->pointer),
  322. complete_transaction, orb);
  323. }
  324. static int sbp2_cancel_orbs(struct fw_unit *unit)
  325. {
  326. struct fw_device *device = fw_device(unit->device.parent);
  327. struct sbp2_device *sd = unit->device.driver_data;
  328. struct sbp2_orb *orb, *next;
  329. struct list_head list;
  330. unsigned long flags;
  331. int retval = -ENOENT;
  332. INIT_LIST_HEAD(&list);
  333. spin_lock_irqsave(&device->card->lock, flags);
  334. list_splice_init(&sd->orb_list, &list);
  335. spin_unlock_irqrestore(&device->card->lock, flags);
  336. list_for_each_entry_safe(orb, next, &list, link) {
  337. retval = 0;
  338. if (fw_cancel_transaction(device->card, &orb->t) == 0)
  339. continue;
  340. orb->rcode = RCODE_CANCELLED;
  341. orb->callback(orb, NULL);
  342. }
  343. return retval;
  344. }
  345. static void
  346. complete_management_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
  347. {
  348. struct sbp2_management_orb *orb =
  349. container_of(base_orb, struct sbp2_management_orb, base);
  350. if (status)
  351. memcpy(&orb->status, status, sizeof(*status));
  352. complete(&orb->done);
  353. }
  354. static int
  355. sbp2_send_management_orb(struct fw_unit *unit, int node_id, int generation,
  356. int function, int lun, void *response)
  357. {
  358. struct fw_device *device = fw_device(unit->device.parent);
  359. struct sbp2_device *sd = unit->device.driver_data;
  360. struct sbp2_management_orb *orb;
  361. int retval = -ENOMEM;
  362. orb = kzalloc(sizeof(*orb), GFP_ATOMIC);
  363. if (orb == NULL)
  364. return -ENOMEM;
  365. orb->response_bus =
  366. dma_map_single(device->card->device, &orb->response,
  367. sizeof(orb->response), DMA_FROM_DEVICE);
  368. if (dma_mapping_error(orb->response_bus))
  369. goto fail_mapping_response;
  370. orb->request.response.high = 0;
  371. orb->request.response.low = orb->response_bus;
  372. orb->request.misc =
  373. MANAGEMENT_ORB_NOTIFY |
  374. MANAGEMENT_ORB_FUNCTION(function) |
  375. MANAGEMENT_ORB_LUN(lun);
  376. orb->request.length =
  377. MANAGEMENT_ORB_RESPONSE_LENGTH(sizeof(orb->response));
  378. orb->request.status_fifo.high = sd->address_handler.offset >> 32;
  379. orb->request.status_fifo.low = sd->address_handler.offset;
  380. if (function == SBP2_LOGIN_REQUEST) {
  381. orb->request.misc |=
  382. MANAGEMENT_ORB_EXCLUSIVE(sbp2_param_exclusive_login) |
  383. MANAGEMENT_ORB_RECONNECT(0);
  384. }
  385. fw_memcpy_to_be32(&orb->request, &orb->request, sizeof(orb->request));
  386. init_completion(&orb->done);
  387. orb->base.callback = complete_management_orb;
  388. orb->base.request_bus =
  389. dma_map_single(device->card->device, &orb->request,
  390. sizeof(orb->request), DMA_TO_DEVICE);
  391. if (dma_mapping_error(orb->base.request_bus))
  392. goto fail_mapping_request;
  393. sbp2_send_orb(&orb->base, unit,
  394. node_id, generation, sd->management_agent_address);
  395. wait_for_completion_timeout(&orb->done,
  396. msecs_to_jiffies(SBP2_ORB_TIMEOUT));
  397. retval = -EIO;
  398. if (sbp2_cancel_orbs(unit) == 0) {
  399. fw_error("orb reply timed out, rcode=0x%02x\n",
  400. orb->base.rcode);
  401. goto out;
  402. }
  403. if (orb->base.rcode != RCODE_COMPLETE) {
  404. fw_error("management write failed, rcode 0x%02x\n",
  405. orb->base.rcode);
  406. goto out;
  407. }
  408. if (STATUS_GET_RESPONSE(orb->status) != 0 ||
  409. STATUS_GET_SBP_STATUS(orb->status) != 0) {
  410. fw_error("error status: %d:%d\n",
  411. STATUS_GET_RESPONSE(orb->status),
  412. STATUS_GET_SBP_STATUS(orb->status));
  413. goto out;
  414. }
  415. retval = 0;
  416. out:
  417. dma_unmap_single(device->card->device, orb->base.request_bus,
  418. sizeof(orb->request), DMA_TO_DEVICE);
  419. fail_mapping_request:
  420. dma_unmap_single(device->card->device, orb->response_bus,
  421. sizeof(orb->response), DMA_FROM_DEVICE);
  422. fail_mapping_response:
  423. if (response)
  424. fw_memcpy_from_be32(response,
  425. orb->response, sizeof(orb->response));
  426. kfree(orb);
  427. return retval;
  428. }
  429. static void
  430. complete_agent_reset_write(struct fw_card *card, int rcode,
  431. void *payload, size_t length, void *data)
  432. {
  433. struct fw_transaction *t = data;
  434. kfree(t);
  435. }
  436. static int sbp2_agent_reset(struct fw_unit *unit)
  437. {
  438. struct fw_device *device = fw_device(unit->device.parent);
  439. struct sbp2_device *sd = unit->device.driver_data;
  440. struct fw_transaction *t;
  441. static u32 zero;
  442. t = kzalloc(sizeof(*t), GFP_ATOMIC);
  443. if (t == NULL)
  444. return -ENOMEM;
  445. fw_send_request(device->card, t, TCODE_WRITE_QUADLET_REQUEST,
  446. sd->node_id, sd->generation, device->max_speed,
  447. sd->command_block_agent_address + SBP2_AGENT_RESET,
  448. &zero, sizeof(zero), complete_agent_reset_write, t);
  449. return 0;
  450. }
  451. static void sbp2_reconnect(struct work_struct *work);
  452. static struct scsi_host_template scsi_driver_template;
  453. static void release_sbp2_device(struct kref *kref)
  454. {
  455. struct sbp2_device *sd = container_of(kref, struct sbp2_device, kref);
  456. struct Scsi_Host *host =
  457. container_of((void *)sd, struct Scsi_Host, hostdata[0]);
  458. scsi_remove_host(host);
  459. sbp2_send_management_orb(sd->unit, sd->node_id, sd->generation,
  460. SBP2_LOGOUT_REQUEST, sd->login_id, NULL);
  461. fw_core_remove_address_handler(&sd->address_handler);
  462. fw_notify("removed sbp2 unit %s\n", sd->unit->device.bus_id);
  463. put_device(&sd->unit->device);
  464. scsi_host_put(host);
  465. }
  466. static void sbp2_login(struct work_struct *work)
  467. {
  468. struct sbp2_device *sd =
  469. container_of(work, struct sbp2_device, work.work);
  470. struct Scsi_Host *host =
  471. container_of((void *)sd, struct Scsi_Host, hostdata[0]);
  472. struct fw_unit *unit = sd->unit;
  473. struct fw_device *device = fw_device(unit->device.parent);
  474. struct sbp2_login_response response;
  475. int generation, node_id, local_node_id, lun, retval;
  476. /* FIXME: Make this work for multi-lun devices. */
  477. lun = 0;
  478. generation = device->card->generation;
  479. node_id = device->node->node_id;
  480. local_node_id = device->card->local_node->node_id;
  481. if (sbp2_send_management_orb(unit, node_id, generation,
  482. SBP2_LOGIN_REQUEST, lun, &response) < 0) {
  483. if (sd->retries++ < 5) {
  484. schedule_delayed_work(&sd->work, DIV_ROUND_UP(HZ, 5));
  485. } else {
  486. fw_error("failed to login to %s\n",
  487. unit->device.bus_id);
  488. kref_put(&sd->kref, release_sbp2_device);
  489. }
  490. return;
  491. }
  492. sd->generation = generation;
  493. sd->node_id = node_id;
  494. sd->address_high = local_node_id << 16;
  495. /* Get command block agent offset and login id. */
  496. sd->command_block_agent_address =
  497. ((u64) (response.command_block_agent.high & 0xffff) << 32) |
  498. response.command_block_agent.low;
  499. sd->login_id = LOGIN_RESPONSE_GET_LOGIN_ID(response);
  500. fw_notify("logged in to sbp2 unit %s (%d retries)\n",
  501. unit->device.bus_id, sd->retries);
  502. fw_notify(" - management_agent_address: 0x%012llx\n",
  503. (unsigned long long) sd->management_agent_address);
  504. fw_notify(" - command_block_agent_address: 0x%012llx\n",
  505. (unsigned long long) sd->command_block_agent_address);
  506. fw_notify(" - status write address: 0x%012llx\n",
  507. (unsigned long long) sd->address_handler.offset);
  508. #if 0
  509. /* FIXME: The linux1394 sbp2 does this last step. */
  510. sbp2_set_busy_timeout(scsi_id);
  511. #endif
  512. PREPARE_DELAYED_WORK(&sd->work, sbp2_reconnect);
  513. sbp2_agent_reset(unit);
  514. /* FIXME: Loop over luns here. */
  515. lun = 0;
  516. retval = scsi_add_device(host, 0, 0, lun);
  517. if (retval < 0) {
  518. sbp2_send_management_orb(unit, sd->node_id, sd->generation,
  519. SBP2_LOGOUT_REQUEST, sd->login_id,
  520. NULL);
  521. /*
  522. * Set this back to sbp2_login so we fall back and
  523. * retry login on bus reset.
  524. */
  525. PREPARE_DELAYED_WORK(&sd->work, sbp2_login);
  526. }
  527. kref_put(&sd->kref, release_sbp2_device);
  528. }
  529. static int sbp2_probe(struct device *dev)
  530. {
  531. struct fw_unit *unit = fw_unit(dev);
  532. struct fw_device *device = fw_device(unit->device.parent);
  533. struct sbp2_device *sd;
  534. struct fw_csr_iterator ci;
  535. struct Scsi_Host *host;
  536. int i, key, value, err;
  537. u32 model, firmware_revision;
  538. err = -ENOMEM;
  539. host = scsi_host_alloc(&scsi_driver_template, sizeof(*sd));
  540. if (host == NULL)
  541. goto fail;
  542. sd = (struct sbp2_device *) host->hostdata;
  543. unit->device.driver_data = sd;
  544. sd->unit = unit;
  545. INIT_LIST_HEAD(&sd->orb_list);
  546. kref_init(&sd->kref);
  547. sd->address_handler.length = 0x100;
  548. sd->address_handler.address_callback = sbp2_status_write;
  549. sd->address_handler.callback_data = sd;
  550. err = fw_core_add_address_handler(&sd->address_handler,
  551. &fw_high_memory_region);
  552. if (err < 0)
  553. goto fail_host;
  554. err = fw_device_enable_phys_dma(device);
  555. if (err < 0)
  556. goto fail_address_handler;
  557. err = scsi_add_host(host, &unit->device);
  558. if (err < 0)
  559. goto fail_address_handler;
  560. /*
  561. * Scan unit directory to get management agent address,
  562. * firmware revison and model. Initialize firmware_revision
  563. * and model to values that wont match anything in our table.
  564. */
  565. firmware_revision = 0xff000000;
  566. model = 0xff000000;
  567. fw_csr_iterator_init(&ci, unit->directory);
  568. while (fw_csr_iterator_next(&ci, &key, &value)) {
  569. switch (key) {
  570. case CSR_DEPENDENT_INFO | CSR_OFFSET:
  571. sd->management_agent_address =
  572. 0xfffff0000000ULL + 4 * value;
  573. break;
  574. case SBP2_FIRMWARE_REVISION:
  575. firmware_revision = value;
  576. break;
  577. case CSR_MODEL:
  578. model = value;
  579. break;
  580. }
  581. }
  582. for (i = 0; i < ARRAY_SIZE(sbp2_workarounds_table); i++) {
  583. if (sbp2_workarounds_table[i].firmware_revision !=
  584. (firmware_revision & 0xffffff00))
  585. continue;
  586. if (sbp2_workarounds_table[i].model != model &&
  587. sbp2_workarounds_table[i].model != ~0)
  588. continue;
  589. sd->workarounds |= sbp2_workarounds_table[i].workarounds;
  590. break;
  591. }
  592. if (sd->workarounds)
  593. fw_notify("Workarounds for node %s: 0x%x "
  594. "(firmware_revision 0x%06x, model_id 0x%06x)\n",
  595. unit->device.bus_id,
  596. sd->workarounds, firmware_revision, model);
  597. get_device(&unit->device);
  598. /*
  599. * We schedule work to do the login so we can easily
  600. * reschedule retries. Always get the ref before scheduling
  601. * work.
  602. */
  603. INIT_DELAYED_WORK(&sd->work, sbp2_login);
  604. if (schedule_delayed_work(&sd->work, 0))
  605. kref_get(&sd->kref);
  606. return 0;
  607. fail_address_handler:
  608. fw_core_remove_address_handler(&sd->address_handler);
  609. fail_host:
  610. scsi_host_put(host);
  611. fail:
  612. return err;
  613. }
  614. static int sbp2_remove(struct device *dev)
  615. {
  616. struct fw_unit *unit = fw_unit(dev);
  617. struct sbp2_device *sd = unit->device.driver_data;
  618. kref_put(&sd->kref, release_sbp2_device);
  619. return 0;
  620. }
  621. static void sbp2_reconnect(struct work_struct *work)
  622. {
  623. struct sbp2_device *sd =
  624. container_of(work, struct sbp2_device, work.work);
  625. struct fw_unit *unit = sd->unit;
  626. struct fw_device *device = fw_device(unit->device.parent);
  627. int generation, node_id, local_node_id;
  628. generation = device->card->generation;
  629. node_id = device->node->node_id;
  630. local_node_id = device->card->local_node->node_id;
  631. if (sbp2_send_management_orb(unit, node_id, generation,
  632. SBP2_RECONNECT_REQUEST,
  633. sd->login_id, NULL) < 0) {
  634. if (sd->retries++ >= 5) {
  635. fw_error("failed to reconnect to %s\n",
  636. unit->device.bus_id);
  637. /* Fall back and try to log in again. */
  638. sd->retries = 0;
  639. PREPARE_DELAYED_WORK(&sd->work, sbp2_login);
  640. }
  641. schedule_delayed_work(&sd->work, DIV_ROUND_UP(HZ, 5));
  642. return;
  643. }
  644. sd->generation = generation;
  645. sd->node_id = node_id;
  646. sd->address_high = local_node_id << 16;
  647. fw_notify("reconnected to unit %s (%d retries)\n",
  648. unit->device.bus_id, sd->retries);
  649. sbp2_agent_reset(unit);
  650. sbp2_cancel_orbs(unit);
  651. kref_put(&sd->kref, release_sbp2_device);
  652. }
  653. static void sbp2_update(struct fw_unit *unit)
  654. {
  655. struct fw_device *device = fw_device(unit->device.parent);
  656. struct sbp2_device *sd = unit->device.driver_data;
  657. sd->retries = 0;
  658. fw_device_enable_phys_dma(device);
  659. if (schedule_delayed_work(&sd->work, 0))
  660. kref_get(&sd->kref);
  661. }
  662. #define SBP2_UNIT_SPEC_ID_ENTRY 0x0000609e
  663. #define SBP2_SW_VERSION_ENTRY 0x00010483
  664. static const struct fw_device_id sbp2_id_table[] = {
  665. {
  666. .match_flags = FW_MATCH_SPECIFIER_ID | FW_MATCH_VERSION,
  667. .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY,
  668. .version = SBP2_SW_VERSION_ENTRY,
  669. },
  670. { }
  671. };
  672. static struct fw_driver sbp2_driver = {
  673. .driver = {
  674. .owner = THIS_MODULE,
  675. .name = sbp2_driver_name,
  676. .bus = &fw_bus_type,
  677. .probe = sbp2_probe,
  678. .remove = sbp2_remove,
  679. },
  680. .update = sbp2_update,
  681. .id_table = sbp2_id_table,
  682. };
  683. static unsigned int
  684. sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data)
  685. {
  686. int sam_status;
  687. sense_data[0] = 0x70;
  688. sense_data[1] = 0x0;
  689. sense_data[2] = sbp2_status[1];
  690. sense_data[3] = sbp2_status[4];
  691. sense_data[4] = sbp2_status[5];
  692. sense_data[5] = sbp2_status[6];
  693. sense_data[6] = sbp2_status[7];
  694. sense_data[7] = 10;
  695. sense_data[8] = sbp2_status[8];
  696. sense_data[9] = sbp2_status[9];
  697. sense_data[10] = sbp2_status[10];
  698. sense_data[11] = sbp2_status[11];
  699. sense_data[12] = sbp2_status[2];
  700. sense_data[13] = sbp2_status[3];
  701. sense_data[14] = sbp2_status[12];
  702. sense_data[15] = sbp2_status[13];
  703. sam_status = sbp2_status[0] & 0x3f;
  704. switch (sam_status) {
  705. case SAM_STAT_GOOD:
  706. case SAM_STAT_CHECK_CONDITION:
  707. case SAM_STAT_CONDITION_MET:
  708. case SAM_STAT_BUSY:
  709. case SAM_STAT_RESERVATION_CONFLICT:
  710. case SAM_STAT_COMMAND_TERMINATED:
  711. return DID_OK << 16 | sam_status;
  712. default:
  713. return DID_ERROR << 16;
  714. }
  715. }
  716. static void
  717. complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
  718. {
  719. struct sbp2_command_orb *orb =
  720. container_of(base_orb, struct sbp2_command_orb, base);
  721. struct fw_unit *unit = orb->unit;
  722. struct fw_device *device = fw_device(unit->device.parent);
  723. int result;
  724. if (status != NULL) {
  725. if (STATUS_GET_DEAD(*status))
  726. sbp2_agent_reset(unit);
  727. switch (STATUS_GET_RESPONSE(*status)) {
  728. case SBP2_STATUS_REQUEST_COMPLETE:
  729. result = DID_OK << 16;
  730. break;
  731. case SBP2_STATUS_TRANSPORT_FAILURE:
  732. result = DID_BUS_BUSY << 16;
  733. break;
  734. case SBP2_STATUS_ILLEGAL_REQUEST:
  735. case SBP2_STATUS_VENDOR_DEPENDENT:
  736. default:
  737. result = DID_ERROR << 16;
  738. break;
  739. }
  740. if (result == DID_OK << 16 && STATUS_GET_LEN(*status) > 1)
  741. result = sbp2_status_to_sense_data(STATUS_GET_DATA(*status),
  742. orb->cmd->sense_buffer);
  743. } else {
  744. /*
  745. * If the orb completes with status == NULL, something
  746. * went wrong, typically a bus reset happened mid-orb
  747. * or when sending the write (less likely).
  748. */
  749. result = DID_BUS_BUSY << 16;
  750. }
  751. dma_unmap_single(device->card->device, orb->base.request_bus,
  752. sizeof(orb->request), DMA_TO_DEVICE);
  753. if (scsi_sg_count(orb->cmd) > 0)
  754. dma_unmap_sg(device->card->device, scsi_sglist(orb->cmd),
  755. scsi_sg_count(orb->cmd),
  756. orb->cmd->sc_data_direction);
  757. if (orb->page_table_bus != 0)
  758. dma_unmap_single(device->card->device, orb->page_table_bus,
  759. sizeof(orb->page_table), DMA_TO_DEVICE);
  760. orb->cmd->result = result;
  761. orb->done(orb->cmd);
  762. kfree(orb);
  763. }
  764. static int sbp2_command_orb_map_scatterlist(struct sbp2_command_orb *orb)
  765. {
  766. struct sbp2_device *sd =
  767. (struct sbp2_device *)orb->cmd->device->host->hostdata;
  768. struct fw_unit *unit = sd->unit;
  769. struct fw_device *device = fw_device(unit->device.parent);
  770. struct scatterlist *sg;
  771. int sg_len, l, i, j, count;
  772. dma_addr_t sg_addr;
  773. sg = scsi_sglist(orb->cmd);
  774. count = dma_map_sg(device->card->device, sg, scsi_sg_count(orb->cmd),
  775. orb->cmd->sc_data_direction);
  776. if (count == 0)
  777. goto fail;
  778. /*
  779. * Handle the special case where there is only one element in
  780. * the scatter list by converting it to an immediate block
  781. * request. This is also a workaround for broken devices such
  782. * as the second generation iPod which doesn't support page
  783. * tables.
  784. */
  785. if (count == 1 && sg_dma_len(sg) < SBP2_MAX_SG_ELEMENT_LENGTH) {
  786. orb->request.data_descriptor.high = sd->address_high;
  787. orb->request.data_descriptor.low = sg_dma_address(sg);
  788. orb->request.misc |=
  789. COMMAND_ORB_DATA_SIZE(sg_dma_len(sg));
  790. return 0;
  791. }
  792. /*
  793. * Convert the scatterlist to an sbp2 page table. If any
  794. * scatterlist entries are too big for sbp2, we split them as we
  795. * go. Even if we ask the block I/O layer to not give us sg
  796. * elements larger than 65535 bytes, some IOMMUs may merge sg elements
  797. * during DMA mapping, and Linux currently doesn't prevent this.
  798. */
  799. for (i = 0, j = 0; i < count; i++) {
  800. sg_len = sg_dma_len(sg + i);
  801. sg_addr = sg_dma_address(sg + i);
  802. while (sg_len) {
  803. /* FIXME: This won't get us out of the pinch. */
  804. if (unlikely(j >= ARRAY_SIZE(orb->page_table))) {
  805. fw_error("page table overflow\n");
  806. goto fail_page_table;
  807. }
  808. l = min(sg_len, SBP2_MAX_SG_ELEMENT_LENGTH);
  809. orb->page_table[j].low = sg_addr;
  810. orb->page_table[j].high = (l << 16);
  811. sg_addr += l;
  812. sg_len -= l;
  813. j++;
  814. }
  815. }
  816. fw_memcpy_to_be32(orb->page_table, orb->page_table,
  817. sizeof(orb->page_table[0]) * j);
  818. orb->page_table_bus =
  819. dma_map_single(device->card->device, orb->page_table,
  820. sizeof(orb->page_table), DMA_TO_DEVICE);
  821. if (dma_mapping_error(orb->page_table_bus))
  822. goto fail_page_table;
  823. /*
  824. * The data_descriptor pointer is the one case where we need
  825. * to fill in the node ID part of the address. All other
  826. * pointers assume that the data referenced reside on the
  827. * initiator (i.e. us), but data_descriptor can refer to data
  828. * on other nodes so we need to put our ID in descriptor.high.
  829. */
  830. orb->request.data_descriptor.high = sd->address_high;
  831. orb->request.data_descriptor.low = orb->page_table_bus;
  832. orb->request.misc |=
  833. COMMAND_ORB_PAGE_TABLE_PRESENT |
  834. COMMAND_ORB_DATA_SIZE(j);
  835. return 0;
  836. fail_page_table:
  837. dma_unmap_sg(device->card->device, sg, scsi_sg_count(orb->cmd),
  838. orb->cmd->sc_data_direction);
  839. fail:
  840. return -ENOMEM;
  841. }
  842. /* SCSI stack integration */
  843. static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
  844. {
  845. struct sbp2_device *sd =
  846. (struct sbp2_device *)cmd->device->host->hostdata;
  847. struct fw_unit *unit = sd->unit;
  848. struct fw_device *device = fw_device(unit->device.parent);
  849. struct sbp2_command_orb *orb;
  850. unsigned max_payload;
  851. /*
  852. * Bidirectional commands are not yet implemented, and unknown
  853. * transfer direction not handled.
  854. */
  855. if (cmd->sc_data_direction == DMA_BIDIRECTIONAL) {
  856. fw_error("Can't handle DMA_BIDIRECTIONAL, rejecting command\n");
  857. cmd->result = DID_ERROR << 16;
  858. done(cmd);
  859. return 0;
  860. }
  861. orb = kzalloc(sizeof(*orb), GFP_ATOMIC);
  862. if (orb == NULL) {
  863. fw_notify("failed to alloc orb\n");
  864. goto fail_alloc;
  865. }
  866. /* Initialize rcode to something not RCODE_COMPLETE. */
  867. orb->base.rcode = -1;
  868. orb->unit = unit;
  869. orb->done = done;
  870. orb->cmd = cmd;
  871. orb->request.next.high = SBP2_ORB_NULL;
  872. orb->request.next.low = 0x0;
  873. /*
  874. * At speed 100 we can do 512 bytes per packet, at speed 200,
  875. * 1024 bytes per packet etc. The SBP-2 max_payload field
  876. * specifies the max payload size as 2 ^ (max_payload + 2), so
  877. * if we set this to max_speed + 7, we get the right value.
  878. */
  879. max_payload = min(device->max_speed + 7,
  880. device->card->max_receive - 1);
  881. orb->request.misc =
  882. COMMAND_ORB_MAX_PAYLOAD(max_payload) |
  883. COMMAND_ORB_SPEED(device->max_speed) |
  884. COMMAND_ORB_NOTIFY;
  885. if (cmd->sc_data_direction == DMA_FROM_DEVICE)
  886. orb->request.misc |=
  887. COMMAND_ORB_DIRECTION(SBP2_DIRECTION_FROM_MEDIA);
  888. else if (cmd->sc_data_direction == DMA_TO_DEVICE)
  889. orb->request.misc |=
  890. COMMAND_ORB_DIRECTION(SBP2_DIRECTION_TO_MEDIA);
  891. if (scsi_sg_count(cmd) && sbp2_command_orb_map_scatterlist(orb) < 0)
  892. goto fail_mapping;
  893. fw_memcpy_to_be32(&orb->request, &orb->request, sizeof(orb->request));
  894. memset(orb->request.command_block,
  895. 0, sizeof(orb->request.command_block));
  896. memcpy(orb->request.command_block, cmd->cmnd, COMMAND_SIZE(*cmd->cmnd));
  897. orb->base.callback = complete_command_orb;
  898. orb->base.request_bus =
  899. dma_map_single(device->card->device, &orb->request,
  900. sizeof(orb->request), DMA_TO_DEVICE);
  901. if (dma_mapping_error(orb->base.request_bus))
  902. goto fail_mapping;
  903. sbp2_send_orb(&orb->base, unit, sd->node_id, sd->generation,
  904. sd->command_block_agent_address + SBP2_ORB_POINTER);
  905. return 0;
  906. fail_mapping:
  907. kfree(orb);
  908. fail_alloc:
  909. return SCSI_MLQUEUE_HOST_BUSY;
  910. }
  911. static int sbp2_scsi_slave_alloc(struct scsi_device *sdev)
  912. {
  913. struct sbp2_device *sd = (struct sbp2_device *)sdev->host->hostdata;
  914. sdev->allow_restart = 1;
  915. if (sd->workarounds & SBP2_WORKAROUND_INQUIRY_36)
  916. sdev->inquiry_len = 36;
  917. return 0;
  918. }
  919. static int sbp2_scsi_slave_configure(struct scsi_device *sdev)
  920. {
  921. struct sbp2_device *sd = (struct sbp2_device *)sdev->host->hostdata;
  922. struct fw_unit *unit = sd->unit;
  923. sdev->use_10_for_rw = 1;
  924. if (sdev->type == TYPE_ROM)
  925. sdev->use_10_for_ms = 1;
  926. if (sdev->type == TYPE_DISK &&
  927. sd->workarounds & SBP2_WORKAROUND_MODE_SENSE_8)
  928. sdev->skip_ms_page_8 = 1;
  929. if (sd->workarounds & SBP2_WORKAROUND_FIX_CAPACITY) {
  930. fw_notify("setting fix_capacity for %s\n", unit->device.bus_id);
  931. sdev->fix_capacity = 1;
  932. }
  933. if (sd->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS)
  934. blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512);
  935. return 0;
  936. }
  937. /*
  938. * Called by scsi stack when something has really gone wrong. Usually
  939. * called when a command has timed-out for some reason.
  940. */
  941. static int sbp2_scsi_abort(struct scsi_cmnd *cmd)
  942. {
  943. struct sbp2_device *sd =
  944. (struct sbp2_device *)cmd->device->host->hostdata;
  945. struct fw_unit *unit = sd->unit;
  946. fw_notify("sbp2_scsi_abort\n");
  947. sbp2_agent_reset(unit);
  948. sbp2_cancel_orbs(unit);
  949. return SUCCESS;
  950. }
  951. /*
  952. * Format of /sys/bus/scsi/devices/.../ieee1394_id:
  953. * u64 EUI-64 : u24 directory_ID : u16 LUN (all printed in hexadecimal)
  954. *
  955. * This is the concatenation of target port identifier and logical unit
  956. * identifier as per SAM-2...SAM-4 annex A.
  957. */
  958. static ssize_t
  959. sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr,
  960. char *buf)
  961. {
  962. struct scsi_device *sdev = to_scsi_device(dev);
  963. struct sbp2_device *sd;
  964. struct fw_unit *unit;
  965. struct fw_device *device;
  966. u32 directory_id;
  967. struct fw_csr_iterator ci;
  968. int key, value, lun;
  969. if (!sdev)
  970. return 0;
  971. sd = (struct sbp2_device *)sdev->host->hostdata;
  972. unit = sd->unit;
  973. device = fw_device(unit->device.parent);
  974. /* implicit directory ID */
  975. directory_id = ((unit->directory - device->config_rom) * 4
  976. + CSR_CONFIG_ROM) & 0xffffff;
  977. /* explicit directory ID, overrides implicit ID if present */
  978. fw_csr_iterator_init(&ci, unit->directory);
  979. while (fw_csr_iterator_next(&ci, &key, &value))
  980. if (key == CSR_DIRECTORY_ID) {
  981. directory_id = value;
  982. break;
  983. }
  984. /* FIXME: Make this work for multi-lun devices. */
  985. lun = 0;
  986. return sprintf(buf, "%08x%08x:%06x:%04x\n",
  987. device->config_rom[3], device->config_rom[4],
  988. directory_id, lun);
  989. }
  990. static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL);
  991. static struct device_attribute *sbp2_scsi_sysfs_attrs[] = {
  992. &dev_attr_ieee1394_id,
  993. NULL
  994. };
  995. static struct scsi_host_template scsi_driver_template = {
  996. .module = THIS_MODULE,
  997. .name = "SBP-2 IEEE-1394",
  998. .proc_name = sbp2_driver_name,
  999. .queuecommand = sbp2_scsi_queuecommand,
  1000. .slave_alloc = sbp2_scsi_slave_alloc,
  1001. .slave_configure = sbp2_scsi_slave_configure,
  1002. .eh_abort_handler = sbp2_scsi_abort,
  1003. .this_id = -1,
  1004. .sg_tablesize = SG_ALL,
  1005. .use_clustering = ENABLE_CLUSTERING,
  1006. .cmd_per_lun = 1,
  1007. .can_queue = 1,
  1008. .sdev_attrs = sbp2_scsi_sysfs_attrs,
  1009. };
  1010. MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>");
  1011. MODULE_DESCRIPTION("SCSI over IEEE1394");
  1012. MODULE_LICENSE("GPL");
  1013. MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table);
  1014. /* Provide a module alias so root-on-sbp2 initrds don't break. */
  1015. #ifndef CONFIG_IEEE1394_SBP2_MODULE
  1016. MODULE_ALIAS("sbp2");
  1017. #endif
  1018. static int __init sbp2_init(void)
  1019. {
  1020. return driver_register(&sbp2_driver.driver);
  1021. }
  1022. static void __exit sbp2_cleanup(void)
  1023. {
  1024. driver_unregister(&sbp2_driver.driver);
  1025. }
  1026. module_init(sbp2_init);
  1027. module_exit(sbp2_cleanup);