aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/cxgb4/device.c
diff options
context:
space:
mode:
authorVipul Pandya <vipul@chelsio.com>2012-05-18 05:59:27 -0400
committerRoland Dreier <roland@purestorage.com>2012-05-18 16:22:29 -0400
commit8d81ef34b249109084b2f3c4bb826d0417ef5814 (patch)
tree77dbd13539db2053cada804c35e4cccd26f4e4c0 /drivers/infiniband/hw/cxgb4/device.c
parent3069ee9bc451d90a2fa8c3c7ef2774744d9d3bb0 (diff)
RDMA/cxgb4: Add debugfs RDMA memory stats
Signed-off-by: Vipul Pandya <vipul@chelsio.com> Signed-off-by: Steve Wise <swise@opengridcomputing.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband/hw/cxgb4/device.c')
-rw-r--r--drivers/infiniband/hw/cxgb4/device.c78
1 files changed, 76 insertions, 2 deletions
diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c
index 6d0df6ec161b..84831119c596 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -240,6 +240,62 @@ static const struct file_operations stag_debugfs_fops = {
240 .llseek = default_llseek, 240 .llseek = default_llseek,
241}; 241};
242 242
243static int stats_show(struct seq_file *seq, void *v)
244{
245 struct c4iw_dev *dev = seq->private;
246
247 seq_printf(seq, " Object: %10s %10s %10s\n", "Total", "Current", "Max");
248 seq_printf(seq, " PDID: %10llu %10llu %10llu\n",
249 dev->rdev.stats.pd.total, dev->rdev.stats.pd.cur,
250 dev->rdev.stats.pd.max);
251 seq_printf(seq, " QID: %10llu %10llu %10llu\n",
252 dev->rdev.stats.qid.total, dev->rdev.stats.qid.cur,
253 dev->rdev.stats.qid.max);
254 seq_printf(seq, " TPTMEM: %10llu %10llu %10llu\n",
255 dev->rdev.stats.stag.total, dev->rdev.stats.stag.cur,
256 dev->rdev.stats.stag.max);
257 seq_printf(seq, " PBLMEM: %10llu %10llu %10llu\n",
258 dev->rdev.stats.pbl.total, dev->rdev.stats.pbl.cur,
259 dev->rdev.stats.pbl.max);
260 seq_printf(seq, " RQTMEM: %10llu %10llu %10llu\n",
261 dev->rdev.stats.rqt.total, dev->rdev.stats.rqt.cur,
262 dev->rdev.stats.rqt.max);
263 seq_printf(seq, " OCQPMEM: %10llu %10llu %10llu\n",
264 dev->rdev.stats.ocqp.total, dev->rdev.stats.ocqp.cur,
265 dev->rdev.stats.ocqp.max);
266 return 0;
267}
268
269static int stats_open(struct inode *inode, struct file *file)
270{
271 return single_open(file, stats_show, inode->i_private);
272}
273
274static ssize_t stats_clear(struct file *file, const char __user *buf,
275 size_t count, loff_t *pos)
276{
277 struct c4iw_dev *dev = ((struct seq_file *)file->private_data)->private;
278
279 mutex_lock(&dev->rdev.stats.lock);
280 dev->rdev.stats.pd.max = 0;
281 dev->rdev.stats.qid.max = 0;
282 dev->rdev.stats.stag.max = 0;
283 dev->rdev.stats.pbl.max = 0;
284 dev->rdev.stats.rqt.max = 0;
285 dev->rdev.stats.ocqp.max = 0;
286 mutex_unlock(&dev->rdev.stats.lock);
287 return count;
288}
289
290static const struct file_operations stats_debugfs_fops = {
291 .owner = THIS_MODULE,
292 .open = stats_open,
293 .release = single_release,
294 .read = seq_read,
295 .llseek = seq_lseek,
296 .write = stats_clear,
297};
298
243static int setup_debugfs(struct c4iw_dev *devp) 299static int setup_debugfs(struct c4iw_dev *devp)
244{ 300{
245 struct dentry *de; 301 struct dentry *de;
@@ -256,6 +312,12 @@ static int setup_debugfs(struct c4iw_dev *devp)
256 (void *)devp, &stag_debugfs_fops); 312 (void *)devp, &stag_debugfs_fops);
257 if (de && de->d_inode) 313 if (de && de->d_inode)
258 de->d_inode->i_size = 4096; 314 de->d_inode->i_size = 4096;
315
316 de = debugfs_create_file("stats", S_IWUSR, devp->debugfs_root,
317 (void *)devp, &stats_debugfs_fops);
318 if (de && de->d_inode)
319 de->d_inode->i_size = 4096;
320
259 return 0; 321 return 0;
260} 322}
261 323
@@ -269,9 +331,13 @@ void c4iw_release_dev_ucontext(struct c4iw_rdev *rdev,
269 list_for_each_safe(pos, nxt, &uctx->qpids) { 331 list_for_each_safe(pos, nxt, &uctx->qpids) {
270 entry = list_entry(pos, struct c4iw_qid_list, entry); 332 entry = list_entry(pos, struct c4iw_qid_list, entry);
271 list_del_init(&entry->entry); 333 list_del_init(&entry->entry);
272 if (!(entry->qid & rdev->qpmask)) 334 if (!(entry->qid & rdev->qpmask)) {
273 c4iw_put_resource(&rdev->resource.qid_fifo, entry->qid, 335 c4iw_put_resource(&rdev->resource.qid_fifo, entry->qid,
274 &rdev->resource.qid_fifo_lock); 336 &rdev->resource.qid_fifo_lock);
337 mutex_lock(&rdev->stats.lock);
338 rdev->stats.qid.cur -= rdev->qpmask + 1;
339 mutex_unlock(&rdev->stats.lock);
340 }
275 kfree(entry); 341 kfree(entry);
276 } 342 }
277 343
@@ -332,6 +398,13 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
332 goto err1; 398 goto err1;
333 } 399 }
334 400
401 rdev->stats.pd.total = T4_MAX_NUM_PD;
402 rdev->stats.stag.total = rdev->lldi.vr->stag.size;
403 rdev->stats.pbl.total = rdev->lldi.vr->pbl.size;
404 rdev->stats.rqt.total = rdev->lldi.vr->rq.size;
405 rdev->stats.ocqp.total = rdev->lldi.vr->ocq.size;
406 rdev->stats.qid.total = rdev->lldi.vr->qp.size;
407
335 err = c4iw_init_resource(rdev, c4iw_num_stags(rdev), T4_MAX_NUM_PD); 408 err = c4iw_init_resource(rdev, c4iw_num_stags(rdev), T4_MAX_NUM_PD);
336 if (err) { 409 if (err) {
337 printk(KERN_ERR MOD "error %d initializing resources\n", err); 410 printk(KERN_ERR MOD "error %d initializing resources\n", err);
@@ -440,6 +513,7 @@ static struct c4iw_dev *c4iw_alloc(const struct cxgb4_lld_info *infop)
440 idr_init(&devp->qpidr); 513 idr_init(&devp->qpidr);
441 idr_init(&devp->mmidr); 514 idr_init(&devp->mmidr);
442 spin_lock_init(&devp->lock); 515 spin_lock_init(&devp->lock);
516 mutex_init(&devp->rdev.stats.lock);
443 517
444 if (c4iw_debugfs_root) { 518 if (c4iw_debugfs_root) {
445 devp->debugfs_root = debugfs_create_dir( 519 devp->debugfs_root = debugfs_create_dir(