GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / scsi / bfa / rport_api.c
blobddb58b7454e0c336986000adf1d6cd35aa7bd4da
1 /*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
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
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.
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"
24 BFA_TRC_FILE(FCS, RPORT_API);
26 /**
27 * rport_api.c Remote port implementation.
30 /**
31 * fcs_rport_api FCS rport API.
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.
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)
43 bfa_trc(port->fcs, *pwwn);
45 return BFA_STATUS_OK;
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.
53 bfa_status_t
54 bfa_fcs_rport_remove(struct bfa_fcs_rport_s *rport_in)
57 struct bfa_fcs_rport_s *rport;
59 bfa_trc(rport_in->fcs, rport_in->pwwn);
61 rport = bfa_fcs_port_get_rport_by_pwwn(rport_in->port, rport_in->pwwn);
62 if (rport == NULL) {
64 * TBD Error handling
66 bfa_trc(rport_in->fcs, rport_in->pid);
67 return BFA_STATUS_UNKNOWN_RWWN;
71 * TBD if this remote port is online, send a logo
73 return BFA_STATUS_OK;
77 /**
78 * Remote device status for display/debug.
80 void
81 bfa_fcs_rport_get_attr(struct bfa_fcs_rport_s *rport,
82 struct bfa_rport_attr_s *rport_attr)
84 struct bfa_rport_qos_attr_s qos_attr;
85 struct bfa_fcs_port_s *port = rport->port;
86 enum bfa_pport_speed rport_speed = rport->rpf.rpsc_speed;
88 bfa_os_memset(rport_attr, 0, sizeof(struct bfa_rport_attr_s));
90 rport_attr->pid = rport->pid;
91 rport_attr->pwwn = rport->pwwn;
92 rport_attr->nwwn = rport->nwwn;
93 rport_attr->cos_supported = rport->fc_cos;
94 rport_attr->df_sz = rport->maxfrsize;
95 rport_attr->state = bfa_fcs_rport_get_state(rport);
96 rport_attr->fc_cos = rport->fc_cos;
97 rport_attr->cisc = rport->cisc;
98 rport_attr->scsi_function = rport->scsi_function;
99 rport_attr->curr_speed = rport->rpf.rpsc_speed;
100 rport_attr->assigned_speed = rport->rpf.assigned_speed;
102 bfa_rport_get_qos_attr(rport->bfa_rport, &qos_attr);
103 rport_attr->qos_attr = qos_attr;
105 rport_attr->trl_enforced = BFA_FALSE;
107 if (bfa_fcport_is_ratelim(port->fcs->bfa)) {
108 if (rport_speed == BFA_PPORT_SPEED_UNKNOWN) {
109 /* Use default ratelim speed setting */
110 rport_speed =
111 bfa_fcport_get_ratelim_speed(rport->fcs->bfa);
113 if (rport_speed < bfa_fcs_port_get_rport_max_speed(port))
114 rport_attr->trl_enforced = BFA_TRUE;
118 * TODO
119 * rport->symname
124 * Per remote device statistics.
126 void
127 bfa_fcs_rport_get_stats(struct bfa_fcs_rport_s *rport,
128 struct bfa_rport_stats_s *stats)
130 *stats = rport->stats;
133 void
134 bfa_fcs_rport_clear_stats(struct bfa_fcs_rport_s *rport)
136 bfa_os_memset((char *)&rport->stats, 0,
137 sizeof(struct bfa_rport_stats_s));
140 struct bfa_fcs_rport_s *
141 bfa_fcs_rport_lookup(struct bfa_fcs_port_s *port, wwn_t rpwwn)
143 struct bfa_fcs_rport_s *rport;
145 rport = bfa_fcs_port_get_rport_by_pwwn(port, rpwwn);
146 if (rport == NULL) {
148 * TBD Error handling
152 return rport;
155 struct bfa_fcs_rport_s *
156 bfa_fcs_rport_lookup_by_nwwn(struct bfa_fcs_port_s *port, wwn_t rnwwn)
158 struct bfa_fcs_rport_s *rport;
160 rport = bfa_fcs_port_get_rport_by_nwwn(port, rnwwn);
161 if (rport == NULL) {
163 * TBD Error handling
167 return rport;
171 * This API is to set the Rport's speed. Should be used when RPSC is not
172 * supported by the rport.
174 void
175 bfa_fcs_rport_set_speed(struct bfa_fcs_rport_s *rport,
176 enum bfa_pport_speed speed)
178 rport->rpf.assigned_speed = speed;
180 /* Set this speed in f/w only if the RPSC speed is not available */
181 if (rport->rpf.rpsc_speed == BFA_PPORT_SPEED_UNKNOWN)
182 bfa_rport_speed(rport->bfa_rport, speed);