⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 isp_inline.h

📁 这个linux源代码是很全面的~基本完整了~使用c编译的~由于时间问题我没有亲自测试~但就算用来做参考资料也是非常好的
💻 H
📖 第 1 页 / 共 4 页
字号:
/* @(#)isp_inline.h 1.15 *//* * Qlogic Host Adapter Inline Functions * * Copyright (c) 1999, 2000, 2001 by Matthew Jacob * Feral Software * All rights reserved. * mjacob@feral.com * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice immediately at the beginning of the file, without modification, *    this list of conditions, and the following disclaimer. * 2. The name of the author may not be used to endorse or promote products *    derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */#ifndef	_ISP_INLINE_H#define	_ISP_INLINE_H/* * Handle Functions. * For each outstanding command there will be a non-zero handle. * There will be at most isp_maxcmds handles, and isp_lasthdls * will be a seed for the last handled allocated. */static INLINE int isp_save_xs(struct ispsoftc *, XS_T *, u_int16_t *);static INLINE XS_T *isp_find_xs(struct ispsoftc *, u_int16_t);static INLINE u_int16_t isp_find_handle(struct ispsoftc *, XS_T *);static INLINE int isp_handle_index(u_int16_t);static INLINE void isp_destroy_handle(struct ispsoftc *, u_int16_t);static INLINE void isp_remove_handle(struct ispsoftc *, XS_T *);static INLINE intisp_save_xs(struct ispsoftc *isp, XS_T *xs, u_int16_t *handlep){	int i, j;	for (j = isp->isp_lasthdls, i = 0; i < (int) isp->isp_maxcmds; i++) {		if (isp->isp_xflist[j] == NULL) {			break;		}		if (++j == isp->isp_maxcmds) {			j = 0;		}	}	if (i == isp->isp_maxcmds) {		return (-1);	}	isp->isp_xflist[j] = xs;	*handlep = j+1;	if (++j == isp->isp_maxcmds)		j = 0;	isp->isp_lasthdls = (u_int16_t)j;	return (0);}static INLINE XS_T *isp_find_xs(struct ispsoftc *isp, u_int16_t handle){	if (handle < 1 || handle > (u_int16_t) isp->isp_maxcmds) {		return (NULL);	} else {		return (isp->isp_xflist[handle - 1]);	}}static INLINE u_int16_tisp_find_handle(struct ispsoftc *isp, XS_T *xs){	int i;	if (xs != NULL) {		for (i = 0; i < isp->isp_maxcmds; i++) {			if (isp->isp_xflist[i] == xs) {				return ((u_int16_t) i+1);			}		}	}	return (0);}static INLINE intisp_handle_index(u_int16_t handle){	return (handle-1);}static INLINE voidisp_destroy_handle(struct ispsoftc *isp, u_int16_t handle){	if (handle > 0 && handle <= (u_int16_t) isp->isp_maxcmds) {		isp->isp_xflist[isp_handle_index(handle)] = NULL;	}}static INLINE voidisp_remove_handle(struct ispsoftc *isp, XS_T *xs){	isp_destroy_handle(isp, isp_find_handle(isp, xs));}static INLINE intisp_getrqentry(struct ispsoftc *, u_int16_t *, u_int16_t *, void **);static INLINE intisp_getrqentry(struct ispsoftc *isp, u_int16_t *iptrp,    u_int16_t *optrp, void **resultp){	volatile u_int16_t iptr, optr;	optr = isp->isp_reqodx = READ_REQUEST_QUEUE_OUT_POINTER(isp);	iptr = isp->isp_reqidx;	*resultp = ISP_QUEUE_ENTRY(isp->isp_rquest, iptr);	iptr = ISP_NXT_QENTRY(iptr, RQUEST_QUEUE_LEN(isp));	if (iptr == optr) {		return (1);	}	if (optrp)		*optrp = optr;	if (iptrp)		*iptrp = iptr;	return (0);}static INLINE void isp_print_qentry (struct ispsoftc *, char *, int, void *);#define	TBA	(4 * (((QENTRY_LEN >> 2) * 3) + 1) + 1)static INLINE voidisp_print_qentry(struct ispsoftc *isp, char *msg, int idx, void *arg){	char buf[TBA];	int amt, i, j;	u_int8_t *ptr = arg;	isp_prt(isp, ISP_LOGALL, "%s index %d=>", msg, idx);	for (buf[0] = 0, amt = i = 0; i < 4; i++) {		buf[0] = 0;		SNPRINTF(buf, TBA, "  ");		for (j = 0; j < (QENTRY_LEN >> 2); j++) {			SNPRINTF(buf, TBA, "%s %02x", buf, ptr[amt++] & 0xff);		}		isp_prt(isp, ISP_LOGALL, buf);	}}static INLINE void isp_print_bytes(struct ispsoftc *, char *, int, void *);static INLINE voidisp_print_bytes(struct ispsoftc *isp, char *msg, int amt, void *arg){	char buf[128];	u_int8_t *ptr = arg;	int off;	if (msg)		isp_prt(isp, ISP_LOGALL, "%s:", msg);	off = 0;	buf[0] = 0;	while (off < amt) {		int j, to;		to = off;		for (j = 0; j < 16; j++) {			SNPRINTF(buf, 128, "%s %02x", buf, ptr[off++] & 0xff);			if (off == amt)				break;		}		isp_prt(isp, ISP_LOGALL, "0x%08x:%s", to, buf);		buf[0] = 0;	}}/* * Do the common path to try and ensure that link is up, we've scanned * the fabric (if we're on a fabric), and that we've synchronized this * all with our own database and done the appropriate logins. * * We repeatedly check for firmware state and loop state after each * action because things may have changed while we were doing this. * Any failure or change of state causes us to return a nonzero value. * * We honor HBA roles in that if we're not in Initiator mode, we don't * attempt to sync up the database (that's for somebody else to do, * if ever). * * We assume we enter here with any locks held. */static INLINE int isp_fc_runstate(struct ispsoftc *, int);static INLINE intisp_fc_runstate(struct ispsoftc *isp, int tval){	fcparam *fcp;	int *tptr;	if (IS_SCSI(isp) || isp->isp_role == ISP_ROLE_NONE)		return (0);	tptr = tval? &tval : NULL;	if (isp_control(isp, ISPCTL_FCLINK_TEST, tptr) != 0) {		return (-1);	}	fcp = FCPARAM(isp);	if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate < LOOP_PDB_RCVD)		return (-1);	if (isp_control(isp, ISPCTL_SCAN_FABRIC, NULL) != 0) {		return (-1);	}	if (isp_control(isp, ISPCTL_SCAN_LOOP, NULL) != 0) {		return (-1);	}	if ((isp->isp_role & ISP_ROLE_INITIATOR) == 0) {		return (0);	}	if (isp_control(isp, ISPCTL_PDB_SYNC, NULL) != 0) {		return (-1);	}	if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate != LOOP_READY) {		return (-1);	}	return (0);}/* * Functions to move stuff to a form that the QLogic RISC engine understands * and functions to move stuff back to a form the processor understands. * * Each platform is required to provide the 8, 16 and 32 bit * swizzle and unswizzle macros (ISP_IOX{PUT|GET}_{8,16,32}) * * The assumption is that swizzling and unswizzling is mostly done 'in place' * (with a few exceptions for efficiency). */static INLINE void isp_copy_out_hdr(struct ispsoftc *, isphdr_t *, isphdr_t *);static INLINE void isp_copy_in_hdr(struct ispsoftc *, isphdr_t *, isphdr_t *);static INLINE int isp_get_response_type(struct ispsoftc *, isphdr_t *);static INLINE voidisp_put_request(struct ispsoftc *, ispreq_t *, ispreq_t *);static INLINE voidisp_put_request_t2(struct ispsoftc *, ispreqt2_t *, ispreqt2_t *);static INLINE voidisp_put_request_t3(struct ispsoftc *, ispreqt3_t *, ispreqt3_t *);static INLINE voidisp_put_extended_request(struct ispsoftc *, ispextreq_t *, ispextreq_t *);static INLINE voidisp_put_cont_req(struct ispsoftc *, ispcontreq_t *, ispcontreq_t *);static INLINE voidisp_put_cont64_req(struct ispsoftc *, ispcontreq64_t *, ispcontreq64_t *);static INLINE voidisp_get_response(struct ispsoftc *, ispstatusreq_t *, ispstatusreq_t *);static INLINE voidisp_get_response_x(struct ispsoftc *, ispstatus_cont_t *, ispstatus_cont_t *);static INLINE voidisp_get_rio2(struct ispsoftc *, isp_rio2_t *, isp_rio2_t *);static INLINE voidisp_put_icb(struct ispsoftc *, isp_icb_t *, isp_icb_t *);static INLINE voidisp_get_pdb(struct ispsoftc *, isp_pdb_t *, isp_pdb_t *);static INLINE voidisp_get_ct_hdr(struct ispsoftc *isp, ct_hdr_t *, ct_hdr_t *);static INLINE voidisp_put_sns_request(struct ispsoftc *, sns_screq_t *, sns_screq_t *);static INLINE voidisp_put_gid_ft_request(struct ispsoftc *, sns_gid_ft_req_t *,    sns_gid_ft_req_t *);static INLINE voidisp_put_gxn_id_request(struct ispsoftc *, sns_gxn_id_req_t *,    sns_gxn_id_req_t *);static INLINE voidisp_get_sns_response(struct ispsoftc *, sns_scrsp_t *, sns_scrsp_t *, int);static INLINE voidisp_get_gid_ft_response(struct ispsoftc *, sns_gid_ft_rsp_t *,    sns_gid_ft_rsp_t *, int);static INLINE voidisp_get_gxn_id_response(struct ispsoftc *, sns_gxn_id_rsp_t *,    sns_gxn_id_rsp_t *);static INLINE voidisp_get_ga_nxt_response(struct ispsoftc *, sns_ga_nxt_rsp_t *,    sns_ga_nxt_rsp_t *);#ifdef	ISP_TARGET_MODE#ifndef	_ISP_TARGET_H#include "isp_target.h"#endifstatic INLINE voidisp_put_atio(struct ispsoftc *, at_entry_t *, at_entry_t *);static INLINE voidisp_get_atio(struct ispsoftc *, at_entry_t *, at_entry_t *);static INLINE voidisp_put_atio2(struct ispsoftc *, at2_entry_t *, at2_entry_t *);static INLINE voidisp_get_atio2(struct ispsoftc *, at2_entry_t *, at2_entry_t *);static INLINE voidisp_put_ctio(struct ispsoftc *, ct_entry_t *, ct_entry_t *);static INLINE voidisp_get_ctio(struct ispsoftc *, ct_entry_t *, ct_entry_t *);static INLINE voidisp_put_ctio2(struct ispsoftc *, ct2_entry_t *, ct2_entry_t *);static INLINE voidisp_get_ctio2(struct ispsoftc *, ct2_entry_t *, ct2_entry_t *);static INLINE voidisp_put_enable_lun(struct ispsoftc *, lun_entry_t *, lun_entry_t *);static INLINE voidisp_get_enable_lun(struct ispsoftc *, lun_entry_t *, lun_entry_t *);static INLINE voidisp_put_notify(struct ispsoftc *, in_entry_t *, in_entry_t *);static INLINE voidisp_get_notify(struct ispsoftc *, in_entry_t *, in_entry_t *);static INLINE voidisp_put_notify_fc(struct ispsoftc *, in_fcentry_t *, in_fcentry_t *);static INLINE voidisp_get_notify_fc(struct ispsoftc *, in_fcentry_t *, in_fcentry_t *);static INLINE voidisp_put_notify_ack(struct ispsoftc *, na_entry_t *, na_entry_t *);static INLINE voidisp_get_notify_ack(struct ispsoftc *, na_entry_t *, na_entry_t *);static INLINE voidisp_put_notify_ack_fc(struct ispsoftc *, na_fcentry_t *, na_fcentry_t *);static INLINE voidisp_get_notify_ack_fc(struct ispsoftc *, na_fcentry_t *, na_fcentry_t *);#endif#define	ISP_IS_SBUS(isp)	\	(ISP_SBUS_SUPPORTED && (isp)->isp_bustype == ISP_BT_SBUS)/* * Swizzle/Copy Functions */static INLINE voidisp_copy_out_hdr(struct ispsoftc *isp, isphdr_t *hpsrc, isphdr_t *hpdst){	if (ISP_IS_SBUS(isp)) {		ISP_IOXPUT_8(isp, hpsrc->rqs_entry_type,		    &hpdst->rqs_entry_count);		ISP_IOXPUT_8(isp, hpsrc->rqs_entry_count,		    &hpdst->rqs_entry_type);		ISP_IOXPUT_8(isp, hpsrc->rqs_seqno,		    &hpdst->rqs_flags);		ISP_IOXPUT_8(isp, hpsrc->rqs_flags,		    &hpdst->rqs_seqno);	} else {		ISP_IOXPUT_8(isp, hpsrc->rqs_entry_type,		    &hpdst->rqs_entry_type);		ISP_IOXPUT_8(isp, hpsrc->rqs_entry_count,		    &hpdst->rqs_entry_count);		ISP_IOXPUT_8(isp, hpsrc->rqs_seqno,		    &hpdst->rqs_seqno);		ISP_IOXPUT_8(isp, hpsrc->rqs_flags,		    &hpdst->rqs_flags);	}}static INLINE voidisp_copy_in_hdr(struct ispsoftc *isp, isphdr_t *hpsrc, isphdr_t *hpdst)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -