qla_inline.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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(scsi_qla_host_t *ha)
  32. {
  33. unsigned long flags;
  34. local_irq_save(flags);
  35. ha->isp_ops->intr_handler(0, ha);
  36. local_irq_restore(flags);
  37. }
  38. static __inline__ scsi_qla_host_t *
  39. to_qla_parent(scsi_qla_host_t *ha)
  40. {
  41. return ha->parent ? ha->parent : ha;
  42. }
  43. /**
  44. * qla2x00_issue_marker() - Issue a Marker IOCB if necessary.
  45. * @ha: HA context
  46. * @ha_locked: is function called with the hardware lock
  47. *
  48. * Returns non-zero if a failure occurred, else zero.
  49. */
  50. static inline int
  51. qla2x00_issue_marker(scsi_qla_host_t *ha, int ha_locked)
  52. {
  53. /* Send marker if required */
  54. if (ha->marker_needed != 0) {
  55. if (ha_locked) {
  56. if (__qla2x00_marker(ha, 0, 0, MK_SYNC_ALL) !=
  57. QLA_SUCCESS)
  58. return (QLA_FUNCTION_FAILED);
  59. } else {
  60. if (qla2x00_marker(ha, 0, 0, MK_SYNC_ALL) !=
  61. QLA_SUCCESS)
  62. return (QLA_FUNCTION_FAILED);
  63. }
  64. ha->marker_needed = 0;
  65. }
  66. return (QLA_SUCCESS);
  67. }
  68. static inline uint8_t *
  69. host_to_fcp_swap(uint8_t *fcp, uint32_t bsize)
  70. {
  71. uint32_t *ifcp = (uint32_t *) fcp;
  72. uint32_t *ofcp = (uint32_t *) fcp;
  73. uint32_t iter = bsize >> 2;
  74. for (; iter ; iter--)
  75. *ofcp++ = swab32(*ifcp++);
  76. return fcp;
  77. }
  78. static inline int
  79. qla2x00_is_reserved_id(scsi_qla_host_t *ha, uint16_t loop_id)
  80. {
  81. if (IS_FWI2_CAPABLE(ha))
  82. return (loop_id > NPH_LAST_HANDLE);
  83. return ((loop_id > ha->last_loop_id && loop_id < SNS_FIRST_LOOP_ID) ||
  84. loop_id == MANAGEMENT_SERVER || loop_id == BROADCAST);
  85. };