ql4_inline.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * QLogic iSCSI HBA Driver
  3. * Copyright (c) 2003-2013 QLogic Corporation
  4. *
  5. * See LICENSE.qla4xxx for copyright and licensing details.
  6. */
  7. /*
  8. *
  9. * qla4xxx_lookup_ddb_by_fw_index
  10. * This routine locates a device handle given the firmware device
  11. * database index. If device doesn't exist, returns NULL.
  12. *
  13. * Input:
  14. * ha - Pointer to host adapter structure.
  15. * fw_ddb_index - Firmware's device database index
  16. *
  17. * Returns:
  18. * Pointer to the corresponding internal device database structure
  19. */
  20. static inline struct ddb_entry *
  21. qla4xxx_lookup_ddb_by_fw_index(struct scsi_qla_host *ha, uint32_t fw_ddb_index)
  22. {
  23. struct ddb_entry *ddb_entry = NULL;
  24. if ((fw_ddb_index < MAX_DDB_ENTRIES) &&
  25. (ha->fw_ddb_index_map[fw_ddb_index] !=
  26. (struct ddb_entry *) INVALID_ENTRY)) {
  27. ddb_entry = ha->fw_ddb_index_map[fw_ddb_index];
  28. }
  29. DEBUG3(printk("scsi%d: %s: ddb [%d], ddb_entry = %p\n",
  30. ha->host_no, __func__, fw_ddb_index, ddb_entry));
  31. return ddb_entry;
  32. }
  33. static inline void
  34. __qla4xxx_enable_intrs(struct scsi_qla_host *ha)
  35. {
  36. if (is_qla4022(ha) | is_qla4032(ha)) {
  37. writel(set_rmask(IMR_SCSI_INTR_ENABLE),
  38. &ha->reg->u1.isp4022.intr_mask);
  39. readl(&ha->reg->u1.isp4022.intr_mask);
  40. } else {
  41. writel(set_rmask(CSR_SCSI_INTR_ENABLE), &ha->reg->ctrl_status);
  42. readl(&ha->reg->ctrl_status);
  43. }
  44. set_bit(AF_INTERRUPTS_ON, &ha->flags);
  45. }
  46. static inline void
  47. __qla4xxx_disable_intrs(struct scsi_qla_host *ha)
  48. {
  49. if (is_qla4022(ha) | is_qla4032(ha)) {
  50. writel(clr_rmask(IMR_SCSI_INTR_ENABLE),
  51. &ha->reg->u1.isp4022.intr_mask);
  52. readl(&ha->reg->u1.isp4022.intr_mask);
  53. } else {
  54. writel(clr_rmask(CSR_SCSI_INTR_ENABLE), &ha->reg->ctrl_status);
  55. readl(&ha->reg->ctrl_status);
  56. }
  57. clear_bit(AF_INTERRUPTS_ON, &ha->flags);
  58. }
  59. static inline void
  60. qla4xxx_enable_intrs(struct scsi_qla_host *ha)
  61. {
  62. unsigned long flags;
  63. spin_lock_irqsave(&ha->hardware_lock, flags);
  64. __qla4xxx_enable_intrs(ha);
  65. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  66. }
  67. static inline void
  68. qla4xxx_disable_intrs(struct scsi_qla_host *ha)
  69. {
  70. unsigned long flags;
  71. spin_lock_irqsave(&ha->hardware_lock, flags);
  72. __qla4xxx_disable_intrs(ha);
  73. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  74. }
  75. static inline int qla4xxx_get_chap_type(struct ql4_chap_table *chap_entry)
  76. {
  77. int type;
  78. if (chap_entry->flags & BIT_7)
  79. type = LOCAL_CHAP;
  80. else
  81. type = BIDI_CHAP;
  82. return type;
  83. }