qla_inline.h 2.0 KB

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