[openfabrics-ewg] OFED 1.1 RC5
Hoang-Nam Nguyen
HNGUYEN at de.ibm.com
Wed Sep 13 09:06:27 PDT 2006
Hi,
below is libehca patch with the following changes:
- fix bug that causes wrong order of reads operations of cqe fields
- add logging config via env var
- add helper asm macros
I did commit those changes into 1.1/src/userspace/libehca.
Note that this patch is intended to be in sync with the kernel code level
SVNEHCA_0015.
We're planning to get rid of the EDEB macro and some code cleanup as we
already did for
the kernel part.
Thanks!
Nam Nguyen
PS: This should be sent as plain text only. If not, please let me know.
Thx!
Signed-off-by: Hoang-Nam Nguyen <hnguyen at de.ibm.com>
---
ehca_asm.h | 4 ++-
ehca_uinit.c | 61
+++++++++++++++++++++++++++++++++++++++++++++++------------
ehca_ureqs.c | 6 ++++-
3 files changed, 57 insertions(+), 14 deletions(-)
Index: src/ehca_asm.h
===================================================================
--- src/ehca_asm.h (revision 9350)
+++ src/ehca_asm.h (working copy)
@@ -38,7 +38,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: ehca_asm.h,v 1.1 2006/02/22 12:26:55 nguyen Exp $
+ * $Id: ehca_asm.h,v 1.2 2006/08/04 12:56:34 nguyen Exp $
*/
@@ -48,6 +48,8 @@
#if defined(CONFIG_PPC_PSERIES) || defined (__PPC64__) || defined
(__PPC__)
#define clear_cacheline(adr) __asm__ __volatile("dcbz 0,%0"::"r"(adr))
+/* rmb() in 32-bit mode does a full sync, while we need a lwsync */
+#define lwsync() __asm__ __volatile__ ("lwsync" : : : "memory")
#elif defined(CONFIG_ARCH_S390)
#error "unsupported yet"
Index: src/ehca_uinit.c
===================================================================
--- src/ehca_uinit.c (revision 9350)
+++ src/ehca_uinit.c (working copy)
@@ -191,7 +191,7 @@
char value[64];
int num_ports = 0;
- EDEB_EN(7, "");
+ EDEB_EN(7, "uverbs_sys_path=%s", uverbs_sys_path);
if (ibv_read_sysfs_file(uverbs_sys_path, "device/name",
value, sizeof value) < 0)
@@ -239,23 +239,47 @@
/** @brief module initialization
*/
-int libehca_trlevel = 5;
+int libehca_trlevel = -1;
FILE *libehca_fh = NULL;
#define LIBEHCA_DEFAULT_CFGFILE "/usr/local/libehca/etc/libehca.conf"
-#define CFG_TOKEN_TRLEVEL "log.trlevel"
+#define CFG_TOKEN_TRLEVEL "log.trlevel"
#define CFG_TOKEN_FILENAME "log.filename"
+#define CFG_VAR_TRLEVEL "LIBEHCA_LOG_LEVEL"
+#define CFG_VAR_FILENAME "LIBEHCA_LOG_FILENAME"
-void __attribute__ ((constructor)) ehcau_init(void)
+void ehcau_read_envvars(char **logfilename)
{
+ char *value;
+
+ value = getenv(CFG_VAR_TRLEVEL);
+ if (value) {
+ value = str_strip(value);
+ libehca_trlevel = *value - '0';
+ }
+
+ value = getenv(CFG_VAR_FILENAME);
+ if (value) {
+ value = str_strip(value);
+ if (*logfilename)
+ free(*logfilename);
+ *logfilename = malloc(strlen(value)+1);
+ if (*logfilename==NULL) {
+ fprintf(stderr, "Out of memory error");
+ exit(-ENOMEM);
+ }
+ strcpy(*logfilename, value);
+ }
+}
+
+void ehcau_read_configfile(char **logfilename)
+{
char *cfgfilename = LIBEHCA_DEFAULT_CFGFILE;
FILE *cfg_fh = NULL;
char linebuf[1024];
char *cur_line = NULL;
- char *logfilename = NULL;
cfg_fh = fopen(cfgfilename, "r");
if (cfg_fh == NULL) {
- libehca_trlevel = -1;
fprintf(stderr, "Could not read config file \"%s\"\n",
cfgfilename);
return;
@@ -297,17 +321,28 @@
if (*filename==0) {
continue;
}
- logfilename=malloc(strlen(filename)+1);
- if (logfilename==NULL) {
+ if (*logfilename)
+ free(*logfilename);
+ *logfilename=malloc(strlen(filename)+1);
+ if (*logfilename==NULL) {
fprintf(stderr, "Out of memory error");
exit(-ENOMEM);
}
- strcpy(logfilename, filename);
+ strcpy(*logfilename, filename);
} else { /* invalid token */
fprintf(stderr, "Invalid token \"%s\"\n", cur_line);
}
} /* eof while current_line */
fclose(cfg_fh);
+}
+
+void __attribute__ ((constructor)) ehcau_init(void)
+{
+ char *logfilename = NULL;
+
+ ehcau_read_configfile(&logfilename);
+ ehcau_read_envvars(&logfilename);
+
/* open logfile if given and found */
if (logfilename!=NULL) {
if (strcmp(logfilename, "STDOUT")==0) {
@@ -323,9 +358,11 @@
}
free(logfilename);
}
- if (libehca_fh==NULL) {
- libehca_trlevel = -1;
- } else {
+
+ if (libehca_trlevel > 0) {
+ if (libehca_fh == NULL)
+ libehca_fh = stderr;
+
fprintf(libehca_fh, "tracelevel is:%i\n", libehca_trlevel);
}
}
Index: src/ehca_ureqs.c
===================================================================
--- src/ehca_ureqs.c (revision 9350)
+++ src/ehca_ureqs.c (working copy)
@@ -39,7 +39,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: ehca_ureqs.c,v 1.5 2006/03/26 22:26:54 nguyen Exp $
+ * $Id: ehca_ureqs.c,v 1.6 2006/08/04 12:56:34 nguyen Exp $
*/
@@ -471,6 +471,10 @@
"retcode=%x", my_cq, my_cq->cq_number, retcode);
goto poll_cq_one_exit0;
}
+
+ /* prevents loads being reordered across this point */
+ lwsync();
+
cqe_count++;
if (unlikely(cqe->status & 0x10)) { /* purge bit set */
struct ehcau_qp *qp=ehca_cq_get_qp(my_cq,
cqe->local_qp_number);
More information about the ewg
mailing list