[PATCH] W1: w1_netlink: New init/fini netlink callbacks.
[linux-2.6/verdex.git] / drivers / scsi / qla2xxx / qla_inline.h
blobb9ff85b03a5f68a2ce8a7417f286a141a1ff3c03
1 /*
2 * QLOGIC LINUX SOFTWARE
4 * QLogic ISP2x00 device driver for Linux 2.6.x
5 * Copyright (C) 2003-2005 QLogic Corporation
6 * (www.qlogic.com)
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
21 static __inline__ uint16_t qla2x00_debounce_register(volatile uint16_t __iomem *);
23 * qla2x00_debounce_register
24 * Debounce register.
26 * Input:
27 * port = register address.
29 * Returns:
30 * register value.
32 static __inline__ uint16_t
33 qla2x00_debounce_register(volatile uint16_t __iomem *addr)
35 volatile uint16_t first;
36 volatile uint16_t second;
38 do {
39 first = RD_REG_WORD(addr);
40 barrier();
41 cpu_relax();
42 second = RD_REG_WORD(addr);
43 } while (first != second);
45 return (first);
48 static __inline__ int qla2x00_normalize_dma_addr(
49 dma_addr_t *e_addr, uint32_t *e_len,
50 dma_addr_t *ne_addr, uint32_t *ne_len);
52 /**
53 * qla2x00_normalize_dma_addr() - Normalize an DMA address.
54 * @e_addr: Raw DMA address
55 * @e_len: Raw DMA length
56 * @ne_addr: Normalized second DMA address
57 * @ne_len: Normalized second DMA length
59 * If the address does not span a 4GB page boundary, the contents of @ne_addr
60 * and @ne_len are undefined. @e_len is updated to reflect a normalization.
62 * Example:
64 * ffffabc0ffffeeee (e_addr) start of DMA address
65 * 0000000020000000 (e_len) length of DMA transfer
66 * ffffabc11fffeeed end of DMA transfer
68 * Is the 4GB boundary crossed?
70 * ffffabc0ffffeeee (e_addr)
71 * ffffabc11fffeeed (e_addr + e_len - 1)
72 * 00000001e0000003 ((e_addr ^ (e_addr + e_len - 1))
73 * 0000000100000000 ((e_addr ^ (e_addr + e_len - 1)) & ~(0xffffffff)
75 * Compute start of second DMA segment:
77 * ffffabc0ffffeeee (e_addr)
78 * ffffabc1ffffeeee (0x100000000 + e_addr)
79 * ffffabc100000000 (0x100000000 + e_addr) & ~(0xffffffff)
80 * ffffabc100000000 (ne_addr)
82 * Compute length of second DMA segment:
84 * 00000000ffffeeee (e_addr & 0xffffffff)
85 * 0000000000001112 (0x100000000 - (e_addr & 0xffffffff))
86 * 000000001fffeeee (e_len - (0x100000000 - (e_addr & 0xffffffff))
87 * 000000001fffeeee (ne_len)
89 * Adjust length of first DMA segment
91 * 0000000020000000 (e_len)
92 * 0000000000001112 (e_len - ne_len)
93 * 0000000000001112 (e_len)
95 * Returns non-zero if the specified address was normalized, else zero.
97 static __inline__ int
98 qla2x00_normalize_dma_addr(
99 dma_addr_t *e_addr, uint32_t *e_len,
100 dma_addr_t *ne_addr, uint32_t *ne_len)
102 int normalized;
104 normalized = 0;
105 if ((*e_addr ^ (*e_addr + *e_len - 1)) & ~(0xFFFFFFFFULL)) {
106 /* Compute normalized crossed address and len */
107 *ne_addr = (0x100000000ULL + *e_addr) & ~(0xFFFFFFFFULL);
108 *ne_len = *e_len - (0x100000000ULL - (*e_addr & 0xFFFFFFFFULL));
109 *e_len -= *ne_len;
111 normalized++;
113 return (normalized);
116 static __inline__ void qla2x00_poll(scsi_qla_host_t *);
117 static inline void
118 qla2x00_poll(scsi_qla_host_t *ha)
120 ha->isp_ops.intr_handler(0, ha, NULL);
123 static __inline__ void qla2x00_check_fabric_devices(scsi_qla_host_t *);
125 * This routine will wait for fabric devices for
126 * the reset delay.
128 static __inline__ void qla2x00_check_fabric_devices(scsi_qla_host_t *ha)
130 uint16_t fw_state;
132 qla2x00_get_firmware_state(ha, &fw_state);
136 * qla2x00_issue_marker() - Issue a Marker IOCB if necessary.
137 * @ha: HA context
138 * @ha_locked: is function called with the hardware lock
140 * Returns non-zero if a failure occured, else zero.
142 static inline int
143 qla2x00_issue_marker(scsi_qla_host_t *ha, int ha_locked)
145 /* Send marker if required */
146 if (ha->marker_needed != 0) {
147 if (ha_locked) {
148 if (__qla2x00_marker(ha, 0, 0, MK_SYNC_ALL) !=
149 QLA_SUCCESS)
150 return (QLA_FUNCTION_FAILED);
151 } else {
152 if (qla2x00_marker(ha, 0, 0, MK_SYNC_ALL) !=
153 QLA_SUCCESS)
154 return (QLA_FUNCTION_FAILED);
156 ha->marker_needed = 0;
158 return (QLA_SUCCESS);
161 static inline uint8_t *host_to_fcp_swap(uint8_t *, uint32_t);
162 static inline uint8_t *
163 host_to_fcp_swap(uint8_t *fcp, uint32_t bsize)
165 uint32_t *ifcp = (uint32_t *) fcp;
166 uint32_t *ofcp = (uint32_t *) fcp;
167 uint32_t iter = bsize >> 2;
169 for (; iter ; iter--)
170 *ofcp++ = swab32(*ifcp++);
172 return fcp;
175 static inline int qla2x00_is_reserved_id(scsi_qla_host_t *, uint16_t);
176 static inline int
177 qla2x00_is_reserved_id(scsi_qla_host_t *ha, uint16_t loop_id)
179 if (IS_QLA24XX(ha) || IS_QLA25XX(ha))
180 return (loop_id > NPH_LAST_HANDLE);
182 return ((loop_id > ha->last_loop_id && loop_id < SNS_FIRST_LOOP_ID) ||
183 loop_id == MANAGEMENT_SERVER || loop_id == BROADCAST);