diff options
author | Upinder Malhi <umalhi@cisco.com> | 2014-01-09 18:40:58 -0500 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2014-01-14 03:44:46 -0500 |
commit | 9f637f7936025aef57f247b11036bad18bb87c06 (patch) | |
tree | 6f6b0f89a5e7cd16680c4fdd29c301d9161c1e88 | |
parent | c5f855e08a97edc107c4a3b73809ed629c1dcac1 (diff) |
IB/usnic: Expose flows via debugfs
Signed-off-by: Upinder Malhi <umalhi@cisco.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
-rw-r--r-- | drivers/infiniband/hw/usnic/usnic_debugfs.c | 91 | ||||
-rw-r--r-- | drivers/infiniband/hw/usnic/usnic_debugfs.h | 4 | ||||
-rw-r--r-- | drivers/infiniband/hw/usnic/usnic_ib.h | 7 | ||||
-rw-r--r-- | drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c | 8 | ||||
-rw-r--r-- | drivers/infiniband/hw/usnic/usnic_ib_qp_grp.h | 5 | ||||
-rw-r--r-- | drivers/infiniband/hw/usnic/usnic_ib_sysfs.c | 6 |
6 files changed, 111 insertions, 10 deletions
diff --git a/drivers/infiniband/hw/usnic/usnic_debugfs.c b/drivers/infiniband/hw/usnic/usnic_debugfs.c index 91386df025ae..6cb2e7ca7df2 100644 --- a/drivers/infiniband/hw/usnic/usnic_debugfs.c +++ b/drivers/infiniband/hw/usnic/usnic_debugfs.c | |||
@@ -22,8 +22,11 @@ | |||
22 | #include "usnic.h" | 22 | #include "usnic.h" |
23 | #include "usnic_log.h" | 23 | #include "usnic_log.h" |
24 | #include "usnic_debugfs.h" | 24 | #include "usnic_debugfs.h" |
25 | #include "usnic_ib_qp_grp.h" | ||
26 | #include "usnic_transport.h" | ||
25 | 27 | ||
26 | static struct dentry *debugfs_root; | 28 | static struct dentry *debugfs_root; |
29 | static struct dentry *flows_dentry; | ||
27 | 30 | ||
28 | static ssize_t usnic_debugfs_buildinfo_read(struct file *f, char __user *data, | 31 | static ssize_t usnic_debugfs_buildinfo_read(struct file *f, char __user *data, |
29 | size_t count, loff_t *ppos) | 32 | size_t count, loff_t *ppos) |
@@ -48,17 +51,73 @@ static const struct file_operations usnic_debugfs_buildinfo_ops = { | |||
48 | .read = usnic_debugfs_buildinfo_read | 51 | .read = usnic_debugfs_buildinfo_read |
49 | }; | 52 | }; |
50 | 53 | ||
54 | static ssize_t flowinfo_read(struct file *f, char __user *data, | ||
55 | size_t count, loff_t *ppos) | ||
56 | { | ||
57 | struct usnic_ib_qp_grp_flow *qp_flow; | ||
58 | int n; | ||
59 | int left; | ||
60 | char *ptr; | ||
61 | char buf[512]; | ||
62 | |||
63 | qp_flow = f->private_data; | ||
64 | ptr = buf; | ||
65 | left = count; | ||
66 | |||
67 | if (*ppos > 0) | ||
68 | return 0; | ||
69 | |||
70 | spin_lock(&qp_flow->qp_grp->lock); | ||
71 | n = scnprintf(ptr, left, | ||
72 | "QP Grp ID: %d Transport: %s ", | ||
73 | qp_flow->qp_grp->grp_id, | ||
74 | usnic_transport_to_str(qp_flow->trans_type)); | ||
75 | UPDATE_PTR_LEFT(n, ptr, left); | ||
76 | if (qp_flow->trans_type == USNIC_TRANSPORT_ROCE_CUSTOM) { | ||
77 | n = scnprintf(ptr, left, "Port_Num:%hu\n", | ||
78 | qp_flow->usnic_roce.port_num); | ||
79 | UPDATE_PTR_LEFT(n, ptr, left); | ||
80 | } else if (qp_flow->trans_type == USNIC_TRANSPORT_IPV4_UDP) { | ||
81 | n = usnic_transport_sock_to_str(ptr, left, | ||
82 | qp_flow->udp.sock); | ||
83 | UPDATE_PTR_LEFT(n, ptr, left); | ||
84 | n = scnprintf(ptr, left, "\n"); | ||
85 | UPDATE_PTR_LEFT(n, ptr, left); | ||
86 | } | ||
87 | spin_unlock(&qp_flow->qp_grp->lock); | ||
88 | |||
89 | return simple_read_from_buffer(data, count, ppos, buf, ptr - buf); | ||
90 | } | ||
91 | |||
92 | static const struct file_operations flowinfo_ops = { | ||
93 | .owner = THIS_MODULE, | ||
94 | .open = simple_open, | ||
95 | .read = flowinfo_read, | ||
96 | }; | ||
97 | |||
51 | void usnic_debugfs_init(void) | 98 | void usnic_debugfs_init(void) |
52 | { | 99 | { |
53 | debugfs_root = debugfs_create_dir(DRV_NAME, NULL); | 100 | debugfs_root = debugfs_create_dir(DRV_NAME, NULL); |
54 | if (IS_ERR(debugfs_root)) { | 101 | if (IS_ERR(debugfs_root)) { |
55 | usnic_err("Failed to create debugfs root dir, check if debugfs is enabled in kernel configuration\n"); | 102 | usnic_err("Failed to create debugfs root dir, check if debugfs is enabled in kernel configuration\n"); |
56 | debugfs_root = NULL; | 103 | goto out_clear_root; |
57 | return; | 104 | } |
105 | |||
106 | flows_dentry = debugfs_create_dir("flows", debugfs_root); | ||
107 | if (IS_ERR_OR_NULL(flows_dentry)) { | ||
108 | usnic_err("Failed to create debugfs flow dir with err %ld\n", | ||
109 | PTR_ERR(flows_dentry)); | ||
110 | goto out_free_root; | ||
58 | } | 111 | } |
59 | 112 | ||
60 | debugfs_create_file("build-info", S_IRUGO, debugfs_root, | 113 | debugfs_create_file("build-info", S_IRUGO, debugfs_root, |
61 | NULL, &usnic_debugfs_buildinfo_ops); | 114 | NULL, &usnic_debugfs_buildinfo_ops); |
115 | return; | ||
116 | |||
117 | out_free_root: | ||
118 | debugfs_remove_recursive(debugfs_root); | ||
119 | out_clear_root: | ||
120 | debugfs_root = NULL; | ||
62 | } | 121 | } |
63 | 122 | ||
64 | void usnic_debugfs_exit(void) | 123 | void usnic_debugfs_exit(void) |
@@ -69,3 +128,31 @@ void usnic_debugfs_exit(void) | |||
69 | debugfs_remove_recursive(debugfs_root); | 128 | debugfs_remove_recursive(debugfs_root); |
70 | debugfs_root = NULL; | 129 | debugfs_root = NULL; |
71 | } | 130 | } |
131 | |||
132 | void usnic_debugfs_flow_add(struct usnic_ib_qp_grp_flow *qp_flow) | ||
133 | { | ||
134 | struct usnic_ib_qp_grp *qp_grp; | ||
135 | |||
136 | if (IS_ERR_OR_NULL(flows_dentry)) | ||
137 | return; | ||
138 | |||
139 | qp_grp = qp_flow->qp_grp; | ||
140 | |||
141 | scnprintf(qp_flow->dentry_name, sizeof(qp_flow->dentry_name), | ||
142 | "%u", qp_flow->flow->flow_id); | ||
143 | qp_flow->dbgfs_dentry = debugfs_create_file(qp_flow->dentry_name, | ||
144 | S_IRUGO, | ||
145 | flows_dentry, | ||
146 | qp_flow, | ||
147 | &flowinfo_ops); | ||
148 | if (IS_ERR_OR_NULL(qp_flow->dbgfs_dentry)) { | ||
149 | usnic_err("Failed to create dbg fs entry for flow %u\n", | ||
150 | qp_flow->flow->flow_id); | ||
151 | } | ||
152 | } | ||
153 | |||
154 | void usnic_debugfs_flow_remove(struct usnic_ib_qp_grp_flow *qp_flow) | ||
155 | { | ||
156 | if (!IS_ERR_OR_NULL(qp_flow->dbgfs_dentry)) | ||
157 | debugfs_remove(qp_flow->dbgfs_dentry); | ||
158 | } | ||
diff --git a/drivers/infiniband/hw/usnic/usnic_debugfs.h b/drivers/infiniband/hw/usnic/usnic_debugfs.h index 914a330dd5e7..4087d24a88f6 100644 --- a/drivers/infiniband/hw/usnic/usnic_debugfs.h +++ b/drivers/infiniband/hw/usnic/usnic_debugfs.h | |||
@@ -18,8 +18,12 @@ | |||
18 | #ifndef USNIC_DEBUGFS_H_ | 18 | #ifndef USNIC_DEBUGFS_H_ |
19 | #define USNIC_DEBUGFS_H_ | 19 | #define USNIC_DEBUGFS_H_ |
20 | 20 | ||
21 | #include "usnic_ib_qp_grp.h" | ||
22 | |||
21 | void usnic_debugfs_init(void); | 23 | void usnic_debugfs_init(void); |
22 | 24 | ||
23 | void usnic_debugfs_exit(void); | 25 | void usnic_debugfs_exit(void); |
26 | void usnic_debugfs_flow_add(struct usnic_ib_qp_grp_flow *qp_flow); | ||
27 | void usnic_debugfs_flow_remove(struct usnic_ib_qp_grp_flow *qp_flow); | ||
24 | 28 | ||
25 | #endif /*!USNIC_DEBUGFS_H_ */ | 29 | #endif /*!USNIC_DEBUGFS_H_ */ |
diff --git a/drivers/infiniband/hw/usnic/usnic_ib.h b/drivers/infiniband/hw/usnic/usnic_ib.h index 92d9d9a60b3b..111a86e680d5 100644 --- a/drivers/infiniband/hw/usnic/usnic_ib.h +++ b/drivers/infiniband/hw/usnic/usnic_ib.h | |||
@@ -109,4 +109,11 @@ struct usnic_ib_mr *to_umr(struct ib_mr *ibmr) | |||
109 | return container_of(ibmr, struct usnic_ib_mr, ibmr); | 109 | return container_of(ibmr, struct usnic_ib_mr, ibmr); |
110 | } | 110 | } |
111 | void usnic_ib_log_vf(struct usnic_ib_vf *vf); | 111 | void usnic_ib_log_vf(struct usnic_ib_vf *vf); |
112 | |||
113 | #define UPDATE_PTR_LEFT(N, P, L) \ | ||
114 | do { \ | ||
115 | L -= (N); \ | ||
116 | P += (N); \ | ||
117 | } while (0) | ||
118 | |||
112 | #endif /* USNIC_IB_H_ */ | 119 | #endif /* USNIC_IB_H_ */ |
diff --git a/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c b/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c index 3e17c7c156c3..7ecc6061f1f4 100644 --- a/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c +++ b/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "usnic_vnic.h" | 24 | #include "usnic_vnic.h" |
25 | #include "usnic_fwd.h" | 25 | #include "usnic_fwd.h" |
26 | #include "usnic_uiom.h" | 26 | #include "usnic_uiom.h" |
27 | #include "usnic_debugfs.h" | ||
27 | #include "usnic_ib_qp_grp.h" | 28 | #include "usnic_ib_qp_grp.h" |
28 | #include "usnic_ib_sysfs.h" | 29 | #include "usnic_ib_sysfs.h" |
29 | #include "usnic_transport.h" | 30 | #include "usnic_transport.h" |
@@ -340,8 +341,10 @@ create_and_add_flow(struct usnic_ib_qp_grp *qp_grp, | |||
340 | return ERR_PTR(-EINVAL); | 341 | return ERR_PTR(-EINVAL); |
341 | } | 342 | } |
342 | 343 | ||
343 | if (!IS_ERR_OR_NULL(qp_flow)) | 344 | if (!IS_ERR_OR_NULL(qp_flow)) { |
344 | list_add_tail(&qp_flow->link, &qp_grp->flows_lst); | 345 | list_add_tail(&qp_flow->link, &qp_grp->flows_lst); |
346 | usnic_debugfs_flow_add(qp_flow); | ||
347 | } | ||
345 | 348 | ||
346 | 349 | ||
347 | return qp_flow; | 350 | return qp_flow; |
@@ -349,6 +352,7 @@ create_and_add_flow(struct usnic_ib_qp_grp *qp_grp, | |||
349 | 352 | ||
350 | static void release_and_remove_flow(struct usnic_ib_qp_grp_flow *qp_flow) | 353 | static void release_and_remove_flow(struct usnic_ib_qp_grp_flow *qp_flow) |
351 | { | 354 | { |
355 | usnic_debugfs_flow_remove(qp_flow); | ||
352 | list_del(&qp_flow->link); | 356 | list_del(&qp_flow->link); |
353 | 357 | ||
354 | switch (qp_flow->trans_type) { | 358 | switch (qp_flow->trans_type) { |
@@ -728,9 +732,9 @@ void usnic_ib_qp_grp_destroy(struct usnic_ib_qp_grp *qp_grp) | |||
728 | WARN_ON(qp_grp->state != IB_QPS_RESET); | 732 | WARN_ON(qp_grp->state != IB_QPS_RESET); |
729 | lockdep_assert_held(&qp_grp->vf->lock); | 733 | lockdep_assert_held(&qp_grp->vf->lock); |
730 | 734 | ||
735 | release_and_remove_all_flows(qp_grp); | ||
731 | usnic_ib_sysfs_qpn_remove(qp_grp); | 736 | usnic_ib_sysfs_qpn_remove(qp_grp); |
732 | qp_grp_and_vf_unbind(qp_grp); | 737 | qp_grp_and_vf_unbind(qp_grp); |
733 | release_and_remove_all_flows(qp_grp); | ||
734 | free_qp_grp_res(qp_grp->res_chunk_list); | 738 | free_qp_grp_res(qp_grp->res_chunk_list); |
735 | kfree(qp_grp); | 739 | kfree(qp_grp); |
736 | } | 740 | } |
diff --git a/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.h b/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.h index a8ba1b9224d8..b0aafe8db0c3 100644 --- a/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.h +++ b/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.h | |||
@@ -19,6 +19,7 @@ | |||
19 | #ifndef USNIC_IB_QP_GRP_H_ | 19 | #ifndef USNIC_IB_QP_GRP_H_ |
20 | #define USNIC_IB_QP_GRP_H_ | 20 | #define USNIC_IB_QP_GRP_H_ |
21 | 21 | ||
22 | #include <linux/debugfs.h> | ||
22 | #include <rdma/ib_verbs.h> | 23 | #include <rdma/ib_verbs.h> |
23 | 24 | ||
24 | #include "usnic_ib.h" | 25 | #include "usnic_ib.h" |
@@ -62,6 +63,10 @@ struct usnic_ib_qp_grp_flow { | |||
62 | }; | 63 | }; |
63 | struct usnic_ib_qp_grp *qp_grp; | 64 | struct usnic_ib_qp_grp *qp_grp; |
64 | struct list_head link; | 65 | struct list_head link; |
66 | |||
67 | /* Debug FS */ | ||
68 | struct dentry *dbgfs_dentry; | ||
69 | char dentry_name[32]; | ||
65 | }; | 70 | }; |
66 | 71 | ||
67 | static const struct | 72 | static const struct |
diff --git a/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c b/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c index 3e5884232342..27dc67c1689f 100644 --- a/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c +++ b/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c | |||
@@ -30,12 +30,6 @@ | |||
30 | #include "usnic_ib_verbs.h" | 30 | #include "usnic_ib_verbs.h" |
31 | #include "usnic_log.h" | 31 | #include "usnic_log.h" |
32 | 32 | ||
33 | #define UPDATE_PTR_LEFT(N, P, L) \ | ||
34 | do { \ | ||
35 | L -= (N); \ | ||
36 | P += (N); \ | ||
37 | } while (0) | ||
38 | |||
39 | static ssize_t usnic_ib_show_fw_ver(struct device *device, | 33 | static ssize_t usnic_ib_show_fw_ver(struct device *device, |
40 | struct device_attribute *attr, | 34 | struct device_attribute *attr, |
41 | char *buf) | 35 | char *buf) |