[SCSI] libfc: Formatting cleanups across libfc

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>
This commit is contained in:
Robert Love 2009-11-03 11:47:39 -08:00 коммит произвёл James Bottomley
Родитель a51ab39606
Коммит 3a3b42bf89
9 изменённых файлов: 1633 добавлений и 1264 удалений

Просмотреть файл

@ -53,8 +53,8 @@ static int fc_disc_single(struct fc_lport *, struct fc_disc_port *);
static void fc_disc_restart(struct fc_disc *); static void fc_disc_restart(struct fc_disc *);
/** /**
* fc_disc_stop_rports() - delete all the remote ports associated with the lport * fc_disc_stop_rports() - Delete all the remote ports associated with the lport
* @disc: The discovery job to stop rports on * @disc: The discovery job to stop remote ports on
* *
* Locking Note: This function expects that the lport mutex is locked before * Locking Note: This function expects that the lport mutex is locked before
* calling it. * calling it.
@ -74,9 +74,9 @@ void fc_disc_stop_rports(struct fc_disc *disc)
/** /**
* fc_disc_recv_rscn_req() - Handle Registered State Change Notification (RSCN) * fc_disc_recv_rscn_req() - Handle Registered State Change Notification (RSCN)
* @sp: Current sequence of the RSCN exchange * @sp: The sequence of the RSCN exchange
* @fp: RSCN Frame * @fp: The RSCN frame
* @lport: Fibre Channel host port instance * @lport: The local port that the request will be sent on
* *
* Locking Note: This function expects that the disc_mutex is locked * Locking Note: This function expects that the disc_mutex is locked
* before it is called. * before it is called.
@ -185,9 +185,9 @@ reject:
/** /**
* fc_disc_recv_req() - Handle incoming requests * fc_disc_recv_req() - Handle incoming requests
* @sp: Current sequence of the request exchange * @sp: The sequence of the request exchange
* @fp: The frame * @fp: The request frame
* @lport: The FC local port * @lport: The local port receiving the request
* *
* Locking Note: This function is called from the EM and will lock * Locking Note: This function is called from the EM and will lock
* the disc_mutex before calling the handler for the * the disc_mutex before calling the handler for the
@ -215,7 +215,7 @@ static void fc_disc_recv_req(struct fc_seq *sp, struct fc_frame *fp,
/** /**
* fc_disc_restart() - Restart discovery * fc_disc_restart() - Restart discovery
* @lport: FC discovery context * @disc: The discovery object to be restarted
* *
* Locking Note: This function expects that the disc mutex * Locking Note: This function expects that the disc mutex
* is already locked. * is already locked.
@ -242,9 +242,9 @@ static void fc_disc_restart(struct fc_disc *disc)
} }
/** /**
* fc_disc_start() - Fibre Channel Target discovery * fc_disc_start() - Start discovery on a local port
* @lport: FC local port * @lport: The local port to have discovery started on
* @disc_callback: function to be called when discovery is complete * @disc_callback: Callback function to be called when discovery is complete
*/ */
static void fc_disc_start(void (*disc_callback)(struct fc_lport *, static void fc_disc_start(void (*disc_callback)(struct fc_lport *,
enum fc_disc_event), enum fc_disc_event),
@ -265,8 +265,8 @@ static void fc_disc_start(void (*disc_callback)(struct fc_lport *,
/** /**
* fc_disc_done() - Discovery has been completed * fc_disc_done() - Discovery has been completed
* @disc: FC discovery context * @disc: The discovery context
* @event: discovery completion status * @event: The discovery completion status
* *
* Locking Note: This function expects that the disc mutex is locked before * Locking Note: This function expects that the disc mutex is locked before
* it is called. The discovery callback is then made with the lock released, * it is called. The discovery callback is then made with the lock released,
@ -286,8 +286,8 @@ static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event)
} }
/* /*
* Go through all remote ports. If they were found in the latest * Go through all remote ports. If they were found in the latest
* discovery, reverify or log them in. Otherwise, log them out. * discovery, reverify or log them in. Otherwise, log them out.
* Skip ports which were never discovered. These are the dNS port * Skip ports which were never discovered. These are the dNS port
* and ports which were created by PLOGI. * and ports which were created by PLOGI.
*/ */
@ -307,8 +307,8 @@ static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event)
/** /**
* fc_disc_error() - Handle error on dNS request * fc_disc_error() - Handle error on dNS request
* @disc: FC discovery context * @disc: The discovery context
* @fp: The frame pointer * @fp: The error code encoded as a frame pointer
*/ */
static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp) static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp)
{ {
@ -344,7 +344,7 @@ static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp)
/** /**
* fc_disc_gpn_ft_req() - Send Get Port Names by FC-4 type (GPN_FT) request * fc_disc_gpn_ft_req() - Send Get Port Names by FC-4 type (GPN_FT) request
* @lport: FC discovery context * @lport: The discovery context
* *
* Locking Note: This function expects that the disc_mutex is locked * Locking Note: This function expects that the disc_mutex is locked
* before it is called. * before it is called.
@ -378,9 +378,9 @@ err:
/** /**
* fc_disc_gpn_ft_parse() - Parse the body of the dNS GPN_FT response. * fc_disc_gpn_ft_parse() - Parse the body of the dNS GPN_FT response.
* @lport: Fibre Channel host port instance * @lport: The local port the GPN_FT was received on
* @buf: GPN_FT response buffer * @buf: The GPN_FT response buffer
* @len: size of response buffer * @len: The size of response buffer
* *
* Goes through the list of IDs and names resulting from a request. * Goes through the list of IDs and names resulting from a request.
*/ */
@ -479,10 +479,8 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
} }
/** /**
* fc_disc_timeout() - Retry handler for the disc component * fc_disc_timeout() - Handler for discovery timeouts
* @work: Structure holding disc obj that needs retry discovery * @work: Structure holding discovery context that needs to retry discovery
*
* Handle retry of memory allocation for remote ports.
*/ */
static void fc_disc_timeout(struct work_struct *work) static void fc_disc_timeout(struct work_struct *work)
{ {
@ -496,9 +494,9 @@ static void fc_disc_timeout(struct work_struct *work)
/** /**
* fc_disc_gpn_ft_resp() - Handle a response frame from Get Port Names (GPN_FT) * fc_disc_gpn_ft_resp() - Handle a response frame from Get Port Names (GPN_FT)
* @sp: Current sequence of GPN_FT exchange * @sp: The sequence that the GPN_FT response was received on
* @fp: response frame * @fp: The GPN_FT response frame
* @lp_arg: Fibre Channel host port instance * @lp_arg: The discovery context
* *
* Locking Note: This function is called without disc mutex held, and * Locking Note: This function is called without disc mutex held, and
* should do all its processing with the mutex held * should do all its processing with the mutex held
@ -569,9 +567,9 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp,
/** /**
* fc_disc_gpn_id_resp() - Handle a response frame from Get Port Names (GPN_ID) * fc_disc_gpn_id_resp() - Handle a response frame from Get Port Names (GPN_ID)
* @sp: exchange sequence * @sp: The sequence the GPN_ID is on
* @fp: response frame * @fp: The response frame
* @rdata_arg: remote port private data * @rdata_arg: The remote port that sent the GPN_ID response
* *
* Locking Note: This function is called without disc mutex held. * Locking Note: This function is called without disc mutex held.
*/ */
@ -639,7 +637,7 @@ out:
/** /**
* fc_disc_gpn_id_req() - Send Get Port Names by ID (GPN_ID) request * fc_disc_gpn_id_req() - Send Get Port Names by ID (GPN_ID) request
* @lport: local port * @lport: The local port to initiate discovery on
* @rdata: remote port private data * @rdata: remote port private data
* *
* Locking Note: This function expects that the disc_mutex is locked * Locking Note: This function expects that the disc_mutex is locked
@ -656,7 +654,7 @@ static int fc_disc_gpn_id_req(struct fc_lport *lport,
if (!fp) if (!fp)
return -ENOMEM; return -ENOMEM;
if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, FC_NS_GPN_ID, if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, FC_NS_GPN_ID,
fc_disc_gpn_id_resp, rdata, lport->e_d_tov)) fc_disc_gpn_id_resp, rdata, lport->e_d_tov))
return -ENOMEM; return -ENOMEM;
kref_get(&rdata->kref); kref_get(&rdata->kref);
return 0; return 0;
@ -664,8 +662,8 @@ static int fc_disc_gpn_id_req(struct fc_lport *lport,
/** /**
* fc_disc_single() - Discover the directory information for a single target * fc_disc_single() - Discover the directory information for a single target
* @lport: local port * @lport: The local port the remote port is associated with
* @dp: The port to rediscover * @dp: The port to rediscover
* *
* Locking Note: This function expects that the disc_mutex is locked * Locking Note: This function expects that the disc_mutex is locked
* before it is called. * before it is called.
@ -683,7 +681,7 @@ static int fc_disc_single(struct fc_lport *lport, struct fc_disc_port *dp)
/** /**
* fc_disc_stop() - Stop discovery for a given lport * fc_disc_stop() - Stop discovery for a given lport
* @lport: The lport that discovery should stop for * @lport: The local port that discovery should stop on
*/ */
void fc_disc_stop(struct fc_lport *lport) void fc_disc_stop(struct fc_lport *lport)
{ {
@ -697,7 +695,7 @@ void fc_disc_stop(struct fc_lport *lport)
/** /**
* fc_disc_stop_final() - Stop discovery for a given lport * fc_disc_stop_final() - Stop discovery for a given lport
* @lport: The lport that discovery should stop for * @lport: The lport that discovery should stop on
* *
* This function will block until discovery has been * This function will block until discovery has been
* completely stopped and all rports have been deleted. * completely stopped and all rports have been deleted.
@ -709,8 +707,8 @@ void fc_disc_stop_final(struct fc_lport *lport)
} }
/** /**
* fc_disc_init() - Initialize the discovery block * fc_disc_init() - Initialize the discovery layer for a local port
* @lport: FC local port * @lport: The local port that needs the discovery layer to be initialized
*/ */
int fc_disc_init(struct fc_lport *lport) int fc_disc_init(struct fc_lport *lport)
{ {

Просмотреть файл

@ -28,17 +28,22 @@
#include <scsi/libfc.h> #include <scsi/libfc.h>
#include <scsi/fc_encode.h> #include <scsi/fc_encode.h>
/* /**
* fc_elsct_send - sends ELS/CT frame * 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, struct fc_seq *fc_elsct_send(struct fc_lport *lport, u32 did,
u32 did, struct fc_frame *fp, unsigned int op,
struct fc_frame *fp, void (*resp)(struct fc_seq *,
unsigned int op, struct fc_frame *,
void (*resp)(struct fc_seq *, void *),
struct fc_frame *fp, void *arg, u32 timer_msec)
void *arg),
void *arg, u32 timer_msec)
{ {
enum fc_rctl r_ctl; enum fc_rctl r_ctl;
enum fc_fh_type fh_type; enum fc_fh_type fh_type;
@ -65,6 +70,10 @@ struct fc_seq *fc_elsct_send(struct fc_lport *lport,
} }
EXPORT_SYMBOL(fc_elsct_send); 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) int fc_elsct_init(struct fc_lport *lport)
{ {
if (!lport->tt.elsct_send) if (!lport->tt.elsct_send)
@ -75,8 +84,8 @@ int fc_elsct_init(struct fc_lport *lport)
EXPORT_SYMBOL(fc_elsct_init); EXPORT_SYMBOL(fc_elsct_init);
/** /**
* fc_els_resp_type() - return string describing ELS response for debug. * fc_els_resp_type() - Return a string describing the ELS response
* @fp: frame pointer with possible error code. * @fp: The frame pointer or possible error code
*/ */
const char *fc_els_resp_type(struct fc_frame *fp) const char *fc_els_resp_type(struct fc_frame *fp)
{ {

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -75,7 +75,7 @@ module_exit(libfc_exit);
/** /**
* fc_copy_buffer_to_sglist() - This routine copies the data of a buffer * fc_copy_buffer_to_sglist() - This routine copies the data of a buffer
* into a scatter-gather list (SG list). * into a scatter-gather list (SG list).
* *
* @buf: pointer to the data buffer. * @buf: pointer to the data buffer.
* @len: the byte-length of the data buffer. * @len: the byte-length of the data buffer.
@ -84,7 +84,7 @@ module_exit(libfc_exit);
* @offset: pointer to the current offset in the SG list. * @offset: pointer to the current offset in the SG list.
* @km_type: dedicated page table slot type for kmap_atomic. * @km_type: dedicated page table slot type for kmap_atomic.
* @crc: pointer to the 32-bit crc value. * @crc: pointer to the 32-bit crc value.
* If crc is NULL, CRC is not calculated. * If crc is NULL, CRC is not calculated.
*/ */
u32 fc_copy_buffer_to_sglist(void *buf, size_t len, u32 fc_copy_buffer_to_sglist(void *buf, size_t len,
struct scatterlist *sg, struct scatterlist *sg,

Просмотреть файл

@ -22,22 +22,22 @@
#define FC_LIBFC_LOGGING 0x01 /* General logging, not categorized */ #define FC_LIBFC_LOGGING 0x01 /* General logging, not categorized */
#define FC_LPORT_LOGGING 0x02 /* lport layer logging */ #define FC_LPORT_LOGGING 0x02 /* lport layer logging */
#define FC_DISC_LOGGING 0x04 /* discovery layer logging */ #define FC_DISC_LOGGING 0x04 /* discovery layer logging */
#define FC_RPORT_LOGGING 0x08 /* rport layer logging */ #define FC_RPORT_LOGGING 0x08 /* rport layer logging */
#define FC_FCP_LOGGING 0x10 /* I/O path logging */ #define FC_FCP_LOGGING 0x10 /* I/O path logging */
#define FC_EM_LOGGING 0x20 /* Exchange Manager logging */ #define FC_EM_LOGGING 0x20 /* Exchange Manager logging */
#define FC_EXCH_LOGGING 0x40 /* Exchange/Sequence logging */ #define FC_EXCH_LOGGING 0x40 /* Exchange/Sequence logging */
#define FC_SCSI_LOGGING 0x80 /* SCSI logging (mostly error handling) */ #define FC_SCSI_LOGGING 0x80 /* SCSI logging (mostly error handling) */
extern unsigned int fc_debug_logging; extern unsigned int fc_debug_logging;
#define FC_CHECK_LOGGING(LEVEL, CMD) \ #define FC_CHECK_LOGGING(LEVEL, CMD) \
do { \ do { \
if (unlikely(fc_debug_logging & LEVEL)) \ if (unlikely(fc_debug_logging & LEVEL)) \
do { \ do { \
CMD; \ CMD; \
} while (0); \ } while (0); \
} while (0) } while (0)
#define FC_LIBFC_DBG(fmt, args...) \ #define FC_LIBFC_DBG(fmt, args...) \
FC_CHECK_LOGGING(FC_LIBFC_LOGGING, \ FC_CHECK_LOGGING(FC_LIBFC_LOGGING, \
@ -49,10 +49,10 @@ do { \
(lport)->host->host_no, \ (lport)->host->host_no, \
fc_host_port_id((lport)->host), ##args)) fc_host_port_id((lport)->host), ##args))
#define FC_DISC_DBG(disc, fmt, args...) \ #define FC_DISC_DBG(disc, fmt, args...) \
FC_CHECK_LOGGING(FC_DISC_LOGGING, \ FC_CHECK_LOGGING(FC_DISC_LOGGING, \
printk(KERN_INFO "host%u: disc: " fmt, \ printk(KERN_INFO "host%u: disc: " fmt, \
(disc)->lport->host->host_no, \ (disc)->lport->host->host_no, \
##args)) ##args))
#define FC_RPORT_ID_DBG(lport, port_id, fmt, args...) \ #define FC_RPORT_ID_DBG(lport, port_id, fmt, args...) \
@ -77,7 +77,7 @@ do { \
exch->xid, ##args)) exch->xid, ##args))
#define FC_SCSI_DBG(lport, fmt, args...) \ #define FC_SCSI_DBG(lport, fmt, args...) \
FC_CHECK_LOGGING(FC_SCSI_LOGGING, \ FC_CHECK_LOGGING(FC_SCSI_LOGGING, \
printk(KERN_INFO "host%u: scsi: " fmt, \ printk(KERN_INFO "host%u: scsi: " fmt, \
(lport)->host->host_no, ##args)) (lport)->host->host_no, ##args))

Просмотреть файл

@ -133,7 +133,7 @@ static const char *fc_lport_state_names[] = {
* @job: The passthrough job * @job: The passthrough job
* @lport: The local port to pass through a command * @lport: The local port to pass through a command
* @rsp_code: The expected response code * @rsp_code: The expected response code
* @sg: job->reply_payload.sg_list * @sg: job->reply_payload.sg_list
* @nents: job->reply_payload.sg_cnt * @nents: job->reply_payload.sg_cnt
* @offset: The offset into the response data * @offset: The offset into the response data
*/ */
@ -146,6 +146,11 @@ struct fc_bsg_info {
size_t offset; size_t offset;
}; };
/**
* fc_frame_drop() - Dummy frame handler
* @lport: The local port the frame was received on
* @fp: The received frame
*/
static int fc_frame_drop(struct fc_lport *lport, struct fc_frame *fp) static int fc_frame_drop(struct fc_lport *lport, struct fc_frame *fp)
{ {
fc_frame_free(fp); fc_frame_free(fp);
@ -172,7 +177,7 @@ static void fc_lport_rport_callback(struct fc_lport *lport,
switch (event) { switch (event) {
case RPORT_EV_READY: case RPORT_EV_READY:
if (lport->state == LPORT_ST_DNS) { if (lport->state == LPORT_ST_DNS) {
lport->dns_rp = rdata; lport->dns_rdata = rdata;
fc_lport_enter_ns(lport, LPORT_ST_RNN_ID); fc_lport_enter_ns(lport, LPORT_ST_RNN_ID);
} else { } else {
FC_LPORT_DBG(lport, "Received an READY event " FC_LPORT_DBG(lport, "Received an READY event "
@ -187,7 +192,7 @@ static void fc_lport_rport_callback(struct fc_lport *lport,
case RPORT_EV_LOGO: case RPORT_EV_LOGO:
case RPORT_EV_FAILED: case RPORT_EV_FAILED:
case RPORT_EV_STOP: case RPORT_EV_STOP:
lport->dns_rp = NULL; lport->dns_rdata = NULL;
break; break;
case RPORT_EV_NONE: case RPORT_EV_NONE:
break; break;
@ -211,8 +216,8 @@ static const char *fc_lport_state(struct fc_lport *lport)
/** /**
* fc_lport_ptp_setup() - Create an rport for point-to-point mode * fc_lport_ptp_setup() - Create an rport for point-to-point mode
* @lport: The lport to attach the ptp rport to * @lport: The lport to attach the ptp rport to
* @fid: The FID of the ptp rport * @remote_fid: The FID of the ptp rport
* @remote_wwpn: The WWPN of the ptp rport * @remote_wwpn: The WWPN of the ptp rport
* @remote_wwnn: The WWNN of the ptp rport * @remote_wwnn: The WWNN of the ptp rport
*/ */
@ -221,18 +226,22 @@ static void fc_lport_ptp_setup(struct fc_lport *lport,
u64 remote_wwnn) u64 remote_wwnn)
{ {
mutex_lock(&lport->disc.disc_mutex); mutex_lock(&lport->disc.disc_mutex);
if (lport->ptp_rp) if (lport->ptp_rdata)
lport->tt.rport_logoff(lport->ptp_rp); lport->tt.rport_logoff(lport->ptp_rdata);
lport->ptp_rp = lport->tt.rport_create(lport, remote_fid); lport->ptp_rdata = lport->tt.rport_create(lport, remote_fid);
lport->ptp_rp->ids.port_name = remote_wwpn; lport->ptp_rdata->ids.port_name = remote_wwpn;
lport->ptp_rp->ids.node_name = remote_wwnn; lport->ptp_rdata->ids.node_name = remote_wwnn;
mutex_unlock(&lport->disc.disc_mutex); mutex_unlock(&lport->disc.disc_mutex);
lport->tt.rport_login(lport->ptp_rp); lport->tt.rport_login(lport->ptp_rdata);
fc_lport_enter_ready(lport); fc_lport_enter_ready(lport);
} }
/**
* fc_get_host_port_type() - Return the port type of the given Scsi_Host
* @shost: The SCSI host whose port type is to be determined
*/
void fc_get_host_port_type(struct Scsi_Host *shost) void fc_get_host_port_type(struct Scsi_Host *shost)
{ {
/* TODO - currently just NPORT */ /* TODO - currently just NPORT */
@ -240,25 +249,33 @@ void fc_get_host_port_type(struct Scsi_Host *shost)
} }
EXPORT_SYMBOL(fc_get_host_port_type); EXPORT_SYMBOL(fc_get_host_port_type);
/**
* fc_get_host_port_state() - Return the port state of the given Scsi_Host
* @shost: The SCSI host whose port state is to be determined
*/
void fc_get_host_port_state(struct Scsi_Host *shost) void fc_get_host_port_state(struct Scsi_Host *shost)
{ {
struct fc_lport *lp = shost_priv(shost); struct fc_lport *lport = shost_priv(shost);
mutex_lock(&lp->lp_mutex); mutex_lock(&lport->lp_mutex);
if (!lp->link_up) if (!lport->link_up)
fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
else else
switch (lp->state) { switch (lport->state) {
case LPORT_ST_READY: case LPORT_ST_READY:
fc_host_port_state(shost) = FC_PORTSTATE_ONLINE; fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
break; break;
default: default:
fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
} }
mutex_unlock(&lp->lp_mutex); mutex_unlock(&lport->lp_mutex);
} }
EXPORT_SYMBOL(fc_get_host_port_state); EXPORT_SYMBOL(fc_get_host_port_state);
/**
* fc_get_host_speed() - Return the speed of the given Scsi_Host
* @shost: The SCSI host whose port speed is to be determined
*/
void fc_get_host_speed(struct Scsi_Host *shost) void fc_get_host_speed(struct Scsi_Host *shost)
{ {
struct fc_lport *lport = shost_priv(shost); struct fc_lport *lport = shost_priv(shost);
@ -267,24 +284,28 @@ void fc_get_host_speed(struct Scsi_Host *shost)
} }
EXPORT_SYMBOL(fc_get_host_speed); EXPORT_SYMBOL(fc_get_host_speed);
/**
* fc_get_host_stats() - Return the Scsi_Host's statistics
* @shost: The SCSI host whose statistics are to be returned
*/
struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *shost) struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *shost)
{ {
struct fc_host_statistics *fcoe_stats; struct fc_host_statistics *fcoe_stats;
struct fc_lport *lp = shost_priv(shost); struct fc_lport *lport = shost_priv(shost);
struct timespec v0, v1; struct timespec v0, v1;
unsigned int cpu; unsigned int cpu;
fcoe_stats = &lp->host_stats; fcoe_stats = &lport->host_stats;
memset(fcoe_stats, 0, sizeof(struct fc_host_statistics)); memset(fcoe_stats, 0, sizeof(struct fc_host_statistics));
jiffies_to_timespec(jiffies, &v0); jiffies_to_timespec(jiffies, &v0);
jiffies_to_timespec(lp->boot_time, &v1); jiffies_to_timespec(lport->boot_time, &v1);
fcoe_stats->seconds_since_last_reset = (v0.tv_sec - v1.tv_sec); fcoe_stats->seconds_since_last_reset = (v0.tv_sec - v1.tv_sec);
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
struct fcoe_dev_stats *stats; struct fcoe_dev_stats *stats;
stats = per_cpu_ptr(lp->dev_stats, cpu); stats = per_cpu_ptr(lport->dev_stats, cpu);
fcoe_stats->tx_frames += stats->TxFrames; fcoe_stats->tx_frames += stats->TxFrames;
fcoe_stats->tx_words += stats->TxWords; fcoe_stats->tx_words += stats->TxWords;
@ -309,12 +330,15 @@ struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *shost)
} }
EXPORT_SYMBOL(fc_get_host_stats); EXPORT_SYMBOL(fc_get_host_stats);
/* /**
* Fill in FLOGI command for request. * fc_lport_flogi_fill() - Fill in FLOGI command for request
* @lport: The local port the FLOGI is for
* @flogi: The FLOGI command
* @op: The opcode
*/ */
static void static void fc_lport_flogi_fill(struct fc_lport *lport,
fc_lport_flogi_fill(struct fc_lport *lport, struct fc_els_flogi *flogi, struct fc_els_flogi *flogi,
unsigned int op) unsigned int op)
{ {
struct fc_els_csp *sp; struct fc_els_csp *sp;
struct fc_els_cssp *cp; struct fc_els_cssp *cp;
@ -342,8 +366,10 @@ fc_lport_flogi_fill(struct fc_lport *lport, struct fc_els_flogi *flogi,
} }
} }
/* /**
* Add a supported FC-4 type. * fc_lport_add_fc4_type() - Add a supported FC-4 type to a local port
* @lport: The local port to add a new FC-4 type to
* @type: The new FC-4 type
*/ */
static void fc_lport_add_fc4_type(struct fc_lport *lport, enum fc_fh_type type) static void fc_lport_add_fc4_type(struct fc_lport *lport, enum fc_fh_type type)
{ {
@ -355,9 +381,9 @@ static void fc_lport_add_fc4_type(struct fc_lport *lport, enum fc_fh_type type)
/** /**
* fc_lport_recv_rlir_req() - Handle received Registered Link Incident Report. * fc_lport_recv_rlir_req() - Handle received Registered Link Incident Report.
* @sp: The sequence in the RLIR exchange
* @fp: The RLIR request frame
* @lport: Fibre Channel local port recieving the RLIR * @lport: Fibre Channel local port recieving the RLIR
* @sp: current sequence in the RLIR exchange
* @fp: RLIR request frame
* *
* Locking Note: The lport lock is expected to be held before calling * Locking Note: The lport lock is expected to be held before calling
* this function. * this function.
@ -374,9 +400,9 @@ static void fc_lport_recv_rlir_req(struct fc_seq *sp, struct fc_frame *fp,
/** /**
* fc_lport_recv_echo_req() - Handle received ECHO request * fc_lport_recv_echo_req() - Handle received ECHO request
* @lport: Fibre Channel local port recieving the ECHO * @sp: The sequence in the ECHO exchange
* @sp: current sequence in the ECHO exchange * @fp: ECHO request frame
* @fp: ECHO request frame * @lport: The local port recieving the ECHO
* *
* Locking Note: The lport lock is expected to be held before calling * Locking Note: The lport lock is expected to be held before calling
* this function. * this function.
@ -483,9 +509,9 @@ static void fc_lport_recv_rnid_req(struct fc_seq *sp, struct fc_frame *in_fp,
/** /**
* fc_lport_recv_logo_req() - Handle received fabric LOGO request * fc_lport_recv_logo_req() - Handle received fabric LOGO request
* @lport: Fibre Channel local port recieving the LOGO * @sp: The sequence in the LOGO exchange
* @sp: current sequence in the LOGO exchange * @fp: The LOGO request frame
* @fp: LOGO request frame * @lport: The local port recieving the LOGO
* *
* Locking Note: The lport lock is exected to be held before calling * Locking Note: The lport lock is exected to be held before calling
* this function. * this function.
@ -500,7 +526,7 @@ static void fc_lport_recv_logo_req(struct fc_seq *sp, struct fc_frame *fp,
/** /**
* fc_fabric_login() - Start the lport state machine * fc_fabric_login() - Start the lport state machine
* @lport: The lport that should log into the fabric * @lport: The local port that should log into the fabric
* *
* Locking Note: This function should not be called * Locking Note: This function should not be called
* with the lport lock held. * with the lport lock held.
@ -538,7 +564,7 @@ void __fc_linkup(struct fc_lport *lport)
/** /**
* fc_linkup() - Handler for transport linkup events * fc_linkup() - Handler for transport linkup events
* @lport: The lport whose link is up * @lport: The local port whose link is up
*/ */
void fc_linkup(struct fc_lport *lport) void fc_linkup(struct fc_lport *lport)
{ {
@ -568,7 +594,7 @@ void __fc_linkdown(struct fc_lport *lport)
/** /**
* fc_linkdown() - Handler for transport linkdown events * fc_linkdown() - Handler for transport linkdown events
* @lport: The lport whose link is down * @lport: The local port whose link is down
*/ */
void fc_linkdown(struct fc_lport *lport) void fc_linkdown(struct fc_lport *lport)
{ {
@ -583,7 +609,7 @@ EXPORT_SYMBOL(fc_linkdown);
/** /**
* fc_fabric_logoff() - Logout of the fabric * fc_fabric_logoff() - Logout of the fabric
* @lport: fc_lport pointer to logoff the fabric * @lport: The local port to logoff the fabric
* *
* Return value: * Return value:
* 0 for success, -1 for failure * 0 for success, -1 for failure
@ -592,8 +618,8 @@ int fc_fabric_logoff(struct fc_lport *lport)
{ {
lport->tt.disc_stop_final(lport); lport->tt.disc_stop_final(lport);
mutex_lock(&lport->lp_mutex); mutex_lock(&lport->lp_mutex);
if (lport->dns_rp) if (lport->dns_rdata)
lport->tt.rport_logoff(lport->dns_rp); lport->tt.rport_logoff(lport->dns_rdata);
mutex_unlock(&lport->lp_mutex); mutex_unlock(&lport->lp_mutex);
lport->tt.rport_flush_queue(); lport->tt.rport_flush_queue();
mutex_lock(&lport->lp_mutex); mutex_lock(&lport->lp_mutex);
@ -605,11 +631,9 @@ int fc_fabric_logoff(struct fc_lport *lport)
EXPORT_SYMBOL(fc_fabric_logoff); EXPORT_SYMBOL(fc_fabric_logoff);
/** /**
* fc_lport_destroy() - unregister a fc_lport * fc_lport_destroy() - Unregister a fc_lport
* @lport: fc_lport pointer to unregister * @lport: The local port to unregister
* *
* Return value:
* None
* Note: * Note:
* exit routine for fc_lport instance * exit routine for fc_lport instance
* clean-up all the allocated memory * clean-up all the allocated memory
@ -632,13 +656,9 @@ int fc_lport_destroy(struct fc_lport *lport)
EXPORT_SYMBOL(fc_lport_destroy); EXPORT_SYMBOL(fc_lport_destroy);
/** /**
* fc_set_mfs() - sets up the mfs for the corresponding fc_lport * fc_set_mfs() - Set the maximum frame size for a local port
* @lport: fc_lport pointer to unregister * @lport: The local port to set the MFS for
* @mfs: the new mfs for fc_lport * @mfs: The new MFS
*
* Set mfs for the given fc_lport to the new mfs.
*
* Return: 0 for success
*/ */
int fc_set_mfs(struct fc_lport *lport, u32 mfs) int fc_set_mfs(struct fc_lport *lport, u32 mfs)
{ {
@ -669,7 +689,7 @@ EXPORT_SYMBOL(fc_set_mfs);
/** /**
* fc_lport_disc_callback() - Callback for discovery events * fc_lport_disc_callback() - Callback for discovery events
* @lport: FC local port * @lport: The local port receiving the event
* @event: The discovery event * @event: The discovery event
*/ */
void fc_lport_disc_callback(struct fc_lport *lport, enum fc_disc_event event) void fc_lport_disc_callback(struct fc_lport *lport, enum fc_disc_event event)
@ -693,7 +713,7 @@ void fc_lport_disc_callback(struct fc_lport *lport, enum fc_disc_event event)
/** /**
* fc_rport_enter_ready() - Enter the ready state and start discovery * fc_rport_enter_ready() - Enter the ready state and start discovery
* @lport: Fibre Channel local port that is ready * @lport: The local port that is ready
* *
* Locking Note: The lport lock is expected to be held before calling * Locking Note: The lport lock is expected to be held before calling
* this routine. * this routine.
@ -708,15 +728,15 @@ static void fc_lport_enter_ready(struct fc_lport *lport)
fc_vport_set_state(lport->vport, FC_VPORT_ACTIVE); fc_vport_set_state(lport->vport, FC_VPORT_ACTIVE);
fc_vports_linkchange(lport); fc_vports_linkchange(lport);
if (!lport->ptp_rp) if (!lport->ptp_rdata)
lport->tt.disc_start(fc_lport_disc_callback, lport); lport->tt.disc_start(fc_lport_disc_callback, lport);
} }
/** /**
* fc_lport_recv_flogi_req() - Receive a FLOGI request * fc_lport_recv_flogi_req() - Receive a FLOGI request
* @sp_in: The sequence the FLOGI is on * @sp_in: The sequence the FLOGI is on
* @rx_fp: The frame the FLOGI is in * @rx_fp: The FLOGI frame
* @lport: The lport that recieved the request * @lport: The local port that recieved the request
* *
* A received FLOGI request indicates a point-to-point connection. * A received FLOGI request indicates a point-to-point connection.
* Accept it with the common service parameters indicating our N port. * Accept it with the common service parameters indicating our N port.
@ -802,9 +822,9 @@ out:
/** /**
* fc_lport_recv_req() - The generic lport request handler * fc_lport_recv_req() - The generic lport request handler
* @lport: The lport that received the request * @lport: The local port that received the request
* @sp: The sequence the request is on * @sp: The sequence the request is on
* @fp: The frame the request is in * @fp: The request frame
* *
* This function will see if the lport handles the request or * This function will see if the lport handles the request or
* if an rport should handle the request. * if an rport should handle the request.
@ -872,8 +892,8 @@ static void fc_lport_recv_req(struct fc_lport *lport, struct fc_seq *sp,
} }
/** /**
* fc_lport_reset() - Reset an lport * fc_lport_reset() - Reset a local port
* @lport: The lport which should be reset * @lport: The local port which should be reset
* *
* Locking Note: This functions should not be called with the * Locking Note: This functions should not be called with the
* lport lock held. * lport lock held.
@ -889,18 +909,18 @@ int fc_lport_reset(struct fc_lport *lport)
EXPORT_SYMBOL(fc_lport_reset); EXPORT_SYMBOL(fc_lport_reset);
/** /**
* fc_lport_reset_locked() - Reset the local port * fc_lport_reset_locked() - Reset the local port w/ the lport lock held
* @lport: Fibre Channel local port to be reset * @lport: The local port to be reset
* *
* Locking Note: The lport lock is expected to be held before calling * Locking Note: The lport lock is expected to be held before calling
* this routine. * this routine.
*/ */
static void fc_lport_reset_locked(struct fc_lport *lport) static void fc_lport_reset_locked(struct fc_lport *lport)
{ {
if (lport->dns_rp) if (lport->dns_rdata)
lport->tt.rport_logoff(lport->dns_rp); lport->tt.rport_logoff(lport->dns_rdata);
lport->ptp_rp = NULL; lport->ptp_rdata = NULL;
lport->tt.disc_stop(lport); lport->tt.disc_stop(lport);
@ -911,7 +931,7 @@ static void fc_lport_reset_locked(struct fc_lport *lport)
/** /**
* fc_lport_enter_reset() - Reset the local port * fc_lport_enter_reset() - Reset the local port
* @lport: Fibre Channel local port to be reset * @lport: The local port to be reset
* *
* Locking Note: The lport lock is expected to be held before calling * Locking Note: The lport lock is expected to be held before calling
* this routine. * this routine.
@ -935,8 +955,8 @@ static void fc_lport_enter_reset(struct fc_lport *lport)
} }
/** /**
* fc_lport_enter_disabled() - disable the local port * fc_lport_enter_disabled() - Disable the local port
* @lport: Fibre Channel local port to be reset * @lport: The local port to be reset
* *
* Locking Note: The lport lock is expected to be held before calling * Locking Note: The lport lock is expected to be held before calling
* this routine. * this routine.
@ -953,8 +973,8 @@ static void fc_lport_enter_disabled(struct fc_lport *lport)
/** /**
* fc_lport_error() - Handler for any errors * fc_lport_error() - Handler for any errors
* @lport: The fc_lport object * @lport: The local port that the error was on
* @fp: The frame pointer * @fp: The error code encoded in a frame pointer
* *
* If the error was caused by a resource allocation failure * If the error was caused by a resource allocation failure
* then wait for half a second and retry, otherwise retry * then wait for half a second and retry, otherwise retry
@ -1002,13 +1022,13 @@ static void fc_lport_error(struct fc_lport *lport, struct fc_frame *fp)
/** /**
* fc_lport_ns_resp() - Handle response to a name server * fc_lport_ns_resp() - Handle response to a name server
* registration exchange * registration exchange
* @sp: current sequence in exchange * @sp: current sequence in exchange
* @fp: response frame * @fp: response frame
* @lp_arg: Fibre Channel host port instance * @lp_arg: Fibre Channel host port instance
* *
* Locking Note: This function will be called without the lport lock * Locking Note: This function will be called without the lport lock
* held, but it will lock, call an _enter_* function or fc_lport_error * held, but it will lock, call an _enter_* function or fc_lport_error()
* and then unlock the lport. * and then unlock the lport.
*/ */
static void fc_lport_ns_resp(struct fc_seq *sp, struct fc_frame *fp, static void fc_lport_ns_resp(struct fc_seq *sp, struct fc_frame *fp,
@ -1027,7 +1047,7 @@ static void fc_lport_ns_resp(struct fc_seq *sp, struct fc_frame *fp,
if (lport->state < LPORT_ST_RNN_ID || lport->state > LPORT_ST_RFT_ID) { if (lport->state < LPORT_ST_RNN_ID || lport->state > LPORT_ST_RFT_ID) {
FC_LPORT_DBG(lport, "Received a name server response, " FC_LPORT_DBG(lport, "Received a name server response, "
"but in state %s\n", fc_lport_state(lport)); "but in state %s\n", fc_lport_state(lport));
if (IS_ERR(fp)) if (IS_ERR(fp))
goto err; goto err;
goto out; goto out;
@ -1072,8 +1092,8 @@ err:
/** /**
* fc_lport_scr_resp() - Handle response to State Change Register (SCR) request * fc_lport_scr_resp() - Handle response to State Change Register (SCR) request
* @sp: current sequence in SCR exchange * @sp: current sequence in SCR exchange
* @fp: response frame * @fp: response frame
* @lp_arg: Fibre Channel lport port instance that sent the registration request * @lp_arg: Fibre Channel lport port instance that sent the registration request
* *
* Locking Note: This function will be called without the lport lock * Locking Note: This function will be called without the lport lock
@ -1119,8 +1139,8 @@ err:
} }
/** /**
* fc_lport_enter_scr() - Send a State Change Register (SCR) request * fc_lport_enter_scr() - Send a SCR (State Change Register) request
* @lport: Fibre Channel local port to register for state changes * @lport: The local port to register for state changes
* *
* Locking Note: The lport lock is expected to be held before calling * Locking Note: The lport lock is expected to be held before calling
* this routine. * this routine.
@ -1212,8 +1232,8 @@ static struct fc_rport_operations fc_lport_rport_ops = {
}; };
/** /**
* fc_rport_enter_dns() - Create a rport to the name server * fc_rport_enter_dns() - Create a fc_rport for the name server
* @lport: Fibre Channel local port requesting a rport for the name server * @lport: The local port requesting a remote port for the name server
* *
* Locking Note: The lport lock is expected to be held before calling * Locking Note: The lport lock is expected to be held before calling
* this routine. * this routine.
@ -1242,8 +1262,8 @@ err:
} }
/** /**
* fc_lport_timeout() - Handler for the retry_work timer. * fc_lport_timeout() - Handler for the retry_work timer
* @work: The work struct of the fc_lport * @work: The work struct of the local port
*/ */
static void fc_lport_timeout(struct work_struct *work) static void fc_lport_timeout(struct work_struct *work)
{ {
@ -1287,16 +1307,16 @@ static void fc_lport_timeout(struct work_struct *work)
/** /**
* fc_lport_logo_resp() - Handle response to LOGO request * fc_lport_logo_resp() - Handle response to LOGO request
* @sp: current sequence in LOGO exchange * @sp: The sequence that the LOGO was on
* @fp: response frame * @fp: The LOGO frame
* @lp_arg: Fibre Channel lport port instance that sent the LOGO request * @lp_arg: The lport port that received the LOGO request
* *
* Locking Note: This function will be called without the lport lock * Locking Note: This function will be called without the lport lock
* held, but it will lock, call an _enter_* function or fc_lport_error * held, but it will lock, call an _enter_* function or fc_lport_error()
* and then unlock the lport. * and then unlock the lport.
*/ */
void fc_lport_logo_resp(struct fc_seq *sp, struct fc_frame *fp, void fc_lport_logo_resp(struct fc_seq *sp, struct fc_frame *fp,
void *lp_arg) void *lp_arg)
{ {
struct fc_lport *lport = lp_arg; struct fc_lport *lport = lp_arg;
u8 op; u8 op;
@ -1336,7 +1356,7 @@ EXPORT_SYMBOL(fc_lport_logo_resp);
/** /**
* fc_rport_enter_logo() - Logout of the fabric * fc_rport_enter_logo() - Logout of the fabric
* @lport: Fibre Channel local port to be logged out * @lport: The local port to be logged out
* *
* Locking Note: The lport lock is expected to be held before calling * Locking Note: The lport lock is expected to be held before calling
* this routine. * this routine.
@ -1365,16 +1385,16 @@ static void fc_lport_enter_logo(struct fc_lport *lport)
/** /**
* fc_lport_flogi_resp() - Handle response to FLOGI request * fc_lport_flogi_resp() - Handle response to FLOGI request
* @sp: current sequence in FLOGI exchange * @sp: The sequence that the FLOGI was on
* @fp: response frame * @fp: The FLOGI response frame
* @lp_arg: Fibre Channel lport port instance that sent the FLOGI request * @lp_arg: The lport port that received the FLOGI response
* *
* Locking Note: This function will be called without the lport lock * Locking Note: This function will be called without the lport lock
* held, but it will lock, call an _enter_* function or fc_lport_error * held, but it will lock, call an _enter_* function or fc_lport_error()
* and then unlock the lport. * and then unlock the lport.
*/ */
void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp,
void *lp_arg) void *lp_arg)
{ {
struct fc_lport *lport = lp_arg; struct fc_lport *lport = lp_arg;
struct fc_frame_header *fh; struct fc_frame_header *fh;
@ -1484,7 +1504,10 @@ void fc_lport_enter_flogi(struct fc_lport *lport)
fc_lport_error(lport, NULL); fc_lport_error(lport, NULL);
} }
/* Configure a fc_lport */ /**
* fc_lport_config() - Configure a fc_lport
* @lport: The local port to be configured
*/
int fc_lport_config(struct fc_lport *lport) int fc_lport_config(struct fc_lport *lport)
{ {
INIT_DELAYED_WORK(&lport->retry_work, fc_lport_timeout); INIT_DELAYED_WORK(&lport->retry_work, fc_lport_timeout);
@ -1499,6 +1522,10 @@ int fc_lport_config(struct fc_lport *lport)
} }
EXPORT_SYMBOL(fc_lport_config); EXPORT_SYMBOL(fc_lport_config);
/**
* fc_lport_init() - Initialize the lport layer for a local port
* @lport: The local port to initialize the exchange layer for
*/
int fc_lport_init(struct fc_lport *lport) int fc_lport_init(struct fc_lport *lport)
{ {
if (!lport->tt.lport_recv) if (!lport->tt.lport_recv)
@ -1533,10 +1560,10 @@ int fc_lport_init(struct fc_lport *lport)
EXPORT_SYMBOL(fc_lport_init); EXPORT_SYMBOL(fc_lport_init);
/** /**
* fc_lport_bsg_resp() - The common response handler for fc pass-thru requests * fc_lport_bsg_resp() - The common response handler for FC Passthrough requests
* @sp: current sequence in the fc pass-thru request exchange * @sp: The sequence for the FC Passthrough response
* @fp: received response frame * @fp: The response frame
* @info_arg: pointer to struct fc_bsg_info * @info_arg: The BSG info that the response is for
*/ */
static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp, static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp,
void *info_arg) void *info_arg)
@ -1596,10 +1623,10 @@ static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp,
} }
/** /**
* fc_lport_els_request() - Send ELS pass-thru request * fc_lport_els_request() - Send ELS passthrough request
* @job: The bsg fc pass-thru job structure * @job: The BSG Passthrough job
* @lport: The local port sending the request * @lport: The local port sending the request
* @did: The destination port id. * @did: The destination port id
* *
* Locking Note: The lport lock is expected to be held before calling * Locking Note: The lport lock is expected to be held before calling
* this routine. * this routine.
@ -1656,11 +1683,11 @@ static int fc_lport_els_request(struct fc_bsg_job *job,
} }
/** /**
* fc_lport_ct_request() - Send CT pass-thru request * fc_lport_ct_request() - Send CT Passthrough request
* @job: The bsg fc pass-thru job structure * @job: The BSG Passthrough job
* @lport: The local port sending the request * @lport: The local port sending the request
* @did: The destination FC-ID * @did: The destination FC-ID
* @tov: The time to wait for a response * @tov: The timeout period to wait for the response
* *
* Locking Note: The lport lock is expected to be held before calling * Locking Note: The lport lock is expected to be held before calling
* this routine. * this routine.
@ -1717,8 +1744,8 @@ static int fc_lport_ct_request(struct fc_bsg_job *job,
/** /**
* fc_lport_bsg_request() - The common entry point for sending * fc_lport_bsg_request() - The common entry point for sending
* fc pass-thru requests * FC Passthrough requests
* @job: The fc pass-thru job structure * @job: The BSG passthrough job
*/ */
int fc_lport_bsg_request(struct fc_bsg_job *job) int fc_lport_bsg_request(struct fc_bsg_job *job)
{ {
@ -1759,7 +1786,7 @@ int fc_lport_bsg_request(struct fc_bsg_job *job)
case FC_BSG_HST_CT: case FC_BSG_HST_CT:
did = ntoh24(job->request->rqst_data.h_ct.port_id); did = ntoh24(job->request->rqst_data.h_ct.port_id);
if (did == FC_FID_DIR_SERV) if (did == FC_FID_DIR_SERV)
rdata = lport->dns_rp; rdata = lport->dns_rdata;
else else
rdata = lport->tt.rport_lookup(lport, did); rdata = lport->tt.rport_lookup(lport, did);

Просмотреть файл

@ -92,9 +92,9 @@ static const char *fc_rport_state_names[] = {
}; };
/** /**
* fc_rport_lookup() - lookup a remote port by port_id * fc_rport_lookup() - Lookup a remote port by port_id
* @lport: Fibre Channel host port instance * @lport: The local port to lookup the remote port on
* @port_id: remote port port_id to match * @port_id: The remote port ID to look up
*/ */
static struct fc_rport_priv *fc_rport_lookup(const struct fc_lport *lport, static struct fc_rport_priv *fc_rport_lookup(const struct fc_lport *lport,
u32 port_id) u32 port_id)
@ -109,8 +109,10 @@ static struct fc_rport_priv *fc_rport_lookup(const struct fc_lport *lport,
/** /**
* fc_rport_create() - Create a new remote port * fc_rport_create() - Create a new remote port
* @lport: The local port that the new remote port is for * @lport: The local port this remote port will be associated with
* @port_id: The port ID for the new remote port * @ids: The identifiers for the new remote port
*
* The remote port will start in the INIT state.
* *
* Locking note: must be called with the disc_mutex held. * Locking note: must be called with the disc_mutex held.
*/ */
@ -149,8 +151,8 @@ static struct fc_rport_priv *fc_rport_create(struct fc_lport *lport,
} }
/** /**
* fc_rport_destroy() - free a remote port after last reference is released. * fc_rport_destroy() - Free a remote port after last reference is released
* @kref: pointer to kref inside struct fc_rport_priv * @kref: The remote port's kref
*/ */
static void fc_rport_destroy(struct kref *kref) static void fc_rport_destroy(struct kref *kref)
{ {
@ -161,8 +163,8 @@ static void fc_rport_destroy(struct kref *kref)
} }
/** /**
* fc_rport_state() - return a string for the state the rport is in * fc_rport_state() - Return a string identifying the remote port's state
* @rdata: remote port private data * @rdata: The remote port
*/ */
static const char *fc_rport_state(struct fc_rport_priv *rdata) static const char *fc_rport_state(struct fc_rport_priv *rdata)
{ {
@ -175,9 +177,9 @@ static const char *fc_rport_state(struct fc_rport_priv *rdata)
} }
/** /**
* fc_set_rport_loss_tmo() - Set the remote port loss timeout in seconds. * fc_set_rport_loss_tmo() - Set the remote port loss timeout
* @rport: Pointer to Fibre Channel remote port structure * @rport: The remote port that gets a new timeout value
* @timeout: timeout in seconds * @timeout: The new timeout value (in seconds)
*/ */
void fc_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout) void fc_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout)
{ {
@ -189,9 +191,11 @@ void fc_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout)
EXPORT_SYMBOL(fc_set_rport_loss_tmo); EXPORT_SYMBOL(fc_set_rport_loss_tmo);
/** /**
* fc_plogi_get_maxframe() - Get max payload from the common service parameters * fc_plogi_get_maxframe() - Get the maximum payload from the common service
* @flp: FLOGI payload structure * parameters in a FLOGI frame
* @maxval: upper limit, may be less than what is in the service parameters * @flp: The FLOGI payload
* @maxval: The maximum frame size upper limit; this may be less than what
* is in the service parameters
*/ */
static unsigned int fc_plogi_get_maxframe(struct fc_els_flogi *flp, static unsigned int fc_plogi_get_maxframe(struct fc_els_flogi *flp,
unsigned int maxval) unsigned int maxval)
@ -212,9 +216,9 @@ static unsigned int fc_plogi_get_maxframe(struct fc_els_flogi *flp,
} }
/** /**
* fc_rport_state_enter() - Change the rport's state * fc_rport_state_enter() - Change the state of a remote port
* @rdata: The rport whose state should change * @rdata: The remote port whose state should change
* @new: The new state of the rport * @new: The new state
* *
* Locking Note: Called with the rport lock held * Locking Note: Called with the rport lock held
*/ */
@ -226,12 +230,16 @@ static void fc_rport_state_enter(struct fc_rport_priv *rdata,
rdata->rp_state = new; rdata->rp_state = new;
} }
/**
* fc_rport_work() - Handler for remote port events in the rport_event_queue
* @work: Handle to the remote port being dequeued
*/
static void fc_rport_work(struct work_struct *work) static void fc_rport_work(struct work_struct *work)
{ {
u32 port_id; u32 port_id;
struct fc_rport_priv *rdata = struct fc_rport_priv *rdata =
container_of(work, struct fc_rport_priv, event_work); container_of(work, struct fc_rport_priv, event_work);
struct fc_rport_libfc_priv *rp; struct fc_rport_libfc_priv *rpriv;
enum fc_rport_event event; enum fc_rport_event event;
struct fc_lport *lport = rdata->local_port; struct fc_lport *lport = rdata->local_port;
struct fc_rport_operations *rport_ops; struct fc_rport_operations *rport_ops;
@ -268,12 +276,12 @@ static void fc_rport_work(struct work_struct *work)
rport->maxframe_size = rdata->maxframe_size; rport->maxframe_size = rdata->maxframe_size;
rport->supported_classes = rdata->supported_classes; rport->supported_classes = rdata->supported_classes;
rp = rport->dd_data; rpriv = rport->dd_data;
rp->local_port = lport; rpriv->local_port = lport;
rp->rp_state = rdata->rp_state; rpriv->rp_state = rdata->rp_state;
rp->flags = rdata->flags; rpriv->flags = rdata->flags;
rp->e_d_tov = rdata->e_d_tov; rpriv->e_d_tov = rdata->e_d_tov;
rp->r_a_tov = rdata->r_a_tov; rpriv->r_a_tov = rdata->r_a_tov;
mutex_unlock(&rdata->rp_mutex); mutex_unlock(&rdata->rp_mutex);
if (rport_ops && rport_ops->event_callback) { if (rport_ops && rport_ops->event_callback) {
@ -319,8 +327,8 @@ static void fc_rport_work(struct work_struct *work)
lport->tt.exch_mgr_reset(lport, port_id, 0); lport->tt.exch_mgr_reset(lport, port_id, 0);
if (rport) { if (rport) {
rp = rport->dd_data; rpriv = rport->dd_data;
rp->rp_state = RPORT_ST_DELETE; rpriv->rp_state = RPORT_ST_DELETE;
mutex_lock(&rdata->rp_mutex); mutex_lock(&rdata->rp_mutex);
rdata->rport = NULL; rdata->rport = NULL;
mutex_unlock(&rdata->rp_mutex); mutex_unlock(&rdata->rp_mutex);
@ -343,7 +351,7 @@ static void fc_rport_work(struct work_struct *work)
/** /**
* fc_rport_login() - Start the remote port login state machine * fc_rport_login() - Start the remote port login state machine
* @rdata: private remote port * @rdata: The remote port to be logged in to
* *
* Locking Note: Called without the rport lock held. This * Locking Note: Called without the rport lock held. This
* function will hold the rport lock, call an _enter_* * function will hold the rport lock, call an _enter_*
@ -379,9 +387,9 @@ int fc_rport_login(struct fc_rport_priv *rdata)
} }
/** /**
* fc_rport_enter_delete() - schedule a remote port to be deleted. * fc_rport_enter_delete() - Schedule a remote port to be deleted
* @rdata: private remote port * @rdata: The remote port to be deleted
* @event: event to report as the reason for deletion * @event: The event to report as the reason for deletion
* *
* Locking Note: Called with the rport lock held. * Locking Note: Called with the rport lock held.
* *
@ -408,8 +416,8 @@ static void fc_rport_enter_delete(struct fc_rport_priv *rdata,
} }
/** /**
* fc_rport_logoff() - Logoff and remove an rport * fc_rport_logoff() - Logoff and remove a remote port
* @rdata: private remote port * @rdata: The remote port to be logged off of
* *
* Locking Note: Called without the rport lock held. This * Locking Note: Called without the rport lock held. This
* function will hold the rport lock, call an _enter_* * function will hold the rport lock, call an _enter_*
@ -442,8 +450,8 @@ out:
} }
/** /**
* fc_rport_enter_ready() - The rport is ready * fc_rport_enter_ready() - Transition to the RPORT_ST_READY state
* @rdata: private remote port * @rdata: The remote port that is ready
* *
* Locking Note: The rport lock is expected to be held before calling * Locking Note: The rport lock is expected to be held before calling
* this routine. * this routine.
@ -460,8 +468,8 @@ static void fc_rport_enter_ready(struct fc_rport_priv *rdata)
} }
/** /**
* fc_rport_timeout() - Handler for the retry_work timer. * fc_rport_timeout() - Handler for the retry_work timer
* @work: The work struct of the fc_rport_priv * @work: Handle to the remote port that has timed out
* *
* Locking Note: Called without the rport lock held. This * Locking Note: Called without the rport lock held. This
* function will hold the rport lock, call an _enter_* * function will hold the rport lock, call an _enter_*
@ -502,8 +510,8 @@ static void fc_rport_timeout(struct work_struct *work)
/** /**
* fc_rport_error() - Error handler, called once retries have been exhausted * fc_rport_error() - Error handler, called once retries have been exhausted
* @rdata: private remote port * @rdata: The remote port the error is happened on
* @fp: The frame pointer * @fp: The error code encapsulated in a frame pointer
* *
* Locking Note: The rport lock is expected to be held before * Locking Note: The rport lock is expected to be held before
* calling this routine * calling this routine
@ -535,9 +543,9 @@ static void fc_rport_error(struct fc_rport_priv *rdata, struct fc_frame *fp)
} }
/** /**
* fc_rport_error_retry() - Error handler when retries are desired * fc_rport_error_retry() - Handler for remote port state retries
* @rdata: private remote port data * @rdata: The remote port whose state is to be retried
* @fp: The frame pointer * @fp: The error code encapsulated in a frame pointer
* *
* If the error was an exchange timeout retry immediately, * If the error was an exchange timeout retry immediately,
* otherwise wait for E_D_TOV. * otherwise wait for E_D_TOV.
@ -569,10 +577,10 @@ static void fc_rport_error_retry(struct fc_rport_priv *rdata,
} }
/** /**
* fc_rport_plogi_recv_resp() - Handle incoming ELS PLOGI response * fc_rport_plogi_recv_resp() - Handler for ELS PLOGI responses
* @sp: current sequence in the PLOGI exchange * @sp: The sequence the PLOGI is on
* @fp: response frame * @fp: The PLOGI response frame
* @rdata_arg: private remote port data * @rdata_arg: The remote port that sent the PLOGI response
* *
* Locking Note: This function will be called without the rport lock * Locking Note: This function will be called without the rport lock
* held, but it will lock, call an _enter_* function or fc_rport_error * held, but it will lock, call an _enter_* function or fc_rport_error
@ -635,8 +643,8 @@ err:
} }
/** /**
* fc_rport_enter_plogi() - Send Port Login (PLOGI) request to peer * fc_rport_enter_plogi() - Send Port Login (PLOGI) request
* @rdata: private remote port data * @rdata: The remote port to send a PLOGI to
* *
* Locking Note: The rport lock is expected to be held before calling * Locking Note: The rport lock is expected to be held before calling
* this routine. * this routine.
@ -668,9 +676,9 @@ static void fc_rport_enter_plogi(struct fc_rport_priv *rdata)
/** /**
* fc_rport_prli_resp() - Process Login (PRLI) response handler * fc_rport_prli_resp() - Process Login (PRLI) response handler
* @sp: current sequence in the PRLI exchange * @sp: The sequence the PRLI response was on
* @fp: response frame * @fp: The PRLI response frame
* @rdata_arg: private remote port data * @rdata_arg: The remote port that sent the PRLI response
* *
* Locking Note: This function will be called without the rport lock * Locking Note: This function will be called without the rport lock
* held, but it will lock, call an _enter_* function or fc_rport_error * held, but it will lock, call an _enter_* function or fc_rport_error
@ -739,10 +747,10 @@ err:
} }
/** /**
* fc_rport_logo_resp() - Logout (LOGO) response handler * fc_rport_logo_resp() - Handler for logout (LOGO) responses
* @sp: current sequence in the LOGO exchange * @sp: The sequence the LOGO was on
* @fp: response frame * @fp: The LOGO response frame
* @rdata_arg: private remote port data * @rdata_arg: The remote port that sent the LOGO response
* *
* Locking Note: This function will be called without the rport lock * Locking Note: This function will be called without the rport lock
* held, but it will lock, call an _enter_* function or fc_rport_error * held, but it will lock, call an _enter_* function or fc_rport_error
@ -785,8 +793,8 @@ err:
} }
/** /**
* fc_rport_enter_prli() - Send Process Login (PRLI) request to peer * fc_rport_enter_prli() - Send Process Login (PRLI) request
* @rdata: private remote port data * @rdata: The remote port to send the PRLI request to
* *
* Locking Note: The rport lock is expected to be held before calling * Locking Note: The rport lock is expected to be held before calling
* this routine. * this routine.
@ -828,10 +836,10 @@ static void fc_rport_enter_prli(struct fc_rport_priv *rdata)
} }
/** /**
* fc_rport_els_rtv_resp() - Request Timeout Value response handler * fc_rport_els_rtv_resp() - Handler for Request Timeout Value (RTV) responses
* @sp: current sequence in the RTV exchange * @sp: The sequence the RTV was on
* @fp: response frame * @fp: The RTV response frame
* @rdata_arg: private remote port data * @rdata_arg: The remote port that sent the RTV response
* *
* Many targets don't seem to support this. * Many targets don't seem to support this.
* *
@ -894,8 +902,8 @@ err:
} }
/** /**
* fc_rport_enter_rtv() - Send Request Timeout Value (RTV) request to peer * fc_rport_enter_rtv() - Send Request Timeout Value (RTV) request
* @rdata: private remote port data * @rdata: The remote port to send the RTV request to
* *
* Locking Note: The rport lock is expected to be held before calling * Locking Note: The rport lock is expected to be held before calling
* this routine. * this routine.
@ -917,15 +925,15 @@ static void fc_rport_enter_rtv(struct fc_rport_priv *rdata)
} }
if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_RTV, if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_RTV,
fc_rport_rtv_resp, rdata, lport->e_d_tov)) fc_rport_rtv_resp, rdata, lport->e_d_tov))
fc_rport_error_retry(rdata, NULL); fc_rport_error_retry(rdata, NULL);
else else
kref_get(&rdata->kref); kref_get(&rdata->kref);
} }
/** /**
* fc_rport_enter_logo() - Send Logout (LOGO) request to peer * fc_rport_enter_logo() - Send a logout (LOGO) request
* @rdata: private remote port data * @rdata: The remote port to send the LOGO request to
* *
* Locking Note: The rport lock is expected to be held before calling * Locking Note: The rport lock is expected to be held before calling
* this routine. * this routine.
@ -954,17 +962,17 @@ static void fc_rport_enter_logo(struct fc_rport_priv *rdata)
} }
/** /**
* fc_rport_els_adisc_resp() - Address Discovery response handler * fc_rport_els_adisc_resp() - Handler for Address Discovery (ADISC) responses
* @sp: current sequence in the ADISC exchange * @sp: The sequence the ADISC response was on
* @fp: response frame * @fp: The ADISC response frame
* @rdata_arg: remote port private. * @rdata_arg: The remote port that sent the ADISC response
* *
* Locking Note: This function will be called without the rport lock * Locking Note: This function will be called without the rport lock
* held, but it will lock, call an _enter_* function or fc_rport_error * held, but it will lock, call an _enter_* function or fc_rport_error
* and then unlock the rport. * and then unlock the rport.
*/ */
static void fc_rport_adisc_resp(struct fc_seq *sp, struct fc_frame *fp, static void fc_rport_adisc_resp(struct fc_seq *sp, struct fc_frame *fp,
void *rdata_arg) void *rdata_arg)
{ {
struct fc_rport_priv *rdata = rdata_arg; struct fc_rport_priv *rdata = rdata_arg;
struct fc_els_adisc *adisc; struct fc_els_adisc *adisc;
@ -1012,8 +1020,8 @@ err:
} }
/** /**
* fc_rport_enter_adisc() - Send Address Discover (ADISC) request to peer * fc_rport_enter_adisc() - Send Address Discover (ADISC) request
* @rdata: remote port private data * @rdata: The remote port to send the ADISC request to
* *
* Locking Note: The rport lock is expected to be held before calling * Locking Note: The rport lock is expected to be held before calling
* this routine. * this routine.
@ -1041,10 +1049,10 @@ static void fc_rport_enter_adisc(struct fc_rport_priv *rdata)
} }
/** /**
* fc_rport_recv_adisc_req() - Handle incoming Address Discovery (ADISC) Request * fc_rport_recv_adisc_req() - Handler for Address Discovery (ADISC) requests
* @rdata: remote port private * @rdata: The remote port that sent the ADISC request
* @sp: current sequence in the ADISC exchange * @sp: The sequence the ADISC request was on
* @in_fp: ADISC request frame * @in_fp: The ADISC request frame
* *
* Locking Note: Called with the lport and rport locks held. * Locking Note: Called with the lport and rport locks held.
*/ */
@ -1085,10 +1093,10 @@ drop:
} }
/** /**
* fc_rport_recv_els_req() - handle a validated ELS request. * fc_rport_recv_els_req() - Handler for validated ELS requests
* @lport: Fibre Channel local port * @lport: The local port that received the ELS request
* @sp: current sequence in the PLOGI exchange * @sp: The sequence that the ELS request was on
* @fp: response frame * @fp: The ELS request frame
* *
* Handle incoming ELS requests that require port login. * Handle incoming ELS requests that require port login.
* The ELS opcode has already been validated by the caller. * The ELS opcode has already been validated by the caller.
@ -1160,10 +1168,10 @@ reject:
} }
/** /**
* fc_rport_recv_req() - Handle a received ELS request from a rport * fc_rport_recv_req() - Handler for requests
* @sp: current sequence in the PLOGI exchange * @sp: The sequence the request was on
* @fp: response frame * @fp: The request frame
* @lport: Fibre Channel local port * @lport: The local port that received the request
* *
* Locking Note: Called with the lport lock held. * Locking Note: Called with the lport lock held.
*/ */
@ -1203,10 +1211,10 @@ void fc_rport_recv_req(struct fc_seq *sp, struct fc_frame *fp,
} }
/** /**
* fc_rport_recv_plogi_req() - Handle incoming Port Login (PLOGI) request * fc_rport_recv_plogi_req() - Handler for Port Login (PLOGI) requests
* @lport: local port * @lport: The local port that received the PLOGI request
* @sp: current sequence in the PLOGI exchange * @sp: The sequence that the PLOGI request was on
* @fp: PLOGI request frame * @rx_fp: The PLOGI request frame
* *
* Locking Note: The rport lock is held before calling this function. * Locking Note: The rport lock is held before calling this function.
*/ */
@ -1328,10 +1336,10 @@ reject:
} }
/** /**
* fc_rport_recv_prli_req() - Handle incoming Process Login (PRLI) request * fc_rport_recv_prli_req() - Handler for process login (PRLI) requests
* @rdata: private remote port data * @rdata: The remote port that sent the PRLI request
* @sp: current sequence in the PRLI exchange * @sp: The sequence that the PRLI was on
* @fp: PRLI request frame * @rx_fp: The PRLI request frame
* *
* Locking Note: The rport lock is exected to be held before calling * Locking Note: The rport lock is exected to be held before calling
* this function. * this function.
@ -1485,10 +1493,10 @@ static void fc_rport_recv_prli_req(struct fc_rport_priv *rdata,
} }
/** /**
* fc_rport_recv_prlo_req() - Handle incoming Process Logout (PRLO) request * fc_rport_recv_prlo_req() - Handler for process logout (PRLO) requests
* @rdata: private remote port data * @rdata: The remote port that sent the PRLO request
* @sp: current sequence in the PRLO exchange * @sp: The sequence that the PRLO was on
* @fp: PRLO request frame * @fp: The PRLO request frame
* *
* Locking Note: The rport lock is exected to be held before calling * Locking Note: The rport lock is exected to be held before calling
* this function. * this function.
@ -1515,10 +1523,10 @@ static void fc_rport_recv_prlo_req(struct fc_rport_priv *rdata,
} }
/** /**
* fc_rport_recv_logo_req() - Handle incoming Logout (LOGO) request * fc_rport_recv_logo_req() - Handler for logout (LOGO) requests
* @lport: local port. * @lport: The local port that received the LOGO request
* @sp: current sequence in the LOGO exchange * @sp: The sequence that the LOGO request was on
* @fp: LOGO request frame * @fp: The LOGO request frame
* *
* Locking Note: The rport lock is exected to be held before calling * Locking Note: The rport lock is exected to be held before calling
* this function. * this function.
@ -1559,11 +1567,18 @@ static void fc_rport_recv_logo_req(struct fc_lport *lport,
fc_frame_free(fp); fc_frame_free(fp);
} }
/**
* fc_rport_flush_queue() - Flush the rport_event_queue
*/
static void fc_rport_flush_queue(void) static void fc_rport_flush_queue(void)
{ {
flush_workqueue(rport_event_queue); flush_workqueue(rport_event_queue);
} }
/**
* fc_rport_init() - Initialize the remote port layer for a local port
* @lport: The local port to initialize the remote port layer for
*/
int fc_rport_init(struct fc_lport *lport) int fc_rport_init(struct fc_lport *lport)
{ {
if (!lport->tt.rport_lookup) if (!lport->tt.rport_lookup)
@ -1591,7 +1606,10 @@ int fc_rport_init(struct fc_lport *lport)
} }
EXPORT_SYMBOL(fc_rport_init); EXPORT_SYMBOL(fc_rport_init);
int fc_setup_rport(void) /**
* fc_setup_rport() - Initialize the rport_event_queue
*/
int fc_setup_rport()
{ {
rport_event_queue = create_singlethread_workqueue("fc_rport_eq"); rport_event_queue = create_singlethread_workqueue("fc_rport_eq");
if (!rport_event_queue) if (!rport_event_queue)
@ -1599,15 +1617,22 @@ int fc_setup_rport(void)
return 0; return 0;
} }
void fc_destroy_rport(void) /**
* fc_destroy_rport() - Destroy the rport_event_queue
*/
void fc_destroy_rport()
{ {
destroy_workqueue(rport_event_queue); destroy_workqueue(rport_event_queue);
} }
/**
* fc_rport_terminate_io() - Stop all outstanding I/O on a remote port
* @rport: The remote port whose I/O should be terminated
*/
void fc_rport_terminate_io(struct fc_rport *rport) void fc_rport_terminate_io(struct fc_rport *rport)
{ {
struct fc_rport_libfc_priv *rp = rport->dd_data; struct fc_rport_libfc_priv *rpriv = rport->dd_data;
struct fc_lport *lport = rp->local_port; struct fc_lport *lport = rpriv->local_port;
lport->tt.exch_mgr_reset(lport, 0, rport->port_id); lport->tt.exch_mgr_reset(lport, 0, rport->port_id);
lport->tt.exch_mgr_reset(lport, rport->port_id, 0); lport->tt.exch_mgr_reset(lport, rport->port_id, 0);

Разница между файлами не показана из-за своего большого размера Загрузить разницу