forked from Minki/linux
3a3b42bf89
This patch makes a variety of cleanup changes to all libfc files. This patch adds kernel-doc headers to all functions lacking them and attempts to better format existing headers. It also add kernel-doc headers to structures. This patch ensures that the current naming conventions for local ports, remote ports and remote port private data is upheld in the following manner. struct instance (i.e. variable name) -------------------------------------------------- fc_lport lport fc_rport rport fc_rport_libfc_priv rpriv fc_rport_priv rdata I also renamed dns_rp and ptp_rp to dns_rdata and ptp_rdata respectively. I used emacs 'indent-region' and 'tabify' on all libfc files to correct spacing alignments. I feel sorry for anyone attempting to review this patch. Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
123 lines
3.1 KiB
C
123 lines
3.1 KiB
C
/*
|
|
* Copyright(c) 2008 Intel Corporation. All rights reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms and conditions of the GNU General Public License,
|
|
* version 2, as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along with
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
|
*
|
|
* Maintained at www.Open-FCoE.org
|
|
*/
|
|
|
|
/*
|
|
* Provide interface to send ELS/CT FC frames
|
|
*/
|
|
|
|
#include <asm/unaligned.h>
|
|
#include <scsi/fc/fc_gs.h>
|
|
#include <scsi/fc/fc_ns.h>
|
|
#include <scsi/fc/fc_els.h>
|
|
#include <scsi/libfc.h>
|
|
#include <scsi/fc_encode.h>
|
|
|
|
/**
|
|
* fc_elsct_send() - Send an ELS or CT frame
|
|
* @lport: The local port to send the frame on
|
|
* @did: The destination ID for the frame
|
|
* @fp: The frame to be sent
|
|
* @op: The operational code
|
|
* @resp: The callback routine when the response is received
|
|
* @arg: The argument to pass to the response callback routine
|
|
* @timer_msec: The timeout period for the frame (in msecs)
|
|
*/
|
|
struct fc_seq *fc_elsct_send(struct fc_lport *lport, u32 did,
|
|
struct fc_frame *fp, unsigned int op,
|
|
void (*resp)(struct fc_seq *,
|
|
struct fc_frame *,
|
|
void *),
|
|
void *arg, u32 timer_msec)
|
|
{
|
|
enum fc_rctl r_ctl;
|
|
enum fc_fh_type fh_type;
|
|
int rc;
|
|
|
|
/* ELS requests */
|
|
if ((op >= ELS_LS_RJT) && (op <= ELS_AUTH_ELS))
|
|
rc = fc_els_fill(lport, did, fp, op, &r_ctl, &fh_type);
|
|
else {
|
|
/* CT requests */
|
|
rc = fc_ct_fill(lport, did, fp, op, &r_ctl, &fh_type);
|
|
did = FC_FID_DIR_SERV;
|
|
}
|
|
|
|
if (rc) {
|
|
fc_frame_free(fp);
|
|
return NULL;
|
|
}
|
|
|
|
fc_fill_fc_hdr(fp, r_ctl, did, fc_host_port_id(lport->host), fh_type,
|
|
FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0);
|
|
|
|
return lport->tt.exch_seq_send(lport, fp, resp, NULL, arg, timer_msec);
|
|
}
|
|
EXPORT_SYMBOL(fc_elsct_send);
|
|
|
|
/**
|
|
* fc_elsct_init() - Initialize the ELS/CT layer
|
|
* @lport: The local port to initialize the ELS/CT layer for
|
|
*/
|
|
int fc_elsct_init(struct fc_lport *lport)
|
|
{
|
|
if (!lport->tt.elsct_send)
|
|
lport->tt.elsct_send = fc_elsct_send;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(fc_elsct_init);
|
|
|
|
/**
|
|
* fc_els_resp_type() - Return a string describing the ELS response
|
|
* @fp: The frame pointer or possible error code
|
|
*/
|
|
const char *fc_els_resp_type(struct fc_frame *fp)
|
|
{
|
|
const char *msg;
|
|
if (IS_ERR(fp)) {
|
|
switch (-PTR_ERR(fp)) {
|
|
case FC_NO_ERR:
|
|
msg = "response no error";
|
|
break;
|
|
case FC_EX_TIMEOUT:
|
|
msg = "response timeout";
|
|
break;
|
|
case FC_EX_CLOSED:
|
|
msg = "response closed";
|
|
break;
|
|
default:
|
|
msg = "response unknown error";
|
|
break;
|
|
}
|
|
} else {
|
|
switch (fc_frame_payload_op(fp)) {
|
|
case ELS_LS_ACC:
|
|
msg = "accept";
|
|
break;
|
|
case ELS_LS_RJT:
|
|
msg = "reject";
|
|
break;
|
|
default:
|
|
msg = "response unknown ELS";
|
|
break;
|
|
}
|
|
}
|
|
return msg;
|
|
}
|