Deleted Added
full compact
ctl_tpc_local.c (275942) ctl_tpc_local.c (278037)
1/*-
2 * Copyright (c) 2014 Alexander Motin <mav@FreeBSD.org>
3 * Copyright (c) 2004, 2005 Silicon Graphics International Corp.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2014 Alexander Motin <mav@FreeBSD.org>
3 * Copyright (c) 2004, 2005 Silicon Graphics International Corp.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl_tpc_local.c 275942 2014-12-19 20:35:06Z mav $");
29__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl_tpc_local.c 278037 2015-02-01 21:50:28Z mav $");
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/kernel.h>
34#include <sys/types.h>
35#include <sys/lock.h>
36#include <sys/module.h>
37#include <sys/mutex.h>

--- 271 unchanged lines hidden (view full) ---

309
310uint64_t
311tpcl_resolve(struct ctl_softc *softc, int init_port,
312 struct scsi_ec_cscd *cscd, uint32_t *ss)
313{
314 struct scsi_ec_cscd_id *cscdid;
315 struct ctl_port *port;
316 struct ctl_lun *lun;
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/kernel.h>
34#include <sys/types.h>
35#include <sys/lock.h>
36#include <sys/module.h>
37#include <sys/mutex.h>

--- 271 unchanged lines hidden (view full) ---

309
310uint64_t
311tpcl_resolve(struct ctl_softc *softc, int init_port,
312 struct scsi_ec_cscd *cscd, uint32_t *ss)
313{
314 struct scsi_ec_cscd_id *cscdid;
315 struct ctl_port *port;
316 struct ctl_lun *lun;
317 uint64_t lunid = UINT64_MAX, l;
318 int i;
317 uint64_t lunid = UINT64_MAX;
319
320 if (cscd->type_code != EC_CSCD_ID)
321 return (lunid);
322
323 cscdid = (struct scsi_ec_cscd_id *)cscd;
324 mtx_lock(&softc->ctl_lock);
318
319 if (cscd->type_code != EC_CSCD_ID)
320 return (lunid);
321
322 cscdid = (struct scsi_ec_cscd_id *)cscd;
323 mtx_lock(&softc->ctl_lock);
325 if (init_port >= 0) {
324 if (init_port >= 0)
326 port = softc->ctl_ports[ctl_port_idx(init_port)];
325 port = softc->ctl_ports[ctl_port_idx(init_port)];
327 if (port == NULL || port->lun_map == NULL)
328 init_port = -1;
329 }
330 if (init_port < 0) {
331 STAILQ_FOREACH(lun, &softc->lun_list, links) {
332 if (lun->lun_devid == NULL)
333 continue;
334 if (scsi_devid_match(lun->lun_devid->data,
335 lun->lun_devid->len, &cscdid->codeset,
336 cscdid->length + 4) == 0) {
337 lunid = lun->lun;
338 if (ss && lun->be_lun)
339 *ss = lun->be_lun->blocksize;
340 break;
341 }
326 else
327 port = NULL;
328 STAILQ_FOREACH(lun, &softc->lun_list, links) {
329 if (port != NULL &&
330 ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
331 continue;
332 if (lun->lun_devid == NULL)
333 continue;
334 if (scsi_devid_match(lun->lun_devid->data,
335 lun->lun_devid->len, &cscdid->codeset,
336 cscdid->length + 4) == 0) {
337 lunid = lun->lun;
338 if (ss && lun->be_lun)
339 *ss = lun->be_lun->blocksize;
340 break;
342 }
341 }
343 } else {
344 for (i = 0; i < CTL_MAX_LUNS; i++) {
345 l = port->lun_map(port->targ_lun_arg, i);
346 if (l >= CTL_MAX_LUNS)
347 continue;
348 lun = softc->ctl_luns[l];
349 if (lun == NULL || lun->lun_devid == NULL)
350 continue;
351 if (scsi_devid_match(lun->lun_devid->data,
352 lun->lun_devid->len, &cscdid->codeset,
353 cscdid->length + 4) == 0) {
354 lunid = lun->lun;
355 if (ss && lun->be_lun)
356 *ss = lun->be_lun->blocksize;
357 break;
358 }
359 }
360 }
361 mtx_unlock(&softc->ctl_lock);
362 return (lunid);
363};
364
365union ctl_io *
366tpcl_alloc_io(void)
367{

--- 18 unchanged lines hidden ---
342 }
343 mtx_unlock(&softc->ctl_lock);
344 return (lunid);
345};
346
347union ctl_io *
348tpcl_alloc_io(void)
349{

--- 18 unchanged lines hidden ---