[SCSI] bfa: Brocade BFA FC SCSI driver
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / scsi / bfa / include / fcs / bfa_fcs_lport.h
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
18 /**
19 * bfa_fcs_port.h BFA fcs port module public interface
20 */
21
22 #ifndef __BFA_FCS_PORT_H__
23 #define __BFA_FCS_PORT_H__
24
25 #include <defs/bfa_defs_status.h>
26 #include <defs/bfa_defs_port.h>
27 #include <defs/bfa_defs_pport.h>
28 #include <defs/bfa_defs_rport.h>
29 #include <cs/bfa_q.h>
30 #include <bfa_svc.h>
31 #include <cs/bfa_wc.h>
32
33 struct bfa_fcs_s;
34 struct bfa_fcs_fabric_s;
35
36 /*
37 * @todo : need to move to a global config file.
38 * Maximum Vports supported per physical port or vf.
39 */
40 #define BFA_FCS_MAX_VPORTS_SUPP_CB 255
41 #define BFA_FCS_MAX_VPORTS_SUPP_CT 191
42
43 /*
44 * @todo : need to move to a global config file.
45 * Maximum Rports supported per port (physical/logical).
46 */
47 #define BFA_FCS_MAX_RPORTS_SUPP 256 /* @todo : tentative value */
48
49
50 struct bfa_fcs_port_ns_s {
51 bfa_sm_t sm; /* state machine */
52 struct bfa_timer_s timer;
53 struct bfa_fcs_port_s *port; /* parent port */
54 struct bfa_fcxp_s *fcxp;
55 struct bfa_fcxp_wqe_s fcxp_wqe;
56 };
57
58
59 struct bfa_fcs_port_scn_s {
60 bfa_sm_t sm; /* state machine */
61 struct bfa_timer_s timer;
62 struct bfa_fcs_port_s *port; /* parent port */
63 struct bfa_fcxp_s *fcxp;
64 struct bfa_fcxp_wqe_s fcxp_wqe;
65 };
66
67
68 struct bfa_fcs_port_fdmi_s {
69 bfa_sm_t sm; /* state machine */
70 struct bfa_timer_s timer;
71 struct bfa_fcs_port_ms_s *ms; /* parent ms */
72 struct bfa_fcxp_s *fcxp;
73 struct bfa_fcxp_wqe_s fcxp_wqe;
74 u8 retry_cnt; /* retry count */
75 u8 rsvd[3];
76 };
77
78
79 struct bfa_fcs_port_ms_s {
80 bfa_sm_t sm; /* state machine */
81 struct bfa_timer_s timer;
82 struct bfa_fcs_port_s *port; /* parent port */
83 struct bfa_fcxp_s *fcxp;
84 struct bfa_fcxp_wqe_s fcxp_wqe;
85 struct bfa_fcs_port_fdmi_s fdmi; /* FDMI component of MS */
86 u8 retry_cnt; /* retry count */
87 u8 rsvd[3];
88 };
89
90
91 struct bfa_fcs_port_fab_s {
92 struct bfa_fcs_port_ns_s ns; /* NS component of port */
93 struct bfa_fcs_port_scn_s scn; /* scn component of port */
94 struct bfa_fcs_port_ms_s ms; /* MS component of port */
95 };
96
97
98
99 #define MAX_ALPA_COUNT 127
100
101 struct bfa_fcs_port_loop_s {
102 u8 num_alpa; /* Num of ALPA entries in the map */
103 u8 alpa_pos_map[MAX_ALPA_COUNT]; /* ALPA Positional
104 *Map */
105 struct bfa_fcs_port_s *port; /* parent port */
106 };
107
108
109
110 struct bfa_fcs_port_n2n_s {
111 u32 rsvd;
112 u16 reply_oxid; /* ox_id from the req flogi to be
113 *used in flogi acc */
114 wwn_t rem_port_wwn; /* Attached port's wwn */
115 };
116
117
118 union bfa_fcs_port_topo_u {
119 struct bfa_fcs_port_fab_s pfab;
120 struct bfa_fcs_port_loop_s ploop;
121 struct bfa_fcs_port_n2n_s pn2n;
122 };
123
124
125 struct bfa_fcs_port_s {
126 struct list_head qe; /* used by port/vport */
127 bfa_sm_t sm; /* state machine */
128 struct bfa_fcs_fabric_s *fabric; /* parent fabric */
129 struct bfa_port_cfg_s port_cfg; /* port configuration */
130 struct bfa_timer_s link_timer; /* timer for link offline */
131 u32 pid : 24; /* FC address */
132 u8 lp_tag; /* lport tag */
133 u16 num_rports; /* Num of r-ports */
134 struct list_head rport_q; /* queue of discovered r-ports */
135 struct bfa_fcs_s *fcs; /* FCS instance */
136 union bfa_fcs_port_topo_u port_topo; /* fabric/loop/n2n details */
137 struct bfad_port_s *bfad_port; /* driver peer instance */
138 struct bfa_fcs_vport_s *vport; /* NULL for base ports */
139 struct bfa_fcxp_s *fcxp;
140 struct bfa_fcxp_wqe_s fcxp_wqe;
141 struct bfa_port_stats_s stats;
142 struct bfa_wc_s wc; /* waiting counter for events */
143 };
144
145 #define bfa_fcs_lport_t struct bfa_fcs_port_s
146
147 /**
148 * Symbolic Name related defines
149 * Total bytes 255.
150 * Physical Port's symbolic name 128 bytes.
151 * For Vports, Vport's symbolic name is appended to the Physical port's
152 * Symbolic Name.
153 *
154 * Physical Port's symbolic name Format : (Total 128 bytes)
155 * Adapter Model number/name : 12 bytes
156 * Driver Version : 10 bytes
157 * Host Machine Name : 30 bytes
158 * Host OS Info : 48 bytes
159 * Host OS PATCH Info : 16 bytes
160 * ( remaining 12 bytes reserved to be used for separator)
161 */
162 #define BFA_FCS_PORT_SYMBNAME_SEPARATOR " | "
163
164 #define BFA_FCS_PORT_SYMBNAME_MODEL_SZ 12
165 #define BFA_FCS_PORT_SYMBNAME_VERSION_SZ 10
166 #define BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ 30
167 #define BFA_FCS_PORT_SYMBNAME_OSINFO_SZ 48
168 #define BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ 16
169
170 /**
171 * Get FC port ID for a logical port.
172 */
173 #define bfa_fcs_port_get_fcid(_lport) ((_lport)->pid)
174 #define bfa_fcs_port_get_pwwn(_lport) ((_lport)->port_cfg.pwwn)
175 #define bfa_fcs_port_get_nwwn(_lport) ((_lport)->port_cfg.nwwn)
176 #define bfa_fcs_port_get_psym_name(_lport) ((_lport)->port_cfg.sym_name)
177 #define bfa_fcs_port_is_initiator(_lport) \
178 ((_lport)->port_cfg.roles & BFA_PORT_ROLE_FCP_IM)
179 #define bfa_fcs_port_is_target(_lport) \
180 ((_lport)->port_cfg.roles & BFA_PORT_ROLE_FCP_TM)
181 #define bfa_fcs_port_get_nrports(_lport) \
182 ((_lport) ? (_lport)->num_rports : 0)
183
184 static inline struct bfad_port_s *
185 bfa_fcs_port_get_drvport(struct bfa_fcs_port_s *port)
186 {
187 return port->bfad_port;
188 }
189
190
191 #define bfa_fcs_port_get_opertype(_lport) (_lport)->fabric->oper_type
192
193
194 #define bfa_fcs_port_get_fabric_name(_lport) (_lport)->fabric->fabric_name
195
196
197 #define bfa_fcs_port_get_fabric_ipaddr(_lport) (_lport)->fabric->fabric_ip_addr
198
199 /**
200 * bfa fcs port public functions
201 */
202 void bfa_fcs_cfg_base_port(struct bfa_fcs_s *fcs,
203 struct bfa_port_cfg_s *port_cfg);
204 struct bfa_fcs_port_s *bfa_fcs_get_base_port(struct bfa_fcs_s *fcs);
205 void bfa_fcs_port_get_rports(struct bfa_fcs_port_s *port,
206 wwn_t rport_wwns[], int *nrports);
207
208 wwn_t bfa_fcs_port_get_rport(struct bfa_fcs_port_s *port, wwn_t wwn,
209 int index, int nrports, bfa_boolean_t bwwn);
210
211 struct bfa_fcs_port_s *bfa_fcs_lookup_port(struct bfa_fcs_s *fcs,
212 u16 vf_id, wwn_t lpwwn);
213
214 void bfa_fcs_port_get_info(struct bfa_fcs_port_s *port,
215 struct bfa_port_info_s *port_info);
216 void bfa_fcs_port_get_attr(struct bfa_fcs_port_s *port,
217 struct bfa_port_attr_s *port_attr);
218 void bfa_fcs_port_get_stats(struct bfa_fcs_port_s *fcs_port,
219 struct bfa_port_stats_s *port_stats);
220 void bfa_fcs_port_clear_stats(struct bfa_fcs_port_s *fcs_port);
221 enum bfa_pport_speed bfa_fcs_port_get_rport_max_speed(
222 struct bfa_fcs_port_s *port);
223 void bfa_fcs_port_enable_ipfc_roles(struct bfa_fcs_port_s *fcs_port);
224 void bfa_fcs_port_disable_ipfc_roles(struct bfa_fcs_port_s *fcs_port);
225
226 #endif /* __BFA_FCS_PORT_H__ */