ionic: map PHC state page for user space access map the PHC page to allow applications to access hardware timestamp information. Signed-off-by: Allen Hubbe <allen.hubbe@amd.com> Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
diff --git a/providers/ionic/ionic.c b/providers/ionic/ionic.c index a91fa19..6451aab 100644 --- a/providers/ionic/ionic.c +++ b/providers/ionic/ionic.c
@@ -5,6 +5,7 @@ #include <stdio.h> #include <stdlib.h> +#include <sys/mman.h> #include "ionic.h" @@ -86,6 +87,16 @@ } ctx->dbpage = ctx->dbpage_page + (resp.dbell_offset & mask); + if (resp.phc_offset) { + ctx->phc_state = mmap(NULL, IONIC_PAGE_SIZE, PROT_READ, MAP_SHARED, + cmd_fd, resp.phc_offset); + if (ctx->phc_state == MAP_FAILED) { + ctx->phc_state = NULL; + rc = errno; + goto err_phc; + } + } + pthread_mutex_init(&ctx->mut, NULL); ionic_tbl_init(&ctx->qp_tbl); @@ -98,6 +109,8 @@ verbs_debug(&ctx->vctx, "Attached to ctx %p", ctx); return &ctx->vctx; +err_phc: + ionic_unmap(ctx->dbpage_page, 1u << ctx->pg_shift); err_cmd: verbs_uninit_context(&ctx->vctx); err_ctx:
diff --git a/providers/ionic/ionic.h b/providers/ionic/ionic.h index 8a93197..2ac0959 100644 --- a/providers/ionic/ionic.h +++ b/providers/ionic/ionic.h
@@ -103,6 +103,7 @@ void *dbpage_page; uint64_t *dbpage; + struct ib_uverbs_clock_info *phc_state; pthread_mutex_t mut; struct ionic_tbl_root qp_tbl;
diff --git a/providers/ionic/ionic_verbs.c b/providers/ionic/ionic_verbs.c index b5abe74..53d22e9 100644 --- a/providers/ionic/ionic_verbs.c +++ b/providers/ionic/ionic_verbs.c
@@ -3364,6 +3364,9 @@ pthread_mutex_destroy(&ctx->mut); + if (ctx->phc_state) + munmap(ctx->phc_state, IONIC_PAGE_SIZE); + ionic_unmap(ctx->dbpage_page, 1u << ctx->pg_shift); verbs_uninit_context(&ctx->vctx);