2 * Copyright(c) 2008 Intel Corporation. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17 * Maintained at www.Open-FCoE.org
21 * Provide interface to send ELS/CT FC frames
24 #include <linux/export.h>
25 #include <asm/unaligned.h>
26 #include <scsi/fc/fc_gs.h>
27 #include <scsi/fc/fc_ns.h>
28 #include <scsi/fc/fc_els.h>
29 #include <scsi/libfc.h>
30 #include <scsi/fc_encode.h>
34 * fc_elsct_send() - Send an ELS or CT frame
35 * @lport: The local port to send the frame on
36 * @did: The destination ID for the frame
37 * @fp: The frame to be sent
38 * @op: The operational code
39 * @resp: The callback routine when the response is received
40 * @arg: The argument to pass to the response callback routine
41 * @timer_msec: The timeout period for the frame (in msecs)
43 struct fc_seq
*fc_elsct_send(struct fc_lport
*lport
, u32 did
,
44 struct fc_frame
*fp
, unsigned int op
,
45 void (*resp
)(struct fc_seq
*,
48 void *arg
, u32 timer_msec
)
51 enum fc_fh_type fh_type
;
55 if ((op
>= ELS_LS_RJT
) && (op
<= ELS_AUTH_ELS
))
56 rc
= fc_els_fill(lport
, did
, fp
, op
, &r_ctl
, &fh_type
);
59 rc
= fc_ct_fill(lport
, did
, fp
, op
, &r_ctl
, &fh_type
);
60 did
= FC_FID_DIR_SERV
;
68 fc_fill_fc_hdr(fp
, r_ctl
, did
, lport
->port_id
, fh_type
,
71 return lport
->tt
.exch_seq_send(lport
, fp
, resp
, NULL
, arg
, timer_msec
);
73 EXPORT_SYMBOL(fc_elsct_send
);
76 * fc_elsct_init() - Initialize the ELS/CT layer
77 * @lport: The local port to initialize the ELS/CT layer for
79 int fc_elsct_init(struct fc_lport
*lport
)
81 if (!lport
->tt
.elsct_send
)
82 lport
->tt
.elsct_send
= fc_elsct_send
;
86 EXPORT_SYMBOL(fc_elsct_init
);
89 * fc_els_resp_type() - Return a string describing the ELS response
90 * @fp: The frame pointer or possible error code
92 const char *fc_els_resp_type(struct fc_frame
*fp
)
95 struct fc_frame_header
*fh
;
99 switch (-PTR_ERR(fp
)) {
101 msg
= "response no error";
104 msg
= "response timeout";
107 msg
= "response closed";
110 msg
= "response unknown error";
114 fh
= fc_frame_header_get(fp
);
115 switch (fh
->fh_type
) {
117 switch (fc_frame_payload_op(fp
)) {
125 msg
= "response unknown ELS";
130 ct
= fc_frame_payload_get(fp
, sizeof(*ct
));
132 switch (ntohs(ct
->ct_cmd
)) {
140 msg
= "response unknown CT";
144 msg
= "short CT response";
148 msg
= "response not ELS or CT";