fc_libfc.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Copyright(c) 2009 Intel Corporation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with
  14. * this program; if not, write to the Free Software Foundation, Inc.,
  15. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  16. *
  17. * Maintained at www.Open-FCoE.org
  18. */
  19. #ifndef _FC_LIBFC_H_
  20. #define _FC_LIBFC_H_
  21. #define FC_LIBFC_LOGGING 0x01 /* General logging, not categorized */
  22. #define FC_LPORT_LOGGING 0x02 /* lport layer logging */
  23. #define FC_DISC_LOGGING 0x04 /* discovery layer logging */
  24. #define FC_RPORT_LOGGING 0x08 /* rport layer logging */
  25. #define FC_FCP_LOGGING 0x10 /* I/O path logging */
  26. #define FC_EM_LOGGING 0x20 /* Exchange Manager logging */
  27. #define FC_EXCH_LOGGING 0x40 /* Exchange/Sequence logging */
  28. #define FC_SCSI_LOGGING 0x80 /* SCSI logging (mostly error handling) */
  29. extern unsigned int fc_debug_logging;
  30. #define FC_CHECK_LOGGING(LEVEL, CMD) \
  31. do { \
  32. if (unlikely(fc_debug_logging & LEVEL)) \
  33. do { \
  34. CMD; \
  35. } while (0); \
  36. } while (0)
  37. #define FC_LIBFC_DBG(fmt, args...) \
  38. FC_CHECK_LOGGING(FC_LIBFC_LOGGING, \
  39. pr_info("libfc: " fmt, ##args))
  40. #define FC_LPORT_DBG(lport, fmt, args...) \
  41. FC_CHECK_LOGGING(FC_LPORT_LOGGING, \
  42. pr_info("host%u: lport %6.6x: " fmt, \
  43. (lport)->host->host_no, \
  44. (lport)->port_id, ##args))
  45. #define FC_DISC_DBG(disc, fmt, args...) \
  46. FC_CHECK_LOGGING(FC_DISC_LOGGING, \
  47. pr_info("host%u: disc: " fmt, \
  48. fc_disc_lport(disc)->host->host_no, \
  49. ##args))
  50. #define FC_RPORT_ID_DBG(lport, port_id, fmt, args...) \
  51. FC_CHECK_LOGGING(FC_RPORT_LOGGING, \
  52. pr_info("host%u: rport %6.6x: " fmt, \
  53. (lport)->host->host_no, \
  54. (port_id), ##args))
  55. #define FC_RPORT_DBG(rdata, fmt, args...) \
  56. FC_RPORT_ID_DBG((rdata)->local_port, (rdata)->ids.port_id, fmt, ##args)
  57. #define FC_FCP_DBG(pkt, fmt, args...) \
  58. FC_CHECK_LOGGING(FC_FCP_LOGGING, \
  59. { \
  60. if ((pkt)->seq_ptr) { \
  61. struct fc_exch *_ep = NULL; \
  62. _ep = fc_seq_exch((pkt)->seq_ptr); \
  63. pr_info("host%u: fcp: %6.6x: " \
  64. "xid %04x-%04x: " fmt, \
  65. (pkt)->lp->host->host_no, \
  66. (pkt)->rport->port_id, \
  67. (_ep)->oxid, (_ep)->rxid, ##args); \
  68. } else { \
  69. pr_info("host%u: fcp: %6.6x: " fmt, \
  70. (pkt)->lp->host->host_no, \
  71. (pkt)->rport->port_id, ##args); \
  72. } \
  73. })
  74. #define FC_EXCH_DBG(exch, fmt, args...) \
  75. FC_CHECK_LOGGING(FC_EXCH_LOGGING, \
  76. pr_info("host%u: xid %4x: " fmt, \
  77. (exch)->lp->host->host_no, \
  78. exch->xid, ##args))
  79. #define FC_SCSI_DBG(lport, fmt, args...) \
  80. FC_CHECK_LOGGING(FC_SCSI_LOGGING, \
  81. pr_info("host%u: scsi: " fmt, \
  82. (lport)->host->host_no, ##args))
  83. /*
  84. * FC-4 Providers.
  85. */
  86. extern struct fc4_prov *fc_active_prov[]; /* providers without recv */
  87. extern struct fc4_prov *fc_passive_prov[]; /* providers with recv */
  88. extern struct mutex fc_prov_mutex; /* lock over table changes */
  89. extern struct fc4_prov fc_rport_t0_prov; /* type 0 provider */
  90. extern struct fc4_prov fc_lport_els_prov; /* ELS provider */
  91. extern struct fc4_prov fc_rport_fcp_init; /* FCP initiator provider */
  92. /*
  93. * Set up direct-data placement for this I/O request
  94. */
  95. void fc_fcp_ddp_setup(struct fc_fcp_pkt *fsp, u16 xid);
  96. void fc_fcp_ddp_done(struct fc_fcp_pkt *fsp);
  97. /*
  98. * Module setup functions
  99. */
  100. int fc_setup_exch_mgr(void);
  101. void fc_destroy_exch_mgr(void);
  102. int fc_setup_rport(void);
  103. void fc_destroy_rport(void);
  104. int fc_setup_fcp(void);
  105. void fc_destroy_fcp(void);
  106. /*
  107. * Internal libfc functions
  108. */
  109. const char *fc_els_resp_type(struct fc_frame *);
  110. extern void fc_fc4_add_lport(struct fc_lport *);
  111. extern void fc_fc4_del_lport(struct fc_lport *);
  112. extern void fc_fc4_conf_lport_params(struct fc_lport *, enum fc_fh_type);
  113. /*
  114. * Copies a buffer into an sg list
  115. */
  116. u32 fc_copy_buffer_to_sglist(void *buf, size_t len,
  117. struct scatterlist *sg,
  118. u32 *nents, size_t *offset,
  119. u32 *crc);
  120. #endif /* _FC_LIBFC_H_ */