Deleted Added
sdiff udiff text old ( 292715 ) new ( 292725 )
full compact
1/*-
2 * Copyright (c) 1997-2009 by Matthew Jacob
3 * All rights reserved.
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 *

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

30 */
31#ifdef __NetBSD__
32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD$");
34#include <dev/ic/isp_netbsd.h>
35#endif
36#ifdef __FreeBSD__
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sys/dev/isp/isp_library.c 292725 2015-12-25 13:03:18Z mav $");
39#include <dev/isp/isp_freebsd.h>
40#endif
41#ifdef __OpenBSD__
42#include <dev/ic/isp_openbsd.h>
43#endif
44#ifdef __linux__
45#include "isp_linux.h"
46#endif

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

242 }
243 if (isp->isp_dblev & ISP_LOGDEBUG1) {
244 isp_print_bytes(isp, "first queue entry", QENTRY_LEN, fqe);
245 }
246 ISP_ADD_REQUEST(isp, nxt);
247 return (CMD_QUEUED);
248}
249
250uint32_t
251isp_allocate_handle(ispsoftc_t *isp, void *xs, int type)
252{
253 isp_hdl_t *hdp;
254
255 hdp = isp->isp_xffree;
256 if (hdp == NULL)
257 return (ISP_HANDLE_FREE);
258 isp->isp_xffree = hdp->cmd;
259 hdp->cmd = xs;
260 hdp->handle = (hdp - isp->isp_xflist);
261 hdp->handle |= (type << ISP_HANDLE_USAGE_SHIFT);
262 hdp->handle |= (isp->isp_seqno++ << ISP_HANDLE_SEQ_SHIFT);
263 return (hdp->handle);
264}
265
266void *
267isp_find_xs(ispsoftc_t *isp, uint32_t handle)
268{
269 if (!ISP_VALID_HANDLE(isp, handle)) {
270 isp_prt(isp, ISP_LOGERR, "%s: bad handle 0x%x", __func__, handle);
271 return (NULL);
272 }
273 return (isp->isp_xflist[(handle & ISP_HANDLE_CMD_MASK)].cmd);
274}
275
276uint32_t
277isp_find_handle(ispsoftc_t *isp, void *xs)
278{
279 uint32_t i, foundhdl = ISP_HANDLE_FREE;
280
281 if (xs != NULL) {
282 for (i = 0; i < isp->isp_maxcmds; i++) {
283 if (isp->isp_xflist[i].cmd != xs) {
284 continue;
285 }
286 foundhdl = isp->isp_xflist[i].handle;
287 break;
288 }
289 }
290 return (foundhdl);
291}
292
293void
294isp_destroy_handle(ispsoftc_t *isp, uint32_t handle)
295{
296 if (!ISP_VALID_HANDLE(isp, handle)) {
297 isp_prt(isp, ISP_LOGERR, "%s: bad handle 0x%x", __func__, handle);
298 } else {
299 isp->isp_xflist[(handle & ISP_HANDLE_CMD_MASK)].handle = ISP_HANDLE_FREE;
300 isp->isp_xflist[(handle & ISP_HANDLE_CMD_MASK)].cmd = isp->isp_xffree;
301 isp->isp_xffree = &isp->isp_xflist[(handle & ISP_HANDLE_CMD_MASK)];
302 }
303}
304

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

565{
566 uint32_t tmp;
567 isp_hdl_t *hdp;
568#ifdef ISP_TARGET_MODE
569 isp_notify_t notify;
570#endif
571
572 for (tmp = 0; isp->isp_xflist && tmp < isp->isp_maxcmds; tmp++) {
573
574 hdp = &isp->isp_xflist[tmp];
575 if (ISP_H2HT(hdp->handle) == ISP_HANDLE_INITIATOR) {
576 XS_T *xs = hdp->cmd;
577 if (XS_XFRLEN(xs)) {
578 ISP_DMAFREE(isp, xs, hdp->handle);
579 XS_SET_RESID(xs, XS_XFRLEN(xs));
580 } else {
581 XS_SET_RESID(xs, 0);
582 }
583 hdp->handle = 0;
584 hdp->cmd = NULL;
585 XS_SETERR(xs, HBA_BUSRESET);
586 isp_done(xs);
587#ifdef ISP_TARGET_MODE
588 } else if (ISP_H2HT(hdp->handle) == ISP_HANDLE_TARGET) {
589 uint8_t local[QENTRY_LEN];
590 ISP_DMAFREE(isp, hdp->cmd, hdp->handle);
591 ISP_MEMZERO(local, QENTRY_LEN);
592 if (IS_24XX(isp)) {
593 ct7_entry_t *ctio = (ct7_entry_t *) local;
594 ctio->ct_syshandle = hdp->handle;
595 ctio->ct_nphdl = CT_HBA_RESET;
596 ctio->ct_header.rqs_entry_type = RQSTYPE_CTIO7;
597 } else {
598 ct2_entry_t *ctio = (ct2_entry_t *) local;
599 ctio->ct_syshandle = hdp->handle;
600 ctio->ct_status = CT_HBA_RESET;
601 ctio->ct_header.rqs_entry_type = RQSTYPE_CTIO2;
602 }
603 isp_async(isp, ISPASYNC_TARGET_ACTION, local);
604#endif
605 }
606 }
607#ifdef ISP_TARGET_MODE
608 for (tmp = 0; tmp < isp->isp_nchan; tmp++) {
609 ISP_MEMZERO(&notify, sizeof (isp_notify_t));
610 notify.nt_ncode = NT_HBA_RESET;
611 notify.nt_hba = isp;
612 notify.nt_wwn = INI_ANY;
613 notify.nt_nphdl = NIL_HANDLE;
614 notify.nt_sid = PORT_ANY;
615 notify.nt_did = PORT_ANY;

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

2200 }
2201 if (isp->isp_dblev & ISP_LOGTDEBUG1) {
2202 isp_print_bytes(isp, "first queue entry", QENTRY_LEN, fqe);
2203 }
2204 ISP_ADD_REQUEST(isp, nxt);
2205 return (CMD_QUEUED);
2206}
2207
2208#endif
2209
2210/*
2211 * Find port database entries
2212 */
2213int
2214isp_find_pdb_empty(ispsoftc_t *isp, int chan, fcportdb_t **lptr)
2215{

--- 1295 unchanged lines hidden ---