scsi_dh_emc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. /*
  2. * Target driver for EMC CLARiiON AX/CX-series hardware.
  3. * Based on code from Lars Marowsky-Bree <lmb@suse.de>
  4. * and Ed Goggin <egoggin@emc.com>.
  5. *
  6. * Copyright (C) 2006 Red Hat, Inc. All rights reserved.
  7. * Copyright (C) 2006 Mike Christie
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2, or (at your option)
  12. * any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; see the file COPYING. If not, write to
  21. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22. */
  23. #include <linux/slab.h>
  24. #include <linux/module.h>
  25. #include <scsi/scsi.h>
  26. #include <scsi/scsi_eh.h>
  27. #include <scsi/scsi_dh.h>
  28. #include <scsi/scsi_device.h>
  29. #define CLARIION_NAME "emc"
  30. #define CLARIION_TRESPASS_PAGE 0x22
  31. #define CLARIION_BUFFER_SIZE 0xFC
  32. #define CLARIION_TIMEOUT (60 * HZ)
  33. #define CLARIION_RETRIES 3
  34. #define CLARIION_UNBOUND_LU -1
  35. #define CLARIION_SP_A 0
  36. #define CLARIION_SP_B 1
  37. /* Flags */
  38. #define CLARIION_SHORT_TRESPASS 1
  39. #define CLARIION_HONOR_RESERVATIONS 2
  40. /* LUN states */
  41. #define CLARIION_LUN_UNINITIALIZED -1
  42. #define CLARIION_LUN_UNBOUND 0
  43. #define CLARIION_LUN_BOUND 1
  44. #define CLARIION_LUN_OWNED 2
  45. static unsigned char long_trespass[] = {
  46. 0, 0, 0, 0, 0, 0, 0, 0,
  47. CLARIION_TRESPASS_PAGE, /* Page code */
  48. 0x09, /* Page length - 2 */
  49. 0x01, /* Trespass code */
  50. 0xff, 0xff, /* Trespass target */
  51. 0, 0, 0, 0, 0, 0 /* Reserved bytes / unknown */
  52. };
  53. static unsigned char short_trespass[] = {
  54. 0, 0, 0, 0,
  55. CLARIION_TRESPASS_PAGE, /* Page code */
  56. 0x02, /* Page length - 2 */
  57. 0x01, /* Trespass code */
  58. 0xff, /* Trespass target */
  59. };
  60. static const char * lun_state[] =
  61. {
  62. "not bound",
  63. "bound",
  64. "owned",
  65. };
  66. struct clariion_dh_data {
  67. /*
  68. * Flags:
  69. * CLARIION_SHORT_TRESPASS
  70. * Use short trespass command (FC-series) or the long version
  71. * (default for AX/CX CLARiiON arrays).
  72. *
  73. * CLARIION_HONOR_RESERVATIONS
  74. * Whether or not (default) to honor SCSI reservations when
  75. * initiating a switch-over.
  76. */
  77. unsigned flags;
  78. /*
  79. * I/O buffer for both MODE_SELECT and INQUIRY commands.
  80. */
  81. unsigned char buffer[CLARIION_BUFFER_SIZE];
  82. /*
  83. * SCSI sense buffer for commands -- assumes serial issuance
  84. * and completion sequence of all commands for same multipath.
  85. */
  86. unsigned char sense[SCSI_SENSE_BUFFERSIZE];
  87. unsigned int senselen;
  88. /*
  89. * LUN state
  90. */
  91. int lun_state;
  92. /*
  93. * SP Port number
  94. */
  95. int port;
  96. /*
  97. * which SP (A=0,B=1,UNBOUND=-1) is the default SP for this
  98. * path's mapped LUN
  99. */
  100. int default_sp;
  101. /*
  102. * which SP (A=0,B=1,UNBOUND=-1) is the active SP for this
  103. * path's mapped LUN
  104. */
  105. int current_sp;
  106. };
  107. /*
  108. * Parse MODE_SELECT cmd reply.
  109. */
  110. static int trespass_endio(struct scsi_device *sdev, char *sense)
  111. {
  112. int err = SCSI_DH_IO;
  113. struct scsi_sense_hdr sshdr;
  114. if (!scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, &sshdr)) {
  115. sdev_printk(KERN_ERR, sdev, "%s: Found valid sense data 0x%2x, "
  116. "0x%2x, 0x%2x while sending CLARiiON trespass "
  117. "command.\n", CLARIION_NAME, sshdr.sense_key,
  118. sshdr.asc, sshdr.ascq);
  119. if ((sshdr.sense_key == 0x05) && (sshdr.asc == 0x04) &&
  120. (sshdr.ascq == 0x00)) {
  121. /*
  122. * Array based copy in progress -- do not send
  123. * mode_select or copy will be aborted mid-stream.
  124. */
  125. sdev_printk(KERN_INFO, sdev, "%s: Array Based Copy in "
  126. "progress while sending CLARiiON trespass "
  127. "command.\n", CLARIION_NAME);
  128. err = SCSI_DH_DEV_TEMP_BUSY;
  129. } else if ((sshdr.sense_key == 0x02) && (sshdr.asc == 0x04) &&
  130. (sshdr.ascq == 0x03)) {
  131. /*
  132. * LUN Not Ready - Manual Intervention Required
  133. * indicates in-progress ucode upgrade (NDU).
  134. */
  135. sdev_printk(KERN_INFO, sdev, "%s: Detected in-progress "
  136. "ucode upgrade NDU operation while sending "
  137. "CLARiiON trespass command.\n", CLARIION_NAME);
  138. err = SCSI_DH_DEV_TEMP_BUSY;
  139. } else
  140. err = SCSI_DH_DEV_FAILED;
  141. } else {
  142. sdev_printk(KERN_INFO, sdev,
  143. "%s: failed to send MODE SELECT, no sense available\n",
  144. CLARIION_NAME);
  145. }
  146. return err;
  147. }
  148. static int parse_sp_info_reply(struct scsi_device *sdev,
  149. struct clariion_dh_data *csdev)
  150. {
  151. int err = SCSI_DH_OK;
  152. /* check for in-progress ucode upgrade (NDU) */
  153. if (csdev->buffer[48] != 0) {
  154. sdev_printk(KERN_NOTICE, sdev, "%s: Detected in-progress "
  155. "ucode upgrade NDU operation while finding "
  156. "current active SP.", CLARIION_NAME);
  157. err = SCSI_DH_DEV_TEMP_BUSY;
  158. goto out;
  159. }
  160. if (csdev->buffer[4] > 2) {
  161. /* Invalid buffer format */
  162. sdev_printk(KERN_NOTICE, sdev,
  163. "%s: invalid VPD page 0xC0 format\n",
  164. CLARIION_NAME);
  165. err = SCSI_DH_NOSYS;
  166. goto out;
  167. }
  168. switch (csdev->buffer[28] & 0x0f) {
  169. case 6:
  170. sdev_printk(KERN_NOTICE, sdev,
  171. "%s: ALUA failover mode detected\n",
  172. CLARIION_NAME);
  173. break;
  174. case 4:
  175. /* Linux failover */
  176. break;
  177. default:
  178. sdev_printk(KERN_WARNING, sdev,
  179. "%s: Invalid failover mode %d\n",
  180. CLARIION_NAME, csdev->buffer[28] & 0x0f);
  181. err = SCSI_DH_NOSYS;
  182. goto out;
  183. }
  184. csdev->default_sp = csdev->buffer[5];
  185. csdev->lun_state = csdev->buffer[4];
  186. csdev->current_sp = csdev->buffer[8];
  187. csdev->port = csdev->buffer[7];
  188. out:
  189. return err;
  190. }
  191. #define emc_default_str "FC (Legacy)"
  192. static char * parse_sp_model(struct scsi_device *sdev, unsigned char *buffer)
  193. {
  194. unsigned char len = buffer[4] + 5;
  195. char *sp_model = NULL;
  196. unsigned char sp_len, serial_len;
  197. if (len < 160) {
  198. sdev_printk(KERN_WARNING, sdev,
  199. "%s: Invalid information section length %d\n",
  200. CLARIION_NAME, len);
  201. /* Check for old FC arrays */
  202. if (!strncmp(buffer + 8, "DGC", 3)) {
  203. /* Old FC array, not supporting extended information */
  204. sp_model = emc_default_str;
  205. }
  206. goto out;
  207. }
  208. /*
  209. * Parse extended information for SP model number
  210. */
  211. serial_len = buffer[160];
  212. if (serial_len == 0 || serial_len + 161 > len) {
  213. sdev_printk(KERN_WARNING, sdev,
  214. "%s: Invalid array serial number length %d\n",
  215. CLARIION_NAME, serial_len);
  216. goto out;
  217. }
  218. sp_len = buffer[99];
  219. if (sp_len == 0 || serial_len + sp_len + 161 > len) {
  220. sdev_printk(KERN_WARNING, sdev,
  221. "%s: Invalid model number length %d\n",
  222. CLARIION_NAME, sp_len);
  223. goto out;
  224. }
  225. sp_model = &buffer[serial_len + 161];
  226. /* Strip whitespace at the end */
  227. while (sp_len > 1 && sp_model[sp_len - 1] == ' ')
  228. sp_len--;
  229. sp_model[sp_len] = '\0';
  230. out:
  231. return sp_model;
  232. }
  233. /*
  234. * Get block request for REQ_BLOCK_PC command issued to path. Currently
  235. * limited to MODE_SELECT (trespass) and INQUIRY (VPD page 0xC0) commands.
  236. *
  237. * Uses data and sense buffers in hardware handler context structure and
  238. * assumes serial servicing of commands, both issuance and completion.
  239. */
  240. static struct request *get_req(struct scsi_device *sdev, int cmd,
  241. unsigned char *buffer)
  242. {
  243. struct request *rq;
  244. int len = 0;
  245. rq = blk_get_request(sdev->request_queue,
  246. (cmd != INQUIRY) ? WRITE : READ, GFP_NOIO);
  247. if (IS_ERR(rq)) {
  248. sdev_printk(KERN_INFO, sdev, "get_req: blk_get_request failed");
  249. return NULL;
  250. }
  251. blk_rq_set_block_pc(rq);
  252. rq->cmd_len = COMMAND_SIZE(cmd);
  253. rq->cmd[0] = cmd;
  254. switch (cmd) {
  255. case MODE_SELECT:
  256. len = sizeof(short_trespass);
  257. rq->cmd[1] = 0x10;
  258. rq->cmd[4] = len;
  259. break;
  260. case MODE_SELECT_10:
  261. len = sizeof(long_trespass);
  262. rq->cmd[1] = 0x10;
  263. rq->cmd[8] = len;
  264. break;
  265. case INQUIRY:
  266. len = CLARIION_BUFFER_SIZE;
  267. rq->cmd[4] = len;
  268. memset(buffer, 0, len);
  269. break;
  270. default:
  271. BUG_ON(1);
  272. break;
  273. }
  274. rq->cmd_flags |= REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
  275. REQ_FAILFAST_DRIVER;
  276. rq->timeout = CLARIION_TIMEOUT;
  277. rq->retries = CLARIION_RETRIES;
  278. if (blk_rq_map_kern(rq->q, rq, buffer, len, GFP_NOIO)) {
  279. blk_put_request(rq);
  280. return NULL;
  281. }
  282. return rq;
  283. }
  284. static int send_inquiry_cmd(struct scsi_device *sdev, int page,
  285. struct clariion_dh_data *csdev)
  286. {
  287. struct request *rq = get_req(sdev, INQUIRY, csdev->buffer);
  288. int err;
  289. if (!rq)
  290. return SCSI_DH_RES_TEMP_UNAVAIL;
  291. rq->sense = csdev->sense;
  292. memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE);
  293. rq->sense_len = csdev->senselen = 0;
  294. rq->cmd[0] = INQUIRY;
  295. if (page != 0) {
  296. rq->cmd[1] = 1;
  297. rq->cmd[2] = page;
  298. }
  299. err = blk_execute_rq(sdev->request_queue, NULL, rq, 1);
  300. if (err == -EIO) {
  301. sdev_printk(KERN_INFO, sdev,
  302. "%s: failed to send %s INQUIRY: %x\n",
  303. CLARIION_NAME, page?"EVPD":"standard",
  304. rq->errors);
  305. csdev->senselen = rq->sense_len;
  306. err = SCSI_DH_IO;
  307. }
  308. blk_put_request(rq);
  309. return err;
  310. }
  311. static int send_trespass_cmd(struct scsi_device *sdev,
  312. struct clariion_dh_data *csdev)
  313. {
  314. struct request *rq;
  315. unsigned char *page22;
  316. int err, len, cmd;
  317. if (csdev->flags & CLARIION_SHORT_TRESPASS) {
  318. page22 = short_trespass;
  319. if (!(csdev->flags & CLARIION_HONOR_RESERVATIONS))
  320. /* Set Honor Reservations bit */
  321. page22[6] |= 0x80;
  322. len = sizeof(short_trespass);
  323. cmd = MODE_SELECT;
  324. } else {
  325. page22 = long_trespass;
  326. if (!(csdev->flags & CLARIION_HONOR_RESERVATIONS))
  327. /* Set Honor Reservations bit */
  328. page22[10] |= 0x80;
  329. len = sizeof(long_trespass);
  330. cmd = MODE_SELECT_10;
  331. }
  332. BUG_ON((len > CLARIION_BUFFER_SIZE));
  333. memcpy(csdev->buffer, page22, len);
  334. rq = get_req(sdev, cmd, csdev->buffer);
  335. if (!rq)
  336. return SCSI_DH_RES_TEMP_UNAVAIL;
  337. rq->sense = csdev->sense;
  338. memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE);
  339. rq->sense_len = csdev->senselen = 0;
  340. err = blk_execute_rq(sdev->request_queue, NULL, rq, 1);
  341. if (err == -EIO) {
  342. if (rq->sense_len) {
  343. err = trespass_endio(sdev, csdev->sense);
  344. } else {
  345. sdev_printk(KERN_INFO, sdev,
  346. "%s: failed to send MODE SELECT: %x\n",
  347. CLARIION_NAME, rq->errors);
  348. }
  349. }
  350. blk_put_request(rq);
  351. return err;
  352. }
  353. static int clariion_check_sense(struct scsi_device *sdev,
  354. struct scsi_sense_hdr *sense_hdr)
  355. {
  356. switch (sense_hdr->sense_key) {
  357. case NOT_READY:
  358. if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x03)
  359. /*
  360. * LUN Not Ready - Manual Intervention Required
  361. * indicates this is a passive path.
  362. *
  363. * FIXME: However, if this is seen and EVPD C0
  364. * indicates that this is due to a NDU in
  365. * progress, we should set FAIL_PATH too.
  366. * This indicates we might have to do a SCSI
  367. * inquiry in the end_io path. Ugh.
  368. *
  369. * Can return FAILED only when we want the error
  370. * recovery process to kick in.
  371. */
  372. return SUCCESS;
  373. break;
  374. case ILLEGAL_REQUEST:
  375. if (sense_hdr->asc == 0x25 && sense_hdr->ascq == 0x01)
  376. /*
  377. * An array based copy is in progress. Do not
  378. * fail the path, do not bypass to another PG,
  379. * do not retry. Fail the IO immediately.
  380. * (Actually this is the same conclusion as in
  381. * the default handler, but lets make sure.)
  382. *
  383. * Can return FAILED only when we want the error
  384. * recovery process to kick in.
  385. */
  386. return SUCCESS;
  387. break;
  388. case UNIT_ATTENTION:
  389. if (sense_hdr->asc == 0x29 && sense_hdr->ascq == 0x00)
  390. /*
  391. * Unit Attention Code. This is the first IO
  392. * to the new path, so just retry.
  393. */
  394. return ADD_TO_MLQUEUE;
  395. break;
  396. }
  397. return SCSI_RETURN_NOT_HANDLED;
  398. }
  399. static int clariion_prep_fn(struct scsi_device *sdev, struct request *req)
  400. {
  401. struct clariion_dh_data *h = sdev->handler_data;
  402. int ret = BLKPREP_OK;
  403. if (h->lun_state != CLARIION_LUN_OWNED) {
  404. ret = BLKPREP_KILL;
  405. req->cmd_flags |= REQ_QUIET;
  406. }
  407. return ret;
  408. }
  409. static int clariion_std_inquiry(struct scsi_device *sdev,
  410. struct clariion_dh_data *csdev)
  411. {
  412. int err = SCSI_DH_OK;
  413. char *sp_model;
  414. err = send_inquiry_cmd(sdev, 0, csdev);
  415. if (err != SCSI_DH_OK && csdev->senselen) {
  416. struct scsi_sense_hdr sshdr;
  417. if (scsi_normalize_sense(csdev->sense, SCSI_SENSE_BUFFERSIZE,
  418. &sshdr)) {
  419. sdev_printk(KERN_ERR, sdev, "%s: INQUIRY sense code "
  420. "%02x/%02x/%02x\n", CLARIION_NAME,
  421. sshdr.sense_key, sshdr.asc, sshdr.ascq);
  422. }
  423. err = SCSI_DH_IO;
  424. goto out;
  425. }
  426. sp_model = parse_sp_model(sdev, csdev->buffer);
  427. if (!sp_model) {
  428. err = SCSI_DH_DEV_UNSUPP;
  429. goto out;
  430. }
  431. /*
  432. * FC Series arrays do not support long trespass
  433. */
  434. if (!strlen(sp_model) || !strncmp(sp_model, "FC",2))
  435. csdev->flags |= CLARIION_SHORT_TRESPASS;
  436. sdev_printk(KERN_INFO, sdev,
  437. "%s: detected Clariion %s, flags %x\n",
  438. CLARIION_NAME, sp_model, csdev->flags);
  439. out:
  440. return err;
  441. }
  442. static int clariion_send_inquiry(struct scsi_device *sdev,
  443. struct clariion_dh_data *csdev)
  444. {
  445. int err, retry = CLARIION_RETRIES;
  446. retry:
  447. err = send_inquiry_cmd(sdev, 0xC0, csdev);
  448. if (err != SCSI_DH_OK && csdev->senselen) {
  449. struct scsi_sense_hdr sshdr;
  450. err = scsi_normalize_sense(csdev->sense, SCSI_SENSE_BUFFERSIZE,
  451. &sshdr);
  452. if (!err)
  453. return SCSI_DH_IO;
  454. err = clariion_check_sense(sdev, &sshdr);
  455. if (retry > 0 && err == ADD_TO_MLQUEUE) {
  456. retry--;
  457. goto retry;
  458. }
  459. sdev_printk(KERN_ERR, sdev, "%s: INQUIRY sense code "
  460. "%02x/%02x/%02x\n", CLARIION_NAME,
  461. sshdr.sense_key, sshdr.asc, sshdr.ascq);
  462. err = SCSI_DH_IO;
  463. } else {
  464. err = parse_sp_info_reply(sdev, csdev);
  465. }
  466. return err;
  467. }
  468. static int clariion_activate(struct scsi_device *sdev,
  469. activate_complete fn, void *data)
  470. {
  471. struct clariion_dh_data *csdev = sdev->handler_data;
  472. int result;
  473. result = clariion_send_inquiry(sdev, csdev);
  474. if (result != SCSI_DH_OK)
  475. goto done;
  476. if (csdev->lun_state == CLARIION_LUN_OWNED)
  477. goto done;
  478. result = send_trespass_cmd(sdev, csdev);
  479. if (result != SCSI_DH_OK)
  480. goto done;
  481. sdev_printk(KERN_INFO, sdev,"%s: %s trespass command sent\n",
  482. CLARIION_NAME,
  483. csdev->flags&CLARIION_SHORT_TRESPASS?"short":"long" );
  484. /* Update status */
  485. result = clariion_send_inquiry(sdev, csdev);
  486. if (result != SCSI_DH_OK)
  487. goto done;
  488. done:
  489. sdev_printk(KERN_INFO, sdev,
  490. "%s: at SP %c Port %d (%s, default SP %c)\n",
  491. CLARIION_NAME, csdev->current_sp + 'A',
  492. csdev->port, lun_state[csdev->lun_state],
  493. csdev->default_sp + 'A');
  494. if (fn)
  495. fn(data, result);
  496. return 0;
  497. }
  498. /*
  499. * params - parameters in the following format
  500. * "no_of_params\0param1\0param2\0param3\0...\0"
  501. * for example, string for 2 parameters with value 10 and 21
  502. * is specified as "2\010\021\0".
  503. */
  504. static int clariion_set_params(struct scsi_device *sdev, const char *params)
  505. {
  506. struct clariion_dh_data *csdev = sdev->handler_data;
  507. unsigned int hr = 0, st = 0, argc;
  508. const char *p = params;
  509. int result = SCSI_DH_OK;
  510. if ((sscanf(params, "%u", &argc) != 1) || (argc != 2))
  511. return -EINVAL;
  512. while (*p++)
  513. ;
  514. if ((sscanf(p, "%u", &st) != 1) || (st > 1))
  515. return -EINVAL;
  516. while (*p++)
  517. ;
  518. if ((sscanf(p, "%u", &hr) != 1) || (hr > 1))
  519. return -EINVAL;
  520. if (st)
  521. csdev->flags |= CLARIION_SHORT_TRESPASS;
  522. else
  523. csdev->flags &= ~CLARIION_SHORT_TRESPASS;
  524. if (hr)
  525. csdev->flags |= CLARIION_HONOR_RESERVATIONS;
  526. else
  527. csdev->flags &= ~CLARIION_HONOR_RESERVATIONS;
  528. /*
  529. * If this path is owned, we have to send a trespass command
  530. * with the new parameters. If not, simply return. Next trespass
  531. * command would use the parameters.
  532. */
  533. if (csdev->lun_state != CLARIION_LUN_OWNED)
  534. goto done;
  535. csdev->lun_state = CLARIION_LUN_UNINITIALIZED;
  536. result = send_trespass_cmd(sdev, csdev);
  537. if (result != SCSI_DH_OK)
  538. goto done;
  539. /* Update status */
  540. result = clariion_send_inquiry(sdev, csdev);
  541. done:
  542. return result;
  543. }
  544. static int clariion_bus_attach(struct scsi_device *sdev)
  545. {
  546. struct clariion_dh_data *h;
  547. int err;
  548. h = kzalloc(sizeof(*h) , GFP_KERNEL);
  549. if (!h)
  550. return -ENOMEM;
  551. h->lun_state = CLARIION_LUN_UNINITIALIZED;
  552. h->default_sp = CLARIION_UNBOUND_LU;
  553. h->current_sp = CLARIION_UNBOUND_LU;
  554. err = clariion_std_inquiry(sdev, h);
  555. if (err != SCSI_DH_OK)
  556. goto failed;
  557. err = clariion_send_inquiry(sdev, h);
  558. if (err != SCSI_DH_OK)
  559. goto failed;
  560. sdev_printk(KERN_INFO, sdev,
  561. "%s: connected to SP %c Port %d (%s, default SP %c)\n",
  562. CLARIION_NAME, h->current_sp + 'A',
  563. h->port, lun_state[h->lun_state],
  564. h->default_sp + 'A');
  565. sdev->handler_data = h;
  566. return 0;
  567. failed:
  568. kfree(h);
  569. return -EINVAL;
  570. }
  571. static void clariion_bus_detach(struct scsi_device *sdev)
  572. {
  573. kfree(sdev->handler_data);
  574. sdev->handler_data = NULL;
  575. }
  576. static struct scsi_device_handler clariion_dh = {
  577. .name = CLARIION_NAME,
  578. .module = THIS_MODULE,
  579. .attach = clariion_bus_attach,
  580. .detach = clariion_bus_detach,
  581. .check_sense = clariion_check_sense,
  582. .activate = clariion_activate,
  583. .prep_fn = clariion_prep_fn,
  584. .set_params = clariion_set_params,
  585. };
  586. static int __init clariion_init(void)
  587. {
  588. int r;
  589. r = scsi_register_device_handler(&clariion_dh);
  590. if (r != 0)
  591. printk(KERN_ERR "%s: Failed to register scsi device handler.",
  592. CLARIION_NAME);
  593. return r;
  594. }
  595. static void __exit clariion_exit(void)
  596. {
  597. scsi_unregister_device_handler(&clariion_dh);
  598. }
  599. module_init(clariion_init);
  600. module_exit(clariion_exit);
  601. MODULE_DESCRIPTION("EMC CX/AX/FC-family driver");
  602. MODULE_AUTHOR("Mike Christie <michaelc@cs.wisc.edu>, Chandra Seetharaman <sekharan@us.ibm.com>");
  603. MODULE_LICENSE("GPL");