qla_inline.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * QLogic Fibre Channel HBA Driver
  3. * Copyright (c) 2003-2010 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. if (IS_QLA82XX(ha))
  37. qla82xx_poll(0, rsp);
  38. else
  39. ha->isp_ops->intr_handler(0, rsp);
  40. local_irq_restore(flags);
  41. }
  42. static inline uint8_t *
  43. host_to_fcp_swap(uint8_t *fcp, uint32_t bsize)
  44. {
  45. uint32_t *ifcp = (uint32_t *) fcp;
  46. uint32_t *ofcp = (uint32_t *) fcp;
  47. uint32_t iter = bsize >> 2;
  48. for (; iter ; iter--)
  49. *ofcp++ = swab32(*ifcp++);
  50. return fcp;
  51. }
  52. static inline int
  53. qla2x00_is_reserved_id(scsi_qla_host_t *vha, uint16_t loop_id)
  54. {
  55. struct qla_hw_data *ha = vha->hw;
  56. if (IS_FWI2_CAPABLE(ha))
  57. return (loop_id > NPH_LAST_HANDLE);
  58. return ((loop_id > ha->max_loop_id && loop_id < SNS_FIRST_LOOP_ID) ||
  59. loop_id == MANAGEMENT_SERVER || loop_id == BROADCAST);
  60. }
  61. static inline void
  62. qla2x00_clean_dsd_pool(struct qla_hw_data *ha, srb_t *sp)
  63. {
  64. struct dsd_dma *dsd_ptr, *tdsd_ptr;
  65. /* clean up allocated prev pool */
  66. list_for_each_entry_safe(dsd_ptr, tdsd_ptr,
  67. &((struct crc_context *)sp->ctx)->dsd_list, list) {
  68. dma_pool_free(ha->dl_dma_pool, dsd_ptr->dsd_addr,
  69. dsd_ptr->dsd_list_dma);
  70. list_del(&dsd_ptr->list);
  71. kfree(dsd_ptr);
  72. }
  73. INIT_LIST_HEAD(&((struct crc_context *)sp->ctx)->dsd_list);
  74. }