Skip to content

Commit b84056b

Browse files
yizouJames Bottomley
authored andcommitted
[SCSI] fcoe, libfc: add get_lesb() to allow LLD to fill the link error status block (LESB)
Add a member function pointer as get_lesb to libfc_function_template so LLD can fill the LESB based on its own statistics. For fcoe, it fills the LESB as a fcoe_fc_els_lesb struct according to FC-BB-5. Signed-off-by: Yi Zou <yi.zou@intel.com> Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
1 parent b21a0c3 commit b84056b

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

‎drivers/scsi/fcoe/fcoe.c‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ static struct fc_seq *fcoe_elsct_send(struct fc_lport *,
111111
void *, u32 timeout);
112112
static void fcoe_recv_frame(struct sk_buff *skb);
113113

114+
static void fcoe_get_lesb(struct fc_lport *, struct fc_els_lesb *);
115+
114116
module_param_call(create, fcoe_create, NULL, NULL, S_IWUSR);
115117
__MODULE_PARM_TYPE(create, "string");
116118
MODULE_PARM_DESC(create, "Create fcoe fcoe using net device passed in.");
@@ -141,6 +143,7 @@ static struct libfc_function_template fcoe_libfc_fcn_templ = {
141143
.ddp_setup = fcoe_ddp_setup,
142144
.ddp_done = fcoe_ddp_done,
143145
.elsct_send = fcoe_elsct_send,
146+
.get_lesb = fcoe_get_lesb,
144147
};
145148

146149
struct fc_function_template fcoe_transport_function = {
@@ -2455,3 +2458,34 @@ static void fcoe_set_vport_symbolic_name(struct fc_vport *vport)
24552458
lport->tt.elsct_send(lport, FC_FID_DIR_SERV, fp, FC_NS_RSPN_ID,
24562459
NULL, NULL, 3 * lport->r_a_tov);
24572460
}
2461+
2462+
/**
2463+
* fcoe_get_lesb() - Fill the FCoE Link Error Status Block
2464+
* @lport: the local port
2465+
* @fc_lesb: the link error status block
2466+
*/
2467+
static void fcoe_get_lesb(struct fc_lport *lport,
2468+
struct fc_els_lesb *fc_lesb)
2469+
{
2470+
unsigned int cpu;
2471+
u32 lfc, vlfc, mdac;
2472+
struct fcoe_dev_stats *devst;
2473+
struct fcoe_fc_els_lesb *lesb;
2474+
struct net_device *netdev = fcoe_netdev(lport);
2475+
2476+
lfc = 0;
2477+
vlfc = 0;
2478+
mdac = 0;
2479+
lesb = (struct fcoe_fc_els_lesb *)fc_lesb;
2480+
memset(lesb, 0, sizeof(*lesb));
2481+
for_each_possible_cpu(cpu) {
2482+
devst = per_cpu_ptr(lport->dev_stats, cpu);
2483+
lfc += devst->LinkFailureCount;
2484+
vlfc += devst->VLinkFailureCount;
2485+
mdac += devst->MissDiscAdvCount;
2486+
}
2487+
lesb->lesb_link_fail = htonl(lfc);
2488+
lesb->lesb_vlink_fail = htonl(vlfc);
2489+
lesb->lesb_miss_fka = htonl(mdac);
2490+
lesb->lesb_fcs_error = htonl(dev_get_stats(netdev)->rx_crc_errors);
2491+
}

‎include/scsi/libfc.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,12 @@ struct libfc_function_template {
510510
* STATUS: OPTIONAL
511511
*/
512512
int (*ddp_done)(struct fc_lport *, u16);
513+
/*
514+
* Allow LLD to fill its own Link Error Status Block
515+
*
516+
* STATUS: OPTIONAL
517+
*/
518+
void (*get_lesb)(struct fc_lport *, struct fc_els_lesb *lesb);
513519
/*
514520
* Send a frame using an existing sequence and exchange.
515521
*

0 commit comments

Comments
 (0)