]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
rsocket: Use configuration files to specify default settings
authorSean Hefty <sean.hefty@intel.com>
Tue, 5 Jun 2012 22:28:18 +0000 (15:28 -0700)
committerSean Hefty <sean.hefty@intel.com>
Wed, 6 Jun 2012 18:23:41 +0000 (11:23 -0700)
Give an administrator control over the default settings
used by rsockets.  Use files under %sysconfig%/rdma/rsocket as shown:

mem_default - default size of receive buffer(s)
wmem_default - default size of send buffer(s)
sqsize_default - default size of send queue
rqsize_default - default size of receive queue
inline_default - default size of inline data

If configuration files are not available, rsockets will continue to
use internal defaults.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
src/rsocket.c

index d7344c7ebc28327c0d094c3e8259d427d0c99436..5e0e413dcda7a05e63858a57218f75dcd32138f5 100644 (file)
 #include "cma.h"
 #include "indexer.h"
 
-#define RS_INLINE 64
 #define RS_OLAP_START_SIZE 2048
 #define RS_MAX_TRANSFER 65536
-#define RS_QP_SIZE 384
 #define RS_QP_MAX_SIZE 0xFFFE
-#define RS_QP_MIN_SIZE 8
 #define RS_QP_CTRL_SIZE 4
 #define RS_CONN_RETRIES 6
 #define RS_SGL_SIZE 2
-#define RS_BUF_SIZE (1 << 17)
 static struct index_map idm;
 static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
 
+static uint16_t def_inline = 64;
+static uint16_t def_sqsize = 384;
+static uint16_t def_rqsize = 384;
+static uint32_t def_mem = (1 << 17);
+static uint32_t def_wmem = (1 << 17);
 static uint32_t polling_time = 10;
 
 /*
@@ -216,6 +217,40 @@ void rs_configure(void)
                fscanf(f, "%u", &polling_time);
                fclose(f);
        }
+
+       if ((f = fopen(RS_CONF_DIR "/inline_default", "r"))) {
+               fscanf(f, "%hu", &def_inline);
+               fclose(f);
+
+               if (def_inline < RS_MIN_INLINE)
+                       def_inline = RS_MIN_INLINE;
+       }
+
+       if ((f = fopen(RS_CONF_DIR "/sqsize_default", "r"))) {
+               fscanf(f, "%hu", &def_sqsize);
+               fclose(f);
+       }
+
+       if ((f = fopen(RS_CONF_DIR "/rqsize_default", "r"))) {
+               fscanf(f, "%hu", &def_rqsize);
+               fclose(f);
+       }
+
+       if ((f = fopen(RS_CONF_DIR "/mem_default", "r"))) {
+               fscanf(f, "%u", &def_mem);
+               fclose(f);
+
+               if (def_mem < 1)
+                       def_mem = 1;
+       }
+
+       if ((f = fopen(RS_CONF_DIR "/wmem_default", "r"))) {
+               fscanf(f, "%u", &def_wmem);
+               fclose(f);
+
+               if (def_wmem < 1)
+                       def_wmem = 1;
+       }
        init = 1;
 out:
        pthread_mutex_unlock(&mut);
@@ -264,9 +299,11 @@ static struct rsocket *rs_alloc(struct rsocket *inherited_rs)
                rs->rq_size = inherited_rs->rq_size;
                rs->ctrl_avail = inherited_rs->ctrl_avail;
        } else {
-               rs->sbuf_size = rs->rbuf_size = RS_BUF_SIZE;
-               rs->sq_inline = RS_INLINE;
-               rs->sq_size = rs->rq_size = RS_QP_SIZE;
+               rs->sbuf_size = def_wmem;
+               rs->rbuf_size = def_mem;
+               rs->sq_inline = def_inline;
+               rs->sq_size = def_sqsize;
+               rs->rq_size = def_rqsize;
                rs->ctrl_avail = RS_QP_CTRL_SIZE;
        }
        fastlock_init(&rs->slock);