blob: 5e0a7095c9f2fa52d905e26e46d54d20f27d28ab [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Andrew Vasquezfa90c542005-10-27 11:10:08 -07002 * QLogic Fibre Channel HBA Driver
Andrew Vasquez01e58d82008-04-03 13:13:13 -07003 * Copyright (c) 2003-2008 QLogic Corporation
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Andrew Vasquezfa90c542005-10-27 11:10:08 -07005 * See LICENSE.qla2xxx for copyright and licensing details.
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 */
7
Linus Torvalds1da177e2005-04-16 15:20:36 -07008/*
9 * qla2x00_debounce_register
10 * Debounce register.
11 *
12 * Input:
13 * port = register address.
14 *
15 * Returns:
16 * register value.
17 */
18static __inline__ uint16_t
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -070019qla2x00_debounce_register(volatile uint16_t __iomem *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070020{
21 volatile uint16_t first;
22 volatile uint16_t second;
23
24 do {
25 first = RD_REG_WORD(addr);
26 barrier();
27 cpu_relax();
28 second = RD_REG_WORD(addr);
29 } while (first != second);
30
31 return (first);
32}
33
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -070034static inline void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -080035qla2x00_poll(struct rsp_que *rsp)
Linus Torvalds1da177e2005-04-16 15:20:36 -070036{
Andrew Vasquezd2ba5672008-05-12 22:21:14 -070037 unsigned long flags;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -080038 struct qla_hw_data *ha = rsp->hw;
Andrew Vasquezd2ba5672008-05-12 22:21:14 -070039 local_irq_save(flags);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -080040 ha->isp_ops->intr_handler(0, rsp);
Andrew Vasquezd2ba5672008-05-12 22:21:14 -070041 local_irq_restore(flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070042}
43
Andrew Vasquez2b6c0ce2005-07-06 10:31:17 -070044static inline uint8_t *
45host_to_fcp_swap(uint8_t *fcp, uint32_t bsize)
46{
47 uint32_t *ifcp = (uint32_t *) fcp;
48 uint32_t *ofcp = (uint32_t *) fcp;
49 uint32_t iter = bsize >> 2;
50
51 for (; iter ; iter--)
52 *ofcp++ = swab32(*ifcp++);
53
54 return fcp;
55}
Andrew Vasquez3d716442005-07-06 10:30:26 -070056
Andrew Vasquez3d716442005-07-06 10:30:26 -070057static inline int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -080058qla2x00_is_reserved_id(scsi_qla_host_t *vha, uint16_t loop_id)
Andrew Vasquez3d716442005-07-06 10:30:26 -070059{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -080060 struct qla_hw_data *ha = vha->hw;
Andrew Vasqueze4289242007-07-19 15:05:56 -070061 if (IS_FWI2_CAPABLE(ha))
Andrew Vasquez3d716442005-07-06 10:30:26 -070062 return (loop_id > NPH_LAST_HANDLE);
63
Anirban Chakrabortye315cd22008-11-06 10:40:51 -080064 return ((loop_id > ha->max_loop_id && loop_id < SNS_FIRST_LOOP_ID) ||
Andrew Vasquez3d716442005-07-06 10:30:26 -070065 loop_id == MANAGEMENT_SERVER || loop_id == BROADCAST);
Anirban Chakraborty17d98632008-12-18 10:06:15 -080066}