Update to odulow per maintenance bronze
[o-du/phy.git] / wls_lib / wls_lib_dpdk.c
index f05b12c..dcabfb8 100644 (file)
@@ -130,36 +130,11 @@ static inline int wls_check_ctx1(void *h)
     return 0;
 }
 
-static int wls_VirtToPhys(const void* virtAddr, uint64_t* physAddr)
+static int wls_VirtToIova(const void* virtAddr, uint64_t* iovaAddr)
 {
-    int mapFd;
-    uint64_t page;
-    unsigned int pageSize;
-    unsigned long virtualPageNumber;
-
-    mapFd = open("/proc/self/pagemap", O_RDONLY);
-    if (mapFd < 0) {
-        PLIB_ERR("Could't open pagemap file\n");
+    *iovaAddr = rte_mem_virt2iova(virtAddr);
+    if (*iovaAddr==RTE_BAD_IOVA)
         return -1;
-    }
-
-    /*get standard page size*/
-    pageSize = getpagesize();
-
-    virtualPageNumber = (unsigned long) virtAddr / pageSize;
-
-    lseek(mapFd, virtualPageNumber * sizeof (uint64_t), SEEK_SET);
-
-    if (read(mapFd, &page, sizeof (uint64_t)) < 0) {
-        close(mapFd);
-        PLIB_ERR("Could't read pagemap file\n");
-        return -1;
-    }
-
-    *physAddr = ((page & 0x007fffffffffffffULL) * pageSize);
-
-    close(mapFd);
-
     return 0;
 }
 
@@ -788,7 +763,7 @@ void* WLS_Alloc(void* h, unsigned int size)
 
     hp_memzone = (struct rte_memzone *)mng_memzone;
     pvirtAddr = (void *)hp_memzone->addr;
-    PLIB_DEBUG("pvirtAddr is %p\n", pvirtAddr);
+
     if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
         memset(pvirtAddr, 0, sizeof (wls_drv_ctx_t));
     }
@@ -801,7 +776,7 @@ void* WLS_Alloc(void* h, unsigned int size)
                                                 inorder to get pagemap*/
         *(unsigned char*) pHugePageTlb[count].pageVa = 1;
 
