fw-sbp2.c 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208
  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. /*
  366. * The sbp2 device is going to send a block read request to
  367. * read out the request from host memory, so map it for dma.
  368. */
  369. orb->base.request_bus =
  370. dma_map_single(device->card->device, &orb->request,
  371. sizeof(orb->request), DMA_TO_DEVICE);
  372. if (dma_mapping_error(orb->base.request_bus))
  373. goto out;
  374. orb->response_bus =
  375. dma_map_single(device->card->device, &orb->response,
  376. sizeof(orb->response), DMA_FROM_DEVICE);
  377. if (dma_mapping_error(orb->response_bus))
  378. goto out;
  379. orb->request.response.high = 0;
  380. orb->request.response.low = orb->response_bus;
  381. orb->request.misc =
  382. MANAGEMENT_ORB_NOTIFY |
  383. MANAGEMENT_ORB_FUNCTION(function) |
  384. MANAGEMENT_ORB_LUN(lun);
  385. orb->request.length =
  386. MANAGEMENT_ORB_RESPONSE_LENGTH(sizeof(orb->response));
  387. orb->request.status_fifo.high = sd->address_handler.offset >> 32;
  388. orb->request.status_fifo.low = sd->address_handler.offset;
  389. if (function == SBP2_LOGIN_REQUEST) {
  390. orb->request.misc |=
  391. MANAGEMENT_ORB_EXCLUSIVE(sbp2_param_exclusive_login) |
  392. MANAGEMENT_ORB_RECONNECT(0);
  393. }
  394. fw_memcpy_to_be32(&orb->request, &orb->request, sizeof(orb->request));
  395. init_completion(&orb->done);
  396. orb->base.callback = complete_management_orb;
  397. sbp2_send_orb(&orb->base, unit,
  398. node_id, generation, sd->management_agent_address);
  399. wait_for_completion_timeout(&orb->done,
  400. msecs_to_jiffies(SBP2_ORB_TIMEOUT));
  401. retval = -EIO;
  402. if (sbp2_cancel_orbs(unit) == 0) {
  403. fw_error("orb reply timed out, rcode=0x%02x\n",
  404. orb->base.rcode);
  405. goto out;
  406. }
  407. if (orb->base.rcode != RCODE_COMPLETE) {
  408. fw_error("management write failed, rcode 0x%02x\n",
  409. orb->base.rcode);
  410. goto out;
  411. }
  412. if (STATUS_GET_RESPONSE(orb->status) != 0 ||
  413. STATUS_GET_SBP_STATUS(orb->status) != 0) {
  414. fw_error("error status: %d:%d\n",
  415. STATUS_GET_RESPONSE(orb->status),
  416. STATUS_GET_SBP_STATUS(orb->status));
  417. goto out;
  418. }
  419. retval = 0;
  420. out:
  421. dma_unmap_single(device->card->device, orb->base.request_bus,
  422. sizeof(orb->request), DMA_TO_DEVICE);
  423. dma_unmap_single(device->card->device, orb->response_bus,
  424. sizeof(orb->response), DMA_FROM_DEVICE);
  425. if (response)
  426. fw_memcpy_from_be32(response,
  427. orb->response, sizeof(orb->response));
  428. kfree(orb);
  429. return retval;
  430. }
  431. static void
  432. complete_agent_reset_write(struct fw_card *card, int rcode,
  433. void *payload, size_t length, void *data)
  434. {
  435. struct fw_transaction *t = data;
  436. kfree(t);
  437. }
  438. static int sbp2_agent_reset(struct fw_unit *unit)
  439. {
  440. struct fw_device *device = fw_device(unit->device.parent);
  441. struct sbp2_device *sd = unit->device.driver_data;
  442. struct fw_transaction *t;
  443. static u32 zero;
  444. t = kzalloc(sizeof(*t), GFP_ATOMIC);
  445. if (t == NULL)
  446. return -ENOMEM;
  447. fw_send_request(device->card, t, TCODE_WRITE_QUADLET_REQUEST,
  448. sd->node_id, sd->generation, device->max_speed,
  449. sd->command_block_agent_address + SBP2_AGENT_RESET,
  450. &zero, sizeof(zero), complete_agent_reset_write, t);
  451. return 0;
  452. }
  453. static void sbp2_reconnect(struct work_struct *work);
  454. static struct scsi_host_template scsi_driver_template;
  455. static void release_sbp2_device(struct kref *kref)
  456. {
  457. struct sbp2_device *sd = container_of(kref, struct sbp2_device, kref);
  458. struct Scsi_Host *host =
  459. container_of((void *)sd, struct Scsi_Host, hostdata[0]);
  460. scsi_remove_host(host);
  461. sbp2_send_management_orb(sd->unit, sd->node_id, sd->generation,
  462. SBP2_LOGOUT_REQUEST, sd->login_id, NULL);
  463. fw_core_remove_address_handler(&sd->address_handler);
  464. fw_notify("removed sbp2 unit %s\n", sd->unit->device.bus_id);
  465. put_device(&sd->unit->device);
  466. scsi_host_put(host);
  467. }
  468. static void sbp2_login(struct work_struct *work)
  469. {
  470. struct sbp2_device *sd =
  471. container_of(work, struct sbp2_device, work.work);
  472. struct Scsi_Host *host =
  473. container_of((void *)sd, struct Scsi_Host, hostdata[0]);
  474. struct fw_unit *unit = sd->unit;
  475. struct fw_device *device = fw_device(unit->device.parent);
  476. struct sbp2_login_response response;
  477. int generation, node_id, local_node_id, lun, retval;
  478. /* FIXME: Make this work for multi-lun devices. */
  479. lun = 0;
  480. generation = device->card->generation;
  481. node_id = device->node->node_id;
  482. local_node_id = device->card->local_node->node_id;
  483. if (sbp2_send_management_orb(unit, node_id, generation,
  484. SBP2_LOGIN_REQUEST, lun, &response) < 0) {
  485. if (sd->retries++ < 5) {
  486. schedule_delayed_work(&sd->work, DIV_ROUND_UP(HZ, 5));
  487. } else {
  488. fw_error("failed to login to %s\n",
  489. unit->device.bus_id);
  490. kref_put(&sd->kref, release_sbp2_device);
  491. }
  492. return;
  493. }
  494. sd->generation = generation;
  495. sd->node_id = node_id;
  496. sd->address_high = local_node_id << 16;
  497. /* Get command block agent offset and login id. */
  498. sd->command_block_agent_address =
  499. ((u64) (response.command_block_agent.high & 0xffff) << 32) |
  500. response.command_block_agent.low;
  501. sd->login_id = LOGIN_RESPONSE_GET_LOGIN_ID(response);
  502. fw_notify("logged in to sbp2 unit %s (%d retries)\n",
  503. unit->device.bus_id, sd->retries);
  504. fw_notify(" - management_agent_address: 0x%012llx\n",
  505. (unsigned long long) sd->management_agent_address);
  506. fw_notify(" - command_block_agent_address: 0x%012llx\n",
  507. (unsigned long long) sd->command_block_agent_address);
  508. fw_notify(" - status write address: 0x%012llx\n",
  509. (unsigned long long) sd->address_handler.offset);
  510. #if 0
  511. /* FIXME: The linux1394 sbp2 does this last step. */
  512. sbp2_set_busy_timeout(scsi_id);
  513. #endif
  514. PREPARE_DELAYED_WORK(&sd->work, sbp2_reconnect);
  515. sbp2_agent_reset(unit);
  516. /* FIXME: Loop over luns here. */
  517. lun = 0;
  518. retval = scsi_add_device(host, 0, 0, lun);
  519. if (retval < 0) {
  520. sbp2_send_management_orb(unit, sd->node_id, sd->generation,
  521. SBP2_LOGOUT_REQUEST, sd->login_id,
  522. NULL);
  523. /*
  524. * Set this back to sbp2_login so we fall back and
  525. * retry login on bus reset.
  526. */
  527. PREPARE_DELAYED_WORK(&sd->work, sbp2_login);
  528. }
  529. kref_put(&sd->kref, release_sbp2_device);
  530. }
  531. static int sbp2_probe(struct device *dev)
  532. {
  533. struct fw_unit *unit = fw_unit(dev);
  534. struct fw_device *device = fw_device(unit->device.parent);
  535. struct sbp2_device *sd;
  536. struct fw_csr_iterator ci;
  537. struct Scsi_Host *host;
  538. int i, key, value, err;
  539. u32 model, firmware_revision;
  540. err = -ENOMEM;
  541. host = scsi_host_alloc(&scsi_driver_template, sizeof(*sd));
  542. if (host == NULL)
  543. goto fail;
  544. sd = (struct sbp2_device *) host->hostdata;
  545. unit->device.driver_data = sd;
  546. sd->unit = unit;
  547. INIT_LIST_HEAD(&sd->orb_list);
  548. kref_init(&sd->kref);
  549. sd->address_handler.length = 0x100;
  550. sd->address_handler.address_callback = sbp2_status_write;
  551. sd->address_handler.callback_data = sd;
  552. err = fw_core_add_address_handler(&sd->address_handler,
  553. &fw_high_memory_region);
  554. if (err < 0)
  555. goto fail_host;
  556. err = fw_device_enable_phys_dma(device);
  557. if (err < 0)
  558. goto fail_address_handler;
  559. err = scsi_add_host(host, &unit->device);
  560. if (err < 0)
  561. goto fail_address_handler;
  562. /*
  563. * Scan unit directory to get management agent address,
  564. * firmware revison and model. Initialize firmware_revision
  565. * and model to values that wont match anything in our table.
  566. */
  567. firmware_revision = 0xff000000;
  568. model = 0xff000000;
  569. fw_csr_iterator_init(&ci, unit->directory);
  570. while (fw_csr_iterator_next(&ci, &key, &value)) {
  571. switch (key) {
  572. case CSR_DEPENDENT_INFO | CSR_OFFSET:
  573. sd->management_agent_address =
  574. 0xfffff0000000ULL + 4 * value;
  575. break;
  576. case SBP2_FIRMWARE_REVISION:
  577. firmware_revision = value;
  578. break;
  579. case CSR_MODEL:
  580. model = value;
  581. break;
  582. }
  583. }
  584. for (i = 0; i < ARRAY_SIZE(sbp2_workarounds_table); i++) {
  585. if (sbp2_workarounds_table[i].firmware_revision !=
  586. (firmware_revision & 0xffffff00))
  587. continue;
  588. if (sbp2_workarounds_table[i].model != model &&
  589. sbp2_workarounds_table[i].model != ~0)
  590. continue;
  591. sd->workarounds |= sbp2_workarounds_table[i].workarounds;
  592. break;
  593. }
  594. if (sd->workarounds)
  595. fw_notify("Workarounds for node %s: 0x%x "
  596. "(firmware_revision 0x%06x, model_id 0x%06x)\n",
  597. unit->device.bus_id,
  598. sd->workarounds, firmware_revision, model);
  599. get_device(&unit->device);
  600. /*
  601. * We schedule work to do the login so we can easily
  602. * reschedule retries. Always get the ref before scheduling
  603. * work.
  604. */
  605. INIT_DELAYED_WORK(&sd->work, sbp2_login);
  606. if (schedule_delayed_work(&sd->work, 0))
  607. kref_get(&sd->kref);
  608. return 0;
  609. fail_address_handler:
  610. fw_core_remove_address_handler(&sd->address_handler);
  611. fail_host:
  612. scsi_host_put(host);
  613. fail:
  614. return err;
  615. }
  616. static int sbp2_remove(struct device *dev)
  617. {
  618. struct fw_unit *unit = fw_unit(dev);
  619. struct sbp2_device *sd = unit->device.driver_data;
  620. kref_put(&sd->kref, release_sbp2_device);
  621. return 0;
  622. }
  623. static void sbp2_reconnect(struct work_struct *work)
  624. {
  625. struct sbp2_device *sd =
  626. container_of(work, struct sbp2_device, work.work);
  627. struct fw_unit *unit = sd->unit;
  628. struct fw_device *device = fw_device(unit->device.parent);
  629. int generation, node_id, local_node_id;
  630. generation = device->card->generation;
  631. node_id = device->node->node_id;
  632. local_node_id = device->card->local_node->node_id;
  633. if (sbp2_send_management_orb(unit, node_id, generation,
  634. SBP2_RECONNECT_REQUEST,
  635. sd->login_id, NULL) < 0) {
  636. if (sd->retries++ >= 5) {
  637. fw_error("failed to reconnect to %s\n",
  638. unit->device.bus_id);
  639. /* Fall back and try to log in again. */
  640. sd->retries = 0;
  641. PREPARE_DELAYED_WORK(&sd->work, sbp2_login);
  642. }
  643. schedule_delayed_work(&sd->work, DIV_ROUND_UP(HZ, 5));
  644. return;
  645. }
  646. sd->generation = generation;
  647. sd->node_id = node_id;
  648. sd->address_high = local_node_id << 16;
  649. fw_notify("reconnected to unit %s (%d retries)\n",
  650. unit->device.bus_id, sd->retries);
  651. sbp2_agent_reset(unit);
  652. sbp2_cancel_orbs(unit);
  653. kref_put(&sd->kref, release_sbp2_device);
  654. }
  655. static void sbp2_update(struct fw_unit *unit)
  656. {
  657. struct fw_device *device = fw_device(unit->device.parent);
  658. struct sbp2_device *sd = unit->device.driver_data;
  659. sd->retries = 0;
  660. fw_device_enable_phys_dma(device);
  661. if (schedule_delayed_work(&sd->work, 0))
  662. kref_get(&sd->kref);
  663. }
  664. #define SBP2_UNIT_SPEC_ID_ENTRY 0x0000609e
  665. #define SBP2_SW_VERSION_ENTRY 0x00010483
  666. static const struct fw_device_id sbp2_id_table[] = {
  667. {
  668. .match_flags = FW_MATCH_SPECIFIER_ID | FW_MATCH_VERSION,
  669. .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY,
  670. .version = SBP2_SW_VERSION_ENTRY,
  671. },
  672. { }
  673. };
  674. static struct fw_driver sbp2_driver = {
  675. .driver = {
  676. .owner = THIS_MODULE,
  677. .name = sbp2_driver_name,
  678. .bus = &fw_bus_type,
  679. .probe = sbp2_probe,
  680. .remove = sbp2_remove,
  681. },
  682. .update = sbp2_update,
  683. .id_table = sbp2_id_table,
  684. };
  685. static unsigned int
  686. sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data)
  687. {
  688. int sam_status;
  689. sense_data[0] = 0x70;
  690. sense_data[1] = 0x0;
  691. sense_data[2] = sbp2_status[1];
  692. sense_data[3] = sbp2_status[4];
  693. sense_data[4] = sbp2_status[5];
  694. sense_data[5] = sbp2_status[6];
  695. sense_data[6] = sbp2_status[7];
  696. sense_data[7] = 10;
  697. sense_data[8] = sbp2_status[8];
  698. sense_data[9] = sbp2_status[9];
  699. sense_data[10] = sbp2_status[10];
  700. sense_data[11] = sbp2_status[11];
  701. sense_data[12] = sbp2_status[2];
  702. sense_data[13] = sbp2_status[3];
  703. sense_data[14] = sbp2_status[12];
  704. sense_data[15] = sbp2_status[13];
  705. sam_status = sbp2_status[0] & 0x3f;
  706. switch (sam_status) {
  707. case SAM_STAT_GOOD:
  708. case SAM_STAT_CHECK_CONDITION:
  709. case SAM_STAT_CONDITION_MET:
  710. case SAM_STAT_BUSY:
  711. case SAM_STAT_RESERVATION_CONFLICT:
  712. case SAM_STAT_COMMAND_TERMINATED:
  713. return DID_OK << 16 | sam_status;
  714. default:
  715. return DID_ERROR << 16;
  716. }
  717. }
  718. static void
  719. complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
  720. {
  721. struct sbp2_command_orb *orb =
  722. container_of(base_orb, struct sbp2_command_orb, base);
  723. struct fw_unit *unit = orb->unit;
  724. struct fw_device *device = fw_device(unit->device.parent);
  725. struct scatterlist *sg;
  726. int result;
  727. if (status != NULL) {
  728. if (STATUS_GET_DEAD(*status))
  729. sbp2_agent_reset(unit);
  730. switch (STATUS_GET_RESPONSE(*status)) {
  731. case SBP2_STATUS_REQUEST_COMPLETE:
  732. result = DID_OK << 16;
  733. break;
  734. case SBP2_STATUS_TRANSPORT_FAILURE:
  735. result = DID_BUS_BUSY << 16;
  736. break;
  737. case SBP2_STATUS_ILLEGAL_REQUEST:
  738. case SBP2_STATUS_VENDOR_DEPENDENT:
  739. default:
  740. result = DID_ERROR << 16;
  741. break;
  742. }
  743. if (result == DID_OK << 16 && STATUS_GET_LEN(*status) > 1)
  744. result = sbp2_status_to_sense_data(STATUS_GET_DATA(*status),
  745. orb->cmd->sense_buffer);
  746. } else {
  747. /*
  748. * If the orb completes with status == NULL, something
  749. * went wrong, typically a bus reset happened mid-orb
  750. * or when sending the write (less likely).
  751. */
  752. result = DID_BUS_BUSY << 16;
  753. }
  754. dma_unmap_single(device->card->device, orb->base.request_bus,
  755. sizeof(orb->request), DMA_TO_DEVICE);
  756. if (orb->cmd->use_sg > 0) {
  757. sg = (struct scatterlist *)orb->cmd->request_buffer;
  758. dma_unmap_sg(device->card->device, sg, orb->cmd->use_sg,
  759. orb->cmd->sc_data_direction);
  760. }
  761. if (orb->page_table_bus != 0)
  762. dma_unmap_single(device->card->device, orb->page_table_bus,
  763. sizeof(orb->page_table_bus), DMA_TO_DEVICE);
  764. orb->cmd->result = result;
  765. orb->done(orb->cmd);
  766. kfree(orb);
  767. }
  768. static int sbp2_command_orb_map_scatterlist(struct sbp2_command_orb *orb)
  769. {
  770. struct sbp2_device *sd =
  771. (struct sbp2_device *)orb->cmd->device->host->hostdata;
  772. struct fw_unit *unit = sd->unit;
  773. struct fw_device *device = fw_device(unit->device.parent);
  774. struct scatterlist *sg;
  775. int sg_len, l, i, j, count;
  776. size_t size;
  777. dma_addr_t sg_addr;
  778. sg = (struct scatterlist *)orb->cmd->request_buffer;
  779. count = dma_map_sg(device->card->device, sg, orb->cmd->use_sg,
  780. orb->cmd->sc_data_direction);
  781. if (count == 0)
  782. goto fail;
  783. /*
  784. * Handle the special case where there is only one element in
  785. * the scatter list by converting it to an immediate block
  786. * request. This is also a workaround for broken devices such
  787. * as the second generation iPod which doesn't support page
  788. * tables.
  789. */
  790. if (count == 1 && sg_dma_len(sg) < SBP2_MAX_SG_ELEMENT_LENGTH) {
  791. orb->request.data_descriptor.high = sd->address_high;
  792. orb->request.data_descriptor.low = sg_dma_address(sg);
  793. orb->request.misc |=
  794. COMMAND_ORB_DATA_SIZE(sg_dma_len(sg));
  795. return 0;
  796. }
  797. /*
  798. * Convert the scatterlist to an sbp2 page table. If any
  799. * scatterlist entries are too big for sbp2, we split them as we
  800. * go. Even if we ask the block I/O layer to not give us sg
  801. * elements larger than 65535 bytes, some IOMMUs may merge sg elements
  802. * during DMA mapping, and Linux currently doesn't prevent this.
  803. */
  804. for (i = 0, j = 0; i < count; i++) {
  805. sg_len = sg_dma_len(sg + i);
  806. sg_addr = sg_dma_address(sg + i);
  807. while (sg_len) {
  808. /* FIXME: This won't get us out of the pinch. */
  809. if (unlikely(j >= ARRAY_SIZE(orb->page_table))) {
  810. fw_error("page table overflow\n");
  811. goto fail_page_table;
  812. }
  813. l = min(sg_len, SBP2_MAX_SG_ELEMENT_LENGTH);
  814. orb->page_table[j].low = sg_addr;
  815. orb->page_table[j].high = (l << 16);
  816. sg_addr += l;
  817. sg_len -= l;
  818. j++;
  819. }
  820. }
  821. size = sizeof(orb->page_table[0]) * j;
  822. /*
  823. * The data_descriptor pointer is the one case where we need
  824. * to fill in the node ID part of the address. All other
  825. * pointers assume that the data referenced reside on the
  826. * initiator (i.e. us), but data_descriptor can refer to data
  827. * on other nodes so we need to put our ID in descriptor.high.
  828. */
  829. orb->page_table_bus =
  830. dma_map_single(device->card->device, orb->page_table,
  831. size, DMA_TO_DEVICE);
  832. if (dma_mapping_error(orb->page_table_bus))
  833. goto fail_page_table;
  834. orb->request.data_descriptor.high = sd->address_high;
  835. orb->request.data_descriptor.low = orb->page_table_bus;
  836. orb->request.misc |=
  837. COMMAND_ORB_PAGE_TABLE_PRESENT |
  838. COMMAND_ORB_DATA_SIZE(j);
  839. fw_memcpy_to_be32(orb->page_table, orb->page_table, size);
  840. return 0;
  841. fail_page_table:
  842. dma_unmap_sg(device->card->device, sg, orb->cmd->use_sg,
  843. orb->cmd->sc_data_direction);
  844. fail:
  845. return -ENOMEM;
  846. }
  847. /* SCSI stack integration */
  848. static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
  849. {
  850. struct sbp2_device *sd =
  851. (struct sbp2_device *)cmd->device->host->hostdata;
  852. struct fw_unit *unit = sd->unit;
  853. struct fw_device *device = fw_device(unit->device.parent);
  854. struct sbp2_command_orb *orb;
  855. /*
  856. * Bidirectional commands are not yet implemented, and unknown
  857. * transfer direction not handled.
  858. */
  859. if (cmd->sc_data_direction == DMA_BIDIRECTIONAL) {
  860. fw_error("Can't handle DMA_BIDIRECTIONAL, rejecting command\n");
  861. cmd->result = DID_ERROR << 16;
  862. done(cmd);
  863. return 0;
  864. }
  865. orb = kzalloc(sizeof(*orb), GFP_ATOMIC);
  866. if (orb == NULL) {
  867. fw_notify("failed to alloc orb\n");
  868. goto fail_alloc;
  869. }
  870. /* Initialize rcode to something not RCODE_COMPLETE. */
  871. orb->base.rcode = -1;
  872. orb->base.request_bus =
  873. dma_map_single(device->card->device, &orb->request,
  874. sizeof(orb->request), DMA_TO_DEVICE);
  875. if (dma_mapping_error(orb->base.request_bus))
  876. goto fail_mapping;
  877. orb->unit = unit;
  878. orb->done = done;
  879. orb->cmd = cmd;
  880. orb->request.next.high = SBP2_ORB_NULL;
  881. orb->request.next.low = 0x0;
  882. /*
  883. * At speed 100 we can do 512 bytes per packet, at speed 200,
  884. * 1024 bytes per packet etc. The SBP-2 max_payload field
  885. * specifies the max payload size as 2 ^ (max_payload + 2), so
  886. * if we set this to max_speed + 7, we get the right value.
  887. */
  888. orb->request.misc =
  889. COMMAND_ORB_MAX_PAYLOAD(device->max_speed + 7) |
  890. COMMAND_ORB_SPEED(device->max_speed) |
  891. COMMAND_ORB_NOTIFY;
  892. if (cmd->sc_data_direction == DMA_FROM_DEVICE)
  893. orb->request.misc |=
  894. COMMAND_ORB_DIRECTION(SBP2_DIRECTION_FROM_MEDIA);
  895. else if (cmd->sc_data_direction == DMA_TO_DEVICE)
  896. orb->request.misc |=
  897. COMMAND_ORB_DIRECTION(SBP2_DIRECTION_TO_MEDIA);
  898. if (cmd->use_sg && sbp2_command_orb_map_scatterlist(orb) < 0)
  899. goto fail_map_payload;
  900. fw_memcpy_to_be32(&orb->request, &orb->request, sizeof(orb->request));
  901. memset(orb->request.command_block,
  902. 0, sizeof(orb->request.command_block));
  903. memcpy(orb->request.command_block, cmd->cmnd, COMMAND_SIZE(*cmd->cmnd));
  904. orb->base.callback = complete_command_orb;
  905. sbp2_send_orb(&orb->base, unit, sd->node_id, sd->generation,
  906. sd->command_block_agent_address + SBP2_ORB_POINTER);
  907. return 0;
  908. fail_map_payload:
  909. dma_unmap_single(device->card->device, orb->base.request_bus,
  910. sizeof(orb->request), DMA_TO_DEVICE);
  911. fail_mapping:
  912. kfree(orb);
  913. fail_alloc:
  914. return SCSI_MLQUEUE_HOST_BUSY;
  915. }
  916. static int sbp2_scsi_slave_alloc(struct scsi_device *sdev)
  917. {
  918. struct sbp2_device *sd = (struct sbp2_device *)sdev->host->hostdata;
  919. sdev->allow_restart = 1;
  920. if (sd->workarounds & SBP2_WORKAROUND_INQUIRY_36)
  921. sdev->inquiry_len = 36;
  922. return 0;
  923. }
  924. static int sbp2_scsi_slave_configure(struct scsi_device *sdev)
  925. {
  926. struct sbp2_device *sd = (struct sbp2_device *)sdev->host->hostdata;
  927. struct fw_unit *unit = sd->unit;
  928. sdev->use_10_for_rw = 1;
  929. if (sdev->type == TYPE_ROM)
  930. sdev->use_10_for_ms = 1;
  931. if (sdev->type == TYPE_DISK &&
  932. sd->workarounds & SBP2_WORKAROUND_MODE_SENSE_8)
  933. sdev->skip_ms_page_8 = 1;
  934. if (sd->workarounds & SBP2_WORKAROUND_FIX_CAPACITY) {
  935. fw_notify("setting fix_capacity for %s\n", unit->device.bus_id);
  936. sdev->fix_capacity = 1;
  937. }
  938. if (sd->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS)
  939. blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512);
  940. return 0;
  941. }
  942. /*
  943. * Called by scsi stack when something has really gone wrong. Usually
  944. * called when a command has timed-out for some reason.
  945. */
  946. static int sbp2_scsi_abort(struct scsi_cmnd *cmd)
  947. {
  948. struct sbp2_device *sd =
  949. (struct sbp2_device *)cmd->device->host->hostdata;
  950. struct fw_unit *unit = sd->unit;
  951. fw_notify("sbp2_scsi_abort\n");
  952. sbp2_agent_reset(unit);
  953. sbp2_cancel_orbs(unit);
  954. return SUCCESS;
  955. }
  956. /*
  957. * Format of /sys/bus/scsi/devices/.../ieee1394_id:
  958. * u64 EUI-64 : u24 directory_ID : u16 LUN (all printed in hexadecimal)
  959. *
  960. * This is the concatenation of target port identifier and logical unit
  961. * identifier as per SAM-2...SAM-4 annex A.
  962. */
  963. static ssize_t
  964. sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr,
  965. char *buf)
  966. {
  967. struct scsi_device *sdev = to_scsi_device(dev);
  968. struct sbp2_device *sd;
  969. struct fw_unit *unit;
  970. struct fw_device *device;
  971. u32 directory_id;
  972. struct fw_csr_iterator ci;
  973. int key, value, lun;
  974. if (!sdev)
  975. return 0;
  976. sd = (struct sbp2_device *)sdev->host->hostdata;
  977. unit = sd->unit;
  978. device = fw_device(unit->device.parent);
  979. /* implicit directory ID */
  980. directory_id = ((unit->directory - device->config_rom) * 4
  981. + CSR_CONFIG_ROM) & 0xffffff;
  982. /* explicit directory ID, overrides implicit ID if present */
  983. fw_csr_iterator_init(&ci, unit->directory);
  984. while (fw_csr_iterator_next(&ci, &key, &value))
  985. if (key == CSR_DIRECTORY_ID) {
  986. directory_id = value;
  987. break;
  988. }
  989. /* FIXME: Make this work for multi-lun devices. */
  990. lun = 0;
  991. return sprintf(buf, "%08x%08x:%06x:%04x\n",
  992. device->config_rom[3], device->config_rom[4],
  993. directory_id, lun);
  994. }
  995. static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL);
  996. static struct device_attribute *sbp2_scsi_sysfs_attrs[] = {
  997. &dev_attr_ieee1394_id,
  998. NULL
  999. };
  1000. static struct scsi_host_template scsi_driver_template = {
  1001. .module = THIS_MODULE,
  1002. .name = "SBP-2 IEEE-1394",
  1003. .proc_name = (char *)sbp2_driver_name,
  1004. .queuecommand = sbp2_scsi_queuecommand,
  1005. .slave_alloc = sbp2_scsi_slave_alloc,
  1006. .slave_configure = sbp2_scsi_slave_configure,
  1007. .eh_abort_handler = sbp2_scsi_abort,
  1008. .this_id = -1,
  1009. .sg_tablesize = SG_ALL,
  1010. .use_clustering = ENABLE_CLUSTERING,
  1011. .cmd_per_lun = 1,
  1012. .can_queue = 1,
  1013. .sdev_attrs = sbp2_scsi_sysfs_attrs,
  1014. };
  1015. MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>");
  1016. MODULE_DESCRIPTION("SCSI over IEEE1394");
  1017. MODULE_LICENSE("GPL");
  1018. MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table);
  1019. /* Provide a module alias so root-on-sbp2 initrds don't break. */
  1020. #ifndef CONFIG_IEEE1394_SBP2_MODULE
  1021. MODULE_ALIAS("sbp2");
  1022. #endif
  1023. static int __init sbp2_init(void)
  1024. {
  1025. return driver_register(&sbp2_driver.driver);
  1026. }
  1027. static void __exit sbp2_cleanup(void)
  1028. {
  1029. driver_unregister(&sbp2_driver.driver);
  1030. }
  1031. module_init(sbp2_init);
  1032. module_exit(sbp2_cleanup);