qla_inline.h 1.9 KB

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