sbp_targ.c (271795) | sbp_targ.c (272214) |
---|---|
1/*- 2 * Copyright (C) 2003 3 * Hidetoshi Shimokawa. All rights reserved. | 1/*- 2 * Copyright (C) 2003 3 * Hidetoshi Shimokawa. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * 16 * This product includes software developed by Hidetoshi Shimokawa. 17 * 18 * 4. Neither the name of the author nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. | 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * 16 * This product includes software developed by Hidetoshi Shimokawa. 17 * 18 * 4. Neither the name of the author nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. |
21 * | 21 * |
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. | 22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. |
33 * 34 * $FreeBSD: head/sys/dev/firewire/sbp_targ.c 271795 2014-09-18 17:28:21Z will $ | 33 * 34 * $FreeBSD: head/sys/dev/firewire/sbp_targ.c 272214 2014-09-27 16:50:21Z kan $ |
35 */ 36 37#include <sys/param.h> 38#include <sys/kernel.h> 39#include <sys/systm.h> 40#include <sys/sysctl.h> 41#include <sys/types.h> 42#include <sys/conf.h> --- 56 unchanged lines hidden (view full) --- 99 100SYSCTL_INT(_debug, OID_AUTO, sbp_targ_debug, CTLFLAG_RW, &debug, 0, 101 "SBP target mode debug flag"); 102 103struct sbp_targ_login { 104 struct sbp_targ_lstate *lstate; 105 struct fw_device *fwdev; 106 struct sbp_login_res loginres; | 35 */ 36 37#include <sys/param.h> 38#include <sys/kernel.h> 39#include <sys/systm.h> 40#include <sys/sysctl.h> 41#include <sys/types.h> 42#include <sys/conf.h> --- 56 unchanged lines hidden (view full) --- 99 100SYSCTL_INT(_debug, OID_AUTO, sbp_targ_debug, CTLFLAG_RW, &debug, 0, 101 "SBP target mode debug flag"); 102 103struct sbp_targ_login { 104 struct sbp_targ_lstate *lstate; 105 struct fw_device *fwdev; 106 struct sbp_login_res loginres; |
107 uint16_t fifo_hi; | 107 uint16_t fifo_hi; |
108 uint16_t last_hi; | 108 uint16_t last_hi; |
109 uint32_t fifo_lo; | 109 uint32_t fifo_lo; |
110 uint32_t last_lo; 111 STAILQ_HEAD(, orb_info) orbs; 112 STAILQ_ENTRY(sbp_targ_login) link; 113 uint16_t hold_sec; 114 uint16_t id; | 110 uint32_t last_lo; 111 STAILQ_HEAD(, orb_info) orbs; 112 STAILQ_ENTRY(sbp_targ_login) link; 113 uint16_t hold_sec; 114 uint16_t id; |
115 uint8_t flags; 116 uint8_t spd; | 115 uint8_t flags; 116 uint8_t spd; |
117 struct callout hold_callout; 118}; 119 120struct sbp_targ_lstate { 121 uint16_t lun; 122 struct sbp_targ_softc *sc; 123 struct cam_path *path; 124 struct ccb_hdr_slist accept_tios; 125 struct ccb_hdr_slist immed_notifies; 126 struct crom_chunk model; | 117 struct callout hold_callout; 118}; 119 120struct sbp_targ_lstate { 121 uint16_t lun; 122 struct sbp_targ_softc *sc; 123 struct cam_path *path; 124 struct ccb_hdr_slist accept_tios; 125 struct ccb_hdr_slist immed_notifies; 126 struct crom_chunk model; |
127 uint32_t flags; | 127 uint32_t flags; |
128 STAILQ_HEAD(, sbp_targ_login) logins; 129}; 130 131struct sbp_targ_softc { 132 struct firewire_dev_comm fd; 133 struct cam_sim *sim; 134 struct cam_path *path; 135 struct fw_bind fwb; --- 64 unchanged lines hidden (view full) --- 200 201 202struct orb_info { 203 struct sbp_targ_softc *sc; 204 struct fw_device *fwdev; 205 struct sbp_targ_login *login; 206 union ccb *ccb; 207 struct ccb_accept_tio *atio; | 128 STAILQ_HEAD(, sbp_targ_login) logins; 129}; 130 131struct sbp_targ_softc { 132 struct firewire_dev_comm fd; 133 struct cam_sim *sim; 134 struct cam_path *path; 135 struct fw_bind fwb; --- 64 unchanged lines hidden (view full) --- 200 201 202struct orb_info { 203 struct sbp_targ_softc *sc; 204 struct fw_device *fwdev; 205 struct sbp_targ_login *login; 206 union ccb *ccb; 207 struct ccb_accept_tio *atio; |
208 uint8_t state; | 208 uint8_t state; |
209#define ORBI_STATUS_NONE 0 210#define ORBI_STATUS_FETCH 1 211#define ORBI_STATUS_ATIO 2 212#define ORBI_STATUS_CTIO 3 213#define ORBI_STATUS_STATUS 4 214#define ORBI_STATUS_POINTER 5 215#define ORBI_STATUS_ABORTED 7 | 209#define ORBI_STATUS_NONE 0 210#define ORBI_STATUS_FETCH 1 211#define ORBI_STATUS_ATIO 2 212#define ORBI_STATUS_CTIO 3 213#define ORBI_STATUS_STATUS 4 214#define ORBI_STATUS_POINTER 5 215#define ORBI_STATUS_ABORTED 7 |
216 uint8_t refcount; | 216 uint8_t refcount; |
217 uint16_t orb_hi; 218 uint32_t orb_lo; 219 uint32_t data_hi; 220 uint32_t data_lo; 221 struct corb4 orb4; 222 STAILQ_ENTRY(orb_info) link; 223 uint32_t orb[8]; 224 struct unrestricted_page_table_fmt *page_table; --- 20 unchanged lines hidden (view full) --- 245} 246 247static int 248sbp_targ_probe(device_t dev) 249{ 250 device_t pa; 251 252 pa = device_get_parent(dev); | 217 uint16_t orb_hi; 218 uint32_t orb_lo; 219 uint32_t data_hi; 220 uint32_t data_lo; 221 struct corb4 orb4; 222 STAILQ_ENTRY(orb_info) link; 223 uint32_t orb[8]; 224 struct unrestricted_page_table_fmt *page_table; --- 20 unchanged lines hidden (view full) --- 245} 246 247static int 248sbp_targ_probe(device_t dev) 249{ 250 device_t pa; 251 252 pa = device_get_parent(dev); |
253 if(device_get_unit(dev) != device_get_unit(pa)){ 254 return(ENXIO); | 253 if (device_get_unit(dev) != device_get_unit(pa)) { 254 return (ENXIO); |
255 } 256 257 device_set_desc(dev, "SBP-2/SCSI over FireWire target mode"); 258 return (0); 259} 260 261static void 262sbp_targ_dealloc_login(struct sbp_targ_login *login) --- 68 unchanged lines hidden (view full) --- 331 crom_add_entry(unit, CSRKEY_SPEC, CSRVAL_ANSIT10); 332 crom_add_entry(unit, CSRKEY_VER, CSRVAL_T10SBP2); 333 crom_add_entry(unit, CSRKEY_COM_SPEC, CSRVAL_ANSIT10); 334 crom_add_entry(unit, CSRKEY_COM_SET, CSRVAL_SCSI); 335 336 crom_add_entry(unit, CROM_MGM, SBP_TARG_MGM >> 2); 337 crom_add_entry(unit, CSRKEY_UNIT_CH, (10<<8) | 8); 338 | 255 } 256 257 device_set_desc(dev, "SBP-2/SCSI over FireWire target mode"); 258 return (0); 259} 260 261static void 262sbp_targ_dealloc_login(struct sbp_targ_login *login) --- 68 unchanged lines hidden (view full) --- 331 crom_add_entry(unit, CSRKEY_SPEC, CSRVAL_ANSIT10); 332 crom_add_entry(unit, CSRKEY_VER, CSRVAL_T10SBP2); 333 crom_add_entry(unit, CSRKEY_COM_SPEC, CSRVAL_ANSIT10); 334 crom_add_entry(unit, CSRKEY_COM_SET, CSRVAL_SCSI); 335 336 crom_add_entry(unit, CROM_MGM, SBP_TARG_MGM >> 2); 337 crom_add_entry(unit, CSRKEY_UNIT_CH, (10<<8) | 8); 338 |
339 for (i = 0; i < MAX_LUN; i ++) { | 339 for (i = 0; i < MAX_LUN; i++) { |
340 lstate = sc->lstate[i]; 341 if (lstate == NULL) 342 continue; 343 crom_add_entry(unit, CSRKEY_FIRM_VER, 1); 344 crom_add_entry(unit, CROM_LUN, i); 345 crom_add_entry(unit, CSRKEY_MODEL, 1); 346 crom_add_simple_text(src, unit, &lstate->model, "TargetMode"); 347 } 348 349 /* Process for reconnection hold time */ | 340 lstate = sc->lstate[i]; 341 if (lstate == NULL) 342 continue; 343 crom_add_entry(unit, CSRKEY_FIRM_VER, 1); 344 crom_add_entry(unit, CROM_LUN, i); 345 crom_add_entry(unit, CSRKEY_MODEL, 1); 346 crom_add_simple_text(src, unit, &lstate->model, "TargetMode"); 347 } 348 349 /* Process for reconnection hold time */ |
350 for (i = 0; i < MAX_LOGINS; i ++) { | 350 for (i = 0; i < MAX_LOGINS; i++) { |
351 login = sc->logins[i]; 352 if (login == NULL) 353 continue; 354 sbp_targ_abort(sc, STAILQ_FIRST(&login->orbs)); 355 if (login->flags & F_LOGIN) { 356 login->flags |= F_HOLD; 357 callout_reset(&login->hold_callout, | 351 login = sc->logins[i]; 352 if (login == NULL) 353 continue; 354 sbp_targ_abort(sc, STAILQ_FIRST(&login->orbs)); 355 if (login->flags & F_LOGIN) { 356 login->flags |= F_HOLD; 357 callout_reset(&login->hold_callout, |
358 hz * login->hold_sec, | 358 hz * login->hold_sec, |
359 sbp_targ_hold_expire, (void *)login); 360 } 361 } 362} 363 364static void 365sbp_targ_post_explore(void *arg) 366{ --- 20 unchanged lines hidden (view full) --- 387 if (debug) 388 printf("setting black hole for this target id(%d)\n", ccb->ccb_h.target_id); 389 return (CAM_REQ_CMP); 390 } 391 392 lun = ccb->ccb_h.target_lun; 393 if (lun >= MAX_LUN) 394 return (CAM_LUN_INVALID); | 359 sbp_targ_hold_expire, (void *)login); 360 } 361 } 362} 363 364static void 365sbp_targ_post_explore(void *arg) 366{ --- 20 unchanged lines hidden (view full) --- 387 if (debug) 388 printf("setting black hole for this target id(%d)\n", ccb->ccb_h.target_id); 389 return (CAM_REQ_CMP); 390 } 391 392 lun = ccb->ccb_h.target_lun; 393 if (lun >= MAX_LUN) 394 return (CAM_LUN_INVALID); |
395 | 395 |
396 *lstate = sc->lstate[lun]; 397 398 if (notfound_failure != 0 && *lstate == NULL) { 399 if (debug) 400 printf("%s: lstate for lun is invalid, target(%d), lun(%d)\n", 401 __func__, ccb->ccb_h.target_id, lun); 402 return (CAM_PATH_INVALID); 403 } else --- 431 unchanged lines hidden (view full) --- 835 if (xfer->resp != 0) { 836 printf("%s: xfer->resp = %d\n", __func__, xfer->resp); 837 orbi->status.resp = SBP_TRANS_FAIL; 838 orbi->status.status = OBJ_DATA | SBE_TIMEOUT/*XXX*/; 839 orbi->status.dead = 1; 840 sbp_targ_abort(orbi->sc, STAILQ_NEXT(orbi, link)); 841 } 842 | 396 *lstate = sc->lstate[lun]; 397 398 if (notfound_failure != 0 && *lstate == NULL) { 399 if (debug) 400 printf("%s: lstate for lun is invalid, target(%d), lun(%d)\n", 401 __func__, ccb->ccb_h.target_id, lun); 402 return (CAM_PATH_INVALID); 403 } else --- 431 unchanged lines hidden (view full) --- 835 if (xfer->resp != 0) { 836 printf("%s: xfer->resp = %d\n", __func__, xfer->resp); 837 orbi->status.resp = SBP_TRANS_FAIL; 838 orbi->status.status = OBJ_DATA | SBE_TIMEOUT/*XXX*/; 839 orbi->status.dead = 1; 840 sbp_targ_abort(orbi->sc, STAILQ_NEXT(orbi, link)); 841 } 842 |
843 orbi->refcount --; | 843 orbi->refcount--; |
844 845 ccb = orbi->ccb; 846 if (orbi->refcount == 0) { 847 orbi->ccb = NULL; 848 if (orbi->state == ORBI_STATUS_ABORTED) { 849 if (debug) 850 printf("%s: orbi aborted\n", __func__); 851 sbp_targ_remove_orb_info(orbi->login, orbi); --- 59 unchanged lines hidden (view full) --- 911 return (CAM_UA_ABORT); 912 913 curelm = SLIST_FIRST(list); 914 found = 0; 915 if (curelm == &accb->ccb_h) { 916 found = 1; 917 SLIST_REMOVE_HEAD(list, sim_links.sle); 918 } else { | 844 845 ccb = orbi->ccb; 846 if (orbi->refcount == 0) { 847 orbi->ccb = NULL; 848 if (orbi->state == ORBI_STATUS_ABORTED) { 849 if (debug) 850 printf("%s: orbi aborted\n", __func__); 851 sbp_targ_remove_orb_info(orbi->login, orbi); --- 59 unchanged lines hidden (view full) --- 911 return (CAM_UA_ABORT); 912 913 curelm = SLIST_FIRST(list); 914 found = 0; 915 if (curelm == &accb->ccb_h) { 916 found = 1; 917 SLIST_REMOVE_HEAD(list, sim_links.sle); 918 } else { |
919 while(curelm != NULL) { | 919 while (curelm != NULL) { |
920 struct ccb_hdr *nextelm; 921 922 nextelm = SLIST_NEXT(curelm, sim_links.sle); 923 if (nextelm == &accb->ccb_h) { 924 found = 1; 925 SLIST_NEXT(curelm, sim_links.sle) = 926 SLIST_NEXT(nextelm, sim_links.sle); 927 break; --- 49 unchanged lines hidden (view full) --- 977 xfer = fwmem_write_block(orbi->fwdev, 978 (void *)orbi, /*spd*/FWSPD_S400, 979 dst_hi, dst_lo + off, len, 980 ptr + off, hand); 981 } 982 if (xfer == NULL) { 983 printf("%s: xfer == NULL", __func__); 984 /* XXX what should we do?? */ | 920 struct ccb_hdr *nextelm; 921 922 nextelm = SLIST_NEXT(curelm, sim_links.sle); 923 if (nextelm == &accb->ccb_h) { 924 found = 1; 925 SLIST_NEXT(curelm, sim_links.sle) = 926 SLIST_NEXT(nextelm, sim_links.sle); 927 break; --- 49 unchanged lines hidden (view full) --- 977 xfer = fwmem_write_block(orbi->fwdev, 978 (void *)orbi, /*spd*/FWSPD_S400, 979 dst_hi, dst_lo + off, len, 980 ptr + off, hand); 981 } 982 if (xfer == NULL) { 983 printf("%s: xfer == NULL", __func__); 984 /* XXX what should we do?? */ |
985 orbi->refcount --; | 985 orbi->refcount--; |
986 } 987 off += len; 988 } 989} 990 991static void 992sbp_targ_pt_done(struct fw_xfer *xfer) 993{ --- 355 unchanged lines hidden (view full) --- 1349 case XPT_IMMEDIATE_NOTIFY: 1350 ccb->ccb_h.status = sbp_targ_abort_ccb(sc, ccb); 1351 break; 1352 case XPT_CONT_TARGET_IO: 1353 /* XXX */ 1354 ccb->ccb_h.status = CAM_UA_ABORT; 1355 break; 1356 default: | 986 } 987 off += len; 988 } 989} 990 991static void 992sbp_targ_pt_done(struct fw_xfer *xfer) 993{ --- 355 unchanged lines hidden (view full) --- 1349 case XPT_IMMEDIATE_NOTIFY: 1350 ccb->ccb_h.status = sbp_targ_abort_ccb(sc, ccb); 1351 break; 1352 case XPT_CONT_TARGET_IO: 1353 /* XXX */ 1354 ccb->ccb_h.status = CAM_UA_ABORT; 1355 break; 1356 default: |
1357 printf("%s: aborting unknown function %d\n", | 1357 printf("%s: aborting unknown function %d\n", |
1358 __func__, accb->ccb_h.func_code); 1359 ccb->ccb_h.status = CAM_REQ_INVALID; 1360 break; 1361 } 1362 xpt_done(ccb); 1363 break; 1364 } 1365#ifdef CAM_NEW_TRAN_CODE --- 93 unchanged lines hidden (view full) --- 1459 xpt_done((union ccb*)atio); 1460 SBP_UNLOCK(orbi->sc); 1461 goto done0; 1462 } 1463 orbi->state = ORBI_STATUS_ATIO; 1464 1465 orb = orbi->orb; 1466 /* swap payload except SCSI command */ | 1358 __func__, accb->ccb_h.func_code); 1359 ccb->ccb_h.status = CAM_REQ_INVALID; 1360 break; 1361 } 1362 xpt_done(ccb); 1363 break; 1364 } 1365#ifdef CAM_NEW_TRAN_CODE --- 93 unchanged lines hidden (view full) --- 1459 xpt_done((union ccb*)atio); 1460 SBP_UNLOCK(orbi->sc); 1461 goto done0; 1462 } 1463 orbi->state = ORBI_STATUS_ATIO; 1464 1465 orb = orbi->orb; 1466 /* swap payload except SCSI command */ |
1467 for (i = 0; i < 5; i ++) | 1467 for (i = 0; i < 5; i++) |
1468 orb[i] = ntohl(orb[i]); 1469 1470 orb4 = (struct corb4 *)&orb[4]; 1471 if (orb4->rq_fmt != 0) { 1472 /* XXX */ 1473 printf("%s: rq_fmt(%d) != 0\n", __func__, orb4->rq_fmt); 1474 } 1475 --- 64 unchanged lines hidden (view full) --- 1540static struct sbp_targ_login * 1541sbp_targ_get_login(struct sbp_targ_softc *sc, struct fw_device *fwdev, int lun) 1542{ 1543 struct sbp_targ_lstate *lstate; 1544 struct sbp_targ_login *login; 1545 int i; 1546 1547 lstate = sc->lstate[lun]; | 1468 orb[i] = ntohl(orb[i]); 1469 1470 orb4 = (struct corb4 *)&orb[4]; 1471 if (orb4->rq_fmt != 0) { 1472 /* XXX */ 1473 printf("%s: rq_fmt(%d) != 0\n", __func__, orb4->rq_fmt); 1474 } 1475 --- 64 unchanged lines hidden (view full) --- 1540static struct sbp_targ_login * 1541sbp_targ_get_login(struct sbp_targ_softc *sc, struct fw_device *fwdev, int lun) 1542{ 1543 struct sbp_targ_lstate *lstate; 1544 struct sbp_targ_login *login; 1545 int i; 1546 1547 lstate = sc->lstate[lun]; |
1548 | 1548 |
1549 STAILQ_FOREACH(login, &lstate->logins, link) 1550 if (login->fwdev == fwdev) 1551 return (login); 1552 | 1549 STAILQ_FOREACH(login, &lstate->logins, link) 1550 if (login->fwdev == fwdev) 1551 return (login); 1552 |
1553 for (i = 0; i < MAX_LOGINS; i ++) | 1553 for (i = 0; i < MAX_LOGINS; i++) |
1554 if (sc->logins[i] == NULL) 1555 goto found; 1556 1557 printf("%s: increase MAX_LOGIN\n", __func__); 1558 return (NULL); 1559 1560found: 1561 login = (struct sbp_targ_login *)malloc( --- 40 unchanged lines hidden (view full) --- 1602 orbi->login->fifo_hi, orbi->login->fifo_lo, /*dequeue*/0); 1603 fw_xfer_free(xfer); 1604 return; 1605 } 1606 fp = &xfer->recv.hdr; 1607 1608 orb = orbi->orb; 1609 /* swap payload */ | 1554 if (sc->logins[i] == NULL) 1555 goto found; 1556 1557 printf("%s: increase MAX_LOGIN\n", __func__); 1558 return (NULL); 1559 1560found: 1561 login = (struct sbp_targ_login *)malloc( --- 40 unchanged lines hidden (view full) --- 1602 orbi->login->fifo_hi, orbi->login->fifo_lo, /*dequeue*/0); 1603 fw_xfer_free(xfer); 1604 return; 1605 } 1606 fp = &xfer->recv.hdr; 1607 1608 orb = orbi->orb; 1609 /* swap payload */ |
1610 for (i = 0; i < 8; i ++) { | 1610 for (i = 0; i < 8; i++) { |
1611 orb[i] = ntohl(orb[i]); 1612 } 1613 orb4 = (struct morb4 *)&orb[4]; 1614 if (debug) 1615 printf("%s: %s\n", __func__, orb_fun_name[orb4->fun]); 1616 1617 orbi->status.src = SRC_NO_NEXT; 1618 --- 4 unchanged lines hidden (view full) --- 1623 1624 if (orb[4] & ORB_EXV) 1625 exclusive = 1; 1626 1627 lun = orb4->id; 1628 lstate = orbi->sc->lstate[lun]; 1629 1630 if (lun >= MAX_LUN || lstate == NULL || | 1611 orb[i] = ntohl(orb[i]); 1612 } 1613 orb4 = (struct morb4 *)&orb[4]; 1614 if (debug) 1615 printf("%s: %s\n", __func__, orb_fun_name[orb4->fun]); 1616 1617 orbi->status.src = SRC_NO_NEXT; 1618 --- 4 unchanged lines hidden (view full) --- 1623 1624 if (orb[4] & ORB_EXV) 1625 exclusive = 1; 1626 1627 lun = orb4->id; 1628 lstate = orbi->sc->lstate[lun]; 1629 1630 if (lun >= MAX_LUN || lstate == NULL || |
1631 (exclusive && | 1631 (exclusive && |
1632 STAILQ_FIRST(&lstate->logins) != NULL && 1633 STAILQ_FIRST(&lstate->logins)->fwdev != orbi->fwdev) | 1632 STAILQ_FIRST(&lstate->logins) != NULL && 1633 STAILQ_FIRST(&lstate->logins)->fwdev != orbi->fwdev) |
1634 ) { | 1634 ) { |
1635 /* error */ 1636 orbi->status.dead = 1; 1637 orbi->status.status = STATUS_ACCESS_DENY; 1638 orbi->status.len = 1; 1639 break; 1640 } 1641 1642 /* allocate login */ --- 171 unchanged lines hidden (view full) --- 1814sbp_targ_cmd(struct fw_xfer *xfer, struct fw_device *fwdev, int login_id, 1815 int reg) 1816{ 1817 struct sbp_targ_login *login; 1818 struct sbp_targ_softc *sc; 1819 int rtcode = 0; 1820 1821 if (login_id < 0 || login_id >= MAX_LOGINS) | 1635 /* error */ 1636 orbi->status.dead = 1; 1637 orbi->status.status = STATUS_ACCESS_DENY; 1638 orbi->status.len = 1; 1639 break; 1640 } 1641 1642 /* allocate login */ --- 171 unchanged lines hidden (view full) --- 1814sbp_targ_cmd(struct fw_xfer *xfer, struct fw_device *fwdev, int login_id, 1815 int reg) 1816{ 1817 struct sbp_targ_login *login; 1818 struct sbp_targ_softc *sc; 1819 int rtcode = 0; 1820 1821 if (login_id < 0 || login_id >= MAX_LOGINS) |
1822 return(RESP_ADDRESS_ERROR); | 1822 return (RESP_ADDRESS_ERROR); |
1823 1824 sc = (struct sbp_targ_softc *)xfer->sc; 1825 login = sc->logins[login_id]; 1826 if (login == NULL) | 1823 1824 sc = (struct sbp_targ_softc *)xfer->sc; 1825 login = sc->logins[login_id]; 1826 if (login == NULL) |
1827 return(RESP_ADDRESS_ERROR); | 1827 return (RESP_ADDRESS_ERROR); |
1828 1829 if (login->fwdev != fwdev) { 1830 /* XXX */ | 1828 1829 if (login->fwdev != fwdev) { 1830 /* XXX */ |
1831 return(RESP_ADDRESS_ERROR); | 1831 return (RESP_ADDRESS_ERROR); |
1832 } 1833 1834 switch (reg) { 1835 case 0x08: /* ORB_POINTER */ 1836 if (debug) 1837 printf("%s: ORB_POINTER(%d)\n", __func__, login_id); 1838 if ((login->flags & F_LINK_ACTIVE) != 0) { 1839 if (debug) --- 50 unchanged lines hidden (view full) --- 1890sbp_targ_mgm(struct fw_xfer *xfer, struct fw_device *fwdev) 1891{ 1892 struct sbp_targ_softc *sc; 1893 struct fw_pkt *fp; 1894 1895 sc = (struct sbp_targ_softc *)xfer->sc; 1896 1897 fp = &xfer->recv.hdr; | 1832 } 1833 1834 switch (reg) { 1835 case 0x08: /* ORB_POINTER */ 1836 if (debug) 1837 printf("%s: ORB_POINTER(%d)\n", __func__, login_id); 1838 if ((login->flags & F_LINK_ACTIVE) != 0) { 1839 if (debug) --- 50 unchanged lines hidden (view full) --- 1890sbp_targ_mgm(struct fw_xfer *xfer, struct fw_device *fwdev) 1891{ 1892 struct sbp_targ_softc *sc; 1893 struct fw_pkt *fp; 1894 1895 sc = (struct sbp_targ_softc *)xfer->sc; 1896 1897 fp = &xfer->recv.hdr; |
1898 if (fp->mode.wreqb.tcode != FWTCODE_WREQB){ | 1898 if (fp->mode.wreqb.tcode != FWTCODE_WREQB) { |
1899 printf("%s: tcode = %d\n", __func__, fp->mode.wreqb.tcode); | 1899 printf("%s: tcode = %d\n", __func__, fp->mode.wreqb.tcode); |
1900 return(RESP_TYPE_ERROR); | 1900 return (RESP_TYPE_ERROR); |
1901 } 1902 1903 sbp_targ_fetch_orb(sc, fwdev, 1904 ntohl(xfer->recv.payload[0]), 1905 ntohl(xfer->recv.payload[1]), 1906 NULL, FETCH_MGM); | 1901 } 1902 1903 sbp_targ_fetch_orb(sc, fwdev, 1904 ntohl(xfer->recv.payload[0]), 1905 ntohl(xfer->recv.payload[1]), 1906 NULL, FETCH_MGM); |
1907 1908 return(0); | 1907 1908 return (0); |
1909} 1910 1911static void 1912sbp_targ_recv(struct fw_xfer *xfer) 1913{ 1914 struct fw_pkt *fp, *sfp; 1915 struct fw_device *fwdev; 1916 uint32_t lo; --- 101 unchanged lines hidden (view full) --- 2018 2019 sc = (struct sbp_targ_softc *)device_get_softc(dev); 2020 sc->fd.post_busreset = NULL; 2021 2022 SBP_LOCK(sc); 2023 xpt_free_path(sc->path); 2024 xpt_bus_deregister(cam_sim_path(sc->sim)); 2025 SBP_UNLOCK(sc); | 1909} 1910 1911static void 1912sbp_targ_recv(struct fw_xfer *xfer) 1913{ 1914 struct fw_pkt *fp, *sfp; 1915 struct fw_device *fwdev; 1916 uint32_t lo; --- 101 unchanged lines hidden (view full) --- 2018 2019 sc = (struct sbp_targ_softc *)device_get_softc(dev); 2020 sc->fd.post_busreset = NULL; 2021 2022 SBP_LOCK(sc); 2023 xpt_free_path(sc->path); 2024 xpt_bus_deregister(cam_sim_path(sc->sim)); 2025 SBP_UNLOCK(sc); |
2026 cam_sim_free(sc->sim, /*free_devq*/TRUE); | 2026 cam_sim_free(sc->sim, /*free_devq*/TRUE); |
2027 | 2027 |
2028 for (i = 0; i < MAX_LUN; i ++) { | 2028 for (i = 0; i < MAX_LUN; i++) { |
2029 lstate = sc->lstate[i]; 2030 if (lstate != NULL) { 2031 xpt_free_path(lstate->path); 2032 free(lstate, M_SBP_TARG); 2033 } 2034 } 2035 if (sc->black_hole != NULL) { 2036 xpt_free_path(sc->black_hole->path); 2037 free(sc->black_hole, M_SBP_TARG); 2038 } | 2029 lstate = sc->lstate[i]; 2030 if (lstate != NULL) { 2031 xpt_free_path(lstate->path); 2032 free(lstate, M_SBP_TARG); 2033 } 2034 } 2035 if (sc->black_hole != NULL) { 2036 xpt_free_path(sc->black_hole->path); 2037 free(sc->black_hole, M_SBP_TARG); 2038 } |
2039 | 2039 |
2040 fw_bindremove(sc->fd.fc, &sc->fwb); 2041 fw_xferlist_remove(&sc->fwb.xferlist); 2042 2043 mtx_destroy(&sc->mtx); 2044 2045 return 0; 2046} 2047 --- 21 unchanged lines hidden --- | 2040 fw_bindremove(sc->fd.fc, &sc->fwb); 2041 fw_xferlist_remove(&sc->fwb.xferlist); 2042 2043 mtx_destroy(&sc->mtx); 2044 2045 return 0; 2046} 2047 --- 21 unchanged lines hidden --- |