Re: [PATCH 07/24] ibtrs: client: sysfs interface functions

2018-02-06 Thread Roman Penyaev
On Mon, Feb 5, 2018 at 12:20 PM, Sagi Grimberg  wrote:
> Hi Roman,
>
>
>> This is the sysfs interface to IBTRS sessions on client side:
>>
>>/sys/kernel/ibtrs_client//
>>  *** IBTRS session created by ibtrs_clt_open() API call
>>  |
>>  |- max_reconnect_attempts
>>  |  *** number of reconnect attempts for session
>>  |
>>  |- add_path
>>  |  *** adds another connection path into IBTRS session
>>  |
>>  |- paths//
>> *** established paths to server in a session
>> |
>> |- disconnect
>> |  *** disconnect path
>> |
>> |- reconnect
>> |  *** reconnect path
>> |
>> |- remove_path
>> |  *** remove current path
>> |
>> |- state
>> |  *** retrieve current path state
>> |
>> |- stats/
>>*** current path statistics
>>|
>>   |- cpu_migration
>>   |- rdma
>>   |- rdma_lat
>>   |- reconnects
>>   |- reset_all
>>   |- sg_entries
>>   |- wc_completions
>>
>> Signed-off-by: Roman Pen 
>> Signed-off-by: Danil Kipnis 
>> Cc: Jack Wang 
>
>
> I think stats usually belong in debugfs.

I will change that.

--
Roman


Re: [PATCH 07/24] ibtrs: client: sysfs interface functions

2018-02-05 Thread Sagi Grimberg

Hi Roman,


This is the sysfs interface to IBTRS sessions on client side:

   /sys/kernel/ibtrs_client//
 *** IBTRS session created by ibtrs_clt_open() API call
 |
 |- max_reconnect_attempts
 |  *** number of reconnect attempts for session
 |
 |- add_path
 |  *** adds another connection path into IBTRS session
 |
 |- paths//
*** established paths to server in a session
|
|- disconnect
|  *** disconnect path
|
|- reconnect
|  *** reconnect path
|
|- remove_path
|  *** remove current path
|
|- state
|  *** retrieve current path state
|
|- stats/
   *** current path statistics
   |
  |- cpu_migration
  |- rdma
  |- rdma_lat
  |- reconnects
  |- reset_all
  |- sg_entries
  |- wc_completions

Signed-off-by: Roman Pen 
Signed-off-by: Danil Kipnis 
Cc: Jack Wang 


I think stats usually belong in debugfs.


[PATCH 07/24] ibtrs: client: sysfs interface functions

2018-02-02 Thread Roman Pen
This is the sysfs interface to IBTRS sessions on client side:

  /sys/kernel/ibtrs_client//
*** IBTRS session created by ibtrs_clt_open() API call
|
|- max_reconnect_attempts
|  *** number of reconnect attempts for session
|
|- add_path
|  *** adds another connection path into IBTRS session
|
|- paths//
   *** established paths to server in a session
   |
   |- disconnect
   |  *** disconnect path
   |
   |- reconnect
   |  *** reconnect path
   |
   |- remove_path
   |  *** remove current path
   |
   |- state
   |  *** retrieve current path state
   |
   |- stats/
  *** current path statistics
  |
  |- cpu_migration
  |- rdma
  |- rdma_lat
  |- reconnects
  |- reset_all
  |- sg_entries
  |- wc_completions

Signed-off-by: Roman Pen 
Signed-off-by: Danil Kipnis 
Cc: Jack Wang 
---
 drivers/infiniband/ulp/ibtrs/ibtrs-clt-sysfs.c | 519 +
 1 file changed, 519 insertions(+)

diff --git a/drivers/infiniband/ulp/ibtrs/ibtrs-clt-sysfs.c 
b/drivers/infiniband/ulp/ibtrs/ibtrs-clt-sysfs.c
new file mode 100644
index ..04949d6d796b
--- /dev/null
+++ b/drivers/infiniband/ulp/ibtrs/ibtrs-clt-sysfs.c
@@ -0,0 +1,519 @@
+/*
+ * InfiniBand Transport Layer
+ *
+ * Copyright (c) 2014 - 2017 ProfitBricks GmbH. All rights reserved.
+ * Authors: Fabian Holler 
+ *  Jack Wang 
+ *  Kleber Souza 
+ *  Danil Kipnis 
+ *  Roman Penyaev 
+ *  Milind Dumbare 
+ *
+ * Copyright (c) 2017 - 2018 ProfitBricks GmbH. All rights reserved.
+ * Authors: Danil Kipnis 
+ *  Roman Penyaev 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see .
+ */
+
+#undef pr_fmt
+#define pr_fmt(fmt) KBUILD_MODNAME " L" __stringify(__LINE__) ": " fmt
+
+#include "ibtrs-pri.h"
+#include "ibtrs-clt.h"
+#include "ibtrs-log.h"
+
+static struct kobject *ibtrs_kobj;
+
+#define MIN_MAX_RECONN_ATT -1
+#define MAX_MAX_RECONN_ATT 
+
+static struct kobj_type ktype = {
+   .sysfs_ops = _sysfs_ops,
+};
+
+static ssize_t ibtrs_clt_max_reconn_attempts_show(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ char *page)
+{
+   struct ibtrs_clt *clt;
+
+   clt = container_of(kobj, struct ibtrs_clt, kobj);
+
+   return sprintf(page, "%d\n", ibtrs_clt_get_max_reconnect_attempts(clt));
+}
+
+static ssize_t ibtrs_clt_max_reconn_attempts_store(struct kobject *kobj,
+  struct kobj_attribute *attr,
+  const char *buf,
+  size_t count)
+{
+   struct ibtrs_clt *clt;
+   int value;
+   int ret;
+
+   clt = container_of(kobj, struct ibtrs_clt, kobj);
+
+   ret = kstrtoint(buf, 10, );
+   if (unlikely(ret)) {
+   ibtrs_err(clt, "%s: failed to convert string '%s' to int\n",
+ attr->attr.name, buf);
+   return ret;
+   }
+   if (unlikely(value > MAX_MAX_RECONN_ATT ||
+value < MIN_MAX_RECONN_ATT)) {
+   ibtrs_err(clt, "%s: invalid range"
+ " (provided: '%s', accepted: min: %d, max: %d)\n",
+ attr->attr.name, buf, MIN_MAX_RECONN_ATT,
+ MAX_MAX_RECONN_ATT);
+   return -EINVAL;
+   }
+   ibtrs_clt_set_max_reconnect_attempts(clt, value);
+
+   return count;
+}
+
+static struct kobj_attribute ibtrs_clt_max_reconnect_attempts_attr =
+   __ATTR(max_reconnect_attempts, 0644,
+  ibtrs_clt_max_reconn_attempts_show,
+  ibtrs_clt_max_reconn_attempts_store);
+
+static ssize_t ibtrs_clt_mp_policy_show(struct kobject *kobj,
+   struct kobj_attribute *attr,
+   char *page)
+{
+   struct