csio_rnode.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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_RNODE_H__
  35. #define __CSIO_RNODE_H__
  36. #include "csio_defs.h"
  37. /* State machine evets */
  38. enum csio_rn_ev {
  39. CSIO_RNFE_NONE = (uint32_t)0, /* None */
  40. CSIO_RNFE_LOGGED_IN, /* [N/F]Port login
  41. * complete.
  42. */
  43. CSIO_RNFE_PRLI_DONE, /* PRLI completed */
  44. CSIO_RNFE_PLOGI_RECV, /* Received PLOGI */
  45. CSIO_RNFE_PRLI_RECV, /* Received PLOGI */
  46. CSIO_RNFE_LOGO_RECV, /* Received LOGO */
  47. CSIO_RNFE_PRLO_RECV, /* Received PRLO */
  48. CSIO_RNFE_DOWN, /* Rnode is down */
  49. CSIO_RNFE_CLOSE, /* Close rnode */
  50. CSIO_RNFE_NAME_MISSING, /* Rnode name missing
  51. * in name server.
  52. */
  53. CSIO_RNFE_MAX_EVENT,
  54. };
  55. /* rnode stats */
  56. struct csio_rnode_stats {
  57. uint32_t n_err; /* error */
  58. uint32_t n_err_inval; /* invalid parameter */
  59. uint32_t n_err_nomem; /* error nomem */
  60. uint32_t n_evt_unexp; /* unexpected event */
  61. uint32_t n_evt_drop; /* unexpected event */
  62. uint32_t n_evt_fw[PROTO_ERR_IMPL_LOGO + 1]; /* fw events */
  63. enum csio_rn_ev n_evt_sm[CSIO_RNFE_MAX_EVENT]; /* State m/c events */
  64. uint32_t n_lun_rst; /* Number of resets of
  65. * of LUNs under this
  66. * target
  67. */
  68. uint32_t n_lun_rst_fail; /* Number of LUN reset
  69. * failures.
  70. */
  71. uint32_t n_tgt_rst; /* Number of target resets */
  72. uint32_t n_tgt_rst_fail; /* Number of target reset
  73. * failures.
  74. */
  75. };
  76. /* Defines for rnode role */
  77. #define CSIO_RNFR_INITIATOR 0x1
  78. #define CSIO_RNFR_TARGET 0x2
  79. #define CSIO_RNFR_FABRIC 0x4
  80. #define CSIO_RNFR_NS 0x8
  81. #define CSIO_RNFR_NPORT 0x10
  82. struct csio_rnode {
  83. struct csio_sm sm; /* State machine -
  84. * should be the
  85. * 1st member
  86. */
  87. struct csio_lnode *lnp; /* Pointer to owning
  88. * Lnode */
  89. uint32_t flowid; /* Firmware ID */
  90. struct list_head host_cmpl_q; /* SCSI IOs
  91. * pending to completed
  92. * to Mid-layer.
  93. */
  94. /* FC identifiers for remote node */
  95. uint32_t nport_id;
  96. uint16_t fcp_flags; /* FCP Flags */
  97. uint8_t cur_evt; /* Current event */
  98. uint8_t prev_evt; /* Previous event */
  99. uint32_t role; /* Fabric/Target/
  100. * Initiator/NS
  101. */
  102. struct fcoe_rdev_entry *rdev_entry; /* Rdev entry */
  103. struct csio_service_parms rn_sparm;
  104. /* FC transport attributes */
  105. struct fc_rport *rport; /* FC transport rport */
  106. uint32_t supp_classes; /* Supported FC classes */
  107. uint32_t maxframe_size; /* Max Frame size */
  108. uint32_t scsi_id; /* Transport given SCSI id */
  109. struct csio_rnode_stats stats; /* Common rnode stats */
  110. };
  111. #define csio_rn_flowid(rn) ((rn)->flowid)
  112. #define csio_rn_wwpn(rn) ((rn)->rn_sparm.wwpn)
  113. #define csio_rn_wwnn(rn) ((rn)->rn_sparm.wwnn)
  114. #define csio_rnode_to_lnode(rn) ((rn)->lnp)
  115. int csio_is_rnode_ready(struct csio_rnode *rn);
  116. void csio_rnode_state_to_str(struct csio_rnode *rn, int8_t *str);
  117. struct csio_rnode *csio_rnode_lookup_portid(struct csio_lnode *, uint32_t);
  118. struct csio_rnode *csio_confirm_rnode(struct csio_lnode *,
  119. uint32_t, struct fcoe_rdev_entry *);
  120. void csio_rnode_fwevt_handler(struct csio_rnode *rn, uint8_t fwevt);
  121. void csio_put_rnode(struct csio_lnode *ln, struct csio_rnode *rn);
  122. void csio_reg_rnode(struct csio_rnode *);
  123. void csio_unreg_rnode(struct csio_rnode *);
  124. void csio_rnode_devloss_handler(struct csio_rnode *);
  125. #endif /* ifndef __CSIO_RNODE_H__ */