Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  * Copyright (c) 2014- QLogic Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  * All rights reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  * www.qlogic.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11)  * fcbuild.c - FC link service frame building and parsing routines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) #include "bfad_drv.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) #include "bfa_fcbuild.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18)  * static build functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) static void     fc_els_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) 				 __be16 ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) static void     fc_bls_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) 				 __be16 ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) static struct fchs_s fc_els_req_tmpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) static struct fchs_s fc_els_rsp_tmpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) static struct fchs_s fc_bls_req_tmpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) static struct fchs_s fc_bls_rsp_tmpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) static struct fc_ba_acc_s ba_acc_tmpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) static struct fc_logi_s plogi_tmpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) static struct fc_prli_s prli_tmpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) static struct fc_rrq_s rrq_tmpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) static struct fchs_s fcp_fchs_tmpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) fcbuild_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) 	 * fc_els_req_tmpl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) 	fc_els_req_tmpl.routing = FC_RTG_EXT_LINK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) 	fc_els_req_tmpl.cat_info = FC_CAT_LD_REQUEST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) 	fc_els_req_tmpl.type = FC_TYPE_ELS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) 	fc_els_req_tmpl.f_ctl =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) 		bfa_hton3b(FCTL_SEQ_INI | FCTL_FS_EXCH | FCTL_END_SEQ |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) 			      FCTL_SI_XFER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) 	fc_els_req_tmpl.rx_id = FC_RXID_ANY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) 	 * fc_els_rsp_tmpl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) 	fc_els_rsp_tmpl.routing = FC_RTG_EXT_LINK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) 	fc_els_rsp_tmpl.cat_info = FC_CAT_LD_REPLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) 	fc_els_rsp_tmpl.type = FC_TYPE_ELS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) 	fc_els_rsp_tmpl.f_ctl =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) 		bfa_hton3b(FCTL_EC_RESP | FCTL_SEQ_INI | FCTL_LS_EXCH |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 			      FCTL_END_SEQ | FCTL_SI_XFER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) 	fc_els_rsp_tmpl.rx_id = FC_RXID_ANY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) 	 * fc_bls_req_tmpl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) 	fc_bls_req_tmpl.routing = FC_RTG_BASIC_LINK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) 	fc_bls_req_tmpl.type = FC_TYPE_BLS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) 	fc_bls_req_tmpl.f_ctl = bfa_hton3b(FCTL_END_SEQ | FCTL_SI_XFER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) 	fc_bls_req_tmpl.rx_id = FC_RXID_ANY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) 	 * fc_bls_rsp_tmpl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) 	fc_bls_rsp_tmpl.routing = FC_RTG_BASIC_LINK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) 	fc_bls_rsp_tmpl.cat_info = FC_CAT_BA_ACC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) 	fc_bls_rsp_tmpl.type = FC_TYPE_BLS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 	fc_bls_rsp_tmpl.f_ctl =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 		bfa_hton3b(FCTL_EC_RESP | FCTL_SEQ_INI | FCTL_LS_EXCH |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) 			      FCTL_END_SEQ | FCTL_SI_XFER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 	fc_bls_rsp_tmpl.rx_id = FC_RXID_ANY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) 	 * ba_acc_tmpl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) 	ba_acc_tmpl.seq_id_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) 	ba_acc_tmpl.low_seq_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) 	ba_acc_tmpl.high_seq_cnt = 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) 	 * plogi_tmpl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) 	plogi_tmpl.csp.verhi = FC_PH_VER_PH_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) 	plogi_tmpl.csp.verlo = FC_PH_VER_4_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) 	plogi_tmpl.csp.ciro = 0x1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) 	plogi_tmpl.csp.cisc = 0x0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) 	plogi_tmpl.csp.altbbcred = 0x0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 	plogi_tmpl.csp.conseq = cpu_to_be16(0x00FF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 	plogi_tmpl.csp.ro_bitmap = cpu_to_be16(0x0002);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) 	plogi_tmpl.csp.e_d_tov = cpu_to_be32(2000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 	plogi_tmpl.class3.class_valid = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 	plogi_tmpl.class3.sequential = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 	plogi_tmpl.class3.conseq = 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 	plogi_tmpl.class3.ospx = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) 	 * prli_tmpl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 	prli_tmpl.command = FC_ELS_PRLI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 	prli_tmpl.pglen = 0x10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 	prli_tmpl.pagebytes = cpu_to_be16(0x0014);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 	prli_tmpl.parampage.type = FC_TYPE_FCP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 	prli_tmpl.parampage.imagepair = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 	prli_tmpl.parampage.servparams.rxrdisab = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) 	 * rrq_tmpl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 	rrq_tmpl.els_cmd.els_code = FC_ELS_RRQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 	 * fcp_struct fchs_s mpl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 	fcp_fchs_tmpl.routing = FC_RTG_FC4_DEV_DATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 	fcp_fchs_tmpl.cat_info = FC_CAT_UNSOLICIT_CMD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 	fcp_fchs_tmpl.type = FC_TYPE_FCP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 	fcp_fchs_tmpl.f_ctl =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 		bfa_hton3b(FCTL_FS_EXCH | FCTL_END_SEQ | FCTL_SI_XFER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 	fcp_fchs_tmpl.seq_id = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) 	fcp_fchs_tmpl.rx_id = FC_RXID_ANY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) fc_gs_fchdr_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u32 ox_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) 	memset(fchs, 0, sizeof(struct fchs_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 	fchs->routing = FC_RTG_FC4_DEV_DATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 	fchs->cat_info = FC_CAT_UNSOLICIT_CTRL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 	fchs->type = FC_TYPE_SERVICES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) 	fchs->f_ctl =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 		bfa_hton3b(FCTL_SEQ_INI | FCTL_FS_EXCH | FCTL_END_SEQ |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 			      FCTL_SI_XFER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) 	fchs->rx_id = FC_RXID_ANY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) 	fchs->d_id = (d_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) 	fchs->s_id = (s_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 	fchs->ox_id = cpu_to_be16(ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 	 * @todo no need to set ox_id for request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) 	 *       no need to set rx_id for response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) fc_gsresp_fchdr_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 	memset(fchs, 0, sizeof(struct fchs_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 	fchs->routing = FC_RTG_FC4_DEV_DATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 	fchs->cat_info = FC_CAT_SOLICIT_CTRL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 	fchs->type = FC_TYPE_SERVICES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 	fchs->f_ctl =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 		bfa_hton3b(FCTL_EC_RESP | FCTL_SEQ_INI | FCTL_LS_EXCH |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 			   FCTL_END_SEQ | FCTL_SI_XFER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 	fchs->d_id = d_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 	fchs->s_id = s_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 	fchs->ox_id = ox_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) fc_els_req_build(struct fchs_s *fchs, u32 d_id, u32 s_id, __be16 ox_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 	memcpy(fchs, &fc_els_req_tmpl, sizeof(struct fchs_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 	fchs->d_id = (d_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 	fchs->s_id = (s_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 	fchs->ox_id = cpu_to_be16(ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) fc_els_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id, __be16 ox_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 	memcpy(fchs, &fc_els_rsp_tmpl, sizeof(struct fchs_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 	fchs->d_id = d_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 	fchs->s_id = s_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 	fchs->ox_id = ox_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) fc_bls_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id, __be16 ox_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 	memcpy(fchs, &fc_bls_rsp_tmpl, sizeof(struct fchs_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 	fchs->d_id = d_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 	fchs->s_id = s_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 	fchs->ox_id = ox_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) static          u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) fc_plogi_x_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 		 __be16 ox_id, wwn_t port_name, wwn_t node_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 		 u16 pdu_size, u16 bb_cr, u8 els_code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) 	struct fc_logi_s *plogi = (struct fc_logi_s *) (pld);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) 	memcpy(plogi, &plogi_tmpl, sizeof(struct fc_logi_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 	/* For FC AL bb_cr is 0 and altbbcred is 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 	if (!bb_cr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 		plogi->csp.altbbcred = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 	plogi->els_cmd.els_code = els_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 	if (els_code == FC_ELS_PLOGI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 		fc_els_req_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 		fc_els_rsp_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 	plogi->csp.rxsz = plogi->class3.rxsz = cpu_to_be16(pdu_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 	plogi->csp.bbcred  = cpu_to_be16(bb_cr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 	memcpy(&plogi->port_name, &port_name, sizeof(wwn_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 	memcpy(&plogi->node_name, &node_name, sizeof(wwn_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 	return sizeof(struct fc_logi_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) fc_flogi_build(struct fchs_s *fchs, struct fc_logi_s *flogi, u32 s_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 		u16 ox_id, wwn_t port_name, wwn_t node_name, u16 pdu_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 	       u8 set_npiv, u8 set_auth, u16 local_bb_credits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 	u32        d_id = bfa_hton3b(FC_FABRIC_PORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 	__be32	*vvl_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 	memcpy(flogi, &plogi_tmpl, sizeof(struct fc_logi_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 	flogi->els_cmd.els_code = FC_ELS_FLOGI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 	fc_els_req_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 	flogi->csp.rxsz = flogi->class3.rxsz = cpu_to_be16(pdu_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 	flogi->port_name = port_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 	flogi->node_name = node_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 	 * Set the NPIV Capability Bit ( word 1, bit 31) of Common
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 	 * Service Parameters.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 	flogi->csp.ciro = set_npiv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 	/* set AUTH capability */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 	flogi->csp.security = set_auth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 	flogi->csp.bbcred = cpu_to_be16(local_bb_credits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 	/* Set brcd token in VVL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 	vvl_info = (u32 *)&flogi->vvl[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 	/* set the flag to indicate the presence of VVL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 	flogi->csp.npiv_supp    = 1; /* @todo. field name is not correct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 	vvl_info[0]	= cpu_to_be32(FLOGI_VVL_BRCD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 	return sizeof(struct fc_logi_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) fc_flogi_acc_build(struct fchs_s *fchs, struct fc_logi_s *flogi, u32 s_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 		   __be16 ox_id, wwn_t port_name, wwn_t node_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 		   u16 pdu_size, u16 local_bb_credits, u8 bb_scn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 	u32        d_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 	u16	   bbscn_rxsz = (bb_scn << 12) | pdu_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 	memcpy(flogi, &plogi_tmpl, sizeof(struct fc_logi_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 	fc_els_rsp_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 	flogi->els_cmd.els_code = FC_ELS_ACC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 	flogi->class3.rxsz = cpu_to_be16(pdu_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 	flogi->csp.rxsz  = cpu_to_be16(bbscn_rxsz);	/* bb_scn/rxsz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 	flogi->port_name = port_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 	flogi->node_name = node_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 	flogi->csp.bbcred = cpu_to_be16(local_bb_credits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 	return sizeof(struct fc_logi_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) fc_fdisc_build(struct fchs_s *fchs, struct fc_logi_s *flogi, u32 s_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 		u16 ox_id, wwn_t port_name, wwn_t node_name, u16 pdu_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 	u32        d_id = bfa_hton3b(FC_FABRIC_PORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 	memcpy(flogi, &plogi_tmpl, sizeof(struct fc_logi_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 	flogi->els_cmd.els_code = FC_ELS_FDISC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 	fc_els_req_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 	flogi->csp.rxsz = flogi->class3.rxsz = cpu_to_be16(pdu_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 	flogi->port_name = port_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 	flogi->node_name = node_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 	return sizeof(struct fc_logi_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) fc_plogi_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 	       u16 ox_id, wwn_t port_name, wwn_t node_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 	       u16 pdu_size, u16 bb_cr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 	return fc_plogi_x_build(fchs, pld, d_id, s_id, ox_id, port_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 				node_name, pdu_size, bb_cr, FC_ELS_PLOGI);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) fc_plogi_acc_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 		   u16 ox_id, wwn_t port_name, wwn_t node_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 		   u16 pdu_size, u16 bb_cr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 	return fc_plogi_x_build(fchs, pld, d_id, s_id, ox_id, port_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 				node_name, pdu_size, bb_cr, FC_ELS_ACC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) enum fc_parse_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) fc_plogi_rsp_parse(struct fchs_s *fchs, int len, wwn_t port_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 	struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 	struct fc_logi_s *plogi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 	struct fc_ls_rjt_s *ls_rjt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 	switch (els_cmd->els_code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 	case FC_ELS_LS_RJT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 		ls_rjt = (struct fc_ls_rjt_s *) (fchs + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 		if (ls_rjt->reason_code == FC_LS_RJT_RSN_LOGICAL_BUSY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 			return FC_PARSE_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 			return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 	case FC_ELS_ACC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 		plogi = (struct fc_logi_s *) (fchs + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 		if (len < sizeof(struct fc_logi_s))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 			return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 		if (!wwn_is_equal(plogi->port_name, port_name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 			return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 		if (!plogi->class3.class_valid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 			return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 		if (be16_to_cpu(plogi->class3.rxsz) < (FC_MIN_PDUSZ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 			return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 		return FC_PARSE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 		return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) enum fc_parse_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) fc_plogi_parse(struct fchs_s *fchs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 	struct fc_logi_s *plogi = (struct fc_logi_s *) (fchs + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 	if (plogi->class3.class_valid != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 		return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 	if ((be16_to_cpu(plogi->class3.rxsz) < FC_MIN_PDUSZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 	    || (be16_to_cpu(plogi->class3.rxsz) > FC_MAX_PDUSZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 	    || (plogi->class3.rxsz == 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 		return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 	return FC_PARSE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) fc_prli_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 	      u16 ox_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 	struct fc_prli_s *prli = (struct fc_prli_s *) (pld);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 	fc_els_req_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 	memcpy(prli, &prli_tmpl, sizeof(struct fc_prli_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 	prli->command = FC_ELS_PRLI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 	prli->parampage.servparams.initiator     = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 	prli->parampage.servparams.retry         = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 	prli->parampage.servparams.rec_support   = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 	prli->parampage.servparams.task_retry_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 	prli->parampage.servparams.confirm       = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 	return sizeof(struct fc_prli_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) fc_prli_acc_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 		  __be16 ox_id, enum bfa_lport_role role)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 	struct fc_prli_s *prli = (struct fc_prli_s *) (pld);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 	fc_els_rsp_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 	memcpy(prli, &prli_tmpl, sizeof(struct fc_prli_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 	prli->command = FC_ELS_ACC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 	prli->parampage.servparams.initiator = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 	prli->parampage.rspcode = FC_PRLI_ACC_XQTD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 	return sizeof(struct fc_prli_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) enum fc_parse_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) fc_prli_rsp_parse(struct fc_prli_s *prli, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 	if (len < sizeof(struct fc_prli_s))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 		return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 	if (prli->command != FC_ELS_ACC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 		return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 	if ((prli->parampage.rspcode != FC_PRLI_ACC_XQTD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 	    && (prli->parampage.rspcode != FC_PRLI_ACC_PREDEF_IMG))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 		return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 	if (prli->parampage.servparams.target != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 		return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 	return FC_PARSE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) enum fc_parse_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) fc_prli_parse(struct fc_prli_s *prli)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 	if (prli->parampage.type != FC_TYPE_FCP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 		return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 	if (!prli->parampage.imagepair)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 		return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 	if (!prli->parampage.servparams.initiator)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 		return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 	return FC_PARSE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) fc_logo_build(struct fchs_s *fchs, struct fc_logo_s *logo, u32 d_id, u32 s_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 	      u16 ox_id, wwn_t port_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 	fc_els_req_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 	memset(logo, '\0', sizeof(struct fc_logo_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 	logo->els_cmd.els_code = FC_ELS_LOGO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 	logo->nport_id = (s_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 	logo->orig_port_name = port_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 	return sizeof(struct fc_logo_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) static u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) fc_adisc_x_build(struct fchs_s *fchs, struct fc_adisc_s *adisc, u32 d_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 		 u32 s_id, __be16 ox_id, wwn_t port_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 		 wwn_t node_name, u8 els_code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 	memset(adisc, '\0', sizeof(struct fc_adisc_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 	adisc->els_cmd.els_code = els_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 	if (els_code == FC_ELS_ADISC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 		fc_els_req_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 		fc_els_rsp_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 	adisc->orig_HA = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 	adisc->orig_port_name = port_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 	adisc->orig_node_name = node_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 	adisc->nport_id = (s_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 	return sizeof(struct fc_adisc_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) fc_adisc_build(struct fchs_s *fchs, struct fc_adisc_s *adisc, u32 d_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 		u32 s_id, __be16 ox_id, wwn_t port_name, wwn_t node_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 	return fc_adisc_x_build(fchs, adisc, d_id, s_id, ox_id, port_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 				node_name, FC_ELS_ADISC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) fc_adisc_acc_build(struct fchs_s *fchs, struct fc_adisc_s *adisc, u32 d_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 		   u32 s_id, __be16 ox_id, wwn_t port_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 		   wwn_t node_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 	return fc_adisc_x_build(fchs, adisc, d_id, s_id, ox_id, port_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 				node_name, FC_ELS_ACC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) enum fc_parse_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) fc_adisc_rsp_parse(struct fc_adisc_s *adisc, int len, wwn_t port_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 				 wwn_t node_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 	if (len < sizeof(struct fc_adisc_s))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 		return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 	if (adisc->els_cmd.els_code != FC_ELS_ACC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 		return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 	if (!wwn_is_equal(adisc->orig_port_name, port_name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 		return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 	return FC_PARSE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) enum fc_parse_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) fc_adisc_parse(struct fchs_s *fchs, void *pld, u32 host_dap, wwn_t node_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 	       wwn_t port_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 	struct fc_adisc_s *adisc = (struct fc_adisc_s *) pld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 	if (adisc->els_cmd.els_code != FC_ELS_ACC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 		return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 	if ((adisc->nport_id == (host_dap))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 	    && wwn_is_equal(adisc->orig_port_name, port_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 	    && wwn_is_equal(adisc->orig_node_name, node_name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 		return FC_PARSE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 	return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) enum fc_parse_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) fc_pdisc_parse(struct fchs_s *fchs, wwn_t node_name, wwn_t port_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 	struct fc_logi_s *pdisc = (struct fc_logi_s *) (fchs + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 	if (pdisc->class3.class_valid != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 		return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 	if ((be16_to_cpu(pdisc->class3.rxsz) <
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 		(FC_MIN_PDUSZ - sizeof(struct fchs_s)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 	    || (pdisc->class3.rxsz == 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 		return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 	if (!wwn_is_equal(pdisc->port_name, port_name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 		return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 	if (!wwn_is_equal(pdisc->node_name, node_name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 		return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 	return FC_PARSE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) fc_abts_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 	memcpy(fchs, &fc_bls_req_tmpl, sizeof(struct fchs_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 	fchs->cat_info = FC_CAT_ABTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 	fchs->d_id = (d_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 	fchs->s_id = (s_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 	fchs->ox_id = cpu_to_be16(ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 	return sizeof(struct fchs_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) enum fc_parse_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) fc_abts_rsp_parse(struct fchs_s *fchs, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 	if ((fchs->cat_info == FC_CAT_BA_ACC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 	    || (fchs->cat_info == FC_CAT_BA_RJT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 		return FC_PARSE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 	return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) fc_rrq_build(struct fchs_s *fchs, struct fc_rrq_s *rrq, u32 d_id, u32 s_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 	     u16 ox_id, u16 rrq_oxid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 	fc_els_req_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 	 * build rrq payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 	memcpy(rrq, &rrq_tmpl, sizeof(struct fc_rrq_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 	rrq->s_id = (s_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 	rrq->ox_id = cpu_to_be16(rrq_oxid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 	rrq->rx_id = FC_RXID_ANY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 	return sizeof(struct fc_rrq_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) fc_logo_acc_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 		  __be16 ox_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 	struct fc_els_cmd_s *acc = pld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 	fc_els_rsp_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 	memset(acc, 0, sizeof(struct fc_els_cmd_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 	acc->els_code = FC_ELS_ACC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 	return sizeof(struct fc_els_cmd_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) fc_ls_rjt_build(struct fchs_s *fchs, struct fc_ls_rjt_s *ls_rjt, u32 d_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 		u32 s_id, __be16 ox_id, u8 reason_code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 		u8 reason_code_expl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 	fc_els_rsp_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 	memset(ls_rjt, 0, sizeof(struct fc_ls_rjt_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 	ls_rjt->els_cmd.els_code = FC_ELS_LS_RJT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 	ls_rjt->reason_code = reason_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 	ls_rjt->reason_code_expl = reason_code_expl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 	ls_rjt->vendor_unique = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 	return sizeof(struct fc_ls_rjt_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) fc_ba_acc_build(struct fchs_s *fchs, struct fc_ba_acc_s *ba_acc, u32 d_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 		u32 s_id, __be16 ox_id, u16 rx_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 	fc_bls_rsp_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 	memcpy(ba_acc, &ba_acc_tmpl, sizeof(struct fc_ba_acc_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 	fchs->rx_id = rx_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 	ba_acc->ox_id = fchs->ox_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 	ba_acc->rx_id = fchs->rx_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 	return sizeof(struct fc_ba_acc_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) fc_ls_acc_build(struct fchs_s *fchs, struct fc_els_cmd_s *els_cmd, u32 d_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 		u32 s_id, __be16 ox_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 	fc_els_rsp_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 	memset(els_cmd, 0, sizeof(struct fc_els_cmd_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 	els_cmd->els_code = FC_ELS_ACC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 	return sizeof(struct fc_els_cmd_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) fc_logout_params_pages(struct fchs_s *fc_frame, u8 els_code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 	int             num_pages = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 	struct fc_prlo_s *prlo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 	struct fc_tprlo_s *tprlo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 	if (els_code == FC_ELS_PRLO) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 		prlo = (struct fc_prlo_s *) (fc_frame + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 		num_pages = (be16_to_cpu(prlo->payload_len) - 4) / 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 		tprlo = (struct fc_tprlo_s *) (fc_frame + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 		num_pages = (be16_to_cpu(tprlo->payload_len) - 4) / 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 	return num_pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) fc_tprlo_acc_build(struct fchs_s *fchs, struct fc_tprlo_acc_s *tprlo_acc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 		u32 d_id, u32 s_id, __be16 ox_id, int num_pages)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 	int             page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 	fc_els_rsp_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 	memset(tprlo_acc, 0, (num_pages * 16) + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 	tprlo_acc->command = FC_ELS_ACC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 	tprlo_acc->page_len = 0x10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 	tprlo_acc->payload_len = cpu_to_be16((num_pages * 16) + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 	for (page = 0; page < num_pages; page++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 		tprlo_acc->tprlo_acc_params[page].opa_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 		tprlo_acc->tprlo_acc_params[page].rpa_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 		tprlo_acc->tprlo_acc_params[page].fc4type_csp = FC_TYPE_FCP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 		tprlo_acc->tprlo_acc_params[page].orig_process_assc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 		tprlo_acc->tprlo_acc_params[page].resp_process_assc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 	return be16_to_cpu(tprlo_acc->payload_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) fc_prlo_acc_build(struct fchs_s *fchs, struct fc_prlo_acc_s *prlo_acc, u32 d_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 		  u32 s_id, __be16 ox_id, int num_pages)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 	int             page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 	fc_els_rsp_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 	memset(prlo_acc, 0, (num_pages * 16) + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 	prlo_acc->command = FC_ELS_ACC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 	prlo_acc->page_len = 0x10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 	prlo_acc->payload_len = cpu_to_be16((num_pages * 16) + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 	for (page = 0; page < num_pages; page++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 		prlo_acc->prlo_acc_params[page].opa_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 		prlo_acc->prlo_acc_params[page].rpa_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 		prlo_acc->prlo_acc_params[page].fc4type_csp = FC_TYPE_FCP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 		prlo_acc->prlo_acc_params[page].orig_process_assc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 		prlo_acc->prlo_acc_params[page].resp_process_assc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 	return be16_to_cpu(prlo_acc->payload_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) fc_rnid_build(struct fchs_s *fchs, struct fc_rnid_cmd_s *rnid, u32 d_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 		u32 s_id, u16 ox_id, u32 data_format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 	fc_els_req_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 	memset(rnid, 0, sizeof(struct fc_rnid_cmd_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 	rnid->els_cmd.els_code = FC_ELS_RNID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 	rnid->node_id_data_format = data_format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 	return sizeof(struct fc_rnid_cmd_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) fc_rnid_acc_build(struct fchs_s *fchs, struct fc_rnid_acc_s *rnid_acc, u32 d_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 		  u32 s_id, __be16 ox_id, u32 data_format,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 		  struct fc_rnid_common_id_data_s *common_id_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 		  struct fc_rnid_general_topology_data_s *gen_topo_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 	memset(rnid_acc, 0, sizeof(struct fc_rnid_acc_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 	fc_els_rsp_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 	rnid_acc->els_cmd.els_code = FC_ELS_ACC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 	rnid_acc->node_id_data_format = data_format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 	rnid_acc->common_id_data_length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 			sizeof(struct fc_rnid_common_id_data_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 	rnid_acc->common_id_data = *common_id_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 	if (data_format == RNID_NODEID_DATA_FORMAT_DISCOVERY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 		rnid_acc->specific_id_data_length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 			sizeof(struct fc_rnid_general_topology_data_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 		rnid_acc->gen_topology_data = *gen_topo_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 		return sizeof(struct fc_rnid_acc_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 		return sizeof(struct fc_rnid_acc_s) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 			sizeof(struct fc_rnid_general_topology_data_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) fc_rpsc_build(struct fchs_s *fchs, struct fc_rpsc_cmd_s *rpsc, u32 d_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 		u32 s_id, u16 ox_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 	fc_els_req_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 	memset(rpsc, 0, sizeof(struct fc_rpsc_cmd_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 	rpsc->els_cmd.els_code = FC_ELS_RPSC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 	return sizeof(struct fc_rpsc_cmd_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) fc_rpsc2_build(struct fchs_s *fchs, struct fc_rpsc2_cmd_s *rpsc2, u32 d_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 		u32 s_id, u32 *pid_list, u16 npids)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 	u32 dctlr_id = FC_DOMAIN_CTRLR(bfa_hton3b(d_id));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 	int i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 	fc_els_req_build(fchs, bfa_hton3b(dctlr_id), s_id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 	memset(rpsc2, 0, sizeof(struct fc_rpsc2_cmd_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 	rpsc2->els_cmd.els_code = FC_ELS_RPSC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 	rpsc2->token = cpu_to_be32(FC_BRCD_TOKEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 	rpsc2->num_pids  = cpu_to_be16(npids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 	for (i = 0; i < npids; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 		rpsc2->pid_list[i].pid = pid_list[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 	return sizeof(struct fc_rpsc2_cmd_s) + ((npids - 1) * (sizeof(u32)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) fc_rpsc_acc_build(struct fchs_s *fchs, struct fc_rpsc_acc_s *rpsc_acc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 		u32 d_id, u32 s_id, __be16 ox_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 		  struct fc_rpsc_speed_info_s *oper_speed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 	memset(rpsc_acc, 0, sizeof(struct fc_rpsc_acc_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 	fc_els_rsp_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 	rpsc_acc->command = FC_ELS_ACC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 	rpsc_acc->num_entries = cpu_to_be16(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 	rpsc_acc->speed_info[0].port_speed_cap =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) 		cpu_to_be16(oper_speed->port_speed_cap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 	rpsc_acc->speed_info[0].port_op_speed =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 		cpu_to_be16(oper_speed->port_op_speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 	return sizeof(struct fc_rpsc_acc_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) fc_pdisc_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 	       wwn_t port_name, wwn_t node_name, u16 pdu_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 	struct fc_logi_s *pdisc = (struct fc_logi_s *) (fchs + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 	memcpy(pdisc, &plogi_tmpl, sizeof(struct fc_logi_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 	pdisc->els_cmd.els_code = FC_ELS_PDISC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 	fc_els_req_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 	pdisc->csp.rxsz = pdisc->class3.rxsz = cpu_to_be16(pdu_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 	pdisc->port_name = port_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 	pdisc->node_name = node_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 	return sizeof(struct fc_logi_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) fc_pdisc_rsp_parse(struct fchs_s *fchs, int len, wwn_t port_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 	struct fc_logi_s *pdisc = (struct fc_logi_s *) (fchs + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 	if (len < sizeof(struct fc_logi_s))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 		return FC_PARSE_LEN_INVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 	if (pdisc->els_cmd.els_code != FC_ELS_ACC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 		return FC_PARSE_ACC_INVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 	if (!wwn_is_equal(pdisc->port_name, port_name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 		return FC_PARSE_PWWN_NOT_EQUAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 	if (!pdisc->class3.class_valid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 		return FC_PARSE_NWWN_NOT_EQUAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 	if (be16_to_cpu(pdisc->class3.rxsz) < (FC_MIN_PDUSZ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 		return FC_PARSE_RXSZ_INVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 	return FC_PARSE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) fc_prlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 	      int num_pages)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 	struct fc_prlo_s *prlo = (struct fc_prlo_s *) (fchs + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 	int             page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 	fc_els_req_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 	memset(prlo, 0, (num_pages * 16) + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 	prlo->command = FC_ELS_PRLO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 	prlo->page_len = 0x10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 	prlo->payload_len = cpu_to_be16((num_pages * 16) + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 	for (page = 0; page < num_pages; page++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 		prlo->prlo_params[page].type = FC_TYPE_FCP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 		prlo->prlo_params[page].opa_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 		prlo->prlo_params[page].rpa_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 		prlo->prlo_params[page].orig_process_assc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 		prlo->prlo_params[page].resp_process_assc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 	return be16_to_cpu(prlo->payload_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) fc_tprlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 	       int num_pages, enum fc_tprlo_type tprlo_type, u32 tpr_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 	struct fc_tprlo_s *tprlo = (struct fc_tprlo_s *) (fchs + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 	int             page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 	fc_els_req_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 	memset(tprlo, 0, (num_pages * 16) + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 	tprlo->command = FC_ELS_TPRLO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 	tprlo->page_len = 0x10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 	tprlo->payload_len = cpu_to_be16((num_pages * 16) + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 	for (page = 0; page < num_pages; page++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 		tprlo->tprlo_params[page].type = FC_TYPE_FCP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 		tprlo->tprlo_params[page].opa_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 		tprlo->tprlo_params[page].rpa_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 		tprlo->tprlo_params[page].orig_process_assc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 		tprlo->tprlo_params[page].resp_process_assc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 		if (tprlo_type == FC_GLOBAL_LOGO) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 			tprlo->tprlo_params[page].global_process_logout = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 		} else if (tprlo_type == FC_TPR_LOGO) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 			tprlo->tprlo_params[page].tpo_nport_valid = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 			tprlo->tprlo_params[page].tpo_nport_id = (tpr_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 	return be16_to_cpu(tprlo->payload_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) fc_ba_rjt_build(struct fchs_s *fchs, u32 d_id, u32 s_id, __be16 ox_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 		u32 reason_code, u32 reason_expl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 	struct fc_ba_rjt_s *ba_rjt = (struct fc_ba_rjt_s *) (fchs + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 	fc_bls_rsp_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 	fchs->cat_info = FC_CAT_BA_RJT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 	ba_rjt->reason_code = reason_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 	ba_rjt->reason_expl = reason_expl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 	return sizeof(struct fc_ba_rjt_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) fc_gs_cthdr_build(struct ct_hdr_s *cthdr, u32 s_id, u16 cmd_code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 	memset(cthdr, 0, sizeof(struct ct_hdr_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 	cthdr->rev_id = CT_GS3_REVISION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 	cthdr->gs_type = CT_GSTYPE_DIRSERVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 	cthdr->gs_sub_type = CT_GSSUBTYPE_NAMESERVER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 	cthdr->cmd_rsp_code = cpu_to_be16(cmd_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) fc_gs_fdmi_cthdr_build(struct ct_hdr_s *cthdr, u32 s_id, u16 cmd_code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 	memset(cthdr, 0, sizeof(struct ct_hdr_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 	cthdr->rev_id = CT_GS3_REVISION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 	cthdr->gs_type = CT_GSTYPE_MGMTSERVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 	cthdr->gs_sub_type = CT_GSSUBTYPE_HBA_MGMTSERVER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 	cthdr->cmd_rsp_code = cpu_to_be16(cmd_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) fc_gs_ms_cthdr_build(struct ct_hdr_s *cthdr, u32 s_id, u16 cmd_code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 					 u8 sub_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 	memset(cthdr, 0, sizeof(struct ct_hdr_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 	cthdr->rev_id = CT_GS3_REVISION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 	cthdr->gs_type = CT_GSTYPE_MGMTSERVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 	cthdr->gs_sub_type = sub_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 	cthdr->cmd_rsp_code = cpu_to_be16(cmd_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) fc_gidpn_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 	       wwn_t port_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 	struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 	struct fcgs_gidpn_req_s *gidpn = (struct fcgs_gidpn_req_s *)(cthdr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 	u32        d_id = bfa_hton3b(FC_NAME_SERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 	fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 	fc_gs_cthdr_build(cthdr, s_id, GS_GID_PN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 	memset(gidpn, 0, sizeof(struct fcgs_gidpn_req_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 	gidpn->port_name = port_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 	return sizeof(struct fcgs_gidpn_req_s) + sizeof(struct ct_hdr_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) fc_gpnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 	       u32 port_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 	struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 	fcgs_gpnid_req_t *gpnid = (fcgs_gpnid_req_t *) (cthdr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 	u32        d_id = bfa_hton3b(FC_NAME_SERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 	fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 	fc_gs_cthdr_build(cthdr, s_id, GS_GPN_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 	memset(gpnid, 0, sizeof(fcgs_gpnid_req_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 	gpnid->dap = port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 	return sizeof(fcgs_gpnid_req_t) + sizeof(struct ct_hdr_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) fc_gnnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 	       u32 port_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 	struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 	fcgs_gnnid_req_t *gnnid = (fcgs_gnnid_req_t *) (cthdr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 	u32        d_id = bfa_hton3b(FC_NAME_SERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 	fc_gs_cthdr_build(cthdr, s_id, GS_GNN_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 	memset(gnnid, 0, sizeof(fcgs_gnnid_req_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 	gnnid->dap = port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 	return sizeof(fcgs_gnnid_req_t) + sizeof(struct ct_hdr_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) fc_ct_rsp_parse(struct ct_hdr_s *cthdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 	if (be16_to_cpu(cthdr->cmd_rsp_code) != CT_RSP_ACCEPT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 		if (cthdr->reason_code == CT_RSN_LOGICAL_BUSY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 			return FC_PARSE_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 			return FC_PARSE_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 	return FC_PARSE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) fc_gs_rjt_build(struct fchs_s *fchs,  struct ct_hdr_s *cthdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 		u32 d_id, u32 s_id, u16 ox_id, u8 reason_code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 		u8 reason_code_expl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 	fc_gsresp_fchdr_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 	cthdr->cmd_rsp_code = cpu_to_be16(CT_RSP_REJECT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 	cthdr->rev_id = CT_GS3_REVISION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 	cthdr->reason_code = reason_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 	cthdr->exp_code    = reason_code_expl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 	return sizeof(struct ct_hdr_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) fc_scr_build(struct fchs_s *fchs, struct fc_scr_s *scr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 		u8 set_br_reg, u32 s_id, u16 ox_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 	u32        d_id = bfa_hton3b(FC_FABRIC_CONTROLLER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 	fc_els_req_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 	memset(scr, 0, sizeof(struct fc_scr_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 	scr->command = FC_ELS_SCR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 	scr->reg_func = FC_SCR_REG_FUNC_FULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 	if (set_br_reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 		scr->vu_reg_func = FC_VU_SCR_REG_FUNC_FABRIC_NAME_CHANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 	return sizeof(struct fc_scr_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) fc_rscn_build(struct fchs_s *fchs, struct fc_rscn_pl_s *rscn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 		u32 s_id, u16 ox_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 	u32        d_id = bfa_hton3b(FC_FABRIC_CONTROLLER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 	u16        payldlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 	fc_els_req_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) 	rscn->command = FC_ELS_RSCN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 	rscn->pagelen = sizeof(rscn->event[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 	payldlen = sizeof(u32) + rscn->pagelen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) 	rscn->payldlen = cpu_to_be16(payldlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) 	rscn->event[0].format = FC_RSCN_FORMAT_PORTID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) 	rscn->event[0].portid = s_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 	return sizeof(struct fc_rscn_pl_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) fc_rftid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 	       enum bfa_lport_role roles)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 	struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 	struct fcgs_rftid_req_s *rftid = (struct fcgs_rftid_req_s *)(cthdr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) 	u32        type_value, d_id = bfa_hton3b(FC_NAME_SERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 	u8         index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 	fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) 	fc_gs_cthdr_build(cthdr, s_id, GS_RFT_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 	memset(rftid, 0, sizeof(struct fcgs_rftid_req_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) 	rftid->dap = s_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) 	/* By default, FCP FC4 Type is registered */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 	index = FC_TYPE_FCP >> 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) 	type_value = 1 << (FC_TYPE_FCP % 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 	rftid->fc4_type[index] = cpu_to_be32(type_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 	return sizeof(struct fcgs_rftid_req_s) + sizeof(struct ct_hdr_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) fc_rftid_build_sol(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 		   u8 *fc4_bitmap, u32 bitmap_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) 	struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) 	struct fcgs_rftid_req_s *rftid = (struct fcgs_rftid_req_s *)(cthdr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 	u32        d_id = bfa_hton3b(FC_NAME_SERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 	fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 	fc_gs_cthdr_build(cthdr, s_id, GS_RFT_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) 	memset(rftid, 0, sizeof(struct fcgs_rftid_req_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) 	rftid->dap = s_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 	memcpy((void *)rftid->fc4_type, (void *)fc4_bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 		(bitmap_size < 32 ? bitmap_size : 32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 	return sizeof(struct fcgs_rftid_req_s) + sizeof(struct ct_hdr_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) fc_rffid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 	       u8 fc4_type, u8 fc4_ftrs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 	struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 	struct fcgs_rffid_req_s *rffid = (struct fcgs_rffid_req_s *)(cthdr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 	u32         d_id = bfa_hton3b(FC_NAME_SERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) 	fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 	fc_gs_cthdr_build(cthdr, s_id, GS_RFF_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 	memset(rffid, 0, sizeof(struct fcgs_rffid_req_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 	rffid->dap	    = s_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 	rffid->fc4ftr_bits  = fc4_ftrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 	rffid->fc4_type	    = fc4_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 	return sizeof(struct fcgs_rffid_req_s) + sizeof(struct ct_hdr_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) fc_rspnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 		u8 *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 	struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 	struct fcgs_rspnid_req_s *rspnid =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 			(struct fcgs_rspnid_req_s *)(cthdr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 	u32        d_id = bfa_hton3b(FC_NAME_SERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 	fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) 	fc_gs_cthdr_build(cthdr, s_id, GS_RSPN_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) 	memset(rspnid, 0, sizeof(struct fcgs_rspnid_req_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 	rspnid->dap = s_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) 	strlcpy(rspnid->spn, name, sizeof(rspnid->spn));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) 	rspnid->spn_len = (u8) strlen(rspnid->spn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) 	return sizeof(struct fcgs_rspnid_req_s) + sizeof(struct ct_hdr_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) fc_rsnn_nn_build(struct fchs_s *fchs, void *pyld, u32 s_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 			wwn_t node_name, u8 *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) 	struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) 	struct fcgs_rsnn_nn_req_s *rsnn_nn =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) 		(struct fcgs_rsnn_nn_req_s *) (cthdr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) 	u32	d_id = bfa_hton3b(FC_NAME_SERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 	fc_gs_fchdr_build(fchs, d_id, s_id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) 	fc_gs_cthdr_build(cthdr, s_id, GS_RSNN_NN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) 	memset(rsnn_nn, 0, sizeof(struct fcgs_rsnn_nn_req_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) 	rsnn_nn->node_name = node_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 	strlcpy(rsnn_nn->snn, name, sizeof(rsnn_nn->snn));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 	rsnn_nn->snn_len = (u8) strlen(rsnn_nn->snn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 	return sizeof(struct fcgs_rsnn_nn_req_s) + sizeof(struct ct_hdr_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) fc_gid_ft_build(struct fchs_s *fchs, void *pyld, u32 s_id, u8 fc4_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) 	struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) 	struct fcgs_gidft_req_s *gidft = (struct fcgs_gidft_req_s *)(cthdr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) 	u32        d_id = bfa_hton3b(FC_NAME_SERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) 	fc_gs_fchdr_build(fchs, d_id, s_id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) 	fc_gs_cthdr_build(cthdr, s_id, GS_GID_FT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) 	memset(gidft, 0, sizeof(struct fcgs_gidft_req_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 	gidft->fc4_type = fc4_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) 	gidft->domain_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) 	gidft->area_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 	return sizeof(struct fcgs_gidft_req_s) + sizeof(struct ct_hdr_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) fc_rpnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) 	       wwn_t port_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) 	struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) 	struct fcgs_rpnid_req_s *rpnid = (struct fcgs_rpnid_req_s *)(cthdr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) 	u32        d_id = bfa_hton3b(FC_NAME_SERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) 	fc_gs_fchdr_build(fchs, d_id, s_id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 	fc_gs_cthdr_build(cthdr, s_id, GS_RPN_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) 	memset(rpnid, 0, sizeof(struct fcgs_rpnid_req_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 	rpnid->port_id = port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 	rpnid->port_name = port_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) 	return sizeof(struct fcgs_rpnid_req_s) + sizeof(struct ct_hdr_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) fc_rnnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) 	       wwn_t node_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) 	struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) 	struct fcgs_rnnid_req_s *rnnid = (struct fcgs_rnnid_req_s *)(cthdr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) 	u32        d_id = bfa_hton3b(FC_NAME_SERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) 	fc_gs_fchdr_build(fchs, d_id, s_id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) 	fc_gs_cthdr_build(cthdr, s_id, GS_RNN_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) 	memset(rnnid, 0, sizeof(struct fcgs_rnnid_req_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) 	rnnid->port_id = port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) 	rnnid->node_name = node_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) 	return sizeof(struct fcgs_rnnid_req_s) + sizeof(struct ct_hdr_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) fc_rcsid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) 	       u32 cos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) 	struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) 	struct fcgs_rcsid_req_s *rcsid =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) 			(struct fcgs_rcsid_req_s *) (cthdr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) 	u32        d_id = bfa_hton3b(FC_NAME_SERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) 	fc_gs_fchdr_build(fchs, d_id, s_id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) 	fc_gs_cthdr_build(cthdr, s_id, GS_RCS_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) 	memset(rcsid, 0, sizeof(struct fcgs_rcsid_req_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) 	rcsid->port_id = port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) 	rcsid->cos = cos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) 	return sizeof(struct fcgs_rcsid_req_s) + sizeof(struct ct_hdr_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) fc_rptid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) 	       u8 port_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) 	struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) 	struct fcgs_rptid_req_s *rptid = (struct fcgs_rptid_req_s *)(cthdr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) 	u32        d_id = bfa_hton3b(FC_NAME_SERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) 	fc_gs_fchdr_build(fchs, d_id, s_id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) 	fc_gs_cthdr_build(cthdr, s_id, GS_RPT_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) 	memset(rptid, 0, sizeof(struct fcgs_rptid_req_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) 	rptid->port_id = port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) 	rptid->port_type = port_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) 	return sizeof(struct fcgs_rptid_req_s) + sizeof(struct ct_hdr_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) fc_ganxt_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) 	struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) 	struct fcgs_ganxt_req_s *ganxt = (struct fcgs_ganxt_req_s *)(cthdr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) 	u32        d_id = bfa_hton3b(FC_NAME_SERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) 	fc_gs_fchdr_build(fchs, d_id, s_id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) 	fc_gs_cthdr_build(cthdr, s_id, GS_GA_NXT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) 	memset(ganxt, 0, sizeof(struct fcgs_ganxt_req_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) 	ganxt->port_id = port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) 	return sizeof(struct ct_hdr_s) + sizeof(struct fcgs_ganxt_req_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274)  * Builds fc hdr and ct hdr for FDMI requests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) fc_fdmi_reqhdr_build(struct fchs_s *fchs, void *pyld, u32 s_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) 		     u16 cmd_code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) 	struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) 	u32        d_id = bfa_hton3b(FC_MGMT_SERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) 	fc_gs_fchdr_build(fchs, d_id, s_id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) 	fc_gs_fdmi_cthdr_build(cthdr, s_id, cmd_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) 	return sizeof(struct ct_hdr_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291)  * Given a FC4 Type, this function returns a fc4 type bitmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) fc_get_fc4type_bitmask(u8 fc4_type, u8 *bit_mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) 	u8         index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) 	__be32       *ptr = (__be32 *) bit_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) 	u32        type_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) 	 * @todo : Check for bitmask size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) 	index = fc4_type >> 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) 	type_value = 1 << (fc4_type % 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) 	ptr[index] = cpu_to_be32(type_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311)  *	GMAL Request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) fc_gmal_req_build(struct fchs_s *fchs, void *pyld, u32 s_id, wwn_t wwn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) 	struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) 	fcgs_gmal_req_t *gmal = (fcgs_gmal_req_t *) (cthdr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) 	u32        d_id = bfa_hton3b(FC_MGMT_SERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) 	fc_gs_fchdr_build(fchs, d_id, s_id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) 	fc_gs_ms_cthdr_build(cthdr, s_id, GS_FC_GMAL_CMD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) 			CT_GSSUBTYPE_CFGSERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) 	memset(gmal, 0, sizeof(fcgs_gmal_req_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) 	gmal->wwn = wwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) 	return sizeof(struct ct_hdr_s) + sizeof(fcgs_gmal_req_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331)  * GFN (Get Fabric Name) Request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) fc_gfn_req_build(struct fchs_s *fchs, void *pyld, u32 s_id, wwn_t wwn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) 	struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) 	fcgs_gfn_req_t *gfn = (fcgs_gfn_req_t *) (cthdr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) 	u32        d_id = bfa_hton3b(FC_MGMT_SERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) 	fc_gs_fchdr_build(fchs, d_id, s_id, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) 	fc_gs_ms_cthdr_build(cthdr, s_id, GS_FC_GFN_CMD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) 			CT_GSSUBTYPE_CFGSERVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) 	memset(gfn, 0, sizeof(fcgs_gfn_req_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) 	gfn->wwn = wwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) 	return sizeof(struct ct_hdr_s) + sizeof(fcgs_gfn_req_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) }