-        if (wls_VirtToPhys((uint64_t*) pHugePageTlb[count].pageVa,
+        if (wls_VirtToIova((uint64_t*) pHugePageTlb[count].pageVa,
                 &pHugePageTlb[count].pagePa) == -1) {
             PLIB_ERR("Virtual to physical conversion failed\n");
             return NULL;
@@ -862,6 +837,7 @@ int WLS_Put(void *h, unsigned long long pMsg, unsigned int MsgSize, unsigned sho
 {
     wls_us_ctx_t* pWls_us = (wls_us_ctx_t*) h;
     int ret = 0;
+    unsigned short nFlags = Flags & (~WLS_TF_URLLC);
 
     if (wls_check_ctx(h))
         return -1;
@@ -873,22 +849,22 @@ int WLS_Put(void *h, unsigned long long pMsg, unsigned int MsgSize, unsigned sho
 
     wls_mutex_lock(&wls_put_lock);
 
-    if ((WLS_FLAGS_MASK & Flags)) { // multi block transaction
-        if (Flags & WLS_TF_SYN) {
+    if ((WLS_FLAGS_MASK & nFlags)) { // multi block transaction
+        if (nFlags & WLS_TF_SYN) {
             PLIB_DEBUG("WLS_SG_FIRST\n");
             if (WLS_MsgEnqueue(&pWls_us->put_queue, pMsg, MsgSize, MsgTypeID,
                     Flags, NULL, (void*) pWls_us)) {
                 PLIB_DEBUG("WLS_Get %lx %d type %d\n", (U64) pMsg, MsgSize, MsgTypeID);
             }
-        } else if ((Flags & WLS_TF_SCATTER_GATHER)
-                    && !(Flags & WLS_TF_SYN)
-                    && !(Flags & WLS_TF_FIN)) {
+        } else if ((nFlags & WLS_TF_SCATTER_GATHER)
+                    && !(nFlags & WLS_TF_SYN)
+                    && !(nFlags & WLS_TF_FIN)) {
             PLIB_DEBUG("WLS_SG_NEXT\n");
             if (WLS_MsgEnqueue(&pWls_us->put_queue, pMsg, MsgSize, MsgTypeID,
                     Flags, NULL, (void*) pWls_us)) {
                 PLIB_DEBUG("WLS_Put %lx %d type %d\n", (U64) pMsg, MsgSize, MsgTypeID);
             }
-        } else if (Flags & WLS_TF_FIN) {
+        } else if (nFlags & WLS_TF_FIN) {
             if (WLS_MsgEnqueue(&pWls_us->put_queue, pMsg, MsgSize, MsgTypeID,
                     Flags, NULL, (void*) pWls_us)) {
                 PLIB_DEBUG("WLS_Put %lx %d type %d\n", (U64) pMsg, MsgSize, MsgTypeID);
@@ -903,7 +879,7 @@ int WLS_Put(void *h, unsigned long long pMsg, unsigned int MsgSize, unsigned sho
                 }
             }
         } else
-            PLIB_ERR("unsaported flags %x\n", WLS_FLAGS_MASK & Flags);
+            PLIB_ERR("unsupported flags %x\n", WLS_FLAGS_MASK & Flags);
     } else { // one block transaction
         if (WLS_MsgEnqueue(&pWls_us->put_queue, pMsg, MsgSize, MsgTypeID,
                 Flags, NULL, (void*) pWls_us)) {
@@ -932,6 +908,7 @@ int WLS_Put1(void *h, unsigned long long pMsg, unsigned int MsgSize, unsigned sh
 {
     wls_us_ctx_t* pWls_us = (wls_us_ctx_t*) h;
     int ret = 0;
+    unsigned short nFlags = Flags & (~WLS_TF_URLLC);    
 
     if (wls_check_ctx1(h))
         return -1;
@@ -943,22 +920,22 @@ int WLS_Put1(void *h, unsigned long long pMsg, unsigned int MsgSize, unsigned sh
 
     wls_mutex_lock(&wls_put_lock1);
 
-    if ((WLS_FLAGS_MASK & Flags)) { // multi block transaction
-        if (Flags & WLS_TF_SYN) {
+    if ((WLS_FLAGS_MASK & nFlags)) { // multi block transaction
+        if (nFlags & WLS_TF_SYN) {
             PLIB_DEBUG("WLS_SG_FIRST\n");
             if (WLS_MsgEnqueue(&pWls_us->put_queue, pMsg, MsgSize, MsgTypeID,
                     Flags, NULL, (void*) pWls_us)) {
                 PLIB_DEBUG("WLS_Get %lx %d type %d\n", (U64) pMsg, MsgSize, MsgTypeID);
             }
-        } else if ((Flags & WLS_TF_SCATTER_GATHER)
-                    && !(Flags & WLS_TF_SYN)
-                    && !(Flags & WLS_TF_FIN)) {
+        } else if ((nFlags & WLS_TF_SCATTER_GATHER)
+                    && !(nFlags & WLS_TF_SYN)
+                    && !(nFlags & WLS_TF_FIN)) {
             PLIB_DEBUG("WLS_SG_NEXT\n");
             if (WLS_MsgEnqueue(&pWls_us->put_queue, pMsg, MsgSize, MsgTypeID,
                     Flags, NULL, (void*) pWls_us)) {
                 PLIB_DEBUG("WLS_Put %lx %d type %d\n", (U64) pMsg, MsgSize, MsgTypeID);
             }
-        } else if (Flags & WLS_TF_FIN) {
+        } else if (nFlags & WLS_TF_FIN) {
             if (WLS_MsgEnqueue(&pWls_us->put_queue, pMsg, MsgSize, MsgTypeID,
                     Flags, NULL, (void*) pWls_us)) {
                 PLIB_DEBUG("WLS_Put %lx %d type %d\n", (U64) pMsg, MsgSize, MsgTypeID);