qla_inline.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * QLogic Fibre Channel HBA Driver
  3. * Copyright (c) 2003-2008 QLogic Corporation
  4. *
  5. * See LICENSE.qla2xxx for copyright and licensing details.
  6. */
  7. /*
  8. * qla2x00_debounce_register
  9. * Debounce register.
  10. *
  11. * Input:
  12. * port = register address.
  13. *
  14. * Returns:
  15. * register value.
  16. */
  17. static __inline__ uint16_t
  18. qla2x00_debounce_register(volatile uint16_t __iomem *addr)
  19. {
  20. volatile uint16_t first;
  21. volatile uint16_t second;
  22. do {
  23. first = RD_REG_WORD(addr);
  24. barrier();
  25. cpu_relax();
  26. second = RD_REG_WORD(addr);
  27. } while (first != second);
  28. return (first);
  29. }
  30. static inline void
  31. qla2x00_poll(struct rsp_que *rsp)
  32. {
  33. unsigned long flags;
  34. struct qla_hw_data *ha = rsp->hw;
  35. local_irq_save(flags);
  36. ha->isp_ops->intr_handler(0, rsp);
  37. local_irq_restore(flags);
  38. }
  39. static inline uint8_t *
  40. host_to_fcp_swap(uint8_t *fcp, uint32_t bsize)
  41. {
  42. uint32_t *ifcp = (uint32_t *) fcp;
  43. uint32_t *ofcp = (uint32_t *) fcp;
  44. uint32_t iter = bsize >> 2;
  45. for (; iter ; iter--)
  46. *ofcp++ = swab32(*ifcp++);
  47. return fcp;
  48. }
  49. static inline int
  50. qla2x00_is_reserved_id(scsi_qla_host_t *vha, uint16_t loop_id)
  51. {
  52. struct qla_hw_data *ha = vha->hw;
  53. if (IS_FWI2_CAPABLE(ha))
  54. return (loop_id > NPH_LAST_HANDLE);
  55. return ((loop_id > ha->max_loop_id && loop_id < SNS_FIRST_LOOP_ID) ||
  56. loop_id == MANAGEMENT_SERVER || loop_id == BROADCAST);
  57. }