fw-sbp2.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  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. 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), 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. dma_addr_t sg_addr;
  775. sg = (struct scatterlist *)orb->cmd->request_buffer;
  776. count = dma_map_sg(device->card->device, sg, orb->cmd->use_sg,
  777. orb->cmd->sc_data_direction);
  778. if (count == 0)
  779. goto fail;
  780. /*
  781. * Handle the special case where there is only one element in
  782. * the scatter list by converting it to an immediate block
  783. * request. This is also a workaround for broken devices such
  784. * as the second generation iPod which doesn't support page
  785. * tables.
  786. */
  787. if (count == 1 && sg_dma_len(sg) < SBP2_MAX_SG_ELEMENT_LENGTH) {
  788. orb->request.data_descriptor.high = sd->address_high;
  789. orb->request.data_descriptor.low = sg_dma_address(sg);
  790. orb->request.misc |=
  791. COMMAND_ORB_DATA_SIZE(sg_dma_len(sg));
  792. return 0;
  793. }
  794. /*
  795. * Convert the scatterlist to an sbp2 page table. If any
  796. * scatterlist entries are too big for sbp2, we split them as we
  797. * go. Even if we ask the block I/O layer to not give us sg
  798. * elements larger than 65535 bytes, some IOMMUs may merge sg elements
  799. * during DMA mapping, and Linux currently doesn't prevent this.
  800. */
  801. for (i = 0, j = 0; i < count; i++) {
  802. sg_len = sg_dma_len(sg + i);
  803. sg_addr = sg_dma_address(sg + i);
  804. while (sg_len) {
  805. /* FIXME: This won't get us out of the pinch. */
  806. if (unlikely(j >= ARRAY_SIZE(orb->page_table))) {
  807. fw_error("page table overflow\n");
  808. goto fail_page_table;
  809. }
  810. l = min(sg_len, SBP2_MAX_SG_ELEMENT_LENGTH);
  811. orb->page_table[j].low = sg_addr;
  812. orb->page_table[j].high = (l << 16);
  813. sg_addr += l;
  814. sg_len -= l;
  815. j++;
  816. }
  817. }
  818. fw_memcpy_to_be32(orb->page_table, orb->page_table,
  819. sizeof(orb->page_table[0]) * j);
  820. orb->page_table_bus =
  821. dma_map_single(device->card->device, orb->page_table,
  822. sizeof(orb->page_table), DMA_TO_DEVICE);
  823. if (dma_mapping_error(orb->page_table_bus))
  824. goto fail_page_table;
  825. /*
  826. * The data_descriptor pointer is the one case where we need
  827. * to fill in the node ID part of the address. All other
  828. * pointers assume that the data referenced reside on the
  829. * initiator (i.e. us), but data_descriptor can refer to data
  830. * on other nodes so we need to put our ID in descriptor.high.
  831. */
  832. orb->request.data_descriptor.high = sd->address_high;
  833. orb->request.data_descriptor.low = orb->page_table_bus;
  834. orb->request.misc |=
  835. COMMAND_ORB_PAGE_TABLE_PRESENT |
  836. COMMAND_ORB_DATA_SIZE(j);
  837. return 0;
  838. fail_page_table:
  839. dma_unmap_sg(device->card->device, sg, orb->cmd->use_sg,
  840. orb->cmd->sc_data_direction);
  841. fail:
  842. return -ENOMEM;
  843. }
  844. /* SCSI stack integration */
  845. static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
  846. {
  847. struct sbp2_device *sd =
  848. (struct sbp2_device *)cmd->device->host->hostdata;
  849. struct fw_unit *unit = sd->unit;
  850. struct fw_device *device = fw_device(unit->device.parent);
  851. struct sbp2_command_orb *orb;
  852. /*
  853. * Bidirectional commands are not yet implemented, and unknown
  854. * transfer direction not handled.
  855. */
  856. if (cmd->sc_data_direction == DMA_BIDIRECTIONAL) {
  857. fw_error("Can't handle DMA_BIDIRECTIONAL, rejecting command\n");
  858. cmd->result = DID_ERROR << 16;
  859. done(cmd);
  860. return 0;
  861. }
  862. orb = kzalloc(sizeof(*orb), GFP_ATOMIC);
  863. if (orb == NULL) {
  864. fw_notify("failed to alloc orb\n");
  865. goto fail_alloc;
  866. }
  867. /* Initialize rcode to something not RCODE_COMPLETE. */
  868. orb->base.rcode = -1;
  869. orb->unit = unit;
  870. orb->done = done;
  871. orb->cmd = cmd;
  872. orb->request.next.high = SBP2_ORB_NULL;
  873. orb->request.next.low = 0x0;
  874. /*
  875. * At speed 100 we can do 512 bytes per packet, at speed 200,
  876. * 1024 bytes per packet etc. The SBP-2 max_payload field
  877. * specifies the max payload size as 2 ^ (max_payload + 2), so
  878. * if we set this to max_speed + 7, we get the right value.
  879. */
  880. orb->request.misc =
  881. COMMAND_ORB_MAX_PAYLOAD(device->max_speed + 7) |
  882. COMMAND_ORB_SPEED(device->max_speed) |
  883. COMMAND_ORB_NOTIFY;
  884. if (cmd->sc_data_direction == DMA_FROM_DEVICE)
  885. orb->request.misc |=
  886. COMMAND_ORB_DIRECTION(SBP2_DIRECTION_FROM_MEDIA);
  887. else if (cmd->sc_data_direction == DMA_TO_DEVICE)
  888. orb->request.misc |=
  889. COMMAND_ORB_DIRECTION(SBP2_DIRECTION_TO_MEDIA);
  890. if (cmd->use_sg && sbp2_command_orb_map_scatterlist(orb) < 0)
  891. goto fail_mapping;
  892. fw_memcpy_to_be32(&orb->request, &orb->request, sizeof(orb->request));
  893. memset(orb->request.command_block,
  894. 0, sizeof(orb->request.command_block));
  895. memcpy(orb->request.command_block, cmd->cmnd, COMMAND_SIZE(*cmd->cmnd));
  896. orb->base.callback = complete_command_orb;
  897. orb->base.request_bus =
  898. dma_map_single(device->card->device, &orb->request,
  899. sizeof(orb->request), DMA_TO_DEVICE);
  900. if (dma_mapping_error(orb->base.request_bus))
  901. goto fail_mapping;
  902. sbp2_send_orb(&orb->base, unit, sd->node_id, sd->generation,
  903. sd->command_block_agent_address + SBP2_ORB_POINTER);
  904. return 0;
  905. fail_mapping:
  906. kfree(orb);
  907. fail_alloc:
  908. return SCSI_MLQUEUE_HOST_BUSY;
  909. }
  910. static int sbp2_scsi_slave_alloc(struct scsi_device *sdev)
  911. {
  912. struct sbp2_device *sd = (struct sbp2_device *)sdev->host->hostdata;
  913. sdev->allow_restart = 1;
  914. if (sd->workarounds & SBP2_WORKAROUND_INQUIRY_36)
  915. sdev->inquiry_len = 36;
  916. return 0;
  917. }
  918. static int sbp2_scsi_slave_configure(struct scsi_device *sdev)
  919. {
  920. struct sbp2_device *sd = (struct sbp2_device *)sdev->host->hostdata;
  921. struct fw_unit *unit = sd->unit;
  922. sdev->use_10_for_rw = 1;
  923. if (sdev->type == TYPE_ROM)
  924. sdev->use_10_for_ms = 1;
  925. if (sdev->type == TYPE_DISK &&
  926. sd->workarounds & SBP2_WORKAROUND_MODE_SENSE_8)
  927. sdev->skip_ms_page_8 = 1;
  928. if (sd->workarounds & SBP2_WORKAROUND_FIX_CAPACITY) {
  929. fw_notify("setting fix_capacity for %s\n", unit->device.bus_id);
  930. sdev->fix_capacity = 1;
  931. }
  932. if (sd->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS)
  933. blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512);
  934. return 0;
  935. }
  936. /*
  937. * Called by scsi stack when something has really gone wrong. Usually
  938. * called when a command has timed-out for some reason.
  939. */
  940. static int sbp2_scsi_abort(struct scsi_cmnd *cmd)
  941. {
  942. struct sbp2_device *sd =
  943. (struct sbp2_device *)cmd->device->host->hostdata;
  944. struct fw_unit *unit = sd->unit;
  945. fw_notify("sbp2_scsi_abort\n");
  946. sbp2_agent_reset(unit);
  947. sbp2_cancel_orbs(unit);
  948. return SUCCESS;
  949. }
  950. /*
  951. * Format of /sys/bus/scsi/devices/.../ieee1394_id:
  952. * u64 EUI-64 : u24 directory_ID : u16 LUN (all printed in hexadecimal)
  953. *
  954. * This is the concatenation of target port identifier and logical unit
  955. * identifier as per SAM-2...SAM-4 annex A.
  956. */
  957. static ssize_t
  958. sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr,
  959. char *buf)
  960. {
  961. struct scsi_device *sdev = to_scsi_device(dev);
  962. struct sbp2_device *sd;
  963. struct fw_unit *unit;
  964. struct fw_device *device;
  965. u32 directory_id;
  966. struct fw_csr_iterator ci;
  967. int key, value, lun;
  968. if (!sdev)
  969. return 0;
  970. sd = (struct sbp2_device *)sdev->host->hostdata;
  971. unit = sd->unit;
  972. device = fw_device(unit->device.parent);
  973. /* implicit directory ID */
  974. directory_id = ((unit->directory - device->config_rom) * 4
  975. + CSR_CONFIG_ROM) & 0xffffff;
  976. /* explicit directory ID, overrides implicit ID if present */
  977. fw_csr_iterator_init(&ci, unit->directory);
  978. while (fw_csr_iterator_next(&ci, &key, &value))
  979. if (key == CSR_DIRECTORY_ID) {
  980. directory_id = value;
  981. break;
  982. }
  983. /* FIXME: Make this work for multi-lun devices. */
  984. lun = 0;
  985. return sprintf(buf, "%08x%08x:%06x:%04x\n",
  986. device->config_rom[3], device->config_rom[4],
  987. directory_id, lun);
  988. }
  989. static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL);
  990. static struct device_attribute *sbp2_scsi_sysfs_attrs[] = {
  991. &dev_attr_ieee1394_id,
  992. NULL
  993. };
  994. static struct scsi_host_template scsi_driver_template = {
  995. .module = THIS_MODULE,
  996. .name = "SBP-2 IEEE-1394",
  997. .proc_name = (char *)sbp2_driver_name,
  998. .queuecommand = sbp2_scsi_queuecommand,
  999. .slave_alloc = sbp2_scsi_slave_alloc,
  1000. .slave_configure = sbp2_scsi_slave_configure,
  1001. .eh_abort_handler = sbp2_scsi_abort,
  1002. .this_id = -1,
  1003. .sg_tablesize = SG_ALL,
  1004. .use_clustering = ENABLE_CLUSTERING,
  1005. .cmd_per_lun = 1,
  1006. .can_queue = 1,
  1007. .sdev_attrs = sbp2_scsi_sysfs_attrs,
  1008. };
  1009. MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>");
  1010. MODULE_DESCRIPTION("SCSI over IEEE1394");
  1011. MODULE_LICENSE("GPL");
  1012. MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table);
  1013. /* Provide a module alias so root-on-sbp2 initrds don't break. */
  1014. #ifndef CONFIG_IEEE1394_SBP2_MODULE
  1015. MODULE_ALIAS("sbp2");
  1016. #endif
  1017. static int __init sbp2_init(void)
  1018. {
  1019. return driver_register(&sbp2_driver.driver);
  1020. }
  1021. static void __exit sbp2_cleanup(void)
  1022. {
  1023. driver_unregister(&sbp2_driver.driver);
  1024. }
  1025. module_init(sbp2_init);
  1026. module_exit(sbp2_cleanup);