ql4_inline.h 2.3 KB

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