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 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; |
317 uint64_t lunid = UINT64_MAX; |
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); |
324 if (init_port >= 0) |
325 port = softc->ctl_ports[ctl_port_idx(init_port)]; |
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; |
341 } |
342 } 343 mtx_unlock(&softc->ctl_lock); 344 return (lunid); 345}; 346 347union ctl_io * 348tpcl_alloc_io(void) 349{ --- 18 unchanged lines hidden --- |