diff options
Diffstat (limited to 'drivers/scsi/bfa/rport_api.c')
| -rw-r--r-- | drivers/scsi/bfa/rport_api.c | 180 |
1 files changed, 180 insertions, 0 deletions
diff --git a/drivers/scsi/bfa/rport_api.c b/drivers/scsi/bfa/rport_api.c new file mode 100644 index 000000000000..3dae1774181e --- /dev/null +++ b/drivers/scsi/bfa/rport_api.c | |||
| @@ -0,0 +1,180 @@ | |||
| 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 | |||
| 24 | BFA_TRC_FILE(FCS, RPORT_API); | ||
| 25 | |||
| 26 | /** | ||
| 27 | * rport_api.c Remote port implementation. | ||
| 28 | */ | ||
| 29 | |||
| 30 | /** | ||
| 31 | * fcs_rport_api FCS rport API. | ||
| 32 | */ | ||
| 33 | |||
| 34 | /** | ||
| 35 | * Direct API to add a target by port wwn. This interface is used, for | ||
| 36 | * example, by bios when target pwwn is known from boot lun configuration. | ||
| 37 | */ | ||
| 38 | bfa_status_t | ||
| 39 | bfa_fcs_rport_add(struct bfa_fcs_port_s *port, wwn_t *pwwn, | ||
| 40 | struct bfa_fcs_rport_s *rport, | ||
| 41 | struct bfad_rport_s *rport_drv) | ||
| 42 | { | ||
| 43 | bfa_trc(port->fcs, *pwwn); | ||
| 44 | |||
| 45 | return BFA_STATUS_OK; | ||
| 46 | } | ||
| 47 | |||
| 48 | /** | ||
| 49 | * Direct API to remove a target and its associated resources. This | ||
| 50 | * interface is used, for example, by vmware driver to remove target | ||
| 51 | * ports from the target list for a VM. | ||
| 52 | */ | ||
| 53 | bfa_status_t | ||
| 54 | bfa_fcs_rport_remove(struct bfa_fcs_rport_s *rport_in) | ||
| 55 | { | ||
| 56 | |||
| 57 | struct bfa_fcs_rport_s *rport; | ||
| 58 | |||
| 59 | bfa_trc(rport_in->fcs, rport_in->pwwn); | ||
| 60 | |||
| 61 | rport = bfa_fcs_port_get_rport_by_pwwn(rport_in->port, rport_in->pwwn); | ||
| 62 | if (rport == NULL) { | ||
| 63 | /* | ||
| 64 | * TBD Error handling | ||
| 65 | */ | ||
| 66 | bfa_trc(rport_in->fcs, rport_in->pid); | ||
| 67 | return BFA_STATUS_UNKNOWN_RWWN; | ||
| 68 | } | ||
| 69 | |||
| 70 | /* | ||
| 71 | * TBD if this remote port is online, send a logo | ||
| 72 | */ | ||
| 73 | return BFA_STATUS_OK; | ||
| 74 | |||
| 75 | } | ||
| 76 | |||
| 77 | /** | ||
| 78 | * Remote device status for display/debug. | ||
| 79 | */ | ||
| 80 | void | ||
| 81 | bfa_fcs_rport_get_attr(struct bfa_fcs_rport_s *rport, | ||
| 82 | struct bfa_rport_attr_s *rport_attr) | ||
| 83 | { | ||
| 84 | struct bfa_rport_qos_attr_s qos_attr; | ||
| 85 | struct bfa_fcs_port_s *port = rport->port; | ||
| 86 | |||
| 87 | bfa_os_memset(rport_attr, 0, sizeof(struct bfa_rport_attr_s)); | ||
| 88 | |||
| 89 | rport_attr->pid = rport->pid; | ||
| 90 | rport_attr->pwwn = rport->pwwn; | ||
| 91 | rport_attr->nwwn = rport->nwwn; | ||
| 92 | rport_attr->cos_supported = rport->fc_cos; | ||
| 93 | rport_attr->df_sz = rport->maxfrsize; | ||
| 94 | rport_attr->state = bfa_fcs_rport_get_state(rport); | ||
| 95 | rport_attr->fc_cos = rport->fc_cos; | ||
| 96 | rport_attr->cisc = rport->cisc; | ||
| 97 | rport_attr->scsi_function = rport->scsi_function; | ||
| 98 | rport_attr->curr_speed = rport->rpf.rpsc_speed; | ||
| 99 | rport_attr->assigned_speed = rport->rpf.assigned_speed; | ||
| 100 | |||
| 101 | bfa_rport_get_qos_attr(rport->bfa_rport, &qos_attr); | ||
| 102 | rport_attr->qos_attr = qos_attr; | ||
| 103 | |||
| 104 | rport_attr->trl_enforced = BFA_FALSE; | ||
| 105 | if (bfa_pport_is_ratelim(port->fcs->bfa)) { | ||
| 106 | if ((rport->rpf.rpsc_speed == BFA_PPORT_SPEED_UNKNOWN) || | ||
| 107 | (rport->rpf.rpsc_speed < | ||
| 108 | bfa_fcs_port_get_rport_max_speed(port))) | ||
| 109 | rport_attr->trl_enforced = BFA_TRUE; | ||
| 110 | } | ||
| 111 | |||
| 112 | /* | ||
| 113 | * TODO | ||
| 114 | * rport->symname | ||
| 115 | */ | ||
| 116 | } | ||
| 117 | |||
| 118 | /** | ||
| 119 | * Per remote device statistics. | ||
| 120 | */ | ||
| 121 | void | ||
| 122 | bfa_fcs_rport_get_stats(struct bfa_fcs_rport_s *rport, | ||
| 123 | struct bfa_rport_stats_s *stats) | ||
| 124 | { | ||
| 125 | *stats = rport->stats; | ||
| 126 | } | ||
| 127 | |||
| 128 | void | ||
| 129 | bfa_fcs_rport_clear_stats(struct bfa_fcs_rport_s *rport) | ||
| 130 | { | ||
| 131 | bfa_os_memset((char *)&rport->stats, 0, | ||
| 132 | sizeof(struct bfa_rport_stats_s)); | ||
| 133 | } | ||
| 134 | |||
| 135 | struct bfa_fcs_rport_s * | ||
| 136 | bfa_fcs_rport_lookup(struct bfa_fcs_port_s *port, wwn_t rpwwn) | ||
| 137 | { | ||
| 138 | struct bfa_fcs_rport_s *rport; | ||
| 139 | |||
| 140 | rport = bfa_fcs_port_get_rport_by_pwwn(port, rpwwn); | ||
| 141 | if (rport == NULL) { | ||
| 142 | /* | ||
| 143 | * TBD Error handling | ||
| 144 | */ | ||
| 145 | } | ||
| 146 | |||
| 147 | return rport; | ||
| 148 | } | ||
| 149 | |||
| 150 | struct bfa_fcs_rport_s * | ||
| 151 | bfa_fcs_rport_lookup_by_nwwn(struct bfa_fcs_port_s *port, wwn_t rnwwn) | ||
| 152 | { | ||
| 153 | struct bfa_fcs_rport_s *rport; | ||
| 154 | |||
| 155 | rport = bfa_fcs_port_get_rport_by_nwwn(port, rnwwn); | ||
| 156 | if (rport == NULL) { | ||
| 157 | /* | ||
| 158 | * TBD Error handling | ||
| 159 | */ | ||
| 160 | } | ||
| 161 | |||
| 162 | return rport; | ||
| 163 | } | ||
| 164 | |||
| 165 | /* | ||
| 166 | * This API is to set the Rport's speed. Should be used when RPSC is not | ||
| 167 | * supported by the rport. | ||
| 168 | */ | ||
| 169 | void | ||
| 170 | bfa_fcs_rport_set_speed(struct bfa_fcs_rport_s *rport, | ||
| 171 | enum bfa_pport_speed speed) | ||
| 172 | { | ||
| 173 | rport->rpf.assigned_speed = speed; | ||
| 174 | |||
| 175 | /* Set this speed in f/w only if the RPSC speed is not available */ | ||
| 176 | if (rport->rpf.rpsc_speed == BFA_PPORT_SPEED_UNKNOWN) | ||
| 177 | bfa_rport_speed(rport->bfa_rport, speed); | ||
| 178 | } | ||
| 179 | |||
| 180 | |||
