1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright(c) 2008 Intel Corporation. All rights reserved.
5 * Maintained at www.Open-FCoE.org
9 * Provide interface to send ELS/CT FC frames
12 #include <linux/export.h>
13 #include <asm/unaligned.h>
14 #include <scsi/fc/fc_gs.h>
15 #include <scsi/fc/fc_ns.h>
16 #include <scsi/fc/fc_els.h>
17 #include <scsi/libfc.h>
18 #include "fc_encode.h"
22 * fc_elsct_send() - Send an ELS or CT frame
23 * @lport: The local port to send the frame on
24 * @did: The destination ID for the frame
25 * @fp: The frame to be sent
26 * @op: The operational code
27 * @resp: The callback routine when the response is received
28 * @arg: The argument to pass to the response callback routine
29 * @timer_msec: The timeout period for the frame (in msecs)
31 struct fc_seq
*fc_elsct_send(struct fc_lport
*lport
, u32 did
,
32 struct fc_frame
*fp
, unsigned int op
,
33 void (*resp
)(struct fc_seq
*,
36 void *arg
, u32 timer_msec
)
39 enum fc_fh_type fh_type
;
43 if ((op
>= ELS_LS_RJT
) && (op
<= ELS_AUTH_ELS
))
44 rc
= fc_els_fill(lport
, did
, fp
, op
, &r_ctl
, &fh_type
);
47 rc
= fc_ct_fill(lport
, did
, fp
, op
, &r_ctl
, &fh_type
, &did
);
55 fc_fill_fc_hdr(fp
, r_ctl
, did
, lport
->port_id
, fh_type
,
58 return fc_exch_seq_send(lport
, fp
, resp
, NULL
, arg
, timer_msec
);
60 EXPORT_SYMBOL(fc_elsct_send
);
63 * fc_elsct_init() - Initialize the ELS/CT layer
64 * @lport: The local port to initialize the ELS/CT layer for
66 int fc_elsct_init(struct fc_lport
*lport
)
68 if (!lport
->tt
.elsct_send
)
69 lport
->tt
.elsct_send
= fc_elsct_send
;
73 EXPORT_SYMBOL(fc_elsct_init
);
76 * fc_els_resp_type() - Return a string describing the ELS response
77 * @fp: The frame pointer or possible error code
79 const char *fc_els_resp_type(struct fc_frame
*fp
)
82 struct fc_frame_header
*fh
;
86 switch (-PTR_ERR(fp
)) {
88 msg
= "response no error";
91 msg
= "response timeout";
94 msg
= "response closed";
97 msg
= "response unknown error";
101 fh
= fc_frame_header_get(fp
);
102 switch (fh
->fh_type
) {
104 switch (fc_frame_payload_op(fp
)) {
112 msg
= "response unknown ELS";
117 ct
= fc_frame_payload_get(fp
, sizeof(*ct
));
119 switch (ntohs(ct
->ct_cmd
)) {
127 msg
= "response unknown CT";
131 msg
= "short CT response";
135 msg
= "response not ELS or CT";