blob: b7e253451654774f89c48cd6d428a557690a222f [file] [log] [blame]
Jing Huang7725ccf2009-09-23 17:46:15 -07001/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07002 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
Jing Huang7725ccf2009-09-23 17:46:15 -07003 * 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 * fcbuild.c - FC link service frame building and parsing routines
19 */
20
Maggie Zhangf16a1752010-12-09 19:12:32 -080021#include "bfad_drv.h"
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070022#include "bfa_fcbuild.h"
Jing Huang7725ccf2009-09-23 17:46:15 -070023
24/*
25 * static build functions
26 */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070027static void fc_els_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
Maggie50444a32010-11-29 18:26:32 -080028 __be16 ox_id);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070029static void fc_bls_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
Maggie50444a32010-11-29 18:26:32 -080030 __be16 ox_id);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070031static struct fchs_s fc_els_req_tmpl;
32static struct fchs_s fc_els_rsp_tmpl;
33static struct fchs_s fc_bls_req_tmpl;
34static struct fchs_s fc_bls_rsp_tmpl;
Jing Huang7725ccf2009-09-23 17:46:15 -070035static struct fc_ba_acc_s ba_acc_tmpl;
36static struct fc_logi_s plogi_tmpl;
37static struct fc_prli_s prli_tmpl;
38static struct fc_rrq_s rrq_tmpl;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070039static struct fchs_s fcp_fchs_tmpl;
Jing Huang7725ccf2009-09-23 17:46:15 -070040
41void
42fcbuild_init(void)
43{
44 /*
45 * fc_els_req_tmpl
46 */
47 fc_els_req_tmpl.routing = FC_RTG_EXT_LINK;
48 fc_els_req_tmpl.cat_info = FC_CAT_LD_REQUEST;
49 fc_els_req_tmpl.type = FC_TYPE_ELS;
50 fc_els_req_tmpl.f_ctl =
Maggie Zhangf16a1752010-12-09 19:12:32 -080051 bfa_hton3b(FCTL_SEQ_INI | FCTL_FS_EXCH | FCTL_END_SEQ |
Jing Huang7725ccf2009-09-23 17:46:15 -070052 FCTL_SI_XFER);
53 fc_els_req_tmpl.rx_id = FC_RXID_ANY;
54
55 /*
56 * fc_els_rsp_tmpl
57 */
58 fc_els_rsp_tmpl.routing = FC_RTG_EXT_LINK;
59 fc_els_rsp_tmpl.cat_info = FC_CAT_LD_REPLY;
60 fc_els_rsp_tmpl.type = FC_TYPE_ELS;
61 fc_els_rsp_tmpl.f_ctl =
Maggie Zhangf16a1752010-12-09 19:12:32 -080062 bfa_hton3b(FCTL_EC_RESP | FCTL_SEQ_INI | FCTL_LS_EXCH |
Jing Huang7725ccf2009-09-23 17:46:15 -070063 FCTL_END_SEQ | FCTL_SI_XFER);
64 fc_els_rsp_tmpl.rx_id = FC_RXID_ANY;
65
66 /*
67 * fc_bls_req_tmpl
68 */
69 fc_bls_req_tmpl.routing = FC_RTG_BASIC_LINK;
70 fc_bls_req_tmpl.type = FC_TYPE_BLS;
Maggie Zhangf16a1752010-12-09 19:12:32 -080071 fc_bls_req_tmpl.f_ctl = bfa_hton3b(FCTL_END_SEQ | FCTL_SI_XFER);
Jing Huang7725ccf2009-09-23 17:46:15 -070072 fc_bls_req_tmpl.rx_id = FC_RXID_ANY;
73
74 /*
75 * fc_bls_rsp_tmpl
76 */
77 fc_bls_rsp_tmpl.routing = FC_RTG_BASIC_LINK;
78 fc_bls_rsp_tmpl.cat_info = FC_CAT_BA_ACC;
79 fc_bls_rsp_tmpl.type = FC_TYPE_BLS;
80 fc_bls_rsp_tmpl.f_ctl =
Maggie Zhangf16a1752010-12-09 19:12:32 -080081 bfa_hton3b(FCTL_EC_RESP | FCTL_SEQ_INI | FCTL_LS_EXCH |
Jing Huang7725ccf2009-09-23 17:46:15 -070082 FCTL_END_SEQ | FCTL_SI_XFER);
83 fc_bls_rsp_tmpl.rx_id = FC_RXID_ANY;
84
85 /*
86 * ba_acc_tmpl
87 */
88 ba_acc_tmpl.seq_id_valid = 0;
89 ba_acc_tmpl.low_seq_cnt = 0;
90 ba_acc_tmpl.high_seq_cnt = 0xFFFF;
91
92 /*
93 * plogi_tmpl
94 */
95 plogi_tmpl.csp.verhi = FC_PH_VER_PH_3;
96 plogi_tmpl.csp.verlo = FC_PH_VER_4_3;
Jing Huangba816ea2010-10-18 17:10:50 -070097 plogi_tmpl.csp.bbcred = cpu_to_be16(0x0004);
Jing Huang7725ccf2009-09-23 17:46:15 -070098 plogi_tmpl.csp.ciro = 0x1;
99 plogi_tmpl.csp.cisc = 0x0;
100 plogi_tmpl.csp.altbbcred = 0x0;
Jing Huangba816ea2010-10-18 17:10:50 -0700101 plogi_tmpl.csp.conseq = cpu_to_be16(0x00FF);
102 plogi_tmpl.csp.ro_bitmap = cpu_to_be16(0x0002);
103 plogi_tmpl.csp.e_d_tov = cpu_to_be32(2000);
Jing Huang7725ccf2009-09-23 17:46:15 -0700104
105 plogi_tmpl.class3.class_valid = 1;
106 plogi_tmpl.class3.sequential = 1;
107 plogi_tmpl.class3.conseq = 0xFF;
108 plogi_tmpl.class3.ospx = 1;
109
110 /*
111 * prli_tmpl
112 */
113 prli_tmpl.command = FC_ELS_PRLI;
114 prli_tmpl.pglen = 0x10;
Jing Huangba816ea2010-10-18 17:10:50 -0700115 prli_tmpl.pagebytes = cpu_to_be16(0x0014);
Jing Huang7725ccf2009-09-23 17:46:15 -0700116 prli_tmpl.parampage.type = FC_TYPE_FCP;
117 prli_tmpl.parampage.imagepair = 1;
118 prli_tmpl.parampage.servparams.rxrdisab = 1;
119
120 /*
121 * rrq_tmpl
122 */
123 rrq_tmpl.els_cmd.els_code = FC_ELS_RRQ;
124
125 /*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700126 * fcp_struct fchs_s mpl
Jing Huang7725ccf2009-09-23 17:46:15 -0700127 */
128 fcp_fchs_tmpl.routing = FC_RTG_FC4_DEV_DATA;
129 fcp_fchs_tmpl.cat_info = FC_CAT_UNSOLICIT_CMD;
130 fcp_fchs_tmpl.type = FC_TYPE_FCP;
131 fcp_fchs_tmpl.f_ctl =
Maggie Zhangf16a1752010-12-09 19:12:32 -0800132 bfa_hton3b(FCTL_FS_EXCH | FCTL_END_SEQ | FCTL_SI_XFER);
Jing Huang7725ccf2009-09-23 17:46:15 -0700133 fcp_fchs_tmpl.seq_id = 1;
134 fcp_fchs_tmpl.rx_id = FC_RXID_ANY;
135}
136
137static void
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700138fc_gs_fchdr_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u32 ox_id)
Jing Huang7725ccf2009-09-23 17:46:15 -0700139{
Jing Huang6a18b162010-10-18 17:08:54 -0700140 memset(fchs, 0, sizeof(struct fchs_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700141
142 fchs->routing = FC_RTG_FC4_DEV_DATA;
143 fchs->cat_info = FC_CAT_UNSOLICIT_CTRL;
144 fchs->type = FC_TYPE_SERVICES;
145 fchs->f_ctl =
Maggie Zhangf16a1752010-12-09 19:12:32 -0800146 bfa_hton3b(FCTL_SEQ_INI | FCTL_FS_EXCH | FCTL_END_SEQ |
Jing Huang7725ccf2009-09-23 17:46:15 -0700147 FCTL_SI_XFER);
148 fchs->rx_id = FC_RXID_ANY;
149 fchs->d_id = (d_id);
150 fchs->s_id = (s_id);
Jing Huangba816ea2010-10-18 17:10:50 -0700151 fchs->ox_id = cpu_to_be16(ox_id);
Jing Huang7725ccf2009-09-23 17:46:15 -0700152
Jing Huang5fbe25c2010-10-18 17:17:23 -0700153 /*
Jing Huang7725ccf2009-09-23 17:46:15 -0700154 * @todo no need to set ox_id for request
155 * no need to set rx_id for response
156 */
157}
158
159void
Maggie50444a32010-11-29 18:26:32 -0800160fc_els_req_build(struct fchs_s *fchs, u32 d_id, u32 s_id, __be16 ox_id)
Jing Huang7725ccf2009-09-23 17:46:15 -0700161{
Jing Huang6a18b162010-10-18 17:08:54 -0700162 memcpy(fchs, &fc_els_req_tmpl, sizeof(struct fchs_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700163 fchs->d_id = (d_id);
164 fchs->s_id = (s_id);
Jing Huangba816ea2010-10-18 17:10:50 -0700165 fchs->ox_id = cpu_to_be16(ox_id);
Jing Huang7725ccf2009-09-23 17:46:15 -0700166}
167
168static void
Maggie50444a32010-11-29 18:26:32 -0800169fc_els_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id, __be16 ox_id)
Jing Huang7725ccf2009-09-23 17:46:15 -0700170{
Jing Huang6a18b162010-10-18 17:08:54 -0700171 memcpy(fchs, &fc_els_rsp_tmpl, sizeof(struct fchs_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700172 fchs->d_id = d_id;
173 fchs->s_id = s_id;
174 fchs->ox_id = ox_id;
175}
176
177enum fc_parse_status
178fc_els_rsp_parse(struct fchs_s *fchs, int len)
179{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700180 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
181 struct fc_ls_rjt_s *ls_rjt = (struct fc_ls_rjt_s *) els_cmd;
Jing Huang7725ccf2009-09-23 17:46:15 -0700182
183 len = len;
184
185 switch (els_cmd->els_code) {
186 case FC_ELS_LS_RJT:
187 if (ls_rjt->reason_code == FC_LS_RJT_RSN_LOGICAL_BUSY)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700188 return FC_PARSE_BUSY;
Jing Huang7725ccf2009-09-23 17:46:15 -0700189 else
Jing Huangf8ceafd2009-09-25 12:29:54 -0700190 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700191
192 case FC_ELS_ACC:
Jing Huangf8ceafd2009-09-25 12:29:54 -0700193 return FC_PARSE_OK;
Jing Huang7725ccf2009-09-23 17:46:15 -0700194 }
Jing Huangf8ceafd2009-09-25 12:29:54 -0700195 return FC_PARSE_OK;
Jing Huang7725ccf2009-09-23 17:46:15 -0700196}
197
198static void
Maggie50444a32010-11-29 18:26:32 -0800199fc_bls_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id, __be16 ox_id)
Jing Huang7725ccf2009-09-23 17:46:15 -0700200{
Jing Huang6a18b162010-10-18 17:08:54 -0700201 memcpy(fchs, &fc_bls_rsp_tmpl, sizeof(struct fchs_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700202 fchs->d_id = d_id;
203 fchs->s_id = s_id;
204 fchs->ox_id = ox_id;
205}
206
207static u16
208fc_plogi_x_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
Maggie50444a32010-11-29 18:26:32 -0800209 __be16 ox_id, wwn_t port_name, wwn_t node_name,
Jing Huang7725ccf2009-09-23 17:46:15 -0700210 u16 pdu_size, u8 els_code)
211{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700212 struct fc_logi_s *plogi = (struct fc_logi_s *) (pld);
Jing Huang7725ccf2009-09-23 17:46:15 -0700213
Jing Huang6a18b162010-10-18 17:08:54 -0700214 memcpy(plogi, &plogi_tmpl, sizeof(struct fc_logi_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700215
216 plogi->els_cmd.els_code = els_code;
217 if (els_code == FC_ELS_PLOGI)
218 fc_els_req_build(fchs, d_id, s_id, ox_id);
219 else
220 fc_els_rsp_build(fchs, d_id, s_id, ox_id);
221
Jing Huangba816ea2010-10-18 17:10:50 -0700222 plogi->csp.rxsz = plogi->class3.rxsz = cpu_to_be16(pdu_size);
Jing Huang7725ccf2009-09-23 17:46:15 -0700223
Jing Huang6a18b162010-10-18 17:08:54 -0700224 memcpy(&plogi->port_name, &port_name, sizeof(wwn_t));
225 memcpy(&plogi->node_name, &node_name, sizeof(wwn_t));
Jing Huang7725ccf2009-09-23 17:46:15 -0700226
Jing Huangf8ceafd2009-09-25 12:29:54 -0700227 return sizeof(struct fc_logi_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700228}
229
230u16
231fc_flogi_build(struct fchs_s *fchs, struct fc_logi_s *flogi, u32 s_id,
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700232 u16 ox_id, wwn_t port_name, wwn_t node_name, u16 pdu_size,
233 u8 set_npiv, u8 set_auth, u16 local_bb_credits)
Jing Huang7725ccf2009-09-23 17:46:15 -0700234{
Maggie Zhangf16a1752010-12-09 19:12:32 -0800235 u32 d_id = bfa_hton3b(FC_FABRIC_PORT);
Maggie50444a32010-11-29 18:26:32 -0800236 __be32 *vvl_info;
Jing Huang7725ccf2009-09-23 17:46:15 -0700237
Jing Huang6a18b162010-10-18 17:08:54 -0700238 memcpy(flogi, &plogi_tmpl, sizeof(struct fc_logi_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700239
240 flogi->els_cmd.els_code = FC_ELS_FLOGI;
241 fc_els_req_build(fchs, d_id, s_id, ox_id);
242
Jing Huangba816ea2010-10-18 17:10:50 -0700243 flogi->csp.rxsz = flogi->class3.rxsz = cpu_to_be16(pdu_size);
Jing Huang7725ccf2009-09-23 17:46:15 -0700244 flogi->port_name = port_name;
245 flogi->node_name = node_name;
246
247 /*
248 * Set the NPIV Capability Bit ( word 1, bit 31) of Common
249 * Service Parameters.
250 */
251 flogi->csp.ciro = set_npiv;
252
253 /* set AUTH capability */
254 flogi->csp.security = set_auth;
255
Jing Huangba816ea2010-10-18 17:10:50 -0700256 flogi->csp.bbcred = cpu_to_be16(local_bb_credits);
Jing Huang7725ccf2009-09-23 17:46:15 -0700257
258 /* Set brcd token in VVL */
259 vvl_info = (u32 *)&flogi->vvl[0];
260
261 /* set the flag to indicate the presence of VVL */
262 flogi->csp.npiv_supp = 1; /* @todo. field name is not correct */
Jing Huangba816ea2010-10-18 17:10:50 -0700263 vvl_info[0] = cpu_to_be32(FLOGI_VVL_BRCD);
Jing Huang7725ccf2009-09-23 17:46:15 -0700264
Jing Huangf8ceafd2009-09-25 12:29:54 -0700265 return sizeof(struct fc_logi_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700266}
267
268u16
269fc_flogi_acc_build(struct fchs_s *fchs, struct fc_logi_s *flogi, u32 s_id,
Maggie50444a32010-11-29 18:26:32 -0800270 __be16 ox_id, wwn_t port_name, wwn_t node_name,
Jing Huang7725ccf2009-09-23 17:46:15 -0700271 u16 pdu_size, u16 local_bb_credits)
272{
273 u32 d_id = 0;
274
Jing Huang6a18b162010-10-18 17:08:54 -0700275 memcpy(flogi, &plogi_tmpl, sizeof(struct fc_logi_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700276 fc_els_rsp_build(fchs, d_id, s_id, ox_id);
277
278 flogi->els_cmd.els_code = FC_ELS_ACC;
Jing Huangba816ea2010-10-18 17:10:50 -0700279 flogi->csp.rxsz = flogi->class3.rxsz = cpu_to_be16(pdu_size);
Jing Huang7725ccf2009-09-23 17:46:15 -0700280 flogi->port_name = port_name;
281 flogi->node_name = node_name;
282
Jing Huangba816ea2010-10-18 17:10:50 -0700283 flogi->csp.bbcred = cpu_to_be16(local_bb_credits);
Jing Huang7725ccf2009-09-23 17:46:15 -0700284
Jing Huangf8ceafd2009-09-25 12:29:54 -0700285 return sizeof(struct fc_logi_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700286}
287
288u16
289fc_fdisc_build(struct fchs_s *fchs, struct fc_logi_s *flogi, u32 s_id,
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700290 u16 ox_id, wwn_t port_name, wwn_t node_name, u16 pdu_size)
Jing Huang7725ccf2009-09-23 17:46:15 -0700291{
Maggie Zhangf16a1752010-12-09 19:12:32 -0800292 u32 d_id = bfa_hton3b(FC_FABRIC_PORT);
Jing Huang7725ccf2009-09-23 17:46:15 -0700293
Jing Huang6a18b162010-10-18 17:08:54 -0700294 memcpy(flogi, &plogi_tmpl, sizeof(struct fc_logi_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700295
296 flogi->els_cmd.els_code = FC_ELS_FDISC;
297 fc_els_req_build(fchs, d_id, s_id, ox_id);
298
Jing Huangba816ea2010-10-18 17:10:50 -0700299 flogi->csp.rxsz = flogi->class3.rxsz = cpu_to_be16(pdu_size);
Jing Huang7725ccf2009-09-23 17:46:15 -0700300 flogi->port_name = port_name;
301 flogi->node_name = node_name;
302
Jing Huangf8ceafd2009-09-25 12:29:54 -0700303 return sizeof(struct fc_logi_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700304}
305
306u16
307fc_plogi_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
308 u16 ox_id, wwn_t port_name, wwn_t node_name,
309 u16 pdu_size)
310{
311 return fc_plogi_x_build(fchs, pld, d_id, s_id, ox_id, port_name,
312 node_name, pdu_size, FC_ELS_PLOGI);
313}
314
315u16
316fc_plogi_acc_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
317 u16 ox_id, wwn_t port_name, wwn_t node_name,
318 u16 pdu_size)
319{
320 return fc_plogi_x_build(fchs, pld, d_id, s_id, ox_id, port_name,
321 node_name, pdu_size, FC_ELS_ACC);
322}
323
324enum fc_parse_status
325fc_plogi_rsp_parse(struct fchs_s *fchs, int len, wwn_t port_name)
326{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700327 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
328 struct fc_logi_s *plogi;
329 struct fc_ls_rjt_s *ls_rjt;
Jing Huang7725ccf2009-09-23 17:46:15 -0700330
331 switch (els_cmd->els_code) {
332 case FC_ELS_LS_RJT:
333 ls_rjt = (struct fc_ls_rjt_s *) (fchs + 1);
334 if (ls_rjt->reason_code == FC_LS_RJT_RSN_LOGICAL_BUSY)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700335 return FC_PARSE_BUSY;
Jing Huang7725ccf2009-09-23 17:46:15 -0700336 else
Jing Huangf8ceafd2009-09-25 12:29:54 -0700337 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700338 case FC_ELS_ACC:
339 plogi = (struct fc_logi_s *) (fchs + 1);
340 if (len < sizeof(struct fc_logi_s))
Jing Huangf8ceafd2009-09-25 12:29:54 -0700341 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700342
343 if (!wwn_is_equal(plogi->port_name, port_name))
Jing Huangf8ceafd2009-09-25 12:29:54 -0700344 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700345
346 if (!plogi->class3.class_valid)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700347 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700348
Jing Huangba816ea2010-10-18 17:10:50 -0700349 if (be16_to_cpu(plogi->class3.rxsz) < (FC_MIN_PDUSZ))
Jing Huangf8ceafd2009-09-25 12:29:54 -0700350 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700351
Jing Huangf8ceafd2009-09-25 12:29:54 -0700352 return FC_PARSE_OK;
Jing Huang7725ccf2009-09-23 17:46:15 -0700353 default:
Jing Huangf8ceafd2009-09-25 12:29:54 -0700354 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700355 }
356}
357
358enum fc_parse_status
359fc_plogi_parse(struct fchs_s *fchs)
360{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700361 struct fc_logi_s *plogi = (struct fc_logi_s *) (fchs + 1);
Jing Huang7725ccf2009-09-23 17:46:15 -0700362
363 if (plogi->class3.class_valid != 1)
364 return FC_PARSE_FAILURE;
365
Jing Huangba816ea2010-10-18 17:10:50 -0700366 if ((be16_to_cpu(plogi->class3.rxsz) < FC_MIN_PDUSZ)
367 || (be16_to_cpu(plogi->class3.rxsz) > FC_MAX_PDUSZ)
Jing Huang7725ccf2009-09-23 17:46:15 -0700368 || (plogi->class3.rxsz == 0))
Jing Huangf8ceafd2009-09-25 12:29:54 -0700369 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700370
371 return FC_PARSE_OK;
372}
373
374u16
375fc_prli_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
376 u16 ox_id)
377{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700378 struct fc_prli_s *prli = (struct fc_prli_s *) (pld);
Jing Huang7725ccf2009-09-23 17:46:15 -0700379
380 fc_els_req_build(fchs, d_id, s_id, ox_id);
Jing Huang6a18b162010-10-18 17:08:54 -0700381 memcpy(prli, &prli_tmpl, sizeof(struct fc_prli_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700382
383 prli->command = FC_ELS_PRLI;
384 prli->parampage.servparams.initiator = 1;
385 prli->parampage.servparams.retry = 1;
386 prli->parampage.servparams.rec_support = 1;
387 prli->parampage.servparams.task_retry_id = 0;
388 prli->parampage.servparams.confirm = 1;
389
Jing Huangf8ceafd2009-09-25 12:29:54 -0700390 return sizeof(struct fc_prli_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700391}
392
393u16
394fc_prli_acc_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
Maggie50444a32010-11-29 18:26:32 -0800395 __be16 ox_id, enum bfa_lport_role role)
Jing Huang7725ccf2009-09-23 17:46:15 -0700396{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700397 struct fc_prli_s *prli = (struct fc_prli_s *) (pld);
Jing Huang7725ccf2009-09-23 17:46:15 -0700398
399 fc_els_rsp_build(fchs, d_id, s_id, ox_id);
Jing Huang6a18b162010-10-18 17:08:54 -0700400 memcpy(prli, &prli_tmpl, sizeof(struct fc_prli_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700401
402 prli->command = FC_ELS_ACC;
403
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700404 prli->parampage.servparams.initiator = 1;
Jing Huang7725ccf2009-09-23 17:46:15 -0700405
406 prli->parampage.rspcode = FC_PRLI_ACC_XQTD;
407
Jing Huangf8ceafd2009-09-25 12:29:54 -0700408 return sizeof(struct fc_prli_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700409}
410
411enum fc_parse_status
412fc_prli_rsp_parse(struct fc_prli_s *prli, int len)
413{
414 if (len < sizeof(struct fc_prli_s))
Jing Huangf8ceafd2009-09-25 12:29:54 -0700415 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700416
417 if (prli->command != FC_ELS_ACC)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700418 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700419
420 if ((prli->parampage.rspcode != FC_PRLI_ACC_XQTD)
421 && (prli->parampage.rspcode != FC_PRLI_ACC_PREDEF_IMG))
Jing Huangf8ceafd2009-09-25 12:29:54 -0700422 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700423
424 if (prli->parampage.servparams.target != 1)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700425 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700426
Jing Huangf8ceafd2009-09-25 12:29:54 -0700427 return FC_PARSE_OK;
Jing Huang7725ccf2009-09-23 17:46:15 -0700428}
429
430enum fc_parse_status
431fc_prli_parse(struct fc_prli_s *prli)
432{
433 if (prli->parampage.type != FC_TYPE_FCP)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700434 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700435
436 if (!prli->parampage.imagepair)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700437 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700438
439 if (!prli->parampage.servparams.initiator)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700440 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700441
Jing Huangf8ceafd2009-09-25 12:29:54 -0700442 return FC_PARSE_OK;
Jing Huang7725ccf2009-09-23 17:46:15 -0700443}
444
445u16
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700446fc_logo_build(struct fchs_s *fchs, struct fc_logo_s *logo, u32 d_id, u32 s_id,
447 u16 ox_id, wwn_t port_name)
Jing Huang7725ccf2009-09-23 17:46:15 -0700448{
449 fc_els_req_build(fchs, d_id, s_id, ox_id);
450
Jing Huang6a18b162010-10-18 17:08:54 -0700451 memset(logo, '\0', sizeof(struct fc_logo_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700452 logo->els_cmd.els_code = FC_ELS_LOGO;
453 logo->nport_id = (s_id);
454 logo->orig_port_name = port_name;
455
Jing Huangf8ceafd2009-09-25 12:29:54 -0700456 return sizeof(struct fc_logo_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700457}
458
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800459static u16
Jing Huang7725ccf2009-09-23 17:46:15 -0700460fc_adisc_x_build(struct fchs_s *fchs, struct fc_adisc_s *adisc, u32 d_id,
Maggie50444a32010-11-29 18:26:32 -0800461 u32 s_id, __be16 ox_id, wwn_t port_name,
Jing Huang7725ccf2009-09-23 17:46:15 -0700462 wwn_t node_name, u8 els_code)
463{
Jing Huang6a18b162010-10-18 17:08:54 -0700464 memset(adisc, '\0', sizeof(struct fc_adisc_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700465
466 adisc->els_cmd.els_code = els_code;
467
468 if (els_code == FC_ELS_ADISC)
469 fc_els_req_build(fchs, d_id, s_id, ox_id);
470 else
471 fc_els_rsp_build(fchs, d_id, s_id, ox_id);
472
473 adisc->orig_HA = 0;
474 adisc->orig_port_name = port_name;
475 adisc->orig_node_name = node_name;
476 adisc->nport_id = (s_id);
477
Jing Huangf8ceafd2009-09-25 12:29:54 -0700478 return sizeof(struct fc_adisc_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700479}
480
481u16
482fc_adisc_build(struct fchs_s *fchs, struct fc_adisc_s *adisc, u32 d_id,
Maggie50444a32010-11-29 18:26:32 -0800483 u32 s_id, __be16 ox_id, wwn_t port_name, wwn_t node_name)
Jing Huang7725ccf2009-09-23 17:46:15 -0700484{
485 return fc_adisc_x_build(fchs, adisc, d_id, s_id, ox_id, port_name,
486 node_name, FC_ELS_ADISC);
487}
488
489u16
490fc_adisc_acc_build(struct fchs_s *fchs, struct fc_adisc_s *adisc, u32 d_id,
Maggie50444a32010-11-29 18:26:32 -0800491 u32 s_id, __be16 ox_id, wwn_t port_name,
Jing Huang7725ccf2009-09-23 17:46:15 -0700492 wwn_t node_name)
493{
494 return fc_adisc_x_build(fchs, adisc, d_id, s_id, ox_id, port_name,
495 node_name, FC_ELS_ACC);
496}
497
498enum fc_parse_status
499fc_adisc_rsp_parse(struct fc_adisc_s *adisc, int len, wwn_t port_name,
500 wwn_t node_name)
501{
502
503 if (len < sizeof(struct fc_adisc_s))
Jing Huangf8ceafd2009-09-25 12:29:54 -0700504 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700505
506 if (adisc->els_cmd.els_code != FC_ELS_ACC)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700507 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700508
509 if (!wwn_is_equal(adisc->orig_port_name, port_name))
Jing Huangf8ceafd2009-09-25 12:29:54 -0700510 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700511
Jing Huangf8ceafd2009-09-25 12:29:54 -0700512 return FC_PARSE_OK;
Jing Huang7725ccf2009-09-23 17:46:15 -0700513}
514
515enum fc_parse_status
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700516fc_adisc_parse(struct fchs_s *fchs, void *pld, u32 host_dap, wwn_t node_name,
517 wwn_t port_name)
Jing Huang7725ccf2009-09-23 17:46:15 -0700518{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700519 struct fc_adisc_s *adisc = (struct fc_adisc_s *) pld;
Jing Huang7725ccf2009-09-23 17:46:15 -0700520
521 if (adisc->els_cmd.els_code != FC_ELS_ACC)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700522 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700523
524 if ((adisc->nport_id == (host_dap))
525 && wwn_is_equal(adisc->orig_port_name, port_name)
526 && wwn_is_equal(adisc->orig_node_name, node_name))
Jing Huangf8ceafd2009-09-25 12:29:54 -0700527 return FC_PARSE_OK;
Jing Huang7725ccf2009-09-23 17:46:15 -0700528
Jing Huangf8ceafd2009-09-25 12:29:54 -0700529 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700530}
531
532enum fc_parse_status
533fc_pdisc_parse(struct fchs_s *fchs, wwn_t node_name, wwn_t port_name)
534{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700535 struct fc_logi_s *pdisc = (struct fc_logi_s *) (fchs + 1);
Jing Huang7725ccf2009-09-23 17:46:15 -0700536
537 if (pdisc->class3.class_valid != 1)
538 return FC_PARSE_FAILURE;
539
Jing Huangba816ea2010-10-18 17:10:50 -0700540 if ((be16_to_cpu(pdisc->class3.rxsz) <
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700541 (FC_MIN_PDUSZ - sizeof(struct fchs_s)))
Jing Huang7725ccf2009-09-23 17:46:15 -0700542 || (pdisc->class3.rxsz == 0))
Jing Huangf8ceafd2009-09-25 12:29:54 -0700543 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700544
545 if (!wwn_is_equal(pdisc->port_name, port_name))
Jing Huangf8ceafd2009-09-25 12:29:54 -0700546 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700547
548 if (!wwn_is_equal(pdisc->node_name, node_name))
Jing Huangf8ceafd2009-09-25 12:29:54 -0700549 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700550
551 return FC_PARSE_OK;
552}
553
554u16
555fc_abts_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id)
556{
Jing Huang6a18b162010-10-18 17:08:54 -0700557 memcpy(fchs, &fc_bls_req_tmpl, sizeof(struct fchs_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700558 fchs->cat_info = FC_CAT_ABTS;
559 fchs->d_id = (d_id);
560 fchs->s_id = (s_id);
Jing Huangba816ea2010-10-18 17:10:50 -0700561 fchs->ox_id = cpu_to_be16(ox_id);
Jing Huang7725ccf2009-09-23 17:46:15 -0700562
Jing Huangf8ceafd2009-09-25 12:29:54 -0700563 return sizeof(struct fchs_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700564}
565
566enum fc_parse_status
567fc_abts_rsp_parse(struct fchs_s *fchs, int len)
568{
569 if ((fchs->cat_info == FC_CAT_BA_ACC)
570 || (fchs->cat_info == FC_CAT_BA_RJT))
Jing Huangf8ceafd2009-09-25 12:29:54 -0700571 return FC_PARSE_OK;
Jing Huang7725ccf2009-09-23 17:46:15 -0700572
Jing Huangf8ceafd2009-09-25 12:29:54 -0700573 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700574}
575
576u16
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700577fc_rrq_build(struct fchs_s *fchs, struct fc_rrq_s *rrq, u32 d_id, u32 s_id,
578 u16 ox_id, u16 rrq_oxid)
Jing Huang7725ccf2009-09-23 17:46:15 -0700579{
580 fc_els_req_build(fchs, d_id, s_id, ox_id);
581
582 /*
583 * build rrq payload
584 */
Jing Huang6a18b162010-10-18 17:08:54 -0700585 memcpy(rrq, &rrq_tmpl, sizeof(struct fc_rrq_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700586 rrq->s_id = (s_id);
Jing Huangba816ea2010-10-18 17:10:50 -0700587 rrq->ox_id = cpu_to_be16(rrq_oxid);
Jing Huang7725ccf2009-09-23 17:46:15 -0700588 rrq->rx_id = FC_RXID_ANY;
589
Jing Huangf8ceafd2009-09-25 12:29:54 -0700590 return sizeof(struct fc_rrq_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700591}
592
593u16
594fc_logo_acc_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
Maggie50444a32010-11-29 18:26:32 -0800595 __be16 ox_id)
Jing Huang7725ccf2009-09-23 17:46:15 -0700596{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700597 struct fc_els_cmd_s *acc = pld;
Jing Huang7725ccf2009-09-23 17:46:15 -0700598
599 fc_els_rsp_build(fchs, d_id, s_id, ox_id);
600
Jing Huang6a18b162010-10-18 17:08:54 -0700601 memset(acc, 0, sizeof(struct fc_els_cmd_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700602 acc->els_code = FC_ELS_ACC;
603
Jing Huangf8ceafd2009-09-25 12:29:54 -0700604 return sizeof(struct fc_els_cmd_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700605}
606
607u16
608fc_ls_rjt_build(struct fchs_s *fchs, struct fc_ls_rjt_s *ls_rjt, u32 d_id,
Maggie50444a32010-11-29 18:26:32 -0800609 u32 s_id, __be16 ox_id, u8 reason_code,
Jing Huang7725ccf2009-09-23 17:46:15 -0700610 u8 reason_code_expl)
611{
612 fc_els_rsp_build(fchs, d_id, s_id, ox_id);
Jing Huang6a18b162010-10-18 17:08:54 -0700613 memset(ls_rjt, 0, sizeof(struct fc_ls_rjt_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700614
615 ls_rjt->els_cmd.els_code = FC_ELS_LS_RJT;
616 ls_rjt->reason_code = reason_code;
617 ls_rjt->reason_code_expl = reason_code_expl;
618 ls_rjt->vendor_unique = 0x00;
619
Jing Huangf8ceafd2009-09-25 12:29:54 -0700620 return sizeof(struct fc_ls_rjt_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700621}
622
623u16
624fc_ba_acc_build(struct fchs_s *fchs, struct fc_ba_acc_s *ba_acc, u32 d_id,
Maggie50444a32010-11-29 18:26:32 -0800625 u32 s_id, __be16 ox_id, u16 rx_id)
Jing Huang7725ccf2009-09-23 17:46:15 -0700626{
627 fc_bls_rsp_build(fchs, d_id, s_id, ox_id);
628
Jing Huang6a18b162010-10-18 17:08:54 -0700629 memcpy(ba_acc, &ba_acc_tmpl, sizeof(struct fc_ba_acc_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700630
631 fchs->rx_id = rx_id;
632
633 ba_acc->ox_id = fchs->ox_id;
634 ba_acc->rx_id = fchs->rx_id;
635
Jing Huangf8ceafd2009-09-25 12:29:54 -0700636 return sizeof(struct fc_ba_acc_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700637}
638
639u16
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700640fc_ls_acc_build(struct fchs_s *fchs, struct fc_els_cmd_s *els_cmd, u32 d_id,
Maggie50444a32010-11-29 18:26:32 -0800641 u32 s_id, __be16 ox_id)
Jing Huang7725ccf2009-09-23 17:46:15 -0700642{
643 fc_els_rsp_build(fchs, d_id, s_id, ox_id);
Jing Huang6a18b162010-10-18 17:08:54 -0700644 memset(els_cmd, 0, sizeof(struct fc_els_cmd_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700645 els_cmd->els_code = FC_ELS_ACC;
646
Jing Huangf8ceafd2009-09-25 12:29:54 -0700647 return sizeof(struct fc_els_cmd_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700648}
649
650int
651fc_logout_params_pages(struct fchs_s *fc_frame, u8 els_code)
652{
653 int num_pages = 0;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700654 struct fc_prlo_s *prlo;
655 struct fc_tprlo_s *tprlo;
Jing Huang7725ccf2009-09-23 17:46:15 -0700656
657 if (els_code == FC_ELS_PRLO) {
658 prlo = (struct fc_prlo_s *) (fc_frame + 1);
Jing Huangba816ea2010-10-18 17:10:50 -0700659 num_pages = (be16_to_cpu(prlo->payload_len) - 4) / 16;
Jing Huang7725ccf2009-09-23 17:46:15 -0700660 } else {
661 tprlo = (struct fc_tprlo_s *) (fc_frame + 1);
Jing Huangba816ea2010-10-18 17:10:50 -0700662 num_pages = (be16_to_cpu(tprlo->payload_len) - 4) / 16;
Jing Huang7725ccf2009-09-23 17:46:15 -0700663 }
664 return num_pages;
665}
666
667u16
668fc_tprlo_acc_build(struct fchs_s *fchs, struct fc_tprlo_acc_s *tprlo_acc,
Maggie50444a32010-11-29 18:26:32 -0800669 u32 d_id, u32 s_id, __be16 ox_id, int num_pages)
Jing Huang7725ccf2009-09-23 17:46:15 -0700670{
671 int page;
672
673 fc_els_rsp_build(fchs, d_id, s_id, ox_id);
674
Jing Huang6a18b162010-10-18 17:08:54 -0700675 memset(tprlo_acc, 0, (num_pages * 16) + 4);
Jing Huang7725ccf2009-09-23 17:46:15 -0700676 tprlo_acc->command = FC_ELS_ACC;
677
678 tprlo_acc->page_len = 0x10;
Jing Huangba816ea2010-10-18 17:10:50 -0700679 tprlo_acc->payload_len = cpu_to_be16((num_pages * 16) + 4);
Jing Huang7725ccf2009-09-23 17:46:15 -0700680
681 for (page = 0; page < num_pages; page++) {
682 tprlo_acc->tprlo_acc_params[page].opa_valid = 0;
683 tprlo_acc->tprlo_acc_params[page].rpa_valid = 0;
684 tprlo_acc->tprlo_acc_params[page].fc4type_csp = FC_TYPE_FCP;
685 tprlo_acc->tprlo_acc_params[page].orig_process_assc = 0;
686 tprlo_acc->tprlo_acc_params[page].resp_process_assc = 0;
687 }
Jing Huangba816ea2010-10-18 17:10:50 -0700688 return be16_to_cpu(tprlo_acc->payload_len);
Jing Huang7725ccf2009-09-23 17:46:15 -0700689}
690
691u16
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700692fc_prlo_acc_build(struct fchs_s *fchs, struct fc_prlo_acc_s *prlo_acc, u32 d_id,
Maggie50444a32010-11-29 18:26:32 -0800693 u32 s_id, __be16 ox_id, int num_pages)
Jing Huang7725ccf2009-09-23 17:46:15 -0700694{
695 int page;
696
697 fc_els_rsp_build(fchs, d_id, s_id, ox_id);
698
Jing Huang6a18b162010-10-18 17:08:54 -0700699 memset(prlo_acc, 0, (num_pages * 16) + 4);
Jing Huang7725ccf2009-09-23 17:46:15 -0700700 prlo_acc->command = FC_ELS_ACC;
701 prlo_acc->page_len = 0x10;
Jing Huangba816ea2010-10-18 17:10:50 -0700702 prlo_acc->payload_len = cpu_to_be16((num_pages * 16) + 4);
Jing Huang7725ccf2009-09-23 17:46:15 -0700703
704 for (page = 0; page < num_pages; page++) {
705 prlo_acc->prlo_acc_params[page].opa_valid = 0;
706 prlo_acc->prlo_acc_params[page].rpa_valid = 0;
707 prlo_acc->prlo_acc_params[page].fc4type_csp = FC_TYPE_FCP;
708 prlo_acc->prlo_acc_params[page].orig_process_assc = 0;
709 prlo_acc->prlo_acc_params[page].resp_process_assc = 0;
710 }
711
Jing Huangba816ea2010-10-18 17:10:50 -0700712 return be16_to_cpu(prlo_acc->payload_len);
Jing Huang7725ccf2009-09-23 17:46:15 -0700713}
714
715u16
716fc_rnid_build(struct fchs_s *fchs, struct fc_rnid_cmd_s *rnid, u32 d_id,
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700717 u32 s_id, u16 ox_id, u32 data_format)
Jing Huang7725ccf2009-09-23 17:46:15 -0700718{
719 fc_els_req_build(fchs, d_id, s_id, ox_id);
720
Jing Huang6a18b162010-10-18 17:08:54 -0700721 memset(rnid, 0, sizeof(struct fc_rnid_cmd_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700722
723 rnid->els_cmd.els_code = FC_ELS_RNID;
724 rnid->node_id_data_format = data_format;
725
Jing Huangf8ceafd2009-09-25 12:29:54 -0700726 return sizeof(struct fc_rnid_cmd_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700727}
728
729u16
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700730fc_rnid_acc_build(struct fchs_s *fchs, struct fc_rnid_acc_s *rnid_acc, u32 d_id,
Maggie50444a32010-11-29 18:26:32 -0800731 u32 s_id, __be16 ox_id, u32 data_format,
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700732 struct fc_rnid_common_id_data_s *common_id_data,
733 struct fc_rnid_general_topology_data_s *gen_topo_data)
Jing Huang7725ccf2009-09-23 17:46:15 -0700734{
Jing Huang6a18b162010-10-18 17:08:54 -0700735 memset(rnid_acc, 0, sizeof(struct fc_rnid_acc_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700736
737 fc_els_rsp_build(fchs, d_id, s_id, ox_id);
738
739 rnid_acc->els_cmd.els_code = FC_ELS_ACC;
740 rnid_acc->node_id_data_format = data_format;
741 rnid_acc->common_id_data_length =
742 sizeof(struct fc_rnid_common_id_data_s);
743 rnid_acc->common_id_data = *common_id_data;
744
745 if (data_format == RNID_NODEID_DATA_FORMAT_DISCOVERY) {
746 rnid_acc->specific_id_data_length =
747 sizeof(struct fc_rnid_general_topology_data_s);
Jing Huang6a18b162010-10-18 17:08:54 -0700748 rnid_acc->gen_topology_data = *gen_topo_data;
Jing Huangf8ceafd2009-09-25 12:29:54 -0700749 return sizeof(struct fc_rnid_acc_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700750 } else {
Jing Huangf8ceafd2009-09-25 12:29:54 -0700751 return sizeof(struct fc_rnid_acc_s) -
752 sizeof(struct fc_rnid_general_topology_data_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700753 }
754
755}
756
757u16
758fc_rpsc_build(struct fchs_s *fchs, struct fc_rpsc_cmd_s *rpsc, u32 d_id,
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700759 u32 s_id, u16 ox_id)
Jing Huang7725ccf2009-09-23 17:46:15 -0700760{
761 fc_els_req_build(fchs, d_id, s_id, ox_id);
762
Jing Huang6a18b162010-10-18 17:08:54 -0700763 memset(rpsc, 0, sizeof(struct fc_rpsc_cmd_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700764
765 rpsc->els_cmd.els_code = FC_ELS_RPSC;
Jing Huangf8ceafd2009-09-25 12:29:54 -0700766 return sizeof(struct fc_rpsc_cmd_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700767}
768
769u16
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700770fc_rpsc2_build(struct fchs_s *fchs, struct fc_rpsc2_cmd_s *rpsc2, u32 d_id,
771 u32 s_id, u32 *pid_list, u16 npids)
Jing Huang7725ccf2009-09-23 17:46:15 -0700772{
Maggie Zhangf16a1752010-12-09 19:12:32 -0800773 u32 dctlr_id = FC_DOMAIN_CTRLR(bfa_hton3b(d_id));
Jing Huang7725ccf2009-09-23 17:46:15 -0700774 int i = 0;
775
Maggie Zhangf16a1752010-12-09 19:12:32 -0800776 fc_els_req_build(fchs, bfa_hton3b(dctlr_id), s_id, 0);
Jing Huang7725ccf2009-09-23 17:46:15 -0700777
Jing Huang6a18b162010-10-18 17:08:54 -0700778 memset(rpsc2, 0, sizeof(struct fc_rpsc2_cmd_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700779
780 rpsc2->els_cmd.els_code = FC_ELS_RPSC;
Jing Huangba816ea2010-10-18 17:10:50 -0700781 rpsc2->token = cpu_to_be32(FC_BRCD_TOKEN);
782 rpsc2->num_pids = cpu_to_be16(npids);
Jing Huang7725ccf2009-09-23 17:46:15 -0700783 for (i = 0; i < npids; i++)
784 rpsc2->pid_list[i].pid = pid_list[i];
785
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700786 return sizeof(struct fc_rpsc2_cmd_s) + ((npids - 1) * (sizeof(u32)));
Jing Huang7725ccf2009-09-23 17:46:15 -0700787}
788
789u16
790fc_rpsc_acc_build(struct fchs_s *fchs, struct fc_rpsc_acc_s *rpsc_acc,
Maggie50444a32010-11-29 18:26:32 -0800791 u32 d_id, u32 s_id, __be16 ox_id,
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700792 struct fc_rpsc_speed_info_s *oper_speed)
Jing Huang7725ccf2009-09-23 17:46:15 -0700793{
Jing Huang6a18b162010-10-18 17:08:54 -0700794 memset(rpsc_acc, 0, sizeof(struct fc_rpsc_acc_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700795
796 fc_els_rsp_build(fchs, d_id, s_id, ox_id);
797
798 rpsc_acc->command = FC_ELS_ACC;
Jing Huangba816ea2010-10-18 17:10:50 -0700799 rpsc_acc->num_entries = cpu_to_be16(1);
Jing Huang7725ccf2009-09-23 17:46:15 -0700800
801 rpsc_acc->speed_info[0].port_speed_cap =
Jing Huangba816ea2010-10-18 17:10:50 -0700802 cpu_to_be16(oper_speed->port_speed_cap);
Jing Huang7725ccf2009-09-23 17:46:15 -0700803
804 rpsc_acc->speed_info[0].port_op_speed =
Jing Huangba816ea2010-10-18 17:10:50 -0700805 cpu_to_be16(oper_speed->port_op_speed);
Jing Huang7725ccf2009-09-23 17:46:15 -0700806
Jing Huangf8ceafd2009-09-25 12:29:54 -0700807 return sizeof(struct fc_rpsc_acc_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700808}
809
Jing Huang7725ccf2009-09-23 17:46:15 -0700810u16
811fc_logo_rsp_parse(struct fchs_s *fchs, int len)
812{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700813 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
Jing Huang7725ccf2009-09-23 17:46:15 -0700814
815 len = len;
816 if (els_cmd->els_code != FC_ELS_ACC)
817 return FC_PARSE_FAILURE;
818
819 return FC_PARSE_OK;
820}
821
822u16
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700823fc_pdisc_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id,
824 wwn_t port_name, wwn_t node_name, u16 pdu_size)
Jing Huang7725ccf2009-09-23 17:46:15 -0700825{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700826 struct fc_logi_s *pdisc = (struct fc_logi_s *) (fchs + 1);
Jing Huang7725ccf2009-09-23 17:46:15 -0700827
Jing Huang6a18b162010-10-18 17:08:54 -0700828 memcpy(pdisc, &plogi_tmpl, sizeof(struct fc_logi_s));
Jing Huang7725ccf2009-09-23 17:46:15 -0700829
830 pdisc->els_cmd.els_code = FC_ELS_PDISC;
831 fc_els_req_build(fchs, d_id, s_id, ox_id);
832
Jing Huangba816ea2010-10-18 17:10:50 -0700833 pdisc->csp.rxsz = pdisc->class3.rxsz = cpu_to_be16(pdu_size);
Jing Huang7725ccf2009-09-23 17:46:15 -0700834 pdisc->port_name = port_name;
835 pdisc->node_name = node_name;
836
Jing Huangf8ceafd2009-09-25 12:29:54 -0700837 return sizeof(struct fc_logi_s);
Jing Huang7725ccf2009-09-23 17:46:15 -0700838}
839
840u16
841fc_pdisc_rsp_parse(struct fchs_s *fchs, int len, wwn_t port_name)
842{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700843 struct fc_logi_s *pdisc = (struct fc_logi_s *) (fchs + 1);
Jing Huang7725ccf2009-09-23 17:46:15 -0700844
845 if (len < sizeof(struct fc_logi_s))
Jing Huangf8ceafd2009-09-25 12:29:54 -0700846 return FC_PARSE_LEN_INVAL;
Jing Huang7725ccf2009-09-23 17:46:15 -0700847
848 if (pdisc->els_cmd.els_code != FC_ELS_ACC)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700849 return FC_PARSE_ACC_INVAL;
Jing Huang7725ccf2009-09-23 17:46:15 -0700850
851 if (!wwn_is_equal(pdisc->port_name, port_name))
Jing Huangf8ceafd2009-09-25 12:29:54 -0700852 return FC_PARSE_PWWN_NOT_EQUAL;
Jing Huang7725ccf2009-09-23 17:46:15 -0700853
854 if (!pdisc->class3.class_valid)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700855 return FC_PARSE_NWWN_NOT_EQUAL;
Jing Huang7725ccf2009-09-23 17:46:15 -0700856
Jing Huangba816ea2010-10-18 17:10:50 -0700857 if (be16_to_cpu(pdisc->class3.rxsz) < (FC_MIN_PDUSZ))
Jing Huangf8ceafd2009-09-25 12:29:54 -0700858 return FC_PARSE_RXSZ_INVAL;
Jing Huang7725ccf2009-09-23 17:46:15 -0700859
Jing Huangf8ceafd2009-09-25 12:29:54 -0700860 return FC_PARSE_OK;
Jing Huang7725ccf2009-09-23 17:46:15 -0700861}
862
863u16
864fc_prlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id,
865 int num_pages)
866{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700867 struct fc_prlo_s *prlo = (struct fc_prlo_s *) (fchs + 1);
Jing Huang7725ccf2009-09-23 17:46:15 -0700868 int page;
869
870 fc_els_req_build(fchs, d_id, s_id, ox_id);
Jing Huang6a18b162010-10-18 17:08:54 -0700871 memset(prlo, 0, (num_pages * 16) + 4);
Jing Huang7725ccf2009-09-23 17:46:15 -0700872 prlo->command = FC_ELS_PRLO;
873 prlo->page_len = 0x10;
Jing Huangba816ea2010-10-18 17:10:50 -0700874 prlo->payload_len = cpu_to_be16((num_pages * 16) + 4);
Jing Huang7725ccf2009-09-23 17:46:15 -0700875
876 for (page = 0; page < num_pages; page++) {
877 prlo->prlo_params[page].type = FC_TYPE_FCP;
878 prlo->prlo_params[page].opa_valid = 0;
879 prlo->prlo_params[page].rpa_valid = 0;
880 prlo->prlo_params[page].orig_process_assc = 0;
881 prlo->prlo_params[page].resp_process_assc = 0;
882 }
883
Jing Huangba816ea2010-10-18 17:10:50 -0700884 return be16_to_cpu(prlo->payload_len);
Jing Huang7725ccf2009-09-23 17:46:15 -0700885}
886
887u16
888fc_prlo_rsp_parse(struct fchs_s *fchs, int len)
889{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700890 struct fc_prlo_acc_s *prlo = (struct fc_prlo_acc_s *) (fchs + 1);
Jing Huang7725ccf2009-09-23 17:46:15 -0700891 int num_pages = 0;
892 int page = 0;
893
894 len = len;
895
896 if (prlo->command != FC_ELS_ACC)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700897 return FC_PARSE_FAILURE;
Jing Huang7725ccf2009-09-23 17:46:15 -0700898
Jing Huangba816ea2010-10-18 17:10:50 -0700899 num_pages = ((be16_to_cpu(prlo->payload_len)) - 4) / 16;
Jing Huang7725ccf2009-09-23 17:46:15 -0700900
901 for (page = 0; page < num_pages; page++) {
902 if (prlo->prlo_acc_params[page].type != FC_TYPE_FCP)
903 return FC_PARSE_FAILURE;
904
905 if (prlo->prlo_acc_params[page].opa_valid != 0)
906 return FC_PARSE_FAILURE;
907
908 if (prlo->prlo_acc_params[page].rpa_valid != 0)
909 return FC_PARSE_FAILURE;
910
911 if (prlo->prlo_acc_params[page].orig_process_assc != 0)
912 return FC_PARSE_FAILURE;
913
914 if (prlo->prlo_acc_params[page].resp_process_assc != 0)
915 return FC_PARSE_FAILURE;
916 }
Jing Huangf8ceafd2009-09-25 12:29:54 -0700917 return FC_PARSE_OK;
Jing Huang7725ccf2009-09-23 17:46:15 -0700918
919}
920
921u16
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700922fc_tprlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id,
923 int num_pages, enum fc_tprlo_type tprlo_type, u32 tpr_id)
Jing Huang7725ccf2009-09-23 17:46:15 -0700924{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700925 struct fc_tprlo_s *tprlo = (struct fc_tprlo_s *) (fchs + 1);
Jing Huang7725ccf2009-09-23 17:46:15 -0700926 int page;
927
928 fc_els_req_build(fchs, d_id, s_id, ox_id);
Jing Huang6a18b162010-10-18 17:08:54 -0700929 memset(tprlo, 0, (num_pages * 16) + 4);
Jing Huang7725ccf2009-09-23 17:46:15 -0700930 tprlo->command = FC_ELS_TPRLO;
931 tprlo->page_len = 0x10;
Jing Huangba816ea2010-10-18 17:10:50 -0700932 tprlo->payload_len = cpu_to_be16((num_pages * 16) + 4);
Jing Huang7725ccf2009-09-23 17:46:15 -0700933
934 for (page = 0; page < num_pages; page++) {
935 tprlo->tprlo_params[page].type = FC_TYPE_FCP;
936 tprlo->tprlo_params[page].opa_valid = 0;
937 tprlo->tprlo_params[page].rpa_valid = 0;
938 tprlo->tprlo_params[page].orig_process_assc = 0;
939 tprlo->tprlo_params[page].resp_process_assc = 0;
940 if (tprlo_type == FC_GLOBAL_LOGO) {
941 tprlo->tprlo_params[page].global_process_logout = 1;
942 } else if (tprlo_type == FC_TPR_LOGO) {
943 tprlo->tprlo_params[page].tpo_nport_valid = 1;
944 tprlo->tprlo_params[page].tpo_nport_id = (tpr_id);
945 }
946 }
947
Jing Huangba816ea2010-10-18 17:10:50 -0700948 return be16_to_cpu(tprlo->payload_len);
Jing Huang7725ccf2009-09-23 17:46:15 -0700949}
950
951u16
952fc_tprlo_rsp_parse(struct fchs_s *fchs, int len)
953{
954 struct fc_tprlo_acc_s *tprlo = (struct fc_tprlo_acc_s *) (fchs + 1);
955 int num_pages = 0;
956 int page = 0;
957
958 len = len;
959
960 if (tprlo->command != FC_ELS_ACC)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700961 return FC_PARSE_ACC_INVAL;
Jing Huang7725ccf2009-09-23 17:46:15 -0700962
Jing Huangba816ea2010-10-18 17:10:50 -0700963 num_pages = (be16_to_cpu(tprlo->payload_len) - 4) / 16;
Jing Huang7725ccf2009-09-23 17:46:15 -0700964
965 for (page = 0; page < num_pages; page++) {
966 if (tprlo->tprlo_acc_params[page].type != FC_TYPE_FCP)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700967 return FC_PARSE_NOT_FCP;
Jing Huang7725ccf2009-09-23 17:46:15 -0700968 if (tprlo->tprlo_acc_params[page].opa_valid != 0)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700969 return FC_PARSE_OPAFLAG_INVAL;
Jing Huang7725ccf2009-09-23 17:46:15 -0700970 if (tprlo->tprlo_acc_params[page].rpa_valid != 0)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700971 return FC_PARSE_RPAFLAG_INVAL;
Jing Huang7725ccf2009-09-23 17:46:15 -0700972 if (tprlo->tprlo_acc_params[page].orig_process_assc != 0)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700973 return FC_PARSE_OPA_INVAL;
Jing Huang7725ccf2009-09-23 17:46:15 -0700974 if (tprlo->tprlo_acc_params[page].resp_process_assc != 0)
Jing Huangf8ceafd2009-09-25 12:29:54 -0700975 return FC_PARSE_RPA_INVAL;
Jing Huang7725ccf2009-09-23 17:46:15 -0700976 }
Jing Huangf8ceafd2009-09-25 12:29:54 -0700977 return FC_PARSE_OK;
Jing Huang7725ccf2009-09-23 17:46:15 -0700978}
979
980enum fc_parse_status
981fc_rrq_rsp_parse(struct fchs_s *fchs, int len)
982{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700983 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
Jing Huang7725ccf2009-09-23 17:46:15 -0700984
985 len = len;
986 if (els_cmd->els_code != FC_ELS_ACC)
987 return FC_PARSE_FAILURE;
988
989 return FC_PARSE_OK;
990}
991
992u16
Maggie50444a32010-11-29 18:26:32 -0800993fc_ba_rjt_build(struct fchs_s *fchs, u32 d_id, u32 s_id, __be16 ox_id,
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700994 u32 reason_code, u32 reason_expl)
Jing Huang7725ccf2009-09-23 17:46:15 -0700995{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700996 struct fc_ba_rjt_s *ba_rjt = (struct fc_ba_rjt_s *) (fchs + 1);
Jing Huang7725ccf2009-09-23 17:46:15 -0700997
998 fc_bls_rsp_build(fchs, d_id, s_id, ox_id);
999
1000 fchs->cat_info = FC_CAT_BA_RJT;
1001 ba_rjt->reason_code = reason_code;
1002 ba_rjt->reason_expl = reason_expl;
Jing Huangf8ceafd2009-09-25 12:29:54 -07001003 return sizeof(struct fc_ba_rjt_s);
Jing Huang7725ccf2009-09-23 17:46:15 -07001004}
1005
1006static void
1007fc_gs_cthdr_build(struct ct_hdr_s *cthdr, u32 s_id, u16 cmd_code)
1008{
Jing Huang6a18b162010-10-18 17:08:54 -07001009 memset(cthdr, 0, sizeof(struct ct_hdr_s));
Jing Huang7725ccf2009-09-23 17:46:15 -07001010 cthdr->rev_id = CT_GS3_REVISION;
1011 cthdr->gs_type = CT_GSTYPE_DIRSERVICE;
1012 cthdr->gs_sub_type = CT_GSSUBTYPE_NAMESERVER;
Jing Huangba816ea2010-10-18 17:10:50 -07001013 cthdr->cmd_rsp_code = cpu_to_be16(cmd_code);
Jing Huang7725ccf2009-09-23 17:46:15 -07001014}
1015
1016static void
1017fc_gs_fdmi_cthdr_build(struct ct_hdr_s *cthdr, u32 s_id, u16 cmd_code)
1018{
Jing Huang6a18b162010-10-18 17:08:54 -07001019 memset(cthdr, 0, sizeof(struct ct_hdr_s));
Jing Huang7725ccf2009-09-23 17:46:15 -07001020 cthdr->rev_id = CT_GS3_REVISION;
1021 cthdr->gs_type = CT_GSTYPE_MGMTSERVICE;
1022 cthdr->gs_sub_type = CT_GSSUBTYPE_HBA_MGMTSERVER;
Jing Huangba816ea2010-10-18 17:10:50 -07001023 cthdr->cmd_rsp_code = cpu_to_be16(cmd_code);
Jing Huang7725ccf2009-09-23 17:46:15 -07001024}
1025
1026static void
1027fc_gs_ms_cthdr_build(struct ct_hdr_s *cthdr, u32 s_id, u16 cmd_code,
1028 u8 sub_type)
1029{
Jing Huang6a18b162010-10-18 17:08:54 -07001030 memset(cthdr, 0, sizeof(struct ct_hdr_s));
Jing Huang7725ccf2009-09-23 17:46:15 -07001031 cthdr->rev_id = CT_GS3_REVISION;
1032 cthdr->gs_type = CT_GSTYPE_MGMTSERVICE;
1033 cthdr->gs_sub_type = sub_type;
Jing Huangba816ea2010-10-18 17:10:50 -07001034 cthdr->cmd_rsp_code = cpu_to_be16(cmd_code);
Jing Huang7725ccf2009-09-23 17:46:15 -07001035}
1036
1037u16
1038fc_gidpn_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
1039 wwn_t port_name)
1040{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001041 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1042 struct fcgs_gidpn_req_s *gidpn = (struct fcgs_gidpn_req_s *)(cthdr + 1);
Maggie Zhangf16a1752010-12-09 19:12:32 -08001043 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
Jing Huang7725ccf2009-09-23 17:46:15 -07001044
1045 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
1046 fc_gs_cthdr_build(cthdr, s_id, GS_GID_PN);
1047
Jing Huang6a18b162010-10-18 17:08:54 -07001048 memset(gidpn, 0, sizeof(struct fcgs_gidpn_req_s));
Jing Huang7725ccf2009-09-23 17:46:15 -07001049 gidpn->port_name = port_name;
Jing Huangf8ceafd2009-09-25 12:29:54 -07001050 return sizeof(struct fcgs_gidpn_req_s) + sizeof(struct ct_hdr_s);
Jing Huang7725ccf2009-09-23 17:46:15 -07001051}
1052
1053u16
1054fc_gpnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
1055 u32 port_id)
1056{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001057 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
Jing Huang7725ccf2009-09-23 17:46:15 -07001058 fcgs_gpnid_req_t *gpnid = (fcgs_gpnid_req_t *) (cthdr + 1);
Maggie Zhangf16a1752010-12-09 19:12:32 -08001059 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
Jing Huang7725ccf2009-09-23 17:46:15 -07001060
1061 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
1062 fc_gs_cthdr_build(cthdr, s_id, GS_GPN_ID);
1063
Jing Huang6a18b162010-10-18 17:08:54 -07001064 memset(gpnid, 0, sizeof(fcgs_gpnid_req_t));
Jing Huang7725ccf2009-09-23 17:46:15 -07001065 gpnid->dap = port_id;
Jing Huangf8ceafd2009-09-25 12:29:54 -07001066 return sizeof(fcgs_gpnid_req_t) + sizeof(struct ct_hdr_s);
Jing Huang7725ccf2009-09-23 17:46:15 -07001067}
1068
1069u16
1070fc_gnnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
1071 u32 port_id)
1072{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001073 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
Jing Huang7725ccf2009-09-23 17:46:15 -07001074 fcgs_gnnid_req_t *gnnid = (fcgs_gnnid_req_t *) (cthdr + 1);
Maggie Zhangf16a1752010-12-09 19:12:32 -08001075 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
Jing Huang7725ccf2009-09-23 17:46:15 -07001076
1077 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
1078 fc_gs_cthdr_build(cthdr, s_id, GS_GNN_ID);
1079
Jing Huang6a18b162010-10-18 17:08:54 -07001080 memset(gnnid, 0, sizeof(fcgs_gnnid_req_t));
Jing Huang7725ccf2009-09-23 17:46:15 -07001081 gnnid->dap = port_id;
Jing Huangf8ceafd2009-09-25 12:29:54 -07001082 return sizeof(fcgs_gnnid_req_t) + sizeof(struct ct_hdr_s);
Jing Huang7725ccf2009-09-23 17:46:15 -07001083}
1084
1085u16
1086fc_ct_rsp_parse(struct ct_hdr_s *cthdr)
1087{
Jing Huangba816ea2010-10-18 17:10:50 -07001088 if (be16_to_cpu(cthdr->cmd_rsp_code) != CT_RSP_ACCEPT) {
Jing Huang7725ccf2009-09-23 17:46:15 -07001089 if (cthdr->reason_code == CT_RSN_LOGICAL_BUSY)
1090 return FC_PARSE_BUSY;
1091 else
1092 return FC_PARSE_FAILURE;
1093 }
1094
1095 return FC_PARSE_OK;
1096}
1097
1098u16
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001099fc_scr_build(struct fchs_s *fchs, struct fc_scr_s *scr,
1100 u8 set_br_reg, u32 s_id, u16 ox_id)
Jing Huang7725ccf2009-09-23 17:46:15 -07001101{
Maggie Zhangf16a1752010-12-09 19:12:32 -08001102 u32 d_id = bfa_hton3b(FC_FABRIC_CONTROLLER);
Jing Huang7725ccf2009-09-23 17:46:15 -07001103
1104 fc_els_req_build(fchs, d_id, s_id, ox_id);
1105
Jing Huang6a18b162010-10-18 17:08:54 -07001106 memset(scr, 0, sizeof(struct fc_scr_s));
Jing Huang7725ccf2009-09-23 17:46:15 -07001107 scr->command = FC_ELS_SCR;
1108 scr->reg_func = FC_SCR_REG_FUNC_FULL;
1109 if (set_br_reg)
1110 scr->vu_reg_func = FC_VU_SCR_REG_FUNC_FABRIC_NAME_CHANGE;
1111
Jing Huangf8ceafd2009-09-25 12:29:54 -07001112 return sizeof(struct fc_scr_s);
Jing Huang7725ccf2009-09-23 17:46:15 -07001113}
1114
1115u16
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001116fc_rscn_build(struct fchs_s *fchs, struct fc_rscn_pl_s *rscn,
1117 u32 s_id, u16 ox_id)
Jing Huang7725ccf2009-09-23 17:46:15 -07001118{
Maggie Zhangf16a1752010-12-09 19:12:32 -08001119 u32 d_id = bfa_hton3b(FC_FABRIC_CONTROLLER);
Jing Huang7725ccf2009-09-23 17:46:15 -07001120 u16 payldlen;
1121
1122 fc_els_req_build(fchs, d_id, s_id, ox_id);
1123 rscn->command = FC_ELS_RSCN;
1124 rscn->pagelen = sizeof(rscn->event[0]);
1125
1126 payldlen = sizeof(u32) + rscn->pagelen;
Jing Huangba816ea2010-10-18 17:10:50 -07001127 rscn->payldlen = cpu_to_be16(payldlen);
Jing Huang7725ccf2009-09-23 17:46:15 -07001128
1129 rscn->event[0].format = FC_RSCN_FORMAT_PORTID;
1130 rscn->event[0].portid = s_id;
1131
Jing Huangf8ceafd2009-09-25 12:29:54 -07001132 return sizeof(struct fc_rscn_pl_s);
Jing Huang7725ccf2009-09-23 17:46:15 -07001133}
1134
1135u16
1136fc_rftid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001137 enum bfa_lport_role roles)
Jing Huang7725ccf2009-09-23 17:46:15 -07001138{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001139 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1140 struct fcgs_rftid_req_s *rftid = (struct fcgs_rftid_req_s *)(cthdr + 1);
Maggie Zhangf16a1752010-12-09 19:12:32 -08001141 u32 type_value, d_id = bfa_hton3b(FC_NAME_SERVER);
Jing Huang7725ccf2009-09-23 17:46:15 -07001142 u8 index;
1143
1144 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
1145 fc_gs_cthdr_build(cthdr, s_id, GS_RFT_ID);
1146
Jing Huang6a18b162010-10-18 17:08:54 -07001147 memset(rftid, 0, sizeof(struct fcgs_rftid_req_s));
Jing Huang7725ccf2009-09-23 17:46:15 -07001148
1149 rftid->dap = s_id;
1150
1151 /* By default, FCP FC4 Type is registered */
1152 index = FC_TYPE_FCP >> 5;
1153 type_value = 1 << (FC_TYPE_FCP % 32);
Jing Huangba816ea2010-10-18 17:10:50 -07001154 rftid->fc4_type[index] = cpu_to_be32(type_value);
Jing Huang7725ccf2009-09-23 17:46:15 -07001155
Jing Huangf8ceafd2009-09-25 12:29:54 -07001156 return sizeof(struct fcgs_rftid_req_s) + sizeof(struct ct_hdr_s);
Jing Huang7725ccf2009-09-23 17:46:15 -07001157}
1158
1159u16
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001160fc_rftid_build_sol(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
1161 u8 *fc4_bitmap, u32 bitmap_size)
Jing Huang7725ccf2009-09-23 17:46:15 -07001162{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001163 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1164 struct fcgs_rftid_req_s *rftid = (struct fcgs_rftid_req_s *)(cthdr + 1);
Maggie Zhangf16a1752010-12-09 19:12:32 -08001165 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
Jing Huang7725ccf2009-09-23 17:46:15 -07001166
1167 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
1168 fc_gs_cthdr_build(cthdr, s_id, GS_RFT_ID);
1169
Jing Huang6a18b162010-10-18 17:08:54 -07001170 memset(rftid, 0, sizeof(struct fcgs_rftid_req_s));
Jing Huang7725ccf2009-09-23 17:46:15 -07001171
1172 rftid->dap = s_id;
Jing Huang6a18b162010-10-18 17:08:54 -07001173 memcpy((void *)rftid->fc4_type, (void *)fc4_bitmap,
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001174 (bitmap_size < 32 ? bitmap_size : 32));
Jing Huang7725ccf2009-09-23 17:46:15 -07001175
Jing Huangf8ceafd2009-09-25 12:29:54 -07001176 return sizeof(struct fcgs_rftid_req_s) + sizeof(struct ct_hdr_s);
Jing Huang7725ccf2009-09-23 17:46:15 -07001177}
1178
1179u16
1180fc_rffid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
1181 u8 fc4_type, u8 fc4_ftrs)
1182{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001183 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1184 struct fcgs_rffid_req_s *rffid = (struct fcgs_rffid_req_s *)(cthdr + 1);
Maggie Zhangf16a1752010-12-09 19:12:32 -08001185 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
Jing Huang7725ccf2009-09-23 17:46:15 -07001186
1187 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
1188 fc_gs_cthdr_build(cthdr, s_id, GS_RFF_ID);
1189
Jing Huang6a18b162010-10-18 17:08:54 -07001190 memset(rffid, 0, sizeof(struct fcgs_rffid_req_s));
Jing Huang7725ccf2009-09-23 17:46:15 -07001191
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001192 rffid->dap = s_id;
Jing Huang7725ccf2009-09-23 17:46:15 -07001193 rffid->fc4ftr_bits = fc4_ftrs;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001194 rffid->fc4_type = fc4_type;
Jing Huang7725ccf2009-09-23 17:46:15 -07001195
Jing Huangf8ceafd2009-09-25 12:29:54 -07001196 return sizeof(struct fcgs_rffid_req_s) + sizeof(struct ct_hdr_s);
Jing Huang7725ccf2009-09-23 17:46:15 -07001197}
1198
1199u16
1200fc_rspnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
1201 u8 *name)
1202{
1203
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001204 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
Jing Huang7725ccf2009-09-23 17:46:15 -07001205 struct fcgs_rspnid_req_s *rspnid =
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001206 (struct fcgs_rspnid_req_s *)(cthdr + 1);
Maggie Zhangf16a1752010-12-09 19:12:32 -08001207 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
Jing Huang7725ccf2009-09-23 17:46:15 -07001208
1209 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
1210 fc_gs_cthdr_build(cthdr, s_id, GS_RSPN_ID);
1211
Jing Huang6a18b162010-10-18 17:08:54 -07001212 memset(rspnid, 0, sizeof(struct fcgs_rspnid_req_s));
Jing Huang7725ccf2009-09-23 17:46:15 -07001213
1214 rspnid->dap = s_id;
1215 rspnid->spn_len = (u8) strlen((char *)name);
1216 strncpy((char *)rspnid->spn, (char *)name, rspnid->spn_len);
1217
Jing Huangf8ceafd2009-09-25 12:29:54 -07001218 return sizeof(struct fcgs_rspnid_req_s) + sizeof(struct ct_hdr_s);
Jing Huang7725ccf2009-09-23 17:46:15 -07001219}
1220
1221u16
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001222fc_gid_ft_build(struct fchs_s *fchs, void *pyld, u32 s_id, u8 fc4_type)
Jing Huang7725ccf2009-09-23 17:46:15 -07001223{
1224
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001225 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1226 struct fcgs_gidft_req_s *gidft = (struct fcgs_gidft_req_s *)(cthdr + 1);
Maggie Zhangf16a1752010-12-09 19:12:32 -08001227 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
Jing Huang7725ccf2009-09-23 17:46:15 -07001228
1229 fc_gs_fchdr_build(fchs, d_id, s_id, 0);
1230
1231 fc_gs_cthdr_build(cthdr, s_id, GS_GID_FT);
1232
Jing Huang6a18b162010-10-18 17:08:54 -07001233 memset(gidft, 0, sizeof(struct fcgs_gidft_req_s));
Jing Huang7725ccf2009-09-23 17:46:15 -07001234 gidft->fc4_type = fc4_type;
1235 gidft->domain_id = 0;
1236 gidft->area_id = 0;
1237
Jing Huangf8ceafd2009-09-25 12:29:54 -07001238 return sizeof(struct fcgs_gidft_req_s) + sizeof(struct ct_hdr_s);
Jing Huang7725ccf2009-09-23 17:46:15 -07001239}
1240
1241u16
1242fc_rpnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id,
1243 wwn_t port_name)
1244{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001245 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1246 struct fcgs_rpnid_req_s *rpnid = (struct fcgs_rpnid_req_s *)(cthdr + 1);
Maggie Zhangf16a1752010-12-09 19:12:32 -08001247 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
Jing Huang7725ccf2009-09-23 17:46:15 -07001248
1249 fc_gs_fchdr_build(fchs, d_id, s_id, 0);
1250 fc_gs_cthdr_build(cthdr, s_id, GS_RPN_ID);
1251
Jing Huang6a18b162010-10-18 17:08:54 -07001252 memset(rpnid, 0, sizeof(struct fcgs_rpnid_req_s));
Jing Huang7725ccf2009-09-23 17:46:15 -07001253 rpnid->port_id = port_id;
1254 rpnid->port_name = port_name;
1255
Jing Huangf8ceafd2009-09-25 12:29:54 -07001256 return sizeof(struct fcgs_rpnid_req_s) + sizeof(struct ct_hdr_s);
Jing Huang7725ccf2009-09-23 17:46:15 -07001257}
1258
1259u16
1260fc_rnnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id,
1261 wwn_t node_name)
1262{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001263 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1264 struct fcgs_rnnid_req_s *rnnid = (struct fcgs_rnnid_req_s *)(cthdr + 1);
Maggie Zhangf16a1752010-12-09 19:12:32 -08001265 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
Jing Huang7725ccf2009-09-23 17:46:15 -07001266
1267 fc_gs_fchdr_build(fchs, d_id, s_id, 0);
1268 fc_gs_cthdr_build(cthdr, s_id, GS_RNN_ID);
1269
Jing Huang6a18b162010-10-18 17:08:54 -07001270 memset(rnnid, 0, sizeof(struct fcgs_rnnid_req_s));
Jing Huang7725ccf2009-09-23 17:46:15 -07001271 rnnid->port_id = port_id;
1272 rnnid->node_name = node_name;
1273
Jing Huangf8ceafd2009-09-25 12:29:54 -07001274 return sizeof(struct fcgs_rnnid_req_s) + sizeof(struct ct_hdr_s);
Jing Huang7725ccf2009-09-23 17:46:15 -07001275}
1276
1277u16
1278fc_rcsid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id,
1279 u32 cos)
1280{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001281 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
Jing Huang7725ccf2009-09-23 17:46:15 -07001282 struct fcgs_rcsid_req_s *rcsid =
1283 (struct fcgs_rcsid_req_s *) (cthdr + 1);
Maggie Zhangf16a1752010-12-09 19:12:32 -08001284 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
Jing Huang7725ccf2009-09-23 17:46:15 -07001285
1286 fc_gs_fchdr_build(fchs, d_id, s_id, 0);
1287 fc_gs_cthdr_build(cthdr, s_id, GS_RCS_ID);
1288
Jing Huang6a18b162010-10-18 17:08:54 -07001289 memset(rcsid, 0, sizeof(struct fcgs_rcsid_req_s));
Jing Huang7725ccf2009-09-23 17:46:15 -07001290 rcsid->port_id = port_id;
1291 rcsid->cos = cos;
1292
Jing Huangf8ceafd2009-09-25 12:29:54 -07001293 return sizeof(struct fcgs_rcsid_req_s) + sizeof(struct ct_hdr_s);
Jing Huang7725ccf2009-09-23 17:46:15 -07001294}
1295
1296u16
1297fc_rptid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id,
1298 u8 port_type)
1299{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001300 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1301 struct fcgs_rptid_req_s *rptid = (struct fcgs_rptid_req_s *)(cthdr + 1);
Maggie Zhangf16a1752010-12-09 19:12:32 -08001302 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
Jing Huang7725ccf2009-09-23 17:46:15 -07001303
1304 fc_gs_fchdr_build(fchs, d_id, s_id, 0);
1305 fc_gs_cthdr_build(cthdr, s_id, GS_RPT_ID);
1306
Jing Huang6a18b162010-10-18 17:08:54 -07001307 memset(rptid, 0, sizeof(struct fcgs_rptid_req_s));
Jing Huang7725ccf2009-09-23 17:46:15 -07001308 rptid->port_id = port_id;
1309 rptid->port_type = port_type;
1310
Jing Huangf8ceafd2009-09-25 12:29:54 -07001311 return sizeof(struct fcgs_rptid_req_s) + sizeof(struct ct_hdr_s);
Jing Huang7725ccf2009-09-23 17:46:15 -07001312}
1313
1314u16
1315fc_ganxt_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id)
1316{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001317 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1318 struct fcgs_ganxt_req_s *ganxt = (struct fcgs_ganxt_req_s *)(cthdr + 1);
Maggie Zhangf16a1752010-12-09 19:12:32 -08001319 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
Jing Huang7725ccf2009-09-23 17:46:15 -07001320
1321 fc_gs_fchdr_build(fchs, d_id, s_id, 0);
1322 fc_gs_cthdr_build(cthdr, s_id, GS_GA_NXT);
1323
Jing Huang6a18b162010-10-18 17:08:54 -07001324 memset(ganxt, 0, sizeof(struct fcgs_ganxt_req_s));
Jing Huang7725ccf2009-09-23 17:46:15 -07001325 ganxt->port_id = port_id;
1326
Jing Huangf8ceafd2009-09-25 12:29:54 -07001327 return sizeof(struct ct_hdr_s) + sizeof(struct fcgs_ganxt_req_s);
Jing Huang7725ccf2009-09-23 17:46:15 -07001328}
1329
1330/*
1331 * Builds fc hdr and ct hdr for FDMI requests.
1332 */
1333u16
1334fc_fdmi_reqhdr_build(struct fchs_s *fchs, void *pyld, u32 s_id,
1335 u16 cmd_code)
1336{
1337
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001338 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
Maggie Zhangf16a1752010-12-09 19:12:32 -08001339 u32 d_id = bfa_hton3b(FC_MGMT_SERVER);
Jing Huang7725ccf2009-09-23 17:46:15 -07001340
1341 fc_gs_fchdr_build(fchs, d_id, s_id, 0);
1342 fc_gs_fdmi_cthdr_build(cthdr, s_id, cmd_code);
1343
Jing Huangf8ceafd2009-09-25 12:29:54 -07001344 return sizeof(struct ct_hdr_s);
Jing Huang7725ccf2009-09-23 17:46:15 -07001345}
1346
1347/*
1348 * Given a FC4 Type, this function returns a fc4 type bitmask
1349 */
1350void
1351fc_get_fc4type_bitmask(u8 fc4_type, u8 *bit_mask)
1352{
1353 u8 index;
Maggie50444a32010-11-29 18:26:32 -08001354 __be32 *ptr = (__be32 *) bit_mask;
Jing Huang7725ccf2009-09-23 17:46:15 -07001355 u32 type_value;
1356
1357 /*
1358 * @todo : Check for bitmask size
1359 */
1360
1361 index = fc4_type >> 5;
1362 type_value = 1 << (fc4_type % 32);
Jing Huangba816ea2010-10-18 17:10:50 -07001363 ptr[index] = cpu_to_be32(type_value);
Jing Huang7725ccf2009-09-23 17:46:15 -07001364
1365}
1366
1367/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001368 * GMAL Request
Jing Huang7725ccf2009-09-23 17:46:15 -07001369 */
1370u16
1371fc_gmal_req_build(struct fchs_s *fchs, void *pyld, u32 s_id, wwn_t wwn)
1372{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001373 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
Jing Huang7725ccf2009-09-23 17:46:15 -07001374 fcgs_gmal_req_t *gmal = (fcgs_gmal_req_t *) (cthdr + 1);
Maggie Zhangf16a1752010-12-09 19:12:32 -08001375 u32 d_id = bfa_hton3b(FC_MGMT_SERVER);
Jing Huang7725ccf2009-09-23 17:46:15 -07001376
1377 fc_gs_fchdr_build(fchs, d_id, s_id, 0);
1378 fc_gs_ms_cthdr_build(cthdr, s_id, GS_FC_GMAL_CMD,
1379 CT_GSSUBTYPE_CFGSERVER);
1380
Jing Huang6a18b162010-10-18 17:08:54 -07001381 memset(gmal, 0, sizeof(fcgs_gmal_req_t));
Jing Huang7725ccf2009-09-23 17:46:15 -07001382 gmal->wwn = wwn;
1383
Jing Huangf8ceafd2009-09-25 12:29:54 -07001384 return sizeof(struct ct_hdr_s) + sizeof(fcgs_gmal_req_t);
Jing Huang7725ccf2009-09-23 17:46:15 -07001385}
1386
1387/*
1388 * GFN (Get Fabric Name) Request
1389 */
1390u16
1391fc_gfn_req_build(struct fchs_s *fchs, void *pyld, u32 s_id, wwn_t wwn)
1392{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001393 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
Jing Huang7725ccf2009-09-23 17:46:15 -07001394 fcgs_gfn_req_t *gfn = (fcgs_gfn_req_t *) (cthdr + 1);
Maggie Zhangf16a1752010-12-09 19:12:32 -08001395 u32 d_id = bfa_hton3b(FC_MGMT_SERVER);
Jing Huang7725ccf2009-09-23 17:46:15 -07001396
1397 fc_gs_fchdr_build(fchs, d_id, s_id, 0);
1398 fc_gs_ms_cthdr_build(cthdr, s_id, GS_FC_GFN_CMD,
1399 CT_GSSUBTYPE_CFGSERVER);
1400
Jing Huang6a18b162010-10-18 17:08:54 -07001401 memset(gfn, 0, sizeof(fcgs_gfn_req_t));
Jing Huang7725ccf2009-09-23 17:46:15 -07001402 gfn->wwn = wwn;
1403
Jing Huangf8ceafd2009-09-25 12:29:54 -07001404 return sizeof(struct ct_hdr_s) + sizeof(fcgs_gfn_req_t);
Jing Huang7725ccf2009-09-23 17:46:15 -07001405}