fw-sbp2.c 33 KB

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