Commit 582e05c3 authored by Dean Luick's avatar Dean Luick Committed by Doug Ledford

staging/rdma/hfi1: Fix counter read for cp

A cp or cat of /sys/kernel/debug/hfi1/hfi1_0/port1counters
produces the following message:

hfi1 0000:81:00.0: hfi1_0: index not supported
hfi1 0000:81:00.0: hfi1_0: read_cntrs does not support indexing

Fix by removing the file position logic and the associated messages
and make the file positioning the responsibility of the caller.

The port counter read function argument is changed to the per port
data structure since the counters are relative to the port and not
the device.
Reviewed-by: default avatarSebastian Sanchez <sebastian.sanchez@intel.com>
Signed-off-by: default avatarDean Luick <dean.luick@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 7b47622d
...@@ -11407,28 +11407,19 @@ void hfi1_rcvctrl(struct hfi1_devdata *dd, unsigned int op, int ctxt) ...@@ -11407,28 +11407,19 @@ void hfi1_rcvctrl(struct hfi1_devdata *dd, unsigned int op, int ctxt)
dd->rcvhdrtail_dummy_physaddr); dd->rcvhdrtail_dummy_physaddr);
} }
u32 hfi1_read_cntrs(struct hfi1_devdata *dd, loff_t pos, char **namep, u32 hfi1_read_cntrs(struct hfi1_devdata *dd, char **namep, u64 **cntrp)
u64 **cntrp)
{ {
int ret; int ret;
u64 val = 0; u64 val = 0;
if (namep) { if (namep) {
ret = dd->cntrnameslen; ret = dd->cntrnameslen;
if (pos != 0) {
dd_dev_err(dd, "read_cntrs does not support indexing");
return 0;
}
*namep = dd->cntrnames; *namep = dd->cntrnames;
} else { } else {
const struct cntr_entry *entry; const struct cntr_entry *entry;
int i, j; int i, j;
ret = (dd->ndevcntrs) * sizeof(u64); ret = (dd->ndevcntrs) * sizeof(u64);
if (pos != 0) {
dd_dev_err(dd, "read_cntrs does not support indexing");
return 0;
}
/* Get the start of the block of counters */ /* Get the start of the block of counters */
*cntrp = dd->cntrs; *cntrp = dd->cntrs;
...@@ -11487,30 +11478,19 @@ u32 hfi1_read_cntrs(struct hfi1_devdata *dd, loff_t pos, char **namep, ...@@ -11487,30 +11478,19 @@ u32 hfi1_read_cntrs(struct hfi1_devdata *dd, loff_t pos, char **namep,
/* /*
* Used by sysfs to create files for hfi stats to read * Used by sysfs to create files for hfi stats to read
*/ */
u32 hfi1_read_portcntrs(struct hfi1_devdata *dd, loff_t pos, u32 port, u32 hfi1_read_portcntrs(struct hfi1_pportdata *ppd, char **namep, u64 **cntrp)
char **namep, u64 **cntrp)
{ {
int ret; int ret;
u64 val = 0; u64 val = 0;
if (namep) { if (namep) {
ret = dd->portcntrnameslen; ret = ppd->dd->portcntrnameslen;
if (pos != 0) { *namep = ppd->dd->portcntrnames;
dd_dev_err(dd, "index not supported");
return 0;
}
*namep = dd->portcntrnames;
} else { } else {
const struct cntr_entry *entry; const struct cntr_entry *entry;
struct hfi1_pportdata *ppd;
int i, j; int i, j;
ret = (dd->nportcntrs) * sizeof(u64); ret = ppd->dd->nportcntrs * sizeof(u64);
if (pos != 0) {
dd_dev_err(dd, "indexing not supported");
return 0;
}
ppd = (struct hfi1_pportdata *)(dd + 1 + port);
*cntrp = ppd->cntrs; *cntrp = ppd->cntrs;
for (i = 0; i < PORT_CNTR_LAST; i++) { for (i = 0; i < PORT_CNTR_LAST; i++) {
......
...@@ -1297,10 +1297,8 @@ void hfi1_put_tid(struct hfi1_devdata *dd, u32 index, ...@@ -1297,10 +1297,8 @@ void hfi1_put_tid(struct hfi1_devdata *dd, u32 index,
u32 type, unsigned long pa, u16 order); u32 type, unsigned long pa, u16 order);
void hfi1_quiet_serdes(struct hfi1_pportdata *ppd); void hfi1_quiet_serdes(struct hfi1_pportdata *ppd);
void hfi1_rcvctrl(struct hfi1_devdata *dd, unsigned int op, int ctxt); void hfi1_rcvctrl(struct hfi1_devdata *dd, unsigned int op, int ctxt);
u32 hfi1_read_cntrs(struct hfi1_devdata *dd, loff_t pos, char **namep, u32 hfi1_read_cntrs(struct hfi1_devdata *dd, char **namep, u64 **cntrp);
u64 **cntrp); u32 hfi1_read_portcntrs(struct hfi1_pportdata *ppd, char **namep, u64 **cntrp);
u32 hfi1_read_portcntrs(struct hfi1_devdata *dd, loff_t pos, u32 port,
char **namep, u64 **cntrp);
u8 hfi1_ibphys_portstate(struct hfi1_pportdata *ppd); u8 hfi1_ibphys_portstate(struct hfi1_pportdata *ppd);
int hfi1_get_ib_cfg(struct hfi1_pportdata *ppd, int which); int hfi1_get_ib_cfg(struct hfi1_pportdata *ppd, int which);
int hfi1_set_ib_cfg(struct hfi1_pportdata *ppd, int which, u32 val); int hfi1_set_ib_cfg(struct hfi1_pportdata *ppd, int which, u32 val);
......
...@@ -336,7 +336,7 @@ static ssize_t dev_counters_read(struct file *file, char __user *buf, ...@@ -336,7 +336,7 @@ static ssize_t dev_counters_read(struct file *file, char __user *buf,
rcu_read_lock(); rcu_read_lock();
dd = private2dd(file); dd = private2dd(file);
avail = hfi1_read_cntrs(dd, *ppos, NULL, &counters); avail = hfi1_read_cntrs(dd, NULL, &counters);
rval = simple_read_from_buffer(buf, count, ppos, counters, avail); rval = simple_read_from_buffer(buf, count, ppos, counters, avail);
rcu_read_unlock(); rcu_read_unlock();
return rval; return rval;
...@@ -353,7 +353,7 @@ static ssize_t dev_names_read(struct file *file, char __user *buf, ...@@ -353,7 +353,7 @@ static ssize_t dev_names_read(struct file *file, char __user *buf,
rcu_read_lock(); rcu_read_lock();
dd = private2dd(file); dd = private2dd(file);
avail = hfi1_read_cntrs(dd, *ppos, &names, NULL); avail = hfi1_read_cntrs(dd, &names, NULL);
rval = simple_read_from_buffer(buf, count, ppos, names, avail); rval = simple_read_from_buffer(buf, count, ppos, names, avail);
rcu_read_unlock(); rcu_read_unlock();
return rval; return rval;
...@@ -380,8 +380,7 @@ static ssize_t portnames_read(struct file *file, char __user *buf, ...@@ -380,8 +380,7 @@ static ssize_t portnames_read(struct file *file, char __user *buf,
rcu_read_lock(); rcu_read_lock();
dd = private2dd(file); dd = private2dd(file);
/* port number n/a here since names are constant */ avail = hfi1_read_portcntrs(dd->pport, &names, NULL);
avail = hfi1_read_portcntrs(dd, *ppos, 0, &names, NULL);
rval = simple_read_from_buffer(buf, count, ppos, names, avail); rval = simple_read_from_buffer(buf, count, ppos, names, avail);
rcu_read_unlock(); rcu_read_unlock();
return rval; return rval;
...@@ -393,14 +392,12 @@ static ssize_t portcntrs_debugfs_read(struct file *file, char __user *buf, ...@@ -393,14 +392,12 @@ static ssize_t portcntrs_debugfs_read(struct file *file, char __user *buf,
{ {
u64 *counters; u64 *counters;
size_t avail; size_t avail;
struct hfi1_devdata *dd;
struct hfi1_pportdata *ppd; struct hfi1_pportdata *ppd;
ssize_t rval; ssize_t rval;
rcu_read_lock(); rcu_read_lock();
ppd = private2ppd(file); ppd = private2ppd(file);
dd = ppd->dd; avail = hfi1_read_portcntrs(ppd, NULL, &counters);
avail = hfi1_read_portcntrs(dd, *ppos, ppd->port - 1, NULL, &counters);
rval = simple_read_from_buffer(buf, count, ppos, counters, avail); rval = simple_read_from_buffer(buf, count, ppos, counters, avail);
rcu_read_unlock(); rcu_read_unlock();
return rval; return rval;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment