rport_api.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
  3. * All rights reserved
  4. * www.brocade.com
  5. *
  6. * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License (GPL) Version 2 as
  10. * published by the Free Software Foundation
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. */
  17. #include <bfa.h>
  18. #include <bfa_svc.h>
  19. #include "fcs_vport.h"
  20. #include "fcs_lport.h"
  21. #include "fcs_rport.h"
  22. #include "fcs_trcmod.h"
  23. BFA_TRC_FILE(FCS, RPORT_API);
  24. /**
  25. * rport_api.c Remote port implementation.
  26. */
  27. /**
  28. * fcs_rport_api FCS rport API.
  29. */
  30. /**
  31. * Direct API to add a target by port wwn. This interface is used, for
  32. * example, by bios when target pwwn is known from boot lun configuration.
  33. */
  34. bfa_status_t
  35. bfa_fcs_rport_add(struct bfa_fcs_port_s *port, wwn_t *pwwn,
  36. struct bfa_fcs_rport_s *rport,
  37. struct bfad_rport_s *rport_drv)
  38. {
  39. bfa_trc(port->fcs, *pwwn);
  40. return BFA_STATUS_OK;
  41. }
  42. /**
  43. * Direct API to remove a target and its associated resources. This
  44. * interface is used, for example, by vmware driver to remove target
  45. * ports from the target list for a VM.
  46. */
  47. bfa_status_t
  48. bfa_fcs_rport_remove(struct bfa_fcs_rport_s *rport_in)
  49. {
  50. struct bfa_fcs_rport_s *rport;
  51. bfa_trc(rport_in->fcs, rport_in->pwwn);
  52. rport = bfa_fcs_port_get_rport_by_pwwn(rport_in->port, rport_in->pwwn);
  53. if (rport == NULL) {
  54. /*
  55. * TBD Error handling
  56. */
  57. bfa_trc(rport_in->fcs, rport_in->pid);
  58. return BFA_STATUS_UNKNOWN_RWWN;
  59. }
  60. /*
  61. * TBD if this remote port is online, send a logo
  62. */
  63. return BFA_STATUS_OK;
  64. }
  65. /**
  66. * Remote device status for display/debug.
  67. */
  68. void
  69. bfa_fcs_rport_get_attr(struct bfa_fcs_rport_s *rport,
  70. struct bfa_rport_attr_s *rport_attr)
  71. {
  72. struct bfa_rport_qos_attr_s qos_attr;
  73. struct bfa_fcs_port_s *port = rport->port;
  74. bfa_os_memset(rport_attr, 0, sizeof(struct bfa_rport_attr_s));
  75. rport_attr->pid = rport->pid;
  76. rport_attr->pwwn = rport->pwwn;
  77. rport_attr->nwwn = rport->nwwn;
  78. rport_attr->cos_supported = rport->fc_cos;
  79. rport_attr->df_sz = rport->maxfrsize;
  80. rport_attr->state = bfa_fcs_rport_get_state(rport);
  81. rport_attr->fc_cos = rport->fc_cos;
  82. rport_attr->cisc = rport->cisc;
  83. rport_attr->scsi_function = rport->scsi_function;
  84. rport_attr->curr_speed = rport->rpf.rpsc_speed;
  85. rport_attr->assigned_speed = rport->rpf.assigned_speed;
  86. bfa_rport_get_qos_attr(rport->bfa_rport, &qos_attr);
  87. rport_attr->qos_attr = qos_attr;
  88. rport_attr->trl_enforced = BFA_FALSE;
  89. if (bfa_pport_is_ratelim(port->fcs->bfa)) {
  90. if ((rport->rpf.rpsc_speed == BFA_PPORT_SPEED_UNKNOWN) ||
  91. (rport->rpf.rpsc_speed <
  92. bfa_fcs_port_get_rport_max_speed(port)))
  93. rport_attr->trl_enforced = BFA_TRUE;
  94. }
  95. /*
  96. * TODO
  97. * rport->symname
  98. */
  99. }
  100. /**
  101. * Per remote device statistics.
  102. */
  103. void
  104. bfa_fcs_rport_get_stats(struct bfa_fcs_rport_s *rport,
  105. struct bfa_rport_stats_s *stats)
  106. {
  107. *stats = rport->stats;
  108. }
  109. void
  110. bfa_fcs_rport_clear_stats(struct bfa_fcs_rport_s *rport)
  111. {
  112. bfa_os_memset((char *)&rport->stats, 0,
  113. sizeof(struct bfa_rport_stats_s));
  114. }
  115. struct bfa_fcs_rport_s *
  116. bfa_fcs_rport_lookup(struct bfa_fcs_port_s *port, wwn_t rpwwn)
  117. {
  118. struct bfa_fcs_rport_s *rport;
  119. rport = bfa_fcs_port_get_rport_by_pwwn(port, rpwwn);
  120. if (rport == NULL) {
  121. /*
  122. * TBD Error handling
  123. */
  124. }
  125. return rport;
  126. }
  127. struct bfa_fcs_rport_s *
  128. bfa_fcs_rport_lookup_by_nwwn(struct bfa_fcs_port_s *port, wwn_t rnwwn)
  129. {
  130. struct bfa_fcs_rport_s *rport;
  131. rport = bfa_fcs_port_get_rport_by_nwwn(port, rnwwn);
  132. if (rport == NULL) {
  133. /*
  134. * TBD Error handling
  135. */
  136. }
  137. return rport;
  138. }
  139. /*
  140. * This API is to set the Rport's speed. Should be used when RPSC is not
  141. * supported by the rport.
  142. */
  143. void
  144. bfa_fcs_rport_set_speed(struct bfa_fcs_rport_s *rport,
  145. enum bfa_pport_speed speed)
  146. {
  147. rport->rpf.assigned_speed = speed;
  148. /* Set this speed in f/w only if the RPSC speed is not available */
  149. if (rport->rpf.rpsc_speed == BFA_PPORT_SPEED_UNKNOWN)
  150. bfa_rport_speed(rport->bfa_rport, speed);
  151. }