• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/scsi/bfa/
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
24BFA_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 */
38bfa_status_t
39bfa_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 */
53bfa_status_t
54bfa_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 */
80void
81bfa_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	enum bfa_pport_speed rport_speed = rport->rpf.rpsc_speed;
87
88	bfa_os_memset(rport_attr, 0, sizeof(struct bfa_rport_attr_s));
89
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;
101
102	bfa_rport_get_qos_attr(rport->bfa_rport, &qos_attr);
103	rport_attr->qos_attr = qos_attr;
104
105	rport_attr->trl_enforced = BFA_FALSE;
106
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);
112		}
113		if (rport_speed < bfa_fcs_port_get_rport_max_speed(port))
114			rport_attr->trl_enforced = BFA_TRUE;
115	}
116
117	/*
118	 * TODO
119	 * rport->symname
120	 */
121}
122
123/**
124 * 	Per remote device statistics.
125 */
126void
127bfa_fcs_rport_get_stats(struct bfa_fcs_rport_s *rport,
128			struct bfa_rport_stats_s *stats)
129{
130	*stats = rport->stats;
131}
132
133void
134bfa_fcs_rport_clear_stats(struct bfa_fcs_rport_s *rport)
135{
136	bfa_os_memset((char *)&rport->stats, 0,
137			sizeof(struct bfa_rport_stats_s));
138}
139
140struct bfa_fcs_rport_s *
141bfa_fcs_rport_lookup(struct bfa_fcs_port_s *port, wwn_t rpwwn)
142{
143	struct bfa_fcs_rport_s *rport;
144
145	rport = bfa_fcs_port_get_rport_by_pwwn(port, rpwwn);
146	if (rport == NULL) {
147		/*
148		 * TBD Error handling
149		 */
150	}
151
152	return rport;
153}
154
155struct bfa_fcs_rport_s *
156bfa_fcs_rport_lookup_by_nwwn(struct bfa_fcs_port_s *port, wwn_t rnwwn)
157{
158	struct bfa_fcs_rport_s *rport;
159
160	rport = bfa_fcs_port_get_rport_by_nwwn(port, rnwwn);
161	if (rport == NULL) {
162		/*
163		 * TBD Error handling
164		 */
165	}
166
167	return rport;
168}
169
170/*
171 * This API is to set the Rport's speed. Should be used when RPSC is not
172 * supported by the rport.
173 */
174void
175bfa_fcs_rport_set_speed(struct bfa_fcs_rport_s *rport,
176			enum bfa_pport_speed speed)
177{
178	rport->rpf.assigned_speed  = speed;
179
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);
183}
184