From 46f0460602740767079c2d856134a664be45c42f Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 13 Jun 2011 12:26:51 +0000 Subject: [PATCH] ib_srpt: Export RDMA channel state to sysfs git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@3572 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index efa37f356..27e113ce0 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -3423,14 +3423,47 @@ static ssize_t show_req_lim_delta(struct kobject *kobj, return sprintf(buf, "%d\n", ch->req_lim_delta); } +static const char *get_ch_state_name(enum rdma_ch_state s) +{ + switch (s) { + case CH_CONNECTING: + return "connecting"; + case CH_LIVE: + return "live"; + case CH_DISCONNECTING: + return "disconnecting"; + case CH_DRAINING: + return "draining"; + case CH_RELEASING: + return "releasing"; + } + return "???"; +} + +static ssize_t show_ch_state(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + struct scst_session *scst_sess; + struct srpt_rdma_ch *ch; + + scst_sess = container_of(kobj, struct scst_session, sess_kobj); + ch = scst_sess_get_tgt_priv(scst_sess); + if (!ch) + return -ENOENT; + return sprintf(buf, "%s\n", get_ch_state_name(ch->state)); +} + static const struct kobj_attribute srpt_req_lim_attr = __ATTR(req_lim, S_IRUGO, show_req_lim, NULL); static const struct kobj_attribute srpt_req_lim_delta_attr = __ATTR(req_lim_delta, S_IRUGO, show_req_lim_delta, NULL); +static const struct kobj_attribute srpt_ch_state_attr = + __ATTR(ch_state, S_IRUGO, show_ch_state, NULL); static const struct attribute *srpt_sess_attrs[] = { &srpt_req_lim_attr.attr, &srpt_req_lim_delta_attr.attr, + &srpt_ch_state_attr.attr, NULL }; #endif