Skip to content

Commit 74a7baa

Browse files
jsmart-ghmartinkpetersen
authored andcommitted
scsi: lpfc: Add cmf_info sysfs entry
Allow abbreviated cm framework status information to be obtained via sysfs. Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Justin Tee <[email protected]> Signed-off-by: Justin Tee <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 9f77870 commit 74a7baa

File tree

7 files changed

+235
-10
lines changed

7 files changed

+235
-10
lines changed

drivers/scsi/lpfc/lpfc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,7 @@ struct lpfc_hba {
16001600
};
16011601

16021602
#define LPFC_MAX_RXMONITOR_ENTRY 800
1603+
#define LPFC_MAX_RXMONITOR_DUMP 32
16031604
struct rxtable_entry {
16041605
uint64_t total_bytes; /* Total no of read bytes requested */
16051606
uint64_t rcv_bytes; /* Total no of read bytes completed */

drivers/scsi/lpfc/lpfc_attr.c

Lines changed: 189 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
#define LPFC_MIN_DEVLOSS_TMO 1
5858
#define LPFC_MAX_DEVLOSS_TMO 255
5959

60+
#define LPFC_MAX_INFO_TMP_LEN 100
61+
#define LPFC_INFO_MORE_STR "\nCould be more info...\n"
6062
/*
6163
* Write key size should be multiple of 4. If write key is changed
6264
* make sure that library write key is also changed.
@@ -112,6 +114,186 @@ lpfc_jedec_to_ascii(int incr, char hdw[])
112114
return;
113115
}
114116

117+
static ssize_t
118+
lpfc_cmf_info_show(struct device *dev, struct device_attribute *attr,
119+
char *buf)
120+
{
121+
struct Scsi_Host *shost = class_to_shost(dev);
122+
struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
123+
struct lpfc_hba *phba = vport->phba;
124+
struct lpfc_cgn_info *cp = NULL;
125+
struct lpfc_cgn_stat *cgs;
126+
int len = 0;
127+
int cpu;
128+
u64 rcv, total;
129+
char tmp[LPFC_MAX_INFO_TMP_LEN] = {0};
130+
131+
if (phba->cgn_i)
132+
cp = (struct lpfc_cgn_info *)phba->cgn_i->virt;
133+
134+
scnprintf(tmp, sizeof(tmp),
135+
"Congestion Mgmt Info: E2Eattr %d Ver %d "
136+
"CMF %d cnt %d\n",
137+
phba->sli4_hba.pc_sli4_params.mi_ver,
138+
cp ? cp->cgn_info_version : 0,
139+
phba->sli4_hba.pc_sli4_params.cmf, phba->cmf_timer_cnt);
140+
141+
if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
142+
goto buffer_done;
143+
144+
if (!phba->sli4_hba.pc_sli4_params.cmf)
145+
goto buffer_done;
146+
147+
switch (phba->cgn_init_reg_signal) {
148+
case EDC_CG_SIG_WARN_ONLY:
149+
scnprintf(tmp, sizeof(tmp),
150+
"Register: Init: Signal:WARN ");
151+
break;
152+
case EDC_CG_SIG_WARN_ALARM:
153+
scnprintf(tmp, sizeof(tmp),
154+
"Register: Init: Signal:WARN|ALARM ");
155+
break;
156+
default:
157+
scnprintf(tmp, sizeof(tmp),
158+
"Register: Init: Signal:NONE ");
159+
break;
160+
}
161+
if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
162+
goto buffer_done;
163+
164+
switch (phba->cgn_init_reg_fpin) {
165+
case LPFC_CGN_FPIN_WARN:
166+
scnprintf(tmp, sizeof(tmp),
167+
"FPIN:WARN\n");
168+
break;
169+
case LPFC_CGN_FPIN_ALARM:
170+
scnprintf(tmp, sizeof(tmp),
171+
"FPIN:ALARM\n");
172+
break;
173+
case LPFC_CGN_FPIN_BOTH:
174+
scnprintf(tmp, sizeof(tmp),
175+
"FPIN:WARN|ALARM\n");
176+
break;
177+
default:
178+
scnprintf(tmp, sizeof(tmp),
179+
"FPIN:NONE\n");
180+
break;
181+
}
182+
if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
183+
goto buffer_done;
184+
185+
switch (phba->cgn_reg_signal) {
186+
case EDC_CG_SIG_WARN_ONLY:
187+
scnprintf(tmp, sizeof(tmp),
188+
" Current: Signal:WARN ");
189+
break;
190+
case EDC_CG_SIG_WARN_ALARM:
191+
scnprintf(tmp, sizeof(tmp),
192+
" Current: Signal:WARN|ALARM ");
193+
break;
194+
default:
195+
scnprintf(tmp, sizeof(tmp),
196+
" Current: Signal:NONE ");
197+
break;
198+
}
199+
if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
200+
goto buffer_done;
201+
202+
switch (phba->cgn_reg_fpin) {
203+
case LPFC_CGN_FPIN_WARN:
204+
scnprintf(tmp, sizeof(tmp),
205+
"FPIN:WARN ACQEcnt:%d\n", phba->cgn_acqe_cnt);
206+
break;
207+
case LPFC_CGN_FPIN_ALARM:
208+
scnprintf(tmp, sizeof(tmp),
209+
"FPIN:ALARM ACQEcnt:%d\n", phba->cgn_acqe_cnt);
210+
break;
211+
case LPFC_CGN_FPIN_BOTH:
212+
scnprintf(tmp, sizeof(tmp),
213+
"FPIN:WARN|ALARM ACQEcnt:%d\n", phba->cgn_acqe_cnt);
214+
break;
215+
default:
216+
scnprintf(tmp, sizeof(tmp),
217+
"FPIN:NONE ACQEcnt:%d\n", phba->cgn_acqe_cnt);
218+
break;
219+
}
220+
if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
221+
goto buffer_done;
222+
223+
if (phba->cmf_active_mode != phba->cgn_p.cgn_param_mode) {
224+
switch (phba->cmf_active_mode) {
225+
case LPFC_CFG_OFF:
226+
scnprintf(tmp, sizeof(tmp), "Active: Mode:Off\n");
227+
break;
228+
case LPFC_CFG_MANAGED:
229+
scnprintf(tmp, sizeof(tmp), "Active: Mode:Managed\n");
230+
break;
231+
case LPFC_CFG_MONITOR:
232+
scnprintf(tmp, sizeof(tmp), "Active: Mode:Monitor\n");
233+
break;
234+
default:
235+
scnprintf(tmp, sizeof(tmp), "Active: Mode:Unknown\n");
236+
}
237+
if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
238+
goto buffer_done;
239+
}
240+
241+
switch (phba->cgn_p.cgn_param_mode) {
242+
case LPFC_CFG_OFF:
243+
scnprintf(tmp, sizeof(tmp), "Config: Mode:Off ");
244+
break;
245+
case LPFC_CFG_MANAGED:
246+
scnprintf(tmp, sizeof(tmp), "Config: Mode:Managed ");
247+
break;
248+
case LPFC_CFG_MONITOR:
249+
scnprintf(tmp, sizeof(tmp), "Config: Mode:Monitor ");
250+
break;
251+
default:
252+
scnprintf(tmp, sizeof(tmp), "Config: Mode:Unknown ");
253+
}
254+
if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
255+
goto buffer_done;
256+
257+
total = 0;
258+
rcv = 0;
259+
for_each_present_cpu(cpu) {
260+
cgs = per_cpu_ptr(phba->cmf_stat, cpu);
261+
total += atomic64_read(&cgs->total_bytes);
262+
rcv += atomic64_read(&cgs->rcv_bytes);
263+
}
264+
265+
scnprintf(tmp, sizeof(tmp),
266+
"IObusy:%d Info:%d Bytes: Rcv:x%llx Total:x%llx\n",
267+
atomic_read(&phba->cmf_busy),
268+
phba->cmf_active_info, rcv, total);
269+
if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
270+
goto buffer_done;
271+
272+
scnprintf(tmp, sizeof(tmp),
273+
"Port_speed:%d Link_byte_cnt:%ld "
274+
"Max_byte_per_interval:%ld\n",
275+
lpfc_sli_port_speed_get(phba),
276+
(unsigned long)phba->cmf_link_byte_count,
277+
(unsigned long)phba->cmf_max_bytes_per_interval);
278+
strlcat(buf, tmp, PAGE_SIZE);
279+
280+
buffer_done:
281+
len = strnlen(buf, PAGE_SIZE);
282+
283+
if (unlikely(len >= (PAGE_SIZE - 1))) {
284+
lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT,
285+
"6312 Catching potential buffer "
286+
"overflow > PAGE_SIZE = %lu bytes\n",
287+
PAGE_SIZE);
288+
strscpy(buf + PAGE_SIZE - 1 -
289+
strnlen(LPFC_INFO_MORE_STR, PAGE_SIZE - 1),
290+
LPFC_INFO_MORE_STR,
291+
strnlen(LPFC_INFO_MORE_STR, PAGE_SIZE - 1)
292+
+ 1);
293+
}
294+
return len;
295+
}
296+
115297
/**
116298
* lpfc_drvr_version_show - Return the Emulex driver string with version number
117299
* @dev: class unused variable.
@@ -168,7 +350,7 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr,
168350
char *statep;
169351
int i;
170352
int len = 0;
171-
char tmp[LPFC_MAX_NVME_INFO_TMP_LEN] = {0};
353+
char tmp[LPFC_MAX_INFO_TMP_LEN] = {0};
172354

173355
if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) {
174356
len = scnprintf(buf, PAGE_SIZE, "NVME Disabled\n");
@@ -512,9 +694,9 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr,
512694
"6314 Catching potential buffer "
513695
"overflow > PAGE_SIZE = %lu bytes\n",
514696
PAGE_SIZE);
515-
strlcpy(buf + PAGE_SIZE - 1 - sizeof(LPFC_NVME_INFO_MORE_STR),
516-
LPFC_NVME_INFO_MORE_STR,
517-
sizeof(LPFC_NVME_INFO_MORE_STR) + 1);
697+
strscpy(buf + PAGE_SIZE - 1 - sizeof(LPFC_INFO_MORE_STR),
698+
LPFC_INFO_MORE_STR,
699+
sizeof(LPFC_INFO_MORE_STR) + 1);
518700
}
519701

520702
return len;
@@ -2636,6 +2818,7 @@ static DEVICE_ATTR_RO(lpfc_sriov_hw_max_virtfn);
26362818
static DEVICE_ATTR(protocol, S_IRUGO, lpfc_sli4_protocol_show, NULL);
26372819
static DEVICE_ATTR(lpfc_xlane_supported, S_IRUGO, lpfc_oas_supported_show,
26382820
NULL);
2821+
static DEVICE_ATTR(cmf_info, 0444, lpfc_cmf_info_show, NULL);
26392822

26402823
static char *lpfc_soft_wwn_key = "C99G71SL8032A";
26412824
#define WWN_SZ 8
@@ -6332,6 +6515,7 @@ struct device_attribute *lpfc_hba_attrs[] = {
63326515
&dev_attr_lpfc_enable_bbcr,
63336516
&dev_attr_lpfc_enable_dpp,
63346517
&dev_attr_lpfc_enable_mi,
6518+
&dev_attr_cmf_info,
63356519
&dev_attr_lpfc_max_vmid,
63366520
&dev_attr_lpfc_vmid_inactivity_timeout,
63376521
&dev_attr_lpfc_vmid_app_header,
@@ -6362,6 +6546,7 @@ struct device_attribute *lpfc_vport_attrs[] = {
63626546
&dev_attr_lpfc_max_scsicmpl_time,
63636547
&dev_attr_lpfc_stat_data_ctrl,
63646548
&dev_attr_lpfc_static_vport,
6549+
&dev_attr_cmf_info,
63656550
NULL,
63666551
};
63676552

drivers/scsi/lpfc/lpfc_crtn.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ int lpfc_sli4_cgn_params_read(struct lpfc_hba *phba);
8686
uint32_t lpfc_cgn_calc_crc32(void *bufp, uint32_t sz, uint32_t seed);
8787
int lpfc_config_cgn_signal(struct lpfc_hba *phba);
8888
int lpfc_issue_cmf_sync_wqe(struct lpfc_hba *phba, u32 ms, u64 total);
89+
void lpfc_cgn_dump_rxmonitor(struct lpfc_hba *phba);
8990
void lpfc_cgn_update_stat(struct lpfc_hba *phba, uint32_t dtag);
9091
void lpfc_unblock_requests(struct lpfc_hba *phba);
9192
void lpfc_block_requests(struct lpfc_hba *phba);
@@ -159,6 +160,7 @@ int lpfc_issue_els_rscn(struct lpfc_vport *vport, uint8_t retry);
159160
int lpfc_issue_fabric_reglogin(struct lpfc_vport *);
160161
int lpfc_issue_els_rdf(struct lpfc_vport *vport, uint8_t retry);
161162
int lpfc_issue_els_edc(struct lpfc_vport *vport, uint8_t retry);
163+
void lpfc_els_rcv_fpin(struct lpfc_vport *vport, void *p, u32 fpin_length);
162164
int lpfc_els_free_iocb(struct lpfc_hba *, struct lpfc_iocbq *);
163165
int lpfc_ct_free_iocb(struct lpfc_hba *, struct lpfc_iocbq *);
164166
int lpfc_els_rsp_acc(struct lpfc_vport *, uint32_t, struct lpfc_iocbq *,

drivers/scsi/lpfc/lpfc_els.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9632,7 +9632,7 @@ lpfc_els_rcv_fpin_cgn(struct lpfc_hba *phba, struct fc_tlv_desc *tlv)
96329632
return rc;
96339633
}
96349634

9635-
static void
9635+
void
96369636
lpfc_els_rcv_fpin(struct lpfc_vport *vport, void *p, u32 fpin_length)
96379637
{
96389638
struct lpfc_hba *phba = vport->phba;

drivers/scsi/lpfc/lpfc_hw4.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,7 @@ struct lpfc_mbx_nembed_sge_virt {
11571157
void *addr[LPFC_SLI4_MBX_SGE_MAX_PAGES];
11581158
};
11591159

1160+
#define LPFC_MBX_OBJECT_NAME_LEN_DW 26
11601161
struct lpfc_mbx_read_object { /* Version 0 */
11611162
struct mbox_header header;
11621163
union {
@@ -1166,7 +1167,7 @@ struct lpfc_mbx_read_object { /* Version 0 */
11661167
#define lpfc_mbx_rd_object_rlen_MASK 0x00FFFFFF
11671168
#define lpfc_mbx_rd_object_rlen_WORD word0
11681169
uint32_t rd_object_offset;
1169-
uint32_t rd_object_name[26];
1170+
uint32_t rd_object_name[LPFC_MBX_OBJECT_NAME_LEN_DW];
11701171
#define LPFC_OBJ_NAME_SZ 104 /* 26 x sizeof(uint32_t) is 104. */
11711172
uint32_t rd_object_cnt;
11721173
struct lpfc_mbx_host_buf rd_object_hbuf[4];
@@ -3871,6 +3872,7 @@ struct lpfc_mbx_get_port_name {
38713872
#define MB_CEQ_STATUS_QUEUE_FLUSHING 0x4
38723873
#define MB_CQE_STATUS_DMA_FAILED 0x5
38733874

3875+
38743876
#define LPFC_MBX_WR_CONFIG_MAX_BDE 1
38753877
struct lpfc_mbx_wr_object {
38763878
struct mbox_header header;
@@ -3887,7 +3889,7 @@ struct lpfc_mbx_wr_object {
38873889
#define lpfc_wr_object_write_length_MASK 0x00FFFFFF
38883890
#define lpfc_wr_object_write_length_WORD word4
38893891
uint32_t write_offset;
3890-
uint32_t object_name[26];
3892+
uint32_t object_name[LPFC_MBX_OBJECT_NAME_LEN_DW];
38913893
uint32_t bde_count;
38923894
struct ulp_bde64 bde[LPFC_MBX_WR_CONFIG_MAX_BDE];
38933895
} request;

drivers/scsi/lpfc/lpfc_init.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5404,6 +5404,44 @@ lpfc_async_link_speed_to_read_top(struct lpfc_hba *phba, uint8_t speed_code)
54045404
return port_speed;
54055405
}
54065406

5407+
void
5408+
lpfc_cgn_dump_rxmonitor(struct lpfc_hba *phba)
5409+
{
5410+
struct rxtable_entry *entry;
5411+
int cnt = 0, head, tail, last, start;
5412+
5413+
head = atomic_read(&phba->rxtable_idx_head);
5414+
tail = atomic_read(&phba->rxtable_idx_tail);
5415+
if (!phba->rxtable || head == tail) {
5416+
lpfc_printf_log(phba, KERN_ERR, LOG_CGN_MGMT,
5417+
"4411 Rxtable is empty\n");
5418+
return;
5419+
}
5420+
last = tail;
5421+
start = head;
5422+
5423+
/* Display the last LPFC_MAX_RXMONITOR_DUMP entries from the rxtable */
5424+
while (start != last) {
5425+
if (start)
5426+
start--;
5427+
else
5428+
start = LPFC_MAX_RXMONITOR_ENTRY - 1;
5429+
entry = &phba->rxtable[start];
5430+
lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT,
5431+
"4410 %02d: MBPI %lld Xmit %lld Cmpl %lld "
5432+
"Lat %lld ASz %lld Info %02d BWUtil %d "
5433+
"Int %d slot %d\n",
5434+
cnt, entry->max_bytes_per_interval,
5435+
entry->total_bytes, entry->rcv_bytes,
5436+
entry->avg_io_latency, entry->avg_io_size,
5437+
entry->cmf_info, entry->timer_utilization,
5438+
entry->timer_interval, start);
5439+
cnt++;
5440+
if (cnt >= LPFC_MAX_RXMONITOR_DUMP)
5441+
return;
5442+
}
5443+
}
5444+
54075445
/**
54085446
* lpfc_cgn_update_stat - Save data into congestion stats buffer
54095447
* @phba: pointer to lpfc hba data structure.

drivers/scsi/lpfc/lpfc_nvme.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434
#define LPFC_NVME_FB_SHIFT 9
3535
#define LPFC_NVME_MAX_FB (1 << 20) /* 1M */
3636

37-
#define LPFC_MAX_NVME_INFO_TMP_LEN 100
38-
#define LPFC_NVME_INFO_MORE_STR "\nCould be more info...\n"
39-
4037
#define lpfc_ndlp_get_nrport(ndlp) \
4138
((!ndlp->nrport || (ndlp->fc4_xpt_flags & NVME_XPT_UNREG_WAIT))\
4239
? NULL : ndlp->nrport)

0 commit comments

Comments
 (0)