csio_init.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * This file is part of the Chelsio FCoE driver for Linux.
  3. *
  4. * Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved.
  5. *
  6. * This software is available to you under a choice of one of two
  7. * licenses. You may choose to be licensed under the terms of the GNU
  8. * General Public License (GPL) Version 2, available from the file
  9. * COPYING in the main directory of this source tree, or the
  10. * OpenIB.org BSD license below:
  11. *
  12. * Redistribution and use in source and binary forms, with or
  13. * without modification, are permitted provided that the following
  14. * conditions are met:
  15. *
  16. * - Redistributions of source code must retain the above
  17. * copyright notice, this list of conditions and the following
  18. * disclaimer.
  19. *
  20. * - Redistributions in binary form must reproduce the above
  21. * copyright notice, this list of conditions and the following
  22. * disclaimer in the documentation and/or other materials
  23. * provided with the distribution.
  24. *
  25. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  28. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  29. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  30. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  31. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  32. * SOFTWARE.
  33. */
  34. #ifndef __CSIO_INIT_H__
  35. #define __CSIO_INIT_H__
  36. #include <linux/pci.h>
  37. #include <linux/if_ether.h>
  38. #include <scsi/scsi.h>
  39. #include <scsi/scsi_device.h>
  40. #include <scsi/scsi_host.h>
  41. #include <scsi/scsi_transport_fc.h>
  42. #include "csio_scsi.h"
  43. #include "csio_lnode.h"
  44. #include "csio_rnode.h"
  45. #include "csio_hw.h"
  46. #define CSIO_DRV_AUTHOR "Chelsio Communications"
  47. #define CSIO_DRV_LICENSE "Dual BSD/GPL"
  48. #define CSIO_DRV_DESC "Chelsio FCoE driver"
  49. #define CSIO_DRV_VERSION "1.0.0"
  50. #define CSIO_DEVICE(devid, idx) \
  51. { PCI_VENDOR_ID_CHELSIO, (devid), PCI_ANY_ID, PCI_ANY_ID, 0, 0, (idx) }
  52. #define CSIO_IS_T4_FPGA(_dev) (((_dev) == CSIO_DEVID_PE10K) ||\
  53. ((_dev) == CSIO_DEVID_PE10K_PF1))
  54. /* FCoE device IDs */
  55. #define CSIO_DEVID_PE10K 0xA000
  56. #define CSIO_DEVID_PE10K_PF1 0xA001
  57. #define CSIO_DEVID_T440DBG_FCOE 0x4600
  58. #define CSIO_DEVID_T420CR_FCOE 0x4601
  59. #define CSIO_DEVID_T422CR_FCOE 0x4602
  60. #define CSIO_DEVID_T440CR_FCOE 0x4603
  61. #define CSIO_DEVID_T420BCH_FCOE 0x4604
  62. #define CSIO_DEVID_T440BCH_FCOE 0x4605
  63. #define CSIO_DEVID_T440CH_FCOE 0x4606
  64. #define CSIO_DEVID_T420SO_FCOE 0x4607
  65. #define CSIO_DEVID_T420CX_FCOE 0x4608
  66. #define CSIO_DEVID_T420BT_FCOE 0x4609
  67. #define CSIO_DEVID_T404BT_FCOE 0x460A
  68. #define CSIO_DEVID_B420_FCOE 0x460B
  69. #define CSIO_DEVID_B404_FCOE 0x460C
  70. #define CSIO_DEVID_T480CR_FCOE 0x460D
  71. #define CSIO_DEVID_T440LPCR_FCOE 0x460E
  72. extern struct fc_function_template csio_fc_transport_funcs;
  73. extern struct fc_function_template csio_fc_transport_vport_funcs;
  74. void csio_fchost_attr_init(struct csio_lnode *);
  75. /* INTx handlers */
  76. void csio_scsi_intx_handler(struct csio_hw *, void *, uint32_t,
  77. struct csio_fl_dma_buf *, void *);
  78. void csio_fwevt_intx_handler(struct csio_hw *, void *, uint32_t,
  79. struct csio_fl_dma_buf *, void *);
  80. /* Common os lnode APIs */
  81. void csio_lnodes_block_request(struct csio_hw *);
  82. void csio_lnodes_unblock_request(struct csio_hw *);
  83. void csio_lnodes_block_by_port(struct csio_hw *, uint8_t);
  84. void csio_lnodes_unblock_by_port(struct csio_hw *, uint8_t);
  85. struct csio_lnode *csio_shost_init(struct csio_hw *, struct device *, bool,
  86. struct csio_lnode *);
  87. void csio_shost_exit(struct csio_lnode *);
  88. void csio_lnodes_exit(struct csio_hw *, bool);
  89. static inline struct Scsi_Host *
  90. csio_ln_to_shost(struct csio_lnode *ln)
  91. {
  92. return container_of((void *)ln, struct Scsi_Host, hostdata[0]);
  93. }
  94. /* SCSI -- locking version of get/put ioreqs */
  95. static inline struct csio_ioreq *
  96. csio_get_scsi_ioreq_lock(struct csio_hw *hw, struct csio_scsim *scsim)
  97. {
  98. struct csio_ioreq *ioreq;
  99. unsigned long flags;
  100. spin_lock_irqsave(&scsim->freelist_lock, flags);
  101. ioreq = csio_get_scsi_ioreq(scsim);
  102. spin_unlock_irqrestore(&scsim->freelist_lock, flags);
  103. return ioreq;
  104. }
  105. static inline void
  106. csio_put_scsi_ioreq_lock(struct csio_hw *hw, struct csio_scsim *scsim,
  107. struct csio_ioreq *ioreq)
  108. {
  109. unsigned long flags;
  110. spin_lock_irqsave(&scsim->freelist_lock, flags);
  111. csio_put_scsi_ioreq(scsim, ioreq);
  112. spin_unlock_irqrestore(&scsim->freelist_lock, flags);
  113. }
  114. /* Called in interrupt context */
  115. static inline void
  116. csio_put_scsi_ioreq_list_lock(struct csio_hw *hw, struct csio_scsim *scsim,
  117. struct list_head *reqlist, int n)
  118. {
  119. unsigned long flags;
  120. spin_lock_irqsave(&scsim->freelist_lock, flags);
  121. csio_put_scsi_ioreq_list(scsim, reqlist, n);
  122. spin_unlock_irqrestore(&scsim->freelist_lock, flags);
  123. }
  124. /* Called in interrupt context */
  125. static inline void
  126. csio_put_scsi_ddp_list_lock(struct csio_hw *hw, struct csio_scsim *scsim,
  127. struct list_head *reqlist, int n)
  128. {
  129. unsigned long flags;
  130. spin_lock_irqsave(&hw->lock, flags);
  131. csio_put_scsi_ddp_list(scsim, reqlist, n);
  132. spin_unlock_irqrestore(&hw->lock, flags);
  133. }
  134. #endif /* ifndef __CSIO_INIT_H__ */